@vincemakes/kiso-provider-openai 0.31.1 → 0.32.0
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.
- package/dist/index.js +30 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -118,8 +118,13 @@ export function createOpenAICompatAdapter(client, adapterOpts = {}) {
|
|
|
118
118
|
continue; // content and finish reasons after the first finish: ignored
|
|
119
119
|
}
|
|
120
120
|
// Reasoning dialect → thinking (digested here, not in the union).
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
// Two spellings of one thing: DeepSeek's own API says
|
|
122
|
+
// `reasoning_content`; OpenRouter normalises every vendor it
|
|
123
|
+
// fronts (GLM, Qwen, …) into `reasoning`. GLM-F1 (2026-09-09):
|
|
124
|
+
// z-ai/glm-5.3-flash through openrouter.ai streamed its whole
|
|
125
|
+
// think under `reasoning` and the adapter showed none of it.
|
|
126
|
+
const d = chunk.choices?.[0]?.delta;
|
|
127
|
+
const reasoning = d?.reasoning_content || d?.reasoning;
|
|
123
128
|
if (reasoning) {
|
|
124
129
|
yield { seq: 0, type: "thinking", text: reasoning };
|
|
125
130
|
}
|
|
@@ -255,6 +260,19 @@ export function createOpenAICompatAdapter(client, adapterOpts = {}) {
|
|
|
255
260
|
// Area 6 hardening (review finding 4): a stream that ended with
|
|
256
261
|
// NO finish_reason is a TRUNCATED turn — the stop is an explicit
|
|
257
262
|
// error, never a default end_turn/completed.
|
|
263
|
+
// COMPAT-F1 (2026-09-09, the GLM leg): the SDK closes an ABORTED
|
|
264
|
+
// stream quietly — the iterator just ends, no finish_reason — and
|
|
265
|
+
// that used to read as the provider's failure below, so esc on a
|
|
266
|
+
// DeepSeek or OpenRouter turn recorded an error terminal and no
|
|
267
|
+
// durable void. The kernel classifies an abort only when the
|
|
268
|
+
// adapter THROWS while the signal is set (its catch asks
|
|
269
|
+
// `aborted()` first), which is what the Responses adapter does.
|
|
270
|
+
// An early end WITHOUT an abort stays the provider's error.
|
|
271
|
+
if (options.signal?.aborted) {
|
|
272
|
+
const err = new Error("stream aborted by the caller");
|
|
273
|
+
err.name = "AbortError";
|
|
274
|
+
throw err;
|
|
275
|
+
}
|
|
258
276
|
yield { seq: 0, type: "stop", reason: finishReason === null ? "error" : stopReason };
|
|
259
277
|
},
|
|
260
278
|
};
|
|
@@ -464,5 +482,15 @@ function toOpenAIError(err, model) {
|
|
|
464
482
|
// CX-1 F8: the kernel owns retries — Retry-After travels with the error
|
|
465
483
|
return mapApiError(err.status, label + err.message, retryAfterOf(err.headers));
|
|
466
484
|
}
|
|
485
|
+
// COMPAT-F2 (2026-09-09, the GLM leg): a response BODY cut by the
|
|
486
|
+
// transport after the headers — the upstream dropped a long answer 14 s
|
|
487
|
+
// in — reaches here as Node's own `TypeError: terminated` (undici), not
|
|
488
|
+
// as any OpenAI error class, and used to pass through as `unknown`,
|
|
489
|
+
// non-retryable: an error terminal where the mid-stream retry belongs.
|
|
490
|
+
// The name is fetch's, not the vendor's, so it is a transport failure by
|
|
491
|
+
// construction — the same class as APIConnectionError above.
|
|
492
|
+
if (err instanceof TypeError && (err.message === "terminated" || err.message === "fetch failed")) {
|
|
493
|
+
return { code: "network", retryable: true, message: label + err.message };
|
|
494
|
+
}
|
|
467
495
|
return err;
|
|
468
496
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vincemakes/kiso-provider-openai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "kiso OpenAI-compatible adapter — OpenAI + the compat family (GLM, Kimi, DeepSeek, OpenRouter) via base_url swap, reasoning dialects digested.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"test": "vitest run"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@vincemakes/kiso-core": "0.
|
|
24
|
+
"@vincemakes/kiso-core": "0.32.0",
|
|
25
25
|
"openai": "^7.3.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|