@bastani/atomic 0.9.20-alpha.3 → 0.9.20-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (763) hide show
  1. package/CHANGELOG.md +131 -0
  2. package/README.md +15 -7
  3. package/dist/builtin/intercom/CHANGELOG.md +18 -0
  4. package/dist/builtin/intercom/README.md +2 -2
  5. package/dist/builtin/intercom/broker/send-handler.ts +59 -2
  6. package/dist/builtin/intercom/index.bundle.mjs +101 -16
  7. package/dist/builtin/intercom/package.json +3 -3
  8. package/dist/builtin/intercom/session-target.ts +34 -9
  9. package/dist/builtin/intercom/skills/intercom/SKILL.md +4 -4
  10. package/dist/builtin/mcp/CHANGELOG.md +13 -0
  11. package/dist/builtin/mcp/OAUTH.md +1 -1
  12. package/dist/builtin/mcp/README.md +3 -1
  13. package/dist/builtin/mcp/index.bundle.mjs +412 -64
  14. package/dist/builtin/mcp/package.json +3 -3
  15. package/dist/builtin/subagents/CHANGELOG.md +27 -0
  16. package/dist/builtin/subagents/README.md +2 -2
  17. package/dist/builtin/subagents/agents/code-simplifier.md +2 -3
  18. package/dist/builtin/subagents/agents/codebase-analyzer.md +2 -3
  19. package/dist/builtin/subagents/agents/codebase-locator.md +2 -3
  20. package/dist/builtin/subagents/agents/codebase-online-researcher.md +2 -3
  21. package/dist/builtin/subagents/agents/codebase-pattern-finder.md +2 -3
  22. package/dist/builtin/subagents/agents/codebase-research-analyzer.md +2 -3
  23. package/dist/builtin/subagents/agents/codebase-research-locator.md +2 -3
  24. package/dist/builtin/subagents/agents/debugger.md +1 -2
  25. package/dist/builtin/subagents/agents/worker.md +1 -2
  26. package/dist/builtin/subagents/package.json +4 -8
  27. package/dist/builtin/subagents/skills/subagent/SKILL.md +15 -13
  28. package/dist/builtin/subagents/src/extension/index.bundle.mjs +249 -63
  29. package/dist/builtin/web-access/CHANGELOG.md +12 -0
  30. package/dist/builtin/web-access/index.bundle.mjs +367 -295
  31. package/dist/builtin/web-access/package.json +3 -3
  32. package/dist/builtin/workflows/CHANGELOG.md +68 -0
  33. package/dist/builtin/workflows/README.md +29 -30
  34. package/dist/builtin/workflows/builtin/adversarial-verification.js +3 -3
  35. package/dist/builtin/workflows/builtin/{chunk-yeee2jrc.js → chunk-119kxb28.js} +5 -46
  36. package/dist/builtin/workflows/builtin/chunk-1dydq7w3.js +9722 -0
  37. package/dist/builtin/workflows/builtin/{chunk-31j2gs7h.js → chunk-9y0f90rd.js} +4 -6
  38. package/dist/builtin/workflows/builtin/{chunk-z29qbehr.js → chunk-d1xqh1rd.js} +4 -6
  39. package/dist/builtin/workflows/builtin/{chunk-zqtm1d2c.js → chunk-hnbbb5r0.js} +12 -217
  40. package/dist/builtin/workflows/builtin/{chunk-wf741bv3.js → chunk-k18g9me8.js} +4 -6
  41. package/dist/builtin/workflows/builtin/{chunk-g0csgs7w.js → chunk-kf5xpbkz.js} +8 -10
  42. package/dist/builtin/workflows/builtin/{chunk-a2kdsqn8.js → chunk-n4yxrsm9.js} +1 -1
  43. package/dist/builtin/workflows/builtin/{chunk-xtxcq5tj.js → chunk-n8g2da69.js} +17 -1
  44. package/dist/builtin/workflows/builtin/{chunk-fg9esgkj.js → chunk-scgprmdj.js} +4 -6
  45. package/dist/builtin/workflows/builtin/{chunk-6w6cvk6b.js → chunk-sn5mchnx.js} +4 -6
  46. package/dist/builtin/workflows/builtin/{chunk-ewkkkbak.js → chunk-vt9zgr9d.js} +9 -91
  47. package/dist/builtin/workflows/builtin/classify-and-act.js +3 -3
  48. package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +3 -3
  49. package/dist/builtin/workflows/builtin/generate-and-filter.js +3 -3
  50. package/dist/builtin/workflows/builtin/goal.js +4 -4
  51. package/dist/builtin/workflows/builtin/index.js +12 -12
  52. package/dist/builtin/workflows/builtin/loop-until-done.js +3 -3
  53. package/dist/builtin/workflows/builtin/open-claude-design.js +3 -3
  54. package/dist/builtin/workflows/builtin/ralph.js +4 -4
  55. package/dist/builtin/workflows/builtin/steering-context.js +1 -1
  56. package/dist/builtin/workflows/builtin/tournament.js +3 -3
  57. package/dist/builtin/workflows/package.json +3 -3
  58. package/dist/builtin/workflows/src/authoring.d.ts +2 -0
  59. package/dist/builtin/workflows/src/durable/dependency-doctor-types.d.ts +42 -0
  60. package/dist/builtin/workflows/src/extension/index.bundle.mjs +82005 -78701
  61. package/dist/builtin/workflows/src/index.js +8900 -1200
  62. package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +11 -0
  63. package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +4 -1
  64. package/dist/cli/args.js +2 -2
  65. package/dist/cli/args.js.map +1 -1
  66. package/dist/config.d.ts +1 -0
  67. package/dist/config.d.ts.map +1 -1
  68. package/dist/config.js +1 -0
  69. package/dist/config.js.map +1 -1
  70. package/dist/core/agent-session-accessors.d.ts.map +1 -1
  71. package/dist/core/agent-session-accessors.js +2 -1
  72. package/dist/core/agent-session-accessors.js.map +1 -1
  73. package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
  74. package/dist/core/agent-session-auto-compaction.js +9 -2
  75. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  76. package/dist/core/agent-session-bash.d.ts +3 -1
  77. package/dist/core/agent-session-bash.d.ts.map +1 -1
  78. package/dist/core/agent-session-bash.js +18 -6
  79. package/dist/core/agent-session-bash.js.map +1 -1
  80. package/dist/core/agent-session-compaction.d.ts.map +1 -1
  81. package/dist/core/agent-session-compaction.js +25 -8
  82. package/dist/core/agent-session-compaction.js.map +1 -1
  83. package/dist/core/agent-session-events.d.ts +6 -6
  84. package/dist/core/agent-session-events.d.ts.map +1 -1
  85. package/dist/core/agent-session-events.js +145 -62
  86. package/dist/core/agent-session-events.js.map +1 -1
  87. package/dist/core/agent-session-export.d.ts +1 -1
  88. package/dist/core/agent-session-export.d.ts.map +1 -1
  89. package/dist/core/agent-session-export.js +18 -19
  90. package/dist/core/agent-session-export.js.map +1 -1
  91. package/dist/core/agent-session-extension-bindings.d.ts +3 -2
  92. package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
  93. package/dist/core/agent-session-extension-bindings.js +274 -70
  94. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  95. package/dist/core/agent-session-message-queue.d.ts +1 -1
  96. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  97. package/dist/core/agent-session-message-queue.js +30 -4
  98. package/dist/core/agent-session-message-queue.js.map +1 -1
  99. package/dist/core/agent-session-methods.d.ts +19 -11
  100. package/dist/core/agent-session-methods.d.ts.map +1 -1
  101. package/dist/core/agent-session-methods.js.map +1 -1
  102. package/dist/core/agent-session-models.d.ts +2 -2
  103. package/dist/core/agent-session-models.d.ts.map +1 -1
  104. package/dist/core/agent-session-models.js +38 -29
  105. package/dist/core/agent-session-models.js.map +1 -1
  106. package/dist/core/agent-session-persistent-custom-messages.d.ts +1 -1
  107. package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
  108. package/dist/core/agent-session-post-tool-compaction.d.ts.map +1 -1
  109. package/dist/core/agent-session-post-tool-compaction.js +18 -1
  110. package/dist/core/agent-session-post-tool-compaction.js.map +1 -1
  111. package/dist/core/agent-session-prompt.d.ts +1 -1
  112. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  113. package/dist/core/agent-session-prompt.js +104 -22
  114. package/dist/core/agent-session-prompt.js.map +1 -1
  115. package/dist/core/agent-session-queue-pause.d.ts +2 -0
  116. package/dist/core/agent-session-queue-pause.d.ts.map +1 -1
  117. package/dist/core/agent-session-queue-pause.js +13 -2
  118. package/dist/core/agent-session-queue-pause.js.map +1 -1
  119. package/dist/core/agent-session-retry.d.ts +0 -3
  120. package/dist/core/agent-session-retry.d.ts.map +1 -1
  121. package/dist/core/agent-session-retry.js +24 -11
  122. package/dist/core/agent-session-retry.js.map +1 -1
  123. package/dist/core/agent-session-runtime-auth.d.ts.map +1 -1
  124. package/dist/core/agent-session-runtime-auth.js +10 -0
  125. package/dist/core/agent-session-runtime-auth.js.map +1 -1
  126. package/dist/core/agent-session-runtime.d.ts +17 -1
  127. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  128. package/dist/core/agent-session-runtime.js +428 -197
  129. package/dist/core/agent-session-runtime.js.map +1 -1
  130. package/dist/core/agent-session-services.d.ts +4 -0
  131. package/dist/core/agent-session-services.d.ts.map +1 -1
  132. package/dist/core/agent-session-services.js +31 -2
  133. package/dist/core/agent-session-services.js.map +1 -1
  134. package/dist/core/agent-session-state.d.ts +10 -2
  135. package/dist/core/agent-session-state.d.ts.map +1 -1
  136. package/dist/core/agent-session-state.js +32 -22
  137. package/dist/core/agent-session-state.js.map +1 -1
  138. package/dist/core/agent-session-summary.d.ts.map +1 -1
  139. package/dist/core/agent-session-summary.js +9 -2
  140. package/dist/core/agent-session-summary.js.map +1 -1
  141. package/dist/core/agent-session-tasks.d.ts +1 -0
  142. package/dist/core/agent-session-tasks.d.ts.map +1 -1
  143. package/dist/core/agent-session-tasks.js +24 -3
  144. package/dist/core/agent-session-tasks.js.map +1 -1
  145. package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
  146. package/dist/core/agent-session-tool-hooks.js +26 -3
  147. package/dist/core/agent-session-tool-hooks.js.map +1 -1
  148. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  149. package/dist/core/agent-session-tool-registry.js +0 -2
  150. package/dist/core/agent-session-tool-registry.js.map +1 -1
  151. package/dist/core/agent-session-transfer.js.map +1 -1
  152. package/dist/core/agent-session-tree.d.ts.map +1 -1
  153. package/dist/core/agent-session-tree.js +6 -0
  154. package/dist/core/agent-session-tree.js.map +1 -1
  155. package/dist/core/agent-session-types.d.ts +5 -0
  156. package/dist/core/agent-session-types.d.ts.map +1 -1
  157. package/dist/core/agent-session-types.js.map +1 -1
  158. package/dist/core/agent-session.d.ts +15 -8
  159. package/dist/core/agent-session.d.ts.map +1 -1
  160. package/dist/core/agent-session.js +113 -66
  161. package/dist/core/agent-session.js.map +1 -1
  162. package/dist/core/auth-storage.d.ts +5 -3
  163. package/dist/core/auth-storage.d.ts.map +1 -1
  164. package/dist/core/auth-storage.js +18 -5
  165. package/dist/core/auth-storage.js.map +1 -1
  166. package/dist/core/builtin-diagnostics.d.ts +2 -0
  167. package/dist/core/builtin-diagnostics.d.ts.map +1 -0
  168. package/dist/core/builtin-diagnostics.js +14 -0
  169. package/dist/core/builtin-diagnostics.js.map +1 -0
  170. package/dist/core/builtin-packages.d.ts +5 -2
  171. package/dist/core/builtin-packages.d.ts.map +1 -1
  172. package/dist/core/builtin-packages.js +24 -3
  173. package/dist/core/builtin-packages.js.map +1 -1
  174. package/dist/core/builtin-resource-loader.d.ts +4 -0
  175. package/dist/core/builtin-resource-loader.d.ts.map +1 -0
  176. package/dist/core/builtin-resource-loader.js +239 -0
  177. package/dist/core/builtin-resource-loader.js.map +1 -0
  178. package/dist/core/cache-retention.d.ts +4 -0
  179. package/dist/core/cache-retention.d.ts.map +1 -0
  180. package/dist/core/cache-retention.js +58 -0
  181. package/dist/core/cache-retention.js.map +1 -0
  182. package/dist/core/cache-stats.d.ts.map +1 -1
  183. package/dist/core/cache-stats.js +11 -0
  184. package/dist/core/cache-stats.js.map +1 -1
  185. package/dist/core/cache-warmer.d.ts +66 -0
  186. package/dist/core/cache-warmer.d.ts.map +1 -0
  187. package/dist/core/cache-warmer.js +313 -0
  188. package/dist/core/cache-warmer.js.map +1 -0
  189. package/dist/core/child-session-options.d.ts +5 -0
  190. package/dist/core/child-session-options.d.ts.map +1 -0
  191. package/dist/core/child-session-options.js +30 -0
  192. package/dist/core/child-session-options.js.map +1 -0
  193. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  194. package/dist/core/compaction/branch-summarization.js +2 -2
  195. package/dist/core/compaction/branch-summarization.js.map +1 -1
  196. package/dist/core/compaction/compaction-boundary.d.ts.map +1 -1
  197. package/dist/core/compaction/compaction-boundary.js +2 -1
  198. package/dist/core/compaction/compaction-boundary.js.map +1 -1
  199. package/dist/core/compaction/compaction.d.ts.map +1 -1
  200. package/dist/core/compaction/compaction.js +18 -0
  201. package/dist/core/compaction/compaction.js.map +1 -1
  202. package/dist/core/compaction/fallback-planner.d.ts +1 -0
  203. package/dist/core/compaction/fallback-planner.d.ts.map +1 -1
  204. package/dist/core/compaction/fallback-planner.js +2 -0
  205. package/dist/core/compaction/fallback-planner.js.map +1 -1
  206. package/dist/core/compaction/range-planner.d.ts.map +1 -1
  207. package/dist/core/compaction/range-planner.js +3 -3
  208. package/dist/core/compaction/range-planner.js.map +1 -1
  209. package/dist/core/compaction/session-summarization.d.ts.map +1 -1
  210. package/dist/core/compaction/session-summarization.js +2 -1
  211. package/dist/core/compaction/session-summarization.js.map +1 -1
  212. package/dist/core/credential-screening.d.ts +17 -0
  213. package/dist/core/credential-screening.d.ts.map +1 -0
  214. package/dist/core/credential-screening.js +30 -0
  215. package/dist/core/credential-screening.js.map +1 -0
  216. package/dist/core/decision-provider.d.ts +4 -0
  217. package/dist/core/decision-provider.d.ts.map +1 -0
  218. package/dist/core/decision-provider.js +12 -0
  219. package/dist/core/decision-provider.js.map +1 -0
  220. package/dist/core/execution-model-router.d.ts +28 -0
  221. package/dist/core/execution-model-router.d.ts.map +1 -0
  222. package/dist/core/execution-model-router.js +165 -0
  223. package/dist/core/execution-model-router.js.map +1 -0
  224. package/dist/core/extensions/agent-events.d.ts +4 -4
  225. package/dist/core/extensions/agent-events.d.ts.map +1 -1
  226. package/dist/core/extensions/agent-events.js.map +1 -1
  227. package/dist/core/extensions/api-types.d.ts +46 -40
  228. package/dist/core/extensions/api-types.d.ts.map +1 -1
  229. package/dist/core/extensions/api-types.js.map +1 -1
  230. package/dist/core/extensions/context-types.d.ts +7 -1
  231. package/dist/core/extensions/context-types.d.ts.map +1 -1
  232. package/dist/core/extensions/context-types.js.map +1 -1
  233. package/dist/core/extensions/event-results.d.ts +7 -6
  234. package/dist/core/extensions/event-results.d.ts.map +1 -1
  235. package/dist/core/extensions/event-results.js.map +1 -1
  236. package/dist/core/extensions/event-types.d.ts +2 -1
  237. package/dist/core/extensions/event-types.d.ts.map +1 -1
  238. package/dist/core/extensions/event-types.js.map +1 -1
  239. package/dist/core/extensions/extension-work.d.ts +14 -0
  240. package/dist/core/extensions/extension-work.d.ts.map +1 -0
  241. package/dist/core/extensions/extension-work.js +73 -0
  242. package/dist/core/extensions/extension-work.js.map +1 -0
  243. package/dist/core/extensions/herdr-file-integration.d.ts +36 -0
  244. package/dist/core/extensions/herdr-file-integration.d.ts.map +1 -0
  245. package/dist/core/extensions/herdr-file-integration.js +60 -0
  246. package/dist/core/extensions/herdr-file-integration.js.map +1 -0
  247. package/dist/core/extensions/host-input.d.ts +51 -0
  248. package/dist/core/extensions/host-input.d.ts.map +1 -0
  249. package/dist/core/extensions/host-input.js +211 -0
  250. package/dist/core/extensions/host-input.js.map +1 -0
  251. package/dist/core/extensions/index.d.ts +4 -2
  252. package/dist/core/extensions/index.d.ts.map +1 -1
  253. package/dist/core/extensions/index.js +0 -3
  254. package/dist/core/extensions/index.js.map +1 -1
  255. package/dist/core/extensions/jiti-loader.d.ts +2 -0
  256. package/dist/core/extensions/jiti-loader.d.ts.map +1 -0
  257. package/dist/core/extensions/jiti-loader.js +3 -0
  258. package/dist/core/extensions/jiti-loader.js.map +1 -0
  259. package/dist/core/extensions/jiti-static-loader.d.ts +2 -0
  260. package/dist/core/extensions/jiti-static-loader.d.ts.map +1 -0
  261. package/dist/core/extensions/jiti-static-loader.js +3 -0
  262. package/dist/core/extensions/jiti-static-loader.js.map +1 -0
  263. package/dist/core/extensions/loader-api.d.ts +7 -0
  264. package/dist/core/extensions/loader-api.d.ts.map +1 -1
  265. package/dist/core/extensions/loader-api.js +154 -28
  266. package/dist/core/extensions/loader-api.js.map +1 -1
  267. package/dist/core/extensions/loader-bindings.d.ts +24 -0
  268. package/dist/core/extensions/loader-bindings.d.ts.map +1 -0
  269. package/dist/core/extensions/loader-bindings.js +128 -0
  270. package/dist/core/extensions/loader-bindings.js.map +1 -0
  271. package/dist/core/extensions/loader-core.d.ts +2 -1
  272. package/dist/core/extensions/loader-core.d.ts.map +1 -1
  273. package/dist/core/extensions/loader-core.js +91 -14
  274. package/dist/core/extensions/loader-core.js.map +1 -1
  275. package/dist/core/extensions/loader-host-modules.d.ts.map +1 -1
  276. package/dist/core/extensions/loader-host-modules.js +3 -1
  277. package/dist/core/extensions/loader-host-modules.js.map +1 -1
  278. package/dist/core/extensions/loader-rollback.d.ts +14 -0
  279. package/dist/core/extensions/loader-rollback.d.ts.map +1 -0
  280. package/dist/core/extensions/loader-rollback.js +95 -0
  281. package/dist/core/extensions/loader-rollback.js.map +1 -0
  282. package/dist/core/extensions/loader-runtime.d.ts +3 -1
  283. package/dist/core/extensions/loader-runtime.d.ts.map +1 -1
  284. package/dist/core/extensions/loader-runtime.js +38 -14
  285. package/dist/core/extensions/loader-runtime.js.map +1 -1
  286. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  287. package/dist/core/extensions/loader-virtual-modules.js +9 -2
  288. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  289. package/dist/core/extensions/loader.d.ts +1 -1
  290. package/dist/core/extensions/loader.d.ts.map +1 -1
  291. package/dist/core/extensions/loader.js +1 -1
  292. package/dist/core/extensions/loader.js.map +1 -1
  293. package/dist/core/extensions/reactive-widget.d.ts +1 -1
  294. package/dist/core/extensions/reactive-widget.js.map +1 -1
  295. package/dist/core/extensions/runner-context.d.ts +4 -0
  296. package/dist/core/extensions/runner-context.d.ts.map +1 -1
  297. package/dist/core/extensions/runner-context.js +25 -0
  298. package/dist/core/extensions/runner-context.js.map +1 -1
  299. package/dist/core/extensions/runner-events.d.ts +8 -4
  300. package/dist/core/extensions/runner-events.d.ts.map +1 -1
  301. package/dist/core/extensions/runner-events.js +55 -53
  302. package/dist/core/extensions/runner-events.js.map +1 -1
  303. package/dist/core/extensions/runner-project-trust.d.ts.map +1 -1
  304. package/dist/core/extensions/runner-project-trust.js +2 -4
  305. package/dist/core/extensions/runner-project-trust.js.map +1 -1
  306. package/dist/core/extensions/runner.d.ts +31 -4
  307. package/dist/core/extensions/runner.d.ts.map +1 -1
  308. package/dist/core/extensions/runner.js +219 -23
  309. package/dist/core/extensions/runner.js.map +1 -1
  310. package/dist/core/extensions/runtime-types.d.ts +2 -0
  311. package/dist/core/extensions/runtime-types.d.ts.map +1 -1
  312. package/dist/core/extensions/runtime-types.js.map +1 -1
  313. package/dist/core/extensions/types.d.ts +3 -2
  314. package/dist/core/extensions/types.d.ts.map +1 -1
  315. package/dist/core/extensions/types.js +0 -12
  316. package/dist/core/extensions/types.js.map +1 -1
  317. package/dist/core/extensions/workflow-activity-hub.d.ts +2 -0
  318. package/dist/core/extensions/workflow-activity-hub.d.ts.map +1 -1
  319. package/dist/core/extensions/workflow-activity-hub.js +5 -3
  320. package/dist/core/extensions/workflow-activity-hub.js.map +1 -1
  321. package/dist/core/extensions/wrapper.d.ts.map +1 -1
  322. package/dist/core/extensions/wrapper.js +5 -3
  323. package/dist/core/extensions/wrapper.js.map +1 -1
  324. package/dist/core/fast-model-routing.d.ts +3 -3
  325. package/dist/core/fast-model-routing.d.ts.map +1 -1
  326. package/dist/core/fast-model-routing.js +3 -3
  327. package/dist/core/fast-model-routing.js.map +1 -1
  328. package/dist/core/fast-model-variants.d.ts +4 -0
  329. package/dist/core/fast-model-variants.d.ts.map +1 -1
  330. package/dist/core/fast-model-variants.js +3 -0
  331. package/dist/core/fast-model-variants.js.map +1 -1
  332. package/dist/core/index.d.ts +4 -1
  333. package/dist/core/index.d.ts.map +1 -1
  334. package/dist/core/index.js +2 -0
  335. package/dist/core/index.js.map +1 -1
  336. package/dist/core/mandatory-resource-loader.d.ts +4 -0
  337. package/dist/core/mandatory-resource-loader.d.ts.map +1 -1
  338. package/dist/core/mandatory-resource-loader.js +29 -1
  339. package/dist/core/mandatory-resource-loader.js.map +1 -1
  340. package/dist/core/mandatory-runtime-tools.d.ts +1 -4
  341. package/dist/core/mandatory-runtime-tools.d.ts.map +1 -1
  342. package/dist/core/mandatory-runtime-tools.js +1 -9
  343. package/dist/core/mandatory-runtime-tools.js.map +1 -1
  344. package/dist/core/messages.d.ts.map +1 -1
  345. package/dist/core/messages.js +8 -1
  346. package/dist/core/messages.js.map +1 -1
  347. package/dist/core/model-config.d.ts +41 -10
  348. package/dist/core/model-config.d.ts.map +1 -1
  349. package/dist/core/model-config.js +11 -2
  350. package/dist/core/model-config.js.map +1 -1
  351. package/dist/core/model-registry.d.ts +4 -2
  352. package/dist/core/model-registry.d.ts.map +1 -1
  353. package/dist/core/model-registry.js +6 -2
  354. package/dist/core/model-registry.js.map +1 -1
  355. package/dist/core/model-routing-constraints.d.ts +24 -0
  356. package/dist/core/model-routing-constraints.d.ts.map +1 -0
  357. package/dist/core/model-routing-constraints.js +46 -0
  358. package/dist/core/model-routing-constraints.js.map +1 -0
  359. package/dist/core/model-routing-task.d.ts +4 -0
  360. package/dist/core/model-routing-task.d.ts.map +1 -0
  361. package/dist/core/model-routing-task.js +76 -0
  362. package/dist/core/model-routing-task.js.map +1 -0
  363. package/dist/core/model-runtime-streaming.d.ts +13 -3
  364. package/dist/core/model-runtime-streaming.d.ts.map +1 -1
  365. package/dist/core/model-runtime-streaming.js +15 -5
  366. package/dist/core/model-runtime-streaming.js.map +1 -1
  367. package/dist/core/model-runtime-types.d.ts +2 -2
  368. package/dist/core/model-runtime-types.d.ts.map +1 -1
  369. package/dist/core/model-runtime-types.js.map +1 -1
  370. package/dist/core/model-runtime.d.ts +6 -3
  371. package/dist/core/model-runtime.d.ts.map +1 -1
  372. package/dist/core/model-runtime.js +29 -2
  373. package/dist/core/model-runtime.js.map +1 -1
  374. package/dist/core/provider-composer-internal.d.ts +3 -2
  375. package/dist/core/provider-composer-internal.d.ts.map +1 -1
  376. package/dist/core/provider-composer-internal.js +2 -0
  377. package/dist/core/provider-composer-internal.js.map +1 -1
  378. package/dist/core/provider-composer.d.ts.map +1 -1
  379. package/dist/core/provider-composer.js.map +1 -1
  380. package/dist/core/resolve-config-value.d.ts +2 -0
  381. package/dist/core/resolve-config-value.d.ts.map +1 -1
  382. package/dist/core/resolve-config-value.js +23 -1
  383. package/dist/core/resolve-config-value.js.map +1 -1
  384. package/dist/core/resource-loader-core.d.ts +6 -0
  385. package/dist/core/resource-loader-core.d.ts.map +1 -1
  386. package/dist/core/resource-loader-core.js +37 -6
  387. package/dist/core/resource-loader-core.js.map +1 -1
  388. package/dist/core/resource-loader-extensions.d.ts.map +1 -1
  389. package/dist/core/resource-loader-extensions.js +2 -0
  390. package/dist/core/resource-loader-extensions.js.map +1 -1
  391. package/dist/core/resource-loader-reload.d.ts.map +1 -1
  392. package/dist/core/resource-loader-reload.js +7 -2
  393. package/dist/core/resource-loader-reload.js.map +1 -1
  394. package/dist/core/resource-loader.d.ts +1 -1
  395. package/dist/core/resource-loader.d.ts.map +1 -1
  396. package/dist/core/resource-loader.js +1 -1
  397. package/dist/core/resource-loader.js.map +1 -1
  398. package/dist/core/runtime-credentials.d.ts +2 -0
  399. package/dist/core/runtime-credentials.d.ts.map +1 -1
  400. package/dist/core/runtime-credentials.js +15 -0
  401. package/dist/core/runtime-credentials.js.map +1 -1
  402. package/dist/core/sdk-types.d.ts +13 -5
  403. package/dist/core/sdk-types.d.ts.map +1 -1
  404. package/dist/core/sdk-types.js.map +1 -1
  405. package/dist/core/sdk.d.ts +3 -1
  406. package/dist/core/sdk.d.ts.map +1 -1
  407. package/dist/core/sdk.js +211 -37
  408. package/dist/core/sdk.js.map +1 -1
  409. package/dist/core/session-lifecycle-scope.d.ts +15 -0
  410. package/dist/core/session-lifecycle-scope.d.ts.map +1 -0
  411. package/dist/core/session-lifecycle-scope.js +13 -0
  412. package/dist/core/session-lifecycle-scope.js.map +1 -0
  413. package/dist/core/session-lifecycle-work.d.ts +17 -0
  414. package/dist/core/session-lifecycle-work.d.ts.map +1 -0
  415. package/dist/core/session-lifecycle-work.js +144 -0
  416. package/dist/core/session-lifecycle-work.js.map +1 -0
  417. package/dist/core/session-manager-core.d.ts +8 -4
  418. package/dist/core/session-manager-core.d.ts.map +1 -1
  419. package/dist/core/session-manager-core.js +27 -3
  420. package/dist/core/session-manager-core.js.map +1 -1
  421. package/dist/core/session-manager-history.d.ts.map +1 -1
  422. package/dist/core/session-manager-history.js +3 -0
  423. package/dist/core/session-manager-history.js.map +1 -1
  424. package/dist/core/session-manager-list.d.ts +3 -3
  425. package/dist/core/session-manager-list.d.ts.map +1 -1
  426. package/dist/core/session-manager-list.js +89 -74
  427. package/dist/core/session-manager-list.js.map +1 -1
  428. package/dist/core/session-manager-storage.d.ts.map +1 -1
  429. package/dist/core/session-manager-storage.js +10 -7
  430. package/dist/core/session-manager-storage.js.map +1 -1
  431. package/dist/core/session-manager-types.d.ts +13 -3
  432. package/dist/core/session-manager-types.d.ts.map +1 -1
  433. package/dist/core/session-manager-types.js.map +1 -1
  434. package/dist/core/session-manager.d.ts +1 -1
  435. package/dist/core/session-manager.d.ts.map +1 -1
  436. package/dist/core/session-manager.js.map +1 -1
  437. package/dist/core/session-startup-rollback.d.ts +5 -0
  438. package/dist/core/session-startup-rollback.d.ts.map +1 -0
  439. package/dist/core/session-startup-rollback.js +16 -0
  440. package/dist/core/session-startup-rollback.js.map +1 -0
  441. package/dist/core/settings-manager-basic-accessors.d.ts +5 -0
  442. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  443. package/dist/core/settings-manager-basic-accessors.js +35 -0
  444. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  445. package/dist/core/settings-manager-core.d.ts.map +1 -1
  446. package/dist/core/settings-manager-core.js +4 -0
  447. package/dist/core/settings-manager-core.js.map +1 -1
  448. package/dist/core/settings-manager.d.ts +1 -0
  449. package/dist/core/settings-manager.d.ts.map +1 -1
  450. package/dist/core/settings-manager.js +1 -0
  451. package/dist/core/settings-manager.js.map +1 -1
  452. package/dist/core/settings-types.d.ts +4 -0
  453. package/dist/core/settings-types.d.ts.map +1 -1
  454. package/dist/core/settings-types.js +1 -1
  455. package/dist/core/settings-types.js.map +1 -1
  456. package/dist/core/settings-write-ownership.d.ts +7 -0
  457. package/dist/core/settings-write-ownership.d.ts.map +1 -0
  458. package/dist/core/settings-write-ownership.js +24 -0
  459. package/dist/core/settings-write-ownership.js.map +1 -0
  460. package/dist/core/slash-commands.js +1 -1
  461. package/dist/core/slash-commands.js.map +1 -1
  462. package/dist/core/structured-output/index.d.ts +12 -0
  463. package/dist/core/structured-output/index.d.ts.map +1 -0
  464. package/dist/core/structured-output/index.js +251 -0
  465. package/dist/core/structured-output/index.js.map +1 -0
  466. package/dist/core/structured-output/invalid-output.d.ts +8 -0
  467. package/dist/core/structured-output/invalid-output.d.ts.map +1 -0
  468. package/dist/core/structured-output/invalid-output.js +4 -0
  469. package/dist/core/structured-output/invalid-output.js.map +1 -0
  470. package/dist/core/structured-output/jev-client.d.ts +20 -0
  471. package/dist/core/structured-output/jev-client.d.ts.map +1 -0
  472. package/dist/core/structured-output/jev-client.js +116 -0
  473. package/dist/core/structured-output/jev-client.js.map +1 -0
  474. package/dist/core/structured-output/jev.d.ts +5 -0
  475. package/dist/core/structured-output/jev.d.ts.map +1 -0
  476. package/dist/core/structured-output/jev.js +275 -0
  477. package/dist/core/structured-output/jev.js.map +1 -0
  478. package/dist/core/structured-output/resolver.d.ts +41 -0
  479. package/dist/core/structured-output/resolver.d.ts.map +1 -0
  480. package/dist/core/structured-output/resolver.js +56 -0
  481. package/dist/core/structured-output/resolver.js.map +1 -0
  482. package/dist/core/structured-output/types.d.ts +68 -0
  483. package/dist/core/structured-output/types.d.ts.map +1 -0
  484. package/dist/core/structured-output/types.js +2 -0
  485. package/dist/core/structured-output/types.js.map +1 -0
  486. package/dist/core/system-prompt.d.ts +48 -5
  487. package/dist/core/system-prompt.d.ts.map +1 -1
  488. package/dist/core/system-prompt.js +130 -99
  489. package/dist/core/system-prompt.js.map +1 -1
  490. package/dist/core/tasks/contracts.d.ts +6 -0
  491. package/dist/core/tasks/contracts.d.ts.map +1 -1
  492. package/dist/core/tasks/contracts.js.map +1 -1
  493. package/dist/core/tasks/supervisor.d.ts.map +1 -1
  494. package/dist/core/tasks/supervisor.js +7 -0
  495. package/dist/core/tasks/supervisor.js.map +1 -1
  496. package/dist/core/tools/ask-user-question/ask-user-question.d.ts +4 -1
  497. package/dist/core/tools/ask-user-question/ask-user-question.d.ts.map +1 -1
  498. package/dist/core/tools/ask-user-question/ask-user-question.js +31 -35
  499. package/dist/core/tools/ask-user-question/ask-user-question.js.map +1 -1
  500. package/dist/core/tools/ask-user-question/index.d.ts +1 -1
  501. package/dist/core/tools/ask-user-question/index.js.map +1 -1
  502. package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts +1 -1
  503. package/dist/core/tools/ask-user-question/state/build-questionnaire.js.map +1 -1
  504. package/dist/core/tools/ask-user-question/state/key-router.d.ts +1 -1
  505. package/dist/core/tools/ask-user-question/state/key-router.js.map +1 -1
  506. package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts +1 -1
  507. package/dist/core/tools/ask-user-question/state/questionnaire-session.js.map +1 -1
  508. package/dist/core/tools/ask-user-question/state/row-intent.d.ts +1 -1
  509. package/dist/core/tools/ask-user-question/state/row-intent.js.map +1 -1
  510. package/dist/core/tools/ask-user-question/state/selectors/contract.d.ts +1 -1
  511. package/dist/core/tools/ask-user-question/state/selectors/contract.js.map +1 -1
  512. package/dist/core/tools/ask-user-question/state/selectors/derivations.d.ts +1 -1
  513. package/dist/core/tools/ask-user-question/state/selectors/derivations.js.map +1 -1
  514. package/dist/core/tools/ask-user-question/state/state-reducer.d.ts +1 -1
  515. package/dist/core/tools/ask-user-question/state/state-reducer.js.map +1 -1
  516. package/dist/core/tools/ask-user-question/state/state.d.ts +1 -1
  517. package/dist/core/tools/ask-user-question/state/state.js.map +1 -1
  518. package/dist/core/tools/ask-user-question/tool/format-answer.d.ts +1 -1
  519. package/dist/core/tools/ask-user-question/tool/format-answer.js.map +1 -1
  520. package/dist/core/tools/ask-user-question/tool/response-envelope.d.ts +1 -1
  521. package/dist/core/tools/ask-user-question/tool/response-envelope.js.map +1 -1
  522. package/dist/core/tools/ask-user-question/tool/validate-questionnaire.d.ts +1 -1
  523. package/dist/core/tools/ask-user-question/tool/validate-questionnaire.js.map +1 -1
  524. package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts +1 -1
  525. package/dist/core/tools/ask-user-question/view/components/multi-select-view.js.map +1 -1
  526. package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.d.ts +1 -1
  527. package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.js.map +1 -1
  528. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts +1 -1
  529. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js.map +1 -1
  530. package/dist/core/tools/ask-user-question/view/components/preview/preview-layout-decider.d.ts +1 -1
  531. package/dist/core/tools/ask-user-question/view/components/preview/preview-layout-decider.js.map +1 -1
  532. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts +1 -1
  533. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js.map +1 -1
  534. package/dist/core/tools/ask-user-question/view/components/submit-picker.js.map +1 -1
  535. package/dist/core/tools/ask-user-question/view/components/wrapping-select.js.map +1 -1
  536. package/dist/core/tools/ask-user-question/view/dialog-builder.d.ts +1 -1
  537. package/dist/core/tools/ask-user-question/view/dialog-builder.js.map +1 -1
  538. package/dist/core/tools/ask-user-question/view/props-adapter.d.ts +1 -1
  539. package/dist/core/tools/ask-user-question/view/props-adapter.js.map +1 -1
  540. package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts +1 -1
  541. package/dist/core/tools/ask-user-question/view/tab-content-strategy.js.map +1 -1
  542. package/dist/core/tools/bash.d.ts.map +1 -1
  543. package/dist/core/tools/bash.js +16 -11
  544. package/dist/core/tools/bash.js.map +1 -1
  545. package/dist/core/tools/find.d.ts +2 -2
  546. package/dist/core/tools/find.d.ts.map +1 -1
  547. package/dist/core/tools/find.js +1 -1
  548. package/dist/core/tools/find.js.map +1 -1
  549. package/dist/core/usage-totals.d.ts.map +1 -1
  550. package/dist/core/usage-totals.js +4 -0
  551. package/dist/core/usage-totals.js.map +1 -1
  552. package/dist/extensions/herdr/index.d.ts.map +1 -1
  553. package/dist/extensions/herdr/index.js +0 -7
  554. package/dist/extensions/herdr/index.js.map +1 -1
  555. package/dist/extensions/llama/client.d.ts +2 -0
  556. package/dist/extensions/llama/client.d.ts.map +1 -1
  557. package/dist/extensions/llama/client.js +6 -2
  558. package/dist/extensions/llama/client.js.map +1 -1
  559. package/dist/extensions/llama/provider.d.ts.map +1 -1
  560. package/dist/extensions/llama/provider.js +18 -4
  561. package/dist/extensions/llama/provider.js.map +1 -1
  562. package/dist/index.d.ts +10 -1
  563. package/dist/index.d.ts.map +1 -1
  564. package/dist/index.js +5 -0
  565. package/dist/index.js.map +1 -1
  566. package/dist/main-session.d.ts.map +1 -1
  567. package/dist/main-session.js +19 -10
  568. package/dist/main-session.js.map +1 -1
  569. package/dist/main.d.ts.map +1 -1
  570. package/dist/main.js +4 -5
  571. package/dist/main.js.map +1 -1
  572. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  573. package/dist/modes/interactive/components/branch-summary-message.js +12 -5
  574. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  575. package/dist/modes/interactive/components/chat-message-renderer.d.ts +5 -1
  576. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  577. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  578. package/dist/modes/interactive/components/chat-session-host-events.d.ts +2 -2
  579. package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
  580. package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
  581. package/dist/modes/interactive/components/compaction-boundary-message.js +17 -9
  582. package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
  583. package/dist/modes/interactive/components/custom-editor.d.ts +6 -0
  584. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  585. package/dist/modes/interactive/components/custom-editor.js +17 -0
  586. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  587. package/dist/modes/interactive/components/host-input-form-mount.d.ts +1 -1
  588. package/dist/modes/interactive/components/host-input-form-mount.js.map +1 -1
  589. package/dist/modes/interactive/components/host-input-form.d.ts +1 -1
  590. package/dist/modes/interactive/components/host-input-form.js.map +1 -1
  591. package/dist/modes/interactive/components/host-session-picker.d.ts +1 -1
  592. package/dist/modes/interactive/components/host-session-picker.js.map +1 -1
  593. package/dist/modes/interactive/components/reserved-bottom-overlay.d.ts +1 -1
  594. package/dist/modes/interactive/components/reserved-bottom-overlay.js.map +1 -1
  595. package/dist/modes/interactive/components/scroll-widget.d.ts +1 -1
  596. package/dist/modes/interactive/components/scroll-widget.js.map +1 -1
  597. package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -1
  598. package/dist/modes/interactive/components/settings-selector-handlers.js +3 -0
  599. package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -1
  600. package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
  601. package/dist/modes/interactive/components/settings-selector-items.js +50 -1
  602. package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
  603. package/dist/modes/interactive/components/settings-selector-submenus.d.ts.map +1 -1
  604. package/dist/modes/interactive/components/settings-selector-submenus.js +2 -1
  605. package/dist/modes/interactive/components/settings-selector-submenus.js.map +1 -1
  606. package/dist/modes/interactive/components/settings-selector-types.d.ts +6 -1
  607. package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
  608. package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
  609. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  610. package/dist/modes/interactive/components/skill-invocation-message.js +11 -4
  611. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  612. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  613. package/dist/modes/interactive/components/tool-execution.js +14 -9
  614. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  615. package/dist/modes/interactive/interactive-auth-login.js +1 -1
  616. package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
  617. package/dist/modes/interactive/interactive-auth-routing.js +2 -2
  618. package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
  619. package/dist/modes/interactive/interactive-autocomplete.js +4 -0
  620. package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
  621. package/dist/modes/interactive/interactive-bash-compact.d.ts.map +1 -1
  622. package/dist/modes/interactive/interactive-bash-compact.js +13 -6
  623. package/dist/modes/interactive/interactive-bash-compact.js.map +1 -1
  624. package/dist/modes/interactive/interactive-extension-runtime.js +5 -0
  625. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  626. package/dist/modes/interactive/interactive-input-handling.js +2 -2
  627. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  628. package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
  629. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  630. package/dist/modes/interactive/interactive-mode-deps.js +1 -1
  631. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  632. package/dist/modes/interactive/interactive-mode-surface.d.ts +1 -1
  633. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  634. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  635. package/dist/modes/interactive/interactive-render-chat.js +27 -25
  636. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  637. package/dist/modes/interactive/interactive-selectors.js +10 -0
  638. package/dist/modes/interactive/interactive-selectors.js.map +1 -1
  639. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  640. package/dist/modes/interactive/interactive-startup.js +2 -2
  641. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  642. package/dist/modes/interactive/interactive-tui.js.map +1 -1
  643. package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
  644. package/dist/modes/interactive-engine/engine-custom-ui.js +3 -1
  645. package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
  646. package/dist/modes/interactive-engine/engine-input-form.d.ts +1 -1
  647. package/dist/modes/interactive-engine/engine-input-form.js.map +1 -1
  648. package/dist/modes/interactive-engine/engine-session-picker.d.ts +1 -1
  649. package/dist/modes/interactive-engine/engine-session-picker.js.map +1 -1
  650. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  651. package/dist/modes/interactive-engine/isolated-runtime.js +10 -1
  652. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  653. package/dist/modes/interactive-engine/protocol.d.ts +1 -1
  654. package/dist/modes/interactive-engine/protocol.js.map +1 -1
  655. package/dist/modes/interactive-engine/remote-component.js.map +1 -1
  656. package/dist/modes/rpc/rpc-keybindings-reload.d.ts +1 -1
  657. package/dist/modes/rpc/rpc-keybindings-reload.js.map +1 -1
  658. package/dist/modes/rpc/rpc-provider-auth.d.ts +1 -1
  659. package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
  660. package/dist/session-id-target.d.ts +31 -0
  661. package/dist/session-id-target.d.ts.map +1 -0
  662. package/dist/session-id-target.js +57 -0
  663. package/dist/session-id-target.js.map +1 -0
  664. package/dist/utils/abort.d.ts.map +1 -1
  665. package/dist/utils/abort.js +29 -4
  666. package/dist/utils/abort.js.map +1 -1
  667. package/dist/utils/clipboard-image.d.ts.map +1 -1
  668. package/dist/utils/clipboard-image.js +1 -12
  669. package/dist/utils/clipboard-image.js.map +1 -1
  670. package/dist/utils/clipboard.d.ts.map +1 -1
  671. package/dist/utils/clipboard.js +87 -23
  672. package/dist/utils/clipboard.js.map +1 -1
  673. package/dist/utils/wsl.d.ts +3 -0
  674. package/dist/utils/wsl.d.ts.map +1 -0
  675. package/dist/utils/wsl.js +15 -0
  676. package/dist/utils/wsl.js.map +1 -0
  677. package/docs/background-tasks.md +24 -14
  678. package/docs/build.md +6 -16
  679. package/docs/compaction/reference.md +10 -12
  680. package/docs/compaction.md +30 -112
  681. package/docs/computer-use.md +1 -3
  682. package/docs/containerization.md +4 -5
  683. package/docs/custom-provider/api-reference.md +10 -1
  684. package/docs/custom-provider/oauth.md +4 -2
  685. package/docs/custom-provider/streaming.md +8 -3
  686. package/docs/custom-provider.md +1 -1
  687. package/docs/development.md +13 -138
  688. package/docs/docs.json +19 -5
  689. package/docs/environment-variables.md +20 -4
  690. package/docs/extensions/api-reference.md +6 -2
  691. package/docs/extensions/authoring.md +10 -7
  692. package/docs/extensions/events.md +14 -24
  693. package/docs/extensions/ui.md +3 -4
  694. package/docs/extensions.md +22 -18
  695. package/docs/getting-started/authentication.md +4 -1
  696. package/docs/getting-started/first-session.md +8 -6
  697. package/docs/getting-started/installation.md +8 -4
  698. package/docs/getting-started/project-instructions.md +5 -1
  699. package/docs/guides/configuration.md +10 -5
  700. package/docs/guides/non-interactive.md +2 -2
  701. package/docs/guides.md +8 -17
  702. package/docs/herdr.md +2 -1
  703. package/docs/index.md +2 -2
  704. package/docs/intercom/operations.md +16 -70
  705. package/docs/intercom/reference.md +15 -5
  706. package/docs/intercom.md +10 -6
  707. package/docs/json.md +12 -2
  708. package/docs/keybindings.md +13 -8
  709. package/docs/llama-cpp.md +5 -1
  710. package/docs/{mcp.md → mcp-servers.md} +21 -2
  711. package/docs/models/evals.md +133 -465
  712. package/docs/models/model-selection.md +27 -116
  713. package/docs/models/reference.md +18 -21
  714. package/docs/models.md +7 -4
  715. package/docs/packages/authoring.md +5 -1
  716. package/docs/packages/reference.md +5 -1
  717. package/docs/packages.md +5 -3
  718. package/docs/programmatic.md +3 -1
  719. package/docs/prompt-templates.md +2 -10
  720. package/docs/providers/reference.md +2 -2
  721. package/docs/providers.md +41 -16
  722. package/docs/quickstart.md +7 -3
  723. package/docs/reference/cli.md +19 -11
  724. package/docs/reference.md +3 -6
  725. package/docs/rpc/protocol.md +11 -13
  726. package/docs/rpc.md +5 -1
  727. package/docs/sdk/reference.md +59 -239
  728. package/docs/sdk/structured-decisions.md +132 -0
  729. package/docs/sdk.md +181 -17
  730. package/docs/security.md +7 -4
  731. package/docs/session-format.md +18 -5
  732. package/docs/sessions.md +12 -6
  733. package/docs/settings.md +68 -16
  734. package/docs/skills/authoring.md +7 -1
  735. package/docs/skills.md +25 -6
  736. package/docs/subagents/authoring.md +11 -1
  737. package/docs/subagents/reference.md +98 -10
  738. package/docs/subagents.md +45 -35
  739. package/docs/terminal-setup.md +4 -2
  740. package/docs/termux.md +3 -1
  741. package/docs/themes/reference.md +4 -1
  742. package/docs/themes.md +1 -1
  743. package/docs/tools.md +431 -20
  744. package/docs/tui/reference.md +13 -14
  745. package/docs/tui.md +10 -6
  746. package/docs/usage.md +19 -7
  747. package/docs/web-access.md +5 -1
  748. package/docs/windows.md +18 -11
  749. package/docs/workflows/api-reference.md +135 -25
  750. package/docs/workflows/authoring.md +48 -39
  751. package/docs/workflows/builtins.md +20 -26
  752. package/docs/workflows/operations.md +284 -137
  753. package/docs/workflows/reliable-design.md +62 -129
  754. package/docs/workflows.md +10 -16
  755. package/examples/extensions/custom-provider-anthropic/index.ts +15 -10
  756. package/examples/extensions/custom-provider-gitlab-duo/index.ts +2 -2
  757. package/examples/extensions/prompt-customizer.ts +17 -37
  758. package/npm-shrinkwrap.json +502 -709
  759. package/package.json +12 -10
  760. package/dist/builtin/workflows/builtin/chunk-m0xfsef8.js +0 -2813
  761. package/docs/models/artificial-analysis-index.md +0 -89
  762. package/docs/models/pareto-efficiency.md +0 -90
  763. package/docs/tools/edit.md +0 -378
