@copilotkit/runtime 1.5.12-next.5 → 1.5.12-next.7

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 (72) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/__snapshots__/schema/schema.graphql +33 -0
  3. package/dist/{chunk-MFDRA3BJ.mjs → chunk-34276UUU.mjs} +652 -285
  4. package/dist/chunk-34276UUU.mjs.map +1 -0
  5. package/dist/{chunk-XRW7ZSWJ.mjs → chunk-DLESGNLO.mjs} +2 -2
  6. package/dist/{chunk-TPTCSIAR.mjs → chunk-S3KKBII4.mjs} +42 -30
  7. package/dist/chunk-S3KKBII4.mjs.map +1 -0
  8. package/dist/{chunk-QDMAQO2C.mjs → chunk-UBYSQI43.mjs} +2 -2
  9. package/dist/{chunk-NORCONUM.mjs → chunk-WTUPF3W3.mjs} +2 -2
  10. package/dist/{copilot-runtime-1a224a0f.d.ts → copilot-runtime-8c442d65.d.ts} +16 -3
  11. package/dist/graphql/types/converted/index.d.ts +1 -1
  12. package/dist/{groq-adapter-c35c5374.d.ts → groq-adapter-7a82cd22.d.ts} +21 -1
  13. package/dist/{index-24315d90.d.ts → index-a7f37670.d.ts} +1 -1
  14. package/dist/index.d.ts +4 -4
  15. package/dist/index.js +727 -348
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.mjs +5 -5
  18. package/dist/{langserve-a16ef8f4.d.ts → langserve-e308c437.d.ts} +32 -3
  19. package/dist/lib/index.d.ts +4 -4
  20. package/dist/lib/index.js +725 -346
  21. package/dist/lib/index.js.map +1 -1
  22. package/dist/lib/index.mjs +5 -5
  23. package/dist/lib/integrations/index.d.ts +4 -4
  24. package/dist/lib/integrations/index.js +504 -244
  25. package/dist/lib/integrations/index.js.map +1 -1
  26. package/dist/lib/integrations/index.mjs +5 -5
  27. package/dist/lib/integrations/nest/index.d.ts +3 -3
  28. package/dist/lib/integrations/nest/index.js +504 -244
  29. package/dist/lib/integrations/nest/index.js.map +1 -1
  30. package/dist/lib/integrations/nest/index.mjs +3 -3
  31. package/dist/lib/integrations/node-express/index.d.ts +3 -3
  32. package/dist/lib/integrations/node-express/index.js +504 -244
  33. package/dist/lib/integrations/node-express/index.js.map +1 -1
  34. package/dist/lib/integrations/node-express/index.mjs +3 -3
  35. package/dist/lib/integrations/node-http/index.d.ts +3 -3
  36. package/dist/lib/integrations/node-http/index.js +504 -244
  37. package/dist/lib/integrations/node-http/index.js.map +1 -1
  38. package/dist/lib/integrations/node-http/index.mjs +2 -2
  39. package/dist/service-adapters/index.d.ts +4 -4
  40. package/dist/service-adapters/index.js +23 -11
  41. package/dist/service-adapters/index.js.map +1 -1
  42. package/dist/service-adapters/index.mjs +1 -1
  43. package/package.json +2 -2
  44. package/src/graphql/inputs/extensions.input.ts +21 -0
  45. package/src/graphql/inputs/generate-copilot-response.input.ts +4 -0
  46. package/src/graphql/inputs/load-agent-state.input.ts +10 -0
  47. package/src/graphql/resolvers/copilot.resolver.ts +8 -3
  48. package/src/graphql/resolvers/state.resolver.ts +23 -0
  49. package/src/graphql/types/agents-response.type.ts +1 -4
  50. package/src/graphql/types/copilot-response.type.ts +5 -1
  51. package/src/graphql/types/extensions-response.type.ts +23 -0
  52. package/src/graphql/types/load-agent-state-response.type.ts +17 -0
  53. package/src/lib/integrations/shared.ts +2 -1
  54. package/src/lib/runtime/copilot-runtime.ts +155 -31
  55. package/src/lib/runtime/remote-action-constructors.ts +42 -33
  56. package/src/lib/runtime/remote-actions.ts +12 -7
  57. package/src/lib/runtime/remote-lg-action.ts +24 -12
  58. package/src/service-adapters/anthropic/anthropic-adapter.ts +2 -3
  59. package/src/service-adapters/empty/empty-adapter.ts +2 -2
  60. package/src/service-adapters/events.ts +5 -0
  61. package/src/service-adapters/experimental/ollama/ollama-adapter.ts +2 -2
  62. package/src/service-adapters/groq/groq-adapter.ts +2 -2
  63. package/src/service-adapters/langchain/langchain-adapter.ts +10 -3
  64. package/src/service-adapters/openai/openai-adapter.ts +4 -3
  65. package/src/service-adapters/openai/openai-assistant-adapter.ts +15 -4
  66. package/src/service-adapters/service-adapter.ts +4 -0
  67. package/src/service-adapters/unify/unify-adapter.ts +2 -3
  68. package/dist/chunk-MFDRA3BJ.mjs.map +0 -1
  69. package/dist/chunk-TPTCSIAR.mjs.map +0 -1
  70. /package/dist/{chunk-XRW7ZSWJ.mjs.map → chunk-DLESGNLO.mjs.map} +0 -0
  71. /package/dist/{chunk-QDMAQO2C.mjs.map → chunk-UBYSQI43.mjs.map} +0 -0
  72. /package/dist/{chunk-NORCONUM.mjs.map → chunk-WTUPF3W3.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.5.12-next.5",
47
+ version: "1.5.12-next.7",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -157,7 +157,7 @@ module.exports = __toCommonJS(src_exports);
157
157
  var import_reflect_metadata = require("reflect-metadata");
158
158
 
159
159
  // src/lib/runtime/copilot-runtime.ts
160
- var import_shared12 = require("@copilotkit/shared");
160
+ var import_shared15 = require("@copilotkit/shared");
161
161
 
162
162
  // src/service-adapters/langchain/langserve.ts
163
163
  var import_remote = require("langchain/runnables/remote");
@@ -397,8 +397,9 @@ var OpenAIAdapter = class {
397
397
  this.disableParallelToolCalls = (params == null ? void 0 : params.disableParallelToolCalls) || false;
398
398
  }
399
399
  async process(request) {
400
- const { threadId, model = this.model, messages, actions, eventSource, forwardedParameters } = request;
400
+ const { threadId: threadIdFromRequest, model = this.model, messages, actions, eventSource, forwardedParameters } = request;
401
401
  const tools = actions.map(convertActionInputToOpenAITool);
402
+ const threadId = threadIdFromRequest ?? (0, import_shared.randomUUID)();
402
403
  let openaiMessages = messages.map(convertMessageToOpenAIMessage);
403
404
  openaiMessages = limitMessagesToTokenCount(openaiMessages, tools, model);
404
405
  let toolChoice = forwardedParameters == null ? void 0 : forwardedParameters.toolChoice;
@@ -496,7 +497,7 @@ var OpenAIAdapter = class {
496
497
  eventStream$.complete();
497
498
  });
498
499
  return {
499
- threadId: threadId || (0, import_shared.randomId)()
500
+ threadId
500
501
  };
501
502
  }
502
503
  };
@@ -742,8 +743,8 @@ var LangChainAdapter = class {
742
743
  }
743
744
  async process(request) {
744
745
  try {
745
- const { eventSource, model, actions, messages, runId } = request;
746
- const threadId = request.threadId ?? (0, import_shared3.randomId)();
746
+ const { eventSource, model, actions, messages, runId, threadId: threadIdFromRequest } = request;
747
+ const threadId = threadIdFromRequest ?? (0, import_shared3.randomUUID)();
747
748
  const result = await this.options.chainFn({
748
749
  messages: messages.map(convertMessageToLangChainMessage),
749
750
  tools: actions.map(convertActionInputToLangChainTool),
@@ -804,8 +805,12 @@ var OpenAIAssistantAdapter = class {
804
805
  this.disableParallelToolCalls = (params == null ? void 0 : params.disableParallelToolCalls) || false;
805
806
  }
806
807
  async process(request) {
808
+ var _a, _b;
807
809
  const { messages, actions, eventSource, runId, forwardedParameters } = request;
808
- let threadId = request.threadId || (await this.openai.beta.threads.create()).id;
810
+ let threadId = (_b = (_a = request.extensions) == null ? void 0 : _a.openaiAssistantAPI) == null ? void 0 : _b.threadId;
811
+ if (!threadId) {
812
+ threadId = (await this.openai.beta.threads.create()).id;
813
+ }
809
814
  const lastMessage = messages.at(-1);
810
815
  let nextRunId = void 0;
811
816
  if (lastMessage.isResultMessage() && runId) {
@@ -816,8 +821,15 @@ var OpenAIAssistantAdapter = class {
816
821
  throw new Error("No actionable message found in the messages");
817
822
  }
818
823
  return {
824
+ runId: nextRunId,
819
825
  threadId,
820
- runId: nextRunId
826
+ extensions: {
827
+ ...request.extensions,
828
+ openaiAssistantAPI: {
829
+ threadId,
830
+ runId: nextRunId
831
+ }
832
+ }
821
833
  };
822
834
  }
823
835
  async submitToolOutputs(threadId, runId, messages, eventSource) {
@@ -1085,7 +1097,7 @@ var UnifyAdapter = class {
1085
1097
  eventStream$.complete();
1086
1098
  });
1087
1099
  return {
1088
- threadId: request.threadId || (0, import_shared4.randomId)()
1100
+ threadId: request.threadId || (0, import_shared4.randomUUID)()
1089
1101
  };
1090
1102
  }
1091
1103
  };
@@ -1206,7 +1218,7 @@ var GroqAdapter = class {
1206
1218
  eventStream$.complete();
1207
1219
  });
1208
1220
  return {
1209
- threadId: threadId || (0, import_shared5.randomId)()
1221
+ threadId: request.threadId || (0, import_shared5.randomUUID)()
1210
1222
  };
1211
1223
  }
1212
1224
  };
@@ -1457,7 +1469,7 @@ var AnthropicAdapter = class {
1457
1469
  eventStream$.complete();
1458
1470
  });
1459
1471
  return {
1460
- threadId: threadId || (0, import_shared6.randomId)()
1472
+ threadId: threadId || (0, import_shared6.randomUUID)()
1461
1473
  };
1462
1474
  }
1463
1475
  };
@@ -1532,7 +1544,7 @@ var ExperimentalOllamaAdapter = class {
1532
1544
  eventStream$.complete();
1533
1545
  });
1534
1546
  return {
1535
- threadId: request.threadId || (0, import_shared7.randomId)()
1547
+ threadId: request.threadId || (0, import_shared7.randomUUID)()
1536
1548
  };
1537
1549
  }
1538
1550
  };
@@ -1543,7 +1555,7 @@ var import_shared8 = require("@copilotkit/shared");
1543
1555
  var EmptyAdapter = class {
1544
1556
  async process(request) {
1545
1557
  return {
1546
- threadId: request.threadId || (0, import_shared8.randomId)()
1558
+ threadId: request.threadId || (0, import_shared8.randomUUID)()
1547
1559
  };
1548
1560
  }
1549
1561
  };
@@ -1551,11 +1563,11 @@ __name(EmptyAdapter, "EmptyAdapter");
1551
1563
  var ExperimentalEmptyAdapter = EmptyAdapter;
1552
1564
 
1553
1565
  // src/service-adapters/events.ts
1554
- var import_shared11 = require("@copilotkit/shared");
1566
+ var import_shared14 = require("@copilotkit/shared");
1555
1567
  var import_rxjs2 = require("rxjs");
1556
1568
 
1557
1569
  // src/lib/telemetry-client.ts
1558
- var import_shared10 = require("@copilotkit/shared");
1570
+ var import_shared13 = require("@copilotkit/shared");
1559
1571
 
1560
1572
  // src/lib/runtime/remote-action-constructors.ts
1561
1573
  var import_node_crypto2 = require("crypto");
@@ -1803,6 +1815,7 @@ __name(RemoteLangGraphEventSource, "RemoteLangGraphEventSource");
1803
1815
  // src/lib/runtime/remote-lg-action.ts
1804
1816
  var import_langgraph_sdk = require("@langchain/langgraph-sdk");
1805
1817
  var import_node_crypto = require("crypto");
1818
+ var import_shared10 = require("@copilotkit/shared");
1806
1819
  var import_partial_json = require("partial-json");
