glm-acp-agent 1.13.0 → 1.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +13 -1
  2. package/dist/llm/glm-client.d.ts +61 -0
  3. package/dist/llm/glm-client.d.ts.map +1 -1
  4. package/dist/llm/glm-client.js +277 -60
  5. package/dist/llm/glm-client.js.map +1 -1
  6. package/dist/protocol/agent.d.ts +10 -1
  7. package/dist/protocol/agent.d.ts.map +1 -1
  8. package/dist/protocol/agent.js +364 -91
  9. package/dist/protocol/agent.js.map +1 -1
  10. package/dist/protocol/context-budget.d.ts.map +1 -1
  11. package/dist/protocol/context-budget.js +5 -1
  12. package/dist/protocol/context-budget.js.map +1 -1
  13. package/dist/protocol/session-store.d.ts +7 -1
  14. package/dist/protocol/session-store.d.ts.map +1 -1
  15. package/dist/protocol/session-store.js +51 -12
  16. package/dist/protocol/session-store.js.map +1 -1
  17. package/dist/tools/executor.d.ts +8 -0
  18. package/dist/tools/executor.d.ts.map +1 -1
  19. package/dist/tools/executor.js +95 -35
  20. package/dist/tools/executor.js.map +1 -1
  21. package/dist/tools/file-reader.d.ts +2 -0
  22. package/dist/tools/file-reader.d.ts.map +1 -1
  23. package/dist/tools/file-reader.js +62 -5
  24. package/dist/tools/file-reader.js.map +1 -1
  25. package/dist/tools/mcp-http-response.d.ts +29 -0
  26. package/dist/tools/mcp-http-response.d.ts.map +1 -0
  27. package/dist/tools/mcp-http-response.js +194 -0
  28. package/dist/tools/mcp-http-response.js.map +1 -0
  29. package/dist/tools/session-mcp-client.d.ts +3 -1
  30. package/dist/tools/session-mcp-client.d.ts.map +1 -1
  31. package/dist/tools/session-mcp-client.js +42 -42
  32. package/dist/tools/session-mcp-client.js.map +1 -1
  33. package/dist/tools/vision-mcp-client.d.ts +1 -0
  34. package/dist/tools/vision-mcp-client.d.ts.map +1 -1
  35. package/dist/tools/vision-mcp-client.js +39 -6
  36. package/dist/tools/vision-mcp-client.js.map +1 -1
  37. package/dist/tools/zai-mcp-client.d.ts +3 -1
  38. package/dist/tools/zai-mcp-client.d.ts.map +1 -1
  39. package/dist/tools/zai-mcp-client.js +31 -51
  40. package/dist/tools/zai-mcp-client.js.map +1 -1
  41. package/package.json +3 -1
package/README.md CHANGED
@@ -97,7 +97,7 @@ The agent does not run tools inside an OS or container sandbox. Shell commands a
97
97
  |------|---------|---------------------|-------------|
98
98
  | `read_file` | ACP client when both fs read/write capabilities are advertised, otherwise agent process | Always silent | Read a text file or editor buffer, paginated by offset/limit (default 2000 lines, capped at 5000). Local scans are byte-bounded; totals can be unknown and an incomplete line is never given a next offset. |
99
99
  | `write_file` | Agent process (ACP client `fs` when advertised) | Mode-dependent | Write or overwrite a text file. Silent in `accept_edits` and `bypass_permissions`. |
100
- | `edit_file` | Agent process (ACP client `fs` when advertised) | Mode-dependent | Replace one exact, unique snippet in an existing file. It refuses an input or editor buffer over the read/edit budget, and re-validates after permission so concurrent edits are not overwritten. Silent in `accept_edits` and `bypass_permissions`. |
100
+ | `edit_file` | Agent process (ACP client `fs` when advertised) | Mode-dependent | Replace one exact, unique snippet in an existing file. It refuses an input or editor buffer over the read/edit budget, and re-validates after permission and progress notification delivery to preserve changes present at the final read. Silent in `accept_edits` and `bypass_permissions`. |
101
101
  | `todowrite` | Agent process | Always silent | Create or replace the session's structured task list so multi-step progress is tracked instead of narrated in chat. Each call replaces the list; the tool result renders it back to the model. |
102
102
  | `list_files` | Agent process | Always silent | List a directory through a bounded iterator; a truncated result is a disclosed subset. |
