@ai-agent-forge/agent-forge 0.86.7 → 0.87.0

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 (665) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +8 -9
  3. package/dist/artifacts/artifact-store.d.ts.map +1 -1
  4. package/dist/artifacts/artifact-store.js +9 -5
  5. package/dist/artifacts/artifact-store.js.map +1 -1
  6. package/dist/bundle/.build-manifest.json +410 -371
  7. package/dist/bundle/chunks/{chunk-A7GUOX2H.js → chunk-6ZKDNZHA.js} +5 -1
  8. package/dist/bundle/chunks/chunk-BFC2BDVJ.js +13 -0
  9. package/dist/bundle/chunks/chunk-MOHOLL3F.js +1456 -0
  10. package/dist/bundle/chunks/image-resize-worker.js +12 -1
  11. package/dist/bundle/chunks/{virtual-modules-3IZ4MYSQ.js → virtual-modules-KZ5DRH7Q.js} +1 -1
  12. package/dist/bundle/cli.js +1 -1
  13. package/dist/bundle/client.js +1 -1
  14. package/dist/bundle/index.js +2 -2
  15. package/dist/bundle/rpc-entry.js +1 -1
  16. package/dist/cli/args.d.ts.map +1 -1
  17. package/dist/cli/args.js +231 -185
  18. package/dist/cli/args.js.map +1 -1
  19. package/dist/cli/auth-check.d.ts.map +1 -1
  20. package/dist/cli/auth-check.js +3 -2
  21. package/dist/cli/auth-check.js.map +1 -1
  22. package/dist/cli/auth-command.d.ts.map +1 -1
  23. package/dist/cli/auth-command.js +15 -9
  24. package/dist/cli/auth-command.js.map +1 -1
  25. package/dist/cli/credential-print.d.ts.map +1 -1
  26. package/dist/cli/credential-print.js +14 -7
  27. package/dist/cli/credential-print.js.map +1 -1
  28. package/dist/cli/experimental/command.d.ts.map +1 -1
  29. package/dist/cli/experimental/command.js +6 -5
  30. package/dist/cli/experimental/command.js.map +1 -1
  31. package/dist/cli/list-models.d.ts.map +1 -1
  32. package/dist/cli/list-models.js +9 -8
  33. package/dist/cli/list-models.js.map +1 -1
  34. package/dist/cli/plugin-manager-controller.d.ts.map +1 -1
  35. package/dist/cli/plugin-manager-controller.js +2 -1
  36. package/dist/cli/plugin-manager-controller.js.map +1 -1
  37. package/dist/cli/serve.d.ts.map +1 -1
  38. package/dist/cli/serve.js +8 -5
  39. package/dist/cli/serve.js.map +1 -1
  40. package/dist/client/remote-session.d.ts.map +1 -1
  41. package/dist/client/remote-session.js +16 -9
  42. package/dist/client/remote-session.js.map +1 -1
  43. package/dist/config.d.ts.map +1 -1
  44. package/dist/config.js +2 -1
  45. package/dist/config.js.map +1 -1
  46. package/dist/core/agent-capability-contract.d.ts +0 -7
  47. package/dist/core/agent-capability-contract.d.ts.map +1 -1
  48. package/dist/core/agent-capability-contract.js +72 -68
  49. package/dist/core/agent-capability-contract.js.map +1 -1
  50. package/dist/core/agent-session-bash.d.ts.map +1 -1
  51. package/dist/core/agent-session-bash.js +5 -4
  52. package/dist/core/agent-session-bash.js.map +1 -1
  53. package/dist/core/agent-session-compaction.d.ts.map +1 -1
  54. package/dist/core/agent-session-compaction.js +28 -22
  55. package/dist/core/agent-session-compaction.js.map +1 -1
  56. package/dist/core/agent-session-context.d.ts.map +1 -1
  57. package/dist/core/agent-session-context.js +18 -13
  58. package/dist/core/agent-session-context.js.map +1 -1
  59. package/dist/core/agent-session-model.d.ts.map +1 -1
  60. package/dist/core/agent-session-model.js +2 -1
  61. package/dist/core/agent-session-model.js.map +1 -1
  62. package/dist/core/agent-session-retry.d.ts.map +1 -1
  63. package/dist/core/agent-session-retry.js +3 -2
  64. package/dist/core/agent-session-retry.js.map +1 -1
  65. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  66. package/dist/core/agent-session-runtime.js +7 -6
  67. package/dist/core/agent-session-runtime.js.map +1 -1
  68. package/dist/core/agent-session-services.d.ts +1 -1
  69. package/dist/core/agent-session-services.d.ts.map +1 -1
  70. package/dist/core/agent-session-services.js.map +1 -1
  71. package/dist/core/agent-session-tools.d.ts.map +1 -1
  72. package/dist/core/agent-session-tools.js +3 -2
  73. package/dist/core/agent-session-tools.js.map +1 -1
  74. package/dist/core/agent-session.d.ts +40 -2
  75. package/dist/core/agent-session.d.ts.map +1 -1
  76. package/dist/core/agent-session.js +142 -34
  77. package/dist/core/agent-session.js.map +1 -1
  78. package/dist/core/auth-guidance.d.ts.map +1 -1
  79. package/dist/core/auth-guidance.js +11 -5
  80. package/dist/core/auth-guidance.js.map +1 -1
  81. package/dist/core/auth-storage.d.ts.map +1 -1
  82. package/dist/core/auth-storage.js +9 -6
  83. package/dist/core/auth-storage.js.map +1 -1
  84. package/dist/core/compaction/compaction.d.ts.map +1 -1
  85. package/dist/core/compaction/compaction.js +2 -1
  86. package/dist/core/compaction/compaction.js.map +1 -1
  87. package/dist/core/embedded-sdk.d.ts.map +1 -1
  88. package/dist/core/embedded-sdk.js +10 -6
  89. package/dist/core/embedded-sdk.js.map +1 -1
  90. package/dist/core/export-html/index.d.ts.map +1 -1
  91. package/dist/core/export-html/index.js +9 -4
  92. package/dist/core/export-html/index.js.map +1 -1
  93. package/dist/core/extensions/agent-composition.d.ts.map +1 -1
  94. package/dist/core/extensions/agent-composition.js +26 -19
  95. package/dist/core/extensions/agent-composition.js.map +1 -1
  96. package/dist/core/extensions/bootstrap-agent-loop.d.ts.map +1 -1
  97. package/dist/core/extensions/bootstrap-agent-loop.js +3 -2
  98. package/dist/core/extensions/bootstrap-agent-loop.js.map +1 -1
  99. package/dist/core/extensions/bootstrap-lifecycle.d.ts.map +1 -1
  100. package/dist/core/extensions/bootstrap-lifecycle.js +20 -17
  101. package/dist/core/extensions/bootstrap-lifecycle.js.map +1 -1
  102. package/dist/core/extensions/bootstrap-overflow-policy.d.ts.map +1 -1
  103. package/dist/core/extensions/bootstrap-overflow-policy.js +2 -1
  104. package/dist/core/extensions/bootstrap-overflow-policy.js.map +1 -1
  105. package/dist/core/extensions/bootstrap-retry-policy.d.ts.map +1 -1
  106. package/dist/core/extensions/bootstrap-retry-policy.js +2 -1
  107. package/dist/core/extensions/bootstrap-retry-policy.js.map +1 -1
  108. package/dist/core/extensions/bootstrap-skills.d.ts.map +1 -1
  109. package/dist/core/extensions/bootstrap-skills.js +7 -6
  110. package/dist/core/extensions/bootstrap-skills.js.map +1 -1
  111. package/dist/core/extensions/bootstrap-tools.d.ts.map +1 -1
  112. package/dist/core/extensions/bootstrap-tools.js +2 -1
  113. package/dist/core/extensions/bootstrap-tools.js.map +1 -1
  114. package/dist/core/extensions/capability-plugin.d.ts.map +1 -1
  115. package/dist/core/extensions/capability-plugin.js +37 -13
  116. package/dist/core/extensions/capability-plugin.js.map +1 -1
  117. package/dist/core/extensions/capability-runtime-events.d.ts.map +1 -1
  118. package/dist/core/extensions/capability-runtime-events.js +17 -13
  119. package/dist/core/extensions/capability-runtime-events.js.map +1 -1
  120. package/dist/core/extensions/capability-runtime-guards.d.ts.map +1 -1
  121. package/dist/core/extensions/capability-runtime-guards.js +16 -15
  122. package/dist/core/extensions/capability-runtime-guards.js.map +1 -1
  123. package/dist/core/extensions/capability-runtime-manifest.d.ts.map +1 -1
  124. package/dist/core/extensions/capability-runtime-manifest.js +52 -30
  125. package/dist/core/extensions/capability-runtime-manifest.js.map +1 -1
  126. package/dist/core/extensions/capability-runtime-validation.d.ts.map +1 -1
  127. package/dist/core/extensions/capability-runtime-validation.js +66 -65
  128. package/dist/core/extensions/capability-runtime-validation.js.map +1 -1
  129. package/dist/core/extensions/capability-runtime.d.ts.map +1 -1
  130. package/dist/core/extensions/capability-runtime.js +147 -127
  131. package/dist/core/extensions/capability-runtime.js.map +1 -1
  132. package/dist/core/extensions/compaction-memory-failure-mode.d.ts.map +1 -1
  133. package/dist/core/extensions/compaction-memory-failure-mode.js +3 -2
  134. package/dist/core/extensions/compaction-memory-failure-mode.js.map +1 -1
  135. package/dist/core/extensions/context-strategy-binding.d.ts.map +1 -1
  136. package/dist/core/extensions/context-strategy-binding.js +7 -4
  137. package/dist/core/extensions/context-strategy-binding.js.map +1 -1
  138. package/dist/core/extensions/lifecycle-catalog.d.ts.map +1 -1
  139. package/dist/core/extensions/lifecycle-catalog.js +290 -279
  140. package/dist/core/extensions/lifecycle-catalog.js.map +1 -1
  141. package/dist/core/extensions/lifecycle-delivery-queue.d.ts.map +1 -1
  142. package/dist/core/extensions/lifecycle-delivery-queue.js +3 -2
  143. package/dist/core/extensions/lifecycle-delivery-queue.js.map +1 -1
  144. package/dist/core/facade/coding-agent-facade.d.ts +6 -0
  145. package/dist/core/facade/coding-agent-facade.d.ts.map +1 -1
  146. package/dist/core/facade/coding-agent-facade.js +2 -0
  147. package/dist/core/facade/coding-agent-facade.js.map +1 -1
  148. package/dist/core/http-dispatcher.d.ts.map +1 -1
  149. package/dist/core/http-dispatcher.js +2 -1
  150. package/dist/core/http-dispatcher.js.map +1 -1
  151. package/dist/core/i18n/index.d.ts +14 -0
  152. package/dist/core/i18n/index.d.ts.map +1 -0
  153. package/dist/core/i18n/index.js +67 -0
  154. package/dist/core/i18n/index.js.map +1 -0
  155. package/dist/core/i18n/locales/en/example.d.ts +7 -0
  156. package/dist/core/i18n/locales/en/example.d.ts.map +1 -0
  157. package/dist/core/i18n/locales/en/example.js +7 -0
  158. package/dist/core/i18n/locales/en/example.js.map +1 -0
  159. package/dist/core/i18n/locales/zh-cn/cli.d.ts +8 -0
  160. package/dist/core/i18n/locales/zh-cn/cli.d.ts.map +1 -0
  161. package/dist/core/i18n/locales/zh-cn/cli.js +227 -0
  162. package/dist/core/i18n/locales/zh-cn/cli.js.map +1 -0
  163. package/dist/core/i18n/locales/zh-cn/common.d.ts +6 -0
  164. package/dist/core/i18n/locales/zh-cn/common.d.ts.map +1 -0
  165. package/dist/core/i18n/locales/zh-cn/common.js +6 -0
  166. package/dist/core/i18n/locales/zh-cn/common.js.map +1 -0
  167. package/dist/core/i18n/locales/zh-cn/core-contract-core.d.ts +13 -0
  168. package/dist/core/i18n/locales/zh-cn/core-contract-core.d.ts.map +1 -0
  169. package/dist/core/i18n/locales/zh-cn/core-contract-core.js +173 -0
  170. package/dist/core/i18n/locales/zh-cn/core-contract-core.js.map +1 -0
  171. package/dist/core/i18n/locales/zh-cn/core-contract-extensions.d.ts +12 -0
  172. package/dist/core/i18n/locales/zh-cn/core-contract-extensions.d.ts.map +1 -0
  173. package/dist/core/i18n/locales/zh-cn/core-contract-extensions.js +582 -0
  174. package/dist/core/i18n/locales/zh-cn/core-contract-extensions.js.map +1 -0
  175. package/dist/core/i18n/locales/zh-cn/core-contract-final.d.ts +9 -0
  176. package/dist/core/i18n/locales/zh-cn/core-contract-final.d.ts.map +1 -0
  177. package/dist/core/i18n/locales/zh-cn/core-contract-final.js +55 -0
  178. package/dist/core/i18n/locales/zh-cn/core-contract-final.js.map +1 -0
  179. package/dist/core/i18n/locales/zh-cn/core-contract-plugins.d.ts +11 -0
  180. package/dist/core/i18n/locales/zh-cn/core-contract-plugins.d.ts.map +1 -0
  181. package/dist/core/i18n/locales/zh-cn/core-contract-plugins.js +455 -0
  182. package/dist/core/i18n/locales/zh-cn/core-contract-plugins.js.map +1 -0
  183. package/dist/core/i18n/locales/zh-cn/core-errors.d.ts +9 -0
  184. package/dist/core/i18n/locales/zh-cn/core-errors.d.ts.map +1 -0
  185. package/dist/core/i18n/locales/zh-cn/core-errors.js +191 -0
  186. package/dist/core/i18n/locales/zh-cn/core-errors.js.map +1 -0
  187. package/dist/core/i18n/locales/zh-cn/example.d.ts +7 -0
  188. package/dist/core/i18n/locales/zh-cn/example.d.ts.map +1 -0
  189. package/dist/core/i18n/locales/zh-cn/example.js +10 -0
  190. package/dist/core/i18n/locales/zh-cn/example.js.map +1 -0
  191. package/dist/core/i18n/locales/zh-cn/index.d.ts +2 -0
  192. package/dist/core/i18n/locales/zh-cn/index.d.ts.map +1 -0
  193. package/dist/core/i18n/locales/zh-cn/index.js +41 -0
  194. package/dist/core/i18n/locales/zh-cn/index.js.map +1 -0
  195. package/dist/core/i18n/locales/zh-cn/interactive-mode.d.ts +10 -0
  196. package/dist/core/i18n/locales/zh-cn/interactive-mode.d.ts.map +1 -0
  197. package/dist/core/i18n/locales/zh-cn/interactive-mode.js +265 -0
  198. package/dist/core/i18n/locales/zh-cn/interactive-mode.js.map +1 -0
  199. package/dist/core/i18n/locales/zh-cn/keybindings.d.ts +11 -0
  200. package/dist/core/i18n/locales/zh-cn/keybindings.d.ts.map +1 -0
  201. package/dist/core/i18n/locales/zh-cn/keybindings.js +67 -0
  202. package/dist/core/i18n/locales/zh-cn/keybindings.js.map +1 -0
  203. package/dist/core/i18n/locales/zh-cn/slash-commands.d.ts +7 -0
  204. package/dist/core/i18n/locales/zh-cn/slash-commands.d.ts.map +1 -0
  205. package/dist/core/i18n/locales/zh-cn/slash-commands.js +39 -0
  206. package/dist/core/i18n/locales/zh-cn/slash-commands.js.map +1 -0
  207. package/dist/core/i18n/locales/zh-cn/tui-builtin.d.ts +10 -0
  208. package/dist/core/i18n/locales/zh-cn/tui-builtin.d.ts.map +1 -0
  209. package/dist/core/i18n/locales/zh-cn/tui-builtin.js +15 -0
  210. package/dist/core/i18n/locales/zh-cn/tui-builtin.js.map +1 -0
  211. package/dist/core/i18n/locales/zh-cn/tui-components-misc.d.ts +13 -0
  212. package/dist/core/i18n/locales/zh-cn/tui-components-misc.d.ts.map +1 -0
  213. package/dist/core/i18n/locales/zh-cn/tui-components-misc.js +102 -0
  214. package/dist/core/i18n/locales/zh-cn/tui-components-misc.js.map +1 -0
  215. package/dist/core/i18n/locales/zh-cn/tui-components-selectors.d.ts +12 -0
  216. package/dist/core/i18n/locales/zh-cn/tui-components-selectors.d.ts.map +1 -0
  217. package/dist/core/i18n/locales/zh-cn/tui-components-selectors.js +288 -0
  218. package/dist/core/i18n/locales/zh-cn/tui-components-selectors.js.map +1 -0
  219. package/dist/core/i18n/locales/zh-cn/tui-interactive-misc.d.ts +9 -0
  220. package/dist/core/i18n/locales/zh-cn/tui-interactive-misc.d.ts.map +1 -0
  221. package/dist/core/i18n/locales/zh-cn/tui-interactive-misc.js +79 -0
  222. package/dist/core/i18n/locales/zh-cn/tui-interactive-misc.js.map +1 -0
  223. package/dist/core/i18n/locales/zh-cn/tui-self-owned.d.ts +8 -0
  224. package/dist/core/i18n/locales/zh-cn/tui-self-owned.d.ts.map +1 -0
  225. package/dist/core/i18n/locales/zh-cn/tui-self-owned.js +72 -0
  226. package/dist/core/i18n/locales/zh-cn/tui-self-owned.js.map +1 -0
  227. package/dist/core/keybindings.d.ts +15 -0
  228. package/dist/core/keybindings.d.ts.map +1 -1
  229. package/dist/core/keybindings.js +18 -0
  230. package/dist/core/keybindings.js.map +1 -1
  231. package/dist/core/logger.d.ts.map +1 -1
  232. package/dist/core/logger.js +5 -1
  233. package/dist/core/logger.js.map +1 -1
  234. package/dist/core/model-registry.d.ts.map +1 -1
  235. package/dist/core/model-registry.js +2 -1
  236. package/dist/core/model-registry.js.map +1 -1
  237. package/dist/core/model-runtime.d.ts.map +1 -1
  238. package/dist/core/model-runtime.js +8 -4
  239. package/dist/core/model-runtime.js.map +1 -1
  240. package/dist/core/package-install-host.d.ts.map +1 -1
  241. package/dist/core/package-install-host.js +4 -3
  242. package/dist/core/package-install-host.js.map +1 -1
  243. package/dist/core/package-manager.d.ts.map +1 -1
  244. package/dist/core/package-manager.js +15 -10
  245. package/dist/core/package-manager.js.map +1 -1
  246. package/dist/core/package-resource-collection.d.ts.map +1 -1
  247. package/dist/core/package-resource-collection.js +2 -1
  248. package/dist/core/package-resource-collection.js.map +1 -1
  249. package/dist/core/package-source.d.ts.map +1 -1
  250. package/dist/core/package-source.js +3 -2
  251. package/dist/core/package-source.js.map +1 -1
  252. package/dist/core/provider-composer.d.ts.map +1 -1
  253. package/dist/core/provider-composer.js +22 -13
  254. package/dist/core/provider-composer.js.map +1 -1
  255. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  256. package/dist/core/remote-catalog-provider.js +6 -2
  257. package/dist/core/remote-catalog-provider.js.map +1 -1
  258. package/dist/core/resolve-config-value.d.ts.map +1 -1
  259. package/dist/core/resolve-config-value.js +15 -5
  260. package/dist/core/resolve-config-value.js.map +1 -1
  261. package/dist/core/sdk.d.ts +19 -5
  262. package/dist/core/sdk.d.ts.map +1 -1
  263. package/dist/core/sdk.js +74 -54
  264. package/dist/core/sdk.js.map +1 -1
  265. package/dist/core/session-cwd.d.ts.map +1 -1
  266. package/dist/core/session-cwd.js +5 -2
  267. package/dist/core/session-cwd.js.map +1 -1
  268. package/dist/core/session-export.d.ts.map +1 -1
  269. package/dist/core/session-export.js +2 -1
  270. package/dist/core/session-export.js.map +1 -1
  271. package/dist/core/session-manager.d.ts.map +1 -1
  272. package/dist/core/session-manager.js +39 -29
  273. package/dist/core/session-manager.js.map +1 -1
  274. package/dist/core/session-storage.d.ts.map +1 -1
  275. package/dist/core/session-storage.js +3 -3
  276. package/dist/core/session-storage.js.map +1 -1
  277. package/dist/core/settings-manager.d.ts +11 -0
  278. package/dist/core/settings-manager.d.ts.map +1 -1
  279. package/dist/core/settings-manager.js +27 -5
  280. package/dist/core/settings-manager.js.map +1 -1
  281. package/dist/core/slash-commands.d.ts.map +1 -1
  282. package/dist/core/slash-commands.js +53 -32
  283. package/dist/core/slash-commands.js.map +1 -1
  284. package/dist/core/system-prompt.d.ts.map +1 -1
  285. package/dist/core/system-prompt.js +25 -2
  286. package/dist/core/system-prompt.js.map +1 -1
  287. package/dist/core/tools/bash.d.ts.map +1 -1
  288. package/dist/core/tools/bash.js +11 -7
  289. package/dist/core/tools/bash.js.map +1 -1
  290. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  291. package/dist/core/tools/edit-diff.js +9 -4
  292. package/dist/core/tools/edit-diff.js.map +1 -1
  293. package/dist/core/tools/edit.d.ts.map +1 -1
  294. package/dist/core/tools/edit.js +4 -3
  295. package/dist/core/tools/edit.js.map +1 -1
  296. package/dist/core/tools/index.d.ts.map +1 -1
  297. package/dist/core/tools/index.js +3 -2
  298. package/dist/core/tools/index.js.map +1 -1
  299. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  300. package/dist/core/tools/output-accumulator.js +2 -1
  301. package/dist/core/tools/output-accumulator.js.map +1 -1
  302. package/dist/core/tools/read.d.ts.map +1 -1
  303. package/dist/core/tools/read.js +6 -2
  304. package/dist/core/tools/read.js.map +1 -1
  305. package/dist/core/tools/write.d.ts.map +1 -1
  306. package/dist/core/tools/write.js +2 -1
  307. package/dist/core/tools/write.js.map +1 -1
  308. package/dist/durable/durable-service.d.ts.map +1 -1
  309. package/dist/durable/durable-service.js +25 -18
  310. package/dist/durable/durable-service.js.map +1 -1
  311. package/dist/host/checkpoint-commit.d.ts.map +1 -1
  312. package/dist/host/checkpoint-commit.js +2 -1
  313. package/dist/host/checkpoint-commit.js.map +1 -1
  314. package/dist/host/manual-compaction.d.ts.map +1 -1
  315. package/dist/host/manual-compaction.js +2 -1
  316. package/dist/host/manual-compaction.js.map +1 -1
  317. package/dist/host/output-projection.d.ts +0 -13
  318. package/dist/host/output-projection.d.ts.map +1 -1
  319. package/dist/host/output-projection.js +16 -2
  320. package/dist/host/output-projection.js.map +1 -1
  321. package/dist/host/summary-retry.d.ts.map +1 -1
  322. package/dist/host/summary-retry.js +3 -2
  323. package/dist/host/summary-retry.js.map +1 -1
  324. package/dist/main.d.ts.map +1 -1
  325. package/dist/main.js +94 -58
  326. package/dist/main.js.map +1 -1
  327. package/dist/modes/interactive/components/agents-view.d.ts.map +1 -1
  328. package/dist/modes/interactive/components/agents-view.js +18 -15
  329. package/dist/modes/interactive/components/agents-view.js.map +1 -1
  330. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  331. package/dist/modes/interactive/components/assistant-message.js +6 -5
  332. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  333. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  334. package/dist/modes/interactive/components/bash-execution.js +12 -7
  335. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  336. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
  337. package/dist/modes/interactive/components/bordered-loader.js +2 -1
  338. package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  339. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  340. package/dist/modes/interactive/components/branch-summary-message.js +6 -5
  341. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  342. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  343. package/dist/modes/interactive/components/compaction-summary-message.js +9 -5
  344. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  345. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  346. package/dist/modes/interactive/components/config-selector.js +18 -15
  347. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  348. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  349. package/dist/modes/interactive/components/custom-entry.js +2 -1
  350. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  351. package/dist/modes/interactive/components/dialog-editor.d.ts.map +1 -1
  352. package/dist/modes/interactive/components/dialog-editor.js +5 -4
  353. package/dist/modes/interactive/components/dialog-editor.js.map +1 -1
  354. package/dist/modes/interactive/components/dialog-input.d.ts.map +1 -1
  355. package/dist/modes/interactive/components/dialog-input.js +2 -1
  356. package/dist/modes/interactive/components/dialog-input.js.map +1 -1
  357. package/dist/modes/interactive/components/dialog-selector.d.ts.map +1 -1
  358. package/dist/modes/interactive/components/dialog-selector.js +4 -3
  359. package/dist/modes/interactive/components/dialog-selector.js.map +1 -1
  360. package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
  361. package/dist/modes/interactive/components/first-time-setup.js +11 -10
  362. package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
  363. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  364. package/dist/modes/interactive/components/footer.js +7 -4
  365. package/dist/modes/interactive/components/footer.js.map +1 -1
  366. package/dist/modes/interactive/components/index.d.ts +1 -0
  367. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  368. package/dist/modes/interactive/components/index.js +1 -0
  369. package/dist/modes/interactive/components/index.js.map +1 -1
  370. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  371. package/dist/modes/interactive/components/keybinding-hints.js +3 -2
  372. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  373. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  374. package/dist/modes/interactive/components/login-dialog.js +12 -11
  375. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  376. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
  377. package/dist/modes/interactive/components/mermaid.js +6 -2
  378. package/dist/modes/interactive/components/mermaid.js.map +1 -1
  379. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  380. package/dist/modes/interactive/components/model-selector.js +28 -16
  381. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  382. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  383. package/dist/modes/interactive/components/oauth-selector.js +10 -9
  384. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  385. package/dist/modes/interactive/components/plugin-manager-entry.d.ts.map +1 -1
  386. package/dist/modes/interactive/components/plugin-manager-entry.js +22 -13
  387. package/dist/modes/interactive/components/plugin-manager-entry.js.map +1 -1
  388. package/dist/modes/interactive/components/plugin-selection-entry.d.ts.map +1 -1
  389. package/dist/modes/interactive/components/plugin-selection-entry.js +27 -12
  390. package/dist/modes/interactive/components/plugin-selection-entry.js.map +1 -1
  391. package/dist/modes/interactive/components/queue-manager-selector.d.ts +60 -0
  392. package/dist/modes/interactive/components/queue-manager-selector.d.ts.map +1 -0
  393. package/dist/modes/interactive/components/queue-manager-selector.js +166 -0
  394. package/dist/modes/interactive/components/queue-manager-selector.js.map +1 -0
  395. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  396. package/dist/modes/interactive/components/scoped-models-selector.js +16 -14
  397. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  398. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  399. package/dist/modes/interactive/components/session-selector.js +43 -31
  400. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  401. package/dist/modes/interactive/components/settings-selector.d.ts +2 -0
  402. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  403. package/dist/modes/interactive/components/settings-selector.js +113 -96
  404. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  405. package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
  406. package/dist/modes/interactive/components/settings-submenu.js +5 -4
  407. package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
  408. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
  409. package/dist/modes/interactive/components/show-images-selector.js +3 -2
  410. package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
  411. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  412. package/dist/modes/interactive/components/skill-invocation-message.js +4 -3
  413. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  414. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  415. package/dist/modes/interactive/components/status-indicator.js +14 -5
  416. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  417. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
  418. package/dist/modes/interactive/components/theme-selector.js +2 -1
  419. package/dist/modes/interactive/components/theme-selector.js.map +1 -1
  420. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  421. package/dist/modes/interactive/components/thinking-selector.js +11 -4
  422. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  423. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  424. package/dist/modes/interactive/components/tool-execution.js +8 -3
  425. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  426. package/dist/modes/interactive/components/tree-list.d.ts.map +1 -1
  427. package/dist/modes/interactive/components/tree-list.js +7 -6
  428. package/dist/modes/interactive/components/tree-list.js.map +1 -1
  429. package/dist/modes/interactive/components/tree-render.d.ts.map +1 -1
  430. package/dist/modes/interactive/components/tree-render.js +28 -23
  431. package/dist/modes/interactive/components/tree-render.js.map +1 -1
  432. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  433. package/dist/modes/interactive/components/tree-selector.js +9 -7
  434. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  435. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  436. package/dist/modes/interactive/components/user-message-selector.js +5 -4
  437. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  438. package/dist/modes/interactive/components/workflow-view.d.ts.map +1 -1
  439. package/dist/modes/interactive/components/workflow-view.js +36 -21
  440. package/dist/modes/interactive/components/workflow-view.js.map +1 -1
  441. package/dist/modes/interactive/external-editor.d.ts.map +1 -1
  442. package/dist/modes/interactive/external-editor.js +2 -1
  443. package/dist/modes/interactive/external-editor.js.map +1 -1
  444. package/dist/modes/interactive/interactive-auth.d.ts.map +1 -1
  445. package/dist/modes/interactive/interactive-auth.js +71 -40
  446. package/dist/modes/interactive/interactive-auth.js.map +1 -1
  447. package/dist/modes/interactive/interactive-commands.d.ts +1 -0
  448. package/dist/modes/interactive/interactive-commands.d.ts.map +1 -1
  449. package/dist/modes/interactive/interactive-commands.js +3 -0
  450. package/dist/modes/interactive/interactive-commands.js.map +1 -1
  451. package/dist/modes/interactive/interactive-dialog-ui.d.ts.map +1 -1
  452. package/dist/modes/interactive/interactive-dialog-ui.js +5 -5
  453. package/dist/modes/interactive/interactive-dialog-ui.js.map +1 -1
  454. package/dist/modes/interactive/interactive-format.d.ts.map +1 -1
  455. package/dist/modes/interactive/interactive-format.js +34 -18
  456. package/dist/modes/interactive/interactive-format.js.map +1 -1
  457. package/dist/modes/interactive/interactive-helpers.d.ts.map +1 -1
  458. package/dist/modes/interactive/interactive-helpers.js +7 -2
  459. package/dist/modes/interactive/interactive-helpers.js.map +1 -1
  460. package/dist/modes/interactive/interactive-mode.d.ts +4 -1
  461. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  462. package/dist/modes/interactive/interactive-mode.js +327 -243
  463. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  464. package/dist/modes/interactive/interactive-selectors.d.ts +9 -0
  465. package/dist/modes/interactive/interactive-selectors.d.ts.map +1 -1
  466. package/dist/modes/interactive/interactive-selectors.js +79 -25
  467. package/dist/modes/interactive/interactive-selectors.js.map +1 -1
  468. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
  469. package/dist/modes/interactive/theme/theme-controller.js +5 -1
  470. package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
  471. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  472. package/dist/modes/interactive/theme/theme.js +26 -23
  473. package/dist/modes/interactive/theme/theme.js.map +1 -1
  474. package/dist/modes/json-event.d.ts.map +1 -1
  475. package/dist/modes/json-event.js +3 -2
  476. package/dist/modes/json-event.js.map +1 -1
  477. package/dist/modes/print-mode.d.ts.map +1 -1
  478. package/dist/modes/print-mode.js +3 -2
  479. package/dist/modes/print-mode.js.map +1 -1
  480. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  481. package/dist/modes/rpc/rpc-client.js +3 -2
  482. package/dist/modes/rpc/rpc-client.js.map +1 -1
  483. package/dist/package-manager-cli.d.ts.map +1 -1
  484. package/dist/package-manager-cli.js +28 -13
  485. package/dist/package-manager-cli.js.map +1 -1
  486. package/dist/plugins/ecosystem/catalog.d.ts.map +1 -1
  487. package/dist/plugins/ecosystem/catalog.js +3 -2
  488. package/dist/plugins/ecosystem/catalog.js.map +1 -1
  489. package/dist/plugins/ecosystem/cli.d.ts.map +1 -1
  490. package/dist/plugins/ecosystem/cli.js +2 -1
  491. package/dist/plugins/ecosystem/cli.js.map +1 -1
  492. package/dist/plugins/ecosystem/default-plugin-market.d.ts.map +1 -1
  493. package/dist/plugins/ecosystem/default-plugin-market.js +3 -2
  494. package/dist/plugins/ecosystem/default-plugin-market.js.map +1 -1
  495. package/dist/plugins/ecosystem/distribution.d.ts.map +1 -1
  496. package/dist/plugins/ecosystem/distribution.js +2 -1
  497. package/dist/plugins/ecosystem/distribution.js.map +1 -1
  498. package/dist/plugins/ecosystem/installer.d.ts.map +1 -1
  499. package/dist/plugins/ecosystem/installer.js +3 -2
  500. package/dist/plugins/ecosystem/installer.js.map +1 -1
  501. package/dist/plugins/ecosystem/node-disk-registry-source.d.ts.map +1 -1
  502. package/dist/plugins/ecosystem/node-disk-registry-source.js +20 -17
  503. package/dist/plugins/ecosystem/node-disk-registry-source.js.map +1 -1
  504. package/dist/plugins/ecosystem/node-distribution-host.d.ts.map +1 -1
  505. package/dist/plugins/ecosystem/node-distribution-host.js +35 -34
  506. package/dist/plugins/ecosystem/node-distribution-host.js.map +1 -1
  507. package/dist/plugins/ecosystem/node-npm-registry-source.d.ts.map +1 -1
  508. package/dist/plugins/ecosystem/node-npm-registry-source.js +35 -34
  509. package/dist/plugins/ecosystem/node-npm-registry-source.js.map +1 -1
  510. package/dist/plugins/ecosystem/node-package-install-host.d.ts.map +1 -1
  511. package/dist/plugins/ecosystem/node-package-install-host.js +9 -8
  512. package/dist/plugins/ecosystem/node-package-install-host.js.map +1 -1
  513. package/dist/plugins/ecosystem/node-package-install-persistence.d.ts.map +1 -1
  514. package/dist/plugins/ecosystem/node-package-install-persistence.js +4 -3
  515. package/dist/plugins/ecosystem/node-package-install-persistence.js.map +1 -1
  516. package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts.map +1 -1
  517. package/dist/plugins/ecosystem/node-plugin-bootstrap.js +21 -5
  518. package/dist/plugins/ecosystem/node-plugin-bootstrap.js.map +1 -1
  519. package/dist/plugins/ecosystem/node-plugin-trust-root.d.ts.map +1 -1
  520. package/dist/plugins/ecosystem/node-plugin-trust-root.js +10 -9
  521. package/dist/plugins/ecosystem/node-plugin-trust-root.js.map +1 -1
  522. package/dist/plugins/ecosystem/node-registry-source.d.ts.map +1 -1
  523. package/dist/plugins/ecosystem/node-registry-source.js +31 -30
  524. package/dist/plugins/ecosystem/node-registry-source.js.map +1 -1
  525. package/dist/plugins/ecosystem/node-release-package-source.d.ts.map +1 -1
  526. package/dist/plugins/ecosystem/node-release-package-source.js +30 -29
  527. package/dist/plugins/ecosystem/node-release-package-source.js.map +1 -1
  528. package/dist/plugins/ecosystem/node-tar-writer.d.ts.map +1 -1
  529. package/dist/plugins/ecosystem/node-tar-writer.js +11 -10
  530. package/dist/plugins/ecosystem/node-tar-writer.js.map +1 -1
  531. package/dist/plugins/ecosystem/node-url-package-source.d.ts.map +1 -1
  532. package/dist/plugins/ecosystem/node-url-package-source.js +21 -20
  533. package/dist/plugins/ecosystem/node-url-package-source.js.map +1 -1
  534. package/dist/plugins/ecosystem/plugin-acquisition.d.ts.map +1 -1
  535. package/dist/plugins/ecosystem/plugin-acquisition.js +3 -2
  536. package/dist/plugins/ecosystem/plugin-acquisition.js.map +1 -1
  537. package/dist/plugins/ecosystem/registry-cli-adapter.d.ts.map +1 -1
  538. package/dist/plugins/ecosystem/registry-cli-adapter.js +2 -1
  539. package/dist/plugins/ecosystem/registry-cli-adapter.js.map +1 -1
  540. package/dist/plugins/ecosystem/registry.d.ts.map +1 -1
  541. package/dist/plugins/ecosystem/registry.js +35 -32
  542. package/dist/plugins/ecosystem/registry.js.map +1 -1
  543. package/dist/plugins/ecosystem/resolver.d.ts.map +1 -1
  544. package/dist/plugins/ecosystem/resolver.js +3 -2
  545. package/dist/plugins/ecosystem/resolver.js.map +1 -1
  546. package/dist/plugins/ecosystem/selection-store.d.ts.map +1 -1
  547. package/dist/plugins/ecosystem/selection-store.js +11 -10
  548. package/dist/plugins/ecosystem/selection-store.js.map +1 -1
  549. package/dist/plugins/ecosystem/selection.d.ts.map +1 -1
  550. package/dist/plugins/ecosystem/selection.js +8 -7
  551. package/dist/plugins/ecosystem/selection.js.map +1 -1
  552. package/dist/plugins/ecosystem/state.d.ts.map +1 -1
  553. package/dist/plugins/ecosystem/state.js +24 -23
  554. package/dist/plugins/ecosystem/state.js.map +1 -1
  555. package/dist/plugins/ecosystem/updates.d.ts.map +1 -1
  556. package/dist/plugins/ecosystem/updates.js +5 -4
  557. package/dist/plugins/ecosystem/updates.js.map +1 -1
  558. package/dist/plugins/mcp-http.d.ts +0 -17
  559. package/dist/plugins/mcp-http.d.ts.map +1 -1
  560. package/dist/plugins/mcp-http.js +30 -7
  561. package/dist/plugins/mcp-http.js.map +1 -1
  562. package/dist/plugins/plugin-supervisor.d.ts.map +1 -1
  563. package/dist/plugins/plugin-supervisor.js +19 -1
  564. package/dist/plugins/plugin-supervisor.js.map +1 -1
  565. package/dist/profile/first-roles.d.ts.map +1 -1
  566. package/dist/profile/first-roles.js +10 -1
  567. package/dist/profile/first-roles.js.map +1 -1
  568. package/dist/profile/goal-plugin.d.ts.map +1 -1
  569. package/dist/profile/goal-plugin.js +24 -5
  570. package/dist/profile/goal-plugin.js.map +1 -1
  571. package/dist/profile/identity.d.ts.map +1 -1
  572. package/dist/profile/identity.js +7 -6
  573. package/dist/profile/identity.js.map +1 -1
  574. package/dist/profile/lock.d.ts.map +1 -1
  575. package/dist/profile/lock.js +15 -1
  576. package/dist/profile/lock.js.map +1 -1
  577. package/dist/profile/plan-plugin.d.ts.map +1 -1
  578. package/dist/profile/plan-plugin.js +26 -13
  579. package/dist/profile/plan-plugin.js.map +1 -1
  580. package/dist/profile/plugin-profiles.d.ts.map +1 -1
  581. package/dist/profile/plugin-profiles.js +2 -1
  582. package/dist/profile/plugin-profiles.js.map +1 -1
  583. package/dist/profile/policy-manifest.d.ts.map +1 -1
  584. package/dist/profile/policy-manifest.js +5 -4
  585. package/dist/profile/policy-manifest.js.map +1 -1
  586. package/dist/profile/profile-registry.d.ts +0 -12
  587. package/dist/profile/profile-registry.d.ts.map +1 -1
  588. package/dist/profile/profile-registry.js +14 -1
  589. package/dist/profile/profile-registry.js.map +1 -1
  590. package/dist/profile/role-catalog.d.ts +0 -1
  591. package/dist/profile/role-catalog.d.ts.map +1 -1
  592. package/dist/profile/role-catalog.js +17 -15
  593. package/dist/profile/role-catalog.js.map +1 -1
  594. package/dist/profile/role-orchestrator.d.ts.map +1 -1
  595. package/dist/profile/role-orchestrator.js +8 -7
  596. package/dist/profile/role-orchestrator.js.map +1 -1
  597. package/dist/profile/role-runner.d.ts.map +1 -1
  598. package/dist/profile/role-runner.js +3 -2
  599. package/dist/profile/role-runner.js.map +1 -1
  600. package/dist/profile/root-facade.d.ts.map +1 -1
  601. package/dist/profile/root-facade.js +2 -1
  602. package/dist/profile/root-facade.js.map +1 -1
  603. package/dist/profile/skill-discovery-wiring.d.ts.map +1 -1
  604. package/dist/profile/skill-discovery-wiring.js +7 -2
  605. package/dist/profile/skill-discovery-wiring.js.map +1 -1
  606. package/dist/profile/state-store.d.ts.map +1 -1
  607. package/dist/profile/state-store.js +13 -9
  608. package/dist/profile/state-store.js.map +1 -1
  609. package/dist/profile/todo-plugin.d.ts.map +1 -1
  610. package/dist/profile/todo-plugin.js +9 -4
  611. package/dist/profile/todo-plugin.js.map +1 -1
  612. package/dist/profiles/builtin-suites.d.ts +13 -6
  613. package/dist/profiles/builtin-suites.d.ts.map +1 -1
  614. package/dist/profiles/builtin-suites.js +15 -6
  615. package/dist/profiles/builtin-suites.js.map +1 -1
  616. package/dist/profiles/suite-loader.d.ts +25 -1
  617. package/dist/profiles/suite-loader.d.ts.map +1 -1
  618. package/dist/profiles/suite-loader.js +34 -9
  619. package/dist/profiles/suite-loader.js.map +1 -1
  620. package/dist/remote/server-entry.d.ts.map +1 -1
  621. package/dist/remote/server-entry.js +3 -2
  622. package/dist/remote/server-entry.js.map +1 -1
  623. package/dist/remote/session-source.d.ts.map +1 -1
  624. package/dist/remote/session-source.js +8 -4
  625. package/dist/remote/session-source.js.map +1 -1
  626. package/dist/share/session-share.d.ts.map +1 -1
  627. package/dist/share/session-share.js +14 -2
  628. package/dist/share/session-share.js.map +1 -1
  629. package/dist/testing/plugin-testkit.d.ts.map +1 -1
  630. package/dist/testing/plugin-testkit.js +4 -3
  631. package/dist/testing/plugin-testkit.js.map +1 -1
  632. package/dist/testing/runtime-delivery-queue.d.ts.map +1 -1
  633. package/dist/testing/runtime-delivery-queue.js +2 -1
  634. package/dist/testing/runtime-delivery-queue.js.map +1 -1
  635. package/dist/testing/session-plugin-testkit.d.ts.map +1 -1
  636. package/dist/testing/session-plugin-testkit.js +10 -7
  637. package/dist/testing/session-plugin-testkit.js.map +1 -1
  638. package/dist/utils/ansi.d.ts.map +1 -1
  639. package/dist/utils/ansi.js +2 -1
  640. package/dist/utils/ansi.js.map +1 -1
  641. package/dist/utils/clipboard.d.ts.map +1 -1
  642. package/dist/utils/clipboard.js +7 -6
  643. package/dist/utils/clipboard.js.map +1 -1
  644. package/dist/utils/image-resize-worker.d.ts.map +1 -1
  645. package/dist/utils/image-resize-worker.js +3 -2
  646. package/dist/utils/image-resize-worker.js.map +1 -1
  647. package/dist/utils/shell.d.ts.map +1 -1
  648. package/dist/utils/shell.js +9 -8
  649. package/dist/utils/shell.js.map +1 -1
  650. package/dist/utils/tools-manager.d.ts.map +1 -1
  651. package/dist/utils/tools-manager.js +23 -13
  652. package/dist/utils/tools-manager.js.map +1 -1
  653. package/dist/utils/version-check.d.ts.map +1 -1
  654. package/dist/utils/version-check.js +5 -1
  655. package/dist/utils/version-check.js.map +1 -1
  656. package/docs/keybindings.md +3 -0
  657. package/docs/quickstart.md +1 -1
  658. package/docs/settings.md +1 -0
  659. package/docs/terminal-setup.md +2 -3
  660. package/docs/usage.md +6 -5
  661. package/examples/extensions/with-deps/package-lock.json +2 -2
  662. package/examples/extensions/with-deps/package.json +1 -1
  663. package/examples/extensions/with-deps/plugin.json +1 -1
  664. package/package.json +1 -1
  665. package/dist/bundle/chunks/chunk-EALJ5DDX.js +0 -1452
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-view.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/workflow-view.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAkB,SAAS,EAAE,cAAc,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEpG,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAm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AC,IAAI,OAAO,KAAK,GAAG,EAAE,CAAC;YACpE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACf,CAAC;aAAM,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,iBAAiB,CAAC,IAAI,OAAO,KAAK,GAAG,EAAE,CAAC;YACtE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACd,CAAC;aAAM,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,mBAAmB,CAAC,EAAE,CAAC;YACrD,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;QAC9C,CAAC;aAAM,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,qBAAqB,CAAC,EAAE,CAAC;YACvD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;QAC7C,CAAC;aAAM,IAAI,OAAO,KAAK,GAAG,EAAE,CAAC;YAC5B,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACzB,CAAC;aAAM,IAAI,OAAO,KAAK,GAAG,EAAE,CAAC;YAC5B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACxB,CAAC;aAAM,IAAI,OAAO,KAAK,GAAG,EAAE,CAAC;YAC5B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACtB,CAAC;aAAM,IAAI,OAAO,KAAK,GAAG,EAAE,CAAC;YAC5B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACxB,CAAC;IAAA,CACD;CACD","sourcesContent":["/**\n * Workflow overlay view (§9 L2/L3 of docs/design/工作流编排插件设计.md).\n *\n * Read-only panorama (L2) and transition stream (L3) rendered from the\n * session's `workflow.state` / `workflow.transition` custom entries — the\n * same isomorphic read the footer performs on `goal.state`, so the plugin\n * does not need to be present and this module never imports plugin code.\n * Waiting-condition labels mirror the engine's `computeWaitingOn` order\n * (active-limit precedes write-scope conflict); plan lookups read the latest\n * `plan.state` snapshot the same way.\n *\n * Operations are never executed here: approve/reject/skip/cancel forward an\n * action text (e.g. `approve stage s2-review`) to the conversation input and\n * the main agent drives it through workflow_advance — rendering and execution\n * stay separated (设计 §9 L2 \"转发到对话\").\n */\n\nimport { type Component, Container, getKeybindings, Text, truncateToWidth } from \"@agent-forge/tui\";\nimport type { SessionEntry } from \"../../../core/session-manager.ts\";\nimport { theme } from \"../theme/theme.ts\";\nimport { DynamicBorder } from \"./dynamic-border.ts\";\nimport { keyHint, rawKeyHint } from \"./keybinding-hints.ts\";\n\n// ---------------------------------------------------------------------------\n// View model (pure; exported for tests)\n// ---------------------------------------------------------------------------\n\ntype StageStatus = \"pending\" | \"active\" | \"awaiting_review\" | \"completed\" | \"failed\" | \"skipped\";\n\nconst STAGE_STATUSES: readonly string[] = [\"pending\", \"active\", \"awaiting_review\", \"completed\", \"failed\", \"skipped\"];\n\n/** One selectable stage row of the L2 panorama tree. */\nexport interface WorkflowStageRow {\n\tworkflowId: string;\n\tstageId: string;\n\ttitle: string;\n\tdepth: number;\n\tstatus: StageStatus;\n\t/** §8.1 waiting-condition label, or null when nothing blocks the stage. */\n\twaitingOn: string | null;\n\tattempts: number;\n\tevidenceCount: number;\n\t/** Conflicting active write stage id (write-scope marker), or null. */\n\tscopeConflict: string | null;\n\t/** Diamond edge collapsed to a back-reference instead of a duplicate subtree. */\n\tbackReference: boolean;\n}\n\n/** One workflow block of the L2 panorama. */\nexport interface WorkflowBlock {\n\tworkflowId: string;\n\ttitle: string;\n\tstatus: string;\n\trevision: number;\n\tgoalId: string | undefined;\n\tactiveCount: number;\n\tmaxActiveStages: number;\n\tretreatCount: number;\n\tmaxRetreats: number;\n\tdiagnostics: string[];\n\tstages: WorkflowStageRow[];\n}\n\n/** One L3 transition row (already newest-first, capped by the builder). */\nexport interface WorkflowTransitionRow {\n\trevision: number;\n\tworkflowId: string;\n\tstageId: string | undefined;\n\tfrom: string;\n\tto: string;\n\ttrigger: string;\n\tcode: string;\n\tmessage: string;\n\tdetail: string | undefined;\n}\n\nexport interface WorkflowViewModel {\n\t/** Undefined when the session has no `workflow.state` entry at all. */\n\tpanorama: WorkflowBlock[] | undefined;\n\ttransitions: WorkflowTransitionRow[];\n\t/** Newest non-terminal workflow id (footer's pick), for workflow-level actions. */\n\tactiveWorkflowId: string | undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction stringOrUndefined(value: unknown): string | undefined {\n\treturn typeof value === \"string\" ? value : undefined;\n}\n\ninterface ParsedStageSpec {\n\tid: string;\n\ttitle: string;\n\tdependsOn: string[];\n\tplanId: string | undefined;\n\tkind: \"read\" | \"write\";\n\tscope: string[] | undefined;\n\tacceptanceIds: string[];\n}\n\ninterface ParsedStageRuntime {\n\tstageId: string;\n\tstatus: StageStatus;\n\tattempts: number;\n\tevidenceCount: number;\n\tcoveredAcceptanceIds: Set<string>;\n}\n\ninterface ParsedWorkflow {\n\tid: string;\n\ttitle: string;\n\tstatus: string;\n\trevision: number;\n\tgoalId: string | undefined;\n\tmaxActiveStages: number;\n\tmaxRetreats: number;\n\tretreatCount: number;\n\tdiagnostics: string[];\n\tstages: ParsedStageSpec[];\n\truntime: Map<string, ParsedStageRuntime>;\n}\n\nfunction parseStageSpec(value: unknown): ParsedStageSpec | undefined {\n\tif (!isRecord(value)) return undefined;\n\tconst id = stringOrUndefined(value.id);\n\tif (id === undefined) return undefined;\n\tconst dependsOn = Array.isArray(value.dependsOn) ? value.dependsOn.filter(isString) : [];\n\tconst acceptance =\n\t\tisRecord(value.objective) && Array.isArray(value.objective.acceptance) ? value.objective.acceptance : [];\n\tconst scope = Array.isArray(value.scope) ? value.scope.filter(isString) : undefined;\n\treturn {\n\t\tid,\n\t\ttitle: stringOrUndefined(value.title) ?? id,\n\t\tdependsOn,\n\t\tplanId: stringOrUndefined(value.planId),\n\t\tkind: value.kind === \"read\" ? \"read\" : \"write\",\n\t\tscope: scope !== undefined && scope.length > 0 ? scope : undefined,\n\t\tacceptanceIds: acceptance\n\t\t\t.map((item) => (isRecord(item) ? stringOrUndefined(item.id) : undefined))\n\t\t\t.filter((item): item is string => item !== undefined),\n\t};\n}\n\nfunction isString(value: unknown): value is string {\n\treturn typeof value === \"string\";\n}\n\nfunction parseStageRuntime(value: unknown): ParsedStageRuntime | undefined {\n\tif (!isRecord(value)) return undefined;\n\tconst stageId = stringOrUndefined(value.stageId);\n\tconst status = stringOrUndefined(value.status);\n\tif (stageId === undefined || status === undefined || !STAGE_STATUSES.includes(status)) return undefined;\n\tconst evidence = Array.isArray(value.evidence) ? value.evidence : [];\n\tconst covered = new Set<string>();\n\tlet evidenceCount = 0;\n\tfor (const item of evidence) {\n\t\tif (!isRecord(item)) continue;\n\t\tevidenceCount++;\n\t\tconst acceptanceId = stringOrUndefined(item.acceptanceId);\n\t\tif (acceptanceId !== undefined) covered.add(acceptanceId);\n\t}\n\treturn {\n\t\tstageId,\n\t\tstatus: status as StageStatus,\n\t\tattempts: typeof value.attempts === \"number\" ? value.attempts : 0,\n\t\tevidenceCount,\n\t\tcoveredAcceptanceIds: covered,\n\t};\n}\n\nfunction parseWorkflowRecord(value: unknown): ParsedWorkflow | undefined {\n\tif (!isRecord(value)) return undefined;\n\tconst id = stringOrUndefined(value.id);\n\tconst title = stringOrUndefined(value.title);\n\tconst status = stringOrUndefined(value.status);\n\tif (id === undefined || title === undefined || status === undefined) return undefined;\n\tconst stages: ParsedStageSpec[] = [];\n\tfor (const item of Array.isArray(value.stages) ? value.stages : []) {\n\t\tconst spec = parseStageSpec(item);\n\t\tif (spec !== undefined) stages.push(spec);\n\t}\n\tconst runtime = new Map<string, ParsedStageRuntime>();\n\tfor (const item of Array.isArray(value.runtime) ? value.runtime : []) {\n\t\tconst parsed = parseStageRuntime(item);\n\t\tif (parsed !== undefined) runtime.set(parsed.stageId, parsed);\n\t}\n\tconst diagnostics = Array.isArray(value.diagnostics) ? value.diagnostics.filter(isString) : [];\n\treturn {\n\t\tid,\n\t\ttitle,\n\t\tstatus,\n\t\trevision: typeof value.revision === \"number\" ? value.revision : 0,\n\t\tgoalId: stringOrUndefined(value.goalId),\n\t\tmaxActiveStages: typeof value.maxActiveStages === \"number\" ? value.maxActiveStages : 4,\n\t\tmaxRetreats: typeof value.maxRetreats === \"number\" ? value.maxRetreats : 3,\n\t\tretreatCount: typeof value.retreatCount === \"number\" ? value.retreatCount : 0,\n\t\tdiagnostics,\n\t\tstages,\n\t\truntime,\n\t};\n}\n\n/** Latest `plan.state` snapshot reduced to id -> status (plan-dangling / plan-incomplete labels). */\nfunction parsePlanStatuses(data: unknown): Map<string, string> {\n\tconst statuses = new Map<string, string>();\n\tif (!isRecord(data) || !Array.isArray(data.plans)) return statuses;\n\tfor (const item of data.plans) {\n\t\tif (!isRecord(item)) continue;\n\t\tconst id = stringOrUndefined(item.id);\n\t\tconst status = stringOrUndefined(item.status);\n\t\tif (id !== undefined && status !== undefined) statuses.set(id, status);\n\t}\n\treturn statuses;\n}\n\nfunction parseTransition(value: unknown): WorkflowTransitionRow | undefined {\n\tif (!isRecord(value)) return undefined;\n\tconst workflowId = stringOrUndefined(value.workflowId);\n\tconst from = stringOrUndefined(value.from);\n\tconst to = stringOrUndefined(value.to);\n\tconst reason = isRecord(value.reason) ? value.reason : undefined;\n\tconst code = reason !== undefined ? stringOrUndefined(reason.code) : undefined;\n\tif (\n\t\tworkflowId === undefined ||\n\t\tfrom === undefined ||\n\t\tto === undefined ||\n\t\tcode === undefined ||\n\t\ttypeof value.revision !== \"number\"\n\t) {\n\t\treturn undefined;\n\t}\n\treturn {\n\t\trevision: value.revision,\n\t\tworkflowId,\n\t\tstageId: stringOrUndefined(value.stageId),\n\t\tfrom,\n\t\tto,\n\t\ttrigger: stringOrUndefined(value.trigger) ?? \"tool\",\n\t\tcode,\n\t\tmessage: reason !== undefined ? (stringOrUndefined(reason.message) ?? \"\") : \"\",\n\t\tdetail: reason !== undefined ? stringOrUndefined(reason.detail) : undefined,\n\t};\n}\n\nfunction scopesIntersect(a: string[] | undefined, b: string[] | undefined): boolean {\n\tif (a === undefined || a.length === 0 || b === undefined || b.length === 0) return true;\n\treturn a.some((tag) => b.includes(tag));\n}\n\nfunction findScopeConflict(workflow: ParsedWorkflow, spec: ParsedStageSpec): string | null {\n\tif (spec.kind !== \"write\") return null;\n\tfor (const other of workflow.stages) {\n\t\tif (other.id === spec.id || other.kind !== \"write\") continue;\n\t\tif (workflow.runtime.get(other.id)?.status !== \"active\") continue;\n\t\tif (scopesIntersect(spec.scope, other.scope)) return other.id;\n\t}\n\treturn null;\n}\n\nfunction uncoveredAcceptanceIds(spec: ParsedStageSpec, runtime: ParsedStageRuntime | undefined): string[] {\n\tif (runtime === undefined) return [...spec.acceptanceIds];\n\treturn spec.acceptanceIds.filter((id) => !runtime.coveredAcceptanceIds.has(id));\n}\n\n/**\n * §8.1 waiting-condition label, mirroring the engine's `computeWaitingOn`\n * check order (active-limit precedes write-scope conflict) so the overlay\n * names the same condition the audit stream recorded. Plan lookups use the\n * latest `plan.state` snapshot instead of the engine's live dependency.\n */\nfunction computeWaitingOn(\n\tworkflow: ParsedWorkflow,\n\tspec: ParsedStageSpec,\n\truntime: ParsedStageRuntime | undefined,\n\tplanStatuses: Map<string, string>,\n): string | null {\n\tconst status = runtime?.status ?? \"pending\";\n\tif (status === \"awaiting_review\") return \"review\";\n\tif (status === \"pending\") {\n\t\tif (workflow.status === \"draft\") return \"not-yet-active\";\n\t\tif ((runtime?.attempts ?? 0) > 0) {\n\t\t\tif (spec.acceptanceIds.length === 0) return \"retry-wait\";\n\t\t\treturn `acceptance-missing:[${uncoveredAcceptanceIds(spec, runtime).join(\", \")}]`;\n\t\t}\n\t\tconst incomplete = spec.dependsOn.filter((dep) => {\n\t\t\tconst dependency = workflow.runtime.get(dep)?.status;\n\t\t\treturn dependency !== \"completed\" && dependency !== \"skipped\";\n\t\t});\n\t\tif (incomplete.length > 0) return `deps-incomplete:[${incomplete.join(\", \")}]`;\n\t\tif (spec.planId !== undefined && !planStatuses.has(spec.planId)) return \"plan-dangling\";\n\t\tconst activeCount = [...workflow.runtime.values()].filter((item) => item.status === \"active\").length;\n\t\tif (activeCount >= workflow.maxActiveStages) return \"active-limit\";\n\t\tconst conflict = findScopeConflict(workflow, spec);\n\t\tif (conflict !== null) return `write-scope-conflict:[${conflict}]`;\n\t\treturn \"not-yet-active\";\n\t}\n\tif (status === \"active\") {\n\t\tif (spec.planId === undefined) return null;\n\t\tconst planStatus = planStatuses.get(spec.planId);\n\t\tif (planStatus === undefined) return \"plan-dangling\";\n\t\tif (planStatus !== \"completed\") return \"plan-incomplete\";\n\t\treturn null;\n\t}\n\treturn null;\n}\n\nfunction buildStageRows(workflow: ParsedWorkflow, planStatuses: Map<string, string>): WorkflowStageRow[] {\n\tconst rows: WorkflowStageRow[] = [];\n\tconst visited = new Set<string>();\n\tconst walk = (spec: ParsedStageSpec, depth: number): void => {\n\t\tif (visited.has(spec.id)) {\n\t\t\trows.push({\n\t\t\t\tworkflowId: workflow.id,\n\t\t\t\tstageId: spec.id,\n\t\t\t\ttitle: spec.title,\n\t\t\t\tdepth,\n\t\t\t\tstatus: workflow.runtime.get(spec.id)?.status ?? \"pending\",\n\t\t\t\twaitingOn: null,\n\t\t\t\tattempts: 0,\n\t\t\t\tevidenceCount: 0,\n\t\t\t\tscopeConflict: null,\n\t\t\t\tbackReference: true,\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tvisited.add(spec.id);\n\t\tconst runtime = workflow.runtime.get(spec.id);\n\t\trows.push({\n\t\t\tworkflowId: workflow.id,\n\t\t\tstageId: spec.id,\n\t\t\ttitle: spec.title,\n\t\t\tdepth,\n\t\t\tstatus: runtime?.status ?? \"pending\",\n\t\t\twaitingOn: computeWaitingOn(workflow, spec, runtime, planStatuses),\n\t\t\tattempts: runtime?.attempts ?? 0,\n\t\t\tevidenceCount: runtime?.evidenceCount ?? 0,\n\t\t\tscopeConflict: findScopeConflict(workflow, spec),\n\t\t\tbackReference: false,\n\t\t});\n\t\tfor (const child of workflow.stages.filter((item) => item.dependsOn.includes(spec.id))) {\n\t\t\twalk(child, depth + 1);\n\t\t}\n\t};\n\tfor (const root of workflow.stages.filter((item) => item.dependsOn.length === 0)) {\n\t\twalk(root, 0);\n\t}\n\t// Stages unreachable from a root (defensive; the engine validates acyclic\n\t// graphs) still render at the top level, mirroring the L1 text panorama.\n\tfor (const spec of workflow.stages) {\n\t\tif (!visited.has(spec.id)) walk(spec, 0);\n\t}\n\treturn rows;\n}\n\n/**\n * Build the L2/L3 view model from session entries: the latest\n * `workflow.state` snapshot plus the `workflow.transition` audit stream\n * (newest first, capped). Malformed records are skipped, never thrown.\n */\nexport function buildWorkflowViewModel(entries: readonly SessionEntry[], transitionLimit = 30): WorkflowViewModel {\n\tlet stateData: unknown;\n\tlet hasStateEntry = false;\n\tlet planData: unknown;\n\tconst transitions: WorkflowTransitionRow[] = [];\n\tfor (const entry of entries) {\n\t\tif (entry.type !== \"custom\") continue;\n\t\tif (entry.customType === \"workflow.state\") {\n\t\t\thasStateEntry = true;\n\t\t\tstateData = entry.data;\n\t\t} else if (entry.customType === \"plan.state\") {\n\t\t\tplanData = entry.data;\n\t\t} else if (entry.customType === \"workflow.transition\") {\n\t\t\tconst parsed = parseTransition(entry.data);\n\t\t\tif (parsed !== undefined) transitions.push(parsed);\n\t\t}\n\t}\n\n\tconst planStatuses = parsePlanStatuses(planData);\n\tlet blocks: WorkflowBlock[] | undefined;\n\tif (hasStateEntry) {\n\t\tconst workflows = isRecord(stateData) && Array.isArray(stateData.workflows) ? stateData.workflows : [];\n\t\tblocks = workflows\n\t\t\t.map((item) => {\n\t\t\t\tconst parsed = parseWorkflowRecord(item);\n\t\t\t\tif (parsed === undefined) return undefined;\n\t\t\t\treturn {\n\t\t\t\t\tworkflowId: parsed.id,\n\t\t\t\t\ttitle: parsed.title,\n\t\t\t\t\tstatus: parsed.status,\n\t\t\t\t\trevision: parsed.revision,\n\t\t\t\t\tgoalId: parsed.goalId,\n\t\t\t\t\tactiveCount: [...parsed.runtime.values()].filter((item) => item.status === \"active\").length,\n\t\t\t\t\tmaxActiveStages: parsed.maxActiveStages,\n\t\t\t\t\tretreatCount: parsed.retreatCount,\n\t\t\t\t\tmaxRetreats: parsed.maxRetreats,\n\t\t\t\t\tdiagnostics: [...parsed.diagnostics],\n\t\t\t\t\tstages: buildStageRows(parsed, planStatuses),\n\t\t\t\t} satisfies WorkflowBlock;\n\t\t\t})\n\t\t\t.filter((block): block is WorkflowBlock => block !== undefined);\n\t}\n\n\tconst activeRecord = blocks?.filter((block) => block.status === \"draft\" || block.status === \"running\").at(-1);\n\tconst activeWorkflowId = activeRecord?.workflowId ?? blocks?.at(-1)?.workflowId;\n\n\treturn {\n\t\tpanorama: blocks,\n\t\ttransitions: transitions.slice(-transitionLimit).reverse(),\n\t\tactiveWorkflowId,\n\t};\n}\n\n/** Forwarded action vocabulary (§9 L2): rendered here, executed via workflow_advance by the main agent. */\nexport type WorkflowForwardAction = \"approve\" | \"reject\" | \"skip\" | \"cancel\";\n\n/** Action text injected into the conversation input, e.g. `approve stage s2-review`. */\nexport function buildWorkflowActionText(\n\taction: WorkflowForwardAction,\n\tworkflowId: string,\n\tstageId: string | undefined,\n): string {\n\tif (action === \"cancel\" || stageId === undefined) return `cancel workflow ${workflowId}`;\n\treturn `${action} stage ${stageId}`;\n}\n\n// ---------------------------------------------------------------------------\n// Component (L2 panorama + L3 log)\n// ---------------------------------------------------------------------------\n\n/** Selectable row shape used by the component; stage rows carry action targets. */\ninterface ViewRow {\n\ttext: string;\n\tstage: { workflowId: string; stageId: string } | undefined;\n}\n\nfunction stageStatusColor(status: StageStatus): (text: string) => string {\n\tswitch (status) {\n\t\tcase \"active\":\n\t\t\treturn (text) => theme.fg(\"accent\", text);\n\t\tcase \"awaiting_review\":\n\t\t\treturn (text) => theme.fg(\"warning\", text);\n\t\tcase \"completed\":\n\t\t\treturn (text) => theme.fg(\"success\", text);\n\t\tcase \"failed\":\n\t\t\treturn (text) => theme.fg(\"error\", text);\n\t\tcase \"skipped\":\n\t\t\treturn (text) => theme.fg(\"dim\", text);\n\t\tcase \"pending\":\n\t\t\treturn (text) => theme.fg(\"muted\", text);\n\t}\n}\n\nfunction workflowStatusColor(status: string): (text: string) => string {\n\tif (status === \"running\") return (text) => theme.fg(\"accent\", text);\n\tif (status === \"completed\") return (text) => theme.fg(\"success\", text);\n\tif (status === \"failed\") return (text) => theme.fg(\"error\", text);\n\treturn (text) => theme.fg(\"dim\", text);\n}\n\nfunction transitionCodeColor(code: string): (text: string) => string {\n\tif (code.includes(\"failed\") || code.includes(\"retreat\") || code.includes(\"error\") || code.includes(\"limit\")) {\n\t\treturn (text) => theme.fg(\"error\", text);\n\t}\n\tif (code.includes(\"held\") || code.includes(\"retry\") || code.includes(\"amended\")) {\n\t\treturn (text) => theme.fg(\"warning\", text);\n\t}\n\treturn (text) => theme.fg(\"muted\", text);\n}\n\n/** Renders the visible row window; reads live state from the owning component. */\nclass WorkflowRowsView implements Component {\n\tprivate view: WorkflowViewComponent;\n\n\tconstructor(view: WorkflowViewComponent) {\n\t\tthis.view = view;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\treturn this.view.renderRows(width);\n\t}\n}\n\nexport interface WorkflowViewConfig {\n\t/** Entries provider; rescanned when the array identity or length changes (append-only sessions). */\n\tgetEntries: () => readonly SessionEntry[];\n\t/** Maximum visible rows before the list scrolls. */\n\tmaxRows: number;\n\t/** Request a TUI re-render (used for transient status flashes). */\n\trequestRender?: () => void;\n}\n\nexport class WorkflowViewComponent extends Container {\n\tpublic onClose?: () => void;\n\tpublic onForwardAction?: (text: string) => void;\n\n\tprivate config: WorkflowViewConfig;\n\tprivate mode: \"panorama\" | \"log\" = \"panorama\";\n\tprivate rows: ViewRow[] = [];\n\tprivate selectedIndex = 0;\n\tprivate offset = 0;\n\tprivate titleText: Text;\n\tprivate modeHintText: Text;\n\tprivate helpText: Text;\n\tprivate flashText: Text;\n\tprivate cache: { entries: readonly SessionEntry[]; length: number; model: WorkflowViewModel } | undefined;\n\tprivate flashTimeout: ReturnType<typeof setTimeout> | null = null;\n\n\tconstructor(config: WorkflowViewConfig) {\n\t\tsuper();\n\n\t\tthis.config = config;\n\t\tthis.titleText = new Text(theme.fg(\"accent\", theme.bold(\" Workflow Overview\")), 1, 0);\n\t\tthis.modeHintText = new Text(\"\", 1, 0);\n\t\tthis.helpText = new Text(\"\", 1, 0);\n\t\tthis.flashText = new Text(\"\", 1, 0);\n\t\tthis.updateModeTexts();\n\n\t\tthis.addChild(new DynamicBorder());\n\t\tthis.addChild(this.titleText);\n\t\tthis.addChild(this.modeHintText);\n\t\tthis.addChild(new WorkflowRowsView(this));\n\t\tthis.addChild(this.flashText);\n\t\tthis.addChild(this.helpText);\n\t\tthis.addChild(new DynamicBorder());\n\t}\n\n\tdispose(): void {\n\t\tif (this.flashTimeout !== null) {\n\t\t\tclearTimeout(this.flashTimeout);\n\t\t\tthis.flashTimeout = null;\n\t\t}\n\t}\n\n\tprivate updateModeTexts(): void {\n\t\tconst label = this.mode === \"panorama\" ? \"panorama\" : \"transition log (newest first)\";\n\t\tthis.modeHintText.setText(theme.fg(\"dim\", ` ${label}`));\n\t\tthis.helpText.setText(this.buildHelpLine());\n\t}\n\n\tprivate buildHelpLine(): string {\n\t\tconst parts = [rawKeyHint(\"↑↓\", \"move\")];\n\t\tif (this.mode === \"panorama\") {\n\t\t\tparts.push(\n\t\t\t\trawKeyHint(\"tab/l\", \"log\"),\n\t\t\t\trawKeyHint(\"a\", \"approve\"),\n\t\t\t\trawKeyHint(\"r\", \"reject\"),\n\t\t\t\trawKeyHint(\"s\", \"skip\"),\n\t\t\t\trawKeyHint(\"c\", \"cancel\"),\n\t\t\t);\n\t\t} else {\n\t\t\tparts.push(rawKeyHint(\"tab/l\", \"panorama\"));\n\t\t}\n\t\tparts.push(keyHint(\"tui.select.cancel\", \"close\"));\n\t\treturn ` ${parts.join(\" \")}`;\n\t}\n\n\tprivate getModel(): WorkflowViewModel {\n\t\tconst entries = this.config.getEntries();\n\t\tif (this.cache && this.cache.entries === entries && this.cache.length === entries.length) {\n\t\t\treturn this.cache.model;\n\t\t}\n\t\tconst model = buildWorkflowViewModel(entries);\n\t\tthis.cache = { entries, length: entries.length, model };\n\t\treturn model;\n\t}\n\n\tprivate buildRows(model: WorkflowViewModel): ViewRow[] {\n\t\tconst rows: ViewRow[] = [];\n\t\tif (this.mode === \"log\") {\n\t\t\tif (model.transitions.length === 0) {\n\t\t\t\trows.push({ text: \" no workflow transitions recorded\", stage: undefined });\n\t\t\t\treturn rows;\n\t\t\t}\n\t\t\tfor (const transition of model.transitions) {\n\t\t\t\tconst stage = transition.stageId !== undefined ? `/${transition.stageId}` : \"\";\n\t\t\t\tconst detail = transition.detail !== undefined ? ` — ${transition.detail}` : \"\";\n\t\t\t\tconst code = transitionCodeColor(transition.code)(transition.code);\n\t\t\t\trows.push({\n\t\t\t\t\ttext: ` #${transition.revision} ${transition.workflowId}${stage} ${transition.from} -> ${transition.to} [${transition.trigger}] ${code}: ${transition.message}${detail}`,\n\t\t\t\t\tstage: undefined,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn rows;\n\t\t}\n\n\t\tconst blocks = model.panorama;\n\t\tif (blocks === undefined) {\n\t\t\trows.push({ text: \" no workflow.state entry in this session\", stage: undefined });\n\t\t\treturn rows;\n\t\t}\n\t\tif (blocks.length === 0) {\n\t\t\trows.push({ text: \" no workflows in this session; create one with workflow_set\", stage: undefined });\n\t\t\treturn rows;\n\t\t}\n\t\tfor (const block of blocks) {\n\t\t\tconst status = workflowStatusColor(block.status)(block.status);\n\t\t\trows.push({\n\t\t\t\ttext: ` workflow \"${block.title}\" (${block.workflowId}) — ${status} · revision ${block.revision} · active ${block.activeCount}/${block.maxActiveStages} · retreats ${block.retreatCount}/${block.maxRetreats}`,\n\t\t\t\tstage: undefined,\n\t\t\t});\n\t\t\tif (block.goalId !== undefined) {\n\t\t\t\trows.push({ text: ` goal: ${block.goalId}`, stage: undefined });\n\t\t\t}\n\t\t\tfor (const stage of block.stages) {\n\t\t\t\trows.push({\n\t\t\t\t\ttext: this.formatStageRow(stage),\n\t\t\t\t\tstage: { workflowId: block.workflowId, stageId: stage.stageId },\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (block.diagnostics.length > 0) {\n\t\t\t\trows.push({ text: \" diagnostics:\", stage: undefined });\n\t\t\t\tfor (const diagnostic of block.diagnostics) {\n\t\t\t\t\trows.push({ text: theme.fg(\"warning\", ` - ${diagnostic}`), stage: undefined });\n\t\t\t\t}\n\t\t\t}\n\t\t\trows.push({ text: \"\", stage: undefined });\n\t\t}\n\t\treturn rows;\n\t}\n\n\tprivate formatStageRow(stage: WorkflowStageRow): string {\n\t\tconst pad = \" \".repeat(stage.depth + 1);\n\t\tif (stage.backReference) {\n\t\t\treturn `${pad} -> ${stage.stageId} (shown above)`;\n\t\t}\n\t\tconst bits = [`- ${stage.stageId} [${stageStatusColor(stage.status)(stage.status)}] ${stage.title}`];\n\t\tif (stage.waitingOn !== null) bits.push(theme.fg(\"dim\", `— waiting: ${stage.waitingOn}`));\n\t\tif (stage.attempts > 0) bits.push(theme.fg(\"dim\", `· attempts ${stage.attempts}`));\n\t\tif (stage.evidenceCount > 0) bits.push(theme.fg(\"dim\", `· evidence ${stage.evidenceCount}`));\n\t\tif (stage.scopeConflict !== null) {\n\t\t\tbits.push(theme.fg(\"warning\", `⚠ scope:${stage.scopeConflict}`));\n\t\t}\n\t\treturn `${pad}${bits.join(\" \")}`;\n\t}\n\n\t/** Rows are rebuilt lazily on access; the key couples rebuild + selection restore. */\n\tprivate syncRows(): void {\n\t\tconst model = this.getModel();\n\t\tconst previous = this.rows[this.selectedIndex]?.stage;\n\t\tthis.rows = this.buildRows(model);\n\t\tif (previous !== undefined) {\n\t\t\tconst restored = this.rows.findIndex((row) => row.stage?.stageId === previous.stageId);\n\t\t\tif (restored !== -1) this.selectedIndex = restored;\n\t\t}\n\t\tif (this.selectedIndex >= this.rows.length) this.selectedIndex = Math.max(0, this.rows.length - 1);\n\t\tthis.clampOffset();\n\t}\n\n\tprivate clampOffset(): void {\n\t\tconst maxRows = Math.max(1, this.config.maxRows);\n\t\tif (this.selectedIndex < this.offset) this.offset = this.selectedIndex;\n\t\tif (this.selectedIndex >= this.offset + maxRows) this.offset = this.selectedIndex - maxRows + 1;\n\t\tif (this.offset < 0) this.offset = 0;\n\t}\n\n\trenderRows(width: number): string[] {\n\t\tthis.syncRows();\n\t\tconst maxRows = Math.max(1, this.config.maxRows);\n\t\tconst lines: string[] = [];\n\t\tfor (let index = this.offset; index < Math.min(this.rows.length, this.offset + maxRows); index++) {\n\t\t\tconst row = this.rows[index];\n\t\t\tif (row === undefined) continue;\n\t\t\tconst selected = index === this.selectedIndex;\n\t\t\tconst prefix = selected ? theme.fg(\"accent\", \"→ \") : \" \";\n\t\t\tlines.push(truncateToWidth(`${prefix}${row.text}`, width));\n\t\t}\n\t\tconst hiddenAbove = this.offset;\n\t\tconst hiddenBelow = this.rows.length - this.offset - maxRows;\n\t\tconst hidden: string[] = [];\n\t\tif (hiddenAbove > 0) hidden.push(`↑${hiddenAbove}`);\n\t\tif (hiddenBelow > 0) hidden.push(`↓${hiddenBelow}`);\n\t\t// Fixed output height (exactly maxRows content rows plus this final\n\t\t// indicator row), the same contract as agents-view renderRows: the\n\t\t// overlay's grid footprint must not change with mode switches or row\n\t\t// counts, or the chat/editor layout boundary moves between frames.\n\t\twhile (lines.length < maxRows) lines.push(truncateToWidth(\" \", width));\n\t\tlines.push(truncateToWidth(hidden.length > 0 ? theme.fg(\"dim\", ` ${hidden.join(\" \")}`) : \" \", width));\n\t\treturn lines;\n\t}\n\n\tprivate move(delta: number): void {\n\t\tif (this.rows.length === 0) return;\n\t\tthis.selectedIndex = Math.min(this.rows.length - 1, Math.max(0, this.selectedIndex + delta));\n\t\tthis.clampOffset();\n\t}\n\n\tprivate flash(message: string): void {\n\t\tthis.flashText.setText(theme.fg(\"warning\", ` ${message}`));\n\t\tif (this.flashTimeout !== null) clearTimeout(this.flashTimeout);\n\t\tthis.flashTimeout = setTimeout(() => {\n\t\t\tthis.flashText.setText(\"\");\n\t\t\tthis.flashTimeout = null;\n\t\t\tthis.config.requestRender?.();\n\t\t}, 2500);\n\t\tthis.config.requestRender?.();\n\t}\n\n\tprivate toggleMode(): void {\n\t\tthis.mode = this.mode === \"panorama\" ? \"log\" : \"panorama\";\n\t\tthis.selectedIndex = 0;\n\t\tthis.offset = 0;\n\t\tthis.updateModeTexts();\n\t\tthis.config.requestRender?.();\n\t}\n\n\tprivate forward(action: WorkflowForwardAction): void {\n\t\tconst selected = this.rows[this.selectedIndex];\n\t\tif (selected?.stage === undefined) {\n\t\t\tif (action === \"cancel\") {\n\t\t\t\tconst workflowId = this.getModel().activeWorkflowId;\n\t\t\t\tif (workflowId === undefined) {\n\t\t\t\t\tthis.flash(\"No workflow to cancel\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.onForwardAction?.(buildWorkflowActionText(action, workflowId, undefined));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.flash(\"Select a stage row first\");\n\t\t\treturn;\n\t\t}\n\t\tthis.onForwardAction?.(buildWorkflowActionText(action, selected.stage.workflowId, selected.stage.stageId));\n\t}\n\n\thandleInput(keyData: string): void {\n\t\tconst kb = getKeybindings();\n\t\tif (kb.matches(keyData, \"tui.select.cancel\")) {\n\t\t\tthis.onClose?.();\n\t\t} else if (kb.matches(keyData, \"tui.input.tab\") || keyData === \"l\") {\n\t\t\tthis.toggleMode();\n\t\t} else if (kb.matches(keyData, \"tui.select.up\") || keyData === \"k\") {\n\t\t\tthis.move(-1);\n\t\t} else if (kb.matches(keyData, \"tui.select.down\") || keyData === \"j\") {\n\t\t\tthis.move(1);\n\t\t} else if (kb.matches(keyData, \"tui.select.pageUp\")) {\n\t\t\tthis.move(-Math.max(1, this.config.maxRows));\n\t\t} else if (kb.matches(keyData, \"tui.select.pageDown\")) {\n\t\t\tthis.move(Math.max(1, this.config.maxRows));\n\t\t} else if (keyData === \"a\") {\n\t\t\tthis.forward(\"approve\");\n\t\t} else if (keyData === \"r\") {\n\t\t\tthis.forward(\"reject\");\n\t\t} else if (keyData === \"s\") {\n\t\t\tthis.forward(\"skip\");\n\t\t} else if (keyData === \"c\") {\n\t\t\tthis.forward(\"cancel\");\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"workflow-view.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/workflow-view.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAkB,SAAS,EAAE,cAAc,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACpG,OAAO,EAAE,CAAC,EAAE,MAAM,6BAA6B,CAAC;AAEhD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAQ5D,MAAM,cAAc,GAAsB,CAAC,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAuDrH,SAAS,QAAQ,CAAC,KAAc,EAAoC;IACnE,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAAA,CAC5E;AAED,SAAS,iBAAiB,CAAC,KAAc,EAAsB;IAC9D,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS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C;YAC5B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACtB,CAAC;aAAM,IAAI,OAAO,KAAK,GAAG,EAAE,CAAC;YAC5B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACxB,CAAC;IAAA,CACD;CACD","sourcesContent":["/**\n * Workflow overlay view (§9 L2/L3 of docs/design/工作流编排插件设计.md).\n *\n * Read-only panorama (L2) and transition stream (L3) rendered from the\n * session's `workflow.state` / `workflow.transition` custom entries — the\n * same isomorphic read the footer performs on `goal.state`, so the plugin\n * does not need to be present and this module never imports plugin code.\n * Waiting-condition labels mirror the engine's `computeWaitingOn` order\n * (active-limit precedes write-scope conflict); plan lookups read the latest\n * `plan.state` snapshot the same way.\n *\n * Operations are never executed here: approve/reject/skip/cancel forward an\n * action text (e.g. `approve stage s2-review`) to the conversation input and\n * the main agent drives it through workflow_advance — rendering and execution\n * stay separated (设计 §9 L2 \"转发到对话\").\n */\n\nimport { type Component, Container, getKeybindings, Text, truncateToWidth } from \"@agent-forge/tui\";\nimport { t } from \"../../../core/i18n/index.ts\";\nimport type { SessionEntry } from \"../../../core/session-manager.ts\";\nimport { theme } from \"../theme/theme.ts\";\nimport { DynamicBorder } from \"./dynamic-border.ts\";\nimport { keyHint, rawKeyHint } from \"./keybinding-hints.ts\";\n\n// ---------------------------------------------------------------------------\n// View model (pure; exported for tests)\n// ---------------------------------------------------------------------------\n\ntype StageStatus = \"pending\" | \"active\" | \"awaiting_review\" | \"completed\" | \"failed\" | \"skipped\";\n\nconst STAGE_STATUSES: readonly string[] = [\"pending\", \"active\", \"awaiting_review\", \"completed\", \"failed\", \"skipped\"];\n\n/** One selectable stage row of the L2 panorama tree. */\nexport interface WorkflowStageRow {\n\tworkflowId: string;\n\tstageId: string;\n\ttitle: string;\n\tdepth: number;\n\tstatus: StageStatus;\n\t/** §8.1 waiting-condition label, or null when nothing blocks the stage. */\n\twaitingOn: string | null;\n\tattempts: number;\n\tevidenceCount: number;\n\t/** Conflicting active write stage id (write-scope marker), or null. */\n\tscopeConflict: string | null;\n\t/** Diamond edge collapsed to a back-reference instead of a duplicate subtree. */\n\tbackReference: boolean;\n}\n\n/** One workflow block of the L2 panorama. */\nexport interface WorkflowBlock {\n\tworkflowId: string;\n\ttitle: string;\n\tstatus: string;\n\trevision: number;\n\tgoalId: string | undefined;\n\tactiveCount: number;\n\tmaxActiveStages: number;\n\tretreatCount: number;\n\tmaxRetreats: number;\n\tdiagnostics: string[];\n\tstages: WorkflowStageRow[];\n}\n\n/** One L3 transition row (already newest-first, capped by the builder). */\nexport interface WorkflowTransitionRow {\n\trevision: number;\n\tworkflowId: string;\n\tstageId: string | undefined;\n\tfrom: string;\n\tto: string;\n\ttrigger: string;\n\tcode: string;\n\tmessage: string;\n\tdetail: string | undefined;\n}\n\nexport interface WorkflowViewModel {\n\t/** Undefined when the session has no `workflow.state` entry at all. */\n\tpanorama: WorkflowBlock[] | undefined;\n\ttransitions: WorkflowTransitionRow[];\n\t/** Newest non-terminal workflow id (footer's pick), for workflow-level actions. */\n\tactiveWorkflowId: string | undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction stringOrUndefined(value: unknown): string | undefined {\n\treturn typeof value === \"string\" ? value : undefined;\n}\n\ninterface ParsedStageSpec {\n\tid: string;\n\ttitle: string;\n\tdependsOn: string[];\n\tplanId: string | undefined;\n\tkind: \"read\" | \"write\";\n\tscope: string[] | undefined;\n\tacceptanceIds: string[];\n}\n\ninterface ParsedStageRuntime {\n\tstageId: string;\n\tstatus: StageStatus;\n\tattempts: number;\n\tevidenceCount: number;\n\tcoveredAcceptanceIds: Set<string>;\n}\n\ninterface ParsedWorkflow {\n\tid: string;\n\ttitle: string;\n\tstatus: string;\n\trevision: number;\n\tgoalId: string | undefined;\n\tmaxActiveStages: number;\n\tmaxRetreats: number;\n\tretreatCount: number;\n\tdiagnostics: string[];\n\tstages: ParsedStageSpec[];\n\truntime: Map<string, ParsedStageRuntime>;\n}\n\nfunction parseStageSpec(value: unknown): ParsedStageSpec | undefined {\n\tif (!isRecord(value)) return undefined;\n\tconst id = stringOrUndefined(value.id);\n\tif (id === undefined) return undefined;\n\tconst dependsOn = Array.isArray(value.dependsOn) ? value.dependsOn.filter(isString) : [];\n\tconst acceptance =\n\t\tisRecord(value.objective) && Array.isArray(value.objective.acceptance) ? value.objective.acceptance : [];\n\tconst scope = Array.isArray(value.scope) ? value.scope.filter(isString) : undefined;\n\treturn {\n\t\tid,\n\t\ttitle: stringOrUndefined(value.title) ?? id,\n\t\tdependsOn,\n\t\tplanId: stringOrUndefined(value.planId),\n\t\tkind: value.kind === \"read\" ? \"read\" : \"write\",\n\t\tscope: scope !== undefined && scope.length > 0 ? scope : undefined,\n\t\tacceptanceIds: acceptance\n\t\t\t.map((item) => (isRecord(item) ? stringOrUndefined(item.id) : undefined))\n\t\t\t.filter((item): item is string => item !== undefined),\n\t};\n}\n\nfunction isString(value: unknown): value is string {\n\treturn typeof value === \"string\";\n}\n\nfunction parseStageRuntime(value: unknown): ParsedStageRuntime | undefined {\n\tif (!isRecord(value)) return undefined;\n\tconst stageId = stringOrUndefined(value.stageId);\n\tconst status = stringOrUndefined(value.status);\n\tif (stageId === undefined || status === undefined || !STAGE_STATUSES.includes(status)) return undefined;\n\tconst evidence = Array.isArray(value.evidence) ? value.evidence : [];\n\tconst covered = new Set<string>();\n\tlet evidenceCount = 0;\n\tfor (const item of evidence) {\n\t\tif (!isRecord(item)) continue;\n\t\tevidenceCount++;\n\t\tconst acceptanceId = stringOrUndefined(item.acceptanceId);\n\t\tif (acceptanceId !== undefined) covered.add(acceptanceId);\n\t}\n\treturn {\n\t\tstageId,\n\t\tstatus: status as StageStatus,\n\t\tattempts: typeof value.attempts === \"number\" ? value.attempts : 0,\n\t\tevidenceCount,\n\t\tcoveredAcceptanceIds: covered,\n\t};\n}\n\nfunction parseWorkflowRecord(value: unknown): ParsedWorkflow | undefined {\n\tif (!isRecord(value)) return undefined;\n\tconst id = stringOrUndefined(value.id);\n\tconst title = stringOrUndefined(value.title);\n\tconst status = stringOrUndefined(value.status);\n\tif (id === undefined || title === undefined || status === undefined) return undefined;\n\tconst stages: ParsedStageSpec[] = [];\n\tfor (const item of Array.isArray(value.stages) ? value.stages : []) {\n\t\tconst spec = parseStageSpec(item);\n\t\tif (spec !== undefined) stages.push(spec);\n\t}\n\tconst runtime = new Map<string, ParsedStageRuntime>();\n\tfor (const item of Array.isArray(value.runtime) ? value.runtime : []) {\n\t\tconst parsed = parseStageRuntime(item);\n\t\tif (parsed !== undefined) runtime.set(parsed.stageId, parsed);\n\t}\n\tconst diagnostics = Array.isArray(value.diagnostics) ? value.diagnostics.filter(isString) : [];\n\treturn {\n\t\tid,\n\t\ttitle,\n\t\tstatus,\n\t\trevision: typeof value.revision === \"number\" ? value.revision : 0,\n\t\tgoalId: stringOrUndefined(value.goalId),\n\t\tmaxActiveStages: typeof value.maxActiveStages === \"number\" ? value.maxActiveStages : 4,\n\t\tmaxRetreats: typeof value.maxRetreats === \"number\" ? value.maxRetreats : 3,\n\t\tretreatCount: typeof value.retreatCount === \"number\" ? value.retreatCount : 0,\n\t\tdiagnostics,\n\t\tstages,\n\t\truntime,\n\t};\n}\n\n/** Latest `plan.state` snapshot reduced to id -> status (plan-dangling / plan-incomplete labels). */\nfunction parsePlanStatuses(data: unknown): Map<string, string> {\n\tconst statuses = new Map<string, string>();\n\tif (!isRecord(data) || !Array.isArray(data.plans)) return statuses;\n\tfor (const item of data.plans) {\n\t\tif (!isRecord(item)) continue;\n\t\tconst id = stringOrUndefined(item.id);\n\t\tconst status = stringOrUndefined(item.status);\n\t\tif (id !== undefined && status !== undefined) statuses.set(id, status);\n\t}\n\treturn statuses;\n}\n\nfunction parseTransition(value: unknown): WorkflowTransitionRow | undefined {\n\tif (!isRecord(value)) return undefined;\n\tconst workflowId = stringOrUndefined(value.workflowId);\n\tconst from = stringOrUndefined(value.from);\n\tconst to = stringOrUndefined(value.to);\n\tconst reason = isRecord(value.reason) ? value.reason : undefined;\n\tconst code = reason !== undefined ? stringOrUndefined(reason.code) : undefined;\n\tif (\n\t\tworkflowId === undefined ||\n\t\tfrom === undefined ||\n\t\tto === undefined ||\n\t\tcode === undefined ||\n\t\ttypeof value.revision !== \"number\"\n\t) {\n\t\treturn undefined;\n\t}\n\treturn {\n\t\trevision: value.revision,\n\t\tworkflowId,\n\t\tstageId: stringOrUndefined(value.stageId),\n\t\tfrom,\n\t\tto,\n\t\ttrigger: stringOrUndefined(value.trigger) ?? \"tool\",\n\t\tcode,\n\t\tmessage: reason !== undefined ? (stringOrUndefined(reason.message) ?? \"\") : \"\",\n\t\tdetail: reason !== undefined ? stringOrUndefined(reason.detail) : undefined,\n\t};\n}\n\nfunction scopesIntersect(a: string[] | undefined, b: string[] | undefined): boolean {\n\tif (a === undefined || a.length === 0 || b === undefined || b.length === 0) return true;\n\treturn a.some((tag) => b.includes(tag));\n}\n\nfunction findScopeConflict(workflow: ParsedWorkflow, spec: ParsedStageSpec): string | null {\n\tif (spec.kind !== \"write\") return null;\n\tfor (const other of workflow.stages) {\n\t\tif (other.id === spec.id || other.kind !== \"write\") continue;\n\t\tif (workflow.runtime.get(other.id)?.status !== \"active\") continue;\n\t\tif (scopesIntersect(spec.scope, other.scope)) return other.id;\n\t}\n\treturn null;\n}\n\nfunction uncoveredAcceptanceIds(spec: ParsedStageSpec, runtime: ParsedStageRuntime | undefined): string[] {\n\tif (runtime === undefined) return [...spec.acceptanceIds];\n\treturn spec.acceptanceIds.filter((id) => !runtime.coveredAcceptanceIds.has(id));\n}\n\n/**\n * §8.1 waiting-condition label, mirroring the engine's `computeWaitingOn`\n * check order (active-limit precedes write-scope conflict) so the overlay\n * names the same condition the audit stream recorded. Plan lookups use the\n * latest `plan.state` snapshot instead of the engine's live dependency.\n */\nfunction computeWaitingOn(\n\tworkflow: ParsedWorkflow,\n\tspec: ParsedStageSpec,\n\truntime: ParsedStageRuntime | undefined,\n\tplanStatuses: Map<string, string>,\n): string | null {\n\tconst status = runtime?.status ?? \"pending\";\n\tif (status === \"awaiting_review\") return \"review\";\n\tif (status === \"pending\") {\n\t\tif (workflow.status === \"draft\") return \"not-yet-active\";\n\t\tif ((runtime?.attempts ?? 0) > 0) {\n\t\t\tif (spec.acceptanceIds.length === 0) return \"retry-wait\";\n\t\t\treturn `acceptance-missing:[${uncoveredAcceptanceIds(spec, runtime).join(\", \")}]`;\n\t\t}\n\t\tconst incomplete = spec.dependsOn.filter((dep) => {\n\t\t\tconst dependency = workflow.runtime.get(dep)?.status;\n\t\t\treturn dependency !== \"completed\" && dependency !== \"skipped\";\n\t\t});\n\t\tif (incomplete.length > 0) return `deps-incomplete:[${incomplete.join(\", \")}]`;\n\t\tif (spec.planId !== undefined && !planStatuses.has(spec.planId)) return \"plan-dangling\";\n\t\tconst activeCount = [...workflow.runtime.values()].filter((item) => item.status === \"active\").length;\n\t\tif (activeCount >= workflow.maxActiveStages) return \"active-limit\";\n\t\tconst conflict = findScopeConflict(workflow, spec);\n\t\tif (conflict !== null) return `write-scope-conflict:[${conflict}]`;\n\t\treturn \"not-yet-active\";\n\t}\n\tif (status === \"active\") {\n\t\tif (spec.planId === undefined) return null;\n\t\tconst planStatus = planStatuses.get(spec.planId);\n\t\tif (planStatus === undefined) return \"plan-dangling\";\n\t\tif (planStatus !== \"completed\") return \"plan-incomplete\";\n\t\treturn null;\n\t}\n\treturn null;\n}\n\nfunction buildStageRows(workflow: ParsedWorkflow, planStatuses: Map<string, string>): WorkflowStageRow[] {\n\tconst rows: WorkflowStageRow[] = [];\n\tconst visited = new Set<string>();\n\tconst walk = (spec: ParsedStageSpec, depth: number): void => {\n\t\tif (visited.has(spec.id)) {\n\t\t\trows.push({\n\t\t\t\tworkflowId: workflow.id,\n\t\t\t\tstageId: spec.id,\n\t\t\t\ttitle: spec.title,\n\t\t\t\tdepth,\n\t\t\t\tstatus: workflow.runtime.get(spec.id)?.status ?? \"pending\",\n\t\t\t\twaitingOn: null,\n\t\t\t\tattempts: 0,\n\t\t\t\tevidenceCount: 0,\n\t\t\t\tscopeConflict: null,\n\t\t\t\tbackReference: true,\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tvisited.add(spec.id);\n\t\tconst runtime = workflow.runtime.get(spec.id);\n\t\trows.push({\n\t\t\tworkflowId: workflow.id,\n\t\t\tstageId: spec.id,\n\t\t\ttitle: spec.title,\n\t\t\tdepth,\n\t\t\tstatus: runtime?.status ?? \"pending\",\n\t\t\twaitingOn: computeWaitingOn(workflow, spec, runtime, planStatuses),\n\t\t\tattempts: runtime?.attempts ?? 0,\n\t\t\tevidenceCount: runtime?.evidenceCount ?? 0,\n\t\t\tscopeConflict: findScopeConflict(workflow, spec),\n\t\t\tbackReference: false,\n\t\t});\n\t\tfor (const child of workflow.stages.filter((item) => item.dependsOn.includes(spec.id))) {\n\t\t\twalk(child, depth + 1);\n\t\t}\n\t};\n\tfor (const root of workflow.stages.filter((item) => item.dependsOn.length === 0)) {\n\t\twalk(root, 0);\n\t}\n\t// Stages unreachable from a root (defensive; the engine validates acyclic\n\t// graphs) still render at the top level, mirroring the L1 text panorama.\n\tfor (const spec of workflow.stages) {\n\t\tif (!visited.has(spec.id)) walk(spec, 0);\n\t}\n\treturn rows;\n}\n\n/**\n * Build the L2/L3 view model from session entries: the latest\n * `workflow.state` snapshot plus the `workflow.transition` audit stream\n * (newest first, capped). Malformed records are skipped, never thrown.\n */\nexport function buildWorkflowViewModel(entries: readonly SessionEntry[], transitionLimit = 30): WorkflowViewModel {\n\tlet stateData: unknown;\n\tlet hasStateEntry = false;\n\tlet planData: unknown;\n\tconst transitions: WorkflowTransitionRow[] = [];\n\tfor (const entry of entries) {\n\t\tif (entry.type !== \"custom\") continue;\n\t\tif (entry.customType === \"workflow.state\") {\n\t\t\thasStateEntry = true;\n\t\t\tstateData = entry.data;\n\t\t} else if (entry.customType === \"plan.state\") {\n\t\t\tplanData = entry.data;\n\t\t} else if (entry.customType === \"workflow.transition\") {\n\t\t\tconst parsed = parseTransition(entry.data);\n\t\t\tif (parsed !== undefined) transitions.push(parsed);\n\t\t}\n\t}\n\n\tconst planStatuses = parsePlanStatuses(planData);\n\tlet blocks: WorkflowBlock[] | undefined;\n\tif (hasStateEntry) {\n\t\tconst workflows = isRecord(stateData) && Array.isArray(stateData.workflows) ? stateData.workflows : [];\n\t\tblocks = workflows\n\t\t\t.map((item) => {\n\t\t\t\tconst parsed = parseWorkflowRecord(item);\n\t\t\t\tif (parsed === undefined) return undefined;\n\t\t\t\treturn {\n\t\t\t\t\tworkflowId: parsed.id,\n\t\t\t\t\ttitle: parsed.title,\n\t\t\t\t\tstatus: parsed.status,\n\t\t\t\t\trevision: parsed.revision,\n\t\t\t\t\tgoalId: parsed.goalId,\n\t\t\t\t\tactiveCount: [...parsed.runtime.values()].filter((item) => item.status === \"active\").length,\n\t\t\t\t\tmaxActiveStages: parsed.maxActiveStages,\n\t\t\t\t\tretreatCount: parsed.retreatCount,\n\t\t\t\t\tmaxRetreats: parsed.maxRetreats,\n\t\t\t\t\tdiagnostics: [...parsed.diagnostics],\n\t\t\t\t\tstages: buildStageRows(parsed, planStatuses),\n\t\t\t\t} satisfies WorkflowBlock;\n\t\t\t})\n\t\t\t.filter((block): block is WorkflowBlock => block !== undefined);\n\t}\n\n\tconst activeRecord = blocks?.filter((block) => block.status === \"draft\" || block.status === \"running\").at(-1);\n\tconst activeWorkflowId = activeRecord?.workflowId ?? blocks?.at(-1)?.workflowId;\n\n\treturn {\n\t\tpanorama: blocks,\n\t\ttransitions: transitions.slice(-transitionLimit).reverse(),\n\t\tactiveWorkflowId,\n\t};\n}\n\n/** Forwarded action vocabulary (§9 L2): rendered here, executed via workflow_advance by the main agent. */\nexport type WorkflowForwardAction = \"approve\" | \"reject\" | \"skip\" | \"cancel\";\n\n/** Action text injected into the conversation input, e.g. `approve stage s2-review`. */\nexport function buildWorkflowActionText(\n\taction: WorkflowForwardAction,\n\tworkflowId: string,\n\tstageId: string | undefined,\n): string {\n\tif (action === \"cancel\" || stageId === undefined) return `cancel workflow ${workflowId}`;\n\treturn `${action} stage ${stageId}`;\n}\n\n// ---------------------------------------------------------------------------\n// Component (L2 panorama + L3 log)\n// ---------------------------------------------------------------------------\n\n/** Selectable row shape used by the component; stage rows carry action targets. */\ninterface ViewRow {\n\ttext: string;\n\tstage: { workflowId: string; stageId: string } | undefined;\n}\n\nfunction stageStatusColor(status: StageStatus): (text: string) => string {\n\tswitch (status) {\n\t\tcase \"active\":\n\t\t\treturn (text) => theme.fg(\"accent\", text);\n\t\tcase \"awaiting_review\":\n\t\t\treturn (text) => theme.fg(\"warning\", text);\n\t\tcase \"completed\":\n\t\t\treturn (text) => theme.fg(\"success\", text);\n\t\tcase \"failed\":\n\t\t\treturn (text) => theme.fg(\"error\", text);\n\t\tcase \"skipped\":\n\t\t\treturn (text) => theme.fg(\"dim\", text);\n\t\tcase \"pending\":\n\t\t\treturn (text) => theme.fg(\"muted\", text);\n\t}\n}\n\nfunction workflowStatusColor(status: string): (text: string) => string {\n\tif (status === \"running\") return (text) => theme.fg(\"accent\", text);\n\tif (status === \"completed\") return (text) => theme.fg(\"success\", text);\n\tif (status === \"failed\") return (text) => theme.fg(\"error\", text);\n\treturn (text) => theme.fg(\"dim\", text);\n}\n\nfunction transitionCodeColor(code: string): (text: string) => string {\n\tif (code.includes(\"failed\") || code.includes(\"retreat\") || code.includes(\"error\") || code.includes(\"limit\")) {\n\t\treturn (text) => theme.fg(\"error\", text);\n\t}\n\tif (code.includes(\"held\") || code.includes(\"retry\") || code.includes(\"amended\")) {\n\t\treturn (text) => theme.fg(\"warning\", text);\n\t}\n\treturn (text) => theme.fg(\"muted\", text);\n}\n\n/** Renders the visible row window; reads live state from the owning component. */\nclass WorkflowRowsView implements Component {\n\tprivate view: WorkflowViewComponent;\n\n\tconstructor(view: WorkflowViewComponent) {\n\t\tthis.view = view;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\treturn this.view.renderRows(width);\n\t}\n}\n\nexport interface WorkflowViewConfig {\n\t/** Entries provider; rescanned when the array identity or length changes (append-only sessions). */\n\tgetEntries: () => readonly SessionEntry[];\n\t/** Maximum visible rows before the list scrolls. */\n\tmaxRows: number;\n\t/** Request a TUI re-render (used for transient status flashes). */\n\trequestRender?: () => void;\n}\n\nexport class WorkflowViewComponent extends Container {\n\tpublic onClose?: () => void;\n\tpublic onForwardAction?: (text: string) => void;\n\n\tprivate config: WorkflowViewConfig;\n\tprivate mode: \"panorama\" | \"log\" = \"panorama\";\n\tprivate rows: ViewRow[] = [];\n\tprivate selectedIndex = 0;\n\tprivate offset = 0;\n\tprivate titleText: Text;\n\tprivate modeHintText: Text;\n\tprivate helpText: Text;\n\tprivate flashText: Text;\n\tprivate cache: { entries: readonly SessionEntry[]; length: number; model: WorkflowViewModel } | undefined;\n\tprivate flashTimeout: ReturnType<typeof setTimeout> | null = null;\n\n\tconstructor(config: WorkflowViewConfig) {\n\t\tsuper();\n\n\t\tthis.config = config;\n\t\tthis.titleText = new Text(theme.fg(\"accent\", theme.bold(` ${t(\"Workflow Overview\")}`)), 1, 0);\n\t\tthis.modeHintText = new Text(\"\", 1, 0);\n\t\tthis.helpText = new Text(\"\", 1, 0);\n\t\tthis.flashText = new Text(\"\", 1, 0);\n\t\tthis.updateModeTexts();\n\n\t\tthis.addChild(new DynamicBorder());\n\t\tthis.addChild(this.titleText);\n\t\tthis.addChild(this.modeHintText);\n\t\tthis.addChild(new WorkflowRowsView(this));\n\t\tthis.addChild(this.flashText);\n\t\tthis.addChild(this.helpText);\n\t\tthis.addChild(new DynamicBorder());\n\t}\n\n\tdispose(): void {\n\t\tif (this.flashTimeout !== null) {\n\t\t\tclearTimeout(this.flashTimeout);\n\t\t\tthis.flashTimeout = null;\n\t\t}\n\t}\n\n\tprivate updateModeTexts(): void {\n\t\tconst label = this.mode === \"panorama\" ? t(\"panorama\") : t(\"transition log (newest first)\");\n\t\tthis.modeHintText.setText(theme.fg(\"dim\", ` ${label}`));\n\t\tthis.helpText.setText(this.buildHelpLine());\n\t}\n\n\tprivate buildHelpLine(): string {\n\t\tconst parts = [rawKeyHint(\"↑↓\", t(\"move\"))];\n\t\tif (this.mode === \"panorama\") {\n\t\t\tparts.push(\n\t\t\t\trawKeyHint(\"tab/l\", t(\"log\")),\n\t\t\t\trawKeyHint(\"a\", t(\"approve\")),\n\t\t\t\trawKeyHint(\"r\", t(\"reject\")),\n\t\t\t\trawKeyHint(\"s\", t(\"skip\")),\n\t\t\t\trawKeyHint(\"c\", t(\"cancel\")),\n\t\t\t);\n\t\t} else {\n\t\t\tparts.push(rawKeyHint(\"tab/l\", t(\"panorama\")));\n\t\t}\n\t\tparts.push(keyHint(\"tui.select.cancel\", t(\"close\")));\n\t\treturn ` ${parts.join(\" \")}`;\n\t}\n\n\tprivate getModel(): WorkflowViewModel {\n\t\tconst entries = this.config.getEntries();\n\t\tif (this.cache && this.cache.entries === entries && this.cache.length === entries.length) {\n\t\t\treturn this.cache.model;\n\t\t}\n\t\tconst model = buildWorkflowViewModel(entries);\n\t\tthis.cache = { entries, length: entries.length, model };\n\t\treturn model;\n\t}\n\n\tprivate buildRows(model: WorkflowViewModel): ViewRow[] {\n\t\tconst rows: ViewRow[] = [];\n\t\tif (this.mode === \"log\") {\n\t\t\tif (model.transitions.length === 0) {\n\t\t\t\trows.push({ text: ` ${t(\"no workflow transitions recorded\")}`, stage: undefined });\n\t\t\t\treturn rows;\n\t\t\t}\n\t\t\tfor (const transition of model.transitions) {\n\t\t\t\tconst stage = transition.stageId !== undefined ? `/${transition.stageId}` : \"\";\n\t\t\t\tconst detail = transition.detail !== undefined ? ` — ${transition.detail}` : \"\";\n\t\t\t\tconst code = transitionCodeColor(transition.code)(transition.code);\n\t\t\t\trows.push({\n\t\t\t\t\ttext: ` #${transition.revision} ${transition.workflowId}${stage} ${transition.from} -> ${transition.to} [${transition.trigger}] ${code}: ${transition.message}${detail}`,\n\t\t\t\t\tstage: undefined,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn rows;\n\t\t}\n\n\t\tconst blocks = model.panorama;\n\t\tif (blocks === undefined) {\n\t\t\trows.push({ text: ` ${t(\"no workflow.state entry in this session\")}`, stage: undefined });\n\t\t\treturn rows;\n\t\t}\n\t\tif (blocks.length === 0) {\n\t\t\trows.push({\n\t\t\t\ttext: ` ${t(\"no workflows in this session; create one with workflow_set\")}`,\n\t\t\t\tstage: undefined,\n\t\t\t});\n\t\t\treturn rows;\n\t\t}\n\t\tfor (const block of blocks) {\n\t\t\tconst status = workflowStatusColor(block.status)(block.status);\n\t\t\trows.push({\n\t\t\t\ttext: ` ${t(\n\t\t\t\t\t'workflow \"{title}\" ({workflowId}) — {status} · revision {revision} · active {activeCount}/{maxActiveStages} · retreats {retreatCount}/{maxRetreats}',\n\t\t\t\t\t{\n\t\t\t\t\t\ttitle: block.title,\n\t\t\t\t\t\tworkflowId: block.workflowId,\n\t\t\t\t\t\tstatus,\n\t\t\t\t\t\trevision: block.revision,\n\t\t\t\t\t\tactiveCount: block.activeCount,\n\t\t\t\t\t\tmaxActiveStages: block.maxActiveStages,\n\t\t\t\t\t\tretreatCount: block.retreatCount,\n\t\t\t\t\t\tmaxRetreats: block.maxRetreats,\n\t\t\t\t\t},\n\t\t\t\t)}`,\n\t\t\t\tstage: undefined,\n\t\t\t});\n\t\t\tif (block.goalId !== undefined) {\n\t\t\t\trows.push({ text: ` ${t(\"goal: {goalId}\", { goalId: block.goalId })}`, stage: undefined });\n\t\t\t}\n\t\t\tfor (const stage of block.stages) {\n\t\t\t\trows.push({\n\t\t\t\t\ttext: this.formatStageRow(stage),\n\t\t\t\t\tstage: { workflowId: block.workflowId, stageId: stage.stageId },\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (block.diagnostics.length > 0) {\n\t\t\t\trows.push({ text: ` ${t(\"diagnostics:\")}`, stage: undefined });\n\t\t\t\tfor (const diagnostic of block.diagnostics) {\n\t\t\t\t\trows.push({ text: theme.fg(\"warning\", ` - ${diagnostic}`), stage: undefined });\n\t\t\t\t}\n\t\t\t}\n\t\t\trows.push({ text: \"\", stage: undefined });\n\t\t}\n\t\treturn rows;\n\t}\n\n\tprivate formatStageRow(stage: WorkflowStageRow): string {\n\t\tconst pad = \" \".repeat(stage.depth + 1);\n\t\tif (stage.backReference) {\n\t\t\treturn `${pad} -> ${stage.stageId} ${t(\"(shown above)\")}`;\n\t\t}\n\t\tconst bits = [`- ${stage.stageId} [${stageStatusColor(stage.status)(stage.status)}] ${stage.title}`];\n\t\tif (stage.waitingOn !== null) {\n\t\t\tbits.push(theme.fg(\"dim\", `— ${t(\"waiting: {condition}\", { condition: stage.waitingOn })}`));\n\t\t}\n\t\tif (stage.attempts > 0) bits.push(theme.fg(\"dim\", t(\"· attempts {count}\", { count: stage.attempts })));\n\t\tif (stage.evidenceCount > 0) {\n\t\t\tbits.push(theme.fg(\"dim\", t(\"· evidence {count}\", { count: stage.evidenceCount })));\n\t\t}\n\t\tif (stage.scopeConflict !== null) {\n\t\t\tbits.push(theme.fg(\"warning\", `⚠ ${t(\"scope:{conflict}\", { conflict: stage.scopeConflict })}`));\n\t\t}\n\t\treturn `${pad}${bits.join(\" \")}`;\n\t}\n\n\t/** Rows are rebuilt lazily on access; the key couples rebuild + selection restore. */\n\tprivate syncRows(): void {\n\t\tconst model = this.getModel();\n\t\tconst previous = this.rows[this.selectedIndex]?.stage;\n\t\tthis.rows = this.buildRows(model);\n\t\tif (previous !== undefined) {\n\t\t\tconst restored = this.rows.findIndex((row) => row.stage?.stageId === previous.stageId);\n\t\t\tif (restored !== -1) this.selectedIndex = restored;\n\t\t}\n\t\tif (this.selectedIndex >= this.rows.length) this.selectedIndex = Math.max(0, this.rows.length - 1);\n\t\tthis.clampOffset();\n\t}\n\n\tprivate clampOffset(): void {\n\t\tconst maxRows = Math.max(1, this.config.maxRows);\n\t\tif (this.selectedIndex < this.offset) this.offset = this.selectedIndex;\n\t\tif (this.selectedIndex >= this.offset + maxRows) this.offset = this.selectedIndex - maxRows + 1;\n\t\tif (this.offset < 0) this.offset = 0;\n\t}\n\n\trenderRows(width: number): string[] {\n\t\tthis.syncRows();\n\t\tconst maxRows = Math.max(1, this.config.maxRows);\n\t\tconst lines: string[] = [];\n\t\tfor (let index = this.offset; index < Math.min(this.rows.length, this.offset + maxRows); index++) {\n\t\t\tconst row = this.rows[index];\n\t\t\tif (row === undefined) continue;\n\t\t\tconst selected = index === this.selectedIndex;\n\t\t\tconst prefix = selected ? theme.fg(\"accent\", \"→ \") : \" \";\n\t\t\tlines.push(truncateToWidth(`${prefix}${row.text}`, width));\n\t\t}\n\t\tconst hiddenAbove = this.offset;\n\t\tconst hiddenBelow = this.rows.length - this.offset - maxRows;\n\t\tconst hidden: string[] = [];\n\t\tif (hiddenAbove > 0) hidden.push(`↑${hiddenAbove}`);\n\t\tif (hiddenBelow > 0) hidden.push(`↓${hiddenBelow}`);\n\t\t// Fixed output height (exactly maxRows content rows plus this final\n\t\t// indicator row), the same contract as agents-view renderRows: the\n\t\t// overlay's grid footprint must not change with mode switches or row\n\t\t// counts, or the chat/editor layout boundary moves between frames.\n\t\twhile (lines.length < maxRows) lines.push(truncateToWidth(\" \", width));\n\t\tlines.push(truncateToWidth(hidden.length > 0 ? theme.fg(\"dim\", ` ${hidden.join(\" \")}`) : \" \", width));\n\t\treturn lines;\n\t}\n\n\tprivate move(delta: number): void {\n\t\tif (this.rows.length === 0) return;\n\t\tthis.selectedIndex = Math.min(this.rows.length - 1, Math.max(0, this.selectedIndex + delta));\n\t\tthis.clampOffset();\n\t}\n\n\tprivate flash(message: string): void {\n\t\tthis.flashText.setText(theme.fg(\"warning\", ` ${message}`));\n\t\tif (this.flashTimeout !== null) clearTimeout(this.flashTimeout);\n\t\tthis.flashTimeout = setTimeout(() => {\n\t\t\tthis.flashText.setText(\"\");\n\t\t\tthis.flashTimeout = null;\n\t\t\tthis.config.requestRender?.();\n\t\t}, 2500);\n\t\tthis.config.requestRender?.();\n\t}\n\n\tprivate toggleMode(): void {\n\t\tthis.mode = this.mode === \"panorama\" ? \"log\" : \"panorama\";\n\t\tthis.selectedIndex = 0;\n\t\tthis.offset = 0;\n\t\tthis.updateModeTexts();\n\t\tthis.config.requestRender?.();\n\t}\n\n\tprivate forward(action: WorkflowForwardAction): void {\n\t\tconst selected = this.rows[this.selectedIndex];\n\t\tif (selected?.stage === undefined) {\n\t\t\tif (action === \"cancel\") {\n\t\t\t\tconst workflowId = this.getModel().activeWorkflowId;\n\t\t\t\tif (workflowId === undefined) {\n\t\t\t\t\tthis.flash(t(\"No workflow to cancel\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.onForwardAction?.(buildWorkflowActionText(action, workflowId, undefined));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.flash(t(\"Select a stage row first\"));\n\t\t\treturn;\n\t\t}\n\t\tthis.onForwardAction?.(buildWorkflowActionText(action, selected.stage.workflowId, selected.stage.stageId));\n\t}\n\n\thandleInput(keyData: string): void {\n\t\tconst kb = getKeybindings();\n\t\tif (kb.matches(keyData, \"tui.select.cancel\")) {\n\t\t\tthis.onClose?.();\n\t\t} else if (kb.matches(keyData, \"tui.input.tab\") || keyData === \"l\") {\n\t\t\tthis.toggleMode();\n\t\t} else if (kb.matches(keyData, \"tui.select.up\") || keyData === \"k\") {\n\t\t\tthis.move(-1);\n\t\t} else if (kb.matches(keyData, \"tui.select.down\") || keyData === \"j\") {\n\t\t\tthis.move(1);\n\t\t} else if (kb.matches(keyData, \"tui.select.pageUp\")) {\n\t\t\tthis.move(-Math.max(1, this.config.maxRows));\n\t\t} else if (kb.matches(keyData, \"tui.select.pageDown\")) {\n\t\t\tthis.move(Math.max(1, this.config.maxRows));\n\t\t} else if (keyData === \"a\") {\n\t\t\tthis.forward(\"approve\");\n\t\t} else if (keyData === \"r\") {\n\t\t\tthis.forward(\"reject\");\n\t\t} else if (keyData === \"s\") {\n\t\t\tthis.forward(\"skip\");\n\t\t} else if (keyData === \"c\") {\n\t\t\tthis.forward(\"cancel\");\n\t\t}\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"external-editor.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/external-editor.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,qBAAqB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,oBAAoB,GAAG;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,CAAC;AAElG,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAkCxG","sourcesContent":["import { spawn } from \"node:child_process\";\nimport { mkdtempSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { stripBom } from \"../../utils/text.ts\";\n\nexport interface ExternalEditorOptions {\n\tcommand: string;\n\tcontent: string;\n}\n\nexport type ExternalEditorResult = { status: \"complete\"; content: string } | { status: \"failed\" };\n\nexport async function editInExternalEditor(options: ExternalEditorOptions): Promise<ExternalEditorResult> {\n\tconst directory = mkdtempSync(join(tmpdir(), \"agent-forge-editor-\"));\n\tconst filePath = join(directory, \"prompt.md\");\n\ttry {\n\t\twriteFileSync(filePath, options.content, \"utf-8\");\n\t\tconst [editor, ...editorArgs] = options.command.split(\" \");\n\t\tprocess.stdout.write(\n\t\t\t`Launching external editor: ${options.command}\\nAgent Forge will resume when the editor exits.\\n`,\n\t\t);\n\n\t\t// Do not use spawnSync here. On Windows, synchronous child_process calls can keep\n\t\t// Node/libuv's console input read active after the parent pauses stdin, racing\n\t\t// vim/nvim for the console input buffer until Ctrl+C cancels the pending read.\n\t\tconst exitCode = await new Promise<number | null>((resolve) => {\n\t\t\tconst child = spawn(editor, [...editorArgs, filePath], {\n\t\t\t\tstdio: \"inherit\",\n\t\t\t\tshell: process.platform === \"win32\",\n\t\t\t});\n\t\t\tchild.on(\"error\", () => resolve(null));\n\t\t\tchild.on(\"close\", (code) => resolve(code));\n\t\t});\n\n\t\tif (exitCode !== 0) {\n\t\t\treturn { status: \"failed\" };\n\t\t}\n\n\t\treturn { status: \"complete\", content: stripBom(readFileSync(filePath, \"utf-8\")).replace(/\\n$/, \"\") };\n\t} finally {\n\t\ttry {\n\t\t\trmSync(directory, { recursive: true, force: true });\n\t\t} catch {\n\t\t\t// Cleanup is best effort.\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"external-editor.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/external-editor.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,qBAAqB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,oBAAoB,GAAG;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,CAAC;AAElG,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAkCxG","sourcesContent":["import { spawn } from \"node:child_process\";\nimport { mkdtempSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { t } from \"../../core/i18n/index.ts\";\nimport { stripBom } from \"../../utils/text.ts\";\n\nexport interface ExternalEditorOptions {\n\tcommand: string;\n\tcontent: string;\n}\n\nexport type ExternalEditorResult = { status: \"complete\"; content: string } | { status: \"failed\" };\n\nexport async function editInExternalEditor(options: ExternalEditorOptions): Promise<ExternalEditorResult> {\n\tconst directory = mkdtempSync(join(tmpdir(), \"agent-forge-editor-\"));\n\tconst filePath = join(directory, \"prompt.md\");\n\ttry {\n\t\twriteFileSync(filePath, options.content, \"utf-8\");\n\t\tconst [editor, ...editorArgs] = options.command.split(\" \");\n\t\tprocess.stdout.write(\n\t\t\t`${t(\"Launching external editor: {command}\", { command: options.command })}\\n${t(\"Agent Forge will resume when the editor exits.\")}\\n`,\n\t\t);\n\n\t\t// Do not use spawnSync here. On Windows, synchronous child_process calls can keep\n\t\t// Node/libuv's console input read active after the parent pauses stdin, racing\n\t\t// vim/nvim for the console input buffer until Ctrl+C cancels the pending read.\n\t\tconst exitCode = await new Promise<number | null>((resolve) => {\n\t\t\tconst child = spawn(editor, [...editorArgs, filePath], {\n\t\t\t\tstdio: \"inherit\",\n\t\t\t\tshell: process.platform === \"win32\",\n\t\t\t});\n\t\t\tchild.on(\"error\", () => resolve(null));\n\t\t\tchild.on(\"close\", (code) => resolve(code));\n\t\t});\n\n\t\tif (exitCode !== 0) {\n\t\t\treturn { status: \"failed\" };\n\t\t}\n\n\t\treturn { status: \"complete\", content: stripBom(readFileSync(filePath, \"utf-8\")).replace(/\\n$/, \"\") };\n\t} finally {\n\t\ttry {\n\t\t\trmSync(directory, { recursive: true, force: true });\n\t\t} catch {\n\t\t\t// Cleanup is best effort.\n\t\t}\n\t}\n}\n"]}
@@ -2,6 +2,7 @@ import { spawn } from "node:child_process";
2
2
  import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
