@veryfront/ext-llm-openai 0.1.1240 → 0.1.1241

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.
@@ -1 +1 @@
1
- {"version":3,"file":"openai-chat-stream.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-llm-openai/src/openai-chat-stream.ts"],"names":[],"mappings":"AA2BA,KAAK,4BAA4B,GAAG,QAAQ,GAAG,SAAS,GAAG,YAAY,CAAC;AAExE,KAAK,uBAAuB,GAAG;IAC7B,YAAY,CAAC,EAAE,4BAA4B,CAAC;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AASF,eAAO,MAAM,4BAA4B,OAAQ,CAAC;AA4KlD,wBAAuB,2BAA2B,CAChD,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,EAClC,OAAO,GAAE,uBAA4B,GACpC,aAAa,CAAC,OAAO,CAAC,CA0UxB"}
1
+ {"version":3,"file":"openai-chat-stream.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-llm-openai/src/openai-chat-stream.ts"],"names":[],"mappings":"AA2BA,KAAK,4BAA4B,GAAG,QAAQ,GAAG,SAAS,GAAG,YAAY,CAAC;AAExE,KAAK,uBAAuB,GAAG;IAC7B,YAAY,CAAC,EAAE,4BAA4B,CAAC;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AASF,eAAO,MAAM,4BAA4B,OAAQ,CAAC;AA4KlD,wBAAuB,2BAA2B,CAChD,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,EAClC,OAAO,GAAE,uBAA4B,GACpC,aAAa,CAAC,OAAO,CAAC,CAsVxB"}
@@ -219,11 +219,16 @@ export async function* streamOpenAICompatibleParts(stream, context = {}) {
219
219
  }
220
220
  delta = deltaRecord;
221
221
  }
222
- if (delta.role !== undefined &&
222
+ // Optional delta fields are `null` rather than absent on many
223
+ // OpenAI-compatible gateways (Moonshot/Kimi sends `reasoning_content: null`
224
+ // on both the opening and the finish chunk). Treat `null` as "not present
225
+ // on this chunk", matching how `content`, `refusal`, `tool_calls`, and
226
+ // `finish_reason` are already handled below.
227
+ if (delta.role !== undefined && delta.role !== null &&
223
228
  delta.role !== "assistant") {
224
229
  throw invalidOpenAIStream(context, "choice delta role was not assistant");
225
230
  }
226
- if (delta.reasoning_content !== undefined &&
231
+ if (delta.reasoning_content !== undefined && delta.reasoning_content !== null &&
227
232
  typeof delta.reasoning_content !== "string") {
228
233
  throw invalidOpenAIStream(context, "reasoning delta was malformed");
229
234
  }
@@ -272,11 +277,15 @@ export async function* streamOpenAICompatibleParts(stream, context = {}) {
272
277
  throw invalidOpenAIStream(context, "tool call index was malformed");
273
278
  }
274
279
  const toolCallIndex = index;
275
- if (toolCallRecord.id !== undefined &&
280
+ // As with the reasoning delta above, gateways repeat `id`, `type`, and
281
+ // `function.name` as `null` on continuation fragments instead of omitting
282
+ // them; only the opening fragment carries real values. Treat `null` as
283
+ // absent so the fragment merges into the call already being assembled.
284
+ if (toolCallRecord.id !== undefined && toolCallRecord.id !== null &&
276
285
  !isBoundedOpenAIStreamString(toolCallRecord.id, MAX_OPENAI_STREAM_IDENTIFIER_BYTES)) {
277
286
  throw invalidOpenAIStream(context, "tool call id was malformed");
278
287
  }
279
- if (toolCallRecord.type !== undefined &&
288
+ if (toolCallRecord.type !== undefined && toolCallRecord.type !== null &&
280
289
  toolCallRecord.type !== "function") {
281
290
  throw invalidOpenAIStream(context, "tool call type was not function");
282
291
  }
@@ -306,7 +315,7 @@ export async function* streamOpenAICompatibleParts(stream, context = {}) {
306
315
  if (!fn) {
307
316
  throw invalidOpenAIStream(context, "tool call function was not an object");
308
317
  }
309
- if (fn.name !== undefined &&
318
+ if (fn.name !== undefined && fn.name !== null &&
310
319
  !isBoundedOpenAIStreamString(fn.name, MAX_OPENAI_STREAM_TOOL_NAME_BYTES)) {
311
320
  throw invalidOpenAIStream(context, "tool call function name was malformed");
312
321
  }
@@ -324,7 +333,8 @@ export async function* streamOpenAICompatibleParts(stream, context = {}) {
324
333
  toolName: current.name,
325
334
  };
326
335
  }
327
- if (fn.arguments !== undefined && typeof fn.arguments !== "string") {
336
+ if (fn.arguments !== undefined && fn.arguments !== null &&
337
+ typeof fn.arguments !== "string") {
328
338
  throw invalidOpenAIStream(context, "tool call arguments delta was malformed");
329
339
  }
330
340
  if (typeof fn.arguments === "string") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veryfront/ext-llm-openai",
3
- "version": "0.1.1240",
3
+ "version": "0.1.1241",
4
4
  "description": "Veryfront first-party extension package for ext-llm-openai",
5
5
  "keywords": [
6
6
  "veryfront",
@@ -45,7 +45,7 @@
45
45
  "capabilities": []
46
46
  },
47
47
  "peerDependencies": {
48
- "veryfront": "^0.1.1240"
48
+ "veryfront": "^0.1.1241"
49
49
  },
50
50
  "type": "module",
51
51
  "types": "./esm/extensions/ext-llm-openai/src/index.d.ts",