@copilotkit/runtime 1.4.0-pre-1-4-0-alpha.10 → 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 (60) hide show
  1. package/CHANGELOG.md +160 -24
  2. package/dist/{chunk-YUJSVJWS.mjs → chunk-6H45CJUK.mjs} +2 -2
  3. package/dist/{chunk-SBWLAAB3.mjs → chunk-N4ROMSZN.mjs} +2 -2
  4. package/dist/{chunk-SVL5LEKB.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-RDHJQVWH.mjs → chunk-X4FFTYTH.mjs} +49 -92
  8. package/dist/chunk-X4FFTYTH.mjs.map +1 -0
  9. package/dist/{copilot-runtime-dbe5fa02.d.ts → copilot-runtime-335a610d.d.ts} +8 -8
  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 +103 -303
  13. package/dist/index.js.map +1 -1
  14. package/dist/index.mjs +7 -7
  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 +97 -282
  18. package/dist/lib/index.js.map +1 -1
  19. package/dist/lib/index.mjs +7 -7
  20. package/dist/lib/integrations/index.d.ts +3 -3
  21. package/dist/lib/integrations/index.js +6 -14
  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 +6 -14
  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 +6 -14
  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 +6 -14
  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 +2 -14
  42. package/src/graphql/resolvers/copilot.resolver.ts +2 -28
  43. package/src/lib/runtime/copilot-runtime.ts +6 -6
  44. package/src/lib/runtime/remote-action-constructors.ts +7 -7
  45. package/src/lib/runtime/remote-actions.ts +9 -9
  46. package/src/lib/runtime/{remote-lg-cloud-action.ts → remote-lg-action.ts} +18 -18
  47. package/src/lib/telemetry-client.ts +3 -3
  48. package/src/service-adapters/anthropic/anthropic-adapter.ts +6 -15
  49. package/src/service-adapters/events.ts +35 -73
  50. package/src/service-adapters/experimental/ollama/ollama-adapter.ts +3 -7
  51. package/src/service-adapters/groq/groq-adapter.ts +8 -22
  52. package/src/service-adapters/langchain/utils.ts +31 -47
  53. package/src/service-adapters/openai/openai-adapter.ts +9 -21
  54. package/src/service-adapters/openai/openai-assistant-adapter.ts +8 -21
  55. package/src/service-adapters/unify/unify-adapter.ts +11 -28
  56. package/dist/chunk-56IQ6PGC.mjs.map +0 -1
  57. package/dist/chunk-RDHJQVWH.mjs.map +0 -1
  58. /package/dist/{chunk-YUJSVJWS.mjs.map → chunk-6H45CJUK.mjs.map} +0 -0
  59. /package/dist/{chunk-SBWLAAB3.mjs.map → chunk-N4ROMSZN.mjs.map} +0 -0
  60. /package/dist/{chunk-SVL5LEKB.mjs.map → chunk-NFMXFL2C.mjs.map} +0 -0
