@copilotkit/runtime 1.8.8-next.1 → 1.8.9-next.0

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 (39) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/{chunk-3UU33HF6.mjs → chunk-AFJ3VQB4.mjs} +2 -2
  3. package/dist/{chunk-QF6GPOZV.mjs → chunk-HEKLYCFM.mjs} +2 -2
  4. package/dist/{chunk-HBCCZQBE.mjs → chunk-LFB4PE32.mjs} +64 -6
  5. package/dist/chunk-LFB4PE32.mjs.map +1 -0
  6. package/dist/{chunk-O4WMMGSX.mjs → chunk-TPDMN2N7.mjs} +2 -2
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.js +64 -5
  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 +64 -5
  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-32a46e93.d.ts → shared-df478d34.d.ts} +6 -1
  33. package/package.json +2 -2
  34. package/src/lib/runtime/copilot-runtime.ts +32 -12
  35. package/src/lib/runtime/mcp-tools-utils.ts +60 -0
  36. package/dist/chunk-HBCCZQBE.mjs.map +0 -1
  37. /package/dist/{chunk-3UU33HF6.mjs.map → chunk-AFJ3VQB4.mjs.map} +0 -0
  38. /package/dist/{chunk-QF6GPOZV.mjs.map → chunk-HEKLYCFM.mjs.map} +0 -0
  39. /package/dist/{chunk-O4WMMGSX.mjs.map → chunk-TPDMN2N7.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @copilotkit/runtime
2
2
 
3
+ ## 1.8.9-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - f81a526: - Fix MCP tool schema structure to match interface requirements
8
+ - add utils
9
+ - @copilotkit/shared@1.8.9-next.0
10
+
11
+ ## 1.8.8
12
+
13
+ ### Patch Changes
14
+
15
+ - 8c26335: - fix: update MCP tool parameter extraction to handle full tool objects
16
+ - dfb67c3: - refactor: rename mcpEndpoints to mcpServers for naming consistency
17
+ - doc changes
18
+ - @copilotkit/shared@1.8.8
19
+
3
20
  ## 1.8.8-next.1
4
21
 
5
22
  ### Patch Changes
@@ -2,7 +2,7 @@ import {
2
2
  copilotRuntimeNodeHttpEndpoint,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-HBCCZQBE.mjs";
5
+ } from "./chunk-LFB4PE32.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-3UU33HF6.mjs.map
25
+ //# sourceMappingURL=chunk-AFJ3VQB4.mjs.map
@@ -2,7 +2,7 @@ import {
2
2
  getCommonConfig,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-HBCCZQBE.mjs";
5
+ } from "./chunk-LFB4PE32.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-QF6GPOZV.mjs.map
80
+ //# sourceMappingURL=chunk-HEKLYCFM.mjs.map
@@ -40,7 +40,7 @@ var require_package = __commonJS({
40
40
  publishConfig: {
41
41
  access: "public"
42
42
  },
43
- version: "1.8.8-next.1",
43
+ version: "1.8.9-next.0",
44
44
  sideEffects: false,
45
45
  main: "./dist/index.js",
46
46
  module: "./dist/index.mjs",
@@ -3012,6 +3012,47 @@ function convertMCPToolsToActions(mcpTools, mcpEndpoint) {
3012
3012
  return actions;
3013
3013
  }
3014
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");
3015
3056
 
3016
3057
  // src/lib/runtime/copilot-runtime.ts
3017
3058
  var CopilotRuntime = class {
@@ -3069,10 +3110,26 @@ var CopilotRuntime = class {
3069
3110
  mcpActionsForRequest.forEach((action) => {
3070
3111
  uniqueMcpTools.set(action.name, action);
3071
3112
  });
3072
- const mcpToolInstructions = Array.from(uniqueMcpTools.values()).map((action) => {
3073
- const paramsString = action.parameters && action.parameters.length > 0 ? ` Parameters: ${action.parameters.map((p) => `${p.name}${p.required ? "*" : ""}(${p.type})`).join(", ")}` : "";
3074
- return `- ${action.name}:${paramsString} ${action.description || ""}`;
3075
- }).join("\n");
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);
3076
3133
  if (!mcpToolInstructions) {
3077
3134
  return messages;
3078
3135
  }
@@ -4983,6 +5040,7 @@ __name(copilotRuntimeNodeHttpEndpoint, "copilotRuntimeNodeHttpEndpoint");
4983
5040
  export {
4984
5041
  extractParametersFromSchema,
4985
5042
  convertMCPToolsToActions,
5043
+ generateMcpToolInstructions,
4986
5044
  CopilotRuntime,
4987
5045
  flattenToolCallsNoDuplicates,
4988
5046
  copilotKitEndpoint,
@@ -4997,4 +5055,4 @@ export {
4997
5055
  getCommonConfig,
4998
5056
  copilotRuntimeNodeHttpEndpoint
4999
5057
  };
5000
- //# sourceMappingURL=chunk-HBCCZQBE.mjs.map
5058
+ //# sourceMappingURL=chunk-LFB4PE32.mjs.map