@copilotkit/runtime 1.8.5-next.3 → 1.8.5-next.5

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 (41) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/{chunk-TDPCQIMB.mjs → chunk-AIQJ5N22.mjs} +2 -2
  3. package/dist/{chunk-UOCZJTXN.mjs → chunk-FP7EJSMU.mjs} +2 -2
  4. package/dist/{chunk-2PVUPC44.mjs → chunk-GQEDXH53.mjs} +2 -2
  5. package/dist/{chunk-UTUGZIQI.mjs → chunk-Q4KJZACA.mjs} +146 -9
  6. package/dist/chunk-Q4KJZACA.mjs.map +1 -0
  7. package/dist/index.d.ts +2 -1
  8. package/dist/index.js +183 -46
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.mjs +4 -4
  11. package/dist/lib/index.d.ts +2 -1
  12. package/dist/lib/index.js +176 -39
  13. package/dist/lib/index.js.map +1 -1
  14. package/dist/lib/index.mjs +4 -4
  15. package/dist/lib/integrations/index.d.ts +3 -2
  16. package/dist/lib/integrations/index.js +15 -10
  17. package/dist/lib/integrations/index.js.map +1 -1
  18. package/dist/lib/integrations/index.mjs +4 -4
  19. package/dist/lib/integrations/nest/index.d.ts +2 -1
  20. package/dist/lib/integrations/nest/index.js +15 -10
  21. package/dist/lib/integrations/nest/index.js.map +1 -1
  22. package/dist/lib/integrations/nest/index.mjs +2 -2
  23. package/dist/lib/integrations/node-express/index.d.ts +2 -1
  24. package/dist/lib/integrations/node-express/index.js +15 -10
  25. package/dist/lib/integrations/node-express/index.js.map +1 -1
  26. package/dist/lib/integrations/node-express/index.mjs +2 -2
  27. package/dist/lib/integrations/node-http/index.d.ts +2 -1
  28. package/dist/lib/integrations/node-http/index.js +15 -10
  29. package/dist/lib/integrations/node-http/index.js.map +1 -1
  30. package/dist/lib/integrations/node-http/index.mjs +1 -1
  31. package/dist/{shared-86ec42e7.d.ts → shared-93687488.d.ts} +3 -0
  32. package/package.json +6 -2
  33. package/src/lib/runtime/agentwire-action.ts +123 -0
  34. package/src/lib/runtime/copilot-runtime.ts +9 -1
  35. package/src/lib/runtime/remote-action-constructors.ts +2 -7
  36. package/src/lib/runtime/remote-actions.ts +25 -1
  37. package/src/lib/runtime/remote-lg-action.ts +24 -2
  38. package/dist/chunk-UTUGZIQI.mjs.map +0 -1
  39. /package/dist/{chunk-TDPCQIMB.mjs.map → chunk-AIQJ5N22.mjs.map} +0 -0
  40. /package/dist/{chunk-UOCZJTXN.mjs.map → chunk-FP7EJSMU.mjs.map} +0 -0
  41. /package/dist/{chunk-2PVUPC44.mjs.map → chunk-GQEDXH53.mjs.map} +0 -0