package/dist/index.js CHANGED
@@ -44,7 +44,7 @@ var require_package = __commonJS({
44
44
  publishConfig: {
45
45
  access: "public"
46
46
  },
47
- version: "1.4.0-pre-1-4-0-alpha.10",
47
+ version: "1.4.0-pre-1-4-0.14",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -147,7 +147,7 @@ __export(src_exports, {
147
147
  createContext: () => createContext,
148
148
  flattenToolCallsNoDuplicates: () => flattenToolCallsNoDuplicates,
149
149
  getCommonConfig: () => getCommonConfig,
150
- langGraphCloudEndpoint: () => langGraphCloudEndpoint,
150
+ langGraphPlatformEndpoint: () => langGraphPlatformEndpoint,
151
151
  resolveEndpointType: () => resolveEndpointType
152
152
  });
153
153
  module.exports = __toCommonJS(src_exports);
@@ -430,8 +430,6 @@ var OpenAIAdapter = class {
430
430
  eventSource.stream(async (eventStream$) => {
431
431
  var _a, _b;
432
432
  let mode = null;
433
- let currentMessageId;
434
- let currentToolCallId;
435
433
  for await (const chunk of stream) {
436
434
  if (chunk.choices.length === 0) {
437
435
  continue;
@@ -440,51 +438,30 @@ var OpenAIAdapter = class {
440
438
  const content = chunk.choices[0].delta.content;
441
439
  if (mode === "message" && (toolCall == null ? void 0 : toolCall.id)) {
442
440
  mode = null;
443
- eventStream$.sendTextMessageEnd({
444
- messageId: currentMessageId
445
- });
441
+ eventStream$.sendTextMessageEnd();
446
442
  } else if (mode === "function" && (toolCall === void 0 || (toolCall == null ? void 0 : toolCall.id))) {
447
443
  mode = null;
448
- eventStream$.sendActionExecutionEnd({
449
- actionExecutionId: currentToolCallId
450
- });
444
+ eventStream$.sendActionExecutionEnd();
451
445
  }
452
446
  if (mode === null) {
453
447
  if (toolCall == null ? void 0 : toolCall.id) {
454
448
  mode = "function";
455
- currentToolCallId = toolCall.id;
456
- eventStream$.sendActionExecutionStart({
457
- actionExecutionId: currentToolCallId,
458
- actionName: toolCall.function.name
459
- });
449
+ eventStream$.sendActionExecutionStart(toolCall.id, toolCall.function.name);
460
450
  } else if (content) {
461
451
  mode = "message";
462
- currentMessageId = chunk.id;
463
- eventStream$.sendTextMessageStart({
464
- messageId: currentMessageId
465
- });
452
+ eventStream$.sendTextMessageStart(chunk.id);
466
453
  }
467
454
  }
468
455
  if (mode === "message" && content) {
469
- eventStream$.sendTextMessageContent({
470
- messageId: currentMessageId,
471
- content
472
- });
456
+ eventStream$.sendTextMessageContent(content);
473
457
  } else if (mode === "function" && ((_b = toolCall == null ? void 0 : toolCall.function) == null ? void 0 : _b.arguments)) {
474
- eventStream$.sendActionExecutionArgs({
475
- actionExecutionId: currentToolCallId,
476
- args: toolCall.function.arguments
477
- });
458
+ eventStream$.sendActionExecutionArgs(toolCall.function.arguments);
478
459
  }
479
460
  }
480
461
  if (mode === "message") {
481
- eventStream$.sendTextMessageEnd({
482
- messageId: currentMessageId
483
- });
462
+ eventStream$.sendTextMessageEnd();
484
463
  } else if (mode === "function") {
485
- eventStream$.sendActionExecutionEnd({
486
- actionExecutionId: currentToolCallId
487
- });
464
+ eventStream$.sendActionExecutionEnd();
488
465
  }
489
466
  eventStream$.complete();
490
467
  });
@@ -580,11 +557,7 @@ function isBaseMessageChunk(message) {
580
557
  __name(isBaseMessageChunk, "isBaseMessageChunk");
581
558
  function maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution) {
582
559
  if (actionExecution) {
583
- eventStream$.sendActionExecutionResult({
584
- actionExecutionId: actionExecution.id,
585
- actionName: actionExecution.name,
586
- result: "Sending a message"
587
- });
560
+ eventStream$.sendActionExecutionResult(actionExecution.id, actionExecution.name, "Sending a message");
588
561
  }
589
562
  }
590
563
  __name(maybeSendActionExecutionResultIsMessage, "maybeSendActionExecutionResultIsMessage");
@@ -594,11 +567,7 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
594
567
  if (!actionExecution) {
595
568
  eventStream$.sendTextMessage((0, import_shared2.randomId)(), result);
596
569
  } else {
597
- eventStream$.sendActionExecutionResult({
598
- actionExecutionId: actionExecution.id,
599
- actionName: actionExecution.name,
600
- result
601
- });
570
+ eventStream$.sendActionExecutionResult(actionExecution.id, actionExecution.name, result);
602
571
  }
603
572
  } else if (isAIMessage(result)) {
604
573
  maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution);
@@ -606,11 +575,7 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
606
575
  eventStream$.sendTextMessage((0, import_shared2.randomId)(), result.content);
607
576
  }
608
577
  for (const toolCall of result.tool_calls) {
609
- eventStream$.sendActionExecution({
610
- actionExecutionId: toolCall.id || (0, import_shared2.randomId)(),
611
- actionName: toolCall.name,
612
- args: JSON.stringify(toolCall.args)
613
- });
578
+ eventStream$.sendActionExecution(toolCall.id || (0, import_shared2.randomId)(), toolCall.name, JSON.stringify(toolCall.args));
614
579
  }
615
580
  } else if (isBaseMessageChunk(result)) {
616
581
  maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution);
@@ -619,11 +584,7 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
619
584
  }
620
585
  if ((_b = result.lc_kwargs) == null ? void 0 : _b.tool_calls) {
621
586
  for (const toolCall of (_c = result.lc_kwargs) == null ? void 0 : _c.tool_calls) {
622
- eventStream$.sendActionExecution({
623
- actionExecutionId: toolCall.id || (0, import_shared2.randomId)(),
624
- actionName: toolCall.name,
625
- args: JSON.stringify(toolCall.args)
626
- });
587
+ eventStream$.sendActionExecution(toolCall.id || (0, import_shared2.randomId)(), toolCall.name, JSON.stringify(toolCall.args));
627
588
  }
628
589
  }
629
590
  } else if (result && "getReader" in result) {
@@ -641,7 +602,6 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
641
602
  const { done, value } = await reader.read();
642
603
  let toolCallName = void 0;
643
604
  let toolCallId = void 0;
644
- let currentMessageId;
645
605
  let toolCallArgs = void 0;
646
606
  let hasToolCall = false;
647
607
  let content = value == null ? void 0 : value.content;
@@ -669,14 +629,10 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
669
629
  }
670
630
  if (mode === "message" && (toolCallId || done)) {
671
631
  mode = null;
672
- eventStream$.sendTextMessageEnd({
673
- messageId: currentMessageId
674
- });
632
+ eventStream$.sendTextMessageEnd();
675
633
  } else if (mode === "function" && (!hasToolCall || done)) {
676
634
  mode = null;
677
- eventStream$.sendActionExecutionEnd({
678
- actionExecutionId: toolCallId
679
- });
635
+ eventStream$.sendActionExecutionEnd();
680
636
  }
