@copilotkit/runtime 0.0.0-feat-enable-setting-recursion-limit-20250424165940 → 0.0.0-feat-support-custom-markdown-20250428111750

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 (46) hide show
  1. package/CHANGELOG.md +42 -4
  2. package/__snapshots__/schema/schema.graphql +1 -1
  3. package/dist/{chunk-NOBEZQXE.mjs → chunk-4KLOSPKW.mjs} +101 -34
  4. package/dist/chunk-4KLOSPKW.mjs.map +1 -0
  5. package/dist/{chunk-P4G7CDGG.mjs → chunk-75TKODO4.mjs} +2 -2
  6. package/dist/{chunk-JMLO6ZET.mjs → chunk-JXLF6SJU.mjs} +2 -2
  7. package/dist/{chunk-E5I25B3L.mjs → chunk-W7BXDLO4.mjs} +2 -2
  8. package/dist/{groq-adapter-4848f8e8.d.ts → groq-adapter-53d3fa48.d.ts} +1 -1
  9. package/dist/index.d.ts +3 -3
  10. package/dist/index.js +101 -33
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.mjs +6 -4
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/{langserve-4a5c9217.d.ts → langserve-c9a20fe9.d.ts} +1 -1
  15. package/dist/lib/index.d.ts +3 -3
  16. package/dist/lib/index.js +101 -33
  17. package/dist/lib/index.js.map +1 -1
  18. package/dist/lib/index.mjs +6 -4
  19. package/dist/lib/integrations/index.d.ts +3 -3
  20. package/dist/lib/integrations/index.js +3 -3
  21. package/dist/lib/integrations/index.js.map +1 -1
  22. package/dist/lib/integrations/index.mjs +4 -4
  23. package/dist/lib/integrations/nest/index.d.ts +2 -2
  24. package/dist/lib/integrations/nest/index.js +3 -3
  25. package/dist/lib/integrations/nest/index.js.map +1 -1
  26. package/dist/lib/integrations/nest/index.mjs +2 -2
  27. package/dist/lib/integrations/node-express/index.d.ts +2 -2
  28. package/dist/lib/integrations/node-express/index.js +3 -3
  29. package/dist/lib/integrations/node-express/index.js.map +1 -1
  30. package/dist/lib/integrations/node-express/index.mjs +2 -2
  31. package/dist/lib/integrations/node-http/index.d.ts +2 -2
  32. package/dist/lib/integrations/node-http/index.js +3 -3
  33. package/dist/lib/integrations/node-http/index.js.map +1 -1
  34. package/dist/lib/integrations/node-http/index.mjs +1 -1
  35. package/dist/service-adapters/index.d.ts +3 -3
  36. package/dist/{shared-e7c09fa4.d.ts → shared-df478d34.d.ts} +14 -8
  37. package/package.json +4 -4
  38. package/src/graphql/inputs/agent-state.input.ts +1 -1
  39. package/src/lib/runtime/copilot-runtime.ts +65 -35
  40. package/src/lib/runtime/mcp-tools-utils.ts +76 -5
  41. package/src/lib/runtime/remote-action-constructors.ts +6 -6
  42. package/src/lib/runtime/remote-lg-action.ts +6 -11
  43. package/dist/chunk-NOBEZQXE.mjs.map +0 -1
  44. /package/dist/{chunk-P4G7CDGG.mjs.map → chunk-75TKODO4.mjs.map} +0 -0
  45. /package/dist/{chunk-JMLO6ZET.mjs.map → chunk-JXLF6SJU.mjs.map} +0 -0
  46. /package/dist/{chunk-E5I25B3L.mjs.map → chunk-W7BXDLO4.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,12 +1,50 @@
1
1
  # @copilotkit/runtime
2
2
 
3
- ## 0.0.0-feat-enable-setting-recursion-limit-20250424165940
3
+ ## 0.0.0-feat-support-custom-markdown-20250428111750
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - 1d2ae5a: - feat: enable setting langgraph config from ui
8
- - chore: document usage of new config
9
- - @copilotkit/shared@0.0.0-feat-enable-setting-recursion-limit-20250424165940
7
+ - @copilotkit/shared@0.0.0-feat-support-custom-markdown-20250428111750
8
+
9
+ ## 1.8.9
10
+
11
+ ### Patch Changes
12
+
13
+ - f81a526: - Fix MCP tool schema structure to match interface requirements
14
+ - add utils
15
+ - @copilotkit/shared@1.8.9
16
+
17
+ ## 1.8.9-next.0
18
+
19
+ ### Patch Changes
20
+
21
+ - f81a526: - Fix MCP tool schema structure to match interface requirements
22
+ - add utils
23
+ - @copilotkit/shared@1.8.9-next.0
24
+
25
+ ## 1.8.8
26
+
27
+ ### Patch Changes
28
+
29
+ - 8c26335: - fix: update MCP tool parameter extraction to handle full tool objects
30
+ - dfb67c3: - refactor: rename mcpEndpoints to mcpServers for naming consistency
31
+ - doc changes
32
+ - @copilotkit/shared@1.8.8
33
+
34
+ ## 1.8.8-next.1
35
+
36
+ ### Patch Changes
37
+
38
+ - 8c26335: - fix: update MCP tool parameter extraction to handle full tool objects
39
+ - @copilotkit/shared@1.8.8-next.1
40
+
41
+ ## 1.8.8-next.0
42
+
43
+ ### Patch Changes
44
+
45
+ - dfb67c3: - refactor: rename mcpEndpoints to mcpServers for naming consistency
46
+ - doc changes
47
+ - @copilotkit/shared@1.8.8-next.0
10
48
 
11
49
  ## 1.8.7
12
50
 
@@ -48,7 +48,7 @@ input AgentSessionInput {
48
48
 
49
49
  input AgentStateInput {
50
50
  agentName: String!
51
- config: String
51
+ configurable: String
52
52
  state: String!
53
53
  }
54
54
 
@@ -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",
@@ -709,7 +709,7 @@ __name(_ts_metadata8, "_ts_metadata");
709
709
  var AgentStateInput = class {
710
710
  agentName;
711
711
  state;
712
- config;
712
+ configurable;
713
713
  };
714
714
  __name(AgentStateInput, "AgentStateInput");
715
715
  _ts_decorate8([
@@ -725,7 +725,7 @@ _ts_decorate8([
725
725
  nullable: true
726
726
  }),
727
727
  _ts_metadata8("design:type", String)
728
- ], AgentStateInput.prototype, "config", void 0);
728
+ ], AgentStateInput.prototype, "configurable", void 0);
729
729
  AgentStateInput = _ts_decorate8([
730
730
  InputType8()
731
731
  ], AgentStateInput);
