@copilotkit/runtime 1.5.1-next.1 → 1.5.1-next.3
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 +17 -0
- package/__snapshots__/schema/schema.graphql +9 -8
- package/dist/{chunk-RFF5IIZJ.mjs → chunk-B74M7FXG.mjs} +2 -3
- package/dist/chunk-B74M7FXG.mjs.map +1 -0
- package/dist/{chunk-L4VT7Z25.mjs → chunk-M4QD67S3.mjs} +2 -2
- package/dist/{chunk-CLGKEUOA.mjs → chunk-OKQVDDJ2.mjs} +63 -298
- package/dist/chunk-OKQVDDJ2.mjs.map +1 -0
- package/dist/{chunk-G2PTXSIW.mjs → chunk-U3AYI5XZ.mjs} +2 -2
- package/dist/{chunk-Z3MD5FQ4.mjs → chunk-U75F2RAQ.mjs} +2 -2
- package/dist/{chunk-6N4ZHRRC.mjs → chunk-ZSWCEADS.mjs} +331 -465
- package/dist/chunk-ZSWCEADS.mjs.map +1 -0
- package/dist/{copilot-runtime-6285d897.d.ts → copilot-runtime-12e7ac40.d.ts} +2 -2
- package/dist/graphql/types/converted/index.d.ts +1 -1
- package/dist/graphql/types/converted/index.js +1 -2
- package/dist/graphql/types/converted/index.js.map +1 -1
- package/dist/graphql/types/converted/index.mjs +1 -1
- package/dist/{groq-adapter-15d41154.d.ts → groq-adapter-24abe931.d.ts} +1 -1
- package/dist/{index-ff3fbc33.d.ts → index-10b1c870.d.ts} +8 -7
- package/dist/index.d.ts +5 -5
- package/dist/index.js +480 -852
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -15
- package/dist/index.mjs.map +1 -1
- package/dist/{langserve-48e976ac.d.ts → langserve-f021ab9c.d.ts} +14 -54
- package/dist/lib/index.d.ts +4 -4
- package/dist/lib/index.js +459 -754
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +7 -7
- package/dist/lib/integrations/index.d.ts +4 -4
- package/dist/lib/integrations/index.js +30 -78
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +6 -6
- package/dist/lib/integrations/nest/index.d.ts +3 -3
- package/dist/lib/integrations/nest/index.js +30 -78
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +4 -4
- package/dist/lib/integrations/node-express/index.d.ts +3 -3
- package/dist/lib/integrations/node-express/index.js +30 -78
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +4 -4
- package/dist/lib/integrations/node-http/index.d.ts +3 -3
- package/dist/lib/integrations/node-http/index.js +30 -78
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +3 -3
- package/dist/service-adapters/index.d.ts +5 -36
- package/dist/service-adapters/index.js +61 -298
- package/dist/service-adapters/index.js.map +1 -1
- package/dist/service-adapters/index.mjs +1 -5
- package/package.json +4 -4
- package/src/graphql/resolvers/copilot.resolver.ts +16 -0
- package/src/graphql/types/agents-response.type.ts +22 -0
- package/src/lib/runtime/copilot-runtime.ts +50 -0
- package/dist/chunk-6N4ZHRRC.mjs.map +0 -1
- package/dist/chunk-CLGKEUOA.mjs.map +0 -1
- package/dist/chunk-RFF5IIZJ.mjs.map +0 -1
- /package/dist/{chunk-L4VT7Z25.mjs.map → chunk-M4QD67S3.mjs.map} +0 -0
- /package/dist/{chunk-G2PTXSIW.mjs.map → chunk-U3AYI5XZ.mjs.map} +0 -0
- /package/dist/{chunk-Z3MD5FQ4.mjs.map → chunk-U75F2RAQ.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.
|
|
47
|
+
version: "1.4.1-pre.6",
|
|
48
48
|
sideEffects: false,
|
|
49
49
|
main: "./dist/index.js",
|
|
50
50
|
module: "./dist/index.mjs",
|
|
@@ -419,16 +419,11 @@ var OpenAIAdapter = class {
|
|
|
419
419
|
},
|
|
420
420
|
...this.disableParallelToolCalls && {
|
|
421
421
|
parallel_tool_calls: false
|
|
422
|
-
},
|
|
423
|
-
...(forwardedParameters == null ? void 0 : forwardedParameters.temperature) && {
|
|
424
|
-
temperature: forwardedParameters.temperature
|
|
425
422
|
}
|
|
426
423
|
});
|
|
427
424
|
eventSource.stream(async (eventStream$) => {
|
|
428
425
|
var _a, _b;
|
|
429
426
|
let mode = null;
|
|
430
|
-
let currentMessageId;
|
|
431
|
-
let currentToolCallId;
|
|
432
427
|
for await (const chunk of stream) {
|
|
433
428
|
if (chunk.choices.length === 0) {
|
|
434
429
|
continue;
|
|
@@ -437,52 +432,30 @@ var OpenAIAdapter = class {
|
|
|
437
432
|
const content = chunk.choices[0].delta.content;
|
|
438
433
|
if (mode === "message" && (toolCall == null ? void 0 : toolCall.id)) {
|
|
439
434
|
mode = null;
|
|
440
|
-
eventStream$.sendTextMessageEnd(
|
|
441
|
-
messageId: currentMessageId
|
|
442
|
-
});
|
|
435
|
+
eventStream$.sendTextMessageEnd();
|
|
443
436
|
} else if (mode === "function" && (toolCall === void 0 || (toolCall == null ? void 0 : toolCall.id))) {
|
|
444
437
|
mode = null;
|
|
445
|
-
eventStream$.sendActionExecutionEnd(
|
|
446
|
-
actionExecutionId: currentToolCallId
|
|
447
|
-
});
|
|
438
|
+
eventStream$.sendActionExecutionEnd();
|
|
448
439
|
}
|
|
449
440
|
if (mode === null) {
|
|
450
441
|
if (toolCall == null ? void 0 : toolCall.id) {
|
|
451
442
|
mode = "function";
|
|
452
|
-
|
|
453
|
-
eventStream$.sendActionExecutionStart({
|
|
454
|
-
actionExecutionId: currentToolCallId,
|
|
455
|
-
parentMessageId: chunk.id,
|
|
456
|
-
actionName: toolCall.function.name
|
|
457
|
-
});
|
|
443
|
+
eventStream$.sendActionExecutionStart(toolCall.id, toolCall.function.name);
|
|
458
444
|
} else if (content) {
|
|
459
445
|
mode = "message";
|
|
460
|
-
|
|
461
|
-
eventStream$.sendTextMessageStart({
|
|
462
|
-
messageId: currentMessageId
|
|
463
|
-
});
|
|
446
|
+
eventStream$.sendTextMessageStart(chunk.id);
|
|
464
447
|
}
|
|
465
448
|
}
|
|
466
449
|
if (mode === "message" && content) {
|
|
467
|
-
eventStream$.sendTextMessageContent(
|
|
468
|
-
messageId: currentMessageId,
|
|
469
|
-
content
|
|
470
|
-
});
|
|
450
|
+
eventStream$.sendTextMessageContent(content);
|
|
471
451
|
} else if (mode === "function" && ((_b = toolCall == null ? void 0 : toolCall.function) == null ? void 0 : _b.arguments)) {
|
|
472
|
-
eventStream$.sendActionExecutionArgs(
|
|
473
|
-
actionExecutionId: currentToolCallId,
|
|
474
|
-
args: toolCall.function.arguments
|
|
475
|
-
});
|
|
452
|
+
eventStream$.sendActionExecutionArgs(toolCall.function.arguments);
|
|
476
453
|
}
|
|
477
454
|
}
|
|
478
455
|
if (mode === "message") {
|
|
479
|
-
eventStream$.sendTextMessageEnd(
|
|
480
|
-
messageId: currentMessageId
|
|
481
|
-
});
|
|
456
|
+
eventStream$.sendTextMessageEnd();
|
|
482
457
|
} else if (mode === "function") {
|
|
483
|
-
eventStream$.sendActionExecutionEnd(
|
|
484
|
-
actionExecutionId: currentToolCallId
|
|
485
|
-
});
|
|
458
|
+
eventStream$.sendActionExecutionEnd();
|
|
486
459
|
}
|
|
487
460
|
eventStream$.complete();
|
|
488
461
|
});
|
|
@@ -550,25 +523,17 @@ function isBaseMessageChunk(message) {
|
|
|
550
523
|
__name(isBaseMessageChunk, "isBaseMessageChunk");
|
|
551
524
|
function maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution) {
|
|
552
525
|
if (actionExecution) {
|
|
553
|
-
eventStream$.sendActionExecutionResult(
|
|
554
|
-
actionExecutionId: actionExecution.id,
|
|
555
|
-
actionName: actionExecution.name,
|
|
556
|
-
result: "Sending a message"
|
|
557
|
-
});
|
|
526
|
+
eventStream$.sendActionExecutionResult(actionExecution.id, actionExecution.name, "Sending a message");
|
|
558
527
|
}
|
|
559
528
|
}
|
|
560
529
|
__name(maybeSendActionExecutionResultIsMessage, "maybeSendActionExecutionResultIsMessage");
|
|
561
530
|
async function streamLangChainResponse({ result, eventStream$, actionExecution }) {
|
|
562
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i
|
|
531
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
563
532
|
if (typeof result === "string") {
|
|
564
533
|
if (!actionExecution) {
|
|
565
534
|
eventStream$.sendTextMessage((0, import_shared2.randomId)(), result);
|
|
566
535
|
} else {
|
|
567
|
-
eventStream$.sendActionExecutionResult(
|
|
568
|
-
actionExecutionId: actionExecution.id,
|
|
569
|
-
actionName: actionExecution.name,
|
|
570
|
-
result
|
|
571
|
-
});
|
|
536
|
+
eventStream$.sendActionExecutionResult(actionExecution.id, actionExecution.name, result);
|
|
572
537
|
}
|
|
573
538
|
} else if (isAIMessage(result)) {
|
|
574
539
|
maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution);
|
|
@@ -576,11 +541,7 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
576
541
|
eventStream$.sendTextMessage((0, import_shared2.randomId)(), result.content);
|
|
577
542
|
}
|
|
578
543
|
for (const toolCall of result.tool_calls) {
|
|
579
|
-
eventStream$.sendActionExecution(
|
|
580
|
-
actionExecutionId: toolCall.id || (0, import_shared2.randomId)(),
|
|
581
|
-
actionName: toolCall.name,
|
|
582
|
-
args: JSON.stringify(toolCall.args)
|
|
583
|
-
});
|
|
544
|
+
eventStream$.sendActionExecution(toolCall.id || (0, import_shared2.randomId)(), toolCall.name, JSON.stringify(toolCall.args));
|
|
584
545
|
}
|
|
585
546
|
} else if (isBaseMessageChunk(result)) {
|
|
586
547
|
maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution);
|
|
@@ -589,18 +550,13 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
589
550
|
}
|
|
590
551
|
if ((_b = result.lc_kwargs) == null ? void 0 : _b.tool_calls) {
|
|
591
552
|
for (const toolCall of (_c = result.lc_kwargs) == null ? void 0 : _c.tool_calls) {
|
|
592
|
-
eventStream$.sendActionExecution(
|
|
593
|
-
actionExecutionId: toolCall.id || (0, import_shared2.randomId)(),
|
|
594
|
-
actionName: toolCall.name,
|
|
595
|
-
args: JSON.stringify(toolCall.args)
|
|
596
|
-
});
|
|
553
|
+
eventStream$.sendActionExecution(toolCall.id || (0, import_shared2.randomId)(), toolCall.name, JSON.stringify(toolCall.args));
|
|
597
554
|
}
|
|
598
555
|
}
|
|
599
556
|
} else if (result && "getReader" in result) {
|
|
600
557
|
maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution);
|
|
601
558
|
let reader = result.getReader();
|
|
602
559
|
let mode = null;
|
|
603
|
-
let currentMessageId;
|
|
604
560
|
const toolCallDetails = {
|
|
605
561
|
name: null,
|
|
606
562
|
id: null,
|
|
@@ -614,12 +570,9 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
614
570
|
let toolCallId = void 0;
|
|
615
571
|
let toolCallArgs = void 0;
|
|
616
572
|
let hasToolCall = false;
|
|
617
|
-
let content =
|
|
618
|
-
if (value && value.content) {
|
|
619
|
-
content = Array.isArray(value.content) ? ((_d = value.content[0]) == null ? void 0 : _d.text) ?? "" : value.content;
|
|
620
|
-
}
|
|
573
|
+
let content = value == null ? void 0 : value.content;
|
|
621
574
|
if (isAIMessageChunk(value)) {
|
|
622
|
-
let chunk = (
|
|
575
|
+
let chunk = (_d = value.tool_call_chunks) == null ? void 0 : _d[0];
|
|
623
576
|
toolCallArgs = chunk == null ? void 0 : chunk.args;
|
|
624
577
|
hasToolCall = chunk != void 0;
|
|
625
578
|
if (chunk == null ? void 0 : chunk.name)
|
|
@@ -634,22 +587,18 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
634
587
|
toolCallName = toolCallDetails.name;
|
|
635
588
|
toolCallId = toolCallDetails.id;
|
|
636
589
|
} else if (isBaseMessageChunk(value)) {
|
|
637
|
-
let chunk = (
|
|
638
|
-
toolCallName = (
|
|
590
|
+
let chunk = (_f = (_e = value.additional_kwargs) == null ? void 0 : _e.tool_calls) == null ? void 0 : _f[0];
|
|
591
|
+
toolCallName = (_g = chunk == null ? void 0 : chunk.function) == null ? void 0 : _g.name;
|
|
639
592
|
toolCallId = chunk == null ? void 0 : chunk.id;
|
|
640
|
-
toolCallArgs = (
|
|
593
|
+
toolCallArgs = (_h = chunk == null ? void 0 : chunk.function) == null ? void 0 : _h.arguments;
|
|
641
594
|
hasToolCall = (chunk == null ? void 0 : chunk.function) != void 0;
|
|
642
595
|
}
|
|
643
596
|
if (mode === "message" && (toolCallId || done)) {
|
|
644
597
|
mode = null;
|
|
645
|
-
eventStream$.sendTextMessageEnd(
|
|
646
|
-
messageId: currentMessageId
|
|
647
|
-
});
|
|
598
|
+
eventStream$.sendTextMessageEnd();
|
|
648
599
|
} else if (mode === "function" && (!hasToolCall || done)) {
|
|
649
600
|
mode = null;
|
|
650
|
-
eventStream$.sendActionExecutionEnd(
|
|
651
|
-
actionExecutionId: toolCallId
|
|
652
|
-
});
|
|
601
|
+
eventStream$.sendActionExecutionEnd();
|
|
653
602
|
}
|
|
654
603
|
if (done) {
|
|
655
604
|
break;
|
|
@@ -657,40 +606,21 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
657
606
|
if (mode === null) {
|
|
658
607
|
if (hasToolCall && toolCallId && toolCallName) {
|
|
659
608
|
mode = "function";
|
|
660
|
-
eventStream$.sendActionExecutionStart(
|
|
661
|
-
actionExecutionId: toolCallId,
|
|
662
|
-
actionName: toolCallName,
|
|
663
|
-
parentMessageId: (_j = value.lc_kwargs) == null ? void 0 : _j.id
|
|
664
|
-
});
|
|
609
|
+
eventStream$.sendActionExecutionStart(toolCallId, toolCallName);
|
|
665
610
|
} else if (content) {
|
|
666
611
|
mode = "message";
|
|
667
|
-
|
|
668
|
-
eventStream$.sendTextMessageStart({
|
|
669
|
-
messageId: currentMessageId
|
|
670
|
-
});
|
|
612
|
+
eventStream$.sendTextMessageStart((0, import_shared2.randomId)());
|
|
671
613
|
}
|
|
672
614
|
}
|
|
673
615
|
if (mode === "message" && content) {
|
|
674
|
-
eventStream$.sendTextMessageContent(
|
|
675
|
-
messageId: currentMessageId,
|
|
676
|
-
content
|
|
677
|
-
});
|
|
616
|
+
eventStream$.sendTextMessageContent(Array.isArray(content) ? ((_i = content[0]) == null ? void 0 : _i.text) ?? "" : content);
|
|
678
617
|
} else if (mode === "function" && toolCallArgs) {
|
|
679
618
|
if (toolCallDetails.index !== toolCallDetails.prevIndex) {
|
|
680
|
-
eventStream$.sendActionExecutionEnd(
|
|
681
|
-
|
|
682
|
-
});
|
|
683
|
-
eventStream$.sendActionExecutionStart({
|
|
684
|
-
actionExecutionId: toolCallId,
|
|
685
|
-
actionName: toolCallName,
|
|
686
|
-
parentMessageId: (_l = value.lc_kwargs) == null ? void 0 : _l.id
|
|
687
|
-
});
|
|
619
|
+
eventStream$.sendActionExecutionEnd();
|
|
620
|
+
eventStream$.sendActionExecutionStart(toolCallId, toolCallName);
|
|
688
621
|
toolCallDetails.prevIndex = toolCallDetails.index;
|
|
689
622
|
}
|
|
690
|
-
eventStream$.sendActionExecutionArgs(
|
|
691
|
-
actionExecutionId: toolCallId,
|
|
692
|
-
args: toolCallArgs
|
|
693
|
-
});
|
|
623
|
+
eventStream$.sendActionExecutionArgs(toolCallArgs);
|
|
694
624
|
}
|
|
695
625
|
} catch (error) {
|
|
696
626
|
console.error("Error reading from stream", error);
|
|
@@ -698,11 +628,7 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
698
628
|
}
|
|
699
629
|
}
|
|
700
630
|
} else if (actionExecution) {
|
|
701
|
-
eventStream$.sendActionExecutionResult(
|
|
702
|
-
actionExecutionId: actionExecution.id,
|
|
703
|
-
actionName: actionExecution.name,
|
|
704
|
-
result: encodeResult(result)
|
|
705
|
-
});
|
|
631
|
+
eventStream$.sendActionExecutionResult(actionExecution.id, actionExecution.name, encodeResult(result));
|
|
706
632
|
} else {
|
|
707
633
|
throw new Error("Invalid return type from LangChain function.");
|
|
708
634
|
}
|
|
@@ -882,33 +808,21 @@ var OpenAIAssistantAdapter = class {
|
|
|
882
808
|
eventSource.stream(async (eventStream$) => {
|
|
883
809
|
var _a, _b, _c, _d, _e, _f;
|
|
884
810
|
let inFunctionCall = false;
|
|
885
|
-
let currentMessageId;
|
|
886
|
-
let currentToolCallId;
|
|
887
811
|
for await (const chunk of stream) {
|
|
888
812
|
switch (chunk.event) {
|
|
889
813
|
case "thread.message.created":
|
|
890
814
|
if (inFunctionCall) {
|
|
891
|
-
eventStream$.sendActionExecutionEnd(
|
|
892
|
-
actionExecutionId: currentToolCallId
|
|
893
|
-
});
|
|
815
|
+
eventStream$.sendActionExecutionEnd();
|
|
894
816
|
}
|
|
895
|
-
|
|
896
|
-
eventStream$.sendTextMessageStart({
|
|
897
|
-
messageId: currentMessageId
|
|
898
|
-
});
|
|
817
|
+
eventStream$.sendTextMessageStart(chunk.data.id);
|
|
899
818
|
break;
|
|
900
819
|
case "thread.message.delta":
|
|
901
820
|
if (((_a = chunk.data.delta.content) == null ? void 0 : _a[0].type) === "text") {
|
|
902
|
-
eventStream$.sendTextMessageContent(
|
|
903
|
-
messageId: currentMessageId,
|
|
904
|
-
content: (_b = chunk.data.delta.content) == null ? void 0 : _b[0].text.value
|
|
905
|
-
});
|
|
821
|
+
eventStream$.sendTextMessageContent((_b = chunk.data.delta.content) == null ? void 0 : _b[0].text.value);
|
|
906
822
|
}
|
|
907
823
|
break;
|
|
908
824
|
case "thread.message.completed":
|
|
909
|
-
eventStream$.sendTextMessageEnd(
|
|
910
|
-
messageId: currentMessageId
|
|
911
|
-
});
|
|
825
|
+
eventStream$.sendTextMessageEnd();
|
|
912
826
|
break;
|
|
913
827
|
case "thread.run.step.delta":
|
|
914
828
|
let toolCallId;
|
|
@@ -921,30 +835,18 @@ var OpenAIAssistantAdapter = class {
|
|
|
921
835
|
}
|
|
922
836
|
if (toolCallName && toolCallId) {
|
|
923
837
|
if (inFunctionCall) {
|
|
924
|
-
eventStream$.sendActionExecutionEnd(
|
|
925
|
-
actionExecutionId: currentToolCallId
|
|
926
|
-
});
|
|
838
|
+
eventStream$.sendActionExecutionEnd();
|
|
927
839
|
}
|
|
928
840
|
inFunctionCall = true;
|
|
929
|
-
|
|
930
|
-
eventStream$.sendActionExecutionStart({
|
|
931
|
-
actionExecutionId: currentToolCallId,
|
|
932
|
-
parentMessageId: chunk.data.id,
|
|
933
|
-
actionName: toolCallName
|
|
934
|
-
});
|
|
841
|
+
eventStream$.sendActionExecutionStart(toolCallId, toolCallName);
|
|
935
842
|
} else if (toolCallArgs) {
|
|
936
|
-
eventStream$.sendActionExecutionArgs(
|
|
937
|
-
actionExecutionId: currentToolCallId,
|
|
938
|
-
args: toolCallArgs
|
|
939
|
-
});
|
|
843
|
+
eventStream$.sendActionExecutionArgs(toolCallArgs);
|
|
940
844
|
}
|
|
941
845
|
break;
|
|
942
846
|
}
|
|
943
847
|
}
|
|
944
848
|
if (inFunctionCall) {
|
|
945
|
-
eventStream$.sendActionExecutionEnd(
|
|
946
|
-
actionExecutionId: currentToolCallId
|
|
947
|
-
});
|
|
849
|
+
eventStream$.sendActionExecutionEnd();
|
|
948
850
|
}
|
|
949
851
|
eventStream$.complete();
|
|
950
852
|
});
|
|
@@ -987,7 +889,6 @@ var UnifyAdapter = class {
|
|
|
987
889
|
apiKey: this.apiKey,
|
|
988
890
|
baseURL: "https://api.unify.ai/v0/"
|
|
989
891
|
});
|
|
990
|
-
const forwardedParameters = request.forwardedParameters;
|
|
991
892
|
const messages = request.messages.map(convertMessageToOpenAIMessage);
|
|
992
893
|
const stream = await openai.chat.completions.create({
|
|
993
894
|
model: this.model,
|
|
@@ -995,83 +896,49 @@ var UnifyAdapter = class {
|
|
|
995
896
|
stream: true,
|
|
996
897
|
...tools.length > 0 && {
|
|
997
898
|
tools
|
|
998
|
-
},
|
|
999
|
-
...(forwardedParameters == null ? void 0 : forwardedParameters.temperature) && {
|
|
1000
|
-
temperature: forwardedParameters.temperature
|
|
1001
899
|
}
|
|
1002
900
|
});
|
|
1003
901
|
let model = null;
|
|
1004
|
-
let currentMessageId;
|
|
1005
|
-
let currentToolCallId;
|
|
1006
902
|
request.eventSource.stream(async (eventStream$) => {
|
|
1007
903
|
var _a, _b;
|
|
1008
904
|
let mode = null;
|
|
1009
905
|
for await (const chunk of stream) {
|
|
1010
906
|
if (this.start) {
|
|
1011
907
|
model = chunk.model;
|
|
1012
|
-
|
|
1013
|
-
eventStream$.
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
eventStream$.sendTextMessageContent({
|
|
1017
|
-
messageId: currentMessageId,
|
|
1018
|
-
content: `Model used: ${model}
|
|
1019
|
-
`
|
|
1020
|
-
});
|
|
1021
|
-
eventStream$.sendTextMessageEnd({
|
|
1022
|
-
messageId: currentMessageId
|
|
1023
|
-
});
|
|
908
|
+
eventStream$.sendTextMessageStart((0, import_shared4.randomId)());
|
|
909
|
+
eventStream$.sendTextMessageContent(`Model used: ${model}
|
|
910
|
+
`);
|
|
911
|
+
eventStream$.sendTextMessageEnd();
|
|
1024
912
|
this.start = false;
|
|
1025
913
|
}
|
|
1026
914
|
const toolCall = (_a = chunk.choices[0].delta.tool_calls) == null ? void 0 : _a[0];
|
|
1027
915
|
const content = chunk.choices[0].delta.content;
|
|
1028
916
|
if (mode === "message" && (toolCall == null ? void 0 : toolCall.id)) {
|
|
1029
917
|
mode = null;
|
|
1030
|
-
eventStream$.sendTextMessageEnd(
|
|
1031
|
-
messageId: currentMessageId
|
|
1032
|
-
});
|
|
918
|
+
eventStream$.sendTextMessageEnd();
|
|
1033
919
|
} else if (mode === "function" && (toolCall === void 0 || (toolCall == null ? void 0 : toolCall.id))) {
|
|
1034
920
|
mode = null;
|
|
1035
|
-
eventStream$.sendActionExecutionEnd(
|
|
1036
|
-
actionExecutionId: currentToolCallId
|
|
1037
|
-
});
|
|
921
|
+
eventStream$.sendActionExecutionEnd();
|
|
1038
922
|
}
|
|
1039
923
|
if (mode === null) {
|
|
1040
924
|
if (toolCall == null ? void 0 : toolCall.id) {
|
|
1041
925
|
mode = "function";
|
|
1042
|
-
|
|
1043
|
-
eventStream$.sendActionExecutionStart({
|
|
1044
|
-
actionExecutionId: currentToolCallId,
|
|
1045
|
-
actionName: toolCall.function.name
|
|
1046
|
-
});
|
|
926
|
+
eventStream$.sendActionExecutionStart(toolCall.id, toolCall.function.name);
|
|
1047
927
|
} else if (content) {
|
|
1048
928
|
mode = "message";
|
|
1049
|
-
|
|
1050
|
-
eventStream$.sendTextMessageStart({
|
|
1051
|
-
messageId: currentMessageId
|
|
1052
|
-
});
|
|
929
|
+
eventStream$.sendTextMessageStart(chunk.id);
|
|
1053
930
|
}
|
|
1054
931
|
}
|
|
1055
932
|
if (mode === "message" && content) {
|
|
1056
|
-
eventStream$.sendTextMessageContent(
|
|
1057
|
-
messageId: currentMessageId,
|
|
1058
|
-
content
|
|
1059
|
-
});
|
|
933
|
+
eventStream$.sendTextMessageContent(content);
|
|
1060
934
|
} else if (mode === "function" && ((_b = toolCall == null ? void 0 : toolCall.function) == null ? void 0 : _b.arguments)) {
|
|
1061
|
-
eventStream$.sendActionExecutionArgs(
|
|
1062
|
-
actionExecutionId: currentToolCallId,
|
|
1063
|
-
args: toolCall.function.arguments
|
|
1064
|
-
});
|
|
935
|
+
eventStream$.sendActionExecutionArgs(toolCall.function.arguments);
|
|
1065
936
|
}
|
|
1066
937
|
}
|
|
1067
938
|
if (mode === "message") {
|
|
1068
|
-
eventStream$.sendTextMessageEnd(
|
|
1069
|
-
messageId: currentMessageId
|
|
1070
|
-
});
|
|
939
|
+
eventStream$.sendTextMessageEnd();
|
|
1071
940
|
} else if (mode === "function") {
|
|
1072
|
-
eventStream$.sendActionExecutionEnd(
|
|
1073
|
-
actionExecutionId: currentToolCallId
|
|
1074
|
-
});
|
|
941
|
+
eventStream$.sendActionExecutionEnd();
|
|
1075
942
|
}
|
|
1076
943
|
eventStream$.complete();
|
|
1077
944
|
});
|
|
@@ -1132,67 +999,40 @@ var GroqAdapter = class {
|
|
|
1132
999
|
},
|
|
1133
1000
|
...this.disableParallelToolCalls && {
|
|
1134
1001
|
parallel_tool_calls: false
|
|
1135
|
-
},
|
|
1136
|
-
...(forwardedParameters == null ? void 0 : forwardedParameters.temperature) && {
|
|
1137
|
-
temperature: forwardedParameters.temperature
|
|
1138
1002
|
}
|
|
1139
1003
|
});
|
|
1140
1004
|
eventSource.stream(async (eventStream$) => {
|
|
1141
1005
|
var _a, _b;
|
|
1142
1006
|
let mode = null;
|
|
1143
|
-
let currentMessageId;
|
|
1144
|
-
let currentToolCallId;
|
|
1145
1007
|
for await (const chunk of stream) {
|
|
1146
1008
|
const toolCall = (_a = chunk.choices[0].delta.tool_calls) == null ? void 0 : _a[0];
|
|
1147
1009
|
const content = chunk.choices[0].delta.content;
|
|
1148
1010
|
if (mode === "message" && (toolCall == null ? void 0 : toolCall.id)) {
|
|
1149
1011
|
mode = null;
|
|
1150
|
-
eventStream$.sendTextMessageEnd(
|
|
1151
|
-
messageId: currentMessageId
|
|
1152
|
-
});
|
|
1012
|
+
eventStream$.sendTextMessageEnd();
|
|
1153
1013
|
} else if (mode === "function" && (toolCall === void 0 || (toolCall == null ? void 0 : toolCall.id))) {
|
|
1154
1014
|
mode = null;
|
|
1155
|
-
eventStream$.sendActionExecutionEnd(
|
|
1156
|
-
actionExecutionId: currentToolCallId
|
|
1157
|
-
});
|
|
1015
|
+
eventStream$.sendActionExecutionEnd();
|
|
1158
1016
|
}
|
|
1159
1017
|
if (mode === null) {
|
|
1160
1018
|
if (toolCall == null ? void 0 : toolCall.id) {
|
|
1161
1019
|
mode = "function";
|
|
1162
|
-
|
|
1163
|
-
eventStream$.sendActionExecutionStart({
|
|
1164
|
-
actionExecutionId: currentToolCallId,
|
|
1165
|
-
actionName: toolCall.function.name,
|
|
1166
|
-
parentMessageId: chunk.id
|
|
1167
|
-
});
|
|
1020
|
+
eventStream$.sendActionExecutionStart(toolCall.id, toolCall.function.name);
|
|
1168
1021
|
} else if (content) {
|
|
1169
1022
|
mode = "message";
|
|
1170
|
-
|
|
1171
|
-
eventStream$.sendTextMessageStart({
|
|
1172
|
-
messageId: currentMessageId
|
|
1173
|
-
});
|
|
1023
|
+
eventStream$.sendTextMessageStart(chunk.id);
|
|
1174
1024
|
}
|
|
1175
1025
|
}
|
|
1176
1026
|
if (mode === "message" && content) {
|
|
1177
|
-
eventStream$.sendTextMessageContent(
|
|
1178
|
-
messageId: currentMessageId,
|
|
1179
|
-
content
|
|
1180
|
-
});
|
|
1027
|
+
eventStream$.sendTextMessageContent(content);
|
|
1181
1028
|
} else if (mode === "function" && ((_b = toolCall == null ? void 0 : toolCall.function) == null ? void 0 : _b.arguments)) {
|
|
1182
|
-
eventStream$.sendActionExecutionArgs(
|
|
1183
|
-
actionExecutionId: currentToolCallId,
|
|
1184
|
-
args: toolCall.function.arguments
|
|
1185
|
-
});
|
|
1029
|
+
eventStream$.sendActionExecutionArgs(toolCall.function.arguments);
|
|
1186
1030
|
}
|
|
1187
1031
|
}
|
|
1188
1032
|
if (mode === "message") {
|
|
1189
|
-
eventStream$.sendTextMessageEnd(
|
|
1190
|
-
messageId: currentMessageId
|
|
1191
|
-
});
|
|
1033
|
+
eventStream$.sendTextMessageEnd();
|
|
1192
1034
|
} else if (mode === "function") {
|
|
1193
|
-
eventStream$.sendActionExecutionEnd(
|
|
1194
|
-
actionExecutionId: currentToolCallId
|
|
1195
|
-
});
|
|
1035
|
+
eventStream$.sendActionExecutionEnd();
|
|
1196
1036
|
}
|
|
1197
1037
|
eventStream$.complete();
|
|
1198
1038
|
});
|
|
@@ -1253,167 +1093,163 @@ var RemoteLangGraphEventSource = class {
|
|
|
1253
1093
|
}
|
|
1254
1094
|
return shouldEmitToolCalls === toolCallName;
|
|
1255
1095
|
}
|
|
1256
|
-
getCurrentContent(event) {
|
|
1257
|
-
var _a, _b, _c, _d, _e;
|
|
1258
|
-
const content = ((_c = (_b = (_a = event.data) == null ? void 0 : _a.chunk) == null ? void 0 : _b.kwargs) == null ? void 0 : _c.content) ?? ((_e = (_d = event.data) == null ? void 0 : _d.chunk) == null ? void 0 : _e.content);
|
|
1259
|
-
if (!content) {
|
|
1260
|
-
const toolCallChunks = this.getCurrentToolCallChunks(event) ?? [];
|
|
1261
|
-
for (const chunk of toolCallChunks) {
|
|
1262
|
-
if (chunk.args) {
|
|
1263
|
-
return chunk.args;
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1266
|
-
}
|
|
1267
|
-
if (typeof content === "string") {
|
|
1268
|
-
return content;
|
|
1269
|
-
} else if (Array.isArray(content) && content.length > 0) {
|
|
1270
|
-
return content[0].text;
|
|
1271
|
-
}
|
|
1272
|
-
return null;
|
|
1273
|
-
}
|
|
1274
|
-
getCurrentMessageId(event) {
|
|
1275
|
-
var _a, _b, _c, _d, _e;
|
|
1276
|
-
return ((_c = (_b = (_a = event.data) == null ? void 0 : _a.chunk) == null ? void 0 : _b.kwargs) == null ? void 0 : _c.id) ?? ((_e = (_d = event.data) == null ? void 0 : _d.chunk) == null ? void 0 : _e.id);
|
|
1277
|
-
}
|
|
1278
|
-
getCurrentToolCallChunks(event) {
|
|
1279
|
-
var _a, _b, _c, _d, _e;
|
|
1280
|
-
return ((_c = (_b = (_a = event.data) == null ? void 0 : _a.chunk) == null ? void 0 : _b.kwargs) == null ? void 0 : _c.tool_call_chunks) ?? ((_e = (_d = event.data) == null ? void 0 : _d.chunk) == null ? void 0 : _e.tool_call_chunks);
|
|
1281
|
-
}
|
|
1282
|
-
getResponseMetadata(event) {
|
|
1283
|
-
var _a, _b, _c, _d, _e;
|
|
1284
|
-
return ((_c = (_b = (_a = event.data) == null ? void 0 : _a.chunk) == null ? void 0 : _b.kwargs) == null ? void 0 : _c.response_metadata) ?? ((_e = (_d = event.data) == null ? void 0 : _d.chunk) == null ? void 0 : _e.response_metadata);
|
|
1285
|
-
}
|
|
1286
1096
|
processLangGraphEvents() {
|
|
1287
1097
|
let lastEventWithState = null;
|
|
1288
1098
|
return this.eventStream$.pipe((0, import_rxjs.scan)((acc, event) => {
|
|
1099
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
1289
1100
|
if (event.event === LangGraphEventTypes.OnChatModelStream) {
|
|
1290
|
-
const
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1101
|
+
const content = ((_c = (_b = (_a = event.data) == null ? void 0 : _a.chunk) == null ? void 0 : _b.kwargs) == null ? void 0 : _c.content) ?? ((_e = (_d = event.data) == null ? void 0 : _d.chunk) == null ? void 0 : _e.content);
|
|
1102
|
+
if (typeof content === "string") {
|
|
1103
|
+
acc.content = content;
|
|
1104
|
+
} else if (Array.isArray(content) && content.length > 0) {
|
|
1105
|
+
acc.content = content[0].text;
|
|
1106
|
+
} else {
|
|
1107
|
+
acc.content = null;
|
|
1108
|
+
}
|
|
1109
|
+
const toolCallChunks = (
|
|
1110
|
+
// @ts-expect-error -- LangGraph Platform implementation stores data outside of kwargs
|
|
1111
|
+
((_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)
|
|
1112
|
+
);
|
|
1113
|
+
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);
|
|
1114
|
+
if (toolCallChunks && toolCallChunks.length > 0) {
|
|
1115
|
+
acc.prevToolCallMessageId = acc.toolCallMessageId;
|
|
1116
|
+
acc.toolCallMessageId = toolCallMessageId;
|
|
1117
|
+
if ((_p = toolCallChunks[0]) == null ? void 0 : _p.name) {
|
|
1118
|
+
acc.toolCallName = toolCallChunks[0].name;
|
|
1119
|
+
}
|
|
1120
|
+
if ((_q = toolCallChunks[0]) == null ? void 0 : _q.id) {
|
|
1121
|
+
acc.toolCallId = toolCallChunks[0].id;
|
|
1122
|
+
}
|
|
1123
|
+
acc.prevMessageId = acc.messageId;
|
|
1124
|
+
acc.messageId = toolCallMessageId;
|
|
1125
|
+
} else if (acc.content && acc.content != "") {
|
|
1126
|
+
acc.prevMessageId = acc.messageId;
|
|
1127
|
+
acc.messageId = toolCallMessageId;
|
|
1128
|
+
} else {
|
|
1129
|
+
acc.prevToolCallMessageId = acc.toolCallMessageId;
|
|
1130
|
+
acc.prevMessageId = acc.messageId;
|
|
1131
|
+
}
|
|
1132
|
+
} else {
|
|
1133
|
+
acc.prevToolCallMessageId = acc.toolCallMessageId;
|
|
1134
|
+
acc.toolCallMessageId = null;
|
|
1135
|
+
acc.prevMessageId = acc.messageId;
|
|
1136
|
+
acc.messageId = null;
|
|
1137
|
+
acc.toolCallName = null;
|
|
1304
1138
|
}
|
|
1305
1139
|
acc.event = event;
|
|
1306
1140
|
lastEventWithState = acc;
|
|
1307
1141
|
return acc;
|
|
1308
1142
|
}, {
|
|
1309
1143
|
event: null,
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
}), (0, import_rxjs.mergeMap)((acc) => {
|
|
1144
|
+
toolCallId: null,
|
|
1145
|
+
toolCallMessageId: null,
|
|
1146
|
+
prevToolCallMessageId: null,
|
|
1147
|
+
messageId: null,
|
|
1148
|
+
toolCallName: null,
|
|
1149
|
+
prevMessageId: null,
|
|
1150
|
+
content: null
|
|
1151
|
+
}), (0, import_rxjs.mergeMap)((eventWithState) => {
|
|
1152
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1320
1153
|
const events = [];
|
|
1321
1154
|
let shouldEmitMessages = true;
|
|
1322
|
-
let shouldEmitToolCalls =
|
|
1323
|
-
if (
|
|
1324
|
-
if ("copilotkit:emit-tool-calls" in (
|
|
1325
|
-
shouldEmitToolCalls =
|
|
1155
|
+
let shouldEmitToolCalls = false;
|
|
1156
|
+
if (eventWithState.event.event == LangGraphEventTypes.OnChatModelStream) {
|
|
1157
|
+
if ("copilotkit:emit-tool-calls" in (eventWithState.event.metadata || {})) {
|
|
1158
|
+
shouldEmitToolCalls = eventWithState.event.metadata["copilotkit:emit-tool-calls"];
|
|
1326
1159
|
}
|
|
1327
|
-
if ("copilotkit:emit-messages" in (
|
|
1328
|
-
shouldEmitMessages =
|
|
1160
|
+
if ("copilotkit:emit-messages" in (eventWithState.event.metadata || {})) {
|
|
1161
|
+
shouldEmitMessages = eventWithState.event.metadata["copilotkit:emit-messages"];
|
|
1329
1162
|
}
|
|
1330
1163
|
}
|
|
1331
|
-
|
|
1332
|
-
if ((responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "tool_calls" && this.shouldEmitToolCall(shouldEmitToolCalls, acc.lastToolCallName)) {
|
|
1164
|
+
if (eventWithState.prevToolCallMessageId !== null && eventWithState.prevToolCallMessageId !== eventWithState.toolCallMessageId && this.shouldEmitToolCall(shouldEmitToolCalls, eventWithState.toolCallName)) {
|
|
1333
1165
|
events.push({
|
|
1334
|
-
type: RuntimeEventTypes.ActionExecutionEnd
|
|
1335
|
-
actionExecutionId: acc.lastToolCallId
|
|
1166
|
+
type: RuntimeEventTypes.ActionExecutionEnd
|
|
1336
1167
|
});
|
|
1337
1168
|
}
|
|
1338
|
-
if (
|
|
1169
|
+
if (eventWithState.prevMessageId !== null && eventWithState.prevMessageId !== eventWithState.messageId && shouldEmitMessages) {
|
|
1339
1170
|
events.push({
|
|
1340
|
-
type: RuntimeEventTypes.TextMessageEnd
|
|
1341
|
-
messageId: acc.lastMessageId
|
|
1171
|
+
type: RuntimeEventTypes.TextMessageEnd
|
|
1342
1172
|
});
|
|
1343
1173
|
}
|
|
1344
|
-
switch (
|
|
1174
|
+
switch (eventWithState.event.event) {
|
|
1345
1175
|
case LangGraphEventTypes.OnCustomEvent:
|
|
1346
|
-
if (
|
|
1176
|
+
if (eventWithState.event.name === CustomEventNames.CopilotKitManuallyEmitMessage) {
|
|
1347
1177
|
events.push({
|
|
1348
1178
|
type: RuntimeEventTypes.TextMessageStart,
|
|
1349
|
-
messageId:
|
|
1179
|
+
messageId: eventWithState.event.data.message_id
|
|
1350
1180
|
});
|
|
1351
1181
|
events.push({
|
|
1352
1182
|
type: RuntimeEventTypes.TextMessageContent,
|
|
1353
|
-
|
|
1354
|
-
content: acc.event.data.message
|
|
1183
|
+
content: eventWithState.event.data.message
|
|
1355
1184
|
});
|
|
1356
1185
|
events.push({
|
|
1357
|
-
type: RuntimeEventTypes.TextMessageEnd
|
|
1358
|
-
messageId: acc.event.data.message_id
|
|
1186
|
+
type: RuntimeEventTypes.TextMessageEnd
|
|
1359
1187
|
});
|
|
1360
|
-
} else if (
|
|
1188
|
+
} else if (eventWithState.event.name === CustomEventNames.CopilotKitManuallyEmitToolCall) {
|
|
1361
1189
|
events.push({
|
|
1362
1190
|
type: RuntimeEventTypes.ActionExecutionStart,
|
|
1363
|
-
actionExecutionId:
|
|
1364
|
-
actionName:
|
|
1365
|
-
parentMessageId: acc.event.data.id
|
|
1191
|
+
actionExecutionId: eventWithState.event.data.id,
|
|
1192
|
+
actionName: eventWithState.event.data.name
|
|
1366
1193
|
});
|
|
1367
1194
|
events.push({
|
|
1368
1195
|
type: RuntimeEventTypes.ActionExecutionArgs,
|
|
1369
|
-
|
|
1370
|
-
args: JSON.stringify(acc.event.data.args)
|
|
1196
|
+
args: JSON.stringify(eventWithState.event.data.args)
|
|
1371
1197
|
});
|
|
1372
1198
|
events.push({
|
|
1373
|
-
type: RuntimeEventTypes.ActionExecutionEnd
|
|
1374
|
-
actionExecutionId: acc.event.data.id
|
|
1199
|
+
type: RuntimeEventTypes.ActionExecutionEnd
|
|
1375
1200
|
});
|
|
1376
1201
|
}
|
|
1377
1202
|
break;
|
|
1378
1203
|
case LangGraphEventTypes.OnCopilotKitStateSync:
|
|
1379
1204
|
events.push({
|
|
1380
1205
|
type: RuntimeEventTypes.AgentStateMessage,
|
|
1381
|
-
threadId:
|
|
1382
|
-
role:
|
|
1383
|
-
agentName:
|
|
1384
|
-
nodeName:
|
|
1385
|
-
runId:
|
|
1386
|
-
active:
|
|
1387
|
-
state: JSON.stringify(
|
|
1388
|
-
running:
|
|
1206
|
+
threadId: eventWithState.event.thread_id,
|
|
1207
|
+
role: eventWithState.event.role,
|
|
1208
|
+
agentName: eventWithState.event.agent_name,
|
|
1209
|
+
nodeName: eventWithState.event.node_name,
|
|
1210
|
+
runId: eventWithState.event.run_id,
|
|
1211
|
+
active: eventWithState.event.active,
|
|
1212
|
+
state: JSON.stringify(eventWithState.event.state),
|
|
1213
|
+
running: eventWithState.event.running
|
|
1389
1214
|
});
|
|
1390
1215
|
break;
|
|
1216
|
+
case LangGraphEventTypes.OnToolEnd:
|
|
1217
|
+
break;
|
|
1391
1218
|
case LangGraphEventTypes.OnChatModelStream:
|
|
1392
|
-
if (
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1219
|
+
if (eventWithState.toolCallMessageId !== null && eventWithState.prevToolCallMessageId !== eventWithState.toolCallMessageId) {
|
|
1220
|
+
if (this.shouldEmitToolCall(shouldEmitToolCalls, eventWithState.toolCallName)) {
|
|
1221
|
+
events.push({
|
|
1222
|
+
type: RuntimeEventTypes.ActionExecutionStart,
|
|
1223
|
+
actionExecutionId: eventWithState.toolCallMessageId,
|
|
1224
|
+
actionName: eventWithState.toolCallName,
|
|
1225
|
+
scope: "client"
|
|
1226
|
+
});
|
|
1227
|
+
}
|
|
1228
|
+
} else if (eventWithState.messageId !== null && eventWithState.prevMessageId !== eventWithState.messageId) {
|
|
1229
|
+
if (shouldEmitMessages) {
|
|
1230
|
+
events.push({
|
|
1231
|
+
type: RuntimeEventTypes.TextMessageStart,
|
|
1232
|
+
messageId: eventWithState.messageId
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1404
1235
|
}
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1236
|
+
const args = ((_e = (_d = (_c = (_b = (_a = eventWithState.event.data) == null ? void 0 : _a.chunk) == null ? void 0 : _b.kwargs) == null ? void 0 : _c.tool_call_chunks) == null ? void 0 : _d[0]) == null ? void 0 : _e.args) ?? // @ts-expect-error -- sdf
|
|
1237
|
+
((_i = (_h = (_g = (_f = eventWithState.event.data) == null ? void 0 : _f.chunk) == null ? void 0 : _g.tool_call_chunks) == null ? void 0 : _h[0]) == null ? void 0 : _i.args);
|
|
1238
|
+
const content = eventWithState.content;
|
|
1239
|
+
if (args) {
|
|
1240
|
+
if (this.shouldEmitToolCall(shouldEmitToolCalls, eventWithState.toolCallName)) {
|
|
1241
|
+
events.push({
|
|
1242
|
+
type: RuntimeEventTypes.ActionExecutionArgs,
|
|
1243
|
+
args
|
|
1244
|
+
});
|
|
1245
|
+
}
|
|
1246
|
+
} else if (eventWithState.messageId !== null && content) {
|
|
1247
|
+
if (shouldEmitMessages) {
|
|
1248
|
+
events.push({
|
|
1249
|
+
type: RuntimeEventTypes.TextMessageContent,
|
|
1250
|
+
content
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1417
1253
|
}
|
|
1418
1254
|
break;
|
|
1419
1255
|
}
|
|
@@ -1421,16 +1257,14 @@ var RemoteLangGraphEventSource = class {
|
|
|
1421
1257
|
}), (0, import_rxjs.catchError)((error) => {
|
|
1422
1258
|
console.error(error);
|
|
1423
1259
|
const events = [];
|
|
1424
|
-
if (
|
|
1260
|
+
if (lastEventWithState == null ? void 0 : lastEventWithState.messageId) {
|
|
1425
1261
|
events.push({
|
|
1426
|
-
type: RuntimeEventTypes.TextMessageEnd
|
|
1427
|
-
messageId: lastEventWithState.lastMessageId
|
|
1262
|
+
type: RuntimeEventTypes.TextMessageEnd
|
|
1428
1263
|
});
|
|
1429
1264
|
}
|
|
1430
|
-
if (lastEventWithState == null ? void 0 : lastEventWithState.
|
|
1265
|
+
if (lastEventWithState == null ? void 0 : lastEventWithState.toolCallMessageId) {
|
|
1431
1266
|
events.push({
|
|
1432
|
-
type: RuntimeEventTypes.ActionExecutionEnd
|
|
1433
|
-
actionExecutionId: lastEventWithState.lastToolCallId
|
|
1267
|
+
type: RuntimeEventTypes.ActionExecutionEnd
|
|
1434
1268
|
});
|
|
1435
1269
|
}
|
|
1436
1270
|
const messageId = (0, import_shared6.randomId)();
|
|
@@ -1440,12 +1274,10 @@ var RemoteLangGraphEventSource = class {
|
|
|
1440
1274
|
});
|
|
1441
1275
|
events.push({
|
|
1442
1276
|
type: RuntimeEventTypes.TextMessageContent,
|
|
1443
|
-
messageId,
|
|
1444
1277
|
content: "\u274C An error occurred. Please try again."
|
|
1445
1278
|
});
|
|
1446
1279
|
events.push({
|
|
1447
|
-
type: RuntimeEventTypes.TextMessageEnd
|
|
1448
|
-
messageId
|
|
1280
|
+
type: RuntimeEventTypes.TextMessageEnd
|
|
1449
1281
|
});
|
|
1450
1282
|
return events;
|
|
1451
1283
|
}));
|
|
@@ -1467,6 +1299,12 @@ var MessageRole;
|
|
|
1467
1299
|
MessageRole2["system"] = "system";
|
|
1468
1300
|
MessageRole2["tool"] = "tool";
|
|
1469
1301
|
})(MessageRole || (MessageRole = {}));
|
|
1302
|
+
var ActionExecutionScope;
|
|
1303
|
+
(function(ActionExecutionScope2) {
|
|
1304
|
+
ActionExecutionScope2["server"] = "server";
|
|
1305
|
+
ActionExecutionScope2["client"] = "client";
|
|
1306
|
+
ActionExecutionScope2["passThrough"] = "passThrough";
|
|
1307
|
+
})(ActionExecutionScope || (ActionExecutionScope = {}));
|
|
1470
1308
|
var CopilotRequestType;
|
|
1471
1309
|
(function(CopilotRequestType2) {
|
|
1472
1310
|
CopilotRequestType2["Chat"] = "Chat";
|
|
@@ -1485,6 +1323,10 @@ var ActionInputAvailability;
|
|
|
1485
1323
|
name: "MessageRole",
|
|
1486
1324
|
description: "The role of the message"
|
|
1487
1325
|
});
|
|
1326
|
+
(0, import_type_graphql.registerEnumType)(ActionExecutionScope, {
|
|
1327
|
+
name: "ActionExecutionScope",
|
|
1328
|
+
description: "The scope of the action"
|
|
1329
|
+
});
|
|
1488
1330
|
(0, import_type_graphql.registerEnumType)(CopilotRequestType, {
|
|
1489
1331
|
name: "CopilotRequestType",
|
|
1490
1332
|
description: "The type of Copilot request"
|
|
@@ -1522,6 +1364,8 @@ async function streamEvents(controller, args) {
|
|
|
1522
1364
|
if (initialThreadId && initialThreadId.startsWith("ck-")) {
|
|
1523
1365
|
initialThreadId = initialThreadId.substring(3);
|
|
1524
1366
|
}
|
|
1367
|
+
const assistants = await client.assistants.search();
|
|
1368
|
+
const retrievedAssistant = assistants.find((a) => a.name === name);
|
|
1525
1369
|
const threadId = initialThreadId ?? (0, import_node_crypto.randomUUID)();
|
|
1526
1370
|
if (initialThreadId === threadId) {
|
|
1527
1371
|
await client.threads.get(threadId);
|
|
@@ -1541,7 +1385,7 @@ async function streamEvents(controller, args) {
|
|
|
1541
1385
|
const mode = wasInitiatedWithExistingThread && nodeName != "__end__" ? "continue" : "start";
|
|
1542
1386
|
let formattedMessages = [];
|
|
1543
1387
|
try {
|
|
1544
|
-
formattedMessages =
|
|
1388
|
+
formattedMessages = formatMessages(messages);
|
|
1545
1389
|
} catch (e) {
|
|
1546
1390
|
logger2.error(e, `Error event thrown: ${e.message}`);
|
|
1547
1391
|
}
|
|
@@ -1552,16 +1396,8 @@ async function streamEvents(controller, args) {
|
|
|
1552
1396
|
asNode: nodeName
|
|
1553
1397
|
});
|
|
1554
1398
|
}
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
};
|
|
1558
|
-
const assistants = await client.assistants.search();
|
|
1559
|
-
const retrievedAssistant = assistants.find((a) => a.name === name || a.assistant_id === initialAssistantId);
|
|
1560
|
-
if (!retrievedAssistant) {
|
|
1561
|
-
telemetry_client_default.capture("oss.runtime.agent_execution_stream_errored", {
|
|
1562
|
-
...streamInfo,
|
|
1563
|
-
error: `Found no assistants for given information, while ${assistants.length} assistants exists`
|
|
1564
|
-
});
|
|
1399
|
+
const assistantId = initialAssistantId ?? (retrievedAssistant == null ? void 0 : retrievedAssistant.assistant_id);
|
|
1400
|
+
if (!assistantId) {
|
|
1565
1401
|
console.error(`
|
|
1566
1402
|
No agent found for the agent name specified in CopilotKit provider
|
|
1567
1403
|
Please check your available agents or provide an agent ID in the LangGraph Platform endpoint definition.
|
|
@@ -1571,7 +1407,6 @@ async function streamEvents(controller, args) {
|
|
|
1571
1407
|
`);
|
|
1572
1408
|
throw new Error("No agent id found");
|
|
1573
1409
|
}
|
|
1574
|
-
const assistantId = retrievedAssistant.assistant_id;
|
|
1575
1410
|
const graphInfo = await client.assistants.getGraph(assistantId);
|
|
1576
1411
|
const streamInput = mode === "start" ? state : null;
|
|
1577
1412
|
let streamingStateExtractor = new StreamingStateExtractor([]);
|
|
@@ -1590,6 +1425,9 @@ async function streamEvents(controller, args) {
|
|
|
1590
1425
|
let latestStateValues = {};
|
|
1591
1426
|
let updatedState = state;
|
|
1592
1427
|
let manuallyEmittedState = null;
|
|
1428
|
+
let streamInfo = {
|
|
1429
|
+
hashedLgcKey: (0, import_node_crypto.createHash)("sha256").update(langsmithApiKey).digest("hex")
|
|
1430
|
+
};
|
|
1593
1431
|
try {
|
|
1594
1432
|
telemetry_client_default.capture("oss.runtime.agent_execution_stream_started", {
|
|
1595
1433
|
hashedLgcKey: streamInfo.hashedLgcKey
|
|
@@ -1602,6 +1440,7 @@ async function streamEvents(controller, args) {
|
|
|
1602
1440
|
].includes(chunk.event))
|
|
1603
1441
|
continue;
|
|
1604
1442
|
if (chunk.event === "error") {
|
|
1443
|
+
logger2.error(chunk, `Error event thrown: ${chunk.data.message}`);
|
|
1605
1444
|
throw new Error(`Error event thrown: ${chunk.data.message}`);
|
|
1606
1445
|
}
|
|
1607
1446
|
if (chunk.event === "values") {
|
|
@@ -1694,34 +1533,21 @@ async function streamEvents(controller, args) {
|
|
|
1694
1533
|
nodeName: isEndNode ? "__end__" : nodeName,
|
|
1695
1534
|
state: state.values,
|
|
1696
1535
|
running: !shouldExit,
|
|
1697
|
-
active: false
|
|
1698
|
-
includeMessages: true
|
|
1536
|
+
active: false
|
|
1699
1537
|
}));
|
|
1700
1538
|
return Promise.resolve();
|
|
1701
1539
|
} catch (e) {
|
|
1702
|
-
logger2.error(e);
|
|
1703
|
-
telemetry_client_default.capture("oss.runtime.agent_execution_stream_errored", {
|
|
1704
|
-
...streamInfo,
|
|
1705
|
-
error: e.message
|
|
1706
|
-
});
|
|
1707
1540
|
return Promise.resolve();
|
|
1708
1541
|
}
|
|
1709
1542
|
}
|
|
1710
1543
|
__name(streamEvents, "streamEvents");
|
|
1711
|
-
function getStateSyncEvent({ threadId, runId, agentName, nodeName, state, running, active
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
}, {});
|
|
1719
|
-
} else {
|
|
1720
|
-
state = {
|
|
1721
|
-
...state,
|
|
1722
|
-
messages: langchainMessagesToCopilotKit(state.messages || [])
|
|
1723
|
-
};
|
|
1724
|
-
}
|
|
1544
|
+
function getStateSyncEvent({ threadId, runId, agentName, nodeName, state, running, active }) {
|
|
1545
|
+
const stateWithoutMessages = Object.keys(state).reduce((acc, key) => {
|
|
1546
|
+
if (key !== "messages") {
|
|
1547
|
+
acc[key] = state[key];
|
|
1548
|
+
}
|
|
1549
|
+
return acc;
|
|
1550
|
+
}, {});
|
|
1725
1551
|
return JSON.stringify({
|
|
1726
1552
|
event: LangGraphEventTypes.OnCopilotKitStateSync,
|
|
1727
1553
|
thread_id: threadId,
|
|
@@ -1729,7 +1555,7 @@ function getStateSyncEvent({ threadId, runId, agentName, nodeName, state, runnin
|
|
|
1729
1555
|
agent_name: agentName,
|
|
1730
1556
|
node_name: nodeName,
|
|
1731
1557
|
active,
|
|
1732
|
-
state,
|
|
1558
|
+
state: stateWithoutMessages,
|
|
1733
1559
|
running,
|
|
1734
1560
|
role: "assistant"
|
|
1735
1561
|
}) + "\n";
|
|
@@ -1805,157 +1631,134 @@ function langGraphDefaultMergeState(state, messages, actions, agentName) {
|
|
|
1805
1631
|
if (messages.length > 0 && "role" in messages[0] && messages[0].role === "system") {
|
|
1806
1632
|
messages = messages.slice(1);
|
|
1807
1633
|
}
|
|
1808
|
-
const
|
|
1809
|
-
const existingMessageIds = new Set(
|
|
1810
|
-
const
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
copilotkit: {
|
|
1815
|
-
actions
|
|
1816
|
-
}
|
|
1817
|
-
};
|
|
1818
|
-
}
|
|
1819
|
-
__name(langGraphDefaultMergeState, "langGraphDefaultMergeState");
|
|
1820
|
-
function langchainMessagesToCopilotKit(messages) {
|
|
1821
|
-
const result = [];
|
|
1822
|
-
const tool_call_names = {};
|
|
1823
|
-
for (const message of messages) {
|
|
1824
|
-
if (message.type === "ai") {
|
|
1825
|
-
for (const tool_call of message.tool_calls) {
|
|
1826
|
-
tool_call_names[tool_call.id] = tool_call.name;
|
|
1827
|
-
}
|
|
1634
|
+
const mergedMessages = state.messages || [];
|
|
1635
|
+
const existingMessageIds = new Set(mergedMessages.map((message) => message.id));
|
|
1636
|
+
const existingToolCallResults = /* @__PURE__ */ new Set();
|
|
1637
|
+
for (const message of mergedMessages) {
|
|
1638
|
+
if ("tool_call_id" in message) {
|
|
1639
|
+
existingToolCallResults.add(message.tool_call_id);
|
|
1828
1640
|
}
|
|
1829
1641
|
}
|
|
1830
1642
|
for (const message of messages) {
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
content = content[0];
|
|
1643
|
+
if ("tool_calls" in message && message.tool_calls.length > 0 && message.tool_calls[0].name === agentName) {
|
|
1644
|
+
continue;
|
|
1834
1645
|
}
|
|
1835
|
-
if (
|
|
1836
|
-
|
|
1646
|
+
if ("name" in message && message.name === agentName) {
|
|
1647
|
+
continue;
|
|
1837
1648
|
}
|
|
1838
|
-
if (message.
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
} else
|
|
1845
|
-
|
|
1846
|
-
role
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
for (const tool_call of message.tool_calls) {
|
|
1853
|
-
result.push({
|
|
1854
|
-
id: tool_call.id,
|
|
1855
|
-
name: tool_call.name,
|
|
1856
|
-
arguments: tool_call.args,
|
|
1857
|
-
parentMessageId: message.id
|
|
1858
|
-
});
|
|
1649
|
+
if (!existingMessageIds.has(message.id)) {
|
|
1650
|
+
if ("tool_call_id" in message && existingToolCallResults.has(message.tool_call_id)) {
|
|
1651
|
+
console.warn("Warning: Duplicate tool call result, skipping:", message.tool_call_id);
|
|
1652
|
+
continue;
|
|
1653
|
+
}
|
|
1654
|
+
mergedMessages.push(message);
|
|
1655
|
+
} else {
|
|
1656
|
+
for (let i = 0; i < mergedMessages.length; i++) {
|
|
1657
|
+
if (mergedMessages[i].id === message.id && message.role === "assistant") {
|
|
1658
|
+
if (("tool_calls" in mergedMessages[i] || "additional_kwargs" in mergedMessages[i]) && mergedMessages[i].content) {
|
|
1659
|
+
message.tool_calls = mergedMessages[i]["tool_calls"];
|
|
1660
|
+
message.additional_kwargs = mergedMessages[i].additional_kwargs;
|
|
1661
|
+
}
|
|
1662
|
+
mergedMessages[i] = message;
|
|
1859
1663
|
}
|
|
1860
|
-
} else {
|
|
1861
|
-
result.push({
|
|
1862
|
-
role: "assistant",
|
|
1863
|
-
content,
|
|
1864
|
-
id: message.id,
|
|
1865
|
-
parentMessageId: message.id
|
|
1866
|
-
});
|
|
1867
1664
|
}
|
|
1868
|
-
} else if (message.type === "tool") {
|
|
1869
|
-
const actionName = tool_call_names[message.tool_call_id] || message.name || "";
|
|
1870
|
-
result.push({
|
|
1871
|
-
actionExecutionId: message.tool_call_id,
|
|
1872
|
-
actionName,
|
|
1873
|
-
result: content,
|
|
1874
|
-
id: message.id
|
|
1875
|
-
});
|
|
1876
1665
|
}
|
|
1877
1666
|
}
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1667
|
+
for (let i = 0; i < mergedMessages.length - 1; i++) {
|
|
1668
|
+
const currentMessage = mergedMessages[i];
|
|
1669
|
+
const nextMessage = mergedMessages[i + 1];
|
|
1670
|
+
if ("tool_calls" in currentMessage && currentMessage.tool_calls.length > 0 && "tool_call_id" in nextMessage) {
|
|
1671
|
+
nextMessage.tool_call_id = currentMessage.tool_calls[0].id;
|
|
1882
1672
|
}
|
|
1883
1673
|
}
|
|
1884
|
-
const
|
|
1885
|
-
for (
|
|
1886
|
-
|
|
1887
|
-
|
|
1674
|
+
const correctedMessages = [];
|
|
1675
|
+
for (let i = 0; i < mergedMessages.length; i++) {
|
|
1676
|
+
const currentMessage = mergedMessages[i];
|
|
1677
|
+
const nextMessage = mergedMessages[i + 1] || null;
|
|
1678
|
+
const prevMessage = mergedMessages[i - 1] || null;
|
|
1679
|
+
if ("tool_calls" in currentMessage && currentMessage.tool_calls.length > 0) {
|
|
1680
|
+
if (!nextMessage) {
|
|
1681
|
+
console.warn("No next message to auto-correct tool call, skipping:", currentMessage.tool_calls[0].id);
|
|
1682
|
+
continue;
|
|
1683
|
+
}
|
|
1684
|
+
if (!("tool_call_id" in nextMessage) || nextMessage.tool_call_id !== currentMessage.tool_calls[0].id) {
|
|
1685
|
+
const toolMessage = mergedMessages.find((m) => "tool_call_id" in m && m.tool_call_id === currentMessage.tool_calls[0].id);
|
|
1686
|
+
if (toolMessage) {
|
|
1687
|
+
console.warn("Auto-corrected tool call alignment issue:", currentMessage.tool_calls[0].id);
|
|
1688
|
+
correctedMessages.push(currentMessage, toolMessage);
|
|
1689
|
+
continue;
|
|
1690
|
+
} else {
|
|
1691
|
+
console.warn("No corresponding tool call result found for tool call, skipping:", currentMessage.tool_calls[0].id);
|
|
1692
|
+
continue;
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
correctedMessages.push(currentMessage);
|
|
1696
|
+
continue;
|
|
1888
1697
|
}
|
|
1889
|
-
if ("
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1698
|
+
if ("tool_call_id" in currentMessage) {
|
|
1699
|
+
if (!prevMessage || !("tool_calls" in prevMessage)) {
|
|
1700
|
+
console.warn("No previous tool call, skipping tool call result:", currentMessage.id);
|
|
1701
|
+
continue;
|
|
1893
1702
|
}
|
|
1703
|
+
if (prevMessage.tool_calls && prevMessage.tool_calls[0].id !== currentMessage.tool_call_id) {
|
|
1704
|
+
console.warn("Tool call id is incorrect, skipping tool call result:", currentMessage.id);
|
|
1705
|
+
continue;
|
|
1706
|
+
}
|
|
1707
|
+
correctedMessages.push(currentMessage);
|
|
1708
|
+
continue;
|
|
1894
1709
|
}
|
|
1710
|
+
correctedMessages.push(currentMessage);
|
|
1895
1711
|
}
|
|
1896
|
-
return
|
|
1712
|
+
return {
|
|
1713
|
+
...state,
|
|
1714
|
+
messages: correctedMessages,
|
|
1715
|
+
copilotkit: {
|
|
1716
|
+
actions
|
|
1717
|
+
}
|
|
1718
|
+
};
|
|
1897
1719
|
}
|
|
1898
|
-
__name(
|
|
1899
|
-
function
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
} else if (message.role === "system") {
|
|
1910
|
-
result.push({
|
|
1911
|
-
...message,
|
|
1912
|
-
role: MessageRole.system
|
|
1913
|
-
});
|
|
1914
|
-
} else if (message.role === "assistant") {
|
|
1915
|
-
result.push({
|
|
1916
|
-
...message,
|
|
1917
|
-
role: MessageRole.assistant
|
|
1918
|
-
});
|
|
1919
|
-
}
|
|
1920
|
-
continue;
|
|
1720
|
+
__name(langGraphDefaultMergeState, "langGraphDefaultMergeState");
|
|
1721
|
+
function formatMessages(messages) {
|
|
1722
|
+
return messages.map((message) => {
|
|
1723
|
+
if (message.isTextMessage() && message.role === "assistant") {
|
|
1724
|
+
return message;
|
|
1725
|
+
}
|
|
1726
|
+
if (message.isTextMessage() && message.role === "system") {
|
|
1727
|
+
return message;
|
|
1728
|
+
}
|
|
1729
|
+
if (message.isTextMessage() && message.role === "user") {
|
|
1730
|
+
return message;
|
|
1921
1731
|
}
|
|
1922
1732
|
if (message.isActionExecutionMessage()) {
|
|
1923
|
-
const
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
name: m.name,
|
|
1931
|
-
args: m.arguments,
|
|
1932
|
-
id: m.id
|
|
1933
|
-
}));
|
|
1934
|
-
result.push({
|
|
1935
|
-
id: messageId,
|
|
1936
|
-
type: "ActionExecutionMessage",
|
|
1733
|
+
const toolCall = {
|
|
1734
|
+
name: message.name,
|
|
1735
|
+
args: message.arguments,
|
|
1736
|
+
id: message.id
|
|
1737
|
+
};
|
|
1738
|
+
return {
|
|
1739
|
+
type: message.type,
|
|
1937
1740
|
content: "",
|
|
1938
|
-
tool_calls
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1741
|
+
tool_calls: [
|
|
1742
|
+
toolCall
|
|
1743
|
+
],
|
|
1744
|
+
role: MessageRole.assistant,
|
|
1745
|
+
id: message.id
|
|
1746
|
+
};
|
|
1942
1747
|
}
|
|
1943
1748
|
if (message.isResultMessage()) {
|
|
1944
|
-
|
|
1749
|
+
return {
|
|
1945
1750
|
type: message.type,
|
|
1946
1751
|
content: message.result,
|
|
1947
1752
|
id: message.id,
|
|
1948
1753
|
tool_call_id: message.actionExecutionId,
|
|
1949
1754
|
name: message.actionName,
|
|
1950
1755
|
role: MessageRole.tool
|
|
1951
|
-
}
|
|
1952
|
-
continue;
|
|
1756
|
+
};
|
|
1953
1757
|
}
|
|
1954
1758
|
throw new Error(`Unknown message type ${message.type}`);
|
|
1955
|
-
}
|
|
1956
|
-
return result;
|
|
1759
|
+
});
|
|
1957
1760
|
}
|
|
1958
|
-
__name(
|
|
1761
|
+
__name(formatMessages, "formatMessages");
|
|
1959
1762
|
|
|
1960
1763
|
// src/lib/runtime/remote-action-constructors.ts
|
|
1961
1764
|
function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, messages, agentStates }) {
|
|
@@ -1965,7 +1768,7 @@ function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, m
|
|
|
1965
1768
|
parameters: [],
|
|
1966
1769
|
handler: async (_args) => {
|
|
1967
1770
|
},
|
|
1968
|
-
langGraphAgentHandler: async ({ name, actionInputsWithoutAgents, threadId, nodeName
|
|
1771
|
+
langGraphAgentHandler: async ({ name, actionInputsWithoutAgents, threadId, nodeName }) => {
|
|
1969
1772
|
var _a;
|
|
1970
1773
|
logger2.debug({
|
|
1971
1774
|
actionName: agent.name
|
|
@@ -1991,10 +1794,7 @@ function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, m
|
|
|
1991
1794
|
agent,
|
|
1992
1795
|
threadId,
|
|
1993
1796
|
nodeName,
|
|
1994
|
-
messages
|
|
1995
|
-
...messages,
|
|
1996
|
-
...additionalMessages
|
|
1997
|
-
],
|
|
1797
|
+
messages,
|
|
1998
1798
|
state,
|
|
1999
1799
|
properties: graphqlContext.properties,
|
|
2000
1800
|
actions: actionInputsWithoutAgents.map((action) => ({
|
|
@@ -2022,7 +1822,6 @@ function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, m
|
|
|
2022
1822
|
}
|
|
2023
1823
|
__name(constructLGCRemoteAction, "constructLGCRemoteAction");
|
|
2024
1824
|
function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, logger: logger2, messages, agentStates }) {
|
|
2025
|
-
const totalAgents = Array.isArray(json["agents"]) ? json["agents"].length : 0;
|
|
2026
1825
|
const actions = json["actions"].map((action) => ({
|
|
2027
1826
|
name: action.name,
|
|
2028
1827
|
description: action.description,
|
|
@@ -2036,7 +1835,7 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
|
|
|
2036
1835
|
telemetry_client_default.capture("oss.runtime.remote_action_executed", {
|
|
2037
1836
|
agentExecution: false,
|
|
2038
1837
|
type: "self-hosted",
|
|
2039
|
-
agentsAmount:
|
|
1838
|
+
agentsAmount: json["agents"].length
|
|
2040
1839
|
});
|
|
2041
1840
|
try {
|
|
2042
1841
|
const response = await fetch(`${url}/actions/execute`, {
|
|
@@ -2071,13 +1870,13 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
|
|
|
2071
1870
|
}
|
|
2072
1871
|
}
|
|
2073
1872
|
}));
|
|
2074
|
-
const agents =
|
|
1873
|
+
const agents = json["agents"].map((agent) => ({
|
|
2075
1874
|
name: agent.name,
|
|
2076
1875
|
description: agent.description,
|
|
2077
1876
|
parameters: [],
|
|
2078
1877
|
handler: async (_args) => {
|
|
2079
1878
|
},
|
|
2080
|
-
langGraphAgentHandler: async ({ name, actionInputsWithoutAgents, threadId, nodeName
|
|
1879
|
+
langGraphAgentHandler: async ({ name, actionInputsWithoutAgents, threadId, nodeName }) => {
|
|
2081
1880
|
var _a;
|
|
2082
1881
|
logger2.debug({
|
|
2083
1882
|
actionName: agent.name
|
|
@@ -2102,10 +1901,7 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
|
|
|
2102
1901
|
name,
|
|
2103
1902
|
threadId,
|
|
2104
1903
|
nodeName,
|
|
2105
|
-
messages
|
|
2106
|
-
...messages,
|
|
2107
|
-
...additionalMessages
|
|
2108
|
-
],
|
|
1904
|
+
messages,
|
|
2109
1905
|
state,
|
|
2110
1906
|
properties: graphqlContext.properties,
|
|
2111
1907
|
actions: actionInputsWithoutAgents.map((action) => ({
|
|
@@ -2127,7 +1923,7 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
|
|
|
2127
1923
|
streamResponse(response.body, eventSource.eventStream$);
|
|
2128
1924
|
return eventSource.processLangGraphEvents();
|
|
2129
1925
|
}
|
|
2130
|
-
}))
|
|
1926
|
+
}));
|
|
2131
1927
|
return [
|
|
2132
1928
|
...actions,
|
|
2133
1929
|
...agents
|
|
@@ -2348,94 +2144,7 @@ function getRuntimeInstanceTelemetryInfo(runtime) {
|
|
|
2348
2144
|
__name(getRuntimeInstanceTelemetryInfo, "getRuntimeInstanceTelemetryInfo");
|
|
2349
2145
|
var telemetry_client_default = telemetryClient;
|
|
2350
2146
|
|
|
2351
|
-
// src/graphql/types/base/index.ts
|
|
2352
|
-
var import_type_graphql2 = require("type-graphql");
|
|
2353
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
2354
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2355
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2356
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
2357
|
-
else
|
|
2358
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
2359
|
-
if (d = decorators[i])
|
|
2360
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2361
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2362
|
-
}
|
|
2363
|
-
__name(_ts_decorate, "_ts_decorate");
|
|
2364
|
-
function _ts_metadata(k, v) {
|
|
2365
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
2366
|
-
return Reflect.metadata(k, v);
|
|
2367
|
-
}
|
|
2368
|
-
__name(_ts_metadata, "_ts_metadata");
|
|
2369
|
-
var BaseMessageInput = class {
|
|
2370
|
-
id;
|
|
2371
|
-
createdAt;
|
|
2372
|
-
};
|
|
2373
|
-
__name(BaseMessageInput, "BaseMessageInput");
|
|
2374
|
-
_ts_decorate([
|
|
2375
|
-
(0, import_type_graphql2.Field)(() => String),
|
|
2376
|
-
_ts_metadata("design:type", String)
|
|
2377
|
-
], BaseMessageInput.prototype, "id", void 0);
|
|
2378
|
-
_ts_decorate([
|
|
2379
|
-
(0, import_type_graphql2.Field)(() => Date),
|
|
2380
|
-
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
2381
|
-
], BaseMessageInput.prototype, "createdAt", void 0);
|
|
2382
|
-
BaseMessageInput = _ts_decorate([
|
|
2383
|
-
(0, import_type_graphql2.InputType)()
|
|
2384
|
-
], BaseMessageInput);
|
|
2385
|
-
|
|
2386
|
-
// src/graphql/types/converted/index.ts
|
|
2387
|
-
var Message = class extends BaseMessageInput {
|
|
2388
|
-
type;
|
|
2389
|
-
isTextMessage() {
|
|
2390
|
-
return this.type === "TextMessage";
|
|
2391
|
-
}
|
|
2392
|
-
isActionExecutionMessage() {
|
|
2393
|
-
return this.type === "ActionExecutionMessage";
|
|
2394
|
-
}
|
|
2395
|
-
isResultMessage() {
|
|
2396
|
-
return this.type === "ResultMessage";
|
|
2397
|
-
}
|
|
2398
|
-
isAgentStateMessage() {
|
|
2399
|
-
return this.type === "AgentStateMessage";
|
|
2400
|
-
}
|
|
2401
|
-
};
|
|
2402
|
-
__name(Message, "Message");
|
|
2403
|
-
var TextMessage = class extends Message {
|
|
2404
|
-
type = "TextMessage";
|
|
2405
|
-
content;
|
|
2406
|
-
role;
|
|
2407
|
-
parentMessageId;
|
|
2408
|
-
};
|
|
2409
|
-
__name(TextMessage, "TextMessage");
|
|
2410
|
-
var ActionExecutionMessage = class extends Message {
|
|
2411
|
-
type = "ActionExecutionMessage";
|
|
2412
|
-
name;
|
|
2413
|
-
arguments;
|
|
2414
|
-
parentMessageId;
|
|
2415
|
-
};
|
|
2416
|
-
__name(ActionExecutionMessage, "ActionExecutionMessage");
|
|
2417
|
-
var ResultMessage = class extends Message {
|
|
2418
|
-
type = "ResultMessage";
|
|
2419
|
-
actionExecutionId;
|
|
2420
|
-
actionName;
|
|
2421
|
-
result;
|
|
2422
|
-
};
|
|
2423
|
-
__name(ResultMessage, "ResultMessage");
|
|
2424
|
-
var AgentStateMessage = class extends Message {
|
|
2425
|
-
type = "AgentStateMessage";
|
|
2426
|
-
threadId;
|
|
2427
|
-
agentName;
|
|
2428
|
-
nodeName;
|
|
2429
|
-
runId;
|
|
2430
|
-
active;
|
|
2431
|
-
role;
|
|
2432
|
-
state;
|
|
2433
|
-
running;
|
|
2434
|
-
};
|
|
2435
|
-
__name(AgentStateMessage, "AgentStateMessage");
|
|
2436
|
-
|
|
2437
2147
|
// src/service-adapters/events.ts
|
|
2438
|
-
var import_class_transformer = require("class-transformer");
|
|
2439
2148
|
var RuntimeEventTypes;
|
|
2440
2149
|
(function(RuntimeEventTypes2) {
|
|
2441
2150
|
RuntimeEventTypes2["TextMessageStart"] = "TextMessageStart";
|
|
@@ -2451,74 +2160,52 @@ var RuntimeEventSubject = class extends import_rxjs2.ReplaySubject {
|
|
|
2451
2160
|
constructor() {
|
|
2452
2161
|
super();
|
|
2453
2162
|
}
|
|
2454
|
-
sendTextMessageStart(
|
|
2163
|
+
sendTextMessageStart(messageId) {
|
|
2455
2164
|
this.next({
|
|
2456
2165
|
type: "TextMessageStart",
|
|
2457
|
-
messageId
|
|
2458
|
-
parentMessageId
|
|
2166
|
+
messageId
|
|
2459
2167
|
});
|
|
2460
2168
|
}
|
|
2461
|
-
sendTextMessageContent(
|
|
2169
|
+
sendTextMessageContent(content) {
|
|
2462
2170
|
this.next({
|
|
2463
2171
|
type: "TextMessageContent",
|
|
2464
|
-
content
|
|
2465
|
-
messageId
|
|
2172
|
+
content
|
|
2466
2173
|
});
|
|
2467
2174
|
}
|
|
2468
|
-
sendTextMessageEnd(
|
|
2175
|
+
sendTextMessageEnd() {
|
|
2469
2176
|
this.next({
|
|
2470
|
-
type: "TextMessageEnd"
|
|
2471
|
-
messageId
|
|
2177
|
+
type: "TextMessageEnd"
|
|
2472
2178
|
});
|
|
2473
2179
|
}
|
|
2474
2180
|
sendTextMessage(messageId, content) {
|
|
2475
|
-
this.sendTextMessageStart(
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
this.sendTextMessageContent({
|
|
2479
|
-
messageId,
|
|
2480
|
-
content
|
|
2481
|
-
});
|
|
2482
|
-
this.sendTextMessageEnd({
|
|
2483
|
-
messageId
|
|
2484
|
-
});
|
|
2181
|
+
this.sendTextMessageStart(messageId);
|
|
2182
|
+
this.sendTextMessageContent(content);
|
|
2183
|
+
this.sendTextMessageEnd();
|
|
2485
2184
|
}
|
|
2486
|
-
sendActionExecutionStart(
|
|
2185
|
+
sendActionExecutionStart(actionExecutionId, actionName) {
|
|
2487
2186
|
this.next({
|
|
2488
2187
|
type: "ActionExecutionStart",
|
|
2489
2188
|
actionExecutionId,
|
|
2490
|
-
actionName
|
|
2491
|
-
parentMessageId
|
|
2189
|
+
actionName
|
|
2492
2190
|
});
|
|
2493
2191
|
}
|
|
2494
|
-
sendActionExecutionArgs(
|
|
2192
|
+
sendActionExecutionArgs(args) {
|
|
2495
2193
|
this.next({
|
|
2496
2194
|
type: "ActionExecutionArgs",
|
|
2497
|
-
args
|
|
2498
|
-
actionExecutionId
|
|
2195
|
+
args
|
|
2499
2196
|
});
|
|
2500
2197
|
}
|
|
2501
|
-
sendActionExecutionEnd(
|
|
2198
|
+
sendActionExecutionEnd() {
|
|
2502
2199
|
this.next({
|
|
2503
|
-
type: "ActionExecutionEnd"
|
|
2504
|
-
actionExecutionId
|
|
2200
|
+
type: "ActionExecutionEnd"
|
|
2505
2201
|
});
|
|
2506
2202
|
}
|
|
2507
|
-
sendActionExecution(
|
|
2508
|
-
this.sendActionExecutionStart(
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
parentMessageId
|
|
2512
|
-
});
|
|
2513
|
-
this.sendActionExecutionArgs({
|
|
2514
|
-
actionExecutionId,
|
|
2515
|
-
args
|
|
2516
|
-
});
|
|
2517
|
-
this.sendActionExecutionEnd({
|
|
2518
|
-
actionExecutionId
|
|
2519
|
-
});
|
|
2203
|
+
sendActionExecution(actionExecutionId, toolName, args) {
|
|
2204
|
+
this.sendActionExecutionStart(actionExecutionId, toolName);
|
|
2205
|
+
this.sendActionExecutionArgs(args);
|
|
2206
|
+
this.sendActionExecutionEnd();
|
|
2520
2207
|
}
|
|
2521
|
-
sendActionExecutionResult(
|
|
2208
|
+
sendActionExecutionResult(actionExecutionId, actionName, result) {
|
|
2522
2209
|
this.next({
|
|
2523
2210
|
type: "ActionExecutionResult",
|
|
2524
2211
|
actionName,
|
|
@@ -2526,7 +2213,7 @@ var RuntimeEventSubject = class extends import_rxjs2.ReplaySubject {
|
|
|
2526
2213
|
result
|
|
2527
2214
|
});
|
|
2528
2215
|
}
|
|
2529
|
-
sendAgentStateMessage(
|
|
2216
|
+
sendAgentStateMessage(threadId, agentName, nodeName, runId, active, role, state, running) {
|
|
2530
2217
|
this.next({
|
|
2531
2218
|
type: "AgentStateMessage",
|
|
2532
2219
|
threadId,
|
|
@@ -2547,8 +2234,8 @@ var RuntimeEventSource = class {
|
|
|
2547
2234
|
async stream(callback) {
|
|
2548
2235
|
this.callback = callback;
|
|
2549
2236
|
}
|
|
2550
|
-
sendErrorMessageToChat(
|
|
2551
|
-
const errorMessage =
|
|
2237
|
+
sendErrorMessageToChat() {
|
|
2238
|
+
const errorMessage = "\u274C An error occurred. Please try again.";
|
|
2552
2239
|
if (!this.callback) {
|
|
2553
2240
|
this.stream(async (eventStream$) => {
|
|
2554
2241
|
eventStream$.sendTextMessage((0, import_shared8.randomId)(), errorMessage);
|
|
@@ -2563,19 +2250,27 @@ var RuntimeEventSource = class {
|
|
|
2563
2250
|
this.sendErrorMessageToChat();
|
|
2564
2251
|
});
|
|
2565
2252
|
return this.eventStream$.pipe(
|
|
2253
|
+
// mark tools for server side execution
|
|
2254
|
+
(0, import_rxjs2.map)((event) => {
|
|
2255
|
+
if (event.type === "ActionExecutionStart") {
|
|
2256
|
+
if (event.scope !== "passThrough") {
|
|
2257
|
+
event.scope = serverSideActions.find((action) => action.name === event.actionName) ? "server" : "client";
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
return event;
|
|
2261
|
+
}),
|
|
2566
2262
|
// track state
|
|
2567
2263
|
(0, import_rxjs2.scan)((acc, event) => {
|
|
2568
2264
|
acc = {
|
|
2569
2265
|
...acc
|
|
2570
2266
|
};
|
|
2571
2267
|
if (event.type === "ActionExecutionStart") {
|
|
2572
|
-
acc.callActionServerSide =
|
|
2268
|
+
acc.callActionServerSide = event.scope === "server";
|
|
2573
2269
|
acc.args = "";
|
|
2574
2270
|
acc.actionExecutionId = event.actionExecutionId;
|
|
2575
2271
|
if (acc.callActionServerSide) {
|
|
2576
2272
|
acc.action = serverSideActions.find((action) => action.name === event.actionName);
|
|
2577
2273
|
}
|
|
2578
|
-
acc.actionExecutionParentMessageId = event.parentMessageId;
|
|
2579
2274
|
} else if (event.type === "ActionExecutionArgs") {
|
|
2580
2275
|
acc.args += event.args;
|
|
2581
2276
|
}
|
|
@@ -2586,13 +2281,12 @@ var RuntimeEventSource = class {
|
|
|
2586
2281
|
callActionServerSide: false,
|
|
2587
2282
|
args: "",
|
|
2588
2283
|
actionExecutionId: null,
|
|
2589
|
-
action: null
|
|
2590
|
-
actionExecutionParentMessageId: null
|
|
2284
|
+
action: null
|
|
2591
2285
|
}),
|
|
2592
2286
|
(0, import_rxjs2.concatMap)((eventWithState) => {
|
|
2593
2287
|
if (eventWithState.event.type === "ActionExecutionEnd" && eventWithState.callActionServerSide) {
|
|
2594
2288
|
const toolCallEventStream$ = new RuntimeEventSubject();
|
|
2595
|
-
executeAction(toolCallEventStream$, guardrailsResult$ ? guardrailsResult$ : null, eventWithState.action, eventWithState.args, eventWithState.
|
|
2289
|
+
executeAction(toolCallEventStream$, guardrailsResult$ ? guardrailsResult$ : null, eventWithState.action, eventWithState.args, eventWithState.actionExecutionId, actionInputsWithoutAgents).catch((error) => {
|
|
2596
2290
|
console.error(error);
|
|
2597
2291
|
});
|
|
2598
2292
|
telemetry_client_default.capture("oss.runtime.server_action_executed", {});
|
|
@@ -2605,7 +2299,7 @@ var RuntimeEventSource = class {
|
|
|
2605
2299
|
}
|
|
2606
2300
|
};
|
|
2607
2301
|
__name(RuntimeEventSource, "RuntimeEventSource");
|
|
2608
|
-
async function executeAction(eventStream$, guardrailsResult$, action, actionArguments,
|
|
2302
|
+
async function executeAction(eventStream$, guardrailsResult$, action, actionArguments, actionExecutionId, actionInputsWithoutAgents) {
|
|
2609
2303
|
var _a;
|
|
2610
2304
|
if (guardrailsResult$) {
|
|
2611
2305
|
const { status } = await (0, import_rxjs2.firstValueFrom)(guardrailsResult$);
|
|
@@ -2625,33 +2319,10 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
|
|
|
2625
2319
|
}
|
|
2626
2320
|
}
|
|
2627
2321
|
if (isLangGraphAgentAction(action)) {
|
|
2628
|
-
|
|
2629
|
-
const agentExecution = (0, import_class_transformer.plainToInstance)(ActionExecutionMessage, {
|
|
2630
|
-
id: actionExecutionId,
|
|
2631
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
2632
|
-
name: action.name,
|
|
2633
|
-
arguments: JSON.parse(actionArguments),
|
|
2634
|
-
parentMessageId: actionExecutionParentMessageId ?? actionExecutionId
|
|
2635
|
-
});
|
|
2636
|
-
const agentExecutionResult = (0, import_class_transformer.plainToInstance)(ResultMessage, {
|
|
2637
|
-
id: "result-" + actionExecutionId,
|
|
2638
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
2639
|
-
actionExecutionId,
|
|
2640
|
-
actionName: action.name,
|
|
2641
|
-
result
|
|
2642
|
-
});
|
|
2643
|
-
eventStream$.sendActionExecutionResult({
|
|
2644
|
-
actionExecutionId,
|
|
2645
|
-
actionName: action.name,
|
|
2646
|
-
result
|
|
2647
|
-
});
|
|
2322
|
+
eventStream$.sendActionExecutionResult(actionExecutionId, action.name, `${action.name} agent started`);
|
|
2648
2323
|
const stream = await action.langGraphAgentHandler({
|
|
2649
2324
|
name: action.name,
|
|
2650
|
-
actionInputsWithoutAgents
|
|
2651
|
-
additionalMessages: [
|
|
2652
|
-
agentExecution,
|
|
2653
|
-
agentExecutionResult
|
|
2654
|
-
]
|
|
2325
|
+
actionInputsWithoutAgents
|
|
2655
2326
|
});
|
|
2656
2327
|
(0, import_rxjs2.from)(stream).subscribe({
|
|
2657
2328
|
next: (event) => eventStream$.next(event),
|
|
@@ -2672,29 +2343,113 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
|
|
|
2672
2343
|
}
|
|
2673
2344
|
__name(executeAction, "executeAction");
|
|
2674
2345
|
|
|
2346
|
+
// src/graphql/types/base/index.ts
|
|
2347
|
+
var import_type_graphql2 = require("type-graphql");
|
|
2348
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
2349
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2350
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2351
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2352
|
+
else
|
|
2353
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
2354
|
+
if (d = decorators[i])
|
|
2355
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2356
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2357
|
+
}
|
|
2358
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
2359
|
+
function _ts_metadata(k, v) {
|
|
2360
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
2361
|
+
return Reflect.metadata(k, v);
|
|
2362
|
+
}
|
|
2363
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
2364
|
+
var BaseMessageInput = class {
|
|
2365
|
+
id;
|
|
2366
|
+
createdAt;
|
|
2367
|
+
};
|
|
2368
|
+
__name(BaseMessageInput, "BaseMessageInput");
|
|
2369
|
+
_ts_decorate([
|
|
2370
|
+
(0, import_type_graphql2.Field)(() => String),
|
|
2371
|
+
_ts_metadata("design:type", String)
|
|
2372
|
+
], BaseMessageInput.prototype, "id", void 0);
|
|
2373
|
+
_ts_decorate([
|
|
2374
|
+
(0, import_type_graphql2.Field)(() => Date),
|
|
2375
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
2376
|
+
], BaseMessageInput.prototype, "createdAt", void 0);
|
|
2377
|
+
BaseMessageInput = _ts_decorate([
|
|
2378
|
+
(0, import_type_graphql2.InputType)()
|
|
2379
|
+
], BaseMessageInput);
|
|
2380
|
+
|
|
2381
|
+
// src/graphql/types/converted/index.ts
|
|
2382
|
+
var Message = class extends BaseMessageInput {
|
|
2383
|
+
type;
|
|
2384
|
+
isTextMessage() {
|
|
2385
|
+
return this.type === "TextMessage";
|
|
2386
|
+
}
|
|
2387
|
+
isActionExecutionMessage() {
|
|
2388
|
+
return this.type === "ActionExecutionMessage";
|
|
2389
|
+
}
|
|
2390
|
+
isResultMessage() {
|
|
2391
|
+
return this.type === "ResultMessage";
|
|
2392
|
+
}
|
|
2393
|
+
isAgentStateMessage() {
|
|
2394
|
+
return this.type === "AgentStateMessage";
|
|
2395
|
+
}
|
|
2396
|
+
};
|
|
2397
|
+
__name(Message, "Message");
|
|
2398
|
+
var TextMessage = class extends Message {
|
|
2399
|
+
type = "TextMessage";
|
|
2400
|
+
content;
|
|
2401
|
+
role;
|
|
2402
|
+
};
|
|
2403
|
+
__name(TextMessage, "TextMessage");
|
|
2404
|
+
var ActionExecutionMessage = class extends Message {
|
|
2405
|
+
type = "ActionExecutionMessage";
|
|
2406
|
+
name;
|
|
2407
|
+
arguments;
|
|
2408
|
+
scope;
|
|
2409
|
+
};
|
|
2410
|
+
__name(ActionExecutionMessage, "ActionExecutionMessage");
|
|
2411
|
+
var ResultMessage = class extends Message {
|
|
2412
|
+
type = "ResultMessage";
|
|
2413
|
+
actionExecutionId;
|
|
2414
|
+
actionName;
|
|
2415
|
+
result;
|
|
2416
|
+
};
|
|
2417
|
+
__name(ResultMessage, "ResultMessage");
|
|
2418
|
+
var AgentStateMessage = class extends Message {
|
|
2419
|
+
type = "AgentStateMessage";
|
|
2420
|
+
threadId;
|
|
2421
|
+
agentName;
|
|
2422
|
+
nodeName;
|
|
2423
|
+
runId;
|
|
2424
|
+
active;
|
|
2425
|
+
role;
|
|
2426
|
+
state;
|
|
2427
|
+
running;
|
|
2428
|
+
};
|
|
2429
|
+
__name(AgentStateMessage, "AgentStateMessage");
|
|
2430
|
+
|
|
2675
2431
|
// src/service-adapters/conversion.ts
|
|
2676
|
-
var
|
|
2432
|
+
var import_class_transformer = require("class-transformer");
|
|
2677
2433
|
function convertGqlInputToMessages(inputMessages) {
|
|
2678
2434
|
const messages = [];
|
|
2679
2435
|
for (const message of inputMessages) {
|
|
2680
2436
|
if (message.textMessage) {
|
|
2681
|
-
messages.push((0,
|
|
2437
|
+
messages.push((0, import_class_transformer.plainToInstance)(TextMessage, {
|
|
2682
2438
|
id: message.id,
|
|
2683
2439
|
createdAt: message.createdAt,
|
|
2684
2440
|
role: message.textMessage.role,
|
|
2685
|
-
content: message.textMessage.content
|
|
2686
|
-
parentMessageId: message.textMessage.parentMessageId
|
|
2441
|
+
content: message.textMessage.content
|
|
2687
2442
|
}));
|
|
2688
2443
|
} else if (message.actionExecutionMessage) {
|
|
2689
|
-
messages.push((0,
|
|
2444
|
+
messages.push((0, import_class_transformer.plainToInstance)(ActionExecutionMessage, {
|
|
2690
2445
|
id: message.id,
|
|
2691
2446
|
createdAt: message.createdAt,
|
|
2692
2447
|
name: message.actionExecutionMessage.name,
|
|
2693
2448
|
arguments: JSON.parse(message.actionExecutionMessage.arguments),
|
|
2694
|
-
|
|
2449
|
+
scope: message.actionExecutionMessage.scope
|
|
2695
2450
|
}));
|
|
2696
2451
|
} else if (message.resultMessage) {
|
|
2697
|
-
messages.push((0,
|
|
2452
|
+
messages.push((0, import_class_transformer.plainToInstance)(ResultMessage, {
|
|
2698
2453
|
id: message.id,
|
|
2699
2454
|
createdAt: message.createdAt,
|
|
2700
2455
|
actionExecutionId: message.resultMessage.actionExecutionId,
|
|
@@ -2702,7 +2457,7 @@ function convertGqlInputToMessages(inputMessages) {
|
|
|
2702
2457
|
result: message.resultMessage.result
|
|
2703
2458
|
}));
|
|
2704
2459
|
} else if (message.agentStateMessage) {
|
|
2705
|
-
messages.push((0,
|
|
2460
|
+
messages.push((0, import_class_transformer.plainToInstance)(AgentStateMessage, {
|
|
2706
2461
|
id: message.id,
|
|
2707
2462
|
threadId: message.agentStateMessage.threadId,
|
|
2708
2463
|
createdAt: message.createdAt,
|
|
@@ -2802,7 +2557,13 @@ var CopilotRuntime = class {
|
|
|
2802
2557
|
} catch (error) {
|
|
2803
2558
|
console.error("Error getting response:", error);
|
|
2804
2559
|
eventSource.sendErrorMessageToChat();
|
|
2805
|
-
|
|
2560
|
+
return {
|
|
2561
|
+
threadId: threadId || (0, import_shared9.randomId)(),
|
|
2562
|
+
runId: runId || (0, import_shared9.randomId)(),
|
|
2563
|
+
eventSource,
|
|
2564
|
+
serverSideActions: [],
|
|
2565
|
+
actionInputsWithoutAgents: []
|
|
2566
|
+
};
|
|
2806
2567
|
}
|
|
2807
2568
|
}
|
|
2808
2569
|
async processAgentRequest(request) {
|
|
@@ -3005,7 +2766,6 @@ MessageInput = _ts_decorate2([
|
|
|
3005
2766
|
], MessageInput);
|
|
3006
2767
|
var TextMessageInput = class {
|
|
3007
2768
|
content;
|
|
3008
|
-
parentMessageId;
|
|
3009
2769
|
role;
|
|
3010
2770
|
};
|
|
3011
2771
|
__name(TextMessageInput, "TextMessageInput");
|
|
@@ -3013,12 +2773,6 @@ _ts_decorate2([
|
|
|
3013
2773
|
(0, import_type_graphql3.Field)(() => String),
|
|
3014
2774
|
_ts_metadata2("design:type", String)
|
|
3015
2775
|
], TextMessageInput.prototype, "content", void 0);
|
|
3016
|
-
_ts_decorate2([
|
|
3017
|
-
(0, import_type_graphql3.Field)(() => String, {
|
|
3018
|
-
nullable: true
|
|
3019
|
-
}),
|
|
3020
|
-
_ts_metadata2("design:type", String)
|
|
3021
|
-
], TextMessageInput.prototype, "parentMessageId", void 0);
|
|
3022
2776
|
_ts_decorate2([
|
|
3023
2777
|
(0, import_type_graphql3.Field)(() => MessageRole),
|
|
3024
2778
|
_ts_metadata2("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
|
|
@@ -3029,7 +2783,6 @@ TextMessageInput = _ts_decorate2([
|
|
|
3029
2783
|
var ActionExecutionMessageInput = class {
|
|
3030
2784
|
name;
|
|
3031
2785
|
arguments;
|
|
3032
|
-
parentMessageId;
|
|
3033
2786
|
scope;
|
|
3034
2787
|
};
|
|
3035
2788
|
__name(ActionExecutionMessageInput, "ActionExecutionMessageInput");
|
|
@@ -3042,17 +2795,8 @@ _ts_decorate2([
|
|
|
3042
2795
|
_ts_metadata2("design:type", String)
|
|
3043
2796
|
], ActionExecutionMessageInput.prototype, "arguments", void 0);
|
|
3044
2797
|
_ts_decorate2([
|
|
3045
|
-
(0, import_type_graphql3.Field)(() =>
|
|
3046
|
-
|
|
3047
|
-
}),
|
|
3048
|
-
_ts_metadata2("design:type", String)
|
|
3049
|
-
], ActionExecutionMessageInput.prototype, "parentMessageId", void 0);
|
|
3050
|
-
_ts_decorate2([
|
|
3051
|
-
(0, import_type_graphql3.Field)(() => String, {
|
|
3052
|
-
nullable: true,
|
|
3053
|
-
deprecationReason: "This field will be removed in a future version"
|
|
3054
|
-
}),
|
|
3055
|
-
_ts_metadata2("design:type", typeof String === "undefined" ? Object : String)
|
|
2798
|
+
(0, import_type_graphql3.Field)(() => ActionExecutionScope),
|
|
2799
|
+
_ts_metadata2("design:type", typeof ActionExecutionScope === "undefined" ? Object : ActionExecutionScope)
|
|
3056
2800
|
], ActionExecutionMessageInput.prototype, "scope", void 0);
|
|
3057
2801
|
ActionExecutionMessageInput = _ts_decorate2([
|
|
3058
2802
|
(0, import_type_graphql3.InputType)()
|
|
@@ -3060,7 +2804,6 @@ ActionExecutionMessageInput = _ts_decorate2([
|
|
|
3060
2804
|
var ResultMessageInput = class {
|
|
3061
2805
|
actionExecutionId;
|
|
3062
2806
|
actionName;
|
|
3063
|
-
parentMessageId;
|
|
3064
2807
|
result;
|
|
3065
2808
|
};
|
|
3066
2809
|
__name(ResultMessageInput, "ResultMessageInput");
|
|
@@ -3072,12 +2815,6 @@ _ts_decorate2([
|
|
|
3072
2815
|
(0, import_type_graphql3.Field)(() => String),
|
|
3073
2816
|
_ts_metadata2("design:type", String)
|
|
3074
2817
|
], ResultMessageInput.prototype, "actionName", void 0);
|
|
3075
|
-
_ts_decorate2([
|
|
3076
|
-
(0, import_type_graphql3.Field)(() => String, {
|
|
3077
|
-
nullable: true
|
|
3078
|
-
}),
|
|
3079
|
-
_ts_metadata2("design:type", String)
|
|
3080
|
-
], ResultMessageInput.prototype, "parentMessageId", void 0);
|
|
3081
2818
|
_ts_decorate2([
|
|
3082
2819
|
(0, import_type_graphql3.Field)(() => String),
|
|
3083
2820
|
_ts_metadata2("design:type", String)
|
|
@@ -3341,7 +3078,6 @@ var ForwardedParametersInput = class {
|
|
|
3341
3078
|
stop;
|
|
3342
3079
|
toolChoice;
|
|
3343
3080
|
toolChoiceFunctionName;
|
|
3344
|
-
temperature;
|
|
3345
3081
|
};
|
|
3346
3082
|
__name(ForwardedParametersInput, "ForwardedParametersInput");
|
|
3347
3083
|
_ts_decorate7([
|
|
@@ -3376,12 +3112,6 @@ _ts_decorate7([
|
|
|
3376
3112
|
}),
|
|
3377
3113
|
_ts_metadata7("design:type", String)
|
|
3378
3114
|
], ForwardedParametersInput.prototype, "toolChoiceFunctionName", void 0);
|
|
3379
|
-
_ts_decorate7([
|
|
3380
|
-
(0, import_type_graphql8.Field)(() => Number, {
|
|
3381
|
-
nullable: true
|
|
3382
|
-
}),
|
|
3383
|
-
_ts_metadata7("design:type", Number)
|
|
3384
|
-
], ForwardedParametersInput.prototype, "temperature", void 0);
|
|
3385
3115
|
ForwardedParametersInput = _ts_decorate7([
|
|
3386
3116
|
(0, import_type_graphql8.InputType)()
|
|
3387
3117
|
], ForwardedParametersInput);
|
|
@@ -3807,7 +3537,6 @@ BaseMessageOutput = _ts_decorate13([
|
|
|
3807
3537
|
var TextMessageOutput = class {
|
|
3808
3538
|
role;
|
|
3809
3539
|
content;
|
|
3810
|
-
parentMessageId;
|
|
3811
3540
|
};
|
|
3812
3541
|
__name(TextMessageOutput, "TextMessageOutput");
|
|
3813
3542
|
_ts_decorate13([
|
|
@@ -3820,12 +3549,6 @@ _ts_decorate13([
|
|
|
3820
3549
|
]),
|
|
3821
3550
|
_ts_metadata13("design:type", Array)
|
|
3822
3551
|
], TextMessageOutput.prototype, "content", void 0);
|
|
3823
|
-
_ts_decorate13([
|
|
3824
|
-
(0, import_type_graphql14.Field)(() => String, {
|
|
3825
|
-
nullable: true
|
|
3826
|
-
}),
|
|
3827
|
-
_ts_metadata13("design:type", String)
|
|
3828
|
-
], TextMessageOutput.prototype, "parentMessageId", void 0);
|
|
3829
3552
|
TextMessageOutput = _ts_decorate13([
|
|
3830
3553
|
(0, import_type_graphql14.ObjectType)({
|
|
3831
3554
|
implements: BaseMessageOutput
|
|
@@ -3835,7 +3558,6 @@ var ActionExecutionMessageOutput = class {
|
|
|
3835
3558
|
name;
|
|
3836
3559
|
scope;
|
|
3837
3560
|
arguments;
|
|
3838
|
-
parentMessageId;
|
|
3839
3561
|
};
|
|
3840
3562
|
__name(ActionExecutionMessageOutput, "ActionExecutionMessageOutput");
|
|
3841
3563
|
_ts_decorate13([
|
|
@@ -3843,11 +3565,8 @@ _ts_decorate13([
|
|
|
3843
3565
|
_ts_metadata13("design:type", String)
|
|
3844
3566
|
], ActionExecutionMessageOutput.prototype, "name", void 0);
|
|
3845
3567
|
_ts_decorate13([
|
|
3846
|
-
(0, import_type_graphql14.Field)(() =>
|
|
3847
|
-
|
|
3848
|
-
deprecationReason: "This field will be removed in a future version"
|
|
3849
|
-
}),
|
|
3850
|
-
_ts_metadata13("design:type", String)
|
|
3568
|
+
(0, import_type_graphql14.Field)(() => ActionExecutionScope),
|
|
3569
|
+
_ts_metadata13("design:type", typeof ActionExecutionScope === "undefined" ? Object : ActionExecutionScope)
|
|
3851
3570
|
], ActionExecutionMessageOutput.prototype, "scope", void 0);
|
|
3852
3571
|
_ts_decorate13([
|
|
3853
3572
|
(0, import_type_graphql14.Field)(() => [
|
|
@@ -3855,12 +3574,6 @@ _ts_decorate13([
|
|
|
3855
3574
|
]),
|
|
3856
3575
|
_ts_metadata13("design:type", Array)
|
|
3857
3576
|
], ActionExecutionMessageOutput.prototype, "arguments", void 0);
|
|
3858
|
-
_ts_decorate13([
|
|
3859
|
-
(0, import_type_graphql14.Field)(() => String, {
|
|
3860
|
-
nullable: true
|
|
3861
|
-
}),
|
|
3862
|
-
_ts_metadata13("design:type", String)
|
|
3863
|
-
], ActionExecutionMessageOutput.prototype, "parentMessageId", void 0);
|
|
3864
3577
|
ActionExecutionMessageOutput = _ts_decorate13([
|
|
3865
3578
|
(0, import_type_graphql14.ObjectType)({
|
|
3866
3579
|
implements: BaseMessageOutput
|
|
@@ -3971,7 +3684,7 @@ CopilotResponse = _ts_decorate13([
|
|
|
3971
3684
|
// src/graphql/resolvers/copilot.resolver.ts
|
|
3972
3685
|
var import_graphql_yoga = require("graphql-yoga");
|
|
3973
3686
|
var import_graphql_scalars2 = require("graphql-scalars");
|
|
3974
|
-
var
|
|
3687
|
+
var import_class_transformer2 = require("class-transformer");
|
|
3975
3688
|
var import_graphql = require("graphql");
|
|
3976
3689
|
|
|
3977
3690
|
// src/utils/failed-response-status-reasons.ts
|
|
@@ -4169,7 +3882,7 @@ var CopilotResolver = class {
|
|
|
4169
3882
|
reason: `Interrupted due to Guardrails validation failure. Reason: ${result.reason}`
|
|
4170
3883
|
});
|
|
4171
3884
|
outputMessages = [
|
|
4172
|
-
(0,
|
|
3885
|
+
(0, import_class_transformer2.plainToInstance)(TextMessage, {
|
|
4173
3886
|
id: (0, import_shared10.randomId)(),
|
|
4174
3887
|
createdAt: /* @__PURE__ */ new Date(),
|
|
4175
3888
|
content: result.reason,
|
|
@@ -4218,15 +3931,12 @@ var CopilotResolver = class {
|
|
|
4218
3931
|
// skip until this message start event
|
|
4219
3932
|
(0, import_rxjs4.skipWhile)((e) => e !== event),
|
|
4220
3933
|
// take until the message end event
|
|
4221
|
-
(0, import_rxjs4.takeWhile)((e) =>
|
|
4222
|
-
// filter out any other message events or message ids
|
|
4223
|
-
(0, import_rxjs4.filter)((e) => e.type == RuntimeEventTypes.TextMessageContent && e.messageId == event.messageId)
|
|
3934
|
+
(0, import_rxjs4.takeWhile)((e) => e.type != RuntimeEventTypes.TextMessageEnd)
|
|
4224
3935
|
);
|
|
4225
3936
|
const streamingTextStatus = new import_rxjs4.Subject();
|
|
4226
3937
|
const messageId = event.messageId;
|
|
4227
3938
|
pushMessage({
|
|
4228
3939
|
id: messageId,
|
|
4229
|
-
parentMessageId: event.parentMessageId,
|
|
4230
3940
|
status: (0, import_rxjs4.firstValueFrom)(streamingTextStatus),
|
|
4231
3941
|
createdAt: /* @__PURE__ */ new Date(),
|
|
4232
3942
|
role: MessageRole.assistant,
|
|
@@ -4239,7 +3949,7 @@ var CopilotResolver = class {
|
|
|
4239
3949
|
reason,
|
|
4240
3950
|
messageId: messageId2
|
|
4241
3951
|
}, "Text streaming interrupted");
|
|
4242
|
-
streamingTextStatus.next((0,
|
|
3952
|
+
streamingTextStatus.next((0, import_class_transformer2.plainToInstance)(FailedMessageStatus, {
|
|
4243
3953
|
reason
|
|
4244
3954
|
}));
|
|
4245
3955
|
responseStatus$.next(new MessageStreamInterruptedResponse({
|
|
@@ -4272,7 +3982,7 @@ var CopilotResolver = class {
|
|
|
4272
3982
|
streamingTextStatus.next(new SuccessMessageStatus());
|
|
4273
3983
|
stopStreamingText();
|
|
4274
3984
|
textSubscription == null ? void 0 : textSubscription.unsubscribe();
|
|
4275
|
-
outputMessages.push((0,
|
|
3985
|
+
outputMessages.push((0, import_class_transformer2.plainToInstance)(TextMessage, {
|
|
4276
3986
|
id: messageId,
|
|
4277
3987
|
createdAt: /* @__PURE__ */ new Date(),
|
|
4278
3988
|
content: textChunks.join(""),
|
|
@@ -4285,20 +3995,14 @@ var CopilotResolver = class {
|
|
|
4285
3995
|
break;
|
|
4286
3996
|
case RuntimeEventTypes.ActionExecutionStart:
|
|
4287
3997
|
logger2.debug("Action execution start event received");
|
|
4288
|
-
const actionExecutionArgumentStream = eventStream.pipe(
|
|
4289
|
-
(0, import_rxjs4.skipWhile)((e) => e !== event),
|
|
4290
|
-
// take until the action execution end event
|
|
4291
|
-
(0, import_rxjs4.takeWhile)((e) => !(e.type === RuntimeEventTypes.ActionExecutionEnd && e.actionExecutionId == event.actionExecutionId)),
|
|
4292
|
-
// filter out any other action execution events or action execution ids
|
|
4293
|
-
(0, import_rxjs4.filter)((e) => e.type == RuntimeEventTypes.ActionExecutionArgs && e.actionExecutionId == event.actionExecutionId)
|
|
4294
|
-
);
|
|
3998
|
+
const actionExecutionArgumentStream = eventStream.pipe((0, import_rxjs4.skipWhile)((e) => e !== event), (0, import_rxjs4.takeWhile)((e) => e.type != RuntimeEventTypes.ActionExecutionEnd));
|
|
4295
3999
|
const streamingArgumentsStatus = new import_rxjs4.Subject();
|
|
4296
4000
|
pushMessage({
|
|
4297
4001
|
id: event.actionExecutionId,
|
|
4298
|
-
parentMessageId: event.parentMessageId,
|
|
4299
4002
|
status: (0, import_rxjs4.firstValueFrom)(streamingArgumentsStatus),
|
|
4300
4003
|
createdAt: /* @__PURE__ */ new Date(),
|
|
4301
4004
|
name: event.actionName,
|
|
4005
|
+
scope: event.scope,
|
|
4302
4006
|
arguments: new import_graphql_yoga.Repeater(async (pushArgumentsChunk, stopStreamingArguments) => {
|
|
4303
4007
|
logger2.debug("Action execution argument stream created");
|
|
4304
4008
|
const argumentChunks = [];
|
|
@@ -4314,7 +4018,7 @@ var CopilotResolver = class {
|
|
|
4314
4018
|
logger2.error({
|
|
4315
4019
|
err
|
|
4316
4020
|
}, "Error in action execution argument stream");
|
|
4317
|
-
streamingArgumentsStatus.next((0,
|
|
4021
|
+
streamingArgumentsStatus.next((0, import_class_transformer2.plainToInstance)(FailedMessageStatus, {
|
|
4318
4022
|
reason: "An unknown error has occurred in the action execution argument stream"
|
|
4319
4023
|
}));
|
|
4320
4024
|
stopStreamingArguments();
|
|
@@ -4325,10 +4029,11 @@ var CopilotResolver = class {
|
|
|
4325
4029
|
streamingArgumentsStatus.next(new SuccessMessageStatus());
|
|
4326
4030
|
stopStreamingArguments();
|
|
4327
4031
|
actionExecutionArgumentSubscription == null ? void 0 : actionExecutionArgumentSubscription.unsubscribe();
|
|
4328
|
-
outputMessages.push((0,
|
|
4032
|
+
outputMessages.push((0, import_class_transformer2.plainToInstance)(ActionExecutionMessage, {
|
|
4329
4033
|
id: event.actionExecutionId,
|
|
4330
4034
|
createdAt: /* @__PURE__ */ new Date(),
|
|
4331
4035
|
name: event.actionName,
|
|
4036
|
+
scope: event.scope,
|
|
4332
4037
|
arguments: argumentChunks.join("")
|
|
4333
4038
|
}));
|
|
4334
4039
|
}
|
|
@@ -4341,15 +4046,15 @@ var CopilotResolver = class {
|
|
|
4341
4046
|
result: event.result
|
|
4342
4047
|
}, "Action execution result event received");
|
|
4343
4048
|
pushMessage({
|
|
4344
|
-
id:
|
|
4049
|
+
id: (0, import_shared10.randomId)(),
|
|
4345
4050
|
status: new SuccessMessageStatus(),
|
|
4346
4051
|
createdAt: /* @__PURE__ */ new Date(),
|
|
4347
4052
|
actionExecutionId: event.actionExecutionId,
|
|
4348
4053
|
actionName: event.actionName,
|
|
4349
4054
|
result: event.result
|
|
4350
4055
|
});
|
|
4351
|
-
outputMessages.push((0,
|
|
4352
|
-
id:
|
|
4056
|
+
outputMessages.push((0, import_class_transformer2.plainToInstance)(ResultMessage, {
|
|
4057
|
+
id: (0, import_shared10.randomId)(),
|
|
4353
4058
|
createdAt: /* @__PURE__ */ new Date(),
|
|
4354
4059
|
actionExecutionId: event.actionExecutionId,
|
|
4355
4060
|
actionName: event.actionName,
|
|
@@ -4373,7 +4078,7 @@ var CopilotResolver = class {
|
|
|
4373
4078
|
role: MessageRole.assistant,
|
|
4374
4079
|
createdAt: /* @__PURE__ */ new Date()
|
|
4375
4080
|
});
|
|
4376
|
-
outputMessages.push((0,
|
|
4081
|
+
outputMessages.push((0, import_class_transformer2.plainToInstance)(AgentStateMessage, {
|
|
4377
4082
|
id: (0, import_shared10.randomId)(),
|
|
4378
4083
|
threadId: event.threadId,
|
|
4379
4084
|
agentName: event.agentName,
|