@copilotkit/runtime 1.72.1-canary.sp-longthread-perf → 1.73.1
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/index.cjs +49 -9
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +20 -7
- package/dist/agent/index.d.cts.map +1 -1
- package/dist/agent/index.d.mts +19 -6
- package/dist/agent/index.d.mts.map +1 -1
- package/dist/agent/index.mjs +49 -9
- package/dist/agent/index.mjs.map +1 -1
- package/dist/agent/learned-skills.cjs +77 -0
- package/dist/agent/learned-skills.cjs.map +1 -0
- package/dist/agent/learned-skills.d.cts +16 -0
- package/dist/agent/learned-skills.d.cts.map +1 -0
- package/dist/agent/learned-skills.d.mts +16 -0
- package/dist/agent/learned-skills.d.mts.map +1 -0
- package/dist/agent/learned-skills.mjs +75 -0
- package/dist/agent/learned-skills.mjs.map +1 -0
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/internal/learned-skills.cjs +22 -0
- package/dist/internal/learned-skills.d.cts +10 -0
- package/dist/internal/learned-skills.d.mts +10 -0
- package/dist/internal/learned-skills.mjs +10 -0
- package/dist/lib/index.d.cts +2 -2
- package/dist/lib/index.d.mts +2 -2
- package/dist/lib/integrations/nextjs/app-router.cjs +1 -1
- package/dist/lib/integrations/nextjs/app-router.cjs.map +1 -1
- package/dist/lib/integrations/nextjs/app-router.mjs +1 -1
- package/dist/lib/integrations/nextjs/app-router.mjs.map +1 -1
- package/dist/lib/integrations/node-http/index.cjs +1 -1
- package/dist/lib/integrations/node-http/index.cjs.map +1 -1
- package/dist/lib/integrations/node-http/index.d.cts.map +1 -1
- package/dist/lib/integrations/node-http/index.d.mts.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +1 -1
- package/dist/lib/integrations/node-http/index.mjs.map +1 -1
- package/dist/lib/integrations/shared.cjs.map +1 -1
- package/dist/lib/integrations/shared.d.cts +1 -1
- package/dist/lib/integrations/shared.d.cts.map +1 -1
- package/dist/lib/integrations/shared.d.mts +1 -1
- package/dist/lib/integrations/shared.d.mts.map +1 -1
- package/dist/lib/integrations/shared.mjs.map +1 -1
- package/dist/lib/runtime/agent-integrations/langgraph/agent.d.cts +1 -1
- package/dist/lib/runtime/copilot-runtime.cjs +79 -37
- package/dist/lib/runtime/copilot-runtime.cjs.map +1 -1
- package/dist/lib/runtime/copilot-runtime.d.cts +54 -4
- package/dist/lib/runtime/copilot-runtime.d.cts.map +1 -1
- package/dist/lib/runtime/copilot-runtime.d.mts +56 -6
- package/dist/lib/runtime/copilot-runtime.d.mts.map +1 -1
- package/dist/lib/runtime/copilot-runtime.mjs +79 -37
- package/dist/lib/runtime/copilot-runtime.mjs.map +1 -1
- package/dist/lib/runtime/mcp-client-cache.cjs +135 -0
- package/dist/lib/runtime/mcp-client-cache.cjs.map +1 -0
- package/dist/lib/runtime/mcp-client-cache.mjs +132 -0
- package/dist/lib/runtime/mcp-client-cache.mjs.map +1 -0
- package/dist/lib/runtime/telemetry-agent-runner.cjs.map +1 -1
- package/dist/lib/runtime/telemetry-agent-runner.d.cts +1 -1
- package/dist/lib/runtime/telemetry-agent-runner.d.mts +1 -1
- package/dist/lib/runtime/telemetry-agent-runner.mjs.map +1 -1
- package/dist/package.cjs +15 -7
- package/dist/package.mjs +15 -7
- package/dist/service-adapters/anthropic/anthropic-adapter.cjs.map +1 -1
- package/dist/service-adapters/anthropic/anthropic-adapter.d.cts.map +1 -1
- package/dist/service-adapters/anthropic/anthropic-adapter.d.mts.map +1 -1
- package/dist/service-adapters/anthropic/anthropic-adapter.mjs.map +1 -1
- package/dist/service-adapters/shared/sdk-client-utils.cjs.map +1 -1
- package/dist/service-adapters/shared/sdk-client-utils.d.cts.map +1 -1
- package/dist/service-adapters/shared/sdk-client-utils.d.mts.map +1 -1
- package/dist/service-adapters/shared/sdk-client-utils.mjs.map +1 -1
- package/dist/v2/index.cjs +9 -3
- package/dist/v2/index.d.cts +12 -11
- package/dist/v2/index.d.mts +12 -11
- package/dist/v2/index.mjs +5 -5
- package/dist/v2/runtime/core/channel-manager.cjs +1 -1
- package/dist/v2/runtime/core/channel-manager.d.cts +1 -1
- package/dist/v2/runtime/core/channel-manager.d.mts +1 -1
- package/dist/v2/runtime/core/channel-manager.mjs +1 -1
- package/dist/v2/runtime/core/fetch-handler.cjs +1 -0
- package/dist/v2/runtime/core/fetch-handler.cjs.map +1 -1
- package/dist/v2/runtime/core/fetch-handler.d.cts +2 -2
- package/dist/v2/runtime/core/fetch-handler.d.mts +2 -2
- package/dist/v2/runtime/core/fetch-handler.mjs +1 -0
- package/dist/v2/runtime/core/fetch-handler.mjs.map +1 -1
- package/dist/v2/runtime/core/runtime.cjs +5 -0
- package/dist/v2/runtime/core/runtime.cjs.map +1 -1
- package/dist/v2/runtime/core/runtime.d.cts +18 -3
- package/dist/v2/runtime/core/runtime.d.cts.map +1 -1
- package/dist/v2/runtime/core/runtime.d.mts +17 -2
- package/dist/v2/runtime/core/runtime.d.mts.map +1 -1
- package/dist/v2/runtime/core/runtime.mjs +5 -0
- package/dist/v2/runtime/core/runtime.mjs.map +1 -1
- package/dist/v2/runtime/endpoints/express-single.cjs.map +1 -1
- package/dist/v2/runtime/endpoints/express-single.d.cts +2 -2
- package/dist/v2/runtime/endpoints/express-single.d.cts.map +1 -1
- package/dist/v2/runtime/endpoints/express-single.d.mts +2 -2
- package/dist/v2/runtime/endpoints/express-single.d.mts.map +1 -1
- package/dist/v2/runtime/endpoints/express-single.mjs.map +1 -1
- package/dist/v2/runtime/endpoints/express.cjs +2 -3
- package/dist/v2/runtime/endpoints/express.cjs.map +1 -1
- package/dist/v2/runtime/endpoints/express.d.cts +26 -7
- package/dist/v2/runtime/endpoints/express.d.cts.map +1 -1
- package/dist/v2/runtime/endpoints/express.d.mts +26 -7
- package/dist/v2/runtime/endpoints/express.d.mts.map +1 -1
- package/dist/v2/runtime/endpoints/express.mjs +2 -2
- package/dist/v2/runtime/endpoints/express.mjs.map +1 -1
- package/dist/v2/runtime/endpoints/hono.d.cts +2 -2
- package/dist/v2/runtime/endpoints/hono.d.mts +2 -2
- package/dist/v2/runtime/endpoints/index.d.cts +3 -3
- package/dist/v2/runtime/endpoints/index.d.mts +3 -3
- package/dist/v2/runtime/endpoints/load-express.cjs +36 -0
- package/dist/v2/runtime/endpoints/load-express.cjs.map +1 -0
- package/dist/v2/runtime/endpoints/load-express.mjs +35 -0
- package/dist/v2/runtime/endpoints/load-express.mjs.map +1 -0
- package/dist/v2/runtime/handlers/handle-stop.cjs +18 -14
- package/dist/v2/runtime/handlers/handle-stop.cjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-stop.mjs +18 -14
- package/dist/v2/runtime/handlers/handle-stop.mjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-suggest.cjs +4 -3
- package/dist/v2/runtime/handlers/handle-suggest.cjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-suggest.mjs +5 -4
- package/dist/v2/runtime/handlers/handle-suggest.mjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/agent-utils.cjs +3 -4
- package/dist/v2/runtime/handlers/shared/agent-utils.cjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/agent-utils.mjs +1 -2
- package/dist/v2/runtime/handlers/shared/agent-utils.mjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/sse-keep-alive.cjs +69 -0
- package/dist/v2/runtime/handlers/shared/sse-keep-alive.cjs.map +1 -0
- package/dist/v2/runtime/handlers/shared/sse-keep-alive.mjs +67 -0
- package/dist/v2/runtime/handlers/shared/sse-keep-alive.mjs.map +1 -0
- package/dist/v2/runtime/handlers/shared/sse-response.cjs +5 -2
- package/dist/v2/runtime/handlers/shared/sse-response.cjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/sse-response.mjs +5 -2
- package/dist/v2/runtime/handlers/shared/sse-response.mjs.map +1 -1
- package/dist/v2/runtime/handlers/sse/connect.cjs +1 -0
- package/dist/v2/runtime/handlers/sse/connect.cjs.map +1 -1
- package/dist/v2/runtime/handlers/sse/connect.mjs +1 -0
- package/dist/v2/runtime/handlers/sse/connect.mjs.map +1 -1
- package/dist/v2/runtime/handlers/sse/run.cjs +1 -0
- package/dist/v2/runtime/handlers/sse/run.cjs.map +1 -1
- package/dist/v2/runtime/handlers/sse/run.mjs +1 -0
- package/dist/v2/runtime/handlers/sse/run.mjs.map +1 -1
- package/dist/v2/runtime/index.d.cts +9 -9
- package/dist/v2/runtime/index.d.mts +9 -9
- package/dist/v2/runtime/intelligence-platform/client.cjs +1 -1
- package/dist/v2/runtime/intelligence-platform/client.d.cts +1 -1
- package/dist/v2/runtime/intelligence-platform/client.d.mts +1 -1
- package/dist/v2/runtime/intelligence-platform/client.mjs +1 -1
- package/dist/v2/runtime/intelligence-platform/skill-registry/archive.cjs +132 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/archive.cjs.map +1 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/archive.d.cts +11 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/archive.d.cts.map +1 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/archive.d.mts +11 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/archive.d.mts.map +1 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/archive.mjs +128 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/archive.mjs.map +1 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/config.cjs +48 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/config.cjs.map +1 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/config.d.cts +27 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/config.d.cts.map +1 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/config.d.mts +27 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/config.d.mts.map +1 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/config.mjs +48 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/config.mjs.map +1 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/errors.cjs +11 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/errors.cjs.map +1 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/errors.d.cts +8 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/errors.d.cts.map +1 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/errors.d.mts +8 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/errors.d.mts.map +1 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/errors.mjs +11 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/errors.mjs.map +1 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/index.d.cts +8 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/index.d.mts +8 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/registry.cjs +132 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/registry.cjs.map +1 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/registry.d.cts +31 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/registry.d.cts.map +1 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/registry.d.mts +31 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/registry.d.mts.map +1 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/registry.mjs +132 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/registry.mjs.map +1 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/skill-content.cjs +42 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/skill-content.cjs.map +1 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/skill-content.d.cts +13 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/skill-content.d.cts.map +1 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/skill-content.d.mts +13 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/skill-content.d.mts.map +1 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/skill-content.mjs +39 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/skill-content.mjs.map +1 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/snapshot.cjs +93 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/snapshot.cjs.map +1 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/snapshot.d.cts +28 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/snapshot.d.cts.map +1 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/snapshot.d.mts +28 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/snapshot.d.mts.map +1 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/snapshot.mjs +92 -0
- package/dist/v2/runtime/intelligence-platform/skill-registry/snapshot.mjs.map +1 -0
- package/dist/v2/runtime/runner/agent-runner.d.cts +1 -1
- package/dist/v2/runtime/runner/in-memory.d.cts +1 -1
- package/dist/v2/runtime/runner/index.d.cts +2 -2
- package/dist/v2/runtime/runner/index.d.mts +2 -2
- package/dist/v2/runtime/runner/index.mjs +2 -2
- package/dist/v2/runtime/runner/intelligence.d.cts +1 -1
- package/package.json +17 -7
- package/dist/v2/runtime/open-generative-ui-middleware.cjs +0 -286
- package/dist/v2/runtime/open-generative-ui-middleware.cjs.map +0 -1
- package/dist/v2/runtime/open-generative-ui-middleware.mjs +0 -284
- package/dist/v2/runtime/open-generative-ui-middleware.mjs.map +0 -1
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
require("reflect-metadata");
|
|
2
|
+
|
|
3
|
+
//#region src/v1-deprecated/lib/runtime/mcp-client-cache.ts
|
|
4
|
+
/**
|
|
5
|
+
* Cap on live MCP connections. Reached only by runtimes whose endpoint config
|
|
6
|
+
* varies per request — a static `mcpServers` list occupies one slot per
|
|
7
|
+
* server for the life of the process.
|
|
8
|
+
*/
|
|
9
|
+
const MAX_ENTRIES = 100;
|
|
10
|
+
const cache = /* @__PURE__ */ new Map();
|
|
11
|
+
/**
|
|
12
|
+
* A form of the endpoint that is safe to write to application logs.
|
|
13
|
+
*
|
|
14
|
+
* Both halves of an endpoint URL can carry a secret: userinfo, and the query
|
|
15
|
+
* string — the #2407 reporter's own workaround appended `?uid=<hash of the
|
|
16
|
+
* API key>`. Only the origin and path survive.
|
|
17
|
+
*
|
|
18
|
+
* Used for anything that leaves this process with an endpoint in it: log
|
|
19
|
+
* lines, and the tool descriptions that go to the model provider.
|
|
20
|
+
*/
|
|
21
|
+
function describeEndpoint(endpoint) {
|
|
22
|
+
if (!endpoint) return "an MCP endpoint";
|
|
23
|
+
try {
|
|
24
|
+
const url = new URL(endpoint);
|
|
25
|
+
return `${url.protocol}//${url.host}${url.pathname}`;
|
|
26
|
+
} catch {
|
|
27
|
+
return "an MCP endpoint";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Identity for a `createMCPClient` implementation.
|
|
32
|
+
*
|
|
33
|
+
* Two runtimes that pass the same factory may share a connection. Two that
|
|
34
|
+
* pass different factories must not: the second runtime's factory could wrap
|
|
35
|
+
* the transport, add auth, or point somewhere else entirely, and handing it a
|
|
36
|
+
* client built by the first would silently bypass all of that.
|
|
37
|
+
*/
|
|
38
|
+
const factoryIds = /* @__PURE__ */ new WeakMap();
|
|
39
|
+
let nextFactoryId = 0;
|
|
40
|
+
function factoryId(factory) {
|
|
41
|
+
let id = factoryIds.get(factory);
|
|
42
|
+
if (!id) {
|
|
43
|
+
id = `f${++nextFactoryId}`;
|
|
44
|
+
factoryIds.set(factory, id);
|
|
45
|
+
}
|
|
46
|
+
return id;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Deterministic serialization of an endpoint config, so that two configs that
|
|
50
|
+
* differ only in key order produce one cache entry, and two that differ in
|
|
51
|
+
* `apiKey` produce two.
|
|
52
|
+
*/
|
|
53
|
+
function stableStringify(value) {
|
|
54
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value) ?? "null";
|
|
55
|
+
if (Array.isArray(value)) return `[${value.map(stableStringify).join(",")}]`;
|
|
56
|
+
return `{${Object.entries(value).filter(([, v]) => typeof v !== "function" && v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => `${JSON.stringify(k)}:${stableStringify(v)}`).join(",")}}`;
|
|
57
|
+
}
|
|
58
|
+
function mcpCacheKey(createMCPClient, config) {
|
|
59
|
+
return `${factoryId(createMCPClient)}::${stableStringify(config)}`;
|
|
60
|
+
}
|
|
61
|
+
async function closeQuietly(client, label) {
|
|
62
|
+
try {
|
|
63
|
+
await client.close?.();
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.error(`MCP: Failed to close the client for ${label}:`, error);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** Drop the least recently used entries until the cache is within its cap. */
|
|
69
|
+
async function evictDownToCap() {
|
|
70
|
+
while (cache.size > MAX_ENTRIES) {
|
|
71
|
+
const oldestKey = cache.keys().next().value;
|
|
72
|
+
if (oldestKey === void 0) return;
|
|
73
|
+
const evicted = cache.get(oldestKey);
|
|
74
|
+
cache.delete(oldestKey);
|
|
75
|
+
if (!evicted) continue;
|
|
76
|
+
try {
|
|
77
|
+
const entry = await evicted.entry;
|
|
78
|
+
if (entry) await closeQuietly(entry.client, evicted.label);
|
|
79
|
+
} catch {}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Return the cached connection for this factory and config, creating it on
|
|
84
|
+
* first use.
|
|
85
|
+
*
|
|
86
|
+
* A rejected creation is removed rather than cached, so a server that was
|
|
87
|
+
* briefly unreachable is retried on the next request instead of staying
|
|
88
|
+
* toolless for the life of the process.
|
|
89
|
+
*/
|
|
90
|
+
function resolveMCPEntry(createMCPClient, config, build) {
|
|
91
|
+
const key = mcpCacheKey(createMCPClient, config);
|
|
92
|
+
const hit = cache.get(key);
|
|
93
|
+
if (hit) {
|
|
94
|
+
cache.delete(key);
|
|
95
|
+
cache.set(key, hit);
|
|
96
|
+
return hit.entry;
|
|
97
|
+
}
|
|
98
|
+
const slot = {
|
|
99
|
+
label: describeEndpoint(config?.endpoint),
|
|
100
|
+
entry: void 0
|
|
101
|
+
};
|
|
102
|
+
const created = build().catch((error) => {
|
|
103
|
+
if (cache.get(key) === slot) cache.delete(key);
|
|
104
|
+
throw error;
|
|
105
|
+
});
|
|
106
|
+
slot.entry = created;
|
|
107
|
+
cache.set(key, slot);
|
|
108
|
+
evictDownToCap();
|
|
109
|
+
return created;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Mark an entry as recently used.
|
|
113
|
+
*
|
|
114
|
+
* Without this, an entry's position is set once, when the agent resolves, and
|
|
115
|
+
* a run that is actively calling tools still ages toward eviction — so a busy
|
|
116
|
+
* process can close a connection out from under a live run. Tool execution is
|
|
117
|
+
* the only signal available that a connection is still wanted: the v1 runtime
|
|
118
|
+
* has no reliable end-of-run hook to lease against (an abandoned SSE run never
|
|
119
|
+
* fires one), so a lease taken at resolution could never be released.
|
|
120
|
+
*
|
|
121
|
+
* A no-op when the key is gone, which is the already-evicted case.
|
|
122
|
+
*/
|
|
123
|
+
function touchMCPEntry(createMCPClient, config) {
|
|
124
|
+
const key = mcpCacheKey(createMCPClient, config);
|
|
125
|
+
const slot = cache.get(key);
|
|
126
|
+
if (!slot) return;
|
|
127
|
+
cache.delete(key);
|
|
128
|
+
cache.set(key, slot);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
//#endregion
|
|
132
|
+
exports.describeEndpoint = describeEndpoint;
|
|
133
|
+
exports.resolveMCPEntry = resolveMCPEntry;
|
|
134
|
+
exports.touchMCPEntry = touchMCPEntry;
|
|
135
|
+
//# sourceMappingURL=mcp-client-cache.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-client-cache.cjs","names":[],"sources":["../../../../src/v1-deprecated/lib/runtime/mcp-client-cache.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * Internal helper for the v1 CopilotRuntime shim. Not exported from the\n * package. The v2 path builds its MCP clients per run in `agent/index.ts`.\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\nimport type { MCPClient, MCPEndpointConfig } from \"./mcp-tools-utils\";\n\n/**\n * One cached MCP connection and the tool definitions built from it.\n *\n * The tool definitions close over `tool.execute` on this exact client, so the\n * two share a lifetime: dropping the entry has to close the client, and\n * closing the client has to drop the tools.\n */\nexport interface MCPCacheEntry<TTools> {\n client: MCPClient;\n tools: TTools;\n}\n\n/**\n * Cap on live MCP connections. Reached only by runtimes whose endpoint config\n * varies per request — a static `mcpServers` list occupies one slot per\n * server for the life of the process.\n */\nconst MAX_ENTRIES = 100;\n\n/**\n * Process-wide, not per runtime instance.\n *\n * The documented per-request pattern builds `new CopilotRuntime(...)` inside\n * the request handler, so a cache owned by the instance is a fresh cache on\n * every request: one connection per HTTP request, never closed. Keying the\n * cache on the client factory plus the endpoint config instead means those\n * runtimes share the connection they would otherwise re-open, and the entry\n * count is bounded by the number of distinct credentials in play rather than\n * by traffic.\n *\n * The slot carries a redacted endpoint label beside the connection. The cache\n * *key* cannot be used for that: it contains the serialized config, and the\n * config contains `apiKey`.\n */\ninterface MCPCacheSlot {\n /** Safe to log. See `describeEndpoint`. */\n label: string;\n entry: Promise<MCPCacheEntry<unknown>>;\n}\n\nconst cache = new Map<string, MCPCacheSlot>();\n\n/**\n * A form of the endpoint that is safe to write to application logs.\n *\n * Both halves of an endpoint URL can carry a secret: userinfo, and the query\n * string — the #2407 reporter's own workaround appended `?uid=<hash of the\n * API key>`. Only the origin and path survive.\n *\n * Used for anything that leaves this process with an endpoint in it: log\n * lines, and the tool descriptions that go to the model provider.\n */\nexport function describeEndpoint(endpoint: string | undefined): string {\n if (!endpoint) return \"an MCP endpoint\";\n try {\n const url = new URL(endpoint);\n // Not `url.origin`: for any scheme other than http(s) that is the opaque\n // origin, the literal string \"null\", and `pathname` is empty — so a\n // `stdio://` endpoint would render as \"null\" in a log and in a prompt.\n // Rebuilding from protocol and host keeps every scheme legible while\n // still dropping userinfo, query, and fragment.\n return `${url.protocol}//${url.host}${url.pathname}`;\n } catch {\n return \"an MCP endpoint\";\n }\n}\n\n/**\n * Identity for a `createMCPClient` implementation.\n *\n * Two runtimes that pass the same factory may share a connection. Two that\n * pass different factories must not: the second runtime's factory could wrap\n * the transport, add auth, or point somewhere else entirely, and handing it a\n * client built by the first would silently bypass all of that.\n */\nconst factoryIds = new WeakMap<object, string>();\nlet nextFactoryId = 0;\n\nfunction factoryId(factory: object): string {\n let id = factoryIds.get(factory);\n if (!id) {\n id = `f${++nextFactoryId}`;\n factoryIds.set(factory, id);\n }\n return id;\n}\n\n/**\n * Deterministic serialization of an endpoint config, so that two configs that\n * differ only in key order produce one cache entry, and two that differ in\n * `apiKey` produce two.\n */\nfunction stableStringify(value: unknown): string {\n if (value === null || typeof value !== \"object\") {\n return JSON.stringify(value) ?? \"null\";\n }\n if (Array.isArray(value)) {\n return `[${value.map(stableStringify).join(\",\")}]`;\n }\n const entries = Object.entries(value as Record<string, unknown>)\n .filter(([, v]) => typeof v !== \"function\" && v !== undefined)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([k, v]) => `${JSON.stringify(k)}:${stableStringify(v)}`);\n return `{${entries.join(\",\")}}`;\n}\n\nexport function mcpCacheKey(\n createMCPClient: object,\n config: MCPEndpointConfig,\n): string {\n return `${factoryId(createMCPClient)}::${stableStringify(config)}`;\n}\n\nasync function closeQuietly(client: MCPClient, label: string) {\n try {\n await client.close?.();\n } catch (error) {\n console.error(`MCP: Failed to close the client for ${label}:`, error);\n }\n}\n\n/** Drop the least recently used entries until the cache is within its cap. */\nasync function evictDownToCap() {\n while (cache.size > MAX_ENTRIES) {\n const oldestKey = cache.keys().next().value as string | undefined;\n if (oldestKey === undefined) return;\n const evicted = cache.get(oldestKey);\n cache.delete(oldestKey);\n if (!evicted) continue;\n try {\n const entry = await evicted.entry;\n if (entry) await closeQuietly(entry.client, evicted.label);\n } catch {\n // A rejected entry has nothing to close.\n }\n }\n}\n\n/**\n * Return the cached connection for this factory and config, creating it on\n * first use.\n *\n * A rejected creation is removed rather than cached, so a server that was\n * briefly unreachable is retried on the next request instead of staying\n * toolless for the life of the process.\n */\nexport function resolveMCPEntry<TTools>(\n createMCPClient: object,\n config: MCPEndpointConfig,\n build: () => Promise<MCPCacheEntry<TTools>>,\n): Promise<MCPCacheEntry<TTools>> {\n const key = mcpCacheKey(createMCPClient, config);\n const hit = cache.get(key);\n if (hit) {\n // Re-insert so that Map iteration order stays least-recently-used first.\n cache.delete(key);\n cache.set(key, hit);\n return hit.entry as Promise<MCPCacheEntry<TTools>>;\n }\n\n const slot: MCPCacheSlot = {\n label: describeEndpoint(config?.endpoint),\n // Assigned below; `build()` cannot run before the slot exists, because the\n // rejection handler compares against it.\n entry: undefined as unknown as Promise<MCPCacheEntry<unknown>>,\n };\n\n const created = build().catch((error: unknown) => {\n // Only drop our own slot. Eviction can remove this key while `build()` is\n // still in flight, and a later request can insert a replacement under it;\n // an unconditional delete would evict that replacement and leave its\n // client live but outside cache cleanup, which is the leak this file\n // exists to prevent.\n if (cache.get(key) === slot) {\n cache.delete(key);\n }\n throw error;\n });\n\n slot.entry = created as Promise<MCPCacheEntry<unknown>>;\n cache.set(key, slot);\n void evictDownToCap();\n return created;\n}\n\n/**\n * Mark an entry as recently used.\n *\n * Without this, an entry's position is set once, when the agent resolves, and\n * a run that is actively calling tools still ages toward eviction — so a busy\n * process can close a connection out from under a live run. Tool execution is\n * the only signal available that a connection is still wanted: the v1 runtime\n * has no reliable end-of-run hook to lease against (an abandoned SSE run never\n * fires one), so a lease taken at resolution could never be released.\n *\n * A no-op when the key is gone, which is the already-evicted case.\n */\nexport function touchMCPEntry(\n createMCPClient: object,\n config: MCPEndpointConfig,\n): void {\n const key = mcpCacheKey(createMCPClient, config);\n const slot = cache.get(key);\n if (!slot) return;\n cache.delete(key);\n cache.set(key, slot);\n}\n\n/** Test seam: close and forget every cached connection. */\nexport async function __resetMCPClientCache() {\n const slots = Array.from(cache.values());\n cache.clear();\n await Promise.all(\n slots.map(async (slot) => {\n try {\n const entry = await slot.entry;\n await closeQuietly(entry.client, slot.label);\n } catch {\n // Nothing to close.\n }\n }),\n );\n}\n\n/** Test seam: how many connections are live. */\nexport function __mcpClientCacheSize() {\n return cache.size;\n}\n"],"mappings":";;;;;;;;AA4BA,MAAM,cAAc;AAuBpB,MAAM,wBAAQ,IAAI,KAA2B;;;;;;;;;;;AAY7C,SAAgB,iBAAiB,UAAsC;AACrE,KAAI,CAAC,SAAU,QAAO;AACtB,KAAI;EACF,MAAM,MAAM,IAAI,IAAI,SAAS;AAM7B,SAAO,GAAG,IAAI,SAAS,IAAI,IAAI,OAAO,IAAI;SACpC;AACN,SAAO;;;;;;;;;;;AAYX,MAAM,6BAAa,IAAI,SAAyB;AAChD,IAAI,gBAAgB;AAEpB,SAAS,UAAU,SAAyB;CAC1C,IAAI,KAAK,WAAW,IAAI,QAAQ;AAChC,KAAI,CAAC,IAAI;AACP,OAAK,IAAI,EAAE;AACX,aAAW,IAAI,SAAS,GAAG;;AAE7B,QAAO;;;;;;;AAQT,SAAS,gBAAgB,OAAwB;AAC/C,KAAI,UAAU,QAAQ,OAAO,UAAU,SACrC,QAAO,KAAK,UAAU,MAAM,IAAI;AAElC,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,IAAI,MAAM,IAAI,gBAAgB,CAAC,KAAK,IAAI,CAAC;AAMlD,QAAO,IAJS,OAAO,QAAQ,MAAiC,CAC7D,QAAQ,GAAG,OAAO,OAAO,MAAM,cAAc,MAAM,OAAU,CAC7D,MAAM,CAAC,IAAI,CAAC,OAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,EAAG,CAChD,KAAK,CAAC,GAAG,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC,GAAG,gBAAgB,EAAE,GAAG,CAC7C,KAAK,IAAI,CAAC;;AAG/B,SAAgB,YACd,iBACA,QACQ;AACR,QAAO,GAAG,UAAU,gBAAgB,CAAC,IAAI,gBAAgB,OAAO;;AAGlE,eAAe,aAAa,QAAmB,OAAe;AAC5D,KAAI;AACF,QAAM,OAAO,SAAS;UACf,OAAO;AACd,UAAQ,MAAM,uCAAuC,MAAM,IAAI,MAAM;;;;AAKzE,eAAe,iBAAiB;AAC9B,QAAO,MAAM,OAAO,aAAa;EAC/B,MAAM,YAAY,MAAM,MAAM,CAAC,MAAM,CAAC;AACtC,MAAI,cAAc,OAAW;EAC7B,MAAM,UAAU,MAAM,IAAI,UAAU;AACpC,QAAM,OAAO,UAAU;AACvB,MAAI,CAAC,QAAS;AACd,MAAI;GACF,MAAM,QAAQ,MAAM,QAAQ;AAC5B,OAAI,MAAO,OAAM,aAAa,MAAM,QAAQ,QAAQ,MAAM;UACpD;;;;;;;;;;;AAcZ,SAAgB,gBACd,iBACA,QACA,OACgC;CAChC,MAAM,MAAM,YAAY,iBAAiB,OAAO;CAChD,MAAM,MAAM,MAAM,IAAI,IAAI;AAC1B,KAAI,KAAK;AAEP,QAAM,OAAO,IAAI;AACjB,QAAM,IAAI,KAAK,IAAI;AACnB,SAAO,IAAI;;CAGb,MAAM,OAAqB;EACzB,OAAO,iBAAiB,QAAQ,SAAS;EAGzC,OAAO;EACR;CAED,MAAM,UAAU,OAAO,CAAC,OAAO,UAAmB;AAMhD,MAAI,MAAM,IAAI,IAAI,KAAK,KACrB,OAAM,OAAO,IAAI;AAEnB,QAAM;GACN;AAEF,MAAK,QAAQ;AACb,OAAM,IAAI,KAAK,KAAK;AACpB,CAAK,gBAAgB;AACrB,QAAO;;;;;;;;;;;;;;AAeT,SAAgB,cACd,iBACA,QACM;CACN,MAAM,MAAM,YAAY,iBAAiB,OAAO;CAChD,MAAM,OAAO,MAAM,IAAI,IAAI;AAC3B,KAAI,CAAC,KAAM;AACX,OAAM,OAAO,IAAI;AACjB,OAAM,IAAI,KAAK,KAAK"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
//#region src/v1-deprecated/lib/runtime/mcp-client-cache.ts
|
|
3
|
+
/**
|
|
4
|
+
* Cap on live MCP connections. Reached only by runtimes whose endpoint config
|
|
5
|
+
* varies per request — a static `mcpServers` list occupies one slot per
|
|
6
|
+
* server for the life of the process.
|
|
7
|
+
*/
|
|
8
|
+
const MAX_ENTRIES = 100;
|
|
9
|
+
const cache = /* @__PURE__ */ new Map();
|
|
10
|
+
/**
|
|
11
|
+
* A form of the endpoint that is safe to write to application logs.
|
|
12
|
+
*
|
|
13
|
+
* Both halves of an endpoint URL can carry a secret: userinfo, and the query
|
|
14
|
+
* string — the #2407 reporter's own workaround appended `?uid=<hash of the
|
|
15
|
+
* API key>`. Only the origin and path survive.
|
|
16
|
+
*
|
|
17
|
+
* Used for anything that leaves this process with an endpoint in it: log
|
|
18
|
+
* lines, and the tool descriptions that go to the model provider.
|
|
19
|
+
*/
|
|
20
|
+
function describeEndpoint(endpoint) {
|
|
21
|
+
if (!endpoint) return "an MCP endpoint";
|
|
22
|
+
try {
|
|
23
|
+
const url = new URL(endpoint);
|
|
24
|
+
return `${url.protocol}//${url.host}${url.pathname}`;
|
|
25
|
+
} catch {
|
|
26
|
+
return "an MCP endpoint";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Identity for a `createMCPClient` implementation.
|
|
31
|
+
*
|
|
32
|
+
* Two runtimes that pass the same factory may share a connection. Two that
|
|
33
|
+
* pass different factories must not: the second runtime's factory could wrap
|
|
34
|
+
* the transport, add auth, or point somewhere else entirely, and handing it a
|
|
35
|
+
* client built by the first would silently bypass all of that.
|
|
36
|
+
*/
|
|
37
|
+
const factoryIds = /* @__PURE__ */ new WeakMap();
|
|
38
|
+
let nextFactoryId = 0;
|
|
39
|
+
function factoryId(factory) {
|
|
40
|
+
let id = factoryIds.get(factory);
|
|
41
|
+
if (!id) {
|
|
42
|
+
id = `f${++nextFactoryId}`;
|
|
43
|
+
factoryIds.set(factory, id);
|
|
44
|
+
}
|
|
45
|
+
return id;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Deterministic serialization of an endpoint config, so that two configs that
|
|
49
|
+
* differ only in key order produce one cache entry, and two that differ in
|
|
50
|
+
* `apiKey` produce two.
|
|
51
|
+
*/
|
|
52
|
+
function stableStringify(value) {
|
|
53
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value) ?? "null";
|
|
54
|
+
if (Array.isArray(value)) return `[${value.map(stableStringify).join(",")}]`;
|
|
55
|
+
return `{${Object.entries(value).filter(([, v]) => typeof v !== "function" && v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => `${JSON.stringify(k)}:${stableStringify(v)}`).join(",")}}`;
|
|
56
|
+
}
|
|
57
|
+
function mcpCacheKey(createMCPClient, config) {
|
|
58
|
+
return `${factoryId(createMCPClient)}::${stableStringify(config)}`;
|
|
59
|
+
}
|
|
60
|
+
async function closeQuietly(client, label) {
|
|
61
|
+
try {
|
|
62
|
+
await client.close?.();
|
|
63
|
+
} catch (error) {
|
|
64
|
+
console.error(`MCP: Failed to close the client for ${label}:`, error);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** Drop the least recently used entries until the cache is within its cap. */
|
|
68
|
+
async function evictDownToCap() {
|
|
69
|
+
while (cache.size > MAX_ENTRIES) {
|
|
70
|
+
const oldestKey = cache.keys().next().value;
|
|
71
|
+
if (oldestKey === void 0) return;
|
|
72
|
+
const evicted = cache.get(oldestKey);
|
|
73
|
+
cache.delete(oldestKey);
|
|
74
|
+
if (!evicted) continue;
|
|
75
|
+
try {
|
|
76
|
+
const entry = await evicted.entry;
|
|
77
|
+
if (entry) await closeQuietly(entry.client, evicted.label);
|
|
78
|
+
} catch {}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Return the cached connection for this factory and config, creating it on
|
|
83
|
+
* first use.
|
|
84
|
+
*
|
|
85
|
+
* A rejected creation is removed rather than cached, so a server that was
|
|
86
|
+
* briefly unreachable is retried on the next request instead of staying
|
|
87
|
+
* toolless for the life of the process.
|
|
88
|
+
*/
|
|
89
|
+
function resolveMCPEntry(createMCPClient, config, build) {
|
|
90
|
+
const key = mcpCacheKey(createMCPClient, config);
|
|
91
|
+
const hit = cache.get(key);
|
|
92
|
+
if (hit) {
|
|
93
|
+
cache.delete(key);
|
|
94
|
+
cache.set(key, hit);
|
|
95
|
+
return hit.entry;
|
|
96
|
+
}
|
|
97
|
+
const slot = {
|
|
98
|
+
label: describeEndpoint(config?.endpoint),
|
|
99
|
+
entry: void 0
|
|
100
|
+
};
|
|
101
|
+
const created = build().catch((error) => {
|
|
102
|
+
if (cache.get(key) === slot) cache.delete(key);
|
|
103
|
+
throw error;
|
|
104
|
+
});
|
|
105
|
+
slot.entry = created;
|
|
106
|
+
cache.set(key, slot);
|
|
107
|
+
evictDownToCap();
|
|
108
|
+
return created;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Mark an entry as recently used.
|
|
112
|
+
*
|
|
113
|
+
* Without this, an entry's position is set once, when the agent resolves, and
|
|
114
|
+
* a run that is actively calling tools still ages toward eviction — so a busy
|
|
115
|
+
* process can close a connection out from under a live run. Tool execution is
|
|
116
|
+
* the only signal available that a connection is still wanted: the v1 runtime
|
|
117
|
+
* has no reliable end-of-run hook to lease against (an abandoned SSE run never
|
|
118
|
+
* fires one), so a lease taken at resolution could never be released.
|
|
119
|
+
*
|
|
120
|
+
* A no-op when the key is gone, which is the already-evicted case.
|
|
121
|
+
*/
|
|
122
|
+
function touchMCPEntry(createMCPClient, config) {
|
|
123
|
+
const key = mcpCacheKey(createMCPClient, config);
|
|
124
|
+
const slot = cache.get(key);
|
|
125
|
+
if (!slot) return;
|
|
126
|
+
cache.delete(key);
|
|
127
|
+
cache.set(key, slot);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
//#endregion
|
|
131
|
+
export { describeEndpoint, resolveMCPEntry, touchMCPEntry };
|
|
132
|
+
//# sourceMappingURL=mcp-client-cache.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-client-cache.mjs","names":[],"sources":["../../../../src/v1-deprecated/lib/runtime/mcp-client-cache.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * Internal helper for the v1 CopilotRuntime shim. Not exported from the\n * package. The v2 path builds its MCP clients per run in `agent/index.ts`.\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\nimport type { MCPClient, MCPEndpointConfig } from \"./mcp-tools-utils\";\n\n/**\n * One cached MCP connection and the tool definitions built from it.\n *\n * The tool definitions close over `tool.execute` on this exact client, so the\n * two share a lifetime: dropping the entry has to close the client, and\n * closing the client has to drop the tools.\n */\nexport interface MCPCacheEntry<TTools> {\n client: MCPClient;\n tools: TTools;\n}\n\n/**\n * Cap on live MCP connections. Reached only by runtimes whose endpoint config\n * varies per request — a static `mcpServers` list occupies one slot per\n * server for the life of the process.\n */\nconst MAX_ENTRIES = 100;\n\n/**\n * Process-wide, not per runtime instance.\n *\n * The documented per-request pattern builds `new CopilotRuntime(...)` inside\n * the request handler, so a cache owned by the instance is a fresh cache on\n * every request: one connection per HTTP request, never closed. Keying the\n * cache on the client factory plus the endpoint config instead means those\n * runtimes share the connection they would otherwise re-open, and the entry\n * count is bounded by the number of distinct credentials in play rather than\n * by traffic.\n *\n * The slot carries a redacted endpoint label beside the connection. The cache\n * *key* cannot be used for that: it contains the serialized config, and the\n * config contains `apiKey`.\n */\ninterface MCPCacheSlot {\n /** Safe to log. See `describeEndpoint`. */\n label: string;\n entry: Promise<MCPCacheEntry<unknown>>;\n}\n\nconst cache = new Map<string, MCPCacheSlot>();\n\n/**\n * A form of the endpoint that is safe to write to application logs.\n *\n * Both halves of an endpoint URL can carry a secret: userinfo, and the query\n * string — the #2407 reporter's own workaround appended `?uid=<hash of the\n * API key>`. Only the origin and path survive.\n *\n * Used for anything that leaves this process with an endpoint in it: log\n * lines, and the tool descriptions that go to the model provider.\n */\nexport function describeEndpoint(endpoint: string | undefined): string {\n if (!endpoint) return \"an MCP endpoint\";\n try {\n const url = new URL(endpoint);\n // Not `url.origin`: for any scheme other than http(s) that is the opaque\n // origin, the literal string \"null\", and `pathname` is empty — so a\n // `stdio://` endpoint would render as \"null\" in a log and in a prompt.\n // Rebuilding from protocol and host keeps every scheme legible while\n // still dropping userinfo, query, and fragment.\n return `${url.protocol}//${url.host}${url.pathname}`;\n } catch {\n return \"an MCP endpoint\";\n }\n}\n\n/**\n * Identity for a `createMCPClient` implementation.\n *\n * Two runtimes that pass the same factory may share a connection. Two that\n * pass different factories must not: the second runtime's factory could wrap\n * the transport, add auth, or point somewhere else entirely, and handing it a\n * client built by the first would silently bypass all of that.\n */\nconst factoryIds = new WeakMap<object, string>();\nlet nextFactoryId = 0;\n\nfunction factoryId(factory: object): string {\n let id = factoryIds.get(factory);\n if (!id) {\n id = `f${++nextFactoryId}`;\n factoryIds.set(factory, id);\n }\n return id;\n}\n\n/**\n * Deterministic serialization of an endpoint config, so that two configs that\n * differ only in key order produce one cache entry, and two that differ in\n * `apiKey` produce two.\n */\nfunction stableStringify(value: unknown): string {\n if (value === null || typeof value !== \"object\") {\n return JSON.stringify(value) ?? \"null\";\n }\n if (Array.isArray(value)) {\n return `[${value.map(stableStringify).join(\",\")}]`;\n }\n const entries = Object.entries(value as Record<string, unknown>)\n .filter(([, v]) => typeof v !== \"function\" && v !== undefined)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([k, v]) => `${JSON.stringify(k)}:${stableStringify(v)}`);\n return `{${entries.join(\",\")}}`;\n}\n\nexport function mcpCacheKey(\n createMCPClient: object,\n config: MCPEndpointConfig,\n): string {\n return `${factoryId(createMCPClient)}::${stableStringify(config)}`;\n}\n\nasync function closeQuietly(client: MCPClient, label: string) {\n try {\n await client.close?.();\n } catch (error) {\n console.error(`MCP: Failed to close the client for ${label}:`, error);\n }\n}\n\n/** Drop the least recently used entries until the cache is within its cap. */\nasync function evictDownToCap() {\n while (cache.size > MAX_ENTRIES) {\n const oldestKey = cache.keys().next().value as string | undefined;\n if (oldestKey === undefined) return;\n const evicted = cache.get(oldestKey);\n cache.delete(oldestKey);\n if (!evicted) continue;\n try {\n const entry = await evicted.entry;\n if (entry) await closeQuietly(entry.client, evicted.label);\n } catch {\n // A rejected entry has nothing to close.\n }\n }\n}\n\n/**\n * Return the cached connection for this factory and config, creating it on\n * first use.\n *\n * A rejected creation is removed rather than cached, so a server that was\n * briefly unreachable is retried on the next request instead of staying\n * toolless for the life of the process.\n */\nexport function resolveMCPEntry<TTools>(\n createMCPClient: object,\n config: MCPEndpointConfig,\n build: () => Promise<MCPCacheEntry<TTools>>,\n): Promise<MCPCacheEntry<TTools>> {\n const key = mcpCacheKey(createMCPClient, config);\n const hit = cache.get(key);\n if (hit) {\n // Re-insert so that Map iteration order stays least-recently-used first.\n cache.delete(key);\n cache.set(key, hit);\n return hit.entry as Promise<MCPCacheEntry<TTools>>;\n }\n\n const slot: MCPCacheSlot = {\n label: describeEndpoint(config?.endpoint),\n // Assigned below; `build()` cannot run before the slot exists, because the\n // rejection handler compares against it.\n entry: undefined as unknown as Promise<MCPCacheEntry<unknown>>,\n };\n\n const created = build().catch((error: unknown) => {\n // Only drop our own slot. Eviction can remove this key while `build()` is\n // still in flight, and a later request can insert a replacement under it;\n // an unconditional delete would evict that replacement and leave its\n // client live but outside cache cleanup, which is the leak this file\n // exists to prevent.\n if (cache.get(key) === slot) {\n cache.delete(key);\n }\n throw error;\n });\n\n slot.entry = created as Promise<MCPCacheEntry<unknown>>;\n cache.set(key, slot);\n void evictDownToCap();\n return created;\n}\n\n/**\n * Mark an entry as recently used.\n *\n * Without this, an entry's position is set once, when the agent resolves, and\n * a run that is actively calling tools still ages toward eviction — so a busy\n * process can close a connection out from under a live run. Tool execution is\n * the only signal available that a connection is still wanted: the v1 runtime\n * has no reliable end-of-run hook to lease against (an abandoned SSE run never\n * fires one), so a lease taken at resolution could never be released.\n *\n * A no-op when the key is gone, which is the already-evicted case.\n */\nexport function touchMCPEntry(\n createMCPClient: object,\n config: MCPEndpointConfig,\n): void {\n const key = mcpCacheKey(createMCPClient, config);\n const slot = cache.get(key);\n if (!slot) return;\n cache.delete(key);\n cache.set(key, slot);\n}\n\n/** Test seam: close and forget every cached connection. */\nexport async function __resetMCPClientCache() {\n const slots = Array.from(cache.values());\n cache.clear();\n await Promise.all(\n slots.map(async (slot) => {\n try {\n const entry = await slot.entry;\n await closeQuietly(entry.client, slot.label);\n } catch {\n // Nothing to close.\n }\n }),\n );\n}\n\n/** Test seam: how many connections are live. */\nexport function __mcpClientCacheSize() {\n return cache.size;\n}\n"],"mappings":";;;;;;;AA4BA,MAAM,cAAc;AAuBpB,MAAM,wBAAQ,IAAI,KAA2B;;;;;;;;;;;AAY7C,SAAgB,iBAAiB,UAAsC;AACrE,KAAI,CAAC,SAAU,QAAO;AACtB,KAAI;EACF,MAAM,MAAM,IAAI,IAAI,SAAS;AAM7B,SAAO,GAAG,IAAI,SAAS,IAAI,IAAI,OAAO,IAAI;SACpC;AACN,SAAO;;;;;;;;;;;AAYX,MAAM,6BAAa,IAAI,SAAyB;AAChD,IAAI,gBAAgB;AAEpB,SAAS,UAAU,SAAyB;CAC1C,IAAI,KAAK,WAAW,IAAI,QAAQ;AAChC,KAAI,CAAC,IAAI;AACP,OAAK,IAAI,EAAE;AACX,aAAW,IAAI,SAAS,GAAG;;AAE7B,QAAO;;;;;;;AAQT,SAAS,gBAAgB,OAAwB;AAC/C,KAAI,UAAU,QAAQ,OAAO,UAAU,SACrC,QAAO,KAAK,UAAU,MAAM,IAAI;AAElC,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,IAAI,MAAM,IAAI,gBAAgB,CAAC,KAAK,IAAI,CAAC;AAMlD,QAAO,IAJS,OAAO,QAAQ,MAAiC,CAC7D,QAAQ,GAAG,OAAO,OAAO,MAAM,cAAc,MAAM,OAAU,CAC7D,MAAM,CAAC,IAAI,CAAC,OAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,EAAG,CAChD,KAAK,CAAC,GAAG,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC,GAAG,gBAAgB,EAAE,GAAG,CAC7C,KAAK,IAAI,CAAC;;AAG/B,SAAgB,YACd,iBACA,QACQ;AACR,QAAO,GAAG,UAAU,gBAAgB,CAAC,IAAI,gBAAgB,OAAO;;AAGlE,eAAe,aAAa,QAAmB,OAAe;AAC5D,KAAI;AACF,QAAM,OAAO,SAAS;UACf,OAAO;AACd,UAAQ,MAAM,uCAAuC,MAAM,IAAI,MAAM;;;;AAKzE,eAAe,iBAAiB;AAC9B,QAAO,MAAM,OAAO,aAAa;EAC/B,MAAM,YAAY,MAAM,MAAM,CAAC,MAAM,CAAC;AACtC,MAAI,cAAc,OAAW;EAC7B,MAAM,UAAU,MAAM,IAAI,UAAU;AACpC,QAAM,OAAO,UAAU;AACvB,MAAI,CAAC,QAAS;AACd,MAAI;GACF,MAAM,QAAQ,MAAM,QAAQ;AAC5B,OAAI,MAAO,OAAM,aAAa,MAAM,QAAQ,QAAQ,MAAM;UACpD;;;;;;;;;;;AAcZ,SAAgB,gBACd,iBACA,QACA,OACgC;CAChC,MAAM,MAAM,YAAY,iBAAiB,OAAO;CAChD,MAAM,MAAM,MAAM,IAAI,IAAI;AAC1B,KAAI,KAAK;AAEP,QAAM,OAAO,IAAI;AACjB,QAAM,IAAI,KAAK,IAAI;AACnB,SAAO,IAAI;;CAGb,MAAM,OAAqB;EACzB,OAAO,iBAAiB,QAAQ,SAAS;EAGzC,OAAO;EACR;CAED,MAAM,UAAU,OAAO,CAAC,OAAO,UAAmB;AAMhD,MAAI,MAAM,IAAI,IAAI,KAAK,KACrB,OAAM,OAAO,IAAI;AAEnB,QAAM;GACN;AAEF,MAAK,QAAQ;AACb,OAAM,IAAI,KAAK,KAAK;AACpB,CAAK,gBAAgB;AACrB,QAAO;;;;;;;;;;;;;;AAeT,SAAgB,cACd,iBACA,QACM;CACN,MAAM,MAAM,YAAY,iBAAiB,OAAO;CAChD,MAAM,OAAO,MAAM,IAAI,IAAI;AAC3B,KAAI,CAAC,KAAM;AACX,OAAM,OAAO,IAAI;AACjB,OAAM,IAAI,KAAK,KAAK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry-agent-runner.cjs","names":["InMemoryAgentRunner","telemetry"],"sources":["../../../../src/v1-deprecated/lib/runtime/telemetry-agent-runner.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — TelemetryAgentRunner:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — TelemetryAgentRunnerConfig:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\n/**\n * TelemetryAgentRunner - A wrapper around AgentRunner that adds telemetry\n * for agent execution streams.\n *\n * This captures the following telemetry events:\n * - oss.runtime.agent_execution_stream_started - when an agent execution starts\n * - oss.runtime.agent_execution_stream_ended - when an agent execution completes\n * - oss.runtime.agent_execution_stream_errored - when an agent execution fails\n */\n\nimport { InMemoryAgentRunner } from \"../../../v2/runtime\";\nimport type { AgentRunner } from \"../../../v2/runtime\";\nimport { createHash } from \"node:crypto\";\nimport { tap, catchError, finalize } from \"rxjs\";\nimport telemetry from \"../telemetry-client\";\nimport type { AgentExecutionResponseInfo } from \"@copilotkit/shared/src/telemetry/events\";\nimport type { TelemetryCapture } from \"@copilotkit/shared\";\n\n/**\n * Configuration options for TelemetryAgentRunner\n */\nexport interface TelemetryAgentRunnerConfig {\n /**\n * The underlying runner to delegate to\n * If not provided, defaults to InMemoryAgentRunner\n */\n runner?: AgentRunner;\n\n /**\n * Optional LangSmith API key (will be hashed for telemetry)\n */\n langsmithApiKey?: string;\n\n /** Runtime-bound telemetry capture. Defaults to the legacy singleton. */\n telemetry?: TelemetryCapture;\n}\n\n/**\n * An AgentRunner wrapper that adds telemetry tracking for agent executions.\n *\n * Usage:\n * ```ts\n * const runtime = new CopilotRuntime({\n * runner: new TelemetryAgentRunner(),\n * // or with custom runner:\n * runner: new TelemetryAgentRunner({ runner: customRunner }),\n * });\n * ```\n */\nexport class TelemetryAgentRunner implements AgentRunner {\n private readonly _runner: AgentRunner;\n private readonly hashedLgcKey: string | undefined;\n private readonly telemetry: TelemetryCapture;\n\n constructor(config?: TelemetryAgentRunnerConfig) {\n this._runner = config?.runner ?? new InMemoryAgentRunner();\n this.telemetry = config?.telemetry ?? telemetry;\n this.hashedLgcKey = config?.langsmithApiKey\n ? createHash(\"sha256\").update(config.langsmithApiKey).digest(\"hex\")\n : undefined;\n }\n\n /**\n * Runs an agent with telemetry tracking.\n * Wraps the underlying runner's Observable stream with telemetry events.\n */\n run(...args: Parameters<AgentRunner[\"run\"]>): ReturnType<AgentRunner[\"run\"]> {\n const streamInfo: AgentExecutionResponseInfo = {\n hashedLgcKey: this.hashedLgcKey,\n };\n let streamErrored = false;\n\n // Capture stream started event\n this.telemetry.capture(\"oss.runtime.agent_execution_stream_started\", {\n hashedLgcKey: this.hashedLgcKey,\n });\n\n // Delegate to the underlying runner and wrap with telemetry\n return this._runner.run(...args).pipe(\n // Extract metadata from events if available\n tap((event) => {\n // Try to extract provider/model info from raw events\n const rawEvent = (\n event as {\n rawEvent?: {\n metadata?: Record<string, unknown>;\n data?: Record<string, unknown>;\n };\n }\n ).rawEvent;\n if (rawEvent?.data) {\n const data = rawEvent.data as { output?: { model?: string } };\n if (data?.output?.model) {\n streamInfo.model = data.output.model;\n streamInfo.provider = data.output.model;\n }\n }\n if (rawEvent?.metadata) {\n const metadata = rawEvent.metadata as {\n langgraph_host?: string;\n langgraph_version?: string;\n };\n if (metadata?.langgraph_host) {\n streamInfo.langGraphHost = metadata.langgraph_host;\n }\n if (metadata?.langgraph_version) {\n streamInfo.langGraphVersion = metadata.langgraph_version;\n }\n }\n }),\n catchError((error) => {\n // Capture stream error event\n streamErrored = true;\n this.telemetry.capture(\"oss.runtime.agent_execution_stream_errored\", {\n ...streamInfo,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }),\n finalize(() => {\n // Capture stream ended event (only if not errored)\n if (!streamErrored) {\n this.telemetry.capture(\n \"oss.runtime.agent_execution_stream_ended\",\n streamInfo,\n );\n }\n }),\n );\n }\n\n /**\n * Delegates to the underlying runner's connect method\n */\n connect(\n ...args: Parameters<AgentRunner[\"connect\"]>\n ): ReturnType<AgentRunner[\"connect\"]> {\n return this._runner.connect(...args);\n }\n\n /**\n * Delegates to the underlying runner's isRunning method\n */\n isRunning(\n ...args: Parameters<AgentRunner[\"isRunning\"]>\n ): ReturnType<AgentRunner[\"isRunning\"]> {\n return this._runner.isRunning(...args);\n }\n\n /**\n * Delegates to the underlying runner's stop method\n */\n stop(\n ...args: Parameters<AgentRunner[\"stop\"]>\n ): ReturnType<AgentRunner[\"stop\"]> {\n return this._runner.stop(...args);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,IAAa,uBAAb,MAAyD;CAKvD,YAAY,QAAqC;AAC/C,OAAK,UAAU,QAAQ,UAAU,IAAIA,uCAAqB;AAC1D,OAAK,YAAY,QAAQ,aAAaC;AACtC,OAAK,eAAe,QAAQ,8CACb,SAAS,CAAC,OAAO,OAAO,gBAAgB,CAAC,OAAO,MAAM,GACjE;;;;;;CAON,IAAI,GAAG,MAAsE;EAC3E,MAAM,aAAyC,EAC7C,cAAc,KAAK,cACpB;EACD,IAAI,gBAAgB;AAGpB,OAAK,UAAU,QAAQ,8CAA8C,EACnE,cAAc,KAAK,cACpB,CAAC;AAGF,SAAO,KAAK,QAAQ,IAAI,GAAG,KAAK,CAAC,oBAE1B,UAAU;GAEb,MAAM,WACJ,MAMA;AACF,OAAI,UAAU,MAAM;IAClB,MAAM,OAAO,SAAS;AACtB,QAAI,MAAM,QAAQ,OAAO;AACvB,gBAAW,QAAQ,KAAK,OAAO;AAC/B,gBAAW,WAAW,KAAK,OAAO;;;AAGtC,OAAI,UAAU,UAAU;IACtB,MAAM,WAAW,SAAS;AAI1B,QAAI,UAAU,eACZ,YAAW,gBAAgB,SAAS;AAEtC,QAAI,UAAU,kBACZ,YAAW,mBAAmB,SAAS;;IAG3C,wBACU,UAAU;AAEpB,mBAAgB;AAChB,QAAK,UAAU,QAAQ,8CAA8C;IACnE,GAAG;IACH,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;IAC9D,CAAC;AACF,SAAM;IACN,2BACa;AAEb,OAAI,CAAC,cACH,MAAK,UAAU,QACb,4CACA,WACD;IAEH,CACH;;;;;CAMH,QACE,GAAG,MACiC;AACpC,SAAO,KAAK,QAAQ,QAAQ,GAAG,KAAK;;;;;CAMtC,UACE,GAAG,MACmC;AACtC,SAAO,KAAK,QAAQ,UAAU,GAAG,KAAK;;;;;CAMxC,KACE,GAAG,MAC8B;AACjC,SAAO,KAAK,QAAQ,KAAK,GAAG,KAAK"}
|
|
1
|
+
{"version":3,"file":"telemetry-agent-runner.cjs","names":["InMemoryAgentRunner","telemetry"],"sources":["../../../../src/v1-deprecated/lib/runtime/telemetry-agent-runner.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — TelemetryAgentRunner:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — TelemetryAgentRunnerConfig:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\n/**\n * TelemetryAgentRunner - A wrapper around AgentRunner that adds telemetry\n * for agent execution streams.\n *\n * This captures the following telemetry events:\n * - oss.runtime.agent_execution_stream_started - when an agent execution starts\n * - oss.runtime.agent_execution_stream_ended - when an agent execution completes\n * - oss.runtime.agent_execution_stream_errored - when an agent execution fails\n */\n\nimport { InMemoryAgentRunner } from \"../../../v2/runtime/runner\";\nimport type { AgentRunner } from \"../../../v2/runtime/runner\";\nimport { createHash } from \"node:crypto\";\nimport { tap, catchError, finalize } from \"rxjs\";\nimport telemetry from \"../telemetry-client\";\nimport type { AgentExecutionResponseInfo } from \"@copilotkit/shared/src/telemetry/events\";\nimport type { TelemetryCapture } from \"@copilotkit/shared\";\n\n/**\n * Configuration options for TelemetryAgentRunner\n */\nexport interface TelemetryAgentRunnerConfig {\n /**\n * The underlying runner to delegate to\n * If not provided, defaults to InMemoryAgentRunner\n */\n runner?: AgentRunner;\n\n /**\n * Optional LangSmith API key (will be hashed for telemetry)\n */\n langsmithApiKey?: string;\n\n /** Runtime-bound telemetry capture. Defaults to the legacy singleton. */\n telemetry?: TelemetryCapture;\n}\n\n/**\n * An AgentRunner wrapper that adds telemetry tracking for agent executions.\n *\n * Usage:\n * ```ts\n * const runtime = new CopilotRuntime({\n * runner: new TelemetryAgentRunner(),\n * // or with custom runner:\n * runner: new TelemetryAgentRunner({ runner: customRunner }),\n * });\n * ```\n */\nexport class TelemetryAgentRunner implements AgentRunner {\n private readonly _runner: AgentRunner;\n private readonly hashedLgcKey: string | undefined;\n private readonly telemetry: TelemetryCapture;\n\n constructor(config?: TelemetryAgentRunnerConfig) {\n this._runner = config?.runner ?? new InMemoryAgentRunner();\n this.telemetry = config?.telemetry ?? telemetry;\n this.hashedLgcKey = config?.langsmithApiKey\n ? createHash(\"sha256\").update(config.langsmithApiKey).digest(\"hex\")\n : undefined;\n }\n\n /**\n * Runs an agent with telemetry tracking.\n * Wraps the underlying runner's Observable stream with telemetry events.\n */\n run(...args: Parameters<AgentRunner[\"run\"]>): ReturnType<AgentRunner[\"run\"]> {\n const streamInfo: AgentExecutionResponseInfo = {\n hashedLgcKey: this.hashedLgcKey,\n };\n let streamErrored = false;\n\n // Capture stream started event\n this.telemetry.capture(\"oss.runtime.agent_execution_stream_started\", {\n hashedLgcKey: this.hashedLgcKey,\n });\n\n // Delegate to the underlying runner and wrap with telemetry\n return this._runner.run(...args).pipe(\n // Extract metadata from events if available\n tap((event) => {\n // Try to extract provider/model info from raw events\n const rawEvent = (\n event as {\n rawEvent?: {\n metadata?: Record<string, unknown>;\n data?: Record<string, unknown>;\n };\n }\n ).rawEvent;\n if (rawEvent?.data) {\n const data = rawEvent.data as { output?: { model?: string } };\n if (data?.output?.model) {\n streamInfo.model = data.output.model;\n streamInfo.provider = data.output.model;\n }\n }\n if (rawEvent?.metadata) {\n const metadata = rawEvent.metadata as {\n langgraph_host?: string;\n langgraph_version?: string;\n };\n if (metadata?.langgraph_host) {\n streamInfo.langGraphHost = metadata.langgraph_host;\n }\n if (metadata?.langgraph_version) {\n streamInfo.langGraphVersion = metadata.langgraph_version;\n }\n }\n }),\n catchError((error) => {\n // Capture stream error event\n streamErrored = true;\n this.telemetry.capture(\"oss.runtime.agent_execution_stream_errored\", {\n ...streamInfo,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }),\n finalize(() => {\n // Capture stream ended event (only if not errored)\n if (!streamErrored) {\n this.telemetry.capture(\n \"oss.runtime.agent_execution_stream_ended\",\n streamInfo,\n );\n }\n }),\n );\n }\n\n /**\n * Delegates to the underlying runner's connect method\n */\n connect(\n ...args: Parameters<AgentRunner[\"connect\"]>\n ): ReturnType<AgentRunner[\"connect\"]> {\n return this._runner.connect(...args);\n }\n\n /**\n * Delegates to the underlying runner's isRunning method\n */\n isRunning(\n ...args: Parameters<AgentRunner[\"isRunning\"]>\n ): ReturnType<AgentRunner[\"isRunning\"]> {\n return this._runner.isRunning(...args);\n }\n\n /**\n * Delegates to the underlying runner's stop method\n */\n stop(\n ...args: Parameters<AgentRunner[\"stop\"]>\n ): ReturnType<AgentRunner[\"stop\"]> {\n return this._runner.stop(...args);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,IAAa,uBAAb,MAAyD;CAKvD,YAAY,QAAqC;AAC/C,OAAK,UAAU,QAAQ,UAAU,IAAIA,uCAAqB;AAC1D,OAAK,YAAY,QAAQ,aAAaC;AACtC,OAAK,eAAe,QAAQ,8CACb,SAAS,CAAC,OAAO,OAAO,gBAAgB,CAAC,OAAO,MAAM,GACjE;;;;;;CAON,IAAI,GAAG,MAAsE;EAC3E,MAAM,aAAyC,EAC7C,cAAc,KAAK,cACpB;EACD,IAAI,gBAAgB;AAGpB,OAAK,UAAU,QAAQ,8CAA8C,EACnE,cAAc,KAAK,cACpB,CAAC;AAGF,SAAO,KAAK,QAAQ,IAAI,GAAG,KAAK,CAAC,oBAE1B,UAAU;GAEb,MAAM,WACJ,MAMA;AACF,OAAI,UAAU,MAAM;IAClB,MAAM,OAAO,SAAS;AACtB,QAAI,MAAM,QAAQ,OAAO;AACvB,gBAAW,QAAQ,KAAK,OAAO;AAC/B,gBAAW,WAAW,KAAK,OAAO;;;AAGtC,OAAI,UAAU,UAAU;IACtB,MAAM,WAAW,SAAS;AAI1B,QAAI,UAAU,eACZ,YAAW,gBAAgB,SAAS;AAEtC,QAAI,UAAU,kBACZ,YAAW,mBAAmB,SAAS;;IAG3C,wBACU,UAAU;AAEpB,mBAAgB;AAChB,QAAK,UAAU,QAAQ,8CAA8C;IACnE,GAAG;IACH,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;IAC9D,CAAC;AACF,SAAM;IACN,2BACa;AAEb,OAAI,CAAC,cACH,MAAK,UAAU,QACb,4CACA,WACD;IAEH,CACH;;;;;CAMH,QACE,GAAG,MACiC;AACpC,SAAO,KAAK,QAAQ,QAAQ,GAAG,KAAK;;;;;CAMtC,UACE,GAAG,MACmC;AACtC,SAAO,KAAK,QAAQ,UAAU,GAAG,KAAK;;;;;CAMxC,KACE,GAAG,MAC8B;AACjC,SAAO,KAAK,QAAQ,KAAK,GAAG,KAAK"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { AgentRunner } from "../../v2/runtime/runner/agent-runner.cjs";
|
|
3
|
-
import "../../v2/runtime/index.cjs";
|
|
3
|
+
import "../../v2/runtime/runner/index.cjs";
|
|
4
4
|
import { TelemetryCapture } from "@copilotkit/shared";
|
|
5
5
|
|
|
6
6
|
//#region src/v1-deprecated/lib/runtime/telemetry-agent-runner.d.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { AgentRunner } from "../../v2/runtime/runner/agent-runner.mjs";
|
|
3
|
-
import "../../v2/runtime/index.mjs";
|
|
3
|
+
import "../../v2/runtime/runner/index.mjs";
|
|
4
4
|
import { TelemetryCapture } from "@copilotkit/shared";
|
|
5
5
|
|
|
6
6
|
//#region src/v1-deprecated/lib/runtime/telemetry-agent-runner.d.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry-agent-runner.mjs","names":["telemetry"],"sources":["../../../../src/v1-deprecated/lib/runtime/telemetry-agent-runner.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — TelemetryAgentRunner:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — TelemetryAgentRunnerConfig:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\n/**\n * TelemetryAgentRunner - A wrapper around AgentRunner that adds telemetry\n * for agent execution streams.\n *\n * This captures the following telemetry events:\n * - oss.runtime.agent_execution_stream_started - when an agent execution starts\n * - oss.runtime.agent_execution_stream_ended - when an agent execution completes\n * - oss.runtime.agent_execution_stream_errored - when an agent execution fails\n */\n\nimport { InMemoryAgentRunner } from \"../../../v2/runtime\";\nimport type { AgentRunner } from \"../../../v2/runtime\";\nimport { createHash } from \"node:crypto\";\nimport { tap, catchError, finalize } from \"rxjs\";\nimport telemetry from \"../telemetry-client\";\nimport type { AgentExecutionResponseInfo } from \"@copilotkit/shared/src/telemetry/events\";\nimport type { TelemetryCapture } from \"@copilotkit/shared\";\n\n/**\n * Configuration options for TelemetryAgentRunner\n */\nexport interface TelemetryAgentRunnerConfig {\n /**\n * The underlying runner to delegate to\n * If not provided, defaults to InMemoryAgentRunner\n */\n runner?: AgentRunner;\n\n /**\n * Optional LangSmith API key (will be hashed for telemetry)\n */\n langsmithApiKey?: string;\n\n /** Runtime-bound telemetry capture. Defaults to the legacy singleton. */\n telemetry?: TelemetryCapture;\n}\n\n/**\n * An AgentRunner wrapper that adds telemetry tracking for agent executions.\n *\n * Usage:\n * ```ts\n * const runtime = new CopilotRuntime({\n * runner: new TelemetryAgentRunner(),\n * // or with custom runner:\n * runner: new TelemetryAgentRunner({ runner: customRunner }),\n * });\n * ```\n */\nexport class TelemetryAgentRunner implements AgentRunner {\n private readonly _runner: AgentRunner;\n private readonly hashedLgcKey: string | undefined;\n private readonly telemetry: TelemetryCapture;\n\n constructor(config?: TelemetryAgentRunnerConfig) {\n this._runner = config?.runner ?? new InMemoryAgentRunner();\n this.telemetry = config?.telemetry ?? telemetry;\n this.hashedLgcKey = config?.langsmithApiKey\n ? createHash(\"sha256\").update(config.langsmithApiKey).digest(\"hex\")\n : undefined;\n }\n\n /**\n * Runs an agent with telemetry tracking.\n * Wraps the underlying runner's Observable stream with telemetry events.\n */\n run(...args: Parameters<AgentRunner[\"run\"]>): ReturnType<AgentRunner[\"run\"]> {\n const streamInfo: AgentExecutionResponseInfo = {\n hashedLgcKey: this.hashedLgcKey,\n };\n let streamErrored = false;\n\n // Capture stream started event\n this.telemetry.capture(\"oss.runtime.agent_execution_stream_started\", {\n hashedLgcKey: this.hashedLgcKey,\n });\n\n // Delegate to the underlying runner and wrap with telemetry\n return this._runner.run(...args).pipe(\n // Extract metadata from events if available\n tap((event) => {\n // Try to extract provider/model info from raw events\n const rawEvent = (\n event as {\n rawEvent?: {\n metadata?: Record<string, unknown>;\n data?: Record<string, unknown>;\n };\n }\n ).rawEvent;\n if (rawEvent?.data) {\n const data = rawEvent.data as { output?: { model?: string } };\n if (data?.output?.model) {\n streamInfo.model = data.output.model;\n streamInfo.provider = data.output.model;\n }\n }\n if (rawEvent?.metadata) {\n const metadata = rawEvent.metadata as {\n langgraph_host?: string;\n langgraph_version?: string;\n };\n if (metadata?.langgraph_host) {\n streamInfo.langGraphHost = metadata.langgraph_host;\n }\n if (metadata?.langgraph_version) {\n streamInfo.langGraphVersion = metadata.langgraph_version;\n }\n }\n }),\n catchError((error) => {\n // Capture stream error event\n streamErrored = true;\n this.telemetry.capture(\"oss.runtime.agent_execution_stream_errored\", {\n ...streamInfo,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }),\n finalize(() => {\n // Capture stream ended event (only if not errored)\n if (!streamErrored) {\n this.telemetry.capture(\n \"oss.runtime.agent_execution_stream_ended\",\n streamInfo,\n );\n }\n }),\n );\n }\n\n /**\n * Delegates to the underlying runner's connect method\n */\n connect(\n ...args: Parameters<AgentRunner[\"connect\"]>\n ): ReturnType<AgentRunner[\"connect\"]> {\n return this._runner.connect(...args);\n }\n\n /**\n * Delegates to the underlying runner's isRunning method\n */\n isRunning(\n ...args: Parameters<AgentRunner[\"isRunning\"]>\n ): ReturnType<AgentRunner[\"isRunning\"]> {\n return this._runner.isRunning(...args);\n }\n\n /**\n * Delegates to the underlying runner's stop method\n */\n stop(\n ...args: Parameters<AgentRunner[\"stop\"]>\n ): ReturnType<AgentRunner[\"stop\"]> {\n return this._runner.stop(...args);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,IAAa,uBAAb,MAAyD;CAKvD,YAAY,QAAqC;AAC/C,OAAK,UAAU,QAAQ,UAAU,IAAI,qBAAqB;AAC1D,OAAK,YAAY,QAAQ,aAAaA;AACtC,OAAK,eAAe,QAAQ,kBACxB,WAAW,SAAS,CAAC,OAAO,OAAO,gBAAgB,CAAC,OAAO,MAAM,GACjE;;;;;;CAON,IAAI,GAAG,MAAsE;EAC3E,MAAM,aAAyC,EAC7C,cAAc,KAAK,cACpB;EACD,IAAI,gBAAgB;AAGpB,OAAK,UAAU,QAAQ,8CAA8C,EACnE,cAAc,KAAK,cACpB,CAAC;AAGF,SAAO,KAAK,QAAQ,IAAI,GAAG,KAAK,CAAC,KAE/B,KAAK,UAAU;GAEb,MAAM,WACJ,MAMA;AACF,OAAI,UAAU,MAAM;IAClB,MAAM,OAAO,SAAS;AACtB,QAAI,MAAM,QAAQ,OAAO;AACvB,gBAAW,QAAQ,KAAK,OAAO;AAC/B,gBAAW,WAAW,KAAK,OAAO;;;AAGtC,OAAI,UAAU,UAAU;IACtB,MAAM,WAAW,SAAS;AAI1B,QAAI,UAAU,eACZ,YAAW,gBAAgB,SAAS;AAEtC,QAAI,UAAU,kBACZ,YAAW,mBAAmB,SAAS;;IAG3C,EACF,YAAY,UAAU;AAEpB,mBAAgB;AAChB,QAAK,UAAU,QAAQ,8CAA8C;IACnE,GAAG;IACH,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;IAC9D,CAAC;AACF,SAAM;IACN,EACF,eAAe;AAEb,OAAI,CAAC,cACH,MAAK,UAAU,QACb,4CACA,WACD;IAEH,CACH;;;;;CAMH,QACE,GAAG,MACiC;AACpC,SAAO,KAAK,QAAQ,QAAQ,GAAG,KAAK;;;;;CAMtC,UACE,GAAG,MACmC;AACtC,SAAO,KAAK,QAAQ,UAAU,GAAG,KAAK;;;;;CAMxC,KACE,GAAG,MAC8B;AACjC,SAAO,KAAK,QAAQ,KAAK,GAAG,KAAK"}
|
|
1
|
+
{"version":3,"file":"telemetry-agent-runner.mjs","names":["telemetry"],"sources":["../../../../src/v1-deprecated/lib/runtime/telemetry-agent-runner.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — TelemetryAgentRunner:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — TelemetryAgentRunnerConfig:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\n/**\n * TelemetryAgentRunner - A wrapper around AgentRunner that adds telemetry\n * for agent execution streams.\n *\n * This captures the following telemetry events:\n * - oss.runtime.agent_execution_stream_started - when an agent execution starts\n * - oss.runtime.agent_execution_stream_ended - when an agent execution completes\n * - oss.runtime.agent_execution_stream_errored - when an agent execution fails\n */\n\nimport { InMemoryAgentRunner } from \"../../../v2/runtime/runner\";\nimport type { AgentRunner } from \"../../../v2/runtime/runner\";\nimport { createHash } from \"node:crypto\";\nimport { tap, catchError, finalize } from \"rxjs\";\nimport telemetry from \"../telemetry-client\";\nimport type { AgentExecutionResponseInfo } from \"@copilotkit/shared/src/telemetry/events\";\nimport type { TelemetryCapture } from \"@copilotkit/shared\";\n\n/**\n * Configuration options for TelemetryAgentRunner\n */\nexport interface TelemetryAgentRunnerConfig {\n /**\n * The underlying runner to delegate to\n * If not provided, defaults to InMemoryAgentRunner\n */\n runner?: AgentRunner;\n\n /**\n * Optional LangSmith API key (will be hashed for telemetry)\n */\n langsmithApiKey?: string;\n\n /** Runtime-bound telemetry capture. Defaults to the legacy singleton. */\n telemetry?: TelemetryCapture;\n}\n\n/**\n * An AgentRunner wrapper that adds telemetry tracking for agent executions.\n *\n * Usage:\n * ```ts\n * const runtime = new CopilotRuntime({\n * runner: new TelemetryAgentRunner(),\n * // or with custom runner:\n * runner: new TelemetryAgentRunner({ runner: customRunner }),\n * });\n * ```\n */\nexport class TelemetryAgentRunner implements AgentRunner {\n private readonly _runner: AgentRunner;\n private readonly hashedLgcKey: string | undefined;\n private readonly telemetry: TelemetryCapture;\n\n constructor(config?: TelemetryAgentRunnerConfig) {\n this._runner = config?.runner ?? new InMemoryAgentRunner();\n this.telemetry = config?.telemetry ?? telemetry;\n this.hashedLgcKey = config?.langsmithApiKey\n ? createHash(\"sha256\").update(config.langsmithApiKey).digest(\"hex\")\n : undefined;\n }\n\n /**\n * Runs an agent with telemetry tracking.\n * Wraps the underlying runner's Observable stream with telemetry events.\n */\n run(...args: Parameters<AgentRunner[\"run\"]>): ReturnType<AgentRunner[\"run\"]> {\n const streamInfo: AgentExecutionResponseInfo = {\n hashedLgcKey: this.hashedLgcKey,\n };\n let streamErrored = false;\n\n // Capture stream started event\n this.telemetry.capture(\"oss.runtime.agent_execution_stream_started\", {\n hashedLgcKey: this.hashedLgcKey,\n });\n\n // Delegate to the underlying runner and wrap with telemetry\n return this._runner.run(...args).pipe(\n // Extract metadata from events if available\n tap((event) => {\n // Try to extract provider/model info from raw events\n const rawEvent = (\n event as {\n rawEvent?: {\n metadata?: Record<string, unknown>;\n data?: Record<string, unknown>;\n };\n }\n ).rawEvent;\n if (rawEvent?.data) {\n const data = rawEvent.data as { output?: { model?: string } };\n if (data?.output?.model) {\n streamInfo.model = data.output.model;\n streamInfo.provider = data.output.model;\n }\n }\n if (rawEvent?.metadata) {\n const metadata = rawEvent.metadata as {\n langgraph_host?: string;\n langgraph_version?: string;\n };\n if (metadata?.langgraph_host) {\n streamInfo.langGraphHost = metadata.langgraph_host;\n }\n if (metadata?.langgraph_version) {\n streamInfo.langGraphVersion = metadata.langgraph_version;\n }\n }\n }),\n catchError((error) => {\n // Capture stream error event\n streamErrored = true;\n this.telemetry.capture(\"oss.runtime.agent_execution_stream_errored\", {\n ...streamInfo,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }),\n finalize(() => {\n // Capture stream ended event (only if not errored)\n if (!streamErrored) {\n this.telemetry.capture(\n \"oss.runtime.agent_execution_stream_ended\",\n streamInfo,\n );\n }\n }),\n );\n }\n\n /**\n * Delegates to the underlying runner's connect method\n */\n connect(\n ...args: Parameters<AgentRunner[\"connect\"]>\n ): ReturnType<AgentRunner[\"connect\"]> {\n return this._runner.connect(...args);\n }\n\n /**\n * Delegates to the underlying runner's isRunning method\n */\n isRunning(\n ...args: Parameters<AgentRunner[\"isRunning\"]>\n ): ReturnType<AgentRunner[\"isRunning\"]> {\n return this._runner.isRunning(...args);\n }\n\n /**\n * Delegates to the underlying runner's stop method\n */\n stop(\n ...args: Parameters<AgentRunner[\"stop\"]>\n ): ReturnType<AgentRunner[\"stop\"]> {\n return this._runner.stop(...args);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,IAAa,uBAAb,MAAyD;CAKvD,YAAY,QAAqC;AAC/C,OAAK,UAAU,QAAQ,UAAU,IAAI,qBAAqB;AAC1D,OAAK,YAAY,QAAQ,aAAaA;AACtC,OAAK,eAAe,QAAQ,kBACxB,WAAW,SAAS,CAAC,OAAO,OAAO,gBAAgB,CAAC,OAAO,MAAM,GACjE;;;;;;CAON,IAAI,GAAG,MAAsE;EAC3E,MAAM,aAAyC,EAC7C,cAAc,KAAK,cACpB;EACD,IAAI,gBAAgB;AAGpB,OAAK,UAAU,QAAQ,8CAA8C,EACnE,cAAc,KAAK,cACpB,CAAC;AAGF,SAAO,KAAK,QAAQ,IAAI,GAAG,KAAK,CAAC,KAE/B,KAAK,UAAU;GAEb,MAAM,WACJ,MAMA;AACF,OAAI,UAAU,MAAM;IAClB,MAAM,OAAO,SAAS;AACtB,QAAI,MAAM,QAAQ,OAAO;AACvB,gBAAW,QAAQ,KAAK,OAAO;AAC/B,gBAAW,WAAW,KAAK,OAAO;;;AAGtC,OAAI,UAAU,UAAU;IACtB,MAAM,WAAW,SAAS;AAI1B,QAAI,UAAU,eACZ,YAAW,gBAAgB,SAAS;AAEtC,QAAI,UAAU,kBACZ,YAAW,mBAAmB,SAAS;;IAG3C,EACF,YAAY,UAAU;AAEpB,mBAAgB;AAChB,QAAK,UAAU,QAAQ,8CAA8C;IACnE,GAAG;IACH,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;IAC9D,CAAC;AACF,SAAM;IACN,EACF,eAAe;AAEb,OAAI,CAAC,cACH,MAAK,UAAU,QACb,4CACA,WACD;IAEH,CACH;;;;;CAMH,QACE,GAAG,MACiC;AACpC,SAAO,KAAK,QAAQ,QAAQ,GAAG,KAAK;;;;;CAMtC,UACE,GAAG,MACmC;AACtC,SAAO,KAAK,QAAQ,UAAU,GAAG,KAAK;;;;;CAMxC,KACE,GAAG,MAC8B;AACjC,SAAO,KAAK,QAAQ,KAAK,GAAG,KAAK"}
|
package/dist/package.cjs
CHANGED
|
@@ -5,7 +5,7 @@ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
|
5
5
|
var require_package = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, module) => {
|
|
6
6
|
module.exports = {
|
|
7
7
|
"name": "@copilotkit/runtime",
|
|
8
|
-
"version": "1.
|
|
8
|
+
"version": "1.73.1",
|
|
9
9
|
"private": false,
|
|
10
10
|
"keywords": [
|
|
11
11
|
"ai",
|
|
@@ -41,6 +41,10 @@ var require_package = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, m
|
|
|
41
41
|
"import": "./dist/index.mjs",
|
|
42
42
|
"require": "./dist/index.cjs"
|
|
43
43
|
},
|
|
44
|
+
"./internal/learned-skills": {
|
|
45
|
+
"import": "./dist/internal/learned-skills.mjs",
|
|
46
|
+
"require": "./dist/internal/learned-skills.cjs"
|
|
47
|
+
},
|
|
44
48
|
"./langgraph": {
|
|
45
49
|
"import": "./dist/langgraph.mjs",
|
|
46
50
|
"require": "./dist/langgraph.cjs"
|
|
@@ -73,7 +77,7 @@ var require_package = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, m
|
|
|
73
77
|
"generate-graphql-schema": "node -e \"const fs=require('fs');fs.rmSync('__snapshots__',{recursive:true,force:true})\" && ts-node --transpile-only ./scripts/generate-gql-schema.ts",
|
|
74
78
|
"link:global": "pnpm link --global",
|
|
75
79
|
"unlink:global": "pnpm unlink --global",
|
|
76
|
-
"check-dts": "tsx ../../scripts/validate-dts-ambient.ts dist && tsx ../../scripts/validate-dts-imports.ts dist",
|
|
80
|
+
"check-dts": "tsx ../../scripts/validate-dts-ambient.ts dist && tsx ../../scripts/validate-dts-imports.ts dist && tsx ../../scripts/validate-optional-peer-entries.ts . && tsc --noEmit -p type-fixtures/express4/tsconfig.json && tsc --noEmit -p type-fixtures/express5/tsconfig.json",
|
|
77
81
|
"publint": "publint .",
|
|
78
82
|
"attw": "attw --pack . --profile node16"
|
|
79
83
|
},
|
|
@@ -102,13 +106,10 @@ var require_package = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, m
|
|
|
102
106
|
"@scarf/scarf": "^1.3.0",
|
|
103
107
|
"@segment/analytics-node": "^2.1.2",
|
|
104
108
|
"@types/cors": "^2.8.17",
|
|
105
|
-
"@types/express": "^4.17.21",
|
|
106
109
|
"ai": "^6.0.104",
|
|
107
|
-
"clarinet": "^0.12.4",
|
|
108
110
|
"class-transformer": "^0.5.1",
|
|
109
111
|
"class-validator": "^0.14.1",
|
|
110
112
|
"cors": "^2.8.5",
|
|
111
|
-
"express": "^4.21.2",
|
|
112
113
|
"graphql": "^16.8.1",
|
|
113
114
|
"graphql-scalars": "^1.23.0",
|
|
114
115
|
"graphql-yoga": "^5.3.1",
|
|
@@ -123,13 +124,16 @@ var require_package = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, m
|
|
|
123
124
|
"type-graphql": "2.0.0-rc.1",
|
|
124
125
|
"uuid": "^11.1.0",
|
|
125
126
|
"ws": "^8.18.0",
|
|
126
|
-
"zod": "^3.23.3"
|
|
127
|
+
"zod": "^3.23.3",
|
|
128
|
+
"yauzl": "2.10.0"
|
|
127
129
|
},
|
|
128
130
|
"devDependencies": {
|
|
129
131
|
"@copilotkit/aimock": "latest",
|
|
130
132
|
"@copilotkit/channels": "workspace:*",
|
|
131
133
|
"@swc/core": "1.5.28",
|
|
132
134
|
"@tanstack/intent": "^0.0.29",
|
|
135
|
+
"@types/express": "^4.17.21",
|
|
136
|
+
"@types/express-v5": "npm:@types/express@^5.0.0",
|
|
133
137
|
"@types/node": "^18.11.17",
|
|
134
138
|
"@types/phoenix": "^1.6.6",
|
|
135
139
|
"@valibot/to-json-schema": "^1.5.0",
|
|
@@ -138,6 +142,7 @@ var require_package = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, m
|
|
|
138
142
|
"arktype": "^2.1.29",
|
|
139
143
|
"elysia": "^1.2.25",
|
|
140
144
|
"eslint": "^8.56.0",
|
|
145
|
+
"express": "^4.18.0 || ^5.0.0",
|
|
141
146
|
"nodemon": "^3.1.3",
|
|
142
147
|
"supertest": "^7.1.1",
|
|
143
148
|
"ts-node": "^10.9.2",
|
|
@@ -145,7 +150,8 @@ var require_package = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, m
|
|
|
145
150
|
"tsdown": "^0.20.3",
|
|
146
151
|
"typescript": "^5.2.3",
|
|
147
152
|
"valibot": "^1.2.0",
|
|
148
|
-
"vitest": "^3.2.4"
|
|
153
|
+
"vitest": "^3.2.4",
|
|
154
|
+
"@types/yauzl": "2.10.3"
|
|
149
155
|
},
|
|
150
156
|
"peerDependencies": {
|
|
151
157
|
"@anthropic-ai/sdk": ">=0.57.0",
|
|
@@ -155,6 +161,7 @@ var require_package = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, m
|
|
|
155
161
|
"@langchain/google-gauth": ">=0.1.0",
|
|
156
162
|
"@langchain/langgraph-sdk": ">=0.1.2",
|
|
157
163
|
"@langchain/openai": ">=0.4.2",
|
|
164
|
+
"express": "^4.18.0 || ^5.0.0",
|
|
158
165
|
"groq-sdk": ">=0.3.0 <1.0.0",
|
|
159
166
|
"langchain": ">=0.3.3",
|
|
160
167
|
"openai": "^4.85.1 || >=5.0.0"
|
|
@@ -166,6 +173,7 @@ var require_package = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, m
|
|
|
166
173
|
"@langchain/google-gauth": { "optional": true },
|
|
167
174
|
"@langchain/langgraph-sdk": { "optional": true },
|
|
168
175
|
"@langchain/openai": { "optional": true },
|
|
176
|
+
"express": { "optional": true },
|
|
169
177
|
"groq-sdk": { "optional": true },
|
|
170
178
|
"langchain": { "optional": true },
|
|
171
179
|
"openai": { "optional": true }
|
package/dist/package.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { __commonJSMin } from "./_virtual/_rolldown/runtime.mjs";
|
|
|
5
5
|
var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6
6
|
module.exports = {
|
|
7
7
|
"name": "@copilotkit/runtime",
|
|
8
|
-
"version": "1.
|
|
8
|
+
"version": "1.73.1",
|
|
9
9
|
"private": false,
|
|
10
10
|
"keywords": [
|
|
11
11
|
"ai",
|
|
@@ -41,6 +41,10 @@ var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
41
41
|
"import": "./dist/index.mjs",
|
|
42
42
|
"require": "./dist/index.cjs"
|
|
43
43
|
},
|
|
44
|
+
"./internal/learned-skills": {
|
|
45
|
+
"import": "./dist/internal/learned-skills.mjs",
|
|
46
|
+
"require": "./dist/internal/learned-skills.cjs"
|
|
47
|
+
},
|
|
44
48
|
"./langgraph": {
|
|
45
49
|
"import": "./dist/langgraph.mjs",
|
|
46
50
|
"require": "./dist/langgraph.cjs"
|
|
@@ -73,7 +77,7 @@ var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
73
77
|
"generate-graphql-schema": "node -e \"const fs=require('fs');fs.rmSync('__snapshots__',{recursive:true,force:true})\" && ts-node --transpile-only ./scripts/generate-gql-schema.ts",
|
|
74
78
|
"link:global": "pnpm link --global",
|
|
75
79
|
"unlink:global": "pnpm unlink --global",
|
|
76
|
-
"check-dts": "tsx ../../scripts/validate-dts-ambient.ts dist && tsx ../../scripts/validate-dts-imports.ts dist",
|
|
80
|
+
"check-dts": "tsx ../../scripts/validate-dts-ambient.ts dist && tsx ../../scripts/validate-dts-imports.ts dist && tsx ../../scripts/validate-optional-peer-entries.ts . && tsc --noEmit -p type-fixtures/express4/tsconfig.json && tsc --noEmit -p type-fixtures/express5/tsconfig.json",
|
|
77
81
|
"publint": "publint .",
|
|
78
82
|
"attw": "attw --pack . --profile node16"
|
|
79
83
|
},
|
|
@@ -102,13 +106,10 @@ var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
102
106
|
"@scarf/scarf": "^1.3.0",
|
|
103
107
|
"@segment/analytics-node": "^2.1.2",
|
|
104
108
|
"@types/cors": "^2.8.17",
|
|
105
|
-
"@types/express": "^4.17.21",
|
|
106
109
|
"ai": "^6.0.104",
|
|
107
|
-
"clarinet": "^0.12.4",
|
|
108
110
|
"class-transformer": "^0.5.1",
|
|
109
111
|
"class-validator": "^0.14.1",
|
|
110
112
|
"cors": "^2.8.5",
|
|
111
|
-
"express": "^4.21.2",
|
|
112
113
|
"graphql": "^16.8.1",
|
|
113
114
|
"graphql-scalars": "^1.23.0",
|
|
114
115
|
"graphql-yoga": "^5.3.1",
|
|
@@ -123,13 +124,16 @@ var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
123
124
|
"type-graphql": "2.0.0-rc.1",
|
|
124
125
|
"uuid": "^11.1.0",
|
|
125
126
|
"ws": "^8.18.0",
|
|
126
|
-
"zod": "^3.23.3"
|
|
127
|
+
"zod": "^3.23.3",
|
|
128
|
+
"yauzl": "2.10.0"
|
|
127
129
|
},
|
|
128
130
|
"devDependencies": {
|
|
129
131
|
"@copilotkit/aimock": "latest",
|
|
130
132
|
"@copilotkit/channels": "workspace:*",
|
|
131
133
|
"@swc/core": "1.5.28",
|
|
132
134
|
"@tanstack/intent": "^0.0.29",
|
|
135
|
+
"@types/express": "^4.17.21",
|
|
136
|
+
"@types/express-v5": "npm:@types/express@^5.0.0",
|
|
133
137
|
"@types/node": "^18.11.17",
|
|
134
138
|
"@types/phoenix": "^1.6.6",
|
|
135
139
|
"@valibot/to-json-schema": "^1.5.0",
|
|
@@ -138,6 +142,7 @@ var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
138
142
|
"arktype": "^2.1.29",
|
|
139
143
|
"elysia": "^1.2.25",
|
|
140
144
|
"eslint": "^8.56.0",
|
|
145
|
+
"express": "^4.18.0 || ^5.0.0",
|
|
141
146
|
"nodemon": "^3.1.3",
|
|
142
147
|
"supertest": "^7.1.1",
|
|
143
148
|
"ts-node": "^10.9.2",
|
|
@@ -145,7 +150,8 @@ var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
145
150
|
"tsdown": "^0.20.3",
|
|
146
151
|
"typescript": "^5.2.3",
|
|
147
152
|
"valibot": "^1.2.0",
|
|
148
|
-
"vitest": "^3.2.4"
|
|
153
|
+
"vitest": "^3.2.4",
|
|
154
|
+
"@types/yauzl": "2.10.3"
|
|
149
155
|
},
|
|
150
156
|
"peerDependencies": {
|
|
151
157
|
"@anthropic-ai/sdk": ">=0.57.0",
|
|
@@ -155,6 +161,7 @@ var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
155
161
|
"@langchain/google-gauth": ">=0.1.0",
|
|
156
162
|
"@langchain/langgraph-sdk": ">=0.1.2",
|
|
157
163
|
"@langchain/openai": ">=0.4.2",
|
|
164
|
+
"express": "^4.18.0 || ^5.0.0",
|
|
158
165
|
"groq-sdk": ">=0.3.0 <1.0.0",
|
|
159
166
|
"langchain": ">=0.3.3",
|
|
160
167
|
"openai": "^4.85.1 || >=5.0.0"
|
|
@@ -166,6 +173,7 @@ var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
166
173
|
"@langchain/google-gauth": { "optional": true },
|
|
167
174
|
"@langchain/langgraph-sdk": { "optional": true },
|
|
168
175
|
"@langchain/openai": { "optional": true },
|
|
176
|
+
"express": { "optional": true },
|
|
169
177
|
"groq-sdk": { "optional": true },
|
|
170
178
|
"langchain": { "optional": true },
|
|
171
179
|
"openai": { "optional": true }
|