@copilotkit/runtime 1.4.0-pre-1-4-0.13 → 1.4.0-pre-1-4-0.14

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 (55) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/{chunk-AQBZWBJD.mjs → chunk-6H45CJUK.mjs} +2 -2
  3. package/dist/{chunk-CBZV4PPM.mjs → chunk-N4ROMSZN.mjs} +2 -2
  4. package/dist/{chunk-P4EZLCB6.mjs → chunk-NFMXFL2C.mjs} +2 -2
  5. package/dist/{chunk-56IQ6PGC.mjs → chunk-WHJ3DAYL.mjs} +56 -213
  6. package/dist/chunk-WHJ3DAYL.mjs.map +1 -0
  7. package/dist/{chunk-NKGWZWKJ.mjs → chunk-X4FFTYTH.mjs} +33 -76
  8. package/dist/chunk-X4FFTYTH.mjs.map +1 -0
  9. package/dist/{copilot-runtime-d9ef5d8c.d.ts → copilot-runtime-335a610d.d.ts} +1 -1
  10. package/dist/{groq-adapter-192d2413.d.ts → groq-adapter-2f8fd767.d.ts} +1 -1
  11. package/dist/index.d.ts +3 -3
  12. package/dist/index.js +85 -285
  13. package/dist/index.js.map +1 -1
  14. package/dist/index.mjs +5 -5
  15. package/dist/{langserve-878c62b9.d.ts → langserve-cc06e76e.d.ts} +9 -45
  16. package/dist/lib/index.d.ts +3 -3
  17. package/dist/lib/index.js +79 -264
  18. package/dist/lib/index.js.map +1 -1
  19. package/dist/lib/index.mjs +5 -5
  20. package/dist/lib/integrations/index.d.ts +3 -3
  21. package/dist/lib/integrations/index.js +3 -11
  22. package/dist/lib/integrations/index.js.map +1 -1
  23. package/dist/lib/integrations/index.mjs +5 -5
  24. package/dist/lib/integrations/nest/index.d.ts +2 -2
  25. package/dist/lib/integrations/nest/index.js +3 -11
  26. package/dist/lib/integrations/nest/index.js.map +1 -1
  27. package/dist/lib/integrations/nest/index.mjs +3 -3
  28. package/dist/lib/integrations/node-express/index.d.ts +2 -2
  29. package/dist/lib/integrations/node-express/index.js +3 -11
  30. package/dist/lib/integrations/node-express/index.js.map +1 -1
  31. package/dist/lib/integrations/node-express/index.mjs +3 -3
  32. package/dist/lib/integrations/node-http/index.d.ts +2 -2
  33. package/dist/lib/integrations/node-http/index.js +3 -11
  34. package/dist/lib/integrations/node-http/index.js.map +1 -1
  35. package/dist/lib/integrations/node-http/index.mjs +2 -2
  36. package/dist/service-adapters/index.d.ts +3 -3
  37. package/dist/service-adapters/index.js +55 -212
  38. package/dist/service-adapters/index.js.map +1 -1
  39. package/dist/service-adapters/index.mjs +1 -1
  40. package/package.json +4 -4
  41. package/src/agents/langgraph/event-source.ts +0 -12
  42. package/src/graphql/resolvers/copilot.resolver.ts +2 -28
  43. package/src/service-adapters/anthropic/anthropic-adapter.ts +6 -15
  44. package/src/service-adapters/events.ts +35 -73
  45. package/src/service-adapters/experimental/ollama/ollama-adapter.ts +3 -7
  46. package/src/service-adapters/groq/groq-adapter.ts +8 -22
  47. package/src/service-adapters/langchain/utils.ts +31 -47
  48. package/src/service-adapters/openai/openai-adapter.ts +9 -21
  49. package/src/service-adapters/openai/openai-assistant-adapter.ts +8 -21
  50. package/src/service-adapters/unify/unify-adapter.ts +11 -28
  51. package/dist/chunk-56IQ6PGC.mjs.map +0 -1
  52. package/dist/chunk-NKGWZWKJ.mjs.map +0 -1
  53. /package/dist/{chunk-AQBZWBJD.mjs.map → chunk-6H45CJUK.mjs.map} +0 -0
  54. /package/dist/{chunk-CBZV4PPM.mjs.map → chunk-N4ROMSZN.mjs.map} +0 -0
  55. /package/dist/{chunk-P4EZLCB6.mjs.map → chunk-NFMXFL2C.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @copilotkit/runtime
2
2
 
3
+ ## 1.4.0-pre-1-4-0.14
4
+
5
+ ### Minor Changes
6
+
7
+ - lgc & lgjs alpha release
8
+
9
+ ### Patch Changes
10
+
11
+ - a5efccd: Revert rxjs changes
12
+ - Updated dependencies [a5efccd]
13
+ - Updated dependencies
14
+ - @copilotkit/shared@1.4.0-pre-1-4-0.14
15
+
3
16
  ## 1.4.0-pre-1-4-0.13
4
17
 
5
18
  ### Minor Changes
@@ -2,7 +2,7 @@ import {
2
2
  getCommonConfig,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-NKGWZWKJ.mjs";
5
+ } from "./chunk-X4FFTYTH.mjs";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-44O2JGUY.mjs";
@@ -77,4 +77,4 @@ export {
77
77
  config,
78
78
  copilotRuntimeNextJSPagesRouterEndpoint
79
79
  };
80
- //# sourceMappingURL=chunk-AQBZWBJD.mjs.map
80
+ //# sourceMappingURL=chunk-6H45CJUK.mjs.map
@@ -2,7 +2,7 @@ import {
2
2
  copilotRuntimeNodeHttpEndpoint,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-NKGWZWKJ.mjs";
5
+ } from "./chunk-X4FFTYTH.mjs";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-44O2JGUY.mjs";
@@ -22,4 +22,4 @@ __name(copilotRuntimeNodeExpressEndpoint, "copilotRuntimeNodeExpressEndpoint");
22
22
  export {
23
23
  copilotRuntimeNodeExpressEndpoint
24
24
  };
25
- //# sourceMappingURL=chunk-CBZV4PPM.mjs.map
25
+ //# sourceMappingURL=chunk-N4ROMSZN.mjs.map
@@ -2,7 +2,7 @@ import {
2
2
  copilotRuntimeNodeHttpEndpoint,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-NKGWZWKJ.mjs";
5
+ } from "./chunk-X4FFTYTH.mjs";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-44O2JGUY.mjs";
@@ -22,4 +22,4 @@ __name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
22
22
  export {
23
23
  copilotRuntimeNestEndpoint
24
24
  };
25
- //# sourceMappingURL=chunk-P4EZLCB6.mjs.map
25
+ //# sourceMappingURL=chunk-NFMXFL2C.mjs.map
@@ -276,8 +276,6 @@ var OpenAIAdapter = class {
276
276
  eventSource.stream(async (eventStream$) => {
277
277
  var _a, _b;
278
278
  let mode = null;
279
- let currentMessageId;
280
- let currentToolCallId;
281
279
  for await (const chunk of stream) {
282
280
  if (chunk.choices.length === 0) {
283
281
  continue;
@@ -286,51 +284,30 @@ var OpenAIAdapter = class {
286
284
  const content = chunk.choices[0].delta.content;
287
285
  if (mode === "message" && (toolCall == null ? void 0 : toolCall.id)) {
288
286
  mode = null;
289
- eventStream$.sendTextMessageEnd({
290
- messageId: currentMessageId
291
- });
287
+ eventStream$.sendTextMessageEnd();
292
288
  } else if (mode === "function" && (toolCall === void 0 || (toolCall == null ? void 0 : toolCall.id))) {
293
289
  mode = null;
294
- eventStream$.sendActionExecutionEnd({
295
- actionExecutionId: currentToolCallId
296
- });
290
+ eventStream$.sendActionExecutionEnd();
297
291
  }
298
292
  if (mode === null) {
299
293
  if (toolCall == null ? void 0 : toolCall.id) {
300
294
  mode = "function";
301
- currentToolCallId = toolCall.id;
302
- eventStream$.sendActionExecutionStart({
303
- actionExecutionId: currentToolCallId,
304
- actionName: toolCall.function.name
305
- });
295
+ eventStream$.sendActionExecutionStart(toolCall.id, toolCall.function.name);
306
296
  } else if (content) {
307
297
  mode = "message";
308
- currentMessageId = chunk.id;
309
- eventStream$.sendTextMessageStart({
310
- messageId: currentMessageId
311
- });
298
+ eventStream$.sendTextMessageStart(chunk.id);
312
299
  }
313
300
  }
314
301
  if (mode === "message" && content) {
315
- eventStream$.sendTextMessageContent({
316
- messageId: currentMessageId,
317
- content
318
- });
302
+ eventStream$.sendTextMessageContent(content);
319
303
  } else if (mode === "function" && ((_b = toolCall == null ? void 0 : toolCall.function) == null ? void 0 : _b.arguments)) {
320
- eventStream$.sendActionExecutionArgs({
321
- actionExecutionId: currentToolCallId,
322
- args: toolCall.function.arguments
323
- });
304
+ eventStream$.sendActionExecutionArgs(toolCall.function.arguments);
324
305
  }
325
306
  }
326
307
  if (mode === "message") {
327
- eventStream$.sendTextMessageEnd({
328
- messageId: currentMessageId
329
- });
308
+ eventStream$.sendTextMessageEnd();
330
309
  } else if (mode === "function") {
331
- eventStream$.sendActionExecutionEnd({
332
- actionExecutionId: currentToolCallId
333
- });
310
+ eventStream$.sendActionExecutionEnd();
334
311
  }
335
312
  eventStream$.complete();
336
313
  });
@@ -426,11 +403,7 @@ function isBaseMessageChunk(message) {
426
403
  __name(isBaseMessageChunk, "isBaseMessageChunk");
427
404
  function maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution) {
428
405
  if (actionExecution) {
429
- eventStream$.sendActionExecutionResult({
430
- actionExecutionId: actionExecution.id,
431
- actionName: actionExecution.name,
432
- result: "Sending a message"
433
- });
406
+ eventStream$.sendActionExecutionResult(actionExecution.id, actionExecution.name, "Sending a message");
434
407
  }
435
408
  }
436
409
  __name(maybeSendActionExecutionResultIsMessage, "maybeSendActionExecutionResultIsMessage");
@@ -440,11 +413,7 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
440
413
  if (!actionExecution) {
441
414
  eventStream$.sendTextMessage(randomId2(), result);
442
415
  } else {
443
- eventStream$.sendActionExecutionResult({
444
- actionExecutionId: actionExecution.id,
445
- actionName: actionExecution.name,
446
- result
447
- });
416
+ eventStream$.sendActionExecutionResult(actionExecution.id, actionExecution.name, result);
448
417
  }
449
418
  } else if (isAIMessage(result)) {
450
419
  maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution);
@@ -452,11 +421,7 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
452
421
  eventStream$.sendTextMessage(randomId2(), result.content);
453
422
  }
454
423
  for (const toolCall of result.tool_calls) {
455
- eventStream$.sendActionExecution({
456
- actionExecutionId: toolCall.id || randomId2(),
457
- actionName: toolCall.name,
458
- args: JSON.stringify(toolCall.args)
459
- });
424
+ eventStream$.sendActionExecution(toolCall.id || randomId2(), toolCall.name, JSON.stringify(toolCall.args));
460
425
  }
461
426
  } else if (isBaseMessageChunk(result)) {
462
427
  maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution);
@@ -465,11 +430,7 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
465
430
  }
