@copilotkit/aimock 1.39.0 → 1.41.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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +46 -0
- package/README.md +4 -2
- package/dist/agui-stub.d.cts +2 -2
- package/dist/agui-stub.d.ts +2 -2
- package/dist/agui-types.d.cts +66 -3
- package/dist/agui-types.d.cts.map +1 -1
- package/dist/agui-types.d.ts +66 -3
- package/dist/agui-types.d.ts.map +1 -1
- package/dist/byteplus-video.cjs +954 -0
- package/dist/byteplus-video.cjs.map +1 -0
- package/dist/byteplus-video.d.cts +176 -0
- package/dist/byteplus-video.d.cts.map +1 -0
- package/dist/byteplus-video.d.ts +176 -0
- package/dist/byteplus-video.d.ts.map +1 -0
- package/dist/byteplus-video.js +947 -0
- package/dist/byteplus-video.js.map +1 -0
- package/dist/cli.cjs +5 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +5 -1
- package/dist/cli.js.map +1 -1
- package/dist/helpers.cjs +8 -4
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.d.cts.map +1 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +8 -4
- package/dist/helpers.js.map +1 -1
- package/dist/images.cjs +2 -2
- package/dist/images.cjs.map +1 -1
- package/dist/images.d.cts +11 -3
- package/dist/images.d.cts.map +1 -1
- package/dist/images.d.ts +11 -3
- package/dist/images.d.ts.map +1 -1
- package/dist/images.js +2 -2
- package/dist/images.js.map +1 -1
- package/dist/index.cjs +7 -0
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/metrics.cjs +20 -0
- package/dist/metrics.cjs.map +1 -1
- package/dist/metrics.d.cts.map +1 -1
- package/dist/metrics.d.ts.map +1 -1
- package/dist/metrics.js +19 -1
- package/dist/metrics.js.map +1 -1
- package/dist/openrouter-chat.cjs +41 -0
- package/dist/openrouter-chat.cjs.map +1 -1
- package/dist/openrouter-chat.js +41 -0
- package/dist/openrouter-chat.js.map +1 -1
- package/dist/provider-auth.cjs +2 -0
- package/dist/provider-auth.cjs.map +1 -1
- package/dist/provider-auth.js +2 -0
- package/dist/provider-auth.js.map +1 -1
- package/dist/recorder.cjs +77 -8
- package/dist/recorder.cjs.map +1 -1
- package/dist/recorder.d.cts.map +1 -1
- package/dist/recorder.d.ts.map +1 -1
- package/dist/recorder.js +77 -8
- package/dist/recorder.js.map +1 -1
- package/dist/router.cjs +1 -0
- package/dist/router.cjs.map +1 -1
- package/dist/router.d.cts.map +1 -1
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +1 -0
- package/dist/router.js.map +1 -1
- package/dist/server.cjs +137 -6
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +2 -0
- package/dist/server.d.cts.map +1 -1
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +138 -7
- package/dist/server.js.map +1 -1
- package/dist/stream-collapse.cjs +21 -6
- package/dist/stream-collapse.cjs.map +1 -1
- package/dist/stream-collapse.d.cts +16 -0
- package/dist/stream-collapse.d.cts.map +1 -1
- package/dist/stream-collapse.d.ts +16 -0
- package/dist/stream-collapse.d.ts.map +1 -1
- package/dist/stream-collapse.js +21 -6
- package/dist/stream-collapse.js.map +1 -1
- package/dist/types.d.cts +41 -6
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.ts +41 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/vector-types.d.cts.map +1 -1
- package/package.json +4 -3
package/dist/stream-collapse.cjs
CHANGED
|
@@ -245,6 +245,7 @@ function collapseOpenAISSE(rawBody) {
|
|
|
245
245
|
let transcriptUsage;
|
|
246
246
|
let reasoning = "";
|
|
247
247
|
const webSearchQueries = [];
|
|
248
|
+
let usage;
|
|
248
249
|
let droppedChunks = 0;
|
|
249
250
|
let firstDroppedSample;
|
|
250
251
|
let harmonyUnparsed = false;
|
|
@@ -252,6 +253,7 @@ function collapseOpenAISSE(rawBody) {
|
|
|
252
253
|
const toolCallMap = /* @__PURE__ */ new Map();
|
|
253
254
|
let nextSyntheticIndex = 1e6;
|
|
254
255
|
const idKeyMap = /* @__PURE__ */ new Map();
|
|
256
|
+
let lastToolCallKey;
|
|
255
257
|
const orderAtoms = [];
|
|
256
258
|
for (const line of lines) {
|
|
257
259
|
const data = extractSSEData(splitSSELines(line));
|
|
@@ -275,7 +277,7 @@ function collapseOpenAISSE(rawBody) {
|
|
|
275
277
|
transcript = parsed.text;
|
|
276
278
|
transcriptSeen = true;
|
|
277
279
|
if (Array.isArray(parsed.languages)) transcriptLanguages = parsed.languages.filter((language) => typeof language === "object" && language !== null && typeof language.code === "string").map((language) => ({ code: language.code }));
|
|
278
|
-
if (parsed.usage && typeof parsed.usage === "object") transcriptUsage = parsed.usage;
|
|
280
|
+
if (parsed.usage && typeof parsed.usage === "object" && !Array.isArray(parsed.usage) && Object.keys(parsed.usage).length > 0) transcriptUsage = parsed.usage;
|
|
279
281
|
continue;
|
|
280
282
|
}
|
|
281
283
|
if (parsed.type === "response.reasoning_summary_text.delta" && typeof parsed.delta === "string") {
|
|
@@ -374,6 +376,7 @@ function collapseOpenAISSE(rawBody) {
|
|
|
374
376
|
continue;
|
|
375
377
|
}
|
|
376
378
|
if (typeof parsed.type === "string" && parsed.type.startsWith("response.")) continue;
|
|
379
|
+
if (parsed.usage && typeof parsed.usage === "object" && !Array.isArray(parsed.usage) && Object.keys(parsed.usage).length > 0) usage = parsed.usage;
|
|
377
380
|
const choices = parsed.choices;
|
|
378
381
|
if (!choices || choices.length === 0) continue;
|
|
379
382
|
const delta = choices[0].delta;
|
|
@@ -399,7 +402,9 @@ function collapseOpenAISSE(rawBody) {
|
|
|
399
402
|
index = nextSyntheticIndex++;
|
|
400
403
|
idKeyMap.set(rawId, index);
|
|
401
404
|
}
|
|
402
|
-
} else index =
|
|
405
|
+
} else if (lastToolCallKey !== void 0) index = lastToolCallKey;
|
|
406
|
+
else index = nextSyntheticIndex++;
|
|
407
|
+
lastToolCallKey = index;
|
|
403
408
|
if (!toolCallMap.has(index)) {
|
|
404
409
|
const created = {
|
|
405
410
|
id: rawId ?? "",
|
|
@@ -453,6 +458,7 @@ function collapseOpenAISSE(rawBody) {
|
|
|
453
458
|
toolCalls: [...blocks ? orderedToolCalls : indexSortedToolCalls, ...harmonyToolCalls],
|
|
454
459
|
...reasoning ? { reasoning } : {},
|
|
455
460
|
...webSearchQueries.length > 0 ? { webSearches: webSearchQueries } : {},
|
|
461
|
+
...usage ? { usage } : {},
|
|
456
462
|
...droppedChunks > 0 ? { droppedChunks } : {},
|
|
457
463
|
...firstDroppedSample ? { firstDroppedSample } : {},
|
|
458
464
|
...harmonyUnparsed ? { harmonyUnparsed: true } : {},
|
|
@@ -469,6 +475,7 @@ function collapseOpenAISSE(rawBody) {
|
|
|
469
475
|
content,
|
|
470
476
|
...reasoning ? { reasoning } : {},
|
|
471
477
|
...webSearchQueries.length > 0 ? { webSearches: webSearchQueries } : {},
|
|
478
|
+
...usage ? { usage } : {},
|
|
472
479
|
...droppedChunks > 0 ? { droppedChunks } : {},
|
|
473
480
|
...firstDroppedSample ? { firstDroppedSample } : {},
|
|
474
481
|
...harmonyUnparsed ? { harmonyUnparsed: true } : {},
|
|
@@ -833,7 +840,6 @@ function collapseCohereSSE(rawBody) {
|
|
|
833
840
|
let index;
|
|
834
841
|
if (typeof parsed.index === "number") index = parsed.index;
|
|
835
842
|
else index = nextSyntheticIndex++;
|
|
836
|
-
lastStartKey = index;
|
|
837
843
|
const toolCalls = (parsed.delta?.message)?.tool_calls;
|
|
838
844
|
if (toolCalls) {
|
|
839
845
|
const fn = toolCalls.function;
|
|
@@ -843,6 +849,7 @@ function collapseCohereSSE(rawBody) {
|
|
|
843
849
|
arguments: ""
|
|
844
850
|
};
|
|
845
851
|
toolCallMap.set(index, created);
|
|
852
|
+
lastStartKey = index;
|
|
846
853
|
orderAtoms.push({
|
|
847
854
|
kind: "toolCall",
|
|
848
855
|
ref: created
|
|
@@ -1036,7 +1043,7 @@ function collapseBedrockEventStream(rawBody) {
|
|
|
1036
1043
|
const index = parsed.index;
|
|
1037
1044
|
const redactedData = capturedRedactedData(block);
|
|
1038
1045
|
if (redactedData !== void 0) redactedThinking.push(redactedData);
|
|
1039
|
-
if (block?.type === "tool_use"
|
|
1046
|
+
if (block?.type === "tool_use") if (index !== void 0) {
|
|
1040
1047
|
const created = {
|
|
1041
1048
|
id: block.id ?? "",
|
|
1042
1049
|
name: block.name ?? "",
|
|
@@ -1047,6 +1054,9 @@ function collapseBedrockEventStream(rawBody) {
|
|
|
1047
1054
|
kind: "toolCall",
|
|
1048
1055
|
ref: created
|
|
1049
1056
|
});
|
|
1057
|
+
} else {
|
|
1058
|
+
droppedChunks++;
|
|
1059
|
+
if (droppedChunks === 1) firstDroppedSample = `tool_use content_block_start with no index — tool call identity lost: ${surrogateSafeSlice(frameStr, 200)}`;
|
|
1050
1060
|
}
|
|
1051
1061
|
continue;
|
|
1052
1062
|
}
|
|
@@ -1054,7 +1064,7 @@ function collapseBedrockEventStream(rawBody) {
|
|
|
1054
1064
|
const blockStart = parsed.contentBlockStart;
|
|
1055
1065
|
const index = parsed.contentBlockIndex ?? blockStart.contentBlockIndex;
|
|
1056
1066
|
const start = blockStart.start;
|
|
1057
|
-
if (start?.toolUse
|
|
1067
|
+
if (start?.toolUse) if (index !== void 0) {
|
|
1058
1068
|
const toolUse = start.toolUse;
|
|
1059
1069
|
const created = {
|
|
1060
1070
|
id: toolUse.toolUseId ?? "",
|
|
@@ -1066,6 +1076,9 @@ function collapseBedrockEventStream(rawBody) {
|
|
|
1066
1076
|
kind: "toolCall",
|
|
1067
1077
|
ref: created
|
|
1068
1078
|
});
|
|
1079
|
+
} else {
|
|
1080
|
+
droppedChunks++;
|
|
1081
|
+
if (droppedChunks === 1) firstDroppedSample = `contentBlockStart toolUse with no index — tool call identity lost: ${surrogateSafeSlice(frameStr, 200)}`;
|
|
1069
1082
|
}
|
|
1070
1083
|
}
|
|
1071
1084
|
if (parsed.contentBlockDelta) {
|
|
@@ -1252,7 +1265,9 @@ function collapseStreamingResponse(contentType, providerKey, body, logger) {
|
|
|
1252
1265
|
const str = typeof body === "string" ? body : body.toString("utf8");
|
|
1253
1266
|
switch (providerKey) {
|
|
1254
1267
|
case "openai":
|
|
1255
|
-
case "azure":
|
|
1268
|
+
case "azure":
|
|
1269
|
+
case "openrouter":
|
|
1270
|
+
case "byteplus": return collapseOpenAISSE(str);
|
|
1256
1271
|
case "anthropic": return collapseAnthropicSSE(str);
|
|
1257
1272
|
case "gemini":
|
|
1258
1273
|
case "vertexai": return collapseGeminiSSE(str);
|