@@ -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, configurable, 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,10 @@ 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 (configurable) {
1897
+ const filteredConfigurable = (schemaKeys == null ? void 0 : schemaKeys.config) ? filterObjectBySchemaKeys(configurable, schemaKeys == null ? void 0 : schemaKeys.config) : configurable;
1898
1898
  await client.assistants.update(assistantId, {
1899
1899
  config: {
1900
- ...config,
1901
1900
  configurable: filteredConfigurable
1902
1901
  }
1903
1902
  });
@@ -2441,12 +2440,12 @@ function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, m
2441
2440
  hashedLgcKey: createHash2("sha256").update(endpoint.langsmithApiKey).digest("hex")
2442
2441
  });
2443
2442
  let state = {};
2444
- let config = {};
2443
+ let configurable = {};
2445
2444
  if (agentStates) {
2446
2445
  const jsonState = agentStates.find((state2) => state2.agentName === name);
2447
2446
  if (jsonState) {
2448
2447
  state = parseJson2(jsonState.state, {});
2449
- config = parseJson2(jsonState.config, {});
2448
+ configurable = parseJson2(jsonState.configurable, {});
2450
2449
  }
2451
2450
  }
2452
2451
  try {
@@ -2464,7 +2463,7 @@ function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, m
2464
2463
  ...additionalMessages
2465
2464
  ],
