@copilotkit/aimock 1.38.0 → 1.39.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.
Files changed (58) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +26 -0
  3. package/README.md +23 -2
  4. package/dist/agui-handler.cjs +20 -18
  5. package/dist/agui-handler.cjs.map +1 -1
  6. package/dist/agui-handler.d.cts +8 -1
  7. package/dist/agui-handler.d.cts.map +1 -1
  8. package/dist/agui-handler.d.ts +8 -1
  9. package/dist/agui-handler.d.ts.map +1 -1
  10. package/dist/agui-handler.js +20 -18
  11. package/dist/agui-handler.js.map +1 -1
  12. package/dist/agui-stub.d.cts +2 -2
  13. package/dist/agui-stub.d.ts +2 -2
  14. package/dist/agui-types.d.cts +19 -1
  15. package/dist/agui-types.d.cts.map +1 -1
  16. package/dist/agui-types.d.ts +19 -1
  17. package/dist/agui-types.d.ts.map +1 -1
  18. package/dist/aimock-cli.cjs +1 -1
  19. package/dist/aimock-cli.cjs.map +1 -1
  20. package/dist/aimock-cli.js +1 -1
  21. package/dist/aimock-cli.js.map +1 -1
  22. package/dist/cli.cjs +10 -10
  23. package/dist/cli.cjs.map +1 -1
  24. package/dist/cli.js +10 -10
  25. package/dist/cli.js.map +1 -1
  26. package/dist/config-loader.d.ts.map +1 -1
  27. package/dist/index.d.cts +2 -2
  28. package/dist/index.d.ts +2 -2
  29. package/dist/llmock.cjs +23 -9
  30. package/dist/llmock.cjs.map +1 -1
  31. package/dist/llmock.d.cts +22 -0
  32. package/dist/llmock.d.cts.map +1 -1
  33. package/dist/llmock.d.ts +22 -0
  34. package/dist/llmock.d.ts.map +1 -1
  35. package/dist/llmock.js +25 -11
  36. package/dist/llmock.js.map +1 -1
  37. package/dist/openrouter-video.cjs.map +1 -1
  38. package/dist/openrouter-video.js.map +1 -1
  39. package/dist/server.cjs +34 -17
  40. package/dist/server.cjs.map +1 -1
  41. package/dist/server.d.cts +6 -1
  42. package/dist/server.d.cts.map +1 -1
  43. package/dist/server.d.ts +6 -1
  44. package/dist/server.d.ts.map +1 -1
  45. package/dist/server.js +34 -18
  46. package/dist/server.js.map +1 -1
  47. package/dist/stream-collapse.cjs +77 -0
  48. package/dist/stream-collapse.cjs.map +1 -1
  49. package/dist/stream-collapse.d.cts.map +1 -1
  50. package/dist/stream-collapse.d.ts.map +1 -1
  51. package/dist/stream-collapse.js +77 -0
  52. package/dist/stream-collapse.js.map +1 -1
  53. package/dist/vector-types.d.ts.map +1 -1
  54. package/dist/ws-gemini-live.cjs +41 -6
  55. package/dist/ws-gemini-live.cjs.map +1 -1
  56. package/dist/ws-gemini-live.js +41 -6
  57. package/dist/ws-gemini-live.js.map +1 -1
  58. package/package.json +3 -2
@@ -291,9 +291,86 @@ function collapseOpenAISSE(rawBody) {
291
291
  continue;
292
292
  }
293
293
  }
294
+ if (item?.type === "function_call" && typeof parsed.output_index === "number") {
295
+ const entry = toolCallMap.get(parsed.output_index);
296
+ if (entry) {
297
+ if (!entry.id && typeof item.call_id === "string") entry.id = item.call_id;
298
+ if (!entry.name && typeof item.name === "string") entry.name = item.name;
299
+ if (entry.arguments === "" && typeof item.arguments === "string") entry.arguments = item.arguments;
300
+ } else {
301
+ const created = {
302
+ id: typeof item.call_id === "string" ? item.call_id : "",
303
+ name: typeof item.name === "string" ? item.name : "",
304
+ arguments: typeof item.arguments === "string" ? item.arguments : ""
305
+ };
306
+ toolCallMap.set(parsed.output_index, created);
307
+ orderAtoms.push({
308
+ kind: "toolCall",
309
+ ref: created
310
+ });
311
+ }
312
+ continue;
313
+ }
314
+ }
315
+ if (parsed.type === "response.output_item.added") {
316
+ const item = parsed.item;
317
+ if (item?.type === "function_call" && typeof parsed.output_index === "number") {
318
+ if (!toolCallMap.has(parsed.output_index)) {
319
+ const created = {
320
+ id: typeof item.call_id === "string" ? item.call_id : "",
321
+ name: typeof item.name === "string" ? item.name : "",
322
+ arguments: ""
323
+ };
324
+ toolCallMap.set(parsed.output_index, created);
325
+ orderAtoms.push({
326
+ kind: "toolCall",
327
+ ref: created
328
+ });
329
+ }
330
+ continue;
331
+ }
332
+ }
333
+ if (parsed.type === "response.function_call_arguments.delta" && typeof parsed.delta === "string" && typeof parsed.output_index === "number") {
334
+ let entry = toolCallMap.get(parsed.output_index);
335
+ if (!entry) {
336
+ entry = {
337
+ id: "",
338
+ name: "",
339
+ arguments: ""
340
+ };
341
+ toolCallMap.set(parsed.output_index, entry);
342
+ orderAtoms.push({
343
+ kind: "toolCall",
344
+ ref: entry
345
+ });
346
+ }
347
+ entry.arguments += parsed.delta;
348
+ continue;
349
+ }
350
+ if (parsed.type === "response.function_call_arguments.done" && typeof parsed.output_index === "number") {
351
+ const entry = toolCallMap.get(parsed.output_index);
352
+ if (entry) {
353
+ if (entry.arguments === "" && typeof parsed.arguments === "string") entry.arguments = parsed.arguments;
354
+ } else if (typeof parsed.arguments === "string") {
355
+ const created = {
356
+ id: "",
357
+ name: "",
358
+ arguments: parsed.arguments
359
+ };
360
+ toolCallMap.set(parsed.output_index, created);
361
+ orderAtoms.push({
362
+ kind: "toolCall",
363
+ ref: created
364
+ });
365
+ }
366
+ continue;
294
367
  }
295
368
  if (parsed.type === "response.output_text.delta" && typeof parsed.delta === "string") {
296
369
  content += parsed.delta;
370
+ if (parsed.delta.length > 0) orderAtoms.push({
371
+ kind: "text",
372
+ text: parsed.delta
373
+ });
297
374
  continue;
298
375
  }
299
376
  if (typeof parsed.type === "string" && parsed.type.startsWith("response.")) continue;