@copilotkit/runtime 1.8.7 → 1.8.8-next.1

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 (38) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/{chunk-TOZ7TDZQ.mjs → chunk-3UU33HF6.mjs} +2 -2
  3. package/dist/{chunk-D453SZIW.mjs → chunk-HBCCZQBE.mjs} +29 -19
  4. package/dist/chunk-HBCCZQBE.mjs.map +1 -0
  5. package/dist/{chunk-ZD6BIBVB.mjs → chunk-O4WMMGSX.mjs} +2 -2
  6. package/dist/{chunk-S2W2IABM.mjs → chunk-QF6GPOZV.mjs} +2 -2
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.js +28 -18
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.mjs +4 -4
  11. package/dist/lib/index.d.ts +1 -1
  12. package/dist/lib/index.js +28 -18
  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 +2 -2
  16. package/dist/lib/integrations/index.js +1 -1
  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 +1 -1
  20. package/dist/lib/integrations/nest/index.js +1 -1
  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 +1 -1
  24. package/dist/lib/integrations/node-express/index.js +1 -1
  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 +1 -1
  28. package/dist/lib/integrations/node-http/index.js +1 -1
  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-350db43f.d.ts → shared-32a46e93.d.ts} +7 -6
  32. package/package.json +2 -2
  33. package/src/lib/runtime/copilot-runtime.ts +34 -24
  34. package/src/lib/runtime/mcp-tools-utils.ts +16 -5
  35. package/dist/chunk-D453SZIW.mjs.map +0 -1
  36. /package/dist/{chunk-TOZ7TDZQ.mjs.map → chunk-3UU33HF6.mjs.map} +0 -0
  37. /package/dist/{chunk-ZD6BIBVB.mjs.map → chunk-O4WMMGSX.mjs.map} +0 -0
  38. /package/dist/{chunk-S2W2IABM.mjs.map → chunk-QF6GPOZV.mjs.map} +0 -0
@@ -2,7 +2,7 @@ import {
2
2
  copilotRuntimeNodeHttpEndpoint,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-D453SZIW.mjs";
5
+ } from "./chunk-HBCCZQBE.mjs";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-FHD4JECV.mjs";
@@ -22,4 +22,4 @@ __name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
22
22
  export {
23
23
  copilotRuntimeNestEndpoint
24
24
  };
25
- //# sourceMappingURL=chunk-ZD6BIBVB.mjs.map
25
+ //# sourceMappingURL=chunk-O4WMMGSX.mjs.map
@@ -2,7 +2,7 @@ import {
2
2
  getCommonConfig,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-D453SZIW.mjs";
5
+ } from "./chunk-HBCCZQBE.mjs";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-FHD4JECV.mjs";
@@ -77,4 +77,4 @@ export {
77
77
  config,
78
78
  copilotRuntimeNextJSPagesRouterEndpoint
79
79
  };
80
- //# sourceMappingURL=chunk-S2W2IABM.mjs.map
80
+ //# sourceMappingURL=chunk-QF6GPOZV.mjs.map
package/dist/index.d.ts CHANGED
@@ -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-53d3fa48.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-350db43f.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-32a46e93.js';
3
3
  export { CopilotRuntimeServerInstance, config, copilotRuntimeNextJSAppRouterEndpoint, copilotRuntimeNextJSPagesRouterEndpoint } from './lib/integrations/index.js';
4
4
  export { copilotRuntimeNodeHttpEndpoint } from './lib/integrations/node-http/index.js';
5
5
  export { copilotRuntimeNodeExpressEndpoint } from './lib/integrations/node-express/index.js';
