@caupulican/pi-adaptative 0.81.39 → 0.81.40

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 (667) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +2 -0
  3. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +2 -0
  4. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -1
  5. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +2 -0
  6. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -1
  7. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +3 -0
  8. package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts +9 -0
  9. package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
  10. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +290 -107
  11. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
  12. package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +357 -122
  13. package/dist/bundled-resources/skills/tool-call-repair/references/repair-catalogue.md +2 -2
  14. package/dist/cli/args.d.ts +2 -0
  15. package/dist/cli/args.d.ts.map +1 -1
  16. package/dist/cli/args.js +9 -0
  17. package/dist/cli/args.js.map +1 -1
  18. package/dist/core/agent-directory-layout.d.ts +15 -0
  19. package/dist/core/agent-directory-layout.d.ts.map +1 -0
  20. package/dist/core/agent-directory-layout.js +72 -0
  21. package/dist/core/agent-directory-layout.js.map +1 -0
  22. package/dist/core/agent-paths.d.ts +19 -2
  23. package/dist/core/agent-paths.d.ts.map +1 -1
  24. package/dist/core/agent-paths.js +67 -4
  25. package/dist/core/agent-paths.js.map +1 -1
  26. package/dist/core/agent-session-runtime.d.ts +52 -8
  27. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  28. package/dist/core/agent-session-runtime.js +397 -79
  29. package/dist/core/agent-session-runtime.js.map +1 -1
  30. package/dist/core/agent-session-services.d.ts +1 -0
  31. package/dist/core/agent-session-services.d.ts.map +1 -1
  32. package/dist/core/agent-session-services.js +1 -0
  33. package/dist/core/agent-session-services.js.map +1 -1
  34. package/dist/core/agent-session.d.ts +71 -136
  35. package/dist/core/agent-session.d.ts.map +1 -1
  36. package/dist/core/agent-session.js +477 -1318
  37. package/dist/core/agent-session.js.map +1 -1
  38. package/dist/core/autonomy/approval-gate.d.ts +3 -2
  39. package/dist/core/autonomy/approval-gate.d.ts.map +1 -1
  40. package/dist/core/autonomy/approval-gate.js +6 -28
  41. package/dist/core/autonomy/approval-gate.js.map +1 -1
  42. package/dist/core/autonomy/bounded-completion.d.ts +1 -1
  43. package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
  44. package/dist/core/autonomy/bounded-completion.js +1 -1
  45. package/dist/core/autonomy/bounded-completion.js.map +1 -1
  46. package/dist/core/autonomy/contracts.d.ts +20 -12
  47. package/dist/core/autonomy/contracts.d.ts.map +1 -1
  48. package/dist/core/autonomy/contracts.js.map +1 -1
  49. package/dist/core/autonomy/foreground-envelope.d.ts +8 -2
  50. package/dist/core/autonomy/foreground-envelope.d.ts.map +1 -1
  51. package/dist/core/autonomy/foreground-envelope.js +8 -25
  52. package/dist/core/autonomy/foreground-envelope.js.map +1 -1
  53. package/dist/core/autonomy/gates.d.ts.map +1 -1
  54. package/dist/core/autonomy/gates.js +8 -10
  55. package/dist/core/autonomy/gates.js.map +1 -1
  56. package/dist/core/autonomy/lane-private-paths.d.ts +2 -0
  57. package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -0
  58. package/dist/core/autonomy/lane-private-paths.js +16 -0
  59. package/dist/core/autonomy/lane-private-paths.js.map +1 -0
  60. package/dist/core/autonomy/lane-tool-surface.d.ts +10 -0
  61. package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
  62. package/dist/core/autonomy/lane-tool-surface.js +46 -8
  63. package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
  64. package/dist/core/autonomy/lane-tracker.d.ts +14 -0
  65. package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
  66. package/dist/core/autonomy/lane-tracker.js +38 -0
  67. package/dist/core/autonomy/lane-tracker.js.map +1 -1
  68. package/dist/core/autonomy/risk-assessment.d.ts +1 -2
  69. package/dist/core/autonomy/risk-assessment.d.ts.map +1 -1
  70. package/dist/core/autonomy/risk-assessment.js +1 -123
  71. package/dist/core/autonomy/risk-assessment.js.map +1 -1
  72. package/dist/core/autonomy/session-lane-record.d.ts +4 -4
  73. package/dist/core/autonomy/session-lane-record.d.ts.map +1 -1
  74. package/dist/core/autonomy/session-lane-record.js +16 -29
  75. package/dist/core/autonomy/session-lane-record.js.map +1 -1
  76. package/dist/core/autonomy/telemetry-events.d.ts +1 -1
  77. package/dist/core/autonomy/telemetry-events.d.ts.map +1 -1
  78. package/dist/core/autonomy/telemetry-events.js +1 -1
  79. package/dist/core/autonomy/telemetry-events.js.map +1 -1
  80. package/dist/core/autonomy-telemetry.d.ts +7 -7
  81. package/dist/core/autonomy-telemetry.d.ts.map +1 -1
  82. package/dist/core/autonomy-telemetry.js +9 -9
  83. package/dist/core/autonomy-telemetry.js.map +1 -1
  84. package/dist/core/background-lane-controller.d.ts +54 -236
  85. package/dist/core/background-lane-controller.d.ts.map +1 -1
  86. package/dist/core/background-lane-controller.js +140 -1273
  87. package/dist/core/background-lane-controller.js.map +1 -1
  88. package/dist/core/capability-contract.d.ts +4 -0
  89. package/dist/core/capability-contract.d.ts.map +1 -0
  90. package/dist/core/capability-contract.js +28 -0
  91. package/dist/core/capability-contract.js.map +1 -0
  92. package/dist/core/compaction-controller.d.ts +90 -0
  93. package/dist/core/compaction-controller.d.ts.map +1 -0
  94. package/dist/core/compaction-controller.js +452 -0
  95. package/dist/core/compaction-controller.js.map +1 -0
  96. package/dist/core/compaction-support.d.ts +12 -11
  97. package/dist/core/compaction-support.d.ts.map +1 -1
  98. package/dist/core/compaction-support.js.map +1 -1
  99. package/dist/core/context/context-artifacts.d.ts +6 -2
  100. package/dist/core/context/context-artifacts.d.ts.map +1 -1
  101. package/dist/core/context/context-artifacts.js +34 -2
  102. package/dist/core/context/context-artifacts.js.map +1 -1
  103. package/dist/core/context/context-store-retention.d.ts +8 -2
  104. package/dist/core/context/context-store-retention.d.ts.map +1 -1
  105. package/dist/core/context/context-store-retention.js +158 -35
  106. package/dist/core/context/context-store-retention.js.map +1 -1
  107. package/dist/core/context/okf-memory.d.ts.map +1 -1
  108. package/dist/core/context/okf-memory.js +9 -11
  109. package/dist/core/context/okf-memory.js.map +1 -1
  110. package/dist/core/context/sqlite-runtime-index.d.ts.map +1 -1
  111. package/dist/core/context/sqlite-runtime-index.js +6 -8
  112. package/dist/core/context/sqlite-runtime-index.js.map +1 -1
  113. package/dist/core/context-gc.d.ts +3 -0
  114. package/dist/core/context-gc.d.ts.map +1 -1
  115. package/dist/core/context-gc.js +10 -5
  116. package/dist/core/context-gc.js.map +1 -1
  117. package/dist/core/context-pipeline.d.ts.map +1 -1
  118. package/dist/core/context-pipeline.js +9 -4
  119. package/dist/core/context-pipeline.js.map +1 -1
  120. package/dist/core/default-tool-surface.d.ts.map +1 -1
  121. package/dist/core/default-tool-surface.js +1 -0
  122. package/dist/core/default-tool-surface.js.map +1 -1
  123. package/dist/core/delegation/managed-lane-controller.d.ts +34 -0
  124. package/dist/core/delegation/managed-lane-controller.d.ts.map +1 -0
  125. package/dist/core/delegation/managed-lane-controller.js +217 -0
  126. package/dist/core/delegation/managed-lane-controller.js.map +1 -0
  127. package/dist/core/delegation/session-worker-claim.d.ts +44 -0
  128. package/dist/core/delegation/session-worker-claim.d.ts.map +1 -0
  129. package/dist/core/delegation/session-worker-claim.js +98 -0
  130. package/dist/core/delegation/session-worker-claim.js.map +1 -0
  131. package/dist/core/delegation/worker-actions.d.ts +7 -5
  132. package/dist/core/delegation/worker-actions.d.ts.map +1 -1
  133. package/dist/core/delegation/worker-actions.js +20 -4
  134. package/dist/core/delegation/worker-actions.js.map +1 -1
  135. package/dist/core/delegation/{worker-result.d.ts → worker-claim.d.ts} +13 -13
  136. package/dist/core/delegation/worker-claim.d.ts.map +1 -0
  137. package/dist/core/delegation/{worker-result.js → worker-claim.js} +61 -51
  138. package/dist/core/delegation/worker-claim.js.map +1 -0
  139. package/dist/core/delegation/worker-delegation-controller.d.ts +110 -0
  140. package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -0
  141. package/dist/core/delegation/worker-delegation-controller.js +861 -0
  142. package/dist/core/delegation/worker-delegation-controller.js.map +1 -0
  143. package/dist/core/delegation/worker-delegation-request.d.ts +11 -0
  144. package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -0
  145. package/dist/core/delegation/worker-delegation-request.js +2 -0
  146. package/dist/core/delegation/worker-delegation-request.js.map +1 -0
  147. package/dist/core/delegation/worker-dispatch-scheduler.d.ts +40 -0
  148. package/dist/core/delegation/worker-dispatch-scheduler.d.ts.map +1 -0
  149. package/dist/core/delegation/worker-dispatch-scheduler.js +93 -0
  150. package/dist/core/delegation/worker-dispatch-scheduler.js.map +1 -0
  151. package/dist/core/delegation/worker-execution-policy.d.ts +62 -0
  152. package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -0
  153. package/dist/core/delegation/worker-execution-policy.js +160 -0
  154. package/dist/core/delegation/worker-execution-policy.js.map +1 -0
  155. package/dist/core/delegation/worker-lane-projection.d.ts +14 -0
  156. package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -0
  157. package/dist/core/delegation/worker-lane-projection.js +100 -0
  158. package/dist/core/delegation/worker-lane-projection.js.map +1 -0
  159. package/dist/core/delegation/worker-lifecycle.d.ts +97 -0
  160. package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -0
  161. package/dist/core/delegation/worker-lifecycle.js +339 -0
  162. package/dist/core/delegation/worker-lifecycle.js.map +1 -0
  163. package/dist/core/delegation/worker-notification-coordinator.d.ts +36 -0
  164. package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -0
  165. package/dist/core/delegation/worker-notification-coordinator.js +90 -0
  166. package/dist/core/delegation/worker-notification-coordinator.js.map +1 -0
  167. package/dist/core/delegation/worker-profile-resolver.d.ts +55 -0
  168. package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -0
  169. package/dist/core/delegation/worker-profile-resolver.js +113 -0
  170. package/dist/core/delegation/worker-profile-resolver.js.map +1 -0
  171. package/dist/core/delegation/worker-runner.d.ts +25 -14
  172. package/dist/core/delegation/worker-runner.d.ts.map +1 -1
  173. package/dist/core/delegation/worker-runner.js +122 -53
  174. package/dist/core/delegation/worker-runner.js.map +1 -1
  175. package/dist/core/delegation/worker-task-label.d.ts +3 -0
  176. package/dist/core/delegation/worker-task-label.d.ts.map +1 -0
  177. package/dist/core/delegation/worker-task-label.js +11 -0
  178. package/dist/core/delegation/worker-task-label.js.map +1 -0
  179. package/dist/core/doctor.d.ts +8 -0
  180. package/dist/core/doctor.d.ts.map +1 -1
  181. package/dist/core/doctor.js +32 -1
  182. package/dist/core/doctor.js.map +1 -1
  183. package/dist/core/extensions/index.d.ts +1 -1
  184. package/dist/core/extensions/index.d.ts.map +1 -1
  185. package/dist/core/extensions/index.js.map +1 -1
  186. package/dist/core/extensions/loader.d.ts +5 -1
  187. package/dist/core/extensions/loader.d.ts.map +1 -1
  188. package/dist/core/extensions/loader.js +50 -15
  189. package/dist/core/extensions/loader.js.map +1 -1
  190. package/dist/core/extensions/runner.d.ts.map +1 -1
  191. package/dist/core/extensions/runner.js +6 -0
  192. package/dist/core/extensions/runner.js.map +1 -1
  193. package/dist/core/extensions/storage.d.ts +8 -0
  194. package/dist/core/extensions/storage.d.ts.map +1 -0
  195. package/dist/core/extensions/storage.js +28 -0
  196. package/dist/core/extensions/storage.js.map +1 -0
  197. package/dist/core/extensions/types.d.ts +70 -21
  198. package/dist/core/extensions/types.d.ts.map +1 -1
  199. package/dist/core/extensions/types.js.map +1 -1
  200. package/dist/core/failure-corpus.d.ts +1 -15
  201. package/dist/core/failure-corpus.d.ts.map +1 -1
  202. package/dist/core/failure-corpus.js +9 -37
  203. package/dist/core/failure-corpus.js.map +1 -1
  204. package/dist/core/foreground-recovery-controller.d.ts +52 -0
  205. package/dist/core/foreground-recovery-controller.d.ts.map +1 -0
  206. package/dist/core/foreground-recovery-controller.js +111 -0
  207. package/dist/core/foreground-recovery-controller.js.map +1 -0
  208. package/dist/core/gateways/channel-provider.d.ts +3 -0
  209. package/dist/core/gateways/channel-provider.d.ts.map +1 -1
  210. package/dist/core/gateways/channel-provider.js +31 -6
  211. package/dist/core/gateways/channel-provider.js.map +1 -1
  212. package/dist/core/goals/goal-acceptance.d.ts +11 -0
  213. package/dist/core/goals/goal-acceptance.d.ts.map +1 -0
  214. package/dist/core/goals/goal-acceptance.js +25 -0
  215. package/dist/core/goals/goal-acceptance.js.map +1 -0
  216. package/dist/core/goals/goal-auto-continue-controller.d.ts +27 -0
  217. package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -0
  218. package/dist/core/goals/goal-auto-continue-controller.js +93 -0
  219. package/dist/core/goals/goal-auto-continue-controller.js.map +1 -0
  220. package/dist/core/goals/goal-continuation-controller.d.ts +1 -1
  221. package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
  222. package/dist/core/goals/goal-continuation-controller.js +10 -0
  223. package/dist/core/goals/goal-continuation-controller.js.map +1 -1
  224. package/dist/core/goals/goal-continuation-prompt.d.ts +1 -1
  225. package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
  226. package/dist/core/goals/goal-continuation-prompt.js +6 -6
  227. package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
  228. package/dist/core/goals/goal-lifecycle.d.ts +20 -0
  229. package/dist/core/goals/goal-lifecycle.d.ts.map +1 -0
  230. package/dist/core/goals/goal-lifecycle.js +17 -0
  231. package/dist/core/goals/goal-lifecycle.js.map +1 -0
  232. package/dist/core/goals/goal-runtime-snapshot.d.ts +11 -9
  233. package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
  234. package/dist/core/goals/goal-runtime-snapshot.js +10 -8
  235. package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
  236. package/dist/core/goals/goal-state.d.ts +1 -0
  237. package/dist/core/goals/goal-state.d.ts.map +1 -1
  238. package/dist/core/goals/goal-state.js +7 -10
  239. package/dist/core/goals/goal-state.js.map +1 -1
  240. package/dist/core/goals/goal-tool-core.d.ts +8 -6
  241. package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
  242. package/dist/core/goals/goal-tool-core.js +11 -41
  243. package/dist/core/goals/goal-tool-core.js.map +1 -1
  244. package/dist/core/goals/session-goal-state.d.ts +2 -4
  245. package/dist/core/goals/session-goal-state.d.ts.map +1 -1
  246. package/dist/core/goals/session-goal-state.js +10 -33
  247. package/dist/core/goals/session-goal-state.js.map +1 -1
  248. package/dist/core/human-input.d.ts +100 -0
  249. package/dist/core/human-input.d.ts.map +1 -0
  250. package/dist/core/human-input.js +362 -0
  251. package/dist/core/human-input.js.map +1 -0
  252. package/dist/core/index.d.ts +9 -1
  253. package/dist/core/index.d.ts.map +1 -1
  254. package/dist/core/index.js +9 -1
  255. package/dist/core/index.js.map +1 -1
  256. package/dist/core/{telemetry.d.ts → install-telemetry.d.ts} +1 -1
  257. package/dist/core/install-telemetry.d.ts.map +1 -0
  258. package/dist/core/{telemetry.js → install-telemetry.js} +1 -1
  259. package/dist/core/install-telemetry.js.map +1 -0
  260. package/dist/core/keybindings.d.ts +17 -1
  261. package/dist/core/keybindings.d.ts.map +1 -1
  262. package/dist/core/keybindings.js +24 -6
  263. package/dist/core/keybindings.js.map +1 -1
  264. package/dist/core/learning/learning-audit.d.ts +2 -4
  265. package/dist/core/learning/learning-audit.d.ts.map +1 -1
  266. package/dist/core/learning/learning-audit.js +9 -29
  267. package/dist/core/learning/learning-audit.js.map +1 -1
  268. package/dist/core/learning/learning-gate.d.ts.map +1 -1
  269. package/dist/core/learning/learning-gate.js +1 -6
  270. package/dist/core/learning/learning-gate.js.map +1 -1
  271. package/dist/core/learning/session-learning-decision.d.ts +2 -4
  272. package/dist/core/learning/session-learning-decision.d.ts.map +1 -1
  273. package/dist/core/learning/session-learning-decision.js +9 -29
  274. package/dist/core/learning/session-learning-decision.js.map +1 -1
  275. package/dist/core/memory-controller.d.ts.map +1 -1
  276. package/dist/core/memory-controller.js +4 -4
  277. package/dist/core/memory-controller.js.map +1 -1
  278. package/dist/core/model-capability.d.ts.map +1 -1
  279. package/dist/core/model-capability.js +1 -0
  280. package/dist/core/model-capability.js.map +1 -1
  281. package/dist/core/model-resolver.d.ts +1 -1
  282. package/dist/core/model-resolver.d.ts.map +1 -1
  283. package/dist/core/model-resolver.js +6 -9
  284. package/dist/core/model-resolver.js.map +1 -1
  285. package/dist/core/model-router/intent-classifier.d.ts +1 -4
  286. package/dist/core/model-router/intent-classifier.d.ts.map +1 -1
  287. package/dist/core/model-router/intent-classifier.js +1 -156
  288. package/dist/core/model-router/intent-classifier.js.map +1 -1
  289. package/dist/core/model-router-controller.d.ts.map +1 -1
  290. package/dist/core/model-router-controller.js +2 -2
  291. package/dist/core/model-router-controller.js.map +1 -1
  292. package/dist/core/model-selection-controller.d.ts +4 -4
  293. package/dist/core/model-selection-controller.d.ts.map +1 -1
  294. package/dist/core/model-selection-controller.js.map +1 -1
  295. package/dist/core/model-tool-protocol.d.ts +23 -0
  296. package/dist/core/model-tool-protocol.d.ts.map +1 -0
  297. package/dist/core/model-tool-protocol.js +43 -0
  298. package/dist/core/model-tool-protocol.js.map +1 -0
  299. package/dist/core/models/adaptation-store.d.ts +4 -6
  300. package/dist/core/models/adaptation-store.d.ts.map +1 -1
  301. package/dist/core/models/adaptation-store.js +95 -83
  302. package/dist/core/models/adaptation-store.js.map +1 -1
  303. package/dist/core/models/fitness-store.d.ts +2 -12
  304. package/dist/core/models/fitness-store.d.ts.map +1 -1
  305. package/dist/core/models/fitness-store.js +84 -57
  306. package/dist/core/models/fitness-store.js.map +1 -1
  307. package/dist/core/models/host-state-store.d.ts +34 -0
  308. package/dist/core/models/host-state-store.d.ts.map +1 -0
  309. package/dist/core/models/host-state-store.js +86 -0
  310. package/dist/core/models/host-state-store.js.map +1 -0
  311. package/dist/core/orchestration/agent-resume.d.ts +24 -0
  312. package/dist/core/orchestration/agent-resume.d.ts.map +1 -0
  313. package/dist/core/orchestration/agent-resume.js +90 -0
  314. package/dist/core/orchestration/agent-resume.js.map +1 -0
  315. package/dist/core/orchestration/capability-gateway.d.ts +61 -0
  316. package/dist/core/orchestration/capability-gateway.d.ts.map +1 -0
  317. package/dist/core/orchestration/capability-gateway.js +152 -0
  318. package/dist/core/orchestration/capability-gateway.js.map +1 -0
  319. package/dist/core/orchestration/contracts.d.ts +343 -0
  320. package/dist/core/orchestration/contracts.d.ts.map +1 -0
  321. package/dist/core/orchestration/contracts.js +135 -0
  322. package/dist/core/orchestration/contracts.js.map +1 -0
  323. package/dist/core/orchestration/delegation-ledger.d.ts +56 -0
  324. package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -0
  325. package/dist/core/orchestration/delegation-ledger.js +197 -0
  326. package/dist/core/orchestration/delegation-ledger.js.map +1 -0
  327. package/dist/core/orchestration/event-store.d.ts +83 -0
  328. package/dist/core/orchestration/event-store.d.ts.map +1 -0
  329. package/dist/core/orchestration/event-store.js +560 -0
  330. package/dist/core/orchestration/event-store.js.map +1 -0
  331. package/dist/core/orchestration/lane-tool-manifests.d.ts +9 -0
  332. package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -0
  333. package/dist/core/orchestration/lane-tool-manifests.js +37 -0
  334. package/dist/core/orchestration/lane-tool-manifests.js.map +1 -0
  335. package/dist/core/orchestration/model-binding.d.ts +15 -0
  336. package/dist/core/orchestration/model-binding.d.ts.map +1 -0
  337. package/dist/core/orchestration/model-binding.js +29 -0
  338. package/dist/core/orchestration/model-binding.js.map +1 -0
  339. package/dist/core/orchestration/policy-compiler.d.ts +49 -0
  340. package/dist/core/orchestration/policy-compiler.d.ts.map +1 -0
  341. package/dist/core/orchestration/policy-compiler.js +191 -0
  342. package/dist/core/orchestration/policy-compiler.js.map +1 -0
  343. package/dist/core/orchestration/policy-gate.d.ts +18 -0
  344. package/dist/core/orchestration/policy-gate.d.ts.map +1 -0
  345. package/dist/core/orchestration/policy-gate.js +24 -0
  346. package/dist/core/orchestration/policy-gate.js.map +1 -0
  347. package/dist/core/orchestration/profile-registry.d.ts +51 -0
  348. package/dist/core/orchestration/profile-registry.d.ts.map +1 -0
  349. package/dist/core/orchestration/profile-registry.js +393 -0
  350. package/dist/core/orchestration/profile-registry.js.map +1 -0
  351. package/dist/core/orchestration/profile-store.d.ts +31 -0
  352. package/dist/core/orchestration/profile-store.d.ts.map +1 -0
  353. package/dist/core/orchestration/profile-store.js +136 -0
  354. package/dist/core/orchestration/profile-store.js.map +1 -0
  355. package/dist/core/orchestration/risk-budget.d.ts +9 -0
  356. package/dist/core/orchestration/risk-budget.d.ts.map +1 -0
  357. package/dist/core/orchestration/risk-budget.js +48 -0
  358. package/dist/core/orchestration/risk-budget.js.map +1 -0
  359. package/dist/core/orchestration/task-runtime.d.ts +168 -0
  360. package/dist/core/orchestration/task-runtime.d.ts.map +1 -0
  361. package/dist/core/orchestration/task-runtime.js +1600 -0
  362. package/dist/core/orchestration/task-runtime.js.map +1 -0
  363. package/dist/core/orchestration/work-state-projection.d.ts +32 -0
  364. package/dist/core/orchestration/work-state-projection.d.ts.map +1 -0
  365. package/dist/core/orchestration/work-state-projection.js +116 -0
  366. package/dist/core/orchestration/work-state-projection.js.map +1 -0
  367. package/dist/core/orchestration/worker-execution-contract.d.ts +21 -0
  368. package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -0
  369. package/dist/core/orchestration/worker-execution-contract.js +179 -0
  370. package/dist/core/orchestration/worker-execution-contract.js.map +1 -0
  371. package/dist/core/orchestration/worker-result-adapter.d.ts +21 -0
  372. package/dist/core/orchestration/worker-result-adapter.d.ts.map +1 -0
  373. package/dist/core/orchestration/worker-result-adapter.js +109 -0
  374. package/dist/core/orchestration/worker-result-adapter.js.map +1 -0
  375. package/dist/core/process-identity.d.ts +11 -0
  376. package/dist/core/process-identity.d.ts.map +1 -0
  377. package/dist/core/process-identity.js +26 -0
  378. package/dist/core/process-identity.js.map +1 -0
  379. package/dist/core/process-matrix/codes.d.ts +14 -3
  380. package/dist/core/process-matrix/codes.d.ts.map +1 -1
  381. package/dist/core/process-matrix/codes.js.map +1 -1
  382. package/dist/core/process-matrix/resume-launcher.d.ts +26 -0
  383. package/dist/core/process-matrix/resume-launcher.d.ts.map +1 -0
  384. package/dist/core/process-matrix/resume-launcher.js +62 -0
  385. package/dist/core/process-matrix/resume-launcher.js.map +1 -0
  386. package/dist/core/process-matrix/runtime.d.ts +37 -22
  387. package/dist/core/process-matrix/runtime.d.ts.map +1 -1
  388. package/dist/core/process-matrix/runtime.js +399 -76
  389. package/dist/core/process-matrix/runtime.js.map +1 -1
  390. package/dist/core/process-matrix/store.d.ts +5 -2
  391. package/dist/core/process-matrix/store.d.ts.map +1 -1
  392. package/dist/core/process-matrix/store.js +123 -14
  393. package/dist/core/process-matrix/store.js.map +1 -1
  394. package/dist/core/process-matrix/supervisor.d.ts +10 -7
  395. package/dist/core/process-matrix/supervisor.d.ts.map +1 -1
  396. package/dist/core/process-matrix/supervisor.js +45 -14
  397. package/dist/core/process-matrix/supervisor.js.map +1 -1
  398. package/dist/core/profile-registry.d.ts.map +1 -1
  399. package/dist/core/profile-registry.js +6 -8
  400. package/dist/core/profile-registry.js.map +1 -1
  401. package/dist/core/reflection-controller.d.ts +4 -4
  402. package/dist/core/reflection-controller.d.ts.map +1 -1
  403. package/dist/core/reflection-controller.js +2 -1
  404. package/dist/core/reflection-controller.js.map +1 -1
  405. package/dist/core/reload-blockers.d.ts.map +1 -1
  406. package/dist/core/reload-blockers.js +6 -8
  407. package/dist/core/reload-blockers.js.map +1 -1
  408. package/dist/core/research/evidence-bundle.d.ts.map +1 -1
  409. package/dist/core/research/evidence-bundle.js +1 -6
  410. package/dist/core/research/evidence-bundle.js.map +1 -1
  411. package/dist/core/research/lane-model-resolver.d.ts +33 -0
  412. package/dist/core/research/lane-model-resolver.d.ts.map +1 -0
  413. package/dist/core/research/lane-model-resolver.js +65 -0
  414. package/dist/core/research/lane-model-resolver.js.map +1 -0
  415. package/dist/core/research/model-fitness-controller.d.ts +38 -0
  416. package/dist/core/research/model-fitness-controller.d.ts.map +1 -0
  417. package/dist/core/research/model-fitness-controller.js +106 -0
  418. package/dist/core/research/model-fitness-controller.js.map +1 -0
  419. package/dist/core/research/model-fitness.d.ts +1 -1
  420. package/dist/core/research/model-fitness.d.ts.map +1 -1
  421. package/dist/core/research/model-fitness.js +4 -4
  422. package/dist/core/research/model-fitness.js.map +1 -1
  423. package/dist/core/research/research-gate.d.ts.map +1 -1
  424. package/dist/core/research/research-gate.js +7 -7
  425. package/dist/core/research/research-gate.js.map +1 -1
  426. package/dist/core/research/research-lane-controller.d.ts +62 -0
  427. package/dist/core/research/research-lane-controller.d.ts.map +1 -0
  428. package/dist/core/research/research-lane-controller.js +292 -0
  429. package/dist/core/research/research-lane-controller.js.map +1 -0
  430. package/dist/core/research/session-evidence-bundle.d.ts +2 -4
  431. package/dist/core/research/session-evidence-bundle.d.ts.map +1 -1
  432. package/dist/core/research/session-evidence-bundle.js +10 -46
  433. package/dist/core/research/session-evidence-bundle.js.map +1 -1
  434. package/dist/core/resource-loader.d.ts.map +1 -1
  435. package/dist/core/resource-loader.js +7 -2
  436. package/dist/core/resource-loader.js.map +1 -1
  437. package/dist/core/risk-classifier.d.ts +6 -0
  438. package/dist/core/risk-classifier.d.ts.map +1 -0
  439. package/dist/core/risk-classifier.js +225 -0
  440. package/dist/core/risk-classifier.js.map +1 -0
  441. package/dist/core/runtime-builder.d.ts +26 -20
  442. package/dist/core/runtime-builder.d.ts.map +1 -1
  443. package/dist/core/runtime-builder.js +237 -178
  444. package/dist/core/runtime-builder.js.map +1 -1
  445. package/dist/core/sdk.d.ts +6 -3
  446. package/dist/core/sdk.d.ts.map +1 -1
  447. package/dist/core/sdk.js +61 -24
  448. package/dist/core/sdk.js.map +1 -1
  449. package/dist/core/session-analytics.d.ts.map +1 -1
  450. package/dist/core/session-analytics.js +28 -1
  451. package/dist/core/session-analytics.js.map +1 -1
  452. package/dist/core/session-image-store.d.ts +33 -0
  453. package/dist/core/session-image-store.d.ts.map +1 -0
  454. package/dist/core/session-image-store.js +283 -0
  455. package/dist/core/session-image-store.js.map +1 -0
  456. package/dist/core/session-role.d.ts +6 -4
  457. package/dist/core/session-role.d.ts.map +1 -1
  458. package/dist/core/session-role.js +10 -4
  459. package/dist/core/session-role.js.map +1 -1
  460. package/dist/core/session-snapshot.d.ts +34 -0
  461. package/dist/core/session-snapshot.d.ts.map +1 -0
  462. package/dist/core/session-snapshot.js +68 -0
  463. package/dist/core/session-snapshot.js.map +1 -0
  464. package/dist/core/session-supervision-runtime.d.ts +31 -0
  465. package/dist/core/session-supervision-runtime.d.ts.map +1 -0
  466. package/dist/core/session-supervision-runtime.js +97 -0
  467. package/dist/core/session-supervision-runtime.js.map +1 -0
  468. package/dist/core/settings-manager.d.ts +9 -4
  469. package/dist/core/settings-manager.d.ts.map +1 -1
  470. package/dist/core/settings-manager.js +80 -28
  471. package/dist/core/settings-manager.js.map +1 -1
  472. package/dist/core/tasks/session-task-state.d.ts +2 -4
  473. package/dist/core/tasks/session-task-state.d.ts.map +1 -1
  474. package/dist/core/tasks/session-task-state.js +10 -28
  475. package/dist/core/tasks/session-task-state.js.map +1 -1
  476. package/dist/core/tasks/task-projection.d.ts +20 -0
  477. package/dist/core/tasks/task-projection.d.ts.map +1 -0
  478. package/dist/core/tasks/task-projection.js +47 -0
  479. package/dist/core/tasks/task-projection.js.map +1 -0
  480. package/dist/core/tasks/task-state.d.ts +4 -0
  481. package/dist/core/tasks/task-state.d.ts.map +1 -1
  482. package/dist/core/tasks/task-state.js +28 -11
  483. package/dist/core/tasks/task-state.js.map +1 -1
  484. package/dist/core/tool-capability-policy.d.ts +13 -0
  485. package/dist/core/tool-capability-policy.d.ts.map +1 -0
  486. package/dist/core/tool-capability-policy.js +85 -0
  487. package/dist/core/tool-capability-policy.js.map +1 -0
  488. package/dist/core/tool-protocol-controller.d.ts +91 -0
  489. package/dist/core/tool-protocol-controller.d.ts.map +1 -0
  490. package/dist/core/tool-protocol-controller.js +512 -0
  491. package/dist/core/tool-protocol-controller.js.map +1 -0
  492. package/dist/core/tool-recovery-log-records.d.ts +2 -3
  493. package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
  494. package/dist/core/tool-recovery-log-records.js +9 -35
  495. package/dist/core/tool-recovery-log-records.js.map +1 -1
  496. package/dist/core/tool-selection/tool-performance-store.d.ts +3 -7
  497. package/dist/core/tool-selection/tool-performance-store.d.ts.map +1 -1
  498. package/dist/core/tool-selection/tool-performance-store.js +97 -138
  499. package/dist/core/tool-selection/tool-performance-store.js.map +1 -1
  500. package/dist/core/tools/ask-question.d.ts +124 -0
  501. package/dist/core/tools/ask-question.d.ts.map +1 -0
  502. package/dist/core/tools/ask-question.js +693 -0
  503. package/dist/core/tools/ask-question.js.map +1 -0
  504. package/dist/core/tools/delegate-status.d.ts +31 -3
  505. package/dist/core/tools/delegate-status.d.ts.map +1 -1
  506. package/dist/core/tools/delegate-status.js +149 -29
  507. package/dist/core/tools/delegate-status.js.map +1 -1
  508. package/dist/core/tools/delegate.d.ts +15 -13
  509. package/dist/core/tools/delegate.d.ts.map +1 -1
  510. package/dist/core/tools/delegate.js +108 -23
  511. package/dist/core/tools/delegate.js.map +1 -1
  512. package/dist/core/tools/extensionify.d.ts.map +1 -1
  513. package/dist/core/tools/extensionify.js +1 -0
  514. package/dist/core/tools/extensionify.js.map +1 -1
  515. package/dist/core/tools/goal.d.ts +5 -5
  516. package/dist/core/tools/goal.d.ts.map +1 -1
  517. package/dist/core/tools/goal.js +10 -10
  518. package/dist/core/tools/goal.js.map +1 -1
  519. package/dist/core/tools/model-fitness.d.ts.map +1 -1
  520. package/dist/core/tools/model-fitness.js +2 -2
  521. package/dist/core/tools/model-fitness.js.map +1 -1
  522. package/dist/core/tools/orchestration-panel.d.ts +43 -0
  523. package/dist/core/tools/orchestration-panel.d.ts.map +1 -0
  524. package/dist/core/tools/orchestration-panel.js +168 -0
  525. package/dist/core/tools/orchestration-panel.js.map +1 -0
  526. package/dist/core/tools/run-process.d.ts +26 -0
  527. package/dist/core/tools/run-process.d.ts.map +1 -0
  528. package/dist/core/tools/run-process.js +138 -0
  529. package/dist/core/tools/run-process.js.map +1 -0
  530. package/dist/core/tools/task-steps.d.ts +2 -0
  531. package/dist/core/tools/task-steps.d.ts.map +1 -1
  532. package/dist/core/tools/task-steps.js +102 -0
  533. package/dist/core/tools/task-steps.js.map +1 -1
  534. package/dist/core/tools/tmux-dispatch.d.ts +3 -5
  535. package/dist/core/tools/tmux-dispatch.d.ts.map +1 -1
  536. package/dist/core/tools/tmux-dispatch.js +4 -4
  537. package/dist/core/tools/tmux-dispatch.js.map +1 -1
  538. package/dist/core/tools/windows-shell-engine.d.ts.map +1 -1
  539. package/dist/core/tools/windows-shell-engine.js +4 -6
  540. package/dist/core/tools/windows-shell-engine.js.map +1 -1
  541. package/dist/core/util/bounded-jsonl.d.ts +10 -0
  542. package/dist/core/util/bounded-jsonl.d.ts.map +1 -0
  543. package/dist/core/util/bounded-jsonl.js +75 -0
  544. package/dist/core/util/bounded-jsonl.js.map +1 -0
  545. package/dist/core/util/value-guards.d.ts +5 -0
  546. package/dist/core/util/value-guards.d.ts.map +1 -0
  547. package/dist/core/util/value-guards.js +12 -0
  548. package/dist/core/util/value-guards.js.map +1 -0
  549. package/dist/core/worktree-sync/store.d.ts +3 -3
  550. package/dist/core/worktree-sync/store.d.ts.map +1 -1
  551. package/dist/core/worktree-sync/store.js +10 -5
  552. package/dist/core/worktree-sync/store.js.map +1 -1
  553. package/dist/index.d.ts +13 -3
  554. package/dist/index.d.ts.map +1 -1
  555. package/dist/index.js +12 -2
  556. package/dist/index.js.map +1 -1
  557. package/dist/main.d.ts.map +1 -1
  558. package/dist/main.js +128 -44
  559. package/dist/main.js.map +1 -1
  560. package/dist/migrations.d.ts +4 -6
  561. package/dist/migrations.d.ts.map +1 -1
  562. package/dist/migrations.js +186 -28
  563. package/dist/migrations.js.map +1 -1
  564. package/dist/modes/interactive/clipboard-input.d.ts +7 -1
  565. package/dist/modes/interactive/clipboard-input.d.ts.map +1 -1
  566. package/dist/modes/interactive/clipboard-input.js +44 -6
  567. package/dist/modes/interactive/clipboard-input.js.map +1 -1
  568. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  569. package/dist/modes/interactive/components/settings-selector.js +2 -2
  570. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  571. package/dist/modes/interactive/config-backup.d.ts.map +1 -1
  572. package/dist/modes/interactive/config-backup.js +5 -4
  573. package/dist/modes/interactive/config-backup.js.map +1 -1
  574. package/dist/modes/interactive/extension-ui-host.d.ts +14 -0
  575. package/dist/modes/interactive/extension-ui-host.d.ts.map +1 -1
  576. package/dist/modes/interactive/extension-ui-host.js +76 -15
  577. package/dist/modes/interactive/extension-ui-host.js.map +1 -1
  578. package/dist/modes/interactive/interactive-mode.d.ts +3 -0
  579. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  580. package/dist/modes/interactive/interactive-mode.js +63 -1
  581. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  582. package/dist/modes/interactive/key-handlers.d.ts.map +1 -1
  583. package/dist/modes/interactive/key-handlers.js +1 -1
  584. package/dist/modes/interactive/key-handlers.js.map +1 -1
  585. package/dist/modes/interactive/profile-menu-controller.d.ts.map +1 -1
  586. package/dist/modes/interactive/profile-menu-controller.js +7 -7
  587. package/dist/modes/interactive/profile-menu-controller.js.map +1 -1
  588. package/dist/modes/interactive/report-commands.d.ts.map +1 -1
  589. package/dist/modes/interactive/report-commands.js +21 -0
  590. package/dist/modes/interactive/report-commands.js.map +1 -1
  591. package/dist/modes/interactive/session-flow-commands.d.ts +17 -2
  592. package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
  593. package/dist/modes/interactive/session-flow-commands.js +50 -17
  594. package/dist/modes/interactive/session-flow-commands.js.map +1 -1
  595. package/dist/modes/interactive/session-io-commands.d.ts.map +1 -1
  596. package/dist/modes/interactive/session-io-commands.js +16 -6
  597. package/dist/modes/interactive/session-io-commands.js.map +1 -1
  598. package/dist/modes/interactive/session-replacement-errors.d.ts +7 -0
  599. package/dist/modes/interactive/session-replacement-errors.d.ts.map +1 -0
  600. package/dist/modes/interactive/session-replacement-errors.js +15 -0
  601. package/dist/modes/interactive/session-replacement-errors.js.map +1 -0
  602. package/dist/modes/interactive/startup-checks.d.ts.map +1 -1
  603. package/dist/modes/interactive/startup-checks.js +1 -1
  604. package/dist/modes/interactive/startup-checks.js.map +1 -1
  605. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  606. package/dist/modes/rpc/rpc-mode.js +82 -23
  607. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  608. package/dist/modes/rpc/rpc-types.d.ts +15 -0
  609. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  610. package/dist/modes/rpc/rpc-types.js +138 -1
  611. package/dist/modes/rpc/rpc-types.js.map +1 -1
  612. package/dist/utils/clipboard-image.d.ts.map +1 -1
  613. package/dist/utils/clipboard-image.js +2 -13
  614. package/dist/utils/clipboard-image.js.map +1 -1
  615. package/dist/utils/clipboard-native.d.ts +1 -0
  616. package/dist/utils/clipboard-native.d.ts.map +1 -1
  617. package/dist/utils/clipboard-native.js.map +1 -1
  618. package/dist/utils/clipboard.d.ts +1 -0
  619. package/dist/utils/clipboard.d.ts.map +1 -1
  620. package/dist/utils/clipboard.js +52 -1
  621. package/dist/utils/clipboard.js.map +1 -1
  622. package/dist/utils/platform.d.ts +3 -0
  623. package/dist/utils/platform.d.ts.map +1 -0
  624. package/dist/utils/platform.js +8 -0
  625. package/dist/utils/platform.js.map +1 -0
  626. package/dist/utils/work-directory.d.ts +11 -0
  627. package/dist/utils/work-directory.d.ts.map +1 -1
  628. package/dist/utils/work-directory.js +30 -9
  629. package/dist/utils/work-directory.js.map +1 -1
  630. package/docs/UI_POLISH_ORCHESTRATION.md +44 -0
  631. package/docs/UI_QUALITY_ORCHESTRATION.md +30 -0
  632. package/docs/docs.json +4 -0
  633. package/docs/extensions.md +62 -2
  634. package/docs/harness-architecture.md +156 -0
  635. package/docs/keybindings.md +11 -1
  636. package/docs/process-matrix.md +59 -26
  637. package/docs/rpc.md +45 -2
  638. package/docs/sessions.md +15 -0
  639. package/docs/settings.md +125 -11
  640. package/docs/task-steps.md +8 -0
  641. package/docs/telemetry.md +19 -0
  642. package/docs/tmux-agent-manager.md +10 -3
  643. package/docs/ui-reference/README.md +9 -0
  644. package/docs/ui-reference/orchestration-after.txt +7 -0
  645. package/docs/ui-reference/orchestration-before.txt +7 -0
  646. package/docs/ui-reference/orchestration-reference.txt +6 -0
  647. package/docs/usage.md +14 -2
  648. package/docs/work-directory.md +19 -8
  649. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  650. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  651. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  652. package/examples/extensions/question.ts +34 -245
  653. package/examples/extensions/questionnaire.ts +41 -407
  654. package/examples/extensions/sandbox/package-lock.json +2 -2
  655. package/examples/extensions/sandbox/package.json +1 -1
  656. package/examples/extensions/with-deps/package-lock.json +2 -2
  657. package/examples/extensions/with-deps/package.json +1 -1
  658. package/npm-shrinkwrap.json +12 -12
  659. package/package.json +4 -4
  660. package/dist/core/delegation/session-worker-result.d.ts +0 -46
  661. package/dist/core/delegation/session-worker-result.d.ts.map +0 -1
  662. package/dist/core/delegation/session-worker-result.js +0 -113
  663. package/dist/core/delegation/session-worker-result.js.map +0 -1
  664. package/dist/core/delegation/worker-result.d.ts.map +0 -1
  665. package/dist/core/delegation/worker-result.js.map +0 -1
  666. package/dist/core/telemetry.d.ts.map +0 -1
  667. package/dist/core/telemetry.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ask-question.d.ts","sourceRoot":"","sources":["../../../src/core/tools/ask-question.ts"],"names":[],"mappings":"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","sourcesContent":["import type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport {\n\ttype Component,\n\tCURSOR_MARKER,\n\tInput,\n\ttype Keybinding,\n\ttruncateToWidth,\n\tvisibleWidth,\n\twrapTextWithAnsi,\n} from \"@caupulican/pi-tui\";\nimport { type Static, Type } from \"typebox\";\nimport type { ClipboardInputHost, PendingClipboardImage } from \"../../modes/interactive/clipboard-input.ts\";\nimport { formatKeyText } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport type { ArtifactStore } from \"../context/context-artifacts.ts\";\nimport { defineTool } from \"../extensions/types.ts\";\nimport {\n\tbeginHumanInputRequest,\n\tcreateHumanInputRequest,\n\tformatHumanInputAnswerText,\n\ttype HumanInputAnswer,\n\ttype HumanInputAnswerImage,\n\ttype HumanInputPresentationResult,\n\ttype HumanInputQuestion,\n\ttype HumanInputSnapshot,\n\ttype HumanInputStopReason,\n\tresolveHumanInput,\n} from \"../human-input.ts\";\nimport type { KeybindingsManager } from \"../keybindings.ts\";\nimport type { SessionImageStore } from \"../session-image-store.ts\";\nimport {\n\temptyOrchestrationCall,\n\tOrchestrationPanelComponent,\n\ttype OrchestrationPanelModel,\n} from \"./orchestration-panel.ts\";\n\nconst optionSchema = Type.Object(\n\t{\n\t\tlabel: Type.String({ minLength: 1, maxLength: 120, description: \"Concise option label.\" }),\n\t\tdescription: Type.String({\n\t\t\tminLength: 1,\n\t\t\tmaxLength: 500,\n\t\t\tdescription: \"Concrete consequence or tradeoff of choosing this option.\",\n\t\t}),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst questionSchema = Type.Object(\n\t{\n\t\tid: Type.String({ minLength: 1, maxLength: 80, description: \"Stable unique answer identifier.\" }),\n\t\theader: Type.String({\n\t\t\tminLength: 1,\n\t\t\tmaxLength: 32,\n\t\t\tdescription: \"Short topic label used in question navigation.\",\n\t\t}),\n\t\tquestion: Type.String({ minLength: 1, maxLength: 1_000, description: \"The specific user-facing question.\" }),\n\t\toptions: Type.Array(optionSchema, {\n\t\t\tminItems: 2,\n\t\t\tmaxItems: 4,\n\t\t\tdescription: \"Two to four genuine choices. Other and Skip are supplied by the harness.\",\n\t\t}),\n\t\tmultiSelect: Type.Optional(Type.Boolean({ description: \"Allow more than one listed option to be selected.\" })),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst askQuestionSchema = Type.Object(\n\t{\n\t\tquestions: Type.Array(questionSchema, {\n\t\t\tminItems: 1,\n\t\t\tmaxItems: 4,\n\t\t\tdescription: \"One to four independent questions presented in one interaction.\",\n\t\t}),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst ANSWER_PREVIEW_CHARS = 240;\nconst ANSWER_EDITOR_VIEWPORT_LINES = 8;\n\nexport type AskQuestionToolInput = Static<typeof askQuestionSchema>;\nexport type AskQuestion = HumanInputQuestion;\nexport type AskQuestionAnswer = HumanInputAnswer;\nexport type AskQuestionAnswerImage = HumanInputAnswerImage;\nexport type AskQuestionStopReason = HumanInputStopReason;\n\nexport interface AskQuestionToolDetails {\n\tquestions: readonly AskQuestion[];\n\tanswers: readonly AskQuestionAnswer[];\n\tcancelled: boolean;\n\treason?: AskQuestionStopReason;\n\terror?: string;\n}\n\nexport interface AskQuestionToolOptions {\n\tname?: string;\n\tlabel?: string;\n\t/** Production session sink. When present, requests and answers are checkpointed before continuation. */\n\tsessionManager?: Pick<SessionManager, \"appendCustomEntry\">;\n\tartifactStore?: ArtifactStore;\n\tgetImageStore?: () => Pick<SessionImageStore, \"retainContent\"> | undefined;\n}\n\nexport interface AskQuestionClipboardOptions {\n\tautoResizeImages: boolean;\n\tblockImages: boolean;\n\tblockImagesReason?: string;\n\timageStore?: Pick<SessionImageStore, \"write\">;\n}\n\nexport type PasteClipboardImage = (host: ClipboardInputHost) => Promise<void>;\n\nexport interface AskQuestionAnswerEditor extends Component {\n\tfocused: boolean;\n\tonSubmit?: (text: string) => void;\n\thandleInput(data: string): void;\n\tgetText(): string;\n\tsetText(text: string): void;\n\tinsertTextAtCursor(text: string): void;\n}\n\nexport type CreateAskQuestionAnswerEditor = () => AskQuestionAnswerEditor;\n\nclass SingleLineAnswerEditor implements AskQuestionAnswerEditor {\n\tprivate readonly input = new Input();\n\tonSubmit?: (text: string) => void;\n\n\tconstructor() {\n\t\tthis.input.onSubmit = (value) => this.onSubmit?.(value);\n\t}\n\n\tget focused(): boolean {\n\t\treturn this.input.focused;\n\t}\n\n\tset focused(value: boolean) {\n\t\tthis.input.focused = value;\n\t}\n\n\tgetText(): string {\n\t\treturn this.input.getValue();\n\t}\n\n\tsetText(text: string): void {\n\t\tthis.input.setValue(\"\");\n\t\tthis.insertTextAtCursor(text);\n\t}\n\n\tinsertTextAtCursor(text: string): void {\n\t\tthis.input.handleInput(`\\x1b[200~${text}\\x1b[201~`);\n\t}\n\n\thandleInput(data: string): void {\n\t\tthis.input.handleInput(data);\n\t}\n\n\trender(width: number): string[] {\n\t\treturn this.input.render(width);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.input.invalidate();\n\t}\n}\n\ninterface QuestionSelection {\n\toptionIndexes: Set<number>;\n\tcustom?: string;\n\tskipped: boolean;\n}\n\ntype AskQuestionDialogResult = HumanInputPresentationResult;\n\nfunction normalizedIdentity(value: string): string {\n\treturn value.trim().toLowerCase();\n}\n\nfunction validateQuestions(questions: readonly AskQuestion[]): string | undefined {\n\tif (questions.length < 1 || questions.length > 4) return \"Provide between one and four questions.\";\n\tconst ids = new Set<string>();\n\tconst prompts = new Set<string>();\n\tfor (const question of questions) {\n\t\tif (!question.id.trim() || !question.header.trim() || !question.question.trim()) {\n\t\t\treturn \"Question ids, headers, and prompts must not be blank.\";\n\t\t}\n\t\tconst id = normalizedIdentity(question.id);\n\t\tconst prompt = normalizedIdentity(question.question);\n\t\tif (ids.has(id)) return `Question id '${question.id}' is duplicated.`;\n\t\tif (prompts.has(prompt)) return `Question '${question.question}' is duplicated.`;\n\t\tids.add(id);\n\t\tprompts.add(prompt);\n\t\tif (question.options.length < 2 || question.options.length > 4) {\n\t\t\treturn `Question '${question.header}' requires between two and four options.`;\n\t\t}\n\t\tconst labels = new Set<string>();\n\t\tfor (const option of question.options) {\n\t\t\tconst label = normalizedIdentity(option.label);\n\t\t\tif (!label || !option.description.trim()) {\n\t\t\t\treturn `Question '${question.header}' has a blank option label or description.`;\n\t\t\t}\n\t\t\tif (label === \"other\" || label === \"skip\") {\n\t\t\t\treturn `Question '${question.header}' must not define the reserved '${option.label}' option.`;\n\t\t\t}\n\t\t\tif (labels.has(label)) return `Question '${question.header}' has duplicate option '${option.label}'.`;\n\t\t\tlabels.add(label);\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction displayKeys(keybindings: KeybindingsManager, keybinding: Keybinding, limit = 2): string {\n\treturn formatKeyText(keybindings.getKeys(keybinding).slice(0, limit).join(\"/\"), { capitalize: true });\n}\n\nfunction answerFor(\n\tquestion: AskQuestion,\n\tselection: QuestionSelection,\n\tattachments: readonly PendingClipboardImage[] = [],\n): AskQuestionAnswer {\n\tconst images = selection.custom\n\t\t? attachments\n\t\t\t\t.filter((attachment) => selection.custom?.includes(attachment.label))\n\t\t\t\t.map((attachment) => ({ label: attachment.label, mimeType: attachment.content.mimeType }))\n\t\t: [];\n\treturn {\n\t\tid: question.id,\n\t\theader: question.header,\n\t\tquestion: question.question,\n\t\tselected: [...selection.optionIndexes]\n\t\t\t.sort((left, right) => left - right)\n\t\t\t.map((index) => question.options[index]?.label)\n\t\t\t.filter((label): label is string => label !== undefined),\n\t\t...(selection.custom ? { custom: selection.custom } : {}),\n\t\t...(images.length > 0 ? { images } : {}),\n\t\tskipped: selection.skipped,\n\t};\n}\n\nfunction previewAnswer(value: string): string {\n\tif (value.length <= ANSWER_PREVIEW_CHARS) return value;\n\treturn `${value.slice(0, ANSWER_PREVIEW_CHARS)}… (${value.length} characters)`;\n}\n\nfunction isResolved(selection: QuestionSelection): boolean {\n\treturn selection.skipped || selection.optionIndexes.size > 0 || selection.custom !== undefined;\n}\n\n/** Native focused question interaction shared by every provider-facing ask_question call. */\nexport class AskQuestionDialog implements Component {\n\tprivate readonly questions: readonly AskQuestion[];\n\tprivate readonly theme: Theme;\n\tprivate readonly keybindings: KeybindingsManager;\n\tprivate readonly requestRender: () => void;\n\tprivate readonly finish: (result: AskQuestionDialogResult) => void;\n\tprivate readonly clipboard: AskQuestionClipboardOptions;\n\tprivate readonly pasteClipboardImage: PasteClipboardImage;\n\tprivate readonly createAnswerEditor: CreateAskQuestionAnswerEditor;\n\tprivate readonly selections: QuestionSelection[];\n\tprivate readonly cursors: number[];\n\tprivate pendingClipboardImages: PendingClipboardImage[] = [];\n\tprivate clipboardImageCounter = 0;\n\tprivate currentIndex = 0;\n\tprivate input: AskQuestionAnswerEditor | undefined;\n\tprivate inputError: string | undefined;\n\tprivate inputStatus: string | undefined;\n\tprivate pasteInFlight = false;\n\tprivate submitAfterPaste = false;\n\tprivate cachedWidth: number | undefined;\n\tprivate cachedLines: string[] | undefined;\n\tprivate settled = false;\n\n\tconstructor(options: {\n\t\tquestions: readonly AskQuestion[];\n\t\ttheme: Theme;\n\t\tkeybindings: KeybindingsManager;\n\t\trequestRender: () => void;\n\t\tfinish: (result: AskQuestionDialogResult) => void;\n\t\tclipboard?: AskQuestionClipboardOptions;\n\t\tpasteClipboardImage?: PasteClipboardImage;\n\t\tcreateAnswerEditor?: CreateAskQuestionAnswerEditor;\n\t}) {\n\t\tthis.questions = options.questions;\n\t\tthis.theme = options.theme;\n\t\tthis.keybindings = options.keybindings;\n\t\tthis.requestRender = options.requestRender;\n\t\tthis.finish = options.finish;\n\t\tthis.clipboard = options.clipboard ?? { autoResizeImages: true, blockImages: false };\n\t\tthis.pasteClipboardImage =\n\t\t\toptions.pasteClipboardImage ??\n\t\t\t(async (host) => {\n\t\t\t\thost.showWarning(\"Clipboard paste is unavailable in this UI host.\");\n\t\t\t});\n\t\tthis.createAnswerEditor = options.createAnswerEditor ?? (() => new SingleLineAnswerEditor());\n\t\tthis.selections = options.questions.map(() => ({ optionIndexes: new Set(), skipped: false }));\n\t\tthis.cursors = options.questions.map(() => 0);\n\t}\n\n\tprivate refresh(): void {\n\t\tthis.invalidate();\n\t\tthis.requestRender();\n\t}\n\n\tprivate result(cancelled: boolean, reason?: AskQuestionStopReason): AskQuestionDialogResult {\n\t\tconst answers = this.questions.map((question, index) =>\n\t\t\tanswerFor(question, this.selections[index]!, this.pendingClipboardImages),\n\t\t);\n\t\tconst referencedLabels = new Set(answers.flatMap((answer) => answer.images?.map((image) => image.label) ?? []));\n\t\treturn {\n\t\t\tanswers,\n\t\t\tcancelled,\n\t\t\timageContents: cancelled\n\t\t\t\t? []\n\t\t\t\t: this.pendingClipboardImages\n\t\t\t\t\t\t.filter((attachment) => referencedLabels.has(attachment.label))\n\t\t\t\t\t\t.map((attachment) => attachment.content),\n\t\t\t...(reason ? { reason } : {}),\n\t\t};\n\t}\n\n\tprivate complete(result: AskQuestionDialogResult): void {\n\t\tif (this.settled) return;\n\t\tthis.settled = true;\n\t\tif (this.input) this.input.focused = false;\n\t\tthis.finish(result);\n\t}\n\n\tcancel(reason: Extract<AskQuestionStopReason, \"user_cancelled\" | \"interrupted\">): void {\n\t\tthis.complete(this.result(true, reason));\n\t}\n\n\tprivate move(delta: -1 | 1): void {\n\t\tconst lastIndex = this.questions.length;\n\t\tthis.currentIndex = Math.max(0, Math.min(lastIndex, this.currentIndex + delta));\n\t\tthis.refresh();\n\t}\n\n\tprivate advanceAfterSingleSelection(): void {\n\t\tif (this.questions.length === 1) {\n\t\t\tthis.complete(this.result(false));\n\t\t\treturn;\n\t\t}\n\t\tthis.currentIndex = Math.min(this.questions.length, this.currentIndex + 1);\n\t\tthis.refresh();\n\t}\n\n\tprivate beginCustomAnswer(): void {\n\t\tconst questionIndex = this.currentIndex;\n\t\tconst question = this.questions[questionIndex];\n\t\tconst selection = this.selections[questionIndex];\n\t\tif (!question || !selection) return;\n\t\tconst input = this.createAnswerEditor();\n\t\tthis.inputError = undefined;\n\t\tthis.inputStatus = undefined;\n\t\tinput.focused = true;\n\t\tif (selection.custom) input.setText(selection.custom);\n\t\tinput.onSubmit = (value) => {\n\t\t\tconst answer = value.trim();\n\t\t\tif (!answer) return;\n\t\t\tselection.custom = answer;\n\t\t\tselection.skipped = false;\n\t\t\tinput.focused = false;\n\t\t\tthis.input = undefined;\n\t\t\tif (question.multiSelect) this.refresh();\n\t\t\telse this.advanceAfterSingleSelection();\n\t\t};\n\t\tthis.input = input;\n\t\tthis.refresh();\n\t}\n\n\tprivate async pasteIntoCustomAnswer(): Promise<void> {\n\t\tconst input = this.input;\n\t\tif (!input || this.pasteInFlight) return;\n\t\tthis.pasteInFlight = true;\n\t\tthis.inputError = undefined;\n\t\tthis.inputStatus = \"Reading clipboard…\";\n\t\tthis.refresh();\n\t\tlet reported = false;\n\t\tconst self = this;\n\t\tconst host: ClipboardInputHost = {\n\t\t\tget pendingClipboardImages() {\n\t\t\t\treturn self.pendingClipboardImages;\n\t\t\t},\n\t\t\tset pendingClipboardImages(value) {\n\t\t\t\tself.pendingClipboardImages = value;\n\t\t\t},\n\t\t\tget clipboardImageCounter() {\n\t\t\t\treturn self.clipboardImageCounter;\n\t\t\t},\n\t\t\tset clipboardImageCounter(value) {\n\t\t\t\tself.clipboardImageCounter = value;\n\t\t\t},\n\t\t\teditor: {\n\t\t\t\thandleInput: (data) => input.handleInput(data),\n\t\t\t\tinsertTextAtCursor: (text) => input.insertTextAtCursor(text),\n\t\t\t},\n\t\t\tui: { requestRender: () => this.refresh() },\n\t\t\tautoResizeImages: this.clipboard.autoResizeImages,\n\t\t\tblockImages: this.clipboard.blockImages,\n\t\t\tblockImagesReason: this.clipboard.blockImagesReason,\n\t\t\timageStore: this.clipboard.imageStore,\n\t\t\tshowStatus: (message) => {\n\t\t\t\treported = true;\n\t\t\t\tthis.inputStatus = message;\n\t\t\t\tthis.inputError = undefined;\n\t\t\t},\n\t\t\tshowWarning: (message) => {\n\t\t\t\treported = true;\n\t\t\t\tthis.inputStatus = undefined;\n\t\t\t\tthis.inputError = message;\n\t\t\t\tthis.refresh();\n\t\t\t},\n\t\t};\n\t\ttry {\n\t\t\tawait this.pasteClipboardImage(host);\n\t\t} finally {\n\t\t\tthis.pasteInFlight = false;\n\t\t\tconst shouldSubmit = this.submitAfterPaste && this.input === input && !this.settled;\n\t\t\tthis.submitAfterPaste = false;\n\t\t\tif (!reported) this.inputStatus = undefined;\n\t\t\tif (shouldSubmit) input.onSubmit?.(input.getText());\n\t\t\tif (this.input === input && !this.settled) this.refresh();\n\t\t}\n\t}\n\n\tprivate selectCurrent(): void {\n\t\tconst question = this.questions[this.currentIndex];\n\t\tconst selection = this.selections[this.currentIndex];\n\t\tif (!question || !selection) return;\n\t\tconst cursor = this.cursors[this.currentIndex] ?? 0;\n\t\tif (cursor === question.options.length) {\n\t\t\tthis.beginCustomAnswer();\n\t\t\treturn;\n\t\t}\n\t\tif (cursor === question.options.length + 1) {\n\t\t\tselection.optionIndexes.clear();\n\t\t\tselection.custom = undefined;\n\t\t\tselection.skipped = true;\n\t\t\tthis.advanceAfterSingleSelection();\n\t\t\treturn;\n\t\t}\n\t\tselection.skipped = false;\n\t\tif (question.multiSelect) {\n\t\t\tif (selection.optionIndexes.has(cursor)) selection.optionIndexes.delete(cursor);\n\t\t\telse selection.optionIndexes.add(cursor);\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tselection.optionIndexes.clear();\n\t\tselection.optionIndexes.add(cursor);\n\t\tselection.custom = undefined;\n\t\tthis.advanceAfterSingleSelection();\n\t}\n\n\tprivate submitReview(): void {\n\t\tconst unresolved = this.selections.findIndex((selection) => !isResolved(selection));\n\t\tif (unresolved >= 0) {\n\t\t\tthis.currentIndex = unresolved;\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tthis.complete(this.result(false));\n\t}\n\n\thandleInput(data: string): void {\n\t\tif (this.settled) return;\n\t\tif (this.input) {\n\t\t\tif (this.keybindings.matches(data, \"tui.select.cancel\")) {\n\t\t\t\tthis.submitAfterPaste = false;\n\t\t\t\tthis.input.focused = false;\n\t\t\t\tthis.input = undefined;\n\t\t\t\tthis.refresh();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (this.keybindings.matches(data, \"app.clipboard.pasteImage\")) {\n\t\t\t\tvoid this.pasteIntoCustomAnswer();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (this.pasteInFlight && this.keybindings.matches(data, \"tui.input.submit\")) {\n\t\t\t\tthis.submitAfterPaste = true;\n\t\t\t\tthis.inputStatus = \"Finishing clipboard paste…\";\n\t\t\t\tthis.refresh();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst input = this.input;\n\t\t\tthis.inputError = undefined;\n\t\t\tthis.inputStatus = undefined;\n\t\t\tinput.handleInput(data);\n\t\t\tif (this.input === input) this.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.keybindings.matches(data, \"tui.select.cancel\")) {\n\t\t\tthis.cancel(\"user_cancelled\");\n\t\t\treturn;\n\t\t}\n\t\tif (this.keybindings.matches(data, \"app.question.previous\")) {\n\t\t\tthis.move(-1);\n\t\t\treturn;\n\t\t}\n\t\tif (this.keybindings.matches(data, \"app.question.next\")) {\n\t\t\tthis.move(1);\n\t\t\treturn;\n\t\t}\n\t\tif (this.currentIndex === this.questions.length) {\n\t\t\tif (this.keybindings.matches(data, \"tui.select.confirm\")) this.submitReview();\n\t\t\treturn;\n\t\t}\n\t\tconst question = this.questions[this.currentIndex];\n\t\tif (!question) return;\n\t\tif (this.keybindings.matches(data, \"tui.select.up\")) {\n\t\t\tthis.cursors[this.currentIndex] = Math.max(0, (this.cursors[this.currentIndex] ?? 0) - 1);\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.keybindings.matches(data, \"tui.select.down\")) {\n\t\t\tthis.cursors[this.currentIndex] = Math.min(\n\t\t\t\tquestion.options.length + 1,\n\t\t\t\t(this.cursors[this.currentIndex] ?? 0) + 1,\n\t\t\t);\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (\n\t\t\tthis.keybindings.matches(data, \"tui.select.confirm\") ||\n\t\t\t(question.multiSelect && this.keybindings.matches(data, \"app.question.toggle\"))\n\t\t) {\n\t\t\tthis.selectCurrent();\n\t\t}\n\t}\n\n\tprivate addWrapped(lines: string[], text: string, width: number, indent = \"\"): void {\n\t\tconst contentWidth = Math.max(1, width - visibleWidth(indent));\n\t\tfor (const line of wrapTextWithAnsi(text, contentWidth)) {\n\t\t\tlines.push(truncateToWidth(`${indent}${line}`, width, \"\"));\n\t\t}\n\t}\n\n\tprivate renderProgress(lines: string[], width: number): void {\n\t\tif (this.questions.length === 1 && !this.questions[0]?.multiSelect) return;\n\t\tconst chips = this.questions.map((question, index) => {\n\t\t\tconst resolved = isResolved(this.selections[index]!);\n\t\t\tconst text = ` ${resolved ? \"●\" : \"○\"} ${question.header} `;\n\t\t\treturn index === this.currentIndex\n\t\t\t\t? this.theme.bg(\"selectedBg\", this.theme.fg(\"text\", text))\n\t\t\t\t: this.theme.fg(resolved ? \"success\" : \"muted\", text);\n\t\t});\n\t\tconst review = \" Review \";\n\t\tchips.push(\n\t\t\tthis.currentIndex === this.questions.length\n\t\t\t\t? this.theme.bg(\"selectedBg\", this.theme.fg(\"text\", review))\n\t\t\t\t: this.theme.fg(\"dim\", review),\n\t\t);\n\t\tlines.push(truncateToWidth(chips.join(\" \"), width, \"\"));\n\t\tlines.push(\"\");\n\t}\n\n\tprivate renderQuestion(lines: string[], width: number, question: AskQuestion): void {\n\t\tconst questionIndex = this.currentIndex;\n\t\tconst selection = this.selections[questionIndex]!;\n\t\tconst cursor = this.cursors[questionIndex] ?? 0;\n\t\tthis.addWrapped(lines, this.theme.bold(question.question), width);\n\t\tif (question.multiSelect) {\n\t\t\tlines.push(this.theme.fg(\"muted\", \"Choose one or more, then continue to review.\"));\n\t\t}\n\t\tlines.push(\"\");\n\n\t\tquestion.options.forEach((option, index) => {\n\t\t\tconst active = index === cursor;\n\t\t\tconst chosen = selection.optionIndexes.has(index);\n\t\t\tconst prefix = `${active ? \"›\" : \" \"} ${chosen ? \"●\" : \"○\"} `;\n\t\t\tconst label = `${prefix}${option.label}`;\n\t\t\tlines.push(\n\t\t\t\ttruncateToWidth(\n\t\t\t\t\tactive ? this.theme.bg(\"selectedBg\", this.theme.fg(\"text\", ` ${label} `)) : this.theme.fg(\"text\", label),\n\t\t\t\t\twidth,\n\t\t\t\t\t\"\",\n\t\t\t\t),\n\t\t\t);\n\t\t\tthis.addWrapped(lines, this.theme.fg(\"muted\", option.description), width, \" \");\n\t\t});\n\n\t\tconst otherIndex = question.options.length;\n\t\tconst otherActive = cursor === otherIndex;\n\t\tconst otherLabel = selection.custom ? `Other: ${previewAnswer(selection.custom)}` : \"Other\";\n\t\tconst otherText = `${otherActive ? \"›\" : \" \"} ${selection.custom ? \"●\" : \"+\"} ${otherLabel}`;\n\t\tlines.push(\n\t\t\ttruncateToWidth(\n\t\t\t\totherActive\n\t\t\t\t\t? this.theme.bg(\"selectedBg\", this.theme.fg(\"text\", ` ${otherText} `))\n\t\t\t\t\t: this.theme.fg(\"muted\", otherText),\n\t\t\t\twidth,\n\t\t\t\t\"\",\n\t\t\t),\n\t\t);\n\t\tconst skipActive = cursor === otherIndex + 1;\n\t\tconst skipText = `${skipActive ? \"›\" : \" \"} ${selection.skipped ? \"●\" : \"–\"} Skip`;\n\t\tlines.push(\n\t\t\ttruncateToWidth(\n\t\t\t\tskipActive\n\t\t\t\t\t? this.theme.bg(\"selectedBg\", this.theme.fg(\"text\", ` ${skipText} `))\n\t\t\t\t\t: this.theme.fg(\"dim\", skipText),\n\t\t\t\twidth,\n\t\t\t\t\"\",\n\t\t\t),\n\t\t);\n\n\t\tif (this.input) {\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(this.theme.fg(\"muted\", \"Your answer\"));\n\t\t\tconst renderedInput = this.input.render(Math.max(4, width - 2));\n\t\t\tconst cursorLine = Math.max(\n\t\t\t\t0,\n\t\t\t\trenderedInput.findIndex((line) => line.includes(CURSOR_MARKER)),\n\t\t\t);\n\t\t\tconst viewportStart = Math.max(\n\t\t\t\t0,\n\t\t\t\tMath.min(\n\t\t\t\t\tcursorLine - Math.floor(ANSWER_EDITOR_VIEWPORT_LINES / 2),\n\t\t\t\t\trenderedInput.length - ANSWER_EDITOR_VIEWPORT_LINES,\n\t\t\t\t),\n\t\t\t);\n\t\t\tconst visibleInput = renderedInput.slice(viewportStart, viewportStart + ANSWER_EDITOR_VIEWPORT_LINES);\n\t\t\tif (viewportStart > 0) {\n\t\t\t\tlines.push(this.theme.fg(\"dim\", ` ↑ ${viewportStart} earlier line${viewportStart === 1 ? \"\" : \"s\"}`));\n\t\t\t}\n\t\t\tfor (const inputLine of visibleInput) {\n\t\t\t\tlines.push(truncateToWidth(` ${inputLine}`, width, \"\"));\n\t\t\t}\n\t\t\tconst remainingLines = renderedInput.length - viewportStart - visibleInput.length;\n\t\t\tif (remainingLines > 0) {\n\t\t\t\tlines.push(this.theme.fg(\"dim\", ` ↓ ${remainingLines} later line${remainingLines === 1 ? \"\" : \"s\"}`));\n\t\t\t}\n\t\t\tif (this.inputError) this.addWrapped(lines, this.theme.fg(\"warning\", this.inputError), width, \" \");\n\t\t\tif (this.inputStatus) this.addWrapped(lines, this.theme.fg(\"success\", this.inputStatus), width, \" \");\n\t\t}\n\t}\n\n\tprivate renderReview(lines: string[], width: number): void {\n\t\tlines.push(this.theme.bold(\"Review your answers\"));\n\t\tlines.push(\"\");\n\t\tlet unresolved = 0;\n\t\tthis.questions.forEach((question, index) => {\n\t\t\tconst answer = answerFor(question, this.selections[index]!);\n\t\t\tconst values = [...answer.selected, ...(answer.custom ? [previewAnswer(answer.custom)] : [])];\n\t\t\tconst value = answer.skipped ? \"Skipped\" : values.length > 0 ? values.join(\", \") : \"Unanswered\";\n\t\t\tif (!isResolved(this.selections[index]!)) unresolved++;\n\t\t\tthis.addWrapped(\n\t\t\t\tlines,\n\t\t\t\t`${this.theme.fg(\"muted\", `${question.header}:`)} ${this.theme.fg(value === \"Unanswered\" ? \"warning\" : \"text\", value)}`,\n\t\t\t\twidth,\n\t\t\t);\n\t\t});\n\t\tif (unresolved > 0) {\n\t\t\tlines.push(\"\");\n\t\t\tthis.addWrapped(\n\t\t\t\tlines,\n\t\t\t\tthis.theme.fg(\n\t\t\t\t\t\"warning\",\n\t\t\t\t\t`${unresolved} unanswered. Answer or explicitly skip each question before submitting.`,\n\t\t\t\t),\n\t\t\t\twidth,\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate renderHelp(lines: string[], width: number): void {\n\t\tconst cancel = displayKeys(this.keybindings, \"tui.select.cancel\", 1);\n\t\tlet help: string;\n\t\tif (this.input) {\n\t\t\thelp = `${displayKeys(this.keybindings, \"tui.input.submit\", 1)} save · ${displayKeys(this.keybindings, \"tui.input.newLine\", 1)} newline · ${displayKeys(this.keybindings, \"app.clipboard.pasteImage\", 1)} paste · ${cancel} back`;\n\t\t} else if (this.currentIndex === this.questions.length) {\n\t\t\thelp = `${displayKeys(this.keybindings, \"tui.select.confirm\", 1)} submit · ${displayKeys(this.keybindings, \"app.question.previous\")} back · ${cancel} cancel`;\n\t\t} else if (this.questions[this.currentIndex]?.multiSelect) {\n\t\t\thelp = `${displayKeys(this.keybindings, \"tui.select.up\")}/${displayKeys(this.keybindings, \"tui.select.down\")} move · ${displayKeys(this.keybindings, \"app.question.toggle\", 1)}/${displayKeys(this.keybindings, \"tui.select.confirm\", 1)} toggle · ${displayKeys(this.keybindings, \"app.question.next\")} next · ${cancel} cancel`;\n\t\t} else {\n\t\t\thelp = `${displayKeys(this.keybindings, \"tui.select.up\")}/${displayKeys(this.keybindings, \"tui.select.down\")} move · ${displayKeys(this.keybindings, \"tui.select.confirm\", 1)} select · ${cancel} cancel`;\n\t\t}\n\t\tthis.addWrapped(lines, this.theme.fg(\"dim\", help), width);\n\t}\n\n\trender(width: number): string[] {\n\t\tif (this.cachedWidth === width && this.cachedLines) return this.cachedLines;\n\t\tconst safeWidth = Math.max(1, width);\n\t\tconst lines: string[] = [];\n\t\tconst header = this.currentIndex === this.questions.length ? \"review\" : this.questions[this.currentIndex]?.header;\n\t\tlines.push(\n\t\t\ttruncateToWidth(\n\t\t\t\t`${this.theme.fg(\"accent\", \"?\")} ${this.theme.bold(header ?? \"question\")} ${this.theme.fg(\"dim\", `${Math.min(this.currentIndex + 1, this.questions.length)}/${this.questions.length}`)}`,\n\t\t\t\tsafeWidth,\n\t\t\t\t\"\",\n\t\t\t),\n\t\t);\n\t\tlines.push(\"\");\n\t\tthis.renderProgress(lines, safeWidth);\n\t\tconst question = this.questions[this.currentIndex];\n\t\tif (question) this.renderQuestion(lines, safeWidth, question);\n\t\telse this.renderReview(lines, safeWidth);\n\t\tlines.push(\"\");\n\t\tthis.renderHelp(lines, safeWidth);\n\t\tthis.cachedWidth = width;\n\t\tthis.cachedLines = lines.map((line) => truncateToWidth(line, safeWidth, \"\"));\n\t\treturn this.cachedLines;\n\t}\n\n\tinvalidate(): void {\n\t\tthis.cachedWidth = undefined;\n\t\tthis.cachedLines = undefined;\n\t}\n}\n\nfunction questionPanelModel(details: AskQuestionToolDetails | undefined): OrchestrationPanelModel {\n\tif (!details) {\n\t\treturn { label: \"question\", status: \"error\", emptyText: \"No structured answer was retained.\" };\n\t}\n\tif (details.reason === \"ui_unavailable\" || details.reason === \"invalid_questions\") {\n\t\treturn {\n\t\t\tlabel: \"question\",\n\t\t\taction: \"unavailable\",\n\t\t\tstatus: \"error\",\n\t\t\temptyText: details.error ?? \"User input is unavailable.\",\n\t\t};\n\t}\n\tconst rows = details.questions.map((question) => {\n\t\tconst answer = details.answers.find((candidate) => candidate.id === question.id);\n\t\tconst values = answer ? [...answer.selected, ...(answer.custom ? [previewAnswer(answer.custom)] : [])] : [];\n\t\tconst imageCount = answer?.images?.length ?? 0;\n\t\treturn {\n\t\t\tstatus: details.cancelled\n\t\t\t\t? (\"cancelled\" as const)\n\t\t\t\t: answer?.skipped\n\t\t\t\t\t? (\"cancelled\" as const)\n\t\t\t\t\t: (\"completed\" as const),\n\t\t\tlabel: question.header,\n\t\t\tmeta: details.cancelled\n\t\t\t\t? [details.reason === \"interrupted\" ? \"interrupted\" : \"cancelled\"]\n\t\t\t\t: answer?.skipped\n\t\t\t\t\t? [\"skipped\"]\n\t\t\t\t\t: [\n\t\t\t\t\t\t\tvalues.length > 1 ? `${values.length} selected` : undefined,\n\t\t\t\t\t\t\timageCount > 0 ? `${imageCount} image${imageCount === 1 ? \"\" : \"s\"}` : undefined,\n\t\t\t\t\t\t].filter((value): value is string => value !== undefined),\n\t\t\tdetails: values.length > 0 ? [`answer: ${values.join(\", \")}`] : undefined,\n\t\t};\n\t});\n\tconst skipped = details.answers.filter((answer) => answer.skipped).length;\n\treturn {\n\t\tlabel: \"question\",\n\t\taction: details.cancelled ? \"cancelled\" : \"answered\",\n\t\tstatus: details.cancelled ? \"warning\" : \"success\",\n\t\tsummary: details.cancelled\n\t\t\t? undefined\n\t\t\t: [`${details.answers.length - skipped} answered`, skipped ? `${skipped} skipped` : undefined].filter(\n\t\t\t\t\t(value): value is string => value !== undefined,\n\t\t\t\t),\n\t\trows,\n\t};\n}\n\nfunction stoppedResult(\n\tquestions: readonly AskQuestion[],\n\treason: AskQuestionStopReason,\n\terror?: string,\n): { content: Array<{ type: \"text\"; text: string }>; details: AskQuestionToolDetails } {\n\treturn {\n\t\tcontent: [{ type: \"text\", text: error ?? `ask_question stopped: ${reason}` }],\n\t\tdetails: { questions, answers: [], cancelled: true, reason, ...(error ? { error } : {}) },\n\t};\n}\n\nexport function createAskQuestionToolDefinition(options: AskQuestionToolOptions = {}) {\n\tconst name = options.name ?? \"ask_question\";\n\treturn defineTool<typeof askQuestionSchema, AskQuestionToolDetails>({\n\t\tname,\n\t\tlabel: options.label ?? \"Ask Question\",\n\t\tdescription:\n\t\t\t\"Ask the human owner one to four concise questions when a missing choice materially changes the work. The harness supplies Other and Skip choices, supports single- and multi-select answers, and returns a typed answer set.\",\n\t\tpromptSnippet: \"Ask the human owner for a consequential missing choice through the native interactive UI.\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use this tool only when a missing owner choice materially changes the result, authority, risk, or acceptance criteria; otherwise proceed with a safe stated assumption.\",\n\t\t\t\"Batch independent questions into one call, with at most four questions and two to four genuine options each.\",\n\t\t\t\"Make every option label concise and describe its concrete consequence or tradeoff. Do not add Other, Skip, None, or filler options; the harness supplies Other and Skip.\",\n\t\t\t\"Set multiSelect only when choices are genuinely independent. Never use a question to delegate a decision already fixed by an owner-authored profile or policy.\",\n\t\t\t\"Respect skipped or cancelled input as owner intent. Do not immediately repeat the same question; proceed safely or report the unresolved boundary.\",\n\t\t],\n\t\tparameters: askQuestionSchema,\n\t\texecutionMode: \"sequential\",\n\t\trenderShell: \"self\",\n\t\trenderCall() {\n\t\t\treturn emptyOrchestrationCall();\n\t\t},\n\t\trenderResult(result, { expanded, isPartial }, theme) {\n\t\t\tif (isPartial) {\n\t\t\t\treturn new OrchestrationPanelComponent(theme, {\n\t\t\t\t\tlabel: \"question\",\n\t\t\t\t\taction: \"waiting for you\",\n\t\t\t\t\tstatus: \"running\",\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn new OrchestrationPanelComponent(theme, questionPanelModel(result.details), expanded);\n\t\t},\n\t\tasync execute(_toolCallId, input, signal, _onUpdate, ctx) {\n\t\t\tconst validationError = validateQuestions(input.questions);\n\t\t\tif (validationError) return stoppedResult(input.questions, \"invalid_questions\", validationError);\n\t\t\tif (!ctx.hasUI) {\n\t\t\t\treturn stoppedResult(input.questions, \"ui_unavailable\", \"ask_question requires interactive UI.\");\n\t\t\t}\n\t\t\tif (signal?.aborted) return stoppedResult(input.questions, \"interrupted\");\n\n\t\t\tconst request = createHumanInputRequest({\n\t\t\t\tsource: \"tool\",\n\t\t\t\ttoolCallId: _toolCallId,\n\t\t\t\ttoolName: name,\n\t\t\t\tquestions: input.questions,\n\t\t\t\tacceptsImages: ctx.model?.input.includes(\"image\") ?? false,\n\t\t\t});\n\t\t\tif (options.sessionManager) beginHumanInputRequest(options.sessionManager, request);\n\t\t\tconst resolved = options.sessionManager\n\t\t\t\t? await resolveHumanInput({\n\t\t\t\t\t\tsessionManager: options.sessionManager,\n\t\t\t\t\t\trequest,\n\t\t\t\t\t\tpresent: (presentation, dialogOptions) => ctx.ui.askQuestions(presentation, dialogOptions),\n\t\t\t\t\t\tartifactStore: options.artifactStore,\n\t\t\t\t\t\tgetImageStore: options.getImageStore,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t})\n\t\t\t\t: await (async (): Promise<{\n\t\t\t\t\t\tsnapshot: HumanInputSnapshot;\n\t\t\t\t\t\timageContents: AskQuestionDialogResult[\"imageContents\"];\n\t\t\t\t\t}> => {\n\t\t\t\t\t\tconst result = await ctx.ui.askQuestions(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\trequestId: request.requestId,\n\t\t\t\t\t\t\t\tquestions: request.questions,\n\t\t\t\t\t\t\t\tacceptsImages: request.acceptsImages,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ signal },\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tsnapshot: {\n\t\t\t\t\t\t\t\trequest,\n\t\t\t\t\t\t\t\tstatus: result.cancelled ? \"cancelled\" : \"answered\",\n\t\t\t\t\t\t\t\tanswers: result.answers,\n\t\t\t\t\t\t\t\t...(result.reason ? { reason: result.reason } : {}),\n\t\t\t\t\t\t\t\tupdatedAt: new Date().toISOString(),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\timageContents: result.imageContents,\n\t\t\t\t\t\t};\n\t\t\t\t\t})();\n\n\t\t\tconst details: AskQuestionToolDetails = {\n\t\t\t\tquestions: input.questions,\n\t\t\t\tanswers: resolved.snapshot.answers,\n\t\t\t\tcancelled: resolved.snapshot.status === \"cancelled\",\n\t\t\t\t...(resolved.snapshot.reason ? { reason: resolved.snapshot.reason } : {}),\n\t\t\t};\n\t\t\tif (details.cancelled) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: formatHumanInputAnswerText(resolved.snapshot) }],\n\t\t\t\t\tdetails,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcontent: [\n\t\t\t\t\t{ type: \"text\" as const, text: formatHumanInputAnswerText(resolved.snapshot) },\n\t\t\t\t\t...resolved.imageContents,\n\t\t\t\t],\n\t\t\t\tdetails,\n\t\t\t};\n\t\t},\n\t});\n}\n"]}