@copilotkit/runtime 1.5.12-next.6 → 1.5.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 (70) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/__snapshots__/schema/schema.graphql +33 -0
  3. package/dist/{chunk-XM2VJFL6.mjs → chunk-4LRVKGBI.mjs} +2 -2
  4. package/dist/{chunk-YGXAWYRB.mjs → chunk-IS3QAGOU.mjs} +2 -2
  5. package/dist/{chunk-ON4AESON.mjs → chunk-PFELVFS7.mjs} +540 -221
  6. package/dist/chunk-PFELVFS7.mjs.map +1 -0
  7. package/dist/{chunk-TPTCSIAR.mjs → chunk-S3KKBII4.mjs} +42 -30
  8. package/dist/chunk-S3KKBII4.mjs.map +1 -0
  9. package/dist/{chunk-BKIGYRXE.mjs → chunk-W6EE6OTN.mjs} +2 -2
  10. package/dist/{copilot-runtime-da917bd5.d.ts → copilot-runtime-8c442d65.d.ts} +16 -5
  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 +628 -297
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.mjs +10 -10
  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 +626 -295
  21. package/dist/lib/index.js.map +1 -1
  22. package/dist/lib/index.mjs +6 -6
  23. package/dist/lib/integrations/index.d.ts +4 -4
  24. package/dist/lib/integrations/index.js +495 -237
  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 +495 -237
  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 +495 -237
  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 +495 -237
  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 +102 -9
  55. package/src/lib/runtime/remote-lg-action.ts +24 -12
  56. package/src/service-adapters/anthropic/anthropic-adapter.ts +2 -3
  57. package/src/service-adapters/empty/empty-adapter.ts +2 -2
  58. package/src/service-adapters/events.ts +5 -0
  59. package/src/service-adapters/experimental/ollama/ollama-adapter.ts +2 -2
  60. package/src/service-adapters/groq/groq-adapter.ts +2 -2
  61. package/src/service-adapters/langchain/langchain-adapter.ts +10 -3
  62. package/src/service-adapters/openai/openai-adapter.ts +4 -3
  63. package/src/service-adapters/openai/openai-assistant-adapter.ts +15 -4
  64. package/src/service-adapters/service-adapter.ts +4 -0
  65. package/src/service-adapters/unify/unify-adapter.ts +2 -3
  66. package/dist/chunk-ON4AESON.mjs.map +0 -1
  67. package/dist/chunk-TPTCSIAR.mjs.map +0 -1
  68. /package/dist/{chunk-XM2VJFL6.mjs.map → chunk-4LRVKGBI.mjs.map} +0 -0
  69. /package/dist/{chunk-YGXAWYRB.mjs.map → chunk-IS3QAGOU.mjs.map} +0 -0
  70. /package/dist/{chunk-BKIGYRXE.mjs.map → chunk-W6EE6OTN.mjs.map} +0 -0