3
3
  import { tmpdir } from "node:os";
4
4
  import { join } from "node:path";
5
+ import { t } from "../../core/i18n/index.js";
5
6
  import { stripBom } from "../../utils/text.js";
6
7
  export async function editInExternalEditor(options) {
7
8
  const directory = mkdtempSync(join(tmpdir(), "agent-forge-editor-"));
@@ -9,7 +10,7 @@ export async function editInExternalEditor(options) {
9
10
  try {
10
11
  writeFileSync(filePath, options.content, "utf-8");
11
12
  const [editor, ...editorArgs] = options.command.split(" ");
12
- process.stdout.write(`Launching external editor: ${options.command}\nAgent Forge will resume when the editor exits.\n`);
13
+ process.stdout.write(`${t("Launching external editor: {command}", { command: options.command })}\n${t("Agent Forge will resume when the editor exits.")}\n`);
13
14
  // Do not use spawnSync here. On Windows, synchronous child_process calls can keep
14
15
  // Node/libuv's console input read active after the parent pauses stdin, racing
15
16
  // vim/nvim for the console input buffer until Ctrl+C cancels the pending read.
@@ -1 +1 @@
1
- {"version":3,"file":"external-editor.js","sourceRoot":"","sources":["../../../src/modes/interactive/external-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAS/C,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAA8B,EAAiC;IACzG,MAAM,SAAS,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,qBAAqB,CAAC,CAAC,CAAC;IACrE,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IAC9C,IAAI,CAAC;QACJ,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAClD,MAAM,CAAC,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3D,OAAO,CAAC,MAAM,CAAC,KAAK,CACnB,8BAA8B,OAAO,CAAC,OAAO,oDAAoD,CACjG,CAAC;QAEF,kFAAkF;QAClF,+EAA+E;QAC/E,+EAA+E;QAC/E,MAAM,QAAQ,GAAG,MAAM,IAAI,OAAO,CAAgB,CAAC,OAAO,EAAE,EAAE,CAAC;YAC9D,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,UAAU,EAAE,QAAQ,CAAC,EAAE;gBACtD,KAAK,EAAE,SAAS;gBAChB,KAAK,EAAE,OAAO,CAAC,QAAQ,KAAK,OAAO;aACnC,CAAC,CAAC;YACH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;YACvC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAAA,CAC3C,CAAC,CAAC;QAEH,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;YACpB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;QAC7B,CAAC;QAED,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC;IACtG,CAAC;YAAS,CAAC;QACV,IAAI,CAAC;YACJ,MAAM,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACrD,CAAC;QAAC,MAAM,CAAC;YACR,0BAA0B;QAC3B,CAAC;IACF,CAAC;AAAA,CACD","sourcesContent":["import { spawn } from \"node:child_process\";\nimport { mkdtempSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { stripBom } from \"../../utils/text.ts\";\n\nexport interface ExternalEditorOptions {\n\tcommand: string;\n\tcontent: string;\n}\n\nexport type ExternalEditorResult = { status: \"complete\"; content: string } | { status: \"failed\" };\n\nexport async function editInExternalEditor(options: ExternalEditorOptions): Promise<ExternalEditorResult> {\n\tconst directory = mkdtempSync(join(tmpdir(), \"agent-forge-editor-\"));\n\tconst filePath = join(directory, \"prompt.md\");\n\ttry {\n\t\twriteFileSync(filePath, options.content, \"utf-8\");\n\t\tconst [editor, ...editorArgs] = options.command.split(\" \");\n\t\tprocess.stdout.write(\n\t\t\t`Launching external editor: ${options.command}\\nAgent Forge will resume when the editor exits.\\n`,\n\t\t);\n\n\t\t// Do not use spawnSync here. On Windows, synchronous child_process calls can keep\n\t\t// Node/libuv's console input read active after the parent pauses stdin, racing\n\t\t// vim/nvim for the console input buffer until Ctrl+C cancels the pending read.\n\t\tconst exitCode = await new Promise<number | null>((resolve) => {\n\t\t\tconst child = spawn(editor, [...editorArgs, filePath], {\n\t\t\t\tstdio: \"inherit\",\n\t\t\t\tshell: process.platform === \"win32\",\n\t\t\t});\n\t\t\tchild.on(\"error\", () => resolve(null));\n\t\t\tchild.on(\"close\", (code) => resolve(code));\n\t\t});\n\n\t\tif (exitCode !== 0) {\n\t\t\treturn { status: \"failed\" };\n\t\t}\n\n\t\treturn { status: \"complete\", content: stripBom(readFileSync(filePath, \"utf-8\")).replace(/\\n$/, \"\") };\n\t} finally {\n\t\ttry {\n\t\t\trmSync(directory, { recursive: true, force: true });\n\t\t} catch {\n\t\t\t// Cleanup is best effort.\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"external-editor.js","sourceRoot":"","sources":["../../../src/modes/interactive/external-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,0BAA0B,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAS/C,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAA8B,EAAiC;IACzG,MAAM,SAAS,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EA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AC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC;IACtG,CAAC;YAAS,CAAC;QACV,IAAI,CAAC;YACJ,MAAM,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACrD,CAAC;QAAC,MAAM,CAAC;YACR,0BAA0B;QAC3B,CAAC;IACF,CAAC;AAAA,CACD","sourcesContent":["import { spawn } from \"node:child_process\";\nimport { mkdtempSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { t } from \"../../core/i18n/index.ts\";\nimport { stripBom } from \"../../utils/text.ts\";\n\nexport interface ExternalEditorOptions {\n\tcommand: string;\n\tcontent: string;\n}\n\nexport type ExternalEditorResult = { status: \"complete\"; content: string } | { status: \"failed\" };\n\nexport async function editInExternalEditor(options: ExternalEditorOptions): Promise<ExternalEditorResult> {\n\tconst directory = mkdtempSync(join(tmpdir(), \"agent-forge-editor-\"));\n\tconst filePath = join(directory, \"prompt.md\");\n\ttry {\n\t\twriteFileSync(filePath, options.content, \"utf-8\");\n\t\tconst [editor, ...editorArgs] = options.command.split(\" \");\n\t\tprocess.stdout.write(\n\t\t\t`${t(\"Launching external editor: {command}\", { command: options.command })}\\n${t(\"Agent Forge will resume when the editor exits.\")}\\n`,\n\t\t);\n\n\t\t// Do not use spawnSync here. On Windows, synchronous child_process calls can keep\n\t\t// Node/libuv's console input read active after the parent pauses stdin, racing\n\t\t// vim/nvim for the console input buffer until Ctrl+C cancels the pending read.\n\t\tconst exitCode = await new Promise<number | null>((resolve) => {\n\t\t\tconst child = spawn(editor, [...editorArgs, filePath], {\n\t\t\t\tstdio: \"inherit\",\n\t\t\t\tshell: process.platform === \"win32\",\n\t\t\t});\n\t\t\tchild.on(\"error\", () => resolve(null));\n\t\t\tchild.on(\"close\", (code) => resolve(code));\n\t\t});\n\n\t\tif (exitCode !== 0) {\n\t\t\treturn { status: \"failed\" };\n\t\t}\n\n\t\treturn { status: \"complete\", content: stripBom(readFileSync(filePath, \"utf-8\")).replace(/\\n$/, \"\") };\n\t} finally {\n\t\ttry {\n\t\t\trmSync(directory, { recursive: true, force: true });\n\t\t} catch {\n\t\t\t// Cleanup is best effort.\n\t\t}\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-auth.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-auth.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAEnF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAIjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,KAAK,oBAAoB,EAA0B,MAAM,gCAAgC,CAAC;AAEnG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGtE;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IAC1B;;;OAGG;IACH,mBAAmB,IAAI,gBAAgB,CAAC;IACxC,2EAA2E;IAC3E,eAAe,IAAI,mBAAmB,CAAC;IACvC,kEAAkE;IAClE,kBAAkB,IAAI,SAAS,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;IAC5C,0EAA0E;IAC1E,kBAAkB,IAAI,OAAO,CAAC;IAC9B,qBAAqB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC;IAClD,gDAAgD;IAChD,gBAAgB,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAC3C,4DAA4D;IAC5D,gBAAgB,CAAC,KAAK,EA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,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA+CrH;AAED,wBAAgB,cAAc,CAC7B,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,GAC7C,OAAO,CAAC,MAAM,CAAC,CA6BjB;AAED,wBAAsB,cAAc,CACnC,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,UAAU,GAChB,OAAO,CAAC,MAAM,CAAC,CAuBjB;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,oBAAoB,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAWxG;AAED,wBAAsB,aAAa,CAClC,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,oBAAoB,EAC5B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,SAAS,GAAG,OAAO,GACzB,OAAO,CAAC,IAAI,CAAC,CAMf;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA4B/G","sourcesContent":["/**\n * Login/authentication flow for interactive mode (S5 slice 3): provider\n * option collection, the /login and /logout selectors, the OAuth and API-key\n * login dialogs, auth prompt plumbing, and post-login completion.\n *\n * InteractiveMode implements AuthUiHost and keeps same-name delegate methods\n * so prototype-level tests and the command dispatch table keep working; the\n * functions below receive the mode through AuthUiHost and route every call —\n * including steps between auth methods — through the host, mirroring the\n * DialogUiHost pattern in ./interactive-dialog-ui.ts. Credential/provider\n * auth, model snapshot, catalog refresh, facade, and session-identity access go\n * through narrow host accessors (D-048: facade projections) so this module\n * never reads session internals directly.\n *\n * Internal collaboration interface (same pattern as CommandDispatchHost): not\n * a plugin API and not exported from the package root.\n */\nimport * as path from \"node:path\";\nimport type { AuthEvent, AuthPrompt } from \"@agent-forge/ai\";\nimport type { Api, Model } from \"@agent-forge/ai/compat\";\nimport type { Component, Container, EditorComponent, TUI } from \"@agent-forge/tui\";\nimport { APP_NAME, getAuthPath, getDocsPath } from \"../../config.ts\";\nimport type { ModelAuthRuntime } from \"../../core/facade/coding-agent-facade.ts\";\nimport { defaultModelPerProvider } from \"../../core/model-resolver.ts\";\nimport { CredentialSynchronizationError } from \"../../core/model-runtime.ts\";\nimport { DialogSelectorComponent } from \"./components/dialog-selector.ts\";\nimport { LoginDialogComponent } from \"./components/login-dialog.ts\";\nimport { type AuthSelectorProvider, OAuthSelectorComponent } from \"./components/oauth-selector.ts\";\nimport { hasDefaultModelProvider, isUnknownModel, llamaCppPostLoginGuidance } from \"./interactive-helpers.ts\";\nimport type { ModelCatalogRuntime } from \"./model-catalog-refresh.ts\";\nimport { theme } from \"./theme/theme.ts\";\n\n/**\n * Host surface InteractiveMode exposes to this module: the auth-flow methods\n * (which stay on the mode for dispatch and prototype-level tests) plus narrow\n * accessors for the session runtime, facade operations, and selector surface.\n *\n * Internal collaboration interface (same pattern as CommandDispatchHost): not\n * a plugin API and not exported from the package root.\n */\nexport interface AuthUiHost {\n\t/**\n\t * Narrow credential/provider auth projection through the stable facade\n\t * (D-048); the full runtime stays on the session.\n\t */\n\tgetModelAuthRuntime(): ModelAuthRuntime;\n\t/** Narrow catalog-refresh projection through the stable facade (D-048). */\n\tgetModelCatalog(): ModelCatalogRuntime;\n\t/** Available model snapshot through the stable facade (D-048). */\n\tgetAvailableModels(): readonly Model<Api>[];\n\t/** Opaque current-session identity token for post-login rebind checks. */\n\tgetSessionIdentity(): unknown;\n\tisSameSessionIdentity(identity: unknown): boolean;\n\t/** Selected model through the stable facade. */\n\tgetSelectedModel(): Model<Api> | undefined;\n\t/** Persists a model selection through the stable facade. */\n\tsetSelectedModel(model: Model<Api>): Promise<void>;\n\n\tui: TUI;\n\teditor: EditorComponent;\n\teditorContainer: Container;\n\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n\tshowWarning(message: string): void;\n\t/** Selector surface; the implementation stays in the mode's selector area. */\n\tshowAuthSelector(\n\t\tcreate: (done: () => void) => { component: Component; focus: Component; dispose?: () => void },\n\t): void;\n\tupdateAvailableProviderCount(): void;\n\tmaybeWarnAboutAnthropicSubscriptionAuth(model?: Model<Api>): Promise<void>;\n\tcheckDaxnutsEasterEgg(model: { provider: string; id: string }): void;\n\tinvalidateFooter(): void;\n\tupdateEditorBorderColor(): void;\n\n\tgetLoginProviderOptions(authType?: \"oauth\" | \"api_key\"): AuthSelectorProvider[];\n\tgetLogoutProviderOptions(): Promise<AuthSelectorProvider[]>;\n\tfindLoginProviderOptions(providerRef: string): AuthSelectorProvider[];\n\thandleLoginCommand(providerRef?: string): Promise<void>;\n\tstartProviderLogin(providerOption: AuthSelectorProvider): Promise<void>;\n\tshowLoginAuthTypeSelector(providerOptions?: AuthSelectorProvider[]): void;\n\tshowLoginProviderSelector(authType?: AuthSelectorProvider[\"authType\"], initialSearchInput?: string): void;\n\tshowOAuthSelector(mode: \"login\" | \"logout\"): Promise<void>;\n\tcompleteProviderAuthentication(\n\t\tproviderId: string,\n\t\tproviderName: string,\n\t\tauthType: \"oauth\" | \"api_key\",\n\t\tpreviousModel: Model<Api> | undefined,\n\t): Promise<void>;\n\tshowAmbientAuthDialog(providerOption: AuthSelectorProvider): void;\n\tshowApiKeyLoginDialog(providerId: string, providerName: string): Promise<void>;\n\tshowAuthSelect(dialog: LoginDialogComponent, prompt: Extract<AuthPrompt, { type: \"select\" }>): Promise<string>;\n\tshowAuthPrompt(dialog: LoginDialogComponent, prompt: AuthPrompt): Promise<string>;\n\tnotifyAuthDialog(dialog: LoginDialogComponent, event: AuthEvent): void;\n\tloginProvider(dialog: LoginDialogComponent, providerId: string, method: \"api_key\" | \"oauth\"): Promise<void>;\n\tshowLoginDialog(providerId: string, providerName: string): Promise<void>;\n}\n\nexport function getLoginProviderOptions(host: AuthUiHost, authType?: \"oauth\" | \"api_key\"): AuthSelectorProvider[] {\n\tconst options: AuthSelectorProvider[] = [];\n\tfor (const provider of host.getModelAuthRuntime().getProviders()) {\n\t\tconst authStatus = host.getModelAuthRuntime().getProviderAuthStatus(provider.id);\n\t\tconst status = authStatus.configured\n\t\t\t? {\n\t\t\t\t\ttype: host.getModelAuthRuntime().isUsingOAuth(provider.id) ? (\"oauth\" as const) : (\"api_key\" as const),\n\t\t\t\t\tsource: authStatus.label ?? authStatus.source,\n\t\t\t\t}\n\t\t\t: undefined;\n\t\tif ((!authType || authType === \"oauth\") && provider.auth.oauth) {\n\t\t\toptions.push({\n\t\t\t\tid: provider.id,\n\t\t\t\tname: provider.name,\n\t\t\t\tauthType: \"oauth\",\n\t\t\t\tmethod: provider.auth.oauth,\n\t\t\t\tstatus,\n\t\t\t});\n\t\t}\n\t\tif ((!authType || authType === \"api_key\") && provider.auth.apiKey) {\n\t\t\toptions.push({\n\t\t\t\tid: provider.id,\n\t\t\t\tname: provider.name,\n\t\t\t\tauthType: \"api_key\",\n\t\t\t\tmethod: provider.auth.apiKey,\n\t\t\t\tstatus,\n\t\t\t});\n\t\t}\n\t}\n\treturn options.sort((a, b) => a.name.localeCompare(b.name));\n}\n\nexport async function getLogoutProviderOptions(host: AuthUiHost): Promise<AuthSelectorProvider[]> {\n\treturn (await host.getModelAuthRuntime().listCredentials({ signal: AbortSignal.timeout(15_000) }))\n\t\t.map(({ providerId, type }) => ({\n\t\t\tid: providerId,\n\t\t\tname: host.getModelAuthRuntime().getProvider(providerId)?.name ?? providerId,\n\t\t\tauthType: type,\n\t\t\tstatus: { type, source: \"stored credential\" },\n\t\t}))\n\t\t.sort((a, b) => a.name.localeCompare(b.name));\n}\n\nexport function findLoginProviderOptions(host: AuthUiHost, providerRef: string): AuthSelectorProvider[] {\n\tconst normalizedProviderRef = providerRef.trim().toLowerCase();\n\tif (!normalizedProviderRef) {\n\t\treturn [];\n\t}\n\n\treturn host\n\t\t.getLoginProviderOptions()\n\t\t.filter(\n\t\t\t(provider) =>\n\t\t\t\tprovider.id.toLowerCase() === normalizedProviderRef ||\n\t\t\t\tprovider.name.toLowerCase() === normalizedProviderRef,\n\t\t);\n}\n\nexport async function handleLoginCommand(host: AuthUiHost, providerRef?: string): Promise<void> {\n\tif (!providerRef) {\n\t\thost.showLoginAuthTypeSelector();\n\t\treturn;\n\t}\n\n\tconst providerOptions = host.findLoginProviderOptions(providerRef);\n\tif (providerOptions.length === 1) {\n\t\tawait host.startProviderLogin(providerOptions[0]!);\n\t\treturn;\n\t}\n\n\tif (providerOptions.length > 1) {\n\t\tconst providerIds = new Set(providerOptions.map((provider) => provider.id));\n\t\tif (providerIds.size === 1) {\n\t\t\thost.showLoginAuthTypeSelector(providerOptions);\n\t\t\treturn;\n\t\t}\n\t}\n\n\thost.showLoginProviderSelector(undefined, providerRef);\n}\n\nexport async function startProviderLogin(host: AuthUiHost, providerOption: AuthSelectorProvider): Promise<void> {\n\tif (providerOption.authType === \"oauth\") {\n\t\tawait host.showLoginDialog(providerOption.id, providerOption.name);\n\t} else if (providerOption.method?.login) {\n\t\tawait host.showApiKeyLoginDialog(providerOption.id, providerOption.name);\n\t} else {\n\t\thost.showAmbientAuthDialog(providerOption);\n\t}\n}\n\nexport function showLoginAuthTypeSelector(host: AuthUiHost, providerOptions?: AuthSelectorProvider[]): void {\n\tconst oauthProvider = providerOptions?.find((provider) => provider.authType === \"oauth\");\n\tconst oauthLoginLabel =\n\t\toauthProvider?.method && \"loginLabel\" in oauthProvider.method ? oauthProvider.method.loginLabel : undefined;\n\tconst subscriptionLabel = oauthLoginLabel ?? \"Sign in with an account\";\n\tconst apiKeyLabel = \"Sign in with an API key\";\n\tconst availableAuthTypes = providerOptions\n\t\t? new Set(providerOptions.map((provider) => provider.authType))\n\t\t: new Set<AuthSelectorProvider[\"authType\"]>([\"oauth\", \"api_key\"]);\n\tconst options: string[] = [];\n\tif (availableAuthTypes.has(\"oauth\")) {\n\t\toptions.push(subscriptionLabel);\n\t}\n\tif (availableAuthTypes.has(\"api_key\")) {\n\t\toptions.push(apiKeyLabel);\n\t}\n\n\tif (options.length === 0) {\n\t\thost.showStatus(\"No login methods available.\");\n\t\treturn;\n\t}\n\n\tif (providerOptions && options.length === 1) {\n\t\tconst providerOption = providerOptions[0];\n\t\t// v8 ignore next -- options.length === 1 已保证 providerOptions 非空,[0] 恒存在\n\t\tif (providerOption) {\n\t\t\tvoid host.startProviderLogin(providerOption);\n\t\t}\n\t\treturn;\n\t}\n\n\tconst title = providerOptions?.[0]\n\t\t? `Select authentication method for ${providerOptions[0].name}:`\n\t\t: \"Select authentication method:\";\n\thost.showAuthSelector((done) => {\n\t\tconst selector = new DialogSelectorComponent(\n\t\t\ttitle,\n\t\t\toptions,\n\t\t\t(option) => {\n\t\t\t\tdone();\n\t\t\t\tconst authType = option === subscriptionLabel ? \"oauth\" : \"api_key\";\n\t\t\t\tif (providerOptions) {\n\t\t\t\t\tconst providerOption = providerOptions.find((provider) => provider.authType === authType);\n\t\t\t\t\t// v8 ignore next -- 选项列表由 providerOptions 的 authTypes 派生,必能找到\n\t\t\t\t\tif (providerOption) {\n\t\t\t\t\t\tvoid host.startProviderLogin(providerOption);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\thost.showLoginProviderSelector(authType);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\thost.ui.requestRender();\n\t\t\t},\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport function showLoginProviderSelector(\n\thost: AuthUiHost,\n\tauthType?: AuthSelectorProvider[\"authType\"],\n\tinitialSearchInput?: string,\n): void {\n\tconst providerOptions = host.getLoginProviderOptions(authType);\n\tif (providerOptions.length === 0) {\n\t\tconst message =\n\t\t\tauthType === \"oauth\"\n\t\t\t\t? \"No subscription providers available.\"\n\t\t\t\t: authType === \"api_key\"\n\t\t\t\t\t? \"No API key providers available.\"\n\t\t\t\t\t: \"No login providers available.\";\n\t\thost.showStatus(message);\n\t\treturn;\n\t}\n\n\thost.showAuthSelector((done) => {\n\t\tconst selector = new OAuthSelectorComponent(\n\t\t\t\"login\",\n\t\t\tproviderOptions,\n\t\t\tasync (providerId, selectedAuthType) => {\n\t\t\t\tdone();\n\n\t\t\t\tconst providerOption = providerOptions.find(\n\t\t\t\t\t(provider) => provider.id === providerId && provider.authType === selectedAuthType,\n\t\t\t\t);\n\t\t\t\tif (!providerOption) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tawait host.startProviderLogin(providerOption);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\tif (authType) {\n\t\t\t\t\thost.showLoginAuthTypeSelector();\n\t\t\t\t} else {\n\t\t\t\t\thost.ui.requestRender();\n\t\t\t\t}\n\t\t\t},\n\t\t\tinitialSearchInput,\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport async function showOAuthSelector(host: AuthUiHost, mode: \"login\" | \"logout\"): Promise<void> {\n\tif (mode === \"login\") {\n\t\thost.showLoginAuthTypeSelector();\n\t\treturn;\n\t}\n\n\tlet providerOptions: AuthSelectorProvider[];\n\ttry {\n\t\tproviderOptions = await host.getLogoutProviderOptions();\n\t} catch (error) {\n\t\thost.showError(`Could not read stored credentials: ${error instanceof Error ? error.message : String(error)}`);\n\t\treturn;\n\t}\n\tif (providerOptions.length === 0) {\n\t\thost.showStatus(\n\t\t\t\"No stored credentials to remove. /logout only removes credentials saved by /login; environment variables and models.json config are unchanged.\",\n\t\t);\n\t\treturn;\n\t}\n\n\thost.showAuthSelector((done) => {\n\t\tconst selector = new OAuthSelectorComponent(\n\t\t\tmode,\n\t\t\tproviderOptions,\n\t\t\tasync (providerId: string) => {\n\t\t\t\tdone();\n\n\t\t\t\tconst providerOption = providerOptions.find((provider) => provider.id === providerId);\n\t\t\t\tif (!providerOption) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait host.getModelAuthRuntime().logout(providerOption.id, {\n\t\t\t\t\t\tsignal: AbortSignal.timeout(15_000),\n\t\t\t\t\t});\n\t\t\t\t\tawait host.updateAvailableProviderCount();\n\t\t\t\t\tconst message =\n\t\t\t\t\t\tproviderOption.authType === \"oauth\"\n\t\t\t\t\t\t\t? `Logged out of ${providerOption.name}`\n\t\t\t\t\t\t\t: `Removed stored API key for ${providerOption.name}. Environment variables and models.json config are unchanged.`;\n\t\t\t\t\thost.showStatus(message);\n\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\thost.showError(\n\t\t\t\t\t\terror instanceof CredentialSynchronizationError\n\t\t\t\t\t\t\t? `Credentials removed for ${providerOption.name}, but local model state could not be synchronized: ${message}`\n\t\t\t\t\t\t\t: `Logout failed: ${message}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\thost.ui.requestRender();\n\t\t\t},\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport async function completeProviderAuthentication(\n\thost: AuthUiHost,\n\tproviderId: string,\n\tproviderName: string,\n\tauthType: \"oauth\" | \"api_key\",\n\tpreviousModel: Model<Api> | undefined,\n): Promise<void> {\n\tconst actionLabel = authType === \"oauth\" ? `Logged in to ${providerName}` : `Saved API key for ${providerName}`;\n\n\t// Opaque identity of the session that started this login; the rebind check\n\t// below compares against it through the host.\n\tconst sessionIdentity = host.getSessionIdentity();\n\t// Dynamic catalogs may be empty until the first authenticated network refresh.\n\tconst deferSelection =\n\t\tisUnknownModel(previousModel) &&\n\t\thasDefaultModelProvider(providerId) &&\n\t\t!host\n\t\t\t.getAvailableModels()\n\t\t\t.some((model) => model.provider === providerId && model.id === defaultModelPerProvider[providerId]);\n\tconst finishAuthentication = async () => {\n\t\tlet selectedModel: Model<Api> | undefined;\n\t\tlet selectionError: string | undefined;\n\t\tif (isUnknownModel(previousModel)) {\n\t\t\tconst availableModels = host.getAvailableModels();\n\t\t\tconst providerModels = availableModels.filter((model) => model.provider === providerId);\n\t\t\t// Matches LLAMA_PROVIDER_ID from extensions/llama/provider.ts; kept inline to avoid coupling interactive mode to the built-in extension.\n\t\t\tif (providerId === \"llama.cpp\") {\n\t\t\t\tselectionError = llamaCppPostLoginGuidance(actionLabel, providerModels.length);\n\t\t\t} else if (!hasDefaultModelProvider(providerId)) {\n\t\t\t\tselectionError = `${actionLabel}, but no default model is configured for provider \"${providerId}\". Use /model to select a model.`;\n\t\t\t} else if (providerModels.length === 0) {\n\t\t\t\tselectionError = `${actionLabel}, but no models are available for that provider. Use /model to select a model.`;\n\t\t\t} else {\n\t\t\t\tconst defaultModelId = defaultModelPerProvider[providerId];\n\t\t\t\tselectedModel = providerModels.find((model) => model.id === defaultModelId);\n\t\t\t\tif (!selectedModel) {\n\t\t\t\t\tselectionError = `${actionLabel}, but its default model \"${defaultModelId}\" is not available. Use /model to select a model.`;\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait host.setSelectedModel(selectedModel);\n\t\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\t\tselectedModel = undefined;\n\t\t\t\t\t\tconst errorMessage = error instanceof Error ? error.message : String(error);\n\t\t\t\t\t\tselectionError = `${actionLabel}, but selecting its default model failed: ${errorMessage}. Use /model to select a model.`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tawait host.updateAvailableProviderCount();\n\t\thost.invalidateFooter();\n\t\thost.updateEditorBorderColor();\n\t\tif (selectedModel) {\n\t\t\thost.showStatus(`${actionLabel}. Selected ${selectedModel.id}. Credentials saved to ${getAuthPath()}`);\n\t\t\tvoid host.maybeWarnAboutAnthropicSubscriptionAuth(selectedModel);\n\t\t\thost.checkDaxnutsEasterEgg(selectedModel);\n\t\t} else {\n\t\t\thost.showStatus(`${actionLabel}. Credentials saved to ${getAuthPath()}`);\n\t\t\tif (selectionError) {\n\t\t\t\thost.showError(selectionError);\n\t\t\t} else {\n\t\t\t\tvoid host.maybeWarnAboutAnthropicSubscriptionAuth();\n\t\t\t}\n\t\t}\n\t};\n\tif (deferSelection) {\n\t\thost.showStatus(`${actionLabel}. Credentials saved to ${getAuthPath()}. Refreshing model catalog…`);\n\t} else {\n\t\tawait finishAuthentication();\n\t}\n\n\tconst controller = new AbortController();\n\tconst timeout = setTimeout(() => controller.abort(), 15_000);\n\tvoid host\n\t\t.getModelCatalog()\n\t\t.refresh({ providers: [providerId], signal: controller.signal })\n\t\t.then(async (result) => {\n\t\t\tif (result.aborted) {\n\t\t\t\thost.showWarning(`${actionLabel}, but its model catalog refresh timed out; using cached models.`);\n\t\t\t} else if (result.errors.size > 0) {\n\t\t\t\thost.showWarning(`${actionLabel}, but its model catalog could not be refreshed; using cached models.`);\n\t\t\t}\n\t\t\t// Do not replace a model or session selected while the refresh was running.\n\t\t\tif (\n\t\t\t\tdeferSelection &&\n\t\t\t\thost.isSameSessionIdentity(sessionIdentity) &&\n\t\t\t\thost.getSelectedModel() === previousModel\n\t\t\t) {\n\t\t\t\tawait finishAuthentication();\n\t\t\t}\n\t\t\thost.updateAvailableProviderCount();\n\t\t\thost.invalidateFooter();\n\t\t\thost.ui.requestRender();\n\t\t})\n\t\t.catch((error: unknown) => {\n\t\t\thost.showWarning(\n\t\t\t\t`${actionLabel}, but its model catalog could not be refreshed: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t})\n\t\t.finally(() => clearTimeout(timeout));\n}\n\nexport function showAmbientAuthDialog(host: AuthUiHost, providerOption: AuthSelectorProvider): void {\n\tconst restoreEditor = () => {\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(host.editor);\n\t\thost.ui.setFocus(host.editor);\n\t\thost.ui.requestRender();\n\t};\n\n\tconst dialog = new LoginDialogComponent(\n\t\thost.ui,\n\t\tproviderOption.id,\n\t\t() => restoreEditor(),\n\t\tproviderOption.name,\n\t\t`${providerOption.name} setup`,\n\t);\n\tdialog.showInfo(`${providerOption.method?.name ?? \"Authentication\"} is configured outside ${APP_NAME}.`, [], true);\n\n\thost.editorContainer.clear();\n\thost.editorContainer.addChild(dialog);\n\thost.ui.setFocus(dialog);\n\thost.ui.requestRender();\n}\n\nexport async function showApiKeyLoginDialog(host: AuthUiHost, providerId: string, providerName: string): Promise<void> {\n\tconst previousModel = host.getSelectedModel();\n\n\tconst dialog = new LoginDialogComponent(\n\t\thost.ui,\n\t\tproviderId,\n\t\t(_success, _message) => {\n\t\t\t// Completion handled below\n\t\t},\n\t\tproviderName,\n\t);\n\n\tif (providerId === \"amazon-bedrock\") {\n\t\tdialog.showDetails([\n\t\t\ttheme.fg(\"text\", \"You can also use an AWS profile, IAM keys, or role-based credentials.\"),\n\t\t\ttheme.fg(\"muted\", \"See:\"),\n\t\t\ttheme.fg(\"accent\", ` ${path.join(getDocsPath(), \"providers.md\")}`),\n\t\t]);\n\t}\n\n\thost.editorContainer.clear();\n\thost.editorContainer.addChild(dialog);\n\thost.ui.setFocus(dialog);\n\thost.ui.requestRender();\n\n\tconst restoreEditor = () => {\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(host.editor);\n\t\thost.ui.setFocus(host.editor);\n\t\thost.ui.requestRender();\n\t};\n\n\ttry {\n\t\tawait host.loginProvider(dialog, providerId, \"api_key\");\n\t\trestoreEditor();\n\t\tawait host.completeProviderAuthentication(providerId, providerName, \"api_key\", previousModel);\n\t} catch (error: unknown) {\n\t\trestoreEditor();\n\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\tif (error instanceof CredentialSynchronizationError) {\n\t\t\thost.showError(\n\t\t\t\t`Saved API key for ${providerName}, but local model state could not be synchronized: ${errorMsg}`,\n\t\t\t);\n\t\t} else if (errorMsg !== \"Login cancelled\") {\n\t\t\thost.showError(`Failed to save API key for ${providerName}: ${errorMsg}`);\n\t\t}\n\t}\n}\n\nexport function showAuthSelect(\n\thost: AuthUiHost,\n\tdialog: LoginDialogComponent,\n\tprompt: Extract<AuthPrompt, { type: \"select\" }>,\n): Promise<string> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst restoreDialog = () => {\n\t\t\thost.editorContainer.clear();\n\t\t\thost.editorContainer.addChild(dialog);\n\t\t\thost.ui.setFocus(dialog);\n\t\t\thost.ui.requestRender();\n\t\t};\n\t\tconst labels = prompt.options.map((option) => option.label);\n\t\tconst selector = new DialogSelectorComponent(\n\t\t\tprompt.message,\n\t\t\tlabels,\n\t\t\t(optionLabel) => {\n\t\t\t\trestoreDialog();\n\t\t\t\tconst id = prompt.options.find((option) => option.label === optionLabel)?.id;\n\t\t\t\t// v8 ignore next -- 选项列表由 prompt.options 派生,选中项必能找到\n\t\t\t\tif (id) resolve(id);\n\t\t\t\telse reject(new Error(\"Login cancelled\"));\n\t\t\t},\n\t\t\t() => {\n\t\t\t\trestoreDialog();\n\t\t\t\treject(new Error(\"Login cancelled\"));\n\t\t\t},\n\t\t);\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(selector);\n\t\thost.ui.setFocus(selector);\n\t\thost.ui.requestRender();\n\t});\n}\n\nexport async function showAuthPrompt(\n\thost: AuthUiHost,\n\tdialog: LoginDialogComponent,\n\tprompt: AuthPrompt,\n): Promise<string> {\n\tlet response: Promise<string>;\n\tif (prompt.type === \"select\") {\n\t\tresponse = host.showAuthSelect(dialog, prompt);\n\t} else if (prompt.type === \"manual_code\") {\n\t\tresponse = dialog.showManualInput(prompt.message);\n\t} else {\n\t\tresponse = dialog.showPrompt(prompt.message, prompt.placeholder);\n\t}\n\tif (!prompt.signal) return response;\n\tif (prompt.signal.aborted) throw new Error(\"Login cancelled\");\n\tconst signal = prompt.signal;\n\tlet onAbort: (() => void) | undefined;\n\tconst aborted = new Promise<string>((_resolve, reject) => {\n\t\tonAbort = () => reject(new Error(\"Login cancelled\"));\n\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n\ttry {\n\t\treturn await Promise.race([response, aborted]);\n\t} finally {\n\t\t// v8 ignore next -- onAbort 在 Promise executor 中同步赋值,恒已定义\n\t\tif (onAbort) signal.removeEventListener(\"abort\", onAbort);\n\t}\n}\n\nexport function notifyAuthDialog(_host: AuthUiHost, dialog: LoginDialogComponent, event: AuthEvent): void {\n\tif (event.type === \"auth_url\") {\n\t\tdialog.showAuth(event.url, event.instructions);\n\t} else if (event.type === \"device_code\") {\n\t\tdialog.showDeviceCode(event);\n\t\tdialog.showWaiting(\"Waiting for authentication...\");\n\t} else if (event.type === \"info\") {\n\t\tdialog.showInfo(event.message, event.links);\n\t} else {\n\t\tdialog.showProgress(event.message);\n\t}\n}\n\nexport async function loginProvider(\n\thost: AuthUiHost,\n\tdialog: LoginDialogComponent,\n\tproviderId: string,\n\tmethod: \"api_key\" | \"oauth\",\n): Promise<void> {\n\tawait host.getModelAuthRuntime().login(providerId, method, {\n\t\tsignal: dialog.signal,\n\t\tprompt: (prompt) => host.showAuthPrompt(dialog, prompt),\n\t\tnotify: (event) => host.notifyAuthDialog(dialog, event),\n\t});\n}\n\nexport async function showLoginDialog(host: AuthUiHost, providerId: string, providerName: string): Promise<void> {\n\tconst previousModel = host.getSelectedModel();\n\tconst dialog = new LoginDialogComponent(host.ui, providerId, (_success, _message) => {}, providerName);\n\thost.editorContainer.clear();\n\thost.editorContainer.addChild(dialog);\n\thost.ui.setFocus(dialog);\n\thost.ui.requestRender();\n\n\tconst restoreEditor = () => {\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(host.editor);\n\t\thost.ui.setFocus(host.editor);\n\t\thost.ui.requestRender();\n\t};\n\n\ttry {\n\t\tawait host.loginProvider(dialog, providerId, \"oauth\");\n\t\trestoreEditor();\n\t\tawait host.completeProviderAuthentication(providerId, providerName, \"oauth\", previousModel);\n\t} catch (error: unknown) {\n\t\trestoreEditor();\n\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\tif (error instanceof CredentialSynchronizationError) {\n\t\t\thost.showError(`Logged in to ${providerName}, but local model state could not be synchronized: ${errorMsg}`);\n\t\t} else if (errorMsg !== \"Login cancelled\") {\n\t\t\thost.showError(`Failed to login to ${providerName}: ${errorMsg}`);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"interactive-auth.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-auth.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAEnF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAKjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,KAAK,oBAAoB,EAA0B,MAAM,gCAAgC,CAAC;AAEnG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGtE;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IAC1B;;;OAGG;IACH,mBAAmB,IAAI,gBAAgB,CAAC;IACxC,2EAA2E;IAC3E,eAAe,IAAI,mBAAmB,CAAC;IACvC,kEAAkE;IAClE,kBAAkB,IAAI,SAAS,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;IAC5C,0EAA0E;IAC1E,kBAAkB,IAAI,OAAO,CAAC;IAC9B,qBAAqB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC;IAClD,gDAAgD;IAChD,gBAAgB,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAC3C,4DAA4D;IAC5D,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnD,E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CAkDrH;AAED,wBAAgB,cAAc,CAC7B,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,GAC7C,OAAO,CAAC,MAAM,CAAC,CA6BjB;AAED,wBAAsB,cAAc,CACnC,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,UAAU,GAChB,OAAO,CAAC,MAAM,CAAC,CAuBjB;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,oBAAoB,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAWxG;AAED,wBAAsB,aAAa,CAClC,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,oBAAoB,EAC5B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,SAAS,GAAG,OAAO,GACzB,OAAO,CAAC,IAAI,CAAC,CAMf;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiC/G","sourcesContent":["/**\n * Login/authentication flow for interactive mode (S5 slice 3): provider\n * option collection, the /login and /logout selectors, the OAuth and API-key\n * login dialogs, auth prompt plumbing, and post-login completion.\n *\n * InteractiveMode implements AuthUiHost and keeps same-name delegate methods\n * so prototype-level tests and the command dispatch table keep working; the\n * functions below receive the mode through AuthUiHost and route every call —\n * including steps between auth methods — through the host, mirroring the\n * DialogUiHost pattern in ./interactive-dialog-ui.ts. Credential/provider\n * auth, model snapshot, catalog refresh, facade, and session-identity access go\n * through narrow host accessors (D-048: facade projections) so this module\n * never reads session internals directly.\n *\n * Internal collaboration interface (same pattern as CommandDispatchHost): not\n * a plugin API and not exported from the package root.\n */\nimport * as path from \"node:path\";\nimport type { AuthEvent, AuthPrompt } from \"@agent-forge/ai\";\nimport type { Api, Model } from \"@agent-forge/ai/compat\";\nimport type { Component, Container, EditorComponent, TUI } from \"@agent-forge/tui\";\nimport { APP_NAME, getAuthPath, getDocsPath } from \"../../config.ts\";\nimport type { ModelAuthRuntime } from \"../../core/facade/coding-agent-facade.ts\";\nimport { t } from \"../../core/i18n/index.ts\";\nimport { defaultModelPerProvider } from \"../../core/model-resolver.ts\";\nimport { CredentialSynchronizationError } from \"../../core/model-runtime.ts\";\nimport { DialogSelectorComponent } from \"./components/dialog-selector.ts\";\nimport { LoginDialogComponent } from \"./components/login-dialog.ts\";\nimport { type AuthSelectorProvider, OAuthSelectorComponent } from \"./components/oauth-selector.ts\";\nimport { hasDefaultModelProvider, isUnknownModel, llamaCppPostLoginGuidance } from \"./interactive-helpers.ts\";\nimport type { ModelCatalogRuntime } from \"./model-catalog-refresh.ts\";\nimport { theme } from \"./theme/theme.ts\";\n\n/**\n * Host surface InteractiveMode exposes to this module: the auth-flow methods\n * (which stay on the mode for dispatch and prototype-level tests) plus narrow\n * accessors for the session runtime, facade operations, and selector surface.\n *\n * Internal collaboration interface (same pattern as CommandDispatchHost): not\n * a plugin API and not exported from the package root.\n */\nexport interface AuthUiHost {\n\t/**\n\t * Narrow credential/provider auth projection through the stable facade\n\t * (D-048); the full runtime stays on the session.\n\t */\n\tgetModelAuthRuntime(): ModelAuthRuntime;\n\t/** Narrow catalog-refresh projection through the stable facade (D-048). */\n\tgetModelCatalog(): ModelCatalogRuntime;\n\t/** Available model snapshot through the stable facade (D-048). */\n\tgetAvailableModels(): readonly Model<Api>[];\n\t/** Opaque current-session identity token for post-login rebind checks. */\n\tgetSessionIdentity(): unknown;\n\tisSameSessionIdentity(identity: unknown): boolean;\n\t/** Selected model through the stable facade. */\n\tgetSelectedModel(): Model<Api> | undefined;\n\t/** Persists a model selection through the stable facade. */\n\tsetSelectedModel(model: Model<Api>): Promise<void>;\n\n\tui: TUI;\n\teditor: EditorComponent;\n\teditorContainer: Container;\n\n\tshowStatus(message: string): void;\n\tshowError(message: string): void;\n\tshowWarning(message: string): void;\n\t/** Selector surface; the implementation stays in the mode's selector area. */\n\tshowAuthSelector(\n\t\tcreate: (done: () => void) => { component: Component; focus: Component; dispose?: () => void },\n\t): void;\n\tupdateAvailableProviderCount(): void;\n\tmaybeWarnAboutAnthropicSubscriptionAuth(model?: Model<Api>): Promise<void>;\n\tcheckDaxnutsEasterEgg(model: { provider: string; id: string }): void;\n\tinvalidateFooter(): void;\n\tupdateEditorBorderColor(): void;\n\n\tgetLoginProviderOptions(authType?: \"oauth\" | \"api_key\"): AuthSelectorProvider[];\n\tgetLogoutProviderOptions(): Promise<AuthSelectorProvider[]>;\n\tfindLoginProviderOptions(providerRef: string): AuthSelectorProvider[];\n\thandleLoginCommand(providerRef?: string): Promise<void>;\n\tstartProviderLogin(providerOption: AuthSelectorProvider): Promise<void>;\n\tshowLoginAuthTypeSelector(providerOptions?: AuthSelectorProvider[]): void;\n\tshowLoginProviderSelector(authType?: AuthSelectorProvider[\"authType\"], initialSearchInput?: string): void;\n\tshowOAuthSelector(mode: \"login\" | \"logout\"): Promise<void>;\n\tcompleteProviderAuthentication(\n\t\tproviderId: string,\n\t\tproviderName: string,\n\t\tauthType: \"oauth\" | \"api_key\",\n\t\tpreviousModel: Model<Api> | undefined,\n\t): Promise<void>;\n\tshowAmbientAuthDialog(providerOption: AuthSelectorProvider): void;\n\tshowApiKeyLoginDialog(providerId: string, providerName: string): Promise<void>;\n\tshowAuthSelect(dialog: LoginDialogComponent, prompt: Extract<AuthPrompt, { type: \"select\" }>): Promise<string>;\n\tshowAuthPrompt(dialog: LoginDialogComponent, prompt: AuthPrompt): Promise<string>;\n\tnotifyAuthDialog(dialog: LoginDialogComponent, event: AuthEvent): void;\n\tloginProvider(dialog: LoginDialogComponent, providerId: string, method: \"api_key\" | \"oauth\"): Promise<void>;\n\tshowLoginDialog(providerId: string, providerName: string): Promise<void>;\n}\n\nexport function getLoginProviderOptions(host: AuthUiHost, authType?: \"oauth\" | \"api_key\"): AuthSelectorProvider[] {\n\tconst options: AuthSelectorProvider[] = [];\n\tfor (const provider of host.getModelAuthRuntime().getProviders()) {\n\t\tconst authStatus = host.getModelAuthRuntime().getProviderAuthStatus(provider.id);\n\t\tconst status = authStatus.configured\n\t\t\t? {\n\t\t\t\t\ttype: host.getModelAuthRuntime().isUsingOAuth(provider.id) ? (\"oauth\" as const) : (\"api_key\" as const),\n\t\t\t\t\tsource: authStatus.label ?? authStatus.source,\n\t\t\t\t}\n\t\t\t: undefined;\n\t\tif ((!authType || authType === \"oauth\") && provider.auth.oauth) {\n\t\t\toptions.push({\n\t\t\t\tid: provider.id,\n\t\t\t\tname: provider.name,\n\t\t\t\tauthType: \"oauth\",\n\t\t\t\tmethod: provider.auth.oauth,\n\t\t\t\tstatus,\n\t\t\t});\n\t\t}\n\t\tif ((!authType || authType === \"api_key\") && provider.auth.apiKey) {\n\t\t\toptions.push({\n\t\t\t\tid: provider.id,\n\t\t\t\tname: provider.name,\n\t\t\t\tauthType: \"api_key\",\n\t\t\t\tmethod: provider.auth.apiKey,\n\t\t\t\tstatus,\n\t\t\t});\n\t\t}\n\t}\n\treturn options.sort((a, b) => a.name.localeCompare(b.name));\n}\n\nexport async function getLogoutProviderOptions(host: AuthUiHost): Promise<AuthSelectorProvider[]> {\n\treturn (await host.getModelAuthRuntime().listCredentials({ signal: AbortSignal.timeout(15_000) }))\n\t\t.map(({ providerId, type }) => ({\n\t\t\tid: providerId,\n\t\t\tname: host.getModelAuthRuntime().getProvider(providerId)?.name ?? providerId,\n\t\t\tauthType: type,\n\t\t\tstatus: { type, source: \"stored credential\" },\n\t\t}))\n\t\t.sort((a, b) => a.name.localeCompare(b.name));\n}\n\nexport function findLoginProviderOptions(host: AuthUiHost, providerRef: string): AuthSelectorProvider[] {\n\tconst normalizedProviderRef = providerRef.trim().toLowerCase();\n\tif (!normalizedProviderRef) {\n\t\treturn [];\n\t}\n\n\treturn host\n\t\t.getLoginProviderOptions()\n\t\t.filter(\n\t\t\t(provider) =>\n\t\t\t\tprovider.id.toLowerCase() === normalizedProviderRef ||\n\t\t\t\tprovider.name.toLowerCase() === normalizedProviderRef,\n\t\t);\n}\n\nexport async function handleLoginCommand(host: AuthUiHost, providerRef?: string): Promise<void> {\n\tif (!providerRef) {\n\t\thost.showLoginAuthTypeSelector();\n\t\treturn;\n\t}\n\n\tconst providerOptions = host.findLoginProviderOptions(providerRef);\n\tif (providerOptions.length === 1) {\n\t\tawait host.startProviderLogin(providerOptions[0]!);\n\t\treturn;\n\t}\n\n\tif (providerOptions.length > 1) {\n\t\tconst providerIds = new Set(providerOptions.map((provider) => provider.id));\n\t\tif (providerIds.size === 1) {\n\t\t\thost.showLoginAuthTypeSelector(providerOptions);\n\t\t\treturn;\n\t\t}\n\t}\n\n\thost.showLoginProviderSelector(undefined, providerRef);\n}\n\nexport async function startProviderLogin(host: AuthUiHost, providerOption: AuthSelectorProvider): Promise<void> {\n\tif (providerOption.authType === \"oauth\") {\n\t\tawait host.showLoginDialog(providerOption.id, providerOption.name);\n\t} else if (providerOption.method?.login) {\n\t\tawait host.showApiKeyLoginDialog(providerOption.id, providerOption.name);\n\t} else {\n\t\thost.showAmbientAuthDialog(providerOption);\n\t}\n}\n\nexport function showLoginAuthTypeSelector(host: AuthUiHost, providerOptions?: AuthSelectorProvider[]): void {\n\tconst oauthProvider = providerOptions?.find((provider) => provider.authType === \"oauth\");\n\tconst oauthLoginLabel =\n\t\toauthProvider?.method && \"loginLabel\" in oauthProvider.method ? oauthProvider.method.loginLabel : undefined;\n\tconst subscriptionLabel = oauthLoginLabel ?? t(\"Sign in with an account\");\n\tconst apiKeyLabel = t(\"Sign in with an API key\");\n\tconst availableAuthTypes = providerOptions\n\t\t? new Set(providerOptions.map((provider) => provider.authType))\n\t\t: new Set<AuthSelectorProvider[\"authType\"]>([\"oauth\", \"api_key\"]);\n\tconst options: string[] = [];\n\tif (availableAuthTypes.has(\"oauth\")) {\n\t\toptions.push(subscriptionLabel);\n\t}\n\tif (availableAuthTypes.has(\"api_key\")) {\n\t\toptions.push(apiKeyLabel);\n\t}\n\n\tif (options.length === 0) {\n\t\thost.showStatus(t(\"No login methods available.\"));\n\t\treturn;\n\t}\n\n\tif (providerOptions && options.length === 1) {\n\t\tconst providerOption = providerOptions[0];\n\t\t// v8 ignore next -- options.length === 1 已保证 providerOptions 非空,[0] 恒存在\n\t\tif (providerOption) {\n\t\t\tvoid host.startProviderLogin(providerOption);\n\t\t}\n\t\treturn;\n\t}\n\n\tconst title = providerOptions?.[0]\n\t\t? t(\"Select authentication method for {name}:\", { name: providerOptions[0].name })\n\t\t: t(\"Select authentication method:\");\n\thost.showAuthSelector((done) => {\n\t\tconst selector = new DialogSelectorComponent(\n\t\t\ttitle,\n\t\t\toptions,\n\t\t\t(option) => {\n\t\t\t\tdone();\n\t\t\t\tconst authType = option === subscriptionLabel ? \"oauth\" : \"api_key\";\n\t\t\t\tif (providerOptions) {\n\t\t\t\t\tconst providerOption = providerOptions.find((provider) => provider.authType === authType);\n\t\t\t\t\t// v8 ignore next -- 选项列表由 providerOptions 的 authTypes 派生,必能找到\n\t\t\t\t\tif (providerOption) {\n\t\t\t\t\t\tvoid host.startProviderLogin(providerOption);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\thost.showLoginProviderSelector(authType);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\thost.ui.requestRender();\n\t\t\t},\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport function showLoginProviderSelector(\n\thost: AuthUiHost,\n\tauthType?: AuthSelectorProvider[\"authType\"],\n\tinitialSearchInput?: string,\n): void {\n\tconst providerOptions = host.getLoginProviderOptions(authType);\n\tif (providerOptions.length === 0) {\n\t\tconst message =\n\t\t\tauthType === \"oauth\"\n\t\t\t\t? t(\"No subscription providers available.\")\n\t\t\t\t: authType === \"api_key\"\n\t\t\t\t\t? t(\"No API key providers available.\")\n\t\t\t\t\t: t(\"No login providers available.\");\n\t\thost.showStatus(message);\n\t\treturn;\n\t}\n\n\thost.showAuthSelector((done) => {\n\t\tconst selector = new OAuthSelectorComponent(\n\t\t\t\"login\",\n\t\t\tproviderOptions,\n\t\t\tasync (providerId, selectedAuthType) => {\n\t\t\t\tdone();\n\n\t\t\t\tconst providerOption = providerOptions.find(\n\t\t\t\t\t(provider) => provider.id === providerId && provider.authType === selectedAuthType,\n\t\t\t\t);\n\t\t\t\tif (!providerOption) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tawait host.startProviderLogin(providerOption);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\tif (authType) {\n\t\t\t\t\thost.showLoginAuthTypeSelector();\n\t\t\t\t} else {\n\t\t\t\t\thost.ui.requestRender();\n\t\t\t\t}\n\t\t\t},\n\t\t\tinitialSearchInput,\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport async function showOAuthSelector(host: AuthUiHost, mode: \"login\" | \"logout\"): Promise<void> {\n\tif (mode === \"login\") {\n\t\thost.showLoginAuthTypeSelector();\n\t\treturn;\n\t}\n\n\tlet providerOptions: AuthSelectorProvider[];\n\ttry {\n\t\tproviderOptions = await host.getLogoutProviderOptions();\n\t} catch (error) {\n\t\thost.showError(\n\t\t\tt(\"Could not read stored credentials: {error}\", {\n\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t}),\n\t\t);\n\t\treturn;\n\t}\n\tif (providerOptions.length === 0) {\n\t\thost.showStatus(\n\t\t\tt(\n\t\t\t\t\"No stored credentials to remove. /logout only removes credentials saved by /login; environment variables and models.json config are unchanged.\",\n\t\t\t),\n\t\t);\n\t\treturn;\n\t}\n\n\thost.showAuthSelector((done) => {\n\t\tconst selector = new OAuthSelectorComponent(\n\t\t\tmode,\n\t\t\tproviderOptions,\n\t\t\tasync (providerId: string) => {\n\t\t\t\tdone();\n\n\t\t\t\tconst providerOption = providerOptions.find((provider) => provider.id === providerId);\n\t\t\t\tif (!providerOption) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait host.getModelAuthRuntime().logout(providerOption.id, {\n\t\t\t\t\t\tsignal: AbortSignal.timeout(15_000),\n\t\t\t\t\t});\n\t\t\t\t\tawait host.updateAvailableProviderCount();\n\t\t\t\t\tconst message =\n\t\t\t\t\t\tproviderOption.authType === \"oauth\"\n\t\t\t\t\t\t\t? t(\"Logged out of {name}\", { name: providerOption.name })\n\t\t\t\t\t\t\t: t(\n\t\t\t\t\t\t\t\t\t\"Removed stored API key for {name}. Environment variables and models.json config are unchanged.\",\n\t\t\t\t\t\t\t\t\t{ name: providerOption.name },\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\thost.showStatus(message);\n\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\thost.showError(\n\t\t\t\t\t\terror instanceof CredentialSynchronizationError\n\t\t\t\t\t\t\t? t(\"Credentials removed for {name}, but local model state could not be synchronized: {error}\", {\n\t\t\t\t\t\t\t\t\tname: providerOption.name,\n\t\t\t\t\t\t\t\t\terror: message,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t: t(\"Logout failed: {error}\", { error: message }),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\thost.ui.requestRender();\n\t\t\t},\n\t\t);\n\t\treturn { component: selector, focus: selector };\n\t});\n}\n\nexport async function completeProviderAuthentication(\n\thost: AuthUiHost,\n\tproviderId: string,\n\tproviderName: string,\n\tauthType: \"oauth\" | \"api_key\",\n\tpreviousModel: Model<Api> | undefined,\n): Promise<void> {\n\tconst actionLabel =\n\t\tauthType === \"oauth\"\n\t\t\t? t(\"Logged in to {name}\", { name: providerName })\n\t\t\t: t(\"Saved API key for {name}\", { name: providerName });\n\n\t// Opaque identity of the session that started this login; the rebind check\n\t// below compares against it through the host.\n\tconst sessionIdentity = host.getSessionIdentity();\n\t// Dynamic catalogs may be empty until the first authenticated network refresh.\n\tconst deferSelection =\n\t\tisUnknownModel(previousModel) &&\n\t\thasDefaultModelProvider(providerId) &&\n\t\t!host\n\t\t\t.getAvailableModels()\n\t\t\t.some((model) => model.provider === providerId && model.id === defaultModelPerProvider[providerId]);\n\tconst finishAuthentication = async () => {\n\t\tlet selectedModel: Model<Api> | undefined;\n\t\tlet selectionError: string | undefined;\n\t\tif (isUnknownModel(previousModel)) {\n\t\t\tconst availableModels = host.getAvailableModels();\n\t\t\tconst providerModels = availableModels.filter((model) => model.provider === providerId);\n\t\t\t// Matches LLAMA_PROVIDER_ID from extensions/llama/provider.ts; kept inline to avoid coupling interactive mode to the built-in extension.\n\t\t\tif (providerId === \"llama.cpp\") {\n\t\t\t\tselectionError = llamaCppPostLoginGuidance(actionLabel, providerModels.length);\n\t\t\t} else if (!hasDefaultModelProvider(providerId)) {\n\t\t\t\tselectionError = t(\n\t\t\t\t\t'{action}, but no default model is configured for provider \"{providerId}\". Use /model to select a model.',\n\t\t\t\t\t{ action: actionLabel, providerId },\n\t\t\t\t);\n\t\t\t} else if (providerModels.length === 0) {\n\t\t\t\tselectionError = t(\n\t\t\t\t\t\"{action}, but no models are available for that provider. Use /model to select a model.\",\n\t\t\t\t\t{\n\t\t\t\t\t\taction: actionLabel,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst defaultModelId = defaultModelPerProvider[providerId];\n\t\t\t\tselectedModel = providerModels.find((model) => model.id === defaultModelId);\n\t\t\t\tif (!selectedModel) {\n\t\t\t\t\tselectionError = t(\n\t\t\t\t\t\t'{action}, but its default model \"{modelId}\" is not available. Use /model to select a model.',\n\t\t\t\t\t\t{ action: actionLabel, modelId: defaultModelId },\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait host.setSelectedModel(selectedModel);\n\t\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\t\tselectedModel = undefined;\n\t\t\t\t\t\tconst errorMessage = error instanceof Error ? error.message : String(error);\n\t\t\t\t\t\tselectionError = t(\n\t\t\t\t\t\t\t\"{action}, but selecting its default model failed: {error}. Use /model to select a model.\",\n\t\t\t\t\t\t\t{ action: actionLabel, error: errorMessage },\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tawait host.updateAvailableProviderCount();\n\t\thost.invalidateFooter();\n\t\thost.updateEditorBorderColor();\n\t\tif (selectedModel) {\n\t\t\thost.showStatus(\n\t\t\t\tt(\"{action}. Selected {modelId}. Credentials saved to {path}\", {\n\t\t\t\t\taction: actionLabel,\n\t\t\t\t\tmodelId: selectedModel.id,\n\t\t\t\t\tpath: getAuthPath(),\n\t\t\t\t}),\n\t\t\t);\n\t\t\tvoid host.maybeWarnAboutAnthropicSubscriptionAuth(selectedModel);\n\t\t\thost.checkDaxnutsEasterEgg(selectedModel);\n\t\t} else {\n\t\t\thost.showStatus(t(\"{action}. Credentials saved to {path}\", { action: actionLabel, path: getAuthPath() }));\n\t\t\tif (selectionError) {\n\t\t\t\thost.showError(selectionError);\n\t\t\t} else {\n\t\t\t\tvoid host.maybeWarnAboutAnthropicSubscriptionAuth();\n\t\t\t}\n\t\t}\n\t};\n\tif (deferSelection) {\n\t\thost.showStatus(\n\t\t\tt(\"{action}. Credentials saved to {path}. Refreshing model catalog…\", {\n\t\t\t\taction: actionLabel,\n\t\t\t\tpath: getAuthPath(),\n\t\t\t}),\n\t\t);\n\t} else {\n\t\tawait finishAuthentication();\n\t}\n\n\tconst controller = new AbortController();\n\tconst timeout = setTimeout(() => controller.abort(), 15_000);\n\tvoid host\n\t\t.getModelCatalog()\n\t\t.refresh({ providers: [providerId], signal: controller.signal })\n\t\t.then(async (result) => {\n\t\t\tif (result.aborted) {\n\t\t\t\thost.showWarning(\n\t\t\t\t\tt(\"{action}, but its model catalog refresh timed out; using cached models.\", { action: actionLabel }),\n\t\t\t\t);\n\t\t\t} else if (result.errors.size > 0) {\n\t\t\t\thost.showWarning(\n\t\t\t\t\tt(\"{action}, but its model catalog could not be refreshed; using cached models.\", {\n\t\t\t\t\t\taction: actionLabel,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\t// Do not replace a model or session selected while the refresh was running.\n\t\t\tif (\n\t\t\t\tdeferSelection &&\n\t\t\t\thost.isSameSessionIdentity(sessionIdentity) &&\n\t\t\t\thost.getSelectedModel() === previousModel\n\t\t\t) {\n\t\t\t\tawait finishAuthentication();\n\t\t\t}\n\t\t\thost.updateAvailableProviderCount();\n\t\t\thost.invalidateFooter();\n\t\t\thost.ui.requestRender();\n\t\t})\n\t\t.catch((error: unknown) => {\n\t\t\thost.showWarning(\n\t\t\t\tt(\"{action}, but its model catalog could not be refreshed: {error}\", {\n\t\t\t\t\taction: actionLabel,\n\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t}),\n\t\t\t);\n\t\t})\n\t\t.finally(() => clearTimeout(timeout));\n}\n\nexport function showAmbientAuthDialog(host: AuthUiHost, providerOption: AuthSelectorProvider): void {\n\tconst restoreEditor = () => {\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(host.editor);\n\t\thost.ui.setFocus(host.editor);\n\t\thost.ui.requestRender();\n\t};\n\n\tconst dialog = new LoginDialogComponent(\n\t\thost.ui,\n\t\tproviderOption.id,\n\t\t() => restoreEditor(),\n\t\tproviderOption.name,\n\t\tt(\"{name} setup\", { name: providerOption.name }),\n\t);\n\tdialog.showInfo(\n\t\tt(\"{method} is configured outside {appName}.\", {\n\t\t\tmethod: providerOption.method?.name ?? t(\"Authentication\"),\n\t\t\tappName: APP_NAME,\n\t\t}),\n\t\t[],\n\t\ttrue,\n\t);\n\n\thost.editorContainer.clear();\n\thost.editorContainer.addChild(dialog);\n\thost.ui.setFocus(dialog);\n\thost.ui.requestRender();\n}\n\nexport async function showApiKeyLoginDialog(host: AuthUiHost, providerId: string, providerName: string): Promise<void> {\n\tconst previousModel = host.getSelectedModel();\n\n\tconst dialog = new LoginDialogComponent(\n\t\thost.ui,\n\t\tproviderId,\n\t\t(_success, _message) => {\n\t\t\t// Completion handled below\n\t\t},\n\t\tproviderName,\n\t);\n\n\tif (providerId === \"amazon-bedrock\") {\n\t\tdialog.showDetails([\n\t\t\ttheme.fg(\"text\", t(\"You can also use an AWS profile, IAM keys, or role-based credentials.\")),\n\t\t\ttheme.fg(\"muted\", t(\"See:\")),\n\t\t\ttheme.fg(\"accent\", ` ${path.join(getDocsPath(), \"providers.md\")}`),\n\t\t]);\n\t}\n\n\thost.editorContainer.clear();\n\thost.editorContainer.addChild(dialog);\n\thost.ui.setFocus(dialog);\n\thost.ui.requestRender();\n\n\tconst restoreEditor = () => {\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(host.editor);\n\t\thost.ui.setFocus(host.editor);\n\t\thost.ui.requestRender();\n\t};\n\n\ttry {\n\t\tawait host.loginProvider(dialog, providerId, \"api_key\");\n\t\trestoreEditor();\n\t\tawait host.completeProviderAuthentication(providerId, providerName, \"api_key\", previousModel);\n\t} catch (error: unknown) {\n\t\trestoreEditor();\n\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\tif (error instanceof CredentialSynchronizationError) {\n\t\t\thost.showError(\n\t\t\t\tt(\"Saved API key for {name}, but local model state could not be synchronized: {error}\", {\n\t\t\t\t\tname: providerName,\n\t\t\t\t\terror: errorMsg,\n\t\t\t\t}),\n\t\t\t);\n\t\t} else if (errorMsg !== t(\"Login cancelled\")) {\n\t\t\thost.showError(t(\"Failed to save API key for {name}: {error}\", { name: providerName, error: errorMsg }));\n\t\t}\n\t}\n}\n\nexport function showAuthSelect(\n\thost: AuthUiHost,\n\tdialog: LoginDialogComponent,\n\tprompt: Extract<AuthPrompt, { type: \"select\" }>,\n): Promise<string> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst restoreDialog = () => {\n\t\t\thost.editorContainer.clear();\n\t\t\thost.editorContainer.addChild(dialog);\n\t\t\thost.ui.setFocus(dialog);\n\t\t\thost.ui.requestRender();\n\t\t};\n\t\tconst labels = prompt.options.map((option) => option.label);\n\t\tconst selector = new DialogSelectorComponent(\n\t\t\tprompt.message,\n\t\t\tlabels,\n\t\t\t(optionLabel) => {\n\t\t\t\trestoreDialog();\n\t\t\t\tconst id = prompt.options.find((option) => option.label === optionLabel)?.id;\n\t\t\t\t// v8 ignore next -- 选项列表由 prompt.options 派生,选中项必能找到\n\t\t\t\tif (id) resolve(id);\n\t\t\t\telse reject(new Error(t(\"Login cancelled\")));\n\t\t\t},\n\t\t\t() => {\n\t\t\t\trestoreDialog();\n\t\t\t\treject(new Error(t(\"Login cancelled\")));\n\t\t\t},\n\t\t);\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(selector);\n\t\thost.ui.setFocus(selector);\n\t\thost.ui.requestRender();\n\t});\n}\n\nexport async function showAuthPrompt(\n\thost: AuthUiHost,\n\tdialog: LoginDialogComponent,\n\tprompt: AuthPrompt,\n): Promise<string> {\n\tlet response: Promise<string>;\n\tif (prompt.type === \"select\") {\n\t\tresponse = host.showAuthSelect(dialog, prompt);\n\t} else if (prompt.type === \"manual_code\") {\n\t\tresponse = dialog.showManualInput(prompt.message);\n\t} else {\n\t\tresponse = dialog.showPrompt(prompt.message, prompt.placeholder);\n\t}\n\tif (!prompt.signal) return response;\n\tif (prompt.signal.aborted) throw new Error(t(\"Login cancelled\"));\n\tconst signal = prompt.signal;\n\tlet onAbort: (() => void) | undefined;\n\tconst aborted = new Promise<string>((_resolve, reject) => {\n\t\tonAbort = () => reject(new Error(t(\"Login cancelled\")));\n\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n\ttry {\n\t\treturn await Promise.race([response, aborted]);\n\t} finally {\n\t\t// v8 ignore next -- onAbort 在 Promise executor 中同步赋值,恒已定义\n\t\tif (onAbort) signal.removeEventListener(\"abort\", onAbort);\n\t}\n}\n\nexport function notifyAuthDialog(_host: AuthUiHost, dialog: LoginDialogComponent, event: AuthEvent): void {\n\tif (event.type === \"auth_url\") {\n\t\tdialog.showAuth(event.url, event.instructions);\n\t} else if (event.type === \"device_code\") {\n\t\tdialog.showDeviceCode(event);\n\t\tdialog.showWaiting(t(\"Waiting for authentication...\"));\n\t} else if (event.type === \"info\") {\n\t\tdialog.showInfo(event.message, event.links);\n\t} else {\n\t\tdialog.showProgress(event.message);\n\t}\n}\n\nexport async function loginProvider(\n\thost: AuthUiHost,\n\tdialog: LoginDialogComponent,\n\tproviderId: string,\n\tmethod: \"api_key\" | \"oauth\",\n): Promise<void> {\n\tawait host.getModelAuthRuntime().login(providerId, method, {\n\t\tsignal: dialog.signal,\n\t\tprompt: (prompt) => host.showAuthPrompt(dialog, prompt),\n\t\tnotify: (event) => host.notifyAuthDialog(dialog, event),\n\t});\n}\n\nexport async function showLoginDialog(host: AuthUiHost, providerId: string, providerName: string): Promise<void> {\n\tconst previousModel = host.getSelectedModel();\n\tconst dialog = new LoginDialogComponent(host.ui, providerId, (_success, _message) => {}, providerName);\n\thost.editorContainer.clear();\n\thost.editorContainer.addChild(dialog);\n\thost.ui.setFocus(dialog);\n\thost.ui.requestRender();\n\n\tconst restoreEditor = () => {\n\t\thost.editorContainer.clear();\n\t\thost.editorContainer.addChild(host.editor);\n\t\thost.ui.setFocus(host.editor);\n\t\thost.ui.requestRender();\n\t};\n\n\ttry {\n\t\tawait host.loginProvider(dialog, providerId, \"oauth\");\n\t\trestoreEditor();\n\t\tawait host.completeProviderAuthentication(providerId, providerName, \"oauth\", previousModel);\n\t} catch (error: unknown) {\n\t\trestoreEditor();\n\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\t\tif (error instanceof CredentialSynchronizationError) {\n\t\t\thost.showError(\n\t\t\t\tt(\"Logged in to {name}, but local model state could not be synchronized: {error}\", {\n\t\t\t\t\tname: providerName,\n\t\t\t\t\terror: errorMsg,\n\t\t\t\t}),\n\t\t\t);\n\t\t} else if (errorMsg !== t(\"Login cancelled\")) {\n\t\t\thost.showError(t(\"Failed to login to {name}: {error}\", { name: providerName, error: errorMsg }));\n\t\t}\n\t}\n}\n"]}