@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/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",
@@ -137,7 +136,6 @@ __export(src_exports, {
137
136
  UnknownErrorResponse: () => UnknownErrorResponse,
138
137
  buildSchema: () => buildSchema,
139
138
  config: () => config,
140
- copilotKitEndpoint: () => copilotKitEndpoint,
141
139
  copilotRuntimeNestEndpoint: () => copilotRuntimeNestEndpoint,
142
140
  copilotRuntimeNextJSAppRouterEndpoint: () => copilotRuntimeNextJSAppRouterEndpoint,
143
141
  copilotRuntimeNextJSPagesRouterEndpoint: () => copilotRuntimeNextJSPagesRouterEndpoint,
@@ -145,8 +143,7 @@ __export(src_exports, {
145
143
  copilotRuntimeNodeHttpEndpoint: () => copilotRuntimeNodeHttpEndpoint,
146
144
  createContext: () => createContext,
147
145
  flattenToolCallsNoDuplicates: () => flattenToolCallsNoDuplicates,
148
- getCommonConfig: () => getCommonConfig,
149
- langGraphCloudEndpoint: () => langGraphCloudEndpoint
146
+ getCommonConfig: () => getCommonConfig
150
147
  });
151
148
  module.exports = __toCommonJS(src_exports);
152
149
  var import_reflect_metadata = require("reflect-metadata");
@@ -503,24 +500,27 @@ __name(convertMessageToLangChainMessage, "convertMessageToLangChainMessage");
503
500
  function convertJsonSchemaToZodSchema(jsonSchema, required) {
504
501
  if (jsonSchema.type === "object") {
505
502
  const spec = {};
503
+ if (!jsonSchema.properties || !Object.keys(jsonSchema.properties).length) {
504
+ return !required ? import_zod.z.object(spec).optional() : import_zod.z.object(spec);
505
+ }
506
506
  for (const [key, value] of Object.entries(jsonSchema.properties)) {
507
507
  spec[key] = convertJsonSchemaToZodSchema(value, jsonSchema.required ? jsonSchema.required.includes(key) : false);
508
508
  }
509
509
  let schema = import_zod.z.object(spec);
510
- return !required ? schema.optional() : schema;
510
+ return required ? schema : schema.optional();
511
511
  } else if (jsonSchema.type === "string") {
512
512
  let schema = import_zod.z.string().describe(jsonSchema.description);
513
- return !required ? schema.optional() : schema;
513
+ return required ? schema : schema.optional();
514
514
  } else if (jsonSchema.type === "number") {
515
515
  let schema = import_zod.z.number().describe(jsonSchema.description);
516
- return !required ? schema.optional() : schema;
516
+ return required ? schema : schema.optional();
517
517
  } else if (jsonSchema.type === "boolean") {
518
518
  let schema = import_zod.z.boolean().describe(jsonSchema.description);
519
- return !required ? schema.optional() : schema;
519
+ return required ? schema : schema.optional();
520
520
  } else if (jsonSchema.type === "array") {
521
521
  let itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true);
522
522
  let schema = import_zod.z.array(itemSchema);
523
- return !required ? schema.optional() : schema;
523
+ return required ? schema : schema.optional();
524
524
  }
525
525
  }
526
526
  __name(convertJsonSchemaToZodSchema, "convertJsonSchemaToZodSchema");
@@ -1338,6 +1338,50 @@ var LangGraphEventTypes;
1338
1338
  var import_shared8 = require("@copilotkit/shared");
1339
1339
  var RemoteLangGraphEventSource = class {
1340
1340
  eventStream$ = new import_rxjs.ReplaySubject();
1341
+ async streamResponse(response) {
1342
+ const reader = response.body.getReader();
1343
+ const decoder = new TextDecoder();
1344
+ let buffer = [];
1345
+ const eventStream$ = this.eventStream$;
1346
+ function flushBuffer() {
1347
+ const currentBuffer = buffer.join("");
1348
+ if (currentBuffer.trim().length === 0) {
1349
+ return;
1350
+ }
1351
+ const parts = currentBuffer.split("\n");
1352
+ if (parts.length === 0) {
1353
+ return;
1354
+ }
1355
+ const lastPartIsComplete = currentBuffer.endsWith("\n");
1356
+ buffer = [];
1357
+ if (!lastPartIsComplete) {
1358
+ buffer.push(parts.pop());
1359
+ }
1360
+ parts.map((part) => part.trim()).filter((part) => part != "").forEach((part) => {
1361
+ eventStream$.next(JSON.parse(part));
1362
+ });
1363
+ }
1364
+ __name(flushBuffer, "flushBuffer");
1365
+ try {
1366
+ while (true) {
1367
+ const { done, value } = await reader.read();
1368
+ if (!done) {
1369
+ buffer.push(decoder.decode(value, {
1370
+ stream: true
1371
+ }));
1372
+ }
1373
+ flushBuffer();
1374
+ if (done) {
1375
+ break;
1376
+ }
1377
+ }
1378
+ } catch (error) {
1379
+ console.error("Error in stream", error);
1380
+ eventStream$.error(error);
1381
+ return;
1382
+ }
1383
+ eventStream$.complete();
1384
+ }
1341
1385
  shouldEmitToolCall(shouldEmitToolCalls, toolCallName) {
1342
1386
  if (typeof shouldEmitToolCalls === "boolean") {
1343
1387
  return shouldEmitToolCalls;
@@ -1360,25 +1404,20 @@ var RemoteLangGraphEventSource = class {
1360
1404
  } else {
1361
1405
  acc.content = null;
1362
1406
  }
1363
- const toolCallChunks = (
1364
- // @ts-expect-error -- LangGraph Cloud implementation stores data outside of kwargs
1365
- ((_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)
1366
- );
1367
- 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);
1368
- if (toolCallChunks && toolCallChunks.length > 0) {
1407
+ if ((_h = (_g = (_f = event.data) == null ? void 0 : _f.chunk) == null ? void 0 : _g.kwargs) == null ? void 0 : _h.tool_call_chunks) {
1369
1408
  acc.prevToolCallMessageId = acc.toolCallMessageId;
1370
- acc.toolCallMessageId = toolCallMessageId;
1371
- if ((_p = toolCallChunks[0]) == null ? void 0 : _p.name) {
1372
- acc.toolCallName = toolCallChunks[0].name;
1409
+ acc.toolCallMessageId = (_i = event.data.chunk.kwargs) == null ? void 0 : _i.id;
1410
+ if ((_j = event.data.chunk.kwargs.tool_call_chunks[0]) == null ? void 0 : _j.name) {
1411
+ acc.toolCallName = event.data.chunk.kwargs.tool_call_chunks[0].name;
1373
1412
  }
1374
- if ((_q = toolCallChunks[0]) == null ? void 0 : _q.id) {
1375
- acc.toolCallId = toolCallChunks[0].id;
1413
+ if ((_k = event.data.chunk.kwargs.tool_call_chunks[0]) == null ? void 0 : _k.id) {
1414
+ acc.toolCallId = event.data.chunk.kwargs.tool_call_chunks[0].id;
1376
1415
  }
1377
1416
  acc.prevMessageId = acc.messageId;
1378
- acc.messageId = toolCallMessageId;
1417
+ acc.messageId = (_n = (_m = (_l = event.data) == null ? void 0 : _l.chunk) == null ? void 0 : _m.kwargs) == null ? void 0 : _n.id;
1379
1418
  } else if (acc.content && acc.content != "") {
1380
1419
  acc.prevMessageId = acc.messageId;
1381
- acc.messageId = toolCallMessageId;
1420
+ acc.messageId = (_q = (_p = (_o = event.data) == null ? void 0 : _o.chunk) == null ? void 0 : _p.kwargs) == null ? void 0 : _q.id;
1382
1421
  } else {
1383
1422
  acc.prevToolCallMessageId = acc.toolCallMessageId;
1384
1423
  acc.prevMessageId = acc.messageId;
@@ -1403,7 +1442,7 @@ var RemoteLangGraphEventSource = class {
1403
1442
  prevMessageId: null,
1404
1443
  content: null
1405
1444
  }), (0, import_rxjs.mergeMap)((eventWithState) => {
1406
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1445
+ var _a, _b, _c, _d, _e;
1407
1446
  const events = [];
1408
1447
  let shouldEmitMessages = true;
1409
1448
  let shouldEmitToolCalls = false;
@@ -1486,8 +1525,7 @@ var RemoteLangGraphEventSource = class {
1486
1525
  });
1487
1526
  }
1488
1527
  }
1489
- 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
1490
- ((_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);
1528
+ 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;
1491
1529
  const content = eventWithState.content;
1492
1530
  if (args) {
1493
1531
  if (this.shouldEmitToolCall(shouldEmitToolCalls, eventWithState.toolCallName)) {
@@ -1538,446 +1576,70 @@ var RemoteLangGraphEventSource = class {
1538
1576
  };
1539
1577
  __name(RemoteLangGraphEventSource, "RemoteLangGraphEventSource");
1540
1578
 
1541
- // src/lib/runtime/remote-lg-cloud-action.ts
1542
- var import_langgraph_sdk = require("@langchain/langgraph-sdk");
1543
- var import_node_crypto = require("crypto");
1544
- var import_partial_json = require("partial-json");
1545
-
1546
- // src/graphql/types/enums.ts
1547
- var import_type_graphql = require("type-graphql");
1548
- var MessageRole;
1549
- (function(MessageRole2) {
1550
- MessageRole2["user"] = "user";
1551
- MessageRole2["assistant"] = "assistant";
1552
- MessageRole2["system"] = "system";
1553
- })(MessageRole || (MessageRole = {}));
1554
- var ActionExecutionScope;
1555
- (function(ActionExecutionScope2) {
1556
- ActionExecutionScope2["server"] = "server";
1557
- ActionExecutionScope2["client"] = "client";
1558
- ActionExecutionScope2["passThrough"] = "passThrough";
1559
- })(ActionExecutionScope || (ActionExecutionScope = {}));
1560
- var CopilotRequestType;
1561
- (function(CopilotRequestType2) {
1562
- CopilotRequestType2["Chat"] = "Chat";
1563
- CopilotRequestType2["Task"] = "Task";
1564
- CopilotRequestType2["TextareaCompletion"] = "TextareaCompletion";
1565
- CopilotRequestType2["TextareaPopover"] = "TextareaPopover";
1566
- CopilotRequestType2["Suggestion"] = "Suggestion";
1567
- })(CopilotRequestType || (CopilotRequestType = {}));
1568
- (0, import_type_graphql.registerEnumType)(MessageRole, {
1569
- name: "MessageRole",
1570
- description: "The role of the message"
1571
- });
1572
- (0, import_type_graphql.registerEnumType)(ActionExecutionScope, {
1573
- name: "ActionExecutionScope",
1574
- description: "The scope of the action"
1575
- });
1576
- (0, import_type_graphql.registerEnumType)(CopilotRequestType, {
1577
- name: "CopilotRequestType",
1578
- description: "The type of Copilot request"
1579
- });
1580
-
1581
- // src/lib/runtime/remote-lg-cloud-action.ts
1582
- async function execute(args) {
1583
- return new ReadableStream({
1584
- async start(controller) {
1585
- try {
1586
- await streamEvents(controller, args);
1587
- controller.close();
1588
- } catch (err) {
1589
- }
1590
- }
1591
- });
1592
- }
1593
- __name(execute, "execute");
1594
- async function streamEvents(controller, args) {
1595
- const { deploymentUrl, langsmithApiKey, threadId: agrsInitialThreadId, agent, nodeName: initialNodeName, state: initialState, messages, actions } = args;
1596
- let nodeName = initialNodeName;
1597
- let state = initialState;
1598
- const { name, assistantId: initialAssistantId } = agent;
1599
- const client = new import_langgraph_sdk.Client({
1600
- apiUrl: deploymentUrl,
1601
- apiKey: langsmithApiKey
1602
- });
1603
- let initialThreadId = agrsInitialThreadId;
1604
- const wasInitiatedWithExistingThread = !!initialThreadId;
1605
- if (initialThreadId && initialThreadId.startsWith("ck-")) {
1606
- initialThreadId = initialThreadId.substring(3);
1607
- }
1608
- const assistants = await client.assistants.search();
1609
- const retrievedAssistant = assistants.find((a) => a.name === name);
1610
- const threadId = initialThreadId ?? (0, import_node_crypto.randomUUID)();
1611
- if (initialThreadId === threadId) {
1612
- await client.threads.get(threadId);
1613
- } else {
1614
- await client.threads.create({
1615
- threadId
1616
- });
1617
- }
1618
- let agentState = {
1619
- values: {}
1620
- };
1621
- if (wasInitiatedWithExistingThread) {
1622
- agentState = await client.threads.getState(threadId);
1623
- }
1624
- const agentStateValues = agentState.values;
1625
- state.messages = agentStateValues.messages;
1626
- const mode = wasInitiatedWithExistingThread && nodeName != "__end__" ? "continue" : "start";
1627
- state = langGraphDefaultMergeState(state, formatMessages(messages), actions);
1628
- if (mode === "continue") {
1629
- await client.threads.updateState(threadId, {
1630
- values: state,
1631
- asNode: nodeName
1632
- });
1633
- }
1634
- const assistantId = initialAssistantId ?? retrievedAssistant.assistant_id;
1635
- const graphInfo = await client.assistants.getGraph(assistantId);
1636
- const streamInput = mode === "start" ? state : null;
1637
- let streamingStateExtractor = new StreamingStateExtractor([]);
1638
- let prevNodeName = null;
1639
- let emitIntermediateStateUntilEnd = null;
1640
- let shouldExit = null;
1641
- let externalRunId = null;
1642
- const streamResponse2 = client.runs.stream(threadId, assistantId, {
1643
- input: streamInput,
1644
- streamMode: [
1645
- "events",
1646
- "values"
1647
- ]
1648
- });
1649
- const emit = /* @__PURE__ */ __name((message) => controller.enqueue(new TextEncoder().encode(message)), "emit");
1650
- let latestStateValues = {};
1651
- for await (const chunk of streamResponse2) {
1652
- if (![
1653
- "events",
1654
- "values"
1655
- ].includes(chunk.event))
1656
- continue;
1657
- if (chunk.event === "values") {
1658
- latestStateValues = chunk.data;
1659
- continue;
1660
- }
1661
- const event = chunk.data;
1662
- const currentNodeName = event.name;
1663
- const eventType = event.event;
1664
- const runId = event.metadata.run_id;
1665
- externalRunId = runId;
1666
- const metadata = event.metadata;
1667
- shouldExit = shouldExit != null ? shouldExit : metadata["copilotkit:exit"];
1668
- const emitIntermediateState = metadata["copilotkit:emit-intermediate-state"];
1669
- const forceEmitIntermediateState = metadata["copilotkit:force-emit-intermediate-state"];
1670
- const manuallyEmitMessage = metadata["copilotkit:manually-emit-messages"];
1671
- const manuallyEmitToolCall = metadata["copilotkit:manually-emit-tool-calls"];
1672
- if (graphInfo["nodes"].some((node) => node.id === currentNodeName)) {
1673
- nodeName = currentNodeName;
1674
- }
1675
- if (!nodeName) {
1676
- continue;
1677
- }
1678
- if (forceEmitIntermediateState) {
1679
- if (eventType === "on_chain_end") {
1680
- state = event.data.output;
1681
- emit(getStateSyncEvent({
1682
- threadId,
1683
- runId,
1684
- agentName: agent.name,
1685
- nodeName,
1686
- state: event.data.output,
1687
- running: true,
1688
- active: true
1689
- }));
1690
- }
1691
- continue;
1692
- }
1693
- if (manuallyEmitMessage) {
1694
- if (eventType === "on_chain_end") {
1695
- state = event.data.output;
1696
- emit(JSON.stringify({
1697
- event: "on_copilotkit_emit_message",
1698
- message: event.data.output,
1699
- messageId: (0, import_node_crypto.randomUUID)(),
1700
- role: MessageRole.assistant
1701
- }) + "\n");
1702
- }
1703
- continue;
1704
- }
1705
- if (manuallyEmitToolCall) {
1706
- if (eventType === "on_chain_end") {
1707
- state = event.data.output;
1708
- emit(JSON.stringify({
1709
- event: "on_copilotkit_emit_tool_call",
1710
- name: event.data.output.name,
1711
- args: event.data.output.args,
1712
- id: event.data.output.id
1713
- }) + "\n");
1714
- }
1715
- continue;
1716
- }
1717
- if (emitIntermediateState && emitIntermediateStateUntilEnd == null) {
1718
- emitIntermediateStateUntilEnd = nodeName;
1719
- }
1720
- if (emitIntermediateState && eventType === "on_chat_model_start") {
1721
- streamingStateExtractor = new StreamingStateExtractor(emitIntermediateState);
1722
- }
1723
- let updatedState = latestStateValues;
1724
- if (emitIntermediateState && eventType === "on_chat_model_stream") {
1725
- streamingStateExtractor.bufferToolCalls(event);
1726
- }
1727
- if (emitIntermediateStateUntilEnd !== null) {
1728
- updatedState = {
1729
- ...updatedState,
1730
- ...streamingStateExtractor.extractState()
1731
- };
1732
- }
1733
- if (!emitIntermediateState && currentNodeName === emitIntermediateStateUntilEnd && eventType === "on_chain_end") {
1734
- emitIntermediateStateUntilEnd = null;
1735
- }
1736
- const exitingNode = nodeName === currentNodeName && eventType === "on_chain_end";
1737
- if (JSON.stringify(updatedState) !== JSON.stringify(state) || prevNodeName != nodeName || exitingNode) {
1738
- state = updatedState;
1739
- prevNodeName = nodeName;
1740
- emit(getStateSyncEvent({
1741
- threadId,
1742
- runId,
1743
- agentName: agent.name,
1744
- nodeName,
1745
- state,
1746
- running: true,
1747
- active: !exitingNode
1748
- }));
1749
- }
1750
- emit(JSON.stringify(event) + "\n");
1751
- }
1752
- state = await client.threads.getState(threadId);
1753
- const isEndNode = state.next.length === 0;
1754
- nodeName = Object.keys(state.metadata.writes)[0];
1755
- emit(getStateSyncEvent({
1756
- threadId,
1757
- runId: externalRunId,
1758
- agentName: agent.name,
1759
- nodeName: isEndNode ? "__end__" : nodeName,
1760
- state: state.values,
1761
- running: !shouldExit,
1762
- active: false
1763
- }));
1764
- return Promise.resolve();
1765
- }
1766
- __name(streamEvents, "streamEvents");
1767
- function getStateSyncEvent({ threadId, runId, agentName, nodeName, state, running, active }) {
1768
- const stateWithoutMessages = Object.keys(state).reduce((acc, key) => {
1769
- if (key !== "messages") {
1770
- acc[key] = state[key];
1771
- }
1772
- return acc;
1773
- }, {});
1774
- return JSON.stringify({
1775
- event: "on_copilotkit_state_sync",
1776
- thread_id: threadId,
1777
- run_id: runId,
1778
- agent_name: agentName,
1779
- node_name: nodeName,
1780
- active,
1781
- state: stateWithoutMessages,
1782
- running,
1783
- role: "assistant"
1784
- }) + "\n";
1785
- }
1786
- __name(getStateSyncEvent, "getStateSyncEvent");
1787
- var StreamingStateExtractor = /* @__PURE__ */ __name(class StreamingStateExtractor2 {
1788
- emitIntermediateState;
1789
- toolCallBuffer;
1790
- currentToolCall;
1791
- previouslyParsableState;
1792
- constructor(emitIntermediateState) {
1793
- this.emitIntermediateState = emitIntermediateState;
1794
- this.toolCallBuffer = {};
1795
- this.currentToolCall = null;
1796
- this.previouslyParsableState = {};
1797
- }
1798
- bufferToolCalls(event) {
1799
- if (event.data.chunk.tool_call_chunks.length > 0) {
1800
- const chunk = event.data.chunk.tool_call_chunks[0];
1801
- if (chunk.name !== null) {
1802
- this.currentToolCall = chunk.name;
1803
- this.toolCallBuffer[this.currentToolCall] = chunk.args;
1804
- } else if (this.currentToolCall !== null) {
1805
- this.toolCallBuffer[this.currentToolCall] += chunk.args;
1806
- }
1807
- }
1808
- }
1809
- getEmitStateConfig(currentToolName) {
1810
- for (const config2 of this.emitIntermediateState) {
1811
- const stateKey = config2["state_key"];
1812
- const tool = config2["tool"];
1813
- const toolArgument = config2["tool_argument"];
1814
- if (currentToolName === tool) {
1815
- return [
1816
- toolArgument,
1817
- stateKey
1818
- ];
1819
- }
1820
- }
1821
- return [
1822
- null,
1823
- null
1824
- ];
1825
- }
1826
- extractState() {
1827
- const state = {};
1828
- for (const [key, value] of Object.entries(this.toolCallBuffer)) {
1829
- const [argumentName, stateKey] = this.getEmitStateConfig(key);
1830
- if (stateKey === null) {
1831
- continue;
1832
- }
1833
- let parsedValue;
1834
- try {
1835
- parsedValue = (0, import_partial_json.parse)(value);
1836
- } catch (error) {
1837
- if (key in this.previouslyParsableState) {
1838
- parsedValue = this.previouslyParsableState[key];
1839
- } else {
1840
- continue;
1841
- }
1842
- }
1843
- this.previouslyParsableState[key] = parsedValue;
1844
- if (!argumentName) {
1845
- state[stateKey] = parsedValue;
1846
- } else {
1847
- state[stateKey] = parsedValue[argumentName];
1848
- }
1849
- }
1850
- return state;
1851
- }
1852
- }, "StreamingStateExtractor");
1853
- function langGraphDefaultMergeState(state, messages, actions) {
1854
- if (messages.length > 0 && "role" in messages[0] && messages[0].role === "system") {
1855
- messages = messages.slice(1);
1856
- }
1857
- const mergedMessages = state.messages || [];
1858
- const existingMessageIds = new Set(mergedMessages.map((message) => message.id));
1859
- for (const message of messages) {
1860
- if (!existingMessageIds.has(message.id)) {
1861
- mergedMessages.push(message);
1862
- }
1579
+ // src/lib/runtime/remote-actions.ts
1580
+ function isLangGraphAgentAction(action) {
1581
+ if (!action) {
1582
+ return false;
1863
1583
  }
1864
- return deepMerge(state, {
1865
- messages: mergedMessages,
1866
- copilotkit: {
1867
- actions
1868
- }
1869
- });
1584
+ return typeof action.langGraphAgentHandler === "function";
1870
1585
  }
1871
- __name(langGraphDefaultMergeState, "langGraphDefaultMergeState");
1872
- function deepMerge(obj1, obj2) {
1873
- let result = {
1874
- ...obj1
1586
+ __name(isLangGraphAgentAction, "isLangGraphAgentAction");
1587
+ function createHeaders(onBeforeRequest, graphqlContext) {
1588
+ const headers = {
1589
+ "Content-Type": "application/json"
1875
1590
  };
1876
- for (let key in obj2) {
1877
- if (typeof obj2[key] === "object" && !Array.isArray(obj2[key])) {
1878
- if (obj1[key]) {
1879
- result[key] = deepMerge(obj1[key], obj2[key]);
1880
- } else {
1881
- result[key] = {
1882
- ...obj2[key]
1883
- };
1884
- }
1885
- } else {
1886
- result[key] = obj2[key];
1591
+ if (onBeforeRequest) {
1592
+ const { headers: additionalHeaders } = onBeforeRequest({
1593
+ ctx: graphqlContext
1594
+ });
1595
+ if (additionalHeaders) {
1596
+ Object.assign(headers, additionalHeaders);
1887
1597
  }
1888
1598
  }
1889
- return result;
1599
+ return headers;
1890
1600
  }
1891
- __name(deepMerge, "deepMerge");
1892
- function formatMessages(messages) {
1893
- return messages.map((message) => {
1894
- if ("content" in message) {
1895
- return message;
1896
- }
1897
- if ("arguments" in message) {
1898
- const toolCall = {
1899
- name: message["name"],
1900
- args: message["arguments"],
1901
- id: message["id"]
1902
- };
1903
- return {
1904
- ...message,
1905
- content: "",
1906
- tool_calls: [
1907
- toolCall
1908
- ],
1909
- role: message["role"] ?? MessageRole.assistant
1910
- };
1911
- }
1912
- if ("actionExecutionId" in message) {
1601
+ __name(createHeaders, "createHeaders");
1602
+ async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: logger2, frontendUrl }) {
1603
+ logger2.debug({
1604
+ url
1605
+ }, "Fetching actions from url");
1606
+ const headers = createHeaders(onBeforeRequest, graphqlContext);
1607
+ try {
1608
+ const response = await fetch(`${url}/info`, {
1609
+ method: "POST",
1610
+ headers,
1611
+ body: JSON.stringify({
1612
+ properties: graphqlContext.properties,
1613
+ frontendUrl
1614
+ })
1615
+ });
1616
+ if (!response.ok) {
1617
+ logger2.error({
1618
+ url,
1619
+ status: response.status,
1620
+ body: await response.text()
1621
+ }, "Failed to fetch actions from url");
1913
1622
  return {
1914
- ...message,
1915
- content: message["result"],
1916
- name: message["actionName"],
1917
- tool_call_id: message["actionExecutionId"],
1918
- role: message["role"] ?? MessageRole.user
1623
+ actions: [],
1624
+ agents: []
1919
1625
  };
1920
1626
  }
1921
- return message;
1922
- });
1923
- }
1924
- __name(formatMessages, "formatMessages");
1925
-
1926
- // src/lib/runtime/remote-action-constructors.ts
1927
- function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, messages, agentStates }) {
1928
- const agents = endpoint.agents.map((agent) => ({
1929
- name: agent.name,
1930
- description: agent.description,
1931
- parameters: [],
1932
- handler: async (_args) => {
1933
- },
1934
- langGraphAgentHandler: async ({ name, actionInputsWithoutAgents, threadId, nodeName }) => {
1935
- var _a;
1936
- logger2.debug({
1937
- actionName: agent.name
1938
- }, "Executing LangGraph Cloud agent");
1939
- telemetry_client_default.capture("oss.runtime.remote_action_executed", {});
1940
- let state = {};
1941
- if (agentStates) {
1942
- const jsonState = (_a = agentStates.find((state2) => state2.agentName === name)) == null ? void 0 : _a.state;
1943
- if (jsonState) {
1944
- state = JSON.parse(jsonState);
1945
- }
1946
- }
1947
- try {
1948
- const response = await execute({
1949
- deploymentUrl: endpoint.deploymentUrl,
1950
- langsmithApiKey: endpoint.langsmithApiKey,
1951
- agent,
1952
- threadId,
1953
- nodeName,
1954
- messages,
1955
- state,
1956
- properties: graphqlContext.properties,
1957
- actions: actionInputsWithoutAgents.map((action) => ({
1958
- name: action.name,
1959
- description: action.description,
1960
- parameters: JSON.parse(action.jsonSchema)
1961
- }))
1962
- });
1963
- const eventSource = new RemoteLangGraphEventSource();
1964
- streamResponse(response, eventSource.eventStream$);
1965
- return eventSource.processLangGraphEvents();
1966
- } catch (error) {
1967
- logger2.error({
1968
- url: endpoint.deploymentUrl,
1969
- status: 500,
1970
- body: error.message
1971
- }, "Failed to execute LangGraph Cloud agent");
1972
- throw new Error("Failed to execute LangGraph Cloud agent");
1973
- }
1974
- }
1975
- }));
1976
- return [
1977
- ...agents
1978
- ];
1627
+ const json = await response.json();
1628
+ logger2.debug({
1629
+ json
1630
+ }, "Fetched actions from url");
1631
+ return json;
1632
+ } catch (error) {
1633
+ logger2.error({
1634
+ error: error.message ? error.message : error + ""
1635
+ }, "Failed to fetch actions from url");
1636
+ return {
1637
+ actions: [],
1638
+ agents: []
1639
+ };
1640
+ }
1979
1641
  }
1980
- __name(constructLGCRemoteAction, "constructLGCRemoteAction");
1642
+ __name(fetchRemoteInfo, "fetchRemoteInfo");
1981
1643
  function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, logger: logger2, messages, agentStates }) {
1982
1644
  const actions = json["actions"].map((action) => ({
1983
1645
  name: action.name,
@@ -2069,7 +1731,7 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
2069
1731
  throw new Error("Failed to execute remote agent");
2070
1732
  }
2071
1733
  const eventSource = new RemoteLangGraphEventSource();
2072
- streamResponse(response.body, eventSource.eventStream$);
1734
+ eventSource.streamResponse(response);
2073
1735
  return eventSource.processLangGraphEvents();
2074
1736
  }
2075
1737
  }));
@@ -2079,165 +1741,34 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
2079
1741
  ];
2080
1742
  }
2081
1743
  __name(constructRemoteActions, "constructRemoteActions");
2082
- async function streamResponse(response, eventStream$) {
2083
- const reader = response.getReader();
2084
- const decoder = new TextDecoder();
2085
- let buffer = [];
2086
- function flushBuffer() {
2087
- const currentBuffer = buffer.join("");
2088
- if (currentBuffer.trim().length === 0) {
2089
- return;
2090
- }
2091
- const parts = currentBuffer.split("\n");
2092
- if (parts.length === 0) {
2093
- return;
2094
- }
2095
- const lastPartIsComplete = currentBuffer.endsWith("\n");
2096
- buffer = [];
2097
- if (!lastPartIsComplete) {
2098
- buffer.push(parts.pop());
2099
- }
2100
- parts.map((part) => part.trim()).filter((part) => part != "").forEach((part) => {
2101
- eventStream$.next(JSON.parse(part));
2102
- });
2103
- }
2104
- __name(flushBuffer, "flushBuffer");
2105
- try {
2106
- while (true) {
2107
- const { done, value } = await reader.read();
2108
- if (!done) {
2109
- buffer.push(decoder.decode(value, {
2110
- stream: true
2111
- }));
2112
- }
2113
- flushBuffer();
2114
- if (done) {
2115
- break;
2116
- }
2117
- }
2118
- } catch (error) {
2119
- console.error("Error in stream", error);
2120
- eventStream$.error(error);
2121
- return;
2122
- }
2123
- eventStream$.complete();
2124
- }
2125
- __name(streamResponse, "streamResponse");
2126
- function createHeaders(onBeforeRequest, graphqlContext) {
2127
- const headers = {
2128
- "Content-Type": "application/json"
2129
- };
2130
- if (onBeforeRequest) {
2131
- const { headers: additionalHeaders } = onBeforeRequest({
2132
- ctx: graphqlContext
2133
- });
2134
- if (additionalHeaders) {
2135
- Object.assign(headers, additionalHeaders);
2136
- }
2137
- }
2138
- return headers;
2139
- }
2140
- __name(createHeaders, "createHeaders");
2141
-
2142
- // src/lib/runtime/remote-actions.ts
2143
- var EndpointType;
2144
- (function(EndpointType2) {
2145
- EndpointType2["CopilotKit"] = "copilotKit";
2146
- EndpointType2["LangGraphCloud"] = "langgraph-cloud";
2147
- })(EndpointType || (EndpointType = {}));
2148
- function isLangGraphAgentAction(action) {
2149
- if (!action) {
2150
- return false;
2151
- }
2152
- return typeof action.langGraphAgentHandler === "function";
2153
- }
2154
- __name(isLangGraphAgentAction, "isLangGraphAgentAction");
2155
- async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: logger2, frontendUrl }) {
2156
- logger2.debug({
2157
- url
2158
- }, "Fetching actions from url");
2159
- const headers = createHeaders(onBeforeRequest, graphqlContext);
2160
- try {
2161
- const response = await fetch(`${url}/info`, {
2162
- method: "POST",
2163
- headers,
2164
- body: JSON.stringify({
2165
- properties: graphqlContext.properties,
2166
- frontendUrl
2167
- })
2168
- });
2169
- if (!response.ok) {
2170
- logger2.error({
2171
- url,
2172
- status: response.status,
2173
- body: await response.text()
2174
- }, "Failed to fetch actions from url");
2175
- return {
2176
- actions: [],
2177
- agents: []
2178
- };
2179
- }
2180
- const json = await response.json();
2181
- logger2.debug({
2182
- json
2183
- }, "Fetched actions from url");
2184
- return json;
2185
- } catch (error) {
2186
- logger2.error({
2187
- error: error.message ? error.message : error + ""
2188
- }, "Failed to fetch actions from url");
2189
- return {
2190
- actions: [],
2191
- agents: []
2192
- };
2193
- }
2194
- }
2195
- __name(fetchRemoteInfo, "fetchRemoteInfo");
2196
- async function setupRemoteActions({ remoteEndpointDefinitions, graphqlContext, messages, agentStates, frontendUrl }) {
1744
+ async function setupRemoteActions({ remoteActionDefinitions, graphqlContext, messages, agentStates, frontendUrl }) {
2197
1745
  const logger2 = graphqlContext.logger.child({
2198
1746
  component: "remote-actions.fetchRemoteActions"
2199
1747
  });
2200
1748
  logger2.debug({
2201
- remoteEndpointDefinitions
2202
- }, "Fetching from remote endpoints");
2203
- const filtered = remoteEndpointDefinitions.filter((value, index, self) => {
2204
- if (value.type === "langgraph-cloud") {
2205
- return value;
2206
- }
2207
- return index === self.findIndex((t) => t.url === value.url);
2208
- });
2209
- const result = await Promise.all(filtered.map(async (endpoint) => {
2210
- if (endpoint.type === "langgraph-cloud") {
2211
- return constructLGCRemoteAction({
2212
- endpoint,
2213
- messages,
2214
- graphqlContext,
2215
- logger: logger2.child({
2216
- component: "remote-actions.constructLGCRemoteAction",
2217
- endpoint
2218
- }),
2219
- agentStates
2220
- });
2221
- }
1749
+ remoteActionDefinitions
1750
+ }, "Fetching remote actions");
1751
+ const filtered = remoteActionDefinitions.filter((value, index, self) => index === self.findIndex((t) => t.url === value.url));
1752
+ const result = await Promise.all(filtered.map(async (actionDefinition) => {
2222
1753
  const json = await fetchRemoteInfo({
2223
- url: endpoint.url,
2224
- onBeforeRequest: endpoint.onBeforeRequest,
1754
+ url: actionDefinition.url,
1755
+ onBeforeRequest: actionDefinition.onBeforeRequest,
2225
1756
  graphqlContext,
2226
1757
  logger: logger2.child({
2227
1758
  component: "remote-actions.fetchActionsFromUrl",
2228
- endpoint
1759
+ actionDefinition
2229
1760
  }),
2230
1761
  frontendUrl
2231
1762
  });
2232
1763
  return constructRemoteActions({
2233
1764
  json,
2234
1765
  messages,
2235
- url: endpoint.url,
2236
- onBeforeRequest: endpoint.onBeforeRequest,
1766
+ url: actionDefinition.url,
1767
+ onBeforeRequest: actionDefinition.onBeforeRequest,
2237
1768
  graphqlContext,
2238
1769
  logger: logger2.child({
2239
1770
  component: "remote-actions.constructActions",
2240
- endpoint
1771
+ actionDefinition
2241
1772
  }),
2242
1773
  agentStates
2243
1774
  });
@@ -2401,7 +1932,13 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
2401
1932
  }
2402
1933
  let args = [];
2403
1934
  if (actionArguments) {
2404
- args = JSON.parse(actionArguments);
1935
+ try {
1936
+ args = JSON.parse(actionArguments);
1937
+ } catch (e) {
1938
+ console.warn("Action argument unparsable", {
1939
+ actionArguments
1940
+ });
1941
+ }
2405
1942
  }
2406
1943
  if (isLangGraphAgentAction(action)) {
2407
1944
  eventStream$.sendActionExecutionResult(actionExecutionId, action.name, `${action.name} agent started`);
@@ -2429,7 +1966,7 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
2429
1966
  __name(executeAction, "executeAction");
2430
1967
 
2431
1968
  // src/graphql/types/base/index.ts
2432
- var import_type_graphql2 = require("type-graphql");
1969
+ var import_type_graphql = require("type-graphql");
2433
1970
  function _ts_decorate(decorators, target, key, desc) {
2434
1971
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2435
1972
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -2452,15 +1989,15 @@ var BaseMessageInput = class {
2452
1989
  };
2453
1990
  __name(BaseMessageInput, "BaseMessageInput");
2454
1991
  _ts_decorate([
2455
- (0, import_type_graphql2.Field)(() => String),
1992
+ (0, import_type_graphql.Field)(() => String),
2456
1993
  _ts_metadata("design:type", String)
2457
1994
  ], BaseMessageInput.prototype, "id", void 0);
2458
1995
  _ts_decorate([
2459
- (0, import_type_graphql2.Field)(() => Date),
1996
+ (0, import_type_graphql.Field)(() => Date),
2460
1997
  _ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
2461
1998
  ], BaseMessageInput.prototype, "createdAt", void 0);
2462
1999
  BaseMessageInput = _ts_decorate([
2463
- (0, import_type_graphql2.InputType)()
2000
+ (0, import_type_graphql.InputType)()
2464
2001
  ], BaseMessageInput);
2465
2002
 
2466
2003
  // src/graphql/types/converted/index.ts
@@ -2564,7 +2101,7 @@ __name(convertGqlInputToMessages, "convertGqlInputToMessages");
2564
2101
  var import_rxjs3 = require("rxjs");
2565
2102
  var CopilotRuntime = class {
2566
2103
  actions;
2567
- remoteEndpointDefinitions;
2104
+ remoteActionDefinitions;
2568
2105
  langserve = [];
2569
2106
  onBeforeRequest;
2570
2107
  onAfterRequest;
@@ -2575,7 +2112,7 @@ var CopilotRuntime = class {
2575
2112
  const remoteChain = new RemoteChain(chain);
2576
2113
  this.langserve.push(remoteChain.toAction());
2577
2114
  }
2578
- this.remoteEndpointDefinitions = (params == null ? void 0 : params.remoteEndpoints) || [];
2115
+ this.remoteActionDefinitions = (params == null ? void 0 : params.remoteActions) || [];
2579
2116
  this.onBeforeRequest = (_a = params == null ? void 0 : params.middleware) == null ? void 0 : _a.onBeforeRequest;
2580
2117
  this.onAfterRequest = (_b = params == null ? void 0 : params.middleware) == null ? void 0 : _b.onAfterRequest;
2581
2118
  }
@@ -2644,7 +2181,7 @@ var CopilotRuntime = class {
2644
2181
  async processAgentRequest(request) {
2645
2182
  var _a;
2646
2183
  const { messages: rawMessages, outputMessagesPromise, graphqlContext, agentSession } = request;
2647
- const { threadId, agentName, nodeName } = agentSession;
2184
+ const { threadId = (0, import_shared9.randomId)(), agentName, nodeName } = agentSession;
2648
2185
  const serverSideActions = await this.getServerSideActions(request);
2649
2186
  const messages = convertGqlInputToMessages(rawMessages);
2650
2187
  const agent = serverSideActions.find((action) => action.name === agentName && isLangGraphAgentAction(action));
@@ -2716,12 +2253,8 @@ var CopilotRuntime = class {
2716
2253
  console.error("Error loading langserve chain:", error);
2717
2254
  }
2718
2255
  }
2719
- const remoteEndpointDefinitions = this.remoteEndpointDefinitions.map((endpoint) => ({
2720
- ...endpoint,
2721
- type: this.resolveEndpointType(endpoint)
2722
- }));
2723
2256
  const remoteActions = await setupRemoteActions({
2724
- remoteEndpointDefinitions,
2257
+ remoteActionDefinitions: this.remoteActionDefinitions,
2725
2258
  graphqlContext,
2726
2259
  messages: inputMessages,
2727
2260
  agentStates,
@@ -2737,12 +2270,6 @@ var CopilotRuntime = class {
2737
2270
  ...remoteActions
2738
2271
  ];
2739
2272
  }
2740
- resolveEndpointType(endpoint) {
2741
- if (!endpoint.type && "langsmithApiKey" in endpoint && "deploymentUrl" in endpoint && "agents" in endpoint) {
2742
- return EndpointType.LangGraphCloud;
2743
- }
2744
- return endpoint.type;
2745
- }
2746
2273
  };
2747
2274
  __name(CopilotRuntime, "CopilotRuntime");
2748
2275
  function flattenToolCallsNoDuplicates(toolsByPriority) {
@@ -2757,20 +2284,6 @@ function flattenToolCallsNoDuplicates(toolsByPriority) {
2757
2284
  return allTools;
2758
2285
  }
2759
2286
  __name(flattenToolCallsNoDuplicates, "flattenToolCallsNoDuplicates");
2760
- function copilotKitEndpoint(config2) {
2761
- return {
2762
- ...config2,
2763
- type: EndpointType.CopilotKit
2764
- };
2765
- }
2766
- __name(copilotKitEndpoint, "copilotKitEndpoint");
2767
- function langGraphCloudEndpoint(config2) {
2768
- return {
2769
- ...config2,
2770
- type: EndpointType.LangGraphCloud
2771
- };
2772
- }
2773
- __name(langGraphCloudEndpoint, "langGraphCloudEndpoint");
2774
2287
 
2775
2288
  // src/lib/integrations/shared.ts
2776
2289
  var import_type_graphql16 = require("type-graphql");
@@ -2784,6 +2297,43 @@ var import_type_graphql11 = require("type-graphql");
2784
2297
 
2785
2298
  // src/graphql/inputs/message.input.ts
2786
2299
  var import_type_graphql3 = require("type-graphql");
2300
+
2301
+ // src/graphql/types/enums.ts
2302
+ var import_type_graphql2 = require("type-graphql");
2303
+ var MessageRole;
2304
+ (function(MessageRole2) {
2305
+ MessageRole2["user"] = "user";
2306
+ MessageRole2["assistant"] = "assistant";
2307
+ MessageRole2["system"] = "system";
2308
+ })(MessageRole || (MessageRole = {}));
2309
+ var ActionExecutionScope;
2310
+ (function(ActionExecutionScope2) {
2311
+ ActionExecutionScope2["server"] = "server";
2312
+ ActionExecutionScope2["client"] = "client";
2313
+ ActionExecutionScope2["passThrough"] = "passThrough";
2314
+ })(ActionExecutionScope || (ActionExecutionScope = {}));
2315
+ var CopilotRequestType;
2316
+ (function(CopilotRequestType2) {
2317
+ CopilotRequestType2["Chat"] = "Chat";
2318
+ CopilotRequestType2["Task"] = "Task";
2319
+ CopilotRequestType2["TextareaCompletion"] = "TextareaCompletion";
2320
+ CopilotRequestType2["TextareaPopover"] = "TextareaPopover";
2321
+ CopilotRequestType2["Suggestion"] = "Suggestion";
2322
+ })(CopilotRequestType || (CopilotRequestType = {}));
2323
+ (0, import_type_graphql2.registerEnumType)(MessageRole, {
2324
+ name: "MessageRole",
2325
+ description: "The role of the message"
2326
+ });
2327
+ (0, import_type_graphql2.registerEnumType)(ActionExecutionScope, {
2328
+ name: "ActionExecutionScope",
2329
+ description: "The scope of the action"
2330
+ });
2331
+ (0, import_type_graphql2.registerEnumType)(CopilotRequestType, {
2332
+ name: "CopilotRequestType",
2333
+ description: "The type of Copilot request"
2334
+ });
2335
+
2336
+ // src/graphql/inputs/message.input.ts
2787
2337
  function _ts_decorate2(decorators, target, key, desc) {
2788
2338
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2789
2339
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -4445,7 +3995,6 @@ __name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
4445
3995
  UnknownErrorResponse,
4446
3996
  buildSchema,
4447
3997
  config,
4448
- copilotKitEndpoint,
4449
3998
  copilotRuntimeNestEndpoint,
4450
3999
  copilotRuntimeNextJSAppRouterEndpoint,
4451
4000
  copilotRuntimeNextJSPagesRouterEndpoint,
@@ -4453,7 +4002,6 @@ __name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
4453
4002
  copilotRuntimeNodeHttpEndpoint,
4454
4003
  createContext,
4455
4004
  flattenToolCallsNoDuplicates,
4456
- getCommonConfig,
4457
- langGraphCloudEndpoint
4005
+ getCommonConfig
4458
4006
  });
4459
4007
  //# sourceMappingURL=index.js.map