681
637
  if (done) {
682
638
  break;
@@ -684,38 +640,21 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
684
640
  if (mode === null) {
685
641
  if (hasToolCall && toolCallId && toolCallName) {
686
642
  mode = "function";
687
- eventStream$.sendActionExecutionStart({
688
- actionExecutionId: toolCallId,
689
- actionName: toolCallName
690
- });
643
+ eventStream$.sendActionExecutionStart(toolCallId, toolCallName);
691
644
  } else if (content) {
692
645
  mode = "message";
693
- currentMessageId = (0, import_shared2.randomId)();
694
- eventStream$.sendTextMessageStart({
695
- messageId: currentMessageId
696
- });
646
+ eventStream$.sendTextMessageStart((0, import_shared2.randomId)());
697
647
  }
698
648
  }
699
649
  if (mode === "message" && content) {
700
- eventStream$.sendTextMessageContent({
701
- messageId: currentMessageId,
702
- content: Array.isArray(content) ? ((_i = content[0]) == null ? void 0 : _i.text) ?? "" : content
703
- });
650
+ eventStream$.sendTextMessageContent(Array.isArray(content) ? ((_i = content[0]) == null ? void 0 : _i.text) ?? "" : content);
704
651
  } else if (mode === "function" && toolCallArgs) {
705
652
  if (toolCallDetails.index !== toolCallDetails.prevIndex) {
706
- eventStream$.sendActionExecutionEnd({
707
- actionExecutionId: toolCallId
708
- });
709
- eventStream$.sendActionExecutionStart({
710
- actionExecutionId: toolCallId,
711
- actionName: toolCallName
712
- });
653
+ eventStream$.sendActionExecutionEnd();
654
+ eventStream$.sendActionExecutionStart(toolCallId, toolCallName);
713
655
  toolCallDetails.prevIndex = toolCallDetails.index;
714
656
  }
715
- eventStream$.sendActionExecutionArgs({
716
- actionExecutionId: toolCallId,
717
- args: toolCallArgs
718
- });
657
+ eventStream$.sendActionExecutionArgs(toolCallArgs);
719
658
  }
720
659
  } catch (error) {
721
660
  console.error("Error reading from stream", error);
@@ -723,11 +662,7 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
723
662
  }
724
663
  }
725
664
  } else if (actionExecution) {
726
- eventStream$.sendActionExecutionResult({
727
- actionExecutionId: actionExecution.id,
728
- actionName: actionExecution.name,
729
- result: encodeResult(result)
730
- });
665
+ eventStream$.sendActionExecutionResult(actionExecution.id, actionExecution.name, encodeResult(result));
731
666
  } else {
732
667
  throw new Error("Invalid return type from LangChain function.");
733
668
  }
@@ -907,33 +842,21 @@ var OpenAIAssistantAdapter = class {
907
842
  eventSource.stream(async (eventStream$) => {
908
843
  var _a, _b, _c, _d, _e, _f;
909
844
  let inFunctionCall = false;
910
- let currentMessageId;
911
- let currentToolCallId;
912
845
  for await (const chunk of stream) {
913
846
  switch (chunk.event) {
914
847
  case "thread.message.created":
915
848
  if (inFunctionCall) {
916
- eventStream$.sendActionExecutionEnd({
917
- actionExecutionId: currentToolCallId
918
- });
849
+ eventStream$.sendActionExecutionEnd();
919
850
  }
920
- currentMessageId = chunk.data.id;
921
- eventStream$.sendTextMessageStart({
922
- messageId: currentMessageId
923
- });
851
+ eventStream$.sendTextMessageStart(chunk.data.id);
924
852
  break;
925
853
  case "thread.message.delta":
926
854
  if (((_a = chunk.data.delta.content) == null ? void 0 : _a[0].type) === "text") {
927
- eventStream$.sendTextMessageContent({
928
- messageId: currentMessageId,
929
- content: (_b = chunk.data.delta.content) == null ? void 0 : _b[0].text.value
930
- });
855
+ eventStream$.sendTextMessageContent((_b = chunk.data.delta.content) == null ? void 0 : _b[0].text.value);
931
856
  }
932
857
  break;
933
858
  case "thread.message.completed":
934
- eventStream$.sendTextMessageEnd({
935
- messageId: currentMessageId
936
- });
859
+ eventStream$.sendTextMessageEnd();
937
860
  break;
938
861
  case "thread.run.step.delta":
939
862
  let toolCallId;
@@ -946,29 +869,18 @@ var OpenAIAssistantAdapter = class {
946
869
  }
947
870
  if (toolCallName && toolCallId) {
948
871
  if (inFunctionCall) {
949
- eventStream$.sendActionExecutionEnd({
950
- actionExecutionId: currentToolCallId
951
- });
872
+ eventStream$.sendActionExecutionEnd();
952
873
  }
953
874
  inFunctionCall = true;
954
- currentToolCallId = toolCallId;
955
- eventStream$.sendActionExecutionStart({
956
- actionExecutionId: currentToolCallId,
957
- actionName: toolCallName
958
- });
875
+ eventStream$.sendActionExecutionStart(toolCallId, toolCallName);
959
876
  } else if (toolCallArgs) {
960
- eventStream$.sendActionExecutionArgs({
961
- actionExecutionId: currentToolCallId,
962
- args: toolCallArgs
963
- });
877
+ eventStream$.sendActionExecutionArgs(toolCallArgs);
964
878
  }
965
879
  break;
966
880
  }
967
881
  }
968
882
  if (inFunctionCall) {
969
- eventStream$.sendActionExecutionEnd({
970
- actionExecutionId: currentToolCallId
971
- });
883
+ eventStream$.sendActionExecutionEnd();
972
884
  }
973
885
  eventStream$.complete();
974
886
  });
@@ -1021,77 +933,46 @@ var UnifyAdapter = class {
1021
933
  }
1022
934
  });
1023
935
  let model = null;
