@ai-agent-forge/agent-forge 0.88.2 → 0.88.4

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.
Files changed (460) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +1 -1
  3. package/bundled-plugins/agent-loop-policy/agent-forge.json +1 -1
  4. package/bundled-plugins/agent-loop-policy/plugin.json +1 -1
  5. package/bundled-plugins/coding-tools/agent-forge.json +1 -1
  6. package/bundled-plugins/coding-tools/plugin.json +1 -1
  7. package/bundled-plugins/compaction-policy/agent-forge.json +1 -1
  8. package/bundled-plugins/compaction-policy/plugin.json +1 -1
  9. package/bundled-plugins/overflow-policy/agent-forge.json +1 -1
  10. package/bundled-plugins/overflow-policy/plugin.json +1 -1
  11. package/bundled-plugins/provider-failover/agent-forge.json +1 -1
  12. package/bundled-plugins/provider-failover/plugin.json +1 -1
  13. package/bundled-plugins/retry-policy/agent-forge.json +1 -1
  14. package/bundled-plugins/retry-policy/plugin.json +1 -1
  15. package/dist/artifacts/paged-read.d.ts +6 -1
  16. package/dist/artifacts/paged-read.d.ts.map +1 -1
  17. package/dist/artifacts/paged-read.js.map +1 -1
  18. package/dist/bundle/.build-manifest.json +244 -234
  19. package/dist/bundle/chunks/{anthropic-messages-PLAKXR73.js → anthropic-messages-3FJHRAJL.js} +2 -2
  20. package/dist/bundle/chunks/anthropic.js +1 -1
  21. package/dist/bundle/chunks/{azure-openai-responses-OUWQ2AZD.js → azure-openai-responses-GCL47IDS.js} +1 -1
  22. package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
  23. package/dist/bundle/chunks/{chunk-6F5JWGKE.js → chunk-32YDZI4J.js} +1 -1
  24. package/dist/bundle/chunks/{chunk-LSP24WNH.js → chunk-755VNWIF.js} +12 -12
  25. package/dist/bundle/chunks/{chunk-DRQDKNXA.js → chunk-BVVSHK6W.js} +1 -1
  26. package/dist/bundle/chunks/{chunk-HTC5K5SM.js → chunk-HEL6TAWE.js} +95 -90
  27. package/dist/bundle/chunks/{chunk-6R7UI4IY.js → chunk-QDLOMKF6.js} +1 -1
  28. package/dist/bundle/chunks/{chunk-44I47ACN.js → chunk-V3ACW7VD.js} +1 -1
  29. package/dist/bundle/chunks/{google-generative-ai-DLII6DAT.js → google-generative-ai-6BMXWA44.js} +1 -1
  30. package/dist/bundle/chunks/{google-vertex-G7BZL7GM.js → google-vertex-6H7NLRTK.js} +1 -1
  31. package/dist/bundle/chunks/image-resize-worker.js +1 -1
  32. package/dist/bundle/chunks/{mistral-conversations-JXUK24ID.js → mistral-conversations-IXUHSFSJ.js} +1 -1
  33. package/dist/bundle/chunks/{openai-codex-responses-5GSGFIPG.js → openai-codex-responses-YHUAEVCM.js} +1 -1
  34. package/dist/bundle/chunks/openai-codex.js +1 -1
  35. package/dist/bundle/chunks/{openai-completions-EI2I6DTG.js → openai-completions-ULQCFC72.js} +1 -1
  36. package/dist/bundle/chunks/openai-responses-NLLAJDPS.js +2 -0
  37. package/dist/bundle/chunks/{openrouter-images-G4GQRUSG.js → openrouter-images-GZZQZXMS.js} +1 -1
  38. package/dist/bundle/chunks/openrouter.js +1 -1
  39. package/dist/bundle/chunks/{pi-messages-PWU2VJMR.js → pi-messages-EJTI2EJ3.js} +1 -1
  40. package/dist/bundle/chunks/virtual-modules-TQWEGNNZ.js +5 -0
  41. package/dist/bundle/cli.js +1 -1
  42. package/dist/bundle/client.js +1 -1
  43. package/dist/bundle/index.js +1 -1
  44. package/dist/bundle/rpc-entry.js +1 -1
  45. package/dist/cli/args.d.ts +0 -1
  46. package/dist/cli/args.d.ts.map +1 -1
  47. package/dist/cli/args.js +1 -4
  48. package/dist/cli/args.js.map +1 -1
  49. package/dist/cli/config-selector.d.ts.map +1 -1
  50. package/dist/cli/config-selector.js +1 -1
  51. package/dist/cli/config-selector.js.map +1 -1
  52. package/dist/cli/experimental/cli.d.ts +3 -3
  53. package/dist/cli/experimental/cli.d.ts.map +1 -1
  54. package/dist/cli/experimental/cli.js +2 -2
  55. package/dist/cli/experimental/cli.js.map +1 -1
  56. package/dist/cli/experimental/commands/agent-forge.d.ts +15 -0
  57. package/dist/cli/experimental/commands/agent-forge.d.ts.map +1 -0
  58. package/dist/cli/experimental/commands/{pi.js → agent-forge.js} +4 -4
  59. package/dist/cli/experimental/commands/agent-forge.js.map +1 -0
  60. package/dist/cli/startup-ui.d.ts.map +1 -1
  61. package/dist/cli/startup-ui.js +1 -1
  62. package/dist/cli/startup-ui.js.map +1 -1
  63. package/dist/config.d.ts +4 -4
  64. package/dist/config.d.ts.map +1 -1
  65. package/dist/config.js +7 -7
  66. package/dist/config.js.map +1 -1
  67. package/dist/core/agent-forge-manifest.d.ts +7 -0
  68. package/dist/core/agent-forge-manifest.d.ts.map +1 -0
  69. package/dist/core/{pi-manifest.js → agent-forge-manifest.js} +4 -4
  70. package/dist/core/agent-forge-manifest.js.map +1 -0
  71. package/dist/core/agent-session-compaction.d.ts +1 -1
  72. package/dist/core/agent-session-compaction.d.ts.map +1 -1
  73. package/dist/core/agent-session-compaction.js +3 -3
  74. package/dist/core/agent-session-compaction.js.map +1 -1
  75. package/dist/core/agent-session-lifecycle.d.ts.map +1 -1
  76. package/dist/core/agent-session-lifecycle.js +12 -1
  77. package/dist/core/agent-session-lifecycle.js.map +1 -1
  78. package/dist/core/agent-session-projection.d.ts.map +1 -1
  79. package/dist/core/agent-session-projection.js +3 -3
  80. package/dist/core/agent-session-projection.js.map +1 -1
  81. package/dist/core/agent-session-services.d.ts +1 -1
  82. package/dist/core/agent-session-services.d.ts.map +1 -1
  83. package/dist/core/agent-session-services.js +1 -1
  84. package/dist/core/agent-session-services.js.map +1 -1
  85. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  86. package/dist/core/compaction/branch-summarization.js +1 -1
  87. package/dist/core/compaction/branch-summarization.js.map +1 -1
  88. package/dist/core/experimental.d.ts.map +1 -1
  89. package/dist/core/experimental.js +1 -3
  90. package/dist/core/experimental.js.map +1 -1
  91. package/dist/core/extensions/capability-plugin.d.ts.map +1 -1
  92. package/dist/core/extensions/capability-plugin.js +15 -8
  93. package/dist/core/extensions/capability-plugin.js.map +1 -1
  94. package/dist/core/extensions/capability-runtime-store.d.ts +20 -1
  95. package/dist/core/extensions/capability-runtime-store.d.ts.map +1 -1
  96. package/dist/core/extensions/capability-runtime-store.js +67 -0
  97. package/dist/core/extensions/capability-runtime-store.js.map +1 -1
  98. package/dist/core/extensions/capability-runtime-types.d.ts +14 -0
  99. package/dist/core/extensions/capability-runtime-types.d.ts.map +1 -1
  100. package/dist/core/extensions/capability-runtime-types.js +7 -1
  101. package/dist/core/extensions/capability-runtime-types.js.map +1 -1
  102. package/dist/core/extensions/capability-runtime.d.ts.map +1 -1
  103. package/dist/core/extensions/capability-runtime.js +144 -42
  104. package/dist/core/extensions/capability-runtime.js.map +1 -1
  105. package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
  106. package/dist/core/extensions/virtual-modules.js +12 -4
  107. package/dist/core/extensions/virtual-modules.js.map +1 -1
  108. package/dist/core/facade/coding-agent-facade.d.ts +1 -1
  109. package/dist/core/facade/coding-agent-facade.d.ts.map +1 -1
  110. package/dist/core/facade/coding-agent-facade.js +1 -1
  111. package/dist/core/facade/coding-agent-facade.js.map +1 -1
  112. package/dist/core/i18n/locales/zh-cn/core-contract-final.d.ts +1 -1
  113. package/dist/core/i18n/locales/zh-cn/core-contract-final.d.ts.map +1 -1
  114. package/dist/core/i18n/locales/zh-cn/core-contract-final.js +3 -3
  115. package/dist/core/i18n/locales/zh-cn/core-contract-final.js.map +1 -1
  116. package/dist/core/i18n/locales/zh-cn/core-contract-plugins.d.ts.map +1 -1
  117. package/dist/core/i18n/locales/zh-cn/core-contract-plugins.js +1 -1
  118. package/dist/core/i18n/locales/zh-cn/core-contract-plugins.js.map +1 -1
  119. package/dist/core/i18n/locales/zh-cn/core-errors.d.ts.map +1 -1
  120. package/dist/core/i18n/locales/zh-cn/core-errors.js +1 -1
  121. package/dist/core/i18n/locales/zh-cn/core-errors.js.map +1 -1
  122. package/dist/core/i18n/locales/zh-cn/tui-components-misc.d.ts.map +1 -1
  123. package/dist/core/i18n/locales/zh-cn/tui-components-misc.js +2 -0
  124. package/dist/core/i18n/locales/zh-cn/tui-components-misc.js.map +1 -1
  125. package/dist/core/model-resolver.d.ts +2 -0
  126. package/dist/core/model-resolver.d.ts.map +1 -1
  127. package/dist/core/model-resolver.js +4 -1
  128. package/dist/core/model-resolver.js.map +1 -1
  129. package/dist/core/package-resource-collection.d.ts.map +1 -1
  130. package/dist/core/package-resource-collection.js +5 -5
  131. package/dist/core/package-resource-collection.js.map +1 -1
  132. package/dist/core/provider-composer.d.ts.map +1 -1
  133. package/dist/core/provider-composer.js +3 -3
  134. package/dist/core/provider-composer.js.map +1 -1
  135. package/dist/core/resource-loader.d.ts.map +1 -1
  136. package/dist/core/resource-loader.js +1 -1
  137. package/dist/core/resource-loader.js.map +1 -1
  138. package/dist/core/sdk.d.ts +1 -1
  139. package/dist/core/sdk.d.ts.map +1 -1
  140. package/dist/core/sdk.js +6 -7
  141. package/dist/core/sdk.js.map +1 -1
  142. package/dist/core/session-manager.d.ts.map +1 -1
  143. package/dist/core/session-manager.js +4 -4
  144. package/dist/core/session-manager.js.map +1 -1
  145. package/dist/core/settings-manager.d.ts.map +1 -1
  146. package/dist/core/settings-manager.js +5 -10
  147. package/dist/core/settings-manager.js.map +1 -1
  148. package/dist/core/timings.d.ts.map +1 -1
  149. package/dist/core/timings.js +1 -3
  150. package/dist/core/timings.js.map +1 -1
  151. package/dist/core/tools/render-utils.d.ts +1 -1
  152. package/dist/core/tools/render-utils.d.ts.map +1 -1
  153. package/dist/core/tools/render-utils.js.map +1 -1
  154. package/dist/core/tools/tool-definition.d.ts +1 -1
  155. package/dist/core/tools/tool-definition.d.ts.map +1 -1
  156. package/dist/core/tools/tool-definition.js.map +1 -1
  157. package/dist/core/trace-retention.d.ts +16 -1
  158. package/dist/core/trace-retention.d.ts.map +1 -1
  159. package/dist/core/trace-retention.js +43 -20
  160. package/dist/core/trace-retention.js.map +1 -1
  161. package/dist/export-html/ansi-to-html.d.ts.map +1 -0
  162. package/dist/export-html/ansi-to-html.js.map +1 -0
  163. package/dist/{core/export-html → export-html}/index.d.ts +1 -1
  164. package/dist/export-html/index.d.ts.map +1 -0
  165. package/dist/{core/export-html → export-html}/index.js +5 -5
  166. package/dist/export-html/index.js.map +1 -0
  167. package/dist/{core/export-html → export-html}/tool-renderer.d.ts +2 -2
  168. package/dist/export-html/tool-renderer.d.ts.map +1 -0
  169. package/dist/export-html/tool-renderer.js.map +1 -0
  170. package/dist/{modes/interactive → host}/model-catalog-refresh.d.ts +1 -1
  171. package/dist/host/model-catalog-refresh.d.ts.map +1 -0
  172. package/dist/{modes/interactive → host}/model-catalog-refresh.js +1 -1
  173. package/dist/host/model-catalog-refresh.js.map +1 -0
  174. package/dist/index.d.ts +5 -5
  175. package/dist/index.d.ts.map +1 -1
  176. package/dist/index.js +12 -12
  177. package/dist/index.js.map +1 -1
  178. package/dist/main.d.ts.map +1 -1
  179. package/dist/main.js +25 -14
  180. package/dist/main.js.map +1 -1
  181. package/dist/modes/interactive/components/agents-view.d.ts.map +1 -1
  182. package/dist/modes/interactive/components/agents-view.js +1 -1
  183. package/dist/modes/interactive/components/agents-view.js.map +1 -1
  184. package/dist/modes/interactive/components/armin.d.ts.map +1 -1
  185. package/dist/modes/interactive/components/armin.js +1 -1
  186. package/dist/modes/interactive/components/armin.js.map +1 -1
  187. package/dist/modes/interactive/components/assistant-message.d.ts +3 -0
  188. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  189. package/dist/modes/interactive/components/assistant-message.js +83 -24
  190. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  191. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  192. package/dist/modes/interactive/components/bash-execution.js +1 -1
  193. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  194. package/dist/modes/interactive/components/bordered-loader.d.ts +1 -1
  195. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
  196. package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  197. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  198. package/dist/modes/interactive/components/branch-summary-message.js +1 -1
  199. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  200. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  201. package/dist/modes/interactive/components/compaction-summary-message.js +1 -1
  202. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  203. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  204. package/dist/modes/interactive/components/config-selector.js +1 -1
  205. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  206. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  207. package/dist/modes/interactive/components/custom-entry.js +1 -1
  208. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  209. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  210. package/dist/modes/interactive/components/custom-message.js +1 -1
  211. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  212. package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
  213. package/dist/modes/interactive/components/daxnuts.js +1 -1
  214. package/dist/modes/interactive/components/daxnuts.js.map +1 -1
  215. package/dist/modes/interactive/components/dialog-editor.d.ts.map +1 -1
  216. package/dist/modes/interactive/components/dialog-editor.js +1 -1
  217. package/dist/modes/interactive/components/dialog-editor.js.map +1 -1
  218. package/dist/modes/interactive/components/dialog-input.d.ts.map +1 -1
  219. package/dist/modes/interactive/components/dialog-input.js +1 -1
  220. package/dist/modes/interactive/components/dialog-input.js.map +1 -1
  221. package/dist/modes/interactive/components/dialog-selector.d.ts.map +1 -1
  222. package/dist/modes/interactive/components/dialog-selector.js +1 -1
  223. package/dist/modes/interactive/components/dialog-selector.js.map +1 -1
  224. package/dist/modes/interactive/components/diff.d.ts.map +1 -1
  225. package/dist/modes/interactive/components/diff.js +1 -1
  226. package/dist/modes/interactive/components/diff.js.map +1 -1
  227. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
  228. package/dist/modes/interactive/components/dynamic-border.js +1 -1
  229. package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
  230. package/dist/modes/interactive/components/first-time-setup.d.ts +1 -1
  231. package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
  232. package/dist/modes/interactive/components/first-time-setup.js +1 -1
  233. package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
  234. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  235. package/dist/modes/interactive/components/footer.js +1 -1
  236. package/dist/modes/interactive/components/footer.js.map +1 -1
  237. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  238. package/dist/modes/interactive/components/keybinding-hints.js +1 -1
  239. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  240. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  241. package/dist/modes/interactive/components/login-dialog.js +1 -1
  242. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  243. package/dist/modes/interactive/components/mermaid.d.ts +1 -1
  244. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
  245. package/dist/modes/interactive/components/mermaid.js.map +1 -1
  246. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  247. package/dist/modes/interactive/components/model-selector.js +2 -2
  248. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  249. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  250. package/dist/modes/interactive/components/oauth-selector.js +1 -1
  251. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  252. package/dist/modes/interactive/components/plugin-manager-entry.d.ts.map +1 -1
  253. package/dist/modes/interactive/components/plugin-manager-entry.js +1 -1
  254. package/dist/modes/interactive/components/plugin-manager-entry.js.map +1 -1
  255. package/dist/modes/interactive/components/plugin-selection-entry.d.ts.map +1 -1
  256. package/dist/modes/interactive/components/plugin-selection-entry.js +1 -1
  257. package/dist/modes/interactive/components/plugin-selection-entry.js.map +1 -1
  258. package/dist/modes/interactive/components/queue-manager-selector.d.ts.map +1 -1
  259. package/dist/modes/interactive/components/queue-manager-selector.js +1 -1
  260. package/dist/modes/interactive/components/queue-manager-selector.js.map +1 -1
  261. package/dist/modes/interactive/components/render-types.d.ts +1 -1
  262. package/dist/modes/interactive/components/render-types.d.ts.map +1 -1
  263. package/dist/modes/interactive/components/render-types.js.map +1 -1
  264. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  265. package/dist/modes/interactive/components/scoped-models-selector.js +1 -1
  266. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  267. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  268. package/dist/modes/interactive/components/session-selector.js +2 -2
  269. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  270. package/dist/modes/interactive/components/settings-selector.d.ts +1 -1
  271. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  272. package/dist/modes/interactive/components/settings-selector.js +1 -1
  273. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  274. package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
  275. package/dist/modes/interactive/components/settings-submenu.js +1 -1
  276. package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
  277. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
  278. package/dist/modes/interactive/components/show-images-selector.js +1 -1
  279. package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
  280. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  281. package/dist/modes/interactive/components/skill-invocation-message.js +1 -1
  282. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  283. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  284. package/dist/modes/interactive/components/status-indicator.js +1 -1
  285. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  286. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
  287. package/dist/modes/interactive/components/theme-selector.js +1 -1
  288. package/dist/modes/interactive/components/theme-selector.js.map +1 -1
  289. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  290. package/dist/modes/interactive/components/thinking-selector.js +1 -1
  291. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  292. package/dist/modes/interactive/components/tool-execution.d.ts +2 -0
  293. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  294. package/dist/modes/interactive/components/tool-execution.js +96 -4
  295. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  296. package/dist/modes/interactive/components/tool-run-group.d.ts.map +1 -1
  297. package/dist/modes/interactive/components/tool-run-group.js +1 -1
  298. package/dist/modes/interactive/components/tool-run-group.js.map +1 -1
  299. package/dist/modes/interactive/components/tree-list.d.ts.map +1 -1
  300. package/dist/modes/interactive/components/tree-list.js +1 -1
  301. package/dist/modes/interactive/components/tree-list.js.map +1 -1
  302. package/dist/modes/interactive/components/tree-render.d.ts.map +1 -1
  303. package/dist/modes/interactive/components/tree-render.js +1 -1
  304. package/dist/modes/interactive/components/tree-render.js.map +1 -1
  305. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  306. package/dist/modes/interactive/components/tree-selector.js +1 -1
  307. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  308. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  309. package/dist/modes/interactive/components/user-message-selector.js +1 -1
  310. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  311. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  312. package/dist/modes/interactive/components/user-message.js +1 -1
  313. package/dist/modes/interactive/components/user-message.js.map +1 -1
  314. package/dist/modes/interactive/components/workflow-view.d.ts.map +1 -1
  315. package/dist/modes/interactive/components/workflow-view.js +1 -1
  316. package/dist/modes/interactive/components/workflow-view.js.map +1 -1
  317. package/dist/modes/interactive/interactive-auth.d.ts +1 -1
  318. package/dist/modes/interactive/interactive-auth.d.ts.map +1 -1
  319. package/dist/modes/interactive/interactive-auth.js +1 -1
  320. package/dist/modes/interactive/interactive-auth.js.map +1 -1
  321. package/dist/modes/interactive/interactive-commands.d.ts +123 -6
  322. package/dist/modes/interactive/interactive-commands.d.ts.map +1 -1
  323. package/dist/modes/interactive/interactive-commands.js +691 -4
  324. package/dist/modes/interactive/interactive-commands.js.map +1 -1
  325. package/dist/modes/interactive/interactive-events.d.ts +174 -0
  326. package/dist/modes/interactive/interactive-events.d.ts.map +1 -0
  327. package/dist/modes/interactive/interactive-events.js +704 -0
  328. package/dist/modes/interactive/interactive-events.js.map +1 -0
  329. package/dist/modes/interactive/interactive-format.d.ts.map +1 -1
  330. package/dist/modes/interactive/interactive-format.js +1 -1
  331. package/dist/modes/interactive/interactive-format.js.map +1 -1
  332. package/dist/modes/interactive/interactive-lifecycle.d.ts +94 -0
  333. package/dist/modes/interactive/interactive-lifecycle.d.ts.map +1 -0
  334. package/dist/modes/interactive/interactive-lifecycle.js +177 -0
  335. package/dist/modes/interactive/interactive-lifecycle.js.map +1 -0
  336. package/dist/modes/interactive/interactive-mode.d.ts +240 -133
  337. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  338. package/dist/modes/interactive/interactive-mode.js +251 -2159
  339. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  340. package/dist/modes/interactive/interactive-queues.d.ts +96 -0
  341. package/dist/modes/interactive/interactive-queues.d.ts.map +1 -0
  342. package/dist/modes/interactive/interactive-queues.js +183 -0
  343. package/dist/modes/interactive/interactive-queues.js.map +1 -0
  344. package/dist/modes/interactive/interactive-selectors.d.ts +95 -5
  345. package/dist/modes/interactive/interactive-selectors.d.ts.map +1 -1
  346. package/dist/modes/interactive/interactive-selectors.js +517 -6
  347. package/dist/modes/interactive/interactive-selectors.js.map +1 -1
  348. package/dist/modes/interactive/startup-services.d.ts +31 -0
  349. package/dist/modes/interactive/startup-services.d.ts.map +1 -0
  350. package/dist/modes/interactive/startup-services.js +123 -0
  351. package/dist/modes/interactive/startup-services.js.map +1 -0
  352. package/dist/modes/memory-preheat.d.ts +11 -0
  353. package/dist/modes/memory-preheat.d.ts.map +1 -0
  354. package/dist/modes/memory-preheat.js +20 -0
  355. package/dist/modes/memory-preheat.js.map +1 -0
  356. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  357. package/dist/modes/rpc/rpc-mode.js +3 -1
  358. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  359. package/dist/plugins/ecosystem/node-package-install-host.d.ts +9 -1
  360. package/dist/plugins/ecosystem/node-package-install-host.d.ts.map +1 -1
  361. package/dist/plugins/ecosystem/node-package-install-host.js +79 -0
  362. package/dist/plugins/ecosystem/node-package-install-host.js.map +1 -1
  363. package/dist/remote/server-assembly.d.ts.map +1 -1
  364. package/dist/remote/server-assembly.js +7 -2
  365. package/dist/remote/server-assembly.js.map +1 -1
  366. package/dist/suites/builtin-suites.d.ts.map +1 -0
  367. package/dist/suites/builtin-suites.js.map +1 -0
  368. package/dist/suites/resolved-agent-profile.d.ts.map +1 -0
  369. package/dist/suites/resolved-agent-profile.js.map +1 -0
  370. package/dist/suites/suite-lifecycle.d.ts.map +1 -0
  371. package/dist/suites/suite-lifecycle.js.map +1 -0
  372. package/dist/suites/suite-loader.d.ts.map +1 -0
  373. package/dist/suites/suite-loader.js.map +1 -0
  374. package/dist/{modes/interactive/theme → theme}/dark.json +1 -1
  375. package/dist/{modes/interactive/theme → theme}/light.json +1 -1
  376. package/dist/{modes/interactive/theme → theme}/theme-controller.d.ts +1 -1
  377. package/dist/theme/theme-controller.d.ts.map +1 -0
  378. package/dist/{modes/interactive/theme → theme}/theme-controller.js +1 -1
  379. package/dist/theme/theme-controller.js.map +1 -0
  380. package/dist/{modes/interactive/theme → theme}/theme.d.ts +1 -1
  381. package/dist/theme/theme.d.ts.map +1 -0
  382. package/dist/{modes/interactive/theme → theme}/theme.js +5 -5
  383. package/dist/theme/theme.js.map +1 -0
  384. package/docs/compaction.md +7 -7
  385. package/docs/environment-variables.md +10 -4
  386. package/docs/keybindings.md +3 -3
  387. package/docs/models.md +17 -17
  388. package/docs/packages.md +1 -1
  389. package/docs/prompt-templates.md +1 -1
  390. package/docs/rpc.md +2 -2
  391. package/docs/sdk.md +5 -5
  392. package/docs/session-format.md +3 -3
  393. package/docs/settings.md +15 -1
  394. package/docs/shell-aliases.md +1 -1
  395. package/docs/skills.md +1 -1
  396. package/docs/terminal-setup.md +17 -17
  397. package/docs/themes.md +5 -5
  398. package/docs/tmux.md +4 -4
  399. package/docs/tui.md +1 -1
  400. package/docs/usage.md +292 -292
  401. package/docs/windows.md +1 -1
  402. package/examples/extensions/bash-spawn-hook/index.ts +1 -1
  403. package/examples/extensions/dynamic-resources/dynamic.json +1 -1
  404. package/examples/extensions/mcp-stdio/index.d.ts +64 -0
  405. package/examples/extensions/mcp-stdio/index.d.ts.map +1 -0
  406. package/examples/extensions/mcp-stdio/index.js +292 -0
  407. package/examples/extensions/mcp-stdio/index.js.map +1 -0
  408. package/examples/extensions/with-deps/package-lock.json +2 -2
  409. package/examples/extensions/with-deps/package.json +1 -6
  410. package/examples/extensions/with-deps/plugin.json +1 -1
  411. package/package.json +2 -2
  412. package/dist/bundle/chunks/openai-responses-AUJQ3NWT.js +0 -2
  413. package/dist/bundle/chunks/virtual-modules-MRXD3RWG.js +0 -5
  414. package/dist/cli/experimental/commands/pi.d.ts +0 -15
  415. package/dist/cli/experimental/commands/pi.d.ts.map +0 -1
  416. package/dist/cli/experimental/commands/pi.js.map +0 -1
  417. package/dist/core/export-html/ansi-to-html.d.ts.map +0 -1
  418. package/dist/core/export-html/ansi-to-html.js.map +0 -1
  419. package/dist/core/export-html/index.d.ts.map +0 -1
  420. package/dist/core/export-html/index.js.map +0 -1
  421. package/dist/core/export-html/tool-renderer.d.ts.map +0 -1
  422. package/dist/core/export-html/tool-renderer.js.map +0 -1
  423. package/dist/core/pi-manifest.d.ts +0 -7
  424. package/dist/core/pi-manifest.d.ts.map +0 -1
  425. package/dist/core/pi-manifest.js.map +0 -1
  426. package/dist/modes/interactive/model-catalog-refresh.d.ts.map +0 -1
  427. package/dist/modes/interactive/model-catalog-refresh.js.map +0 -1
  428. package/dist/modes/interactive/theme/theme-controller.d.ts.map +0 -1
  429. package/dist/modes/interactive/theme/theme-controller.js.map +0 -1
  430. package/dist/modes/interactive/theme/theme.d.ts.map +0 -1
  431. package/dist/modes/interactive/theme/theme.js.map +0 -1
  432. package/dist/profiles/builtin-suites.d.ts.map +0 -1
  433. package/dist/profiles/builtin-suites.js.map +0 -1
  434. package/dist/profiles/resolved-agent-profile.d.ts.map +0 -1
  435. package/dist/profiles/resolved-agent-profile.js.map +0 -1
  436. package/dist/profiles/suite-lifecycle.d.ts.map +0 -1
  437. package/dist/profiles/suite-lifecycle.js.map +0 -1
  438. package/dist/profiles/suite-loader.d.ts.map +0 -1
  439. package/dist/profiles/suite-loader.js.map +0 -1
  440. package/dist/utils/deprecation.d.ts +0 -4
  441. package/dist/utils/deprecation.d.ts.map +0 -1
  442. package/dist/utils/deprecation.js +0 -13
  443. package/dist/utils/deprecation.js.map +0 -1
  444. /package/dist/{core/export-html → export-html}/ansi-to-html.d.ts +0 -0
  445. /package/dist/{core/export-html → export-html}/ansi-to-html.js +0 -0
  446. /package/dist/{core/export-html → export-html}/template.css +0 -0
  447. /package/dist/{core/export-html → export-html}/template.html +0 -0
  448. /package/dist/{core/export-html → export-html}/template.js +0 -0
  449. /package/dist/{core/export-html → export-html}/tool-renderer.js +0 -0
  450. /package/dist/{core/export-html → export-html}/vendor/highlight.min.js +0 -0
  451. /package/dist/{core/export-html → export-html}/vendor/marked.min.js +0 -0
  452. /package/dist/{profiles → suites}/builtin-suites.d.ts +0 -0
  453. /package/dist/{profiles → suites}/builtin-suites.js +0 -0
  454. /package/dist/{profiles → suites}/resolved-agent-profile.d.ts +0 -0
  455. /package/dist/{profiles → suites}/resolved-agent-profile.js +0 -0
  456. /package/dist/{profiles → suites}/suite-lifecycle.d.ts +0 -0
  457. /package/dist/{profiles → suites}/suite-lifecycle.js +0 -0
  458. /package/dist/{profiles → suites}/suite-loader.d.ts +0 -0
  459. /package/dist/{profiles → suites}/suite-loader.js +0 -0
  460. /package/dist/{modes/interactive/theme → theme}/theme-schema.json +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"settings-manager.d.ts","sourceRoot":"","sources":["../../src/core/settings-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAoC,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC/F,OAAO,KAAK,EACX,OAAO,IAAI,eAAe,EAC1B,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,MAAM,kBAAkB,CAAC;AAS1B,OAAO,EAAE,KAAK,YAAY,EAAK,MAAM,iBAAiB,CAAC;AAEvD,MAAM,WAAW,uBAAuB;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC1B;AAOD,MAAM,WAAW,kBAAkB;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;CACzD;AAED,MAAM,WAAW,qBAAqB;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,qBAAqB;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CACjC;AAED,MAAM,MAAM,O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,MAAM,GAAG,IAAI,CAIvC;IAED,YAAY,IAAI,CAAC,GAAG,CAAC,CAEpB;IAED,YAAY,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAIjC;IAED,yBAAyB,IAAI,MAAM,CAElC;IAED,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAIlD;IAED,kBAAkB,IAAI,MAAM,CAE3B;IAED,uBAAuB,IAAI,oBAAoB,CAG9C;IAED,uBAAuB,CAAC,IAAI,EAAE,oBAAoB,GAAG,IAAI,CAKxD;IAED,WAAW,IAAI,eAAe,CAE7B;IAED,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAI3C;CACD","sourcesContent":["import type { ThinkingLevel } from \"@agent-forge/agent-core\";\nimport { DEFAULT_MAX_AGENT_RETRY_DELAY_MS, type Model, type Transport } from \"@agent-forge/ai\";\nimport type {\n\tTuiMode as RendererTuiMode,\n\tScrollViewScrollbar,\n\tTerminalCapabilities,\n\tWheelScrollLines,\n} from \"@agent-forge/tui\";\nimport { randomUUID } from \"crypto\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\nimport lockfile from \"proper-lockfile\";\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../config.ts\";\nimport { normalizePath, resolvePath } from \"../utils/paths.ts\";\nimport { stripBom } from \"../utils/text.ts\";\nimport { DEFAULT_HTTP_IDLE_TIMEOUT_MS, parseHttpIdleTimeoutMs } from \"./http-dispatcher.ts\";\nimport { type I18nLanguage, t } from \"./i18n/index.ts\";\n\nexport interface CompactionModelOverride {\n\treserveTokens?: number;\n\tkeepRecentTokens?: number;\n}\n\nconst DEFAULT_COMPACTION_TOKEN_SETTINGS: Required<CompactionModelOverride> = {\n\treserveTokens: 16384,\n\tkeepRecentTokens: 20000,\n};\n\nexport interface CompactionSettings {\n\treserveTokens?: number; // default: 16384\n\tkeepRecentTokens?: number; // default: 20000\n\tmodelOverrides?: Record<string, CompactionModelOverride>; // exact \"provider/modelId\" keys\n}\n\nexport interface BranchSummarySettings {\n\treserveTokens?: number; // default: 16384 (tokens reserved for prompt + LLM response)\n\tskipPrompt?: boolean; // default: false - when true, skips \"Summarize branch?\" prompt and defaults to no summary\n}\n\nexport interface ProviderRetrySettings {\n\ttimeoutMs?: number; // SDK/provider request timeout in milliseconds\n\tmaxRetries?: number; // SDK/provider retry attempts\n\tmaxRetryDelayMs?: number; // default: 60000 (max server-requested delay before failing)\n}\n\nexport interface RetrySettings {\n\tmaxRetries?: number; // default: 5 (matches codex's stream_max_retries default)\n\tbaseDelayMs?: number; // default: 2000 (exponential backoff with ±10% jitter: ~2s, ~4s, ~8s, ~16s, ~32s)\n\tmaxAgentDelayMs?: number; // default: 60000 (cap applied before ±10% jitter)\n\tprovider?: ProviderRetrySettings;\n}\n\nexport type TuiMode = RendererTuiMode;\nexport type FullscreenExitOutput = \"transcript\" | \"resume-hint\";\n\n/**\n * 界面语言(docs/design/国际化与本地化.md):`ui.language` 持久配置面。\n * env `AGENT_FORGE_I18N_LANG` 是更高优先的临时覆盖。\n */\nexport interface UiSettings {\n\tlanguage?: I18nLanguage; // default: \"zh-CN\"\n}\n\nexport interface TerminalSettings {\n\tshowImages?: boolean; // default: true (only relevant if terminal supports images)\n\timageWidthCells?: number; // default: 60 (preferred inline image width in terminal cells)\n\tclearOnShrink?: boolean; // default: false (clear empty rows when content shrinks)\n\tshowTerminalProgress?: boolean; // default: false (OSC 9;4 terminal progress indicators)\n\thyperlinks?: boolean | \"auto\";\n\timages?: \"kitty\" | \"iterm2\" | \"auto\" | false;\n\ttrueColor?: boolean | \"auto\";\n}\n\nexport interface ImageSettings {\n\tautoResize?: boolean; // default: true (resize images to 2000x2000 max for better model compatibility)\n\tblockImages?: boolean; // default: false - when true, prevents all images from being sent to LLM providers\n}\n\nexport interface ThinkingBudgetsSettings {\n\tminimal?: number;\n\tlow?: number;\n\tmedium?: number;\n\thigh?: number;\n}\n\nexport type MermaidRenderingMode = \"off\" | \"final\" | \"streaming\";\n\nexport interface MarkdownSettings {\n\tcodeBlockIndent?: string; // default: \" \"\n\tmermaid?: MermaidRenderingMode; // default: \"streaming\"\n}\n\nexport interface WarningSettings {\n\tanthropicExtraUsage?: boolean; // default: true\n}\n\n/**\n * 记忆全局档位(2.4d6 S1):settings.json 的持久配置面。env\n * `AGENT_FORGE_MEMORY_MODE` 是临时覆盖,优先级高于本键(完整解析链:SDK 显式值\n * > env > settings > 旧别名 env `AGENT_FORGE_MEMORY_VECTOR` > off)。\n */\nexport interface MemorySettings {\n\tmode?: \"off\" | \"light\" | \"full\";\n}\n\n/**\n * 生图独立供应商槽位(供应商能力槽位设计 §3.1):`capabilities.imageGeneration`\n * 持久配置面。`provider` 必填;`model` 可省——省略时由 image-generation 插件按\n * 该 provider 在 models.json 登记的生图模型推断(取值链见设计 §3.2)。\n */\nexport interface ImageGenerationCapabilitySettings {\n\tprovider: string;\n\tmodel?: string;\n}\n\n/** 能力槽位配置节(供应商能力槽位设计 §3.1);视频/音频未来按同名模式扩展。 */\nexport interface CapabilitiesSettings {\n\timageGeneration?: ImageGenerationCapabilitySettings;\n}\n\n/** 主备切换冷却参数(供应商能力槽位与主备切换设计 §4.1)。 */\nexport interface FailoverCooldownSettings {\n\tinitialMs?: number;\n\tmaxMs?: number;\n}\n\n/** 显式链(供应商能力槽位与主备切换设计 §4.1):主模型 → 备用模型序列。 */\nexport interface FailoverChainSettings {\n\tprimary: string;\n\tbackups: string[];\n}\n\n/**\n * 主供应商主备切换配置面(供应商能力槽位与主备切换设计 §4.1)。Phase 1 仅\n * 声明类型并提供 raw 读出(`getFailoverSettings`);任何 failover 行为都是\n * Phase 2 的 provider-failover 插件的事,本层不实现、不校验、不消费。\n */\nexport interface FailoverSettings {\n\tbackupProviders?: string[];\n\tfailureThreshold?: number;\n\tcooldown?: FailoverCooldownSettings;\n\tchains?: FailoverChainSettings[];\n}\n\nexport type TransportSetting = Transport;\n\n/**\n * Package source for npm/git packages.\n * - String form: load all resources from the package\n * - Object form: filter which resources to load\n * - autoload=false: start empty and only apply explicit resource patterns\n */\nexport type PackageSource =\n\t| string\n\t| {\n\t\t\tsource: string;\n\t\t\tautoload?: boolean;\n\t\t\textensions?: string[];\n\t\t\tskills?: string[];\n\t\t\tprompts?: string[];\n\t\t\tthemes?: string[];\n\t };\n\nexport interface Settings {\n\tlastChangelogVersion?: string;\n\t/** Suite 漂移/升级提示的已见记录(借鉴 lastChangelogVersion 模式:同版本只呈现一次)。 */\n\tsuiteNoticesAcknowledged?: Record<string, { driftDigest?: string; upgradeRevision?: number }>;\n\tdefaultProvider?: string;\n\tdefaultModel?: string;\n\tdefaultThinkingLevel?: ThinkingLevel;\n\tmodelThinkingLevels?: Record<string, ThinkingLevel>; // per-model default thinking level overrides keyed by \"provider/modelId\"\n\ttransport?: TransportSetting; // default: \"auto\"\n\tsteeringMode?: \"all\" | \"one-at-a-time\";\n\tfollowUpMode?: \"all\" | \"one-at-a-time\";\n\ttheme?: string;\n\tui?: UiSettings; // 界面语言 (ui.language); env AGENT_FORGE_I18N_LANG 可临时覆盖\n\tcompaction?: CompactionSettings;\n\tbranchSummary?: BranchSummarySettings;\n\tretry?: RetrySettings;\n\thideThinkingBlock?: boolean;\n\tshowCacheMissNotices?: boolean; // default: false - show cache cost and provider recovery notices\n\texternalEditor?: string; // Command for Ctrl+G external editor; takes precedence over VISUAL/EDITOR\n\tshellPath?: string; // Custom shell path (e.g., for Cygwin users on Windows); supports leading ~ expansion\n\tquietStartup?: boolean;\n\tshellCommandPrefix?: string; // Prefix prepended to every bash command (e.g., \"shopt -s expand_aliases\" for alias support)\n\tnpmCommand?: string[]; // Command used for npm package lookup/install operations, argv-style (e.g., [\"mise\", \"exec\", \"node@20\", \"--\", \"npm\"])\n\tcollapseChangelog?: boolean; // Show condensed changelog after update (use /changelog for full)\n\tenableAnalytics?: boolean; // default: false - opt-in analytics data sharing\n\ttrackingId?: string; // analytics tracking identifier, generated when analytics is enabled\n\tpackages?: PackageSource[]; // Array of npm/git package sources (string or object with filtering)\n\tskills?: string[]; // Array of local skill file paths or directories\n\tprompts?: string[]; // Array of local prompt template paths or directories\n\tthemes?: string[]; // Array of local theme file paths or directories\n\tterminal?: TerminalSettings;\n\timages?: ImageSettings;\n\tenabledModels?: string[]; // Model patterns for cycling (same format as --models CLI flag)\n\tdefaultTools?: string[]; // Initial tool selection; plain names replace the inherited selection, `+name` entries add to it (`-name` removal syntax removed 2026-10-03, D-079)\n\tsuite?: string; // Active suite (方案) id; resolved CLI > AGENT_FORGE_SUITE > project > global > \"assistant\"\n\tdoubleEscapeAction?: \"tree\" | \"none\"; // Action for double-escape with empty editor (default: \"tree\"; the removed \"fork\" value reads as \"tree\")\n\ttreeFilterMode?: \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\"; // Default filter when opening /tree\n\tthinkingBudgets?: ThinkingBudgetsSettings; // Custom token budgets for thinking levels\n\teditorPaddingX?: number; // Horizontal padding for input editor (default: 0)\n\toutputPad?: 0 | 1; // Horizontal padding for chat message output (default: 1)\n\tautocompleteMaxVisible?: number; // Max visible items in autocomplete dropdown (default: 5)\n\tshowHardwareCursor?: boolean; // Show terminal cursor while still positioning it for IME\n\tmarkdown?: MarkdownSettings;\n\twarnings?: WarningSettings;\n\tmemory?: MemorySettings; // 记忆全局档位 (memory.mode); env AGENT_FORGE_MEMORY_MODE 可临时覆盖\n\tcapabilities?: CapabilitiesSettings; // 能力槽位:按能力独立配置供应商(生图先行);深合并语义与现有键一致\n\tfailover?: FailoverSettings; // 主供应商主备切换(设计 §4);Phase 1 仅持久化配置面,行为属 Phase 2\n\tsessionDir?: string; // Custom session storage directory (same format as --session-dir CLI flag)\n\thttpProxy?: string; // Proxy URL applied as HTTP_PROXY and HTTPS_PROXY for Pi-managed HTTP clients\n\thttpIdleTimeoutMs?: number; // HTTP header/body idle timeout in milliseconds; 0 disables it\n\twebsocketConnectTimeoutMs?: number; // WebSocket connect/open handshake timeout in milliseconds; 0 disables it\n\ttuiMode?: TuiMode; // default: \"regular\"\n\tfullscreenExitOutput?: FullscreenExitOutput; // default: \"transcript\"; no effect in regular TUI mode\n\tfullscreenScrollbar?: ScrollViewScrollbar; // default: \"auto\"; no effect in regular TUI mode\n\tfullscreenCopyOnSelect?: boolean; // default: true; no effect in regular TUI mode\n\tfullscreenWheelScrollLines?: WheelScrollLines; // default: \"auto\"; lines per wheel event, 1-100\n}\n\nfunction isMergeableObject(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction deepMergeObjects(base: Record<string, unknown>, overrides: Record<string, unknown>): Record<string, unknown> {\n\tconst result = { ...base };\n\n\tfor (const key of Object.keys(overrides)) {\n\t\tconst overrideValue = overrides[key];\n\t\tif (overrideValue === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst baseValue = base[key];\n\t\tresult[key] =\n\t\t\tisMergeableObject(baseValue) && isMergeableObject(overrideValue)\n\t\t\t\t? deepMergeObjects(baseValue, overrideValue)\n\t\t\t\t: overrideValue;\n\t}\n\n\treturn result;\n}\n\n/** Tools enabled at startup when `defaultTools` does not change them. */\nexport const DEFAULT_TOOL_NAMES: readonly string[] = [\"read\", \"bash\", \"edit\", \"write\"];\n\n// D-079:`-name` 移除语法退役,modifier 只认 `+` 前缀。\nfunction isToolModifier(entry: unknown): boolean {\n\treturn typeof entry === \"string\" && entry.startsWith(\"+\");\n}\n\n/**\n * Merge `defaultTools` of two settings layers. A list with plain tool names replaces the inherited\n * one; a list of only `+name` entries is appended, so it modifies the inherited selection.\n */\nfunction mergeDefaultTools(base: string[] | undefined, overrides: string[] | undefined): string[] | undefined {\n\tif (overrides === undefined) return base;\n\t// Settings files are not validated; a malformed value replaces instead of throwing here.\n\tif (!Array.isArray(base) || !Array.isArray(overrides) || !overrides.every(isToolModifier)) return overrides;\n\treturn [...base, ...overrides];\n}\n\n/**\n * Resolve a merged `defaultTools` list: plain names replace `DEFAULT_TOOL_NAMES`, then `+name`\n * entries add tools in list order (`-name` removal syntax removed 2026-10-03, D-079).\n */\nfunction resolveDefaultTools(entries: string[]): string[] {\n\t// D-079:`-name` 移除语法退役——以 `-` 开头的条目跳过(不进 plain、不报错),净效果为忽略该条目。\n\tconst plain = entries.filter((entry) => !entry.startsWith(\"-\") && !isToolModifier(entry));\n\tconst tools = plain.length > 0 || entries.length === 0 ? plain : [...DEFAULT_TOOL_NAMES];\n\tfor (const entry of entries) {\n\t\tif (!isToolModifier(entry)) continue;\n\t\tconst name = entry.slice(1);\n\t\tif (name && !tools.includes(name)) tools.push(name);\n\t}\n\treturn tools;\n}\n\n/** Deep merge settings: project/overrides take precedence, nested objects merge recursively */\nfunction deepMergeSettings(base: Settings, overrides: Settings): Settings {\n\tconst merged = deepMergeObjects(base as Record<string, unknown>, overrides as Record<string, unknown>) as Settings;\n\tconst defaultTools = mergeDefaultTools(base.defaultTools, overrides.defaultTools);\n\treturn defaultTools === undefined ? merged : { ...merged, defaultTools };\n}\n\nfunction parseTimeoutSetting(value: unknown, settingName: string): number | undefined {\n\tconst timeoutMs = parseHttpIdleTimeoutMs(value);\n\tif (timeoutMs !== undefined) {\n\t\treturn timeoutMs;\n\t}\n\tif (value !== undefined) {\n\t\tthrow new Error(t(\"Invalid {settingName} setting: {value}\", { settingName, value: String(value) }));\n\t}\n\treturn undefined;\n}\n\nexport type SettingsScope = \"global\" | \"project\";\n\nexport interface SettingsManagerCreateOptions {\n\t/** @deprecated Project trust is no longer a core policy and this option is ignored. */\n\tprojectTrusted?: boolean;\n}\n\nexport interface SettingsStorage {\n\twithLock(scope: SettingsScope, fn: (current: string | undefined) => string | undefined): void;\n}\n\nexport interface SettingsError {\n\tscope: SettingsScope;\n\tpath?: string;\n\terror: Error;\n}\n\ntype SettingsPaths = Partial<Record<SettingsScope, string>>;\n\nfunction toSettingsError(scope: SettingsScope, error: unknown, path?: string): SettingsError {\n\treturn {\n\t\tscope,\n\t\t...(path ? { path } : {}),\n\t\terror: error instanceof Error ? error : new Error(String(error)),\n\t};\n}\n\nexport class FileSettingsStorage implements SettingsStorage {\n\tprivate globalSettingsPath: string;\n\tprivate projectSettingsPath: string;\n\n\tconstructor(cwd: string, agentDir: string) {\n\t\tconst resolvedCwd = resolvePath(cwd);\n\t\tconst resolvedAgentDir = resolvePath(agentDir);\n\t\tthis.globalSettingsPath = join(resolvedAgentDir, \"settings.json\");\n\t\tthis.projectSettingsPath = join(resolvedCwd, CONFIG_DIR_NAME, \"settings.json\");\n\t}\n\n\tprivate acquireLockSyncWithRetry(path: string): () => void {\n\t\tconst maxAttempts = 10;\n\t\tconst delayMs = 20;\n\t\tlet lastError: unknown;\n\n\t\tfor (let attempt = 1; attempt <= maxAttempts; attempt++) {\n\t\t\ttry {\n\t\t\t\treturn lockfile.lockSync(path, { realpath: false });\n\t\t\t} catch (error) {\n\t\t\t\tconst code =\n\t\t\t\t\ttypeof error === \"object\" && error !== null && \"code\" in error\n\t\t\t\t\t\t? String((error as { code?: unknown }).code)\n\t\t\t\t\t\t: undefined;\n\t\t\t\tif (code !== \"ELOCKED\" || attempt === maxAttempts) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tlastError = error;\n\t\t\t\tconst start = Date.now();\n\t\t\t\twhile (Date.now() - start < delayMs) {\n\t\t\t\t\t// Sleep synchronously to avoid changing callers to async.\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthrow (lastError as Error) ?? new Error(\"Failed to acquire settings lock\");\n\t}\n\n\twithLock(scope: SettingsScope, fn: (current: string | undefined) => string | undefined): void {\n\t\tconst path = scope === \"global\" ? this.globalSettingsPath : this.projectSettingsPath;\n\t\tconst dir = dirname(path);\n\n\t\tlet release: (() => void) | undefined;\n\t\ttry {\n\t\t\t// Only create directory and lock if file exists or we need to write\n\t\t\tconst fileExists = existsSync(path);\n\t\t\tif (fileExists) {\n\t\t\t\trelease = this.acquireLockSyncWithRetry(path);\n\t\t\t}\n\t\t\tconst current = fileExists ? readFileSync(path, \"utf-8\") : undefined;\n\t\t\tconst next = fn(current);\n\t\t\tif (next !== undefined) {\n\t\t\t\t// Only create directory when we actually need to write\n\t\t\t\tif (!existsSync(dir)) {\n\t\t\t\t\tmkdirSync(dir, { recursive: true });\n\t\t\t\t}\n\t\t\t\tif (!release) {\n\t\t\t\t\trelease = this.acquireLockSyncWithRetry(path);\n\t\t\t\t}\n\t\t\t\twriteFileSync(path, next, \"utf-8\");\n\t\t\t}\n\t\t} finally {\n\t\t\tif (release) {\n\t\t\t\trelease();\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport class InMemorySettingsStorage implements SettingsStorage {\n\tprivate global: string | undefined;\n\tprivate project: string | undefined;\n\n\twithLock(scope: SettingsScope, fn: (current: string | undefined) => string | undefined): void {\n\t\tconst current = scope === \"global\" ? this.global : this.project;\n\t\tconst next = fn(current);\n\t\tif (next !== undefined) {\n\t\t\tif (scope === \"global\") {\n\t\t\t\tthis.global = next;\n\t\t\t} else {\n\t\t\t\tthis.project = next;\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport class SettingsManager {\n\tprivate storage: SettingsStorage;\n\tprivate globalSettings: Settings;\n\tprivate projectSettings: Settings;\n\tprivate settings: Settings;\n\tprivate modifiedFields = new Set<keyof Settings>(); // Track global fields modified during session\n\tprivate modifiedNestedFields = new Map<keyof Settings, Set<string>>(); // Track global nested field modifications\n\tprivate modifiedProjectFields = new Set<keyof Settings>(); // Track project fields modified during session\n\tprivate modifiedProjectNestedFields = new Map<keyof Settings, Set<string>>(); // Track project nested field modifications\n\tprivate globalSettingsLoadError: Error | null = null; // Track if global settings file had parse errors\n\tprivate projectSettingsLoadError: Error | null = null; // Track if project settings file had parse errors\n\tprivate capabilitiesWarningRecorded = false; // One capabilities-structure warning per manager lifetime\n\tprivate writeQueue: Promise<void> = Promise.resolve();\n\tprivate errors: SettingsError[];\n\tprivate settingsPaths: SettingsPaths;\n\n\tprivate constructor(\n\t\tstorage: SettingsStorage,\n\t\tinitialGlobal: Settings,\n\t\tinitialProject: Settings,\n\t\tglobalLoadError: Error | null = null,\n\t\tprojectLoadError: Error | null = null,\n\t\tinitialErrors: SettingsError[] = [],\n\t\tsettingsPaths: SettingsPaths = {},\n\t) {\n\t\tthis.storage = storage;\n\t\tthis.globalSettings = initialGlobal;\n\t\tthis.projectSettings = initialProject;\n\t\tthis.globalSettingsLoadError = globalLoadError;\n\t\tthis.projectSettingsLoadError = projectLoadError;\n\t\tthis.errors = [...initialErrors];\n\t\tthis.settingsPaths = settingsPaths;\n\t\tthis.settings = deepMergeSettings(this.globalSettings, this.projectSettings);\n\t}\n\n\t/** Create a SettingsManager that loads from files */\n\tstatic create(\n\t\tcwd: string,\n\t\tagentDir: string = getAgentDir(),\n\t\toptions: SettingsManagerCreateOptions = {},\n\t): SettingsManager {\n\t\tconst resolvedCwd = resolvePath(cwd);\n\t\tconst resolvedAgentDir = resolvePath(agentDir);\n\t\tconst storage = new FileSettingsStorage(resolvedCwd, resolvedAgentDir);\n\t\treturn SettingsManager.fromStorageWithPaths(storage, options, {\n\t\t\tglobal: join(resolvedAgentDir, \"settings.json\"),\n\t\t\tproject: join(resolvedCwd, CONFIG_DIR_NAME, \"settings.json\"),\n\t\t});\n\t}\n\n\t/** Create a SettingsManager from an arbitrary storage backend */\n\tstatic fromStorage(storage: SettingsStorage, options: SettingsManagerCreateOptions = {}): SettingsManager {\n\t\treturn SettingsManager.fromStorageWithPaths(storage, options);\n\t}\n\n\t/** Create a manager while retaining optional file paths for reported storage errors. */\n\tprivate static fromStorageWithPaths(\n\t\tstorage: SettingsStorage,\n\t\toptions: SettingsManagerCreateOptions,\n\t\tsettingsPaths: SettingsPaths = {},\n\t): SettingsManager {\n\t\tvoid options;\n\t\tconst globalLoad = SettingsManager.tryLoadFromStorage(storage, \"global\");\n\t\tconst projectLoad = SettingsManager.tryLoadFromStorage(storage, \"project\");\n\t\tconst initialErrors: SettingsError[] = [];\n\t\tif (globalLoad.error) {\n\t\t\tinitialErrors.push(toSettingsError(\"global\", globalLoad.error, settingsPaths.global));\n\t\t}\n\t\tif (projectLoad.error) {\n\t\t\tinitialErrors.push(toSettingsError(\"project\", projectLoad.error, settingsPaths.project));\n\t\t}\n\n\t\treturn new SettingsManager(\n\t\t\tstorage,\n\t\t\tglobalLoad.settings,\n\t\t\tprojectLoad.settings,\n\t\t\tglobalLoad.error,\n\t\t\tprojectLoad.error,\n\t\t\tinitialErrors,\n\t\t\tsettingsPaths,\n\t\t);\n\t}\n\n\t/** Create an in-memory SettingsManager (no file I/O) */\n\tstatic inMemory(settings: Partial<Settings> = {}, options: SettingsManagerCreateOptions = {}): SettingsManager {\n\t\tconst storage = new InMemorySettingsStorage();\n\t\tconst initialSettings = SettingsManager.migrateSettings(structuredClone(settings) as Record<string, unknown>);\n\t\tstorage.withLock(\"global\", () => JSON.stringify(initialSettings, null, 2));\n\t\treturn SettingsManager.fromStorage(storage, options);\n\t}\n\n\tprivate static loadFromStorage(storage: SettingsStorage, scope: SettingsScope): Settings {\n\t\tlet content: string | undefined;\n\t\tstorage.withLock(scope, (current) => {\n\t\t\tcontent = current;\n\t\t\treturn undefined;\n\t\t});\n\n\t\tif (!content) {\n\t\t\treturn {};\n\t\t}\n\t\tconst settings = JSON.parse(stripBom(content));\n\t\treturn SettingsManager.migrateSettings(settings);\n\t}\n\n\tprivate static tryLoadFromStorage(\n\t\tstorage: SettingsStorage,\n\t\tscope: SettingsScope,\n\t): { settings: Settings; error: Error | null } {\n\t\ttry {\n\t\t\treturn { settings: SettingsManager.loadFromStorage(storage, scope), error: null };\n\t\t} catch (error) {\n\t\t\treturn { settings: {}, error: error as Error };\n\t\t}\n\t}\n\n\t/** Migrate old settings format to new format */\n\tprivate static migrateSettings(settings: Record<string, unknown>): Settings {\n\t\t// Migrate queueMode -> steeringMode\n\t\tif (\"queueMode\" in settings && !(\"steeringMode\" in settings)) {\n\t\t\tsettings.steeringMode = settings.queueMode;\n\t\t\tdelete settings.queueMode;\n\t\t}\n\n\t\t// Migrate legacy websockets boolean -> transport enum\n\t\tif (!(\"transport\" in settings) && typeof settings.websockets === \"boolean\") {\n\t\t\tsettings.transport = settings.websockets ? \"websocket\" : \"sse\";\n\t\t\tdelete settings.websockets;\n\t\t}\n\n\t\t// Migrate old skills object format to new array format. The legacy\n\t\t// enableSkillCommands flag is dropped with the switch itself (2026-10-03\n\t\t// D-079): skill commands register unconditionally, so the flag has no\n\t\t// target to promote to anymore.\n\t\tif (\n\t\t\t\"skills\" in settings &&\n\t\t\ttypeof settings.skills === \"object\" &&\n\t\t\tsettings.skills !== null &&\n\t\t\t!Array.isArray(settings.skills)\n\t\t) {\n\t\t\tconst skillsSettings = settings.skills as {\n\t\t\t\tcustomDirectories?: unknown;\n\t\t\t};\n\t\t\tif (Array.isArray(skillsSettings.customDirectories) && skillsSettings.customDirectories.length > 0) {\n\t\t\t\tsettings.skills = skillsSettings.customDirectories;\n\t\t\t} else {\n\t\t\t\tdelete settings.skills;\n\t\t\t}\n\t\t}\n\n\t\t// Migrate retry.maxDelayMs -> retry.provider.maxRetryDelayMs\n\t\tif (\n\t\t\t\"retry\" in settings &&\n\t\t\ttypeof settings.retry === \"object\" &&\n\t\t\tsettings.retry !== null &&\n\t\t\t!Array.isArray(settings.retry)\n\t\t) {\n\t\t\tconst retrySettings = settings.retry as Record<string, unknown>;\n\t\t\tconst providerSettings =\n\t\t\t\ttypeof retrySettings.provider === \"object\" && retrySettings.provider !== null\n\t\t\t\t\t? (retrySettings.provider as Record<string, unknown>)\n\t\t\t\t\t: undefined;\n\t\t\tif (\n\t\t\t\ttypeof retrySettings.maxDelayMs === \"number\" &&\n\t\t\t\t(providerSettings?.maxRetryDelayMs === undefined || providerSettings?.maxRetryDelayMs === null)\n\t\t\t) {\n\t\t\t\tretrySettings.provider = {\n\t\t\t\t\t...(providerSettings ?? {}),\n\t\t\t\t\tmaxRetryDelayMs: retrySettings.maxDelayMs,\n\t\t\t\t};\n\t\t\t}\n\t\t\tdelete retrySettings.maxDelayMs;\n\t\t}\n\n\t\treturn settings as Settings;\n\t}\n\n\tgetGlobalSettings(): Settings {\n\t\treturn structuredClone(this.globalSettings);\n\t}\n\n\tgetProjectSettings(): Settings {\n\t\treturn structuredClone(this.projectSettings);\n\t}\n\n\tasync reload(): Promise<void> {\n\t\tawait this.writeQueue;\n\t\tconst globalLoad = SettingsManager.tryLoadFromStorage(this.storage, \"global\");\n\t\tif (!globalLoad.error) {\n\t\t\tthis.globalSettings = globalLoad.settings;\n\t\t\tthis.globalSettingsLoadError = null;\n\t\t} else {\n\t\t\tthis.globalSettingsLoadError = globalLoad.error;\n\t\t\tthis.recordError(\"global\", globalLoad.error);\n\t\t}\n\n\t\tthis.modifiedFields.clear();\n\t\tthis.modifiedNestedFields.clear();\n\t\tthis.modifiedProjectFields.clear();\n\t\tthis.modifiedProjectNestedFields.clear();\n\n\t\tconst projectLoad = SettingsManager.tryLoadFromStorage(this.storage, \"project\");\n\t\tif (!projectLoad.error) {\n\t\t\tthis.projectSettings = projectLoad.settings;\n\t\t\tthis.projectSettingsLoadError = null;\n\t\t} else {\n\t\t\tthis.projectSettingsLoadError = projectLoad.error;\n\t\t\tthis.recordError(\"project\", projectLoad.error);\n\t\t}\n\n\t\tthis.settings = deepMergeSettings(this.globalSettings, this.projectSettings);\n\t}\n\n\t/** Apply additional overrides on top of current settings */\n\tapplyOverrides(overrides: Partial<Settings>): void {\n\t\tthis.settings = deepMergeSettings(this.settings, overrides);\n\t}\n\n\t/** Mark a global field as modified during this session */\n\tprivate markModified(field: keyof Settings, nestedKey?: string): void {\n\t\tthis.modifiedFields.add(field);\n\t\tif (nestedKey) {\n\t\t\tif (!this.modifiedNestedFields.has(field)) {\n\t\t\t\tthis.modifiedNestedFields.set(field, new Set());\n\t\t\t}\n\t\t\tthis.modifiedNestedFields.get(field)!.add(nestedKey);\n\t\t}\n\t}\n\n\t/** Mark a project field as modified during this session */\n\tprivate markProjectModified(field: keyof Settings, nestedKey?: string): void {\n\t\tthis.modifiedProjectFields.add(field);\n\t\tif (nestedKey) {\n\t\t\tif (!this.modifiedProjectNestedFields.has(field)) {\n\t\t\t\tthis.modifiedProjectNestedFields.set(field, new Set());\n\t\t\t}\n\t\t\tthis.modifiedProjectNestedFields.get(field)!.add(nestedKey);\n\t\t}\n\t}\n\n\tprivate recordError(scope: SettingsScope, error: unknown): void {\n\t\tthis.errors.push(toSettingsError(scope, error, this.settingsPaths[scope]));\n\t}\n\n\tprivate clearModifiedScope(scope: SettingsScope): void {\n\t\tif (scope === \"global\") {\n\t\t\tthis.modifiedFields.clear();\n\t\t\tthis.modifiedNestedFields.clear();\n\t\t\treturn;\n\t\t}\n\n\t\tthis.modifiedProjectFields.clear();\n\t\tthis.modifiedProjectNestedFields.clear();\n\t}\n\n\tprivate enqueueWrite(scope: SettingsScope, task: () => void): void {\n\t\tthis.writeQueue = this.writeQueue\n\t\t\t.then(() => {\n\t\t\t\ttask();\n\t\t\t\tthis.clearModifiedScope(scope);\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tthis.recordError(scope, error);\n\t\t\t});\n\t}\n\n\tprivate cloneModifiedNestedFields(source: Map<keyof Settings, Set<string>>): Map<keyof Settings, Set<string>> {\n\t\tconst snapshot = new Map<keyof Settings, Set<string>>();\n\t\tfor (const [key, value] of source.entries()) {\n\t\t\tsnapshot.set(key, new Set(value));\n\t\t}\n\t\treturn snapshot;\n\t}\n\n\tprivate persistScopedSettings(\n\t\tscope: SettingsScope,\n\t\tsnapshotSettings: Settings,\n\t\tmodifiedFields: Set<keyof Settings>,\n\t\tmodifiedNestedFields: Map<keyof Settings, Set<string>>,\n\t): void {\n\t\tthis.storage.withLock(scope, (current) => {\n\t\t\tconst currentFileSettings = current\n\t\t\t\t? SettingsManager.migrateSettings(JSON.parse(stripBom(current)) as Record<string, unknown>)\n\t\t\t\t: {};\n\t\t\tconst mergedSettings: Settings = { ...currentFileSettings };\n\t\t\tfor (const field of modifiedFields) {\n\t\t\t\tconst value = snapshotSettings[field];\n\t\t\t\tif (modifiedNestedFields.has(field) && typeof value === \"object\" && value !== null) {\n\t\t\t\t\tconst nestedModified = modifiedNestedFields.get(field)!;\n\t\t\t\t\tconst baseNested = (currentFileSettings[field] as Record<string, unknown>) ?? {};\n\t\t\t\t\tconst inMemoryNested = value as Record<string, unknown>;\n\t\t\t\t\tconst mergedNested = { ...baseNested };\n\t\t\t\t\tfor (const nestedKey of nestedModified) {\n\t\t\t\t\t\tmergedNested[nestedKey] = inMemoryNested[nestedKey];\n\t\t\t\t\t}\n\t\t\t\t\t(mergedSettings as Record<string, unknown>)[field] = mergedNested;\n\t\t\t\t} else {\n\t\t\t\t\t(mergedSettings as Record<string, unknown>)[field] = value;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn JSON.stringify(mergedSettings, null, 2);\n\t\t});\n\t}\n\n\tprivate save(): void {\n\t\tthis.settings = deepMergeSettings(this.globalSettings, this.projectSettings);\n\n\t\tif (this.globalSettingsLoadError) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst snapshotGlobalSettings = structuredClone(this.globalSettings);\n\t\tconst modifiedFields = new Set(this.modifiedFields);\n\t\tconst modifiedNestedFields = this.cloneModifiedNestedFields(this.modifiedNestedFields);\n\n\t\tthis.enqueueWrite(\"global\", () => {\n\t\t\tthis.persistScopedSettings(\"global\", snapshotGlobalSettings, modifiedFields, modifiedNestedFields);\n\t\t});\n\t}\n\n\tprivate saveProjectSettings(settings: Settings): void {\n\t\tthis.projectSettings = structuredClone(settings);\n\t\tthis.settings = deepMergeSettings(this.globalSettings, this.projectSettings);\n\n\t\tif (this.projectSettingsLoadError) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst snapshotProjectSettings = structuredClone(this.projectSettings);\n\t\tconst modifiedFields = new Set(this.modifiedProjectFields);\n\t\tconst modifiedNestedFields = this.cloneModifiedNestedFields(this.modifiedProjectNestedFields);\n\t\tthis.enqueueWrite(\"project\", () => {\n\t\t\tthis.persistScopedSettings(\"project\", snapshotProjectSettings, modifiedFields, modifiedNestedFields);\n\t\t});\n\t}\n\n\tprivate updateProjectSettings(field: keyof Settings, update: (settings: Settings) => void): void {\n\t\tconst projectSettings = structuredClone(this.projectSettings);\n\t\tupdate(projectSettings);\n\t\tthis.markProjectModified(field);\n\t\tthis.saveProjectSettings(projectSettings);\n\t}\n\n\tasync flush(): Promise<void> {\n\t\tawait this.writeQueue;\n\t}\n\n\tdrainErrors(): SettingsError[] {\n\t\tconst drained = [...this.errors];\n\t\tthis.errors = [];\n\t\treturn drained;\n\t}\n\n\tgetLastChangelogVersion(): string | undefined {\n\t\treturn this.settings.lastChangelogVersion;\n\t}\n\n\tsetLastChangelogVersion(version: string): void {\n\t\tthis.globalSettings.lastChangelogVersion = version;\n\t\tthis.markModified(\"lastChangelogVersion\");\n\t\tthis.save();\n\t}\n\n\tgetSuiteNoticeAcknowledgement(suiteId: string): { driftDigest?: string; upgradeRevision?: number } | undefined {\n\t\treturn this.settings.suiteNoticesAcknowledged?.[suiteId];\n\t}\n\n\tsetSuiteNoticeAcknowledgement(suiteId: string, ack: { driftDigest?: string; upgradeRevision?: number }): void {\n\t\t// 与 lastChangelogVersion 同模式:写到 globalSettings 源层——save() 会从\n\t\t// global+project 重建合并层,只写合并层会在 save 时被冲掉。\n\t\tconst next = {\n\t\t\t...(this.globalSettings.suiteNoticesAcknowledged ?? {}),\n\t\t\t...(this.settings.suiteNoticesAcknowledged ?? {}),\n\t\t};\n\t\tconst existing = next[suiteId];\n\t\tnext[suiteId] = {\n\t\t\t...(typeof existing === \"object\" && existing !== null ? existing : {}),\n\t\t\t...(ack.driftDigest === undefined ? {} : { driftDigest: ack.driftDigest }),\n\t\t\t...(ack.upgradeRevision === undefined ? {} : { upgradeRevision: ack.upgradeRevision }),\n\t\t};\n\t\tthis.globalSettings.suiteNoticesAcknowledged = next;\n\t\tthis.settings.suiteNoticesAcknowledged = next;\n\t\tthis.markModified(\"suiteNoticesAcknowledged\");\n\t\tthis.save();\n\t}\n\n\tgetSessionDir(): string | undefined {\n\t\tconst sessionDir = this.settings.sessionDir;\n\t\treturn sessionDir ? normalizePath(sessionDir) : sessionDir;\n\t}\n\n\tgetDefaultProvider(): string | undefined {\n\t\treturn this.settings.defaultProvider;\n\t}\n\n\tgetDefaultModel(): string | undefined {\n\t\treturn this.settings.defaultModel;\n\t}\n\n\t/**\n\t * 记忆全局档位(2.4d6 S1 持久配置面):settings.json `memory.mode` 原样读出。\n\t * 类型面只声明合法档位;手改文件写入的非法值不经运行时收窄、原样透传,由\n\t * `resolveMemoryMode` fail-closed 为 off 并输出诊断(不在此处静默吞掉)。\n\t */\n\tgetMemoryModeSetting(): \"off\" | \"light\" | \"full\" | undefined {\n\t\treturn this.settings.memory?.mode;\n\t}\n\n\t/**\n\t * 能力槽位配置节(供应商能力槽位设计 §3.1):返回合并层的原始\n\t * `capabilities`。结构非法时记录一条 warning(经 drainErrors 以\n\t * settings 诊断面呈现)并按 fail-closed 丢弃非法子节,不抛出、不崩溃;\n\t * 槽位失效后由消费方(image-generation 插件)按 config_missing 报\n\t * 可操作错误。warning 每实例至多记录一次。\n\t */\n\tgetCapabilitiesSettings(): CapabilitiesSettings | undefined {\n\t\tconst raw = this.settings.capabilities;\n\t\tif (raw === undefined) return undefined;\n\t\tif (!isMergeableObject(raw)) {\n\t\t\tthis.recordCapabilitiesWarning(\"capabilities must be an object\");\n\t\t\treturn undefined;\n\t\t}\n\t\tconst imageGeneration = raw.imageGeneration;\n\t\tif (imageGeneration === undefined) return raw;\n\t\tif (!isMergeableObject(imageGeneration)) {\n\t\t\tthis.recordCapabilitiesWarning(\"capabilities.imageGeneration must be an object\");\n\t\t\treturn undefined;\n\t\t}\n\t\tconst provider = imageGeneration.provider;\n\t\tif (typeof provider !== \"string\" || provider.trim() === \"\") {\n\t\t\tthis.recordCapabilitiesWarning(\n\t\t\t\t`capabilities.imageGeneration.provider must be a non-empty string: ${String(provider)}`,\n\t\t\t);\n\t\t\treturn undefined;\n\t\t}\n\t\tconst model = imageGeneration.model;\n\t\tif (model !== undefined && (typeof model !== \"string\" || model.trim() === \"\")) {\n\t\t\tthis.recordCapabilitiesWarning(\n\t\t\t\t`capabilities.imageGeneration.model must be a non-empty string when present: ${String(model)}`,\n\t\t\t);\n\t\t\treturn undefined;\n\t\t}\n\t\tconst slot: ImageGenerationCapabilitySettings = { provider, ...(model === undefined ? {} : { model }) };\n\t\treturn { ...raw, imageGeneration: slot };\n\t}\n\n\t/**\n\t * 主备切换配置节(设计 §4.1):raw 读出,原样透传合并层对象。Phase 1\n\t * 不做结构校验与默认值解析——那是 Phase 2 provider-failover 插件的\n\t * 消费面;此处提前收窄会把非法值静默变成合法语义。\n\t */\n\tgetFailoverSettings(): FailoverSettings | undefined {\n\t\tconst failover = this.settings.failover;\n\t\treturn failover === undefined ? undefined : { ...failover };\n\t}\n\n\tprivate recordCapabilitiesWarning(message: string): void {\n\t\tif (this.capabilitiesWarningRecorded) return;\n\t\tthis.capabilitiesWarningRecorded = true;\n\t\t// 槽位在两层合并后读取,无法逐字段追溯来源层;capabilities 节存在\n\t\t// 于哪层就归到哪层(project 层存在即以 project 呈现,与深合并优先级一致)。\n\t\tconst scope: SettingsScope = isMergeableObject(this.projectSettings.capabilities) ? \"project\" : \"global\";\n\t\tthis.recordError(scope, new Error(`Invalid ${message}`));\n\t}\n\n\tsetDefaultProvider(provider: string): void {\n\t\tthis.globalSettings.defaultProvider = provider;\n\t\tthis.markModified(\"defaultProvider\");\n\t\tthis.save();\n\t}\n\n\tsetDefaultModel(modelId: string): void {\n\t\tthis.globalSettings.defaultModel = modelId;\n\t\tthis.markModified(\"defaultModel\");\n\t\tthis.save();\n\t}\n\n\tsetDefaultModelAndProvider(provider: string, modelId: string): void {\n\t\tthis.globalSettings.defaultProvider = provider;\n\t\tthis.globalSettings.defaultModel = modelId;\n\t\tthis.markModified(\"defaultProvider\");\n\t\tthis.markModified(\"defaultModel\");\n\t\tthis.save();\n\t}\n\n\tgetSteeringMode(): \"all\" | \"one-at-a-time\" {\n\t\treturn this.settings.steeringMode || \"one-at-a-time\";\n\t}\n\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\"): void {\n\t\tthis.globalSettings.steeringMode = mode;\n\t\tthis.markModified(\"steeringMode\");\n\t\tthis.save();\n\t}\n\n\tgetFollowUpMode(): \"all\" | \"one-at-a-time\" {\n\t\treturn this.settings.followUpMode || \"one-at-a-time\";\n\t}\n\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\"): void {\n\t\tthis.globalSettings.followUpMode = mode;\n\t\tthis.markModified(\"followUpMode\");\n\t\tthis.save();\n\t}\n\n\tgetThemeSetting(): string | undefined {\n\t\tconst value = this.settings.theme;\n\t\tif (typeof value === \"string\") return value;\n\t\treturn undefined;\n\t}\n\n\tgetTheme(): string | undefined {\n\t\tconst theme = this.getThemeSetting();\n\t\treturn theme?.includes(\"/\") ? undefined : theme;\n\t}\n\n\tsetTheme(theme: string): void {\n\t\tthis.globalSettings.theme = theme;\n\t\tthis.markModified(\"theme\");\n\t\tthis.save();\n\t}\n\n\tgetDefaultThinkingLevel(): ThinkingLevel | undefined {\n\t\treturn this.settings.defaultThinkingLevel;\n\t}\n\n\tsetDefaultThinkingLevel(level: ThinkingLevel): void {\n\t\tthis.globalSettings.defaultThinkingLevel = level;\n\t\tthis.markModified(\"defaultThinkingLevel\");\n\t\tthis.save();\n\t}\n\n\tgetModelThinkingLevel(provider: string, modelId: string): ThinkingLevel | undefined {\n\t\treturn this.settings.modelThinkingLevels?.[`${provider}/${modelId}`];\n\t}\n\n\tgetAllModelThinkingLevels(): Record<string, ThinkingLevel> {\n\t\treturn { ...(this.settings.modelThinkingLevels ?? {}) };\n\t}\n\n\tsetModelThinkingLevel(provider: string, modelId: string, level: ThinkingLevel): void {\n\t\tif (!this.globalSettings.modelThinkingLevels) {\n\t\t\tthis.globalSettings.modelThinkingLevels = {};\n\t\t}\n\t\tthis.globalSettings.modelThinkingLevels[`${provider}/${modelId}`] = level;\n\t\tthis.markModified(\"modelThinkingLevels\");\n\t\tthis.save();\n\t}\n\n\tremoveModelThinkingLevel(provider: string, modelId: string): void {\n\t\tif (!this.globalSettings.modelThinkingLevels) return;\n\t\tdelete this.globalSettings.modelThinkingLevels[`${provider}/${modelId}`];\n\t\tif (Object.keys(this.globalSettings.modelThinkingLevels).length === 0) {\n\t\t\tdelete this.globalSettings.modelThinkingLevels;\n\t\t}\n\t\tthis.markModified(\"modelThinkingLevels\");\n\t\tthis.save();\n\t}\n\n\tgetTransport(): TransportSetting {\n\t\treturn this.settings.transport ?? \"auto\";\n\t}\n\n\tsetTransport(transport: TransportSetting): void {\n\t\tthis.globalSettings.transport = transport;\n\t\tthis.markModified(\"transport\");\n\t\tthis.save();\n\t}\n\n\tprivate getCompactionTokenSetting(\n\t\tfield: keyof CompactionModelOverride,\n\t\tmodel?: Pick<Model<string>, \"provider\" | \"id\">,\n\t): number {\n\t\tconst compaction = this.settings.compaction;\n\t\tconst ordinary = compaction?.[field];\n\t\tif (ordinary !== undefined && (typeof ordinary !== \"number\" || !Number.isSafeInteger(ordinary) || ordinary < 0)) {\n\t\t\tthrow new Error(\n\t\t\t\tt(\"Invalid compaction.{field} setting: {value}. Expected a non-negative safe integer.\", {\n\t\t\t\t\tfield,\n\t\t\t\t\tvalue: String(ordinary),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tconst modelKey = model ? `${model.provider}/${model.id}` : undefined;\n\t\tconst entry = modelKey !== undefined ? compaction?.modelOverrides?.[modelKey] : undefined;\n\t\tif (entry !== undefined && !isMergeableObject(entry)) {\n\t\t\tthrow new Error(\n\t\t\t\tt('Invalid compaction.modelOverrides[\"{modelKey}\"] setting: {value}. Expected an object.', {\n\t\t\t\t\tmodelKey: modelKey ?? \"unknown\",\n\t\t\t\t\tvalue: String(entry),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\tconst override = entry?.[field];\n\t\tif (override !== undefined && (typeof override !== \"number\" || !Number.isSafeInteger(override) || override < 0)) {\n\t\t\tthrow new Error(\n\t\t\t\tt(\n\t\t\t\t\t'Invalid compaction.modelOverrides[\"{modelKey}\"].{field} setting: {value}. Expected a non-negative safe integer.',\n\t\t\t\t\t{\n\t\t\t\t\t\tmodelKey: modelKey ?? \"unknown\",\n\t\t\t\t\t\tfield,\n\t\t\t\t\t\tvalue: String(override),\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\treturn override ?? ordinary ?? DEFAULT_COMPACTION_TOKEN_SETTINGS[field];\n\t}\n\n\tgetCompactionReserveTokens(model?: Pick<Model<string>, \"provider\" | \"id\">): number {\n\t\treturn this.getCompactionTokenSetting(\"reserveTokens\", model);\n\t}\n\n\tgetCompactionKeepRecentTokens(model?: Pick<Model<string>, \"provider\" | \"id\">): number {\n\t\treturn this.getCompactionTokenSetting(\"keepRecentTokens\", model);\n\t}\n\n\t/** Resolve each token setting through model override, ordinary setting, then built-in default. */\n\tgetCompactionSettings(model?: Pick<Model<string>, \"provider\" | \"id\">): {\n\t\treserveTokens: number;\n\t\tkeepRecentTokens: number;\n\t} {\n\t\treturn {\n\t\t\treserveTokens: this.getCompactionReserveTokens(model),\n\t\t\tkeepRecentTokens: this.getCompactionKeepRecentTokens(model),\n\t\t};\n\t}\n\n\tgetBranchSummarySettings(): { reserveTokens: number; skipPrompt: boolean } {\n\t\treturn {\n\t\t\treserveTokens: this.settings.branchSummary?.reserveTokens ?? 16384,\n\t\t\tskipPrompt: this.settings.branchSummary?.skipPrompt ?? false,\n\t\t};\n\t}\n\n\tgetBranchSummarySkipPrompt(): boolean {\n\t\treturn this.settings.branchSummary?.skipPrompt ?? false;\n\t}\n\n\t/**\n\t * 聚合 retry 数值面。返回体带常量 `enabled: true`:pi-ai `RetryPolicy`\n\t * (packages/ai/src/utils/retry.ts)的 `enabled` 是 required 字段,库层形状\n\t * 不动;产品侧自动重试无条件生效(2026-10-03 D-079,settings\n\t * `retry.enabled` 开关已移除),残留旧键按 settings 层宽松契约静默忽略。\n\t */\n\tgetRetrySettings(): { enabled: boolean; maxRetries: number; baseDelayMs: number; maxAgentDelayMs: number } {\n\t\treturn {\n\t\t\tenabled: true,\n\t\t\tmaxRetries: this.settings.retry?.maxRetries ?? 5,\n\t\t\tbaseDelayMs: this.settings.retry?.baseDelayMs ?? 2000,\n\t\t\tmaxAgentDelayMs: this.settings.retry?.maxAgentDelayMs ?? DEFAULT_MAX_AGENT_RETRY_DELAY_MS,\n\t\t};\n\t}\n\n\tgetHttpIdleTimeoutMs(): number {\n\t\treturn parseTimeoutSetting(this.settings.httpIdleTimeoutMs, \"httpIdleTimeoutMs\") ?? DEFAULT_HTTP_IDLE_TIMEOUT_MS;\n\t}\n\n\tsetHttpIdleTimeoutMs(timeoutMs: number): void {\n\t\tif (!Number.isFinite(timeoutMs) || timeoutMs < 0) {\n\t\t\tthrow new Error(t(\"Invalid httpIdleTimeoutMs setting: {value}\", { value: String(timeoutMs) }));\n\t\t}\n\t\tthis.globalSettings.httpIdleTimeoutMs = Math.floor(timeoutMs);\n\t\tthis.markModified(\"httpIdleTimeoutMs\");\n\t\tthis.save();\n\t}\n\n\tgetProviderRetrySettings(): { timeoutMs?: number; maxRetries?: number; maxRetryDelayMs: number } {\n\t\treturn {\n\t\t\ttimeoutMs: this.settings.retry?.provider?.timeoutMs,\n\t\t\tmaxRetries: this.settings.retry?.provider?.maxRetries,\n\t\t\tmaxRetryDelayMs: this.settings.retry?.provider?.maxRetryDelayMs ?? 60000,\n\t\t};\n\t}\n\n\tgetWebSocketConnectTimeoutMs(): number | undefined {\n\t\treturn parseTimeoutSetting(this.settings.websocketConnectTimeoutMs, \"websocketConnectTimeoutMs\");\n\t}\n\n\tgetHideThinkingBlock(): boolean {\n\t\treturn this.settings.hideThinkingBlock ?? false;\n\t}\n\n\tgetShowCacheMissNotices(): boolean {\n\t\treturn this.settings.showCacheMissNotices ?? false;\n\t}\n\n\tgetExternalEditorCommand(): string {\n\t\tconst configuredEditor = this.settings.externalEditor;\n\t\tif (typeof configuredEditor === \"string\" && configuredEditor.trim() !== \"\") {\n\t\t\treturn configuredEditor;\n\t\t}\n\t\tconst environmentEditor = process.env.VISUAL || process.env.EDITOR;\n\t\tif (environmentEditor) {\n\t\t\treturn environmentEditor;\n\t\t}\n\t\treturn process.platform === \"win32\" ? \"notepad\" : \"nano\";\n\t}\n\n\tsetHideThinkingBlock(hide: boolean): void {\n\t\tthis.globalSettings.hideThinkingBlock = hide;\n\t\tthis.markModified(\"hideThinkingBlock\");\n\t\tthis.save();\n\t}\n\n\tsetShowCacheMissNotices(show: boolean): void {\n\t\tthis.globalSettings.showCacheMissNotices = show;\n\t\tthis.markModified(\"showCacheMissNotices\");\n\t\tthis.save();\n\t}\n\n\tgetShellPath(): string | undefined {\n\t\tconst shellPath = this.settings.shellPath;\n\t\treturn shellPath ? normalizePath(shellPath) : shellPath;\n\t}\n\n\tsetShellPath(path: string | undefined): void {\n\t\tthis.globalSettings.shellPath = path;\n\t\tthis.markModified(\"shellPath\");\n\t\tthis.save();\n\t}\n\n\tgetQuietStartup(): boolean {\n\t\treturn this.settings.quietStartup ?? false;\n\t}\n\n\tsetQuietStartup(quiet: boolean): void {\n\t\tthis.globalSettings.quietStartup = quiet;\n\t\tthis.markModified(\"quietStartup\");\n\t\tthis.save();\n\t}\n\n\tgetShellCommandPrefix(): string | undefined {\n\t\treturn this.settings.shellCommandPrefix;\n\t}\n\n\tsetShellCommandPrefix(prefix: string | undefined): void {\n\t\tthis.globalSettings.shellCommandPrefix = prefix;\n\t\tthis.markModified(\"shellCommandPrefix\");\n\t\tthis.save();\n\t}\n\n\tgetNpmCommand(): string[] | undefined {\n\t\treturn this.settings.npmCommand ? [...this.settings.npmCommand] : undefined;\n\t}\n\n\tsetNpmCommand(command: string[] | undefined): void {\n\t\tthis.globalSettings.npmCommand = command ? [...command] : undefined;\n\t\tthis.markModified(\"npmCommand\");\n\t\tthis.save();\n\t}\n\n\tgetCollapseChangelog(): boolean {\n\t\treturn this.settings.collapseChangelog ?? false;\n\t}\n\n\tsetCollapseChangelog(collapse: boolean): void {\n\t\tthis.globalSettings.collapseChangelog = collapse;\n\t\tthis.markModified(\"collapseChangelog\");\n\t\tthis.save();\n\t}\n\n\tgetEnableAnalytics(): boolean {\n\t\treturn this.settings.enableAnalytics ?? false;\n\t}\n\n\tgetTrackingId(): string | undefined {\n\t\treturn this.settings.trackingId;\n\t}\n\n\t/** Set the analytics opt-in preference; generates a tracking identifier on first opt-in */\n\tsetEnableAnalytics(enabled: boolean): void {\n\t\tthis.globalSettings.enableAnalytics = enabled;\n\t\tthis.markModified(\"enableAnalytics\");\n\t\tif (enabled && !this.globalSettings.trackingId) {\n\t\t\tthis.globalSettings.trackingId = randomUUID();\n\t\t\tthis.markModified(\"trackingId\");\n\t\t}\n\t\tthis.save();\n\t}\n\n\tgetPackages(): PackageSource[] {\n\t\treturn [...(this.settings.packages ?? [])];\n\t}\n\n\tsetPackages(packages: PackageSource[]): void {\n\t\tthis.globalSettings.packages = packages;\n\t\tthis.markModified(\"packages\");\n\t\tthis.save();\n\t}\n\n\tsetProjectPackages(packages: PackageSource[]): void {\n\t\tthis.updateProjectSettings(\"packages\", (settings) => {\n\t\t\tsettings.packages = packages;\n\t\t});\n\t}\n\n\tgetSkillPaths(): string[] {\n\t\treturn [...(this.settings.skills ?? [])];\n\t}\n\n\tsetSkillPaths(paths: string[]): void {\n\t\tthis.globalSettings.skills = paths;\n\t\tthis.markModified(\"skills\");\n\t\tthis.save();\n\t}\n\n\tsetProjectSkillPaths(paths: string[]): void {\n\t\tthis.updateProjectSettings(\"skills\", (settings) => {\n\t\t\tsettings.skills = paths;\n\t\t});\n\t}\n\n\tgetPromptTemplatePaths(): string[] {\n\t\treturn [...(this.settings.prompts ?? [])];\n\t}\n\n\tsetPromptTemplatePaths(paths: string[]): void {\n\t\tthis.globalSettings.prompts = paths;\n\t\tthis.markModified(\"prompts\");\n\t\tthis.save();\n\t}\n\n\tsetProjectPromptTemplatePaths(paths: string[]): void {\n\t\tthis.updateProjectSettings(\"prompts\", (settings) => {\n\t\t\tsettings.prompts = paths;\n\t\t});\n\t}\n\n\tgetThemePaths(): string[] {\n\t\treturn [...(this.settings.themes ?? [])];\n\t}\n\n\tsetThemePaths(paths: string[]): void {\n\t\tthis.globalSettings.themes = paths;\n\t\tthis.markModified(\"themes\");\n\t\tthis.save();\n\t}\n\n\tsetProjectThemePaths(paths: string[]): void {\n\t\tthis.updateProjectSettings(\"themes\", (settings) => {\n\t\t\tsettings.themes = paths;\n\t\t});\n\t}\n\n\t/** Project-scope active suite (方案) id; undefined clears the key (设计 §9). */\n\tsetProjectSuite(id: string | undefined): void {\n\t\tthis.updateProjectSettings(\"suite\", (settings) => {\n\t\t\tif (id === undefined) {\n\t\t\t\tdelete settings.suite;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsettings.suite = id;\n\t\t});\n\t}\n\n\t/** Global-scope active suite (方案) id; undefined clears the key (设计 §9). */\n\tsetSuite(id: string | undefined): void {\n\t\tif (id === undefined) {\n\t\t\tdelete this.globalSettings.suite;\n\t\t} else {\n\t\t\tthis.globalSettings.suite = id;\n\t\t}\n\t\tthis.markModified(\"suite\");\n\t\tthis.save();\n\t}\n\n\tgetThinkingBudgets(): ThinkingBudgetsSettings | undefined {\n\t\treturn this.settings.thinkingBudgets;\n\t}\n\n\tgetTerminalCapabilityOverrides(): Partial<TerminalCapabilities> {\n\t\tconst terminal = this.settings.terminal;\n\t\tconst images = terminal?.images;\n\t\treturn {\n\t\t\t...(images === \"kitty\" || images === \"iterm2\" ? { images } : images === false ? { images: null } : {}),\n\t\t\t...(typeof terminal?.trueColor === \"boolean\" ? { trueColor: terminal.trueColor } : {}),\n\t\t\t...(typeof terminal?.hyperlinks === \"boolean\" ? { hyperlinks: terminal.hyperlinks } : {}),\n\t\t};\n\t}\n\n\tgetShowImages(): boolean {\n\t\treturn this.settings.terminal?.showImages ?? true;\n\t}\n\n\tsetShowImages(show: boolean): void {\n\t\tif (!this.globalSettings.terminal) {\n\t\t\tthis.globalSettings.terminal = {};\n\t\t}\n\t\tthis.globalSettings.terminal.showImages = show;\n\t\tthis.markModified(\"terminal\", \"showImages\");\n\t\tthis.save();\n\t}\n\n\tgetImageWidthCells(): number {\n\t\tconst width = this.settings.terminal?.imageWidthCells;\n\t\tif (typeof width !== \"number\" || !Number.isFinite(width)) {\n\t\t\treturn 60;\n\t\t}\n\t\treturn Math.max(1, Math.floor(width));\n\t}\n\n\tsetImageWidthCells(width: number): void {\n\t\tif (!this.globalSettings.terminal) {\n\t\t\tthis.globalSettings.terminal = {};\n\t\t}\n\t\tthis.globalSettings.terminal.imageWidthCells = Math.max(1, Math.floor(width));\n\t\tthis.markModified(\"terminal\", \"imageWidthCells\");\n\t\tthis.save();\n\t}\n\n\tgetClearOnShrink(): boolean {\n\t\t// Settings takes precedence, then env var, then default false\n\t\tif (this.settings.terminal?.clearOnShrink !== undefined) {\n\t\t\treturn this.settings.terminal.clearOnShrink;\n\t\t}\n\t\tconst configuredValue = process.env.AGENT_FORGE_CLEAR_ON_SHRINK;\n\t\t// Legacy fallback for installations configured before the Agent Forge rename.\n\t\treturn configuredValue === undefined ? process.env.PI_CLEAR_ON_SHRINK === \"1\" : configuredValue === \"1\";\n\t}\n\n\tsetClearOnShrink(enabled: boolean): void {\n\t\tif (!this.globalSettings.terminal) {\n\t\t\tthis.globalSettings.terminal = {};\n\t\t}\n\t\tthis.globalSettings.terminal.clearOnShrink = enabled;\n\t\tthis.markModified(\"terminal\", \"clearOnShrink\");\n\t\tthis.save();\n\t}\n\n\tgetShowTerminalProgress(): boolean {\n\t\treturn this.settings.terminal?.showTerminalProgress ?? false;\n\t}\n\n\tsetShowTerminalProgress(enabled: boolean): void {\n\t\tif (!this.globalSettings.terminal) {\n\t\t\tthis.globalSettings.terminal = {};\n\t\t}\n\t\tthis.globalSettings.terminal.showTerminalProgress = enabled;\n\t\tthis.markModified(\"terminal\", \"showTerminalProgress\");\n\t\tthis.save();\n\t}\n\n\tgetTuiMode(): TuiMode {\n\t\treturn this.settings.tuiMode === \"fullscreen\" ? \"fullscreen\" : \"regular\";\n\t}\n\n\tsetTuiMode(mode: TuiMode): void {\n\t\tthis.globalSettings.tuiMode = mode;\n\t\tthis.markModified(\"tuiMode\");\n\t\tthis.save();\n\t}\n\n\tgetFullscreenExitOutput(): FullscreenExitOutput {\n\t\treturn this.settings.fullscreenExitOutput === \"resume-hint\" ? \"resume-hint\" : \"transcript\";\n\t}\n\n\tsetFullscreenExitOutput(output: FullscreenExitOutput): void {\n\t\tthis.globalSettings.fullscreenExitOutput = output;\n\t\tthis.markModified(\"fullscreenExitOutput\");\n\t\tthis.save();\n\t}\n\n\tgetFullscreenScrollbar(): ScrollViewScrollbar {\n\t\tconst mode = this.settings.fullscreenScrollbar;\n\t\treturn mode === \"always\" || mode === \"hidden\" ? mode : \"auto\";\n\t}\n\n\tsetFullscreenScrollbar(mode: ScrollViewScrollbar): void {\n\t\tthis.globalSettings.fullscreenScrollbar = mode;\n\t\tthis.markModified(\"fullscreenScrollbar\");\n\t\tthis.save();\n\t}\n\n\tgetFullscreenCopyOnSelect(): boolean {\n\t\treturn this.settings.fullscreenCopyOnSelect ?? true;\n\t}\n\n\tsetFullscreenCopyOnSelect(enabled: boolean): void {\n\t\tthis.globalSettings.fullscreenCopyOnSelect = enabled;\n\t\tthis.markModified(\"fullscreenCopyOnSelect\");\n\t\tthis.save();\n\t}\n\n\tgetFullscreenWheelScrollLines(): WheelScrollLines {\n\t\tconst lines = this.settings.fullscreenWheelScrollLines;\n\t\treturn typeof lines === \"number\" && Number.isFinite(lines)\n\t\t\t? Math.max(1, Math.min(100, Math.floor(lines)))\n\t\t\t: \"auto\";\n\t}\n\n\tsetFullscreenWheelScrollLines(lines: WheelScrollLines): void {\n\t\tthis.globalSettings.fullscreenWheelScrollLines =\n\t\t\tlines === \"auto\" ? lines : Math.max(1, Math.min(100, Math.floor(lines)));\n\t\tthis.markModified(\"fullscreenWheelScrollLines\");\n\t\tthis.save();\n\t}\n\n\tgetImageAutoResize(): boolean {\n\t\treturn this.settings.images?.autoResize ?? true;\n\t}\n\n\tsetImageAutoResize(enabled: boolean): void {\n\t\tif (!this.globalSettings.images) {\n\t\t\tthis.globalSettings.images = {};\n\t\t}\n\t\tthis.globalSettings.images.autoResize = enabled;\n\t\tthis.markModified(\"images\", \"autoResize\");\n\t\tthis.save();\n\t}\n\n\tgetBlockImages(): boolean {\n\t\treturn this.settings.images?.blockImages ?? false;\n\t}\n\n\tsetBlockImages(blocked: boolean): void {\n\t\tif (!this.globalSettings.images) {\n\t\t\tthis.globalSettings.images = {};\n\t\t}\n\t\tthis.globalSettings.images.blockImages = blocked;\n\t\tthis.markModified(\"images\", \"blockImages\");\n\t\tthis.save();\n\t}\n\n\tgetEnabledModels(): string[] | undefined {\n\t\treturn this.settings.enabledModels;\n\t}\n\n\t/** The resolved `defaultTools` selection, or undefined when no settings layer sets it. */\n\tgetDefaultTools(): string[] | undefined {\n\t\tconst tools = this.settings.defaultTools;\n\t\tif (tools === undefined) return undefined;\n\t\treturn resolveDefaultTools(Array.isArray(tools) ? tools.filter((tool) => typeof tool === \"string\") : []);\n\t}\n\n\tsetEnabledModels(patterns: string[] | undefined): void {\n\t\tthis.globalSettings.enabledModels = patterns;\n\t\tthis.markModified(\"enabledModels\");\n\t\tthis.save();\n\t}\n\n\tgetDoubleEscapeAction(): \"tree\" | \"none\" {\n\t\treturn this.settings.doubleEscapeAction === \"none\" ? \"none\" : \"tree\";\n\t}\n\n\tgetUiLanguage(): I18nLanguage {\n\t\treturn this.settings.ui?.language === \"en\" ? \"en\" : \"zh-CN\";\n\t}\n\n\tsetUiLanguage(language: I18nLanguage): void {\n\t\tif (!this.globalSettings.ui) {\n\t\t\tthis.globalSettings.ui = {};\n\t\t}\n\t\tthis.globalSettings.ui.language = language;\n\t\tthis.markModified(\"ui\", \"language\");\n\t\tthis.save();\n\t}\n\n\tsetDoubleEscapeAction(action: \"tree\" | \"none\"): void {\n\t\tthis.globalSettings.doubleEscapeAction = action;\n\t\tthis.markModified(\"doubleEscapeAction\");\n\t\tthis.save();\n\t}\n\n\tgetTreeFilterMode(): \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\" {\n\t\tconst mode = this.settings.treeFilterMode;\n\t\tconst valid = [\"default\", \"no-tools\", \"user-only\", \"labeled-only\", \"all\"];\n\t\treturn mode && valid.includes(mode) ? mode : \"default\";\n\t}\n\n\tsetTreeFilterMode(mode: \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\"): void {\n\t\tthis.globalSettings.treeFilterMode = mode;\n\t\tthis.markModified(\"treeFilterMode\");\n\t\tthis.save();\n\t}\n\n\tgetShowHardwareCursor(): boolean {\n\t\tif (this.settings.showHardwareCursor !== undefined) {\n\t\t\treturn this.settings.showHardwareCursor;\n\t\t}\n\t\tconst configuredValue = process.env.AGENT_FORGE_HARDWARE_CURSOR;\n\t\t// Legacy fallback for installations configured before the Agent Forge rename.\n\t\treturn configuredValue === undefined ? process.env.PI_HARDWARE_CURSOR === \"1\" : configuredValue === \"1\";\n\t}\n\n\tsetShowHardwareCursor(enabled: boolean): void {\n\t\tthis.globalSettings.showHardwareCursor = enabled;\n\t\tthis.markModified(\"showHardwareCursor\");\n\t\tthis.save();\n\t}\n\n\tgetEditorPaddingX(): number {\n\t\treturn this.settings.editorPaddingX ?? 0;\n\t}\n\n\tsetEditorPaddingX(padding: number): void {\n\t\tthis.globalSettings.editorPaddingX = Math.max(0, Math.min(3, Math.floor(padding)));\n\t\tthis.markModified(\"editorPaddingX\");\n\t\tthis.save();\n\t}\n\n\tgetOutputPad(): 0 | 1 {\n\t\treturn this.settings.outputPad === 0 ? 0 : 1;\n\t}\n\n\tsetOutputPad(padding: 0 | 1): void {\n\t\tthis.globalSettings.outputPad = padding;\n\t\tthis.markModified(\"outputPad\");\n\t\tthis.save();\n\t}\n\n\tgetAutocompleteMaxVisible(): number {\n\t\treturn this.settings.autocompleteMaxVisible ?? 5;\n\t}\n\n\tsetAutocompleteMaxVisible(maxVisible: number): void {\n\t\tthis.globalSettings.autocompleteMaxVisible = Math.max(3, Math.min(20, Math.floor(maxVisible)));\n\t\tthis.markModified(\"autocompleteMaxVisible\");\n\t\tthis.save();\n\t}\n\n\tgetCodeBlockIndent(): string {\n\t\treturn this.settings.markdown?.codeBlockIndent ?? \" \";\n\t}\n\n\tgetMermaidRenderingMode(): MermaidRenderingMode {\n\t\tconst mode = this.settings.markdown?.mermaid;\n\t\treturn mode === \"off\" || mode === \"final\" ? mode : \"streaming\";\n\t}\n\n\tsetMermaidRenderingMode(mode: MermaidRenderingMode): void {\n\t\tthis.globalSettings.markdown ??= {};\n\t\tthis.globalSettings.markdown.mermaid = mode;\n\t\tthis.markModified(\"markdown\", \"mermaid\");\n\t\tthis.save();\n\t}\n\n\tgetWarnings(): WarningSettings {\n\t\treturn { ...(this.settings.warnings ?? {}) };\n\t}\n\n\tsetWarnings(warnings: WarningSettings): void {\n\t\tthis.globalSettings.warnings = { ...warnings };\n\t\tthis.markModified(\"warnings\");\n\t\tthis.save();\n\t}\n}\n"]}