package/dist/index.mjs CHANGED
@@ -3,13 +3,13 @@ import {
3
3
  config,
4
4
  copilotRuntimeNextJSAppRouterEndpoint,
5
5
  copilotRuntimeNextJSPagesRouterEndpoint
6
- } from "./chunk-UOCZJTXN.mjs";
6
+ } from "./chunk-FP7EJSMU.mjs";
7
7
  import {
8
8
  copilotRuntimeNestEndpoint
9
- } from "./chunk-TDPCQIMB.mjs";
9
+ } from "./chunk-AIQJ5N22.mjs";
10
10
  import {
11
11
  copilotRuntimeNodeExpressEndpoint
12
- } from "./chunk-2PVUPC44.mjs";
12
+ } from "./chunk-GQEDXH53.mjs";
13
13
  import {
14
14
  CopilotRuntime,
15
15
  addCustomHeaderPlugin,
@@ -24,7 +24,7 @@ import {
24
24
  getCommonConfig,
25
25
  langGraphPlatformEndpoint,
26
26
  resolveEndpointType
27
- } from "./chunk-UTUGZIQI.mjs";
27
+ } from "./chunk-Q4KJZACA.mjs";
28
28
  import {
29
29
  AnthropicAdapter,
30
30
  EmptyAdapter,
@@ -1,5 +1,5 @@
1
1
  export { G as GoogleGenerativeAIAdapter, f as GroqAdapter, e as GroqAdapterParams, L as LangChainAdapter, a as OpenAIAdapter, O as OpenAIAdapterParams, c as OpenAIAssistantAdapter, b as OpenAIAssistantAdapterParams, d as UnifyAdapter, U as UnifyAdapterParams } from '../groq-adapter-fb9aa3ab.js';
2
- export { e as CommonConfig, C as CopilotRequestContextProperties, k as CopilotRuntime, j as CopilotRuntimeConstructorParams, f as CopilotRuntimeLogger, i as CopilotRuntimeRequest, b as CreateCopilotRuntimeServerOptions, G as GraphQLContext, L as LogLevel, o as MCPClient, p as MCPEndpointConfig, M as MCPTool, a as addCustomHeaderPlugin, d as buildSchema, s as convertMCPToolsToActions, m as copilotKitEndpoint, c as createContext, h as createLogger, q as extractParametersFromSchema, l as flattenToolCallsNoDuplicates, g as getCommonConfig, n as langGraphPlatformEndpoint, r as resolveEndpointType } from '../shared-86ec42e7.js';
2
+ export { e as CommonConfig, C as CopilotRequestContextProperties, k as CopilotRuntime, j as CopilotRuntimeConstructorParams, f as CopilotRuntimeLogger, i as CopilotRuntimeRequest, b as CreateCopilotRuntimeServerOptions, G as GraphQLContext, L as LogLevel, o as MCPClient, p as MCPEndpointConfig, M as MCPTool, a as addCustomHeaderPlugin, d as buildSchema, s as convertMCPToolsToActions, m as copilotKitEndpoint, c as createContext, h as createLogger, q as extractParametersFromSchema, l as flattenToolCallsNoDuplicates, g as getCommonConfig, n as langGraphPlatformEndpoint, r as resolveEndpointType } from '../shared-93687488.js';
3
3
  export { CopilotRuntimeServerInstance, config, copilotRuntimeNextJSAppRouterEndpoint, copilotRuntimeNextJSPagesRouterEndpoint } from './integrations/index.js';
4
4
  export { copilotRuntimeNodeHttpEndpoint } from './integrations/node-http/index.js';
5
5
  export { copilotRuntimeNodeExpressEndpoint } from './integrations/node-express/index.js';
@@ -18,3 +18,4 @@ import 'graphql';
18
18
  import 'pino';
19
19
  import 'graphql-yoga';
20
20
  import './cloud/index.js';
21
+ import '@agentwire/client';
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.8.5-next.3",
47
+ version: "1.8.5-next.5",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -81,6 +81,10 @@ var require_package = __commonJS({
81
81
  "zod-to-json-schema": "^3.23.5"
82
82
  },
83
83
  dependencies: {
84
+ "@agentwire/client": "0.0.26",
85
+ "@agentwire/proto": "0.0.26",
86
+ "@agentwire/core": "0.0.26",
87
+ "@agentwire/encoder": "0.0.26",
84
88
  "@anthropic-ai/sdk": "^0.27.3",
85
89
  "@copilotkit/shared": "workspace:*",
86
90
  "@graphql-yoga/plugin-defer-stream": "^3.3.1",
@@ -2598,11 +2602,14 @@ GenerateCopilotResponseInput = _ts_decorate17([
2598
2602
  var import_graphql_yoga = require("graphql-yoga");
2599
2603
 
2600
2604
  // src/service-adapters/events.ts
2601
- var import_shared18 = require("@copilotkit/shared");
2605
+ var import_shared20 = require("@copilotkit/shared");
2602
2606
  var import_rxjs3 = require("rxjs");
2603
2607
 
2604
2608
  // src/lib/telemetry-client.ts
2605
- var import_shared17 = require("@copilotkit/shared");
2609
+ var import_shared19 = require("@copilotkit/shared");
2610
+
2611
+ // src/lib/runtime/remote-actions.ts
2612
+ var import_shared14 = require("@copilotkit/shared");
2606
2613
 
2607
2614
  // src/lib/runtime/remote-action-constructors.ts
2608
2615
  var import_node_crypto2 = require("crypto");
@@ -2891,6 +2898,23 @@ async function execute(args) {
2891
2898
  await streamEvents(controller, args);
2892
2899
  controller.close();
2893
2900
  } catch (err) {
2901
+ const cause = err == null ? void 0 : err.cause;
2902
+ const errorCode = (cause == null ? void 0 : cause.code) || (err == null ? void 0 : err.code);
2903
+ if (errorCode === "ECONNREFUSED") {
2904
+ throw new import_shared9.CopilotKitMisuseError({
2905
+ message: `
2906
+ The LangGraph client could not connect to the graph. Please further check previous logs, which includes further details.
2907
+
2908
+ See more: https://docs.copilotkit.ai/troubleshooting/common-issues`
2909
+ });
2910
+ } else {
2911
+ throw new import_shared9.CopilotKitMisuseError({
2912
+ message: `
2913
+ The LangGraph client threw unhandled error ${err}.
2914
+
2915
+ See more: https://docs.copilotkit.ai/troubleshooting/common-issues`
2916
+ });
2917
+ }
2894
2918
  }
2895
2919
  }
2896
2920
  });
@@ -3755,7 +3779,101 @@ function createHeaders(onBeforeRequest, graphqlContext) {
3755
3779
  __name(createHeaders, "createHeaders");
3756
3780
 
3757
3781
  // src/lib/runtime/remote-actions.ts
3782
+ var import_shared15 = require("@copilotkit/shared");
3783
+
3784
+ // src/lib/runtime/agentwire-action.ts
3758
3785
  var import_shared13 = require("@copilotkit/shared");
3786
+ function constructAgentWireRemoteAction({ logger: logger2, messages, agentStates, agent }) {
3787
+ const action = {
3788
+ name: agent.agentId,
3789
+ description: agent.description,
3790
+ parameters: [],
3791
+ handler: async (_args) => {
3792
+ },
3793
+ remoteAgentHandler: async ({ actionInputsWithoutAgents, threadId }) => {
3794
+ logger2.debug({
3795
+ actionName: agent.agentId
3796
+ }, "Executing remote agent");
3797
+ const agentWireMessages = convertMessagesToAgentWire(messages);
3798
+ agent.messages = agentWireMessages;
3799
+ agent.threadId = threadId;
3800
+ telemetry_client_default.capture("oss.runtime.remote_action_executed", {
3801
+ agentExecution: true,
3802
+ type: "self-hosted",
3803
+ agentsAmount: 1
3804
+ });
3805
+ let state = {};
3806
+ if (agentStates) {
3807
+ const jsonState = agentStates.find((state2) => state2.agentName === agent.agentId);
3808
+ if (jsonState) {
3809
+ state = (0, import_shared13.parseJson)(jsonState.state, {});
3810
+ }
3811
+ }
3812
+ agent.state = state;
3813
+ const tools = actionInputsWithoutAgents.map((input) => {
3814
+ return {
3815
+ name: input.name,
3816
+ description: input.description,
3817
+ parameters: JSON.parse(input.jsonSchema)
3818
+ };
3819
+ });
3820
+ return agent.legacy_to_be_removed_runAgentBridged({
3821
+ tools
3822
+ });
3823
+ }
3824
+ };
3825
+ return [
3826
+ action
3827
+ ];
3828
+ }
3829
+ __name(constructAgentWireRemoteAction, "constructAgentWireRemoteAction");
3830
+ function convertMessagesToAgentWire(messages) {
3831
+ const result = [];
3832
+ for (const message of messages) {
3833
+ if (message.isTextMessage()) {
3834
+ result.push({
3835
+ id: message.id,
3836
+ role: message.role,
3837
+ content: message.content
3838
+ });
3839
+ } else if (message.isActionExecutionMessage()) {
3840
+ const toolCall = {
3841
+ id: message.id,
3842
+ type: "function",
3843
+ function: {
3844
+ name: message.name,
3845
+ arguments: JSON.stringify(message.arguments)
3846
+ }
3847
+ };
3848
+ if (message.parentMessageId && result.some((m) => m.id === message.parentMessageId)) {
3849
+ const parentMessage = result.find((m) => m.id === message.parentMessageId);
3850
+ if (parentMessage.toolCalls === void 0) {
3851
+ parentMessage.toolCalls = [];
3852
+ }
3853
+ parentMessage.toolCalls.push(toolCall);
3854
+ } else {
3855
+ result.push({
3856
+ id: message.parentMessageId ?? message.id,
3857
+ role: "assistant",
3858
+ toolCalls: [
3859
+ toolCall
3860
+ ]
3861
+ });
3862
+ }
3863
+ } else if (message.isResultMessage()) {
3864
+ result.push({
3865
+ id: message.id,
3866
+ role: "tool",
3867
+ content: message.result,
3868
+ toolCallId: message.actionExecutionId
3869
+ });
3870
+ }
3871
+ }
3872
+ return result;
3873
+ }
3874
+ __name(convertMessagesToAgentWire, "convertMessagesToAgentWire");
3875
+
3876
+ // src/lib/runtime/remote-actions.ts
3759
3877
  var EndpointType;
3760
3878
  (function(EndpointType2) {
3761
3879
  EndpointType2["CopilotKit"] = "copilotKit";
@@ -3789,7 +3907,7 @@ async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: l
3789
3907
  status: response.status,
3790
3908
  body: await response.text()
3791
3909
  }, "Failed to fetch actions from url");
3792
- throw new import_shared13.ResolvedCopilotKitError({
3910
+ throw new import_shared15.ResolvedCopilotKitError({
3793
3911
  status: response.status,
3794
3912
  url: fetchUrl,
3795
3913
  isRemoteEndpoint: true
@@ -3801,17 +3919,17 @@ async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: l
3801
3919
  }, "Fetched actions from url");
3802
3920
  return json;
3803
3921
  } catch (error) {
3804
- if (error instanceof import_shared13.CopilotKitError) {
3922
+ if (error instanceof import_shared15.CopilotKitError) {
3805
3923
  throw error;
3806
3924
  }
3807
- throw new import_shared13.CopilotKitLowLevelError({
3925
+ throw new import_shared15.CopilotKitLowLevelError({
3808
3926
  error,
3809
3927
  url: fetchUrl
3810
3928
  });
3811
3929
  }
3812
3930
  }
3813
3931
  __name(fetchRemoteInfo, "fetchRemoteInfo");
3814
- async function setupRemoteActions({ remoteEndpointDefinitions, graphqlContext, messages, agentStates, frontendUrl }) {
3932
+ async function setupRemoteActions({ remoteEndpointDefinitions, graphqlContext, messages, agentStates, frontendUrl, agents }) {
3815
3933
  const logger2 = graphqlContext.logger.child({
3816
3934
  component: "remote-actions.fetchRemoteActions"
3817
3935
  });
@@ -3860,6 +3978,22 @@ async function setupRemoteActions({ remoteEndpointDefinitions, graphqlContext, m
3860
3978
  agentStates
3861
3979
  });
3862
3980
  }));
3981
+ for (const [key, agent] of Object.entries(agents)) {
3982
+ if (agent.agentId !== void 0 && agent.agentId !== key) {
3983
+ throw new import_shared15.CopilotKitError({
3984
+ message: `Agent ${key} has agentId ${agent.agentId} which does not match the key ${key}`,
3985
+ code: import_shared14.CopilotKitErrorCode.UNKNOWN
3986
+ });
3987
+ } else if (agent.agentId === void 0) {
3988
+ agent.agentId = key;
3989
+ }
3990
+ result.push(constructAgentWireRemoteAction({
3991
+ logger: logger2,
3992
+ messages,
3993
+ agentStates,
3994
+ agent
3995
+ }));
3996
+ }
3863
3997
  return result.flat();
3864
3998
  }
3865
3999
  __name(setupRemoteActions, "setupRemoteActions");
@@ -3868,7 +4002,7 @@ __name(setupRemoteActions, "setupRemoteActions");
3868
4002
  var import_node_crypto3 = require("crypto");
3869
4003
 
3870
4004
  // src/lib/runtime/copilot-runtime.ts
3871
- var import_shared16 = require("@copilotkit/shared");
4005
+ var import_shared18 = require("@copilotkit/shared");
3872
4006
 
3873
4007
  // src/service-adapters/langchain/langserve.ts
3874
4008
  var import_remote = require("langchain/runnables/remote");
@@ -3949,11 +4083,11 @@ var RemoteChain = class {
3949
4083
  __name(RemoteChain, "RemoteChain");
3950
4084
 
3951
4085
  // src/service-adapters/empty/empty-adapter.ts
3952
- var import_shared14 = require("@copilotkit/shared");
4086
+ var import_shared16 = require("@copilotkit/shared");
3953
4087
  var EmptyAdapter = class {
3954
4088
  async process(request) {
3955
4089
  return {
3956
- threadId: request.threadId || (0, import_shared14.randomUUID)()
4090
+ threadId: request.threadId || (0, import_shared16.randomUUID)()
3957
4091
  };
3958
4092
  }
3959
4093
  };
@@ -4075,9 +4209,9 @@ __name(AgentStateMessage, "AgentStateMessage");
4075
4209
 
4076
4210
  // src/service-adapters/conversion.ts
4077
4211
  var import_class_transformer = require("class-transformer");
4078
- var import_shared15 = require("@copilotkit/shared");
4212
+ var import_shared17 = require("@copilotkit/shared");
4079
4213
  function convertGqlInputToMessages(inputMessages) {
4080
- const messages = (0, import_shared15.tryMap)(inputMessages, (message) => {
4214
+ const messages = (0, import_shared17.tryMap)(inputMessages, (message) => {
4081
4215
  if (message.textMessage) {
4082
4216
  return (0, import_class_transformer.plainToInstance)(TextMessage, {
4083
4217
  id: message.id,
@@ -4184,6 +4318,7 @@ __name(convertMCPToolsToActions, "convertMCPToolsToActions");
4184
4318
  // src/lib/runtime/copilot-runtime.ts
4185
4319
  var CopilotRuntime = class {
4186
4320
  actions;
4321
+ agents;
4187
4322
  remoteEndpointDefinitions;
4188
4323
  langserve = [];
4189
4324
  onBeforeRequest;
@@ -4214,10 +4349,11 @@ var CopilotRuntime = class {
4214
4349
  this.onAfterRequest = (_b = params == null ? void 0 : params.middleware) == null ? void 0 : _b.onAfterRequest;
4215
4350
  this.delegateAgentProcessingToServiceAdapter = (params == null ? void 0 : params.delegateAgentProcessingToServiceAdapter) || false;
4216
4351
  this.observability = params == null ? void 0 : params.observability_c;
4352
+ this.agents = (params == null ? void 0 : params.agents) ?? {};
4217
4353
  this.mcpEndpointsConfig = params == null ? void 0 : params.mcpEndpoints;
4218
4354
  this.createMCPClientImpl = params == null ? void 0 : params.createMCPClient;
4219
4355
  if (this.mcpEndpointsConfig && this.mcpEndpointsConfig.length > 0 && !this.createMCPClientImpl) {
4220
- throw new import_shared16.CopilotKitMisuseError({
4356
+ throw new import_shared18.CopilotKitMisuseError({
4221
4357
  message: "MCP Integration Error: `mcpEndpoints` were provided, but the `createMCPClient` function was not passed to the CopilotRuntime constructor. Please provide an implementation for `createMCPClient`."
4222
4358
  });
4223
4359
  }
@@ -4253,7 +4389,7 @@ var CopilotRuntime = class {
4253
4389
  }
4254
4390
  } else {
4255
4391
  newMessages.unshift({
4256
- id: (0, import_shared16.randomId)(),
4392
+ id: (0, import_shared18.randomId)(),
4257
4393
  createdAt: /* @__PURE__ */ new Date(),
4258
4394
  textMessage: {
4259
4395
  role: MessageRole.system,
@@ -4278,7 +4414,7 @@ var CopilotRuntime = class {
4278
4414
  return await this.processAgentRequest(request);
4279
4415
  }
4280
4416
  if (serviceAdapter instanceof EmptyAdapter) {
4281
- throw new import_shared16.CopilotKitMisuseError({
4417
+ throw new import_shared18.CopilotKitMisuseError({
4282
4418
  message: `Invalid adapter configuration: EmptyAdapter is only meant to be used with agent lock mode.
4283
4419
  For non-agent components like useCopilotChatSuggestions, CopilotTextarea, or CopilotTask,
4284
4420
  please use an LLM adapter instead.`
@@ -4308,7 +4444,7 @@ please use an LLM adapter instead.`
4308
4444
  const serverSideActionsInput = serverSideActions.map((action) => ({
4309
4445
  name: action.name,
4310
4446
  description: action.description,
4311
- jsonSchema: JSON.stringify((0, import_shared16.actionParametersToJsonSchema)(action.parameters))
4447
+ jsonSchema: JSON.stringify((0, import_shared18.actionParametersToJsonSchema)(action.parameters))
4312
4448
  }));
4313
4449
  const actionInputs = flattenToolCallsNoDuplicates([
4314
4450
  ...serverSideActionsInput,
@@ -4437,7 +4573,7 @@ please use an LLM adapter instead.`
4437
4573
  console.error("Error logging LLM error:", logError);
4438
4574
  }
4439
4575
  }
4440
- if (error instanceof import_shared16.CopilotKitError) {
4576
+ if (error instanceof import_shared18.CopilotKitError) {
4441
4577
  throw error;
4442
4578
  }
4443
4579
  console.error("Error getting response:", error);
@@ -4463,12 +4599,12 @@ please use an LLM adapter instead.`
4463
4599
  try {
4464
4600
  data = await client.assistants.search();
4465
4601
  if (data && "detail" in data && data.detail.toLowerCase() === "not found") {
4466
- throw new import_shared16.CopilotKitAgentDiscoveryError({
4602
+ throw new import_shared18.CopilotKitAgentDiscoveryError({
4467
4603
  availableAgents: this.availableAgents
4468
4604
  });
4469
4605
  }
4470
4606
  } catch (e) {
4471
- throw new import_shared16.CopilotKitMisuseError({
4607
+ throw new import_shared18.CopilotKitMisuseError({
4472
4608
  message: `
4473
4609
  Failed to find or contact remote endpoint at url ${endpoint.deploymentUrl}.
4474
4610
  Make sure the API is running and that it's indeed a LangGraph platform url.
@@ -4499,11 +4635,11 @@ please use an LLM adapter instead.`
4499
4635
  });
4500
4636
  if (!response.ok) {
4501
4637
  if (response.status === 404) {
4502
- throw new import_shared16.CopilotKitApiDiscoveryError({
4638
+ throw new import_shared18.CopilotKitApiDiscoveryError({
4503
4639
  url: fetchUrl
4504
4640
  });
4505
4641
  }
4506
- throw new import_shared16.ResolvedCopilotKitError({
4642
+ throw new import_shared18.ResolvedCopilotKitError({
4507
4643
  status: response.status,
4508
4644
  url: fetchUrl,
4509
4645
  isRemoteEndpoint: true
@@ -4513,7 +4649,7 @@ please use an LLM adapter instead.`
4513
4649
  const endpointAgents = ((data == null ? void 0 : data.agents) ?? []).map((agent) => ({
4514
4650
  name: agent.name,
4515
4651
  description: agent.description ?? "" ?? "",
4516
- id: (0, import_shared16.randomId)(),
4652
+ id: (0, import_shared18.randomId)(),
4517
4653
  endpoint
4518
4654
  }));
4519
4655
  return [
@@ -4521,10 +4657,10 @@ please use an LLM adapter instead.`
4521
4657
  ...endpointAgents
4522
4658
  ];
4523
4659
  } catch (error) {
4524
- if (error instanceof import_shared16.CopilotKitError) {
4660
+ if (error instanceof import_shared18.CopilotKitError) {
4525
4661
  throw error;
4526
4662
  }
4527
- throw new import_shared16.CopilotKitLowLevelError({
4663
+ throw new import_shared18.CopilotKitLowLevelError({
4528
4664
  error,
4529
4665
  url: fetchUrl
4530
4666
  });
@@ -4590,11 +4726,11 @@ please use an LLM adapter instead.`
4590
4726
  });
4591
4727
  if (!response.ok) {
4592
4728
  if (response.status === 404) {
4593
- throw new import_shared16.CopilotKitApiDiscoveryError({
4729
+ throw new import_shared18.CopilotKitApiDiscoveryError({
4594
4730
  url: fetchUrl
4595
4731
  });
4596
4732
  }
4597
- throw new import_shared16.ResolvedCopilotKitError({
4733
+ throw new import_shared18.ResolvedCopilotKitError({
4598
4734
  status: response.status,
4599
4735
  url: fetchUrl,
4600
4736
  isRemoteEndpoint: true
@@ -4607,10 +4743,10 @@ please use an LLM adapter instead.`
4607
4743
  messages: JSON.stringify(data.messages)
4608
4744
  };
4609
4745
  } catch (error) {
4610
- if (error instanceof import_shared16.CopilotKitError) {
4746
+ if (error instanceof import_shared18.CopilotKitError) {
4611
4747
  throw error;
4612
4748
  }
4613
- throw new import_shared16.CopilotKitLowLevelError({
4749
+ throw new import_shared18.CopilotKitLowLevelError({
4614
4750
  error,
4615
4751
  url: fetchUrl
4616
4752
  });
@@ -4630,7 +4766,7 @@ please use an LLM adapter instead.`
4630
4766
  const messages = convertGqlInputToMessages(rawMessages);
4631
4767
  const currentAgent = serverSideActions.find((action) => action.name === agentName && isRemoteAgentAction(action));
4632
4768
  if (!currentAgent) {
4633
- throw new import_shared16.CopilotKitAgentDiscoveryError({
4769
+ throw new import_shared18.CopilotKitAgentDiscoveryError({
4634
4770
  agentName,
4635
4771
  availableAgents: this.availableAgents
4636
4772
  });
@@ -4642,7 +4778,7 @@ please use an LLM adapter instead.`
4642
4778
  )).map((action) => ({
4643
4779
  name: action.name,
4644
4780
  description: action.description,
4645
- jsonSchema: JSON.stringify((0, import_shared16.actionParametersToJsonSchema)(action.parameters))
4781
+ jsonSchema: JSON.stringify((0, import_shared18.actionParametersToJsonSchema)(action.parameters))
4646
4782
  }));
4647
4783
  const allAvailableActions = flattenToolCallsNoDuplicates([
4648
4784
  ...availableActionsForCurrentAgent,
@@ -4835,7 +4971,8 @@ please use an LLM adapter instead.`
4835
4971
  graphqlContext,
4836
4972
  messages: inputMessages,
4837
4973
  agentStates,
4838
- frontendUrl: url
4974
+ frontendUrl: url,
4975
+ agents: this.agents
4839
4976
  });
4840
4977
  const configuredActions = typeof this.actions === "function" ? this.actions({
4841
4978
  properties: graphqlContext.properties,
@@ -4940,7 +5077,7 @@ __name(resolveEndpointType, "resolveEndpointType");
4940
5077
 
4941
5078
  // src/lib/telemetry-client.ts
4942
5079
  var packageJson = require_package();
4943
- var telemetryClient = new import_shared17.TelemetryClient({
5080
+ var telemetryClient = new import_shared19.TelemetryClient({
4944
5081
  packageName: packageJson.name,
4945
5082
  packageVersion: packageJson.version
4946
5083
  });
@@ -5108,10 +5245,10 @@ var RuntimeEventSource = class {
5108
5245
  const errorMessage = `\u274C ${message}`;
5109
5246
  if (!this.callback) {
5110
5247
  this.stream(async (eventStream$) => {
5111
- eventStream$.sendTextMessage((0, import_shared18.randomId)(), errorMessage);
5248
+ eventStream$.sendTextMessage((0, import_shared20.randomId)(), errorMessage);
5112
5249
  });
5113
5250
  } else {
5114
- this.eventStream$.sendTextMessage((0, import_shared18.randomId)(), errorMessage);
5251
+ this.eventStream$.sendTextMessage((0, import_shared20.randomId)(), errorMessage);
5115
5252
  }
5116
5253
  }
5117
5254
  processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents, threadId }) {
@@ -5307,7 +5444,7 @@ var UnknownErrorResponse = class extends FailedResponseStatus {
5307
5444
  __name(UnknownErrorResponse, "UnknownErrorResponse");
5308
5445
 
5309
5446
  // src/graphql/resolvers/copilot.resolver.ts
5310
- var import_shared19 = require("@copilotkit/shared");
5447
+ var import_shared21 = require("@copilotkit/shared");
5311
5448
 
5312
5449
  // src/graphql/types/agents-response.type.ts
5313
5450
  var import_type_graphql19 = require("type-graphql");
@@ -5493,7 +5630,7 @@ var CopilotResolver = class {
5493
5630
  ctx.properties["copilotCloudPublicApiKey"] = copilotCloudPublicApiKey;
5494
5631
  }
5495
5632
  logger2.debug("Processing");
5496
- const { eventSource, threadId = (0, import_shared19.randomId)(), runId, serverSideActions, actionInputsWithoutAgents, extensions } = await copilotRuntime.processRuntimeRequest({
5633
+ const { eventSource, threadId = (0, import_shared21.randomId)(), runId, serverSideActions, actionInputsWithoutAgents, extensions } = await copilotRuntime.processRuntimeRequest({
5497
5634
  serviceAdapter,
5498
5635
  messages: data.messages,
5499
5636
  actions: data.frontend.actions.filter((action) => action.available !== ActionInputAvailability.disabled),
@@ -5626,7 +5763,7 @@ var CopilotResolver = class {
5626
5763
  });
5627
5764
  outputMessages = [
5628
5765
  (0, import_class_transformer3.plainToInstance)(TextMessage, {
5629
- id: (0, import_shared19.randomId)(),
5766
+ id: (0, import_shared21.randomId)(),
5630
5767
  createdAt: /* @__PURE__ */ new Date(),
5631
5768
  content: result.reason,
5632
5769
  role: MessageRole.assistant
@@ -5804,7 +5941,7 @@ var CopilotResolver = class {
5804
5941
  event
5805
5942
  }, "Agent message event received");
5806
5943
  pushMessage({
5807
- id: (0, import_shared19.randomId)(),
5944
+ id: (0, import_shared21.randomId)(),
5808
5945
  status: new SuccessMessageStatus(),
5809
5946
  threadId: event.threadId,
5810
5947
  agentName: event.agentName,
@@ -5817,7 +5954,7 @@ var CopilotResolver = class {
5817
5954
  createdAt: /* @__PURE__ */ new Date()
5818
5955
  });
5819
5956
  outputMessages.push((0, import_class_transformer3.plainToInstance)(AgentStateMessage, {
5820
- id: (0, import_shared19.randomId)(),
5957
+ id: (0, import_shared21.randomId)(),
5821
5958
  threadId: event.threadId,
5822
5959
  agentName: event.agentName,
5823
5960
  nodeName: event.nodeName,