1024
- let currentMessageId;
1025
- let currentToolCallId;
1026
936
  request.eventSource.stream(async (eventStream$) => {
1027
937
  var _a, _b;
1028
938
  let mode = null;
1029
939
  for await (const chunk of stream) {
1030
940
  if (this.start) {
1031
941
  model = chunk.model;
1032
- currentMessageId = (0, import_shared4.randomId)();
1033
- eventStream$.sendTextMessageStart({
1034
- messageId: currentMessageId
1035
- });
1036
- eventStream$.sendTextMessageContent({
1037
- messageId: currentMessageId,
1038
- content: `Model used: ${model}
1039
- `
1040
- });
1041
- eventStream$.sendTextMessageEnd({
1042
- messageId: currentMessageId
1043
- });
942
+ eventStream$.sendTextMessageStart((0, import_shared4.randomId)());
943
+ eventStream$.sendTextMessageContent(`Model used: ${model}
944
+ `);
945
+ eventStream$.sendTextMessageEnd();
1044
946
  this.start = false;
1045
947
  }
1046
948
  const toolCall = (_a = chunk.choices[0].delta.tool_calls) == null ? void 0 : _a[0];
1047
949
  const content = chunk.choices[0].delta.content;
1048
950
  if (mode === "message" && (toolCall == null ? void 0 : toolCall.id)) {
1049
951
  mode = null;
1050
- eventStream$.sendTextMessageEnd({
1051
- messageId: currentMessageId
1052
- });
952
+ eventStream$.sendTextMessageEnd();
1053
953
  } else if (mode === "function" && (toolCall === void 0 || (toolCall == null ? void 0 : toolCall.id))) {
1054
954
  mode = null;
1055
- eventStream$.sendActionExecutionEnd({
1056
- actionExecutionId: currentToolCallId
1057
- });
955
+ eventStream$.sendActionExecutionEnd();
1058
956
  }
1059
957
  if (mode === null) {
1060
958
  if (toolCall == null ? void 0 : toolCall.id) {
1061
959
  mode = "function";
1062
- currentToolCallId = toolCall.id;
1063
- eventStream$.sendActionExecutionStart({
1064
- actionExecutionId: currentToolCallId,
1065
- actionName: toolCall.function.name
1066
- });
960
+ eventStream$.sendActionExecutionStart(toolCall.id, toolCall.function.name);
1067
961
  } else if (content) {
1068
962
  mode = "message";
1069
- currentMessageId = chunk.id;
1070
- eventStream$.sendTextMessageStart({
1071
- messageId: currentMessageId
1072
- });
963
+ eventStream$.sendTextMessageStart(chunk.id);
1073
964
  }
1074
965
  }
1075
966
  if (mode === "message" && content) {
1076
- eventStream$.sendTextMessageContent({
1077
- messageId: currentMessageId,
1078
- content
1079
- });
967
+ eventStream$.sendTextMessageContent(content);
1080
968
  } else if (mode === "function" && ((_b = toolCall == null ? void 0 : toolCall.function) == null ? void 0 : _b.arguments)) {
1081
- eventStream$.sendActionExecutionArgs({
1082
- actionExecutionId: currentToolCallId,
1083
- args: toolCall.function.arguments
1084
- });
969
+ eventStream$.sendActionExecutionArgs(toolCall.function.arguments);
1085
970
  }
1086
971
  }
1087
972
  if (mode === "message") {
1088
- eventStream$.sendTextMessageEnd({
1089
- messageId: currentMessageId
1090
- });
973
+ eventStream$.sendTextMessageEnd();
1091
974
  } else if (mode === "function") {
1092
- eventStream$.sendActionExecutionEnd({
1093
- actionExecutionId: currentToolCallId
1094
- });
975
+ eventStream$.sendActionExecutionEnd();
1095
976
  }
1096
977
  eventStream$.complete();
1097
978
  });