466
431
  if ((_b = result.lc_kwargs) == null ? void 0 : _b.tool_calls) {
467
432
  for (const toolCall of (_c = result.lc_kwargs) == null ? void 0 : _c.tool_calls) {
468
- eventStream$.sendActionExecution({
469
- actionExecutionId: toolCall.id || randomId2(),
470
- actionName: toolCall.name,
471
- args: JSON.stringify(toolCall.args)
472
- });
433
+ eventStream$.sendActionExecution(toolCall.id || randomId2(), toolCall.name, JSON.stringify(toolCall.args));
473
434
  }
474
435
  }
475
436
  } else if (result && "getReader" in result) {
@@ -487,7 +448,6 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
487
448
  const { done, value } = await reader.read();
488
449
  let toolCallName = void 0;
489
450
  let toolCallId = void 0;
490
- let currentMessageId;
491
451
  let toolCallArgs = void 0;
492
452
  let hasToolCall = false;
493
453
  let content = value == null ? void 0 : value.content;
@@ -515,14 +475,10 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
515
475
  }
516
476
  if (mode === "message" && (toolCallId || done)) {
517
477
  mode = null;
518
- eventStream$.sendTextMessageEnd({
519
- messageId: currentMessageId
520
- });
478
+ eventStream$.sendTextMessageEnd();
521
479
  } else if (mode === "function" && (!hasToolCall || done)) {
522
480
  mode = null;
523
- eventStream$.sendActionExecutionEnd({
524
- actionExecutionId: toolCallId
525
- });
481
+ eventStream$.sendActionExecutionEnd();
526
482
  }