103
103
  | `run_command` | Agent process | Mode-dependent | Run an arbitrary shell command; cancelling a turn terminates its shell process group, while intentionally backgrounded processes survive a normal shell exit. Silent only in `bypass_permissions`. |
@@ -105,6 +105,8 @@ The agent does not run tools inside an OS or container sandbox. Shell commands a
105
105
  | `web_reader` | Agent (Z.AI Coding Plan MCP) | Always silent | Fetch and parse a web page (markdown or plain text) |
106
106
  | `image_analysis` | Agent (Z.AI Vision MCP, stdio) | Always silent | Analyze a local image path or remote URL using `@z_ai/mcp-server` |
107
107
 
108
+ Editor edits use an optimistic read followed by a full-buffer write. ACP's `fs/write_text_file` request has no version precondition, so edits made during that write RPC can still race with the replacement. The final read preserves unrelated changes already present and rejects a target snippet that has disappeared or become ambiguous.
109
+
108
110
  ### Session Modes
109
111
 
110
112
  Clients can use `session/set_mode` to drive the permission policy:
@@ -255,6 +257,12 @@ When the model name matches `glm-4.5`, `glm-4.6`, `glm-4.7`, or the `glm-5` fami
255
257
 
256
258
  The provider stream itself is guarded against stalls. The Z.AI SDK's HTTP timeout only covers waiting for response headers — a response whose body stops mid-stream would otherwise hang the turn forever. The agent therefore aborts a provider stream read that produces no data for `ACP_GLM_STREAM_IDLE_TIMEOUT_MS` milliseconds (default `300000`; invalid values for the variable fall back to the default with a stderr warning). On timeout, whatever partial output already reached the user is kept, an `[error]` message is appended as an agent message, the turn ends, and the last valid on-disk session checkpoint is preserved. A slow ACP client back-pressuring chunks it already received does not trip the watchdog — only silence from the provider between reads does.
257
259
 
260
+ A dropped network connection is handled separately from a stall. Each provider client has its own connection pool. When a request fails before an HTTP status arrives (`APIConnectionError`, including a connection timeout, or a socket error such as `ECONNRESET`), the agent closes that pool once nothing is still sending on it, and later requests open another. A retry another session already started follows that replacement, so closing the old pool does not fail the retry locally. The OpenAI client retries a failed open twice (`maxRetries: 2`). Those same two retries cover HTTP 408, 409, 429, and 5xx. The agent does not wrap the client in a second retry loop. If the link is still down after that budget, the turn ends with `stopReason: "cancelled"` instead of a JSON-RPC internal error, and the session stays open. A turn that produced no assistant text or tool result drops that user message and asks for it to be sent again. Assistant text or a tool result that already arrived is kept. The next message continues the same session on a new connection. An HTTP status such as 400 or 401 fails the turn.
261
+
262
+ A socket reset after response bytes have started is not retried. That turn still ends with `stopReason: "cancelled"` and a connection-lost notice, and the text or tool result already in the session stays there. The idle-stream watchdog and an incomplete tool-call stream still fail the turn with an error and leave the previous checkpoint in place.
263
+
264
+ Cancelling a turn keeps the user's prompt whether or not the history was compacted for that request. When compaction already ran and the cancelled turn produced no reply, the pre-compaction messages are restored and the prompt stays, so the saved checkpoint still contains the earlier exchange. A connection drop with no reply is the path that removes the unsent prompt.
265
+
258
266
  #### Thought level (reasoning effort)
259
267
 