@@ -1157,58 +1038,35 @@ var GroqAdapter = class {
1157
1038
  eventSource.stream(async (eventStream$) => {
1158
1039
  var _a, _b;
1159
1040
  let mode = null;
1160
- let currentMessageId;
1161
- let currentToolCallId;
1162
1041
  for await (const chunk of stream) {
1163
1042
  const toolCall = (_a = chunk.choices[0].delta.tool_calls) == null ? void 0 : _a[0];
1164
1043
  const content = chunk.choices[0].delta.content;
1165
1044
  if (mode === "message" && (toolCall == null ? void 0 : toolCall.id)) {
1166
1045
  mode = null;
1167
- eventStream$.sendTextMessageEnd({
1168
- messageId: currentMessageId
1169
- });
1046
+ eventStream$.sendTextMessageEnd();
1170
1047
  } else if (mode === "function" && (toolCall === void 0 || (toolCall == null ? void 0 : toolCall.id))) {
1171
1048
  mode = null;
1172
- eventStream$.sendActionExecutionEnd({
1173
- actionExecutionId: currentToolCallId
1174
- });
1049
+ eventStream$.sendActionExecutionEnd();
1175
1050
  }
1176
1051
  if (mode === null) {
1177
1052
  if (toolCall == null ? void 0 : toolCall.id) {
1178
1053
  mode = "function";
1179
- currentToolCallId = toolCall.id;
1180
- eventStream$.sendActionExecutionStart({
1181
- actionExecutionId: currentToolCallId,
1182
- actionName: toolCall.function.name
1183
- });
1054
+ eventStream$.sendActionExecutionStart(toolCall.id, toolCall.function.name);
1184
1055
  } else if (content) {
1185
1056
  mode = "message";
1186
- currentMessageId = chunk.id;
1187
- eventStream$.sendTextMessageStart({
1188
- messageId: currentMessageId
1189
- });
1057
+ eventStream$.sendTextMessageStart(chunk.id);
1190
1058
  }
1191
1059
  }
1192
1060
  if (mode === "message" && content) {
1193
- eventStream$.sendTextMessageContent({
1194
- messageId: currentMessageId,
1195
- content
1196
- });
1061
+ eventStream$.sendTextMessageContent(content);
1197
1062
  } else if (mode === "function" && ((_b = toolCall == null ? void 0 : toolCall.function) == null ? void 0 : _b.arguments)) {
1198
- eventStream$.sendActionExecutionArgs({
1199
- actionExecutionId: currentToolCallId,
1200
- args: toolCall.function.arguments
1201
- });
1063
+ eventStream$.sendActionExecutionArgs(toolCall.function.arguments);
1202
1064
  }
1203
1065
  }
1204
1066
  if (mode === "message") {
1205
- eventStream$.sendTextMessageEnd({
1206
- messageId: currentMessageId
1207
- });
1067
+ eventStream$.sendTextMessageEnd();
1208
1068
  } else if (mode === "function") {
1209
- eventStream$.sendActionExecutionEnd({
1210
- actionExecutionId: currentToolCallId
1211
- });
1069
+ eventStream$.sendActionExecutionEnd();
1212
1070
  }
1213
1071
  eventStream$.complete();
1214
1072
  });
@@ -1416,10 +1274,7 @@ var AnthropicAdapter = class {
1416
1274
  mode = "message";
1417
1275
  } else if (chunk.content_block.type === "tool_use") {
1418
1276
  currentToolCallId = chunk.content_block.id;
1419
- eventStream$.sendActionExecutionStart({
1420
- actionExecutionId: currentToolCallId,
1421
- actionName: chunk.content_block.name
1422
- });
1277
+ eventStream$.sendActionExecutionStart(currentToolCallId, chunk.content_block.name);
1423
1278
  mode = "function";
1424
1279
  }
1425
1280
  } else if (chunk.type === "content_block_delta") {
@@ -1427,33 +1282,21 @@ var AnthropicAdapter = class {
1427
1282
  const text = filterThinkingTextBuffer.onTextChunk(chunk.delta.text);
1428
1283
  if (text.length > 0) {
1429
1284
  if (!didOutputText) {
1430
- eventStream$.sendTextMessageStart({
1431
- messageId: currentMessageId
1432
- });
1285
+ eventStream$.sendTextMessageStart(currentMessageId);
1433
1286
  didOutputText = true;
1434
1287
  }
1435
- eventStream$.sendTextMessageContent({
1436
- messageId: currentMessageId,
1437
- content: text
1438
- });
1288
+ eventStream$.sendTextMessageContent(text);
1439
1289
  }
1440
1290
  } else if (chunk.delta.type === "input_json_delta") {
1441
- eventStream$.sendActionExecutionArgs({
1442
- actionExecutionId: currentToolCallId,
1443
- args: chunk.delta.partial_json
1444
- });
1291
+ eventStream$.sendActionExecutionArgs(chunk.delta.partial_json);
1445
1292
  }
1446
1293
  } else if (chunk.type === "content_block_stop") {
1447
1294
  if (mode === "message") {
1448
1295
  if (didOutputText) {
1449
- eventStream$.sendTextMessageEnd({
1450
- messageId: currentMessageId
1451
- });
1296
+ eventStream$.sendTextMessageEnd();
1452
1297
  }
1453
1298
  } else if (mode === "function") {
1454
- eventStream$.sendActionExecutionEnd({
1455
- actionExecutionId: currentToolCallId
1456
- });
1299
+ eventStream$.sendActionExecutionEnd();
1457
1300
  }
1458
1301
  }
1459
1302
  }
@@ -1562,7 +1405,7 @@ var RemoteLangGraphEventSource = class {
1562
1405
  acc.content = null;
1563
1406
  }
1564
1407
  const toolCallChunks = (
1565
- // @ts-expect-error -- LangGraph Cloud implementation stores data outside of kwargs
1408
+ // @ts-expect-error -- LangGraph Platform implementation stores data outside of kwargs
1566
1409
  ((_h = (_g = (_f = event.data) == null ? void 0 : _f.chunk) == null ? void 0 : _g.kwargs) == null ? void 0 : _h.tool_call_chunks) ?? ((_j = (_i = event.data) == null ? void 0 : _i.chunk) == null ? void 0 : _j.tool_call_chunks)
1567
1410
  );
1568
1411
  const toolCallMessageId = ((_m = (_l = (_k = event.data) == null ? void 0 : _k.chunk) == null ? void 0 : _l.kwargs) == null ? void 0 : _m.id) ?? ((_o = (_n = event.data) == null ? void 0 : _n.chunk) == null ? void 0 : _o.id);
@@ -1618,14 +1461,12 @@ var RemoteLangGraphEventSource = class {
1618
1461
  }
1619
1462
  if (eventWithState.prevToolCallMessageId !== null && eventWithState.prevToolCallMessageId !== eventWithState.toolCallMessageId && this.shouldEmitToolCall(shouldEmitToolCalls, eventWithState.toolCallName)) {
1620
1463
  events.push({
1621
- type: RuntimeEventTypes.ActionExecutionEnd,
1622
- actionExecutionId: eventWithState.prevToolCallMessageId
1464
+ type: RuntimeEventTypes.ActionExecutionEnd
1623
1465
  });
1624
1466
  }
1625
1467
  if (eventWithState.prevMessageId !== null && eventWithState.prevMessageId !== eventWithState.messageId && shouldEmitMessages) {
1626
1468
  events.push({
1627
- type: RuntimeEventTypes.TextMessageEnd,
1628
- messageId: eventWithState.prevMessageId
1469
+ type: RuntimeEventTypes.TextMessageEnd
1629
1470
  });
1630
1471
  }
1631
1472
  switch (eventWithState.event.event) {
@@ -1637,12 +1478,10 @@ var RemoteLangGraphEventSource = class {
1637
1478
  });
