@copilotkit/runtime 0.0.0-feat-enable-setting-recursion-limit-20250424165940 → 0.0.0-feat-enable-setting-recursion-limit-20250428151824

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 (40) hide show
  1. package/CHANGELOG.md +42 -2
  2. package/dist/{chunk-E5I25B3L.mjs → chunk-6N7YZABI.mjs} +2 -2
  3. package/dist/{chunk-P4G7CDGG.mjs → chunk-RESUQNFX.mjs} +2 -2
  4. package/dist/{chunk-JMLO6ZET.mjs → chunk-UXFLLVRF.mjs} +2 -2
  5. package/dist/{chunk-NOBEZQXE.mjs → chunk-UYOLJP2E.mjs} +98 -26
  6. package/dist/chunk-UYOLJP2E.mjs.map +1 -0
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.js +98 -25
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.mjs +6 -4
  11. package/dist/index.mjs.map +1 -1
  12. package/dist/lib/index.d.ts +1 -1
  13. package/dist/lib/index.js +98 -25
  14. package/dist/lib/index.js.map +1 -1
  15. package/dist/lib/index.mjs +6 -4
  16. package/dist/lib/integrations/index.d.ts +2 -2
  17. package/dist/lib/integrations/index.js +1 -1
  18. package/dist/lib/integrations/index.js.map +1 -1
  19. package/dist/lib/integrations/index.mjs +4 -4
  20. package/dist/lib/integrations/nest/index.d.ts +1 -1
  21. package/dist/lib/integrations/nest/index.js +1 -1
  22. package/dist/lib/integrations/nest/index.js.map +1 -1
  23. package/dist/lib/integrations/nest/index.mjs +2 -2
  24. package/dist/lib/integrations/node-express/index.d.ts +1 -1
  25. package/dist/lib/integrations/node-express/index.js +1 -1
  26. package/dist/lib/integrations/node-express/index.js.map +1 -1
  27. package/dist/lib/integrations/node-express/index.mjs +2 -2
  28. package/dist/lib/integrations/node-http/index.d.ts +1 -1
  29. package/dist/lib/integrations/node-http/index.js +1 -1
  30. package/dist/lib/integrations/node-http/index.js.map +1 -1
  31. package/dist/lib/integrations/node-http/index.mjs +1 -1
  32. package/dist/{shared-e7c09fa4.d.ts → shared-a7b30781.d.ts} +13 -7
  33. package/package.json +4 -4
  34. package/src/lib/runtime/copilot-runtime.ts +65 -35
  35. package/src/lib/runtime/mcp-tools-utils.ts +76 -5
  36. package/src/lib/runtime/remote-lg-action.ts +10 -6
  37. package/dist/chunk-NOBEZQXE.mjs.map +0 -1
  38. /package/dist/{chunk-E5I25B3L.mjs.map → chunk-6N7YZABI.mjs.map} +0 -0
  39. /package/dist/{chunk-P4G7CDGG.mjs.map → chunk-RESUQNFX.mjs.map} +0 -0
  40. /package/dist/{chunk-JMLO6ZET.mjs.map → chunk-UXFLLVRF.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,12 +1,52 @@
1
1
  # @copilotkit/runtime
2
2
 
3
- ## 0.0.0-feat-enable-setting-recursion-limit-20250424165940
3
+ ## 0.0.0-feat-enable-setting-recursion-limit-20250428151824
4
4
 
5
5
  ### Patch Changes
6
6
 
7
7
  - 1d2ae5a: - feat: enable setting langgraph config from ui
8
8
  - chore: document usage of new config
9
- - @copilotkit/shared@0.0.0-feat-enable-setting-recursion-limit-20250424165940
9
+ - @copilotkit/shared@0.0.0-feat-enable-setting-recursion-limit-20250428151824
10
+
11
+ ## 1.8.9
12
+
13
+ ### Patch Changes
14
+
15
+ - f81a526: - Fix MCP tool schema structure to match interface requirements
16
+ - add utils
17
+ - @copilotkit/shared@1.8.9
18
+
19
+ ## 1.8.9-next.0
20
+
21
+ ### Patch Changes
22
+
23
+ - f81a526: - Fix MCP tool schema structure to match interface requirements
24
+ - add utils
25
+ - @copilotkit/shared@1.8.9-next.0
26
+
27
+ ## 1.8.8
28
+
29
+ ### Patch Changes
30
+
31
+ - 8c26335: - fix: update MCP tool parameter extraction to handle full tool objects
32
+ - dfb67c3: - refactor: rename mcpEndpoints to mcpServers for naming consistency
33
+ - doc changes
34
+ - @copilotkit/shared@1.8.8
35
+
36
+ ## 1.8.8-next.1
37
+
38
+ ### Patch Changes
39
+
40
+ - 8c26335: - fix: update MCP tool parameter extraction to handle full tool objects
41
+ - @copilotkit/shared@1.8.8-next.1
42
+
43
+ ## 1.8.8-next.0
44
+
45
+ ### Patch Changes
46
+
47
+ - dfb67c3: - refactor: rename mcpEndpoints to mcpServers for naming consistency
48
+ - doc changes
49
+ - @copilotkit/shared@1.8.8-next.0
10
50
 
11
51
  ## 1.8.7
12
52
 
@@ -2,7 +2,7 @@ import {
2
2
  copilotRuntimeNodeHttpEndpoint,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-NOBEZQXE.mjs";
5
+ } from "./chunk-UYOLJP2E.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-E5I25B3L.mjs.map
25
+ //# sourceMappingURL=chunk-6N7YZABI.mjs.map
@@ -2,7 +2,7 @@ import {
2
2
  copilotRuntimeNodeHttpEndpoint,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-NOBEZQXE.mjs";
5
+ } from "./chunk-UYOLJP2E.mjs";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-FHD4JECV.mjs";
@@ -22,4 +22,4 @@ __name(copilotRuntimeNodeExpressEndpoint, "copilotRuntimeNodeExpressEndpoint");
22
22
  export {
23
23
  copilotRuntimeNodeExpressEndpoint
24
24
  };
25
- //# sourceMappingURL=chunk-P4G7CDGG.mjs.map
25
+ //# sourceMappingURL=chunk-RESUQNFX.mjs.map
@@ -2,7 +2,7 @@ import {
2
2
  getCommonConfig,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-NOBEZQXE.mjs";
5
+ } from "./chunk-UYOLJP2E.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-JMLO6ZET.mjs.map
80
+ //# sourceMappingURL=chunk-UXFLLVRF.mjs.map
@@ -40,7 +40,7 @@ var require_package = __commonJS({
40
40
  publishConfig: {
41
41
  access: "public"
42
42
  },
43
- version: "1.8.7",
43
+ version: "1.8.9",
44
44
  sideEffects: false,
45
45
  main: "./dist/index.js",
46
46
  module: "./dist/index.mjs",
@@ -1796,7 +1796,7 @@ async function execute(args) {
1796
1796
  __name(execute, "execute");
1797
1797
  async function streamEvents(controller, args) {
1798
1798
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1799
- const { deploymentUrl, langsmithApiKey, threadId: argsInitialThreadId, agent, nodeName: initialNodeName, state: initialState, config, messages, actions, logger: logger2, properties, metaEvents } = args;
1799
+ const { deploymentUrl, langsmithApiKey, threadId: argsInitialThreadId, agent, nodeName: initialNodeName, state: initialState, config: explicitConfig, messages, actions, logger: logger2, properties, metaEvents } = args;
1800
1800
  let nodeName = initialNodeName;
1801
1801
  let state = initialState;
1802
1802
  const { name, assistantId: initialAssistantId } = agent;
@@ -1893,11 +1893,15 @@ async function streamEvents(controller, args) {
1893
1893
  const graphInfo = await client.assistants.getGraph(assistantId);
1894
1894
  const graphSchema = await client.assistants.getSchemas(assistantId);
1895
1895
  const schemaKeys = getSchemaKeys(graphSchema);
1896
- if (config == null ? void 0 : config.configurable) {
1897
- const filteredConfigurable = (schemaKeys == null ? void 0 : schemaKeys.config) ? filterObjectBySchemaKeys(config == null ? void 0 : config.configurable, schemaKeys == null ? void 0 : schemaKeys.config) : config == null ? void 0 : config.configurable;
1896
+ if (explicitConfig) {
1897
+ let filteredConfigurable = retrievedAssistant.config.configurable ?? {};
1898
+ if (explicitConfig.configurable) {
1899
+ filteredConfigurable = (schemaKeys == null ? void 0 : schemaKeys.config) ? filterObjectBySchemaKeys(explicitConfig == null ? void 0 : explicitConfig.configurable, schemaKeys == null ? void 0 : schemaKeys.config) : explicitConfig == null ? void 0 : explicitConfig.configurable;
1900
+ }
1898
1901
  await client.assistants.update(assistantId, {
1899
1902
  config: {
1900
- ...config,
1903
+ ...retrievedAssistant.config,
1904
+ ...explicitConfig,
1901
1905
  configurable: filteredConfigurable
1902
1906
  }
1903
1907
  });
@@ -2959,11 +2963,13 @@ import { from } from "rxjs";
2959
2963
  import { Client as LangGraphClient2 } from "@langchain/langgraph-sdk";
2960
2964
 
2961
2965
  // src/lib/runtime/mcp-tools-utils.ts
2962
- function extractParametersFromSchema(toolSchema) {
2963
- var _a, _b;
2966
+ function extractParametersFromSchema(toolOrSchema) {
2967
+ var _a;
2964
2968
  const parameters = [];
2965
- const properties = (_a = toolSchema == null ? void 0 : toolSchema.parameters) == null ? void 0 : _a.properties;
2966
- const requiredParams = new Set(((_b = toolSchema == null ? void 0 : toolSchema.parameters) == null ? void 0 : _b.required) || []);
2969
+ const schema = "schema" in (toolOrSchema || {}) ? toolOrSchema.schema : toolOrSchema;
2970
+ const toolParameters = (schema == null ? void 0 : schema.parameters) || ((_a = schema == null ? void 0 : schema.parameters) == null ? void 0 : _a.jsonSchema);
2971
+ const properties = toolParameters == null ? void 0 : toolParameters.properties;
2972
+ const requiredParams = new Set((toolParameters == null ? void 0 : toolParameters.required) || []);
2967
2973
  if (!properties) {
2968
2974
  return parameters;
2969
2975
  }
@@ -2986,7 +2992,7 @@ __name(extractParametersFromSchema, "extractParametersFromSchema");
2986
2992
  function convertMCPToolsToActions(mcpTools, mcpEndpoint) {
2987
2993
  const actions = [];
2988
2994
  for (const [toolName, tool] of Object.entries(mcpTools)) {
2989
- const parameters = extractParametersFromSchema(tool.schema);
2995
+ const parameters = extractParametersFromSchema(tool);
2990
2996
  const handler = /* @__PURE__ */ __name(async (params) => {
2991
2997
  try {
2992
2998
  const result = await tool.execute({
@@ -3011,6 +3017,47 @@ function convertMCPToolsToActions(mcpTools, mcpEndpoint) {
3011
3017
  return actions;
3012
3018
  }
3013
3019
  __name(convertMCPToolsToActions, "convertMCPToolsToActions");
3020
+ function generateMcpToolInstructions(toolsMap) {
3021
+ if (!toolsMap || Object.keys(toolsMap).length === 0) {
3022
+ return "";
3023
+ }
3024
+ const toolEntries = Object.entries(toolsMap);
3025
+ const toolsDoc = toolEntries.map(([name, tool]) => {
3026
+ let paramsDoc = " No parameters required";
3027
+ try {
3028
+ if (tool.schema && typeof tool.schema === "object") {
3029
+ const schema = tool.schema;
3030
+ if (schema.properties) {
3031
+ const requiredParams = schema.required || [];
3032
+ const paramsList = Object.entries(schema.properties).map(([paramName, propSchema]) => {
3033
+ const propDetails = propSchema;
3034
+ const requiredMark = requiredParams.includes(paramName) ? "*" : "";
3035
+ const typeInfo = propDetails.type || "any";
3036
+ const description = propDetails.description ? ` - ${propDetails.description}` : "";
3037
+ return ` - ${paramName}${requiredMark} (${typeInfo})${description}`;
3038
+ });
3039
+ if (paramsList.length > 0) {
3040
+ paramsDoc = paramsList.join("\n");
3041
+ }
3042
+ }
3043
+ }
3044
+ } catch (e) {
3045
+ console.error(`Error parsing schema for tool ${name}:`, e);
3046
+ }
3047
+ return `- ${name}: ${tool.description || ""}
3048
+ ${paramsDoc}`;
3049
+ }).join("\n\n");
3050
+ return `You have access to the following external tools provided by Model Context Protocol (MCP) servers:
3051
+
3052
+ ${toolsDoc}
3053
+
3054
+ When using these tools:
3055
+ 1. Only provide valid parameters according to their type requirements
3056
+ 2. Required parameters are marked with *
3057
+ 3. Format API calls correctly with the expected parameter structure
3058
+ 4. Always check tool responses to determine your next action`;
3059
+ }
3060
+ __name(generateMcpToolInstructions, "generateMcpToolInstructions");
3014
3061
 
3015
3062
  // src/lib/runtime/copilot-runtime.ts
3016
3063
  var CopilotRuntime = class {
@@ -3024,7 +3071,7 @@ var CopilotRuntime = class {
3024
3071
  observability;
3025
3072
  availableAgents;
3026
3073
  // +++ MCP Properties +++
3027
- mcpEndpointsConfig;
3074
+ mcpServersConfig;
3028
3075
  mcpActionCache = /* @__PURE__ */ new Map();
3029
3076
  // --- MCP Properties ---
3030
3077
  // +++ MCP Client Factory +++
@@ -3047,14 +3094,14 @@ var CopilotRuntime = class {
3047
3094
  this.delegateAgentProcessingToServiceAdapter = (params == null ? void 0 : params.delegateAgentProcessingToServiceAdapter) || false;
3048
3095
  this.observability = params == null ? void 0 : params.observability_c;
3049
3096
  this.agents = (params == null ? void 0 : params.agents) ?? {};
3050
- this.mcpEndpointsConfig = params == null ? void 0 : params.mcpEndpoints;
3097
+ this.mcpServersConfig = params == null ? void 0 : params.mcpServers;
3051
3098
  this.createMCPClientImpl = params == null ? void 0 : params.createMCPClient;
3052
- if (this.mcpEndpointsConfig && this.mcpEndpointsConfig.length > 0 && !this.createMCPClientImpl) {
3099
+ if (this.mcpServersConfig && this.mcpServersConfig.length > 0 && !this.createMCPClientImpl) {
3053
3100
  throw new CopilotKitMisuseError2({
3054
- message: "MCP Integration Error: `mcpEndpoints` were provided, but the `createMCPClient` function was not passed to the CopilotRuntime constructor. Please provide an implementation for `createMCPClient`."
3101
+ message: "MCP Integration Error: `mcpServers` were provided, but the `createMCPClient` function was not passed to the CopilotRuntime constructor. Please provide an implementation for `createMCPClient`."
3055
3102
  });
3056
3103
  }
3057
- 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))) {
3104
+ 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))) {
3058
3105
  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.");
3059
3106
  }
3060
3107
  }
@@ -3064,10 +3111,30 @@ var CopilotRuntime = class {
3064
3111
  if (!mcpActionsForRequest || mcpActionsForRequest.length === 0) {
3065
3112
  return messages;
3066
3113
  }
3067
- const mcpToolInstructions = mcpActionsForRequest.map((action) => {
3068
- const paramsString = action.parameters && action.parameters.length > 0 ? ` Parameters: ${action.parameters.map((p) => `${p.name}${p.required ? "*" : ""}(${p.type})`).join(", ")}` : "";
3069
- return `- ${action.name}:${paramsString} ${action.description || ""}`;
3070
- }).join("\n");
3114
+ const uniqueMcpTools = /* @__PURE__ */ new Map();
3115
+ mcpActionsForRequest.forEach((action) => {
3116
+ uniqueMcpTools.set(action.name, action);
3117
+ });
3118
+ const toolsMap = {};
3119
+ Array.from(uniqueMcpTools.values()).forEach((action) => {
3120
+ toolsMap[action.name] = {
3121
+ description: action.description || "",
3122
+ schema: action.parameters ? {
3123
+ parameters: {
3124
+ properties: action.parameters.reduce((acc, p) => ({
3125
+ ...acc,
3126
+ [p.name]: {
3127
+ type: p.type,
3128
+ description: p.description
3129
+ }
3130
+ }), {}),
3131
+ required: action.parameters.filter((p) => p.required).map((p) => p.name)
3132
+ }
3133
+ } : {},
3134
+ execute: async () => ({})
3135
+ };
3136
+ });
3137
+ const mcpToolInstructions = generateMcpToolInstructions(toolsMap);
3071
3138
  if (!mcpToolInstructions) {
3072
3139
  return messages;
3073
3140
  }
@@ -3647,7 +3714,7 @@ please use an LLM adapter instead.`
3647
3714
  }
3648
3715
  }
3649
3716
  async getServerSideActions(request) {
3650
- var _a;
3717
+ var _a, _b;
3651
3718
  const { graphqlContext, messages: rawMessages, agentStates, url } = request;
3652
3719
  const inputMessages = convertGqlInputToMessages(rawMessages);
3653
3720
  const langserveFunctions = [];
@@ -3677,11 +3744,17 @@ please use an LLM adapter instead.`
3677
3744
  }) : this.actions;
3678
3745
  const requestSpecificMCPActions = [];
3679
3746
  if (this.createMCPClientImpl) {
3680
- const baseEndpoints = this.mcpEndpointsConfig || [];
3681
- const requestEndpoints = ((_a = graphqlContext.properties) == null ? void 0 : _a.mcpEndpoints) || [];
3747
+ const baseEndpoints = this.mcpServersConfig || [];
3748
+ const requestEndpoints = ((_a = graphqlContext.properties) == null ? void 0 : _a.mcpServers) || ((_b = graphqlContext.properties) == null ? void 0 : _b.mcpEndpoints) || [];
3682
3749
  const effectiveEndpointsMap = /* @__PURE__ */ new Map();
3683
3750
  [
3684
- ...baseEndpoints,
3751
+ ...baseEndpoints
3752
+ ].forEach((ep) => {
3753
+ if (ep && ep.endpoint) {
3754
+ effectiveEndpointsMap.set(ep.endpoint, ep);
3755
+ }
3756
+ });
3757
+ [
3685
3758
  ...requestEndpoints
3686
3759
  ].forEach((ep) => {
3687
3760
  if (ep && ep.endpoint) {
@@ -3695,12 +3768,10 @@ please use an LLM adapter instead.`
3695
3768
  if (!actionsForEndpoint) {
3696
3769
  let client = null;
3697
3770
  try {
3698
- console.log(`MCP: Cache miss. Fetching tools for endpoint: ${endpointUrl}`);
3699
3771
  client = await this.createMCPClientImpl(config);
3700
3772
  const tools = await client.tools();
3701
3773
  actionsForEndpoint = convertMCPToolsToActions(tools, endpointUrl);
3702
3774
  this.mcpActionCache.set(endpointUrl, actionsForEndpoint);
3703
- console.log(`MCP: Fetched and cached ${actionsForEndpoint.length} tools for ${endpointUrl}`);
3704
3775
  } catch (error) {
3705
3776
  console.error(`MCP: Failed to fetch tools from endpoint ${endpointUrl}. Skipping. Error:`, error);
3706
3777
  actionsForEndpoint = [];
@@ -4974,6 +5045,7 @@ __name(copilotRuntimeNodeHttpEndpoint, "copilotRuntimeNodeHttpEndpoint");
4974
5045
  export {
4975
5046
  extractParametersFromSchema,
4976
5047
  convertMCPToolsToActions,
5048
+ generateMcpToolInstructions,
4977
5049
  CopilotRuntime,
4978
5050
  flattenToolCallsNoDuplicates,
4979
5051
  copilotKitEndpoint,
@@ -4988,4 +5060,4 @@ export {
4988
5060
  getCommonConfig,
4989
5061
  copilotRuntimeNodeHttpEndpoint
4990
5062
  };
4991
- //# sourceMappingURL=chunk-NOBEZQXE.mjs.map
5063
+ //# sourceMappingURL=chunk-UYOLJP2E.mjs.map