527
483
  if (done) {
528
484
  break;
@@ -530,38 +486,21 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
530
486
  if (mode === null) {
531
487
  if (hasToolCall && toolCallId && toolCallName) {
532
488
  mode = "function";
533
- eventStream$.sendActionExecutionStart({
534
- actionExecutionId: toolCallId,
535
- actionName: toolCallName
536
- });
489
+ eventStream$.sendActionExecutionStart(toolCallId, toolCallName);
537
490
  } else if (content) {
538
491
  mode = "message";
539
- currentMessageId = randomId2();
540
- eventStream$.sendTextMessageStart({
541
- messageId: currentMessageId
542
- });
492
+ eventStream$.sendTextMessageStart(randomId2());
543
493
  }
544
494
  }
545
495
  if (mode === "message" && content) {
546
- eventStream$.sendTextMessageContent({
547
- messageId: currentMessageId,
548
- content: Array.isArray(content) ? ((_i = content[0]) == null ? void 0 : _i.text) ?? "" : content
549
- });
496
+ eventStream$.sendTextMessageContent(Array.isArray(content) ? ((_i = content[0]) == null ? void 0 : _i.text) ?? "" : content);
550
497
  } else if (mode === "function" && toolCallArgs) {
551
498
  if (toolCallDetails.index !== toolCallDetails.prevIndex) {
552
- eventStream$.sendActionExecutionEnd({
553
- actionExecutionId: toolCallId
554
- });
555
- eventStream$.sendActionExecutionStart({
556
- actionExecutionId: toolCallId,
557
- actionName: toolCallName
558
- });
499
+ eventStream$.sendActionExecutionEnd();
500
+ eventStream$.sendActionExecutionStart(toolCallId, toolCallName);
559
501
  toolCallDetails.prevIndex = toolCallDetails.index;
560
502
  }
561
- eventStream$.sendActionExecutionArgs({
562
- actionExecutionId: toolCallId,
563
- args: toolCallArgs
564
- });
503
+ eventStream$.sendActionExecutionArgs(toolCallArgs);
565
504
  }
566
505
  } catch (error) {
567
506
  console.error("Error reading from stream", error);
@@ -569,11 +508,7 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
569
508
  }
