@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 +0,0 @@
1
- {"version":3,"file":"theme.js","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAEN,eAAe,GAKf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,CAAC,EAAE,MAAM,6BAA6B,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC;IACnC,IAAI,CAAC,MAAM,EAAE,EAAE,gDAAgD;IAC/D,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,kBAAkB;CAC9D,CAAC,CAAC;AAIH,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC;IACnC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACrC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE;IACnB,IAAI,EAAE,IAAI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CAAC;KAClD,CAAC;AAAA,CACF;AAED,MAAM,UAAU,cAAc,GAAgB;IAC7C,OAAO;QACN,WAAW,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,aAAa,EAAE,IAAI,CAAC;QAC5D,UAAU,EAAE,kBAAkB,EAAE;KAChC,CAAC;AAAA,CACF;AAED,MAAM,UAAU,oBAAoB,GAAsB;IACzD,OAAO;QACN,KAAK,EAAE,CAAC,IAAY,EAAE,QAAiB,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACxF,KAAK,EAAE,CAAC,IAAY,EAAE,QAAiB,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC3G,WAAW,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC;QACpD,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAI,CAAC;QAChC,IAAI,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC;KAC7C,CAAC;AAAA,CACF","sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { ThinkingLevel } from \"@agent-forge/agent-core\";\nimport {\n\ttype EditorTheme,\n\tgetCapabilities,\n\ttype MarkdownTheme,\n\ttype RgbColor,\n\ttype SelectListTheme,\n\ttype SettingsListTheme,\n} from \"@agent-forge/tui\";\nimport chalk from \"chalk\";\nimport { type Static, Type } from \"typebox\";\nimport { Compile } from \"typebox/compile\";\nimport { getCustomThemesDir, getThemesDir } from \"../../../config.ts\";\nimport { t } from \"../../../core/i18n/index.ts\";\nimport type { SourceInfo } from \"../../../core/source-info.ts\";\nimport { closeWatcher, watchWithErrorHandler } from \"../../../utils/fs-watch.ts\";\nimport { highlight, supportsLanguage } from \"../../../utils/syntax-highlight.ts\";\nimport { stripBom } from \"../../../utils/text.ts\";\n\n// ============================================================================\n// Types & Schema\n// ============================================================================\n\nconst ColorValueSchema = Type.Union([\n\tType.String(), // hex \"#ff0000\", var ref \"primary\", or empty \"\"\n\tType.Integer({ minimum: 0, maximum: 255 }), // 256-color index\n]);\n\ntype ColorValue = Static<typeof ColorValueSchema>;\n\nconst ThemeJsonSchema = Type.Object({\n\t$schema: Type.Optional(Type.String()),\n\tname: Type.String(),\n\tvars: Type.Optional(Type.Record(Type.String(), ColorValueSchema)),\n\tcolors: Type.Object({\n\t\t// Core UI (10 colors)\n\t\taccent: ColorValueSchema,\n\t\tborder: ColorValueSchema,\n\t\tborderAccent: ColorValueSchema,\n\t\tborderMuted: ColorValueSchema,\n\t\tsuccess: ColorValueSchema,\n\t\terror: ColorValueSchema,\n\t\twarning: ColorValueSchema,\n\t\tmuted: ColorValueSchema,\n\t\tdim: ColorValueSchema,\n\t\ttext: ColorValueSchema,\n\t\tthinkingText: ColorValueSchema,\n\t\t// Backgrounds & Content Text (11 required, 3 optional)\n\t\tselectedBg: ColorValueSchema,\n\t\tscrollbarThumb: Type.Optional(ColorValueSchema),\n\t\tsearchMatchBg: Type.Optional(ColorValueSchema),\n\t\tsearchMatchText: Type.Optional(ColorValueSchema),\n\t\tuserMessageBg: ColorValueSchema,\n\t\tuserMessageText: ColorValueSchema,\n\t\tcustomMessageBg: ColorValueSchema,\n\t\tcustomMessageText: ColorValueSchema,\n\t\tcustomMessageLabel: ColorValueSchema,\n\t\ttoolPendingBg: ColorValueSchema,\n\t\ttoolSuccessBg: ColorValueSchema,\n\t\ttoolErrorBg: ColorValueSchema,\n\t\ttoolTitle: ColorValueSchema,\n\t\ttoolOutput: ColorValueSchema,\n\t\t// Markdown (10 colors)\n\t\tmdHeading: ColorValueSchema,\n\t\tmdLink: ColorValueSchema,\n\t\tmdLinkUrl: ColorValueSchema,\n\t\tmdCode: ColorValueSchema,\n\t\tmdCodeBlock: ColorValueSchema,\n\t\tmdCodeBlockBorder: ColorValueSchema,\n\t\tmdQuote: ColorValueSchema,\n\t\tmdQuoteBorder: ColorValueSchema,\n\t\tmdHr: ColorValueSchema,\n\t\tmdListBullet: ColorValueSchema,\n\t\t// Tool Diffs (3 colors)\n\t\ttoolDiffAdded: ColorValueSchema,\n\t\ttoolDiffRemoved: ColorValueSchema,\n\t\ttoolDiffContext: ColorValueSchema,\n\t\t// Syntax Highlighting (9 colors)\n\t\tsyntaxComment: ColorValueSchema,\n\t\tsyntaxKeyword: ColorValueSchema,\n\t\tsyntaxFunction: ColorValueSchema,\n\t\tsyntaxVariable: ColorValueSchema,\n\t\tsyntaxString: ColorValueSchema,\n\t\tsyntaxNumber: ColorValueSchema,\n\t\tsyntaxType: ColorValueSchema,\n\t\tsyntaxOperator: ColorValueSchema,\n\t\tsyntaxPunctuation: ColorValueSchema,\n\t\t// Thinking Level Borders (6 colors)\n\t\tthinkingOff: ColorValueSchema,\n\t\tthinkingMinimal: ColorValueSchema,\n\t\tthinkingLow: ColorValueSchema,\n\t\tthinkingMedium: ColorValueSchema,\n\t\tthinkingHigh: ColorValueSchema,\n\t\tthinkingXhigh: ColorValueSchema,\n\t\tthinkingMax: Type.Optional(ColorValueSchema),\n\t\t// Bash Mode (1 color)\n\t\tbashMode: ColorValueSchema,\n\t}),\n\texport: Type.Optional(\n\t\tType.Object({\n\t\t\tpageBg: Type.Optional(ColorValueSchema),\n\t\t\tcardBg: Type.Optional(ColorValueSchema),\n\t\t\tinfoBg: Type.Optional(ColorValueSchema),\n\t\t}),\n\t),\n});\n\ntype ThemeJson = Static<typeof ThemeJsonSchema>;\n\nconst validateThemeJson = Compile(ThemeJsonSchema);\n\nexport type ThemeColor =\n\t| \"accent\"\n\t| \"border\"\n\t| \"borderAccent\"\n\t| \"borderMuted\"\n\t| \"success\"\n\t| \"error\"\n\t| \"warning\"\n\t| \"muted\"\n\t| \"dim\"\n\t| \"text\"\n\t| \"thinkingText\"\n\t| \"searchMatchText\"\n\t| \"userMessageText\"\n\t| \"customMessageText\"\n\t| \"customMessageLabel\"\n\t| \"toolTitle\"\n\t| \"toolOutput\"\n\t| \"mdHeading\"\n\t| \"mdLink\"\n\t| \"mdLinkUrl\"\n\t| \"mdCode\"\n\t| \"mdCodeBlock\"\n\t| \"mdCodeBlockBorder\"\n\t| \"mdQuote\"\n\t| \"mdQuoteBorder\"\n\t| \"mdHr\"\n\t| \"mdListBullet\"\n\t| \"toolDiffAdded\"\n\t| \"toolDiffRemoved\"\n\t| \"toolDiffContext\"\n\t| \"syntaxComment\"\n\t| \"syntaxKeyword\"\n\t| \"syntaxFunction\"\n\t| \"syntaxVariable\"\n\t| \"syntaxString\"\n\t| \"syntaxNumber\"\n\t| \"syntaxType\"\n\t| \"syntaxOperator\"\n\t| \"syntaxPunctuation\"\n\t| \"thinkingOff\"\n\t| \"thinkingMinimal\"\n\t| \"thinkingLow\"\n\t| \"thinkingMedium\"\n\t| \"thinkingHigh\"\n\t| \"thinkingXhigh\"\n\t| \"thinkingMax\"\n\t| \"bashMode\";\n\nexport type ThemeBg =\n\t| \"selectedBg\"\n\t| \"scrollbarThumb\"\n\t| \"searchMatchBg\"\n\t| \"userMessageBg\"\n\t| \"customMessageBg\"\n\t| \"toolPendingBg\"\n\t| \"toolSuccessBg\"\n\t| \"toolErrorBg\";\n\ntype OptionalThemeColor = \"thinkingMax\" | \"searchMatchText\";\ntype OptionalThemeBg = \"scrollbarThumb\" | \"searchMatchBg\";\n\ntype ColorMode = \"truecolor\" | \"256color\";\n\n// ============================================================================\n// Color Utilities\n// ============================================================================\n\nfunction hexToRgb(hex: string): { r: number; g: number; b: number } {\n\tconst cleaned = hex.replace(\"#\", \"\");\n\tif (cleaned.length !== 6) {\n\t\tthrow new Error(t(\"Invalid hex color: {hex}\", { hex }));\n\t}\n\tconst r = parseInt(cleaned.substring(0, 2), 16);\n\tconst g = parseInt(cleaned.substring(2, 4), 16);\n\tconst b = parseInt(cleaned.substring(4, 6), 16);\n\tif (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {\n\t\tthrow new Error(t(\"Invalid hex color: {hex}\", { hex }));\n\t}\n\treturn { r, g, b };\n}\n\n// The 6x6x6 color cube channel values (indices 0-5)\nconst CUBE_VALUES = [0, 95, 135, 175, 215, 255];\n\n// Grayscale ramp values (indices 232-255, 24 grays from 8 to 238)\nconst GRAY_VALUES = Array.from({ length: 24 }, (_, i) => 8 + i * 10);\n\nfunction findClosestCubeIndex(value: number): number {\n\tlet minDist = Infinity;\n\tlet minIdx = 0;\n\tfor (let i = 0; i < CUBE_VALUES.length; i++) {\n\t\tconst dist = Math.abs(value - CUBE_VALUES[i]);\n\t\tif (dist < minDist) {\n\t\t\tminDist = dist;\n\t\t\tminIdx = i;\n\t\t}\n\t}\n\treturn minIdx;\n}\n\nfunction findClosestGrayIndex(gray: number): number {\n\tlet minDist = Infinity;\n\tlet minIdx = 0;\n\tfor (let i = 0; i < GRAY_VALUES.length; i++) {\n\t\tconst dist = Math.abs(gray - GRAY_VALUES[i]);\n\t\tif (dist < minDist) {\n\t\t\tminDist = dist;\n\t\t\tminIdx = i;\n\t\t}\n\t}\n\treturn minIdx;\n}\n\nfunction colorDistance(r1: number, g1: number, b1: number, r2: number, g2: number, b2: number): number {\n\t// Weighted Euclidean distance (human eye is more sensitive to green)\n\tconst dr = r1 - r2;\n\tconst dg = g1 - g2;\n\tconst db = b1 - b2;\n\treturn dr * dr * 0.299 + dg * dg * 0.587 + db * db * 0.114;\n}\n\nfunction rgbTo256(r: number, g: number, b: number): number {\n\t// Find closest color in the 6x6x6 cube\n\tconst rIdx = findClosestCubeIndex(r);\n\tconst gIdx = findClosestCubeIndex(g);\n\tconst bIdx = findClosestCubeIndex(b);\n\tconst cubeR = CUBE_VALUES[rIdx];\n\tconst cubeG = CUBE_VALUES[gIdx];\n\tconst cubeB = CUBE_VALUES[bIdx];\n\tconst cubeIndex = 16 + 36 * rIdx + 6 * gIdx + bIdx;\n\tconst cubeDist = colorDistance(r, g, b, cubeR, cubeG, cubeB);\n\n\t// Find closest grayscale\n\tconst gray = Math.round(0.299 * r + 0.587 * g + 0.114 * b);\n\tconst grayIdx = findClosestGrayIndex(gray);\n\tconst grayValue = GRAY_VALUES[grayIdx];\n\tconst grayIndex = 232 + grayIdx;\n\tconst grayDist = colorDistance(r, g, b, grayValue, grayValue, grayValue);\n\n\t// Check if color has noticeable saturation (hue matters)\n\t// If max-min spread is significant, prefer cube to preserve tint\n\tconst maxC = Math.max(r, g, b);\n\tconst minC = Math.min(r, g, b);\n\tconst spread = maxC - minC;\n\n\t// Only consider grayscale if color is nearly neutral (spread < 10)\n\t// AND grayscale is actually closer\n\tif (spread < 10 && grayDist < cubeDist) {\n\t\treturn grayIndex;\n\t}\n\n\treturn cubeIndex;\n}\n\nfunction hexTo256(hex: string): number {\n\tconst { r, g, b } = hexToRgb(hex);\n\treturn rgbTo256(r, g, b);\n}\n\nfunction fgAnsi(color: string | number, mode: ColorMode): string {\n\tif (color === \"\") return \"\\x1b[39m\";\n\tif (typeof color === \"number\") return `\\x1b[38;5;${color}m`;\n\tif (color.startsWith(\"#\")) {\n\t\tif (mode === \"truecolor\") {\n\t\t\tconst { r, g, b } = hexToRgb(color);\n\t\t\treturn `\\x1b[38;2;${r};${g};${b}m`;\n\t\t} else {\n\t\t\tconst index = hexTo256(color);\n\t\t\treturn `\\x1b[38;5;${index}m`;\n\t\t}\n\t}\n\tthrow new Error(t(\"Invalid color value: {color}\", { color }));\n}\n\nfunction bgAnsi(color: string | number, mode: ColorMode): string {\n\tif (color === \"\") return \"\\x1b[49m\";\n\tif (typeof color === \"number\") return `\\x1b[48;5;${color}m`;\n\tif (color.startsWith(\"#\")) {\n\t\tif (mode === \"truecolor\") {\n\t\t\tconst { r, g, b } = hexToRgb(color);\n\t\t\treturn `\\x1b[48;2;${r};${g};${b}m`;\n\t\t} else {\n\t\t\tconst index = hexTo256(color);\n\t\t\treturn `\\x1b[48;5;${index}m`;\n\t\t}\n\t}\n\tthrow new Error(t(\"Invalid color value: {color}\", { color }));\n}\n\nfunction resolveVarRefs(\n\tvalue: ColorValue,\n\tvars: Record<string, ColorValue>,\n\tvisited = new Set<string>(),\n): string | number {\n\tif (typeof value === \"number\" || value === \"\" || value.startsWith(\"#\")) {\n\t\treturn value;\n\t}\n\tif (visited.has(value)) {\n\t\tthrow new Error(t(\"Circular variable reference detected: {value}\", { value }));\n\t}\n\tif (!(value in vars)) {\n\t\tthrow new Error(t(\"Variable reference not found: {value}\", { value }));\n\t}\n\tvisited.add(value);\n\treturn resolveVarRefs(vars[value], vars, visited);\n}\n\nfunction resolveThemeColors<T extends Record<string, ColorValue>>(\n\tcolors: T,\n\tvars: Record<string, ColorValue> = {},\n): Record<keyof T, string | number> {\n\tconst resolved: Record<string, string | number> = {};\n\tfor (const [key, value] of Object.entries(colors)) {\n\t\tresolved[key] = resolveVarRefs(value, vars);\n\t}\n\treturn resolved as Record<keyof T, string | number>;\n}\n\nfunction withThemeColorFallbacks(colors: ThemeJson[\"colors\"]): ThemeJson[\"colors\"] & {\n\tthinkingMax: ColorValue;\n\tscrollbarThumb: ColorValue;\n\tsearchMatchBg: ColorValue;\n\tsearchMatchText: ColorValue;\n} {\n\treturn {\n\t\t...colors,\n\t\tthinkingMax: colors.thinkingMax ?? colors.thinkingXhigh,\n\t\tscrollbarThumb: colors.scrollbarThumb ?? colors.selectedBg,\n\t\tsearchMatchBg: colors.searchMatchBg ?? colors.selectedBg,\n\t\tsearchMatchText: colors.searchMatchText ?? colors.text,\n\t};\n}\n\n// ============================================================================\n// Theme Class\n// ============================================================================\n\nexport class Theme {\n\treadonly name?: string;\n\treadonly sourcePath?: string;\n\tsourceInfo?: SourceInfo;\n\tprivate fgColors: Map<ThemeColor, string>;\n\tprivate bgColors: Map<ThemeBg, string>;\n\tprivate mode: ColorMode;\n\n\tconstructor(\n\t\tfgColors: Record<Exclude<ThemeColor, OptionalThemeColor>, string | number> &\n\t\t\tPartial<Record<OptionalThemeColor, string | number>>,\n\t\tbgColors: Record<Exclude<ThemeBg, OptionalThemeBg>, string | number> &\n\t\t\tPartial<Record<OptionalThemeBg, string | number>>,\n\t\tmode: ColorMode,\n\t\toptions: { name?: string; sourcePath?: string; sourceInfo?: SourceInfo } = {},\n\t) {\n\t\tthis.name = options.name;\n\t\tthis.sourcePath = options.sourcePath;\n\t\tthis.sourceInfo = options.sourceInfo;\n\t\tthis.mode = mode;\n\t\tthis.fgColors = new Map();\n\t\tconst colors = {\n\t\t\t...fgColors,\n\t\t\tthinkingMax: fgColors.thinkingMax ?? fgColors.thinkingXhigh,\n\t\t\tsearchMatchText: fgColors.searchMatchText ?? fgColors.text,\n\t\t};\n\t\tfor (const [key, value] of Object.entries(colors) as [ThemeColor, string | number][]) {\n\t\t\tthis.fgColors.set(key, fgAnsi(value, mode));\n\t\t}\n\t\tthis.bgColors = new Map();\n\t\tconst backgrounds = {\n\t\t\t...bgColors,\n\t\t\tscrollbarThumb: bgColors.scrollbarThumb ?? bgColors.selectedBg,\n\t\t\tsearchMatchBg: bgColors.searchMatchBg ?? bgColors.selectedBg,\n\t\t};\n\t\tfor (const [key, value] of Object.entries(backgrounds) as [ThemeBg, string | number][]) {\n\t\t\tthis.bgColors.set(key, bgAnsi(value, mode));\n\t\t}\n\t}\n\n\tfg(color: ThemeColor, text: string): string {\n\t\tconst ansi = this.fgColors.get(color);\n\t\tif (!ansi) throw new Error(t(\"Unknown theme color: {color}\", { color }));\n\t\treturn `${ansi}${text}\\x1b[39m`; // Reset only foreground color\n\t}\n\n\tbg(color: ThemeBg, text: string): string {\n\t\tconst ansi = this.bgColors.get(color);\n\t\tif (!ansi) throw new Error(t(\"Unknown theme background color: {color}\", { color }));\n\t\treturn `${ansi}${text}\\x1b[49m`; // Reset only background color\n\t}\n\n\tbold(text: string): string {\n\t\treturn chalk.bold(text);\n\t}\n\n\titalic(text: string): string {\n\t\treturn chalk.italic(text);\n\t}\n\n\tunderline(text: string): string {\n\t\treturn chalk.underline(text);\n\t}\n\n\tinverse(text: string): string {\n\t\treturn chalk.inverse(text);\n\t}\n\n\tstrikethrough(text: string): string {\n\t\treturn chalk.strikethrough(text);\n\t}\n\n\tgetFgAnsi(color: ThemeColor): string {\n\t\tconst ansi = this.fgColors.get(color);\n\t\tif (!ansi) throw new Error(t(\"Unknown theme color: {color}\", { color }));\n\t\treturn ansi;\n\t}\n\n\tgetBgAnsi(color: ThemeBg): string {\n\t\tconst ansi = this.bgColors.get(color);\n\t\tif (!ansi) throw new Error(t(\"Unknown theme background color: {color}\", { color }));\n\t\treturn ansi;\n\t}\n\n\tgetColorMode(): ColorMode {\n\t\treturn this.mode;\n\t}\n\n\tgetThinkingBorderColor(level: ThinkingLevel): (str: string) => string {\n\t\t// Map thinking levels to dedicated theme colors\n\t\tswitch (level) {\n\t\t\tcase \"off\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingOff\", str);\n\t\t\tcase \"minimal\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingMinimal\", str);\n\t\t\tcase \"low\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingLow\", str);\n\t\t\tcase \"medium\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingMedium\", str);\n\t\t\tcase \"high\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingHigh\", str);\n\t\t\tcase \"xhigh\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingXhigh\", str);\n\t\t\tcase \"max\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingMax\", str);\n\t\t\tdefault:\n\t\t\t\treturn (str: string) => this.fg(\"thinkingOff\", str);\n\t\t}\n\t}\n\n\tgetBashModeBorderColor(): (str: string) => string {\n\t\treturn (str: string) => this.fg(\"bashMode\", str);\n\t}\n}\n\n// ============================================================================\n// Theme Loading\n// ============================================================================\n\nlet BUILTIN_THEMES: Record<string, ThemeJson> | undefined;\n\nfunction getBuiltinThemes(): Record<string, ThemeJson> {\n\tif (!BUILTIN_THEMES) {\n\t\tconst themesDir = getThemesDir();\n\t\tconst darkPath = path.join(themesDir, \"dark.json\");\n\t\tconst lightPath = path.join(themesDir, \"light.json\");\n\t\tBUILTIN_THEMES = {\n\t\t\tdark: JSON.parse(stripBom(fs.readFileSync(darkPath, \"utf-8\"))) as ThemeJson,\n\t\t\tlight: JSON.parse(stripBom(fs.readFileSync(lightPath, \"utf-8\"))) as ThemeJson,\n\t\t};\n\t}\n\treturn BUILTIN_THEMES;\n}\n\nexport function getAvailableThemes(): string[] {\n\treturn getAvailableThemesWithPaths().map(({ name }) => name);\n}\n\nexport interface ThemeInfo {\n\tname: string;\n\tpath: string | undefined;\n}\n\nexport function getAvailableThemesWithPaths(): ThemeInfo[] {\n\tconst themesDir = getThemesDir();\n\tconst result: ThemeInfo[] = [];\n\tconst seen = new Set<string>();\n\tconst addTheme = (themeInfo: ThemeInfo) => {\n\t\tif (seen.has(themeInfo.name)) {\n\t\t\treturn;\n\t\t}\n\t\tseen.add(themeInfo.name);\n\t\tresult.push(themeInfo);\n\t};\n\n\t// Built-in themes\n\tfor (const name of Object.keys(getBuiltinThemes())) {\n\t\taddTheme({ name, path: path.join(themesDir, `${name}.json`) });\n\t}\n\n\t// Custom themes\n\tfor (const themeInfo of getCustomThemeInfos()) {\n\t\taddTheme(themeInfo);\n\t}\n\n\tfor (const [name, theme] of registeredThemes.entries()) {\n\t\taddTheme({ name, path: theme.sourcePath });\n\t}\n\n\treturn result.sort((a, b) => a.name.localeCompare(b.name));\n}\n\nfunction getCustomThemeInfos(): ThemeInfo[] {\n\tconst customThemesDir = getCustomThemesDir();\n\tconst result: ThemeInfo[] = [];\n\tif (!fs.existsSync(customThemesDir)) {\n\t\treturn result;\n\t}\n\n\tfor (const file of fs.readdirSync(customThemesDir)) {\n\t\tif (!file.endsWith(\".json\")) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst themePath = path.join(customThemesDir, file);\n\t\ttry {\n\t\t\tconst customTheme = loadThemeFromPath(themePath);\n\t\t\tif (customTheme.name) {\n\t\t\t\tresult.push({ name: customTheme.name, path: themePath });\n\t\t\t}\n\t\t} catch {\n\t\t\t// Invalid themes are ignored here; the resource loader reports them\n\t\t\t// during normal startup/reload.\n\t\t}\n\t}\n\treturn result;\n}\n\nfunction assertThemeNameIsValid(name: string): void {\n\tif (name.includes(\"/\")) {\n\t\tthrow new Error(\n\t\t\tt(\n\t\t\t\t'Invalid theme name \"{name}\": theme names cannot contain \"/\" because it is reserved for automatic light/dark theme settings.',\n\t\t\t\t{\n\t\t\t\t\tname,\n\t\t\t\t},\n\t\t\t),\n\t\t);\n\t}\n}\n\nfunction parseThemeJson(label: string, json: unknown): ThemeJson {\n\tif (!validateThemeJson.Check(json)) {\n\t\tconst errors = Array.from(validateThemeJson.Errors(json));\n\t\tconst missingColors = new Set<string>();\n\t\tconst otherErrors: string[] = [];\n\n\t\tfor (const error of errors) {\n\t\t\tif (error.keyword === \"required\" && error.instancePath === \"/colors\") {\n\t\t\t\tconst requiredProperties = (error.params as { requiredProperties?: string[] }).requiredProperties;\n\t\t\t\tfor (const requiredProperty of requiredProperties ?? []) {\n\t\t\t\t\tmissingColors.add(requiredProperty);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst path = error.instancePath || \"/\";\n\t\t\totherErrors.push(` - ${path}: ${error.message}`);\n\t\t}\n\n\t\tlet errorMessage = `${t('Invalid theme \"{label}\":', { label })}\\n`;\n\t\tif (missingColors.size > 0) {\n\t\t\terrorMessage += `\\n${t(\"Missing required color tokens:\")}\\n`;\n\t\t\terrorMessage += Array.from(missingColors)\n\t\t\t\t.sort()\n\t\t\t\t.map((color) => ` - ${color}`)\n\t\t\t\t.join(\"\\n\");\n\t\t\terrorMessage += `\\n\\n${t('Please add these colors to your theme\\'s \"colors\" object.')}`;\n\t\t\terrorMessage += `\\n${t(\"See the built-in themes (dark.json, light.json) for reference values.\")}`;\n\t\t}\n\t\tif (otherErrors.length > 0) {\n\t\t\terrorMessage += `\\n\\n${t(\"Other errors:\")}\\n${otherErrors.join(\"\\n\")}`;\n\t\t}\n\n\t\tthrow new Error(errorMessage);\n\t}\n\n\tconst themeJson = json as ThemeJson;\n\tassertThemeNameIsValid(themeJson.name);\n\treturn themeJson;\n}\n\nfunction parseThemeJsonContent(label: string, content: string): ThemeJson {\n\tlet json: unknown;\n\ttry {\n\t\tjson = JSON.parse(stripBom(content));\n\t} catch (error) {\n\t\tthrow new Error(t(\"Failed to parse theme {label}: {error}\", { label, error: String(error) }));\n\t}\n\treturn parseThemeJson(label, json);\n}\n\nfunction loadThemeJson(name: string): ThemeJson {\n\tconst builtinThemes = getBuiltinThemes();\n\tif (name in builtinThemes) {\n\t\treturn builtinThemes[name];\n\t}\n\tconst registeredTheme = registeredThemes.get(name);\n\tif (registeredTheme?.sourcePath) {\n\t\tconst content = fs.readFileSync(registeredTheme.sourcePath, \"utf-8\");\n\t\treturn parseThemeJsonContent(registeredTheme.sourcePath, content);\n\t}\n\tif (registeredTheme) {\n\t\tthrow new Error(t('Theme \"{name}\" does not have a source path for export', { name }));\n\t}\n\tconst customThemesDir = getCustomThemesDir();\n\tconst themePath = path.join(customThemesDir, `${name}.json`);\n\tif (!fs.existsSync(themePath)) {\n\t\tthrow new Error(t(\"Theme not found: {name}\", { name }));\n\t}\n\tconst content = fs.readFileSync(themePath, \"utf-8\");\n\treturn parseThemeJsonContent(name, content);\n}\n\nfunction createTheme(themeJson: ThemeJson, mode?: ColorMode, sourcePath?: string): Theme {\n\tconst colorMode = mode ?? (getCapabilities().trueColor ? \"truecolor\" : \"256color\");\n\tconst resolvedColors = resolveThemeColors(withThemeColorFallbacks(themeJson.colors), themeJson.vars);\n\tconst fgColors: Record<ThemeColor, string | number> = {} as Record<ThemeColor, string | number>;\n\tconst bgColors: Record<ThemeBg, string | number> = {} as Record<ThemeBg, string | number>;\n\tconst bgColorKeys: Set<string> = new Set([\n\t\t\"selectedBg\",\n\t\t\"scrollbarThumb\",\n\t\t\"searchMatchBg\",\n\t\t\"userMessageBg\",\n\t\t\"customMessageBg\",\n\t\t\"toolPendingBg\",\n\t\t\"toolSuccessBg\",\n\t\t\"toolErrorBg\",\n\t]);\n\tfor (const [key, value] of Object.entries(resolvedColors)) {\n\t\tif (bgColorKeys.has(key)) {\n\t\t\tbgColors[key as ThemeBg] = value;\n\t\t} else {\n\t\t\tfgColors[key as ThemeColor] = value;\n\t\t}\n\t}\n\treturn new Theme(fgColors, bgColors, colorMode, {\n\t\tname: themeJson.name,\n\t\tsourcePath,\n\t});\n}\n\nexport function loadThemeFromPath(themePath: string, mode?: ColorMode): Theme {\n\tconst content = fs.readFileSync(themePath, \"utf-8\");\n\tconst themeJson = parseThemeJsonContent(themePath, content);\n\treturn createTheme(themeJson, mode, themePath);\n}\n\nfunction loadTheme(name: string, mode?: ColorMode): Theme {\n\tconst registeredTheme = registeredThemes.get(name);\n\tif (registeredTheme) {\n\t\treturn registeredTheme;\n\t}\n\tconst themeJson = loadThemeJson(name);\n\treturn createTheme(themeJson, mode);\n}\n\nexport function getThemeByName(name: string): Theme | undefined {\n\ttry {\n\t\treturn loadTheme(name);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport type TerminalTheme = \"dark\" | \"light\";\n\nexport function parseAutoThemeSetting(\n\tthemeSetting: string | undefined,\n): { lightTheme: string; darkTheme: string } | undefined {\n\tif (!themeSetting) return undefined;\n\tconst slashIndex = themeSetting.indexOf(\"/\");\n\tif (slashIndex === -1 || themeSetting.indexOf(\"/\", slashIndex + 1) !== -1) {\n\t\treturn undefined;\n\t}\n\n\tconst lightTheme = themeSetting.slice(0, slashIndex).trim();\n\tconst darkTheme = themeSetting.slice(slashIndex + 1).trim();\n\tif (!lightTheme || !darkTheme) {\n\t\treturn undefined;\n\t}\n\treturn { lightTheme, darkTheme };\n}\n\nexport function resolveThemeSetting(\n\tthemeSetting: string | undefined,\n\tterminalTheme: TerminalTheme,\n): string | undefined {\n\tconst autoTheme = parseAutoThemeSetting(themeSetting);\n\tif (autoTheme) {\n\t\treturn terminalTheme === \"light\" ? autoTheme.lightTheme : autoTheme.darkTheme;\n\t}\n\tif (themeSetting?.includes(\"/\")) return undefined;\n\tif (typeof themeSetting === \"string\") return themeSetting;\n\treturn undefined;\n}\n\nexport interface TerminalThemeDetection {\n\ttheme: TerminalTheme;\n\tsource: \"terminal background\" | \"COLORFGBG\" | \"fallback\";\n\tdetail: string;\n\tconfidence: \"high\" | \"low\";\n}\n\nexport interface TerminalThemeDetectionOptions {\n\tenv?: NodeJS.ProcessEnv;\n}\n\nexport interface TerminalBackgroundThemeDetector {\n\tqueryTerminalBackgroundColor({ timeoutMs }: { timeoutMs: number }): Promise<RgbColor | undefined>;\n}\n\nexport interface TerminalAutoThemeDetector extends TerminalBackgroundThemeDetector {\n\tqueryTerminalColorScheme?({ timeoutMs }: { timeoutMs: number }): Promise<TerminalTheme | undefined>;\n}\n\nexport interface TerminalBackgroundThemeDetectionOptions extends TerminalThemeDetectionOptions {\n\tui: TerminalBackgroundThemeDetector;\n\ttimeoutMs: number;\n}\n\nexport interface TerminalAutoThemeDetectionOptions extends TerminalThemeDetectionOptions {\n\tui: TerminalAutoThemeDetector;\n\ttimeoutMs: number;\n}\n\nfunction getColorFgBgBackgroundIndex(colorfgbg: string): number | undefined {\n\tconst parts = colorfgbg.split(\";\");\n\tfor (let i = parts.length - 1; i >= 0; i--) {\n\t\tconst bg = parseInt(parts[i].trim(), 10);\n\t\tif (Number.isInteger(bg) && bg >= 0 && bg <= 255) {\n\t\t\treturn bg;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction getRgbColorLuminance({ r, g, b }: RgbColor): number {\n\tconst toLinear = (channel: number) => {\n\t\tconst value = channel / 255;\n\t\treturn value <= 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;\n\t};\n\treturn 0.2126 * toLinear(r) + 0.7152 * toLinear(g) + 0.0722 * toLinear(b);\n}\n\nfunction getAnsiColorLuminance(index: number): number {\n\treturn getRgbColorLuminance(hexToRgb(ansi256ToHex(index)));\n}\n\nexport function getThemeForRgbColor(rgb: RgbColor): TerminalTheme {\n\treturn getRgbColorLuminance(rgb) >= 0.5 ? \"light\" : \"dark\";\n}\n\nexport function detectTerminalBackgroundFromEnv(options: TerminalThemeDetectionOptions = {}): TerminalThemeDetection {\n\tconst env = options.env ?? process.env;\n\tconst colorfgbg = env.COLORFGBG || \"\";\n\tconst bg = getColorFgBgBackgroundIndex(colorfgbg);\n\tif (bg !== undefined) {\n\t\treturn {\n\t\t\ttheme: getAnsiColorLuminance(bg) >= 0.5 ? \"light\" : \"dark\",\n\t\t\tsource: \"COLORFGBG\",\n\t\t\tdetail: `background color index ${bg}`,\n\t\t\tconfidence: \"high\",\n\t\t};\n\t}\n\n\treturn {\n\t\ttheme: \"dark\",\n\t\tsource: \"fallback\",\n\t\tdetail: \"no terminal background hint found\",\n\t\tconfidence: \"low\",\n\t};\n}\n\nexport async function detectTerminalBackgroundTheme({\n\tui,\n\ttimeoutMs,\n\tenv,\n}: TerminalBackgroundThemeDetectionOptions): Promise<TerminalThemeDetection> {\n\ttry {\n\t\tconst rgb = await ui.queryTerminalBackgroundColor({ timeoutMs });\n\t\tif (rgb) {\n\t\t\treturn {\n\t\t\t\ttheme: getThemeForRgbColor(rgb),\n\t\t\t\tsource: \"terminal background\",\n\t\t\t\tdetail: `OSC 11 background rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`,\n\t\t\t\tconfidence: \"high\",\n\t\t\t};\n\t\t}\n\t} catch {\n\t\t// Fall back to environment-based detection when the terminal query fails.\n\t}\n\n\treturn detectTerminalBackgroundFromEnv({ env });\n}\n\nexport async function detectTerminalThemeForAuto({\n\tui,\n\ttimeoutMs,\n\tenv,\n}: TerminalAutoThemeDetectionOptions): Promise<TerminalTheme> {\n\tlet colorSchemePromise: Promise<TerminalTheme | undefined> | undefined;\n\ttry {\n\t\tcolorSchemePromise = ui.queryTerminalColorScheme?.({ timeoutMs });\n\t} catch {\n\t\t// Fall back to OSC 11 / COLORFGBG detection when starting the color-scheme query fails.\n\t}\n\tconst backgroundThemePromise = detectTerminalBackgroundTheme({ ui, timeoutMs, env });\n\n\ttry {\n\t\tconst colorScheme = await colorSchemePromise;\n\t\tif (colorScheme) return colorScheme;\n\t} catch {\n\t\t// Fall back to the concurrently queried OSC 11 / COLORFGBG detection.\n\t}\n\treturn (await backgroundThemePromise).theme;\n}\n\nexport function getDefaultTheme(): string {\n\treturn detectTerminalBackgroundFromEnv().theme;\n}\n\n// ============================================================================\n// Global Theme Instance\n// ============================================================================\n\n// Use globalThis to share theme across module loaders (tsx + jiti in dev mode)\nconst THEME_KEY = Symbol.for(\"@agent-forge/agent-forge:theme\");\nconst THEME_KEY_OLD = Symbol.for(\"@mariozechner/pi-coding-agent:theme\");\n\n// Export theme as a getter that reads from globalThis\n// This ensures all module instances (tsx, jiti) see the same theme\nexport const theme: Theme = new Proxy({} as Theme, {\n\tget(_target, prop) {\n\t\tconst active = (globalThis as Record<symbol, Theme>)[THEME_KEY];\n\t\tif (!active) throw new Error(t(\"Theme not initialized. Call initTheme() first.\"));\n\t\treturn (active as unknown as Record<string | symbol, unknown>)[prop];\n\t},\n});\n\nfunction setGlobalTheme(t: Theme): void {\n\t(globalThis as Record<symbol, Theme>)[THEME_KEY] = t;\n\t(globalThis as Record<symbol, Theme>)[THEME_KEY_OLD] = t;\n}\n\nlet currentThemeName: string | undefined;\nlet themeWatcher: fs.FSWatcher | undefined;\nlet themeReloadTimer: NodeJS.Timeout | undefined;\nlet onThemeChangeCallback: (() => void) | undefined;\nconst registeredThemes = new Map<string, Theme>();\n\nexport function setRegisteredThemes(themes: Theme[]): void {\n\tregisteredThemes.clear();\n\tfor (const theme of themes) {\n\t\tif (theme.name) {\n\t\t\tassertThemeNameIsValid(theme.name);\n\t\t\tregisteredThemes.set(theme.name, theme);\n\t\t}\n\t}\n}\n\nexport function initTheme(themeName?: string, enableWatcher: boolean = false): void {\n\tconst name = themeName ?? getDefaultTheme();\n\tcurrentThemeName = name;\n\ttry {\n\t\tsetGlobalTheme(loadTheme(name));\n\t\tif (enableWatcher) {\n\t\t\tstartThemeWatcher();\n\t\t}\n\t} catch (_error) {\n\t\t// Theme is invalid - fall back to dark theme silently\n\t\tcurrentThemeName = \"dark\";\n\t\tsetGlobalTheme(loadTheme(\"dark\"));\n\t\t// Don't start watcher for fallback theme\n\t}\n}\n\nexport function setTheme(name: string, enableWatcher: boolean = false): { success: boolean; error?: string } {\n\tcurrentThemeName = name;\n\ttry {\n\t\tsetGlobalTheme(loadTheme(name));\n\t\tif (enableWatcher) {\n\t\t\tstartThemeWatcher();\n\t\t}\n\t\tif (onThemeChangeCallback) {\n\t\t\tonThemeChangeCallback();\n\t\t}\n\t\treturn { success: true };\n\t} catch (error) {\n\t\t// Theme is invalid - fall back to dark theme\n\t\tcurrentThemeName = \"dark\";\n\t\tsetGlobalTheme(loadTheme(\"dark\"));\n\t\t// Don't start watcher for fallback theme\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\t// v8 ignore next -- loadTheme rejections are always Error instances\n\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t};\n\t}\n}\n\nexport function setThemeInstance(themeInstance: Theme): void {\n\tsetGlobalTheme(themeInstance);\n\tcurrentThemeName = \"<in-memory>\";\n\tstopThemeWatcher(); // Can't watch a direct instance\n\tif (onThemeChangeCallback) {\n\t\tonThemeChangeCallback();\n\t}\n}\n\nexport function onThemeChange(callback: () => void): void {\n\tonThemeChangeCallback = callback;\n}\n\nfunction startThemeWatcher(): void {\n\tstopThemeWatcher();\n\n\t// Only watch if it's a custom theme (not built-in)\n\tif (!currentThemeName || currentThemeName === \"dark\" || currentThemeName === \"light\") {\n\t\treturn;\n\t}\n\n\tconst customThemesDir = getCustomThemesDir();\n\tconst watchedThemeName = currentThemeName;\n\tconst watchedFileName = `${watchedThemeName}.json`;\n\tconst themeFile = path.join(customThemesDir, watchedFileName);\n\n\t// Only watch if the file exists\n\tif (!fs.existsSync(themeFile)) {\n\t\treturn;\n\t}\n\n\tconst scheduleReload = () => {\n\t\tif (themeReloadTimer) {\n\t\t\tclearTimeout(themeReloadTimer);\n\t\t}\n\t\tthemeReloadTimer = setTimeout(() => {\n\t\t\tthemeReloadTimer = undefined;\n\n\t\t\t// Ignore stale timers after switching themes or stopping the watcher\n\t\t\tif (currentThemeName !== watchedThemeName) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Keep the last successfully loaded theme active if the file is temporarily missing\n\t\t\tif (!fs.existsSync(themeFile)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\t// Reload the theme from disk and refresh the registry cache\n\t\t\t\tconst reloadedTheme = loadThemeFromPath(themeFile);\n\t\t\t\tregisteredThemes.set(watchedThemeName, reloadedTheme);\n\t\t\t\tsetGlobalTheme(reloadedTheme);\n\t\t\t\t// Notify callback (to invalidate UI)\n\t\t\t\tif (onThemeChangeCallback) {\n\t\t\t\t\tonThemeChangeCallback();\n\t\t\t\t}\n\t\t\t} catch (_error) {\n\t\t\t\t// Ignore errors (file might be in invalid state while being edited)\n\t\t\t}\n\t\t}, 100);\n\t};\n\n\tthemeWatcher =\n\t\twatchWithErrorHandler(\n\t\t\tcustomThemesDir,\n\t\t\t(_eventType, filename) => {\n\t\t\t\tif (currentThemeName !== watchedThemeName) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (!filename) {\n\t\t\t\t\tscheduleReload();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (filename !== watchedFileName) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tscheduleReload();\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tcloseWatcher(themeWatcher);\n\t\t\t\tthemeWatcher = undefined;\n\t\t\t},\n\t\t) ?? undefined;\n}\n\nexport function stopThemeWatcher(): void {\n\tif (themeReloadTimer) {\n\t\tclearTimeout(themeReloadTimer);\n\t\tthemeReloadTimer = undefined;\n\t}\n\tcloseWatcher(themeWatcher);\n\tthemeWatcher = undefined;\n}\n\n// ============================================================================\n// HTML Export Helpers\n// ============================================================================\n\n/**\n * Convert a 256-color index to hex string.\n * Indices 0-15: basic colors (approximate)\n * Indices 16-231: 6x6x6 color cube\n * Indices 232-255: grayscale ramp\n */\nfunction ansi256ToHex(index: number): string {\n\t// Basic colors (0-15) - approximate common terminal values\n\tconst basicColors = [\n\t\t\"#000000\",\n\t\t\"#800000\",\n\t\t\"#008000\",\n\t\t\"#808000\",\n\t\t\"#000080\",\n\t\t\"#800080\",\n\t\t\"#008080\",\n\t\t\"#c0c0c0\",\n\t\t\"#808080\",\n\t\t\"#ff0000\",\n\t\t\"#00ff00\",\n\t\t\"#ffff00\",\n\t\t\"#0000ff\",\n\t\t\"#ff00ff\",\n\t\t\"#00ffff\",\n\t\t\"#ffffff\",\n\t];\n\tif (index < 16) {\n\t\treturn basicColors[index];\n\t}\n\n\t// Color cube (16-231): 6x6x6 = 216 colors\n\tif (index < 232) {\n\t\tconst cubeIndex = index - 16;\n\t\tconst r = Math.floor(cubeIndex / 36);\n\t\tconst g = Math.floor((cubeIndex % 36) / 6);\n\t\tconst b = cubeIndex % 6;\n\t\tconst toHex = (n: number) => (n === 0 ? 0 : 55 + n * 40).toString(16).padStart(2, \"0\");\n\t\treturn `#${toHex(r)}${toHex(g)}${toHex(b)}`;\n\t}\n\n\t// Grayscale (232-255): 24 shades\n\tconst gray = 8 + (index - 232) * 10;\n\tconst grayHex = gray.toString(16).padStart(2, \"0\");\n\treturn `#${grayHex}${grayHex}${grayHex}`;\n}\n\n/**\n * Get resolved theme colors as CSS-compatible hex strings.\n * Used by HTML export to generate CSS custom properties.\n */\nexport function getResolvedThemeColors(themeName?: string): Record<string, string> {\n\tconst name = themeName ?? currentThemeName ?? getDefaultTheme();\n\tconst isLight = name === \"light\";\n\tconst themeJson = loadThemeJson(name);\n\tconst resolved = resolveThemeColors(withThemeColorFallbacks(themeJson.colors), themeJson.vars);\n\n\t// Default text color for empty values (terminal uses default fg color)\n\tconst defaultText = isLight ? \"#000000\" : \"#e5e5e7\";\n\n\tconst cssColors: Record<string, string> = {};\n\tfor (const [key, value] of Object.entries(resolved)) {\n\t\tif (typeof value === \"number\") {\n\t\t\tcssColors[key] = ansi256ToHex(value);\n\t\t} else if (value === \"\") {\n\t\t\t// Empty means default terminal color - use sensible fallback for HTML\n\t\t\tcssColors[key] = defaultText;\n\t\t} else {\n\t\t\tcssColors[key] = value;\n\t\t}\n\t}\n\treturn cssColors;\n}\n\n/**\n * Check if a theme is a \"light\" theme (for CSS that needs light/dark variants).\n */\nexport function isLightTheme(themeName?: string): boolean {\n\t// Currently just check the name - could be extended to analyze colors\n\treturn themeName === \"light\";\n}\n\n/**\n * Get explicit export colors from theme JSON, if specified.\n * Returns undefined for each color that isn't explicitly set.\n */\nexport function getThemeExportColors(themeName?: string): {\n\tpageBg?: string;\n\tcardBg?: string;\n\tinfoBg?: string;\n} {\n\tconst name = themeName ?? currentThemeName ?? getDefaultTheme();\n\ttry {\n\t\tconst themeJson = loadThemeJson(name);\n\t\tconst exportSection = themeJson.export;\n\t\tif (!exportSection) return {};\n\n\t\tconst vars = themeJson.vars ?? {};\n\t\tconst resolve = (value: ColorValue | undefined): string | undefined => {\n\t\t\tif (value === undefined) return undefined;\n\t\t\tconst resolved = resolveVarRefs(value, vars);\n\t\t\tif (typeof resolved === \"number\") return ansi256ToHex(resolved);\n\t\t\tif (resolved === \"\") return undefined;\n\t\t\treturn resolved;\n\t\t};\n\n\t\treturn {\n\t\t\tpageBg: resolve(exportSection.pageBg),\n\t\t\tcardBg: resolve(exportSection.cardBg),\n\t\t\tinfoBg: resolve(exportSection.infoBg),\n\t\t};\n\t} catch {\n\t\treturn {};\n\t}\n}\n\n// ============================================================================\n// TUI Helpers\n// ============================================================================\n\ntype CliHighlightTheme = Record<string, (s: string) => string>;\n\nlet cachedHighlightThemeFor: Theme | undefined;\nlet cachedCliHighlightTheme: CliHighlightTheme | undefined;\n\nfunction buildCliHighlightTheme(t: Theme): CliHighlightTheme {\n\treturn {\n\t\tkeyword: (s: string) => t.fg(\"syntaxKeyword\", s),\n\t\tbuilt_in: (s: string) => t.fg(\"syntaxType\", s),\n\t\tliteral: (s: string) => t.fg(\"syntaxNumber\", s),\n\t\tnumber: (s: string) => t.fg(\"syntaxNumber\", s),\n\t\tregexp: (s: string) => t.fg(\"syntaxString\", s),\n\t\tstring: (s: string) => t.fg(\"syntaxString\", s),\n\t\tcomment: (s: string) => t.fg(\"syntaxComment\", s),\n\t\tdoctag: (s: string) => t.fg(\"syntaxComment\", s),\n\t\tmeta: (s: string) => t.fg(\"muted\", s),\n\t\tfunction: (s: string) => t.fg(\"syntaxFunction\", s),\n\t\ttitle: (s: string) => t.fg(\"syntaxFunction\", s),\n\t\tclass: (s: string) => t.fg(\"syntaxType\", s),\n\t\ttype: (s: string) => t.fg(\"syntaxType\", s),\n\t\ttag: (s: string) => t.fg(\"syntaxPunctuation\", s),\n\t\tname: (s: string) => t.fg(\"syntaxKeyword\", s),\n\t\tattr: (s: string) => t.fg(\"syntaxVariable\", s),\n\t\tvariable: (s: string) => t.fg(\"syntaxVariable\", s),\n\t\tparams: (s: string) => t.fg(\"syntaxVariable\", s),\n\t\toperator: (s: string) => t.fg(\"syntaxOperator\", s),\n\t\tpunctuation: (s: string) => t.fg(\"syntaxPunctuation\", s),\n\t\temphasis: (s: string) => t.italic(s),\n\t\tstrong: (s: string) => t.bold(s),\n\t\tlink: (s: string) => t.underline(s),\n\t\taddition: (s: string) => t.fg(\"toolDiffAdded\", s),\n\t\tdeletion: (s: string) => t.fg(\"toolDiffRemoved\", s),\n\t};\n}\n\nfunction getCliHighlightTheme(t: Theme): CliHighlightTheme {\n\tif (cachedHighlightThemeFor !== t || !cachedCliHighlightTheme) {\n\t\tcachedHighlightThemeFor = t;\n\t\tcachedCliHighlightTheme = buildCliHighlightTheme(t);\n\t}\n\treturn cachedCliHighlightTheme;\n}\n\n/**\n * Highlight code with syntax coloring based on file extension or language.\n * Returns array of highlighted lines.\n */\nexport function highlightCode(code: string, lang?: string): string[] {\n\t// Validate language before highlighting to avoid stderr spam from cli-highlight\n\tconst validLang = lang && supportsLanguage(lang) ? lang : undefined;\n\t// Skip highlighting when no valid language is specified. cli-highlight's\n\t// auto-detection is unreliable and can misidentify prose as AppleScript,\n\t// LiveCodeServer, etc., coloring random English words as keywords.\n\tif (!validLang) {\n\t\treturn code.split(\"\\n\").map((line) => theme.fg(\"mdCodeBlock\", line));\n\t}\n\tconst opts = {\n\t\tlanguage: validLang,\n\t\tignoreIllegals: true,\n\t\ttheme: getCliHighlightTheme(theme),\n\t};\n\ttry {\n\t\treturn highlight(code, opts).split(\"\\n\");\n\t} catch {\n\t\treturn code.split(\"\\n\");\n\t}\n}\n\n/**\n * Get language identifier from file path extension.\n */\nexport function getLanguageFromPath(filePath: string): string | undefined {\n\tconst ext = filePath.split(\".\").pop()?.toLowerCase();\n\tif (!ext) return undefined;\n\n\tconst extToLang: Record<string, string> = {\n\t\tts: \"typescript\",\n\t\ttsx: \"typescript\",\n\t\tjs: \"javascript\",\n\t\tjsx: \"javascript\",\n\t\tmjs: \"javascript\",\n\t\tcjs: \"javascript\",\n\t\tpy: \"python\",\n\t\trb: \"ruby\",\n\t\trs: \"rust\",\n\t\tgo: \"go\",\n\t\tjava: \"java\",\n\t\tkt: \"kotlin\",\n\t\tswift: \"swift\",\n\t\tc: \"c\",\n\t\th: \"c\",\n\t\tcpp: \"cpp\",\n\t\tcc: \"cpp\",\n\t\tcxx: \"cpp\",\n\t\thpp: \"cpp\",\n\t\tcs: \"csharp\",\n\t\tphp: \"php\",\n\t\tsh: \"bash\",\n\t\tbash: \"bash\",\n\t\tzsh: \"bash\",\n\t\tfish: \"fish\",\n\t\tps1: \"powershell\",\n\t\tsql: \"sql\",\n\t\thtml: \"html\",\n\t\thtm: \"html\",\n\t\tcss: \"css\",\n\t\tscss: \"scss\",\n\t\tsass: \"sass\",\n\t\tless: \"less\",\n\t\tjson: \"json\",\n\t\tyaml: \"yaml\",\n\t\tyml: \"yaml\",\n\t\ttoml: \"toml\",\n\t\txml: \"xml\",\n\t\tmd: \"markdown\",\n\t\tmarkdown: \"markdown\",\n\t\tdockerfile: \"dockerfile\",\n\t\tmakefile: \"makefile\",\n\t\tcmake: \"cmake\",\n\t\tlua: \"lua\",\n\t\tperl: \"perl\",\n\t\tr: \"r\",\n\t\tscala: \"scala\",\n\t\tclj: \"clojure\",\n\t\tex: \"elixir\",\n\t\texs: \"elixir\",\n\t\terl: \"erlang\",\n\t\ths: \"haskell\",\n\t\tml: \"ocaml\",\n\t\tvim: \"vim\",\n\t\tgraphql: \"graphql\",\n\t\tproto: \"protobuf\",\n\t\ttf: \"hcl\",\n\t\thcl: \"hcl\",\n\t};\n\n\treturn extToLang[ext];\n}\n\nexport function getMarkdownTheme(): MarkdownTheme {\n\treturn {\n\t\theading: (text: string) => theme.fg(\"mdHeading\", text),\n\t\tlink: (text: string) => theme.fg(\"mdLink\", text),\n\t\tlinkUrl: (text: string) => theme.fg(\"mdLinkUrl\", text),\n\t\tcode: (text: string) => theme.fg(\"mdCode\", text),\n\t\tcodeBlock: (text: string) => theme.fg(\"mdCodeBlock\", text),\n\t\tcodeBlockBorder: (text: string) => theme.fg(\"mdCodeBlockBorder\", text),\n\t\tquote: (text: string) => theme.fg(\"mdQuote\", text),\n\t\tquoteBorder: (text: string) => theme.fg(\"mdQuoteBorder\", text),\n\t\thr: (text: string) => theme.fg(\"mdHr\", text),\n\t\tlistBullet: (text: string) => theme.fg(\"mdListBullet\", text),\n\t\tbold: (text: string) => theme.bold(text),\n\t\titalic: (text: string) => theme.italic(text),\n\t\tunderline: (text: string) => theme.underline(text),\n\t\tstrikethrough: (text: string) => chalk.strikethrough(text),\n\t\thighlightCode: (code: string, lang?: string): string[] => {\n\t\t\t// Validate language before highlighting to avoid stderr spam from cli-highlight\n\t\t\tconst validLang = lang && supportsLanguage(lang) ? lang : undefined;\n\t\t\t// Skip highlighting when no valid language is specified. cli-highlight's\n\t\t\t// auto-detection is unreliable and can misidentify prose as AppleScript,\n\t\t\t// LiveCodeServer, etc., coloring random English words as keywords.\n\t\t\tif (!validLang) {\n\t\t\t\treturn code.split(\"\\n\").map((line) => theme.fg(\"mdCodeBlock\", line));\n\t\t\t}\n\t\t\tconst opts = {\n\t\t\t\tlanguage: validLang,\n\t\t\t\tignoreIllegals: true,\n\t\t\t\ttheme: getCliHighlightTheme(theme),\n\t\t\t};\n\t\t\ttry {\n\t\t\t\treturn highlight(code, opts).split(\"\\n\");\n\t\t\t} catch {\n\t\t\t\treturn code.split(\"\\n\").map((line) => theme.fg(\"mdCodeBlock\", line));\n\t\t\t}\n\t\t},\n\t};\n}\n\nexport function getSelectListTheme(): SelectListTheme {\n\treturn {\n\t\tselectedPrefix: (text: string) => theme.fg(\"accent\", text),\n\t\tselectedText: (text: string) => theme.fg(\"accent\", text),\n\t\tdescription: (text: string) => theme.fg(\"muted\", text),\n\t\tscrollInfo: (text: string) => theme.fg(\"muted\", text),\n\t\tnoMatch: (text: string) => theme.fg(\"muted\", text),\n\t};\n}\n\nexport function getEditorTheme(): EditorTheme {\n\treturn {\n\t\tborderColor: (text: string) => theme.fg(\"borderMuted\", text),\n\t\tselectList: getSelectListTheme(),\n\t};\n}\n\nexport function getSettingsListTheme(): SettingsListTheme {\n\treturn {\n\t\tlabel: (text: string, selected: boolean) => (selected ? theme.fg(\"accent\", text) : text),\n\t\tvalue: (text: string, selected: boolean) => (selected ? theme.fg(\"accent\", text) : theme.fg(\"muted\", text)),\n\t\tdescription: (text: string) => theme.fg(\"dim\", text),\n\t\tcursor: theme.fg(\"accent\", \"→ \"),\n\t\thint: (text: string) => theme.fg(\"dim\", text),\n\t};\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,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K,CAAC,EAAE,eAAe,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC7B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;IAAE,eAAe,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GACzD,oBAAoB,CAWtB;AAED,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,OAAO,EACd,OAAO,GAAE;IAAE,eAAe,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GAC9D,oBAAoB,CA0FtB","sourcesContent":["/**\n * Builtin suite (方案) declarations and suite.json (schemaVersion 1)\n * serialization, parsing, and validation — 方案系统设计.md v2 §5/§6/§9, M1a.\n *\n * Suites are pure data plus default policy: both builtin suites share the same\n * unrestricted tool surface and differ only in orientation and memory strategy\n * (the orientation persona text is injected into the system prompt, M2).\n * Nothing here touches the packages/agent kernel; association resolution is\n * declaration-only until M1b.\n */\n\nexport const SUITE_SCHEMA_VERSION = 1;\n\n/**\n * Factory contents revision (M4): the revision of the factory builtin\n * declarations, independent of SUITE_SCHEMA_VERSION. Bump it (and update both\n * builtin declarations' `factoryRevision`) whenever the factory contents\n * change; the registry upgrade proposal then offers `--suite-reset` for\n * workspaces still on an older revision. Suite schema evolution keeps using\n * SUITE_SCHEMA_VERSION.\n *\n * Revision 2 (统一修复轮集成收口, 2026-09-08): assistant and coding now share\n * the same active 8-tool surface in full-control — the sdk `suiteToolOverride`\n * DEFAULT_SUITE_ID exemption was removed (方案设计 §5 + user decision). Existing\n * workspaces provisioned at revision 1 receive the upgrade-proposal diagnostic\n * and adopt via `--suite-reset`.\n *\n * Revision 3 (2026-09-18): `builtin.session-share` joins both builtin suites\n * (开发计划 §216: session-share productized from the example plugin into a\n * first-party default-distributed capability) once the agent-dir config\n * channel for embedded capabilities landed\n * (`<agentDir>/capabilities/<short-id>.json`, see capabilities/builtin.ts).\n * Existing workspaces provisioned at revision 2 receive the upgrade-proposal\n * diagnostic and adopt via `--suite-reset`.\n *\n * Revision 4 (2026-09-18): `builtin.subagent-delegate` joins both builtin\n * suites — the first-party subagent delegation tool (`subagent_run`) now ships\n * by default in shared mode (zero extra processes; pooled runner processes stay\n * opt-in through the capability config channel). Existing workspaces\n * provisioned at revision 3 receive the upgrade-proposal diagnostic and adopt\n * via `--suite-reset`.\n *\n * Revision 5 (2026-09-20): subagent role profiles land on disk only\n * (`<agentDir>/roles/<id>.json` — the factory seeds explore/reviewer and never\n * overwrites user edits) and both builtin suites associate them by default via\n * the new `suite.associations.roles` field, with skill/MCP-isomorphic\n * visibility: unassociated roles stay invisible, associated-but-missing files\n * surface as dangling diagnostics. Existing workspaces provisioned at\n * revision 4 receive the upgrade-proposal diagnostic and adopt via\n * `--suite-reset`.\n *\n * Revision 6 (D-077, 2026-10-02): `builtin.workflow` joins both builtin suites\n * — the workflow orchestration plugin enters the factory bootstrap manifest\n * (ninth package) and the suite capability declaration at goal/plan/todo-set\n * parity, keeping its plugin form. Existing workspaces provisioned at revision\n * 5 receive the upgrade-proposal diagnostic and adopt via `--suite-reset`.\n *\n * Revision 7 (视觉保底, 2026-10-04): the two visual baseline roles\n * `design-proposer` / `visual-reviewer` join the factory seeds and the default\n * `associations.roles` (user ruling \"术有专攻、角色隔离\"; role files are\n * disk-only and the seeds never overwrite user edits — see\n * `docs/plans/视觉保底角色设计注记.md`). Existing workspaces provisioned at\n * revision 6 receive the upgrade-proposal diagnostic and adopt via\n * `--suite-reset`.\n */\nexport const FACTORY_CONTENTS_VERSION = 7;\n\n/**\n * Factory default suite used when no suite is configured anywhere (设计 §9).\n * 2026-10-02 user ruling: the product is a coding agent, so the factory\n * default flipped from \"assistant\" to \"coding\"; assistant stays as the\n * explicit-switch fallback suite.\n */\nexport const DEFAULT_SUITE_ID = \"coding\";\n\n/** Suite ids become directory names: lowercase letters, digits, hyphens (设计 §9). */\nexport const SUITE_ID_MAX_LENGTH = 64;\n\n/** The single unrestricted tool surface shared by both builtin suites (设计 §5/§6). */\nexport const BUILTIN_SUITE_TOOLS: readonly string[] = [\n\t\"read\",\n\t\"write\",\n\t\"edit\",\n\t\"bash\",\n\t\"ls\",\n\t\"find\",\n\t\"grep\",\n\t\"powershell\",\n];\n\n/**\n * Builtin capability plugins associated with both suites. Declaration-only\n * data in M1a; the actual plugin wiring is delivered in M3. `builtin.memory`\n * joins in the 统一修复轮 A 路 (方案系统设计 §6.1: both suites share the same\n * memory tool surface; the strategy difference lives in the suiteId domain\n * isolation and the assistant preference card). `builtin.session-share` joins\n * in the session-share productization slice (开发计划 §216); its\n * target/gateway/viewerUrl are configured through the agent-dir config\n * channel (`<agentDir>/capabilities/builtin.session-share.json`), and the\n * unconfigured default answers `/share` with the explicit configuration\n * prompt — never an implicit Radius/Gist fallback. `builtin.workflow` joins\n * at goal/plan/todo-set parity (D-077, 2026-10-02: factory default install\n * plus this suite declaration, plugin form unchanged). `builtin.coding-tools`\n * joins with the D-082 batch-1 tool split (2026-10-03): the default coding\n * tools assemble from the `plugins/coding-tools` package through the bundled\n * distribution channel (插件独立分发与启动装配设计 §4.9), not the install\n * store.\n */\nexport const BUILTIN_SUITE_CAPABILITIES: readonly string[] = [\n\t\"builtin.goal\",\n\t\"builtin.plan\",\n\t\"builtin.todo-set\",\n\t\"builtin.workflow\",\n\t\"builtin.memory\",\n\t\"builtin.session-share\",\n\t\"builtin.subagent-delegate\",\n\t\"builtin.coding-tools\",\n];\n\nexport type SuiteMemoryStrategy = \"assistant\" | \"code\";\nexport type SuiteOrientation = \"assistant\" | \"coding\" | \"custom\";\n\n/**\n * Orientation persona texts injected into the system prompt (设计 §6.2, M2).\n * The strings are verbatim from the design spec: the assistant persona is the\n * companion style, the coding persona is the rigor-first style. Both are\n * session-nature declarations, so they ride every system prompt branch\n * (default and customPrompt). The custom orientation is not in this table: its\n * persona text comes from the suite workspace persona.md (设计 §6.3, resolved\n * by suite-loader).\n */\nexport const ORIENTATION_PROMPTS: Record<\"assistant\" | \"coding\", string> = {\n\tassistant: `You are the user's thoughtful companion — warm, patient, and helpful.\n- Understand the intent behind the question, including the unspoken parts; when something that matters is ambiguous, ask one short clarifying question instead of assuming.\n- Pay attention to detail: notice what the user might have missed and gently point it out.\n- Be proactive and divergent: after answering, offer next steps, related ideas, or creative alternatives — without being pushy.\n- Adapt tone to the user; stay natural and flexible, never robotic or formulaic.\n- When you can help by doing, act through tools autonomously (minimal interruption).\n- Structure longer answers clearly: short paragraphs, lists where they help, and a concrete \"what you can do next\" at the end.`,\n\tcoding: `You are an autonomous software engineering agent with a rigor-first mindset.\n- Never guess. Ground every claim in code you have read, commands you have run, or documented evidence; cite file paths and line numbers. If the evidence is insufficient, investigate, and report what is unverified — or \"unknown\" — instead of a plausible invention.\n- First principles: trace problems to the earliest reasonable root cause and fix that; do not patch symptoms.\n- No over-engineering: add no abstraction, options, or defensive handling for imagined future needs; generalise only when a second concrete case demands it.\n- Tests first: pin expected behavior with a failing or updated test before or alongside the fix, then run the smallest sufficient relevant checks; the work is not done until they pass.\n- Reproducible: prefer deterministic tests and mocks over ad-hoc verification, and report the exact commands and results so others can re-run them.\n- Docs as code: repository documentation is part of the change — keep design docs, READMEs, and changelogs consistent with the behavior they describe.\n- Self-review before finishing: re-check your changes for correctness, edge cases, regressions, and missing tests; prefer a second review pass over shipping the first draft.\n- Cautious: weigh side effects, compatibility, and failure modes; when in doubt, take the safer path.`,\n};\n\nexport interface SuiteAssociations {\n\treadonly skills: readonly string[];\n\treadonly mcp: readonly string[];\n\treadonly plugins: readonly string[];\n\t/**\n\t * 子代理角色关联(D-044 角色机制):关联的是 `<agentDir>/roles/<id>.json` 里的角色 id。\n\t * 角色定义只在磁盘上(工厂仅做种子落盘),方案只决定哪些角色对主代理可见——与\n\t * skill/MCP/插件同构,第一方与第三方角色没有区别。\n\t */\n\treadonly roles: readonly string[];\n}\n\nexport interface SuiteClonedFrom {\n\treadonly id: string;\n\treadonly digest: string;\n\treadonly at: number;\n}\n\n/** The serializable suite definition persisted as suite.json (设计 §5). */\nexport interface SuiteDefinition {\n\treadonly schemaVersion: number;\n\treadonly id: string;\n\treadonly name: string;\n\treadonly builtin: boolean;\n\treadonly tools: readonly string[];\n\treadonly capabilities: readonly string[];\n\treadonly associations: SuiteAssociations;\n\treadonly inheritSystemAgentsMd: boolean;\n\treadonly memory: SuiteMemoryStrategy;\n\treadonly orientation: SuiteOrientation;\n\treadonly model: string | null;\n\treadonly thinking: string | null;\n\treadonly clonedFrom: SuiteClonedFrom | null;\n\t/**\n\t * Factory contents revision this declaration was written at (M4). Builtin\n\t * declarations carry it; on-disk builtin suite.json may omit it (pre-M4\n\t * files parse as FACTORY_CONTENTS_VERSION). User suites are outside factory\n\t * upgrade governance: the key stays optional and may be absent.\n\t */\n\treadonly factoryRevision?: number;\n}\n\nconst EMPTY_ASSOCIATIONS: SuiteAssociations = { skills: [], mcp: [], plugins: [], roles: [] };\n\n/**\n * 默认方案关联的子代理角色(开箱即用):这四个 id 对应工厂种子落盘的四个普通角色文件\n * (`<agentDir>/roles/{explore,reviewer,design-proposer,visual-reviewer}.json`,用户可改可删)。\n * design-proposer / visual-reviewer 是视觉保底角色(2026-10-04 用户裁决\"术有专攻、角色隔离\"),\n * 档案 readonly + 只读工具收窄,与编码角色结构性隔离——见 docs/plans/视觉保底角色设计注记.md。\n * 工厂不在运行期回退到任何编译内的角色定义;删掉文件只会让该关联成为 dangling 诊断。\n */\nexport const DEFAULT_ROLE_ASSOCIATIONS: readonly string[] = [\n\t\"explore\",\n\t\"reviewer\",\n\t\"design-proposer\",\n\t\"visual-reviewer\",\n];\n\nconst assistantSuite: SuiteDefinition = {\n\tschemaVersion: SUITE_SCHEMA_VERSION,\n\tid: \"assistant\",\n\tname: \"Assistant\",\n\tbuiltin: true,\n\ttools: BUILTIN_SUITE_TOOLS,\n\tcapabilities: BUILTIN_SUITE_CAPABILITIES,\n\tassociations: { ...EMPTY_ASSOCIATIONS, roles: DEFAULT_ROLE_ASSOCIATIONS },\n\tinheritSystemAgentsMd: false,\n\tmemory: \"assistant\",\n\torientation: \"assistant\",\n\tmodel: null,\n\tthinking: null,\n\tclonedFrom: null,\n\tfactoryRevision: FACTORY_CONTENTS_VERSION,\n};\n\nconst codingSuite: SuiteDefinition = {\n\tschemaVersion: SUITE_SCHEMA_VERSION,\n\tid: \"coding\",\n\tname: \"Coding\",\n\tbuiltin: true,\n\ttools: BUILTIN_SUITE_TOOLS,\n\tcapabilities: BUILTIN_SUITE_CAPABILITIES,\n\tassociations: { ...EMPTY_ASSOCIATIONS, roles: DEFAULT_ROLE_ASSOCIATIONS },\n\tinheritSystemAgentsMd: false,\n\tmemory: \"code\",\n\torientation: \"coding\",\n\tmodel: null,\n\tthinking: null,\n\tclonedFrom: null,\n\tfactoryRevision: FACTORY_CONTENTS_VERSION,\n};\n\n/** The factory builtin pair: coding (factory default 尖刀) and assistant (fallback). */\nexport const BUILTIN_SUITES: readonly SuiteDefinition[] = [assistantSuite, codingSuite];\n\nexport function getBuiltinSuite(id: string): SuiteDefinition | undefined {\n\treturn BUILTIN_SUITES.find((suite) => suite.id === id);\n}\n\nexport function isBuiltinSuiteId(id: string): boolean {\n\treturn BUILTIN_SUITES.some((suite) => suite.id === id);\n}\n\nconst WINDOWS_RESERVED_IDS = new Set([\n\t\"con\",\n\t\"prn\",\n\t\"aux\",\n\t\"nul\",\n\t\"com1\",\n\t\"com2\",\n\t\"com3\",\n\t\"com4\",\n\t\"com5\",\n\t\"com6\",\n\t\"com7\",\n\t\"com8\",\n\t\"com9\",\n\t\"lpt1\",\n\t\"lpt2\",\n\t\"lpt3\",\n\t\"lpt4\",\n\t\"lpt5\",\n\t\"lpt6\",\n\t\"lpt7\",\n\t\"lpt8\",\n\t\"lpt9\",\n\t\"conin$\",\n\t\"conout$\",\n]);\n\n/** Suite id rule (设计 §9): `a-z0-9-`, no leading/trailing hyphen, no Windows reserved names. */\nexport function isValidSuiteId(id: string): boolean {\n\tif (id.length === 0 || id.length > SUITE_ID_MAX_LENGTH) return false;\n\tif (!/^[a-z0-9-]+$/.test(id)) return false;\n\tif (id.startsWith(\"-\") || id.endsWith(\"-\")) return false;\n\tif (WINDOWS_RESERVED_IDS.has(id)) return false;\n\treturn true;\n}\n\n/** Serializes a suite to the canonical suite.json text (stable field order, trailing newline). */\nexport function serializeSuiteJson(suite: SuiteDefinition): string {\n\tconst ordered = {\n\t\tschemaVersion: suite.schemaVersion,\n\t\tid: suite.id,\n\t\tname: suite.name,\n\t\tbuiltin: suite.builtin,\n\t\ttools: [...suite.tools],\n\t\tcapabilities: [...suite.capabilities],\n\t\tassociations: {\n\t\t\tskills: [...suite.associations.skills],\n\t\t\tmcp: [...suite.associations.mcp],\n\t\t\tplugins: [...suite.associations.plugins],\n\t\t\troles: [...suite.associations.roles],\n\t\t},\n\t\tinheritSystemAgentsMd: suite.inheritSystemAgentsMd,\n\t\tmemory: suite.memory,\n\t\torientation: suite.orientation,\n\t\tmodel: suite.model,\n\t\tthinking: suite.thinking,\n\t\tclonedFrom: suite.clonedFrom\n\t\t\t? { id: suite.clonedFrom.id, digest: suite.clonedFrom.digest, at: suite.clonedFrom.at }\n\t\t\t: null,\n\t\tfactoryRevision: suite.factoryRevision,\n\t};\n\treturn `${JSON.stringify(ordered, null, 2)}\\n`;\n}\n\nexport interface SuiteJsonParseResult {\n\treadonly valid: boolean;\n\treadonly suite?: SuiteDefinition;\n\treadonly errors: readonly string[];\n}\n\n/**\n * Parses suite.json text. Never throws: an invalid result carries every\n * validation error so callers can apply the corruption policy (设计 §9) —\n * builtin suites fall back to factory content, user suites fail fast.\n */\nexport function parseSuiteJson(\n\traw: string,\n\toptions: { expectedBuiltin?: boolean; expectedId?: string },\n): SuiteJsonParseResult {\n\tlet value: unknown;\n\ttry {\n\t\tvalue = JSON.parse(raw);\n\t} catch (error) {\n\t\treturn {\n\t\t\tvalid: false,\n\t\t\terrors: [`invalid JSON: ${error instanceof Error ? error.message : String(error)}`],\n\t\t};\n\t}\n\treturn validateSuiteJson(value, options);\n}\n\nexport function validateSuiteJson(\n\tvalue: unknown,\n\toptions: { expectedBuiltin?: boolean; expectedId?: string } = {},\n): SuiteJsonParseResult {\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n\t\treturn { valid: false, errors: [\"suite.json must be a JSON object\"] };\n\t}\n\tconst record = value as Record<string, unknown>;\n\tconst errors: string[] = [];\n\n\tif (record.schemaVersion !== SUITE_SCHEMA_VERSION) {\n\t\terrors.push(`schemaVersion must be ${SUITE_SCHEMA_VERSION}, found ${JSON.stringify(record.schemaVersion)}`);\n\t}\n\n\t// Each field keeps a typed local: valid values land here, invalid ones only\n\t// contribute errors. The suite below is constructed exclusively when\n\t// `errors` is empty, so the fallbacks/coercions at that point are dead.\n\tconst idValue = record.id;\n\tconst id = typeof idValue === \"string\" && isValidSuiteId(idValue) ? idValue : undefined;\n\tif (id === undefined) {\n\t\terrors.push(\n\t\t\t`id must be a suite id (^[a-z0-9-]+$, no leading/trailing hyphen, Windows reserved names rejected), found ${JSON.stringify(idValue)}`,\n\t\t);\n\t} else if (options.expectedId !== undefined && id !== options.expectedId) {\n\t\terrors.push(`id \"${id}\" does not match the suite workspace directory id \"${options.expectedId}\"`);\n\t}\n\n\tconst nameValue = record.name;\n\tconst name = typeof nameValue === \"string\" && nameValue.trim().length > 0 ? nameValue : undefined;\n\tif (name === undefined) {\n\t\terrors.push(`name must be a non-empty string, found ${JSON.stringify(nameValue)}`);\n\t}\n\n\tconst builtinValue = record.builtin;\n\tconst builtin = typeof builtinValue === \"boolean\" ? builtinValue : undefined;\n\tif (builtin === undefined) {\n\t\terrors.push(`builtin must be a boolean, found ${JSON.stringify(builtinValue)}`);\n\t} else if (options.expectedBuiltin === true && builtin !== true) {\n\t\terrors.push(`builtin must be true for a builtin suite workspace, found ${builtin}`);\n\t}\n\n\tconst tools = readStringArray(record, \"tools\", errors);\n\tconst capabilities = readStringArray(record, \"capabilities\", errors);\n\tconst associations = readAssociations(record.associations, errors);\n\n\tconst inheritValue = record.inheritSystemAgentsMd;\n\tconst inheritSystemAgentsMd = typeof inheritValue === \"boolean\" ? inheritValue : undefined;\n\tif (inheritSystemAgentsMd === undefined) {\n\t\terrors.push(`inheritSystemAgentsMd must be a boolean, found ${JSON.stringify(inheritValue)}`);\n\t}\n\n\tconst memoryValue = record.memory;\n\tconst memory = memoryValue === \"assistant\" || memoryValue === \"code\" ? memoryValue : undefined;\n\tif (memory === undefined) {\n\t\terrors.push(`memory must be \"assistant\" or \"code\", found ${JSON.stringify(memoryValue)}`);\n\t}\n\n\tconst orientationValue = record.orientation;\n\tconst orientation =\n\t\torientationValue === \"assistant\" || orientationValue === \"coding\" || orientationValue === \"custom\"\n\t\t\t? orientationValue\n\t\t\t: undefined;\n\tif (orientationValue !== undefined && orientation === undefined) {\n\t\terrors.push(`orientation must be \"assistant\", \"coding\", or \"custom\", found ${JSON.stringify(orientationValue)}`);\n\t}\n\n\tconst model = readOptionalString(record, \"model\", errors);\n\tconst thinking = readOptionalString(record, \"thinking\", errors);\n\tconst clonedFrom = readClonedFrom(record.clonedFrom, errors);\n\tconst factoryRevision = readFactoryRevision(record.factoryRevision, options.expectedBuiltin === true, errors);\n\n\tif (errors.length > 0) return { valid: false, errors };\n\n\treturn {\n\t\tvalid: true,\n\t\terrors: [],\n\t\tsuite: {\n\t\t\tschemaVersion: SUITE_SCHEMA_VERSION,\n\t\t\tid: id!,\n\t\t\tname: name!,\n\t\t\tbuiltin: builtin!,\n\t\t\ttools,\n\t\t\tcapabilities,\n\t\t\tassociations,\n\t\t\tinheritSystemAgentsMd: inheritSystemAgentsMd!,\n\t\t\tmemory: memory!,\n\t\t\torientation: orientation ?? \"assistant\",\n\t\t\tmodel,\n\t\t\tthinking,\n\t\t\tclonedFrom,\n\t\t\t...(factoryRevision === undefined ? {} : { factoryRevision }),\n\t\t},\n\t};\n}\n\nfunction readStringArray(record: Record<string, unknown>, key: string, errors: string[]): readonly string[] {\n\tconst value = record[key];\n\tif (!Array.isArray(value)) {\n\t\terrors.push(`${key} must be an array of strings, found ${JSON.stringify(value)}`);\n\t\treturn [];\n\t}\n\tconst entries: string[] = [];\n\tconst seen = new Set<string>();\n\tfor (const item of value) {\n\t\tif (typeof item !== \"string\" || item.trim().length === 0) {\n\t\t\terrors.push(`${key} entries must be non-empty strings, found ${JSON.stringify(item)}`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (seen.has(item)) {\n\t\t\terrors.push(`${key} contains duplicate entry \"${item}\"`);\n\t\t\tcontinue;\n\t\t}\n\t\tseen.add(item);\n\t\tentries.push(item);\n\t}\n\treturn entries;\n}\n\nfunction readAssociations(value: unknown, errors: string[]): SuiteAssociations {\n\tif (value === undefined) return { skills: [], mcp: [], plugins: [], roles: [] };\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n\t\terrors.push(\n\t\t\t`associations must be an object with skills/mcp/plugins/roles arrays, found ${JSON.stringify(value)}`,\n\t\t);\n\t\treturn { skills: [], mcp: [], plugins: [], roles: [] };\n\t}\n\tconst record = value as Record<string, unknown>;\n\t// A key left out entirely means an empty list, consistent with a fully\n\t// absent `associations` object; a key that is present but malformed still\n\t// reports its errors. The removed legacy `extensions` kind is ignored on\n\t// read (it lost its loader with the old ExtensionAPI surface).\n\treturn {\n\t\tskills: record.skills === undefined ? [] : readStringArray(record, \"skills\", errors),\n\t\tmcp: record.mcp === undefined ? [] : readStringArray(record, \"mcp\", errors),\n\t\tplugins: record.plugins === undefined ? [] : readStringArray(record, \"plugins\", errors),\n\t\troles: record.roles === undefined ? [] : readStringArray(record, \"roles\", errors),\n\t};\n}\n\nfunction readOptionalString(record: Record<string, unknown>, key: string, errors: string[]): string | null {\n\tconst value = record[key];\n\tif (value === undefined || value === null) return null;\n\tif (typeof value !== \"string\" || value.trim().length === 0) {\n\t\terrors.push(`${key} must be a non-empty string or null, found ${JSON.stringify(value)}`);\n\t\treturn null;\n\t}\n\treturn value;\n}\n\n/**\n * Reads the optional `factoryRevision` key (M4). A missing key means\n * FACTORY_CONTENTS_VERSION for builtin workspaces (pre-M4 on-disk files stay\n * compatible) and stays absent for user suites (outside factory upgrade\n * governance). A present key must be a positive integer.\n */\nfunction readFactoryRevision(value: unknown, expectedBuiltin: boolean, errors: string[]): number | undefined {\n\tif (value === undefined) return expectedBuiltin ? FACTORY_CONTENTS_VERSION : undefined;\n\tif (typeof value !== \"number\" || !Number.isSafeInteger(value) || value <= 0) {\n\t\terrors.push(`factoryRevision must be a positive integer, found ${JSON.stringify(value)}`);\n\t\treturn undefined;\n\t}\n\treturn value;\n}\n\nfunction readClonedFrom(value: unknown, errors: string[]): SuiteClonedFrom | null {\n\tif (value === undefined || value === null) return null;\n\tif (typeof value !== \"object\" || Array.isArray(value)) {\n\t\terrors.push(`clonedFrom must be an object with id/digest/at, found ${JSON.stringify(value)}`);\n\t\treturn null;\n\t}\n\tconst record = value as Record<string, unknown>;\n\tif (\n\t\ttypeof record.id !== \"string\" ||\n\t\trecord.id.trim().length === 0 ||\n\t\ttypeof record.digest !== \"string\" ||\n\t\trecord.digest.trim().length === 0 ||\n\t\ttypeof record.at !== \"number\" ||\n\t\t!Number.isSafeInteger(record.at)\n\t) {\n\t\terrors.push(\n\t\t\t`clonedFrom must be an object with non-empty id/digest strings and an integer at, found ${JSON.stringify(value)}`,\n\t\t);\n\t\treturn null;\n\t}\n\treturn { id: record.id, digest: record.digest, at: record.at };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"builtin-suites.js","sourceRoot":"","sources":["../../src/profiles/builtin-suites.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,CAAC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,KAAK,CAAC;QAC7B,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ;QACjC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;QACjC,OAAO,MAAM,CAAC,EAAE,KAAK,QAAQ;QAC7B,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,EAC/B,CAAC;QACF,MAAM,CAAC,IAAI,CACV,0FAA0F,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CACjH,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;AAAA,CAC/D","sourcesContent":["/**\n * Builtin suite (方案) declarations and suite.json (schemaVersion 1)\n * serialization, parsing, and validation — 方案系统设计.md v2 §5/§6/§9, M1a.\n *\n * Suites are pure data plus default policy: both builtin suites share the same\n * unrestricted tool surface and differ only in orientation and memory strategy\n * (the orientation persona text is injected into the system prompt, M2).\n * Nothing here touches the packages/agent kernel; association resolution is\n * declaration-only until M1b.\n */\n\nexport const SUITE_SCHEMA_VERSION = 1;\n\n/**\n * Factory contents revision (M4): the revision of the factory builtin\n * declarations, independent of SUITE_SCHEMA_VERSION. Bump it (and update both\n * builtin declarations' `factoryRevision`) whenever the factory contents\n * change; the registry upgrade proposal then offers `--suite-reset` for\n * workspaces still on an older revision. Suite schema evolution keeps using\n * SUITE_SCHEMA_VERSION.\n *\n * Revision 2 (统一修复轮集成收口, 2026-09-08): assistant and coding now share\n * the same active 8-tool surface in full-control — the sdk `suiteToolOverride`\n * DEFAULT_SUITE_ID exemption was removed (方案设计 §5 + user decision). Existing\n * workspaces provisioned at revision 1 receive the upgrade-proposal diagnostic\n * and adopt via `--suite-reset`.\n *\n * Revision 3 (2026-09-18): `builtin.session-share` joins both builtin suites\n * (开发计划 §216: session-share productized from the example plugin into a\n * first-party default-distributed capability) once the agent-dir config\n * channel for embedded capabilities landed\n * (`<agentDir>/capabilities/<short-id>.json`, see capabilities/builtin.ts).\n * Existing workspaces provisioned at revision 2 receive the upgrade-proposal\n * diagnostic and adopt via `--suite-reset`.\n *\n * Revision 4 (2026-09-18): `builtin.subagent-delegate` joins both builtin\n * suites — the first-party subagent delegation tool (`subagent_run`) now ships\n * by default in shared mode (zero extra processes; pooled runner processes stay\n * opt-in through the capability config channel). Existing workspaces\n * provisioned at revision 3 receive the upgrade-proposal diagnostic and adopt\n * via `--suite-reset`.\n *\n * Revision 5 (2026-09-20): subagent role profiles land on disk only\n * (`<agentDir>/roles/<id>.json` — the factory seeds explore/reviewer and never\n * overwrites user edits) and both builtin suites associate them by default via\n * the new `suite.associations.roles` field, with skill/MCP-isomorphic\n * visibility: unassociated roles stay invisible, associated-but-missing files\n * surface as dangling diagnostics. Existing workspaces provisioned at\n * revision 4 receive the upgrade-proposal diagnostic and adopt via\n * `--suite-reset`.\n *\n * Revision 6 (D-077, 2026-10-02): `builtin.workflow` joins both builtin suites\n * — the workflow orchestration plugin enters the factory bootstrap manifest\n * (ninth package) and the suite capability declaration at goal/plan/todo-set\n * parity, keeping its plugin form. Existing workspaces provisioned at revision\n * 5 receive the upgrade-proposal diagnostic and adopt via `--suite-reset`.\n *\n * Revision 7 (视觉保底, 2026-10-04): the two visual baseline roles\n * `design-proposer` / `visual-reviewer` join the factory seeds and the default\n * `associations.roles` (user ruling \"术有专攻、角色隔离\"; role files are\n * disk-only and the seeds never overwrite user edits — see\n * `docs/plans/视觉保底角色设计注记.md`). Existing workspaces provisioned at\n * revision 6 receive the upgrade-proposal diagnostic and adopt via\n * `--suite-reset`.\n */\nexport const FACTORY_CONTENTS_VERSION = 7;\n\n/**\n * Factory default suite used when no suite is configured anywhere (设计 §9).\n * 2026-10-02 user ruling: the product is a coding agent, so the factory\n * default flipped from \"assistant\" to \"coding\"; assistant stays as the\n * explicit-switch fallback suite.\n */\nexport const DEFAULT_SUITE_ID = \"coding\";\n\n/** Suite ids become directory names: lowercase letters, digits, hyphens (设计 §9). */\nexport const SUITE_ID_MAX_LENGTH = 64;\n\n/** The single unrestricted tool surface shared by both builtin suites (设计 §5/§6). */\nexport const BUILTIN_SUITE_TOOLS: readonly string[] = [\n\t\"read\",\n\t\"write\",\n\t\"edit\",\n\t\"bash\",\n\t\"ls\",\n\t\"find\",\n\t\"grep\",\n\t\"powershell\",\n];\n\n/**\n * Builtin capability plugins associated with both suites. Declaration-only\n * data in M1a; the actual plugin wiring is delivered in M3. `builtin.memory`\n * joins in the 统一修复轮 A 路 (方案系统设计 §6.1: both suites share the same\n * memory tool surface; the strategy difference lives in the suiteId domain\n * isolation and the assistant preference card). `builtin.session-share` joins\n * in the session-share productization slice (开发计划 §216); its\n * target/gateway/viewerUrl are configured through the agent-dir config\n * channel (`<agentDir>/capabilities/builtin.session-share.json`), and the\n * unconfigured default answers `/share` with the explicit configuration\n * prompt — never an implicit Radius/Gist fallback. `builtin.workflow` joins\n * at goal/plan/todo-set parity (D-077, 2026-10-02: factory default install\n * plus this suite declaration, plugin form unchanged). `builtin.coding-tools`\n * joins with the D-082 batch-1 tool split (2026-10-03): the default coding\n * tools assemble from the `plugins/coding-tools` package through the bundled\n * distribution channel (插件独立分发与启动装配设计 §4.9), not the install\n * store.\n */\nexport const BUILTIN_SUITE_CAPABILITIES: readonly string[] = [\n\t\"builtin.goal\",\n\t\"builtin.plan\",\n\t\"builtin.todo-set\",\n\t\"builtin.workflow\",\n\t\"builtin.memory\",\n\t\"builtin.session-share\",\n\t\"builtin.subagent-delegate\",\n\t\"builtin.coding-tools\",\n];\n\nexport type SuiteMemoryStrategy = \"assistant\" | \"code\";\nexport type SuiteOrientation = \"assistant\" | \"coding\" | \"custom\";\n\n/**\n * Orientation persona texts injected into the system prompt (设计 §6.2, M2).\n * The strings are verbatim from the design spec: the assistant persona is the\n * companion style, the coding persona is the rigor-first style. Both are\n * session-nature declarations, so they ride every system prompt branch\n * (default and customPrompt). The custom orientation is not in this table: its\n * persona text comes from the suite workspace persona.md (设计 §6.3, resolved\n * by suite-loader).\n */\nexport const ORIENTATION_PROMPTS: Record<\"assistant\" | \"coding\", string> = {\n\tassistant: `You are the user's thoughtful companion — warm, patient, and helpful.\n- Understand the intent behind the question, including the unspoken parts; when something that matters is ambiguous, ask one short clarifying question instead of assuming.\n- Pay attention to detail: notice what the user might have missed and gently point it out.\n- Be proactive and divergent: after answering, offer next steps, related ideas, or creative alternatives — without being pushy.\n- Adapt tone to the user; stay natural and flexible, never robotic or formulaic.\n- When you can help by doing, act through tools autonomously (minimal interruption).\n- Structure longer answers clearly: short paragraphs, lists where they help, and a concrete \"what you can do next\" at the end.`,\n\tcoding: `You are an autonomous software engineering agent with a rigor-first mindset.\n- Never guess. Ground every claim in code you have read, commands you have run, or documented evidence; cite file paths and line numbers. If the evidence is insufficient, investigate, and report what is unverified — or \"unknown\" — instead of a plausible invention.\n- First principles: trace problems to the earliest reasonable root cause and fix that; do not patch symptoms.\n- No over-engineering: add no abstraction, options, or defensive handling for imagined future needs; generalise only when a second concrete case demands it.\n- Tests first: pin expected behavior with a failing or updated test before or alongside the fix, then run the smallest sufficient relevant checks; the work is not done until they pass.\n- Reproducible: prefer deterministic tests and mocks over ad-hoc verification, and report the exact commands and results so others can re-run them.\n- Docs as code: repository documentation is part of the change — keep design docs, READMEs, and changelogs consistent with the behavior they describe.\n- Self-review before finishing: re-check your changes for correctness, edge cases, regressions, and missing tests; prefer a second review pass over shipping the first draft.\n- Cautious: weigh side effects, compatibility, and failure modes; when in doubt, take the safer path.`,\n};\n\nexport interface SuiteAssociations {\n\treadonly skills: readonly string[];\n\treadonly mcp: readonly string[];\n\treadonly plugins: readonly string[];\n\t/**\n\t * 子代理角色关联(D-044 角色机制):关联的是 `<agentDir>/roles/<id>.json` 里的角色 id。\n\t * 角色定义只在磁盘上(工厂仅做种子落盘),方案只决定哪些角色对主代理可见——与\n\t * skill/MCP/插件同构,第一方与第三方角色没有区别。\n\t */\n\treadonly roles: readonly string[];\n}\n\nexport interface SuiteClonedFrom {\n\treadonly id: string;\n\treadonly digest: string;\n\treadonly at: number;\n}\n\n/** The serializable suite definition persisted as suite.json (设计 §5). */\nexport interface SuiteDefinition {\n\treadonly schemaVersion: number;\n\treadonly id: string;\n\treadonly name: string;\n\treadonly builtin: boolean;\n\treadonly tools: readonly string[];\n\treadonly capabilities: readonly string[];\n\treadonly associations: SuiteAssociations;\n\treadonly inheritSystemAgentsMd: boolean;\n\treadonly memory: SuiteMemoryStrategy;\n\treadonly orientation: SuiteOrientation;\n\treadonly model: string | null;\n\treadonly thinking: string | null;\n\treadonly clonedFrom: SuiteClonedFrom | null;\n\t/**\n\t * Factory contents revision this declaration was written at (M4). Builtin\n\t * declarations carry it; on-disk builtin suite.json may omit it (pre-M4\n\t * files parse as FACTORY_CONTENTS_VERSION). User suites are outside factory\n\t * upgrade governance: the key stays optional and may be absent.\n\t */\n\treadonly factoryRevision?: number;\n}\n\nconst EMPTY_ASSOCIATIONS: SuiteAssociations = { skills: [], mcp: [], plugins: [], roles: [] };\n\n/**\n * 默认方案关联的子代理角色(开箱即用):这四个 id 对应工厂种子落盘的四个普通角色文件\n * (`<agentDir>/roles/{explore,reviewer,design-proposer,visual-reviewer}.json`,用户可改可删)。\n * design-proposer / visual-reviewer 是视觉保底角色(2026-10-04 用户裁决\"术有专攻、角色隔离\"),\n * 档案 readonly + 只读工具收窄,与编码角色结构性隔离——见 docs/plans/视觉保底角色设计注记.md。\n * 工厂不在运行期回退到任何编译内的角色定义;删掉文件只会让该关联成为 dangling 诊断。\n */\nexport const DEFAULT_ROLE_ASSOCIATIONS: readonly string[] = [\n\t\"explore\",\n\t\"reviewer\",\n\t\"design-proposer\",\n\t\"visual-reviewer\",\n];\n\nconst assistantSuite: SuiteDefinition = {\n\tschemaVersion: SUITE_SCHEMA_VERSION,\n\tid: \"assistant\",\n\tname: \"Assistant\",\n\tbuiltin: true,\n\ttools: BUILTIN_SUITE_TOOLS,\n\tcapabilities: BUILTIN_SUITE_CAPABILITIES,\n\tassociations: { ...EMPTY_ASSOCIATIONS, roles: DEFAULT_ROLE_ASSOCIATIONS },\n\tinheritSystemAgentsMd: false,\n\tmemory: \"assistant\",\n\torientation: \"assistant\",\n\tmodel: null,\n\tthinking: null,\n\tclonedFrom: null,\n\tfactoryRevision: FACTORY_CONTENTS_VERSION,\n};\n\nconst codingSuite: SuiteDefinition = {\n\tschemaVersion: SUITE_SCHEMA_VERSION,\n\tid: \"coding\",\n\tname: \"Coding\",\n\tbuiltin: true,\n\ttools: BUILTIN_SUITE_TOOLS,\n\tcapabilities: BUILTIN_SUITE_CAPABILITIES,\n\tassociations: { ...EMPTY_ASSOCIATIONS, roles: DEFAULT_ROLE_ASSOCIATIONS },\n\tinheritSystemAgentsMd: false,\n\tmemory: \"code\",\n\torientation: \"coding\",\n\tmodel: null,\n\tthinking: null,\n\tclonedFrom: null,\n\tfactoryRevision: FACTORY_CONTENTS_VERSION,\n};\n\n/** The factory builtin pair: coding (factory default 尖刀) and assistant (fallback). */\nexport const BUILTIN_SUITES: readonly SuiteDefinition[] = [assistantSuite, codingSuite];\n\nexport function getBuiltinSuite(id: string): SuiteDefinition | undefined {\n\treturn BUILTIN_SUITES.find((suite) => suite.id === id);\n}\n\nexport function isBuiltinSuiteId(id: string): boolean {\n\treturn BUILTIN_SUITES.some((suite) => suite.id === id);\n}\n\nconst WINDOWS_RESERVED_IDS = new Set([\n\t\"con\",\n\t\"prn\",\n\t\"aux\",\n\t\"nul\",\n\t\"com1\",\n\t\"com2\",\n\t\"com3\",\n\t\"com4\",\n\t\"com5\",\n\t\"com6\",\n\t\"com7\",\n\t\"com8\",\n\t\"com9\",\n\t\"lpt1\",\n\t\"lpt2\",\n\t\"lpt3\",\n\t\"lpt4\",\n\t\"lpt5\",\n\t\"lpt6\",\n\t\"lpt7\",\n\t\"lpt8\",\n\t\"lpt9\",\n\t\"conin$\",\n\t\"conout$\",\n]);\n\n/** Suite id rule (设计 §9): `a-z0-9-`, no leading/trailing hyphen, no Windows reserved names. */\nexport function isValidSuiteId(id: string): boolean {\n\tif (id.length === 0 || id.length > SUITE_ID_MAX_LENGTH) return false;\n\tif (!/^[a-z0-9-]+$/.test(id)) return false;\n\tif (id.startsWith(\"-\") || id.endsWith(\"-\")) return false;\n\tif (WINDOWS_RESERVED_IDS.has(id)) return false;\n\treturn true;\n}\n\n/** Serializes a suite to the canonical suite.json text (stable field order, trailing newline). */\nexport function serializeSuiteJson(suite: SuiteDefinition): string {\n\tconst ordered = {\n\t\tschemaVersion: suite.schemaVersion,\n\t\tid: suite.id,\n\t\tname: suite.name,\n\t\tbuiltin: suite.builtin,\n\t\ttools: [...suite.tools],\n\t\tcapabilities: [...suite.capabilities],\n\t\tassociations: {\n\t\t\tskills: [...suite.associations.skills],\n\t\t\tmcp: [...suite.associations.mcp],\n\t\t\tplugins: [...suite.associations.plugins],\n\t\t\troles: [...suite.associations.roles],\n\t\t},\n\t\tinheritSystemAgentsMd: suite.inheritSystemAgentsMd,\n\t\tmemory: suite.memory,\n\t\torientation: suite.orientation,\n\t\tmodel: suite.model,\n\t\tthinking: suite.thinking,\n\t\tclonedFrom: suite.clonedFrom\n\t\t\t? { id: suite.clonedFrom.id, digest: suite.clonedFrom.digest, at: suite.clonedFrom.at }\n\t\t\t: null,\n\t\tfactoryRevision: suite.factoryRevision,\n\t};\n\treturn `${JSON.stringify(ordered, null, 2)}\\n`;\n}\n\nexport interface SuiteJsonParseResult {\n\treadonly valid: boolean;\n\treadonly suite?: SuiteDefinition;\n\treadonly errors: readonly string[];\n}\n\n/**\n * Parses suite.json text. Never throws: an invalid result carries every\n * validation error so callers can apply the corruption policy (设计 §9) —\n * builtin suites fall back to factory content, user suites fail fast.\n */\nexport function parseSuiteJson(\n\traw: string,\n\toptions: { expectedBuiltin?: boolean; expectedId?: string },\n): SuiteJsonParseResult {\n\tlet value: unknown;\n\ttry {\n\t\tvalue = JSON.parse(raw);\n\t} catch (error) {\n\t\treturn {\n\t\t\tvalid: false,\n\t\t\terrors: [`invalid JSON: ${error instanceof Error ? error.message : String(error)}`],\n\t\t};\n\t}\n\treturn validateSuiteJson(value, options);\n}\n\nexport function validateSuiteJson(\n\tvalue: unknown,\n\toptions: { expectedBuiltin?: boolean; expectedId?: string } = {},\n): SuiteJsonParseResult {\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n\t\treturn { valid: false, errors: [\"suite.json must be a JSON object\"] };\n\t}\n\tconst record = value as Record<string, unknown>;\n\tconst errors: string[] = [];\n\n\tif (record.schemaVersion !== SUITE_SCHEMA_VERSION) {\n\t\terrors.push(`schemaVersion must be ${SUITE_SCHEMA_VERSION}, found ${JSON.stringify(record.schemaVersion)}`);\n\t}\n\n\t// Each field keeps a typed local: valid values land here, invalid ones only\n\t// contribute errors. The suite below is constructed exclusively when\n\t// `errors` is empty, so the fallbacks/coercions at that point are dead.\n\tconst idValue = record.id;\n\tconst id = typeof idValue === \"string\" && isValidSuiteId(idValue) ? idValue : undefined;\n\tif (id === undefined) {\n\t\terrors.push(\n\t\t\t`id must be a suite id (^[a-z0-9-]+$, no leading/trailing hyphen, Windows reserved names rejected), found ${JSON.stringify(idValue)}`,\n\t\t);\n\t} else if (options.expectedId !== undefined && id !== options.expectedId) {\n\t\terrors.push(`id \"${id}\" does not match the suite workspace directory id \"${options.expectedId}\"`);\n\t}\n\n\tconst nameValue = record.name;\n\tconst name = typeof nameValue === \"string\" && nameValue.trim().length > 0 ? nameValue : undefined;\n\tif (name === undefined) {\n\t\terrors.push(`name must be a non-empty string, found ${JSON.stringify(nameValue)}`);\n\t}\n\n\tconst builtinValue = record.builtin;\n\tconst builtin = typeof builtinValue === \"boolean\" ? builtinValue : undefined;\n\tif (builtin === undefined) {\n\t\terrors.push(`builtin must be a boolean, found ${JSON.stringify(builtinValue)}`);\n\t} else if (options.expectedBuiltin === true && builtin !== true) {\n\t\terrors.push(`builtin must be true for a builtin suite workspace, found ${builtin}`);\n\t}\n\n\tconst tools = readStringArray(record, \"tools\", errors);\n\tconst capabilities = readStringArray(record, \"capabilities\", errors);\n\tconst associations = readAssociations(record.associations, errors);\n\n\tconst inheritValue = record.inheritSystemAgentsMd;\n\tconst inheritSystemAgentsMd = typeof inheritValue === \"boolean\" ? inheritValue : undefined;\n\tif (inheritSystemAgentsMd === undefined) {\n\t\terrors.push(`inheritSystemAgentsMd must be a boolean, found ${JSON.stringify(inheritValue)}`);\n\t}\n\n\tconst memoryValue = record.memory;\n\tconst memory = memoryValue === \"assistant\" || memoryValue === \"code\" ? memoryValue : undefined;\n\tif (memory === undefined) {\n\t\terrors.push(`memory must be \"assistant\" or \"code\", found ${JSON.stringify(memoryValue)}`);\n\t}\n\n\tconst orientationValue = record.orientation;\n\tconst orientation =\n\t\torientationValue === \"assistant\" || orientationValue === \"coding\" || orientationValue === \"custom\"\n\t\t\t? orientationValue\n\t\t\t: undefined;\n\tif (orientationValue !== undefined && orientation === undefined) {\n\t\terrors.push(`orientation must be \"assistant\", \"coding\", or \"custom\", found ${JSON.stringify(orientationValue)}`);\n\t}\n\n\tconst model = readOptionalString(record, \"model\", errors);\n\tconst thinking = readOptionalString(record, \"thinking\", errors);\n\tconst clonedFrom = readClonedFrom(record.clonedFrom, errors);\n\tconst factoryRevision = readFactoryRevision(record.factoryRevision, options.expectedBuiltin === true, errors);\n\n\tif (errors.length > 0) return { valid: false, errors };\n\n\treturn {\n\t\tvalid: true,\n\t\terrors: [],\n\t\tsuite: {\n\t\t\tschemaVersion: SUITE_SCHEMA_VERSION,\n\t\t\tid: id!,\n\t\t\tname: name!,\n\t\t\tbuiltin: builtin!,\n\t\t\ttools,\n\t\t\tcapabilities,\n\t\t\tassociations,\n\t\t\tinheritSystemAgentsMd: inheritSystemAgentsMd!,\n\t\t\tmemory: memory!,\n\t\t\torientation: orientation ?? \"assistant\",\n\t\t\tmodel,\n\t\t\tthinking,\n\t\t\tclonedFrom,\n\t\t\t...(factoryRevision === undefined ? {} : { factoryRevision }),\n\t\t},\n\t};\n}\n\nfunction readStringArray(record: Record<string, unknown>, key: string, errors: string[]): readonly string[] {\n\tconst value = record[key];\n\tif (!Array.isArray(value)) {\n\t\terrors.push(`${key} must be an array of strings, found ${JSON.stringify(value)}`);\n\t\treturn [];\n\t}\n\tconst entries: string[] = [];\n\tconst seen = new Set<string>();\n\tfor (const item of value) {\n\t\tif (typeof item !== \"string\" || item.trim().length === 0) {\n\t\t\terrors.push(`${key} entries must be non-empty strings, found ${JSON.stringify(item)}`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (seen.has(item)) {\n\t\t\terrors.push(`${key} contains duplicate entry \"${item}\"`);\n\t\t\tcontinue;\n\t\t}\n\t\tseen.add(item);\n\t\tentries.push(item);\n\t}\n\treturn entries;\n}\n\nfunction readAssociations(value: unknown, errors: string[]): SuiteAssociations {\n\tif (value === undefined) return { skills: [], mcp: [], plugins: [], roles: [] };\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n\t\terrors.push(\n\t\t\t`associations must be an object with skills/mcp/plugins/roles arrays, found ${JSON.stringify(value)}`,\n\t\t);\n\t\treturn { skills: [], mcp: [], plugins: [], roles: [] };\n\t}\n\tconst record = value as Record<string, unknown>;\n\t// A key left out entirely means an empty list, consistent with a fully\n\t// absent `associations` object; a key that is present but malformed still\n\t// reports its errors. The removed legacy `extensions` kind is ignored on\n\t// read (it lost its loader with the old ExtensionAPI surface).\n\treturn {\n\t\tskills: record.skills === undefined ? [] : readStringArray(record, \"skills\", errors),\n\t\tmcp: record.mcp === undefined ? [] : readStringArray(record, \"mcp\", errors),\n\t\tplugins: record.plugins === undefined ? [] : readStringArray(record, \"plugins\", errors),\n\t\troles: record.roles === undefined ? [] : readStringArray(record, \"roles\", errors),\n\t};\n}\n\nfunction readOptionalString(record: Record<string, unknown>, key: string, errors: string[]): string | null {\n\tconst value = record[key];\n\tif (value === undefined || value === null) return null;\n\tif (typeof value !== \"string\" || value.trim().length === 0) {\n\t\terrors.push(`${key} must be a non-empty string or null, found ${JSON.stringify(value)}`);\n\t\treturn null;\n\t}\n\treturn value;\n}\n\n/**\n * Reads the optional `factoryRevision` key (M4). A missing key means\n * FACTORY_CONTENTS_VERSION for builtin workspaces (pre-M4 on-disk files stay\n * compatible) and stays absent for user suites (outside factory upgrade\n * governance). A present key must be a positive integer.\n */\nfunction readFactoryRevision(value: unknown, expectedBuiltin: boolean, errors: string[]): number | undefined {\n\tif (value === undefined) return expectedBuiltin ? FACTORY_CONTENTS_VERSION : undefined;\n\tif (typeof value !== \"number\" || !Number.isSafeInteger(value) || value <= 0) {\n\t\terrors.push(`factoryRevision must be a positive integer, found ${JSON.stringify(value)}`);\n\t\treturn undefined;\n\t}\n\treturn value;\n}\n\nfunction readClonedFrom(value: unknown, errors: string[]): SuiteClonedFrom | null {\n\tif (value === undefined || value === null) return null;\n\tif (typeof value !== \"object\" || Array.isArray(value)) {\n\t\terrors.push(`clonedFrom must be an object with id/digest/at, found ${JSON.stringify(value)}`);\n\t\treturn null;\n\t}\n\tconst record = value as Record<string, unknown>;\n\tif (\n\t\ttypeof record.id !== \"string\" ||\n\t\trecord.id.trim().length === 0 ||\n\t\ttypeof record.digest !== \"string\" ||\n\t\trecord.digest.trim().length === 0 ||\n\t\ttypeof record.at !== \"number\" ||\n\t\t!Number.isSafeInteger(record.at)\n\t) {\n\t\terrors.push(\n\t\t\t`clonedFrom must be an object with non-empty id/digest strings and an integer at, found ${JSON.stringify(value)}`,\n\t\t);\n\t\treturn null;\n\t}\n\treturn { id: record.id, digest: record.digest, at: record.at };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolved-agent-profile.d.ts","sourceRoot":"","sources":["../../src/profiles/resolved-agent-profile.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAA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AAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACnD,CAAC;AAEL,yFAAyF;AACzF,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,6FAA6F;IAC7F,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,mHAAmH;IACnH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,yBAAyB,CAAC;IACtD,2FAA2F;IAC3F,QAAQ,CAAC,aAAa,EAAE,gCAAgC,CAAC;IACzD,wEAAwE;IACxE,QAAQ,CAAC,SAAS,EAAE;QACnB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;QAC/B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,EAAE,SAAS,2BAA2B,EAAE,CAAC;CAC7D;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,cAAc,CAAC;IAC1B,aAAa,CAAC,EAAE,gCAAgC,CAAC;CACjD,GAAG,sBAAsB,CAkDzB","sourcesContent":["/**\n * ResolvedAgentProfile (D-047 S4a, docs/plans/G4-resolved-agent-profile设计注记.md):\n * the immutable per-session aggregate view over the resolved suite profile.\n *\n * S4d first increment: the aggregate additionally carries a build-time\n * `diagnostics` snapshot projected from SuiteWorkspace.diagnostics and the\n * resolved plugin profile's ProfileResolutionV1.diagnostics; the existing five\n * diagnostic channels are untouched and remain the live sources.\n *\n * This is an aggregate VIEW, not a new generation mechanism: every field\n * references an existing authoritative source (字段-权威映射 in the design\n * note), resolution still happens at the existing single point\n * (createAgentSession's suite+pluginProfile assembly, once per session), and\n * the builder only re-projects those sources and deep-freezes the result. The\n * aggregate lives at the resolution layer (session creation result and host\n * references); `AgentSession` stays suite-unaware — it never enters\n * AgentSessionConfig, and the session's persisted identity authority remains\n * the suite custom entry.\n */\nimport { detachedSnapshot } from \"../core/extensions/capability-runtime-snapshot.ts\";\nimport type { PluginDiagnosticCodeV1 } from \"../plugins/ecosystem/types.ts\";\nimport type { ProfileIdentityV1 } from \"../profile/identity.ts\";\nimport type { ProfileLockVerificationV1 } from \"../profile/lock.ts\";\nimport type { BuiltinPluginProfileResolutionV1 } from \"../profile/plugin-profiles.ts\";\nimport type { SuiteWorkspace } from \"./suite-loader.ts\";\n\n/**\n * Bounded summary of the builtin plugin profile resolution: the `resolved`\n * variant carries id/version/digest/pluginIds; every other variant records the\n * variant name with its structured reason fields; an absent resolution is the\n * `none` variant. The full resolution objects stay with their existing\n * channels; the aggregate carries only this bounded projection.\n */\nexport type PluginProfileResolutionSummaryV1 =\n\t| {\n\t\t\treadonly variant: \"resolved\";\n\t\t\treadonly profileId: string;\n\t\t\treadonly profileVersion: string;\n\t\t\t/** Ecosystem resolved-manifests digest (suite-domain digest lives on `identity`). */\n\t\t\treadonly manifestDigest: string;\n\t\t\treadonly pluginIds: readonly string[];\n\t }\n\t| { readonly variant: \"not_found\"; readonly profileId: string }\n\t| { readonly variant: \"host_facts_required\"; readonly profileId: string }\n\t| {\n\t\t\treadonly variant: \"invalid_selection\";\n\t\t\treadonly profileId: string;\n\t\t\treadonly unknownPluginIds: readonly string[];\n\t\t\treadonly duplicatePluginIds: readonly string[];\n\t }\n\t| { readonly variant: \"none\" };\n\n/**\n * Unified diagnostic entry (D-047 S4d): each source keeps its own fidelity\n * behind a `source` tag — suite diagnostics are plain strings, plugin-profile\n * diagnostics keep their structured code/details. No lossy normalization.\n */\nexport type ResolvedProfileDiagnosticV1 =\n\t| { readonly source: \"suite\"; readonly message: string }\n\t| {\n\t\t\treadonly source: \"plugin-profile\";\n\t\t\treadonly code: PluginDiagnosticCodeV1;\n\t\t\treadonly message: string;\n\t\t\treadonly details?: Readonly<Record<string, string>>;\n\t };\n\n/** The immutable, deep-frozen aggregate view of one session's resolved suite profile. */\nexport interface ResolvedAgentProfileV1 {\n\treadonly suiteId: string;\n\t/** Authoritative: workspace.identity (buildSuiteProfileIdentity product, already frozen). */\n\treadonly identity: ProfileIdentityV1;\n\t/** Authoritative: the verifyProfileLock three-state result; undefined when the workspace had no persisted lock. */\n\treadonly lockVerification?: ProfileLockVerificationV1;\n\t/** Bounded summary of the plugin profile resolution; never the live resolution objects. */\n\treadonly pluginProfile: PluginProfileResolutionSummaryV1;\n\t/** Bounded path projection of the suite workspace (no live objects). */\n\treadonly workspace: {\n\t\treadonly suiteDir: string;\n\t\treadonly suiteJsonPath: string;\n\t\treadonly agentsMdPath: string;\n\t\treadonly lockPath: string;\n\t};\n\t/**\n\t * Build-time diagnostic snapshot (D-047 S4d first increment): workspace\n\t * diagnostics (suite source, in order) followed by the resolved plugin\n\t * profile's diagnostics (plugin-profile source, in order). Empty when\n\t * neither source contributed — the common no-diagnostics case.\n\t */\n\treadonly diagnostics: readonly ResolvedProfileDiagnosticV1[];\n}\n\n/**\n * Builds the deep-frozen ResolvedAgentProfileV1 from the existing\n * authoritative sources. Pure function: it assembles from `input` and returns\n * a detached (deep-cloned, recursively frozen) snapshot, so later mutation of\n * the sources can never flow into the aggregate.\n */\nexport function buildResolvedAgentProfileV1(input: {\n\tsuiteId: string;\n\tworkspace: SuiteWorkspace;\n\tpluginProfile?: BuiltinPluginProfileResolutionV1;\n}): ResolvedAgentProfileV1 {\n\tconst { workspace } = input;\n\tconst pluginProfile = input.pluginProfile;\n\tconst summary: PluginProfileResolutionSummaryV1 =\n\t\tpluginProfile === undefined\n\t\t\t? { variant: \"none\" }\n\t\t\t: pluginProfile.status === \"resolved\"\n\t\t\t\t? {\n\t\t\t\t\t\tvariant: \"resolved\",\n\t\t\t\t\t\tprofileId: pluginProfile.profile.id,\n\t\t\t\t\t\tprofileVersion: pluginProfile.profile.version,\n\t\t\t\t\t\tmanifestDigest: pluginProfile.resolution.resolvedManifest.manifestDigest,\n\t\t\t\t\t\tpluginIds: pluginProfile.resolution.resolvedManifest.plugins.map((plugin) => plugin.pluginId),\n\t\t\t\t\t}\n\t\t\t\t: pluginProfile.status === \"invalid_selection\"\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tvariant: \"invalid_selection\",\n\t\t\t\t\t\t\tprofileId: pluginProfile.profileId,\n\t\t\t\t\t\t\tunknownPluginIds: [...pluginProfile.unknownPluginIds],\n\t\t\t\t\t\t\tduplicatePluginIds: [...pluginProfile.duplicatePluginIds],\n\t\t\t\t\t\t}\n\t\t\t\t\t: pluginProfile.status === \"not_found\"\n\t\t\t\t\t\t? { variant: \"not_found\", profileId: pluginProfile.profileId }\n\t\t\t\t\t\t: { variant: \"host_facts_required\", profileId: pluginProfile.profileId };\n\tconst diagnostics: ResolvedProfileDiagnosticV1[] = [\n\t\t...workspace.diagnostics.map((message): ResolvedProfileDiagnosticV1 => ({ source: \"suite\", message })),\n\t\t...(pluginProfile?.status === \"resolved\"\n\t\t\t? pluginProfile.resolution.diagnostics.map(\n\t\t\t\t\t(diagnostic): ResolvedProfileDiagnosticV1 => ({\n\t\t\t\t\t\tsource: \"plugin-profile\",\n\t\t\t\t\t\tcode: diagnostic.code,\n\t\t\t\t\t\tmessage: diagnostic.message,\n\t\t\t\t\t\t...(diagnostic.details === undefined ? {} : { details: diagnostic.details }),\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t: []),\n\t];\n\treturn detachedSnapshot({\n\t\tsuiteId: input.suiteId,\n\t\tidentity: workspace.identity,\n\t\t...(workspace.lockVerification === undefined ? {} : { lockVerification: workspace.lockVerification }),\n\t\tpluginProfile: summary,\n\t\tworkspace: {\n\t\t\tsuiteDir: workspace.suiteDir,\n\t\t\tsuiteJsonPath: workspace.suiteJsonPath,\n\t\t\tagentsMdPath: workspace.agentsMdPath,\n\t\t\tlockPath: workspace.lockPath,\n\t\t},\n\t\tdiagnostics,\n\t});\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolved-agent-profile.js","sourceRoot":"","sources":["../../src/profiles/resolved-agent-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAC;AAwErF;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CAAC,KAI3C,EAA0B;IAC1B,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IAC5B,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC;IAC1C,MAAM,OAAO,GACZ,aAAa,KAAK,SAAS;QAC1B,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE;QACrB,CAAC,CAAC,aAAa,CAAC,MAAM,KAAK,UAAU;YACpC,CAAC,CAAC;gBACA,OAAO,EAAE,UAAU;gBACnB,SAAS,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE;gBACnC,cAAc,EAAE,aAAa,CAAC,OAAO,CAAC,OAAO;gBAC7C,cAAc,EAAE,aAAa,CAAC,UAAU,CAAC,gBAAgB,CAAC,cAAc;gBACxE,SAAS,EAAE,aAAa,CAAC,UAAU,CAAC,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC;aAC7F;YACF,CAAC,CAAC,aAAa,CAAC,MAAM,KAAK,mBAAmB;gBAC7C,CAAC,CAAC;oBACA,OAAO,EAAE,mBAAmB;oBAC5B,SAAS,EAAE,aAAa,CAAC,SAAS;oBAClC,gBAAgB,EAAE,CAAC,GAAG,aAAa,CAAC,gBAAgB,CAAC;oBACrD,kBAAkB,EAAE,CAAC,GAAG,aAAa,CAAC,kBAAkB,CAAC;iBACzD;gBACF,CAAC,CAAC,aAAa,CAAC,MAAM,KAAK,WAAW;oBACrC,CAAC,CAAC,EAAE,OAAO,EAAE,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AC;AAAA,CACH","sourcesContent":["/**\n * ResolvedAgentProfile (D-047 S4a, docs/plans/G4-resolved-agent-profile设计注记.md):\n * the immutable per-session aggregate view over the resolved suite profile.\n *\n * S4d first increment: the aggregate additionally carries a build-time\n * `diagnostics` snapshot projected from SuiteWorkspace.diagnostics and the\n * resolved plugin profile's ProfileResolutionV1.diagnostics; the existing five\n * diagnostic channels are untouched and remain the live sources.\n *\n * This is an aggregate VIEW, not a new generation mechanism: every field\n * references an existing authoritative source (字段-权威映射 in the design\n * note), resolution still happens at the existing single point\n * (createAgentSession's suite+pluginProfile assembly, once per session), and\n * the builder only re-projects those sources and deep-freezes the result. The\n * aggregate lives at the resolution layer (session creation result and host\n * references); `AgentSession` stays suite-unaware — it never enters\n * AgentSessionConfig, and the session's persisted identity authority remains\n * the suite custom entry.\n */\nimport { detachedSnapshot } from \"../core/extensions/capability-runtime-snapshot.ts\";\nimport type { PluginDiagnosticCodeV1 } from \"../plugins/ecosystem/types.ts\";\nimport type { ProfileIdentityV1 } from \"../profile/identity.ts\";\nimport type { ProfileLockVerificationV1 } from \"../profile/lock.ts\";\nimport type { BuiltinPluginProfileResolutionV1 } from \"../profile/plugin-profiles.ts\";\nimport type { SuiteWorkspace } from \"./suite-loader.ts\";\n\n/**\n * Bounded summary of the builtin plugin profile resolution: the `resolved`\n * variant carries id/version/digest/pluginIds; every other variant records the\n * variant name with its structured reason fields; an absent resolution is the\n * `none` variant. The full resolution objects stay with their existing\n * channels; the aggregate carries only this bounded projection.\n */\nexport type PluginProfileResolutionSummaryV1 =\n\t| {\n\t\t\treadonly variant: \"resolved\";\n\t\t\treadonly profileId: string;\n\t\t\treadonly profileVersion: string;\n\t\t\t/** Ecosystem resolved-manifests digest (suite-domain digest lives on `identity`). */\n\t\t\treadonly manifestDigest: string;\n\t\t\treadonly pluginIds: readonly string[];\n\t }\n\t| { readonly variant: \"not_found\"; readonly profileId: string }\n\t| { readonly variant: \"host_facts_required\"; readonly profileId: string }\n\t| {\n\t\t\treadonly variant: \"invalid_selection\";\n\t\t\treadonly profileId: string;\n\t\t\treadonly unknownPluginIds: readonly string[];\n\t\t\treadonly duplicatePluginIds: readonly string[];\n\t }\n\t| { readonly variant: \"none\" };\n\n/**\n * Unified diagnostic entry (D-047 S4d): each source keeps its own fidelity\n * behind a `source` tag — suite diagnostics are plain strings, plugin-profile\n * diagnostics keep their structured code/details. No lossy normalization.\n */\nexport type ResolvedProfileDiagnosticV1 =\n\t| { readonly source: \"suite\"; readonly message: string }\n\t| {\n\t\t\treadonly source: \"plugin-profile\";\n\t\t\treadonly code: PluginDiagnosticCodeV1;\n\t\t\treadonly message: string;\n\t\t\treadonly details?: Readonly<Record<string, string>>;\n\t };\n\n/** The immutable, deep-frozen aggregate view of one session's resolved suite profile. */\nexport interface ResolvedAgentProfileV1 {\n\treadonly suiteId: string;\n\t/** Authoritative: workspace.identity (buildSuiteProfileIdentity product, already frozen). */\n\treadonly identity: ProfileIdentityV1;\n\t/** Authoritative: the verifyProfileLock three-state result; undefined when the workspace had no persisted lock. */\n\treadonly lockVerification?: ProfileLockVerificationV1;\n\t/** Bounded summary of the plugin profile resolution; never the live resolution objects. */\n\treadonly pluginProfile: PluginProfileResolutionSummaryV1;\n\t/** Bounded path projection of the suite workspace (no live objects). */\n\treadonly workspace: {\n\t\treadonly suiteDir: string;\n\t\treadonly suiteJsonPath: string;\n\t\treadonly agentsMdPath: string;\n\t\treadonly lockPath: string;\n\t};\n\t/**\n\t * Build-time diagnostic snapshot (D-047 S4d first increment): workspace\n\t * diagnostics (suite source, in order) followed by the resolved plugin\n\t * profile's diagnostics (plugin-profile source, in order). Empty when\n\t * neither source contributed — the common no-diagnostics case.\n\t */\n\treadonly diagnostics: readonly ResolvedProfileDiagnosticV1[];\n}\n\n/**\n * Builds the deep-frozen ResolvedAgentProfileV1 from the existing\n * authoritative sources. Pure function: it assembles from `input` and returns\n * a detached (deep-cloned, recursively frozen) snapshot, so later mutation of\n * the sources can never flow into the aggregate.\n */\nexport function buildResolvedAgentProfileV1(input: {\n\tsuiteId: string;\n\tworkspace: SuiteWorkspace;\n\tpluginProfile?: BuiltinPluginProfileResolutionV1;\n}): ResolvedAgentProfileV1 {\n\tconst { workspace } = input;\n\tconst pluginProfile = input.pluginProfile;\n\tconst summary: PluginProfileResolutionSummaryV1 =\n\t\tpluginProfile === undefined\n\t\t\t? { variant: \"none\" }\n\t\t\t: pluginProfile.status === \"resolved\"\n\t\t\t\t? {\n\t\t\t\t\t\tvariant: \"resolved\",\n\t\t\t\t\t\tprofileId: pluginProfile.profile.id,\n\t\t\t\t\t\tprofileVersion: pluginProfile.profile.version,\n\t\t\t\t\t\tmanifestDigest: pluginProfile.resolution.resolvedManifest.manifestDigest,\n\t\t\t\t\t\tpluginIds: pluginProfile.resolution.resolvedManifest.plugins.map((plugin) => plugin.pluginId),\n\t\t\t\t\t}\n\t\t\t\t: pluginProfile.status === \"invalid_selection\"\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tvariant: \"invalid_selection\",\n\t\t\t\t\t\t\tprofileId: pluginProfile.profileId,\n\t\t\t\t\t\t\tunknownPluginIds: [...pluginProfile.unknownPluginIds],\n\t\t\t\t\t\t\tduplicatePluginIds: [...pluginProfile.duplicatePluginIds],\n\t\t\t\t\t\t}\n\t\t\t\t\t: pluginProfile.status === \"not_found\"\n\t\t\t\t\t\t? { variant: \"not_found\", profileId: pluginProfile.profileId }\n\t\t\t\t\t\t: { variant: \"host_facts_required\", profileId: pluginProfile.profileId };\n\tconst diagnostics: ResolvedProfileDiagnosticV1[] = [\n\t\t...workspace.diagnostics.map((message): ResolvedProfileDiagnosticV1 => ({ source: \"suite\", message })),\n\t\t...(pluginProfile?.status === \"resolved\"\n\t\t\t? pluginProfile.resolution.diagnostics.map(\n\t\t\t\t\t(diagnostic): ResolvedProfileDiagnosticV1 => ({\n\t\t\t\t\t\tsource: \"plugin-profile\",\n\t\t\t\t\t\tcode: diagnostic.code,\n\t\t\t\t\t\tmessage: diagnostic.message,\n\t\t\t\t\t\t...(diagnostic.details === undefined ? {} : { details: diagnostic.details }),\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t: []),\n\t];\n\treturn detachedSnapshot({\n\t\tsuiteId: input.suiteId,\n\t\tidentity: workspace.identity,\n\t\t...(workspace.lockVerification === undefined ? {} : { lockVerification: workspace.lockVerification }),\n\t\tpluginProfile: summary,\n\t\tworkspace: {\n\t\t\tsuiteDir: workspace.suiteDir,\n\t\t\tsuiteJsonPath: workspace.suiteJsonPath,\n\t\t\tagentsMdPath: workspace.agentsMdPath,\n\t\t\tlockPath: workspace.lockPath,\n\t\t},\n\t\tdiagnostics,\n\t});\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"suite-lifecycle.d.ts","sourceRoot":"","sources":["../../src/profiles/suite-lifecycle.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD,OAAO,EASN,KAAK,eAAe,EAEpB,MAAM,qBAAqB,CAAC;AAiB7B,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAC7C,gEAAgE;AAChE,eAAO,MAAM,gCAAgC,QAA0B,CAAC;AACxE;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,iBAAiB,CAAC;AACzD,gFAAgF;AAChF,eAAO,MAAM,yBAAyB,gBAAgB,CAAC;AAEvD,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEpE,2EAA2E;AAC3E,qBAAa,mBAAoB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,SAAS,EAAE,uBAAuB,CAAC;IAC5C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAEpC,YAAY,SAAS,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,EAAE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,CAAC;IAC1B,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;;;;;;OAQG;IACH,KAAK,IAAI,qBAAqB,CAAC;CAC/B;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAAE,GAAG,cAAc,CA4FxG;AAMD,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,aAAa,EAAE,SAAS,CAAC,SAAS,GAAG,QAAQ,CAAC,EAAE,CAAC;CAC1D;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,eAAe,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,GAAG,oBAAoB,CAW7G","sourcesContent":["/**\n * Suite lifecycle operations (方案系统设计.md v2 §9, M4): create/clone,\n * delete (trash + release + sweep), reset, session reference scan, and\n * dangling settings cleanup.\n *\n * Every operation is deterministic given its inputs (`now` is injectable) and\n * reports refusal reasons as structured errors. Deletion only ever renames\n * the workspace into the trash directory — release and sweep are separate,\n * re-runnable steps — so recovery stays possible until the trash is released.\n * Memory purge is intentionally a hook: the Foundation purge gate lands with\n * M5; before that only suite assets are released.\n */\nimport { randomUUID } from \"node:crypto\";\nimport {\n\tcloseSync,\n\tcpSync,\n\texistsSync,\n\tmkdirSync,\n\topenSync,\n\treaddirSync,\n\treadFileSync,\n\treadSync,\n\trenameSync,\n\tstatSync,\n\twriteFileSync,\n} from \"node:fs\";\nimport { readdir, rm, stat } from \"node:fs/promises\";\nimport { basename, join } from \"node:path\";\nimport { StringDecoder } from \"node:string_decoder\";\nimport type { SettingsManager } from \"../core/settings-manager.ts\";\nimport { generateDiffString } from \"../core/tools/edit-diff.ts\";\nimport type { ProfileLockV1 } from \"../profile/lock.ts\";\nimport { createProfileLock, replaceProfileLock } from \"../profile/lock.ts\";\nimport { createProfileMigrationPolicy } from \"../profile/profile-migration.ts\";\nimport {\n\tBUILTIN_SUITE_CAPABILITIES,\n\tBUILTIN_SUITE_TOOLS,\n\tDEFAULT_ROLE_ASSOCIATIONS,\n\tFACTORY_CONTENTS_VERSION,\n\tgetBuiltinSuite,\n\tisBuiltinSuiteId,\n\tisValidSuiteId,\n\tSUITE_SCHEMA_VERSION,\n\ttype SuiteDefinition,\n\tserializeSuiteJson,\n} from \"./builtin-suites.ts\";\nimport {\n\tbuildSuiteProfileIdentity,\n\tgetSuitesRootDir,\n\tgetSuiteWorkspaceDir,\n\tloadSuiteWorkspace,\n\tparseSuiteProfileLockFile,\n\tSUITE_AGENTS_MD_FILENAME,\n\tSUITE_LOCK_FILENAME,\n\tSUITE_MANIFEST_FILENAME,\n\tSUITE_SESSION_ENTRY_TYPE,\n\tSuiteResolutionError,\n\ttype SuiteWorkspace,\n\tserializeSuiteProfileLockFile,\n\tsuiteManifestDigest,\n} from \"./suite-loader.ts\";\n\nexport const SUITE_TRASH_DIR_NAME = \".trash\";\n/** Trash retention for sweepSuiteTrash (M4 decision record). */\nexport const DEFAULT_SUITE_TRASH_RETENTION_MS = 7 * 24 * 60 * 60 * 1000;\n/**\n * Explicit programmatic authorization token for deleteSuite. The CLI confirms\n * interactively before calling; programmatic callers pass this token to prove\n * intent. Absent keeps the CLI-first flow working.\n */\nexport const SUITE_DELETE_CONFIRM_TOKEN = \"suite-delete\";\n/** lockedBy/authorizedBy stamped onto locks created by --suite-reset (2.7b). */\nexport const SUITE_RESET_AUTHORIZED_BY = \"suite-reset\";\n\nexport type SuiteLifecycleOperation = \"create\" | \"delete\" | \"reset\";\n\n/** Structured lifecycle refusal: operation, suite id, and every reason. */\nexport class SuiteLifecycleError extends Error {\n\treadonly operation: SuiteLifecycleOperation;\n\treadonly suiteId: string;\n\treadonly reasons: readonly string[];\n\n\tconstructor(operation: SuiteLifecycleOperation, suiteId: string, reasons: readonly string[]) {\n\t\tsuper(`Suite ${operation} failed for \"${suiteId}\": ${reasons.join(\"; \")}`);\n\t\tthis.name = \"SuiteLifecycleError\";\n\t\tthis.operation = operation;\n\t\tthis.suiteId = suiteId;\n\t\tthis.reasons = Object.freeze([...reasons]);\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Create / clone (设计 §9 创建)\n// ---------------------------------------------------------------------------\n\nexport interface SuiteCreateOptions {\n\treadonly agentDir: string;\n\treadonly id: string;\n\t/** Clone an existing suite workspace (builtin or user) instead of a fresh skeleton. */\n\treadonly cloneFrom?: string;\n\t/** Display name; defaults to the id (fresh) or \"<source name> clone\" (cloned). */\n\treadonly name?: string;\n\t/** Injectable clock for the clonedFrom timestamp. */\n\treadonly now?: () => number;\n}\n\nexport interface SuiteCreateResult {\n\treadonly suiteId: string;\n\treadonly suiteDir: string;\n\treadonly suiteJsonPath: string;\n\treadonly definition: SuiteDefinition;\n}\n\n/**\n * Creates a user suite workspace (设计 §9): `<agentDir>/suites/<id>/` with a\n * suite.json plus an empty agents.md skeleton, or — with `cloneFrom` — a copy\n * of the source workspace (effective definition, so a corrupted builtin\n * source clones its factory content) with the suite.json identity rewritten:\n * new id, `builtin: false`, and a `clonedFrom` record carrying the source id\n * and the digest of the source's effective suite.json value. The source's\n * `.profile-lock.json` is never copied: the clone is a new profile identity\n * whose lock is created on first assembly.\n */\nexport function createSuite(options: SuiteCreateOptions): SuiteCreateResult {\n\tconst { agentDir, id } = options;\n\tconst suiteDir = getSuiteWorkspaceDir(agentDir, id);\n\tconst suiteJsonPath = join(suiteDir, SUITE_MANIFEST_FILENAME);\n\n\tconst reasons: string[] = [];\n\tif (!isValidSuiteId(id)) {\n\t\treasons.push(\n\t\t\t`id must be a suite id (^[a-z0-9-]+$, no leading/trailing hyphen, Windows reserved names rejected), found ${JSON.stringify(id)}`,\n\t\t);\n\t}\n\tif (isBuiltinSuiteId(id)) {\n\t\treasons.push(\n\t\t\t`\"${id}\" is a builtin suite id; builtin workspaces are provisioned automatically and cannot be created`,\n\t\t);\n\t}\n\tif (existsSync(suiteDir)) {\n\t\treasons.push(`workspace directory ${suiteDir} already exists`);\n\t}\n\tif (reasons.length > 0) throw new SuiteLifecycleError(\"create\", id, reasons);\n\n\tlet definition: SuiteDefinition;\n\tif (options.cloneFrom === undefined) {\n\t\tdefinition = {\n\t\t\tschemaVersion: SUITE_SCHEMA_VERSION,\n\t\t\tid,\n\t\t\tname: options.name ?? id,\n\t\t\tbuiltin: false,\n\t\t\ttools: BUILTIN_SUITE_TOOLS,\n\t\t\tcapabilities: BUILTIN_SUITE_CAPABILITIES,\n\t\t\tassociations: { skills: [], mcp: [], plugins: [], roles: DEFAULT_ROLE_ASSOCIATIONS },\n\t\t\tinheritSystemAgentsMd: false,\n\t\t\tmemory: \"assistant\",\n\t\t\torientation: \"assistant\",\n\t\t\tmodel: null,\n\t\t\tthinking: null,\n\t\t\tclonedFrom: null,\n\t\t\tfactoryRevision: FACTORY_CONTENTS_VERSION,\n\t\t};\n\t\tmkdirSync(suiteDir, { recursive: true });\n\t\twriteFileSync(suiteJsonPath, serializeSuiteJson(definition), \"utf8\");\n\t\twriteFileSync(join(suiteDir, SUITE_AGENTS_MD_FILENAME), \"\", \"utf8\");\n\t} else {\n\t\tconst source = loadEffectiveSourceWorkspace(agentDir, options.cloneFrom);\n\t\tdefinition = {\n\t\t\t...source.suite,\n\t\t\tid,\n\t\t\tname: options.name ?? `${source.suite.name} clone`,\n\t\t\tbuiltin: false,\n\t\t\tclonedFrom: {\n\t\t\t\tid: source.suite.id,\n\t\t\t\tdigest: suiteManifestDigest(source.suite),\n\t\t\t\tat: options.now?.() ?? Date.now(),\n\t\t\t},\n\t\t\tfactoryRevision: FACTORY_CONTENTS_VERSION,\n\t\t};\n\t\t// Copy user assets (agents.md, skills, plugins, ...) but never the\n\t\t// source profile lock: the clone freezes its own identity on first\n\t\t// assembly.\n\t\tcpSync(source.suiteDir, suiteDir, {\n\t\t\trecursive: true,\n\t\t\tfilter: (sourcePath) => basename(sourcePath) !== SUITE_LOCK_FILENAME,\n\t\t});\n\t\twriteFileSync(suiteJsonPath, serializeSuiteJson(definition), \"utf8\");\n\t}\n\n\treturn { suiteId: id, suiteDir, suiteJsonPath, definition };\n}\n\nfunction loadEffectiveSourceWorkspace(agentDir: string, cloneFrom: string): SuiteWorkspace {\n\ttry {\n\t\treturn loadSuiteWorkspace({ agentDir, suiteId: cloneFrom });\n\t} catch (error) {\n\t\tif (error instanceof SuiteResolutionError) {\n\t\t\tthrow new SuiteLifecycleError(\"create\", cloneFrom, [`clone source \"${cloneFrom}\" does not exist`]);\n\t\t}\n\t\tthrow new SuiteLifecycleError(\"create\", cloneFrom, [\n\t\t\t`clone source \"${cloneFrom}\" is unusable: ${error instanceof Error ? error.message : String(error)}`,\n\t\t]);\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Session reference scan (设计 §9 删除前置检查)\n// ---------------------------------------------------------------------------\n\n/** One existing session bound to a suite via its creation-time custom entry. */\nexport interface SuiteSessionRef {\n\treadonly path: string;\n\treadonly sessionId: string;\n\treadonly cwd: string | undefined;\n\treadonly modified: Date;\n}\n\n/** Bounded head-scan window, aligned with the session header reader (1 MB). */\nconst SUITE_REF_SCAN_LIMIT_BYTES = 1024 * 1024;\nconst SUITE_REF_READ_BUFFER_SIZE = 64 * 1024;\n\ninterface SuiteRefScanOutcome {\n\treadonly sessionId: string | undefined;\n\treadonly cwd: string | undefined;\n\treadonly bound: boolean;\n}\n\n/**\n * Scans every session tree under `<agentDir>/sessions/<project>/*.jsonl` for\n * sessions whose creation-time custom entry (customType \"suite\") binds them\n * to `suiteId` (设计 §10.1). The suite entry sits in the first few lines of\n * the file, so a bounded head scan (1 MB, matching the session header reader)\n * is sufficient; a file whose binding line has been seen is decided — later\n * lines cannot change it. Unreadable, oversized, or malformed files are\n * skipped, never fatal. Custom session dirs (--session-dir) are out of scope.\n */\nexport function findSuiteSessionRefs(agentDir: string, suiteId: string): SuiteSessionRef[] {\n\tconst sessionsDir = join(agentDir, \"sessions\");\n\tif (!existsSync(sessionsDir)) return [];\n\tconst refs: SuiteSessionRef[] = [];\n\tfor (const projectEntry of readdirSync(sessionsDir, { withFileTypes: true })) {\n\t\tif (!projectEntry.isDirectory()) continue;\n\t\tconst projectDir = join(sessionsDir, projectEntry.name);\n\t\tlet files: string[];\n\t\ttry {\n\t\t\tfiles = readdirSync(projectDir).filter((file) => file.endsWith(\".jsonl\"));\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const file of files) {\n\t\t\tconst path = join(projectDir, file);\n\t\t\ttry {\n\t\t\t\tconst outcome = scanSessionFileForSuiteBinding(path, suiteId);\n\t\t\t\tif (outcome.bound && outcome.sessionId !== undefined) {\n\t\t\t\t\trefs.push({\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tsessionId: outcome.sessionId,\n\t\t\t\t\t\tcwd: outcome.cwd,\n\t\t\t\t\t\tmodified: statSync(path).mtime,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Skip unreadable files; one bad file must not block deletion.\n\t\t\t}\n\t\t}\n\t}\n\treturn refs;\n}\n\nfunction scanSessionFileForSuiteBinding(path: string, suiteId: string): SuiteRefScanOutcome {\n\tconst fd = openSync(path, \"r\");\n\ttry {\n\t\tconst decoder = new StringDecoder(\"utf8\");\n\t\tconst buffer = Buffer.allocUnsafe(SUITE_REF_READ_BUFFER_SIZE);\n\t\tlet scannedBytes = 0;\n\t\tlet sessionId: string | undefined;\n\t\tlet cwd: string | undefined;\n\t\tlet leftover = \"\";\n\t\tlet bound = false;\n\t\tlet bindingDecided = false;\n\n\t\twhile (scannedBytes < SUITE_REF_SCAN_LIMIT_BYTES && !bindingDecided) {\n\t\t\tconst readLength = Math.min(buffer.length, SUITE_REF_SCAN_LIMIT_BYTES - scannedBytes);\n\t\t\tconst bytesRead = readSync(fd, buffer, 0, readLength, null);\n\t\t\tif (bytesRead === 0) break;\n\t\t\tscannedBytes += bytesRead;\n\t\t\tconst chunk = leftover + decoder.write(buffer.subarray(0, bytesRead));\n\t\t\tconst lines = chunk.split(\"\\n\");\n\t\t\tleftover = lines.pop() ?? \"\";\n\t\t\tfor (const line of lines) {\n\t\t\t\tconst entry = parseSuiteRefLine(line);\n\t\t\t\tif (entry === undefined) continue;\n\t\t\t\tif (entry.header !== undefined && sessionId === undefined) {\n\t\t\t\t\tsessionId = entry.header.id;\n\t\t\t\t\tcwd = entry.header.cwd;\n\t\t\t\t}\n\t\t\t\tif (entry.boundToSuite !== undefined) {\n\t\t\t\t\tbound = entry.boundToSuite === suiteId;\n\t\t\t\t\tbindingDecided = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn { sessionId, cwd, bound };\n\t} finally {\n\t\tcloseSync(fd);\n\t}\n}\n\ninterface SuiteRefLineParseResult {\n\treadonly header?: { readonly id: string; readonly cwd: string | undefined };\n\t/** The suite id this session is bound to, when the line is the suite binding entry. */\n\treadonly boundToSuite?: string;\n}\n\nfunction parseSuiteRefLine(line: string): SuiteRefLineParseResult | undefined {\n\tconst trimmed = line.trim();\n\tif (trimmed.length === 0) return undefined;\n\tlet value: unknown;\n\ttry {\n\t\tvalue = JSON.parse(trimmed);\n\t} catch {\n\t\treturn undefined;\n\t}\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) return undefined;\n\tconst record = value as Record<string, unknown>;\n\tif (record.type === \"session\" && typeof record.id === \"string\") {\n\t\treturn { header: { id: record.id, cwd: typeof record.cwd === \"string\" ? record.cwd : undefined } };\n\t}\n\tif (record.type === \"custom\" && record.customType === SUITE_SESSION_ENTRY_TYPE) {\n\t\tconst data = record.data;\n\t\tconst suiteId =\n\t\t\tdata !== null && typeof data === \"object\" && typeof (data as Record<string, unknown>).suiteId === \"string\"\n\t\t\t\t? ((data as Record<string, unknown>).suiteId as string)\n\t\t\t\t: undefined;\n\t\treturn suiteId === undefined ? {} : { boundToSuite: suiteId };\n\t}\n\treturn {};\n}\n\n// ---------------------------------------------------------------------------\n// Delete: trash rename, release, sweep (设计 §9 删除)\n// ---------------------------------------------------------------------------\n\nexport interface SuiteDeleteOptions {\n\treadonly agentDir: string;\n\treadonly id: string;\n\t/** Session references from findSuiteSessionRefs; a non-empty list refuses the delete. */\n\treadonly refs: readonly SuiteSessionRef[];\n\treadonly now?: () => number;\n\t/** Programmatic authorization; must equal SUITE_DELETE_CONFIRM_TOKEN when provided. */\n\treadonly confirmToken?: string;\n\t/**\n\t * Memory purge hook (M5 wiring point): invoked after the workspace is\n\t * isolated in the trash. M4 releases assets only; memory clearing goes\n\t * through the Foundation purge gate once M5 lands.\n\t */\n\treadonly purgeMemories?: (suiteId: string) => void;\n}\n\nexport interface SuiteDeleteResult {\n\treadonly trashPath: string;\n}\n\n/**\n * Moves a user suite workspace into `<agentDir>/suites/.trash/<id>-<UTC\n * compact timestamp>-<random>/`. Builtin suites are refused; the workspace\n * (directory + suite.json) must exist but does not need to parse; any\n * session reference refuses the delete with the full list. The rename keeps\n * the workspace recoverable; releaseTrashedSuite/sweepSuiteTrash do the\n * actual removal.\n */\nexport function deleteSuite(options: SuiteDeleteOptions): SuiteDeleteResult {\n\tconst { agentDir, id } = options;\n\tif (options.confirmToken !== undefined && options.confirmToken !== SUITE_DELETE_CONFIRM_TOKEN) {\n\t\tthrow new SuiteLifecycleError(\"delete\", id, [\n\t\t\t`confirmToken must be \"${SUITE_DELETE_CONFIRM_TOKEN}\" when provided`,\n\t\t]);\n\t}\n\tconst reasons: string[] = [];\n\tif (isBuiltinSuiteId(id)) {\n\t\treasons.push(`builtin suite \"${id}\" cannot be deleted`);\n\t}\n\tconst suiteDir = getSuiteWorkspaceDir(agentDir, id);\n\tconst suiteJsonPath = join(suiteDir, SUITE_MANIFEST_FILENAME);\n\tif (!existsSync(suiteDir)) {\n\t\treasons.push(`workspace directory ${suiteDir} does not exist`);\n\t} else if (!existsSync(suiteJsonPath)) {\n\t\treasons.push(`${suiteJsonPath} does not exist`);\n\t}\n\tif (reasons.length > 0) throw new SuiteLifecycleError(\"delete\", id, reasons);\n\n\tif (options.refs.length > 0) {\n\t\tthrow new SuiteLifecycleError(\n\t\t\t\"delete\",\n\t\t\tid,\n\t\t\toptions.refs.map((ref) => `session ${ref.sessionId} at ${ref.path} references this suite`),\n\t\t);\n\t}\n\n\tconst trashRoot = join(getSuitesRootDir(agentDir), SUITE_TRASH_DIR_NAME);\n\tmkdirSync(trashRoot, { recursive: true });\n\tconst trashPath = join(\n\t\ttrashRoot,\n\t\t`${id}-${formatTrashTimestamp(options.now?.() ?? Date.now())}-${randomUUID().replaceAll(\"-\", \"\").slice(0, 6)}`,\n\t);\n\trenameSync(suiteDir, trashPath);\n\toptions.purgeMemories?.(id);\n\treturn { trashPath };\n}\n\nfunction formatTrashTimestamp(ms: number): string {\n\t// UTC compact, sortable: \"20260907T123456789Z\".\n\treturn new Date(ms).toISOString().replace(/[-:]/g, \"\").replace(\".\", \"\");\n}\n\n/**\n * Fire-and-forget removal of one trash entry (Node's built-in Windows retry\n * semantics). Failures never throw: the entry simply remains for the next\n * sweepSuiteTrash run.\n */\nexport function releaseTrashedSuite(trashPath: string): void {\n\tvoid rm(trashPath, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 }).catch(() => {\n\t\t// Left for sweepSuiteTrash; release is re-runnable by structure.\n\t});\n}\n\nexport interface SuiteTrashSweepResult {\n\treadonly removed: readonly string[];\n\treadonly kept: readonly string[];\n}\n\n/**\n * Removes trash entries older than `retentionMs` (default 7 days, per the M4\n * decision record). Entries are aged by their mtime; unreadable entries are\n * kept. Deterministic given the injectable clock.\n */\nexport async function sweepSuiteTrash(\n\tagentDir: string,\n\toptions: { retentionMs?: number; now?: () => number } = {},\n): Promise<SuiteTrashSweepResult> {\n\tconst trashRoot = join(getSuitesRootDir(agentDir), SUITE_TRASH_DIR_NAME);\n\tconst retentionMs = options.retentionMs ?? DEFAULT_SUITE_TRASH_RETENTION_MS;\n\tconst cutoffMs = (options.now?.() ?? Date.now()) - retentionMs;\n\tconst removed: string[] = [];\n\tconst kept: string[] = [];\n\tlet entryNames: string[];\n\ttry {\n\t\tentryNames = await readdir(trashRoot);\n\t} catch {\n\t\treturn { removed: Object.freeze(removed), kept: Object.freeze(kept) };\n\t}\n\tfor (const name of entryNames) {\n\t\tconst entryPath = join(trashRoot, name);\n\t\ttry {\n\t\t\tconst stats = await stat(entryPath);\n\t\t\tif (stats.mtimeMs <= cutoffMs) {\n\t\t\t\tawait rm(entryPath, { recursive: true, force: true });\n\t\t\t\tremoved.push(name);\n\t\t\t} else {\n\t\t\t\tkept.push(name);\n\t\t\t}\n\t\t} catch {\n\t\t\tkept.push(name);\n\t\t}\n\t}\n\treturn { removed: Object.freeze(removed), kept: Object.freeze(kept) };\n}\n\n// ---------------------------------------------------------------------------\n// Reset (设计 §9 重置): factory contents + authorized lock migration (2.7b)\n// ---------------------------------------------------------------------------\n\nexport interface SuiteResetApplyResult {\n\treadonly suiteId: string;\n\t/** Whether the on-disk suite.json differed from the factory contents. */\n\treadonly wroteFactory: boolean;\n\t/** The lock now persisted in the workspace. */\n\treadonly lock: ProfileLockV1;\n\t/** Defined when an existing lock was replaced via 2.7b applyMigration. */\n\treadonly previousGeneration?: number;\n}\n\nexport interface SuiteResetPlan {\n\treadonly suiteId: string;\n\treadonly factory: SuiteDefinition;\n\treadonly suiteJsonPath: string;\n\treadonly lockPath: string;\n\t/** Display diff (edit-diff format) of the on-disk file vs the factory contents. */\n\treadonly diffText: string;\n\t/**\n\t * Applies the reset: writes the factory suite.json, then persists the\n\t * factory identity's lock. An existing lock goes through the 2.7b policy:\n\t * `applyMigration` (authorizedBy \"suite-reset\") decides current vs\n\t * non-current; a non-current lock is replaced via `replaceProfileLock`\n\t * (generation increments, `previousGeneration` reports the swap). A missing\n\t * or unreadable lock gets a fresh one. The replacement lock is evaluated\n\t * before any write, so a failure leaves the previous files untouched.\n\t */\n\tapply(): SuiteResetApplyResult;\n}\n\n/**\n * Plans a builtin suite reset (设计 §9 重置): diff the on-disk suite.json\n * against the factory declaration without touching anything. User suites are\n * refused — they have no factory contents to restore; remove them instead.\n */\nexport function resetSuite(options: { agentDir: string; id: string; now?: () => number }): SuiteResetPlan {\n\tconst { agentDir, id } = options;\n\tconst factory = getBuiltinSuite(id);\n\tif (factory === undefined) {\n\t\tthrow new SuiteLifecycleError(\"reset\", id, [\n\t\t\tisBuiltinSuiteId(id)\n\t\t\t\t? `builtin suite \"${id}\" has no factory declaration`\n\t\t\t\t: `suite \"${id}\" is not builtin; only builtin suites can be reset — delete user suites instead`,\n\t\t]);\n\t}\n\tconst suiteDir = getSuiteWorkspaceDir(agentDir, id);\n\tconst suiteJsonPath = join(suiteDir, SUITE_MANIFEST_FILENAME);\n\tconst lockPath = join(suiteDir, SUITE_LOCK_FILENAME);\n\tconst factoryJson = serializeSuiteJson(factory);\n\tconst currentRaw = existsSync(suiteJsonPath) ? readFileSync(suiteJsonPath, \"utf8\") : \"\";\n\n\tconst apply = (): SuiteResetApplyResult => {\n\t\tconst identity = buildSuiteProfileIdentity(factory);\n\t\t// Evaluate the replacement before any write (2.7b): a failure above this\n\t\t// point leaves the previous suite.json and lock untouched.\n\t\tlet previousLock: ProfileLockV1 | undefined;\n\t\tif (existsSync(lockPath)) {\n\t\t\ttry {\n\t\t\t\tpreviousLock = parseSuiteProfileLockFile(readFileSync(lockPath, \"utf8\"));\n\t\t\t} catch {\n\t\t\t\tpreviousLock = undefined;\n\t\t\t}\n\t\t}\n\t\tlet lock: ProfileLockV1;\n\t\tlet previousGeneration: number | undefined;\n\t\tlet replaced = false;\n\t\tif (previousLock !== undefined) {\n\t\t\t// Explicit authorized migration (2.7b): applyMigration decides whether\n\t\t\t// the stored lock is already current; only a non-current outcome\n\t\t\t// replaces the lock, through replaceProfileLock — the lock's only\n\t\t\t// authorized swap primitive (generation increments).\n\t\t\tconst policy = createProfileMigrationPolicy();\n\t\t\tconst migration = policy.applyMigration({\n\t\t\t\tlock: previousLock,\n\t\t\t\tcurrent: identity,\n\t\t\t\tauthorizedBy: SUITE_RESET_AUTHORIZED_BY,\n\t\t\t\t...(options.now === undefined ? {} : { now: options.now }),\n\t\t\t});\n\t\t\tif (migration.status === \"failed\") {\n\t\t\t\tthrow new SuiteLifecycleError(\"reset\", id, [migration.reason]);\n\t\t\t}\n\t\t\tif (migration.status === \"current\") {\n\t\t\t\tlock = previousLock;\n\t\t\t} else {\n\t\t\t\tconst swap = replaceProfileLock(\n\t\t\t\t\tpreviousLock,\n\t\t\t\t\tidentity,\n\t\t\t\t\t{ authorizedBy: SUITE_RESET_AUTHORIZED_BY },\n\t\t\t\t\toptions.now === undefined ? {} : { now: options.now },\n\t\t\t\t);\n\t\t\t\tlock = swap.lock;\n\t\t\t\tpreviousGeneration = swap.previousGeneration;\n\t\t\t\treplaced = true;\n\t\t\t}\n\t\t} else {\n\t\t\tlock = createProfileLock(identity, {\n\t\t\t\tlockedBy: SUITE_RESET_AUTHORIZED_BY,\n\t\t\t\t...(options.now === undefined ? {} : { now: options.now }),\n\t\t\t});\n\t\t\treplaced = true;\n\t\t}\n\t\t// The workspace may never have been assembled (first assembly provisions\n\t\t// it, loadSuiteWorkspace-style); create the directory so a reset of a\n\t\t// never-assembled builtin does not fail with a bare ENOENT.\n\t\tmkdirSync(suiteDir, { recursive: true });\n\t\twriteFileSync(suiteJsonPath, factoryJson, \"utf8\");\n\t\t// D-075 S4 第三批:reset 不再预种角色文件——种子由 subagent-delegate 插件\n\t\t// 注册期的幂等补缺承担(见 entry.ts);方案重置只重写方案自身内容。\n\t\tif (replaced || previousLock === undefined) {\n\t\t\twriteFileSync(lockPath, serializeSuiteProfileLockFile(lock), \"utf8\");\n\t\t}\n\t\treturn {\n\t\t\tsuiteId: id,\n\t\t\twroteFactory: currentRaw !== factoryJson,\n\t\t\tlock,\n\t\t\t...(previousGeneration === undefined ? {} : { previousGeneration }),\n\t\t};\n\t};\n\n\treturn {\n\t\tsuiteId: id,\n\t\tfactory,\n\t\tsuiteJsonPath,\n\t\tlockPath,\n\t\tdiffText: generateDiffString(currentRaw, factoryJson).diff,\n\t\tapply,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Dangling settings cleanup (设计 §9 删除连带)\n// ---------------------------------------------------------------------------\n\nexport interface SuiteSettingsCleanup {\n\treadonly clearedScopes: readonly (\"project\" | \"global\")[];\n}\n\n/**\n * Clears the project/global settings `suite` keys when they point at `id`\n * (设计 §9 删除连带). Keys pointing elsewhere are untouched.\n */\nexport function clearDanglingSuiteSettings(settingsManager: SettingsManager, id: string): SuiteSettingsCleanup {\n\tconst clearedScopes: (\"project\" | \"global\")[] = [];\n\tif (settingsManager.getProjectSettings().suite === id) {\n\t\tsettingsManager.setProjectSuite(undefined);\n\t\tclearedScopes.push(\"project\");\n\t}\n\tif (settingsManager.getGlobalSettings().suite === id) {\n\t\tsettingsManager.setSuite(undefined);\n\t\tclearedScopes.push(\"global\");\n\t}\n\treturn { clearedScopes: Object.freeze(clearedScopes) };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"suite-lifecycle.js","sourceRoot":"","sources":["../../src/profiles/suite-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,SAAS,EACT,MAAM,EACN,UAAU,EACV,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,aAAa,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE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ACb,QAAQ;QACR,QAAQ,EAAE,kBAAkB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,IAAI;QAC1D,KAAK;KACL,CAAC;AAAA,CACF;AAUD;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAC,eAAgC,EAAE,EAAU,EAAwB;IAC9G,MAAM,aAAa,GAA6B,EAAE,CAAC;IACnD,IAAI,eAAe,CAAC,kBAAkB,EAAE,CAAC,KAAK,KAAK,EAAE,EAAE,CAAC;QACvD,eAAe,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;QAC3C,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;IACD,IAAI,eAAe,CAAC,iBAAiB,EAAE,CAAC,KAAK,KAAK,EAAE,EAAE,CAAC;QACtD,eAAe,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACpC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,EAAE,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;AAAA,CACvD","sourcesContent":["/**\n * Suite lifecycle operations (方案系统设计.md v2 §9, M4): create/clone,\n * delete (trash + release + sweep), reset, session reference scan, and\n * dangling settings cleanup.\n *\n * Every operation is deterministic given its inputs (`now` is injectable) and\n * reports refusal reasons as structured errors. Deletion only ever renames\n * the workspace into the trash directory — release and sweep are separate,\n * re-runnable steps — so recovery stays possible until the trash is released.\n * Memory purge is intentionally a hook: the Foundation purge gate lands with\n * M5; before that only suite assets are released.\n */\nimport { randomUUID } from \"node:crypto\";\nimport {\n\tcloseSync,\n\tcpSync,\n\texistsSync,\n\tmkdirSync,\n\topenSync,\n\treaddirSync,\n\treadFileSync,\n\treadSync,\n\trenameSync,\n\tstatSync,\n\twriteFileSync,\n} from \"node:fs\";\nimport { readdir, rm, stat } from \"node:fs/promises\";\nimport { basename, join } from \"node:path\";\nimport { StringDecoder } from \"node:string_decoder\";\nimport type { SettingsManager } from \"../core/settings-manager.ts\";\nimport { generateDiffString } from \"../core/tools/edit-diff.ts\";\nimport type { ProfileLockV1 } from \"../profile/lock.ts\";\nimport { createProfileLock, replaceProfileLock } from \"../profile/lock.ts\";\nimport { createProfileMigrationPolicy } from \"../profile/profile-migration.ts\";\nimport {\n\tBUILTIN_SUITE_CAPABILITIES,\n\tBUILTIN_SUITE_TOOLS,\n\tDEFAULT_ROLE_ASSOCIATIONS,\n\tFACTORY_CONTENTS_VERSION,\n\tgetBuiltinSuite,\n\tisBuiltinSuiteId,\n\tisValidSuiteId,\n\tSUITE_SCHEMA_VERSION,\n\ttype SuiteDefinition,\n\tserializeSuiteJson,\n} from \"./builtin-suites.ts\";\nimport {\n\tbuildSuiteProfileIdentity,\n\tgetSuitesRootDir,\n\tgetSuiteWorkspaceDir,\n\tloadSuiteWorkspace,\n\tparseSuiteProfileLockFile,\n\tSUITE_AGENTS_MD_FILENAME,\n\tSUITE_LOCK_FILENAME,\n\tSUITE_MANIFEST_FILENAME,\n\tSUITE_SESSION_ENTRY_TYPE,\n\tSuiteResolutionError,\n\ttype SuiteWorkspace,\n\tserializeSuiteProfileLockFile,\n\tsuiteManifestDigest,\n} from \"./suite-loader.ts\";\n\nexport const SUITE_TRASH_DIR_NAME = \".trash\";\n/** Trash retention for sweepSuiteTrash (M4 decision record). */\nexport const DEFAULT_SUITE_TRASH_RETENTION_MS = 7 * 24 * 60 * 60 * 1000;\n/**\n * Explicit programmatic authorization token for deleteSuite. The CLI confirms\n * interactively before calling; programmatic callers pass this token to prove\n * intent. Absent keeps the CLI-first flow working.\n */\nexport const SUITE_DELETE_CONFIRM_TOKEN = \"suite-delete\";\n/** lockedBy/authorizedBy stamped onto locks created by --suite-reset (2.7b). */\nexport const SUITE_RESET_AUTHORIZED_BY = \"suite-reset\";\n\nexport type SuiteLifecycleOperation = \"create\" | \"delete\" | \"reset\";\n\n/** Structured lifecycle refusal: operation, suite id, and every reason. */\nexport class SuiteLifecycleError extends Error {\n\treadonly operation: SuiteLifecycleOperation;\n\treadonly suiteId: string;\n\treadonly reasons: readonly string[];\n\n\tconstructor(operation: SuiteLifecycleOperation, suiteId: string, reasons: readonly string[]) {\n\t\tsuper(`Suite ${operation} failed for \"${suiteId}\": ${reasons.join(\"; \")}`);\n\t\tthis.name = \"SuiteLifecycleError\";\n\t\tthis.operation = operation;\n\t\tthis.suiteId = suiteId;\n\t\tthis.reasons = Object.freeze([...reasons]);\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Create / clone (设计 §9 创建)\n// ---------------------------------------------------------------------------\n\nexport interface SuiteCreateOptions {\n\treadonly agentDir: string;\n\treadonly id: string;\n\t/** Clone an existing suite workspace (builtin or user) instead of a fresh skeleton. */\n\treadonly cloneFrom?: string;\n\t/** Display name; defaults to the id (fresh) or \"<source name> clone\" (cloned). */\n\treadonly name?: string;\n\t/** Injectable clock for the clonedFrom timestamp. */\n\treadonly now?: () => number;\n}\n\nexport interface SuiteCreateResult {\n\treadonly suiteId: string;\n\treadonly suiteDir: string;\n\treadonly suiteJsonPath: string;\n\treadonly definition: SuiteDefinition;\n}\n\n/**\n * Creates a user suite workspace (设计 §9): `<agentDir>/suites/<id>/` with a\n * suite.json plus an empty agents.md skeleton, or — with `cloneFrom` — a copy\n * of the source workspace (effective definition, so a corrupted builtin\n * source clones its factory content) with the suite.json identity rewritten:\n * new id, `builtin: false`, and a `clonedFrom` record carrying the source id\n * and the digest of the source's effective suite.json value. The source's\n * `.profile-lock.json` is never copied: the clone is a new profile identity\n * whose lock is created on first assembly.\n */\nexport function createSuite(options: SuiteCreateOptions): SuiteCreateResult {\n\tconst { agentDir, id } = options;\n\tconst suiteDir = getSuiteWorkspaceDir(agentDir, id);\n\tconst suiteJsonPath = join(suiteDir, SUITE_MANIFEST_FILENAME);\n\n\tconst reasons: string[] = [];\n\tif (!isValidSuiteId(id)) {\n\t\treasons.push(\n\t\t\t`id must be a suite id (^[a-z0-9-]+$, no leading/trailing hyphen, Windows reserved names rejected), found ${JSON.stringify(id)}`,\n\t\t);\n\t}\n\tif (isBuiltinSuiteId(id)) {\n\t\treasons.push(\n\t\t\t`\"${id}\" is a builtin suite id; builtin workspaces are provisioned automatically and cannot be created`,\n\t\t);\n\t}\n\tif (existsSync(suiteDir)) {\n\t\treasons.push(`workspace directory ${suiteDir} already exists`);\n\t}\n\tif (reasons.length > 0) throw new SuiteLifecycleError(\"create\", id, reasons);\n\n\tlet definition: SuiteDefinition;\n\tif (options.cloneFrom === undefined) {\n\t\tdefinition = {\n\t\t\tschemaVersion: SUITE_SCHEMA_VERSION,\n\t\t\tid,\n\t\t\tname: options.name ?? id,\n\t\t\tbuiltin: false,\n\t\t\ttools: BUILTIN_SUITE_TOOLS,\n\t\t\tcapabilities: BUILTIN_SUITE_CAPABILITIES,\n\t\t\tassociations: { skills: [], mcp: [], plugins: [], roles: DEFAULT_ROLE_ASSOCIATIONS },\n\t\t\tinheritSystemAgentsMd: false,\n\t\t\tmemory: \"assistant\",\n\t\t\torientation: \"assistant\",\n\t\t\tmodel: null,\n\t\t\tthinking: null,\n\t\t\tclonedFrom: null,\n\t\t\tfactoryRevision: FACTORY_CONTENTS_VERSION,\n\t\t};\n\t\tmkdirSync(suiteDir, { recursive: true });\n\t\twriteFileSync(suiteJsonPath, serializeSuiteJson(definition), \"utf8\");\n\t\twriteFileSync(join(suiteDir, SUITE_AGENTS_MD_FILENAME), \"\", \"utf8\");\n\t} else {\n\t\tconst source = loadEffectiveSourceWorkspace(agentDir, options.cloneFrom);\n\t\tdefinition = {\n\t\t\t...source.suite,\n\t\t\tid,\n\t\t\tname: options.name ?? `${source.suite.name} clone`,\n\t\t\tbuiltin: false,\n\t\t\tclonedFrom: {\n\t\t\t\tid: source.suite.id,\n\t\t\t\tdigest: suiteManifestDigest(source.suite),\n\t\t\t\tat: options.now?.() ?? Date.now(),\n\t\t\t},\n\t\t\tfactoryRevision: FACTORY_CONTENTS_VERSION,\n\t\t};\n\t\t// Copy user assets (agents.md, skills, plugins, ...) but never the\n\t\t// source profile lock: the clone freezes its own identity on first\n\t\t// assembly.\n\t\tcpSync(source.suiteDir, suiteDir, {\n\t\t\trecursive: true,\n\t\t\tfilter: (sourcePath) => basename(sourcePath) !== SUITE_LOCK_FILENAME,\n\t\t});\n\t\twriteFileSync(suiteJsonPath, serializeSuiteJson(definition), \"utf8\");\n\t}\n\n\treturn { suiteId: id, suiteDir, suiteJsonPath, definition };\n}\n\nfunction loadEffectiveSourceWorkspace(agentDir: string, cloneFrom: string): SuiteWorkspace {\n\ttry {\n\t\treturn loadSuiteWorkspace({ agentDir, suiteId: cloneFrom });\n\t} catch (error) {\n\t\tif (error instanceof SuiteResolutionError) {\n\t\t\tthrow new SuiteLifecycleError(\"create\", cloneFrom, [`clone source \"${cloneFrom}\" does not exist`]);\n\t\t}\n\t\tthrow new SuiteLifecycleError(\"create\", cloneFrom, [\n\t\t\t`clone source \"${cloneFrom}\" is unusable: ${error instanceof Error ? error.message : String(error)}`,\n\t\t]);\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Session reference scan (设计 §9 删除前置检查)\n// ---------------------------------------------------------------------------\n\n/** One existing session bound to a suite via its creation-time custom entry. */\nexport interface SuiteSessionRef {\n\treadonly path: string;\n\treadonly sessionId: string;\n\treadonly cwd: string | undefined;\n\treadonly modified: Date;\n}\n\n/** Bounded head-scan window, aligned with the session header reader (1 MB). */\nconst SUITE_REF_SCAN_LIMIT_BYTES = 1024 * 1024;\nconst SUITE_REF_READ_BUFFER_SIZE = 64 * 1024;\n\ninterface SuiteRefScanOutcome {\n\treadonly sessionId: string | undefined;\n\treadonly cwd: string | undefined;\n\treadonly bound: boolean;\n}\n\n/**\n * Scans every session tree under `<agentDir>/sessions/<project>/*.jsonl` for\n * sessions whose creation-time custom entry (customType \"suite\") binds them\n * to `suiteId` (设计 §10.1). The suite entry sits in the first few lines of\n * the file, so a bounded head scan (1 MB, matching the session header reader)\n * is sufficient; a file whose binding line has been seen is decided — later\n * lines cannot change it. Unreadable, oversized, or malformed files are\n * skipped, never fatal. Custom session dirs (--session-dir) are out of scope.\n */\nexport function findSuiteSessionRefs(agentDir: string, suiteId: string): SuiteSessionRef[] {\n\tconst sessionsDir = join(agentDir, \"sessions\");\n\tif (!existsSync(sessionsDir)) return [];\n\tconst refs: SuiteSessionRef[] = [];\n\tfor (const projectEntry of readdirSync(sessionsDir, { withFileTypes: true })) {\n\t\tif (!projectEntry.isDirectory()) continue;\n\t\tconst projectDir = join(sessionsDir, projectEntry.name);\n\t\tlet files: string[];\n\t\ttry {\n\t\t\tfiles = readdirSync(projectDir).filter((file) => file.endsWith(\".jsonl\"));\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const file of files) {\n\t\t\tconst path = join(projectDir, file);\n\t\t\ttry {\n\t\t\t\tconst outcome = scanSessionFileForSuiteBinding(path, suiteId);\n\t\t\t\tif (outcome.bound && outcome.sessionId !== undefined) {\n\t\t\t\t\trefs.push({\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tsessionId: outcome.sessionId,\n\t\t\t\t\t\tcwd: outcome.cwd,\n\t\t\t\t\t\tmodified: statSync(path).mtime,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Skip unreadable files; one bad file must not block deletion.\n\t\t\t}\n\t\t}\n\t}\n\treturn refs;\n}\n\nfunction scanSessionFileForSuiteBinding(path: string, suiteId: string): SuiteRefScanOutcome {\n\tconst fd = openSync(path, \"r\");\n\ttry {\n\t\tconst decoder = new StringDecoder(\"utf8\");\n\t\tconst buffer = Buffer.allocUnsafe(SUITE_REF_READ_BUFFER_SIZE);\n\t\tlet scannedBytes = 0;\n\t\tlet sessionId: string | undefined;\n\t\tlet cwd: string | undefined;\n\t\tlet leftover = \"\";\n\t\tlet bound = false;\n\t\tlet bindingDecided = false;\n\n\t\twhile (scannedBytes < SUITE_REF_SCAN_LIMIT_BYTES && !bindingDecided) {\n\t\t\tconst readLength = Math.min(buffer.length, SUITE_REF_SCAN_LIMIT_BYTES - scannedBytes);\n\t\t\tconst bytesRead = readSync(fd, buffer, 0, readLength, null);\n\t\t\tif (bytesRead === 0) break;\n\t\t\tscannedBytes += bytesRead;\n\t\t\tconst chunk = leftover + decoder.write(buffer.subarray(0, bytesRead));\n\t\t\tconst lines = chunk.split(\"\\n\");\n\t\t\tleftover = lines.pop() ?? \"\";\n\t\t\tfor (const line of lines) {\n\t\t\t\tconst entry = parseSuiteRefLine(line);\n\t\t\t\tif (entry === undefined) continue;\n\t\t\t\tif (entry.header !== undefined && sessionId === undefined) {\n\t\t\t\t\tsessionId = entry.header.id;\n\t\t\t\t\tcwd = entry.header.cwd;\n\t\t\t\t}\n\t\t\t\tif (entry.boundToSuite !== undefined) {\n\t\t\t\t\tbound = entry.boundToSuite === suiteId;\n\t\t\t\t\tbindingDecided = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn { sessionId, cwd, bound };\n\t} finally {\n\t\tcloseSync(fd);\n\t}\n}\n\ninterface SuiteRefLineParseResult {\n\treadonly header?: { readonly id: string; readonly cwd: string | undefined };\n\t/** The suite id this session is bound to, when the line is the suite binding entry. */\n\treadonly boundToSuite?: string;\n}\n\nfunction parseSuiteRefLine(line: string): SuiteRefLineParseResult | undefined {\n\tconst trimmed = line.trim();\n\tif (trimmed.length === 0) return undefined;\n\tlet value: unknown;\n\ttry {\n\t\tvalue = JSON.parse(trimmed);\n\t} catch {\n\t\treturn undefined;\n\t}\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) return undefined;\n\tconst record = value as Record<string, unknown>;\n\tif (record.type === \"session\" && typeof record.id === \"string\") {\n\t\treturn { header: { id: record.id, cwd: typeof record.cwd === \"string\" ? record.cwd : undefined } };\n\t}\n\tif (record.type === \"custom\" && record.customType === SUITE_SESSION_ENTRY_TYPE) {\n\t\tconst data = record.data;\n\t\tconst suiteId =\n\t\t\tdata !== null && typeof data === \"object\" && typeof (data as Record<string, unknown>).suiteId === \"string\"\n\t\t\t\t? ((data as Record<string, unknown>).suiteId as string)\n\t\t\t\t: undefined;\n\t\treturn suiteId === undefined ? {} : { boundToSuite: suiteId };\n\t}\n\treturn {};\n}\n\n// ---------------------------------------------------------------------------\n// Delete: trash rename, release, sweep (设计 §9 删除)\n// ---------------------------------------------------------------------------\n\nexport interface SuiteDeleteOptions {\n\treadonly agentDir: string;\n\treadonly id: string;\n\t/** Session references from findSuiteSessionRefs; a non-empty list refuses the delete. */\n\treadonly refs: readonly SuiteSessionRef[];\n\treadonly now?: () => number;\n\t/** Programmatic authorization; must equal SUITE_DELETE_CONFIRM_TOKEN when provided. */\n\treadonly confirmToken?: string;\n\t/**\n\t * Memory purge hook (M5 wiring point): invoked after the workspace is\n\t * isolated in the trash. M4 releases assets only; memory clearing goes\n\t * through the Foundation purge gate once M5 lands.\n\t */\n\treadonly purgeMemories?: (suiteId: string) => void;\n}\n\nexport interface SuiteDeleteResult {\n\treadonly trashPath: string;\n}\n\n/**\n * Moves a user suite workspace into `<agentDir>/suites/.trash/<id>-<UTC\n * compact timestamp>-<random>/`. Builtin suites are refused; the workspace\n * (directory + suite.json) must exist but does not need to parse; any\n * session reference refuses the delete with the full list. The rename keeps\n * the workspace recoverable; releaseTrashedSuite/sweepSuiteTrash do the\n * actual removal.\n */\nexport function deleteSuite(options: SuiteDeleteOptions): SuiteDeleteResult {\n\tconst { agentDir, id } = options;\n\tif (options.confirmToken !== undefined && options.confirmToken !== SUITE_DELETE_CONFIRM_TOKEN) {\n\t\tthrow new SuiteLifecycleError(\"delete\", id, [\n\t\t\t`confirmToken must be \"${SUITE_DELETE_CONFIRM_TOKEN}\" when provided`,\n\t\t]);\n\t}\n\tconst reasons: string[] = [];\n\tif (isBuiltinSuiteId(id)) {\n\t\treasons.push(`builtin suite \"${id}\" cannot be deleted`);\n\t}\n\tconst suiteDir = getSuiteWorkspaceDir(agentDir, id);\n\tconst suiteJsonPath = join(suiteDir, SUITE_MANIFEST_FILENAME);\n\tif (!existsSync(suiteDir)) {\n\t\treasons.push(`workspace directory ${suiteDir} does not exist`);\n\t} else if (!existsSync(suiteJsonPath)) {\n\t\treasons.push(`${suiteJsonPath} does not exist`);\n\t}\n\tif (reasons.length > 0) throw new SuiteLifecycleError(\"delete\", id, reasons);\n\n\tif (options.refs.length > 0) {\n\t\tthrow new SuiteLifecycleError(\n\t\t\t\"delete\",\n\t\t\tid,\n\t\t\toptions.refs.map((ref) => `session ${ref.sessionId} at ${ref.path} references this suite`),\n\t\t);\n\t}\n\n\tconst trashRoot = join(getSuitesRootDir(agentDir), SUITE_TRASH_DIR_NAME);\n\tmkdirSync(trashRoot, { recursive: true });\n\tconst trashPath = join(\n\t\ttrashRoot,\n\t\t`${id}-${formatTrashTimestamp(options.now?.() ?? Date.now())}-${randomUUID().replaceAll(\"-\", \"\").slice(0, 6)}`,\n\t);\n\trenameSync(suiteDir, trashPath);\n\toptions.purgeMemories?.(id);\n\treturn { trashPath };\n}\n\nfunction formatTrashTimestamp(ms: number): string {\n\t// UTC compact, sortable: \"20260907T123456789Z\".\n\treturn new Date(ms).toISOString().replace(/[-:]/g, \"\").replace(\".\", \"\");\n}\n\n/**\n * Fire-and-forget removal of one trash entry (Node's built-in Windows retry\n * semantics). Failures never throw: the entry simply remains for the next\n * sweepSuiteTrash run.\n */\nexport function releaseTrashedSuite(trashPath: string): void {\n\tvoid rm(trashPath, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 }).catch(() => {\n\t\t// Left for sweepSuiteTrash; release is re-runnable by structure.\n\t});\n}\n\nexport interface SuiteTrashSweepResult {\n\treadonly removed: readonly string[];\n\treadonly kept: readonly string[];\n}\n\n/**\n * Removes trash entries older than `retentionMs` (default 7 days, per the M4\n * decision record). Entries are aged by their mtime; unreadable entries are\n * kept. Deterministic given the injectable clock.\n */\nexport async function sweepSuiteTrash(\n\tagentDir: string,\n\toptions: { retentionMs?: number; now?: () => number } = {},\n): Promise<SuiteTrashSweepResult> {\n\tconst trashRoot = join(getSuitesRootDir(agentDir), SUITE_TRASH_DIR_NAME);\n\tconst retentionMs = options.retentionMs ?? DEFAULT_SUITE_TRASH_RETENTION_MS;\n\tconst cutoffMs = (options.now?.() ?? Date.now()) - retentionMs;\n\tconst removed: string[] = [];\n\tconst kept: string[] = [];\n\tlet entryNames: string[];\n\ttry {\n\t\tentryNames = await readdir(trashRoot);\n\t} catch {\n\t\treturn { removed: Object.freeze(removed), kept: Object.freeze(kept) };\n\t}\n\tfor (const name of entryNames) {\n\t\tconst entryPath = join(trashRoot, name);\n\t\ttry {\n\t\t\tconst stats = await stat(entryPath);\n\t\t\tif (stats.mtimeMs <= cutoffMs) {\n\t\t\t\tawait rm(entryPath, { recursive: true, force: true });\n\t\t\t\tremoved.push(name);\n\t\t\t} else {\n\t\t\t\tkept.push(name);\n\t\t\t}\n\t\t} catch {\n\t\t\tkept.push(name);\n\t\t}\n\t}\n\treturn { removed: Object.freeze(removed), kept: Object.freeze(kept) };\n}\n\n// ---------------------------------------------------------------------------\n// Reset (设计 §9 重置): factory contents + authorized lock migration (2.7b)\n// ---------------------------------------------------------------------------\n\nexport interface SuiteResetApplyResult {\n\treadonly suiteId: string;\n\t/** Whether the on-disk suite.json differed from the factory contents. */\n\treadonly wroteFactory: boolean;\n\t/** The lock now persisted in the workspace. */\n\treadonly lock: ProfileLockV1;\n\t/** Defined when an existing lock was replaced via 2.7b applyMigration. */\n\treadonly previousGeneration?: number;\n}\n\nexport interface SuiteResetPlan {\n\treadonly suiteId: string;\n\treadonly factory: SuiteDefinition;\n\treadonly suiteJsonPath: string;\n\treadonly lockPath: string;\n\t/** Display diff (edit-diff format) of the on-disk file vs the factory contents. */\n\treadonly diffText: string;\n\t/**\n\t * Applies the reset: writes the factory suite.json, then persists the\n\t * factory identity's lock. An existing lock goes through the 2.7b policy:\n\t * `applyMigration` (authorizedBy \"suite-reset\") decides current vs\n\t * non-current; a non-current lock is replaced via `replaceProfileLock`\n\t * (generation increments, `previousGeneration` reports the swap). A missing\n\t * or unreadable lock gets a fresh one. The replacement lock is evaluated\n\t * before any write, so a failure leaves the previous files untouched.\n\t */\n\tapply(): SuiteResetApplyResult;\n}\n\n/**\n * Plans a builtin suite reset (设计 §9 重置): diff the on-disk suite.json\n * against the factory declaration without touching anything. User suites are\n * refused — they have no factory contents to restore; remove them instead.\n */\nexport function resetSuite(options: { agentDir: string; id: string; now?: () => number }): SuiteResetPlan {\n\tconst { agentDir, id } = options;\n\tconst factory = getBuiltinSuite(id);\n\tif (factory === undefined) {\n\t\tthrow new SuiteLifecycleError(\"reset\", id, [\n\t\t\tisBuiltinSuiteId(id)\n\t\t\t\t? `builtin suite \"${id}\" has no factory declaration`\n\t\t\t\t: `suite \"${id}\" is not builtin; only builtin suites can be reset — delete user suites instead`,\n\t\t]);\n\t}\n\tconst suiteDir = getSuiteWorkspaceDir(agentDir, id);\n\tconst suiteJsonPath = join(suiteDir, SUITE_MANIFEST_FILENAME);\n\tconst lockPath = join(suiteDir, SUITE_LOCK_FILENAME);\n\tconst factoryJson = serializeSuiteJson(factory);\n\tconst currentRaw = existsSync(suiteJsonPath) ? readFileSync(suiteJsonPath, \"utf8\") : \"\";\n\n\tconst apply = (): SuiteResetApplyResult => {\n\t\tconst identity = buildSuiteProfileIdentity(factory);\n\t\t// Evaluate the replacement before any write (2.7b): a failure above this\n\t\t// point leaves the previous suite.json and lock untouched.\n\t\tlet previousLock: ProfileLockV1 | undefined;\n\t\tif (existsSync(lockPath)) {\n\t\t\ttry {\n\t\t\t\tpreviousLock = parseSuiteProfileLockFile(readFileSync(lockPath, \"utf8\"));\n\t\t\t} catch {\n\t\t\t\tpreviousLock = undefined;\n\t\t\t}\n\t\t}\n\t\tlet lock: ProfileLockV1;\n\t\tlet previousGeneration: number | undefined;\n\t\tlet replaced = false;\n\t\tif (previousLock !== undefined) {\n\t\t\t// Explicit authorized migration (2.7b): applyMigration decides whether\n\t\t\t// the stored lock is already current; only a non-current outcome\n\t\t\t// replaces the lock, through replaceProfileLock — the lock's only\n\t\t\t// authorized swap primitive (generation increments).\n\t\t\tconst policy = createProfileMigrationPolicy();\n\t\t\tconst migration = policy.applyMigration({\n\t\t\t\tlock: previousLock,\n\t\t\t\tcurrent: identity,\n\t\t\t\tauthorizedBy: SUITE_RESET_AUTHORIZED_BY,\n\t\t\t\t...(options.now === undefined ? {} : { now: options.now }),\n\t\t\t});\n\t\t\tif (migration.status === \"failed\") {\n\t\t\t\tthrow new SuiteLifecycleError(\"reset\", id, [migration.reason]);\n\t\t\t}\n\t\t\tif (migration.status === \"current\") {\n\t\t\t\tlock = previousLock;\n\t\t\t} else {\n\t\t\t\tconst swap = replaceProfileLock(\n\t\t\t\t\tpreviousLock,\n\t\t\t\t\tidentity,\n\t\t\t\t\t{ authorizedBy: SUITE_RESET_AUTHORIZED_BY },\n\t\t\t\t\toptions.now === undefined ? {} : { now: options.now },\n\t\t\t\t);\n\t\t\t\tlock = swap.lock;\n\t\t\t\tpreviousGeneration = swap.previousGeneration;\n\t\t\t\treplaced = true;\n\t\t\t}\n\t\t} else {\n\t\t\tlock = createProfileLock(identity, {\n\t\t\t\tlockedBy: SUITE_RESET_AUTHORIZED_BY,\n\t\t\t\t...(options.now === undefined ? {} : { now: options.now }),\n\t\t\t});\n\t\t\treplaced = true;\n\t\t}\n\t\t// The workspace may never have been assembled (first assembly provisions\n\t\t// it, loadSuiteWorkspace-style); create the directory so a reset of a\n\t\t// never-assembled builtin does not fail with a bare ENOENT.\n\t\tmkdirSync(suiteDir, { recursive: true });\n\t\twriteFileSync(suiteJsonPath, factoryJson, \"utf8\");\n\t\t// D-075 S4 第三批:reset 不再预种角色文件——种子由 subagent-delegate 插件\n\t\t// 注册期的幂等补缺承担(见 entry.ts);方案重置只重写方案自身内容。\n\t\tif (replaced || previousLock === undefined) {\n\t\t\twriteFileSync(lockPath, serializeSuiteProfileLockFile(lock), \"utf8\");\n\t\t}\n\t\treturn {\n\t\t\tsuiteId: id,\n\t\t\twroteFactory: currentRaw !== factoryJson,\n\t\t\tlock,\n\t\t\t...(previousGeneration === undefined ? {} : { previousGeneration }),\n\t\t};\n\t};\n\n\treturn {\n\t\tsuiteId: id,\n\t\tfactory,\n\t\tsuiteJsonPath,\n\t\tlockPath,\n\t\tdiffText: generateDiffString(currentRaw, factoryJson).diff,\n\t\tapply,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Dangling settings cleanup (设计 §9 删除连带)\n// ---------------------------------------------------------------------------\n\nexport interface SuiteSettingsCleanup {\n\treadonly clearedScopes: readonly (\"project\" | \"global\")[];\n}\n\n/**\n * Clears the project/global settings `suite` keys when they point at `id`\n * (设计 §9 删除连带). Keys pointing elsewhere are untouched.\n */\nexport function clearDanglingSuiteSettings(settingsManager: SettingsManager, id: string): SuiteSettingsCleanup {\n\tconst clearedScopes: (\"project\" | \"global\")[] = [];\n\tif (settingsManager.getProjectSettings().suite === id) {\n\t\tsettingsManager.setProjectSuite(undefined);\n\t\tclearedScopes.push(\"project\");\n\t}\n\tif (settingsManager.getGlobalSettings().suite === id) {\n\t\tsettingsManager.setSuite(undefined);\n\t\tclearedScopes.push(\"global\");\n\t}\n\treturn { clearedScopes: Object.freeze(clearedScopes) };\n}\n"]}