package/dist/index.js CHANGED
@@ -44,7 +44,7 @@ var require_package = __commonJS({
44
44
  publishConfig: {
45
45
  access: "public"
46
46
  },
47
- version: "1.8.7",
47
+ version: "1.8.8-next.1",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -4744,11 +4744,13 @@ var import_rxjs2 = require("rxjs");
4744
4744
  var import_langgraph_sdk2 = require("@langchain/langgraph-sdk");
4745
4745
 
4746
4746
  // src/lib/runtime/mcp-tools-utils.ts
4747
- function extractParametersFromSchema(toolSchema) {
4748
- var _a, _b;
4747
+ function extractParametersFromSchema(toolOrSchema) {
4748
+ var _a;
4749
4749
  const parameters = [];
4750
- const properties = (_a = toolSchema == null ? void 0 : toolSchema.parameters) == null ? void 0 : _a.properties;
4751
- const requiredParams = new Set(((_b = toolSchema == null ? void 0 : toolSchema.parameters) == null ? void 0 : _b.required) || []);
4750
+ const schema = "schema" in (toolOrSchema || {}) ? toolOrSchema.schema : toolOrSchema;
4751
+ const toolParameters = (schema == null ? void 0 : schema.parameters) || ((_a = schema == null ? void 0 : schema.parameters) == null ? void 0 : _a.jsonSchema);
4752
+ const properties = toolParameters == null ? void 0 : toolParameters.properties;
4753
+ const requiredParams = new Set((toolParameters == null ? void 0 : toolParameters.required) || []);
4752
4754
  if (!properties) {
4753
4755
  return parameters;
4754
4756
  }
@@ -4771,7 +4773,7 @@ __name(extractParametersFromSchema, "extractParametersFromSchema");
4771
4773
  function convertMCPToolsToActions(mcpTools, mcpEndpoint) {
4772
4774
  const actions = [];
4773
4775
  for (const [toolName, tool] of Object.entries(mcpTools)) {
4774
- const parameters = extractParametersFromSchema(tool.schema);
4776
+ const parameters = extractParametersFromSchema(tool);
4775
4777
  const handler = /* @__PURE__ */ __name(async (params) => {
4776
4778
  try {
4777
4779
  const result = await tool.execute({
@@ -4809,7 +4811,7 @@ var CopilotRuntime = class {
4809
4811
  observability;
4810
4812
  availableAgents;
4811
4813
  // +++ MCP Properties +++
4812
- mcpEndpointsConfig;
4814
+ mcpServersConfig;
4813
4815
  mcpActionCache = /* @__PURE__ */ new Map();
4814
4816
  // --- MCP Properties ---
4815
4817
  // +++ MCP Client Factory +++
@@ -4832,14 +4834,14 @@ var CopilotRuntime = class {
4832
4834
  this.delegateAgentProcessingToServiceAdapter = (params == null ? void 0 : params.delegateAgentProcessingToServiceAdapter) || false;
4833
4835
  this.observability = params == null ? void 0 : params.observability_c;
4834
4836
  this.agents = (params == null ? void 0 : params.agents) ?? {};
4835
- this.mcpEndpointsConfig = params == null ? void 0 : params.mcpEndpoints;
4837
+ this.mcpServersConfig = params == null ? void 0 : params.mcpServers;
4836
4838
  this.createMCPClientImpl = params == null ? void 0 : params.createMCPClient;
4837
- if (this.mcpEndpointsConfig && this.mcpEndpointsConfig.length > 0 && !this.createMCPClientImpl) {
4839
+ if (this.mcpServersConfig && this.mcpServersConfig.length > 0 && !this.createMCPClientImpl) {
4838
4840
  throw new import_shared20.CopilotKitMisuseError({
4839
- message: "MCP Integration Error: `mcpEndpoints` were provided, but the `createMCPClient` function was not passed to the CopilotRuntime constructor. Please provide an implementation for `createMCPClient`."
4841
+ message: "MCP Integration Error: `mcpServers` were provided, but the `createMCPClient` function was not passed to the CopilotRuntime constructor. Please provide an implementation for `createMCPClient`."
4840
4842
  });
4841
4843
  }
4842
- if ((params == null ? void 0 : params.actions) && (((_c = params == null ? void 0 : params.remoteEndpoints) == null ? void 0 : _c.some((e) => e.type === EndpointType.LangGraphPlatform)) || ((_d = this.mcpEndpointsConfig) == null ? void 0 : _d.length))) {
4844
+ if ((params == null ? void 0 : params.actions) && (((_c = params == null ? void 0 : params.remoteEndpoints) == null ? void 0 : _c.some((e) => e.type === EndpointType.LangGraphPlatform)) || ((_d = this.mcpServersConfig) == null ? void 0 : _d.length))) {
4843
4845
  console.warn("Local 'actions' defined in CopilotRuntime might not be available to remote agents (LangGraph, MCP). Consider defining actions closer to the agent implementation if needed.");
4844
4846
  }
4845
4847
  }
@@ -4849,7 +4851,11 @@ var CopilotRuntime = class {
4849
4851
  if (!mcpActionsForRequest || mcpActionsForRequest.length === 0) {
4850
4852
  return messages;
4851
4853
  }
4852
- const mcpToolInstructions = mcpActionsForRequest.map((action) => {
4854
+ const uniqueMcpTools = /* @__PURE__ */ new Map();
4855
+ mcpActionsForRequest.forEach((action) => {
4856
+ uniqueMcpTools.set(action.name, action);
4857
+ });
4858
+ const mcpToolInstructions = Array.from(uniqueMcpTools.values()).map((action) => {
4853
4859
  const paramsString = action.parameters && action.parameters.length > 0 ? ` Parameters: ${action.parameters.map((p) => `${p.name}${p.required ? "*" : ""}(${p.type})`).join(", ")}` : "";
4854
4860
  return `- ${action.name}:${paramsString} ${action.description || ""}`;
4855
4861
  }).join("\n");
@@ -5432,7 +5438,7 @@ please use an LLM adapter instead.`
5432
5438
  }
5433
5439
  }
5434
5440
  async getServerSideActions(request) {
5435
- var _a;
5441
+ var _a, _b;
5436
5442
  const { graphqlContext, messages: rawMessages, agentStates, url } = request;
5437
5443
  const inputMessages = convertGqlInputToMessages(rawMessages);
5438
5444
  const langserveFunctions = [];
@@ -5462,11 +5468,17 @@ please use an LLM adapter instead.`
5462
5468
  }) : this.actions;
5463
5469
  const requestSpecificMCPActions = [];
5464
5470
  if (this.createMCPClientImpl) {
5465
- const baseEndpoints = this.mcpEndpointsConfig || [];
5466
- const requestEndpoints = ((_a = graphqlContext.properties) == null ? void 0 : _a.mcpEndpoints) || [];
5471
+ const baseEndpoints = this.mcpServersConfig || [];
5472
+ const requestEndpoints = ((_a = graphqlContext.properties) == null ? void 0 : _a.mcpServers) || ((_b = graphqlContext.properties) == null ? void 0 : _b.mcpEndpoints) || [];
5467
5473
  const effectiveEndpointsMap = /* @__PURE__ */ new Map();
5468
5474
  [
5469
- ...baseEndpoints,
5475
+ ...baseEndpoints
5476
+ ].forEach((ep) => {
5477
+ if (ep && ep.endpoint) {
5478
+ effectiveEndpointsMap.set(ep.endpoint, ep);
5479
+ }
5480
+ });
5481
+ [
5470
5482
  ...requestEndpoints
5471
5483
  ].forEach((ep) => {
5472
5484
  if (ep && ep.endpoint) {
@@ -5480,12 +5492,10 @@ please use an LLM adapter instead.`
5480
5492
  if (!actionsForEndpoint) {
5481
5493
  let client = null;
5482
5494
  try {
5483
- console.log(`MCP: Cache miss. Fetching tools for endpoint: ${endpointUrl}`);
5484
5495
  client = await this.createMCPClientImpl(config2);
5485
5496
  const tools = await client.tools();
5486
5497
  actionsForEndpoint = convertMCPToolsToActions(tools, endpointUrl);
5487
5498
  this.mcpActionCache.set(endpointUrl, actionsForEndpoint);
5488
- console.log(`MCP: Fetched and cached ${actionsForEndpoint.length} tools for ${endpointUrl}`);
5489
5499
  } catch (error) {
5490
5500
  console.error(`MCP: Failed to fetch tools from endpoint ${endpointUrl}. Skipping. Error:`, error);
5491
5501
  actionsForEndpoint = [];