@copilotkit/runtime 1.8.8 → 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 +8 -0
- package/dist/{chunk-HAIKRVPW.mjs → chunk-AFJ3VQB4.mjs} +2 -2
- package/dist/{chunk-UKGY3PWM.mjs → chunk-HEKLYCFM.mjs} +2 -2
- package/dist/{chunk-3R446VII.mjs → chunk-LFB4PE32.mjs} +64 -6
- package/dist/chunk-LFB4PE32.mjs.map +1 -0
- package/dist/{chunk-PTBPJ2YQ.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-3R446VII.mjs.map +0 -1
- /package/dist/{chunk-HAIKRVPW.mjs.map → chunk-AFJ3VQB4.mjs.map} +0 -0
- /package/dist/{chunk-UKGY3PWM.mjs.map → chunk-HEKLYCFM.mjs.map} +0 -0
- /package/dist/{chunk-PTBPJ2YQ.mjs.map → chunk-TPDMN2N7.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
config,
|
|
4
4
|
copilotRuntimeNextJSAppRouterEndpoint,
|
|
5
5
|
copilotRuntimeNextJSPagesRouterEndpoint
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-HEKLYCFM.mjs";
|
|
7
7
|
import {
|
|
8
8
|
copilotRuntimeNestEndpoint
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-TPDMN2N7.mjs";
|
|
10
10
|
import {
|
|
11
11
|
copilotRuntimeNodeExpressEndpoint
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-AFJ3VQB4.mjs";
|
|
13
13
|
import {
|
|
14
14
|
CopilotRuntime,
|
|
15
15
|
addCustomHeaderPlugin,
|
|
@@ -21,10 +21,11 @@ import {
|
|
|
21
21
|
createLogger,
|
|
22
22
|
extractParametersFromSchema,
|
|
23
23
|
flattenToolCallsNoDuplicates,
|
|
24
|
+
generateMcpToolInstructions,
|
|
24
25
|
getCommonConfig,
|
|
25
26
|
langGraphPlatformEndpoint,
|
|
26
27
|
resolveEndpointType
|
|
27
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-LFB4PE32.mjs";
|
|
28
29
|
import {
|
|
29
30
|
AnthropicAdapter,
|
|
30
31
|
EmptyAdapter,
|
|
@@ -79,6 +80,7 @@ export {
|
|
|
79
80
|
createLogger,
|
|
80
81
|
extractParametersFromSchema,
|
|
81
82
|
flattenToolCallsNoDuplicates,
|
|
83
|
+
generateMcpToolInstructions,
|
|
82
84
|
getCommonConfig,
|
|
83
85
|
langGraphPlatformEndpoint,
|
|
84
86
|
resolveEndpointType
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import \"reflect-metadata\";\nexport * from \"./lib\";\nexport * from \"./utils\";\nexport * from \"./service-adapters\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import \"reflect-metadata\";\nexport * from \"./lib\";\nexport * from \"./utils\";\nexport * from \"./service-adapters\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO;","names":[]}
|
package/dist/lib/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 './integrations/index.js';
|
|
4
4
|
export { copilotRuntimeNodeHttpEndpoint } from './integrations/node-http/index.js';
|
|
5
5
|
export { copilotRuntimeNodeExpressEndpoint } from './integrations/node-express/index.js';
|
package/dist/lib/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",
|
|
@@ -150,6 +150,7 @@ __export(lib_exports, {
|
|
|
150
150
|
createLogger: () => createLogger,
|
|
151
151
|
extractParametersFromSchema: () => extractParametersFromSchema,
|
|
152
152
|
flattenToolCallsNoDuplicates: () => flattenToolCallsNoDuplicates,
|
|
153
|
+
generateMcpToolInstructions: () => generateMcpToolInstructions,
|
|
153
154
|
getCommonConfig: () => getCommonConfig,
|
|
154
155
|
langGraphPlatformEndpoint: () => langGraphPlatformEndpoint,
|
|
155
156
|
resolveEndpointType: () => resolveEndpointType
|
|
@@ -4431,6 +4432,47 @@ function convertMCPToolsToActions(mcpTools, mcpEndpoint) {
|
|
|
4431
4432
|
return actions;
|
|
4432
4433
|
}
|
|
4433
4434
|
__name(convertMCPToolsToActions, "convertMCPToolsToActions");
|
|
4435
|
+
function generateMcpToolInstructions(toolsMap) {
|
|
4436
|
+
if (!toolsMap || Object.keys(toolsMap).length === 0) {
|
|
4437
|
+
return "";
|
|
4438
|
+
}
|
|
4439
|
+
const toolEntries = Object.entries(toolsMap);
|
|
4440
|
+
const toolsDoc = toolEntries.map(([name, tool]) => {
|
|
4441
|
+
let paramsDoc = " No parameters required";
|
|
4442
|
+
try {
|
|
4443
|
+
if (tool.schema && typeof tool.schema === "object") {
|
|
4444
|
+
const schema = tool.schema;
|
|
4445
|
+
if (schema.properties) {
|
|
4446
|
+
const requiredParams = schema.required || [];
|
|
4447
|
+
const paramsList = Object.entries(schema.properties).map(([paramName, propSchema]) => {
|
|
4448
|
+
const propDetails = propSchema;
|
|
4449
|
+
const requiredMark = requiredParams.includes(paramName) ? "*" : "";
|
|
4450
|
+
const typeInfo = propDetails.type || "any";
|
|
4451
|
+
const description = propDetails.description ? ` - ${propDetails.description}` : "";
|
|
4452
|
+
return ` - ${paramName}${requiredMark} (${typeInfo})${description}`;
|
|
4453
|
+
});
|
|
4454
|
+
if (paramsList.length > 0) {
|
|
4455
|
+
paramsDoc = paramsList.join("\n");
|
|
4456
|
+
}
|
|
4457
|
+
}
|
|
4458
|
+
}
|
|
4459
|
+
} catch (e) {
|
|
4460
|
+
console.error(`Error parsing schema for tool ${name}:`, e);
|
|
4461
|
+
}
|
|
4462
|
+
return `- ${name}: ${tool.description || ""}
|
|
4463
|
+
${paramsDoc}`;
|
|
4464
|
+
}).join("\n\n");
|
|
4465
|
+
return `You have access to the following external tools provided by Model Context Protocol (MCP) servers:
|
|
4466
|
+
|
|
4467
|
+
${toolsDoc}
|
|
4468
|
+
|
|
4469
|
+
When using these tools:
|
|
4470
|
+
1. Only provide valid parameters according to their type requirements
|
|
4471
|
+
2. Required parameters are marked with *
|
|
4472
|
+
3. Format API calls correctly with the expected parameter structure
|
|
4473
|
+
4. Always check tool responses to determine your next action`;
|
|
4474
|
+
}
|
|
4475
|
+
__name(generateMcpToolInstructions, "generateMcpToolInstructions");
|
|
4434
4476
|
|
|
4435
4477
|
// src/lib/runtime/copilot-runtime.ts
|
|
4436
4478
|
var CopilotRuntime = class {
|
|
@@ -4488,10 +4530,26 @@ var CopilotRuntime = class {
|
|
|
4488
4530
|
mcpActionsForRequest.forEach((action) => {
|
|
4489
4531
|
uniqueMcpTools.set(action.name, action);
|
|
4490
4532
|
});
|
|
4491
|
-
const
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4533
|
+
const toolsMap = {};
|
|
4534
|
+
Array.from(uniqueMcpTools.values()).forEach((action) => {
|
|
4535
|
+
toolsMap[action.name] = {
|
|
4536
|
+
description: action.description || "",
|
|
4537
|
+
schema: action.parameters ? {
|
|
4538
|
+
parameters: {
|
|
4539
|
+
properties: action.parameters.reduce((acc, p) => ({
|
|
4540
|
+
...acc,
|
|
4541
|
+
[p.name]: {
|
|
4542
|
+
type: p.type,
|
|
4543
|
+
description: p.description
|
|
4544
|
+
}
|
|
4545
|
+
}), {}),
|
|
4546
|
+
required: action.parameters.filter((p) => p.required).map((p) => p.name)
|
|
4547
|
+
}
|
|
4548
|
+
} : {},
|
|
4549
|
+
execute: async () => ({})
|
|
4550
|
+
};
|
|
4551
|
+
});
|
|
4552
|
+
const mcpToolInstructions = generateMcpToolInstructions(toolsMap);
|
|
4495
4553
|
if (!mcpToolInstructions) {
|
|
4496
4554
|
return messages;
|
|
4497
4555
|
}
|
|
@@ -6546,6 +6604,7 @@ __name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
|
|
|
6546
6604
|
createLogger,
|
|
6547
6605
|
extractParametersFromSchema,
|
|
6548
6606
|
flattenToolCallsNoDuplicates,
|
|
6607
|
+
generateMcpToolInstructions,
|
|
6549
6608
|
getCommonConfig,
|
|
6550
6609
|
langGraphPlatformEndpoint,
|
|
6551
6610
|
resolveEndpointType
|