570
509
  }
571
510
  } else if (actionExecution) {
572
- eventStream$.sendActionExecutionResult({
573
- actionExecutionId: actionExecution.id,
574
- actionName: actionExecution.name,
575
- result: encodeResult(result)
576
- });
511
+ eventStream$.sendActionExecutionResult(actionExecution.id, actionExecution.name, encodeResult(result));
577
512
  } else {
578
513
  throw new Error("Invalid return type from LangChain function.");
579
514
  }
@@ -753,33 +688,21 @@ var OpenAIAssistantAdapter = class {
753
688
  eventSource.stream(async (eventStream$) => {
754
689
  var _a, _b, _c, _d, _e, _f;
755
690
  let inFunctionCall = false;
756
- let currentMessageId;
757
- let currentToolCallId;
758
691
  for await (const chunk of stream) {
759
692
  switch (chunk.event) {
760
693
  case "thread.message.created":
761
694
  if (inFunctionCall) {
762
- eventStream$.sendActionExecutionEnd({
763
- actionExecutionId: currentToolCallId
764
- });
695
+ eventStream$.sendActionExecutionEnd();
765
696
  }
766
- currentMessageId = chunk.data.id;
767
- eventStream$.sendTextMessageStart({
768
- messageId: currentMessageId
769
- });
697
+ eventStream$.sendTextMessageStart(chunk.data.id);
770
698
  break;
771
699
  case "thread.message.delta":
772
700
  if (((_a = chunk.data.delta.content) == null ? void 0 : _a[0].type) === "text") {
773
- eventStream$.sendTextMessageContent({
774
- messageId: currentMessageId,
775
- content: (_b = chunk.data.delta.content) == null ? void 0 : _b[0].text.value
776
- });
701
+ eventStream$.sendTextMessageContent((_b = chunk.data.delta.content) == null ? void 0 : _b[0].text.value);
777
702
  }
778
703
  break;
779
704
  case "thread.message.completed":
780
- eventStream$.sendTextMessageEnd({
781
- messageId: currentMessageId
782
- });
705
+ eventStream$.sendTextMessageEnd();
783
706
  break;
784
707
  case "thread.run.step.delta":
785
708
  let toolCallId;
@@ -792,29 +715,18 @@ var OpenAIAssistantAdapter = class {
792
715
  }
793
716
  if (toolCallName && toolCallId) {
794
717
  if (inFunctionCall) {
795
- eventStream$.sendActionExecutionEnd({
796
- actionExecutionId: currentToolCallId
797
- });
718
+ eventStream$.sendActionExecutionEnd();
798
719
  }
799
720
  inFunctionCall = true;
800
- currentToolCallId = toolCallId;
801
- eventStream$.sendActionExecutionStart({
802
- actionExecutionId: currentToolCallId,
803
- actionName: toolCallName
804
- });
721
+ eventStream$.sendActionExecutionStart(toolCallId, toolCallName);
805
722
  } else if (toolCallArgs) {
806
- eventStream$.sendActionExecutionArgs({
807
- actionExecutionId: currentToolCallId,
808
- args: toolCallArgs
809
- });
723
+ eventStream$.sendActionExecutionArgs(toolCallArgs);
810
724
  }
811
725
  break;
812
726
  }
813
727
  }
814
728
  if (inFunctionCall) {
815
- eventStream$.sendActionExecutionEnd({
816
- actionExecutionId: currentToolCallId
817
- });
729
+ eventStream$.sendActionExecutionEnd();
818
730
  }
819
731
  eventStream$.complete();
820
732
  });
@@ -867,77 +779,46 @@ var UnifyAdapter = class {
867
779
  }
868
780
  });
