@copilotkit/runtime 1.8.8 → 1.8.9
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.
- package/CHANGELOG.md +16 -0
- package/dist/{chunk-3R446VII.mjs → chunk-4KLOSPKW.mjs} +64 -6
- package/dist/chunk-4KLOSPKW.mjs.map +1 -0
- package/dist/{chunk-HAIKRVPW.mjs → chunk-75TKODO4.mjs} +2 -2
- package/dist/{chunk-UKGY3PWM.mjs → chunk-JXLF6SJU.mjs} +2 -2
- package/dist/{chunk-PTBPJ2YQ.mjs → chunk-W7BXDLO4.mjs} +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +64 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -4
- package/dist/index.mjs.map +1 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +64 -5
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +6 -4
- package/dist/lib/integrations/index.d.ts +2 -2
- package/dist/lib/integrations/index.js +1 -1
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +4 -4
- package/dist/lib/integrations/nest/index.d.ts +1 -1
- package/dist/lib/integrations/nest/index.js +1 -1
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +2 -2
- package/dist/lib/integrations/node-express/index.d.ts +1 -1
- package/dist/lib/integrations/node-express/index.js +1 -1
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +2 -2
- package/dist/lib/integrations/node-http/index.d.ts +1 -1
- package/dist/lib/integrations/node-http/index.js +1 -1
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +1 -1
- package/dist/{shared-32a46e93.d.ts → shared-df478d34.d.ts} +6 -1
- package/package.json +2 -2
- package/src/lib/runtime/copilot-runtime.ts +32 -12
- package/src/lib/runtime/mcp-tools-utils.ts +60 -0
- package/dist/chunk-3R446VII.mjs.map +0 -1
- /package/dist/{chunk-HAIKRVPW.mjs.map → chunk-75TKODO4.mjs.map} +0 -0
- /package/dist/{chunk-UKGY3PWM.mjs.map → chunk-JXLF6SJU.mjs.map} +0 -0
- /package/dist/{chunk-PTBPJ2YQ.mjs.map → chunk-W7BXDLO4.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @copilotkit/runtime
|
|
2
2
|
|
|
3
|
+
## 1.8.9
|
|
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
|
|
10
|
+
|
|
11
|
+
## 1.8.9-next.0
|
|
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-next.0
|
|
18
|
+
|
|
3
19
|
## 1.8.8
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -40,7 +40,7 @@ var require_package = __commonJS({
|
|
|
40
40
|
publishConfig: {
|
|
41
41
|
access: "public"
|
|
42
42
|
},
|
|
43
|
-
version: "1.8.
|
|
43
|
+
version: "1.8.9",
|
|
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
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
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-
|
|
5058
|
+
//# sourceMappingURL=chunk-4KLOSPKW.mjs.map
|