@copilotkit/runtime 1.4.8 → 1.5.0-coagents-v0-3.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 +13 -0
- package/__snapshots__/schema/schema.graphql +7 -9
- package/dist/{chunk-W7GP2EOT.mjs → chunk-4AYRDPWK.mjs} +239 -65
- package/dist/chunk-4AYRDPWK.mjs.map +1 -0
- package/dist/{chunk-LSLFIYKP.mjs → chunk-7BOO3OFP.mjs} +2 -2
- package/dist/{chunk-GGNRDS7N.mjs → chunk-GSTWFOZF.mjs} +2 -2
- package/dist/{chunk-TA5I5LYF.mjs → chunk-OMAAKIJQ.mjs} +2 -2
- package/dist/{chunk-R6AUAQK6.mjs → chunk-PXS4SBRF.mjs} +423 -299
- package/dist/chunk-PXS4SBRF.mjs.map +1 -0
- package/dist/{chunk-B74M7FXG.mjs → chunk-RFF5IIZJ.mjs} +3 -2
- package/dist/chunk-RFF5IIZJ.mjs.map +1 -0
- package/dist/{copilot-runtime-48d7c2fc.d.ts → copilot-runtime-2e46a7b6.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-ac43305a.d.ts → groq-adapter-7bf6824b.d.ts} +1 -1
- package/dist/{index-10b1c870.d.ts → index-ff3fbc33.d.ts} +7 -8
- package/dist/index.d.ts +4 -4
- package/dist/index.js +747 -448
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/{langserve-b74e8606.d.ts → langserve-f318db89.d.ts} +51 -12
- package/dist/lib/index.d.ts +4 -4
- package/dist/lib/index.js +714 -439
- 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 +71 -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 +71 -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 +71 -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 +71 -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 +4 -4
- package/dist/service-adapters/index.js +238 -64
- package/dist/service-adapters/index.js.map +1 -1
- package/dist/service-adapters/index.mjs +1 -1
- package/package.json +2 -2
- package/src/agents/langgraph/event-source.ts +140 -148
- package/src/agents/langgraph/events.ts +1 -1
- 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/remote-action-constructors.ts +4 -2
- package/src/lib/runtime/remote-actions.ts +1 -0
- package/src/lib/runtime/remote-lg-action.ts +159 -140
- package/src/service-adapters/anthropic/anthropic-adapter.ts +16 -6
- package/src/service-adapters/conversion.ts +2 -1
- package/src/service-adapters/events.ts +116 -52
- package/src/service-adapters/experimental/ollama/ollama-adapter.ts +7 -3
- package/src/service-adapters/groq/groq-adapter.ts +23 -8
- package/src/service-adapters/langchain/utils.ts +55 -32
- package/src/service-adapters/openai/openai-adapter.ts +22 -9
- package/src/service-adapters/openai/openai-assistant-adapter.ts +22 -8
- package/src/service-adapters/unify/unify-adapter.ts +28 -11
- package/dist/chunk-B74M7FXG.mjs.map +0 -1
- package/dist/chunk-R6AUAQK6.mjs.map +0 -1
- package/dist/chunk-W7GP2EOT.mjs.map +0 -1
- /package/dist/{chunk-LSLFIYKP.mjs.map → chunk-7BOO3OFP.mjs.map} +0 -0
- /package/dist/{chunk-GGNRDS7N.mjs.map → chunk-GSTWFOZF.mjs.map} +0 -0
- /package/dist/{chunk-TA5I5LYF.mjs.map → chunk-OMAAKIJQ.mjs.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RemoteChain,
|
|
3
3
|
streamLangChainResponse
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-4AYRDPWK.mjs";
|
|
5
5
|
import {
|
|
6
6
|
GuardrailsValidationFailureResponse,
|
|
7
7
|
MessageStreamInterruptedResponse,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
AgentStateMessage,
|
|
15
15
|
ResultMessage,
|
|
16
16
|
TextMessage
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-RFF5IIZJ.mjs";
|
|
18
18
|
import {
|
|
19
19
|
BaseMessageInput
|
|
20
20
|
} from "./chunk-D2WLFQS6.mjs";
|
|
@@ -37,7 +37,7 @@ var require_package = __commonJS({
|
|
|
37
37
|
publishConfig: {
|
|
38
38
|
access: "public"
|
|
39
39
|
},
|
|
40
|
-
version: "1.
|
|
40
|
+
version: "1.5.0-coagents-v0-3.0",
|
|
41
41
|
sideEffects: false,
|
|
42
42
|
main: "./dist/index.js",
|
|
43
43
|
module: "./dist/index.mjs",
|
|
@@ -122,7 +122,7 @@ import { buildSchemaSync } from "type-graphql";
|
|
|
122
122
|
|
|
123
123
|
// src/graphql/resolvers/copilot.resolver.ts
|
|
124
124
|
import { Arg, Ctx, Mutation, Query, Resolver } from "type-graphql";
|
|
125
|
-
import { ReplaySubject as ReplaySubject3, Subject, finalize, firstValueFrom as firstValueFrom2, shareReplay, skipWhile, take, takeWhile, tap } from "rxjs";
|
|
125
|
+
import { ReplaySubject as ReplaySubject3, Subject, filter, finalize, firstValueFrom as firstValueFrom2, shareReplay, skipWhile, take, takeWhile, tap } from "rxjs";
|
|
126
126
|
|
|
127
127
|
// src/graphql/inputs/generate-copilot-response.input.ts
|
|
128
128
|
import { Field as Field9, InputType as InputType9 } from "type-graphql";
|
|
@@ -139,12 +139,6 @@ var MessageRole;
|
|
|
139
139
|
MessageRole2["system"] = "system";
|
|
140
140
|
MessageRole2["tool"] = "tool";
|
|
141
141
|
})(MessageRole || (MessageRole = {}));
|
|
142
|
-
var ActionExecutionScope;
|
|
143
|
-
(function(ActionExecutionScope2) {
|
|
144
|
-
ActionExecutionScope2["server"] = "server";
|
|
145
|
-
ActionExecutionScope2["client"] = "client";
|
|
146
|
-
ActionExecutionScope2["passThrough"] = "passThrough";
|
|
147
|
-
})(ActionExecutionScope || (ActionExecutionScope = {}));
|
|
148
142
|
var CopilotRequestType;
|
|
149
143
|
(function(CopilotRequestType2) {
|
|
150
144
|
CopilotRequestType2["Chat"] = "Chat";
|
|
@@ -163,10 +157,6 @@ registerEnumType(MessageRole, {
|
|
|
163
157
|
name: "MessageRole",
|
|
164
158
|
description: "The role of the message"
|
|
165
159
|
});
|
|
166
|
-
registerEnumType(ActionExecutionScope, {
|
|
167
|
-
name: "ActionExecutionScope",
|
|
168
|
-
description: "The scope of the action"
|
|
169
|
-
});
|
|
170
160
|
registerEnumType(CopilotRequestType, {
|
|
171
161
|
name: "CopilotRequestType",
|
|
172
162
|
description: "The type of Copilot request"
|
|
@@ -229,6 +219,7 @@ MessageInput = _ts_decorate([
|
|
|
229
219
|
], MessageInput);
|
|
230
220
|
var TextMessageInput = class {
|
|
231
221
|
content;
|
|
222
|
+
parentMessageId;
|
|
232
223
|
role;
|
|
233
224
|
};
|
|
234
225
|
__name(TextMessageInput, "TextMessageInput");
|
|
@@ -236,6 +227,12 @@ _ts_decorate([
|
|
|
236
227
|
Field(() => String),
|
|
237
228
|
_ts_metadata("design:type", String)
|
|
238
229
|
], TextMessageInput.prototype, "content", void 0);
|
|
230
|
+
_ts_decorate([
|
|
231
|
+
Field(() => String, {
|
|
232
|
+
nullable: true
|
|
233
|
+
}),
|
|
234
|
+
_ts_metadata("design:type", String)
|
|
235
|
+
], TextMessageInput.prototype, "parentMessageId", void 0);
|
|
239
236
|
_ts_decorate([
|
|
240
237
|
Field(() => MessageRole),
|
|
241
238
|
_ts_metadata("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
|
|
@@ -246,6 +243,7 @@ TextMessageInput = _ts_decorate([
|
|
|
246
243
|
var ActionExecutionMessageInput = class {
|
|
247
244
|
name;
|
|
248
245
|
arguments;
|
|
246
|
+
parentMessageId;
|
|
249
247
|
scope;
|
|
250
248
|
};
|
|
251
249
|
__name(ActionExecutionMessageInput, "ActionExecutionMessageInput");
|
|
@@ -258,8 +256,17 @@ _ts_decorate([
|
|
|
258
256
|
_ts_metadata("design:type", String)
|
|
259
257
|
], ActionExecutionMessageInput.prototype, "arguments", void 0);
|
|
260
258
|
_ts_decorate([
|
|
261
|
-
Field(() =>
|
|
262
|
-
|
|
259
|
+
Field(() => String, {
|
|
260
|
+
nullable: true
|
|
261
|
+
}),
|
|
262
|
+
_ts_metadata("design:type", String)
|
|
263
|
+
], ActionExecutionMessageInput.prototype, "parentMessageId", void 0);
|
|
264
|
+
_ts_decorate([
|
|
265
|
+
Field(() => String, {
|
|
266
|
+
nullable: true,
|
|
267
|
+
deprecationReason: "This field will be removed in a future version"
|
|
268
|
+
}),
|
|
269
|
+
_ts_metadata("design:type", typeof String === "undefined" ? Object : String)
|
|
263
270
|
], ActionExecutionMessageInput.prototype, "scope", void 0);
|
|
264
271
|
ActionExecutionMessageInput = _ts_decorate([
|
|
265
272
|
InputType()
|
|
@@ -267,6 +274,7 @@ ActionExecutionMessageInput = _ts_decorate([
|
|
|
267
274
|
var ResultMessageInput = class {
|
|
268
275
|
actionExecutionId;
|
|
269
276
|
actionName;
|
|
277
|
+
parentMessageId;
|
|
270
278
|
result;
|
|
271
279
|
};
|
|
272
280
|
__name(ResultMessageInput, "ResultMessageInput");
|
|
@@ -278,6 +286,12 @@ _ts_decorate([
|
|
|
278
286
|
Field(() => String),
|
|
279
287
|
_ts_metadata("design:type", String)
|
|
280
288
|
], ResultMessageInput.prototype, "actionName", void 0);
|
|
289
|
+
_ts_decorate([
|
|
290
|
+
Field(() => String, {
|
|
291
|
+
nullable: true
|
|
292
|
+
}),
|
|
293
|
+
_ts_metadata("design:type", String)
|
|
294
|
+
], ResultMessageInput.prototype, "parentMessageId", void 0);
|
|
281
295
|
_ts_decorate([
|
|
282
296
|
Field(() => String),
|
|
283
297
|
_ts_metadata("design:type", String)
|
|
@@ -893,6 +907,7 @@ BaseMessageOutput = _ts_decorate11([
|
|
|
893
907
|
var TextMessageOutput = class {
|
|
894
908
|
role;
|
|
895
909
|
content;
|
|
910
|
+
parentMessageId;
|
|
896
911
|
};
|
|
897
912
|
__name(TextMessageOutput, "TextMessageOutput");
|
|
898
913
|
_ts_decorate11([
|
|
@@ -905,6 +920,12 @@ _ts_decorate11([
|
|
|
905
920
|
]),
|
|
906
921
|
_ts_metadata11("design:type", Array)
|
|
907
922
|
], TextMessageOutput.prototype, "content", void 0);
|
|
923
|
+
_ts_decorate11([
|
|
924
|
+
Field11(() => String, {
|
|
925
|
+
nullable: true
|
|
926
|
+
}),
|
|
927
|
+
_ts_metadata11("design:type", String)
|
|
928
|
+
], TextMessageOutput.prototype, "parentMessageId", void 0);
|
|
908
929
|
TextMessageOutput = _ts_decorate11([
|
|
909
930
|
ObjectType2({
|
|
910
931
|
implements: BaseMessageOutput
|
|
@@ -914,6 +935,7 @@ var ActionExecutionMessageOutput = class {
|
|
|
914
935
|
name;
|
|
915
936
|
scope;
|
|
916
937
|
arguments;
|
|
938
|
+
parentMessageId;
|
|
917
939
|
};
|
|
918
940
|
__name(ActionExecutionMessageOutput, "ActionExecutionMessageOutput");
|
|
919
941
|
_ts_decorate11([
|
|
@@ -921,8 +943,11 @@ _ts_decorate11([
|
|
|
921
943
|
_ts_metadata11("design:type", String)
|
|
922
944
|
], ActionExecutionMessageOutput.prototype, "name", void 0);
|
|
923
945
|
_ts_decorate11([
|
|
924
|
-
Field11(() =>
|
|
925
|
-
|
|
946
|
+
Field11(() => String, {
|
|
947
|
+
nullable: true,
|
|
948
|
+
deprecationReason: "This field will be removed in a future version"
|
|
949
|
+
}),
|
|
950
|
+
_ts_metadata11("design:type", String)
|
|
926
951
|
], ActionExecutionMessageOutput.prototype, "scope", void 0);
|
|
927
952
|
_ts_decorate11([
|
|
928
953
|
Field11(() => [
|
|
@@ -930,6 +955,12 @@ _ts_decorate11([
|
|
|
930
955
|
]),
|
|
931
956
|
_ts_metadata11("design:type", Array)
|
|
932
957
|
], ActionExecutionMessageOutput.prototype, "arguments", void 0);
|
|
958
|
+
_ts_decorate11([
|
|
959
|
+
Field11(() => String, {
|
|
960
|
+
nullable: true
|
|
961
|
+
}),
|
|
962
|
+
_ts_metadata11("design:type", String)
|
|
963
|
+
], ActionExecutionMessageOutput.prototype, "parentMessageId", void 0);
|
|
933
964
|
ActionExecutionMessageOutput = _ts_decorate11([
|
|
934
965
|
ObjectType2({
|
|
935
966
|
implements: BaseMessageOutput
|
|
@@ -1042,7 +1073,7 @@ import { Repeater } from "graphql-yoga";
|
|
|
1042
1073
|
|
|
1043
1074
|
// src/service-adapters/events.ts
|
|
1044
1075
|
import { randomId as randomId2 } from "@copilotkit/shared";
|
|
1045
|
-
import { of, concat,
|
|
1076
|
+
import { of, concat, scan as scan2, concatMap, ReplaySubject as ReplaySubject2, firstValueFrom, from as from2 } from "rxjs";
|
|
1046
1077
|
|
|
1047
1078
|
// src/lib/telemetry-client.ts
|
|
1048
1079
|
import { TelemetryClient } from "@copilotkit/shared";
|
|
@@ -1090,163 +1121,167 @@ var RemoteLangGraphEventSource = class {
|
|
|
1090
1121
|
}
|
|
1091
1122
|
return shouldEmitToolCalls === toolCallName;
|
|
1092
1123
|
}
|
|
1124
|
+
getCurrentContent(event) {
|
|
1125
|
+
var _a, _b, _c, _d, _e;
|
|
1126
|
+
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);
|
|
1127
|
+
if (!content) {
|
|
1128
|
+
const toolCallChunks = this.getCurrentToolCallChunks(event) ?? [];
|
|
1129
|
+
for (const chunk of toolCallChunks) {
|
|
1130
|
+
if (chunk.args) {
|
|
1131
|
+
return chunk.args;
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
if (typeof content === "string") {
|
|
1136
|
+
return content;
|
|
1137
|
+
} else if (Array.isArray(content) && content.length > 0) {
|
|
1138
|
+
return content[0].text;
|
|
1139
|
+
}
|
|
1140
|
+
return null;
|
|
1141
|
+
}
|
|
1142
|
+
getCurrentMessageId(event) {
|
|
1143
|
+
var _a, _b, _c, _d, _e;
|
|
1144
|
+
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);
|
|
1145
|
+
}
|
|
1146
|
+
getCurrentToolCallChunks(event) {
|
|
1147
|
+
var _a, _b, _c, _d, _e;
|
|
1148
|
+
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);
|
|
1149
|
+
}
|
|
1150
|
+
getResponseMetadata(event) {
|
|
1151
|
+
var _a, _b, _c, _d, _e;
|
|
1152
|
+
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);
|
|
1153
|
+
}
|
|
1093
1154
|
processLangGraphEvents() {
|
|
1094
1155
|
let lastEventWithState = null;
|
|
1095
1156
|
return this.eventStream$.pipe(scan((acc, event) => {
|
|
1096
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
1097
1157
|
if (event.event === LangGraphEventTypes.OnChatModelStream) {
|
|
1098
|
-
const
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
acc.prevToolCallMessageId = acc.toolCallMessageId;
|
|
1113
|
-
acc.toolCallMessageId = toolCallMessageId;
|
|
1114
|
-
if ((_p = toolCallChunks[0]) == null ? void 0 : _p.name) {
|
|
1115
|
-
acc.toolCallName = toolCallChunks[0].name;
|
|
1116
|
-
}
|
|
1117
|
-
if ((_q = toolCallChunks[0]) == null ? void 0 : _q.id) {
|
|
1118
|
-
acc.toolCallId = toolCallChunks[0].id;
|
|
1119
|
-
}
|
|
1120
|
-
acc.prevMessageId = acc.messageId;
|
|
1121
|
-
acc.messageId = toolCallMessageId;
|
|
1122
|
-
} else if (acc.content && acc.content != "") {
|
|
1123
|
-
acc.prevMessageId = acc.messageId;
|
|
1124
|
-
acc.messageId = toolCallMessageId;
|
|
1125
|
-
} else {
|
|
1126
|
-
acc.prevToolCallMessageId = acc.toolCallMessageId;
|
|
1127
|
-
acc.prevMessageId = acc.messageId;
|
|
1128
|
-
}
|
|
1129
|
-
} else {
|
|
1130
|
-
acc.prevToolCallMessageId = acc.toolCallMessageId;
|
|
1131
|
-
acc.toolCallMessageId = null;
|
|
1132
|
-
acc.prevMessageId = acc.messageId;
|
|
1133
|
-
acc.messageId = null;
|
|
1134
|
-
acc.toolCallName = null;
|
|
1158
|
+
const prevMessageId = acc.lastMessageId;
|
|
1159
|
+
acc.currentContent = this.getCurrentContent(event);
|
|
1160
|
+
acc.lastMessageId = this.getCurrentMessageId(event) ?? acc.lastMessageId;
|
|
1161
|
+
const toolCallChunks = this.getCurrentToolCallChunks(event) ?? [];
|
|
1162
|
+
const responseMetadata = this.getResponseMetadata(event);
|
|
1163
|
+
acc.isToolCallStart = toolCallChunks.some((chunk) => chunk.name && chunk.id);
|
|
1164
|
+
acc.isMessageStart = prevMessageId !== acc.lastMessageId && !acc.isToolCallStart;
|
|
1165
|
+
acc.isToolCall = toolCallChunks && toolCallChunks.length > 0;
|
|
1166
|
+
acc.isToolCallEnd = (responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "tool_calls";
|
|
1167
|
+
acc.isMessageEnd = (responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "stop";
|
|
1168
|
+
({ name: acc.lastToolCallName, id: acc.lastToolCallId } = toolCallChunks.find((chunk) => chunk.name && chunk.id) ?? {
|
|
1169
|
+
name: acc.lastToolCallName,
|
|
1170
|
+
id: acc.lastToolCallId
|
|
1171
|
+
});
|
|
1135
1172
|
}
|
|
1136
1173
|
acc.event = event;
|
|
1137
1174
|
lastEventWithState = acc;
|
|
1138
1175
|
return acc;
|
|
1139
1176
|
}, {
|
|
1140
1177
|
event: null,
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1178
|
+
isMessageStart: false,
|
|
1179
|
+
isMessageEnd: false,
|
|
1180
|
+
isToolCallStart: false,
|
|
1181
|
+
isToolCallEnd: false,
|
|
1182
|
+
isToolCall: false,
|
|
1183
|
+
lastMessageId: null,
|
|
1184
|
+
lastToolCallId: null,
|
|
1185
|
+
lastToolCallName: null,
|
|
1186
|
+
currentContent: null
|
|
1187
|
+
}), mergeMap((acc) => {
|
|
1150
1188
|
const events = [];
|
|
1151
1189
|
let shouldEmitMessages = true;
|
|
1152
|
-
let shouldEmitToolCalls =
|
|
1153
|
-
if (
|
|
1154
|
-
if ("copilotkit:emit-tool-calls" in (
|
|
1155
|
-
shouldEmitToolCalls =
|
|
1190
|
+
let shouldEmitToolCalls = true;
|
|
1191
|
+
if (acc.event.event == LangGraphEventTypes.OnChatModelStream) {
|
|
1192
|
+
if ("copilotkit:emit-tool-calls" in (acc.event.metadata || {})) {
|
|
1193
|
+
shouldEmitToolCalls = acc.event.metadata["copilotkit:emit-tool-calls"];
|
|
1156
1194
|
}
|
|
1157
|
-
if ("copilotkit:emit-messages" in (
|
|
1158
|
-
shouldEmitMessages =
|
|
1195
|
+
if ("copilotkit:emit-messages" in (acc.event.metadata || {})) {
|
|
1196
|
+
shouldEmitMessages = acc.event.metadata["copilotkit:emit-messages"];
|
|
1159
1197
|
}
|
|
1160
1198
|
}
|
|
1161
|
-
|
|
1199
|
+
const responseMetadata = this.getResponseMetadata(acc.event);
|
|
1200
|
+
if ((responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "tool_calls" && this.shouldEmitToolCall(shouldEmitToolCalls, acc.lastToolCallName)) {
|
|
1162
1201
|
events.push({
|
|
1163
|
-
type: RuntimeEventTypes.ActionExecutionEnd
|
|
1202
|
+
type: RuntimeEventTypes.ActionExecutionEnd,
|
|
1203
|
+
actionExecutionId: acc.lastToolCallId
|
|
1164
1204
|
});
|
|
1165
1205
|
}
|
|
1166
|
-
if (
|
|
1206
|
+
if ((responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "stop" && shouldEmitMessages) {
|
|
1167
1207
|
events.push({
|
|
1168
|
-
type: RuntimeEventTypes.TextMessageEnd
|
|
1208
|
+
type: RuntimeEventTypes.TextMessageEnd,
|
|
1209
|
+
messageId: acc.lastMessageId
|
|
1169
1210
|
});
|
|
1170
1211
|
}
|
|
1171
|
-
switch (
|
|
1212
|
+
switch (acc.event.event) {
|
|
1172
1213
|
case LangGraphEventTypes.OnCustomEvent:
|
|
1173
|
-
if (
|
|
1214
|
+
if (acc.event.name === CustomEventNames.CopilotKitManuallyEmitMessage) {
|
|
1174
1215
|
events.push({
|
|
1175
1216
|
type: RuntimeEventTypes.TextMessageStart,
|
|
1176
|
-
messageId:
|
|
1217
|
+
messageId: acc.event.data.message_id
|
|
1177
1218
|
});
|
|
1178
1219
|
events.push({
|
|
1179
1220
|
type: RuntimeEventTypes.TextMessageContent,
|
|
1180
|
-
|
|
1221
|
+
messageId: acc.event.data.message_id,
|
|
1222
|
+
content: acc.event.data.message
|
|
1181
1223
|
});
|
|
1182
1224
|
events.push({
|
|
1183
|
-
type: RuntimeEventTypes.TextMessageEnd
|
|
1225
|
+
type: RuntimeEventTypes.TextMessageEnd,
|
|
1226
|
+
messageId: acc.event.data.message_id
|
|
1184
1227
|
});
|
|
1185
|
-
} else if (
|
|
1228
|
+
} else if (acc.event.name === CustomEventNames.CopilotKitManuallyEmitToolCall) {
|
|
1186
1229
|
events.push({
|
|
1187
1230
|
type: RuntimeEventTypes.ActionExecutionStart,
|
|
1188
|
-
actionExecutionId:
|
|
1189
|
-
actionName:
|
|
1231
|
+
actionExecutionId: acc.event.data.id,
|
|
1232
|
+
actionName: acc.event.data.name,
|
|
1233
|
+
parentMessageId: acc.event.data.id
|
|
1190
1234
|
});
|
|
1191
1235
|
events.push({
|
|
1192
1236
|
type: RuntimeEventTypes.ActionExecutionArgs,
|
|
1193
|
-
|
|
1237
|
+
actionExecutionId: acc.event.data.id,
|
|
1238
|
+
args: JSON.stringify(acc.event.data.args)
|
|
1194
1239
|
});
|
|
1195
1240
|
events.push({
|
|
1196
|
-
type: RuntimeEventTypes.ActionExecutionEnd
|
|
1241
|
+
type: RuntimeEventTypes.ActionExecutionEnd,
|
|
1242
|
+
actionExecutionId: acc.event.data.id
|
|
1197
1243
|
});
|
|
1198
1244
|
}
|
|
1199
1245
|
break;
|
|
1200
1246
|
case LangGraphEventTypes.OnCopilotKitStateSync:
|
|
1201
1247
|
events.push({
|
|
1202
1248
|
type: RuntimeEventTypes.AgentStateMessage,
|
|
1203
|
-
threadId:
|
|
1204
|
-
role:
|
|
1205
|
-
agentName:
|
|
1206
|
-
nodeName:
|
|
1207
|
-
runId:
|
|
1208
|
-
active:
|
|
1209
|
-
state: JSON.stringify(
|
|
1210
|
-
running:
|
|
1249
|
+
threadId: acc.event.thread_id,
|
|
1250
|
+
role: acc.event.role,
|
|
1251
|
+
agentName: acc.event.agent_name,
|
|
1252
|
+
nodeName: acc.event.node_name,
|
|
1253
|
+
runId: acc.event.run_id,
|
|
1254
|
+
active: acc.event.active,
|
|
1255
|
+
state: JSON.stringify(acc.event.state),
|
|
1256
|
+
running: acc.event.running
|
|
1211
1257
|
});
|
|
1212
1258
|
break;
|
|
1213
|
-
case LangGraphEventTypes.OnToolEnd:
|
|
1214
|
-
break;
|
|
1215
1259
|
case LangGraphEventTypes.OnChatModelStream:
|
|
1216
|
-
if (
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
type: RuntimeEventTypes.TextMessageStart,
|
|
1229
|
-
messageId: eventWithState.messageId
|
|
1230
|
-
});
|
|
1231
|
-
}
|
|
1260
|
+
if (acc.isToolCallStart && this.shouldEmitToolCall(shouldEmitToolCalls, acc.lastToolCallName)) {
|
|
1261
|
+
events.push({
|
|
1262
|
+
type: RuntimeEventTypes.ActionExecutionStart,
|
|
1263
|
+
actionExecutionId: acc.lastToolCallId,
|
|
1264
|
+
actionName: acc.lastToolCallName,
|
|
1265
|
+
parentMessageId: acc.lastMessageId
|
|
1266
|
+
});
|
|
1267
|
+
} else if (acc.isMessageStart && shouldEmitMessages) {
|
|
1268
|
+
events.push({
|
|
1269
|
+
type: RuntimeEventTypes.TextMessageStart,
|
|
1270
|
+
messageId: acc.lastMessageId
|
|
1271
|
+
});
|
|
1232
1272
|
}
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
events.push({
|
|
1246
|
-
type: RuntimeEventTypes.TextMessageContent,
|
|
1247
|
-
content
|
|
1248
|
-
});
|
|
1249
|
-
}
|
|
1273
|
+
if (acc.isToolCall && acc.currentContent && this.shouldEmitToolCall(shouldEmitToolCalls, acc.lastToolCallName)) {
|
|
1274
|
+
events.push({
|
|
1275
|
+
type: RuntimeEventTypes.ActionExecutionArgs,
|
|
1276
|
+
actionExecutionId: acc.lastToolCallId,
|
|
1277
|
+
args: acc.currentContent
|
|
1278
|
+
});
|
|
1279
|
+
} else if (!acc.isToolCall && acc.currentContent && shouldEmitMessages) {
|
|
1280
|
+
events.push({
|
|
1281
|
+
type: RuntimeEventTypes.TextMessageContent,
|
|
1282
|
+
messageId: acc.lastMessageId,
|
|
1283
|
+
content: acc.currentContent
|
|
1284
|
+
});
|
|
1250
1285
|
}
|
|
1251
1286
|
break;
|
|
1252
1287
|
}
|
|
@@ -1254,14 +1289,16 @@ var RemoteLangGraphEventSource = class {
|
|
|
1254
1289
|
}), catchError((error) => {
|
|
1255
1290
|
console.error(error);
|
|
1256
1291
|
const events = [];
|
|
1257
|
-
if (lastEventWithState == null ? void 0 : lastEventWithState.
|
|
1292
|
+
if ((lastEventWithState == null ? void 0 : lastEventWithState.lastMessageId) && !lastEventWithState.isToolCall) {
|
|
1258
1293
|
events.push({
|
|
1259
|
-
type: RuntimeEventTypes.TextMessageEnd
|
|
1294
|
+
type: RuntimeEventTypes.TextMessageEnd,
|
|
1295
|
+
messageId: lastEventWithState.lastMessageId
|
|
1260
1296
|
});
|
|
1261
1297
|
}
|
|
1262
|
-
if (lastEventWithState == null ? void 0 : lastEventWithState.
|
|
1298
|
+
if (lastEventWithState == null ? void 0 : lastEventWithState.lastToolCallId) {
|
|
1263
1299
|
events.push({
|
|
1264
|
-
type: RuntimeEventTypes.ActionExecutionEnd
|
|
1300
|
+
type: RuntimeEventTypes.ActionExecutionEnd,
|
|
1301
|
+
actionExecutionId: lastEventWithState.lastToolCallId
|
|
1265
1302
|
});
|
|
1266
1303
|
}
|
|
1267
1304
|
const messageId = randomId();
|
|
@@ -1271,10 +1308,12 @@ var RemoteLangGraphEventSource = class {
|
|
|
1271
1308
|
});
|
|
1272
1309
|
events.push({
|
|
1273
1310
|
type: RuntimeEventTypes.TextMessageContent,
|
|
1311
|
+
messageId,
|
|
1274
1312
|
content: "\u274C An error occurred. Please try again."
|
|
1275
1313
|
});
|
|
1276
1314
|
events.push({
|
|
1277
|
-
type: RuntimeEventTypes.TextMessageEnd
|
|
1315
|
+
type: RuntimeEventTypes.TextMessageEnd,
|
|
1316
|
+
messageId
|
|
1278
1317
|
});
|
|
1279
1318
|
return events;
|
|
1280
1319
|
}));
|
|
@@ -1332,7 +1371,7 @@ async function streamEvents(controller, args) {
|
|
|
1332
1371
|
const mode = wasInitiatedWithExistingThread && nodeName != "__end__" ? "continue" : "start";
|
|
1333
1372
|
let formattedMessages = [];
|
|
1334
1373
|
try {
|
|
1335
|
-
formattedMessages =
|
|
1374
|
+
formattedMessages = copilotkitMessagesToLangChain(messages);
|
|
1336
1375
|
} catch (e) {
|
|
1337
1376
|
logger2.error(e, `Error event thrown: ${e.message}`);
|
|
1338
1377
|
}
|
|
@@ -1485,7 +1524,8 @@ async function streamEvents(controller, args) {
|
|
|
1485
1524
|
nodeName: isEndNode ? "__end__" : nodeName,
|
|
1486
1525
|
state: state.values,
|
|
1487
1526
|
running: !shouldExit,
|
|
1488
|
-
active: false
|
|
1527
|
+
active: false,
|
|
1528
|
+
includeMessages: true
|
|
1489
1529
|
}));
|
|
1490
1530
|
return Promise.resolve();
|
|
1491
1531
|
} catch (e) {
|
|
@@ -1498,13 +1538,20 @@ async function streamEvents(controller, args) {
|
|
|
1498
1538
|
}
|
|
1499
1539
|
}
|
|
1500
1540
|
__name(streamEvents, "streamEvents");
|
|
1501
|
-
function getStateSyncEvent({ threadId, runId, agentName, nodeName, state, running, active }) {
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1541
|
+
function getStateSyncEvent({ threadId, runId, agentName, nodeName, state, running, active, includeMessages = false }) {
|
|
1542
|
+
if (!includeMessages) {
|
|
1543
|
+
state = Object.keys(state).reduce((acc, key) => {
|
|
1544
|
+
if (key !== "messages") {
|
|
1545
|
+
acc[key] = state[key];
|
|
1546
|
+
}
|
|
1547
|
+
return acc;
|
|
1548
|
+
}, {});
|
|
1549
|
+
} else {
|
|
1550
|
+
state = {
|
|
1551
|
+
...state,
|
|
1552
|
+
messages: langchainMessagesToCopilotKit(state.messages || [])
|
|
1553
|
+
};
|
|
1554
|
+
}
|
|
1508
1555
|
return JSON.stringify({
|
|
1509
1556
|
event: LangGraphEventTypes.OnCopilotKitStateSync,
|
|
1510
1557
|
thread_id: threadId,
|
|
@@ -1512,7 +1559,7 @@ function getStateSyncEvent({ threadId, runId, agentName, nodeName, state, runnin
|
|
|
1512
1559
|
agent_name: agentName,
|
|
1513
1560
|
node_name: nodeName,
|
|
1514
1561
|
active,
|
|
1515
|
-
state
|
|
1562
|
+
state,
|
|
1516
1563
|
running,
|
|
1517
1564
|
role: "assistant"
|
|
1518
1565
|
}) + "\n";
|
|
@@ -1588,134 +1635,157 @@ function langGraphDefaultMergeState(state, messages, actions, agentName) {
|
|
|
1588
1635
|
if (messages.length > 0 && "role" in messages[0] && messages[0].role === "system") {
|
|
1589
1636
|
messages = messages.slice(1);
|
|
1590
1637
|
}
|
|
1591
|
-
const
|
|
1592
|
-
const existingMessageIds = new Set(
|
|
1593
|
-
const
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1638
|
+
const existingMessages = state.messages || [];
|
|
1639
|
+
const existingMessageIds = new Set(existingMessages.map((message) => message.id));
|
|
1640
|
+
const newMessages = messages.filter((message) => !existingMessageIds.has(message.id));
|
|
1641
|
+
return {
|
|
1642
|
+
...state,
|
|
1643
|
+
messages: newMessages,
|
|
1644
|
+
copilotkit: {
|
|
1645
|
+
actions
|
|
1646
|
+
}
|
|
1647
|
+
};
|
|
1648
|
+
}
|
|
1649
|
+
__name(langGraphDefaultMergeState, "langGraphDefaultMergeState");
|
|
1650
|
+
function langchainMessagesToCopilotKit(messages) {
|
|
1651
|
+
const result = [];
|
|
1652
|
+
const tool_call_names = {};
|
|
1653
|
+
for (const message of messages) {
|
|
1654
|
+
if (message.type === "ai") {
|
|
1655
|
+
for (const tool_call of message.tool_calls) {
|
|
1656
|
+
tool_call_names[tool_call.id] = tool_call.name;
|
|
1657
|
+
}
|
|
1597
1658
|
}
|
|
1598
1659
|
}
|
|
1599
1660
|
for (const message of messages) {
|
|
1600
|
-
|
|
1601
|
-
|
|
1661
|
+
let content = message.content;
|
|
1662
|
+
if (content instanceof Array) {
|
|
1663
|
+
content = content[0];
|
|
1602
1664
|
}
|
|
1603
|
-
if (
|
|
1604
|
-
|
|
1665
|
+
if (content instanceof Object) {
|
|
1666
|
+
content = content.text;
|
|
1605
1667
|
}
|
|
1606
|
-
if (
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
} else {
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1668
|
+
if (message.type === "human") {
|
|
1669
|
+
result.push({
|
|
1670
|
+
role: "user",
|
|
1671
|
+
content,
|
|
1672
|
+
id: message.id
|
|
1673
|
+
});
|
|
1674
|
+
} else if (message.type === "system") {
|
|
1675
|
+
result.push({
|
|
1676
|
+
role: "system",
|
|
1677
|
+
content,
|
|
1678
|
+
id: message.id
|
|
1679
|
+
});
|
|
1680
|
+
} else if (message.type === "ai") {
|
|
1681
|
+
if (message.tool_calls && message.tool_calls.length > 0) {
|
|
1682
|
+
for (const tool_call of message.tool_calls) {
|
|
1683
|
+
result.push({
|
|
1684
|
+
id: tool_call.id,
|
|
1685
|
+
name: tool_call.name,
|
|
1686
|
+
arguments: tool_call.args,
|
|
1687
|
+
parentMessageId: message.id
|
|
1688
|
+
});
|
|
1620
1689
|
}
|
|
1690
|
+
} else {
|
|
1691
|
+
result.push({
|
|
1692
|
+
role: "assistant",
|
|
1693
|
+
content,
|
|
1694
|
+
id: message.id,
|
|
1695
|
+
parentMessageId: message.id
|
|
1696
|
+
});
|
|
1621
1697
|
}
|
|
1698
|
+
} else if (message.type === "tool") {
|
|
1699
|
+
const actionName = tool_call_names[message.tool_call_id] || message.name || "";
|
|
1700
|
+
result.push({
|
|
1701
|
+
actionExecutionId: message.tool_call_id,
|
|
1702
|
+
actionName,
|
|
1703
|
+
result: content,
|
|
1704
|
+
id: message.id
|
|
1705
|
+
});
|
|
1622
1706
|
}
|
|
1623
1707
|
}
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
nextMessage.tool_call_id = currentMessage.tool_calls[0].id;
|
|
1708
|
+
const resultsDict = {};
|
|
1709
|
+
for (const msg of result) {
|
|
1710
|
+
if (msg.actionExecutionId) {
|
|
1711
|
+
resultsDict[msg.actionExecutionId] = msg;
|
|
1629
1712
|
}
|
|
1630
1713
|
}
|
|
1631
|
-
const
|
|
1632
|
-
for (
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
const prevMessage = mergedMessages[i - 1] || null;
|
|
1636
|
-
if ("tool_calls" in currentMessage && currentMessage.tool_calls.length > 0) {
|
|
1637
|
-
if (!nextMessage) {
|
|
1638
|
-
console.warn("No next message to auto-correct tool call, skipping:", currentMessage.tool_calls[0].id);
|
|
1639
|
-
continue;
|
|
1640
|
-
}
|
|
1641
|
-
if (!("tool_call_id" in nextMessage) || nextMessage.tool_call_id !== currentMessage.tool_calls[0].id) {
|
|
1642
|
-
const toolMessage = mergedMessages.find((m) => "tool_call_id" in m && m.tool_call_id === currentMessage.tool_calls[0].id);
|
|
1643
|
-
if (toolMessage) {
|
|
1644
|
-
console.warn("Auto-corrected tool call alignment issue:", currentMessage.tool_calls[0].id);
|
|
1645
|
-
correctedMessages.push(currentMessage, toolMessage);
|
|
1646
|
-
continue;
|
|
1647
|
-
} else {
|
|
1648
|
-
console.warn("No corresponding tool call result found for tool call, skipping:", currentMessage.tool_calls[0].id);
|
|
1649
|
-
continue;
|
|
1650
|
-
}
|
|
1651
|
-
}
|
|
1652
|
-
correctedMessages.push(currentMessage);
|
|
1653
|
-
continue;
|
|
1714
|
+
const reorderedResult = [];
|
|
1715
|
+
for (const msg of result) {
|
|
1716
|
+
if (!("actionExecutionId" in msg)) {
|
|
1717
|
+
reorderedResult.push(msg);
|
|
1654
1718
|
}
|
|
1655
|
-
if ("
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
}
|
|
1660
|
-
if (prevMessage.tool_calls && prevMessage.tool_calls[0].id !== currentMessage.tool_call_id) {
|
|
1661
|
-
console.warn("Tool call id is incorrect, skipping tool call result:", currentMessage.id);
|
|
1662
|
-
continue;
|
|
1719
|
+
if ("arguments" in msg) {
|
|
1720
|
+
const msgId = msg.id;
|
|
1721
|
+
if (msgId in resultsDict) {
|
|
1722
|
+
reorderedResult.push(resultsDict[msgId]);
|
|
1663
1723
|
}
|
|
1664
|
-
correctedMessages.push(currentMessage);
|
|
1665
|
-
continue;
|
|
1666
1724
|
}
|
|
1667
|
-
correctedMessages.push(currentMessage);
|
|
1668
1725
|
}
|
|
1669
|
-
return
|
|
1670
|
-
...state,
|
|
1671
|
-
messages: correctedMessages,
|
|
1672
|
-
copilotkit: {
|
|
1673
|
-
actions
|
|
1674
|
-
}
|
|
1675
|
-
};
|
|
1726
|
+
return reorderedResult;
|
|
1676
1727
|
}
|
|
1677
|
-
__name(
|
|
1678
|
-
function
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1728
|
+
__name(langchainMessagesToCopilotKit, "langchainMessagesToCopilotKit");
|
|
1729
|
+
function copilotkitMessagesToLangChain(messages) {
|
|
1730
|
+
const result = [];
|
|
1731
|
+
const processedActionExecutions = /* @__PURE__ */ new Set();
|
|
1732
|
+
for (const message of messages) {
|
|
1733
|
+
if (message.isTextMessage()) {
|
|
1734
|
+
if (message.role === "user") {
|
|
1735
|
+
result.push({
|
|
1736
|
+
...message,
|
|
1737
|
+
role: MessageRole.user
|
|
1738
|
+
});
|
|
1739
|
+
} else if (message.role === "system") {
|
|
1740
|
+
result.push({
|
|
1741
|
+
...message,
|
|
1742
|
+
role: MessageRole.system
|
|
1743
|
+
});
|
|
1744
|
+
} else if (message.role === "assistant") {
|
|
1745
|
+
result.push({
|
|
1746
|
+
...message,
|
|
1747
|
+
role: MessageRole.assistant
|
|
1748
|
+
});
|
|
1749
|
+
}
|
|
1750
|
+
continue;
|
|
1688
1751
|
}
|
|
1689
1752
|
if (message.isActionExecutionMessage()) {
|
|
1690
|
-
const
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1753
|
+
const messageId = message.parentMessageId ?? message.id;
|
|
1754
|
+
if (processedActionExecutions.has(messageId)) {
|
|
1755
|
+
continue;
|
|
1756
|
+
}
|
|
1757
|
+
processedActionExecutions.add(messageId);
|
|
1758
|
+
const relatedActionExecutions = messages.filter((m) => m.isActionExecutionMessage() && (m.parentMessageId && m.parentMessageId === messageId || m.id === messageId));
|
|
1759
|
+
const tool_calls = relatedActionExecutions.map((m) => ({
|
|
1760
|
+
name: m.name,
|
|
1761
|
+
args: m.arguments,
|
|
1762
|
+
id: m.id
|
|
1763
|
+
}));
|
|
1764
|
+
result.push({
|
|
1765
|
+
id: messageId,
|
|
1766
|
+
type: "ActionExecutionMessage",
|
|
1697
1767
|
content: "",
|
|
1698
|
-
tool_calls
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
id: message.id
|
|
1703
|
-
};
|
|
1768
|
+
tool_calls,
|
|
1769
|
+
role: MessageRole.assistant
|
|
1770
|
+
});
|
|
1771
|
+
continue;
|
|
1704
1772
|
}
|
|
1705
1773
|
if (message.isResultMessage()) {
|
|
1706
|
-
|
|
1774
|
+
result.push({
|
|
1707
1775
|
type: message.type,
|
|
1708
1776
|
content: message.result,
|
|
1709
1777
|
id: message.id,
|
|
1710
1778
|
tool_call_id: message.actionExecutionId,
|
|
1711
1779
|
name: message.actionName,
|
|
1712
1780
|
role: MessageRole.tool
|
|
1713
|
-
};
|
|
1781
|
+
});
|
|
1782
|
+
continue;
|
|
1714
1783
|
}
|
|
1715
1784
|
throw new Error(`Unknown message type ${message.type}`);
|
|
1716
|
-
}
|
|
1785
|
+
}
|
|
1786
|
+
return result;
|
|
1717
1787
|
}
|
|
1718
|
-
__name(
|
|
1788
|
+
__name(copilotkitMessagesToLangChain, "copilotkitMessagesToLangChain");
|
|
1719
1789
|
|
|
1720
1790
|
// src/lib/runtime/remote-action-constructors.ts
|
|
1721
1791
|
function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, messages, agentStates }) {
|
|
@@ -1725,7 +1795,7 @@ function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, m
|
|
|
1725
1795
|
parameters: [],
|
|
1726
1796
|
handler: async (_args) => {
|
|
1727
1797
|
},
|
|
1728
|
-
langGraphAgentHandler: async ({ name, actionInputsWithoutAgents, threadId, nodeName }) => {
|
|
1798
|
+
langGraphAgentHandler: async ({ name, actionInputsWithoutAgents, threadId, nodeName, additionalMessages = [] }) => {
|
|
1729
1799
|
var _a;
|
|
1730
1800
|
logger2.debug({
|
|
1731
1801
|
actionName: agent.name
|
|
@@ -1751,7 +1821,10 @@ function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, m
|
|
|
1751
1821
|
agent,
|
|
1752
1822
|
threadId,
|
|
1753
1823
|
nodeName,
|
|
1754
|
-
messages
|
|
1824
|
+
messages: [
|
|
1825
|
+
...messages,
|
|
1826
|
+
...additionalMessages
|
|
1827
|
+
],
|
|
1755
1828
|
state,
|
|
1756
1829
|
properties: graphqlContext.properties,
|
|
1757
1830
|
actions: actionInputsWithoutAgents.map((action) => ({
|
|
@@ -1834,7 +1907,7 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
|
|
|
1834
1907
|
parameters: [],
|
|
1835
1908
|
handler: async (_args) => {
|
|
1836
1909
|
},
|
|
1837
|
-
langGraphAgentHandler: async ({ name, actionInputsWithoutAgents, threadId, nodeName }) => {
|
|
1910
|
+
langGraphAgentHandler: async ({ name, actionInputsWithoutAgents, threadId, nodeName, additionalMessages = [] }) => {
|
|
1838
1911
|
var _a;
|
|
1839
1912
|
logger2.debug({
|
|
1840
1913
|
actionName: agent.name
|
|
@@ -1859,7 +1932,10 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
|
|
|
1859
1932
|
name,
|
|
1860
1933
|
threadId,
|
|
1861
1934
|
nodeName,
|
|
1862
|
-
messages
|
|
1935
|
+
messages: [
|
|
1936
|
+
...messages,
|
|
1937
|
+
...additionalMessages
|
|
1938
|
+
],
|
|
1863
1939
|
state,
|
|
1864
1940
|
properties: graphqlContext.properties,
|
|
1865
1941
|
actions: actionInputsWithoutAgents.map((action) => ({
|
|
@@ -2071,7 +2147,8 @@ function convertGqlInputToMessages(inputMessages) {
|
|
|
2071
2147
|
id: message.id,
|
|
2072
2148
|
createdAt: message.createdAt,
|
|
2073
2149
|
role: message.textMessage.role,
|
|
2074
|
-
content: message.textMessage.content
|
|
2150
|
+
content: message.textMessage.content,
|
|
2151
|
+
parentMessageId: message.textMessage.parentMessageId
|
|
2075
2152
|
}));
|
|
2076
2153
|
} else if (message.actionExecutionMessage) {
|
|
2077
2154
|
messages.push(plainToInstance(ActionExecutionMessage, {
|
|
@@ -2079,7 +2156,7 @@ function convertGqlInputToMessages(inputMessages) {
|
|
|
2079
2156
|
createdAt: message.createdAt,
|
|
2080
2157
|
name: message.actionExecutionMessage.name,
|
|
2081
2158
|
arguments: JSON.parse(message.actionExecutionMessage.arguments),
|
|
2082
|
-
|
|
2159
|
+
parentMessageId: message.actionExecutionMessage.parentMessageId
|
|
2083
2160
|
}));
|
|
2084
2161
|
} else if (message.resultMessage) {
|
|
2085
2162
|
messages.push(plainToInstance(ResultMessage, {
|
|
@@ -2376,6 +2453,7 @@ __name(getRuntimeInstanceTelemetryInfo, "getRuntimeInstanceTelemetryInfo");
|
|
|
2376
2453
|
var telemetry_client_default = telemetryClient;
|
|
2377
2454
|
|
|
2378
2455
|
// src/service-adapters/events.ts
|
|
2456
|
+
import { plainToInstance as plainToInstance2 } from "class-transformer";
|
|
2379
2457
|
var RuntimeEventTypes;
|
|
2380
2458
|
(function(RuntimeEventTypes2) {
|
|
2381
2459
|
RuntimeEventTypes2["TextMessageStart"] = "TextMessageStart";
|
|
@@ -2391,52 +2469,74 @@ var RuntimeEventSubject = class extends ReplaySubject2 {
|
|
|
2391
2469
|
constructor() {
|
|
2392
2470
|
super();
|
|
2393
2471
|
}
|
|
2394
|
-
sendTextMessageStart(messageId) {
|
|
2472
|
+
sendTextMessageStart({ messageId, parentMessageId }) {
|
|
2395
2473
|
this.next({
|
|
2396
2474
|
type: "TextMessageStart",
|
|
2397
|
-
messageId
|
|
2475
|
+
messageId,
|
|
2476
|
+
parentMessageId
|
|
2398
2477
|
});
|
|
2399
2478
|
}
|
|
2400
|
-
sendTextMessageContent(content) {
|
|
2479
|
+
sendTextMessageContent({ messageId, content }) {
|
|
2401
2480
|
this.next({
|
|
2402
2481
|
type: "TextMessageContent",
|
|
2403
|
-
content
|
|
2482
|
+
content,
|
|
2483
|
+
messageId
|
|
2404
2484
|
});
|
|
2405
2485
|
}
|
|
2406
|
-
sendTextMessageEnd() {
|
|
2486
|
+
sendTextMessageEnd({ messageId }) {
|
|
2407
2487
|
this.next({
|
|
2408
|
-
type: "TextMessageEnd"
|
|
2488
|
+
type: "TextMessageEnd",
|
|
2489
|
+
messageId
|
|
2409
2490
|
});
|
|
2410
2491
|
}
|
|
2411
2492
|
sendTextMessage(messageId, content) {
|
|
2412
|
-
this.sendTextMessageStart(
|
|
2413
|
-
|
|
2414
|
-
|
|
2493
|
+
this.sendTextMessageStart({
|
|
2494
|
+
messageId
|
|
2495
|
+
});
|
|
2496
|
+
this.sendTextMessageContent({
|
|
2497
|
+
messageId,
|
|
2498
|
+
content
|
|
2499
|
+
});
|
|
2500
|
+
this.sendTextMessageEnd({
|
|
2501
|
+
messageId
|
|
2502
|
+
});
|
|
2415
2503
|
}
|
|
2416
|
-
sendActionExecutionStart(actionExecutionId, actionName) {
|
|
2504
|
+
sendActionExecutionStart({ actionExecutionId, actionName, parentMessageId }) {
|
|
2417
2505
|
this.next({
|
|
2418
2506
|
type: "ActionExecutionStart",
|
|
2419
2507
|
actionExecutionId,
|
|
2420
|
-
actionName
|
|
2508
|
+
actionName,
|
|
2509
|
+
parentMessageId
|
|
2421
2510
|
});
|
|
2422
2511
|
}
|
|
2423
|
-
sendActionExecutionArgs(args) {
|
|
2512
|
+
sendActionExecutionArgs({ actionExecutionId, args }) {
|
|
2424
2513
|
this.next({
|
|
2425
2514
|
type: "ActionExecutionArgs",
|
|
2426
|
-
args
|
|
2515
|
+
args,
|
|
2516
|
+
actionExecutionId
|
|
2427
2517
|
});
|
|
2428
2518
|
}
|
|
2429
|
-
sendActionExecutionEnd() {
|
|
2519
|
+
sendActionExecutionEnd({ actionExecutionId }) {
|
|
2430
2520
|
this.next({
|
|
2431
|
-
type: "ActionExecutionEnd"
|
|
2521
|
+
type: "ActionExecutionEnd",
|
|
2522
|
+
actionExecutionId
|
|
2432
2523
|
});
|
|
2433
2524
|
}
|
|
2434
|
-
sendActionExecution(actionExecutionId,
|
|
2435
|
-
this.sendActionExecutionStart(
|
|
2436
|
-
|
|
2437
|
-
|
|
2525
|
+
sendActionExecution({ actionExecutionId, actionName, args, parentMessageId }) {
|
|
2526
|
+
this.sendActionExecutionStart({
|
|
2527
|
+
actionExecutionId,
|
|
2528
|
+
actionName,
|
|
2529
|
+
parentMessageId
|
|
2530
|
+
});
|
|
2531
|
+
this.sendActionExecutionArgs({
|
|
2532
|
+
actionExecutionId,
|
|
2533
|
+
args
|
|
2534
|
+
});
|
|
2535
|
+
this.sendActionExecutionEnd({
|
|
2536
|
+
actionExecutionId
|
|
2537
|
+
});
|
|
2438
2538
|
}
|
|
2439
|
-
sendActionExecutionResult(actionExecutionId, actionName, result) {
|
|
2539
|
+
sendActionExecutionResult({ actionExecutionId, actionName, result }) {
|
|
2440
2540
|
this.next({
|
|
2441
2541
|
type: "ActionExecutionResult",
|
|
2442
2542
|
actionName,
|
|
@@ -2444,7 +2544,7 @@ var RuntimeEventSubject = class extends ReplaySubject2 {
|
|
|
2444
2544
|
result
|
|
2445
2545
|
});
|
|
2446
2546
|
}
|
|
2447
|
-
sendAgentStateMessage(threadId, agentName, nodeName, runId, active, role, state, running) {
|
|
2547
|
+
sendAgentStateMessage({ threadId, agentName, nodeName, runId, active, role, state, running }) {
|
|
2448
2548
|
this.next({
|
|
2449
2549
|
type: "AgentStateMessage",
|
|
2450
2550
|
threadId,
|
|
@@ -2481,27 +2581,19 @@ var RuntimeEventSource = class {
|
|
|
2481
2581
|
this.sendErrorMessageToChat();
|
|
2482
2582
|
});
|
|
2483
2583
|
return this.eventStream$.pipe(
|
|
2484
|
-
// mark tools for server side execution
|
|
2485
|
-
map((event) => {
|
|
2486
|
-
if (event.type === "ActionExecutionStart") {
|
|
2487
|
-
if (event.scope !== "passThrough") {
|
|
2488
|
-
event.scope = serverSideActions.find((action) => action.name === event.actionName) ? "server" : "client";
|
|
2489
|
-
}
|
|
2490
|
-
}
|
|
2491
|
-
return event;
|
|
2492
|
-
}),
|
|
2493
2584
|
// track state
|
|
2494
2585
|
scan2((acc, event) => {
|
|
2495
2586
|
acc = {
|
|
2496
2587
|
...acc
|
|
2497
2588
|
};
|
|
2498
2589
|
if (event.type === "ActionExecutionStart") {
|
|
2499
|
-
acc.callActionServerSide =
|
|
2590
|
+
acc.callActionServerSide = serverSideActions.find((action) => action.name === event.actionName) !== void 0;
|
|
2500
2591
|
acc.args = "";
|
|
2501
2592
|
acc.actionExecutionId = event.actionExecutionId;
|
|
2502
2593
|
if (acc.callActionServerSide) {
|
|
2503
2594
|
acc.action = serverSideActions.find((action) => action.name === event.actionName);
|
|
2504
2595
|
}
|
|
2596
|
+
acc.actionExecutionParentMessageId = event.parentMessageId;
|
|
2505
2597
|
} else if (event.type === "ActionExecutionArgs") {
|
|
2506
2598
|
acc.args += event.args;
|
|
2507
2599
|
}
|
|
@@ -2512,12 +2604,13 @@ var RuntimeEventSource = class {
|
|
|
2512
2604
|
callActionServerSide: false,
|
|
2513
2605
|
args: "",
|
|
2514
2606
|
actionExecutionId: null,
|
|
2515
|
-
action: null
|
|
2607
|
+
action: null,
|
|
2608
|
+
actionExecutionParentMessageId: null
|
|
2516
2609
|
}),
|
|
2517
2610
|
concatMap((eventWithState) => {
|
|
2518
2611
|
if (eventWithState.event.type === "ActionExecutionEnd" && eventWithState.callActionServerSide) {
|
|
2519
2612
|
const toolCallEventStream$ = new RuntimeEventSubject();
|
|
2520
|
-
executeAction(toolCallEventStream$, guardrailsResult$ ? guardrailsResult$ : null, eventWithState.action, eventWithState.args, eventWithState.actionExecutionId, actionInputsWithoutAgents).catch((error) => {
|
|
2613
|
+
executeAction(toolCallEventStream$, guardrailsResult$ ? guardrailsResult$ : null, eventWithState.action, eventWithState.args, eventWithState.actionExecutionParentMessageId, eventWithState.actionExecutionId, actionInputsWithoutAgents).catch((error) => {
|
|
2521
2614
|
console.error(error);
|
|
2522
2615
|
});
|
|
2523
2616
|
telemetry_client_default.capture("oss.runtime.server_action_executed", {});
|
|
@@ -2530,7 +2623,7 @@ var RuntimeEventSource = class {
|
|
|
2530
2623
|
}
|
|
2531
2624
|
};
|
|
2532
2625
|
__name(RuntimeEventSource, "RuntimeEventSource");
|
|
2533
|
-
async function executeAction(eventStream$, guardrailsResult$, action, actionArguments, actionExecutionId, actionInputsWithoutAgents) {
|
|
2626
|
+
async function executeAction(eventStream$, guardrailsResult$, action, actionArguments, actionExecutionParentMessageId, actionExecutionId, actionInputsWithoutAgents) {
|
|
2534
2627
|
var _a;
|
|
2535
2628
|
if (guardrailsResult$) {
|
|
2536
2629
|
const { status } = await firstValueFrom(guardrailsResult$);
|
|
@@ -2550,10 +2643,33 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
|
|
|
2550
2643
|
}
|
|
2551
2644
|
}
|
|
2552
2645
|
if (isLangGraphAgentAction(action)) {
|
|
2553
|
-
|
|
2646
|
+
const result = `${action.name} agent started`;
|
|
2647
|
+
const agentExecution = plainToInstance2(ActionExecutionMessage, {
|
|
2648
|
+
id: actionExecutionId,
|
|
2649
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
2650
|
+
name: action.name,
|
|
2651
|
+
arguments: JSON.parse(actionArguments),
|
|
2652
|
+
parentMessageId: actionExecutionParentMessageId ?? actionExecutionId
|
|
2653
|
+
});
|
|
2654
|
+
const agentExecutionResult = plainToInstance2(ResultMessage, {
|
|
2655
|
+
id: "result-" + actionExecutionId,
|
|
2656
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
2657
|
+
actionExecutionId,
|
|
2658
|
+
actionName: action.name,
|
|
2659
|
+
result
|
|
2660
|
+
});
|
|
2661
|
+
eventStream$.sendActionExecutionResult({
|
|
2662
|
+
actionExecutionId,
|
|
2663
|
+
actionName: action.name,
|
|
2664
|
+
result
|
|
2665
|
+
});
|
|
2554
2666
|
const stream = await action.langGraphAgentHandler({
|
|
2555
2667
|
name: action.name,
|
|
2556
|
-
actionInputsWithoutAgents
|
|
2668
|
+
actionInputsWithoutAgents,
|
|
2669
|
+
additionalMessages: [
|
|
2670
|
+
agentExecution,
|
|
2671
|
+
agentExecutionResult
|
|
2672
|
+
]
|
|
2557
2673
|
});
|
|
2558
2674
|
from2(stream).subscribe({
|
|
2559
2675
|
next: (event) => eventStream$.next(event),
|
|
@@ -2576,7 +2692,7 @@ __name(executeAction, "executeAction");
|
|
|
2576
2692
|
|
|
2577
2693
|
// src/graphql/resolvers/copilot.resolver.ts
|
|
2578
2694
|
import { GraphQLJSONObject } from "graphql-scalars";
|
|
2579
|
-
import { plainToInstance as
|
|
2695
|
+
import { plainToInstance as plainToInstance3 } from "class-transformer";
|
|
2580
2696
|
import { GraphQLError } from "graphql";
|
|
2581
2697
|
import { randomId as randomId3 } from "@copilotkit/shared";
|
|
2582
2698
|
function _ts_decorate12(decorators, target, key, desc) {
|
|
@@ -2739,7 +2855,7 @@ var CopilotResolver = class {
|
|
|
2739
2855
|
reason: `Interrupted due to Guardrails validation failure. Reason: ${result.reason}`
|
|
2740
2856
|
});
|
|
2741
2857
|
outputMessages = [
|
|
2742
|
-
|
|
2858
|
+
plainToInstance3(TextMessage, {
|
|
2743
2859
|
id: randomId3(),
|
|
2744
2860
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2745
2861
|
content: result.reason,
|
|
@@ -2788,12 +2904,15 @@ var CopilotResolver = class {
|
|
|
2788
2904
|
// skip until this message start event
|
|
2789
2905
|
skipWhile((e) => e !== event),
|
|
2790
2906
|
// take until the message end event
|
|
2791
|
-
takeWhile((e) => e.type
|
|
2907
|
+
takeWhile((e) => !(e.type === RuntimeEventTypes.TextMessageEnd && e.messageId == event.messageId)),
|
|
2908
|
+
// filter out any other message events or message ids
|
|
2909
|
+
filter((e) => e.type == RuntimeEventTypes.TextMessageContent && e.messageId == event.messageId)
|
|
2792
2910
|
);
|
|
2793
2911
|
const streamingTextStatus = new Subject();
|
|
2794
2912
|
const messageId = event.messageId;
|
|
2795
2913
|
pushMessage({
|
|
2796
2914
|
id: messageId,
|
|
2915
|
+
parentMessageId: event.parentMessageId,
|
|
2797
2916
|
status: firstValueFrom2(streamingTextStatus),
|
|
2798
2917
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2799
2918
|
role: MessageRole.assistant,
|
|
@@ -2806,7 +2925,7 @@ var CopilotResolver = class {
|
|
|
2806
2925
|
reason,
|
|
2807
2926
|
messageId: messageId2
|
|
2808
2927
|
}, "Text streaming interrupted");
|
|
2809
|
-
streamingTextStatus.next(
|
|
2928
|
+
streamingTextStatus.next(plainToInstance3(FailedMessageStatus, {
|
|
2810
2929
|
reason
|
|
2811
2930
|
}));
|
|
2812
2931
|
responseStatus$.next(new MessageStreamInterruptedResponse({
|
|
@@ -2839,7 +2958,7 @@ var CopilotResolver = class {
|
|
|
2839
2958
|
streamingTextStatus.next(new SuccessMessageStatus());
|
|
2840
2959
|
stopStreamingText();
|
|
2841
2960
|
textSubscription == null ? void 0 : textSubscription.unsubscribe();
|
|
2842
|
-
outputMessages.push(
|
|
2961
|
+
outputMessages.push(plainToInstance3(TextMessage, {
|
|
2843
2962
|
id: messageId,
|
|
2844
2963
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2845
2964
|
content: textChunks.join(""),
|
|
@@ -2852,14 +2971,20 @@ var CopilotResolver = class {
|
|
|
2852
2971
|
break;
|
|
2853
2972
|
case RuntimeEventTypes.ActionExecutionStart:
|
|
2854
2973
|
logger2.debug("Action execution start event received");
|
|
2855
|
-
const actionExecutionArgumentStream = eventStream.pipe(
|
|
2974
|
+
const actionExecutionArgumentStream = eventStream.pipe(
|
|
2975
|
+
skipWhile((e) => e !== event),
|
|
2976
|
+
// take until the action execution end event
|
|
2977
|
+
takeWhile((e) => !(e.type === RuntimeEventTypes.ActionExecutionEnd && e.actionExecutionId == event.actionExecutionId)),
|
|
2978
|
+
// filter out any other action execution events or action execution ids
|
|
2979
|
+
filter((e) => e.type == RuntimeEventTypes.ActionExecutionArgs && e.actionExecutionId == event.actionExecutionId)
|
|
2980
|
+
);
|
|
2856
2981
|
const streamingArgumentsStatus = new Subject();
|
|
2857
2982
|
pushMessage({
|
|
2858
2983
|
id: event.actionExecutionId,
|
|
2984
|
+
parentMessageId: event.parentMessageId,
|
|
2859
2985
|
status: firstValueFrom2(streamingArgumentsStatus),
|
|
2860
2986
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2861
2987
|
name: event.actionName,
|
|
2862
|
-
scope: event.scope,
|
|
2863
2988
|
arguments: new Repeater(async (pushArgumentsChunk, stopStreamingArguments) => {
|
|
2864
2989
|
logger2.debug("Action execution argument stream created");
|
|
2865
2990
|
const argumentChunks = [];
|
|
@@ -2875,7 +3000,7 @@ var CopilotResolver = class {
|
|
|
2875
3000
|
logger2.error({
|
|
2876
3001
|
err
|
|
2877
3002
|
}, "Error in action execution argument stream");
|
|
2878
|
-
streamingArgumentsStatus.next(
|
|
3003
|
+
streamingArgumentsStatus.next(plainToInstance3(FailedMessageStatus, {
|
|
2879
3004
|
reason: "An unknown error has occurred in the action execution argument stream"
|
|
2880
3005
|
}));
|
|
2881
3006
|
stopStreamingArguments();
|
|
@@ -2886,11 +3011,10 @@ var CopilotResolver = class {
|
|
|
2886
3011
|
streamingArgumentsStatus.next(new SuccessMessageStatus());
|
|
2887
3012
|
stopStreamingArguments();
|
|
2888
3013
|
actionExecutionArgumentSubscription == null ? void 0 : actionExecutionArgumentSubscription.unsubscribe();
|
|
2889
|
-
outputMessages.push(
|
|
3014
|
+
outputMessages.push(plainToInstance3(ActionExecutionMessage, {
|
|
2890
3015
|
id: event.actionExecutionId,
|
|
2891
3016
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2892
3017
|
name: event.actionName,
|
|
2893
|
-
scope: event.scope,
|
|
2894
3018
|
arguments: argumentChunks.join("")
|
|
2895
3019
|
}));
|
|
2896
3020
|
}
|
|
@@ -2903,15 +3027,15 @@ var CopilotResolver = class {
|
|
|
2903
3027
|
result: event.result
|
|
2904
3028
|
}, "Action execution result event received");
|
|
2905
3029
|
pushMessage({
|
|
2906
|
-
id:
|
|
3030
|
+
id: "result-" + event.actionExecutionId,
|
|
2907
3031
|
status: new SuccessMessageStatus(),
|
|
2908
3032
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2909
3033
|
actionExecutionId: event.actionExecutionId,
|
|
2910
3034
|
actionName: event.actionName,
|
|
2911
3035
|
result: event.result
|
|
2912
3036
|
});
|
|
2913
|
-
outputMessages.push(
|
|
2914
|
-
id:
|
|
3037
|
+
outputMessages.push(plainToInstance3(ResultMessage, {
|
|
3038
|
+
id: "result-" + event.actionExecutionId,
|
|
2915
3039
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2916
3040
|
actionExecutionId: event.actionExecutionId,
|
|
2917
3041
|
actionName: event.actionName,
|
|
@@ -2935,7 +3059,7 @@ var CopilotResolver = class {
|
|
|
2935
3059
|
role: MessageRole.assistant,
|
|
2936
3060
|
createdAt: /* @__PURE__ */ new Date()
|
|
2937
3061
|
});
|
|
2938
|
-
outputMessages.push(
|
|
3062
|
+
outputMessages.push(plainToInstance3(AgentStateMessage, {
|
|
2939
3063
|
id: randomId3(),
|
|
2940
3064
|
threadId: event.threadId,
|
|
2941
3065
|
agentName: event.agentName,
|
|
@@ -3147,4 +3271,4 @@ export {
|
|
|
3147
3271
|
getCommonConfig,
|
|
3148
3272
|
copilotRuntimeNodeHttpEndpoint
|
|
3149
3273
|
};
|
|
3150
|
-
//# sourceMappingURL=chunk-
|
|
3274
|
+
//# sourceMappingURL=chunk-PXS4SBRF.mjs.map
|