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