@@ -1 +1 @@
1
- {"version":3,"file":"derivations.js","sourceRoot":"","sources":["../../../../../../src/core/tools/ask-user-question/state/selectors/derivations.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAC7C,SAAkC,EAClC,UAAkB,EAClB,WAAmB;IAEnB,MAAM,CAAC,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;IAChC,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,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U,EAAE,aAAa,EAAE,KAAK,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;IACjE,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAClF,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,KAAK,QAAQ,IAAI,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,MAAM,CAAC,CAAC;IACzF,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IAChC,OAAO,EAAE,KAAK,EAAE,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAAC,UAAkB,EAAE,cAAsB;IACtF,IAAI,cAAc,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,cAAc,GAAG,CAAC,CAAC,CAAC;AACjD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CACnC,UAAwD,EACxD,UAAkB,EAClB,cAAsB;IAEtB,MAAM,GAAG,GAAG,4BAA4B,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IACrE,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["import type { QuestionAnswer, QuestionData } from \"../../tool/types.ts\";\nimport type { WrappingSelectItem } from \"../../view/components/wrapping-select.ts\";\nimport { ROW_INTENT_META } from \"../row-intent.ts\";\n\n/**\n * Pure derivation: does the option focused by `(currentTab, optionIndex)` carry a\n * non-empty `preview` string? Mode gates (chat focus, notes mode, multiSelect) layer\n * on top via dispatch branches; this predicate is intentionally mode-agnostic.\n */\nexport function computeFocusedOptionHasPreview(\n\tquestions: readonly QuestionData[],\n\tcurrentTab: number,\n\toptionIndex: number,\n): boolean {\n\tconst q = questions[currentTab];\n\tif (!q) return false;\n\tconst opt = q.options[optionIndex];\n\treturn !!opt && typeof opt.preview === \"string\" && opt.preview.length > 0;\n}\n\n/**\n * Numbering for the chat row's WrappingSelect, computed from the active tab's items.\n *\n * The chat row lives in its own one-item WrappingSelect; the host calls this on every tab\n * switch / selection update to keep the chat row's `N. ` label continuous with the visible\n * numbered rows of the active tab. The shape `{ offset, total }` mirrors\n * `WrappingSelect.setNumbering(numberStartOffset, totalItemsForNumbering)` directly.\n */\nexport function chatNumberingFor(items: readonly WrappingSelectItem[]): {\n\toffset: number;\n\ttotal: number;\n} {\n\t// Count only the visible-numbered rows. The Next sentinel renders without a number\n\t// (see MultiSelectView), so it must NOT advance the chat row's number — otherwise\n\t// chat reads as \"6.\" next to options labeled 1-4. Sourced from `ROW_INTENT_META[kind].numbered`\n\t// so adding a new non-numbered kind is a single META edit.\n\tconst count = items.filter((i) => ROW_INTENT_META[i.kind].numbered).length;\n\treturn { offset: count, total: count + 1 };\n}\n\n/**\n * Which row in the active tab should be marked as \"previously confirmed\"? Drives the\n * `WrappingSelect` confirmed-row indicator (label + ` ✔`) when the user navigates back\n * to a question they already answered. Returns `undefined` when no marker should be drawn —\n * multi-select handles its own `[✔]` boxes via `multiSelectChecked`, `kind: \"chat\"` ends the\n * dialog so the row can never be re-entered, and a missing/non-matching answer (defensive)\n * silently skips the marker.\n */\nexport function selectConfirmedIndicator(\n\tquestions: readonly QuestionData[],\n\tcurrentTab: number,\n\tanswers: ReadonlyMap<number, QuestionAnswer>,\n\titems: readonly WrappingSelectItem[],\n): { index: number; labelOverride?: string } | undefined {\n\tconst q = questions[currentTab];\n\tif (!q || q.multiSelect === true) return undefined;\n\tconst prior = answers.get(currentTab);\n\tif (!prior || prior.kind === \"chat\") return undefined;\n\tif (prior.kind === \"custom\") {\n\t\tconst otherIndex = items.findIndex((it) => it.kind === \"other\");\n\t\tif (otherIndex < 0) return undefined;\n\t\treturn { index: otherIndex, labelOverride: prior.answer ?? \"\" };\n\t}\n\tif (prior.kind !== \"option\" || typeof prior.answer !== \"string\") return undefined;\n\tconst index = items.findIndex((it) => it.kind === \"option\" && it.label === prior.answer);\n\tif (index < 0) return undefined;\n\treturn { index };\n}\n\n/**\n * Index of the preview pane to display for the current tab. The Submit tab (currentTab ===\n * questions.length) reuses the last question's pane purely for layout — the strategy\n * machinery picks the right body component independently. Defensive against `totalQuestions === 0`.\n */\nexport function selectActivePreviewPaneIndex(currentTab: number, totalQuestions: number): number {\n\tif (totalQuestions <= 0) return 0;\n\treturn Math.min(currentTab, totalQuestions - 1);\n}\n\n/**\n * Items array for the active tab, with the same Submit-tab clamp as `selectActivePreviewPaneIndex`.\n * Falls back to an empty array if the index lands outside the items array (defensive).\n */\nexport function selectActiveTabItems(\n\titemsByTab: ReadonlyArray<readonly WrappingSelectItem[]>,\n\tcurrentTab: number,\n\ttotalQuestions: number,\n): readonly WrappingSelectItem[] {\n\tconst idx = selectActivePreviewPaneIndex(currentTab, totalQuestions);\n\treturn itemsByTab[idx] ?? [];\n}\n"]}
1
+ {"version":3,"file":"derivations.js","sourceRoot":"","sources":["../../../../../../src/core/tools/ask-user-question/state/selectors/derivations.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAC7C,SAAkC,EAClC,UAAkB,EAClB,WAAmB;IAEnB,MAAM,CAAC,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;IAChC,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IACrB,MAAM,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACnC,OAAO,CAAC,CAAC,GAAG,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;AAC3E,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAA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C,EAAE,CAAC,IAAI,KAAK,QAAQ,IAAI,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,MAAM,CAAC,CAAC;IACzF,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IAChC,OAAO,EAAE,KAAK,EAAE,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAAC,UAAkB,EAAE,cAAsB;IACtF,IAAI,cAAc,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,cAAc,GAAG,CAAC,CAAC,CAAC;AACjD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CACnC,UAAwD,EACxD,UAAkB,EAClB,cAAsB;IAEtB,MAAM,GAAG,GAAG,4BAA4B,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IACrE,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["import type { QuestionAnswer, QuestionData } from \"../../tool/types.js\";\nimport type { WrappingSelectItem } from \"../../view/components/wrapping-select.ts\";\nimport { ROW_INTENT_META } from \"../row-intent.ts\";\n\n/**\n * Pure derivation: does the option focused by `(currentTab, optionIndex)` carry a\n * non-empty `preview` string? Mode gates (chat focus, notes mode, multiSelect) layer\n * on top via dispatch branches; this predicate is intentionally mode-agnostic.\n */\nexport function computeFocusedOptionHasPreview(\n\tquestions: readonly QuestionData[],\n\tcurrentTab: number,\n\toptionIndex: number,\n): boolean {\n\tconst q = questions[currentTab];\n\tif (!q) return false;\n\tconst opt = q.options[optionIndex];\n\treturn !!opt && typeof opt.preview === \"string\" && opt.preview.length > 0;\n}\n\n/**\n * Numbering for the chat row's WrappingSelect, computed from the active tab's items.\n *\n * The chat row lives in its own one-item WrappingSelect; the host calls this on every tab\n * switch / selection update to keep the chat row's `N. ` label continuous with the visible\n * numbered rows of the active tab. The shape `{ offset, total }` mirrors\n * `WrappingSelect.setNumbering(numberStartOffset, totalItemsForNumbering)` directly.\n */\nexport function chatNumberingFor(items: readonly WrappingSelectItem[]): {\n\toffset: number;\n\ttotal: number;\n} {\n\t// Count only the visible-numbered rows. The Next sentinel renders without a number\n\t// (see MultiSelectView), so it must NOT advance the chat row's number — otherwise\n\t// chat reads as \"6.\" next to options labeled 1-4. Sourced from `ROW_INTENT_META[kind].numbered`\n\t// so adding a new non-numbered kind is a single META edit.\n\tconst count = items.filter((i) => ROW_INTENT_META[i.kind].numbered).length;\n\treturn { offset: count, total: count + 1 };\n}\n\n/**\n * Which row in the active tab should be marked as \"previously confirmed\"? Drives the\n * `WrappingSelect` confirmed-row indicator (label + ` ✔`) when the user navigates back\n * to a question they already answered. Returns `undefined` when no marker should be drawn —\n * multi-select handles its own `[✔]` boxes via `multiSelectChecked`, `kind: \"chat\"` ends the\n * dialog so the row can never be re-entered, and a missing/non-matching answer (defensive)\n * silently skips the marker.\n */\nexport function selectConfirmedIndicator(\n\tquestions: readonly QuestionData[],\n\tcurrentTab: number,\n\tanswers: ReadonlyMap<number, QuestionAnswer>,\n\titems: readonly WrappingSelectItem[],\n): { index: number; labelOverride?: string } | undefined {\n\tconst q = questions[currentTab];\n\tif (!q || q.multiSelect === true) return undefined;\n\tconst prior = answers.get(currentTab);\n\tif (!prior || prior.kind === \"chat\") return undefined;\n\tif (prior.kind === \"custom\") {\n\t\tconst otherIndex = items.findIndex((it) => it.kind === \"other\");\n\t\tif (otherIndex < 0) return undefined;\n\t\treturn { index: otherIndex, labelOverride: prior.answer ?? \"\" };\n\t}\n\tif (prior.kind !== \"option\" || typeof prior.answer !== \"string\") return undefined;\n\tconst index = items.findIndex((it) => it.kind === \"option\" && it.label === prior.answer);\n\tif (index < 0) return undefined;\n\treturn { index };\n}\n\n/**\n * Index of the preview pane to display for the current tab. The Submit tab (currentTab ===\n * questions.length) reuses the last question's pane purely for layout — the strategy\n * machinery picks the right body component independently. Defensive against `totalQuestions === 0`.\n */\nexport function selectActivePreviewPaneIndex(currentTab: number, totalQuestions: number): number {\n\tif (totalQuestions <= 0) return 0;\n\treturn Math.min(currentTab, totalQuestions - 1);\n}\n\n/**\n * Items array for the active tab, with the same Submit-tab clamp as `selectActivePreviewPaneIndex`.\n * Falls back to an empty array if the index lands outside the items array (defensive).\n */\nexport function selectActiveTabItems(\n\titemsByTab: ReadonlyArray<readonly WrappingSelectItem[]>,\n\tcurrentTab: number,\n\ttotalQuestions: number,\n): readonly WrappingSelectItem[] {\n\tconst idx = selectActivePreviewPaneIndex(currentTab, totalQuestions);\n\treturn itemsByTab[idx] ?? [];\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { QuestionData, QuestionnaireResult } from "../tool/types.ts";
1
+ import type { QuestionData, QuestionnaireResult } from "../tool/types.js";
2
2
  import type { WrappingSelectItem } from "../view/components/wrapping-select.ts";
3
3
  import type { QuestionnaireAction } from "./key-router.ts";
4
4
  import type { QuestionnaireState } from "./state.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"state-reducer.js","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/state/state-reducer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE9F,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AA4B5E,SAAS,cAAc,CAAC,KAAyB,EAAE,SAAkC;IACpF,MAAM,GAAG,GAAqB,EAAE,CAAC;IACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC/B,IAAI,CAAC;YAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAC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AAE,iBAAiB;IAC9B,UAAU,EAAE,gBAAgB;IAC5B,aAAa,EAAE,mBAAmB;IAClC,MAAM,EAAE,aAAa;IACrB,UAAU,EAAE,gBAAgB;IAC5B,UAAU,EAAE,gBAAgB;IAC5B,aAAa,EAAE,mBAAmB;IAClC,MAAM,EAAE,aAAa;CACrB,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAC,KAAyB,EAAE,MAA2B,EAAE,GAAiB;IAC/F,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAgC,CAAC;IACrE,OAAO,OAAO,CAAC,KAAK,EAAE,MAAe,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import type { QuestionAnswer, QuestionData, QuestionnaireResult } from \"../tool/types.ts\";\nimport type { WrappingSelectItem } from \"../view/components/wrapping-select.ts\";\nimport { readInlineCaret, resolveInlineDraftValue, withInlineDraft } from \"./inline-input.ts\";\nimport type { QuestionnaireAction } from \"./key-router.ts\";\nimport { ROW_INTENT_META } from \"./row-intent.ts\";\nimport { computeFocusedOptionHasPreview } from \"./selectors/derivations.ts\";\nimport type { InlineInputOwner, QuestionnaireState } from \"./state.ts\";\n\n/** Session-lifetime constants. No live-component reads — peripheral values live on canonical state. */\nexport interface ApplyContext {\n\tquestions: readonly QuestionData[];\n\titemsByTab: ReadonlyArray<readonly WrappingSelectItem[]>;\n\tchatAsOption?: boolean;\n}\n\n/**\n * Declarative side-effects emitted by `reduce`. The runtime executes them after\n * committing the new state, then asks the props-adapter to re-project. Closed set —\n * adding an effect requires updating both the union AND the runtime's `runEffect` switch\n * (compiler-enforced exhaustive). No string-keyed escape hatch.\n */\nexport type Effect =\n\t| { kind: \"set_input_buffer\"; value: string; caret: number }\n\t| { kind: \"set_notes_value\"; value: string }\n\t| { kind: \"set_notes_focused\"; focused: boolean }\n\t| { kind: \"forward_notes_keystroke\"; data: string }\n\t| { kind: \"done\"; result: QuestionnaireResult };\n\nexport interface ApplyResult {\n\tstate: QuestionnaireState;\n\teffects: readonly Effect[];\n}\n\nfunction orderedAnswers(state: QuestionnaireState, questions: readonly QuestionData[]): QuestionAnswer[] {\n\tconst out: QuestionAnswer[] = [];\n\tfor (let i = 0; i < questions.length; i++) {\n\t\tconst a = state.answers.get(i);\n\t\tif (a) out.push(a);\n\t}\n\treturn out;\n}\n\nfunction withFocusedOptionHasPreview(\n\tstate: QuestionnaireState,\n\tquestions: readonly QuestionData[],\n): QuestionnaireState {\n\tconst focusedOptionHasPreview = computeFocusedOptionHasPreview(questions, state.currentTab, state.optionIndex);\n\tif (state.focusedOptionHasPreview === focusedOptionHasPreview) return state;\n\treturn { ...state, focusedOptionHasPreview };\n}\n\nfunction syncMultiSelectFromAnswers(\n\tanswers: ReadonlyMap<number, QuestionAnswer>,\n\tquestions: readonly QuestionData[],\n\ttab: number,\n): ReadonlySet<number> {\n\tconst q = questions[tab];\n\tif (!q?.multiSelect) return new Set();\n\tconst saved = answers.get(tab);\n\tconst labels = saved?.selected ?? [];\n\tconst indices = new Set<number>();\n\tfor (let i = 0; i < q.options.length; i++) {\n\t\tif (labels.includes(q.options[i]!.label)) indices.add(i);\n\t}\n\treturn indices;\n}\n\nfunction persistMultiSelectAnswer(state: QuestionnaireState, ctx: ApplyContext): ReadonlyMap<number, QuestionAnswer> {\n\tconst q = ctx.questions[state.currentTab];\n\tif (!q?.multiSelect) return state.answers;\n\tconst selected: string[] = [];\n\tfor (let i = 0; i < q.options.length; i++) {\n\t\tif (state.multiSelectChecked.has(i)) selected.push(q.options[i]!.label);\n\t}\n\tconst out = new Map(state.answers);\n\tif (selected.length === 0) {\n\t\tout.delete(state.currentTab);\n\t\treturn out;\n\t}\n\tconst pendingNotes = state.notesByTab.get(state.currentTab);\n\tout.set(state.currentTab, {\n\t\tquestionIndex: state.currentTab,\n\t\tquestion: q.question,\n\t\tkind: \"multi\",\n\t\tanswer: null,\n\t\tselected,\n\t\t...(pendingNotes && pendingNotes.length > 0 ? { notes: pendingNotes } : {}),\n\t});\n\treturn out;\n}\n\nfunction clampCaret(value: string, caret: number | undefined): number {\n\tif (caret === undefined || !Number.isFinite(caret)) return value.length;\n\treturn Math.max(0, Math.min(caret, value.length));\n}\n\nfunction inlineOwnerForItem(item: WrappingSelectItem | undefined): InlineInputOwner | null {\n\tif (!item || !ROW_INTENT_META[item.kind].activatesInputMode) return null;\n\tswitch (item.kind) {\n\t\tcase \"other\":\n\t\tcase \"chat\":\n\t\t\treturn item.kind;\n\t\tcase \"option\":\n\t\tcase \"next\":\n\t\t\treturn null;\n\t}\n}\n\nfunction hydrateInlineInputResult(state: QuestionnaireState, owner: InlineInputOwner): ApplyResult {\n\tconst value = resolveInlineDraftValue(state, owner);\n\tconst caret = clampCaret(value, readInlineCaret(state, owner));\n\treturn {\n\t\tstate: withInlineDraft({ ...state, inputMode: true, inlineInputOwner: owner }, owner, value, caret),\n\t\teffects: [{ kind: \"set_input_buffer\", value, caret }],\n\t};\n}\n\nfunction switchTabResult(state: QuestionnaireState, nextTab: number, ctx: ApplyContext): ApplyResult {\n\tconst notesValue = state.notesByTab.get(nextTab) ?? state.answers.get(nextTab)?.notes ?? \"\";\n\tconst transitioned: QuestionnaireState = {\n\t\t...state,\n\t\tcurrentTab: nextTab,\n\t\toptionIndex: 0,\n\t\tinputMode: false,\n\t\tinlineInputOwner: null,\n\t\tnotesVisible: false,\n\t\tchatFocused: false,\n\t\tsubmitChoiceIndex: 0,\n\t\tmultiSelectChecked: syncMultiSelectFromAnswers(state.answers, ctx.questions, nextTab),\n\t\tnotesDraft: notesValue,\n\t};\n\tconst finalState = withFocusedOptionHasPreview(transitioned, ctx.questions);\n\treturn {\n\t\tstate: finalState,\n\t\teffects: [\n\t\t\t{ kind: \"set_notes_focused\", focused: false },\n\t\t\t{ kind: \"set_notes_value\", value: notesValue },\n\t\t],\n\t};\n}\n\nfunction doneFor(state: QuestionnaireState, ctx: ApplyContext, cancelled: boolean): ApplyResult {\n\tconst result: QuestionnaireResult = { answers: orderedAnswers(state, ctx.questions), cancelled };\n\treturn { state, effects: [{ kind: \"done\", result }] };\n}\n\n/**\n * Per-kind handler signature: action payload narrows to the matching union member\n * via `Extract`, so handlers consume fully-typed actions without `as` casts.\n */\ntype Handler<K extends QuestionnaireAction[\"kind\"]> = (\n\tstate: QuestionnaireState,\n\taction: Extract<QuestionnaireAction, { kind: K }>,\n\tctx: ApplyContext,\n) => ApplyResult;\n\nconst navHandler: Handler<\"nav\"> = (state, action, ctx) => {\n\tconst items = ctx.itemsByTab[state.currentTab] ?? [];\n\tconst item = items[action.nextIndex];\n\tconst owner = inlineOwnerForItem(item);\n\tconst next = withFocusedOptionHasPreview(\n\t\t{\n\t\t\t...state,\n\t\t\tchatFocused: false,\n\t\t\toptionIndex: action.nextIndex,\n\t\t\tinputMode: owner !== null,\n\t\t\tinlineInputOwner: owner,\n\t\t},\n\t\tctx.questions,\n\t);\n\treturn owner ? hydrateInlineInputResult(next, owner) : { state: next, effects: [] };\n};\n\nconst tabSwitchHandler: Handler<\"tab_switch\"> = (state, action, ctx) => switchTabResult(state, action.nextTab, ctx);\n\nconst confirmHandler: Handler<\"confirm\"> = (state, action, ctx) => {\n\tlet answer = action.answer;\n\tif (answer.kind === \"option\" && answer.answer) {\n\t\tconst q = ctx.questions[answer.questionIndex];\n\t\tconst matched = q?.options.find((o) => o.label === answer.answer);\n\t\tif (matched?.preview && matched.preview.length > 0) {\n\t\t\tanswer = { ...answer, preview: matched.preview };\n\t\t}\n\t}\n\tconst pendingNotes = state.notesByTab.get(answer.questionIndex);\n\tif (pendingNotes && pendingNotes.length > 0) {\n\t\tanswer = { ...answer, notes: pendingNotes };\n\t}\n\tconst answers = new Map(state.answers);\n\tanswers.set(answer.questionIndex, answer);\n\tconst next: QuestionnaireState = { ...state, answers };\n\tif (answer.kind === \"chat\") return doneFor(next, ctx, false);\n\tif (action.autoAdvanceTab !== undefined) return switchTabResult(next, action.autoAdvanceTab, ctx);\n\treturn doneFor(next, ctx, false);\n};\n\nconst toggleHandler: Handler<\"toggle\"> = (state, action, ctx) => {\n\tconst checked = new Set(state.multiSelectChecked);\n\tif (checked.has(action.index)) checked.delete(action.index);\n\telse checked.add(action.index);\n\tconst intermediate: QuestionnaireState = { ...state, multiSelectChecked: checked };\n\tconst answers = persistMultiSelectAnswer(intermediate, ctx);\n\treturn { state: { ...intermediate, answers }, effects: [] };\n};\n\nconst multiConfirmHandler: Handler<\"multi_confirm\"> = (state, action, ctx) => {\n\tconst q = ctx.questions[state.currentTab];\n\tif (!q) return { state, effects: [] };\n\tconst pendingNotes = state.notesByTab.get(state.currentTab);\n\tconst answers = new Map(state.answers);\n\tanswers.set(state.currentTab, {\n\t\tquestionIndex: state.currentTab,\n\t\tquestion: q.question,\n\t\tkind: \"multi\",\n\t\tanswer: null,\n\t\tselected: action.selected,\n\t\t...(pendingNotes && pendingNotes.length > 0 ? { notes: pendingNotes } : {}),\n\t});\n\tconst synced: QuestionnaireState = {\n\t\t...state,\n\t\tanswers,\n\t\tmultiSelectChecked: syncMultiSelectFromAnswers(answers, ctx.questions, state.currentTab),\n\t};\n\tif (action.autoAdvanceTab !== undefined) return switchTabResult(synced, action.autoAdvanceTab, ctx);\n\treturn doneFor(synced, ctx, false);\n};\n\nconst notesEnterHandler: Handler<\"notes_enter\"> = (state, _action, _ctx) => {\n\tconst value = state.answers.get(state.currentTab)?.notes ?? \"\";\n\treturn {\n\t\tstate: { ...state, notesVisible: true, notesDraft: value },\n\t\teffects: [\n\t\t\t{ kind: \"set_notes_value\", value },\n\t\t\t{ kind: \"set_notes_focused\", focused: true },\n\t\t],\n\t};\n};\n\nconst notesExitHandler: Handler<\"notes_exit\"> = (state, _action, _ctx) => {\n\tconst trimmed = state.notesDraft.trim();\n\tconst notes = new Map(state.notesByTab);\n\tconst answers = new Map(state.answers);\n\tif (trimmed.length === 0) {\n\t\tnotes.delete(state.currentTab);\n\t\tconst prev = answers.get(state.currentTab);\n\t\tif (prev?.notes) {\n\t\t\tconst stripped = { ...prev };\n\t\t\tdelete (stripped as { notes?: string }).notes;\n\t\t\tanswers.set(state.currentTab, stripped);\n\t\t}\n\t} else {\n\t\tnotes.set(state.currentTab, trimmed);\n\t\tconst prev = answers.get(state.currentTab);\n\t\tif (prev) answers.set(state.currentTab, { ...prev, notes: trimmed });\n\t}\n\treturn {\n\t\tstate: { ...state, notesByTab: notes, answers, notesVisible: false },\n\t\teffects: [{ kind: \"set_notes_focused\", focused: false }],\n\t};\n};\n\nconst focusOptionsHandler: Handler<\"focus_options\"> = (state, action, ctx) => {\n\tconst items = ctx.itemsByTab[state.currentTab] ?? [];\n\tconst focused = items[action.optionIndex];\n\tconst owner = inlineOwnerForItem(focused);\n\tconst next = withFocusedOptionHasPreview(\n\t\t{\n\t\t\t...state,\n\t\t\tchatFocused: false,\n\t\t\toptionIndex: action.optionIndex,\n\t\t\tinputMode: owner !== null,\n\t\t\tinlineInputOwner: owner,\n\t\t},\n\t\tctx.questions,\n\t);\n\treturn owner ? hydrateInlineInputResult(next, owner) : { state: next, effects: [] };\n};\n\nconst cancelHandler: Handler<\"cancel\"> = (s, _a, c) => doneFor(s, c, true);\nconst submitHandler: Handler<\"submit\"> = (s, _a, c) => doneFor(s, c, false);\nconst submitNavHandler: Handler<\"submit_nav\"> = (s, a, _c) => ({\n\tstate: { ...s, submitChoiceIndex: a.nextIndex },\n\teffects: [],\n});\nconst focusChatHandler: Handler<\"focus_chat\"> = (s, _a, ctx) =>\n\tctx.chatAsOption === true\n\t\t? { state: { ...s, chatFocused: true, inputMode: false, inlineInputOwner: null }, effects: [] }\n\t\t: hydrateInlineInputResult({ ...s, chatFocused: true, inputMode: true, inlineInputOwner: \"chat\" }, \"chat\");\nconst notesForwardHandler: Handler<\"notes_forward\"> = (s, a, _c) => ({\n\tstate: s,\n\teffects: [{ kind: \"forward_notes_keystroke\", data: a.data }],\n});\nconst ignoreHandler: Handler<\"ignore\"> = (s, _a, _c) => ({ state: s, effects: [] });\n\n/**\n * Compile-time-exhaustive dispatch table. `{ [K in Kind]: Handler<K> }` requires\n * an entry per union member — adding a new `QuestionnaireAction` variant fails to\n * compile here until a handler is registered, mirroring the `Record<RowKind, …>`\n * pattern used by `ROW_INTENT_META`.\n */\nconst HANDLERS: { [K in QuestionnaireAction[\"kind\"]]: Handler<K> } = {\n\tnav: navHandler,\n\ttab_switch: tabSwitchHandler,\n\tconfirm: confirmHandler,\n\ttoggle: toggleHandler,\n\tmulti_confirm: multiConfirmHandler,\n\tcancel: cancelHandler,\n\tnotes_enter: notesEnterHandler,\n\tnotes_exit: notesExitHandler,\n\tnotes_forward: notesForwardHandler,\n\tsubmit: submitHandler,\n\tsubmit_nav: submitNavHandler,\n\tfocus_chat: focusChatHandler,\n\tfocus_options: focusOptionsHandler,\n\tignore: ignoreHandler,\n};\n\n/**\n * Pure reducer: (state, action, ctx) → (state, Effect[]). Mirrors `rpiv-todo`'s `applyTaskMutation`.\n * Delegates to `HANDLERS` — per-kind handlers above are pure, named, and individually testable.\n * `ignore` is also handled outside the reducer by `handleIgnoreInline` in the runtime fast path.\n */\nexport function reduce(state: QuestionnaireState, action: QuestionnaireAction, ctx: ApplyContext): ApplyResult {\n\tconst handler = HANDLERS[action.kind] as Handler<typeof action.kind>;\n\treturn handler(state, action as never, ctx);\n}\n"]}
