@ai-agent-forge/agent-forge 0.88.1 → 0.88.3
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 +71 -0
- package/README.md +1 -1
- package/bundled-plugins/agent-loop-policy/agent-forge.json +1 -1
- package/bundled-plugins/agent-loop-policy/plugin.json +1 -1
- package/bundled-plugins/coding-tools/agent-forge.json +1 -1
- package/bundled-plugins/coding-tools/plugin.json +1 -1
- package/bundled-plugins/compaction-policy/agent-forge.json +1 -1
- package/bundled-plugins/compaction-policy/plugin.json +1 -1
- package/bundled-plugins/overflow-policy/agent-forge.json +1 -1
- package/bundled-plugins/overflow-policy/plugin.json +1 -1
- package/bundled-plugins/provider-failover/agent-forge.json +1 -1
- package/bundled-plugins/provider-failover/plugin.json +1 -1
- package/bundled-plugins/retry-policy/agent-forge.json +1 -1
- package/bundled-plugins/retry-policy/plugin.json +1 -1
- package/dist/artifacts/paged-read.d.ts +6 -1
- package/dist/artifacts/paged-read.d.ts.map +1 -1
- package/dist/artifacts/paged-read.js.map +1 -1
- package/dist/bundle/.build-manifest.json +283 -263
- package/dist/bundle/chunks/{anthropic-messages-PLAKXR73.js → anthropic-messages-3FJHRAJL.js} +2 -2
- package/dist/bundle/chunks/anthropic.js +1 -1
- package/dist/bundle/chunks/{azure-openai-responses-OUWQ2AZD.js → azure-openai-responses-GCL47IDS.js} +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
- package/dist/bundle/chunks/{chunk-Z72JWUZ4.js → chunk-32YDZI4J.js} +1 -1
- package/dist/bundle/chunks/{chunk-AQLNTW2B.js → chunk-755VNWIF.js} +17 -16
- package/dist/bundle/chunks/{chunk-LZOEQITZ.js → chunk-B42Y2VME.js} +120 -104
- package/dist/bundle/chunks/{chunk-DRQDKNXA.js → chunk-BVVSHK6W.js} +1 -1
- package/dist/bundle/chunks/{chunk-6R7UI4IY.js → chunk-QDLOMKF6.js} +1 -1
- package/dist/bundle/chunks/{chunk-D3ARGZFR.js → chunk-V3ACW7VD.js} +3 -3
- package/dist/bundle/chunks/{google-generative-ai-DLII6DAT.js → google-generative-ai-6BMXWA44.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-G7BZL7GM.js → google-vertex-6H7NLRTK.js} +1 -1
- package/dist/bundle/chunks/image-resize-worker.js +3 -3
- package/dist/bundle/chunks/{mistral-conversations-JXUK24ID.js → mistral-conversations-IXUHSFSJ.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-5GSGFIPG.js → openai-codex-responses-YHUAEVCM.js} +1 -1
- package/dist/bundle/chunks/openai-codex.js +1 -1
- package/dist/bundle/chunks/{openai-completions-EI2I6DTG.js → openai-completions-ULQCFC72.js} +1 -1
- package/dist/bundle/chunks/openai-responses-NLLAJDPS.js +2 -0
- package/dist/bundle/chunks/{openrouter-images-G4GQRUSG.js → openrouter-images-GZZQZXMS.js} +1 -1
- package/dist/bundle/chunks/openrouter.js +1 -1
- package/dist/bundle/chunks/{pi-messages-PWU2VJMR.js → pi-messages-EJTI2EJ3.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-TQWEGNNZ.js +5 -0
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/client.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.d.ts +0 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +1 -4
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/experimental/cli.d.ts +3 -3
- package/dist/cli/experimental/cli.d.ts.map +1 -1
- package/dist/cli/experimental/cli.js +2 -2
- package/dist/cli/experimental/cli.js.map +1 -1
- package/dist/cli/experimental/commands/agent-forge.d.ts +15 -0
- package/dist/cli/experimental/commands/agent-forge.d.ts.map +1 -0
- package/dist/cli/experimental/commands/{pi.js → agent-forge.js} +4 -4
- package/dist/cli/experimental/commands/agent-forge.js.map +1 -0
- package/dist/cli/plugin-command.d.ts.map +1 -1
- package/dist/cli/plugin-command.js +8 -2
- package/dist/cli/plugin-command.js.map +1 -1
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +1 -1
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/config.d.ts +4 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +7 -7
- package/dist/config.js.map +1 -1
- package/dist/core/agent-forge-manifest.d.ts +7 -0
- package/dist/core/agent-forge-manifest.d.ts.map +1 -0
- package/dist/core/{pi-manifest.js → agent-forge-manifest.js} +4 -4
- package/dist/core/agent-forge-manifest.js.map +1 -0
- package/dist/core/agent-session-compaction.d.ts +1 -1
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +3 -3
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-internal.d.ts +2 -0
- package/dist/core/agent-session-internal.d.ts.map +1 -1
- package/dist/core/agent-session-internal.js.map +1 -1
- package/dist/core/agent-session-lifecycle.d.ts.map +1 -1
- package/dist/core/agent-session-lifecycle.js +12 -1
- package/dist/core/agent-session-lifecycle.js.map +1 -1
- package/dist/core/agent-session-projection.d.ts.map +1 -1
- package/dist/core/agent-session-projection.js +3 -3
- package/dist/core/agent-session-projection.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +3 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +2 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-store.d.ts.map +1 -1
- package/dist/core/agent-session-store.js +6 -1
- package/dist/core/agent-session-store.js.map +1 -1
- package/dist/core/agent-session-tools.d.ts.map +1 -1
- package/dist/core/agent-session-tools.js +13 -0
- package/dist/core/agent-session-tools.js.map +1 -1
- package/dist/core/agent-session.d.ts +24 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +58 -4
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +1 -1
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/experimental.d.ts.map +1 -1
- package/dist/core/experimental.js +1 -3
- package/dist/core/experimental.js.map +1 -1
- package/dist/core/extensions/capability-runtime-store.d.ts +20 -1
- package/dist/core/extensions/capability-runtime-store.d.ts.map +1 -1
- package/dist/core/extensions/capability-runtime-store.js +67 -0
- package/dist/core/extensions/capability-runtime-store.js.map +1 -1
- package/dist/core/extensions/capability-runtime-types.d.ts +14 -0
- package/dist/core/extensions/capability-runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/capability-runtime-types.js +7 -1
- package/dist/core/extensions/capability-runtime-types.js.map +1 -1
- package/dist/core/extensions/capability-runtime.d.ts.map +1 -1
- package/dist/core/extensions/capability-runtime.js +144 -42
- package/dist/core/extensions/capability-runtime.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/virtual-modules.js +6 -1
- package/dist/core/extensions/virtual-modules.js.map +1 -1
- package/dist/core/facade/coding-agent-facade.d.ts +1 -1
- package/dist/core/facade/coding-agent-facade.d.ts.map +1 -1
- package/dist/core/facade/coding-agent-facade.js +1 -1
- package/dist/core/facade/coding-agent-facade.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/cli.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/cli.js +2 -0
- package/dist/core/i18n/locales/zh-cn/cli.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-final.d.ts +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-final.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-final.js +3 -3
- package/dist/core/i18n/locales/zh-cn/core-contract-final.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-plugins.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-plugins.js +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-plugins.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-errors.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-errors.js +1 -1
- package/dist/core/i18n/locales/zh-cn/core-errors.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/index.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/index.js +2 -0
- package/dist/core/i18n/locales/zh-cn/index.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/interactive-mode.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/interactive-mode.js +5 -0
- package/dist/core/i18n/locales/zh-cn/interactive-mode.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/session-cleanup.d.ts +7 -0
- package/dist/core/i18n/locales/zh-cn/session-cleanup.d.ts.map +1 -0
- package/dist/core/i18n/locales/zh-cn/session-cleanup.js +15 -0
- package/dist/core/i18n/locales/zh-cn/session-cleanup.js.map +1 -0
- package/dist/core/i18n/locales/zh-cn/slash-commands.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/slash-commands.js +1 -0
- package/dist/core/i18n/locales/zh-cn/slash-commands.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/tui-components-misc.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/tui-components-misc.js +2 -0
- package/dist/core/i18n/locales/zh-cn/tui-components-misc.js.map +1 -1
- package/dist/core/model-resolver.d.ts +2 -0
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +4 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/package-resource-collection.d.ts.map +1 -1
- package/dist/core/package-resource-collection.js +5 -5
- package/dist/core/package-resource-collection.js.map +1 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +3 -3
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +1 -1
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +30 -8
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-cleanup.d.ts +49 -0
- package/dist/core/session-cleanup.d.ts.map +1 -0
- package/dist/core/session-cleanup.js +159 -0
- package/dist/core/session-cleanup.js.map +1 -0
- package/dist/core/session-index.d.ts +75 -0
- package/dist/core/session-index.d.ts.map +1 -0
- package/dist/core/session-index.js +455 -0
- package/dist/core/session-index.js.map +1 -0
- package/dist/core/session-manager.d.ts +9 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +206 -51
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +5 -10
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +5 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +12 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/timings.js +1 -3
- package/dist/core/timings.js.map +1 -1
- package/dist/core/tools/capability-mount.d.ts +40 -0
- package/dist/core/tools/capability-mount.d.ts.map +1 -0
- package/dist/core/tools/capability-mount.js +112 -0
- package/dist/core/tools/capability-mount.js.map +1 -0
- package/dist/core/tools/render-utils.d.ts +1 -1
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/tool-definition.d.ts +1 -1
- package/dist/core/tools/tool-definition.d.ts.map +1 -1
- package/dist/core/tools/tool-definition.js.map +1 -1
- package/dist/core/trace-retention.d.ts +16 -1
- package/dist/core/trace-retention.d.ts.map +1 -1
- package/dist/core/trace-retention.js +43 -20
- package/dist/core/trace-retention.js.map +1 -1
- package/dist/export-html/ansi-to-html.d.ts.map +1 -0
- package/dist/export-html/ansi-to-html.js.map +1 -0
- package/dist/{core/export-html → export-html}/index.d.ts +1 -1
- package/dist/export-html/index.d.ts.map +1 -0
- package/dist/{core/export-html → export-html}/index.js +5 -5
- package/dist/export-html/index.js.map +1 -0
- package/dist/{core/export-html → export-html}/tool-renderer.d.ts +2 -2
- package/dist/export-html/tool-renderer.d.ts.map +1 -0
- package/dist/export-html/tool-renderer.js.map +1 -0
- package/dist/{modes/interactive → host}/model-catalog-refresh.d.ts +1 -1
- package/dist/host/model-catalog-refresh.d.ts.map +1 -0
- package/dist/{modes/interactive → host}/model-catalog-refresh.js +1 -1
- package/dist/host/model-catalog-refresh.js.map +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +26 -14
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/agents-view.d.ts.map +1 -1
- package/dist/modes/interactive/components/agents-view.js +1 -1
- package/dist/modes/interactive/components/agents-view.js.map +1 -1
- package/dist/modes/interactive/components/armin.d.ts.map +1 -1
- package/dist/modes/interactive/components/armin.js +1 -1
- package/dist/modes/interactive/components/armin.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +6 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +108 -27
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +1 -1
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +1 -1
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-entry.js +1 -1
- package/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +1 -1
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
- package/dist/modes/interactive/components/daxnuts.js +1 -1
- package/dist/modes/interactive/components/daxnuts.js.map +1 -1
- package/dist/modes/interactive/components/dialog-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/dialog-editor.js +1 -1
- package/dist/modes/interactive/components/dialog-editor.js.map +1 -1
- package/dist/modes/interactive/components/dialog-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/dialog-input.js +1 -1
- package/dist/modes/interactive/components/dialog-input.js.map +1 -1
- package/dist/modes/interactive/components/dialog-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/dialog-selector.js +1 -1
- package/dist/modes/interactive/components/dialog-selector.js.map +1 -1
- package/dist/modes/interactive/components/diff.d.ts.map +1 -1
- package/dist/modes/interactive/components/diff.js +1 -1
- package/dist/modes/interactive/components/diff.js.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js +1 -1
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.js +1 -1
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +1 -1
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/mermaid.d.ts +1 -1
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
- package/dist/modes/interactive/components/mermaid.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +2 -2
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +1 -1
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/plugin-manager-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/plugin-manager-entry.js +1 -1
- package/dist/modes/interactive/components/plugin-manager-entry.js.map +1 -1
- package/dist/modes/interactive/components/plugin-selection-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/plugin-selection-entry.js +1 -1
- package/dist/modes/interactive/components/plugin-selection-entry.js.map +1 -1
- package/dist/modes/interactive/components/queue-manager-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/queue-manager-selector.js +1 -1
- package/dist/modes/interactive/components/queue-manager-selector.js.map +1 -1
- package/dist/modes/interactive/components/render-types.d.ts +1 -1
- package/dist/modes/interactive/components/render-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/render-types.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.js +5 -1
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +11 -2
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +1 -1
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.js +1 -1
- package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.js +1 -1
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +1 -1
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/theme-selector.js +1 -1
- package/dist/modes/interactive/components/theme-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +1 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +19 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +139 -4
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-run-group.d.ts +44 -0
- package/dist/modes/interactive/components/tool-run-group.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-run-group.js +121 -0
- package/dist/modes/interactive/components/tool-run-group.js.map +1 -0
- package/dist/modes/interactive/components/tree-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-list.js +1 -1
- package/dist/modes/interactive/components/tree-list.js.map +1 -1
- package/dist/modes/interactive/components/tree-render.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-render.js +1 -1
- package/dist/modes/interactive/components/tree-render.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +1 -1
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +1 -1
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +1 -1
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/components/workflow-view.d.ts.map +1 -1
- package/dist/modes/interactive/components/workflow-view.js +1 -1
- package/dist/modes/interactive/components/workflow-view.js.map +1 -1
- package/dist/modes/interactive/interactive-auth.d.ts +1 -1
- package/dist/modes/interactive/interactive-auth.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-auth.js +1 -1
- package/dist/modes/interactive/interactive-auth.js.map +1 -1
- package/dist/modes/interactive/interactive-commands.d.ts +125 -6
- package/dist/modes/interactive/interactive-commands.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-commands.js +698 -4
- package/dist/modes/interactive/interactive-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-events.d.ts +174 -0
- package/dist/modes/interactive/interactive-events.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-events.js +704 -0
- package/dist/modes/interactive/interactive-events.js.map +1 -0
- package/dist/modes/interactive/interactive-format.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-format.js +1 -1
- package/dist/modes/interactive/interactive-format.js.map +1 -1
- package/dist/modes/interactive/interactive-lifecycle.d.ts +94 -0
- package/dist/modes/interactive/interactive-lifecycle.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-lifecycle.js +177 -0
- package/dist/modes/interactive/interactive-lifecycle.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +254 -129
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +275 -2101
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/interactive-queues.d.ts +96 -0
- package/dist/modes/interactive/interactive-queues.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-queues.js +183 -0
- package/dist/modes/interactive/interactive-queues.js.map +1 -0
- package/dist/modes/interactive/interactive-selectors.d.ts +95 -5
- package/dist/modes/interactive/interactive-selectors.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-selectors.js +517 -6
- package/dist/modes/interactive/interactive-selectors.js.map +1 -1
- package/dist/modes/interactive/startup-services.d.ts +31 -0
- package/dist/modes/interactive/startup-services.d.ts.map +1 -0
- package/dist/modes/interactive/startup-services.js +123 -0
- package/dist/modes/interactive/startup-services.js.map +1 -0
- package/dist/modes/memory-preheat.d.ts +11 -0
- package/dist/modes/memory-preheat.d.ts.map +1 -0
- package/dist/modes/memory-preheat.js +20 -0
- package/dist/modes/memory-preheat.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +3 -1
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/plugins/ecosystem/cli.d.ts.map +1 -1
- package/dist/plugins/ecosystem/cli.js +6 -3
- package/dist/plugins/ecosystem/cli.js.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts +7 -1
- package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-bootstrap.js +50 -3
- package/dist/plugins/ecosystem/node-plugin-bootstrap.js.map +1 -1
- package/dist/plugins/ecosystem/plugin-bootstrap.d.ts +28 -16
- package/dist/plugins/ecosystem/plugin-bootstrap.d.ts.map +1 -1
- package/dist/plugins/ecosystem/plugin-bootstrap.js +35 -33
- package/dist/plugins/ecosystem/plugin-bootstrap.js.map +1 -1
- package/dist/profile/plugin-profiles.d.ts +1 -1
- package/dist/profile/plugin-profiles.d.ts.map +1 -1
- package/dist/profile/plugin-profiles.js +18 -0
- package/dist/profile/plugin-profiles.js.map +1 -1
- package/dist/remote/server-assembly.d.ts.map +1 -1
- package/dist/remote/server-assembly.js +7 -2
- package/dist/remote/server-assembly.js.map +1 -1
- package/dist/{profiles → suites}/builtin-suites.d.ts +14 -4
- package/dist/suites/builtin-suites.d.ts.map +1 -0
- package/dist/{profiles → suites}/builtin-suites.js +20 -5
- package/dist/suites/builtin-suites.js.map +1 -0
- package/dist/suites/resolved-agent-profile.d.ts.map +1 -0
- package/dist/suites/resolved-agent-profile.js.map +1 -0
- package/dist/suites/suite-lifecycle.d.ts.map +1 -0
- package/dist/suites/suite-lifecycle.js.map +1 -0
- package/dist/suites/suite-loader.d.ts.map +1 -0
- package/dist/suites/suite-loader.js.map +1 -0
- package/dist/{modes/interactive/theme → theme}/dark.json +1 -1
- package/dist/{modes/interactive/theme → theme}/light.json +1 -1
- package/dist/{modes/interactive/theme → theme}/theme-controller.d.ts +1 -1
- package/dist/theme/theme-controller.d.ts.map +1 -0
- package/dist/{modes/interactive/theme → theme}/theme-controller.js +1 -1
- package/dist/theme/theme-controller.js.map +1 -0
- package/dist/{modes/interactive/theme → theme}/theme.d.ts +1 -1
- package/dist/theme/theme.d.ts.map +1 -0
- package/dist/{modes/interactive/theme → theme}/theme.js +5 -5
- package/dist/theme/theme.js.map +1 -0
- package/docs/compaction.md +7 -7
- package/docs/environment-variables.md +10 -4
- package/docs/keybindings.md +3 -3
- package/docs/models.md +17 -17
- package/docs/packages.md +1 -1
- package/docs/prompt-templates.md +1 -1
- package/docs/rpc.md +2 -2
- package/docs/sdk.md +5 -5
- package/docs/session-format.md +3 -3
- package/docs/settings.md +368 -354
- package/docs/shell-aliases.md +1 -1
- package/docs/skills.md +1 -1
- package/docs/terminal-setup.md +17 -17
- package/docs/themes.md +5 -5
- package/docs/tmux.md +4 -4
- package/docs/tui.md +1 -1
- package/docs/windows.md +1 -1
- package/examples/extensions/bash-spawn-hook/index.ts +1 -1
- package/examples/extensions/dynamic-resources/dynamic.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -6
- package/examples/extensions/with-deps/plugin.json +1 -1
- package/package.json +2 -2
- package/dist/bundle/chunks/openai-responses-AUJQ3NWT.js +0 -2
- package/dist/bundle/chunks/virtual-modules-WF6WRHP7.js +0 -5
- package/dist/cli/experimental/commands/pi.d.ts +0 -15
- package/dist/cli/experimental/commands/pi.d.ts.map +0 -1
- package/dist/cli/experimental/commands/pi.js.map +0 -1
- package/dist/core/export-html/ansi-to-html.d.ts.map +0 -1
- package/dist/core/export-html/ansi-to-html.js.map +0 -1
- package/dist/core/export-html/index.d.ts.map +0 -1
- package/dist/core/export-html/index.js.map +0 -1
- package/dist/core/export-html/tool-renderer.d.ts.map +0 -1
- package/dist/core/export-html/tool-renderer.js.map +0 -1
- package/dist/core/pi-manifest.d.ts +0 -7
- package/dist/core/pi-manifest.d.ts.map +0 -1
- package/dist/core/pi-manifest.js.map +0 -1
- package/dist/modes/interactive/model-catalog-refresh.d.ts.map +0 -1
- package/dist/modes/interactive/model-catalog-refresh.js.map +0 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +0 -1
- package/dist/modes/interactive/theme/theme-controller.js.map +0 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +0 -1
- package/dist/modes/interactive/theme/theme.js.map +0 -1
- package/dist/profiles/builtin-suites.d.ts.map +0 -1
- package/dist/profiles/builtin-suites.js.map +0 -1
- package/dist/profiles/resolved-agent-profile.d.ts.map +0 -1
- package/dist/profiles/resolved-agent-profile.js.map +0 -1
- package/dist/profiles/suite-lifecycle.d.ts.map +0 -1
- package/dist/profiles/suite-lifecycle.js.map +0 -1
- package/dist/profiles/suite-loader.d.ts.map +0 -1
- package/dist/profiles/suite-loader.js.map +0 -1
- package/dist/utils/deprecation.d.ts +0 -4
- package/dist/utils/deprecation.d.ts.map +0 -1
- package/dist/utils/deprecation.js +0 -13
- package/dist/utils/deprecation.js.map +0 -1
- /package/dist/{core/export-html → export-html}/ansi-to-html.d.ts +0 -0
- /package/dist/{core/export-html → export-html}/ansi-to-html.js +0 -0
- /package/dist/{core/export-html → export-html}/template.css +0 -0
- /package/dist/{core/export-html → export-html}/template.html +0 -0
- /package/dist/{core/export-html → export-html}/template.js +0 -0
- /package/dist/{core/export-html → export-html}/tool-renderer.js +0 -0
- /package/dist/{core/export-html → export-html}/vendor/highlight.min.js +0 -0
- /package/dist/{core/export-html → export-html}/vendor/marked.min.js +0 -0
- /package/dist/{profiles → suites}/resolved-agent-profile.d.ts +0 -0
- /package/dist/{profiles → suites}/resolved-agent-profile.js +0 -0
- /package/dist/{profiles → suites}/suite-lifecycle.d.ts +0 -0
- /package/dist/{profiles → suites}/suite-lifecycle.js +0 -0
- /package/dist/{profiles → suites}/suite-loader.d.ts +0 -0
- /package/dist/{profiles → suites}/suite-loader.js +0 -0
- /package/dist/{modes/interactive/theme → theme}/theme-schema.json +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-auth.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-auth.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,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AC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,oBAAoB,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAWxG;AAED,wBAAsB,aAAa,CAClC,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,oBAAoB,EAC5B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,SAAS,GAAG,OAAO,GACzB,OAAO,CAAC,IAAI,CAAC,CAMf;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiC/G","sourcesContent":["/**\n * Login/authentication flow for interactive mode (S5 slice 3): provider\n * option collection, the /login and /logout selectors, the OAuth and API-key\n * login dialogs, auth prompt plumbing, and post-login completion.\n *\n * InteractiveMode implements AuthUiHost and keeps same-name delegate methods\n * so prototype-level tests and the command dispatch table keep working; the\n * functions below receive the mode through AuthUiHost and route every call —\n * including steps between auth methods — through the host, mirroring the\n * DialogUiHost pattern in ./interactive-dialog-ui.ts. Credential/provider\n * auth, model snapshot, catalog refresh, facade, and session-identity access go\n * through narrow host accessors (D-048: facade projections) so this module\n * never reads session internals directly.\n *\n * Internal collaboration interface (same pattern as CommandDispatchHost): not\n * a plugin API and not exported from the package root.\n */\nimport * as path from \"node:path\";\nimport type { AuthEvent, AuthPrompt } from \"@agent-forge/ai\";\nimport type { Api, Model } from \"@agent-forge/ai/compat\";\nimport type { Component, Container, EditorComponent, TUI } from \"@agent-forge/tui\";\nimport { APP_NAME, getAuthPath, getDocsPath } from \"../../config.ts\";\nimport type { ModelAuthRuntime } from \"../../core/facade/coding-agent-facade.ts\";\nimport { t } from \"../../core/i18n/index.ts\";\nimport { defaultModelPerProvider } from \"../../core/model-resolver.ts\";\nimport { CredentialSynchronizationError } from \"../../core/model-runtime.ts\";\nimport { DialogSelectorComponent } from \"./components/dialog-selector.ts\";\nimport { LoginDialogComponent } from \"./components/login-dialog.ts\";\nimport { type AuthSelectorProvider, OAuthSelectorComponent } from \"./components/oauth-selector.ts\";\nimport { hasDefaultModelProvider, isUnknownModel, llamaCppPostLoginGuidance } from \"./interactive-helpers.ts\";\nimport type { ModelCatalogRuntime } from \"./model-catalog-refresh.ts\";\nimport { theme } from \"./theme/theme.ts\";\n\n/**\n * Host surface InteractiveMode exposes to this module: the auth-flow methods\n * (which stay on the mode for dispatch and prototype-level tests) plus narrow\n * accessors for the session runtime, facade operations, and selector surface.\n *\n * Internal collaboration interface (same pattern as CommandDispatchHost): not\n * a plugin API and not exported from the package root.\n */\nexport interface AuthUiHost {\n\t/**\n\t * Narrow credential/provider auth projection through the stable facade\n\t * (D-048); the full runtime stays on the session.\n\t */\n\tgetModelAuthRuntime(): ModelAuthRuntime;\n\t/** Narrow catalog-refresh projection through the stable facade (D-048). */\n\tgetModelCatalog(): ModelCatalogRuntime;\n\t/** Available model snapshot through the stable facade (D-048). */\n\tgetAvailableModels(): readonly Model<Api>[];\n\t/** Opaque current-session identity token for post-login rebind checks. */\n\tgetSessionIdentity(): unknown;\n\tisSameSessionIdentity(identity: unknown): boolean;\n\t/** Selected model through the stable facade. */\n\tgetSelectedModel(): Model<Api> | undefined;\n\t/** Persists a model selection through the stable facade. */\n\tsetSelectedModel(model: Model<Api>): Promise<void>;\n\n\tui: TUI;\n\teditor: EditorComponent;\n\teditorContainer: Container;\n\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n\tshowWarning(message: string): void;\n\t/** Selector surface; the implementation stays in the mode's selector area. */\n\tshowAuthSelector(\n\t\tcreate: (done: () => void) => { component: Component; focus: Component; dispose?: () => void },\n\t): void;\n\tupdateAvailableProviderCount(): void;\n\tmaybeWarnAboutAnthropicSubscriptionAuth(model?: Model<Api>): Promise<void>;\n\tcheckDaxnutsEasterEgg(model: { provider: string; id: string }): void;\n\tinvalidateFooter(): void;\n\tupdateEditorBorderColor(): void;\n\n\tgetLoginProviderOptions(authType?: \"oauth\" | \"api_key\"): AuthSelectorProvider[];\n\tgetLogoutProviderOptions(): Promise<AuthSelectorProvider[]>;\n\tfindLoginProviderOptions(providerRef: string): AuthSelectorProvider[];\n\thandleLoginCommand(providerRef?: string): Promise<void>;\n\tstartProviderLogin(providerOption: AuthSelectorProvider): Promise<void>;\n\tshowLoginAuthTypeSelector(providerOptions?: AuthSelectorProvider[]): void;\n\tshowLoginProviderSelector(authType?: AuthSelectorProvider[\"authType\"], initialSearchInput?: string): void;\n\tshowOAuthSelector(mode: \"login\" | \"logout\"): Promise<void>;\n\tcompleteProviderAuthentication(\n\t\tproviderId: string,\n\t\tproviderName: string,\n\t\tauthType: \"oauth\" | \"api_key\",\n\t\tpreviousModel: Model<Api> | undefined,\n\t): Promise<void>;\n\tshowAmbientAuthDialog(providerOption: AuthSelectorProvider): void;\n\tshowApiKeyLoginDialog(providerId: string, providerName: string): Promise<void>;\n\tshowAuthSelect(dialog: LoginDialogComponent, prompt: Extract<AuthPrompt, { type: \"select\" }>): Promise<string>;\n\tshowAuthPrompt(dialog: LoginDialogComponent, prompt: AuthPrompt): Promise<string>;\n\tnotifyAuthDialog(dialog: LoginDialogComponent, event: AuthEvent): void;\n\tloginProvider(dialog: LoginDialogComponent, providerId: string, method: \"api_key\" | \"oauth\"): Promise<void>;\n\tshowLoginDialog(providerId: string, providerName: string): Promise<void>;\n}\n\nexport function getLoginProviderOptions(host: AuthUiHost, authType?: \"oauth\" | \"api_key\"): AuthSelectorProvider[] {\n\tconst options: AuthSelectorProvider[] = [];\n\tfor (const provider of host.getModelAuthRuntime().getProviders()) {\n\t\tconst authStatus = host.getModelAuthRuntime().getProviderAuthStatus(provider.id);\n\t\tconst status = authStatus.configured\n\t\t\t? {\n\t\t\t\t\ttype: host.getModelAuthRuntime().isUsingOAuth(provider.id) ? (\"oauth\" as const) : (\"api_key\" as const),\n\t\t\t\t\tsource: authStatus.label ?? authStatus.source,\n\t\t\t\t}\n\t\t\t: undefined;\n\t\tif ((!authType || authType === \"oauth\") && provider.auth.oauth) {\n\t\t\toptions.push({\n\t\t\t\tid: provider.id,\n\t\t\t\tname: provider.name,\n\t\t\t\tauthType: \"oauth\",\n\t\t\t\tmethod: provider.auth.oauth,\n\t\t\t\tstatus,\n\t\t\t});\n\t\t}\n\t\tif ((!authType || authType === \"api_key\") && provider.auth.apiKey) {\n\t\t\toptions.push({\n\t\t\t\tid: provider.id,\n\t\t\t\tname: provider.name,\n\t\t\t\tauthType: \"api_key\",\n\t\t\t\tmethod: provider.auth.apiKey,\n\t\t\t\tstatus,\n\t\t\t});\n\t\t}\n\t}\n\treturn options.sort((a, b) => a.name.localeCompare(b.name));\n}\n\nexport async function getLogoutProviderOptions(host: AuthUiHost): Promise<AuthSelectorProvider[]> {\n\treturn (await host.getModelAuthRuntime().listCredentials({ signal: AbortSignal.timeout(15_000) }))\n\t\t.map(({ providerId, type }) => ({\n\t\t\tid: providerId,\n\t\t\tname: host.getModelAuthRuntime().getProvider(providerId)?.name ?? providerId,\n\t\t\tauthType: type,\n\t\t\tstatus: { type, source: \"stored credential\" },\n\t\t}))\n\t\t.sort((a, b) => a.name.localeCompare(b.name));\n}\n\nexport function findLoginProviderOptions(host: AuthUiHost, providerRef: string): AuthSelectorProvider[] {\n\tconst normalizedProviderRef = providerRef.trim().toLowerCase();\n\tif (!normalizedProviderRef) {\n\t\treturn [];\n\t}\n\n\treturn host\n\t\t.getLoginProviderOptions()\n\t\t.filter(\n\t\t\t(provider) =>\n\t\t\t\tprovider.id.toLowerCase() === normalizedProviderRef ||\n\t\t\t\tprovider.name.toLowerCase() === normalizedProviderRef,\n\t\t);\n}\n\nexport async function handleLoginCommand(host: AuthUiHost, providerRef?: string): Promise<void> {\n\tif (!providerRef) {\n\t\thost.showLoginAuthTypeSelector();\n\t\treturn;\n\t}\n\n\tconst providerOptions = host.findLoginProviderOptions(providerRef);\n\tif (providerOptions.length === 1) {\n\t\tawait host.startProviderLogin(providerOptions[0]!);\n\t\treturn;\n\t}\n\n\tif (providerOptions.length > 1) {\n\t\tconst providerIds = new Set(providerOptions.map((provider) => provider.id));\n\t\tif (providerIds.size === 1) {\n\t\t\thost.showLoginAuthTypeSelector(providerOptions);\n\t\t\treturn;\n\t\t}\n\t}\n\n\thost.showLoginProviderSelector(undefined, providerRef);\n}\n\nexport async function startProviderLogin(host: AuthUiHost, providerOption: AuthSelectorProvider): Promise<void> {\n\tif (providerOption.authType === \"oauth\") {\n\t\tawait host.showLoginDialog(providerOption.id, providerOption.name);\n\t} else if (providerOption.method?.login) {\n\t\tawait host.showApiKeyLoginDialog(providerOption.id, providerOption.name);\n\t} else {\n\t\thost.showAmbientAuthDialog(providerOption);\n\t}\n}\n\nexport function showLoginAuthTypeSelector(host: AuthUiHost, providerOptions?: AuthSelectorProvider[]): void {\n\tconst oauthProvider = providerOptions?.find((provider) => provider.authType === \"oauth\");\n\tconst oauthLoginLabel =\n\t\toauthProvider?.method && \"loginLabel\" in oauthProvider.method ? oauthProvider.method.loginLabel : undefined;\n\tconst subscriptionLabel = oauthLoginLabel ?? t(\"Sign in with an account\");\n\tconst apiKeyLabel = t(\"Sign in with an API key\");\n\tconst availableAuthTypes = providerOptions\n\t\t? new Set(providerOptions.map((provider) => provider.authType))\n\t\t: new Set<AuthSelectorProvider[\"authType\"]>([\"oauth\", \"api_key\"]);\n\tconst options: string[] = [];\n\tif (availableAuthTypes.has(\"oauth\")) {\n\t\toptions.push(subscriptionLabel);\n\t}\n\tif (availableAuthTypes.has(\"api_key\")) {\n\t\toptions.push(apiKeyLabel);\n\t}\n\n\tif (options.length === 0) {\n\t\thost.showStatus(t(\"No login methods available.\"));\n\t\treturn;\n\t}\n\n\tif (providerOptions && options.length === 1) {\n\t\tconst providerOption = providerOptions[0];\n\t\t// v8 ignore next -- options.length === 1 已保证 providerOptions 非空,[0] 恒存在\n\t\tif (providerOption) {\n\t\t\tvoid host.startProviderLogin(providerOption);\n\t\t}\n\t\treturn;\n\t}\n\n\tconst title = providerOptions?.[0]\n\t\t? t(\"Select authentication method for {name}:\", { name: providerOptions[0].name })\n\t\t: t(\"Select authentication method:\");\n\thost.showAuthSelector((done) => {\n\t\tconst selector = new DialogSelectorComponent(\n\t\t\ttitle,\n\t\t\toptions,\n\t\t\t(option) => {\n\t\t\t\tdone();\n\t\t\t\tconst authType = option === subscriptionLabel ? \"oauth\" : \"api_key\";\n\t\t\t\tif (providerOptions) {\n\t\t\t\t\tconst providerOption = providerOptions.find((provider) => provider.authType === authType);\n\t\t\t\t\t// v8 ignore next -- 选项列表由 providerOptions 的 authTypes 派生,必能找到\n\t\t\t\t\tif (providerOption) {\n\t\t\t\t\t\tvoid host.startProviderLogin(providerOption);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\thost.showLoginProviderSelector(authType);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\thost.ui.requestRender();\n\t\t\t},\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport function showLoginProviderSelector(\n\thost: AuthUiHost,\n\tauthType?: AuthSelectorProvider[\"authType\"],\n\tinitialSearchInput?: string,\n): void {\n\tconst providerOptions = host.getLoginProviderOptions(authType);\n\tif (providerOptions.length === 0) {\n\t\tconst message =\n\t\t\tauthType === \"oauth\"\n\t\t\t\t? t(\"No subscription providers available.\")\n\t\t\t\t: authType === \"api_key\"\n\t\t\t\t\t? t(\"No API key providers available.\")\n\t\t\t\t\t: t(\"No login providers available.\");\n\t\thost.showStatus(message);\n\t\treturn;\n\t}\n\n\thost.showAuthSelector((done) => {\n\t\tconst selector = new OAuthSelectorComponent(\n\t\t\t\"login\",\n\t\t\tproviderOptions,\n\t\t\tasync (providerId, selectedAuthType) => {\n\t\t\t\tdone();\n\n\t\t\t\tconst providerOption = providerOptions.find(\n\t\t\t\t\t(provider) => provider.id === providerId && provider.authType === selectedAuthType,\n\t\t\t\t);\n\t\t\t\tif (!providerOption) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tawait host.startProviderLogin(providerOption);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\tif (authType) {\n\t\t\t\t\thost.showLoginAuthTypeSelector();\n\t\t\t\t} else {\n\t\t\t\t\thost.ui.requestRender();\n\t\t\t\t}\n\t\t\t},\n\t\t\tinitialSearchInput,\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport async function showOAuthSelector(host: AuthUiHost, mode: \"login\" | \"logout\"): Promise<void> {\n\tif (mode === \"login\") {\n\t\thost.showLoginAuthTypeSelector();\n\t\treturn;\n\t}\n\n\tlet providerOptions: AuthSelectorProvider[];\n\ttry {\n\t\tproviderOptions = await host.getLogoutProviderOptions();\n\t} catch (error) {\n\t\thost.showError(\n\t\t\tt(\"Could not read stored credentials: {error}\", {\n\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t}),\n\t\t);\n\t\treturn;\n\t}\n\tif (providerOptions.length === 0) {\n\t\thost.showStatus(\n\t\t\tt(\n\t\t\t\t\"No stored credentials to remove. /logout only removes credentials saved by /login; environment variables and models.json config are unchanged.\",\n\t\t\t),\n\t\t);\n\t\treturn;\n\t}\n\n\thost.showAuthSelector((done) => {\n\t\tconst selector = new OAuthSelectorComponent(\n\t\t\tmode,\n\t\t\tproviderOptions,\n\t\t\tasync (providerId: string) => {\n\t\t\t\tdone();\n\n\t\t\t\tconst providerOption = providerOptions.find((provider) => provider.id === providerId);\n\t\t\t\tif (!providerOption) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait host.getModelAuthRuntime().logout(providerOption.id, {\n\t\t\t\t\t\tsignal: AbortSignal.timeout(15_000),\n\t\t\t\t\t});\n\t\t\t\t\tawait host.updateAvailableProviderCount();\n\t\t\t\t\tconst message =\n\t\t\t\t\t\tproviderOption.authType === \"oauth\"\n\t\t\t\t\t\t\t? t(\"Logged out of {name}\", { name: providerOption.name })\n\t\t\t\t\t\t\t: t(\n\t\t\t\t\t\t\t\t\t\"Removed stored API key for {name}. Environment variables and models.json config are unchanged.\",\n\t\t\t\t\t\t\t\t\t{ name: providerOption.name },\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\thost.showStatus(message);\n\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\thost.showError(\n\t\t\t\t\t\terror instanceof CredentialSynchronizationError\n\t\t\t\t\t\t\t? t(\"Credentials removed for {name}, but local model state could not be synchronized: {error}\", {\n\t\t\t\t\t\t\t\t\tname: providerOption.name,\n\t\t\t\t\t\t\t\t\terror: message,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t: t(\"Logout failed: {error}\", { error: message }),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\thost.ui.requestRender();\n\t\t\t},\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport async function completeProviderAuthentication(\n\thost: AuthUiHost,\n\tproviderId: string,\n\tproviderName: string,\n\tauthType: \"oauth\" | \"api_key\",\n\tpreviousModel: Model<Api> | undefined,\n): Promise<void> {\n\tconst actionLabel =\n\t\tauthType === \"oauth\"\n\t\t\t? t(\"Logged in to {name}\", { name: providerName })\n\t\t\t: t(\"Saved API key for {name}\", { name: providerName });\n\n\t// Opaque identity of the session that started this login; the rebind check\n\t// below compares against it through the host.\n\tconst sessionIdentity = host.getSessionIdentity();\n\t// Dynamic catalogs may be empty until the first authenticated network refresh.\n\tconst deferSelection =\n\t\tisUnknownModel(previousModel) &&\n\t\thasDefaultModelProvider(providerId) &&\n\t\t!host\n\t\t\t.getAvailableModels()\n\t\t\t.some((model) => model.provider === providerId && model.id === defaultModelPerProvider[providerId]);\n\tconst finishAuthentication = async () => {\n\t\tlet selectedModel: Model<Api> | undefined;\n\t\tlet selectionError: string | undefined;\n\t\tif (isUnknownModel(previousModel)) {\n\t\t\tconst availableModels = host.getAvailableModels();\n\t\t\tconst providerModels = availableModels.filter((model) => model.provider === providerId);\n\t\t\t// Matches LLAMA_PROVIDER_ID from extensions/llama/provider.ts; kept inline to avoid coupling interactive mode to the built-in extension.\n\t\t\tif (providerId === \"llama.cpp\") {\n\t\t\t\tselectionError = llamaCppPostLoginGuidance(actionLabel, providerModels.length);\n\t\t\t} else if (!hasDefaultModelProvider(providerId)) {\n\t\t\t\tselectionError = t(\n\t\t\t\t\t'{action}, but no default model is configured for provider \"{providerId}\". Use /model to select a model.',\n\t\t\t\t\t{ action: actionLabel, providerId },\n\t\t\t\t);\n\t\t\t} else if (providerModels.length === 0) {\n\t\t\t\tselectionError = t(\n\t\t\t\t\t\"{action}, but no models are available for that provider. Use /model to select a model.\",\n\t\t\t\t\t{\n\t\t\t\t\t\taction: actionLabel,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst defaultModelId = defaultModelPerProvider[providerId];\n\t\t\t\tselectedModel = providerModels.find((model) => model.id === defaultModelId);\n\t\t\t\tif (!selectedModel) {\n\t\t\t\t\tselectionError = t(\n\t\t\t\t\t\t'{action}, but its default model \"{modelId}\" is not available. Use /model to select a model.',\n\t\t\t\t\t\t{ action: actionLabel, modelId: defaultModelId },\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait host.setSelectedModel(selectedModel);\n\t\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\t\tselectedModel = undefined;\n\t\t\t\t\t\tconst errorMessage = error instanceof Error ? error.message : String(error);\n\t\t\t\t\t\tselectionError = t(\n\t\t\t\t\t\t\t\"{action}, but selecting its default model failed: {error}. Use /model to select a model.\",\n\t\t\t\t\t\t\t{ action: actionLabel, error: errorMessage },\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tawait host.updateAvailableProviderCount();\n\t\thost.invalidateFooter();\n\t\thost.updateEditorBorderColor();\n\t\tif (selectedModel) {\n\t\t\thost.showStatus(\n\t\t\t\tt(\"{action}. Selected {modelId}. Credentials saved to {path}\", {\n\t\t\t\t\taction: actionLabel,\n\t\t\t\t\tmodelId: selectedModel.id,\n\t\t\t\t\tpath: getAuthPath(),\n\t\t\t\t}),\n\t\t\t);\n\t\t\tvoid host.maybeWarnAboutAnthropicSubscriptionAuth(selectedModel);\n\t\t\thost.checkDaxnutsEasterEgg(selectedModel);\n\t\t} else {\n\t\t\thost.showStatus(t(\"{action}. Credentials saved to {path}\", { action: actionLabel, path: getAuthPath() }));\n\t\t\tif (selectionError) {\n\t\t\t\thost.showError(selectionError);\n\t\t\t} else {\n\t\t\t\tvoid host.maybeWarnAboutAnthropicSubscriptionAuth();\n\t\t\t}\n\t\t}\n\t};\n\tif (deferSelection) {\n\t\thost.showStatus(\n\t\t\tt(\"{action}. Credentials saved to {path}. Refreshing model catalog…\", {\n\t\t\t\taction: actionLabel,\n\t\t\t\tpath: getAuthPath(),\n\t\t\t}),\n\t\t);\n\t} else {\n\t\tawait finishAuthentication();\n\t}\n\n\tconst controller = new AbortController();\n\tconst timeout = setTimeout(() => controller.abort(), 15_000);\n\tvoid host\n\t\t.getModelCatalog()\n\t\t.refresh({ providers: [providerId], signal: controller.signal })\n\t\t.then(async (result) => {\n\t\t\tif (result.aborted) {\n\t\t\t\thost.showWarning(\n\t\t\t\t\tt(\"{action}, but its model catalog refresh timed out; using cached models.\", { action: actionLabel }),\n\t\t\t\t);\n\t\t\t} else if (result.errors.size > 0) {\n\t\t\t\thost.showWarning(\n\t\t\t\t\tt(\"{action}, but its model catalog could not be refreshed; using cached models.\", {\n\t\t\t\t\t\taction: actionLabel,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\t// Do not replace a model or session selected while the refresh was running.\n\t\t\tif (\n\t\t\t\tdeferSelection &&\n\t\t\t\thost.isSameSessionIdentity(sessionIdentity) &&\n\t\t\t\thost.getSelectedModel() === previousModel\n\t\t\t) {\n\t\t\t\tawait finishAuthentication();\n\t\t\t}\n\t\t\thost.updateAvailableProviderCount();\n\t\t\thost.invalidateFooter();\n\t\t\thost.ui.requestRender();\n\t\t})\n\t\t.catch((error: unknown) => {\n\t\t\thost.showWarning(\n\t\t\t\tt(\"{action}, but its model catalog could not be refreshed: {error}\", {\n\t\t\t\t\taction: actionLabel,\n\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t}),\n\t\t\t);\n\t\t})\n\t\t.finally(() => clearTimeout(timeout));\n}\n\nexport function showAmbientAuthDialog(host: AuthUiHost, providerOption: AuthSelectorProvider): void {\n\tconst restoreEditor = () => {\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(host.editor);\n\t\thost.ui.setFocus(host.editor);\n\t\thost.ui.requestRender();\n\t};\n\n\tconst dialog = new LoginDialogComponent(\n\t\thost.ui,\n\t\tproviderOption.id,\n\t\t() => restoreEditor(),\n\t\tproviderOption.name,\n\t\tt(\"{name} setup\", { name: providerOption.name }),\n\t);\n\tdialog.showInfo(\n\t\tt(\"{method} is configured outside {appName}.\", {\n\t\t\tmethod: providerOption.method?.name ?? t(\"Authentication\"),\n\t\t\tappName: APP_NAME,\n\t\t}),\n\t\t[],\n\t\ttrue,\n\t);\n\n\thost.editorContainer.clear();\n\thost.editorContainer.addChild(dialog);\n\thost.ui.setFocus(dialog);\n\thost.ui.requestRender();\n}\n\nexport async function showApiKeyLoginDialog(host: AuthUiHost, providerId: string, providerName: string): Promise<void> {\n\tconst previousModel = host.getSelectedModel();\n\n\tconst dialog = new LoginDialogComponent(\n\t\thost.ui,\n\t\tproviderId,\n\t\t(_success, _message) => {\n\t\t\t// Completion handled below\n\t\t},\n\t\tproviderName,\n\t);\n\n\tif (providerId === \"amazon-bedrock\") {\n\t\tdialog.showDetails([\n\t\t\ttheme.fg(\"text\", t(\"You can also use an AWS profile, IAM keys, or role-based credentials.\")),\n\t\t\ttheme.fg(\"muted\", t(\"See:\")),\n\t\t\ttheme.fg(\"accent\", ` ${path.join(getDocsPath(), \"providers.md\")}`),\n\t\t]);\n\t}\n\n\thost.editorContainer.clear();\n\thost.editorContainer.addChild(dialog);\n\thost.ui.setFocus(dialog);\n\thost.ui.requestRender();\n\n\tconst restoreEditor = () => {\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(host.editor);\n\t\thost.ui.setFocus(host.editor);\n\t\thost.ui.requestRender();\n\t};\n\n\ttry {\n\t\tawait host.loginProvider(dialog, providerId, \"api_key\");\n\t\trestoreEditor();\n\t\tawait host.completeProviderAuthentication(providerId, providerName, \"api_key\", previousModel);\n\t} catch (error: unknown) {\n\t\trestoreEditor();\n\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\tif (error instanceof CredentialSynchronizationError) {\n\t\t\thost.showError(\n\t\t\t\tt(\"Saved API key for {name}, but local model state could not be synchronized: {error}\", {\n\t\t\t\t\tname: providerName,\n\t\t\t\t\terror: errorMsg,\n\t\t\t\t}),\n\t\t\t);\n\t\t} else if (errorMsg !== t(\"Login cancelled\")) {\n\t\t\thost.showError(t(\"Failed to save API key for {name}: {error}\", { name: providerName, error: errorMsg }));\n\t\t}\n\t}\n}\n\nexport function showAuthSelect(\n\thost: AuthUiHost,\n\tdialog: LoginDialogComponent,\n\tprompt: Extract<AuthPrompt, { type: \"select\" }>,\n): Promise<string> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst restoreDialog = () => {\n\t\t\thost.editorContainer.clear();\n\t\t\thost.editorContainer.addChild(dialog);\n\t\t\thost.ui.setFocus(dialog);\n\t\t\thost.ui.requestRender();\n\t\t};\n\t\tconst labels = prompt.options.map((option) => option.label);\n\t\tconst selector = new DialogSelectorComponent(\n\t\t\tprompt.message,\n\t\t\tlabels,\n\t\t\t(optionLabel) => {\n\t\t\t\trestoreDialog();\n\t\t\t\tconst id = prompt.options.find((option) => option.label === optionLabel)?.id;\n\t\t\t\t// v8 ignore next -- 选项列表由 prompt.options 派生,选中项必能找到\n\t\t\t\tif (id) resolve(id);\n\t\t\t\telse reject(new Error(t(\"Login cancelled\")));\n\t\t\t},\n\t\t\t() => {\n\t\t\t\trestoreDialog();\n\t\t\t\treject(new Error(t(\"Login cancelled\")));\n\t\t\t},\n\t\t);\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(selector);\n\t\thost.ui.setFocus(selector);\n\t\thost.ui.requestRender();\n\t});\n}\n\nexport async function showAuthPrompt(\n\thost: AuthUiHost,\n\tdialog: LoginDialogComponent,\n\tprompt: AuthPrompt,\n): Promise<string> {\n\tlet response: Promise<string>;\n\tif (prompt.type === \"select\") {\n\t\tresponse = host.showAuthSelect(dialog, prompt);\n\t} else if (prompt.type === \"manual_code\") {\n\t\tresponse = dialog.showManualInput(prompt.message);\n\t} else {\n\t\tresponse = dialog.showPrompt(prompt.message, prompt.placeholder);\n\t}\n\tif (!prompt.signal) return response;\n\tif (prompt.signal.aborted) throw new Error(t(\"Login cancelled\"));\n\tconst signal = prompt.signal;\n\tlet onAbort: (() => void) | undefined;\n\tconst aborted = new Promise<string>((_resolve, reject) => {\n\t\tonAbort = () => reject(new Error(t(\"Login cancelled\")));\n\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n\ttry {\n\t\treturn await Promise.race([response, aborted]);\n\t} finally {\n\t\t// v8 ignore next -- onAbort 在 Promise executor 中同步赋值,恒已定义\n\t\tif (onAbort) signal.removeEventListener(\"abort\", onAbort);\n\t}\n}\n\nexport function notifyAuthDialog(_host: AuthUiHost, dialog: LoginDialogComponent, event: AuthEvent): void {\n\tif (event.type === \"auth_url\") {\n\t\tdialog.showAuth(event.url, event.instructions);\n\t} else if (event.type === \"device_code\") {\n\t\tdialog.showDeviceCode(event);\n\t\tdialog.showWaiting(t(\"Waiting for authentication...\"));\n\t} else if (event.type === \"info\") {\n\t\tdialog.showInfo(event.message, event.links);\n\t} else {\n\t\tdialog.showProgress(event.message);\n\t}\n}\n\nexport async function loginProvider(\n\thost: AuthUiHost,\n\tdialog: LoginDialogComponent,\n\tproviderId: string,\n\tmethod: \"api_key\" | \"oauth\",\n): Promise<void> {\n\tawait host.getModelAuthRuntime().login(providerId, method, {\n\t\tsignal: dialog.signal,\n\t\tprompt: (prompt) => host.showAuthPrompt(dialog, prompt),\n\t\tnotify: (event) => host.notifyAuthDialog(dialog, event),\n\t});\n}\n\nexport async function showLoginDialog(host: AuthUiHost, providerId: string, providerName: string): Promise<void> {\n\tconst previousModel = host.getSelectedModel();\n\tconst dialog = new LoginDialogComponent(host.ui, providerId, (_success, _message) => {}, providerName);\n\thost.editorContainer.clear();\n\thost.editorContainer.addChild(dialog);\n\thost.ui.setFocus(dialog);\n\thost.ui.requestRender();\n\n\tconst restoreEditor = () => {\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(host.editor);\n\t\thost.ui.setFocus(host.editor);\n\t\thost.ui.requestRender();\n\t};\n\n\ttry {\n\t\tawait host.loginProvider(dialog, providerId, \"oauth\");\n\t\trestoreEditor();\n\t\tawait host.completeProviderAuthentication(providerId, providerName, \"oauth\", previousModel);\n\t} catch (error: unknown) {\n\t\trestoreEditor();\n\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\tif (error instanceof CredentialSynchronizationError) {\n\t\t\thost.showError(\n\t\t\t\tt(\"Logged in to {name}, but local model state could not be synchronized: {error}\", {\n\t\t\t\t\tname: providerName,\n\t\t\t\t\terror: errorMsg,\n\t\t\t\t}),\n\t\t\t);\n\t\t} else if (errorMsg !== t(\"Login cancelled\")) {\n\t\t\thost.showError(t(\"Failed to login to {name}: {error}\", { name: providerName, error: errorMsg }));\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interactive-auth.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-auth.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO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M,EAAE,oBAAoB,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAWxG;AAED,wBAAsB,aAAa,CAClC,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,oBAAoB,EAC5B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,SAAS,GAAG,OAAO,GACzB,OAAO,CAAC,IAAI,CAAC,CAMf;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiC/G","sourcesContent":["/**\n * Login/authentication flow for interactive mode (S5 slice 3): provider\n * option collection, the /login and /logout selectors, the OAuth and API-key\n * login dialogs, auth prompt plumbing, and post-login completion.\n *\n * InteractiveMode implements AuthUiHost and keeps same-name delegate methods\n * so prototype-level tests and the command dispatch table keep working; the\n * functions below receive the mode through AuthUiHost and route every call —\n * including steps between auth methods — through the host, mirroring the\n * DialogUiHost pattern in ./interactive-dialog-ui.ts. Credential/provider\n * auth, model snapshot, catalog refresh, facade, and session-identity access go\n * through narrow host accessors (D-048: facade projections) so this module\n * never reads session internals directly.\n *\n * Internal collaboration interface (same pattern as CommandDispatchHost): not\n * a plugin API and not exported from the package root.\n */\nimport * as path from \"node:path\";\nimport type { AuthEvent, AuthPrompt } from \"@agent-forge/ai\";\nimport type { Api, Model } from \"@agent-forge/ai/compat\";\nimport type { Component, Container, EditorComponent, TUI } from \"@agent-forge/tui\";\nimport { APP_NAME, getAuthPath, getDocsPath } from \"../../config.ts\";\nimport type { ModelAuthRuntime } from \"../../core/facade/coding-agent-facade.ts\";\nimport { t } from \"../../core/i18n/index.ts\";\nimport { defaultModelPerProvider } from \"../../core/model-resolver.ts\";\nimport { CredentialSynchronizationError } from \"../../core/model-runtime.ts\";\nimport type { ModelCatalogRuntime } from \"../../host/model-catalog-refresh.ts\";\nimport { theme } from \"../../theme/theme.ts\";\nimport { DialogSelectorComponent } from \"./components/dialog-selector.ts\";\nimport { LoginDialogComponent } from \"./components/login-dialog.ts\";\nimport { type AuthSelectorProvider, OAuthSelectorComponent } from \"./components/oauth-selector.ts\";\nimport { hasDefaultModelProvider, isUnknownModel, llamaCppPostLoginGuidance } from \"./interactive-helpers.ts\";\n\n/**\n * Host surface InteractiveMode exposes to this module: the auth-flow methods\n * (which stay on the mode for dispatch and prototype-level tests) plus narrow\n * accessors for the session runtime, facade operations, and selector surface.\n *\n * Internal collaboration interface (same pattern as CommandDispatchHost): not\n * a plugin API and not exported from the package root.\n */\nexport interface AuthUiHost {\n\t/**\n\t * Narrow credential/provider auth projection through the stable facade\n\t * (D-048); the full runtime stays on the session.\n\t */\n\tgetModelAuthRuntime(): ModelAuthRuntime;\n\t/** Narrow catalog-refresh projection through the stable facade (D-048). */\n\tgetModelCatalog(): ModelCatalogRuntime;\n\t/** Available model snapshot through the stable facade (D-048). */\n\tgetAvailableModels(): readonly Model<Api>[];\n\t/** Opaque current-session identity token for post-login rebind checks. */\n\tgetSessionIdentity(): unknown;\n\tisSameSessionIdentity(identity: unknown): boolean;\n\t/** Selected model through the stable facade. */\n\tgetSelectedModel(): Model<Api> | undefined;\n\t/** Persists a model selection through the stable facade. */\n\tsetSelectedModel(model: Model<Api>): Promise<void>;\n\n\tui: TUI;\n\teditor: EditorComponent;\n\teditorContainer: Container;\n\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n\tshowWarning(message: string): void;\n\t/** Selector surface; the implementation stays in the mode's selector area. */\n\tshowAuthSelector(\n\t\tcreate: (done: () => void) => { component: Component; focus: Component; dispose?: () => void },\n\t): void;\n\tupdateAvailableProviderCount(): void;\n\tmaybeWarnAboutAnthropicSubscriptionAuth(model?: Model<Api>): Promise<void>;\n\tcheckDaxnutsEasterEgg(model: { provider: string; id: string }): void;\n\tinvalidateFooter(): void;\n\tupdateEditorBorderColor(): void;\n\n\tgetLoginProviderOptions(authType?: \"oauth\" | \"api_key\"): AuthSelectorProvider[];\n\tgetLogoutProviderOptions(): Promise<AuthSelectorProvider[]>;\n\tfindLoginProviderOptions(providerRef: string): AuthSelectorProvider[];\n\thandleLoginCommand(providerRef?: string): Promise<void>;\n\tstartProviderLogin(providerOption: AuthSelectorProvider): Promise<void>;\n\tshowLoginAuthTypeSelector(providerOptions?: AuthSelectorProvider[]): void;\n\tshowLoginProviderSelector(authType?: AuthSelectorProvider[\"authType\"], initialSearchInput?: string): void;\n\tshowOAuthSelector(mode: \"login\" | \"logout\"): Promise<void>;\n\tcompleteProviderAuthentication(\n\t\tproviderId: string,\n\t\tproviderName: string,\n\t\tauthType: \"oauth\" | \"api_key\",\n\t\tpreviousModel: Model<Api> | undefined,\n\t): Promise<void>;\n\tshowAmbientAuthDialog(providerOption: AuthSelectorProvider): void;\n\tshowApiKeyLoginDialog(providerId: string, providerName: string): Promise<void>;\n\tshowAuthSelect(dialog: LoginDialogComponent, prompt: Extract<AuthPrompt, { type: \"select\" }>): Promise<string>;\n\tshowAuthPrompt(dialog: LoginDialogComponent, prompt: AuthPrompt): Promise<string>;\n\tnotifyAuthDialog(dialog: LoginDialogComponent, event: AuthEvent): void;\n\tloginProvider(dialog: LoginDialogComponent, providerId: string, method: \"api_key\" | \"oauth\"): Promise<void>;\n\tshowLoginDialog(providerId: string, providerName: string): Promise<void>;\n}\n\nexport function getLoginProviderOptions(host: AuthUiHost, authType?: \"oauth\" | \"api_key\"): AuthSelectorProvider[] {\n\tconst options: AuthSelectorProvider[] = [];\n\tfor (const provider of host.getModelAuthRuntime().getProviders()) {\n\t\tconst authStatus = host.getModelAuthRuntime().getProviderAuthStatus(provider.id);\n\t\tconst status = authStatus.configured\n\t\t\t? {\n\t\t\t\t\ttype: host.getModelAuthRuntime().isUsingOAuth(provider.id) ? (\"oauth\" as const) : (\"api_key\" as const),\n\t\t\t\t\tsource: authStatus.label ?? authStatus.source,\n\t\t\t\t}\n\t\t\t: undefined;\n\t\tif ((!authType || authType === \"oauth\") && provider.auth.oauth) {\n\t\t\toptions.push({\n\t\t\t\tid: provider.id,\n\t\t\t\tname: provider.name,\n\t\t\t\tauthType: \"oauth\",\n\t\t\t\tmethod: provider.auth.oauth,\n\t\t\t\tstatus,\n\t\t\t});\n\t\t}\n\t\tif ((!authType || authType === \"api_key\") && provider.auth.apiKey) {\n\t\t\toptions.push({\n\t\t\t\tid: provider.id,\n\t\t\t\tname: provider.name,\n\t\t\t\tauthType: \"api_key\",\n\t\t\t\tmethod: provider.auth.apiKey,\n\t\t\t\tstatus,\n\t\t\t});\n\t\t}\n\t}\n\treturn options.sort((a, b) => a.name.localeCompare(b.name));\n}\n\nexport async function getLogoutProviderOptions(host: AuthUiHost): Promise<AuthSelectorProvider[]> {\n\treturn (await host.getModelAuthRuntime().listCredentials({ signal: AbortSignal.timeout(15_000) }))\n\t\t.map(({ providerId, type }) => ({\n\t\t\tid: providerId,\n\t\t\tname: host.getModelAuthRuntime().getProvider(providerId)?.name ?? providerId,\n\t\t\tauthType: type,\n\t\t\tstatus: { type, source: \"stored credential\" },\n\t\t}))\n\t\t.sort((a, b) => a.name.localeCompare(b.name));\n}\n\nexport function findLoginProviderOptions(host: AuthUiHost, providerRef: string): AuthSelectorProvider[] {\n\tconst normalizedProviderRef = providerRef.trim().toLowerCase();\n\tif (!normalizedProviderRef) {\n\t\treturn [];\n\t}\n\n\treturn host\n\t\t.getLoginProviderOptions()\n\t\t.filter(\n\t\t\t(provider) =>\n\t\t\t\tprovider.id.toLowerCase() === normalizedProviderRef ||\n\t\t\t\tprovider.name.toLowerCase() === normalizedProviderRef,\n\t\t);\n}\n\nexport async function handleLoginCommand(host: AuthUiHost, providerRef?: string): Promise<void> {\n\tif (!providerRef) {\n\t\thost.showLoginAuthTypeSelector();\n\t\treturn;\n\t}\n\n\tconst providerOptions = host.findLoginProviderOptions(providerRef);\n\tif (providerOptions.length === 1) {\n\t\tawait host.startProviderLogin(providerOptions[0]!);\n\t\treturn;\n\t}\n\n\tif (providerOptions.length > 1) {\n\t\tconst providerIds = new Set(providerOptions.map((provider) => provider.id));\n\t\tif (providerIds.size === 1) {\n\t\t\thost.showLoginAuthTypeSelector(providerOptions);\n\t\t\treturn;\n\t\t}\n\t}\n\n\thost.showLoginProviderSelector(undefined, providerRef);\n}\n\nexport async function startProviderLogin(host: AuthUiHost, providerOption: AuthSelectorProvider): Promise<void> {\n\tif (providerOption.authType === \"oauth\") {\n\t\tawait host.showLoginDialog(providerOption.id, providerOption.name);\n\t} else if (providerOption.method?.login) {\n\t\tawait host.showApiKeyLoginDialog(providerOption.id, providerOption.name);\n\t} else {\n\t\thost.showAmbientAuthDialog(providerOption);\n\t}\n}\n\nexport function showLoginAuthTypeSelector(host: AuthUiHost, providerOptions?: AuthSelectorProvider[]): void {\n\tconst oauthProvider = providerOptions?.find((provider) => provider.authType === \"oauth\");\n\tconst oauthLoginLabel =\n\t\toauthProvider?.method && \"loginLabel\" in oauthProvider.method ? oauthProvider.method.loginLabel : undefined;\n\tconst subscriptionLabel = oauthLoginLabel ?? t(\"Sign in with an account\");\n\tconst apiKeyLabel = t(\"Sign in with an API key\");\n\tconst availableAuthTypes = providerOptions\n\t\t? new Set(providerOptions.map((provider) => provider.authType))\n\t\t: new Set<AuthSelectorProvider[\"authType\"]>([\"oauth\", \"api_key\"]);\n\tconst options: string[] = [];\n\tif (availableAuthTypes.has(\"oauth\")) {\n\t\toptions.push(subscriptionLabel);\n\t}\n\tif (availableAuthTypes.has(\"api_key\")) {\n\t\toptions.push(apiKeyLabel);\n\t}\n\n\tif (options.length === 0) {\n\t\thost.showStatus(t(\"No login methods available.\"));\n\t\treturn;\n\t}\n\n\tif (providerOptions && options.length === 1) {\n\t\tconst providerOption = providerOptions[0];\n\t\t// v8 ignore next -- options.length === 1 已保证 providerOptions 非空,[0] 恒存在\n\t\tif (providerOption) {\n\t\t\tvoid host.startProviderLogin(providerOption);\n\t\t}\n\t\treturn;\n\t}\n\n\tconst title = providerOptions?.[0]\n\t\t? t(\"Select authentication method for {name}:\", { name: providerOptions[0].name })\n\t\t: t(\"Select authentication method:\");\n\thost.showAuthSelector((done) => {\n\t\tconst selector = new DialogSelectorComponent(\n\t\t\ttitle,\n\t\t\toptions,\n\t\t\t(option) => {\n\t\t\t\tdone();\n\t\t\t\tconst authType = option === subscriptionLabel ? \"oauth\" : \"api_key\";\n\t\t\t\tif (providerOptions) {\n\t\t\t\t\tconst providerOption = providerOptions.find((provider) => provider.authType === authType);\n\t\t\t\t\t// v8 ignore next -- 选项列表由 providerOptions 的 authTypes 派生,必能找到\n\t\t\t\t\tif (providerOption) {\n\t\t\t\t\t\tvoid host.startProviderLogin(providerOption);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\thost.showLoginProviderSelector(authType);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\thost.ui.requestRender();\n\t\t\t},\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport function showLoginProviderSelector(\n\thost: AuthUiHost,\n\tauthType?: AuthSelectorProvider[\"authType\"],\n\tinitialSearchInput?: string,\n): void {\n\tconst providerOptions = host.getLoginProviderOptions(authType);\n\tif (providerOptions.length === 0) {\n\t\tconst message =\n\t\t\tauthType === \"oauth\"\n\t\t\t\t? t(\"No subscription providers available.\")\n\t\t\t\t: authType === \"api_key\"\n\t\t\t\t\t? t(\"No API key providers available.\")\n\t\t\t\t\t: t(\"No login providers available.\");\n\t\thost.showStatus(message);\n\t\treturn;\n\t}\n\n\thost.showAuthSelector((done) => {\n\t\tconst selector = new OAuthSelectorComponent(\n\t\t\t\"login\",\n\t\t\tproviderOptions,\n\t\t\tasync (providerId, selectedAuthType) => {\n\t\t\t\tdone();\n\n\t\t\t\tconst providerOption = providerOptions.find(\n\t\t\t\t\t(provider) => provider.id === providerId && provider.authType === selectedAuthType,\n\t\t\t\t);\n\t\t\t\tif (!providerOption) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tawait host.startProviderLogin(providerOption);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\tif (authType) {\n\t\t\t\t\thost.showLoginAuthTypeSelector();\n\t\t\t\t} else {\n\t\t\t\t\thost.ui.requestRender();\n\t\t\t\t}\n\t\t\t},\n\t\t\tinitialSearchInput,\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport async function showOAuthSelector(host: AuthUiHost, mode: \"login\" | \"logout\"): Promise<void> {\n\tif (mode === \"login\") {\n\t\thost.showLoginAuthTypeSelector();\n\t\treturn;\n\t}\n\n\tlet providerOptions: AuthSelectorProvider[];\n\ttry {\n\t\tproviderOptions = await host.getLogoutProviderOptions();\n\t} catch (error) {\n\t\thost.showError(\n\t\t\tt(\"Could not read stored credentials: {error}\", {\n\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t}),\n\t\t);\n\t\treturn;\n\t}\n\tif (providerOptions.length === 0) {\n\t\thost.showStatus(\n\t\t\tt(\n\t\t\t\t\"No stored credentials to remove. /logout only removes credentials saved by /login; environment variables and models.json config are unchanged.\",\n\t\t\t),\n\t\t);\n\t\treturn;\n\t}\n\n\thost.showAuthSelector((done) => {\n\t\tconst selector = new OAuthSelectorComponent(\n\t\t\tmode,\n\t\t\tproviderOptions,\n\t\t\tasync (providerId: string) => {\n\t\t\t\tdone();\n\n\t\t\t\tconst providerOption = providerOptions.find((provider) => provider.id === providerId);\n\t\t\t\tif (!providerOption) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait host.getModelAuthRuntime().logout(providerOption.id, {\n\t\t\t\t\t\tsignal: AbortSignal.timeout(15_000),\n\t\t\t\t\t});\n\t\t\t\t\tawait host.updateAvailableProviderCount();\n\t\t\t\t\tconst message =\n\t\t\t\t\t\tproviderOption.authType === \"oauth\"\n\t\t\t\t\t\t\t? t(\"Logged out of {name}\", { name: providerOption.name })\n\t\t\t\t\t\t\t: t(\n\t\t\t\t\t\t\t\t\t\"Removed stored API key for {name}. Environment variables and models.json config are unchanged.\",\n\t\t\t\t\t\t\t\t\t{ name: providerOption.name },\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\thost.showStatus(message);\n\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\thost.showError(\n\t\t\t\t\t\terror instanceof CredentialSynchronizationError\n\t\t\t\t\t\t\t? t(\"Credentials removed for {name}, but local model state could not be synchronized: {error}\", {\n\t\t\t\t\t\t\t\t\tname: providerOption.name,\n\t\t\t\t\t\t\t\t\terror: message,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t: t(\"Logout failed: {error}\", { error: message }),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\thost.ui.requestRender();\n\t\t\t},\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport async function completeProviderAuthentication(\n\thost: AuthUiHost,\n\tproviderId: string,\n\tproviderName: string,\n\tauthType: \"oauth\" | \"api_key\",\n\tpreviousModel: Model<Api> | undefined,\n): Promise<void> {\n\tconst actionLabel =\n\t\tauthType === \"oauth\"\n\t\t\t? t(\"Logged in to {name}\", { name: providerName })\n\t\t\t: t(\"Saved API key for {name}\", { name: providerName });\n\n\t// Opaque identity of the session that started this login; the rebind check\n\t// below compares against it through the host.\n\tconst sessionIdentity = host.getSessionIdentity();\n\t// Dynamic catalogs may be empty until the first authenticated network refresh.\n\tconst deferSelection =\n\t\tisUnknownModel(previousModel) &&\n\t\thasDefaultModelProvider(providerId) &&\n\t\t!host\n\t\t\t.getAvailableModels()\n\t\t\t.some((model) => model.provider === providerId && model.id === defaultModelPerProvider[providerId]);\n\tconst finishAuthentication = async () => {\n\t\tlet selectedModel: Model<Api> | undefined;\n\t\tlet selectionError: string | undefined;\n\t\tif (isUnknownModel(previousModel)) {\n\t\t\tconst availableModels = host.getAvailableModels();\n\t\t\tconst providerModels = availableModels.filter((model) => model.provider === providerId);\n\t\t\t// Matches LLAMA_PROVIDER_ID from extensions/llama/provider.ts; kept inline to avoid coupling interactive mode to the built-in extension.\n\t\t\tif (providerId === \"llama.cpp\") {\n\t\t\t\tselectionError = llamaCppPostLoginGuidance(actionLabel, providerModels.length);\n\t\t\t} else if (!hasDefaultModelProvider(providerId)) {\n\t\t\t\tselectionError = t(\n\t\t\t\t\t'{action}, but no default model is configured for provider \"{providerId}\". Use /model to select a model.',\n\t\t\t\t\t{ action: actionLabel, providerId },\n\t\t\t\t);\n\t\t\t} else if (providerModels.length === 0) {\n\t\t\t\tselectionError = t(\n\t\t\t\t\t\"{action}, but no models are available for that provider. Use /model to select a model.\",\n\t\t\t\t\t{\n\t\t\t\t\t\taction: actionLabel,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst defaultModelId = defaultModelPerProvider[providerId];\n\t\t\t\tselectedModel = providerModels.find((model) => model.id === defaultModelId);\n\t\t\t\tif (!selectedModel) {\n\t\t\t\t\tselectionError = t(\n\t\t\t\t\t\t'{action}, but its default model \"{modelId}\" is not available. Use /model to select a model.',\n\t\t\t\t\t\t{ action: actionLabel, modelId: defaultModelId },\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait host.setSelectedModel(selectedModel);\n\t\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\t\tselectedModel = undefined;\n\t\t\t\t\t\tconst errorMessage = error instanceof Error ? error.message : String(error);\n\t\t\t\t\t\tselectionError = t(\n\t\t\t\t\t\t\t\"{action}, but selecting its default model failed: {error}. Use /model to select a model.\",\n\t\t\t\t\t\t\t{ action: actionLabel, error: errorMessage },\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tawait host.updateAvailableProviderCount();\n\t\thost.invalidateFooter();\n\t\thost.updateEditorBorderColor();\n\t\tif (selectedModel) {\n\t\t\thost.showStatus(\n\t\t\t\tt(\"{action}. Selected {modelId}. Credentials saved to {path}\", {\n\t\t\t\t\taction: actionLabel,\n\t\t\t\t\tmodelId: selectedModel.id,\n\t\t\t\t\tpath: getAuthPath(),\n\t\t\t\t}),\n\t\t\t);\n\t\t\tvoid host.maybeWarnAboutAnthropicSubscriptionAuth(selectedModel);\n\t\t\thost.checkDaxnutsEasterEgg(selectedModel);\n\t\t} else {\n\t\t\thost.showStatus(t(\"{action}. Credentials saved to {path}\", { action: actionLabel, path: getAuthPath() }));\n\t\t\tif (selectionError) {\n\t\t\t\thost.showError(selectionError);\n\t\t\t} else {\n\t\t\t\tvoid host.maybeWarnAboutAnthropicSubscriptionAuth();\n\t\t\t}\n\t\t}\n\t};\n\tif (deferSelection) {\n\t\thost.showStatus(\n\t\t\tt(\"{action}. Credentials saved to {path}. Refreshing model catalog…\", {\n\t\t\t\taction: actionLabel,\n\t\t\t\tpath: getAuthPath(),\n\t\t\t}),\n\t\t);\n\t} else {\n\t\tawait finishAuthentication();\n\t}\n\n\tconst controller = new AbortController();\n\tconst timeout = setTimeout(() => controller.abort(), 15_000);\n\tvoid host\n\t\t.getModelCatalog()\n\t\t.refresh({ providers: [providerId], signal: controller.signal })\n\t\t.then(async (result) => {\n\t\t\tif (result.aborted) {\n\t\t\t\thost.showWarning(\n\t\t\t\t\tt(\"{action}, but its model catalog refresh timed out; using cached models.\", { action: actionLabel }),\n\t\t\t\t);\n\t\t\t} else if (result.errors.size > 0) {\n\t\t\t\thost.showWarning(\n\t\t\t\t\tt(\"{action}, but its model catalog could not be refreshed; using cached models.\", {\n\t\t\t\t\t\taction: actionLabel,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\t// Do not replace a model or session selected while the refresh was running.\n\t\t\tif (\n\t\t\t\tdeferSelection &&\n\t\t\t\thost.isSameSessionIdentity(sessionIdentity) &&\n\t\t\t\thost.getSelectedModel() === previousModel\n\t\t\t) {\n\t\t\t\tawait finishAuthentication();\n\t\t\t}\n\t\t\thost.updateAvailableProviderCount();\n\t\t\thost.invalidateFooter();\n\t\t\thost.ui.requestRender();\n\t\t})\n\t\t.catch((error: unknown) => {\n\t\t\thost.showWarning(\n\t\t\t\tt(\"{action}, but its model catalog could not be refreshed: {error}\", {\n\t\t\t\t\taction: actionLabel,\n\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t}),\n\t\t\t);\n\t\t})\n\t\t.finally(() => clearTimeout(timeout));\n}\n\nexport function showAmbientAuthDialog(host: AuthUiHost, providerOption: AuthSelectorProvider): void {\n\tconst restoreEditor = () => {\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(host.editor);\n\t\thost.ui.setFocus(host.editor);\n\t\thost.ui.requestRender();\n\t};\n\n\tconst dialog = new LoginDialogComponent(\n\t\thost.ui,\n\t\tproviderOption.id,\n\t\t() => restoreEditor(),\n\t\tproviderOption.name,\n\t\tt(\"{name} setup\", { name: providerOption.name }),\n\t);\n\tdialog.showInfo(\n\t\tt(\"{method} is configured outside {appName}.\", {\n\t\t\tmethod: providerOption.method?.name ?? t(\"Authentication\"),\n\t\t\tappName: APP_NAME,\n\t\t}),\n\t\t[],\n\t\ttrue,\n\t);\n\n\thost.editorContainer.clear();\n\thost.editorContainer.addChild(dialog);\n\thost.ui.setFocus(dialog);\n\thost.ui.requestRender();\n}\n\nexport async function showApiKeyLoginDialog(host: AuthUiHost, providerId: string, providerName: string): Promise<void> {\n\tconst previousModel = host.getSelectedModel();\n\n\tconst dialog = new LoginDialogComponent(\n\t\thost.ui,\n\t\tproviderId,\n\t\t(_success, _message) => {\n\t\t\t// Completion handled below\n\t\t},\n\t\tproviderName,\n\t);\n\n\tif (providerId === \"amazon-bedrock\") {\n\t\tdialog.showDetails([\n\t\t\ttheme.fg(\"text\", t(\"You can also use an AWS profile, IAM keys, or role-based credentials.\")),\n\t\t\ttheme.fg(\"muted\", t(\"See:\")),\n\t\t\ttheme.fg(\"accent\", ` ${path.join(getDocsPath(), \"providers.md\")}`),\n\t\t]);\n\t}\n\n\thost.editorContainer.clear();\n\thost.editorContainer.addChild(dialog);\n\thost.ui.setFocus(dialog);\n\thost.ui.requestRender();\n\n\tconst restoreEditor = () => {\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(host.editor);\n\t\thost.ui.setFocus(host.editor);\n\t\thost.ui.requestRender();\n\t};\n\n\ttry {\n\t\tawait host.loginProvider(dialog, providerId, \"api_key\");\n\t\trestoreEditor();\n\t\tawait host.completeProviderAuthentication(providerId, providerName, \"api_key\", previousModel);\n\t} catch (error: unknown) {\n\t\trestoreEditor();\n\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\tif (error instanceof CredentialSynchronizationError) {\n\t\t\thost.showError(\n\t\t\t\tt(\"Saved API key for {name}, but local model state could not be synchronized: {error}\", {\n\t\t\t\t\tname: providerName,\n\t\t\t\t\terror: errorMsg,\n\t\t\t\t}),\n\t\t\t);\n\t\t} else if (errorMsg !== t(\"Login cancelled\")) {\n\t\t\thost.showError(t(\"Failed to save API key for {name}: {error}\", { name: providerName, error: errorMsg }));\n\t\t}\n\t}\n}\n\nexport function showAuthSelect(\n\thost: AuthUiHost,\n\tdialog: LoginDialogComponent,\n\tprompt: Extract<AuthPrompt, { type: \"select\" }>,\n): Promise<string> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst restoreDialog = () => {\n\t\t\thost.editorContainer.clear();\n\t\t\thost.editorContainer.addChild(dialog);\n\t\t\thost.ui.setFocus(dialog);\n\t\t\thost.ui.requestRender();\n\t\t};\n\t\tconst labels = prompt.options.map((option) => option.label);\n\t\tconst selector = new DialogSelectorComponent(\n\t\t\tprompt.message,\n\t\t\tlabels,\n\t\t\t(optionLabel) => {\n\t\t\t\trestoreDialog();\n\t\t\t\tconst id = prompt.options.find((option) => option.label === optionLabel)?.id;\n\t\t\t\t// v8 ignore next -- 选项列表由 prompt.options 派生,选中项必能找到\n\t\t\t\tif (id) resolve(id);\n\t\t\t\telse reject(new Error(t(\"Login cancelled\")));\n\t\t\t},\n\t\t\t() => {\n\t\t\t\trestoreDialog();\n\t\t\t\treject(new Error(t(\"Login cancelled\")));\n\t\t\t},\n\t\t);\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(selector);\n\t\thost.ui.setFocus(selector);\n\t\thost.ui.requestRender();\n\t});\n}\n\nexport async function showAuthPrompt(\n\thost: AuthUiHost,\n\tdialog: LoginDialogComponent,\n\tprompt: AuthPrompt,\n): Promise<string> {\n\tlet response: Promise<string>;\n\tif (prompt.type === \"select\") {\n\t\tresponse = host.showAuthSelect(dialog, prompt);\n\t} else if (prompt.type === \"manual_code\") {\n\t\tresponse = dialog.showManualInput(prompt.message);\n\t} else {\n\t\tresponse = dialog.showPrompt(prompt.message, prompt.placeholder);\n\t}\n\tif (!prompt.signal) return response;\n\tif (prompt.signal.aborted) throw new Error(t(\"Login cancelled\"));\n\tconst signal = prompt.signal;\n\tlet onAbort: (() => void) | undefined;\n\tconst aborted = new Promise<string>((_resolve, reject) => {\n\t\tonAbort = () => reject(new Error(t(\"Login cancelled\")));\n\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n\ttry {\n\t\treturn await Promise.race([response, aborted]);\n\t} finally {\n\t\t// v8 ignore next -- onAbort 在 Promise executor 中同步赋值,恒已定义\n\t\tif (onAbort) signal.removeEventListener(\"abort\", onAbort);\n\t}\n}\n\nexport function notifyAuthDialog(_host: AuthUiHost, dialog: LoginDialogComponent, event: AuthEvent): void {\n\tif (event.type === \"auth_url\") {\n\t\tdialog.showAuth(event.url, event.instructions);\n\t} else if (event.type === \"device_code\") {\n\t\tdialog.showDeviceCode(event);\n\t\tdialog.showWaiting(t(\"Waiting for authentication...\"));\n\t} else if (event.type === \"info\") {\n\t\tdialog.showInfo(event.message, event.links);\n\t} else {\n\t\tdialog.showProgress(event.message);\n\t}\n}\n\nexport async function loginProvider(\n\thost: AuthUiHost,\n\tdialog: LoginDialogComponent,\n\tproviderId: string,\n\tmethod: \"api_key\" | \"oauth\",\n): Promise<void> {\n\tawait host.getModelAuthRuntime().login(providerId, method, {\n\t\tsignal: dialog.signal,\n\t\tprompt: (prompt) => host.showAuthPrompt(dialog, prompt),\n\t\tnotify: (event) => host.notifyAuthDialog(dialog, event),\n\t});\n}\n\nexport async function showLoginDialog(host: AuthUiHost, providerId: string, providerName: string): Promise<void> {\n\tconst previousModel = host.getSelectedModel();\n\tconst dialog = new LoginDialogComponent(host.ui, providerId, (_success, _message) => {}, providerName);\n\thost.editorContainer.clear();\n\thost.editorContainer.addChild(dialog);\n\thost.ui.setFocus(dialog);\n\thost.ui.requestRender();\n\n\tconst restoreEditor = () => {\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(host.editor);\n\t\thost.ui.setFocus(host.editor);\n\t\thost.ui.requestRender();\n\t};\n\n\ttry {\n\t\tawait host.loginProvider(dialog, providerId, \"oauth\");\n\t\trestoreEditor();\n\t\tawait host.completeProviderAuthentication(providerId, providerName, \"oauth\", previousModel);\n\t} catch (error: unknown) {\n\t\trestoreEditor();\n\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\tif (error instanceof CredentialSynchronizationError) {\n\t\t\thost.showError(\n\t\t\t\tt(\"Logged in to {name}, but local model state could not be synchronized: {error}\", {\n\t\t\t\t\tname: providerName,\n\t\t\t\t\terror: errorMsg,\n\t\t\t\t}),\n\t\t\t);\n\t\t} else if (errorMsg !== t(\"Login cancelled\")) {\n\t\t\thost.showError(t(\"Failed to login to {name}: {error}\", { name: providerName, error: errorMsg }));\n\t\t}\n\t}\n}\n"]}
|
|
@@ -20,11 +20,11 @@ import { APP_NAME, getAuthPath, getDocsPath } from "../../config.js";
|
|
|
20
20
|
import { t } from "../../core/i18n/index.js";
|
|
21
21
|
import { defaultModelPerProvider } from "../../core/model-resolver.js";
|
|
22
22
|
import { CredentialSynchronizationError } from "../../core/model-runtime.js";
|
|
23
|
+
import { theme } from "../../theme/theme.js";
|
|
23
24
|
import { DialogSelectorComponent } from "./components/dialog-selector.js";
|
|
24
25
|
import { LoginDialogComponent } from "./components/login-dialog.js";
|
|
25
26
|
import { OAuthSelectorComponent } from "./components/oauth-selector.js";
|
|
26
27
|
import { hasDefaultModelProvider, isUnknownModel, llamaCppPostLoginGuidance } from "./interactive-helpers.js";
|
|
27
|
-
import { theme } from "./theme/theme.js";
|
|
28
28
|
export function getLoginProviderOptions(host, authType) {
|
|
29
29
|
const options = [];
|
|
30
30
|
for (const provider of host.getModelAuthRuntime().getProviders()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-auth.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAIlC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAErE,OAAO,EAAE,CAAC,EAAE,MAAM,0BAA0B,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAA6B,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACnG,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAE9G,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAoEzC,MAAM,UAAU,uBAAuB,CAAC,IAAgB,EAAE,QAA8B,EAA0B;IACjH,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC,YAAY,EAAE,EAAE,CAAC;QAClE,MAAM,UAAU,GAAG,IAAI,CAA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,YAAY,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;IAC7F,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACzB,aAAa,EAAE,CAAC;QAChB,MAAM,QAAQ,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACxE,IAAI,KAAK,YAAY,8BAA8B,EAAE,CAAC;YACrD,IAAI,CAAC,SAAS,CACb,CAAC,CAAC,+EAA+E,EAAE;gBAClF,IAAI,EAAE,YAAY;gBAClB,KAAK,EAAE,QAAQ;aACf,CAAC,CACF,CAAC;QACH,CAAC;aAAM,IAAI,QAAQ,KAAK,CAAC,CAAC,iBAAiB,CAAC,EAAE,CAAC;YAC9C,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,oCAAoC,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;QAClG,CAAC;IACF,CAAC;AAAA,CACD","sourcesContent":["/**\n * Login/authentication flow for interactive mode (S5 slice 3): provider\n * option collection, the /login and /logout selectors, the OAuth and API-key\n * login dialogs, auth prompt plumbing, and post-login completion.\n *\n * InteractiveMode implements AuthUiHost and keeps same-name delegate methods\n * so prototype-level tests and the command dispatch table keep working; the\n * functions below receive the mode through AuthUiHost and route every call —\n * including steps between auth methods — through the host, mirroring the\n * DialogUiHost pattern in ./interactive-dialog-ui.ts. Credential/provider\n * auth, model snapshot, catalog refresh, facade, and session-identity access go\n * through narrow host accessors (D-048: facade projections) so this module\n * never reads session internals directly.\n *\n * Internal collaboration interface (same pattern as CommandDispatchHost): not\n * a plugin API and not exported from the package root.\n */\nimport * as path from \"node:path\";\nimport type { AuthEvent, AuthPrompt } from \"@agent-forge/ai\";\nimport type { Api, Model } from \"@agent-forge/ai/compat\";\nimport type { Component, Container, EditorComponent, TUI } from \"@agent-forge/tui\";\nimport { APP_NAME, getAuthPath, getDocsPath } from \"../../config.ts\";\nimport type { ModelAuthRuntime } from \"../../core/facade/coding-agent-facade.ts\";\nimport { t } from \"../../core/i18n/index.ts\";\nimport { defaultModelPerProvider } from \"../../core/model-resolver.ts\";\nimport { CredentialSynchronizationError } from \"../../core/model-runtime.ts\";\nimport { DialogSelectorComponent } from \"./components/dialog-selector.ts\";\nimport { LoginDialogComponent } from \"./components/login-dialog.ts\";\nimport { type AuthSelectorProvider, OAuthSelectorComponent } from \"./components/oauth-selector.ts\";\nimport { hasDefaultModelProvider, isUnknownModel, llamaCppPostLoginGuidance } from \"./interactive-helpers.ts\";\nimport type { ModelCatalogRuntime } from \"./model-catalog-refresh.ts\";\nimport { theme } from \"./theme/theme.ts\";\n\n/**\n * Host surface InteractiveMode exposes to this module: the auth-flow methods\n * (which stay on the mode for dispatch and prototype-level tests) plus narrow\n * accessors for the session runtime, facade operations, and selector surface.\n *\n * Internal collaboration interface (same pattern as CommandDispatchHost): not\n * a plugin API and not exported from the package root.\n */\nexport interface AuthUiHost {\n\t/**\n\t * Narrow credential/provider auth projection through the stable facade\n\t * (D-048); the full runtime stays on the session.\n\t */\n\tgetModelAuthRuntime(): ModelAuthRuntime;\n\t/** Narrow catalog-refresh projection through the stable facade (D-048). */\n\tgetModelCatalog(): ModelCatalogRuntime;\n\t/** Available model snapshot through the stable facade (D-048). */\n\tgetAvailableModels(): readonly Model<Api>[];\n\t/** Opaque current-session identity token for post-login rebind checks. */\n\tgetSessionIdentity(): unknown;\n\tisSameSessionIdentity(identity: unknown): boolean;\n\t/** Selected model through the stable facade. */\n\tgetSelectedModel(): Model<Api> | undefined;\n\t/** Persists a model selection through the stable facade. */\n\tsetSelectedModel(model: Model<Api>): Promise<void>;\n\n\tui: TUI;\n\teditor: EditorComponent;\n\teditorContainer: Container;\n\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n\tshowWarning(message: string): void;\n\t/** Selector surface; the implementation stays in the mode's selector area. */\n\tshowAuthSelector(\n\t\tcreate: (done: () => void) => { component: Component; focus: Component; dispose?: () => void },\n\t): void;\n\tupdateAvailableProviderCount(): void;\n\tmaybeWarnAboutAnthropicSubscriptionAuth(model?: Model<Api>): Promise<void>;\n\tcheckDaxnutsEasterEgg(model: { provider: string; id: string }): void;\n\tinvalidateFooter(): void;\n\tupdateEditorBorderColor(): void;\n\n\tgetLoginProviderOptions(authType?: \"oauth\" | \"api_key\"): AuthSelectorProvider[];\n\tgetLogoutProviderOptions(): Promise<AuthSelectorProvider[]>;\n\tfindLoginProviderOptions(providerRef: string): AuthSelectorProvider[];\n\thandleLoginCommand(providerRef?: string): Promise<void>;\n\tstartProviderLogin(providerOption: AuthSelectorProvider): Promise<void>;\n\tshowLoginAuthTypeSelector(providerOptions?: AuthSelectorProvider[]): void;\n\tshowLoginProviderSelector(authType?: AuthSelectorProvider[\"authType\"], initialSearchInput?: string): void;\n\tshowOAuthSelector(mode: \"login\" | \"logout\"): Promise<void>;\n\tcompleteProviderAuthentication(\n\t\tproviderId: string,\n\t\tproviderName: string,\n\t\tauthType: \"oauth\" | \"api_key\",\n\t\tpreviousModel: Model<Api> | undefined,\n\t): Promise<void>;\n\tshowAmbientAuthDialog(providerOption: AuthSelectorProvider): void;\n\tshowApiKeyLoginDialog(providerId: string, providerName: string): Promise<void>;\n\tshowAuthSelect(dialog: LoginDialogComponent, prompt: Extract<AuthPrompt, { type: \"select\" }>): Promise<string>;\n\tshowAuthPrompt(dialog: LoginDialogComponent, prompt: AuthPrompt): Promise<string>;\n\tnotifyAuthDialog(dialog: LoginDialogComponent, event: AuthEvent): void;\n\tloginProvider(dialog: LoginDialogComponent, providerId: string, method: \"api_key\" | \"oauth\"): Promise<void>;\n\tshowLoginDialog(providerId: string, providerName: string): Promise<void>;\n}\n\nexport function getLoginProviderOptions(host: AuthUiHost, authType?: \"oauth\" | \"api_key\"): AuthSelectorProvider[] {\n\tconst options: AuthSelectorProvider[] = [];\n\tfor (const provider of host.getModelAuthRuntime().getProviders()) {\n\t\tconst authStatus = host.getModelAuthRuntime().getProviderAuthStatus(provider.id);\n\t\tconst status = authStatus.configured\n\t\t\t? {\n\t\t\t\t\ttype: host.getModelAuthRuntime().isUsingOAuth(provider.id) ? (\"oauth\" as const) : (\"api_key\" as const),\n\t\t\t\t\tsource: authStatus.label ?? authStatus.source,\n\t\t\t\t}\n\t\t\t: undefined;\n\t\tif ((!authType || authType === \"oauth\") && provider.auth.oauth) {\n\t\t\toptions.push({\n\t\t\t\tid: provider.id,\n\t\t\t\tname: provider.name,\n\t\t\t\tauthType: \"oauth\",\n\t\t\t\tmethod: provider.auth.oauth,\n\t\t\t\tstatus,\n\t\t\t});\n\t\t}\n\t\tif ((!authType || authType === \"api_key\") && provider.auth.apiKey) {\n\t\t\toptions.push({\n\t\t\t\tid: provider.id,\n\t\t\t\tname: provider.name,\n\t\t\t\tauthType: \"api_key\",\n\t\t\t\tmethod: provider.auth.apiKey,\n\t\t\t\tstatus,\n\t\t\t});\n\t\t}\n\t}\n\treturn options.sort((a, b) => a.name.localeCompare(b.name));\n}\n\nexport async function getLogoutProviderOptions(host: AuthUiHost): Promise<AuthSelectorProvider[]> {\n\treturn (await host.getModelAuthRuntime().listCredentials({ signal: AbortSignal.timeout(15_000) }))\n\t\t.map(({ providerId, type }) => ({\n\t\t\tid: providerId,\n\t\t\tname: host.getModelAuthRuntime().getProvider(providerId)?.name ?? providerId,\n\t\t\tauthType: type,\n\t\t\tstatus: { type, source: \"stored credential\" },\n\t\t}))\n\t\t.sort((a, b) => a.name.localeCompare(b.name));\n}\n\nexport function findLoginProviderOptions(host: AuthUiHost, providerRef: string): AuthSelectorProvider[] {\n\tconst normalizedProviderRef = providerRef.trim().toLowerCase();\n\tif (!normalizedProviderRef) {\n\t\treturn [];\n\t}\n\n\treturn host\n\t\t.getLoginProviderOptions()\n\t\t.filter(\n\t\t\t(provider) =>\n\t\t\t\tprovider.id.toLowerCase() === normalizedProviderRef ||\n\t\t\t\tprovider.name.toLowerCase() === normalizedProviderRef,\n\t\t);\n}\n\nexport async function handleLoginCommand(host: AuthUiHost, providerRef?: string): Promise<void> {\n\tif (!providerRef) {\n\t\thost.showLoginAuthTypeSelector();\n\t\treturn;\n\t}\n\n\tconst providerOptions = host.findLoginProviderOptions(providerRef);\n\tif (providerOptions.length === 1) {\n\t\tawait host.startProviderLogin(providerOptions[0]!);\n\t\treturn;\n\t}\n\n\tif (providerOptions.length > 1) {\n\t\tconst providerIds = new Set(providerOptions.map((provider) => provider.id));\n\t\tif (providerIds.size === 1) {\n\t\t\thost.showLoginAuthTypeSelector(providerOptions);\n\t\t\treturn;\n\t\t}\n\t}\n\n\thost.showLoginProviderSelector(undefined, providerRef);\n}\n\nexport async function startProviderLogin(host: AuthUiHost, providerOption: AuthSelectorProvider): Promise<void> {\n\tif (providerOption.authType === \"oauth\") {\n\t\tawait host.showLoginDialog(providerOption.id, providerOption.name);\n\t} else if (providerOption.method?.login) {\n\t\tawait host.showApiKeyLoginDialog(providerOption.id, providerOption.name);\n\t} else {\n\t\thost.showAmbientAuthDialog(providerOption);\n\t}\n}\n\nexport function showLoginAuthTypeSelector(host: AuthUiHost, providerOptions?: AuthSelectorProvider[]): void {\n\tconst oauthProvider = providerOptions?.find((provider) => provider.authType === \"oauth\");\n\tconst oauthLoginLabel =\n\t\toauthProvider?.method && \"loginLabel\" in oauthProvider.method ? oauthProvider.method.loginLabel : undefined;\n\tconst subscriptionLabel = oauthLoginLabel ?? t(\"Sign in with an account\");\n\tconst apiKeyLabel = t(\"Sign in with an API key\");\n\tconst availableAuthTypes = providerOptions\n\t\t? new Set(providerOptions.map((provider) => provider.authType))\n\t\t: new Set<AuthSelectorProvider[\"authType\"]>([\"oauth\", \"api_key\"]);\n\tconst options: string[] = [];\n\tif (availableAuthTypes.has(\"oauth\")) {\n\t\toptions.push(subscriptionLabel);\n\t}\n\tif (availableAuthTypes.has(\"api_key\")) {\n\t\toptions.push(apiKeyLabel);\n\t}\n\n\tif (options.length === 0) {\n\t\thost.showStatus(t(\"No login methods available.\"));\n\t\treturn;\n\t}\n\n\tif (providerOptions && options.length === 1) {\n\t\tconst providerOption = providerOptions[0];\n\t\t// v8 ignore next -- options.length === 1 已保证 providerOptions 非空,[0] 恒存在\n\t\tif (providerOption) {\n\t\t\tvoid host.startProviderLogin(providerOption);\n\t\t}\n\t\treturn;\n\t}\n\n\tconst title = providerOptions?.[0]\n\t\t? t(\"Select authentication method for {name}:\", { name: providerOptions[0].name })\n\t\t: t(\"Select authentication method:\");\n\thost.showAuthSelector((done) => {\n\t\tconst selector = new DialogSelectorComponent(\n\t\t\ttitle,\n\t\t\toptions,\n\t\t\t(option) => {\n\t\t\t\tdone();\n\t\t\t\tconst authType = option === subscriptionLabel ? \"oauth\" : \"api_key\";\n\t\t\t\tif (providerOptions) {\n\t\t\t\t\tconst providerOption = providerOptions.find((provider) => provider.authType === authType);\n\t\t\t\t\t// v8 ignore next -- 选项列表由 providerOptions 的 authTypes 派生,必能找到\n\t\t\t\t\tif (providerOption) {\n\t\t\t\t\t\tvoid host.startProviderLogin(providerOption);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\thost.showLoginProviderSelector(authType);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\thost.ui.requestRender();\n\t\t\t},\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport function showLoginProviderSelector(\n\thost: AuthUiHost,\n\tauthType?: AuthSelectorProvider[\"authType\"],\n\tinitialSearchInput?: string,\n): void {\n\tconst providerOptions = host.getLoginProviderOptions(authType);\n\tif (providerOptions.length === 0) {\n\t\tconst message =\n\t\t\tauthType === \"oauth\"\n\t\t\t\t? t(\"No subscription providers available.\")\n\t\t\t\t: authType === \"api_key\"\n\t\t\t\t\t? t(\"No API key providers available.\")\n\t\t\t\t\t: t(\"No login providers available.\");\n\t\thost.showStatus(message);\n\t\treturn;\n\t}\n\n\thost.showAuthSelector((done) => {\n\t\tconst selector = new OAuthSelectorComponent(\n\t\t\t\"login\",\n\t\t\tproviderOptions,\n\t\t\tasync (providerId, selectedAuthType) => {\n\t\t\t\tdone();\n\n\t\t\t\tconst providerOption = providerOptions.find(\n\t\t\t\t\t(provider) => provider.id === providerId && provider.authType === selectedAuthType,\n\t\t\t\t);\n\t\t\t\tif (!providerOption) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tawait host.startProviderLogin(providerOption);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\tif (authType) {\n\t\t\t\t\thost.showLoginAuthTypeSelector();\n\t\t\t\t} else {\n\t\t\t\t\thost.ui.requestRender();\n\t\t\t\t}\n\t\t\t},\n\t\t\tinitialSearchInput,\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport async function showOAuthSelector(host: AuthUiHost, mode: \"login\" | \"logout\"): Promise<void> {\n\tif (mode === \"login\") {\n\t\thost.showLoginAuthTypeSelector();\n\t\treturn;\n\t}\n\n\tlet providerOptions: AuthSelectorProvider[];\n\ttry {\n\t\tproviderOptions = await host.getLogoutProviderOptions();\n\t} catch (error) {\n\t\thost.showError(\n\t\t\tt(\"Could not read stored credentials: {error}\", {\n\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t}),\n\t\t);\n\t\treturn;\n\t}\n\tif (providerOptions.length === 0) {\n\t\thost.showStatus(\n\t\t\tt(\n\t\t\t\t\"No stored credentials to remove. /logout only removes credentials saved by /login; environment variables and models.json config are unchanged.\",\n\t\t\t),\n\t\t);\n\t\treturn;\n\t}\n\n\thost.showAuthSelector((done) => {\n\t\tconst selector = new OAuthSelectorComponent(\n\t\t\tmode,\n\t\t\tproviderOptions,\n\t\t\tasync (providerId: string) => {\n\t\t\t\tdone();\n\n\t\t\t\tconst providerOption = providerOptions.find((provider) => provider.id === providerId);\n\t\t\t\tif (!providerOption) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait host.getModelAuthRuntime().logout(providerOption.id, {\n\t\t\t\t\t\tsignal: AbortSignal.timeout(15_000),\n\t\t\t\t\t});\n\t\t\t\t\tawait host.updateAvailableProviderCount();\n\t\t\t\t\tconst message =\n\t\t\t\t\t\tproviderOption.authType === \"oauth\"\n\t\t\t\t\t\t\t? t(\"Logged out of {name}\", { name: providerOption.name })\n\t\t\t\t\t\t\t: t(\n\t\t\t\t\t\t\t\t\t\"Removed stored API key for {name}. Environment variables and models.json config are unchanged.\",\n\t\t\t\t\t\t\t\t\t{ name: providerOption.name },\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\thost.showStatus(message);\n\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\thost.showError(\n\t\t\t\t\t\terror instanceof CredentialSynchronizationError\n\t\t\t\t\t\t\t? t(\"Credentials removed for {name}, but local model state could not be synchronized: {error}\", {\n\t\t\t\t\t\t\t\t\tname: providerOption.name,\n\t\t\t\t\t\t\t\t\terror: message,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t: t(\"Logout failed: {error}\", { error: message }),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\thost.ui.requestRender();\n\t\t\t},\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport async function completeProviderAuthentication(\n\thost: AuthUiHost,\n\tproviderId: string,\n\tproviderName: string,\n\tauthType: \"oauth\" | \"api_key\",\n\tpreviousModel: Model<Api> | undefined,\n): Promise<void> {\n\tconst actionLabel =\n\t\tauthType === \"oauth\"\n\t\t\t? t(\"Logged in to {name}\", { name: providerName })\n\t\t\t: t(\"Saved API key for {name}\", { name: providerName });\n\n\t// Opaque identity of the session that started this login; the rebind check\n\t// below compares against it through the host.\n\tconst sessionIdentity = host.getSessionIdentity();\n\t// Dynamic catalogs may be empty until the first authenticated network refresh.\n\tconst deferSelection =\n\t\tisUnknownModel(previousModel) &&\n\t\thasDefaultModelProvider(providerId) &&\n\t\t!host\n\t\t\t.getAvailableModels()\n\t\t\t.some((model) => model.provider === providerId && model.id === defaultModelPerProvider[providerId]);\n\tconst finishAuthentication = async () => {\n\t\tlet selectedModel: Model<Api> | undefined;\n\t\tlet selectionError: string | undefined;\n\t\tif (isUnknownModel(previousModel)) {\n\t\t\tconst availableModels = host.getAvailableModels();\n\t\t\tconst providerModels = availableModels.filter((model) => model.provider === providerId);\n\t\t\t// Matches LLAMA_PROVIDER_ID from extensions/llama/provider.ts; kept inline to avoid coupling interactive mode to the built-in extension.\n\t\t\tif (providerId === \"llama.cpp\") {\n\t\t\t\tselectionError = llamaCppPostLoginGuidance(actionLabel, providerModels.length);\n\t\t\t} else if (!hasDefaultModelProvider(providerId)) {\n\t\t\t\tselectionError = t(\n\t\t\t\t\t'{action}, but no default model is configured for provider \"{providerId}\". Use /model to select a model.',\n\t\t\t\t\t{ action: actionLabel, providerId },\n\t\t\t\t);\n\t\t\t} else if (providerModels.length === 0) {\n\t\t\t\tselectionError = t(\n\t\t\t\t\t\"{action}, but no models are available for that provider. Use /model to select a model.\",\n\t\t\t\t\t{\n\t\t\t\t\t\taction: actionLabel,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst defaultModelId = defaultModelPerProvider[providerId];\n\t\t\t\tselectedModel = providerModels.find((model) => model.id === defaultModelId);\n\t\t\t\tif (!selectedModel) {\n\t\t\t\t\tselectionError = t(\n\t\t\t\t\t\t'{action}, but its default model \"{modelId}\" is not available. Use /model to select a model.',\n\t\t\t\t\t\t{ action: actionLabel, modelId: defaultModelId },\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait host.setSelectedModel(selectedModel);\n\t\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\t\tselectedModel = undefined;\n\t\t\t\t\t\tconst errorMessage = error instanceof Error ? error.message : String(error);\n\t\t\t\t\t\tselectionError = t(\n\t\t\t\t\t\t\t\"{action}, but selecting its default model failed: {error}. Use /model to select a model.\",\n\t\t\t\t\t\t\t{ action: actionLabel, error: errorMessage },\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tawait host.updateAvailableProviderCount();\n\t\thost.invalidateFooter();\n\t\thost.updateEditorBorderColor();\n\t\tif (selectedModel) {\n\t\t\thost.showStatus(\n\t\t\t\tt(\"{action}. Selected {modelId}. Credentials saved to {path}\", {\n\t\t\t\t\taction: actionLabel,\n\t\t\t\t\tmodelId: selectedModel.id,\n\t\t\t\t\tpath: getAuthPath(),\n\t\t\t\t}),\n\t\t\t);\n\t\t\tvoid host.maybeWarnAboutAnthropicSubscriptionAuth(selectedModel);\n\t\t\thost.checkDaxnutsEasterEgg(selectedModel);\n\t\t} else {\n\t\t\thost.showStatus(t(\"{action}. Credentials saved to {path}\", { action: actionLabel, path: getAuthPath() }));\n\t\t\tif (selectionError) {\n\t\t\t\thost.showError(selectionError);\n\t\t\t} else {\n\t\t\t\tvoid host.maybeWarnAboutAnthropicSubscriptionAuth();\n\t\t\t}\n\t\t}\n\t};\n\tif (deferSelection) {\n\t\thost.showStatus(\n\t\t\tt(\"{action}. Credentials saved to {path}. Refreshing model catalog…\", {\n\t\t\t\taction: actionLabel,\n\t\t\t\tpath: getAuthPath(),\n\t\t\t}),\n\t\t);\n\t} else {\n\t\tawait finishAuthentication();\n\t}\n\n\tconst controller = new AbortController();\n\tconst timeout = setTimeout(() => controller.abort(), 15_000);\n\tvoid host\n\t\t.getModelCatalog()\n\t\t.refresh({ providers: [providerId], signal: controller.signal })\n\t\t.then(async (result) => {\n\t\t\tif (result.aborted) {\n\t\t\t\thost.showWarning(\n\t\t\t\t\tt(\"{action}, but its model catalog refresh timed out; using cached models.\", { action: actionLabel }),\n\t\t\t\t);\n\t\t\t} else if (result.errors.size > 0) {\n\t\t\t\thost.showWarning(\n\t\t\t\t\tt(\"{action}, but its model catalog could not be refreshed; using cached models.\", {\n\t\t\t\t\t\taction: actionLabel,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\t// Do not replace a model or session selected while the refresh was running.\n\t\t\tif (\n\t\t\t\tdeferSelection &&\n\t\t\t\thost.isSameSessionIdentity(sessionIdentity) &&\n\t\t\t\thost.getSelectedModel() === previousModel\n\t\t\t) {\n\t\t\t\tawait finishAuthentication();\n\t\t\t}\n\t\t\thost.updateAvailableProviderCount();\n\t\t\thost.invalidateFooter();\n\t\t\thost.ui.requestRender();\n\t\t})\n\t\t.catch((error: unknown) => {\n\t\t\thost.showWarning(\n\t\t\t\tt(\"{action}, but its model catalog could not be refreshed: {error}\", {\n\t\t\t\t\taction: actionLabel,\n\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t}),\n\t\t\t);\n\t\t})\n\t\t.finally(() => clearTimeout(timeout));\n}\n\nexport function showAmbientAuthDialog(host: AuthUiHost, providerOption: AuthSelectorProvider): void {\n\tconst restoreEditor = () => {\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(host.editor);\n\t\thost.ui.setFocus(host.editor);\n\t\thost.ui.requestRender();\n\t};\n\n\tconst dialog = new LoginDialogComponent(\n\t\thost.ui,\n\t\tproviderOption.id,\n\t\t() => restoreEditor(),\n\t\tproviderOption.name,\n\t\tt(\"{name} setup\", { name: providerOption.name }),\n\t);\n\tdialog.showInfo(\n\t\tt(\"{method} is configured outside {appName}.\", {\n\t\t\tmethod: providerOption.method?.name ?? t(\"Authentication\"),\n\t\t\tappName: APP_NAME,\n\t\t}),\n\t\t[],\n\t\ttrue,\n\t);\n\n\thost.editorContainer.clear();\n\thost.editorContainer.addChild(dialog);\n\thost.ui.setFocus(dialog);\n\thost.ui.requestRender();\n}\n\nexport async function showApiKeyLoginDialog(host: AuthUiHost, providerId: string, providerName: string): Promise<void> {\n\tconst previousModel = host.getSelectedModel();\n\n\tconst dialog = new LoginDialogComponent(\n\t\thost.ui,\n\t\tproviderId,\n\t\t(_success, _message) => {\n\t\t\t// Completion handled below\n\t\t},\n\t\tproviderName,\n\t);\n\n\tif (providerId === \"amazon-bedrock\") {\n\t\tdialog.showDetails([\n\t\t\ttheme.fg(\"text\", t(\"You can also use an AWS profile, IAM keys, or role-based credentials.\")),\n\t\t\ttheme.fg(\"muted\", t(\"See:\")),\n\t\t\ttheme.fg(\"accent\", ` ${path.join(getDocsPath(), \"providers.md\")}`),\n\t\t]);\n\t}\n\n\thost.editorContainer.clear();\n\thost.editorContainer.addChild(dialog);\n\thost.ui.setFocus(dialog);\n\thost.ui.requestRender();\n\n\tconst restoreEditor = () => {\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(host.editor);\n\t\thost.ui.setFocus(host.editor);\n\t\thost.ui.requestRender();\n\t};\n\n\ttry {\n\t\tawait host.loginProvider(dialog, providerId, \"api_key\");\n\t\trestoreEditor();\n\t\tawait host.completeProviderAuthentication(providerId, providerName, \"api_key\", previousModel);\n\t} catch (error: unknown) {\n\t\trestoreEditor();\n\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\tif (error instanceof CredentialSynchronizationError) {\n\t\t\thost.showError(\n\t\t\t\tt(\"Saved API key for {name}, but local model state could not be synchronized: {error}\", {\n\t\t\t\t\tname: providerName,\n\t\t\t\t\terror: errorMsg,\n\t\t\t\t}),\n\t\t\t);\n\t\t} else if (errorMsg !== t(\"Login cancelled\")) {\n\t\t\thost.showError(t(\"Failed to save API key for {name}: {error}\", { name: providerName, error: errorMsg }));\n\t\t}\n\t}\n}\n\nexport function showAuthSelect(\n\thost: AuthUiHost,\n\tdialog: LoginDialogComponent,\n\tprompt: Extract<AuthPrompt, { type: \"select\" }>,\n): Promise<string> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst restoreDialog = () => {\n\t\t\thost.editorContainer.clear();\n\t\t\thost.editorContainer.addChild(dialog);\n\t\t\thost.ui.setFocus(dialog);\n\t\t\thost.ui.requestRender();\n\t\t};\n\t\tconst labels = prompt.options.map((option) => option.label);\n\t\tconst selector = new DialogSelectorComponent(\n\t\t\tprompt.message,\n\t\t\tlabels,\n\t\t\t(optionLabel) => {\n\t\t\t\trestoreDialog();\n\t\t\t\tconst id = prompt.options.find((option) => option.label === optionLabel)?.id;\n\t\t\t\t// v8 ignore next -- 选项列表由 prompt.options 派生,选中项必能找到\n\t\t\t\tif (id) resolve(id);\n\t\t\t\telse reject(new Error(t(\"Login cancelled\")));\n\t\t\t},\n\t\t\t() => {\n\t\t\t\trestoreDialog();\n\t\t\t\treject(new Error(t(\"Login cancelled\")));\n\t\t\t},\n\t\t);\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(selector);\n\t\thost.ui.setFocus(selector);\n\t\thost.ui.requestRender();\n\t});\n}\n\nexport async function showAuthPrompt(\n\thost: AuthUiHost,\n\tdialog: LoginDialogComponent,\n\tprompt: AuthPrompt,\n): Promise<string> {\n\tlet response: Promise<string>;\n\tif (prompt.type === \"select\") {\n\t\tresponse = host.showAuthSelect(dialog, prompt);\n\t} else if (prompt.type === \"manual_code\") {\n\t\tresponse = dialog.showManualInput(prompt.message);\n\t} else {\n\t\tresponse = dialog.showPrompt(prompt.message, prompt.placeholder);\n\t}\n\tif (!prompt.signal) return response;\n\tif (prompt.signal.aborted) throw new Error(t(\"Login cancelled\"));\n\tconst signal = prompt.signal;\n\tlet onAbort: (() => void) | undefined;\n\tconst aborted = new Promise<string>((_resolve, reject) => {\n\t\tonAbort = () => reject(new Error(t(\"Login cancelled\")));\n\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n\ttry {\n\t\treturn await Promise.race([response, aborted]);\n\t} finally {\n\t\t// v8 ignore next -- onAbort 在 Promise executor 中同步赋值,恒已定义\n\t\tif (onAbort) signal.removeEventListener(\"abort\", onAbort);\n\t}\n}\n\nexport function notifyAuthDialog(_host: AuthUiHost, dialog: LoginDialogComponent, event: AuthEvent): void {\n\tif (event.type === \"auth_url\") {\n\t\tdialog.showAuth(event.url, event.instructions);\n\t} else if (event.type === \"device_code\") {\n\t\tdialog.showDeviceCode(event);\n\t\tdialog.showWaiting(t(\"Waiting for authentication...\"));\n\t} else if (event.type === \"info\") {\n\t\tdialog.showInfo(event.message, event.links);\n\t} else {\n\t\tdialog.showProgress(event.message);\n\t}\n}\n\nexport async function loginProvider(\n\thost: AuthUiHost,\n\tdialog: LoginDialogComponent,\n\tproviderId: string,\n\tmethod: \"api_key\" | \"oauth\",\n): Promise<void> {\n\tawait host.getModelAuthRuntime().login(providerId, method, {\n\t\tsignal: dialog.signal,\n\t\tprompt: (prompt) => host.showAuthPrompt(dialog, prompt),\n\t\tnotify: (event) => host.notifyAuthDialog(dialog, event),\n\t});\n}\n\nexport async function showLoginDialog(host: AuthUiHost, providerId: string, providerName: string): Promise<void> {\n\tconst previousModel = host.getSelectedModel();\n\tconst dialog = new LoginDialogComponent(host.ui, providerId, (_success, _message) => {}, providerName);\n\thost.editorContainer.clear();\n\thost.editorContainer.addChild(dialog);\n\thost.ui.setFocus(dialog);\n\thost.ui.requestRender();\n\n\tconst restoreEditor = () => {\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(host.editor);\n\t\thost.ui.setFocus(host.editor);\n\t\thost.ui.requestRender();\n\t};\n\n\ttry {\n\t\tawait host.loginProvider(dialog, providerId, \"oauth\");\n\t\trestoreEditor();\n\t\tawait host.completeProviderAuthentication(providerId, providerName, \"oauth\", previousModel);\n\t} catch (error: unknown) {\n\t\trestoreEditor();\n\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\tif (error instanceof CredentialSynchronizationError) {\n\t\t\thost.showError(\n\t\t\t\tt(\"Logged in to {name}, but local model state could not be synchronized: {error}\", {\n\t\t\t\t\tname: providerName,\n\t\t\t\t\terror: errorMsg,\n\t\t\t\t}),\n\t\t\t);\n\t\t} else if (errorMsg !== t(\"Login cancelled\")) {\n\t\t\thost.showError(t(\"Failed to login to {name}: {error}\", { name: providerName, error: errorMsg }));\n\t\t}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SAAS,CACb,CAAC,CAAC,+EAA+E,EAAE;gBAClF,IAAI,EAAE,YAAY;gBAClB,KAAK,EAAE,QAAQ;aACf,CAAC,CACF,CAAC;QACH,CAAC;aAAM,IAAI,QAAQ,KAAK,CAAC,CAAC,iBAAiB,CAAC,EAAE,CAAC;YAC9C,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,oCAAoC,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;QAClG,CAAC;IACF,CAAC;AAAA,CACD","sourcesContent":["/**\n * Login/authentication flow for interactive mode (S5 slice 3): provider\n * option collection, the /login and /logout selectors, the OAuth and API-key\n * login dialogs, auth prompt plumbing, and post-login completion.\n *\n * InteractiveMode implements AuthUiHost and keeps same-name delegate methods\n * so prototype-level tests and the command dispatch table keep working; the\n * functions below receive the mode through AuthUiHost and route every call —\n * including steps between auth methods — through the host, mirroring the\n * DialogUiHost pattern in ./interactive-dialog-ui.ts. Credential/provider\n * auth, model snapshot, catalog refresh, facade, and session-identity access go\n * through narrow host accessors (D-048: facade projections) so this module\n * never reads session internals directly.\n *\n * Internal collaboration interface (same pattern as CommandDispatchHost): not\n * a plugin API and not exported from the package root.\n */\nimport * as path from \"node:path\";\nimport type { AuthEvent, AuthPrompt } from \"@agent-forge/ai\";\nimport type { Api, Model } from \"@agent-forge/ai/compat\";\nimport type { Component, Container, EditorComponent, TUI } from \"@agent-forge/tui\";\nimport { APP_NAME, getAuthPath, getDocsPath } from \"../../config.ts\";\nimport type { ModelAuthRuntime } from \"../../core/facade/coding-agent-facade.ts\";\nimport { t } from \"../../core/i18n/index.ts\";\nimport { defaultModelPerProvider } from \"../../core/model-resolver.ts\";\nimport { CredentialSynchronizationError } from \"../../core/model-runtime.ts\";\nimport type { ModelCatalogRuntime } from \"../../host/model-catalog-refresh.ts\";\nimport { theme } from \"../../theme/theme.ts\";\nimport { DialogSelectorComponent } from \"./components/dialog-selector.ts\";\nimport { LoginDialogComponent } from \"./components/login-dialog.ts\";\nimport { type AuthSelectorProvider, OAuthSelectorComponent } from \"./components/oauth-selector.ts\";\nimport { hasDefaultModelProvider, isUnknownModel, llamaCppPostLoginGuidance } from \"./interactive-helpers.ts\";\n\n/**\n * Host surface InteractiveMode exposes to this module: the auth-flow methods\n * (which stay on the mode for dispatch and prototype-level tests) plus narrow\n * accessors for the session runtime, facade operations, and selector surface.\n *\n * Internal collaboration interface (same pattern as CommandDispatchHost): not\n * a plugin API and not exported from the package root.\n */\nexport interface AuthUiHost {\n\t/**\n\t * Narrow credential/provider auth projection through the stable facade\n\t * (D-048); the full runtime stays on the session.\n\t */\n\tgetModelAuthRuntime(): ModelAuthRuntime;\n\t/** Narrow catalog-refresh projection through the stable facade (D-048). */\n\tgetModelCatalog(): ModelCatalogRuntime;\n\t/** Available model snapshot through the stable facade (D-048). */\n\tgetAvailableModels(): readonly Model<Api>[];\n\t/** Opaque current-session identity token for post-login rebind checks. */\n\tgetSessionIdentity(): unknown;\n\tisSameSessionIdentity(identity: unknown): boolean;\n\t/** Selected model through the stable facade. */\n\tgetSelectedModel(): Model<Api> | undefined;\n\t/** Persists a model selection through the stable facade. */\n\tsetSelectedModel(model: Model<Api>): Promise<void>;\n\n\tui: TUI;\n\teditor: EditorComponent;\n\teditorContainer: Container;\n\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n\tshowWarning(message: string): void;\n\t/** Selector surface; the implementation stays in the mode's selector area. */\n\tshowAuthSelector(\n\t\tcreate: (done: () => void) => { component: Component; focus: Component; dispose?: () => void },\n\t): void;\n\tupdateAvailableProviderCount(): void;\n\tmaybeWarnAboutAnthropicSubscriptionAuth(model?: Model<Api>): Promise<void>;\n\tcheckDaxnutsEasterEgg(model: { provider: string; id: string }): void;\n\tinvalidateFooter(): void;\n\tupdateEditorBorderColor(): void;\n\n\tgetLoginProviderOptions(authType?: \"oauth\" | \"api_key\"): AuthSelectorProvider[];\n\tgetLogoutProviderOptions(): Promise<AuthSelectorProvider[]>;\n\tfindLoginProviderOptions(providerRef: string): AuthSelectorProvider[];\n\thandleLoginCommand(providerRef?: string): Promise<void>;\n\tstartProviderLogin(providerOption: AuthSelectorProvider): Promise<void>;\n\tshowLoginAuthTypeSelector(providerOptions?: AuthSelectorProvider[]): void;\n\tshowLoginProviderSelector(authType?: AuthSelectorProvider[\"authType\"], initialSearchInput?: string): void;\n\tshowOAuthSelector(mode: \"login\" | \"logout\"): Promise<void>;\n\tcompleteProviderAuthentication(\n\t\tproviderId: string,\n\t\tproviderName: string,\n\t\tauthType: \"oauth\" | \"api_key\",\n\t\tpreviousModel: Model<Api> | undefined,\n\t): Promise<void>;\n\tshowAmbientAuthDialog(providerOption: AuthSelectorProvider): void;\n\tshowApiKeyLoginDialog(providerId: string, providerName: string): Promise<void>;\n\tshowAuthSelect(dialog: LoginDialogComponent, prompt: Extract<AuthPrompt, { type: \"select\" }>): Promise<string>;\n\tshowAuthPrompt(dialog: LoginDialogComponent, prompt: AuthPrompt): Promise<string>;\n\tnotifyAuthDialog(dialog: LoginDialogComponent, event: AuthEvent): void;\n\tloginProvider(dialog: LoginDialogComponent, providerId: string, method: \"api_key\" | \"oauth\"): Promise<void>;\n\tshowLoginDialog(providerId: string, providerName: string): Promise<void>;\n}\n\nexport function getLoginProviderOptions(host: AuthUiHost, authType?: \"oauth\" | \"api_key\"): AuthSelectorProvider[] {\n\tconst options: AuthSelectorProvider[] = [];\n\tfor (const provider of host.getModelAuthRuntime().getProviders()) {\n\t\tconst authStatus = host.getModelAuthRuntime().getProviderAuthStatus(provider.id);\n\t\tconst status = authStatus.configured\n\t\t\t? {\n\t\t\t\t\ttype: host.getModelAuthRuntime().isUsingOAuth(provider.id) ? (\"oauth\" as const) : (\"api_key\" as const),\n\t\t\t\t\tsource: authStatus.label ?? authStatus.source,\n\t\t\t\t}\n\t\t\t: undefined;\n\t\tif ((!authType || authType === \"oauth\") && provider.auth.oauth) {\n\t\t\toptions.push({\n\t\t\t\tid: provider.id,\n\t\t\t\tname: provider.name,\n\t\t\t\tauthType: \"oauth\",\n\t\t\t\tmethod: provider.auth.oauth,\n\t\t\t\tstatus,\n\t\t\t});\n\t\t}\n\t\tif ((!authType || authType === \"api_key\") && provider.auth.apiKey) {\n\t\t\toptions.push({\n\t\t\t\tid: provider.id,\n\t\t\t\tname: provider.name,\n\t\t\t\tauthType: \"api_key\",\n\t\t\t\tmethod: provider.auth.apiKey,\n\t\t\t\tstatus,\n\t\t\t});\n\t\t}\n\t}\n\treturn options.sort((a, b) => a.name.localeCompare(b.name));\n}\n\nexport async function getLogoutProviderOptions(host: AuthUiHost): Promise<AuthSelectorProvider[]> {\n\treturn (await host.getModelAuthRuntime().listCredentials({ signal: AbortSignal.timeout(15_000) }))\n\t\t.map(({ providerId, type }) => ({\n\t\t\tid: providerId,\n\t\t\tname: host.getModelAuthRuntime().getProvider(providerId)?.name ?? providerId,\n\t\t\tauthType: type,\n\t\t\tstatus: { type, source: \"stored credential\" },\n\t\t}))\n\t\t.sort((a, b) => a.name.localeCompare(b.name));\n}\n\nexport function findLoginProviderOptions(host: AuthUiHost, providerRef: string): AuthSelectorProvider[] {\n\tconst normalizedProviderRef = providerRef.trim().toLowerCase();\n\tif (!normalizedProviderRef) {\n\t\treturn [];\n\t}\n\n\treturn host\n\t\t.getLoginProviderOptions()\n\t\t.filter(\n\t\t\t(provider) =>\n\t\t\t\tprovider.id.toLowerCase() === normalizedProviderRef ||\n\t\t\t\tprovider.name.toLowerCase() === normalizedProviderRef,\n\t\t);\n}\n\nexport async function handleLoginCommand(host: AuthUiHost, providerRef?: string): Promise<void> {\n\tif (!providerRef) {\n\t\thost.showLoginAuthTypeSelector();\n\t\treturn;\n\t}\n\n\tconst providerOptions = host.findLoginProviderOptions(providerRef);\n\tif (providerOptions.length === 1) {\n\t\tawait host.startProviderLogin(providerOptions[0]!);\n\t\treturn;\n\t}\n\n\tif (providerOptions.length > 1) {\n\t\tconst providerIds = new Set(providerOptions.map((provider) => provider.id));\n\t\tif (providerIds.size === 1) {\n\t\t\thost.showLoginAuthTypeSelector(providerOptions);\n\t\t\treturn;\n\t\t}\n\t}\n\n\thost.showLoginProviderSelector(undefined, providerRef);\n}\n\nexport async function startProviderLogin(host: AuthUiHost, providerOption: AuthSelectorProvider): Promise<void> {\n\tif (providerOption.authType === \"oauth\") {\n\t\tawait host.showLoginDialog(providerOption.id, providerOption.name);\n\t} else if (providerOption.method?.login) {\n\t\tawait host.showApiKeyLoginDialog(providerOption.id, providerOption.name);\n\t} else {\n\t\thost.showAmbientAuthDialog(providerOption);\n\t}\n}\n\nexport function showLoginAuthTypeSelector(host: AuthUiHost, providerOptions?: AuthSelectorProvider[]): void {\n\tconst oauthProvider = providerOptions?.find((provider) => provider.authType === \"oauth\");\n\tconst oauthLoginLabel =\n\t\toauthProvider?.method && \"loginLabel\" in oauthProvider.method ? oauthProvider.method.loginLabel : undefined;\n\tconst subscriptionLabel = oauthLoginLabel ?? t(\"Sign in with an account\");\n\tconst apiKeyLabel = t(\"Sign in with an API key\");\n\tconst availableAuthTypes = providerOptions\n\t\t? new Set(providerOptions.map((provider) => provider.authType))\n\t\t: new Set<AuthSelectorProvider[\"authType\"]>([\"oauth\", \"api_key\"]);\n\tconst options: string[] = [];\n\tif (availableAuthTypes.has(\"oauth\")) {\n\t\toptions.push(subscriptionLabel);\n\t}\n\tif (availableAuthTypes.has(\"api_key\")) {\n\t\toptions.push(apiKeyLabel);\n\t}\n\n\tif (options.length === 0) {\n\t\thost.showStatus(t(\"No login methods available.\"));\n\t\treturn;\n\t}\n\n\tif (providerOptions && options.length === 1) {\n\t\tconst providerOption = providerOptions[0];\n\t\t// v8 ignore next -- options.length === 1 已保证 providerOptions 非空,[0] 恒存在\n\t\tif (providerOption) {\n\t\t\tvoid host.startProviderLogin(providerOption);\n\t\t}\n\t\treturn;\n\t}\n\n\tconst title = providerOptions?.[0]\n\t\t? t(\"Select authentication method for {name}:\", { name: providerOptions[0].name })\n\t\t: t(\"Select authentication method:\");\n\thost.showAuthSelector((done) => {\n\t\tconst selector = new DialogSelectorComponent(\n\t\t\ttitle,\n\t\t\toptions,\n\t\t\t(option) => {\n\t\t\t\tdone();\n\t\t\t\tconst authType = option === subscriptionLabel ? \"oauth\" : \"api_key\";\n\t\t\t\tif (providerOptions) {\n\t\t\t\t\tconst providerOption = providerOptions.find((provider) => provider.authType === authType);\n\t\t\t\t\t// v8 ignore next -- 选项列表由 providerOptions 的 authTypes 派生,必能找到\n\t\t\t\t\tif (providerOption) {\n\t\t\t\t\t\tvoid host.startProviderLogin(providerOption);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\thost.showLoginProviderSelector(authType);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\thost.ui.requestRender();\n\t\t\t},\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport function showLoginProviderSelector(\n\thost: AuthUiHost,\n\tauthType?: AuthSelectorProvider[\"authType\"],\n\tinitialSearchInput?: string,\n): void {\n\tconst providerOptions = host.getLoginProviderOptions(authType);\n\tif (providerOptions.length === 0) {\n\t\tconst message =\n\t\t\tauthType === \"oauth\"\n\t\t\t\t? t(\"No subscription providers available.\")\n\t\t\t\t: authType === \"api_key\"\n\t\t\t\t\t? t(\"No API key providers available.\")\n\t\t\t\t\t: t(\"No login providers available.\");\n\t\thost.showStatus(message);\n\t\treturn;\n\t}\n\n\thost.showAuthSelector((done) => {\n\t\tconst selector = new OAuthSelectorComponent(\n\t\t\t\"login\",\n\t\t\tproviderOptions,\n\t\t\tasync (providerId, selectedAuthType) => {\n\t\t\t\tdone();\n\n\t\t\t\tconst providerOption = providerOptions.find(\n\t\t\t\t\t(provider) => provider.id === providerId && provider.authType === selectedAuthType,\n\t\t\t\t);\n\t\t\t\tif (!providerOption) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tawait host.startProviderLogin(providerOption);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\tif (authType) {\n\t\t\t\t\thost.showLoginAuthTypeSelector();\n\t\t\t\t} else {\n\t\t\t\t\thost.ui.requestRender();\n\t\t\t\t}\n\t\t\t},\n\t\t\tinitialSearchInput,\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport async function showOAuthSelector(host: AuthUiHost, mode: \"login\" | \"logout\"): Promise<void> {\n\tif (mode === \"login\") {\n\t\thost.showLoginAuthTypeSelector();\n\t\treturn;\n\t}\n\n\tlet providerOptions: AuthSelectorProvider[];\n\ttry {\n\t\tproviderOptions = await host.getLogoutProviderOptions();\n\t} catch (error) {\n\t\thost.showError(\n\t\t\tt(\"Could not read stored credentials: {error}\", {\n\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t}),\n\t\t);\n\t\treturn;\n\t}\n\tif (providerOptions.length === 0) {\n\t\thost.showStatus(\n\t\t\tt(\n\t\t\t\t\"No stored credentials to remove. /logout only removes credentials saved by /login; environment variables and models.json config are unchanged.\",\n\t\t\t),\n\t\t);\n\t\treturn;\n\t}\n\n\thost.showAuthSelector((done) => {\n\t\tconst selector = new OAuthSelectorComponent(\n\t\t\tmode,\n\t\t\tproviderOptions,\n\t\t\tasync (providerId: string) => {\n\t\t\t\tdone();\n\n\t\t\t\tconst providerOption = providerOptions.find((provider) => provider.id === providerId);\n\t\t\t\tif (!providerOption) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait host.getModelAuthRuntime().logout(providerOption.id, {\n\t\t\t\t\t\tsignal: AbortSignal.timeout(15_000),\n\t\t\t\t\t});\n\t\t\t\t\tawait host.updateAvailableProviderCount();\n\t\t\t\t\tconst message =\n\t\t\t\t\t\tproviderOption.authType === \"oauth\"\n\t\t\t\t\t\t\t? t(\"Logged out of {name}\", { name: providerOption.name })\n\t\t\t\t\t\t\t: t(\n\t\t\t\t\t\t\t\t\t\"Removed stored API key for {name}. Environment variables and models.json config are unchanged.\",\n\t\t\t\t\t\t\t\t\t{ name: providerOption.name },\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\thost.showStatus(message);\n\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\thost.showError(\n\t\t\t\t\t\terror instanceof CredentialSynchronizationError\n\t\t\t\t\t\t\t? t(\"Credentials removed for {name}, but local model state could not be synchronized: {error}\", {\n\t\t\t\t\t\t\t\t\tname: providerOption.name,\n\t\t\t\t\t\t\t\t\terror: message,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t: t(\"Logout failed: {error}\", { error: message }),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\thost.ui.requestRender();\n\t\t\t},\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport async function completeProviderAuthentication(\n\thost: AuthUiHost,\n\tproviderId: string,\n\tproviderName: string,\n\tauthType: \"oauth\" | \"api_key\",\n\tpreviousModel: Model<Api> | undefined,\n): Promise<void> {\n\tconst actionLabel =\n\t\tauthType === \"oauth\"\n\t\t\t? t(\"Logged in to {name}\", { name: providerName })\n\t\t\t: t(\"Saved API key for {name}\", { name: providerName });\n\n\t// Opaque identity of the session that started this login; the rebind check\n\t// below compares against it through the host.\n\tconst sessionIdentity = host.getSessionIdentity();\n\t// Dynamic catalogs may be empty until the first authenticated network refresh.\n\tconst deferSelection =\n\t\tisUnknownModel(previousModel) &&\n\t\thasDefaultModelProvider(providerId) &&\n\t\t!host\n\t\t\t.getAvailableModels()\n\t\t\t.some((model) => model.provider === providerId && model.id === defaultModelPerProvider[providerId]);\n\tconst finishAuthentication = async () => {\n\t\tlet selectedModel: Model<Api> | undefined;\n\t\tlet selectionError: string | undefined;\n\t\tif (isUnknownModel(previousModel)) {\n\t\t\tconst availableModels = host.getAvailableModels();\n\t\t\tconst providerModels = availableModels.filter((model) => model.provider === providerId);\n\t\t\t// Matches LLAMA_PROVIDER_ID from extensions/llama/provider.ts; kept inline to avoid coupling interactive mode to the built-in extension.\n\t\t\tif (providerId === \"llama.cpp\") {\n\t\t\t\tselectionError = llamaCppPostLoginGuidance(actionLabel, providerModels.length);\n\t\t\t} else if (!hasDefaultModelProvider(providerId)) {\n\t\t\t\tselectionError = t(\n\t\t\t\t\t'{action}, but no default model is configured for provider \"{providerId}\". Use /model to select a model.',\n\t\t\t\t\t{ action: actionLabel, providerId },\n\t\t\t\t);\n\t\t\t} else if (providerModels.length === 0) {\n\t\t\t\tselectionError = t(\n\t\t\t\t\t\"{action}, but no models are available for that provider. Use /model to select a model.\",\n\t\t\t\t\t{\n\t\t\t\t\t\taction: actionLabel,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst defaultModelId = defaultModelPerProvider[providerId];\n\t\t\t\tselectedModel = providerModels.find((model) => model.id === defaultModelId);\n\t\t\t\tif (!selectedModel) {\n\t\t\t\t\tselectionError = t(\n\t\t\t\t\t\t'{action}, but its default model \"{modelId}\" is not available. Use /model to select a model.',\n\t\t\t\t\t\t{ action: actionLabel, modelId: defaultModelId },\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait host.setSelectedModel(selectedModel);\n\t\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\t\tselectedModel = undefined;\n\t\t\t\t\t\tconst errorMessage = error instanceof Error ? error.message : String(error);\n\t\t\t\t\t\tselectionError = t(\n\t\t\t\t\t\t\t\"{action}, but selecting its default model failed: {error}. Use /model to select a model.\",\n\t\t\t\t\t\t\t{ action: actionLabel, error: errorMessage },\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tawait host.updateAvailableProviderCount();\n\t\thost.invalidateFooter();\n\t\thost.updateEditorBorderColor();\n\t\tif (selectedModel) {\n\t\t\thost.showStatus(\n\t\t\t\tt(\"{action}. Selected {modelId}. Credentials saved to {path}\", {\n\t\t\t\t\taction: actionLabel,\n\t\t\t\t\tmodelId: selectedModel.id,\n\t\t\t\t\tpath: getAuthPath(),\n\t\t\t\t}),\n\t\t\t);\n\t\t\tvoid host.maybeWarnAboutAnthropicSubscriptionAuth(selectedModel);\n\t\t\thost.checkDaxnutsEasterEgg(selectedModel);\n\t\t} else {\n\t\t\thost.showStatus(t(\"{action}. Credentials saved to {path}\", { action: actionLabel, path: getAuthPath() }));\n\t\t\tif (selectionError) {\n\t\t\t\thost.showError(selectionError);\n\t\t\t} else {\n\t\t\t\tvoid host.maybeWarnAboutAnthropicSubscriptionAuth();\n\t\t\t}\n\t\t}\n\t};\n\tif (deferSelection) {\n\t\thost.showStatus(\n\t\t\tt(\"{action}. Credentials saved to {path}. Refreshing model catalog…\", {\n\t\t\t\taction: actionLabel,\n\t\t\t\tpath: getAuthPath(),\n\t\t\t}),\n\t\t);\n\t} else {\n\t\tawait finishAuthentication();\n\t}\n\n\tconst controller = new AbortController();\n\tconst timeout = setTimeout(() => controller.abort(), 15_000);\n\tvoid host\n\t\t.getModelCatalog()\n\t\t.refresh({ providers: [providerId], signal: controller.signal })\n\t\t.then(async (result) => {\n\t\t\tif (result.aborted) {\n\t\t\t\thost.showWarning(\n\t\t\t\t\tt(\"{action}, but its model catalog refresh timed out; using cached models.\", { action: actionLabel }),\n\t\t\t\t);\n\t\t\t} else if (result.errors.size > 0) {\n\t\t\t\thost.showWarning(\n\t\t\t\t\tt(\"{action}, but its model catalog could not be refreshed; using cached models.\", {\n\t\t\t\t\t\taction: actionLabel,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\t// Do not replace a model or session selected while the refresh was running.\n\t\t\tif (\n\t\t\t\tdeferSelection &&\n\t\t\t\thost.isSameSessionIdentity(sessionIdentity) &&\n\t\t\t\thost.getSelectedModel() === previousModel\n\t\t\t) {\n\t\t\t\tawait finishAuthentication();\n\t\t\t}\n\t\t\thost.updateAvailableProviderCount();\n\t\t\thost.invalidateFooter();\n\t\t\thost.ui.requestRender();\n\t\t})\n\t\t.catch((error: unknown) => {\n\t\t\thost.showWarning(\n\t\t\t\tt(\"{action}, but its model catalog could not be refreshed: {error}\", {\n\t\t\t\t\taction: actionLabel,\n\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t}),\n\t\t\t);\n\t\t})\n\t\t.finally(() => clearTimeout(timeout));\n}\n\nexport function showAmbientAuthDialog(host: AuthUiHost, providerOption: AuthSelectorProvider): void {\n\tconst restoreEditor = () => {\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(host.editor);\n\t\thost.ui.setFocus(host.editor);\n\t\thost.ui.requestRender();\n\t};\n\n\tconst dialog = new LoginDialogComponent(\n\t\thost.ui,\n\t\tproviderOption.id,\n\t\t() => restoreEditor(),\n\t\tproviderOption.name,\n\t\tt(\"{name} setup\", { name: providerOption.name }),\n\t);\n\tdialog.showInfo(\n\t\tt(\"{method} is configured outside {appName}.\", {\n\t\t\tmethod: providerOption.method?.name ?? t(\"Authentication\"),\n\t\t\tappName: APP_NAME,\n\t\t}),\n\t\t[],\n\t\ttrue,\n\t);\n\n\thost.editorContainer.clear();\n\thost.editorContainer.addChild(dialog);\n\thost.ui.setFocus(dialog);\n\thost.ui.requestRender();\n}\n\nexport async function showApiKeyLoginDialog(host: AuthUiHost, providerId: string, providerName: string): Promise<void> {\n\tconst previousModel = host.getSelectedModel();\n\n\tconst dialog = new LoginDialogComponent(\n\t\thost.ui,\n\t\tproviderId,\n\t\t(_success, _message) => {\n\t\t\t// Completion handled below\n\t\t},\n\t\tproviderName,\n\t);\n\n\tif (providerId === \"amazon-bedrock\") {\n\t\tdialog.showDetails([\n\t\t\ttheme.fg(\"text\", t(\"You can also use an AWS profile, IAM keys, or role-based credentials.\")),\n\t\t\ttheme.fg(\"muted\", t(\"See:\")),\n\t\t\ttheme.fg(\"accent\", ` ${path.join(getDocsPath(), \"providers.md\")}`),\n\t\t]);\n\t}\n\n\thost.editorContainer.clear();\n\thost.editorContainer.addChild(dialog);\n\thost.ui.setFocus(dialog);\n\thost.ui.requestRender();\n\n\tconst restoreEditor = () => {\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(host.editor);\n\t\thost.ui.setFocus(host.editor);\n\t\thost.ui.requestRender();\n\t};\n\n\ttry {\n\t\tawait host.loginProvider(dialog, providerId, \"api_key\");\n\t\trestoreEditor();\n\t\tawait host.completeProviderAuthentication(providerId, providerName, \"api_key\", previousModel);\n\t} catch (error: unknown) {\n\t\trestoreEditor();\n\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\tif (error instanceof CredentialSynchronizationError) {\n\t\t\thost.showError(\n\t\t\t\tt(\"Saved API key for {name}, but local model state could not be synchronized: {error}\", {\n\t\t\t\t\tname: providerName,\n\t\t\t\t\terror: errorMsg,\n\t\t\t\t}),\n\t\t\t);\n\t\t} else if (errorMsg !== t(\"Login cancelled\")) {\n\t\t\thost.showError(t(\"Failed to save API key for {name}: {error}\", { name: providerName, error: errorMsg }));\n\t\t}\n\t}\n}\n\nexport function showAuthSelect(\n\thost: AuthUiHost,\n\tdialog: LoginDialogComponent,\n\tprompt: Extract<AuthPrompt, { type: \"select\" }>,\n): Promise<string> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst restoreDialog = () => {\n\t\t\thost.editorContainer.clear();\n\t\t\thost.editorContainer.addChild(dialog);\n\t\t\thost.ui.setFocus(dialog);\n\t\t\thost.ui.requestRender();\n\t\t};\n\t\tconst labels = prompt.options.map((option) => option.label);\n\t\tconst selector = new DialogSelectorComponent(\n\t\t\tprompt.message,\n\t\t\tlabels,\n\t\t\t(optionLabel) => {\n\t\t\t\trestoreDialog();\n\t\t\t\tconst id = prompt.options.find((option) => option.label === optionLabel)?.id;\n\t\t\t\t// v8 ignore next -- 选项列表由 prompt.options 派生,选中项必能找到\n\t\t\t\tif (id) resolve(id);\n\t\t\t\telse reject(new Error(t(\"Login cancelled\")));\n\t\t\t},\n\t\t\t() => {\n\t\t\t\trestoreDialog();\n\t\t\t\treject(new Error(t(\"Login cancelled\")));\n\t\t\t},\n\t\t);\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(selector);\n\t\thost.ui.setFocus(selector);\n\t\thost.ui.requestRender();\n\t});\n}\n\nexport async function showAuthPrompt(\n\thost: AuthUiHost,\n\tdialog: LoginDialogComponent,\n\tprompt: AuthPrompt,\n): Promise<string> {\n\tlet response: Promise<string>;\n\tif (prompt.type === \"select\") {\n\t\tresponse = host.showAuthSelect(dialog, prompt);\n\t} else if (prompt.type === \"manual_code\") {\n\t\tresponse = dialog.showManualInput(prompt.message);\n\t} else {\n\t\tresponse = dialog.showPrompt(prompt.message, prompt.placeholder);\n\t}\n\tif (!prompt.signal) return response;\n\tif (prompt.signal.aborted) throw new Error(t(\"Login cancelled\"));\n\tconst signal = prompt.signal;\n\tlet onAbort: (() => void) | undefined;\n\tconst aborted = new Promise<string>((_resolve, reject) => {\n\t\tonAbort = () => reject(new Error(t(\"Login cancelled\")));\n\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n\ttry {\n\t\treturn await Promise.race([response, aborted]);\n\t} finally {\n\t\t// v8 ignore next -- onAbort 在 Promise executor 中同步赋值,恒已定义\n\t\tif (onAbort) signal.removeEventListener(\"abort\", onAbort);\n\t}\n}\n\nexport function notifyAuthDialog(_host: AuthUiHost, dialog: LoginDialogComponent, event: AuthEvent): void {\n\tif (event.type === \"auth_url\") {\n\t\tdialog.showAuth(event.url, event.instructions);\n\t} else if (event.type === \"device_code\") {\n\t\tdialog.showDeviceCode(event);\n\t\tdialog.showWaiting(t(\"Waiting for authentication...\"));\n\t} else if (event.type === \"info\") {\n\t\tdialog.showInfo(event.message, event.links);\n\t} else {\n\t\tdialog.showProgress(event.message);\n\t}\n}\n\nexport async function loginProvider(\n\thost: AuthUiHost,\n\tdialog: LoginDialogComponent,\n\tproviderId: string,\n\tmethod: \"api_key\" | \"oauth\",\n): Promise<void> {\n\tawait host.getModelAuthRuntime().login(providerId, method, {\n\t\tsignal: dialog.signal,\n\t\tprompt: (prompt) => host.showAuthPrompt(dialog, prompt),\n\t\tnotify: (event) => host.notifyAuthDialog(dialog, event),\n\t});\n}\n\nexport async function showLoginDialog(host: AuthUiHost, providerId: string, providerName: string): Promise<void> {\n\tconst previousModel = host.getSelectedModel();\n\tconst dialog = new LoginDialogComponent(host.ui, providerId, (_success, _message) => {}, providerName);\n\thost.editorContainer.clear();\n\thost.editorContainer.addChild(dialog);\n\thost.ui.setFocus(dialog);\n\thost.ui.requestRender();\n\n\tconst restoreEditor = () => {\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(host.editor);\n\t\thost.ui.setFocus(host.editor);\n\t\thost.ui.requestRender();\n\t};\n\n\ttry {\n\t\tawait host.loginProvider(dialog, providerId, \"oauth\");\n\t\trestoreEditor();\n\t\tawait host.completeProviderAuthentication(providerId, providerName, \"oauth\", previousModel);\n\t} catch (error: unknown) {\n\t\trestoreEditor();\n\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\tif (error instanceof CredentialSynchronizationError) {\n\t\t\thost.showError(\n\t\t\t\tt(\"Logged in to {name}, but local model state could not be synchronized: {error}\", {\n\t\t\t\t\tname: providerName,\n\t\t\t\t\terror: errorMsg,\n\t\t\t\t}),\n\t\t\t);\n\t\t} else if (errorMsg !== t(\"Login cancelled\")) {\n\t\t\thost.showError(t(\"Failed to login to {name}: {error}\", { name: providerName, error: errorMsg }));\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import type { Component, EditorComponent, Keybinding, MarkdownTheme, TUI } from "@agent-forge/tui";
|
|
2
|
+
import { Container } from "@agent-forge/tui";
|
|
3
|
+
import type { CodingAgentFacadeV1, CodingAgentRuntimeFacadeV1 } from "../../core/facade/index.ts";
|
|
4
|
+
import type { AppKeybinding, KeybindingsManager } from "../../core/keybindings.ts";
|
|
5
|
+
import type { ThemeMetaV1 } from "../../core/resource-loader.ts";
|
|
6
|
+
import { MissingSessionCwdError } from "../../core/session-cwd.ts";
|
|
7
|
+
import type { SettingsManager } from "../../core/settings-manager.ts";
|
|
8
|
+
import type { MetricsSnapshotV1, ObservabilityMetricsOptions } from "../../plugins/observability-types.ts";
|
|
9
|
+
import { type Theme } from "../../theme/theme.ts";
|
|
10
|
+
import type { InteractiveThemeController } from "../../theme/theme-controller.ts";
|
|
11
|
+
import { BashExecutionComponent } from "./components/bash-execution.ts";
|
|
7
12
|
/**
|
|
8
13
|
* Narrow facade InteractiveMode exposes to the dispatch table. Entries resolve
|
|
9
14
|
* handlers through this interface at dispatch time, so instance-level
|
|
@@ -38,6 +43,8 @@ export interface CommandDispatchHost {
|
|
|
38
43
|
showOAuthSelector(mode: "login" | "logout"): Promise<void>;
|
|
39
44
|
handleClearCommand(): Promise<void>;
|
|
40
45
|
handleCompactCommand(customInstructions?: string): Promise<void>;
|
|
46
|
+
/** /clean-sessions:会话清理两阶段流程(预览 → 宿主确认 → 执行,设计 §7)。 */
|
|
47
|
+
handleCleanSessionsCommand(arg: string | undefined): Promise<void>;
|
|
41
48
|
handleReloadCommand(): Promise<void>;
|
|
42
49
|
handleDebugCommand(): void;
|
|
43
50
|
handleArminSaysHi(): void;
|
|
@@ -52,6 +59,60 @@ export interface CommandDispatchHost {
|
|
|
52
59
|
}): Promise<void>;
|
|
53
60
|
showWorkflowView(): void;
|
|
54
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Host surface for the command-handler implementations in this module (拆分
|
|
64
|
+
* slice 1): everything the handler bodies touch on the mode beyond the
|
|
65
|
+
* dispatch signatures CommandDispatchHost already declares. InteractiveMode
|
|
66
|
+
* implements this interface; its same-name delegate methods keep
|
|
67
|
+
* prototype-level test bindings and the dispatch table working.
|
|
68
|
+
*
|
|
69
|
+
* Internal collaboration interface (same pattern as CommandDispatchHost): not
|
|
70
|
+
* a plugin API and not exported from the package root.
|
|
71
|
+
*/
|
|
72
|
+
export interface CommandHandlersHost extends CommandDispatchHost {
|
|
73
|
+
/** Stable facade (阶段 1 slice 1). */
|
|
74
|
+
facade: CodingAgentFacadeV1;
|
|
75
|
+
/** Stable runtime facade (阶段 4 slice 3). */
|
|
76
|
+
runtimeFacade: CodingAgentRuntimeFacadeV1;
|
|
77
|
+
/** Constructor-injected settings (D-047). */
|
|
78
|
+
settingsManager: SettingsManager;
|
|
79
|
+
/** Mode options; /metrics reads the observability plugin source here. */
|
|
80
|
+
options: {
|
|
81
|
+
getMetrics?: (options?: ObservabilityMetricsOptions) => MetricsSnapshotV1 | undefined;
|
|
82
|
+
};
|
|
83
|
+
keybindings: KeybindingsManager;
|
|
84
|
+
themeController: InteractiveThemeController;
|
|
85
|
+
ui: TUI;
|
|
86
|
+
editor: EditorComponent;
|
|
87
|
+
editorContainer: Container;
|
|
88
|
+
chatContainer: Container;
|
|
89
|
+
pendingMessagesContainer: Container;
|
|
90
|
+
builtInHeader: Component | undefined;
|
|
91
|
+
toolOutputExpanded: boolean;
|
|
92
|
+
hideThinkingBlock: boolean;
|
|
93
|
+
outputPad: number;
|
|
94
|
+
bashComponent: BashExecutionComponent | undefined;
|
|
95
|
+
pendingBashComponents: BashExecutionComponent[];
|
|
96
|
+
showStatus(message: string): void;
|
|
97
|
+
showError(message: string): void;
|
|
98
|
+
showWarning(message: string): void;
|
|
99
|
+
clearStatusIndicator(): void;
|
|
100
|
+
resetDialogUI(): void;
|
|
101
|
+
rebuildChatFromMessages(): void;
|
|
102
|
+
applyRuntimeSettings(): void;
|
|
103
|
+
setupAutocompleteProvider(): void;
|
|
104
|
+
showLoadedResources(options?: {
|
|
105
|
+
force?: boolean;
|
|
106
|
+
showDiagnosticsWhenQuiet?: boolean;
|
|
107
|
+
}): void;
|
|
108
|
+
showDialogConfirm(title: string, message: string): Promise<boolean>;
|
|
109
|
+
promptForMissingSessionCwd(error: MissingSessionCwdError): Promise<string | undefined>;
|
|
110
|
+
handleFatalRuntimeError(title: string, error: unknown): Promise<void>;
|
|
111
|
+
getMarkdownThemeWithSettings(): MarkdownTheme;
|
|
112
|
+
/** Daxnuts easter-egg render; resolved through the host so instance-level
|
|
113
|
+
* overrides keep working (original called this.handleDaxnuts()). */
|
|
114
|
+
handleDaxnuts(): void;
|
|
115
|
+
}
|
|
55
116
|
export interface CommandDispatchEntry {
|
|
56
117
|
/** Command word including the leading slash, e.g. "/model". */
|
|
57
118
|
command: string;
|
|
@@ -88,4 +149,62 @@ export interface CompletionCommandInput {
|
|
|
88
149
|
* their own paths; neither is offered as an ambiguous completion).
|
|
89
150
|
*/
|
|
90
151
|
export declare function filterCapabilityCommandsForCompletions(capabilityCommands: readonly CompletionCommandInput[], reservedNames: readonly Iterable<string>[]): CompletionCommandInput[];
|
|
152
|
+
/**
|
|
153
|
+
* Rebuilds real Theme instances from the resource loader's ThemeMetaV1
|
|
154
|
+
* projection for the theme registry (B-S2b v1). Registration points
|
|
155
|
+
* (constructor, runtime session start, reload) need loadable instances —
|
|
156
|
+
* setRegisteredThemes stores what it is given and getThemeByName returns the
|
|
157
|
+
* registered instance first — while the loader surface now projects only
|
|
158
|
+
* metadata. Re-loading is synchronous and deterministic per sourcePath;
|
|
159
|
+
* theme names come from the same JSON the loader parsed, so meta.name ===
|
|
160
|
+
* Theme.name and the registry keeps its own name-filter/dedupe semantics.
|
|
161
|
+
*
|
|
162
|
+
* Contract: a meta without a sourcePath (or one whose file no longer parses)
|
|
163
|
+
* throws — themesOverride host inputs must always carry a loadable
|
|
164
|
+
* sourcePath. This adds one extra parse per theme at registration time
|
|
165
|
+
* (constructor / session start / reload, not per turn).
|
|
166
|
+
*
|
|
167
|
+
* Re-exported from ./interactive-mode.ts for existing consumers of that module.
|
|
168
|
+
*/
|
|
169
|
+
export declare function buildRegisteredThemes(themes: readonly ThemeMetaV1[]): Theme[];
|
|
170
|
+
export declare function handleReloadCommand(host: CommandHandlersHost): Promise<void>;
|
|
171
|
+
export declare function handleExportCommand(host: CommandHandlersHost, text: string): Promise<void>;
|
|
172
|
+
export declare function getPathCommandArgument(text: string, command: "/export" | "/import"): string | undefined;
|
|
173
|
+
export declare function handleImportCommand(host: CommandHandlersHost, text: string): Promise<void>;
|
|
174
|
+
export declare function handleCopyCommand(host: CommandHandlersHost, options?: {
|
|
175
|
+
flashConfirmation?: boolean;
|
|
176
|
+
preferSelection?: boolean;
|
|
177
|
+
}): Promise<void>;
|
|
178
|
+
export declare function handleNameCommand(host: CommandHandlersHost, text: string): void;
|
|
179
|
+
/**
|
|
180
|
+
* 中断分级(设计 子代理运行时 §4.2,2026-10-02):/stop-agents 的唯一执行
|
|
181
|
+
* 面——终止全部后台子代理(不触当前回合)。Esc 从不做这件事。
|
|
182
|
+
*/
|
|
183
|
+
export declare function handleStopAgentsCommand(host: CommandHandlersHost): void;
|
|
184
|
+
export declare function handleSessionCommand(host: CommandHandlersHost): void;
|
|
185
|
+
export declare function handleMetricsCommand(host: CommandHandlersHost, turnsArg: string | undefined): void;
|
|
186
|
+
export declare function handleChangelogCommand(host: CommandHandlersHost): void;
|
|
187
|
+
/**
|
|
188
|
+
* Get capitalized display string for an app keybinding action.
|
|
189
|
+
*/
|
|
190
|
+
export declare function getAppKeyDisplay(action: AppKeybinding): string;
|
|
191
|
+
/**
|
|
192
|
+
* Get capitalized display string for an editor keybinding action.
|
|
193
|
+
*/
|
|
194
|
+
export declare function getEditorKeyDisplay(action: Keybinding): string;
|
|
195
|
+
export declare function handleHelpCommand(host: CommandHandlersHost): void;
|
|
196
|
+
export declare function handleHotkeysCommand(host: CommandHandlersHost): void;
|
|
197
|
+
export declare function handleClearCommand(host: CommandHandlersHost): Promise<void>;
|
|
198
|
+
export declare function handleDebugCommand(host: CommandHandlersHost): void;
|
|
199
|
+
export declare function handleArminSaysHi(host: CommandHandlersHost): void;
|
|
200
|
+
export declare function handleDaxnuts(host: CommandHandlersHost): void;
|
|
201
|
+
/** Host-visible for ./interactive-auth.ts (S5 slice 3). */
|
|
202
|
+
export declare function checkDaxnutsEasterEgg(host: CommandHandlersHost, model: {
|
|
203
|
+
provider: string;
|
|
204
|
+
id: string;
|
|
205
|
+
}): void;
|
|
206
|
+
export declare function handleBashCommand(host: CommandHandlersHost, command: string, excludeFromContext?: boolean): Promise<void>;
|
|
207
|
+
export declare function handleCompactCommand(host: CommandHandlersHost, customInstructions?: string): Promise<void>;
|
|
208
|
+
/** /clean-sessions:会话清理两阶段流程;输出/确认走宿主既有机制(设计 §7)。 */
|
|
209
|
+
export declare function handleCleanSessionsCommand(host: CommandHandlersHost, arg: string | undefined): Promise<void>;
|
|
91
210
|
//# sourceMappingURL=interactive-commands.d.ts.map
|