@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.
- package/CHANGELOG.md +17 -0
- package/dist/{chunk-3UU33HF6.mjs → chunk-AFJ3VQB4.mjs} +2 -2
- package/dist/{chunk-QF6GPOZV.mjs → chunk-HEKLYCFM.mjs} +2 -2
- package/dist/{chunk-HBCCZQBE.mjs → chunk-LFB4PE32.mjs} +64 -6
- package/dist/chunk-LFB4PE32.mjs.map +1 -0
- package/dist/{chunk-O4WMMGSX.mjs → chunk-TPDMN2N7.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-HBCCZQBE.mjs.map +0 -1
- /package/dist/{chunk-3UU33HF6.mjs.map → chunk-AFJ3VQB4.mjs.map} +0 -0
- /package/dist/{chunk-QF6GPOZV.mjs.map → chunk-HEKLYCFM.mjs.map} +0 -0
- /package/dist/{chunk-O4WMMGSX.mjs.map → chunk-TPDMN2N7.mjs.map} +0 -0
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
copilotRuntimeNodeHttpEndpoint,
|
|
3
3
|
getRuntimeInstanceTelemetryInfo,
|
|
4
4
|
telemetry_client_default
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-LFB4PE32.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-TPDMN2N7.mjs.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { G as GoogleGenerativeAIAdapter, f as GroqAdapter, e as GroqAdapterParams, L as LangChainAdapter, a as OpenAIAdapter, O as OpenAIAdapterParams, c as OpenAIAssistantAdapter, b as OpenAIAssistantAdapterParams, d as UnifyAdapter, U as UnifyAdapterParams } from './groq-adapter-53d3fa48.js';
|
|
2
|
-
export { e as CommonConfig, C as CopilotRequestContextProperties, k as CopilotRuntime, j as CopilotRuntimeConstructorParams, f as CopilotRuntimeLogger, i as CopilotRuntimeRequest, b as CreateCopilotRuntimeServerOptions, G as GraphQLContext, L as LogLevel, o as MCPClient, p as MCPEndpointConfig, M as MCPTool, a as addCustomHeaderPlugin, d as buildSchema, s as convertMCPToolsToActions, m as copilotKitEndpoint, c as createContext, h as createLogger, q as extractParametersFromSchema, l as flattenToolCallsNoDuplicates, g as getCommonConfig, n as langGraphPlatformEndpoint, r as resolveEndpointType } from './shared-
|
|
2
|
+
export { e as CommonConfig, C as CopilotRequestContextProperties, k as CopilotRuntime, j as CopilotRuntimeConstructorParams, f as CopilotRuntimeLogger, i as CopilotRuntimeRequest, b as CreateCopilotRuntimeServerOptions, G as GraphQLContext, L as LogLevel, o as MCPClient, p as MCPEndpointConfig, M as MCPTool, a as addCustomHeaderPlugin, d as buildSchema, s as convertMCPToolsToActions, m as copilotKitEndpoint, c as createContext, h as createLogger, q as extractParametersFromSchema, l as flattenToolCallsNoDuplicates, t as generateMcpToolInstructions, g as getCommonConfig, n as langGraphPlatformEndpoint, r as resolveEndpointType } from './shared-df478d34.js';
|
|
3
3
|
export { CopilotRuntimeServerInstance, config, copilotRuntimeNextJSAppRouterEndpoint, copilotRuntimeNextJSPagesRouterEndpoint } from './lib/integrations/index.js';
|
|
4
4
|
export { copilotRuntimeNodeHttpEndpoint } from './lib/integrations/node-http/index.js';
|
|
5
5
|
export { copilotRuntimeNodeExpressEndpoint } from './lib/integrations/node-express/index.js';
|
package/dist/index.js
CHANGED
|
@@ -44,7 +44,7 @@ var require_package = __commonJS({
|
|
|
44
44
|
publishConfig: {
|
|
45
45
|
access: "public"
|
|
46
46
|
},
|
|
47
|
-
version: "1.8.
|
|
47
|
+
version: "1.8.9-next.0",
|
|
48
48
|
sideEffects: false,
|
|
49
49
|
main: "./dist/index.js",
|
|
50
50
|
module: "./dist/index.mjs",
|
|
@@ -158,6 +158,7 @@ __export(src_exports, {
|
|
|
158
158
|
createLogger: () => createLogger,
|
|
159
159
|
extractParametersFromSchema: () => extractParametersFromSchema,
|
|
160
160
|
flattenToolCallsNoDuplicates: () => flattenToolCallsNoDuplicates,
|
|
161
|
+
generateMcpToolInstructions: () => generateMcpToolInstructions,
|
|
161
162
|
getCommonConfig: () => getCommonConfig,
|
|
162
163
|
langGraphPlatformEndpoint: () => langGraphPlatformEndpoint,
|
|
163
164
|
resolveEndpointType: () => resolveEndpointType
|
|
@@ -4798,6 +4799,47 @@ function convertMCPToolsToActions(mcpTools, mcpEndpoint) {
|
|
|
4798
4799
|
return actions;
|
|
4799
4800
|
}
|
|
4800
4801
|
__name(convertMCPToolsToActions, "convertMCPToolsToActions");
|
|
4802
|
+
function generateMcpToolInstructions(toolsMap) {
|
|
4803
|
+
if (!toolsMap || Object.keys(toolsMap).length === 0) {
|
|
4804
|
+
return "";
|
|
4805
|
+
}
|
|
4806
|
+
const toolEntries = Object.entries(toolsMap);
|
|
4807
|
+
const toolsDoc = toolEntries.map(([name, tool]) => {
|
|
4808
|
+
let paramsDoc = " No parameters required";
|
|
4809
|
+
try {
|
|
4810
|
+
if (tool.schema && typeof tool.schema === "object") {
|
|
4811
|
+
const schema = tool.schema;
|
|
4812
|
+
if (schema.properties) {
|
|
4813
|
+
const requiredParams = schema.required || [];
|
|
4814
|
+
const paramsList = Object.entries(schema.properties).map(([paramName, propSchema]) => {
|
|
4815
|
+
const propDetails = propSchema;
|
|
4816
|
+
const requiredMark = requiredParams.includes(paramName) ? "*" : "";
|
|
4817
|
+
const typeInfo = propDetails.type || "any";
|
|
4818
|
+
const description = propDetails.description ? ` - ${propDetails.description}` : "";
|
|
4819
|
+
return ` - ${paramName}${requiredMark} (${typeInfo})${description}`;
|
|
4820
|
+
});
|
|
4821
|
+
if (paramsList.length > 0) {
|
|
4822
|
+
paramsDoc = paramsList.join("\n");
|
|
4823
|
+
}
|
|
4824
|
+
}
|
|
4825
|
+
}
|
|
4826
|
+
} catch (e) {
|
|
4827
|
+
console.error(`Error parsing schema for tool ${name}:`, e);
|
|
4828
|
+
}
|
|
4829
|
+
return `- ${name}: ${tool.description || ""}
|
|
4830
|
+
${paramsDoc}`;
|
|
4831
|
+
}).join("\n\n");
|
|
4832
|
+
return `You have access to the following external tools provided by Model Context Protocol (MCP) servers:
|
|
4833
|
+
|
|
4834
|
+
${toolsDoc}
|
|
4835
|
+
|
|
4836
|
+
When using these tools:
|
|
4837
|
+
1. Only provide valid parameters according to their type requirements
|
|
4838
|
+
2. Required parameters are marked with *
|
|
4839
|
+
3. Format API calls correctly with the expected parameter structure
|
|
4840
|
+
4. Always check tool responses to determine your next action`;
|
|
4841
|
+
}
|
|
4842
|
+
__name(generateMcpToolInstructions, "generateMcpToolInstructions");
|
|
4801
4843
|
|
|
4802
4844
|
// src/lib/runtime/copilot-runtime.ts
|
|
4803
4845
|
var CopilotRuntime = class {
|
|
@@ -4855,10 +4897,26 @@ var CopilotRuntime = class {
|
|
|
4855
4897
|
mcpActionsForRequest.forEach((action) => {
|
|
4856
4898
|
uniqueMcpTools.set(action.name, action);
|
|
4857
4899
|
});
|
|
4858
|
-
const
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4900
|
+
const toolsMap = {};
|
|
4901
|
+
Array.from(uniqueMcpTools.values()).forEach((action) => {
|
|
4902
|
+
toolsMap[action.name] = {
|
|
4903
|
+
description: action.description || "",
|
|
4904
|
+
schema: action.parameters ? {
|
|
4905
|
+
parameters: {
|
|
4906
|
+
properties: action.parameters.reduce((acc, p) => ({
|
|
4907
|
+
...acc,
|
|
4908
|
+
[p.name]: {
|
|
4909
|
+
type: p.type,
|
|
4910
|
+
description: p.description
|
|
4911
|
+
}
|
|
4912
|
+
}), {}),
|
|
4913
|
+
required: action.parameters.filter((p) => p.required).map((p) => p.name)
|
|
4914
|
+
}
|
|
4915
|
+
} : {},
|
|
4916
|
+
execute: async () => ({})
|
|
4917
|
+
};
|
|
4918
|
+
});
|
|
4919
|
+
const mcpToolInstructions = generateMcpToolInstructions(toolsMap);
|
|
4862
4920
|
if (!mcpToolInstructions) {
|
|
4863
4921
|
return messages;
|
|
4864
4922
|
}
|
|
@@ -6921,6 +6979,7 @@ __name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
|
|
|
6921
6979
|
createLogger,
|
|
6922
6980
|
extractParametersFromSchema,
|
|
6923
6981
|
flattenToolCallsNoDuplicates,
|
|
6982
|
+
generateMcpToolInstructions,
|
|
6924
6983
|
getCommonConfig,
|
|
6925
6984
|
langGraphPlatformEndpoint,
|
|
6926
6985
|
resolveEndpointType
|