@copass/core
Advanced tools
+21
-8
@@ -387,3 +387,3 @@ "use strict"; | ||
| async request(path3, options = {}) { | ||
| const { method = "GET", body, rawBody, rawResponse, encryptedPayload, query, headers: extraHeaders } = options; | ||
| const { method = "GET", body, rawBody, rawResponse, encryptedPayload, query, headers: extraHeaders, signal } = options; | ||
| const session = await this.authProvider.getSession(); | ||
@@ -427,3 +427,4 @@ const headers = { | ||
| headers: ctx.headers, | ||
| body: requestBody ?? void 0 | ||
| body: requestBody ?? void 0, | ||
| signal | ||
| }); | ||
@@ -474,3 +475,3 @@ if (!response.ok) { | ||
| async streamRequest(path3, options = {}) { | ||
| const { method = "POST", body, rawBody, query, headers: extraHeaders } = options; | ||
| const { method = "POST", body, rawBody, query, headers: extraHeaders, signal } = options; | ||
| const session = await this.authProvider.getSession(); | ||
@@ -512,3 +513,4 @@ const headers = { | ||
| headers: ctx.headers, | ||
| body: requestBody ?? void 0 | ||
| body: requestBody ?? void 0, | ||
| signal | ||
| }); | ||
@@ -1130,2 +1132,6 @@ if (!response.ok) { | ||
| try { | ||
| await reader.cancel(); | ||
| } catch { | ||
| } | ||
| try { | ||
| reader.releaseLock(); | ||
@@ -1175,9 +1181,16 @@ } catch { | ||
| * frame the server emits. Loop until you see `agent_finish` (or | ||
| * `agent_error` — terminal). Break out early to cancel the | ||
| * stream; the server marks the run `cancelled`. | ||
| * `agent_error` — terminal). | ||
| * | ||
| * Cancellation: pass an `AbortSignal` via `options.signal` and call | ||
| * `controller.abort()` to interrupt. The signal aborts the | ||
| * underlying `fetch`, the server detects the disconnect via | ||
| * `asyncio.CancelledError`, and the run row is marked `cancelled`. | ||
| * Breaking out of the iterator alone is not enough — without a | ||
| * signal, the TCP connection stays open and the agent keeps running | ||
| * server-side. | ||
| */ | ||
| async *chat(sandboxId, request) { | ||
| async *chat(sandboxId, request, options = {}) { | ||
| const response = await this.http.streamRequest( | ||
| `${conciergeBase(sandboxId)}/chat`, | ||
| { method: "POST", body: request } | ||
| { method: "POST", body: request, signal: options.signal } | ||
| ); | ||
@@ -1184,0 +1197,0 @@ for await (const frame of parseSSE(response)) { |
+21
-8
@@ -301,3 +301,3 @@ // src/auth/api-key.ts | ||
| async request(path3, options = {}) { | ||
| const { method = "GET", body, rawBody, rawResponse, encryptedPayload, query, headers: extraHeaders } = options; | ||
| const { method = "GET", body, rawBody, rawResponse, encryptedPayload, query, headers: extraHeaders, signal } = options; | ||
| const session = await this.authProvider.getSession(); | ||
@@ -341,3 +341,4 @@ const headers = { | ||
| headers: ctx.headers, | ||
| body: requestBody ?? void 0 | ||
| body: requestBody ?? void 0, | ||
| signal | ||
| }); | ||
@@ -388,3 +389,3 @@ if (!response.ok) { | ||
| async streamRequest(path3, options = {}) { | ||
| const { method = "POST", body, rawBody, query, headers: extraHeaders } = options; | ||
| const { method = "POST", body, rawBody, query, headers: extraHeaders, signal } = options; | ||
| const session = await this.authProvider.getSession(); | ||
@@ -426,3 +427,4 @@ const headers = { | ||
| headers: ctx.headers, | ||
| body: requestBody ?? void 0 | ||
| body: requestBody ?? void 0, | ||
| signal | ||
| }); | ||
@@ -1044,2 +1046,6 @@ if (!response.ok) { | ||
| try { | ||
| await reader.cancel(); | ||
| } catch { | ||
| } | ||
| try { | ||
| reader.releaseLock(); | ||
@@ -1089,9 +1095,16 @@ } catch { | ||
| * frame the server emits. Loop until you see `agent_finish` (or | ||
| * `agent_error` — terminal). Break out early to cancel the | ||
| * stream; the server marks the run `cancelled`. | ||
| * `agent_error` — terminal). | ||
| * | ||
| * Cancellation: pass an `AbortSignal` via `options.signal` and call | ||
| * `controller.abort()` to interrupt. The signal aborts the | ||
| * underlying `fetch`, the server detects the disconnect via | ||
| * `asyncio.CancelledError`, and the run row is marked `cancelled`. | ||
| * Breaking out of the iterator alone is not enough — without a | ||
| * signal, the TCP connection stays open and the agent keeps running | ||
| * server-side. | ||
| */ | ||
| async *chat(sandboxId, request) { | ||
| async *chat(sandboxId, request, options = {}) { | ||
| const response = await this.http.streamRequest( | ||
| `${conciergeBase(sandboxId)}/chat`, | ||
| { method: "POST", body: request } | ||
| { method: "POST", body: request, signal: options.signal } | ||
| ); | ||
@@ -1098,0 +1111,0 @@ for await (const frame of parseSSE(response)) { |
+2
-2
| { | ||
| "name": "@copass/core", | ||
| "version": "0.3.2", | ||
| "version": "0.3.3", | ||
| "description": "Core client SDK for the Copass platform", | ||
@@ -64,3 +64,3 @@ "publishConfig": { | ||
| }, | ||
| "gitHead": "ceb95cbf4a629fc07cfa71abf84612e4b958a9ce" | ||
| "gitHead": "95d36e21da93ab35e112fab4dacc4134ed8b488c" | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
535116
0.98%5359
0.81%