package/dist/lib/index.js CHANGED
@@ -44,7 +44,7 @@ var require_package = __commonJS({
44
44
  publishConfig: {
45
45
  access: "public"
46
46
  },
47
- version: "1.5.12-next.6",
47
+ version: "1.5.12",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -148,8 +148,7 @@ __export(lib_exports, {
148
148
  module.exports = __toCommonJS(lib_exports);
149
149
 
150
150
  // src/lib/runtime/copilot-runtime.ts
151
- var import_shared12 = require("@copilotkit/shared");
152
- var import_langgraph_sdk2 = require("@langchain/langgraph-sdk");
151
+ var import_shared13 = require("@copilotkit/shared");
153
152
 
154
153
  // src/service-adapters/langchain/langserve.ts
155
154
  var import_remote = require("langchain/runnables/remote");
@@ -389,8 +388,9 @@ var OpenAIAdapter = class {
389
388
  this.disableParallelToolCalls = (params == null ? void 0 : params.disableParallelToolCalls) || false;
390
389
  }
391
390
  async process(request) {
392
- const { threadId, model = this.model, messages, actions, eventSource, forwardedParameters } = request;
391
+ const { threadId: threadIdFromRequest, model = this.model, messages, actions, eventSource, forwardedParameters } = request;
393
392
  const tools = actions.map(convertActionInputToOpenAITool);
393
+ const threadId = threadIdFromRequest ?? (0, import_shared.randomUUID)();
394
394
  let openaiMessages = messages.map(convertMessageToOpenAIMessage);
395
395
  openaiMessages = limitMessagesToTokenCount(openaiMessages, tools, model);
396
396
  let toolChoice = forwardedParameters == null ? void 0 : forwardedParameters.toolChoice;
@@ -488,7 +488,7 @@ var OpenAIAdapter = class {
488
488
  eventStream$.complete();
489
489
  });
490
490
  return {
491
- threadId: threadId || (0, import_shared.randomId)()
491
+ threadId
492
492
  };
493
493
  }
494
494
  };
@@ -734,8 +734,8 @@ var LangChainAdapter = class {
734
734
  }
735
735
  async process(request) {
736
736
  try {
737
- const { eventSource, model, actions, messages, runId } = request;
738
- const threadId = request.threadId ?? (0, import_shared3.randomId)();
737
+ const { eventSource, model, actions, messages, runId, threadId: threadIdFromRequest } = request;
738
+ const threadId = threadIdFromRequest ?? (0, import_shared3.randomUUID)();
739
739
  const result = await this.options.chainFn({
740
740
  messages: messages.map(convertMessageToLangChainMessage),
741
741
  tools: actions.map(convertActionInputToLangChainTool),
@@ -796,8 +796,12 @@ var OpenAIAssistantAdapter = class {
796
796
  this.disableParallelToolCalls = (params == null ? void 0 : params.disableParallelToolCalls) || false;
797
797
  }
798
798
  async process(request) {
799
+ var _a, _b;
799
800
  const { messages, actions, eventSource, runId, forwardedParameters } = request;
800
- let threadId = request.threadId || (await this.openai.beta.threads.create()).id;
801
+ let threadId = (_b = (_a = request.extensions) == null ? void 0 : _a.openaiAssistantAPI) == null ? void 0 : _b.threadId;
802
+ if (!threadId) {
803
+ threadId = (await this.openai.beta.threads.create()).id;
804
+ }
801
805
  const lastMessage = messages.at(-1);
802
806
  let nextRunId = void 0;
803
807
  if (lastMessage.isResultMessage() && runId) {
@@ -808,8 +812,15 @@ var OpenAIAssistantAdapter = class {
808
812
  throw new Error("No actionable message found in the messages");
809
813
  }
810
814
  return {
815
+ runId: nextRunId,
811
816
  threadId,
812
- runId: nextRunId
817
+ extensions: {
818
+ ...request.extensions,
819
+ openaiAssistantAPI: {
820
+ threadId,
821
+ runId: nextRunId
822
+ }
823
+ }
813
824
  };
814
825
  }
815
826
  async submitToolOutputs(threadId, runId, messages, eventSource) {
@@ -1077,7 +1088,7 @@ var UnifyAdapter = class {
1077
1088
  eventStream$.complete();
1078
1089
  });
1079
1090
  return {
1080
- threadId: request.threadId || (0, import_shared4.randomId)()
1091
+ threadId: request.threadId || (0, import_shared4.randomUUID)()
1081
1092
  };
1082
1093
  }
1083
1094
  };
@@ -1198,7 +1209,7 @@ var GroqAdapter = class {
1198
1209
  eventStream$.complete();
1199
1210
  });
1200
1211
  return {
1201
- threadId: threadId || (0, import_shared5.randomId)()
1212
+ threadId: request.threadId || (0, import_shared5.randomUUID)()
1202
1213
  };
1203
1214
  }
1204
1215
  };
@@ -1209,18 +1220,18 @@ var import_shared6 = require("@copilotkit/shared");
1209
1220
  var EmptyAdapter = class {
1210
1221
  async process(request) {
1211
1222
  return {
1212
- threadId: request.threadId || (0, import_shared6.randomId)()
1223
+ threadId: request.threadId || (0, import_shared6.randomUUID)()
1213
1224
  };
1214
1225
  }
1215
1226
  };
1216
1227
  __name(EmptyAdapter, "EmptyAdapter");
1217
1228
 
1218
1229
  // src/service-adapters/events.ts
1219
- var import_shared11 = require("@copilotkit/shared");
1230
+ var import_shared12 = require("@copilotkit/shared");
1220
1231
  var import_rxjs2 = require("rxjs");
1221
1232
 
1222
1233
  // src/lib/telemetry-client.ts
1223
- var import_shared10 = require("@copilotkit/shared");
1234
+ var import_shared11 = require("@copilotkit/shared");
1224
1235
 
1225
1236
  // src/lib/runtime/remote-action-constructors.ts
1226
1237
  var import_node_crypto2 = require("crypto");
@@ -1468,6 +1479,7 @@ __name(RemoteLangGraphEventSource, "RemoteLangGraphEventSource");
1468
1479
  // src/lib/runtime/remote-lg-action.ts
1469
1480
  var import_langgraph_sdk = require("@langchain/langgraph-sdk");
1470
1481
  var import_node_crypto = require("crypto");
1482
+ var import_shared8 = require("@copilotkit/shared");
1471
1483
  var import_partial_json = require("partial-json");
1472
1484
 
1473
1485
  // src/graphql/types/enums.ts
@@ -1521,7 +1533,7 @@ async function execute(args) {
1521
1533
  __name(execute, "execute");
1522
1534
  async function streamEvents(controller, args) {
1523
1535
  var _a, _b, _c, _d, _e, _f;
1524
- const { deploymentUrl, langsmithApiKey, threadId: agrsInitialThreadId, agent, nodeName: initialNodeName, state: initialState, messages, actions, logger: logger2 } = args;
1536
+ const { deploymentUrl, langsmithApiKey, threadId: argsInitialThreadId, agent, nodeName: initialNodeName, state: initialState, messages, actions, logger: logger2 } = args;
1525
1537
  let nodeName = initialNodeName;
1526
1538
  let state = initialState;
1527
1539
  const { name, assistantId: initialAssistantId } = agent;
@@ -1529,15 +1541,18 @@ async function streamEvents(controller, args) {
1529
1541
  apiUrl: deploymentUrl,
1530
1542
  apiKey: langsmithApiKey
1531
1543
  });
1532
- let initialThreadId = agrsInitialThreadId;
1533
- const wasInitiatedWithExistingThread = !!initialThreadId;
1534
- if (initialThreadId && initialThreadId.startsWith("ck-")) {
1535
- initialThreadId = initialThreadId.substring(3);
1544
+ let threadId = argsInitialThreadId ?? (0, import_shared8.randomUUID)();
1545
+ if (argsInitialThreadId && argsInitialThreadId.startsWith("ck-")) {
1546
+ threadId = argsInitialThreadId.substring(3);
1536
1547
  }
1537
- const threadId = initialThreadId ?? (0, import_node_crypto.randomUUID)();
1538
- if (initialThreadId === threadId) {
1548
+ if (!(0, import_shared8.isValidUUID)(threadId)) {
1549
+ console.warn(`Cannot use the threadId ${threadId} with LangGraph Platform. Must be a valid UUID.`);
1550
+ }
1551
+ let wasInitiatedWithExistingThread = true;
1552
+ try {
1539
1553
  await client.threads.get(threadId);
1540
- } else {
1554
+ } catch (error) {
1555
+ wasInitiatedWithExistingThread = false;
1541
1556
  await client.threads.create({
1542
1557
  threadId
1543
1558
  });
@@ -1550,7 +1565,7 @@ async function streamEvents(controller, args) {
1550
1565
  }
1551
1566
  const agentStateValues = agentState.values;
1552
1567
  state.messages = agentStateValues.messages;
1553
- const mode = wasInitiatedWithExistingThread && nodeName != "__end__" ? "continue" : "start";
1568
+ const mode = threadId && nodeName != "__end__" && nodeName != void 0 && nodeName != null ? "continue" : "start";
1554
1569
  let formattedMessages = [];
1555
1570
  try {
1556
1571
  formattedMessages = copilotkitMessagesToLangChain(messages);
@@ -1970,7 +1985,7 @@ function copilotkitMessagesToLangChain(messages) {
1970
1985
  __name(copilotkitMessagesToLangChain, "copilotkitMessagesToLangChain");
1971
1986
 
1972
1987
  // src/lib/runtime/remote-action-constructors.ts
1973
- var import_shared8 = require("@copilotkit/shared");
1988
+ var import_shared9 = require("@copilotkit/shared");
1974
1989
  function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, messages, agentStates }) {
1975
1990
  const agents = endpoint.agents.map((agent) => ({
1976
1991
  name: agent.name,
@@ -2078,10 +2093,10 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
2078
2093
  }, "Executed remote action");
2079
2094
  return result;
2080
2095
  } catch (error) {
2081
- if (error instanceof import_shared8.CopilotKitError) {
2096
+ if (error instanceof import_shared9.CopilotKitError) {
2082
2097
  throw error;
2083
2098
  }
2084
- throw new import_shared8.CopilotKitLowLevelError({
2099
+ throw new import_shared9.CopilotKitLowLevelError({
2085
2100
  error,
2086
2101
  url: fetchUrl
2087
2102
  });
@@ -2146,10 +2161,10 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
2146
2161
  streamResponse(response.body, eventSource.eventStream$);
2147
2162
  return eventSource.processLangGraphEvents();
2148
2163
  } catch (error) {
2149
- if (error instanceof import_shared8.CopilotKitError) {
2164
+ if (error instanceof import_shared9.CopilotKitError) {
2150
2165
  throw error;
2151
2166
  }
2152
- throw new import_shared8.CopilotKitLowLevelError({
2167
+ throw new import_shared9.CopilotKitLowLevelError({
2153
2168
  error,
2154
2169
  url: fetchUrl
2155
2170
  });
@@ -2223,7 +2238,7 @@ function createHeaders(onBeforeRequest, graphqlContext) {
2223
2238
  __name(createHeaders, "createHeaders");
2224
2239
 
2225
2240
  // src/lib/runtime/remote-actions.ts
2226
- var import_shared9 = require("@copilotkit/shared");
2241
+ var import_shared10 = require("@copilotkit/shared");
2227
2242
  var EndpointType;
2228
2243
  (function(EndpointType2) {
2229
2244
  EndpointType2["CopilotKit"] = "copilotKit";
@@ -2257,7 +2272,7 @@ async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: l
2257
2272
  status: response.status,
2258
2273
  body: await response.text()
2259
2274
  }, "Failed to fetch actions from url");
2260
- throw new import_shared9.ResolvedCopilotKitError({
2275
+ throw new import_shared10.ResolvedCopilotKitError({
2261
2276
  status: response.status,
2262
2277
  isRemoteEndpoint: true
2263
2278
  });
@@ -2268,10 +2283,10 @@ async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: l
2268
2283
  }, "Fetched actions from url");
2269
2284
  return json;
2270
2285
  } catch (error) {
2271
- if (error instanceof import_shared9.CopilotKitError) {
2286
+ if (error instanceof import_shared10.CopilotKitError) {
2272
2287
  throw error;
2273
2288
  }
2274
- throw new import_shared9.CopilotKitLowLevelError({
2289
+ throw new import_shared10.CopilotKitLowLevelError({
2275
2290
  error,
2276
2291
  url: fetchUrl
2277
2292
  });
@@ -2334,7 +2349,7 @@ __name(setupRemoteActions, "setupRemoteActions");
2334
2349
  // src/lib/telemetry-client.ts
2335
2350
  var import_node_crypto3 = require("crypto");
2336
2351
  var packageJson = require_package();
2337
- var telemetryClient = new import_shared10.TelemetryClient({
2352
+ var telemetryClient = new import_shared11.TelemetryClient({
2338
2353
  packageName: packageJson.name,
2339
2354
  packageVersion: packageJson.version
2340
2355
  });
@@ -2644,13 +2659,13 @@ var RuntimeEventSource = class {
2644
2659
  const errorMessage = `\u274C ${message}`;
2645
2660
  if (!this.callback) {
2646
2661
  this.stream(async (eventStream$) => {
2647
- eventStream$.sendTextMessage((0, import_shared11.randomId)(), errorMessage);
2662
+ eventStream$.sendTextMessage((0, import_shared12.randomId)(), errorMessage);
2648
2663
  });
2649
2664
  } else {
2650
- this.eventStream$.sendTextMessage((0, import_shared11.randomId)(), errorMessage);
2665
+ this.eventStream$.sendTextMessage((0, import_shared12.randomId)(), errorMessage);
2651
2666
  }
2652
2667
  }
2653
- processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents }) {
2668
+ processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents, threadId }) {
2654
2669
  this.callback(this.eventStream$).catch((error) => {
2655
2670
  console.error("Error in event source callback", error);
2656
2671
  this.sendErrorMessageToChat();
@@ -2686,7 +2701,7 @@ var RuntimeEventSource = class {
2686
2701
  (0, import_rxjs2.concatMap)((eventWithState) => {
2687
2702
  if (eventWithState.event.type === "ActionExecutionEnd" && eventWithState.callActionServerSide) {
2688
2703
  const toolCallEventStream$ = new RuntimeEventSubject();
2689
- executeAction(toolCallEventStream$, guardrailsResult$ ? guardrailsResult$ : null, eventWithState.action, eventWithState.args, eventWithState.actionExecutionParentMessageId, eventWithState.actionExecutionId, actionInputsWithoutAgents).catch((error) => {
2704
+ executeAction(toolCallEventStream$, guardrailsResult$ ? guardrailsResult$ : null, eventWithState.action, eventWithState.args, eventWithState.actionExecutionParentMessageId, eventWithState.actionExecutionId, actionInputsWithoutAgents, threadId).catch((error) => {
2690
2705
  console.error(error);
2691
2706
  });
2692
2707
  telemetry_client_default.capture("oss.runtime.server_action_executed", {});
@@ -2703,7 +2718,7 @@ var RuntimeEventSource = class {
2703
2718
  }
2704
2719
  };
2705
2720
  __name(RuntimeEventSource, "RuntimeEventSource");
2706
- async function executeAction(eventStream$, guardrailsResult$, action, actionArguments, actionExecutionParentMessageId, actionExecutionId, actionInputsWithoutAgents) {
2721
+ async function executeAction(eventStream$, guardrailsResult$, action, actionArguments, actionExecutionParentMessageId, actionExecutionId, actionInputsWithoutAgents, threadId) {
2707
2722
  var _a;
2708
2723
  if (guardrailsResult$) {
2709
2724
  const { status } = await (0, import_rxjs2.firstValueFrom)(guardrailsResult$);
@@ -2754,6 +2769,7 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
2754
2769
  });
2755
2770
  const stream = await action.langGraphAgentHandler({
2756
2771
  name: action.name,
2772
+ threadId,
2757
2773
  actionInputsWithoutAgents,
2758
2774
  additionalMessages: [
2759
2775
  agentExecution,
@@ -2853,6 +2869,7 @@ __name(convertGqlInputToMessages, "convertGqlInputToMessages");
2853
2869
 
2854
2870
  // src/lib/runtime/copilot-runtime.ts
2855
2871
  var import_rxjs3 = require("rxjs");
2872
+ var import_langgraph_sdk2 = require("@langchain/langgraph-sdk");
2856
2873
  var CopilotRuntime = class {
2857
2874
  actions;
2858
2875
  remoteEndpointDefinitions;
@@ -2872,14 +2889,14 @@ var CopilotRuntime = class {
2872
2889
  }
2873
2890
  async processRuntimeRequest(request) {
2874
2891
  var _a;
2875
- const { serviceAdapter, messages: rawMessages, actions: clientSideActionsInput, threadId, runId, outputMessagesPromise, graphqlContext, forwardedParameters, agentSession, url } = request;
2892
+ const { serviceAdapter, messages: rawMessages, actions: clientSideActionsInput, threadId, runId, outputMessagesPromise, graphqlContext, forwardedParameters, agentSession, url, extensions } = request;
2876
2893
  const eventSource = new RuntimeEventSource();
2877
2894
  try {
2878
2895
  if (agentSession) {
2879
2896
  return await this.processAgentRequest(request);
2880
2897
  }
2881
2898
  if (serviceAdapter instanceof EmptyAdapter) {
2882
- throw new import_shared12.CopilotKitMisuseError({
2899
+ throw new import_shared13.CopilotKitMisuseError({
2883
2900
  message: `Invalid adapter configuration: EmptyAdapter is only meant to be used with agent lock mode.
2884
2901
  For non-agent components like useCopilotChatSuggestions, CopilotTextarea, or CopilotTask,
2885
2902
  please use an LLM adapter instead.`
@@ -2891,7 +2908,7 @@ please use an LLM adapter instead.`
2891
2908
  const serverSideActionsInput = serverSideActions.map((action) => ({
2892
2909
  name: action.name,
2893
2910
  description: action.description,
2894
- jsonSchema: JSON.stringify((0, import_shared12.actionParametersToJsonSchema)(action.parameters))
2911
+ jsonSchema: JSON.stringify((0, import_shared13.actionParametersToJsonSchema)(action.parameters))
2895
2912
  }));
2896
2913
  const actionInputs = flattenToolCallsNoDuplicates([
2897
2914
  ...serverSideActionsInput,
@@ -2913,12 +2930,14 @@ please use an LLM adapter instead.`
2913
2930
  threadId,
2914
2931
  runId,
2915
2932
  eventSource,
2916
- forwardedParameters
2933
+ forwardedParameters,
2934
+ extensions
2917
2935
  });
2936
+ const nonEmptyThreadId = threadId ?? result.threadId;
2918
2937
  outputMessagesPromise.then((outputMessages) => {
2919
2938
  var _a2;
2920
2939
  (_a2 = this.onAfterRequest) == null ? void 0 : _a2.call(this, {
2921
- threadId: result.threadId,
2940
+ threadId: nonEmptyThreadId,
2922
2941
  runId: result.runId,
2923
2942
  inputMessages,
2924
2943
  outputMessages,
@@ -2928,17 +2947,18 @@ please use an LLM adapter instead.`
2928
2947
  }).catch((_error) => {
2929
2948
  });
2930
2949
  return {
2931
- threadId: result.threadId,
2950
+ threadId: nonEmptyThreadId,
2932
2951
  runId: result.runId,
2933
2952
  eventSource,
2934
2953
  serverSideActions,
2935
2954
  actionInputsWithoutAgents: actionInputs.filter((action) => (
2936
2955
  // TODO-AGENTS: do not exclude ALL server side actions
2937
2956
  !serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)
2938
- ))
2957
+ )),
2958
+ extensions: result.extensions
2939
2959
  };
2940
2960
  } catch (error) {
2941
- if (error instanceof import_shared12.CopilotKitError) {
2961
+ if (error instanceof import_shared13.CopilotKitError) {
2942
2962
  throw error;
2943
2963
  }
2944
2964
  console.error("Error getting response:", error);
@@ -2978,9 +2998,9 @@ please use an LLM adapter instead.`
2978
2998
  });
2979
2999
  if (!response.ok) {
2980
3000
  if (response.status === 404) {
2981
- throw new import_shared12.CopilotKitApiDiscoveryError();
3001
+ throw new import_shared13.CopilotKitApiDiscoveryError();
2982
3002
  }
2983
- throw new import_shared12.ResolvedCopilotKitError({
3003
+ throw new import_shared13.ResolvedCopilotKitError({
2984
3004
  status: response.status,
2985
3005
  isRemoteEndpoint: true
2986
3006
  });
@@ -2988,18 +3008,19 @@ please use an LLM adapter instead.`
2988
3008
  const data = await response.json();
2989
3009
  const endpointAgents = ((data == null ? void 0 : data.agents) ?? []).map((agent) => ({
2990
3010
  name: agent.name,
2991
- description: agent.description ?? "",
2992
- id: (0, import_shared12.randomId)()
3011
+ description: agent.description ?? "" ?? "",
3012
+ id: (0, import_shared13.randomId)(),
3013
+ endpoint
2993
3014
  }));
2994
3015
  return [
2995
3016
  ...agents2,
2996
3017
  ...endpointAgents
2997
3018
  ];
2998
3019
  } catch (error) {
2999
- if (error instanceof import_shared12.CopilotKitError) {
3020
+ if (error instanceof import_shared13.CopilotKitError) {
3000
3021
  throw error;
3001
3022
  }
3002
- throw new import_shared12.CopilotKitLowLevelError({
3023
+ throw new import_shared13.CopilotKitLowLevelError({
3003
3024
  error,
3004
3025
  url: fetchUrl
3005
3026
  });
@@ -3007,22 +3028,74 @@ please use an LLM adapter instead.`
3007
3028
  }, Promise.resolve([]));
3008
3029
  return agents;
3009
3030
  }
3031
+ async loadAgentState(graphqlContext, threadId, agentName) {
3032
+ const agentsWithEndpoints = await this.discoverAgentsFromEndpoints(graphqlContext);
3033
+ const agentWithEndpoint = agentsWithEndpoints.find((agent) => agent.name === agentName);
3034
+ if (!agentWithEndpoint) {
3035
+ throw new Error("Agent not found");
3036
+ }
3037
+ const headers = createHeaders(null, graphqlContext);
3038
+ if (agentWithEndpoint.endpoint.type === EndpointType.LangGraphPlatform) {
3039
+ const client = new import_langgraph_sdk2.Client({
3040
+ apiUrl: agentWithEndpoint.endpoint.deploymentUrl,
3041
+ apiKey: agentWithEndpoint.endpoint.langsmithApiKey
3042
+ });
3043
+ const state = (await client.threads.getState(threadId)).values;
3044
+ if (Object.keys(state).length === 0) {
3045
+ return {
3046
+ threadId,
3047
+ threadExists: false,
3048
+ state: JSON.stringify({}),
3049
+ messages: JSON.stringify([])
3050
+ };
3051
+ } else {
3052
+ console.log(state);
3053
+ const { messages, ...stateWithoutMessages } = state;
3054
+ const copilotkitMessages = langchainMessagesToCopilotKit(messages);
3055
+ return {
3056
+ threadId,
3057
+ threadExists: true,
3058
+ state: JSON.stringify(stateWithoutMessages),
3059
+ messages: JSON.stringify(copilotkitMessages)
3060
+ };
3061
+ }
3062
+ } else if (agentWithEndpoint.endpoint.type === EndpointType.CopilotKit || !("type" in agentWithEndpoint.endpoint)) {
3063
+ const response = await fetch(`${agentWithEndpoint.endpoint.url}/agents/state`, {
3064
+ method: "POST",
3065
+ headers,
3066
+ body: JSON.stringify({
3067
+ properties: graphqlContext.properties,
3068
+ threadId,
3069
+ name: agentName
3070
+ })
3071
+ });
3072
+ const data = await response.json();
3073
+ return {
3074
+ ...data,
3075
+ state: JSON.stringify(data.state),
3076
+ messages: JSON.stringify(data.messages)
3077
+ };
3078
+ } else {
3079
+ throw new Error(`Unknown endpoint type: ${agentWithEndpoint.endpoint.type}`);
3080
+ }
3081
+ }
3010
3082
  async processAgentRequest(request) {
3011
3083
  var _a;
3012
- const { messages: rawMessages, outputMessagesPromise, graphqlContext, agentSession } = request;
3013
- const { threadId, agentName, nodeName } = agentSession;
3084
+ const { messages: rawMessages, outputMessagesPromise, graphqlContext, agentSession, threadId: threadIdFromRequest } = request;
3085
+ const { agentName, nodeName } = agentSession;
3086
+ const threadId = threadIdFromRequest ?? agentSession.threadId;
3014
3087
  const serverSideActions = await this.getServerSideActions(request);
3015
3088
  const messages = convertGqlInputToMessages(rawMessages);
3016
3089
  const agent = serverSideActions.find((action) => action.name === agentName && isLangGraphAgentAction(action));
3017
3090
  if (!agent) {
3018
- throw new import_shared12.CopilotKitAgentDiscoveryError({
3091
+ throw new import_shared13.CopilotKitAgentDiscoveryError({
3019
3092
  agentName
3020
3093
  });
3021
3094
  }
3022
3095
  const serverSideActionsInput = serverSideActions.filter((action) => !isLangGraphAgentAction(action)).map((action) => ({
3023
3096
  name: action.name,
3024
3097
  description: action.description,
3025
- jsonSchema: JSON.stringify((0, import_shared12.actionParametersToJsonSchema)(action.parameters))
3098
+ jsonSchema: JSON.stringify((0, import_shared13.actionParametersToJsonSchema)(action.parameters))
3026
3099
  }));
3027
3100
  const actionInputsWithoutAgents = flattenToolCallsNoDuplicates([
3028
3101
  ...serverSideActionsInput,
@@ -3150,14 +3223,14 @@ function resolveEndpointType(endpoint) {
3150
3223
  __name(resolveEndpointType, "resolveEndpointType");
3151
3224
 
3152
3225
  // src/lib/integrations/shared.ts
3153
- var import_type_graphql17 = require("type-graphql");
3226
+ var import_type_graphql24 = require("type-graphql");
3154
3227
 
3155
3228
  // src/graphql/resolvers/copilot.resolver.ts
3156
- var import_type_graphql16 = require("type-graphql");
3229
+ var import_type_graphql18 = require("type-graphql");
3157
3230
  var import_rxjs4 = require("rxjs");
3158
3231
 
3159
3232
  // src/graphql/inputs/generate-copilot-response.input.ts
3160
- var import_type_graphql11 = require("type-graphql");
3233
+ var import_type_graphql12 = require("type-graphql");
3161
3234
 
3162
3235
  // src/graphql/inputs/message.input.ts
3163
3236
  var import_type_graphql3 = require("type-graphql");
@@ -3673,7 +3746,8 @@ AgentStateInput = _ts_decorate9([
3673
3746
  (0, import_type_graphql10.InputType)()
3674
3747
  ], AgentStateInput);
3675
3748
 
3676
- // src/graphql/inputs/generate-copilot-response.input.ts
3749
+ // src/graphql/inputs/extensions.input.ts
3750
+ var import_type_graphql11 = require("type-graphql");
3677
3751
  function _ts_decorate10(decorators, target, key, desc) {
3678
3752
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3679
3753
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -3690,18 +3764,69 @@ function _ts_metadata10(k, v) {
3690
3764
  return Reflect.metadata(k, v);
3691
3765
  }
3692
3766
  __name(_ts_metadata10, "_ts_metadata");
3767
+ var ExtensionsInput = class {
3768
+ openaiAssistantAPI;
3769
+ };
3770
+ __name(ExtensionsInput, "ExtensionsInput");
3771
+ _ts_decorate10([
3772
+ (0, import_type_graphql11.Field)(() => OpenAIApiAssistantAPIInput, {
3773
+ nullable: true
3774
+ }),
3775
+ _ts_metadata10("design:type", typeof OpenAIApiAssistantAPIInput === "undefined" ? Object : OpenAIApiAssistantAPIInput)
3776
+ ], ExtensionsInput.prototype, "openaiAssistantAPI", void 0);
3777
+ ExtensionsInput = _ts_decorate10([
3778
+ (0, import_type_graphql11.InputType)()
3779
+ ], ExtensionsInput);
3780
+ var OpenAIApiAssistantAPIInput = class {
3781
+ runId;
3782
+ threadId;
3783
+ };
3784
+ __name(OpenAIApiAssistantAPIInput, "OpenAIApiAssistantAPIInput");
3785
+ _ts_decorate10([
3786
+ (0, import_type_graphql11.Field)(() => String, {
3787
+ nullable: true
3788
+ }),
3789
+ _ts_metadata10("design:type", String)
3790
+ ], OpenAIApiAssistantAPIInput.prototype, "runId", void 0);
3791
+ _ts_decorate10([
3792
+ (0, import_type_graphql11.Field)(() => String, {
3793
+ nullable: true
3794
+ }),
3795
+ _ts_metadata10("design:type", String)
3796
+ ], OpenAIApiAssistantAPIInput.prototype, "threadId", void 0);
3797
+ OpenAIApiAssistantAPIInput = _ts_decorate10([
3798
+ (0, import_type_graphql11.InputType)()
3799
+ ], OpenAIApiAssistantAPIInput);
3800
+
3801
+ // src/graphql/inputs/generate-copilot-response.input.ts
3802
+ function _ts_decorate11(decorators, target, key, desc) {
3803
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3804
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3805
+ r = Reflect.decorate(decorators, target, key, desc);
3806
+ else
3807
+ for (var i = decorators.length - 1; i >= 0; i--)
3808
+ if (d = decorators[i])
3809
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3810
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
3811
+ }
3812
+ __name(_ts_decorate11, "_ts_decorate");
3813
+ function _ts_metadata11(k, v) {
3814
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
3815
+ return Reflect.metadata(k, v);
3816
+ }
3817
+ __name(_ts_metadata11, "_ts_metadata");
3693
3818
  var GenerateCopilotResponseMetadataInput = class {
3694
3819
  requestType;
3695
3820
  };
3696
3821
  __name(GenerateCopilotResponseMetadataInput, "GenerateCopilotResponseMetadataInput");
3697
- _ts_decorate10([
3698
- (0, import_type_graphql11.Field)(() => CopilotRequestType, {
3822
+ _ts_decorate11([
3823
+ (0, import_type_graphql12.Field)(() => CopilotRequestType, {
3699
3824
  nullable: true
3700
3825
  }),
3701
- _ts_metadata10("design:type", typeof CopilotRequestType === "undefined" ? Object : CopilotRequestType)
3826
+ _ts_metadata11("design:type", typeof CopilotRequestType === "undefined" ? Object : CopilotRequestType)
3702
3827
  ], GenerateCopilotResponseMetadataInput.prototype, "requestType", void 0);
3703
- GenerateCopilotResponseMetadataInput = _ts_decorate10([
3704
- (0, import_type_graphql11.InputType)()
3828
+ GenerateCopilotResponseMetadataInput = _ts_decorate11([
3829
+ (0, import_type_graphql12.InputType)()
3705
3830
  ], GenerateCopilotResponseMetadataInput);
3706
3831
  var GenerateCopilotResponseInput = class {
3707
3832
  metadata;
@@ -3714,78 +3839,85 @@ var GenerateCopilotResponseInput = class {
3714
3839
  agentSession;
3715
3840
  agentState;
3716
3841
  agentStates;
3842
+ extensions;
3717
3843
  };
3718
3844
  __name(GenerateCopilotResponseInput, "GenerateCopilotResponseInput");
3719
- _ts_decorate10([
3720
- (0, import_type_graphql11.Field)(() => GenerateCopilotResponseMetadataInput, {
3845
+ _ts_decorate11([
3846
+ (0, import_type_graphql12.Field)(() => GenerateCopilotResponseMetadataInput, {
3721
3847
  nullable: false
3722
3848
  }),
3723
- _ts_metadata10("design:type", typeof GenerateCopilotResponseMetadataInput === "undefined" ? Object : GenerateCopilotResponseMetadataInput)
3849
+ _ts_metadata11("design:type", typeof GenerateCopilotResponseMetadataInput === "undefined" ? Object : GenerateCopilotResponseMetadataInput)
3724
3850
  ], GenerateCopilotResponseInput.prototype, "metadata", void 0);
3725
- _ts_decorate10([
3726
- (0, import_type_graphql11.Field)(() => String, {
3851
+ _ts_decorate11([
3852
+ (0, import_type_graphql12.Field)(() => String, {
3727
3853
  nullable: true
3728
3854
  }),
3729
- _ts_metadata10("design:type", String)
3855
+ _ts_metadata11("design:type", String)
3730
3856
  ], GenerateCopilotResponseInput.prototype, "threadId", void 0);
3731
- _ts_decorate10([
3732
- (0, import_type_graphql11.Field)(() => String, {
3857
+ _ts_decorate11([
3858
+ (0, import_type_graphql12.Field)(() => String, {
3733
3859
  nullable: true
3734
3860
  }),
3735
- _ts_metadata10("design:type", String)
3861
+ _ts_metadata11("design:type", String)
3736
3862
  ], GenerateCopilotResponseInput.prototype, "runId", void 0);
3737
- _ts_decorate10([
3738
- (0, import_type_graphql11.Field)(() => [
3863
+ _ts_decorate11([
3864
+ (0, import_type_graphql12.Field)(() => [
3739
3865
  MessageInput
3740
3866
  ]),
3741
- _ts_metadata10("design:type", Array)
3867
+ _ts_metadata11("design:type", Array)
3742
3868
  ], GenerateCopilotResponseInput.prototype, "messages", void 0);
3743
- _ts_decorate10([
3744
- (0, import_type_graphql11.Field)(() => FrontendInput),
3745
- _ts_metadata10("design:type", typeof FrontendInput === "undefined" ? Object : FrontendInput)
3869
+ _ts_decorate11([
3870
+ (0, import_type_graphql12.Field)(() => FrontendInput),
3871
+ _ts_metadata11("design:type", typeof FrontendInput === "undefined" ? Object : FrontendInput)
3746
3872
  ], GenerateCopilotResponseInput.prototype, "frontend", void 0);
3747
- _ts_decorate10([
3748
- (0, import_type_graphql11.Field)(() => CloudInput, {
3873
+ _ts_decorate11([
3874
+ (0, import_type_graphql12.Field)(() => CloudInput, {
3749
3875
  nullable: true
3750
3876
  }),
3751
- _ts_metadata10("design:type", typeof CloudInput === "undefined" ? Object : CloudInput)
3877
+ _ts_metadata11("design:type", typeof CloudInput === "undefined" ? Object : CloudInput)
3752
3878
  ], GenerateCopilotResponseInput.prototype, "cloud", void 0);
3753
- _ts_decorate10([
3754
- (0, import_type_graphql11.Field)(() => ForwardedParametersInput, {
3879
+ _ts_decorate11([
3880
+ (0, import_type_graphql12.Field)(() => ForwardedParametersInput, {
3755
3881
  nullable: true
3756
3882
  }),
3757
- _ts_metadata10("design:type", typeof ForwardedParametersInput === "undefined" ? Object : ForwardedParametersInput)
3883
+ _ts_metadata11("design:type", typeof ForwardedParametersInput === "undefined" ? Object : ForwardedParametersInput)
3758
3884
  ], GenerateCopilotResponseInput.prototype, "forwardedParameters", void 0);
3759
- _ts_decorate10([
3760
- (0, import_type_graphql11.Field)(() => AgentSessionInput, {
3885
+ _ts_decorate11([
3886
+ (0, import_type_graphql12.Field)(() => AgentSessionInput, {
3761
3887
  nullable: true
3762
3888
  }),
3763
- _ts_metadata10("design:type", typeof AgentSessionInput === "undefined" ? Object : AgentSessionInput)
3889
+ _ts_metadata11("design:type", typeof AgentSessionInput === "undefined" ? Object : AgentSessionInput)
3764
3890
  ], GenerateCopilotResponseInput.prototype, "agentSession", void 0);
3765
- _ts_decorate10([
3766
- (0, import_type_graphql11.Field)(() => AgentStateInput, {
3891
+ _ts_decorate11([
3892
+ (0, import_type_graphql12.Field)(() => AgentStateInput, {
3767
3893
  nullable: true
3768
3894
  }),
3769
- _ts_metadata10("design:type", typeof AgentStateInput === "undefined" ? Object : AgentStateInput)
3895
+ _ts_metadata11("design:type", typeof AgentStateInput === "undefined" ? Object : AgentStateInput)
3770
3896
  ], GenerateCopilotResponseInput.prototype, "agentState", void 0);
3771
- _ts_decorate10([
3772
- (0, import_type_graphql11.Field)(() => [
3897
+ _ts_decorate11([
3898
+ (0, import_type_graphql12.Field)(() => [
3773
3899
  AgentStateInput
3774
3900
  ], {
3775
3901
  nullable: true
3776
3902
  }),
3777
- _ts_metadata10("design:type", Array)
3903
+ _ts_metadata11("design:type", Array)
3778
3904
  ], GenerateCopilotResponseInput.prototype, "agentStates", void 0);
3779
- GenerateCopilotResponseInput = _ts_decorate10([
3780
- (0, import_type_graphql11.InputType)()
3905
+ _ts_decorate11([
3906
+ (0, import_type_graphql12.Field)(() => ExtensionsInput, {
3907
+ nullable: true
3908
+ }),
3909
+ _ts_metadata11("design:type", typeof ExtensionsInput === "undefined" ? Object : ExtensionsInput)
3910
+ ], GenerateCopilotResponseInput.prototype, "extensions", void 0);
3911
+ GenerateCopilotResponseInput = _ts_decorate11([
3912
+ (0, import_type_graphql12.InputType)()
3781
3913
  ], GenerateCopilotResponseInput);
3782
3914
 
3783
3915
  // src/graphql/types/copilot-response.type.ts
3784
- var import_type_graphql14 = require("type-graphql");
3916
+ var import_type_graphql16 = require("type-graphql");
3785
3917
 
3786
3918
  // src/graphql/types/message-status.type.ts
3787
- var import_type_graphql12 = require("type-graphql");
3788
- function _ts_decorate11(decorators, target, key, desc) {
3919
+ var import_type_graphql13 = require("type-graphql");
3920
+ function _ts_decorate12(decorators, target, key, desc) {
3789
3921
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3790
3922
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3791
3923
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3795,58 +3927,58 @@ function _ts_decorate11(decorators, target, key, desc) {
3795
3927
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3796
3928
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3797
3929
  }
3798
- __name(_ts_decorate11, "_ts_decorate");
3799
- function _ts_metadata11(k, v) {
3930
+ __name(_ts_decorate12, "_ts_decorate");
3931
+ function _ts_metadata12(k, v) {
3800
3932
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
3801
3933
  return Reflect.metadata(k, v);
3802
3934
  }
3803
- __name(_ts_metadata11, "_ts_metadata");
3935
+ __name(_ts_metadata12, "_ts_metadata");
3804
3936
  var MessageStatusCode;
3805
3937
  (function(MessageStatusCode2) {
3806
3938
  MessageStatusCode2["Pending"] = "pending";
3807
3939
  MessageStatusCode2["Success"] = "success";
3808
3940
  MessageStatusCode2["Failed"] = "failed";
3809
3941
  })(MessageStatusCode || (MessageStatusCode = {}));
3810
- (0, import_type_graphql12.registerEnumType)(MessageStatusCode, {
3942
+ (0, import_type_graphql13.registerEnumType)(MessageStatusCode, {
3811
3943
  name: "MessageStatusCode"
3812
3944
  });
3813
3945
  var BaseMessageStatus = /* @__PURE__ */ __name(class BaseMessageStatus2 {
3814
3946
  code;
3815
3947
  }, "BaseMessageStatus");
3816
- _ts_decorate11([
3817
- (0, import_type_graphql12.Field)(() => MessageStatusCode),
3818
- _ts_metadata11("design:type", String)
3948
+ _ts_decorate12([
3949
+ (0, import_type_graphql13.Field)(() => MessageStatusCode),
3950
+ _ts_metadata12("design:type", String)
3819
3951
  ], BaseMessageStatus.prototype, "code", void 0);
3820
- BaseMessageStatus = _ts_decorate11([
3821
- (0, import_type_graphql12.ObjectType)()
3952
+ BaseMessageStatus = _ts_decorate12([
3953
+ (0, import_type_graphql13.ObjectType)()
3822
3954
  ], BaseMessageStatus);
3823
3955
  var PendingMessageStatus = class extends BaseMessageStatus {
3824
3956
  code = "pending";
3825
3957
  };
3826
3958
  __name(PendingMessageStatus, "PendingMessageStatus");
3827
- PendingMessageStatus = _ts_decorate11([
3828
- (0, import_type_graphql12.ObjectType)()
3959
+ PendingMessageStatus = _ts_decorate12([
3960
+ (0, import_type_graphql13.ObjectType)()
3829
3961
  ], PendingMessageStatus);
3830
3962
  var SuccessMessageStatus = class extends BaseMessageStatus {
3831
3963
  code = "success";
3832
3964
  };
3833
3965
  __name(SuccessMessageStatus, "SuccessMessageStatus");
3834
- SuccessMessageStatus = _ts_decorate11([
3835
- (0, import_type_graphql12.ObjectType)()
3966
+ SuccessMessageStatus = _ts_decorate12([
3967
+ (0, import_type_graphql13.ObjectType)()
3836
3968
  ], SuccessMessageStatus);
3837
3969
  var FailedMessageStatus = class extends BaseMessageStatus {
3838
3970
  code = "failed";
3839
3971
  reason;
3840
3972
  };
3841
3973
  __name(FailedMessageStatus, "FailedMessageStatus");
3842
- _ts_decorate11([
3843
- (0, import_type_graphql12.Field)(() => String),
3844
- _ts_metadata11("design:type", String)
3974
+ _ts_decorate12([
3975
+ (0, import_type_graphql13.Field)(() => String),
3976
+ _ts_metadata12("design:type", String)
3845
3977
  ], FailedMessageStatus.prototype, "reason", void 0);
3846
- FailedMessageStatus = _ts_decorate11([
3847
- (0, import_type_graphql12.ObjectType)()
3978
+ FailedMessageStatus = _ts_decorate12([
3979
+ (0, import_type_graphql13.ObjectType)()
3848
3980
  ], FailedMessageStatus);
3849
- var MessageStatusUnion = (0, import_type_graphql12.createUnionType)({
3981
+ var MessageStatusUnion = (0, import_type_graphql13.createUnionType)({
3850
3982
  name: "MessageStatus",
3851
3983
  types: () => [
3852
3984
  PendingMessageStatus,
@@ -3857,8 +3989,8 @@ var MessageStatusUnion = (0, import_type_graphql12.createUnionType)({
3857
3989
 
3858
3990
  // src/graphql/types/response-status.type.ts
3859
3991
  var import_graphql_scalars = require("graphql-scalars");
3860
- var import_type_graphql13 = require("type-graphql");
3861
- function _ts_decorate12(decorators, target, key, desc) {
3992
+ var import_type_graphql14 = require("type-graphql");
3993
+ function _ts_decorate13(decorators, target, key, desc) {
3862
3994
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3863
3995
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3864
3996
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3868,30 +4000,30 @@ function _ts_decorate12(decorators, target, key, desc) {
3868
4000
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3869
4001
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3870
4002
  }
3871
- __name(_ts_decorate12, "_ts_decorate");
3872
- function _ts_metadata12(k, v) {
4003
+ __name(_ts_decorate13, "_ts_decorate");
4004
+ function _ts_metadata13(k, v) {
3873
4005
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
3874
4006
  return Reflect.metadata(k, v);
3875
4007
  }
3876
- __name(_ts_metadata12, "_ts_metadata");
4008
+ __name(_ts_metadata13, "_ts_metadata");
3877
4009
  var ResponseStatusCode;
3878
4010
  (function(ResponseStatusCode2) {
3879
4011
  ResponseStatusCode2["Pending"] = "pending";
3880
4012
  ResponseStatusCode2["Success"] = "success";
3881
4013
  ResponseStatusCode2["Failed"] = "failed";
3882
4014
  })(ResponseStatusCode || (ResponseStatusCode = {}));
3883
- (0, import_type_graphql13.registerEnumType)(ResponseStatusCode, {
4015
+ (0, import_type_graphql14.registerEnumType)(ResponseStatusCode, {
3884
4016
  name: "ResponseStatusCode"
3885
4017
  });
3886
4018
  var BaseResponseStatus = /* @__PURE__ */ __name(class BaseResponseStatus2 {
3887
4019
  code;
3888
4020
  }, "BaseResponseStatus");
3889
- _ts_decorate12([
3890
- (0, import_type_graphql13.Field)(() => ResponseStatusCode),
3891
- _ts_metadata12("design:type", String)
4021
+ _ts_decorate13([
4022
+ (0, import_type_graphql14.Field)(() => ResponseStatusCode),
4023
+ _ts_metadata13("design:type", String)
3892
4024
  ], BaseResponseStatus.prototype, "code", void 0);
3893
- BaseResponseStatus = _ts_decorate12([
3894
- (0, import_type_graphql13.InterfaceType)({
4025
+ BaseResponseStatus = _ts_decorate13([
4026
+ (0, import_type_graphql14.InterfaceType)({
3895
4027
  resolveType(value) {
3896
4028
  if (value.code === "success") {
3897
4029
  return SuccessResponseStatus;
@@ -3903,14 +4035,14 @@ BaseResponseStatus = _ts_decorate12([
3903
4035
  return void 0;
3904
4036
  }
3905
4037
  }),
3906
- (0, import_type_graphql13.ObjectType)()
4038
+ (0, import_type_graphql14.ObjectType)()
3907
4039
  ], BaseResponseStatus);
3908
4040
  var PendingResponseStatus = class extends BaseResponseStatus {
3909
4041
  code = "pending";
3910
4042
  };
3911
4043
  __name(PendingResponseStatus, "PendingResponseStatus");
3912
- PendingResponseStatus = _ts_decorate12([
3913
- (0, import_type_graphql13.ObjectType)({
4044
+ PendingResponseStatus = _ts_decorate13([
4045
+ (0, import_type_graphql14.ObjectType)({
3914
4046
  implements: BaseResponseStatus
3915
4047
  })
3916
4048
  ], PendingResponseStatus);
@@ -3918,8 +4050,8 @@ var SuccessResponseStatus = class extends BaseResponseStatus {
3918
4050
  code = "success";
3919
4051
  };
3920
4052
  __name(SuccessResponseStatus, "SuccessResponseStatus");
3921
- SuccessResponseStatus = _ts_decorate12([
3922
- (0, import_type_graphql13.ObjectType)({
4053
+ SuccessResponseStatus = _ts_decorate13([
4054
+ (0, import_type_graphql14.ObjectType)({
3923
4055
  implements: BaseResponseStatus
3924
4056
  })
3925
4057
  ], SuccessResponseStatus);
@@ -3929,7 +4061,7 @@ var FailedResponseStatusReason;
3929
4061
  FailedResponseStatusReason2["MESSAGE_STREAM_INTERRUPTED"] = "MESSAGE_STREAM_INTERRUPTED";
3930
4062
  FailedResponseStatusReason2["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
3931
4063
  })(FailedResponseStatusReason || (FailedResponseStatusReason = {}));
3932
- (0, import_type_graphql13.registerEnumType)(FailedResponseStatusReason, {
4064
+ (0, import_type_graphql14.registerEnumType)(FailedResponseStatusReason, {
3933
4065
  name: "FailedResponseStatusReason"
3934
4066
  });
3935
4067
  var FailedResponseStatus = class extends BaseResponseStatus {
@@ -3938,22 +4070,22 @@ var FailedResponseStatus = class extends BaseResponseStatus {
3938
4070
  details = null;
3939
4071
  };
3940
4072
  __name(FailedResponseStatus, "FailedResponseStatus");
3941
- _ts_decorate12([
3942
- (0, import_type_graphql13.Field)(() => FailedResponseStatusReason),
3943
- _ts_metadata12("design:type", String)
4073
+ _ts_decorate13([
4074
+ (0, import_type_graphql14.Field)(() => FailedResponseStatusReason),
4075
+ _ts_metadata13("design:type", String)
3944
4076
  ], FailedResponseStatus.prototype, "reason", void 0);
3945
- _ts_decorate12([
3946
- (0, import_type_graphql13.Field)(() => import_graphql_scalars.GraphQLJSON, {
4077
+ _ts_decorate13([
4078
+ (0, import_type_graphql14.Field)(() => import_graphql_scalars.GraphQLJSON, {
3947
4079
  nullable: true
3948
4080
  }),
3949
- _ts_metadata12("design:type", typeof Record === "undefined" ? Object : Record)
4081
+ _ts_metadata13("design:type", typeof Record === "undefined" ? Object : Record)
3950
4082
  ], FailedResponseStatus.prototype, "details", void 0);
3951
- FailedResponseStatus = _ts_decorate12([
3952
- (0, import_type_graphql13.ObjectType)({
4083
+ FailedResponseStatus = _ts_decorate13([
4084
+ (0, import_type_graphql14.ObjectType)({
3953
4085
  implements: BaseResponseStatus
3954
4086
  })
3955
4087
  ], FailedResponseStatus);
3956
- var ResponseStatusUnion = (0, import_type_graphql13.createUnionType)({
4088
+ var ResponseStatusUnion = (0, import_type_graphql14.createUnionType)({
3957
4089
  name: "ResponseStatus",
3958
4090
  types: () => [
3959
4091
  PendingResponseStatus,
@@ -3962,8 +4094,60 @@ var ResponseStatusUnion = (0, import_type_graphql13.createUnionType)({
3962
4094
  ]
3963
4095
  });
3964
4096
 
4097
+ // src/graphql/types/extensions-response.type.ts
4098
+ var import_type_graphql15 = require("type-graphql");
4099
+ function _ts_decorate14(decorators, target, key, desc) {
4100
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4101
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4102
+ r = Reflect.decorate(decorators, target, key, desc);
4103
+ else
4104
+ for (var i = decorators.length - 1; i >= 0; i--)
4105
+ if (d = decorators[i])
4106
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4107
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
4108
+ }
4109
+ __name(_ts_decorate14, "_ts_decorate");
4110
+ function _ts_metadata14(k, v) {
4111
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
4112
+ return Reflect.metadata(k, v);
4113
+ }
4114
+ __name(_ts_metadata14, "_ts_metadata");
4115
+ var ExtensionsResponse = class {
4116
+ openaiAssistantAPI;
4117
+ };
4118
+ __name(ExtensionsResponse, "ExtensionsResponse");
4119
+ _ts_decorate14([
4120
+ (0, import_type_graphql15.Field)(() => OpenAIApiAssistantAPIResponse, {
4121
+ nullable: true
4122
+ }),
4123
+ _ts_metadata14("design:type", typeof OpenAIApiAssistantAPIResponse === "undefined" ? Object : OpenAIApiAssistantAPIResponse)
4124
+ ], ExtensionsResponse.prototype, "openaiAssistantAPI", void 0);
4125
+ ExtensionsResponse = _ts_decorate14([
4126
+ (0, import_type_graphql15.ObjectType)()
4127
+ ], ExtensionsResponse);
4128
+ var OpenAIApiAssistantAPIResponse = class {
4129
+ runId;
4130
+ threadId;
4131
+ };
4132
+ __name(OpenAIApiAssistantAPIResponse, "OpenAIApiAssistantAPIResponse");
4133
+ _ts_decorate14([
4134
+ (0, import_type_graphql15.Field)(() => String, {
4135
+ nullable: true
4136
+ }),
4137
+ _ts_metadata14("design:type", String)
4138
+ ], OpenAIApiAssistantAPIResponse.prototype, "runId", void 0);
4139
+ _ts_decorate14([
4140
+ (0, import_type_graphql15.Field)(() => String, {
4141
+ nullable: true
4142
+ }),
4143
+ _ts_metadata14("design:type", String)
4144
+ ], OpenAIApiAssistantAPIResponse.prototype, "threadId", void 0);
4145
+ OpenAIApiAssistantAPIResponse = _ts_decorate14([
4146
+ (0, import_type_graphql15.ObjectType)()
4147
+ ], OpenAIApiAssistantAPIResponse);
4148
+
3965
4149
  // src/graphql/types/copilot-response.type.ts
3966
- function _ts_decorate13(decorators, target, key, desc) {
4150
+ function _ts_decorate15(decorators, target, key, desc) {
3967
4151
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3968
4152
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3969
4153
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3973,31 +4157,32 @@ function _ts_decorate13(decorators, target, key, desc) {
3973
4157
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3974
4158
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3975
4159
  }
3976
- __name(_ts_decorate13, "_ts_decorate");
3977
- function _ts_metadata13(k, v) {
4160
+ __name(_ts_decorate15, "_ts_decorate");
4161
+ function _ts_metadata15(k, v) {
3978
4162
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
3979
4163
  return Reflect.metadata(k, v);
3980
4164
  }
3981
- __name(_ts_metadata13, "_ts_metadata");
3982
- var BaseMessageOutput = /* @__PURE__ */ __name(class BaseMessageOutput2 {
4165
+ __name(_ts_metadata15, "_ts_metadata");
4166
+ var BaseMessageOutput = class {
3983
4167
  id;
3984
4168
  createdAt;
3985
4169
  status;
3986
- }, "BaseMessageOutput");
3987
- _ts_decorate13([
3988
- (0, import_type_graphql14.Field)(() => String),
3989
- _ts_metadata13("design:type", String)
4170
+ };
4171
+ __name(BaseMessageOutput, "BaseMessageOutput");
4172
+ _ts_decorate15([
4173
+ (0, import_type_graphql16.Field)(() => String),
4174
+ _ts_metadata15("design:type", String)
3990
4175
  ], BaseMessageOutput.prototype, "id", void 0);
3991
- _ts_decorate13([
3992
- (0, import_type_graphql14.Field)(() => Date),
3993
- _ts_metadata13("design:type", typeof Date === "undefined" ? Object : Date)
4176
+ _ts_decorate15([
4177
+ (0, import_type_graphql16.Field)(() => Date),
4178
+ _ts_metadata15("design:type", typeof Date === "undefined" ? Object : Date)
3994
4179
  ], BaseMessageOutput.prototype, "createdAt", void 0);
3995
- _ts_decorate13([
3996
- (0, import_type_graphql14.Field)(() => MessageStatusUnion),
3997
- _ts_metadata13("design:type", Object)
4180
+ _ts_decorate15([
4181
+ (0, import_type_graphql16.Field)(() => MessageStatusUnion),
4182
+ _ts_metadata15("design:type", Object)
3998
4183
  ], BaseMessageOutput.prototype, "status", void 0);
3999
- BaseMessageOutput = _ts_decorate13([
4000
- (0, import_type_graphql14.InterfaceType)({
4184
+ BaseMessageOutput = _ts_decorate15([
4185
+ (0, import_type_graphql16.InterfaceType)({
4001
4186
  resolveType(value) {
4002
4187
  if (value.hasOwnProperty("content")) {
4003
4188
  return TextMessageOutput;
@@ -4018,24 +4203,24 @@ var TextMessageOutput = class {
4018
4203
  parentMessageId;
4019
4204
  };
4020
4205
  __name(TextMessageOutput, "TextMessageOutput");
4021
- _ts_decorate13([
4022
- (0, import_type_graphql14.Field)(() => MessageRole),
4023
- _ts_metadata13("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
4206
+ _ts_decorate15([
4207
+ (0, import_type_graphql16.Field)(() => MessageRole),
4208
+ _ts_metadata15("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
4024
4209
  ], TextMessageOutput.prototype, "role", void 0);
4025
- _ts_decorate13([
4026
- (0, import_type_graphql14.Field)(() => [
4210
+ _ts_decorate15([
4211
+ (0, import_type_graphql16.Field)(() => [
4027
4212
  String
4028
4213
  ]),
4029
- _ts_metadata13("design:type", Array)
4214
+ _ts_metadata15("design:type", Array)
4030
4215
  ], TextMessageOutput.prototype, "content", void 0);
4031
- _ts_decorate13([
4032
- (0, import_type_graphql14.Field)(() => String, {
4216
+ _ts_decorate15([
4217
+ (0, import_type_graphql16.Field)(() => String, {
4033
4218
  nullable: true
4034
4219
  }),
4035
- _ts_metadata13("design:type", String)
4220
+ _ts_metadata15("design:type", String)
4036
4221
  ], TextMessageOutput.prototype, "parentMessageId", void 0);
4037
- TextMessageOutput = _ts_decorate13([
4038
- (0, import_type_graphql14.ObjectType)({
4222
+ TextMessageOutput = _ts_decorate15([
4223
+ (0, import_type_graphql16.ObjectType)({
4039
4224
  implements: BaseMessageOutput
4040
4225
  })
4041
4226
  ], TextMessageOutput);
@@ -4046,31 +4231,31 @@ var ActionExecutionMessageOutput = class {
4046
4231
  parentMessageId;
4047
4232
  };
4048
4233
  __name(ActionExecutionMessageOutput, "ActionExecutionMessageOutput");
4049
- _ts_decorate13([
4050
- (0, import_type_graphql14.Field)(() => String),
4051
- _ts_metadata13("design:type", String)
4234
+ _ts_decorate15([
4235
+ (0, import_type_graphql16.Field)(() => String),
4236
+ _ts_metadata15("design:type", String)
4052
4237
  ], ActionExecutionMessageOutput.prototype, "name", void 0);
4053
- _ts_decorate13([
4054
- (0, import_type_graphql14.Field)(() => String, {
4238
+ _ts_decorate15([
4239
+ (0, import_type_graphql16.Field)(() => String, {
4055
4240
  nullable: true,
4056
4241
  deprecationReason: "This field will be removed in a future version"
4057
4242
  }),
4058
- _ts_metadata13("design:type", String)
4243
+ _ts_metadata15("design:type", String)
4059
4244
  ], ActionExecutionMessageOutput.prototype, "scope", void 0);
4060
- _ts_decorate13([
4061
- (0, import_type_graphql14.Field)(() => [
4245
+ _ts_decorate15([
4246
+ (0, import_type_graphql16.Field)(() => [
4062
4247
  String
4063
4248
  ]),
4064
- _ts_metadata13("design:type", Array)
4249
+ _ts_metadata15("design:type", Array)
4065
4250
  ], ActionExecutionMessageOutput.prototype, "arguments", void 0);
4066
- _ts_decorate13([
4067
- (0, import_type_graphql14.Field)(() => String, {
4251
+ _ts_decorate15([
4252
+ (0, import_type_graphql16.Field)(() => String, {
4068
4253
  nullable: true
4069
4254
  }),
4070
- _ts_metadata13("design:type", String)
4255
+ _ts_metadata15("design:type", String)
4071
4256
  ], ActionExecutionMessageOutput.prototype, "parentMessageId", void 0);
4072
- ActionExecutionMessageOutput = _ts_decorate13([
4073
- (0, import_type_graphql14.ObjectType)({
4257
+ ActionExecutionMessageOutput = _ts_decorate15([
4258
+ (0, import_type_graphql16.ObjectType)({
4074
4259
  implements: BaseMessageOutput
4075
4260
  })
4076
4261
  ], ActionExecutionMessageOutput);
@@ -4080,20 +4265,20 @@ var ResultMessageOutput = class {
4080
4265
  result;
4081
4266
  };
4082
4267
  __name(ResultMessageOutput, "ResultMessageOutput");
4083
- _ts_decorate13([
4084
- (0, import_type_graphql14.Field)(() => String),
4085
- _ts_metadata13("design:type", String)
4268
+ _ts_decorate15([
4269
+ (0, import_type_graphql16.Field)(() => String),
4270
+ _ts_metadata15("design:type", String)
4086
4271
  ], ResultMessageOutput.prototype, "actionExecutionId", void 0);
4087
- _ts_decorate13([
4088
- (0, import_type_graphql14.Field)(() => String),
4089
- _ts_metadata13("design:type", String)
4272
+ _ts_decorate15([
4273
+ (0, import_type_graphql16.Field)(() => String),
4274
+ _ts_metadata15("design:type", String)
4090
4275
  ], ResultMessageOutput.prototype, "actionName", void 0);
4091
- _ts_decorate13([
4092
- (0, import_type_graphql14.Field)(() => String),
4093
- _ts_metadata13("design:type", String)
4276
+ _ts_decorate15([
4277
+ (0, import_type_graphql16.Field)(() => String),
4278
+ _ts_metadata15("design:type", String)
4094
4279
  ], ResultMessageOutput.prototype, "result", void 0);
4095
- ResultMessageOutput = _ts_decorate13([
4096
- (0, import_type_graphql14.ObjectType)({
4280
+ ResultMessageOutput = _ts_decorate15([
4281
+ (0, import_type_graphql16.ObjectType)({
4097
4282
  implements: BaseMessageOutput
4098
4283
  })
4099
4284
  ], ResultMessageOutput);
@@ -4108,40 +4293,40 @@ var AgentStateMessageOutput = class {
4108
4293
  running;
4109
4294
  };
4110
4295
  __name(AgentStateMessageOutput, "AgentStateMessageOutput");
4111
- _ts_decorate13([
4112
- (0, import_type_graphql14.Field)(() => String),
4113
- _ts_metadata13("design:type", String)
4296
+ _ts_decorate15([
4297
+ (0, import_type_graphql16.Field)(() => String),
4298
+ _ts_metadata15("design:type", String)
4114
4299
  ], AgentStateMessageOutput.prototype, "threadId", void 0);
4115
- _ts_decorate13([
4116
- (0, import_type_graphql14.Field)(() => String),
4117
- _ts_metadata13("design:type", String)
4300
+ _ts_decorate15([
4301
+ (0, import_type_graphql16.Field)(() => String),
4302
+ _ts_metadata15("design:type", String)
4118
4303
  ], AgentStateMessageOutput.prototype, "agentName", void 0);
4119
- _ts_decorate13([
4120
- (0, import_type_graphql14.Field)(() => String),
4121
- _ts_metadata13("design:type", String)
4304
+ _ts_decorate15([
4305
+ (0, import_type_graphql16.Field)(() => String),
4306
+ _ts_metadata15("design:type", String)
4122
4307
  ], AgentStateMessageOutput.prototype, "nodeName", void 0);
4123
- _ts_decorate13([
4124
- (0, import_type_graphql14.Field)(() => String),
4125
- _ts_metadata13("design:type", String)
4308
+ _ts_decorate15([
4309
+ (0, import_type_graphql16.Field)(() => String),
4310
+ _ts_metadata15("design:type", String)
4126
4311
  ], AgentStateMessageOutput.prototype, "runId", void 0);
4127
- _ts_decorate13([
4128
- (0, import_type_graphql14.Field)(() => Boolean),
4129
- _ts_metadata13("design:type", Boolean)
4312
+ _ts_decorate15([
4313
+ (0, import_type_graphql16.Field)(() => Boolean),
4314
+ _ts_metadata15("design:type", Boolean)
4130
4315
  ], AgentStateMessageOutput.prototype, "active", void 0);
4131
- _ts_decorate13([
4132
- (0, import_type_graphql14.Field)(() => MessageRole),
4133
- _ts_metadata13("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
4316
+ _ts_decorate15([
4317
+ (0, import_type_graphql16.Field)(() => MessageRole),
4318
+ _ts_metadata15("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
4134
4319
  ], AgentStateMessageOutput.prototype, "role", void 0);
4135
- _ts_decorate13([
4136
- (0, import_type_graphql14.Field)(() => String),
4137
- _ts_metadata13("design:type", String)
4320
+ _ts_decorate15([
4321
+ (0, import_type_graphql16.Field)(() => String),
4322
+ _ts_metadata15("design:type", String)
4138
4323
  ], AgentStateMessageOutput.prototype, "state", void 0);
4139
- _ts_decorate13([
4140
- (0, import_type_graphql14.Field)(() => Boolean),
4141
- _ts_metadata13("design:type", Boolean)
4324
+ _ts_decorate15([
4325
+ (0, import_type_graphql16.Field)(() => Boolean),
4326
+ _ts_metadata15("design:type", Boolean)
4142
4327
  ], AgentStateMessageOutput.prototype, "running", void 0);
4143
- AgentStateMessageOutput = _ts_decorate13([
4144
- (0, import_type_graphql14.ObjectType)({
4328
+ AgentStateMessageOutput = _ts_decorate15([
4329
+ (0, import_type_graphql16.ObjectType)({
4145
4330
  implements: BaseMessageOutput
4146
4331
  })
4147
4332
  ], AgentStateMessageOutput);
@@ -4150,30 +4335,37 @@ var CopilotResponse = class {
4150
4335
  status;
4151
4336
  runId;
4152
4337
  messages;
4338
+ extensions;
4153
4339
  };
4154
4340
  __name(CopilotResponse, "CopilotResponse");
4155
- _ts_decorate13([
4156
- (0, import_type_graphql14.Field)(() => String),
4157
- _ts_metadata13("design:type", String)
4341
+ _ts_decorate15([
4342
+ (0, import_type_graphql16.Field)(() => String),
4343
+ _ts_metadata15("design:type", String)
4158
4344
  ], CopilotResponse.prototype, "threadId", void 0);
4159
- _ts_decorate13([
4160
- (0, import_type_graphql14.Field)(() => ResponseStatusUnion),
4161
- _ts_metadata13("design:type", Object)
4345
+ _ts_decorate15([
4346
+ (0, import_type_graphql16.Field)(() => ResponseStatusUnion),
4347
+ _ts_metadata15("design:type", Object)
4162
4348
  ], CopilotResponse.prototype, "status", void 0);
4163
- _ts_decorate13([
4164
- (0, import_type_graphql14.Field)({
4349
+ _ts_decorate15([
4350
+ (0, import_type_graphql16.Field)({
4165
4351
  nullable: true
4166
4352
  }),
4167
- _ts_metadata13("design:type", String)
4353
+ _ts_metadata15("design:type", String)
4168
4354
  ], CopilotResponse.prototype, "runId", void 0);
4169
- _ts_decorate13([
4170
- (0, import_type_graphql14.Field)(() => [
4355
+ _ts_decorate15([
4356
+ (0, import_type_graphql16.Field)(() => [
4171
4357
  BaseMessageOutput
4172
4358
  ]),
4173
- _ts_metadata13("design:type", Array)
4359
+ _ts_metadata15("design:type", Array)
4174
4360
  ], CopilotResponse.prototype, "messages", void 0);
4175
- CopilotResponse = _ts_decorate13([
4176
- (0, import_type_graphql14.ObjectType)()
4361
+ _ts_decorate15([
4362
+ (0, import_type_graphql16.Field)(() => ExtensionsResponse, {
4363
+ nullable: true
4364
+ }),
4365
+ _ts_metadata15("design:type", typeof ExtensionsResponse === "undefined" ? Object : ExtensionsResponse)
4366
+ ], CopilotResponse.prototype, "extensions", void 0);
4367
+ CopilotResponse = _ts_decorate15([
4368
+ (0, import_type_graphql16.ObjectType)()
4177
4369
  ], CopilotResponse);
4178
4370
 
4179
4371
  // src/graphql/resolvers/copilot.resolver.ts
@@ -4216,11 +4408,11 @@ var UnknownErrorResponse = class extends FailedResponseStatus {
4216
4408
  __name(UnknownErrorResponse, "UnknownErrorResponse");
4217
4409
 
4218
4410
  // src/graphql/resolvers/copilot.resolver.ts
4219
- var import_shared13 = require("@copilotkit/shared");
4411
+ var import_shared14 = require("@copilotkit/shared");
4220
4412
 
4221
4413
  // src/graphql/types/agents-response.type.ts
4222
- var import_type_graphql15 = require("type-graphql");
4223
- function _ts_decorate14(decorators, target, key, desc) {
4414
+ var import_type_graphql17 = require("type-graphql");
4415
+ function _ts_decorate16(decorators, target, key, desc) {
4224
4416
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4225
4417
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4226
4418
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4230,49 +4422,49 @@ function _ts_decorate14(decorators, target, key, desc) {
4230
4422
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4231
4423
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4232
4424
  }
4233
- __name(_ts_decorate14, "_ts_decorate");
4234
- function _ts_metadata14(k, v) {
4425
+ __name(_ts_decorate16, "_ts_decorate");
4426
+ function _ts_metadata16(k, v) {
4235
4427
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
4236
4428
  return Reflect.metadata(k, v);
4237
4429
  }
4238
- __name(_ts_metadata14, "_ts_metadata");
4430
+ __name(_ts_metadata16, "_ts_metadata");
4239
4431
  var Agent = class {
4240
4432
  id;
4241
4433
  name;
4242
4434
  description;
4243
4435
  };
4244
4436
  __name(Agent, "Agent");
4245
- _ts_decorate14([
4246
- (0, import_type_graphql15.Field)(() => String),
4247
- _ts_metadata14("design:type", String)
4437
+ _ts_decorate16([
4438
+ (0, import_type_graphql17.Field)(() => String),
4439
+ _ts_metadata16("design:type", String)
4248
4440
  ], Agent.prototype, "id", void 0);
4249
- _ts_decorate14([
4250
- (0, import_type_graphql15.Field)(() => String),
4251
- _ts_metadata14("design:type", String)
4441
+ _ts_decorate16([
4442
+ (0, import_type_graphql17.Field)(() => String),
4443
+ _ts_metadata16("design:type", String)
4252
4444
  ], Agent.prototype, "name", void 0);
4253
- _ts_decorate14([
4254
- (0, import_type_graphql15.Field)(() => String),
4255
- _ts_metadata14("design:type", String)
4445
+ _ts_decorate16([
4446
+ (0, import_type_graphql17.Field)(() => String),
4447
+ _ts_metadata16("design:type", String)
4256
4448
  ], Agent.prototype, "description", void 0);
4257
- Agent = _ts_decorate14([
4258
- (0, import_type_graphql15.ObjectType)()
4449
+ Agent = _ts_decorate16([
4450
+ (0, import_type_graphql17.ObjectType)()
4259
4451
  ], Agent);
4260
4452
  var AgentsResponse = class {
4261
4453
  agents;
4262
4454
  };
4263
4455
  __name(AgentsResponse, "AgentsResponse");
4264
- _ts_decorate14([
4265
- (0, import_type_graphql15.Field)(() => [
4456
+ _ts_decorate16([
4457
+ (0, import_type_graphql17.Field)(() => [
4266
4458
  Agent
4267
4459
  ]),
4268
- _ts_metadata14("design:type", Array)
4460
+ _ts_metadata16("design:type", Array)
4269
4461
  ], AgentsResponse.prototype, "agents", void 0);
4270
- AgentsResponse = _ts_decorate14([
4271
- (0, import_type_graphql15.ObjectType)()
4462
+ AgentsResponse = _ts_decorate16([
4463
+ (0, import_type_graphql17.ObjectType)()
4272
4464
  ], AgentsResponse);
4273
4465
 
4274
4466
  // src/graphql/resolvers/copilot.resolver.ts
4275
- function _ts_decorate15(decorators, target, key, desc) {
4467
+ function _ts_decorate17(decorators, target, key, desc) {
4276
4468
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4277
4469
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4278
4470
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4282,12 +4474,12 @@ function _ts_decorate15(decorators, target, key, desc) {
4282
4474
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4283
4475
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4284
4476
  }
4285
- __name(_ts_decorate15, "_ts_decorate");
4286
- function _ts_metadata15(k, v) {
4477
+ __name(_ts_decorate17, "_ts_decorate");
4478
+ function _ts_metadata17(k, v) {
4287
4479
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
4288
4480
  return Reflect.metadata(k, v);
4289
4481
  }
4290
- __name(_ts_metadata15, "_ts_metadata");
4482
+ __name(_ts_metadata17, "_ts_metadata");
4291
4483
  function _ts_param(paramIndex, decorator) {
4292
4484
  return function(target, key) {
4293
4485
  decorator(target, key, paramIndex);
@@ -4334,10 +4526,10 @@ var CopilotResolver = class {
4334
4526
  component: "CopilotResolver.availableAgents"
4335
4527
  });
4336
4528
  logger2.debug("Processing");
4337
- const agents = await ctx._copilotkit.runtime.discoverAgentsFromEndpoints(ctx);
4529
+ const agentsWithEndpoints = await ctx._copilotkit.runtime.discoverAgentsFromEndpoints(ctx);
4338
4530
  logger2.debug("Event source created, creating response");
4339
4531
  return {
4340
- agents
4532
+ agents: agentsWithEndpoints.map(({ endpoint, ...agentWithoutEndpoint }) => agentWithoutEndpoint)
4341
4533
  };
4342
4534
  }
4343
4535
  async generateCopilotResponse(ctx, data, properties) {
@@ -4399,7 +4591,7 @@ var CopilotResolver = class {
4399
4591
  rejectOutputMessagesPromise = reject;
4400
4592
  });
4401
4593
  logger2.debug("Processing");
4402
- const { eventSource, threadId = (0, import_shared13.randomId)(), runId, serverSideActions, actionInputsWithoutAgents } = await copilotRuntime.processRuntimeRequest({
4594
+ const { eventSource, threadId = (0, import_shared14.randomId)(), runId, serverSideActions, actionInputsWithoutAgents, extensions } = await copilotRuntime.processRuntimeRequest({
4403
4595
  serviceAdapter,
4404
4596
  messages: data.messages,
4405
4597
  actions: data.frontend.actions.filter((action) => action.available !== ActionInputAvailability.disabled),
@@ -4411,13 +4603,15 @@ var CopilotResolver = class {
4411
4603
  forwardedParameters: data.forwardedParameters,
4412
4604
  agentSession: data.agentSession,
4413
4605
  agentStates: data.agentStates,
4414
- url: data.frontend.url
4606
+ url: data.frontend.url,
4607
+ extensions: data.extensions
4415
4608
  });
4416
4609
  logger2.debug("Event source created, creating response");
4417
4610
  const response = {
4418
4611
  threadId,
4419
4612
  runId,
4420
4613
  status: (0, import_rxjs4.firstValueFrom)(responseStatus$),
4614
+ extensions,
4421
4615
  messages: new import_graphql_yoga.Repeater(async (pushMessage, stopStreamingMessages) => {
4422
4616
  var _a2, _b2;
4423
4617
  logger2.debug("Messages repeater created");
@@ -4444,7 +4638,7 @@ var CopilotResolver = class {
4444
4638
  });
4445
4639
  outputMessages = [
4446
4640
  (0, import_class_transformer3.plainToInstance)(TextMessage, {
4447
- id: (0, import_shared13.randomId)(),
4641
+ id: (0, import_shared14.randomId)(),
4448
4642
  createdAt: /* @__PURE__ */ new Date(),
4449
4643
  content: result.reason,
4450
4644
  role: MessageRole.assistant
@@ -4474,7 +4668,8 @@ var CopilotResolver = class {
4474
4668
  actionInputsWithoutAgents: actionInputsWithoutAgents.filter(
4475
4669
  // TODO-AGENTS: do not exclude ALL server side actions
4476
4670
  (action) => !serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)
4477
- )
4671
+ ),
4672
+ threadId
4478
4673
  }).pipe(
4479
4674
  // shareReplay() ensures that later subscribers will see the whole stream instead of
4480
4675
  // just the events that were emitted after the subscriber was added.
@@ -4635,7 +4830,7 @@ var CopilotResolver = class {
4635
4830
  event
4636
4831
  }, "Agent message event received");
4637
4832
  pushMessage({
4638
- id: (0, import_shared13.randomId)(),
4833
+ id: (0, import_shared14.randomId)(),
4639
4834
  status: new SuccessMessageStatus(),
4640
4835
  threadId: event.threadId,
4641
4836
  agentName: event.agentName,
@@ -4648,7 +4843,7 @@ var CopilotResolver = class {
4648
4843
  createdAt: /* @__PURE__ */ new Date()
4649
4844
  });
4650
4845
  outputMessages.push((0, import_class_transformer3.plainToInstance)(AgentStateMessage, {
4651
- id: (0, import_shared13.randomId)(),
4846
+ id: (0, import_shared14.randomId)(),
4652
4847
  threadId: event.threadId,
4653
4848
  agentName: event.agentName,
4654
4849
  nodeName: event.nodeName,
@@ -4692,38 +4887,38 @@ var CopilotResolver = class {
4692
4887
  }
4693
4888
  };
4694
4889
  __name(CopilotResolver, "CopilotResolver");
4695
- _ts_decorate15([
4696
- (0, import_type_graphql16.Query)(() => String),
4697
- _ts_metadata15("design:type", Function),
4698
- _ts_metadata15("design:paramtypes", []),
4699
- _ts_metadata15("design:returntype", Promise)
4890
+ _ts_decorate17([
4891
+ (0, import_type_graphql18.Query)(() => String),
4892
+ _ts_metadata17("design:type", Function),
4893
+ _ts_metadata17("design:paramtypes", []),
4894
+ _ts_metadata17("design:returntype", Promise)
4700
4895
  ], CopilotResolver.prototype, "hello", null);
4701
- _ts_decorate15([
4702
- (0, import_type_graphql16.Query)(() => AgentsResponse),
4703
- _ts_param(0, (0, import_type_graphql16.Ctx)()),
4704
- _ts_metadata15("design:type", Function),
4705
- _ts_metadata15("design:paramtypes", [
4896
+ _ts_decorate17([
4897
+ (0, import_type_graphql18.Query)(() => AgentsResponse),
4898
+ _ts_param(0, (0, import_type_graphql18.Ctx)()),
4899
+ _ts_metadata17("design:type", Function),
4900
+ _ts_metadata17("design:paramtypes", [
4706
4901
  typeof GraphQLContext === "undefined" ? Object : GraphQLContext
4707
4902
  ]),
4708
- _ts_metadata15("design:returntype", Promise)
4903
+ _ts_metadata17("design:returntype", Promise)
4709
4904
  ], CopilotResolver.prototype, "availableAgents", null);
4710
- _ts_decorate15([
4711
- (0, import_type_graphql16.Mutation)(() => CopilotResponse),
4712
- _ts_param(0, (0, import_type_graphql16.Ctx)()),
4713
- _ts_param(1, (0, import_type_graphql16.Arg)("data")),
4714
- _ts_param(2, (0, import_type_graphql16.Arg)("properties", () => import_graphql_scalars2.GraphQLJSONObject, {
4905
+ _ts_decorate17([
4906
+ (0, import_type_graphql18.Mutation)(() => CopilotResponse),
4907
+ _ts_param(0, (0, import_type_graphql18.Ctx)()),
4908
+ _ts_param(1, (0, import_type_graphql18.Arg)("data")),
4909
+ _ts_param(2, (0, import_type_graphql18.Arg)("properties", () => import_graphql_scalars2.GraphQLJSONObject, {
4715
4910
  nullable: true
4716
4911
  })),
4717
- _ts_metadata15("design:type", Function),
4718
- _ts_metadata15("design:paramtypes", [
4912
+ _ts_metadata17("design:type", Function),
4913
+ _ts_metadata17("design:paramtypes", [
4719
4914
  typeof GraphQLContext === "undefined" ? Object : GraphQLContext,
4720
4915
  typeof GenerateCopilotResponseInput === "undefined" ? Object : GenerateCopilotResponseInput,
4721
4916
  typeof CopilotRequestContextProperties === "undefined" ? Object : CopilotRequestContextProperties
4722
4917
  ]),
4723
- _ts_metadata15("design:returntype", Promise)
4918
+ _ts_metadata17("design:returntype", Promise)
4724
4919
  ], CopilotResolver.prototype, "generateCopilotResponse", null);
4725
- CopilotResolver = _ts_decorate15([
4726
- (0, import_type_graphql16.Resolver)(() => CopilotResponse)
4920
+ CopilotResolver = _ts_decorate17([
4921
+ (0, import_type_graphql18.Resolver)(() => CopilotResponse)
4727
4922
  ], CopilotResolver);
4728
4923
 
4729
4924
  // src/lib/integrations/shared.ts
@@ -4757,6 +4952,141 @@ function createLogger(options) {
4757
4952
  }
4758
4953
  __name(createLogger, "createLogger");
4759
4954
 
4955
+ // src/graphql/resolvers/state.resolver.ts
4956
+ var import_type_graphql21 = require("type-graphql");
4957
+ var import_type_graphql22 = require("type-graphql");
4958
+ var import_type_graphql23 = require("type-graphql");
4959
+
4960
+ // src/graphql/types/load-agent-state-response.type.ts
4961
+ var import_type_graphql19 = require("type-graphql");
4962
+ function _ts_decorate18(decorators, target, key, desc) {
4963
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4964
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4965
+ r = Reflect.decorate(decorators, target, key, desc);
4966
+ else
4967
+ for (var i = decorators.length - 1; i >= 0; i--)
4968
+ if (d = decorators[i])
4969
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4970
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
4971
+ }
4972
+ __name(_ts_decorate18, "_ts_decorate");
4973
+ function _ts_metadata18(k, v) {
4974
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
4975
+ return Reflect.metadata(k, v);
4976
+ }
4977
+ __name(_ts_metadata18, "_ts_metadata");
4978
+ var LoadAgentStateResponse = class {
4979
+ threadId;
4980
+ threadExists;
4981
+ state;
4982
+ messages;
4983
+ };
4984
+ __name(LoadAgentStateResponse, "LoadAgentStateResponse");
4985
+ _ts_decorate18([
4986
+ (0, import_type_graphql19.Field)(() => String),
4987
+ _ts_metadata18("design:type", String)
4988
+ ], LoadAgentStateResponse.prototype, "threadId", void 0);
4989
+ _ts_decorate18([
4990
+ (0, import_type_graphql19.Field)(() => Boolean),
4991
+ _ts_metadata18("design:type", Boolean)
4992
+ ], LoadAgentStateResponse.prototype, "threadExists", void 0);
4993
+ _ts_decorate18([
4994
+ (0, import_type_graphql19.Field)(() => String),
4995
+ _ts_metadata18("design:type", String)
4996
+ ], LoadAgentStateResponse.prototype, "state", void 0);
4997
+ _ts_decorate18([
4998
+ (0, import_type_graphql19.Field)(() => String),
4999
+ _ts_metadata18("design:type", String)
5000
+ ], LoadAgentStateResponse.prototype, "messages", void 0);
5001
+ LoadAgentStateResponse = _ts_decorate18([
5002
+ (0, import_type_graphql19.ObjectType)()
5003
+ ], LoadAgentStateResponse);
5004
+
5005
+ // src/graphql/inputs/load-agent-state.input.ts
5006
+ var import_type_graphql20 = require("type-graphql");
5007
+ function _ts_decorate19(decorators, target, key, desc) {
5008
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5009
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
5010
+ r = Reflect.decorate(decorators, target, key, desc);
5011
+ else
5012
+ for (var i = decorators.length - 1; i >= 0; i--)
5013
+ if (d = decorators[i])
5014
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5015
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
5016
+ }
5017
+ __name(_ts_decorate19, "_ts_decorate");
5018
+ function _ts_metadata19(k, v) {
5019
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
5020
+ return Reflect.metadata(k, v);
5021
+ }
5022
+ __name(_ts_metadata19, "_ts_metadata");
5023
+ var LoadAgentStateInput = class {
5024
+ threadId;
5025
+ agentName;
5026
+ };
5027
+ __name(LoadAgentStateInput, "LoadAgentStateInput");
5028
+ _ts_decorate19([
5029
+ (0, import_type_graphql20.Field)(() => String),
5030
+ _ts_metadata19("design:type", String)
5031
+ ], LoadAgentStateInput.prototype, "threadId", void 0);
5032
+ _ts_decorate19([
5033
+ (0, import_type_graphql20.Field)(() => String),
5034
+ _ts_metadata19("design:type", String)
5035
+ ], LoadAgentStateInput.prototype, "agentName", void 0);
5036
+ LoadAgentStateInput = _ts_decorate19([
5037
+ (0, import_type_graphql20.InputType)()
5038
+ ], LoadAgentStateInput);
5039
+
5040
+ // src/graphql/resolvers/state.resolver.ts
5041
+ function _ts_decorate20(decorators, target, key, desc) {
5042
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5043
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
5044
+ r = Reflect.decorate(decorators, target, key, desc);
5045
+ else
5046
+ for (var i = decorators.length - 1; i >= 0; i--)
5047
+ if (d = decorators[i])
5048
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5049
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
5050
+ }
5051
+ __name(_ts_decorate20, "_ts_decorate");
5052
+ function _ts_metadata20(k, v) {
5053
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
5054
+ return Reflect.metadata(k, v);
5055
+ }
5056
+ __name(_ts_metadata20, "_ts_metadata");
5057
+ function _ts_param2(paramIndex, decorator) {
5058
+ return function(target, key) {
5059
+ decorator(target, key, paramIndex);
5060
+ };
5061
+ }
5062
+ __name(_ts_param2, "_ts_param");
5063
+ var StateResolver = class {
5064
+ async loadAgentState(ctx, data) {
5065
+ const agents = await ctx._copilotkit.runtime.discoverAgentsFromEndpoints(ctx);
5066
+ const agent = agents.find((agent2) => agent2.name === data.agentName);
5067
+ if (!agent) {
5068
+ throw new Error("Agent not found");
5069
+ }
5070
+ const state = await ctx._copilotkit.runtime.loadAgentState(ctx, data.threadId, data.agentName);
5071
+ return state;
5072
+ }
5073
+ };
5074
+ __name(StateResolver, "StateResolver");
5075
+ _ts_decorate20([
5076
+ (0, import_type_graphql23.Query)(() => LoadAgentStateResponse),
5077
+ _ts_param2(0, (0, import_type_graphql22.Ctx)()),
5078
+ _ts_param2(1, (0, import_type_graphql21.Arg)("data")),
5079
+ _ts_metadata20("design:type", Function),
5080
+ _ts_metadata20("design:paramtypes", [
5081
+ typeof GraphQLContext === "undefined" ? Object : GraphQLContext,
5082
+ typeof LoadAgentStateInput === "undefined" ? Object : LoadAgentStateInput
5083
+ ]),
5084
+ _ts_metadata20("design:returntype", Promise)
5085
+ ], StateResolver.prototype, "loadAgentState", null);
5086
+ StateResolver = _ts_decorate20([
5087
+ (0, import_type_graphql21.Resolver)(() => LoadAgentStateResponse)
5088
+ ], StateResolver);
5089
+
4760
5090
  // src/lib/integrations/shared.ts
4761
5091
  var logger = createLogger();
4762
5092
  async function createContext(initialContext, copilotKitContext, contextLogger, properties = {}) {
@@ -4778,9 +5108,10 @@ async function createContext(initialContext, copilotKitContext, contextLogger, p
4778
5108
  __name(createContext, "createContext");
4779
5109
  function buildSchema(options = {}) {
4780
5110
  logger.debug("Building GraphQL schema...");
4781
- const schema = (0, import_type_graphql17.buildSchemaSync)({
5111
+ const schema = (0, import_type_graphql24.buildSchemaSync)({
4782
5112
  resolvers: [
4783
- CopilotResolver
5113
+ CopilotResolver,
5114
+ StateResolver
4784
5115
  ],
4785
5116
  emitSchemaFile: options.emitSchemaFile
4786
5117
  });