@caupulican/pi-adaptative 0.80.7 → 0.80.8
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 +8 -0
- package/README.md +1 -1
- package/dist/core/reload-blockers.d.ts +2 -0
- package/dist/core/reload-blockers.d.ts.map +1 -1
- package/dist/core/reload-blockers.js +8 -2
- package/dist/core/reload-blockers.js.map +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +7 -3
- package/dist/core/skills.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +3 -0
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +1 -1
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +3 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +88 -26
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/docs/adaptive-extension-shared-state-audit.md +43 -0
- package/docs/settings.md +2 -2
- package/docs/skills.md +3 -3
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAyB,KAAK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AAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACzD,4EAA4E;IAC5E,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;CACjB;AAwCD,kEAAkE;AAClE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,MAAM,CAmI3E","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport { getDocsPath, getExamplesPath, getReadmePath } from \"../config.ts\";\nimport { formatSkillsForPrompt, type Skill } from \"./skills.ts\";\n\nexport interface BuildSystemPromptOptions {\n\t/** Custom system prompt (replaces default). */\n\tcustomPrompt?: string;\n\t/** Tools to include in prompt. Default: [read, bash, edit, write] */\n\tselectedTools?: string[];\n\t/** Optional one-line tool snippets keyed by tool name. */\n\ttoolSnippets?: Record<string, string>;\n\t/** Additional guideline bullets appended to the default system prompt guidelines. */\n\tpromptGuidelines?: string[];\n\t/** Text to append to system prompt. */\n\tappendSystemPrompt?: string;\n\t/** Working directory. */\n\tcwd: string;\n\t/** Eagerly loaded project/agent instruction files. */\n\tcontextFiles?: Array<{ path: string; content?: string }>;\n\t/** Discovered skills; startup prompt lists only lazy-loadable locations. */\n\tskills?: Skill[];\n}\n\nconst ADAPTATIVE_PERSONA_SECTION = `\n\nAdaptative Agent Persona:\n- Work as a self-improving engineering agent: clarify the mission, choose the smallest safe action, verify important claims, and preserve user trust.\n- Use a lightweight MAPE loop for adaptive work: monitor source/runtime evidence, analyze it against mission and memory, plan the smallest safe change, execute with scoped edits, then verify and feed back durable learning.\n- Treat harness evolution as a first-class task. Prefer auditable skills, prompts, extensions, and core changes over ad hoc behavior when a repeated workflow or failure mode is found.\n- For self-evolution, inspect the current runtime/source before changing it, make focused changes, reload or renew only after source is auditable, and validate with concrete artifacts.\n- For file-backed extensions and tools, default to current-session or current-tenant state; shared/global files, locks, cleanup, stop, compact, prune, or list operations must be deliberate, documented, and safe for parallel sessions.\n- Before preserving or changing durable behavior, confront Automata/user memory and ask: why is it good for the user, is it unique or should it merge with existing memory/skills/agents, and will it make the agent better.\n- Maintain a clear contract between objective, evidence, and completion. Do not call work done until requirements are mapped to files, commands, or runtime observations.\n- Keep durable learning concise: store stable preferences, rules, fixes, and source pointers; do not preserve transient execution noise.`;\n\nfunction formatContextFilesForPrompt(contextFiles: Array<{ path: string; content?: string }>): string {\n\tif (contextFiles.length === 0) {\n\t\treturn \"\";\n\t}\n\n\tconst lines = [\"\\n\\n<project_context>\", \"\", \"Project-specific instructions and guidelines:\", \"\"];\n\n\tfor (const { path, content } of contextFiles) {\n\t\tlines.push(`<project_instructions path=\"${escapeXml(path)}\">`);\n\t\tlines.push(content ?? \"\");\n\t\tlines.push(\"</project_instructions>\", \"\");\n\t}\n\n\tlines.push(\"</project_context>\");\n\treturn lines.join(\"\\n\");\n}\n\nfunction escapeXml(str: string): string {\n\treturn str\n\t\t.replace(/&/g, \"&\")\n\t\t.replace(/</g, \"<\")\n\t\t.replace(/>/g, \">\")\n\t\t.replace(/\"/g, \""\")\n\t\t.replace(/'/g, \"'\");\n}\n\n/** Build the system prompt with tools, guidelines, and context */\nexport function buildSystemPrompt(options: BuildSystemPromptOptions): string {\n\tconst {\n\t\tcustomPrompt,\n\t\tselectedTools,\n\t\ttoolSnippets,\n\t\tpromptGuidelines,\n\t\tappendSystemPrompt,\n\t\tcwd,\n\t\tcontextFiles: providedContextFiles,\n\t\tskills: providedSkills,\n\t} = options;\n\tconst resolvedCwd = cwd;\n\tconst promptCwd = resolvedCwd.replace(/\\\\/g, \"/\");\n\n\tconst now = new Date();\n\tconst year = now.getFullYear();\n\tconst month = String(now.getMonth() + 1).padStart(2, \"0\");\n\tconst day = String(now.getDate()).padStart(2, \"0\");\n\tconst date = `${year}-${month}-${day}`;\n\n\tconst appendSection = appendSystemPrompt ? `\\n\\n${appendSystemPrompt}` : \"\";\n\n\tconst contextFiles = providedContextFiles ?? [];\n\tconst skills = providedSkills ?? [];\n\n\tif (customPrompt) {\n\t\tlet prompt = customPrompt;\n\n\t\tprompt += ADAPTATIVE_PERSONA_SECTION;\n\n\t\tif (appendSection) {\n\t\t\tprompt += appendSection;\n\t\t}\n\n\t\tprompt += formatContextFilesForPrompt(contextFiles);\n\n\t\t// Append skills section (only if read tool is available)\n\t\tconst customPromptHasRead = !selectedTools || selectedTools.includes(\"read\");\n\t\tif (customPromptHasRead && skills.length > 0) {\n\t\t\tprompt += formatSkillsForPrompt(skills);\n\t\t}\n\n\t\t// Add date and working directory last\n\t\tprompt += `\\nCurrent date: ${date}`;\n\t\tprompt += `\\nCurrent working directory: ${promptCwd}`;\n\n\t\treturn prompt;\n\t}\n\n\t// Get absolute paths to documentation and examples\n\tconst readmePath = getReadmePath();\n\tconst docsPath = getDocsPath();\n\tconst examplesPath = getExamplesPath();\n\n\t// Build tools list based on selected tools.\n\t// A tool appears in Available tools only when the caller provides a one-line snippet.\n\tconst tools = selectedTools || [\"read\", \"bash\", \"edit\", \"write\"];\n\tconst visibleTools = tools.filter((name) => !!toolSnippets?.[name]);\n\tconst toolsList =\n\t\tvisibleTools.length > 0 ? visibleTools.map((name) => `- ${name}: ${toolSnippets![name]}`).join(\"\\n\") : \"(none)\";\n\n\t// Build guidelines based on which tools are actually available\n\tconst guidelinesList: string[] = [];\n\tconst guidelinesSet = new Set<string>();\n\tconst addGuideline = (guideline: string): void => {\n\t\tif (guidelinesSet.has(guideline)) {\n\t\t\treturn;\n\t\t}\n\t\tguidelinesSet.add(guideline);\n\t\tguidelinesList.push(guideline);\n\t};\n\n\tconst hasBash = tools.includes(\"bash\");\n\tconst hasGrep = tools.includes(\"grep\");\n\tconst hasFind = tools.includes(\"find\");\n\tconst hasLs = tools.includes(\"ls\");\n\tconst hasRead = tools.includes(\"read\");\n\n\t// File exploration guidelines\n\tif (hasBash && !hasGrep && !hasFind && !hasLs) {\n\t\taddGuideline(\"Use bash for file operations like ls, rg, find\");\n\t}\n\n\tfor (const guideline of promptGuidelines ?? []) {\n\t\tconst normalized = guideline.trim();\n\t\tif (normalized.length > 0) {\n\t\t\taddGuideline(normalized);\n\t\t}\n\t}\n\n\t// Always include these\n\taddGuideline(\"Be concise in your responses\");\n\taddGuideline(\"Show file paths clearly when working with files\");\n\n\tconst guidelines = guidelinesList.map((g) => `- ${g}`).join(\"\\n\");\n\n\tlet prompt = `You are an expert coding assistant operating inside pi, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\n\nAvailable tools:\n${toolsList}\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.${ADAPTATIVE_PERSONA_SECTION}\n\nGuidelines:\n${guidelines}\n\nPi documentation (read only when the user asks about pi itself, its SDK, extensions, themes, skills, or TUI):\n- Main documentation: ${readmePath}\n- Additional docs: ${docsPath}\n- Examples: ${examplesPath} (extensions, custom tools, SDK)\n- When reading pi docs or examples, resolve docs/... under Additional docs and examples/... under Examples, not the current working directory\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), pi packages (docs/packages.md)\n- When working on pi topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read pi .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;\n\n\tif (appendSection) {\n\t\tprompt += appendSection;\n\t}\n\n\tprompt += formatContextFilesForPrompt(contextFiles);\n\n\t// Append skills section (only if read tool is available)\n\tif (hasRead && skills.length > 0) {\n\t\tprompt += formatSkillsForPrompt(skills);\n\t}\n\n\t// Add date and working directory last\n\tprompt += `\\nCurrent date: ${date}`;\n\tprompt += `\\nCurrent working directory: ${promptCwd}`;\n\n\treturn prompt;\n}\n"]}
|
|
@@ -7,8 +7,11 @@ const ADAPTATIVE_PERSONA_SECTION = `
|
|
|
7
7
|
|
|
8
8
|
Adaptative Agent Persona:
|
|
9
9
|
- Work as a self-improving engineering agent: clarify the mission, choose the smallest safe action, verify important claims, and preserve user trust.
|
|
10
|
+
- Use a lightweight MAPE loop for adaptive work: monitor source/runtime evidence, analyze it against mission and memory, plan the smallest safe change, execute with scoped edits, then verify and feed back durable learning.
|
|
10
11
|
- Treat harness evolution as a first-class task. Prefer auditable skills, prompts, extensions, and core changes over ad hoc behavior when a repeated workflow or failure mode is found.
|
|
11
12
|
- For self-evolution, inspect the current runtime/source before changing it, make focused changes, reload or renew only after source is auditable, and validate with concrete artifacts.
|
|
13
|
+
- For file-backed extensions and tools, default to current-session or current-tenant state; shared/global files, locks, cleanup, stop, compact, prune, or list operations must be deliberate, documented, and safe for parallel sessions.
|
|
14
|
+
- Before preserving or changing durable behavior, confront Automata/user memory and ask: why is it good for the user, is it unique or should it merge with existing memory/skills/agents, and will it make the agent better.
|
|
12
15
|
- Maintain a clear contract between objective, evidence, and completion. Do not call work done until requirements are mapped to files, commands, or runtime observations.
|
|
13
16
|
- Keep durable learning concise: store stable preferences, rules, fixes, and source pointers; do not preserve transient execution noise.`;
|
|
14
17
|
function formatContextFilesForPrompt(contextFiles) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAc,MAAM,aAAa,CAAC;AAqBhE,MAAM,0BAA0B,GAAG;;;;;;;yIAOsG,CAAC;AAE1I,SAAS,2BAA2B,CAAC,YAAuD,EAAU;IACrG,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,EAAE,CAAC;IACX,CAAC;IAED,MAAM,KAAK,GAAG,CAAC,uBAAuB,EAAE,EAAE,EAAE,+CAA+C,EAAE,EAAE,CAAC,CAAC;IAEjG,KAAK,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,YAAY,EAAE,CAAC;QAC9C,KAAK,CAAC,IAAI,CAAC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AChD,MAAM,UAAU,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;QACpC,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,YAAY,CAAC,UAAU,CAAC,CAAC;QAC1B,CAAC;IACF,CAAC;IAED,uBAAuB;IACvB,YAAY,CAAC,8BAA8B,CAAC,CAAC;IAC7C,YAAY,CAAC,iDAAiD,CAAC,CAAC;IAEhE,MAAM,UAAU,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAElE,IAAI,MAAM,GAAG;;;EAGZ,SAAS;;qGAE0F,0BAA0B;;;EAG7H,UAAU;;;wBAGY,UAAU;qBACb,QAAQ;cACf,YAAY;;;;0GAIgF,CAAC;IAE1G,IAAI,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,aAAa,CAAC;IACzB,CAAC;IAED,MAAM,IAAI,2BAA2B,CAAC,YAAY,CAAC,CAAC;IAEpD,yDAAyD;IACzD,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,sCAAsC;IACtC,MAAM,IAAI,mBAAmB,IAAI,EAAE,CAAC;IACpC,MAAM,IAAI,gCAAgC,SAAS,EAAE,CAAC;IAEtD,OAAO,MAAM,CAAC;AAAA,CACd","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport { getDocsPath, getExamplesPath, getReadmePath } from \"../config.ts\";\nimport { formatSkillsForPrompt, type Skill } from \"./skills.ts\";\n\nexport interface BuildSystemPromptOptions {\n\t/** Custom system prompt (replaces default). */\n\tcustomPrompt?: string;\n\t/** Tools to include in prompt. Default: [read, bash, edit, write] */\n\tselectedTools?: string[];\n\t/** Optional one-line tool snippets keyed by tool name. */\n\ttoolSnippets?: Record<string, string>;\n\t/** Additional guideline bullets appended to the default system prompt guidelines. */\n\tpromptGuidelines?: string[];\n\t/** Text to append to system prompt. */\n\tappendSystemPrompt?: string;\n\t/** Working directory. */\n\tcwd: string;\n\t/** Eagerly loaded project/agent instruction files. */\n\tcontextFiles?: Array<{ path: string; content?: string }>;\n\t/** Discovered skills; startup prompt lists only lazy-loadable locations. */\n\tskills?: Skill[];\n}\n\nconst ADAPTATIVE_PERSONA_SECTION = `\n\nAdaptative Agent Persona:\n- Work as a self-improving engineering agent: clarify the mission, choose the smallest safe action, verify important claims, and preserve user trust.\n- Treat harness evolution as a first-class task. Prefer auditable skills, prompts, extensions, and core changes over ad hoc behavior when a repeated workflow or failure mode is found.\n- For self-evolution, inspect the current runtime/source before changing it, make focused changes, reload or renew only after source is auditable, and validate with concrete artifacts.\n- Maintain a clear contract between objective, evidence, and completion. Do not call work done until requirements are mapped to files, commands, or runtime observations.\n- Keep durable learning concise: store stable preferences, rules, fixes, and source pointers; do not preserve transient execution noise.`;\n\nfunction formatContextFilesForPrompt(contextFiles: Array<{ path: string; content?: string }>): string {\n\tif (contextFiles.length === 0) {\n\t\treturn \"\";\n\t}\n\n\tconst lines = [\"\\n\\n<project_context>\", \"\", \"Project-specific instructions and guidelines:\", \"\"];\n\n\tfor (const { path, content } of contextFiles) {\n\t\tlines.push(`<project_instructions path=\"${escapeXml(path)}\">`);\n\t\tlines.push(content ?? \"\");\n\t\tlines.push(\"</project_instructions>\", \"\");\n\t}\n\n\tlines.push(\"</project_context>\");\n\treturn lines.join(\"\\n\");\n}\n\nfunction escapeXml(str: string): string {\n\treturn str\n\t\t.replace(/&/g, \"&\")\n\t\t.replace(/</g, \"<\")\n\t\t.replace(/>/g, \">\")\n\t\t.replace(/\"/g, \""\")\n\t\t.replace(/'/g, \"'\");\n}\n\n/** Build the system prompt with tools, guidelines, and context */\nexport function buildSystemPrompt(options: BuildSystemPromptOptions): string {\n\tconst {\n\t\tcustomPrompt,\n\t\tselectedTools,\n\t\ttoolSnippets,\n\t\tpromptGuidelines,\n\t\tappendSystemPrompt,\n\t\tcwd,\n\t\tcontextFiles: providedContextFiles,\n\t\tskills: providedSkills,\n\t} = options;\n\tconst resolvedCwd = cwd;\n\tconst promptCwd = resolvedCwd.replace(/\\\\/g, \"/\");\n\n\tconst now = new Date();\n\tconst year = now.getFullYear();\n\tconst month = String(now.getMonth() + 1).padStart(2, \"0\");\n\tconst day = String(now.getDate()).padStart(2, \"0\");\n\tconst date = `${year}-${month}-${day}`;\n\n\tconst appendSection = appendSystemPrompt ? `\\n\\n${appendSystemPrompt}` : \"\";\n\n\tconst contextFiles = providedContextFiles ?? [];\n\tconst skills = providedSkills ?? [];\n\n\tif (customPrompt) {\n\t\tlet prompt = customPrompt;\n\n\t\tprompt += ADAPTATIVE_PERSONA_SECTION;\n\n\t\tif (appendSection) {\n\t\t\tprompt += appendSection;\n\t\t}\n\n\t\tprompt += formatContextFilesForPrompt(contextFiles);\n\n\t\t// Append skills section (only if read tool is available)\n\t\tconst customPromptHasRead = !selectedTools || selectedTools.includes(\"read\");\n\t\tif (customPromptHasRead && skills.length > 0) {\n\t\t\tprompt += formatSkillsForPrompt(skills);\n\t\t}\n\n\t\t// Add date and working directory last\n\t\tprompt += `\\nCurrent date: ${date}`;\n\t\tprompt += `\\nCurrent working directory: ${promptCwd}`;\n\n\t\treturn prompt;\n\t}\n\n\t// Get absolute paths to documentation and examples\n\tconst readmePath = getReadmePath();\n\tconst docsPath = getDocsPath();\n\tconst examplesPath = getExamplesPath();\n\n\t// Build tools list based on selected tools.\n\t// A tool appears in Available tools only when the caller provides a one-line snippet.\n\tconst tools = selectedTools || [\"read\", \"bash\", \"edit\", \"write\"];\n\tconst visibleTools = tools.filter((name) => !!toolSnippets?.[name]);\n\tconst toolsList =\n\t\tvisibleTools.length > 0 ? visibleTools.map((name) => `- ${name}: ${toolSnippets![name]}`).join(\"\\n\") : \"(none)\";\n\n\t// Build guidelines based on which tools are actually available\n\tconst guidelinesList: string[] = [];\n\tconst guidelinesSet = new Set<string>();\n\tconst addGuideline = (guideline: string): void => {\n\t\tif (guidelinesSet.has(guideline)) {\n\t\t\treturn;\n\t\t}\n\t\tguidelinesSet.add(guideline);\n\t\tguidelinesList.push(guideline);\n\t};\n\n\tconst hasBash = tools.includes(\"bash\");\n\tconst hasGrep = tools.includes(\"grep\");\n\tconst hasFind = tools.includes(\"find\");\n\tconst hasLs = tools.includes(\"ls\");\n\tconst hasRead = tools.includes(\"read\");\n\n\t// File exploration guidelines\n\tif (hasBash && !hasGrep && !hasFind && !hasLs) {\n\t\taddGuideline(\"Use bash for file operations like ls, rg, find\");\n\t}\n\n\tfor (const guideline of promptGuidelines ?? []) {\n\t\tconst normalized = guideline.trim();\n\t\tif (normalized.length > 0) {\n\t\t\taddGuideline(normalized);\n\t\t}\n\t}\n\n\t// Always include these\n\taddGuideline(\"Be concise in your responses\");\n\taddGuideline(\"Show file paths clearly when working with files\");\n\n\tconst guidelines = guidelinesList.map((g) => `- ${g}`).join(\"\\n\");\n\n\tlet prompt = `You are an expert coding assistant operating inside pi, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\n\nAvailable tools:\n${toolsList}\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.${ADAPTATIVE_PERSONA_SECTION}\n\nGuidelines:\n${guidelines}\n\nPi documentation (read only when the user asks about pi itself, its SDK, extensions, themes, skills, or TUI):\n- Main documentation: ${readmePath}\n- Additional docs: ${docsPath}\n- Examples: ${examplesPath} (extensions, custom tools, SDK)\n- When reading pi docs or examples, resolve docs/... under Additional docs and examples/... under Examples, not the current working directory\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), pi packages (docs/packages.md)\n- When working on pi topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read pi .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;\n\n\tif (appendSection) {\n\t\tprompt += appendSection;\n\t}\n\n\tprompt += formatContextFilesForPrompt(contextFiles);\n\n\t// Append skills section (only if read tool is available)\n\tif (hasRead && skills.length > 0) {\n\t\tprompt += formatSkillsForPrompt(skills);\n\t}\n\n\t// Add date and working directory last\n\tprompt += `\\nCurrent date: ${date}`;\n\tprompt += `\\nCurrent working directory: ${promptCwd}`;\n\n\treturn prompt;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAc,MAAM,aAAa,CAAC;AAqBhE,MAAM,0BAA0B,GAAG;;;;;;;;;;yIAUsG,CAAC;AAE1I,SAAS,2BAA2B,CAAC,YAAuD,EAAU;IACrG,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,EAAE,CAAC;IACX,CAAC;IAED,MAAM,KAAK,GAAG,CAAC,uBAAuB,EAAE,EAAE,EAAE,+CAA+C,EAAE,EAAE,CAAC,CAAC;IAEjG,KAAK,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,YAAY,EAAE,CAAC;QAC9C,KAAK,CAAC,IAAI,CAAC,+BAA+B,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/D,KAAK,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;QAC1B,KAAK,CAAC,IAAI,CAAC,yBAAyB,EAAE,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACjC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAAA,CACxB;AAED,SAAS,SAAS,CAAC,GAAW,EAAU;IACvC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CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAElE,IAAI,MAAM,GAAG;;;EAGZ,SAAS;;qGAE0F,0BAA0B;;;EAG7H,UAAU;;;wBAGY,UAAU;qBACb,QAAQ;cACf,YAAY;;;;0GAIgF,CAAC;IAE1G,IAAI,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,aAAa,CAAC;IACzB,CAAC;IAED,MAAM,IAAI,2BAA2B,CAAC,YAAY,CAAC,CAAC;IAEpD,yDAAyD;IACzD,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,sCAAsC;IACtC,MAAM,IAAI,mBAAmB,IAAI,EAAE,CAAC;IACpC,MAAM,IAAI,gCAAgC,SAAS,EAAE,CAAC;IAEtD,OAAO,MAAM,CAAC;AAAA,CACd","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport { getDocsPath, getExamplesPath, getReadmePath } from \"../config.ts\";\nimport { formatSkillsForPrompt, type Skill } from \"./skills.ts\";\n\nexport interface BuildSystemPromptOptions {\n\t/** Custom system prompt (replaces default). */\n\tcustomPrompt?: string;\n\t/** Tools to include in prompt. Default: [read, bash, edit, write] */\n\tselectedTools?: string[];\n\t/** Optional one-line tool snippets keyed by tool name. */\n\ttoolSnippets?: Record<string, string>;\n\t/** Additional guideline bullets appended to the default system prompt guidelines. */\n\tpromptGuidelines?: string[];\n\t/** Text to append to system prompt. */\n\tappendSystemPrompt?: string;\n\t/** Working directory. */\n\tcwd: string;\n\t/** Eagerly loaded project/agent instruction files. */\n\tcontextFiles?: Array<{ path: string; content?: string }>;\n\t/** Discovered skills; startup prompt lists only lazy-loadable locations. */\n\tskills?: Skill[];\n}\n\nconst ADAPTATIVE_PERSONA_SECTION = `\n\nAdaptative Agent Persona:\n- Work as a self-improving engineering agent: clarify the mission, choose the smallest safe action, verify important claims, and preserve user trust.\n- Use a lightweight MAPE loop for adaptive work: monitor source/runtime evidence, analyze it against mission and memory, plan the smallest safe change, execute with scoped edits, then verify and feed back durable learning.\n- Treat harness evolution as a first-class task. Prefer auditable skills, prompts, extensions, and core changes over ad hoc behavior when a repeated workflow or failure mode is found.\n- For self-evolution, inspect the current runtime/source before changing it, make focused changes, reload or renew only after source is auditable, and validate with concrete artifacts.\n- For file-backed extensions and tools, default to current-session or current-tenant state; shared/global files, locks, cleanup, stop, compact, prune, or list operations must be deliberate, documented, and safe for parallel sessions.\n- Before preserving or changing durable behavior, confront Automata/user memory and ask: why is it good for the user, is it unique or should it merge with existing memory/skills/agents, and will it make the agent better.\n- Maintain a clear contract between objective, evidence, and completion. Do not call work done until requirements are mapped to files, commands, or runtime observations.\n- Keep durable learning concise: store stable preferences, rules, fixes, and source pointers; do not preserve transient execution noise.`;\n\nfunction formatContextFilesForPrompt(contextFiles: Array<{ path: string; content?: string }>): string {\n\tif (contextFiles.length === 0) {\n\t\treturn \"\";\n\t}\n\n\tconst lines = [\"\\n\\n<project_context>\", \"\", \"Project-specific instructions and guidelines:\", \"\"];\n\n\tfor (const { path, content } of contextFiles) {\n\t\tlines.push(`<project_instructions path=\"${escapeXml(path)}\">`);\n\t\tlines.push(content ?? \"\");\n\t\tlines.push(\"</project_instructions>\", \"\");\n\t}\n\n\tlines.push(\"</project_context>\");\n\treturn lines.join(\"\\n\");\n}\n\nfunction escapeXml(str: string): string {\n\treturn str\n\t\t.replace(/&/g, \"&\")\n\t\t.replace(/</g, \"<\")\n\t\t.replace(/>/g, \">\")\n\t\t.replace(/\"/g, \""\")\n\t\t.replace(/'/g, \"'\");\n}\n\n/** Build the system prompt with tools, guidelines, and context */\nexport function buildSystemPrompt(options: BuildSystemPromptOptions): string {\n\tconst {\n\t\tcustomPrompt,\n\t\tselectedTools,\n\t\ttoolSnippets,\n\t\tpromptGuidelines,\n\t\tappendSystemPrompt,\n\t\tcwd,\n\t\tcontextFiles: providedContextFiles,\n\t\tskills: providedSkills,\n\t} = options;\n\tconst resolvedCwd = cwd;\n\tconst promptCwd = resolvedCwd.replace(/\\\\/g, \"/\");\n\n\tconst now = new Date();\n\tconst year = now.getFullYear();\n\tconst month = String(now.getMonth() + 1).padStart(2, \"0\");\n\tconst day = String(now.getDate()).padStart(2, \"0\");\n\tconst date = `${year}-${month}-${day}`;\n\n\tconst appendSection = appendSystemPrompt ? `\\n\\n${appendSystemPrompt}` : \"\";\n\n\tconst contextFiles = providedContextFiles ?? [];\n\tconst skills = providedSkills ?? [];\n\n\tif (customPrompt) {\n\t\tlet prompt = customPrompt;\n\n\t\tprompt += ADAPTATIVE_PERSONA_SECTION;\n\n\t\tif (appendSection) {\n\t\t\tprompt += appendSection;\n\t\t}\n\n\t\tprompt += formatContextFilesForPrompt(contextFiles);\n\n\t\t// Append skills section (only if read tool is available)\n\t\tconst customPromptHasRead = !selectedTools || selectedTools.includes(\"read\");\n\t\tif (customPromptHasRead && skills.length > 0) {\n\t\t\tprompt += formatSkillsForPrompt(skills);\n\t\t}\n\n\t\t// Add date and working directory last\n\t\tprompt += `\\nCurrent date: ${date}`;\n\t\tprompt += `\\nCurrent working directory: ${promptCwd}`;\n\n\t\treturn prompt;\n\t}\n\n\t// Get absolute paths to documentation and examples\n\tconst readmePath = getReadmePath();\n\tconst docsPath = getDocsPath();\n\tconst examplesPath = getExamplesPath();\n\n\t// Build tools list based on selected tools.\n\t// A tool appears in Available tools only when the caller provides a one-line snippet.\n\tconst tools = selectedTools || [\"read\", \"bash\", \"edit\", \"write\"];\n\tconst visibleTools = tools.filter((name) => !!toolSnippets?.[name]);\n\tconst toolsList =\n\t\tvisibleTools.length > 0 ? visibleTools.map((name) => `- ${name}: ${toolSnippets![name]}`).join(\"\\n\") : \"(none)\";\n\n\t// Build guidelines based on which tools are actually available\n\tconst guidelinesList: string[] = [];\n\tconst guidelinesSet = new Set<string>();\n\tconst addGuideline = (guideline: string): void => {\n\t\tif (guidelinesSet.has(guideline)) {\n\t\t\treturn;\n\t\t}\n\t\tguidelinesSet.add(guideline);\n\t\tguidelinesList.push(guideline);\n\t};\n\n\tconst hasBash = tools.includes(\"bash\");\n\tconst hasGrep = tools.includes(\"grep\");\n\tconst hasFind = tools.includes(\"find\");\n\tconst hasLs = tools.includes(\"ls\");\n\tconst hasRead = tools.includes(\"read\");\n\n\t// File exploration guidelines\n\tif (hasBash && !hasGrep && !hasFind && !hasLs) {\n\t\taddGuideline(\"Use bash for file operations like ls, rg, find\");\n\t}\n\n\tfor (const guideline of promptGuidelines ?? []) {\n\t\tconst normalized = guideline.trim();\n\t\tif (normalized.length > 0) {\n\t\t\taddGuideline(normalized);\n\t\t}\n\t}\n\n\t// Always include these\n\taddGuideline(\"Be concise in your responses\");\n\taddGuideline(\"Show file paths clearly when working with files\");\n\n\tconst guidelines = guidelinesList.map((g) => `- ${g}`).join(\"\\n\");\n\n\tlet prompt = `You are an expert coding assistant operating inside pi, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\n\nAvailable tools:\n${toolsList}\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.${ADAPTATIVE_PERSONA_SECTION}\n\nGuidelines:\n${guidelines}\n\nPi documentation (read only when the user asks about pi itself, its SDK, extensions, themes, skills, or TUI):\n- Main documentation: ${readmePath}\n- Additional docs: ${docsPath}\n- Examples: ${examplesPath} (extensions, custom tools, SDK)\n- When reading pi docs or examples, resolve docs/... under Additional docs and examples/... under Examples, not the current working directory\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), pi packages (docs/packages.md)\n- When working on pi topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read pi .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;\n\n\tif (appendSection) {\n\t\tprompt += appendSection;\n\t}\n\n\tprompt += formatContextFilesForPrompt(contextFiles);\n\n\t// Append skills section (only if read tool is available)\n\tif (hasRead && skills.length > 0) {\n\t\tprompt += formatSkillsForPrompt(skills);\n\t}\n\n\t// Add date and working directory last\n\tprompt += `\\nCurrent date: ${date}`;\n\tprompt += `\\nCurrent working directory: ${promptCwd}`;\n\n\treturn prompt;\n}\n"]}
|
|
@@ -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,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACN,SAAS,EAIT,KAAK,UAAU,EAIf,YAAY,EAGZ,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EACX,iBAAiB,EAEjB,gBAAgB,EAChB,wBAAwB,EACxB,aAAa,EACb,eAAe,EACf,MAAM,mCAAmC,CAAC;AAqH3C,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,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,aAAa,CAAC;IAC7B,uBAAuB,EAAE,aAAa,EAAE,CAAC;IACzC,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,sBAAsB,EAAE,OAAO,CAA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AAE,wBAAwB,EAAE,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC7F,gBAAgB,EAAE,CAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC7E,iBAAiB,EAAE,CAAC,QAAQ,EAAE,iBAAiB,EAAE,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC/E,QAAQ,EAAE,MAAM,IAAI,CAAC;CACrB;AAwjBD;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,SAAS;IACvD,OAAO,CAAC,YAAY,CAAe;IAEnC,YAAY,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,iBAAiB,EAwY/D;IAED,eAAe,IAAI,YAAY,CAE9B;CACD","sourcesContent":["import type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Transport } from \"@earendil-works/pi-ai\";\nimport {\n\tContainer,\n\tgetCapabilities,\n\tgetKeybindings,\n\tInput,\n\ttype SelectItem,\n\tSelectList,\n\ttype SelectListLayoutOptions,\n\ttype SettingItem,\n\tSettingsList,\n\tSpacer,\n\tText,\n} from \"@earendil-works/pi-tui\";\nimport { formatHttpIdleTimeoutMs, HTTP_IDLE_TIMEOUT_CHOICES } from \"../../../core/http-dispatcher.ts\";\nimport type {\n\tAutoLearnSettings,\n\tAutonomyMode,\n\tAutonomySettings,\n\tSelfModificationSettings,\n\tSettingsScope,\n\tWarningSettings,\n} from \"../../../core/settings-manager.ts\";\nimport { getSelectListTheme, getSettingsListTheme, theme } from \"../theme/theme.ts\";\nimport { DynamicBorder } from \"./dynamic-border.ts\";\nimport { keyDisplayText } from \"./keybinding-hints.ts\";\n\nconst SETTINGS_SUBMENU_SELECT_LIST_LAYOUT: SelectListLayoutOptions = {\n\tminPrimaryColumnWidth: 12,\n\tmaxPrimaryColumnWidth: 32,\n};\n\nconst AUTO_LEARN_CUSTOM_MODEL_VALUE = \"__custom_auto_learn_model__\";\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\nconst AUTONOMY_MODES: AutonomyMode[] = [\"off\", \"safe\", \"balanced\", \"full\"];\n\nconst AUTO_LEARN_DEFAULTS = {\n\tmodel: \"active\",\n\tlongSessionMessages: 32,\n\tlongSessionContextPercent: 70,\n\tcooldownMinutes: 120,\n\tleaseMinutes: 90,\n\tmaxConcurrentLearners: 2,\n\tapplyHighConfidence: false,\n\treflectionReview: true,\n\treflectionMinToolCalls: 5,\n\treflectionCooldownMinutes: 60,\n} as const;\n\nfunction booleanSettingValue(value: boolean | undefined, defaultValue = false): string {\n\treturn (value ?? defaultValue) ? \"true\" : \"false\";\n}\n\nfunction optionalStringValue(value: string | undefined, fallback = \"(not set)\"): string {\n\tconst trimmed = value?.trim();\n\treturn trimmed && trimmed.length > 0 ? trimmed : fallback;\n}\n\nfunction normalizeOptionalString(value: string): string | undefined {\n\tconst trimmed = value.trim();\n\treturn trimmed.length > 0 ? trimmed : undefined;\n}\n\nfunction numberSettingValue(value: number | undefined, defaultValue: number): string {\n\treturn String(value ?? defaultValue);\n}\n\nfunction autoLearnModelValue(settings: AutoLearnSettings): string {\n\treturn optionalStringValue(settings.model, AUTO_LEARN_DEFAULTS.model);\n}\n\nfunction selfModificationSummary(settings: SelfModificationSettings): string {\n\tif (!(settings.enabled ?? false)) return \"disabled\";\n\treturn optionalStringValue(settings.sourcePath) === \"(not set)\" ? \"enabled (missing path)\" : \"enabled\";\n}\n\nfunction autonomyModeValue(settings: AutonomySettings): AutonomyMode {\n\treturn settings.mode && AUTONOMY_MODES.includes(settings.mode) ? settings.mode : \"off\";\n}\n\nfunction autonomySummary(settings: AutonomySettings): string {\n\tconst mode = autonomyModeValue(settings);\n\treturn mode === \"full\" ? \"standing autonomy\" : mode;\n}\n\nfunction autoLearnSummary(settings: AutoLearnSettings): string {\n\treturn settings.enabled ? `enabled (${autoLearnModelValue(settings)})` : \"disabled\";\n}\n\nfunction buildAutoLearnModelOptions(\n\tsettings: AutoLearnSettings,\n\tconfiguredModelOptions: SelectItem[] | undefined,\n\tcurrentModelPattern: string | undefined,\n): SelectItem[] {\n\tconst currentValue = autoLearnModelValue(settings);\n\tconst options: SelectItem[] = [\n\t\t{\n\t\t\tvalue: AUTO_LEARN_DEFAULTS.model,\n\t\t\tlabel: \"active\",\n\t\t\tdescription: currentModelPattern\n\t\t\t\t? `Use the current session model (${currentModelPattern})`\n\t\t\t\t: \"Use the current session model\",\n\t\t},\n\t];\n\tconst seen = new Set(options.map((option) => option.value));\n\n\tfor (const option of configuredModelOptions ?? []) {\n\t\tif (seen.has(option.value)) continue;\n\t\toptions.push(option);\n\t\tseen.add(option.value);\n\t}\n\n\tif (currentValue !== AUTO_LEARN_DEFAULTS.model && !seen.has(currentValue)) {\n\t\toptions.push({\n\t\t\tvalue: currentValue,\n\t\t\tlabel: currentValue,\n\t\t\tdescription: \"Current custom setting\",\n\t\t});\n\t\tseen.add(currentValue);\n\t}\n\n\toptions.push({\n\t\tvalue: AUTO_LEARN_CUSTOM_MODEL_VALUE,\n\t\tlabel: \"Manual / custom…\",\n\t\tdescription: \"Type a model pattern not listed above\",\n\t});\n\n\treturn options;\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\thttpIdleTimeoutMs: number;\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\tselfModification: { enabled: boolean; sourcePath?: string };\n\tselfModificationScope?: SettingsScope;\n\tautonomy: AutonomySettings;\n\tautonomyScope?: SettingsScope;\n\tautoLearn: AutoLearnSettings;\n\tautoLearnScope?: SettingsScope;\n\tcurrentModelPattern?: string;\n\tautoLearnModelOptions?: SelectItem[];\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\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\tonSelfModificationChange: (settings: SelfModificationSettings, scope: SettingsScope) => void;\n\tonAutonomyChange: (settings: AutonomySettings, scope: SettingsScope) => void;\n\tonAutoLearnChange: (settings: AutoLearnSettings, scope: SettingsScope) => void;\n\tonCancel: () => void;\n}\n\nclass TextInputSubmenu extends Container {\n\tprivate input: Input;\n\n\tconstructor(\n\t\ttitle: string,\n\t\tdescription: string,\n\t\tcurrentValue: string,\n\t\tonSubmit: (value: string) => void,\n\t\tonCancel: () => void,\n\t\temptyHint = \"empty clears the setting\",\n\t) {\n\t\tsuper();\n\n\t\tthis.addChild(new Text(theme.bold(theme.fg(\"accent\", title)), 0, 0));\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\t\tthis.addChild(new Spacer(1));\n\n\t\tthis.input = new Input();\n\t\tthis.input.setValue(currentValue);\n\t\tthis.input.focused = true;\n\t\tthis.input.onSubmit = onSubmit;\n\t\tthis.input.onEscape = onCancel;\n\t\tthis.addChild(this.input);\n\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(new Text(theme.fg(\"dim\", ` Enter to save · Esc to go back · ${emptyHint}`), 0, 0));\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.input.handleInput(data);\n\t}\n}\n\nclass AutoLearnModelSelectionSubmenu extends Container {\n\tprivate searchInput: Input;\n\tprivate selectList: SelectList;\n\tprivate customInput: TextInputSubmenu | null = null;\n\n\tconstructor(options: SelectItem[], currentValue: string, onSelect: (value: string) => void, onCancel: () => void) {\n\t\tsuper();\n\n\t\tthis.addChild(new Text(theme.bold(theme.fg(\"accent\", \"Auto Learn Scavenger Model\")), 0, 0));\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(\n\t\t\tnew Text(\n\t\t\t\ttheme.fg(\n\t\t\t\t\t\"muted\",\n\t\t\t\t\t\"Choose active or a model from currently configured subscription/API accounts. Type to filter; choose manual for a custom pattern.\",\n\t\t\t\t),\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t),\n\t\t);\n\t\tthis.addChild(new Spacer(1));\n\n\t\tthis.searchInput = new Input();\n\t\tthis.searchInput.focused = true;\n\t\tthis.addChild(this.searchInput);\n\t\tthis.addChild(new Spacer(1));\n\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\tconst currentIndex = options.findIndex((option) => option.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\tif (item.value === AUTO_LEARN_CUSTOM_MODEL_VALUE) {\n\t\t\t\tthis.customInput = new TextInputSubmenu(\n\t\t\t\t\t\"Custom Auto Learn Model\",\n\t\t\t\t\t'Enter \"active\" or a provider/model pattern like \"openai/gpt-5.4\".',\n\t\t\t\t\tcurrentValue === AUTO_LEARN_DEFAULTS.model ? \"\" : currentValue,\n\t\t\t\t\t(value) => {\n\t\t\t\t\t\tonSelect(normalizeOptionalString(value) ?? AUTO_LEARN_DEFAULTS.model);\n\t\t\t\t\t},\n\t\t\t\t\t() => {\n\t\t\t\t\t\tthis.customInput = null;\n\t\t\t\t\t},\n\t\t\t\t\t'empty uses \"active\"',\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonSelect(item.value);\n\t\t};\n\t\tthis.selectList.onCancel = onCancel;\n\t\tthis.addChild(this.selectList);\n\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(new Text(theme.fg(\"dim\", \" Type to filter · Enter to select · Esc to go back\"), 0, 0));\n\t}\n\n\thandleInput(data: string): void {\n\t\tif (this.customInput) {\n\t\t\tthis.customInput.handleInput(data);\n\t\t\treturn;\n\t\t}\n\n\t\tconst kb = getKeybindings();\n\t\tif (kb.matches(data, \"tui.select.up\") || kb.matches(data, \"tui.select.down\")) {\n\t\t\tthis.selectList.handleInput(data);\n\t\t\treturn;\n\t\t}\n\t\tif (kb.matches(data, \"tui.select.confirm\") || kb.matches(data, \"tui.select.cancel\")) {\n\t\t\tthis.selectList.handleInput(data);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.searchInput.handleInput(data);\n\t\tthis.selectList.setFilter(this.searchInput.getValue());\n\t}\n\n\trender(width: number): string[] {\n\t\treturn this.customInput ? this.customInput.render(width) : super.render(width);\n\t}\n\n\tinvalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.customInput?.invalidate?.();\n\t}\n}\n\nclass SelfModificationSettingsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\tprivate state: SelfModificationSettings;\n\tprivate scope: SettingsScope;\n\n\tconstructor(\n\t\tsettings: SelfModificationSettings,\n\t\tonChange: (settings: SelfModificationSettings, scope: SettingsScope) => void,\n\t\tonCancel: () => void,\n\t\tscope: SettingsScope = \"global\",\n\t) {\n\t\tsuper();\n\n\t\tthis.state = { ...settings, enabled: settings.enabled ?? false };\n\t\tthis.scope = scope;\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"self-modification-scope\",\n\t\t\t\tlabel: \"Save scope\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Save this self-modification configuration globally or in the current project's .pi/settings.json\",\n\t\t\t\tcurrentValue: this.scope,\n\t\t\t\tvalues: [\"global\", \"project\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"self-modification-enabled\",\n\t\t\t\tlabel: \"Enabled\",\n\t\t\t\tdescription: \"Allow agents to modify Pi's own source/harness only when explicitly tasked\",\n\t\t\t\tcurrentValue: booleanSettingValue(this.state.enabled),\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"self-modification-source-path\",\n\t\t\t\tlabel: \"Source path\",\n\t\t\t\tdescription: \"Path to the pi-adaptative source checkout agents may edit for self-evolution\",\n\t\t\t\tcurrentValue: optionalStringValue(this.state.sourcePath),\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew TextInputSubmenu(\n\t\t\t\t\t\t\"Pi-adaptative Source Path\",\n\t\t\t\t\t\t\"Set the source checkout path used by self-evolution guardrails. Empty clears it.\",\n\t\t\t\t\t\tthis.state.sourcePath ?? \"\",\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\tconst sourcePath = normalizeOptionalString(value);\n\t\t\t\t\t\t\tthis.state = { ...this.state, sourcePath };\n\t\t\t\t\t\t\tonChange({ ...this.state }, this.scope);\n\t\t\t\t\t\t\tdone(optionalStringValue(sourcePath));\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\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 \"self-modification-scope\":\n\t\t\t\t\t\tthis.scope = newValue as SettingsScope;\n\t\t\t\t\t\tonChange({ ...this.state }, this.scope);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"self-modification-enabled\":\n\t\t\t\t\t\tthis.state = { ...this.state, enabled: newValue === \"true\" };\n\t\t\t\t\t\tonChange({ ...this.state }, this.scope);\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 AutonomySettingsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\tprivate state: AutonomySettings;\n\tprivate scope: SettingsScope;\n\n\tconstructor(\n\t\tsettings: AutonomySettings,\n\t\tonChange: (settings: AutonomySettings, scope: SettingsScope) => void,\n\t\tonCancel: () => void,\n\t\tscope: SettingsScope = \"global\",\n\t) {\n\t\tsuper();\n\t\tthis.state = { mode: autonomyModeValue(settings) };\n\t\tthis.scope = scope;\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"autonomy-scope\",\n\t\t\t\tlabel: \"Save scope\",\n\t\t\t\tdescription: \"Save this autonomy preset globally or in the current project's .pi/settings.json\",\n\t\t\t\tcurrentValue: this.scope,\n\t\t\t\tvalues: [\"global\", \"project\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"autonomy-mode\",\n\t\t\t\tlabel: \"Mode\",\n\t\t\t\tdescription: \"One preset for background learning: off, safe, balanced, or standing autonomy\",\n\t\t\t\tcurrentValue: autonomyModeValue(this.state),\n\t\t\t\tvalues: AUTONOMY_MODES,\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 \"autonomy-scope\":\n\t\t\t\t\t\tthis.scope = newValue as SettingsScope;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"autonomy-mode\":\n\t\t\t\t\t\tthis.state = { ...this.state, mode: newValue as AutonomyMode };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tonChange({ ...this.state }, this.scope);\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 AutoLearnSettingsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\tprivate state: AutoLearnSettings;\n\tprivate scope: SettingsScope;\n\n\tconstructor(\n\t\tsettings: AutoLearnSettings,\n\t\tcurrentModelPattern: string | undefined,\n\t\tmodelOptions: SelectItem[] | undefined,\n\t\tonChange: (settings: AutoLearnSettings, scope: SettingsScope) => void,\n\t\tonCancel: () => void,\n\t\tscope: SettingsScope = \"global\",\n\t) {\n\t\tsuper();\n\n\t\tthis.state = { ...settings };\n\t\tthis.scope = scope;\n\t\tconst modelDescription = currentModelPattern\n\t\t\t? `Model for background learning. \"active\" uses ${currentModelPattern}; configured subscription/API models are listed first.`\n\t\t\t: 'Model for background learning. Use \"active\" for the current session model, or choose a configured subscription/API model.';\n\t\tconst selectableModelOptions = buildAutoLearnModelOptions(this.state, modelOptions, currentModelPattern);\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"auto-learn-scope\",\n\t\t\t\tlabel: \"Save scope\",\n\t\t\t\tdescription: \"Save this Auto Learn configuration globally or in the current project's .pi/settings.json\",\n\t\t\t\tcurrentValue: this.scope,\n\t\t\t\tvalues: [\"global\", \"project\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"auto-learn-enabled\",\n\t\t\t\tlabel: \"Enabled\",\n\t\t\t\tdescription: \"Autonomously trigger background history scavenging for long sessions\",\n\t\t\t\tcurrentValue: booleanSettingValue(this.state.enabled),\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"auto-learn-model\",\n\t\t\t\tlabel: \"Scavenger model\",\n\t\t\t\tdescription: modelDescription,\n\t\t\t\tcurrentValue: autoLearnModelValue(this.state),\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew AutoLearnModelSelectionSubmenu(\n\t\t\t\t\t\tselectableModelOptions,\n\t\t\t\t\t\tautoLearnModelValue(this.state),\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\tthis.state = { ...this.state, model: value };\n\t\t\t\t\t\t\tonChange({ ...this.state }, this.scope);\n\t\t\t\t\t\t\tdone(autoLearnModelValue(this.state));\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: \"auto-learn-long-session-messages\",\n\t\t\t\tlabel: \"Message trigger\",\n\t\t\t\tdescription: \"Trigger after this many message entries in the active branch\",\n\t\t\t\tcurrentValue: numberSettingValue(this.state.longSessionMessages, AUTO_LEARN_DEFAULTS.longSessionMessages),\n\t\t\t\tvalues: [\"16\", \"32\", \"64\", \"128\", \"256\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"auto-learn-context-percent\",\n\t\t\t\tlabel: \"Context trigger %\",\n\t\t\t\tdescription: \"Trigger when current context usage reaches this percentage\",\n\t\t\t\tcurrentValue: numberSettingValue(\n\t\t\t\t\tthis.state.longSessionContextPercent,\n\t\t\t\t\tAUTO_LEARN_DEFAULTS.longSessionContextPercent,\n\t\t\t\t),\n\t\t\t\tvalues: [\"50\", \"60\", \"70\", \"80\", \"90\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"auto-learn-cooldown-minutes\",\n\t\t\t\tlabel: \"Cooldown minutes\",\n\t\t\t\tdescription: \"Per-session-tenant cooldown between learner launches\",\n\t\t\t\tcurrentValue: numberSettingValue(this.state.cooldownMinutes, AUTO_LEARN_DEFAULTS.cooldownMinutes),\n\t\t\t\tvalues: [\"15\", \"30\", \"60\", \"120\", \"240\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"auto-learn-lease-minutes\",\n\t\t\t\tlabel: \"Lease minutes\",\n\t\t\t\tdescription: \"Shared-state lease duration for a running background learner\",\n\t\t\t\tcurrentValue: numberSettingValue(this.state.leaseMinutes, AUTO_LEARN_DEFAULTS.leaseMinutes),\n\t\t\t\tvalues: [\"30\", \"60\", \"90\", \"180\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"auto-learn-max-concurrent\",\n\t\t\t\tlabel: \"Max learners\",\n\t\t\t\tdescription: \"Maximum running Auto Learn background learners across all session tenants\",\n\t\t\t\tcurrentValue: numberSettingValue(\n\t\t\t\t\tthis.state.maxConcurrentLearners,\n\t\t\t\t\tAUTO_LEARN_DEFAULTS.maxConcurrentLearners,\n\t\t\t\t),\n\t\t\t\tvalues: [\"1\", \"2\", \"3\", \"4\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"auto-learn-apply-high-confidence\",\n\t\t\t\tlabel: \"Apply high confidence\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Allow high-confidence memory candidates to be applied automatically; broader write authority follows autonomy.mode\",\n\t\t\t\tcurrentValue: booleanSettingValue(this.state.applyHighConfidence, AUTO_LEARN_DEFAULTS.applyHighConfidence),\n\t\t\t\tvalues: [\"false\", \"true\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"auto-learn-reflection-review\",\n\t\t\t\tlabel: \"Reflection review\",\n\t\t\t\tdescription: \"After corrective or complex turns, launch a bounded background learning review\",\n\t\t\t\tcurrentValue: booleanSettingValue(this.state.reflectionReview, AUTO_LEARN_DEFAULTS.reflectionReview),\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"auto-learn-reflection-tool-calls\",\n\t\t\t\tlabel: \"Reflection tool trigger\",\n\t\t\t\tdescription: \"Trigger reflection review after this many tool calls in one completed turn\",\n\t\t\t\tcurrentValue: numberSettingValue(\n\t\t\t\t\tthis.state.reflectionMinToolCalls,\n\t\t\t\t\tAUTO_LEARN_DEFAULTS.reflectionMinToolCalls,\n\t\t\t\t),\n\t\t\t\tvalues: [\"3\", \"5\", \"8\", \"12\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"auto-learn-reflection-cooldown\",\n\t\t\t\tlabel: \"Reflection cooldown\",\n\t\t\t\tdescription: \"Per-session-tenant cooldown between reflection-review launches\",\n\t\t\t\tcurrentValue: numberSettingValue(\n\t\t\t\t\tthis.state.reflectionCooldownMinutes,\n\t\t\t\t\tAUTO_LEARN_DEFAULTS.reflectionCooldownMinutes,\n\t\t\t\t),\n\t\t\t\tvalues: [\"15\", \"30\", \"60\", \"120\"],\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 \"auto-learn-scope\":\n\t\t\t\t\t\tthis.scope = newValue as SettingsScope;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"auto-learn-enabled\":\n\t\t\t\t\t\tthis.state = { ...this.state, enabled: newValue === \"true\" };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"auto-learn-long-session-messages\":\n\t\t\t\t\t\tthis.state = { ...this.state, longSessionMessages: parseInt(newValue, 10) };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"auto-learn-context-percent\":\n\t\t\t\t\t\tthis.state = { ...this.state, longSessionContextPercent: parseInt(newValue, 10) };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"auto-learn-cooldown-minutes\":\n\t\t\t\t\t\tthis.state = { ...this.state, cooldownMinutes: parseInt(newValue, 10) };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"auto-learn-lease-minutes\":\n\t\t\t\t\t\tthis.state = { ...this.state, leaseMinutes: parseInt(newValue, 10) };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"auto-learn-max-concurrent\":\n\t\t\t\t\t\tthis.state = { ...this.state, maxConcurrentLearners: parseInt(newValue, 10) };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"auto-learn-apply-high-confidence\":\n\t\t\t\t\t\tthis.state = { ...this.state, applyHighConfidence: newValue === \"true\" };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"auto-learn-reflection-review\":\n\t\t\t\t\t\tthis.state = { ...this.state, reflectionReview: newValue === \"true\" };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"auto-learn-reflection-tool-calls\":\n\t\t\t\t\t\tthis.state = { ...this.state, reflectionMinToolCalls: parseInt(newValue, 10) };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"auto-learn-reflection-cooldown\":\n\t\t\t\t\t\tthis.state = { ...this.state, reflectionCooldownMinutes: parseInt(newValue, 10) };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tonChange({ ...this.state }, this.scope);\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 * 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\t\tlet currentSelfModification: SelfModificationSettings = { ...config.selfModification };\n\t\tlet currentAutonomy: AutonomySettings = { ...config.autonomy };\n\t\tlet currentAutoLearn: AutoLearnSettings = { ...config.autoLearn };\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: \"http-idle-timeout\",\n\t\t\t\tlabel: \"HTTP idle timeout\",\n\t\t\t\tdescription:\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\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: \"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: \"self-modification\",\n\t\t\t\tlabel: \"Self modification\",\n\t\t\t\tdescription: \"Enable Pi self-evolution guardrails and configure the editable pi-adaptative source checkout\",\n\t\t\t\tcurrentValue: selfModificationSummary(currentSelfModification),\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew SelfModificationSettingsSubmenu(\n\t\t\t\t\t\tcurrentSelfModification,\n\t\t\t\t\t\t(settings, scope) => {\n\t\t\t\t\t\t\tcurrentSelfModification = { ...settings };\n\t\t\t\t\t\t\tcallbacks.onSelfModificationChange(settings, scope);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => done(selfModificationSummary(currentSelfModification)),\n\t\t\t\t\t\tconfig.selfModificationScope ?? \"global\",\n\t\t\t\t\t),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"autonomy\",\n\t\t\t\tlabel: \"Autonomy\",\n\t\t\t\tdescription: \"Choose one autonomy preset instead of tuning many background-learning knobs\",\n\t\t\t\tcurrentValue: autonomySummary(currentAutonomy),\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew AutonomySettingsSubmenu(\n\t\t\t\t\t\tcurrentAutonomy,\n\t\t\t\t\t\t(settings, scope) => {\n\t\t\t\t\t\t\tcurrentAutonomy = { ...settings };\n\t\t\t\t\t\t\tcallbacks.onAutonomyChange(settings, scope);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => done(autonomySummary(currentAutonomy)),\n\t\t\t\t\t\tconfig.autonomyScope ?? \"global\",\n\t\t\t\t\t),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"auto-learn\",\n\t\t\t\tlabel: \"Auto Learn Advanced\",\n\t\t\t\tdescription: \"Advanced overrides for autonomous background learning/scavenging\",\n\t\t\t\tcurrentValue: autoLearnSummary(currentAutoLearn),\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew AutoLearnSettingsSubmenu(\n\t\t\t\t\t\tcurrentAutoLearn,\n\t\t\t\t\t\tconfig.currentModelPattern,\n\t\t\t\t\t\tconfig.autoLearnModelOptions,\n\t\t\t\t\t\t(settings, scope) => {\n\t\t\t\t\t\t\tcurrentAutoLearn = { ...settings };\n\t\t\t\t\t\t\tcallbacks.onAutoLearnChange(settings, scope);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => done(autoLearnSummary(currentAutoLearn)),\n\t\t\t\t\t\tconfig.autoLearnScope ?? \"global\",\n\t\t\t\t\t),\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 \"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\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 \"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,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACN,SAAS,EAIT,KAAK,UAAU,EAIf,YAAY,EAGZ,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EACX,iBAAiB,EAEjB,gBAAgB,EAChB,wBAAwB,EACxB,aAAa,EACb,eAAe,EACf,MAAM,mCAAmC,CAAC;AAqH3C,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,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,aAAa,CAAC;IAC7B,uBAAuB,EAAE,aAAa,EAA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IAAI,CAAC;IAClD,4BAA4B,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACzD,gBAAgB,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,CAAC;IACtD,wBAAwB,EAAE,CAAC,QAAQ,EAAE,wBAAwB,EAAE,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC7F,gBAAgB,EAAE,CAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC7E,iBAAiB,EAAE,CAAC,QAAQ,EAAE,iBAAiB,EAAE,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC/E,QAAQ,EAAE,MAAM,IAAI,CAAC;CACrB;AAwjBD;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,SAAS;IACvD,OAAO,CAAC,YAAY,CAAe;IAEnC,YAAY,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,iBAAiB,EAwY/D;IAED,eAAe,IAAI,YAAY,CAE9B;CACD","sourcesContent":["import type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Transport } from \"@earendil-works/pi-ai\";\nimport {\n\tContainer,\n\tgetCapabilities,\n\tgetKeybindings,\n\tInput,\n\ttype SelectItem,\n\tSelectList,\n\ttype SelectListLayoutOptions,\n\ttype SettingItem,\n\tSettingsList,\n\tSpacer,\n\tText,\n} from \"@earendil-works/pi-tui\";\nimport { formatHttpIdleTimeoutMs, HTTP_IDLE_TIMEOUT_CHOICES } from \"../../../core/http-dispatcher.ts\";\nimport type {\n\tAutoLearnSettings,\n\tAutonomyMode,\n\tAutonomySettings,\n\tSelfModificationSettings,\n\tSettingsScope,\n\tWarningSettings,\n} from \"../../../core/settings-manager.ts\";\nimport { getSelectListTheme, getSettingsListTheme, theme } from \"../theme/theme.ts\";\nimport { DynamicBorder } from \"./dynamic-border.ts\";\nimport { keyDisplayText } from \"./keybinding-hints.ts\";\n\nconst SETTINGS_SUBMENU_SELECT_LIST_LAYOUT: SelectListLayoutOptions = {\n\tminPrimaryColumnWidth: 12,\n\tmaxPrimaryColumnWidth: 32,\n};\n\nconst AUTO_LEARN_CUSTOM_MODEL_VALUE = \"__custom_auto_learn_model__\";\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\nconst AUTONOMY_MODES: AutonomyMode[] = [\"off\", \"safe\", \"balanced\", \"full\"];\n\nconst AUTO_LEARN_DEFAULTS = {\n\tmodel: \"active\",\n\tlongSessionMessages: 32,\n\tlongSessionContextPercent: 70,\n\tcooldownMinutes: 120,\n\tleaseMinutes: 90,\n\tmaxConcurrentLearners: 2,\n\tapplyHighConfidence: false,\n\treflectionReview: true,\n\treflectionMinToolCalls: 5,\n\treflectionCooldownMinutes: 60,\n} as const;\n\nfunction booleanSettingValue(value: boolean | undefined, defaultValue = false): string {\n\treturn (value ?? defaultValue) ? \"true\" : \"false\";\n}\n\nfunction optionalStringValue(value: string | undefined, fallback = \"(not set)\"): string {\n\tconst trimmed = value?.trim();\n\treturn trimmed && trimmed.length > 0 ? trimmed : fallback;\n}\n\nfunction normalizeOptionalString(value: string): string | undefined {\n\tconst trimmed = value.trim();\n\treturn trimmed.length > 0 ? trimmed : undefined;\n}\n\nfunction numberSettingValue(value: number | undefined, defaultValue: number): string {\n\treturn String(value ?? defaultValue);\n}\n\nfunction autoLearnModelValue(settings: AutoLearnSettings): string {\n\treturn optionalStringValue(settings.model, AUTO_LEARN_DEFAULTS.model);\n}\n\nfunction selfModificationSummary(settings: SelfModificationSettings): string {\n\tif (!(settings.enabled ?? false)) return \"disabled\";\n\treturn optionalStringValue(settings.sourcePath) === \"(not set)\" ? \"enabled (missing path)\" : \"enabled\";\n}\n\nfunction autonomyModeValue(settings: AutonomySettings): AutonomyMode {\n\treturn settings.mode && AUTONOMY_MODES.includes(settings.mode) ? settings.mode : \"off\";\n}\n\nfunction autonomySummary(settings: AutonomySettings): string {\n\tconst mode = autonomyModeValue(settings);\n\treturn mode === \"full\" ? \"standing autonomy\" : mode;\n}\n\nfunction autoLearnSummary(settings: AutoLearnSettings): string {\n\treturn settings.enabled ? `enabled (${autoLearnModelValue(settings)})` : \"disabled\";\n}\n\nfunction buildAutoLearnModelOptions(\n\tsettings: AutoLearnSettings,\n\tconfiguredModelOptions: SelectItem[] | undefined,\n\tcurrentModelPattern: string | undefined,\n): SelectItem[] {\n\tconst currentValue = autoLearnModelValue(settings);\n\tconst options: SelectItem[] = [\n\t\t{\n\t\t\tvalue: AUTO_LEARN_DEFAULTS.model,\n\t\t\tlabel: \"active\",\n\t\t\tdescription: currentModelPattern\n\t\t\t\t? `Use the current session model (${currentModelPattern})`\n\t\t\t\t: \"Use the current session model\",\n\t\t},\n\t];\n\tconst seen = new Set(options.map((option) => option.value));\n\n\tfor (const option of configuredModelOptions ?? []) {\n\t\tif (seen.has(option.value)) continue;\n\t\toptions.push(option);\n\t\tseen.add(option.value);\n\t}\n\n\tif (currentValue !== AUTO_LEARN_DEFAULTS.model && !seen.has(currentValue)) {\n\t\toptions.push({\n\t\t\tvalue: currentValue,\n\t\t\tlabel: currentValue,\n\t\t\tdescription: \"Current custom setting\",\n\t\t});\n\t\tseen.add(currentValue);\n\t}\n\n\toptions.push({\n\t\tvalue: AUTO_LEARN_CUSTOM_MODEL_VALUE,\n\t\tlabel: \"Manual / custom…\",\n\t\tdescription: \"Type a model pattern not listed above\",\n\t});\n\n\treturn options;\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\thttpIdleTimeoutMs: number;\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\tselfModification: { enabled: boolean; sourcePath?: string };\n\tselfModificationScope?: SettingsScope;\n\tautonomy: AutonomySettings;\n\tautonomyScope?: SettingsScope;\n\tautoLearn: AutoLearnSettings;\n\tautoLearnScope?: SettingsScope;\n\tcurrentModelPattern?: string;\n\tautoLearnModelOptions?: SelectItem[];\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\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\tonSelfModificationChange: (settings: SelfModificationSettings, scope: SettingsScope) => void;\n\tonAutonomyChange: (settings: AutonomySettings, scope: SettingsScope) => void;\n\tonAutoLearnChange: (settings: AutoLearnSettings, scope: SettingsScope) => void;\n\tonCancel: () => void;\n}\n\nclass TextInputSubmenu extends Container {\n\tprivate input: Input;\n\n\tconstructor(\n\t\ttitle: string,\n\t\tdescription: string,\n\t\tcurrentValue: string,\n\t\tonSubmit: (value: string) => void,\n\t\tonCancel: () => void,\n\t\temptyHint = \"empty clears the setting\",\n\t) {\n\t\tsuper();\n\n\t\tthis.addChild(new Text(theme.bold(theme.fg(\"accent\", title)), 0, 0));\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\t\tthis.addChild(new Spacer(1));\n\n\t\tthis.input = new Input();\n\t\tthis.input.setValue(currentValue);\n\t\tthis.input.focused = true;\n\t\tthis.input.onSubmit = onSubmit;\n\t\tthis.input.onEscape = onCancel;\n\t\tthis.addChild(this.input);\n\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(new Text(theme.fg(\"dim\", ` Enter to save · Esc to go back · ${emptyHint}`), 0, 0));\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.input.handleInput(data);\n\t}\n}\n\nclass AutoLearnModelSelectionSubmenu extends Container {\n\tprivate searchInput: Input;\n\tprivate selectList: SelectList;\n\tprivate customInput: TextInputSubmenu | null = null;\n\n\tconstructor(options: SelectItem[], currentValue: string, onSelect: (value: string) => void, onCancel: () => void) {\n\t\tsuper();\n\n\t\tthis.addChild(new Text(theme.bold(theme.fg(\"accent\", \"Auto Learn Scavenger Model\")), 0, 0));\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(\n\t\t\tnew Text(\n\t\t\t\ttheme.fg(\n\t\t\t\t\t\"muted\",\n\t\t\t\t\t\"Choose active or a model from currently configured subscription/API accounts. Type to filter; choose manual for a custom pattern.\",\n\t\t\t\t),\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t),\n\t\t);\n\t\tthis.addChild(new Spacer(1));\n\n\t\tthis.searchInput = new Input();\n\t\tthis.searchInput.focused = true;\n\t\tthis.addChild(this.searchInput);\n\t\tthis.addChild(new Spacer(1));\n\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\tconst currentIndex = options.findIndex((option) => option.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\tif (item.value === AUTO_LEARN_CUSTOM_MODEL_VALUE) {\n\t\t\t\tthis.customInput = new TextInputSubmenu(\n\t\t\t\t\t\"Custom Auto Learn Model\",\n\t\t\t\t\t'Enter \"active\" or a provider/model pattern like \"openai/gpt-5.4\".',\n\t\t\t\t\tcurrentValue === AUTO_LEARN_DEFAULTS.model ? \"\" : currentValue,\n\t\t\t\t\t(value) => {\n\t\t\t\t\t\tonSelect(normalizeOptionalString(value) ?? AUTO_LEARN_DEFAULTS.model);\n\t\t\t\t\t},\n\t\t\t\t\t() => {\n\t\t\t\t\t\tthis.customInput = null;\n\t\t\t\t\t},\n\t\t\t\t\t'empty uses \"active\"',\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonSelect(item.value);\n\t\t};\n\t\tthis.selectList.onCancel = onCancel;\n\t\tthis.addChild(this.selectList);\n\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(new Text(theme.fg(\"dim\", \" Type to filter · Enter to select · Esc to go back\"), 0, 0));\n\t}\n\n\thandleInput(data: string): void {\n\t\tif (this.customInput) {\n\t\t\tthis.customInput.handleInput(data);\n\t\t\treturn;\n\t\t}\n\n\t\tconst kb = getKeybindings();\n\t\tif (kb.matches(data, \"tui.select.up\") || kb.matches(data, \"tui.select.down\")) {\n\t\t\tthis.selectList.handleInput(data);\n\t\t\treturn;\n\t\t}\n\t\tif (kb.matches(data, \"tui.select.confirm\") || kb.matches(data, \"tui.select.cancel\")) {\n\t\t\tthis.selectList.handleInput(data);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.searchInput.handleInput(data);\n\t\tthis.selectList.setFilter(this.searchInput.getValue());\n\t}\n\n\trender(width: number): string[] {\n\t\treturn this.customInput ? this.customInput.render(width) : super.render(width);\n\t}\n\n\tinvalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.customInput?.invalidate?.();\n\t}\n}\n\nclass SelfModificationSettingsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\tprivate state: SelfModificationSettings;\n\tprivate scope: SettingsScope;\n\n\tconstructor(\n\t\tsettings: SelfModificationSettings,\n\t\tonChange: (settings: SelfModificationSettings, scope: SettingsScope) => void,\n\t\tonCancel: () => void,\n\t\tscope: SettingsScope = \"global\",\n\t) {\n\t\tsuper();\n\n\t\tthis.state = { ...settings, enabled: settings.enabled ?? false };\n\t\tthis.scope = scope;\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"self-modification-scope\",\n\t\t\t\tlabel: \"Save scope\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Save this self-modification configuration globally or in the current project's .pi/settings.json\",\n\t\t\t\tcurrentValue: this.scope,\n\t\t\t\tvalues: [\"global\", \"project\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"self-modification-enabled\",\n\t\t\t\tlabel: \"Enabled\",\n\t\t\t\tdescription: \"Allow agents to modify Pi's own source/harness only when explicitly tasked\",\n\t\t\t\tcurrentValue: booleanSettingValue(this.state.enabled),\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"self-modification-source-path\",\n\t\t\t\tlabel: \"Source path\",\n\t\t\t\tdescription: \"Path to the pi-adaptative source checkout agents may edit for self-evolution\",\n\t\t\t\tcurrentValue: optionalStringValue(this.state.sourcePath),\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew TextInputSubmenu(\n\t\t\t\t\t\t\"Pi-adaptative Source Path\",\n\t\t\t\t\t\t\"Set the source checkout path used by self-evolution guardrails. Empty clears it.\",\n\t\t\t\t\t\tthis.state.sourcePath ?? \"\",\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\tconst sourcePath = normalizeOptionalString(value);\n\t\t\t\t\t\t\tthis.state = { ...this.state, sourcePath };\n\t\t\t\t\t\t\tonChange({ ...this.state }, this.scope);\n\t\t\t\t\t\t\tdone(optionalStringValue(sourcePath));\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\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 \"self-modification-scope\":\n\t\t\t\t\t\tthis.scope = newValue as SettingsScope;\n\t\t\t\t\t\tonChange({ ...this.state }, this.scope);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"self-modification-enabled\":\n\t\t\t\t\t\tthis.state = { ...this.state, enabled: newValue === \"true\" };\n\t\t\t\t\t\tonChange({ ...this.state }, this.scope);\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 AutonomySettingsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\tprivate state: AutonomySettings;\n\tprivate scope: SettingsScope;\n\n\tconstructor(\n\t\tsettings: AutonomySettings,\n\t\tonChange: (settings: AutonomySettings, scope: SettingsScope) => void,\n\t\tonCancel: () => void,\n\t\tscope: SettingsScope = \"global\",\n\t) {\n\t\tsuper();\n\t\tthis.state = { mode: autonomyModeValue(settings) };\n\t\tthis.scope = scope;\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"autonomy-scope\",\n\t\t\t\tlabel: \"Save scope\",\n\t\t\t\tdescription: \"Save this autonomy preset globally or in the current project's .pi/settings.json\",\n\t\t\t\tcurrentValue: this.scope,\n\t\t\t\tvalues: [\"global\", \"project\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"autonomy-mode\",\n\t\t\t\tlabel: \"Mode\",\n\t\t\t\tdescription: \"One preset for background learning: off, safe, balanced, or standing autonomy\",\n\t\t\t\tcurrentValue: autonomyModeValue(this.state),\n\t\t\t\tvalues: AUTONOMY_MODES,\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 \"autonomy-scope\":\n\t\t\t\t\t\tthis.scope = newValue as SettingsScope;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"autonomy-mode\":\n\t\t\t\t\t\tthis.state = { ...this.state, mode: newValue as AutonomyMode };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tonChange({ ...this.state }, this.scope);\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 AutoLearnSettingsSubmenu extends Container {\n\tprivate settingsList: SettingsList;\n\tprivate state: AutoLearnSettings;\n\tprivate scope: SettingsScope;\n\n\tconstructor(\n\t\tsettings: AutoLearnSettings,\n\t\tcurrentModelPattern: string | undefined,\n\t\tmodelOptions: SelectItem[] | undefined,\n\t\tonChange: (settings: AutoLearnSettings, scope: SettingsScope) => void,\n\t\tonCancel: () => void,\n\t\tscope: SettingsScope = \"global\",\n\t) {\n\t\tsuper();\n\n\t\tthis.state = { ...settings };\n\t\tthis.scope = scope;\n\t\tconst modelDescription = currentModelPattern\n\t\t\t? `Model for background learning. \"active\" uses ${currentModelPattern}; configured subscription/API models are listed first.`\n\t\t\t: 'Model for background learning. Use \"active\" for the current session model, or choose a configured subscription/API model.';\n\t\tconst selectableModelOptions = buildAutoLearnModelOptions(this.state, modelOptions, currentModelPattern);\n\n\t\tconst items: SettingItem[] = [\n\t\t\t{\n\t\t\t\tid: \"auto-learn-scope\",\n\t\t\t\tlabel: \"Save scope\",\n\t\t\t\tdescription: \"Save this Auto Learn configuration globally or in the current project's .pi/settings.json\",\n\t\t\t\tcurrentValue: this.scope,\n\t\t\t\tvalues: [\"global\", \"project\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"auto-learn-enabled\",\n\t\t\t\tlabel: \"Enabled\",\n\t\t\t\tdescription: \"Autonomously trigger background history scavenging for long sessions\",\n\t\t\t\tcurrentValue: booleanSettingValue(this.state.enabled),\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"auto-learn-model\",\n\t\t\t\tlabel: \"Scavenger model\",\n\t\t\t\tdescription: modelDescription,\n\t\t\t\tcurrentValue: autoLearnModelValue(this.state),\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew AutoLearnModelSelectionSubmenu(\n\t\t\t\t\t\tselectableModelOptions,\n\t\t\t\t\t\tautoLearnModelValue(this.state),\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\tthis.state = { ...this.state, model: value };\n\t\t\t\t\t\t\tonChange({ ...this.state }, this.scope);\n\t\t\t\t\t\t\tdone(autoLearnModelValue(this.state));\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: \"auto-learn-long-session-messages\",\n\t\t\t\tlabel: \"Message trigger\",\n\t\t\t\tdescription: \"Trigger after this many message entries in the active branch\",\n\t\t\t\tcurrentValue: numberSettingValue(this.state.longSessionMessages, AUTO_LEARN_DEFAULTS.longSessionMessages),\n\t\t\t\tvalues: [\"16\", \"32\", \"64\", \"128\", \"256\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"auto-learn-context-percent\",\n\t\t\t\tlabel: \"Context trigger %\",\n\t\t\t\tdescription: \"Trigger when current context usage reaches this percentage\",\n\t\t\t\tcurrentValue: numberSettingValue(\n\t\t\t\t\tthis.state.longSessionContextPercent,\n\t\t\t\t\tAUTO_LEARN_DEFAULTS.longSessionContextPercent,\n\t\t\t\t),\n\t\t\t\tvalues: [\"50\", \"60\", \"70\", \"80\", \"90\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"auto-learn-cooldown-minutes\",\n\t\t\t\tlabel: \"Cooldown minutes\",\n\t\t\t\tdescription: \"Per-session-tenant cooldown between learner launches\",\n\t\t\t\tcurrentValue: numberSettingValue(this.state.cooldownMinutes, AUTO_LEARN_DEFAULTS.cooldownMinutes),\n\t\t\t\tvalues: [\"15\", \"30\", \"60\", \"120\", \"240\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"auto-learn-lease-minutes\",\n\t\t\t\tlabel: \"Lease minutes\",\n\t\t\t\tdescription: \"Shared-state lease duration for a running background learner\",\n\t\t\t\tcurrentValue: numberSettingValue(this.state.leaseMinutes, AUTO_LEARN_DEFAULTS.leaseMinutes),\n\t\t\t\tvalues: [\"30\", \"60\", \"90\", \"180\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"auto-learn-max-concurrent\",\n\t\t\t\tlabel: \"Max learners\",\n\t\t\t\tdescription: \"Maximum running Auto Learn background learners per session tenant\",\n\t\t\t\tcurrentValue: numberSettingValue(\n\t\t\t\t\tthis.state.maxConcurrentLearners,\n\t\t\t\t\tAUTO_LEARN_DEFAULTS.maxConcurrentLearners,\n\t\t\t\t),\n\t\t\t\tvalues: [\"1\", \"2\", \"3\", \"4\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"auto-learn-apply-high-confidence\",\n\t\t\t\tlabel: \"Apply high confidence\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Allow high-confidence memory candidates to be applied automatically; broader write authority follows autonomy.mode\",\n\t\t\t\tcurrentValue: booleanSettingValue(this.state.applyHighConfidence, AUTO_LEARN_DEFAULTS.applyHighConfidence),\n\t\t\t\tvalues: [\"false\", \"true\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"auto-learn-reflection-review\",\n\t\t\t\tlabel: \"Reflection review\",\n\t\t\t\tdescription: \"After corrective or complex turns, launch a bounded background learning review\",\n\t\t\t\tcurrentValue: booleanSettingValue(this.state.reflectionReview, AUTO_LEARN_DEFAULTS.reflectionReview),\n\t\t\t\tvalues: [\"true\", \"false\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"auto-learn-reflection-tool-calls\",\n\t\t\t\tlabel: \"Reflection tool trigger\",\n\t\t\t\tdescription: \"Trigger reflection review after this many tool calls in one completed turn\",\n\t\t\t\tcurrentValue: numberSettingValue(\n\t\t\t\t\tthis.state.reflectionMinToolCalls,\n\t\t\t\t\tAUTO_LEARN_DEFAULTS.reflectionMinToolCalls,\n\t\t\t\t),\n\t\t\t\tvalues: [\"3\", \"5\", \"8\", \"12\"],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"auto-learn-reflection-cooldown\",\n\t\t\t\tlabel: \"Reflection cooldown\",\n\t\t\t\tdescription: \"Per-session-tenant cooldown between reflection-review launches\",\n\t\t\t\tcurrentValue: numberSettingValue(\n\t\t\t\t\tthis.state.reflectionCooldownMinutes,\n\t\t\t\t\tAUTO_LEARN_DEFAULTS.reflectionCooldownMinutes,\n\t\t\t\t),\n\t\t\t\tvalues: [\"15\", \"30\", \"60\", \"120\"],\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 \"auto-learn-scope\":\n\t\t\t\t\t\tthis.scope = newValue as SettingsScope;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"auto-learn-enabled\":\n\t\t\t\t\t\tthis.state = { ...this.state, enabled: newValue === \"true\" };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"auto-learn-long-session-messages\":\n\t\t\t\t\t\tthis.state = { ...this.state, longSessionMessages: parseInt(newValue, 10) };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"auto-learn-context-percent\":\n\t\t\t\t\t\tthis.state = { ...this.state, longSessionContextPercent: parseInt(newValue, 10) };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"auto-learn-cooldown-minutes\":\n\t\t\t\t\t\tthis.state = { ...this.state, cooldownMinutes: parseInt(newValue, 10) };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"auto-learn-lease-minutes\":\n\t\t\t\t\t\tthis.state = { ...this.state, leaseMinutes: parseInt(newValue, 10) };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"auto-learn-max-concurrent\":\n\t\t\t\t\t\tthis.state = { ...this.state, maxConcurrentLearners: parseInt(newValue, 10) };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"auto-learn-apply-high-confidence\":\n\t\t\t\t\t\tthis.state = { ...this.state, applyHighConfidence: newValue === \"true\" };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"auto-learn-reflection-review\":\n\t\t\t\t\t\tthis.state = { ...this.state, reflectionReview: newValue === \"true\" };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"auto-learn-reflection-tool-calls\":\n\t\t\t\t\t\tthis.state = { ...this.state, reflectionMinToolCalls: parseInt(newValue, 10) };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"auto-learn-reflection-cooldown\":\n\t\t\t\t\t\tthis.state = { ...this.state, reflectionCooldownMinutes: parseInt(newValue, 10) };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tonChange({ ...this.state }, this.scope);\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 * 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\t\tlet currentSelfModification: SelfModificationSettings = { ...config.selfModification };\n\t\tlet currentAutonomy: AutonomySettings = { ...config.autonomy };\n\t\tlet currentAutoLearn: AutoLearnSettings = { ...config.autoLearn };\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: \"http-idle-timeout\",\n\t\t\t\tlabel: \"HTTP idle timeout\",\n\t\t\t\tdescription:\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\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: \"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: \"self-modification\",\n\t\t\t\tlabel: \"Self modification\",\n\t\t\t\tdescription: \"Enable Pi self-evolution guardrails and configure the editable pi-adaptative source checkout\",\n\t\t\t\tcurrentValue: selfModificationSummary(currentSelfModification),\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew SelfModificationSettingsSubmenu(\n\t\t\t\t\t\tcurrentSelfModification,\n\t\t\t\t\t\t(settings, scope) => {\n\t\t\t\t\t\t\tcurrentSelfModification = { ...settings };\n\t\t\t\t\t\t\tcallbacks.onSelfModificationChange(settings, scope);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => done(selfModificationSummary(currentSelfModification)),\n\t\t\t\t\t\tconfig.selfModificationScope ?? \"global\",\n\t\t\t\t\t),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"autonomy\",\n\t\t\t\tlabel: \"Autonomy\",\n\t\t\t\tdescription: \"Choose one autonomy preset instead of tuning many background-learning knobs\",\n\t\t\t\tcurrentValue: autonomySummary(currentAutonomy),\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew AutonomySettingsSubmenu(\n\t\t\t\t\t\tcurrentAutonomy,\n\t\t\t\t\t\t(settings, scope) => {\n\t\t\t\t\t\t\tcurrentAutonomy = { ...settings };\n\t\t\t\t\t\t\tcallbacks.onAutonomyChange(settings, scope);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => done(autonomySummary(currentAutonomy)),\n\t\t\t\t\t\tconfig.autonomyScope ?? \"global\",\n\t\t\t\t\t),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"auto-learn\",\n\t\t\t\tlabel: \"Auto Learn Advanced\",\n\t\t\t\tdescription: \"Advanced overrides for autonomous background learning/scavenging\",\n\t\t\t\tcurrentValue: autoLearnSummary(currentAutoLearn),\n\t\t\t\tsubmenu: (_currentValue, done) =>\n\t\t\t\t\tnew AutoLearnSettingsSubmenu(\n\t\t\t\t\t\tcurrentAutoLearn,\n\t\t\t\t\t\tconfig.currentModelPattern,\n\t\t\t\t\t\tconfig.autoLearnModelOptions,\n\t\t\t\t\t\t(settings, scope) => {\n\t\t\t\t\t\t\tcurrentAutoLearn = { ...settings };\n\t\t\t\t\t\t\tcallbacks.onAutoLearnChange(settings, scope);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => done(autoLearnSummary(currentAutoLearn)),\n\t\t\t\t\t\tconfig.autoLearnScope ?? \"global\",\n\t\t\t\t\t),\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 \"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\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 \"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"]}
|
|
@@ -343,7 +343,7 @@ class AutoLearnSettingsSubmenu extends Container {
|
|
|
343
343
|
{
|
|
344
344
|
id: "auto-learn-max-concurrent",
|
|
345
345
|
label: "Max learners",
|
|
346
|
-
description: "Maximum running Auto Learn background learners
|
|
346
|
+
description: "Maximum running Auto Learn background learners per session tenant",
|
|
347
347
|
currentValue: numberSettingValue(this.state.maxConcurrentLearners, AUTO_LEARN_DEFAULTS.maxConcurrentLearners),
|
|
348
348
|
values: ["1", "2", "3", "4"],
|
|
349
349
|
},
|