1
+ {"version":3,"file":"settings-manager.d.ts","sourceRoot":"","sources":["../../src/core/settings-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAoC,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC/F,OAAO,KAAK,EACX,OAAO,IAAI,eAAe,EAC1B,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,MAAM,kBAAkB,CAAC;AAU1B,OAAO,EAAE,KAAK,YAAY,EAAK,MAAM,iBAAiB,CAAC;AAEvD,MAAM,WAAW,uBAAuB;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC1B;AAOD,MAAM,WAAW,kBAAkB;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CA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;IAED,qBAAqB,IAAI,MAAM,GAAG,MAAM,CAEvC;IAED,aAAa,IAAI,YAAY,CAE5B;IAED,aAAa,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAO1C;IAED,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAInD;IAED,iBAAiB,IAAI,SAAS,GAAG,UAAU,GAAG,WAAW,GAAG,cAAc,GAAG,KAAK,CAIjF;IAED,iBAAiB,CAAC,IAAI,EAAE,SAAS,GAAG,UAAU,GAAG,WAAW,GAAG,cAAc,GAAG,KAAK,GAAG,IAAI,CAI3F;IAED,qBAAqB,IAAI,OAAO,CAK/B;IAED,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAI5C;IAED,iBAAiB,IAAI,MAAM,CAE1B;IAED,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAIvC;IAED,YAAY,IAAI,CAAC,GAAG,CAAC,CAEpB;IAED,YAAY,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAIjC;IAED,yBAAyB,IAAI,MAAM,CAElC;IAED,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAIlD;IAED,kBAAkB,IAAI,MAAM,CAE3B;IAED,uBAAuB,IAAI,oBAAoB,CAG9C;IAED,uBAAuB,CAAC,IAAI,EAAE,oBAAoB,GAAG,IAAI,CAKxD;IAED,WAAW,IAAI,eAAe,CAE7B;IAED,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAI3C;CACD","sourcesContent":["import type { ThinkingLevel } from \"@agent-forge/agent-core\";\nimport { DEFAULT_MAX_AGENT_RETRY_DELAY_MS, type Model, type Transport } from \"@agent-forge/ai\";\nimport type {\n\tTuiMode as RendererTuiMode,\n\tScrollViewScrollbar,\n\tTerminalCapabilities,\n\tWheelScrollLines,\n} from \"@agent-forge/tui\";\nimport { randomUUID } from \"crypto\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\nimport lockfile from \"proper-lockfile\";\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../config.ts\";\nimport { normalizePath, resolvePath } from \"../utils/paths.ts\";\nimport { sleepSync } from \"../utils/sync-sleep.ts\";\nimport { stripBom } from \"../utils/text.ts\";\nimport { DEFAULT_HTTP_IDLE_TIMEOUT_MS, parseHttpIdleTimeoutMs } from \"./http-dispatcher.ts\";\nimport { type I18nLanguage, t } from \"./i18n/index.ts\";\n\nexport interface CompactionModelOverride {\n\treserveTokens?: number;\n\tkeepRecentTokens?: number;\n}\n\nconst DEFAULT_COMPACTION_TOKEN_SETTINGS: Required<CompactionModelOverride> = {\n\treserveTokens: 16384,\n\tkeepRecentTokens: 20000,\n};\n\nexport interface CompactionSettings {\n\treserveTokens?: number; // default: 16384\n\tkeepRecentTokens?: number; // default: 20000\n\tmodelOverrides?: Record<string, CompactionModelOverride>; // exact \"provider/modelId\" keys\n}\n\nexport interface BranchSummarySettings {\n\treserveTokens?: number; // default: 16384 (tokens reserved for prompt + LLM response)\n\tskipPrompt?: boolean; // default: false - when true, skips \"Summarize branch?\" prompt and defaults to no summary\n}\n\nexport interface ProviderRetrySettings {\n\ttimeoutMs?: number; // SDK/provider request timeout in milliseconds\n\tmaxRetries?: number; // SDK/provider retry attempts\n\tmaxRetryDelayMs?: number; // default: 60000 (max server-requested delay before failing)\n}\n\nexport interface RetrySettings {\n\tmaxRetries?: number; // default: 5 (matches codex's stream_max_retries default)\n\tbaseDelayMs?: number; // default: 2000 (exponential backoff with ±10% jitter: ~2s, ~4s, ~8s, ~16s, ~32s)\n\tmaxAgentDelayMs?: number; // default: 60000 (cap applied before ±10% jitter)\n\tprovider?: ProviderRetrySettings;\n}\n\nexport type TuiMode = RendererTuiMode;\nexport type FullscreenExitOutput = \"transcript\" | \"resume-hint\";\n\n/**\n * 界面语言(docs/design/国际化与本地化.md):`ui.language` 持久配置面。\n * env `AGENT_FORGE_I18N_LANG` 是更高优先的临时覆盖。\n */\nexport interface UiSettings {\n\tlanguage?: I18nLanguage; // default: \"zh-CN\"\n}\n\nexport interface TerminalSettings {\n\tshowImages?: boolean; // default: true (only relevant if terminal supports images)\n\timageWidthCells?: number; // default: 60 (preferred inline image width in terminal cells)\n\tclearOnShrink?: boolean; // default: false (clear empty rows when content shrinks)\n\tshowTerminalProgress?: boolean; // default: false (OSC 9;4 terminal progress indicators)\n\thyperlinks?: boolean | \"auto\";\n\timages?: \"kitty\" | \"iterm2\" | \"auto\" | false;\n\ttrueColor?: boolean | \"auto\";\n}\n\nexport interface ImageSettings {\n\tautoResize?: boolean; // default: true (resize images to 2000x2000 max for better model compatibility)\n\tblockImages?: boolean; // default: false - when true, prevents all images from being sent to LLM providers\n}\n\nexport interface ThinkingBudgetsSettings {\n\tminimal?: number;\n\tlow?: number;\n\tmedium?: number;\n\thigh?: number;\n}\n\nexport type MermaidRenderingMode = \"off\" | \"final\" | \"streaming\";\n\nexport interface MarkdownSettings {\n\tcodeBlockIndent?: string; // default: \" \"\n\tmermaid?: MermaidRenderingMode; // default: \"streaming\"\n}\n\nexport interface WarningSettings {\n\tanthropicExtraUsage?: boolean; // default: true\n}\n\n/**\n * 记忆全局档位(2.4d6 S1):settings.json 的持久配置面。env\n * `AGENT_FORGE_MEMORY_MODE` 是临时覆盖,优先级高于本键(完整解析链:SDK 显式值\n * > env > settings > 旧别名 env `AGENT_FORGE_MEMORY_VECTOR` > off)。\n */\nexport interface MemorySettings {\n\tmode?: \"off\" | \"light\" | \"full\";\n}\n\n/**\n * 生图独立供应商槽位(供应商能力槽位设计 §3.1):`capabilities.imageGeneration`\n * 持久配置面。`provider` 必填;`model` 可省——省略时由 image-generation 插件按\n * 该 provider 在 models.json 登记的生图模型推断(取值链见设计 §3.2)。\n */\nexport interface ImageGenerationCapabilitySettings {\n\tprovider: string;\n\tmodel?: string;\n}\n\n/** 能力槽位配置节(供应商能力槽位设计 §3.1);视频/音频未来按同名模式扩展。 */\nexport interface CapabilitiesSettings {\n\timageGeneration?: ImageGenerationCapabilitySettings;\n}\n\n/** 主备切换冷却参数(供应商能力槽位与主备切换设计 §4.1)。 */\nexport interface FailoverCooldownSettings {\n\tinitialMs?: number;\n\tmaxMs?: number;\n}\n\n/** 显式链(供应商能力槽位与主备切换设计 §4.1):主模型 → 备用模型序列。 */\nexport interface FailoverChainSettings {\n\tprimary: string;\n\tbackups: string[];\n}\n\n/**\n * 主供应商主备切换配置面(供应商能力槽位与主备切换设计 §4.1)。Phase 1 仅\n * 声明类型并提供 raw 读出(`getFailoverSettings`);任何 failover 行为都是\n * Phase 2 的 provider-failover 插件的事,本层不实现、不校验、不消费。\n */\nexport interface FailoverSettings {\n\tbackupProviders?: string[];\n\tfailureThreshold?: number;\n\tcooldown?: FailoverCooldownSettings;\n\tchains?: FailoverChainSettings[];\n}\n\nexport type TransportSetting = Transport;\n\n/**\n * Package source for npm/git packages.\n * - String form: load all resources from the package\n * - Object form: filter which resources to load\n * - autoload=false: start empty and only apply explicit resource patterns\n */\nexport type PackageSource =\n\t| string\n\t| {\n\t\t\tsource: string;\n\t\t\tautoload?: boolean;\n\t\t\textensions?: string[];\n\t\t\tskills?: string[];\n\t\t\tprompts?: string[];\n\t\t\tthemes?: string[];\n\t };\n\nexport interface Settings {\n\tlastChangelogVersion?: string;\n\t/** Suite 漂移/升级提示的已见记录(借鉴 lastChangelogVersion 模式:同版本只呈现一次)。 */\n\tsuiteNoticesAcknowledged?: Record<string, { driftDigest?: string; upgradeRevision?: number }>;\n\tdefaultProvider?: string;\n\tdefaultModel?: string;\n\tdefaultThinkingLevel?: ThinkingLevel;\n\tmodelThinkingLevels?: Record<string, ThinkingLevel>; // per-model default thinking level overrides keyed by \"provider/modelId\"\n\ttransport?: TransportSetting; // default: \"auto\"\n\tsteeringMode?: \"all\" | \"one-at-a-time\";\n\tfollowUpMode?: \"all\" | \"one-at-a-time\";\n\ttheme?: string;\n\tui?: UiSettings; // 界面语言 (ui.language); env AGENT_FORGE_I18N_LANG 可临时覆盖\n\tcompaction?: CompactionSettings;\n\tbranchSummary?: BranchSummarySettings;\n\tretry?: RetrySettings;\n\thideThinkingBlock?: boolean;\n\tshowCacheMissNotices?: boolean; // default: false - show cache cost and provider recovery notices\n\texternalEditor?: string; // Command for Ctrl+G external editor; takes precedence over VISUAL/EDITOR\n\tshellPath?: string; // Custom shell path (e.g., for Cygwin users on Windows); supports leading ~ expansion\n\tquietStartup?: boolean;\n\tshellCommandPrefix?: string; // Prefix prepended to every bash command (e.g., \"shopt -s expand_aliases\" for alias support)\n\tnpmCommand?: string[]; // Command used for npm package lookup/install operations, argv-style (e.g., [\"mise\", \"exec\", \"node@20\", \"--\", \"npm\"])\n\tcollapseChangelog?: boolean; // Show condensed changelog after update (use /changelog for full)\n\tenableAnalytics?: boolean; // default: false - opt-in analytics data sharing\n\ttrackingId?: string; // analytics tracking identifier, generated when analytics is enabled\n\tpackages?: PackageSource[]; // Array of npm/git package sources (string or object with filtering)\n\tskills?: string[]; // Array of local skill file paths or directories\n\tprompts?: string[]; // Array of local prompt template paths or directories\n\tthemes?: string[]; // Array of local theme file paths or directories\n\tterminal?: TerminalSettings;\n\timages?: ImageSettings;\n\tenabledModels?: string[]; // Model patterns for cycling (same format as --models CLI flag)\n\tdefaultTools?: string[]; // Initial tool selection; plain names replace the inherited selection, `+name` entries add to it (`-name` removal syntax removed 2026-10-03, D-079)\n\tsuite?: string; // Active suite (方案) id; resolved CLI > AGENT_FORGE_SUITE > project > global > \"assistant\"\n\tdoubleEscapeAction?: \"tree\" | \"none\"; // Action for double-escape with empty editor (default: \"tree\"; the removed \"fork\" value reads as \"tree\")\n\ttreeFilterMode?: \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\"; // Default filter when opening /tree\n\tthinkingBudgets?: ThinkingBudgetsSettings; // Custom token budgets for thinking levels\n\teditorPaddingX?: number; // Horizontal padding for input editor (default: 0)\n\toutputPad?: 0 | 1; // Horizontal padding for chat message output (default: 1)\n\tautocompleteMaxVisible?: number; // Max visible items in autocomplete dropdown (default: 5)\n\tshowHardwareCursor?: boolean; // Show terminal cursor while still positioning it for IME\n\tmarkdown?: MarkdownSettings;\n\twarnings?: WarningSettings;\n\tmemory?: MemorySettings; // 记忆全局档位 (memory.mode); env AGENT_FORGE_MEMORY_MODE 可临时覆盖\n\tcapabilities?: CapabilitiesSettings; // 能力槽位:按能力独立配置供应商(生图先行);深合并语义与现有键一致\n\tfailover?: FailoverSettings; // 主供应商主备切换(设计 §4);Phase 1 仅持久化配置面,行为属 Phase 2\n\tsessionDir?: string; // Custom session storage directory (same format as --session-dir CLI flag)\n\thttpProxy?: string; // Proxy URL applied as HTTP_PROXY and HTTPS_PROXY for Pi-managed HTTP clients\n\thttpIdleTimeoutMs?: number; // HTTP header/body idle timeout in milliseconds; 0 disables it\n\twebsocketConnectTimeoutMs?: number; // WebSocket connect/open handshake timeout in milliseconds; 0 disables it\n\ttuiMode?: TuiMode; // default: \"regular\"\n\tfullscreenExitOutput?: FullscreenExitOutput; // default: \"transcript\"; no effect in regular TUI mode\n\tfullscreenScrollbar?: ScrollViewScrollbar; // default: \"auto\"; no effect in regular TUI mode\n\tfullscreenCopyOnSelect?: boolean; // default: true; no effect in regular TUI mode\n\tfullscreenWheelScrollLines?: WheelScrollLines; // default: \"auto\"; lines per wheel event, 1-100\n}\n\nfunction isMergeableObject(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction deepMergeObjects(base: Record<string, unknown>, overrides: Record<string, unknown>): Record<string, unknown> {\n\tconst result = { ...base };\n\n\tfor (const key of Object.keys(overrides)) {\n\t\tconst overrideValue = overrides[key];\n\t\tif (overrideValue === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst baseValue = base[key];\n\t\tresult[key] =\n\t\t\tisMergeableObject(baseValue) && isMergeableObject(overrideValue)\n\t\t\t\t? deepMergeObjects(baseValue, overrideValue)\n\t\t\t\t: overrideValue;\n\t}\n\n\treturn result;\n}\n\n/** Tools enabled at startup when `defaultTools` does not change them. */\nexport const DEFAULT_TOOL_NAMES: readonly string[] = [\"read\", \"bash\", \"edit\", \"write\"];\n\n// D-079:`-name` 移除语法退役,modifier 只认 `+` 前缀。\nfunction isToolModifier(entry: unknown): boolean {\n\treturn typeof entry === \"string\" && entry.startsWith(\"+\");\n}\n\n/**\n * Merge `defaultTools` of two settings layers. A list with plain tool names replaces the inherited\n * one; a list of only `+name` entries is appended, so it modifies the inherited selection.\n */\nfunction mergeDefaultTools(base: string[] | undefined, overrides: string[] | undefined): string[] | undefined {\n\tif (overrides === undefined) return base;\n\t// Settings files are not validated; a malformed value replaces instead of throwing here.\n\tif (!Array.isArray(base) || !Array.isArray(overrides) || !overrides.every(isToolModifier)) return overrides;\n\treturn [...base, ...overrides];\n}\n\n/**\n * Resolve a merged `defaultTools` list: plain names replace `DEFAULT_TOOL_NAMES`, then `+name`\n * entries add tools in list order (`-name` removal syntax removed 2026-10-03, D-079).\n */\nfunction resolveDefaultTools(entries: string[]): string[] {\n\t// D-079:`-name` 移除语法退役——以 `-` 开头的条目跳过(不进 plain、不报错),净效果为忽略该条目。\n\tconst plain = entries.filter((entry) => !entry.startsWith(\"-\") && !isToolModifier(entry));\n\tconst tools = plain.length > 0 || entries.length === 0 ? plain : [...DEFAULT_TOOL_NAMES];\n\tfor (const entry of entries) {\n\t\tif (!isToolModifier(entry)) continue;\n\t\tconst name = entry.slice(1);\n\t\tif (name && !tools.includes(name)) tools.push(name);\n\t}\n\treturn tools;\n}\n\n/** Deep merge settings: project/overrides take precedence, nested objects merge recursively */\nfunction deepMergeSettings(base: Settings, overrides: Settings): Settings {\n\tconst merged = deepMergeObjects(base as Record<string, unknown>, overrides as Record<string, unknown>) as Settings;\n\tconst defaultTools = mergeDefaultTools(base.defaultTools, overrides.defaultTools);\n\treturn defaultTools === undefined ? merged : { ...merged, defaultTools };\n}\n\nfunction parseTimeoutSetting(value: unknown, settingName: string): number | undefined {\n\tconst timeoutMs = parseHttpIdleTimeoutMs(value);\n\tif (timeoutMs !== undefined) {\n\t\treturn timeoutMs;\n\t}\n\tif (value !== undefined) {\n\t\tthrow new Error(t(\"Invalid {settingName} setting: {value}\", { settingName, value: String(value) }));\n\t}\n\treturn undefined;\n}\n\nexport type SettingsScope = \"global\" | \"project\";\n\nexport interface SettingsManagerCreateOptions {\n\t/** @deprecated Project trust is no longer a core policy and this option is ignored. */\n\tprojectTrusted?: boolean;\n}\n\nexport interface SettingsStorage {\n\twithLock(scope: SettingsScope, fn: (current: string | undefined) => string | undefined): void;\n}\n\nexport interface SettingsError {\n\tscope: SettingsScope;\n\tpath?: string;\n\terror: Error;\n}\n\ntype SettingsPaths = Partial<Record<SettingsScope, string>>;\n\nfunction toSettingsError(scope: SettingsScope, error: unknown, path?: string): SettingsError {\n\treturn {\n\t\tscope,\n\t\t...(path ? { path } : {}),\n\t\terror: error instanceof Error ? error : new Error(String(error)),\n\t};\n}\n\nexport class FileSettingsStorage implements SettingsStorage {\n\tprivate globalSettingsPath: string;\n\tprivate projectSettingsPath: string;\n\n\tconstructor(cwd: string, agentDir: string) {\n\t\tconst resolvedCwd = resolvePath(cwd);\n\t\tconst resolvedAgentDir = resolvePath(agentDir);\n\t\tthis.globalSettingsPath = join(resolvedAgentDir, \"settings.json\");\n\t\tthis.projectSettingsPath = join(resolvedCwd, CONFIG_DIR_NAME, \"settings.json\");\n\t}\n\n\tprivate acquireLockSyncWithRetry(path: string): () => void {\n\t\tconst maxAttempts = 10;\n\t\tconst delayMs = 20;\n\t\tlet lastError: unknown;\n\n\t\tfor (let attempt = 1; attempt <= maxAttempts; attempt++) {\n\t\t\ttry {\n\t\t\t\treturn lockfile.lockSync(path, { realpath: false });\n\t\t\t} catch (error) {\n\t\t\t\tconst code =\n\t\t\t\t\ttypeof error === \"object\" && error !== null && \"code\" in error\n\t\t\t\t\t\t? String((error as { code?: unknown }).code)\n\t\t\t\t\t\t: undefined;\n\t\t\t\tif (code !== \"ELOCKED\" || attempt === maxAttempts) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tlastError = error;\n\t\t\t\t// Atomics.wait 同步休眠: 空转 while 会烧 CPU 且占住事件循环。\n\t\t\t\tsleepSync(delayMs);\n\t\t\t}\n\t\t}\n\n\t\tthrow (lastError as Error) ?? new Error(\"Failed to acquire settings lock\");\n\t}\n\n\twithLock(scope: SettingsScope, fn: (current: string | undefined) => string | undefined): void {\n\t\tconst path = scope === \"global\" ? this.globalSettingsPath : this.projectSettingsPath;\n\t\tconst dir = dirname(path);\n\n\t\tlet release: (() => void) | undefined;\n\t\ttry {\n\t\t\t// Only create directory and lock if file exists or we need to write\n\t\t\tconst fileExists = existsSync(path);\n\t\t\tif (fileExists) {\n\t\t\t\trelease = this.acquireLockSyncWithRetry(path);\n\t\t\t}\n\t\t\tconst current = fileExists ? readFileSync(path, \"utf-8\") : undefined;\n\t\t\tconst next = fn(current);\n\t\t\tif (next !== undefined) {\n\t\t\t\t// Only create directory when we actually need to write\n\t\t\t\tif (!existsSync(dir)) {\n\t\t\t\t\tmkdirSync(dir, { recursive: true });\n\t\t\t\t}\n\t\t\t\tif (!release) {\n\t\t\t\t\trelease = this.acquireLockSyncWithRetry(path);\n\t\t\t\t}\n\t\t\t\twriteFileSync(path, next, \"utf-8\");\n\t\t\t}\n\t\t} finally {\n\t\t\tif (release) {\n\t\t\t\trelease();\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport class InMemorySettingsStorage implements SettingsStorage {\n\tprivate global: string | undefined;\n\tprivate project: string | undefined;\n\n\twithLock(scope: SettingsScope, fn: (current: string | undefined) => string | undefined): void {\n\t\tconst current = scope === \"global\" ? this.global : this.project;\n\t\tconst next = fn(current);\n\t\tif (next !== undefined) {\n\t\t\tif (scope === \"global\") {\n\t\t\t\tthis.global = next;\n\t\t\t} else {\n\t\t\t\tthis.project = next;\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport class SettingsManager {\n\tprivate storage: SettingsStorage;\n\tprivate globalSettings: Settings;\n\tprivate projectSettings: Settings;\n\tprivate settings: Settings;\n\tprivate modifiedFields = new Set<keyof Settings>(); // Track global fields modified during session\n\tprivate modifiedNestedFields = new Map<keyof Settings, Set<string>>(); // Track global nested field modifications\n\tprivate modifiedProjectFields = new Set<keyof Settings>(); // Track project fields modified during session\n\tprivate modifiedProjectNestedFields = new Map<keyof Settings, Set<string>>(); // Track project nested field modifications\n\tprivate globalSettingsLoadError: Error | null = null; // Track if global settings file had parse errors\n\tprivate projectSettingsLoadError: Error | null = null; // Track if project settings file had parse errors\n\tprivate capabilitiesWarningRecorded = false; // One capabilities-structure warning per manager lifetime\n\tprivate writeQueue: Promise<void> = Promise.resolve();\n\tprivate errors: SettingsError[];\n\tprivate settingsPaths: SettingsPaths;\n\n\tprivate constructor(\n\t\tstorage: SettingsStorage,\n\t\tinitialGlobal: Settings,\n\t\tinitialProject: Settings,\n\t\tglobalLoadError: Error | null = null,\n\t\tprojectLoadError: Error | null = null,\n\t\tinitialErrors: SettingsError[] = [],\n\t\tsettingsPaths: SettingsPaths = {},\n\t) {\n\t\tthis.storage = storage;\n\t\tthis.globalSettings = initialGlobal;\n\t\tthis.projectSettings = initialProject;\n\t\tthis.globalSettingsLoadError = globalLoadError;\n\t\tthis.projectSettingsLoadError = projectLoadError;\n\t\tthis.errors = [...initialErrors];\n\t\tthis.settingsPaths = settingsPaths;\n\t\tthis.settings = deepMergeSettings(this.globalSettings, this.projectSettings);\n\t}\n\n\t/** Create a SettingsManager that loads from files */\n\tstatic create(\n\t\tcwd: string,\n\t\tagentDir: string = getAgentDir(),\n\t\toptions: SettingsManagerCreateOptions = {},\n\t): SettingsManager {\n\t\tconst resolvedCwd = resolvePath(cwd);\n\t\tconst resolvedAgentDir = resolvePath(agentDir);\n\t\tconst storage = new FileSettingsStorage(resolvedCwd, resolvedAgentDir);\n\t\treturn SettingsManager.fromStorageWithPaths(storage, options, {\n\t\t\tglobal: join(resolvedAgentDir, \"settings.json\"),\n\t\t\tproject: join(resolvedCwd, CONFIG_DIR_NAME, \"settings.json\"),\n\t\t});\n\t}\n\n\t/** Create a SettingsManager from an arbitrary storage backend */\n\tstatic fromStorage(storage: SettingsStorage, options: SettingsManagerCreateOptions = {}): SettingsManager {\n\t\treturn SettingsManager.fromStorageWithPaths(storage, options);\n\t}\n\n\t/** Create a manager while retaining optional file paths for reported storage errors. */\n\tprivate static fromStorageWithPaths(\n\t\tstorage: SettingsStorage,\n\t\toptions: SettingsManagerCreateOptions,\n\t\tsettingsPaths: SettingsPaths = {},\n\t): SettingsManager {\n\t\tvoid options;\n\t\tconst globalLoad = SettingsManager.tryLoadFromStorage(storage, \"global\");\n\t\tconst projectLoad = SettingsManager.tryLoadFromStorage(storage, \"project\");\n\t\tconst initialErrors: SettingsError[] = [];\n\t\tif (globalLoad.error) {\n\t\t\tinitialErrors.push(toSettingsError(\"global\", globalLoad.error, settingsPaths.global));\n\t\t}\n\t\tif (projectLoad.error) {\n\t\t\tinitialErrors.push(toSettingsError(\"project\", projectLoad.error, settingsPaths.project));\n\t\t}\n\n\t\treturn new SettingsManager(\n\t\t\tstorage,\n\t\t\tglobalLoad.settings,\n\t\t\tprojectLoad.settings,\n\t\t\tglobalLoad.error,\n\t\t\tprojectLoad.error,\n\t\t\tinitialErrors,\n\t\t\tsettingsPaths,\n\t\t);\n\t}\n\n\t/** Create an in-memory SettingsManager (no file I/O) */\n\tstatic inMemory(settings: Partial<Settings> = {}, options: SettingsManagerCreateOptions = {}): SettingsManager {\n\t\tconst storage = new InMemorySettingsStorage();\n\t\tconst initialSettings = SettingsManager.migrateSettings(structuredClone(settings) as Record<string, unknown>);\n\t\tstorage.withLock(\"global\", () => JSON.stringify(initialSettings, null, 2));\n\t\treturn SettingsManager.fromStorage(storage, options);\n\t}\n\n\tprivate static loadFromStorage(storage: SettingsStorage, scope: SettingsScope): Settings {\n\t\tlet content: string | undefined;\n\t\tstorage.withLock(scope, (current) => {\n\t\t\tcontent = current;\n\t\t\treturn undefined;\n\t\t});\n\n\t\tif (!content) {\n\t\t\treturn {};\n\t\t}\n\t\tconst settings = JSON.parse(stripBom(content));\n\t\treturn SettingsManager.migrateSettings(settings);\n\t}\n\n\tprivate static tryLoadFromStorage(\n\t\tstorage: SettingsStorage,\n\t\tscope: SettingsScope,\n\t): { settings: Settings; error: Error | null } {\n\t\ttry {\n\t\t\treturn { settings: SettingsManager.loadFromStorage(storage, scope), error: null };\n\t\t} catch (error) {\n\t\t\treturn { settings: {}, error: error as Error };\n\t\t}\n\t}\n\n\t/** Migrate old settings format to new format */\n\tprivate static migrateSettings(settings: Record<string, unknown>): Settings {\n\t\t// Migrate queueMode -> steeringMode\n\t\tif (\"queueMode\" in settings && !(\"steeringMode\" in settings)) {\n\t\t\tsettings.steeringMode = settings.queueMode;\n\t\t\tdelete settings.queueMode;\n\t\t}\n\n\t\t// Migrate legacy websockets boolean -> transport enum\n\t\tif (!(\"transport\" in settings) && typeof settings.websockets === \"boolean\") {\n\t\t\tsettings.transport = settings.websockets ? \"websocket\" : \"sse\";\n\t\t\tdelete settings.websockets;\n\t\t}\n\n\t\t// Migrate old skills object format to new array format. The legacy\n\t\t// enableSkillCommands flag is dropped with the switch itself (2026-10-03\n\t\t// D-079): skill commands register unconditionally, so the flag has no\n\t\t// target to promote to anymore.\n\t\tif (\n\t\t\t\"skills\" in settings &&\n\t\t\ttypeof settings.skills === \"object\" &&\n\t\t\tsettings.skills !== null &&\n\t\t\t!Array.isArray(settings.skills)\n\t\t) {\n\t\t\tconst skillsSettings = settings.skills as {\n\t\t\t\tcustomDirectories?: unknown;\n\t\t\t};\n\t\t\tif (Array.isArray(skillsSettings.customDirectories) && skillsSettings.customDirectories.length > 0) {\n\t\t\t\tsettings.skills = skillsSettings.customDirectories;\n\t\t\t} else {\n\t\t\t\tdelete settings.skills;\n\t\t\t}\n\t\t}\n\n\t\t// Migrate retry.maxDelayMs -> retry.provider.maxRetryDelayMs\n\t\tif (\n\t\t\t\"retry\" in settings &&\n\t\t\ttypeof settings.retry === \"object\" &&\n\t\t\tsettings.retry !== null &&\n\t\t\t!Array.isArray(settings.retry)\n\t\t) {\n\t\t\tconst retrySettings = settings.retry as Record<string, unknown>;\n\t\t\tconst providerSettings =\n\t\t\t\ttypeof retrySettings.provider === \"object\" && retrySettings.provider !== null\n\t\t\t\t\t? (retrySettings.provider as Record<string, unknown>)\n\t\t\t\t\t: undefined;\n\t\t\tif (\n\t\t\t\ttypeof retrySettings.maxDelayMs === \"number\" &&\n\t\t\t\t(providerSettings?.maxRetryDelayMs === undefined || providerSettings?.maxRetryDelayMs === null)\n\t\t\t) {\n\t\t\t\tretrySettings.provider = {\n\t\t\t\t\t...(providerSettings ?? {}),\n\t\t\t\t\tmaxRetryDelayMs: retrySettings.maxDelayMs,\n\t\t\t\t};\n\t\t\t}\n\t\t\tdelete retrySettings.maxDelayMs;\n\t\t}\n\n\t\treturn settings as Settings;\n\t}\n\n\tgetGlobalSettings(): Settings {\n\t\treturn structuredClone(this.globalSettings);\n\t}\n\n\tgetProjectSettings(): Settings {\n\t\treturn structuredClone(this.projectSettings);\n\t}\n\n\tasync reload(): Promise<void> {\n\t\tawait this.writeQueue;\n\t\tconst globalLoad = SettingsManager.tryLoadFromStorage(this.storage, \"global\");\n\t\tif (!globalLoad.error) {\n\t\t\tthis.globalSettings = globalLoad.settings;\n\t\t\tthis.globalSettingsLoadError = null;\n\t\t} else {\n\t\t\tthis.globalSettingsLoadError = globalLoad.error;\n\t\t\tthis.recordError(\"global\", globalLoad.error);\n\t\t}\n\n\t\tthis.modifiedFields.clear();\n\t\tthis.modifiedNestedFields.clear();\n\t\tthis.modifiedProjectFields.clear();\n\t\tthis.modifiedProjectNestedFields.clear();\n\n\t\tconst projectLoad = SettingsManager.tryLoadFromStorage(this.storage, \"project\");\n\t\tif (!projectLoad.error) {\n\t\t\tthis.projectSettings = projectLoad.settings;\n\t\t\tthis.projectSettingsLoadError = null;\n\t\t} else {\n\t\t\tthis.projectSettingsLoadError = projectLoad.error;\n\t\t\tthis.recordError(\"project\", projectLoad.error);\n\t\t}\n\n\t\tthis.settings = deepMergeSettings(this.globalSettings, this.projectSettings);\n\t}\n\n\t/** Apply additional overrides on top of current settings */\n\tapplyOverrides(overrides: Partial<Settings>): void {\n\t\tthis.settings = deepMergeSettings(this.settings, overrides);\n\t}\n\n\t/** Mark a global field as modified during this session */\n\tprivate markModified(field: keyof Settings, nestedKey?: string): void {\n\t\tthis.modifiedFields.add(field);\n\t\tif (nestedKey) {\n\t\t\tif (!this.modifiedNestedFields.has(field)) {\n\t\t\t\tthis.modifiedNestedFields.set(field, new Set());\n\t\t\t}\n\t\t\tthis.modifiedNestedFields.get(field)!.add(nestedKey);\n\t\t}\n\t}\n\n\t/** Mark a project field as modified during this session */\n\tprivate markProjectModified(field: keyof Settings, nestedKey?: string): void {\n\t\tthis.modifiedProjectFields.add(field);\n\t\tif (nestedKey) {\n\t\t\tif (!this.modifiedProjectNestedFields.has(field)) {\n\t\t\t\tthis.modifiedProjectNestedFields.set(field, new Set());\n\t\t\t}\n\t\t\tthis.modifiedProjectNestedFields.get(field)!.add(nestedKey);\n\t\t}\n\t}\n\n\tprivate recordError(scope: SettingsScope, error: unknown): void {\n\t\tthis.errors.push(toSettingsError(scope, error, this.settingsPaths[scope]));\n\t}\n\n\tprivate clearModifiedScope(scope: SettingsScope): void {\n\t\tif (scope === \"global\") {\n\t\t\tthis.modifiedFields.clear();\n\t\t\tthis.modifiedNestedFields.clear();\n\t\t\treturn;\n\t\t}\n\n\t\tthis.modifiedProjectFields.clear();\n\t\tthis.modifiedProjectNestedFields.clear();\n\t}\n\n\tprivate enqueueWrite(scope: SettingsScope, task: () => void): void {\n\t\tthis.writeQueue = this.writeQueue\n\t\t\t.then(() => {\n\t\t\t\ttask();\n\t\t\t\tthis.clearModifiedScope(scope);\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tthis.recordError(scope, error);\n\t\t\t});\n\t}\n\n\tprivate cloneModifiedNestedFields(source: Map<keyof Settings, Set<string>>): Map<keyof Settings, Set<string>> {\n\t\tconst snapshot = new Map<keyof Settings, Set<string>>();\n\t\tfor (const [key, value] of source.entries()) {\n\t\t\tsnapshot.set(key, new Set(value));\n\t\t}\n\t\treturn snapshot;\n\t}\n\n\tprivate persistScopedSettings(\n\t\tscope: SettingsScope,\n\t\tsnapshotSettings: Settings,\n\t\tmodifiedFields: Set<keyof Settings>,\n\t\tmodifiedNestedFields: Map<keyof Settings, Set<string>>,\n\t): void {\n\t\tthis.storage.withLock(scope, (current) => {\n\t\t\tconst currentFileSettings = current\n\t\t\t\t? SettingsManager.migrateSettings(JSON.parse(stripBom(current)) as Record<string, unknown>)\n\t\t\t\t: {};\n\t\t\tconst mergedSettings: Settings = { ...currentFileSettings };\n\t\t\tfor (const field of modifiedFields) {\n\t\t\t\tconst value = snapshotSettings[field];\n\t\t\t\tif (modifiedNestedFields.has(field) && typeof value === \"object\" && value !== null) {\n\t\t\t\t\tconst nestedModified = modifiedNestedFields.get(field)!;\n\t\t\t\t\tconst baseNested = (currentFileSettings[field] as Record<string, unknown>) ?? {};\n\t\t\t\t\tconst inMemoryNested = value as Record<string, unknown>;\n\t\t\t\t\tconst mergedNested = { ...baseNested };\n\t\t\t\t\tfor (const nestedKey of nestedModified) {\n\t\t\t\t\t\tmergedNested[nestedKey] = inMemoryNested[nestedKey];\n\t\t\t\t\t}\n\t\t\t\t\t(mergedSettings as Record<string, unknown>)[field] = mergedNested;\n\t\t\t\t} else {\n\t\t\t\t\t(mergedSettings as Record<string, unknown>)[field] = value;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn JSON.stringify(mergedSettings, null, 2);\n\t\t});\n\t}\n\n\tprivate save(): void {\n\t\tthis.settings = deepMergeSettings(this.globalSettings, this.projectSettings);\n\n\t\tif (this.globalSettingsLoadError) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst snapshotGlobalSettings = structuredClone(this.globalSettings);\n\t\tconst modifiedFields = new Set(this.modifiedFields);\n\t\tconst modifiedNestedFields = this.cloneModifiedNestedFields(this.modifiedNestedFields);\n\n\t\tthis.enqueueWrite(\"global\", () => {\n\t\t\tthis.persistScopedSettings(\"global\", snapshotGlobalSettings, modifiedFields, modifiedNestedFields);\n\t\t});\n\t}\n\n\tprivate saveProjectSettings(settings: Settings): void {\n\t\tthis.projectSettings = structuredClone(settings);\n\t\tthis.settings = deepMergeSettings(this.globalSettings, this.projectSettings);\n\n\t\tif (this.projectSettingsLoadError) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst snapshotProjectSettings = structuredClone(this.projectSettings);\n\t\tconst modifiedFields = new Set(this.modifiedProjectFields);\n\t\tconst modifiedNestedFields = this.cloneModifiedNestedFields(this.modifiedProjectNestedFields);\n\t\tthis.enqueueWrite(\"project\", () => {\n\t\t\tthis.persistScopedSettings(\"project\", snapshotProjectSettings, modifiedFields, modifiedNestedFields);\n\t\t});\n\t}\n\n\tprivate updateProjectSettings(field: keyof Settings, update: (settings: Settings) => void): void {\n\t\tconst projectSettings = structuredClone(this.projectSettings);\n\t\tupdate(projectSettings);\n\t\tthis.markProjectModified(field);\n\t\tthis.saveProjectSettings(projectSettings);\n\t}\n\n\tasync flush(): Promise<void> {\n\t\tawait this.writeQueue;\n\t}\n\n\tdrainErrors(): SettingsError[] {\n\t\tconst drained = [...this.errors];\n\t\tthis.errors = [];\n\t\treturn drained;\n\t}\n\n\tgetLastChangelogVersion(): string | undefined {\n\t\treturn this.settings.lastChangelogVersion;\n\t}\n\n\tsetLastChangelogVersion(version: string): void {\n\t\tthis.globalSettings.lastChangelogVersion = version;\n\t\tthis.markModified(\"lastChangelogVersion\");\n\t\tthis.save();\n\t}\n\n\tgetSuiteNoticeAcknowledgement(suiteId: string): { driftDigest?: string; upgradeRevision?: number } | undefined {\n\t\treturn this.settings.suiteNoticesAcknowledged?.[suiteId];\n\t}\n\n\tsetSuiteNoticeAcknowledgement(suiteId: string, ack: { driftDigest?: string; upgradeRevision?: number }): void {\n\t\t// 与 lastChangelogVersion 同模式:写到 globalSettings 源层——save() 会从\n\t\t// global+project 重建合并层,只写合并层会在 save 时被冲掉。\n\t\tconst next = {\n\t\t\t...(this.globalSettings.suiteNoticesAcknowledged ?? {}),\n\t\t\t...(this.settings.suiteNoticesAcknowledged ?? {}),\n\t\t};\n\t\tconst existing = next[suiteId];\n\t\tnext[suiteId] = {\n\t\t\t...(typeof existing === \"object\" && existing !== null ? existing : {}),\n\t\t\t...(ack.driftDigest === undefined ? {} : { driftDigest: ack.driftDigest }),\n\t\t\t...(ack.upgradeRevision === undefined ? {} : { upgradeRevision: ack.upgradeRevision }),\n\t\t};\n\t\tthis.globalSettings.suiteNoticesAcknowledged = next;\n\t\tthis.settings.suiteNoticesAcknowledged = next;\n\t\tthis.markModified(\"suiteNoticesAcknowledged\");\n\t\tthis.save();\n\t}\n\n\tgetSessionDir(): string | undefined {\n\t\tconst sessionDir = this.settings.sessionDir;\n\t\treturn sessionDir ? normalizePath(sessionDir) : sessionDir;\n\t}\n\n\tgetDefaultProvider(): string | undefined {\n\t\treturn this.settings.defaultProvider;\n\t}\n\n\tgetDefaultModel(): string | undefined {\n\t\treturn this.settings.defaultModel;\n\t}\n\n\t/**\n\t * 记忆全局档位(2.4d6 S1 持久配置面):settings.json `memory.mode` 原样读出。\n\t * 类型面只声明合法档位;手改文件写入的非法值不经运行时收窄、原样透传,由\n\t * `resolveMemoryMode` fail-closed 为 off 并输出诊断(不在此处静默吞掉)。\n\t */\n\tgetMemoryModeSetting(): \"off\" | \"light\" | \"full\" | undefined {\n\t\treturn this.settings.memory?.mode;\n\t}\n\n\t/**\n\t * 能力槽位配置节(供应商能力槽位设计 §3.1):返回合并层的原始\n\t * `capabilities`。结构非法时记录一条 warning(经 drainErrors 以\n\t * settings 诊断面呈现)并按 fail-closed 丢弃非法子节,不抛出、不崩溃;\n\t * 槽位失效后由消费方(image-generation 插件)按 config_missing 报\n\t * 可操作错误。warning 每实例至多记录一次。\n\t */\n\tgetCapabilitiesSettings(): CapabilitiesSettings | undefined {\n\t\tconst raw = this.settings.capabilities;\n\t\tif (raw === undefined) return undefined;\n\t\tif (!isMergeableObject(raw)) {\n\t\t\tthis.recordCapabilitiesWarning(\"capabilities must be an object\");\n\t\t\treturn undefined;\n\t\t}\n\t\tconst imageGeneration = raw.imageGeneration;\n\t\tif (imageGeneration === undefined) return raw;\n\t\tif (!isMergeableObject(imageGeneration)) {\n\t\t\tthis.recordCapabilitiesWarning(\"capabilities.imageGeneration must be an object\");\n\t\t\treturn undefined;\n\t\t}\n\t\tconst provider = imageGeneration.provider;\n\t\tif (typeof provider !== \"string\" || provider.trim() === \"\") {\n\t\t\tthis.recordCapabilitiesWarning(\n\t\t\t\t`capabilities.imageGeneration.provider must be a non-empty string: ${String(provider)}`,\n\t\t\t);\n\t\t\treturn undefined;\n\t\t}\n\t\tconst model = imageGeneration.model;\n\t\tif (model !== undefined && (typeof model !== \"string\" || model.trim() === \"\")) {\n\t\t\tthis.recordCapabilitiesWarning(\n\t\t\t\t`capabilities.imageGeneration.model must be a non-empty string when present: ${String(model)}`,\n\t\t\t);\n\t\t\treturn undefined;\n\t\t}\n\t\tconst slot: ImageGenerationCapabilitySettings = { provider, ...(model === undefined ? {} : { model }) };\n\t\treturn { ...raw, imageGeneration: slot };\n\t}\n\n\t/**\n\t * 主备切换配置节(设计 §4.1):raw 读出,原样透传合并层对象。Phase 1\n\t * 不做结构校验与默认值解析——那是 Phase 2 provider-failover 插件的\n\t * 消费面;此处提前收窄会把非法值静默变成合法语义。\n\t */\n\tgetFailoverSettings(): FailoverSettings | undefined {\n\t\tconst failover = this.settings.failover;\n\t\treturn failover === undefined ? undefined : { ...failover };\n\t}\n\n\tprivate recordCapabilitiesWarning(message: string): void {\n\t\tif (this.capabilitiesWarningRecorded) return;\n\t\tthis.capabilitiesWarningRecorded = true;\n\t\t// 槽位在两层合并后读取,无法逐字段追溯来源层;capabilities 节存在\n\t\t// 于哪层就归到哪层(project 层存在即以 project 呈现,与深合并优先级一致)。\n\t\tconst scope: SettingsScope = isMergeableObject(this.projectSettings.capabilities) ? \"project\" : \"global\";\n\t\tthis.recordError(scope, new Error(`Invalid ${message}`));\n\t}\n\n\tsetDefaultProvider(provider: string): void {\n\t\tthis.globalSettings.defaultProvider = provider;\n\t\tthis.markModified(\"defaultProvider\");\n\t\tthis.save();\n\t}\n\n\tsetDefaultModel(modelId: string): void {\n\t\tthis.globalSettings.defaultModel = modelId;\n\t\tthis.markModified(\"defaultModel\");\n\t\tthis.save();\n\t}\n\n\tsetDefaultModelAndProvider(provider: string, modelId: string): void {\n\t\tthis.globalSettings.defaultProvider = provider;\n\t\tthis.globalSettings.defaultModel = modelId;\n\t\tthis.markModified(\"defaultProvider\");\n\t\tthis.markModified(\"defaultModel\");\n\t\tthis.save();\n\t}\n\n\tgetSteeringMode(): \"all\" | \"one-at-a-time\" {\n\t\treturn this.settings.steeringMode || \"one-at-a-time\";\n\t}\n\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\"): void {\n\t\tthis.globalSettings.steeringMode = mode;\n\t\tthis.markModified(\"steeringMode\");\n\t\tthis.save();\n\t}\n\n\tgetFollowUpMode(): \"all\" | \"one-at-a-time\" {\n\t\treturn this.settings.followUpMode || \"one-at-a-time\";\n\t}\n\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\"): void {\n\t\tthis.globalSettings.followUpMode = mode;\n\t\tthis.markModified(\"followUpMode\");\n\t\tthis.save();\n\t}\n\n\tgetThemeSetting(): string | undefined {\n\t\tconst value = this.settings.theme;\n\t\tif (typeof value === \"string\") return value;\n\t\treturn undefined;\n\t}\n\n\tgetTheme(): string | undefined {\n\t\tconst theme = this.getThemeSetting();\n\t\treturn theme?.includes(\"/\") ? undefined : theme;\n\t}\n\n\tsetTheme(theme: string): void {\n\t\tthis.globalSettings.theme = theme;\n\t\tthis.markModified(\"theme\");\n\t\tthis.save();\n\t}\n\n\tgetDefaultThinkingLevel(): ThinkingLevel | undefined {\n\t\treturn this.settings.defaultThinkingLevel;\n\t}\n\n\tsetDefaultThinkingLevel(level: ThinkingLevel): void {\n\t\tthis.globalSettings.defaultThinkingLevel = level;\n\t\tthis.markModified(\"defaultThinkingLevel\");\n\t\tthis.save();\n\t}\n\n\tgetModelThinkingLevel(provider: string, modelId: string): ThinkingLevel | undefined {\n\t\treturn this.settings.modelThinkingLevels?.[`${provider}/${modelId}`];\n\t}\n\n\tgetAllModelThinkingLevels(): Record<string, ThinkingLevel> {\n\t\treturn { ...(this.settings.modelThinkingLevels ?? {}) };\n\t}\n\n\tsetModelThinkingLevel(provider: string, modelId: string, level: ThinkingLevel): void {\n\t\tif (!this.globalSettings.modelThinkingLevels) {\n\t\t\tthis.globalSettings.modelThinkingLevels = {};\n\t\t}\n\t\tthis.globalSettings.modelThinkingLevels[`${provider}/${modelId}`] = level;\n\t\tthis.markModified(\"modelThinkingLevels\");\n\t\tthis.save();\n\t}\n\n\tremoveModelThinkingLevel(provider: string, modelId: string): void {\n\t\tif (!this.globalSettings.modelThinkingLevels) return;\n\t\tdelete this.globalSettings.modelThinkingLevels[`${provider}/${modelId}`];\n\t\tif (Object.keys(this.globalSettings.modelThinkingLevels).length === 0) {\n\t\t\tdelete this.globalSettings.modelThinkingLevels;\n\t\t}\n\t\tthis.markModified(\"modelThinkingLevels\");\n\t\tthis.save();\n\t}\n\n\tgetTransport(): TransportSetting {\n\t\treturn this.settings.transport ?? \"auto\";\n\t}\n\n\tsetTransport(transport: TransportSetting): void {\n\t\tthis.globalSettings.transport = transport;\n\t\tthis.markModified(\"transport\");\n\t\tthis.save();\n\t}\n\n\tprivate getCompactionTokenSetting(\n\t\tfield: keyof CompactionModelOverride,\n\t\tmodel?: Pick<Model<string>, \"provider\" | \"id\">,\n\t): number {\n\t\tconst compaction = this.settings.compaction;\n\t\tconst ordinary = compaction?.[field];\n\t\tif (ordinary !== undefined && (typeof ordinary !== \"number\" || !Number.isSafeInteger(ordinary) || ordinary < 0)) {\n\t\t\tthrow new Error(\n\t\t\t\tt(\"Invalid compaction.{field} setting: {value}. Expected a non-negative safe integer.\", {\n\t\t\t\t\tfield,\n\t\t\t\t\tvalue: String(ordinary),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tconst modelKey = model ? `${model.provider}/${model.id}` : undefined;\n\t\tconst entry = modelKey !== undefined ? compaction?.modelOverrides?.[modelKey] : undefined;\n\t\tif (entry !== undefined && !isMergeableObject(entry)) {\n\t\t\tthrow new Error(\n\t\t\t\tt('Invalid compaction.modelOverrides[\"{modelKey}\"] setting: {value}. Expected an object.', {\n\t\t\t\t\tmodelKey: modelKey ?? \"unknown\",\n\t\t\t\t\tvalue: String(entry),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\tconst override = entry?.[field];\n\t\tif (override !== undefined && (typeof override !== \"number\" || !Number.isSafeInteger(override) || override < 0)) {\n\t\t\tthrow new Error(\n\t\t\t\tt(\n\t\t\t\t\t'Invalid compaction.modelOverrides[\"{modelKey}\"].{field} setting: {value}. Expected a non-negative safe integer.',\n\t\t\t\t\t{\n\t\t\t\t\t\tmodelKey: modelKey ?? \"unknown\",\n\t\t\t\t\t\tfield,\n\t\t\t\t\t\tvalue: String(override),\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\treturn override ?? ordinary ?? DEFAULT_COMPACTION_TOKEN_SETTINGS[field];\n\t}\n\n\tgetCompactionReserveTokens(model?: Pick<Model<string>, \"provider\" | \"id\">): number {\n\t\treturn this.getCompactionTokenSetting(\"reserveTokens\", model);\n\t}\n\n\tgetCompactionKeepRecentTokens(model?: Pick<Model<string>, \"provider\" | \"id\">): number {\n\t\treturn this.getCompactionTokenSetting(\"keepRecentTokens\", model);\n\t}\n\n\t/** Resolve each token setting through model override, ordinary setting, then built-in default. */\n\tgetCompactionSettings(model?: Pick<Model<string>, \"provider\" | \"id\">): {\n\t\treserveTokens: number;\n\t\tkeepRecentTokens: number;\n\t} {\n\t\treturn {\n\t\t\treserveTokens: this.getCompactionReserveTokens(model),\n\t\t\tkeepRecentTokens: this.getCompactionKeepRecentTokens(model),\n\t\t};\n\t}\n\n\tgetBranchSummarySettings(): { reserveTokens: number; skipPrompt: boolean } {\n\t\treturn {\n\t\t\treserveTokens: this.settings.branchSummary?.reserveTokens ?? 16384,\n\t\t\tskipPrompt: this.settings.branchSummary?.skipPrompt ?? false,\n\t\t};\n\t}\n\n\tgetBranchSummarySkipPrompt(): boolean {\n\t\treturn this.settings.branchSummary?.skipPrompt ?? false;\n\t}\n\n\t/**\n\t * 聚合 retry 数值面。返回体带常量 `enabled: true`:pi-ai `RetryPolicy`\n\t * (packages/ai/src/utils/retry.ts)的 `enabled` 是 required 字段,库层形状\n\t * 不动;产品侧自动重试无条件生效(2026-10-03 D-079,settings\n\t * `retry.enabled` 开关已移除),残留旧键按 settings 层宽松契约静默忽略。\n\t */\n\tgetRetrySettings(): { enabled: boolean; maxRetries: number; baseDelayMs: number; maxAgentDelayMs: number } {\n\t\treturn {\n\t\t\tenabled: true,\n\t\t\tmaxRetries: this.settings.retry?.maxRetries ?? 5,\n\t\t\tbaseDelayMs: this.settings.retry?.baseDelayMs ?? 2000,\n\t\t\tmaxAgentDelayMs: this.settings.retry?.maxAgentDelayMs ?? DEFAULT_MAX_AGENT_RETRY_DELAY_MS,\n\t\t};\n\t}\n\n\tgetHttpIdleTimeoutMs(): number {\n\t\treturn parseTimeoutSetting(this.settings.httpIdleTimeoutMs, \"httpIdleTimeoutMs\") ?? DEFAULT_HTTP_IDLE_TIMEOUT_MS;\n\t}\n\n\tsetHttpIdleTimeoutMs(timeoutMs: number): void {\n\t\tif (!Number.isFinite(timeoutMs) || timeoutMs < 0) {\n\t\t\tthrow new Error(t(\"Invalid httpIdleTimeoutMs setting: {value}\", { value: String(timeoutMs) }));\n\t\t}\n\t\tthis.globalSettings.httpIdleTimeoutMs = Math.floor(timeoutMs);\n\t\tthis.markModified(\"httpIdleTimeoutMs\");\n\t\tthis.save();\n\t}\n\n\tgetProviderRetrySettings(): { timeoutMs?: number; maxRetries?: number; maxRetryDelayMs: number } {\n\t\treturn {\n\t\t\ttimeoutMs: this.settings.retry?.provider?.timeoutMs,\n\t\t\tmaxRetries: this.settings.retry?.provider?.maxRetries,\n\t\t\tmaxRetryDelayMs: this.settings.retry?.provider?.maxRetryDelayMs ?? 60000,\n\t\t};\n\t}\n\n\tgetWebSocketConnectTimeoutMs(): number | undefined {\n\t\treturn parseTimeoutSetting(this.settings.websocketConnectTimeoutMs, \"websocketConnectTimeoutMs\");\n\t}\n\n\tgetHideThinkingBlock(): boolean {\n\t\treturn this.settings.hideThinkingBlock ?? false;\n\t}\n\n\tgetShowCacheMissNotices(): boolean {\n\t\treturn this.settings.showCacheMissNotices ?? false;\n\t}\n\n\tgetExternalEditorCommand(): string {\n\t\tconst configuredEditor = this.settings.externalEditor;\n\t\tif (typeof configuredEditor === \"string\" && configuredEditor.trim() !== \"\") {\n\t\t\treturn configuredEditor;\n\t\t}\n\t\tconst environmentEditor = process.env.VISUAL || process.env.EDITOR;\n\t\tif (environmentEditor) {\n\t\t\treturn environmentEditor;\n\t\t}\n\t\treturn process.platform === \"win32\" ? \"notepad\" : \"nano\";\n\t}\n\n\tsetHideThinkingBlock(hide: boolean): void {\n\t\tthis.globalSettings.hideThinkingBlock = hide;\n\t\tthis.markModified(\"hideThinkingBlock\");\n\t\tthis.save();\n\t}\n\n\tsetShowCacheMissNotices(show: boolean): void {\n\t\tthis.globalSettings.showCacheMissNotices = show;\n\t\tthis.markModified(\"showCacheMissNotices\");\n\t\tthis.save();\n\t}\n\n\tgetShellPath(): string | undefined {\n\t\tconst shellPath = this.settings.shellPath;\n\t\treturn shellPath ? normalizePath(shellPath) : shellPath;\n\t}\n\n\tsetShellPath(path: string | undefined): void {\n\t\tthis.globalSettings.shellPath = path;\n\t\tthis.markModified(\"shellPath\");\n\t\tthis.save();\n\t}\n\n\tgetQuietStartup(): boolean {\n\t\treturn this.settings.quietStartup ?? false;\n\t}\n\n\tsetQuietStartup(quiet: boolean): void {\n\t\tthis.globalSettings.quietStartup = quiet;\n\t\tthis.markModified(\"quietStartup\");\n\t\tthis.save();\n\t}\n\n\tgetShellCommandPrefix(): string | undefined {\n\t\treturn this.settings.shellCommandPrefix;\n\t}\n\n\tsetShellCommandPrefix(prefix: string | undefined): void {\n\t\tthis.globalSettings.shellCommandPrefix = prefix;\n\t\tthis.markModified(\"shellCommandPrefix\");\n\t\tthis.save();\n\t}\n\n\tgetNpmCommand(): string[] | undefined {\n\t\treturn this.settings.npmCommand ? [...this.settings.npmCommand] : undefined;\n\t}\n\n\tsetNpmCommand(command: string[] | undefined): void {\n\t\tthis.globalSettings.npmCommand = command ? [...command] : undefined;\n\t\tthis.markModified(\"npmCommand\");\n\t\tthis.save();\n\t}\n\n\tgetCollapseChangelog(): boolean {\n\t\treturn this.settings.collapseChangelog ?? false;\n\t}\n\n\tsetCollapseChangelog(collapse: boolean): void {\n\t\tthis.globalSettings.collapseChangelog = collapse;\n\t\tthis.markModified(\"collapseChangelog\");\n\t\tthis.save();\n\t}\n\n\tgetEnableAnalytics(): boolean {\n\t\treturn this.settings.enableAnalytics ?? false;\n\t}\n\n\tgetTrackingId(): string | undefined {\n\t\treturn this.settings.trackingId;\n\t}\n\n\t/** Set the analytics opt-in preference; generates a tracking identifier on first opt-in */\n\tsetEnableAnalytics(enabled: boolean): void {\n\t\tthis.globalSettings.enableAnalytics = enabled;\n\t\tthis.markModified(\"enableAnalytics\");\n\t\tif (enabled && !this.globalSettings.trackingId) {\n\t\t\tthis.globalSettings.trackingId = randomUUID();\n\t\t\tthis.markModified(\"trackingId\");\n\t\t}\n\t\tthis.save();\n\t}\n\n\tgetPackages(): PackageSource[] {\n\t\treturn [...(this.settings.packages ?? [])];\n\t}\n\n\tsetPackages(packages: PackageSource[]): void {\n\t\tthis.globalSettings.packages = packages;\n\t\tthis.markModified(\"packages\");\n\t\tthis.save();\n\t}\n\n\tsetProjectPackages(packages: PackageSource[]): void {\n\t\tthis.updateProjectSettings(\"packages\", (settings) => {\n\t\t\tsettings.packages = packages;\n\t\t});\n\t}\n\n\tgetSkillPaths(): string[] {\n\t\treturn [...(this.settings.skills ?? [])];\n\t}\n\n\tsetSkillPaths(paths: string[]): void {\n\t\tthis.globalSettings.skills = paths;\n\t\tthis.markModified(\"skills\");\n\t\tthis.save();\n\t}\n\n\tsetProjectSkillPaths(paths: string[]): void {\n\t\tthis.updateProjectSettings(\"skills\", (settings) => {\n\t\t\tsettings.skills = paths;\n\t\t});\n\t}\n\n\tgetPromptTemplatePaths(): string[] {\n\t\treturn [...(this.settings.prompts ?? [])];\n\t}\n\n\tsetPromptTemplatePaths(paths: string[]): void {\n\t\tthis.globalSettings.prompts = paths;\n\t\tthis.markModified(\"prompts\");\n\t\tthis.save();\n\t}\n\n\tsetProjectPromptTemplatePaths(paths: string[]): void {\n\t\tthis.updateProjectSettings(\"prompts\", (settings) => {\n\t\t\tsettings.prompts = paths;\n\t\t});\n\t}\n\n\tgetThemePaths(): string[] {\n\t\treturn [...(this.settings.themes ?? [])];\n\t}\n\n\tsetThemePaths(paths: string[]): void {\n\t\tthis.globalSettings.themes = paths;\n\t\tthis.markModified(\"themes\");\n\t\tthis.save();\n\t}\n\n\tsetProjectThemePaths(paths: string[]): void {\n\t\tthis.updateProjectSettings(\"themes\", (settings) => {\n\t\t\tsettings.themes = paths;\n\t\t});\n\t}\n\n\t/** Project-scope active suite (方案) id; undefined clears the key (设计 §9). */\n\tsetProjectSuite(id: string | undefined): void {\n\t\tthis.updateProjectSettings(\"suite\", (settings) => {\n\t\t\tif (id === undefined) {\n\t\t\t\tdelete settings.suite;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsettings.suite = id;\n\t\t});\n\t}\n\n\t/** Global-scope active suite (方案) id; undefined clears the key (设计 §9). */\n\tsetSuite(id: string | undefined): void {\n\t\tif (id === undefined) {\n\t\t\tdelete this.globalSettings.suite;\n\t\t} else {\n\t\t\tthis.globalSettings.suite = id;\n\t\t}\n\t\tthis.markModified(\"suite\");\n\t\tthis.save();\n\t}\n\n\tgetThinkingBudgets(): ThinkingBudgetsSettings | undefined {\n\t\treturn this.settings.thinkingBudgets;\n\t}\n\n\tgetTerminalCapabilityOverrides(): Partial<TerminalCapabilities> {\n\t\tconst terminal = this.settings.terminal;\n\t\tconst images = terminal?.images;\n\t\treturn {\n\t\t\t...(images === \"kitty\" || images === \"iterm2\" ? { images } : images === false ? { images: null } : {}),\n\t\t\t...(typeof terminal?.trueColor === \"boolean\" ? { trueColor: terminal.trueColor } : {}),\n\t\t\t...(typeof terminal?.hyperlinks === \"boolean\" ? { hyperlinks: terminal.hyperlinks } : {}),\n\t\t};\n\t}\n\n\tgetShowImages(): boolean {\n\t\treturn this.settings.terminal?.showImages ?? true;\n\t}\n\n\tsetShowImages(show: boolean): void {\n\t\tif (!this.globalSettings.terminal) {\n\t\t\tthis.globalSettings.terminal = {};\n\t\t}\n\t\tthis.globalSettings.terminal.showImages = show;\n\t\tthis.markModified(\"terminal\", \"showImages\");\n\t\tthis.save();\n\t}\n\n\tgetImageWidthCells(): number {\n\t\tconst width = this.settings.terminal?.imageWidthCells;\n\t\tif (typeof width !== \"number\" || !Number.isFinite(width)) {\n\t\t\treturn 60;\n\t\t}\n\t\treturn Math.max(1, Math.floor(width));\n\t}\n\n\tsetImageWidthCells(width: number): void {\n\t\tif (!this.globalSettings.terminal) {\n\t\t\tthis.globalSettings.terminal = {};\n\t\t}\n\t\tthis.globalSettings.terminal.imageWidthCells = Math.max(1, Math.floor(width));\n\t\tthis.markModified(\"terminal\", \"imageWidthCells\");\n\t\tthis.save();\n\t}\n\n\tgetClearOnShrink(): boolean {\n\t\t// Settings takes precedence, then env var, then default false\n\t\tif (this.settings.terminal?.clearOnShrink !== undefined) {\n\t\t\treturn this.settings.terminal.clearOnShrink;\n\t\t}\n\t\treturn process.env.AGENT_FORGE_CLEAR_ON_SHRINK === \"1\";\n\t}\n\n\tsetClearOnShrink(enabled: boolean): void {\n\t\tif (!this.globalSettings.terminal) {\n\t\t\tthis.globalSettings.terminal = {};\n\t\t}\n\t\tthis.globalSettings.terminal.clearOnShrink = enabled;\n\t\tthis.markModified(\"terminal\", \"clearOnShrink\");\n\t\tthis.save();\n\t}\n\n\tgetShowTerminalProgress(): boolean {\n\t\treturn this.settings.terminal?.showTerminalProgress ?? false;\n\t}\n\n\tsetShowTerminalProgress(enabled: boolean): void {\n\t\tif (!this.globalSettings.terminal) {\n\t\t\tthis.globalSettings.terminal = {};\n\t\t}\n\t\tthis.globalSettings.terminal.showTerminalProgress = enabled;\n\t\tthis.markModified(\"terminal\", \"showTerminalProgress\");\n\t\tthis.save();\n\t}\n\n\tgetTuiMode(): TuiMode {\n\t\treturn this.settings.tuiMode === \"fullscreen\" ? \"fullscreen\" : \"regular\";\n\t}\n\n\tsetTuiMode(mode: TuiMode): void {\n\t\tthis.globalSettings.tuiMode = mode;\n\t\tthis.markModified(\"tuiMode\");\n\t\tthis.save();\n\t}\n\n\tgetFullscreenExitOutput(): FullscreenExitOutput {\n\t\treturn this.settings.fullscreenExitOutput === \"resume-hint\" ? \"resume-hint\" : \"transcript\";\n\t}\n\n\tsetFullscreenExitOutput(output: FullscreenExitOutput): void {\n\t\tthis.globalSettings.fullscreenExitOutput = output;\n\t\tthis.markModified(\"fullscreenExitOutput\");\n\t\tthis.save();\n\t}\n\n\tgetFullscreenScrollbar(): ScrollViewScrollbar {\n\t\tconst mode = this.settings.fullscreenScrollbar;\n\t\treturn mode === \"always\" || mode === \"hidden\" ? mode : \"auto\";\n\t}\n\n\tsetFullscreenScrollbar(mode: ScrollViewScrollbar): void {\n\t\tthis.globalSettings.fullscreenScrollbar = mode;\n\t\tthis.markModified(\"fullscreenScrollbar\");\n\t\tthis.save();\n\t}\n\n\tgetFullscreenCopyOnSelect(): boolean {\n\t\treturn this.settings.fullscreenCopyOnSelect ?? true;\n\t}\n\n\tsetFullscreenCopyOnSelect(enabled: boolean): void {\n\t\tthis.globalSettings.fullscreenCopyOnSelect = enabled;\n\t\tthis.markModified(\"fullscreenCopyOnSelect\");\n\t\tthis.save();\n\t}\n\n\tgetFullscreenWheelScrollLines(): WheelScrollLines {\n\t\tconst lines = this.settings.fullscreenWheelScrollLines;\n\t\treturn typeof lines === \"number\" && Number.isFinite(lines)\n\t\t\t? Math.max(1, Math.min(100, Math.floor(lines)))\n\t\t\t: \"auto\";\n\t}\n\n\tsetFullscreenWheelScrollLines(lines: WheelScrollLines): void {\n\t\tthis.globalSettings.fullscreenWheelScrollLines =\n\t\t\tlines === \"auto\" ? lines : Math.max(1, Math.min(100, Math.floor(lines)));\n\t\tthis.markModified(\"fullscreenWheelScrollLines\");\n\t\tthis.save();\n\t}\n\n\tgetImageAutoResize(): boolean {\n\t\treturn this.settings.images?.autoResize ?? true;\n\t}\n\n\tsetImageAutoResize(enabled: boolean): void {\n\t\tif (!this.globalSettings.images) {\n\t\t\tthis.globalSettings.images = {};\n\t\t}\n\t\tthis.globalSettings.images.autoResize = enabled;\n\t\tthis.markModified(\"images\", \"autoResize\");\n\t\tthis.save();\n\t}\n\n\tgetBlockImages(): boolean {\n\t\treturn this.settings.images?.blockImages ?? false;\n\t}\n\n\tsetBlockImages(blocked: boolean): void {\n\t\tif (!this.globalSettings.images) {\n\t\t\tthis.globalSettings.images = {};\n\t\t}\n\t\tthis.globalSettings.images.blockImages = blocked;\n\t\tthis.markModified(\"images\", \"blockImages\");\n\t\tthis.save();\n\t}\n\n\tgetEnabledModels(): string[] | undefined {\n\t\treturn this.settings.enabledModels;\n\t}\n\n\t/** The resolved `defaultTools` selection, or undefined when no settings layer sets it. */\n\tgetDefaultTools(): string[] | undefined {\n\t\tconst tools = this.settings.defaultTools;\n\t\tif (tools === undefined) return undefined;\n\t\treturn resolveDefaultTools(Array.isArray(tools) ? tools.filter((tool) => typeof tool === \"string\") : []);\n\t}\n\n\tsetEnabledModels(patterns: string[] | undefined): void {\n\t\tthis.globalSettings.enabledModels = patterns;\n\t\tthis.markModified(\"enabledModels\");\n\t\tthis.save();\n\t}\n\n\tgetDoubleEscapeAction(): \"tree\" | \"none\" {\n\t\treturn this.settings.doubleEscapeAction === \"none\" ? \"none\" : \"tree\";\n\t}\n\n\tgetUiLanguage(): I18nLanguage {\n\t\treturn this.settings.ui?.language === \"en\" ? \"en\" : \"zh-CN\";\n\t}\n\n\tsetUiLanguage(language: I18nLanguage): void {\n\t\tif (!this.globalSettings.ui) {\n\t\t\tthis.globalSettings.ui = {};\n\t\t}\n\t\tthis.globalSettings.ui.language = language;\n\t\tthis.markModified(\"ui\", \"language\");\n\t\tthis.save();\n\t}\n\n\tsetDoubleEscapeAction(action: \"tree\" | \"none\"): void {\n\t\tthis.globalSettings.doubleEscapeAction = action;\n\t\tthis.markModified(\"doubleEscapeAction\");\n\t\tthis.save();\n\t}\n\n\tgetTreeFilterMode(): \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\" {\n\t\tconst mode = this.settings.treeFilterMode;\n\t\tconst valid = [\"default\", \"no-tools\", \"user-only\", \"labeled-only\", \"all\"];\n\t\treturn mode && valid.includes(mode) ? mode : \"default\";\n\t}\n\n\tsetTreeFilterMode(mode: \"default\" | \"no-tools\" | \"user-only\" | \"labeled-only\" | \"all\"): void {\n\t\tthis.globalSettings.treeFilterMode = mode;\n\t\tthis.markModified(\"treeFilterMode\");\n\t\tthis.save();\n\t}\n\n\tgetShowHardwareCursor(): boolean {\n\t\tif (this.settings.showHardwareCursor !== undefined) {\n\t\t\treturn this.settings.showHardwareCursor;\n\t\t}\n\t\treturn process.env.AGENT_FORGE_HARDWARE_CURSOR === \"1\";\n\t}\n\n\tsetShowHardwareCursor(enabled: boolean): void {\n\t\tthis.globalSettings.showHardwareCursor = enabled;\n\t\tthis.markModified(\"showHardwareCursor\");\n\t\tthis.save();\n\t}\n\n\tgetEditorPaddingX(): number {\n\t\treturn this.settings.editorPaddingX ?? 0;\n\t}\n\n\tsetEditorPaddingX(padding: number): void {\n\t\tthis.globalSettings.editorPaddingX = Math.max(0, Math.min(3, Math.floor(padding)));\n\t\tthis.markModified(\"editorPaddingX\");\n\t\tthis.save();\n\t}\n\n\tgetOutputPad(): 0 | 1 {\n\t\treturn this.settings.outputPad === 0 ? 0 : 1;\n\t}\n\n\tsetOutputPad(padding: 0 | 1): void {\n\t\tthis.globalSettings.outputPad = padding;\n\t\tthis.markModified(\"outputPad\");\n\t\tthis.save();\n\t}\n\n\tgetAutocompleteMaxVisible(): number {\n\t\treturn this.settings.autocompleteMaxVisible ?? 5;\n\t}\n\n\tsetAutocompleteMaxVisible(maxVisible: number): void {\n\t\tthis.globalSettings.autocompleteMaxVisible = Math.max(3, Math.min(20, Math.floor(maxVisible)));\n\t\tthis.markModified(\"autocompleteMaxVisible\");\n\t\tthis.save();\n\t}\n\n\tgetCodeBlockIndent(): string {\n\t\treturn this.settings.markdown?.codeBlockIndent ?? \" \";\n\t}\n\n\tgetMermaidRenderingMode(): MermaidRenderingMode {\n\t\tconst mode = this.settings.markdown?.mermaid;\n\t\treturn mode === \"off\" || mode === \"final\" ? mode : \"streaming\";\n\t}\n\n\tsetMermaidRenderingMode(mode: MermaidRenderingMode): void {\n\t\tthis.globalSettings.markdown ??= {};\n\t\tthis.globalSettings.markdown.mermaid = mode;\n\t\tthis.markModified(\"markdown\", \"mermaid\");\n\t\tthis.save();\n\t}\n\n\tgetWarnings(): WarningSettings {\n\t\treturn { ...(this.settings.warnings ?? {}) };\n\t}\n\n\tsetWarnings(warnings: WarningSettings): void {\n\t\tthis.globalSettings.warnings = { ...warnings };\n\t\tthis.markModified(\"warnings\");\n\t\tthis.save();\n\t}\n}\n"]}
@@ -5,6 +5,7 @@ import { dirname, join } from "path";
5
5
  import lockfile from "proper-lockfile";
6
6
  import { CONFIG_DIR_NAME, getAgentDir } from "../config.js";
7
7
  import { normalizePath, resolvePath } from "../utils/paths.js";
8
+ import { sleepSync } from "../utils/sync-sleep.js";
8
9
  import { stripBom } from "../utils/text.js";
9
10
  import { DEFAULT_HTTP_IDLE_TIMEOUT_MS, parseHttpIdleTimeoutMs } from "./http-dispatcher.js";
10
11
  import { t } from "./i18n/index.js";
@@ -113,10 +114,8 @@ export class FileSettingsStorage {
113
114
  throw error;
114
115
  }
115
116
  lastError = error;
116
- const start = Date.now();
117
- while (Date.now() - start < delayMs) {
118
- // Sleep synchronously to avoid changing callers to async.
119
- }
117
+ // Atomics.wait 同步休眠: 空转 while 会烧 CPU 且占住事件循环。
118
+ sleepSync(delayMs);
120
119
  }