1638
1479
  events.push({
1639
1480
  type: RuntimeEventTypes.TextMessageContent,
1640
- messageId: eventWithState.event.data.message_id,
1641
1481
  content: eventWithState.event.data.message
1642
1482
  });
1643
1483
  events.push({
1644
- type: RuntimeEventTypes.TextMessageEnd,
1645
- messageId: eventWithState.event.data.message_id
1484
+ type: RuntimeEventTypes.TextMessageEnd
1646
1485
  });
1647
1486
  } else if (eventWithState.event.name === CustomEventNames.CopilotKitManuallyEmitToolCall) {
1648
1487
  events.push({
@@ -1652,12 +1491,10 @@ var RemoteLangGraphEventSource = class {
1652
1491
  });
1653
1492
  events.push({
1654
1493
  type: RuntimeEventTypes.ActionExecutionArgs,
1655
- actionExecutionId: eventWithState.event.data.id,
1656
1494
  args: JSON.stringify(eventWithState.event.data.args)
1657
1495
  });
1658
1496
  events.push({
1659
- type: RuntimeEventTypes.ActionExecutionEnd,
1660
- actionExecutionId: eventWithState.event.data.id
1497
+ type: RuntimeEventTypes.ActionExecutionEnd
1661
1498
  });
1662
1499
  }
1663
1500
  break;
@@ -1701,7 +1538,6 @@ var RemoteLangGraphEventSource = class {
1701
1538
  if (this.shouldEmitToolCall(shouldEmitToolCalls, eventWithState.toolCallName)) {
1702
1539
  events.push({
1703
1540
  type: RuntimeEventTypes.ActionExecutionArgs,
1704
- actionExecutionId: eventWithState.toolCallMessageId,
1705
1541
  args
1706
1542
  });
1707
1543
  }
@@ -1709,7 +1545,6 @@ var RemoteLangGraphEventSource = class {
1709
1545
  if (shouldEmitMessages) {
1710
1546
  events.push({
1711
1547
  type: RuntimeEventTypes.TextMessageContent,
1712
- messageId: eventWithState.messageId,
1713
1548
  content
1714
1549
  });
1715
1550
  }
@@ -1722,14 +1557,12 @@ var RemoteLangGraphEventSource = class {
1722
1557
  const events = [];
1723
1558
  if (lastEventWithState == null ? void 0 : lastEventWithState.messageId) {
1724
1559
  events.push({
1725
- type: RuntimeEventTypes.TextMessageEnd,
1726
- messageId: lastEventWithState.messageId
1560
+ type: RuntimeEventTypes.TextMessageEnd
1727
1561
  });
1728
1562
  }
1729
1563
  if (lastEventWithState == null ? void 0 : lastEventWithState.toolCallMessageId) {
1730
1564
  events.push({
1731
- type: RuntimeEventTypes.ActionExecutionEnd,
1732
- actionExecutionId: lastEventWithState.toolCallMessageId
1565
+ type: RuntimeEventTypes.ActionExecutionEnd
1733
1566
  });
1734
1567
  }
1735
1568
  const messageId = (0, import_shared7.randomId)();
@@ -1739,12 +1572,10 @@ var RemoteLangGraphEventSource = class {
1739
1572
  });
1740
1573
  events.push({
1741
1574
  type: RuntimeEventTypes.TextMessageContent,
1742
- messageId,
1743
1575
  content: "\u274C An error occurred. Please try again."
1744
1576
  });
1745
1577
  events.push({
1746
- type: RuntimeEventTypes.TextMessageEnd,
1747
- messageId
1578
+ type: RuntimeEventTypes.TextMessageEnd
1748
1579
  });
1749
1580
  return events;
1750
1581
  }));
@@ -1752,7 +1583,7 @@ var RemoteLangGraphEventSource = class {
1752
1583
  };
1753
1584
  __name(RemoteLangGraphEventSource, "RemoteLangGraphEventSource");
1754
1585
 
1755
- // src/lib/runtime/remote-lg-cloud-action.ts
1586
+ // src/lib/runtime/remote-lg-action.ts
1756
1587
  var import_langgraph_sdk = require("@langchain/langgraph-sdk");
1757
1588
  var import_node_crypto = require("crypto");
1758
1589
  var import_partial_json = require("partial-json");
@@ -1793,7 +1624,7 @@ var CopilotRequestType;
1793
1624
  description: "The type of Copilot request"
1794
1625
  });
1795
1626
 
