@caupulican/pi-adaptative 0.94.0 → 0.95.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (371) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/dist/bundled-resources/extensions/tmux-agent-manager/README.md +32 -13
  3. package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts +7 -4
  4. package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
  5. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +173 -293
  6. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
  7. package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +247 -392
  8. package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.d.ts +52 -0
  9. package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.d.ts.map +1 -0
  10. package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.js +118 -0
  11. package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.js.map +1 -0
  12. package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.ts +169 -0
  13. package/dist/bundled-resources/extensions/tmux-agent-manager/templates/builder-validator.json +1 -1
  14. package/dist/bundled-resources/extensions/tmux-agent-manager/templates/provider-prompt-smoke.json +1 -1
  15. package/dist/bundled-resources/skills/pi-harness-learning/SKILL.md +13 -7
  16. package/dist/bundled-resources/skills/worker-profile-writer/SKILL.md +11 -11
  17. package/dist/core/agent-paths.d.ts +2 -0
  18. package/dist/core/agent-paths.d.ts.map +1 -1
  19. package/dist/core/agent-paths.js +7 -0
  20. package/dist/core/agent-paths.js.map +1 -1
  21. package/dist/core/agent-session.d.ts +11 -41
  22. package/dist/core/agent-session.d.ts.map +1 -1
  23. package/dist/core/agent-session.js +98 -161
  24. package/dist/core/agent-session.js.map +1 -1
  25. package/dist/core/autonomy/envelope-enforcement.d.ts +6 -1
  26. package/dist/core/autonomy/envelope-enforcement.d.ts.map +1 -1
  27. package/dist/core/autonomy/envelope-enforcement.js +26 -25
  28. package/dist/core/autonomy/envelope-enforcement.js.map +1 -1
  29. package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -1
  30. package/dist/core/autonomy/lane-private-paths.js +2 -1
  31. package/dist/core/autonomy/lane-private-paths.js.map +1 -1
  32. package/dist/core/autonomy/lane-tool-surface.d.ts +8 -8
  33. package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
  34. package/dist/core/autonomy/lane-tool-surface.js +45 -30
  35. package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
  36. package/dist/core/autonomy/worker-session-private-scope.d.ts +12 -0
  37. package/dist/core/autonomy/worker-session-private-scope.d.ts.map +1 -0
  38. package/dist/core/autonomy/worker-session-private-scope.js +42 -0
  39. package/dist/core/autonomy/worker-session-private-scope.js.map +1 -0
  40. package/dist/core/autonomy/worker-tool-adapter-registry.d.ts +65 -0
  41. package/dist/core/autonomy/worker-tool-adapter-registry.d.ts.map +1 -0
  42. package/dist/core/autonomy/worker-tool-adapter-registry.js +145 -0
  43. package/dist/core/autonomy/worker-tool-adapter-registry.js.map +1 -0
  44. package/dist/core/background-lane-controller.d.ts +9 -1
  45. package/dist/core/background-lane-controller.d.ts.map +1 -1
  46. package/dist/core/background-lane-controller.js +76 -6
  47. package/dist/core/background-lane-controller.js.map +1 -1
  48. package/dist/core/background-tool-task-controller.d.ts +23 -2
  49. package/dist/core/background-tool-task-controller.d.ts.map +1 -1
  50. package/dist/core/background-tool-task-controller.js +132 -17
  51. package/dist/core/background-tool-task-controller.js.map +1 -1
  52. package/dist/core/context/long-term-memory-trigger.d.ts +3 -1
  53. package/dist/core/context/long-term-memory-trigger.d.ts.map +1 -1
  54. package/dist/core/context/long-term-memory-trigger.js +1 -1
  55. package/dist/core/context/long-term-memory-trigger.js.map +1 -1
  56. package/dist/core/context/okf-memory-provider.d.ts +3 -0
  57. package/dist/core/context/okf-memory-provider.d.ts.map +1 -1
  58. package/dist/core/context/okf-memory-provider.js +66 -31
  59. package/dist/core/context/okf-memory-provider.js.map +1 -1
  60. package/dist/core/context/okf-memory.d.ts +18 -1
  61. package/dist/core/context/okf-memory.d.ts.map +1 -1
  62. package/dist/core/context/okf-memory.js +48 -0
  63. package/dist/core/context/okf-memory.js.map +1 -1
  64. package/dist/core/cost-guard-controller.d.ts +37 -0
  65. package/dist/core/cost-guard-controller.d.ts.map +1 -0
  66. package/dist/core/cost-guard-controller.js +71 -0
  67. package/dist/core/cost-guard-controller.js.map +1 -0
  68. package/dist/core/cost-guard.d.ts +9 -4
  69. package/dist/core/cost-guard.d.ts.map +1 -1
  70. package/dist/core/cost-guard.js +7 -3
  71. package/dist/core/cost-guard.js.map +1 -1
  72. package/dist/core/delegation/worker-agent-control.d.ts +4 -0
  73. package/dist/core/delegation/worker-agent-control.d.ts.map +1 -1
  74. package/dist/core/delegation/worker-agent-control.js.map +1 -1
  75. package/dist/core/delegation/worker-attempt-executor.d.ts +1 -1
  76. package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
  77. package/dist/core/delegation/worker-attempt-executor.js +0 -1
  78. package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
  79. package/dist/core/delegation/worker-authority-resolver.d.ts +16 -3
  80. package/dist/core/delegation/worker-authority-resolver.d.ts.map +1 -1
  81. package/dist/core/delegation/worker-authority-resolver.js +114 -55
  82. package/dist/core/delegation/worker-authority-resolver.js.map +1 -1
  83. package/dist/core/delegation/worker-claim.d.ts +1 -2
  84. package/dist/core/delegation/worker-claim.d.ts.map +1 -1
  85. package/dist/core/delegation/worker-claim.js.map +1 -1
  86. package/dist/core/delegation/worker-delegation-controller.d.ts +19 -6
  87. package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
  88. package/dist/core/delegation/worker-delegation-controller.js +125 -40
  89. package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
  90. package/dist/core/delegation/worker-delegation-request.d.ts +3 -3
  91. package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
  92. package/dist/core/delegation/worker-delegation-request.js +13 -19
  93. package/dist/core/delegation/worker-delegation-request.js.map +1 -1
  94. package/dist/core/delegation/worker-execution-policy.d.ts +3 -2
  95. package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
  96. package/dist/core/delegation/worker-execution-policy.js +54 -39
  97. package/dist/core/delegation/worker-execution-policy.js.map +1 -1
  98. package/dist/core/delegation/worker-fleet-limits.d.ts +3 -3
  99. package/dist/core/delegation/worker-fleet-limits.d.ts.map +1 -1
  100. package/dist/core/delegation/worker-fleet-limits.js +7 -7
  101. package/dist/core/delegation/worker-fleet-limits.js.map +1 -1
  102. package/dist/core/delegation/worker-machine-scope.d.ts +12 -0
  103. package/dist/core/delegation/worker-machine-scope.d.ts.map +1 -0
  104. package/dist/core/delegation/worker-machine-scope.js +38 -0
  105. package/dist/core/delegation/worker-machine-scope.js.map +1 -0
  106. package/dist/core/delegation/worker-notification-coordinator.d.ts +10 -0
  107. package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -1
  108. package/dist/core/delegation/worker-notification-coordinator.js +69 -3
  109. package/dist/core/delegation/worker-notification-coordinator.js.map +1 -1
  110. package/dist/core/delegation/worker-recovery-coordinator.d.ts.map +1 -1
  111. package/dist/core/delegation/worker-recovery-coordinator.js +6 -1
  112. package/dist/core/delegation/worker-recovery-coordinator.js.map +1 -1
  113. package/dist/core/delegation/worker-runner.d.ts +5 -7
  114. package/dist/core/delegation/worker-runner.d.ts.map +1 -1
  115. package/dist/core/delegation/worker-runner.js +1 -4
  116. package/dist/core/delegation/worker-runner.js.map +1 -1
  117. package/dist/core/delegation/worker-write-reservation-coordinator.d.ts +3 -2
  118. package/dist/core/delegation/worker-write-reservation-coordinator.d.ts.map +1 -1
  119. package/dist/core/delegation/worker-write-reservation-coordinator.js +50 -25
  120. package/dist/core/delegation/worker-write-reservation-coordinator.js.map +1 -1
  121. package/dist/core/durable-custom-message-turn-controller.d.ts +6 -0
  122. package/dist/core/durable-custom-message-turn-controller.d.ts.map +1 -1
  123. package/dist/core/durable-custom-message-turn-controller.js +38 -15
  124. package/dist/core/durable-custom-message-turn-controller.js.map +1 -1
  125. package/dist/core/extension-binding-controller.d.ts +5 -1
  126. package/dist/core/extension-binding-controller.d.ts.map +1 -1
  127. package/dist/core/extension-binding-controller.js +15 -0
  128. package/dist/core/extension-binding-controller.js.map +1 -1
  129. package/dist/core/extensions/factory-runtime.d.ts.map +1 -1
  130. package/dist/core/extensions/factory-runtime.js +5 -0
  131. package/dist/core/extensions/factory-runtime.js.map +1 -1
  132. package/dist/core/extensions/runner.d.ts.map +1 -1
  133. package/dist/core/extensions/runner.js +1 -0
  134. package/dist/core/extensions/runner.js.map +1 -1
  135. package/dist/core/extensions/types.d.ts +8 -4
  136. package/dist/core/extensions/types.d.ts.map +1 -1
  137. package/dist/core/extensions/types.js.map +1 -1
  138. package/dist/core/foreground-terminal-handoff-controller.d.ts +31 -0
  139. package/dist/core/foreground-terminal-handoff-controller.d.ts.map +1 -1
  140. package/dist/core/foreground-terminal-handoff-controller.js +239 -55
  141. package/dist/core/foreground-terminal-handoff-controller.js.map +1 -1
  142. package/dist/core/goals/goal-session-controller.d.ts +2 -0
  143. package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
  144. package/dist/core/goals/goal-session-controller.js +8 -0
  145. package/dist/core/goals/goal-session-controller.js.map +1 -1
  146. package/dist/core/goals/goal-tool-core.d.ts +5 -4
  147. package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
  148. package/dist/core/goals/goal-tool-core.js +23 -19
  149. package/dist/core/goals/goal-tool-core.js.map +1 -1
  150. package/dist/core/learning/auto-learn-settings.d.ts +84 -0
  151. package/dist/core/learning/auto-learn-settings.d.ts.map +1 -0
  152. package/dist/core/learning/auto-learn-settings.js +66 -0
  153. package/dist/core/learning/auto-learn-settings.js.map +1 -0
  154. package/dist/core/learning/learning-audit.d.ts +5 -1
  155. package/dist/core/learning/learning-audit.d.ts.map +1 -1
  156. package/dist/core/learning/learning-audit.js +32 -1
  157. package/dist/core/learning/learning-audit.js.map +1 -1
  158. package/dist/core/learning/reflection-engine.d.ts +24 -0
  159. package/dist/core/learning/reflection-engine.d.ts.map +1 -1
  160. package/dist/core/learning/reflection-engine.js +104 -8
  161. package/dist/core/learning/reflection-engine.js.map +1 -1
  162. package/dist/core/local-prefix-warm-controller.d.ts +24 -0
  163. package/dist/core/local-prefix-warm-controller.d.ts.map +1 -0
  164. package/dist/core/local-prefix-warm-controller.js +79 -0
  165. package/dist/core/local-prefix-warm-controller.js.map +1 -0
  166. package/dist/core/memory/okf-project-memory-store.d.ts +28 -0
  167. package/dist/core/memory/okf-project-memory-store.d.ts.map +1 -0
  168. package/dist/core/memory/okf-project-memory-store.js +111 -0
  169. package/dist/core/memory/okf-project-memory-store.js.map +1 -0
  170. package/dist/core/memory/providers/file-store.d.ts +44 -1
  171. package/dist/core/memory/providers/file-store.d.ts.map +1 -1
  172. package/dist/core/memory/providers/file-store.js +341 -24
  173. package/dist/core/memory/providers/file-store.js.map +1 -1
  174. package/dist/core/memory/worker-memory-tools.d.ts +5 -0
  175. package/dist/core/memory/worker-memory-tools.d.ts.map +1 -0
  176. package/dist/core/memory/worker-memory-tools.js +5 -0
  177. package/dist/core/memory/worker-memory-tools.js.map +1 -0
  178. package/dist/core/memory-controller.d.ts +10 -1
  179. package/dist/core/memory-controller.d.ts.map +1 -1
  180. package/dist/core/memory-controller.js +72 -8
  181. package/dist/core/memory-controller.js.map +1 -1
  182. package/dist/core/model-capability.d.ts +7 -0
  183. package/dist/core/model-capability.d.ts.map +1 -1
  184. package/dist/core/model-capability.js +12 -0
  185. package/dist/core/model-capability.js.map +1 -1
  186. package/dist/core/model-registry.d.ts.map +1 -1
  187. package/dist/core/model-registry.js +2 -10
  188. package/dist/core/model-registry.js.map +1 -1
  189. package/dist/core/model-router-controller.d.ts +3 -2
  190. package/dist/core/model-router-controller.d.ts.map +1 -1
  191. package/dist/core/model-router-controller.js +3 -2
  192. package/dist/core/model-router-controller.js.map +1 -1
  193. package/dist/core/orchestration/contracts.d.ts +16 -12
  194. package/dist/core/orchestration/contracts.d.ts.map +1 -1
  195. package/dist/core/orchestration/contracts.js +2 -2
  196. package/dist/core/orchestration/contracts.js.map +1 -1
  197. package/dist/core/orchestration/lane-tool-manifests.d.ts +2 -2
  198. package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -1
  199. package/dist/core/orchestration/lane-tool-manifests.js +6 -1
  200. package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
  201. package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
  202. package/dist/core/orchestration/profile-registry.js +14 -0
  203. package/dist/core/orchestration/profile-registry.js.map +1 -1
  204. package/dist/core/orchestration/task-profile-writer.d.ts +7 -4
  205. package/dist/core/orchestration/task-profile-writer.d.ts.map +1 -1
  206. package/dist/core/orchestration/task-profile-writer.js +71 -59
  207. package/dist/core/orchestration/task-profile-writer.js.map +1 -1
  208. package/dist/core/orchestration/thinking-level-schema.d.ts +7 -0
  209. package/dist/core/orchestration/thinking-level-schema.d.ts.map +1 -0
  210. package/dist/core/orchestration/thinking-level-schema.js +19 -0
  211. package/dist/core/orchestration/thinking-level-schema.js.map +1 -0
  212. package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -1
  213. package/dist/core/orchestration/worker-execution-contract.js +12 -5
  214. package/dist/core/orchestration/worker-execution-contract.js.map +1 -1
  215. package/dist/core/provider-prompt-contracts.d.ts +1 -4
  216. package/dist/core/provider-prompt-contracts.d.ts.map +1 -1
  217. package/dist/core/provider-prompt-contracts.js +13 -29
  218. package/dist/core/provider-prompt-contracts.js.map +1 -1
  219. package/dist/core/provider-request-context-controller.d.ts +2 -0
  220. package/dist/core/provider-request-context-controller.d.ts.map +1 -1
  221. package/dist/core/provider-request-context-controller.js +10 -3
  222. package/dist/core/provider-request-context-controller.js.map +1 -1
  223. package/dist/core/reflection-controller.d.ts +63 -27
  224. package/dist/core/reflection-controller.d.ts.map +1 -1
  225. package/dist/core/reflection-controller.js +300 -132
  226. package/dist/core/reflection-controller.js.map +1 -1
  227. package/dist/core/runtime-builder.d.ts +1 -0
  228. package/dist/core/runtime-builder.d.ts.map +1 -1
  229. package/dist/core/runtime-builder.js +25 -14
  230. package/dist/core/runtime-builder.js.map +1 -1
  231. package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -1
  232. package/dist/core/secrets/credential-exposure-guard.js +55 -10
  233. package/dist/core/secrets/credential-exposure-guard.js.map +1 -1
  234. package/dist/core/session-role.d.ts +6 -8
  235. package/dist/core/session-role.d.ts.map +1 -1
  236. package/dist/core/session-role.js +8 -18
  237. package/dist/core/session-role.js.map +1 -1
  238. package/dist/core/settings-manager.d.ts +13 -16
  239. package/dist/core/settings-manager.d.ts.map +1 -1
  240. package/dist/core/settings-manager.js +53 -50
  241. package/dist/core/settings-manager.js.map +1 -1
  242. package/dist/core/skill-vault.d.ts +15 -0
  243. package/dist/core/skill-vault.d.ts.map +1 -1
  244. package/dist/core/skill-vault.js +79 -45
  245. package/dist/core/skill-vault.js.map +1 -1
  246. package/dist/core/skills.d.ts +3 -0
  247. package/dist/core/skills.d.ts.map +1 -1
  248. package/dist/core/skills.js +6 -6
  249. package/dist/core/skills.js.map +1 -1
  250. package/dist/core/system-prompt-builder.d.ts +2 -0
  251. package/dist/core/system-prompt-builder.d.ts.map +1 -1
  252. package/dist/core/system-prompt-builder.js +52 -12
  253. package/dist/core/system-prompt-builder.js.map +1 -1
  254. package/dist/core/system-prompt.js +1 -1
  255. package/dist/core/system-prompt.js.map +1 -1
  256. package/dist/core/tool-capability-policy.d.ts +3 -0
  257. package/dist/core/tool-capability-policy.d.ts.map +1 -1
  258. package/dist/core/tool-capability-policy.js +13 -2
  259. package/dist/core/tool-capability-policy.js.map +1 -1
  260. package/dist/core/toolkit/script-runner.d.ts +2 -1
  261. package/dist/core/toolkit/script-runner.d.ts.map +1 -1
  262. package/dist/core/toolkit/script-runner.js +10 -2
  263. package/dist/core/toolkit/script-runner.js.map +1 -1
  264. package/dist/core/tools/delegate-status.d.ts +3 -1
  265. package/dist/core/tools/delegate-status.d.ts.map +1 -1
  266. package/dist/core/tools/delegate-status.js +5 -1
  267. package/dist/core/tools/delegate-status.js.map +1 -1
  268. package/dist/core/tools/delegate.d.ts +4 -13
  269. package/dist/core/tools/delegate.d.ts.map +1 -1
  270. package/dist/core/tools/delegate.js +173 -73
  271. package/dist/core/tools/delegate.js.map +1 -1
  272. package/dist/core/tools/goal.d.ts +3 -4
  273. package/dist/core/tools/goal.d.ts.map +1 -1
  274. package/dist/core/tools/goal.js +24 -7
  275. package/dist/core/tools/goal.js.map +1 -1
  276. package/dist/core/tools/profile-writer.d.ts +2 -8
  277. package/dist/core/tools/profile-writer.d.ts.map +1 -1
  278. package/dist/core/tools/profile-writer.js +6 -18
  279. package/dist/core/tools/profile-writer.js.map +1 -1
  280. package/dist/core/tools/run-toolkit-script.d.ts +1 -1
  281. package/dist/core/tools/run-toolkit-script.d.ts.map +1 -1
  282. package/dist/core/tools/run-toolkit-script.js +2 -2
  283. package/dist/core/tools/run-toolkit-script.js.map +1 -1
  284. package/dist/core/tools/skill-audit.d.ts +28 -1
  285. package/dist/core/tools/skill-audit.d.ts.map +1 -1
  286. package/dist/core/tools/skill-audit.js +56 -12
  287. package/dist/core/tools/skill-audit.js.map +1 -1
  288. package/dist/core/tools/skill.d.ts +12 -1
  289. package/dist/core/tools/skill.d.ts.map +1 -1
  290. package/dist/core/tools/skill.js +52 -0
  291. package/dist/core/tools/skill.js.map +1 -1
  292. package/dist/core/tools/skillify.d.ts.map +1 -1
  293. package/dist/core/tools/skillify.js +16 -7
  294. package/dist/core/tools/skillify.js.map +1 -1
  295. package/dist/core/tools/task-steps.js +1 -1
  296. package/dist/core/tools/task-steps.js.map +1 -1
  297. package/dist/core/tools/tmux-dispatch.d.ts +4 -16
  298. package/dist/core/tools/tmux-dispatch.d.ts.map +1 -1
  299. package/dist/core/tools/tmux-dispatch.js +5 -20
  300. package/dist/core/tools/tmux-dispatch.js.map +1 -1
  301. package/dist/core/tools/tool-task.d.ts +1 -0
  302. package/dist/core/tools/tool-task.d.ts.map +1 -1
  303. package/dist/core/tools/tool-task.js +13 -8
  304. package/dist/core/tools/tool-task.js.map +1 -1
  305. package/dist/core/util/atomic-file.d.ts +2 -0
  306. package/dist/core/util/atomic-file.d.ts.map +1 -1
  307. package/dist/core/util/atomic-file.js +4 -0
  308. package/dist/core/util/atomic-file.js.map +1 -1
  309. package/dist/core/worktree-sync/codes.d.ts +1 -2
  310. package/dist/core/worktree-sync/codes.d.ts.map +1 -1
  311. package/dist/core/worktree-sync/codes.js +1 -2
  312. package/dist/core/worktree-sync/codes.js.map +1 -1
  313. package/dist/core/worktree-sync/lane-gate.d.ts +4 -8
  314. package/dist/core/worktree-sync/lane-gate.d.ts.map +1 -1
  315. package/dist/core/worktree-sync/lane-gate.js +5 -51
  316. package/dist/core/worktree-sync/lane-gate.js.map +1 -1
  317. package/dist/index.d.ts +5 -0
  318. package/dist/index.d.ts.map +1 -1
  319. package/dist/index.js +7 -0
  320. package/dist/index.js.map +1 -1
  321. package/dist/modes/interactive/auto-learn-controller.d.ts +6 -7
  322. package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
  323. package/dist/modes/interactive/auto-learn-controller.js +32 -207
  324. package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
  325. package/dist/modes/interactive/autonomy-commands.js +2 -2
  326. package/dist/modes/interactive/autonomy-commands.js.map +1 -1
  327. package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -1
  328. package/dist/modes/interactive/components/activity-lane.js +12 -23
  329. package/dist/modes/interactive/components/activity-lane.js.map +1 -1
  330. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  331. package/dist/modes/interactive/components/custom-message.js +142 -1
  332. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  333. package/dist/modes/interactive/components/fitness-role-selector.d.ts.map +1 -1
  334. package/dist/modes/interactive/components/fitness-role-selector.js +2 -2
  335. package/dist/modes/interactive/components/fitness-role-selector.js.map +1 -1
  336. package/dist/modes/interactive/components/footer.js +1 -1
  337. package/dist/modes/interactive/components/footer.js.map +1 -1
  338. package/dist/modes/interactive/components/settings-selector.d.ts +4 -0
  339. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  340. package/dist/modes/interactive/components/settings-selector.js +150 -73
  341. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  342. package/dist/modes/interactive/report-commands.d.ts.map +1 -1
  343. package/dist/modes/interactive/report-commands.js +8 -4
  344. package/dist/modes/interactive/report-commands.js.map +1 -1
  345. package/dist/modes/interactive/settings-selector-flow.d.ts.map +1 -1
  346. package/dist/modes/interactive/settings-selector-flow.js +10 -0
  347. package/dist/modes/interactive/settings-selector-flow.js.map +1 -1
  348. package/docs/extensions.md +8 -0
  349. package/docs/harness-architecture.md +28 -32
  350. package/docs/index.md +1 -1
  351. package/docs/process-matrix.md +8 -6
  352. package/docs/resources.md +1 -1
  353. package/docs/settings.md +61 -51
  354. package/docs/tmux-agent-manager.md +47 -40
  355. package/docs/usage.md +1 -1
  356. package/docs/worker-profiles.md +8 -6
  357. package/docs/worktree-sync.md +26 -20
  358. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  359. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  360. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  361. package/examples/extensions/sandbox/package-lock.json +2 -2
  362. package/examples/extensions/sandbox/package.json +1 -1
  363. package/examples/extensions/with-deps/package-lock.json +2 -2
  364. package/examples/extensions/with-deps/package.json +1 -1
  365. package/npm-shrinkwrap.json +12 -12
  366. package/package.json +4 -4
  367. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +0 -133
  368. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +0 -1
  369. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +0 -199
  370. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +0 -1
  371. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +0 -312
