@copilotkit/runtime 1.9.2-next.22 → 1.9.2-next.24
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 +19 -0
- package/dist/{chunk-MQNSNCJU.mjs → chunk-ECQRTXJX.mjs} +2 -2
- package/dist/{chunk-Z2HSWVJ6.mjs → chunk-FR4C3TPU.mjs} +2 -2
- package/dist/{chunk-WLLDTXG6.mjs → chunk-GAUZHH2X.mjs} +73 -34
- package/dist/chunk-GAUZHH2X.mjs.map +1 -0
- package/dist/{chunk-YSRDTT3V.mjs → chunk-S2YGYQDH.mjs} +2 -2
- package/dist/{chunk-UOSL5GYI.mjs → chunk-TBVA4IGX.mjs} +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +65 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/lib/index.d.ts +153 -3
- package/dist/lib/index.js +65 -26
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +6 -6
- package/dist/lib/integrations/index.d.ts +2 -2
- package/dist/lib/integrations/index.js +10 -10
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +5 -5
- package/dist/lib/integrations/nest/index.d.ts +1 -1
- package/dist/lib/integrations/nest/index.js +10 -10
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +3 -3
- package/dist/lib/integrations/node-express/index.d.ts +1 -1
- package/dist/lib/integrations/node-express/index.js +10 -10
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +3 -3
- package/dist/lib/integrations/node-http/index.d.ts +1 -1
- package/dist/lib/integrations/node-http/index.js +10 -10
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +2 -2
- package/dist/{shared-41d4988d.d.ts → shared-6b6dbf8b.d.ts} +1 -3
- package/package.json +11 -11
- package/src/lib/runtime/__tests__/mcp-tools-utils.test.ts +464 -0
- package/src/lib/runtime/copilot-runtime.ts +1 -3
- package/src/lib/runtime/mcp-tools-utils.ts +84 -18
- package/dist/chunk-WLLDTXG6.mjs.map +0 -1
- /package/dist/{chunk-MQNSNCJU.mjs.map → chunk-ECQRTXJX.mjs.map} +0 -0
- /package/dist/{chunk-Z2HSWVJ6.mjs.map → chunk-FR4C3TPU.mjs.map} +0 -0
- /package/dist/{chunk-YSRDTT3V.mjs.map → chunk-S2YGYQDH.mjs.map} +0 -0
- /package/dist/{chunk-UOSL5GYI.mjs.map → chunk-TBVA4IGX.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @copilotkit/runtime
|
|
2
2
|
|
|
3
|
+
## 1.9.2-next.24
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8ef8199: - fix: use latest agui dependencies to include required fixes
|
|
8
|
+
- @copilotkit/shared@1.9.2-next.24
|
|
9
|
+
|
|
10
|
+
## 1.9.2-next.23
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- fc6b653: - Fix extract toolParameters in extractParametersFromSchema
|
|
15
|
+
- Ensures consistency in how parameters are passed to the execute function across the codebase.
|
|
16
|
+
- fc6b653: - Fix extract toolParameters in extractParametersFromSchema
|
|
17
|
+
- Fixed generateMcpToolInstructions to properly extract parameters from schema.parameters.properties
|
|
18
|
+
- fix: enhance MCP schema support for complex types and remove duplicate headers
|
|
19
|
+
- fc6b653: - Fix extract toolParameters in extractParametersFromSchema
|
|
20
|
+
- @copilotkit/shared@1.9.2-next.23
|
|
21
|
+
|
|
3
22
|
## 1.9.2-next.22
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
copilotRuntimeNodeHttpEndpoint,
|
|
3
3
|
getRuntimeInstanceTelemetryInfo,
|
|
4
4
|
telemetry_client_default
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-GAUZHH2X.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-
|
|
25
|
+
//# sourceMappingURL=chunk-ECQRTXJX.mjs.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
copilotRuntimeNodeHttpEndpoint,
|
|
3
3
|
getRuntimeInstanceTelemetryInfo,
|
|
4
4
|
telemetry_client_default
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-GAUZHH2X.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-
|
|
25
|
+
//# sourceMappingURL=chunk-FR4C3TPU.mjs.map
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ActionExecutionMessage,
|
|
3
|
-
AgentStateMessage,
|
|
4
|
-
ImageMessage,
|
|
5
|
-
ResultMessage,
|
|
6
|
-
TextMessage
|
|
7
|
-
} from "./chunk-SHBDMA63.mjs";
|
|
8
1
|
import {
|
|
9
2
|
EmptyAdapter,
|
|
10
3
|
RemoteChain,
|
|
@@ -17,6 +10,13 @@ import {
|
|
|
17
10
|
SuccessResponseStatus,
|
|
18
11
|
UnknownErrorResponse
|
|
19
12
|
} from "./chunk-XWBDEXDA.mjs";
|
|
13
|
+
import {
|
|
14
|
+
ActionExecutionMessage,
|
|
15
|
+
AgentStateMessage,
|
|
16
|
+
ImageMessage,
|
|
17
|
+
ResultMessage,
|
|
18
|
+
TextMessage
|
|
19
|
+
} from "./chunk-SHBDMA63.mjs";
|
|
20
20
|
import {
|
|
21
21
|
BaseMessageInput
|
|
22
22
|
} from "./chunk-2OZAGFV3.mjs";
|
|
@@ -40,7 +40,7 @@ var require_package = __commonJS({
|
|
|
40
40
|
publishConfig: {
|
|
41
41
|
access: "public"
|
|
42
42
|
},
|
|
43
|
-
version: "1.9.2-next.
|
|
43
|
+
version: "1.9.2-next.24",
|
|
44
44
|
sideEffects: false,
|
|
45
45
|
main: "./dist/index.js",
|
|
46
46
|
module: "./dist/index.mjs",
|
|
@@ -78,11 +78,11 @@ var require_package = __commonJS({
|
|
|
78
78
|
"zod-to-json-schema": "^3.23.5"
|
|
79
79
|
},
|
|
80
80
|
dependencies: {
|
|
81
|
-
"@ag-ui/client": "0.0.
|
|
82
|
-
"@ag-ui/core": "0.0.
|
|
83
|
-
"@ag-ui/encoder": "0.0.
|
|
84
|
-
"@ag-ui/langgraph": "0.0.
|
|
85
|
-
"@ag-ui/proto": "0.0.
|
|
81
|
+
"@ag-ui/client": "0.0.34",
|
|
82
|
+
"@ag-ui/core": "0.0.34",
|
|
83
|
+
"@ag-ui/encoder": "0.0.34",
|
|
84
|
+
"@ag-ui/langgraph": "0.0.6",
|
|
85
|
+
"@ag-ui/proto": "0.0.34",
|
|
86
86
|
"@anthropic-ai/sdk": "^0.27.3",
|
|
87
87
|
"@copilotkit/shared": "workspace:*",
|
|
88
88
|
"@graphql-yoga/plugin-defer-stream": "^3.3.1",
|
|
@@ -110,10 +110,10 @@ var require_package = __commonJS({
|
|
|
110
110
|
zod: "^3.23.3"
|
|
111
111
|
},
|
|
112
112
|
peerDependencies: {
|
|
113
|
-
"@ag-ui/client": ">=0.0.
|
|
114
|
-
"@ag-ui/core": ">=0.0.
|
|
115
|
-
"@ag-ui/encoder": ">=0.0.
|
|
116
|
-
"@ag-ui/proto": ">=0.0.
|
|
113
|
+
"@ag-ui/client": ">=0.0.34",
|
|
114
|
+
"@ag-ui/core": ">=0.0.34",
|
|
115
|
+
"@ag-ui/encoder": ">=0.0.34",
|
|
116
|
+
"@ag-ui/proto": ">=0.0.34"
|
|
117
117
|
},
|
|
118
118
|
keywords: [
|
|
119
119
|
"copilotkit",
|
|
@@ -2632,7 +2632,7 @@ function extractParametersFromSchema(toolOrSchema) {
|
|
|
2632
2632
|
var _a;
|
|
2633
2633
|
const parameters = [];
|
|
2634
2634
|
const schema = "schema" in (toolOrSchema || {}) ? toolOrSchema.schema : toolOrSchema;
|
|
2635
|
-
const toolParameters = (schema == null ? void 0 : schema.parameters)
|
|
2635
|
+
const toolParameters = ((_a = schema == null ? void 0 : schema.parameters) == null ? void 0 : _a.jsonSchema) || (schema == null ? void 0 : schema.parameters);
|
|
2636
2636
|
const properties = toolParameters == null ? void 0 : toolParameters.properties;
|
|
2637
2637
|
const requiredParams = new Set((toolParameters == null ? void 0 : toolParameters.required) || []);
|
|
2638
2638
|
if (!properties) {
|
|
@@ -2641,12 +2641,29 @@ function extractParametersFromSchema(toolOrSchema) {
|
|
|
2641
2641
|
for (const paramName in properties) {
|
|
2642
2642
|
if (Object.prototype.hasOwnProperty.call(properties, paramName)) {
|
|
2643
2643
|
const paramDef = properties[paramName];
|
|
2644
|
+
let type = paramDef.type || "string";
|
|
2645
|
+
let description = paramDef.description || "";
|
|
2646
|
+
if (type === "array" && paramDef.items) {
|
|
2647
|
+
const itemType = paramDef.items.type || "object";
|
|
2648
|
+
if (itemType === "object" && paramDef.items.properties) {
|
|
2649
|
+
const itemProperties = Object.keys(paramDef.items.properties).join(", ");
|
|
2650
|
+
description = description + (description ? " " : "") + `Array of objects with properties: ${itemProperties}`;
|
|
2651
|
+
} else {
|
|
2652
|
+
type = `array<${itemType}>`;
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
if (paramDef.enum && Array.isArray(paramDef.enum)) {
|
|
2656
|
+
const enumValues = paramDef.enum.join(" | ");
|
|
2657
|
+
description = description + (description ? " " : "") + `Allowed values: ${enumValues}`;
|
|
2658
|
+
}
|
|
2659
|
+
if (type === "object" && paramDef.properties) {
|
|
2660
|
+
const objectProperties = Object.keys(paramDef.properties).join(", ");
|
|
2661
|
+
description = description + (description ? " " : "") + `Object with properties: ${objectProperties}`;
|
|
2662
|
+
}
|
|
2644
2663
|
parameters.push({
|
|
2645
2664
|
name: paramName,
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
type: paramDef.type || "string",
|
|
2649
|
-
description: paramDef.description,
|
|
2665
|
+
type,
|
|
2666
|
+
description,
|
|
2650
2667
|
required: requiredParams.has(paramName)
|
|
2651
2668
|
});
|
|
2652
2669
|
}
|
|
@@ -2660,9 +2677,7 @@ function convertMCPToolsToActions(mcpTools, mcpEndpoint) {
|
|
|
2660
2677
|
const parameters = extractParametersFromSchema(tool);
|
|
2661
2678
|
const handler = /* @__PURE__ */ __name(async (params) => {
|
|
2662
2679
|
try {
|
|
2663
|
-
const result = await tool.execute(
|
|
2664
|
-
params
|
|
2665
|
-
});
|
|
2680
|
+
const result = await tool.execute(params);
|
|
2666
2681
|
return typeof result === "string" ? result : JSON.stringify(result);
|
|
2667
2682
|
} catch (error) {
|
|
2668
2683
|
console.error(`Error executing MCP tool '${toolName}' from endpoint ${mcpEndpoint}:`, error);
|
|
@@ -2688,17 +2703,38 @@ function generateMcpToolInstructions(toolsMap) {
|
|
|
2688
2703
|
}
|
|
2689
2704
|
const toolEntries = Object.entries(toolsMap);
|
|
2690
2705
|
const toolsDoc = toolEntries.map(([name, tool]) => {
|
|
2706
|
+
var _a;
|
|
2691
2707
|
let paramsDoc = " No parameters required";
|
|
2692
2708
|
try {
|
|
2693
2709
|
if (tool.schema && typeof tool.schema === "object") {
|
|
2694
2710
|
const schema = tool.schema;
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2711
|
+
const toolParameters = ((_a = schema.parameters) == null ? void 0 : _a.jsonSchema) || schema.parameters;
|
|
2712
|
+
const properties = (toolParameters == null ? void 0 : toolParameters.properties) || schema.properties;
|
|
2713
|
+
const requiredParams = (toolParameters == null ? void 0 : toolParameters.required) || schema.required || [];
|
|
2714
|
+
if (properties) {
|
|
2715
|
+
const paramsList = Object.entries(properties).map(([paramName, propSchema]) => {
|
|
2698
2716
|
const propDetails = propSchema;
|
|
2699
2717
|
const requiredMark = requiredParams.includes(paramName) ? "*" : "";
|
|
2700
|
-
|
|
2701
|
-
|
|
2718
|
+
let typeInfo = propDetails.type || "any";
|
|
2719
|
+
let description = propDetails.description ? ` - ${propDetails.description}` : "";
|
|
2720
|
+
if (typeInfo === "array" && propDetails.items) {
|
|
2721
|
+
const itemType = propDetails.items.type || "object";
|
|
2722
|
+
if (itemType === "object" && propDetails.items.properties) {
|
|
2723
|
+
const itemProps = Object.keys(propDetails.items.properties).join(", ");
|
|
2724
|
+
typeInfo = `array<object>`;
|
|
2725
|
+
description = description + (description ? " " : " - ") + `Array of objects with properties: ${itemProps}`;
|
|
2726
|
+
} else {
|
|
2727
|
+
typeInfo = `array<${itemType}>`;
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
if (propDetails.enum && Array.isArray(propDetails.enum)) {
|
|
2731
|
+
const enumValues = propDetails.enum.join(" | ");
|
|
2732
|
+
description = description + (description ? " " : " - ") + `Allowed values: ${enumValues}`;
|
|
2733
|
+
}
|
|
2734
|
+
if (typeInfo === "object" && propDetails.properties) {
|
|
2735
|
+
const objectProps = Object.keys(propDetails.properties).join(", ");
|
|
2736
|
+
description = description + (description ? " " : " - ") + `Object with properties: ${objectProps}`;
|
|
2737
|
+
}
|
|
2702
2738
|
return ` - ${paramName}${requiredMark} (${typeInfo})${description}`;
|
|
2703
2739
|
});
|
|
2704
2740
|
if (paramsList.length > 0) {
|
|
@@ -2719,8 +2755,11 @@ ${toolsDoc}
|
|
|
2719
2755
|
When using these tools:
|
|
2720
2756
|
1. Only provide valid parameters according to their type requirements
|
|
2721
2757
|
2. Required parameters are marked with *
|
|
2722
|
-
3.
|
|
2723
|
-
4.
|
|
2758
|
+
3. For array parameters, provide data in the correct array format
|
|
2759
|
+
4. For object parameters, include all required nested properties
|
|
2760
|
+
5. For enum parameters, use only the allowed values listed
|
|
2761
|
+
6. Format API calls correctly with the expected parameter structure
|
|
2762
|
+
7. Always check tool responses to determine your next action`;
|
|
2724
2763
|
}
|
|
2725
2764
|
__name(generateMcpToolInstructions, "generateMcpToolInstructions");
|
|
2726
2765
|
|
|
@@ -2807,7 +2846,7 @@ var CopilotRuntime = class {
|
|
|
2807
2846
|
if (!mcpToolInstructions) {
|
|
2808
2847
|
return messages;
|
|
2809
2848
|
}
|
|
2810
|
-
const instructions =
|
|
2849
|
+
const instructions = mcpToolInstructions + "\nUse them when appropriate to fulfill the user's request.";
|
|
2811
2850
|
const systemMessageIndex = messages.findIndex((msg) => {
|
|
2812
2851
|
var _a;
|
|
2813
2852
|
return ((_a = msg.textMessage) == null ? void 0 : _a.role) === "system";
|
|
@@ -5824,4 +5863,4 @@ export {
|
|
|
5824
5863
|
getCommonConfig,
|
|
5825
5864
|
copilotRuntimeNodeHttpEndpoint
|
|
5826
5865
|
};
|
|
5827
|
-
//# sourceMappingURL=chunk-
|
|
5866
|
+
//# sourceMappingURL=chunk-GAUZHH2X.mjs.map
|