@copilotkit/runtime 1.3.12-lgc-alpha-1.0 → 1.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/CHANGELOG.md +4 -3
  2. package/dist/{chunk-7MQDBRXJ.mjs → chunk-24WEOOFX.mjs} +2 -2
  3. package/dist/{chunk-E6ZFCM3B.mjs → chunk-F2KJWMGD.mjs} +133 -561
  4. package/dist/chunk-F2KJWMGD.mjs.map +1 -0
  5. package/dist/{chunk-6HXQC7IT.mjs → chunk-IXVCESAR.mjs} +9 -36
  6. package/dist/chunk-IXVCESAR.mjs.map +1 -0
  7. package/dist/{chunk-TM7ZRU3M.mjs → chunk-IZP72K7I.mjs} +2 -2
  8. package/dist/{chunk-6B3NPPSR.mjs → chunk-PRG6VWHR.mjs} +2 -2
  9. package/dist/{chunk-XMDH5MKI.mjs → chunk-WBLYFYMZ.mjs} +2 -2
  10. package/dist/{chunk-V7SK6QZN.mjs → chunk-ZEHCLFJ2.mjs} +9 -6
  11. package/dist/chunk-ZEHCLFJ2.mjs.map +1 -0
  12. package/dist/{copilot-runtime-aba7d4b4.d.ts → copilot-runtime-df3527ad.d.ts} +5 -27
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.js +186 -638
  15. package/dist/index.js.map +1 -1
  16. package/dist/index.mjs +9 -13
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/lib/index.d.ts +1 -1
  19. package/dist/lib/index.js +186 -638
  20. package/dist/lib/index.js.map +1 -1
  21. package/dist/lib/index.mjs +9 -13
  22. package/dist/lib/integrations/index.d.ts +2 -2
  23. package/dist/lib/integrations/index.js +4 -5
  24. package/dist/lib/integrations/index.js.map +1 -1
  25. package/dist/lib/integrations/index.mjs +5 -5
  26. package/dist/lib/integrations/nest/index.d.ts +1 -1
  27. package/dist/lib/integrations/nest/index.js +4 -5
  28. package/dist/lib/integrations/nest/index.js.map +1 -1
  29. package/dist/lib/integrations/nest/index.mjs +3 -3
  30. package/dist/lib/integrations/node-express/index.d.ts +1 -1
  31. package/dist/lib/integrations/node-express/index.js +4 -5
  32. package/dist/lib/integrations/node-express/index.js.map +1 -1
  33. package/dist/lib/integrations/node-express/index.mjs +3 -3
  34. package/dist/lib/integrations/node-http/index.d.ts +1 -1
  35. package/dist/lib/integrations/node-http/index.js +4 -5
  36. package/dist/lib/integrations/node-http/index.js.map +1 -1
  37. package/dist/lib/integrations/node-http/index.mjs +2 -2
  38. package/dist/service-adapters/index.js +8 -5
  39. package/dist/service-adapters/index.js.map +1 -1
  40. package/dist/service-adapters/index.mjs +2 -2
  41. package/package.json +6 -7
  42. package/src/agents/langgraph/event-source.ts +67 -22
  43. package/src/lib/runtime/copilot-runtime.ts +11 -58
  44. package/src/lib/runtime/remote-actions.ts +159 -65
  45. package/src/service-adapters/events.ts +5 -1
  46. package/src/service-adapters/langchain/utils.test.ts +169 -0
  47. package/src/service-adapters/langchain/utils.ts +10 -5
  48. package/dist/chunk-6HXQC7IT.mjs.map +0 -1
  49. package/dist/chunk-E6ZFCM3B.mjs.map +0 -1
  50. package/dist/chunk-V7SK6QZN.mjs.map +0 -1
  51. package/src/lib/runtime/remote-action-constructors.ts +0 -283
  52. package/src/lib/runtime/remote-lg-cloud-action.ts +0 -441
  53. /package/dist/{chunk-7MQDBRXJ.mjs.map → chunk-24WEOOFX.mjs.map} +0 -0
  54. /package/dist/{chunk-TM7ZRU3M.mjs.map → chunk-IZP72K7I.mjs.map} +0 -0
  55. /package/dist/{chunk-6B3NPPSR.mjs.map → chunk-PRG6VWHR.mjs.map} +0 -0
  56. /package/dist/{chunk-XMDH5MKI.mjs.map → chunk-WBLYFYMZ.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.3.12-lgc-alpha-1.0",
47
+ version: "1.3.12",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -77,16 +77,16 @@ var require_package = __commonJS({
77
77
  "ts-node": "^10.9.2",
78
78
  tsconfig: "workspace:*",
79
79
  tsup: "^6.7.0",
80
- typescript: "^5.2.3"
80
+ typescript: "^5.2.3",
81
+ "zod-to-json-schema": "^3.23.5"
81
82
  },
82
83
  dependencies: {
83
84
  "@anthropic-ai/sdk": "^0.27.3",
84
85
  "@copilotkit/shared": "workspace:*",
85
- "@langchain/google-gauth": "^0.1.0",
86
86
  "@graphql-yoga/plugin-defer-stream": "^3.3.1",
87
87
  "@langchain/community": "^0.0.53",
88
88
  "@langchain/core": "^0.3.13",
89
- "@langchain/langgraph-sdk": "^0.0.16",
89
+ "@langchain/google-gauth": "^0.1.0",
90
90
  "@langchain/openai": "^0.0.28",
91
91
  "class-transformer": "^0.5.1",
92
92
  express: "^4.19.2",
@@ -96,7 +96,6 @@ var require_package = __commonJS({
96
96
  "groq-sdk": "^0.5.0",
97
97
  langchain: "^0.3.3",
98
98
  openai: "^4.50.0",
99
- "partial-json": "^0.1.7",
100
99
  pino: "^9.2.0",
101
100
  "pino-pretty": "^11.2.1",
102
101
  "reflect-metadata": "^0.2.2",
@@ -132,7 +131,6 @@ __export(lib_exports, {
132
131
  UnifyAdapter: () => UnifyAdapter,
133
132
  buildSchema: () => buildSchema,
134
133
  config: () => config,
135
- copilotKitEndpoint: () => copilotKitEndpoint,
136
134
  copilotRuntimeNestEndpoint: () => copilotRuntimeNestEndpoint,
137
135
  copilotRuntimeNextJSAppRouterEndpoint: () => copilotRuntimeNextJSAppRouterEndpoint,
138
136
  copilotRuntimeNextJSPagesRouterEndpoint: () => copilotRuntimeNextJSPagesRouterEndpoint,
@@ -140,8 +138,7 @@ __export(lib_exports, {
140
138
  copilotRuntimeNodeHttpEndpoint: () => copilotRuntimeNodeHttpEndpoint,
141
139
  createContext: () => createContext,
142
140
  flattenToolCallsNoDuplicates: () => flattenToolCallsNoDuplicates,
143
- getCommonConfig: () => getCommonConfig,
144
- langGraphCloudEndpoint: () => langGraphCloudEndpoint
141
+ getCommonConfig: () => getCommonConfig
145
142
  });
146
143
  module.exports = __toCommonJS(lib_exports);
147
144
 
@@ -497,24 +494,27 @@ __name(convertMessageToLangChainMessage, "convertMessageToLangChainMessage");
497
494
  function convertJsonSchemaToZodSchema(jsonSchema, required) {
498
495
  if (jsonSchema.type === "object") {
499
496
  const spec = {};
497
+ if (!jsonSchema.properties || !Object.keys(jsonSchema.properties).length) {
498
+ return !required ? import_zod.z.object(spec).optional() : import_zod.z.object(spec);
499
+ }
500
500
  for (const [key, value] of Object.entries(jsonSchema.properties)) {
501
501
  spec[key] = convertJsonSchemaToZodSchema(value, jsonSchema.required ? jsonSchema.required.includes(key) : false);
502
502
  }
503
503
  let schema = import_zod.z.object(spec);
504
- return !required ? schema.optional() : schema;
504
+ return required ? schema : schema.optional();
505
505
  } else if (jsonSchema.type === "string") {
506
506
  let schema = import_zod.z.string().describe(jsonSchema.description);
507
- return !required ? schema.optional() : schema;
507
+ return required ? schema : schema.optional();
508
508
  } else if (jsonSchema.type === "number") {
509
509
  let schema = import_zod.z.number().describe(jsonSchema.description);
510
- return !required ? schema.optional() : schema;
510
+ return required ? schema : schema.optional();
511
511
  } else if (jsonSchema.type === "boolean") {
512
512
  let schema = import_zod.z.boolean().describe(jsonSchema.description);
513
- return !required ? schema.optional() : schema;
513
+ return required ? schema : schema.optional();
514
514
  } else if (jsonSchema.type === "array") {
515
515
  let itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true);
516
516
  let schema = import_zod.z.array(itemSchema);
517
- return !required ? schema.optional() : schema;
517
+ return required ? schema : schema.optional();
518
518
  }
519
519
  }
520
520
  __name(convertJsonSchemaToZodSchema, "convertJsonSchemaToZodSchema");
@@ -1068,6 +1068,50 @@ var LangGraphEventTypes;
1068
1068
  var import_shared7 = require("@copilotkit/shared");
1069
1069
  var RemoteLangGraphEventSource = class {
1070
1070
  eventStream$ = new import_rxjs.ReplaySubject();
1071
+ async streamResponse(response) {
1072
+ const reader = response.body.getReader();
1073
+ const decoder = new TextDecoder();
1074
+ let buffer = [];
1075
+ const eventStream$ = this.eventStream$;
1076
+ function flushBuffer() {
1077
+ const currentBuffer = buffer.join("");
1078
+ if (currentBuffer.trim().length === 0) {
1079
+ return;
1080
+ }
1081
+ const parts = currentBuffer.split("\n");
1082
+ if (parts.length === 0) {
1083
+ return;
1084
+ }
1085
+ const lastPartIsComplete = currentBuffer.endsWith("\n");
1086
+ buffer = [];
1087
+ if (!lastPartIsComplete) {
1088
+ buffer.push(parts.pop());
1089
+ }
1090
+ parts.map((part) => part.trim()).filter((part) => part != "").forEach((part) => {
1091
+ eventStream$.next(JSON.parse(part));
1092
+ });
1093
+ }
1094
+ __name(flushBuffer, "flushBuffer");
1095
+ try {
1096
+ while (true) {
1097
+ const { done, value } = await reader.read();
1098
+ if (!done) {
1099
+ buffer.push(decoder.decode(value, {
1100
+ stream: true
1101
+ }));
1102
+ }
1103
+ flushBuffer();
1104
+ if (done) {
1105
+ break;
1106
+ }
1107
+ }
1108
+ } catch (error) {
1109
+ console.error("Error in stream", error);
1110
+ eventStream$.error(error);
1111
+ return;
1112
+ }
1113
+ eventStream$.complete();
1114
+ }
1071
1115
  shouldEmitToolCall(shouldEmitToolCalls, toolCallName) {
1072
1116
  if (typeof shouldEmitToolCalls === "boolean") {
1073
1117
  return shouldEmitToolCalls;
@@ -1090,25 +1134,20 @@ var RemoteLangGraphEventSource = class {
1090
1134
  } else {
1091
1135
  acc.content = null;
1092
1136
  }
1093
- const toolCallChunks = (
1094
- // @ts-expect-error -- LangGraph Cloud implementation stores data outside of kwargs
1095
- ((_h = (_g = (_f = event.data) == null ? void 0 : _f.chunk) == null ? void 0 : _g.kwargs) == null ? void 0 : _h.tool_call_chunks) ?? ((_j = (_i = event.data) == null ? void 0 : _i.chunk) == null ? void 0 : _j.tool_call_chunks)
1096
- );
1097
- const toolCallMessageId = ((_m = (_l = (_k = event.data) == null ? void 0 : _k.chunk) == null ? void 0 : _l.kwargs) == null ? void 0 : _m.id) ?? ((_o = (_n = event.data) == null ? void 0 : _n.chunk) == null ? void 0 : _o.id);
1098
- if (toolCallChunks && toolCallChunks.length > 0) {
1137
+ if ((_h = (_g = (_f = event.data) == null ? void 0 : _f.chunk) == null ? void 0 : _g.kwargs) == null ? void 0 : _h.tool_call_chunks) {
1099
1138
  acc.prevToolCallMessageId = acc.toolCallMessageId;
1100
- acc.toolCallMessageId = toolCallMessageId;
1101
- if ((_p = toolCallChunks[0]) == null ? void 0 : _p.name) {
1102
- acc.toolCallName = toolCallChunks[0].name;
1139
+ acc.toolCallMessageId = (_i = event.data.chunk.kwargs) == null ? void 0 : _i.id;
1140
+ if ((_j = event.data.chunk.kwargs.tool_call_chunks[0]) == null ? void 0 : _j.name) {
1141
+ acc.toolCallName = event.data.chunk.kwargs.tool_call_chunks[0].name;
1103
1142
  }
1104
- if ((_q = toolCallChunks[0]) == null ? void 0 : _q.id) {
1105
- acc.toolCallId = toolCallChunks[0].id;
1143
+ if ((_k = event.data.chunk.kwargs.tool_call_chunks[0]) == null ? void 0 : _k.id) {
1144
+ acc.toolCallId = event.data.chunk.kwargs.tool_call_chunks[0].id;
1106
1145
  }
1107
1146
  acc.prevMessageId = acc.messageId;
1108
- acc.messageId = toolCallMessageId;
1147
+ acc.messageId = (_n = (_m = (_l = event.data) == null ? void 0 : _l.chunk) == null ? void 0 : _m.kwargs) == null ? void 0 : _n.id;
1109
1148
  } else if (acc.content && acc.content != "") {
1110
1149
  acc.prevMessageId = acc.messageId;
1111
- acc.messageId = toolCallMessageId;
1150
+ acc.messageId = (_q = (_p = (_o = event.data) == null ? void 0 : _o.chunk) == null ? void 0 : _p.kwargs) == null ? void 0 : _q.id;
1112
1151
  } else {
1113
1152
  acc.prevToolCallMessageId = acc.toolCallMessageId;
1114
1153
  acc.prevMessageId = acc.messageId;
@@ -1133,7 +1172,7 @@ var RemoteLangGraphEventSource = class {
1133
1172
  prevMessageId: null,
1134
1173
  content: null
1135
1174
  }), (0, import_rxjs.mergeMap)((eventWithState) => {
1136
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1175
+ var _a, _b, _c, _d, _e;
1137
1176
  const events = [];
1138
1177
  let shouldEmitMessages = true;
1139
1178
  let shouldEmitToolCalls = false;
@@ -1216,8 +1255,7 @@ var RemoteLangGraphEventSource = class {
1216
1255
  });
1217
1256
  }
1218
1257
  }
1219
- const args = ((_e = (_d = (_c = (_b = (_a = eventWithState.event.data) == null ? void 0 : _a.chunk) == null ? void 0 : _b.kwargs) == null ? void 0 : _c.tool_call_chunks) == null ? void 0 : _d[0]) == null ? void 0 : _e.args) ?? // @ts-expect-error -- sdf
1220
- ((_i = (_h = (_g = (_f = eventWithState.event.data) == null ? void 0 : _f.chunk) == null ? void 0 : _g.tool_call_chunks) == null ? void 0 : _h[0]) == null ? void 0 : _i.args);
1258
+ const args = (_e = (_d = (_c = (_b = (_a = eventWithState.event.data) == null ? void 0 : _a.chunk) == null ? void 0 : _b.kwargs) == null ? void 0 : _c.tool_call_chunks) == null ? void 0 : _d[0]) == null ? void 0 : _e.args;
1221
1259
  const content = eventWithState.content;
1222
1260
  if (args) {
1223
1261
  if (this.shouldEmitToolCall(shouldEmitToolCalls, eventWithState.toolCallName)) {
@@ -1268,446 +1306,70 @@ var RemoteLangGraphEventSource = class {
1268
1306
  };
1269
1307
  __name(RemoteLangGraphEventSource, "RemoteLangGraphEventSource");
1270
1308
 
1271
- // src/lib/runtime/remote-lg-cloud-action.ts
1272
- var import_langgraph_sdk = require("@langchain/langgraph-sdk");
1273
- var import_node_crypto = require("crypto");
1274
- var import_partial_json = require("partial-json");
1275
-
1276
- // src/graphql/types/enums.ts
1277
- var import_type_graphql = require("type-graphql");
1278
- var MessageRole;
1279
- (function(MessageRole2) {
1280
- MessageRole2["user"] = "user";
1281
- MessageRole2["assistant"] = "assistant";
1282
- MessageRole2["system"] = "system";
1283
- })(MessageRole || (MessageRole = {}));
1284
- var ActionExecutionScope;
1285
- (function(ActionExecutionScope2) {
1286
- ActionExecutionScope2["server"] = "server";
1287
- ActionExecutionScope2["client"] = "client";
1288
- ActionExecutionScope2["passThrough"] = "passThrough";
1289
- })(ActionExecutionScope || (ActionExecutionScope = {}));
1290
- var CopilotRequestType;
1291
- (function(CopilotRequestType2) {
1292
- CopilotRequestType2["Chat"] = "Chat";
1293
- CopilotRequestType2["Task"] = "Task";
1294
- CopilotRequestType2["TextareaCompletion"] = "TextareaCompletion";
1295
- CopilotRequestType2["TextareaPopover"] = "TextareaPopover";
1296
- CopilotRequestType2["Suggestion"] = "Suggestion";
1297
- })(CopilotRequestType || (CopilotRequestType = {}));
1298
- (0, import_type_graphql.registerEnumType)(MessageRole, {
1299
- name: "MessageRole",
1300
- description: "The role of the message"
1301
- });
1302
- (0, import_type_graphql.registerEnumType)(ActionExecutionScope, {
1303
- name: "ActionExecutionScope",
1304
- description: "The scope of the action"
1305
- });
1306
- (0, import_type_graphql.registerEnumType)(CopilotRequestType, {
1307
- name: "CopilotRequestType",
1308
- description: "The type of Copilot request"
1309
- });
1310
-
1311
- // src/lib/runtime/remote-lg-cloud-action.ts
1312
- async function execute(args) {
1313
- return new ReadableStream({
1314
- async start(controller) {
1315
- try {
1316
- await streamEvents(controller, args);
1317
- controller.close();
1318
- } catch (err) {
1319
- }
1320
- }
1321
- });
1322
- }
1323
- __name(execute, "execute");
1324
- async function streamEvents(controller, args) {
1325
- const { deploymentUrl, langsmithApiKey, threadId: agrsInitialThreadId, agent, nodeName: initialNodeName, state: initialState, messages, actions } = args;
1326
- let nodeName = initialNodeName;
1327
- let state = initialState;
1328
- const { name, assistantId: initialAssistantId } = agent;
1329
- const client = new import_langgraph_sdk.Client({
1330
- apiUrl: deploymentUrl,
1331
- apiKey: langsmithApiKey
1332
- });
1333
- let initialThreadId = agrsInitialThreadId;
1334
- const wasInitiatedWithExistingThread = !!initialThreadId;
1335
- if (initialThreadId && initialThreadId.startsWith("ck-")) {
1336
- initialThreadId = initialThreadId.substring(3);
1337
- }
1338
- const assistants = await client.assistants.search();
1339
- const retrievedAssistant = assistants.find((a) => a.name === name);
1340
- const threadId = initialThreadId ?? (0, import_node_crypto.randomUUID)();
1341
- if (initialThreadId === threadId) {
1342
- await client.threads.get(threadId);
1343
- } else {
1344
- await client.threads.create({
1345
- threadId
1346
- });
1347
- }
1348
- let agentState = {
1349
- values: {}
1350
- };
1351
- if (wasInitiatedWithExistingThread) {
1352
- agentState = await client.threads.getState(threadId);
1353
- }
1354
- const agentStateValues = agentState.values;
1355
- state.messages = agentStateValues.messages;
1356
- const mode = wasInitiatedWithExistingThread && nodeName != "__end__" ? "continue" : "start";
1357
- state = langGraphDefaultMergeState(state, formatMessages(messages), actions);
1358
- if (mode === "continue") {
1359
- await client.threads.updateState(threadId, {
1360
- values: state,
1361
- asNode: nodeName
1362
- });
1363
- }
1364
- const assistantId = initialAssistantId ?? retrievedAssistant.assistant_id;
1365
- const graphInfo = await client.assistants.getGraph(assistantId);
1366
- const streamInput = mode === "start" ? state : null;
1367
- let streamingStateExtractor = new StreamingStateExtractor([]);
1368
- let prevNodeName = null;
1369
- let emitIntermediateStateUntilEnd = null;
1370
- let shouldExit = null;
1371
- let externalRunId = null;
1372
- const streamResponse2 = client.runs.stream(threadId, assistantId, {
1373
- input: streamInput,
1374
- streamMode: [
1375
- "events",
1376
- "values"
1377
- ]
1378
- });
1379
- const emit = /* @__PURE__ */ __name((message) => controller.enqueue(new TextEncoder().encode(message)), "emit");
1380
- let latestStateValues = {};
1381
- for await (const chunk of streamResponse2) {
1382
- if (![
1383
- "events",
1384
- "values"
1385
- ].includes(chunk.event))
1386
- continue;
1387
- if (chunk.event === "values") {
1388
- latestStateValues = chunk.data;
1389
- continue;
1390
- }
1391
- const event = chunk.data;
1392
- const currentNodeName = event.name;
1393
- const eventType = event.event;
1394
- const runId = event.metadata.run_id;
1395
- externalRunId = runId;
1396
- const metadata = event.metadata;
1397
- shouldExit = shouldExit != null ? shouldExit : metadata["copilotkit:exit"];
1398
- const emitIntermediateState = metadata["copilotkit:emit-intermediate-state"];
1399
- const forceEmitIntermediateState = metadata["copilotkit:force-emit-intermediate-state"];
1400
- const manuallyEmitMessage = metadata["copilotkit:manually-emit-messages"];
1401
- const manuallyEmitToolCall = metadata["copilotkit:manually-emit-tool-calls"];
1402
- if (graphInfo["nodes"].some((node) => node.id === currentNodeName)) {
1403
- nodeName = currentNodeName;
1404
- }
1405
- if (!nodeName) {
1406
- continue;
1407
- }
1408
- if (forceEmitIntermediateState) {
1409
- if (eventType === "on_chain_end") {
1410
- state = event.data.output;
1411
- emit(getStateSyncEvent({
1412
- threadId,
1413
- runId,
1414
- agentName: agent.name,
1415
- nodeName,
1416
- state: event.data.output,
1417
- running: true,
1418
- active: true
1419
- }));
1420
- }
1421
- continue;
1422
- }
1423
- if (manuallyEmitMessage) {
1424
- if (eventType === "on_chain_end") {
1425
- state = event.data.output;
1426
- emit(JSON.stringify({
1427
- event: "on_copilotkit_emit_message",
1428
- message: event.data.output,
1429
- messageId: (0, import_node_crypto.randomUUID)(),
1430
- role: MessageRole.assistant
1431
- }) + "\n");
1432
- }
1433
- continue;
1434
- }
1435
- if (manuallyEmitToolCall) {
1436
- if (eventType === "on_chain_end") {
1437
- state = event.data.output;
1438
- emit(JSON.stringify({
1439
- event: "on_copilotkit_emit_tool_call",
1440
- name: event.data.output.name,
1441
- args: event.data.output.args,
1442
- id: event.data.output.id
1443
- }) + "\n");
1444
- }
1445
- continue;
1446
- }
1447
- if (emitIntermediateState && emitIntermediateStateUntilEnd == null) {
1448
- emitIntermediateStateUntilEnd = nodeName;
1449
- }
1450
- if (emitIntermediateState && eventType === "on_chat_model_start") {
1451
- streamingStateExtractor = new StreamingStateExtractor(emitIntermediateState);
1452
- }
1453
- let updatedState = latestStateValues;
1454
- if (emitIntermediateState && eventType === "on_chat_model_stream") {
1455
- streamingStateExtractor.bufferToolCalls(event);
1456
- }
1457
- if (emitIntermediateStateUntilEnd !== null) {
1458
- updatedState = {
1459
- ...updatedState,
1460
- ...streamingStateExtractor.extractState()
1461
- };
1462
- }
1463
- if (!emitIntermediateState && currentNodeName === emitIntermediateStateUntilEnd && eventType === "on_chain_end") {
1464
- emitIntermediateStateUntilEnd = null;
1465
- }
1466
- const exitingNode = nodeName === currentNodeName && eventType === "on_chain_end";
1467
- if (JSON.stringify(updatedState) !== JSON.stringify(state) || prevNodeName != nodeName || exitingNode) {
1468
- state = updatedState;
1469
- prevNodeName = nodeName;
1470
- emit(getStateSyncEvent({
1471
- threadId,
1472
- runId,
1473
- agentName: agent.name,
1474
- nodeName,
1475
- state,
1476
- running: true,
1477
- active: !exitingNode
1478
- }));
1479
- }
1480
- emit(JSON.stringify(event) + "\n");
1481
- }
1482
- state = await client.threads.getState(threadId);
1483
- const isEndNode = state.next.length === 0;
1484
- nodeName = Object.keys(state.metadata.writes)[0];
1485
- emit(getStateSyncEvent({
1486
- threadId,
1487
- runId: externalRunId,
1488
- agentName: agent.name,
1489
- nodeName: isEndNode ? "__end__" : nodeName,
1490
- state: state.values,
1491
- running: !shouldExit,
1492
- active: false
1493
- }));
1494
- return Promise.resolve();
1495
- }
1496
- __name(streamEvents, "streamEvents");
1497
- function getStateSyncEvent({ threadId, runId, agentName, nodeName, state, running, active }) {
1498
- const stateWithoutMessages = Object.keys(state).reduce((acc, key) => {
1499
- if (key !== "messages") {
1500
- acc[key] = state[key];
1501
- }
1502
- return acc;
1503
- }, {});
1504
- return JSON.stringify({
1505
- event: "on_copilotkit_state_sync",
1506
- thread_id: threadId,
1507
- run_id: runId,
1508
- agent_name: agentName,
1509
- node_name: nodeName,
1510
- active,
1511
- state: stateWithoutMessages,
1512
- running,
1513
- role: "assistant"
1514
- }) + "\n";
1515
- }
1516
- __name(getStateSyncEvent, "getStateSyncEvent");
1517
- var StreamingStateExtractor = /* @__PURE__ */ __name(class StreamingStateExtractor2 {
1518
- emitIntermediateState;
1519
- toolCallBuffer;
1520
- currentToolCall;
1521
- previouslyParsableState;
1522
- constructor(emitIntermediateState) {
1523
- this.emitIntermediateState = emitIntermediateState;
1524
- this.toolCallBuffer = {};
1525
- this.currentToolCall = null;
1526
- this.previouslyParsableState = {};
1527
- }
1528
- bufferToolCalls(event) {
1529
- if (event.data.chunk.tool_call_chunks.length > 0) {
1530
- const chunk = event.data.chunk.tool_call_chunks[0];
1531
- if (chunk.name !== null) {
1532
- this.currentToolCall = chunk.name;
1533
- this.toolCallBuffer[this.currentToolCall] = chunk.args;
1534
- } else if (this.currentToolCall !== null) {
1535
- this.toolCallBuffer[this.currentToolCall] += chunk.args;
1536
- }
1537
- }
1538
- }
1539
- getEmitStateConfig(currentToolName) {
1540
- for (const config2 of this.emitIntermediateState) {
1541
- const stateKey = config2["state_key"];
1542
- const tool = config2["tool"];
1543
- const toolArgument = config2["tool_argument"];
1544
- if (currentToolName === tool) {
1545
- return [
1546
- toolArgument,
1547
- stateKey
1548
- ];
1549
- }
1550
- }
1551
- return [
1552
- null,
1553
- null
1554
- ];
1555
- }
1556
- extractState() {
1557
- const state = {};
1558
- for (const [key, value] of Object.entries(this.toolCallBuffer)) {
1559
- const [argumentName, stateKey] = this.getEmitStateConfig(key);
1560
- if (stateKey === null) {
1561
- continue;
1562
- }
1563
- let parsedValue;
1564
- try {
1565
- parsedValue = (0, import_partial_json.parse)(value);
1566
- } catch (error) {
1567
- if (key in this.previouslyParsableState) {
1568
- parsedValue = this.previouslyParsableState[key];
1569
- } else {
1570
- continue;
1571
- }
1572
- }
1573
- this.previouslyParsableState[key] = parsedValue;
1574
- if (!argumentName) {
1575
- state[stateKey] = parsedValue;
1576
- } else {
1577
- state[stateKey] = parsedValue[argumentName];
1578
- }
1579
- }
1580
- return state;
1581
- }
1582
- }, "StreamingStateExtractor");
1583
- function langGraphDefaultMergeState(state, messages, actions) {
1584
- if (messages.length > 0 && "role" in messages[0] && messages[0].role === "system") {
1585
- messages = messages.slice(1);
1586
- }
1587
- const mergedMessages = state.messages || [];
1588
- const existingMessageIds = new Set(mergedMessages.map((message) => message.id));
1589
- for (const message of messages) {
1590
- if (!existingMessageIds.has(message.id)) {
1591
- mergedMessages.push(message);
1592
- }
1309
+ // src/lib/runtime/remote-actions.ts
1310
+ function isLangGraphAgentAction(action) {
1311
+ if (!action) {
1312
+ return false;
1593
1313
  }
1594
- return deepMerge(state, {
1595
- messages: mergedMessages,
1596
- copilotkit: {
1597
- actions
1598
- }
1599
- });
1314
+ return typeof action.langGraphAgentHandler === "function";
1600
1315
  }
1601
- __name(langGraphDefaultMergeState, "langGraphDefaultMergeState");
1602
- function deepMerge(obj1, obj2) {
1603
- let result = {
1604
- ...obj1
1316
+ __name(isLangGraphAgentAction, "isLangGraphAgentAction");
1317
+ function createHeaders(onBeforeRequest, graphqlContext) {
1318
+ const headers = {
1319
+ "Content-Type": "application/json"
1605
1320
  };
1606
- for (let key in obj2) {
1607
- if (typeof obj2[key] === "object" && !Array.isArray(obj2[key])) {
1608
- if (obj1[key]) {
1609
- result[key] = deepMerge(obj1[key], obj2[key]);
1610
- } else {
1611
- result[key] = {
1612
- ...obj2[key]
1613
- };
1614
- }
1615
- } else {
1616
- result[key] = obj2[key];
1321
+ if (onBeforeRequest) {
1322
+ const { headers: additionalHeaders } = onBeforeRequest({
1323
+ ctx: graphqlContext
1324
+ });
1325
+ if (additionalHeaders) {
1326
+ Object.assign(headers, additionalHeaders);
1617
1327
  }
1618
1328
  }
1619
- return result;
1329
+ return headers;
1620
1330
  }
1621
- __name(deepMerge, "deepMerge");
1622
- function formatMessages(messages) {
1623
- return messages.map((message) => {
1624
- if ("content" in message) {
1625
- return message;
1626
- }
1627
- if ("arguments" in message) {
1628
- const toolCall = {
1629
- name: message["name"],
1630
- args: message["arguments"],
1631
- id: message["id"]
1632
- };
1633
- return {
1634
- ...message,
1635
- content: "",
1636
- tool_calls: [
1637
- toolCall
1638
- ],
1639
- role: message["role"] ?? MessageRole.assistant
1640
- };
1641
- }
1642
- if ("actionExecutionId" in message) {
1331
+ __name(createHeaders, "createHeaders");
1332
+ async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: logger2, frontendUrl }) {
1333
+ logger2.debug({
1334
+ url
1335
+ }, "Fetching actions from url");
1336
+ const headers = createHeaders(onBeforeRequest, graphqlContext);
1337
+ try {
1338
+ const response = await fetch(`${url}/info`, {
1339
+ method: "POST",
1340
+ headers,
1341
+ body: JSON.stringify({
1342
+ properties: graphqlContext.properties,
1343
+ frontendUrl
1344
+ })
1345
+ });
1346
+ if (!response.ok) {
1347
+ logger2.error({
1348
+ url,
1349
+ status: response.status,
1350
+ body: await response.text()
1351
+ }, "Failed to fetch actions from url");
1643
1352
  return {
1644
- ...message,
1645
- content: message["result"],
1646
- name: message["actionName"],
1647
- tool_call_id: message["actionExecutionId"],
1648
- role: message["role"] ?? MessageRole.user
1353
+ actions: [],
1354
+ agents: []
1649
1355
  };
1650
1356
  }
1651
- return message;
1652
- });
1653
- }
1654
- __name(formatMessages, "formatMessages");
1655
-
1656
- // src/lib/runtime/remote-action-constructors.ts
1657
- function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, messages, agentStates }) {
1658
- const agents = endpoint.agents.map((agent) => ({
1659
- name: agent.name,
1660
- description: agent.description,
1661
- parameters: [],
1662
- handler: async (_args) => {
1663
- },
1664
- langGraphAgentHandler: async ({ name, actionInputsWithoutAgents, threadId, nodeName }) => {
1665
- var _a;
1666
- logger2.debug({
1667
- actionName: agent.name
1668
- }, "Executing LangGraph Cloud agent");
1669
- telemetry_client_default.capture("oss.runtime.remote_action_executed", {});
1670
- let state = {};
1671
- if (agentStates) {
1672
- const jsonState = (_a = agentStates.find((state2) => state2.agentName === name)) == null ? void 0 : _a.state;
1673
- if (jsonState) {
1674
- state = JSON.parse(jsonState);
1675
- }
1676
- }
1677
- try {
1678
- const response = await execute({
1679
- deploymentUrl: endpoint.deploymentUrl,
1680
- langsmithApiKey: endpoint.langsmithApiKey,
1681
- agent,
1682
- threadId,
1683
- nodeName,
1684
- messages,
1685
- state,
1686
- properties: graphqlContext.properties,
1687
- actions: actionInputsWithoutAgents.map((action) => ({
1688
- name: action.name,
1689
- description: action.description,
1690
- parameters: JSON.parse(action.jsonSchema)
1691
- }))
1692
- });
1693
- const eventSource = new RemoteLangGraphEventSource();
1694
- streamResponse(response, eventSource.eventStream$);
1695
- return eventSource.processLangGraphEvents();
1696
- } catch (error) {
1697
- logger2.error({
1698
- url: endpoint.deploymentUrl,
1699
- status: 500,
1700
- body: error.message
1701
- }, "Failed to execute LangGraph Cloud agent");
1702
- throw new Error("Failed to execute LangGraph Cloud agent");
1703
- }
1704
- }
1705
- }));
1706
- return [
1707
- ...agents
1708
- ];
1357
+ const json = await response.json();
1358
+ logger2.debug({
1359
+ json
1360
+ }, "Fetched actions from url");
1361
+ return json;
1362
+ } catch (error) {
1363
+ logger2.error({
1364
+ error: error.message ? error.message : error + ""
1365
+ }, "Failed to fetch actions from url");
1366
+ return {
1367
+ actions: [],
1368
+ agents: []
1369
+ };
1370
+ }
1709
1371
  }
1710
- __name(constructLGCRemoteAction, "constructLGCRemoteAction");
1372
+ __name(fetchRemoteInfo, "fetchRemoteInfo");
1711
1373
  function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, logger: logger2, messages, agentStates }) {
1712
1374
  const actions = json["actions"].map((action) => ({
1713
1375
  name: action.name,
@@ -1799,7 +1461,7 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
1799
1461
  throw new Error("Failed to execute remote agent");
1800
1462
  }
1801
1463
  const eventSource = new RemoteLangGraphEventSource();
1802
- streamResponse(response.body, eventSource.eventStream$);
1464
+ eventSource.streamResponse(response);
1803
1465
  return eventSource.processLangGraphEvents();
1804
1466
  }
1805
1467
  }));
@@ -1809,165 +1471,34 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
1809
1471
  ];
1810
1472
  }
1811
1473
  __name(constructRemoteActions, "constructRemoteActions");
1812
- async function streamResponse(response, eventStream$) {
1813
- const reader = response.getReader();
1814
- const decoder = new TextDecoder();
1815
- let buffer = [];
1816
- function flushBuffer() {
1817
- const currentBuffer = buffer.join("");
1818
- if (currentBuffer.trim().length === 0) {
1819
- return;
1820
- }
1821
- const parts = currentBuffer.split("\n");
1822
- if (parts.length === 0) {
1823
- return;
1824
- }
1825
- const lastPartIsComplete = currentBuffer.endsWith("\n");
1826
- buffer = [];
1827
- if (!lastPartIsComplete) {
1828
- buffer.push(parts.pop());
1829
- }
1830
- parts.map((part) => part.trim()).filter((part) => part != "").forEach((part) => {
1831
- eventStream$.next(JSON.parse(part));
1832
- });
1833
- }
1834
- __name(flushBuffer, "flushBuffer");
1835
- try {
1836
- while (true) {
1837
- const { done, value } = await reader.read();
1838
- if (!done) {
1839
- buffer.push(decoder.decode(value, {
1840
- stream: true
1841
- }));
1842
- }
1843
- flushBuffer();
1844
- if (done) {
1845
- break;
1846
- }
1847
- }
1848
- } catch (error) {
1849
- console.error("Error in stream", error);
1850
- eventStream$.error(error);
1851
- return;
1852
- }
1853
- eventStream$.complete();
1854
- }
1855
- __name(streamResponse, "streamResponse");
1856
- function createHeaders(onBeforeRequest, graphqlContext) {
1857
- const headers = {
1858
- "Content-Type": "application/json"
1859
- };
1860
- if (onBeforeRequest) {
1861
- const { headers: additionalHeaders } = onBeforeRequest({
1862
- ctx: graphqlContext
1863
- });
1864
- if (additionalHeaders) {
1865
- Object.assign(headers, additionalHeaders);
1866
- }
1867
- }
1868
- return headers;
1869
- }
1870
- __name(createHeaders, "createHeaders");
1871
-
1872
- // src/lib/runtime/remote-actions.ts
1873
- var EndpointType;
1874
- (function(EndpointType2) {
1875
- EndpointType2["CopilotKit"] = "copilotKit";
1876
- EndpointType2["LangGraphCloud"] = "langgraph-cloud";
1877
- })(EndpointType || (EndpointType = {}));
1878
- function isLangGraphAgentAction(action) {
1879
- if (!action) {
1880
- return false;
1881
- }
1882
- return typeof action.langGraphAgentHandler === "function";
1883
- }
1884
- __name(isLangGraphAgentAction, "isLangGraphAgentAction");
1885
- async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: logger2, frontendUrl }) {
1886
- logger2.debug({
1887
- url
1888
- }, "Fetching actions from url");
1889
- const headers = createHeaders(onBeforeRequest, graphqlContext);
1890
- try {
1891
- const response = await fetch(`${url}/info`, {
1892
- method: "POST",
1893
- headers,
1894
- body: JSON.stringify({
1895
- properties: graphqlContext.properties,
1896
- frontendUrl
1897
- })
1898
- });
1899
- if (!response.ok) {
1900
- logger2.error({
1901
- url,
1902
- status: response.status,
1903
- body: await response.text()
1904
- }, "Failed to fetch actions from url");
1905
- return {
1906
- actions: [],
1907
- agents: []
1908
- };
1909
- }
1910
- const json = await response.json();
1911
- logger2.debug({
1912
- json
1913
- }, "Fetched actions from url");
1914
- return json;
1915
- } catch (error) {
1916
- logger2.error({
1917
- error: error.message ? error.message : error + ""
1918
- }, "Failed to fetch actions from url");
1919
- return {
1920
- actions: [],
1921
- agents: []
1922
- };
1923
- }
1924
- }
1925
- __name(fetchRemoteInfo, "fetchRemoteInfo");
1926
- async function setupRemoteActions({ remoteEndpointDefinitions, graphqlContext, messages, agentStates, frontendUrl }) {
1474
+ async function setupRemoteActions({ remoteActionDefinitions, graphqlContext, messages, agentStates, frontendUrl }) {
1927
1475
  const logger2 = graphqlContext.logger.child({
1928
1476
  component: "remote-actions.fetchRemoteActions"
1929
1477
  });
1930
1478
  logger2.debug({
1931
- remoteEndpointDefinitions
1932
- }, "Fetching from remote endpoints");
1933
- const filtered = remoteEndpointDefinitions.filter((value, index, self) => {
1934
- if (value.type === "langgraph-cloud") {
1935
- return value;
1936
- }
1937
- return index === self.findIndex((t) => t.url === value.url);
1938
- });
1939
- const result = await Promise.all(filtered.map(async (endpoint) => {
1940
- if (endpoint.type === "langgraph-cloud") {
1941
- return constructLGCRemoteAction({
1942
- endpoint,
1943
- messages,
1944
- graphqlContext,
1945
- logger: logger2.child({
1946
- component: "remote-actions.constructLGCRemoteAction",
1947
- endpoint
1948
- }),
1949
- agentStates
1950
- });
1951
- }
1479
+ remoteActionDefinitions
1480
+ }, "Fetching remote actions");
1481
+ const filtered = remoteActionDefinitions.filter((value, index, self) => index === self.findIndex((t) => t.url === value.url));
1482
+ const result = await Promise.all(filtered.map(async (actionDefinition) => {
1952
1483
  const json = await fetchRemoteInfo({
1953
- url: endpoint.url,
1954
- onBeforeRequest: endpoint.onBeforeRequest,
1484
+ url: actionDefinition.url,
1485
+ onBeforeRequest: actionDefinition.onBeforeRequest,
1955
1486
  graphqlContext,
1956
1487
  logger: logger2.child({
1957
1488
  component: "remote-actions.fetchActionsFromUrl",
1958
- endpoint
1489
+ actionDefinition
1959
1490
  }),
1960
1491
  frontendUrl
1961
1492
  });
1962
1493
  return constructRemoteActions({
1963
1494
  json,
1964
1495
  messages,
1965
- url: endpoint.url,
1966
- onBeforeRequest: endpoint.onBeforeRequest,
1496
+ url: actionDefinition.url,
1497
+ onBeforeRequest: actionDefinition.onBeforeRequest,
1967
1498
  graphqlContext,
1968
1499
  logger: logger2.child({
1969
1500
  component: "remote-actions.constructActions",
1970
- endpoint
1501
+ actionDefinition
1971
1502
  }),
1972
1503
  agentStates
1973
1504
  });
@@ -2131,7 +1662,13 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
2131
1662
  }
2132
1663
  let args = [];
2133
1664
  if (actionArguments) {
2134
- args = JSON.parse(actionArguments);
1665
+ try {
1666
+ args = JSON.parse(actionArguments);
1667
+ } catch (e) {
1668
+ console.warn("Action argument unparsable", {
1669
+ actionArguments
1670
+ });
1671
+ }
2135
1672
  }
2136
1673
  if (isLangGraphAgentAction(action)) {
2137
1674
  eventStream$.sendActionExecutionResult(actionExecutionId, action.name, `${action.name} agent started`);
@@ -2159,7 +1696,7 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
2159
1696
  __name(executeAction, "executeAction");
2160
1697
 
2161
1698
  // src/graphql/types/base/index.ts
2162
- var import_type_graphql2 = require("type-graphql");
1699
+ var import_type_graphql = require("type-graphql");
2163
1700
  function _ts_decorate(decorators, target, key, desc) {
2164
1701
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2165
1702
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -2182,15 +1719,15 @@ var BaseMessageInput = class {
2182
1719
  };
2183
1720
  __name(BaseMessageInput, "BaseMessageInput");
2184
1721
  _ts_decorate([
2185
- (0, import_type_graphql2.Field)(() => String),
1722
+ (0, import_type_graphql.Field)(() => String),
2186
1723
  _ts_metadata("design:type", String)
2187
1724
  ], BaseMessageInput.prototype, "id", void 0);
2188
1725
  _ts_decorate([
2189
- (0, import_type_graphql2.Field)(() => Date),
1726
+ (0, import_type_graphql.Field)(() => Date),
2190
1727
  _ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
2191
1728
  ], BaseMessageInput.prototype, "createdAt", void 0);
2192
1729
  BaseMessageInput = _ts_decorate([
2193
- (0, import_type_graphql2.InputType)()
1730
+ (0, import_type_graphql.InputType)()
2194
1731
  ], BaseMessageInput);
2195
1732
 
2196
1733
  // src/graphql/types/converted/index.ts
@@ -2294,7 +1831,7 @@ __name(convertGqlInputToMessages, "convertGqlInputToMessages");
2294
1831
  var import_rxjs3 = require("rxjs");
2295
1832
  var CopilotRuntime = class {
2296
1833
  actions;
2297
- remoteEndpointDefinitions;
1834
+ remoteActionDefinitions;
2298
1835
  langserve = [];
2299
1836
  onBeforeRequest;
2300
1837
  onAfterRequest;
@@ -2305,7 +1842,7 @@ var CopilotRuntime = class {
2305
1842
  const remoteChain = new RemoteChain(chain);
2306
1843
  this.langserve.push(remoteChain.toAction());
2307
1844
  }
2308
- this.remoteEndpointDefinitions = (params == null ? void 0 : params.remoteEndpoints) || [];
1845
+ this.remoteActionDefinitions = (params == null ? void 0 : params.remoteActions) || [];
2309
1846
  this.onBeforeRequest = (_a = params == null ? void 0 : params.middleware) == null ? void 0 : _a.onBeforeRequest;
2310
1847
  this.onAfterRequest = (_b = params == null ? void 0 : params.middleware) == null ? void 0 : _b.onAfterRequest;
2311
1848
  }
@@ -2374,7 +1911,7 @@ var CopilotRuntime = class {
2374
1911
  async processAgentRequest(request) {
2375
1912
  var _a;
2376
1913
  const { messages: rawMessages, outputMessagesPromise, graphqlContext, agentSession } = request;
2377
- const { threadId, agentName, nodeName } = agentSession;
1914
+ const { threadId = (0, import_shared8.randomId)(), agentName, nodeName } = agentSession;
2378
1915
  const serverSideActions = await this.getServerSideActions(request);
2379
1916
  const messages = convertGqlInputToMessages(rawMessages);
2380
1917
  const agent = serverSideActions.find((action) => action.name === agentName && isLangGraphAgentAction(action));
@@ -2446,12 +1983,8 @@ var CopilotRuntime = class {
2446
1983
  console.error("Error loading langserve chain:", error);
2447
1984
  }
2448
1985
  }
2449
- const remoteEndpointDefinitions = this.remoteEndpointDefinitions.map((endpoint) => ({
2450
- ...endpoint,
2451
- type: this.resolveEndpointType(endpoint)
2452
- }));
2453
1986
  const remoteActions = await setupRemoteActions({
2454
- remoteEndpointDefinitions,
1987
+ remoteActionDefinitions: this.remoteActionDefinitions,
2455
1988
  graphqlContext,
2456
1989
  messages: inputMessages,
2457
1990
  agentStates,
@@ -2467,12 +2000,6 @@ var CopilotRuntime = class {
2467
2000
  ...remoteActions
2468
2001
  ];
2469
2002
  }
2470
- resolveEndpointType(endpoint) {
2471
- if (!endpoint.type && "langsmithApiKey" in endpoint && "deploymentUrl" in endpoint && "agents" in endpoint) {
2472
- return EndpointType.LangGraphCloud;
2473
- }
2474
- return endpoint.type;
2475
- }
2476
2003
  };
2477
2004
  __name(CopilotRuntime, "CopilotRuntime");
2478
2005
  function flattenToolCallsNoDuplicates(toolsByPriority) {
@@ -2487,20 +2014,6 @@ function flattenToolCallsNoDuplicates(toolsByPriority) {
2487
2014
  return allTools;
2488
2015
  }
2489
2016
  __name(flattenToolCallsNoDuplicates, "flattenToolCallsNoDuplicates");
2490
- function copilotKitEndpoint(config2) {
2491
- return {
2492
- ...config2,
2493
- type: EndpointType.CopilotKit
2494
- };
2495
- }
2496
- __name(copilotKitEndpoint, "copilotKitEndpoint");
2497
- function langGraphCloudEndpoint(config2) {
2498
- return {
2499
- ...config2,
2500
- type: EndpointType.LangGraphCloud
2501
- };
2502
- }
2503
- __name(langGraphCloudEndpoint, "langGraphCloudEndpoint");
2504
2017
 
2505
2018
  // src/lib/integrations/shared.ts
2506
2019
  var import_type_graphql16 = require("type-graphql");
@@ -2514,6 +2027,43 @@ var import_type_graphql11 = require("type-graphql");
2514
2027
 
2515
2028
  // src/graphql/inputs/message.input.ts
2516
2029
  var import_type_graphql3 = require("type-graphql");
2030
+
2031
+ // src/graphql/types/enums.ts
2032
+ var import_type_graphql2 = require("type-graphql");
2033
+ var MessageRole;
2034
+ (function(MessageRole2) {
2035
+ MessageRole2["user"] = "user";
2036
+ MessageRole2["assistant"] = "assistant";
2037
+ MessageRole2["system"] = "system";
2038
+ })(MessageRole || (MessageRole = {}));
2039
+ var ActionExecutionScope;
2040
+ (function(ActionExecutionScope2) {
2041
+ ActionExecutionScope2["server"] = "server";
2042
+ ActionExecutionScope2["client"] = "client";
2043
+ ActionExecutionScope2["passThrough"] = "passThrough";
2044
+ })(ActionExecutionScope || (ActionExecutionScope = {}));
2045
+ var CopilotRequestType;
2046
+ (function(CopilotRequestType2) {
2047
+ CopilotRequestType2["Chat"] = "Chat";
2048
+ CopilotRequestType2["Task"] = "Task";
2049
+ CopilotRequestType2["TextareaCompletion"] = "TextareaCompletion";
2050
+ CopilotRequestType2["TextareaPopover"] = "TextareaPopover";
2051
+ CopilotRequestType2["Suggestion"] = "Suggestion";
2052
+ })(CopilotRequestType || (CopilotRequestType = {}));
2053
+ (0, import_type_graphql2.registerEnumType)(MessageRole, {
2054
+ name: "MessageRole",
2055
+ description: "The role of the message"
2056
+ });
2057
+ (0, import_type_graphql2.registerEnumType)(ActionExecutionScope, {
2058
+ name: "ActionExecutionScope",
2059
+ description: "The scope of the action"
2060
+ });
2061
+ (0, import_type_graphql2.registerEnumType)(CopilotRequestType, {
2062
+ name: "CopilotRequestType",
2063
+ description: "The type of Copilot request"
2064
+ });
2065
+
2066
+ // src/graphql/inputs/message.input.ts
2517
2067
  function _ts_decorate2(decorators, target, key, desc) {
2518
2068
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2519
2069
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -4170,7 +3720,6 @@ __name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
4170
3720
  UnifyAdapter,
4171
3721
  buildSchema,
4172
3722
  config,
4173
- copilotKitEndpoint,
4174
3723
  copilotRuntimeNestEndpoint,
4175
3724
  copilotRuntimeNextJSAppRouterEndpoint,
4176
3725
  copilotRuntimeNextJSPagesRouterEndpoint,
@@ -4178,7 +3727,6 @@ __name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
4178
3727
  copilotRuntimeNodeHttpEndpoint,
4179
3728
  createContext,
4180
3729
  flattenToolCallsNoDuplicates,
4181
- getCommonConfig,
4182
- langGraphCloudEndpoint
3730
+ getCommonConfig
4183
3731
  });
4184
3732
  //# sourceMappingURL=index.js.map