@copilotkit/runtime 1.8.7-next.0 → 1.8.8-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 +15 -0
- package/dist/{chunk-RU5CS42E.mjs → chunk-5TUGSSSM.mjs} +2 -2
- package/dist/{chunk-CWPYW7XE.mjs → chunk-62XKONGF.mjs} +2 -2
- package/dist/{chunk-JSV26III.mjs → chunk-XXKM3PJL.mjs} +22 -14
- package/dist/chunk-XXKM3PJL.mjs.map +1 -0
- package/dist/{chunk-BXJZ5GEO.mjs → chunk-YM7JEVJF.mjs} +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +21 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +21 -13
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +4 -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-350db43f.d.ts → shared-e61e0ebb.d.ts} +4 -4
- package/package.json +2 -2
- package/src/lib/runtime/copilot-runtime.ts +34 -24
- package/dist/chunk-JSV26III.mjs.map +0 -1
- /package/dist/{chunk-RU5CS42E.mjs.map → chunk-5TUGSSSM.mjs.map} +0 -0
- /package/dist/{chunk-CWPYW7XE.mjs.map → chunk-62XKONGF.mjs.map} +0 -0
- /package/dist/{chunk-BXJZ5GEO.mjs.map → chunk-YM7JEVJF.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-5TUGSSSM.mjs";
|
|
7
7
|
import {
|
|
8
8
|
copilotRuntimeNestEndpoint
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-YM7JEVJF.mjs";
|
|
10
10
|
import {
|
|
11
11
|
copilotRuntimeNodeExpressEndpoint
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-62XKONGF.mjs";
|
|
13
13
|
import {
|
|
14
14
|
CopilotRuntime,
|
|
15
15
|
addCustomHeaderPlugin,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
getCommonConfig,
|
|
25
25
|
langGraphPlatformEndpoint,
|
|
26
26
|
resolveEndpointType
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-XXKM3PJL.mjs";
|
|
28
28
|
import {
|
|
29
29
|
AnthropicAdapter,
|
|
30
30
|
EmptyAdapter,
|
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, g as getCommonConfig, n as langGraphPlatformEndpoint, r as resolveEndpointType } from '../shared-e61e0ebb.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.8-next.0",
|
|
48
48
|
sideEffects: false,
|
|
49
49
|
main: "./dist/index.js",
|
|
50
50
|
module: "./dist/index.mjs",
|
|
@@ -4442,7 +4442,7 @@ var CopilotRuntime = class {
|
|
|
4442
4442
|
observability;
|
|
4443
4443
|
availableAgents;
|
|
4444
4444
|
// +++ MCP Properties +++
|
|
4445
|
-
|
|
4445
|
+
mcpServersConfig;
|
|
4446
4446
|
mcpActionCache = /* @__PURE__ */ new Map();
|
|
4447
4447
|
// --- MCP Properties ---
|
|
4448
4448
|
// +++ MCP Client Factory +++
|
|
@@ -4465,14 +4465,14 @@ var CopilotRuntime = class {
|
|
|
4465
4465
|
this.delegateAgentProcessingToServiceAdapter = (params == null ? void 0 : params.delegateAgentProcessingToServiceAdapter) || false;
|
|
4466
4466
|
this.observability = params == null ? void 0 : params.observability_c;
|
|
4467
4467
|
this.agents = (params == null ? void 0 : params.agents) ?? {};
|
|
4468
|
-
this.
|
|
4468
|
+
this.mcpServersConfig = params == null ? void 0 : params.mcpServers;
|
|
4469
4469
|
this.createMCPClientImpl = params == null ? void 0 : params.createMCPClient;
|
|
4470
|
-
if (this.
|
|
4470
|
+
if (this.mcpServersConfig && this.mcpServersConfig.length > 0 && !this.createMCPClientImpl) {
|
|
4471
4471
|
throw new import_shared18.CopilotKitMisuseError({
|
|
4472
|
-
message: "MCP Integration Error: `
|
|
4472
|
+
message: "MCP Integration Error: `mcpServers` were provided, but the `createMCPClient` function was not passed to the CopilotRuntime constructor. Please provide an implementation for `createMCPClient`."
|
|
4473
4473
|
});
|
|
4474
4474
|
}
|
|
4475
|
-
if ((params == null ? void 0 : params.actions) && (((_c = params == null ? void 0 : params.remoteEndpoints) == null ? void 0 : _c.some((e) => e.type === EndpointType.LangGraphPlatform)) || ((_d = this.
|
|
4475
|
+
if ((params == null ? void 0 : params.actions) && (((_c = params == null ? void 0 : params.remoteEndpoints) == null ? void 0 : _c.some((e) => e.type === EndpointType.LangGraphPlatform)) || ((_d = this.mcpServersConfig) == null ? void 0 : _d.length))) {
|
|
4476
4476
|
console.warn("Local 'actions' defined in CopilotRuntime might not be available to remote agents (LangGraph, MCP). Consider defining actions closer to the agent implementation if needed.");
|
|
4477
4477
|
}
|
|
4478
4478
|
}
|
|
@@ -4482,7 +4482,11 @@ var CopilotRuntime = class {
|
|
|
4482
4482
|
if (!mcpActionsForRequest || mcpActionsForRequest.length === 0) {
|
|
4483
4483
|
return messages;
|
|
4484
4484
|
}
|
|
4485
|
-
const
|
|
4485
|
+
const uniqueMcpTools = /* @__PURE__ */ new Map();
|
|
4486
|
+
mcpActionsForRequest.forEach((action) => {
|
|
4487
|
+
uniqueMcpTools.set(action.name, action);
|
|
4488
|
+
});
|
|
4489
|
+
const mcpToolInstructions = Array.from(uniqueMcpTools.values()).map((action) => {
|
|
4486
4490
|
const paramsString = action.parameters && action.parameters.length > 0 ? ` Parameters: ${action.parameters.map((p) => `${p.name}${p.required ? "*" : ""}(${p.type})`).join(", ")}` : "";
|
|
4487
4491
|
return `- ${action.name}:${paramsString} ${action.description || ""}`;
|
|
4488
4492
|
}).join("\n");
|
|
@@ -5065,7 +5069,7 @@ please use an LLM adapter instead.`
|
|
|
5065
5069
|
}
|
|
5066
5070
|
}
|
|
5067
5071
|
async getServerSideActions(request) {
|
|
5068
|
-
var _a;
|
|
5072
|
+
var _a, _b;
|
|
5069
5073
|
const { graphqlContext, messages: rawMessages, agentStates, url } = request;
|
|
5070
5074
|
const inputMessages = convertGqlInputToMessages(rawMessages);
|
|
5071
5075
|
const langserveFunctions = [];
|
|
@@ -5095,11 +5099,17 @@ please use an LLM adapter instead.`
|
|
|
5095
5099
|
}) : this.actions;
|
|
5096
5100
|
const requestSpecificMCPActions = [];
|
|
5097
5101
|
if (this.createMCPClientImpl) {
|
|
5098
|
-
const baseEndpoints = this.
|
|
5099
|
-
const requestEndpoints = ((_a = graphqlContext.properties) == null ? void 0 : _a.mcpEndpoints) || [];
|
|
5102
|
+
const baseEndpoints = this.mcpServersConfig || [];
|
|
5103
|
+
const requestEndpoints = ((_a = graphqlContext.properties) == null ? void 0 : _a.mcpServers) || ((_b = graphqlContext.properties) == null ? void 0 : _b.mcpEndpoints) || [];
|
|
5100
5104
|
const effectiveEndpointsMap = /* @__PURE__ */ new Map();
|
|
5101
5105
|
[
|
|
5102
|
-
...baseEndpoints
|
|
5106
|
+
...baseEndpoints
|
|
5107
|
+
].forEach((ep) => {
|
|
5108
|
+
if (ep && ep.endpoint) {
|
|
5109
|
+
effectiveEndpointsMap.set(ep.endpoint, ep);
|
|
5110
|
+
}
|
|
5111
|
+
});
|
|
5112
|
+
[
|
|
5103
5113
|
...requestEndpoints
|
|
5104
5114
|
].forEach((ep) => {
|
|
5105
5115
|
if (ep && ep.endpoint) {
|
|
@@ -5113,12 +5123,10 @@ please use an LLM adapter instead.`
|
|
|
5113
5123
|
if (!actionsForEndpoint) {
|
|
5114
5124
|
let client = null;
|
|
5115
5125
|
try {
|
|
5116
|
-
console.log(`MCP: Cache miss. Fetching tools for endpoint: ${endpointUrl}`);
|
|
5117
5126
|
client = await this.createMCPClientImpl(config2);
|
|
5118
5127
|
const tools = await client.tools();
|
|
5119
5128
|
actionsForEndpoint = convertMCPToolsToActions(tools, endpointUrl);
|
|
5120
5129
|
this.mcpActionCache.set(endpointUrl, actionsForEndpoint);
|
|
5121
|
-
console.log(`MCP: Fetched and cached ${actionsForEndpoint.length} tools for ${endpointUrl}`);
|
|
5122
5130
|
} catch (error) {
|
|
5123
5131
|
console.error(`MCP: Failed to fetch tools from endpoint ${endpointUrl}. Skipping. Error:`, error);
|
|
5124
5132
|
actionsForEndpoint = [];
|