@earendil-works/pi-coding-agent 0.99.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +86 -0
- package/dist/bundle/chunks/anthropic-messages-UID2PALB.js +6 -0
- package/dist/bundle/chunks/anthropic.js +2 -2
- package/dist/bundle/chunks/{azure-openai-responses-EN5WOBET.js → azure-openai-responses-AFMVM6NP.js} +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
- package/dist/bundle/chunks/{chunk-AXPY26X7.js → chunk-2KTBZM5G.js} +14 -28
- package/dist/bundle/chunks/{chunk-LRS5S6EK.js → chunk-2VNGUWBO.js} +2 -2
- package/dist/bundle/chunks/chunk-33XOIQ5N.js +1204 -0
- package/dist/bundle/chunks/{chunk-W2DOMZSC.js → chunk-3LH3ZQKY.js} +1 -1
- package/dist/bundle/chunks/chunk-4KU537KD.js +2 -0
- package/dist/bundle/chunks/chunk-6D7LHLKG.js +2 -0
- package/dist/bundle/chunks/chunk-7FH3BDRG.js +82 -0
- package/dist/bundle/chunks/{chunk-LLMKQWZS.js → chunk-IBCPYVFK.js} +7 -9
- package/dist/bundle/chunks/chunk-KDN6RCEQ.js +4 -0
- package/dist/bundle/chunks/chunk-LD2P6SFZ.js +2 -0
- package/dist/bundle/chunks/{chunk-PEHWOV5U.js → chunk-LTXEMVMA.js} +18 -78
- package/dist/bundle/chunks/{chunk-J4CWPC4N.js → chunk-OSKPX3Z5.js} +1 -1
- package/dist/bundle/chunks/chunk-PRD6WYBT.js +16 -0
- package/dist/bundle/chunks/chunk-VIV3CWXG.js +2 -0
- package/dist/bundle/chunks/{cli-AZXNGIZH.js → cli-QOMC26IJ.js} +8 -6
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-XJQQYGGU.js → cloudflare-workers-ai-system-one-NPQN263E.js} +1 -1
- package/dist/bundle/chunks/codemode-worker.js +67 -8
- package/dist/bundle/chunks/execute-GVRSEGHL.js +367 -0
- package/dist/bundle/chunks/github-copilot.js +1 -1
- package/dist/bundle/chunks/{google-generative-ai-CQAKKJTA.js → google-generative-ai-APTPZOQL.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-AE36YXJU.js → google-vertex-MXCOSOY3.js} +1 -1
- package/dist/bundle/chunks/{llama-cpp-classify-PJJYKPLD.js → llama-cpp-classify-XT44PI3C.js} +1 -1
- package/dist/bundle/chunks/{mistral-conversations-KEYTXJM7.js → mistral-conversations-DKVFNQL6.js} +1 -1
- package/dist/bundle/chunks/openai-chatgpt.js +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-JQTCOVEG.js → openai-codex-responses-GK67DQQJ.js} +1 -1
- package/dist/bundle/chunks/openai-codex.js +1 -1
- package/dist/bundle/chunks/{openai-completions-XW2Q5HVC.js → openai-completions-JXDDPZ23.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-6AXWFL75.js → openai-responses-CQDDLDQF.js} +1 -1
- package/dist/bundle/chunks/{openrouter-images-TPQ4V6OR.js → openrouter-images-ZVXWCSIM.js} +1 -1
- package/dist/bundle/chunks/openrouter.js +1 -1
- package/dist/bundle/chunks/pi-logo-animation-MPKZE4EK.js +2 -0
- package/dist/bundle/chunks/radius.js +1 -1
- package/dist/bundle/chunks/runtime-2SO2JDWM.js +2 -0
- package/dist/bundle/chunks/{typesafe-system-one-E7A4HNJI.js → typesafe-system-one-A4CZTQWZ.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-6ZMK7GDO.js +2 -0
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.js +2 -2
- package/dist/cli/args.js.map +1 -1
- package/dist/config.d.ts +5 -8
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +16 -13
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +15 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +51 -10
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +13 -1
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/types.d.ts +6 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/mcp-servers.d.ts +34 -7
- package/dist/core/mcp-servers.d.ts.map +1 -1
- package/dist/core/mcp-servers.js +52 -11
- package/dist/core/mcp-servers.js.map +1 -1
- package/dist/core/model-registry.d.ts +3 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +4 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-runtime.d.ts +6 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +22 -18
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/radius.d.ts +2 -0
- package/dist/core/radius.d.ts.map +1 -1
- package/dist/core/radius.js +2 -0
- package/dist/core/radius.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +4 -9
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +1 -0
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-manager.d.ts +7 -5
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +3 -2
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt.js +1 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +3 -5
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts.map +1 -1
- package/dist/core/tools/renderers/bash.js +11 -31
- package/dist/core/tools/renderers/bash.js.map +1 -1
- package/dist/core/virtual-models.d.ts +2 -0
- package/dist/core/virtual-models.d.ts.map +1 -1
- package/dist/core/virtual-models.js +19 -12
- package/dist/core/virtual-models.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +197 -51
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/renderer.d.ts.map +1 -1
- package/dist/extensions/codemode/renderer.js +43 -25
- package/dist/extensions/codemode/renderer.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts +12 -11
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js +73 -129
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/codemode/worker.d.ts +1 -1
- package/dist/extensions/codemode/worker.js +1 -1
- package/dist/extensions/codemode/worker.js.map +1 -1
- package/dist/extensions/mcp/cli.d.ts.map +1 -1
- package/dist/extensions/mcp/cli.js +20 -5
- package/dist/extensions/mcp/cli.js.map +1 -1
- package/dist/extensions/mcp/config.d.ts +4 -2
- package/dist/extensions/mcp/config.d.ts.map +1 -1
- package/dist/extensions/mcp/config.js +14 -2
- package/dist/extensions/mcp/config.js.map +1 -1
- package/dist/extensions/mcp/index.d.ts +32 -8
- package/dist/extensions/mcp/index.d.ts.map +1 -1
- package/dist/extensions/mcp/index.js +220 -56
- package/dist/extensions/mcp/index.js.map +1 -1
- package/dist/extensions/mcp/oauth.d.ts +10 -7
- package/dist/extensions/mcp/oauth.d.ts.map +1 -1
- package/dist/extensions/mcp/oauth.js +56 -31
- package/dist/extensions/mcp/oauth.js.map +1 -1
- package/dist/extensions/mcp/runtime.d.ts +2 -0
- package/dist/extensions/mcp/runtime.d.ts.map +1 -1
- package/dist/extensions/mcp/runtime.js +16 -9
- package/dist/extensions/mcp/runtime.js.map +1 -1
- package/dist/extensions/mcp/tools.d.ts +5 -4
- package/dist/extensions/mcp/tools.d.ts.map +1 -1
- package/dist/extensions/mcp/tools.js +33 -15
- package/dist/extensions/mcp/tools.js.map +1 -1
- package/dist/extensions/mcp/ui.d.ts.map +1 -1
- package/dist/extensions/mcp/ui.js +4 -2
- package/dist/extensions/mcp/ui.js.map +1 -1
- package/dist/extensions/tool-search/tool.d.ts +5 -4
- package/dist/extensions/tool-search/tool.d.ts.map +1 -1
- package/dist/extensions/tool-search/tool.js +7 -28
- package/dist/extensions/tool-search/tool.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +6 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +8 -2
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +24 -21
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/pi-logo-animation.d.ts +68 -0
- package/dist/modes/interactive/components/pi-logo-animation.d.ts.map +1 -0
- package/dist/modes/interactive/components/pi-logo-animation.js +1086 -0
- package/dist/modes/interactive/components/pi-logo-animation.js.map +1 -0
- package/dist/modes/interactive/components/pi-logo-animation.lazy.d.ts +7 -0
- package/dist/modes/interactive/components/pi-logo-animation.lazy.d.ts.map +1 -0
- package/dist/modes/interactive/components/pi-logo-animation.lazy.js +12 -0
- package/dist/modes/interactive/components/pi-logo-animation.lazy.js.map +1 -0
- package/dist/modes/interactive/components/pi-logo.d.ts +7 -0
- package/dist/modes/interactive/components/pi-logo.d.ts.map +1 -1
- package/dist/modes/interactive/components/pi-logo.js +13 -1
- package/dist/modes/interactive/components/pi-logo.js.map +1 -1
- package/dist/modes/interactive/components/radius-login-selector.d.ts +15 -0
- package/dist/modes/interactive/components/radius-login-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/radius-login-selector.js +85 -0
- package/dist/modes/interactive/components/radius-login-selector.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +3 -3
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +5 -5
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +5 -4
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.d.ts +27 -3
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.js +39 -6
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +10 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +153 -40
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/system-theme.d.ts +2 -1
- package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/system-theme.js +16 -5
- package/dist/modes/interactive/theme/system-theme.js.map +1 -1
- package/docs/cli.md +8 -18
- package/docs/codemode.md +207 -0
- package/docs/docs.json +5 -1
- package/docs/environment-variables.md +2 -2
- package/docs/extensions.md +3 -3
- package/docs/index.md +1 -1
- package/docs/mcp.md +142 -82
- package/docs/models.md +22 -1
- package/docs/providers.md +18 -6
- package/docs/sdk.md +2 -2
- package/docs/settings.md +5 -3
- package/docs/usage.md +1 -1
- package/examples/extensions/built-in-tool-renderer.ts +16 -40
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/minimal-mode.ts +24 -96
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/sdk/14-codemode-mcp.ts +2 -2
- package/npm-shrinkwrap.json +25 -30
- package/package.json +10 -10
- package/dist/bundle/chunks/anthropic-messages-A6EXUBG6.js +0 -6
- package/dist/bundle/chunks/chunk-GOPCREV2.js +0 -4
- package/dist/bundle/chunks/chunk-GUORCHFS.js +0 -1435
- package/dist/bundle/chunks/chunk-HSPCVFST.js +0 -2
- package/dist/bundle/chunks/chunk-IMTXZUO7.js +0 -82
- package/dist/bundle/chunks/chunk-SLDA2X2H.js +0 -2
- package/dist/bundle/chunks/chunk-XNGRGP62.js +0 -2
- package/dist/bundle/chunks/execute-7XXPZAWW.js +0 -308
- package/dist/bundle/chunks/runtime-G5WJPRBM.js +0 -2
- package/dist/bundle/chunks/virtual-modules-CSWRO37N.js +0 -2
package/dist/core/mcp-servers.js
CHANGED
|
@@ -4,13 +4,9 @@
|
|
|
4
4
|
* The core only validates and stores registrations. The MCP extension (built in, or another
|
|
5
5
|
* extension that handles `mcp_servers_change`) connects them next to the servers from `mcp.json`.
|
|
6
6
|
*/
|
|
7
|
-
const MCP_EXPOSURES = [
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"deferred",
|
|
11
|
-
"direct",
|
|
12
|
-
"hidden",
|
|
13
|
-
];
|
|
7
|
+
const MCP_EXPOSURES = ["codemode", "deferred", "direct", "hidden"];
|
|
8
|
+
/** Older exposure names, accepted in configs and replaced by their current name when validated. */
|
|
9
|
+
const MCP_EXPOSURE_ALIASES = { "codemode-deferred": "codemode" };
|
|
14
10
|
const LOOPBACK_HOSTS = ["localhost", "127.0.0.1", "[::1]"];
|
|
15
11
|
/** Whether a redirect URI can be served by pi's loopback callback server. */
|
|
16
12
|
export function isLoopbackRedirectUri(value) {
|
|
@@ -20,6 +16,10 @@ export function isLoopbackRedirectUri(value) {
|
|
|
20
16
|
return url.protocol === "http:" && LOOPBACK_HOSTS.includes(url.hostname) && url.search === "" && url.hash === "";
|
|
21
17
|
}
|
|
22
18
|
const SERVER_NAME = /^[A-Za-z0-9_-]+$/;
|
|
19
|
+
/** Namespace of a server's tools: `mcp__<server>` with `-` replaced by `_`, like the tool names. */
|
|
20
|
+
export function mcpNamespace(server) {
|
|
21
|
+
return `mcp__${server.replace(/-/g, "_")}`;
|
|
22
|
+
}
|
|
23
23
|
function isRecord(value) {
|
|
24
24
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25
25
|
}
|
|
@@ -51,11 +51,36 @@ function validateOAuth(value) {
|
|
|
51
51
|
}
|
|
52
52
|
if (value.scope !== undefined && typeof value.scope !== "string")
|
|
53
53
|
return "oauth.scope must be a string";
|
|
54
|
+
if (value.clientName !== undefined && (typeof value.clientName !== "string" || !value.clientName.trim())) {
|
|
55
|
+
return "oauth.clientName must be a non-empty string";
|
|
56
|
+
}
|
|
57
|
+
const metadataUrl = value.authServerMetadataUrl;
|
|
58
|
+
if (metadataUrl !== undefined) {
|
|
59
|
+
const url = typeof metadataUrl === "string" && URL.canParse(metadataUrl) ? new URL(metadataUrl) : undefined;
|
|
60
|
+
if (!url || !(url.protocol === "https:" || (url.protocol === "http:" && LOOPBACK_HOSTS.includes(url.hostname)))) {
|
|
61
|
+
return "oauth.authServerMetadataUrl must be an https URL, or http on localhost, 127.0.0.1, or [::1]";
|
|
62
|
+
}
|
|
63
|
+
}
|
|
54
64
|
return undefined;
|
|
55
65
|
}
|
|
56
66
|
function isExposure(value) {
|
|
57
67
|
return typeof value === "string" && MCP_EXPOSURES.includes(value);
|
|
58
68
|
}
|
|
69
|
+
/** The exposure an alias stands for; other values are returned unchanged. */
|
|
70
|
+
function resolveExposureAlias(value) {
|
|
71
|
+
return typeof value === "string" ? (MCP_EXPOSURE_ALIASES[value] ?? value) : value;
|
|
72
|
+
}
|
|
73
|
+
/** A copy of the server entry with exposure aliases replaced by their current names. */
|
|
74
|
+
function resolveExposureAliases(value) {
|
|
75
|
+
const { exposure, toolExposure } = value;
|
|
76
|
+
const resolved = { ...value };
|
|
77
|
+
if (exposure !== undefined)
|
|
78
|
+
resolved.exposure = resolveExposureAlias(exposure);
|
|
79
|
+
if (isRecord(toolExposure)) {
|
|
80
|
+
resolved.toolExposure = Object.fromEntries(Object.entries(toolExposure).map(([tool, entry]) => [tool, resolveExposureAlias(entry)]));
|
|
81
|
+
}
|
|
82
|
+
return resolved;
|
|
83
|
+
}
|
|
59
84
|
function toolPatternRegExp(pattern) {
|
|
60
85
|
const source = pattern
|
|
61
86
|
.split("*")
|
|
@@ -75,13 +100,17 @@ export function getMcpToolExposure(config, toolName) {
|
|
|
75
100
|
}
|
|
76
101
|
return config.exposure ?? "codemode";
|
|
77
102
|
}
|
|
78
|
-
/**
|
|
79
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Validate one server entry of the `mcpServers` shape. Returns a copy of the config with exposure
|
|
105
|
+
* aliases resolved, or an error message.
|
|
106
|
+
*/
|
|
107
|
+
export function validateMcpServerConfig(name, raw) {
|
|
80
108
|
if (!SERVER_NAME.test(name))
|
|
81
109
|
return `invalid server name "${name}" (use letters, digits, "_" and "-")`;
|
|
82
|
-
if (!isRecord(
|
|
110
|
+
if (!isRecord(raw))
|
|
83
111
|
return `server "${name}" must be an object`;
|
|
84
|
-
const
|
|
112
|
+
const value = resolveExposureAliases(raw);
|
|
113
|
+
const { type, exposure, enabled, timeout, toolExposure, description } = value;
|
|
85
114
|
const exposures = MCP_EXPOSURES.map((value) => `"${value}"`).join(", ");
|
|
86
115
|
if (exposure !== undefined && !isExposure(exposure)) {
|
|
87
116
|
return `server "${name}": exposure must be one of ${exposures}`;
|
|
@@ -96,6 +125,9 @@ export function validateMcpServerConfig(name, value) {
|
|
|
96
125
|
}
|
|
97
126
|
if (enabled !== undefined && typeof enabled !== "boolean")
|
|
98
127
|
return `server "${name}": enabled must be a boolean`;
|
|
128
|
+
if (description !== undefined && typeof description !== "string") {
|
|
129
|
+
return `server "${name}": description must be a string`;
|
|
130
|
+
}
|
|
99
131
|
if (timeout !== undefined && (typeof timeout !== "number" || !(timeout > 0))) {
|
|
100
132
|
return `server "${name}": timeout must be a positive number of seconds`;
|
|
101
133
|
}
|
|
@@ -111,6 +143,15 @@ export function validateMcpServerConfig(name, value) {
|
|
|
111
143
|
const oauthError = validateOAuth(value.oauth);
|
|
112
144
|
if (oauthError)
|
|
113
145
|
return `server "${name}": ${oauthError}`;
|
|
146
|
+
if (value.auth !== undefined) {
|
|
147
|
+
if (!isRecord(value.auth) || typeof value.auth.provider !== "string" || !value.auth.provider) {
|
|
148
|
+
return `server "${name}": auth.provider must be a provider name`;
|
|
149
|
+
}
|
|
150
|
+
const url = new URL(value.url);
|
|
151
|
+
if (url.protocol !== "https:" && !LOOPBACK_HOSTS.includes(url.hostname)) {
|
|
152
|
+
return `server "${name}": auth requires an https URL, or http on localhost, 127.0.0.1, or [::1]`;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
114
155
|
return value;
|
|
115
156
|
}
|
|
116
157
|
if (typeof value.command === "string" && (type === undefined || type === "stdio")) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-servers.js","sourceRoot":"","sources":["../../src/core/mcp-servers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,MAAM,aAAa,GAAsB;IACxC,UAAU;IACV,mBAAmB;IACnB,UAAU;IACV,QAAQ;IACR,QAAQ;CACgB,CAAC;AAiD1B,MAAM,cAAc,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AAE3D,6EAA6E;AAC7E,MAAM,UAAU,qBAAqB,CAAC,KAAa;IAClD,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACvC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IAC3B,OAAO,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE,IAAI,GAAG,CAAC,IAAI,KAAK,EAAE,CAAC;AAClH,CAAC;AAYD,MAAM,WAA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AM,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5G,CAAC;IAED,iGAAiG;IACjG,iBAAiB,CAAC,QAAkC;QACnD,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC;IAChC,CAAC;CACD","sourcesContent":["/**\n * MCP server configuration and the servers extensions register with `pi.registerMcpServer()`.\n *\n * The core only validates and stores registrations. The MCP extension (built in, or another\n * extension that handles `mcp_servers_change`) connects them next to the servers from `mcp.json`.\n */\n\n/**\n * - `codemode`: tools are callable from codemode scripts and listed in its description, but not\n * declared to the model.\n * - `codemode-deferred`: like `codemode`, but not listed in the codemode description. Scripts find\n * them with `searchTools()`.\n * - `deferred`: not declared to the model until the `tool_search` tool loads them; the model then\n * calls them directly. Does not need codemode.\n * - `direct`: tools are declared to the model like any other tool (and callable from codemode).\n * - `hidden`: tools are registered but unreachable.\n */\nexport type McpExposure = \"codemode\" | \"codemode-deferred\" | \"deferred\" | \"direct\" | \"hidden\";\n\nconst MCP_EXPOSURES: readonly string[] = [\n\t\"codemode\",\n\t\"codemode-deferred\",\n\t\"deferred\",\n\t\"direct\",\n\t\"hidden\",\n] satisfies McpExposure[];\n\ninterface McpServerConfigBase {\n\t/** Default: `codemode`. */\n\texposure?: McpExposure;\n\t/**\n\t * Exposure of single tools, overriding `exposure`. Keys are tool names as the server offers them,\n\t * or patterns where `*` matches any characters. An exact name wins over patterns; among patterns\n\t * the first match in the object wins. `hidden` removes tools, so `\"exposure\": \"hidden\"` with\n\t * overrides for a few tools exposes only those.\n\t */\n\ttoolExposure?: Record<string, McpExposure>;\n\t/** Set to false to keep the entry without connecting. Default: true. */\n\tenabled?: boolean;\n\t/** Per-request timeout in seconds. Progress notifications from the server reset it. Default: 60. */\n\ttimeout?: number;\n}\n\nexport interface McpStdioServerConfig extends McpServerConfigBase {\n\ttype?: \"stdio\";\n\tcommand: string;\n\targs?: string[];\n\t/** Values may reference environment variables (`${NAME}`) or commands (`!cmd`). */\n\tenv?: Record<string, string>;\n\t/** Relative paths resolve against the session working directory. */\n\tcwd?: string;\n}\n\n/** OAuth client settings for servers that do not support dynamic client registration. */\nexport interface McpOAuthConfig {\n\t/** Pre-registered client id. Without it, pi registers a client with the authorization server. */\n\tclientId?: string;\n\t/** May reference environment variables (`${NAME}`) or commands (`!cmd`). */\n\tclientSecret?: string;\n\t/**\n\t * Port of the loopback callback server, for clients registered with a fixed redirect URI. Without\n\t * `callbackUrl`, the redirect URI is `http://127.0.0.1:<port>/callback`.\n\t */\n\tcallbackPort?: number;\n\t/**\n\t * Redirect URI registered for `clientId`, for example `http://localhost:8080/oauth/callback`. It must\n\t * be an `http` URI on `localhost`, `127.0.0.1`, or `[::1]`. Without a port, the callback server\n\t * listens on `callbackPort` or a free port, which is added to the URI (RFC 8252).\n\t */\n\tcallbackUrl?: string;\n\t/** Scopes to request, separated by spaces. Default: the scopes the server advertises. */\n\tscope?: string;\n}\n\nconst LOOPBACK_HOSTS = [\"localhost\", \"127.0.0.1\", \"[::1]\"];\n\n/** Whether a redirect URI can be served by pi's loopback callback server. */\nexport function isLoopbackRedirectUri(value: string): boolean {\n\tif (!URL.canParse(value)) return false;\n\tconst url = new URL(value);\n\treturn url.protocol === \"http:\" && LOOPBACK_HOSTS.includes(url.hostname) && url.search === \"\" && url.hash === \"\";\n}\n\nexport interface McpHttpServerConfig extends McpServerConfigBase {\n\ttype?: \"http\";\n\turl: string;\n\t/** Values may reference environment variables (`${NAME}`) or commands (`!cmd`). */\n\theaders?: Record<string, string>;\n\toauth?: McpOAuthConfig;\n}\n\nexport type McpServerConfig = McpStdioServerConfig | McpHttpServerConfig;\n\nconst SERVER_NAME = /^[A-Za-z0-9_-]+$/;\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isStringRecord(value: unknown): value is Record<string, string> {\n\treturn isRecord(value) && Object.values(value).every((entry) => typeof entry === \"string\");\n}\n\nfunction validateOAuth(value: unknown): string | undefined {\n\tif (value === undefined) return undefined;\n\tif (!isRecord(value)) return \"oauth must be an object\";\n\tif (value.clientId !== undefined && typeof value.clientId !== \"string\") return \"oauth.clientId must be a string\";\n\tif (value.clientSecret !== undefined && typeof value.clientSecret !== \"string\") {\n\t\treturn \"oauth.clientSecret must be a string\";\n\t}\n\tconst port = value.callbackPort;\n\tif (port !== undefined && (typeof port !== \"number\" || !Number.isInteger(port) || port < 1 || port > 65535)) {\n\t\treturn \"oauth.callbackPort must be a port number\";\n\t}\n\tif (value.callbackUrl !== undefined) {\n\t\tif (typeof value.callbackUrl !== \"string\" || !isLoopbackRedirectUri(value.callbackUrl)) {\n\t\t\treturn \"oauth.callbackUrl must be an http URI on localhost, 127.0.0.1, or [::1] without query or fragment\";\n\t\t}\n\t\tconst urlPort = new URL(value.callbackUrl).port;\n\t\tif (urlPort && port !== undefined && Number(urlPort) !== port) {\n\t\t\treturn \"oauth.callbackUrl and oauth.callbackPort name different ports\";\n\t\t}\n\t}\n\tif (value.scope !== undefined && typeof value.scope !== \"string\") return \"oauth.scope must be a string\";\n\treturn undefined;\n}\n\nfunction isExposure(value: unknown): value is McpExposure {\n\treturn typeof value === \"string\" && MCP_EXPOSURES.includes(value);\n}\n\nfunction toolPatternRegExp(pattern: string): RegExp {\n\tconst source = pattern\n\t\t.split(\"*\")\n\t\t.map((part) => part.replace(/[.+?^${}()|[\\]\\\\]/g, \"\\\\$&\"))\n\t\t.join(\".*\");\n\treturn new RegExp(`^${source}$`);\n}\n\n/** Exposure of one tool of a server: its `toolExposure` entry, else the server's `exposure`. */\nexport function getMcpToolExposure(config: McpServerConfig, toolName: string): McpExposure {\n\tconst overrides = config.toolExposure ?? {};\n\tconst exact = overrides[toolName];\n\tif (exact !== undefined) return exact;\n\tfor (const [pattern, exposure] of Object.entries(overrides)) {\n\t\tif (pattern.includes(\"*\") && toolPatternRegExp(pattern).test(toolName)) return exposure;\n\t}\n\treturn config.exposure ?? \"codemode\";\n}\n\n/** Validate one server entry of the `mcpServers` shape. Returns the config or an error message. */\nexport function validateMcpServerConfig(name: string, value: unknown): McpServerConfig | string {\n\tif (!SERVER_NAME.test(name)) return `invalid server name \"${name}\" (use letters, digits, \"_\" and \"-\")`;\n\tif (!isRecord(value)) return `server \"${name}\" must be an object`;\n\tconst { type, exposure, enabled, timeout, toolExposure } = value;\n\tconst exposures = MCP_EXPOSURES.map((value) => `\"${value}\"`).join(\", \");\n\tif (exposure !== undefined && !isExposure(exposure)) {\n\t\treturn `server \"${name}\": exposure must be one of ${exposures}`;\n\t}\n\tif (toolExposure !== undefined) {\n\t\tif (!isRecord(toolExposure)) return `server \"${name}\": toolExposure must map tool names to exposures`;\n\t\tfor (const [tool, value] of Object.entries(toolExposure)) {\n\t\t\tif (!isExposure(value)) return `server \"${name}\": toolExposure \"${tool}\" must be one of ${exposures}`;\n\t\t}\n\t}\n\tif (enabled !== undefined && typeof enabled !== \"boolean\") return `server \"${name}\": enabled must be a boolean`;\n\tif (timeout !== undefined && (typeof timeout !== \"number\" || !(timeout > 0))) {\n\t\treturn `server \"${name}\": timeout must be a positive number of seconds`;\n\t}\n\tif (type === \"sse\") return `server \"${name}\": legacy SSE transport is not supported; use the streamable HTTP URL`;\n\n\tif (typeof value.url === \"string\" && (type === undefined || type === \"http\" || type === \"streamable-http\")) {\n\t\tif (!URL.canParse(value.url) || !/^https?:$/.test(new URL(value.url).protocol)) {\n\t\t\treturn `server \"${name}\": url must be an http or https URL`;\n\t\t}\n\t\tif (value.headers !== undefined && !isStringRecord(value.headers)) {\n\t\t\treturn `server \"${name}\": headers must map names to strings`;\n\t\t}\n\t\tconst oauthError = validateOAuth(value.oauth);\n\t\tif (oauthError) return `server \"${name}\": ${oauthError}`;\n\t\treturn value as unknown as McpHttpServerConfig;\n\t}\n\tif (typeof value.command === \"string\" && (type === undefined || type === \"stdio\")) {\n\t\tif (\n\t\t\tvalue.args !== undefined &&\n\t\t\t!(Array.isArray(value.args) && value.args.every((arg) => typeof arg === \"string\"))\n\t\t) {\n\t\t\treturn `server \"${name}\": args must be an array of strings`;\n\t\t}\n\t\tif (value.env !== undefined && !isStringRecord(value.env))\n\t\t\treturn `server \"${name}\": env must map names to strings`;\n\t\tif (value.cwd !== undefined && typeof value.cwd !== \"string\") return `server \"${name}\": cwd must be a string`;\n\t\treturn value as unknown as McpStdioServerConfig;\n\t}\n\treturn `server \"${name}\" needs either \"command\" (stdio) or \"url\" (streamable HTTP)`;\n}\n\n/** A server an extension registered with `pi.registerMcpServer()`. */\nexport interface RegisteredMcpServer {\n\tname: string;\n\tconfig: McpServerConfig;\n\t/** Path of the extension that registered the server. */\n\textensionPath: string;\n}\n\n/** Servers registered by the extensions of one runtime. */\nexport class McpServerRegistry {\n\tprivate readonly servers = new Map<string, RegisteredMcpServer>();\n\tprivate changeListener: (() => void) | undefined;\n\n\t/** Register or replace a server. The caller checks ownership. */\n\tregister(server: RegisteredMcpServer): void {\n\t\tthis.servers.set(server.name, server);\n\t\tthis.changeListener?.();\n\t}\n\n\t/** Remove a server registered by `extensionPath`. Servers of other extensions are left alone. */\n\tunregister(name: string, extensionPath: string): void {\n\t\tif (this.servers.get(name)?.extensionPath !== extensionPath) return;\n\t\tthis.servers.delete(name);\n\t\tthis.changeListener?.();\n\t}\n\n\tget(name: string): RegisteredMcpServer | undefined {\n\t\treturn this.servers.get(name);\n\t}\n\n\t/** Copies of the registered servers, in registration order. */\n\tlist(): RegisteredMcpServer[] {\n\t\treturn [...this.servers.values()].map((server) => ({ ...server, config: structuredClone(server.config) }));\n\t}\n\n\t/** Called after every change. The runner sets it when it binds, to emit `mcp_servers_change`. */\n\tsetChangeListener(listener: (() => void) | undefined): void {\n\t\tthis.changeListener = listener;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mcp-servers.js","sourceRoot":"","sources":["../../src/core/mcp-servers.ts"],"names":[],"mappings":"AAAA;;;;;GA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,CAAC,CAAC;QACtC,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,iGAAiG;IACjG,UAAU,CAAC,IAAY,EAAE,aAAqB;QAC7C,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,aAAa,KAAK,aAAa;YAAE,OAAO;QACpE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC1B,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,GAAG,CAAC,IAAY;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,+DAA+D;IAC/D,IAAI;QACH,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5G,CAAC;IAED,iGAAiG;IACjG,iBAAiB,CAAC,QAAkC;QACnD,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC;IAChC,CAAC;CACD","sourcesContent":["/**\n * MCP server configuration and the servers extensions register with `pi.registerMcpServer()`.\n *\n * The core only validates and stores registrations. The MCP extension (built in, or another\n * extension that handles `mcp_servers_change`) connects them next to the servers from `mcp.json`.\n */\n\n/**\n * - `codemode`: tools are callable from codemode scripts but neither declared to the model nor\n * listed in the codemode description, which lists only the server's namespace. Scripts find them\n * with `searchTools()`. `codemode-deferred` is accepted as an alias.\n * - `deferred`: not declared to the model until the `tool_search` tool loads them; the model then\n * calls them directly. Does not need codemode.\n * - `direct`: tools are declared to the model like any other tool (and callable from codemode).\n * - `hidden`: tools are registered but unreachable.\n */\nexport type McpExposure = \"codemode\" | \"deferred\" | \"direct\" | \"hidden\";\n\nconst MCP_EXPOSURES: readonly string[] = [\"codemode\", \"deferred\", \"direct\", \"hidden\"] satisfies McpExposure[];\n\n/** Older exposure names, accepted in configs and replaced by their current name when validated. */\nconst MCP_EXPOSURE_ALIASES: Readonly<Record<string, McpExposure>> = { \"codemode-deferred\": \"codemode\" };\n\ninterface McpServerConfigBase {\n\t/** Default: `codemode`. */\n\texposure?: McpExposure;\n\t/**\n\t * What the server offers, in a sentence. The `mcp_servers` system prompt section lists the server\n\t * with it, tool search ranks the server's tools by it, and codemode's `describeNamespace()` returns it.\n\t */\n\tdescription?: string;\n\t/**\n\t * Exposure of single tools, overriding `exposure`. Keys are tool names as the server offers them,\n\t * or patterns where `*` matches any characters. An exact name wins over patterns; among patterns\n\t * the first match in the object wins. `hidden` removes tools, so `\"exposure\": \"hidden\"` with\n\t * overrides for a few tools exposes only those.\n\t */\n\ttoolExposure?: Record<string, McpExposure>;\n\t/** Set to false to keep the entry without connecting. Default: true. */\n\tenabled?: boolean;\n\t/** Per-request timeout in seconds. Progress notifications from the server reset it. Default: 60. */\n\ttimeout?: number;\n}\n\nexport interface McpStdioServerConfig extends McpServerConfigBase {\n\ttype?: \"stdio\";\n\tcommand: string;\n\targs?: string[];\n\t/** Values may reference environment variables (`${NAME}`) or commands (`!cmd`). */\n\tenv?: Record<string, string>;\n\t/** Relative paths resolve against the session working directory. */\n\tcwd?: string;\n}\n\n/** OAuth client settings for servers that do not support dynamic client registration. */\nexport interface McpOAuthConfig {\n\t/** Pre-registered client id. Without it, pi registers a client with the authorization server. */\n\tclientId?: string;\n\t/** May reference environment variables (`${NAME}`) or commands (`!cmd`). */\n\tclientSecret?: string;\n\t/**\n\t * Port of the loopback callback server, for clients registered with a fixed redirect URI. Without\n\t * `callbackUrl`, the redirect URI is `http://127.0.0.1:<port>/callback`.\n\t */\n\tcallbackPort?: number;\n\t/**\n\t * Redirect URI registered for `clientId`, for example `http://localhost:8080/oauth/callback`. It must\n\t * be an `http` URI on `localhost`, `127.0.0.1`, or `[::1]`. Without a port, the callback server\n\t * listens on `callbackPort` or a free port, which is added to the URI (RFC 8252).\n\t */\n\tcallbackUrl?: string;\n\t/** Scopes to request, separated by spaces. Default: the scopes the server advertises. */\n\tscope?: string;\n\t/**\n\t * `client_name` sent with dynamic client registration, for servers that only accept known clients.\n\t * Default: `pi`.\n\t */\n\tclientName?: string;\n\t/**\n\t * Authorization server metadata document (RFC 8414 or OpenID Connect discovery) to use instead of\n\t * discovery through the server, for servers that advertise a wrong authorization server or none.\n\t * The document is trusted as configured. Must use https, except on loopback hosts.\n\t */\n\tauthServerMetadataUrl?: string;\n}\n\nconst LOOPBACK_HOSTS = [\"localhost\", \"127.0.0.1\", \"[::1]\"];\n\n/** Whether a redirect URI can be served by pi's loopback callback server. */\nexport function isLoopbackRedirectUri(value: string): boolean {\n\tif (!URL.canParse(value)) return false;\n\tconst url = new URL(value);\n\treturn url.protocol === \"http:\" && LOOPBACK_HOSTS.includes(url.hostname) && url.search === \"\" && url.hash === \"\";\n}\n\nexport interface McpHttpServerConfig extends McpServerConfigBase {\n\ttype?: \"http\";\n\turl: string;\n\t/** Values may reference environment variables (`${NAME}`) or commands (`!cmd`). */\n\theaders?: Record<string, string>;\n\toauth?: McpOAuthConfig;\n\t/**\n\t * Send the token of a pi provider (`/login <provider>`) instead of using OAuth. Not allowed in project\n\t * `mcp.json` files, and requires https except on loopback hosts, since it sends the credential to `url`.\n\t */\n\tauth?: { provider: string };\n}\n\nexport type McpServerConfig = McpStdioServerConfig | McpHttpServerConfig;\n\nconst SERVER_NAME = /^[A-Za-z0-9_-]+$/;\n\n/** Namespace of a server's tools: `mcp__<server>` with `-` replaced by `_`, like the tool names. */\nexport function mcpNamespace(server: string): string {\n\treturn `mcp__${server.replace(/-/g, \"_\")}`;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isStringRecord(value: unknown): value is Record<string, string> {\n\treturn isRecord(value) && Object.values(value).every((entry) => typeof entry === \"string\");\n}\n\nfunction validateOAuth(value: unknown): string | undefined {\n\tif (value === undefined) return undefined;\n\tif (!isRecord(value)) return \"oauth must be an object\";\n\tif (value.clientId !== undefined && typeof value.clientId !== \"string\") return \"oauth.clientId must be a string\";\n\tif (value.clientSecret !== undefined && typeof value.clientSecret !== \"string\") {\n\t\treturn \"oauth.clientSecret must be a string\";\n\t}\n\tconst port = value.callbackPort;\n\tif (port !== undefined && (typeof port !== \"number\" || !Number.isInteger(port) || port < 1 || port > 65535)) {\n\t\treturn \"oauth.callbackPort must be a port number\";\n\t}\n\tif (value.callbackUrl !== undefined) {\n\t\tif (typeof value.callbackUrl !== \"string\" || !isLoopbackRedirectUri(value.callbackUrl)) {\n\t\t\treturn \"oauth.callbackUrl must be an http URI on localhost, 127.0.0.1, or [::1] without query or fragment\";\n\t\t}\n\t\tconst urlPort = new URL(value.callbackUrl).port;\n\t\tif (urlPort && port !== undefined && Number(urlPort) !== port) {\n\t\t\treturn \"oauth.callbackUrl and oauth.callbackPort name different ports\";\n\t\t}\n\t}\n\tif (value.scope !== undefined && typeof value.scope !== \"string\") return \"oauth.scope must be a string\";\n\tif (value.clientName !== undefined && (typeof value.clientName !== \"string\" || !value.clientName.trim())) {\n\t\treturn \"oauth.clientName must be a non-empty string\";\n\t}\n\tconst metadataUrl = value.authServerMetadataUrl;\n\tif (metadataUrl !== undefined) {\n\t\tconst url = typeof metadataUrl === \"string\" && URL.canParse(metadataUrl) ? new URL(metadataUrl) : undefined;\n\t\tif (!url || !(url.protocol === \"https:\" || (url.protocol === \"http:\" && LOOPBACK_HOSTS.includes(url.hostname)))) {\n\t\t\treturn \"oauth.authServerMetadataUrl must be an https URL, or http on localhost, 127.0.0.1, or [::1]\";\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction isExposure(value: unknown): value is McpExposure {\n\treturn typeof value === \"string\" && MCP_EXPOSURES.includes(value);\n}\n\n/** The exposure an alias stands for; other values are returned unchanged. */\nfunction resolveExposureAlias(value: unknown): unknown {\n\treturn typeof value === \"string\" ? (MCP_EXPOSURE_ALIASES[value] ?? value) : value;\n}\n\n/** A copy of the server entry with exposure aliases replaced by their current names. */\nfunction resolveExposureAliases(value: Record<string, unknown>): Record<string, unknown> {\n\tconst { exposure, toolExposure } = value;\n\tconst resolved: Record<string, unknown> = { ...value };\n\tif (exposure !== undefined) resolved.exposure = resolveExposureAlias(exposure);\n\tif (isRecord(toolExposure)) {\n\t\tresolved.toolExposure = Object.fromEntries(\n\t\t\tObject.entries(toolExposure).map(([tool, entry]) => [tool, resolveExposureAlias(entry)]),\n\t\t);\n\t}\n\treturn resolved;\n}\n\nfunction toolPatternRegExp(pattern: string): RegExp {\n\tconst source = pattern\n\t\t.split(\"*\")\n\t\t.map((part) => part.replace(/[.+?^${}()|[\\]\\\\]/g, \"\\\\$&\"))\n\t\t.join(\".*\");\n\treturn new RegExp(`^${source}$`);\n}\n\n/** Exposure of one tool of a server: its `toolExposure` entry, else the server's `exposure`. */\nexport function getMcpToolExposure(config: McpServerConfig, toolName: string): McpExposure {\n\tconst overrides = config.toolExposure ?? {};\n\tconst exact = overrides[toolName];\n\tif (exact !== undefined) return exact;\n\tfor (const [pattern, exposure] of Object.entries(overrides)) {\n\t\tif (pattern.includes(\"*\") && toolPatternRegExp(pattern).test(toolName)) return exposure;\n\t}\n\treturn config.exposure ?? \"codemode\";\n}\n\n/**\n * Validate one server entry of the `mcpServers` shape. Returns a copy of the config with exposure\n * aliases resolved, or an error message.\n */\nexport function validateMcpServerConfig(name: string, raw: unknown): McpServerConfig | string {\n\tif (!SERVER_NAME.test(name)) return `invalid server name \"${name}\" (use letters, digits, \"_\" and \"-\")`;\n\tif (!isRecord(raw)) return `server \"${name}\" must be an object`;\n\tconst value = resolveExposureAliases(raw);\n\tconst { type, exposure, enabled, timeout, toolExposure, description } = value;\n\tconst exposures = MCP_EXPOSURES.map((value) => `\"${value}\"`).join(\", \");\n\tif (exposure !== undefined && !isExposure(exposure)) {\n\t\treturn `server \"${name}\": exposure must be one of ${exposures}`;\n\t}\n\tif (toolExposure !== undefined) {\n\t\tif (!isRecord(toolExposure)) return `server \"${name}\": toolExposure must map tool names to exposures`;\n\t\tfor (const [tool, value] of Object.entries(toolExposure)) {\n\t\t\tif (!isExposure(value)) return `server \"${name}\": toolExposure \"${tool}\" must be one of ${exposures}`;\n\t\t}\n\t}\n\tif (enabled !== undefined && typeof enabled !== \"boolean\") return `server \"${name}\": enabled must be a boolean`;\n\tif (description !== undefined && typeof description !== \"string\") {\n\t\treturn `server \"${name}\": description must be a string`;\n\t}\n\tif (timeout !== undefined && (typeof timeout !== \"number\" || !(timeout > 0))) {\n\t\treturn `server \"${name}\": timeout must be a positive number of seconds`;\n\t}\n\tif (type === \"sse\") return `server \"${name}\": legacy SSE transport is not supported; use the streamable HTTP URL`;\n\n\tif (typeof value.url === \"string\" && (type === undefined || type === \"http\" || type === \"streamable-http\")) {\n\t\tif (!URL.canParse(value.url) || !/^https?:$/.test(new URL(value.url).protocol)) {\n\t\t\treturn `server \"${name}\": url must be an http or https URL`;\n\t\t}\n\t\tif (value.headers !== undefined && !isStringRecord(value.headers)) {\n\t\t\treturn `server \"${name}\": headers must map names to strings`;\n\t\t}\n\t\tconst oauthError = validateOAuth(value.oauth);\n\t\tif (oauthError) return `server \"${name}\": ${oauthError}`;\n\t\tif (value.auth !== undefined) {\n\t\t\tif (!isRecord(value.auth) || typeof value.auth.provider !== \"string\" || !value.auth.provider) {\n\t\t\t\treturn `server \"${name}\": auth.provider must be a provider name`;\n\t\t\t}\n\t\t\tconst url = new URL(value.url);\n\t\t\tif (url.protocol !== \"https:\" && !LOOPBACK_HOSTS.includes(url.hostname)) {\n\t\t\t\treturn `server \"${name}\": auth requires an https URL, or http on localhost, 127.0.0.1, or [::1]`;\n\t\t\t}\n\t\t}\n\t\treturn value as unknown as McpHttpServerConfig;\n\t}\n\tif (typeof value.command === \"string\" && (type === undefined || type === \"stdio\")) {\n\t\tif (\n\t\t\tvalue.args !== undefined &&\n\t\t\t!(Array.isArray(value.args) && value.args.every((arg) => typeof arg === \"string\"))\n\t\t) {\n\t\t\treturn `server \"${name}\": args must be an array of strings`;\n\t\t}\n\t\tif (value.env !== undefined && !isStringRecord(value.env))\n\t\t\treturn `server \"${name}\": env must map names to strings`;\n\t\tif (value.cwd !== undefined && typeof value.cwd !== \"string\") return `server \"${name}\": cwd must be a string`;\n\t\treturn value as unknown as McpStdioServerConfig;\n\t}\n\treturn `server \"${name}\" needs either \"command\" (stdio) or \"url\" (streamable HTTP)`;\n}\n\n/** A server an extension registered with `pi.registerMcpServer()`. */\nexport interface RegisteredMcpServer {\n\tname: string;\n\tconfig: McpServerConfig;\n\t/** Path of the extension that registered the server. */\n\textensionPath: string;\n}\n\n/** Servers registered by the extensions of one runtime. */\nexport class McpServerRegistry {\n\tprivate readonly servers = new Map<string, RegisteredMcpServer>();\n\tprivate changeListener: (() => void) | undefined;\n\n\t/** Register or replace a server. The caller checks ownership. */\n\tregister(server: RegisteredMcpServer): void {\n\t\tthis.servers.set(server.name, server);\n\t\tthis.changeListener?.();\n\t}\n\n\t/** Remove a server registered by `extensionPath`. Servers of other extensions are left alone. */\n\tunregister(name: string, extensionPath: string): void {\n\t\tif (this.servers.get(name)?.extensionPath !== extensionPath) return;\n\t\tthis.servers.delete(name);\n\t\tthis.changeListener?.();\n\t}\n\n\tget(name: string): RegisteredMcpServer | undefined {\n\t\treturn this.servers.get(name);\n\t}\n\n\t/** Copies of the registered servers, in registration order. */\n\tlist(): RegisteredMcpServer[] {\n\t\treturn [...this.servers.values()].map((server) => ({ ...server, config: structuredClone(server.config) }));\n\t}\n\n\t/** Called after every change. The runner sets it when it binds, to emit `mcp_servers_change`. */\n\tsetChangeListener(listener: (() => void) | undefined): void {\n\t\tthis.changeListener = listener;\n\t}\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Api, AssistantMessage, AssistantMessageEventStream, AuthOperationOptions, AuthResult, ClassifierApi, ClassifierContext, ClassifierModel, ClassifierResult, Context, Model, ModelsApiStreamOptions, ModelsClassifierOptions, ModelsRefreshOptions, ModelsRefreshResult, ModelsSimpleStreamOptions, ModelType, ModelTypeMap, Provider, ProviderHeaders } from "@earendil-works/pi-ai";
|
|
1
|
+
import type { Api, AssistantImages, AssistantMessage, AssistantMessageEventStream, AuthOperationOptions, AuthResult, ClassifierApi, ClassifierContext, ClassifierModel, ClassifierResult, Context, ImageApi, ImageModel, ImagesContext, Model, ModelsApiStreamOptions, ModelsClassifierOptions, ModelsImagesOptions, ModelsRefreshOptions, ModelsRefreshResult, ModelsSimpleStreamOptions, ModelType, ModelTypeMap, Provider, ProviderHeaders } from "@earendil-works/pi-ai";
|
|
2
2
|
import type { ModelRuntime } from "./model-runtime.ts";
|
|
3
3
|
import type { AuthStatus, ProviderConfigInput } from "./provider-composer.ts";
|
|
4
4
|
import type { VirtualModelDefinition } from "./virtual-models.ts";
|
|
@@ -45,6 +45,8 @@ export declare class ModelRegistry {
|
|
|
45
45
|
getModelOfType<TType extends ModelType>(type: TType, provider: string, modelId: string): ModelTypeMap[TType] | undefined;
|
|
46
46
|
/** Classify structured state with request-time authentication. Never rejects. */
|
|
47
47
|
classify(model: ClassifierModel<ClassifierApi>, context: ClassifierContext, options?: ModelsClassifierOptions): Promise<ClassifierResult>;
|
|
48
|
+
/** Generate images with request-time authentication. Never rejects. */
|
|
49
|
+
generateImages(model: ImageModel<ImageApi>, context: ImagesContext, options?: ModelsImagesOptions): Promise<AssistantImages>;
|
|
48
50
|
getProviderDisplayName(provider: string): string;
|
|
49
51
|
getProviderAuth(provider: string): Promise<AuthResult | undefined>;
|
|
50
52
|
getApiKeyForProvider(provider: string): Promise<string | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-registry.d.ts","sourceRoot":"","sources":["../../src/core/model-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,GAAG,EACH,gBAAgB,EAChB,2BAA2B,EAC3B,oBAAoB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AG,SAAS,CAEjF;IAED,2BAA2B,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAEtE;IAED,wBAAwB,IAAI,SAAS,MAAM,EAAE,CAE5C;CACD"}
|
|
1
|
+
{"version":3,"file":"model-registry.d.ts","sourceRoot":"","sources":["../../src/core/model-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,GAAG,EACH,eAAe,EACf,gBAAgB,EAChB,2BAA2B,EAC3B,oBAAoB,EACpB,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,UAAU,EACV,aAAa,EACb,KAAK,EACL,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EACzB,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE,YAAY,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,MAAM,MAAM,mBAAmB,GAC5B;IACA,EAAE,EAAE,IAAI,CAAC;IACT,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5B,GACD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;;GAGG;AACH,qBAAa,aAAa;IAC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AAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAMxE;IAED,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,OAAO,CAEvC;IAED,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3C,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAU1E,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAE7C;IAED,oBAAoB,CAAC,UAAU,EAAE,sBAAsB,GAAG,IAAI,CAE7D;IAED,sBAAsB,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAE7D;IAED,2BAA2B,CAAC,YAAY,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS,CAEjF;IAED,2BAA2B,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAEtE;IAED,wBAAwB,IAAI,SAAS,MAAM,EAAE,CAE5C;CACD"}
|
|
@@ -92,6 +92,10 @@ export class ModelRegistry {
|
|
|
92
92
|
classify(model, context, options) {
|
|
93
93
|
return this.runtime.classify(model, context, options);
|
|
94
94
|
}
|
|
95
|
+
/** Generate images with request-time authentication. Never rejects. */
|
|
96
|
+
generateImages(model, context, options) {
|
|
97
|
+
return this.runtime.generateImages(model, context, options);
|
|
98
|
+
}
|
|
95
99
|
getProviderDisplayName(provider) {
|
|
96
100
|
return this.runtime.getProvider(provider)?.name ?? provider;
|
|
97
101
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-registry.js","sourceRoot":"","sources":["../../src/core/model-registry.ts"],"names":[],"mappings":"AAoCA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;;GAGG;AACH,MAAM,OAAO,aAAa;IACR,OAAO,CAAe;IAEvC,YAAY,OAAqB;QAChC,IAAI,CAAC,OAAO,GAAG,OAA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,2BAA2B,CAAC,YAAoB;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,YAAY,CAAC,CAAC;IAC/D,CAAC;IAED,wBAAwB;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC,wBAAwB,EAAE,CAAC;IAChD,CAAC;CACD","sourcesContent":["import type {\n\tApi,\n\tAssistantMessage,\n\tAssistantMessageEventStream,\n\tAuthOperationOptions,\n\tAuthResult,\n\tClassifierApi,\n\tClassifierContext,\n\tClassifierModel,\n\tClassifierResult,\n\tContext,\n\tModel,\n\tModelsApiStreamOptions,\n\tModelsClassifierOptions,\n\tModelsRefreshOptions,\n\tModelsRefreshResult,\n\tModelsSimpleStreamOptions,\n\tModelType,\n\tModelTypeMap,\n\tProvider,\n\tProviderHeaders,\n} from \"@earendil-works/pi-ai\";\nimport type { ModelRuntime } from \"./model-runtime.ts\";\nimport type { AuthStatus, ProviderConfigInput } from \"./provider-composer.ts\";\nimport type { VirtualModelDefinition } from \"./virtual-models.ts\";\n\nexport type { ProviderConfigInput } from \"./provider-composer.ts\";\nexport type ResolvedRequestAuth =\n\t| {\n\t\t\tok: true;\n\t\t\tapiKey?: string;\n\t\t\theaders?: ProviderHeaders;\n\t\t\tbaseUrl?: string;\n\t\t\tenv?: Record<string, string>;\n\t }\n\t| { ok: false; error: string };\nexport { clearApiKeyCache } from \"./provider-composer.ts\";\n\n/**\n * Synchronous compatibility facade exposed to extensions.\n * Coding-agent internals use ModelRuntime directly.\n */\nexport class ModelRegistry {\n\tprivate readonly runtime: ModelRuntime;\n\n\tconstructor(runtime: ModelRuntime) {\n\t\tthis.runtime = runtime;\n\t}\n\n\t/** Reload models.json asynchronously. Await before making synchronous registry reads. */\n\trefresh(options?: ModelsRefreshOptions): Promise<ModelsRefreshResult> {\n\t\treturn this.runtime.refresh(options);\n\t}\n\n\tgetError(): string | undefined {\n\t\treturn this.runtime.getError();\n\t}\n\n\tgetAll(): Model<Api>[] {\n\t\treturn [...this.runtime.getModels()];\n\t}\n\n\tgetAvailable(): Model<Api>[] {\n\t\treturn [...this.runtime.getAvailableSnapshot()];\n\t}\n\n\tfind(provider: string, modelId: string): Model<Api> | undefined {\n\t\treturn this.runtime.getModel(provider, modelId);\n\t}\n\n\t/** Find a model of a non-chat type, e.g. `findOfType(\"classifier\", \"typesafe\", \"jev-latest\")`. */\n\tfindOfType<TType extends ModelType>(\n\t\ttype: TType,\n\t\tprovider: string,\n\t\tmodelId: string,\n\t): ModelTypeMap[TType] | undefined {\n\t\treturn this.runtime.getModelOfType(type, provider, modelId);\n\t}\n\n\thasConfiguredAuth(model: Model<Api>): boolean {\n\t\treturn this.runtime.hasConfiguredAuth(model.provider);\n\t}\n\n\tasync getApiKeyAndHeaders(model: Model<Api>): Promise<ResolvedRequestAuth> {\n\t\ttry {\n\t\t\tconst resolution = await this.runtime.getAuth(model);\n\t\t\tif (!resolution) {\n\t\t\t\tconst compatibility = this.runtime.getCompatibilityRequestConfig(model);\n\t\t\t\tif (compatibility.authHeader) {\n\t\t\t\t\treturn { ok: false, error: `No API key found for \"${model.provider}\"` };\n\t\t\t\t}\n\t\t\t\treturn { ok: true, headers: compatibility.headers };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tapiKey: resolution.auth.apiKey,\n\t\t\t\theaders: resolution.auth.headers,\n\t\t\t\t...(resolution.auth.baseUrl ? { baseUrl: resolution.auth.baseUrl } : {}),\n\t\t\t\tenv: resolution.env,\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tconst cause = error instanceof Error ? error.cause : undefined;\n\t\t\tconst message =\n\t\t\t\tcause instanceof Error ? cause.message : error instanceof Error ? error.message : String(error);\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\terror:\n\t\t\t\t\tmessage === \"authHeader requires a resolved API key\"\n\t\t\t\t\t\t? `No API key found for \"${model.provider}\"`\n\t\t\t\t\t\t: message,\n\t\t\t};\n\t\t}\n\t}\n\n\tgetProviderAuthStatus(provider: string): AuthStatus {\n\t\treturn this.runtime.getProviderAuthStatus(provider);\n\t}\n\n\tgetProvider(provider: string): Provider | undefined {\n\t\treturn this.runtime.getProvider(provider);\n\t}\n\n\t/** Stream through the configured provider with request-time authentication. */\n\tstream<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): AssistantMessageEventStream {\n\t\treturn this.runtime.stream(model, context, options);\n\t}\n\n\t/** Stream with provider-neutral options and request-time authentication. */\n\tstreamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream {\n\t\treturn this.runtime.streamSimple(model, context, options);\n\t}\n\n\tcomplete<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): Promise<AssistantMessage> {\n\t\treturn this.runtime.complete(model, context, options);\n\t}\n\n\t/** Every known model of a type (chat, image, classifier), optionally for one provider. */\n\tgetModelsOfType<TType extends ModelType>(type: TType, provider?: string): readonly ModelTypeMap[TType][] {\n\t\treturn this.runtime.getModelsOfType(type, provider);\n\t}\n\n\t/** Models of a type whose provider has working credentials. */\n\tgetAvailableOfType<TType extends ModelType>(\n\t\ttype: TType,\n\t\tprovider?: string,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<readonly ModelTypeMap[TType][]> {\n\t\treturn this.runtime.getAvailableOfType(type, provider, options);\n\t}\n\n\tgetModelOfType<TType extends ModelType>(\n\t\ttype: TType,\n\t\tprovider: string,\n\t\tmodelId: string,\n\t): ModelTypeMap[TType] | undefined {\n\t\treturn this.runtime.getModelOfType(type, provider, modelId);\n\t}\n\n\t/** Classify structured state with request-time authentication. Never rejects. */\n\tclassify(\n\t\tmodel: ClassifierModel<ClassifierApi>,\n\t\tcontext: ClassifierContext,\n\t\toptions?: ModelsClassifierOptions,\n\t): Promise<ClassifierResult> {\n\t\treturn this.runtime.classify(model, context, options);\n\t}\n\n\tgetProviderDisplayName(provider: string): string {\n\t\treturn this.runtime.getProvider(provider)?.name ?? provider;\n\t}\n\n\tgetProviderAuth(provider: string): Promise<AuthResult | undefined> {\n\t\treturn this.runtime.getAuth(provider);\n\t}\n\n\tasync getApiKeyForProvider(provider: string): Promise<string | undefined> {\n\t\ttry {\n\t\t\treturn (await this.runtime.getAuth(provider))?.auth.apiKey;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tisUsingOAuth(model: Model<Api>): boolean {\n\t\treturn this.runtime.isUsingOAuth(model.provider);\n\t}\n\n\tregisterProvider(provider: Provider): void;\n\tregisterProvider(providerName: string, config: ProviderConfigInput): void;\n\tregisterProvider(providerOrName: Provider | string, config?: ProviderConfigInput): void {\n\t\tif (typeof providerOrName === \"string\") {\n\t\t\tif (!config) throw new Error(\"Provider config is required when registering by name\");\n\t\t\tthis.runtime.registerProvider(providerOrName, config);\n\t\t\treturn;\n\t\t}\n\t\tthis.runtime.registerNativeProvider(providerOrName);\n\t}\n\n\tunregisterProvider(providerName: string): void {\n\t\tthis.runtime.unregisterProvider(providerName);\n\t}\n\n\tregisterVirtualModel(definition: VirtualModelDefinition): void {\n\t\tthis.runtime.registerVirtualModel(definition);\n\t}\n\n\tunregisterVirtualModel(providerName: string, id: string): void {\n\t\tthis.runtime.unregisterVirtualModel(providerName, id);\n\t}\n\n\tgetRegisteredProviderConfig(providerName: string): ProviderConfigInput | undefined {\n\t\treturn this.runtime.getRegisteredProviderConfig(providerName);\n\t}\n\n\tgetRegisteredNativeProvider(providerName: string): Provider | undefined {\n\t\treturn this.runtime.getRegisteredNativeProvider(providerName);\n\t}\n\n\tgetRegisteredProviderIds(): readonly string[] {\n\t\treturn this.runtime.getRegisteredProviderIds();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"model-registry.js","sourceRoot":"","sources":["../../src/core/model-registry.ts"],"names":[],"mappings":"AAyCA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE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CAAC,UAAU,CAAC,CAAC;IAC/C,CAAC;IAED,sBAAsB,CAAC,YAAoB,EAAE,EAAU;QACtD,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,2BAA2B,CAAC,YAAoB;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,YAAY,CAAC,CAAC;IAC/D,CAAC;IAED,2BAA2B,CAAC,YAAoB;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,YAAY,CAAC,CAAC;IAC/D,CAAC;IAED,wBAAwB;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC,wBAAwB,EAAE,CAAC;IAChD,CAAC;CACD","sourcesContent":["import type {\n\tApi,\n\tAssistantImages,\n\tAssistantMessage,\n\tAssistantMessageEventStream,\n\tAuthOperationOptions,\n\tAuthResult,\n\tClassifierApi,\n\tClassifierContext,\n\tClassifierModel,\n\tClassifierResult,\n\tContext,\n\tImageApi,\n\tImageModel,\n\tImagesContext,\n\tModel,\n\tModelsApiStreamOptions,\n\tModelsClassifierOptions,\n\tModelsImagesOptions,\n\tModelsRefreshOptions,\n\tModelsRefreshResult,\n\tModelsSimpleStreamOptions,\n\tModelType,\n\tModelTypeMap,\n\tProvider,\n\tProviderHeaders,\n} from \"@earendil-works/pi-ai\";\nimport type { ModelRuntime } from \"./model-runtime.ts\";\nimport type { AuthStatus, ProviderConfigInput } from \"./provider-composer.ts\";\nimport type { VirtualModelDefinition } from \"./virtual-models.ts\";\n\nexport type { ProviderConfigInput } from \"./provider-composer.ts\";\nexport type ResolvedRequestAuth =\n\t| {\n\t\t\tok: true;\n\t\t\tapiKey?: string;\n\t\t\theaders?: ProviderHeaders;\n\t\t\tbaseUrl?: string;\n\t\t\tenv?: Record<string, string>;\n\t }\n\t| { ok: false; error: string };\nexport { clearApiKeyCache } from \"./provider-composer.ts\";\n\n/**\n * Synchronous compatibility facade exposed to extensions.\n * Coding-agent internals use ModelRuntime directly.\n */\nexport class ModelRegistry {\n\tprivate readonly runtime: ModelRuntime;\n\n\tconstructor(runtime: ModelRuntime) {\n\t\tthis.runtime = runtime;\n\t}\n\n\t/** Reload models.json asynchronously. Await before making synchronous registry reads. */\n\trefresh(options?: ModelsRefreshOptions): Promise<ModelsRefreshResult> {\n\t\treturn this.runtime.refresh(options);\n\t}\n\n\tgetError(): string | undefined {\n\t\treturn this.runtime.getError();\n\t}\n\n\tgetAll(): Model<Api>[] {\n\t\treturn [...this.runtime.getModels()];\n\t}\n\n\tgetAvailable(): Model<Api>[] {\n\t\treturn [...this.runtime.getAvailableSnapshot()];\n\t}\n\n\tfind(provider: string, modelId: string): Model<Api> | undefined {\n\t\treturn this.runtime.getModel(provider, modelId);\n\t}\n\n\t/** Find a model of a non-chat type, e.g. `findOfType(\"classifier\", \"typesafe\", \"jev-latest\")`. */\n\tfindOfType<TType extends ModelType>(\n\t\ttype: TType,\n\t\tprovider: string,\n\t\tmodelId: string,\n\t): ModelTypeMap[TType] | undefined {\n\t\treturn this.runtime.getModelOfType(type, provider, modelId);\n\t}\n\n\thasConfiguredAuth(model: Model<Api>): boolean {\n\t\treturn this.runtime.hasConfiguredAuth(model.provider);\n\t}\n\n\tasync getApiKeyAndHeaders(model: Model<Api>): Promise<ResolvedRequestAuth> {\n\t\ttry {\n\t\t\tconst resolution = await this.runtime.getAuth(model);\n\t\t\tif (!resolution) {\n\t\t\t\tconst compatibility = this.runtime.getCompatibilityRequestConfig(model);\n\t\t\t\tif (compatibility.authHeader) {\n\t\t\t\t\treturn { ok: false, error: `No API key found for \"${model.provider}\"` };\n\t\t\t\t}\n\t\t\t\treturn { ok: true, headers: compatibility.headers };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tapiKey: resolution.auth.apiKey,\n\t\t\t\theaders: resolution.auth.headers,\n\t\t\t\t...(resolution.auth.baseUrl ? { baseUrl: resolution.auth.baseUrl } : {}),\n\t\t\t\tenv: resolution.env,\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tconst cause = error instanceof Error ? error.cause : undefined;\n\t\t\tconst message =\n\t\t\t\tcause instanceof Error ? cause.message : error instanceof Error ? error.message : String(error);\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\terror:\n\t\t\t\t\tmessage === \"authHeader requires a resolved API key\"\n\t\t\t\t\t\t? `No API key found for \"${model.provider}\"`\n\t\t\t\t\t\t: message,\n\t\t\t};\n\t\t}\n\t}\n\n\tgetProviderAuthStatus(provider: string): AuthStatus {\n\t\treturn this.runtime.getProviderAuthStatus(provider);\n\t}\n\n\tgetProvider(provider: string): Provider | undefined {\n\t\treturn this.runtime.getProvider(provider);\n\t}\n\n\t/** Stream through the configured provider with request-time authentication. */\n\tstream<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): AssistantMessageEventStream {\n\t\treturn this.runtime.stream(model, context, options);\n\t}\n\n\t/** Stream with provider-neutral options and request-time authentication. */\n\tstreamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream {\n\t\treturn this.runtime.streamSimple(model, context, options);\n\t}\n\n\tcomplete<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): Promise<AssistantMessage> {\n\t\treturn this.runtime.complete(model, context, options);\n\t}\n\n\t/** Every known model of a type (chat, image, classifier), optionally for one provider. */\n\tgetModelsOfType<TType extends ModelType>(type: TType, provider?: string): readonly ModelTypeMap[TType][] {\n\t\treturn this.runtime.getModelsOfType(type, provider);\n\t}\n\n\t/** Models of a type whose provider has working credentials. */\n\tgetAvailableOfType<TType extends ModelType>(\n\t\ttype: TType,\n\t\tprovider?: string,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<readonly ModelTypeMap[TType][]> {\n\t\treturn this.runtime.getAvailableOfType(type, provider, options);\n\t}\n\n\tgetModelOfType<TType extends ModelType>(\n\t\ttype: TType,\n\t\tprovider: string,\n\t\tmodelId: string,\n\t): ModelTypeMap[TType] | undefined {\n\t\treturn this.runtime.getModelOfType(type, provider, modelId);\n\t}\n\n\t/** Classify structured state with request-time authentication. Never rejects. */\n\tclassify(\n\t\tmodel: ClassifierModel<ClassifierApi>,\n\t\tcontext: ClassifierContext,\n\t\toptions?: ModelsClassifierOptions,\n\t): Promise<ClassifierResult> {\n\t\treturn this.runtime.classify(model, context, options);\n\t}\n\n\t/** Generate images with request-time authentication. Never rejects. */\n\tgenerateImages(\n\t\tmodel: ImageModel<ImageApi>,\n\t\tcontext: ImagesContext,\n\t\toptions?: ModelsImagesOptions,\n\t): Promise<AssistantImages> {\n\t\treturn this.runtime.generateImages(model, context, options);\n\t}\n\n\tgetProviderDisplayName(provider: string): string {\n\t\treturn this.runtime.getProvider(provider)?.name ?? provider;\n\t}\n\n\tgetProviderAuth(provider: string): Promise<AuthResult | undefined> {\n\t\treturn this.runtime.getAuth(provider);\n\t}\n\n\tasync getApiKeyForProvider(provider: string): Promise<string | undefined> {\n\t\ttry {\n\t\t\treturn (await this.runtime.getAuth(provider))?.auth.apiKey;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tisUsingOAuth(model: Model<Api>): boolean {\n\t\treturn this.runtime.isUsingOAuth(model.provider);\n\t}\n\n\tregisterProvider(provider: Provider): void;\n\tregisterProvider(providerName: string, config: ProviderConfigInput): void;\n\tregisterProvider(providerOrName: Provider | string, config?: ProviderConfigInput): void {\n\t\tif (typeof providerOrName === \"string\") {\n\t\t\tif (!config) throw new Error(\"Provider config is required when registering by name\");\n\t\t\tthis.runtime.registerProvider(providerOrName, config);\n\t\t\treturn;\n\t\t}\n\t\tthis.runtime.registerNativeProvider(providerOrName);\n\t}\n\n\tunregisterProvider(providerName: string): void {\n\t\tthis.runtime.unregisterProvider(providerName);\n\t}\n\n\tregisterVirtualModel(definition: VirtualModelDefinition): void {\n\t\tthis.runtime.registerVirtualModel(definition);\n\t}\n\n\tunregisterVirtualModel(providerName: string, id: string): void {\n\t\tthis.runtime.unregisterVirtualModel(providerName, id);\n\t}\n\n\tgetRegisteredProviderConfig(providerName: string): ProviderConfigInput | undefined {\n\t\treturn this.runtime.getRegisteredProviderConfig(providerName);\n\t}\n\n\tgetRegisteredNativeProvider(providerName: string): Provider | undefined {\n\t\treturn this.runtime.getRegisteredNativeProvider(providerName);\n\t}\n\n\tgetRegisteredProviderIds(): readonly string[] {\n\t\treturn this.runtime.getRegisteredProviderIds();\n\t}\n}\n"]}
|
|
@@ -108,6 +108,12 @@ export declare class ModelRuntime implements Models {
|
|
|
108
108
|
logout(providerId: string, options?: AuthOperationOptions): Promise<void>;
|
|
109
109
|
refresh(options?: ModelsRefreshOptions): Promise<ModelsRefreshResult>;
|
|
110
110
|
registerNativeProvider(provider: Provider): void;
|
|
111
|
+
/**
|
|
112
|
+
* Mark a newly registered provider as configured when it has a stored credential or a configured
|
|
113
|
+
* API key. Availability checks run asynchronously, and callers such as initial model selection
|
|
114
|
+
* read the snapshot before they finish. The next availability pass replaces this entry.
|
|
115
|
+
*/
|
|
116
|
+
private markProvisionallyConfigured;
|
|
111
117
|
registerProvider(providerId: string, config: ProviderConfigInput): void;
|
|
112
118
|
unregisterProvider(providerId: string): void;
|
|
113
119
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-runtime.d.ts","sourceRoot":"","sources":["../../src/core/model-runtime.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,QAAQ,EACb,KAAK,GAAG,EAER,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,2BAA2B,EAChC,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EAEpB,KAAK,gBAAgB,EACrB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AAE,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAqBtE;IAED,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAM3C;IAED;;;;OAIG;IACH,oBAAoB,CAAC,UAAU,EAAE,sBAAsB,GAAG,IAAI,CAmB7D;IAED,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAO3D;IAED;;;;;;;;OAQG;IACG,YAAY,CACjB,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EACjB,QAAQ,EAAE,SAAS,OAAO,EAAE,EAC5B,OAAO,EAAE;QACR,MAAM,EAAE,gBAAgB,CAAC;QACzB,aAAa,EAAE,kBAAkB,CAAC;QAClC,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,MAAM,CAAC,EAAE,gBAAgB,CAAC;QAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;KAChB,GACC,OAAO,CAAC,UAAU,CAAC,CAqBrB;IAED,gDAAgD;IAChD,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAG5E;CACD"}
|
|
@@ -630,8 +630,29 @@ export class ModelRuntime {
|
|
|
630
630
|
this.nativeExtensionProviders.set(provider.id, provider);
|
|
631
631
|
this.recomposeProvider(provider.id);
|
|
632
632
|
this.updateModelSnapshot();
|
|
633
|
+
this.markProvisionallyConfigured(provider.id, configuredRequestAuthStatus(this.config.getProvider(provider.id), undefined), provider.auth.oauth && !provider.auth.apiKey ? "oauth" : "api_key");
|
|
633
634
|
void this.refresh({ allowNetwork: false });
|
|
634
635
|
}
|
|
636
|
+
/**
|
|
637
|
+
* Mark a newly registered provider as configured when it has a stored credential or a configured
|
|
638
|
+
* API key. Availability checks run asynchronously, and callers such as initial model selection
|
|
639
|
+
* read the snapshot before they finish. The next availability pass replaces this entry.
|
|
640
|
+
*/
|
|
641
|
+
markProvisionallyConfigured(providerId, configuredStatus, type) {
|
|
642
|
+
if (!this.snapshot.storedProviders.has(providerId) && !configuredStatus?.configured)
|
|
643
|
+
return;
|
|
644
|
+
const configuredProviders = new Set(this.snapshot.configuredProviders).add(providerId);
|
|
645
|
+
const auth = new Map(this.snapshot.auth);
|
|
646
|
+
// Never clobber a real check result.
|
|
647
|
+
if (!auth.get(providerId))
|
|
648
|
+
auth.set(providerId, { type, source: "configured provider" });
|
|
649
|
+
this.snapshot = {
|
|
650
|
+
...this.snapshot,
|
|
651
|
+
auth,
|
|
652
|
+
configuredProviders,
|
|
653
|
+
available: this.snapshot.all.filter((model) => configuredProviders.has(model.provider)),
|
|
654
|
+
};
|
|
655
|
+
}
|
|
635
656
|
registerProvider(providerId, config) {
|
|
636
657
|
// Validate the incoming registration on its own, like the legacy registry:
|
|
637
658
|
// a broken re-registration must throw without touching the stored config.
|
|
@@ -648,24 +669,7 @@ export class ModelRuntime {
|
|
|
648
669
|
this.extensionProviders.set(providerId, effective);
|
|
649
670
|
this.recomposeProvider(providerId);
|
|
650
671
|
this.updateModelSnapshot();
|
|
651
|
-
|
|
652
|
-
configuredRequestAuthStatus(this.config.getProvider(providerId), effective)?.configured) {
|
|
653
|
-
const configuredProviders = new Set(this.snapshot.configuredProviders).add(providerId);
|
|
654
|
-
const auth = new Map(this.snapshot.auth);
|
|
655
|
-
// Provisional entry until the async refresh lands; never clobber a real check result.
|
|
656
|
-
if (!auth.get(providerId)) {
|
|
657
|
-
auth.set(providerId, {
|
|
658
|
-
type: effective.oauth && !effective.apiKey ? "oauth" : "api_key",
|
|
659
|
-
source: "configured provider",
|
|
660
|
-
});
|
|
661
|
-
}
|
|
662
|
-
this.snapshot = {
|
|
663
|
-
...this.snapshot,
|
|
664
|
-
auth,
|
|
665
|
-
configuredProviders,
|
|
666
|
-
available: this.snapshot.all.filter((model) => configuredProviders.has(model.provider)),
|
|
667
|
-
};
|
|
668
|
-
}
|
|
672
|
+
this.markProvisionallyConfigured(providerId, configuredRequestAuthStatus(this.config.getProvider(providerId), effective), effective.oauth && !effective.apiKey ? "oauth" : "api_key");
|
|
669
673
|
void this.refresh({ allowNetwork: false });
|
|
670
674
|
}
|
|
671
675
|
unregisterProvider(providerId) {
|