@copilotkit/runtime 1.9.2-next.22 → 1.9.2-next.23
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 +12 -0
- package/dist/{chunk-YSRDTT3V.mjs → chunk-C6PCDSTD.mjs} +2 -2
- package/dist/{chunk-WLLDTXG6.mjs → chunk-FIA5HRU2.mjs} +57 -18
- package/dist/chunk-FIA5HRU2.mjs.map +1 -0
- package/dist/{chunk-UOSL5GYI.mjs → chunk-HZW6X63M.mjs} +2 -2
- package/dist/{chunk-MQNSNCJU.mjs → chunk-LYXJJDV3.mjs} +2 -2
- package/dist/{chunk-Z2HSWVJ6.mjs → chunk-ZQUGWRVU.mjs} +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +56 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +56 -17
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +5 -5
- 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-41d4988d.d.ts → shared-6b6dbf8b.d.ts} +1 -3
- package/package.json +2 -2
- 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-YSRDTT3V.mjs.map → chunk-C6PCDSTD.mjs.map} +0 -0
- /package/dist/{chunk-UOSL5GYI.mjs.map → chunk-HZW6X63M.mjs.map} +0 -0
- /package/dist/{chunk-MQNSNCJU.mjs.map → chunk-LYXJJDV3.mjs.map} +0 -0
- /package/dist/{chunk-Z2HSWVJ6.mjs.map → chunk-ZQUGWRVU.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CustomEventNames,
|
|
3
3
|
LangGraphAgent
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-C6PCDSTD.mjs";
|
|
5
5
|
import {
|
|
6
6
|
config,
|
|
7
7
|
copilotRuntimeNextJSAppRouterEndpoint,
|
|
8
8
|
copilotRuntimeNextJSPagesRouterEndpoint
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-HZW6X63M.mjs";
|
|
10
10
|
import {
|
|
11
11
|
copilotRuntimeNestEndpoint
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-LYXJJDV3.mjs";
|
|
13
13
|
import {
|
|
14
14
|
copilotRuntimeNodeExpressEndpoint
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-ZQUGWRVU.mjs";
|
|
16
16
|
import {
|
|
17
17
|
CopilotRuntime,
|
|
18
18
|
addCustomHeaderPlugin,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
getCommonConfig,
|
|
29
29
|
langGraphPlatformEndpoint,
|
|
30
30
|
resolveEndpointType
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-FIA5HRU2.mjs";
|
|
32
32
|
import "./chunk-SHBDMA63.mjs";
|
|
33
33
|
import {
|
|
34
34
|
AnthropicAdapter,
|
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-098f97f6.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, t as generateMcpToolInstructions, 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-6b6dbf8b.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.9.2-next.
|
|
47
|
+
version: "1.9.2-next.23",
|
|
48
48
|
sideEffects: false,
|
|
49
49
|
main: "./dist/index.js",
|
|
50
50
|
module: "./dist/index.mjs",
|
|
@@ -4149,7 +4149,7 @@ function extractParametersFromSchema(toolOrSchema) {
|
|
|
4149
4149
|
var _a;
|
|
4150
4150
|
const parameters = [];
|
|
4151
4151
|
const schema = "schema" in (toolOrSchema || {}) ? toolOrSchema.schema : toolOrSchema;
|
|
4152
|
-
const toolParameters = (schema == null ? void 0 : schema.parameters)
|
|
4152
|
+
const toolParameters = ((_a = schema == null ? void 0 : schema.parameters) == null ? void 0 : _a.jsonSchema) || (schema == null ? void 0 : schema.parameters);
|
|
4153
4153
|
const properties = toolParameters == null ? void 0 : toolParameters.properties;
|
|
4154
4154
|
const requiredParams = new Set((toolParameters == null ? void 0 : toolParameters.required) || []);
|
|
4155
4155
|
if (!properties) {
|
|
@@ -4158,12 +4158,29 @@ function extractParametersFromSchema(toolOrSchema) {
|
|
|
4158
4158
|
for (const paramName in properties) {
|
|
4159
4159
|
if (Object.prototype.hasOwnProperty.call(properties, paramName)) {
|
|
4160
4160
|
const paramDef = properties[paramName];
|
|
4161
|
+
let type = paramDef.type || "string";
|
|
4162
|
+
let description = paramDef.description || "";
|
|
4163
|
+
if (type === "array" && paramDef.items) {
|
|
4164
|
+
const itemType = paramDef.items.type || "object";
|
|
4165
|
+
if (itemType === "object" && paramDef.items.properties) {
|
|
4166
|
+
const itemProperties = Object.keys(paramDef.items.properties).join(", ");
|
|
4167
|
+
description = description + (description ? " " : "") + `Array of objects with properties: ${itemProperties}`;
|
|
4168
|
+
} else {
|
|
4169
|
+
type = `array<${itemType}>`;
|
|
4170
|
+
}
|
|
4171
|
+
}
|
|
4172
|
+
if (paramDef.enum && Array.isArray(paramDef.enum)) {
|
|
4173
|
+
const enumValues = paramDef.enum.join(" | ");
|
|
4174
|
+
description = description + (description ? " " : "") + `Allowed values: ${enumValues}`;
|
|
4175
|
+
}
|
|
4176
|
+
if (type === "object" && paramDef.properties) {
|
|
4177
|
+
const objectProperties = Object.keys(paramDef.properties).join(", ");
|
|
4178
|
+
description = description + (description ? " " : "") + `Object with properties: ${objectProperties}`;
|
|
4179
|
+
}
|
|
4161
4180
|
parameters.push({
|
|
4162
4181
|
name: paramName,
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
type: paramDef.type || "string",
|
|
4166
|
-
description: paramDef.description,
|
|
4182
|
+
type,
|
|
4183
|
+
description,
|
|
4167
4184
|
required: requiredParams.has(paramName)
|
|
4168
4185
|
});
|
|
4169
4186
|
}
|
|
@@ -4177,9 +4194,7 @@ function convertMCPToolsToActions(mcpTools, mcpEndpoint) {
|
|
|
4177
4194
|
const parameters = extractParametersFromSchema(tool);
|
|
4178
4195
|
const handler = /* @__PURE__ */ __name(async (params) => {
|
|
4179
4196
|
try {
|
|
4180
|
-
const result = await tool.execute(
|
|
4181
|
-
params
|
|
4182
|
-
});
|
|
4197
|
+
const result = await tool.execute(params);
|
|
4183
4198
|
return typeof result === "string" ? result : JSON.stringify(result);
|
|
4184
4199
|
} catch (error) {
|
|
4185
4200
|
console.error(`Error executing MCP tool '${toolName}' from endpoint ${mcpEndpoint}:`, error);
|
|
@@ -4205,17 +4220,38 @@ function generateMcpToolInstructions(toolsMap) {
|
|
|
4205
4220
|
}
|
|
4206
4221
|
const toolEntries = Object.entries(toolsMap);
|
|
4207
4222
|
const toolsDoc = toolEntries.map(([name, tool]) => {
|
|
4223
|
+
var _a;
|
|
4208
4224
|
let paramsDoc = " No parameters required";
|
|
4209
4225
|
try {
|
|
4210
4226
|
if (tool.schema && typeof tool.schema === "object") {
|
|
4211
4227
|
const schema = tool.schema;
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4228
|
+
const toolParameters = ((_a = schema.parameters) == null ? void 0 : _a.jsonSchema) || schema.parameters;
|
|
4229
|
+
const properties = (toolParameters == null ? void 0 : toolParameters.properties) || schema.properties;
|
|
4230
|
+
const requiredParams = (toolParameters == null ? void 0 : toolParameters.required) || schema.required || [];
|
|
4231
|
+
if (properties) {
|
|
4232
|
+
const paramsList = Object.entries(properties).map(([paramName, propSchema]) => {
|
|
4215
4233
|
const propDetails = propSchema;
|
|
4216
4234
|
const requiredMark = requiredParams.includes(paramName) ? "*" : "";
|
|
4217
|
-
|
|
4218
|
-
|
|
4235
|
+
let typeInfo = propDetails.type || "any";
|
|
4236
|
+
let description = propDetails.description ? ` - ${propDetails.description}` : "";
|
|
4237
|
+
if (typeInfo === "array" && propDetails.items) {
|
|
4238
|
+
const itemType = propDetails.items.type || "object";
|
|
4239
|
+
if (itemType === "object" && propDetails.items.properties) {
|
|
4240
|
+
const itemProps = Object.keys(propDetails.items.properties).join(", ");
|
|
4241
|
+
typeInfo = `array<object>`;
|
|
4242
|
+
description = description + (description ? " " : " - ") + `Array of objects with properties: ${itemProps}`;
|
|
4243
|
+
} else {
|
|
4244
|
+
typeInfo = `array<${itemType}>`;
|
|
4245
|
+
}
|
|
4246
|
+
}
|
|
4247
|
+
if (propDetails.enum && Array.isArray(propDetails.enum)) {
|
|
4248
|
+
const enumValues = propDetails.enum.join(" | ");
|
|
4249
|
+
description = description + (description ? " " : " - ") + `Allowed values: ${enumValues}`;
|
|
4250
|
+
}
|
|
4251
|
+
if (typeInfo === "object" && propDetails.properties) {
|
|
4252
|
+
const objectProps = Object.keys(propDetails.properties).join(", ");
|
|
4253
|
+
description = description + (description ? " " : " - ") + `Object with properties: ${objectProps}`;
|
|
4254
|
+
}
|
|
4219
4255
|
return ` - ${paramName}${requiredMark} (${typeInfo})${description}`;
|
|
4220
4256
|
});
|
|
4221
4257
|
if (paramsList.length > 0) {
|
|
@@ -4236,8 +4272,11 @@ ${toolsDoc}
|
|
|
4236
4272
|
When using these tools:
|
|
4237
4273
|
1. Only provide valid parameters according to their type requirements
|
|
4238
4274
|
2. Required parameters are marked with *
|
|
4239
|
-
3.
|
|
4240
|
-
4.
|
|
4275
|
+
3. For array parameters, provide data in the correct array format
|
|
4276
|
+
4. For object parameters, include all required nested properties
|
|
4277
|
+
5. For enum parameters, use only the allowed values listed
|
|
4278
|
+
6. Format API calls correctly with the expected parameter structure
|
|
4279
|
+
7. Always check tool responses to determine your next action`;
|
|
4241
4280
|
}
|
|
4242
4281
|
__name(generateMcpToolInstructions, "generateMcpToolInstructions");
|
|
4243
4282
|
|
|
@@ -4324,7 +4363,7 @@ var CopilotRuntime = class {
|
|
|
4324
4363
|
if (!mcpToolInstructions) {
|
|
4325
4364
|
return messages;
|
|
4326
4365
|
}
|
|
4327
|
-
const instructions =
|
|
4366
|
+
const instructions = mcpToolInstructions + "\nUse them when appropriate to fulfill the user's request.";
|
|
4328
4367
|
const systemMessageIndex = messages.findIndex((msg) => {
|
|
4329
4368
|
var _a;
|
|
4330
4369
|
return ((_a = msg.textMessage) == null ? void 0 : _a.role) === "system";
|