@kolisachint/hoocode-agent 0.4.149 → 0.4.151
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 +29 -0
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +22 -5
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +6 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/context-gc.d.ts +5 -0
- package/dist/core/context-gc.d.ts.map +1 -1
- package/dist/core/context-gc.js +19 -18
- package/dist/core/context-gc.js.map +1 -1
- package/dist/core/settings-defaults.d.ts +2 -0
- package/dist/core/settings-defaults.d.ts.map +1 -1
- package/dist/core/settings-defaults.js +3 -1
- package/dist/core/settings-defaults.js.map +1 -1
- package/dist/core/settings-manager.d.ts +13 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +62 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-types.d.ts +3 -0
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/tools/read-dedup.d.ts +78 -0
- package/dist/core/tools/read-dedup.d.ts.map +1 -0
- package/dist/core/tools/read-dedup.js +219 -0
- package/dist/core/tools/read-dedup.js.map +1 -0
- package/dist/core/tools/read.d.ts +7 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +18 -2
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/truncate.d.ts +3 -3
- package/dist/core/tools/truncate.d.ts.map +1 -1
- package/dist/core/tools/truncate.js +2 -2
- package/dist/core/tools/truncate.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +8 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +46 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +304 -3
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +13 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +24 -4
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +125 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package.json +1 -1
- package/package.json +4 -4
|
@@ -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,iCAAiC,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EACN,SAAS,EAMT,YAAY,EAGZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAmBzE,MAAM,WAAW,cAAc;IAC9B,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,EAAE,OAAO,CAAC;IACrB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,YAAY,EAAE,KAAK,GAAG,eAAe,CAAC;IACtC,YAAY,EAAE,KAAK,GAAG,eAAe,CAAC;IACtC,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,EAAE,aAAa,C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isachint/hoocode-agent-core\";\nimport type { Transport } from \"@kolisachint/hoocode-ai\";\nimport {\n\tContainer,\n\tgetCapabilities,\n\ttype SelectItem,\n\tSelectList,\n\ttype SelectListLayoutOptions,\n\ttype SettingItem,\n\tSettingsList,\n\tSpacer,\n\tText,\n} from \"@kolisachint/hoocode-tui\";\nimport type { WarningSettings } from \"../../../core/settings-manager.js\";\nimport { getSelectListTheme, getSettingsListTheme, theme } from \"../theme/theme.js\";\nimport { DynamicBorder } from \"./dynamic-border.js\";\nimport { keyDisplayText } from \"./keybinding-hints.js\";\n\nconst SETTINGS_SUBMENU_SELECT_LIST_LAYOUT: SelectListLayoutOptions = {\n\tminPrimaryColumnWidth: 12,\n\tmaxPrimaryColumnWidth: 32,\n};\n\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: \"Maximum reasoning (~32k tokens)\",\n};\n\nexport interface SettingsConfig {\n\tautoCompact: boolean;\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\tthinkingLevel: ThinkingLevel;\n\tavailableThinkingLevels: ThinkingLevel[];\n\tcurrentTheme: string;\n\tavailableThemes: string[];\n\thideThinkingBlock: boolean;\n\tcollapseChangelog: boolean;\n\tenableInstallTelemetry: boolean;\n\tdoubleEscapeAction: \"fork\" | \"tree\" | \"none\";\n\ttreeFilterMode: \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\";\n\tshowHardwareCursor: boolean;\n\teditorPaddingX: number;\n\tautocompleteMaxVisible: number;\n\tquietStartup: boolean;\n\tclearOnShrink: boolean;\n\tshowTerminalProgress: boolean;\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\tonThinkingLevelChange: (level: ThinkingLevel) => void;\n\tonThemeChange: (theme: string) => void;\n\tonThemePreview?: (theme: string) => void;\n\tonHideThinkingBlockChange: (hidden: boolean) => void;\n\tonCollapseChangelogChange: (collapsed: boolean) => void;\n\tonEnableInstallTelemetryChange: (enabled: boolean) => void;\n\tonDoubleEscapeActionChange: (action: \"fork\" | \"tree\" | \"none\") => void;\n\tonTreeFilterModeChange: (mode: \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\") => void;\n\tonShowHardwareCursorChange: (enabled: boolean) => void;\n\tonEditorPaddingXChange: (padding: number) => void;\n\tonAutocompleteMaxVisibleChange: (maxVisible: number) => void;\n\tonQuietStartupChange: (enabled: boolean) => void;\n\tonClearOnShrinkChange: (enabled: boolean) => void;\n\tonShowTerminalProgressChange: (enabled: boolean) => 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: \"Anthropic extra usage\",\n\t\t\t\tdescription: \"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\nclass SelectSubmenu extends Container {\n\tprivate selectList: SelectList;\n\n\tconstructor(\n\t\ttitle: string,\n\t\tdescription: string,\n\t\toptions: SelectItem[],\n\t\tcurrentValue: string,\n\t\tonSelect: (value: string) => void,\n\t\tonCancel: () => void,\n\t\tonSelectionChange?: (value: string) => void,\n\t) {\n\t\tsuper();\n\n\t\t// Title\n\t\tthis.addChild(new Text(theme.bold(theme.fg(\"accent\", title)), 0, 0));\n\n\t\t// Description\n\t\tif (description) {\n\t\t\tthis.addChild(new Spacer(1));\n\t\t\tthis.addChild(new Text(theme.fg(\"muted\", description), 0, 0));\n\t\t}\n\n\t\t// Spacer\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Select list\n\t\tthis.selectList = new SelectList(\n\t\t\toptions,\n\t\t\tMath.min(options.length, 10),\n\t\t\tgetSelectListTheme(),\n\t\t\tSETTINGS_SUBMENU_SELECT_LIST_LAYOUT,\n\t\t);\n\n\t\t// Pre-select current value\n\t\tconst currentIndex = options.findIndex((o) => o.value === currentValue);\n\t\tif (currentIndex !== -1) {\n\t\t\tthis.selectList.setSelectedIndex(currentIndex);\n\t\t}\n\n\t\tthis.selectList.onSelect = (item) => {\n\t\t\tonSelect(item.value);\n\t\t};\n\n\t\tthis.selectList.onCancel = onCancel;\n\n\t\tif (onSelectionChange) {\n\t\t\tthis.selectList.onSelectionChange = (item) => {\n\t\t\t\tonSelectionChange(item.value);\n\t\t\t};\n\t\t}\n\n\t\tthis.addChild(this.selectList);\n\n\t\t// Hint\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(new Text(theme.fg(\"dim\", \" Enter to select · Esc to go back\"), 0, 0));\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.selectList.handleInput(data);\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\");\n\t\tlet currentWarnings = { ...config.warnings };\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"autocompact\",\n\t\t\t\tlabel: \"Auto-compact\",\n\t\t\t\tdescription: \"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: \"Steering mode\",\n\t\t\t\tdescription:\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\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: \"Follow-up mode\",\n\t\t\t\tdescription: `${followUpKey} 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\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: \"Transport\",\n\t\t\t\tdescription: \"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: \"hide-thinking\",\n\t\t\t\tlabel: \"Hide thinking\",\n\t\t\t\tdescription: \"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: \"collapse-changelog\",\n\t\t\t\tlabel: \"Collapse changelog\",\n\t\t\t\tdescription: \"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: \"Quiet startup\",\n\t\t\t\tdescription: \"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: \"install-telemetry\",\n\t\t\t\tlabel: \"Install telemetry\",\n\t\t\t\tdescription: \"Send an anonymous version/update ping after changelog-detected updates\",\n\t\t\t\tcurrentValue: config.enableInstallTelemetry ? \"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: \"Double-escape action\",\n\t\t\t\tdescription: \"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: \"tree-filter-mode\",\n\t\t\t\tlabel: \"Tree filter mode\",\n\t\t\t\tdescription: \"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: \"Warnings\",\n\t\t\t\tdescription: \"Enable or disable individual warnings\",\n\t\t\t\tcurrentValue: \"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: \"thinking\",\n\t\t\t\tlabel: \"Thinking level\",\n\t\t\t\tdescription: \"Reasoning depth for thinking-capable models\",\n\t\t\t\tcurrentValue: config.thinkingLevel,\n\t\t\t\tsubmenu: (currentValue, done) =>\n\t\t\t\t\tnew SelectSubmenu(\n\t\t\t\t\t\t\"Thinking Level\",\n\t\t\t\t\t\t\"Select reasoning depth for thinking-capable models\",\n\t\t\t\t\t\tconfig.availableThinkingLevels.map((level) => ({\n\t\t\t\t\t\t\tvalue: level,\n\t\t\t\t\t\t\tlabel: level,\n\t\t\t\t\t\t\tdescription: THINKING_DESCRIPTIONS[level],\n\t\t\t\t\t\t})),\n\t\t\t\t\t\tcurrentValue,\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\tcallbacks.onThinkingLevelChange(value as ThinkingLevel);\n\t\t\t\t\t\t\tdone(value);\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: \"theme\",\n\t\t\t\tlabel: \"Theme\",\n\t\t\t\tdescription: \"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 SelectSubmenu(\n\t\t\t\t\t\t\"Theme\",\n\t\t\t\t\t\t\"Select color theme\",\n\t\t\t\t\t\tconfig.availableThemes.map((t) => ({\n\t\t\t\t\t\t\tvalue: t,\n\t\t\t\t\t\t\tlabel: t,\n\t\t\t\t\t\t})),\n\t\t\t\t\t\tcurrentValue,\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\tcallbacks.onThemeChange(value);\n\t\t\t\t\t\t\tdone(value);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t// Restore original theme on cancel\n\t\t\t\t\t\t\tcallbacks.onThemePreview?.(currentValue);\n\t\t\t\t\t\t\tdone();\n\t\t\t\t\t\t},\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\t// Preview theme on selection change\n\t\t\t\t\t\t\tcallbacks.onThemePreview?.(value);\n\t\t\t\t\t\t},\n\t\t\t\t\t),\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: \"Show images\",\n\t\t\t\tdescription: \"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: \"Image width\",\n\t\t\t\tdescription: \"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: \"Auto-resize images\",\n\t\t\tdescription: \"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: \"Block images\",\n\t\t\tdescription: \"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: \"Skill commands\",\n\t\t\tdescription: \"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: \"Show hardware cursor\",\n\t\t\tdescription: \"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: \"Editor padding\",\n\t\t\tdescription: \"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// Autocomplete max visible 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: \"autocomplete-max-visible\",\n\t\t\tlabel: \"Autocomplete max items\",\n\t\t\tdescription: \"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: \"Clear on shrink\",\n\t\t\tdescription: \"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: \"Terminal progress\",\n\t\t\tdescription: \"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 \"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 \"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 \"install-telemetry\":\n\t\t\t\t\t\tcallbacks.onEnableInstallTelemetryChange(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 \"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 \"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}\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,OA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,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACvD,sBAAsB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,8BAA8B,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7D,oBAAoB,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,gBAAgB,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,CAAC;IACtD,QAAQ,EAAE,MAAM,IAAI,CAAC;CACrB;AA8ID,MAAM,WAAW,kBAAkB;IAClC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB;IACrC,0BAA0B,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,0BAA0B,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,iBAAiB,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9C;AAkPD;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,SAAS;IACvD,OAAO,CAAC,YAAY,CAAe;IAEnC,YAAY,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,iBAAiB,EAmc/D;IAED,eAAe,IAAI,YAAY,CAE9B;CACD","sourcesContent":["import type { ThinkingLevel } from \"@kolisachint/hoocode-agent-core\";\nimport type { Transport } from \"@kolisachint/hoocode-ai\";\nimport {\n\tContainer,\n\tgetCapabilities,\n\tInput,\n\ttype SelectItem,\n\tSelectList,\n\ttype SelectListLayoutOptions,\n\ttype SettingItem,\n\tSettingsList,\n\tSpacer,\n\tText,\n} from \"@kolisachint/hoocode-tui\";\nimport type { WarningSettings } from \"../../../core/settings-manager.js\";\nimport { getSelectListTheme, getSettingsListTheme, theme } from \"../theme/theme.js\";\nimport { DynamicBorder } from \"./dynamic-border.js\";\nimport { keyDisplayText } from \"./keybinding-hints.js\";\n\nconst SETTINGS_SUBMENU_SELECT_LIST_LAYOUT: SelectListLayoutOptions = {\n\tminPrimaryColumnWidth: 12,\n\tmaxPrimaryColumnWidth: 32,\n};\n\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: \"Maximum reasoning (~32k tokens)\",\n};\n\nexport interface ToolToggleInfo {\n\t/** Tool name (e.g. \"read\", \"bash\"). */\n\tname: string;\n\t/** Whether the tool is currently enabled (not in the persisted disabled set). */\n\tenabled: boolean;\n}\n\nexport interface FlagInfo {\n\t/** Flag name (without the leading --). */\n\tname: string;\n\tdescription?: string;\n\ttype: \"boolean\" | \"string\";\n\t/** Current effective value. */\n\tvalue: boolean | string;\n}\n\nexport interface ToolGroupInfo {\n\t/** Group identifier (e.g. \"web\", \"browser\", \"file\", \"embsearch\"). */\n\tid: string;\n\tlabel: string;\n\tdescription: string;\n\t/** Whether the group is currently enabled (its tools are available). */\n\tenabled: boolean;\n}\n\nexport interface SettingsConfig {\n\tautoCompact: boolean;\n\ttools: ToolToggleInfo[];\n\ttoolGroups: ToolGroupInfo[];\n\tflags: FlagInfo[];\n\ttoolOutputDisplay: \"collapsed\" | \"peek\" | \"standard\";\n\ttoolOutputMaxBytes: number;\n\ttoolOutputMaxLines: number;\n\tcontextGc: boolean;\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\tthinkingLevel: ThinkingLevel;\n\tavailableThinkingLevels: ThinkingLevel[];\n\tcurrentTheme: string;\n\tavailableThemes: string[];\n\thideThinkingBlock: boolean;\n\tcollapseChangelog: boolean;\n\tenableInstallTelemetry: boolean;\n\tdoubleEscapeAction: \"fork\" | \"tree\" | \"none\";\n\ttreeFilterMode: \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\";\n\tshowHardwareCursor: boolean;\n\teditorPaddingX: number;\n\tautocompleteMaxVisible: number;\n\tquietStartup: boolean;\n\tclearOnShrink: boolean;\n\tshowTerminalProgress: boolean;\n\twarnings: WarningSettings;\n}\n\nexport interface SettingsCallbacks {\n\tonAutoCompactChange: (enabled: boolean) => void;\n\tonToolEnabledChange: (name: string, enabled: boolean) => void;\n\tonToolGroupChange: (id: string, enabled: boolean) => void;\n\tonToolOutputDisplayChange: (level: \"collapsed\" | \"peek\" | \"standard\") => void;\n\tonToolOutputMaxBytesChange: (bytes: number) => void;\n\tonToolOutputMaxLinesChange: (lines: number) => void;\n\tonContextGcChange: (enabled: boolean) => void;\n\tonFlagChange: (name: string, value: boolean | string) => 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\tonThinkingLevelChange: (level: ThinkingLevel) => void;\n\tonThemeChange: (theme: string) => void;\n\tonThemePreview?: (theme: string) => void;\n\tonHideThinkingBlockChange: (hidden: boolean) => void;\n\tonCollapseChangelogChange: (collapsed: boolean) => void;\n\tonEnableInstallTelemetryChange: (enabled: boolean) => void;\n\tonDoubleEscapeActionChange: (action: \"fork\" | \"tree\" | \"none\") => void;\n\tonTreeFilterModeChange: (mode: \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\") => void;\n\tonShowHardwareCursorChange: (enabled: boolean) => void;\n\tonEditorPaddingXChange: (padding: number) => void;\n\tonAutocompleteMaxVisibleChange: (maxVisible: number) => void;\n\tonQuietStartupChange: (enabled: boolean) => void;\n\tonClearOnShrinkChange: (enabled: boolean) => void;\n\tonShowTerminalProgressChange: (enabled: boolean) => 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: \"Anthropic extra usage\",\n\t\t\t\tdescription: \"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\n/**\n * Submenu for tool availability. The first rows are group switches (web,\n * browser, document, semantic search) that decide whether a group's tools\n * exist at all — this is the same master switch that governs, e.g., the\n * webfetch/websearch tools. Below them are per-tool on/off toggles for the\n * tools that are currently available.\n *\n * Group switches change tool availability and apply on the next session;\n * per-tool toggles apply live and persist. A minimum core (read/bash/edit/\n * write) is guarded so the agent can never be left with no way to act.\n */\nclass ToolsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\tprivate enabled: Map<string, boolean>;\n\tprivate static readonly CORE = new Set([\"read\", \"bash\", \"edit\", \"write\"]);\n\tprivate static readonly GROUP_PREFIX = \"group:\";\n\n\tconstructor(\n\t\ttools: ToolToggleInfo[],\n\t\tgroups: ToolGroupInfo[],\n\t\tonChange: (name: string, enabled: boolean) => void,\n\t\tonGroupChange: (id: string, enabled: boolean) => void,\n\t\tonCancel: () => void,\n\t) {\n\t\tsuper();\n\n\t\tthis.enabled = new Map(tools.map((t) => [t.name, t.enabled]));\n\n\t\tconst groupItems: SettingItem[] = groups.map((group) => ({\n\t\t\tid: `${ToolsSubmenu.GROUP_PREFIX}${group.id}`,\n\t\t\tlabel: `[group] ${group.label}`,\n\t\t\tdescription: `${group.description} Governs whether these tools exist; applies on the next session.`,\n\t\t\tcurrentValue: group.enabled ? \"on\" : \"off\",\n\t\t\tvalues: [\"on\", \"off\"],\n\t\t}));\n\n\t\tconst toolItems: SettingItem[] = tools.map((tool) => ({\n\t\t\tid: tool.name,\n\t\t\tlabel: tool.name,\n\t\t\tdescription: ToolsSubmenu.CORE.has(tool.name)\n\t\t\t\t? \"Core tool. Disabling leaves the agent unable to perform this action in every session.\"\n\t\t\t\t: \"Disable to remove this tool from the agent this session and every future session.\",\n\t\t\tcurrentValue: tool.enabled ? \"on\" : \"off\",\n\t\t\tvalues: [\"on\", \"off\"],\n\t\t}));\n\n\t\tconst items = [...groupItems, ...toolItems];\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 12),\n\t\t\tgetSettingsListTheme(),\n\t\t\t(id, newValue) => {\n\t\t\t\tconst wantEnabled = newValue === \"on\";\n\t\t\t\tif (id.startsWith(ToolsSubmenu.GROUP_PREFIX)) {\n\t\t\t\t\tonGroupChange(id.slice(ToolsSubmenu.GROUP_PREFIX.length), wantEnabled);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Guard: never let the last core tool be turned off.\n\t\t\t\tif (!wantEnabled && ToolsSubmenu.CORE.has(id)) {\n\t\t\t\t\tconst remainingCore = [...ToolsSubmenu.CORE].filter((n) => n !== id && this.enabled.get(n));\n\t\t\t\t\tif (remainingCore.length === 0) {\n\t\t\t\t\t\tthis.settingsList.updateValue(id, \"on\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.enabled.set(id, wantEnabled);\n\t\t\t\tonChange(id, wantEnabled);\n\t\t\t},\n\t\t\tonCancel,\n\t\t\t{ enableSearch: true },\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\n/** Byte-cap presets shown as human labels; mapped back to raw byte counts. */\nconst TOOL_OUTPUT_BYTE_PRESETS: ReadonlyArray<[label: string, bytes: number]> = [\n\t[\"8 KB\", 8 * 1024],\n\t[\"16 KB\", 16 * 1024],\n\t[\"32 KB\", 32 * 1024],\n\t[\"64 KB\", 64 * 1024],\n\t[\"128 KB\", 128 * 1024],\n];\n\nfunction bytesToLabel(bytes: number): string {\n\tconst match = TOOL_OUTPUT_BYTE_PRESETS.find(([, b]) => b === bytes);\n\treturn match ? match[0] : `${Math.round(bytes / 1024)} KB`;\n}\n\nexport interface ToolSettingsConfig {\n\ttoolOutputMaxBytes: number;\n\ttoolOutputMaxLines: number;\n\tcontextGc: boolean;\n}\n\nexport interface ToolSettingsCallbacks {\n\tonToolOutputMaxBytesChange: (bytes: number) => void;\n\tonToolOutputMaxLinesChange: (lines: number) => void;\n\tonContextGcChange: (enabled: boolean) => void;\n}\n\n/**\n * Submenu for per-tool runtime settings. These feed the tool runtime the next\n * time it is built (next session / rebuild), so changes apply to future tool\n * calls rather than retroactively.\n */\nclass ToolSettingsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\n\tconstructor(config: ToolSettingsConfig, callbacks: ToolSettingsCallbacks, onCancel: () => void) {\n\t\tsuper();\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"output-max-bytes\",\n\t\t\t\tlabel: \"Output max bytes\",\n\t\t\t\tdescription: \"Byte cap on a single read/bash result before truncation. Applies to future tool calls.\",\n\t\t\t\tcurrentValue: bytesToLabel(config.toolOutputMaxBytes),\n\t\t\t\tvalues: TOOL_OUTPUT_BYTE_PRESETS.map(([label]) => label),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"output-max-lines\",\n\t\t\t\tlabel: \"Output max lines\",\n\t\t\t\tdescription: \"Line cap on a single read/bash result before truncation. Applies to future tool calls.\",\n\t\t\t\tcurrentValue: String(config.toolOutputMaxLines),\n\t\t\t\tvalues: [\"200\", \"400\", \"800\", \"1600\", \"3200\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"context-gc\",\n\t\t\t\tlabel: \"Context GC\",\n\t\t\t\tdescription: \"Stub superseded read results (files later edited/re-read) out of the outgoing context.\",\n\t\t\t\tcurrentValue: config.contextGc ? \"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 \"output-max-bytes\": {\n\t\t\t\t\t\tconst preset = TOOL_OUTPUT_BYTE_PRESETS.find(([label]) => label === newValue);\n\t\t\t\t\t\tif (preset) callbacks.onToolOutputMaxBytesChange(preset[1]);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"output-max-lines\":\n\t\t\t\t\t\tcallbacks.onToolOutputMaxLinesChange(parseInt(newValue, 10));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"context-gc\":\n\t\t\t\t\t\tcallbacks.onContextGcChange(newValue === \"true\");\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\n/** Single-line text editor for a string flag value. */\nclass FlagStringEditSubmenu extends Container {\n\tprivate input: Input;\n\n\tconstructor(flagName: string, currentValue: string, done: (value?: string) => void) {\n\t\tsuper();\n\n\t\tthis.addChild(new Text(theme.bold(theme.fg(\"accent\", `Flag: --${flagName}`)), 0, 0));\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(new Text(theme.fg(\"muted\", \"Enter a value · Enter to save · Esc to cancel\"), 0, 0));\n\t\tthis.addChild(new Spacer(1));\n\n\t\tthis.input = new Input();\n\t\tthis.input.setValue(currentValue);\n\t\tthis.input.onSubmit = (value: string) => done(value);\n\t\tthis.input.onEscape = () => done();\n\t\tthis.addChild(this.input);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.input.handleInput(data);\n\t}\n}\n\n/**\n * Submenu listing extension-registered flags. Boolean flags toggle on/off;\n * string flags open a text editor. Changes persist to settings.json and are\n * applied live best-effort — extensions that read a flag only at load time\n * pick up the new value on the next launch.\n */\nclass FlagsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\n\tconstructor(flags: FlagInfo[], onChange: (name: string, value: boolean | string) => void, onCancel: () => void) {\n\t\tsuper();\n\n\t\tconst items: SettingItem[] = flags.map((flag) => {\n\t\t\tconst baseDescription = flag.description ?? \"Extension-registered flag.\";\n\t\t\tconst description = `${baseDescription} Persists across sessions; some flags need a restart to fully apply.`;\n\t\t\tif (flag.type === \"boolean\") {\n\t\t\t\treturn {\n\t\t\t\t\tid: flag.name,\n\t\t\t\t\tlabel: flag.name,\n\t\t\t\t\tdescription,\n\t\t\t\t\tcurrentValue: flag.value ? \"on\" : \"off\",\n\t\t\t\t\tvalues: [\"on\", \"off\"],\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tid: flag.name,\n\t\t\t\tlabel: flag.name,\n\t\t\t\tdescription,\n\t\t\t\tcurrentValue: String(flag.value ?? \"\"),\n\t\t\t\tsubmenu: (currentValue, done) => new FlagStringEditSubmenu(flag.name, currentValue, done),\n\t\t\t};\n\t\t});\n\n\t\tconst typeByName = new Map(flags.map((f) => [f.name, f.type]));\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\titems,\n\t\t\tMath.min(items.length, 12),\n\t\t\tgetSettingsListTheme(),\n\t\t\t(id, newValue) => {\n\t\t\t\tif (typeByName.get(id) === \"boolean\") {\n\t\t\t\t\tonChange(id, newValue === \"on\");\n\t\t\t\t} else {\n\t\t\t\t\tonChange(id, newValue);\n\t\t\t\t}\n\t\t\t},\n\t\t\tonCancel,\n\t\t\t{ enableSearch: true },\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\n/**\n * Generic submenu holding a subset of leaf settings under a category label.\n * Shares the parent's change handler so cycle rows behave exactly as they did\n * when flat; nested submenu rows (theme, thinking, warnings) keep their own\n * factories.\n */\nclass CategorySubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\n\tconstructor(items: SettingItem[], onChange: (id: string, newValue: string) => void, onCancel: () => void) {\n\t\tsuper();\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\tonChange,\n\t\t\tonCancel,\n\t\t\t{\n\t\t\t\tenableSearch: true,\n\t\t\t},\n\t\t);\n\t\tthis.addChild(this.settingsList);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.settingsList.handleInput(data);\n\t}\n}\n\nclass SelectSubmenu extends Container {\n\tprivate selectList: SelectList;\n\n\tconstructor(\n\t\ttitle: string,\n\t\tdescription: string,\n\t\toptions: SelectItem[],\n\t\tcurrentValue: string,\n\t\tonSelect: (value: string) => void,\n\t\tonCancel: () => void,\n\t\tonSelectionChange?: (value: string) => void,\n\t) {\n\t\tsuper();\n\n\t\t// Title\n\t\tthis.addChild(new Text(theme.bold(theme.fg(\"accent\", title)), 0, 0));\n\n\t\t// Description\n\t\tif (description) {\n\t\t\tthis.addChild(new Spacer(1));\n\t\t\tthis.addChild(new Text(theme.fg(\"muted\", description), 0, 0));\n\t\t}\n\n\t\t// Spacer\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Select list\n\t\tthis.selectList = new SelectList(\n\t\t\toptions,\n\t\t\tMath.min(options.length, 10),\n\t\t\tgetSelectListTheme(),\n\t\t\tSETTINGS_SUBMENU_SELECT_LIST_LAYOUT,\n\t\t);\n\n\t\t// Pre-select current value\n\t\tconst currentIndex = options.findIndex((o) => o.value === currentValue);\n\t\tif (currentIndex !== -1) {\n\t\t\tthis.selectList.setSelectedIndex(currentIndex);\n\t\t}\n\n\t\tthis.selectList.onSelect = (item) => {\n\t\t\tonSelect(item.value);\n\t\t};\n\n\t\tthis.selectList.onCancel = onCancel;\n\n\t\tif (onSelectionChange) {\n\t\t\tthis.selectList.onSelectionChange = (item) => {\n\t\t\t\tonSelectionChange(item.value);\n\t\t\t};\n\t\t}\n\n\t\tthis.addChild(this.selectList);\n\n\t\t// Hint\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(new Text(theme.fg(\"dim\", \" Enter to select · Esc to go back\"), 0, 0));\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.selectList.handleInput(data);\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\");\n\t\tlet currentWarnings = { ...config.warnings };\n\n\t\tconst toolsOn = config.tools.filter((t) => t.enabled).length;\n\t\tconst toolsOff = config.tools.length - toolsOn;\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"autocompact\",\n\t\t\t\tlabel: \"Auto-compact\",\n\t\t\t\tdescription: \"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: \"Steering mode\",\n\t\t\t\tdescription:\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\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: \"Follow-up mode\",\n\t\t\t\tdescription: `${followUpKey} 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\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: \"Transport\",\n\t\t\t\tdescription: \"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: \"hide-thinking\",\n\t\t\t\tlabel: \"Hide thinking\",\n\t\t\t\tdescription: \"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: \"collapse-changelog\",\n\t\t\t\tlabel: \"Collapse changelog\",\n\t\t\t\tdescription: \"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: \"Quiet startup\",\n\t\t\t\tdescription: \"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: \"install-telemetry\",\n\t\t\t\tlabel: \"Install telemetry\",\n\t\t\t\tdescription: \"Send an anonymous version/update ping after changelog-detected updates\",\n\t\t\t\tcurrentValue: config.enableInstallTelemetry ? \"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: \"Double-escape action\",\n\t\t\t\tdescription: \"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: \"tree-filter-mode\",\n\t\t\t\tlabel: \"Tree filter mode\",\n\t\t\t\tdescription: \"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: \"Warnings\",\n\t\t\t\tdescription: \"Enable or disable individual warnings\",\n\t\t\t\tcurrentValue: \"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: \"thinking\",\n\t\t\t\tlabel: \"Thinking level\",\n\t\t\t\tdescription: \"Reasoning depth for thinking-capable models\",\n\t\t\t\tcurrentValue: config.thinkingLevel,\n\t\t\t\tsubmenu: (currentValue, done) =>\n\t\t\t\t\tnew SelectSubmenu(\n\t\t\t\t\t\t\"Thinking Level\",\n\t\t\t\t\t\t\"Select reasoning depth for thinking-capable models\",\n\t\t\t\t\t\tconfig.availableThinkingLevels.map((level) => ({\n\t\t\t\t\t\t\tvalue: level,\n\t\t\t\t\t\t\tlabel: level,\n\t\t\t\t\t\t\tdescription: THINKING_DESCRIPTIONS[level],\n\t\t\t\t\t\t})),\n\t\t\t\t\t\tcurrentValue,\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\tcallbacks.onThinkingLevelChange(value as ThinkingLevel);\n\t\t\t\t\t\t\tdone(value);\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: \"theme\",\n\t\t\t\tlabel: \"Theme\",\n\t\t\t\tdescription: \"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 SelectSubmenu(\n\t\t\t\t\t\t\"Theme\",\n\t\t\t\t\t\t\"Select color theme\",\n\t\t\t\t\t\tconfig.availableThemes.map((t) => ({\n\t\t\t\t\t\t\tvalue: t,\n\t\t\t\t\t\t\tlabel: t,\n\t\t\t\t\t\t})),\n\t\t\t\t\t\tcurrentValue,\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\tcallbacks.onThemeChange(value);\n\t\t\t\t\t\t\tdone(value);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t// Restore original theme on cancel\n\t\t\t\t\t\t\tcallbacks.onThemePreview?.(currentValue);\n\t\t\t\t\t\t\tdone();\n\t\t\t\t\t\t},\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\t// Preview theme on selection change\n\t\t\t\t\t\t\tcallbacks.onThemePreview?.(value);\n\t\t\t\t\t\t},\n\t\t\t\t\t),\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: \"Show images\",\n\t\t\t\tdescription: \"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: \"Image width\",\n\t\t\t\tdescription: \"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: \"Auto-resize images\",\n\t\t\tdescription: \"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: \"Block images\",\n\t\t\tdescription: \"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: \"Skill commands\",\n\t\t\tdescription: \"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: \"Show hardware cursor\",\n\t\t\tdescription: \"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: \"Editor padding\",\n\t\t\tdescription: \"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// Autocomplete max visible 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: \"autocomplete-max-visible\",\n\t\t\tlabel: \"Autocomplete max items\",\n\t\t\tdescription: \"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: \"Clear on shrink\",\n\t\t\tdescription: \"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: \"Terminal progress\",\n\t\t\tdescription: \"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// Keep the tool/flag controls together as one block near the top, inserted\n\t\t// after the image/terminal splices above so they aren't leapfrogged.\n\t\tconst toolFlagGroup: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"tools\",\n\t\t\t\tlabel: \"Tools\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Enable/disable tools and tool groups (web, browser, document, semantic search). Changes persist across sessions.\",\n\t\t\t\tcurrentValue: toolsOff > 0 ? `${toolsOn} on · ${toolsOff} off` : `${toolsOn} on`,\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew ToolsSubmenu(\n\t\t\t\t\t\tconfig.tools,\n\t\t\t\t\t\tconfig.toolGroups,\n\t\t\t\t\t\t(name, enabled) => callbacks.onToolEnabledChange(name, enabled),\n\t\t\t\t\t\t(id, enabled) => callbacks.onToolGroupChange(id, enabled),\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: \"tool-output-display\",\n\t\t\t\tlabel: \"Tool output display\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"How tool results render. 'standard': shown (expandable). 'collapsed': hidden. 'peek': hidden with a ▸ reveal caret (press the expand key to reveal).\",\n\t\t\t\tcurrentValue: config.toolOutputDisplay,\n\t\t\t\tvalues: [\"standard\", \"collapsed\", \"peek\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"tool-settings\",\n\t\t\t\tlabel: \"Tool settings\",\n\t\t\t\tdescription: \"Per-tool runtime settings: output truncation caps and context garbage collection.\",\n\t\t\t\tcurrentValue: \"configure\",\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew ToolSettingsSubmenu(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttoolOutputMaxBytes: config.toolOutputMaxBytes,\n\t\t\t\t\t\t\ttoolOutputMaxLines: config.toolOutputMaxLines,\n\t\t\t\t\t\t\tcontextGc: config.contextGc,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tonToolOutputMaxBytesChange: callbacks.onToolOutputMaxBytesChange,\n\t\t\t\t\t\t\tonToolOutputMaxLinesChange: callbacks.onToolOutputMaxLinesChange,\n\t\t\t\t\t\t\tonContextGcChange: callbacks.onContextGcChange,\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];\n\t\tif (config.flags.length > 0) {\n\t\t\ttoolFlagGroup.push({\n\t\t\t\tid: \"flags\",\n\t\t\t\tlabel: \"Flags\",\n\t\t\t\tdescription: \"Set flags registered by extensions. Changes persist across sessions.\",\n\t\t\t\tcurrentValue: `${config.flags.length} flag${config.flags.length === 1 ? \"\" : \"s\"}`,\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew FlagsSubmenu(\n\t\t\t\t\t\tconfig.flags,\n\t\t\t\t\t\t(name, value) => callbacks.onFlagChange(name, value),\n\t\t\t\t\t\t() => done(),\n\t\t\t\t\t),\n\t\t\t});\n\t\t}\n\t\t// Add borders\n\t\tthis.addChild(new DynamicBorder());\n\n\t\t// Shared change handler for every leaf (cycle) setting; used by the\n\t\t// top-level list and each category submenu.\n\t\tconst applyChange = (id: string, newValue: string): void => {\n\t\t\tswitch (id) {\n\t\t\t\tcase \"autocompact\":\n\t\t\t\t\tcallbacks.onAutoCompactChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-output-display\":\n\t\t\t\t\tcallbacks.onToolOutputDisplayChange(newValue as \"collapsed\" | \"peek\" | \"standard\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"show-images\":\n\t\t\t\t\tcallbacks.onShowImagesChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"image-width-cells\":\n\t\t\t\t\tcallbacks.onImageWidthCellsChange(parseInt(newValue, 10));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"auto-resize-images\":\n\t\t\t\t\tcallbacks.onAutoResizeImagesChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"block-images\":\n\t\t\t\t\tcallbacks.onBlockImagesChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"skill-commands\":\n\t\t\t\t\tcallbacks.onEnableSkillCommandsChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"steering-mode\":\n\t\t\t\t\tcallbacks.onSteeringModeChange(newValue as \"all\" | \"one-at-a-time\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"follow-up-mode\":\n\t\t\t\t\tcallbacks.onFollowUpModeChange(newValue as \"all\" | \"one-at-a-time\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"transport\":\n\t\t\t\t\tcallbacks.onTransportChange(newValue as Transport);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"hide-thinking\":\n\t\t\t\t\tcallbacks.onHideThinkingBlockChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"collapse-changelog\":\n\t\t\t\t\tcallbacks.onCollapseChangelogChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"quiet-startup\":\n\t\t\t\t\tcallbacks.onQuietStartupChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"install-telemetry\":\n\t\t\t\t\tcallbacks.onEnableInstallTelemetryChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"double-escape-action\":\n\t\t\t\t\tcallbacks.onDoubleEscapeActionChange(newValue as \"fork\" | \"tree\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tree-filter-mode\":\n\t\t\t\t\tcallbacks.onTreeFilterModeChange(\n\t\t\t\t\t\tnewValue as \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\",\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"show-hardware-cursor\":\n\t\t\t\t\tcallbacks.onShowHardwareCursorChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"editor-padding\":\n\t\t\t\t\tcallbacks.onEditorPaddingXChange(parseInt(newValue, 10));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"autocomplete-max-visible\":\n\t\t\t\t\tcallbacks.onAutocompleteMaxVisibleChange(parseInt(newValue, 10));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"clear-on-shrink\":\n\t\t\t\t\tcallbacks.onClearOnShrinkChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"terminal-progress\":\n\t\t\t\t\tcallbacks.onShowTerminalProgressChange(newValue === \"true\");\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t};\n\n\t\t// Partition the flat leaf settings into named category submenus so the\n\t\t// top level stays short. `items` holds autocompact + every leaf setting.\n\t\tconst byId = new Map(items.map((item) => [item.id, item] as const));\n\t\tconst pick = (ids: string[]): SettingItem[] =>\n\t\t\tids.map((id) => byId.get(id)).filter((item): item is SettingItem => item !== undefined);\n\t\tconst categoryRow = (id: string, label: string, description: string, ids: string[]): SettingItem => {\n\t\t\tconst members = pick(ids);\n\t\t\treturn {\n\t\t\t\tid,\n\t\t\t\tlabel,\n\t\t\t\tdescription,\n\t\t\t\tcurrentValue: `${members.length} setting${members.length === 1 ? \"\" : \"s\"}`,\n\t\t\t\tsubmenu: (_currentValue, done) => new CategorySubmenu(members, applyChange, () => done()),\n\t\t\t};\n\t\t};\n\n\t\tconst topItems: SettingItem[] = [\n\t\t\t...(byId.has(\"autocompact\") ? [byId.get(\"autocompact\")!] : []),\n\t\t\t...toolFlagGroup,\n\t\t\tcategoryRow(\n\t\t\t\t\"cat-behavior\",\n\t\t\t\t\"Behavior\",\n\t\t\t\t\"Agent and session behavior: steering, follow-up, thinking, escape, tree filter, transport.\",\n\t\t\t\t[\"steering-mode\", \"follow-up-mode\", \"thinking\", \"double-escape-action\", \"tree-filter-mode\", \"transport\"],\n\t\t\t),\n\t\t\tcategoryRow(\n\t\t\t\t\"cat-interface\",\n\t\t\t\t\"Interface\",\n\t\t\t\t\"Appearance and editor: theme, thinking visibility, cursor, padding, autocomplete, terminal.\",\n\t\t\t\t[\n\t\t\t\t\t\"theme\",\n\t\t\t\t\t\"hide-thinking\",\n\t\t\t\t\t\"show-hardware-cursor\",\n\t\t\t\t\t\"editor-padding\",\n\t\t\t\t\t\"autocomplete-max-visible\",\n\t\t\t\t\t\"clear-on-shrink\",\n\t\t\t\t\t\"terminal-progress\",\n\t\t\t\t],\n\t\t\t),\n\t\t\tcategoryRow(\"cat-images\", \"Images\", \"Inline image rendering and resizing.\", [\n\t\t\t\t\"show-images\",\n\t\t\t\t\"image-width-cells\",\n\t\t\t\t\"auto-resize-images\",\n\t\t\t\t\"block-images\",\n\t\t\t]),\n\t\t\tcategoryRow(\"cat-advanced\", \"Advanced\", \"Startup, telemetry, skills, and warnings.\", [\n\t\t\t\t\"quiet-startup\",\n\t\t\t\t\"collapse-changelog\",\n\t\t\t\t\"install-telemetry\",\n\t\t\t\t\"skill-commands\",\n\t\t\t\t\"warnings\",\n\t\t\t]),\n\t\t];\n\n\t\tthis.settingsList = new SettingsList(\n\t\t\ttopItems,\n\t\t\tMath.min(topItems.length, 10),\n\t\t\tgetSettingsListTheme(),\n\t\t\tapplyChange,\n\t\t\tcallbacks.onCancel,\n\t\t\t{\n\t\t\t\tenableSearch: true,\n\t\t\t},\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,4 +1,4 @@
|
|
|
1
|
-
import { Container, getCapabilities, SelectList, SettingsList, Spacer, Text, } from "@kolisachint/hoocode-tui";
|
|
1
|
+
import { Container, getCapabilities, Input, SelectList, SettingsList, Spacer, Text, } from "@kolisachint/hoocode-tui";
|
|
2
2
|
import { getSelectListTheme, getSettingsListTheme, theme } from "../theme/theme.js";
|
|
3
3
|
import { DynamicBorder } from "./dynamic-border.js";
|
|
4
4
|
import { keyDisplayText } from "./keybinding-hints.js";
|
|
@@ -46,6 +46,214 @@ class WarningSettingsSubmenu extends Container {
|
|
|
46
46
|
this.settingsList.handleInput(data);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Submenu for tool availability. The first rows are group switches (web,
|
|
51
|
+
* browser, document, semantic search) that decide whether a group's tools
|
|
52
|
+
* exist at all — this is the same master switch that governs, e.g., the
|
|
53
|
+
* webfetch/websearch tools. Below them are per-tool on/off toggles for the
|
|
54
|
+
* tools that are currently available.
|
|
55
|
+
*
|
|
56
|
+
* Group switches change tool availability and apply on the next session;
|
|
57
|
+
* per-tool toggles apply live and persist. A minimum core (read/bash/edit/
|
|
58
|
+
* write) is guarded so the agent can never be left with no way to act.
|
|
59
|
+
*/
|
|
60
|
+
class ToolsSubmenu extends Container {
|
|
61
|
+
settingsList;
|
|
62
|
+
enabled;
|
|
63
|
+
static CORE = new Set(["read", "bash", "edit", "write"]);
|
|
64
|
+
static GROUP_PREFIX = "group:";
|
|
65
|
+
constructor(tools, groups, onChange, onGroupChange, onCancel) {
|
|
66
|
+
super();
|
|
67
|
+
this.enabled = new Map(tools.map((t) => [t.name, t.enabled]));
|
|
68
|
+
const groupItems = groups.map((group) => ({
|
|
69
|
+
id: `${ToolsSubmenu.GROUP_PREFIX}${group.id}`,
|
|
70
|
+
label: `[group] ${group.label}`,
|
|
71
|
+
description: `${group.description} Governs whether these tools exist; applies on the next session.`,
|
|
72
|
+
currentValue: group.enabled ? "on" : "off",
|
|
73
|
+
values: ["on", "off"],
|
|
74
|
+
}));
|
|
75
|
+
const toolItems = tools.map((tool) => ({
|
|
76
|
+
id: tool.name,
|
|
77
|
+
label: tool.name,
|
|
78
|
+
description: ToolsSubmenu.CORE.has(tool.name)
|
|
79
|
+
? "Core tool. Disabling leaves the agent unable to perform this action in every session."
|
|
80
|
+
: "Disable to remove this tool from the agent this session and every future session.",
|
|
81
|
+
currentValue: tool.enabled ? "on" : "off",
|
|
82
|
+
values: ["on", "off"],
|
|
83
|
+
}));
|
|
84
|
+
const items = [...groupItems, ...toolItems];
|
|
85
|
+
this.settingsList = new SettingsList(items, Math.min(items.length, 12), getSettingsListTheme(), (id, newValue) => {
|
|
86
|
+
const wantEnabled = newValue === "on";
|
|
87
|
+
if (id.startsWith(ToolsSubmenu.GROUP_PREFIX)) {
|
|
88
|
+
onGroupChange(id.slice(ToolsSubmenu.GROUP_PREFIX.length), wantEnabled);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
// Guard: never let the last core tool be turned off.
|
|
92
|
+
if (!wantEnabled && ToolsSubmenu.CORE.has(id)) {
|
|
93
|
+
const remainingCore = [...ToolsSubmenu.CORE].filter((n) => n !== id && this.enabled.get(n));
|
|
94
|
+
if (remainingCore.length === 0) {
|
|
95
|
+
this.settingsList.updateValue(id, "on");
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
this.enabled.set(id, wantEnabled);
|
|
100
|
+
onChange(id, wantEnabled);
|
|
101
|
+
}, onCancel, { enableSearch: true });
|
|
102
|
+
this.addChild(this.settingsList);
|
|
103
|
+
}
|
|
104
|
+
handleInput(data) {
|
|
105
|
+
this.settingsList.handleInput(data);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/** Byte-cap presets shown as human labels; mapped back to raw byte counts. */
|
|
109
|
+
const TOOL_OUTPUT_BYTE_PRESETS = [
|
|
110
|
+
["8 KB", 8 * 1024],
|
|
111
|
+
["16 KB", 16 * 1024],
|
|
112
|
+
["32 KB", 32 * 1024],
|
|
113
|
+
["64 KB", 64 * 1024],
|
|
114
|
+
["128 KB", 128 * 1024],
|
|
115
|
+
];
|
|
116
|
+
function bytesToLabel(bytes) {
|
|
117
|
+
const match = TOOL_OUTPUT_BYTE_PRESETS.find(([, b]) => b === bytes);
|
|
118
|
+
return match ? match[0] : `${Math.round(bytes / 1024)} KB`;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Submenu for per-tool runtime settings. These feed the tool runtime the next
|
|
122
|
+
* time it is built (next session / rebuild), so changes apply to future tool
|
|
123
|
+
* calls rather than retroactively.
|
|
124
|
+
*/
|
|
125
|
+
class ToolSettingsSubmenu extends Container {
|
|
126
|
+
settingsList;
|
|
127
|
+
constructor(config, callbacks, onCancel) {
|
|
128
|
+
super();
|
|
129
|
+
const items = [
|
|
130
|
+
{
|
|
131
|
+
id: "output-max-bytes",
|
|
132
|
+
label: "Output max bytes",
|
|
133
|
+
description: "Byte cap on a single read/bash result before truncation. Applies to future tool calls.",
|
|
134
|
+
currentValue: bytesToLabel(config.toolOutputMaxBytes),
|
|
135
|
+
values: TOOL_OUTPUT_BYTE_PRESETS.map(([label]) => label),
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
id: "output-max-lines",
|
|
139
|
+
label: "Output max lines",
|
|
140
|
+
description: "Line cap on a single read/bash result before truncation. Applies to future tool calls.",
|
|
141
|
+
currentValue: String(config.toolOutputMaxLines),
|
|
142
|
+
values: ["200", "400", "800", "1600", "3200"],
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
id: "context-gc",
|
|
146
|
+
label: "Context GC",
|
|
147
|
+
description: "Stub superseded read results (files later edited/re-read) out of the outgoing context.",
|
|
148
|
+
currentValue: config.contextGc ? "true" : "false",
|
|
149
|
+
values: ["true", "false"],
|
|
150
|
+
},
|
|
151
|
+
];
|
|
152
|
+
this.settingsList = new SettingsList(items, Math.min(items.length, 10), getSettingsListTheme(), (id, newValue) => {
|
|
153
|
+
switch (id) {
|
|
154
|
+
case "output-max-bytes": {
|
|
155
|
+
const preset = TOOL_OUTPUT_BYTE_PRESETS.find(([label]) => label === newValue);
|
|
156
|
+
if (preset)
|
|
157
|
+
callbacks.onToolOutputMaxBytesChange(preset[1]);
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
case "output-max-lines":
|
|
161
|
+
callbacks.onToolOutputMaxLinesChange(parseInt(newValue, 10));
|
|
162
|
+
break;
|
|
163
|
+
case "context-gc":
|
|
164
|
+
callbacks.onContextGcChange(newValue === "true");
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
}, onCancel);
|
|
168
|
+
this.addChild(this.settingsList);
|
|
169
|
+
}
|
|
170
|
+
handleInput(data) {
|
|
171
|
+
this.settingsList.handleInput(data);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/** Single-line text editor for a string flag value. */
|
|
175
|
+
class FlagStringEditSubmenu extends Container {
|
|
176
|
+
input;
|
|
177
|
+
constructor(flagName, currentValue, done) {
|
|
178
|
+
super();
|
|
179
|
+
this.addChild(new Text(theme.bold(theme.fg("accent", `Flag: --${flagName}`)), 0, 0));
|
|
180
|
+
this.addChild(new Spacer(1));
|
|
181
|
+
this.addChild(new Text(theme.fg("muted", "Enter a value · Enter to save · Esc to cancel"), 0, 0));
|
|
182
|
+
this.addChild(new Spacer(1));
|
|
183
|
+
this.input = new Input();
|
|
184
|
+
this.input.setValue(currentValue);
|
|
185
|
+
this.input.onSubmit = (value) => done(value);
|
|
186
|
+
this.input.onEscape = () => done();
|
|
187
|
+
this.addChild(this.input);
|
|
188
|
+
}
|
|
189
|
+
handleInput(data) {
|
|
190
|
+
this.input.handleInput(data);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Submenu listing extension-registered flags. Boolean flags toggle on/off;
|
|
195
|
+
* string flags open a text editor. Changes persist to settings.json and are
|
|
196
|
+
* applied live best-effort — extensions that read a flag only at load time
|
|
197
|
+
* pick up the new value on the next launch.
|
|
198
|
+
*/
|
|
199
|
+
class FlagsSubmenu extends Container {
|
|
200
|
+
settingsList;
|
|
201
|
+
constructor(flags, onChange, onCancel) {
|
|
202
|
+
super();
|
|
203
|
+
const items = flags.map((flag) => {
|
|
204
|
+
const baseDescription = flag.description ?? "Extension-registered flag.";
|
|
205
|
+
const description = `${baseDescription} Persists across sessions; some flags need a restart to fully apply.`;
|
|
206
|
+
if (flag.type === "boolean") {
|
|
207
|
+
return {
|
|
208
|
+
id: flag.name,
|
|
209
|
+
label: flag.name,
|
|
210
|
+
description,
|
|
211
|
+
currentValue: flag.value ? "on" : "off",
|
|
212
|
+
values: ["on", "off"],
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
id: flag.name,
|
|
217
|
+
label: flag.name,
|
|
218
|
+
description,
|
|
219
|
+
currentValue: String(flag.value ?? ""),
|
|
220
|
+
submenu: (currentValue, done) => new FlagStringEditSubmenu(flag.name, currentValue, done),
|
|
221
|
+
};
|
|
222
|
+
});
|
|
223
|
+
const typeByName = new Map(flags.map((f) => [f.name, f.type]));
|
|
224
|
+
this.settingsList = new SettingsList(items, Math.min(items.length, 12), getSettingsListTheme(), (id, newValue) => {
|
|
225
|
+
if (typeByName.get(id) === "boolean") {
|
|
226
|
+
onChange(id, newValue === "on");
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
onChange(id, newValue);
|
|
230
|
+
}
|
|
231
|
+
}, onCancel, { enableSearch: true });
|
|
232
|
+
this.addChild(this.settingsList);
|
|
233
|
+
}
|
|
234
|
+
handleInput(data) {
|
|
235
|
+
this.settingsList.handleInput(data);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Generic submenu holding a subset of leaf settings under a category label.
|
|
240
|
+
* Shares the parent's change handler so cycle rows behave exactly as they did
|
|
241
|
+
* when flat; nested submenu rows (theme, thinking, warnings) keep their own
|
|
242
|
+
* factories.
|
|
243
|
+
*/
|
|
244
|
+
class CategorySubmenu extends Container {
|
|
245
|
+
settingsList;
|
|
246
|
+
constructor(items, onChange, onCancel) {
|
|
247
|
+
super();
|
|
248
|
+
this.settingsList = new SettingsList(items, Math.min(items.length, 10), getSettingsListTheme(), onChange, onCancel, {
|
|
249
|
+
enableSearch: true,
|
|
250
|
+
});
|
|
251
|
+
this.addChild(this.settingsList);
|
|
252
|
+
}
|
|
253
|
+
handleInput(data) {
|
|
254
|
+
this.settingsList.handleInput(data);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
49
257
|
class SelectSubmenu extends Container {
|
|
50
258
|
selectList;
|
|
51
259
|
constructor(title, description, options, currentValue, onSelect, onCancel, onSelectionChange) {
|
|
@@ -94,6 +302,8 @@ export class SettingsSelectorComponent extends Container {
|
|
|
94
302
|
const supportsImages = getCapabilities().images;
|
|
95
303
|
const followUpKey = keyDisplayText("app.message.followUp");
|
|
96
304
|
let currentWarnings = { ...config.warnings };
|
|
305
|
+
const toolsOn = config.tools.filter((t) => t.enabled).length;
|
|
306
|
+
const toolsOff = config.tools.length - toolsOn;
|
|
97
307
|
const items = [
|
|
98
308
|
{
|
|
99
309
|
id: "autocompact",
|
|
@@ -299,13 +509,60 @@ export class SettingsSelectorComponent extends Container {
|
|
|
299
509
|
currentValue: config.showTerminalProgress ? "true" : "false",
|
|
300
510
|
values: ["true", "false"],
|
|
301
511
|
});
|
|
512
|
+
// Keep the tool/flag controls together as one block near the top, inserted
|
|
513
|
+
// after the image/terminal splices above so they aren't leapfrogged.
|
|
514
|
+
const toolFlagGroup = [
|
|
515
|
+
{
|
|
516
|
+
id: "tools",
|
|
517
|
+
label: "Tools",
|
|
518
|
+
description: "Enable/disable tools and tool groups (web, browser, document, semantic search). Changes persist across sessions.",
|
|
519
|
+
currentValue: toolsOff > 0 ? `${toolsOn} on · ${toolsOff} off` : `${toolsOn} on`,
|
|
520
|
+
submenu: (_currentValue, done) => new ToolsSubmenu(config.tools, config.toolGroups, (name, enabled) => callbacks.onToolEnabledChange(name, enabled), (id, enabled) => callbacks.onToolGroupChange(id, enabled), () => done()),
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
id: "tool-output-display",
|
|
524
|
+
label: "Tool output display",
|
|
525
|
+
description: "How tool results render. 'standard': shown (expandable). 'collapsed': hidden. 'peek': hidden with a ▸ reveal caret (press the expand key to reveal).",
|
|
526
|
+
currentValue: config.toolOutputDisplay,
|
|
527
|
+
values: ["standard", "collapsed", "peek"],
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
id: "tool-settings",
|
|
531
|
+
label: "Tool settings",
|
|
532
|
+
description: "Per-tool runtime settings: output truncation caps and context garbage collection.",
|
|
533
|
+
currentValue: "configure",
|
|
534
|
+
submenu: (_currentValue, done) => new ToolSettingsSubmenu({
|
|
535
|
+
toolOutputMaxBytes: config.toolOutputMaxBytes,
|
|
536
|
+
toolOutputMaxLines: config.toolOutputMaxLines,
|
|
537
|
+
contextGc: config.contextGc,
|
|
538
|
+
}, {
|
|
539
|
+
onToolOutputMaxBytesChange: callbacks.onToolOutputMaxBytesChange,
|
|
540
|
+
onToolOutputMaxLinesChange: callbacks.onToolOutputMaxLinesChange,
|
|
541
|
+
onContextGcChange: callbacks.onContextGcChange,
|
|
542
|
+
}, () => done()),
|
|
543
|
+
},
|
|
544
|
+
];
|
|
545
|
+
if (config.flags.length > 0) {
|
|
546
|
+
toolFlagGroup.push({
|
|
547
|
+
id: "flags",
|
|
548
|
+
label: "Flags",
|
|
549
|
+
description: "Set flags registered by extensions. Changes persist across sessions.",
|
|
550
|
+
currentValue: `${config.flags.length} flag${config.flags.length === 1 ? "" : "s"}`,
|
|
551
|
+
submenu: (_currentValue, done) => new FlagsSubmenu(config.flags, (name, value) => callbacks.onFlagChange(name, value), () => done()),
|
|
552
|
+
});
|
|
553
|
+
}
|
|
302
554
|
// Add borders
|
|
303
555
|
this.addChild(new DynamicBorder());
|
|
304
|
-
|
|
556
|
+
// Shared change handler for every leaf (cycle) setting; used by the
|
|
557
|
+
// top-level list and each category submenu.
|
|
558
|
+
const applyChange = (id, newValue) => {
|
|
305
559
|
switch (id) {
|
|
306
560
|
case "autocompact":
|
|
307
561
|
callbacks.onAutoCompactChange(newValue === "true");
|
|
308
562
|
break;
|
|
563
|
+
case "tool-output-display":
|
|
564
|
+
callbacks.onToolOutputDisplayChange(newValue);
|
|
565
|
+
break;
|
|
309
566
|
case "show-images":
|
|
310
567
|
callbacks.onShowImagesChange(newValue === "true");
|
|
311
568
|
break;
|
|
@@ -364,7 +621,51 @@ export class SettingsSelectorComponent extends Container {
|
|
|
364
621
|
callbacks.onShowTerminalProgressChange(newValue === "true");
|
|
365
622
|
break;
|
|
366
623
|
}
|
|
367
|
-
}
|
|
624
|
+
};
|
|
625
|
+
// Partition the flat leaf settings into named category submenus so the
|
|
626
|
+
// top level stays short. `items` holds autocompact + every leaf setting.
|
|
627
|
+
const byId = new Map(items.map((item) => [item.id, item]));
|
|
628
|
+
const pick = (ids) => ids.map((id) => byId.get(id)).filter((item) => item !== undefined);
|
|
629
|
+
const categoryRow = (id, label, description, ids) => {
|
|
630
|
+
const members = pick(ids);
|
|
631
|
+
return {
|
|
632
|
+
id,
|
|
633
|
+
label,
|
|
634
|
+
description,
|
|
635
|
+
currentValue: `${members.length} setting${members.length === 1 ? "" : "s"}`,
|
|
636
|
+
submenu: (_currentValue, done) => new CategorySubmenu(members, applyChange, () => done()),
|
|
637
|
+
};
|
|
638
|
+
};
|
|
639
|
+
const topItems = [
|
|
640
|
+
...(byId.has("autocompact") ? [byId.get("autocompact")] : []),
|
|
641
|
+
...toolFlagGroup,
|
|
642
|
+
categoryRow("cat-behavior", "Behavior", "Agent and session behavior: steering, follow-up, thinking, escape, tree filter, transport.", ["steering-mode", "follow-up-mode", "thinking", "double-escape-action", "tree-filter-mode", "transport"]),
|
|
643
|
+
categoryRow("cat-interface", "Interface", "Appearance and editor: theme, thinking visibility, cursor, padding, autocomplete, terminal.", [
|
|
644
|
+
"theme",
|
|
645
|
+
"hide-thinking",
|
|
646
|
+
"show-hardware-cursor",
|
|
647
|
+
"editor-padding",
|
|
648
|
+
"autocomplete-max-visible",
|
|
649
|
+
"clear-on-shrink",
|
|
650
|
+
"terminal-progress",
|
|
651
|
+
]),
|
|
652
|
+
categoryRow("cat-images", "Images", "Inline image rendering and resizing.", [
|
|
653
|
+
"show-images",
|
|
654
|
+
"image-width-cells",
|
|
655
|
+
"auto-resize-images",
|
|
656
|
+
"block-images",
|
|
657
|
+
]),
|
|
658
|
+
categoryRow("cat-advanced", "Advanced", "Startup, telemetry, skills, and warnings.", [
|
|
659
|
+
"quiet-startup",
|
|
660
|
+
"collapse-changelog",
|
|
661
|
+
"install-telemetry",
|
|
662
|
+
"skill-commands",
|
|
663
|
+
"warnings",
|
|
664
|
+
]),
|
|
665
|
+
];
|
|
666
|
+
this.settingsList = new SettingsList(topItems, Math.min(topItems.length, 10), getSettingsListTheme(), applyChange, callbacks.onCancel, {
|
|
667
|
+
enableSearch: true,
|
|
668
|
+
});
|
|
368
669
|
this.addChild(this.settingsList);
|
|
369
670
|
this.addChild(new DynamicBorder());
|
|
370
671
|
}
|