260
268
  The agent advertises a `thought_level` [SessionConfigOption](https://agentclientprotocol.com) so clients that support config options (e.g. a "Thinking" selector) can control reasoning effort per session. The available levels depend on the active model:
@@ -469,6 +477,7 @@ src/
469
477
  ├── credentials.test.ts # Credential resolution and --setup persistence
470
478
  ├── executor.test.ts # Tests for ToolExecutor
471
479
  ├── glm-client.test.ts # Tests for streaming / tool-call assembly
480
+ ├── transport-recovery.test.ts # Connection-loss retry and session recovery
472
481
  ├── slash-commands.test.ts # Command discovery and `/name` expansion
473
482
  └── integration.test.ts # End-to-end tests over the real ACP ndjson transport
474
483
  ```
@@ -495,6 +504,7 @@ The test suite covers:
495
504
  - Permission flows for `write_file` and `run_command` (allow / reject / cancel)
496
505
  - Shell-quoted argument handling for `list_files` and `run_command`
497
506
  - GLM streaming: text deltas, `reasoning_content` deltas, multi-chunk tool-call assembly, and trailing usage
507
+ - Connection loss: one retry budget for a dropped open and for HTTP 408/409/429/5xx, a cancelled turn, an unanswered prompt dropped, partial text or a tool result kept, and the same session accepting the next prompt
498
508
  - Image preprocessing through a mocked Vision MCP client and graceful degradation on Vision MCP failures
499
509
 
500
510
  ---
@@ -503,6 +513,8 @@ The test suite covers:
503
513
 
504
514
  - **`No API key found.`** — either set `Z_AI_API_KEY` in the environment, or run `glm-acp-agent --setup` (or `node dist/index.js --setup` from a source clone) once to store the key on disk.
505
515
  - **`HTTP 401: Invalid API key`** — your key is wrong or expired; rotate it on <https://z.ai/manage-apikey/apikey-list>.
516
+ - **`Connection lost. Send the message again when you are back online.`** — the link to Z.AI dropped before this turn produced a reply. The session is still open. Send the prompt again once the network is back.
517
+ - **`Connection lost. Send a message to continue.`** — the link dropped after this turn already produced assistant text or a tool result. That work is still in the session. Send another message to continue.
506
518
  - **Writes or commands never get to run.** — make sure your ACP client supports `session/request_permission` and that you approve the prompt for the specific tool call.
507
519
 
508
520
  ---
@@ -77,6 +77,24 @@ export interface StreamChatOptions {
77
77
  export declare class ModelStreamIdleTimeoutError extends Error {
78
78
  name: string;
79
79
  }
80
+ /**
81
+ * Retries on one provider request. This is the OpenAI client's `maxRetries`:
82
+ * the initial open plus two retries, for connection failures and for HTTP
83
+ * 408, 409, 429, and 5xx. There is no second loop around the client — that
84
+ * would run this policy again on every open.
85
+ */
86
+ export declare const PROVIDER_MAX_RETRIES = 2;
87
+ /**
88
+ * A provider call failed before any HTTP status arrived.
89
+ *
90
+ * `APIConnectionError` is the OpenAI SDK's message for that case ("Connection
91
+ * error."). A socket reset while the body is already streaming surfaces as the
92
+ * raw cause code instead, and still means this client should not be reused.
93
+ * An error that carries an HTTP status is a provider response, not a drop.
94
+ * Status is checked first: `APIConnectionError` is an `APIError` and can
95
+ * carry a numeric `status`, and that response must not be treated as a drop.
96
+ */
97
+ export declare function isRecoverableTransportError(err: unknown): boolean;
80
98
  /** Default GLM model when neither client nor user has chosen one. */
81
99
  export declare const DEFAULT_MODEL = "glm-5.3";
82
100
  /**
@@ -104,13 +122,56 @@ export declare function getDefaultModel(): string;
104
122
  * so no Zhipu-specific SDK is required. The Z.AI service speaks the OpenAI
105
123
  * Chat Completions wire format, plus a few GLM-specific extras (like the
106
124
  * `thinking` field and `delta.reasoning_content` for reasoning tokens).
125
+ *
126
+ * Each instance owns an undici connection pool. `new OpenAI({ apiKey, baseURL })`
127
+ * alone uses `globalThis.fetch` and Node's shared pool, so replacing the
128
+ * wrapper would not open a new connection. After a dropped connection the
129
+ * next request uses a new pool immediately. Every attempt, including an SDK
130
+ * retry that was already waiting, resolves that live pool. The previous pool
131
+ * is closed once its own fetches have returned, so a response another session
132
+ * is still reading can finish; it is not destroyed, which would abort that read.
107
133
  */
108
134
  export declare class GlmClient {
109
135
  private client;
136
+ private dispatcher;
137
+ /** Fetches currently inside each pool. A retired pool closes at zero. */
138
+ private readonly pools;
139
+ private readonly baseURL;
110
140
  private maxTokens;
111
141
  /** Resolved once at construction; later env changes cannot affect a running client. */
112
142
  private readonly streamIdleTimeoutMs;
113
143
  constructor();
144
+ /**
145
+ * Build a new HTTP client with its own connection pool. Called at startup
146
+ * and after a transport failure so the next request cannot reuse a socket
147
+ * from the pool that just failed.
148
+ */
149
+ private buildClient;
150
+ /**
151
+ * Route later requests to a new pool immediately. Fetches already on the
152
+ * previous pool finish there; the pool is closed when the last of them
153
+ * returns, so a body still being read is not aborted. One GlmClient is
154
+ * shared by every session, and destroy() would abort the healthy ones
155
+ * with `TypeError: terminated`. If a replacement cannot be built, the
156
+ * current client stays.
157
+ */
158
+ private discardTransport;
159
+ /** A pool that never served a request can be torn down immediately. */
160
+ private destroyDispatcher;
161
+ /**
162
+ * Count this attempt against the pool it will actually use. The OpenAI
163
+ * client sleeps between retries with no request on the wire; those later
164
+ * attempts must take the replacement pool instead of one already closed.
165
+ */
166
+ private fetchUsingLivePool;
167
+ /**
168
+ * Stop new requests on a pool and let the ones already running finish.
169
+ * Not awaited: the session that hit the failure must not wait for every
170
+ * other session still reading this pool. A pool that still has a fetch
171
+ * in progress stays open until that fetch returns.
172
+ */
173
+ private closePoolIfIdle;
174
+ private fetchWithDispatcher;
114
175
  /** The same resolved reservation used in the outgoing `max_tokens` field. */
115
176
  getMaxOutputTokens(): number;
116
177
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"glm-client.d.ts","sourceRoot":"","sources":["../../src/llm/glm-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mCAAmC,EAAE,0BAA0B,EAAsB,MAAM,2BAA2B,CAAC;AACrI,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAoB,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAKhF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,YAAY,GACpB,MAAM,GAC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AmB;IAsBjC,6EAA6E;IAC7E,kBAAkB,IAAI,MAAM;IAI5B;;;;;;OAMG;IACI,UAAU,CACf,QAAQ,EAAE,UAAU,EAAE,EACtB,MAAM,CAAC,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,cAAc,CAAC,cAAc,CAAC;CA8KlC;AAwGD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,YAAY,GACpB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA0CzB"}
@@ -1,4 +1,5 @@
1
1
  import OpenAI from "openai";
2
+ import { Agent, fetch as undiciFetch } from "undici";
2
3
  import { TOOL_DEFINITIONS } from "../tools/definitions.js";
3
4
  import { resolveApiKey } from "./credentials.js";
4
5
  import { debug, error, warn } from "./logger.js";
@@ -93,6 +94,90 @@ export function resolveThoughtLevel(model, level) {
93
94
  export class ModelStreamIdleTimeoutError extends Error {
94
95
  name = "ModelStreamIdleTimeoutError";
95
96
  }
97
+ /**
98
+ * Retries on one provider request. This is the OpenAI client's `maxRetries`:
99
+ * the initial open plus two retries, for connection failures and for HTTP
100
+ * 408, 409, 429, and 5xx. There is no second loop around the client — that
101
+ * would run this policy again on every open.
102
+ */
103
+ export const PROVIDER_MAX_RETRIES = 2;
104
+ const TRANSPORT_CAUSE_CODES = new Set([
105
+ "ECONNRESET",
106
+ "ECONNREFUSED",
107
+ "ETIMEDOUT",
108
+ "ENOTFOUND",
109
+ "EAI_AGAIN",
110
+ "EPIPE",
111
+ "UND_ERR_SOCKET",
112
+ "UND_ERR_CONNECT_TIMEOUT",
113
+ "UND_ERR_HEADERS_TIMEOUT",
114
+ "UND_ERR_BODY_TIMEOUT",
115
+ ]);
116
+ /**
117
+ * A provider call failed before any HTTP status arrived.
118
+ *
119
+ * `APIConnectionError` is the OpenAI SDK's message for that case ("Connection
120
+ * error."). A socket reset while the body is already streaming surfaces as the
121
+ * raw cause code instead, and still means this client should not be reused.
122
+ * An error that carries an HTTP status is a provider response, not a drop.
123
+ * Status is checked first: `APIConnectionError` is an `APIError` and can
124
+ * carry a numeric `status`, and that response must not be treated as a drop.
125
+ */
126
+ export function isRecoverableTransportError(err) {
127
+ if (!err || typeof err !== "object")
128
+ return false;
129
+ if (numericHttpStatus(err) !== undefined)
130
+ return false;
131
+ if (err instanceof OpenAI.APIConnectionError)
132
+ return true;
133
+ let current = err;
134
+ for (let depth = 0; depth < 6 && current && typeof current === "object"; depth++) {
135
+ if (numericHttpStatus(current) !== undefined)
136
+ return false;
137
+ const code = current.code;
138
+ if (typeof code === "string" && TRANSPORT_CAUSE_CODES.has(code))
139
+ return true;
140
+ current = current.cause;
141
+ }
142
+ return false;
143
+ }
144
+ function numericHttpStatus(err) {
145
+ if (!("status" in err))
146
+ return undefined;
147
+ const status = err.status;
148
+ return typeof status === "number" ? status : undefined;
149
+ }
150
+ function readRetryCount(init) {
151
+ const raw = headerValue(init?.headers, "x-stainless-retry-count");
152
+ const parsed = raw === undefined ? Number.NaN : Number(raw);
153
+ return Number.isInteger(parsed) && parsed >= 0 ? parsed : 0;
154
+ }
155
+ function headerValue(headers, name) {
156
+ if (!headers)
157
+ return undefined;
158
+ if (headers instanceof Headers)
159
+ return headers.get(name) ?? undefined;
160
+ if (Array.isArray(headers)) {
161
+ const found = headers.find(([key]) => key.toLowerCase() === name);
162
+ return found?.[1];
163
+ }
164
+ const record = headers;
165
+ return record[name] ?? record[name.toLowerCase()];
166
+ }
167
+ function transportCauseCode(err) {
168
+ let current = err;
169
+ for (let depth = 0; depth < 6 && current && typeof current === "object"; depth++) {
170
+ const code = current.code;
171
+ if (typeof code === "string" && code.length > 0)
172
+ return code;
173
+ current = current.cause;
174
+ }
175
+ return undefined;
176
+ }
177
+ /** Statuses the OpenAI client retries when `maxRetries` is still remaining. */
178
+ function isSdkRetryableStatus(status) {
179
+ return status === 408 || status === 409 || status === 429 || status >= 500;
180
+ }
96
181
  /** Default base URL for the Z.AI / Zhipu OpenAI-compatible API (Coding endpoint). */
97
182
  const DEFAULT_BASE_URL = "https://api.z.ai/api/coding/paas/v4";
98
183
  const DEFAULT_STREAM_IDLE_TIMEOUT_MS = 300_000;
@@ -202,18 +287,26 @@ export function getDefaultModel() {
202
287
  * so no Zhipu-specific SDK is required. The Z.AI service speaks the OpenAI
203
288
  * Chat Completions wire format, plus a few GLM-specific extras (like the
204
289
  * `thinking` field and `delta.reasoning_content` for reasoning tokens).
290
+ *
291
+ * Each instance owns an undici connection pool. `new OpenAI({ apiKey, baseURL })`
292
+ * alone uses `globalThis.fetch` and Node's shared pool, so replacing the
293
+ * wrapper would not open a new connection. After a dropped connection the
294
+ * next request uses a new pool immediately. Every attempt, including an SDK
295
+ * retry that was already waiting, resolves that live pool. The previous pool
296
+ * is closed once its own fetches have returned, so a response another session
297
+ * is still reading can finish; it is not destroyed, which would abort that read.
205
298
  */
206
299
  export class GlmClient {
207
300
  client;
301
+ dispatcher;
302
+ /** Fetches currently inside each pool. A retired pool closes at zero. */
303
+ pools = new Map();
304
+ baseURL;
208
305
  maxTokens;
209
306
  /** Resolved once at construction; later env changes cannot affect a running client. */
210
307
  streamIdleTimeoutMs;
211
308
  constructor() {
212
- const apiKey = resolveApiKey();
213
- if (!apiKey) {
214
- throw new Error("No API key found. Set the Z_AI_API_KEY environment variable, or run `glm-acp-agent --setup` to store one.");
215
- }
216
- const baseURL = process.env["ACP_GLM_BASE_URL"] ?? DEFAULT_BASE_URL;
309
+ this.baseURL = process.env["ACP_GLM_BASE_URL"] ?? DEFAULT_BASE_URL;
217
310
  // 32768 leaves room for whole-file writes and GLM thinking tokens in the
218
311
  // same turn; reasoning counts against this cap, so a small value starves
219
312
  // the actual content and trips finish_reason=length ("output limit
@@ -223,7 +316,116 @@ export class GlmClient {
223
316
  // StreamChatOptions.idleTimeoutMs). Resolved once at construction so
224
317
  // env re-reads cannot change behaviour mid-session.
225
318
  this.streamIdleTimeoutMs = parseIntEnv("ACP_GLM_STREAM_IDLE_TIMEOUT_MS", DEFAULT_STREAM_IDLE_TIMEOUT_MS);
226
- this.client = new OpenAI({ apiKey, baseURL });
319
+ const transport = this.buildClient();
320
+ this.client = transport.client;
321
+ this.dispatcher = transport.dispatcher;
322
+ }
323
+ /**
324
+ * Build a new HTTP client with its own connection pool. Called at startup
325
+ * and after a transport failure so the next request cannot reuse a socket
326
+ * from the pool that just failed.
327
+ */
328
+ buildClient() {
329
+ const apiKey = resolveApiKey();
330
+ if (!apiKey) {
331
+ throw new Error("No API key found. Set the Z_AI_API_KEY environment variable, or run `glm-acp-agent --setup` to store one.");
332
+ }
333
+ const dispatcher = new Agent();
334
+ try {
335
+ const client = new OpenAI({
336
+ apiKey,
337
+ baseURL: this.baseURL,
338
+ maxRetries: PROVIDER_MAX_RETRIES,
339
+ // Resolve the dispatcher on each attempt. The SDK retries through this
340
+ // same function, including after another session has replaced the pool.
341
+ fetch: (input, init) => this.fetchUsingLivePool(input, init),
342
+ });
343
+ this.pools.set(dispatcher, { inflight: 0, retired: false, closed: false });
344
+ return { client, dispatcher };
345
+ }
346
+ catch (err) {
347
+ void this.destroyDispatcher(dispatcher);
348
+ throw err;
349
+ }
350
+ }
351
+ /**
352
+ * Route later requests to a new pool immediately. Fetches already on the
353
+ * previous pool finish there; the pool is closed when the last of them
354
+ * returns, so a body still being read is not aborted. One GlmClient is
355
+ * shared by every session, and destroy() would abort the healthy ones
356
+ * with `TypeError: terminated`. If a replacement cannot be built, the
357
+ * current client stays.
358
+ */
359
+ discardTransport() {
360
+ const previousClient = this.client;
361
+ const previousDispatcher = this.dispatcher;
362
+ try {
363
+ const next = this.buildClient();
364
+ this.client = next.client;
365
+ this.dispatcher = next.dispatcher;
366
+ const previous = this.pools.get(previousDispatcher);
367
+ if (previous)
368
+ previous.retired = true;
369
+ this.closePoolIfIdle(previousDispatcher);
370
+ }
371
+ catch (err) {
372
+ this.client = previousClient;
373
+ this.dispatcher = previousDispatcher;
374
+ warn(`could not replace the provider client after a connection failure; keeping the existing client: ${err instanceof Error ? err.message : String(err)}`);
375
+ }
376
+ }
377
+ /** A pool that never served a request can be torn down immediately. */
378
+ destroyDispatcher(dispatcher) {
379
+ return dispatcher.destroy(new Error("discarded provider connection")).catch((err) => {
380
+ warn(`could not close the discarded provider connection: ${err instanceof Error ? err.message : String(err)}`);
381
+ });
382
+ }
383
+ /**
384
+ * Count this attempt against the pool it will actually use. The OpenAI
385
+ * client sleeps between retries with no request on the wire; those later
386
+ * attempts must take the replacement pool instead of one already closed.
387
+ */
388
+ fetchUsingLivePool(input, init) {
389
+ const dispatcher = this.dispatcher;
390
+ const state = this.pools.get(dispatcher);
391
+ if (!state)
392
+ return this.fetchWithDispatcher(dispatcher, input, init);
393
+ state.inflight += 1;
394
+ return this.fetchWithDispatcher(dispatcher, input, init).finally(() => {
395
+ state.inflight -= 1;
396
+ this.closePoolIfIdle(dispatcher);
397
+ });
398
+ }
399
+ /**
400
+ * Stop new requests on a pool and let the ones already running finish.
401
+ * Not awaited: the session that hit the failure must not wait for every
402
+ * other session still reading this pool. A pool that still has a fetch
403
+ * in progress stays open until that fetch returns.
404
+ */
405
+ closePoolIfIdle(dispatcher) {
406
+ const state = this.pools.get(dispatcher);
407
+ if (!state || !state.retired || state.closed || state.inflight > 0)
408
+ return;
409
+ state.closed = true;
410
+ this.pools.delete(dispatcher);
411
+ void dispatcher.close().catch((err) => {
412
+ warn(`could not close the discarded provider connection: ${err instanceof Error ? err.message : String(err)}`);
413
+ });
414
+ }
415
+ async fetchWithDispatcher(dispatcher, input, init) {
416
+ const attempt = readRetryCount(init) + 1;
417
+ try {
418
+ const response = await undiciFetch(input, { ...init, dispatcher });
419
+ if (!response.ok && isSdkRetryableStatus(response.status)) {
420
+ warn(`provider request attempt ${attempt} failed: status=${response.status}`);
421
+ }
422
+ return response;
423
+ }
424
+ catch (err) {
425
+ const code = transportCauseCode(err);
426
+ warn(`provider request attempt ${attempt} failed: code=${code ?? "unknown"}`);
427
+ throw err;
428
+ }
227
429
  }
228
430
  /** The same resolved reservation used in the outgoing `max_tokens` field. */
229
431
  getMaxOutputTokens() {
@@ -251,6 +453,10 @@ export class GlmClient {
251
453
  // The OpenAI SDK forwards unknown extra body fields verbatim, so we use
252
454
  // that to pass GLM-specific fields like `thinking` and `reasoning_effort`.
253
455
  const extraBody = { ...thinkingParams };
456
+ // One retry policy, on the client: connection errors and HTTP 408/409/429/5xx
457
+ // share `PROVIDER_MAX_RETRIES`. A body that has already started is outside
458
+ // that loop; a mid-stream socket reset discards the pool below and is not
459
+ // opened again.
254
460
  let stream;
255
461
  try {
256
462
  stream = await this.client.chat.completions.create({
@@ -266,6 +472,10 @@ export class GlmClient {
266
472
  }, { signal });
267
473
  }
268
474
  catch (err) {
475
+ // Replace the client after the retry budget is spent, so a later prompt
476
+ // in this same process does not reuse the pool that just failed.
477
+ if (isRecoverableTransportError(err))
478
+ this.discardTransport();
269
479
  const status = err?.status;
270
480
  const body = err?.error;
271
481
  error(`streamChat request failed: status=${status}`, JSON.stringify(body) ?? String(err));
@@ -280,68 +490,75 @@ export class GlmClient {
280
490
  const pendingToolCalls = new Map();
281
491
  let lastFinishReason;
282
492
  let terminalChoiceSeen = false;
283
- for await (const rawChunk of idleBoundedStream) {
284
- const chunk = rawChunk;
285
- if (chunk.choices.length > 1) {
286
- throw new IncompleteModelStreamError("Incomplete model stream: received multiple model choices for one completion.");
287
- }
288
- if (terminalChoiceSeen && chunk.choices.length > 0) {
289
- throw new IncompleteModelStreamError("Incomplete model stream: received a model frame after terminal completion.");
290
- }
291
- const choice = chunk.choices[0];
292
- if (choice) {
293
- const delta = choice.delta;
294
- // Reasoning / thinking tokens (GLM "thinking" mode).
295
- const reasoning = delta["reasoning_content"];
296
- if (typeof reasoning === "string" && reasoning.length > 0) {
297
- yield { thinking: reasoning };
493
+ try {
494
+ for await (const rawChunk of idleBoundedStream) {
495
+ const chunk = rawChunk;
496
+ if (chunk.choices.length > 1) {
497
+ throw new IncompleteModelStreamError("Incomplete model stream: received multiple model choices for one completion.");
298
498
  }
299
- // Regular assistant text.
300
- const content = delta["content"];
301
- if (typeof content === "string" && content.length > 0) {
302
- yield { text: content };
499
+ if (terminalChoiceSeen && chunk.choices.length > 0) {
500
+ throw new IncompleteModelStreamError("Incomplete model stream: received a model frame after terminal completion.");
303
501
  }
304
- // Tool call deltas.
305
- const toolCallDeltas = delta["tool_calls"];
306
- if (Array.isArray(toolCallDeltas)) {
307
- for (const tc of toolCallDeltas) {
308
- let pending = pendingToolCalls.get(tc.index);
309
- if (!pending) {
310
- pending = { id: "", name: "", arguments: "" };
311
- pendingToolCalls.set(tc.index, pending);
502
+ const choice = chunk.choices[0];
503
+ if (choice) {
504
+ const delta = choice.delta;
505
+ // Reasoning / thinking tokens (GLM "thinking" mode).
506
+ const reasoning = delta["reasoning_content"];
507
+ if (typeof reasoning === "string" && reasoning.length > 0) {
508
+ yield { thinking: reasoning };
509
+ }
510
+ // Regular assistant text.
511
+ const content = delta["content"];
512
+ if (typeof content === "string" && content.length > 0) {
513
+ yield { text: content };
514
+ }
515
+ // Tool call deltas.
516
+ const toolCallDeltas = delta["tool_calls"];
517
+ if (Array.isArray(toolCallDeltas)) {
518
+ for (const tc of toolCallDeltas) {
519
+ let pending = pendingToolCalls.get(tc.index);
520
+ if (!pending) {
521
+ pending = { id: "", name: "", arguments: "" };
522
+ pendingToolCalls.set(tc.index, pending);
523
+ }
524
+ if (tc.id)
525
+ pending.id = tc.id;
526
+ if (tc.function?.name)
527
+ pending.name = tc.function.name;
528
+ if (tc.function?.arguments)
529
+ pending.arguments += tc.function.arguments;
312
530
  }
313
- if (tc.id)
314
- pending.id = tc.id;
315
- if (tc.function?.name)
316
- pending.name = tc.function.name;
317
- if (tc.function?.arguments)
318
- pending.arguments += tc.function.arguments;
531
+ }
532
+ if (choice.finish_reason) {
533
+ lastFinishReason = choice.finish_reason;
534
+ terminalChoiceSeen = true;
319
535
  }
320
536
  }
321
- if (choice.finish_reason) {
322
- lastFinishReason = choice.finish_reason;
323
- terminalChoiceSeen = true;
324
- }
325
- }
326
- // The final chunk on most providers (GLM included when
327
- // include_usage: true) ships only a `usage` object with no choices.
328
- const rawUsage = chunk.usage;
329
- if (rawUsage) {
330
- const usage = {
331
- inputTokens: rawUsage.prompt_tokens ?? 0,
332
- outputTokens: rawUsage.completion_tokens ?? 0,
333
- totalTokens: rawUsage.total_tokens ?? 0,
334
- };
335
- if (typeof rawUsage.prompt_tokens_details?.cached_tokens === "number") {
336
- usage.cachedReadTokens = rawUsage.prompt_tokens_details.cached_tokens;
337
- }
338
- if (typeof rawUsage.completion_tokens_details?.reasoning_tokens === "number") {
339
- usage.thoughtTokens = rawUsage.completion_tokens_details.reasoning_tokens;
537
+ // The final chunk on most providers (GLM included when
538
+ // include_usage: true) ships only a `usage` object with no choices.
539
+ const rawUsage = chunk.usage;
540
+ if (rawUsage) {
541
+ const usage = {
542
+ inputTokens: rawUsage.prompt_tokens ?? 0,
543
+ outputTokens: rawUsage.completion_tokens ?? 0,
544
+ totalTokens: rawUsage.total_tokens ?? 0,
545
+ };
546
+ if (typeof rawUsage.prompt_tokens_details?.cached_tokens === "number") {
547
+ usage.cachedReadTokens = rawUsage.prompt_tokens_details.cached_tokens;
548
+ }
549
+ if (typeof rawUsage.completion_tokens_details?.reasoning_tokens === "number") {
550
+ usage.thoughtTokens = rawUsage.completion_tokens_details.reasoning_tokens;
551
+ }
552
+ debug(`streamChat usage: input=${usage.inputTokens} output=${usage.outputTokens} total=${usage.totalTokens}`);
553
+ yield { usage };
340
554
  }
341
- debug(`streamChat usage: input=${usage.inputTokens} output=${usage.outputTokens} total=${usage.totalTokens}`);
342
- yield { usage };
343
555
  }
344
556
  }
557
+ catch (err) {
558
+ if (isRecoverableTransportError(err))
559
+ this.discardTransport();
560
+ throw err;
561
+ }
345
562
  signal?.throwIfAborted();
346
563
  const calls = [...pendingToolCalls.entries()].sort(([a], [b]) => a - b).map(([, call]) => call);
347
564
  const stopReason = validateStream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