@@ -56,9 +56,9 @@ export interface GoalToolDependencies {
56
56
  hasToolCallId?: (toolCallId: string) => boolean;
57
57
  /**
58
58
  * Read the session's live worker lane records, for validating kind:"worker" evidence refs
59
- * (the `uri` is a laneId) at add_evidence time. Read-defensive: when not wired -- exactly like
60
- * `hasToolCallId` -- a "worker" ref cannot be proven and is recorded as `verified: false` rather
61
- * than assumed true. Live wiring is added separately.
59
+ * (the `uri` is a laneId) at add_evidence time and refusing completion while goal-owned work is
60
+ * queued or running. Read-defensive: when not wired -- exactly like `hasToolCallId` -- a "worker"
61
+ * ref cannot be proven and is recorded as `verified: false` rather than assumed true.
62
62
  */
63
63
  getLaneRecords?: () => readonly LaneRecord[];
64
64
  /**
@@ -94,7 +94,6 @@ export interface GoalToolDependencies {
94
94
  * BOTH `input.dispatchTarget === "tmux"` AND this dependency is present; otherwise the EXISTING
95
95
  * {@link startWorkerDelegation} in-process path runs, byte-identical to before this field existed.
96
96
  * The honest skip-reason vocabulary this can return: `tmux_extension_not_loaded`,
97
- * `no_standing_grant` (the owner has not authorized unattended tmux dispatch),
98
97
  * `tmux_dispatch_failed`, `tmux_dispatch_incomplete`, `lane_correlation_failed`,
99
98
  * `worktree_create_failed` (worktree-sync is enabled but the lane-first `create_lane` call was
100
99
  * refused -- e.g. max lanes reached -- so no fire_task call was ever attempted),
@@ -1 +1 @@
1
- {"version":3,"file":"goal.d.ts","sourceRoot":"","sources":["../../../src/core/tools/goal.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,C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E,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IAC/G,+GAA+G;IAC/G,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,aAAa,CAAC,KAAK,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAChH;;;OAGG;IACH,mBAAmB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;CAC/C;AAmMD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,oBAAoB,GAAG,kBAAkB,CA8OvF;AAED;;;;GAIG;AACH,wBAAgB,kCAAkC,CAAC,QAAQ,EAAE,kBAAkB,iJAuD9E"}
@@ -52,7 +52,7 @@ const goalSchema = Type.Object({
52
52
  })),
53
53
  reason: Type.Optional(Type.String({ description: "Reason for block_requirement or block_goal." })),
54
54
  dispatchTarget: Type.Optional(Type.Union([Type.Literal("in_process"), Type.Literal("tmux")], {
55
- description: "Legacy target. Native is default; use tmux only for an owner-requested persistent pane.",
55
+ description: "Legacy target. Native is default; use tmux when the task benefits from a persistent pane.",
56
56
  })),
57
57
  }, { additionalProperties: false });
58
58
  const createGoalSchema = Type.Object({
@@ -241,6 +241,13 @@ function goalPanelModel(details) {
241
241
  emptyText: "No requirements recorded.",
242
242
  };
243
243
  }
244
+ function goalExecutionError(action, message, state) {
245
+ return {
246
+ content: [{ type: "text", text: `goal ${action} failed: ${message}` }],
247
+ details: { action, applied: false, error: message, state },
248
+ isError: true,
249
+ };
250
+ }
244
251
  export function createGoalToolDefinition(deps) {
245
252
  const now = deps.now ?? (() => new Date().toISOString());
246
253
  return {
@@ -252,7 +259,7 @@ export function createGoalToolDefinition(deps) {
252
259
  "Start when persistent continuation materially benefits current work or the user/system requests it. Skip routine one-turn tasks; get if uncertain; never replace unfinished goal; tokenBudget only if requested.",
253
260
  "Plans: task_steps. Workers: delegate. Background tools: tool_task wait once; cite taskId as kind=tool evidence.",
254
261
  "increment satisfies the current open requirement from unused evidence, or completes when none remain.",
255
- "complete needs current authoritative evidence, no remaining work, no linked open task_steps, no running tool_task, no active pipeline. block_goal needs same real impasse for 3 goal turns.",
262
+ "complete needs current authoritative evidence, no remaining work, no active goal-owned lanes, no open task_steps, no goal-owned running or cited non-completed tool_task, and no active pipeline. block_goal needs same real impasse for 3 goal turns.",
256
263
  ],
257
264
  parameters: goalSchema,
258
265
  renderShell: "self",
@@ -407,19 +414,28 @@ export function createGoalToolDefinition(deps) {
407
414
  }
408
415
  else {
409
416
  let activePipeline;
417
+ let activeGoalLaneIds;
410
418
  if (current &&
411
419
  isGoalExecutionActive(current.status) &&
412
420
  (action.action === "complete" || action.action === "increment")) {
421
+ try {
422
+ const boundLaneIds = new Set(current.requirements.flatMap((requirement) => requirement.boundLaneId ? [requirement.boundLaneId] : []));
423
+ activeGoalLaneIds = deps
424
+ .getLaneRecords?.()
425
+ .filter((record) => (record.status === "queued" || record.status === "running") &&
426
+ (record.goalId === current.goalId || boundLaneIds.has(record.laneId)))
427
+ .map((record) => record.laneId);
428
+ }
429
+ catch (error) {
430
+ const message = `Cannot verify active goal-owned lane state: ${error instanceof Error ? error.message : String(error)}`;
431
+ return goalExecutionError(input.action, message, current);
432
+ }
413
433
  try {
414
434
  activePipeline = deps.getActivePipeline?.();
415
435
  }
416
436
  catch (error) {
417
437
  const message = `Cannot verify active pipeline state: ${error instanceof Error ? error.message : String(error)}`;
418
- return {
419
- content: [{ type: "text", text: `goal ${input.action} failed: ${message}` }],
420
- details: { action: input.action, applied: false, error: message, state: current },
421
- isError: true,
422
- };
438
+ return goalExecutionError(input.action, message, current);
423
439
  }
424
440
  }
425
441
  const result = applyGoalAction(current, action, now(), {
@@ -427,6 +443,7 @@ export function createGoalToolDefinition(deps) {
427
443
  openTaskSteps: deps.getOpenTaskSteps?.(),
428
444
  backgroundToolTasks: deps.getBackgroundToolTasks?.(),
429
445
  activePipeline,
446
+ activeGoalLaneIds,
430
447
  });
431
448
  if (!result.ok) {
432
449
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"goal.js","sourceRoot":"","sources":["../../../src/core/tools/goal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAK5C,OAAO,EAA0B,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAC1F,OAAO,EAA0D,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACvH,OAAO,EACN,eAAe,EAIf,kBAAkB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAC/F,OAAO,EACN,sBAAsB,EAEtB,6BAA6B,GAC7B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAC7B;IACC,MAAM,EAAE,IAAI,CAAC,KAAK,CACjB;QACC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QACnB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC;QAC/B,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC;QACnC,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC;QACjC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;QAClC,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC;QAC/B,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;QAC5B,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;QAC3B,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;QACxB,IAA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C;AACnD,CAAC","sourcesContent":["import { createHash, randomUUID } from \"node:crypto\";\nimport { stat as fsStat } from \"node:fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport type { WorkerClaim } from \"../autonomy/contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport type { BackgroundToolTaskRef } from \"../background-tool-task-controller.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type GoalStateRevision, getGoalStateRevision } from \"../goals/goal-lifecycle.ts\";\nimport { type GoalEvidenceKind, type GoalState, type GoalStatus, isGoalExecutionActive } from \"../goals/goal-state.ts\";\nimport {\n\tapplyGoalAction,\n\ttype GoalAction,\n\ttype GoalActionName,\n\ttype OpenTaskStepRef,\n\tsummarizeGoalState,\n} from \"../goals/goal-tool-core.ts\";\nimport { GOAL_LIFECYCLE_TOOL_NAMES, LEGACY_GOAL_TOOL_NAME } from \"../goals/goal-tool-names.ts\";\nimport {\n\temptyOrchestrationCall,\n\ttype OrchestrationPanelModel,\n\trenderOrchestrationToolResult,\n} from \"./orchestration-panel.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\n\nconst goalSchema = Type.Object(\n\t{\n\t\taction: Type.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"get\"),\n\t\t\t\tType.Literal(\"start\"),\n\t\t\t\tType.Literal(\"add_requirement\"),\n\t\t\t\tType.Literal(\"satisfy_requirement\"),\n\t\t\t\tType.Literal(\"block_requirement\"),\n\t\t\t\tType.Literal(\"reopen_requirement\"),\n\t\t\t\tType.Literal(\"dispatch_worker\"),\n\t\t\t\tType.Literal(\"add_evidence\"),\n\t\t\t\tType.Literal(\"progress\"),\n\t\t\t\tType.Literal(\"no_progress\"),\n\t\t\t\tType.Literal(\"complete\"),\n\t\t\t\tType.Literal(\"increment\"),\n\t\t\t\tType.Literal(\"block_goal\"),\n\t\t\t],\n\t\t\t{ description: \"Goal record action.\" },\n\t\t),\n\t\tgoalId: Type.Optional(Type.String({ description: \"Stable goal id. Required for action 'start'.\" })),\n\t\tuserGoal: Type.Optional(Type.String({ description: \"The goal statement. Required for action 'start'.\" })),\n\t\ttokenBudget: Type.Optional(\n\t\t\tType.Integer({ minimum: 1, description: \"Optional positive token budget for action 'start'.\" }),\n\t\t),\n\t\trequirementId: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"Requirement id for requirement actions. Omit on add_requirement for a stable host id.\",\n\t\t\t}),\n\t\t),\n\t\ttext: Type.Optional(Type.String({ description: \"Requirement text. Required for add_requirement.\" })),\n\t\tdependencies: Type.Optional(\n\t\t\tType.Array(Type.String(), {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Optional IDs of requirements that must be satisfied before this one. Valid for add_requirement.\",\n\t\t\t}),\n\t\t),\n\t\tinstructions: Type.Optional(Type.String({ description: \"Worker instructions. Required for dispatch_worker.\" })),\n\t\tevidenceId: Type.Optional(\n\t\t\tType.String({ description: \"Evidence id. Omit on add_evidence for a stable host id.\" }),\n\t\t),\n\t\tevidenceIds: Type.Optional(\n\t\t\tType.Array(Type.String(), {\n\t\t\t\tdescription: \"Existing evidence ids for satisfy_requirement.\",\n\t\t\t}),\n\t\t),\n\t\tkind: Type.Optional(\n\t\t\tType.Union(\n\t\t\t\t[\n\t\t\t\t\tType.Literal(\"file\"),\n\t\t\t\t\tType.Literal(\"test\"),\n\t\t\t\t\tType.Literal(\"tool\"),\n\t\t\t\t\tType.Literal(\"user\"),\n\t\t\t\t\tType.Literal(\"finding\"),\n\t\t\t\t\tType.Literal(\"worker\"),\n\t\t\t\t],\n\t\t\t\t{ description: \"Evidence kind. Required for add_evidence.\" },\n\t\t\t),\n\t\t),\n\t\tsummary: Type.Optional(Type.String({ description: \"Evidence summary. Required for add_evidence.\" })),\n\t\turi: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"Optional file/URL, toolCallId, or laneId evidence locator.\",\n\t\t\t}),\n\t\t),\n\t\treason: Type.Optional(Type.String({ description: \"Reason for block_requirement or block_goal.\" })),\n\t\tdispatchTarget: Type.Optional(\n\t\t\tType.Union([Type.Literal(\"in_process\"), Type.Literal(\"tmux\")], {\n\t\t\t\tdescription: \"Legacy target. Native is default; use tmux only for an owner-requested persistent pane.\",\n\t\t\t}),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst createGoalSchema = Type.Object(\n\t{\n\t\tobjective: Type.String({ description: \"Required. The concrete objective to start pursuing.\" }),\n\t\ttoken_budget: Type.Optional(\n\t\t\tType.Integer({ minimum: 1, description: \"Positive token budget. Omit unless explicitly requested.\" }),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst getGoalSchema = Type.Object({}, { additionalProperties: false });\n\nconst updateGoalSchema = Type.Object(\n\t{\n\t\tstatus: Type.Union([Type.Literal(\"active\"), Type.Literal(\"complete\"), Type.Literal(\"blocked\")], {\n\t\t\tdescription:\n\t\t\t\t\"Set active after concrete progress, complete after an evidence audit, or blocked after the same blocker persists for three turns.\",\n\t\t}),\n\t\treason: Type.Optional(\n\t\t\tType.String({ minLength: 1, description: \"Required for blocked: the recurring external blocker.\" }),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type GoalToolInput = Static<typeof goalSchema>;\nexport type GoalToolDefinition = ToolDefinition;\n\nexport interface GoalToolDetails {\n\taction: GoalActionName | \"get\";\n\tapplied: boolean;\n\terror?: string;\n\tstate?: GoalState;\n\t/** Set on 'dispatch_worker' when a worker lane actually started; mirrors the requirement's\n\t * new `boundLaneId`. The in-process route by default, or a real persistent tmux lane when\n\t * `dispatchTarget:\"tmux\"` was selected and routed -- see {@link GoalToolDependencies.dispatchTmuxWorker}. */\n\tdispatchedLaneId?: string;\n\t/** Set on 'dispatch_worker' when no worker was dispatched: a wired dependency declined (e.g. worker\n\t * delegation disabled, already at capacity, or an honest tmux skip reason -- see\n\t * {@link GoalToolDependencies.dispatchTmuxWorker}), or the indeterminate-binding guard refused a\n\t * re-dispatch against an already-bound requirement (`requirement_already_bound`/`bound_lane_indeterminate`).\n\t * The binding is recorded (or, for a guard refusal, left exactly as it was) with no NEW laneId. */\n\tdispatchSkipReason?: string;\n}\n\nexport interface GoalToolDependencies {\n\t/** Read the latest persisted goal state for the active session. */\n\tgetGoalState: () => GoalState | undefined;\n\t/** Persist a new goal state snapshot to the active session. */\n\tsaveGoalState: (state: GoalState, expected?: GoalStateRevision) => void;\n\t/** Clock injection for deterministic tests. */\n\tnow?: () => string;\n\t/**\n\t * Check whether `toolCallId` exists in this session's records, for validating kind:\"tool\"\n\t * evidence refs at add_evidence time. When not wired, a \"tool\" ref cannot be proven and is\n\t * recorded as `verified: false` rather than assumed true.\n\t */\n\thasToolCallId?: (toolCallId: string) => boolean;\n\t/**\n\t * Read the session's live worker lane records, for validating kind:\"worker\" evidence refs\n\t * (the `uri` is a laneId) at add_evidence time. Read-defensive: when not wired -- exactly like\n\t * `hasToolCallId` -- a \"worker\" ref cannot be proven and is recorded as `verified: false` rather\n\t * than assumed true. Live wiring is added separately.\n\t */\n\tgetLaneRecords?: () => readonly LaneRecord[];\n\t/**\n\t * Read persisted worker claim snapshots (keyed by `WorkerClaim.requestId`, which is the same\n\t * id as the dispatching lane's laneId), for validating kind:\"worker\" evidence refs. See\n\t * {@link getLaneRecords}. A matching claim that is `parentReviewRequired && !parentReviewedAt`\n\t * verifies `false` -- an unreviewed worker completion must never ungate goal completion through\n\t * the existing verified/complete gate.\n\t */\n\tgetWorkerClaimSnapshots?: () => readonly WorkerClaim[];\n\t/**\n\t * Tool-layer side effect for a 'dispatch_worker' action when `dispatchTarget` is 'in_process'\n\t * (the default) or when {@link dispatchTmuxWorker} is not wired: dispatches a real in-process\n\t * worker lane for the given requirement and returns the resulting laneId to bind onto it. When\n\t * the dependency is present but the underlying delegation starter declines (disabled, already at\n\t * capacity, etc.), return `{ skipReason }` instead of a laneId -- a real, non-silent skip that\n\t * the tool response surfaces, distinct from this dependency being altogether unwired (`undefined`\n\t * dep, or the dep returning `undefined`), which records the binding attempt structurally with no\n\t * laneId (a no-op).\n\t */\n\tstartWorkerDelegation?: (args: {\n\t\trequirementId: string;\n\t\tinstructions: string;\n\t}) => { laneId?: string; skipReason?: string } | undefined;\n\t/**\n\t * Tool-layer side effect for a 'dispatch_worker' action when `input.dispatchTarget === \"tmux\"`:\n\t * dispatches a REAL persistent tmux worker via the tmux_agent_manager extension's `fire_task`\n\t * action (core structurally invokes the same tool call the model would make; no extension change,\n\t * no faked launch or laneId -- see `tmux-dispatch.ts`'s `dispatchTmuxWorker`). Selected ONLY when\n\t * BOTH `input.dispatchTarget === \"tmux\"` AND this dependency is present; otherwise the EXISTING\n\t * {@link startWorkerDelegation} in-process path runs, byte-identical to before this field existed.\n\t * The honest skip-reason vocabulary this can return: `tmux_extension_not_loaded`,\n\t * `no_standing_grant` (the owner has not authorized unattended tmux dispatch),\n\t * `tmux_dispatch_failed`, `tmux_dispatch_incomplete`, `lane_correlation_failed`,\n\t * `worktree_create_failed` (worktree-sync is enabled but the lane-first `create_lane` call was\n\t * refused -- e.g. max lanes reached -- so no fire_task call was ever attempted),\n\t * `worker_capability_insufficient` (the model is sub-full class, has an unknown context window,\n\t * does not advertise a native tool-call path, or is graded-demoted to text-protocol/none -- see\n\t * `model-capability.ts`'s `evaluateLaneWorkerRefusal`; this is the parent's best-effort check\n\t * only, refused before any lane/pane side effect -- the dispatched child still refuses\n\t * authoritatively at its own startup regardless).\n\t */\n\tdispatchTmuxWorker?: (args: {\n\t\trequirementId: string;\n\t\tinstructions: string;\n\t}) => Promise<{ laneId?: string; skipReason?: string }>;\n\t/** Working directory for resolving kind:\"file\" evidence ref paths. Defaults to `process.cwd()`. */\n\tcwd?: () => string;\n\t/**\n\t * Gate agent-facing 'complete' on verified/user evidence backing. Defaults to `true` (on)\n\t * when omitted -- the conservative default; set to a function returning `false` to opt out.\n\t */\n\trequireVerifiedEvidenceForCompletion?: () => boolean;\n\t/**\n\t * Read-only open (non-terminal) task_steps steps on the active branch, for the goal⇄task\n\t * cross-visibility nudge in the tool response. When omitted, `summarizeGoalState` gets\n\t * no task-step context and simply emits no nudge -- goal-tool-core stays pure and never reads\n\t * task state itself; this is the only place that supplies it.\n\t */\n\tgetOpenTaskSteps?: () => readonly OpenTaskStepRef[];\n\t/** Live background tool_task records for kind:\"tool\" evidence and complete-time re-check. */\n\tgetBackgroundToolTasks?: () => readonly BackgroundToolTaskRef[];\n\t/** Active ICM pipeline run for the complete/increment join. */\n\tgetActivePipeline?: () => { runId: string; pipelineName: string; goalId?: string; status: string } | undefined;\n\t/** Model-facing budget normalization for the current foreground turn. Omitted by direct owner/test callers. */\n\tauthorizeStart?: (input: Pick<GoalToolInput, \"userGoal\" | \"tokenBudget\">) => string | number | null | undefined;\n\t/**\n\t * Live tool-evidence check. When wired, kind:\"tool\" uses this instead of {@link hasToolCallId}\n\t * so a still-running background handoff cannot verify as done.\n\t */\n\tresolveToolEvidence?: (uri: string) => boolean;\n}\n\nfunction allowsNativeTmuxFallback(reason: string | undefined): boolean {\n\treturn reason === \"tmux_unavailable\" || reason === \"tmux_extension_not_loaded\";\n}\n\n/**\n * Validate an evidence ref's `uri` against session records (\"tool\") or the filesystem (\"file\").\n * Returns `undefined` for kinds/refs that carry nothing checkable (e.g. \"user\"/\"finding\"/\"test\",\n * or a missing `uri`) -- absence of a ref is not the same as a ref that failed to verify.\n */\nasync function resolveEvidenceVerified(\n\tkind: GoalEvidenceKind,\n\turi: string | undefined,\n\tdeps: GoalToolDependencies,\n): Promise<boolean | undefined> {\n\tconst trimmedUri = uri?.trim();\n\tif (!trimmedUri) return undefined;\n\tif (kind === \"tool\") {\n\t\tif (deps.resolveToolEvidence) return deps.resolveToolEvidence(trimmedUri);\n\t\treturn deps.hasToolCallId ? deps.hasToolCallId(trimmedUri) : false;\n\t}\n\tif (kind === \"file\") {\n\t\tconst cwd = deps.cwd?.() ?? process.cwd();\n\t\ttry {\n\t\t\tconst stats = await fsStat(resolveToCwd(trimmedUri, cwd));\n\t\t\treturn stats.isFile();\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\tif (kind === \"worker\") {\n\t\tif (!deps.getLaneRecords || !deps.getWorkerClaimSnapshots) return false;\n\t\tconst laneId = trimmedUri;\n\t\tconst record = deps.getLaneRecords().find((candidate) => candidate.laneId === laneId);\n\t\tif (!record) return false;\n\t\tconst claim = deps.getWorkerClaimSnapshots().find((candidate) => candidate.requestId === laneId);\n\t\tif (!claim) return false;\n\t\t// An unreviewed mutation (parentReviewRequired && no parentReviewedAt) can never verify true --\n\t\t// this is what stops an unreviewed worker completion from ungating goal completion through\n\t\t// the existing verified/complete gate (goal-tool-core's isVerifiedOrUserEvidence/complete).\n\t\tif (claim.parentReviewRequired === true && claim.parentReviewedAt === undefined) return false;\n\t\treturn claim.status === \"completed\";\n\t}\n\treturn undefined;\n}\n\nfunction generatedGoalRecordId(prefix: \"req\" | \"ev\", value: unknown): string {\n\treturn `${prefix}-${createHash(\"sha256\").update(JSON.stringify(value)).digest(\"hex\").slice(0, 16)}`;\n}\n\nfunction toGoalAction(input: GoalToolInput): GoalAction | { error: string } {\n\tswitch (input.action) {\n\t\tcase \"start\":\n\t\t\treturn {\n\t\t\t\taction: \"start\",\n\t\t\t\tgoalId: input.goalId ?? \"\",\n\t\t\t\tuserGoal: input.userGoal ?? \"\",\n\t\t\t\ttokenBudget: input.tokenBudget,\n\t\t\t};\n\t\tcase \"add_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"add_requirement\",\n\t\t\t\trequirementId:\n\t\t\t\t\tinput.requirementId ??\n\t\t\t\t\tgeneratedGoalRecordId(\"req\", {\n\t\t\t\t\t\ttext: input.text?.trim() ?? \"\",\n\t\t\t\t\t\tdependencies: [...(input.dependencies ?? [])].map((value) => value.trim()).sort(),\n\t\t\t\t\t}),\n\t\t\t\ttext: input.text ?? \"\",\n\t\t\t\tdependencies: input.dependencies,\n\t\t\t};\n\t\tcase \"satisfy_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"satisfy_requirement\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\tevidenceIds: input.evidenceIds,\n\t\t\t};\n\t\tcase \"block_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"block_requirement\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\treason: input.reason ?? \"\",\n\t\t\t};\n\t\tcase \"reopen_requirement\":\n\t\t\treturn { action: \"reopen_requirement\", requirementId: input.requirementId ?? \"\" };\n\t\tcase \"dispatch_worker\":\n\t\t\treturn {\n\t\t\t\taction: \"dispatch_worker\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\tinstructions: input.instructions ?? \"\",\n\t\t\t};\n\t\tcase \"add_evidence\": {\n\t\t\tif (input.kind === undefined) {\n\t\t\t\treturn { error: \"add_evidence requires a kind.\" };\n\t\t\t}\n\t\t\tconst kind: GoalEvidenceKind = input.kind;\n\t\t\treturn {\n\t\t\t\taction: \"add_evidence\",\n\t\t\t\tevidenceId:\n\t\t\t\t\tinput.evidenceId ??\n\t\t\t\t\tgeneratedGoalRecordId(\"ev\", {\n\t\t\t\t\t\tkind,\n\t\t\t\t\t\tsummary: input.summary?.trim() ?? \"\",\n\t\t\t\t\t\turi: input.uri?.trim() ?? \"\",\n\t\t\t\t\t}),\n\t\t\t\tkind,\n\t\t\t\tsummary: input.summary ?? \"\",\n\t\t\t\turi: input.uri,\n\t\t\t};\n\t\t}\n\t\tcase \"progress\":\n\t\t\treturn { action: \"progress\" };\n\t\tcase \"no_progress\":\n\t\t\treturn { action: \"no_progress\" };\n\t\tcase \"complete\":\n\t\t\treturn { action: \"complete\" };\n\t\tcase \"increment\":\n\t\t\treturn { action: \"increment\" };\n\t\tcase \"block_goal\":\n\t\t\treturn { action: \"block_goal\", reason: input.reason ?? \"\" };\n\t\tcase \"get\":\n\t\t\treturn { error: \"get is handled as a read-only action.\" };\n\t\tdefault:\n\t\t\treturn { error: \"Unknown goal action.\" };\n\t}\n}\n\nfunction goalPanelModel(details: GoalToolDetails | undefined): OrchestrationPanelModel {\n\tconst state = details?.state;\n\tif (!state) {\n\t\treturn {\n\t\t\tlabel: \"goal\",\n\t\t\taction: details?.action,\n\t\t\tstatus: details?.error ? \"error\" : \"idle\",\n\t\t\temptyText: details?.error ?? \"No goal state was returned.\",\n\t\t};\n\t}\n\tconst satisfied = state.requirements.filter((requirement) => requirement.status === \"satisfied\").length;\n\treturn {\n\t\tlabel: \"goal\",\n\t\taction: details.action,\n\t\tstatus:\n\t\t\tstate.status === \"completed\"\n\t\t\t\t? \"success\"\n\t\t\t\t: state.status === \"blocked\" ||\n\t\t\t\t\t\tstate.status === \"paused\" ||\n\t\t\t\t\t\tstate.status === \"usage_limited\" ||\n\t\t\t\t\t\tstate.status === \"budget_limited\"\n\t\t\t\t\t? \"warning\"\n\t\t\t\t\t: state.status === \"cancelled\"\n\t\t\t\t\t\t? \"idle\"\n\t\t\t\t\t\t: \"running\",\n\t\tsummary: [\n\t\t\t`${satisfied}/${state.requirements.length} requirements`,\n\t\t\t`${state.evidence.length} evidence`,\n\t\t\t...(state.tokenBudget !== undefined ? [`${state.tokensUsed ?? 0}/${state.tokenBudget} tokens`] : []),\n\t\t],\n\t\trows: state.requirements.map((requirement) => ({\n\t\t\tstatus:\n\t\t\t\trequirement.status === \"satisfied\"\n\t\t\t\t\t? (\"completed\" as const)\n\t\t\t\t\t: requirement.status === \"open\"\n\t\t\t\t\t\t? (\"pending\" as const)\n\t\t\t\t\t\t: (\"blocked\" as const),\n\t\t\tlabel: requirement.text,\n\t\t\tmeta: [\n\t\t\t\trequirement.id,\n\t\t\t\trequirement.evidenceIds.length > 0 ? `${requirement.evidenceIds.length} evidence` : undefined,\n\t\t\t\trequirement.boundLaneId ? `worker ${requirement.boundLaneId}` : undefined,\n\t\t\t].filter((value): value is string => value !== undefined),\n\t\t\tdetails: requirement.blockedReason ? [`blocked: ${requirement.blockedReason}`] : undefined,\n\t\t})),\n\t\tnotices: [\n\t\t\t...(details.dispatchSkipReason\n\t\t\t\t? [{ status: \"warning\" as const, text: `Worker dispatch skipped: ${details.dispatchSkipReason}` }]\n\t\t\t\t: []),\n\t\t\t...(state.blockedReason ? [{ status: \"warning\" as const, text: state.blockedReason }] : []),\n\t\t],\n\t\temptyText: \"No requirements recorded.\",\n\t};\n}\n\nexport function createGoalToolDefinition(deps: GoalToolDependencies): GoalToolDefinition {\n\tconst now = deps.now ?? (() => new Date().toISOString());\n\treturn {\n\t\tname: LEGACY_GOAL_TOOL_NAME,\n\t\tlabel: \"goal\",\n\t\tdescription:\n\t\t\t\"Read or update the durable goal for work that benefits from persistent autonomous continuation. The agent may start one at its discretion or on explicit user/system request; only the owner or system may set a token budget.\",\n\t\tpromptSnippet: \"Read or update the durable goal.\",\n\t\tpromptGuidelines: [\n\t\t\t\"Start when persistent continuation materially benefits current work or the user/system requests it. Skip routine one-turn tasks; get if uncertain; never replace unfinished goal; tokenBudget only if requested.\",\n\t\t\t\"Plans: task_steps. Workers: delegate. Background tools: tool_task wait once; cite taskId as kind=tool evidence.\",\n\t\t\t\"increment satisfies the current open requirement from unused evidence, or completes when none remain.\",\n\t\t\t\"complete needs current authoritative evidence, no remaining work, no linked open task_steps, no running tool_task, no active pipeline. block_goal needs same real impasse for 3 goal turns.\",\n\t\t],\n\t\tparameters: goalSchema,\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\tconst details = result.details as GoalToolDetails | undefined;\n\t\t\treturn renderOrchestrationToolResult(theme, goalPanelModel(details), {\n\t\t\t\tisPartial,\n\t\t\t\tcollapse: !expanded && details?.applied === true,\n\t\t\t\texpanded: true,\n\t\t\t});\n\t\t},\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\tinput: GoalToolInput,\n\t\t): Promise<{\n\t\t\tcontent: Array<{ type: \"text\"; text: string }>;\n\t\t\tdetails: GoalToolDetails;\n\t\t\tisError?: boolean;\n\t\t}> {\n\t\t\tif (input.action === \"get\") {\n\t\t\t\tconst state = deps.getGoalState();\n\t\t\t\tif (!state) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"No goal exists for this session.\" }],\n\t\t\t\t\t\tdetails: { action: \"get\", applied: false },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: summarizeGoalState(state) }],\n\t\t\t\t\tdetails: { action: \"get\", applied: false, state },\n\t\t\t\t};\n\t\t\t}\n\t\t\tlet normalizedInput = input;\n\t\t\tif (input.action === \"start\" && deps.authorizeStart) {\n\t\t\t\tconst authority = deps.authorizeStart(input);\n\t\t\t\tif (typeof authority === \"string\") {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: `goal start failed: ${authority}` }],\n\t\t\t\t\t\tdetails: { action: \"start\", applied: false, error: authority },\n\t\t\t\t\t\tisError: true,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tnormalizedInput = {\n\t\t\t\t\t...input,\n\t\t\t\t\t...(typeof authority === \"number\" ? { tokenBudget: authority } : {}),\n\t\t\t\t};\n\t\t\t\tif (authority === null) delete normalizedInput.tokenBudget;\n\t\t\t}\n\t\t\tconst mapped = toGoalAction(normalizedInput);\n\t\t\tif (\"error\" in mapped) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${mapped.error}` }],\n\t\t\t\t\tdetails: { action: input.action, applied: false, error: mapped.error },\n\t\t\t\t\tisError: true,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tlet action: GoalAction = mapped;\n\t\t\tif (action.action === \"add_evidence\") {\n\t\t\t\tconst verified = await resolveEvidenceVerified(action.kind, action.uri, deps);\n\t\t\t\taction = { ...action, verified };\n\t\t\t}\n\t\t\t// Honest dispatch reporting: distinguish \"dispatched\" (laneId), \"declined\" (skipReason --\n\t\t\t// the dependency IS wired but the underlying delegation starter refused, e.g. disabled or\n\t\t\t// already at capacity), and \"unwired\" (no dependency at all) -- never collapse a real\n\t\t\t// decline into a silent no-laneId no-op indistinguishable from the dep being absent.\n\t\t\tlet dispatchNote: string | undefined;\n\t\t\tlet dispatchSkipReason: string | undefined;\n\t\t\t// Indeterminate-binding dedupe guard: checked BEFORE any dispatch side effect, for BOTH\n\t\t\t// routes. A requirement already bound to a lane that is either still live (a plain\n\t\t\t// duplicate) or whose liveness/outcome cannot be determined at all (for example, a legacy\n\t\t\t// snapshot with no lane record or worker result) must never be\n\t\t\t// re-dispatched silently; only a CONFIRMED terminal outcome allows a legitimate retry.\n\t\t\tlet dispatchGuardRefused = false;\n\t\t\tif (action.action === \"dispatch_worker\") {\n\t\t\t\t// Captured into a `const` so the \"dispatch_worker\" narrowing survives into the closures\n\t\t\t\t// below -- TS does not narrow a `let`-bound outer variable across a callback boundary.\n\t\t\t\tconst dispatchAction = action;\n\t\t\t\tconst boundRequirement = deps\n\t\t\t\t\t.getGoalState()\n\t\t\t\t\t?.requirements.find((r) => r.id === dispatchAction.requirementId);\n\t\t\t\tconst bound = boundRequirement?.boundLaneId;\n\t\t\t\tif (bound !== undefined) {\n\t\t\t\t\tconst boundLaneRecord = deps.getLaneRecords?.().find((record) => record.laneId === bound);\n\t\t\t\t\tconst isLiveInFlight =\n\t\t\t\t\t\tboundLaneRecord !== undefined &&\n\t\t\t\t\t\t(boundLaneRecord.status === \"queued\" || boundLaneRecord.status === \"running\");\n\t\t\t\t\tif (isLiveInFlight) {\n\t\t\t\t\t\tdispatchSkipReason = \"requirement_already_bound\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// `boundLaneRecord` present here is necessarily terminal (isLiveInFlight was false).\n\t\t\t\t\t\tconst hasTerminalOutcome =\n\t\t\t\t\t\t\tboundLaneRecord !== undefined ||\n\t\t\t\t\t\t\t(deps.getWorkerClaimSnapshots?.().some((claim) => claim.requestId === bound) ?? false);\n\t\t\t\t\t\tif (!hasTerminalOutcome) dispatchSkipReason = \"bound_lane_indeterminate\";\n\t\t\t\t\t}\n\t\t\t\t\tif (dispatchSkipReason) {\n\t\t\t\t\t\tdispatchGuardRefused = true;\n\t\t\t\t\t\tdispatchNote = `No worker was dispatched (${dispatchSkipReason}); requirement '${dispatchAction.requirementId}' remains bound to lane '${bound}'.`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (action.action === \"dispatch_worker\" && !dispatchGuardRefused) {\n\t\t\t\tconst tmuxRequested = input.dispatchTarget === \"tmux\";\n\t\t\t\tlet useTmux = tmuxRequested && deps.dispatchTmuxWorker !== undefined;\n\t\t\t\tlet tmuxFallbackReason: string | undefined;\n\t\t\t\tlet dispatched: { laneId?: string; skipReason?: string } | undefined;\n\t\t\t\tif (useTmux) {\n\t\t\t\t\tdispatched = await deps.dispatchTmuxWorker?.({\n\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t});\n\t\t\t\t\tif (\n\t\t\t\t\t\t!dispatched?.laneId &&\n\t\t\t\t\t\tallowsNativeTmuxFallback(dispatched?.skipReason) &&\n\t\t\t\t\t\tdeps.startWorkerDelegation\n\t\t\t\t\t) {\n\t\t\t\t\t\ttmuxFallbackReason = dispatched?.skipReason;\n\t\t\t\t\t\tuseTmux = false;\n\t\t\t\t\t\tdispatched = deps.startWorkerDelegation({\n\t\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (tmuxRequested) tmuxFallbackReason = \"tmux_extension_not_loaded\";\n\t\t\t\t\tdispatched = deps.startWorkerDelegation?.({\n\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\taction = { ...action, laneId: dispatched?.laneId };\n\t\t\t\tif (dispatched?.laneId) {\n\t\t\t\t\tdispatchNote = tmuxFallbackReason\n\t\t\t\t\t\t? `Tmux route returned ${tmuxFallbackReason}; dispatched native fallback worker lane '${dispatched.laneId}' for requirement '${action.requirementId}'.`\n\t\t\t\t\t\t: useTmux\n\t\t\t\t\t\t\t? `Dispatched tmux worker lane '${dispatched.laneId}' for requirement '${action.requirementId}'.`\n\t\t\t\t\t\t\t: `Dispatched in-process worker lane '${dispatched.laneId}' for requirement '${action.requirementId}' (native default).`;\n\t\t\t\t} else {\n\t\t\t\t\tconst wired = useTmux ? deps.dispatchTmuxWorker : deps.startWorkerDelegation;\n\t\t\t\t\tdispatchSkipReason = dispatched?.skipReason ?? (wired ? \"declined\" : \"dependency_unwired\");\n\t\t\t\t\tdispatchNote = `${tmuxFallbackReason ? `Tmux route returned ${tmuxFallbackReason}; ` : \"\"}No worker was dispatched (${dispatchSkipReason}); requirement '${action.requirementId}' is recorded but not bound to a lane.`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst current = deps.getGoalState();\n\t\t\tlet nextState: GoalState;\n\t\t\tif (action.action === \"dispatch_worker\" && dispatchGuardRefused) {\n\t\t\t\t// Short-circuit: the guard refused before any dispatch attempt -- never call\n\t\t\t\t// applyGoalAction for this turn, so the requirement's existing `boundLaneId` is\n\t\t\t\t// preserved exactly as-is rather than clobbered to `undefined` by the reducer's\n\t\t\t\t// unconditional `boundLaneId: event.laneId` write (goal-state.ts's dispatch_worker case).\n\t\t\t\t// `current` is guaranteed defined here: the guard only refuses when a requirement with\n\t\t\t\t// a `boundLaneId` was found on it.\n\t\t\t\tnextState = current as GoalState;\n\t\t\t} else {\n\t\t\t\tlet activePipeline: ReturnType<NonNullable<GoalToolDependencies[\"getActivePipeline\"]>>;\n\t\t\t\tif (\n\t\t\t\t\tcurrent &&\n\t\t\t\t\tisGoalExecutionActive(current.status) &&\n\t\t\t\t\t(action.action === \"complete\" || action.action === \"increment\")\n\t\t\t\t) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tactivePipeline = deps.getActivePipeline?.();\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconst message = `Cannot verify active pipeline state: ${error instanceof Error ? error.message : String(error)}`;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${message}` }],\n\t\t\t\t\t\t\tdetails: { action: input.action, applied: false, error: message, state: current },\n\t\t\t\t\t\t\tisError: true,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst result = applyGoalAction(current, action, now(), {\n\t\t\t\t\trequireVerifiedEvidenceForCompletion: deps.requireVerifiedEvidenceForCompletion?.() ?? true,\n\t\t\t\t\topenTaskSteps: deps.getOpenTaskSteps?.(),\n\t\t\t\t\tbackgroundToolTasks: deps.getBackgroundToolTasks?.(),\n\t\t\t\t\tactivePipeline,\n\t\t\t\t});\n\t\t\t\tif (!result.ok) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${result.error}` }],\n\t\t\t\t\t\tdetails: { action: input.action, applied: false, error: result.error, state: current },\n\t\t\t\t\t\tisError: true,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tdeps.saveGoalState(result.state, current ? getGoalStateRevision(current) : undefined);\n\t\t\t\tnextState = result.state;\n\t\t\t}\n\n\t\t\tconst summary = summarizeGoalState(nextState, { action, openTaskSteps: deps.getOpenTaskSteps?.() });\n\t\t\tconst text = dispatchNote\n\t\t\t\t? `goal ${input.action} recorded.\\n${summary}\\n${dispatchNote}`\n\t\t\t\t: `goal ${input.action} recorded.\\n${summary}`;\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\" as const, text }],\n\t\t\t\tdetails: {\n\t\t\t\t\taction: input.action,\n\t\t\t\t\tapplied: true,\n\t\t\t\t\tstate: nextState,\n\t\t\t\t\t...(action.action === \"dispatch_worker\" && action.laneId ? { dispatchedLaneId: action.laneId } : {}),\n\t\t\t\t\t...(action.action === \"dispatch_worker\" && !action.laneId ? { dispatchSkipReason } : {}),\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t};\n}\n\n/**\n * Build the compact Codex-compatible lifecycle surface as adapters over the authoritative legacy\n * goal executor. The wrappers own no state and duplicate no validation, persistence, accounting,\n * completion gate, or start-authority rule.\n */\nexport function createGoalLifecycleToolDefinitions(goalTool: GoalToolDefinition) {\n\tconst createGoal: ToolDefinition = {\n\t\tname: GOAL_LIFECYCLE_TOOL_NAMES[0],\n\t\tlabel: GOAL_LIFECYCLE_TOOL_NAMES[0],\n\t\tdescription:\n\t\t\t\"Create a durable goal when persistent autonomous continuation materially benefits the current work, or when the user/system explicitly requests one. Use agent discretion; skip routine short tasks. Set token_budget only when explicitly requested. Fails if an unfinished goal exists.\",\n\t\tpromptSnippet: \"Start durable goal.\",\n\t\tparameters: createGoalSchema,\n\t\texecute(toolCallId, input: Static<typeof createGoalSchema>, signal, onUpdate, context) {\n\t\t\treturn goalTool.execute(\n\t\t\t\ttoolCallId,\n\t\t\t\t{\n\t\t\t\t\taction: \"start\",\n\t\t\t\t\tgoalId: `goal-${randomUUID()}`,\n\t\t\t\t\tuserGoal: input.objective,\n\t\t\t\t\ttokenBudget: input.token_budget,\n\t\t\t\t},\n\t\t\t\tsignal,\n\t\t\t\tonUpdate,\n\t\t\t\tcontext,\n\t\t\t);\n\t\t},\n\t};\n\n\tconst getGoal: ToolDefinition = {\n\t\tname: GOAL_LIFECYCLE_TOOL_NAMES[1],\n\t\tlabel: GOAL_LIFECYCLE_TOOL_NAMES[1],\n\t\tdescription:\n\t\t\t\"Get the current goal for this session, including status, budget, token and elapsed-time usage, requirements, evidence, and progress.\",\n\t\tpromptSnippet: \"Inspect durable goal.\",\n\t\tparameters: getGoalSchema,\n\t\texecute(toolCallId, _input, signal, onUpdate, context) {\n\t\t\treturn goalTool.execute(toolCallId, { action: \"get\" }, signal, onUpdate, context);\n\t\t},\n\t};\n\n\tconst updateGoal: ToolDefinition = {\n\t\tname: GOAL_LIFECYCLE_TOOL_NAMES[2],\n\t\tlabel: GOAL_LIFECYCLE_TOOL_NAMES[2],\n\t\tdescription:\n\t\t\t\"Update the existing goal. Set active only after concrete, verifiable progress in the current turn. Mark complete only when current evidence proves the full objective is achieved and no required work remains. Mark blocked only after the same blocking condition has recurred for at least three consecutive goal turns and no meaningful progress is possible without user input or external change; include that condition in reason. Never use blocked merely because work is hard, slow, uncertain, incomplete, or would benefit from clarification.\",\n\t\tpromptSnippet: \"Update goal; complete/block only with evidence.\",\n\t\tparameters: updateGoalSchema,\n\t\texecute(toolCallId, input: Static<typeof updateGoalSchema>, signal, onUpdate, context) {\n\t\t\tconst requestedGoalStatus: GoalStatus = input.status === \"complete\" ? \"completed\" : input.status;\n\t\t\tconst action: GoalToolInput = isGoalExecutionActive(requestedGoalStatus)\n\t\t\t\t? { action: \"progress\" }\n\t\t\t\t: input.status === \"complete\"\n\t\t\t\t\t? { action: \"complete\" }\n\t\t\t\t\t: { action: \"block_goal\", reason: input.reason ?? \"\" };\n\t\t\treturn goalTool.execute(toolCallId, action, signal, onUpdate, context);\n\t\t},\n\t};\n\n\treturn [createGoal, getGoal, updateGoal] as const;\n}\n"]}
1
+ {"version":3,"file":"goal.js","sourceRoot":"","sources":["../../../src/core/tools/goal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAK5C,OAAO,EAA0B,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAC1F,OAAO,EAA0D,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACvH,OAAO,EACN,eAAe,EAIf,kBAAkB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,6BAA6B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C,KAAK,CAAC,MAAM,CAAC;YACjG,MAAM,MAAM,GAAkB,qBAAqB,CAAC,mBAAmB,CAAC;gBACvE,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE;gBACxB,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,UAAU;oBAC5B,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE;oBACxB,CAAC,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;YACzD,OAAO,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QACxE,CAAC;KACD,CAAC;IAEF,OAAO,CAAC,UAAU,EAAE,OAAO,EAAE,UAAU,CAAU,CAAC;AACnD,CAAC","sourcesContent":["import { createHash, randomUUID } from \"node:crypto\";\nimport { stat as fsStat } from \"node:fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport type { WorkerClaim } from \"../autonomy/contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport type { BackgroundToolTaskRef } from \"../background-tool-task-controller.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type GoalStateRevision, getGoalStateRevision } from \"../goals/goal-lifecycle.ts\";\nimport { type GoalEvidenceKind, type GoalState, type GoalStatus, isGoalExecutionActive } from \"../goals/goal-state.ts\";\nimport {\n\tapplyGoalAction,\n\ttype GoalAction,\n\ttype GoalActionName,\n\ttype OpenTaskStepRef,\n\tsummarizeGoalState,\n} from \"../goals/goal-tool-core.ts\";\nimport { GOAL_LIFECYCLE_TOOL_NAMES, LEGACY_GOAL_TOOL_NAME } from \"../goals/goal-tool-names.ts\";\nimport {\n\temptyOrchestrationCall,\n\ttype OrchestrationPanelModel,\n\trenderOrchestrationToolResult,\n} from \"./orchestration-panel.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\n\nconst goalSchema = Type.Object(\n\t{\n\t\taction: Type.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"get\"),\n\t\t\t\tType.Literal(\"start\"),\n\t\t\t\tType.Literal(\"add_requirement\"),\n\t\t\t\tType.Literal(\"satisfy_requirement\"),\n\t\t\t\tType.Literal(\"block_requirement\"),\n\t\t\t\tType.Literal(\"reopen_requirement\"),\n\t\t\t\tType.Literal(\"dispatch_worker\"),\n\t\t\t\tType.Literal(\"add_evidence\"),\n\t\t\t\tType.Literal(\"progress\"),\n\t\t\t\tType.Literal(\"no_progress\"),\n\t\t\t\tType.Literal(\"complete\"),\n\t\t\t\tType.Literal(\"increment\"),\n\t\t\t\tType.Literal(\"block_goal\"),\n\t\t\t],\n\t\t\t{ description: \"Goal record action.\" },\n\t\t),\n\t\tgoalId: Type.Optional(Type.String({ description: \"Stable goal id. Required for action 'start'.\" })),\n\t\tuserGoal: Type.Optional(Type.String({ description: \"The goal statement. Required for action 'start'.\" })),\n\t\ttokenBudget: Type.Optional(\n\t\t\tType.Integer({ minimum: 1, description: \"Optional positive token budget for action 'start'.\" }),\n\t\t),\n\t\trequirementId: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"Requirement id for requirement actions. Omit on add_requirement for a stable host id.\",\n\t\t\t}),\n\t\t),\n\t\ttext: Type.Optional(Type.String({ description: \"Requirement text. Required for add_requirement.\" })),\n\t\tdependencies: Type.Optional(\n\t\t\tType.Array(Type.String(), {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Optional IDs of requirements that must be satisfied before this one. Valid for add_requirement.\",\n\t\t\t}),\n\t\t),\n\t\tinstructions: Type.Optional(Type.String({ description: \"Worker instructions. Required for dispatch_worker.\" })),\n\t\tevidenceId: Type.Optional(\n\t\t\tType.String({ description: \"Evidence id. Omit on add_evidence for a stable host id.\" }),\n\t\t),\n\t\tevidenceIds: Type.Optional(\n\t\t\tType.Array(Type.String(), {\n\t\t\t\tdescription: \"Existing evidence ids for satisfy_requirement.\",\n\t\t\t}),\n\t\t),\n\t\tkind: Type.Optional(\n\t\t\tType.Union(\n\t\t\t\t[\n\t\t\t\t\tType.Literal(\"file\"),\n\t\t\t\t\tType.Literal(\"test\"),\n\t\t\t\t\tType.Literal(\"tool\"),\n\t\t\t\t\tType.Literal(\"user\"),\n\t\t\t\t\tType.Literal(\"finding\"),\n\t\t\t\t\tType.Literal(\"worker\"),\n\t\t\t\t],\n\t\t\t\t{ description: \"Evidence kind. Required for add_evidence.\" },\n\t\t\t),\n\t\t),\n\t\tsummary: Type.Optional(Type.String({ description: \"Evidence summary. Required for add_evidence.\" })),\n\t\turi: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"Optional file/URL, toolCallId, or laneId evidence locator.\",\n\t\t\t}),\n\t\t),\n\t\treason: Type.Optional(Type.String({ description: \"Reason for block_requirement or block_goal.\" })),\n\t\tdispatchTarget: Type.Optional(\n\t\t\tType.Union([Type.Literal(\"in_process\"), Type.Literal(\"tmux\")], {\n\t\t\t\tdescription: \"Legacy target. Native is default; use tmux when the task benefits from a persistent pane.\",\n\t\t\t}),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst createGoalSchema = Type.Object(\n\t{\n\t\tobjective: Type.String({ description: \"Required. The concrete objective to start pursuing.\" }),\n\t\ttoken_budget: Type.Optional(\n\t\t\tType.Integer({ minimum: 1, description: \"Positive token budget. Omit unless explicitly requested.\" }),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst getGoalSchema = Type.Object({}, { additionalProperties: false });\n\nconst updateGoalSchema = Type.Object(\n\t{\n\t\tstatus: Type.Union([Type.Literal(\"active\"), Type.Literal(\"complete\"), Type.Literal(\"blocked\")], {\n\t\t\tdescription:\n\t\t\t\t\"Set active after concrete progress, complete after an evidence audit, or blocked after the same blocker persists for three turns.\",\n\t\t}),\n\t\treason: Type.Optional(\n\t\t\tType.String({ minLength: 1, description: \"Required for blocked: the recurring external blocker.\" }),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type GoalToolInput = Static<typeof goalSchema>;\nexport type GoalToolDefinition = ToolDefinition;\n\nexport interface GoalToolDetails {\n\taction: GoalActionName | \"get\";\n\tapplied: boolean;\n\terror?: string;\n\tstate?: GoalState;\n\t/** Set on 'dispatch_worker' when a worker lane actually started; mirrors the requirement's\n\t * new `boundLaneId`. The in-process route by default, or a real persistent tmux lane when\n\t * `dispatchTarget:\"tmux\"` was selected and routed -- see {@link GoalToolDependencies.dispatchTmuxWorker}. */\n\tdispatchedLaneId?: string;\n\t/** Set on 'dispatch_worker' when no worker was dispatched: a wired dependency declined (e.g. worker\n\t * delegation disabled, already at capacity, or an honest tmux skip reason -- see\n\t * {@link GoalToolDependencies.dispatchTmuxWorker}), or the indeterminate-binding guard refused a\n\t * re-dispatch against an already-bound requirement (`requirement_already_bound`/`bound_lane_indeterminate`).\n\t * The binding is recorded (or, for a guard refusal, left exactly as it was) with no NEW laneId. */\n\tdispatchSkipReason?: string;\n}\n\nexport interface GoalToolDependencies {\n\t/** Read the latest persisted goal state for the active session. */\n\tgetGoalState: () => GoalState | undefined;\n\t/** Persist a new goal state snapshot to the active session. */\n\tsaveGoalState: (state: GoalState, expected?: GoalStateRevision) => void;\n\t/** Clock injection for deterministic tests. */\n\tnow?: () => string;\n\t/**\n\t * Check whether `toolCallId` exists in this session's records, for validating kind:\"tool\"\n\t * evidence refs at add_evidence time. When not wired, a \"tool\" ref cannot be proven and is\n\t * recorded as `verified: false` rather than assumed true.\n\t */\n\thasToolCallId?: (toolCallId: string) => boolean;\n\t/**\n\t * Read the session's live worker lane records, for validating kind:\"worker\" evidence refs\n\t * (the `uri` is a laneId) at add_evidence time and refusing completion while goal-owned work is\n\t * queued or running. Read-defensive: when not wired -- exactly like `hasToolCallId` -- a \"worker\"\n\t * ref cannot be proven and is recorded as `verified: false` rather than assumed true.\n\t */\n\tgetLaneRecords?: () => readonly LaneRecord[];\n\t/**\n\t * Read persisted worker claim snapshots (keyed by `WorkerClaim.requestId`, which is the same\n\t * id as the dispatching lane's laneId), for validating kind:\"worker\" evidence refs. See\n\t * {@link getLaneRecords}. A matching claim that is `parentReviewRequired && !parentReviewedAt`\n\t * verifies `false` -- an unreviewed worker completion must never ungate goal completion through\n\t * the existing verified/complete gate.\n\t */\n\tgetWorkerClaimSnapshots?: () => readonly WorkerClaim[];\n\t/**\n\t * Tool-layer side effect for a 'dispatch_worker' action when `dispatchTarget` is 'in_process'\n\t * (the default) or when {@link dispatchTmuxWorker} is not wired: dispatches a real in-process\n\t * worker lane for the given requirement and returns the resulting laneId to bind onto it. When\n\t * the dependency is present but the underlying delegation starter declines (disabled, already at\n\t * capacity, etc.), return `{ skipReason }` instead of a laneId -- a real, non-silent skip that\n\t * the tool response surfaces, distinct from this dependency being altogether unwired (`undefined`\n\t * dep, or the dep returning `undefined`), which records the binding attempt structurally with no\n\t * laneId (a no-op).\n\t */\n\tstartWorkerDelegation?: (args: {\n\t\trequirementId: string;\n\t\tinstructions: string;\n\t}) => { laneId?: string; skipReason?: string } | undefined;\n\t/**\n\t * Tool-layer side effect for a 'dispatch_worker' action when `input.dispatchTarget === \"tmux\"`:\n\t * dispatches a REAL persistent tmux worker via the tmux_agent_manager extension's `fire_task`\n\t * action (core structurally invokes the same tool call the model would make; no extension change,\n\t * no faked launch or laneId -- see `tmux-dispatch.ts`'s `dispatchTmuxWorker`). Selected ONLY when\n\t * BOTH `input.dispatchTarget === \"tmux\"` AND this dependency is present; otherwise the EXISTING\n\t * {@link startWorkerDelegation} in-process path runs, byte-identical to before this field existed.\n\t * The honest skip-reason vocabulary this can return: `tmux_extension_not_loaded`,\n\t * `tmux_dispatch_failed`, `tmux_dispatch_incomplete`, `lane_correlation_failed`,\n\t * `worktree_create_failed` (worktree-sync is enabled but the lane-first `create_lane` call was\n\t * refused -- e.g. max lanes reached -- so no fire_task call was ever attempted),\n\t * `worker_capability_insufficient` (the model is sub-full class, has an unknown context window,\n\t * does not advertise a native tool-call path, or is graded-demoted to text-protocol/none -- see\n\t * `model-capability.ts`'s `evaluateLaneWorkerRefusal`; this is the parent's best-effort check\n\t * only, refused before any lane/pane side effect -- the dispatched child still refuses\n\t * authoritatively at its own startup regardless).\n\t */\n\tdispatchTmuxWorker?: (args: {\n\t\trequirementId: string;\n\t\tinstructions: string;\n\t}) => Promise<{ laneId?: string; skipReason?: string }>;\n\t/** Working directory for resolving kind:\"file\" evidence ref paths. Defaults to `process.cwd()`. */\n\tcwd?: () => string;\n\t/**\n\t * Gate agent-facing 'complete' on verified/user evidence backing. Defaults to `true` (on)\n\t * when omitted -- the conservative default; set to a function returning `false` to opt out.\n\t */\n\trequireVerifiedEvidenceForCompletion?: () => boolean;\n\t/**\n\t * Read-only open (non-terminal) task_steps steps on the active branch, for the goal⇄task\n\t * cross-visibility nudge in the tool response. When omitted, `summarizeGoalState` gets\n\t * no task-step context and simply emits no nudge -- goal-tool-core stays pure and never reads\n\t * task state itself; this is the only place that supplies it.\n\t */\n\tgetOpenTaskSteps?: () => readonly OpenTaskStepRef[];\n\t/** Live background tool_task records for kind:\"tool\" evidence and complete-time re-check. */\n\tgetBackgroundToolTasks?: () => readonly BackgroundToolTaskRef[];\n\t/** Active ICM pipeline run for the complete/increment join. */\n\tgetActivePipeline?: () => { runId: string; pipelineName: string; goalId?: string; status: string } | undefined;\n\t/** Model-facing budget normalization for the current foreground turn. Omitted by direct owner/test callers. */\n\tauthorizeStart?: (input: Pick<GoalToolInput, \"userGoal\" | \"tokenBudget\">) => string | number | null | undefined;\n\t/**\n\t * Live tool-evidence check. When wired, kind:\"tool\" uses this instead of {@link hasToolCallId}\n\t * so a still-running background handoff cannot verify as done.\n\t */\n\tresolveToolEvidence?: (uri: string) => boolean;\n}\n\nfunction allowsNativeTmuxFallback(reason: string | undefined): boolean {\n\treturn reason === \"tmux_unavailable\" || reason === \"tmux_extension_not_loaded\";\n}\n\n/**\n * Validate an evidence ref's `uri` against session records (\"tool\") or the filesystem (\"file\").\n * Returns `undefined` for kinds/refs that carry nothing checkable (e.g. \"user\"/\"finding\"/\"test\",\n * or a missing `uri`) -- absence of a ref is not the same as a ref that failed to verify.\n */\nasync function resolveEvidenceVerified(\n\tkind: GoalEvidenceKind,\n\turi: string | undefined,\n\tdeps: GoalToolDependencies,\n): Promise<boolean | undefined> {\n\tconst trimmedUri = uri?.trim();\n\tif (!trimmedUri) return undefined;\n\tif (kind === \"tool\") {\n\t\tif (deps.resolveToolEvidence) return deps.resolveToolEvidence(trimmedUri);\n\t\treturn deps.hasToolCallId ? deps.hasToolCallId(trimmedUri) : false;\n\t}\n\tif (kind === \"file\") {\n\t\tconst cwd = deps.cwd?.() ?? process.cwd();\n\t\ttry {\n\t\t\tconst stats = await fsStat(resolveToCwd(trimmedUri, cwd));\n\t\t\treturn stats.isFile();\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\tif (kind === \"worker\") {\n\t\tif (!deps.getLaneRecords || !deps.getWorkerClaimSnapshots) return false;\n\t\tconst laneId = trimmedUri;\n\t\tconst record = deps.getLaneRecords().find((candidate) => candidate.laneId === laneId);\n\t\tif (!record) return false;\n\t\tconst claim = deps.getWorkerClaimSnapshots().find((candidate) => candidate.requestId === laneId);\n\t\tif (!claim) return false;\n\t\t// An unreviewed mutation (parentReviewRequired && no parentReviewedAt) can never verify true --\n\t\t// this is what stops an unreviewed worker completion from ungating goal completion through\n\t\t// the existing verified/complete gate (goal-tool-core's isVerifiedOrUserEvidence/complete).\n\t\tif (claim.parentReviewRequired === true && claim.parentReviewedAt === undefined) return false;\n\t\treturn claim.status === \"completed\";\n\t}\n\treturn undefined;\n}\n\nfunction generatedGoalRecordId(prefix: \"req\" | \"ev\", value: unknown): string {\n\treturn `${prefix}-${createHash(\"sha256\").update(JSON.stringify(value)).digest(\"hex\").slice(0, 16)}`;\n}\n\nfunction toGoalAction(input: GoalToolInput): GoalAction | { error: string } {\n\tswitch (input.action) {\n\t\tcase \"start\":\n\t\t\treturn {\n\t\t\t\taction: \"start\",\n\t\t\t\tgoalId: input.goalId ?? \"\",\n\t\t\t\tuserGoal: input.userGoal ?? \"\",\n\t\t\t\ttokenBudget: input.tokenBudget,\n\t\t\t};\n\t\tcase \"add_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"add_requirement\",\n\t\t\t\trequirementId:\n\t\t\t\t\tinput.requirementId ??\n\t\t\t\t\tgeneratedGoalRecordId(\"req\", {\n\t\t\t\t\t\ttext: input.text?.trim() ?? \"\",\n\t\t\t\t\t\tdependencies: [...(input.dependencies ?? [])].map((value) => value.trim()).sort(),\n\t\t\t\t\t}),\n\t\t\t\ttext: input.text ?? \"\",\n\t\t\t\tdependencies: input.dependencies,\n\t\t\t};\n\t\tcase \"satisfy_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"satisfy_requirement\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\tevidenceIds: input.evidenceIds,\n\t\t\t};\n\t\tcase \"block_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"block_requirement\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\treason: input.reason ?? \"\",\n\t\t\t};\n\t\tcase \"reopen_requirement\":\n\t\t\treturn { action: \"reopen_requirement\", requirementId: input.requirementId ?? \"\" };\n\t\tcase \"dispatch_worker\":\n\t\t\treturn {\n\t\t\t\taction: \"dispatch_worker\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\tinstructions: input.instructions ?? \"\",\n\t\t\t};\n\t\tcase \"add_evidence\": {\n\t\t\tif (input.kind === undefined) {\n\t\t\t\treturn { error: \"add_evidence requires a kind.\" };\n\t\t\t}\n\t\t\tconst kind: GoalEvidenceKind = input.kind;\n\t\t\treturn {\n\t\t\t\taction: \"add_evidence\",\n\t\t\t\tevidenceId:\n\t\t\t\t\tinput.evidenceId ??\n\t\t\t\t\tgeneratedGoalRecordId(\"ev\", {\n\t\t\t\t\t\tkind,\n\t\t\t\t\t\tsummary: input.summary?.trim() ?? \"\",\n\t\t\t\t\t\turi: input.uri?.trim() ?? \"\",\n\t\t\t\t\t}),\n\t\t\t\tkind,\n\t\t\t\tsummary: input.summary ?? \"\",\n\t\t\t\turi: input.uri,\n\t\t\t};\n\t\t}\n\t\tcase \"progress\":\n\t\t\treturn { action: \"progress\" };\n\t\tcase \"no_progress\":\n\t\t\treturn { action: \"no_progress\" };\n\t\tcase \"complete\":\n\t\t\treturn { action: \"complete\" };\n\t\tcase \"increment\":\n\t\t\treturn { action: \"increment\" };\n\t\tcase \"block_goal\":\n\t\t\treturn { action: \"block_goal\", reason: input.reason ?? \"\" };\n\t\tcase \"get\":\n\t\t\treturn { error: \"get is handled as a read-only action.\" };\n\t\tdefault:\n\t\t\treturn { error: \"Unknown goal action.\" };\n\t}\n}\n\nfunction goalPanelModel(details: GoalToolDetails | undefined): OrchestrationPanelModel {\n\tconst state = details?.state;\n\tif (!state) {\n\t\treturn {\n\t\t\tlabel: \"goal\",\n\t\t\taction: details?.action,\n\t\t\tstatus: details?.error ? \"error\" : \"idle\",\n\t\t\temptyText: details?.error ?? \"No goal state was returned.\",\n\t\t};\n\t}\n\tconst satisfied = state.requirements.filter((requirement) => requirement.status === \"satisfied\").length;\n\treturn {\n\t\tlabel: \"goal\",\n\t\taction: details.action,\n\t\tstatus:\n\t\t\tstate.status === \"completed\"\n\t\t\t\t? \"success\"\n\t\t\t\t: state.status === \"blocked\" ||\n\t\t\t\t\t\tstate.status === \"paused\" ||\n\t\t\t\t\t\tstate.status === \"usage_limited\" ||\n\t\t\t\t\t\tstate.status === \"budget_limited\"\n\t\t\t\t\t? \"warning\"\n\t\t\t\t\t: state.status === \"cancelled\"\n\t\t\t\t\t\t? \"idle\"\n\t\t\t\t\t\t: \"running\",\n\t\tsummary: [\n\t\t\t`${satisfied}/${state.requirements.length} requirements`,\n\t\t\t`${state.evidence.length} evidence`,\n\t\t\t...(state.tokenBudget !== undefined ? [`${state.tokensUsed ?? 0}/${state.tokenBudget} tokens`] : []),\n\t\t],\n\t\trows: state.requirements.map((requirement) => ({\n\t\t\tstatus:\n\t\t\t\trequirement.status === \"satisfied\"\n\t\t\t\t\t? (\"completed\" as const)\n\t\t\t\t\t: requirement.status === \"open\"\n\t\t\t\t\t\t? (\"pending\" as const)\n\t\t\t\t\t\t: (\"blocked\" as const),\n\t\t\tlabel: requirement.text,\n\t\t\tmeta: [\n\t\t\t\trequirement.id,\n\t\t\t\trequirement.evidenceIds.length > 0 ? `${requirement.evidenceIds.length} evidence` : undefined,\n\t\t\t\trequirement.boundLaneId ? `worker ${requirement.boundLaneId}` : undefined,\n\t\t\t].filter((value): value is string => value !== undefined),\n\t\t\tdetails: requirement.blockedReason ? [`blocked: ${requirement.blockedReason}`] : undefined,\n\t\t})),\n\t\tnotices: [\n\t\t\t...(details.dispatchSkipReason\n\t\t\t\t? [{ status: \"warning\" as const, text: `Worker dispatch skipped: ${details.dispatchSkipReason}` }]\n\t\t\t\t: []),\n\t\t\t...(state.blockedReason ? [{ status: \"warning\" as const, text: state.blockedReason }] : []),\n\t\t],\n\t\temptyText: \"No requirements recorded.\",\n\t};\n}\n\nfunction goalExecutionError(\n\taction: GoalToolDetails[\"action\"],\n\tmessage: string,\n\tstate: GoalState,\n): { content: Array<{ type: \"text\"; text: string }>; details: GoalToolDetails; isError: true } {\n\treturn {\n\t\tcontent: [{ type: \"text\", text: `goal ${action} failed: ${message}` }],\n\t\tdetails: { action, applied: false, error: message, state },\n\t\tisError: true,\n\t};\n}\n\nexport function createGoalToolDefinition(deps: GoalToolDependencies): GoalToolDefinition {\n\tconst now = deps.now ?? (() => new Date().toISOString());\n\treturn {\n\t\tname: LEGACY_GOAL_TOOL_NAME,\n\t\tlabel: \"goal\",\n\t\tdescription:\n\t\t\t\"Read or update the durable goal for work that benefits from persistent autonomous continuation. The agent may start one at its discretion or on explicit user/system request; only the owner or system may set a token budget.\",\n\t\tpromptSnippet: \"Read or update the durable goal.\",\n\t\tpromptGuidelines: [\n\t\t\t\"Start when persistent continuation materially benefits current work or the user/system requests it. Skip routine one-turn tasks; get if uncertain; never replace unfinished goal; tokenBudget only if requested.\",\n\t\t\t\"Plans: task_steps. Workers: delegate. Background tools: tool_task wait once; cite taskId as kind=tool evidence.\",\n\t\t\t\"increment satisfies the current open requirement from unused evidence, or completes when none remain.\",\n\t\t\t\"complete needs current authoritative evidence, no remaining work, no active goal-owned lanes, no open task_steps, no goal-owned running or cited non-completed tool_task, and no active pipeline. block_goal needs same real impasse for 3 goal turns.\",\n\t\t],\n\t\tparameters: goalSchema,\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\tconst details = result.details as GoalToolDetails | undefined;\n\t\t\treturn renderOrchestrationToolResult(theme, goalPanelModel(details), {\n\t\t\t\tisPartial,\n\t\t\t\tcollapse: !expanded && details?.applied === true,\n\t\t\t\texpanded: true,\n\t\t\t});\n\t\t},\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\tinput: GoalToolInput,\n\t\t): Promise<{\n\t\t\tcontent: Array<{ type: \"text\"; text: string }>;\n\t\t\tdetails: GoalToolDetails;\n\t\t\tisError?: boolean;\n\t\t}> {\n\t\t\tif (input.action === \"get\") {\n\t\t\t\tconst state = deps.getGoalState();\n\t\t\t\tif (!state) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"No goal exists for this session.\" }],\n\t\t\t\t\t\tdetails: { action: \"get\", applied: false },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: summarizeGoalState(state) }],\n\t\t\t\t\tdetails: { action: \"get\", applied: false, state },\n\t\t\t\t};\n\t\t\t}\n\t\t\tlet normalizedInput = input;\n\t\t\tif (input.action === \"start\" && deps.authorizeStart) {\n\t\t\t\tconst authority = deps.authorizeStart(input);\n\t\t\t\tif (typeof authority === \"string\") {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: `goal start failed: ${authority}` }],\n\t\t\t\t\t\tdetails: { action: \"start\", applied: false, error: authority },\n\t\t\t\t\t\tisError: true,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tnormalizedInput = {\n\t\t\t\t\t...input,\n\t\t\t\t\t...(typeof authority === \"number\" ? { tokenBudget: authority } : {}),\n\t\t\t\t};\n\t\t\t\tif (authority === null) delete normalizedInput.tokenBudget;\n\t\t\t}\n\t\t\tconst mapped = toGoalAction(normalizedInput);\n\t\t\tif (\"error\" in mapped) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${mapped.error}` }],\n\t\t\t\t\tdetails: { action: input.action, applied: false, error: mapped.error },\n\t\t\t\t\tisError: true,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tlet action: GoalAction = mapped;\n\t\t\tif (action.action === \"add_evidence\") {\n\t\t\t\tconst verified = await resolveEvidenceVerified(action.kind, action.uri, deps);\n\t\t\t\taction = { ...action, verified };\n\t\t\t}\n\t\t\t// Honest dispatch reporting: distinguish \"dispatched\" (laneId), \"declined\" (skipReason --\n\t\t\t// the dependency IS wired but the underlying delegation starter refused, e.g. disabled or\n\t\t\t// already at capacity), and \"unwired\" (no dependency at all) -- never collapse a real\n\t\t\t// decline into a silent no-laneId no-op indistinguishable from the dep being absent.\n\t\t\tlet dispatchNote: string | undefined;\n\t\t\tlet dispatchSkipReason: string | undefined;\n\t\t\t// Indeterminate-binding dedupe guard: checked BEFORE any dispatch side effect, for BOTH\n\t\t\t// routes. A requirement already bound to a lane that is either still live (a plain\n\t\t\t// duplicate) or whose liveness/outcome cannot be determined at all (for example, a legacy\n\t\t\t// snapshot with no lane record or worker result) must never be\n\t\t\t// re-dispatched silently; only a CONFIRMED terminal outcome allows a legitimate retry.\n\t\t\tlet dispatchGuardRefused = false;\n\t\t\tif (action.action === \"dispatch_worker\") {\n\t\t\t\t// Captured into a `const` so the \"dispatch_worker\" narrowing survives into the closures\n\t\t\t\t// below -- TS does not narrow a `let`-bound outer variable across a callback boundary.\n\t\t\t\tconst dispatchAction = action;\n\t\t\t\tconst boundRequirement = deps\n\t\t\t\t\t.getGoalState()\n\t\t\t\t\t?.requirements.find((r) => r.id === dispatchAction.requirementId);\n\t\t\t\tconst bound = boundRequirement?.boundLaneId;\n\t\t\t\tif (bound !== undefined) {\n\t\t\t\t\tconst boundLaneRecord = deps.getLaneRecords?.().find((record) => record.laneId === bound);\n\t\t\t\t\tconst isLiveInFlight =\n\t\t\t\t\t\tboundLaneRecord !== undefined &&\n\t\t\t\t\t\t(boundLaneRecord.status === \"queued\" || boundLaneRecord.status === \"running\");\n\t\t\t\t\tif (isLiveInFlight) {\n\t\t\t\t\t\tdispatchSkipReason = \"requirement_already_bound\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// `boundLaneRecord` present here is necessarily terminal (isLiveInFlight was false).\n\t\t\t\t\t\tconst hasTerminalOutcome =\n\t\t\t\t\t\t\tboundLaneRecord !== undefined ||\n\t\t\t\t\t\t\t(deps.getWorkerClaimSnapshots?.().some((claim) => claim.requestId === bound) ?? false);\n\t\t\t\t\t\tif (!hasTerminalOutcome) dispatchSkipReason = \"bound_lane_indeterminate\";\n\t\t\t\t\t}\n\t\t\t\t\tif (dispatchSkipReason) {\n\t\t\t\t\t\tdispatchGuardRefused = true;\n\t\t\t\t\t\tdispatchNote = `No worker was dispatched (${dispatchSkipReason}); requirement '${dispatchAction.requirementId}' remains bound to lane '${bound}'.`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (action.action === \"dispatch_worker\" && !dispatchGuardRefused) {\n\t\t\t\tconst tmuxRequested = input.dispatchTarget === \"tmux\";\n\t\t\t\tlet useTmux = tmuxRequested && deps.dispatchTmuxWorker !== undefined;\n\t\t\t\tlet tmuxFallbackReason: string | undefined;\n\t\t\t\tlet dispatched: { laneId?: string; skipReason?: string } | undefined;\n\t\t\t\tif (useTmux) {\n\t\t\t\t\tdispatched = await deps.dispatchTmuxWorker?.({\n\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t});\n\t\t\t\t\tif (\n\t\t\t\t\t\t!dispatched?.laneId &&\n\t\t\t\t\t\tallowsNativeTmuxFallback(dispatched?.skipReason) &&\n\t\t\t\t\t\tdeps.startWorkerDelegation\n\t\t\t\t\t) {\n\t\t\t\t\t\ttmuxFallbackReason = dispatched?.skipReason;\n\t\t\t\t\t\tuseTmux = false;\n\t\t\t\t\t\tdispatched = deps.startWorkerDelegation({\n\t\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (tmuxRequested) tmuxFallbackReason = \"tmux_extension_not_loaded\";\n\t\t\t\t\tdispatched = deps.startWorkerDelegation?.({\n\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\taction = { ...action, laneId: dispatched?.laneId };\n\t\t\t\tif (dispatched?.laneId) {\n\t\t\t\t\tdispatchNote = tmuxFallbackReason\n\t\t\t\t\t\t? `Tmux route returned ${tmuxFallbackReason}; dispatched native fallback worker lane '${dispatched.laneId}' for requirement '${action.requirementId}'.`\n\t\t\t\t\t\t: useTmux\n\t\t\t\t\t\t\t? `Dispatched tmux worker lane '${dispatched.laneId}' for requirement '${action.requirementId}'.`\n\t\t\t\t\t\t\t: `Dispatched in-process worker lane '${dispatched.laneId}' for requirement '${action.requirementId}' (native default).`;\n\t\t\t\t} else {\n\t\t\t\t\tconst wired = useTmux ? deps.dispatchTmuxWorker : deps.startWorkerDelegation;\n\t\t\t\t\tdispatchSkipReason = dispatched?.skipReason ?? (wired ? \"declined\" : \"dependency_unwired\");\n\t\t\t\t\tdispatchNote = `${tmuxFallbackReason ? `Tmux route returned ${tmuxFallbackReason}; ` : \"\"}No worker was dispatched (${dispatchSkipReason}); requirement '${action.requirementId}' is recorded but not bound to a lane.`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst current = deps.getGoalState();\n\t\t\tlet nextState: GoalState;\n\t\t\tif (action.action === \"dispatch_worker\" && dispatchGuardRefused) {\n\t\t\t\t// Short-circuit: the guard refused before any dispatch attempt -- never call\n\t\t\t\t// applyGoalAction for this turn, so the requirement's existing `boundLaneId` is\n\t\t\t\t// preserved exactly as-is rather than clobbered to `undefined` by the reducer's\n\t\t\t\t// unconditional `boundLaneId: event.laneId` write (goal-state.ts's dispatch_worker case).\n\t\t\t\t// `current` is guaranteed defined here: the guard only refuses when a requirement with\n\t\t\t\t// a `boundLaneId` was found on it.\n\t\t\t\tnextState = current as GoalState;\n\t\t\t} else {\n\t\t\t\tlet activePipeline: ReturnType<NonNullable<GoalToolDependencies[\"getActivePipeline\"]>>;\n\t\t\t\tlet activeGoalLaneIds: string[] | undefined;\n\t\t\t\tif (\n\t\t\t\t\tcurrent &&\n\t\t\t\t\tisGoalExecutionActive(current.status) &&\n\t\t\t\t\t(action.action === \"complete\" || action.action === \"increment\")\n\t\t\t\t) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst boundLaneIds = new Set(\n\t\t\t\t\t\t\tcurrent.requirements.flatMap((requirement) =>\n\t\t\t\t\t\t\t\trequirement.boundLaneId ? [requirement.boundLaneId] : [],\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tactiveGoalLaneIds = deps\n\t\t\t\t\t\t\t.getLaneRecords?.()\n\t\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t\t(record) =>\n\t\t\t\t\t\t\t\t\t(record.status === \"queued\" || record.status === \"running\") &&\n\t\t\t\t\t\t\t\t\t(record.goalId === current.goalId || boundLaneIds.has(record.laneId)),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.map((record) => record.laneId);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconst message = `Cannot verify active goal-owned lane state: ${error instanceof Error ? error.message : String(error)}`;\n\t\t\t\t\t\treturn goalExecutionError(input.action, message, current);\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tactivePipeline = deps.getActivePipeline?.();\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconst message = `Cannot verify active pipeline state: ${error instanceof Error ? error.message : String(error)}`;\n\t\t\t\t\t\treturn goalExecutionError(input.action, message, current);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst result = applyGoalAction(current, action, now(), {\n\t\t\t\t\trequireVerifiedEvidenceForCompletion: deps.requireVerifiedEvidenceForCompletion?.() ?? true,\n\t\t\t\t\topenTaskSteps: deps.getOpenTaskSteps?.(),\n\t\t\t\t\tbackgroundToolTasks: deps.getBackgroundToolTasks?.(),\n\t\t\t\t\tactivePipeline,\n\t\t\t\t\tactiveGoalLaneIds,\n\t\t\t\t});\n\t\t\t\tif (!result.ok) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${result.error}` }],\n\t\t\t\t\t\tdetails: { action: input.action, applied: false, error: result.error, state: current },\n\t\t\t\t\t\tisError: true,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tdeps.saveGoalState(result.state, current ? getGoalStateRevision(current) : undefined);\n\t\t\t\tnextState = result.state;\n\t\t\t}\n\n\t\t\tconst summary = summarizeGoalState(nextState, { action, openTaskSteps: deps.getOpenTaskSteps?.() });\n\t\t\tconst text = dispatchNote\n\t\t\t\t? `goal ${input.action} recorded.\\n${summary}\\n${dispatchNote}`\n\t\t\t\t: `goal ${input.action} recorded.\\n${summary}`;\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\" as const, text }],\n\t\t\t\tdetails: {\n\t\t\t\t\taction: input.action,\n\t\t\t\t\tapplied: true,\n\t\t\t\t\tstate: nextState,\n\t\t\t\t\t...(action.action === \"dispatch_worker\" && action.laneId ? { dispatchedLaneId: action.laneId } : {}),\n\t\t\t\t\t...(action.action === \"dispatch_worker\" && !action.laneId ? { dispatchSkipReason } : {}),\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t};\n}\n\n/**\n * Build the compact Codex-compatible lifecycle surface as adapters over the authoritative legacy\n * goal executor. The wrappers own no state and duplicate no validation, persistence, accounting,\n * completion gate, or start-authority rule.\n */\nexport function createGoalLifecycleToolDefinitions(goalTool: GoalToolDefinition) {\n\tconst createGoal: ToolDefinition = {\n\t\tname: GOAL_LIFECYCLE_TOOL_NAMES[0],\n\t\tlabel: GOAL_LIFECYCLE_TOOL_NAMES[0],\n\t\tdescription:\n\t\t\t\"Create a durable goal when persistent autonomous continuation materially benefits the current work, or when the user/system explicitly requests one. Use agent discretion; skip routine short tasks. Set token_budget only when explicitly requested. Fails if an unfinished goal exists.\",\n\t\tpromptSnippet: \"Start durable goal.\",\n\t\tparameters: createGoalSchema,\n\t\texecute(toolCallId, input: Static<typeof createGoalSchema>, signal, onUpdate, context) {\n\t\t\treturn goalTool.execute(\n\t\t\t\ttoolCallId,\n\t\t\t\t{\n\t\t\t\t\taction: \"start\",\n\t\t\t\t\tgoalId: `goal-${randomUUID()}`,\n\t\t\t\t\tuserGoal: input.objective,\n\t\t\t\t\ttokenBudget: input.token_budget,\n\t\t\t\t},\n\t\t\t\tsignal,\n\t\t\t\tonUpdate,\n\t\t\t\tcontext,\n\t\t\t);\n\t\t},\n\t};\n\n\tconst getGoal: ToolDefinition = {\n\t\tname: GOAL_LIFECYCLE_TOOL_NAMES[1],\n\t\tlabel: GOAL_LIFECYCLE_TOOL_NAMES[1],\n\t\tdescription:\n\t\t\t\"Get the current goal for this session, including status, budget, token and elapsed-time usage, requirements, evidence, and progress.\",\n\t\tpromptSnippet: \"Inspect durable goal.\",\n\t\tparameters: getGoalSchema,\n\t\texecute(toolCallId, _input, signal, onUpdate, context) {\n\t\t\treturn goalTool.execute(toolCallId, { action: \"get\" }, signal, onUpdate, context);\n\t\t},\n\t};\n\n\tconst updateGoal: ToolDefinition = {\n\t\tname: GOAL_LIFECYCLE_TOOL_NAMES[2],\n\t\tlabel: GOAL_LIFECYCLE_TOOL_NAMES[2],\n\t\tdescription:\n\t\t\t\"Update the existing goal. Set active only after concrete, verifiable progress in the current turn. Mark complete only when current evidence proves the full objective is achieved and no required work remains. Mark blocked only after the same blocking condition has recurred for at least three consecutive goal turns and no meaningful progress is possible without user input or external change; include that condition in reason. Never use blocked merely because work is hard, slow, uncertain, incomplete, or would benefit from clarification.\",\n\t\tpromptSnippet: \"Update goal; complete/block only with evidence.\",\n\t\tparameters: updateGoalSchema,\n\t\texecute(toolCallId, input: Static<typeof updateGoalSchema>, signal, onUpdate, context) {\n\t\t\tconst requestedGoalStatus: GoalStatus = input.status === \"complete\" ? \"completed\" : input.status;\n\t\t\tconst action: GoalToolInput = isGoalExecutionActive(requestedGoalStatus)\n\t\t\t\t? { action: \"progress\" }\n\t\t\t\t: input.status === \"complete\"\n\t\t\t\t\t? { action: \"complete\" }\n\t\t\t\t\t: { action: \"block_goal\", reason: input.reason ?? \"\" };\n\t\t\treturn goalTool.execute(toolCallId, action, signal, onUpdate, context);\n\t\t},\n\t};\n\n\treturn [createGoal, getGoal, updateGoal] as const;\n}\n"]}
@@ -7,8 +7,9 @@ export interface DelegateProfileInput {
7
7
  task?: string;
8
8
  baseProfileId?: string;
9
9
  model?: TaskProfileCreateInput["model"];
10
+ thinkingLevel?: TaskProfileCreateInput["thinkingLevel"];
11
+ path?: string;
10
12
  toolNames?: readonly string[];
11
- resourceProfileNames?: readonly string[];
12
13
  }