1807
1820
 
1808
1821
  // src/graphql/types/enums.ts
@@ -1856,7 +1869,7 @@ async function execute(args) {
1856
1869
  __name(execute, "execute");
1857
1870
  async function streamEvents(controller, args) {
1858
1871
  var _a, _b, _c, _d, _e, _f;
1859
- const { deploymentUrl, langsmithApiKey, threadId: agrsInitialThreadId, agent, nodeName: initialNodeName, state: initialState, messages, actions, logger: logger2 } = args;
1872
+ const { deploymentUrl, langsmithApiKey, threadId: argsInitialThreadId, agent, nodeName: initialNodeName, state: initialState, messages, actions, logger: logger2 } = args;
1860
1873
  let nodeName = initialNodeName;
1861
1874
  let state = initialState;
1862
1875
  const { name, assistantId: initialAssistantId } = agent;
@@ -1864,15 +1877,18 @@ async function streamEvents(controller, args) {
1864
1877
  apiUrl: deploymentUrl,
1865
1878
  apiKey: langsmithApiKey
1866
1879
  });
1867
- let initialThreadId = agrsInitialThreadId;
1868
- const wasInitiatedWithExistingThread = !!initialThreadId;
1869
- if (initialThreadId && initialThreadId.startsWith("ck-")) {
1870
- initialThreadId = initialThreadId.substring(3);
1880
+ let threadId = argsInitialThreadId ?? (0, import_shared10.randomUUID)();
1881
+ if (argsInitialThreadId && argsInitialThreadId.startsWith("ck-")) {
1882
+ threadId = argsInitialThreadId.substring(3);
1883
+ }
1884
+ if (!(0, import_shared10.isValidUUID)(threadId)) {
1885
+ console.warn(`Cannot use the threadId ${threadId} with LangGraph Platform. Must be a valid UUID.`);
1871
1886
  }
1872
- const threadId = initialThreadId ?? (0, import_node_crypto.randomUUID)();
1873
- if (initialThreadId === threadId) {
1887
+ let wasInitiatedWithExistingThread = true;
1888
+ try {
1874
1889
  await client.threads.get(threadId);
1875
- } else {
1890
+ } catch (error) {
1891
+ wasInitiatedWithExistingThread = false;
1876
1892
  await client.threads.create({
1877
1893
  threadId
1878
1894
  });
@@ -1885,7 +1901,7 @@ async function streamEvents(controller, args) {
1885
1901
  }
1886
1902
  const agentStateValues = agentState.values;
1887
1903
  state.messages = agentStateValues.messages;
1888
- const mode = wasInitiatedWithExistingThread && nodeName != "__end__" ? "continue" : "start";
1904
+ const mode = threadId && nodeName != "__end__" && nodeName != void 0 && nodeName != null ? "continue" : "start";
1889
1905
  let formattedMessages = [];
1890
1906
  try {
1891
1907
  formattedMessages = copilotkitMessagesToLangChain(messages);
@@ -2305,6 +2321,7 @@ function copilotkitMessagesToLangChain(messages) {
2305
2321
  __name(copilotkitMessagesToLangChain, "copilotkitMessagesToLangChain");
2306
2322
 
2307
2323
  // src/lib/runtime/remote-action-constructors.ts
2324
+ var import_shared11 = require("@copilotkit/shared");
2308
2325
  function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, messages, agentStates }) {
2309
2326
  const agents = endpoint.agents.map((agent) => ({
2310
2327
  name: agent.name,
@@ -2385,8 +2402,9 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
2385
2402
  type: "self-hosted",
2386
2403
  agentsAmount: totalAgents
2387
2404
  });
2405
+ const fetchUrl = `${url}/actions/execute`;
2388
2406
  try {
2389
- const response = await fetch(`${url}/actions/execute`, {
2407
+ const response = await fetch(fetchUrl, {
2390
2408
  method: "POST",
2391
2409
  headers,
2392
2410
  body: JSON.stringify({
@@ -2411,10 +2429,13 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
2411
2429
  }, "Executed remote action");
2412
2430
  return result;
2413
2431
  } catch (error) {
2414
- logger2.error({
2415
- error: error.message ? error.message : error + ""
2416
- }, "Failed to execute remote action");
2417
- return "Failed to execute remote action";
2432
+ if (error instanceof import_shared11.CopilotKitError) {
2433
+ throw error;
2434
+ }
2435
+ throw new import_shared11.CopilotKitLowLevelError({
2436
+ error,
2437
+ url: fetchUrl
2438
+ });
2418
2439
  }
2419
2440
  }
2420
2441
  }));
@@ -2442,37 +2463,48 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
2442
2463
  state = JSON.parse(jsonState);
2443
2464
  }
2444
2465
  }
2445
- const response = await fetch(`${url}/agents/execute`, {
2446
- method: "POST",
2447
- headers,
2448
- body: JSON.stringify({
2449
- name,
2450
- threadId,
2451
- nodeName,
2452
- messages: [
2453
- ...messages,
2454
- ...additionalMessages
2455
- ],
2456
- state,
2457
- properties: graphqlContext.properties,
2458
- actions: actionInputsWithoutAgents.map((action) => ({
2459
- name: action.name,
2460
- description: action.description,
2461
- parameters: JSON.parse(action.jsonSchema)
2462
- }))
2463
- })
2464
- });
2465
- if (!response.ok) {
2466
- logger2.error({
2467
- url,
2468
- status: response.status,
2469
- body: await response.text()
2470
- }, "Failed to execute remote agent");
2471
- throw new Error("Failed to execute remote agent");
2466
+ const fetchUrl = `${url}/agents/execute`;
2467
+ try {
2468
+ const response = await fetch(fetchUrl, {
2469
+ method: "POST",
2470
+ headers,
2471
+ body: JSON.stringify({
2472
+ name,
2473
+ threadId,
2474
+ nodeName,
2475
+ messages: [
2476
+ ...messages,
2477
+ ...additionalMessages
2478
+ ],
2479
+ state,
2480
+ properties: graphqlContext.properties,
2481
+ actions: actionInputsWithoutAgents.map((action) => ({
2482
+ name: action.name,
2483
+ description: action.description,
2484
+ parameters: JSON.parse(action.jsonSchema)
2485
+ }))
2486
+ })
2487
+ });
2488
+ if (!response.ok) {
2489
+ logger2.error({
2490
+ url,
2491
+ status: response.status,
2492
+ body: await response.text()
2493
+ }, "Failed to execute remote agent");
2494
+ throw new Error("Failed to execute remote agent");
2495
+ }
2496
+ const eventSource = new RemoteLangGraphEventSource();
2497
+ streamResponse(response.body, eventSource.eventStream$);
2498
+ return eventSource.processLangGraphEvents();
2499
+ } catch (error) {
2500
+ if (error instanceof import_shared11.CopilotKitError) {
2501
+ throw error;
2502
+ }
2503
+ throw new import_shared11.CopilotKitLowLevelError({
2504
+ error,
2505
+ url: fetchUrl
2506
+ });
2472
2507
  }
2473
- const eventSource = new RemoteLangGraphEventSource();
2474
- streamResponse(response.body, eventSource.eventStream$);
2475
- return eventSource.processLangGraphEvents();
2476
2508
  }
2477
2509
  })) : [];
2478
2510
  return [
@@ -2542,6 +2574,7 @@ function createHeaders(onBeforeRequest, graphqlContext) {
2542
2574
  __name(createHeaders, "createHeaders");
2543
2575
 
2544
2576
  // src/lib/runtime/remote-actions.ts
2577
+ var import_shared12 = require("@copilotkit/shared");
2545
2578
  var EndpointType;
2546
2579
  (function(EndpointType2) {
2547
2580
  EndpointType2["CopilotKit"] = "copilotKit";
@@ -2559,8 +2592,9 @@ async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: l
2559
2592
  url
2560
2593
  }, "Fetching actions from url");
2561
2594
  const headers = createHeaders(onBeforeRequest, graphqlContext);
2595
+ const fetchUrl = `${url}/info`;
2562
2596
  try {
2563
- const response = await fetch(`${url}/info`, {
2597
+ const response = await fetch(fetchUrl, {
2564
2598
  method: "POST",
2565
2599
  headers,
2566
2600
  body: JSON.stringify({
@@ -2574,10 +2608,10 @@ async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: l
2574
2608
  status: response.status,
2575
2609
  body: await response.text()
2576
2610
  }, "Failed to fetch actions from url");
2577
- return {
2578
- actions: [],
2579
- agents: []
2580
- };
2611
+ throw new import_shared12.ResolvedCopilotKitError({
2612
+ status: response.status,
2613
+ isRemoteEndpoint: true
2614
+ });
2581
2615
  }
2582
2616
  const json = await response.json();
2583
2617
  logger2.debug({
@@ -2585,13 +2619,13 @@ async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: l
2585
2619
  }, "Fetched actions from url");
2586
2620
  return json;
2587
2621
  } catch (error) {
2588
- logger2.error({
2589
- error: error.message ? error.message : error + ""
2590
- }, "Failed to fetch actions from url");
2591
- return {
2592
- actions: [],
2593
- agents: []
2594
- };
2622
+ if (error instanceof import_shared12.CopilotKitError) {
2623
+ throw error;
2624
+ }
2625
+ throw new import_shared12.CopilotKitLowLevelError({
2626
+ error,
2627
+ url: fetchUrl
2628
+ });
2595
2629
  }
2596
2630
  }
2597
2631
  __name(fetchRemoteInfo, "fetchRemoteInfo");
@@ -2651,7 +2685,7 @@ __name(setupRemoteActions, "setupRemoteActions");
2651
2685
  // src/lib/telemetry-client.ts
2652
2686
  var import_node_crypto3 = require("crypto");
2653
2687
  var packageJson = require_package();
2654
- var telemetryClient = new import_shared10.TelemetryClient({
2688
+ var telemetryClient = new import_shared13.TelemetryClient({
2655
2689
  packageName: packageJson.name,
2656
2690
  packageVersion: packageJson.version
2657
2691
  });
@@ -2961,13 +2995,13 @@ var RuntimeEventSource = class {
2961
2995
  const errorMessage = `\u274C ${message}`;
2962
2996
  if (!this.callback) {
2963
2997
  this.stream(async (eventStream$) => {
2964
- eventStream$.sendTextMessage((0, import_shared11.randomId)(), errorMessage);
2998
+ eventStream$.sendTextMessage((0, import_shared14.randomId)(), errorMessage);
2965
2999
  });
2966
3000
  } else {
2967
- this.eventStream$.sendTextMessage((0, import_shared11.randomId)(), errorMessage);
3001
+ this.eventStream$.sendTextMessage((0, import_shared14.randomId)(), errorMessage);
2968
3002
  }
2969
3003
  }
2970
- processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents }) {
3004
+ processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents, threadId }) {
2971
3005
  this.callback(this.eventStream$).catch((error) => {
2972
3006
  console.error("Error in event source callback", error);
2973
3007
  this.sendErrorMessageToChat();
@@ -3003,7 +3037,7 @@ var RuntimeEventSource = class {
3003
3037
  (0, import_rxjs2.concatMap)((eventWithState) => {
3004
3038
  if (eventWithState.event.type === "ActionExecutionEnd" && eventWithState.callActionServerSide) {
3005
3039
  const toolCallEventStream$ = new RuntimeEventSubject();
3006
- executeAction(toolCallEventStream$, guardrailsResult$ ? guardrailsResult$ : null, eventWithState.action, eventWithState.args, eventWithState.actionExecutionParentMessageId, eventWithState.actionExecutionId, actionInputsWithoutAgents).catch((error) => {
3040
+ executeAction(toolCallEventStream$, guardrailsResult$ ? guardrailsResult$ : null, eventWithState.action, eventWithState.args, eventWithState.actionExecutionParentMessageId, eventWithState.actionExecutionId, actionInputsWithoutAgents, threadId).catch((error) => {
3007
3041
  console.error(error);
3008
3042
  });
3009
3043
  telemetry_client_default.capture("oss.runtime.server_action_executed", {});
@@ -3020,7 +3054,7 @@ var RuntimeEventSource = class {
3020
3054
  }
3021
3055
  };
3022
3056
  __name(RuntimeEventSource, "RuntimeEventSource");
3023
- async function executeAction(eventStream$, guardrailsResult$, action, actionArguments, actionExecutionParentMessageId, actionExecutionId, actionInputsWithoutAgents) {
3057
+ async function executeAction(eventStream$, guardrailsResult$, action, actionArguments, actionExecutionParentMessageId, actionExecutionId, actionInputsWithoutAgents, threadId) {
3024
3058
  var _a;
3025
3059
  if (guardrailsResult$) {
3026
3060
  const { status } = await (0, import_rxjs2.firstValueFrom)(guardrailsResult$);
@@ -3071,6 +3105,7 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
3071
3105
  });
3072
3106
  const stream = await action.langGraphAgentHandler({
3073
3107
  name: action.name,
3108
+ threadId,
3074
3109
  actionInputsWithoutAgents,
3075
3110
  additionalMessages: [
3076
3111
  agentExecution,
@@ -3170,6 +3205,7 @@ __name(convertGqlInputToMessages, "convertGqlInputToMessages");
3170
3205
 
3171
3206
  // src/lib/runtime/copilot-runtime.ts
3172
3207
  var import_rxjs3 = require("rxjs");
3208
+ var import_langgraph_sdk2 = require("@langchain/langgraph-sdk");
3173
3209
  var CopilotRuntime = class {
3174
3210
  actions;
3175
3211
  remoteEndpointDefinitions;
@@ -3189,16 +3225,18 @@ var CopilotRuntime = class {
3189
3225
  }
3190
3226
  async processRuntimeRequest(request) {
3191
3227
  var _a;
3192
- const { serviceAdapter, messages: rawMessages, actions: clientSideActionsInput, threadId, runId, outputMessagesPromise, graphqlContext, forwardedParameters, agentSession, url } = request;
3228
+ const { serviceAdapter, messages: rawMessages, actions: clientSideActionsInput, threadId, runId, outputMessagesPromise, graphqlContext, forwardedParameters, agentSession, url, extensions } = request;
3193
3229
  const eventSource = new RuntimeEventSource();
3194
3230
  try {
3195
3231
  if (agentSession) {
3196
3232
  return await this.processAgentRequest(request);
3197
3233
  }
3198
3234
  if (serviceAdapter instanceof EmptyAdapter) {
3199
- throw new Error(`Invalid adapter configuration: EmptyAdapter is only meant to be used with agent lock mode.
3235
+ throw new import_shared15.CopilotKitMisuseError({
3236
+ message: `Invalid adapter configuration: EmptyAdapter is only meant to be used with agent lock mode.
3200
3237
  For non-agent components like useCopilotChatSuggestions, CopilotTextarea, or CopilotTask,
3201
- please use an LLM adapter instead.`);
3238
+ please use an LLM adapter instead.`
3239
+ });
3202
3240
  }
3203
3241
  const messages = rawMessages.filter((message) => !message.agentStateMessage);
3204
3242
  const inputMessages = convertGqlInputToMessages(messages);
@@ -3206,7 +3244,7 @@ please use an LLM adapter instead.`);
3206
3244
  const serverSideActionsInput = serverSideActions.map((action) => ({
3207
3245
  name: action.name,
3208
3246
  description: action.description,
3209
- jsonSchema: JSON.stringify((0, import_shared12.actionParametersToJsonSchema)(action.parameters))
3247
+ jsonSchema: JSON.stringify((0, import_shared15.actionParametersToJsonSchema)(action.parameters))
3210
3248
  }));
3211
3249
  const actionInputs = flattenToolCallsNoDuplicates([
3212
3250
  ...serverSideActionsInput,
@@ -3228,12 +3266,14 @@ please use an LLM adapter instead.`);
3228
3266
  threadId,
3229
3267
  runId,
3230
3268
  eventSource,
3231
- forwardedParameters
3269
+ forwardedParameters,
3270
+ extensions
3232
3271
  });
3272
+ const nonEmptyThreadId = threadId ?? result.threadId;
3233
3273
  outputMessagesPromise.then((outputMessages) => {
3234
3274
  var _a2;
3235
3275
  (_a2 = this.onAfterRequest) == null ? void 0 : _a2.call(this, {
3236
- threadId: result.threadId,
3276
+ threadId: nonEmptyThreadId,
3237
3277
  runId: result.runId,
3238
3278
  inputMessages,
3239
3279
  outputMessages,
@@ -3243,16 +3283,20 @@ please use an LLM adapter instead.`);
3243
3283
  }).catch((_error) => {
3244
3284
  });
3245
3285
  return {
3246
- threadId: result.threadId,
3286
+ threadId: nonEmptyThreadId,
3247
3287
  runId: result.runId,
3248
3288
  eventSource,
3249
3289
  serverSideActions,
3250
3290
  actionInputsWithoutAgents: actionInputs.filter((action) => (
3251
3291
  // TODO-AGENTS: do not exclude ALL server side actions
3252
3292
  !serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)
3253
- ))
3293
+ )),
3294
+ extensions: result.extensions
3254
3295
  };
3255
3296
  } catch (error) {
3297
+ if (error instanceof import_shared15.CopilotKitError) {
3298
+ throw error;
3299
+ }
3256
3300
  console.error("Error getting response:", error);
3257
3301
  eventSource.sendErrorMessageToChat();
3258
3302
  throw error;
@@ -3263,54 +3307,131 @@ please use an LLM adapter instead.`);
3263
3307
  const agents = this.remoteEndpointDefinitions.reduce(async (acc, endpoint) => {
3264
3308
  const agents2 = await acc;
3265
3309
  if (endpoint.type === EndpointType.LangGraphPlatform) {
3266
- const response2 = await fetch(`${endpoint.deploymentUrl}/assistants/search`, {
3267
- method: "POST",
3268
- headers
3310
+ const client = new import_langgraph_sdk2.Client({
3311
+ apiUrl: endpoint.deploymentUrl,
3312
+ apiKey: endpoint.langsmithApiKey
3269
3313
  });
3270
- const data2 = await response2.json();
3271
- const endpointAgents2 = (data2 ?? []).map((entry) => ({
3314
+ const data = await client.assistants.search();
3315
+ const endpointAgents = (data ?? []).map((entry) => ({
3272
3316
  name: entry.graph_id,
3273
- id: entry.assistant_id
3317
+ id: entry.assistant_id,
3318
+ description: "",
3319
+ endpoint
3320
+ }));
3321
+ return [
3322
+ ...agents2,
3323
+ ...endpointAgents
3324
+ ];
3325
+ }
3326
+ const fetchUrl = `${endpoint.url}/info`;
3327
+ try {
3328
+ const response = await fetch(fetchUrl, {
3329
+ method: "POST",
3330
+ headers,
3331
+ body: JSON.stringify({
3332
+ properties: graphqlContext.properties
3333
+ })
3334
+ });
3335
+ if (!response.ok) {
3336
+ if (response.status === 404) {
3337
+ throw new import_shared15.CopilotKitApiDiscoveryError();
3338
+ }
3339
+ throw new import_shared15.ResolvedCopilotKitError({
3340
+ status: response.status,
3341
+ isRemoteEndpoint: true
3342
+ });
3343
+ }
3344
+ const data = await response.json();
3345
+ const endpointAgents = ((data == null ? void 0 : data.agents) ?? []).map((agent) => ({
3346
+ name: agent.name,
3347
+ description: agent.description ?? "" ?? "",
3348
+ id: (0, import_shared15.randomId)(),
3349
+ endpoint
3274
3350
  }));
3275
3351
  return [
3276
3352
  ...agents2,
3277
- ...endpointAgents2
3353
+ ...endpointAgents
3278
3354
  ];
3355
+ } catch (error) {
3356
+ if (error instanceof import_shared15.CopilotKitError) {
3357
+ throw error;
3358
+ }
3359
+ throw new import_shared15.CopilotKitLowLevelError({
3360
+ error,
3361
+ url: fetchUrl
3362
+ });
3363
+ }
3364
+ }, Promise.resolve([]));
3365
+ return agents;
3366
+ }
3367
+ async loadAgentState(graphqlContext, threadId, agentName) {
3368
+ const agentsWithEndpoints = await this.discoverAgentsFromEndpoints(graphqlContext);
3369
+ const agentWithEndpoint = agentsWithEndpoints.find((agent) => agent.name === agentName);
3370
+ if (!agentWithEndpoint) {
3371
+ throw new Error("Agent not found");
3372
+ }
3373
+ const headers = createHeaders(null, graphqlContext);
3374
+ if (agentWithEndpoint.endpoint.type === EndpointType.LangGraphPlatform) {
3375
+ const client = new import_langgraph_sdk2.Client({
3376
+ apiUrl: agentWithEndpoint.endpoint.deploymentUrl,
3377
+ apiKey: agentWithEndpoint.endpoint.langsmithApiKey
3378
+ });
3379
+ const state = (await client.threads.getState(threadId)).values;
3380
+ if (Object.keys(state).length === 0) {
3381
+ return {
3382
+ threadId,
3383
+ threadExists: false,
3384
+ state: JSON.stringify({}),
3385
+ messages: JSON.stringify([])
3386
+ };
3387
+ } else {
3388
+ console.log(state);
3389
+ const { messages, ...stateWithoutMessages } = state;
3390
+ const copilotkitMessages = langchainMessagesToCopilotKit(messages);
3391
+ return {
3392
+ threadId,
3393
+ threadExists: true,
3394
+ state: JSON.stringify(stateWithoutMessages),
3395
+ messages: JSON.stringify(copilotkitMessages)
3396
+ };
3279
3397
  }
3280
- const response = await fetch(`${endpoint.url}/info`, {
3398
+ } else if (agentWithEndpoint.endpoint.type === EndpointType.CopilotKit || !("type" in agentWithEndpoint.endpoint)) {
3399
+ const response = await fetch(`${agentWithEndpoint.endpoint.url}/agents/state`, {
3281
3400
  method: "POST",
3282
3401
  headers,
3283
3402
  body: JSON.stringify({
3284
- properties: graphqlContext.properties
3403
+ properties: graphqlContext.properties,
3404
+ threadId,
3405
+ name: agentName
3285
3406
  })
3286
3407
  });
3287
3408
  const data = await response.json();
3288
- const endpointAgents = ((data == null ? void 0 : data.agents) ?? []).map((agent) => ({
3289
- name: agent.name,
3290
- description: agent.description,
3291
- id: (0, import_shared12.randomId)()
3292
- }));
3293
- return [
3294
- ...agents2,
3295
- ...endpointAgents
3296
- ];
3297
- }, Promise.resolve([]));
3298
- return agents;
3409
+ return {
3410
+ ...data,
3411
+ state: JSON.stringify(data.state),
3412
+ messages: JSON.stringify(data.messages)
3413
+ };
3414
+ } else {
3415
+ throw new Error(`Unknown endpoint type: ${agentWithEndpoint.endpoint.type}`);
3416
+ }
3299
3417
  }
3300
3418
  async processAgentRequest(request) {
3301
3419
  var _a;
3302
- const { messages: rawMessages, outputMessagesPromise, graphqlContext, agentSession } = request;
3303
- const { threadId, agentName, nodeName } = agentSession;
3420
+ const { messages: rawMessages, outputMessagesPromise, graphqlContext, agentSession, threadId: threadIdFromRequest } = request;
3421
+ const { agentName, nodeName } = agentSession;
3422
+ const threadId = threadIdFromRequest ?? agentSession.threadId;
3304
3423
  const serverSideActions = await this.getServerSideActions(request);
3305
3424
  const messages = convertGqlInputToMessages(rawMessages);
3306
3425
  const agent = serverSideActions.find((action) => action.name === agentName && isLangGraphAgentAction(action));
3307
3426
  if (!agent) {
3308
- throw new Error(`Agent ${agentName} not found`);
3427
+ throw new import_shared15.CopilotKitAgentDiscoveryError({
3428
+ agentName
3429
+ });
3309
3430
  }
3310
3431
  const serverSideActionsInput = serverSideActions.filter((action) => !isLangGraphAgentAction(action)).map((action) => ({
3311
3432
  name: action.name,
3312
3433
  description: action.description,
3313
- jsonSchema: JSON.stringify((0, import_shared12.actionParametersToJsonSchema)(action.parameters))
3434
+ jsonSchema: JSON.stringify((0, import_shared15.actionParametersToJsonSchema)(action.parameters))
3314
3435
  }));
3315
3436
  const actionInputsWithoutAgents = flattenToolCallsNoDuplicates([
3316
3437
  ...serverSideActionsInput,
@@ -3438,14 +3559,14 @@ function resolveEndpointType(endpoint) {
3438
3559
  __name(resolveEndpointType, "resolveEndpointType");
3439
3560
 
3440
3561
  // src/lib/integrations/shared.ts
3441
- var import_type_graphql17 = require("type-graphql");
3562
+ var import_type_graphql24 = require("type-graphql");
3442
3563
 
3443
3564
  // src/graphql/resolvers/copilot.resolver.ts
3444
- var import_type_graphql16 = require("type-graphql");
3565
+ var import_type_graphql18 = require("type-graphql");
3445
3566
  var import_rxjs4 = require("rxjs");
3446
3567
 
3447
3568
  // src/graphql/inputs/generate-copilot-response.input.ts
3448
- var import_type_graphql11 = require("type-graphql");
3569
+ var import_type_graphql12 = require("type-graphql");
3449
3570
 
3450
3571
  // src/graphql/inputs/message.input.ts
3451
3572
  var import_type_graphql3 = require("type-graphql");
@@ -3961,7 +4082,8 @@ AgentStateInput = _ts_decorate9([
3961
4082
  (0, import_type_graphql10.InputType)()
3962
4083
  ], AgentStateInput);
3963
4084
 
3964
- // src/graphql/inputs/generate-copilot-response.input.ts
4085
+ // src/graphql/inputs/extensions.input.ts
4086
+ var import_type_graphql11 = require("type-graphql");
3965
4087
  function _ts_decorate10(decorators, target, key, desc) {
3966
4088
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3967
4089
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -3978,18 +4100,69 @@ function _ts_metadata10(k, v) {
3978
4100
  return Reflect.metadata(k, v);
3979
4101
  }
3980
4102
  __name(_ts_metadata10, "_ts_metadata");
4103
+ var ExtensionsInput = class {
4104
+ openaiAssistantAPI;
4105
+ };
4106
+ __name(ExtensionsInput, "ExtensionsInput");
4107
+ _ts_decorate10([
4108
+ (0, import_type_graphql11.Field)(() => OpenAIApiAssistantAPIInput, {
4109
+ nullable: true
4110
+ }),
4111
+ _ts_metadata10("design:type", typeof OpenAIApiAssistantAPIInput === "undefined" ? Object : OpenAIApiAssistantAPIInput)
4112
+ ], ExtensionsInput.prototype, "openaiAssistantAPI", void 0);
4113
+ ExtensionsInput = _ts_decorate10([
4114
+ (0, import_type_graphql11.InputType)()
4115
+ ], ExtensionsInput);
4116
+ var OpenAIApiAssistantAPIInput = class {
4117
+ runId;
4118
+ threadId;
4119
+ };
4120
+ __name(OpenAIApiAssistantAPIInput, "OpenAIApiAssistantAPIInput");
4121
+ _ts_decorate10([
4122
+ (0, import_type_graphql11.Field)(() => String, {
4123
+ nullable: true
4124
+ }),
4125
+ _ts_metadata10("design:type", String)
4126
+ ], OpenAIApiAssistantAPIInput.prototype, "runId", void 0);
4127
+ _ts_decorate10([
4128
+ (0, import_type_graphql11.Field)(() => String, {
4129
+ nullable: true
4130
+ }),
4131
+ _ts_metadata10("design:type", String)
4132
+ ], OpenAIApiAssistantAPIInput.prototype, "threadId", void 0);
4133
+ OpenAIApiAssistantAPIInput = _ts_decorate10([
4134
+ (0, import_type_graphql11.InputType)()
4135
+ ], OpenAIApiAssistantAPIInput);
4136
+
4137
+ // src/graphql/inputs/generate-copilot-response.input.ts
4138
+ function _ts_decorate11(decorators, target, key, desc) {
4139
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4140
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4141
+ r = Reflect.decorate(decorators, target, key, desc);
4142
+ else
4143
+ for (var i = decorators.length - 1; i >= 0; i--)
4144
+ if (d = decorators[i])
4145
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4146
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
4147
+ }
4148
+ __name(_ts_decorate11, "_ts_decorate");
4149
+ function _ts_metadata11(k, v) {
4150
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
4151
+ return Reflect.metadata(k, v);
4152
+ }
4153
+ __name(_ts_metadata11, "_ts_metadata");
3981
4154
  var GenerateCopilotResponseMetadataInput = class {
3982
4155
  requestType;
3983
4156
  };
3984
4157
  __name(GenerateCopilotResponseMetadataInput, "GenerateCopilotResponseMetadataInput");
3985
- _ts_decorate10([
3986
- (0, import_type_graphql11.Field)(() => CopilotRequestType, {
4158
+ _ts_decorate11([
4159
+ (0, import_type_graphql12.Field)(() => CopilotRequestType, {
3987
4160
  nullable: true
3988
4161
  }),
3989
- _ts_metadata10("design:type", typeof CopilotRequestType === "undefined" ? Object : CopilotRequestType)
4162
+ _ts_metadata11("design:type", typeof CopilotRequestType === "undefined" ? Object : CopilotRequestType)
3990
4163
  ], GenerateCopilotResponseMetadataInput.prototype, "requestType", void 0);
3991
- GenerateCopilotResponseMetadataInput = _ts_decorate10([
3992
- (0, import_type_graphql11.InputType)()
4164
+ GenerateCopilotResponseMetadataInput = _ts_decorate11([
4165
+ (0, import_type_graphql12.InputType)()
3993
4166
  ], GenerateCopilotResponseMetadataInput);
3994
4167
  var GenerateCopilotResponseInput = class {
3995
4168
  metadata;
@@ -4002,78 +4175,85 @@ var GenerateCopilotResponseInput = class {
4002
4175
  agentSession;
4003
4176
  agentState;
4004
4177
  agentStates;
4178
+ extensions;
4005
4179
  };
4006
4180
  __name(GenerateCopilotResponseInput, "GenerateCopilotResponseInput");
4007
- _ts_decorate10([
4008
- (0, import_type_graphql11.Field)(() => GenerateCopilotResponseMetadataInput, {
4181
+ _ts_decorate11([
4182
+ (0, import_type_graphql12.Field)(() => GenerateCopilotResponseMetadataInput, {
4009
4183
  nullable: false
4010
4184
  }),
4011
- _ts_metadata10("design:type", typeof GenerateCopilotResponseMetadataInput === "undefined" ? Object : GenerateCopilotResponseMetadataInput)
4185
+ _ts_metadata11("design:type", typeof GenerateCopilotResponseMetadataInput === "undefined" ? Object : GenerateCopilotResponseMetadataInput)
4012
4186
  ], GenerateCopilotResponseInput.prototype, "metadata", void 0);
4013
- _ts_decorate10([
4014
- (0, import_type_graphql11.Field)(() => String, {
4187
+ _ts_decorate11([
4188
+ (0, import_type_graphql12.Field)(() => String, {
4015
4189
  nullable: true
4016
4190
  }),
4017
- _ts_metadata10("design:type", String)
4191
+ _ts_metadata11("design:type", String)
4018
4192
  ], GenerateCopilotResponseInput.prototype, "threadId", void 0);
4019
- _ts_decorate10([
4020
- (0, import_type_graphql11.Field)(() => String, {
4193
+ _ts_decorate11([
4194
+ (0, import_type_graphql12.Field)(() => String, {
4021
4195
  nullable: true
4022
4196
  }),
4023
- _ts_metadata10("design:type", String)
4197
+ _ts_metadata11("design:type", String)
4024
4198
  ], GenerateCopilotResponseInput.prototype, "runId", void 0);
4025
- _ts_decorate10([
4026
- (0, import_type_graphql11.Field)(() => [
4199
+ _ts_decorate11([
4200
+ (0, import_type_graphql12.Field)(() => [
4027
4201
  MessageInput
4028
4202
  ]),
4029
- _ts_metadata10("design:type", Array)
4203
+ _ts_metadata11("design:type", Array)
4030
4204
  ], GenerateCopilotResponseInput.prototype, "messages", void 0);
4031
- _ts_decorate10([
4032
- (0, import_type_graphql11.Field)(() => FrontendInput),
4033
- _ts_metadata10("design:type", typeof FrontendInput === "undefined" ? Object : FrontendInput)
4205
+ _ts_decorate11([
4206
+ (0, import_type_graphql12.Field)(() => FrontendInput),
4207
+ _ts_metadata11("design:type", typeof FrontendInput === "undefined" ? Object : FrontendInput)
4034
4208
  ], GenerateCopilotResponseInput.prototype, "frontend", void 0);
4035
- _ts_decorate10([
4036
- (0, import_type_graphql11.Field)(() => CloudInput, {
4209
+ _ts_decorate11([
4210
+ (0, import_type_graphql12.Field)(() => CloudInput, {
4037
4211
  nullable: true
4038
4212
  }),
4039
- _ts_metadata10("design:type", typeof CloudInput === "undefined" ? Object : CloudInput)
4213
+ _ts_metadata11("design:type", typeof CloudInput === "undefined" ? Object : CloudInput)
4040
4214
  ], GenerateCopilotResponseInput.prototype, "cloud", void 0);
4041
- _ts_decorate10([
4042
- (0, import_type_graphql11.Field)(() => ForwardedParametersInput, {
4215
+ _ts_decorate11([
4216
+ (0, import_type_graphql12.Field)(() => ForwardedParametersInput, {
4043
4217
  nullable: true
4044
4218
  }),
4045
- _ts_metadata10("design:type", typeof ForwardedParametersInput === "undefined" ? Object : ForwardedParametersInput)
4219
+ _ts_metadata11("design:type", typeof ForwardedParametersInput === "undefined" ? Object : ForwardedParametersInput)
4046
4220
  ], GenerateCopilotResponseInput.prototype, "forwardedParameters", void 0);
4047
- _ts_decorate10([
4048
- (0, import_type_graphql11.Field)(() => AgentSessionInput, {
4221
+ _ts_decorate11([
4222
+ (0, import_type_graphql12.Field)(() => AgentSessionInput, {
4049
4223
  nullable: true
4050
4224
  }),
4051
- _ts_metadata10("design:type", typeof AgentSessionInput === "undefined" ? Object : AgentSessionInput)
4225
+ _ts_metadata11("design:type", typeof AgentSessionInput === "undefined" ? Object : AgentSessionInput)
4052
4226
  ], GenerateCopilotResponseInput.prototype, "agentSession", void 0);
4053
- _ts_decorate10([
4054
- (0, import_type_graphql11.Field)(() => AgentStateInput, {
4227
+ _ts_decorate11([
4228
+ (0, import_type_graphql12.Field)(() => AgentStateInput, {
4055
4229
  nullable: true
4056
4230
  }),
4057
- _ts_metadata10("design:type", typeof AgentStateInput === "undefined" ? Object : AgentStateInput)
4231
+ _ts_metadata11("design:type", typeof AgentStateInput === "undefined" ? Object : AgentStateInput)
4058
4232
  ], GenerateCopilotResponseInput.prototype, "agentState", void 0);
4059
- _ts_decorate10([
4060
- (0, import_type_graphql11.Field)(() => [
4233
+ _ts_decorate11([
4234
+ (0, import_type_graphql12.Field)(() => [
4061
4235
  AgentStateInput
4062
4236
  ], {
4063
4237
  nullable: true
4064
4238
  }),
4065
- _ts_metadata10("design:type", Array)
4239
+ _ts_metadata11("design:type", Array)
4066
4240
  ], GenerateCopilotResponseInput.prototype, "agentStates", void 0);
4067
- GenerateCopilotResponseInput = _ts_decorate10([
4068
- (0, import_type_graphql11.InputType)()
4241
+ _ts_decorate11([
4242
+ (0, import_type_graphql12.Field)(() => ExtensionsInput, {
4243
+ nullable: true
4244
+ }),
4245
+ _ts_metadata11("design:type", typeof ExtensionsInput === "undefined" ? Object : ExtensionsInput)
4246
+ ], GenerateCopilotResponseInput.prototype, "extensions", void 0);
4247
+ GenerateCopilotResponseInput = _ts_decorate11([
4248
+ (0, import_type_graphql12.InputType)()
4069
4249
  ], GenerateCopilotResponseInput);
4070
4250
 
4071
4251
  // src/graphql/types/copilot-response.type.ts
4072
- var import_type_graphql14 = require("type-graphql");
4252
+ var import_type_graphql16 = require("type-graphql");
4073
4253
 
4074
4254
  // src/graphql/types/message-status.type.ts
4075
- var import_type_graphql12 = require("type-graphql");
4076
- function _ts_decorate11(decorators, target, key, desc) {
4255
+ var import_type_graphql13 = require("type-graphql");
4256
+ function _ts_decorate12(decorators, target, key, desc) {
4077
4257
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4078
4258
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4079
4259
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4083,58 +4263,58 @@ function _ts_decorate11(decorators, target, key, desc) {
4083
4263
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4084
4264
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4085
4265
  }
4086
- __name(_ts_decorate11, "_ts_decorate");
4087
- function _ts_metadata11(k, v) {
4266
+ __name(_ts_decorate12, "_ts_decorate");
4267
+ function _ts_metadata12(k, v) {
4088
4268
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
4089
4269
  return Reflect.metadata(k, v);
4090
4270
  }
4091
- __name(_ts_metadata11, "_ts_metadata");
4271
+ __name(_ts_metadata12, "_ts_metadata");
4092
4272
  var MessageStatusCode;
4093
4273
  (function(MessageStatusCode2) {
4094
4274
  MessageStatusCode2["Pending"] = "pending";
4095
4275
  MessageStatusCode2["Success"] = "success";
4096
4276
  MessageStatusCode2["Failed"] = "failed";
4097
4277
  })(MessageStatusCode || (MessageStatusCode = {}));
4098
- (0, import_type_graphql12.registerEnumType)(MessageStatusCode, {
4278
+ (0, import_type_graphql13.registerEnumType)(MessageStatusCode, {
4099
4279
  name: "MessageStatusCode"
4100
4280
  });
4101
4281
  var BaseMessageStatus = /* @__PURE__ */ __name(class BaseMessageStatus2 {
4102
4282
  code;
4103
4283
  }, "BaseMessageStatus");
4104
- _ts_decorate11([
4105
- (0, import_type_graphql12.Field)(() => MessageStatusCode),
4106
- _ts_metadata11("design:type", String)
4284
+ _ts_decorate12([
4285
+ (0, import_type_graphql13.Field)(() => MessageStatusCode),
4286
+ _ts_metadata12("design:type", String)
4107
4287
  ], BaseMessageStatus.prototype, "code", void 0);
4108
- BaseMessageStatus = _ts_decorate11([
4109
- (0, import_type_graphql12.ObjectType)()
4288
+ BaseMessageStatus = _ts_decorate12([
4289
+ (0, import_type_graphql13.ObjectType)()
4110
4290
  ], BaseMessageStatus);
4111
4291
  var PendingMessageStatus = class extends BaseMessageStatus {
4112
4292
  code = "pending";
4113
4293
  };
4114
4294
  __name(PendingMessageStatus, "PendingMessageStatus");
4115
- PendingMessageStatus = _ts_decorate11([
4116
- (0, import_type_graphql12.ObjectType)()
4295
+ PendingMessageStatus = _ts_decorate12([
4296
+ (0, import_type_graphql13.ObjectType)()
4117
4297
  ], PendingMessageStatus);
4118
4298
  var SuccessMessageStatus = class extends BaseMessageStatus {
4119
4299
  code = "success";
4120
4300
  };
4121
4301
  __name(SuccessMessageStatus, "SuccessMessageStatus");
4122
- SuccessMessageStatus = _ts_decorate11([
4123
- (0, import_type_graphql12.ObjectType)()
4302
+ SuccessMessageStatus = _ts_decorate12([
4303
+ (0, import_type_graphql13.ObjectType)()
4124
4304
  ], SuccessMessageStatus);
4125
4305
  var FailedMessageStatus = class extends BaseMessageStatus {
4126
4306
  code = "failed";
4127
4307
  reason;
4128
4308
  };
4129
4309
  __name(FailedMessageStatus, "FailedMessageStatus");
4130
- _ts_decorate11([
4131
- (0, import_type_graphql12.Field)(() => String),
4132
- _ts_metadata11("design:type", String)
4310
+ _ts_decorate12([
4311
+ (0, import_type_graphql13.Field)(() => String),
4312
+ _ts_metadata12("design:type", String)
4133
4313
  ], FailedMessageStatus.prototype, "reason", void 0);
4134
- FailedMessageStatus = _ts_decorate11([
4135
- (0, import_type_graphql12.ObjectType)()
4314
+ FailedMessageStatus = _ts_decorate12([
4315
+ (0, import_type_graphql13.ObjectType)()
4136
4316
  ], FailedMessageStatus);
4137
- var MessageStatusUnion = (0, import_type_graphql12.createUnionType)({
4317
+ var MessageStatusUnion = (0, import_type_graphql13.createUnionType)({
4138
4318
  name: "MessageStatus",
4139
4319
  types: () => [
4140
4320
  PendingMessageStatus,
@@ -4145,8 +4325,8 @@ var MessageStatusUnion = (0, import_type_graphql12.createUnionType)({
4145
4325
 
4146
4326
  // src/graphql/types/response-status.type.ts
4147
4327
  var import_graphql_scalars = require("graphql-scalars");
4148
- var import_type_graphql13 = require("type-graphql");
4149
- function _ts_decorate12(decorators, target, key, desc) {
4328
+ var import_type_graphql14 = require("type-graphql");
4329
+ function _ts_decorate13(decorators, target, key, desc) {
4150
4330
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4151
4331
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4152
4332
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4156,30 +4336,30 @@ function _ts_decorate12(decorators, target, key, desc) {
4156
4336
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4157
4337
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4158
4338
  }
4159
- __name(_ts_decorate12, "_ts_decorate");
4160
- function _ts_metadata12(k, v) {
4339
+ __name(_ts_decorate13, "_ts_decorate");
4340
+ function _ts_metadata13(k, v) {
4161
4341
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
4162
4342
  return Reflect.metadata(k, v);
4163
4343
  }
4164
- __name(_ts_metadata12, "_ts_metadata");
4344
+ __name(_ts_metadata13, "_ts_metadata");
4165
4345
  var ResponseStatusCode;
4166
4346
  (function(ResponseStatusCode2) {
4167
4347
  ResponseStatusCode2["Pending"] = "pending";
4168
4348
  ResponseStatusCode2["Success"] = "success";
4169
4349
  ResponseStatusCode2["Failed"] = "failed";
4170
4350
  })(ResponseStatusCode || (ResponseStatusCode = {}));
4171
- (0, import_type_graphql13.registerEnumType)(ResponseStatusCode, {
4351
+ (0, import_type_graphql14.registerEnumType)(ResponseStatusCode, {
4172
4352
  name: "ResponseStatusCode"
4173
4353
  });
4174
4354
  var BaseResponseStatus = /* @__PURE__ */ __name(class BaseResponseStatus2 {
4175
4355
  code;
4176
4356
  }, "BaseResponseStatus");
4177
- _ts_decorate12([
4178
- (0, import_type_graphql13.Field)(() => ResponseStatusCode),
4179
- _ts_metadata12("design:type", String)
4357
+ _ts_decorate13([
4358
+ (0, import_type_graphql14.Field)(() => ResponseStatusCode),
4359
+ _ts_metadata13("design:type", String)
4180
4360
  ], BaseResponseStatus.prototype, "code", void 0);
4181
- BaseResponseStatus = _ts_decorate12([
4182
- (0, import_type_graphql13.InterfaceType)({
4361
+ BaseResponseStatus = _ts_decorate13([
4362
+ (0, import_type_graphql14.InterfaceType)({
4183
4363
  resolveType(value) {
4184
4364
  if (value.code === "success") {
4185
4365
  return SuccessResponseStatus;
@@ -4191,14 +4371,14 @@ BaseResponseStatus = _ts_decorate12([
4191
4371
  return void 0;
4192
4372
  }
4193
4373
  }),
4194
- (0, import_type_graphql13.ObjectType)()
4374
+ (0, import_type_graphql14.ObjectType)()
4195
4375
  ], BaseResponseStatus);
4196
4376
  var PendingResponseStatus = class extends BaseResponseStatus {
4197
4377
  code = "pending";
4198
4378
  };
4199
4379
  __name(PendingResponseStatus, "PendingResponseStatus");
4200
- PendingResponseStatus = _ts_decorate12([
4201
- (0, import_type_graphql13.ObjectType)({
4380
+ PendingResponseStatus = _ts_decorate13([
4381
+ (0, import_type_graphql14.ObjectType)({
4202
4382
  implements: BaseResponseStatus
4203
4383
  })
4204
4384
  ], PendingResponseStatus);
@@ -4206,8 +4386,8 @@ var SuccessResponseStatus = class extends BaseResponseStatus {
4206
4386
  code = "success";
4207
4387
  };
4208
4388
  __name(SuccessResponseStatus, "SuccessResponseStatus");
4209
- SuccessResponseStatus = _ts_decorate12([
4210
- (0, import_type_graphql13.ObjectType)({
4389
+ SuccessResponseStatus = _ts_decorate13([
4390
+ (0, import_type_graphql14.ObjectType)({
4211
4391
  implements: BaseResponseStatus
4212
4392
  })
4213
4393
  ], SuccessResponseStatus);
@@ -4217,7 +4397,7 @@ var FailedResponseStatusReason;
4217
4397
  FailedResponseStatusReason2["MESSAGE_STREAM_INTERRUPTED"] = "MESSAGE_STREAM_INTERRUPTED";
4218
4398
  FailedResponseStatusReason2["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
4219
4399
  })(FailedResponseStatusReason || (FailedResponseStatusReason = {}));
4220
- (0, import_type_graphql13.registerEnumType)(FailedResponseStatusReason, {
4400
+ (0, import_type_graphql14.registerEnumType)(FailedResponseStatusReason, {
4221
4401
  name: "FailedResponseStatusReason"
4222
4402
  });
4223
4403
  var FailedResponseStatus = class extends BaseResponseStatus {
@@ -4226,22 +4406,22 @@ var FailedResponseStatus = class extends BaseResponseStatus {
4226
4406
  details = null;
4227
4407
  };
4228
4408
  __name(FailedResponseStatus, "FailedResponseStatus");
4229
- _ts_decorate12([
4230
- (0, import_type_graphql13.Field)(() => FailedResponseStatusReason),
4231
- _ts_metadata12("design:type", String)
4409
+ _ts_decorate13([
4410
+ (0, import_type_graphql14.Field)(() => FailedResponseStatusReason),
4411
+ _ts_metadata13("design:type", String)
4232
4412
  ], FailedResponseStatus.prototype, "reason", void 0);
4233
- _ts_decorate12([
4234
- (0, import_type_graphql13.Field)(() => import_graphql_scalars.GraphQLJSON, {
4413
+ _ts_decorate13([
4414
+ (0, import_type_graphql14.Field)(() => import_graphql_scalars.GraphQLJSON, {
4235
4415
  nullable: true
4236
4416
  }),
4237
- _ts_metadata12("design:type", typeof Record === "undefined" ? Object : Record)
4417
+ _ts_metadata13("design:type", typeof Record === "undefined" ? Object : Record)
4238
4418
  ], FailedResponseStatus.prototype, "details", void 0);
4239
- FailedResponseStatus = _ts_decorate12([
4240
- (0, import_type_graphql13.ObjectType)({
4419
+ FailedResponseStatus = _ts_decorate13([
4420
+ (0, import_type_graphql14.ObjectType)({
4241
4421
  implements: BaseResponseStatus
4242
4422
  })
4243
4423
  ], FailedResponseStatus);
4244
- var ResponseStatusUnion = (0, import_type_graphql13.createUnionType)({
4424
+ var ResponseStatusUnion = (0, import_type_graphql14.createUnionType)({
4245
4425
  name: "ResponseStatus",
4246
4426
  types: () => [
4247
4427
  PendingResponseStatus,
@@ -4250,8 +4430,60 @@ var ResponseStatusUnion = (0, import_type_graphql13.createUnionType)({
4250
4430
  ]
4251
4431
  });
4252
4432
 
4433
+ // src/graphql/types/extensions-response.type.ts
4434
+ var import_type_graphql15 = require("type-graphql");
4435
+ function _ts_decorate14(decorators, target, key, desc) {
4436
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4437
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4438
+ r = Reflect.decorate(decorators, target, key, desc);
4439
+ else
4440
+ for (var i = decorators.length - 1; i >= 0; i--)
4441
+ if (d = decorators[i])
4442
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4443
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
4444
+ }
4445
+ __name(_ts_decorate14, "_ts_decorate");
4446
+ function _ts_metadata14(k, v) {
4447
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
4448
+ return Reflect.metadata(k, v);
4449
+ }
4450
+ __name(_ts_metadata14, "_ts_metadata");
4451
+ var ExtensionsResponse = class {
4452
+ openaiAssistantAPI;
4453
+ };
4454
+ __name(ExtensionsResponse, "ExtensionsResponse");
4455
+ _ts_decorate14([
4456
+ (0, import_type_graphql15.Field)(() => OpenAIApiAssistantAPIResponse, {
4457
+ nullable: true
4458
+ }),
4459
+ _ts_metadata14("design:type", typeof OpenAIApiAssistantAPIResponse === "undefined" ? Object : OpenAIApiAssistantAPIResponse)
4460
+ ], ExtensionsResponse.prototype, "openaiAssistantAPI", void 0);
4461
+ ExtensionsResponse = _ts_decorate14([
4462
+ (0, import_type_graphql15.ObjectType)()
4463
+ ], ExtensionsResponse);
4464
+ var OpenAIApiAssistantAPIResponse = class {
4465
+ runId;
4466
+ threadId;
4467
+ };
4468
+ __name(OpenAIApiAssistantAPIResponse, "OpenAIApiAssistantAPIResponse");
4469
+ _ts_decorate14([
4470
+ (0, import_type_graphql15.Field)(() => String, {
4471
+ nullable: true
4472
+ }),
4473
+ _ts_metadata14("design:type", String)
4474
+ ], OpenAIApiAssistantAPIResponse.prototype, "runId", void 0);
4475
+ _ts_decorate14([
4476
+ (0, import_type_graphql15.Field)(() => String, {
4477
+ nullable: true
4478
+ }),
4479
+ _ts_metadata14("design:type", String)
4480
+ ], OpenAIApiAssistantAPIResponse.prototype, "threadId", void 0);
4481
+ OpenAIApiAssistantAPIResponse = _ts_decorate14([
4482
+ (0, import_type_graphql15.ObjectType)()
4483
+ ], OpenAIApiAssistantAPIResponse);
4484
+
4253
4485
  // src/graphql/types/copilot-response.type.ts
4254
- function _ts_decorate13(decorators, target, key, desc) {
4486
+ function _ts_decorate15(decorators, target, key, desc) {
4255
4487
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4256
4488
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4257
4489
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4261,31 +4493,32 @@ function _ts_decorate13(decorators, target, key, desc) {
4261
4493
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4262
4494
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4263
4495
  }
4264
- __name(_ts_decorate13, "_ts_decorate");
4265
- function _ts_metadata13(k, v) {
4496
+ __name(_ts_decorate15, "_ts_decorate");
4497
+ function _ts_metadata15(k, v) {
4266
4498
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
4267
4499
  return Reflect.metadata(k, v);
4268
4500
  }
4269
- __name(_ts_metadata13, "_ts_metadata");
4270
- var BaseMessageOutput = /* @__PURE__ */ __name(class BaseMessageOutput2 {
4501
+ __name(_ts_metadata15, "_ts_metadata");
4502
+ var BaseMessageOutput = class {
4271
4503
  id;
4272
4504
  createdAt;
4273
4505
  status;
4274
- }, "BaseMessageOutput");
4275
- _ts_decorate13([
4276
- (0, import_type_graphql14.Field)(() => String),
4277
- _ts_metadata13("design:type", String)
4506
+ };
4507
+ __name(BaseMessageOutput, "BaseMessageOutput");
4508
+ _ts_decorate15([
4509
+ (0, import_type_graphql16.Field)(() => String),
4510
+ _ts_metadata15("design:type", String)
4278
4511
  ], BaseMessageOutput.prototype, "id", void 0);
4279
- _ts_decorate13([
4280
- (0, import_type_graphql14.Field)(() => Date),
4281
- _ts_metadata13("design:type", typeof Date === "undefined" ? Object : Date)
4512
+ _ts_decorate15([
4513
+ (0, import_type_graphql16.Field)(() => Date),
4514
+ _ts_metadata15("design:type", typeof Date === "undefined" ? Object : Date)
4282
4515
  ], BaseMessageOutput.prototype, "createdAt", void 0);
4283
- _ts_decorate13([
4284
- (0, import_type_graphql14.Field)(() => MessageStatusUnion),
4285
- _ts_metadata13("design:type", Object)
4516
+ _ts_decorate15([
4517
+ (0, import_type_graphql16.Field)(() => MessageStatusUnion),
4518
+ _ts_metadata15("design:type", Object)
4286
4519
  ], BaseMessageOutput.prototype, "status", void 0);
4287
- BaseMessageOutput = _ts_decorate13([
4288
- (0, import_type_graphql14.InterfaceType)({
4520
+ BaseMessageOutput = _ts_decorate15([
4521
+ (0, import_type_graphql16.InterfaceType)({
4289
4522
  resolveType(value) {
4290
4523
  if (value.hasOwnProperty("content")) {
4291
4524
  return TextMessageOutput;
@@ -4306,24 +4539,24 @@ var TextMessageOutput = class {
4306
4539
  parentMessageId;
4307
4540
  };
4308
4541
  __name(TextMessageOutput, "TextMessageOutput");
4309
- _ts_decorate13([
4310
- (0, import_type_graphql14.Field)(() => MessageRole),
4311
- _ts_metadata13("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
4542
+ _ts_decorate15([
4543
+ (0, import_type_graphql16.Field)(() => MessageRole),
4544
+ _ts_metadata15("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
4312
4545
  ], TextMessageOutput.prototype, "role", void 0);
4313
- _ts_decorate13([
4314
- (0, import_type_graphql14.Field)(() => [
4546
+ _ts_decorate15([
4547
+ (0, import_type_graphql16.Field)(() => [
4315
4548
  String
4316
4549
  ]),
4317
- _ts_metadata13("design:type", Array)
4550
+ _ts_metadata15("design:type", Array)
4318
4551
  ], TextMessageOutput.prototype, "content", void 0);
4319
- _ts_decorate13([
4320
- (0, import_type_graphql14.Field)(() => String, {
4552
+ _ts_decorate15([
4553
+ (0, import_type_graphql16.Field)(() => String, {
4321
4554
  nullable: true
4322
4555
  }),
4323
- _ts_metadata13("design:type", String)
4556
+ _ts_metadata15("design:type", String)
4324
4557
  ], TextMessageOutput.prototype, "parentMessageId", void 0);
4325
- TextMessageOutput = _ts_decorate13([
4326
- (0, import_type_graphql14.ObjectType)({
4558
+ TextMessageOutput = _ts_decorate15([
4559
+ (0, import_type_graphql16.ObjectType)({
4327
4560
  implements: BaseMessageOutput
4328
4561
  })
4329
4562
  ], TextMessageOutput);
@@ -4334,31 +4567,31 @@ var ActionExecutionMessageOutput = class {
4334
4567
  parentMessageId;
4335
4568
  };
4336
4569
  __name(ActionExecutionMessageOutput, "ActionExecutionMessageOutput");
4337
- _ts_decorate13([
4338
- (0, import_type_graphql14.Field)(() => String),
4339
- _ts_metadata13("design:type", String)
4570
+ _ts_decorate15([
4571
+ (0, import_type_graphql16.Field)(() => String),
4572
+ _ts_metadata15("design:type", String)
4340
4573
  ], ActionExecutionMessageOutput.prototype, "name", void 0);
4341
- _ts_decorate13([
4342
- (0, import_type_graphql14.Field)(() => String, {
4574
+ _ts_decorate15([
4575
+ (0, import_type_graphql16.Field)(() => String, {
4343
4576
  nullable: true,
4344
4577
  deprecationReason: "This field will be removed in a future version"
4345
4578
  }),
4346
- _ts_metadata13("design:type", String)
4579
+ _ts_metadata15("design:type", String)
4347
4580
  ], ActionExecutionMessageOutput.prototype, "scope", void 0);
4348
- _ts_decorate13([
4349
- (0, import_type_graphql14.Field)(() => [
4581
+ _ts_decorate15([
4582
+ (0, import_type_graphql16.Field)(() => [
4350
4583
  String
4351
4584
  ]),
4352
- _ts_metadata13("design:type", Array)
4585
+ _ts_metadata15("design:type", Array)
4353
4586
  ], ActionExecutionMessageOutput.prototype, "arguments", void 0);
4354
- _ts_decorate13([
4355
- (0, import_type_graphql14.Field)(() => String, {
4587
+ _ts_decorate15([
4588
+ (0, import_type_graphql16.Field)(() => String, {
4356
4589
  nullable: true
4357
4590
  }),
4358
- _ts_metadata13("design:type", String)
4591
+ _ts_metadata15("design:type", String)
4359
4592
  ], ActionExecutionMessageOutput.prototype, "parentMessageId", void 0);
4360
- ActionExecutionMessageOutput = _ts_decorate13([
4361
- (0, import_type_graphql14.ObjectType)({
4593
+ ActionExecutionMessageOutput = _ts_decorate15([
4594
+ (0, import_type_graphql16.ObjectType)({
4362
4595
  implements: BaseMessageOutput
4363
4596
  })
4364
4597
  ], ActionExecutionMessageOutput);
@@ -4368,20 +4601,20 @@ var ResultMessageOutput = class {
4368
4601
  result;
4369
4602
  };
4370
4603
  __name(ResultMessageOutput, "ResultMessageOutput");
4371
- _ts_decorate13([
4372
- (0, import_type_graphql14.Field)(() => String),
4373
- _ts_metadata13("design:type", String)
4604
+ _ts_decorate15([
4605
+ (0, import_type_graphql16.Field)(() => String),
4606
+ _ts_metadata15("design:type", String)
4374
4607
  ], ResultMessageOutput.prototype, "actionExecutionId", void 0);
4375
- _ts_decorate13([
4376
- (0, import_type_graphql14.Field)(() => String),
4377
- _ts_metadata13("design:type", String)
4608
+ _ts_decorate15([
4609
+ (0, import_type_graphql16.Field)(() => String),
4610
+ _ts_metadata15("design:type", String)
4378
4611
  ], ResultMessageOutput.prototype, "actionName", void 0);
4379
- _ts_decorate13([
4380
- (0, import_type_graphql14.Field)(() => String),
4381
- _ts_metadata13("design:type", String)
4612
+ _ts_decorate15([
4613
+ (0, import_type_graphql16.Field)(() => String),
4614
+ _ts_metadata15("design:type", String)
4382
4615
  ], ResultMessageOutput.prototype, "result", void 0);
4383
- ResultMessageOutput = _ts_decorate13([
4384
- (0, import_type_graphql14.ObjectType)({
4616
+ ResultMessageOutput = _ts_decorate15([
4617
+ (0, import_type_graphql16.ObjectType)({
4385
4618
  implements: BaseMessageOutput
4386
4619
  })
4387
4620
  ], ResultMessageOutput);
@@ -4396,40 +4629,40 @@ var AgentStateMessageOutput = class {
4396
4629
  running;
4397
4630
  };
4398
4631
  __name(AgentStateMessageOutput, "AgentStateMessageOutput");
4399
- _ts_decorate13([
4400
- (0, import_type_graphql14.Field)(() => String),
4401
- _ts_metadata13("design:type", String)
4632
+ _ts_decorate15([
4633
+ (0, import_type_graphql16.Field)(() => String),
4634
+ _ts_metadata15("design:type", String)
4402
4635
  ], AgentStateMessageOutput.prototype, "threadId", void 0);
4403
- _ts_decorate13([
4404
- (0, import_type_graphql14.Field)(() => String),
4405
- _ts_metadata13("design:type", String)
4636
+ _ts_decorate15([
4637
+ (0, import_type_graphql16.Field)(() => String),
4638
+ _ts_metadata15("design:type", String)
4406
4639
  ], AgentStateMessageOutput.prototype, "agentName", void 0);
4407
- _ts_decorate13([
4408
- (0, import_type_graphql14.Field)(() => String),
4409
- _ts_metadata13("design:type", String)
4640
+ _ts_decorate15([
4641
+ (0, import_type_graphql16.Field)(() => String),
4642
+ _ts_metadata15("design:type", String)
4410
4643
  ], AgentStateMessageOutput.prototype, "nodeName", void 0);
4411
- _ts_decorate13([
4412
- (0, import_type_graphql14.Field)(() => String),
4413
- _ts_metadata13("design:type", String)
4644
+ _ts_decorate15([
4645
+ (0, import_type_graphql16.Field)(() => String),
4646
+ _ts_metadata15("design:type", String)
4414
4647
  ], AgentStateMessageOutput.prototype, "runId", void 0);
4415
- _ts_decorate13([
4416
- (0, import_type_graphql14.Field)(() => Boolean),
4417
- _ts_metadata13("design:type", Boolean)
4648
+ _ts_decorate15([
4649
+ (0, import_type_graphql16.Field)(() => Boolean),
4650
+ _ts_metadata15("design:type", Boolean)
4418
4651
  ], AgentStateMessageOutput.prototype, "active", void 0);
4419
- _ts_decorate13([
4420
- (0, import_type_graphql14.Field)(() => MessageRole),
4421
- _ts_metadata13("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
4652
+ _ts_decorate15([
4653
+ (0, import_type_graphql16.Field)(() => MessageRole),
4654
+ _ts_metadata15("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
4422
4655
  ], AgentStateMessageOutput.prototype, "role", void 0);
4423
- _ts_decorate13([
4424
- (0, import_type_graphql14.Field)(() => String),
4425
- _ts_metadata13("design:type", String)
4656
+ _ts_decorate15([
4657
+ (0, import_type_graphql16.Field)(() => String),
4658
+ _ts_metadata15("design:type", String)
4426
4659
  ], AgentStateMessageOutput.prototype, "state", void 0);
4427
- _ts_decorate13([
4428
- (0, import_type_graphql14.Field)(() => Boolean),
4429
- _ts_metadata13("design:type", Boolean)
4660
+ _ts_decorate15([
4661
+ (0, import_type_graphql16.Field)(() => Boolean),
4662
+ _ts_metadata15("design:type", Boolean)
4430
4663
  ], AgentStateMessageOutput.prototype, "running", void 0);
4431
- AgentStateMessageOutput = _ts_decorate13([
4432
- (0, import_type_graphql14.ObjectType)({
4664
+ AgentStateMessageOutput = _ts_decorate15([
4665
+ (0, import_type_graphql16.ObjectType)({
4433
4666
  implements: BaseMessageOutput
4434
4667
  })
4435
4668
  ], AgentStateMessageOutput);
@@ -4438,30 +4671,37 @@ var CopilotResponse = class {
4438
4671
  status;
4439
4672
  runId;
4440
4673
  messages;
4674
+ extensions;
4441
4675
  };
4442
4676
  __name(CopilotResponse, "CopilotResponse");
4443
- _ts_decorate13([
4444
- (0, import_type_graphql14.Field)(() => String),
4445
- _ts_metadata13("design:type", String)
4677
+ _ts_decorate15([
4678
+ (0, import_type_graphql16.Field)(() => String),
4679
+ _ts_metadata15("design:type", String)
4446
4680
  ], CopilotResponse.prototype, "threadId", void 0);
4447
- _ts_decorate13([
4448
- (0, import_type_graphql14.Field)(() => ResponseStatusUnion),
4449
- _ts_metadata13("design:type", Object)
4681
+ _ts_decorate15([
4682
+ (0, import_type_graphql16.Field)(() => ResponseStatusUnion),
4683
+ _ts_metadata15("design:type", Object)
4450
4684
  ], CopilotResponse.prototype, "status", void 0);
4451
- _ts_decorate13([
4452
- (0, import_type_graphql14.Field)({
4685
+ _ts_decorate15([
4686
+ (0, import_type_graphql16.Field)({
4453
4687
  nullable: true
4454
4688
  }),
4455
- _ts_metadata13("design:type", String)
4689
+ _ts_metadata15("design:type", String)
4456
4690
  ], CopilotResponse.prototype, "runId", void 0);
4457
- _ts_decorate13([
4458
- (0, import_type_graphql14.Field)(() => [
4691
+ _ts_decorate15([
4692
+ (0, import_type_graphql16.Field)(() => [
4459
4693
  BaseMessageOutput
4460
4694
  ]),
4461
- _ts_metadata13("design:type", Array)
4695
+ _ts_metadata15("design:type", Array)
4462
4696
  ], CopilotResponse.prototype, "messages", void 0);
4463
- CopilotResponse = _ts_decorate13([
4464
- (0, import_type_graphql14.ObjectType)()
4697
+ _ts_decorate15([
4698
+ (0, import_type_graphql16.Field)(() => ExtensionsResponse, {
4699
+ nullable: true
4700
+ }),
4701
+ _ts_metadata15("design:type", typeof ExtensionsResponse === "undefined" ? Object : ExtensionsResponse)
4702
+ ], CopilotResponse.prototype, "extensions", void 0);
4703
+ CopilotResponse = _ts_decorate15([
4704
+ (0, import_type_graphql16.ObjectType)()
4465
4705
  ], CopilotResponse);
4466
4706
 
4467
4707
  // src/graphql/resolvers/copilot.resolver.ts
@@ -4504,11 +4744,11 @@ var UnknownErrorResponse = class extends FailedResponseStatus {
4504
4744
  __name(UnknownErrorResponse, "UnknownErrorResponse");
4505
4745
 
4506
4746
  // src/graphql/resolvers/copilot.resolver.ts
4507
- var import_shared13 = require("@copilotkit/shared");
4747
+ var import_shared16 = require("@copilotkit/shared");
4508
4748
 
4509
4749
  // src/graphql/types/agents-response.type.ts
4510
- var import_type_graphql15 = require("type-graphql");
4511
- function _ts_decorate14(decorators, target, key, desc) {
4750
+ var import_type_graphql17 = require("type-graphql");
4751
+ function _ts_decorate16(decorators, target, key, desc) {
4512
4752
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4513
4753
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4514
4754
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4518,49 +4758,49 @@ function _ts_decorate14(decorators, target, key, desc) {
4518
4758
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4519
4759
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4520
4760
  }
4521
- __name(_ts_decorate14, "_ts_decorate");
4522
- function _ts_metadata14(k, v) {
4761
+ __name(_ts_decorate16, "_ts_decorate");
4762
+ function _ts_metadata16(k, v) {
4523
4763
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
4524
4764
  return Reflect.metadata(k, v);
4525
4765
  }
4526
- __name(_ts_metadata14, "_ts_metadata");
4766
+ __name(_ts_metadata16, "_ts_metadata");
4527
4767
  var Agent = class {
4528
4768
  id;
4529
4769
  name;
4530
4770
  description;
4531
4771
  };
4532
4772
  __name(Agent, "Agent");
4533
- _ts_decorate14([
4534
- (0, import_type_graphql15.Field)(() => String),
4535
- _ts_metadata14("design:type", String)
4773
+ _ts_decorate16([
4774
+ (0, import_type_graphql17.Field)(() => String),
4775
+ _ts_metadata16("design:type", String)
4536
4776
  ], Agent.prototype, "id", void 0);
4537
- _ts_decorate14([
4538
- (0, import_type_graphql15.Field)(() => String),
4539
- _ts_metadata14("design:type", String)
4777
+ _ts_decorate16([
4778
+ (0, import_type_graphql17.Field)(() => String),
4779
+ _ts_metadata16("design:type", String)
4540
4780
  ], Agent.prototype, "name", void 0);
4541
- _ts_decorate14([
4542
- (0, import_type_graphql15.Field)(() => String),
4543
- _ts_metadata14("design:type", String)
4781
+ _ts_decorate16([
4782
+ (0, import_type_graphql17.Field)(() => String),
4783
+ _ts_metadata16("design:type", String)
4544
4784
  ], Agent.prototype, "description", void 0);
4545
- Agent = _ts_decorate14([
4546
- (0, import_type_graphql15.ObjectType)()
4785
+ Agent = _ts_decorate16([
4786
+ (0, import_type_graphql17.ObjectType)()
4547
4787
  ], Agent);
4548
4788
  var AgentsResponse = class {
4549
4789
  agents;
4550
4790
  };
4551
4791
  __name(AgentsResponse, "AgentsResponse");
4552
- _ts_decorate14([
4553
- (0, import_type_graphql15.Field)(() => [
4792
+ _ts_decorate16([
4793
+ (0, import_type_graphql17.Field)(() => [
4554
4794
  Agent
4555
4795
  ]),
4556
- _ts_metadata14("design:type", Array)
4796
+ _ts_metadata16("design:type", Array)
4557
4797
  ], AgentsResponse.prototype, "agents", void 0);
4558
- AgentsResponse = _ts_decorate14([
4559
- (0, import_type_graphql15.ObjectType)()
4798
+ AgentsResponse = _ts_decorate16([
4799
+ (0, import_type_graphql17.ObjectType)()
4560
4800
  ], AgentsResponse);
4561
4801
 
4562
4802
  // src/graphql/resolvers/copilot.resolver.ts
4563
- function _ts_decorate15(decorators, target, key, desc) {
4803
+ function _ts_decorate17(decorators, target, key, desc) {
4564
4804
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4565
4805
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4566
4806
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4570,12 +4810,12 @@ function _ts_decorate15(decorators, target, key, desc) {
4570
4810
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4571
4811
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4572
4812
  }
4573
- __name(_ts_decorate15, "_ts_decorate");
4574
- function _ts_metadata15(k, v) {
4813
+ __name(_ts_decorate17, "_ts_decorate");
4814
+ function _ts_metadata17(k, v) {
4575
4815
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
4576
4816
  return Reflect.metadata(k, v);
4577
4817
  }
4578
- __name(_ts_metadata15, "_ts_metadata");
4818
+ __name(_ts_metadata17, "_ts_metadata");
4579
4819
  function _ts_param(paramIndex, decorator) {
4580
4820
  return function(target, key) {
4581
4821
  decorator(target, key, paramIndex);
@@ -4622,10 +4862,10 @@ var CopilotResolver = class {
4622
4862
  component: "CopilotResolver.availableAgents"
4623
4863
  });
4624
4864
  logger2.debug("Processing");
4625
- const agents = await ctx._copilotkit.runtime.discoverAgentsFromEndpoints(ctx);
4865
+ const agentsWithEndpoints = await ctx._copilotkit.runtime.discoverAgentsFromEndpoints(ctx);
4626
4866
  logger2.debug("Event source created, creating response");
4627
4867
  return {
4628
- agents
4868
+ agents: agentsWithEndpoints.map(({ endpoint, ...agentWithoutEndpoint }) => agentWithoutEndpoint)
4629
4869
  };
4630
4870
  }
4631
4871
  async generateCopilotResponse(ctx, data, properties) {
@@ -4687,7 +4927,7 @@ var CopilotResolver = class {
4687
4927
  rejectOutputMessagesPromise = reject;
4688
4928
  });
4689
4929
  logger2.debug("Processing");
4690
- const { eventSource, threadId = (0, import_shared13.randomId)(), runId, serverSideActions, actionInputsWithoutAgents } = await copilotRuntime.processRuntimeRequest({
4930
+ const { eventSource, threadId = (0, import_shared16.randomId)(), runId, serverSideActions, actionInputsWithoutAgents, extensions } = await copilotRuntime.processRuntimeRequest({
4691
4931
  serviceAdapter,
4692
4932
  messages: data.messages,
4693
4933
  actions: data.frontend.actions.filter((action) => action.available !== ActionInputAvailability.disabled),
@@ -4699,13 +4939,15 @@ var CopilotResolver = class {
4699
4939
  forwardedParameters: data.forwardedParameters,
4700
4940
  agentSession: data.agentSession,
4701
4941
  agentStates: data.agentStates,
4702
- url: data.frontend.url
4942
+ url: data.frontend.url,
4943
+ extensions: data.extensions
4703
4944
  });
4704
4945
  logger2.debug("Event source created, creating response");
4705
4946
  const response = {
4706
4947
  threadId,
4707
4948
  runId,
4708
4949
  status: (0, import_rxjs4.firstValueFrom)(responseStatus$),
4950
+ extensions,
4709
4951
  messages: new import_graphql_yoga.Repeater(async (pushMessage, stopStreamingMessages) => {
4710
4952
  var _a2, _b2;
4711
4953
  logger2.debug("Messages repeater created");
@@ -4732,7 +4974,7 @@ var CopilotResolver = class {
4732
4974
  });
4733
4975
  outputMessages = [
4734
4976
  (0, import_class_transformer3.plainToInstance)(TextMessage, {
4735
- id: (0, import_shared13.randomId)(),
4977
+ id: (0, import_shared16.randomId)(),
4736
4978
  createdAt: /* @__PURE__ */ new Date(),
4737
4979
  content: result.reason,
4738
4980
  role: MessageRole.assistant
@@ -4762,7 +5004,8 @@ var CopilotResolver = class {
4762
5004
  actionInputsWithoutAgents: actionInputsWithoutAgents.filter(
4763
5005
  // TODO-AGENTS: do not exclude ALL server side actions
4764
5006
  (action) => !serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)
4765
- )
5007
+ ),
5008
+ threadId
4766
5009
  }).pipe(
4767
5010
  // shareReplay() ensures that later subscribers will see the whole stream instead of
4768
5011
  // just the events that were emitted after the subscriber was added.
@@ -4923,7 +5166,7 @@ var CopilotResolver = class {
4923
5166
  event
4924
5167
  }, "Agent message event received");
4925
5168
  pushMessage({
4926
- id: (0, import_shared13.randomId)(),
5169
+ id: (0, import_shared16.randomId)(),
4927
5170
  status: new SuccessMessageStatus(),
4928
5171
  threadId: event.threadId,
4929
5172
  agentName: event.agentName,
@@ -4936,7 +5179,7 @@ var CopilotResolver = class {
4936
5179
  createdAt: /* @__PURE__ */ new Date()
4937
5180
  });
4938
5181
  outputMessages.push((0, import_class_transformer3.plainToInstance)(AgentStateMessage, {
4939
- id: (0, import_shared13.randomId)(),
5182
+ id: (0, import_shared16.randomId)(),
4940
5183
  threadId: event.threadId,
4941
5184
  agentName: event.agentName,
4942
5185
  nodeName: event.nodeName,
@@ -4980,38 +5223,38 @@ var CopilotResolver = class {
4980
5223
  }
4981
5224
  };
4982
5225
  __name(CopilotResolver, "CopilotResolver");
4983
- _ts_decorate15([
4984
- (0, import_type_graphql16.Query)(() => String),
4985
- _ts_metadata15("design:type", Function),
4986
- _ts_metadata15("design:paramtypes", []),
4987
- _ts_metadata15("design:returntype", Promise)
5226
+ _ts_decorate17([
5227
+ (0, import_type_graphql18.Query)(() => String),
5228
+ _ts_metadata17("design:type", Function),
5229
+ _ts_metadata17("design:paramtypes", []),
5230
+ _ts_metadata17("design:returntype", Promise)
4988
5231
  ], CopilotResolver.prototype, "hello", null);
4989
- _ts_decorate15([
4990
- (0, import_type_graphql16.Query)(() => AgentsResponse),
4991
- _ts_param(0, (0, import_type_graphql16.Ctx)()),
4992
- _ts_metadata15("design:type", Function),
4993
- _ts_metadata15("design:paramtypes", [
5232
+ _ts_decorate17([
5233
+ (0, import_type_graphql18.Query)(() => AgentsResponse),
5234
+ _ts_param(0, (0, import_type_graphql18.Ctx)()),
5235
+ _ts_metadata17("design:type", Function),
5236
+ _ts_metadata17("design:paramtypes", [
4994
5237
  typeof GraphQLContext === "undefined" ? Object : GraphQLContext
4995
5238
  ]),
4996
- _ts_metadata15("design:returntype", Promise)
5239
+ _ts_metadata17("design:returntype", Promise)
4997
5240
  ], CopilotResolver.prototype, "availableAgents", null);
4998
- _ts_decorate15([
4999
- (0, import_type_graphql16.Mutation)(() => CopilotResponse),
5000
- _ts_param(0, (0, import_type_graphql16.Ctx)()),
5001
- _ts_param(1, (0, import_type_graphql16.Arg)("data")),
5002
- _ts_param(2, (0, import_type_graphql16.Arg)("properties", () => import_graphql_scalars2.GraphQLJSONObject, {
5241
+ _ts_decorate17([
5242
+ (0, import_type_graphql18.Mutation)(() => CopilotResponse),
5243
+ _ts_param(0, (0, import_type_graphql18.Ctx)()),
5244
+ _ts_param(1, (0, import_type_graphql18.Arg)("data")),
5245
+ _ts_param(2, (0, import_type_graphql18.Arg)("properties", () => import_graphql_scalars2.GraphQLJSONObject, {
5003
5246
  nullable: true
5004
5247
  })),
5005
- _ts_metadata15("design:type", Function),
5006
- _ts_metadata15("design:paramtypes", [
5248
+ _ts_metadata17("design:type", Function),
5249
+ _ts_metadata17("design:paramtypes", [
5007
5250
  typeof GraphQLContext === "undefined" ? Object : GraphQLContext,
5008
5251
  typeof GenerateCopilotResponseInput === "undefined" ? Object : GenerateCopilotResponseInput,
5009
5252
  typeof CopilotRequestContextProperties === "undefined" ? Object : CopilotRequestContextProperties
5010
5253
  ]),
5011
- _ts_metadata15("design:returntype", Promise)
5254
+ _ts_metadata17("design:returntype", Promise)
5012
5255
  ], CopilotResolver.prototype, "generateCopilotResponse", null);
5013
- CopilotResolver = _ts_decorate15([
5014
- (0, import_type_graphql16.Resolver)(() => CopilotResponse)
5256
+ CopilotResolver = _ts_decorate17([
5257
+ (0, import_type_graphql18.Resolver)(() => CopilotResponse)
5015
5258
  ], CopilotResolver);
5016
5259
 
5017
5260
  // src/lib/integrations/shared.ts
@@ -5045,6 +5288,141 @@ function createLogger(options) {
5045
5288
  }
5046
5289
  __name(createLogger, "createLogger");
5047
5290
 
5291
+ // src/graphql/resolvers/state.resolver.ts
5292
+ var import_type_graphql21 = require("type-graphql");
5293
+ var import_type_graphql22 = require("type-graphql");
5294
+ var import_type_graphql23 = require("type-graphql");
5295
+
5296
+ // src/graphql/types/load-agent-state-response.type.ts
5297
+ var import_type_graphql19 = require("type-graphql");
5298
+ function _ts_decorate18(decorators, target, key, desc) {
5299
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5300
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
5301
+ r = Reflect.decorate(decorators, target, key, desc);
5302
+ else
5303
+ for (var i = decorators.length - 1; i >= 0; i--)
5304
+ if (d = decorators[i])
5305
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5306
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
5307
+ }
5308
+ __name(_ts_decorate18, "_ts_decorate");
5309
+ function _ts_metadata18(k, v) {
5310
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
5311
+ return Reflect.metadata(k, v);
5312
+ }
5313
+ __name(_ts_metadata18, "_ts_metadata");
5314
+ var LoadAgentStateResponse = class {
5315
+ threadId;
5316
+ threadExists;
5317
+ state;
5318
+ messages;
5319
+ };
5320
+ __name(LoadAgentStateResponse, "LoadAgentStateResponse");
5321
+ _ts_decorate18([
5322
+ (0, import_type_graphql19.Field)(() => String),
5323
+ _ts_metadata18("design:type", String)
5324
+ ], LoadAgentStateResponse.prototype, "threadId", void 0);
5325
+ _ts_decorate18([
5326
+ (0, import_type_graphql19.Field)(() => Boolean),
5327
+ _ts_metadata18("design:type", Boolean)
5328
+ ], LoadAgentStateResponse.prototype, "threadExists", void 0);
5329
+ _ts_decorate18([
5330
+ (0, import_type_graphql19.Field)(() => String),
5331
+ _ts_metadata18("design:type", String)
5332
+ ], LoadAgentStateResponse.prototype, "state", void 0);
5333
+ _ts_decorate18([
5334
+ (0, import_type_graphql19.Field)(() => String),
5335
+ _ts_metadata18("design:type", String)
5336
+ ], LoadAgentStateResponse.prototype, "messages", void 0);
5337
+ LoadAgentStateResponse = _ts_decorate18([
5338
+ (0, import_type_graphql19.ObjectType)()
5339
+ ], LoadAgentStateResponse);
5340
+
5341
+ // src/graphql/inputs/load-agent-state.input.ts
5342
+ var import_type_graphql20 = require("type-graphql");
5343
+ function _ts_decorate19(decorators, target, key, desc) {
5344
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5345
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
5346
+ r = Reflect.decorate(decorators, target, key, desc);
5347
+ else
5348
+ for (var i = decorators.length - 1; i >= 0; i--)
5349
+ if (d = decorators[i])
5350
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5351
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
5352
+ }
5353
+ __name(_ts_decorate19, "_ts_decorate");
5354
+ function _ts_metadata19(k, v) {
5355
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
5356
+ return Reflect.metadata(k, v);
5357
+ }
5358
+ __name(_ts_metadata19, "_ts_metadata");
5359
+ var LoadAgentStateInput = class {
5360
+ threadId;
5361
+ agentName;
5362
+ };
5363
+ __name(LoadAgentStateInput, "LoadAgentStateInput");
5364
+ _ts_decorate19([
5365
+ (0, import_type_graphql20.Field)(() => String),
5366
+ _ts_metadata19("design:type", String)
5367
+ ], LoadAgentStateInput.prototype, "threadId", void 0);
5368
+ _ts_decorate19([
5369
+ (0, import_type_graphql20.Field)(() => String),
5370
+ _ts_metadata19("design:type", String)
5371
+ ], LoadAgentStateInput.prototype, "agentName", void 0);
5372
+ LoadAgentStateInput = _ts_decorate19([
5373
+ (0, import_type_graphql20.InputType)()
5374
+ ], LoadAgentStateInput);
5375
+
5376
+ // src/graphql/resolvers/state.resolver.ts
5377
+ function _ts_decorate20(decorators, target, key, desc) {
5378
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5379
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
5380
+ r = Reflect.decorate(decorators, target, key, desc);
5381
+ else
5382
+ for (var i = decorators.length - 1; i >= 0; i--)
5383
+ if (d = decorators[i])
5384
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5385
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
5386
+ }
5387
+ __name(_ts_decorate20, "_ts_decorate");
5388
+ function _ts_metadata20(k, v) {
5389
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
5390
+ return Reflect.metadata(k, v);
5391
+ }
5392
+ __name(_ts_metadata20, "_ts_metadata");
5393
+ function _ts_param2(paramIndex, decorator) {
5394
+ return function(target, key) {
5395
+ decorator(target, key, paramIndex);
5396
+ };
5397
+ }
5398
+ __name(_ts_param2, "_ts_param");
5399
+ var StateResolver = class {
5400
+ async loadAgentState(ctx, data) {
5401
+ const agents = await ctx._copilotkit.runtime.discoverAgentsFromEndpoints(ctx);
5402
+ const agent = agents.find((agent2) => agent2.name === data.agentName);
5403
+ if (!agent) {
5404
+ throw new Error("Agent not found");
5405
+ }
5406
+ const state = await ctx._copilotkit.runtime.loadAgentState(ctx, data.threadId, data.agentName);
5407
+ return state;
5408
+ }
5409
+ };
5410
+ __name(StateResolver, "StateResolver");
5411
+ _ts_decorate20([
5412
+ (0, import_type_graphql23.Query)(() => LoadAgentStateResponse),
5413
+ _ts_param2(0, (0, import_type_graphql22.Ctx)()),
5414
+ _ts_param2(1, (0, import_type_graphql21.Arg)("data")),
5415
+ _ts_metadata20("design:type", Function),
5416
+ _ts_metadata20("design:paramtypes", [
5417
+ typeof GraphQLContext === "undefined" ? Object : GraphQLContext,
5418
+ typeof LoadAgentStateInput === "undefined" ? Object : LoadAgentStateInput
5419
+ ]),
5420
+ _ts_metadata20("design:returntype", Promise)
5421
+ ], StateResolver.prototype, "loadAgentState", null);
5422
+ StateResolver = _ts_decorate20([
5423
+ (0, import_type_graphql21.Resolver)(() => LoadAgentStateResponse)
5424
+ ], StateResolver);
5425
+
5048
5426
  // src/lib/integrations/shared.ts
5049
5427
  var logger = createLogger();
5050
5428
  async function createContext(initialContext, copilotKitContext, contextLogger, properties = {}) {
@@ -5066,9 +5444,10 @@ async function createContext(initialContext, copilotKitContext, contextLogger, p
5066
5444
  __name(createContext, "createContext");
5067
5445
  function buildSchema(options = {}) {
5068
5446
  logger.debug("Building GraphQL schema...");
5069
- const schema = (0, import_type_graphql17.buildSchemaSync)({
5447
+ const schema = (0, import_type_graphql24.buildSchemaSync)({
5070
5448
  resolvers: [
5071
- CopilotResolver
5449
+ CopilotResolver,
5450
+ StateResolver
5072
5451
  ],
5073
5452
  emitSchemaFile: options.emitSchemaFile
5074
5453
  });