121
120
  }
122
121
  throw lastError ?? new Error("Failed to acquire settings lock");
@@ -916,9 +915,7 @@ export class SettingsManager {
916
915
  if (this.settings.terminal?.clearOnShrink !== undefined) {
917
916
  return this.settings.terminal.clearOnShrink;
918
917
  }
919
- const configuredValue = process.env.AGENT_FORGE_CLEAR_ON_SHRINK;
920
- // Legacy fallback for installations configured before the Agent Forge rename.
921
- return configuredValue === undefined ? process.env.PI_CLEAR_ON_SHRINK === "1" : configuredValue === "1";
918
+ return process.env.AGENT_FORGE_CLEAR_ON_SHRINK === "1";
922
919
  }
923
920
  setClearOnShrink(enabled) {
924
921
  if (!this.globalSettings.terminal) {
@@ -1054,9 +1051,7 @@ export class SettingsManager {
1054
1051
  if (this.settings.showHardwareCursor !== undefined) {
1055
1052
  return this.settings.showHardwareCursor;
1056
1053
  }
1057
- const configuredValue = process.env.AGENT_FORGE_HARDWARE_CURSOR;
1058
- // Legacy fallback for installations configured before the Agent Forge rename.
1059
- return configuredValue === undefined ? process.env.PI_HARDWARE_CURSOR === "1" : configuredValue === "1";
1054
+ return process.env.AGENT_FORGE_HARDWARE_CURSOR === "1";
1060
1055
  }
1061
1056
  setShowHardwareCursor(enabled) {
1062
1057
  this.globalSettings.showHardwareCursor = enabled;