1
+ {"version":3,"file":"state-reducer.js","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/state/state-reducer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE9F,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AA4B5E,SAAS,cAAc,CAAC,KAAyB,EAAE,SAAkC;IACpF,MAAM,GAAG,GAAqB,EAAE,CAAC;IACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAA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AAM,QAAQ,GAAuD;IACpE,GAAG,EAAE,UAAU;IACf,UAAU,EAAE,gBAAgB;IAC5B,OAAO,EAAE,cAAc;IACvB,MAAM,EAAE,aAAa;IACrB,aAAa,EAAE,mBAAmB;IAClC,MAAM,EAAE,aAAa;IACrB,WAAW,EAAE,iBAAiB;IAC9B,UAAU,EAAE,gBAAgB;IAC5B,aAAa,EAAE,mBAAmB;IAClC,MAAM,EAAE,aAAa;IACrB,UAAU,EAAE,gBAAgB;IAC5B,UAAU,EAAE,gBAAgB;IAC5B,aAAa,EAAE,mBAAmB;IAClC,MAAM,EAAE,aAAa;CACrB,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAC,KAAyB,EAAE,MAA2B,EAAE,GAAiB;IAC/F,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAgC,CAAC;IACrE,OAAO,OAAO,CAAC,KAAK,EAAE,MAAe,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import type { QuestionAnswer, QuestionData, QuestionnaireResult } from \"../tool/types.js\";\nimport type { WrappingSelectItem } from \"../view/components/wrapping-select.ts\";\nimport { readInlineCaret, resolveInlineDraftValue, withInlineDraft } from \"./inline-input.ts\";\nimport type { QuestionnaireAction } from \"./key-router.ts\";\nimport { ROW_INTENT_META } from \"./row-intent.ts\";\nimport { computeFocusedOptionHasPreview } from \"./selectors/derivations.ts\";\nimport type { InlineInputOwner, QuestionnaireState } from \"./state.ts\";\n\n/** Session-lifetime constants. No live-component reads — peripheral values live on canonical state. */\nexport interface ApplyContext {\n\tquestions: readonly QuestionData[];\n\titemsByTab: ReadonlyArray<readonly WrappingSelectItem[]>;\n\tchatAsOption?: boolean;\n}\n\n/**\n * Declarative side-effects emitted by `reduce`. The runtime executes them after\n * committing the new state, then asks the props-adapter to re-project. Closed set —\n * adding an effect requires updating both the union AND the runtime's `runEffect` switch\n * (compiler-enforced exhaustive). No string-keyed escape hatch.\n */\nexport type Effect =\n\t| { kind: \"set_input_buffer\"; value: string; caret: number }\n\t| { kind: \"set_notes_value\"; value: string }\n\t| { kind: \"set_notes_focused\"; focused: boolean }\n\t| { kind: \"forward_notes_keystroke\"; data: string }\n\t| { kind: \"done\"; result: QuestionnaireResult };\n\nexport interface ApplyResult {\n\tstate: QuestionnaireState;\n\teffects: readonly Effect[];\n}\n\nfunction orderedAnswers(state: QuestionnaireState, questions: readonly QuestionData[]): QuestionAnswer[] {\n\tconst out: QuestionAnswer[] = [];\n\tfor (let i = 0; i < questions.length; i++) {\n\t\tconst a = state.answers.get(i);\n\t\tif (a) out.push(a);\n\t}\n\treturn out;\n}\n\nfunction withFocusedOptionHasPreview(\n\tstate: QuestionnaireState,\n\tquestions: readonly QuestionData[],\n): QuestionnaireState {\n\tconst focusedOptionHasPreview = computeFocusedOptionHasPreview(questions, state.currentTab, state.optionIndex);\n\tif (state.focusedOptionHasPreview === focusedOptionHasPreview) return state;\n\treturn { ...state, focusedOptionHasPreview };\n}\n\nfunction syncMultiSelectFromAnswers(\n\tanswers: ReadonlyMap<number, QuestionAnswer>,\n\tquestions: readonly QuestionData[],\n\ttab: number,\n): ReadonlySet<number> {\n\tconst q = questions[tab];\n\tif (!q?.multiSelect) return new Set();\n\tconst saved = answers.get(tab);\n\tconst labels = saved?.selected ?? [];\n\tconst indices = new Set<number>();\n\tfor (let i = 0; i < q.options.length; i++) {\n\t\tif (labels.includes(q.options[i]!.label)) indices.add(i);\n\t}\n\treturn indices;\n}\n\nfunction persistMultiSelectAnswer(state: QuestionnaireState, ctx: ApplyContext): ReadonlyMap<number, QuestionAnswer> {\n\tconst q = ctx.questions[state.currentTab];\n\tif (!q?.multiSelect) return state.answers;\n\tconst selected: string[] = [];\n\tfor (let i = 0; i < q.options.length; i++) {\n\t\tif (state.multiSelectChecked.has(i)) selected.push(q.options[i]!.label);\n\t}\n\tconst out = new Map(state.answers);\n\tif (selected.length === 0) {\n\t\tout.delete(state.currentTab);\n\t\treturn out;\n\t}\n\tconst pendingNotes = state.notesByTab.get(state.currentTab);\n\tout.set(state.currentTab, {\n\t\tquestionIndex: state.currentTab,\n\t\tquestion: q.question,\n\t\tkind: \"multi\",\n\t\tanswer: null,\n\t\tselected,\n\t\t...(pendingNotes && pendingNotes.length > 0 ? { notes: pendingNotes } : {}),\n\t});\n\treturn out;\n}\n\nfunction clampCaret(value: string, caret: number | undefined): number {\n\tif (caret === undefined || !Number.isFinite(caret)) return value.length;\n\treturn Math.max(0, Math.min(caret, value.length));\n}\n\nfunction inlineOwnerForItem(item: WrappingSelectItem | undefined): InlineInputOwner | null {\n\tif (!item || !ROW_INTENT_META[item.kind].activatesInputMode) return null;\n\tswitch (item.kind) {\n\t\tcase \"other\":\n\t\tcase \"chat\":\n\t\t\treturn item.kind;\n\t\tcase \"option\":\n\t\tcase \"next\":\n\t\t\treturn null;\n\t}\n}\n\nfunction hydrateInlineInputResult(state: QuestionnaireState, owner: InlineInputOwner): ApplyResult {\n\tconst value = resolveInlineDraftValue(state, owner);\n\tconst caret = clampCaret(value, readInlineCaret(state, owner));\n\treturn {\n\t\tstate: withInlineDraft({ ...state, inputMode: true, inlineInputOwner: owner }, owner, value, caret),\n\t\teffects: [{ kind: \"set_input_buffer\", value, caret }],\n\t};\n}\n\nfunction switchTabResult(state: QuestionnaireState, nextTab: number, ctx: ApplyContext): ApplyResult {\n\tconst notesValue = state.notesByTab.get(nextTab) ?? state.answers.get(nextTab)?.notes ?? \"\";\n\tconst transitioned: QuestionnaireState = {\n\t\t...state,\n\t\tcurrentTab: nextTab,\n\t\toptionIndex: 0,\n\t\tinputMode: false,\n\t\tinlineInputOwner: null,\n\t\tnotesVisible: false,\n\t\tchatFocused: false,\n\t\tsubmitChoiceIndex: 0,\n\t\tmultiSelectChecked: syncMultiSelectFromAnswers(state.answers, ctx.questions, nextTab),\n\t\tnotesDraft: notesValue,\n\t};\n\tconst finalState = withFocusedOptionHasPreview(transitioned, ctx.questions);\n\treturn {\n\t\tstate: finalState,\n\t\teffects: [\n\t\t\t{ kind: \"set_notes_focused\", focused: false },\n\t\t\t{ kind: \"set_notes_value\", value: notesValue },\n\t\t],\n\t};\n}\n\nfunction doneFor(state: QuestionnaireState, ctx: ApplyContext, cancelled: boolean): ApplyResult {\n\tconst result: QuestionnaireResult = { answers: orderedAnswers(state, ctx.questions), cancelled };\n\treturn { state, effects: [{ kind: \"done\", result }] };\n}\n\n/**\n * Per-kind handler signature: action payload narrows to the matching union member\n * via `Extract`, so handlers consume fully-typed actions without `as` casts.\n */\ntype Handler<K extends QuestionnaireAction[\"kind\"]> = (\n\tstate: QuestionnaireState,\n\taction: Extract<QuestionnaireAction, { kind: K }>,\n\tctx: ApplyContext,\n) => ApplyResult;\n\nconst navHandler: Handler<\"nav\"> = (state, action, ctx) => {\n\tconst items = ctx.itemsByTab[state.currentTab] ?? [];\n\tconst item = items[action.nextIndex];\n\tconst owner = inlineOwnerForItem(item);\n\tconst next = withFocusedOptionHasPreview(\n\t\t{\n\t\t\t...state,\n\t\t\tchatFocused: false,\n\t\t\toptionIndex: action.nextIndex,\n\t\t\tinputMode: owner !== null,\n\t\t\tinlineInputOwner: owner,\n\t\t},\n\t\tctx.questions,\n\t);\n\treturn owner ? hydrateInlineInputResult(next, owner) : { state: next, effects: [] };\n};\n\nconst tabSwitchHandler: Handler<\"tab_switch\"> = (state, action, ctx) => switchTabResult(state, action.nextTab, ctx);\n\nconst confirmHandler: Handler<\"confirm\"> = (state, action, ctx) => {\n\tlet answer = action.answer;\n\tif (answer.kind === \"option\" && answer.answer) {\n\t\tconst q = ctx.questions[answer.questionIndex];\n\t\tconst matched = q?.options.find((o) => o.label === answer.answer);\n\t\tif (matched?.preview && matched.preview.length > 0) {\n\t\t\tanswer = { ...answer, preview: matched.preview };\n\t\t}\n\t}\n\tconst pendingNotes = state.notesByTab.get(answer.questionIndex);\n\tif (pendingNotes && pendingNotes.length > 0) {\n\t\tanswer = { ...answer, notes: pendingNotes };\n\t}\n\tconst answers = new Map(state.answers);\n\tanswers.set(answer.questionIndex, answer);\n\tconst next: QuestionnaireState = { ...state, answers };\n\tif (answer.kind === \"chat\") return doneFor(next, ctx, false);\n\tif (action.autoAdvanceTab !== undefined) return switchTabResult(next, action.autoAdvanceTab, ctx);\n\treturn doneFor(next, ctx, false);\n};\n\nconst toggleHandler: Handler<\"toggle\"> = (state, action, ctx) => {\n\tconst checked = new Set(state.multiSelectChecked);\n\tif (checked.has(action.index)) checked.delete(action.index);\n\telse checked.add(action.index);\n\tconst intermediate: QuestionnaireState = { ...state, multiSelectChecked: checked };\n\tconst answers = persistMultiSelectAnswer(intermediate, ctx);\n\treturn { state: { ...intermediate, answers }, effects: [] };\n};\n\nconst multiConfirmHandler: Handler<\"multi_confirm\"> = (state, action, ctx) => {\n\tconst q = ctx.questions[state.currentTab];\n\tif (!q) return { state, effects: [] };\n\tconst pendingNotes = state.notesByTab.get(state.currentTab);\n\tconst answers = new Map(state.answers);\n\tanswers.set(state.currentTab, {\n\t\tquestionIndex: state.currentTab,\n\t\tquestion: q.question,\n\t\tkind: \"multi\",\n\t\tanswer: null,\n\t\tselected: action.selected,\n\t\t...(pendingNotes && pendingNotes.length > 0 ? { notes: pendingNotes } : {}),\n\t});\n\tconst synced: QuestionnaireState = {\n\t\t...state,\n\t\tanswers,\n\t\tmultiSelectChecked: syncMultiSelectFromAnswers(answers, ctx.questions, state.currentTab),\n\t};\n\tif (action.autoAdvanceTab !== undefined) return switchTabResult(synced, action.autoAdvanceTab, ctx);\n\treturn doneFor(synced, ctx, false);\n};\n\nconst notesEnterHandler: Handler<\"notes_enter\"> = (state, _action, _ctx) => {\n\tconst value = state.answers.get(state.currentTab)?.notes ?? \"\";\n\treturn {\n\t\tstate: { ...state, notesVisible: true, notesDraft: value },\n\t\teffects: [\n\t\t\t{ kind: \"set_notes_value\", value },\n\t\t\t{ kind: \"set_notes_focused\", focused: true },\n\t\t],\n\t};\n};\n\nconst notesExitHandler: Handler<\"notes_exit\"> = (state, _action, _ctx) => {\n\tconst trimmed = state.notesDraft.trim();\n\tconst notes = new Map(state.notesByTab);\n\tconst answers = new Map(state.answers);\n\tif (trimmed.length === 0) {\n\t\tnotes.delete(state.currentTab);\n\t\tconst prev = answers.get(state.currentTab);\n\t\tif (prev?.notes) {\n\t\t\tconst stripped = { ...prev };\n\t\t\tdelete (stripped as { notes?: string }).notes;\n\t\t\tanswers.set(state.currentTab, stripped);\n\t\t}\n\t} else {\n\t\tnotes.set(state.currentTab, trimmed);\n\t\tconst prev = answers.get(state.currentTab);\n\t\tif (prev) answers.set(state.currentTab, { ...prev, notes: trimmed });\n\t}\n\treturn {\n\t\tstate: { ...state, notesByTab: notes, answers, notesVisible: false },\n\t\teffects: [{ kind: \"set_notes_focused\", focused: false }],\n\t};\n};\n\nconst focusOptionsHandler: Handler<\"focus_options\"> = (state, action, ctx) => {\n\tconst items = ctx.itemsByTab[state.currentTab] ?? [];\n\tconst focused = items[action.optionIndex];\n\tconst owner = inlineOwnerForItem(focused);\n\tconst next = withFocusedOptionHasPreview(\n\t\t{\n\t\t\t...state,\n\t\t\tchatFocused: false,\n\t\t\toptionIndex: action.optionIndex,\n\t\t\tinputMode: owner !== null,\n\t\t\tinlineInputOwner: owner,\n\t\t},\n\t\tctx.questions,\n\t);\n\treturn owner ? hydrateInlineInputResult(next, owner) : { state: next, effects: [] };\n};\n\nconst cancelHandler: Handler<\"cancel\"> = (s, _a, c) => doneFor(s, c, true);\nconst submitHandler: Handler<\"submit\"> = (s, _a, c) => doneFor(s, c, false);\nconst submitNavHandler: Handler<\"submit_nav\"> = (s, a, _c) => ({\n\tstate: { ...s, submitChoiceIndex: a.nextIndex },\n\teffects: [],\n});\nconst focusChatHandler: Handler<\"focus_chat\"> = (s, _a, ctx) =>\n\tctx.chatAsOption === true\n\t\t? { state: { ...s, chatFocused: true, inputMode: false, inlineInputOwner: null }, effects: [] }\n\t\t: hydrateInlineInputResult({ ...s, chatFocused: true, inputMode: true, inlineInputOwner: \"chat\" }, \"chat\");\nconst notesForwardHandler: Handler<\"notes_forward\"> = (s, a, _c) => ({\n\tstate: s,\n\teffects: [{ kind: \"forward_notes_keystroke\", data: a.data }],\n});\nconst ignoreHandler: Handler<\"ignore\"> = (s, _a, _c) => ({ state: s, effects: [] });\n\n/**\n * Compile-time-exhaustive dispatch table. `{ [K in Kind]: Handler<K> }` requires\n * an entry per union member — adding a new `QuestionnaireAction` variant fails to\n * compile here until a handler is registered, mirroring the `Record<RowKind, …>`\n * pattern used by `ROW_INTENT_META`.\n */\nconst HANDLERS: { [K in QuestionnaireAction[\"kind\"]]: Handler<K> } = {\n\tnav: navHandler,\n\ttab_switch: tabSwitchHandler,\n\tconfirm: confirmHandler,\n\ttoggle: toggleHandler,\n\tmulti_confirm: multiConfirmHandler,\n\tcancel: cancelHandler,\n\tnotes_enter: notesEnterHandler,\n\tnotes_exit: notesExitHandler,\n\tnotes_forward: notesForwardHandler,\n\tsubmit: submitHandler,\n\tsubmit_nav: submitNavHandler,\n\tfocus_chat: focusChatHandler,\n\tfocus_options: focusOptionsHandler,\n\tignore: ignoreHandler,\n};\n\n/**\n * Pure reducer: (state, action, ctx) → (state, Effect[]). Mirrors `rpiv-todo`'s `applyTaskMutation`.\n * Delegates to `HANDLERS` — per-kind handlers above are pure, named, and individually testable.\n * `ignore` is also handled outside the reducer by `handleIgnoreInline` in the runtime fast path.\n */\nexport function reduce(state: QuestionnaireState, action: QuestionnaireAction, ctx: ApplyContext): ApplyResult {\n\tconst handler = HANDLERS[action.kind] as Handler<typeof action.kind>;\n\treturn handler(state, action as never, ctx);\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { QuestionAnswer, QuestionData } from "../tool/types.ts";
1
+ import type { QuestionAnswer, QuestionData } from "../tool/types.js";
2
2
  import type { WrappingSelectItem } from "../view/components/wrapping-select.ts";
3
3
  import type { RowKind } from "./row-intent.ts";
4
4
  export type InlineInputOwner = Extract<RowKind, "other" | "chat">;
@@ -1 +1 @@
1
- {"version":3,"file":"state.js","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/state/state.ts"],"names":[],"mappings":"","sourcesContent":["import type { QuestionAnswer, QuestionData } from \"../tool/types.ts\";\nimport type { WrappingSelectItem } from \"../view/components/wrapping-select.ts\";\nimport type { RowKind } from \"./row-intent.ts\";\n\nexport type InlineInputOwner = Extract<RowKind, \"other\" | \"chat\">;\n\n/**\n * Canonical state for the questionnaire dialog. Single source of truth — both the\n * dispatcher (`routeKey`) and the view layer read this same shape.\n */\nexport interface QuestionnaireState {\n\tcurrentTab: number;\n\toptionIndex: number;\n\tinputMode: boolean;\n\tnotesVisible: boolean;\n\tchatFocused: boolean;\n\t/** Active owner of the shared inline input, or null when no inline row is being edited. */\n\tinlineInputOwner: InlineInputOwner | null;\n\tanswers: ReadonlyMap<number, QuestionAnswer>;\n\tmultiSelectChecked: ReadonlySet<number>;\n\t/**\n\t * Pre-answer notes side-band, keyed by tab index. Decoupled from `answers` so adding\n\t * notes does NOT mark a question answered (the Submit-tab missing-check would falsely\n\t * pass otherwise). Merged into the answer at confirm time.\n\t */\n\tnotesByTab: ReadonlyMap<number, string>;\n\t/** True iff the focused option carries a non-empty `preview` string. Gates `notes_enter` and the \"n to add notes\" hint chip. */\n\tfocusedOptionHasPreview: boolean;\n\t/** Focused row in the Submit-tab picker (0 = Submit, 1 = Cancel). Reset on tab switch. */\n\tsubmitChoiceIndex: number;\n\t/** Canonical mirror of the in-flight notes editor; runtime mirrors after `forward_notes_keystroke`. */\n\tnotesDraft: string;\n\t/** In-flight custom \"Type something.\" drafts keyed by question tab. Preserved when focus leaves the row. */\n\tcustomDraftByTab: ReadonlyMap<number, string>;\n\t/** Caret offsets for in-flight custom drafts keyed by question tab. */\n\tcustomCaretByTab: ReadonlyMap<number, number>;\n\t/** In-flight \"Chat about this\" inline drafts keyed by question tab. */\n\tchatDraftByTab: ReadonlyMap<number, string>;\n\t/** Caret offsets for in-flight chat drafts keyed by question tab. */\n\tchatCaretByTab: ReadonlyMap<number, number>;\n}\n\n/**\n * Per-tick context the dispatcher needs alongside canonical state. Held separately\n * because `keybindings` / `inputBuffer` must never reach view setProps consumers.\n */\nexport interface QuestionnaireRuntime {\n\tkeybindings: { matches(data: string, name: string): boolean };\n\tinputBuffer: string;\n\tquestions: readonly QuestionData[];\n\tisMulti: boolean;\n\tcurrentItem: WrappingSelectItem | undefined;\n\titems: readonly WrappingSelectItem[];\n}\n"]}
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/state/state.ts"],"names":[],"mappings":"","sourcesContent":["import type { QuestionAnswer, QuestionData } from \"../tool/types.js\";\nimport type { WrappingSelectItem } from \"../view/components/wrapping-select.ts\";\nimport type { RowKind } from \"./row-intent.ts\";\n\nexport type InlineInputOwner = Extract<RowKind, \"other\" | \"chat\">;\n\n/**\n * Canonical state for the questionnaire dialog. Single source of truth — both the\n * dispatcher (`routeKey`) and the view layer read this same shape.\n */\nexport interface QuestionnaireState {\n\tcurrentTab: number;\n\toptionIndex: number;\n\tinputMode: boolean;\n\tnotesVisible: boolean;\n\tchatFocused: boolean;\n\t/** Active owner of the shared inline input, or null when no inline row is being edited. */\n\tinlineInputOwner: InlineInputOwner | null;\n\tanswers: ReadonlyMap<number, QuestionAnswer>;\n\tmultiSelectChecked: ReadonlySet<number>;\n\t/**\n\t * Pre-answer notes side-band, keyed by tab index. Decoupled from `answers` so adding\n\t * notes does NOT mark a question answered (the Submit-tab missing-check would falsely\n\t * pass otherwise). Merged into the answer at confirm time.\n\t */\n\tnotesByTab: ReadonlyMap<number, string>;\n\t/** True iff the focused option carries a non-empty `preview` string. Gates `notes_enter` and the \"n to add notes\" hint chip. */\n\tfocusedOptionHasPreview: boolean;\n\t/** Focused row in the Submit-tab picker (0 = Submit, 1 = Cancel). Reset on tab switch. */\n\tsubmitChoiceIndex: number;\n\t/** Canonical mirror of the in-flight notes editor; runtime mirrors after `forward_notes_keystroke`. */\n\tnotesDraft: string;\n\t/** In-flight custom \"Type something.\" drafts keyed by question tab. Preserved when focus leaves the row. */\n\tcustomDraftByTab: ReadonlyMap<number, string>;\n\t/** Caret offsets for in-flight custom drafts keyed by question tab. */\n\tcustomCaretByTab: ReadonlyMap<number, number>;\n\t/** In-flight \"Chat about this\" inline drafts keyed by question tab. */\n\tchatDraftByTab: ReadonlyMap<number, string>;\n\t/** Caret offsets for in-flight chat drafts keyed by question tab. */\n\tchatCaretByTab: ReadonlyMap<number, number>;\n}\n\n/**\n * Per-tick context the dispatcher needs alongside canonical state. Held separately\n * because `keybindings` / `inputBuffer` must never reach view setProps consumers.\n */\nexport interface QuestionnaireRuntime {\n\tkeybindings: { matches(data: string, name: string): boolean };\n\tinputBuffer: string;\n\tquestions: readonly QuestionData[];\n\tisMulti: boolean;\n\tcurrentItem: WrappingSelectItem | undefined;\n\titems: readonly WrappingSelectItem[];\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { QuestionAnswer } from "./types.ts";
1
+ import type { QuestionAnswer } from "./types.js";
2
2
  /**
3
3
  * Continuation message used in the LLM-facing envelope. Two-sentence form —
4
4
  * the model needs the "Stop…wait…" directive to know what to do next after the
@@ -1 +1 @@
1
- {"version":3,"file":"format-answer.js","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/tool/format-answer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD;;;;GAIG;AACH,MAAM,CAAC,MAAM,yBAAyB,GACrC,iGAAiG,CAAC;AAEnG;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,+BAA+B,CAAC;AAEpE;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAIjD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,CAAiB;IACjD,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,CAAC,CAAC,MAAM,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IACxE,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAChC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,KAAK,eAAe,CAAC,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IACrF,OAAO,CAAC,CAAC,MAAM,CAAC;AACjB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,CAAiB,EAAE,OAA4B;IACjF,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;QAChB,KAAK,MAAM,EAAE,CAAC;YACb,MAAM,SAAS,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;YACtC,IAAI,SAAS,KAAK,SAAS;gBAAE,OAAO,SAAS,CAAC;YAC9C,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,oBAAoB,CAAC;QAClF,CAAC;QACD,KAAK,OAAO;YACX,OAAO,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC;QAC3F,KAAK,QAAQ;YACZ,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,oBAAoB,CAAC;QAC1E,KAAK,QAAQ;YACZ,OAAO,CAAC,CAAC,MAAM,IAAI,oBAAoB,CAAC;IAC1C,CAAC;AACF,CAAC","sourcesContent":["import { ROW_INTENT_META } from \"../state/row-intent.ts\";\nimport type { QuestionAnswer } from \"./types.ts\";\n\n/**\n * Continuation message used in the LLM-facing envelope. Two-sentence form —\n * the model needs the \"Stop…wait…\" directive to know what to do next after the\n * user picks chat instead of answering.\n */\nexport const CHAT_CONTINUATION_MESSAGE =\n\t\"User wants to chat about this. Stop the current task flow and wait for the user's next message.\";\n\n/**\n * One-sentence summary form shown in the on-screen Submit-tab review pane. The dialog\n * already shows the question; the imperative continuation directive belongs in the\n * envelope, not in the user-facing summary box.\n */\nexport const CHAT_SUMMARY_MESSAGE = \"User wants to chat about this\";\n\n/**\n * Placeholder for empty / null answer text. Used uniformly across both variants — the\n * earlier `(no answer)` fallback in the dialog summary was accidental drift; tests pin\n * `(no input)` only.\n */\nexport const NO_INPUT_PLACEHOLDER = \"(no input)\";\n\nexport type FormatAnswerVariant = \"summary\" | \"envelope\";\n\n/**\n * Return the user-provided chat message, or undefined for the legacy signal-only\n * chat answer. Whitespace-only text and the reserved sentinel label both keep\n * the legacy stop/wait semantics.\n */\nexport function chatAnswerIntent(a: QuestionAnswer): string | undefined {\n\tif (a.kind !== \"chat\" || typeof a.answer !== \"string\") return undefined;\n\tconst trimmed = a.answer.trim();\n\tif (trimmed.length === 0 || trimmed === ROW_INTENT_META.chat.label) return undefined;\n\treturn a.answer;\n}\n\n/**\n * Format a `QuestionAnswer` to its scalar string form. Variant controls only the\n * `kind: \"chat\"` branch — the envelope's stop/wait directive is needed by the LLM,\n * the dialog summary's one-sentence reminder is not. All other branches return identical\n * strings; the `kind: \"custom\"` empty-string handling and the option fallback both unify\n * on `NO_INPUT_PLACEHOLDER`. Switch is exhaustive — non-`void` return enforces every\n * variant is handled.\n */\nexport function formatAnswerScalar(a: QuestionAnswer, variant: FormatAnswerVariant): string {\n\tswitch (a.kind) {\n\t\tcase \"chat\": {\n\t\t\tconst typedChat = chatAnswerIntent(a);\n\t\t\tif (typedChat !== undefined) return typedChat;\n\t\t\treturn variant === \"envelope\" ? CHAT_CONTINUATION_MESSAGE : CHAT_SUMMARY_MESSAGE;\n\t\t}\n\t\tcase \"multi\":\n\t\t\treturn a.selected && a.selected.length > 0 ? a.selected.join(\", \") : NO_INPUT_PLACEHOLDER;\n\t\tcase \"custom\":\n\t\t\treturn a.answer && a.answer.length > 0 ? a.answer : NO_INPUT_PLACEHOLDER;\n\t\tcase \"option\":\n\t\t\treturn a.answer ?? NO_INPUT_PLACEHOLDER;\n\t}\n}\n"]}
1
+ {"version":3,"file":"format-answer.js","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/tool/format-answer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD;;;;GAIG;AACH,MAAM,CAAC,MAAM,yBAAyB,GACrC,iGAAiG,CAAC;AAEnG;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,+BAA+B,CAAC;AAEpE;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAIjD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,CAAiB;IACjD,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,CAAC,CAAC,MAAM,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IACxE,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAChC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,KAAK,eAAe,CAAC,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IACrF,OAAO,CAAC,CAAC,MAAM,CAAC;AACjB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,CAAiB,EAAE,OAA4B;IACjF,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;QAChB,KAAK,MAAM,EAAE,CAAC;YACb,MAAM,SAAS,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;YACtC,IAAI,SAAS,KAAK,SAAS;gBAAE,OAAO,SAAS,CAAC;YAC9C,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,oBAAoB,CAAC;QAClF,CAAC;QACD,KAAK,OAAO;YACX,OAAO,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC;QAC3F,KAAK,QAAQ;YACZ,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,oBAAoB,CAAC;QAC1E,KAAK,QAAQ;YACZ,OAAO,CAAC,CAAC,MAAM,IAAI,oBAAoB,CAAC;IAC1C,CAAC;AACF,CAAC","sourcesContent":["import { ROW_INTENT_META } from \"../state/row-intent.ts\";\nimport type { QuestionAnswer } from \"./types.js\";\n\n/**\n * Continuation message used in the LLM-facing envelope. Two-sentence form —\n * the model needs the \"Stop…wait…\" directive to know what to do next after the\n * user picks chat instead of answering.\n */\nexport const CHAT_CONTINUATION_MESSAGE =\n\t\"User wants to chat about this. Stop the current task flow and wait for the user's next message.\";\n\n/**\n * One-sentence summary form shown in the on-screen Submit-tab review pane. The dialog\n * already shows the question; the imperative continuation directive belongs in the\n * envelope, not in the user-facing summary box.\n */\nexport const CHAT_SUMMARY_MESSAGE = \"User wants to chat about this\";\n\n/**\n * Placeholder for empty / null answer text. Used uniformly across both variants — the\n * earlier `(no answer)` fallback in the dialog summary was accidental drift; tests pin\n * `(no input)` only.\n */\nexport const NO_INPUT_PLACEHOLDER = \"(no input)\";\n\nexport type FormatAnswerVariant = \"summary\" | \"envelope\";\n\n/**\n * Return the user-provided chat message, or undefined for the legacy signal-only\n * chat answer. Whitespace-only text and the reserved sentinel label both keep\n * the legacy stop/wait semantics.\n */\nexport function chatAnswerIntent(a: QuestionAnswer): string | undefined {\n\tif (a.kind !== \"chat\" || typeof a.answer !== \"string\") return undefined;\n\tconst trimmed = a.answer.trim();\n\tif (trimmed.length === 0 || trimmed === ROW_INTENT_META.chat.label) return undefined;\n\treturn a.answer;\n}\n\n/**\n * Format a `QuestionAnswer` to its scalar string form. Variant controls only the\n * `kind: \"chat\"` branch — the envelope's stop/wait directive is needed by the LLM,\n * the dialog summary's one-sentence reminder is not. All other branches return identical\n * strings; the `kind: \"custom\"` empty-string handling and the option fallback both unify\n * on `NO_INPUT_PLACEHOLDER`. Switch is exhaustive — non-`void` return enforces every\n * variant is handled.\n */\nexport function formatAnswerScalar(a: QuestionAnswer, variant: FormatAnswerVariant): string {\n\tswitch (a.kind) {\n\t\tcase \"chat\": {\n\t\t\tconst typedChat = chatAnswerIntent(a);\n\t\t\tif (typedChat !== undefined) return typedChat;\n\t\t\treturn variant === \"envelope\" ? CHAT_CONTINUATION_MESSAGE : CHAT_SUMMARY_MESSAGE;\n\t\t}\n\t\tcase \"multi\":\n\t\t\treturn a.selected && a.selected.length > 0 ? a.selected.join(\", \") : NO_INPUT_PLACEHOLDER;\n\t\tcase \"custom\":\n\t\t\treturn a.answer && a.answer.length > 0 ? a.answer : NO_INPUT_PLACEHOLDER;\n\t\tcase \"option\":\n\t\t\treturn a.answer ?? NO_INPUT_PLACEHOLDER;\n\t}\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { QuestionAnswer, QuestionnaireResult, QuestionParams } from "./types.ts";
1
+ import type { QuestionAnswer, QuestionnaireResult, QuestionParams } from "./types.js";
2
2
  export declare const DECLINE_MESSAGE = "User declined to answer questions";
3
3
  export declare const ENVELOPE_PREFIX = "User has answered your questions:";
4
4
  export declare const ENVELOPE_SUFFIX = "You can now continue with the user's answers in mind.";
@@ -1 +1 @@
1
- {"version":3,"file":"response-envelope.js","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/tool/response-envelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAG1E,MAAM,CAAC,MAAM,eAAe,GAAG,mCAAmC,CAAC;AACnE,MAAM,CAAC,MAAM,eAAe,GAAG,mCAAmC,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;QAAE,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IACxE,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,OAA4B,EAAE,OAAiC;IAC5G,OAAO;QACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,CAAC;QAC1C,OAAO;QACP,GAAG,CAAC,OAAO,EAAE,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC3D,CAAC;AACH,CAAC","sourcesContent":["import { chatAnswerIntent, formatAnswerScalar } from \"./format-answer.ts\";\nimport type { QuestionAnswer, QuestionnaireResult, QuestionParams } from \"./types.ts\";\n\nexport const DECLINE_MESSAGE = \"User declined to answer questions\";\nexport const ENVELOPE_PREFIX = \"User has answered your questions:\";\nexport const ENVELOPE_SUFFIX = \"You can now continue with the user's answers in mind.\";\nconst CHAT_TERMINATION_DIRECTIVE =\n\t\"User wants to chat about this before choosing. Stop the current task flow and wait for the user's next message.\";\nconst TYPED_CHAT_DIRECTIVE =\n\t\"User wants to chat about this before choosing and provided inline text. Stop the structured-choice flow and respond to the user's message.\";\n\n/**\n * True when any answer in the result carries `kind: \"chat\"`.\n * Used by `buildQuestionnaireResponse` to switch to the terminate path.\n */\nexport function hasChatAnswer(result: QuestionnaireResult): boolean {\n\treturn result.answers.some((a) => a.kind === \"chat\");\n}\n\n/**\n * Map a `QuestionnaireResult` (or null/cancelled) to the LLM-facing tool envelope.\n * Pure of `(result, params)`; cancelled and non-chat \"no segments\" both fall to\n * `DECLINE_MESSAGE` so the model sees a single canonical \"didn't answer\" signal\n * regardless of why.\n *\n * Chat rule: signal-only chat keeps the legacy `terminate: true` stop/wait\n * wording. Typed chat omits `terminate` and the generic continuation suffix so\n * the model can respond to the inline user message in this same turn.\n */\nexport function buildQuestionnaireResponse(result: QuestionnaireResult | null | undefined, params: QuestionParams) {\n\tif (!result || result.cancelled) {\n\t\treturn buildToolResult(DECLINE_MESSAGE, {\n\t\t\tanswers: result?.answers ?? [],\n\t\t\tcancelled: true,\n\t\t});\n\t}\n\tconst containsChatAnswer = hasChatAnswer(result);\n\tconst segments: string[] = [];\n\tfor (let i = 0; i < params.questions.length; i++) {\n\t\tconst a = result.answers.find((x) => x.questionIndex === i);\n\t\tif (a) segments.push(buildAnswerSegment(a));\n\t}\n\tif (containsChatAnswer) {\n\t\tconst answerSegments = segments.length > 0 ? ` ${segments.join(\" \")}` : \"\";\n\t\t// Mixed-dialog precedence: signal-only chat WINS. In a multi-question dialog where one\n\t\t// question carried typed chat and another is signal-only, the whole envelope takes the\n\t\t// `terminate: true` stop/wait path — a bare \"chat about this\" is an explicit request to\n\t\t// pause the structured flow, so it dominates. The typed message is not lost: it still\n\t\t// rides along in `answerSegments` for context. This precedence is a deliberate product\n\t\t// decision; mixing typed + signal-only chat across questions is a rare edge.\n\t\tconst hasSignalOnlyChat = result.answers.some((a) => a.kind === \"chat\" && chatAnswerIntent(a) === undefined);\n\t\tif (!hasSignalOnlyChat) {\n\t\t\treturn buildToolResult(`${TYPED_CHAT_DIRECTIVE}${answerSegments}`, result);\n\t\t}\n\t\treturn buildToolResult(`${CHAT_TERMINATION_DIRECTIVE}${answerSegments}`, result, { terminate: true });\n\t}\n\tif (segments.length === 0) {\n\t\treturn buildToolResult(DECLINE_MESSAGE, { answers: result.answers, cancelled: true });\n\t}\n\treturn buildToolResult(`${ENVELOPE_PREFIX} ${segments.join(\" \")} ${ENVELOPE_SUFFIX}`, result);\n}\n\n/**\n * Format a single answer segment for the envelope. Pure of `a`. The `\"Q\"=\"A\"` shape and\n * the optional `selected preview:` / `user notes:` suffixes are pinned by envelope tests.\n */\nexport function buildAnswerSegment(a: QuestionAnswer): string {\n\tconst parts: string[] = [`\"${a.question}\"=\"${formatAnswerScalar(a, \"envelope\")}\"`];\n\tif (a.preview && a.preview.length > 0) parts.push(`selected preview: ${a.preview}`);\n\tif (a.notes && a.notes.length > 0) parts.push(`user notes: ${a.notes}`);\n\treturn `${parts.join(\". \")}.`;\n}\n\nexport function buildToolResult(text: string, details: QuestionnaireResult, options?: { terminate?: boolean }) {\n\treturn {\n\t\tcontent: [{ type: \"text\" as const, text }],\n\t\tdetails,\n\t\t...(options?.terminate === true ? { terminate: true } : {}),\n\t};\n}\n"]}
1
+ {"version":3,"file":"response-envelope.js","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/tool/response-envelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAG1E,MAAM,CAAC,MAAM,eAAe,GAAG,mCAAmC,CAAC;AACnE,MAAM,CAAC,MAAM,eAAe,GAAG,mCAAmC,CAAC;AACnE,MAAM,CAAC,MAAM,eAAe,GAAG,uDAAuD,CAAC;AACvF,MAAM,0BAA0B,GAC/B,iHAAiH,CAAC;AACnH,MAAM,oBAAoB,GACzB,4IAA4I,CAAC;AAE9I;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,MAA2B;IACxD,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;AACtD,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,0BAA0B,CAAC,MAA8C,EAAE,MAAsB;IAChH,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QACjC,OAAO,eAAe,CAAC,eAAe,EAAE;YACvC,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,EAAE;YAC9B,SAAS,EAAE,IAAI;SACf,CAAC,CAAC;IACJ,CAAC;IACD,MAAM,kBAAkB,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACjD,MAA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AAE,IAAI,EAAE,CAAC,CAAC;IACvF,CAAC;IACD,OAAO,eAAe,CAAC,GAAG,eAAe,IAAI,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,eAAe,EAAE,EAAE,MAAM,CAAC,CAAC;AAC/F,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,CAAiB;IACnD,MAAM,KAAK,GAAa,CAAC,IAAI,CAAC,CAAC,QAAQ,MAAM,kBAAkB,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IACnF,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IACpF,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IACxE,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,OAA4B,EAAE,OAAiC;IAC5G,OAAO;QACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,CAAC;QAC1C,OAAO;QACP,GAAG,CAAC,OAAO,EAAE,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC3D,CAAC;AACH,CAAC","sourcesContent":["import { chatAnswerIntent, formatAnswerScalar } from \"./format-answer.ts\";\nimport type { QuestionAnswer, QuestionnaireResult, QuestionParams } from \"./types.js\";\n\nexport const DECLINE_MESSAGE = \"User declined to answer questions\";\nexport const ENVELOPE_PREFIX = \"User has answered your questions:\";\nexport const ENVELOPE_SUFFIX = \"You can now continue with the user's answers in mind.\";\nconst CHAT_TERMINATION_DIRECTIVE =\n\t\"User wants to chat about this before choosing. Stop the current task flow and wait for the user's next message.\";\nconst TYPED_CHAT_DIRECTIVE =\n\t\"User wants to chat about this before choosing and provided inline text. Stop the structured-choice flow and respond to the user's message.\";\n\n/**\n * True when any answer in the result carries `kind: \"chat\"`.\n * Used by `buildQuestionnaireResponse` to switch to the terminate path.\n */\nexport function hasChatAnswer(result: QuestionnaireResult): boolean {\n\treturn result.answers.some((a) => a.kind === \"chat\");\n}\n\n/**\n * Map a `QuestionnaireResult` (or null/cancelled) to the LLM-facing tool envelope.\n * Pure of `(result, params)`; cancelled and non-chat \"no segments\" both fall to\n * `DECLINE_MESSAGE` so the model sees a single canonical \"didn't answer\" signal\n * regardless of why.\n *\n * Chat rule: signal-only chat keeps the legacy `terminate: true` stop/wait\n * wording. Typed chat omits `terminate` and the generic continuation suffix so\n * the model can respond to the inline user message in this same turn.\n */\nexport function buildQuestionnaireResponse(result: QuestionnaireResult | null | undefined, params: QuestionParams) {\n\tif (!result || result.cancelled) {\n\t\treturn buildToolResult(DECLINE_MESSAGE, {\n\t\t\tanswers: result?.answers ?? [],\n\t\t\tcancelled: true,\n\t\t});\n\t}\n\tconst containsChatAnswer = hasChatAnswer(result);\n\tconst segments: string[] = [];\n\tfor (let i = 0; i < params.questions.length; i++) {\n\t\tconst a = result.answers.find((x) => x.questionIndex === i);\n\t\tif (a) segments.push(buildAnswerSegment(a));\n\t}\n\tif (containsChatAnswer) {\n\t\tconst answerSegments = segments.length > 0 ? ` ${segments.join(\" \")}` : \"\";\n\t\t// Mixed-dialog precedence: signal-only chat WINS. In a multi-question dialog where one\n\t\t// question carried typed chat and another is signal-only, the whole envelope takes the\n\t\t// `terminate: true` stop/wait path — a bare \"chat about this\" is an explicit request to\n\t\t// pause the structured flow, so it dominates. The typed message is not lost: it still\n\t\t// rides along in `answerSegments` for context. This precedence is a deliberate product\n\t\t// decision; mixing typed + signal-only chat across questions is a rare edge.\n\t\tconst hasSignalOnlyChat = result.answers.some((a) => a.kind === \"chat\" && chatAnswerIntent(a) === undefined);\n\t\tif (!hasSignalOnlyChat) {\n\t\t\treturn buildToolResult(`${TYPED_CHAT_DIRECTIVE}${answerSegments}`, result);\n\t\t}\n\t\treturn buildToolResult(`${CHAT_TERMINATION_DIRECTIVE}${answerSegments}`, result, { terminate: true });\n\t}\n\tif (segments.length === 0) {\n\t\treturn buildToolResult(DECLINE_MESSAGE, { answers: result.answers, cancelled: true });\n\t}\n\treturn buildToolResult(`${ENVELOPE_PREFIX} ${segments.join(\" \")} ${ENVELOPE_SUFFIX}`, result);\n}\n\n/**\n * Format a single answer segment for the envelope. Pure of `a`. The `\"Q\"=\"A\"` shape and\n * the optional `selected preview:` / `user notes:` suffixes are pinned by envelope tests.\n */\nexport function buildAnswerSegment(a: QuestionAnswer): string {\n\tconst parts: string[] = [`\"${a.question}\"=\"${formatAnswerScalar(a, \"envelope\")}\"`];\n\tif (a.preview && a.preview.length > 0) parts.push(`selected preview: ${a.preview}`);\n\tif (a.notes && a.notes.length > 0) parts.push(`user notes: ${a.notes}`);\n\treturn `${parts.join(\". \")}.`;\n}\n\nexport function buildToolResult(text: string, details: QuestionnaireResult, options?: { terminate?: boolean }) {\n\treturn {\n\t\tcontent: [{ type: \"text\" as const, text }],\n\t\tdetails,\n\t\t...(options?.terminate === true ? { terminate: true } : {}),\n\t};\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { type QuestionnaireError, type QuestionParams } from "./types.ts";
1
+ import { type QuestionnaireError, type QuestionParams } from "./types.js";
2
2
  export declare const ERROR_NO_QUESTIONS = "Error: At least one question is required";
3
3
  export declare const ERROR_TOO_MANY_QUESTIONS = "Error: At most 4 questions are allowed per invocation";
4
4
  export declare const ERROR_DUPLICATE_QUESTION = "Error: Question text must be unique within an invocation";
@@ -1 +1 @@
1
- {"version":3,"file":"validate-questionnaire.js","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/tool/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wBAAwB,EAAE,CAAC;QACtF,CAAC;QACD,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QACjC,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,WAAW,EAAE,CAAC;YACpC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,qBAAqB,EAAE,CAAC;QAC9E,CAAC;QACD,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;QACrC,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;YAC3B,IAAI,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;gBACrC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC;YAC9E,CAAC;YACD,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC7B,OAAO;oBACN,EAAE,EAAE,KAAK;oBACT,KAAK,EAAE,wBAAwB;oBAC/B,OAAO,EAAE,4BAA4B;iBACrC,CAAC;YACH,CAAC;YACD,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;IACF,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACrB,CAAC","sourcesContent":["import { MAX_QUESTIONS, MIN_OPTIONS, type QuestionnaireError, type QuestionParams, RESERVED_LABELS } from \"./types.ts\";\n\nexport const ERROR_NO_QUESTIONS = \"Error: At least one question is required\";\nexport const ERROR_TOO_MANY_QUESTIONS = `Error: At most ${MAX_QUESTIONS} questions are allowed per invocation`;\nexport const ERROR_DUPLICATE_QUESTION = \"Error: Question text must be unique within an invocation\";\nexport const ERROR_TOO_FEW_OPTIONS = `Error: Each question requires at least ${MIN_OPTIONS} options`;\nexport const ERROR_RESERVED_LABEL = `Error: Option label is reserved (${RESERVED_LABELS.join(\", \")})`;\nexport const ERROR_DUPLICATE_OPTION_LABEL = \"Error: Option labels must be unique within a question\";\n\nconst RESERVED_LABEL_SET: ReadonlySet<string> = new Set(RESERVED_LABELS);\n\nexport type ValidationResult = { ok: true } | { ok: false; error: QuestionnaireError; message: string };\n\n/**\n * Pure runtime validator for `QuestionParams`. Covers every guard except\n * `no_ui` (which depends on `ctx.hasUI` and stays inline at the call site).\n * `reserved_label` MUST short-circuit before `duplicate_option_label`.\n */\nexport function validateQuestionnaire(typed: QuestionParams): ValidationResult {\n\tif (typed.questions.length === 0) {\n\t\treturn { ok: false, error: \"no_questions\", message: ERROR_NO_QUESTIONS };\n\t}\n\tif (typed.questions.length > MAX_QUESTIONS) {\n\t\treturn { ok: false, error: \"too_many_questions\", message: ERROR_TOO_MANY_QUESTIONS };\n\t}\n\n\tconst seenQuestions = new Set<string>();\n\tfor (const q of typed.questions) {\n\t\tif (seenQuestions.has(q.question)) {\n\t\t\treturn { ok: false, error: \"duplicate_question\", message: ERROR_DUPLICATE_QUESTION };\n\t\t}\n\t\tseenQuestions.add(q.question);\n\t}\n\n\tfor (const q of typed.questions) {\n\t\tif (q.options.length < MIN_OPTIONS) {\n\t\t\treturn { ok: false, error: \"empty_options\", message: ERROR_TOO_FEW_OPTIONS };\n\t\t}\n\t\tconst seenLabels = new Set<string>();\n\t\tfor (const o of q.options) {\n\t\t\tif (RESERVED_LABEL_SET.has(o.label)) {\n\t\t\t\treturn { ok: false, error: \"reserved_label\", message: ERROR_RESERVED_LABEL };\n\t\t\t}\n\t\t\tif (seenLabels.has(o.label)) {\n\t\t\t\treturn {\n\t\t\t\t\tok: false,\n\t\t\t\t\terror: \"duplicate_option_label\",\n\t\t\t\t\tmessage: ERROR_DUPLICATE_OPTION_LABEL,\n\t\t\t\t};\n\t\t\t}\n\t\t\tseenLabels.add(o.label);\n\t\t}\n\t}\n\n\treturn { ok: true };\n}\n"]}
1
+ {"version":3,"file":"validate-questionnaire.js","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/tool/validate-questionnaire.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAgD,eAAe,EAAE,MAAM,YAAY,CAAC;AAEvH,MAAM,CAAC,MAAM,kBAAkB,GAAG,0CAA0C,CAAC;AAC7E,MAAM,CAAC,MAAM,wBAAwB,GAAG,kBAAkB,aAAa,uCAAuC,CAAC;AAC/G,MAAM,CAAC,MAAM,wBAAwB,GAAG,0DAA0D,CAAC;AACnG,MAAM,CAAC,MAAM,qBAAqB,GAAG,0CAA0C,WAAW,UAAU,CAAC;AACrG,MAAM,CAAC,MAAM,oBAAoB,GAAG,oCAAoC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AACtG,MAAM,CAAC,MAAM,4BAA4B,GAAG,uDAAuD,CAAC;AAEpG,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAC,eAAe,CAAC,CAAC;AAIzE;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAqB;IAC1D,IAAI,KAAK,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC1E,CAAC;IACD,IAAI,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,aAAa,EAAE,CAAC;QAC5C,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,oBAAoB,EAAE,OAAO,EAAE,wBAAwB,EAAE,CAAC;IACtF,CAAC;IAED,MAAM,aAAa,GAAG,IAAI,GAAG,EAAU,CAAC;IACxC,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QACjC,IAAI,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,oBAAoB,EAAE,OAAO,EAAE,wBAAwB,EAAE,CAAC;QACtF,CAAC;QACD,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QACjC,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,WAAW,EAAE,CAAC;YACpC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,qBAAqB,EAAE,CAAC;QAC9E,CAAC;QACD,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;QACrC,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;YAC3B,IAAI,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;gBACrC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC;YAC9E,CAAC;YACD,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC7B,OAAO;oBACN,EAAE,EAAE,KAAK;oBACT,KAAK,EAAE,wBAAwB;oBAC/B,OAAO,EAAE,4BAA4B;iBACrC,CAAC;YACH,CAAC;YACD,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;IACF,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACrB,CAAC","sourcesContent":["import { MAX_QUESTIONS, MIN_OPTIONS, type QuestionnaireError, type QuestionParams, RESERVED_LABELS } from \"./types.js\";\n\nexport const ERROR_NO_QUESTIONS = \"Error: At least one question is required\";\nexport const ERROR_TOO_MANY_QUESTIONS = `Error: At most ${MAX_QUESTIONS} questions are allowed per invocation`;\nexport const ERROR_DUPLICATE_QUESTION = \"Error: Question text must be unique within an invocation\";\nexport const ERROR_TOO_FEW_OPTIONS = `Error: Each question requires at least ${MIN_OPTIONS} options`;\nexport const ERROR_RESERVED_LABEL = `Error: Option label is reserved (${RESERVED_LABELS.join(\", \")})`;\nexport const ERROR_DUPLICATE_OPTION_LABEL = \"Error: Option labels must be unique within a question\";\n\nconst RESERVED_LABEL_SET: ReadonlySet<string> = new Set(RESERVED_LABELS);\n\nexport type ValidationResult = { ok: true } | { ok: false; error: QuestionnaireError; message: string };\n\n/**\n * Pure runtime validator for `QuestionParams`. Covers every guard except\n * `no_ui` (which depends on `ctx.hasUI` and stays inline at the call site).\n * `reserved_label` MUST short-circuit before `duplicate_option_label`.\n */\nexport function validateQuestionnaire(typed: QuestionParams): ValidationResult {\n\tif (typed.questions.length === 0) {\n\t\treturn { ok: false, error: \"no_questions\", message: ERROR_NO_QUESTIONS };\n\t}\n\tif (typed.questions.length > MAX_QUESTIONS) {\n\t\treturn { ok: false, error: \"too_many_questions\", message: ERROR_TOO_MANY_QUESTIONS };\n\t}\n\n\tconst seenQuestions = new Set<string>();\n\tfor (const q of typed.questions) {\n\t\tif (seenQuestions.has(q.question)) {\n\t\t\treturn { ok: false, error: \"duplicate_question\", message: ERROR_DUPLICATE_QUESTION };\n\t\t}\n\t\tseenQuestions.add(q.question);\n\t}\n\n\tfor (const q of typed.questions) {\n\t\tif (q.options.length < MIN_OPTIONS) {\n\t\t\treturn { ok: false, error: \"empty_options\", message: ERROR_TOO_FEW_OPTIONS };\n\t\t}\n\t\tconst seenLabels = new Set<string>();\n\t\tfor (const o of q.options) {\n\t\t\tif (RESERVED_LABEL_SET.has(o.label)) {\n\t\t\t\treturn { ok: false, error: \"reserved_label\", message: ERROR_RESERVED_LABEL };\n\t\t\t}\n\t\t\tif (seenLabels.has(o.label)) {\n\t\t\t\treturn {\n\t\t\t\t\tok: false,\n\t\t\t\t\terror: \"duplicate_option_label\",\n\t\t\t\t\tmessage: ERROR_DUPLICATE_OPTION_LABEL,\n\t\t\t\t};\n\t\t\t}\n\t\t\tseenLabels.add(o.label);\n\t\t}\n\t}\n\n\treturn { ok: true };\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { Theme } from "../../../../../modes/interactive/theme/theme.js";
2
- import type { QuestionData } from "../../tool/types.ts";
2
+ import type { QuestionData } from "../../tool/types.js";
3
3
  import type { StatefulView } from "../stateful-view.ts";
4
4
  export declare const MULTI_SUBMIT_LABEL = "Submit";
5
5
  export interface MultiSelectViewProps {
@@ -1 +1 @@
1
- {"version":3,"file":"multi-select-view.js","sourceRoot":"","sources":["../../../../../../src/core/tools/ask-user-question/view/components/multi-select-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEzF,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAI5D,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,OAAO,GAAG,KAAK,CAAC;AACtB,MAAM,SAAS,GAAG,KAAK,CAAC;AACxB,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,2FAA2F;AAC3F,gGAAgG;AAChG,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AAQ3C;;;;;;;;;GASG;AACH,MAAM,OAAO,eAAe;IAM3B,YAAY,KAAY,EAAE,QAAsB;QAC/C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,K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C7F,uFAAuF;QACvF,gGAAgG;QAChG,+FAA+F;QAC/F,+FAA+F;QAC/F,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;QAC7E,OAAO,CACN,YAAY,CAAC,gBAAgB,CAAC,GAAG,WAAW,GAAG,YAAY,CAAC,GAAG,gBAAgB,GAAG,SAAS,GAAG,aAAa,EAAE,CAAC,CAC9G,CAAC;IACH,CAAC;CACD","sourcesContent":["import { truncateToWidth, visibleWidth, wrapTextWithAnsi } from \"@earendil-works/pi-tui\";\nimport type { Theme } from \"../../../../../modes/interactive/theme/theme.js\";\nimport { OVERLAY_ACTIVE_ROW_MARKER } from \"../../../../extensions/ui-types.ts\";\nimport { ROW_INTENT_META } from \"../../state/row-intent.ts\";\nimport type { QuestionData } from \"../../tool/types.ts\";\nimport type { StatefulView } from \"../stateful-view.ts\";\n\nconst ACTIVE_POINTER = \"❯ \";\nconst INACTIVE_POINTER = \" \";\nconst CHECKED = \"[✔]\";\nconst UNCHECKED = \"[ ]\";\nconst NUMBER_SEPARATOR = \". \";\nconst BOX_LABEL_GAP = \" \";\n// CC parity: description continuation indents to col 2 (past the pointer slot), NOT to the\n// full prefix column. Wrap width still uses prefixVisibleWidth so naturalHeight matches render.\nconst CONTINUATION_INDENT = \" \";\n\nexport const MULTI_SUBMIT_LABEL = \"Submit\";\n\nexport interface MultiSelectViewProps {\n\trows: ReadonlyArray<{ checked: boolean; active: boolean }>;\n\tnextActive: boolean;\n\tnextLabel: string;\n}\n\n/**\n * Renders the multi-select option list (one row per option — pointer + checkbox + label —\n * plus zero or more wrapped continuation lines per description).\n *\n * `naturalHeight(width)` is state-INDEPENDENT (depends only on theme glyph widths,\n * question.options, and width) so the host can compute a stable globalContentHeight\n * without rendering. `naturalHeight(w) === render(w).length` for every props.\n *\n * `setProps(props)` is a pure field reassignment — no render, no invalidate side effects.\n */\nexport class MultiSelectView implements StatefulView<MultiSelectViewProps> {\n\tprivate props: MultiSelectViewProps;\n\n\tprivate declare readonly theme: Theme;\n\tprivate declare readonly question: QuestionData;\n\n\tconstructor(theme: Theme, question: QuestionData) {\n\t\tthis.theme = theme;\n\t\tthis.question = question;\n\t\tthis.props = { rows: [], nextActive: false, nextLabel: ROW_INTENT_META.next.label };\n\t}\n\n\tsetProps(props: MultiSelectViewProps): void {\n\t\tthis.props = props;\n\t}\n\n\thandleInput(_data: string): void {}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst lines: string[] = [];\n\t\tconst prefixWidth = this.prefixVisibleWidth();\n\t\tconst contentWidth = Math.max(1, width - prefixWidth);\n\t\tconst numberWidth = String(Math.max(1, this.question.options.length)).length;\n\t\tfor (let i = 0; i < this.question.options.length; i++) {\n\t\t\tconst opt = this.question.options[i];\n\t\t\tconst row = this.props.rows[i];\n\t\t\tif (!opt || !row) continue;\n\t\t\tconst pointer = row.active ? this.theme.fg(\"accent\", ACTIVE_POINTER) : INACTIVE_POINTER;\n\t\t\t// Checked uses the same `accent` hue as the active-row label so checked rows read\n\t\t\t// as \"selected\" rather than \"success\" — matches the visual rhythm of the rest of\n\t\t\t// the dialog (active pointer, label, picker rows are all accent).\n\t\t\tconst box = row.checked ? this.theme.fg(\"accent\", CHECKED) : this.theme.fg(\"muted\", UNCHECKED);\n\t\t\tconst label = truncateToWidth(opt.label, contentWidth, \"…\");\n\t\t\tconst styledLabel = row.active ? this.theme.fg(\"accent\", this.theme.bold(label)) : label;\n\t\t\tconst num = String(i + 1).padStart(numberWidth, \" \");\n\t\t\tconst line = `${pointer}${num}${NUMBER_SEPARATOR}${box}${BOX_LABEL_GAP}${styledLabel}`;\n\t\t\tconst rendered = truncateToWidth(line, width, \"\");\n\t\t\tlines.push(`${rendered}${row.active ? OVERLAY_ACTIVE_ROW_MARKER : \"\"}`);\n\t\t\tif (opt.description) {\n\t\t\t\tconst wrapped = wrapTextWithAnsi(opt.description, contentWidth);\n\t\t\t\tfor (const segment of wrapped) {\n\t\t\t\t\tlines.push(CONTINUATION_INDENT + this.theme.fg(\"muted\", segment));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst nextPointer = this.props.nextActive ? this.theme.fg(\"accent\", ACTIVE_POINTER) : INACTIVE_POINTER;\n\t\tconst nextLabel = this.props.nextActive\n\t\t\t? this.theme.fg(\"accent\", this.theme.bold(this.props.nextLabel))\n\t\t\t: this.props.nextLabel;\n\t\tconst rendered = truncateToWidth(`${nextPointer}${nextLabel}`, width, \"\");\n\t\tlines.push(`${rendered}${this.props.nextActive ? OVERLAY_ACTIVE_ROW_MARKER : \"\"}`);\n\t\treturn lines;\n\t}\n\n\tnaturalHeight(width: number): number {\n\t\tconst contentWidth = Math.max(1, width - this.prefixVisibleWidth());\n\t\tlet total = 0;\n\t\tfor (const opt of this.question.options) {\n\t\t\tif (!opt) continue;\n\t\t\ttotal += 1; // row line\n\t\t\tif (opt.description) {\n\t\t\t\ttotal += wrapTextWithAnsi(opt.description, contentWidth).length;\n\t\t\t}\n\t\t}\n\t\treturn total + 1; // Next sentinel row (no description; never wraps).\n\t}\n\n\tprivate prefixVisibleWidth(): number {\n\t\t// Canonical prefix for OPTION rows: INACTIVE_POINTER + numberWidth digits + NUMBER_SEPARATOR\n\t\t// + UNCHECKED + BOX_LABEL_GAP. State-independent because ACTIVE/INACTIVE pointer share\n\t\t// visibleWidth, CHECKED/UNCHECKED share visibleWidth, and numberWidth is constant per question.\n\t\t// The Next sentinel uses a bare `pointer + \"Next\"` shape — its width never exceeds this prefix\n\t\t// at any reasonable terminal width, so it's safe to leave it out of the canonical computation.\n\t\tconst numberWidth = String(Math.max(1, this.question.options.length)).length;\n\t\treturn (\n\t\t\tvisibleWidth(INACTIVE_POINTER) + numberWidth + visibleWidth(`${NUMBER_SEPARATOR}${UNCHECKED}${BOX_LABEL_GAP}`)\n\t\t);\n\t}\n}\n"]}
1
+ {"version":3,"file":"multi-select-view.js","sourceRoot":"","sources":["../../../../../../src/core/tools/ask-user-question/view/components/multi-select-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEzF,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAI5D,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,OAAO,GAAG,KAAK,CAAC;AACtB,MAAM,SAAS,GAAG,KAAK,CAAC;AACxB,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,2FAA2F;AAC3F,gGAAgG;AAChG,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AAQ3C;;;;;;;;;GASG;AACH,MAAM,OAAO,eAAe;IAM3B,YAAY,KAAY,EAAE,QAAsB;QAC/C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IACrF,CAAC;IAED,QAAQ,CAAC,KAA2B;QACnC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,CAAC;IAED,WAAW,CAAC,KAAa,IAAS,CAAC;IAEnC,UAAU,KAAU,CAAC;IAErB,MAAM,CAAC,KAAa;QACnB,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,MAAM,WAAW,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC9C,MAAM,YAAY,GAAG,IAAI,CA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";\nimport type { Theme } from \"../../../../../modes/interactive/theme/theme.js\";\nimport { OVERLAY_ACTIVE_ROW_MARKER } from \"../../../../extensions/ui-types.js\";\nimport { ROW_INTENT_META } from \"../../state/row-intent.ts\";\nimport type { QuestionData } from \"../../tool/types.js\";\nimport type { StatefulView } from \"../stateful-view.ts\";\n\nconst ACTIVE_POINTER = \"❯ \";\nconst INACTIVE_POINTER = \" \";\nconst CHECKED = \"[✔]\";\nconst UNCHECKED = \"[ ]\";\nconst NUMBER_SEPARATOR = \". \";\nconst BOX_LABEL_GAP = \" \";\n// CC parity: description continuation indents to col 2 (past the pointer slot), NOT to the\n// full prefix column. Wrap width still uses prefixVisibleWidth so naturalHeight matches render.\nconst CONTINUATION_INDENT = \" \";\n\nexport const MULTI_SUBMIT_LABEL = \"Submit\";\n\nexport interface MultiSelectViewProps {\n\trows: ReadonlyArray<{ checked: boolean; active: boolean }>;\n\tnextActive: boolean;\n\tnextLabel: string;\n}\n\n/**\n * Renders the multi-select option list (one row per option — pointer + checkbox + label —\n * plus zero or more wrapped continuation lines per description).\n *\n * `naturalHeight(width)` is state-INDEPENDENT (depends only on theme glyph widths,\n * question.options, and width) so the host can compute a stable globalContentHeight\n * without rendering. `naturalHeight(w) === render(w).length` for every props.\n *\n * `setProps(props)` is a pure field reassignment — no render, no invalidate side effects.\n */\nexport class MultiSelectView implements StatefulView<MultiSelectViewProps> {\n\tprivate props: MultiSelectViewProps;\n\n\tprivate declare readonly theme: Theme;\n\tprivate declare readonly question: QuestionData;\n\n\tconstructor(theme: Theme, question: QuestionData) {\n\t\tthis.theme = theme;\n\t\tthis.question = question;\n\t\tthis.props = { rows: [], nextActive: false, nextLabel: ROW_INTENT_META.next.label };\n\t}\n\n\tsetProps(props: MultiSelectViewProps): void {\n\t\tthis.props = props;\n\t}\n\n\thandleInput(_data: string): void {}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tconst lines: string[] = [];\n\t\tconst prefixWidth = this.prefixVisibleWidth();\n\t\tconst contentWidth = Math.max(1, width - prefixWidth);\n\t\tconst numberWidth = String(Math.max(1, this.question.options.length)).length;\n\t\tfor (let i = 0; i < this.question.options.length; i++) {\n\t\t\tconst opt = this.question.options[i];\n\t\t\tconst row = this.props.rows[i];\n\t\t\tif (!opt || !row) continue;\n\t\t\tconst pointer = row.active ? this.theme.fg(\"accent\", ACTIVE_POINTER) : INACTIVE_POINTER;\n\t\t\t// Checked uses the same `accent` hue as the active-row label so checked rows read\n\t\t\t// as \"selected\" rather than \"success\" — matches the visual rhythm of the rest of\n\t\t\t// the dialog (active pointer, label, picker rows are all accent).\n\t\t\tconst box = row.checked ? this.theme.fg(\"accent\", CHECKED) : this.theme.fg(\"muted\", UNCHECKED);\n\t\t\tconst label = truncateToWidth(opt.label, contentWidth, \"…\");\n\t\t\tconst styledLabel = row.active ? this.theme.fg(\"accent\", this.theme.bold(label)) : label;\n\t\t\tconst num = String(i + 1).padStart(numberWidth, \" \");\n\t\t\tconst line = `${pointer}${num}${NUMBER_SEPARATOR}${box}${BOX_LABEL_GAP}${styledLabel}`;\n\t\t\tconst rendered = truncateToWidth(line, width, \"\");\n\t\t\tlines.push(`${rendered}${row.active ? OVERLAY_ACTIVE_ROW_MARKER : \"\"}`);\n\t\t\tif (opt.description) {\n\t\t\t\tconst wrapped = wrapTextWithAnsi(opt.description, contentWidth);\n\t\t\t\tfor (const segment of wrapped) {\n\t\t\t\t\tlines.push(CONTINUATION_INDENT + this.theme.fg(\"muted\", segment));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst nextPointer = this.props.nextActive ? this.theme.fg(\"accent\", ACTIVE_POINTER) : INACTIVE_POINTER;\n\t\tconst nextLabel = this.props.nextActive\n\t\t\t? this.theme.fg(\"accent\", this.theme.bold(this.props.nextLabel))\n\t\t\t: this.props.nextLabel;\n\t\tconst rendered = truncateToWidth(`${nextPointer}${nextLabel}`, width, \"\");\n\t\tlines.push(`${rendered}${this.props.nextActive ? OVERLAY_ACTIVE_ROW_MARKER : \"\"}`);\n\t\treturn lines;\n\t}\n\n\tnaturalHeight(width: number): number {\n\t\tconst contentWidth = Math.max(1, width - this.prefixVisibleWidth());\n\t\tlet total = 0;\n\t\tfor (const opt of this.question.options) {\n\t\t\tif (!opt) continue;\n\t\t\ttotal += 1; // row line\n\t\t\tif (opt.description) {\n\t\t\t\ttotal += wrapTextWithAnsi(opt.description, contentWidth).length;\n\t\t\t}\n\t\t}\n\t\treturn total + 1; // Next sentinel row (no description; never wraps).\n\t}\n\n\tprivate prefixVisibleWidth(): number {\n\t\t// Canonical prefix for OPTION rows: INACTIVE_POINTER + numberWidth digits + NUMBER_SEPARATOR\n\t\t// + UNCHECKED + BOX_LABEL_GAP. State-independent because ACTIVE/INACTIVE pointer share\n\t\t// visibleWidth, CHECKED/UNCHECKED share visibleWidth, and numberWidth is constant per question.\n\t\t// The Next sentinel uses a bare `pointer + \"Next\"` shape — its width never exceeds this prefix\n\t\t// at any reasonable terminal width, so it's safe to leave it out of the canonical computation.\n\t\tconst numberWidth = String(Math.max(1, this.question.options.length)).length;\n\t\treturn (\n\t\t\tvisibleWidth(INACTIVE_POINTER) + numberWidth + visibleWidth(`${NUMBER_SEPARATOR}${UNCHECKED}${BOX_LABEL_GAP}`)\n\t\t);\n\t}\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { type MarkdownTheme } from "@earendil-works/pi-tui";
2
2
  import type { Theme } from "../../../../../../modes/interactive/theme/theme.js";
3
- import type { QuestionData } from "../../../tool/types.ts";
3
+ import type { QuestionData } from "../../../tool/types.js";
4
4
  /** CC parity in side-by-side layout. */
5
5
  export declare const MAX_PREVIEW_HEIGHT_SIDE_BY_SIDE = 20;
6
6
  /** Preserves narrow-terminal protection in stacked layout. */
@@ -1 +1 @@
1
- {"version":3,"file":"markdown-content-cache.js","sourceRoot":"","sources":["../../../../../../../src/core/tools/ask-user-question/view/components/preview/markdown-content-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAs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../../../../../modes/interactive/theme/theme.js\";\nimport type { QuestionData } from \"../../../tool/types.ts\";\nimport { stripFenceMarkers } from \"./preview-box-renderer.ts\";\n\n/** CC parity in side-by-side layout. */\nexport const MAX_PREVIEW_HEIGHT_SIDE_BY_SIDE = 20;\n/** Preserves narrow-terminal protection in stacked layout. */\nexport const MAX_PREVIEW_HEIGHT_STACKED = 15;\nexport const NO_PREVIEW_TEXT = \"No preview available\";\n/** 1 blank separator + 1 affordance text row reserved when `hasAnyPreview` (height stability of the affordance row's offset relative to the box). */\nexport const NOTES_AFFORDANCE_OVERHEAD = 2;\n\n/**\n * Per-question cache for rendered markdown previews. Width-keyed: switching the\n * inner width invalidates every cached `Markdown`'s render output (pi-tui's\n * `Markdown.render(width)` re-wraps when width changes).\n *\n * Replaces the inline `previewTexts`, `markdownCache`, `cachedWidth` triple from\n * the previous monolithic `preview-pane.ts`. One Markdown per option, lazy on\n * first request, never re-constructed — count semantics frozen by tests.\n */\nexport class MarkdownContentCache {\n\tprivate readonly previewTexts: Map<number, string>;\n\tprivate readonly markdownCache: Map<number, Markdown>;\n\tprivate cachedWidth: number | undefined;\n\tprivate readonly theme: Theme;\n\tprivate readonly markdownTheme: MarkdownTheme;\n\n\tconstructor(question: QuestionData, theme: Theme, markdownTheme: MarkdownTheme) {\n\t\tthis.theme = theme;\n\t\tthis.markdownTheme = markdownTheme;\n\t\tthis.previewTexts = new Map();\n\t\tfor (let i = 0; i < question.options.length; i++) {\n\t\t\tconst raw = question.options[i]?.preview;\n\t\t\tif (raw && raw.length > 0) this.previewTexts.set(i, raw);\n\t\t}\n\t\tthis.markdownCache = new Map();\n\t}\n\n\thasAnyPreview(): boolean {\n\t\treturn this.previewTexts.size > 0;\n\t}\n\n\thas(optionIndex: number): boolean {\n\t\treturn this.previewTexts.has(optionIndex);\n\t}\n\n\t/**\n\t * Compute the body lines for a given option at a given inner width. Width changes\n\t * invalidate the per-Markdown render cache.\n\t */\n\tbodyFor(optionIndex: number, innerWidth: number): string[] {\n\t\tif (this.cachedWidth !== innerWidth) {\n\t\t\tfor (const md of this.markdownCache.values()) md.invalidate();\n\t\t\tthis.cachedWidth = innerWidth;\n\t\t}\n\t\tconst text = this.previewTexts.get(optionIndex);\n\t\tif (!text) {\n\t\t\tconst placeholder = this.theme.fg(\"dim\", NO_PREVIEW_TEXT);\n\t\t\tconst pad = Math.max(0, innerWidth - visibleWidth(placeholder));\n\t\t\treturn [placeholder + \" \".repeat(pad)];\n\t\t}\n\t\tlet md = this.markdownCache.get(optionIndex);\n\t\tif (!md) {\n\t\t\tmd = new Markdown(text, 0, 0, this.markdownTheme);\n\t\t\tthis.markdownCache.set(optionIndex, md);\n\t\t}\n\t\treturn stripFenceMarkers(md.render(innerWidth));\n\t}\n\n\tinvalidate(): void {\n\t\tfor (const md of this.markdownCache.values()) md.invalidate();\n\t\tthis.cachedWidth = undefined;\n\t}\n}\n"]}
1
+ {"version":3,"file":"markdown-content-cache.js","sourceRoot":"","sources":["../../../../../../../src/core/tools/ask-user-question/view/components/preview/markdown-content-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAsB,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,wCAAwC;AACxC,MAAM,CAAC,MAAM,+BAA+B,GAAG,EAAE,CAAC;AAClD,8DAA8D;AAC9D,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAC;AAC7C,MAAM,CAAC,MAAM,eAAe,GAAG,sBAAsB,CAAC;AACtD,qJAAqJ;AACrJ,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAE3C;;;;;;;;GAQG;AACH,MAAM,OAAO,oBAAoB;IAOhC,YAAY,QAAsB,EAAE,KAAY,EAAE,aAA4B;QAC7E,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC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,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACxC,CAAC;QACD,IAAI,EAAE,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC7C,IAAI,CAAC,EAAE,EAAE,CAAC;YACT,EAAE,GAAG,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;YAClD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,iBAAiB,CAAC,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,UAAU;QACT,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;YAAE,EAAE,CAAC,UAAU,EAAE,CAAC;QAC9D,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;IAC9B,CAAC;CACD","sourcesContent":["import { Markdown, type MarkdownTheme, visibleWidth } from \"@earendil-works/pi-tui\";\nimport type { Theme } from \"../../../../../../modes/interactive/theme/theme.js\";\nimport type { QuestionData } from \"../../../tool/types.js\";\nimport { stripFenceMarkers } from \"./preview-box-renderer.ts\";\n\n/** CC parity in side-by-side layout. */\nexport const MAX_PREVIEW_HEIGHT_SIDE_BY_SIDE = 20;\n/** Preserves narrow-terminal protection in stacked layout. */\nexport const MAX_PREVIEW_HEIGHT_STACKED = 15;\nexport const NO_PREVIEW_TEXT = \"No preview available\";\n/** 1 blank separator + 1 affordance text row reserved when `hasAnyPreview` (height stability of the affordance row's offset relative to the box). */\nexport const NOTES_AFFORDANCE_OVERHEAD = 2;\n\n/**\n * Per-question cache for rendered markdown previews. Width-keyed: switching the\n * inner width invalidates every cached `Markdown`'s render output (pi-tui's\n * `Markdown.render(width)` re-wraps when width changes).\n *\n * Replaces the inline `previewTexts`, `markdownCache`, `cachedWidth` triple from\n * the previous monolithic `preview-pane.ts`. One Markdown per option, lazy on\n * first request, never re-constructed — count semantics frozen by tests.\n */\nexport class MarkdownContentCache {\n\tprivate readonly previewTexts: Map<number, string>;\n\tprivate readonly markdownCache: Map<number, Markdown>;\n\tprivate cachedWidth: number | undefined;\n\tprivate readonly theme: Theme;\n\tprivate readonly markdownTheme: MarkdownTheme;\n\n\tconstructor(question: QuestionData, theme: Theme, markdownTheme: MarkdownTheme) {\n\t\tthis.theme = theme;\n\t\tthis.markdownTheme = markdownTheme;\n\t\tthis.previewTexts = new Map();\n\t\tfor (let i = 0; i < question.options.length; i++) {\n\t\t\tconst raw = question.options[i]?.preview;\n\t\t\tif (raw && raw.length > 0) this.previewTexts.set(i, raw);\n\t\t}\n\t\tthis.markdownCache = new Map();\n\t}\n\n\thasAnyPreview(): boolean {\n\t\treturn this.previewTexts.size > 0;\n\t}\n\n\thas(optionIndex: number): boolean {\n\t\treturn this.previewTexts.has(optionIndex);\n\t}\n\n\t/**\n\t * Compute the body lines for a given option at a given inner width. Width changes\n\t * invalidate the per-Markdown render cache.\n\t */\n\tbodyFor(optionIndex: number, innerWidth: number): string[] {\n\t\tif (this.cachedWidth !== innerWidth) {\n\t\t\tfor (const md of this.markdownCache.values()) md.invalidate();\n\t\t\tthis.cachedWidth = innerWidth;\n\t\t}\n\t\tconst text = this.previewTexts.get(optionIndex);\n\t\tif (!text) {\n\t\t\tconst placeholder = this.theme.fg(\"dim\", NO_PREVIEW_TEXT);\n\t\t\tconst pad = Math.max(0, innerWidth - visibleWidth(placeholder));\n\t\t\treturn [placeholder + \" \".repeat(pad)];\n\t\t}\n\t\tlet md = this.markdownCache.get(optionIndex);\n\t\tif (!md) {\n\t\t\tmd = new Markdown(text, 0, 0, this.markdownTheme);\n\t\t\tthis.markdownCache.set(optionIndex, md);\n\t\t}\n\t\treturn stripFenceMarkers(md.render(innerWidth));\n\t}\n\n\tinvalidate(): void {\n\t\tfor (const md of this.markdownCache.values()) md.invalidate();\n\t\tthis.cachedWidth = undefined;\n\t}\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { MarkdownTheme } from "@earendil-works/pi-tui";
2
2
  import type { Theme } from "../../../../../../modes/interactive/theme/theme.js";
3
- import type { QuestionData } from "../../../tool/types.ts";
3
+ import type { QuestionData } from "../../../tool/types.js";
4
4
  import type { PreviewLayoutMode } from "./preview-layout-decider.ts";
5
5
  /**
6
6
  * Affordance text shown below the bordered preview when focused on a preview-bearing option.
@@ -1 +1 @@
1
- {"version":3,"file":"preview-block-renderer.js","sourceRoot":"","sources":["../../../../../../../src/core/tools/ask-user-question/view/components/preview/preview-block-renderer.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,+BAA+B,EAC/B,0BAA0B,EAC1B,oBAAoB,EACpB,yBAAyB,GACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,0BAA0B,EAC1B,+BAA+B,EAC/B,wBAAwB,EACxB,oBAAoB,EACpB,iBAAiB,GACjB,MAAM,2BAA2B,CAAC;AAGnC;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAQ1D;;;;;;;;;GASG;AACH,MAAM,OAAO,oBAAoB;IAIhC,YAAY,MAAkC;QAC7C,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,oBAAoB,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;IAC5F,CAAC;IAED,aAAa;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;IACnC,CAAC;IAED,GAAG,CAAC,WAAmB;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACpC,CAAC;IAED,UAAU;QACT,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,KAAa,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,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1D,MAAM,YAAY,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QAEnE,MAAM,EAAE,QAAQ,EAAE,GAAG,oBAAoB,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;QACvE,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QAC1D,MAAM,UAAU,GAAG,iBAAiB,CAAC,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAE9E,MAAM,cAAc,GAAG,OAAO,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC/E,MAAM,UAAU,GAAG,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACvF,OAAO,CAAC,GAAG,UAAU,EAAE,EAAE,EAAE,UAAU,CAAC,CAAC;IACxC,CAAC;CACD","sourcesContent":["import type { MarkdownTheme } from \"@earendil-works/pi-tui\";\nimport type { Theme } from \"../../../../../../modes/interactive/theme/theme.js\";\nimport type { QuestionData } from \"../../../tool/types.ts\";\nimport {\n\tMAX_PREVIEW_HEIGHT_SIDE_BY_SIDE,\n\tMAX_PREVIEW_HEIGHT_STACKED,\n\tMarkdownContentCache,\n\tNOTES_AFFORDANCE_OVERHEAD,\n} from \"./markdown-content-cache.ts\";\nimport {\n\tBORDER_HORIZONTAL_OVERHEAD,\n\tBORDER_INNER_PADDING_HORIZONTAL,\n\tBORDER_VERTICAL_OVERHEAD,\n\tcomputeBoxDimensions,\n\trenderBorderedBox,\n} from \"./preview-box-renderer.ts\";\nimport type { PreviewLayoutMode } from \"./preview-layout-decider.ts\";\n\n/**\n * Affordance text shown below the bordered preview when focused on a preview-bearing option.\n * Re-exported by `preview-pane.ts` for the existing test surface.\n */\nexport const NOTES_AFFORDANCE_TEXT = \"Notes: n add notes\";\n\nexport interface PreviewBlockRendererConfig {\n\tquestion: QuestionData;\n\ttheme: Theme;\n\tmarkdownTheme: MarkdownTheme;\n}\n\n/**\n * Renders the bordered markdown preview block for a single question (one block per render call,\n * for the option at `optionIndex`). Owns a per-question `MarkdownContentCache`.\n *\n * NOT a `Component` — pure render-and-measure helper consumed by `PreviewPane`. The layout mode\n * is threaded as an explicit param (never re-derived from column width post-split).\n *\n * The affordance row is always emitted (visually empty when gated) so the preview block's row\n * count is height-stable across affordance-state transitions.\n */\nexport class PreviewBlockRenderer {\n\tprivate readonly theme: Theme;\n\tprivate readonly cache: MarkdownContentCache;\n\n\tconstructor(config: PreviewBlockRendererConfig) {\n\t\tthis.theme = config.theme;\n\t\tthis.cache = new MarkdownContentCache(config.question, config.theme, config.markdownTheme);\n\t}\n\n\thasAnyPreview(): boolean {\n\t\treturn this.cache.hasAnyPreview();\n\t}\n\n\thas(optionIndex: number): boolean {\n\t\treturn this.cache.has(optionIndex);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.cache.invalidate();\n\t}\n\n\t/**\n\t * Height contribution of the preview block: `BORDER_VERTICAL_OVERHEAD + contentRows +\n\t * NOTES_AFFORDANCE_OVERHEAD`. Always returns the same value as `renderBlock(...).length`\n\t * — the affordance overhead is constant, not gated by `focused`/`notesVisible`.\n\t */\n\tblockHeight(width: number, optionIndex: number, mode: PreviewLayoutMode): number {\n\t\tconst cap = mode === \"side-by-side\" ? MAX_PREVIEW_HEIGHT_SIDE_BY_SIDE : MAX_PREVIEW_HEIGHT_STACKED;\n\t\tconst contentBudget = Math.max(1, cap - BORDER_VERTICAL_OVERHEAD - NOTES_AFFORDANCE_OVERHEAD);\n\t\tconst innerWidth = Math.max(1, width - BORDER_HORIZONTAL_OVERHEAD - 2 * BORDER_INNER_PADDING_HORIZONTAL);\n\t\tconst rawRows = this.cache.bodyFor(optionIndex, innerWidth).length;\n\t\tconst contentRows = Math.min(rawRows, contentBudget);\n\t\treturn BORDER_VERTICAL_OVERHEAD + contentRows + NOTES_AFFORDANCE_OVERHEAD;\n\t}\n\n\t/**\n\t * Render the full preview block at `width`: bordered box + blank separator + affordance row.\n\t * `focused` and `notesVisible` together gate the affordance text (visible only when the\n\t * focused option carries a preview AND notes mode is inactive). The affordance row is ALWAYS\n\t * emitted (as an empty string when gated) so the row count is invariant.\n\t */\n\trenderBlock(\n\t\twidth: number,\n\t\toptionIndex: number,\n\t\tmode: PreviewLayoutMode,\n\t\tfocused: boolean,\n\t\tnotesVisible: boolean,\n\t): string[] {\n\t\tconst cap = mode === \"side-by-side\" ? MAX_PREVIEW_HEIGHT_SIDE_BY_SIDE : MAX_PREVIEW_HEIGHT_STACKED;\n\t\tconst contentBudget = Math.max(1, cap - BORDER_VERTICAL_OVERHEAD - NOTES_AFFORDANCE_OVERHEAD);\n\t\tconst maxInnerWidth = Math.max(1, width - BORDER_HORIZONTAL_OVERHEAD - 2 * BORDER_INNER_PADDING_HORIZONTAL);\n\n\t\tconst raw = this.cache.bodyFor(optionIndex, maxInnerWidth);\n\t\tconst truncated = raw.length > contentBudget;\n\t\tconst hidden = truncated ? raw.length - contentBudget : 0;\n\t\tconst contentLines = truncated ? raw.slice(0, contentBudget) : raw;\n\n\t\tconst { boxWidth } = computeBoxDimensions(contentLines, maxInnerWidth);\n\t\tconst colorFn = (s: string) => this.theme.fg(\"accent\", s);\n\t\tconst boxedLines = renderBorderedBox(contentLines, boxWidth, colorFn, hidden);\n\n\t\tconst showAffordance = focused && !notesVisible && this.cache.has(optionIndex);\n\t\tconst affordance = showAffordance ? this.theme.fg(\"muted\", NOTES_AFFORDANCE_TEXT) : \"\";\n\t\treturn [...boxedLines, \"\", affordance];\n\t}\n}\n"]}
1
+ {"version":3,"file":"preview-block-renderer.js","sourceRoot":"","sources":["../../../../../../../src/core/tools/ask-user-question/view/components/preview/preview-block-renderer.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,+BAA+B,EAC/B,0BAA0B,EAC1B,oBAAoB,EACpB,yBAAyB,GACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,0BAA0B,EAC1B,+BAA+B,EAC/B,wBAAwB,EACxB,oBAAoB,EACpB,iBAAiB,GACjB,MAAM,2BAA2B,CAAC;AAGnC;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAQ1D;;;;;;;;;GASG;AACH,MAAM,OAAO,oBAAoB;IAIhC,YAAY,MAAkC;QAC7C,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,oBAAoB,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;IAC5F,CAAC;IAED,aAAa;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;IACnC,CAAC;IAED,GAAG,CAAC,WAAmB;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACpC,CAAC;IAED,UAAU;QACT,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,KAAa,EAAE,WAAmB,EAAE,IAAuB;QACtE,MAAM,GAAG,GAAG,IAAI,KAAK,cAAc,CAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC,0BAA0B,CAAC;QACnG,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,GAAG,wBAAwB,GAAG,yBAAyB,CAAC,CAAC;QAC9F,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GA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AE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QAC1D,MAAM,UAAU,GAAG,iBAAiB,CAAC,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAE9E,MAAM,cAAc,GAAG,OAAO,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC/E,MAAM,UAAU,GAAG,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACvF,OAAO,CAAC,GAAG,UAAU,EAAE,EAAE,EAAE,UAAU,CAAC,CAAC;IACxC,CAAC;CACD","sourcesContent":["import type { MarkdownTheme } from \"@earendil-works/pi-tui\";\nimport type { Theme } from \"../../../../../../modes/interactive/theme/theme.js\";\nimport type { QuestionData } from \"../../../tool/types.js\";\nimport {\n\tMAX_PREVIEW_HEIGHT_SIDE_BY_SIDE,\n\tMAX_PREVIEW_HEIGHT_STACKED,\n\tMarkdownContentCache,\n\tNOTES_AFFORDANCE_OVERHEAD,\n} from \"./markdown-content-cache.ts\";\nimport {\n\tBORDER_HORIZONTAL_OVERHEAD,\n\tBORDER_INNER_PADDING_HORIZONTAL,\n\tBORDER_VERTICAL_OVERHEAD,\n\tcomputeBoxDimensions,\n\trenderBorderedBox,\n} from \"./preview-box-renderer.ts\";\nimport type { PreviewLayoutMode } from \"./preview-layout-decider.ts\";\n\n/**\n * Affordance text shown below the bordered preview when focused on a preview-bearing option.\n * Re-exported by `preview-pane.ts` for the existing test surface.\n */\nexport const NOTES_AFFORDANCE_TEXT = \"Notes: n add notes\";\n\nexport interface PreviewBlockRendererConfig {\n\tquestion: QuestionData;\n\ttheme: Theme;\n\tmarkdownTheme: MarkdownTheme;\n}\n\n/**\n * Renders the bordered markdown preview block for a single question (one block per render call,\n * for the option at `optionIndex`). Owns a per-question `MarkdownContentCache`.\n *\n * NOT a `Component` — pure render-and-measure helper consumed by `PreviewPane`. The layout mode\n * is threaded as an explicit param (never re-derived from column width post-split).\n *\n * The affordance row is always emitted (visually empty when gated) so the preview block's row\n * count is height-stable across affordance-state transitions.\n */\nexport class PreviewBlockRenderer {\n\tprivate readonly theme: Theme;\n\tprivate readonly cache: MarkdownContentCache;\n\n\tconstructor(config: PreviewBlockRendererConfig) {\n\t\tthis.theme = config.theme;\n\t\tthis.cache = new MarkdownContentCache(config.question, config.theme, config.markdownTheme);\n\t}\n\n\thasAnyPreview(): boolean {\n\t\treturn this.cache.hasAnyPreview();\n\t}\n\n\thas(optionIndex: number): boolean {\n\t\treturn this.cache.has(optionIndex);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.cache.invalidate();\n\t}\n\n\t/**\n\t * Height contribution of the preview block: `BORDER_VERTICAL_OVERHEAD + contentRows +\n\t * NOTES_AFFORDANCE_OVERHEAD`. Always returns the same value as `renderBlock(...).length`\n\t * — the affordance overhead is constant, not gated by `focused`/`notesVisible`.\n\t */\n\tblockHeight(width: number, optionIndex: number, mode: PreviewLayoutMode): number {\n\t\tconst cap = mode === \"side-by-side\" ? MAX_PREVIEW_HEIGHT_SIDE_BY_SIDE : MAX_PREVIEW_HEIGHT_STACKED;\n\t\tconst contentBudget = Math.max(1, cap - BORDER_VERTICAL_OVERHEAD - NOTES_AFFORDANCE_OVERHEAD);\n\t\tconst innerWidth = Math.max(1, width - BORDER_HORIZONTAL_OVERHEAD - 2 * BORDER_INNER_PADDING_HORIZONTAL);\n\t\tconst rawRows = this.cache.bodyFor(optionIndex, innerWidth).length;\n\t\tconst contentRows = Math.min(rawRows, contentBudget);\n\t\treturn BORDER_VERTICAL_OVERHEAD + contentRows + NOTES_AFFORDANCE_OVERHEAD;\n\t}\n\n\t/**\n\t * Render the full preview block at `width`: bordered box + blank separator + affordance row.\n\t * `focused` and `notesVisible` together gate the affordance text (visible only when the\n\t * focused option carries a preview AND notes mode is inactive). The affordance row is ALWAYS\n\t * emitted (as an empty string when gated) so the row count is invariant.\n\t */\n\trenderBlock(\n\t\twidth: number,\n\t\toptionIndex: number,\n\t\tmode: PreviewLayoutMode,\n\t\tfocused: boolean,\n\t\tnotesVisible: boolean,\n\t): string[] {\n\t\tconst cap = mode === \"side-by-side\" ? MAX_PREVIEW_HEIGHT_SIDE_BY_SIDE : MAX_PREVIEW_HEIGHT_STACKED;\n\t\tconst contentBudget = Math.max(1, cap - BORDER_VERTICAL_OVERHEAD - NOTES_AFFORDANCE_OVERHEAD);\n\t\tconst maxInnerWidth = Math.max(1, width - BORDER_HORIZONTAL_OVERHEAD - 2 * BORDER_INNER_PADDING_HORIZONTAL);\n\n\t\tconst raw = this.cache.bodyFor(optionIndex, maxInnerWidth);\n\t\tconst truncated = raw.length > contentBudget;\n\t\tconst hidden = truncated ? raw.length - contentBudget : 0;\n\t\tconst contentLines = truncated ? raw.slice(0, contentBudget) : raw;\n\n\t\tconst { boxWidth } = computeBoxDimensions(contentLines, maxInnerWidth);\n\t\tconst colorFn = (s: string) => this.theme.fg(\"accent\", s);\n\t\tconst boxedLines = renderBorderedBox(contentLines, boxWidth, colorFn, hidden);\n\n\t\tconst showAffordance = focused && !notesVisible && this.cache.has(optionIndex);\n\t\tconst affordance = showAffordance ? this.theme.fg(\"muted\", NOTES_AFFORDANCE_TEXT) : \"\";\n\t\treturn [...boxedLines, \"\", affordance];\n\t}\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { QuestionData } from "../../../tool/types.ts";
1
+ import type { QuestionData } from "../../../tool/types.js";
2
2
  import type { WrappingSelectItem } from "../wrapping-select.ts";
3
3
  /** Min terminal/pane width for the side-by-side layout to engage. */
4
4
  export declare const PREVIEW_MIN_WIDTH = 100;
@@ -1 +1 @@
1
- {"version":3,"file":"preview-layout-decider.js","sourceRoot":"","sources":["../../../../../../../src/core/tools/ask-user-question/view/components/preview/preview-layout-decider.ts"],"names":[],"mappings":"AA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{ visibleWidth } from \"@earendil-works/pi-tui\";\nimport type { QuestionData } from \"../../../tool/types.ts\";\nimport type { WrappingSelectItem } from \"../wrapping-select.ts\";\nimport { BORDER_HORIZONTAL_OVERHEAD, BORDER_INNER_PADDING_HORIZONTAL } from \"./preview-box-renderer.ts\";\n\n/** Min terminal/pane width for the side-by-side layout to engage. */\nexport const PREVIEW_MIN_WIDTH = 100;\n/** Visual gap between options column and preview column in side-by-side. */\nexport const PREVIEW_COLUMN_GAP = 2;\n/** 1 col padding inside the preview column (between gap and `│`). */\nexport const PREVIEW_PADDING_LEFT = 1;\n/** Empty rows between options and preview blocks in stacked (narrow) layout. */\nexport const STACKED_GAP_ROWS = 1;\n\n/** Floor for the adaptive left column width — prevents collapse on short labels. */\nexport const MIN_LEFT = 30;\n/** Ceiling ratio: left column never exceeds this fraction of pane width. */\nexport const MAX_LEFT_RATIO = 0.5;\n/** Floor for the preview column width — prevents right-side collapse on narrow terminals. */\nexport const MIN_PREVIEW_WIDTH = 45;\n/** visibleWidth(\" ✔\") = 2 (space + ✔ codepoint). Reserved on the longest-label measurement\n * so a confirmed row never gets truncated when MIN_LEFT clamps the column. */\nexport const CONFIRMED_OVERHEAD = 2;\n\nexport type PreviewLayoutMode = \"side-by-side\" | \"stacked\";\n\n/**\n * Decide layout mode from terminal + pane widths. Pure of inputs.\n *\n * The terminal-width gate is the AND check from the previous `preview-pane.ts` —\n * lifted here so the decision is computed ONCE per render and threaded explicitly\n * through `previewBlockHeight`. Removes the bug class where `previewBlockHeight`\n * re-derived `sideBySide` from a column width (already < pane width post-split),\n * capping height too short.\n */\nexport function decideLayout(terminalWidth: number, paneWidth: number): PreviewLayoutMode {\n\treturn terminalWidth >= PREVIEW_MIN_WIDTH && paneWidth >= PREVIEW_MIN_WIDTH ? \"side-by-side\" : \"stacked\";\n}\n\n/**\n * Compute the adaptive left column width from option labels.\n * Pure function — deterministic for a given (items, totalForNumbering, paneWidth).\n *\n * Pipeline:\n * 1. Measure: longest visible label width + prefix overhead + confirmed-mark overhead\n * 2. Clamp: floor MIN_LEFT, ceiling paneWidth * MAX_LEFT_RATIO\n * 3. Safety net: never exceed available = paneWidth - GAP - MIN_PREVIEW_WIDTH\n */\nexport function adaptiveLeftWidth(\n\titems: readonly WrappingSelectItem[],\n\ttotalForNumbering: number,\n\tpaneWidth: number,\n): number {\n\tconst prefixW = String(Math.max(1, totalForNumbering)).length + 4; // digits + \"❯ \" + \". \"\n\tconst confirmedOverhead = CONFIRMED_OVERHEAD; // visibleWidth(\" ✔\") = 2 (space + ✔ codepoint)\n\tlet maxLabel = 0;\n\tfor (const item of items) {\n\t\tconst w = visibleWidth(item.label);\n\t\tif (w > maxLabel) maxLabel = w;\n\t}\n\tconst desired = maxLabel + prefixW + confirmedOverhead;\n\tconst ratioCapped = Math.min(desired, Math.floor(paneWidth * MAX_LEFT_RATIO));\n\tconst available = paneWidth - PREVIEW_COLUMN_GAP - MIN_PREVIEW_WIDTH;\n\treturn Math.max(MIN_LEFT, Math.min(ratioCapped, Math.max(1, available)));\n}\n\n/**\n * Cross-tab maximum left-column width. Aggregates `adaptiveLeftWidth` over every tab\n * and returns the widest result, so the options column stays stable on tab switch.\n *\n * Pure function — `tabs.length` MUST equal `itemsByTab.length`. Multi-select tabs\n * use `items.length` for numbering; single-select tabs add 1 for the chat row slot.\n * Floor is `MIN_LEFT` so an all-empty input still produces a usable column.\n */\nexport function crossTabMaxLeftWidth(\n\ttabs: ReadonlyArray<{ multiSelect?: boolean }>,\n\titemsByTab: ReadonlyArray<readonly WrappingSelectItem[]>,\n\tpaneWidth: number,\n): number {\n\tlet max = MIN_LEFT;\n\tfor (let i = 0; i < tabs.length; i++) {\n\t\tconst items = itemsByTab[i] ?? [];\n\t\tconst totalForNumbering = tabs[i]?.multiSelect ? items.length : items.length + 1;\n\t\tconst tabWidth = adaptiveLeftWidth(items, totalForNumbering, paneWidth);\n\t\tif (tabWidth > max) max = tabWidth;\n\t}\n\treturn max;\n}\n\n/**\n * Source-line probe: measures the widest source line across all options' previews.\n * Returns 0 when no option carries a preview.\n *\n * V1 heuristic — works well for tree/table/heading/list content where source-line\n * width ≈ rendered width. Paragraphs overstate (source width \"wants\" the full pane);\n * the worst case is \"donation does nothing useful\" — fallback to the label-driven path.\n * Upgrade path: replace with a render-width probe that invokes Markdown at a probe width.\n *\n * Pure function — O(total chars) per question; no Markdown invocation, no cache interaction.\n */\nexport function previewSourceWidth(question: QuestionData): number {\n\tlet max = 0;\n\tfor (const option of question.options) {\n\t\tconst text = option.preview;\n\t\tif (!text) continue;\n\t\tfor (const line of text.split(\"\\n\")) {\n\t\t\tconst w = visibleWidth(line);\n\t\t\tif (w > max) max = w;\n\t\t}\n\t}\n\treturn max;\n}\n\n/**\n * Cross-tab/cross-option preview budget. Iterates all questions, computes each question's\n * preview appetite via `previewSourceWidth`, adds box + padding overhead (5 cols), and\n * returns the widest result. Floor is `MIN_PREVIEW_WIDTH` so a previewless question still\n * reserves a usable column. Ceiling ensures the left column retains its `MIN_LEFT` floor.\n *\n * Pure function — same cross-tab max pattern as `crossTabMaxLeftWidth`.\n */\nexport function crossTabPreviewBudget(questions: readonly QuestionData[], paneWidth: number): number {\n\tlet max = MIN_PREVIEW_WIDTH;\n\tfor (const question of questions) {\n\t\tconst rawWidth = previewSourceWidth(question);\n\t\tconst capped = Math.min(rawWidth, paneWidth - PREVIEW_COLUMN_GAP - MIN_LEFT);\n\t\tconst budget = capped + BORDER_HORIZONTAL_OVERHEAD + 2 * BORDER_INNER_PADDING_HORIZONTAL + PREVIEW_PADDING_LEFT;\n\t\tif (budget > max) max = budget;\n\t}\n\treturn max;\n}\n\n/**\n * Cross-tab left-column width with slack donation. Combines the label-driven width\n * (from `crossTabMaxLeftWidth`) with the slack donated by narrow previews.\n *\n * Pipeline:\n * 1. `labelDriven` = `crossTabMaxLeftWidth(tabs, itemsByTab, paneWidth)`\n * 2. `previewBudget` = `crossTabPreviewBudget(questions, paneWidth)`\n * 3. `slackDonation` = `paneWidth − GAP − previewBudget`\n * 4. Return `min(max(labelDriven, slackDonation), ceiling)` where `ceiling = paneWidth − GAP − MIN_PREVIEW_WIDTH`\n *\n * Invariants:\n * - Floor: result ≥ MIN_LEFT (labelDriven ≥ MIN_LEFT)\n * - Preview floor: right column ≥ MIN_PREVIEW_WIDTH (ceiling enforces this)\n * - Cross-tab stability: both reductions are tab-independent\n * - Determinism: pure of (questions, itemsByTab, paneWidth)\n *\n * `crossTabMaxLeftWidth` is NOT replaced — it continues to exist as the primitive.\n * `MAX_LEFT_RATIO` caps the label-driven path inside `adaptiveLeftWidth`; donation\n * operates above the cap when preview slack is available.\n */\nexport function crossTabLeftWidthWithDonation(\n\ttabs: ReadonlyArray<{ multiSelect?: boolean }>,\n\titemsByTab: ReadonlyArray<readonly WrappingSelectItem[]>,\n\tquestions: readonly QuestionData[],\n\tpaneWidth: number,\n): number {\n\tconst labelDriven = crossTabMaxLeftWidth(tabs, itemsByTab, paneWidth);\n\t// Compact-content guard: labels at MIN_LEFT fit below the floor, so widening\n\t// the column would only inject dead space between the option list and the\n\t// preview box. Skip donation and preserve the compact intent.\n\tif (labelDriven <= MIN_LEFT) return labelDriven;\n\tconst previewBudget = crossTabPreviewBudget(questions, paneWidth);\n\tconst slackDonation = paneWidth - PREVIEW_COLUMN_GAP - previewBudget;\n\tconst ceiling = paneWidth - PREVIEW_COLUMN_GAP - MIN_PREVIEW_WIDTH;\n\treturn Math.min(Math.max(labelDriven, slackDonation), Math.max(1, ceiling));\n}\n\n/**\n * Width allocation for side-by-side mode.\n * `adaptiveLeft` is the pre-computed left column width (from `adaptiveLeftWidth`,\n * cross-tab aggregated). The Math.max(1, ...) calls keep both columns >= 1 col on\n * extreme inputs.\n */\nexport function columnWidths(\n\tpaneWidth: number,\n\tadaptiveLeft: number,\n): { leftWidth: number; rightWidth: number; gap: number } {\n\tconst gap = PREVIEW_COLUMN_GAP;\n\tconst leftWidth = Math.min(adaptiveLeft, Math.max(1, paneWidth - gap - 1));\n\tconst rightWidth = Math.max(1, paneWidth - leftWidth - gap);\n\treturn { leftWidth, rightWidth, gap };\n}\n\n/**\n * Returns the widths actually passed to `options.render` and `previewLines` inside\n * `render()`. Stacked uses the full pane width for both; side-by-side splits via\n * `columnWidths`, with the preview column offset by `PREVIEW_PADDING_LEFT`.\n */\nexport function bodyWidths(\n\tpaneWidth: number,\n\tmode: PreviewLayoutMode,\n\tadaptiveLeft: number,\n): { optionsWidth: number; previewWidth: number } {\n\tif (mode === \"stacked\") return { optionsWidth: paneWidth, previewWidth: paneWidth };\n\tconst { leftWidth, rightWidth } = columnWidths(paneWidth, adaptiveLeft);\n\treturn { optionsWidth: leftWidth, previewWidth: Math.max(1, rightWidth - PREVIEW_PADDING_LEFT) };\n}\n"]}
1
+ {"version":3,"file":"preview-layout-decider.js","sourceRoot":"","sources":["../../../../../../../src/core/tools/ask-user-question/view/components/preview/preview-layout-decider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGtD,OAAO,EAAE,0BAA0B,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAExG,qEAAqE;AACrE,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AACrC,4EAA4E;AAC5E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AACpC,qEAAqE;AACrE,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AACtC,gFAAgF;AAChF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC,oFAAoF;AACpF,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,CAAC;AAC3B,4EAA4E;AAC5E,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAC;AAClC,6FAA6F;AAC7F,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACpC;+EAC+E;AAC/E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAIpC;;;;;;;;GAQG;AAC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,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,GAAG,CAAC,CAAC;IAC5D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC;AACvC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CACzB,SAAiB,EACjB,IAAuB,EACvB,YAAoB;IAEpB,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;IACpF,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,YAAY,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IACxE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,GAAG,oBAAoB,CAAC,EAAE,CAAC;AAClG,CAAC","sourcesContent":["import { visibleWidth } from \"@earendil-works/pi-tui\";\nimport type { QuestionData } from \"../../../tool/types.js\";\nimport type { WrappingSelectItem } from \"../wrapping-select.ts\";\nimport { BORDER_HORIZONTAL_OVERHEAD, BORDER_INNER_PADDING_HORIZONTAL } from \"./preview-box-renderer.ts\";\n\n/** Min terminal/pane width for the side-by-side layout to engage. */\nexport const PREVIEW_MIN_WIDTH = 100;\n/** Visual gap between options column and preview column in side-by-side. */\nexport const PREVIEW_COLUMN_GAP = 2;\n/** 1 col padding inside the preview column (between gap and `│`). */\nexport const PREVIEW_PADDING_LEFT = 1;\n/** Empty rows between options and preview blocks in stacked (narrow) layout. */\nexport const STACKED_GAP_ROWS = 1;\n\n/** Floor for the adaptive left column width — prevents collapse on short labels. */\nexport const MIN_LEFT = 30;\n/** Ceiling ratio: left column never exceeds this fraction of pane width. */\nexport const MAX_LEFT_RATIO = 0.5;\n/** Floor for the preview column width — prevents right-side collapse on narrow terminals. */\nexport const MIN_PREVIEW_WIDTH = 45;\n/** visibleWidth(\" ✔\") = 2 (space + ✔ codepoint). Reserved on the longest-label measurement\n * so a confirmed row never gets truncated when MIN_LEFT clamps the column. */\nexport const CONFIRMED_OVERHEAD = 2;\n\nexport type PreviewLayoutMode = \"side-by-side\" | \"stacked\";\n\n/**\n * Decide layout mode from terminal + pane widths. Pure of inputs.\n *\n * The terminal-width gate is the AND check from the previous `preview-pane.ts` —\n * lifted here so the decision is computed ONCE per render and threaded explicitly\n * through `previewBlockHeight`. Removes the bug class where `previewBlockHeight`\n * re-derived `sideBySide` from a column width (already < pane width post-split),\n * capping height too short.\n */\nexport function decideLayout(terminalWidth: number, paneWidth: number): PreviewLayoutMode {\n\treturn terminalWidth >= PREVIEW_MIN_WIDTH && paneWidth >= PREVIEW_MIN_WIDTH ? \"side-by-side\" : \"stacked\";\n}\n\n/**\n * Compute the adaptive left column width from option labels.\n * Pure function — deterministic for a given (items, totalForNumbering, paneWidth).\n *\n * Pipeline:\n * 1. Measure: longest visible label width + prefix overhead + confirmed-mark overhead\n * 2. Clamp: floor MIN_LEFT, ceiling paneWidth * MAX_LEFT_RATIO\n * 3. Safety net: never exceed available = paneWidth - GAP - MIN_PREVIEW_WIDTH\n */\nexport function adaptiveLeftWidth(\n\titems: readonly WrappingSelectItem[],\n\ttotalForNumbering: number,\n\tpaneWidth: number,\n): number {\n\tconst prefixW = String(Math.max(1, totalForNumbering)).length + 4; // digits + \"❯ \" + \". \"\n\tconst confirmedOverhead = CONFIRMED_OVERHEAD; // visibleWidth(\" ✔\") = 2 (space + ✔ codepoint)\n\tlet maxLabel = 0;\n\tfor (const item of items) {\n\t\tconst w = visibleWidth(item.label);\n\t\tif (w > maxLabel) maxLabel = w;\n\t}\n\tconst desired = maxLabel + prefixW + confirmedOverhead;\n\tconst ratioCapped = Math.min(desired, Math.floor(paneWidth * MAX_LEFT_RATIO));\n\tconst available = paneWidth - PREVIEW_COLUMN_GAP - MIN_PREVIEW_WIDTH;\n\treturn Math.max(MIN_LEFT, Math.min(ratioCapped, Math.max(1, available)));\n}\n\n/**\n * Cross-tab maximum left-column width. Aggregates `adaptiveLeftWidth` over every tab\n * and returns the widest result, so the options column stays stable on tab switch.\n *\n * Pure function — `tabs.length` MUST equal `itemsByTab.length`. Multi-select tabs\n * use `items.length` for numbering; single-select tabs add 1 for the chat row slot.\n * Floor is `MIN_LEFT` so an all-empty input still produces a usable column.\n */\nexport function crossTabMaxLeftWidth(\n\ttabs: ReadonlyArray<{ multiSelect?: boolean }>,\n\titemsByTab: ReadonlyArray<readonly WrappingSelectItem[]>,\n\tpaneWidth: number,\n): number {\n\tlet max = MIN_LEFT;\n\tfor (let i = 0; i < tabs.length; i++) {\n\t\tconst items = itemsByTab[i] ?? [];\n\t\tconst totalForNumbering = tabs[i]?.multiSelect ? items.length : items.length + 1;\n\t\tconst tabWidth = adaptiveLeftWidth(items, totalForNumbering, paneWidth);\n\t\tif (tabWidth > max) max = tabWidth;\n\t}\n\treturn max;\n}\n\n/**\n * Source-line probe: measures the widest source line across all options' previews.\n * Returns 0 when no option carries a preview.\n *\n * V1 heuristic — works well for tree/table/heading/list content where source-line\n * width ≈ rendered width. Paragraphs overstate (source width \"wants\" the full pane);\n * the worst case is \"donation does nothing useful\" — fallback to the label-driven path.\n * Upgrade path: replace with a render-width probe that invokes Markdown at a probe width.\n *\n * Pure function — O(total chars) per question; no Markdown invocation, no cache interaction.\n */\nexport function previewSourceWidth(question: QuestionData): number {\n\tlet max = 0;\n\tfor (const option of question.options) {\n\t\tconst text = option.preview;\n\t\tif (!text) continue;\n\t\tfor (const line of text.split(\"\\n\")) {\n\t\t\tconst w = visibleWidth(line);\n\t\t\tif (w > max) max = w;\n\t\t}\n\t}\n\treturn max;\n}\n\n/**\n * Cross-tab/cross-option preview budget. Iterates all questions, computes each question's\n * preview appetite via `previewSourceWidth`, adds box + padding overhead (5 cols), and\n * returns the widest result. Floor is `MIN_PREVIEW_WIDTH` so a previewless question still\n * reserves a usable column. Ceiling ensures the left column retains its `MIN_LEFT` floor.\n *\n * Pure function — same cross-tab max pattern as `crossTabMaxLeftWidth`.\n */\nexport function crossTabPreviewBudget(questions: readonly QuestionData[], paneWidth: number): number {\n\tlet max = MIN_PREVIEW_WIDTH;\n\tfor (const question of questions) {\n\t\tconst rawWidth = previewSourceWidth(question);\n\t\tconst capped = Math.min(rawWidth, paneWidth - PREVIEW_COLUMN_GAP - MIN_LEFT);\n\t\tconst budget = capped + BORDER_HORIZONTAL_OVERHEAD + 2 * BORDER_INNER_PADDING_HORIZONTAL + PREVIEW_PADDING_LEFT;\n\t\tif (budget > max) max = budget;\n\t}\n\treturn max;\n}\n\n/**\n * Cross-tab left-column width with slack donation. Combines the label-driven width\n * (from `crossTabMaxLeftWidth`) with the slack donated by narrow previews.\n *\n * Pipeline:\n * 1. `labelDriven` = `crossTabMaxLeftWidth(tabs, itemsByTab, paneWidth)`\n * 2. `previewBudget` = `crossTabPreviewBudget(questions, paneWidth)`\n * 3. `slackDonation` = `paneWidth − GAP − previewBudget`\n * 4. Return `min(max(labelDriven, slackDonation), ceiling)` where `ceiling = paneWidth − GAP − MIN_PREVIEW_WIDTH`\n *\n * Invariants:\n * - Floor: result ≥ MIN_LEFT (labelDriven ≥ MIN_LEFT)\n * - Preview floor: right column ≥ MIN_PREVIEW_WIDTH (ceiling enforces this)\n * - Cross-tab stability: both reductions are tab-independent\n * - Determinism: pure of (questions, itemsByTab, paneWidth)\n *\n * `crossTabMaxLeftWidth` is NOT replaced — it continues to exist as the primitive.\n * `MAX_LEFT_RATIO` caps the label-driven path inside `adaptiveLeftWidth`; donation\n * operates above the cap when preview slack is available.\n */\nexport function crossTabLeftWidthWithDonation(\n\ttabs: ReadonlyArray<{ multiSelect?: boolean }>,\n\titemsByTab: ReadonlyArray<readonly WrappingSelectItem[]>,\n\tquestions: readonly QuestionData[],\n\tpaneWidth: number,\n): number {\n\tconst labelDriven = crossTabMaxLeftWidth(tabs, itemsByTab, paneWidth);\n\t// Compact-content guard: labels at MIN_LEFT fit below the floor, so widening\n\t// the column would only inject dead space between the option list and the\n\t// preview box. Skip donation and preserve the compact intent.\n\tif (labelDriven <= MIN_LEFT) return labelDriven;\n\tconst previewBudget = crossTabPreviewBudget(questions, paneWidth);\n\tconst slackDonation = paneWidth - PREVIEW_COLUMN_GAP - previewBudget;\n\tconst ceiling = paneWidth - PREVIEW_COLUMN_GAP - MIN_PREVIEW_WIDTH;\n\treturn Math.min(Math.max(labelDriven, slackDonation), Math.max(1, ceiling));\n}\n\n/**\n * Width allocation for side-by-side mode.\n * `adaptiveLeft` is the pre-computed left column width (from `adaptiveLeftWidth`,\n * cross-tab aggregated). The Math.max(1, ...) calls keep both columns >= 1 col on\n * extreme inputs.\n */\nexport function columnWidths(\n\tpaneWidth: number,\n\tadaptiveLeft: number,\n): { leftWidth: number; rightWidth: number; gap: number } {\n\tconst gap = PREVIEW_COLUMN_GAP;\n\tconst leftWidth = Math.min(adaptiveLeft, Math.max(1, paneWidth - gap - 1));\n\tconst rightWidth = Math.max(1, paneWidth - leftWidth - gap);\n\treturn { leftWidth, rightWidth, gap };\n}\n\n/**\n * Returns the widths actually passed to `options.render` and `previewLines` inside\n * `render()`. Stacked uses the full pane width for both; side-by-side splits via\n * `columnWidths`, with the preview column offset by `PREVIEW_PADDING_LEFT`.\n */\nexport function bodyWidths(\n\tpaneWidth: number,\n\tmode: PreviewLayoutMode,\n\tadaptiveLeft: number,\n): { optionsWidth: number; previewWidth: number } {\n\tif (mode === \"stacked\") return { optionsWidth: paneWidth, previewWidth: paneWidth };\n\tconst { leftWidth, rightWidth } = columnWidths(paneWidth, adaptiveLeft);\n\treturn { optionsWidth: leftWidth, previewWidth: Math.max(1, rightWidth - PREVIEW_PADDING_LEFT) };\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { type Component } from "@earendil-works/pi-tui";
2
- import type { QuestionData } from "../../../tool/types.ts";
2
+ import type { QuestionData } from "../../../tool/types.js";
3
3
  import type { StatefulView } from "../../stateful-view.ts";
4
4
  import type { OptionListView } from "../option-list-view.ts";
5
5
  import type { PreviewBlockRenderer } from "./preview-block-renderer.ts";