869
781
  let model = null;
870
- let currentMessageId;
871
- let currentToolCallId;
872
782
  request.eventSource.stream(async (eventStream$) => {
873
783
  var _a, _b;
874
784
  let mode = null;
875
785
  for await (const chunk of stream) {
876
786
  if (this.start) {
877
787
  model = chunk.model;
878
- currentMessageId = randomId4();
879
- eventStream$.sendTextMessageStart({
880
- messageId: currentMessageId
881
- });
882
- eventStream$.sendTextMessageContent({
883
- messageId: currentMessageId,
884
- content: `Model used: ${model}
885
- `
886
- });
887
- eventStream$.sendTextMessageEnd({
888
- messageId: currentMessageId
889
- });
788
+ eventStream$.sendTextMessageStart(randomId4());
789
+ eventStream$.sendTextMessageContent(`Model used: ${model}
790
+ `);
791
+ eventStream$.sendTextMessageEnd();
890
792
  this.start = false;
891
793
  }
892
794
  const toolCall = (_a = chunk.choices[0].delta.tool_calls) == null ? void 0 : _a[0];
893
795
  const content = chunk.choices[0].delta.content;
894
796
  if (mode === "message" && (toolCall == null ? void 0 : toolCall.id)) {
895
797
  mode = null;
896
- eventStream$.sendTextMessageEnd({
897
- messageId: currentMessageId
898
- });
798
+ eventStream$.sendTextMessageEnd();
899
799
  } else if (mode === "function" && (toolCall === void 0 || (toolCall == null ? void 0 : toolCall.id))) {
900
800
  mode = null;
901
- eventStream$.sendActionExecutionEnd({
902
- actionExecutionId: currentToolCallId
903
- });
801
+ eventStream$.sendActionExecutionEnd();
904
802
  }
905
803
  if (mode === null) {
906
804
  if (toolCall == null ? void 0 : toolCall.id) {
907
805
  mode = "function";
908
- currentToolCallId = toolCall.id;
909
- eventStream$.sendActionExecutionStart({
910
- actionExecutionId: currentToolCallId,
911
- actionName: toolCall.function.name
912
- });
806
+ eventStream$.sendActionExecutionStart(toolCall.id, toolCall.function.name);
913
807
  } else if (content) {
914
808
  mode = "message";
915
- currentMessageId = chunk.id;
916
- eventStream$.sendTextMessageStart({
917
- messageId: currentMessageId
918
- });
809
+ eventStream$.sendTextMessageStart(chunk.id);
919
810
  }
920
811
  }
921
812
  if (mode === "message" && content) {
922
- eventStream$.sendTextMessageContent({
923
- messageId: currentMessageId,
924
- content
925
- });
813
+ eventStream$.sendTextMessageContent(content);
926
814
  } else if (mode === "function" && ((_b = toolCall == null ? void 0 : toolCall.function) == null ? void 0 : _b.arguments)) {
927
- eventStream$.sendActionExecutionArgs({
928
- actionExecutionId: currentToolCallId,
929
- args: toolCall.function.arguments
930
- });
815
+ eventStream$.sendActionExecutionArgs(toolCall.function.arguments);
931
816
  }
932
817
  }
933
818
  if (mode === "message") {
934
- eventStream$.sendTextMessageEnd({
935
- messageId: currentMessageId
936
- });
819
+ eventStream$.sendTextMessageEnd();
937
820
  } else if (mode === "function") {
938
- eventStream$.sendActionExecutionEnd({
939
- actionExecutionId: currentToolCallId
940
- });
821
+ eventStream$.sendActionExecutionEnd();
941
822
  }
942
823
  eventStream$.complete();
943
824
  });
