@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":"lifecycle-delivery-queue.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/lifecycle-delivery-queue.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,MAAM,4BAA4B,GAAG,QAAQ,GAAG,YAAY,GAAG,QAAQ,CAAC;AAE9E,MAAM,WAAW,8BAA8B;IAC9C,QAAQ,CAAC,MAAM,EAA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,CAAC;IAEhC,YACC,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,MAAM,EACxB,eAAe,EAAE,MAAM,GAAG,SAAS,EACnC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EAetB;CACD;AAED,qBAAa,iCAAkC,SAAQ,KAAK;IAC3D,QAAQ,CAAC,IAAI,+BAA+B;IAE5C,cAGC;CACD;AAeD;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,CAAC,EAAE,OAAO,EAAE,6BAA6B,CAAC,CAAC,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAuIpH","sourcesContent":["/** Internal FIFO queue for an explicitly buffered lifecycle subscription. */\nexport type LifecycleDeliveryQueueStatus = \"active\" | \"overflowed\" | \"closed\";\n\nexport interface LifecycleDeliveryQueueSnapshot {\n\treadonly status: LifecycleDeliveryQueueStatus;\n\treadonly maxPendingEvents: number;\n\treadonly maxPendingBytes?: number;\n\treadonly pendingEvents: number;\n\treadonly pendingBytes: number;\n\treadonly accepted: number;\n\treadonly delivered: number;\n\treadonly rejected: number;\n}\n\nexport interface LifecycleDeliveryQueueOptions<T> {\n\treadonly maxPendingEvents: number;\n\treadonly maxPendingBytes?: number;\n\treadonly measureBytes: (value: T) => number;\n\treadonly deliver: (value: T) => void | Promise<void>;\n\treadonly overflowCode: string;\n}\n\nexport interface LifecycleDeliveryQueue<T> {\n\tenqueue(value: T): Promise<void>;\n\tdrain(): Promise<void>;\n\tclose(): void;\n\tsnapshot(): LifecycleDeliveryQueueSnapshot;\n}\n\nexport class LifecycleDeliveryQueueOverflowError extends Error {\n\treadonly code: string;\n\treadonly maxPendingEvents: number;\n\treadonly maxPendingBytes?: number;\n\treadonly pendingEvents: number;\n\treadonly pendingBytes: number;\n\treadonly attemptedBytes: number;\n\n\tconstructor(\n\t\tcode: string,\n\t\tmaxPendingEvents: number,\n\t\tmaxPendingBytes: number | undefined,\n\t\tpendingEvents: number,\n\t\tpendingBytes: number,\n\t\tattemptedBytes: number,\n\t) {\n\t\tsuper(\n\t\t\t`Lifecycle delivery queue overflow: pending events ${pendingEvents + 1} exceeds ${maxPendingEvents}` +\n\t\t\t\t(maxPendingBytes === undefined\n\t\t\t\t\t? \"\"\n\t\t\t\t\t: ` or pending bytes ${pendingBytes + attemptedBytes} exceeds ${maxPendingBytes}`),\n\t\t);\n\t\tthis.name = \"LifecycleDeliveryQueueOverflowError\";\n\t\tthis.code = code;\n\t\tthis.maxPendingEvents = maxPendingEvents;\n\t\tthis.maxPendingBytes = maxPendingBytes;\n\t\tthis.pendingEvents = pendingEvents;\n\t\tthis.pendingBytes = pendingBytes;\n\t\tthis.attemptedBytes = attemptedBytes;\n\t}\n}\n\nexport class LifecycleDeliveryQueueClosedError extends Error {\n\treadonly code = \"lifecycle_delivery_closed\";\n\n\tconstructor() {\n\t\tsuper(\"Lifecycle delivery queue is closed\");\n\t\tthis.name = \"LifecycleDeliveryQueueClosedError\";\n\t}\n}\n\ninterface QueueEntry<T> {\n\treadonly value: T;\n\treadonly bytes: number;\n\treadonly resolve: () => void;\n\treadonly reject: (error: unknown) => void;\n}\n\nfunction assertPositiveSafeInteger(value: number, label: string): void {\n\tif (!Number.isSafeInteger(value) || value < 1) {\n\t\tthrow new Error(`Lifecycle delivery queue ${label} must be a positive safe integer`);\n\t}\n}\n\n/**\n * Overflow terminates only this subscription's acceptance path. Values already\n * accepted remain FIFO and handler failures do not alter source lifecycle\n * facts. A closed queue rejects pending values; an overflowed queue rejects\n * further values with the original overflow code so telemetry keeps one stable\n * backpressure classification. Callers must attach a handler to every enqueue\n * promise immediately: close() and overflow reject those promises.\n */\nexport function createLifecycleDeliveryQueue<T>(options: LifecycleDeliveryQueueOptions<T>): LifecycleDeliveryQueue<T> {\n\tassertPositiveSafeInteger(options.maxPendingEvents, \"maxPendingEvents\");\n\tif (options.maxPendingBytes !== undefined) assertPositiveSafeInteger(options.maxPendingBytes, \"maxPendingBytes\");\n\tif (typeof options.overflowCode !== \"string\" || !options.overflowCode.trim()) {\n\t\tthrow new Error(\"Lifecycle delivery queue overflowCode must be non-empty\");\n\t}\n\n\tconst entries: QueueEntry<T>[] = [];\n\tlet status: LifecycleDeliveryQueueStatus = \"active\";\n\tlet pendingEvents = 0;\n\tlet pendingBytes = 0;\n\tlet accepted = 0;\n\tlet delivered = 0;\n\tlet rejected = 0;\n\tlet processing = false;\n\tlet drainPromise: Promise<void> | undefined;\n\tlet resolveDrain: (() => void) | undefined;\n\n\tconst ensureDrainPromise = (): Promise<void> => {\n\t\tif (drainPromise === undefined) {\n\t\t\tdrainPromise = new Promise<void>((resolve) => {\n\t\t\t\tresolveDrain = resolve;\n\t\t\t});\n\t\t}\n\t\treturn drainPromise;\n\t};\n\tconst settleDrainIfIdle = (): void => {\n\t\tif (processing || entries.length > 0) return;\n\t\tresolveDrain?.();\n\t\tdrainPromise = undefined;\n\t\tresolveDrain = undefined;\n\t};\n\tconst pump = async (): Promise<void> => {\n\t\tif (processing) return;\n\t\tprocessing = true;\n\t\ttry {\n\t\t\twhile (entries.length > 0) {\n\t\t\t\tconst entry = entries.shift();\n\t\t\t\tif (entry === undefined) continue;\n\t\t\t\ttry {\n\t\t\t\t\tawait options.deliver(entry.value);\n\t\t\t\t\tdelivered += 1;\n\t\t\t\t\tentry.resolve();\n\t\t\t\t} catch (error) {\n\t\t\t\t\trejected += 1;\n\t\t\t\t\tentry.reject(error);\n\t\t\t\t} finally {\n\t\t\t\t\tpendingEvents -= 1;\n\t\t\t\t\tpendingBytes -= entry.bytes;\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tprocessing = false;\n\t\t\tsettleDrainIfIdle();\n\t\t}\n\t};\n\n\treturn {\n\t\tenqueue(value) {\n\t\t\tif (status === \"overflowed\") {\n\t\t\t\trejected += 1;\n\t\t\t\treturn Promise.reject(\n\t\t\t\t\tnew LifecycleDeliveryQueueOverflowError(\n\t\t\t\t\t\toptions.overflowCode,\n\t\t\t\t\t\toptions.maxPendingEvents,\n\t\t\t\t\t\toptions.maxPendingBytes,\n\t\t\t\t\t\tpendingEvents,\n\t\t\t\t\t\tpendingBytes,\n\t\t\t\t\t\t0,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (status === \"closed\") {\n\t\t\t\trejected += 1;\n\t\t\t\treturn Promise.reject(new LifecycleDeliveryQueueClosedError());\n\t\t\t}\n\t\t\tconst bytes = options.measureBytes(value);\n\t\t\tassertPositiveSafeInteger(bytes, \"measureBytes result\");\n\t\t\tif (\n\t\t\t\tpendingEvents + 1 > options.maxPendingEvents ||\n\t\t\t\t(options.maxPendingBytes !== undefined && pendingBytes + bytes > options.maxPendingBytes)\n\t\t\t) {\n\t\t\t\tstatus = \"overflowed\";\n\t\t\t\trejected += 1;\n\t\t\t\treturn Promise.reject(\n\t\t\t\t\tnew LifecycleDeliveryQueueOverflowError(\n\t\t\t\t\t\toptions.overflowCode,\n\t\t\t\t\t\toptions.maxPendingEvents,\n\t\t\t\t\t\toptions.maxPendingBytes,\n\t\t\t\t\t\tpendingEvents,\n\t\t\t\t\t\tpendingBytes,\n\t\t\t\t\t\tbytes,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\taccepted += 1;\n\t\t\tpendingEvents += 1;\n\t\t\tpendingBytes += bytes;\n\t\t\tconst result = new Promise<void>((resolve, reject) => {\n\t\t\t\tentries.push({ value, bytes, resolve, reject });\n\t\t\t});\n\t\t\tensureDrainPromise();\n\t\t\tvoid pump();\n\t\t\treturn result;\n\t\t},\n\t\tdrain() {\n\t\t\tif (!processing && entries.length === 0) return Promise.resolve();\n\t\t\treturn ensureDrainPromise();\n\t\t},\n\t\tclose() {\n\t\t\tif (status === \"closed\") return;\n\t\t\tstatus = \"closed\";\n\t\t\tconst error = new LifecycleDeliveryQueueClosedError();\n\t\t\twhile (entries.length > 0) {\n\t\t\t\tconst entry = entries.shift();\n\t\t\t\tif (entry === undefined) continue;\n\t\t\t\tpendingEvents -= 1;\n\t\t\t\tpendingBytes -= entry.bytes;\n\t\t\t\trejected += 1;\n\t\t\t\tentry.reject(error);\n\t\t\t}\n\t\t\tsettleDrainIfIdle();\n\t\t},\n\t\tsnapshot: () =>\n\t\t\tObject.freeze({\n\t\t\t\tstatus,\n\t\t\t\tmaxPendingEvents: options.maxPendingEvents,\n\t\t\t\t...(options.maxPendingBytes === undefined ? {} : { maxPendingBytes: options.maxPendingBytes }),\n\t\t\t\tpendingEvents,\n\t\t\t\tpendingBytes,\n\t\t\t\taccepted,\n\t\t\t\tdelivered,\n\t\t\t\trejected,\n\t\t\t}),\n\t};\n}\n"]}
1
+ {"version":3,"file":"lifecycle-delivery-queue.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/lifecycle-delivery-queue.ts"],"names":[],"mappings":"AACA,6EAA6E;AAC7E,MAAM,MAAM,4BAA4B,GAAG,QAAQ,GAAG,YAAY,GAAG,QAAQ,CAAC;AAE9E,MAAM,WAAW,8BAA8B;IAC9C,QAAQ,CAAC,MAAM,EAAE,4BAA4B,CAAC;IAC9C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,6BAA6B,CAAC,CAAC;IAC/C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;IAC5C,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,sBAAsB,CAAC,CAAC;IACxC,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,KAAK,IAAI,IAAI,CAAC;IACd,QAAQ,IAAI,8BAA8B,CAAC;CAC3C;AAED,qBAAa,mCAAoC,SAAQ,KAAK;IAC7D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAEhC,YACC,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,MAAM,EACxB,eAAe,EAAE,MAAM,GAAG,SAAS,EACnC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EAetB;CACD;AAED,qBAAa,iCAAkC,SAAQ,KAAK;IAC3D,QAAQ,CAAC,IAAI,+BAA+B;IAE5C,cAGC;CACD;AAeD;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,CAAC,EAAE,OAAO,EAAE,6BAA6B,CAAC,CAAC,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAuIpH","sourcesContent":["import { t } from \"../i18n/index.ts\";\n/** Internal FIFO queue for an explicitly buffered lifecycle subscription. */\nexport type LifecycleDeliveryQueueStatus = \"active\" | \"overflowed\" | \"closed\";\n\nexport interface LifecycleDeliveryQueueSnapshot {\n\treadonly status: LifecycleDeliveryQueueStatus;\n\treadonly maxPendingEvents: number;\n\treadonly maxPendingBytes?: number;\n\treadonly pendingEvents: number;\n\treadonly pendingBytes: number;\n\treadonly accepted: number;\n\treadonly delivered: number;\n\treadonly rejected: number;\n}\n\nexport interface LifecycleDeliveryQueueOptions<T> {\n\treadonly maxPendingEvents: number;\n\treadonly maxPendingBytes?: number;\n\treadonly measureBytes: (value: T) => number;\n\treadonly deliver: (value: T) => void | Promise<void>;\n\treadonly overflowCode: string;\n}\n\nexport interface LifecycleDeliveryQueue<T> {\n\tenqueue(value: T): Promise<void>;\n\tdrain(): Promise<void>;\n\tclose(): void;\n\tsnapshot(): LifecycleDeliveryQueueSnapshot;\n}\n\nexport class LifecycleDeliveryQueueOverflowError extends Error {\n\treadonly code: string;\n\treadonly maxPendingEvents: number;\n\treadonly maxPendingBytes?: number;\n\treadonly pendingEvents: number;\n\treadonly pendingBytes: number;\n\treadonly attemptedBytes: number;\n\n\tconstructor(\n\t\tcode: string,\n\t\tmaxPendingEvents: number,\n\t\tmaxPendingBytes: number | undefined,\n\t\tpendingEvents: number,\n\t\tpendingBytes: number,\n\t\tattemptedBytes: number,\n\t) {\n\t\tsuper(\n\t\t\t`Lifecycle delivery queue overflow: pending events ${pendingEvents + 1} exceeds ${maxPendingEvents}` +\n\t\t\t\t(maxPendingBytes === undefined\n\t\t\t\t\t? \"\"\n\t\t\t\t\t: ` or pending bytes ${pendingBytes + attemptedBytes} exceeds ${maxPendingBytes}`),\n\t\t);\n\t\tthis.name = \"LifecycleDeliveryQueueOverflowError\";\n\t\tthis.code = code;\n\t\tthis.maxPendingEvents = maxPendingEvents;\n\t\tthis.maxPendingBytes = maxPendingBytes;\n\t\tthis.pendingEvents = pendingEvents;\n\t\tthis.pendingBytes = pendingBytes;\n\t\tthis.attemptedBytes = attemptedBytes;\n\t}\n}\n\nexport class LifecycleDeliveryQueueClosedError extends Error {\n\treadonly code = \"lifecycle_delivery_closed\";\n\n\tconstructor() {\n\t\tsuper(\"Lifecycle delivery queue is closed\");\n\t\tthis.name = \"LifecycleDeliveryQueueClosedError\";\n\t}\n}\n\ninterface QueueEntry<T> {\n\treadonly value: T;\n\treadonly bytes: number;\n\treadonly resolve: () => void;\n\treadonly reject: (error: unknown) => void;\n}\n\nfunction assertPositiveSafeInteger(value: number, label: string): void {\n\tif (!Number.isSafeInteger(value) || value < 1) {\n\t\tthrow new Error(t(\"Lifecycle delivery queue {label} must be a positive safe integer\", { label }));\n\t}\n}\n\n/**\n * Overflow terminates only this subscription's acceptance path. Values already\n * accepted remain FIFO and handler failures do not alter source lifecycle\n * facts. A closed queue rejects pending values; an overflowed queue rejects\n * further values with the original overflow code so telemetry keeps one stable\n * backpressure classification. Callers must attach a handler to every enqueue\n * promise immediately: close() and overflow reject those promises.\n */\nexport function createLifecycleDeliveryQueue<T>(options: LifecycleDeliveryQueueOptions<T>): LifecycleDeliveryQueue<T> {\n\tassertPositiveSafeInteger(options.maxPendingEvents, \"maxPendingEvents\");\n\tif (options.maxPendingBytes !== undefined) assertPositiveSafeInteger(options.maxPendingBytes, \"maxPendingBytes\");\n\tif (typeof options.overflowCode !== \"string\" || !options.overflowCode.trim()) {\n\t\tthrow new Error(t(\"Lifecycle delivery queue overflowCode must be non-empty\"));\n\t}\n\n\tconst entries: QueueEntry<T>[] = [];\n\tlet status: LifecycleDeliveryQueueStatus = \"active\";\n\tlet pendingEvents = 0;\n\tlet pendingBytes = 0;\n\tlet accepted = 0;\n\tlet delivered = 0;\n\tlet rejected = 0;\n\tlet processing = false;\n\tlet drainPromise: Promise<void> | undefined;\n\tlet resolveDrain: (() => void) | undefined;\n\n\tconst ensureDrainPromise = (): Promise<void> => {\n\t\tif (drainPromise === undefined) {\n\t\t\tdrainPromise = new Promise<void>((resolve) => {\n\t\t\t\tresolveDrain = resolve;\n\t\t\t});\n\t\t}\n\t\treturn drainPromise;\n\t};\n\tconst settleDrainIfIdle = (): void => {\n\t\tif (processing || entries.length > 0) return;\n\t\tresolveDrain?.();\n\t\tdrainPromise = undefined;\n\t\tresolveDrain = undefined;\n\t};\n\tconst pump = async (): Promise<void> => {\n\t\tif (processing) return;\n\t\tprocessing = true;\n\t\ttry {\n\t\t\twhile (entries.length > 0) {\n\t\t\t\tconst entry = entries.shift();\n\t\t\t\tif (entry === undefined) continue;\n\t\t\t\ttry {\n\t\t\t\t\tawait options.deliver(entry.value);\n\t\t\t\t\tdelivered += 1;\n\t\t\t\t\tentry.resolve();\n\t\t\t\t} catch (error) {\n\t\t\t\t\trejected += 1;\n\t\t\t\t\tentry.reject(error);\n\t\t\t\t} finally {\n\t\t\t\t\tpendingEvents -= 1;\n\t\t\t\t\tpendingBytes -= entry.bytes;\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tprocessing = false;\n\t\t\tsettleDrainIfIdle();\n\t\t}\n\t};\n\n\treturn {\n\t\tenqueue(value) {\n\t\t\tif (status === \"overflowed\") {\n\t\t\t\trejected += 1;\n\t\t\t\treturn Promise.reject(\n\t\t\t\t\tnew LifecycleDeliveryQueueOverflowError(\n\t\t\t\t\t\toptions.overflowCode,\n\t\t\t\t\t\toptions.maxPendingEvents,\n\t\t\t\t\t\toptions.maxPendingBytes,\n\t\t\t\t\t\tpendingEvents,\n\t\t\t\t\t\tpendingBytes,\n\t\t\t\t\t\t0,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (status === \"closed\") {\n\t\t\t\trejected += 1;\n\t\t\t\treturn Promise.reject(new LifecycleDeliveryQueueClosedError());\n\t\t\t}\n\t\t\tconst bytes = options.measureBytes(value);\n\t\t\tassertPositiveSafeInteger(bytes, \"measureBytes result\");\n\t\t\tif (\n\t\t\t\tpendingEvents + 1 > options.maxPendingEvents ||\n\t\t\t\t(options.maxPendingBytes !== undefined && pendingBytes + bytes > options.maxPendingBytes)\n\t\t\t) {\n\t\t\t\tstatus = \"overflowed\";\n\t\t\t\trejected += 1;\n\t\t\t\treturn Promise.reject(\n\t\t\t\t\tnew LifecycleDeliveryQueueOverflowError(\n\t\t\t\t\t\toptions.overflowCode,\n\t\t\t\t\t\toptions.maxPendingEvents,\n\t\t\t\t\t\toptions.maxPendingBytes,\n\t\t\t\t\t\tpendingEvents,\n\t\t\t\t\t\tpendingBytes,\n\t\t\t\t\t\tbytes,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\taccepted += 1;\n\t\t\tpendingEvents += 1;\n\t\t\tpendingBytes += bytes;\n\t\t\tconst result = new Promise<void>((resolve, reject) => {\n\t\t\t\tentries.push({ value, bytes, resolve, reject });\n\t\t\t});\n\t\t\tensureDrainPromise();\n\t\t\tvoid pump();\n\t\t\treturn result;\n\t\t},\n\t\tdrain() {\n\t\t\tif (!processing && entries.length === 0) return Promise.resolve();\n\t\t\treturn ensureDrainPromise();\n\t\t},\n\t\tclose() {\n\t\t\tif (status === \"closed\") return;\n\t\t\tstatus = \"closed\";\n\t\t\tconst error = new LifecycleDeliveryQueueClosedError();\n\t\t\twhile (entries.length > 0) {\n\t\t\t\tconst entry = entries.shift();\n\t\t\t\tif (entry === undefined) continue;\n\t\t\t\tpendingEvents -= 1;\n\t\t\t\tpendingBytes -= entry.bytes;\n\t\t\t\trejected += 1;\n\t\t\t\tentry.reject(error);\n\t\t\t}\n\t\t\tsettleDrainIfIdle();\n\t\t},\n\t\tsnapshot: () =>\n\t\t\tObject.freeze({\n\t\t\t\tstatus,\n\t\t\t\tmaxPendingEvents: options.maxPendingEvents,\n\t\t\t\t...(options.maxPendingBytes === undefined ? {} : { maxPendingBytes: options.maxPendingBytes }),\n\t\t\t\tpendingEvents,\n\t\t\t\tpendingBytes,\n\t\t\t\taccepted,\n\t\t\t\tdelivered,\n\t\t\t\trejected,\n\t\t\t}),\n\t};\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import { t } from "../i18n/index.js";
1
2
  export class LifecycleDeliveryQueueOverflowError extends Error {
2
3
  code;
3
4
  maxPendingEvents;
@@ -28,7 +29,7 @@ export class LifecycleDeliveryQueueClosedError extends Error {
28
29
  }
29
30
  function assertPositiveSafeInteger(value, label) {
30
31
  if (!Number.isSafeInteger(value) || value < 1) {
31
- throw new Error(`Lifecycle delivery queue ${label} must be a positive safe integer`);
32
+ throw new Error(t("Lifecycle delivery queue {label} must be a positive safe integer", { label }));
32
33
  }
33
34
  }
34
35
  /**
@@ -44,7 +45,7 @@ export function createLifecycleDeliveryQueue(options) {
44
45
  if (options.maxPendingBytes !== undefined)
45
46
  assertPositiveSafeInteger(options.maxPendingBytes, "maxPendingBytes");
46
47
  if (typeof options.overflowCode !== "string" || !options.overflowCode.trim()) {
47
- throw new Error("Lifecycle delivery queue overflowCode must be non-empty");
48
+ throw new Error(t("Lifecycle delivery queue overflowCode must be non-empty"));
48
49
  }
49
50
  const entries = [];
50
51
  let status = "active";
@@ -1 +1 @@
1
- {"version":3,"file":"lifecycle-delivery-queue.js","sourceRoot":"","sources":["../../../src/core/extensions/lifecycle-delivery-queue.ts"],"names":[],"mappings":"AA6BA,MAAM,OAAO,mCAAoC,SAAQ,KAAK;IACpD,IAAI,CAAS;IACb,gBAAgB,CAAS;IACzB,eAAe,CAAU;IACzB,aAAa,CAAS;IACtB,YAAY,CAAS;IACrB,cAAc,CAAS;IAEhC,YACC,IAAY,EACZ,gBAAwB,EACxB,eAAmC,EACnC,aAAqB,EACrB,YAAoB,EACpB,cAAsB,EACrB;QACD,KAAK,CACJ,qDAAqD,aAAa,GAAG,CAAC,YAAY,gBAAgB,EAAE;YACnG,CAAC,eAAe,KAAK,SAAS;gBAC7B,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,qBAAqB,YAAY,GAAG,cAAc,YAAY,eAAe,EAAE,CAAC,CACpF,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,qCAAqC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,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T,QAAQ;SACR,CAAC;KACH,CAAC;AAAA,CACF","sourcesContent":["/** Internal FIFO queue for an explicitly buffered lifecycle subscription. */\nexport type LifecycleDeliveryQueueStatus = \"active\" | \"overflowed\" | \"closed\";\n\nexport interface LifecycleDeliveryQueueSnapshot {\n\treadonly status: LifecycleDeliveryQueueStatus;\n\treadonly maxPendingEvents: number;\n\treadonly maxPendingBytes?: number;\n\treadonly pendingEvents: number;\n\treadonly pendingBytes: number;\n\treadonly accepted: number;\n\treadonly delivered: number;\n\treadonly rejected: number;\n}\n\nexport interface LifecycleDeliveryQueueOptions<T> {\n\treadonly maxPendingEvents: number;\n\treadonly maxPendingBytes?: number;\n\treadonly measureBytes: (value: T) => number;\n\treadonly deliver: (value: T) => void | Promise<void>;\n\treadonly overflowCode: string;\n}\n\nexport interface LifecycleDeliveryQueue<T> {\n\tenqueue(value: T): Promise<void>;\n\tdrain(): Promise<void>;\n\tclose(): void;\n\tsnapshot(): LifecycleDeliveryQueueSnapshot;\n}\n\nexport class LifecycleDeliveryQueueOverflowError extends Error {\n\treadonly code: string;\n\treadonly maxPendingEvents: number;\n\treadonly maxPendingBytes?: number;\n\treadonly pendingEvents: number;\n\treadonly pendingBytes: number;\n\treadonly attemptedBytes: number;\n\n\tconstructor(\n\t\tcode: string,\n\t\tmaxPendingEvents: number,\n\t\tmaxPendingBytes: number | undefined,\n\t\tpendingEvents: number,\n\t\tpendingBytes: number,\n\t\tattemptedBytes: number,\n\t) {\n\t\tsuper(\n\t\t\t`Lifecycle delivery queue overflow: pending events ${pendingEvents + 1} exceeds ${maxPendingEvents}` +\n\t\t\t\t(maxPendingBytes === undefined\n\t\t\t\t\t? \"\"\n\t\t\t\t\t: ` or pending bytes ${pendingBytes + attemptedBytes} exceeds ${maxPendingBytes}`),\n\t\t);\n\t\tthis.name = \"LifecycleDeliveryQueueOverflowError\";\n\t\tthis.code = code;\n\t\tthis.maxPendingEvents = maxPendingEvents;\n\t\tthis.maxPendingBytes = maxPendingBytes;\n\t\tthis.pendingEvents = pendingEvents;\n\t\tthis.pendingBytes = pendingBytes;\n\t\tthis.attemptedBytes = attemptedBytes;\n\t}\n}\n\nexport class LifecycleDeliveryQueueClosedError extends Error {\n\treadonly code = \"lifecycle_delivery_closed\";\n\n\tconstructor() {\n\t\tsuper(\"Lifecycle delivery queue is closed\");\n\t\tthis.name = \"LifecycleDeliveryQueueClosedError\";\n\t}\n}\n\ninterface QueueEntry<T> {\n\treadonly value: T;\n\treadonly bytes: number;\n\treadonly resolve: () => void;\n\treadonly reject: (error: unknown) => void;\n}\n\nfunction assertPositiveSafeInteger(value: number, label: string): void {\n\tif (!Number.isSafeInteger(value) || value < 1) {\n\t\tthrow new Error(`Lifecycle delivery queue ${label} must be a positive safe integer`);\n\t}\n}\n\n/**\n * Overflow terminates only this subscription's acceptance path. Values already\n * accepted remain FIFO and handler failures do not alter source lifecycle\n * facts. A closed queue rejects pending values; an overflowed queue rejects\n * further values with the original overflow code so telemetry keeps one stable\n * backpressure classification. Callers must attach a handler to every enqueue\n * promise immediately: close() and overflow reject those promises.\n */\nexport function createLifecycleDeliveryQueue<T>(options: LifecycleDeliveryQueueOptions<T>): LifecycleDeliveryQueue<T> {\n\tassertPositiveSafeInteger(options.maxPendingEvents, \"maxPendingEvents\");\n\tif (options.maxPendingBytes !== undefined) assertPositiveSafeInteger(options.maxPendingBytes, \"maxPendingBytes\");\n\tif (typeof options.overflowCode !== \"string\" || !options.overflowCode.trim()) {\n\t\tthrow new Error(\"Lifecycle delivery queue overflowCode must be non-empty\");\n\t}\n\n\tconst entries: QueueEntry<T>[] = [];\n\tlet status: LifecycleDeliveryQueueStatus = \"active\";\n\tlet pendingEvents = 0;\n\tlet pendingBytes = 0;\n\tlet accepted = 0;\n\tlet delivered = 0;\n\tlet rejected = 0;\n\tlet processing = false;\n\tlet drainPromise: Promise<void> | undefined;\n\tlet resolveDrain: (() => void) | undefined;\n\n\tconst ensureDrainPromise = (): Promise<void> => {\n\t\tif (drainPromise === undefined) {\n\t\t\tdrainPromise = new Promise<void>((resolve) => {\n\t\t\t\tresolveDrain = resolve;\n\t\t\t});\n\t\t}\n\t\treturn drainPromise;\n\t};\n\tconst settleDrainIfIdle = (): void => {\n\t\tif (processing || entries.length > 0) return;\n\t\tresolveDrain?.();\n\t\tdrainPromise = undefined;\n\t\tresolveDrain = undefined;\n\t};\n\tconst pump = async (): Promise<void> => {\n\t\tif (processing) return;\n\t\tprocessing = true;\n\t\ttry {\n\t\t\twhile (entries.length > 0) {\n\t\t\t\tconst entry = entries.shift();\n\t\t\t\tif (entry === undefined) continue;\n\t\t\t\ttry {\n\t\t\t\t\tawait options.deliver(entry.value);\n\t\t\t\t\tdelivered += 1;\n\t\t\t\t\tentry.resolve();\n\t\t\t\t} catch (error) {\n\t\t\t\t\trejected += 1;\n\t\t\t\t\tentry.reject(error);\n\t\t\t\t} finally {\n\t\t\t\t\tpendingEvents -= 1;\n\t\t\t\t\tpendingBytes -= entry.bytes;\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tprocessing = false;\n\t\t\tsettleDrainIfIdle();\n\t\t}\n\t};\n\n\treturn {\n\t\tenqueue(value) {\n\t\t\tif (status === \"overflowed\") {\n\t\t\t\trejected += 1;\n\t\t\t\treturn Promise.reject(\n\t\t\t\t\tnew LifecycleDeliveryQueueOverflowError(\n\t\t\t\t\t\toptions.overflowCode,\n\t\t\t\t\t\toptions.maxPendingEvents,\n\t\t\t\t\t\toptions.maxPendingBytes,\n\t\t\t\t\t\tpendingEvents,\n\t\t\t\t\t\tpendingBytes,\n\t\t\t\t\t\t0,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (status === \"closed\") {\n\t\t\t\trejected += 1;\n\t\t\t\treturn Promise.reject(new LifecycleDeliveryQueueClosedError());\n\t\t\t}\n\t\t\tconst bytes = options.measureBytes(value);\n\t\t\tassertPositiveSafeInteger(bytes, \"measureBytes result\");\n\t\t\tif (\n\t\t\t\tpendingEvents + 1 > options.maxPendingEvents ||\n\t\t\t\t(options.maxPendingBytes !== undefined && pendingBytes + bytes > options.maxPendingBytes)\n\t\t\t) {\n\t\t\t\tstatus = \"overflowed\";\n\t\t\t\trejected += 1;\n\t\t\t\treturn Promise.reject(\n\t\t\t\t\tnew LifecycleDeliveryQueueOverflowError(\n\t\t\t\t\t\toptions.overflowCode,\n\t\t\t\t\t\toptions.maxPendingEvents,\n\t\t\t\t\t\toptions.maxPendingBytes,\n\t\t\t\t\t\tpendingEvents,\n\t\t\t\t\t\tpendingBytes,\n\t\t\t\t\t\tbytes,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\taccepted += 1;\n\t\t\tpendingEvents += 1;\n\t\t\tpendingBytes += bytes;\n\t\t\tconst result = new Promise<void>((resolve, reject) => {\n\t\t\t\tentries.push({ value, bytes, resolve, reject });\n\t\t\t});\n\t\t\tensureDrainPromise();\n\t\t\tvoid pump();\n\t\t\treturn result;\n\t\t},\n\t\tdrain() {\n\t\t\tif (!processing && entries.length === 0) return Promise.resolve();\n\t\t\treturn ensureDrainPromise();\n\t\t},\n\t\tclose() {\n\t\t\tif (status === \"closed\") return;\n\t\t\tstatus = \"closed\";\n\t\t\tconst error = new LifecycleDeliveryQueueClosedError();\n\t\t\twhile (entries.length > 0) {\n\t\t\t\tconst entry = entries.shift();\n\t\t\t\tif (entry === undefined) continue;\n\t\t\t\tpendingEvents -= 1;\n\t\t\t\tpendingBytes -= entry.bytes;\n\t\t\t\trejected += 1;\n\t\t\t\tentry.reject(error);\n\t\t\t}\n\t\t\tsettleDrainIfIdle();\n\t\t},\n\t\tsnapshot: () =>\n\t\t\tObject.freeze({\n\t\t\t\tstatus,\n\t\t\t\tmaxPendingEvents: options.maxPendingEvents,\n\t\t\t\t...(options.maxPendingBytes === undefined ? {} : { maxPendingBytes: options.maxPendingBytes }),\n\t\t\t\tpendingEvents,\n\t\t\t\tpendingBytes,\n\t\t\t\taccepted,\n\t\t\t\tdelivered,\n\t\t\t\trejected,\n\t\t\t}),\n\t};\n}\n"]}
1
+ {"version":3,"file":"lifecycle-delivery-queue.js","sourceRoot":"","sources":["../../../src/core/extensions/lifecycle-delivery-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAC;AA8BrC,MAAM,OAAO,mCAAoC,SAAQ,KAAK;IACpD,IAAI,CAAS;IACb,gBAAgB,CAAS;IACzB,eAAe,CAAU;IACzB,aAAa,CAAS;IACtB,YAAY,CAAS;IACrB,cAAc,CAAS;IAEhC,YACC,IAAY,EACZ,gBAAwB,EACxB,eAAmC,EACnC,aAAqB,EACrB,YAAoB,EACpB,cAAsB,EACrB;QACD,KAAK,CACJ,qDAAqD,aAAa,GAAG,CAAC,YAAY,gBAAgB,EAAE;YACnG,CAAC,eAAe,KAAK,SAAS;gBAC7B,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,qBAAqB,YAAY,GAAG,cAAc,YAAY,eAAe,EAAE,CAAC,CACpF,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,qCAAqC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IAAA,CACrC;CACD;AAED,MAAM,OAAO,iCAAkC,SAAQ,KAAK;IAClD,IAAI,GAAG,2BAA2B,CAAC;IAE5C,cAAc;QACb,KAAK,CAAC,oCAAoC,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,GAAG,mCAAmC,CAAC;IAAA,CAChD;CACD;AASD,SAAS,yBAAyB,CAAC,KAAa,EAAE,KAAa,EAAQ;IACtE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CA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EAAE,CAAC;YAClE,OAAO,kBAAkB,EAAE,CAAC;QAAA,CAC5B;QACD,KAAK,GAAG;YACP,IAAI,MAAM,KAAK,QAAQ;gBAAE,OAAO;YAChC,MAAM,GAAG,QAAQ,CAAC;YAClB,MAAM,KAAK,GAAG,IAAI,iCAAiC,EAAE,CAAC;YACtD,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC3B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;gBAC9B,IAAI,KAAK,KAAK,SAAS;oBAAE,SAAS;gBAClC,aAAa,IAAI,CAAC,CAAC;gBACnB,YAAY,IAAI,KAAK,CAAC,KAAK,CAAC;gBAC5B,QAAQ,IAAI,CAAC,CAAC;gBACd,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC;YACD,iBAAiB,EAAE,CAAC;QAAA,CACpB;QACD,QAAQ,EAAE,GAAG,EAAE,CACd,MAAM,CAAC,MAAM,CAAC;YACb,MAAM;YACN,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;YAC1C,GAAG,CAAC,OAAO,CAAC,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,OAAO,CAAC,eAAe,EAAE,CAAC;YAC9F,aAAa;YACb,YAAY;YACZ,QAAQ;YACR,SAAS;YACT,QAAQ;SACR,CAAC;KACH,CAAC;AAAA,CACF","sourcesContent":["import { t } from \"../i18n/index.ts\";\n/** Internal FIFO queue for an explicitly buffered lifecycle subscription. */\nexport type LifecycleDeliveryQueueStatus = \"active\" | \"overflowed\" | \"closed\";\n\nexport interface LifecycleDeliveryQueueSnapshot {\n\treadonly status: LifecycleDeliveryQueueStatus;\n\treadonly maxPendingEvents: number;\n\treadonly maxPendingBytes?: number;\n\treadonly pendingEvents: number;\n\treadonly pendingBytes: number;\n\treadonly accepted: number;\n\treadonly delivered: number;\n\treadonly rejected: number;\n}\n\nexport interface LifecycleDeliveryQueueOptions<T> {\n\treadonly maxPendingEvents: number;\n\treadonly maxPendingBytes?: number;\n\treadonly measureBytes: (value: T) => number;\n\treadonly deliver: (value: T) => void | Promise<void>;\n\treadonly overflowCode: string;\n}\n\nexport interface LifecycleDeliveryQueue<T> {\n\tenqueue(value: T): Promise<void>;\n\tdrain(): Promise<void>;\n\tclose(): void;\n\tsnapshot(): LifecycleDeliveryQueueSnapshot;\n}\n\nexport class LifecycleDeliveryQueueOverflowError extends Error {\n\treadonly code: string;\n\treadonly maxPendingEvents: number;\n\treadonly maxPendingBytes?: number;\n\treadonly pendingEvents: number;\n\treadonly pendingBytes: number;\n\treadonly attemptedBytes: number;\n\n\tconstructor(\n\t\tcode: string,\n\t\tmaxPendingEvents: number,\n\t\tmaxPendingBytes: number | undefined,\n\t\tpendingEvents: number,\n\t\tpendingBytes: number,\n\t\tattemptedBytes: number,\n\t) {\n\t\tsuper(\n\t\t\t`Lifecycle delivery queue overflow: pending events ${pendingEvents + 1} exceeds ${maxPendingEvents}` +\n\t\t\t\t(maxPendingBytes === undefined\n\t\t\t\t\t? \"\"\n\t\t\t\t\t: ` or pending bytes ${pendingBytes + attemptedBytes} exceeds ${maxPendingBytes}`),\n\t\t);\n\t\tthis.name = \"LifecycleDeliveryQueueOverflowError\";\n\t\tthis.code = code;\n\t\tthis.maxPendingEvents = maxPendingEvents;\n\t\tthis.maxPendingBytes = maxPendingBytes;\n\t\tthis.pendingEvents = pendingEvents;\n\t\tthis.pendingBytes = pendingBytes;\n\t\tthis.attemptedBytes = attemptedBytes;\n\t}\n}\n\nexport class LifecycleDeliveryQueueClosedError extends Error {\n\treadonly code = \"lifecycle_delivery_closed\";\n\n\tconstructor() {\n\t\tsuper(\"Lifecycle delivery queue is closed\");\n\t\tthis.name = \"LifecycleDeliveryQueueClosedError\";\n\t}\n}\n\ninterface QueueEntry<T> {\n\treadonly value: T;\n\treadonly bytes: number;\n\treadonly resolve: () => void;\n\treadonly reject: (error: unknown) => void;\n}\n\nfunction assertPositiveSafeInteger(value: number, label: string): void {\n\tif (!Number.isSafeInteger(value) || value < 1) {\n\t\tthrow new Error(t(\"Lifecycle delivery queue {label} must be a positive safe integer\", { label }));\n\t}\n}\n\n/**\n * Overflow terminates only this subscription's acceptance path. Values already\n * accepted remain FIFO and handler failures do not alter source lifecycle\n * facts. A closed queue rejects pending values; an overflowed queue rejects\n * further values with the original overflow code so telemetry keeps one stable\n * backpressure classification. Callers must attach a handler to every enqueue\n * promise immediately: close() and overflow reject those promises.\n */\nexport function createLifecycleDeliveryQueue<T>(options: LifecycleDeliveryQueueOptions<T>): LifecycleDeliveryQueue<T> {\n\tassertPositiveSafeInteger(options.maxPendingEvents, \"maxPendingEvents\");\n\tif (options.maxPendingBytes !== undefined) assertPositiveSafeInteger(options.maxPendingBytes, \"maxPendingBytes\");\n\tif (typeof options.overflowCode !== \"string\" || !options.overflowCode.trim()) {\n\t\tthrow new Error(t(\"Lifecycle delivery queue overflowCode must be non-empty\"));\n\t}\n\n\tconst entries: QueueEntry<T>[] = [];\n\tlet status: LifecycleDeliveryQueueStatus = \"active\";\n\tlet pendingEvents = 0;\n\tlet pendingBytes = 0;\n\tlet accepted = 0;\n\tlet delivered = 0;\n\tlet rejected = 0;\n\tlet processing = false;\n\tlet drainPromise: Promise<void> | undefined;\n\tlet resolveDrain: (() => void) | undefined;\n\n\tconst ensureDrainPromise = (): Promise<void> => {\n\t\tif (drainPromise === undefined) {\n\t\t\tdrainPromise = new Promise<void>((resolve) => {\n\t\t\t\tresolveDrain = resolve;\n\t\t\t});\n\t\t}\n\t\treturn drainPromise;\n\t};\n\tconst settleDrainIfIdle = (): void => {\n\t\tif (processing || entries.length > 0) return;\n\t\tresolveDrain?.();\n\t\tdrainPromise = undefined;\n\t\tresolveDrain = undefined;\n\t};\n\tconst pump = async (): Promise<void> => {\n\t\tif (processing) return;\n\t\tprocessing = true;\n\t\ttry {\n\t\t\twhile (entries.length > 0) {\n\t\t\t\tconst entry = entries.shift();\n\t\t\t\tif (entry === undefined) continue;\n\t\t\t\ttry {\n\t\t\t\t\tawait options.deliver(entry.value);\n\t\t\t\t\tdelivered += 1;\n\t\t\t\t\tentry.resolve();\n\t\t\t\t} catch (error) {\n\t\t\t\t\trejected += 1;\n\t\t\t\t\tentry.reject(error);\n\t\t\t\t} finally {\n\t\t\t\t\tpendingEvents -= 1;\n\t\t\t\t\tpendingBytes -= entry.bytes;\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tprocessing = false;\n\t\t\tsettleDrainIfIdle();\n\t\t}\n\t};\n\n\treturn {\n\t\tenqueue(value) {\n\t\t\tif (status === \"overflowed\") {\n\t\t\t\trejected += 1;\n\t\t\t\treturn Promise.reject(\n\t\t\t\t\tnew LifecycleDeliveryQueueOverflowError(\n\t\t\t\t\t\toptions.overflowCode,\n\t\t\t\t\t\toptions.maxPendingEvents,\n\t\t\t\t\t\toptions.maxPendingBytes,\n\t\t\t\t\t\tpendingEvents,\n\t\t\t\t\t\tpendingBytes,\n\t\t\t\t\t\t0,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (status === \"closed\") {\n\t\t\t\trejected += 1;\n\t\t\t\treturn Promise.reject(new LifecycleDeliveryQueueClosedError());\n\t\t\t}\n\t\t\tconst bytes = options.measureBytes(value);\n\t\t\tassertPositiveSafeInteger(bytes, \"measureBytes result\");\n\t\t\tif (\n\t\t\t\tpendingEvents + 1 > options.maxPendingEvents ||\n\t\t\t\t(options.maxPendingBytes !== undefined && pendingBytes + bytes > options.maxPendingBytes)\n\t\t\t) {\n\t\t\t\tstatus = \"overflowed\";\n\t\t\t\trejected += 1;\n\t\t\t\treturn Promise.reject(\n\t\t\t\t\tnew LifecycleDeliveryQueueOverflowError(\n\t\t\t\t\t\toptions.overflowCode,\n\t\t\t\t\t\toptions.maxPendingEvents,\n\t\t\t\t\t\toptions.maxPendingBytes,\n\t\t\t\t\t\tpendingEvents,\n\t\t\t\t\t\tpendingBytes,\n\t\t\t\t\t\tbytes,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\taccepted += 1;\n\t\t\tpendingEvents += 1;\n\t\t\tpendingBytes += bytes;\n\t\t\tconst result = new Promise<void>((resolve, reject) => {\n\t\t\t\tentries.push({ value, bytes, resolve, reject });\n\t\t\t});\n\t\t\tensureDrainPromise();\n\t\t\tvoid pump();\n\t\t\treturn result;\n\t\t},\n\t\tdrain() {\n\t\t\tif (!processing && entries.length === 0) return Promise.resolve();\n\t\t\treturn ensureDrainPromise();\n\t\t},\n\t\tclose() {\n\t\t\tif (status === \"closed\") return;\n\t\t\tstatus = \"closed\";\n\t\t\tconst error = new LifecycleDeliveryQueueClosedError();\n\t\t\twhile (entries.length > 0) {\n\t\t\t\tconst entry = entries.shift();\n\t\t\t\tif (entry === undefined) continue;\n\t\t\t\tpendingEvents -= 1;\n\t\t\t\tpendingBytes -= entry.bytes;\n\t\t\t\trejected += 1;\n\t\t\t\tentry.reject(error);\n\t\t\t}\n\t\t\tsettleDrainIfIdle();\n\t\t},\n\t\tsnapshot: () =>\n\t\t\tObject.freeze({\n\t\t\t\tstatus,\n\t\t\t\tmaxPendingEvents: options.maxPendingEvents,\n\t\t\t\t...(options.maxPendingBytes === undefined ? {} : { maxPendingBytes: options.maxPendingBytes }),\n\t\t\t\tpendingEvents,\n\t\t\t\tpendingBytes,\n\t\t\t\taccepted,\n\t\t\t\tdelivered,\n\t\t\t\trejected,\n\t\t\t}),\n\t};\n}\n"]}
@@ -113,6 +113,12 @@ export interface CodingAgentFacadeV1 {
113
113
  steering: string[];
114
114
  followUp: string[];
115
115
  };
116
+ /** Delegates to AgentSession.reorderQueuedMessages(): indices refer to the
117
+ * queued display lists; a stale or out-of-bounds move returns false. */
118
+ reorderQueuedMessages(queue: "steer" | "followUp", from: number, to: number): boolean;
119
+ /** Delegates to AgentSession.removeQueuedMessageAt(): removes by queued
120
+ * display list index; a stale index returns null. */
121
+ removeQueuedMessageAt(queue: "steer" | "followUp", index: number): string | null;
116
122
  /** Delegates to AgentSession.recordSuiteMismatch(). */
117
123
  recordSuiteMismatch(originalSuiteId: string, currentSuiteId: string): void;
118
124
  /** Delegates to AgentSession.getSessionAPI(). */
@@ -1 +1 @@
1
- {"version":3,"file":"coding-agent-facade.d.ts","sourceRoot":"","sources":["../../../src/core/facade/coding-agent-facade.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kDAAkD,CAAC;AAE5F,OAAO,KAAK,EACX,YAAY,EACZ,yBAAyB,EACzB,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,sBAAsB,EACtB,YAAY,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC3F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,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AA;KAAE,CAAC,CAAC;IAGxD,wHAAwH;IACxH,kBAAkB,IAAI,SAAS,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;IAC5C,sFAAsF;IACtF,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;IACjD,2EAA2E;IAC3E,cAAc,IAAI,MAAM,GAAG,SAAS,CAAC;IACrC;;;;OAIG;IACH,eAAe,IAAI,mBAAmB,CAAC;IACvC,4EAA4E;IAC5E,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;IACtE,0EAA0E;IAC1E,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IACrE;;;;OAIG;IACH,mBAAmB,IAAI,gBAAgB,CAAC;IACxC;;;;;OAKG;IACH,iBAAiB,IAAI,YAAY,EAAE,CAAC;IAGpC;;;;;OAKG;IACH,mBAAmB,IAAI,gBAAgB,CAAC;IAIxC,uDAAuD;IACvD,mBAAmB,IAAI,SAAS,MAAM,EAAE,CAAC;IACzC,uDAAuD;IACvD,mBAAmB,IAAI,SAAS,MAAM,EAAE,CAAC;IAIzC,8CAA8C;IAC9C,eAAe,IAAI,MAAM,CAAC;IAC1B,+CAA+C;IAC/C,aAAa,IAAI,OAAO,CAAC;IACzB,iDAAiD;IACjD,aAAa,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAG3C,2CAA2C;IAC3C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB;AAED,+FAA+F;AAC/F,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,YAAY,GAAG,mBAAmB,CAmGlF","sourcesContent":["/**\n * Stable facade v1: a read-only mirror plus pass-through run control and\n * session write paths over one AgentSession.\n *\n * Design: docs/design/稳定门面统一入口设计.md (§2.5 阶段 0 实际面, §2.6 slice 1\n * 读面, §2.7 slice 2 读面, §2.8 阶段 2 写面, §2.9 阶段 3 RPC 面, §3 API 面 v1,\n * §4 阶段 0/1/2/3). Every member is a pure delegate onto the wrapped\n * AgentSession or its existing curated surfaces (`getSessionAPI()`, `host`).\n * No new behavior, no policy, no state of its own. Product entry points\n * (TUI/CLI/RPC/Embedded) migrate onto this surface in later phases;\n * AgentSession stays the internal adapter behind it.\n *\n * Scope: in-package stable surface for those product entry points. It is not\n * exported from the package root and is not a cross-package public contract.\n */\n\nimport type { AgentState, ThinkingLevel } from \"@agent-forge/agent-core\";\nimport type { AuthCheck, AuthResult, ImageContent } from \"@agent-forge/ai\";\nimport type { Api, Model } from \"@agent-forge/ai/compat\";\nimport type { ModelCatalogRuntime } from \"../../modes/interactive/model-catalog-refresh.ts\";\nimport { readSessionSuiteBinding } from \"../../profiles/suite-loader.ts\";\nimport type {\n\tAgentSession,\n\tAgentSessionEventListener,\n\tModelCycleResult,\n\tModelMutationOptions,\n\tPromptOptions,\n\tQueuedInputDisposition,\n\tSessionStats,\n} from \"../agent-session.ts\";\nimport type { CompactionCancelledResult } from \"../agent-session-compaction.ts\";\nimport type { ForkableUserMessage } from \"../agent-session-projection.ts\";\nimport type { BashResult } from \"../bash-executor.ts\";\nimport type { ModelPriceSource } from \"../cache-stats.ts\";\nimport type { CompactionResult } from \"../compaction/index.ts\";\nimport type { ResourceDiagnostic } from \"../diagnostics.ts\";\nimport type { ContextUsage, PromptOutcome, SessionAPI } from \"../extensions/public-api.ts\";\nimport type { InputSource } from \"../input-source.ts\";\nimport type { ModelRuntime } from \"../model-runtime.ts\";\nimport type { PromptTemplate } from \"../prompt-templates.ts\";\nimport type { ThemeMetaV1 } from \"../resource-loader.ts\";\nimport type { BranchSummaryEntry, SessionEntry, SessionHeader, SessionTreeNode } from \"../session-manager.ts\";\nimport type { Skill } from \"../skills.ts\";\nimport type { BashOperations } from \"../tools/bash.ts\";\nimport type { ToolDefinition } from \"../tools/tool-definition.ts\";\n\n/** Prompt options for the facade. Identical to AgentSession PromptOptions. */\nexport type CodingAgentFacadePromptOptionsV1 = PromptOptions;\n\n/**\n * Narrow credential/provider auth projection (D-048): the TUI auth surface\n * only. Covers exactly the seven methods the auth host consumes\n * (`getProviders`/`getProvider`/`getProviderAuthStatus`/`isUsingOAuth`/\n * `listCredentials`/`login`/`logout`); the full ModelRuntime never leaks to\n * the host. The credential-management CapabilityAPI semantics question stays\n * open (D-047 裁决 3); this narrows the TUI host path without deciding it.\n */\nexport type ModelAuthRuntime = Pick<\n\tModelRuntime,\n\t\"getProviders\" | \"getProvider\" | \"getProviderAuthStatus\" | \"isUsingOAuth\" | \"listCredentials\" | \"login\" | \"logout\"\n>;\n\n/**\n * Stable facade v1: the consumption surface for product hosts, versioned per\n * repo convention (EmbeddedSdkBindingV1 precedent). Members are pass-throughs\n * onto the wrapped AgentSession; new members must extend the facade design\n * doc first (门面腐化 guard, 设计 §6).\n */\nexport interface CodingAgentFacadeV1 {\n\treadonly version: 1;\n\n\t// --- Run control ---\n\t/**\n\t * Delegates to AgentSession.prompt(). The full PromptOptions pass through,\n\t * including the internal RPC preflight hook (`preflightResult`) that RPC\n\t * mode uses to observe prompt acceptance (阶段 3, 设计 §2.9).\n\t */\n\tprompt(text: string, options?: CodingAgentFacadePromptOptionsV1): Promise<PromptOutcome>;\n\t/** Delegates to AgentSession.steer(). */\n\tsteer(text: string, images?: ImageContent[], options?: { source?: InputSource }): Promise<QueuedInputDisposition>;\n\t/** Delegates to AgentSession.abort(); `cancelAgentTasks: false` stops the\n\t * current turn without cancelling background agent tasks (设计 子代理运行时\n\t * §4.2 中断分级,2026-10-02 — the TUI Esc path always passes false). */\n\tabort(options?: { cancelAgentTasks?: boolean }): Promise<void>;\n\t/** Delegates to AgentSession.abortAgentTasks(): cancel every background agent\n\t * task without aborting the current turn (/stop-agents execution face). */\n\tabortAgentTasks(): void;\n\t/** Delegates to AgentSession.getActiveAgentTaskCount(). */\n\tgetActiveAgentTaskCount(): number;\n\t/** Delegates to AgentSession.waitForIdle(). */\n\twaitForIdle(): Promise<void>;\n\n\t// --- Session write paths ---\n\t/** Delegates to AgentSession.compact(). */\n\tcompact(customInstructions?: string): Promise<CompactionResult | CompactionCancelledResult>;\n\t/** Delegates to AgentSession.navigateTree(). */\n\tnavigateTree(\n\t\ttargetId: string,\n\t\toptions?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string },\n\t): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>;\n\t/** Delegates to AgentSession.reload(). */\n\treload(options?: { beforeSessionStart?: () => void | Promise<void> }): Promise<void>;\n\t/** Delegates to AgentSession.setModel(). */\n\tsetModel(model: Model<Api>, options?: ModelMutationOptions): Promise<void>;\n\t/** Delegates to AgentSession.setThinkingLevel(). */\n\tsetThinkingLevel(level: ThinkingLevel, options?: ModelMutationOptions): void;\n\t/** Delegates to AgentSession.setActiveToolsByName(). */\n\tsetActiveToolsByName(toolNames: string[]): void;\n\t/**\n\t * Queued-message read view, composed from AgentSession.getSteeringMessages()\n\t * and AgentSession.getFollowUpMessages(). AgentSession has no single\n\t * getQueuedMessages(); the shape mirrors clearQueue()'s return value.\n\t */\n\tgetQueuedMessages(): { steering: readonly string[]; followUp: readonly string[] };\n\t/** Delegates to AgentSession.clearQueue(). */\n\tclearQueue(): { steering: string[]; followUp: string[] };\n\t/** Delegates to AgentSession.recordSuiteMismatch(). */\n\trecordSuiteMismatch(originalSuiteId: string, currentSuiteId: string): void;\n\t/** Delegates to AgentSession.getSessionAPI(). */\n\tgetSessionAPI(): SessionAPI;\n\n\t// --- Read-only mirror ---\n\t/** Delegates to AgentSession.isIdle. */\n\tisIdle(): boolean;\n\t/** Mirrors AgentSession.state verbatim (phase 0; a projected state view is a later phase, 设计 §3). */\n\tgetState(): AgentState;\n\t/** Delegates to AgentSession.model. */\n\tgetModel(): Model<Api> | undefined;\n\t/** Delegates to AgentSession.getActiveToolNames(). */\n\tgetToolNames(): string[];\n\t/** Delegates to AgentSession.sessionId (via SessionAPI.getSessionId semantics). */\n\tgetSessionId(): string;\n\t/**\n\t * Suite id from the session-suite binding entry (设计 §10.1), read through\n\t * SessionAPI.getBranchEntries(). Undefined when the session carries no\n\t * suite binding.\n\t */\n\tgetSuiteId(): string | undefined;\n\t/** Delegates to AgentSession.sessionManager.getHeader(). SessionManager itself never leaks. */\n\tgetHeader(): SessionHeader | null;\n\t/** Delegates to AgentSession.subscribe(). Event types pass through verbatim (设计 §3). */\n\tsubscribe(listener: AgentSessionEventListener): () => void;\n\t/**\n\t * Invoked after each raw agent event is delivered to session processing;\n\t * the listener is awaited serially by the agent loop and participates in\n\t * run settlement. Exists for stdout backpressure pacing (D-046); the raw\n\t * event payload and abort signal are deliberately not exposed.\n\t */\n\tsubscribeRawEventGate(listener: () => void | Promise<void>): () => void;\n\n\t// --- Read surface (phase 1 slice 1, TUI display/selector reads, 设计 §2.6) ---\n\t/** Delegates to AgentSession.sessionName (which reads sessionManager.getSessionName()). */\n\tgetSessionName(): string | undefined;\n\t/** Delegates to AgentSession.isCompacting: a compaction or branch summarization is running (session level). */\n\tisCompacting(): boolean;\n\t/**\n\t * Delegates to AgentSession.isStreaming: an agent run is active at the\n\t * session level. Distinct from AgentState.isStreaming (agent-level stream\n\t * flag); do not interchange the two.\n\t */\n\tisStreaming(): boolean;\n\t/** Delegates to AgentSession.getContextUsage(). */\n\tgetContextUsage(): ContextUsage | undefined;\n\t/** Delegates to AgentSession.systemPrompt (effective prompt, including per-turn extension modifications). */\n\tgetSystemPrompt(): string;\n\t/** Delegates to AgentSession.scopedModels. Read view only; setScopedModels stays a phase 2 write path. */\n\tgetScopedModels(): ReadonlyArray<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\t/** Delegates to SessionManager.getTree() on the wrapped session. SessionManager itself never leaks. */\n\tgetTree(): SessionTreeNode[];\n\t/** Delegates to SessionManager.getLeafId() on the wrapped session. SessionManager itself never leaks. */\n\tgetLeafId(): string | null;\n\n\t// --- Read surface (phase 1 slice 2, TUI display/selector cluster convergence, 设计 §2.7) ---\n\t/** Delegates to AgentSession.promptTemplates (file-based prompt templates). */\n\tgetPromptTemplates(): ReadonlyArray<PromptTemplate>;\n\t/** Delegates to AgentSession.getToolDefinition(name): the registered tool definition by name, for diagnostics/rendering. */\n\tgetToolDefinition(name: string): ToolDefinition | undefined;\n\t/** Delegates to SessionManager.getCwd() on the wrapped session; identical to host.cwd. SessionManager itself never leaks. */\n\tgetCwd(): string;\n\t/** Delegates to SessionManager.getEntries() on the wrapped session; identical to host.entries. SessionManager itself never leaks. */\n\tgetEntries(): SessionEntry[];\n\t/** Delegates to AgentSession.pendingMessageCount: queued steering + follow-up message count. */\n\tgetPendingMessageCount(): number;\n\n\t// --- Write surface (phase 2, TUI write path convergence, 设计 §2.8) ---\n\t/** Delegates to AgentSession.followUp(). */\n\tfollowUp(text: string, images?: ImageContent[], options?: { source?: InputSource }): Promise<QueuedInputDisposition>;\n\t/** Delegates to AgentSession.setScopedModels(). */\n\tsetScopedModels(scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>): void;\n\t/** Delegates to AgentSession.cycleModel(). */\n\tcycleModel(\n\t\tdirection?: \"forward\" | \"backward\",\n\t\toptions?: ModelMutationOptions,\n\t): Promise<ModelCycleResult | undefined>;\n\t/** Delegates to AgentSession.cycleThinkingLevel(). */\n\tcycleThinkingLevel(options?: ModelMutationOptions): ThinkingLevel | undefined;\n\t/** Delegates to AgentSession.setSteeringMode(). */\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\"): void;\n\t/** Delegates to AgentSession.setFollowUpMode(). */\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\"): void;\n\t/** Delegates to AgentSession.setAutoCompactionEnabled(). */\n\tsetAutoCompactionEnabled(enabled: boolean): void;\n\t/** Delegates to AgentSession.setSessionName(). */\n\tsetSessionName(name: string): void;\n\t/** Delegates to AgentSession.abortBash(). */\n\tabortBash(): void;\n\t/** Delegates to AgentSession.abortCompaction(). */\n\tabortCompaction(): void;\n\t/** Delegates to AgentSession.abortRetry(). */\n\tabortRetry(): void;\n\t/** Delegates to AgentSession.abortBranchSummary(). */\n\tabortBranchSummary(): void;\n\t/** Delegates to AgentSession.captureBashEpoch(). */\n\tcaptureBashEpoch(): number;\n\t/** Delegates to AgentSession.isBashEpochCurrent(). */\n\tisBashEpochCurrent(epoch: number): boolean;\n\t/** Delegates to AgentSession.emitUserBash(): dispatches the user.bash lifecycle facts. */\n\temitUserBash(excludeFromContext: boolean): void;\n\t/** Delegates to AgentSession.executeBash(). */\n\texecuteBash(\n\t\tcommand: string,\n\t\tonChunk?: (chunk: string) => void,\n\t\toptions?: { excludeFromContext?: boolean; id?: string; operations?: BashOperations },\n\t): Promise<BashResult>;\n\t/** Delegates to AgentSession.recordBashResult(). */\n\trecordBashResult(\n\t\tcommand: string,\n\t\tresult: BashResult,\n\t\toptions?: { excludeFromContext?: boolean; epoch?: number },\n\t): void;\n\n\t// --- Read surface (phase 3, RPC host state reads, 设计 §2.9) ---\n\t/** Delegates to AgentSession.thinkingLevel. */\n\tgetThinkingLevel(): ThinkingLevel;\n\t/** Delegates to AgentSession.steeringMode. */\n\tgetSteeringMode(): \"all\" | \"one-at-a-time\";\n\t/** Delegates to AgentSession.followUpMode. */\n\tgetFollowUpMode(): \"all\" | \"one-at-a-time\";\n\t/** Delegates to AgentSession.sessionFile. */\n\tgetSessionFile(): string | undefined;\n\t/** Delegates to AgentSession.autoCompactionEnabled. */\n\tisAutoCompactionEnabled(): boolean;\n\t/** Delegates to AgentSession.getAvailableThinkingLevels(). */\n\tgetAvailableThinkingLevels(): ThinkingLevel[];\n\t/** Delegates to AgentSession.getUserMessagesForForking(). */\n\tgetUserMessagesForForking(): ForkableUserMessage[];\n\t/** Delegates to AgentSession.getLastAssistantText(). */\n\tgetLastAssistantText(): string | undefined;\n\t/** Delegates to AgentSession.getSessionStats(). */\n\tgetSessionStats(): SessionStats;\n\n\t// --- Write surface (phase 3, RPC host writes, 设计 §2.9) ---\n\t/** Delegates to AgentSession.setAutoRetryEnabled(). */\n\tsetAutoRetryEnabled(enabled: boolean): void;\n\t/** Delegates to AgentSession.exportToHtml(), including the themeName option. */\n\texportToHtml(outputPath?: string, options?: { themeName?: string }): Promise<string>;\n\n\t// --- Session write path (阶段 4 slice 3 v1 修订, D-041) ---\n\t/**\n\t * Delegates to SessionManager.appendLabelChange() on the wrapped session.\n\t * TUI tree selector label rename write point; SessionAPI has no label write.\n\t */\n\tappendLabelChange(entryId: string, label: string | undefined): string;\n\n\t// --- Resource read surface (阶段 4 slice 3 v1 修订, D-041) ---\n\t/**\n\t * Clean read projections over the wrapped session's resource loader. Skills/\n\t * prompts/agents-files results pass through verbatim; themes and extensions\n\t * are the metadata projections (themes as ThemeMetaV1 without the modes\n\t * Theme class; loader registration maps and the shared runtime never\n\t * leak). Guard reason: TUI startup listing/autocomplete/diagnostics\n\t * consume these read points directly; SessionAPI/CapabilityAPI are\n\t * capability-side contracts with no host display projections.\n\t */\n\t/** Delegates to ResourceLoader.getSkills() on the wrapped session. */\n\tgetSkills(): { skills: Skill[]; diagnostics: ResourceDiagnostic[] };\n\t/** Delegates to ResourceLoader.getPrompts() on the wrapped session. */\n\tgetPrompts(): { prompts: PromptTemplate[]; diagnostics: ResourceDiagnostic[] };\n\t/** Delegates to ResourceLoader.getThemes() on the wrapped session. */\n\tgetThemes(): { themes: ThemeMetaV1[]; diagnostics: ResourceDiagnostic[] };\n\t/** Delegates to ResourceLoader.getAgentsFiles() on the wrapped session. */\n\tgetAgentsFiles(): { agentsFiles: Array<{ path: string; content: string }> };\n\t/** Delegates to ResourceLoader.getSystemPromptSource() on the wrapped session. */\n\tgetSystemPromptSource(): { path: string } | undefined;\n\t/** Delegates to ResourceLoader.getAppendSystemPromptSources() on the wrapped session. */\n\tgetAppendSystemPromptSources(): Array<{ path: string }>;\n\n\t// --- Model/catalog/context read surface (v1 修订, D-047: TUI direct session reads zeroed) ---\n\t/** Delegates to ModelRuntime.getAvailableSnapshot() on the wrapped session (D-047); ModelRuntime itself never leaks. */\n\tgetAvailableModels(): readonly Model<Api>[];\n\t/** Delegates to ModelRuntime.isUsingSubscription() on the wrapped session (D-047). */\n\tisUsingSubscription(providerId: string): boolean;\n\t/** Delegates to ModelRuntime.getError() on the wrapped session (D-047). */\n\tgetModelsError(): string | undefined;\n\t/**\n\t * Narrow `ModelCatalogRuntime` projection of the wrapped session's\n\t * ModelRuntime for the shared catalog-refresh coordinator (D-047). A\n\t * projection, not a wrapper: the full runtime never leaks.\n\t */\n\tgetModelCatalog(): ModelCatalogRuntime;\n\t/** Delegates to ModelRuntime.checkAuth() on the wrapped session (D-047). */\n\tcheckProviderAuth(providerId: string): Promise<AuthCheck | undefined>;\n\t/** Delegates to ModelRuntime.getAuth() on the wrapped session (D-047). */\n\tgetProviderAuth(providerId: string): Promise<AuthResult | undefined>;\n\t/**\n\t * Narrow `ModelPriceSource` projection of the wrapped session's\n\t * ModelRuntime for the cache-stats pure functions (D-047). A projection,\n\t * not a wrapper: the full runtime never leaks.\n\t */\n\tgetModelPriceSource(): ModelPriceSource;\n\t/**\n\t * Delegates to SessionManager.buildContextEntries() on the wrapped session\n\t * (D-047; delegation restored by the D-047 regression fix — the\n\t * incrementally maintained byId index is required for correct context\n\t * paths after a compaction commit). SessionManager itself never leaks.\n\t */\n\tgetContextEntries(): SessionEntry[];\n\n\t// --- Credential/provider auth read surface (v1 修订, D-048: TUI auth host path) ---\n\t/**\n\t * Narrow `ModelAuthRuntime` projection of the wrapped session's ModelRuntime\n\t * for the TUI auth surface (D-048). A projection, not a wrapper: the full\n\t * runtime never leaks. The credential-management CapabilityAPI semantics\n\t * question stays open (D-047 裁决 3); this only narrows the TUI host path.\n\t */\n\tgetModelAuthRuntime(): ModelAuthRuntime;\n\n\t// --- Session stats/text read surface (v1 修订, B-S2b③-S3a: TUI direct\n\t// session stats/text read cluster convergence) ---\n\t/** Delegates to AgentSession.getSteeringMessages(). */\n\tgetSteeringMessages(): readonly string[];\n\t/** Delegates to AgentSession.getFollowUpMessages(). */\n\tgetFollowUpMessages(): readonly string[];\n\n\t// --- Status/settings + export read surface (v1 修订, B-S2b③-S3b+c: TUI\n\t// status/settings/export cluster direct session read convergence) ---\n\t/** Delegates to AgentSession.retryAttempt. */\n\tgetRetryAttempt(): number;\n\t/** Delegates to AgentSession.isBashRunning. */\n\tisBashRunning(): boolean;\n\t/** Delegates to AgentSession.exportToJsonl(). */\n\texportToJsonl(outputPath?: string): string;\n\n\t// --- Lifecycle ---\n\t/** Delegates to AgentSession.dispose(). */\n\tdispose(): Promise<void>;\n}\n\n/** Creates a facade v1 view over one AgentSession. Pure wrapper: holds no state of its own. */\nexport function createCodingAgentFacade(session: AgentSession): CodingAgentFacadeV1 {\n\treturn {\n\t\tversion: 1,\n\t\tprompt: (text, options) => session.prompt(text, options),\n\t\tsteer: (text, images, options) => session.steer(text, images, options),\n\t\tabort: (options) => session.abort(undefined, options),\n\t\tabortAgentTasks: () => session.abortAgentTasks(),\n\t\tgetActiveAgentTaskCount: () => session.getActiveAgentTaskCount(),\n\t\twaitForIdle: () => session.waitForIdle(),\n\t\tcompact: (customInstructions) => session.compact(customInstructions),\n\t\tnavigateTree: (targetId, options) => session.navigateTree(targetId, options),\n\t\treload: (options) => session.reload(options),\n\t\tsetModel: (model, options) => session.setModel(model, options),\n\t\tsetThinkingLevel: (level, options) => session.setThinkingLevel(level, options),\n\t\tsetActiveToolsByName: (toolNames) => session.setActiveToolsByName(toolNames),\n\t\tgetQueuedMessages: () => ({\n\t\t\tsteering: session.getSteeringMessages(),\n\t\t\tfollowUp: session.getFollowUpMessages(),\n\t\t}),\n\t\tclearQueue: () => session.clearQueue(),\n\t\trecordSuiteMismatch: (originalSuiteId, currentSuiteId) =>\n\t\t\tsession.recordSuiteMismatch(originalSuiteId, currentSuiteId),\n\t\tgetSessionAPI: () => session.getSessionAPI(),\n\t\tisIdle: () => session.isIdle,\n\t\tgetState: () => session.state,\n\t\tgetModel: () => session.model,\n\t\tgetToolNames: () => session.getActiveToolNames(),\n\t\tgetSessionId: () => session.sessionId,\n\t\tgetHeader: () => session.sessionManager.getHeader(),\n\t\tsubscribe: (listener) => session.subscribe(listener),\n\t\tsubscribeRawEventGate: (listener) => session.agent.subscribe(() => listener()),\n\t\tgetSessionName: () => session.sessionName,\n\t\tisCompacting: () => session.isCompacting,\n\t\tisStreaming: () => session.isStreaming,\n\t\tgetContextUsage: () => session.getContextUsage(),\n\t\tgetSystemPrompt: () => session.systemPrompt,\n\t\tgetScopedModels: () => session.scopedModels,\n\t\tgetTree: () => session.sessionManager.getTree(),\n\t\tgetLeafId: () => session.sessionManager.getLeafId(),\n\t\tgetPromptTemplates: () => session.promptTemplates,\n\t\tgetToolDefinition: (name) => session.getToolDefinition(name),\n\t\tgetCwd: () => session.sessionManager.getCwd(),\n\t\tgetEntries: () => session.sessionManager.getEntries(),\n\t\tgetPendingMessageCount: () => session.pendingMessageCount,\n\t\tfollowUp: (text, images, options) => session.followUp(text, images, options),\n\t\tsetScopedModels: (scopedModels) => session.setScopedModels(scopedModels),\n\t\tcycleModel: (direction, options) => session.cycleModel(direction, options),\n\t\tcycleThinkingLevel: (options) => session.cycleThinkingLevel(options),\n\t\tsetSteeringMode: (mode) => session.setSteeringMode(mode),\n\t\tsetFollowUpMode: (mode) => session.setFollowUpMode(mode),\n\t\tsetAutoCompactionEnabled: (enabled) => session.setAutoCompactionEnabled(enabled),\n\t\tsetSessionName: (name) => session.setSessionName(name),\n\t\tabortBash: () => session.abortBash(),\n\t\tabortCompaction: () => session.abortCompaction(),\n\t\tabortRetry: () => session.abortRetry(),\n\t\tabortBranchSummary: () => session.abortBranchSummary(),\n\t\tcaptureBashEpoch: () => session.captureBashEpoch(),\n\t\tisBashEpochCurrent: (epoch) => session.isBashEpochCurrent(epoch),\n\t\temitUserBash: (excludeFromContext) => session.emitUserBash(excludeFromContext),\n\t\texecuteBash: (command, onChunk, options) => session.executeBash(command, onChunk, options),\n\t\trecordBashResult: (command, result, options) => session.recordBashResult(command, result, options),\n\t\tgetThinkingLevel: () => session.thinkingLevel,\n\t\tgetSteeringMode: () => session.steeringMode,\n\t\tgetFollowUpMode: () => session.followUpMode,\n\t\tgetSessionFile: () => session.sessionFile,\n\t\tisAutoCompactionEnabled: () => session.autoCompactionEnabled,\n\t\tgetAvailableThinkingLevels: () => session.getAvailableThinkingLevels(),\n\t\tgetUserMessagesForForking: () => session.getUserMessagesForForking(),\n\t\tgetLastAssistantText: () => session.getLastAssistantText(),\n\t\tgetSessionStats: () => session.getSessionStats(),\n\t\tsetAutoRetryEnabled: (enabled) => session.setAutoRetryEnabled(enabled),\n\t\texportToHtml: (outputPath, options) => session.exportToHtml(outputPath, options),\n\t\tappendLabelChange: (entryId, label) => session.sessionManager.appendLabelChange(entryId, label),\n\t\tgetSkills: () => session.resourceLoader.getSkills(),\n\t\tgetPrompts: () => session.resourceLoader.getPrompts(),\n\t\tgetThemes: () => session.resourceLoader.getThemes(),\n\t\tgetAgentsFiles: () => session.resourceLoader.getAgentsFiles(),\n\t\tgetSystemPromptSource: () => session.resourceLoader.getSystemPromptSource(),\n\t\tgetAppendSystemPromptSources: () => session.resourceLoader.getAppendSystemPromptSources(),\n\t\tgetSuiteId: () => readSessionSuiteBinding(session.getSessionAPI().getBranchEntries())?.suiteId,\n\t\tgetAvailableModels: () => session.modelRuntime.getAvailableSnapshot(),\n\t\tisUsingSubscription: (providerId) => session.modelRuntime.isUsingSubscription(providerId),\n\t\tgetModelsError: () => session.modelRuntime.getError(),\n\t\tgetModelCatalog: () => session.modelRuntime,\n\t\tcheckProviderAuth: (providerId) => session.modelRuntime.checkAuth(providerId),\n\t\tgetProviderAuth: (providerId) => session.modelRuntime.getAuth(providerId),\n\t\tgetModelPriceSource: () => session.modelRuntime,\n\t\tgetModelAuthRuntime: () => session.modelRuntime,\n\t\t// Delegates to the SessionManager method: its incrementally maintained\n\t\t// byId index walks the full entry graph, which rebuild-from-entries\n\t\t// diverges from after a compaction commit (D-047 regression fix).\n\t\tgetContextEntries: () => session.sessionManager.buildContextEntries(),\n\t\tgetSteeringMessages: () => session.getSteeringMessages(),\n\t\tgetFollowUpMessages: () => session.getFollowUpMessages(),\n\t\tgetRetryAttempt: () => session.retryAttempt,\n\t\tisBashRunning: () => session.isBashRunning,\n\t\texportToJsonl: (outputPath) => session.exportToJsonl(outputPath),\n\t\tdispose: () => session.dispose(),\n\t};\n}\n"]}
1
+ {"version":3,"file":"coding-agent-facade.d.ts","sourceRoot":"","sources":["../../../src/core/facade/coding-agent-facade.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kDAAkD,CAAC;AAE5F,OAAO,KAAK,EACX,YAAY,EACZ,yBAAyB,EACzB,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,sBAAsB,EACtB,YAAY,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;A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C,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAG3C,2CAA2C;IAC3C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB;AAED,+FAA+F;AAC/F,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,YAAY,GAAG,mBAAmB,CAqGlF","sourcesContent":["/**\n * Stable facade v1: a read-only mirror plus pass-through run control and\n * session write paths over one AgentSession.\n *\n * Design: docs/design/稳定门面统一入口设计.md (§2.5 阶段 0 实际面, §2.6 slice 1\n * 读面, §2.7 slice 2 读面, §2.8 阶段 2 写面, §2.9 阶段 3 RPC 面, §3 API 面 v1,\n * §4 阶段 0/1/2/3). Every member is a pure delegate onto the wrapped\n * AgentSession or its existing curated surfaces (`getSessionAPI()`, `host`).\n * No new behavior, no policy, no state of its own. Product entry points\n * (TUI/CLI/RPC/Embedded) migrate onto this surface in later phases;\n * AgentSession stays the internal adapter behind it.\n *\n * Scope: in-package stable surface for those product entry points. It is not\n * exported from the package root and is not a cross-package public contract.\n */\n\nimport type { AgentState, ThinkingLevel } from \"@agent-forge/agent-core\";\nimport type { AuthCheck, AuthResult, ImageContent } from \"@agent-forge/ai\";\nimport type { Api, Model } from \"@agent-forge/ai/compat\";\nimport type { ModelCatalogRuntime } from \"../../modes/interactive/model-catalog-refresh.ts\";\nimport { readSessionSuiteBinding } from \"../../profiles/suite-loader.ts\";\nimport type {\n\tAgentSession,\n\tAgentSessionEventListener,\n\tModelCycleResult,\n\tModelMutationOptions,\n\tPromptOptions,\n\tQueuedInputDisposition,\n\tSessionStats,\n} from \"../agent-session.ts\";\nimport type { CompactionCancelledResult } from \"../agent-session-compaction.ts\";\nimport type { ForkableUserMessage } from \"../agent-session-projection.ts\";\nimport type { BashResult } from \"../bash-executor.ts\";\nimport type { ModelPriceSource } from \"../cache-stats.ts\";\nimport type { CompactionResult } from \"../compaction/index.ts\";\nimport type { ResourceDiagnostic } from \"../diagnostics.ts\";\nimport type { ContextUsage, PromptOutcome, SessionAPI } from \"../extensions/public-api.ts\";\nimport type { InputSource } from \"../input-source.ts\";\nimport type { ModelRuntime } from \"../model-runtime.ts\";\nimport type { PromptTemplate } from \"../prompt-templates.ts\";\nimport type { ThemeMetaV1 } from \"../resource-loader.ts\";\nimport type { BranchSummaryEntry, SessionEntry, SessionHeader, SessionTreeNode } from \"../session-manager.ts\";\nimport type { Skill } from \"../skills.ts\";\nimport type { BashOperations } from \"../tools/bash.ts\";\nimport type { ToolDefinition } from \"../tools/tool-definition.ts\";\n\n/** Prompt options for the facade. Identical to AgentSession PromptOptions. */\nexport type CodingAgentFacadePromptOptionsV1 = PromptOptions;\n\n/**\n * Narrow credential/provider auth projection (D-048): the TUI auth surface\n * only. Covers exactly the seven methods the auth host consumes\n * (`getProviders`/`getProvider`/`getProviderAuthStatus`/`isUsingOAuth`/\n * `listCredentials`/`login`/`logout`); the full ModelRuntime never leaks to\n * the host. The credential-management CapabilityAPI semantics question stays\n * open (D-047 裁决 3); this narrows the TUI host path without deciding it.\n */\nexport type ModelAuthRuntime = Pick<\n\tModelRuntime,\n\t\"getProviders\" | \"getProvider\" | \"getProviderAuthStatus\" | \"isUsingOAuth\" | \"listCredentials\" | \"login\" | \"logout\"\n>;\n\n/**\n * Stable facade v1: the consumption surface for product hosts, versioned per\n * repo convention (EmbeddedSdkBindingV1 precedent). Members are pass-throughs\n * onto the wrapped AgentSession; new members must extend the facade design\n * doc first (门面腐化 guard, 设计 §6).\n */\nexport interface CodingAgentFacadeV1 {\n\treadonly version: 1;\n\n\t// --- Run control ---\n\t/**\n\t * Delegates to AgentSession.prompt(). The full PromptOptions pass through,\n\t * including the internal RPC preflight hook (`preflightResult`) that RPC\n\t * mode uses to observe prompt acceptance (阶段 3, 设计 §2.9).\n\t */\n\tprompt(text: string, options?: CodingAgentFacadePromptOptionsV1): Promise<PromptOutcome>;\n\t/** Delegates to AgentSession.steer(). */\n\tsteer(text: string, images?: ImageContent[], options?: { source?: InputSource }): Promise<QueuedInputDisposition>;\n\t/** Delegates to AgentSession.abort(); `cancelAgentTasks: false` stops the\n\t * current turn without cancelling background agent tasks (设计 子代理运行时\n\t * §4.2 中断分级,2026-10-02 — the TUI Esc path always passes false). */\n\tabort(options?: { cancelAgentTasks?: boolean }): Promise<void>;\n\t/** Delegates to AgentSession.abortAgentTasks(): cancel every background agent\n\t * task without aborting the current turn (/stop-agents execution face). */\n\tabortAgentTasks(): void;\n\t/** Delegates to AgentSession.getActiveAgentTaskCount(). */\n\tgetActiveAgentTaskCount(): number;\n\t/** Delegates to AgentSession.waitForIdle(). */\n\twaitForIdle(): Promise<void>;\n\n\t// --- Session write paths ---\n\t/** Delegates to AgentSession.compact(). */\n\tcompact(customInstructions?: string): Promise<CompactionResult | CompactionCancelledResult>;\n\t/** Delegates to AgentSession.navigateTree(). */\n\tnavigateTree(\n\t\ttargetId: string,\n\t\toptions?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string },\n\t): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>;\n\t/** Delegates to AgentSession.reload(). */\n\treload(options?: { beforeSessionStart?: () => void | Promise<void> }): Promise<void>;\n\t/** Delegates to AgentSession.setModel(). */\n\tsetModel(model: Model<Api>, options?: ModelMutationOptions): Promise<void>;\n\t/** Delegates to AgentSession.setThinkingLevel(). */\n\tsetThinkingLevel(level: ThinkingLevel, options?: ModelMutationOptions): void;\n\t/** Delegates to AgentSession.setActiveToolsByName(). */\n\tsetActiveToolsByName(toolNames: string[]): void;\n\t/**\n\t * Queued-message read view, composed from AgentSession.getSteeringMessages()\n\t * and AgentSession.getFollowUpMessages(). AgentSession has no single\n\t * getQueuedMessages(); the shape mirrors clearQueue()'s return value.\n\t */\n\tgetQueuedMessages(): { steering: readonly string[]; followUp: readonly string[] };\n\t/** Delegates to AgentSession.clearQueue(). */\n\tclearQueue(): { steering: string[]; followUp: string[] };\n\t/** Delegates to AgentSession.reorderQueuedMessages(): indices refer to the\n\t * queued display lists; a stale or out-of-bounds move returns false. */\n\treorderQueuedMessages(queue: \"steer\" | \"followUp\", from: number, to: number): boolean;\n\t/** Delegates to AgentSession.removeQueuedMessageAt(): removes by queued\n\t * display list index; a stale index returns null. */\n\tremoveQueuedMessageAt(queue: \"steer\" | \"followUp\", index: number): string | null;\n\t/** Delegates to AgentSession.recordSuiteMismatch(). */\n\trecordSuiteMismatch(originalSuiteId: string, currentSuiteId: string): void;\n\t/** Delegates to AgentSession.getSessionAPI(). */\n\tgetSessionAPI(): SessionAPI;\n\n\t// --- Read-only mirror ---\n\t/** Delegates to AgentSession.isIdle. */\n\tisIdle(): boolean;\n\t/** Mirrors AgentSession.state verbatim (phase 0; a projected state view is a later phase, 设计 §3). */\n\tgetState(): AgentState;\n\t/** Delegates to AgentSession.model. */\n\tgetModel(): Model<Api> | undefined;\n\t/** Delegates to AgentSession.getActiveToolNames(). */\n\tgetToolNames(): string[];\n\t/** Delegates to AgentSession.sessionId (via SessionAPI.getSessionId semantics). */\n\tgetSessionId(): string;\n\t/**\n\t * Suite id from the session-suite binding entry (设计 §10.1), read through\n\t * SessionAPI.getBranchEntries(). Undefined when the session carries no\n\t * suite binding.\n\t */\n\tgetSuiteId(): string | undefined;\n\t/** Delegates to AgentSession.sessionManager.getHeader(). SessionManager itself never leaks. */\n\tgetHeader(): SessionHeader | null;\n\t/** Delegates to AgentSession.subscribe(). Event types pass through verbatim (设计 §3). */\n\tsubscribe(listener: AgentSessionEventListener): () => void;\n\t/**\n\t * Invoked after each raw agent event is delivered to session processing;\n\t * the listener is awaited serially by the agent loop and participates in\n\t * run settlement. Exists for stdout backpressure pacing (D-046); the raw\n\t * event payload and abort signal are deliberately not exposed.\n\t */\n\tsubscribeRawEventGate(listener: () => void | Promise<void>): () => void;\n\n\t// --- Read surface (phase 1 slice 1, TUI display/selector reads, 设计 §2.6) ---\n\t/** Delegates to AgentSession.sessionName (which reads sessionManager.getSessionName()). */\n\tgetSessionName(): string | undefined;\n\t/** Delegates to AgentSession.isCompacting: a compaction or branch summarization is running (session level). */\n\tisCompacting(): boolean;\n\t/**\n\t * Delegates to AgentSession.isStreaming: an agent run is active at the\n\t * session level. Distinct from AgentState.isStreaming (agent-level stream\n\t * flag); do not interchange the two.\n\t */\n\tisStreaming(): boolean;\n\t/** Delegates to AgentSession.getContextUsage(). */\n\tgetContextUsage(): ContextUsage | undefined;\n\t/** Delegates to AgentSession.systemPrompt (effective prompt, including per-turn extension modifications). */\n\tgetSystemPrompt(): string;\n\t/** Delegates to AgentSession.scopedModels. Read view only; setScopedModels stays a phase 2 write path. */\n\tgetScopedModels(): ReadonlyArray<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\t/** Delegates to SessionManager.getTree() on the wrapped session. SessionManager itself never leaks. */\n\tgetTree(): SessionTreeNode[];\n\t/** Delegates to SessionManager.getLeafId() on the wrapped session. SessionManager itself never leaks. */\n\tgetLeafId(): string | null;\n\n\t// --- Read surface (phase 1 slice 2, TUI display/selector cluster convergence, 设计 §2.7) ---\n\t/** Delegates to AgentSession.promptTemplates (file-based prompt templates). */\n\tgetPromptTemplates(): ReadonlyArray<PromptTemplate>;\n\t/** Delegates to AgentSession.getToolDefinition(name): the registered tool definition by name, for diagnostics/rendering. */\n\tgetToolDefinition(name: string): ToolDefinition | undefined;\n\t/** Delegates to SessionManager.getCwd() on the wrapped session; identical to host.cwd. SessionManager itself never leaks. */\n\tgetCwd(): string;\n\t/** Delegates to SessionManager.getEntries() on the wrapped session; identical to host.entries. SessionManager itself never leaks. */\n\tgetEntries(): SessionEntry[];\n\t/** Delegates to AgentSession.pendingMessageCount: queued steering + follow-up message count. */\n\tgetPendingMessageCount(): number;\n\n\t// --- Write surface (phase 2, TUI write path convergence, 设计 §2.8) ---\n\t/** Delegates to AgentSession.followUp(). */\n\tfollowUp(text: string, images?: ImageContent[], options?: { source?: InputSource }): Promise<QueuedInputDisposition>;\n\t/** Delegates to AgentSession.setScopedModels(). */\n\tsetScopedModels(scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>): void;\n\t/** Delegates to AgentSession.cycleModel(). */\n\tcycleModel(\n\t\tdirection?: \"forward\" | \"backward\",\n\t\toptions?: ModelMutationOptions,\n\t): Promise<ModelCycleResult | undefined>;\n\t/** Delegates to AgentSession.cycleThinkingLevel(). */\n\tcycleThinkingLevel(options?: ModelMutationOptions): ThinkingLevel | undefined;\n\t/** Delegates to AgentSession.setSteeringMode(). */\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\"): void;\n\t/** Delegates to AgentSession.setFollowUpMode(). */\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\"): void;\n\t/** Delegates to AgentSession.setAutoCompactionEnabled(). */\n\tsetAutoCompactionEnabled(enabled: boolean): void;\n\t/** Delegates to AgentSession.setSessionName(). */\n\tsetSessionName(name: string): void;\n\t/** Delegates to AgentSession.abortBash(). */\n\tabortBash(): void;\n\t/** Delegates to AgentSession.abortCompaction(). */\n\tabortCompaction(): void;\n\t/** Delegates to AgentSession.abortRetry(). */\n\tabortRetry(): void;\n\t/** Delegates to AgentSession.abortBranchSummary(). */\n\tabortBranchSummary(): void;\n\t/** Delegates to AgentSession.captureBashEpoch(). */\n\tcaptureBashEpoch(): number;\n\t/** Delegates to AgentSession.isBashEpochCurrent(). */\n\tisBashEpochCurrent(epoch: number): boolean;\n\t/** Delegates to AgentSession.emitUserBash(): dispatches the user.bash lifecycle facts. */\n\temitUserBash(excludeFromContext: boolean): void;\n\t/** Delegates to AgentSession.executeBash(). */\n\texecuteBash(\n\t\tcommand: string,\n\t\tonChunk?: (chunk: string) => void,\n\t\toptions?: { excludeFromContext?: boolean; id?: string; operations?: BashOperations },\n\t): Promise<BashResult>;\n\t/** Delegates to AgentSession.recordBashResult(). */\n\trecordBashResult(\n\t\tcommand: string,\n\t\tresult: BashResult,\n\t\toptions?: { excludeFromContext?: boolean; epoch?: number },\n\t): void;\n\n\t// --- Read surface (phase 3, RPC host state reads, 设计 §2.9) ---\n\t/** Delegates to AgentSession.thinkingLevel. */\n\tgetThinkingLevel(): ThinkingLevel;\n\t/** Delegates to AgentSession.steeringMode. */\n\tgetSteeringMode(): \"all\" | \"one-at-a-time\";\n\t/** Delegates to AgentSession.followUpMode. */\n\tgetFollowUpMode(): \"all\" | \"one-at-a-time\";\n\t/** Delegates to AgentSession.sessionFile. */\n\tgetSessionFile(): string | undefined;\n\t/** Delegates to AgentSession.autoCompactionEnabled. */\n\tisAutoCompactionEnabled(): boolean;\n\t/** Delegates to AgentSession.getAvailableThinkingLevels(). */\n\tgetAvailableThinkingLevels(): ThinkingLevel[];\n\t/** Delegates to AgentSession.getUserMessagesForForking(). */\n\tgetUserMessagesForForking(): ForkableUserMessage[];\n\t/** Delegates to AgentSession.getLastAssistantText(). */\n\tgetLastAssistantText(): string | undefined;\n\t/** Delegates to AgentSession.getSessionStats(). */\n\tgetSessionStats(): SessionStats;\n\n\t// --- Write surface (phase 3, RPC host writes, 设计 §2.9) ---\n\t/** Delegates to AgentSession.setAutoRetryEnabled(). */\n\tsetAutoRetryEnabled(enabled: boolean): void;\n\t/** Delegates to AgentSession.exportToHtml(), including the themeName option. */\n\texportToHtml(outputPath?: string, options?: { themeName?: string }): Promise<string>;\n\n\t// --- Session write path (阶段 4 slice 3 v1 修订, D-041) ---\n\t/**\n\t * Delegates to SessionManager.appendLabelChange() on the wrapped session.\n\t * TUI tree selector label rename write point; SessionAPI has no label write.\n\t */\n\tappendLabelChange(entryId: string, label: string | undefined): string;\n\n\t// --- Resource read surface (阶段 4 slice 3 v1 修订, D-041) ---\n\t/**\n\t * Clean read projections over the wrapped session's resource loader. Skills/\n\t * prompts/agents-files results pass through verbatim; themes and extensions\n\t * are the metadata projections (themes as ThemeMetaV1 without the modes\n\t * Theme class; loader registration maps and the shared runtime never\n\t * leak). Guard reason: TUI startup listing/autocomplete/diagnostics\n\t * consume these read points directly; SessionAPI/CapabilityAPI are\n\t * capability-side contracts with no host display projections.\n\t */\n\t/** Delegates to ResourceLoader.getSkills() on the wrapped session. */\n\tgetSkills(): { skills: Skill[]; diagnostics: ResourceDiagnostic[] };\n\t/** Delegates to ResourceLoader.getPrompts() on the wrapped session. */\n\tgetPrompts(): { prompts: PromptTemplate[]; diagnostics: ResourceDiagnostic[] };\n\t/** Delegates to ResourceLoader.getThemes() on the wrapped session. */\n\tgetThemes(): { themes: ThemeMetaV1[]; diagnostics: ResourceDiagnostic[] };\n\t/** Delegates to ResourceLoader.getAgentsFiles() on the wrapped session. */\n\tgetAgentsFiles(): { agentsFiles: Array<{ path: string; content: string }> };\n\t/** Delegates to ResourceLoader.getSystemPromptSource() on the wrapped session. */\n\tgetSystemPromptSource(): { path: string } | undefined;\n\t/** Delegates to ResourceLoader.getAppendSystemPromptSources() on the wrapped session. */\n\tgetAppendSystemPromptSources(): Array<{ path: string }>;\n\n\t// --- Model/catalog/context read surface (v1 修订, D-047: TUI direct session reads zeroed) ---\n\t/** Delegates to ModelRuntime.getAvailableSnapshot() on the wrapped session (D-047); ModelRuntime itself never leaks. */\n\tgetAvailableModels(): readonly Model<Api>[];\n\t/** Delegates to ModelRuntime.isUsingSubscription() on the wrapped session (D-047). */\n\tisUsingSubscription(providerId: string): boolean;\n\t/** Delegates to ModelRuntime.getError() on the wrapped session (D-047). */\n\tgetModelsError(): string | undefined;\n\t/**\n\t * Narrow `ModelCatalogRuntime` projection of the wrapped session's\n\t * ModelRuntime for the shared catalog-refresh coordinator (D-047). A\n\t * projection, not a wrapper: the full runtime never leaks.\n\t */\n\tgetModelCatalog(): ModelCatalogRuntime;\n\t/** Delegates to ModelRuntime.checkAuth() on the wrapped session (D-047). */\n\tcheckProviderAuth(providerId: string): Promise<AuthCheck | undefined>;\n\t/** Delegates to ModelRuntime.getAuth() on the wrapped session (D-047). */\n\tgetProviderAuth(providerId: string): Promise<AuthResult | undefined>;\n\t/**\n\t * Narrow `ModelPriceSource` projection of the wrapped session's\n\t * ModelRuntime for the cache-stats pure functions (D-047). A projection,\n\t * not a wrapper: the full runtime never leaks.\n\t */\n\tgetModelPriceSource(): ModelPriceSource;\n\t/**\n\t * Delegates to SessionManager.buildContextEntries() on the wrapped session\n\t * (D-047; delegation restored by the D-047 regression fix — the\n\t * incrementally maintained byId index is required for correct context\n\t * paths after a compaction commit). SessionManager itself never leaks.\n\t */\n\tgetContextEntries(): SessionEntry[];\n\n\t// --- Credential/provider auth read surface (v1 修订, D-048: TUI auth host path) ---\n\t/**\n\t * Narrow `ModelAuthRuntime` projection of the wrapped session's ModelRuntime\n\t * for the TUI auth surface (D-048). A projection, not a wrapper: the full\n\t * runtime never leaks. The credential-management CapabilityAPI semantics\n\t * question stays open (D-047 裁决 3); this only narrows the TUI host path.\n\t */\n\tgetModelAuthRuntime(): ModelAuthRuntime;\n\n\t// --- Session stats/text read surface (v1 修订, B-S2b③-S3a: TUI direct\n\t// session stats/text read cluster convergence) ---\n\t/** Delegates to AgentSession.getSteeringMessages(). */\n\tgetSteeringMessages(): readonly string[];\n\t/** Delegates to AgentSession.getFollowUpMessages(). */\n\tgetFollowUpMessages(): readonly string[];\n\n\t// --- Status/settings + export read surface (v1 修订, B-S2b③-S3b+c: TUI\n\t// status/settings/export cluster direct session read convergence) ---\n\t/** Delegates to AgentSession.retryAttempt. */\n\tgetRetryAttempt(): number;\n\t/** Delegates to AgentSession.isBashRunning. */\n\tisBashRunning(): boolean;\n\t/** Delegates to AgentSession.exportToJsonl(). */\n\texportToJsonl(outputPath?: string): string;\n\n\t// --- Lifecycle ---\n\t/** Delegates to AgentSession.dispose(). */\n\tdispose(): Promise<void>;\n}\n\n/** Creates a facade v1 view over one AgentSession. Pure wrapper: holds no state of its own. */\nexport function createCodingAgentFacade(session: AgentSession): CodingAgentFacadeV1 {\n\treturn {\n\t\tversion: 1,\n\t\tprompt: (text, options) => session.prompt(text, options),\n\t\tsteer: (text, images, options) => session.steer(text, images, options),\n\t\tabort: (options) => session.abort(undefined, options),\n\t\tabortAgentTasks: () => session.abortAgentTasks(),\n\t\tgetActiveAgentTaskCount: () => session.getActiveAgentTaskCount(),\n\t\twaitForIdle: () => session.waitForIdle(),\n\t\tcompact: (customInstructions) => session.compact(customInstructions),\n\t\tnavigateTree: (targetId, options) => session.navigateTree(targetId, options),\n\t\treload: (options) => session.reload(options),\n\t\tsetModel: (model, options) => session.setModel(model, options),\n\t\tsetThinkingLevel: (level, options) => session.setThinkingLevel(level, options),\n\t\tsetActiveToolsByName: (toolNames) => session.setActiveToolsByName(toolNames),\n\t\tgetQueuedMessages: () => ({\n\t\t\tsteering: session.getSteeringMessages(),\n\t\t\tfollowUp: session.getFollowUpMessages(),\n\t\t}),\n\t\tclearQueue: () => session.clearQueue(),\n\t\treorderQueuedMessages: (queue, from, to) => session.reorderQueuedMessages(queue, from, to),\n\t\tremoveQueuedMessageAt: (queue, index) => session.removeQueuedMessageAt(queue, index),\n\t\trecordSuiteMismatch: (originalSuiteId, currentSuiteId) =>\n\t\t\tsession.recordSuiteMismatch(originalSuiteId, currentSuiteId),\n\t\tgetSessionAPI: () => session.getSessionAPI(),\n\t\tisIdle: () => session.isIdle,\n\t\tgetState: () => session.state,\n\t\tgetModel: () => session.model,\n\t\tgetToolNames: () => session.getActiveToolNames(),\n\t\tgetSessionId: () => session.sessionId,\n\t\tgetHeader: () => session.sessionManager.getHeader(),\n\t\tsubscribe: (listener) => session.subscribe(listener),\n\t\tsubscribeRawEventGate: (listener) => session.agent.subscribe(() => listener()),\n\t\tgetSessionName: () => session.sessionName,\n\t\tisCompacting: () => session.isCompacting,\n\t\tisStreaming: () => session.isStreaming,\n\t\tgetContextUsage: () => session.getContextUsage(),\n\t\tgetSystemPrompt: () => session.systemPrompt,\n\t\tgetScopedModels: () => session.scopedModels,\n\t\tgetTree: () => session.sessionManager.getTree(),\n\t\tgetLeafId: () => session.sessionManager.getLeafId(),\n\t\tgetPromptTemplates: () => session.promptTemplates,\n\t\tgetToolDefinition: (name) => session.getToolDefinition(name),\n\t\tgetCwd: () => session.sessionManager.getCwd(),\n\t\tgetEntries: () => session.sessionManager.getEntries(),\n\t\tgetPendingMessageCount: () => session.pendingMessageCount,\n\t\tfollowUp: (text, images, options) => session.followUp(text, images, options),\n\t\tsetScopedModels: (scopedModels) => session.setScopedModels(scopedModels),\n\t\tcycleModel: (direction, options) => session.cycleModel(direction, options),\n\t\tcycleThinkingLevel: (options) => session.cycleThinkingLevel(options),\n\t\tsetSteeringMode: (mode) => session.setSteeringMode(mode),\n\t\tsetFollowUpMode: (mode) => session.setFollowUpMode(mode),\n\t\tsetAutoCompactionEnabled: (enabled) => session.setAutoCompactionEnabled(enabled),\n\t\tsetSessionName: (name) => session.setSessionName(name),\n\t\tabortBash: () => session.abortBash(),\n\t\tabortCompaction: () => session.abortCompaction(),\n\t\tabortRetry: () => session.abortRetry(),\n\t\tabortBranchSummary: () => session.abortBranchSummary(),\n\t\tcaptureBashEpoch: () => session.captureBashEpoch(),\n\t\tisBashEpochCurrent: (epoch) => session.isBashEpochCurrent(epoch),\n\t\temitUserBash: (excludeFromContext) => session.emitUserBash(excludeFromContext),\n\t\texecuteBash: (command, onChunk, options) => session.executeBash(command, onChunk, options),\n\t\trecordBashResult: (command, result, options) => session.recordBashResult(command, result, options),\n\t\tgetThinkingLevel: () => session.thinkingLevel,\n\t\tgetSteeringMode: () => session.steeringMode,\n\t\tgetFollowUpMode: () => session.followUpMode,\n\t\tgetSessionFile: () => session.sessionFile,\n\t\tisAutoCompactionEnabled: () => session.autoCompactionEnabled,\n\t\tgetAvailableThinkingLevels: () => session.getAvailableThinkingLevels(),\n\t\tgetUserMessagesForForking: () => session.getUserMessagesForForking(),\n\t\tgetLastAssistantText: () => session.getLastAssistantText(),\n\t\tgetSessionStats: () => session.getSessionStats(),\n\t\tsetAutoRetryEnabled: (enabled) => session.setAutoRetryEnabled(enabled),\n\t\texportToHtml: (outputPath, options) => session.exportToHtml(outputPath, options),\n\t\tappendLabelChange: (entryId, label) => session.sessionManager.appendLabelChange(entryId, label),\n\t\tgetSkills: () => session.resourceLoader.getSkills(),\n\t\tgetPrompts: () => session.resourceLoader.getPrompts(),\n\t\tgetThemes: () => session.resourceLoader.getThemes(),\n\t\tgetAgentsFiles: () => session.resourceLoader.getAgentsFiles(),\n\t\tgetSystemPromptSource: () => session.resourceLoader.getSystemPromptSource(),\n\t\tgetAppendSystemPromptSources: () => session.resourceLoader.getAppendSystemPromptSources(),\n\t\tgetSuiteId: () => readSessionSuiteBinding(session.getSessionAPI().getBranchEntries())?.suiteId,\n\t\tgetAvailableModels: () => session.modelRuntime.getAvailableSnapshot(),\n\t\tisUsingSubscription: (providerId) => session.modelRuntime.isUsingSubscription(providerId),\n\t\tgetModelsError: () => session.modelRuntime.getError(),\n\t\tgetModelCatalog: () => session.modelRuntime,\n\t\tcheckProviderAuth: (providerId) => session.modelRuntime.checkAuth(providerId),\n\t\tgetProviderAuth: (providerId) => session.modelRuntime.getAuth(providerId),\n\t\tgetModelPriceSource: () => session.modelRuntime,\n\t\tgetModelAuthRuntime: () => session.modelRuntime,\n\t\t// Delegates to the SessionManager method: its incrementally maintained\n\t\t// byId index walks the full entry graph, which rebuild-from-entries\n\t\t// diverges from after a compaction commit (D-047 regression fix).\n\t\tgetContextEntries: () => session.sessionManager.buildContextEntries(),\n\t\tgetSteeringMessages: () => session.getSteeringMessages(),\n\t\tgetFollowUpMessages: () => session.getFollowUpMessages(),\n\t\tgetRetryAttempt: () => session.retryAttempt,\n\t\tisBashRunning: () => session.isBashRunning,\n\t\texportToJsonl: (outputPath) => session.exportToJsonl(outputPath),\n\t\tdispose: () => session.dispose(),\n\t};\n}\n"]}
@@ -35,6 +35,8 @@ export function createCodingAgentFacade(session) {
35
35
  followUp: session.getFollowUpMessages(),
36
36
  }),
37
37
  clearQueue: () => session.clearQueue(),
38
+ reorderQueuedMessages: (queue, from, to) => session.reorderQueuedMessages(queue, from, to),
39
+ removeQueuedMessageAt: (queue, index) => session.removeQueuedMessageAt(queue, index),
38
40
  recordSuiteMismatch: (originalSuiteId, currentSuiteId) => session.recordSuiteMismatch(originalSuiteId, currentSuiteId),
39
41
  getSessionAPI: () => session.getSessionAPI(),
40
42
  isIdle: () => session.isIdle,
@@ -1 +1 @@
1
- {"version":3,"file":"coding-agent-facade.js","sourceRoot":"","sources":["../../../src/core/facade/coding-agent-facade.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAwUzE,+FAA+F;AAC/F,MAAM,UAAU,uBAAuB,CAAC,OAAqB,EAAuB;IACnF,OAAO;QACN,OAAO,EAAE,CAAC;QACV,MAAM,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC;QACxD,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC;QACtE,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC;QACrD,eAAe,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,eAAe,EAAE;QAChD,uBAAuB,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,uBAAuB,EAAE;QAChE,WAAW,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE;QACxC,OAAO,EAAE,CAAC,kBAAkB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC;QACpE,YAAY,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC;QAC5E,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;QAC5C,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,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-through run control and\n * session write paths over one AgentSession.\n *\n * Design: docs/design/稳定门面统一入口设计.md (§2.5 阶段 0 实际面, §2.6 slice 1\n * 读面, §2.7 slice 2 读面, §2.8 阶段 2 写面, §2.9 阶段 3 RPC 面, §3 API 面 v1,\n * §4 阶段 0/1/2/3). Every member is a pure delegate onto the wrapped\n * AgentSession or its existing curated surfaces (`getSessionAPI()`, `host`).\n * No new behavior, no policy, no state of its own. Product entry points\n * (TUI/CLI/RPC/Embedded) migrate onto this surface in later phases;\n * AgentSession stays the internal adapter behind it.\n *\n * Scope: in-package stable surface for those product entry points. It is not\n * exported from the package root and is not a cross-package public contract.\n */\n\nimport type { AgentState, ThinkingLevel } from \"@agent-forge/agent-core\";\nimport type { AuthCheck, AuthResult, ImageContent } from \"@agent-forge/ai\";\nimport type { Api, Model } from \"@agent-forge/ai/compat\";\nimport type { ModelCatalogRuntime } from \"../../modes/interactive/model-catalog-refresh.ts\";\nimport { readSessionSuiteBinding } from \"../../profiles/suite-loader.ts\";\nimport type {\n\tAgentSession,\n\tAgentSessionEventListener,\n\tModelCycleResult,\n\tModelMutationOptions,\n\tPromptOptions,\n\tQueuedInputDisposition,\n\tSessionStats,\n} from \"../agent-session.ts\";\nimport type { CompactionCancelledResult } from \"../agent-session-compaction.ts\";\nimport type { ForkableUserMessage } from \"../agent-session-projection.ts\";\nimport type { BashResult } from \"../bash-executor.ts\";\nimport type { ModelPriceSource } from \"../cache-stats.ts\";\nimport type { CompactionResult } from \"../compaction/index.ts\";\nimport type { ResourceDiagnostic } from \"../diagnostics.ts\";\nimport type { ContextUsage, PromptOutcome, SessionAPI } from \"../extensions/public-api.ts\";\nimport type { InputSource } from \"../input-source.ts\";\nimport type { ModelRuntime } from \"../model-runtime.ts\";\nimport type { PromptTemplate } from \"../prompt-templates.ts\";\nimport type { ThemeMetaV1 } from \"../resource-loader.ts\";\nimport type { BranchSummaryEntry, SessionEntry, SessionHeader, SessionTreeNode } from \"../session-manager.ts\";\nimport type { Skill } from \"../skills.ts\";\nimport type { BashOperations } from \"../tools/bash.ts\";\nimport type { ToolDefinition } from \"../tools/tool-definition.ts\";\n\n/** Prompt options for the facade. Identical to AgentSession PromptOptions. */\nexport type CodingAgentFacadePromptOptionsV1 = PromptOptions;\n\n/**\n * Narrow credential/provider auth projection (D-048): the TUI auth surface\n * only. Covers exactly the seven methods the auth host consumes\n * (`getProviders`/`getProvider`/`getProviderAuthStatus`/`isUsingOAuth`/\n * `listCredentials`/`login`/`logout`); the full ModelRuntime never leaks to\n * the host. The credential-management CapabilityAPI semantics question stays\n * open (D-047 裁决 3); this narrows the TUI host path without deciding it.\n */\nexport type ModelAuthRuntime = Pick<\n\tModelRuntime,\n\t\"getProviders\" | \"getProvider\" | \"getProviderAuthStatus\" | \"isUsingOAuth\" | \"listCredentials\" | \"login\" | \"logout\"\n>;\n\n/**\n * Stable facade v1: the consumption surface for product hosts, versioned per\n * repo convention (EmbeddedSdkBindingV1 precedent). Members are pass-throughs\n * onto the wrapped AgentSession; new members must extend the facade design\n * doc first (门面腐化 guard, 设计 §6).\n */\nexport interface CodingAgentFacadeV1 {\n\treadonly version: 1;\n\n\t// --- Run control ---\n\t/**\n\t * Delegates to AgentSession.prompt(). The full PromptOptions pass through,\n\t * including the internal RPC preflight hook (`preflightResult`) that RPC\n\t * mode uses to observe prompt acceptance (阶段 3, 设计 §2.9).\n\t */\n\tprompt(text: string, options?: CodingAgentFacadePromptOptionsV1): Promise<PromptOutcome>;\n\t/** Delegates to AgentSession.steer(). */\n\tsteer(text: string, images?: ImageContent[], options?: { source?: InputSource }): Promise<QueuedInputDisposition>;\n\t/** Delegates to AgentSession.abort(); `cancelAgentTasks: false` stops the\n\t * current turn without cancelling background agent tasks (设计 子代理运行时\n\t * §4.2 中断分级,2026-10-02 — the TUI Esc path always passes false). */\n\tabort(options?: { cancelAgentTasks?: boolean }): Promise<void>;\n\t/** Delegates to AgentSession.abortAgentTasks(): cancel every background agent\n\t * task without aborting the current turn (/stop-agents execution face). */\n\tabortAgentTasks(): void;\n\t/** Delegates to AgentSession.getActiveAgentTaskCount(). */\n\tgetActiveAgentTaskCount(): number;\n\t/** Delegates to AgentSession.waitForIdle(). */\n\twaitForIdle(): Promise<void>;\n\n\t// --- Session write paths ---\n\t/** Delegates to AgentSession.compact(). */\n\tcompact(customInstructions?: string): Promise<CompactionResult | CompactionCancelledResult>;\n\t/** Delegates to AgentSession.navigateTree(). */\n\tnavigateTree(\n\t\ttargetId: string,\n\t\toptions?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string },\n\t): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>;\n\t/** Delegates to AgentSession.reload(). */\n\treload(options?: { beforeSessionStart?: () => void | Promise<void> }): Promise<void>;\n\t/** Delegates to AgentSession.setModel(). */\n\tsetModel(model: Model<Api>, options?: ModelMutationOptions): Promise<void>;\n\t/** Delegates to AgentSession.setThinkingLevel(). */\n\tsetThinkingLevel(level: ThinkingLevel, options?: ModelMutationOptions): void;\n\t/** Delegates to AgentSession.setActiveToolsByName(). */\n\tsetActiveToolsByName(toolNames: string[]): void;\n\t/**\n\t * Queued-message read view, composed from AgentSession.getSteeringMessages()\n\t * and AgentSession.getFollowUpMessages(). AgentSession has no single\n\t * getQueuedMessages(); the shape mirrors clearQueue()'s return value.\n\t */\n\tgetQueuedMessages(): { steering: readonly string[]; followUp: readonly string[] };\n\t/** Delegates to AgentSession.clearQueue(). */\n\tclearQueue(): { steering: string[]; followUp: string[] };\n\t/** Delegates to AgentSession.recordSuiteMismatch(). */\n\trecordSuiteMismatch(originalSuiteId: string, currentSuiteId: string): void;\n\t/** Delegates to AgentSession.getSessionAPI(). */\n\tgetSessionAPI(): SessionAPI;\n\n\t// --- Read-only mirror ---\n\t/** Delegates to AgentSession.isIdle. */\n\tisIdle(): boolean;\n\t/** Mirrors AgentSession.state verbatim (phase 0; a projected state view is a later phase, 设计 §3). */\n\tgetState(): AgentState;\n\t/** Delegates to AgentSession.model. */\n\tgetModel(): Model<Api> | undefined;\n\t/** Delegates to AgentSession.getActiveToolNames(). */\n\tgetToolNames(): string[];\n\t/** Delegates to AgentSession.sessionId (via SessionAPI.getSessionId semantics). */\n\tgetSessionId(): string;\n\t/**\n\t * Suite id from the session-suite binding entry (设计 §10.1), read through\n\t * SessionAPI.getBranchEntries(). Undefined when the session carries no\n\t * suite binding.\n\t */\n\tgetSuiteId(): string | undefined;\n\t/** Delegates to AgentSession.sessionManager.getHeader(). SessionManager itself never leaks. */\n\tgetHeader(): SessionHeader | null;\n\t/** Delegates to AgentSession.subscribe(). Event types pass through verbatim (设计 §3). */\n\tsubscribe(listener: AgentSessionEventListener): () => void;\n\t/**\n\t * Invoked after each raw agent event is delivered to session processing;\n\t * the listener is awaited serially by the agent loop and participates in\n\t * run settlement. Exists for stdout backpressure pacing (D-046); the raw\n\t * event payload and abort signal are deliberately not exposed.\n\t */\n\tsubscribeRawEventGate(listener: () => void | Promise<void>): () => void;\n\n\t// --- Read surface (phase 1 slice 1, TUI display/selector reads, 设计 §2.6) ---\n\t/** Delegates to AgentSession.sessionName (which reads sessionManager.getSessionName()). */\n\tgetSessionName(): string | undefined;\n\t/** Delegates to AgentSession.isCompacting: a compaction or branch summarization is running (session level). */\n\tisCompacting(): boolean;\n\t/**\n\t * Delegates to AgentSession.isStreaming: an agent run is active at the\n\t * session level. Distinct from AgentState.isStreaming (agent-level stream\n\t * flag); do not interchange the two.\n\t */\n\tisStreaming(): boolean;\n\t/** Delegates to AgentSession.getContextUsage(). */\n\tgetContextUsage(): ContextUsage | undefined;\n\t/** Delegates to AgentSession.systemPrompt (effective prompt, including per-turn extension modifications). */\n\tgetSystemPrompt(): string;\n\t/** Delegates to AgentSession.scopedModels. Read view only; setScopedModels stays a phase 2 write path. */\n\tgetScopedModels(): ReadonlyArray<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\t/** Delegates to SessionManager.getTree() on the wrapped session. SessionManager itself never leaks. */\n\tgetTree(): SessionTreeNode[];\n\t/** Delegates to SessionManager.getLeafId() on the wrapped session. SessionManager itself never leaks. */\n\tgetLeafId(): string | null;\n\n\t// --- Read surface (phase 1 slice 2, TUI display/selector cluster convergence, 设计 §2.7) ---\n\t/** Delegates to AgentSession.promptTemplates (file-based prompt templates). */\n\tgetPromptTemplates(): ReadonlyArray<PromptTemplate>;\n\t/** Delegates to AgentSession.getToolDefinition(name): the registered tool definition by name, for diagnostics/rendering. */\n\tgetToolDefinition(name: string): ToolDefinition | undefined;\n\t/** Delegates to SessionManager.getCwd() on the wrapped session; identical to host.cwd. SessionManager itself never leaks. */\n\tgetCwd(): string;\n\t/** Delegates to SessionManager.getEntries() on the wrapped session; identical to host.entries. SessionManager itself never leaks. */\n\tgetEntries(): SessionEntry[];\n\t/** Delegates to AgentSession.pendingMessageCount: queued steering + follow-up message count. */\n\tgetPendingMessageCount(): number;\n\n\t// --- Write surface (phase 2, TUI write path convergence, 设计 §2.8) ---\n\t/** Delegates to AgentSession.followUp(). */\n\tfollowUp(text: string, images?: ImageContent[], options?: { source?: InputSource }): Promise<QueuedInputDisposition>;\n\t/** Delegates to AgentSession.setScopedModels(). */\n\tsetScopedModels(scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>): void;\n\t/** Delegates to AgentSession.cycleModel(). */\n\tcycleModel(\n\t\tdirection?: \"forward\" | \"backward\",\n\t\toptions?: ModelMutationOptions,\n\t): Promise<ModelCycleResult | undefined>;\n\t/** Delegates to AgentSession.cycleThinkingLevel(). */\n\tcycleThinkingLevel(options?: ModelMutationOptions): ThinkingLevel | undefined;\n\t/** Delegates to AgentSession.setSteeringMode(). */\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\"): void;\n\t/** Delegates to AgentSession.setFollowUpMode(). */\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\"): void;\n\t/** Delegates to AgentSession.setAutoCompactionEnabled(). */\n\tsetAutoCompactionEnabled(enabled: boolean): void;\n\t/** Delegates to AgentSession.setSessionName(). */\n\tsetSessionName(name: string): void;\n\t/** Delegates to AgentSession.abortBash(). */\n\tabortBash(): void;\n\t/** Delegates to AgentSession.abortCompaction(). */\n\tabortCompaction(): void;\n\t/** Delegates to AgentSession.abortRetry(). */\n\tabortRetry(): void;\n\t/** Delegates to AgentSession.abortBranchSummary(). */\n\tabortBranchSummary(): void;\n\t/** Delegates to AgentSession.captureBashEpoch(). */\n\tcaptureBashEpoch(): number;\n\t/** Delegates to AgentSession.isBashEpochCurrent(). */\n\tisBashEpochCurrent(epoch: number): boolean;\n\t/** Delegates to AgentSession.emitUserBash(): dispatches the user.bash lifecycle facts. */\n\temitUserBash(excludeFromContext: boolean): void;\n\t/** Delegates to AgentSession.executeBash(). */\n\texecuteBash(\n\t\tcommand: string,\n\t\tonChunk?: (chunk: string) => void,\n\t\toptions?: { excludeFromContext?: boolean; id?: string; operations?: BashOperations },\n\t): Promise<BashResult>;\n\t/** Delegates to AgentSession.recordBashResult(). */\n\trecordBashResult(\n\t\tcommand: string,\n\t\tresult: BashResult,\n\t\toptions?: { excludeFromContext?: boolean; epoch?: number },\n\t): void;\n\n\t// --- Read surface (phase 3, RPC host state reads, 设计 §2.9) ---\n\t/** Delegates to AgentSession.thinkingLevel. */\n\tgetThinkingLevel(): ThinkingLevel;\n\t/** Delegates to AgentSession.steeringMode. */\n\tgetSteeringMode(): \"all\" | \"one-at-a-time\";\n\t/** Delegates to AgentSession.followUpMode. */\n\tgetFollowUpMode(): \"all\" | \"one-at-a-time\";\n\t/** Delegates to AgentSession.sessionFile. */\n\tgetSessionFile(): string | undefined;\n\t/** Delegates to AgentSession.autoCompactionEnabled. */\n\tisAutoCompactionEnabled(): boolean;\n\t/** Delegates to AgentSession.getAvailableThinkingLevels(). */\n\tgetAvailableThinkingLevels(): ThinkingLevel[];\n\t/** Delegates to AgentSession.getUserMessagesForForking(). */\n\tgetUserMessagesForForking(): ForkableUserMessage[];\n\t/** Delegates to AgentSession.getLastAssistantText(). */\n\tgetLastAssistantText(): string | undefined;\n\t/** Delegates to AgentSession.getSessionStats(). */\n\tgetSessionStats(): SessionStats;\n\n\t// --- Write surface (phase 3, RPC host writes, 设计 §2.9) ---\n\t/** Delegates to AgentSession.setAutoRetryEnabled(). */\n\tsetAutoRetryEnabled(enabled: boolean): void;\n\t/** Delegates to AgentSession.exportToHtml(), including the themeName option. */\n\texportToHtml(outputPath?: string, options?: { themeName?: string }): Promise<string>;\n\n\t// --- Session write path (阶段 4 slice 3 v1 修订, D-041) ---\n\t/**\n\t * Delegates to SessionManager.appendLabelChange() on the wrapped session.\n\t * TUI tree selector label rename write point; SessionAPI has no label write.\n\t */\n\tappendLabelChange(entryId: string, label: string | undefined): string;\n\n\t// --- Resource read surface (阶段 4 slice 3 v1 修订, D-041) ---\n\t/**\n\t * Clean read projections over the wrapped session's resource loader. Skills/\n\t * prompts/agents-files results pass through verbatim; themes and extensions\n\t * are the metadata projections (themes as ThemeMetaV1 without the modes\n\t * Theme class; loader registration maps and the shared runtime never\n\t * leak). Guard reason: TUI startup listing/autocomplete/diagnostics\n\t * consume these read points directly; SessionAPI/CapabilityAPI are\n\t * capability-side contracts with no host display projections.\n\t */\n\t/** Delegates to ResourceLoader.getSkills() on the wrapped session. */\n\tgetSkills(): { skills: Skill[]; diagnostics: ResourceDiagnostic[] };\n\t/** Delegates to ResourceLoader.getPrompts() on the wrapped session. */\n\tgetPrompts(): { prompts: PromptTemplate[]; diagnostics: ResourceDiagnostic[] };\n\t/** Delegates to ResourceLoader.getThemes() on the wrapped session. */\n\tgetThemes(): { themes: ThemeMetaV1[]; diagnostics: ResourceDiagnostic[] };\n\t/** Delegates to ResourceLoader.getAgentsFiles() on the wrapped session. */\n\tgetAgentsFiles(): { agentsFiles: Array<{ path: string; content: string }> };\n\t/** Delegates to ResourceLoader.getSystemPromptSource() on the wrapped session. */\n\tgetSystemPromptSource(): { path: string } | undefined;\n\t/** Delegates to ResourceLoader.getAppendSystemPromptSources() on the wrapped session. */\n\tgetAppendSystemPromptSources(): Array<{ path: string }>;\n\n\t// --- Model/catalog/context read surface (v1 修订, D-047: TUI direct session reads zeroed) ---\n\t/** Delegates to ModelRuntime.getAvailableSnapshot() on the wrapped session (D-047); ModelRuntime itself never leaks. */\n\tgetAvailableModels(): readonly Model<Api>[];\n\t/** Delegates to ModelRuntime.isUsingSubscription() on the wrapped session (D-047). */\n\tisUsingSubscription(providerId: string): boolean;\n\t/** Delegates to ModelRuntime.getError() on the wrapped session (D-047). */\n\tgetModelsError(): string | undefined;\n\t/**\n\t * Narrow `ModelCatalogRuntime` projection of the wrapped session's\n\t * ModelRuntime for the shared catalog-refresh coordinator (D-047). A\n\t * projection, not a wrapper: the full runtime never leaks.\n\t */\n\tgetModelCatalog(): ModelCatalogRuntime;\n\t/** Delegates to ModelRuntime.checkAuth() on the wrapped session (D-047). */\n\tcheckProviderAuth(providerId: string): Promise<AuthCheck | undefined>;\n\t/** Delegates to ModelRuntime.getAuth() on the wrapped session (D-047). */\n\tgetProviderAuth(providerId: string): Promise<AuthResult | undefined>;\n\t/**\n\t * Narrow `ModelPriceSource` projection of the wrapped session's\n\t * ModelRuntime for the cache-stats pure functions (D-047). A projection,\n\t * not a wrapper: the full runtime never leaks.\n\t */\n\tgetModelPriceSource(): ModelPriceSource;\n\t/**\n\t * Delegates to SessionManager.buildContextEntries() on the wrapped session\n\t * (D-047; delegation restored by the D-047 regression fix — the\n\t * incrementally maintained byId index is required for correct context\n\t * paths after a compaction commit). SessionManager itself never leaks.\n\t */\n\tgetContextEntries(): SessionEntry[];\n\n\t// --- Credential/provider auth read surface (v1 修订, D-048: TUI auth host path) ---\n\t/**\n\t * Narrow `ModelAuthRuntime` projection of the wrapped session's ModelRuntime\n\t * for the TUI auth surface (D-048). A projection, not a wrapper: the full\n\t * runtime never leaks. The credential-management CapabilityAPI semantics\n\t * question stays open (D-047 裁决 3); this only narrows the TUI host path.\n\t */\n\tgetModelAuthRuntime(): ModelAuthRuntime;\n\n\t// --- Session stats/text read surface (v1 修订, B-S2b③-S3a: TUI direct\n\t// session stats/text read cluster convergence) ---\n\t/** Delegates to AgentSession.getSteeringMessages(). */\n\tgetSteeringMessages(): readonly string[];\n\t/** Delegates to AgentSession.getFollowUpMessages(). */\n\tgetFollowUpMessages(): readonly string[];\n\n\t// --- Status/settings + export read surface (v1 修订, B-S2b③-S3b+c: TUI\n\t// status/settings/export cluster direct session read convergence) ---\n\t/** Delegates to AgentSession.retryAttempt. */\n\tgetRetryAttempt(): number;\n\t/** Delegates to AgentSession.isBashRunning. */\n\tisBashRunning(): boolean;\n\t/** Delegates to AgentSession.exportToJsonl(). */\n\texportToJsonl(outputPath?: string): string;\n\n\t// --- Lifecycle ---\n\t/** Delegates to AgentSession.dispose(). */\n\tdispose(): Promise<void>;\n}\n\n/** Creates a facade v1 view over one AgentSession. Pure wrapper: holds no state of its own. */\nexport function createCodingAgentFacade(session: AgentSession): CodingAgentFacadeV1 {\n\treturn {\n\t\tversion: 1,\n\t\tprompt: (text, options) => session.prompt(text, options),\n\t\tsteer: (text, images, options) => session.steer(text, images, options),\n\t\tabort: (options) => session.abort(undefined, options),\n\t\tabortAgentTasks: () => session.abortAgentTasks(),\n\t\tgetActiveAgentTaskCount: () => session.getActiveAgentTaskCount(),\n\t\twaitForIdle: () => session.waitForIdle(),\n\t\tcompact: (customInstructions) => session.compact(customInstructions),\n\t\tnavigateTree: (targetId, options) => session.navigateTree(targetId, options),\n\t\treload: (options) => session.reload(options),\n\t\tsetModel: (model, options) => session.setModel(model, options),\n\t\tsetThinkingLevel: (level, options) => session.setThinkingLevel(level, options),\n\t\tsetActiveToolsByName: (toolNames) => session.setActiveToolsByName(toolNames),\n\t\tgetQueuedMessages: () => ({\n\t\t\tsteering: session.getSteeringMessages(),\n\t\t\tfollowUp: session.getFollowUpMessages(),\n\t\t}),\n\t\tclearQueue: () => session.clearQueue(),\n\t\trecordSuiteMismatch: (originalSuiteId, currentSuiteId) =>\n\t\t\tsession.recordSuiteMismatch(originalSuiteId, currentSuiteId),\n\t\tgetSessionAPI: () => session.getSessionAPI(),\n\t\tisIdle: () => session.isIdle,\n\t\tgetState: () => session.state,\n\t\tgetModel: () => session.model,\n\t\tgetToolNames: () => session.getActiveToolNames(),\n\t\tgetSessionId: () => session.sessionId,\n\t\tgetHeader: () => session.sessionManager.getHeader(),\n\t\tsubscribe: (listener) => session.subscribe(listener),\n\t\tsubscribeRawEventGate: (listener) => session.agent.subscribe(() => listener()),\n\t\tgetSessionName: () => session.sessionName,\n\t\tisCompacting: () => session.isCompacting,\n\t\tisStreaming: () => session.isStreaming,\n\t\tgetContextUsage: () => session.getContextUsage(),\n\t\tgetSystemPrompt: () => session.systemPrompt,\n\t\tgetScopedModels: () => session.scopedModels,\n\t\tgetTree: () => session.sessionManager.getTree(),\n\t\tgetLeafId: () => session.sessionManager.getLeafId(),\n\t\tgetPromptTemplates: () => session.promptTemplates,\n\t\tgetToolDefinition: (name) => session.getToolDefinition(name),\n\t\tgetCwd: () => session.sessionManager.getCwd(),\n\t\tgetEntries: () => session.sessionManager.getEntries(),\n\t\tgetPendingMessageCount: () => session.pendingMessageCount,\n\t\tfollowUp: (text, images, options) => session.followUp(text, images, options),\n\t\tsetScopedModels: (scopedModels) => session.setScopedModels(scopedModels),\n\t\tcycleModel: (direction, options) => session.cycleModel(direction, options),\n\t\tcycleThinkingLevel: (options) => session.cycleThinkingLevel(options),\n\t\tsetSteeringMode: (mode) => session.setSteeringMode(mode),\n\t\tsetFollowUpMode: (mode) => session.setFollowUpMode(mode),\n\t\tsetAutoCompactionEnabled: (enabled) => session.setAutoCompactionEnabled(enabled),\n\t\tsetSessionName: (name) => session.setSessionName(name),\n\t\tabortBash: () => session.abortBash(),\n\t\tabortCompaction: () => session.abortCompaction(),\n\t\tabortRetry: () => session.abortRetry(),\n\t\tabortBranchSummary: () => session.abortBranchSummary(),\n\t\tcaptureBashEpoch: () => session.captureBashEpoch(),\n\t\tisBashEpochCurrent: (epoch) => session.isBashEpochCurrent(epoch),\n\t\temitUserBash: (excludeFromContext) => session.emitUserBash(excludeFromContext),\n\t\texecuteBash: (command, onChunk, options) => session.executeBash(command, onChunk, options),\n\t\trecordBashResult: (command, result, options) => session.recordBashResult(command, result, options),\n\t\tgetThinkingLevel: () => session.thinkingLevel,\n\t\tgetSteeringMode: () => session.steeringMode,\n\t\tgetFollowUpMode: () => session.followUpMode,\n\t\tgetSessionFile: () => session.sessionFile,\n\t\tisAutoCompactionEnabled: () => session.autoCompactionEnabled,\n\t\tgetAvailableThinkingLevels: () => session.getAvailableThinkingLevels(),\n\t\tgetUserMessagesForForking: () => session.getUserMessagesForForking(),\n\t\tgetLastAssistantText: () => session.getLastAssistantText(),\n\t\tgetSessionStats: () => session.getSessionStats(),\n\t\tsetAutoRetryEnabled: (enabled) => session.setAutoRetryEnabled(enabled),\n\t\texportToHtml: (outputPath, options) => session.exportToHtml(outputPath, options),\n\t\tappendLabelChange: (entryId, label) => session.sessionManager.appendLabelChange(entryId, label),\n\t\tgetSkills: () => session.resourceLoader.getSkills(),\n\t\tgetPrompts: () => session.resourceLoader.getPrompts(),\n\t\tgetThemes: () => session.resourceLoader.getThemes(),\n\t\tgetAgentsFiles: () => session.resourceLoader.getAgentsFiles(),\n\t\tgetSystemPromptSource: () => session.resourceLoader.getSystemPromptSource(),\n\t\tgetAppendSystemPromptSources: () => session.resourceLoader.getAppendSystemPromptSources(),\n\t\tgetSuiteId: () => readSessionSuiteBinding(session.getSessionAPI().getBranchEntries())?.suiteId,\n\t\tgetAvailableModels: () => session.modelRuntime.getAvailableSnapshot(),\n\t\tisUsingSubscription: (providerId) => session.modelRuntime.isUsingSubscription(providerId),\n\t\tgetModelsError: () => session.modelRuntime.getError(),\n\t\tgetModelCatalog: () => session.modelRuntime,\n\t\tcheckProviderAuth: (providerId) => session.modelRuntime.checkAuth(providerId),\n\t\tgetProviderAuth: (providerId) => session.modelRuntime.getAuth(providerId),\n\t\tgetModelPriceSource: () => session.modelRuntime,\n\t\tgetModelAuthRuntime: () => session.modelRuntime,\n\t\t// Delegates to the SessionManager method: its incrementally maintained\n\t\t// byId index walks the full entry graph, which rebuild-from-entries\n\t\t// diverges from after a compaction commit (D-047 regression fix).\n\t\tgetContextEntries: () => session.sessionManager.buildContextEntries(),\n\t\tgetSteeringMessages: () => session.getSteeringMessages(),\n\t\tgetFollowUpMessages: () => session.getFollowUpMessages(),\n\t\tgetRetryAttempt: () => session.retryAttempt,\n\t\tisBashRunning: () => session.isBashRunning,\n\t\texportToJsonl: (outputPath) => session.exportToJsonl(outputPath),\n\t\tdispose: () => session.dispose(),\n\t};\n}\n"]}
1
+ {"version":3,"file":"coding-agent-facade.js","sourceRoot":"","sources":["../../../src/core/facade/coding-agent-facade.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AA8UzE,+FAA+F;AAC/F,MAAM,UAAU,uBAAuB,CAAC,OAAqB,EAAuB;IACnF,OAAO;QACN,OAAO,EAAE,CAAC;QACV,MAAM,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC;QACxD,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC;QACtE,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC;QACrD,eAAe,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,eAAe,EAAE;QAChD,uBAAuB,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,uBAAuB,EAAE;QAChE,WAAW,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE;QACxC,OAAO,EAAE,CAAC,kBAAkB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO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QACpE,kEAAkE;QAClE,iBAAiB,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,mBAAmB,EAAE;QACrE,mBAAmB,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,mBAAmB,EAAE;QACxD,mBAAmB,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,mBAAmB,EAAE;QACxD,eAAe,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,YAAY;QAC3C,aAAa,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,aAAa;QAC1C,aAAa,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC;QAChE,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE;KAChC,CAAC;AAAA,CACF","sourcesContent":["/**\n * Stable facade v1: a read-only mirror plus pass-through run control and\n * session write paths over one AgentSession.\n *\n * Design: docs/design/稳定门面统一入口设计.md (§2.5 阶段 0 实际面, §2.6 slice 1\n * 读面, §2.7 slice 2 读面, §2.8 阶段 2 写面, §2.9 阶段 3 RPC 面, §3 API 面 v1,\n * §4 阶段 0/1/2/3). Every member is a pure delegate onto the wrapped\n * AgentSession or its existing curated surfaces (`getSessionAPI()`, `host`).\n * No new behavior, no policy, no state of its own. Product entry points\n * (TUI/CLI/RPC/Embedded) migrate onto this surface in later phases;\n * AgentSession stays the internal adapter behind it.\n *\n * Scope: in-package stable surface for those product entry points. It is not\n * exported from the package root and is not a cross-package public contract.\n */\n\nimport type { AgentState, ThinkingLevel } from \"@agent-forge/agent-core\";\nimport type { AuthCheck, AuthResult, ImageContent } from \"@agent-forge/ai\";\nimport type { Api, Model } from \"@agent-forge/ai/compat\";\nimport type { ModelCatalogRuntime } from \"../../modes/interactive/model-catalog-refresh.ts\";\nimport { readSessionSuiteBinding } from \"../../profiles/suite-loader.ts\";\nimport type {\n\tAgentSession,\n\tAgentSessionEventListener,\n\tModelCycleResult,\n\tModelMutationOptions,\n\tPromptOptions,\n\tQueuedInputDisposition,\n\tSessionStats,\n} from \"../agent-session.ts\";\nimport type { CompactionCancelledResult } from \"../agent-session-compaction.ts\";\nimport type { ForkableUserMessage } from \"../agent-session-projection.ts\";\nimport type { BashResult } from \"../bash-executor.ts\";\nimport type { ModelPriceSource } from \"../cache-stats.ts\";\nimport type { CompactionResult } from \"../compaction/index.ts\";\nimport type { ResourceDiagnostic } from \"../diagnostics.ts\";\nimport type { ContextUsage, PromptOutcome, SessionAPI } from \"../extensions/public-api.ts\";\nimport type { InputSource } from \"../input-source.ts\";\nimport type { ModelRuntime } from \"../model-runtime.ts\";\nimport type { PromptTemplate } from \"../prompt-templates.ts\";\nimport type { ThemeMetaV1 } from \"../resource-loader.ts\";\nimport type { BranchSummaryEntry, SessionEntry, SessionHeader, SessionTreeNode } from \"../session-manager.ts\";\nimport type { Skill } from \"../skills.ts\";\nimport type { BashOperations } from \"../tools/bash.ts\";\nimport type { ToolDefinition } from \"../tools/tool-definition.ts\";\n\n/** Prompt options for the facade. Identical to AgentSession PromptOptions. */\nexport type CodingAgentFacadePromptOptionsV1 = PromptOptions;\n\n/**\n * Narrow credential/provider auth projection (D-048): the TUI auth surface\n * only. Covers exactly the seven methods the auth host consumes\n * (`getProviders`/`getProvider`/`getProviderAuthStatus`/`isUsingOAuth`/\n * `listCredentials`/`login`/`logout`); the full ModelRuntime never leaks to\n * the host. The credential-management CapabilityAPI semantics question stays\n * open (D-047 裁决 3); this narrows the TUI host path without deciding it.\n */\nexport type ModelAuthRuntime = Pick<\n\tModelRuntime,\n\t\"getProviders\" | \"getProvider\" | \"getProviderAuthStatus\" | \"isUsingOAuth\" | \"listCredentials\" | \"login\" | \"logout\"\n>;\n\n/**\n * Stable facade v1: the consumption surface for product hosts, versioned per\n * repo convention (EmbeddedSdkBindingV1 precedent). Members are pass-throughs\n * onto the wrapped AgentSession; new members must extend the facade design\n * doc first (门面腐化 guard, 设计 §6).\n */\nexport interface CodingAgentFacadeV1 {\n\treadonly version: 1;\n\n\t// --- Run control ---\n\t/**\n\t * Delegates to AgentSession.prompt(). The full PromptOptions pass through,\n\t * including the internal RPC preflight hook (`preflightResult`) that RPC\n\t * mode uses to observe prompt acceptance (阶段 3, 设计 §2.9).\n\t */\n\tprompt(text: string, options?: CodingAgentFacadePromptOptionsV1): Promise<PromptOutcome>;\n\t/** Delegates to AgentSession.steer(). */\n\tsteer(text: string, images?: ImageContent[], options?: { source?: InputSource }): Promise<QueuedInputDisposition>;\n\t/** Delegates to AgentSession.abort(); `cancelAgentTasks: false` stops the\n\t * current turn without cancelling background agent tasks (设计 子代理运行时\n\t * §4.2 中断分级,2026-10-02 — the TUI Esc path always passes false). */\n\tabort(options?: { cancelAgentTasks?: boolean }): Promise<void>;\n\t/** Delegates to AgentSession.abortAgentTasks(): cancel every background agent\n\t * task without aborting the current turn (/stop-agents execution face). */\n\tabortAgentTasks(): void;\n\t/** Delegates to AgentSession.getActiveAgentTaskCount(). */\n\tgetActiveAgentTaskCount(): number;\n\t/** Delegates to AgentSession.waitForIdle(). */\n\twaitForIdle(): Promise<void>;\n\n\t// --- Session write paths ---\n\t/** Delegates to AgentSession.compact(). */\n\tcompact(customInstructions?: string): Promise<CompactionResult | CompactionCancelledResult>;\n\t/** Delegates to AgentSession.navigateTree(). */\n\tnavigateTree(\n\t\ttargetId: string,\n\t\toptions?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string },\n\t): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>;\n\t/** Delegates to AgentSession.reload(). */\n\treload(options?: { beforeSessionStart?: () => void | Promise<void> }): Promise<void>;\n\t/** Delegates to AgentSession.setModel(). */\n\tsetModel(model: Model<Api>, options?: ModelMutationOptions): Promise<void>;\n\t/** Delegates to AgentSession.setThinkingLevel(). */\n\tsetThinkingLevel(level: ThinkingLevel, options?: ModelMutationOptions): void;\n\t/** Delegates to AgentSession.setActiveToolsByName(). */\n\tsetActiveToolsByName(toolNames: string[]): void;\n\t/**\n\t * Queued-message read view, composed from AgentSession.getSteeringMessages()\n\t * and AgentSession.getFollowUpMessages(). AgentSession has no single\n\t * getQueuedMessages(); the shape mirrors clearQueue()'s return value.\n\t */\n\tgetQueuedMessages(): { steering: readonly string[]; followUp: readonly string[] };\n\t/** Delegates to AgentSession.clearQueue(). */\n\tclearQueue(): { steering: string[]; followUp: string[] };\n\t/** Delegates to AgentSession.reorderQueuedMessages(): indices refer to the\n\t * queued display lists; a stale or out-of-bounds move returns false. */\n\treorderQueuedMessages(queue: \"steer\" | \"followUp\", from: number, to: number): boolean;\n\t/** Delegates to AgentSession.removeQueuedMessageAt(): removes by queued\n\t * display list index; a stale index returns null. */\n\tremoveQueuedMessageAt(queue: \"steer\" | \"followUp\", index: number): string | null;\n\t/** Delegates to AgentSession.recordSuiteMismatch(). */\n\trecordSuiteMismatch(originalSuiteId: string, currentSuiteId: string): void;\n\t/** Delegates to AgentSession.getSessionAPI(). */\n\tgetSessionAPI(): SessionAPI;\n\n\t// --- Read-only mirror ---\n\t/** Delegates to AgentSession.isIdle. */\n\tisIdle(): boolean;\n\t/** Mirrors AgentSession.state verbatim (phase 0; a projected state view is a later phase, 设计 §3). */\n\tgetState(): AgentState;\n\t/** Delegates to AgentSession.model. */\n\tgetModel(): Model<Api> | undefined;\n\t/** Delegates to AgentSession.getActiveToolNames(). */\n\tgetToolNames(): string[];\n\t/** Delegates to AgentSession.sessionId (via SessionAPI.getSessionId semantics). */\n\tgetSessionId(): string;\n\t/**\n\t * Suite id from the session-suite binding entry (设计 §10.1), read through\n\t * SessionAPI.getBranchEntries(). Undefined when the session carries no\n\t * suite binding.\n\t */\n\tgetSuiteId(): string | undefined;\n\t/** Delegates to AgentSession.sessionManager.getHeader(). SessionManager itself never leaks. */\n\tgetHeader(): SessionHeader | null;\n\t/** Delegates to AgentSession.subscribe(). Event types pass through verbatim (设计 §3). */\n\tsubscribe(listener: AgentSessionEventListener): () => void;\n\t/**\n\t * Invoked after each raw agent event is delivered to session processing;\n\t * the listener is awaited serially by the agent loop and participates in\n\t * run settlement. Exists for stdout backpressure pacing (D-046); the raw\n\t * event payload and abort signal are deliberately not exposed.\n\t */\n\tsubscribeRawEventGate(listener: () => void | Promise<void>): () => void;\n\n\t// --- Read surface (phase 1 slice 1, TUI display/selector reads, 设计 §2.6) ---\n\t/** Delegates to AgentSession.sessionName (which reads sessionManager.getSessionName()). */\n\tgetSessionName(): string | undefined;\n\t/** Delegates to AgentSession.isCompacting: a compaction or branch summarization is running (session level). */\n\tisCompacting(): boolean;\n\t/**\n\t * Delegates to AgentSession.isStreaming: an agent run is active at the\n\t * session level. Distinct from AgentState.isStreaming (agent-level stream\n\t * flag); do not interchange the two.\n\t */\n\tisStreaming(): boolean;\n\t/** Delegates to AgentSession.getContextUsage(). */\n\tgetContextUsage(): ContextUsage | undefined;\n\t/** Delegates to AgentSession.systemPrompt (effective prompt, including per-turn extension modifications). */\n\tgetSystemPrompt(): string;\n\t/** Delegates to AgentSession.scopedModels. Read view only; setScopedModels stays a phase 2 write path. */\n\tgetScopedModels(): ReadonlyArray<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\t/** Delegates to SessionManager.getTree() on the wrapped session. SessionManager itself never leaks. */\n\tgetTree(): SessionTreeNode[];\n\t/** Delegates to SessionManager.getLeafId() on the wrapped session. SessionManager itself never leaks. */\n\tgetLeafId(): string | null;\n\n\t// --- Read surface (phase 1 slice 2, TUI display/selector cluster convergence, 设计 §2.7) ---\n\t/** Delegates to AgentSession.promptTemplates (file-based prompt templates). */\n\tgetPromptTemplates(): ReadonlyArray<PromptTemplate>;\n\t/** Delegates to AgentSession.getToolDefinition(name): the registered tool definition by name, for diagnostics/rendering. */\n\tgetToolDefinition(name: string): ToolDefinition | undefined;\n\t/** Delegates to SessionManager.getCwd() on the wrapped session; identical to host.cwd. SessionManager itself never leaks. */\n\tgetCwd(): string;\n\t/** Delegates to SessionManager.getEntries() on the wrapped session; identical to host.entries. SessionManager itself never leaks. */\n\tgetEntries(): SessionEntry[];\n\t/** Delegates to AgentSession.pendingMessageCount: queued steering + follow-up message count. */\n\tgetPendingMessageCount(): number;\n\n\t// --- Write surface (phase 2, TUI write path convergence, 设计 §2.8) ---\n\t/** Delegates to AgentSession.followUp(). */\n\tfollowUp(text: string, images?: ImageContent[], options?: { source?: InputSource }): Promise<QueuedInputDisposition>;\n\t/** Delegates to AgentSession.setScopedModels(). */\n\tsetScopedModels(scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>): void;\n\t/** Delegates to AgentSession.cycleModel(). */\n\tcycleModel(\n\t\tdirection?: \"forward\" | \"backward\",\n\t\toptions?: ModelMutationOptions,\n\t): Promise<ModelCycleResult | undefined>;\n\t/** Delegates to AgentSession.cycleThinkingLevel(). */\n\tcycleThinkingLevel(options?: ModelMutationOptions): ThinkingLevel | undefined;\n\t/** Delegates to AgentSession.setSteeringMode(). */\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\"): void;\n\t/** Delegates to AgentSession.setFollowUpMode(). */\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\"): void;\n\t/** Delegates to AgentSession.setAutoCompactionEnabled(). */\n\tsetAutoCompactionEnabled(enabled: boolean): void;\n\t/** Delegates to AgentSession.setSessionName(). */\n\tsetSessionName(name: string): void;\n\t/** Delegates to AgentSession.abortBash(). */\n\tabortBash(): void;\n\t/** Delegates to AgentSession.abortCompaction(). */\n\tabortCompaction(): void;\n\t/** Delegates to AgentSession.abortRetry(). */\n\tabortRetry(): void;\n\t/** Delegates to AgentSession.abortBranchSummary(). */\n\tabortBranchSummary(): void;\n\t/** Delegates to AgentSession.captureBashEpoch(). */\n\tcaptureBashEpoch(): number;\n\t/** Delegates to AgentSession.isBashEpochCurrent(). */\n\tisBashEpochCurrent(epoch: number): boolean;\n\t/** Delegates to AgentSession.emitUserBash(): dispatches the user.bash lifecycle facts. */\n\temitUserBash(excludeFromContext: boolean): void;\n\t/** Delegates to AgentSession.executeBash(). */\n\texecuteBash(\n\t\tcommand: string,\n\t\tonChunk?: (chunk: string) => void,\n\t\toptions?: { excludeFromContext?: boolean; id?: string; operations?: BashOperations },\n\t): Promise<BashResult>;\n\t/** Delegates to AgentSession.recordBashResult(). */\n\trecordBashResult(\n\t\tcommand: string,\n\t\tresult: BashResult,\n\t\toptions?: { excludeFromContext?: boolean; epoch?: number },\n\t): void;\n\n\t// --- Read surface (phase 3, RPC host state reads, 设计 §2.9) ---\n\t/** Delegates to AgentSession.thinkingLevel. */\n\tgetThinkingLevel(): ThinkingLevel;\n\t/** Delegates to AgentSession.steeringMode. */\n\tgetSteeringMode(): \"all\" | \"one-at-a-time\";\n\t/** Delegates to AgentSession.followUpMode. */\n\tgetFollowUpMode(): \"all\" | \"one-at-a-time\";\n\t/** Delegates to AgentSession.sessionFile. */\n\tgetSessionFile(): string | undefined;\n\t/** Delegates to AgentSession.autoCompactionEnabled. */\n\tisAutoCompactionEnabled(): boolean;\n\t/** Delegates to AgentSession.getAvailableThinkingLevels(). */\n\tgetAvailableThinkingLevels(): ThinkingLevel[];\n\t/** Delegates to AgentSession.getUserMessagesForForking(). */\n\tgetUserMessagesForForking(): ForkableUserMessage[];\n\t/** Delegates to AgentSession.getLastAssistantText(). */\n\tgetLastAssistantText(): string | undefined;\n\t/** Delegates to AgentSession.getSessionStats(). */\n\tgetSessionStats(): SessionStats;\n\n\t// --- Write surface (phase 3, RPC host writes, 设计 §2.9) ---\n\t/** Delegates to AgentSession.setAutoRetryEnabled(). */\n\tsetAutoRetryEnabled(enabled: boolean): void;\n\t/** Delegates to AgentSession.exportToHtml(), including the themeName option. */\n\texportToHtml(outputPath?: string, options?: { themeName?: string }): Promise<string>;\n\n\t// --- Session write path (阶段 4 slice 3 v1 修订, D-041) ---\n\t/**\n\t * Delegates to SessionManager.appendLabelChange() on the wrapped session.\n\t * TUI tree selector label rename write point; SessionAPI has no label write.\n\t */\n\tappendLabelChange(entryId: string, label: string | undefined): string;\n\n\t// --- Resource read surface (阶段 4 slice 3 v1 修订, D-041) ---\n\t/**\n\t * Clean read projections over the wrapped session's resource loader. Skills/\n\t * prompts/agents-files results pass through verbatim; themes and extensions\n\t * are the metadata projections (themes as ThemeMetaV1 without the modes\n\t * Theme class; loader registration maps and the shared runtime never\n\t * leak). Guard reason: TUI startup listing/autocomplete/diagnostics\n\t * consume these read points directly; SessionAPI/CapabilityAPI are\n\t * capability-side contracts with no host display projections.\n\t */\n\t/** Delegates to ResourceLoader.getSkills() on the wrapped session. */\n\tgetSkills(): { skills: Skill[]; diagnostics: ResourceDiagnostic[] };\n\t/** Delegates to ResourceLoader.getPrompts() on the wrapped session. */\n\tgetPrompts(): { prompts: PromptTemplate[]; diagnostics: ResourceDiagnostic[] };\n\t/** Delegates to ResourceLoader.getThemes() on the wrapped session. */\n\tgetThemes(): { themes: ThemeMetaV1[]; diagnostics: ResourceDiagnostic[] };\n\t/** Delegates to ResourceLoader.getAgentsFiles() on the wrapped session. */\n\tgetAgentsFiles(): { agentsFiles: Array<{ path: string; content: string }> };\n\t/** Delegates to ResourceLoader.getSystemPromptSource() on the wrapped session. */\n\tgetSystemPromptSource(): { path: string } | undefined;\n\t/** Delegates to ResourceLoader.getAppendSystemPromptSources() on the wrapped session. */\n\tgetAppendSystemPromptSources(): Array<{ path: string }>;\n\n\t// --- Model/catalog/context read surface (v1 修订, D-047: TUI direct session reads zeroed) ---\n\t/** Delegates to ModelRuntime.getAvailableSnapshot() on the wrapped session (D-047); ModelRuntime itself never leaks. */\n\tgetAvailableModels(): readonly Model<Api>[];\n\t/** Delegates to ModelRuntime.isUsingSubscription() on the wrapped session (D-047). */\n\tisUsingSubscription(providerId: string): boolean;\n\t/** Delegates to ModelRuntime.getError() on the wrapped session (D-047). */\n\tgetModelsError(): string | undefined;\n\t/**\n\t * Narrow `ModelCatalogRuntime` projection of the wrapped session's\n\t * ModelRuntime for the shared catalog-refresh coordinator (D-047). A\n\t * projection, not a wrapper: the full runtime never leaks.\n\t */\n\tgetModelCatalog(): ModelCatalogRuntime;\n\t/** Delegates to ModelRuntime.checkAuth() on the wrapped session (D-047). */\n\tcheckProviderAuth(providerId: string): Promise<AuthCheck | undefined>;\n\t/** Delegates to ModelRuntime.getAuth() on the wrapped session (D-047). */\n\tgetProviderAuth(providerId: string): Promise<AuthResult | undefined>;\n\t/**\n\t * Narrow `ModelPriceSource` projection of the wrapped session's\n\t * ModelRuntime for the cache-stats pure functions (D-047). A projection,\n\t * not a wrapper: the full runtime never leaks.\n\t */\n\tgetModelPriceSource(): ModelPriceSource;\n\t/**\n\t * Delegates to SessionManager.buildContextEntries() on the wrapped session\n\t * (D-047; delegation restored by the D-047 regression fix — the\n\t * incrementally maintained byId index is required for correct context\n\t * paths after a compaction commit). SessionManager itself never leaks.\n\t */\n\tgetContextEntries(): SessionEntry[];\n\n\t// --- Credential/provider auth read surface (v1 修订, D-048: TUI auth host path) ---\n\t/**\n\t * Narrow `ModelAuthRuntime` projection of the wrapped session's ModelRuntime\n\t * for the TUI auth surface (D-048). A projection, not a wrapper: the full\n\t * runtime never leaks. The credential-management CapabilityAPI semantics\n\t * question stays open (D-047 裁决 3); this only narrows the TUI host path.\n\t */\n\tgetModelAuthRuntime(): ModelAuthRuntime;\n\n\t// --- Session stats/text read surface (v1 修订, B-S2b③-S3a: TUI direct\n\t// session stats/text read cluster convergence) ---\n\t/** Delegates to AgentSession.getSteeringMessages(). */\n\tgetSteeringMessages(): readonly string[];\n\t/** Delegates to AgentSession.getFollowUpMessages(). */\n\tgetFollowUpMessages(): readonly string[];\n\n\t// --- Status/settings + export read surface (v1 修订, B-S2b③-S3b+c: TUI\n\t// status/settings/export cluster direct session read convergence) ---\n\t/** Delegates to AgentSession.retryAttempt. */\n\tgetRetryAttempt(): number;\n\t/** Delegates to AgentSession.isBashRunning. */\n\tisBashRunning(): boolean;\n\t/** Delegates to AgentSession.exportToJsonl(). */\n\texportToJsonl(outputPath?: string): string;\n\n\t// --- Lifecycle ---\n\t/** Delegates to AgentSession.dispose(). */\n\tdispose(): Promise<void>;\n}\n\n/** Creates a facade v1 view over one AgentSession. Pure wrapper: holds no state of its own. */\nexport function createCodingAgentFacade(session: AgentSession): CodingAgentFacadeV1 {\n\treturn {\n\t\tversion: 1,\n\t\tprompt: (text, options) => session.prompt(text, options),\n\t\tsteer: (text, images, options) => session.steer(text, images, options),\n\t\tabort: (options) => session.abort(undefined, options),\n\t\tabortAgentTasks: () => session.abortAgentTasks(),\n\t\tgetActiveAgentTaskCount: () => session.getActiveAgentTaskCount(),\n\t\twaitForIdle: () => session.waitForIdle(),\n\t\tcompact: (customInstructions) => session.compact(customInstructions),\n\t\tnavigateTree: (targetId, options) => session.navigateTree(targetId, options),\n\t\treload: (options) => session.reload(options),\n\t\tsetModel: (model, options) => session.setModel(model, options),\n\t\tsetThinkingLevel: (level, options) => session.setThinkingLevel(level, options),\n\t\tsetActiveToolsByName: (toolNames) => session.setActiveToolsByName(toolNames),\n\t\tgetQueuedMessages: () => ({\n\t\t\tsteering: session.getSteeringMessages(),\n\t\t\tfollowUp: session.getFollowUpMessages(),\n\t\t}),\n\t\tclearQueue: () => session.clearQueue(),\n\t\treorderQueuedMessages: (queue, from, to) => session.reorderQueuedMessages(queue, from, to),\n\t\tremoveQueuedMessageAt: (queue, index) => session.removeQueuedMessageAt(queue, index),\n\t\trecordSuiteMismatch: (originalSuiteId, currentSuiteId) =>\n\t\t\tsession.recordSuiteMismatch(originalSuiteId, currentSuiteId),\n\t\tgetSessionAPI: () => session.getSessionAPI(),\n\t\tisIdle: () => session.isIdle,\n\t\tgetState: () => session.state,\n\t\tgetModel: () => session.model,\n\t\tgetToolNames: () => session.getActiveToolNames(),\n\t\tgetSessionId: () => session.sessionId,\n\t\tgetHeader: () => session.sessionManager.getHeader(),\n\t\tsubscribe: (listener) => session.subscribe(listener),\n\t\tsubscribeRawEventGate: (listener) => session.agent.subscribe(() => listener()),\n\t\tgetSessionName: () => session.sessionName,\n\t\tisCompacting: () => session.isCompacting,\n\t\tisStreaming: () => session.isStreaming,\n\t\tgetContextUsage: () => session.getContextUsage(),\n\t\tgetSystemPrompt: () => session.systemPrompt,\n\t\tgetScopedModels: () => session.scopedModels,\n\t\tgetTree: () => session.sessionManager.getTree(),\n\t\tgetLeafId: () => session.sessionManager.getLeafId(),\n\t\tgetPromptTemplates: () => session.promptTemplates,\n\t\tgetToolDefinition: (name) => session.getToolDefinition(name),\n\t\tgetCwd: () => session.sessionManager.getCwd(),\n\t\tgetEntries: () => session.sessionManager.getEntries(),\n\t\tgetPendingMessageCount: () => session.pendingMessageCount,\n\t\tfollowUp: (text, images, options) => session.followUp(text, images, options),\n\t\tsetScopedModels: (scopedModels) => session.setScopedModels(scopedModels),\n\t\tcycleModel: (direction, options) => session.cycleModel(direction, options),\n\t\tcycleThinkingLevel: (options) => session.cycleThinkingLevel(options),\n\t\tsetSteeringMode: (mode) => session.setSteeringMode(mode),\n\t\tsetFollowUpMode: (mode) => session.setFollowUpMode(mode),\n\t\tsetAutoCompactionEnabled: (enabled) => session.setAutoCompactionEnabled(enabled),\n\t\tsetSessionName: (name) => session.setSessionName(name),\n\t\tabortBash: () => session.abortBash(),\n\t\tabortCompaction: () => session.abortCompaction(),\n\t\tabortRetry: () => session.abortRetry(),\n\t\tabortBranchSummary: () => session.abortBranchSummary(),\n\t\tcaptureBashEpoch: () => session.captureBashEpoch(),\n\t\tisBashEpochCurrent: (epoch) => session.isBashEpochCurrent(epoch),\n\t\temitUserBash: (excludeFromContext) => session.emitUserBash(excludeFromContext),\n\t\texecuteBash: (command, onChunk, options) => session.executeBash(command, onChunk, options),\n\t\trecordBashResult: (command, result, options) => session.recordBashResult(command, result, options),\n\t\tgetThinkingLevel: () => session.thinkingLevel,\n\t\tgetSteeringMode: () => session.steeringMode,\n\t\tgetFollowUpMode: () => session.followUpMode,\n\t\tgetSessionFile: () => session.sessionFile,\n\t\tisAutoCompactionEnabled: () => session.autoCompactionEnabled,\n\t\tgetAvailableThinkingLevels: () => session.getAvailableThinkingLevels(),\n\t\tgetUserMessagesForForking: () => session.getUserMessagesForForking(),\n\t\tgetLastAssistantText: () => session.getLastAssistantText(),\n\t\tgetSessionStats: () => session.getSessionStats(),\n\t\tsetAutoRetryEnabled: (enabled) => session.setAutoRetryEnabled(enabled),\n\t\texportToHtml: (outputPath, options) => session.exportToHtml(outputPath, options),\n\t\tappendLabelChange: (entryId, label) => session.sessionManager.appendLabelChange(entryId, label),\n\t\tgetSkills: () => session.resourceLoader.getSkills(),\n\t\tgetPrompts: () => session.resourceLoader.getPrompts(),\n\t\tgetThemes: () => session.resourceLoader.getThemes(),\n\t\tgetAgentsFiles: () => session.resourceLoader.getAgentsFiles(),\n\t\tgetSystemPromptSource: () => session.resourceLoader.getSystemPromptSource(),\n\t\tgetAppendSystemPromptSources: () => session.resourceLoader.getAppendSystemPromptSources(),\n\t\tgetSuiteId: () => readSessionSuiteBinding(session.getSessionAPI().getBranchEntries())?.suiteId,\n\t\tgetAvailableModels: () => session.modelRuntime.getAvailableSnapshot(),\n\t\tisUsingSubscription: (providerId) => session.modelRuntime.isUsingSubscription(providerId),\n\t\tgetModelsError: () => session.modelRuntime.getError(),\n\t\tgetModelCatalog: () => session.modelRuntime,\n\t\tcheckProviderAuth: (providerId) => session.modelRuntime.checkAuth(providerId),\n\t\tgetProviderAuth: (providerId) => session.modelRuntime.getAuth(providerId),\n\t\tgetModelPriceSource: () => session.modelRuntime,\n\t\tgetModelAuthRuntime: () => session.modelRuntime,\n\t\t// Delegates to the SessionManager method: its incrementally maintained\n\t\t// byId index walks the full entry graph, which rebuild-from-entries\n\t\t// diverges from after a compaction commit (D-047 regression fix).\n\t\tgetContextEntries: () => session.sessionManager.buildContextEntries(),\n\t\tgetSteeringMessages: () => session.getSteeringMessages(),\n\t\tgetFollowUpMessages: () => session.getFollowUpMessages(),\n\t\tgetRetryAttempt: () => session.retryAttempt,\n\t\tisBashRunning: () => session.isBashRunning,\n\t\texportToJsonl: (outputPath) => session.exportToJsonl(outputPath),\n\t\tdispose: () => session.dispose(),\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"http-dispatcher.d.ts","sourceRoot":"","sources":["../../src/core/http-dispatcher.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,4BAA4B,SAAU,CAAC;AAIpD,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;EAM5B,CAAC;AAKX,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAgBzE;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAMjE;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAK1E;AAKD;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,IAAI,IAAI,CASnD;AA+BD,wBAAgB,uBAAuB,CAAC,SAAS,GAAE,MAAqC,GAAG,IAAI,CAiC9F","sourcesContent":["import { EventEmitter } from \"node:events\";\nimport * as undici from \"undici\";\n\nexport const DEFAULT_HTTP_IDLE_TIMEOUT_MS = 300_000;\n// Node's 250ms default can terminate valid connection attempts on high-latency routes.\nconst DEFAULT_AUTO_SELECT_FAMILY_ATTEMPT_TIMEOUT_MS = 2_000;\n\nexport const HTTP_IDLE_TIMEOUT_CHOICES = [\n\t{ label: \"30 sec\", timeoutMs: 30_000 },\n\t{ label: \"1 min\", timeoutMs: 60_000 },\n\t{ label: \"2 min\", timeoutMs: 120_000 },\n\t{ label: \"5 min\", timeoutMs: 300_000 },\n\t{ label: \"disabled\", timeoutMs: 0 },\n] as const;\n\nconst originalGlobalFetch = globalThis.fetch;\nlet installedGlobalFetch: typeof globalThis.fetch | undefined;\n\nexport function parseHttpIdleTimeoutMs(value: unknown): number | undefined {\n\tif (typeof value === \"string\") {\n\t\tconst trimmed = value.trim();\n\t\tif (trimmed.toLowerCase() === \"disabled\") {\n\t\t\treturn 0;\n\t\t}\n\t\tif (trimmed.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn parseHttpIdleTimeoutMs(Number(trimmed));\n\t}\n\n\tif (typeof value !== \"number\" || !Number.isFinite(value) || value < 0) {\n\t\treturn undefined;\n\t}\n\treturn Math.floor(value);\n}\n\nexport function formatHttpIdleTimeoutMs(timeoutMs: number): string {\n\tconst choice = HTTP_IDLE_TIMEOUT_CHOICES.find((item) => item.timeoutMs === timeoutMs);\n\tif (choice) {\n\t\treturn choice.label;\n\t}\n\treturn `${timeoutMs / 1000} sec`;\n}\n\nexport function applyHttpProxySettings(httpProxy: string | undefined): void {\n\tconst proxy = httpProxy?.trim();\n\tif (!proxy) return;\n\tprocess.env.HTTP_PROXY ??= proxy;\n\tprocess.env.HTTPS_PROXY ??= proxy;\n}\n\nconst PROXY_ENV_KEYS = [\"HTTP_PROXY\", \"http_proxy\", \"HTTPS_PROXY\", \"https_proxy\"] as const;\nconst SOCKS_URL_PATTERN = /^socks[45]?[ah]?:\\/\\//iu;\n\n/**\n * Drop socks:// proxy URLs from the proxy environment before the global\n * EnvHttpProxyAgent picks them up. undici speaks http(s) proxies only; a socks\n * URL produces an opaque \"Connection error\" that kills model traffic with no\n * hint (seat-verified 2026-09-30: two retries then the session dies). Ignoring\n * the entry restores direct connectivity for reachable gateways, and the\n * warning names the fix (the VPN client's http/mixed port). Runs before every\n * dispatcher rebuild; deleted entries cannot warn twice.\n */\nexport function dropUnsupportedSocksProxyEnv(): void {\n\tfor (const key of PROXY_ENV_KEYS) {\n\t\tconst value = process.env[key];\n\t\tif (typeof value !== \"string\" || !SOCKS_URL_PATTERN.test(value.trim())) continue;\n\t\tconsole.error(\n\t\t\t`warning: ${key}=${value.trim()} is a socks proxy URL, which this tool does not support; ignoring it and connecting directly. Set it to your VPN client's http/mixed port instead (e.g. http://127.0.0.1:7897).`,\n\t\t);\n\t\tdelete process.env[key];\n\t}\n}\n\nconst ignoreUndiciDispatcherError = (_error: unknown): void => {};\n\n// Undici can emit an internal Client \"error\" while terminating a mid-stream\n// fetch body. The body stream still rejects through reader.read(); this listener\n// only prevents EventEmitter's unhandled \"error\" special case from crashing pi.\nfunction withUndiciErrorListener<T extends undici.Dispatcher>(dispatcher: T): T {\n\tif (dispatcher instanceof EventEmitter) {\n\t\tEventEmitter.prototype.on.call(dispatcher, \"error\", ignoreUndiciDispatcherError);\n\t}\n\treturn dispatcher;\n}\n\nfunction createUndiciClient(origin: string | URL, options: object): undici.Dispatcher {\n\treturn withUndiciErrorListener(new undici.Client(origin, options as undici.Client.Options));\n}\n\nfunction createUndiciOriginDispatcher(origin: string | URL, options: object): undici.Dispatcher {\n\tconst dispatcherOptions = options as undici.Pool.Options;\n\tif (dispatcherOptions.connections === 1) {\n\t\treturn createUndiciClient(origin, dispatcherOptions);\n\t}\n\treturn withUndiciErrorListener(\n\t\tnew undici.Pool(origin, {\n\t\t\t...dispatcherOptions,\n\t\t\tfactory: createUndiciClient,\n\t\t}),\n\t);\n}\n\nexport function configureHttpDispatcher(timeoutMs: number = DEFAULT_HTTP_IDLE_TIMEOUT_MS): void {\n\tconst normalizedTimeoutMs = parseHttpIdleTimeoutMs(timeoutMs);\n\tif (normalizedTimeoutMs === undefined) {\n\t\tthrow new Error(`Invalid HTTP idle timeout: ${String(timeoutMs)}`);\n\t}\n\tdropUnsupportedSocksProxyEnv();\n\tconst dispatcher = withUndiciErrorListener(\n\t\tnew undici.EnvHttpProxyAgent({\n\t\t\tallowH2: false,\n\t\t\t// Keep HTTP origins on CONNECT tunnels as they were before Undici 8.7.\n\t\t\tproxyTunnel: true,\n\t\t\tbodyTimeout: normalizedTimeoutMs,\n\t\t\tconnect: {\n\t\t\t\tautoSelectFamilyAttemptTimeout: DEFAULT_AUTO_SELECT_FAMILY_ATTEMPT_TIMEOUT_MS,\n\t\t\t},\n\t\t\theadersTimeout: normalizedTimeoutMs,\n\t\t\tclientFactory: createUndiciClient,\n\t\t\tfactory: createUndiciOriginDispatcher,\n\t\t}),\n\t);\n\tundici.setGlobalDispatcher(dispatcher);\n\t// Keep fetch and the dispatcher on the same undici implementation. Node 26.0's\n\t// bundled fetch can otherwise consume compressed responses through npm undici's\n\t// dispatcher without decompressing them, causing response.json() failures.\n\t// If a caller replaced fetch after module load, preserve that deliberate override.\n\tconst shouldInstallGlobals =\n\t\tinstalledGlobalFetch === undefined\n\t\t\t? globalThis.fetch === originalGlobalFetch\n\t\t\t: globalThis.fetch === installedGlobalFetch;\n\tif (shouldInstallGlobals) {\n\t\tundici.install?.();\n\t\tinstalledGlobalFetch = globalThis.fetch;\n\t}\n}\n"]}
1
+ {"version":3,"file":"http-dispatcher.d.ts","sourceRoot":"","sources":["../../src/core/http-dispatcher.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,4BAA4B,SAAU,CAAC;AAIpD,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;EAM5B,CAAC;AAKX,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAgBzE;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAMjE;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAK1E;AAKD;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,IAAI,IAAI,CASnD;AA+BD,wBAAgB,uBAAuB,CAAC,SAAS,GAAE,MAAqC,GAAG,IAAI,CAiC9F","sourcesContent":["import { EventEmitter } from \"node:events\";\nimport * as undici from \"undici\";\nimport { t } from \"./i18n/index.ts\";\n\nexport const DEFAULT_HTTP_IDLE_TIMEOUT_MS = 300_000;\n// Node's 250ms default can terminate valid connection attempts on high-latency routes.\nconst DEFAULT_AUTO_SELECT_FAMILY_ATTEMPT_TIMEOUT_MS = 2_000;\n\nexport const HTTP_IDLE_TIMEOUT_CHOICES = [\n\t{ label: \"30 sec\", timeoutMs: 30_000 },\n\t{ label: \"1 min\", timeoutMs: 60_000 },\n\t{ label: \"2 min\", timeoutMs: 120_000 },\n\t{ label: \"5 min\", timeoutMs: 300_000 },\n\t{ label: \"disabled\", timeoutMs: 0 },\n] as const;\n\nconst originalGlobalFetch = globalThis.fetch;\nlet installedGlobalFetch: typeof globalThis.fetch | undefined;\n\nexport function parseHttpIdleTimeoutMs(value: unknown): number | undefined {\n\tif (typeof value === \"string\") {\n\t\tconst trimmed = value.trim();\n\t\tif (trimmed.toLowerCase() === \"disabled\") {\n\t\t\treturn 0;\n\t\t}\n\t\tif (trimmed.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn parseHttpIdleTimeoutMs(Number(trimmed));\n\t}\n\n\tif (typeof value !== \"number\" || !Number.isFinite(value) || value < 0) {\n\t\treturn undefined;\n\t}\n\treturn Math.floor(value);\n}\n\nexport function formatHttpIdleTimeoutMs(timeoutMs: number): string {\n\tconst choice = HTTP_IDLE_TIMEOUT_CHOICES.find((item) => item.timeoutMs === timeoutMs);\n\tif (choice) {\n\t\treturn choice.label;\n\t}\n\treturn `${timeoutMs / 1000} sec`;\n}\n\nexport function applyHttpProxySettings(httpProxy: string | undefined): void {\n\tconst proxy = httpProxy?.trim();\n\tif (!proxy) return;\n\tprocess.env.HTTP_PROXY ??= proxy;\n\tprocess.env.HTTPS_PROXY ??= proxy;\n}\n\nconst PROXY_ENV_KEYS = [\"HTTP_PROXY\", \"http_proxy\", \"HTTPS_PROXY\", \"https_proxy\"] as const;\nconst SOCKS_URL_PATTERN = /^socks[45]?[ah]?:\\/\\//iu;\n\n/**\n * Drop socks:// proxy URLs from the proxy environment before the global\n * EnvHttpProxyAgent picks them up. undici speaks http(s) proxies only; a socks\n * URL produces an opaque \"Connection error\" that kills model traffic with no\n * hint (seat-verified 2026-09-30: two retries then the session dies). Ignoring\n * the entry restores direct connectivity for reachable gateways, and the\n * warning names the fix (the VPN client's http/mixed port). Runs before every\n * dispatcher rebuild; deleted entries cannot warn twice.\n */\nexport function dropUnsupportedSocksProxyEnv(): void {\n\tfor (const key of PROXY_ENV_KEYS) {\n\t\tconst value = process.env[key];\n\t\tif (typeof value !== \"string\" || !SOCKS_URL_PATTERN.test(value.trim())) continue;\n\t\tconsole.error(\n\t\t\t`warning: ${key}=${value.trim()} is a socks proxy URL, which this tool does not support; ignoring it and connecting directly. Set it to your VPN client's http/mixed port instead (e.g. http://127.0.0.1:7897).`,\n\t\t);\n\t\tdelete process.env[key];\n\t}\n}\n\nconst ignoreUndiciDispatcherError = (_error: unknown): void => {};\n\n// Undici can emit an internal Client \"error\" while terminating a mid-stream\n// fetch body. The body stream still rejects through reader.read(); this listener\n// only prevents EventEmitter's unhandled \"error\" special case from crashing pi.\nfunction withUndiciErrorListener<T extends undici.Dispatcher>(dispatcher: T): T {\n\tif (dispatcher instanceof EventEmitter) {\n\t\tEventEmitter.prototype.on.call(dispatcher, \"error\", ignoreUndiciDispatcherError);\n\t}\n\treturn dispatcher;\n}\n\nfunction createUndiciClient(origin: string | URL, options: object): undici.Dispatcher {\n\treturn withUndiciErrorListener(new undici.Client(origin, options as undici.Client.Options));\n}\n\nfunction createUndiciOriginDispatcher(origin: string | URL, options: object): undici.Dispatcher {\n\tconst dispatcherOptions = options as undici.Pool.Options;\n\tif (dispatcherOptions.connections === 1) {\n\t\treturn createUndiciClient(origin, dispatcherOptions);\n\t}\n\treturn withUndiciErrorListener(\n\t\tnew undici.Pool(origin, {\n\t\t\t...dispatcherOptions,\n\t\t\tfactory: createUndiciClient,\n\t\t}),\n\t);\n}\n\nexport function configureHttpDispatcher(timeoutMs: number = DEFAULT_HTTP_IDLE_TIMEOUT_MS): void {\n\tconst normalizedTimeoutMs = parseHttpIdleTimeoutMs(timeoutMs);\n\tif (normalizedTimeoutMs === undefined) {\n\t\tthrow new Error(t(\"Invalid HTTP idle timeout: {value}\", { value: String(timeoutMs) }));\n\t}\n\tdropUnsupportedSocksProxyEnv();\n\tconst dispatcher = withUndiciErrorListener(\n\t\tnew undici.EnvHttpProxyAgent({\n\t\t\tallowH2: false,\n\t\t\t// Keep HTTP origins on CONNECT tunnels as they were before Undici 8.7.\n\t\t\tproxyTunnel: true,\n\t\t\tbodyTimeout: normalizedTimeoutMs,\n\t\t\tconnect: {\n\t\t\t\tautoSelectFamilyAttemptTimeout: DEFAULT_AUTO_SELECT_FAMILY_ATTEMPT_TIMEOUT_MS,\n\t\t\t},\n\t\t\theadersTimeout: normalizedTimeoutMs,\n\t\t\tclientFactory: createUndiciClient,\n\t\t\tfactory: createUndiciOriginDispatcher,\n\t\t}),\n\t);\n\tundici.setGlobalDispatcher(dispatcher);\n\t// Keep fetch and the dispatcher on the same undici implementation. Node 26.0's\n\t// bundled fetch can otherwise consume compressed responses through npm undici's\n\t// dispatcher without decompressing them, causing response.json() failures.\n\t// If a caller replaced fetch after module load, preserve that deliberate override.\n\tconst shouldInstallGlobals =\n\t\tinstalledGlobalFetch === undefined\n\t\t\t? globalThis.fetch === originalGlobalFetch\n\t\t\t: globalThis.fetch === installedGlobalFetch;\n\tif (shouldInstallGlobals) {\n\t\tundici.install?.();\n\t\tinstalledGlobalFetch = globalThis.fetch;\n\t}\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import { EventEmitter } from "node:events";
2
2
  import * as undici from "undici";
3
+ import { t } from "./i18n/index.js";
3
4
  export const DEFAULT_HTTP_IDLE_TIMEOUT_MS = 300_000;
4
5
  // Node's 250ms default can terminate valid connection attempts on high-latency routes.
5
6
  const DEFAULT_AUTO_SELECT_FAMILY_ATTEMPT_TIMEOUT_MS = 2_000;
@@ -88,7 +89,7 @@ function createUndiciOriginDispatcher(origin, options) {
88
89
  export function configureHttpDispatcher(timeoutMs = DEFAULT_HTTP_IDLE_TIMEOUT_MS) {
89
90
  const normalizedTimeoutMs = parseHttpIdleTimeoutMs(timeoutMs);
90
91
  if (normalizedTimeoutMs === undefined) {
91
- throw new Error(`Invalid HTTP idle timeout: ${String(timeoutMs)}`);
92
+ throw new Error(t("Invalid HTTP idle timeout: {value}", { value: String(timeoutMs) }));
92
93
  }
93
94
  dropUnsupportedSocksProxyEnv();
94
95
  const dispatcher =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IAC/B,MAAM,UAAU,GAAG,uBAAuB,CACzC,IAAI,MAAM,CAAC,iBAAiB,CAAC;QAC5B,OAAO,EAAE,KAAK;QACd,uEAAuE;QACvE,WAAW,EAAE,IAAI;QACjB,WAAW,EAAE,mBAAmB;QAChC,OAAO,EAAE;YACR,8BAA8B,EAAE,6CAA6C;SAC7E;QACD,cAAc,EAAE,mBAAmB;QACnC,aAAa,EAAE,kBAAkB;QACjC,OAAO,EAAE,4BAA4B;KACrC,CAAC,CACF,CAAC;IACF,MAAM,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;IACvC,+EAA+E;IAC/E,gFAAgF;IAChF,2EAA2E;IAC3E,mFAAmF;IACnF,MAAM,oBAAoB,GACzB,oBAAoB,KAAK,SAAS;QACjC,CAAC,CAAC,UAAU,CAAC,KAAK,KAAK,mBAAmB;QAC1C,CAAC,CAAC,UAAU,CAAC,KAAK,KAAK,oBAAoB,CAAC;IAC9C,IAAI,oBAAoB,EAAE,CAAC;QAC1B,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;QACnB,oBAAoB,GAAG,UAAU,CAAC,KAAK,CAAC;IACzC,CAAC;AAAA,CACD","sourcesContent":["import { EventEmitter } from \"node:events\";\nimport * as undici from \"undici\";\n\nexport const DEFAULT_HTTP_IDLE_TIMEOUT_MS = 300_000;\n// Node's 250ms default can terminate valid connection attempts on high-latency routes.\nconst DEFAULT_AUTO_SELECT_FAMILY_ATTEMPT_TIMEOUT_MS = 2_000;\n\nexport const HTTP_IDLE_TIMEOUT_CHOICES = [\n\t{ label: \"30 sec\", timeoutMs: 30_000 },\n\t{ label: \"1 min\", timeoutMs: 60_000 },\n\t{ label: \"2 min\", timeoutMs: 120_000 },\n\t{ label: \"5 min\", timeoutMs: 300_000 },\n\t{ label: \"disabled\", timeoutMs: 0 },\n] as const;\n\nconst originalGlobalFetch = globalThis.fetch;\nlet installedGlobalFetch: typeof globalThis.fetch | undefined;\n\nexport function parseHttpIdleTimeoutMs(value: unknown): number | undefined {\n\tif (typeof value === \"string\") {\n\t\tconst trimmed = value.trim();\n\t\tif (trimmed.toLowerCase() === \"disabled\") {\n\t\t\treturn 0;\n\t\t}\n\t\tif (trimmed.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn parseHttpIdleTimeoutMs(Number(trimmed));\n\t}\n\n\tif (typeof value !== \"number\" || !Number.isFinite(value) || value < 0) {\n\t\treturn undefined;\n\t}\n\treturn Math.floor(value);\n}\n\nexport function formatHttpIdleTimeoutMs(timeoutMs: number): string {\n\tconst choice = HTTP_IDLE_TIMEOUT_CHOICES.find((item) => item.timeoutMs === timeoutMs);\n\tif (choice) {\n\t\treturn choice.label;\n\t}\n\treturn `${timeoutMs / 1000} sec`;\n}\n\nexport function applyHttpProxySettings(httpProxy: string | undefined): void {\n\tconst proxy = httpProxy?.trim();\n\tif (!proxy) return;\n\tprocess.env.HTTP_PROXY ??= proxy;\n\tprocess.env.HTTPS_PROXY ??= proxy;\n}\n\nconst PROXY_ENV_KEYS = [\"HTTP_PROXY\", \"http_proxy\", \"HTTPS_PROXY\", \"https_proxy\"] as const;\nconst SOCKS_URL_PATTERN = /^socks[45]?[ah]?:\\/\\//iu;\n\n/**\n * Drop socks:// proxy URLs from the proxy environment before the global\n * EnvHttpProxyAgent picks them up. undici speaks http(s) proxies only; a socks\n * URL produces an opaque \"Connection error\" that kills model traffic with no\n * hint (seat-verified 2026-09-30: two retries then the session dies). Ignoring\n * the entry restores direct connectivity for reachable gateways, and the\n * warning names the fix (the VPN client's http/mixed port). Runs before every\n * dispatcher rebuild; deleted entries cannot warn twice.\n */\nexport function dropUnsupportedSocksProxyEnv(): void {\n\tfor (const key of PROXY_ENV_KEYS) {\n\t\tconst value = process.env[key];\n\t\tif (typeof value !== \"string\" || !SOCKS_URL_PATTERN.test(value.trim())) continue;\n\t\tconsole.error(\n\t\t\t`warning: ${key}=${value.trim()} is a socks proxy URL, which this tool does not support; ignoring it and connecting directly. Set it to your VPN client's http/mixed port instead (e.g. http://127.0.0.1:7897).`,\n\t\t);\n\t\tdelete process.env[key];\n\t}\n}\n\nconst ignoreUndiciDispatcherError = (_error: unknown): void => {};\n\n// Undici can emit an internal Client \"error\" while terminating a mid-stream\n// fetch body. The body stream still rejects through reader.read(); this listener\n// only prevents EventEmitter's unhandled \"error\" special case from crashing pi.\nfunction withUndiciErrorListener<T extends undici.Dispatcher>(dispatcher: T): T {\n\tif (dispatcher instanceof EventEmitter) {\n\t\tEventEmitter.prototype.on.call(dispatcher, \"error\", ignoreUndiciDispatcherError);\n\t}\n\treturn dispatcher;\n}\n\nfunction createUndiciClient(origin: string | URL, options: object): undici.Dispatcher {\n\treturn withUndiciErrorListener(new undici.Client(origin, options as undici.Client.Options));\n}\n\nfunction createUndiciOriginDispatcher(origin: string | URL, options: object): undici.Dispatcher {\n\tconst dispatcherOptions = options as undici.Pool.Options;\n\tif (dispatcherOptions.connections === 1) {\n\t\treturn createUndiciClient(origin, dispatcherOptions);\n\t}\n\treturn withUndiciErrorListener(\n\t\tnew undici.Pool(origin, {\n\t\t\t...dispatcherOptions,\n\t\t\tfactory: createUndiciClient,\n\t\t}),\n\t);\n}\n\nexport function configureHttpDispatcher(timeoutMs: number = DEFAULT_HTTP_IDLE_TIMEOUT_MS): void {\n\tconst normalizedTimeoutMs = parseHttpIdleTimeoutMs(timeoutMs);\n\tif (normalizedTimeoutMs === undefined) {\n\t\tthrow new Error(`Invalid HTTP idle timeout: ${String(timeoutMs)}`);\n\t}\n\tdropUnsupportedSocksProxyEnv();\n\tconst dispatcher = withUndiciErrorListener(\n\t\tnew undici.EnvHttpProxyAgent({\n\t\t\tallowH2: false,\n\t\t\t// Keep HTTP origins on CONNECT tunnels as they were before Undici 8.7.\n\t\t\tproxyTunnel: true,\n\t\t\tbodyTimeout: normalizedTimeoutMs,\n\t\t\tconnect: {\n\t\t\t\tautoSelectFamilyAttemptTimeout: DEFAULT_AUTO_SELECT_FAMILY_ATTEMPT_TIMEOUT_MS,\n\t\t\t},\n\t\t\theadersTimeout: normalizedTimeoutMs,\n\t\t\tclientFactory: createUndiciClient,\n\t\t\tfactory: createUndiciOriginDispatcher,\n\t\t}),\n\t);\n\tundici.setGlobalDispatcher(dispatcher);\n\t// Keep fetch and the dispatcher on the same undici implementation. Node 26.0's\n\t// bundled fetch can otherwise consume compressed responses through npm undici's\n\t// dispatcher without decompressing them, causing response.json() failures.\n\t// If a caller replaced fetch after module load, preserve that deliberate override.\n\tconst shouldInstallGlobals =\n\t\tinstalledGlobalFetch === undefined\n\t\t\t? globalThis.fetch === originalGlobalFetch\n\t\t\t: globalThis.fetch === installedGlobalFetch;\n\tif (shouldInstallGlobals) {\n\t\tundici.install?.();\n\t\tinstalledGlobalFetch = globalThis.fetch;\n\t}\n}\n"]}
1
+ {"version":3,"file":"http-dispatcher.js","sourceRoot":"","sources":["../../src/core/http-dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAEpC,MAAM,CAAC,MAAM,4BAA4B,GAAG,OAAO,CAAC;AACpD,uFAAuF;AACvF,MAAM,6CAA6C,GAAG,KAAK,CAAC;AAE5D,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACxC,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE;IACtC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE;IACrC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE;IACtC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE;IACtC,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,EAAE;CAC1B,CAAC;AAEX,MAAM,mBAAmB,GAAG,UAAU,CAAC,KAAK,CAAC;AAC7C,IAAI,oBAAyD,CA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;AAAA,CACD","sourcesContent":["import { EventEmitter } from \"node:events\";\nimport * as undici from \"undici\";\nimport { t } from \"./i18n/index.ts\";\n\nexport const DEFAULT_HTTP_IDLE_TIMEOUT_MS = 300_000;\n// Node's 250ms default can terminate valid connection attempts on high-latency routes.\nconst DEFAULT_AUTO_SELECT_FAMILY_ATTEMPT_TIMEOUT_MS = 2_000;\n\nexport const HTTP_IDLE_TIMEOUT_CHOICES = [\n\t{ label: \"30 sec\", timeoutMs: 30_000 },\n\t{ label: \"1 min\", timeoutMs: 60_000 },\n\t{ label: \"2 min\", timeoutMs: 120_000 },\n\t{ label: \"5 min\", timeoutMs: 300_000 },\n\t{ label: \"disabled\", timeoutMs: 0 },\n] as const;\n\nconst originalGlobalFetch = globalThis.fetch;\nlet installedGlobalFetch: typeof globalThis.fetch | undefined;\n\nexport function parseHttpIdleTimeoutMs(value: unknown): number | undefined {\n\tif (typeof value === \"string\") {\n\t\tconst trimmed = value.trim();\n\t\tif (trimmed.toLowerCase() === \"disabled\") {\n\t\t\treturn 0;\n\t\t}\n\t\tif (trimmed.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn parseHttpIdleTimeoutMs(Number(trimmed));\n\t}\n\n\tif (typeof value !== \"number\" || !Number.isFinite(value) || value < 0) {\n\t\treturn undefined;\n\t}\n\treturn Math.floor(value);\n}\n\nexport function formatHttpIdleTimeoutMs(timeoutMs: number): string {\n\tconst choice = HTTP_IDLE_TIMEOUT_CHOICES.find((item) => item.timeoutMs === timeoutMs);\n\tif (choice) {\n\t\treturn choice.label;\n\t}\n\treturn `${timeoutMs / 1000} sec`;\n}\n\nexport function applyHttpProxySettings(httpProxy: string | undefined): void {\n\tconst proxy = httpProxy?.trim();\n\tif (!proxy) return;\n\tprocess.env.HTTP_PROXY ??= proxy;\n\tprocess.env.HTTPS_PROXY ??= proxy;\n}\n\nconst PROXY_ENV_KEYS = [\"HTTP_PROXY\", \"http_proxy\", \"HTTPS_PROXY\", \"https_proxy\"] as const;\nconst SOCKS_URL_PATTERN = /^socks[45]?[ah]?:\\/\\//iu;\n\n/**\n * Drop socks:// proxy URLs from the proxy environment before the global\n * EnvHttpProxyAgent picks them up. undici speaks http(s) proxies only; a socks\n * URL produces an opaque \"Connection error\" that kills model traffic with no\n * hint (seat-verified 2026-09-30: two retries then the session dies). Ignoring\n * the entry restores direct connectivity for reachable gateways, and the\n * warning names the fix (the VPN client's http/mixed port). Runs before every\n * dispatcher rebuild; deleted entries cannot warn twice.\n */\nexport function dropUnsupportedSocksProxyEnv(): void {\n\tfor (const key of PROXY_ENV_KEYS) {\n\t\tconst value = process.env[key];\n\t\tif (typeof value !== \"string\" || !SOCKS_URL_PATTERN.test(value.trim())) continue;\n\t\tconsole.error(\n\t\t\t`warning: ${key}=${value.trim()} is a socks proxy URL, which this tool does not support; ignoring it and connecting directly. Set it to your VPN client's http/mixed port instead (e.g. http://127.0.0.1:7897).`,\n\t\t);\n\t\tdelete process.env[key];\n\t}\n}\n\nconst ignoreUndiciDispatcherError = (_error: unknown): void => {};\n\n// Undici can emit an internal Client \"error\" while terminating a mid-stream\n// fetch body. The body stream still rejects through reader.read(); this listener\n// only prevents EventEmitter's unhandled \"error\" special case from crashing pi.\nfunction withUndiciErrorListener<T extends undici.Dispatcher>(dispatcher: T): T {\n\tif (dispatcher instanceof EventEmitter) {\n\t\tEventEmitter.prototype.on.call(dispatcher, \"error\", ignoreUndiciDispatcherError);\n\t}\n\treturn dispatcher;\n}\n\nfunction createUndiciClient(origin: string | URL, options: object): undici.Dispatcher {\n\treturn withUndiciErrorListener(new undici.Client(origin, options as undici.Client.Options));\n}\n\nfunction createUndiciOriginDispatcher(origin: string | URL, options: object): undici.Dispatcher {\n\tconst dispatcherOptions = options as undici.Pool.Options;\n\tif (dispatcherOptions.connections === 1) {\n\t\treturn createUndiciClient(origin, dispatcherOptions);\n\t}\n\treturn withUndiciErrorListener(\n\t\tnew undici.Pool(origin, {\n\t\t\t...dispatcherOptions,\n\t\t\tfactory: createUndiciClient,\n\t\t}),\n\t);\n}\n\nexport function configureHttpDispatcher(timeoutMs: number = DEFAULT_HTTP_IDLE_TIMEOUT_MS): void {\n\tconst normalizedTimeoutMs = parseHttpIdleTimeoutMs(timeoutMs);\n\tif (normalizedTimeoutMs === undefined) {\n\t\tthrow new Error(t(\"Invalid HTTP idle timeout: {value}\", { value: String(timeoutMs) }));\n\t}\n\tdropUnsupportedSocksProxyEnv();\n\tconst dispatcher = withUndiciErrorListener(\n\t\tnew undici.EnvHttpProxyAgent({\n\t\t\tallowH2: false,\n\t\t\t// Keep HTTP origins on CONNECT tunnels as they were before Undici 8.7.\n\t\t\tproxyTunnel: true,\n\t\t\tbodyTimeout: normalizedTimeoutMs,\n\t\t\tconnect: {\n\t\t\t\tautoSelectFamilyAttemptTimeout: DEFAULT_AUTO_SELECT_FAMILY_ATTEMPT_TIMEOUT_MS,\n\t\t\t},\n\t\t\theadersTimeout: normalizedTimeoutMs,\n\t\t\tclientFactory: createUndiciClient,\n\t\t\tfactory: createUndiciOriginDispatcher,\n\t\t}),\n\t);\n\tundici.setGlobalDispatcher(dispatcher);\n\t// Keep fetch and the dispatcher on the same undici implementation. Node 26.0's\n\t// bundled fetch can otherwise consume compressed responses through npm undici's\n\t// dispatcher without decompressing them, causing response.json() failures.\n\t// If a caller replaced fetch after module load, preserve that deliberate override.\n\tconst shouldInstallGlobals =\n\t\tinstalledGlobalFetch === undefined\n\t\t\t? globalThis.fetch === originalGlobalFetch\n\t\t\t: globalThis.fetch === installedGlobalFetch;\n\tif (shouldInstallGlobals) {\n\t\tundici.install?.();\n\t\tinstalledGlobalFetch = globalThis.fetch;\n\t}\n}\n"]}