@copilotkit/runtime 1.56.4-canary.1777538870 → 1.56.5
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/dist/agent/converters/tanstack.cjs +6 -0
- package/dist/agent/converters/tanstack.cjs.map +1 -1
- package/dist/agent/converters/tanstack.mjs +6 -0
- package/dist/agent/converters/tanstack.mjs.map +1 -1
- package/dist/agent/index.cjs +8 -37
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +27 -52
- package/dist/agent/index.d.cts.map +1 -1
- package/dist/agent/index.d.mts +27 -52
- package/dist/agent/index.d.mts.map +1 -1
- package/dist/agent/index.mjs +9 -38
- package/dist/agent/index.mjs.map +1 -1
- package/dist/lib/runtime/agent-integrations/langgraph/agent.cjs +8 -1
- package/dist/lib/runtime/agent-integrations/langgraph/agent.cjs.map +1 -1
- package/dist/lib/runtime/agent-integrations/langgraph/agent.d.cts.map +1 -1
- package/dist/lib/runtime/agent-integrations/langgraph/agent.d.mts.map +1 -1
- package/dist/lib/runtime/agent-integrations/langgraph/agent.mjs +8 -1
- package/dist/lib/runtime/agent-integrations/langgraph/agent.mjs.map +1 -1
- package/dist/package.cjs +5 -5
- package/dist/package.mjs +5 -5
- package/dist/v2/index.cjs +0 -2
- package/dist/v2/index.d.cts +5 -6
- package/dist/v2/index.d.mts +5 -6
- package/dist/v2/index.mjs +1 -2
- package/dist/v2/runtime/core/runtime.d.cts +0 -1
- package/dist/v2/runtime/core/runtime.d.cts.map +1 -1
- package/dist/v2/runtime/core/runtime.d.mts +0 -1
- package/dist/v2/runtime/core/runtime.d.mts.map +1 -1
- package/dist/v2/runtime/endpoints/express.cjs +5 -5
- package/dist/v2/runtime/endpoints/express.cjs.map +1 -1
- package/dist/v2/runtime/endpoints/express.mjs +5 -5
- package/dist/v2/runtime/endpoints/express.mjs.map +1 -1
- package/dist/v2/runtime/handlers/intelligence/run.cjs +0 -4
- package/dist/v2/runtime/handlers/intelligence/run.cjs.map +1 -1
- package/dist/v2/runtime/handlers/intelligence/run.mjs +0 -4
- package/dist/v2/runtime/handlers/intelligence/run.mjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/agent-utils.cjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/agent-utils.mjs.map +1 -1
- package/dist/v2/runtime/index.d.cts +1 -3
- package/dist/v2/runtime/index.d.cts.map +1 -1
- package/dist/v2/runtime/index.d.mts +1 -3
- package/dist/v2/runtime/index.d.mts.map +1 -1
- package/dist/v2/runtime/intelligence-platform/client.cjs +0 -52
- package/dist/v2/runtime/intelligence-platform/client.cjs.map +1 -1
- package/dist/v2/runtime/intelligence-platform/client.d.cts +0 -41
- package/dist/v2/runtime/intelligence-platform/client.d.cts.map +1 -1
- package/dist/v2/runtime/intelligence-platform/client.d.mts +0 -41
- package/dist/v2/runtime/intelligence-platform/client.d.mts.map +1 -1
- package/dist/v2/runtime/intelligence-platform/client.mjs +0 -52
- package/dist/v2/runtime/intelligence-platform/client.mjs.map +1 -1
- package/package.json +6 -6
- package/src/agent/__tests__/mcp-clients.test.ts +25 -11
- package/src/agent/__tests__/mcp-servers-integration.test.ts +1 -355
- package/src/agent/converters/tanstack.ts +18 -0
- package/src/agent/index.ts +65 -128
- package/src/lib/runtime/agent-integrations/langgraph/agent.ts +8 -1
- package/src/v2/runtime/__tests__/express-fetch-bridge.test.ts +1 -1
- package/src/v2/runtime/endpoints/express.ts +9 -3
- package/src/v2/runtime/handlers/intelligence/run.ts +0 -9
- package/src/v2/runtime/handlers/shared/agent-utils.ts +0 -1
- package/src/v2/runtime/index.ts +0 -5
- package/src/v2/runtime/intelligence-platform/client.ts +0 -67
- package/dist/agent/mcp-transport.cjs +0 -94
- package/dist/agent/mcp-transport.cjs.map +0 -1
- package/dist/agent/mcp-transport.d.cts +0 -51
- package/dist/agent/mcp-transport.d.cts.map +0 -1
- package/dist/agent/mcp-transport.d.mts +0 -52
- package/dist/agent/mcp-transport.d.mts.map +0 -1
- package/dist/agent/mcp-transport.mjs +0 -92
- package/dist/agent/mcp-transport.mjs.map +0 -1
- package/dist/v2/runtime/intelligence-platform/index.d.cts +0 -2
- package/dist/v2/runtime/intelligence-platform/index.d.mts +0 -2
- package/src/agent/mcp-transport.ts +0 -190
- package/src/v2/runtime/intelligence-platform/__tests__/intelligence-mcp-helper.test.ts +0 -188
|
@@ -154,7 +154,14 @@ export class LangGraphAgent extends AGUILangGraphAgent {
|
|
|
154
154
|
|
|
155
155
|
// @ts-ignore
|
|
156
156
|
run(input: RunAgentInput): Observable<BaseEvent> {
|
|
157
|
-
|
|
157
|
+
const enrichedInput = {
|
|
158
|
+
...input,
|
|
159
|
+
forwardedProps: {
|
|
160
|
+
...input.forwardedProps,
|
|
161
|
+
streamSubgraphs: input.forwardedProps?.streamSubgraphs ?? true,
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
return super.run(enrichedInput).pipe(
|
|
158
165
|
map((processedEvent) => {
|
|
159
166
|
// Turn raw event into emit state snapshot from tool call event
|
|
160
167
|
if (processedEvent.type === EventType.RAW) {
|
|
@@ -147,15 +147,21 @@ export function createCopilotExpressHandler({
|
|
|
147
147
|
router.post(normalizedBase, expressHandler);
|
|
148
148
|
router.options(normalizedBase, expressHandler);
|
|
149
149
|
} else if (normalizedBase === "/") {
|
|
150
|
-
router.all(
|
|
150
|
+
router.all(/.*/, expressHandler);
|
|
151
151
|
} else {
|
|
152
|
-
router.all(
|
|
153
|
-
|
|
152
|
+
router.all(
|
|
153
|
+
new RegExp(`^${escapeRegExp(normalizedBase)}(\\/.*)?$`),
|
|
154
|
+
expressHandler,
|
|
155
|
+
);
|
|
154
156
|
}
|
|
155
157
|
|
|
156
158
|
return router;
|
|
157
159
|
}
|
|
158
160
|
|
|
161
|
+
function escapeRegExp(s: string): string {
|
|
162
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
163
|
+
}
|
|
164
|
+
|
|
159
165
|
function normalizeBasePath(path: string): string {
|
|
160
166
|
if (!path) {
|
|
161
167
|
throw new Error("basePath must be provided for Express endpoint");
|
|
@@ -80,15 +80,6 @@ export async function handleIntelligenceRun({
|
|
|
80
80
|
}
|
|
81
81
|
const userId = user.id;
|
|
82
82
|
|
|
83
|
-
// Surface the resolved user on the agent so MCP header resolvers (and any
|
|
84
|
-
// other per-run consumer) can read it via context. Snapshotted by the
|
|
85
|
-
// BuiltInAgent at run-start; runs that don't go through this Intelligence
|
|
86
|
-
// path leave `agent.user` undefined.
|
|
87
|
-
(agent as unknown as { user?: { id: string; name: string } }).user = {
|
|
88
|
-
id: user.id,
|
|
89
|
-
name: user.name,
|
|
90
|
-
};
|
|
91
|
-
|
|
92
83
|
try {
|
|
93
84
|
const { thread, created } = await runtime.intelligence.getOrCreateThread({
|
|
94
85
|
threadId: input.threadId,
|
|
@@ -13,7 +13,6 @@ import { logger } from "@copilotkit/shared";
|
|
|
13
13
|
type MiddlewareCapableAgent = AbstractAgent & {
|
|
14
14
|
use?: (middleware: unknown) => void;
|
|
15
15
|
headers?: Record<string, string>;
|
|
16
|
-
user?: { id: string; name: string };
|
|
17
16
|
};
|
|
18
17
|
|
|
19
18
|
export interface RunAgentParameters {
|
package/src/v2/runtime/index.ts
CHANGED
|
@@ -19,11 +19,6 @@ export {
|
|
|
19
19
|
type UpdateThreadRequest,
|
|
20
20
|
} from "./intelligence-platform";
|
|
21
21
|
|
|
22
|
-
// Re-export `@ai-sdk/mcp` stable types so consumers don't need to depend on
|
|
23
|
-
// it directly to type their MCP wiring. `MCPClient` is the value users pass
|
|
24
|
-
// into `mcpClients`; `MCPTransport` is the contract for custom transports.
|
|
25
|
-
export type { MCPClient, MCPTransport } from "@ai-sdk/mcp";
|
|
26
|
-
|
|
27
22
|
// Export framework-agnostic fetch handler
|
|
28
23
|
export { createCopilotRuntimeHandler } from "./core/fetch-handler";
|
|
29
24
|
export type {
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import { logger } from "@copilotkit/shared";
|
|
2
|
-
import type { MCPClientConfigHTTP } from "../../../agent";
|
|
3
|
-
|
|
4
|
-
// Header name carrying the per-call end-user identity that the CopilotKit
|
|
5
|
-
// Intelligence `/mcp` endpoint requires. Encapsulated inside the helper so
|
|
6
|
-
// users of `intelligence.toMCPServer()` never need to know the wire-level
|
|
7
|
-
// header name — they configure `identifyUser` once on the runtime and the
|
|
8
|
-
// helper does the rest.
|
|
9
|
-
const INTELLIGENCE_USER_ID_HEADER = "x-cpki-user-id";
|
|
10
2
|
|
|
11
3
|
/**
|
|
12
4
|
* Error thrown when an Intelligence platform HTTP request returns a non-2xx
|
|
@@ -348,65 +340,6 @@ export class CopilotKitIntelligence {
|
|
|
348
340
|
return this.#apiKey;
|
|
349
341
|
}
|
|
350
342
|
|
|
351
|
-
/**
|
|
352
|
-
* Build an MCP-server config pre-wired for this Intelligence platform
|
|
353
|
-
* connection. Drop the result into a `BuiltInAgent`'s `mcpServers` to give
|
|
354
|
-
* the agent access to Intel's bash + thread tools with both auth axes
|
|
355
|
-
* correctly populated:
|
|
356
|
-
*
|
|
357
|
-
* - `Authorization: Bearer <apiKey>` is stamped on every outbound request
|
|
358
|
-
* from this Intelligence client's project key.
|
|
359
|
-
* - `X-Cpki-User-Id` is read fresh per call from the agent's resolved user,
|
|
360
|
-
* which is populated by the runtime's `identifyUser` callback. The
|
|
361
|
-
* helper does not surface the header name to user code.
|
|
362
|
-
*
|
|
363
|
-
* @example
|
|
364
|
-
* ```ts
|
|
365
|
-
* const intelligence = new CopilotKitIntelligence({
|
|
366
|
-
* apiUrl: "https://api.copilotkit.ai",
|
|
367
|
-
* wsUrl: "wss://api.copilotkit.ai",
|
|
368
|
-
* apiKey: process.env.INTELLIGENCE_API_KEY!,
|
|
369
|
-
* });
|
|
370
|
-
*
|
|
371
|
-
* const runtime = new CopilotRuntime({
|
|
372
|
-
* intelligence,
|
|
373
|
-
* identifyUser: (request) => resolveUserFromSession(request),
|
|
374
|
-
* agents: {
|
|
375
|
-
* myAgent: new BuiltInAgent({
|
|
376
|
-
* model: "openai/gpt-4o",
|
|
377
|
-
* mcpServers: [intelligence.toMCPServer()],
|
|
378
|
-
* }),
|
|
379
|
-
* },
|
|
380
|
-
* });
|
|
381
|
-
* ```
|
|
382
|
-
*
|
|
383
|
-
* The resolver throws if no user is present — typically the runtime is
|
|
384
|
-
* misconfigured (no `identifyUser`) or `identifyUser` returned an invalid
|
|
385
|
-
* id. Silent fallthrough to an empty user-id would collapse every browser
|
|
386
|
-
* session for this project into one shared bash sandbox, which is the
|
|
387
|
-
* very isolation guarantee the per-call header exists to enforce.
|
|
388
|
-
*/
|
|
389
|
-
toMCPServer(): MCPClientConfigHTTP {
|
|
390
|
-
const apiKey = this.#apiKey;
|
|
391
|
-
const url = `${this.#apiUrl}/mcp`;
|
|
392
|
-
return {
|
|
393
|
-
type: "http",
|
|
394
|
-
url,
|
|
395
|
-
headers: { Authorization: `Bearer ${apiKey}` },
|
|
396
|
-
getHeaders: ({ user }) => {
|
|
397
|
-
const userId = user?.id?.trim();
|
|
398
|
-
if (!userId) {
|
|
399
|
-
throw new Error(
|
|
400
|
-
"CopilotKitIntelligence.toMCPServer(): no user resolved for this run. " +
|
|
401
|
-
"Configure `identifyUser` on the CopilotRuntime so the agent " +
|
|
402
|
-
"knows which end-user each MCP call is on behalf of.",
|
|
403
|
-
);
|
|
404
|
-
}
|
|
405
|
-
return { [INTELLIGENCE_USER_ID_HEADER]: userId };
|
|
406
|
-
},
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
|
|
410
343
|
async #request<T>(method: string, path: string, body?: unknown): Promise<T> {
|
|
411
344
|
const url = `${this.#apiUrl}${path}`;
|
|
412
345
|
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
require("reflect-metadata");
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let _modelcontextprotocol_sdk_client_streamableHttp_js = require("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
4
|
-
|
|
5
|
-
//#region src/agent/mcp-transport.ts
|
|
6
|
-
/**
|
|
7
|
-
* Thrown when an MCP {@link MCPClientConfigHTTP.getHeaders} resolver throws.
|
|
8
|
-
* Wraps the underlying error so `RUN_ERROR` carries clear attribution instead
|
|
9
|
-
* of a generic transport failure. The original error is preserved on the
|
|
10
|
-
* standard ES2022 `Error.cause` chain.
|
|
11
|
-
*/
|
|
12
|
-
var MCPHeaderResolverError = class extends Error {
|
|
13
|
-
constructor(message, cause) {
|
|
14
|
-
super(message, { cause });
|
|
15
|
-
this.name = "MCPHeaderResolverError";
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* MCP transport for CopilotKit's BuiltInAgent that adds per-call header
|
|
20
|
-
* resolution on top of the standard Streamable HTTP transport.
|
|
21
|
-
*
|
|
22
|
-
* Implements `@ai-sdk/mcp`'s {@link MCPTransport} interface so it can be
|
|
23
|
-
* passed straight to `createMCPClient({ transport })`. Internally delegates
|
|
24
|
-
* to `@modelcontextprotocol/sdk`'s `StreamableHTTPClientTransport` with a
|
|
25
|
-
* wrapped `fetch` that runs the static-header + per-call resolver pipeline
|
|
26
|
-
* before each outbound request.
|
|
27
|
-
*/
|
|
28
|
-
var CopilotKitMCPTransport = class {
|
|
29
|
-
constructor(options) {
|
|
30
|
-
const transportOptions = {
|
|
31
|
-
...options.options,
|
|
32
|
-
fetch: buildWrappedFetch(options)
|
|
33
|
-
};
|
|
34
|
-
this.inner = new _modelcontextprotocol_sdk_client_streamableHttp_js.StreamableHTTPClientTransport(new URL(options.url), transportOptions);
|
|
35
|
-
}
|
|
36
|
-
get onclose() {
|
|
37
|
-
return this.inner.onclose;
|
|
38
|
-
}
|
|
39
|
-
set onclose(handler) {
|
|
40
|
-
this.inner.onclose = handler;
|
|
41
|
-
}
|
|
42
|
-
get onerror() {
|
|
43
|
-
return this.inner.onerror;
|
|
44
|
-
}
|
|
45
|
-
set onerror(handler) {
|
|
46
|
-
this.inner.onerror = handler;
|
|
47
|
-
}
|
|
48
|
-
get onmessage() {
|
|
49
|
-
return this.inner.onmessage;
|
|
50
|
-
}
|
|
51
|
-
set onmessage(handler) {
|
|
52
|
-
this.inner.onmessage = handler;
|
|
53
|
-
}
|
|
54
|
-
start() {
|
|
55
|
-
return this.inner.start();
|
|
56
|
-
}
|
|
57
|
-
send(message) {
|
|
58
|
-
return this.inner.send(message);
|
|
59
|
-
}
|
|
60
|
-
close() {
|
|
61
|
-
return this.inner.close();
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
function buildWrappedFetch(options) {
|
|
65
|
-
const { headers: staticHeaders, getHeaders, requestHeaders, input, url: mcpServerUrl, user, options: transportOptions } = options;
|
|
66
|
-
const baseFetch = transportOptions?.fetch ?? globalThis.fetch;
|
|
67
|
-
return async (fetchUrl, init) => {
|
|
68
|
-
const merged = new Headers(init?.headers);
|
|
69
|
-
if (staticHeaders) for (const [key, value] of Object.entries(staticHeaders)) merged.set(key, value);
|
|
70
|
-
if (getHeaders) {
|
|
71
|
-
let resolved;
|
|
72
|
-
try {
|
|
73
|
-
resolved = await getHeaders({
|
|
74
|
-
requestHeaders,
|
|
75
|
-
input,
|
|
76
|
-
mcpServerUrl,
|
|
77
|
-
user
|
|
78
|
-
});
|
|
79
|
-
} catch (err) {
|
|
80
|
-
throw new MCPHeaderResolverError(`MCP header resolver for ${mcpServerUrl} threw: ${err instanceof Error ? err.message : String(err)}`, err);
|
|
81
|
-
}
|
|
82
|
-
for (const [key, value] of Object.entries(resolved)) merged.set(key, value);
|
|
83
|
-
}
|
|
84
|
-
return baseFetch(fetchUrl, {
|
|
85
|
-
...init,
|
|
86
|
-
headers: merged
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
//#endregion
|
|
92
|
-
exports.CopilotKitMCPTransport = CopilotKitMCPTransport;
|
|
93
|
-
exports.MCPHeaderResolverError = MCPHeaderResolverError;
|
|
94
|
-
//# sourceMappingURL=mcp-transport.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-transport.cjs","names":["StreamableHTTPClientTransport"],"sources":["../../src/agent/mcp-transport.ts"],"sourcesContent":["import type { RunAgentInput } from \"@ag-ui/client\";\nimport type { JSONRPCMessage, MCPTransport } from \"@ai-sdk/mcp\";\nimport { StreamableHTTPClientTransport } from \"@modelcontextprotocol/sdk/client/streamableHttp.js\";\nimport type { StreamableHTTPClientTransportOptions } from \"@modelcontextprotocol/sdk/client/streamableHttp.js\";\nimport type { FetchLike } from \"@modelcontextprotocol/sdk/shared/transport.js\";\n\n/**\n * The end-user identity resolved by the runtime's `identifyUser` callback for\n * the current request. Surfaced on {@link MCPRequestContext} so MCP header\n * resolvers can read it without re-doing auth work.\n */\nexport interface MCPRuntimeUser {\n id: string;\n name: string;\n}\n\n/**\n * Context handed to {@link MCPClientConfigHTTP.getHeaders} on every outbound\n * MCP HTTP request. The resolver is invoked fresh per request — initialize,\n * tools/list, tools/call, and reconnects — so values it depends on are never\n * cached across calls.\n */\nexport interface MCPRequestContext {\n /**\n * Headers forwarded onto the agent for this run. Populated by the runtime's\n * `extractForwardableHeaders` (`authorization` + every `x-*` header from the\n * incoming HTTP request). Keys are lower-cased.\n */\n requestHeaders: Record<string, string>;\n /** The {@link RunAgentInput} the agent is currently running. */\n input: RunAgentInput;\n /** URL of the MCP server this request is going to. */\n mcpServerUrl: string;\n /**\n * The end-user identity for this run, resolved by the runtime's\n * `identifyUser` callback (only populated when the agent is run via a\n * `CopilotRuntime` configured with `identifyUser`). Snapshotted at\n * run-start.\n */\n user?: MCPRuntimeUser;\n}\n\n/**\n * Thrown when an MCP {@link MCPClientConfigHTTP.getHeaders} resolver throws.\n * Wraps the underlying error so `RUN_ERROR` carries clear attribution instead\n * of a generic transport failure. The original error is preserved on the\n * standard ES2022 `Error.cause` chain.\n */\nexport class MCPHeaderResolverError extends Error {\n constructor(message: string, cause: unknown) {\n super(message, { cause });\n this.name = \"MCPHeaderResolverError\";\n }\n}\n\nexport interface CopilotKitMCPTransportOptions {\n /** URL of the MCP server. */\n url: string;\n /** Static HTTP headers, merged into every outbound request. */\n headers?: Record<string, string>;\n /**\n * Per-call header resolver. Invoked on **every** outbound HTTP request to\n * this server (initialize, tools/list, tools/call, reconnects). Returned\n * headers are merged on top of `headers`, so a resolver can override either.\n */\n getHeaders?: (\n ctx: MCPRequestContext,\n ) => Record<string, string> | Promise<Record<string, string>>;\n /**\n * Pre-existing escape hatch: low-level options for the underlying\n * `StreamableHTTPClientTransport`. Forwarded as-is, except `fetch` is\n * wrapped so static `headers` and `getHeaders` resolution still apply.\n */\n options?: StreamableHTTPClientTransportOptions;\n /** Snapshot of the agent's per-run forwarded headers, captured at run-start. */\n requestHeaders: Record<string, string>;\n /** RunAgentInput for the current run, exposed to the resolver via context. */\n input: RunAgentInput;\n /** Per-run end-user identity from the runtime's `identifyUser`, if set. */\n user?: MCPRuntimeUser;\n}\n\n/**\n * MCP transport for CopilotKit's BuiltInAgent that adds per-call header\n * resolution on top of the standard Streamable HTTP transport.\n *\n * Implements `@ai-sdk/mcp`'s {@link MCPTransport} interface so it can be\n * passed straight to `createMCPClient({ transport })`. Internally delegates\n * to `@modelcontextprotocol/sdk`'s `StreamableHTTPClientTransport` with a\n * wrapped `fetch` that runs the static-header + per-call resolver pipeline\n * before each outbound request.\n */\nexport class CopilotKitMCPTransport implements MCPTransport {\n private readonly inner: StreamableHTTPClientTransport;\n\n constructor(options: CopilotKitMCPTransportOptions) {\n const transportOptions: StreamableHTTPClientTransportOptions = {\n ...options.options,\n fetch: buildWrappedFetch(options),\n };\n this.inner = new StreamableHTTPClientTransport(\n new URL(options.url),\n transportOptions,\n );\n }\n\n get onclose(): (() => void) | undefined {\n return this.inner.onclose;\n }\n set onclose(handler: (() => void) | undefined) {\n this.inner.onclose = handler;\n }\n\n get onerror(): ((error: Error) => void) | undefined {\n return this.inner.onerror;\n }\n set onerror(handler: ((error: Error) => void) | undefined) {\n this.inner.onerror = handler;\n }\n\n get onmessage(): ((message: JSONRPCMessage) => void) | undefined {\n return this.inner.onmessage as\n | ((message: JSONRPCMessage) => void)\n | undefined;\n }\n set onmessage(handler: ((message: JSONRPCMessage) => void) | undefined) {\n this.inner.onmessage = handler as\n | ((message: JSONRPCMessage) => void)\n | undefined;\n }\n\n start(): Promise<void> {\n return this.inner.start();\n }\n\n send(message: JSONRPCMessage): Promise<void> {\n return this.inner.send(message as Parameters<typeof this.inner.send>[0]);\n }\n\n close(): Promise<void> {\n return this.inner.close();\n }\n}\n\nfunction buildWrappedFetch(options: CopilotKitMCPTransportOptions): FetchLike {\n const {\n headers: staticHeaders,\n getHeaders,\n requestHeaders,\n input,\n url: mcpServerUrl,\n user,\n options: transportOptions,\n } = options;\n const baseFetch: FetchLike = transportOptions?.fetch ?? globalThis.fetch;\n\n return async (fetchUrl, init) => {\n // SDK passes a Headers instance via init.headers — start fresh from it so\n // we don't mutate the SDK's object, then layer headers on top via .set()\n // (last write wins).\n const merged = new Headers(init?.headers);\n if (staticHeaders) {\n for (const [key, value] of Object.entries(staticHeaders)) {\n merged.set(key, value);\n }\n }\n if (getHeaders) {\n let resolved: Record<string, string>;\n try {\n resolved = await getHeaders({\n requestHeaders,\n input,\n mcpServerUrl,\n user,\n });\n } catch (err) {\n throw new MCPHeaderResolverError(\n `MCP header resolver for ${mcpServerUrl} threw: ${\n err instanceof Error ? err.message : String(err)\n }`,\n err,\n );\n }\n for (const [key, value] of Object.entries(resolved)) {\n merged.set(key, value);\n }\n }\n return baseFetch(fetchUrl, { ...init, headers: merged });\n };\n}\n"],"mappings":";;;;;;;;;;;AAgDA,IAAa,yBAAb,cAA4C,MAAM;CAChD,YAAY,SAAiB,OAAgB;AAC3C,QAAM,SAAS,EAAE,OAAO,CAAC;AACzB,OAAK,OAAO;;;;;;;;;;;;;AAyChB,IAAa,yBAAb,MAA4D;CAG1D,YAAY,SAAwC;EAClD,MAAM,mBAAyD;GAC7D,GAAG,QAAQ;GACX,OAAO,kB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
|
|
1
|
-
|
|
2
|
-
import { RunAgentInput } from "@ag-ui/client";
|
|
3
|
-
import { StreamableHTTPClientTransportOptions } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
4
|
-
|
|
5
|
-
//#region src/agent/mcp-transport.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* The end-user identity resolved by the runtime's `identifyUser` callback for
|
|
8
|
-
* the current request. Surfaced on {@link MCPRequestContext} so MCP header
|
|
9
|
-
* resolvers can read it without re-doing auth work.
|
|
10
|
-
*/
|
|
11
|
-
interface MCPRuntimeUser {
|
|
12
|
-
id: string;
|
|
13
|
-
name: string;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Context handed to {@link MCPClientConfigHTTP.getHeaders} on every outbound
|
|
17
|
-
* MCP HTTP request. The resolver is invoked fresh per request — initialize,
|
|
18
|
-
* tools/list, tools/call, and reconnects — so values it depends on are never
|
|
19
|
-
* cached across calls.
|
|
20
|
-
*/
|
|
21
|
-
interface MCPRequestContext {
|
|
22
|
-
/**
|
|
23
|
-
* Headers forwarded onto the agent for this run. Populated by the runtime's
|
|
24
|
-
* `extractForwardableHeaders` (`authorization` + every `x-*` header from the
|
|
25
|
-
* incoming HTTP request). Keys are lower-cased.
|
|
26
|
-
*/
|
|
27
|
-
requestHeaders: Record<string, string>;
|
|
28
|
-
/** The {@link RunAgentInput} the agent is currently running. */
|
|
29
|
-
input: RunAgentInput;
|
|
30
|
-
/** URL of the MCP server this request is going to. */
|
|
31
|
-
mcpServerUrl: string;
|
|
32
|
-
/**
|
|
33
|
-
* The end-user identity for this run, resolved by the runtime's
|
|
34
|
-
* `identifyUser` callback (only populated when the agent is run via a
|
|
35
|
-
* `CopilotRuntime` configured with `identifyUser`). Snapshotted at
|
|
36
|
-
* run-start.
|
|
37
|
-
*/
|
|
38
|
-
user?: MCPRuntimeUser;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Thrown when an MCP {@link MCPClientConfigHTTP.getHeaders} resolver throws.
|
|
42
|
-
* Wraps the underlying error so `RUN_ERROR` carries clear attribution instead
|
|
43
|
-
* of a generic transport failure. The original error is preserved on the
|
|
44
|
-
* standard ES2022 `Error.cause` chain.
|
|
45
|
-
*/
|
|
46
|
-
declare class MCPHeaderResolverError extends Error {
|
|
47
|
-
constructor(message: string, cause: unknown);
|
|
48
|
-
}
|
|
49
|
-
//#endregion
|
|
50
|
-
export { MCPHeaderResolverError, MCPRequestContext };
|
|
51
|
-
//# sourceMappingURL=mcp-transport.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-transport.d.cts","names":[],"sources":["../../src/agent/mcp-transport.ts"],"mappings":";;;;;;AAWA;;;;UAAiB,cAAA;EACf,EAAA;EACA,IAAA;AAAA;;;;;;;UASe,iBAAA;EAQf;;;;;EAFA,cAAA,EAAgB,MAAA;EAWK;EATrB,KAAA,EAAO,aAAA;EAkB2B;EAhBlC,YAAA;EAgB+C;;;;;;EAT/C,IAAA,GAAO,cAAA;AAAA;;;;;;;cASI,sBAAA,SAA+B,KAAA;cAC9B,OAAA,UAAiB,KAAA;AAAA"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import "reflect-metadata";
|
|
2
|
-
import { RunAgentInput } from "@ag-ui/client";
|
|
3
|
-
import "@ai-sdk/mcp";
|
|
4
|
-
import { StreamableHTTPClientTransportOptions } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
5
|
-
|
|
6
|
-
//#region src/agent/mcp-transport.d.ts
|
|
7
|
-
/**
|
|
8
|
-
* The end-user identity resolved by the runtime's `identifyUser` callback for
|
|
9
|
-
* the current request. Surfaced on {@link MCPRequestContext} so MCP header
|
|
10
|
-
* resolvers can read it without re-doing auth work.
|
|
11
|
-
*/
|
|
12
|
-
interface MCPRuntimeUser {
|
|
13
|
-
id: string;
|
|
14
|
-
name: string;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Context handed to {@link MCPClientConfigHTTP.getHeaders} on every outbound
|
|
18
|
-
* MCP HTTP request. The resolver is invoked fresh per request — initialize,
|
|
19
|
-
* tools/list, tools/call, and reconnects — so values it depends on are never
|
|
20
|
-
* cached across calls.
|
|
21
|
-
*/
|
|
22
|
-
interface MCPRequestContext {
|
|
23
|
-
/**
|
|
24
|
-
* Headers forwarded onto the agent for this run. Populated by the runtime's
|
|
25
|
-
* `extractForwardableHeaders` (`authorization` + every `x-*` header from the
|
|
26
|
-
* incoming HTTP request). Keys are lower-cased.
|
|
27
|
-
*/
|
|
28
|
-
requestHeaders: Record<string, string>;
|
|
29
|
-
/** The {@link RunAgentInput} the agent is currently running. */
|
|
30
|
-
input: RunAgentInput;
|
|
31
|
-
/** URL of the MCP server this request is going to. */
|
|
32
|
-
mcpServerUrl: string;
|
|
33
|
-
/**
|
|
34
|
-
* The end-user identity for this run, resolved by the runtime's
|
|
35
|
-
* `identifyUser` callback (only populated when the agent is run via a
|
|
36
|
-
* `CopilotRuntime` configured with `identifyUser`). Snapshotted at
|
|
37
|
-
* run-start.
|
|
38
|
-
*/
|
|
39
|
-
user?: MCPRuntimeUser;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Thrown when an MCP {@link MCPClientConfigHTTP.getHeaders} resolver throws.
|
|
43
|
-
* Wraps the underlying error so `RUN_ERROR` carries clear attribution instead
|
|
44
|
-
* of a generic transport failure. The original error is preserved on the
|
|
45
|
-
* standard ES2022 `Error.cause` chain.
|
|
46
|
-
*/
|
|
47
|
-
declare class MCPHeaderResolverError extends Error {
|
|
48
|
-
constructor(message: string, cause: unknown);
|
|
49
|
-
}
|
|
50
|
-
//#endregion
|
|
51
|
-
export { MCPHeaderResolverError, MCPRequestContext };
|
|
52
|
-
//# sourceMappingURL=mcp-transport.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-transport.d.mts","names":[],"sources":["../../src/agent/mcp-transport.ts"],"mappings":";;;;;;;;AAWA;;;UAAiB,cAAA;EACf,EAAA;EACA,IAAA;AAAA;;;;;;;UASe,iBAAA;EAMC;;;;;EAAhB,cAAA,EAAgB,MAAA;EAWK;EATrB,KAAA,EAAO,aAAA;EAkBI;EAhBX,YAAA;;;;;;;EAOA,IAAA,GAAO,cAAA;AAAA;;;;;;;cASI,sBAAA,SAA+B,KAAA;cAC9B,OAAA,UAAiB,KAAA;AAAA"}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import "reflect-metadata";
|
|
2
|
-
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
3
|
-
|
|
4
|
-
//#region src/agent/mcp-transport.ts
|
|
5
|
-
/**
|
|
6
|
-
* Thrown when an MCP {@link MCPClientConfigHTTP.getHeaders} resolver throws.
|
|
7
|
-
* Wraps the underlying error so `RUN_ERROR` carries clear attribution instead
|
|
8
|
-
* of a generic transport failure. The original error is preserved on the
|
|
9
|
-
* standard ES2022 `Error.cause` chain.
|
|
10
|
-
*/
|
|
11
|
-
var MCPHeaderResolverError = class extends Error {
|
|
12
|
-
constructor(message, cause) {
|
|
13
|
-
super(message, { cause });
|
|
14
|
-
this.name = "MCPHeaderResolverError";
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* MCP transport for CopilotKit's BuiltInAgent that adds per-call header
|
|
19
|
-
* resolution on top of the standard Streamable HTTP transport.
|
|
20
|
-
*
|
|
21
|
-
* Implements `@ai-sdk/mcp`'s {@link MCPTransport} interface so it can be
|
|
22
|
-
* passed straight to `createMCPClient({ transport })`. Internally delegates
|
|
23
|
-
* to `@modelcontextprotocol/sdk`'s `StreamableHTTPClientTransport` with a
|
|
24
|
-
* wrapped `fetch` that runs the static-header + per-call resolver pipeline
|
|
25
|
-
* before each outbound request.
|
|
26
|
-
*/
|
|
27
|
-
var CopilotKitMCPTransport = class {
|
|
28
|
-
constructor(options) {
|
|
29
|
-
const transportOptions = {
|
|
30
|
-
...options.options,
|
|
31
|
-
fetch: buildWrappedFetch(options)
|
|
32
|
-
};
|
|
33
|
-
this.inner = new StreamableHTTPClientTransport(new URL(options.url), transportOptions);
|
|
34
|
-
}
|
|
35
|
-
get onclose() {
|
|
36
|
-
return this.inner.onclose;
|
|
37
|
-
}
|
|
38
|
-
set onclose(handler) {
|
|
39
|
-
this.inner.onclose = handler;
|
|
40
|
-
}
|
|
41
|
-
get onerror() {
|
|
42
|
-
return this.inner.onerror;
|
|
43
|
-
}
|
|
44
|
-
set onerror(handler) {
|
|
45
|
-
this.inner.onerror = handler;
|
|
46
|
-
}
|
|
47
|
-
get onmessage() {
|
|
48
|
-
return this.inner.onmessage;
|
|
49
|
-
}
|
|
50
|
-
set onmessage(handler) {
|
|
51
|
-
this.inner.onmessage = handler;
|
|
52
|
-
}
|
|
53
|
-
start() {
|
|
54
|
-
return this.inner.start();
|
|
55
|
-
}
|
|
56
|
-
send(message) {
|
|
57
|
-
return this.inner.send(message);
|
|
58
|
-
}
|
|
59
|
-
close() {
|
|
60
|
-
return this.inner.close();
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
function buildWrappedFetch(options) {
|
|
64
|
-
const { headers: staticHeaders, getHeaders, requestHeaders, input, url: mcpServerUrl, user, options: transportOptions } = options;
|
|
65
|
-
const baseFetch = transportOptions?.fetch ?? globalThis.fetch;
|
|
66
|
-
return async (fetchUrl, init) => {
|
|
67
|
-
const merged = new Headers(init?.headers);
|
|
68
|
-
if (staticHeaders) for (const [key, value] of Object.entries(staticHeaders)) merged.set(key, value);
|
|
69
|
-
if (getHeaders) {
|
|
70
|
-
let resolved;
|
|
71
|
-
try {
|
|
72
|
-
resolved = await getHeaders({
|
|
73
|
-
requestHeaders,
|
|
74
|
-
input,
|
|
75
|
-
mcpServerUrl,
|
|
76
|
-
user
|
|
77
|
-
});
|
|
78
|
-
} catch (err) {
|
|
79
|
-
throw new MCPHeaderResolverError(`MCP header resolver for ${mcpServerUrl} threw: ${err instanceof Error ? err.message : String(err)}`, err);
|
|
80
|
-
}
|
|
81
|
-
for (const [key, value] of Object.entries(resolved)) merged.set(key, value);
|
|
82
|
-
}
|
|
83
|
-
return baseFetch(fetchUrl, {
|
|
84
|
-
...init,
|
|
85
|
-
headers: merged
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
//#endregion
|
|
91
|
-
export { CopilotKitMCPTransport, MCPHeaderResolverError };
|
|
92
|
-
//# sourceMappingURL=mcp-transport.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-transport.mjs","names":[],"sources":["../../src/agent/mcp-transport.ts"],"sourcesContent":["import type { RunAgentInput } from \"@ag-ui/client\";\nimport type { JSONRPCMessage, MCPTransport } from \"@ai-sdk/mcp\";\nimport { StreamableHTTPClientTransport } from \"@modelcontextprotocol/sdk/client/streamableHttp.js\";\nimport type { StreamableHTTPClientTransportOptions } from \"@modelcontextprotocol/sdk/client/streamableHttp.js\";\nimport type { FetchLike } from \"@modelcontextprotocol/sdk/shared/transport.js\";\n\n/**\n * The end-user identity resolved by the runtime's `identifyUser` callback for\n * the current request. Surfaced on {@link MCPRequestContext} so MCP header\n * resolvers can read it without re-doing auth work.\n */\nexport interface MCPRuntimeUser {\n id: string;\n name: string;\n}\n\n/**\n * Context handed to {@link MCPClientConfigHTTP.getHeaders} on every outbound\n * MCP HTTP request. The resolver is invoked fresh per request — initialize,\n * tools/list, tools/call, and reconnects — so values it depends on are never\n * cached across calls.\n */\nexport interface MCPRequestContext {\n /**\n * Headers forwarded onto the agent for this run. Populated by the runtime's\n * `extractForwardableHeaders` (`authorization` + every `x-*` header from the\n * incoming HTTP request). Keys are lower-cased.\n */\n requestHeaders: Record<string, string>;\n /** The {@link RunAgentInput} the agent is currently running. */\n input: RunAgentInput;\n /** URL of the MCP server this request is going to. */\n mcpServerUrl: string;\n /**\n * The end-user identity for this run, resolved by the runtime's\n * `identifyUser` callback (only populated when the agent is run via a\n * `CopilotRuntime` configured with `identifyUser`). Snapshotted at\n * run-start.\n */\n user?: MCPRuntimeUser;\n}\n\n/**\n * Thrown when an MCP {@link MCPClientConfigHTTP.getHeaders} resolver throws.\n * Wraps the underlying error so `RUN_ERROR` carries clear attribution instead\n * of a generic transport failure. The original error is preserved on the\n * standard ES2022 `Error.cause` chain.\n */\nexport class MCPHeaderResolverError extends Error {\n constructor(message: string, cause: unknown) {\n super(message, { cause });\n this.name = \"MCPHeaderResolverError\";\n }\n}\n\nexport interface CopilotKitMCPTransportOptions {\n /** URL of the MCP server. */\n url: string;\n /** Static HTTP headers, merged into every outbound request. */\n headers?: Record<string, string>;\n /**\n * Per-call header resolver. Invoked on **every** outbound HTTP request to\n * this server (initialize, tools/list, tools/call, reconnects). Returned\n * headers are merged on top of `headers`, so a resolver can override either.\n */\n getHeaders?: (\n ctx: MCPRequestContext,\n ) => Record<string, string> | Promise<Record<string, string>>;\n /**\n * Pre-existing escape hatch: low-level options for the underlying\n * `StreamableHTTPClientTransport`. Forwarded as-is, except `fetch` is\n * wrapped so static `headers` and `getHeaders` resolution still apply.\n */\n options?: StreamableHTTPClientTransportOptions;\n /** Snapshot of the agent's per-run forwarded headers, captured at run-start. */\n requestHeaders: Record<string, string>;\n /** RunAgentInput for the current run, exposed to the resolver via context. */\n input: RunAgentInput;\n /** Per-run end-user identity from the runtime's `identifyUser`, if set. */\n user?: MCPRuntimeUser;\n}\n\n/**\n * MCP transport for CopilotKit's BuiltInAgent that adds per-call header\n * resolution on top of the standard Streamable HTTP transport.\n *\n * Implements `@ai-sdk/mcp`'s {@link MCPTransport} interface so it can be\n * passed straight to `createMCPClient({ transport })`. Internally delegates\n * to `@modelcontextprotocol/sdk`'s `StreamableHTTPClientTransport` with a\n * wrapped `fetch` that runs the static-header + per-call resolver pipeline\n * before each outbound request.\n */\nexport class CopilotKitMCPTransport implements MCPTransport {\n private readonly inner: StreamableHTTPClientTransport;\n\n constructor(options: CopilotKitMCPTransportOptions) {\n const transportOptions: StreamableHTTPClientTransportOptions = {\n ...options.options,\n fetch: buildWrappedFetch(options),\n };\n this.inner = new StreamableHTTPClientTransport(\n new URL(options.url),\n transportOptions,\n );\n }\n\n get onclose(): (() => void) | undefined {\n return this.inner.onclose;\n }\n set onclose(handler: (() => void) | undefined) {\n this.inner.onclose = handler;\n }\n\n get onerror(): ((error: Error) => void) | undefined {\n return this.inner.onerror;\n }\n set onerror(handler: ((error: Error) => void) | undefined) {\n this.inner.onerror = handler;\n }\n\n get onmessage(): ((message: JSONRPCMessage) => void) | undefined {\n return this.inner.onmessage as\n | ((message: JSONRPCMessage) => void)\n | undefined;\n }\n set onmessage(handler: ((message: JSONRPCMessage) => void) | undefined) {\n this.inner.onmessage = handler as\n | ((message: JSONRPCMessage) => void)\n | undefined;\n }\n\n start(): Promise<void> {\n return this.inner.start();\n }\n\n send(message: JSONRPCMessage): Promise<void> {\n return this.inner.send(message as Parameters<typeof this.inner.send>[0]);\n }\n\n close(): Promise<void> {\n return this.inner.close();\n }\n}\n\nfunction buildWrappedFetch(options: CopilotKitMCPTransportOptions): FetchLike {\n const {\n headers: staticHeaders,\n getHeaders,\n requestHeaders,\n input,\n url: mcpServerUrl,\n user,\n options: transportOptions,\n } = options;\n const baseFetch: FetchLike = transportOptions?.fetch ?? globalThis.fetch;\n\n return async (fetchUrl, init) => {\n // SDK passes a Headers instance via init.headers — start fresh from it so\n // we don't mutate the SDK's object, then layer headers on top via .set()\n // (last write wins).\n const merged = new Headers(init?.headers);\n if (staticHeaders) {\n for (const [key, value] of Object.entries(staticHeaders)) {\n merged.set(key, value);\n }\n }\n if (getHeaders) {\n let resolved: Record<string, string>;\n try {\n resolved = await getHeaders({\n requestHeaders,\n input,\n mcpServerUrl,\n user,\n });\n } catch (err) {\n throw new MCPHeaderResolverError(\n `MCP header resolver for ${mcpServerUrl} threw: ${\n err instanceof Error ? err.message : String(err)\n }`,\n err,\n );\n }\n for (const [key, value] of Object.entries(resolved)) {\n merged.set(key, value);\n }\n }\n return baseF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