@@ -1003,58 +884,35 @@ var GroqAdapter = class {
1003
884
  eventSource.stream(async (eventStream$) => {
1004
885
  var _a, _b;
1005
886
  let mode = null;
1006
- let currentMessageId;
1007
- let currentToolCallId;
1008
887
  for await (const chunk of stream) {
1009
888
  const toolCall = (_a = chunk.choices[0].delta.tool_calls) == null ? void 0 : _a[0];
1010
889
  const content = chunk.choices[0].delta.content;
1011
890
  if (mode === "message" && (toolCall == null ? void 0 : toolCall.id)) {
1012
891
  mode = null;
1013
- eventStream$.sendTextMessageEnd({
1014
- messageId: currentMessageId
1015
- });
892
+ eventStream$.sendTextMessageEnd();
1016
893
  } else if (mode === "function" && (toolCall === void 0 || (toolCall == null ? void 0 : toolCall.id))) {
1017
894
  mode = null;
1018
- eventStream$.sendActionExecutionEnd({
1019
- actionExecutionId: currentToolCallId
1020
- });
895
+ eventStream$.sendActionExecutionEnd();
1021
896
  }
1022
897
  if (mode === null) {
1023
898
  if (toolCall == null ? void 0 : toolCall.id) {
1024
899
  mode = "function";
1025
- currentToolCallId = toolCall.id;
1026
- eventStream$.sendActionExecutionStart({
1027
- actionExecutionId: currentToolCallId,
1028
- actionName: toolCall.function.name
1029
- });
900
+ eventStream$.sendActionExecutionStart(toolCall.id, toolCall.function.name);
1030
901
  } else if (content) {
1031
902
  mode = "message";
1032
- currentMessageId = chunk.id;
1033
- eventStream$.sendTextMessageStart({
1034
- messageId: currentMessageId
1035
- });
903
+ eventStream$.sendTextMessageStart(chunk.id);
1036
904
  }
1037
905
  }
1038
906
  if (mode === "message" && content) {
1039
- eventStream$.sendTextMessageContent({
1040
- messageId: currentMessageId,
1041
- content
1042
- });
907
+ eventStream$.sendTextMessageContent(content);
1043
908
  } else if (mode === "function" && ((_b = toolCall == null ? void 0 : toolCall.function) == null ? void 0 : _b.arguments)) {
1044
- eventStream$.sendActionExecutionArgs({
1045
- actionExecutionId: currentToolCallId,
1046
- args: toolCall.function.arguments
1047
- });
909
+ eventStream$.sendActionExecutionArgs(toolCall.function.arguments);
1048
910
  }
1049
911
  }
1050
912
  if (mode === "message") {
1051
- eventStream$.sendTextMessageEnd({
1052
- messageId: currentMessageId
1053
- });
913
+ eventStream$.sendTextMessageEnd();
1054
914
  } else if (mode === "function") {
1055
- eventStream$.sendActionExecutionEnd({
1056
- actionExecutionId: currentToolCallId
1057
- });
915
+ eventStream$.sendActionExecutionEnd();
1058
916
  }
1059
917
  eventStream$.complete();
1060
918
  });
@@ -1262,10 +1120,7 @@ var AnthropicAdapter = class {
1262
1120
  mode = "message";
1263
1121
  } else if (chunk.content_block.type === "tool_use") {
1264
1122
  currentToolCallId = chunk.content_block.id;
1265
- eventStream$.sendActionExecutionStart({
1266
- actionExecutionId: currentToolCallId,
1267
- actionName: chunk.content_block.name
1268
- });
1123
+ eventStream$.sendActionExecutionStart(currentToolCallId, chunk.content_block.name);
1269
1124
  mode = "function";
1270
1125
  }
1271
1126
  } else if (chunk.type === "content_block_delta") {
@@ -1273,33 +1128,21 @@ var AnthropicAdapter = class {
1273
1128
  const text = filterThinkingTextBuffer.onTextChunk(chunk.delta.text);
1274
1129
  if (text.length > 0) {
1275
1130
  if (!didOutputText) {
1276
- eventStream$.sendTextMessageStart({
1277
- messageId: currentMessageId
1278
- });
1131
+ eventStream$.sendTextMessageStart(currentMessageId);
1279
1132
  didOutputText = true;
1280
1133
  }
1281
- eventStream$.sendTextMessageContent({
1282
- messageId: currentMessageId,
1283
- content: text
1284
- });
1134
+ eventStream$.sendTextMessageContent(text);
1285
1135
  }
1286
1136
  } else if (chunk.delta.type === "input_json_delta") {
1287
- eventStream$.sendActionExecutionArgs({
1288
- actionExecutionId: currentToolCallId,
1289
- args: chunk.delta.partial_json
1290
- });
1137
+ eventStream$.sendActionExecutionArgs(chunk.delta.partial_json);
1291
1138
  }
1292
1139
  } else if (chunk.type === "content_block_stop") {
1293
1140
  if (mode === "message") {
1294
1141
  if (didOutputText) {
1295
- eventStream$.sendTextMessageEnd({
1296
- messageId: currentMessageId
1297
- });
1142
+ eventStream$.sendTextMessageEnd();
1298
1143
  }
1299
1144
  } else if (mode === "function") {
1300
- eventStream$.sendActionExecutionEnd({
1301
- actionExecutionId: currentToolCallId
1302
- });
1145
+ eventStream$.sendActionExecutionEnd();
1303
1146
  }
1304
1147
  }
1305
1148
  }
@@ -1355,4 +1198,4 @@ export {
1355
1198
  GroqAdapter,
1356
1199
  AnthropicAdapter
1357
1200
  };
1358
- //# sourceMappingURL=chunk-56IQ6PGC.mjs.map
1201
+ //# sourceMappingURL=chunk-WHJ3DAYL.mjs.map