@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.
- package/CHANGELOG.md +13 -0
- package/dist/{chunk-AQBZWBJD.mjs → chunk-6H45CJUK.mjs} +2 -2
- package/dist/{chunk-CBZV4PPM.mjs → chunk-N4ROMSZN.mjs} +2 -2
- package/dist/{chunk-P4EZLCB6.mjs → chunk-NFMXFL2C.mjs} +2 -2
- package/dist/{chunk-56IQ6PGC.mjs → chunk-WHJ3DAYL.mjs} +56 -213
- package/dist/chunk-WHJ3DAYL.mjs.map +1 -0
- package/dist/{chunk-NKGWZWKJ.mjs → chunk-X4FFTYTH.mjs} +33 -76
- package/dist/chunk-X4FFTYTH.mjs.map +1 -0
- package/dist/{copilot-runtime-d9ef5d8c.d.ts → copilot-runtime-335a610d.d.ts} +1 -1
- package/dist/{groq-adapter-192d2413.d.ts → groq-adapter-2f8fd767.d.ts} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +85 -285
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/{langserve-878c62b9.d.ts → langserve-cc06e76e.d.ts} +9 -45
- package/dist/lib/index.d.ts +3 -3
- package/dist/lib/index.js +79 -264
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +5 -5
- package/dist/lib/integrations/index.d.ts +3 -3
- package/dist/lib/integrations/index.js +3 -11
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +5 -5
- package/dist/lib/integrations/nest/index.d.ts +2 -2
- package/dist/lib/integrations/nest/index.js +3 -11
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +3 -3
- package/dist/lib/integrations/node-express/index.d.ts +2 -2
- package/dist/lib/integrations/node-express/index.js +3 -11
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +3 -3
- package/dist/lib/integrations/node-http/index.d.ts +2 -2
- package/dist/lib/integrations/node-http/index.js +3 -11
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +2 -2
- package/dist/service-adapters/index.d.ts +3 -3
- package/dist/service-adapters/index.js +55 -212
- package/dist/service-adapters/index.js.map +1 -1
- package/dist/service-adapters/index.mjs +1 -1
- package/package.json +4 -4
- package/src/agents/langgraph/event-source.ts +0 -12
- package/src/graphql/resolvers/copilot.resolver.ts +2 -28
- package/src/service-adapters/anthropic/anthropic-adapter.ts +6 -15
- package/src/service-adapters/events.ts +35 -73
- package/src/service-adapters/experimental/ollama/ollama-adapter.ts +3 -7
- package/src/service-adapters/groq/groq-adapter.ts +8 -22
- package/src/service-adapters/langchain/utils.ts +31 -47
- package/src/service-adapters/openai/openai-adapter.ts +9 -21
- package/src/service-adapters/openai/openai-assistant-adapter.ts +8 -21
- package/src/service-adapters/unify/unify-adapter.ts +11 -28
- package/dist/chunk-56IQ6PGC.mjs.map +0 -1
- package/dist/chunk-NKGWZWKJ.mjs.map +0 -1
- /package/dist/{chunk-AQBZWBJD.mjs.map → chunk-6H45CJUK.mjs.map} +0 -0
- /package/dist/{chunk-CBZV4PPM.mjs.map → chunk-N4ROMSZN.mjs.map} +0 -0
- /package/dist/{chunk-P4EZLCB6.mjs.map → chunk-NFMXFL2C.mjs.map} +0 -0
package/dist/lib/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.
|
|
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",
|
|
@@ -424,8 +424,6 @@ var OpenAIAdapter = class {
|
|
|
424
424
|
eventSource.stream(async (eventStream$) => {
|
|
425
425
|
var _a, _b;
|
|
426
426
|
let mode = null;
|
|
427
|
-
let currentMessageId;
|
|
428
|
-
let currentToolCallId;
|
|
429
427
|
for await (const chunk of stream) {
|
|
430
428
|
if (chunk.choices.length === 0) {
|
|
431
429
|
continue;
|
|
@@ -434,51 +432,30 @@ var OpenAIAdapter = class {
|
|
|
434
432
|
const content = chunk.choices[0].delta.content;
|
|
435
433
|
if (mode === "message" && (toolCall == null ? void 0 : toolCall.id)) {
|
|
436
434
|
mode = null;
|
|
437
|
-
eventStream$.sendTextMessageEnd(
|
|
438
|
-
messageId: currentMessageId
|
|
439
|
-
});
|
|
435
|
+
eventStream$.sendTextMessageEnd();
|
|
440
436
|
} else if (mode === "function" && (toolCall === void 0 || (toolCall == null ? void 0 : toolCall.id))) {
|
|
441
437
|
mode = null;
|
|
442
|
-
eventStream$.sendActionExecutionEnd(
|
|
443
|
-
actionExecutionId: currentToolCallId
|
|
444
|
-
});
|
|
438
|
+
eventStream$.sendActionExecutionEnd();
|
|
445
439
|
}
|
|
446
440
|
if (mode === null) {
|
|
447
441
|
if (toolCall == null ? void 0 : toolCall.id) {
|
|
448
442
|
mode = "function";
|
|
449
|
-
|
|
450
|
-
eventStream$.sendActionExecutionStart({
|
|
451
|
-
actionExecutionId: currentToolCallId,
|
|
452
|
-
actionName: toolCall.function.name
|
|
453
|
-
});
|
|
443
|
+
eventStream$.sendActionExecutionStart(toolCall.id, toolCall.function.name);
|
|
454
444
|
} else if (content) {
|
|
455
445
|
mode = "message";
|
|
456
|
-
|
|
457
|
-
eventStream$.sendTextMessageStart({
|
|
458
|
-
messageId: currentMessageId
|
|
459
|
-
});
|
|
446
|
+
eventStream$.sendTextMessageStart(chunk.id);
|
|
460
447
|
}
|
|
461
448
|
}
|
|
462
449
|
if (mode === "message" && content) {
|
|
463
|
-
eventStream$.sendTextMessageContent(
|
|
464
|
-
messageId: currentMessageId,
|
|
465
|
-
content
|
|
466
|
-
});
|
|
450
|
+
eventStream$.sendTextMessageContent(content);
|
|
467
451
|
} else if (mode === "function" && ((_b = toolCall == null ? void 0 : toolCall.function) == null ? void 0 : _b.arguments)) {
|
|
468
|
-
eventStream$.sendActionExecutionArgs(
|
|
469
|
-
actionExecutionId: currentToolCallId,
|
|
470
|
-
args: toolCall.function.arguments
|
|
471
|
-
});
|
|
452
|
+
eventStream$.sendActionExecutionArgs(toolCall.function.arguments);
|
|
472
453
|
}
|
|
473
454
|
}
|
|
474
455
|
if (mode === "message") {
|
|
475
|
-
eventStream$.sendTextMessageEnd(
|
|
476
|
-
messageId: currentMessageId
|
|
477
|
-
});
|
|
456
|
+
eventStream$.sendTextMessageEnd();
|
|
478
457
|
} else if (mode === "function") {
|
|
479
|
-
eventStream$.sendActionExecutionEnd(
|
|
480
|
-
actionExecutionId: currentToolCallId
|
|
481
|
-
});
|
|
458
|
+
eventStream$.sendActionExecutionEnd();
|
|
482
459
|
}
|
|
483
460
|
eventStream$.complete();
|
|
484
461
|
});
|
|
@@ -574,11 +551,7 @@ function isBaseMessageChunk(message) {
|
|
|
574
551
|
__name(isBaseMessageChunk, "isBaseMessageChunk");
|
|
575
552
|
function maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution) {
|
|
576
553
|
if (actionExecution) {
|
|
577
|
-
eventStream$.sendActionExecutionResult(
|
|
578
|
-
actionExecutionId: actionExecution.id,
|
|
579
|
-
actionName: actionExecution.name,
|
|
580
|
-
result: "Sending a message"
|
|
581
|
-
});
|
|
554
|
+
eventStream$.sendActionExecutionResult(actionExecution.id, actionExecution.name, "Sending a message");
|
|
582
555
|
}
|
|
583
556
|
}
|
|
584
557
|
__name(maybeSendActionExecutionResultIsMessage, "maybeSendActionExecutionResultIsMessage");
|
|
@@ -588,11 +561,7 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
588
561
|
if (!actionExecution) {
|
|
589
562
|
eventStream$.sendTextMessage((0, import_shared2.randomId)(), result);
|
|
590
563
|
} else {
|
|
591
|
-
eventStream$.sendActionExecutionResult(
|
|
592
|
-
actionExecutionId: actionExecution.id,
|
|
593
|
-
actionName: actionExecution.name,
|
|
594
|
-
result
|
|
595
|
-
});
|
|
564
|
+
eventStream$.sendActionExecutionResult(actionExecution.id, actionExecution.name, result);
|
|
596
565
|
}
|
|
597
566
|
} else if (isAIMessage(result)) {
|
|
598
567
|
maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution);
|
|
@@ -600,11 +569,7 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
600
569
|
eventStream$.sendTextMessage((0, import_shared2.randomId)(), result.content);
|
|
601
570
|
}
|
|
602
571
|
for (const toolCall of result.tool_calls) {
|
|
603
|
-
eventStream$.sendActionExecution(
|
|
604
|
-
actionExecutionId: toolCall.id || (0, import_shared2.randomId)(),
|
|
605
|
-
actionName: toolCall.name,
|
|
606
|
-
args: JSON.stringify(toolCall.args)
|
|
607
|
-
});
|
|
572
|
+
eventStream$.sendActionExecution(toolCall.id || (0, import_shared2.randomId)(), toolCall.name, JSON.stringify(toolCall.args));
|
|
608
573
|
}
|
|
609
574
|
} else if (isBaseMessageChunk(result)) {
|
|
610
575
|
maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution);
|
|
@@ -613,11 +578,7 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
613
578
|
}
|
|
614
579
|
if ((_b = result.lc_kwargs) == null ? void 0 : _b.tool_calls) {
|
|
615
580
|
for (const toolCall of (_c = result.lc_kwargs) == null ? void 0 : _c.tool_calls) {
|
|
616
|
-
eventStream$.sendActionExecution(
|
|
617
|
-
actionExecutionId: toolCall.id || (0, import_shared2.randomId)(),
|
|
618
|
-
actionName: toolCall.name,
|
|
619
|
-
args: JSON.stringify(toolCall.args)
|
|
620
|
-
});
|
|
581
|
+
eventStream$.sendActionExecution(toolCall.id || (0, import_shared2.randomId)(), toolCall.name, JSON.stringify(toolCall.args));
|
|
621
582
|
}
|
|
622
583
|
}
|
|
623
584
|
} else if (result && "getReader" in result) {
|
|
@@ -635,7 +596,6 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
635
596
|
const { done, value } = await reader.read();
|
|
636
597
|
let toolCallName = void 0;
|
|
637
598
|
let toolCallId = void 0;
|
|
638
|
-
let currentMessageId;
|
|
639
599
|
let toolCallArgs = void 0;
|
|
640
600
|
let hasToolCall = false;
|
|
641
601
|
let content = value == null ? void 0 : value.content;
|
|
@@ -663,14 +623,10 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
663
623
|
}
|
|
664
624
|
if (mode === "message" && (toolCallId || done)) {
|
|
665
625
|
mode = null;
|
|
666
|
-
eventStream$.sendTextMessageEnd(
|
|
667
|
-
messageId: currentMessageId
|
|
668
|
-
});
|
|
626
|
+
eventStream$.sendTextMessageEnd();
|
|
669
627
|
} else if (mode === "function" && (!hasToolCall || done)) {
|
|
670
628
|
mode = null;
|
|
671
|
-
eventStream$.sendActionExecutionEnd(
|
|
672
|
-
actionExecutionId: toolCallId
|
|
673
|
-
});
|
|
629
|
+
eventStream$.sendActionExecutionEnd();
|
|
674
630
|
}
|
|
675
631
|
if (done) {
|
|
676
632
|
break;
|
|
@@ -678,38 +634,21 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
678
634
|
if (mode === null) {
|
|
679
635
|
if (hasToolCall && toolCallId && toolCallName) {
|
|
680
636
|
mode = "function";
|
|
681
|
-
eventStream$.sendActionExecutionStart(
|
|
682
|
-
actionExecutionId: toolCallId,
|
|
683
|
-
actionName: toolCallName
|
|
684
|
-
});
|
|
637
|
+
eventStream$.sendActionExecutionStart(toolCallId, toolCallName);
|
|
685
638
|
} else if (content) {
|
|
686
639
|
mode = "message";
|
|
687
|
-
|
|
688
|
-
eventStream$.sendTextMessageStart({
|
|
689
|
-
messageId: currentMessageId
|
|
690
|
-
});
|
|
640
|
+
eventStream$.sendTextMessageStart((0, import_shared2.randomId)());
|
|
691
641
|
}
|
|
692
642
|
}
|
|
693
643
|
if (mode === "message" && content) {
|
|
694
|
-
eventStream$.sendTextMessageContent(
|
|
695
|
-
messageId: currentMessageId,
|
|
696
|
-
content: Array.isArray(content) ? ((_i = content[0]) == null ? void 0 : _i.text) ?? "" : content
|
|
697
|
-
});
|
|
644
|
+
eventStream$.sendTextMessageContent(Array.isArray(content) ? ((_i = content[0]) == null ? void 0 : _i.text) ?? "" : content);
|
|
698
645
|
} else if (mode === "function" && toolCallArgs) {
|
|
699
646
|
if (toolCallDetails.index !== toolCallDetails.prevIndex) {
|
|
700
|
-
eventStream$.sendActionExecutionEnd(
|
|
701
|
-
|
|
702
|
-
});
|
|
703
|
-
eventStream$.sendActionExecutionStart({
|
|
704
|
-
actionExecutionId: toolCallId,
|
|
705
|
-
actionName: toolCallName
|
|
706
|
-
});
|
|
647
|
+
eventStream$.sendActionExecutionEnd();
|
|
648
|
+
eventStream$.sendActionExecutionStart(toolCallId, toolCallName);
|
|
707
649
|
toolCallDetails.prevIndex = toolCallDetails.index;
|
|
708
650
|
}
|
|
709
|
-
eventStream$.sendActionExecutionArgs(
|
|
710
|
-
actionExecutionId: toolCallId,
|
|
711
|
-
args: toolCallArgs
|
|
712
|
-
});
|
|
651
|
+
eventStream$.sendActionExecutionArgs(toolCallArgs);
|
|
713
652
|
}
|
|
714
653
|
} catch (error) {
|
|
715
654
|
console.error("Error reading from stream", error);
|
|
@@ -717,11 +656,7 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
717
656
|
}
|
|
718
657
|
}
|
|
719
658
|
} else if (actionExecution) {
|
|
720
|
-
eventStream$.sendActionExecutionResult(
|
|
721
|
-
actionExecutionId: actionExecution.id,
|
|
722
|
-
actionName: actionExecution.name,
|
|
723
|
-
result: encodeResult(result)
|
|
724
|
-
});
|
|
659
|
+
eventStream$.sendActionExecutionResult(actionExecution.id, actionExecution.name, encodeResult(result));
|
|
725
660
|
} else {
|
|
726
661
|
throw new Error("Invalid return type from LangChain function.");
|
|
727
662
|
}
|
|
@@ -901,33 +836,21 @@ var OpenAIAssistantAdapter = class {
|
|
|
901
836
|
eventSource.stream(async (eventStream$) => {
|
|
902
837
|
var _a, _b, _c, _d, _e, _f;
|
|
903
838
|
let inFunctionCall = false;
|
|
904
|
-
let currentMessageId;
|
|
905
|
-
let currentToolCallId;
|
|
906
839
|
for await (const chunk of stream) {
|
|
907
840
|
switch (chunk.event) {
|
|
908
841
|
case "thread.message.created":
|
|
909
842
|
if (inFunctionCall) {
|
|
910
|
-
eventStream$.sendActionExecutionEnd(
|
|
911
|
-
actionExecutionId: currentToolCallId
|
|
912
|
-
});
|
|
843
|
+
eventStream$.sendActionExecutionEnd();
|
|
913
844
|
}
|
|
914
|
-
|
|
915
|
-
eventStream$.sendTextMessageStart({
|
|
916
|
-
messageId: currentMessageId
|
|
917
|
-
});
|
|
845
|
+
eventStream$.sendTextMessageStart(chunk.data.id);
|
|
918
846
|
break;
|
|
919
847
|
case "thread.message.delta":
|
|
920
848
|
if (((_a = chunk.data.delta.content) == null ? void 0 : _a[0].type) === "text") {
|
|
921
|
-
eventStream$.sendTextMessageContent(
|
|
922
|
-
messageId: currentMessageId,
|
|
923
|
-
content: (_b = chunk.data.delta.content) == null ? void 0 : _b[0].text.value
|
|
924
|
-
});
|
|
849
|
+
eventStream$.sendTextMessageContent((_b = chunk.data.delta.content) == null ? void 0 : _b[0].text.value);
|
|
925
850
|
}
|
|
926
851
|
break;
|
|
927
852
|
case "thread.message.completed":
|
|
928
|
-
eventStream$.sendTextMessageEnd(
|
|
929
|
-
messageId: currentMessageId
|
|
930
|
-
});
|
|
853
|
+
eventStream$.sendTextMessageEnd();
|
|
931
854
|
break;
|
|
932
855
|
case "thread.run.step.delta":
|
|
933
856
|
let toolCallId;
|
|
@@ -940,29 +863,18 @@ var OpenAIAssistantAdapter = class {
|
|
|
940
863
|
}
|
|
941
864
|
if (toolCallName && toolCallId) {
|
|
942
865
|
if (inFunctionCall) {
|
|
943
|
-
eventStream$.sendActionExecutionEnd(
|
|
944
|
-
actionExecutionId: currentToolCallId
|
|
945
|
-
});
|
|
866
|
+
eventStream$.sendActionExecutionEnd();
|
|
946
867
|
}
|
|
947
868
|
inFunctionCall = true;
|
|
948
|
-
|
|
949
|
-
eventStream$.sendActionExecutionStart({
|
|
950
|
-
actionExecutionId: currentToolCallId,
|
|
951
|
-
actionName: toolCallName
|
|
952
|
-
});
|
|
869
|
+
eventStream$.sendActionExecutionStart(toolCallId, toolCallName);
|
|
953
870
|
} else if (toolCallArgs) {
|
|
954
|
-
eventStream$.sendActionExecutionArgs(
|
|
955
|
-
actionExecutionId: currentToolCallId,
|
|
956
|
-
args: toolCallArgs
|
|
957
|
-
});
|
|
871
|
+
eventStream$.sendActionExecutionArgs(toolCallArgs);
|
|
958
872
|
}
|
|
959
873
|
break;
|
|
960
874
|
}
|
|
961
875
|
}
|
|
962
876
|
if (inFunctionCall) {
|
|
963
|
-
eventStream$.sendActionExecutionEnd(
|
|
964
|
-
actionExecutionId: currentToolCallId
|
|
965
|
-
});
|
|
877
|
+
eventStream$.sendActionExecutionEnd();
|
|
966
878
|
}
|
|
967
879
|
eventStream$.complete();
|
|
968
880
|
});
|
|
@@ -1015,77 +927,46 @@ var UnifyAdapter = class {
|
|
|
1015
927
|
}
|
|
1016
928
|
});
|
|
1017
929
|
let model = null;
|
|
1018
|
-
let currentMessageId;
|
|
1019
|
-
let currentToolCallId;
|
|
1020
930
|
request.eventSource.stream(async (eventStream$) => {
|
|
1021
931
|
var _a, _b;
|
|
1022
932
|
let mode = null;
|
|
1023
933
|
for await (const chunk of stream) {
|
|
1024
934
|
if (this.start) {
|
|
1025
935
|
model = chunk.model;
|
|
1026
|
-
|
|
1027
|
-
eventStream$.
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
eventStream$.sendTextMessageContent({
|
|
1031
|
-
messageId: currentMessageId,
|
|
1032
|
-
content: `Model used: ${model}
|
|
1033
|
-
`
|
|
1034
|
-
});
|
|
1035
|
-
eventStream$.sendTextMessageEnd({
|
|
1036
|
-
messageId: currentMessageId
|
|
1037
|
-
});
|
|
936
|
+
eventStream$.sendTextMessageStart((0, import_shared4.randomId)());
|
|
937
|
+
eventStream$.sendTextMessageContent(`Model used: ${model}
|
|
938
|
+
`);
|
|
939
|
+
eventStream$.sendTextMessageEnd();
|
|
1038
940
|
this.start = false;
|
|
1039
941
|
}
|
|
1040
942
|
const toolCall = (_a = chunk.choices[0].delta.tool_calls) == null ? void 0 : _a[0];
|
|
1041
943
|
const content = chunk.choices[0].delta.content;
|
|
1042
944
|
if (mode === "message" && (toolCall == null ? void 0 : toolCall.id)) {
|
|
1043
945
|
mode = null;
|
|
1044
|
-
eventStream$.sendTextMessageEnd(
|
|
1045
|
-
messageId: currentMessageId
|
|
1046
|
-
});
|
|
946
|
+
eventStream$.sendTextMessageEnd();
|
|
1047
947
|
} else if (mode === "function" && (toolCall === void 0 || (toolCall == null ? void 0 : toolCall.id))) {
|
|
1048
948
|
mode = null;
|
|
1049
|
-
eventStream$.sendActionExecutionEnd(
|
|
1050
|
-
actionExecutionId: currentToolCallId
|
|
1051
|
-
});
|
|
949
|
+
eventStream$.sendActionExecutionEnd();
|
|
1052
950
|
}
|
|
1053
951
|
if (mode === null) {
|
|
1054
952
|
if (toolCall == null ? void 0 : toolCall.id) {
|
|
1055
953
|
mode = "function";
|
|
1056
|
-
|
|
1057
|
-
eventStream$.sendActionExecutionStart({
|
|
1058
|
-
actionExecutionId: currentToolCallId,
|
|
1059
|
-
actionName: toolCall.function.name
|
|
1060
|
-
});
|
|
954
|
+
eventStream$.sendActionExecutionStart(toolCall.id, toolCall.function.name);
|
|
1061
955
|
} else if (content) {
|
|
1062
956
|
mode = "message";
|
|
1063
|
-
|
|
1064
|
-
eventStream$.sendTextMessageStart({
|
|
1065
|
-
messageId: currentMessageId
|
|
1066
|
-
});
|
|
957
|
+
eventStream$.sendTextMessageStart(chunk.id);
|
|
1067
958
|
}
|
|
1068
959
|
}
|
|
1069
960
|
if (mode === "message" && content) {
|
|
1070
|
-
eventStream$.sendTextMessageContent(
|
|
1071
|
-
messageId: currentMessageId,
|
|
1072
|
-
content
|
|
1073
|
-
});
|
|
961
|
+
eventStream$.sendTextMessageContent(content);
|
|
1074
962
|
} else if (mode === "function" && ((_b = toolCall == null ? void 0 : toolCall.function) == null ? void 0 : _b.arguments)) {
|
|
1075
|
-
eventStream$.sendActionExecutionArgs(
|
|
1076
|
-
actionExecutionId: currentToolCallId,
|
|
1077
|
-
args: toolCall.function.arguments
|
|
1078
|
-
});
|
|
963
|
+
eventStream$.sendActionExecutionArgs(toolCall.function.arguments);
|
|
1079
964
|
}
|
|
1080
965
|
}
|
|
1081
966
|
if (mode === "message") {
|
|
1082
|
-
eventStream$.sendTextMessageEnd(
|
|
1083
|
-
messageId: currentMessageId
|
|
1084
|
-
});
|
|
967
|
+
eventStream$.sendTextMessageEnd();
|
|
1085
968
|
} else if (mode === "function") {
|
|
1086
|
-
eventStream$.sendActionExecutionEnd(
|
|
1087
|
-
actionExecutionId: currentToolCallId
|
|
1088
|
-
});
|
|
969
|
+
eventStream$.sendActionExecutionEnd();
|
|
1089
970
|
}
|
|
1090
971
|
eventStream$.complete();
|
|
1091
972
|
});
|
|
@@ -1151,58 +1032,35 @@ var GroqAdapter = class {
|
|
|
1151
1032
|
eventSource.stream(async (eventStream$) => {
|
|
1152
1033
|
var _a, _b;
|
|
1153
1034
|
let mode = null;
|
|
1154
|
-
let currentMessageId;
|
|
1155
|
-
let currentToolCallId;
|
|
1156
1035
|
for await (const chunk of stream) {
|
|
1157
1036
|
const toolCall = (_a = chunk.choices[0].delta.tool_calls) == null ? void 0 : _a[0];
|
|
1158
1037
|
const content = chunk.choices[0].delta.content;
|
|
1159
1038
|
if (mode === "message" && (toolCall == null ? void 0 : toolCall.id)) {
|
|
1160
1039
|
mode = null;
|
|
1161
|
-
eventStream$.sendTextMessageEnd(
|
|
1162
|
-
messageId: currentMessageId
|
|
1163
|
-
});
|
|
1040
|
+
eventStream$.sendTextMessageEnd();
|
|
1164
1041
|
} else if (mode === "function" && (toolCall === void 0 || (toolCall == null ? void 0 : toolCall.id))) {
|
|
1165
1042
|
mode = null;
|
|
1166
|
-
eventStream$.sendActionExecutionEnd(
|
|
1167
|
-
actionExecutionId: currentToolCallId
|
|
1168
|
-
});
|
|
1043
|
+
eventStream$.sendActionExecutionEnd();
|
|
1169
1044
|
}
|
|
1170
1045
|
if (mode === null) {
|
|
1171
1046
|
if (toolCall == null ? void 0 : toolCall.id) {
|
|
1172
1047
|
mode = "function";
|
|
1173
|
-
|
|
1174
|
-
eventStream$.sendActionExecutionStart({
|
|
1175
|
-
actionExecutionId: currentToolCallId,
|
|
1176
|
-
actionName: toolCall.function.name
|
|
1177
|
-
});
|
|
1048
|
+
eventStream$.sendActionExecutionStart(toolCall.id, toolCall.function.name);
|
|
1178
1049
|
} else if (content) {
|
|
1179
1050
|
mode = "message";
|
|
1180
|
-
|
|
1181
|
-
eventStream$.sendTextMessageStart({
|
|
1182
|
-
messageId: currentMessageId
|
|
1183
|
-
});
|
|
1051
|
+
eventStream$.sendTextMessageStart(chunk.id);
|
|
1184
1052
|
}
|
|
1185
1053
|
}
|
|
1186
1054
|
if (mode === "message" && content) {
|
|
1187
|
-
eventStream$.sendTextMessageContent(
|
|
1188
|
-
messageId: currentMessageId,
|
|
1189
|
-
content
|
|
1190
|
-
});
|
|
1055
|
+
eventStream$.sendTextMessageContent(content);
|
|
1191
1056
|
} else if (mode === "function" && ((_b = toolCall == null ? void 0 : toolCall.function) == null ? void 0 : _b.arguments)) {
|
|
1192
|
-
eventStream$.sendActionExecutionArgs(
|
|
1193
|
-
actionExecutionId: currentToolCallId,
|
|
1194
|
-
args: toolCall.function.arguments
|
|
1195
|
-
});
|
|
1057
|
+
eventStream$.sendActionExecutionArgs(toolCall.function.arguments);
|
|
1196
1058
|
}
|
|
1197
1059
|
}
|
|
1198
1060
|
if (mode === "message") {
|
|
1199
|
-
eventStream$.sendTextMessageEnd(
|
|
1200
|
-
messageId: currentMessageId
|
|
1201
|
-
});
|
|
1061
|
+
eventStream$.sendTextMessageEnd();
|
|
1202
1062
|
} else if (mode === "function") {
|
|
1203
|
-
eventStream$.sendActionExecutionEnd(
|
|
1204
|
-
actionExecutionId: currentToolCallId
|
|
1205
|
-
});
|
|
1063
|
+
eventStream$.sendActionExecutionEnd();
|
|
1206
1064
|
}
|
|
1207
1065
|
eventStream$.complete();
|
|
1208
1066
|
});
|
|
@@ -1333,14 +1191,12 @@ var RemoteLangGraphEventSource = class {
|
|
|
1333
1191
|
}
|
|
1334
1192
|
if (eventWithState.prevToolCallMessageId !== null && eventWithState.prevToolCallMessageId !== eventWithState.toolCallMessageId && this.shouldEmitToolCall(shouldEmitToolCalls, eventWithState.toolCallName)) {
|
|
1335
1193
|
events.push({
|
|
1336
|
-
type: RuntimeEventTypes.ActionExecutionEnd
|
|
1337
|
-
actionExecutionId: eventWithState.prevToolCallMessageId
|
|
1194
|
+
type: RuntimeEventTypes.ActionExecutionEnd
|
|
1338
1195
|
});
|
|
1339
1196
|
}
|
|
1340
1197
|
if (eventWithState.prevMessageId !== null && eventWithState.prevMessageId !== eventWithState.messageId && shouldEmitMessages) {
|
|
1341
1198
|
events.push({
|
|
1342
|
-
type: RuntimeEventTypes.TextMessageEnd
|
|
1343
|
-
messageId: eventWithState.prevMessageId
|
|
1199
|
+
type: RuntimeEventTypes.TextMessageEnd
|
|
1344
1200
|
});
|
|
1345
1201
|
}
|
|
1346
1202
|
switch (eventWithState.event.event) {
|
|
@@ -1352,12 +1208,10 @@ var RemoteLangGraphEventSource = class {
|
|
|
1352
1208
|
});
|
|
1353
1209
|
events.push({
|
|
1354
1210
|
type: RuntimeEventTypes.TextMessageContent,
|
|
1355
|
-
messageId: eventWithState.event.data.message_id,
|
|
1356
1211
|
content: eventWithState.event.data.message
|
|
1357
1212
|
});
|
|
1358
1213
|
events.push({
|
|
1359
|
-
type: RuntimeEventTypes.TextMessageEnd
|
|
1360
|
-
messageId: eventWithState.event.data.message_id
|
|
1214
|
+
type: RuntimeEventTypes.TextMessageEnd
|
|
1361
1215
|
});
|
|
1362
1216
|
} else if (eventWithState.event.name === CustomEventNames.CopilotKitManuallyEmitToolCall) {
|
|
1363
1217
|
events.push({
|
|
@@ -1367,12 +1221,10 @@ var RemoteLangGraphEventSource = class {
|
|
|
1367
1221
|
});
|
|
1368
1222
|
events.push({
|
|
1369
1223
|
type: RuntimeEventTypes.ActionExecutionArgs,
|
|
1370
|
-
actionExecutionId: eventWithState.event.data.id,
|
|
1371
1224
|
args: JSON.stringify(eventWithState.event.data.args)
|
|
1372
1225
|
});
|
|
1373
1226
|
events.push({
|
|
1374
|
-
type: RuntimeEventTypes.ActionExecutionEnd
|
|
1375
|
-
actionExecutionId: eventWithState.event.data.id
|
|
1227
|
+
type: RuntimeEventTypes.ActionExecutionEnd
|
|
1376
1228
|
});
|
|
1377
1229
|
}
|
|
1378
1230
|
break;
|
|
@@ -1416,7 +1268,6 @@ var RemoteLangGraphEventSource = class {
|
|
|
1416
1268
|
if (this.shouldEmitToolCall(shouldEmitToolCalls, eventWithState.toolCallName)) {
|
|
1417
1269
|
events.push({
|
|
1418
1270
|
type: RuntimeEventTypes.ActionExecutionArgs,
|
|
1419
|
-
actionExecutionId: eventWithState.toolCallMessageId,
|
|
1420
1271
|
args
|
|
1421
1272
|
});
|
|
1422
1273
|
}
|
|
@@ -1424,7 +1275,6 @@ var RemoteLangGraphEventSource = class {
|
|
|
1424
1275
|
if (shouldEmitMessages) {
|
|
1425
1276
|
events.push({
|
|
1426
1277
|
type: RuntimeEventTypes.TextMessageContent,
|
|
1427
|
-
messageId: eventWithState.messageId,
|
|
1428
1278
|
content
|
|
1429
1279
|
});
|
|
1430
1280
|
}
|
|
@@ -1437,14 +1287,12 @@ var RemoteLangGraphEventSource = class {
|
|
|
1437
1287
|
const events = [];
|
|
1438
1288
|
if (lastEventWithState == null ? void 0 : lastEventWithState.messageId) {
|
|
1439
1289
|
events.push({
|
|
1440
|
-
type: RuntimeEventTypes.TextMessageEnd
|
|
1441
|
-
messageId: lastEventWithState.messageId
|
|
1290
|
+
type: RuntimeEventTypes.TextMessageEnd
|
|
1442
1291
|
});
|
|
1443
1292
|
}
|
|
1444
1293
|
if (lastEventWithState == null ? void 0 : lastEventWithState.toolCallMessageId) {
|
|
1445
1294
|
events.push({
|
|
1446
|
-
type: RuntimeEventTypes.ActionExecutionEnd
|
|
1447
|
-
actionExecutionId: lastEventWithState.toolCallMessageId
|
|
1295
|
+
type: RuntimeEventTypes.ActionExecutionEnd
|
|
1448
1296
|
});
|
|
1449
1297
|
}
|
|
1450
1298
|
const messageId = (0, import_shared6.randomId)();
|
|
@@ -1454,12 +1302,10 @@ var RemoteLangGraphEventSource = class {
|
|
|
1454
1302
|
});
|
|
1455
1303
|
events.push({
|
|
1456
1304
|
type: RuntimeEventTypes.TextMessageContent,
|
|
1457
|
-
messageId,
|
|
1458
1305
|
content: "\u274C An error occurred. Please try again."
|
|
1459
1306
|
});
|
|
1460
1307
|
events.push({
|
|
1461
|
-
type: RuntimeEventTypes.TextMessageEnd
|
|
1462
|
-
messageId
|
|
1308
|
+
type: RuntimeEventTypes.TextMessageEnd
|
|
1463
1309
|
});
|
|
1464
1310
|
return events;
|
|
1465
1311
|
}));
|
|
@@ -2332,71 +2178,52 @@ var RuntimeEventSubject = class extends import_rxjs2.ReplaySubject {
|
|
|
2332
2178
|
constructor() {
|
|
2333
2179
|
super();
|
|
2334
2180
|
}
|
|
2335
|
-
sendTextMessageStart(
|
|
2181
|
+
sendTextMessageStart(messageId) {
|
|
2336
2182
|
this.next({
|
|
2337
2183
|
type: "TextMessageStart",
|
|
2338
2184
|
messageId
|
|
2339
2185
|
});
|
|
2340
2186
|
}
|
|
2341
|
-
sendTextMessageContent(
|
|
2187
|
+
sendTextMessageContent(content) {
|
|
2342
2188
|
this.next({
|
|
2343
2189
|
type: "TextMessageContent",
|
|
2344
|
-
content
|
|
2345
|
-
messageId
|
|
2190
|
+
content
|
|
2346
2191
|
});
|
|
2347
2192
|
}
|
|
2348
|
-
sendTextMessageEnd(
|
|
2193
|
+
sendTextMessageEnd() {
|
|
2349
2194
|
this.next({
|
|
2350
|
-
type: "TextMessageEnd"
|
|
2351
|
-
messageId
|
|
2195
|
+
type: "TextMessageEnd"
|
|
2352
2196
|
});
|
|
2353
2197
|
}
|
|
2354
2198
|
sendTextMessage(messageId, content) {
|
|
2355
|
-
this.sendTextMessageStart(
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
this.sendTextMessageContent({
|
|
2359
|
-
messageId,
|
|
2360
|
-
content
|
|
2361
|
-
});
|
|
2362
|
-
this.sendTextMessageEnd({
|
|
2363
|
-
messageId
|
|
2364
|
-
});
|
|
2199
|
+
this.sendTextMessageStart(messageId);
|
|
2200
|
+
this.sendTextMessageContent(content);
|
|
2201
|
+
this.sendTextMessageEnd();
|
|
2365
2202
|
}
|
|
2366
|
-
sendActionExecutionStart(
|
|
2203
|
+
sendActionExecutionStart(actionExecutionId, actionName) {
|
|
2367
2204
|
this.next({
|
|
2368
2205
|
type: "ActionExecutionStart",
|
|
2369
2206
|
actionExecutionId,
|
|
2370
2207
|
actionName
|
|
2371
2208
|
});
|
|
2372
2209
|
}
|
|
2373
|
-
sendActionExecutionArgs(
|
|
2210
|
+
sendActionExecutionArgs(args) {
|
|
2374
2211
|
this.next({
|
|
2375
2212
|
type: "ActionExecutionArgs",
|
|
2376
|
-
args
|
|
2377
|
-
actionExecutionId
|
|
2213
|
+
args
|
|
2378
2214
|
});
|
|
2379
2215
|
}
|
|
2380
|
-
sendActionExecutionEnd(
|
|
2216
|
+
sendActionExecutionEnd() {
|
|
2381
2217
|
this.next({
|
|
2382
|
-
type: "ActionExecutionEnd"
|
|
2383
|
-
actionExecutionId
|
|
2218
|
+
type: "ActionExecutionEnd"
|
|
2384
2219
|
});
|
|
2385
2220
|
}
|
|
2386
|
-
sendActionExecution(
|
|
2387
|
-
this.sendActionExecutionStart(
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
});
|
|
2391
|
-
this.sendActionExecutionArgs({
|
|
2392
|
-
actionExecutionId,
|
|
2393
|
-
args
|
|
2394
|
-
});
|
|
2395
|
-
this.sendActionExecutionEnd({
|
|
2396
|
-
actionExecutionId
|
|
2397
|
-
});
|
|
2221
|
+
sendActionExecution(actionExecutionId, toolName, args) {
|
|
2222
|
+
this.sendActionExecutionStart(actionExecutionId, toolName);
|
|
2223
|
+
this.sendActionExecutionArgs(args);
|
|
2224
|
+
this.sendActionExecutionEnd();
|
|
2398
2225
|
}
|
|
2399
|
-
sendActionExecutionResult(
|
|
2226
|
+
sendActionExecutionResult(actionExecutionId, actionName, result) {
|
|
2400
2227
|
this.next({
|
|
2401
2228
|
type: "ActionExecutionResult",
|
|
2402
2229
|
actionName,
|
|
@@ -2404,7 +2231,7 @@ var RuntimeEventSubject = class extends import_rxjs2.ReplaySubject {
|
|
|
2404
2231
|
result
|
|
2405
2232
|
});
|
|
2406
2233
|
}
|
|
2407
|
-
sendAgentStateMessage(
|
|
2234
|
+
sendAgentStateMessage(threadId, agentName, nodeName, runId, active, role, state, running) {
|
|
2408
2235
|
this.next({
|
|
2409
2236
|
type: "AgentStateMessage",
|
|
2410
2237
|
threadId,
|
|
@@ -2510,11 +2337,7 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
|
|
|
2510
2337
|
}
|
|
2511
2338
|
}
|
|
2512
2339
|
if (isLangGraphAgentAction(action)) {
|
|
2513
|
-
eventStream$.sendActionExecutionResult({
|
|
2514
|
-
actionExecutionId,
|
|
2515
|
-
actionName: action.name,
|
|
2516
|
-
result: `${action.name} agent started`
|
|
2517
|
-
});
|
|
2340
|
+
eventStream$.sendActionExecutionResult(actionExecutionId, action.name, `${action.name} agent started`);
|
|
2518
2341
|
const stream = await action.langGraphAgentHandler({
|
|
2519
2342
|
name: action.name,
|
|
2520
2343
|
actionInputsWithoutAgents
|
|
@@ -4116,9 +3939,7 @@ var CopilotResolver = class {
|
|
|
4116
3939
|
// skip until this message start event
|
|
4117
3940
|
(0, import_rxjs4.skipWhile)((e) => e !== event),
|
|
4118
3941
|
// take until the message end event
|
|
4119
|
-
(0, import_rxjs4.takeWhile)((e) =>
|
|
4120
|
-
// filter out any other message events or message ids
|
|
4121
|
-
(0, import_rxjs4.filter)((e) => e.type == RuntimeEventTypes.TextMessageContent && e.messageId == event.messageId)
|
|
3942
|
+
(0, import_rxjs4.takeWhile)((e) => e.type != RuntimeEventTypes.TextMessageEnd)
|
|
4122
3943
|
);
|
|
4123
3944
|
const streamingTextStatus = new import_rxjs4.Subject();
|
|
4124
3945
|
const messageId = event.messageId;
|
|
@@ -4182,13 +4003,7 @@ var CopilotResolver = class {
|
|
|
4182
4003
|
break;
|
|
4183
4004
|
case RuntimeEventTypes.ActionExecutionStart:
|
|
4184
4005
|
logger2.debug("Action execution start event received");
|
|
4185
|
-
const actionExecutionArgumentStream = eventStream.pipe(
|
|
4186
|
-
(0, import_rxjs4.skipWhile)((e) => e !== event),
|
|
4187
|
-
// take until the action execution end event
|
|
4188
|
-
(0, import_rxjs4.takeWhile)((e) => !(e.type === RuntimeEventTypes.ActionExecutionEnd && e.actionExecutionId == event.actionExecutionId)),
|
|
4189
|
-
// filter out any other action execution events or action execution ids
|
|
4190
|
-
(0, import_rxjs4.filter)((e) => e.type == RuntimeEventTypes.ActionExecutionArgs && e.actionExecutionId == event.actionExecutionId)
|
|
4191
|
-
);
|
|
4006
|
+
const actionExecutionArgumentStream = eventStream.pipe((0, import_rxjs4.skipWhile)((e) => e !== event), (0, import_rxjs4.takeWhile)((e) => e.type != RuntimeEventTypes.ActionExecutionEnd));
|
|
4192
4007
|
const streamingArgumentsStatus = new import_rxjs4.Subject();
|
|
4193
4008
|
pushMessage({
|
|
4194
4009
|
id: event.actionExecutionId,
|