13
14
  export interface DelegateProfileToolDetails extends TaskProfileCreateResult {
14
15
  started: boolean;
@@ -19,13 +20,6 @@ export interface DelegateProfileToolDetails extends TaskProfileCreateResult {
19
20
  export declare function createDelegateProfileParameterSchemas(): {
20
21
  task: Type.TOptional<Type.TString>;
21
22
  baseProfileId: Type.TOptional<Type.TString>;
22
- model: Type.TOptional<Type.TObject<{
23
- provider: Type.TString;
24
- modelId: Type.TString;
25
- thinkingLevel: Type.TUnion<Type.TLiteral<"high" | "low" | "max" | "medium" | "minimal" | "off" | "ultra" | "xhigh">[]>;
26
- }>>;
27
- toolNames: Type.TOptional<Type.TArray<Type.TString>>;
28
- resourceProfileNames: Type.TOptional<Type.TArray<Type.TString>>;
29
23
  };
30
24
  export declare function delegateProfilePanelModel(details: DelegateProfileToolDetails): OrchestrationPanelModel;
31
25
  export declare function formatTaskProfileInspection(inspection: TaskProfileInspection): string;
@@ -1 +1 @@
1
- {"version":3,"file":"profile-writer.d.ts","sourceRoot":"","sources":["../../../src/core/tools/profile-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAQ/B,OAAO,KAAK,EACX,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,qBAAqB,EACrB,MAAM,yCAAyC,CAAC;AACjD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAExE,eAAO,MAAM,wBAAwB,YAAI,iBAAiB,EAAE,gBAAgB,CAAU,CAAC;AAEvF,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9E,MAAM,WAAW,oBAAoB;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC;IACxC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,oBAAoB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC;AAED,MAAM,WAAW,0BAA2B,SAAQ,uBAAuB;IAC1E,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,qBAAqB,CAAC;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,UAAU,CAAC,EAAE,qBAAqB,CAAC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MAAM,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,0BAA2B,SAAQ,uBAAuB;IAC1E,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,qBAAqB,CAAC;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,UAAU,CAAC,EAAE,qBAAqB,CAAC;CACnC;AAED,wBAAgB,qCAAqC;IAEnD,IAAI;IACJ,aAAa;EAEd;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,0BAA0B,GAAG,uBAAuB,CA2BtG;AAED,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,qBAAqB,GAAG,MAAM,CAIrF;AAED,wBAAgB,4BAA4B,CAC3C,MAAM,EAAE,qBAAqB,EAC7B,KAAK,EAAE,oBAAoB,EAC3B,MAAM,EAAE,qBAAqB,GAC3B;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,EAAE,0BAA0B,CAAA;CAAE,CA8CzF"}
@@ -1,24 +1,10 @@
1
1
  import { Type } from "typebox";
2
- import { MAX_ORCHESTRATION_COLLECTION_LENGTH, MAX_ORCHESTRATION_IDENTIFIER_LENGTH, MAX_ORCHESTRATION_MODEL_ID_LENGTH, MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH, ORCHESTRATION_THINKING_LEVELS, } from "../orchestration/contracts.js";
2
+ import { MAX_ORCHESTRATION_IDENTIFIER_LENGTH } from "../orchestration/contracts.js";
3
3
  export const DELEGATE_PROFILE_ACTIONS = ["profile_inspect", "profile_create"];
4
4
  export function createDelegateProfileParameterSchemas() {
5
5
  return {
6
6
  task: Type.Optional(Type.String({ minLength: 1, maxLength: 3_500 })),
7
7
  baseProfileId: Type.Optional(Type.String({ minLength: 1, maxLength: MAX_ORCHESTRATION_IDENTIFIER_LENGTH })),
8
- model: Type.Optional(Type.Object({
9
- provider: Type.String({
10
- minLength: 1,
11
- maxLength: MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH,
12
- }),
13
- modelId: Type.String({ minLength: 1, maxLength: MAX_ORCHESTRATION_MODEL_ID_LENGTH }),
14
- thinkingLevel: Type.Union(ORCHESTRATION_THINKING_LEVELS.map((level) => Type.Literal(level))),
15
- }, { additionalProperties: false })),
16
- toolNames: Type.Optional(Type.Array(Type.String({ minLength: 1, maxLength: MAX_ORCHESTRATION_IDENTIFIER_LENGTH }), {
17
- maxItems: MAX_ORCHESTRATION_COLLECTION_LENGTH,
18
- })),
19
- resourceProfileNames: Type.Optional(Type.Array(Type.String({ minLength: 1, maxLength: MAX_ORCHESTRATION_IDENTIFIER_LENGTH }), {
20
- maxItems: MAX_ORCHESTRATION_COLLECTION_LENGTH,
21
- })),
22
8
  };
23
9
  }
24
10
  export function delegateProfilePanelModel(details) {
@@ -51,7 +37,8 @@ export function delegateProfilePanelModel(details) {
51
37
  }
52
38
  export function formatTaskProfileInspection(inspection) {
53
39
  const bases = inspection.baseProfiles.map((profile) => profile.profileId).join(", ") || "none";
54
- return `Reusable owner-authored bases for profile_create: ${bases}. Native delegate start does not need a base; omit profileId and set authority.role to explorer or implementer. profile_create requires an owner-authored explorer or implementer base. Available configured models: ${inspection.models.length}.`;
40
+ const inheritedTools = inspection.inheritedToolNames.join(", ") || "none";
41
+ return `Optional owner-authored bases for profile_create: ${bases}. Omit baseProfileId to derive the foreground model, reasoning, compatible tools, and machine scope. Effective inherited native tools: ${inheritedTools}. Optional model, thinkingLevel, path, and toolNames fields narrow that inherited base. Available configured models: ${inspection.models.length}.`;
55
42
  }
56
43
  export function executeDelegateProfileAction(action, input, writer) {
57
44
  if (action === "profile_inspect") {
@@ -82,8 +69,9 @@ export function executeDelegateProfileAction(action, input, writer) {
82
69
  task: input.task,
83
70
  ...(input.baseProfileId !== undefined ? { baseProfileId: input.baseProfileId } : {}),
84
71
  ...(input.model !== undefined ? { model: input.model } : {}),
72
+ ...(input.thinkingLevel !== undefined ? { thinkingLevel: input.thinkingLevel } : {}),
73
+ ...(input.path !== undefined ? { path: input.path } : {}),
85
74
  ...(input.toolNames !== undefined ? { toolNames: input.toolNames } : {}),
86
- ...(input.resourceProfileNames !== undefined ? { resourceProfileNames: input.resourceProfileNames } : {}),
87
75
  };
88
76
  const result = writer.createTaskProfile(request);
89
77
  return {
@@ -91,7 +79,7 @@ export function executeDelegateProfileAction(action, input, writer) {
91
79
  {
92
80
  type: "text",
93
81
  text: result.created
94
- ? `Created immutable session task profile ${result.profileId} from ${result.baseProfileId}.`
82
+ ? `Created immutable session task profile ${result.profileId} from ${result.baseProfileId ?? "foreground inheritance"}.`
95
83
  : `delegate profile_create rejected the request: ${result.reason}.`,
96
84
  },
97
85
  ],
@@ -1 +1 @@
1
- {"version":3,"file":"profile-writer.js","sourceRoot":"","sources":["../../../src/core/tools/profile-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EACN,mCAAmC,EACnC,mCAAmC,EACnC,iCAAiC,EACjC,uCAAuC,EACvC,6BAA6B,GAC7B,MAAM,+BAA+B,CAAC;AASvC,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,iBAAiB,EAAE,gBAAgB,CAAU,CAAC;AAmBvF,MAAM,UAAU,qCAAqC;IACpD,OAAO;QACN,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;QACpE,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,mCAAmC,EAAE,CAAC,CAAC;QAC3G,KAAK,EAAE,IAAI,CAAC,QAAQ,CACnB,IAAI,CAAC,MAAM,CACV;YACC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC;gBACrB,SAAS,EAAE,CAAC;gB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,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE;KACxE,CAAC;AACH,CAAC","sourcesContent":["import { Type } from \"typebox\";\nimport {\n\tMAX_ORCHESTRATION_COLLECTION_LENGTH,\n\tMAX_ORCHESTRATION_IDENTIFIER_LENGTH,\n\tMAX_ORCHESTRATION_MODEL_ID_LENGTH,\n\tMAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH,\n\tORCHESTRATION_THINKING_LEVELS,\n} from \"../orchestration/contracts.ts\";\nimport type {\n\tTaskProfileCreateInput,\n\tTaskProfileCreateResult,\n\tTaskProfileInspection,\n\tTaskProfileWriterPort,\n} from \"../orchestration/task-profile-writer.ts\";\nimport type { OrchestrationPanelModel } from \"./orchestration-panel.ts\";\n\nexport const DELEGATE_PROFILE_ACTIONS = [\"profile_inspect\", \"profile_create\"] as const;\n\nexport type DelegateProfileAction = (typeof DELEGATE_PROFILE_ACTIONS)[number];\n\nexport interface DelegateProfileInput {\n\ttask?: string;\n\tbaseProfileId?: string;\n\tmodel?: TaskProfileCreateInput[\"model\"];\n\ttoolNames?: readonly string[];\n\tresourceProfileNames?: readonly string[];\n}\n\nexport interface DelegateProfileToolDetails extends TaskProfileCreateResult {\n\tstarted: boolean;\n\taction: DelegateProfileAction;\n\tkind: \"profile\";\n\tinspection?: TaskProfileInspection;\n}\n\nexport function createDelegateProfileParameterSchemas() {\n\treturn {\n\t\ttask: Type.Optional(Type.String({ minLength: 1, maxLength: 3_500 })),\n\t\tbaseProfileId: Type.Optional(Type.String({ minLength: 1, maxLength: MAX_ORCHESTRATION_IDENTIFIER_LENGTH })),\n\t\tmodel: Type.Optional(\n\t\t\tType.Object(\n\t\t\t\t{\n\t\t\t\t\tprovider: Type.String({\n\t\t\t\t\t\tminLength: 1,\n\t\t\t\t\t\tmaxLength: MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH,\n\t\t\t\t\t}),\n\t\t\t\t\tmodelId: Type.String({ minLength: 1, maxLength: MAX_ORCHESTRATION_MODEL_ID_LENGTH }),\n\t\t\t\t\tthinkingLevel: Type.Union(ORCHESTRATION_THINKING_LEVELS.map((level) => Type.Literal(level))),\n\t\t\t\t},\n\t\t\t\t{ additionalProperties: false },\n\t\t\t),\n\t\t),\n\t\ttoolNames: Type.Optional(\n\t\t\tType.Array(Type.String({ minLength: 1, maxLength: MAX_ORCHESTRATION_IDENTIFIER_LENGTH }), {\n\t\t\t\tmaxItems: MAX_ORCHESTRATION_COLLECTION_LENGTH,\n\t\t\t}),\n\t\t),\n\t\tresourceProfileNames: Type.Optional(\n\t\t\tType.Array(Type.String({ minLength: 1, maxLength: MAX_ORCHESTRATION_IDENTIFIER_LENGTH }), {\n\t\t\t\tmaxItems: MAX_ORCHESTRATION_COLLECTION_LENGTH,\n\t\t\t}),\n\t\t),\n\t};\n}\n\nexport function delegateProfilePanelModel(details: DelegateProfileToolDetails): OrchestrationPanelModel {\n\tif (details.action === \"profile_inspect\") {\n\t\treturn {\n\t\t\tlabel: \"worker profiles\",\n\t\t\taction: \"inspected\",\n\t\t\tstatus: \"success\",\n\t\t\tsummary: [\n\t\t\t\t`${details.inspection?.baseProfiles.length ?? 0} bases`,\n\t\t\t\t`${details.inspection?.models.length ?? 0} models`,\n\t\t\t],\n\t\t};\n\t}\n\treturn {\n\t\tlabel: \"worker profiles\",\n\t\taction: details.created ? \"created\" : \"rejected\",\n\t\tstatus: details.created ? \"success\" : \"warning\",\n\t\trows: details.profileId\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tstatus: \"succeeded\",\n\t\t\t\t\t\tlabel: details.profileId,\n\t\t\t\t\t\tmeta: details.baseProfileId ? [`base ${details.baseProfileId}`] : undefined,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t: undefined,\n\t\temptyText: details.reason,\n\t};\n}\n\nexport function formatTaskProfileInspection(inspection: TaskProfileInspection): string {\n\tconst bases = inspection.baseProfiles.map((profile) => profile.profileId).join(\", \") || \"none\";\n\treturn `Reusable owner-authored bases for profile_create: ${bases}. Native delegate start does not need a base; omit profileId and set authority.role to explorer or implementer. profile_create requires an owner-authored explorer or implementer base. Available configured models: ${inspection.models.length}.`;\n}\n\nexport function executeDelegateProfileAction(\n\taction: DelegateProfileAction,\n\tinput: DelegateProfileInput,\n\twriter: TaskProfileWriterPort,\n): { content: Array<{ type: \"text\"; text: string }>; details: DelegateProfileToolDetails } {\n\tif (action === \"profile_inspect\") {\n\t\tconst inspection = writer.inspectTaskProfileOptions();\n\t\treturn {\n\t\t\tcontent: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: formatTaskProfileInspection(inspection),\n\t\t\t\t},\n\t\t\t],\n\t\t\tdetails: { started: true, action, kind: \"profile\", created: false, inspection },\n\t\t};\n\t}\n\n\tif (input.task === undefined) {\n\t\treturn {\n\t\t\tcontent: [{ type: \"text\", text: \"delegate profile_create requires task\" }],\n\t\t\tdetails: {\n\t\t\t\tstarted: false,\n\t\t\t\taction,\n\t\t\t\tkind: \"profile\",\n\t\t\t\tcreated: false,\n\t\t\t\treason: \"missing_profile_task\",\n\t\t\t},\n\t\t};\n\t}\n\tconst request: TaskProfileCreateInput = {\n\t\ttask: input.task,\n\t\t...(input.baseProfileId !== undefined ? { baseProfileId: input.baseProfileId } : {}),\n\t\t...(input.model !== undefined ? { model: input.model } : {}),\n\t\t...(input.toolNames !== undefined ? { toolNames: input.toolNames } : {}),\n\t\t...(input.resourceProfileNames !== undefined ? { resourceProfileNames: input.resourceProfileNames } : {}),\n\t};\n\tconst result = writer.createTaskProfile(request);\n\treturn {\n\t\tcontent: [\n\t\t\t{\n\t\t\t\ttype: \"text\",\n\t\t\t\ttext: result.created\n\t\t\t\t\t? `Created immutable session task profile ${result.profileId} from ${result.baseProfileId}.`\n\t\t\t\t\t: `delegate profile_create rejected the request: ${result.reason}.`,\n\t\t\t},\n\t\t],\n\t\tdetails: { started: result.created, action, kind: \"profile\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AG;oBACxH,CAAC,CAAC,iDAAiD,MAAM,CAAC,MAAM,GAAG;aACpE;SACD;QACD,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE;KACxE,CAAC;AACH,CAAC","sourcesContent":["import { Type } from \"typebox\";\nimport { MAX_ORCHESTRATION_IDENTIFIER_LENGTH } from \"../orchestration/contracts.ts\";\nimport type {\n\tTaskProfileCreateInput,\n\tTaskProfileCreateResult,\n\tTaskProfileInspection,\n\tTaskProfileWriterPort,\n} from \"../orchestration/task-profile-writer.ts\";\nimport type { OrchestrationPanelModel } from \"./orchestration-panel.ts\";\n\nexport const DELEGATE_PROFILE_ACTIONS = [\"profile_inspect\", \"profile_create\"] as const;\n\nexport type DelegateProfileAction = (typeof DELEGATE_PROFILE_ACTIONS)[number];\n\nexport interface DelegateProfileInput {\n\ttask?: string;\n\tbaseProfileId?: string;\n\tmodel?: TaskProfileCreateInput[\"model\"];\n\tthinkingLevel?: TaskProfileCreateInput[\"thinkingLevel\"];\n\tpath?: string;\n\ttoolNames?: readonly string[];\n}\n\nexport interface DelegateProfileToolDetails extends TaskProfileCreateResult {\n\tstarted: boolean;\n\taction: DelegateProfileAction;\n\tkind: \"profile\";\n\tinspection?: TaskProfileInspection;\n}\n\nexport function createDelegateProfileParameterSchemas() {\n\treturn {\n\t\ttask: Type.Optional(Type.String({ minLength: 1, maxLength: 3_500 })),\n\t\tbaseProfileId: Type.Optional(Type.String({ minLength: 1, maxLength: MAX_ORCHESTRATION_IDENTIFIER_LENGTH })),\n\t};\n}\n\nexport function delegateProfilePanelModel(details: DelegateProfileToolDetails): OrchestrationPanelModel {\n\tif (details.action === \"profile_inspect\") {\n\t\treturn {\n\t\t\tlabel: \"worker profiles\",\n\t\t\taction: \"inspected\",\n\t\t\tstatus: \"success\",\n\t\t\tsummary: [\n\t\t\t\t`${details.inspection?.baseProfiles.length ?? 0} bases`,\n\t\t\t\t`${details.inspection?.models.length ?? 0} models`,\n\t\t\t],\n\t\t};\n\t}\n\treturn {\n\t\tlabel: \"worker profiles\",\n\t\taction: details.created ? \"created\" : \"rejected\",\n\t\tstatus: details.created ? \"success\" : \"warning\",\n\t\trows: details.profileId\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tstatus: \"succeeded\",\n\t\t\t\t\t\tlabel: details.profileId,\n\t\t\t\t\t\tmeta: details.baseProfileId ? [`base ${details.baseProfileId}`] : undefined,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t: undefined,\n\t\temptyText: details.reason,\n\t};\n}\n\nexport function formatTaskProfileInspection(inspection: TaskProfileInspection): string {\n\tconst bases = inspection.baseProfiles.map((profile) => profile.profileId).join(\", \") || \"none\";\n\tconst inheritedTools = inspection.inheritedToolNames.join(\", \") || \"none\";\n\treturn `Optional owner-authored bases for profile_create: ${bases}. Omit baseProfileId to derive the foreground model, reasoning, compatible tools, and machine scope. Effective inherited native tools: ${inheritedTools}. Optional model, thinkingLevel, path, and toolNames fields narrow that inherited base. Available configured models: ${inspection.models.length}.`;\n}\n\nexport function executeDelegateProfileAction(\n\taction: DelegateProfileAction,\n\tinput: DelegateProfileInput,\n\twriter: TaskProfileWriterPort,\n): { content: Array<{ type: \"text\"; text: string }>; details: DelegateProfileToolDetails } {\n\tif (action === \"profile_inspect\") {\n\t\tconst inspection = writer.inspectTaskProfileOptions();\n\t\treturn {\n\t\t\tcontent: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: formatTaskProfileInspection(inspection),\n\t\t\t\t},\n\t\t\t],\n\t\t\tdetails: { started: true, action, kind: \"profile\", created: false, inspection },\n\t\t};\n\t}\n\n\tif (input.task === undefined) {\n\t\treturn {\n\t\t\tcontent: [{ type: \"text\", text: \"delegate profile_create requires task\" }],\n\t\t\tdetails: {\n\t\t\t\tstarted: false,\n\t\t\t\taction,\n\t\t\t\tkind: \"profile\",\n\t\t\t\tcreated: false,\n\t\t\t\treason: \"missing_profile_task\",\n\t\t\t},\n\t\t};\n\t}\n\tconst request: TaskProfileCreateInput = {\n\t\ttask: input.task,\n\t\t...(input.baseProfileId !== undefined ? { baseProfileId: input.baseProfileId } : {}),\n\t\t...(input.model !== undefined ? { model: input.model } : {}),\n\t\t...(input.thinkingLevel !== undefined ? { thinkingLevel: input.thinkingLevel } : {}),\n\t\t...(input.path !== undefined ? { path: input.path } : {}),\n\t\t...(input.toolNames !== undefined ? { toolNames: input.toolNames } : {}),\n\t};\n\tconst result = writer.createTaskProfile(request);\n\treturn {\n\t\tcontent: [\n\t\t\t{\n\t\t\t\ttype: \"text\",\n\t\t\t\ttext: result.created\n\t\t\t\t\t? `Created immutable session task profile ${result.profileId} from ${result.baseProfileId ?? \"foreground inheritance\"}.`\n\t\t\t\t\t: `delegate profile_create rejected the request: ${result.reason}.`,\n\t\t\t},\n\t\t],\n\t\tdetails: { started: result.created, action, kind: \"profile\", ...result },\n\t};\n}\n"]}
@@ -20,7 +20,7 @@ export interface RunToolkitScriptDetails {
20
20
  }
21
21
  export interface RunToolkitScriptDependencies {
22
22
  getScripts: () => ToolkitScript[];
23
- execute: (script: ToolkitScript, args: readonly string[]) => Promise<ScriptExecution>;
23
+ execute: (script: ToolkitScript, args: readonly string[], signal?: AbortSignal) => Promise<ScriptExecution>;
24
24
  artifactStore?: ArtifactStore;
25
25
  /**
26
26
  * Optional reflex interpreter (local brain): consulted ONLY when the deterministic Level-0
@@ -1 +1 @@
1
- {"version":3,"file":"run-toolkit-script.d.ts","sourceRoot":"","sources":["../../../src/core/tools/run-toolkit-script.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAErE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAoB,KAAK,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exitCode; never claim success for nonzero exitCode.",
24
24
  ],
25
25
  parameters: runToolkitScriptSchema,
26
- async execute(toolCallId, input) {
26
+ async execute(toolCallId, input, signal) {
27
27
  const scripts = deps.getScripts();
28
28
  if (scripts.length === 0) {
29
29
  return {
@@ -88,7 +88,7 @@ export function createRunToolkitScriptToolDefinition(deps) {
88
88
  };
89
89
  }
90
90
  // Explicit args from the caller win; a brain-extracted arg list fills in for fuzzy requests.
91
- const execution = await deps.execute(script, input.args ?? interpreted?.args ?? []);
91
+ const execution = await deps.execute(script, input.args ?? interpreted?.args ?? [], signal);
92
92
  const failed = execution.exitCode !== 0 || execution.timedOut;
93
93
  const header = failed
94
94
  ? `FAILED: ${script.name} exited ${execution.timedOut ? "by timeout" : execution.exitCode} after ${execution.durationMs}ms`