@ai-agent-forge/agent-forge 0.87.0 → 0.88.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/README.md +2 -2
- package/bundled-plugins/agent-loop-policy/agent-forge.json +19 -0
- package/bundled-plugins/agent-loop-policy/dist/entry.d.ts +28 -0
- package/bundled-plugins/agent-loop-policy/dist/entry.d.ts.map +1 -0
- package/bundled-plugins/agent-loop-policy/dist/entry.js +69 -0
- package/bundled-plugins/agent-loop-policy/dist/entry.js.map +1 -0
- package/bundled-plugins/agent-loop-policy/dist/loop-guard.d.ts +199 -0
- package/bundled-plugins/agent-loop-policy/dist/loop-guard.d.ts.map +1 -0
- package/bundled-plugins/agent-loop-policy/dist/loop-guard.js +208 -0
- package/bundled-plugins/agent-loop-policy/dist/loop-guard.js.map +1 -0
- package/bundled-plugins/agent-loop-policy/dist/run-loop-strategy.d.ts +17 -0
- package/bundled-plugins/agent-loop-policy/dist/run-loop-strategy.d.ts.map +1 -0
- package/bundled-plugins/agent-loop-policy/dist/run-loop-strategy.js +18 -0
- package/bundled-plugins/agent-loop-policy/dist/run-loop-strategy.js.map +1 -0
- package/bundled-plugins/agent-loop-policy/plugin.json +7 -0
- package/bundled-plugins/coding-tools/agent-forge.json +19 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/bash.d.ts +5 -44
- package/bundled-plugins/coding-tools/dist/bash.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/bash.js +15 -119
- package/bundled-plugins/coding-tools/dist/bash.js.map +1 -0
- package/bundled-plugins/coding-tools/dist/capability.d.ts +25 -0
- package/bundled-plugins/coding-tools/dist/capability.d.ts.map +1 -0
- package/bundled-plugins/coding-tools/dist/capability.js +98 -0
- package/bundled-plugins/coding-tools/dist/capability.js.map +1 -0
- package/bundled-plugins/coding-tools/dist/config.d.ts +8 -0
- package/bundled-plugins/coding-tools/dist/config.d.ts.map +1 -0
- package/bundled-plugins/coding-tools/dist/config.js +8 -0
- package/bundled-plugins/coding-tools/dist/config.js.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/edit.d.ts +3 -3
- package/bundled-plugins/coding-tools/dist/edit.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/edit.js +12 -10
- package/bundled-plugins/coding-tools/dist/edit.js.map +1 -0
- package/bundled-plugins/coding-tools/dist/entry.d.ts +14 -0
- package/bundled-plugins/coding-tools/dist/entry.d.ts.map +1 -0
- package/bundled-plugins/coding-tools/dist/entry.js +23 -0
- package/bundled-plugins/coding-tools/dist/entry.js.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/find.d.ts +4 -4
- package/bundled-plugins/coding-tools/dist/find.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/find.js +10 -8
- package/bundled-plugins/coding-tools/dist/find.js.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/grep.d.ts +3 -3
- package/bundled-plugins/coding-tools/dist/grep.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/grep.js +10 -8
- package/bundled-plugins/coding-tools/dist/grep.js.map +1 -0
- package/bundled-plugins/coding-tools/dist/index.d.ts +17 -0
- package/bundled-plugins/coding-tools/dist/index.d.ts.map +1 -0
- package/bundled-plugins/coding-tools/dist/index.js +17 -0
- package/bundled-plugins/coding-tools/dist/index.js.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/ls.d.ts +3 -3
- package/bundled-plugins/coding-tools/dist/ls.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/ls.js +8 -6
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/ls.js.map +1 -1
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/powershell.d.ts +2 -1
- package/bundled-plugins/coding-tools/dist/powershell.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/powershell.js +6 -3
- package/bundled-plugins/coding-tools/dist/powershell.js.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/read.d.ts +3 -3
- package/bundled-plugins/coding-tools/dist/read.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/read.js +15 -13
- package/bundled-plugins/coding-tools/dist/read.js.map +1 -0
- package/bundled-plugins/coding-tools/dist/types.d.ts +74 -0
- package/bundled-plugins/coding-tools/dist/types.d.ts.map +1 -0
- package/bundled-plugins/coding-tools/dist/types.js +28 -0
- package/bundled-plugins/coding-tools/dist/types.js.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/write.d.ts +2 -2
- package/bundled-plugins/coding-tools/dist/write.d.ts.map +1 -0
- package/{dist/core/tools → bundled-plugins/coding-tools/dist}/write.js +11 -9
- package/bundled-plugins/coding-tools/dist/write.js.map +1 -0
- package/bundled-plugins/coding-tools/plugin.json +10 -0
- package/bundled-plugins/compaction-policy/agent-forge.json +19 -0
- package/bundled-plugins/compaction-policy/dist/branch-summary-policy.d.ts +6 -0
- package/bundled-plugins/compaction-policy/dist/branch-summary-policy.d.ts.map +1 -0
- package/bundled-plugins/compaction-policy/dist/branch-summary-policy.js +19 -0
- package/bundled-plugins/compaction-policy/dist/branch-summary-policy.js.map +1 -0
- package/bundled-plugins/compaction-policy/dist/compaction-policy.d.ts +6 -0
- package/bundled-plugins/compaction-policy/dist/compaction-policy.d.ts.map +1 -0
- package/bundled-plugins/compaction-policy/dist/compaction-policy.js +38 -0
- package/bundled-plugins/compaction-policy/dist/compaction-policy.js.map +1 -0
- package/bundled-plugins/compaction-policy/dist/entry.d.ts +13 -0
- package/bundled-plugins/compaction-policy/dist/entry.d.ts.map +1 -0
- package/bundled-plugins/compaction-policy/dist/entry.js +23 -0
- package/bundled-plugins/compaction-policy/dist/entry.js.map +1 -0
- package/bundled-plugins/compaction-policy/plugin.json +10 -0
- package/bundled-plugins/mcp-http/dist/index.d.ts +8 -0
- package/bundled-plugins/mcp-http/dist/index.d.ts.map +1 -0
- package/bundled-plugins/mcp-http/dist/index.js +8 -0
- package/bundled-plugins/mcp-http/dist/index.js.map +1 -0
- package/bundled-plugins/mcp-http/dist/mcp-http.d.ts.map +1 -0
- package/{dist/plugins → bundled-plugins/mcp-http/dist}/mcp-http.js +1 -1
- package/bundled-plugins/mcp-http/dist/mcp-http.js.map +1 -0
- package/bundled-plugins/overflow-policy/agent-forge.json +19 -0
- package/bundled-plugins/overflow-policy/dist/entry.d.ts +16 -0
- package/bundled-plugins/overflow-policy/dist/entry.d.ts.map +1 -0
- package/bundled-plugins/overflow-policy/dist/entry.js +35 -0
- package/bundled-plugins/overflow-policy/dist/entry.js.map +1 -0
- package/bundled-plugins/overflow-policy/plugin.json +10 -0
- package/bundled-plugins/provider-failover/agent-forge.json +19 -0
- package/bundled-plugins/provider-failover/dist/entry.d.ts +8 -0
- package/bundled-plugins/provider-failover/dist/entry.d.ts.map +1 -0
- package/bundled-plugins/provider-failover/dist/entry.js +8 -0
- package/bundled-plugins/provider-failover/dist/entry.js.map +1 -0
- package/bundled-plugins/provider-failover/dist/provider-failover.d.ts +122 -0
- package/bundled-plugins/provider-failover/dist/provider-failover.d.ts.map +1 -0
- package/{dist/core/extensions → bundled-plugins/provider-failover/dist}/provider-failover.js +149 -61
- package/bundled-plugins/provider-failover/dist/provider-failover.js.map +1 -0
- package/bundled-plugins/provider-failover/plugin.json +7 -0
- package/bundled-plugins/retry-policy/agent-forge.json +19 -0
- package/bundled-plugins/retry-policy/dist/entry.d.ts +16 -0
- package/bundled-plugins/retry-policy/dist/entry.d.ts.map +1 -0
- package/bundled-plugins/retry-policy/dist/entry.js +34 -0
- package/bundled-plugins/retry-policy/dist/entry.js.map +1 -0
- package/bundled-plugins/retry-policy/plugin.json +10 -0
- package/dist/bundle/.build-manifest.json +105 -183
- package/dist/bundle/chunks/{anthropic-messages-ALDZBUKI.js → anthropic-messages-PLAKXR73.js} +1 -1
- package/dist/bundle/chunks/{azure-openai-responses-A2WJWZFB.js → azure-openai-responses-OUWQ2AZD.js} +1 -1
- package/dist/bundle/chunks/{chunk-CIX3FSBK.js → chunk-A3JYRWB6.js} +1 -1
- package/dist/bundle/chunks/{chunk-SQFG22WN.js → chunk-AC2FIS4G.js} +1 -1
- package/dist/bundle/chunks/chunk-AQLNTW2B.js +664 -0
- package/dist/bundle/chunks/chunk-D3ARGZFR.js +13 -0
- package/dist/bundle/chunks/{chunk-YJCQVXW5.js → chunk-HTEVUY7F.js} +1 -1
- package/dist/bundle/chunks/{chunk-Y7HXTASS.js → chunk-HV64ASMT.js} +1 -1
- package/dist/bundle/chunks/chunk-LZOEQITZ.js +855 -0
- package/dist/bundle/chunks/{chunk-7ZY7IXZD.js → chunk-TRDNDS6A.js} +1 -1
- package/dist/bundle/chunks/chunk-Z72JWUZ4.js +4 -0
- package/dist/bundle/chunks/{google-generative-ai-NIB4WONV.js → google-generative-ai-DLII6DAT.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-DCPYUEUO.js → google-vertex-G7BZL7GM.js} +1 -1
- package/dist/bundle/chunks/image-resize-worker.js +3 -3
- package/dist/bundle/chunks/{mistral-conversations-OC6LA5XL.js → mistral-conversations-JXUK24ID.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-IO2X4Y7L.js → openai-codex-responses-5GSGFIPG.js} +1 -1
- package/dist/bundle/chunks/{openai-completions-XYQQHETU.js → openai-completions-EI2I6DTG.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-DLIRN3CI.js → openai-responses-AUJQ3NWT.js} +1 -1
- package/dist/bundle/chunks/{pi-messages-E6RRYBO7.js → pi-messages-PWU2VJMR.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-WF6WRHP7.js +5 -0
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/client.js +1 -1
- package/dist/bundle/index.js +3 -3
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/capabilities/builtin.d.ts +1 -1
- package/dist/capabilities/builtin.d.ts.map +1 -1
- package/dist/capabilities/builtin.js +5 -0
- package/dist/capabilities/builtin.js.map +1 -1
- package/dist/cli/auth-check.d.ts.map +1 -1
- package/dist/cli/auth-check.js +14 -2
- package/dist/cli/auth-check.js.map +1 -1
- package/dist/cli/auth-command.d.ts.map +1 -1
- package/dist/cli/auth-command.js +1 -1
- package/dist/cli/auth-command.js.map +1 -1
- package/dist/cli/plugin-command.d.ts.map +1 -1
- package/dist/cli/plugin-command.js +17 -1
- package/dist/cli/plugin-command.js.map +1 -1
- package/dist/config.d.ts +2 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -6
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts +1 -1
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +1 -1
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts +6 -10
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +21 -112
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-internal.d.ts +1 -7
- 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-loop.d.ts +4 -3
- package/dist/core/agent-session-loop.d.ts.map +1 -1
- package/dist/core/agent-session-loop.js +9 -6
- package/dist/core/agent-session-loop.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts +1 -1
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +32 -4
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +30 -9
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-tools.d.ts.map +1 -1
- package/dist/core/agent-session-tools.js +5 -1
- package/dist/core/agent-session-tools.js.map +1 -1
- package/dist/core/agent-session.d.ts +12 -33
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +61 -67
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bash-executor.d.ts +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/extensions/bootstrap-agent-loop.d.ts +23 -151
- package/dist/core/extensions/bootstrap-agent-loop.d.ts.map +1 -1
- package/dist/core/extensions/bootstrap-agent-loop.js +28 -290
- package/dist/core/extensions/bootstrap-agent-loop.js.map +1 -1
- package/dist/core/extensions/capability-runtime-types.d.ts +5 -3
- package/dist/core/extensions/capability-runtime-types.d.ts.map +1 -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 +42 -6
- package/dist/core/extensions/capability-runtime.js.map +1 -1
- package/dist/core/extensions/index.d.ts +12 -5
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +12 -5
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/virtual-modules.js +65 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -1
- package/dist/core/facade/coding-agent-facade.d.ts +1 -7
- package/dist/core/facade/coding-agent-facade.d.ts.map +1 -1
- package/dist/core/facade/coding-agent-facade.js +0 -3
- 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 +3 -1
- package/dist/core/i18n/locales/zh-cn/cli.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-core.d.ts +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-core.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-core.js +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-core.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-extensions.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/core-contract-extensions.js +2 -4
- package/dist/core/i18n/locales/zh-cn/core-contract-extensions.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 +3 -1
- package/dist/core/i18n/locales/zh-cn/core-errors.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 +2 -0
- package/dist/core/i18n/locales/zh-cn/interactive-mode.js.map +1 -1
- package/dist/core/i18n/locales/zh-cn/tui-components-selectors.d.ts.map +1 -1
- package/dist/core/i18n/locales/zh-cn/tui-components-selectors.js +0 -2
- package/dist/core/i18n/locales/zh-cn/tui-components-selectors.js.map +1 -1
- package/dist/core/model-config.d.ts +0 -1
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +9 -1
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +3 -3
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/provider-composer.d.ts +2 -2
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +7 -8
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/sdk.d.ts +18 -3
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +267 -76
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-manager.d.ts +9 -20
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +20 -54
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/tools/bash-operations.d.ts +41 -0
- package/dist/core/tools/bash-operations.d.ts.map +1 -0
- package/dist/core/tools/bash-operations.js +113 -0
- package/dist/core/tools/bash-operations.js.map +1 -0
- package/dist/core/tools/index.d.ts +12 -36
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +1 -117
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/readme-path.d.ts +3 -0
- package/dist/core/tools/readme-path.d.ts.map +1 -0
- package/dist/core/tools/readme-path.js +15 -0
- package/dist/core/tools/readme-path.js.map +1 -0
- package/dist/index.d.ts +3 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -39
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +3 -2
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +0 -2
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +2 -7
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +2 -6
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +6 -28
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +0 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +9 -25
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +0 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +23 -36
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +0 -8
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +0 -12
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +0 -9
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +0 -19
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/plugins/ecosystem/cli.d.ts.map +1 -1
- package/dist/plugins/ecosystem/cli.js +14 -2
- package/dist/plugins/ecosystem/cli.js.map +1 -1
- package/dist/plugins/ecosystem/node-npm-registry-source.d.ts +7 -2
- package/dist/plugins/ecosystem/node-npm-registry-source.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-npm-registry-source.js +64 -9
- package/dist/plugins/ecosystem/node-npm-registry-source.js.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-acquisition-host.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-acquisition-host.js +6 -0
- package/dist/plugins/ecosystem/node-plugin-acquisition-host.js.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts +9 -2
- package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts.map +1 -1
- package/dist/plugins/ecosystem/node-plugin-bootstrap.js +23 -0
- package/dist/plugins/ecosystem/node-plugin-bootstrap.js.map +1 -1
- package/dist/plugins/ecosystem/plugin-bootstrap.d.ts +9 -1
- package/dist/plugins/ecosystem/plugin-bootstrap.d.ts.map +1 -1
- package/dist/plugins/ecosystem/plugin-bootstrap.js +5 -0
- package/dist/plugins/ecosystem/plugin-bootstrap.js.map +1 -1
- package/dist/profiles/builtin-suites.d.ts +5 -1
- package/dist/profiles/builtin-suites.d.ts.map +1 -1
- package/dist/profiles/builtin-suites.js +6 -1
- package/dist/profiles/builtin-suites.js.map +1 -1
- package/dist/utils/photon.d.ts +2 -2
- package/dist/utils/photon.d.ts.map +1 -1
- package/dist/utils/photon.js +2 -2
- package/dist/utils/photon.js.map +1 -1
- package/docs/compaction.md +1 -3
- package/docs/docs.json +4 -0
- package/docs/index.md +1 -0
- package/docs/mcp.md +103 -0
- package/docs/models.md +14 -22
- package/docs/providers.md +0 -1
- package/docs/rpc.md +1 -26
- package/docs/sdk.md +4 -6
- package/docs/settings.md +9 -12
- package/docs/skills.md +1 -9
- package/docs/usage.md +1 -1
- package/examples/extensions/bash-spawn-hook/index.ts +7 -2
- package/examples/extensions/built-in-tool-renderer/index.ts +4 -2
- package/examples/extensions/minimal-mode/index.ts +2 -2
- package/examples/extensions/truncated-tool/index.ts +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/extensions/with-deps/plugin.json +1 -1
- package/examples/sdk/10-settings.ts +2 -4
- package/examples/sdk/12-full-control.ts +1 -2
- package/package.json +3 -4
- package/dist/bundle/chunks/chunk-6ZKDNZHA.js +0 -145
- package/dist/bundle/chunks/chunk-BFC2BDVJ.js +0 -13
- package/dist/bundle/chunks/chunk-MOHOLL3F.js +0 -1456
- package/dist/bundle/chunks/virtual-modules-KZ5DRH7Q.js +0 -2
- package/dist/core/extensions/bootstrap-branch-summary-policy.d.ts +0 -7
- package/dist/core/extensions/bootstrap-branch-summary-policy.d.ts.map +0 -1
- package/dist/core/extensions/bootstrap-branch-summary-policy.js +0 -28
- package/dist/core/extensions/bootstrap-branch-summary-policy.js.map +0 -1
- package/dist/core/extensions/bootstrap-compaction-policy.d.ts +0 -7
- package/dist/core/extensions/bootstrap-compaction-policy.d.ts.map +0 -1
- package/dist/core/extensions/bootstrap-compaction-policy.js +0 -82
- package/dist/core/extensions/bootstrap-compaction-policy.js.map +0 -1
- package/dist/core/extensions/bootstrap-overflow-policy.d.ts +0 -7
- package/dist/core/extensions/bootstrap-overflow-policy.d.ts.map +0 -1
- package/dist/core/extensions/bootstrap-overflow-policy.js +0 -30
- package/dist/core/extensions/bootstrap-overflow-policy.js.map +0 -1
- package/dist/core/extensions/bootstrap-retry-policy.d.ts +0 -7
- package/dist/core/extensions/bootstrap-retry-policy.d.ts.map +0 -1
- package/dist/core/extensions/bootstrap-retry-policy.js +0 -29
- package/dist/core/extensions/bootstrap-retry-policy.js.map +0 -1
- package/dist/core/extensions/bootstrap-tools.d.ts +0 -20
- package/dist/core/extensions/bootstrap-tools.d.ts.map +0 -1
- package/dist/core/extensions/bootstrap-tools.js +0 -36
- package/dist/core/extensions/bootstrap-tools.js.map +0 -1
- package/dist/core/extensions/microcompact.d.ts +0 -80
- package/dist/core/extensions/microcompact.d.ts.map +0 -1
- package/dist/core/extensions/microcompact.js +0 -134
- package/dist/core/extensions/microcompact.js.map +0 -1
- package/dist/core/extensions/provider-failover.d.ts +0 -106
- package/dist/core/extensions/provider-failover.d.ts.map +0 -1
- package/dist/core/extensions/provider-failover.js.map +0 -1
- package/dist/core/tools/bash.d.ts.map +0 -1
- package/dist/core/tools/bash.js.map +0 -1
- package/dist/core/tools/edit.d.ts.map +0 -1
- package/dist/core/tools/edit.js.map +0 -1
- package/dist/core/tools/find.d.ts.map +0 -1
- package/dist/core/tools/find.js.map +0 -1
- package/dist/core/tools/grep.d.ts.map +0 -1
- package/dist/core/tools/grep.js.map +0 -1
- package/dist/core/tools/ls.d.ts.map +0 -1
- package/dist/core/tools/powershell.d.ts.map +0 -1
- package/dist/core/tools/powershell.js.map +0 -1
- package/dist/core/tools/read.d.ts.map +0 -1
- package/dist/core/tools/read.js.map +0 -1
- package/dist/core/tools/write.d.ts.map +0 -1
- package/dist/core/tools/write.js.map +0 -1
- package/dist/plugins/mcp-http.d.ts.map +0 -1
- package/dist/plugins/mcp-http.js.map +0 -1
- package/dist/profile/child-facade.d.ts +0 -44
- package/dist/profile/child-facade.d.ts.map +0 -1
- package/dist/profile/child-facade.js +0 -56
- package/dist/profile/child-facade.js.map +0 -1
- package/dist/profile/dependency-wiring.d.ts +0 -48
- package/dist/profile/dependency-wiring.d.ts.map +0 -1
- package/dist/profile/dependency-wiring.js +0 -56
- package/dist/profile/dependency-wiring.js.map +0 -1
- package/dist/profile/domain-recovery.d.ts +0 -60
- package/dist/profile/domain-recovery.d.ts.map +0 -1
- package/dist/profile/domain-recovery.js +0 -94
- package/dist/profile/domain-recovery.js.map +0 -1
- package/dist/profile/first-roles.d.ts +0 -30
- package/dist/profile/first-roles.d.ts.map +0 -1
- package/dist/profile/first-roles.js +0 -83
- package/dist/profile/first-roles.js.map +0 -1
- package/dist/profile/goal-plugin.d.ts +0 -38
- package/dist/profile/goal-plugin.d.ts.map +0 -1
- package/dist/profile/goal-plugin.js +0 -132
- package/dist/profile/goal-plugin.js.map +0 -1
- package/dist/profile/plan-plugin.d.ts +0 -44
- package/dist/profile/plan-plugin.d.ts.map +0 -1
- package/dist/profile/plan-plugin.js +0 -157
- package/dist/profile/plan-plugin.js.map +0 -1
- package/dist/profile/policy-manifest.d.ts +0 -53
- package/dist/profile/policy-manifest.d.ts.map +0 -1
- package/dist/profile/policy-manifest.js +0 -53
- package/dist/profile/policy-manifest.js.map +0 -1
- package/dist/profile/role-assembly.d.ts +0 -47
- package/dist/profile/role-assembly.d.ts.map +0 -1
- package/dist/profile/role-assembly.js +0 -31
- package/dist/profile/role-assembly.js.map +0 -1
- package/dist/profile/role-catalog.d.ts +0 -43
- package/dist/profile/role-catalog.d.ts.map +0 -1
- package/dist/profile/role-catalog.js +0 -132
- package/dist/profile/role-catalog.js.map +0 -1
- package/dist/profile/role-orchestrator.d.ts +0 -123
- package/dist/profile/role-orchestrator.d.ts.map +0 -1
- package/dist/profile/role-orchestrator.js +0 -195
- package/dist/profile/role-orchestrator.js.map +0 -1
- package/dist/profile/role-runner.d.ts +0 -99
- package/dist/profile/role-runner.d.ts.map +0 -1
- package/dist/profile/role-runner.js +0 -79
- package/dist/profile/role-runner.js.map +0 -1
- package/dist/profile/root-facade.d.ts +0 -36
- package/dist/profile/root-facade.d.ts.map +0 -1
- package/dist/profile/root-facade.js +0 -49
- package/dist/profile/root-facade.js.map +0 -1
- package/dist/profile/skill-discovery-wiring.d.ts +0 -58
- package/dist/profile/skill-discovery-wiring.d.ts.map +0 -1
- package/dist/profile/skill-discovery-wiring.js +0 -80
- package/dist/profile/skill-discovery-wiring.js.map +0 -1
- package/dist/profile/state-store.d.ts +0 -62
- package/dist/profile/state-store.d.ts.map +0 -1
- package/dist/profile/state-store.js +0 -144
- package/dist/profile/state-store.js.map +0 -1
- package/dist/profile/todo-plugin.d.ts +0 -37
- package/dist/profile/todo-plugin.d.ts.map +0 -1
- package/dist/profile/todo-plugin.js +0 -137
- package/dist/profile/todo-plugin.js.map +0 -1
- package/dist/server/create-harness.d.ts +0 -26
- package/dist/server/create-harness.d.ts.map +0 -1
- package/dist/server/create-harness.js +0 -106
- package/dist/server/create-harness.js.map +0 -1
- /package/{dist/plugins → bundled-plugins/mcp-http/dist}/mcp-http.d.ts +0 -0
|
@@ -11,14 +11,12 @@ export declare function formatCwdForFooter(cwd: string, home: string | undefined
|
|
|
11
11
|
* Computes token/context stats from session, gets git branch and extension statuses from provider.
|
|
12
12
|
*/
|
|
13
13
|
export declare class FooterComponent implements Component {
|
|
14
|
-
private autoCompactEnabled;
|
|
15
14
|
private session;
|
|
16
15
|
private footerData;
|
|
17
16
|
private sessionStats?;
|
|
18
17
|
constructor(session: AgentSession, footerData: ReadonlyFooterDataProvider);
|
|
19
18
|
setSession(session: AgentSession): void;
|
|
20
19
|
private get facade();
|
|
21
|
-
setAutoCompactEnabled(enabled: boolean): void;
|
|
22
20
|
/**
|
|
23
21
|
* No-op: git branch caching now handled by provider.
|
|
24
22
|
* Kept for compatibility with existing call sites in interactive-mode.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"footer.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/footer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAiC,MAAM,kBAAkB,CAAC;AACjF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAInE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AAiBxF;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMlD;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAYhF;AAmGD;;;GAGG;AACH,qBAAa,eAAgB,YAAW,SAAS;IAChD,OAAO,CAAC,kBAAkB,CAAQ;IAClC,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,UAAU,CAA6B;IAC/C,OAAO,CAAC,YAAY,CAAC,CAAqB;IAE1C,YAAY,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,0BAA0B,EAGxE;IAED,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAEtC;IAKD,OAAO,KAAK,MAAM,GAEjB;IAED,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAE5C;IAED;;;OAGG;IACH,UAAU,IAAI,IAAI,CAEjB;IAED;;;OAGG;IACH,OAAO,IAAI,IAAI,CAEd;IAED;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAgFvB;;;;;OAKG;IACH,sBAAsB,IAAI,OAAO,CAEhC;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAoK9B;CACD","sourcesContent":["import { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport { type Component, truncateToWidth, visibleWidth } from \"@agent-forge/tui\";\nimport type { AgentSession } from \"../../../core/agent-session.ts\";\nimport { areExperimentalFeaturesEnabled } from \"../../../core/experimental.ts\";\nimport type { ContextUsage } from \"../../../core/extensions/public-api.ts\";\nimport { type CodingAgentFacadeV1, createCodingAgentFacade } from \"../../../core/facade/index.ts\";\nimport type { ReadonlyFooterDataProvider } from \"../../../core/footer-data-provider.ts\";\nimport { t } from \"../../../core/i18n/index.ts\";\nimport { addUsageToTotals, createUsageTotals, type UsageTotals } from \"../../../core/usage-totals.ts\";\nimport { theme } from \"../theme/theme.ts\";\n\n/**\n * Sanitize text for display in a single-line status.\n * Removes newlines, tabs, carriage returns, and other control characters.\n */\nfunction sanitizeStatusText(text: string): string {\n\t// Replace newlines, tabs, carriage returns with space, then collapse multiple spaces\n\treturn text\n\t\t.replace(/[\\r\\n\\t]/g, \" \")\n\t\t.replace(/ +/g, \" \")\n\t\t.trim();\n}\n\n/**\n * Format token counts for compact footer display.\n */\nexport function formatTokens(count: number): string {\n\tif (count < 1000) return count.toString();\n\tif (count < 10000) return `${(count / 1000).toFixed(1)}k`;\n\tif (count < 1000000) return `${Math.round(count / 1000)}k`;\n\tif (count < 10000000) return `${(count / 1000000).toFixed(1)}M`;\n\treturn `${Math.round(count / 1000000)}M`;\n}\n\nexport function formatCwdForFooter(cwd: string, home: string | undefined): string {\n\tif (!home) return cwd;\n\n\tconst resolvedCwd = resolve(cwd);\n\tconst resolvedHome = resolve(home);\n\tconst relativeToHome = relative(resolvedHome, resolvedCwd);\n\tconst isInsideHome =\n\t\trelativeToHome === \"\" ||\n\t\t(relativeToHome !== \"..\" && !relativeToHome.startsWith(`..${sep}`) && !isAbsolute(relativeToHome));\n\n\tif (!isInsideHome) return cwd;\n\treturn relativeToHome === \"\" ? \"~\" : `~${sep}${relativeToHome}`;\n}\n\n/** Shape of the `goal.state` custom entry data written by the builtin goal capability. */\ninterface FooterGoalState {\n\tgoals?: Array<{ title?: unknown }>;\n}\n\n/** Shape of the `todo.state` custom entry data written by the builtin todo capability. */\ninterface FooterTodoState {\n\ttodos?: Array<{ status?: unknown }>;\n}\n\n/** Shape of the `workflow.state` custom entry data written by the workflow plugin. */\ninterface FooterWorkflowState {\n\tworkflows?: Array<{\n\t\ttitle?: unknown;\n\t\tstatus?: unknown;\n\t\truntime?: Array<{ status?: unknown }>;\n\t\tdiagnostics?: unknown[];\n\t}>;\n}\n\n/**\n * Shape of the `provider.failover.state` snapshot written by the provider-failover\n * plugin (设计 供应商能力槽位与主备切换 §4.7). Only the last entry per session wins;\n * `status: \"open\"` is the only rendered state (half-open is transient — entered at\n * request time and immediately resolved to an open/closed snapshot).\n */\ninterface FooterFailoverState {\n\tchainId?: unknown;\n\tstatus?: unknown;\n\tbackupProvider?: unknown;\n\tprobeAtMs?: unknown;\n}\n\n/**\n * Build the one-line failover summary from the latest `provider.failover.state`\n * snapshot: `failover: 主 <primary> 不可用 • 经 <backup> • 下次试探 <Ns>`. The\n * countdown is computed against `nowMs`; at or past zero it reads `等待试探`\n * (cooldown over, next real request is the probe). Returns undefined when there is\n * nothing to show (no snapshot, not open, or an unusable chainId).\n */\nfunction summarizeFailoverState(state: FooterFailoverState | undefined, nowMs: number): string | undefined {\n\tif (state?.status !== \"open\" || typeof state.chainId !== \"string\" || state.chainId === \"\") return undefined;\n\tconst parts = [`failover: 主 ${state.chainId} 不可用`];\n\tif (typeof state.backupProvider === \"string\" && state.backupProvider !== \"\") {\n\t\tparts.push(`经 ${state.backupProvider}`);\n\t}\n\tconst probeAtMs = typeof state.probeAtMs === \"number\" ? state.probeAtMs : 0;\n\tif (probeAtMs - nowMs <= 0) parts.push(\"等待试探\");\n\telse parts.push(`下次试探 ${Math.ceil((probeAtMs - nowMs) / 1000)}s`);\n\treturn parts.join(\" • \");\n}\n\n/**\n * Build the one-line workflow summary from the latest `workflow.state` snapshot:\n * `wf: <title> <done>/<total>` plus status markers, in order — `▶n` (n>=2\n * parallel active stages), `⏸` (a stage awaiting review), `⚠` (non-empty\n * diagnostics), `✗` (failed workflow); done counts completed+skipped stages.\n * Picks the newest non-terminal workflow, falling back to the newest one when\n * all are terminal; returns undefined when there is no workflow to show.\n */\nfunction summarizeWorkflowState(state: FooterWorkflowState | undefined): string | undefined {\n\tconst workflows = state?.workflows;\n\tconst records = Array.isArray(workflows) ? workflows : [];\n\tconst record =\n\t\t[...records].reverse().find((item) => item?.status === \"draft\" || item?.status === \"running\") ?? records.at(-1);\n\tif (record === undefined || typeof record.title !== \"string\") {\n\t\treturn undefined;\n\t}\n\n\tconst stages = Array.isArray(record.runtime) ? record.runtime : [];\n\tconst done = stages.filter((stage) => stage?.status === \"completed\" || stage?.status === \"skipped\").length;\n\tconst activeCount = stages.filter((stage) => stage?.status === \"active\").length;\n\n\tconst parts = [`wf: ${record.title} ${done}/${stages.length}`];\n\tif (activeCount >= 2) parts.push(`▶${activeCount}`);\n\tif (stages.some((stage) => stage?.status === \"awaiting_review\")) parts.push(\"⏸\");\n\tif (Array.isArray(record.diagnostics) && record.diagnostics.length > 0) parts.push(\"⚠\");\n\tif (record.status === \"failed\") parts.push(\"✗\");\n\treturn parts.join(\" \");\n}\n\n/** Session-derived stats cached across frames; all fields come from one entries scan. */\ninterface CachedSessionStats {\n\tsession: AgentSession;\n\tsessionId: string;\n\tleafId: string | null;\n\tmodel: unknown;\n\tusageTotals: UsageTotals;\n\tlatestCacheHitRate: number | undefined;\n\tgoalTitle: string | undefined;\n\ttodoDone: number;\n\ttodoTotal: number;\n\tworkflowState: FooterWorkflowState | undefined;\n\tfailoverState: FooterFailoverState | undefined;\n\tcontextUsage: ContextUsage | undefined;\n}\n\n/**\n * Footer component that shows pwd, token stats, and context usage.\n * Computes token/context stats from session, gets git branch and extension statuses from provider.\n */\nexport class FooterComponent implements Component {\n\tprivate autoCompactEnabled = true;\n\tprivate session: AgentSession;\n\tprivate footerData: ReadonlyFooterDataProvider;\n\tprivate sessionStats?: CachedSessionStats;\n\n\tconstructor(session: AgentSession, footerData: ReadonlyFooterDataProvider) {\n\t\tthis.session = session;\n\t\tthis.footerData = footerData;\n\t}\n\n\tsetSession(session: AgentSession): void {\n\t\tthis.session = session;\n\t}\n\n\t// Stable facade (阶段 1 slice 1): derived on each access; the facade and\n\t// `this.session` always resolve to the same AgentSession, so setSession()\n\t// rebind stays the only rebind path.\n\tprivate get facade(): CodingAgentFacadeV1 {\n\t\treturn createCodingAgentFacade(this.session);\n\t}\n\n\tsetAutoCompactEnabled(enabled: boolean): void {\n\t\tthis.autoCompactEnabled = enabled;\n\t}\n\n\t/**\n\t * No-op: git branch caching now handled by provider.\n\t * Kept for compatibility with existing call sites in interactive-mode.\n\t */\n\tinvalidate(): void {\n\t\t// No-op: git branch is cached/invalidated by provider\n\t}\n\n\t/**\n\t * Clean up resources.\n\t * Git watcher cleanup now handled by provider.\n\t */\n\tdispose(): void {\n\t\t// Git watcher cleanup handled by provider\n\t}\n\n\t/**\n\t * Usage totals, goal/todo/workflow state, and context usage scan the whole session, and the\n\t * footer renders on every frame. The session is append-only and every append moves the leaf,\n\t * so the scan results only change with the session, leaf, or the model whose context window\n\t * applies; until then the previous frame's values are reused.\n\t */\n\tprivate getSessionStats(): CachedSessionStats {\n\t\tconst facade = this.facade;\n\t\tconst sessionId = facade.getSessionId();\n\t\tconst leafId = facade.getLeafId();\n\t\tconst model = facade.getModel();\n\t\tconst cached = this.sessionStats;\n\t\tif (\n\t\t\tcached &&\n\t\t\tcached.session === this.session &&\n\t\t\tcached.sessionId === sessionId &&\n\t\t\tcached.leafId === leafId &&\n\t\t\tcached.model === model\n\t\t) {\n\t\t\treturn cached;\n\t\t}\n\n\t\t// Calculate cumulative usage from ALL session entries (not just post-compaction messages)\n\t\tconst usageTotals = createUsageTotals();\n\t\tlet latestCacheHitRate: number | undefined;\n\n\t\t// Latest goal/todo capability state: the builtin goal/todo capabilities announce\n\t\t// goal.changed / todo.changed and persist the same state as goal.state / todo.state\n\t\t// custom entries; the last entry per type wins.\n\t\tlet goalTitle: string | undefined;\n\t\tlet todoDone = 0;\n\t\tlet todoTotal = 0;\n\t\tlet workflowState: FooterWorkflowState | undefined;\n\t\tlet failoverState: FooterFailoverState | undefined;\n\n\t\tfor (const entry of facade.getEntries()) {\n\t\t\tif (entry.type === \"message\" && entry.message.role === \"assistant\") {\n\t\t\t\taddUsageToTotals(usageTotals, entry.message.usage);\n\n\t\t\t\tconst latestPromptTokens =\n\t\t\t\t\tentry.message.usage.input + entry.message.usage.cacheRead + entry.message.usage.cacheWrite;\n\t\t\t\tlatestCacheHitRate =\n\t\t\t\t\tlatestPromptTokens > 0 ? (entry.message.usage.cacheRead / latestPromptTokens) * 100 : undefined;\n\t\t\t} else if (entry.type === \"message\" && entry.message.role === \"toolResult\" && entry.message.usage) {\n\t\t\t\taddUsageToTotals(usageTotals, entry.message.usage);\n\t\t\t} else if ((entry.type === \"branch_summary\" || entry.type === \"compaction\") && entry.usage) {\n\t\t\t\taddUsageToTotals(usageTotals, entry.usage);\n\t\t\t} else if (entry.type === \"custom\" && entry.customType === \"goal.state\") {\n\t\t\t\tconst goals = (entry.data as FooterGoalState | undefined)?.goals;\n\t\t\t\tconst current = Array.isArray(goals) ? goals.at(-1) : undefined;\n\t\t\t\tif (current && typeof current.title === \"string\") {\n\t\t\t\t\tgoalTitle = current.title;\n\t\t\t\t}\n\t\t\t} else if (entry.type === \"custom\" && entry.customType === \"todo.state\") {\n\t\t\t\tconst todos = (entry.data as FooterTodoState | undefined)?.todos;\n\t\t\t\tif (Array.isArray(todos)) {\n\t\t\t\t\ttodoDone = todos.filter((item) => item?.status === \"done\").length;\n\t\t\t\t\ttodoTotal = todos.length;\n\t\t\t\t}\n\t\t\t} else if (entry.type === \"custom\" && entry.customType === \"workflow.state\") {\n\t\t\t\tworkflowState = entry.data as FooterWorkflowState | undefined;\n\t\t\t} else if (entry.type === \"custom\" && entry.customType === \"provider.failover.state\") {\n\t\t\t\tfailoverState = entry.data as FooterFailoverState | undefined;\n\t\t\t}\n\t\t}\n\n\t\t// Calculate context usage from session (handles compaction correctly).\n\t\t// After compaction, tokens are unknown until the next LLM response.\n\t\tconst contextUsage = facade.getContextUsage();\n\t\tthis.sessionStats = {\n\t\t\tsession: this.session,\n\t\t\tsessionId,\n\t\t\tleafId,\n\t\t\tmodel,\n\t\t\tusageTotals,\n\t\t\tlatestCacheHitRate,\n\t\t\tgoalTitle,\n\t\t\ttodoDone,\n\t\t\ttodoTotal,\n\t\t\tworkflowState,\n\t\t\tfailoverState,\n\t\t\tcontextUsage,\n\t\t};\n\t\treturn this.sessionStats;\n\t}\n\n\t/**\n\t * Whether the latest `provider.failover.state` snapshot reports an open\n\t * breaker. Drives the interactive-mode per-second re-render ticker (设计\n\t * 供应商能力槽位与主备切换 §4.7 Phase 3); cheap because it reuses the\n\t * cached session stats.\n\t */\n\tisProviderFailoverOpen(): boolean {\n\t\treturn this.getSessionStats().failoverState?.status === \"open\";\n\t}\n\n\trender(width: number): string[] {\n\t\tconst state = this.facade.getState();\n\t\tconst {\n\t\t\tusageTotals,\n\t\t\tlatestCacheHitRate,\n\t\t\tcontextUsage,\n\t\t\tgoalTitle,\n\t\t\ttodoDone,\n\t\t\ttodoTotal,\n\t\t\tworkflowState,\n\t\t\tfailoverState,\n\t\t} = this.getSessionStats();\n\t\tconst contextWindow = contextUsage?.contextWindow ?? state.model?.contextWindow ?? 0;\n\t\tconst contextPercentValue = contextUsage?.percent ?? 0;\n\t\tconst contextPercent = contextUsage?.percent !== null ? contextPercentValue.toFixed(1) : \"?\";\n\n\t\t// Replace home directory with ~\n\t\tlet pwd = formatCwdForFooter(this.facade.getCwd(), process.env.HOME || process.env.USERPROFILE);\n\n\t\t// Add git branch if available\n\t\tconst branch = this.footerData.getGitBranch();\n\t\tif (branch) {\n\t\t\tpwd = `${pwd} (${branch})`;\n\t\t}\n\n\t\t// Add session name if set\n\t\tconst sessionName = this.facade.getSessionName();\n\t\tif (sessionName) {\n\t\t\tpwd = `${pwd} • ${sessionName}`;\n\t\t}\n\n\t\t// Build stats line\n\t\tconst statsParts = [];\n\t\tif (usageTotals.input) statsParts.push(`↑${formatTokens(usageTotals.input)}`);\n\t\tif (usageTotals.output) statsParts.push(`↓${formatTokens(usageTotals.output)}`);\n\t\tif (usageTotals.cacheRead) statsParts.push(`R${formatTokens(usageTotals.cacheRead)}`);\n\t\tif (usageTotals.cacheWrite) statsParts.push(`W${formatTokens(usageTotals.cacheWrite)}`);\n\t\tif ((usageTotals.cacheRead > 0 || usageTotals.cacheWrite > 0) && latestCacheHitRate !== undefined) {\n\t\t\tstatsParts.push(`CH${latestCacheHitRate.toFixed(1)}%`);\n\t\t}\n\n\t\t// Kimi Coding is subscription-backed despite using API-key authentication.\n\t\tconst usingSubscription = state.model\n\t\t\t? state.model.provider === \"kimi-coding\" || this.facade.isUsingSubscription(state.model.provider)\n\t\t\t: false;\n\t\tif (usageTotals.cost || usingSubscription) {\n\t\t\tconst costStr = `$${usageTotals.cost.toFixed(3)}${usingSubscription ? ` ${t(\"(sub)\")}` : \"\"}`;\n\t\t\tstatsParts.push(costStr);\n\t\t}\n\n\t\t// Colorize context percentage based on usage\n\t\tlet contextPercentStr: string;\n\t\tconst autoIndicator = this.autoCompactEnabled ? ` ${t(\"(auto)\")}` : \"\";\n\t\tconst contextPercentDisplay =\n\t\t\tcontextPercent === \"?\"\n\t\t\t\t? `?/${formatTokens(contextWindow)}${autoIndicator}`\n\t\t\t\t: `${contextPercent}%/${formatTokens(contextWindow)}${autoIndicator}`;\n\t\tif (contextPercentValue > 90) {\n\t\t\tcontextPercentStr = theme.fg(\"error\", contextPercentDisplay);\n\t\t} else if (contextPercentValue > 70) {\n\t\t\tcontextPercentStr = theme.fg(\"warning\", contextPercentDisplay);\n\t\t} else {\n\t\t\tcontextPercentStr = contextPercentDisplay;\n\t\t}\n\t\tstatsParts.push(contextPercentStr);\n\t\tif (areExperimentalFeaturesEnabled()) {\n\t\t\tstatsParts.push(`${theme.fg(\"dim\", \"•\")} ${theme.bold(theme.fg(\"warning\", \"xp\"))}`);\n\t\t}\n\n\t\tlet statsLeft = statsParts.join(\" \");\n\n\t\t// Add model name on the right side, plus thinking level if model supports it\n\t\tconst modelName = state.model?.id || t(\"no-model\");\n\n\t\tlet statsLeftWidth = visibleWidth(statsLeft);\n\n\t\t// If statsLeft is too wide, truncate it\n\t\tif (statsLeftWidth > width) {\n\t\t\tstatsLeft = truncateToWidth(statsLeft, width, \"...\");\n\t\t\tstatsLeftWidth = visibleWidth(statsLeft);\n\t\t}\n\n\t\t// Calculate available space for padding (minimum 2 spaces between stats and model)\n\t\tconst minPadding = 2;\n\n\t\t// Add thinking level indicator if model supports reasoning\n\t\tlet rightSideWithoutProvider = modelName;\n\t\tif (state.model?.reasoning) {\n\t\t\tconst thinkingLevel = state.thinkingLevel || \"off\";\n\t\t\trightSideWithoutProvider =\n\t\t\t\tthinkingLevel === \"off\"\n\t\t\t\t\t? t(\"{model} • thinking off\", { model: modelName })\n\t\t\t\t\t: `${modelName} • ${thinkingLevel}`;\n\t\t}\n\n\t\t// Prepend the provider in parentheses if there are multiple providers and there's enough room\n\t\tlet rightSide = rightSideWithoutProvider;\n\t\tif (this.footerData.getAvailableProviderCount() > 1 && state.model) {\n\t\t\trightSide = `(${state.model!.provider}) ${rightSideWithoutProvider}`;\n\t\t\tif (statsLeftWidth + minPadding + visibleWidth(rightSide) > width) {\n\t\t\t\t// Too wide, fall back\n\t\t\t\trightSide = rightSideWithoutProvider;\n\t\t\t}\n\t\t}\n\n\t\tconst rightSideWidth = visibleWidth(rightSide);\n\t\tconst totalNeeded = statsLeftWidth + minPadding + rightSideWidth;\n\n\t\tlet statsLine: string;\n\t\tif (totalNeeded <= width) {\n\t\t\t// Both fit - add padding to right-align model\n\t\t\tconst padding = \" \".repeat(width - statsLeftWidth - rightSideWidth);\n\t\t\tstatsLine = statsLeft + padding + rightSide;\n\t\t} else {\n\t\t\t// Need to truncate right side\n\t\t\tconst availableForRight = width - statsLeftWidth - minPadding;\n\t\t\tif (availableForRight > 0) {\n\t\t\t\tconst truncatedRight = truncateToWidth(rightSide, availableForRight, \"\");\n\t\t\t\tconst truncatedRightWidth = visibleWidth(truncatedRight);\n\t\t\t\tconst padding = \" \".repeat(Math.max(0, width - statsLeftWidth - truncatedRightWidth));\n\t\t\t\tstatsLine = statsLeft + padding + truncatedRight;\n\t\t\t} else {\n\t\t\t\t// Not enough space for right side at all\n\t\t\t\tstatsLine = statsLeft;\n\t\t\t}\n\t\t}\n\n\t\t// Apply dim to each part separately. statsLeft may contain color codes (for context %)\n\t\t// that end with a reset, which would clear an outer dim wrapper. So we dim the parts\n\t\t// before and after the colored section independently.\n\t\tconst dimStatsLeft = theme.fg(\"dim\", statsLeft);\n\t\tconst remainder = statsLine.slice(statsLeft.length); // padding + rightSide\n\t\tconst dimRemainder = theme.fg(\"dim\", remainder);\n\n\t\tconst pwdLine = truncateToWidth(theme.fg(\"dim\", pwd), width, theme.fg(\"dim\", \"...\"));\n\t\tconst lines = [pwdLine, dimStatsLeft + dimRemainder];\n\n\t\t// Add goal/todo status when either exists; a todo set without a goal\n\t\t// still surfaces its progress line alone.\n\t\tif (goalTitle !== undefined || todoTotal > 0) {\n\t\t\tconst goalParts: string[] = [];\n\t\t\tif (goalTitle !== undefined) goalParts.push(`goal: ${goalTitle}`);\n\t\t\tif (todoTotal > 0) goalParts.push(`todo ${todoDone}/${todoTotal}`);\n\t\t\tconst goalLine = theme.fg(\"dim\", sanitizeStatusText(goalParts.join(\" • \")));\n\t\t\tlines.push(truncateToWidth(goalLine, width, theme.fg(\"dim\", \"...\")));\n\t\t}\n\n\t\t// Add workflow status, only when a workflow snapshot reports one.\n\t\tconst workflowSummary = summarizeWorkflowState(workflowState);\n\t\tif (workflowSummary !== undefined) {\n\t\t\tconst workflowLine = theme.fg(\"dim\", sanitizeStatusText(workflowSummary));\n\t\t\tlines.push(truncateToWidth(workflowLine, width, theme.fg(\"dim\", \"...\")));\n\t\t}\n\n\t\t// Add provider failover status, only while the latest snapshot reports an\n\t\t// open breaker. Warning color: an active degradation, not passive info\n\t\t// (context% 变色先例). The countdown is recomputed per frame from Date.now().\n\t\tconst failoverSummary = summarizeFailoverState(failoverState, Date.now());\n\t\tif (failoverSummary !== undefined) {\n\t\t\tconst failoverLine = theme.fg(\"warning\", sanitizeStatusText(failoverSummary));\n\t\t\tlines.push(truncateToWidth(failoverLine, width, theme.fg(\"warning\", \"...\")));\n\t\t}\n\n\t\treturn lines;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"footer.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/footer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAiC,MAAM,kBAAkB,CAAC;AACjF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAInE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AAiBxF;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMlD;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAYhF;AAmGD;;;GAGG;AACH,qBAAa,eAAgB,YAAW,SAAS;IAChD,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,UAAU,CAA6B;IAC/C,OAAO,CAAC,YAAY,CAAC,CAAqB;IAE1C,YAAY,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,0BAA0B,EAGxE;IAED,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAEtC;IAKD,OAAO,KAAK,MAAM,GAEjB;IAED;;;OAGG;IACH,UAAU,IAAI,IAAI,CAEjB;IAED;;;OAGG;IACH,OAAO,IAAI,IAAI,CAEd;IAED;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAgFvB;;;;;OAKG;IACH,sBAAsB,IAAI,OAAO,CAEhC;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAmK9B;CACD","sourcesContent":["import { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport { type Component, truncateToWidth, visibleWidth } from \"@agent-forge/tui\";\nimport type { AgentSession } from \"../../../core/agent-session.ts\";\nimport { areExperimentalFeaturesEnabled } from \"../../../core/experimental.ts\";\nimport type { ContextUsage } from \"../../../core/extensions/public-api.ts\";\nimport { type CodingAgentFacadeV1, createCodingAgentFacade } from \"../../../core/facade/index.ts\";\nimport type { ReadonlyFooterDataProvider } from \"../../../core/footer-data-provider.ts\";\nimport { t } from \"../../../core/i18n/index.ts\";\nimport { addUsageToTotals, createUsageTotals, type UsageTotals } from \"../../../core/usage-totals.ts\";\nimport { theme } from \"../theme/theme.ts\";\n\n/**\n * Sanitize text for display in a single-line status.\n * Removes newlines, tabs, carriage returns, and other control characters.\n */\nfunction sanitizeStatusText(text: string): string {\n\t// Replace newlines, tabs, carriage returns with space, then collapse multiple spaces\n\treturn text\n\t\t.replace(/[\\r\\n\\t]/g, \" \")\n\t\t.replace(/ +/g, \" \")\n\t\t.trim();\n}\n\n/**\n * Format token counts for compact footer display.\n */\nexport function formatTokens(count: number): string {\n\tif (count < 1000) return count.toString();\n\tif (count < 10000) return `${(count / 1000).toFixed(1)}k`;\n\tif (count < 1000000) return `${Math.round(count / 1000)}k`;\n\tif (count < 10000000) return `${(count / 1000000).toFixed(1)}M`;\n\treturn `${Math.round(count / 1000000)}M`;\n}\n\nexport function formatCwdForFooter(cwd: string, home: string | undefined): string {\n\tif (!home) return cwd;\n\n\tconst resolvedCwd = resolve(cwd);\n\tconst resolvedHome = resolve(home);\n\tconst relativeToHome = relative(resolvedHome, resolvedCwd);\n\tconst isInsideHome =\n\t\trelativeToHome === \"\" ||\n\t\t(relativeToHome !== \"..\" && !relativeToHome.startsWith(`..${sep}`) && !isAbsolute(relativeToHome));\n\n\tif (!isInsideHome) return cwd;\n\treturn relativeToHome === \"\" ? \"~\" : `~${sep}${relativeToHome}`;\n}\n\n/** Shape of the `goal.state` custom entry data written by the builtin goal capability. */\ninterface FooterGoalState {\n\tgoals?: Array<{ title?: unknown }>;\n}\n\n/** Shape of the `todo.state` custom entry data written by the builtin todo capability. */\ninterface FooterTodoState {\n\ttodos?: Array<{ status?: unknown }>;\n}\n\n/** Shape of the `workflow.state` custom entry data written by the workflow plugin. */\ninterface FooterWorkflowState {\n\tworkflows?: Array<{\n\t\ttitle?: unknown;\n\t\tstatus?: unknown;\n\t\truntime?: Array<{ status?: unknown }>;\n\t\tdiagnostics?: unknown[];\n\t}>;\n}\n\n/**\n * Shape of the `provider.failover.state` snapshot written by the provider-failover\n * plugin (设计 供应商能力槽位与主备切换 §4.7). Only the last entry per session wins;\n * `status: \"open\"` is the only rendered state (half-open is transient — entered at\n * request time and immediately resolved to an open/closed snapshot).\n */\ninterface FooterFailoverState {\n\tchainId?: unknown;\n\tstatus?: unknown;\n\tbackupProvider?: unknown;\n\tprobeAtMs?: unknown;\n}\n\n/**\n * Build the one-line failover summary from the latest `provider.failover.state`\n * snapshot: `failover: 主 <primary> 不可用 • 经 <backup> • 下次试探 <Ns>`. The\n * countdown is computed against `nowMs`; at or past zero it reads `等待试探`\n * (cooldown over, next real request is the probe). Returns undefined when there is\n * nothing to show (no snapshot, not open, or an unusable chainId).\n */\nfunction summarizeFailoverState(state: FooterFailoverState | undefined, nowMs: number): string | undefined {\n\tif (state?.status !== \"open\" || typeof state.chainId !== \"string\" || state.chainId === \"\") return undefined;\n\tconst parts = [`failover: 主 ${state.chainId} 不可用`];\n\tif (typeof state.backupProvider === \"string\" && state.backupProvider !== \"\") {\n\t\tparts.push(`经 ${state.backupProvider}`);\n\t}\n\tconst probeAtMs = typeof state.probeAtMs === \"number\" ? state.probeAtMs : 0;\n\tif (probeAtMs - nowMs <= 0) parts.push(\"等待试探\");\n\telse parts.push(`下次试探 ${Math.ceil((probeAtMs - nowMs) / 1000)}s`);\n\treturn parts.join(\" • \");\n}\n\n/**\n * Build the one-line workflow summary from the latest `workflow.state` snapshot:\n * `wf: <title> <done>/<total>` plus status markers, in order — `▶n` (n>=2\n * parallel active stages), `⏸` (a stage awaiting review), `⚠` (non-empty\n * diagnostics), `✗` (failed workflow); done counts completed+skipped stages.\n * Picks the newest non-terminal workflow, falling back to the newest one when\n * all are terminal; returns undefined when there is no workflow to show.\n */\nfunction summarizeWorkflowState(state: FooterWorkflowState | undefined): string | undefined {\n\tconst workflows = state?.workflows;\n\tconst records = Array.isArray(workflows) ? workflows : [];\n\tconst record =\n\t\t[...records].reverse().find((item) => item?.status === \"draft\" || item?.status === \"running\") ?? records.at(-1);\n\tif (record === undefined || typeof record.title !== \"string\") {\n\t\treturn undefined;\n\t}\n\n\tconst stages = Array.isArray(record.runtime) ? record.runtime : [];\n\tconst done = stages.filter((stage) => stage?.status === \"completed\" || stage?.status === \"skipped\").length;\n\tconst activeCount = stages.filter((stage) => stage?.status === \"active\").length;\n\n\tconst parts = [`wf: ${record.title} ${done}/${stages.length}`];\n\tif (activeCount >= 2) parts.push(`▶${activeCount}`);\n\tif (stages.some((stage) => stage?.status === \"awaiting_review\")) parts.push(\"⏸\");\n\tif (Array.isArray(record.diagnostics) && record.diagnostics.length > 0) parts.push(\"⚠\");\n\tif (record.status === \"failed\") parts.push(\"✗\");\n\treturn parts.join(\" \");\n}\n\n/** Session-derived stats cached across frames; all fields come from one entries scan. */\ninterface CachedSessionStats {\n\tsession: AgentSession;\n\tsessionId: string;\n\tleafId: string | null;\n\tmodel: unknown;\n\tusageTotals: UsageTotals;\n\tlatestCacheHitRate: number | undefined;\n\tgoalTitle: string | undefined;\n\ttodoDone: number;\n\ttodoTotal: number;\n\tworkflowState: FooterWorkflowState | undefined;\n\tfailoverState: FooterFailoverState | undefined;\n\tcontextUsage: ContextUsage | undefined;\n}\n\n/**\n * Footer component that shows pwd, token stats, and context usage.\n * Computes token/context stats from session, gets git branch and extension statuses from provider.\n */\nexport class FooterComponent implements Component {\n\tprivate session: AgentSession;\n\tprivate footerData: ReadonlyFooterDataProvider;\n\tprivate sessionStats?: CachedSessionStats;\n\n\tconstructor(session: AgentSession, footerData: ReadonlyFooterDataProvider) {\n\t\tthis.session = session;\n\t\tthis.footerData = footerData;\n\t}\n\n\tsetSession(session: AgentSession): void {\n\t\tthis.session = session;\n\t}\n\n\t// Stable facade (阶段 1 slice 1): derived on each access; the facade and\n\t// `this.session` always resolve to the same AgentSession, so setSession()\n\t// rebind stays the only rebind path.\n\tprivate get facade(): CodingAgentFacadeV1 {\n\t\treturn createCodingAgentFacade(this.session);\n\t}\n\n\t/**\n\t * No-op: git branch caching now handled by provider.\n\t * Kept for compatibility with existing call sites in interactive-mode.\n\t */\n\tinvalidate(): void {\n\t\t// No-op: git branch is cached/invalidated by provider\n\t}\n\n\t/**\n\t * Clean up resources.\n\t * Git watcher cleanup now handled by provider.\n\t */\n\tdispose(): void {\n\t\t// Git watcher cleanup handled by provider\n\t}\n\n\t/**\n\t * Usage totals, goal/todo/workflow state, and context usage scan the whole session, and the\n\t * footer renders on every frame. The session is append-only and every append moves the leaf,\n\t * so the scan results only change with the session, leaf, or the model whose context window\n\t * applies; until then the previous frame's values are reused.\n\t */\n\tprivate getSessionStats(): CachedSessionStats {\n\t\tconst facade = this.facade;\n\t\tconst sessionId = facade.getSessionId();\n\t\tconst leafId = facade.getLeafId();\n\t\tconst model = facade.getModel();\n\t\tconst cached = this.sessionStats;\n\t\tif (\n\t\t\tcached &&\n\t\t\tcached.session === this.session &&\n\t\t\tcached.sessionId === sessionId &&\n\t\t\tcached.leafId === leafId &&\n\t\t\tcached.model === model\n\t\t) {\n\t\t\treturn cached;\n\t\t}\n\n\t\t// Calculate cumulative usage from ALL session entries (not just post-compaction messages)\n\t\tconst usageTotals = createUsageTotals();\n\t\tlet latestCacheHitRate: number | undefined;\n\n\t\t// Latest goal/todo capability state: the builtin goal/todo capabilities announce\n\t\t// goal.changed / todo.changed and persist the same state as goal.state / todo.state\n\t\t// custom entries; the last entry per type wins.\n\t\tlet goalTitle: string | undefined;\n\t\tlet todoDone = 0;\n\t\tlet todoTotal = 0;\n\t\tlet workflowState: FooterWorkflowState | undefined;\n\t\tlet failoverState: FooterFailoverState | undefined;\n\n\t\tfor (const entry of facade.getEntries()) {\n\t\t\tif (entry.type === \"message\" && entry.message.role === \"assistant\") {\n\t\t\t\taddUsageToTotals(usageTotals, entry.message.usage);\n\n\t\t\t\tconst latestPromptTokens =\n\t\t\t\t\tentry.message.usage.input + entry.message.usage.cacheRead + entry.message.usage.cacheWrite;\n\t\t\t\tlatestCacheHitRate =\n\t\t\t\t\tlatestPromptTokens > 0 ? (entry.message.usage.cacheRead / latestPromptTokens) * 100 : undefined;\n\t\t\t} else if (entry.type === \"message\" && entry.message.role === \"toolResult\" && entry.message.usage) {\n\t\t\t\taddUsageToTotals(usageTotals, entry.message.usage);\n\t\t\t} else if ((entry.type === \"branch_summary\" || entry.type === \"compaction\") && entry.usage) {\n\t\t\t\taddUsageToTotals(usageTotals, entry.usage);\n\t\t\t} else if (entry.type === \"custom\" && entry.customType === \"goal.state\") {\n\t\t\t\tconst goals = (entry.data as FooterGoalState | undefined)?.goals;\n\t\t\t\tconst current = Array.isArray(goals) ? goals.at(-1) : undefined;\n\t\t\t\tif (current && typeof current.title === \"string\") {\n\t\t\t\t\tgoalTitle = current.title;\n\t\t\t\t}\n\t\t\t} else if (entry.type === \"custom\" && entry.customType === \"todo.state\") {\n\t\t\t\tconst todos = (entry.data as FooterTodoState | undefined)?.todos;\n\t\t\t\tif (Array.isArray(todos)) {\n\t\t\t\t\ttodoDone = todos.filter((item) => item?.status === \"done\").length;\n\t\t\t\t\ttodoTotal = todos.length;\n\t\t\t\t}\n\t\t\t} else if (entry.type === \"custom\" && entry.customType === \"workflow.state\") {\n\t\t\t\tworkflowState = entry.data as FooterWorkflowState | undefined;\n\t\t\t} else if (entry.type === \"custom\" && entry.customType === \"provider.failover.state\") {\n\t\t\t\tfailoverState = entry.data as FooterFailoverState | undefined;\n\t\t\t}\n\t\t}\n\n\t\t// Calculate context usage from session (handles compaction correctly).\n\t\t// After compaction, tokens are unknown until the next LLM response.\n\t\tconst contextUsage = facade.getContextUsage();\n\t\tthis.sessionStats = {\n\t\t\tsession: this.session,\n\t\t\tsessionId,\n\t\t\tleafId,\n\t\t\tmodel,\n\t\t\tusageTotals,\n\t\t\tlatestCacheHitRate,\n\t\t\tgoalTitle,\n\t\t\ttodoDone,\n\t\t\ttodoTotal,\n\t\t\tworkflowState,\n\t\t\tfailoverState,\n\t\t\tcontextUsage,\n\t\t};\n\t\treturn this.sessionStats;\n\t}\n\n\t/**\n\t * Whether the latest `provider.failover.state` snapshot reports an open\n\t * breaker. Drives the interactive-mode per-second re-render ticker (设计\n\t * 供应商能力槽位与主备切换 §4.7 Phase 3); cheap because it reuses the\n\t * cached session stats.\n\t */\n\tisProviderFailoverOpen(): boolean {\n\t\treturn this.getSessionStats().failoverState?.status === \"open\";\n\t}\n\n\trender(width: number): string[] {\n\t\tconst state = this.facade.getState();\n\t\tconst {\n\t\t\tusageTotals,\n\t\t\tlatestCacheHitRate,\n\t\t\tcontextUsage,\n\t\t\tgoalTitle,\n\t\t\ttodoDone,\n\t\t\ttodoTotal,\n\t\t\tworkflowState,\n\t\t\tfailoverState,\n\t\t} = this.getSessionStats();\n\t\tconst contextWindow = contextUsage?.contextWindow ?? state.model?.contextWindow ?? 0;\n\t\tconst contextPercentValue = contextUsage?.percent ?? 0;\n\t\tconst contextPercent = contextUsage?.percent !== null ? contextPercentValue.toFixed(1) : \"?\";\n\n\t\t// Replace home directory with ~\n\t\tlet pwd = formatCwdForFooter(this.facade.getCwd(), process.env.HOME || process.env.USERPROFILE);\n\n\t\t// Add git branch if available\n\t\tconst branch = this.footerData.getGitBranch();\n\t\tif (branch) {\n\t\t\tpwd = `${pwd} (${branch})`;\n\t\t}\n\n\t\t// Add session name if set\n\t\tconst sessionName = this.facade.getSessionName();\n\t\tif (sessionName) {\n\t\t\tpwd = `${pwd} • ${sessionName}`;\n\t\t}\n\n\t\t// Build stats line\n\t\tconst statsParts = [];\n\t\tif (usageTotals.input) statsParts.push(`↑${formatTokens(usageTotals.input)}`);\n\t\tif (usageTotals.output) statsParts.push(`↓${formatTokens(usageTotals.output)}`);\n\t\tif (usageTotals.cacheRead) statsParts.push(`R${formatTokens(usageTotals.cacheRead)}`);\n\t\tif (usageTotals.cacheWrite) statsParts.push(`W${formatTokens(usageTotals.cacheWrite)}`);\n\t\tif ((usageTotals.cacheRead > 0 || usageTotals.cacheWrite > 0) && latestCacheHitRate !== undefined) {\n\t\t\tstatsParts.push(`CH${latestCacheHitRate.toFixed(1)}%`);\n\t\t}\n\n\t\t// Kimi Coding is subscription-backed despite using API-key authentication.\n\t\tconst usingSubscription = state.model\n\t\t\t? state.model.provider === \"kimi-coding\" || this.facade.isUsingSubscription(state.model.provider)\n\t\t\t: false;\n\t\tif (usageTotals.cost || usingSubscription) {\n\t\t\tconst costStr = `$${usageTotals.cost.toFixed(3)}${usingSubscription ? ` ${t(\"(sub)\")}` : \"\"}`;\n\t\t\tstatsParts.push(costStr);\n\t\t}\n\n\t\t// Colorize context percentage based on usage\n\t\tlet contextPercentStr: string;\n\t\tconst contextPercentDisplay =\n\t\t\tcontextPercent === \"?\"\n\t\t\t\t? `?/${formatTokens(contextWindow)}`\n\t\t\t\t: `${contextPercent}%/${formatTokens(contextWindow)}`;\n\t\tif (contextPercentValue > 90) {\n\t\t\tcontextPercentStr = theme.fg(\"error\", contextPercentDisplay);\n\t\t} else if (contextPercentValue > 70) {\n\t\t\tcontextPercentStr = theme.fg(\"warning\", contextPercentDisplay);\n\t\t} else {\n\t\t\tcontextPercentStr = contextPercentDisplay;\n\t\t}\n\t\tstatsParts.push(contextPercentStr);\n\t\tif (areExperimentalFeaturesEnabled()) {\n\t\t\tstatsParts.push(`${theme.fg(\"dim\", \"•\")} ${theme.bold(theme.fg(\"warning\", \"xp\"))}`);\n\t\t}\n\n\t\tlet statsLeft = statsParts.join(\" \");\n\n\t\t// Add model name on the right side, plus thinking level if model supports it\n\t\tconst modelName = state.model?.id || t(\"no-model\");\n\n\t\tlet statsLeftWidth = visibleWidth(statsLeft);\n\n\t\t// If statsLeft is too wide, truncate it\n\t\tif (statsLeftWidth > width) {\n\t\t\tstatsLeft = truncateToWidth(statsLeft, width, \"...\");\n\t\t\tstatsLeftWidth = visibleWidth(statsLeft);\n\t\t}\n\n\t\t// Calculate available space for padding (minimum 2 spaces between stats and model)\n\t\tconst minPadding = 2;\n\n\t\t// Add thinking level indicator if model supports reasoning\n\t\tlet rightSideWithoutProvider = modelName;\n\t\tif (state.model?.reasoning) {\n\t\t\tconst thinkingLevel = state.thinkingLevel || \"off\";\n\t\t\trightSideWithoutProvider =\n\t\t\t\tthinkingLevel === \"off\"\n\t\t\t\t\t? t(\"{model} • thinking off\", { model: modelName })\n\t\t\t\t\t: `${modelName} • ${thinkingLevel}`;\n\t\t}\n\n\t\t// Prepend the provider in parentheses if there are multiple providers and there's enough room\n\t\tlet rightSide = rightSideWithoutProvider;\n\t\tif (this.footerData.getAvailableProviderCount() > 1 && state.model) {\n\t\t\trightSide = `(${state.model!.provider}) ${rightSideWithoutProvider}`;\n\t\t\tif (statsLeftWidth + minPadding + visibleWidth(rightSide) > width) {\n\t\t\t\t// Too wide, fall back\n\t\t\t\trightSide = rightSideWithoutProvider;\n\t\t\t}\n\t\t}\n\n\t\tconst rightSideWidth = visibleWidth(rightSide);\n\t\tconst totalNeeded = statsLeftWidth + minPadding + rightSideWidth;\n\n\t\tlet statsLine: string;\n\t\tif (totalNeeded <= width) {\n\t\t\t// Both fit - add padding to right-align model\n\t\t\tconst padding = \" \".repeat(width - statsLeftWidth - rightSideWidth);\n\t\t\tstatsLine = statsLeft + padding + rightSide;\n\t\t} else {\n\t\t\t// Need to truncate right side\n\t\t\tconst availableForRight = width - statsLeftWidth - minPadding;\n\t\t\tif (availableForRight > 0) {\n\t\t\t\tconst truncatedRight = truncateToWidth(rightSide, availableForRight, \"\");\n\t\t\t\tconst truncatedRightWidth = visibleWidth(truncatedRight);\n\t\t\t\tconst padding = \" \".repeat(Math.max(0, width - statsLeftWidth - truncatedRightWidth));\n\t\t\t\tstatsLine = statsLeft + padding + truncatedRight;\n\t\t\t} else {\n\t\t\t\t// Not enough space for right side at all\n\t\t\t\tstatsLine = statsLeft;\n\t\t\t}\n\t\t}\n\n\t\t// Apply dim to each part separately. statsLeft may contain color codes (for context %)\n\t\t// that end with a reset, which would clear an outer dim wrapper. So we dim the parts\n\t\t// before and after the colored section independently.\n\t\tconst dimStatsLeft = theme.fg(\"dim\", statsLeft);\n\t\tconst remainder = statsLine.slice(statsLeft.length); // padding + rightSide\n\t\tconst dimRemainder = theme.fg(\"dim\", remainder);\n\n\t\tconst pwdLine = truncateToWidth(theme.fg(\"dim\", pwd), width, theme.fg(\"dim\", \"...\"));\n\t\tconst lines = [pwdLine, dimStatsLeft + dimRemainder];\n\n\t\t// Add goal/todo status when either exists; a todo set without a goal\n\t\t// still surfaces its progress line alone.\n\t\tif (goalTitle !== undefined || todoTotal > 0) {\n\t\t\tconst goalParts: string[] = [];\n\t\t\tif (goalTitle !== undefined) goalParts.push(`goal: ${goalTitle}`);\n\t\t\tif (todoTotal > 0) goalParts.push(`todo ${todoDone}/${todoTotal}`);\n\t\t\tconst goalLine = theme.fg(\"dim\", sanitizeStatusText(goalParts.join(\" • \")));\n\t\t\tlines.push(truncateToWidth(goalLine, width, theme.fg(\"dim\", \"...\")));\n\t\t}\n\n\t\t// Add workflow status, only when a workflow snapshot reports one.\n\t\tconst workflowSummary = summarizeWorkflowState(workflowState);\n\t\tif (workflowSummary !== undefined) {\n\t\t\tconst workflowLine = theme.fg(\"dim\", sanitizeStatusText(workflowSummary));\n\t\t\tlines.push(truncateToWidth(workflowLine, width, theme.fg(\"dim\", \"...\")));\n\t\t}\n\n\t\t// Add provider failover status, only while the latest snapshot reports an\n\t\t// open breaker. Warning color: an active degradation, not passive info\n\t\t// (context% 变色先例). The countdown is recomputed per frame from Date.now().\n\t\tconst failoverSummary = summarizeFailoverState(failoverState, Date.now());\n\t\tif (failoverSummary !== undefined) {\n\t\t\tconst failoverLine = theme.fg(\"warning\", sanitizeStatusText(failoverSummary));\n\t\t\tlines.push(truncateToWidth(failoverLine, width, theme.fg(\"warning\", \"...\")));\n\t\t}\n\n\t\treturn lines;\n\t}\n}\n"]}
|
|
@@ -97,7 +97,6 @@ function summarizeWorkflowState(state) {
|
|
|
97
97
|
* Computes token/context stats from session, gets git branch and extension statuses from provider.
|
|
98
98
|
*/
|
|
99
99
|
export class FooterComponent {
|
|
100
|
-
autoCompactEnabled = true;
|
|
101
100
|
session;
|
|
102
101
|
footerData;
|
|
103
102
|
sessionStats;
|
|
@@ -114,9 +113,6 @@ export class FooterComponent {
|
|
|
114
113
|
get facade() {
|
|
115
114
|
return createCodingAgentFacade(this.session);
|
|
116
115
|
}
|
|
117
|
-
setAutoCompactEnabled(enabled) {
|
|
118
|
-
this.autoCompactEnabled = enabled;
|
|
119
|
-
}
|
|
120
116
|
/**
|
|
121
117
|
* No-op: git branch caching now handled by provider.
|
|
122
118
|
* Kept for compatibility with existing call sites in interactive-mode.
|
|
@@ -264,10 +260,9 @@ export class FooterComponent {
|
|
|
264
260
|
}
|
|
265
261
|
// Colorize context percentage based on usage
|
|
266
262
|
let contextPercentStr;
|
|
267
|
-
const autoIndicator = this.autoCompactEnabled ? ` ${t("(auto)")}` : "";
|
|
268
263
|
const contextPercentDisplay = contextPercent === "?"
|
|
269
|
-
? `?/${formatTokens(contextWindow)}
|
|
270
|
-
: `${contextPercent}%/${formatTokens(contextWindow)}
|
|
264
|
+
? `?/${formatTokens(contextWindow)}`
|
|
265
|
+
: `${contextPercent}%/${formatTokens(contextWindow)}`;
|
|
271
266
|
if (contextPercentValue > 90) {
|
|
272
267
|
contextPercentStr = theme.fg("error", contextPercentDisplay);
|
|
273
268
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"footer.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/footer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAkB,eAAe,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEjF,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAE/E,OAAO,EAA4B,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAElG,OAAO,EAAE,CAAC,EAAE,MAAM,6BAA6B,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAoB,MAAM,+BAA+B,CAAC;AACtG,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C;;;GAGG;AACH,SAAS,kBAAkB,CAAC,IAAY,EAAU;IACjD,qFAAqF;IACrF,OAAO,IAAI;SACT,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC;SACzB,OAAO,CAAC,KAAK,E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AK,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC,CAAC;YAC1E,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;QAC1E,CAAC;QAED,0EAA0E;QAC1E,uEAAuE;QACvE,kFAA0E;QAC1E,MAAM,eAAe,GAAG,sBAAsB,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QAC1E,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;YACnC,MAAM,YAAY,GAAG,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC,CAAC;YAC9E,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;QAC9E,CAAC;QAED,OAAO,KAAK,CAAC;IAAA,CACb;CACD","sourcesContent":["import { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport { type Component, truncateToWidth, visibleWidth } from \"@agent-forge/tui\";\nimport type { AgentSession } from \"../../../core/agent-session.ts\";\nimport { areExperimentalFeaturesEnabled } from \"../../../core/experimental.ts\";\nimport type { ContextUsage } from \"../../../core/extensions/public-api.ts\";\nimport { type CodingAgentFacadeV1, createCodingAgentFacade } from \"../../../core/facade/index.ts\";\nimport type { ReadonlyFooterDataProvider } from \"../../../core/footer-data-provider.ts\";\nimport { t } from \"../../../core/i18n/index.ts\";\nimport { addUsageToTotals, createUsageTotals, type UsageTotals } from \"../../../core/usage-totals.ts\";\nimport { theme } from \"../theme/theme.ts\";\n\n/**\n * Sanitize text for display in a single-line status.\n * Removes newlines, tabs, carriage returns, and other control characters.\n */\nfunction sanitizeStatusText(text: string): string {\n\t// Replace newlines, tabs, carriage returns with space, then collapse multiple spaces\n\treturn text\n\t\t.replace(/[\\r\\n\\t]/g, \" \")\n\t\t.replace(/ +/g, \" \")\n\t\t.trim();\n}\n\n/**\n * Format token counts for compact footer display.\n */\nexport function formatTokens(count: number): string {\n\tif (count < 1000) return count.toString();\n\tif (count < 10000) return `${(count / 1000).toFixed(1)}k`;\n\tif (count < 1000000) return `${Math.round(count / 1000)}k`;\n\tif (count < 10000000) return `${(count / 1000000).toFixed(1)}M`;\n\treturn `${Math.round(count / 1000000)}M`;\n}\n\nexport function formatCwdForFooter(cwd: string, home: string | undefined): string {\n\tif (!home) return cwd;\n\n\tconst resolvedCwd = resolve(cwd);\n\tconst resolvedHome = resolve(home);\n\tconst relativeToHome = relative(resolvedHome, resolvedCwd);\n\tconst isInsideHome =\n\t\trelativeToHome === \"\" ||\n\t\t(relativeToHome !== \"..\" && !relativeToHome.startsWith(`..${sep}`) && !isAbsolute(relativeToHome));\n\n\tif (!isInsideHome) return cwd;\n\treturn relativeToHome === \"\" ? \"~\" : `~${sep}${relativeToHome}`;\n}\n\n/** Shape of the `goal.state` custom entry data written by the builtin goal capability. */\ninterface FooterGoalState {\n\tgoals?: Array<{ title?: unknown }>;\n}\n\n/** Shape of the `todo.state` custom entry data written by the builtin todo capability. */\ninterface FooterTodoState {\n\ttodos?: Array<{ status?: unknown }>;\n}\n\n/** Shape of the `workflow.state` custom entry data written by the workflow plugin. */\ninterface FooterWorkflowState {\n\tworkflows?: Array<{\n\t\ttitle?: unknown;\n\t\tstatus?: unknown;\n\t\truntime?: Array<{ status?: unknown }>;\n\t\tdiagnostics?: unknown[];\n\t}>;\n}\n\n/**\n * Shape of the `provider.failover.state` snapshot written by the provider-failover\n * plugin (设计 供应商能力槽位与主备切换 §4.7). Only the last entry per session wins;\n * `status: \"open\"` is the only rendered state (half-open is transient — entered at\n * request time and immediately resolved to an open/closed snapshot).\n */\ninterface FooterFailoverState {\n\tchainId?: unknown;\n\tstatus?: unknown;\n\tbackupProvider?: unknown;\n\tprobeAtMs?: unknown;\n}\n\n/**\n * Build the one-line failover summary from the latest `provider.failover.state`\n * snapshot: `failover: 主 <primary> 不可用 • 经 <backup> • 下次试探 <Ns>`. The\n * countdown is computed against `nowMs`; at or past zero it reads `等待试探`\n * (cooldown over, next real request is the probe). Returns undefined when there is\n * nothing to show (no snapshot, not open, or an unusable chainId).\n */\nfunction summarizeFailoverState(state: FooterFailoverState | undefined, nowMs: number): string | undefined {\n\tif (state?.status !== \"open\" || typeof state.chainId !== \"string\" || state.chainId === \"\") return undefined;\n\tconst parts = [`failover: 主 ${state.chainId} 不可用`];\n\tif (typeof state.backupProvider === \"string\" && state.backupProvider !== \"\") {\n\t\tparts.push(`经 ${state.backupProvider}`);\n\t}\n\tconst probeAtMs = typeof state.probeAtMs === \"number\" ? state.probeAtMs : 0;\n\tif (probeAtMs - nowMs <= 0) parts.push(\"等待试探\");\n\telse parts.push(`下次试探 ${Math.ceil((probeAtMs - nowMs) / 1000)}s`);\n\treturn parts.join(\" • \");\n}\n\n/**\n * Build the one-line workflow summary from the latest `workflow.state` snapshot:\n * `wf: <title> <done>/<total>` plus status markers, in order — `▶n` (n>=2\n * parallel active stages), `⏸` (a stage awaiting review), `⚠` (non-empty\n * diagnostics), `✗` (failed workflow); done counts completed+skipped stages.\n * Picks the newest non-terminal workflow, falling back to the newest one when\n * all are terminal; returns undefined when there is no workflow to show.\n */\nfunction summarizeWorkflowState(state: FooterWorkflowState | undefined): string | undefined {\n\tconst workflows = state?.workflows;\n\tconst records = Array.isArray(workflows) ? workflows : [];\n\tconst record =\n\t\t[...records].reverse().find((item) => item?.status === \"draft\" || item?.status === \"running\") ?? records.at(-1);\n\tif (record === undefined || typeof record.title !== \"string\") {\n\t\treturn undefined;\n\t}\n\n\tconst stages = Array.isArray(record.runtime) ? record.runtime : [];\n\tconst done = stages.filter((stage) => stage?.status === \"completed\" || stage?.status === \"skipped\").length;\n\tconst activeCount = stages.filter((stage) => stage?.status === \"active\").length;\n\n\tconst parts = [`wf: ${record.title} ${done}/${stages.length}`];\n\tif (activeCount >= 2) parts.push(`▶${activeCount}`);\n\tif (stages.some((stage) => stage?.status === \"awaiting_review\")) parts.push(\"⏸\");\n\tif (Array.isArray(record.diagnostics) && record.diagnostics.length > 0) parts.push(\"⚠\");\n\tif (record.status === \"failed\") parts.push(\"✗\");\n\treturn parts.join(\" \");\n}\n\n/** Session-derived stats cached across frames; all fields come from one entries scan. */\ninterface CachedSessionStats {\n\tsession: AgentSession;\n\tsessionId: string;\n\tleafId: string | null;\n\tmodel: unknown;\n\tusageTotals: UsageTotals;\n\tlatestCacheHitRate: number | undefined;\n\tgoalTitle: string | undefined;\n\ttodoDone: number;\n\ttodoTotal: number;\n\tworkflowState: FooterWorkflowState | undefined;\n\tfailoverState: FooterFailoverState | undefined;\n\tcontextUsage: ContextUsage | undefined;\n}\n\n/**\n * Footer component that shows pwd, token stats, and context usage.\n * Computes token/context stats from session, gets git branch and extension statuses from provider.\n */\nexport class FooterComponent implements Component {\n\tprivate autoCompactEnabled = true;\n\tprivate session: AgentSession;\n\tprivate footerData: ReadonlyFooterDataProvider;\n\tprivate sessionStats?: CachedSessionStats;\n\n\tconstructor(session: AgentSession, footerData: ReadonlyFooterDataProvider) {\n\t\tthis.session = session;\n\t\tthis.footerData = footerData;\n\t}\n\n\tsetSession(session: AgentSession): void {\n\t\tthis.session = session;\n\t}\n\n\t// Stable facade (阶段 1 slice 1): derived on each access; the facade and\n\t// `this.session` always resolve to the same AgentSession, so setSession()\n\t// rebind stays the only rebind path.\n\tprivate get facade(): CodingAgentFacadeV1 {\n\t\treturn createCodingAgentFacade(this.session);\n\t}\n\n\tsetAutoCompactEnabled(enabled: boolean): void {\n\t\tthis.autoCompactEnabled = enabled;\n\t}\n\n\t/**\n\t * No-op: git branch caching now handled by provider.\n\t * Kept for compatibility with existing call sites in interactive-mode.\n\t */\n\tinvalidate(): void {\n\t\t// No-op: git branch is cached/invalidated by provider\n\t}\n\n\t/**\n\t * Clean up resources.\n\t * Git watcher cleanup now handled by provider.\n\t */\n\tdispose(): void {\n\t\t// Git watcher cleanup handled by provider\n\t}\n\n\t/**\n\t * Usage totals, goal/todo/workflow state, and context usage scan the whole session, and the\n\t * footer renders on every frame. The session is append-only and every append moves the leaf,\n\t * so the scan results only change with the session, leaf, or the model whose context window\n\t * applies; until then the previous frame's values are reused.\n\t */\n\tprivate getSessionStats(): CachedSessionStats {\n\t\tconst facade = this.facade;\n\t\tconst sessionId = facade.getSessionId();\n\t\tconst leafId = facade.getLeafId();\n\t\tconst model = facade.getModel();\n\t\tconst cached = this.sessionStats;\n\t\tif (\n\t\t\tcached &&\n\t\t\tcached.session === this.session &&\n\t\t\tcached.sessionId === sessionId &&\n\t\t\tcached.leafId === leafId &&\n\t\t\tcached.model === model\n\t\t) {\n\t\t\treturn cached;\n\t\t}\n\n\t\t// Calculate cumulative usage from ALL session entries (not just post-compaction messages)\n\t\tconst usageTotals = createUsageTotals();\n\t\tlet latestCacheHitRate: number | undefined;\n\n\t\t// Latest goal/todo capability state: the builtin goal/todo capabilities announce\n\t\t// goal.changed / todo.changed and persist the same state as goal.state / todo.state\n\t\t// custom entries; the last entry per type wins.\n\t\tlet goalTitle: string | undefined;\n\t\tlet todoDone = 0;\n\t\tlet todoTotal = 0;\n\t\tlet workflowState: FooterWorkflowState | undefined;\n\t\tlet failoverState: FooterFailoverState | undefined;\n\n\t\tfor (const entry of facade.getEntries()) {\n\t\t\tif (entry.type === \"message\" && entry.message.role === \"assistant\") {\n\t\t\t\taddUsageToTotals(usageTotals, entry.message.usage);\n\n\t\t\t\tconst latestPromptTokens =\n\t\t\t\t\tentry.message.usage.input + entry.message.usage.cacheRead + entry.message.usage.cacheWrite;\n\t\t\t\tlatestCacheHitRate =\n\t\t\t\t\tlatestPromptTokens > 0 ? (entry.message.usage.cacheRead / latestPromptTokens) * 100 : undefined;\n\t\t\t} else if (entry.type === \"message\" && entry.message.role === \"toolResult\" && entry.message.usage) {\n\t\t\t\taddUsageToTotals(usageTotals, entry.message.usage);\n\t\t\t} else if ((entry.type === \"branch_summary\" || entry.type === \"compaction\") && entry.usage) {\n\t\t\t\taddUsageToTotals(usageTotals, entry.usage);\n\t\t\t} else if (entry.type === \"custom\" && entry.customType === \"goal.state\") {\n\t\t\t\tconst goals = (entry.data as FooterGoalState | undefined)?.goals;\n\t\t\t\tconst current = Array.isArray(goals) ? goals.at(-1) : undefined;\n\t\t\t\tif (current && typeof current.title === \"string\") {\n\t\t\t\t\tgoalTitle = current.title;\n\t\t\t\t}\n\t\t\t} else if (entry.type === \"custom\" && entry.customType === \"todo.state\") {\n\t\t\t\tconst todos = (entry.data as FooterTodoState | undefined)?.todos;\n\t\t\t\tif (Array.isArray(todos)) {\n\t\t\t\t\ttodoDone = todos.filter((item) => item?.status === \"done\").length;\n\t\t\t\t\ttodoTotal = todos.length;\n\t\t\t\t}\n\t\t\t} else if (entry.type === \"custom\" && entry.customType === \"workflow.state\") {\n\t\t\t\tworkflowState = entry.data as FooterWorkflowState | undefined;\n\t\t\t} else if (entry.type === \"custom\" && entry.customType === \"provider.failover.state\") {\n\t\t\t\tfailoverState = entry.data as FooterFailoverState | undefined;\n\t\t\t}\n\t\t}\n\n\t\t// Calculate context usage from session (handles compaction correctly).\n\t\t// After compaction, tokens are unknown until the next LLM response.\n\t\tconst contextUsage = facade.getContextUsage();\n\t\tthis.sessionStats = {\n\t\t\tsession: this.session,\n\t\t\tsessionId,\n\t\t\tleafId,\n\t\t\tmodel,\n\t\t\tusageTotals,\n\t\t\tlatestCacheHitRate,\n\t\t\tgoalTitle,\n\t\t\ttodoDone,\n\t\t\ttodoTotal,\n\t\t\tworkflowState,\n\t\t\tfailoverState,\n\t\t\tcontextUsage,\n\t\t};\n\t\treturn this.sessionStats;\n\t}\n\n\t/**\n\t * Whether the latest `provider.failover.state` snapshot reports an open\n\t * breaker. Drives the interactive-mode per-second re-render ticker (设计\n\t * 供应商能力槽位与主备切换 §4.7 Phase 3); cheap because it reuses the\n\t * cached session stats.\n\t */\n\tisProviderFailoverOpen(): boolean {\n\t\treturn this.getSessionStats().failoverState?.status === \"open\";\n\t}\n\n\trender(width: number): string[] {\n\t\tconst state = this.facade.getState();\n\t\tconst {\n\t\t\tusageTotals,\n\t\t\tlatestCacheHitRate,\n\t\t\tcontextUsage,\n\t\t\tgoalTitle,\n\t\t\ttodoDone,\n\t\t\ttodoTotal,\n\t\t\tworkflowState,\n\t\t\tfailoverState,\n\t\t} = this.getSessionStats();\n\t\tconst contextWindow = contextUsage?.contextWindow ?? state.model?.contextWindow ?? 0;\n\t\tconst contextPercentValue = contextUsage?.percent ?? 0;\n\t\tconst contextPercent = contextUsage?.percent !== null ? contextPercentValue.toFixed(1) : \"?\";\n\n\t\t// Replace home directory with ~\n\t\tlet pwd = formatCwdForFooter(this.facade.getCwd(), process.env.HOME || process.env.USERPROFILE);\n\n\t\t// Add git branch if available\n\t\tconst branch = this.footerData.getGitBranch();\n\t\tif (branch) {\n\t\t\tpwd = `${pwd} (${branch})`;\n\t\t}\n\n\t\t// Add session name if set\n\t\tconst sessionName = this.facade.getSessionName();\n\t\tif (sessionName) {\n\t\t\tpwd = `${pwd} • ${sessionName}`;\n\t\t}\n\n\t\t// Build stats line\n\t\tconst statsParts = [];\n\t\tif (usageTotals.input) statsParts.push(`↑${formatTokens(usageTotals.input)}`);\n\t\tif (usageTotals.output) statsParts.push(`↓${formatTokens(usageTotals.output)}`);\n\t\tif (usageTotals.cacheRead) statsParts.push(`R${formatTokens(usageTotals.cacheRead)}`);\n\t\tif (usageTotals.cacheWrite) statsParts.push(`W${formatTokens(usageTotals.cacheWrite)}`);\n\t\tif ((usageTotals.cacheRead > 0 || usageTotals.cacheWrite > 0) && latestCacheHitRate !== undefined) {\n\t\t\tstatsParts.push(`CH${latestCacheHitRate.toFixed(1)}%`);\n\t\t}\n\n\t\t// Kimi Coding is subscription-backed despite using API-key authentication.\n\t\tconst usingSubscription = state.model\n\t\t\t? state.model.provider === \"kimi-coding\" || this.facade.isUsingSubscription(state.model.provider)\n\t\t\t: false;\n\t\tif (usageTotals.cost || usingSubscription) {\n\t\t\tconst costStr = `$${usageTotals.cost.toFixed(3)}${usingSubscription ? ` ${t(\"(sub)\")}` : \"\"}`;\n\t\t\tstatsParts.push(costStr);\n\t\t}\n\n\t\t// Colorize context percentage based on usage\n\t\tlet contextPercentStr: string;\n\t\tconst autoIndicator = this.autoCompactEnabled ? ` ${t(\"(auto)\")}` : \"\";\n\t\tconst contextPercentDisplay =\n\t\t\tcontextPercent === \"?\"\n\t\t\t\t? `?/${formatTokens(contextWindow)}${autoIndicator}`\n\t\t\t\t: `${contextPercent}%/${formatTokens(contextWindow)}${autoIndicator}`;\n\t\tif (contextPercentValue > 90) {\n\t\t\tcontextPercentStr = theme.fg(\"error\", contextPercentDisplay);\n\t\t} else if (contextPercentValue > 70) {\n\t\t\tcontextPercentStr = theme.fg(\"warning\", contextPercentDisplay);\n\t\t} else {\n\t\t\tcontextPercentStr = contextPercentDisplay;\n\t\t}\n\t\tstatsParts.push(contextPercentStr);\n\t\tif (areExperimentalFeaturesEnabled()) {\n\t\t\tstatsParts.push(`${theme.fg(\"dim\", \"•\")} ${theme.bold(theme.fg(\"warning\", \"xp\"))}`);\n\t\t}\n\n\t\tlet statsLeft = statsParts.join(\" \");\n\n\t\t// Add model name on the right side, plus thinking level if model supports it\n\t\tconst modelName = state.model?.id || t(\"no-model\");\n\n\t\tlet statsLeftWidth = visibleWidth(statsLeft);\n\n\t\t// If statsLeft is too wide, truncate it\n\t\tif (statsLeftWidth > width) {\n\t\t\tstatsLeft = truncateToWidth(statsLeft, width, \"...\");\n\t\t\tstatsLeftWidth = visibleWidth(statsLeft);\n\t\t}\n\n\t\t// Calculate available space for padding (minimum 2 spaces between stats and model)\n\t\tconst minPadding = 2;\n\n\t\t// Add thinking level indicator if model supports reasoning\n\t\tlet rightSideWithoutProvider = modelName;\n\t\tif (state.model?.reasoning) {\n\t\t\tconst thinkingLevel = state.thinkingLevel || \"off\";\n\t\t\trightSideWithoutProvider =\n\t\t\t\tthinkingLevel === \"off\"\n\t\t\t\t\t? t(\"{model} • thinking off\", { model: modelName })\n\t\t\t\t\t: `${modelName} • ${thinkingLevel}`;\n\t\t}\n\n\t\t// Prepend the provider in parentheses if there are multiple providers and there's enough room\n\t\tlet rightSide = rightSideWithoutProvider;\n\t\tif (this.footerData.getAvailableProviderCount() > 1 && state.model) {\n\t\t\trightSide = `(${state.model!.provider}) ${rightSideWithoutProvider}`;\n\t\t\tif (statsLeftWidth + minPadding + visibleWidth(rightSide) > width) {\n\t\t\t\t// Too wide, fall back\n\t\t\t\trightSide = rightSideWithoutProvider;\n\t\t\t}\n\t\t}\n\n\t\tconst rightSideWidth = visibleWidth(rightSide);\n\t\tconst totalNeeded = statsLeftWidth + minPadding + rightSideWidth;\n\n\t\tlet statsLine: string;\n\t\tif (totalNeeded <= width) {\n\t\t\t// Both fit - add padding to right-align model\n\t\t\tconst padding = \" \".repeat(width - statsLeftWidth - rightSideWidth);\n\t\t\tstatsLine = statsLeft + padding + rightSide;\n\t\t} else {\n\t\t\t// Need to truncate right side\n\t\t\tconst availableForRight = width - statsLeftWidth - minPadding;\n\t\t\tif (availableForRight > 0) {\n\t\t\t\tconst truncatedRight = truncateToWidth(rightSide, availableForRight, \"\");\n\t\t\t\tconst truncatedRightWidth = visibleWidth(truncatedRight);\n\t\t\t\tconst padding = \" \".repeat(Math.max(0, width - statsLeftWidth - truncatedRightWidth));\n\t\t\t\tstatsLine = statsLeft + padding + truncatedRight;\n\t\t\t} else {\n\t\t\t\t// Not enough space for right side at all\n\t\t\t\tstatsLine = statsLeft;\n\t\t\t}\n\t\t}\n\n\t\t// Apply dim to each part separately. statsLeft may contain color codes (for context %)\n\t\t// that end with a reset, which would clear an outer dim wrapper. So we dim the parts\n\t\t// before and after the colored section independently.\n\t\tconst dimStatsLeft = theme.fg(\"dim\", statsLeft);\n\t\tconst remainder = statsLine.slice(statsLeft.length); // padding + rightSide\n\t\tconst dimRemainder = theme.fg(\"dim\", remainder);\n\n\t\tconst pwdLine = truncateToWidth(theme.fg(\"dim\", pwd), width, theme.fg(\"dim\", \"...\"));\n\t\tconst lines = [pwdLine, dimStatsLeft + dimRemainder];\n\n\t\t// Add goal/todo status when either exists; a todo set without a goal\n\t\t// still surfaces its progress line alone.\n\t\tif (goalTitle !== undefined || todoTotal > 0) {\n\t\t\tconst goalParts: string[] = [];\n\t\t\tif (goalTitle !== undefined) goalParts.push(`goal: ${goalTitle}`);\n\t\t\tif (todoTotal > 0) goalParts.push(`todo ${todoDone}/${todoTotal}`);\n\t\t\tconst goalLine = theme.fg(\"dim\", sanitizeStatusText(goalParts.join(\" • \")));\n\t\t\tlines.push(truncateToWidth(goalLine, width, theme.fg(\"dim\", \"...\")));\n\t\t}\n\n\t\t// Add workflow status, only when a workflow snapshot reports one.\n\t\tconst workflowSummary = summarizeWorkflowState(workflowState);\n\t\tif (workflowSummary !== undefined) {\n\t\t\tconst workflowLine = theme.fg(\"dim\", sanitizeStatusText(workflowSummary));\n\t\t\tlines.push(truncateToWidth(workflowLine, width, theme.fg(\"dim\", \"...\")));\n\t\t}\n\n\t\t// Add provider failover status, only while the latest snapshot reports an\n\t\t// open breaker. Warning color: an active degradation, not passive info\n\t\t// (context% 变色先例). The countdown is recomputed per frame from Date.now().\n\t\tconst failoverSummary = summarizeFailoverState(failoverState, Date.now());\n\t\tif (failoverSummary !== undefined) {\n\t\t\tconst failoverLine = theme.fg(\"warning\", sanitizeStatusText(failoverSummary));\n\t\t\tlines.push(truncateToWidth(failoverLine, width, theme.fg(\"warning\", \"...\")));\n\t\t}\n\n\t\treturn lines;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"footer.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/footer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAkB,eAAe,EAAE,YAAY,EAAE,MAAM,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C,CAAC,CAAC;QACtE,CAAC;QAED,kEAAkE;QAClE,MAAM,eAAe,GAAG,sBAAsB,CAAC,aAAa,CAAC,CAAC;QAC9D,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;YACnC,MAAM,YAAY,GAAG,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC,CAAC;YAC1E,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;QAC1E,CAAC;QAED,0EAA0E;QAC1E,uEAAuE;QACvE,kFAA0E;QAC1E,MAAM,eAAe,GAAG,sBAAsB,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QAC1E,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;YACnC,MAAM,YAAY,GAAG,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC,CAAC;YAC9E,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;QAC9E,CAAC;QAED,OAAO,KAAK,CAAC;IAAA,CACb;CACD","sourcesContent":["import { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport { type Component, truncateToWidth, visibleWidth } from \"@agent-forge/tui\";\nimport type { AgentSession } from \"../../../core/agent-session.ts\";\nimport { areExperimentalFeaturesEnabled } from \"../../../core/experimental.ts\";\nimport type { ContextUsage } from \"../../../core/extensions/public-api.ts\";\nimport { type CodingAgentFacadeV1, createCodingAgentFacade } from \"../../../core/facade/index.ts\";\nimport type { ReadonlyFooterDataProvider } from \"../../../core/footer-data-provider.ts\";\nimport { t } from \"../../../core/i18n/index.ts\";\nimport { addUsageToTotals, createUsageTotals, type UsageTotals } from \"../../../core/usage-totals.ts\";\nimport { theme } from \"../theme/theme.ts\";\n\n/**\n * Sanitize text for display in a single-line status.\n * Removes newlines, tabs, carriage returns, and other control characters.\n */\nfunction sanitizeStatusText(text: string): string {\n\t// Replace newlines, tabs, carriage returns with space, then collapse multiple spaces\n\treturn text\n\t\t.replace(/[\\r\\n\\t]/g, \" \")\n\t\t.replace(/ +/g, \" \")\n\t\t.trim();\n}\n\n/**\n * Format token counts for compact footer display.\n */\nexport function formatTokens(count: number): string {\n\tif (count < 1000) return count.toString();\n\tif (count < 10000) return `${(count / 1000).toFixed(1)}k`;\n\tif (count < 1000000) return `${Math.round(count / 1000)}k`;\n\tif (count < 10000000) return `${(count / 1000000).toFixed(1)}M`;\n\treturn `${Math.round(count / 1000000)}M`;\n}\n\nexport function formatCwdForFooter(cwd: string, home: string | undefined): string {\n\tif (!home) return cwd;\n\n\tconst resolvedCwd = resolve(cwd);\n\tconst resolvedHome = resolve(home);\n\tconst relativeToHome = relative(resolvedHome, resolvedCwd);\n\tconst isInsideHome =\n\t\trelativeToHome === \"\" ||\n\t\t(relativeToHome !== \"..\" && !relativeToHome.startsWith(`..${sep}`) && !isAbsolute(relativeToHome));\n\n\tif (!isInsideHome) return cwd;\n\treturn relativeToHome === \"\" ? \"~\" : `~${sep}${relativeToHome}`;\n}\n\n/** Shape of the `goal.state` custom entry data written by the builtin goal capability. */\ninterface FooterGoalState {\n\tgoals?: Array<{ title?: unknown }>;\n}\n\n/** Shape of the `todo.state` custom entry data written by the builtin todo capability. */\ninterface FooterTodoState {\n\ttodos?: Array<{ status?: unknown }>;\n}\n\n/** Shape of the `workflow.state` custom entry data written by the workflow plugin. */\ninterface FooterWorkflowState {\n\tworkflows?: Array<{\n\t\ttitle?: unknown;\n\t\tstatus?: unknown;\n\t\truntime?: Array<{ status?: unknown }>;\n\t\tdiagnostics?: unknown[];\n\t}>;\n}\n\n/**\n * Shape of the `provider.failover.state` snapshot written by the provider-failover\n * plugin (设计 供应商能力槽位与主备切换 §4.7). Only the last entry per session wins;\n * `status: \"open\"` is the only rendered state (half-open is transient — entered at\n * request time and immediately resolved to an open/closed snapshot).\n */\ninterface FooterFailoverState {\n\tchainId?: unknown;\n\tstatus?: unknown;\n\tbackupProvider?: unknown;\n\tprobeAtMs?: unknown;\n}\n\n/**\n * Build the one-line failover summary from the latest `provider.failover.state`\n * snapshot: `failover: 主 <primary> 不可用 • 经 <backup> • 下次试探 <Ns>`. The\n * countdown is computed against `nowMs`; at or past zero it reads `等待试探`\n * (cooldown over, next real request is the probe). Returns undefined when there is\n * nothing to show (no snapshot, not open, or an unusable chainId).\n */\nfunction summarizeFailoverState(state: FooterFailoverState | undefined, nowMs: number): string | undefined {\n\tif (state?.status !== \"open\" || typeof state.chainId !== \"string\" || state.chainId === \"\") return undefined;\n\tconst parts = [`failover: 主 ${state.chainId} 不可用`];\n\tif (typeof state.backupProvider === \"string\" && state.backupProvider !== \"\") {\n\t\tparts.push(`经 ${state.backupProvider}`);\n\t}\n\tconst probeAtMs = typeof state.probeAtMs === \"number\" ? state.probeAtMs : 0;\n\tif (probeAtMs - nowMs <= 0) parts.push(\"等待试探\");\n\telse parts.push(`下次试探 ${Math.ceil((probeAtMs - nowMs) / 1000)}s`);\n\treturn parts.join(\" • \");\n}\n\n/**\n * Build the one-line workflow summary from the latest `workflow.state` snapshot:\n * `wf: <title> <done>/<total>` plus status markers, in order — `▶n` (n>=2\n * parallel active stages), `⏸` (a stage awaiting review), `⚠` (non-empty\n * diagnostics), `✗` (failed workflow); done counts completed+skipped stages.\n * Picks the newest non-terminal workflow, falling back to the newest one when\n * all are terminal; returns undefined when there is no workflow to show.\n */\nfunction summarizeWorkflowState(state: FooterWorkflowState | undefined): string | undefined {\n\tconst workflows = state?.workflows;\n\tconst records = Array.isArray(workflows) ? workflows : [];\n\tconst record =\n\t\t[...records].reverse().find((item) => item?.status === \"draft\" || item?.status === \"running\") ?? records.at(-1);\n\tif (record === undefined || typeof record.title !== \"string\") {\n\t\treturn undefined;\n\t}\n\n\tconst stages = Array.isArray(record.runtime) ? record.runtime : [];\n\tconst done = stages.filter((stage) => stage?.status === \"completed\" || stage?.status === \"skipped\").length;\n\tconst activeCount = stages.filter((stage) => stage?.status === \"active\").length;\n\n\tconst parts = [`wf: ${record.title} ${done}/${stages.length}`];\n\tif (activeCount >= 2) parts.push(`▶${activeCount}`);\n\tif (stages.some((stage) => stage?.status === \"awaiting_review\")) parts.push(\"⏸\");\n\tif (Array.isArray(record.diagnostics) && record.diagnostics.length > 0) parts.push(\"⚠\");\n\tif (record.status === \"failed\") parts.push(\"✗\");\n\treturn parts.join(\" \");\n}\n\n/** Session-derived stats cached across frames; all fields come from one entries scan. */\ninterface CachedSessionStats {\n\tsession: AgentSession;\n\tsessionId: string;\n\tleafId: string | null;\n\tmodel: unknown;\n\tusageTotals: UsageTotals;\n\tlatestCacheHitRate: number | undefined;\n\tgoalTitle: string | undefined;\n\ttodoDone: number;\n\ttodoTotal: number;\n\tworkflowState: FooterWorkflowState | undefined;\n\tfailoverState: FooterFailoverState | undefined;\n\tcontextUsage: ContextUsage | undefined;\n}\n\n/**\n * Footer component that shows pwd, token stats, and context usage.\n * Computes token/context stats from session, gets git branch and extension statuses from provider.\n */\nexport class FooterComponent implements Component {\n\tprivate session: AgentSession;\n\tprivate footerData: ReadonlyFooterDataProvider;\n\tprivate sessionStats?: CachedSessionStats;\n\n\tconstructor(session: AgentSession, footerData: ReadonlyFooterDataProvider) {\n\t\tthis.session = session;\n\t\tthis.footerData = footerData;\n\t}\n\n\tsetSession(session: AgentSession): void {\n\t\tthis.session = session;\n\t}\n\n\t// Stable facade (阶段 1 slice 1): derived on each access; the facade and\n\t// `this.session` always resolve to the same AgentSession, so setSession()\n\t// rebind stays the only rebind path.\n\tprivate get facade(): CodingAgentFacadeV1 {\n\t\treturn createCodingAgentFacade(this.session);\n\t}\n\n\t/**\n\t * No-op: git branch caching now handled by provider.\n\t * Kept for compatibility with existing call sites in interactive-mode.\n\t */\n\tinvalidate(): void {\n\t\t// No-op: git branch is cached/invalidated by provider\n\t}\n\n\t/**\n\t * Clean up resources.\n\t * Git watcher cleanup now handled by provider.\n\t */\n\tdispose(): void {\n\t\t// Git watcher cleanup handled by provider\n\t}\n\n\t/**\n\t * Usage totals, goal/todo/workflow state, and context usage scan the whole session, and the\n\t * footer renders on every frame. The session is append-only and every append moves the leaf,\n\t * so the scan results only change with the session, leaf, or the model whose context window\n\t * applies; until then the previous frame's values are reused.\n\t */\n\tprivate getSessionStats(): CachedSessionStats {\n\t\tconst facade = this.facade;\n\t\tconst sessionId = facade.getSessionId();\n\t\tconst leafId = facade.getLeafId();\n\t\tconst model = facade.getModel();\n\t\tconst cached = this.sessionStats;\n\t\tif (\n\t\t\tcached &&\n\t\t\tcached.session === this.session &&\n\t\t\tcached.sessionId === sessionId &&\n\t\t\tcached.leafId === leafId &&\n\t\t\tcached.model === model\n\t\t) {\n\t\t\treturn cached;\n\t\t}\n\n\t\t// Calculate cumulative usage from ALL session entries (not just post-compaction messages)\n\t\tconst usageTotals = createUsageTotals();\n\t\tlet latestCacheHitRate: number | undefined;\n\n\t\t// Latest goal/todo capability state: the builtin goal/todo capabilities announce\n\t\t// goal.changed / todo.changed and persist the same state as goal.state / todo.state\n\t\t// custom entries; the last entry per type wins.\n\t\tlet goalTitle: string | undefined;\n\t\tlet todoDone = 0;\n\t\tlet todoTotal = 0;\n\t\tlet workflowState: FooterWorkflowState | undefined;\n\t\tlet failoverState: FooterFailoverState | undefined;\n\n\t\tfor (const entry of facade.getEntries()) {\n\t\t\tif (entry.type === \"message\" && entry.message.role === \"assistant\") {\n\t\t\t\taddUsageToTotals(usageTotals, entry.message.usage);\n\n\t\t\t\tconst latestPromptTokens =\n\t\t\t\t\tentry.message.usage.input + entry.message.usage.cacheRead + entry.message.usage.cacheWrite;\n\t\t\t\tlatestCacheHitRate =\n\t\t\t\t\tlatestPromptTokens > 0 ? (entry.message.usage.cacheRead / latestPromptTokens) * 100 : undefined;\n\t\t\t} else if (entry.type === \"message\" && entry.message.role === \"toolResult\" && entry.message.usage) {\n\t\t\t\taddUsageToTotals(usageTotals, entry.message.usage);\n\t\t\t} else if ((entry.type === \"branch_summary\" || entry.type === \"compaction\") && entry.usage) {\n\t\t\t\taddUsageToTotals(usageTotals, entry.usage);\n\t\t\t} else if (entry.type === \"custom\" && entry.customType === \"goal.state\") {\n\t\t\t\tconst goals = (entry.data as FooterGoalState | undefined)?.goals;\n\t\t\t\tconst current = Array.isArray(goals) ? goals.at(-1) : undefined;\n\t\t\t\tif (current && typeof current.title === \"string\") {\n\t\t\t\t\tgoalTitle = current.title;\n\t\t\t\t}\n\t\t\t} else if (entry.type === \"custom\" && entry.customType === \"todo.state\") {\n\t\t\t\tconst todos = (entry.data as FooterTodoState | undefined)?.todos;\n\t\t\t\tif (Array.isArray(todos)) {\n\t\t\t\t\ttodoDone = todos.filter((item) => item?.status === \"done\").length;\n\t\t\t\t\ttodoTotal = todos.length;\n\t\t\t\t}\n\t\t\t} else if (entry.type === \"custom\" && entry.customType === \"workflow.state\") {\n\t\t\t\tworkflowState = entry.data as FooterWorkflowState | undefined;\n\t\t\t} else if (entry.type === \"custom\" && entry.customType === \"provider.failover.state\") {\n\t\t\t\tfailoverState = entry.data as FooterFailoverState | undefined;\n\t\t\t}\n\t\t}\n\n\t\t// Calculate context usage from session (handles compaction correctly).\n\t\t// After compaction, tokens are unknown until the next LLM response.\n\t\tconst contextUsage = facade.getContextUsage();\n\t\tthis.sessionStats = {\n\t\t\tsession: this.session,\n\t\t\tsessionId,\n\t\t\tleafId,\n\t\t\tmodel,\n\t\t\tusageTotals,\n\t\t\tlatestCacheHitRate,\n\t\t\tgoalTitle,\n\t\t\ttodoDone,\n\t\t\ttodoTotal,\n\t\t\tworkflowState,\n\t\t\tfailoverState,\n\t\t\tcontextUsage,\n\t\t};\n\t\treturn this.sessionStats;\n\t}\n\n\t/**\n\t * Whether the latest `provider.failover.state` snapshot reports an open\n\t * breaker. Drives the interactive-mode per-second re-render ticker (设计\n\t * 供应商能力槽位与主备切换 §4.7 Phase 3); cheap because it reuses the\n\t * cached session stats.\n\t */\n\tisProviderFailoverOpen(): boolean {\n\t\treturn this.getSessionStats().failoverState?.status === \"open\";\n\t}\n\n\trender(width: number): string[] {\n\t\tconst state = this.facade.getState();\n\t\tconst {\n\t\t\tusageTotals,\n\t\t\tlatestCacheHitRate,\n\t\t\tcontextUsage,\n\t\t\tgoalTitle,\n\t\t\ttodoDone,\n\t\t\ttodoTotal,\n\t\t\tworkflowState,\n\t\t\tfailoverState,\n\t\t} = this.getSessionStats();\n\t\tconst contextWindow = contextUsage?.contextWindow ?? state.model?.contextWindow ?? 0;\n\t\tconst contextPercentValue = contextUsage?.percent ?? 0;\n\t\tconst contextPercent = contextUsage?.percent !== null ? contextPercentValue.toFixed(1) : \"?\";\n\n\t\t// Replace home directory with ~\n\t\tlet pwd = formatCwdForFooter(this.facade.getCwd(), process.env.HOME || process.env.USERPROFILE);\n\n\t\t// Add git branch if available\n\t\tconst branch = this.footerData.getGitBranch();\n\t\tif (branch) {\n\t\t\tpwd = `${pwd} (${branch})`;\n\t\t}\n\n\t\t// Add session name if set\n\t\tconst sessionName = this.facade.getSessionName();\n\t\tif (sessionName) {\n\t\t\tpwd = `${pwd} • ${sessionName}`;\n\t\t}\n\n\t\t// Build stats line\n\t\tconst statsParts = [];\n\t\tif (usageTotals.input) statsParts.push(`↑${formatTokens(usageTotals.input)}`);\n\t\tif (usageTotals.output) statsParts.push(`↓${formatTokens(usageTotals.output)}`);\n\t\tif (usageTotals.cacheRead) statsParts.push(`R${formatTokens(usageTotals.cacheRead)}`);\n\t\tif (usageTotals.cacheWrite) statsParts.push(`W${formatTokens(usageTotals.cacheWrite)}`);\n\t\tif ((usageTotals.cacheRead > 0 || usageTotals.cacheWrite > 0) && latestCacheHitRate !== undefined) {\n\t\t\tstatsParts.push(`CH${latestCacheHitRate.toFixed(1)}%`);\n\t\t}\n\n\t\t// Kimi Coding is subscription-backed despite using API-key authentication.\n\t\tconst usingSubscription = state.model\n\t\t\t? state.model.provider === \"kimi-coding\" || this.facade.isUsingSubscription(state.model.provider)\n\t\t\t: false;\n\t\tif (usageTotals.cost || usingSubscription) {\n\t\t\tconst costStr = `$${usageTotals.cost.toFixed(3)}${usingSubscription ? ` ${t(\"(sub)\")}` : \"\"}`;\n\t\t\tstatsParts.push(costStr);\n\t\t}\n\n\t\t// Colorize context percentage based on usage\n\t\tlet contextPercentStr: string;\n\t\tconst contextPercentDisplay =\n\t\t\tcontextPercent === \"?\"\n\t\t\t\t? `?/${formatTokens(contextWindow)}`\n\t\t\t\t: `${contextPercent}%/${formatTokens(contextWindow)}`;\n\t\tif (contextPercentValue > 90) {\n\t\t\tcontextPercentStr = theme.fg(\"error\", contextPercentDisplay);\n\t\t} else if (contextPercentValue > 70) {\n\t\t\tcontextPercentStr = theme.fg(\"warning\", contextPercentDisplay);\n\t\t} else {\n\t\t\tcontextPercentStr = contextPercentDisplay;\n\t\t}\n\t\tstatsParts.push(contextPercentStr);\n\t\tif (areExperimentalFeaturesEnabled()) {\n\t\t\tstatsParts.push(`${theme.fg(\"dim\", \"•\")} ${theme.bold(theme.fg(\"warning\", \"xp\"))}`);\n\t\t}\n\n\t\tlet statsLeft = statsParts.join(\" \");\n\n\t\t// Add model name on the right side, plus thinking level if model supports it\n\t\tconst modelName = state.model?.id || t(\"no-model\");\n\n\t\tlet statsLeftWidth = visibleWidth(statsLeft);\n\n\t\t// If statsLeft is too wide, truncate it\n\t\tif (statsLeftWidth > width) {\n\t\t\tstatsLeft = truncateToWidth(statsLeft, width, \"...\");\n\t\t\tstatsLeftWidth = visibleWidth(statsLeft);\n\t\t}\n\n\t\t// Calculate available space for padding (minimum 2 spaces between stats and model)\n\t\tconst minPadding = 2;\n\n\t\t// Add thinking level indicator if model supports reasoning\n\t\tlet rightSideWithoutProvider = modelName;\n\t\tif (state.model?.reasoning) {\n\t\t\tconst thinkingLevel = state.thinkingLevel || \"off\";\n\t\t\trightSideWithoutProvider =\n\t\t\t\tthinkingLevel === \"off\"\n\t\t\t\t\t? t(\"{model} • thinking off\", { model: modelName })\n\t\t\t\t\t: `${modelName} • ${thinkingLevel}`;\n\t\t}\n\n\t\t// Prepend the provider in parentheses if there are multiple providers and there's enough room\n\t\tlet rightSide = rightSideWithoutProvider;\n\t\tif (this.footerData.getAvailableProviderCount() > 1 && state.model) {\n\t\t\trightSide = `(${state.model!.provider}) ${rightSideWithoutProvider}`;\n\t\t\tif (statsLeftWidth + minPadding + visibleWidth(rightSide) > width) {\n\t\t\t\t// Too wide, fall back\n\t\t\t\trightSide = rightSideWithoutProvider;\n\t\t\t}\n\t\t}\n\n\t\tconst rightSideWidth = visibleWidth(rightSide);\n\t\tconst totalNeeded = statsLeftWidth + minPadding + rightSideWidth;\n\n\t\tlet statsLine: string;\n\t\tif (totalNeeded <= width) {\n\t\t\t// Both fit - add padding to right-align model\n\t\t\tconst padding = \" \".repeat(width - statsLeftWidth - rightSideWidth);\n\t\t\tstatsLine = statsLeft + padding + rightSide;\n\t\t} else {\n\t\t\t// Need to truncate right side\n\t\t\tconst availableForRight = width - statsLeftWidth - minPadding;\n\t\t\tif (availableForRight > 0) {\n\t\t\t\tconst truncatedRight = truncateToWidth(rightSide, availableForRight, \"\");\n\t\t\t\tconst truncatedRightWidth = visibleWidth(truncatedRight);\n\t\t\t\tconst padding = \" \".repeat(Math.max(0, width - statsLeftWidth - truncatedRightWidth));\n\t\t\t\tstatsLine = statsLeft + padding + truncatedRight;\n\t\t\t} else {\n\t\t\t\t// Not enough space for right side at all\n\t\t\t\tstatsLine = statsLeft;\n\t\t\t}\n\t\t}\n\n\t\t// Apply dim to each part separately. statsLeft may contain color codes (for context %)\n\t\t// that end with a reset, which would clear an outer dim wrapper. So we dim the parts\n\t\t// before and after the colored section independently.\n\t\tconst dimStatsLeft = theme.fg(\"dim\", statsLeft);\n\t\tconst remainder = statsLine.slice(statsLeft.length); // padding + rightSide\n\t\tconst dimRemainder = theme.fg(\"dim\", remainder);\n\n\t\tconst pwdLine = truncateToWidth(theme.fg(\"dim\", pwd), width, theme.fg(\"dim\", \"...\"));\n\t\tconst lines = [pwdLine, dimStatsLeft + dimRemainder];\n\n\t\t// Add goal/todo status when either exists; a todo set without a goal\n\t\t// still surfaces its progress line alone.\n\t\tif (goalTitle !== undefined || todoTotal > 0) {\n\t\t\tconst goalParts: string[] = [];\n\t\t\tif (goalTitle !== undefined) goalParts.push(`goal: ${goalTitle}`);\n\t\t\tif (todoTotal > 0) goalParts.push(`todo ${todoDone}/${todoTotal}`);\n\t\t\tconst goalLine = theme.fg(\"dim\", sanitizeStatusText(goalParts.join(\" • \")));\n\t\t\tlines.push(truncateToWidth(goalLine, width, theme.fg(\"dim\", \"...\")));\n\t\t}\n\n\t\t// Add workflow status, only when a workflow snapshot reports one.\n\t\tconst workflowSummary = summarizeWorkflowState(workflowState);\n\t\tif (workflowSummary !== undefined) {\n\t\t\tconst workflowLine = theme.fg(\"dim\", sanitizeStatusText(workflowSummary));\n\t\t\tlines.push(truncateToWidth(workflowLine, width, theme.fg(\"dim\", \"...\")));\n\t\t}\n\n\t\t// Add provider failover status, only while the latest snapshot reports an\n\t\t// open breaker. Warning color: an active degradation, not passive info\n\t\t// (context% 变色先例). The countdown is recomputed per frame from Date.now().\n\t\tconst failoverSummary = summarizeFailoverState(failoverState, Date.now());\n\t\tif (failoverSummary !== undefined) {\n\t\t\tconst failoverLine = theme.fg(\"warning\", sanitizeStatusText(failoverSummary));\n\t\t\tlines.push(truncateToWidth(failoverLine, width, theme.fg(\"warning\", \"...\")));\n\t\t}\n\n\t\treturn lines;\n\t}\n}\n"]}
|
|
@@ -4,7 +4,6 @@ import { Container, type ScrollViewScrollbar, SettingsList, type WheelScrollLine
|
|
|
4
4
|
import type { FullscreenExitOutput, MermaidRenderingMode, TuiMode, WarningSettings } from "../../../core/settings-manager.ts";
|
|
5
5
|
import { type TerminalTheme } from "../theme/theme.ts";
|
|
6
6
|
export interface SettingsConfig {
|
|
7
|
-
autoCompact: boolean;
|
|
8
7
|
defaultModel: string;
|
|
9
8
|
currentModel?: Model<Api>;
|
|
10
9
|
availableDefaultModels: readonly Model<Api>[];
|
|
@@ -12,7 +11,6 @@ export interface SettingsConfig {
|
|
|
12
11
|
imageWidthCells: number;
|
|
13
12
|
autoResizeImages: boolean;
|
|
14
13
|
blockImages: boolean;
|
|
15
|
-
enableSkillCommands: boolean;
|
|
16
14
|
steeringMode: "all" | "one-at-a-time";
|
|
17
15
|
followUpMode: "all" | "one-at-a-time";
|
|
18
16
|
transport: Transport;
|
|
@@ -27,7 +25,7 @@ export interface SettingsConfig {
|
|
|
27
25
|
mermaidRenderingMode: MermaidRenderingMode;
|
|
28
26
|
showCacheMissNotices: boolean;
|
|
29
27
|
collapseChangelog: boolean;
|
|
30
|
-
doubleEscapeAction: "
|
|
28
|
+
doubleEscapeAction: "tree" | "none";
|
|
31
29
|
uiLanguage: "zh-CN" | "en";
|
|
32
30
|
treeFilterMode: "default" | "no-tools" | "user-only" | "labeled-only" | "all";
|
|
33
31
|
showHardwareCursor: boolean;
|
|
@@ -45,12 +43,10 @@ export interface SettingsConfig {
|
|
|
45
43
|
warnings: WarningSettings;
|
|
46
44
|
}
|
|
47
45
|
export interface SettingsCallbacks {
|
|
48
|
-
onAutoCompactChange: (enabled: boolean) => void;
|
|
49
46
|
onShowImagesChange: (enabled: boolean) => void;
|
|
50
47
|
onImageWidthCellsChange: (width: number) => void;
|
|
51
48
|
onAutoResizeImagesChange: (enabled: boolean) => void;
|
|
52
49
|
onBlockImagesChange: (blocked: boolean) => void;
|
|
53
|
-
onEnableSkillCommandsChange: (enabled: boolean) => void;
|
|
54
50
|
onSteeringModeChange: (mode: "all" | "one-at-a-time") => void;
|
|
55
51
|
onFollowUpModeChange: (mode: "all" | "one-at-a-time") => void;
|
|
56
52
|
onTransportChange: (transport: Transport) => void;
|
|
@@ -63,7 +59,7 @@ export interface SettingsCallbacks {
|
|
|
63
59
|
onMermaidRenderingModeChange: (mode: MermaidRenderingMode) => void;
|
|
64
60
|
onShowCacheMissNoticesChange: (shown: boolean) => void;
|
|
65
61
|
onCollapseChangelogChange: (collapsed: boolean) => void;
|
|
66
|
-
onDoubleEscapeActionChange: (action: "
|
|
62
|
+
onDoubleEscapeActionChange: (action: "tree" | "none") => void;
|
|
67
63
|
onUiLanguageChange: (language: "zh-CN" | "en") => void;
|
|
68
64
|
onTreeFilterModeChange: (mode: "default" | "no-tools" | "user-only" | "labeled-only" | "all") => void;
|
|
69
65
|
onShowHardwareCursorChange: (enabled: boolean) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-selector.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/settings-selector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,KAAK,GAAG,EAA8B,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACnG,OAAO,EAEN,SAAS,EAET,KAAK,mBAAmB,EAGxB,YAAY,EAGZ,KAAK,gBAAgB,EACrB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EACX,oBAAoB,EACpB,oBAAoB,EACpB,OAAO,EACP,eAAe,EACf,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAA+C,KAAK,aAAa,EAAS,MAAM,mBAAmB,CAAC;AAsB3G,MAAM,WAAW,cAAc;IAC9B,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAC1B,sBAAsB,EAAE,SAAS,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;IAC9C,UAAU,EAAE,OAAO,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,EAAE,OAAO,CAAC;IACrB,mBAAmB,EAAE,OAAO,CAA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IAED,eAAe,IAAI,YAAY,CAE9B;CACD","sourcesContent":["import type { ThinkingLevel } from \"@agent-forge/agent-core\";\nimport { type Api, getSupportedThinkingLevels, type Model, type Transport } from \"@agent-forge/ai\";\nimport {\n\ttype Component,\n\tContainer,\n\tgetCapabilities,\n\ttype ScrollViewScrollbar,\n\ttype SelectItem,\n\ttype SettingItem,\n\tSettingsList,\n\tSpacer,\n\tText,\n\ttype WheelScrollLines,\n} from \"@agent-forge/tui\";\nimport { formatHttpIdleTimeoutMs, HTTP_IDLE_TIMEOUT_CHOICES } from \"../../../core/http-dispatcher.ts\";\nimport { t } from \"../../../core/i18n/index.ts\";\nimport type {\n\tFullscreenExitOutput,\n\tMermaidRenderingMode,\n\tTuiMode,\n\tWarningSettings,\n} from \"../../../core/settings-manager.ts\";\nimport { getSettingsListTheme, parseAutoThemeSetting, type TerminalTheme, theme } from \"../theme/theme.ts\";\nimport { DynamicBorder } from \"./dynamic-border.ts\";\nimport { keyDisplayText } from \"./keybinding-hints.ts\";\nimport { SelectSubmenu, SteppedSubmenu, type SteppedSubmenuStep } from \"./settings-submenu.ts\";\n\nconst MODEL_PICKER_LAYOUT = { minPrimaryColumnWidth: 12, maxPrimaryColumnWidth: 46 };\n\n// i18n: 以函数查询而非模块级常量,保证语言切换后取到当前词典\nconst THINKING_DESCRIPTIONS: Record<ThinkingLevel, string> = {\n\toff: \"No reasoning\",\n\tminimal: \"Very brief reasoning (~1k tokens)\",\n\tlow: \"Light reasoning (~2k tokens)\",\n\tmedium: \"Moderate reasoning (~8k tokens)\",\n\thigh: \"Deep reasoning (~16k tokens)\",\n\txhigh: \"Extra-high reasoning (~32k tokens)\",\n\tmax: \"Maximum reasoning\",\n};\n\nfunction thinkingDescription(level: ThinkingLevel): string {\n\treturn t(THINKING_DESCRIPTIONS[level]);\n}\n\nexport interface SettingsConfig {\n\tautoCompact: boolean;\n\tdefaultModel: string;\n\tcurrentModel?: Model<Api>;\n\tavailableDefaultModels: readonly Model<Api>[];\n\tshowImages: boolean;\n\timageWidthCells: number;\n\tautoResizeImages: boolean;\n\tblockImages: boolean;\n\tenableSkillCommands: boolean;\n\tsteeringMode: \"all\" | \"one-at-a-time\";\n\tfollowUpMode: \"all\" | \"one-at-a-time\";\n\ttransport: Transport;\n\thttpIdleTimeoutMs: number;\n\tthinkingLevel: ThinkingLevel;\n\tavailableThinkingLevels: ThinkingLevel[];\n\tmodelThinkingLevels: Record<string, ThinkingLevel>;\n\tcurrentTheme: string;\n\tterminalTheme: TerminalTheme;\n\tavailableThemes: string[];\n\thideThinkingBlock: boolean;\n\tmermaidRenderingMode: MermaidRenderingMode;\n\tshowCacheMissNotices: boolean;\n\tcollapseChangelog: boolean;\n\tdoubleEscapeAction: \"fork\" | \"tree\" | \"none\";\n\tuiLanguage: \"zh-CN\" | \"en\";\n\ttreeFilterMode: \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\";\n\tshowHardwareCursor: boolean;\n\teditorPaddingX: number;\n\toutputPad: 0 | 1;\n\tautocompleteMaxVisible: number;\n\tquietStartup: boolean;\n\tclearOnShrink: boolean;\n\tshowTerminalProgress: boolean;\n\ttuiMode: TuiMode;\n\tfullscreenExitOutput: FullscreenExitOutput;\n\tfullscreenScrollbar: ScrollViewScrollbar;\n\tfullscreenCopyOnSelect: boolean;\n\tfullscreenWheelScrollLines: WheelScrollLines;\n\twarnings: WarningSettings;\n}\n\nexport interface SettingsCallbacks {\n\tonAutoCompactChange: (enabled: boolean) => void;\n\tonShowImagesChange: (enabled: boolean) => void;\n\tonImageWidthCellsChange: (width: number) => void;\n\tonAutoResizeImagesChange: (enabled: boolean) => void;\n\tonBlockImagesChange: (blocked: boolean) => void;\n\tonEnableSkillCommandsChange: (enabled: boolean) => void;\n\tonSteeringModeChange: (mode: \"all\" | \"one-at-a-time\") => void;\n\tonFollowUpModeChange: (mode: \"all\" | \"one-at-a-time\") => void;\n\tonTransportChange: (transport: Transport) => void;\n\tonHttpIdleTimeoutMsChange: (timeoutMs: number) => void;\n\tonModelThinkingLevelChange: (provider: string, modelId: string, level: ThinkingLevel) => void;\n\tonModelThinkingLevelRemove: (provider: string, modelId: string) => void;\n\tonThemeChange: (theme: string) => void;\n\tonThemePreview?: (theme: string) => void;\n\tonHideThinkingBlockChange: (hidden: boolean) => void;\n\tonMermaidRenderingModeChange: (mode: MermaidRenderingMode) => void;\n\tonShowCacheMissNoticesChange: (shown: boolean) => void;\n\tonCollapseChangelogChange: (collapsed: boolean) => void;\n\tonDoubleEscapeActionChange: (action: \"fork\" | \"tree\" | \"none\") => void;\n\tonUiLanguageChange: (language: \"zh-CN\" | \"en\") => void;\n\tonTreeFilterModeChange: (mode: \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\") => void;\n\tonShowHardwareCursorChange: (enabled: boolean) => void;\n\tonEditorPaddingXChange: (padding: number) => void;\n\tonOutputPadChange: (padding: 0 | 1) => void;\n\tonAutocompleteMaxVisibleChange: (maxVisible: number) => void;\n\tonQuietStartupChange: (enabled: boolean) => void;\n\tonClearOnShrinkChange: (enabled: boolean) => void;\n\tonShowTerminalProgressChange: (enabled: boolean) => void;\n\tonTuiModeChange: (mode: TuiMode) => void;\n\tonFullscreenExitOutputChange: (output: FullscreenExitOutput) => void;\n\tonFullscreenScrollbarChange: (mode: ScrollViewScrollbar) => void;\n\tonFullscreenCopyOnSelectChange: (enabled: boolean) => void;\n\tonFullscreenWheelScrollLinesChange: (lines: WheelScrollLines) => void;\n\tonWarningsChange: (warnings: WarningSettings) => void;\n\tonCancel: () => void;\n}\n\n/**\n * A submenu component for selecting from a list of options.\n */\nclass WarningSettingsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\tprivate state: WarningSettings;\n\n\tconstructor(warnings: WarningSettings, onChange: (warnings: WarningSettings) => void, onCancel: () => void) {\n\t\tsuper();\n\n\t\tthis.state = { ...warnings };\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"anthropic-extra-usage\",\n\t\t\t\tlabel: t(\"Anthropic extra usage\"),\n\t\t\t\tdescription: t(\"Warn when Anthropic subscription auth may use paid extra usage\"),\n\t\t\t\tcurrentValue: (this.state.anthropicExtraUsage ?? true) ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t];\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 10),\n\t\t\tgetSettingsListTheme(),\n\t\t\t(id, newValue) => {\n\t\t\t\tswitch (id) {\n\t\t\t\t\tcase \"anthropic-extra-usage\":\n\t\t\t\t\t\tthis.state = { ...this.state, anthropicExtraUsage: newValue === \"true\" };\n\t\t\t\t\t\tonChange({ ...this.state });\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t},\n\t\t\tonCancel,\n\t\t);\n\n\t\tthis.addChild(this.settingsList);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.settingsList.handleInput(data);\n\t}\n}\n\nconst CLEAR_OVERRIDE_VALUE = \"__clear__\";\n\nfunction modelSettingKey(model: Model<Api>): string {\n\treturn `${model.provider}/${model.id}`;\n}\n\nfunction modelDisplayLabel(model: Model<Api>): string {\n\treturn `${model.id} [${model.provider}]`;\n}\n\nfunction modelThinkingOverridesSummary(overrides: Record<string, ThinkingLevel>): string {\n\tconst count = Object.keys(overrides).length;\n\tif (count === 0) return t(\"none\");\n\treturn t(\"{count} configured\", { count });\n}\n\nfunction modelItemLabel(model: Model<Api>): string {\n\treturn `${model.id} ${theme.fg(\"muted\", `[${model.provider}]`)}`;\n}\n\nfunction themeItems(availableThemes: string[]): SelectItem[] {\n\treturn availableThemes.map((name) => ({ value: name, label: name }));\n}\n\nconst AUTOMATIC_THEME_VALUE = \"/\";\n\nfunction singleModeThemeItems(availableThemes: string[]): SelectItem[] {\n\treturn [\n\t\t{\n\t\t\tvalue: AUTOMATIC_THEME_VALUE,\n\t\t\tlabel: t(\"Automatic\"),\n\t\t\tdescription: t(\"Use separate themes for light and dark terminal appearance\"),\n\t\t},\n\t\t...themeItems(availableThemes),\n\t];\n}\n\nfunction preferredTheme(availableThemes: string[], preferred: string | undefined, fallback: string): string {\n\tif (preferred && availableThemes.includes(preferred)) return preferred;\n\tif (availableThemes.includes(fallback)) return fallback;\n\treturn availableThemes[0] ?? fallback;\n}\n\nfunction defaultAutomaticThemes(\n\tcurrentThemeSetting: string,\n\tavailableThemes: string[],\n): { lightTheme: string; darkTheme: string } {\n\tconst autoTheme = parseAutoThemeSetting(currentThemeSetting);\n\tif (autoTheme) return autoTheme;\n\n\tconst currentFixedTheme = currentThemeSetting.includes(\"/\") ? undefined : currentThemeSetting;\n\tconst themeName = preferredTheme(availableThemes, currentFixedTheme, \"dark\");\n\treturn { lightTheme: themeName, darkTheme: themeName };\n}\n\nclass ThemeSubmenu extends Container {\n\tprivate inputComponent: Component | undefined;\n\tprivate readonly callbacks: SettingsCallbacks;\n\tprivate readonly availableThemes: string[];\n\tprivate readonly terminalTheme: TerminalTheme;\n\tprivate readonly onDone: (selectedValue?: string) => void;\n\tprivate readonly originalThemeSetting: string;\n\tprivate mode: \"single\" | \"automatic\";\n\tprivate singleTheme: string;\n\tprivate lightTheme: string;\n\tprivate darkTheme: string;\n\n\tconstructor(\n\t\tcurrentThemeSetting: string,\n\t\tterminalTheme: TerminalTheme,\n\t\tavailableThemes: string[],\n\t\tcallbacks: SettingsCallbacks,\n\t\tonDone: (selectedValue?: string) => void,\n\t) {\n\t\tsuper();\n\t\tthis.callbacks = callbacks;\n\t\tthis.availableThemes = availableThemes;\n\t\tthis.terminalTheme = terminalTheme;\n\t\tthis.onDone = onDone;\n\t\tthis.originalThemeSetting = currentThemeSetting;\n\t\tconst autoTheme = parseAutoThemeSetting(currentThemeSetting);\n\t\tconst automaticThemes = defaultAutomaticThemes(currentThemeSetting, availableThemes);\n\t\tconst fixedTheme = autoTheme || currentThemeSetting.includes(\"/\") ? undefined : currentThemeSetting;\n\t\tthis.mode = autoTheme ? \"automatic\" : \"single\";\n\t\tthis.lightTheme = automaticThemes.lightTheme;\n\t\tthis.darkTheme = automaticThemes.darkTheme;\n\t\tthis.singleTheme = preferredTheme(\n\t\t\tavailableThemes,\n\t\t\tfixedTheme ?? (autoTheme ? this.getActiveAutomaticTheme() : undefined),\n\t\t\t\"dark\",\n\t\t);\n\n\t\tif (this.mode === \"automatic\") {\n\t\t\tthis.showAutomaticMenu();\n\t\t} else {\n\t\t\tthis.showSingleMenu();\n\t\t}\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.inputComponent?.handleInput?.(data);\n\t}\n\n\tprivate setContent(renderComponent: Component, inputComponent: Component = renderComponent): void {\n\t\tthis.clear();\n\t\tthis.addChild(renderComponent);\n\t\tthis.inputComponent = inputComponent;\n\t}\n\n\tprivate showSingleMenu(): void {\n\t\tthis.mode = \"single\";\n\t\tconst menu = new SelectSubmenu(\n\t\t\tt(\"Theme\"),\n\t\t\tt(\"Select a theme, or choose Automatic to follow terminal appearance.\"),\n\t\t\tsingleModeThemeItems(this.availableThemes),\n\t\t\tthis.singleTheme,\n\t\t\t(value) => {\n\t\t\t\tif (value === AUTOMATIC_THEME_VALUE) {\n\t\t\t\t\tthis.mode = \"automatic\";\n\t\t\t\t\tthis.callbacks.onThemePreview?.(this.getThemeSetting());\n\t\t\t\t\tthis.showAutomaticMenu();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.singleTheme = value;\n\t\t\t\tthis.apply(value);\n\t\t\t},\n\t\t\t() => this.cancel(),\n\t\t\t(value) => {\n\t\t\t\tthis.callbacks.onThemePreview?.(value === AUTOMATIC_THEME_VALUE ? this.getAutomaticThemeSetting() : value);\n\t\t\t},\n\t\t);\n\t\tthis.setContent(menu);\n\t}\n\n\tprivate showAutomaticMenu(): void {\n\t\tthis.mode = \"automatic\";\n\t\tconst content = new Container();\n\t\tcontent.addChild(new Text(theme.bold(theme.fg(\"accent\", t(\"Automatic Theme\"))), 0, 0));\n\t\tcontent.addChild(new Spacer(1));\n\t\tcontent.addChild(new Text(theme.fg(\"muted\", t(\"Choose themes for terminal light and dark appearance.\")), 0, 0));\n\t\tcontent.addChild(new Text(theme.fg(\"muted\", t(\"Light/dark detection requires terminal support.\")), 0, 0));\n\t\tcontent.addChild(new Spacer(1));\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"light-theme\",\n\t\t\t\tlabel: t(\"Light theme\"),\n\t\t\t\tdescription: t(\"Theme to use in automatic mode when the terminal is light\"),\n\t\t\t\tcurrentValue: this.lightTheme,\n\t\t\t\tsubmenu: (currentValue, done) =>\n\t\t\t\t\tthis.createThemeSelect(\n\t\t\t\t\t\tt(\"Light Theme\"),\n\t\t\t\t\t\tt(\"Select the theme to use for light terminal appearance\"),\n\t\t\t\t\t\tcurrentValue,\n\t\t\t\t\t\tdone,\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\tthis.lightTheme = value;\n\t\t\t\t\t\t\tthis.callbacks.onThemePreview?.(this.getThemeSetting());\n\t\t\t\t\t\t\tdone(value);\n\t\t\t\t\t\t},\n\t\t\t\t\t),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"dark-theme\",\n\t\t\t\tlabel: t(\"Dark theme\"),\n\t\t\t\tdescription: t(\"Theme to use in automatic mode when the terminal is dark\"),\n\t\t\t\tcurrentValue: this.darkTheme,\n\t\t\t\tsubmenu: (currentValue, done) =>\n\t\t\t\t\tthis.createThemeSelect(\n\t\t\t\t\t\tt(\"Dark Theme\"),\n\t\t\t\t\t\tt(\"Select the theme to use for dark terminal appearance\"),\n\t\t\t\t\t\tcurrentValue,\n\t\t\t\t\t\tdone,\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\tthis.darkTheme = value;\n\t\t\t\t\t\t\tthis.callbacks.onThemePreview?.(this.getThemeSetting());\n\t\t\t\t\t\t\tdone(value);\n\t\t\t\t\t\t},\n\t\t\t\t\t),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"apply\",\n\t\t\t\tlabel: t(\"Apply\"),\n\t\t\t\tdescription: t(\"Save and go back\"),\n\t\t\t\tcurrentValue: t(\"save and go back\"),\n\t\t\t\tvalues: [t(\"save and go back\")],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"single-mode\",\n\t\t\t\tlabel: t(\"Change mode\"),\n\t\t\t\tdescription: t(\"Switch to one theme for light and dark\"),\n\t\t\t\tcurrentValue: t(\"switch to single theme\"),\n\t\t\t\tvalues: [t(\"switch to single theme\")],\n\t\t\t},\n\t\t];\n\n\t\tconst settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 10),\n\t\t\tgetSettingsListTheme(),\n\t\t\t(id) => {\n\t\t\t\tswitch (id) {\n\t\t\t\t\tcase \"single-mode\":\n\t\t\t\t\t\tthis.mode = \"single\";\n\t\t\t\t\t\tthis.singleTheme = this.getActiveAutomaticTheme();\n\t\t\t\t\t\tthis.callbacks.onThemePreview?.(this.singleTheme);\n\t\t\t\t\t\tthis.showSingleMenu();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"apply\":\n\t\t\t\t\t\tthis.apply(this.getAutomaticThemeSetting());\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => this.cancel(),\n\t\t);\n\t\tcontent.addChild(settingsList);\n\t\tthis.setContent(content, settingsList);\n\t}\n\n\tprivate createThemeSelect(\n\t\ttitle: string,\n\t\tdescription: string,\n\t\tcurrentValue: string,\n\t\tdone: (selectedValue?: string) => void,\n\t\tonSelect: (value: string) => void,\n\t): SelectSubmenu {\n\t\treturn new SelectSubmenu(\n\t\t\ttitle,\n\t\t\tdescription,\n\t\t\tthemeItems(this.availableThemes),\n\t\t\tcurrentValue,\n\t\t\tonSelect,\n\t\t\t() => {\n\t\t\t\tthis.callbacks.onThemePreview?.(this.getThemeSetting());\n\t\t\t\tdone();\n\t\t\t},\n\t\t\t(value) => this.callbacks.onThemePreview?.(value),\n\t\t);\n\t}\n\n\tprivate getThemeSetting(): string {\n\t\treturn this.mode === \"automatic\" ? this.getAutomaticThemeSetting() : this.singleTheme;\n\t}\n\n\tprivate getActiveAutomaticTheme(): string {\n\t\treturn this.terminalTheme === \"light\" ? this.lightTheme : this.darkTheme;\n\t}\n\n\tprivate getAutomaticThemeSetting(): string {\n\t\treturn `${this.lightTheme}/${this.darkTheme}`;\n\t}\n\n\tprivate apply(themeSetting: string): void {\n\t\tthis.onDone(themeSetting);\n\t}\n\n\tprivate cancel(): void {\n\t\tthis.callbacks.onThemePreview?.(this.originalThemeSetting);\n\t\tthis.onDone();\n\t}\n}\n\n/**\n * Main settings selector component.\n */\nexport class SettingsSelectorComponent extends Container {\n\tprivate settingsList: SettingsList;\n\n\tconstructor(config: SettingsConfig, callbacks: SettingsCallbacks) {\n\t\tsuper();\n\n\t\tconst supportsImages = getCapabilities().images;\n\t\tconst followUpKey = keyDisplayText(\"app.message.followUp\") || \"/queue\";\n\t\tconst cycleThinkingKey = keyDisplayText(\"app.thinking.cycle\") || \"/thinking\";\n\t\tlet currentWarnings = { ...config.warnings };\n\t\tconst currentModelThinkingLevels = { ...config.modelThinkingLevels };\n\t\tconst defaultModelByValue = new Map(\n\t\t\tconfig.availableDefaultModels.map((model) => [modelSettingKey(model), model]),\n\t\t);\n\t\tconst currentDefaultModelKey = defaultModelByValue.has(config.defaultModel) ? config.defaultModel : undefined;\n\t\tconst currentModelKey = config.currentModel ? modelSettingKey(config.currentModel) : undefined;\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"autocompact\",\n\t\t\t\tlabel: t(\"Auto-compact\"),\n\t\t\t\tdescription: t(\"Automatically compact context when it gets too large\"),\n\t\t\t\tcurrentValue: config.autoCompact ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"steering-mode\",\n\t\t\t\tlabel: t(\"Steering mode\"),\n\t\t\t\tdescription: t(\n\t\t\t\t\t\"Enter while streaming queues steering messages. 'one-at-a-time': deliver one, wait for response. 'all': deliver all at once.\",\n\t\t\t\t),\n\t\t\t\tcurrentValue: config.steeringMode,\n\t\t\t\tvalues: [\"one-at-a-time\", \"all\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"follow-up-mode\",\n\t\t\t\tlabel: t(\"Follow-up mode\"),\n\t\t\t\tdescription: t(\n\t\t\t\t\t\"{key} queues follow-up messages until agent stops. 'one-at-a-time': deliver one, wait for response. 'all': deliver all at once.\",\n\t\t\t\t\t{ key: followUpKey },\n\t\t\t\t),\n\t\t\t\tcurrentValue: config.followUpMode,\n\t\t\t\tvalues: [\"one-at-a-time\", \"all\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"transport\",\n\t\t\t\tlabel: t(\"Transport\"),\n\t\t\t\tdescription: t(\"Preferred transport for providers that support multiple transports\"),\n\t\t\t\tcurrentValue: config.transport,\n\t\t\t\tvalues: [\"sse\", \"websocket\", \"websocket-cached\", \"auto\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"http-idle-timeout\",\n\t\t\t\tlabel: t(\"HTTP idle timeout\"),\n\t\t\t\tdescription: t(\n\t\t\t\t\t\"Maximum idle gap while waiting for HTTP headers or body chunks. Disable for local models that pause longer than five minutes.\",\n\t\t\t\t),\n\t\t\t\tcurrentValue: formatHttpIdleTimeoutMs(config.httpIdleTimeoutMs),\n\t\t\t\tvalues: HTTP_IDLE_TIMEOUT_CHOICES.map((choice) => choice.label),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"hide-thinking\",\n\t\t\t\tlabel: t(\"Hide thinking\"),\n\t\t\t\tdescription: t(\"Hide thinking blocks in assistant responses\"),\n\t\t\t\tcurrentValue: config.hideThinkingBlock ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"mermaid-rendering\",\n\t\t\t\tlabel: t(\"Mermaid diagrams\"),\n\t\t\t\tdescription: t(\"Render Mermaid code blocks as Unicode diagrams\"),\n\t\t\t\tcurrentValue: config.mermaidRenderingMode,\n\t\t\t\tvalues: [\"off\", \"final\", \"streaming\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"cache-miss-notices\",\n\t\t\t\tlabel: t(\"Cache miss notices\"),\n\t\t\t\tdescription: t(\"Show transcript notices for cache costs and provider recovery diagnostics\"),\n\t\t\t\tcurrentValue: config.showCacheMissNotices ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"collapse-changelog\",\n\t\t\t\tlabel: t(\"Collapse changelog\"),\n\t\t\t\tdescription: t(\"Show condensed changelog after updates\"),\n\t\t\t\tcurrentValue: config.collapseChangelog ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"quiet-startup\",\n\t\t\t\tlabel: t(\"Quiet startup\"),\n\t\t\t\tdescription: t(\"Disable verbose printing at startup\"),\n\t\t\t\tcurrentValue: config.quietStartup ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"double-escape-action\",\n\t\t\t\tlabel: t(\"Double-escape action\"),\n\t\t\t\tdescription: t(\"Action when pressing Escape twice with empty editor\"),\n\t\t\t\tcurrentValue: config.doubleEscapeAction,\n\t\t\t\tvalues: [\"tree\", \"fork\", \"none\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"language\",\n\t\t\t\tlabel: t(\"Interface language\"),\n\t\t\t\tdescription: t(\"Language for UI text; takes effect immediately\"),\n\t\t\t\tcurrentValue: config.uiLanguage,\n\t\t\t\tvalues: [\"zh-CN\", \"en\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"tree-filter-mode\",\n\t\t\t\tlabel: t(\"Tree filter mode\"),\n\t\t\t\tdescription: t(\"Default filter when opening /tree\"),\n\t\t\t\tcurrentValue: config.treeFilterMode,\n\t\t\t\tvalues: [\"default\", \"no-tools\", \"user-only\", \"labeled-only\", \"all\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"warnings\",\n\t\t\t\tlabel: t(\"Warnings\"),\n\t\t\t\tdescription: t(\"Enable or disable individual warnings\"),\n\t\t\t\tcurrentValue: t(\"configure\"),\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew WarningSettingsSubmenu(\n\t\t\t\t\t\tcurrentWarnings,\n\t\t\t\t\t\t(warnings) => {\n\t\t\t\t\t\t\tcurrentWarnings = warnings;\n\t\t\t\t\t\t\tcallbacks.onWarningsChange(warnings);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => done(),\n\t\t\t\t\t),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"model-thinking\",\n\t\t\t\tlabel: t(\"Default thinking level per model\"),\n\t\t\t\tdescription: t(\"Override the default thinking level for specific models. {key} cycles in-session.\", {\n\t\t\t\t\tkey: cycleThinkingKey,\n\t\t\t\t}),\n\t\t\t\tcurrentValue: modelThinkingOverridesSummary(currentModelThinkingLevels),\n\t\t\t\tsubmenu: (_currentValue, done) => {\n\t\t\t\t\tconst steps: SteppedSubmenuStep[] = [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkey: \"model\",\n\t\t\t\t\t\t\ttitle: t(\"Per-Model Thinking Level\"),\n\t\t\t\t\t\t\tdescription: t(\"Select a model to configure\"),\n\t\t\t\t\t\t\toptions: () => {\n\t\t\t\t\t\t\t\tconst sorted = [...config.availableDefaultModels].sort((a, b) => {\n\t\t\t\t\t\t\t\t\tconst aKey = modelSettingKey(a);\n\t\t\t\t\t\t\t\t\tconst bKey = modelSettingKey(b);\n\t\t\t\t\t\t\t\t\tif (aKey === currentModelKey) return -1;\n\t\t\t\t\t\t\t\t\tif (bKey === currentModelKey) return 1;\n\t\t\t\t\t\t\t\t\tif (aKey === currentDefaultModelKey) return -1;\n\t\t\t\t\t\t\t\t\tif (bKey === currentDefaultModelKey) return 1;\n\t\t\t\t\t\t\t\t\treturn a.provider.localeCompare(b.provider);\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tconst items: SelectItem[] = sorted.map((model) => {\n\t\t\t\t\t\t\t\t\tconst key = modelSettingKey(model);\n\t\t\t\t\t\t\t\t\tconst override = currentModelThinkingLevels[key];\n\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\tvalue: key,\n\t\t\t\t\t\t\t\t\t\tlabel: modelItemLabel(model),\n\t\t\t\t\t\t\t\t\t\tdescription: override ?? undefined,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (items.length === 0) {\n\t\t\t\t\t\t\t\t\titems.push({\n\t\t\t\t\t\t\t\t\t\tvalue: \"__none__\",\n\t\t\t\t\t\t\t\t\t\tlabel: t(\"No models available\"),\n\t\t\t\t\t\t\t\t\t\tdescription: t(\"Log in to a provider or configure an API key first\"),\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn items;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpreselect: () => currentModelKey ?? currentDefaultModelKey,\n\t\t\t\t\t\t\tsearchable: true,\n\t\t\t\t\t\t\tlayout: MODEL_PICKER_LAYOUT,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkey: \"level\",\n\t\t\t\t\t\t\ttitle: (ctx) => {\n\t\t\t\t\t\t\t\tconst m = defaultModelByValue.get(ctx.model);\n\t\t\t\t\t\t\t\treturn t(\"Thinking Level for {model}\", { model: m ? modelDisplayLabel(m) : ctx.model });\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdescription: t(\"Select default thinking level for this model\"),\n\t\t\t\t\t\t\toptions: (ctx) => {\n\t\t\t\t\t\t\t\tconst model = defaultModelByValue.get(ctx.model);\n\t\t\t\t\t\t\t\tif (!model) return [];\n\t\t\t\t\t\t\t\tconst levels = (\n\t\t\t\t\t\t\t\t\tmodel.reasoning ? getSupportedThinkingLevels(model) : [\"off\"]\n\t\t\t\t\t\t\t\t) as ThinkingLevel[];\n\t\t\t\t\t\t\t\tconst items: SelectItem[] = levels.map((level) => ({\n\t\t\t\t\t\t\t\t\tvalue: level,\n\t\t\t\t\t\t\t\t\tlabel: level,\n\t\t\t\t\t\t\t\t\tdescription: thinkingDescription(level),\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\tif (currentModelThinkingLevels[ctx.model] !== undefined) {\n\t\t\t\t\t\t\t\t\titems.push({\n\t\t\t\t\t\t\t\t\t\tvalue: CLEAR_OVERRIDE_VALUE,\n\t\t\t\t\t\t\t\t\t\tlabel: t(\"(clear override)\"),\n\t\t\t\t\t\t\t\t\t\tdescription: t(\"Revert to global default ({level})\", { level: config.thinkingLevel }),\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn items;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpreselect: (ctx) => currentModelThinkingLevels[ctx.model],\n\t\t\t\t\t\t},\n\t\t\t\t\t];\n\n\t\t\t\t\tconst summary = () => modelThinkingOverridesSummary(currentModelThinkingLevels);\n\n\t\t\t\t\treturn new SteppedSubmenu(\n\t\t\t\t\t\tsteps,\n\t\t\t\t\t\t(selections) => {\n\t\t\t\t\t\t\tconst model = defaultModelByValue.get(selections.model);\n\t\t\t\t\t\t\t// v8 ignore next -- the no-models placeholder value never resolves to a model\n\t\t\t\t\t\t\tif (!model) return;\n\t\t\t\t\t\t\tif (selections.level === CLEAR_OVERRIDE_VALUE) {\n\t\t\t\t\t\t\t\tcallbacks.onModelThinkingLevelRemove(model.provider, model.id);\n\t\t\t\t\t\t\t\tdelete currentModelThinkingLevels[selections.model];\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcallbacks.onModelThinkingLevelChange(\n\t\t\t\t\t\t\t\t\tmodel.provider,\n\t\t\t\t\t\t\t\t\tmodel.id,\n\t\t\t\t\t\t\t\t\tselections.level as ThinkingLevel,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tcurrentModelThinkingLevels[selections.model] = selections.level as ThinkingLevel;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\tdone(summary());\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ loop: true },\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"tui-mode\",\n\t\t\t\tlabel: t(\"TUI mode\"),\n\t\t\t\tdescription: t(\"Interface layout; fullscreen mode is experimental\"),\n\t\t\t\tcurrentValue: config.tuiMode,\n\t\t\t\tvalues: [\"regular\", \"fullscreen\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"fullscreen-exit-output\",\n\t\t\t\tlabel: t(\"Fullscreen exit output\"),\n\t\t\t\tdescription: t(\"Print the transcript or only a session resume hint when exiting fullscreen mode\"),\n\t\t\t\tcurrentValue: config.fullscreenExitOutput,\n\t\t\t\tvalues: [\"transcript\", \"resume-hint\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"fullscreen-scrollbar\",\n\t\t\t\tlabel: t(\"Fullscreen scrollbar\"),\n\t\t\t\tdescription: t(\"Scrollbar behavior in fullscreen mode; has no effect in regular mode\"),\n\t\t\t\tcurrentValue: config.fullscreenScrollbar,\n\t\t\t\tvalues: [\"auto\", \"always\", \"hidden\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"fullscreen-copy-on-select\",\n\t\t\t\tlabel: t(\"Fullscreen copy on select\"),\n\t\t\t\tdescription: t(\n\t\t\t\t\t\"Automatically copy selected text in fullscreen mode; disable to copy selections with Ctrl+X\",\n\t\t\t\t),\n\t\t\t\tcurrentValue: config.fullscreenCopyOnSelect ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"fullscreen-wheel-scroll-lines\",\n\t\t\t\tlabel: t(\"Fullscreen wheel scroll lines\"),\n\t\t\t\tdescription: t(\"Lines scrolled per wheel event in fullscreen mode; auto accelerates with scroll speed\"),\n\t\t\t\tcurrentValue: String(config.fullscreenWheelScrollLines),\n\t\t\t\tvalues: [\"auto\", \"1\", \"2\", \"3\", \"5\", \"10\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"theme\",\n\t\t\t\tlabel: t(\"Theme\"),\n\t\t\t\tdescription: t(\"Color theme for the interface\"),\n\t\t\t\tcurrentValue: config.currentTheme,\n\t\t\t\tsubmenu: (currentValue, done) =>\n\t\t\t\t\tnew ThemeSubmenu(currentValue, config.terminalTheme, config.availableThemes, callbacks, done),\n\t\t\t},\n\t\t];\n\n\t\t// Only show image toggle if terminal supports it\n\t\tif (supportsImages) {\n\t\t\t// Insert after autocompact\n\t\t\titems.splice(1, 0, {\n\t\t\t\tid: \"show-images\",\n\t\t\t\tlabel: t(\"Show images\"),\n\t\t\t\tdescription: t(\"Render images inline in terminal\"),\n\t\t\t\tcurrentValue: config.showImages ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t});\n\t\t\titems.splice(2, 0, {\n\t\t\t\tid: \"image-width-cells\",\n\t\t\t\tlabel: t(\"Image width\"),\n\t\t\t\tdescription: t(\"Preferred inline image width in terminal cells\"),\n\t\t\t\tcurrentValue: String(config.imageWidthCells),\n\t\t\t\tvalues: [\"60\", \"80\", \"120\"],\n\t\t\t});\n\t\t}\n\n\t\t// Image auto-resize toggle (always available, affects both attached and read images)\n\t\titems.splice(supportsImages ? 3 : 1, 0, {\n\t\t\tid: \"auto-resize-images\",\n\t\t\tlabel: t(\"Auto-resize images\"),\n\t\t\tdescription: t(\"Resize large images to 2000x2000 max for better model compatibility\"),\n\t\t\tcurrentValue: config.autoResizeImages ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Block images toggle (always available, insert after auto-resize-images)\n\t\tconst autoResizeIndex = items.findIndex((item) => item.id === \"auto-resize-images\");\n\t\titems.splice(autoResizeIndex + 1, 0, {\n\t\t\tid: \"block-images\",\n\t\t\tlabel: t(\"Block images\"),\n\t\t\tdescription: t(\"Prevent images from being sent to LLM providers\"),\n\t\t\tcurrentValue: config.blockImages ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Skill commands toggle (insert after block-images)\n\t\tconst blockImagesIndex = items.findIndex((item) => item.id === \"block-images\");\n\t\titems.splice(blockImagesIndex + 1, 0, {\n\t\t\tid: \"skill-commands\",\n\t\t\tlabel: t(\"Skill commands\"),\n\t\t\tdescription: t(\"Register skills as /skill:name commands\"),\n\t\t\tcurrentValue: config.enableSkillCommands ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Hardware cursor toggle (insert after skill-commands)\n\t\tconst skillCommandsIndex = items.findIndex((item) => item.id === \"skill-commands\");\n\t\titems.splice(skillCommandsIndex + 1, 0, {\n\t\t\tid: \"show-hardware-cursor\",\n\t\t\tlabel: t(\"Show hardware cursor\"),\n\t\t\tdescription: t(\"Show the terminal cursor while still positioning it for IME support\"),\n\t\t\tcurrentValue: config.showHardwareCursor ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Editor padding toggle (insert after show-hardware-cursor)\n\t\tconst hardwareCursorIndex = items.findIndex((item) => item.id === \"show-hardware-cursor\");\n\t\titems.splice(hardwareCursorIndex + 1, 0, {\n\t\t\tid: \"editor-padding\",\n\t\t\tlabel: t(\"Editor padding\"),\n\t\t\tdescription: t(\"Horizontal padding for input editor (0-3)\"),\n\t\t\tcurrentValue: String(config.editorPaddingX),\n\t\t\tvalues: [\"0\", \"1\", \"2\", \"3\"],\n\t\t});\n\n\t\t// Output padding toggle (insert after editor-padding)\n\t\tconst editorPaddingIndex = items.findIndex((item) => item.id === \"editor-padding\");\n\t\titems.splice(editorPaddingIndex + 1, 0, {\n\t\t\tid: \"output-padding\",\n\t\t\tlabel: t(\"Output padding\"),\n\t\t\tdescription: t(\"Horizontal padding for user messages, assistant messages, and thinking\"),\n\t\t\tcurrentValue: String(config.outputPad),\n\t\t\tvalues: [\"0\", \"1\"],\n\t\t});\n\n\t\t// Autocomplete max visible toggle (insert after output-padding)\n\t\tconst outputPaddingIndex = items.findIndex((item) => item.id === \"output-padding\");\n\t\titems.splice(outputPaddingIndex + 1, 0, {\n\t\t\tid: \"autocomplete-max-visible\",\n\t\t\tlabel: t(\"Autocomplete max items\"),\n\t\t\tdescription: t(\"Max visible items in autocomplete dropdown (3-20)\"),\n\t\t\tcurrentValue: String(config.autocompleteMaxVisible),\n\t\t\tvalues: [\"3\", \"5\", \"7\", \"10\", \"15\", \"20\"],\n\t\t});\n\n\t\t// Clear on shrink toggle (insert after autocomplete-max-visible)\n\t\tconst autocompleteIndex = items.findIndex((item) => item.id === \"autocomplete-max-visible\");\n\t\titems.splice(autocompleteIndex + 1, 0, {\n\t\t\tid: \"clear-on-shrink\",\n\t\t\tlabel: t(\"Clear on shrink\"),\n\t\t\tdescription: t(\"Clear empty rows when content shrinks (may cause flicker)\"),\n\t\t\tcurrentValue: config.clearOnShrink ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Terminal progress toggle (insert after clear-on-shrink)\n\t\tconst clearOnShrinkIndex = items.findIndex((item) => item.id === \"clear-on-shrink\");\n\t\titems.splice(clearOnShrinkIndex + 1, 0, {\n\t\t\tid: \"terminal-progress\",\n\t\t\tlabel: t(\"Terminal progress\"),\n\t\t\tdescription: t(\"Show OSC 9;4 progress indicators in the terminal tab bar\"),\n\t\t\tcurrentValue: config.showTerminalProgress ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Add borders\n\t\tthis.addChild(new DynamicBorder());\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\t10,\n\t\t\tgetSettingsListTheme(),\n\t\t\t(id, newValue) => {\n\t\t\t\tswitch (id) {\n\t\t\t\t\tcase \"autocompact\":\n\t\t\t\t\t\tcallbacks.onAutoCompactChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"show-images\":\n\t\t\t\t\t\tcallbacks.onShowImagesChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"image-width-cells\":\n\t\t\t\t\t\tcallbacks.onImageWidthCellsChange(parseInt(newValue, 10));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"auto-resize-images\":\n\t\t\t\t\t\tcallbacks.onAutoResizeImagesChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"block-images\":\n\t\t\t\t\t\tcallbacks.onBlockImagesChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"skill-commands\":\n\t\t\t\t\t\tcallbacks.onEnableSkillCommandsChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"steering-mode\":\n\t\t\t\t\t\tcallbacks.onSteeringModeChange(newValue as \"all\" | \"one-at-a-time\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"follow-up-mode\":\n\t\t\t\t\t\tcallbacks.onFollowUpModeChange(newValue as \"all\" | \"one-at-a-time\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"transport\":\n\t\t\t\t\t\tcallbacks.onTransportChange(newValue as Transport);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"http-idle-timeout\": {\n\t\t\t\t\t\tconst choice = HTTP_IDLE_TIMEOUT_CHOICES.find((item) => item.label === newValue);\n\t\t\t\t\t\t// v8 ignore next -- the timeout choice lookup always matches a rendered value\n\t\t\t\t\t\tif (choice) {\n\t\t\t\t\t\t\tcallbacks.onHttpIdleTimeoutMsChange(choice.timeoutMs);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"hide-thinking\":\n\t\t\t\t\t\tcallbacks.onHideThinkingBlockChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"mermaid-rendering\":\n\t\t\t\t\t\tcallbacks.onMermaidRenderingModeChange(newValue as MermaidRenderingMode);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"cache-miss-notices\":\n\t\t\t\t\t\tcallbacks.onShowCacheMissNoticesChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"collapse-changelog\":\n\t\t\t\t\t\tcallbacks.onCollapseChangelogChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"quiet-startup\":\n\t\t\t\t\t\tcallbacks.onQuietStartupChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"double-escape-action\":\n\t\t\t\t\t\tcallbacks.onDoubleEscapeActionChange(newValue as \"fork\" | \"tree\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"language\":\n\t\t\t\t\t\tcallbacks.onUiLanguageChange(newValue as \"zh-CN\" | \"en\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"tree-filter-mode\":\n\t\t\t\t\t\tcallbacks.onTreeFilterModeChange(\n\t\t\t\t\t\t\tnewValue as \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"show-hardware-cursor\":\n\t\t\t\t\t\tcallbacks.onShowHardwareCursorChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"editor-padding\":\n\t\t\t\t\t\tcallbacks.onEditorPaddingXChange(parseInt(newValue, 10));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"output-padding\":\n\t\t\t\t\t\tcallbacks.onOutputPadChange(newValue === \"0\" ? 0 : 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"autocomplete-max-visible\":\n\t\t\t\t\t\tcallbacks.onAutocompleteMaxVisibleChange(parseInt(newValue, 10));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"clear-on-shrink\":\n\t\t\t\t\t\tcallbacks.onClearOnShrinkChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"terminal-progress\":\n\t\t\t\t\t\tcallbacks.onShowTerminalProgressChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"tui-mode\":\n\t\t\t\t\t\tcallbacks.onTuiModeChange(newValue as TuiMode);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"fullscreen-exit-output\":\n\t\t\t\t\t\tcallbacks.onFullscreenExitOutputChange(newValue as FullscreenExitOutput);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"fullscreen-scrollbar\":\n\t\t\t\t\t\tcallbacks.onFullscreenScrollbarChange(newValue as ScrollViewScrollbar);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"fullscreen-copy-on-select\":\n\t\t\t\t\t\tcallbacks.onFullscreenCopyOnSelectChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"fullscreen-wheel-scroll-lines\":\n\t\t\t\t\t\tcallbacks.onFullscreenWheelScrollLinesChange(\n\t\t\t\t\t\t\tnewValue === \"auto\" ? \"auto\" : (Number(newValue) as WheelScrollLines),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"theme\":\n\t\t\t\t\t\tcallbacks.onThemeChange(newValue);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t},\n\t\t\tcallbacks.onCancel,\n\t\t\t{ enableSearch: true },\n\t\t);\n\n\t\tthis.addChild(this.settingsList);\n\t\tthis.addChild(new DynamicBorder());\n\t}\n\n\tgetSettingsList(): SettingsList {\n\t\treturn this.settingsList;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"settings-selector.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/settings-selector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,KAAK,GAAG,EAA8B,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACnG,OAAO,EAEN,SAAS,EAET,KAAK,mBAAmB,EAGxB,YAAY,EAGZ,KAAK,gBAAgB,EACrB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EACX,oBAAoB,EACpB,oBAAoB,EACpB,OAAO,EACP,eAAe,EACf,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAA+C,KAAK,aAAa,EAAS,MAAM,mBAAmB,CAAC;AAsB3G,MAAM,WAAW,cAAc;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAC1B,sBAAsB,EAAE,SAAS,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;IAC9C,UAAU,EAAE,OAAO,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,KAAK,GAAG,eAAe,CAAC;IACtC,YAAY,EAAE,KAAK,GAAG,eAAe,CAAC;IACtC,SAAS,EAAE,SAAS,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,aAAa,CAAC;IAC7B,uBAAuB,EAAE,aAAa,EAAE,CAAC;IACzC,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACnD,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,aAAa,C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EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,qBAAqB,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,4BAA4B,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACzD,eAAe,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC,4BAA4B,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACrE,2BAA2B,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACjE,8BAA8B,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3D,kCAAkC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACtE,gBAAgB,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,CAAC;IACtD,QAAQ,EAAE,MAAM,IAAI,CAAC;CACrB;AAsTD;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,SAAS;IACvD,OAAO,CAAC,YAAY,CAAe;IAEnC,YAAY,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,iBAAiB,EA+d/D;IAED,eAAe,IAAI,YAAY,CAE9B;CACD","sourcesContent":["import type { ThinkingLevel } from \"@agent-forge/agent-core\";\nimport { type Api, getSupportedThinkingLevels, type Model, type Transport } from \"@agent-forge/ai\";\nimport {\n\ttype Component,\n\tContainer,\n\tgetCapabilities,\n\ttype ScrollViewScrollbar,\n\ttype SelectItem,\n\ttype SettingItem,\n\tSettingsList,\n\tSpacer,\n\tText,\n\ttype WheelScrollLines,\n} from \"@agent-forge/tui\";\nimport { formatHttpIdleTimeoutMs, HTTP_IDLE_TIMEOUT_CHOICES } from \"../../../core/http-dispatcher.ts\";\nimport { t } from \"../../../core/i18n/index.ts\";\nimport type {\n\tFullscreenExitOutput,\n\tMermaidRenderingMode,\n\tTuiMode,\n\tWarningSettings,\n} from \"../../../core/settings-manager.ts\";\nimport { getSettingsListTheme, parseAutoThemeSetting, type TerminalTheme, theme } from \"../theme/theme.ts\";\nimport { DynamicBorder } from \"./dynamic-border.ts\";\nimport { keyDisplayText } from \"./keybinding-hints.ts\";\nimport { SelectSubmenu, SteppedSubmenu, type SteppedSubmenuStep } from \"./settings-submenu.ts\";\n\nconst MODEL_PICKER_LAYOUT = { minPrimaryColumnWidth: 12, maxPrimaryColumnWidth: 46 };\n\n// i18n: 以函数查询而非模块级常量,保证语言切换后取到当前词典\nconst THINKING_DESCRIPTIONS: Record<ThinkingLevel, string> = {\n\toff: \"No reasoning\",\n\tminimal: \"Very brief reasoning (~1k tokens)\",\n\tlow: \"Light reasoning (~2k tokens)\",\n\tmedium: \"Moderate reasoning (~8k tokens)\",\n\thigh: \"Deep reasoning (~16k tokens)\",\n\txhigh: \"Extra-high reasoning (~32k tokens)\",\n\tmax: \"Maximum reasoning\",\n};\n\nfunction thinkingDescription(level: ThinkingLevel): string {\n\treturn t(THINKING_DESCRIPTIONS[level]);\n}\n\nexport interface SettingsConfig {\n\tdefaultModel: string;\n\tcurrentModel?: Model<Api>;\n\tavailableDefaultModels: readonly Model<Api>[];\n\tshowImages: boolean;\n\timageWidthCells: number;\n\tautoResizeImages: boolean;\n\tblockImages: boolean;\n\tsteeringMode: \"all\" | \"one-at-a-time\";\n\tfollowUpMode: \"all\" | \"one-at-a-time\";\n\ttransport: Transport;\n\thttpIdleTimeoutMs: number;\n\tthinkingLevel: ThinkingLevel;\n\tavailableThinkingLevels: ThinkingLevel[];\n\tmodelThinkingLevels: Record<string, ThinkingLevel>;\n\tcurrentTheme: string;\n\tterminalTheme: TerminalTheme;\n\tavailableThemes: string[];\n\thideThinkingBlock: boolean;\n\tmermaidRenderingMode: MermaidRenderingMode;\n\tshowCacheMissNotices: boolean;\n\tcollapseChangelog: boolean;\n\tdoubleEscapeAction: \"tree\" | \"none\";\n\tuiLanguage: \"zh-CN\" | \"en\";\n\ttreeFilterMode: \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\";\n\tshowHardwareCursor: boolean;\n\teditorPaddingX: number;\n\toutputPad: 0 | 1;\n\tautocompleteMaxVisible: number;\n\tquietStartup: boolean;\n\tclearOnShrink: boolean;\n\tshowTerminalProgress: boolean;\n\ttuiMode: TuiMode;\n\tfullscreenExitOutput: FullscreenExitOutput;\n\tfullscreenScrollbar: ScrollViewScrollbar;\n\tfullscreenCopyOnSelect: boolean;\n\tfullscreenWheelScrollLines: WheelScrollLines;\n\twarnings: WarningSettings;\n}\n\nexport interface SettingsCallbacks {\n\tonShowImagesChange: (enabled: boolean) => void;\n\tonImageWidthCellsChange: (width: number) => void;\n\tonAutoResizeImagesChange: (enabled: boolean) => void;\n\tonBlockImagesChange: (blocked: boolean) => void;\n\tonSteeringModeChange: (mode: \"all\" | \"one-at-a-time\") => void;\n\tonFollowUpModeChange: (mode: \"all\" | \"one-at-a-time\") => void;\n\tonTransportChange: (transport: Transport) => void;\n\tonHttpIdleTimeoutMsChange: (timeoutMs: number) => void;\n\tonModelThinkingLevelChange: (provider: string, modelId: string, level: ThinkingLevel) => void;\n\tonModelThinkingLevelRemove: (provider: string, modelId: string) => void;\n\tonThemeChange: (theme: string) => void;\n\tonThemePreview?: (theme: string) => void;\n\tonHideThinkingBlockChange: (hidden: boolean) => void;\n\tonMermaidRenderingModeChange: (mode: MermaidRenderingMode) => void;\n\tonShowCacheMissNoticesChange: (shown: boolean) => void;\n\tonCollapseChangelogChange: (collapsed: boolean) => void;\n\tonDoubleEscapeActionChange: (action: \"tree\" | \"none\") => void;\n\tonUiLanguageChange: (language: \"zh-CN\" | \"en\") => void;\n\tonTreeFilterModeChange: (mode: \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\") => void;\n\tonShowHardwareCursorChange: (enabled: boolean) => void;\n\tonEditorPaddingXChange: (padding: number) => void;\n\tonOutputPadChange: (padding: 0 | 1) => void;\n\tonAutocompleteMaxVisibleChange: (maxVisible: number) => void;\n\tonQuietStartupChange: (enabled: boolean) => void;\n\tonClearOnShrinkChange: (enabled: boolean) => void;\n\tonShowTerminalProgressChange: (enabled: boolean) => void;\n\tonTuiModeChange: (mode: TuiMode) => void;\n\tonFullscreenExitOutputChange: (output: FullscreenExitOutput) => void;\n\tonFullscreenScrollbarChange: (mode: ScrollViewScrollbar) => void;\n\tonFullscreenCopyOnSelectChange: (enabled: boolean) => void;\n\tonFullscreenWheelScrollLinesChange: (lines: WheelScrollLines) => void;\n\tonWarningsChange: (warnings: WarningSettings) => void;\n\tonCancel: () => void;\n}\n\n/**\n * A submenu component for selecting from a list of options.\n */\nclass WarningSettingsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\tprivate state: WarningSettings;\n\n\tconstructor(warnings: WarningSettings, onChange: (warnings: WarningSettings) => void, onCancel: () => void) {\n\t\tsuper();\n\n\t\tthis.state = { ...warnings };\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"anthropic-extra-usage\",\n\t\t\t\tlabel: t(\"Anthropic extra usage\"),\n\t\t\t\tdescription: t(\"Warn when Anthropic subscription auth may use paid extra usage\"),\n\t\t\t\tcurrentValue: (this.state.anthropicExtraUsage ?? true) ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t];\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 10),\n\t\t\tgetSettingsListTheme(),\n\t\t\t(id, newValue) => {\n\t\t\t\tswitch (id) {\n\t\t\t\t\tcase \"anthropic-extra-usage\":\n\t\t\t\t\t\tthis.state = { ...this.state, anthropicExtraUsage: newValue === \"true\" };\n\t\t\t\t\t\tonChange({ ...this.state });\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t},\n\t\t\tonCancel,\n\t\t);\n\n\t\tthis.addChild(this.settingsList);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.settingsList.handleInput(data);\n\t}\n}\n\nconst CLEAR_OVERRIDE_VALUE = \"__clear__\";\n\nfunction modelSettingKey(model: Model<Api>): string {\n\treturn `${model.provider}/${model.id}`;\n}\n\nfunction modelDisplayLabel(model: Model<Api>): string {\n\treturn `${model.id} [${model.provider}]`;\n}\n\nfunction modelThinkingOverridesSummary(overrides: Record<string, ThinkingLevel>): string {\n\tconst count = Object.keys(overrides).length;\n\tif (count === 0) return t(\"none\");\n\treturn t(\"{count} configured\", { count });\n}\n\nfunction modelItemLabel(model: Model<Api>): string {\n\treturn `${model.id} ${theme.fg(\"muted\", `[${model.provider}]`)}`;\n}\n\nfunction themeItems(availableThemes: string[]): SelectItem[] {\n\treturn availableThemes.map((name) => ({ value: name, label: name }));\n}\n\nconst AUTOMATIC_THEME_VALUE = \"/\";\n\nfunction singleModeThemeItems(availableThemes: string[]): SelectItem[] {\n\treturn [\n\t\t{\n\t\t\tvalue: AUTOMATIC_THEME_VALUE,\n\t\t\tlabel: t(\"Automatic\"),\n\t\t\tdescription: t(\"Use separate themes for light and dark terminal appearance\"),\n\t\t},\n\t\t...themeItems(availableThemes),\n\t];\n}\n\nfunction preferredTheme(availableThemes: string[], preferred: string | undefined, fallback: string): string {\n\tif (preferred && availableThemes.includes(preferred)) return preferred;\n\tif (availableThemes.includes(fallback)) return fallback;\n\treturn availableThemes[0] ?? fallback;\n}\n\nfunction defaultAutomaticThemes(\n\tcurrentThemeSetting: string,\n\tavailableThemes: string[],\n): { lightTheme: string; darkTheme: string } {\n\tconst autoTheme = parseAutoThemeSetting(currentThemeSetting);\n\tif (autoTheme) return autoTheme;\n\n\tconst currentFixedTheme = currentThemeSetting.includes(\"/\") ? undefined : currentThemeSetting;\n\tconst themeName = preferredTheme(availableThemes, currentFixedTheme, \"dark\");\n\treturn { lightTheme: themeName, darkTheme: themeName };\n}\n\nclass ThemeSubmenu extends Container {\n\tprivate inputComponent: Component | undefined;\n\tprivate readonly callbacks: SettingsCallbacks;\n\tprivate readonly availableThemes: string[];\n\tprivate readonly terminalTheme: TerminalTheme;\n\tprivate readonly onDone: (selectedValue?: string) => void;\n\tprivate readonly originalThemeSetting: string;\n\tprivate mode: \"single\" | \"automatic\";\n\tprivate singleTheme: string;\n\tprivate lightTheme: string;\n\tprivate darkTheme: string;\n\n\tconstructor(\n\t\tcurrentThemeSetting: string,\n\t\tterminalTheme: TerminalTheme,\n\t\tavailableThemes: string[],\n\t\tcallbacks: SettingsCallbacks,\n\t\tonDone: (selectedValue?: string) => void,\n\t) {\n\t\tsuper();\n\t\tthis.callbacks = callbacks;\n\t\tthis.availableThemes = availableThemes;\n\t\tthis.terminalTheme = terminalTheme;\n\t\tthis.onDone = onDone;\n\t\tthis.originalThemeSetting = currentThemeSetting;\n\t\tconst autoTheme = parseAutoThemeSetting(currentThemeSetting);\n\t\tconst automaticThemes = defaultAutomaticThemes(currentThemeSetting, availableThemes);\n\t\tconst fixedTheme = autoTheme || currentThemeSetting.includes(\"/\") ? undefined : currentThemeSetting;\n\t\tthis.mode = autoTheme ? \"automatic\" : \"single\";\n\t\tthis.lightTheme = automaticThemes.lightTheme;\n\t\tthis.darkTheme = automaticThemes.darkTheme;\n\t\tthis.singleTheme = preferredTheme(\n\t\t\tavailableThemes,\n\t\t\tfixedTheme ?? (autoTheme ? this.getActiveAutomaticTheme() : undefined),\n\t\t\t\"dark\",\n\t\t);\n\n\t\tif (this.mode === \"automatic\") {\n\t\t\tthis.showAutomaticMenu();\n\t\t} else {\n\t\t\tthis.showSingleMenu();\n\t\t}\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.inputComponent?.handleInput?.(data);\n\t}\n\n\tprivate setContent(renderComponent: Component, inputComponent: Component = renderComponent): void {\n\t\tthis.clear();\n\t\tthis.addChild(renderComponent);\n\t\tthis.inputComponent = inputComponent;\n\t}\n\n\tprivate showSingleMenu(): void {\n\t\tthis.mode = \"single\";\n\t\tconst menu = new SelectSubmenu(\n\t\t\tt(\"Theme\"),\n\t\t\tt(\"Select a theme, or choose Automatic to follow terminal appearance.\"),\n\t\t\tsingleModeThemeItems(this.availableThemes),\n\t\t\tthis.singleTheme,\n\t\t\t(value) => {\n\t\t\t\tif (value === AUTOMATIC_THEME_VALUE) {\n\t\t\t\t\tthis.mode = \"automatic\";\n\t\t\t\t\tthis.callbacks.onThemePreview?.(this.getThemeSetting());\n\t\t\t\t\tthis.showAutomaticMenu();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.singleTheme = value;\n\t\t\t\tthis.apply(value);\n\t\t\t},\n\t\t\t() => this.cancel(),\n\t\t\t(value) => {\n\t\t\t\tthis.callbacks.onThemePreview?.(value === AUTOMATIC_THEME_VALUE ? this.getAutomaticThemeSetting() : value);\n\t\t\t},\n\t\t);\n\t\tthis.setContent(menu);\n\t}\n\n\tprivate showAutomaticMenu(): void {\n\t\tthis.mode = \"automatic\";\n\t\tconst content = new Container();\n\t\tcontent.addChild(new Text(theme.bold(theme.fg(\"accent\", t(\"Automatic Theme\"))), 0, 0));\n\t\tcontent.addChild(new Spacer(1));\n\t\tcontent.addChild(new Text(theme.fg(\"muted\", t(\"Choose themes for terminal light and dark appearance.\")), 0, 0));\n\t\tcontent.addChild(new Text(theme.fg(\"muted\", t(\"Light/dark detection requires terminal support.\")), 0, 0));\n\t\tcontent.addChild(new Spacer(1));\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"light-theme\",\n\t\t\t\tlabel: t(\"Light theme\"),\n\t\t\t\tdescription: t(\"Theme to use in automatic mode when the terminal is light\"),\n\t\t\t\tcurrentValue: this.lightTheme,\n\t\t\t\tsubmenu: (currentValue, done) =>\n\t\t\t\t\tthis.createThemeSelect(\n\t\t\t\t\t\tt(\"Light Theme\"),\n\t\t\t\t\t\tt(\"Select the theme to use for light terminal appearance\"),\n\t\t\t\t\t\tcurrentValue,\n\t\t\t\t\t\tdone,\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\tthis.lightTheme = value;\n\t\t\t\t\t\t\tthis.callbacks.onThemePreview?.(this.getThemeSetting());\n\t\t\t\t\t\t\tdone(value);\n\t\t\t\t\t\t},\n\t\t\t\t\t),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"dark-theme\",\n\t\t\t\tlabel: t(\"Dark theme\"),\n\t\t\t\tdescription: t(\"Theme to use in automatic mode when the terminal is dark\"),\n\t\t\t\tcurrentValue: this.darkTheme,\n\t\t\t\tsubmenu: (currentValue, done) =>\n\t\t\t\t\tthis.createThemeSelect(\n\t\t\t\t\t\tt(\"Dark Theme\"),\n\t\t\t\t\t\tt(\"Select the theme to use for dark terminal appearance\"),\n\t\t\t\t\t\tcurrentValue,\n\t\t\t\t\t\tdone,\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\tthis.darkTheme = value;\n\t\t\t\t\t\t\tthis.callbacks.onThemePreview?.(this.getThemeSetting());\n\t\t\t\t\t\t\tdone(value);\n\t\t\t\t\t\t},\n\t\t\t\t\t),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"apply\",\n\t\t\t\tlabel: t(\"Apply\"),\n\t\t\t\tdescription: t(\"Save and go back\"),\n\t\t\t\tcurrentValue: t(\"save and go back\"),\n\t\t\t\tvalues: [t(\"save and go back\")],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"single-mode\",\n\t\t\t\tlabel: t(\"Change mode\"),\n\t\t\t\tdescription: t(\"Switch to one theme for light and dark\"),\n\t\t\t\tcurrentValue: t(\"switch to single theme\"),\n\t\t\t\tvalues: [t(\"switch to single theme\")],\n\t\t\t},\n\t\t];\n\n\t\tconst settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 10),\n\t\t\tgetSettingsListTheme(),\n\t\t\t(id) => {\n\t\t\t\tswitch (id) {\n\t\t\t\t\tcase \"single-mode\":\n\t\t\t\t\t\tthis.mode = \"single\";\n\t\t\t\t\t\tthis.singleTheme = this.getActiveAutomaticTheme();\n\t\t\t\t\t\tthis.callbacks.onThemePreview?.(this.singleTheme);\n\t\t\t\t\t\tthis.showSingleMenu();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"apply\":\n\t\t\t\t\t\tthis.apply(this.getAutomaticThemeSetting());\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => this.cancel(),\n\t\t);\n\t\tcontent.addChild(settingsList);\n\t\tthis.setContent(content, settingsList);\n\t}\n\n\tprivate createThemeSelect(\n\t\ttitle: string,\n\t\tdescription: string,\n\t\tcurrentValue: string,\n\t\tdone: (selectedValue?: string) => void,\n\t\tonSelect: (value: string) => void,\n\t): SelectSubmenu {\n\t\treturn new SelectSubmenu(\n\t\t\ttitle,\n\t\t\tdescription,\n\t\t\tthemeItems(this.availableThemes),\n\t\t\tcurrentValue,\n\t\t\tonSelect,\n\t\t\t() => {\n\t\t\t\tthis.callbacks.onThemePreview?.(this.getThemeSetting());\n\t\t\t\tdone();\n\t\t\t},\n\t\t\t(value) => this.callbacks.onThemePreview?.(value),\n\t\t);\n\t}\n\n\tprivate getThemeSetting(): string {\n\t\treturn this.mode === \"automatic\" ? this.getAutomaticThemeSetting() : this.singleTheme;\n\t}\n\n\tprivate getActiveAutomaticTheme(): string {\n\t\treturn this.terminalTheme === \"light\" ? this.lightTheme : this.darkTheme;\n\t}\n\n\tprivate getAutomaticThemeSetting(): string {\n\t\treturn `${this.lightTheme}/${this.darkTheme}`;\n\t}\n\n\tprivate apply(themeSetting: string): void {\n\t\tthis.onDone(themeSetting);\n\t}\n\n\tprivate cancel(): void {\n\t\tthis.callbacks.onThemePreview?.(this.originalThemeSetting);\n\t\tthis.onDone();\n\t}\n}\n\n/**\n * Main settings selector component.\n */\nexport class SettingsSelectorComponent extends Container {\n\tprivate settingsList: SettingsList;\n\n\tconstructor(config: SettingsConfig, callbacks: SettingsCallbacks) {\n\t\tsuper();\n\n\t\tconst supportsImages = getCapabilities().images;\n\t\tconst followUpKey = keyDisplayText(\"app.message.followUp\") || \"/queue\";\n\t\tconst cycleThinkingKey = keyDisplayText(\"app.thinking.cycle\") || \"/thinking\";\n\t\tlet currentWarnings = { ...config.warnings };\n\t\tconst currentModelThinkingLevels = { ...config.modelThinkingLevels };\n\t\tconst defaultModelByValue = new Map(\n\t\t\tconfig.availableDefaultModels.map((model) => [modelSettingKey(model), model]),\n\t\t);\n\t\tconst currentDefaultModelKey = defaultModelByValue.has(config.defaultModel) ? config.defaultModel : undefined;\n\t\tconst currentModelKey = config.currentModel ? modelSettingKey(config.currentModel) : undefined;\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"steering-mode\",\n\t\t\t\tlabel: t(\"Steering mode\"),\n\t\t\t\tdescription: t(\n\t\t\t\t\t\"Enter while streaming queues steering messages. 'one-at-a-time': deliver one, wait for response. 'all': deliver all at once.\",\n\t\t\t\t),\n\t\t\t\tcurrentValue: config.steeringMode,\n\t\t\t\tvalues: [\"one-at-a-time\", \"all\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"follow-up-mode\",\n\t\t\t\tlabel: t(\"Follow-up mode\"),\n\t\t\t\tdescription: t(\n\t\t\t\t\t\"{key} queues follow-up messages until agent stops. 'one-at-a-time': deliver one, wait for response. 'all': deliver all at once.\",\n\t\t\t\t\t{ key: followUpKey },\n\t\t\t\t),\n\t\t\t\tcurrentValue: config.followUpMode,\n\t\t\t\tvalues: [\"one-at-a-time\", \"all\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"transport\",\n\t\t\t\tlabel: t(\"Transport\"),\n\t\t\t\tdescription: t(\"Preferred transport for providers that support multiple transports\"),\n\t\t\t\tcurrentValue: config.transport,\n\t\t\t\tvalues: [\"sse\", \"websocket\", \"websocket-cached\", \"auto\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"http-idle-timeout\",\n\t\t\t\tlabel: t(\"HTTP idle timeout\"),\n\t\t\t\tdescription: t(\n\t\t\t\t\t\"Maximum idle gap while waiting for HTTP headers or body chunks. Disable for local models that pause longer than five minutes.\",\n\t\t\t\t),\n\t\t\t\tcurrentValue: formatHttpIdleTimeoutMs(config.httpIdleTimeoutMs),\n\t\t\t\tvalues: HTTP_IDLE_TIMEOUT_CHOICES.map((choice) => choice.label),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"hide-thinking\",\n\t\t\t\tlabel: t(\"Hide thinking\"),\n\t\t\t\tdescription: t(\"Hide thinking blocks in assistant responses\"),\n\t\t\t\tcurrentValue: config.hideThinkingBlock ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"mermaid-rendering\",\n\t\t\t\tlabel: t(\"Mermaid diagrams\"),\n\t\t\t\tdescription: t(\"Render Mermaid code blocks as Unicode diagrams\"),\n\t\t\t\tcurrentValue: config.mermaidRenderingMode,\n\t\t\t\tvalues: [\"off\", \"final\", \"streaming\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"cache-miss-notices\",\n\t\t\t\tlabel: t(\"Cache miss notices\"),\n\t\t\t\tdescription: t(\"Show transcript notices for cache costs and provider recovery diagnostics\"),\n\t\t\t\tcurrentValue: config.showCacheMissNotices ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"collapse-changelog\",\n\t\t\t\tlabel: t(\"Collapse changelog\"),\n\t\t\t\tdescription: t(\"Show condensed changelog after updates\"),\n\t\t\t\tcurrentValue: config.collapseChangelog ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"quiet-startup\",\n\t\t\t\tlabel: t(\"Quiet startup\"),\n\t\t\t\tdescription: t(\"Disable verbose printing at startup\"),\n\t\t\t\tcurrentValue: config.quietStartup ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"double-escape-action\",\n\t\t\t\tlabel: t(\"Double-escape action\"),\n\t\t\t\tdescription: t(\"Action when pressing Escape twice with empty editor\"),\n\t\t\t\tcurrentValue: config.doubleEscapeAction,\n\t\t\t\tvalues: [\"tree\", \"none\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"language\",\n\t\t\t\tlabel: t(\"Interface language\"),\n\t\t\t\tdescription: t(\"Language for UI text; takes effect immediately\"),\n\t\t\t\tcurrentValue: config.uiLanguage,\n\t\t\t\tvalues: [\"zh-CN\", \"en\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"tree-filter-mode\",\n\t\t\t\tlabel: t(\"Tree filter mode\"),\n\t\t\t\tdescription: t(\"Default filter when opening /tree\"),\n\t\t\t\tcurrentValue: config.treeFilterMode,\n\t\t\t\tvalues: [\"default\", \"no-tools\", \"user-only\", \"labeled-only\", \"all\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"warnings\",\n\t\t\t\tlabel: t(\"Warnings\"),\n\t\t\t\tdescription: t(\"Enable or disable individual warnings\"),\n\t\t\t\tcurrentValue: t(\"configure\"),\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew WarningSettingsSubmenu(\n\t\t\t\t\t\tcurrentWarnings,\n\t\t\t\t\t\t(warnings) => {\n\t\t\t\t\t\t\tcurrentWarnings = warnings;\n\t\t\t\t\t\t\tcallbacks.onWarningsChange(warnings);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => done(),\n\t\t\t\t\t),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"model-thinking\",\n\t\t\t\tlabel: t(\"Default thinking level per model\"),\n\t\t\t\tdescription: t(\"Override the default thinking level for specific models. {key} cycles in-session.\", {\n\t\t\t\t\tkey: cycleThinkingKey,\n\t\t\t\t}),\n\t\t\t\tcurrentValue: modelThinkingOverridesSummary(currentModelThinkingLevels),\n\t\t\t\tsubmenu: (_currentValue, done) => {\n\t\t\t\t\tconst steps: SteppedSubmenuStep[] = [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkey: \"model\",\n\t\t\t\t\t\t\ttitle: t(\"Per-Model Thinking Level\"),\n\t\t\t\t\t\t\tdescription: t(\"Select a model to configure\"),\n\t\t\t\t\t\t\toptions: () => {\n\t\t\t\t\t\t\t\tconst sorted = [...config.availableDefaultModels].sort((a, b) => {\n\t\t\t\t\t\t\t\t\tconst aKey = modelSettingKey(a);\n\t\t\t\t\t\t\t\t\tconst bKey = modelSettingKey(b);\n\t\t\t\t\t\t\t\t\tif (aKey === currentModelKey) return -1;\n\t\t\t\t\t\t\t\t\tif (bKey === currentModelKey) return 1;\n\t\t\t\t\t\t\t\t\tif (aKey === currentDefaultModelKey) return -1;\n\t\t\t\t\t\t\t\t\tif (bKey === currentDefaultModelKey) return 1;\n\t\t\t\t\t\t\t\t\treturn a.provider.localeCompare(b.provider);\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tconst items: SelectItem[] = sorted.map((model) => {\n\t\t\t\t\t\t\t\t\tconst key = modelSettingKey(model);\n\t\t\t\t\t\t\t\t\tconst override = currentModelThinkingLevels[key];\n\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\tvalue: key,\n\t\t\t\t\t\t\t\t\t\tlabel: modelItemLabel(model),\n\t\t\t\t\t\t\t\t\t\tdescription: override ?? undefined,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (items.length === 0) {\n\t\t\t\t\t\t\t\t\titems.push({\n\t\t\t\t\t\t\t\t\t\tvalue: \"__none__\",\n\t\t\t\t\t\t\t\t\t\tlabel: t(\"No models available\"),\n\t\t\t\t\t\t\t\t\t\tdescription: t(\"Log in to a provider or configure an API key first\"),\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn items;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpreselect: () => currentModelKey ?? currentDefaultModelKey,\n\t\t\t\t\t\t\tsearchable: true,\n\t\t\t\t\t\t\tlayout: MODEL_PICKER_LAYOUT,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkey: \"level\",\n\t\t\t\t\t\t\ttitle: (ctx) => {\n\t\t\t\t\t\t\t\tconst m = defaultModelByValue.get(ctx.model);\n\t\t\t\t\t\t\t\treturn t(\"Thinking Level for {model}\", { model: m ? modelDisplayLabel(m) : ctx.model });\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdescription: t(\"Select default thinking level for this model\"),\n\t\t\t\t\t\t\toptions: (ctx) => {\n\t\t\t\t\t\t\t\tconst model = defaultModelByValue.get(ctx.model);\n\t\t\t\t\t\t\t\tif (!model) return [];\n\t\t\t\t\t\t\t\tconst levels = (\n\t\t\t\t\t\t\t\t\tmodel.reasoning ? getSupportedThinkingLevels(model) : [\"off\"]\n\t\t\t\t\t\t\t\t) as ThinkingLevel[];\n\t\t\t\t\t\t\t\tconst items: SelectItem[] = levels.map((level) => ({\n\t\t\t\t\t\t\t\t\tvalue: level,\n\t\t\t\t\t\t\t\t\tlabel: level,\n\t\t\t\t\t\t\t\t\tdescription: thinkingDescription(level),\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\tif (currentModelThinkingLevels[ctx.model] !== undefined) {\n\t\t\t\t\t\t\t\t\titems.push({\n\t\t\t\t\t\t\t\t\t\tvalue: CLEAR_OVERRIDE_VALUE,\n\t\t\t\t\t\t\t\t\t\tlabel: t(\"(clear override)\"),\n\t\t\t\t\t\t\t\t\t\tdescription: t(\"Revert to global default ({level})\", { level: config.thinkingLevel }),\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn items;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpreselect: (ctx) => currentModelThinkingLevels[ctx.model],\n\t\t\t\t\t\t},\n\t\t\t\t\t];\n\n\t\t\t\t\tconst summary = () => modelThinkingOverridesSummary(currentModelThinkingLevels);\n\n\t\t\t\t\treturn new SteppedSubmenu(\n\t\t\t\t\t\tsteps,\n\t\t\t\t\t\t(selections) => {\n\t\t\t\t\t\t\tconst model = defaultModelByValue.get(selections.model);\n\t\t\t\t\t\t\t// v8 ignore next -- the no-models placeholder value never resolves to a model\n\t\t\t\t\t\t\tif (!model) return;\n\t\t\t\t\t\t\tif (selections.level === CLEAR_OVERRIDE_VALUE) {\n\t\t\t\t\t\t\t\tcallbacks.onModelThinkingLevelRemove(model.provider, model.id);\n\t\t\t\t\t\t\t\tdelete currentModelThinkingLevels[selections.model];\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcallbacks.onModelThinkingLevelChange(\n\t\t\t\t\t\t\t\t\tmodel.provider,\n\t\t\t\t\t\t\t\t\tmodel.id,\n\t\t\t\t\t\t\t\t\tselections.level as ThinkingLevel,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tcurrentModelThinkingLevels[selections.model] = selections.level as ThinkingLevel;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\tdone(summary());\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ loop: true },\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"tui-mode\",\n\t\t\t\tlabel: t(\"TUI mode\"),\n\t\t\t\tdescription: t(\"Interface layout; fullscreen mode is experimental\"),\n\t\t\t\tcurrentValue: config.tuiMode,\n\t\t\t\tvalues: [\"regular\", \"fullscreen\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"fullscreen-exit-output\",\n\t\t\t\tlabel: t(\"Fullscreen exit output\"),\n\t\t\t\tdescription: t(\"Print the transcript or only a session resume hint when exiting fullscreen mode\"),\n\t\t\t\tcurrentValue: config.fullscreenExitOutput,\n\t\t\t\tvalues: [\"transcript\", \"resume-hint\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"fullscreen-scrollbar\",\n\t\t\t\tlabel: t(\"Fullscreen scrollbar\"),\n\t\t\t\tdescription: t(\"Scrollbar behavior in fullscreen mode; has no effect in regular mode\"),\n\t\t\t\tcurrentValue: config.fullscreenScrollbar,\n\t\t\t\tvalues: [\"auto\", \"always\", \"hidden\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"fullscreen-copy-on-select\",\n\t\t\t\tlabel: t(\"Fullscreen copy on select\"),\n\t\t\t\tdescription: t(\n\t\t\t\t\t\"Automatically copy selected text in fullscreen mode; disable to copy selections with Ctrl+X\",\n\t\t\t\t),\n\t\t\t\tcurrentValue: config.fullscreenCopyOnSelect ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"fullscreen-wheel-scroll-lines\",\n\t\t\t\tlabel: t(\"Fullscreen wheel scroll lines\"),\n\t\t\t\tdescription: t(\"Lines scrolled per wheel event in fullscreen mode; auto accelerates with scroll speed\"),\n\t\t\t\tcurrentValue: String(config.fullscreenWheelScrollLines),\n\t\t\t\tvalues: [\"auto\", \"1\", \"2\", \"3\", \"5\", \"10\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"theme\",\n\t\t\t\tlabel: t(\"Theme\"),\n\t\t\t\tdescription: t(\"Color theme for the interface\"),\n\t\t\t\tcurrentValue: config.currentTheme,\n\t\t\t\tsubmenu: (currentValue, done) =>\n\t\t\t\t\tnew ThemeSubmenu(currentValue, config.terminalTheme, config.availableThemes, callbacks, done),\n\t\t\t},\n\t\t];\n\n\t\t// Only show image toggle if terminal supports it\n\t\tif (supportsImages) {\n\t\t\t// Insert at the top of the list\n\t\t\titems.splice(0, 0, {\n\t\t\t\tid: \"show-images\",\n\t\t\t\tlabel: t(\"Show images\"),\n\t\t\t\tdescription: t(\"Render images inline in terminal\"),\n\t\t\t\tcurrentValue: config.showImages ? \"true\" : \"false\",\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t});\n\t\t\titems.splice(1, 0, {\n\t\t\t\tid: \"image-width-cells\",\n\t\t\t\tlabel: t(\"Image width\"),\n\t\t\t\tdescription: t(\"Preferred inline image width in terminal cells\"),\n\t\t\t\tcurrentValue: String(config.imageWidthCells),\n\t\t\t\tvalues: [\"60\", \"80\", \"120\"],\n\t\t\t});\n\t\t}\n\n\t\t// Image auto-resize toggle (always available, affects both attached and read images)\n\t\titems.splice(supportsImages ? 2 : 0, 0, {\n\t\t\tid: \"auto-resize-images\",\n\t\t\tlabel: t(\"Auto-resize images\"),\n\t\t\tdescription: t(\"Resize large images to 2000x2000 max for better model compatibility\"),\n\t\t\tcurrentValue: config.autoResizeImages ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Block images toggle (always available, insert after auto-resize-images)\n\t\tconst autoResizeIndex = items.findIndex((item) => item.id === \"auto-resize-images\");\n\t\titems.splice(autoResizeIndex + 1, 0, {\n\t\t\tid: \"block-images\",\n\t\t\tlabel: t(\"Block images\"),\n\t\t\tdescription: t(\"Prevent images from being sent to LLM providers\"),\n\t\t\tcurrentValue: config.blockImages ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Hardware cursor toggle (insert after block-images)\n\t\tconst blockImagesIndex = items.findIndex((item) => item.id === \"block-images\");\n\t\titems.splice(blockImagesIndex + 1, 0, {\n\t\t\tid: \"show-hardware-cursor\",\n\t\t\tlabel: t(\"Show hardware cursor\"),\n\t\t\tdescription: t(\"Show the terminal cursor while still positioning it for IME support\"),\n\t\t\tcurrentValue: config.showHardwareCursor ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Editor padding toggle (insert after show-hardware-cursor)\n\t\tconst hardwareCursorIndex = items.findIndex((item) => item.id === \"show-hardware-cursor\");\n\t\titems.splice(hardwareCursorIndex + 1, 0, {\n\t\t\tid: \"editor-padding\",\n\t\t\tlabel: t(\"Editor padding\"),\n\t\t\tdescription: t(\"Horizontal padding for input editor (0-3)\"),\n\t\t\tcurrentValue: String(config.editorPaddingX),\n\t\t\tvalues: [\"0\", \"1\", \"2\", \"3\"],\n\t\t});\n\n\t\t// Output padding toggle (insert after editor-padding)\n\t\tconst editorPaddingIndex = items.findIndex((item) => item.id === \"editor-padding\");\n\t\titems.splice(editorPaddingIndex + 1, 0, {\n\t\t\tid: \"output-padding\",\n\t\t\tlabel: t(\"Output padding\"),\n\t\t\tdescription: t(\"Horizontal padding for user messages, assistant messages, and thinking\"),\n\t\t\tcurrentValue: String(config.outputPad),\n\t\t\tvalues: [\"0\", \"1\"],\n\t\t});\n\n\t\t// Autocomplete max visible toggle (insert after output-padding)\n\t\tconst outputPaddingIndex = items.findIndex((item) => item.id === \"output-padding\");\n\t\titems.splice(outputPaddingIndex + 1, 0, {\n\t\t\tid: \"autocomplete-max-visible\",\n\t\t\tlabel: t(\"Autocomplete max items\"),\n\t\t\tdescription: t(\"Max visible items in autocomplete dropdown (3-20)\"),\n\t\t\tcurrentValue: String(config.autocompleteMaxVisible),\n\t\t\tvalues: [\"3\", \"5\", \"7\", \"10\", \"15\", \"20\"],\n\t\t});\n\n\t\t// Clear on shrink toggle (insert after autocomplete-max-visible)\n\t\tconst autocompleteIndex = items.findIndex((item) => item.id === \"autocomplete-max-visible\");\n\t\titems.splice(autocompleteIndex + 1, 0, {\n\t\t\tid: \"clear-on-shrink\",\n\t\t\tlabel: t(\"Clear on shrink\"),\n\t\t\tdescription: t(\"Clear empty rows when content shrinks (may cause flicker)\"),\n\t\t\tcurrentValue: config.clearOnShrink ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Terminal progress toggle (insert after clear-on-shrink)\n\t\tconst clearOnShrinkIndex = items.findIndex((item) => item.id === \"clear-on-shrink\");\n\t\titems.splice(clearOnShrinkIndex + 1, 0, {\n\t\t\tid: \"terminal-progress\",\n\t\t\tlabel: t(\"Terminal progress\"),\n\t\t\tdescription: t(\"Show OSC 9;4 progress indicators in the terminal tab bar\"),\n\t\t\tcurrentValue: config.showTerminalProgress ? \"true\" : \"false\",\n\t\t\tvalues: [\"true\", \"false\"],\n\t\t});\n\n\t\t// Add borders\n\t\tthis.addChild(new DynamicBorder());\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\t10,\n\t\t\tgetSettingsListTheme(),\n\t\t\t(id, newValue) => {\n\t\t\t\tswitch (id) {\n\t\t\t\t\tcase \"show-images\":\n\t\t\t\t\t\tcallbacks.onShowImagesChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"image-width-cells\":\n\t\t\t\t\t\tcallbacks.onImageWidthCellsChange(parseInt(newValue, 10));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"auto-resize-images\":\n\t\t\t\t\t\tcallbacks.onAutoResizeImagesChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"block-images\":\n\t\t\t\t\t\tcallbacks.onBlockImagesChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"steering-mode\":\n\t\t\t\t\t\tcallbacks.onSteeringModeChange(newValue as \"all\" | \"one-at-a-time\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"follow-up-mode\":\n\t\t\t\t\t\tcallbacks.onFollowUpModeChange(newValue as \"all\" | \"one-at-a-time\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"transport\":\n\t\t\t\t\t\tcallbacks.onTransportChange(newValue as Transport);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"http-idle-timeout\": {\n\t\t\t\t\t\tconst choice = HTTP_IDLE_TIMEOUT_CHOICES.find((item) => item.label === newValue);\n\t\t\t\t\t\t// v8 ignore next -- the timeout choice lookup always matches a rendered value\n\t\t\t\t\t\tif (choice) {\n\t\t\t\t\t\t\tcallbacks.onHttpIdleTimeoutMsChange(choice.timeoutMs);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"hide-thinking\":\n\t\t\t\t\t\tcallbacks.onHideThinkingBlockChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"mermaid-rendering\":\n\t\t\t\t\t\tcallbacks.onMermaidRenderingModeChange(newValue as MermaidRenderingMode);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"cache-miss-notices\":\n\t\t\t\t\t\tcallbacks.onShowCacheMissNoticesChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"collapse-changelog\":\n\t\t\t\t\t\tcallbacks.onCollapseChangelogChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"quiet-startup\":\n\t\t\t\t\t\tcallbacks.onQuietStartupChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"double-escape-action\":\n\t\t\t\t\t\tcallbacks.onDoubleEscapeActionChange(newValue as \"tree\" | \"none\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"language\":\n\t\t\t\t\t\tcallbacks.onUiLanguageChange(newValue as \"zh-CN\" | \"en\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"tree-filter-mode\":\n\t\t\t\t\t\tcallbacks.onTreeFilterModeChange(\n\t\t\t\t\t\t\tnewValue as \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"show-hardware-cursor\":\n\t\t\t\t\t\tcallbacks.onShowHardwareCursorChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"editor-padding\":\n\t\t\t\t\t\tcallbacks.onEditorPaddingXChange(parseInt(newValue, 10));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"output-padding\":\n\t\t\t\t\t\tcallbacks.onOutputPadChange(newValue === \"0\" ? 0 : 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"autocomplete-max-visible\":\n\t\t\t\t\t\tcallbacks.onAutocompleteMaxVisibleChange(parseInt(newValue, 10));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"clear-on-shrink\":\n\t\t\t\t\t\tcallbacks.onClearOnShrinkChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"terminal-progress\":\n\t\t\t\t\t\tcallbacks.onShowTerminalProgressChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"tui-mode\":\n\t\t\t\t\t\tcallbacks.onTuiModeChange(newValue as TuiMode);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"fullscreen-exit-output\":\n\t\t\t\t\t\tcallbacks.onFullscreenExitOutputChange(newValue as FullscreenExitOutput);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"fullscreen-scrollbar\":\n\t\t\t\t\t\tcallbacks.onFullscreenScrollbarChange(newValue as ScrollViewScrollbar);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"fullscreen-copy-on-select\":\n\t\t\t\t\t\tcallbacks.onFullscreenCopyOnSelectChange(newValue === \"true\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"fullscreen-wheel-scroll-lines\":\n\t\t\t\t\t\tcallbacks.onFullscreenWheelScrollLinesChange(\n\t\t\t\t\t\t\tnewValue === \"auto\" ? \"auto\" : (Number(newValue) as WheelScrollLines),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"theme\":\n\t\t\t\t\t\tcallbacks.onThemeChange(newValue);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t},\n\t\t\tcallbacks.onCancel,\n\t\t\t{ enableSearch: true },\n\t\t);\n\n\t\tthis.addChild(this.settingsList);\n\t\tthis.addChild(new DynamicBorder());\n\t}\n\n\tgetSettingsList(): SettingsList {\n\t\treturn this.settingsList;\n\t}\n}\n"]}
|