@astralyn/pi 1.3.1 → 1.4.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 +52 -0
- package/dist/bundle/chunks/anthropic-messages-HWL6AS7T.js +6 -0
- package/dist/bundle/chunks/azure-openai-responses-4YYPDYV5.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +8 -8
- package/dist/bundle/chunks/chunk-24FY4C5S.js +2 -0
- package/dist/bundle/chunks/chunk-6JS2SOFO.js +11 -0
- package/dist/bundle/chunks/chunk-ANCZPKX7.js +2 -0
- package/dist/bundle/chunks/{chunk-VOAXAPU6.js → chunk-KSKBY3VV.js} +161 -91
- package/dist/bundle/chunks/chunk-MMNIHCU7.js +2 -0
- package/dist/bundle/chunks/{chunk-KSCGI7JW.js → chunk-MZJC45TM.js} +2 -2
- package/dist/bundle/chunks/{chunk-LXR54CGB.js → chunk-N77PYEXG.js} +1 -1
- package/dist/bundle/chunks/{chunk-J75WV3FL.js → chunk-OV2VMHBX.js} +1 -1
- package/dist/bundle/chunks/chunk-TPVFPFJP.js +2 -0
- package/dist/bundle/chunks/chunk-ZAIGBRV5.js +16 -0
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-7BKATOEJ.js +2 -0
- package/dist/bundle/chunks/github-copilot.js +1 -1
- package/dist/bundle/chunks/google-generative-ai-HTUSU45F.js +2 -0
- package/dist/bundle/chunks/google-vertex-AVQV4P76.js +2 -0
- package/dist/bundle/chunks/{llama-cpp-classify-H3IZDR5O.js → llama-cpp-classify-27QYLJZY.js} +2 -2
- package/dist/bundle/chunks/{mistral-conversations-6E6SS3WF.js → mistral-conversations-V2JJTMJ5.js} +1 -1
- package/dist/bundle/chunks/openai-codex-responses-Q25MHDFX.js +10 -0
- package/dist/bundle/chunks/openai-completions-TXZXILJR.js +7 -0
- package/dist/bundle/chunks/{openai-decisions-TVCDIPZX.js → openai-decisions-3WYFPGSK.js} +1 -1
- package/dist/bundle/chunks/openai-responses-E4BNZIQK.js +4 -0
- package/dist/bundle/chunks/openrouter-images-CBP3OPOD.js +2 -0
- package/dist/bundle/chunks/pi-messages-LBJQ4NGP.js +8 -0
- package/dist/bundle/chunks/typesafe-system-one-BNICP2LS.js +2 -0
- package/dist/bundle/chunks/virtual-modules-XNEYDLXF.js +2 -0
- package/dist/bundle/cli.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 +7 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +61 -13
- 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 +25 -20
- 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 +9 -10
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/tasks/presentation.d.ts.map +1 -1
- package/dist/core/tasks/presentation.js +3 -1
- package/dist/core/tasks/presentation.js.map +1 -1
- package/dist/core/tasks/reminder.d.ts +15 -0
- package/dist/core/tasks/reminder.d.ts.map +1 -0
- package/dist/core/tasks/reminder.js +54 -0
- package/dist/core/tasks/reminder.js.map +1 -0
- package/dist/core/tasks/runtime.d.ts +4 -1
- package/dist/core/tasks/runtime.d.ts.map +1 -1
- package/dist/core/tasks/runtime.js +37 -11
- package/dist/core/tasks/runtime.js.map +1 -1
- package/dist/core/tasks/session.d.ts +9 -0
- package/dist/core/tasks/session.d.ts.map +1 -1
- package/dist/core/tasks/session.js +24 -0
- package/dist/core/tasks/session.js.map +1 -1
- package/dist/core/tasks/types.d.ts +6 -1
- package/dist/core/tasks/types.d.ts.map +1 -1
- package/dist/core/tasks/types.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/core/tools/shell-tool.js +2 -2
- package/dist/core/tools/shell-tool.js.map +1 -1
- package/dist/core/tools/tasks/actions.d.ts +1 -1
- package/dist/core/tools/tasks/actions.d.ts.map +1 -1
- package/dist/core/tools/tasks/actions.js +98 -5
- package/dist/core/tools/tasks/actions.js.map +1 -1
- package/dist/core/tools/tasks/schema.d.ts +1 -1
- package/dist/core/tools/tasks/schema.d.ts.map +1 -1
- package/dist/core/tools/tasks/schema.js +9 -6
- package/dist/core/tools/tasks/schema.js.map +1 -1
- package/dist/core/tools/tasks/types.d.ts +9 -3
- package/dist/core/tools/tasks/types.d.ts.map +1 -1
- package/dist/core/tools/tasks/types.js.map +1 -1
- package/dist/core/tools/tasks.d.ts +1 -1
- package/dist/core/tools/tasks.d.ts.map +1 -1
- package/dist/core/tools/tasks.js +2 -2
- package/dist/core/tools/tasks.js.map +1 -1
- package/dist/extensions/cached-compaction/index.d.ts +3 -0
- package/dist/extensions/cached-compaction/index.d.ts.map +1 -0
- package/dist/extensions/cached-compaction/index.js +91 -0
- package/dist/extensions/cached-compaction/index.js.map +1 -0
- package/dist/extensions/cached-compaction/render.d.ts +11 -0
- package/dist/extensions/cached-compaction/render.d.ts.map +1 -0
- package/dist/extensions/cached-compaction/render.js +19 -0
- package/dist/extensions/cached-compaction/render.js.map +1 -0
- package/dist/extensions/cached-compaction/summary.d.ts +15 -0
- package/dist/extensions/cached-compaction/summary.d.ts.map +1 -0
- package/dist/extensions/cached-compaction/summary.js +131 -0
- package/dist/extensions/cached-compaction/summary.js.map +1 -0
- 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/index.d.ts.map +1 -1
- package/dist/extensions/index.js +2 -0
- package/dist/extensions/index.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/modes/interactive/tasks/render.d.ts.map +1 -1
- package/dist/modes/interactive/tasks/render.js +17 -9
- package/dist/modes/interactive/tasks/render.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/bundled/extensions/cached-compaction.md +35 -0
- package/docs/bundled/tasks.md +17 -7
- package/docs/codemode.md +2 -2
- package/docs/compaction.md +5 -3
- package/docs/custom-provider.md +53 -1
- package/docs/docs.json +8 -0
- package/docs/environment-variables.md +1 -0
- package/docs/extensions.md +98 -3
- package/docs/models-configuration.md +196 -0
- package/docs/models.md +9 -5
- package/docs/sdk.md +2 -2
- package/docs/session-format.md +2 -2
- package/docs/settings.md +2 -2
- package/docs/tui.md +71 -0
- package/docs/windows.md +28 -0
- 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/npm-shrinkwrap.json +150 -137
- package/package.json +7 -6
- package/schemas/models.schema.json +83 -29
- package/dist/bundle/chunks/anthropic-messages-MSB6JBS2.js +0 -6
- package/dist/bundle/chunks/azure-openai-responses-ATZ757I2.js +0 -2
- package/dist/bundle/chunks/chunk-4XZYHGVN.js +0 -11
- package/dist/bundle/chunks/chunk-7UBIBLPN.js +0 -2
- package/dist/bundle/chunks/chunk-LUYFHZ6W.js +0 -11
- package/dist/bundle/chunks/chunk-NM2KGRFS.js +0 -2
- package/dist/bundle/chunks/chunk-QDDSFJ35.js +0 -2
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-HGOVFZDC.js +0 -2
- package/dist/bundle/chunks/google-generative-ai-QRLQ4MCJ.js +0 -2
- package/dist/bundle/chunks/google-vertex-L3T6EGTL.js +0 -2
- package/dist/bundle/chunks/openai-codex-responses-4GUO76XJ.js +0 -10
- package/dist/bundle/chunks/openai-completions-O4TKZCIM.js +0 -7
- package/dist/bundle/chunks/openai-responses-VBQKJFNO.js +0 -3
- package/dist/bundle/chunks/openrouter-images-TDLJV5N4.js +0 -2
- package/dist/bundle/chunks/pi-messages-3POWZ43C.js +0 -8
- package/dist/bundle/chunks/typesafe-system-one-LWPJYTJP.js +0 -2
- package/dist/bundle/chunks/virtual-modules-CKPHR6LX.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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/extensions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/extensions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAanE,eAAO,MAAM,iBAAiB,EAAE,eAAe,EAY9C,CAAC"}
|
package/dist/extensions/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import btwExtension from "./btw/index.js";
|
|
2
|
+
import cachedCompactionExtension from "./cached-compaction/index.js";
|
|
2
3
|
import codemodeExtension from "./codemode/index.js";
|
|
3
4
|
import deepwikiExtension from "./deepwiki/index.js";
|
|
4
5
|
import llamaExtension from "./llama/index.js";
|
|
@@ -12,6 +13,7 @@ export const builtInExtensions = [
|
|
|
12
13
|
{ name: "codemode", factory: codemodeExtension, replaceable: true, builtin: true },
|
|
13
14
|
{ name: "mcp", factory: mcpExtension, replaceable: true, builtin: true },
|
|
14
15
|
{ name: "tool-search", factory: toolSearchExtension, replaceable: true, builtin: true },
|
|
16
|
+
{ name: "cached-compaction", factory: cachedCompactionExtension, replaceable: true, builtin: true },
|
|
15
17
|
{ name: "llama.cpp", factory: llamaExtension, builtin: true },
|
|
16
18
|
{ name: "btw", factory: btwExtension, builtin: true },
|
|
17
19
|
{ name: "deepwiki", factory: deepwikiExtension, builtin: true },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/extensions/index.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,mBAAmB,MAAM,wBAAwB,CAAC;AAEzD,MAAM,CAAC,MAAM,iBAAiB,GAAsB;IACnD,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;IAClF,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;IACxE,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;IACvF,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE;IAC7D,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE;IACrD,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE;IAC/D,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE;IAC/D,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE;IAC/D,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,IAAI,EAAE;IACnE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE;CAC3D,CAAC","sourcesContent":["import type { InlineExtension } from \"../core/extensions/types.ts\";\nimport btwExtension from \"./btw/index.ts\";\nimport codemodeExtension from \"./codemode/index.ts\";\nimport deepwikiExtension from \"./deepwiki/index.ts\";\nimport llamaExtension from \"./llama/index.ts\";\nimport mcpExtension from \"./mcp/index.ts\";\nimport providerExtension from \"./provider/index.ts\";\nimport questionExtension from \"./question/index.ts\";\nimport searchExtension from \"./search/index.ts\";\nimport statuslineExtension from \"./statusline/index.ts\";\nimport toolSearchExtension from \"./tool-search/index.ts\";\n\nexport const builtInExtensions: InlineExtension[] = [\n\t{ name: \"codemode\", factory: codemodeExtension, replaceable: true, builtin: true },\n\t{ name: \"mcp\", factory: mcpExtension, replaceable: true, builtin: true },\n\t{ name: \"tool-search\", factory: toolSearchExtension, replaceable: true, builtin: true },\n\t{ name: \"llama.cpp\", factory: llamaExtension, builtin: true },\n\t{ name: \"btw\", factory: btwExtension, builtin: true },\n\t{ name: \"deepwiki\", factory: deepwikiExtension, builtin: true },\n\t{ name: \"provider\", factory: providerExtension, builtin: true },\n\t{ name: \"question\", factory: questionExtension, builtin: true },\n\t{ name: \"statusline\", factory: statuslineExtension, builtin: true },\n\t{ name: \"search\", factory: searchExtension, builtin: true },\n];\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/extensions/index.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,yBAAyB,MAAM,8BAA8B,CAAC;AACrE,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,mBAAmB,MAAM,wBAAwB,CAAC;AAEzD,MAAM,CAAC,MAAM,iBAAiB,GAAsB;IACnD,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;IAClF,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;IACxE,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;IACvF,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;IACnG,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE;IAC7D,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE;IACrD,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE;IAC/D,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE;IAC/D,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE;IAC/D,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,IAAI,EAAE;IACnE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE;CAC3D,CAAC","sourcesContent":["import type { InlineExtension } from \"../core/extensions/types.ts\";\nimport btwExtension from \"./btw/index.ts\";\nimport cachedCompactionExtension from \"./cached-compaction/index.ts\";\nimport codemodeExtension from \"./codemode/index.ts\";\nimport deepwikiExtension from \"./deepwiki/index.ts\";\nimport llamaExtension from \"./llama/index.ts\";\nimport mcpExtension from \"./mcp/index.ts\";\nimport providerExtension from \"./provider/index.ts\";\nimport questionExtension from \"./question/index.ts\";\nimport searchExtension from \"./search/index.ts\";\nimport statuslineExtension from \"./statusline/index.ts\";\nimport toolSearchExtension from \"./tool-search/index.ts\";\n\nexport const builtInExtensions: InlineExtension[] = [\n\t{ name: \"codemode\", factory: codemodeExtension, replaceable: true, builtin: true },\n\t{ name: \"mcp\", factory: mcpExtension, replaceable: true, builtin: true },\n\t{ name: \"tool-search\", factory: toolSearchExtension, replaceable: true, builtin: true },\n\t{ name: \"cached-compaction\", factory: cachedCompactionExtension, replaceable: true, builtin: true },\n\t{ name: \"llama.cpp\", factory: llamaExtension, builtin: true },\n\t{ name: \"btw\", factory: btwExtension, builtin: true },\n\t{ name: \"deepwiki\", factory: deepwikiExtension, builtin: true },\n\t{ name: \"provider\", factory: providerExtension, builtin: true },\n\t{ name: \"question\", factory: questionExtension, builtin: true },\n\t{ name: \"statusline\", factory: statuslineExtension, builtin: true },\n\t{ name: \"search\", factory: searchExtension, builtin: true },\n];\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/extensions/mcp/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAKH,OAAO,EACN,KAAK,WAAW,EAChB,KAAK,eAAe,EAGpB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/extensions/mcp/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAKH,OAAO,EACN,KAAK,WAAW,EAChB,KAAK,eAAe,EAGpB,MAAM,2BAA2B,CAAC;AAGnC,YAAY,EACX,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,oBAAoB,GACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,eAAe,CAAC;IACxB,2FAA2F;IAC3F,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAC;IAC3C,4GAA4G;IAC5G,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC/B,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,iFAAiF;IACjF,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,gGAAgG;IAChG,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB;AAqED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,OAAO,CAAA;CAAE,GAAG,eAAe,CAWlH;AAED,+GAA+G;AAC/G,MAAM,WAAW,oBAAoB;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,WAAW,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,oBAAoB,EAC3B,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,GAClC,IAAI,CAmBN;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAU/F;AAED,0FAA0F;AAC1F,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAUzE"}
|
|
@@ -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;AAC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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,G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AAM,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\";\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"]}
|
|
@@ -107,9 +107,7 @@ export declare class InteractiveMode {
|
|
|
107
107
|
/** The `/bug` hint is shown at most once per session so error output stays readable. */
|
|
108
108
|
private bugReportHintShown;
|
|
109
109
|
private installChangeWarningShown;
|
|
110
|
-
private
|
|
111
|
-
private extensionInput;
|
|
112
|
-
private extensionEditor;
|
|
110
|
+
private extensionDialogs;
|
|
113
111
|
private extensionTerminalInputSubscriptions;
|
|
114
112
|
private extensionWidgetsAbove;
|
|
115
113
|
private extensionWidgetsBelow;
|
|
@@ -259,13 +257,19 @@ export declare class InteractiveMode {
|
|
|
259
257
|
private createProjectTrustContext;
|
|
260
258
|
private createExtensionUIContext;
|
|
261
259
|
/**
|
|
262
|
-
* Show
|
|
260
|
+
* Show an extension dialog in the editor slot.
|
|
261
|
+
* Dialogs form a stack: a new dialog hides the visible one, and closing the visible dialog shows
|
|
262
|
+
* the previous one again. Every dialog stays answerable, so no dialog promise is left pending,
|
|
263
|
+
* and dialogs opened from inside another dialog (for example a confirm from a custom component) work.
|
|
263
264
|
*/
|
|
264
|
-
private
|
|
265
|
+
private pushExtensionDialog;
|
|
266
|
+
/** Remove an extension dialog. If it was visible, show the previous dialog or the editor. */
|
|
267
|
+
private removeExtensionDialog;
|
|
268
|
+
private showTopExtensionDialog;
|
|
265
269
|
/**
|
|
266
|
-
*
|
|
270
|
+
* Show a selector for extensions.
|
|
267
271
|
*/
|
|
268
|
-
private
|
|
272
|
+
private showExtensionSelector;
|
|
269
273
|
/**
|
|
270
274
|
* Show a confirmation dialog for extensions.
|
|
271
275
|
*/
|
|
@@ -275,18 +279,10 @@ export declare class InteractiveMode {
|
|
|
275
279
|
* Show a text input for extensions.
|
|
276
280
|
*/
|
|
277
281
|
private showExtensionInput;
|
|
278
|
-
/**
|
|
279
|
-
* Hide the extension input.
|
|
280
|
-
*/
|
|
281
|
-
private hideExtensionInput;
|
|
282
282
|
/**
|
|
283
283
|
* Show a multi-line editor for extensions (with Ctrl+G support).
|
|
284
284
|
*/
|
|
285
285
|
private showExtensionEditor;
|
|
286
|
-
/**
|
|
287
|
-
* Hide the extension editor.
|
|
288
|
-
*/
|
|
289
|
-
private hideExtensionEditor;
|
|
290
286
|
/**
|
|
291
287
|
* Set a custom editor component from an extension.
|
|
292
288
|
* 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,OAAO,EAEN,KAAK,YAAY,EAKjB,MAAM,8BAA8B,CAAC;AActC,OAAO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AAiB;IAyBzB,OAAO,CAAC,iBAAiB;IAoCzB,OAAO,CAAC,kBAAkB;IA0H1B,OAAO,CAAC,uBAAuB;YAsCjB,kBAAkB;IAqBhC,OAAO,CAAC,gBAAgB;IA+JxB,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;YA4FnB,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;YAwHd,kBAAkB;IAehC,OAAO,CAAC,kBAAkB;IAiC1B,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,oBAAoB;YAMd,iBAAiB;YA6FjB,oBAAoB;IAUlC,IAAI,CAAC,oBAAoB,uBAAiD,GAAG,IAAI;CAsBjF"}
|
|
@@ -317,9 +317,9 @@ export class InteractiveMode {
|
|
|
317
317
|
this.bugReportHintShown = false;
|
|
318
318
|
this.installChangeWarningShown = false;
|
|
319
319
|
// Extension UI state
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
this.
|
|
320
|
+
// Extension dialogs shown in the editor slot (select, confirm, input, editor, inline custom).
|
|
321
|
+
// The last entry is visible; see pushExtensionDialog().
|
|
322
|
+
this.extensionDialogs = [];
|
|
323
323
|
this.extensionTerminalInputSubscriptions = new Set();
|
|
324
324
|
// Extension widgets (components rendered above/below the editor)
|
|
325
325
|
this.extensionWidgetsAbove = new Map();
|
|
@@ -1848,14 +1848,12 @@ export class InteractiveMode {
|
|
|
1848
1848
|
}
|
|
1849
1849
|
resetExtensionUI() {
|
|
1850
1850
|
this.editorHost.clear();
|
|
1851
|
-
if (this.
|
|
1852
|
-
this.
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
this.
|
|
1856
|
-
|
|
1857
|
-
if (this.extensionEditor) {
|
|
1858
|
-
this.hideExtensionEditor();
|
|
1851
|
+
if (this.extensionDialogs.length > 0) {
|
|
1852
|
+
for (const dialog of this.extensionDialogs) {
|
|
1853
|
+
dialog.component.dispose?.();
|
|
1854
|
+
}
|
|
1855
|
+
this.extensionDialogs = [];
|
|
1856
|
+
this.showTopExtensionDialog();
|
|
1859
1857
|
}
|
|
1860
1858
|
this.ui.hideOverlay();
|
|
1861
1859
|
this.clearExtensionTerminalInputListeners();
|
|
@@ -2056,6 +2054,35 @@ export class InteractiveMode {
|
|
|
2056
2054
|
setToolsExpanded: (expanded) => this.setToolsExpanded(expanded),
|
|
2057
2055
|
};
|
|
2058
2056
|
}
|
|
2057
|
+
/**
|
|
2058
|
+
* Show an extension dialog in the editor slot.
|
|
2059
|
+
* Dialogs form a stack: a new dialog hides the visible one, and closing the visible dialog shows
|
|
2060
|
+
* the previous one again. Every dialog stays answerable, so no dialog promise is left pending,
|
|
2061
|
+
* and dialogs opened from inside another dialog (for example a confirm from a custom component) work.
|
|
2062
|
+
*/
|
|
2063
|
+
pushExtensionDialog(component, blocked) {
|
|
2064
|
+
this.disposeActiveSelector();
|
|
2065
|
+
this.extensionDialogs.push({ component, blocked });
|
|
2066
|
+
this.showTopExtensionDialog();
|
|
2067
|
+
}
|
|
2068
|
+
/** Remove an extension dialog. If it was visible, show the previous dialog or the editor. */
|
|
2069
|
+
removeExtensionDialog(component) {
|
|
2070
|
+
const index = this.extensionDialogs.findIndex((dialog) => dialog.component === component);
|
|
2071
|
+
if (index === -1)
|
|
2072
|
+
return;
|
|
2073
|
+
this.extensionDialogs.splice(index, 1);
|
|
2074
|
+
if (index === this.extensionDialogs.length)
|
|
2075
|
+
this.showTopExtensionDialog();
|
|
2076
|
+
}
|
|
2077
|
+
showTopExtensionDialog() {
|
|
2078
|
+
const top = this.extensionDialogs.at(-1);
|
|
2079
|
+
const component = top?.component ?? this.editor;
|
|
2080
|
+
this.editorContainer.clear();
|
|
2081
|
+
this.editorContainer.addChild(component);
|
|
2082
|
+
this.ui.setFocus(component);
|
|
2083
|
+
this.programStatus.setBlocked("extension-dialog", top?.blocked);
|
|
2084
|
+
this.ui.requestRender();
|
|
2085
|
+
}
|
|
2059
2086
|
/**
|
|
2060
2087
|
* Show a selector for extensions.
|
|
2061
2088
|
*/
|
|
@@ -2065,46 +2092,23 @@ export class InteractiveMode {
|
|
|
2065
2092
|
resolve(undefined);
|
|
2066
2093
|
return;
|
|
2067
2094
|
}
|
|
2068
|
-
const
|
|
2069
|
-
this.hideExtensionSelector();
|
|
2070
|
-
resolve(undefined);
|
|
2071
|
-
};
|
|
2072
|
-
opts?.signal?.addEventListener("abort", onAbort, { once: true });
|
|
2073
|
-
this.extensionSelector = new ExtensionSelectorComponent(title, options, (option) => {
|
|
2095
|
+
const finish = (option) => {
|
|
2074
2096
|
opts?.signal?.removeEventListener("abort", onAbort);
|
|
2075
|
-
|
|
2097
|
+
selector.dispose();
|
|
2098
|
+
this.removeExtensionDialog(selector);
|
|
2076
2099
|
resolve(option);
|
|
2077
|
-
}
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
}, {
|
|
2100
|
+
};
|
|
2101
|
+
const onAbort = () => finish(undefined);
|
|
2102
|
+
opts?.signal?.addEventListener("abort", onAbort, { once: true });
|
|
2103
|
+
const selector = new ExtensionSelectorComponent(title, options, (option) => finish(option), () => finish(undefined), {
|
|
2082
2104
|
tui: this.ui,
|
|
2083
2105
|
timeout: opts?.timeout,
|
|
2084
2106
|
description: opts?.description,
|
|
2085
2107
|
onToggleToolsExpanded: () => this.toggleToolOutputExpansion(),
|
|
2086
2108
|
});
|
|
2087
|
-
this.
|
|
2088
|
-
this.editorContainer.clear();
|
|
2089
|
-
this.editorContainer.addChild(this.extensionSelector);
|
|
2090
|
-
this.ui.setFocus(this.extensionSelector);
|
|
2091
|
-
// Extension dialogs share the editor slot: opening one replaces the status of a displaced one.
|
|
2092
|
-
this.programStatus.setBlocked("extension-dialog", blocked);
|
|
2093
|
-
this.ui.requestRender();
|
|
2109
|
+
this.pushExtensionDialog(selector, blocked);
|
|
2094
2110
|
});
|
|
2095
2111
|
}
|
|
2096
|
-
/**
|
|
2097
|
-
* Hide the extension selector.
|
|
2098
|
-
*/
|
|
2099
|
-
hideExtensionSelector() {
|
|
2100
|
-
this.extensionSelector?.dispose();
|
|
2101
|
-
this.editorContainer.clear();
|
|
2102
|
-
this.editorContainer.addChild(this.editor);
|
|
2103
|
-
this.extensionSelector = undefined;
|
|
2104
|
-
this.programStatus.setBlocked("extension-dialog", undefined);
|
|
2105
|
-
this.ui.setFocus(this.editor);
|
|
2106
|
-
this.ui.requestRender();
|
|
2107
|
-
}
|
|
2108
2112
|
/**
|
|
2109
2113
|
* Show a confirmation dialog for extensions.
|
|
2110
2114
|
*/
|
|
@@ -2127,71 +2131,31 @@ export class InteractiveMode {
|
|
|
2127
2131
|
resolve(undefined);
|
|
2128
2132
|
return;
|
|
2129
2133
|
}
|
|
2130
|
-
const
|
|
2131
|
-
this.hideExtensionInput();
|
|
2132
|
-
resolve(undefined);
|
|
2133
|
-
};
|
|
2134
|
-
opts?.signal?.addEventListener("abort", onAbort, { once: true });
|
|
2135
|
-
this.extensionInput = new ExtensionInputComponent(title, placeholder, (value) => {
|
|
2134
|
+
const finish = (value) => {
|
|
2136
2135
|
opts?.signal?.removeEventListener("abort", onAbort);
|
|
2137
|
-
|
|
2136
|
+
input.dispose();
|
|
2137
|
+
this.removeExtensionDialog(input);
|
|
2138
2138
|
resolve(value);
|
|
2139
|
-
}
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
this.disposeActiveSelector();
|
|
2145
|
-
this.editorContainer.clear();
|
|
2146
|
-
this.editorContainer.addChild(this.extensionInput);
|
|
2147
|
-
this.ui.setFocus(this.extensionInput);
|
|
2148
|
-
this.programStatus.setBlocked("extension-dialog", { kind: "question", message: title });
|
|
2149
|
-
this.ui.requestRender();
|
|
2139
|
+
};
|
|
2140
|
+
const onAbort = () => finish(undefined);
|
|
2141
|
+
opts?.signal?.addEventListener("abort", onAbort, { once: true });
|
|
2142
|
+
const input = new ExtensionInputComponent(title, placeholder, (value) => finish(value), () => finish(undefined), { tui: this.ui, timeout: opts?.timeout });
|
|
2143
|
+
this.pushExtensionDialog(input, { kind: "question", message: title });
|
|
2150
2144
|
});
|
|
2151
2145
|
}
|
|
2152
|
-
/**
|
|
2153
|
-
* Hide the extension input.
|
|
2154
|
-
*/
|
|
2155
|
-
hideExtensionInput() {
|
|
2156
|
-
this.extensionInput?.dispose();
|
|
2157
|
-
this.editorContainer.clear();
|
|
2158
|
-
this.editorContainer.addChild(this.editor);
|
|
2159
|
-
this.extensionInput = undefined;
|
|
2160
|
-
this.programStatus.setBlocked("extension-dialog", undefined);
|
|
2161
|
-
this.ui.setFocus(this.editor);
|
|
2162
|
-
this.ui.requestRender();
|
|
2163
|
-
}
|
|
2164
2146
|
/**
|
|
2165
2147
|
* Show a multi-line editor for extensions (with Ctrl+G support).
|
|
2166
2148
|
*/
|
|
2167
2149
|
showExtensionEditor(title, prefill) {
|
|
2168
2150
|
return new Promise((resolve) => {
|
|
2169
|
-
|
|
2170
|
-
this.
|
|
2151
|
+
const finish = (value) => {
|
|
2152
|
+
this.removeExtensionDialog(editor);
|
|
2171
2153
|
resolve(value);
|
|
2172
|
-
}
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
}, undefined, this.settingsManager.getExternalEditorCommand());
|
|
2176
|
-
this.disposeActiveSelector();
|
|
2177
|
-
this.editorContainer.clear();
|
|
2178
|
-
this.editorContainer.addChild(this.extensionEditor);
|
|
2179
|
-
this.ui.setFocus(this.extensionEditor);
|
|
2180
|
-
this.programStatus.setBlocked("extension-dialog", { kind: "question", message: title });
|
|
2181
|
-
this.ui.requestRender();
|
|
2154
|
+
};
|
|
2155
|
+
const editor = new ExtensionEditorComponent(this.ui, this.keybindings, title, prefill, (value) => finish(value), () => finish(undefined), undefined, this.settingsManager.getExternalEditorCommand());
|
|
2156
|
+
this.pushExtensionDialog(editor, { kind: "question", message: title });
|
|
2182
2157
|
});
|
|
2183
2158
|
}
|
|
2184
|
-
/**
|
|
2185
|
-
* Hide the extension editor.
|
|
2186
|
-
*/
|
|
2187
|
-
hideExtensionEditor() {
|
|
2188
|
-
this.editorContainer.clear();
|
|
2189
|
-
this.editorContainer.addChild(this.editor);
|
|
2190
|
-
this.extensionEditor = undefined;
|
|
2191
|
-
this.programStatus.setBlocked("extension-dialog", undefined);
|
|
2192
|
-
this.ui.setFocus(this.editor);
|
|
2193
|
-
this.ui.requestRender();
|
|
2194
|
-
}
|
|
2195
2159
|
/**
|
|
2196
2160
|
* Set a custom editor component from an extension.
|
|
2197
2161
|
* Pass undefined to restore the default editor.
|
|
@@ -2281,17 +2245,16 @@ export class InteractiveMode {
|
|
|
2281
2245
|
async showExtensionCustom(factory, options) {
|
|
2282
2246
|
const savedText = this.editor.getText();
|
|
2283
2247
|
const isOverlay = options?.overlay ?? false;
|
|
2284
|
-
const restoreEditor = () => {
|
|
2285
|
-
this.editorContainer.clear();
|
|
2286
|
-
this.editorContainer.addChild(this.editor);
|
|
2287
|
-
this.editor.setText(savedText);
|
|
2288
|
-
this.ui.setFocus(this.editor);
|
|
2289
|
-
this.ui.requestRender();
|
|
2290
|
-
};
|
|
2291
2248
|
return new Promise((resolve, reject) => {
|
|
2292
2249
|
let component;
|
|
2293
2250
|
let overlayHandle;
|
|
2294
2251
|
let closed = false;
|
|
2252
|
+
const restoreEditor = () => {
|
|
2253
|
+
if (component)
|
|
2254
|
+
this.removeExtensionDialog(component);
|
|
2255
|
+
this.editor.setText(savedText);
|
|
2256
|
+
this.ui.requestRender();
|
|
2257
|
+
};
|
|
2295
2258
|
const close = (result) => {
|
|
2296
2259
|
if (closed)
|
|
2297
2260
|
return;
|
|
@@ -2325,19 +2288,15 @@ export class InteractiveMode {
|
|
|
2325
2288
|
return opts;
|
|
2326
2289
|
}
|
|
2327
2290
|
// Fallback: use component's width property if available
|
|
2328
|
-
const w =
|
|
2291
|
+
const w = c.width;
|
|
2329
2292
|
return w ? { width: w } : undefined;
|
|
2330
2293
|
};
|
|
2331
|
-
overlayHandle = this.ui.showOverlay(
|
|
2294
|
+
overlayHandle = this.ui.showOverlay(c, resolveOptions());
|
|
2332
2295
|
// Expose handle to caller for visibility control
|
|
2333
2296
|
options?.onHandle?.(overlayHandle);
|
|
2334
2297
|
}
|
|
2335
2298
|
else {
|
|
2336
|
-
this.
|
|
2337
|
-
this.editorContainer.clear();
|
|
2338
|
-
this.editorContainer.addChild(component);
|
|
2339
|
-
this.ui.setFocus(component);
|
|
2340
|
-
this.ui.requestRender();
|
|
2299
|
+
this.pushExtensionDialog(c);
|
|
2341
2300
|
}
|
|
2342
2301
|
})
|
|
2343
2302
|
.catch((err) => {
|