pi-namespace-patch 1.3.0-namespace.1 → 1.4.0-namespace.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/CHANGELOG.md +56 -0
- package/README.md +4 -4
- package/dist/bundle/chunks/anthropic-messages-5FHV3XZG.js +6 -0
- package/dist/bundle/chunks/azure-openai-responses-KLTRI2FU.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +8 -8
- package/dist/bundle/chunks/{chunk-PYGXRV27.js → chunk-3V45WARH.js} +1 -1
- package/dist/bundle/chunks/chunk-4GGCU36O.js +11 -0
- package/dist/bundle/chunks/{chunk-S3GGRYIO.js → chunk-5AGIVGSV.js} +1 -1
- package/dist/bundle/chunks/{chunk-F5ZABL6Z.js → chunk-7CBJINYJ.js} +2 -2
- package/dist/bundle/chunks/{chunk-DRQDKNXA.js → chunk-7DDKXS2Q.js} +1 -1
- package/dist/bundle/chunks/{chunk-2LOB3CBH.js → chunk-A45IWOC6.js} +3 -3
- package/dist/bundle/chunks/{chunk-WJUNYZC5.js → chunk-BSS6T6KQ.js} +1 -1
- package/dist/bundle/chunks/{chunk-H3QXYIF7.js → chunk-CF5GWZHW.js} +1 -1
- package/dist/bundle/chunks/{chunk-DOST5PQW.js → chunk-EGE5YVUM.js} +1 -1
- package/dist/bundle/chunks/{chunk-RXG5KZNJ.js → chunk-FB6L7ZMV.js} +1 -1
- package/dist/bundle/chunks/chunk-H76KZMOI.js +2 -0
- package/dist/bundle/chunks/{chunk-GDR5JFDJ.js → chunk-INGZIYBC.js} +2 -2
- package/dist/bundle/chunks/{chunk-RH6M5TBT.js → chunk-IUWY2KTF.js} +2 -2
- package/dist/bundle/chunks/{chunk-4L3WN2XY.js → chunk-JXWJOIH4.js} +1 -1
- package/dist/bundle/chunks/{chunk-6CYCI3EJ.js → chunk-LVVZS2NO.js} +1 -1
- package/dist/bundle/chunks/{chunk-5GTPJSRI.js → chunk-N43LRJ4N.js} +1 -1
- package/dist/bundle/chunks/chunk-NFLURVK3.js +2 -0
- package/dist/bundle/chunks/chunk-QSDU2SDK.js +16 -0
- package/dist/bundle/chunks/chunk-RISAW7OQ.js +9 -0
- package/dist/bundle/chunks/{chunk-AKJ3ZOR3.js → chunk-RWO6Q3KK.js} +1 -1
- package/dist/bundle/chunks/{chunk-6MWTY2OB.js → chunk-T726RZZU.js} +10 -9
- package/dist/bundle/chunks/{chunk-ZBURYEWF.js → chunk-TMTOQ7H7.js} +1 -1
- package/dist/bundle/chunks/chunk-TRERZKRC.js +2 -0
- package/dist/bundle/chunks/{chunk-22CYIUS4.js → chunk-UKVNB6C4.js} +1 -1
- package/dist/bundle/chunks/chunk-Z6I32PHA.js +2 -0
- package/dist/bundle/chunks/{chunk-H2VI33AU.js → chunk-ZEIZZEGK.js} +32 -30
- package/dist/bundle/chunks/{cli-SWM4FQ6V.js → cli-MIMUTM5L.js} +1 -1
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-7J6REGDV.js +2 -0
- package/dist/bundle/chunks/{easter-egg-3d-OX6RUCIS.js → easter-egg-3d-RMLF7AC4.js} +1 -1
- package/dist/bundle/chunks/{execute-HXNYK3DM.js → execute-MT7QEDSI.js} +9 -3
- package/dist/bundle/chunks/github-copilot.js +1 -1
- package/dist/bundle/chunks/google-generative-ai-VPNFZDHO.js +2 -0
- package/dist/bundle/chunks/google-vertex-ZFM23MQ4.js +2 -0
- package/dist/bundle/chunks/https-proxy-agent-LVOO5TPL.js +13 -0
- package/dist/bundle/chunks/{jiti-loader-C3NU2SDH.js → jiti-loader-GL4HJFAD.js} +1 -1
- package/dist/bundle/chunks/{jiti-static-loader-E6ANQD5T.js → jiti-static-loader-2RCDI6B4.js} +1 -1
- package/dist/bundle/chunks/{lib-TEDK3E5I.js → lib-4AVRLBHM.js} +1 -1
- package/dist/bundle/chunks/{llama-cpp-classify-FYN623RH.js → llama-cpp-classify-U4EH6TAM.js} +2 -2
- package/dist/bundle/chunks/{mistral-conversations-AMQJ43DD.js → mistral-conversations-WCAJTBXO.js} +1 -1
- package/dist/bundle/chunks/{multipart-parser-SQ6GDJL7.js → multipart-parser-FMGQ7342.js} +1 -1
- package/dist/bundle/chunks/{node-TWVVAGPO.js → node-AUOGOBCN.js} +1 -1
- package/dist/bundle/chunks/{node-N5BSDOA5.js → node-KCMANYC2.js} +1 -1
- package/dist/bundle/chunks/openai-codex-responses-JQR3IK2C.js +10 -0
- package/dist/bundle/chunks/openai-completions-27RKPL37.js +7 -0
- package/dist/bundle/chunks/{openai-decisions-WVPMQ4JD.js → openai-decisions-MJYPUCLX.js} +1 -1
- package/dist/bundle/chunks/openai-responses-I2TBW7OL.js +4 -0
- package/dist/bundle/chunks/openrouter-images-WBAVKHHY.js +2 -0
- package/dist/bundle/chunks/pi-messages-S7RKCD5K.js +8 -0
- package/dist/bundle/chunks/{runtime-366HE7CW.js → runtime-GJOZRI5I.js} +1 -1
- package/dist/bundle/chunks/{src-UK77SYZE.js → src-QKGKDFSU.js} +1 -1
- package/dist/bundle/chunks/typesafe-system-one-4C7ULOVP.js +2 -0
- package/dist/bundle/chunks/virtual-modules-6XWNE4NR.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/core/agent-session.d.ts +5 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +41 -12
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/client-identity.d.ts +8 -0
- package/dist/core/client-identity.d.ts.map +1 -0
- package/dist/core/client-identity.js +15 -0
- package/dist/core/client-identity.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +1 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +2 -2
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +20 -15
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +2 -0
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/template.html +1 -0
- package/dist/core/export-html/template.js +2 -1
- package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
- package/dist/core/export-html/vendor/marked.min.js +30 -29
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +3 -0
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/virtual-modules.js +3 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -1
- package/dist/core/model-config.d.ts +915 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +48 -24
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-resolver.js +7 -7
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +6 -3
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/provider-composer.d.ts +2 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +7 -3
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +8 -9
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +3 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +99 -24
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/mcp/config.d.ts.map +1 -1
- package/dist/extensions/mcp/config.js +3 -2
- package/dist/extensions/mcp/config.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +11 -15
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +68 -109
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +2 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/clipboard-command.d.ts.map +1 -1
- package/dist/utils/clipboard-command.js +3 -0
- package/dist/utils/clipboard-command.js.map +1 -1
- package/dist/utils/pi-user-agent.d.ts +1 -0
- package/dist/utils/pi-user-agent.d.ts.map +1 -1
- package/dist/utils/pi-user-agent.js +3 -2
- package/dist/utils/pi-user-agent.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +45 -13
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +4 -3
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/codemode.md +2 -2
- package/docs/compaction.md +3 -3
- package/docs/custom-provider.md +53 -1
- package/docs/docs.json +4 -0
- package/docs/environment-variables.md +1 -0
- package/docs/extensions.md +133 -10
- package/docs/models-configuration.md +196 -0
- package/docs/models.md +21 -5
- package/docs/settings.md +1 -1
- package/docs/tui.md +70 -0
- package/docs/windows.md +16 -2
- 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/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/package.json +7 -6
- package/schemas/models.schema.json +83 -29
- package/dist/bundle/chunks/anthropic-messages-UIH6DSZT.js +0 -6
- package/dist/bundle/chunks/azure-openai-responses-KZZFKCXW.js +0 -2
- package/dist/bundle/chunks/chunk-2JW42LFQ.js +0 -2
- package/dist/bundle/chunks/chunk-3ZATHNCK.js +0 -9
- package/dist/bundle/chunks/chunk-HACVPRBJ.js +0 -11
- package/dist/bundle/chunks/chunk-ITZNWD4K.js +0 -2
- package/dist/bundle/chunks/chunk-UCKJ6OH5.js +0 -11
- package/dist/bundle/chunks/chunk-XIX7LUWI.js +0 -2
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-UTBL2KOF.js +0 -2
- package/dist/bundle/chunks/google-generative-ai-KJOKBJM3.js +0 -2
- package/dist/bundle/chunks/google-vertex-VCLZ36OB.js +0 -2
- package/dist/bundle/chunks/https-proxy-agent-2VXB7436.js +0 -13
- package/dist/bundle/chunks/openai-codex-responses-ZYGHVE5B.js +0 -10
- package/dist/bundle/chunks/openai-completions-BGCEXFAB.js +0 -7
- package/dist/bundle/chunks/openai-responses-KCCCXI3B.js +0 -3
- package/dist/bundle/chunks/openrouter-images-DUPG5DZO.js +0 -2
- package/dist/bundle/chunks/pi-messages-V27DSLVC.js +0 -8
- package/dist/bundle/chunks/typesafe-system-one-ZSK3RN4B.js +0 -2
- package/dist/bundle/chunks/virtual-modules-ZXBODXVN.js +0 -2
- package/dist/core/provider-attribution.d.ts +0 -4
- package/dist/core/provider-attribution.d.ts.map +0 -1
- package/dist/core/provider-attribution.js +0 -72
- package/dist/core/provider-attribution.js.map +0 -1
|
@@ -32,6 +32,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
|
32
32
|
import { dirname, join } from "node:path";
|
|
33
33
|
import { CONFIG_DIR_NAME } from "../../config.js";
|
|
34
34
|
import { mcpNamespace, validateMcpServerConfig, } from "../../core/mcp-servers.js";
|
|
35
|
+
import { stripBom } from "../../utils/text.js";
|
|
35
36
|
export { getMcpToolExposure } from "../../core/mcp-servers.js";
|
|
36
37
|
const OVERRIDE_KEYS = ["enabled", "exposure", "toolExposure"];
|
|
37
38
|
/** Whether an entry overrides a server defined elsewhere instead of defining one. */
|
|
@@ -47,7 +48,7 @@ function readConfigFile(path, scope, state) {
|
|
|
47
48
|
return;
|
|
48
49
|
let parsed;
|
|
49
50
|
try {
|
|
50
|
-
parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
51
|
+
parsed = JSON.parse(stripBom(readFileSync(path, "utf8")));
|
|
51
52
|
}
|
|
52
53
|
catch (error) {
|
|
53
54
|
errors.push(`${path}: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -179,7 +180,7 @@ export function removeMcpServerConfig(path, name) {
|
|
|
179
180
|
* it back with its indentation when `edit` returns true. Other content is kept.
|
|
180
181
|
*/
|
|
181
182
|
function editMcpServers(path, edit) {
|
|
182
|
-
const text = existsSync(path) ? readFileSync(path, "utf8") : undefined;
|
|
183
|
+
const text = existsSync(path) ? stripBom(readFileSync(path, "utf8")) : undefined;
|
|
183
184
|
const parsed = text === undefined ? {} : JSON.parse(text);
|
|
184
185
|
if (!isRecord(parsed) || (parsed.mcpServers !== undefined && !isRecord(parsed.mcpServers))) {
|
|
185
186
|
throw new Error(`${path}: expected an object with an "mcpServers" object`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/extensions/mcp/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAGN,YAAY,EACZ,uBAAuB,GACvB,MAAM,2BAA2B,CAAC;AASnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAyB/D,MAAM,aAAa,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;AAE9D,qFAAqF;AACrF,SAAS,UAAU,CAAC,KAA8B;IACjD,OAAO,KAAK,CAAC,OAAO,KAAK,SAAS,IAAI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ACH,OAAO,OAAO,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAS,cAAc,CACtB,IAAY,EACZ,IAAgG;IAEhG,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACvE,MAAM,MAAM,GAAY,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACnE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,KAAK,SAAS,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;QAC5F,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,kDAAkD,CAAC,CAAC;IAC5E,CAAC;IACD,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5E,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC;QAAE,OAAO;IACnC,MAAM,MAAM,GAAG,CAAC,IAAI,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;IAChE,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,aAAa,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;AAClE,CAAC","sourcesContent":["/**\n * MCP server configuration.\n *\n * Servers are read from `mcp.json` in the agent directory and, for trusted projects, from\n * `<project>/.pi/mcp.json`. Both use the `mcpServers` shape shared by other MCP clients, so\n * existing configurations can be copied over. Project entries replace global entries with the\n * same name.\n *\n * A project entry without `command`, `url`, or `type` overrides only `enabled`, `exposure`, and\n * `toolExposure` of the global server with the same name, for example to turn it off in one project:\n * `{ \"mcpServers\": { \"internal-tools\": { \"enabled\": false } } }`. The rest of the global entry is kept,\n * including credentials the project could not set itself.\n *\n * ```json\n * {\n * \"mcpServers\": {\n * \"filesystem\": { \"command\": \"npx\", \"args\": [\"-y\", \"@modelcontextprotocol/server-filesystem\", \".\"] },\n * \"docs\": { \"url\": \"https://example.com/mcp\", \"headers\": { \"Authorization\": \"Bearer ${DOCS_TOKEN}\" } },\n * \"sentry\": { \"url\": \"https://mcp.sentry.dev/mcp\" }\n * }\n * }\n * ```\n *\n * HTTP servers without an `Authorization` header use OAuth when they answer 401 (sign in with `/mcp`).\n * `\"auth\": { \"provider\": \"<provider>\" }` sends the token of a `/login` provider instead. Project files\n * cannot use it, so a repository cannot pick where the credential goes.\n *\n * The top-level `autoEnableCodemode` (default true) activates the codemode tool when a server\n * with `codemode` exposure connects. A project value overrides the global one.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { CONFIG_DIR_NAME } from \"../../config.ts\";\nimport {\n\ttype McpExposure,\n\ttype McpServerConfig,\n\tmcpNamespace,\n\tvalidateMcpServerConfig,\n} from \"../../core/mcp-servers.ts\";\n\nexport type {\n\tMcpExposure,\n\tMcpHttpServerConfig,\n\tMcpOAuthConfig,\n\tMcpServerConfig,\n\tMcpStdioServerConfig,\n} from \"../../core/mcp-servers.ts\";\nexport { getMcpToolExposure } from \"../../core/mcp-servers.ts\";\n\nexport interface McpServerEntry {\n\tname: string;\n\tconfig: McpServerConfig;\n\t/** Config file that defined the entry, or the path of the extension that registered it. */\n\tsource: string;\n\t/**\n\t * The global or the project `mcp.json`, or `extension` for servers registered with\n\t * `pi.registerMcpServer()`. Changes to extension servers are not saved.\n\t */\n\tscope?: \"global\" | \"project\" | \"extension\";\n\t/** Project `mcp.json` with an override of this global server's `enabled`, `exposure`, or `toolExposure`. */\n\toverride?: string;\n}\n\nexport interface LoadedMcpConfig {\n\tservers: McpServerEntry[];\n\t/** Activate the codemode tool when `codemode` servers connect. Default: true. */\n\tautoEnableCodemode?: boolean;\n\terrors: string[];\n\t/** The project `mcp.json` when the project is trusted, where `/mcp` saves project overrides. */\n\tprojectConfig?: string;\n}\n\nconst OVERRIDE_KEYS = [\"enabled\", \"exposure\", \"toolExposure\"];\n\n/** Whether an entry overrides a server defined elsewhere instead of defining one. */\nfunction isOverride(value: Record<string, unknown>): boolean {\n\treturn value.command === undefined && value.url === undefined && value.type === undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\ninterface McpConfigState {\n\tservers: Map<string, McpServerEntry>;\n\tautoEnableCodemode?: boolean;\n\terrors: string[];\n}\n\nfunction readConfigFile(path: string, scope: \"global\" | \"project\", state: McpConfigState): void {\n\tconst { servers, errors } = state;\n\tif (!existsSync(path)) return;\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(readFileSync(path, \"utf8\"));\n\t} catch (error) {\n\t\terrors.push(`${path}: ${error instanceof Error ? error.message : String(error)}`);\n\t\treturn;\n\t}\n\tif (!isRecord(parsed) || (parsed.mcpServers !== undefined && !isRecord(parsed.mcpServers))) {\n\t\terrors.push(`${path}: expected an object with an \"mcpServers\" object`);\n\t\treturn;\n\t}\n\tif (typeof parsed.autoEnableCodemode === \"boolean\") state.autoEnableCodemode = parsed.autoEnableCodemode;\n\telse if (parsed.autoEnableCodemode !== undefined) errors.push(`${path}: autoEnableCodemode must be a boolean`);\n\tfor (const [name, value] of Object.entries(parsed.mcpServers ?? {})) {\n\t\tif (scope === \"project\" && isRecord(value) && isOverride(value)) {\n\t\t\tconst base = servers.get(name);\n\t\t\tconst extra = Object.keys(value).filter((key) => !OVERRIDE_KEYS.includes(key));\n\t\t\tif (!base) {\n\t\t\t\terrors.push(`${path}: server \"${name}\" needs \"command\" or \"url\", or a global server to override`);\n\t\t\t} else if (extra.length > 0) {\n\t\t\t\terrors.push(`${path}: server \"${name}\": an override can only set ${OVERRIDE_KEYS.join(\", \")}`);\n\t\t\t} else {\n\t\t\t\tconst config = validateMcpServerConfig(name, { ...base.config, ...value });\n\t\t\t\tif (typeof config === \"string\") errors.push(`${path}: ${config}`);\n\t\t\t\telse servers.set(name, { ...base, config, override: path });\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tconst config = validateMcpServerConfig(name, value);\n\t\tif (typeof config === \"string\") {\n\t\t\terrors.push(`${path}: ${config}`);\n\t\t\tcontinue;\n\t\t}\n\t\t// Names that differ only in `-` and `_` would share a namespace.\n\t\tconst clash = [...servers.keys()].find((other) => other !== name && mcpNamespace(other) === mcpNamespace(name));\n\t\tif (clash) {\n\t\t\terrors.push(`${path}: server \"${name}\" conflicts with \"${clash}\"`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (scope === \"project\" && \"url\" in config && config.auth) {\n\t\t\terrors.push(`${path}: server \"${name}\": auth is only allowed in the global mcp.json`);\n\t\t\tcontinue;\n\t\t}\n\t\tservers.set(name, { name, config, source: path, scope });\n\t}\n}\n\n/**\n * Load global and (when trusted) project MCP configuration. Disabled servers are included with\n * `enabled: false`, so they can be enabled again.\n */\nexport function loadMcpConfig(options: { agentDir: string; cwd: string; projectTrusted: boolean }): LoadedMcpConfig {\n\tconst state: McpConfigState = { servers: new Map(), errors: [] };\n\treadConfigFile(join(options.agentDir, \"mcp.json\"), \"global\", state);\n\tconst projectConfig = options.projectTrusted ? join(options.cwd, CONFIG_DIR_NAME, \"mcp.json\") : undefined;\n\tif (projectConfig) readConfigFile(projectConfig, \"project\", state);\n\treturn {\n\t\tservers: [...state.servers.values()],\n\t\t...(state.autoEnableCodemode === undefined ? {} : { autoEnableCodemode: state.autoEnableCodemode }),\n\t\terrors: state.errors,\n\t\t...(projectConfig ? { projectConfig } : {}),\n\t};\n}\n\n/** Settings `/mcp` changes. `enabled: true` and `exposure: \"codemode\"` are the defaults and remove the key. */\nexport interface McpServerConfigPatch {\n\tenabled?: boolean;\n\texposure?: McpExposure;\n}\n\n/**\n * Change one server's settings in the `mcp.json` that defines or overrides it. With `override`, a\n * missing entry is added as an override. Overrides keep default values, since they replace the global\n * server's. Other content is kept; the file is rewritten with its indentation.\n */\nexport function updateMcpServerConfig(\n\tpath: string,\n\tname: string,\n\tpatch: McpServerConfigPatch,\n\toptions: { override?: boolean } = {},\n): void {\n\teditMcpServers(path, (servers, parsed) => {\n\t\tlet server = servers?.[name];\n\t\tif (server === undefined && options.override) {\n\t\t\tserver = {};\n\t\t\tparsed.mcpServers = { ...servers, [name]: server };\n\t\t}\n\t\tif (!isRecord(server)) throw new Error(`${path} does not define MCP server \"${name}\"`);\n\t\tconst keepDefaults = isOverride(server);\n\t\tif (patch.enabled !== undefined) {\n\t\t\tif (patch.enabled && !keepDefaults) delete server.enabled;\n\t\t\telse server.enabled = patch.enabled;\n\t\t}\n\t\tif (patch.exposure !== undefined) {\n\t\t\tif (patch.exposure === \"codemode\" && !keepDefaults) delete server.exposure;\n\t\t\telse server.exposure = patch.exposure;\n\t\t}\n\t\treturn true;\n\t});\n}\n\n/**\n * Add a server to an `mcp.json`, creating the file when missing. An existing entry with the same\n * name is replaced. Returns true when an entry was replaced.\n */\nexport function addMcpServerConfig(path: string, name: string, config: McpServerConfig): boolean {\n\tlet replaced = false;\n\teditMcpServers(path, (servers, parsed) => {\n\t\tconst target = servers ?? {};\n\t\treplaced = target[name] !== undefined;\n\t\ttarget[name] = config;\n\t\tparsed.mcpServers = target;\n\t\treturn true;\n\t});\n\treturn replaced;\n}\n\n/** Remove a server from an `mcp.json`. Returns false when the file does not define it. */\nexport function removeMcpServerConfig(path: string, name: string): boolean {\n\tif (!existsSync(path)) return false;\n\tlet removed = false;\n\teditMcpServers(path, (servers) => {\n\t\tif (!servers || servers[name] === undefined) return false;\n\t\tdelete servers[name];\n\t\tremoved = true;\n\t\treturn true;\n\t});\n\treturn removed;\n}\n\n/**\n * Read an `mcp.json` (an empty config when missing), let `edit` change its `mcpServers`, and write\n * it back with its indentation when `edit` returns true. Other content is kept.\n */\nfunction editMcpServers(\n\tpath: string,\n\tedit: (servers: Record<string, unknown> | undefined, parsed: Record<string, unknown>) => boolean,\n): void {\n\tconst text = existsSync(path) ? readFileSync(path, \"utf8\") : undefined;\n\tconst parsed: unknown = text === undefined ? {} : JSON.parse(text);\n\tif (!isRecord(parsed) || (parsed.mcpServers !== undefined && !isRecord(parsed.mcpServers))) {\n\t\tthrow new Error(`${path}: expected an object with an \"mcpServers\" object`);\n\t}\n\tconst servers = isRecord(parsed.mcpServers) ? parsed.mcpServers : undefined;\n\tif (!edit(servers, parsed)) return;\n\tconst indent = (text && /^([ \\t]+)\\S/m.exec(text)?.[1]) || \" \";\n\tmkdirSync(dirname(path), { recursive: true });\n\twriteFileSync(path, `${JSON.stringify(parsed, null, indent)}\\n`);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/extensions/mcp/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAGN,YAAY,EACZ,uBAAuB,GACvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAS/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAyB/D,MAAM,aAAa,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;AAE9D,qFAAqF;A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","sourcesContent":["/**\n * MCP server configuration.\n *\n * Servers are read from `mcp.json` in the agent directory and, for trusted projects, from\n * `<project>/.pi/mcp.json`. Both use the `mcpServers` shape shared by other MCP clients, so\n * existing configurations can be copied over. Project entries replace global entries with the\n * same name.\n *\n * A project entry without `command`, `url`, or `type` overrides only `enabled`, `exposure`, and\n * `toolExposure` of the global server with the same name, for example to turn it off in one project:\n * `{ \"mcpServers\": { \"internal-tools\": { \"enabled\": false } } }`. The rest of the global entry is kept,\n * including credentials the project could not set itself.\n *\n * ```json\n * {\n * \"mcpServers\": {\n * \"filesystem\": { \"command\": \"npx\", \"args\": [\"-y\", \"@modelcontextprotocol/server-filesystem\", \".\"] },\n * \"docs\": { \"url\": \"https://example.com/mcp\", \"headers\": { \"Authorization\": \"Bearer ${DOCS_TOKEN}\" } },\n * \"sentry\": { \"url\": \"https://mcp.sentry.dev/mcp\" }\n * }\n * }\n * ```\n *\n * HTTP servers without an `Authorization` header use OAuth when they answer 401 (sign in with `/mcp`).\n * `\"auth\": { \"provider\": \"<provider>\" }` sends the token of a `/login` provider instead. Project files\n * cannot use it, so a repository cannot pick where the credential goes.\n *\n * The top-level `autoEnableCodemode` (default true) activates the codemode tool when a server\n * with `codemode` exposure connects. A project value overrides the global one.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { CONFIG_DIR_NAME } from \"../../config.ts\";\nimport {\n\ttype McpExposure,\n\ttype McpServerConfig,\n\tmcpNamespace,\n\tvalidateMcpServerConfig,\n} from \"../../core/mcp-servers.ts\";\nimport { stripBom } from \"../../utils/text.ts\";\n\nexport type {\n\tMcpExposure,\n\tMcpHttpServerConfig,\n\tMcpOAuthConfig,\n\tMcpServerConfig,\n\tMcpStdioServerConfig,\n} from \"../../core/mcp-servers.ts\";\nexport { getMcpToolExposure } from \"../../core/mcp-servers.ts\";\n\nexport interface McpServerEntry {\n\tname: string;\n\tconfig: McpServerConfig;\n\t/** Config file that defined the entry, or the path of the extension that registered it. */\n\tsource: string;\n\t/**\n\t * The global or the project `mcp.json`, or `extension` for servers registered with\n\t * `pi.registerMcpServer()`. Changes to extension servers are not saved.\n\t */\n\tscope?: \"global\" | \"project\" | \"extension\";\n\t/** Project `mcp.json` with an override of this global server's `enabled`, `exposure`, or `toolExposure`. */\n\toverride?: string;\n}\n\nexport interface LoadedMcpConfig {\n\tservers: McpServerEntry[];\n\t/** Activate the codemode tool when `codemode` servers connect. Default: true. */\n\tautoEnableCodemode?: boolean;\n\terrors: string[];\n\t/** The project `mcp.json` when the project is trusted, where `/mcp` saves project overrides. */\n\tprojectConfig?: string;\n}\n\nconst OVERRIDE_KEYS = [\"enabled\", \"exposure\", \"toolExposure\"];\n\n/** Whether an entry overrides a server defined elsewhere instead of defining one. */\nfunction isOverride(value: Record<string, unknown>): boolean {\n\treturn value.command === undefined && value.url === undefined && value.type === undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\ninterface McpConfigState {\n\tservers: Map<string, McpServerEntry>;\n\tautoEnableCodemode?: boolean;\n\terrors: string[];\n}\n\nfunction readConfigFile(path: string, scope: \"global\" | \"project\", state: McpConfigState): void {\n\tconst { servers, errors } = state;\n\tif (!existsSync(path)) return;\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(stripBom(readFileSync(path, \"utf8\")));\n\t} catch (error) {\n\t\terrors.push(`${path}: ${error instanceof Error ? error.message : String(error)}`);\n\t\treturn;\n\t}\n\tif (!isRecord(parsed) || (parsed.mcpServers !== undefined && !isRecord(parsed.mcpServers))) {\n\t\terrors.push(`${path}: expected an object with an \"mcpServers\" object`);\n\t\treturn;\n\t}\n\tif (typeof parsed.autoEnableCodemode === \"boolean\") state.autoEnableCodemode = parsed.autoEnableCodemode;\n\telse if (parsed.autoEnableCodemode !== undefined) errors.push(`${path}: autoEnableCodemode must be a boolean`);\n\tfor (const [name, value] of Object.entries(parsed.mcpServers ?? {})) {\n\t\tif (scope === \"project\" && isRecord(value) && isOverride(value)) {\n\t\t\tconst base = servers.get(name);\n\t\t\tconst extra = Object.keys(value).filter((key) => !OVERRIDE_KEYS.includes(key));\n\t\t\tif (!base) {\n\t\t\t\terrors.push(`${path}: server \"${name}\" needs \"command\" or \"url\", or a global server to override`);\n\t\t\t} else if (extra.length > 0) {\n\t\t\t\terrors.push(`${path}: server \"${name}\": an override can only set ${OVERRIDE_KEYS.join(\", \")}`);\n\t\t\t} else {\n\t\t\t\tconst config = validateMcpServerConfig(name, { ...base.config, ...value });\n\t\t\t\tif (typeof config === \"string\") errors.push(`${path}: ${config}`);\n\t\t\t\telse servers.set(name, { ...base, config, override: path });\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tconst config = validateMcpServerConfig(name, value);\n\t\tif (typeof config === \"string\") {\n\t\t\terrors.push(`${path}: ${config}`);\n\t\t\tcontinue;\n\t\t}\n\t\t// Names that differ only in `-` and `_` would share a namespace.\n\t\tconst clash = [...servers.keys()].find((other) => other !== name && mcpNamespace(other) === mcpNamespace(name));\n\t\tif (clash) {\n\t\t\terrors.push(`${path}: server \"${name}\" conflicts with \"${clash}\"`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (scope === \"project\" && \"url\" in config && config.auth) {\n\t\t\terrors.push(`${path}: server \"${name}\": auth is only allowed in the global mcp.json`);\n\t\t\tcontinue;\n\t\t}\n\t\tservers.set(name, { name, config, source: path, scope });\n\t}\n}\n\n/**\n * Load global and (when trusted) project MCP configuration. Disabled servers are included with\n * `enabled: false`, so they can be enabled again.\n */\nexport function loadMcpConfig(options: { agentDir: string; cwd: string; projectTrusted: boolean }): LoadedMcpConfig {\n\tconst state: McpConfigState = { servers: new Map(), errors: [] };\n\treadConfigFile(join(options.agentDir, \"mcp.json\"), \"global\", state);\n\tconst projectConfig = options.projectTrusted ? join(options.cwd, CONFIG_DIR_NAME, \"mcp.json\") : undefined;\n\tif (projectConfig) readConfigFile(projectConfig, \"project\", state);\n\treturn {\n\t\tservers: [...state.servers.values()],\n\t\t...(state.autoEnableCodemode === undefined ? {} : { autoEnableCodemode: state.autoEnableCodemode }),\n\t\terrors: state.errors,\n\t\t...(projectConfig ? { projectConfig } : {}),\n\t};\n}\n\n/** Settings `/mcp` changes. `enabled: true` and `exposure: \"codemode\"` are the defaults and remove the key. */\nexport interface McpServerConfigPatch {\n\tenabled?: boolean;\n\texposure?: McpExposure;\n}\n\n/**\n * Change one server's settings in the `mcp.json` that defines or overrides it. With `override`, a\n * missing entry is added as an override. Overrides keep default values, since they replace the global\n * server's. Other content is kept; the file is rewritten with its indentation.\n */\nexport function updateMcpServerConfig(\n\tpath: string,\n\tname: string,\n\tpatch: McpServerConfigPatch,\n\toptions: { override?: boolean } = {},\n): void {\n\teditMcpServers(path, (servers, parsed) => {\n\t\tlet server = servers?.[name];\n\t\tif (server === undefined && options.override) {\n\t\t\tserver = {};\n\t\t\tparsed.mcpServers = { ...servers, [name]: server };\n\t\t}\n\t\tif (!isRecord(server)) throw new Error(`${path} does not define MCP server \"${name}\"`);\n\t\tconst keepDefaults = isOverride(server);\n\t\tif (patch.enabled !== undefined) {\n\t\t\tif (patch.enabled && !keepDefaults) delete server.enabled;\n\t\t\telse server.enabled = patch.enabled;\n\t\t}\n\t\tif (patch.exposure !== undefined) {\n\t\t\tif (patch.exposure === \"codemode\" && !keepDefaults) delete server.exposure;\n\t\t\telse server.exposure = patch.exposure;\n\t\t}\n\t\treturn true;\n\t});\n}\n\n/**\n * Add a server to an `mcp.json`, creating the file when missing. An existing entry with the same\n * name is replaced. Returns true when an entry was replaced.\n */\nexport function addMcpServerConfig(path: string, name: string, config: McpServerConfig): boolean {\n\tlet replaced = false;\n\teditMcpServers(path, (servers, parsed) => {\n\t\tconst target = servers ?? {};\n\t\treplaced = target[name] !== undefined;\n\t\ttarget[name] = config;\n\t\tparsed.mcpServers = target;\n\t\treturn true;\n\t});\n\treturn replaced;\n}\n\n/** Remove a server from an `mcp.json`. Returns false when the file does not define it. */\nexport function removeMcpServerConfig(path: string, name: string): boolean {\n\tif (!existsSync(path)) return false;\n\tlet removed = false;\n\teditMcpServers(path, (servers) => {\n\t\tif (!servers || servers[name] === undefined) return false;\n\t\tdelete servers[name];\n\t\tremoved = true;\n\t\treturn true;\n\t});\n\treturn removed;\n}\n\n/**\n * Read an `mcp.json` (an empty config when missing), let `edit` change its `mcpServers`, and write\n * it back with its indentation when `edit` returns true. Other content is kept.\n */\nfunction editMcpServers(\n\tpath: string,\n\tedit: (servers: Record<string, unknown> | undefined, parsed: Record<string, unknown>) => boolean,\n): void {\n\tconst text = existsSync(path) ? stripBom(readFileSync(path, \"utf8\")) : undefined;\n\tconst parsed: unknown = text === undefined ? {} : JSON.parse(text);\n\tif (!isRecord(parsed) || (parsed.mcpServers !== undefined && !isRecord(parsed.mcpServers))) {\n\t\tthrow new Error(`${path}: expected an object with an \"mcpServers\" object`);\n\t}\n\tconst servers = isRecord(parsed.mcpServers) ? parsed.mcpServers : undefined;\n\tif (!edit(servers, parsed)) return;\n\tconst indent = (text && /^([ \\t]+)\\S/m.exec(text)?.[1]) || \" \";\n\tmkdirSync(dirname(path), { recursive: true });\n\twriteFileSync(path, `${JSON.stringify(parsed, null, indent)}\\n`);\n}\n"]}
|
|
@@ -109,9 +109,7 @@ export declare class InteractiveMode {
|
|
|
109
109
|
/** The `/bug` hint is shown at most once per session so error output stays readable. */
|
|
110
110
|
private bugReportHintShown;
|
|
111
111
|
private installChangeWarningShown;
|
|
112
|
-
private
|
|
113
|
-
private extensionInput;
|
|
114
|
-
private extensionEditor;
|
|
112
|
+
private extensionDialogs;
|
|
115
113
|
private extensionTerminalInputSubscriptions;
|
|
116
114
|
private extensionWidgetsAbove;
|
|
117
115
|
private extensionWidgetsBelow;
|
|
@@ -261,13 +259,19 @@ export declare class InteractiveMode {
|
|
|
261
259
|
private createProjectTrustContext;
|
|
262
260
|
private createExtensionUIContext;
|
|
263
261
|
/**
|
|
264
|
-
* Show
|
|
262
|
+
* Show an extension dialog in the editor slot.
|
|
263
|
+
* Dialogs form a stack: a new dialog hides the visible one, and closing the visible dialog shows
|
|
264
|
+
* the previous one again. Every dialog stays answerable, so no dialog promise is left pending,
|
|
265
|
+
* and dialogs opened from inside another dialog (for example a confirm from a custom component) work.
|
|
265
266
|
*/
|
|
266
|
-
private
|
|
267
|
+
private pushExtensionDialog;
|
|
268
|
+
/** Remove an extension dialog. If it was visible, show the previous dialog or the editor. */
|
|
269
|
+
private removeExtensionDialog;
|
|
270
|
+
private showTopExtensionDialog;
|
|
267
271
|
/**
|
|
268
|
-
*
|
|
272
|
+
* Show a selector for extensions.
|
|
269
273
|
*/
|
|
270
|
-
private
|
|
274
|
+
private showExtensionSelector;
|
|
271
275
|
/**
|
|
272
276
|
* Show a confirmation dialog for extensions.
|
|
273
277
|
*/
|
|
@@ -277,18 +281,10 @@ export declare class InteractiveMode {
|
|
|
277
281
|
* Show a text input for extensions.
|
|
278
282
|
*/
|
|
279
283
|
private showExtensionInput;
|
|
280
|
-
/**
|
|
281
|
-
* Hide the extension input.
|
|
282
|
-
*/
|
|
283
|
-
private hideExtensionInput;
|
|
284
284
|
/**
|
|
285
285
|
* Show a multi-line editor for extensions (with Ctrl+G support).
|
|
286
286
|
*/
|
|
287
287
|
private showExtensionEditor;
|
|
288
|
-
/**
|
|
289
|
-
* Hide the extension editor.
|
|
290
|
-
*/
|
|
291
|
-
private hideExtensionEditor;
|
|
292
288
|
/**
|
|
293
289
|
* Set a custom editor component from an extension.
|
|
294
290
|
* Pass undefined to restore the default editor.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-mode.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-mode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAEN,KAAK,YAAY,EAKjB,MAAM,8BAA8B,CAAC;AActC,OAAO,EAYN,KAAK,QAAQ,EASb,MAAM,wBAAwB,CAAC;AAeh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B,OAAO,CAAC,uBAAuB;YAsCjB,kBAAkB;IAqBhC,OAAO,CAAC,gBAAgB;IAqJxB,OAAO,CAAC,mBAAmB;YA2Cb,mBAAmB;IAqCjC,OAAO,CAAC,uBAAuB;YAmCjB,wBAAwB;IAetC,OAAO,CAAC,wBAAwB;YAalB,kBAAkB;IAuBhC,yFAAyF;YAC3E,kBAAkB;IAUhC,OAAO,CAAC,yBAAyB;IA4EjC,OAAO,CAAC,yBAAyB;YA6CnB,iBAAiB;YA4DjB,8BAA8B;IAgG5C,OAAO,CAAC,qBAAqB;YA8Bf,qBAAqB;IAmDnC,OAAO,CAAC,cAAc;YAmCR,cAAc;IAwB5B,OAAO,CAAC,gBAAgB;YAaV,aAAa;YAuBb,eAAe;IAmC7B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;YAqDd,mBAAmB;YA0FnB,mBAAmB;IAkBjC,OAAO,CAAC,sBAAsB;YA6BhB,mBAAmB;YA4CnB,kBAAkB;YAWlB,gBAAgB;YAehB,iBAAiB;IA+B/B,OAAO,CAAC,iBAAiB;IAyBzB,OAAO,CAAC,oBAAoB;IAiF5B,OAAO,CAAC,sBAAsB;IAqB9B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAIxB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,oBAAoB;YAqHd,kBAAkB;IAehC,OAAO,CAAC,kBAAkB;IAiC1B,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,oBAAoB;YAMd,iBAAiB;YA6FjB,oBAAoB;IAUlC,IAAI,CAAC,oBAAoB,uBAAiD,GAAG,IAAI,CAkBhF;CACD"}
|
|
@@ -321,9 +321,9 @@ export class InteractiveMode {
|
|
|
321
321
|
bugReportHintShown = false;
|
|
322
322
|
installChangeWarningShown = false;
|
|
323
323
|
// Extension UI state
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
324
|
+
// Extension dialogs shown in the editor slot (select, confirm, input, editor, inline custom).
|
|
325
|
+
// The last entry is visible; see pushExtensionDialog().
|
|
326
|
+
extensionDialogs = [];
|
|
327
327
|
extensionTerminalInputSubscriptions = new Set();
|
|
328
328
|
// Extension widgets (components rendered above/below the editor)
|
|
329
329
|
extensionWidgetsAbove = new Map();
|
|
@@ -1906,14 +1906,12 @@ export class InteractiveMode {
|
|
|
1906
1906
|
this.renderWidgets();
|
|
1907
1907
|
}
|
|
1908
1908
|
resetExtensionUI() {
|
|
1909
|
-
if (this.
|
|
1910
|
-
this.
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
this.
|
|
1914
|
-
|
|
1915
|
-
if (this.extensionEditor) {
|
|
1916
|
-
this.hideExtensionEditor();
|
|
1909
|
+
if (this.extensionDialogs.length > 0) {
|
|
1910
|
+
for (const dialog of this.extensionDialogs) {
|
|
1911
|
+
dialog.component.dispose?.();
|
|
1912
|
+
}
|
|
1913
|
+
this.extensionDialogs = [];
|
|
1914
|
+
this.showTopExtensionDialog();
|
|
1917
1915
|
}
|
|
1918
1916
|
this.ui.hideOverlay();
|
|
1919
1917
|
this.clearExtensionTerminalInputListeners();
|
|
@@ -2113,6 +2111,35 @@ export class InteractiveMode {
|
|
|
2113
2111
|
setToolsExpanded: (expanded) => this.setToolsExpanded(expanded),
|
|
2114
2112
|
};
|
|
2115
2113
|
}
|
|
2114
|
+
/**
|
|
2115
|
+
* Show an extension dialog in the editor slot.
|
|
2116
|
+
* Dialogs form a stack: a new dialog hides the visible one, and closing the visible dialog shows
|
|
2117
|
+
* the previous one again. Every dialog stays answerable, so no dialog promise is left pending,
|
|
2118
|
+
* and dialogs opened from inside another dialog (for example a confirm from a custom component) work.
|
|
2119
|
+
*/
|
|
2120
|
+
pushExtensionDialog(component, blocked) {
|
|
2121
|
+
this.disposeActiveSelector();
|
|
2122
|
+
this.extensionDialogs.push({ component, blocked });
|
|
2123
|
+
this.showTopExtensionDialog();
|
|
2124
|
+
}
|
|
2125
|
+
/** Remove an extension dialog. If it was visible, show the previous dialog or the editor. */
|
|
2126
|
+
removeExtensionDialog(component) {
|
|
2127
|
+
const index = this.extensionDialogs.findIndex((dialog) => dialog.component === component);
|
|
2128
|
+
if (index === -1)
|
|
2129
|
+
return;
|
|
2130
|
+
this.extensionDialogs.splice(index, 1);
|
|
2131
|
+
if (index === this.extensionDialogs.length)
|
|
2132
|
+
this.showTopExtensionDialog();
|
|
2133
|
+
}
|
|
2134
|
+
showTopExtensionDialog() {
|
|
2135
|
+
const top = this.extensionDialogs.at(-1);
|
|
2136
|
+
const component = top?.component ?? this.editor;
|
|
2137
|
+
this.editorContainer.clear();
|
|
2138
|
+
this.editorContainer.addChild(component);
|
|
2139
|
+
this.ui.setFocus(component);
|
|
2140
|
+
this.programStatus.setBlocked("extension-dialog", top?.blocked);
|
|
2141
|
+
this.ui.requestRender();
|
|
2142
|
+
}
|
|
2116
2143
|
/**
|
|
2117
2144
|
* Show a selector for extensions.
|
|
2118
2145
|
*/
|
|
@@ -2122,41 +2149,18 @@ export class InteractiveMode {
|
|
|
2122
2149
|
resolve(undefined);
|
|
2123
2150
|
return;
|
|
2124
2151
|
}
|
|
2125
|
-
const
|
|
2126
|
-
this.hideExtensionSelector();
|
|
2127
|
-
resolve(undefined);
|
|
2128
|
-
};
|
|
2129
|
-
opts?.signal?.addEventListener("abort", onAbort, { once: true });
|
|
2130
|
-
this.extensionSelector = new ExtensionSelectorComponent(title, options, (option) => {
|
|
2152
|
+
const finish = (option) => {
|
|
2131
2153
|
opts?.signal?.removeEventListener("abort", onAbort);
|
|
2132
|
-
|
|
2154
|
+
selector.dispose();
|
|
2155
|
+
this.removeExtensionDialog(selector);
|
|
2133
2156
|
resolve(option);
|
|
2134
|
-
}
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
this.disposeActiveSelector();
|
|
2140
|
-
this.editorContainer.clear();
|
|
2141
|
-
this.editorContainer.addChild(this.extensionSelector);
|
|
2142
|
-
this.ui.setFocus(this.extensionSelector);
|
|
2143
|
-
// Extension dialogs share the editor slot: opening one replaces the status of a displaced one.
|
|
2144
|
-
this.programStatus.setBlocked("extension-dialog", blocked);
|
|
2145
|
-
this.ui.requestRender();
|
|
2157
|
+
};
|
|
2158
|
+
const onAbort = () => finish(undefined);
|
|
2159
|
+
opts?.signal?.addEventListener("abort", onAbort, { once: true });
|
|
2160
|
+
const selector = new ExtensionSelectorComponent(title, options, (option) => finish(option), () => finish(undefined), { tui: this.ui, timeout: opts?.timeout, onToggleToolsExpanded: () => this.toggleToolOutputExpansion() });
|
|
2161
|
+
this.pushExtensionDialog(selector, blocked);
|
|
2146
2162
|
});
|
|
2147
2163
|
}
|
|
2148
|
-
/**
|
|
2149
|
-
* Hide the extension selector.
|
|
2150
|
-
*/
|
|
2151
|
-
hideExtensionSelector() {
|
|
2152
|
-
this.extensionSelector?.dispose();
|
|
2153
|
-
this.editorContainer.clear();
|
|
2154
|
-
this.editorContainer.addChild(this.editor);
|
|
2155
|
-
this.extensionSelector = undefined;
|
|
2156
|
-
this.programStatus.setBlocked("extension-dialog", undefined);
|
|
2157
|
-
this.ui.setFocus(this.editor);
|
|
2158
|
-
this.ui.requestRender();
|
|
2159
|
-
}
|
|
2160
2164
|
/**
|
|
2161
2165
|
* Show a confirmation dialog for extensions.
|
|
2162
2166
|
*/
|
|
@@ -2180,71 +2184,31 @@ export class InteractiveMode {
|
|
|
2180
2184
|
resolve(undefined);
|
|
2181
2185
|
return;
|
|
2182
2186
|
}
|
|
2183
|
-
const
|
|
2184
|
-
this.hideExtensionInput();
|
|
2185
|
-
resolve(undefined);
|
|
2186
|
-
};
|
|
2187
|
-
opts?.signal?.addEventListener("abort", onAbort, { once: true });
|
|
2188
|
-
this.extensionInput = new ExtensionInputComponent(title, placeholder, (value) => {
|
|
2187
|
+
const finish = (value) => {
|
|
2189
2188
|
opts?.signal?.removeEventListener("abort", onAbort);
|
|
2190
|
-
|
|
2189
|
+
input.dispose();
|
|
2190
|
+
this.removeExtensionDialog(input);
|
|
2191
2191
|
resolve(value);
|
|
2192
|
-
}
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
this.disposeActiveSelector();
|
|
2198
|
-
this.editorContainer.clear();
|
|
2199
|
-
this.editorContainer.addChild(this.extensionInput);
|
|
2200
|
-
this.ui.setFocus(this.extensionInput);
|
|
2201
|
-
this.programStatus.setBlocked("extension-dialog", { kind: "question", message: title });
|
|
2202
|
-
this.ui.requestRender();
|
|
2192
|
+
};
|
|
2193
|
+
const onAbort = () => finish(undefined);
|
|
2194
|
+
opts?.signal?.addEventListener("abort", onAbort, { once: true });
|
|
2195
|
+
const input = new ExtensionInputComponent(title, placeholder, (value) => finish(value), () => finish(undefined), { tui: this.ui, timeout: opts?.timeout });
|
|
2196
|
+
this.pushExtensionDialog(input, { kind: "question", message: title });
|
|
2203
2197
|
});
|
|
2204
2198
|
}
|
|
2205
|
-
/**
|
|
2206
|
-
* Hide the extension input.
|
|
2207
|
-
*/
|
|
2208
|
-
hideExtensionInput() {
|
|
2209
|
-
this.extensionInput?.dispose();
|
|
2210
|
-
this.editorContainer.clear();
|
|
2211
|
-
this.editorContainer.addChild(this.editor);
|
|
2212
|
-
this.extensionInput = undefined;
|
|
2213
|
-
this.programStatus.setBlocked("extension-dialog", undefined);
|
|
2214
|
-
this.ui.setFocus(this.editor);
|
|
2215
|
-
this.ui.requestRender();
|
|
2216
|
-
}
|
|
2217
2199
|
/**
|
|
2218
2200
|
* Show a multi-line editor for extensions (with Ctrl+G support).
|
|
2219
2201
|
*/
|
|
2220
2202
|
showExtensionEditor(title, prefill) {
|
|
2221
2203
|
return new Promise((resolve) => {
|
|
2222
|
-
|
|
2223
|
-
this.
|
|
2204
|
+
const finish = (value) => {
|
|
2205
|
+
this.removeExtensionDialog(editor);
|
|
2224
2206
|
resolve(value);
|
|
2225
|
-
}
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
}, undefined, this.settingsManager.getExternalEditorCommand());
|
|
2229
|
-
this.disposeActiveSelector();
|
|
2230
|
-
this.editorContainer.clear();
|
|
2231
|
-
this.editorContainer.addChild(this.extensionEditor);
|
|
2232
|
-
this.ui.setFocus(this.extensionEditor);
|
|
2233
|
-
this.programStatus.setBlocked("extension-dialog", { kind: "question", message: title });
|
|
2234
|
-
this.ui.requestRender();
|
|
2207
|
+
};
|
|
2208
|
+
const editor = new ExtensionEditorComponent(this.ui, this.keybindings, title, prefill, (value) => finish(value), () => finish(undefined), undefined, this.settingsManager.getExternalEditorCommand());
|
|
2209
|
+
this.pushExtensionDialog(editor, { kind: "question", message: title });
|
|
2235
2210
|
});
|
|
2236
2211
|
}
|
|
2237
|
-
/**
|
|
2238
|
-
* Hide the extension editor.
|
|
2239
|
-
*/
|
|
2240
|
-
hideExtensionEditor() {
|
|
2241
|
-
this.editorContainer.clear();
|
|
2242
|
-
this.editorContainer.addChild(this.editor);
|
|
2243
|
-
this.extensionEditor = undefined;
|
|
2244
|
-
this.programStatus.setBlocked("extension-dialog", undefined);
|
|
2245
|
-
this.ui.setFocus(this.editor);
|
|
2246
|
-
this.ui.requestRender();
|
|
2247
|
-
}
|
|
2248
2212
|
/**
|
|
2249
2213
|
* Set a custom editor component from an extension.
|
|
2250
2214
|
* Pass undefined to restore the default editor.
|
|
@@ -2334,17 +2298,16 @@ export class InteractiveMode {
|
|
|
2334
2298
|
async showExtensionCustom(factory, options) {
|
|
2335
2299
|
const savedText = this.editor.getText();
|
|
2336
2300
|
const isOverlay = options?.overlay ?? false;
|
|
2337
|
-
const restoreEditor = () => {
|
|
2338
|
-
this.editorContainer.clear();
|
|
2339
|
-
this.editorContainer.addChild(this.editor);
|
|
2340
|
-
this.editor.setText(savedText);
|
|
2341
|
-
this.ui.setFocus(this.editor);
|
|
2342
|
-
this.ui.requestRender();
|
|
2343
|
-
};
|
|
2344
2301
|
return new Promise((resolve, reject) => {
|
|
2345
2302
|
let component;
|
|
2346
2303
|
let overlayHandle;
|
|
2347
2304
|
let closed = false;
|
|
2305
|
+
const restoreEditor = () => {
|
|
2306
|
+
if (component)
|
|
2307
|
+
this.removeExtensionDialog(component);
|
|
2308
|
+
this.editor.setText(savedText);
|
|
2309
|
+
this.ui.requestRender();
|
|
2310
|
+
};
|
|
2348
2311
|
const close = (result) => {
|
|
2349
2312
|
if (closed)
|
|
2350
2313
|
return;
|
|
@@ -2378,19 +2341,15 @@ export class InteractiveMode {
|
|
|
2378
2341
|
return opts;
|
|
2379
2342
|
}
|
|
2380
2343
|
// Fallback: use component's width property if available
|
|
2381
|
-
const w =
|
|
2344
|
+
const w = c.width;
|
|
2382
2345
|
return w ? { width: w } : undefined;
|
|
2383
2346
|
};
|
|
2384
|
-
overlayHandle = this.ui.showOverlay(
|
|
2347
|
+
overlayHandle = this.ui.showOverlay(c, resolveOptions());
|
|
2385
2348
|
// Expose handle to caller for visibility control
|
|
2386
2349
|
options?.onHandle?.(overlayHandle);
|
|
2387
2350
|
}
|
|
2388
2351
|
else {
|
|
2389
|
-
this.
|
|
2390
|
-
this.editorContainer.clear();
|
|
2391
|
-
this.editorContainer.addChild(component);
|
|
2392
|
-
this.ui.setFocus(component);
|
|
2393
|
-
this.ui.requestRender();
|
|
2352
|
+
this.pushExtensionDialog(c);
|
|
2394
2353
|
}
|
|
2395
2354
|
})
|
|
2396
2355
|
.catch((err) => {
|