2466
2465
  state,
2467
- config,
2466
+ configurable,
2468
2467
  properties: graphqlContext.properties,
2469
2468
  actions: tryMap(actionInputsWithoutAgents, (action) => ({
2470
2469
  name: action.name,
@@ -2576,12 +2575,12 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
2576
2575
  agentsAmount: json["agents"].length
2577
2576
  });
2578
2577
  let state = {};
2579
- let config = {};
2578
+ let configurable = {};
2580
2579
  if (agentStates) {
2581
2580
  const jsonState = agentStates.find((state2) => state2.agentName === name);
2582
2581
  if (jsonState) {
2583
2582
  state = parseJson2(jsonState.state, {});
2584
- config = parseJson2(jsonState.config, {});
2583
+ configurable = parseJson2(jsonState.configurable, {});
2585
2584
  }
2586
2585
  }
2587
2586
  const fetchUrl = `${url}/agents/execute`;
@@ -2598,7 +2597,7 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
2598
2597
  ...additionalMessages
2599
2598
  ],
2600
2599
  state,
2601
- config,
2600
+ configurable,
2602
2601
  properties: graphqlContext.properties,
2603
2602
  actions: tryMap(actionInputsWithoutAgents, (action) => ({
2604
2603
  name: action.name,
@@ -2959,11 +2958,13 @@ import { from } from "rxjs";
2959
2958
  import { Client as LangGraphClient2 } from "@langchain/langgraph-sdk";
2960
2959
 
2961
2960
  // src/lib/runtime/mcp-tools-utils.ts
2962
- function extractParametersFromSchema(toolSchema) {
2963
- var _a, _b;
2961
+ function extractParametersFromSchema(toolOrSchema) {
2962
+ var _a;
2964
2963
  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) || []);
2964
+ const schema = "schema" in (toolOrSchema || {}) ? toolOrSchema.schema : toolOrSchema;
2965
+ const toolParameters = (schema == null ? void 0 : schema.parameters) || ((_a = schema == null ? void 0 : schema.parameters) == null ? void 0 : _a.jsonSchema);
2966
+ const properties = toolParameters == null ? void 0 : toolParameters.properties;
2967
+ const requiredParams = new Set((toolParameters == null ? void 0 : toolParameters.required) || []);
2967
2968
  if (!properties) {
2968
2969
  return parameters;
2969
2970
  }
@@ -2986,7 +2987,7 @@ __name(extractParametersFromSchema, "extractParametersFromSchema");
2986
2987
  function convertMCPToolsToActions(mcpTools, mcpEndpoint) {
2987
2988
  const actions = [];
2988
2989
  for (const [toolName, tool] of Object.entries(mcpTools)) {
2989
- const parameters = extractParametersFromSchema(tool.schema);
2990
+ const parameters = extractParametersFromSchema(tool);
2990
2991
  const handler = /* @__PURE__ */ __name(async (params) => {
2991
2992
  try {
2992
2993
  const result = await tool.execute({
@@ -3011,6 +3012,47 @@ function convertMCPToolsToActions(mcpTools, mcpEndpoint) {
3011
3012
  return actions;
3012
3013
  }
3013
3014
  __name(convertMCPToolsToActions, "convertMCPToolsToActions");
3015
+ function generateMcpToolInstructions(toolsMap) {
3016
+ if (!toolsMap || Object.keys(toolsMap).length === 0) {
3017
+ return "";
3018
+ }
3019
+ const toolEntries = Object.entries(toolsMap);
3020
+ const toolsDoc = toolEntries.map(([name, tool]) => {
3021
+ let paramsDoc = " No parameters required";
3022
+ try {
3023
+ if (tool.schema && typeof tool.schema === "object") {
3024
+ const schema = tool.schema;
3025
+ if (schema.properties) {
3026
+ const requiredParams = schema.required || [];
3027
+ const paramsList = Object.entries(schema.properties).map(([paramName, propSchema]) => {
3028
+ const propDetails = propSchema;
3029
+ const requiredMark = requiredParams.includes(paramName) ? "*" : "";
3030
+ const typeInfo = propDetails.type || "any";
3031
+ const description = propDetails.description ? ` - ${propDetails.description}` : "";
3032
+ return ` - ${paramName}${requiredMark} (${typeInfo})${description}`;
3033
+ });
3034
+ if (paramsList.length > 0) {
3035
+ paramsDoc = paramsList.join("\n");
3036
+ }
3037
+ }
3038
+ }
3039
+ } catch (e) {
3040
+ console.error(`Error parsing schema for tool ${name}:`, e);
3041
+ }
3042
+ return `- ${name}: ${tool.description || ""}
3043
+ ${paramsDoc}`;
3044
+ }).join("\n\n");
3045
+ return `You have access to the following external tools provided by Model Context Protocol (MCP) servers:
3046
+
3047
+ ${toolsDoc}
3048
+
3049
+ When using these tools:
3050
+ 1. Only provide valid parameters according to their type requirements
3051
+ 2. Required parameters are marked with *
3052
+ 3. Format API calls correctly with the expected parameter structure
3053
+ 4. Always check tool responses to determine your next action`;
3054
+ }
3055
+ __name(generateMcpToolInstructions, "generateMcpToolInstructions");
3014
3056
 
3015
3057
  // src/lib/runtime/copilot-runtime.ts
3016
3058
  var CopilotRuntime = class {
@@ -3024,7 +3066,7 @@ var CopilotRuntime = class {
3024
3066
  observability;
3025
3067
  availableAgents;
3026
3068
  // +++ MCP Properties +++
3027
- mcpEndpointsConfig;
3069
+ mcpServersConfig;
3028
3070
  mcpActionCache = /* @__PURE__ */ new Map();
3029
3071
  // --- MCP Properties ---
3030
3072
  // +++ MCP Client Factory +++
@@ -3047,14 +3089,14 @@ var CopilotRuntime = class {
3047
3089
  this.delegateAgentProcessingToServiceAdapter = (params == null ? void 0 : params.delegateAgentProcessingToServiceAdapter) || false;
3048
3090
  this.observability = params == null ? void 0 : params.observability_c;
3049
3091
  this.agents = (params == null ? void 0 : params.agents) ?? {};
3050
- this.mcpEndpointsConfig = params == null ? void 0 : params.mcpEndpoints;
3092
+ this.mcpServersConfig = params == null ? void 0 : params.mcpServers;
3051
3093
  this.createMCPClientImpl = params == null ? void 0 : params.createMCPClient;
3052
- if (this.mcpEndpointsConfig && this.mcpEndpointsConfig.length > 0 && !this.createMCPClientImpl) {
3094
+ if (this.mcpServersConfig && this.mcpServersConfig.length > 0 && !this.createMCPClientImpl) {
3053
3095
  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`."
3096
+ 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
3097
  });
3056
3098
  }
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))) {
3099
+ 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
3100
  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
3101
  }
3060
3102
  }
@@ -3064,10 +3106,30 @@ var CopilotRuntime = class {
3064
3106
  if (!mcpActionsForRequest || mcpActionsForRequest.length === 0) {
3065
3107
  return messages;
3066
3108
  }
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");
3109
+ const uniqueMcpTools = /* @__PURE__ */ new Map();
3110
+ mcpActionsForRequest.forEach((action) => {
3111
+ uniqueMcpTools.set(action.name, action);
3112
+ });
3113
+ const toolsMap = {};
3114
+ Array.from(uniqueMcpTools.values()).forEach((action) => {
3115
+ toolsMap[action.name] = {
3116
+ description: action.description || "",
3117
+ schema: action.parameters ? {
3118
+ parameters: {
3119
+ properties: action.parameters.reduce((acc, p) => ({
3120
+ ...acc,
3121
+ [p.name]: {
3122
+ type: p.type,
3123
+ description: p.description
3124
+ }
3125
+ }), {}),
3126
+ required: action.parameters.filter((p) => p.required).map((p) => p.name)
3127
+ }
3128
+ } : {},
3129
+ execute: async () => ({})
3130
+ };
3131
+ });
3132
+ const mcpToolInstructions = generateMcpToolInstructions(toolsMap);
3071
3133
  if (!mcpToolInstructions) {
3072
3134
  return messages;
3073
3135
  }
@@ -3647,7 +3709,7 @@ please use an LLM adapter instead.`
3647
3709
  }
3648
3710
  }
3649
3711
  async getServerSideActions(request) {
3650
- var _a;
3712
+ var _a, _b;
3651
3713
  const { graphqlContext, messages: rawMessages, agentStates, url } = request;
3652
3714
  const inputMessages = convertGqlInputToMessages(rawMessages);
3653
3715
  const langserveFunctions = [];
@@ -3677,11 +3739,17 @@ please use an LLM adapter instead.`
3677
3739
  }) : this.actions;
3678
3740
  const requestSpecificMCPActions = [];
3679
3741
  if (this.createMCPClientImpl) {
3680
- const baseEndpoints = this.mcpEndpointsConfig || [];
3681
- const requestEndpoints = ((_a = graphqlContext.properties) == null ? void 0 : _a.mcpEndpoints) || [];
3742
+ const baseEndpoints = this.mcpServersConfig || [];
3743
+ const requestEndpoints = ((_a = graphqlContext.properties) == null ? void 0 : _a.mcpServers) || ((_b = graphqlContext.properties) == null ? void 0 : _b.mcpEndpoints) || [];
3682
3744
  const effectiveEndpointsMap = /* @__PURE__ */ new Map();
3683
3745
  [
3684
- ...baseEndpoints,
3746
+ ...baseEndpoints
3747
+ ].forEach((ep) => {
3748
+ if (ep && ep.endpoint) {
3749
+ effectiveEndpointsMap.set(ep.endpoint, ep);
3750
+ }
3751
+ });
3752
+ [
3685
3753
  ...requestEndpoints
3686
3754
  ].forEach((ep) => {
3687
3755
  if (ep && ep.endpoint) {
@@ -3695,12 +3763,10 @@ please use an LLM adapter instead.`
3695
3763
  if (!actionsForEndpoint) {
3696
3764
  let client = null;
3697
3765
  try {
3698
- console.log(`MCP: Cache miss. Fetching tools for endpoint: ${endpointUrl}`);
3699
3766
  client = await this.createMCPClientImpl(config);
3700
3767
  const tools = await client.tools();
3701
3768
  actionsForEndpoint = convertMCPToolsToActions(tools, endpointUrl);
3702
3769
  this.mcpActionCache.set(endpointUrl, actionsForEndpoint);
3703
- console.log(`MCP: Fetched and cached ${actionsForEndpoint.length} tools for ${endpointUrl}`);
3704
3770
  } catch (error) {
3705
3771
  console.error(`MCP: Failed to fetch tools from endpoint ${endpointUrl}. Skipping. Error:`, error);
3706
3772
  actionsForEndpoint = [];
@@ -4974,6 +5040,7 @@ __name(copilotRuntimeNodeHttpEndpoint, "copilotRuntimeNodeHttpEndpoint");
4974
5040
  export {
4975
5041
  extractParametersFromSchema,
4976
5042
  convertMCPToolsToActions,
5043
+ generateMcpToolInstructions,
4977
5044
  CopilotRuntime,
4978
5045
  flattenToolCallsNoDuplicates,
4979
5046
  copilotKitEndpoint,
@@ -4988,4 +5055,4 @@ export {
4988
5055
  getCommonConfig,
4989
5056
  copilotRuntimeNodeHttpEndpoint
4990
5057
  };
4991
- //# sourceMappingURL=chunk-NOBEZQXE.mjs.map
5058
+ //# sourceMappingURL=chunk-4KLOSPKW.mjs.map