1796
- // src/lib/runtime/remote-lg-cloud-action.ts
1627
+ // src/lib/runtime/remote-lg-action.ts
1797
1628
  async function execute(args) {
1798
1629
  return new ReadableStream({
1799
1630
  async start(controller) {
@@ -1857,7 +1688,7 @@ async function streamEvents(controller, args) {
1857
1688
  if (!assistantId) {
1858
1689
  console.error(`
1859
1690
  No agent found for the agent name specified in CopilotKit provider
1860
- Please check your available agents or provide an agent ID in the LangGraph Cloud endpoint definition.
1691
+ Please check your available agents or provide an agent ID in the LangGraph Platform endpoint definition.
1861
1692
 
1862
1693
 
1863
1694
  These are the available agents: [${assistants.map((a) => `${a.name} (ID: ${a.assistant_id})`).join(", ")}]
@@ -2229,10 +2060,10 @@ function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, m
2229
2060
  var _a;
2230
2061
  logger2.debug({
2231
2062
  actionName: agent.name
2232
- }, "Executing LangGraph Cloud agent");
2063
+ }, "Executing LangGraph Platform agent");
2233
2064
  telemetry_client_default.capture("oss.runtime.remote_action_executed", {
2234
2065
  agentExecution: true,
2235
- type: "langgraph-cloud",
2066
+ type: "langgraph-platform",
2236
2067
  agentsAmount: endpoint.agents.length,
2237
2068
  hashedLgcKey: (0, import_node_crypto2.createHash)("sha256").update(endpoint.langsmithApiKey).digest("hex")
2238
2069
  });
@@ -2268,8 +2099,8 @@ function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, m
2268
2099
  url: endpoint.deploymentUrl,
2269
2100
  status: 500,
2270
2101
  body: error.message
2271
- }, "Failed to execute LangGraph Cloud agent");
2272
- throw new Error("Failed to execute LangGraph Cloud agent");
2102
+ }, "Failed to execute LangGraph Platform agent");
2103
+ throw new Error("Failed to execute LangGraph Platform agent");
2273
2104
  }
2274
2105
  }
2275
2106
  }));
@@ -2451,7 +2282,7 @@ __name(createHeaders, "createHeaders");
2451
2282
  var EndpointType;
2452
2283
  (function(EndpointType2) {
2453
2284
  EndpointType2["CopilotKit"] = "copilotKit";
2454
- EndpointType2["LangGraphCloud"] = "langgraph-cloud";
2285
+ EndpointType2["LangGraphPlatform"] = "langgraph-platform";
2455
2286
  })(EndpointType || (EndpointType = {}));
2456
2287
  function isLangGraphAgentAction(action) {
2457
2288
  if (!action) {
@@ -2509,13 +2340,13 @@ async function setupRemoteActions({ remoteEndpointDefinitions, graphqlContext, m
2509
2340
  remoteEndpointDefinitions
2510
2341
  }, "Fetching from remote endpoints");
2511
2342
  const filtered = remoteEndpointDefinitions.filter((value, index, self) => {
2512
- if (value.type === "langgraph-cloud") {
2343
+ if (value.type === "langgraph-platform") {
2513
2344
  return value;
2514
2345
  }
2515
2346
  return index === self.findIndex((t) => t.url === value.url);
2516
2347
  });
2517
2348
  const result = await Promise.all(filtered.map(async (endpoint) => {
2518
- if (endpoint.type === "langgraph-cloud") {
2349
+ if (endpoint.type === "langgraph-platform") {
2519
2350
  return constructLGCRemoteAction({
2520
2351
  endpoint,
2521
2352
  messages,
@@ -2576,7 +2407,7 @@ function getRuntimeInstanceTelemetryInfo(runtime) {
2576
2407
  ]
2577
2408
  };
2578
2409
  }
2579
- if (endpointType === EndpointType.LangGraphCloud) {
2410
+ if (endpointType === EndpointType.LangGraphPlatform) {
2580
2411
  const ep = endpoint;
2581
2412
  info = {
2582
2413
  ...info,
@@ -2617,71 +2448,52 @@ var RuntimeEventSubject = class extends import_rxjs2.ReplaySubject {
2617
2448
  constructor() {
2618
2449
  super();
2619
2450
  }
2620
- sendTextMessageStart({ messageId }) {
2451
+ sendTextMessageStart(messageId) {
2621
2452
  this.next({
2622
2453
  type: "TextMessageStart",
2623
2454
  messageId
2624
2455
  });
2625
2456
  }
2626
- sendTextMessageContent({ messageId, content }) {
2457
+ sendTextMessageContent(content) {
2627
2458
  this.next({
2628
2459
  type: "TextMessageContent",
2629
- content,
2630
- messageId
2460
+ content
2631
2461
  });
2632
2462
  }
2633
- sendTextMessageEnd({ messageId }) {
2463
+ sendTextMessageEnd() {
2634
2464
  this.next({
2635
- type: "TextMessageEnd",
2636
- messageId
2465
+ type: "TextMessageEnd"
2637
2466
  });
2638
2467
  }
2639
2468
  sendTextMessage(messageId, content) {
2640
- this.sendTextMessageStart({
2641
- messageId
2642
- });
2643
- this.sendTextMessageContent({
2644
- messageId,
2645
- content
2646
- });
2647
- this.sendTextMessageEnd({
2648
- messageId
2649
- });
2469
+ this.sendTextMessageStart(messageId);
2470
+ this.sendTextMessageContent(content);
2471
+ this.sendTextMessageEnd();
2650
2472
  }
2651
- sendActionExecutionStart({ actionExecutionId, actionName }) {
2473
+ sendActionExecutionStart(actionExecutionId, actionName) {
2652
2474
  this.next({
2653
2475
  type: "ActionExecutionStart",
2654
2476
  actionExecutionId,
2655
2477
  actionName
2656
2478
  });
2657
2479
  }
2658
- sendActionExecutionArgs({ actionExecutionId, args }) {
2480
+ sendActionExecutionArgs(args) {
2659
2481
  this.next({
2660
2482
  type: "ActionExecutionArgs",
2661
- args,
2662
- actionExecutionId
2483
+ args
2663
2484
  });
2664
2485
  }
2665
- sendActionExecutionEnd({ actionExecutionId }) {
2486
+ sendActionExecutionEnd() {
2666
2487
  this.next({
2667
- type: "ActionExecutionEnd",
2668
- actionExecutionId
2488
+ type: "ActionExecutionEnd"
2669
2489
  });
2670
2490
  }
2671
- sendActionExecution({ actionExecutionId, actionName, args }) {
2672
- this.sendActionExecutionStart({
2673
- actionExecutionId,
2674
- actionName
2675
- });
2676
- this.sendActionExecutionArgs({
2677
- actionExecutionId,
2678
- args
2679
- });
2680
- this.sendActionExecutionEnd({
2681
- actionExecutionId
2682
- });
2491
+ sendActionExecution(actionExecutionId, toolName, args) {
2492
+ this.sendActionExecutionStart(actionExecutionId, toolName);
2493
+ this.sendActionExecutionArgs(args);
2494
+ this.sendActionExecutionEnd();
2683
2495
  }
2684
- sendActionExecutionResult({ actionExecutionId, actionName, result }) {
2496
+ sendActionExecutionResult(actionExecutionId, actionName, result) {
2685
2497
  this.next({
2686
2498
  type: "ActionExecutionResult",
2687
2499
  actionName,
@@ -2689,7 +2501,7 @@ var RuntimeEventSubject = class extends import_rxjs2.ReplaySubject {
2689
2501
  result
2690
2502
  });
2691
2503
  }
2692
- sendAgentStateMessage({ threadId, agentName, nodeName, runId, active, role, state, running }) {
2504
+ sendAgentStateMessage(threadId, agentName, nodeName, runId, active, role, state, running) {
2693
2505
  this.next({
2694
2506
  type: "AgentStateMessage",
2695
2507
  threadId,
@@ -2795,11 +2607,7 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
2795
2607
  }
2796
2608
  }
2797
2609
  if (isLangGraphAgentAction(action)) {
2798
- eventStream$.sendActionExecutionResult({
2799
- actionExecutionId,
2800
- actionName: action.name,
2801
- result: `${action.name} agent started`
2802
- });
2610
+ eventStream$.sendActionExecutionResult(actionExecutionId, action.name, `${action.name} agent started`);
2803
2611
  const stream = await action.langGraphAgentHandler({
2804
2612
  name: action.name,
2805
2613
  actionInputsWithoutAgents
@@ -3160,17 +2968,17 @@ function copilotKitEndpoint(config2) {
3160
2968
  };
3161
2969
  }
3162
2970
  __name(copilotKitEndpoint, "copilotKitEndpoint");
3163
- function langGraphCloudEndpoint(config2) {
2971
+ function langGraphPlatformEndpoint(config2) {
3164
2972
  return {
3165
2973
  ...config2,
3166
- type: EndpointType.LangGraphCloud
2974
+ type: EndpointType.LangGraphPlatform
3167
2975
  };
3168
2976
  }
3169
- __name(langGraphCloudEndpoint, "langGraphCloudEndpoint");
2977
+ __name(langGraphPlatformEndpoint, "langGraphPlatformEndpoint");
3170
2978
  function resolveEndpointType(endpoint) {
3171
2979
  if (!endpoint.type) {
3172
2980
  if ("langsmithApiKey" in endpoint && "deploymentUrl" in endpoint && "agents" in endpoint) {
3173
- return EndpointType.LangGraphCloud;
2981
+ return EndpointType.LangGraphPlatform;
3174
2982
  } else {
3175
2983
  return EndpointType.CopilotKit;
3176
2984
  }
@@ -4401,9 +4209,7 @@ var CopilotResolver = class {
4401
4209
  // skip until this message start event
4402
4210
  (0, import_rxjs4.skipWhile)((e) => e !== event),
4403
4211
  // take until the message end event
4404
- (0, import_rxjs4.takeWhile)((e) => !(e.type === RuntimeEventTypes.TextMessageEnd && e.messageId == event.messageId)),
4405
- // filter out any other message events or message ids
4406
- (0, import_rxjs4.filter)((e) => e.type == RuntimeEventTypes.TextMessageContent && e.messageId == event.messageId)
4212
+ (0, import_rxjs4.takeWhile)((e) => e.type != RuntimeEventTypes.TextMessageEnd)
4407
4213
  );
4408
4214
  const streamingTextStatus = new import_rxjs4.Subject();
4409
4215
  const messageId = event.messageId;
@@ -4467,13 +4273,7 @@ var CopilotResolver = class {
4467
4273
  break;
4468
4274
  case RuntimeEventTypes.ActionExecutionStart:
4469
4275
  logger2.debug("Action execution start event received");
4470
- const actionExecutionArgumentStream = eventStream.pipe(
4471
- (0, import_rxjs4.skipWhile)((e) => e !== event),
4472
- // take until the action execution end event
4473
- (0, import_rxjs4.takeWhile)((e) => !(e.type === RuntimeEventTypes.ActionExecutionEnd && e.actionExecutionId == event.actionExecutionId)),
4474
- // filter out any other action execution events or action execution ids
4475
- (0, import_rxjs4.filter)((e) => e.type == RuntimeEventTypes.ActionExecutionArgs && e.actionExecutionId == event.actionExecutionId)
4476
- );
4276
+ const actionExecutionArgumentStream = eventStream.pipe((0, import_rxjs4.skipWhile)((e) => e !== event), (0, import_rxjs4.takeWhile)((e) => e.type != RuntimeEventTypes.ActionExecutionEnd));
4477
4277
  const streamingArgumentsStatus = new import_rxjs4.Subject();
4478
4278
  pushMessage({
4479
4279
  id: event.actionExecutionId,
@@ -4869,7 +4669,7 @@ __name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
4869
4669
  createContext,
4870
4670
  flattenToolCallsNoDuplicates,
4871
4671
  getCommonConfig,
4872
- langGraphCloudEndpoint,
4672
+ langGraphPlatformEndpoint,
4873
4673
  resolveEndpointType
4874
4674
  });
4875
4675
  //# sourceMappingURL=index.js.map