agentplane 0.3.6 → 0.3.8

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 (663) hide show
  1. package/assets/AGENTS.md +11 -1
  2. package/assets/RUNNER.md +17 -0
  3. package/bin/agentplane.js +16 -7
  4. package/bin/framework-dev-contract.d.ts +6 -0
  5. package/bin/framework-dev-contract.js +13 -0
  6. package/bin/stale-dist-policy.js +6 -1
  7. package/dist/.build-manifest.json +724 -359
  8. package/dist/adapters/task-backend/task-backend-adapter.d.ts +4 -2
  9. package/dist/adapters/task-backend/task-backend-adapter.d.ts.map +1 -1
  10. package/dist/adapters/task-backend/task-backend-adapter.js +15 -2
  11. package/dist/backends/task-backend/local-backend-doc.d.ts +5 -0
  12. package/dist/backends/task-backend/local-backend-doc.d.ts.map +1 -0
  13. package/dist/backends/task-backend/local-backend-doc.js +98 -0
  14. package/dist/backends/task-backend/local-backend-read.d.ts +7 -0
  15. package/dist/backends/task-backend/local-backend-read.d.ts.map +1 -0
  16. package/dist/backends/task-backend/local-backend-read.js +186 -0
  17. package/dist/backends/task-backend/local-backend-state.d.ts +17 -0
  18. package/dist/backends/task-backend/local-backend-state.d.ts.map +1 -0
  19. package/dist/backends/task-backend/local-backend-state.js +50 -0
  20. package/dist/backends/task-backend/local-backend-write.d.ts +15 -0
  21. package/dist/backends/task-backend/local-backend-write.d.ts.map +1 -0
  22. package/dist/backends/task-backend/local-backend-write.js +254 -0
  23. package/dist/backends/task-backend/local-backend.d.ts +10 -6
  24. package/dist/backends/task-backend/local-backend.d.ts.map +1 -1
  25. package/dist/backends/task-backend/local-backend.js +32 -337
  26. package/dist/backends/task-backend/redmine/backend-cache-doc.d.ts +40 -0
  27. package/dist/backends/task-backend/redmine/backend-cache-doc.d.ts.map +1 -0
  28. package/dist/backends/task-backend/redmine/backend-cache-doc.js +178 -0
  29. package/dist/backends/task-backend/redmine/backend-report.d.ts +10 -0
  30. package/dist/backends/task-backend/redmine/backend-report.d.ts.map +1 -0
  31. package/dist/backends/task-backend/redmine/backend-report.js +43 -0
  32. package/dist/backends/task-backend/redmine/backend-sync.d.ts +67 -0
  33. package/dist/backends/task-backend/redmine/backend-sync.d.ts.map +1 -0
  34. package/dist/backends/task-backend/redmine/backend-sync.js +367 -0
  35. package/dist/backends/task-backend/redmine/env.d.ts +1 -1
  36. package/dist/backends/task-backend/redmine/env.d.ts.map +1 -1
  37. package/dist/backends/task-backend/redmine/env.js +3 -0
  38. package/dist/backends/task-backend/redmine/inspect.d.ts +11 -0
  39. package/dist/backends/task-backend/redmine/inspect.d.ts.map +1 -0
  40. package/dist/backends/task-backend/redmine/inspect.js +75 -0
  41. package/dist/backends/task-backend/redmine/mapping.d.ts +2 -1
  42. package/dist/backends/task-backend/redmine/mapping.d.ts.map +1 -1
  43. package/dist/backends/task-backend/redmine/mapping.js +32 -3
  44. package/dist/backends/task-backend/redmine/parse.d.ts +2 -1
  45. package/dist/backends/task-backend/redmine/parse.d.ts.map +1 -1
  46. package/dist/backends/task-backend/redmine/parse.js +5 -3
  47. package/dist/backends/task-backend/redmine/state.d.ts +19 -0
  48. package/dist/backends/task-backend/redmine/state.d.ts.map +1 -0
  49. package/dist/backends/task-backend/redmine/state.js +109 -0
  50. package/dist/backends/task-backend/redmine-backend.d.ts +14 -17
  51. package/dist/backends/task-backend/redmine-backend.d.ts.map +1 -1
  52. package/dist/backends/task-backend/redmine-backend.js +121 -379
  53. package/dist/backends/task-backend/shared/constants.d.ts +2 -1
  54. package/dist/backends/task-backend/shared/constants.d.ts.map +1 -1
  55. package/dist/backends/task-backend/shared/constants.js +1 -1
  56. package/dist/backends/task-backend/shared/doc.d.ts.map +1 -1
  57. package/dist/backends/task-backend/shared/doc.js +25 -39
  58. package/dist/backends/task-backend/shared/export.d.ts +2 -9
  59. package/dist/backends/task-backend/shared/export.d.ts.map +1 -1
  60. package/dist/backends/task-backend/shared/export.js +73 -8
  61. package/dist/backends/task-backend/shared/normalize.d.ts +5 -1
  62. package/dist/backends/task-backend/shared/normalize.d.ts.map +1 -1
  63. package/dist/backends/task-backend/shared/normalize.js +166 -0
  64. package/dist/backends/task-backend/shared/record.d.ts +1 -1
  65. package/dist/backends/task-backend/shared/record.d.ts.map +1 -1
  66. package/dist/backends/task-backend/shared/record.js +27 -3
  67. package/dist/backends/task-backend/shared/types.d.ts +76 -36
  68. package/dist/backends/task-backend/shared/types.d.ts.map +1 -1
  69. package/dist/backends/task-backend/shared.d.ts +2 -2
  70. package/dist/backends/task-backend/shared.d.ts.map +1 -1
  71. package/dist/backends/task-backend/shared.js +1 -1
  72. package/dist/backends/task-backend.d.ts +1 -1
  73. package/dist/backends/task-backend.d.ts.map +1 -1
  74. package/dist/backends/task-backend.js +1 -1
  75. package/dist/backends/task-index.d.ts +2 -2
  76. package/dist/backends/task-index.d.ts.map +1 -1
  77. package/dist/backends/task-index.js +9 -5
  78. package/dist/cli/bootstrap-guide.d.ts +2 -2
  79. package/dist/cli/bootstrap-guide.d.ts.map +1 -1
  80. package/dist/cli/bootstrap-guide.js +10 -10
  81. package/dist/cli/command-guide.d.ts.map +1 -1
  82. package/dist/cli/command-guide.js +11 -9
  83. package/dist/cli/command-invocations.d.ts +4 -0
  84. package/dist/cli/command-invocations.d.ts.map +1 -0
  85. package/dist/cli/command-invocations.js +35 -0
  86. package/dist/cli/command-snippets.d.ts +12 -8
  87. package/dist/cli/command-snippets.d.ts.map +1 -1
  88. package/dist/cli/command-snippets.js +14 -8
  89. package/dist/cli/exit-codes.d.ts.map +1 -1
  90. package/dist/cli/exit-codes.js +1 -0
  91. package/dist/cli/group-command.d.ts +18 -0
  92. package/dist/cli/group-command.d.ts.map +1 -0
  93. package/dist/cli/group-command.js +45 -0
  94. package/dist/cli/output.d.ts +29 -0
  95. package/dist/cli/output.d.ts.map +1 -1
  96. package/dist/cli/output.js +76 -0
  97. package/dist/cli/prompts.d.ts.map +1 -1
  98. package/dist/cli/prompts.js +5 -1
  99. package/dist/cli/run-cli/command-catalog/core.d.ts.map +1 -1
  100. package/dist/cli/run-cli/command-catalog/core.js +38 -29
  101. package/dist/cli/run-cli/command-catalog/lifecycle.d.ts.map +1 -1
  102. package/dist/cli/run-cli/command-catalog/lifecycle.js +9 -6
  103. package/dist/cli/run-cli/command-catalog/project.d.ts +1 -1
  104. package/dist/cli/run-cli/command-catalog/project.d.ts.map +1 -1
  105. package/dist/cli/run-cli/command-catalog/project.js +11 -7
  106. package/dist/cli/run-cli/command-catalog/shared.d.ts +12 -3
  107. package/dist/cli/run-cli/command-catalog/shared.d.ts.map +1 -1
  108. package/dist/cli/run-cli/command-catalog/shared.js +6 -3
  109. package/dist/cli/run-cli/command-catalog/task.d.ts +1 -1
  110. package/dist/cli/run-cli/command-catalog/task.d.ts.map +1 -1
  111. package/dist/cli/run-cli/command-catalog/task.js +46 -11
  112. package/dist/cli/run-cli/command-catalog.d.ts +11 -1
  113. package/dist/cli/run-cli/command-catalog.d.ts.map +1 -1
  114. package/dist/cli/run-cli/command-catalog.js +29 -0
  115. package/dist/cli/run-cli/commands/config.d.ts.map +1 -1
  116. package/dist/cli/run-cli/commands/config.js +52 -6
  117. package/dist/cli/run-cli/commands/core/agent-profiles.d.ts +34 -0
  118. package/dist/cli/run-cli/commands/core/agent-profiles.d.ts.map +1 -0
  119. package/dist/cli/run-cli/commands/core/agent-profiles.js +97 -0
  120. package/dist/cli/run-cli/commands/core/agents.d.ts +7 -0
  121. package/dist/cli/run-cli/commands/core/agents.d.ts.map +1 -0
  122. package/dist/cli/run-cli/commands/core/agents.js +97 -0
  123. package/dist/cli/run-cli/commands/core/preflight.d.ts +10 -0
  124. package/dist/cli/run-cli/commands/core/preflight.d.ts.map +1 -0
  125. package/dist/cli/run-cli/commands/core/preflight.js +286 -0
  126. package/dist/cli/run-cli/commands/core/quickstart.d.ts +8 -0
  127. package/dist/cli/run-cli/commands/core/quickstart.d.ts.map +1 -0
  128. package/dist/cli/run-cli/commands/core/quickstart.js +43 -0
  129. package/dist/cli/run-cli/commands/core/role.d.ts +9 -0
  130. package/dist/cli/run-cli/commands/core/role.d.ts.map +1 -0
  131. package/dist/cli/run-cli/commands/core/role.js +128 -0
  132. package/dist/cli/run-cli/commands/core.d.ts +4 -24
  133. package/dist/cli/run-cli/commands/core.d.ts.map +1 -1
  134. package/dist/cli/run-cli/commands/core.js +4 -630
  135. package/dist/cli/run-cli/commands/init/write-env.d.ts.map +1 -1
  136. package/dist/cli/run-cli/commands/init/write-env.js +12 -0
  137. package/dist/cli/run-cli/error-guidance.js +10 -0
  138. package/dist/cli/run-cli/globals.d.ts +5 -2
  139. package/dist/cli/run-cli/globals.d.ts.map +1 -1
  140. package/dist/cli/run-cli/globals.js +82 -86
  141. package/dist/cli/run-cli.d.ts.map +1 -1
  142. package/dist/cli/run-cli.js +137 -100
  143. package/dist/cli/run-cli.test-helpers.d.ts +21 -0
  144. package/dist/cli/run-cli.test-helpers.d.ts.map +1 -1
  145. package/dist/cli/run-cli.test-helpers.js +90 -4
  146. package/dist/cli/spec/help.d.ts +10 -2
  147. package/dist/cli/spec/help.d.ts.map +1 -1
  148. package/dist/cli/spec/help.js +7 -5
  149. package/dist/cli/spec/registry.d.ts +27 -1
  150. package/dist/cli/spec/registry.d.ts.map +1 -1
  151. package/dist/cli/spec/registry.js +98 -25
  152. package/dist/commands/backend/sync.command.d.ts +8 -6
  153. package/dist/commands/backend/sync.command.d.ts.map +1 -1
  154. package/dist/commands/backend/sync.command.js +75 -14
  155. package/dist/commands/backend.d.ts +22 -0
  156. package/dist/commands/backend.d.ts.map +1 -1
  157. package/dist/commands/backend.js +111 -1
  158. package/dist/commands/branch/base.command.d.ts +2 -3
  159. package/dist/commands/branch/base.command.d.ts.map +1 -1
  160. package/dist/commands/branch/base.command.js +8 -12
  161. package/dist/commands/branch/base.d.ts.map +1 -1
  162. package/dist/commands/branch/base.js +11 -7
  163. package/dist/commands/branch/cleanup-merged.d.ts.map +1 -1
  164. package/dist/commands/branch/cleanup-merged.js +9 -8
  165. package/dist/commands/branch/remove.d.ts.map +1 -1
  166. package/dist/commands/branch/remove.js +4 -3
  167. package/dist/commands/branch/status.d.ts.map +1 -1
  168. package/dist/commands/branch/status.js +4 -3
  169. package/dist/commands/branch/work-start.d.ts.map +1 -1
  170. package/dist/commands/branch/work-start.js +48 -5
  171. package/dist/commands/cleanup/merged.command.d.ts +2 -3
  172. package/dist/commands/cleanup/merged.command.d.ts.map +1 -1
  173. package/dist/commands/cleanup/merged.command.js +8 -12
  174. package/dist/commands/commit.spec.d.ts.map +1 -1
  175. package/dist/commands/commit.spec.js +30 -6
  176. package/dist/commands/docs/cli.command.js +2 -2
  177. package/dist/commands/doctor/runtime.js +1 -1
  178. package/dist/commands/doctor/workflow.d.ts.map +1 -1
  179. package/dist/commands/doctor/workflow.js +10 -1
  180. package/dist/commands/doctor/workspace.d.ts +8 -0
  181. package/dist/commands/doctor/workspace.d.ts.map +1 -1
  182. package/dist/commands/doctor/workspace.js +127 -3
  183. package/dist/commands/finish.spec.d.ts.map +1 -1
  184. package/dist/commands/finish.spec.js +7 -0
  185. package/dist/commands/guard/commit.command.d.ts.map +1 -1
  186. package/dist/commands/guard/commit.command.js +30 -6
  187. package/dist/commands/guard/guard.command.d.ts +3 -3
  188. package/dist/commands/guard/guard.command.d.ts.map +1 -1
  189. package/dist/commands/guard/guard.command.js +9 -14
  190. package/dist/commands/guard/impl/allow.d.ts +4 -0
  191. package/dist/commands/guard/impl/allow.d.ts.map +1 -1
  192. package/dist/commands/guard/impl/allow.js +14 -3
  193. package/dist/commands/guard/impl/commands.d.ts +2 -0
  194. package/dist/commands/guard/impl/commands.d.ts.map +1 -1
  195. package/dist/commands/guard/impl/commands.js +66 -9
  196. package/dist/commands/guard/impl/policy.d.ts +1 -0
  197. package/dist/commands/guard/impl/policy.d.ts.map +1 -1
  198. package/dist/commands/guard/impl/policy.js +9 -6
  199. package/dist/commands/hooks/hooks.command.d.ts +3 -3
  200. package/dist/commands/hooks/hooks.command.d.ts.map +1 -1
  201. package/dist/commands/hooks/hooks.command.js +9 -11
  202. package/dist/commands/pr/check.d.ts.map +1 -1
  203. package/dist/commands/pr/check.js +90 -18
  204. package/dist/commands/pr/integrate/cmd.d.ts.map +1 -1
  205. package/dist/commands/pr/integrate/cmd.js +31 -3
  206. package/dist/commands/pr/integrate/internal/cleanup.d.ts +12 -0
  207. package/dist/commands/pr/integrate/internal/cleanup.d.ts.map +1 -0
  208. package/dist/commands/pr/integrate/internal/cleanup.js +46 -0
  209. package/dist/commands/pr/integrate/internal/finalize.d.ts +4 -0
  210. package/dist/commands/pr/integrate/internal/finalize.d.ts.map +1 -1
  211. package/dist/commands/pr/integrate/internal/finalize.js +34 -40
  212. package/dist/commands/pr/integrate/internal/merge.d.ts +6 -0
  213. package/dist/commands/pr/integrate/internal/merge.d.ts.map +1 -1
  214. package/dist/commands/pr/integrate/internal/merge.js +92 -0
  215. package/dist/commands/pr/integrate/internal/prepare.d.ts +1 -0
  216. package/dist/commands/pr/integrate/internal/prepare.d.ts.map +1 -1
  217. package/dist/commands/pr/integrate/internal/prepare.js +1 -0
  218. package/dist/commands/pr/integrate/verify.d.ts.map +1 -1
  219. package/dist/commands/pr/integrate/verify.js +4 -3
  220. package/dist/commands/pr/note.d.ts.map +1 -1
  221. package/dist/commands/pr/note.js +3 -2
  222. package/dist/commands/pr/open.d.ts.map +1 -1
  223. package/dist/commands/pr/open.js +9 -12
  224. package/dist/commands/pr/pr.command.d.ts +3 -4
  225. package/dist/commands/pr/pr.command.d.ts.map +1 -1
  226. package/dist/commands/pr/pr.command.js +6 -11
  227. package/dist/commands/pr/update.d.ts.map +1 -1
  228. package/dist/commands/pr/update.js +5 -10
  229. package/dist/commands/recipes/cache.command.d.ts +3 -4
  230. package/dist/commands/recipes/cache.command.d.ts.map +1 -1
  231. package/dist/commands/recipes/cache.command.js +8 -26
  232. package/dist/commands/recipes/impl/apply.d.ts +1 -1
  233. package/dist/commands/recipes/impl/apply.d.ts.map +1 -1
  234. package/dist/commands/recipes/impl/apply.js +1 -1
  235. package/dist/commands/recipes/impl/commands/explain.js +1 -1
  236. package/dist/commands/recipes/impl/commands/install.d.ts.map +1 -1
  237. package/dist/commands/recipes/impl/commands/install.js +1 -2
  238. package/dist/commands/recipes/impl/installed-recipes.d.ts +1 -1
  239. package/dist/commands/recipes/impl/installed-recipes.d.ts.map +1 -1
  240. package/dist/commands/recipes/impl/installed-recipes.js +1 -2
  241. package/dist/commands/recipes/impl/manifest.d.ts.map +1 -1
  242. package/dist/commands/recipes/impl/manifest.js +0 -10
  243. package/dist/commands/recipes/impl/project-installed-recipes.d.ts +1 -1
  244. package/dist/commands/recipes/impl/project-installed-recipes.d.ts.map +1 -1
  245. package/dist/commands/recipes/impl/project-installed-recipes.js +1 -2
  246. package/dist/commands/recipes/impl/resolver.d.ts +1 -1
  247. package/dist/commands/recipes/impl/resolver.d.ts.map +1 -1
  248. package/dist/commands/recipes/impl/resolver.js +26 -16
  249. package/dist/commands/recipes/impl/scenario.d.ts.map +1 -1
  250. package/dist/commands/recipes/impl/scenario.js +80 -0
  251. package/dist/commands/recipes/impl/types.d.ts +27 -13
  252. package/dist/commands/recipes/impl/types.d.ts.map +1 -1
  253. package/dist/commands/recipes/recipes.command.d.ts +3 -4
  254. package/dist/commands/recipes/recipes.command.d.ts.map +1 -1
  255. package/dist/commands/recipes/recipes.command.js +8 -34
  256. package/dist/commands/recipes.d.ts +4 -4
  257. package/dist/commands/recipes.d.ts.map +1 -1
  258. package/dist/commands/recipes.js +3 -3
  259. package/dist/commands/recipes.test-helpers.d.ts +17 -0
  260. package/dist/commands/recipes.test-helpers.d.ts.map +1 -1
  261. package/dist/commands/recipes.test-helpers.js +56 -2
  262. package/dist/commands/release/apply.command.d.ts.map +1 -1
  263. package/dist/commands/release/apply.command.js +77 -56
  264. package/dist/commands/release/plan.command.d.ts.map +1 -1
  265. package/dist/commands/release/plan.command.js +7 -3
  266. package/dist/commands/release/release.command.d.ts +3 -3
  267. package/dist/commands/release/release.command.d.ts.map +1 -1
  268. package/dist/commands/release/release.command.js +9 -11
  269. package/dist/commands/release.test-helpers.d.ts +20 -0
  270. package/dist/commands/release.test-helpers.d.ts.map +1 -0
  271. package/dist/commands/release.test-helpers.js +37 -0
  272. package/dist/commands/runtime.command.d.ts +7 -7
  273. package/dist/commands/runtime.command.d.ts.map +1 -1
  274. package/dist/commands/runtime.command.js +29 -33
  275. package/dist/commands/scenario/execute.command.d.ts +8 -0
  276. package/dist/commands/scenario/execute.command.d.ts.map +1 -0
  277. package/dist/commands/scenario/execute.command.js +117 -0
  278. package/dist/commands/scenario/impl/commands.d.ts.map +1 -1
  279. package/dist/commands/scenario/impl/commands.js +45 -32
  280. package/dist/commands/scenario/run.command.js +2 -2
  281. package/dist/commands/scenario/scenario.command.d.ts +3 -4
  282. package/dist/commands/scenario/scenario.command.d.ts.map +1 -1
  283. package/dist/commands/scenario/scenario.command.js +8 -26
  284. package/dist/commands/shared/git-context.d.ts +1 -0
  285. package/dist/commands/shared/git-context.d.ts.map +1 -1
  286. package/dist/commands/shared/git-context.js +4 -2
  287. package/dist/commands/shared/git-ops.d.ts +1 -0
  288. package/dist/commands/shared/git-ops.d.ts.map +1 -1
  289. package/dist/commands/shared/git-ops.js +13 -0
  290. package/dist/commands/shared/operator-pipeline.d.ts +10 -0
  291. package/dist/commands/shared/operator-pipeline.d.ts.map +1 -0
  292. package/dist/commands/shared/operator-pipeline.js +16 -0
  293. package/dist/commands/shared/pr-meta.d.ts +32 -12
  294. package/dist/commands/shared/pr-meta.d.ts.map +1 -1
  295. package/dist/commands/shared/pr-meta.js +49 -14
  296. package/dist/commands/shared/reconcile-check.d.ts.map +1 -1
  297. package/dist/commands/shared/reconcile-check.js +28 -3
  298. package/dist/commands/shared/task-backend.d.ts +11 -7
  299. package/dist/commands/shared/task-backend.d.ts.map +1 -1
  300. package/dist/commands/shared/task-backend.js +107 -24
  301. package/dist/commands/shared/task-handoff.d.ts +64 -0
  302. package/dist/commands/shared/task-handoff.d.ts.map +1 -0
  303. package/dist/commands/shared/task-handoff.js +151 -0
  304. package/dist/commands/shared/task-mutation.d.ts +36 -0
  305. package/dist/commands/shared/task-mutation.d.ts.map +1 -0
  306. package/dist/commands/shared/task-mutation.js +67 -0
  307. package/dist/commands/shared/task-store.d.ts +65 -2
  308. package/dist/commands/shared/task-store.d.ts.map +1 -1
  309. package/dist/commands/shared/task-store.js +309 -91
  310. package/dist/commands/task/add.d.ts.map +1 -1
  311. package/dist/commands/task/add.js +41 -39
  312. package/dist/commands/task/block.d.ts.map +1 -1
  313. package/dist/commands/task/block.js +31 -89
  314. package/dist/commands/task/close-duplicate.d.ts.map +1 -1
  315. package/dist/commands/task/close-duplicate.js +0 -7
  316. package/dist/commands/task/close-noop.d.ts.map +1 -1
  317. package/dist/commands/task/close-noop.js +0 -21
  318. package/dist/commands/task/close-shared.d.ts +0 -2
  319. package/dist/commands/task/close-shared.d.ts.map +1 -1
  320. package/dist/commands/task/close-shared.js +24 -57
  321. package/dist/commands/task/comment.d.ts.map +1 -1
  322. package/dist/commands/task/comment.js +48 -42
  323. package/dist/commands/task/derive.command.d.ts +1 -0
  324. package/dist/commands/task/derive.command.d.ts.map +1 -1
  325. package/dist/commands/task/derive.command.js +15 -2
  326. package/dist/commands/task/derive.d.ts +1 -0
  327. package/dist/commands/task/derive.d.ts.map +1 -1
  328. package/dist/commands/task/derive.js +37 -7
  329. package/dist/commands/task/doc.command.d.ts.map +1 -1
  330. package/dist/commands/task/doc.command.js +7 -6
  331. package/dist/commands/task/doc.d.ts.map +1 -1
  332. package/dist/commands/task/doc.js +68 -61
  333. package/dist/commands/task/finish-shared.d.ts +60 -0
  334. package/dist/commands/task/finish-shared.d.ts.map +1 -0
  335. package/dist/commands/task/finish-shared.js +181 -0
  336. package/dist/commands/task/finish.d.ts +1 -0
  337. package/dist/commands/task/finish.d.ts.map +1 -1
  338. package/dist/commands/task/finish.js +73 -204
  339. package/dist/commands/task/handoff-record.command.d.ts +17 -0
  340. package/dist/commands/task/handoff-record.command.d.ts.map +1 -0
  341. package/dist/commands/task/handoff-record.command.js +140 -0
  342. package/dist/commands/task/handoff-show.command.d.ts +8 -0
  343. package/dist/commands/task/handoff-show.command.d.ts.map +1 -0
  344. package/dist/commands/task/handoff-show.command.js +77 -0
  345. package/dist/commands/task/handoff.command.d.ts +7 -0
  346. package/dist/commands/task/handoff.command.d.ts.map +1 -0
  347. package/dist/commands/task/handoff.command.js +21 -0
  348. package/dist/commands/task/handoff.shared.d.ts +39 -0
  349. package/dist/commands/task/handoff.shared.d.ts.map +1 -0
  350. package/dist/commands/task/handoff.shared.js +134 -0
  351. package/dist/commands/task/hosted-close.command.d.ts +9 -0
  352. package/dist/commands/task/hosted-close.command.d.ts.map +1 -0
  353. package/dist/commands/task/hosted-close.command.js +190 -0
  354. package/dist/commands/task/hosted-merge-sync.d.ts +40 -0
  355. package/dist/commands/task/hosted-merge-sync.d.ts.map +1 -0
  356. package/dist/commands/task/hosted-merge-sync.js +277 -0
  357. package/dist/commands/task/list.d.ts.map +1 -1
  358. package/dist/commands/task/list.js +7 -24
  359. package/dist/commands/task/migrate-doc.d.ts +15 -0
  360. package/dist/commands/task/migrate-doc.d.ts.map +1 -1
  361. package/dist/commands/task/migrate-doc.js +126 -35
  362. package/dist/commands/task/new.d.ts.map +1 -1
  363. package/dist/commands/task/new.js +26 -4
  364. package/dist/commands/task/next.d.ts.map +1 -1
  365. package/dist/commands/task/next.js +10 -28
  366. package/dist/commands/task/normalize.command.d.ts +1 -0
  367. package/dist/commands/task/normalize.command.d.ts.map +1 -1
  368. package/dist/commands/task/normalize.command.js +12 -0
  369. package/dist/commands/task/normalize.d.ts +1 -0
  370. package/dist/commands/task/normalize.d.ts.map +1 -1
  371. package/dist/commands/task/normalize.js +21 -9
  372. package/dist/commands/task/plan.command.d.ts +3 -4
  373. package/dist/commands/task/plan.command.d.ts.map +1 -1
  374. package/dist/commands/task/plan.command.js +6 -12
  375. package/dist/commands/task/plan.d.ts.map +1 -1
  376. package/dist/commands/task/plan.js +118 -125
  377. package/dist/commands/task/reclaim.command.d.ts +11 -0
  378. package/dist/commands/task/reclaim.command.d.ts.map +1 -0
  379. package/dist/commands/task/reclaim.command.js +102 -0
  380. package/dist/commands/task/resume-context.command.d.ts +9 -0
  381. package/dist/commands/task/resume-context.command.d.ts.map +1 -0
  382. package/dist/commands/task/resume-context.command.js +60 -0
  383. package/dist/commands/task/run-cancel.command.d.ts +6 -0
  384. package/dist/commands/task/run-cancel.command.d.ts.map +1 -0
  385. package/dist/commands/task/run-cancel.command.js +45 -0
  386. package/dist/commands/task/run-cancel.spec.d.ts +7 -0
  387. package/dist/commands/task/run-cancel.spec.d.ts.map +1 -0
  388. package/dist/commands/task/run-cancel.spec.js +20 -0
  389. package/dist/commands/task/run-resume.command.d.ts +6 -0
  390. package/dist/commands/task/run-resume.command.d.ts.map +1 -0
  391. package/dist/commands/task/run-resume.command.js +55 -0
  392. package/dist/commands/task/run-resume.spec.d.ts +7 -0
  393. package/dist/commands/task/run-resume.spec.d.ts.map +1 -0
  394. package/dist/commands/task/run-resume.spec.js +20 -0
  395. package/dist/commands/task/run-retry.command.d.ts +6 -0
  396. package/dist/commands/task/run-retry.command.d.ts.map +1 -0
  397. package/dist/commands/task/run-retry.command.js +56 -0
  398. package/dist/commands/task/run-retry.spec.d.ts +7 -0
  399. package/dist/commands/task/run-retry.spec.d.ts.map +1 -0
  400. package/dist/commands/task/run-retry.spec.js +20 -0
  401. package/dist/commands/task/run-show.command.d.ts +6 -0
  402. package/dist/commands/task/run-show.command.d.ts.map +1 -0
  403. package/dist/commands/task/run-show.command.js +133 -0
  404. package/dist/commands/task/run-show.spec.d.ts +8 -0
  405. package/dist/commands/task/run-show.spec.d.ts.map +1 -0
  406. package/dist/commands/task/run-show.spec.js +44 -0
  407. package/dist/commands/task/run-tail.command.d.ts +6 -0
  408. package/dist/commands/task/run-tail.command.d.ts.map +1 -0
  409. package/dist/commands/task/run-tail.command.js +26 -0
  410. package/dist/commands/task/run-tail.spec.d.ts +8 -0
  411. package/dist/commands/task/run-tail.spec.d.ts.map +1 -0
  412. package/dist/commands/task/run-tail.spec.js +51 -0
  413. package/dist/commands/task/run-trace.command.d.ts +6 -0
  414. package/dist/commands/task/run-trace.command.d.ts.map +1 -0
  415. package/dist/commands/task/run-trace.command.js +25 -0
  416. package/dist/commands/task/run-trace.spec.d.ts +7 -0
  417. package/dist/commands/task/run-trace.spec.d.ts.map +1 -0
  418. package/dist/commands/task/run-trace.spec.js +31 -0
  419. package/dist/commands/task/run.command.d.ts +6 -0
  420. package/dist/commands/task/run.command.d.ts.map +1 -0
  421. package/dist/commands/task/run.command.js +74 -0
  422. package/dist/commands/task/run.spec.d.ts +7 -0
  423. package/dist/commands/task/run.spec.d.ts.map +1 -0
  424. package/dist/commands/task/run.spec.js +26 -0
  425. package/dist/commands/task/scaffold.d.ts.map +1 -1
  426. package/dist/commands/task/scaffold.js +4 -2
  427. package/dist/commands/task/scrub.d.ts.map +1 -1
  428. package/dist/commands/task/scrub.js +27 -24
  429. package/dist/commands/task/search.d.ts.map +1 -1
  430. package/dist/commands/task/search.js +21 -31
  431. package/dist/commands/task/set-status.d.ts.map +1 -1
  432. package/dist/commands/task/set-status.js +38 -111
  433. package/dist/commands/task/shared/dependencies.d.ts +5 -4
  434. package/dist/commands/task/shared/dependencies.d.ts.map +1 -1
  435. package/dist/commands/task/shared/dependencies.js +20 -2
  436. package/dist/commands/task/shared/docs.d.ts +6 -1
  437. package/dist/commands/task/shared/docs.d.ts.map +1 -1
  438. package/dist/commands/task/shared/docs.js +14 -1
  439. package/dist/commands/task/shared/listing.d.ts +16 -2
  440. package/dist/commands/task/shared/listing.d.ts.map +1 -1
  441. package/dist/commands/task/shared/listing.js +56 -0
  442. package/dist/commands/task/shared/transition-command.d.ts +15 -0
  443. package/dist/commands/task/shared/transition-command.d.ts.map +1 -0
  444. package/dist/commands/task/shared/transition-command.js +43 -0
  445. package/dist/commands/task/shared/transitions.d.ts +56 -0
  446. package/dist/commands/task/shared/transitions.d.ts.map +1 -1
  447. package/dist/commands/task/shared/transitions.js +82 -8
  448. package/dist/commands/task/shared/workflow-transition-service.d.ts +75 -0
  449. package/dist/commands/task/shared/workflow-transition-service.d.ts.map +1 -0
  450. package/dist/commands/task/shared/workflow-transition-service.js +226 -0
  451. package/dist/commands/task/shared.d.ts +6 -4
  452. package/dist/commands/task/shared.d.ts.map +1 -1
  453. package/dist/commands/task/shared.js +6 -4
  454. package/dist/commands/task/show.d.ts.map +1 -1
  455. package/dist/commands/task/show.js +37 -3
  456. package/dist/commands/task/start.d.ts.map +1 -1
  457. package/dist/commands/task/start.js +32 -113
  458. package/dist/commands/task/task.command.d.ts +3 -4
  459. package/dist/commands/task/task.command.d.ts.map +1 -1
  460. package/dist/commands/task/task.command.js +22 -37
  461. package/dist/commands/task/verify-record.d.ts.map +1 -1
  462. package/dist/commands/task/verify-record.js +21 -146
  463. package/dist/commands/task/verify.command.d.ts.map +1 -1
  464. package/dist/commands/task/verify.command.js +7 -6
  465. package/dist/commands/task.test-helpers.d.ts +13 -0
  466. package/dist/commands/task.test-helpers.d.ts.map +1 -0
  467. package/dist/commands/task.test-helpers.js +65 -0
  468. package/dist/commands/upgrade/apply.d.ts +2 -0
  469. package/dist/commands/upgrade/apply.d.ts.map +1 -1
  470. package/dist/commands/upgrade/apply.js +33 -1
  471. package/dist/commands/upgrade/materialize.d.ts +28 -0
  472. package/dist/commands/upgrade/materialize.d.ts.map +1 -0
  473. package/dist/commands/upgrade/materialize.js +154 -0
  474. package/dist/commands/upgrade/plan.d.ts +18 -0
  475. package/dist/commands/upgrade/plan.d.ts.map +1 -0
  476. package/dist/commands/upgrade/plan.js +219 -0
  477. package/dist/commands/upgrade/policy.d.ts +24 -0
  478. package/dist/commands/upgrade/policy.d.ts.map +1 -0
  479. package/dist/commands/upgrade/policy.js +182 -0
  480. package/dist/commands/upgrade/report.d.ts.map +1 -1
  481. package/dist/commands/upgrade/report.js +7 -5
  482. package/dist/commands/upgrade.command.d.ts.map +1 -1
  483. package/dist/commands/upgrade.command.js +25 -0
  484. package/dist/commands/upgrade.d.ts +1 -0
  485. package/dist/commands/upgrade.d.ts.map +1 -1
  486. package/dist/commands/upgrade.js +164 -618
  487. package/dist/commands/workflow.command.d.ts +3 -4
  488. package/dist/commands/workflow.command.d.ts.map +1 -1
  489. package/dist/commands/workflow.command.js +8 -25
  490. package/dist/policy/rules/allowlist.d.ts.map +1 -1
  491. package/dist/policy/rules/allowlist.js +12 -9
  492. package/dist/ports/task-backend-port.d.ts +4 -2
  493. package/dist/ports/task-backend-port.d.ts.map +1 -1
  494. package/dist/runner/adapters/codex.d.ts +9 -0
  495. package/dist/runner/adapters/codex.d.ts.map +1 -0
  496. package/dist/runner/adapters/codex.js +414 -0
  497. package/dist/runner/adapters/custom.d.ts +12 -0
  498. package/dist/runner/adapters/custom.d.ts.map +1 -0
  499. package/dist/runner/adapters/custom.js +512 -0
  500. package/dist/runner/adapters/index.d.ts +8 -0
  501. package/dist/runner/adapters/index.d.ts.map +1 -0
  502. package/dist/runner/adapters/index.js +15 -0
  503. package/dist/runner/adapters/recipe-run-profile.d.ts +8 -0
  504. package/dist/runner/adapters/recipe-run-profile.d.ts.map +1 -0
  505. package/dist/runner/adapters/recipe-run-profile.js +53 -0
  506. package/dist/runner/adapters/shared.d.ts +45 -0
  507. package/dist/runner/adapters/shared.d.ts.map +1 -0
  508. package/dist/runner/adapters/shared.js +58 -0
  509. package/dist/runner/artifacts.d.ts +31 -0
  510. package/dist/runner/artifacts.d.ts.map +1 -0
  511. package/dist/runner/artifacts.js +153 -0
  512. package/dist/runner/codex-approval-probe.d.ts +23 -0
  513. package/dist/runner/codex-approval-probe.d.ts.map +1 -0
  514. package/dist/runner/codex-approval-probe.js +55 -0
  515. package/dist/runner/codex-smoke.d.ts +11 -0
  516. package/dist/runner/codex-smoke.d.ts.map +1 -0
  517. package/dist/runner/codex-smoke.js +45 -0
  518. package/dist/runner/config.d.ts +6 -0
  519. package/dist/runner/config.d.ts.map +1 -0
  520. package/dist/runner/config.js +15 -0
  521. package/dist/runner/context/base-prompts.d.ts +10 -0
  522. package/dist/runner/context/base-prompts.d.ts.map +1 -0
  523. package/dist/runner/context/base-prompts.js +255 -0
  524. package/dist/runner/context/recipe-context.d.ts +17 -0
  525. package/dist/runner/context/recipe-context.d.ts.map +1 -0
  526. package/dist/runner/context/recipe-context.js +48 -0
  527. package/dist/runner/context/task-context.d.ts +24 -0
  528. package/dist/runner/context/task-context.d.ts.map +1 -0
  529. package/dist/runner/context/task-context.js +266 -0
  530. package/dist/runner/index.d.ts +12 -0
  531. package/dist/runner/index.d.ts.map +1 -0
  532. package/dist/runner/index.js +11 -0
  533. package/dist/runner/policy-decision.d.ts +12 -0
  534. package/dist/runner/policy-decision.d.ts.map +1 -0
  535. package/dist/runner/policy-decision.js +89 -0
  536. package/dist/runner/policy-display.d.ts +4 -0
  537. package/dist/runner/policy-display.d.ts.map +1 -0
  538. package/dist/runner/policy-display.js +41 -0
  539. package/dist/runner/process-supervision.d.ts +48 -0
  540. package/dist/runner/process-supervision.d.ts.map +1 -0
  541. package/dist/runner/process-supervision.js +490 -0
  542. package/dist/runner/result-manifest-policy.d.ts +9 -0
  543. package/dist/runner/result-manifest-policy.d.ts.map +1 -0
  544. package/dist/runner/result-manifest-policy.js +96 -0
  545. package/dist/runner/result-manifest.d.ts +30 -0
  546. package/dist/runner/result-manifest.d.ts.map +1 -0
  547. package/dist/runner/result-manifest.js +322 -0
  548. package/dist/runner/run-id.d.ts +2 -0
  549. package/dist/runner/run-id.d.ts.map +1 -0
  550. package/dist/runner/run-id.js +3 -0
  551. package/dist/runner/run-repository.d.ts +51 -0
  552. package/dist/runner/run-repository.d.ts.map +1 -0
  553. package/dist/runner/run-repository.js +222 -0
  554. package/dist/runner/task-run-paths.d.ts +19 -0
  555. package/dist/runner/task-run-paths.d.ts.map +1 -0
  556. package/dist/runner/task-run-paths.js +25 -0
  557. package/dist/runner/task-state.d.ts +9 -0
  558. package/dist/runner/task-state.d.ts.map +1 -0
  559. package/dist/runner/task-state.js +354 -0
  560. package/dist/runner/test-helpers.d.ts +30 -0
  561. package/dist/runner/test-helpers.d.ts.map +1 -0
  562. package/dist/runner/test-helpers.js +97 -0
  563. package/dist/runner/trace-artifacts.d.ts +14 -0
  564. package/dist/runner/trace-artifacts.d.ts.map +1 -0
  565. package/dist/runner/trace-artifacts.js +80 -0
  566. package/dist/runner/trace.d.ts +10 -0
  567. package/dist/runner/trace.d.ts.map +1 -0
  568. package/dist/runner/trace.js +37 -0
  569. package/dist/runner/types.d.ts +317 -0
  570. package/dist/runner/types.d.ts.map +1 -0
  571. package/dist/runner/types.js +3 -0
  572. package/dist/runner/usecases/scenario-materialize-task.d.ts +29 -0
  573. package/dist/runner/usecases/scenario-materialize-task.d.ts.map +1 -0
  574. package/dist/runner/usecases/scenario-materialize-task.js +151 -0
  575. package/dist/runner/usecases/task-run-inspect.d.ts +41 -0
  576. package/dist/runner/usecases/task-run-inspect.d.ts.map +1 -0
  577. package/dist/runner/usecases/task-run-inspect.js +74 -0
  578. package/dist/runner/usecases/task-run-lifecycle-cancel.d.ts +10 -0
  579. package/dist/runner/usecases/task-run-lifecycle-cancel.d.ts.map +1 -0
  580. package/dist/runner/usecases/task-run-lifecycle-cancel.js +172 -0
  581. package/dist/runner/usecases/task-run-lifecycle-replay.d.ts +18 -0
  582. package/dist/runner/usecases/task-run-lifecycle-replay.d.ts.map +1 -0
  583. package/dist/runner/usecases/task-run-lifecycle-replay.js +128 -0
  584. package/dist/runner/usecases/task-run-lifecycle-shared.d.ts +45 -0
  585. package/dist/runner/usecases/task-run-lifecycle-shared.d.ts.map +1 -0
  586. package/dist/runner/usecases/task-run-lifecycle-shared.js +172 -0
  587. package/dist/runner/usecases/task-run-lifecycle.d.ts +4 -0
  588. package/dist/runner/usecases/task-run-lifecycle.d.ts.map +1 -0
  589. package/dist/runner/usecases/task-run-lifecycle.js +2 -0
  590. package/dist/runner/usecases/task-run.d.ts +32 -0
  591. package/dist/runner/usecases/task-run.d.ts.map +1 -0
  592. package/dist/runner/usecases/task-run.js +278 -0
  593. package/dist/shared/agent-emoji.d.ts.map +1 -1
  594. package/dist/shared/agent-emoji.js +1 -0
  595. package/dist/shared/errors.d.ts +1 -1
  596. package/dist/shared/errors.d.ts.map +1 -1
  597. package/dist/shared/guards.d.ts.map +1 -1
  598. package/dist/shared/guards.js +1 -0
  599. package/dist/shared/protected-paths.d.ts +10 -0
  600. package/dist/shared/protected-paths.d.ts.map +1 -1
  601. package/dist/shared/protected-paths.js +33 -0
  602. package/dist/shared/repo-cli-version.d.ts.map +1 -1
  603. package/dist/shared/repo-cli-version.js +7 -5
  604. package/dist/shared/task-doc-conflicts.d.ts +12 -0
  605. package/dist/shared/task-doc-conflicts.d.ts.map +1 -0
  606. package/dist/shared/task-doc-conflicts.js +40 -0
  607. package/dist/shared/task-doc-state.d.ts +10 -0
  608. package/dist/shared/task-doc-state.d.ts.map +1 -0
  609. package/dist/shared/task-doc-state.js +15 -0
  610. package/dist/test-helpers/fs.d.ts +2 -0
  611. package/dist/test-helpers/fs.d.ts.map +1 -0
  612. package/dist/test-helpers/fs.js +9 -0
  613. package/dist/usecases/context/resolve-context.d.ts +2 -0
  614. package/dist/usecases/context/resolve-context.d.ts.map +1 -1
  615. package/dist/usecases/context/resolve-context.js +4 -1
  616. package/dist/usecases/task/task-list-usecase.d.ts.map +1 -1
  617. package/dist/usecases/task/task-list-usecase.js +2 -8
  618. package/dist/workflow-runtime/fix.d.ts +9 -1
  619. package/dist/workflow-runtime/fix.d.ts.map +1 -1
  620. package/dist/workflow-runtime/fix.js +9 -1
  621. package/package.json +3 -2
  622. package/dist/backends/task-backend.test-helpers.d.ts +0 -4
  623. package/dist/backends/task-backend.test-helpers.d.ts.map +0 -1
  624. package/dist/backends/task-backend.test-helpers.js +0 -33
  625. package/dist/cli/run-cli/catalog.d.ts +0 -7
  626. package/dist/cli/run-cli/catalog.d.ts.map +0 -1
  627. package/dist/cli/run-cli/catalog.js +0 -22
  628. package/dist/cli/run-cli.core.pr-flow.test-helpers.d.ts +0 -3
  629. package/dist/cli/run-cli.core.pr-flow.test-helpers.d.ts.map +0 -1
  630. package/dist/cli/run-cli.core.pr-flow.test-helpers.js +0 -41
  631. package/dist/cli/run-cli.core.tasks.test-helpers.d.ts +0 -2
  632. package/dist/cli/run-cli.core.tasks.test-helpers.d.ts.map +0 -1
  633. package/dist/cli/run-cli.core.tasks.test-helpers.js +0 -6
  634. package/dist/commands/block.command.d.ts +0 -4
  635. package/dist/commands/block.command.d.ts.map +0 -1
  636. package/dist/commands/block.command.js +0 -2
  637. package/dist/commands/doctor.command.d.ts +0 -3
  638. package/dist/commands/doctor.command.d.ts.map +0 -1
  639. package/dist/commands/doctor.command.js +0 -2
  640. package/dist/commands/finish.command.d.ts +0 -4
  641. package/dist/commands/finish.command.d.ts.map +0 -1
  642. package/dist/commands/finish.command.js +0 -2
  643. package/dist/commands/recipes/install.command.d.ts +0 -3
  644. package/dist/commands/recipes/install.command.d.ts.map +0 -1
  645. package/dist/commands/recipes/install.command.js +0 -2
  646. package/dist/commands/start.command.d.ts +0 -4
  647. package/dist/commands/start.command.d.ts.map +0 -1
  648. package/dist/commands/start.command.js +0 -2
  649. package/dist/commands/task/list.command.d.ts +0 -4
  650. package/dist/commands/task/list.command.d.ts.map +0 -1
  651. package/dist/commands/task/list.command.js +0 -2
  652. package/dist/commands/task/next.command.d.ts +0 -4
  653. package/dist/commands/task/next.command.d.ts.map +0 -1
  654. package/dist/commands/task/next.command.js +0 -2
  655. package/dist/commands/task/search.command.d.ts +0 -4
  656. package/dist/commands/task/search.command.d.ts.map +0 -1
  657. package/dist/commands/task/search.command.js +0 -2
  658. package/dist/commands/task/show.command.d.ts +0 -4
  659. package/dist/commands/task/show.command.d.ts.map +0 -1
  660. package/dist/commands/task/show.command.js +0 -2
  661. package/dist/commands/verify.command.d.ts +0 -4
  662. package/dist/commands/verify.command.d.ts.map +0 -1
  663. package/dist/commands/verify.command.js +0 -2
@@ -0,0 +1,222 @@
1
+ import { readFile, readdir } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { CliError } from "../shared/errors.js";
4
+ import { appendRunnerEvent, readRunnerRunState, writePreparedRunnerArtifacts, writeRunnerRunState, } from "./artifacts.js";
5
+ import { resolveTaskRunnerPaths } from "./task-run-paths.js";
6
+ import { readTraceArtifactText } from "./trace-artifacts.js";
7
+ function parseTimestamp(value) {
8
+ const parsed = typeof value === "string" ? Date.parse(value) : Number.NaN;
9
+ return Number.isNaN(parsed) ? Number.NEGATIVE_INFINITY : parsed;
10
+ }
11
+ export function parseRunnerEventsText(text) {
12
+ return text
13
+ .split(/\r?\n/u)
14
+ .map((line) => line.trim())
15
+ .filter((line) => line.length > 0)
16
+ .flatMap((line) => {
17
+ try {
18
+ return [JSON.parse(line)];
19
+ }
20
+ catch {
21
+ return [];
22
+ }
23
+ });
24
+ }
25
+ async function readOptionalJson(filePath) {
26
+ try {
27
+ return JSON.parse(await readFile(filePath, "utf8"));
28
+ }
29
+ catch (err) {
30
+ const code = err?.code;
31
+ if (code === "ENOENT")
32
+ return null;
33
+ throw err;
34
+ }
35
+ }
36
+ async function readRequiredText(opts) {
37
+ try {
38
+ return await readFile(opts.file_path, "utf8");
39
+ }
40
+ catch (err) {
41
+ const code = err?.code;
42
+ if (code === "ENOENT") {
43
+ throw new CliError({
44
+ exitCode: 4,
45
+ code: "E_IO",
46
+ message: `Runner artifact not found for ${opts.task_id}:${opts.run_id} ` +
47
+ `(${opts.artifact_label} at ${opts.file_path})`,
48
+ });
49
+ }
50
+ throw err;
51
+ }
52
+ }
53
+ export function assertRunnerBundleMatchesTask(bundle, taskId, runId) {
54
+ const bundleTaskId = bundle.task?.task_id ??
55
+ (bundle.target.kind === "task" ? bundle.target.task_id : (bundle.target.task_id ?? null));
56
+ if (bundle.execution.run_id !== runId) {
57
+ throw new CliError({
58
+ exitCode: 4,
59
+ code: "E_IO",
60
+ message: `Runner bundle/run mismatch for ${taskId}:${runId} (bundle.run_id=${bundle.execution.run_id})`,
61
+ });
62
+ }
63
+ if (!bundleTaskId || bundleTaskId !== taskId) {
64
+ throw new CliError({
65
+ exitCode: 4,
66
+ code: "E_IO",
67
+ message: `Runner bundle/task mismatch for ${taskId}:${runId}`,
68
+ });
69
+ }
70
+ }
71
+ export class RunnerRunRepository {
72
+ paths;
73
+ constructor(paths) {
74
+ this.paths = paths;
75
+ }
76
+ static forTaskRun(opts) {
77
+ return new RunnerRunRepository(resolveTaskRunnerPaths({
78
+ git_root: opts.git_root,
79
+ workflow_dir: opts.workflow_dir,
80
+ task_id: opts.task_id,
81
+ run_id: opts.run_id,
82
+ }));
83
+ }
84
+ static fromBundle(bundle) {
85
+ return new RunnerRunRepository(bundle.execution.artifact_paths);
86
+ }
87
+ static fromInvocation(invocation) {
88
+ return new RunnerRunRepository({
89
+ run_dir: invocation.run_dir,
90
+ bundle_path: invocation.bundle_path,
91
+ bootstrap_path: invocation.bootstrap_path ?? "",
92
+ state_path: invocation.state_path,
93
+ events_path: invocation.events_path,
94
+ result_path: invocation.result_path,
95
+ trace_path: invocation.trace_path,
96
+ stderr_path: invocation.stderr_path,
97
+ });
98
+ }
99
+ async writePrepared(opts) {
100
+ return await writePreparedRunnerArtifacts(opts);
101
+ }
102
+ async readBundle() {
103
+ return await readOptionalJson(this.paths.bundle_path);
104
+ }
105
+ async readState() {
106
+ return await readRunnerRunState(this.paths.state_path);
107
+ }
108
+ async readRecord() {
109
+ const [bundle, state] = await Promise.all([this.readBundle(), this.readState()]);
110
+ if (!bundle || !state)
111
+ return null;
112
+ return {
113
+ bundle,
114
+ state,
115
+ result: state.result ?? null,
116
+ };
117
+ }
118
+ async readRequiredRecord(opts) {
119
+ const record = await this.readRecord();
120
+ if (!record) {
121
+ throw new CliError({
122
+ exitCode: 4,
123
+ code: "E_IO",
124
+ message: `Runner artifact not found for ${opts.task_id}:${opts.run_id}`,
125
+ });
126
+ }
127
+ assertRunnerBundleMatchesTask(record.bundle, opts.task_id, opts.run_id);
128
+ return record;
129
+ }
130
+ async writeState(state) {
131
+ await writeRunnerRunState({
132
+ state_path: this.paths.state_path,
133
+ state,
134
+ });
135
+ }
136
+ async appendEvent(event) {
137
+ await appendRunnerEvent({
138
+ events_path: this.paths.events_path,
139
+ event,
140
+ });
141
+ }
142
+ async readEventsTextRequired(opts) {
143
+ return await readRequiredText({
144
+ file_path: this.paths.events_path,
145
+ task_id: opts.task_id,
146
+ run_id: opts.run_id,
147
+ artifact_label: "events",
148
+ });
149
+ }
150
+ async readEventsRequired(opts) {
151
+ const events_text = await this.readEventsTextRequired(opts);
152
+ return {
153
+ events_text,
154
+ events: parseRunnerEventsText(events_text),
155
+ };
156
+ }
157
+ async readTraceTextRequired(opts) {
158
+ try {
159
+ return await readTraceArtifactText(this.paths.trace_path);
160
+ }
161
+ catch (err) {
162
+ const code = err?.code;
163
+ if (code === "ENOENT") {
164
+ throw new CliError({
165
+ exitCode: 4,
166
+ code: "E_IO",
167
+ message: `Runner artifact not found for ${opts.task_id}:${opts.run_id} ` +
168
+ `(trace at ${this.paths.trace_path} or ${this.paths.trace_path}.gz)`,
169
+ });
170
+ }
171
+ throw err;
172
+ }
173
+ }
174
+ }
175
+ export async function resolveLatestRunnerRunId(opts) {
176
+ const runsDir = path.join(opts.git_root, opts.workflow_dir, opts.task_id, "runs");
177
+ let entries = [];
178
+ try {
179
+ const runEntries = await readdir(runsDir, { withFileTypes: true });
180
+ entries = runEntries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
181
+ }
182
+ catch (err) {
183
+ const code = err?.code;
184
+ if (code === "ENOENT") {
185
+ throw new CliError({
186
+ exitCode: 4,
187
+ code: "E_IO",
188
+ message: `No runner runs found for task ${opts.task_id}`,
189
+ });
190
+ }
191
+ throw err;
192
+ }
193
+ const candidates = await Promise.all(entries.map(async (runId) => {
194
+ const repository = RunnerRunRepository.forTaskRun({
195
+ git_root: opts.git_root,
196
+ workflow_dir: opts.workflow_dir,
197
+ task_id: opts.task_id,
198
+ run_id: runId,
199
+ });
200
+ const state = await repository.readState();
201
+ if (!state)
202
+ return null;
203
+ return {
204
+ run_id: runId,
205
+ updated_at: parseTimestamp(state.updated_at),
206
+ created_at: parseTimestamp(state.created_at),
207
+ };
208
+ }));
209
+ const latest = candidates
210
+ .filter((entry) => entry !== null)
211
+ .toSorted((left, right) => right.updated_at - left.updated_at ||
212
+ right.created_at - left.created_at ||
213
+ right.run_id.localeCompare(left.run_id))[0];
214
+ if (!latest) {
215
+ throw new CliError({
216
+ exitCode: 4,
217
+ code: "E_IO",
218
+ message: `No runner runs found for task ${opts.task_id}`,
219
+ });
220
+ }
221
+ return latest.run_id;
222
+ }
@@ -0,0 +1,19 @@
1
+ import type { RunnerArtifactPaths } from "./types.js";
2
+ export declare const RUNNER_BUNDLE_FILENAME = "bundle.json";
3
+ export declare const RUNNER_BOOTSTRAP_FILENAME = "bootstrap.md";
4
+ export declare const RUNNER_STATE_FILENAME = "run-state.json";
5
+ export declare const RUNNER_EVENTS_FILENAME = "events.jsonl";
6
+ export declare const RUNNER_RESULT_FILENAME = "result.json";
7
+ export declare const RUNNER_TRACE_FILENAME = "agent-trace.jsonl";
8
+ export declare const RUNNER_STDERR_FILENAME = "stderr.log";
9
+ export type TaskRunnerPaths = RunnerArtifactPaths & {
10
+ task_dir: string;
11
+ runs_dir: string;
12
+ };
13
+ export declare function resolveTaskRunnerPaths(opts: {
14
+ git_root: string;
15
+ workflow_dir: string;
16
+ task_id: string;
17
+ run_id: string;
18
+ }): TaskRunnerPaths;
19
+ //# sourceMappingURL=task-run-paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-run-paths.d.ts","sourceRoot":"","sources":["../../src/runner/task-run-paths.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,eAAO,MAAM,sBAAsB,gBAAgB,CAAC;AACpD,eAAO,MAAM,yBAAyB,iBAAiB,CAAC;AACxD,eAAO,MAAM,qBAAqB,mBAAmB,CAAC;AACtD,eAAO,MAAM,sBAAsB,iBAAiB,CAAC;AACrD,eAAO,MAAM,sBAAsB,gBAAgB,CAAC;AACpD,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AACzD,eAAO,MAAM,sBAAsB,eAAe,CAAC;AAEnD,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,eAAe,CAgBlB"}
@@ -0,0 +1,25 @@
1
+ import path from "node:path";
2
+ export const RUNNER_BUNDLE_FILENAME = "bundle.json";
3
+ export const RUNNER_BOOTSTRAP_FILENAME = "bootstrap.md";
4
+ export const RUNNER_STATE_FILENAME = "run-state.json";
5
+ export const RUNNER_EVENTS_FILENAME = "events.jsonl";
6
+ export const RUNNER_RESULT_FILENAME = "result.json";
7
+ export const RUNNER_TRACE_FILENAME = "agent-trace.jsonl";
8
+ export const RUNNER_STDERR_FILENAME = "stderr.log";
9
+ export function resolveTaskRunnerPaths(opts) {
10
+ const task_dir = path.join(opts.git_root, opts.workflow_dir, opts.task_id);
11
+ const runs_dir = path.join(task_dir, "runs");
12
+ const run_dir = path.join(runs_dir, opts.run_id);
13
+ return {
14
+ task_dir,
15
+ runs_dir,
16
+ run_dir,
17
+ bundle_path: path.join(run_dir, RUNNER_BUNDLE_FILENAME),
18
+ bootstrap_path: path.join(run_dir, RUNNER_BOOTSTRAP_FILENAME),
19
+ state_path: path.join(run_dir, RUNNER_STATE_FILENAME),
20
+ events_path: path.join(run_dir, RUNNER_EVENTS_FILENAME),
21
+ result_path: path.join(run_dir, RUNNER_RESULT_FILENAME),
22
+ trace_path: path.join(run_dir, RUNNER_TRACE_FILENAME),
23
+ stderr_path: path.join(run_dir, RUNNER_STDERR_FILENAME),
24
+ };
25
+ }
@@ -0,0 +1,9 @@
1
+ import { type CommandContext } from "../commands/shared/task-backend.js";
2
+ import type { RunnerContextBundle, RunnerRunState } from "./types.js";
3
+ export declare function persistRunnerOutcomeToTask(opts: {
4
+ ctx: CommandContext;
5
+ task_id: string;
6
+ state: RunnerRunState;
7
+ bundle?: RunnerContextBundle;
8
+ }): Promise<void>;
9
+ //# sourceMappingURL=task-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-state.d.ts","sourceRoot":"","sources":["../../src/runner/task-state.ts"],"names":[],"mappings":"AAQA,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAgB9F,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAgB,MAAM,YAAY,CAAC;AAgTpF,wBAAsB,0BAA0B,CAAC,IAAI,EAAE;IACrD,GAAG,EAAE,cAAc,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,cAAc,CAAC;IACtB,MAAM,CAAC,EAAE,mBAAmB,CAAC;CAC9B,GAAG,OAAO,CAAC,IAAI,CAAC,CA8FhB"}
@@ -0,0 +1,354 @@
1
+ import { ensureDocSections, setMarkdownSection } from "@agentplaneorg/core";
2
+ import { backendNotSupportedMessage } from "../cli/output.js";
3
+ import { loadTaskFromContext } from "../commands/shared/task-backend.js";
4
+ import { backendIsLocalFileBackend, getTaskStore, setTaskFieldsIntent, setTaskSectionIntent, touchTaskDocMetaIntent, } from "../commands/shared/task-store.js";
5
+ import { extractDocSection, normalizeTaskDocVersion, resolveWritableDocSections, taskObservationSectionName, } from "../commands/task/shared.js";
6
+ import { CliError } from "../shared/errors.js";
7
+ const RUNNER_OUTCOME_BEGIN = "<!-- BEGIN RUNNER OUTCOME -->";
8
+ const RUNNER_OUTCOME_END = "<!-- END RUNNER OUTCOME -->";
9
+ const MAX_TASK_RUNNER_HISTORY = 5;
10
+ function formatRunnerTarget(target) {
11
+ if (target.kind === "task")
12
+ return `task ${target.task_id}`;
13
+ const base = `recipe ${target.recipe_id}:${target.scenario_id}`;
14
+ return target.task_id ? `${base} -> task ${target.task_id}` : base;
15
+ }
16
+ function normalizeRunnerOutcomeSection(sectionText) {
17
+ const normalized = (sectionText ?? "").replaceAll("\r\n", "\n").trimEnd();
18
+ if (!normalized)
19
+ return [RUNNER_OUTCOME_BEGIN, RUNNER_OUTCOME_END].join("\n");
20
+ const hasBegin = normalized.includes(RUNNER_OUTCOME_BEGIN);
21
+ const hasEnd = normalized.includes(RUNNER_OUTCOME_END);
22
+ if (hasBegin && hasEnd)
23
+ return normalized;
24
+ return [normalized, "", RUNNER_OUTCOME_BEGIN, RUNNER_OUTCOME_END].join("\n");
25
+ }
26
+ function replaceRunnerOutcomeSection(sectionText, entryText) {
27
+ const normalized = normalizeRunnerOutcomeSection(sectionText);
28
+ const beginIdx = normalized.indexOf(RUNNER_OUTCOME_BEGIN);
29
+ const endIdx = normalized.indexOf(RUNNER_OUTCOME_END);
30
+ if (beginIdx === -1 || endIdx === -1 || endIdx <= beginIdx) {
31
+ throw new Error("Runner outcome markers are malformed");
32
+ }
33
+ const beforeBegin = normalized.slice(0, beginIdx).trimEnd();
34
+ const afterEnd = normalized.slice(endIdx + RUNNER_OUTCOME_END.length).trimStart();
35
+ const parts = [];
36
+ if (beforeBegin)
37
+ parts.push(beforeBegin, "");
38
+ parts.push(RUNNER_OUTCOME_BEGIN);
39
+ if (entryText.trim())
40
+ parts.push("", entryText.trimEnd());
41
+ parts.push("", RUNNER_OUTCOME_END);
42
+ if (afterEnd)
43
+ parts.push("", afterEnd);
44
+ return parts.join("\n").trimEnd();
45
+ }
46
+ function runArtifactsDirForTask(taskId, runId) {
47
+ return `.agentplane/tasks/${taskId}/runs/${runId}`;
48
+ }
49
+ function formatRunnerAdapterLabel(adapterId) {
50
+ const normalized = adapterId.trim();
51
+ if (!normalized)
52
+ return "Runner";
53
+ return normalized.slice(0, 1).toUpperCase() + normalized.slice(1);
54
+ }
55
+ function renderTaskRunnerSummary(opts) {
56
+ const adapter = formatRunnerAdapterLabel(opts.adapter_id);
57
+ if (opts.status === "prepared")
58
+ return `${adapter} runner is prepared.`;
59
+ if (opts.status === "running")
60
+ return `${adapter} runner is running.`;
61
+ if (opts.status === "success")
62
+ return `${adapter} runner completed successfully.`;
63
+ if (opts.status === "cancelled")
64
+ return `${adapter} runner was cancelled.`;
65
+ return `${adapter} runner failed; inspect run artifacts for details.`;
66
+ }
67
+ function stripRunnerHistory(outcome) {
68
+ return {
69
+ run_id: outcome.run_id,
70
+ status: outcome.status,
71
+ adapter_id: outcome.adapter_id,
72
+ mode: outcome.mode,
73
+ updated_at: outcome.updated_at,
74
+ ...(outcome.started_at ? { started_at: outcome.started_at } : {}),
75
+ ...(outcome.ended_at ? { ended_at: outcome.ended_at } : {}),
76
+ exit_code: outcome.exit_code,
77
+ target: { ...outcome.target },
78
+ ...(outcome.summary ? { summary: outcome.summary } : {}),
79
+ ...(outcome.output_paths?.length ? { output_paths: [...outcome.output_paths] } : {}),
80
+ ...(outcome.metrics ? { metrics: { ...outcome.metrics } } : {}),
81
+ ...(outcome.evidence ? { evidence: { ...outcome.evidence } } : {}),
82
+ };
83
+ }
84
+ function runnerHistoryFromTask(outcome) {
85
+ if (!outcome)
86
+ return [];
87
+ if (outcome.history?.length)
88
+ return outcome.history.map((entry) => stripRunnerHistory(entry));
89
+ return [stripRunnerHistory(outcome)];
90
+ }
91
+ function renderRunnerMetrics(metrics) {
92
+ if (!metrics)
93
+ return null;
94
+ const pairs = [];
95
+ if (typeof metrics.duration_ms === "number")
96
+ pairs.push(`duration_ms=${metrics.duration_ms}`);
97
+ if (typeof metrics.stdout_bytes === "number")
98
+ pairs.push(`stdout_bytes=${metrics.stdout_bytes}`);
99
+ if (typeof metrics.stderr_bytes === "number")
100
+ pairs.push(`stderr_bytes=${metrics.stderr_bytes}`);
101
+ if (metrics.output_last_message_bytes === null ||
102
+ typeof metrics.output_last_message_bytes === "number") {
103
+ pairs.push(`output_last_message_bytes=${metrics.output_last_message_bytes ?? "null"}`);
104
+ }
105
+ return pairs.length > 0 ? pairs.join(", ") : null;
106
+ }
107
+ function renderVerificationHint(status) {
108
+ if (status === "success") {
109
+ return "runner completed successfully; human verification and closure remain explicit lifecycle steps.";
110
+ }
111
+ if (status === "failed") {
112
+ return "runner failed; inspect artifacts before retrying or recording verification evidence.";
113
+ }
114
+ if (status === "cancelled") {
115
+ return "runner was cancelled; verification evidence is incomplete until a later run succeeds.";
116
+ }
117
+ if (status === "running") {
118
+ return "runner is still executing; verification evidence is not complete yet.";
119
+ }
120
+ return "runner is prepared but has not produced verification-relevant output yet.";
121
+ }
122
+ function renderRunnerEvidence(evidence) {
123
+ if (!evidence)
124
+ return [];
125
+ const lines = [];
126
+ if (evidence.evidence_paths?.length) {
127
+ lines.push(`EvidencePaths: ${evidence.evidence_paths.join(", ")}`);
128
+ }
129
+ if (evidence.changed_paths?.length) {
130
+ lines.push(`ChangedPaths: ${evidence.changed_paths.join(", ")}`);
131
+ }
132
+ if (typeof evidence.files_changed_count === "number") {
133
+ lines.push(`FilesChangedCount: ${evidence.files_changed_count}`);
134
+ }
135
+ if (evidence.tests_run?.length) {
136
+ lines.push(`TestsRun: ${evidence.tests_run.join(" | ")}`);
137
+ }
138
+ if (evidence.verification_candidates?.length) {
139
+ lines.push(`VerificationCandidates: ${evidence.verification_candidates.join(" | ")}`);
140
+ }
141
+ return lines;
142
+ }
143
+ function renderRunnerOutcomeEntry(opts) {
144
+ const summary = opts.entry.summary ??
145
+ renderTaskRunnerSummary({
146
+ adapter_id: opts.entry.adapter_id,
147
+ status: opts.entry.status,
148
+ });
149
+ const capabilitiesUsed = opts.projection?.result?.capabilities_used;
150
+ const entryOutputPaths = opts.entry.output_paths;
151
+ const entryMetrics = opts.entry.metrics;
152
+ const entryEvidence = opts.entry.evidence;
153
+ const lines = [
154
+ `#### ${opts.entry.updated_at} — RUNNER — ${opts.entry.status}`,
155
+ "",
156
+ `RunId: ${opts.entry.run_id}`,
157
+ "",
158
+ `Adapter: ${opts.entry.adapter_id}`,
159
+ "",
160
+ `Mode: ${opts.entry.mode}`,
161
+ "",
162
+ `Target: ${formatRunnerTarget(opts.entry.target)}`,
163
+ "",
164
+ `UpdatedAt: ${opts.entry.updated_at}`,
165
+ "",
166
+ `RunArtifacts: ${runArtifactsDirForTask(opts.task_id, opts.entry.run_id)}`,
167
+ "",
168
+ `ExitCode: ${opts.entry.exit_code ?? "null"}`,
169
+ ];
170
+ if (opts.entry.started_at) {
171
+ lines.push("", `StartedAt: ${opts.entry.started_at}`);
172
+ }
173
+ if (opts.entry.ended_at) {
174
+ lines.push("", `EndedAt: ${opts.entry.ended_at}`);
175
+ }
176
+ if (summary) {
177
+ lines.push("", `Summary: ${summary}`);
178
+ }
179
+ if (opts.projection?.result?.artifacts?.length) {
180
+ lines.push("", `Artifacts: ${opts.projection.result.artifacts
181
+ .map((artifact) => (artifact.label ? `${artifact.label}=${artifact.path}` : artifact.path))
182
+ .join(", ")}`);
183
+ }
184
+ if (!opts.projection?.result?.artifacts?.length && entryOutputPaths?.length) {
185
+ lines.push("", `Outputs: ${entryOutputPaths.join(", ")}`);
186
+ }
187
+ if (capabilitiesUsed?.length) {
188
+ lines.push("", `Capabilities: ${capabilitiesUsed.join(", ")}`);
189
+ }
190
+ const metrics = renderRunnerMetrics(entryMetrics);
191
+ if (metrics) {
192
+ lines.push("", `Metrics: ${metrics}`);
193
+ }
194
+ const evidenceLines = renderRunnerEvidence(entryEvidence);
195
+ if (evidenceLines.length > 0) {
196
+ lines.push("", ...evidenceLines);
197
+ }
198
+ lines.push("", `VerificationHint: ${renderVerificationHint(opts.entry.status)}`);
199
+ return `${lines.join("\n").trimEnd()}\n`;
200
+ }
201
+ function buildTaskRunnerHistoryEntry(projection) {
202
+ const { state, result } = projection;
203
+ const outcome = {
204
+ run_id: state.run_id,
205
+ status: state.status,
206
+ adapter_id: state.adapter_id,
207
+ mode: state.mode,
208
+ updated_at: state.updated_at,
209
+ exit_code: state.result?.exit_code ?? null,
210
+ target: { ...state.target },
211
+ };
212
+ if (result?.started_at)
213
+ outcome.started_at = result.started_at;
214
+ if (result?.ended_at)
215
+ outcome.ended_at = result.ended_at;
216
+ outcome.summary = renderTaskRunnerSummary({
217
+ adapter_id: state.adapter_id,
218
+ status: state.status,
219
+ });
220
+ if (result?.output_paths?.length)
221
+ outcome.output_paths = [...result.output_paths];
222
+ if (result?.metrics)
223
+ outcome.metrics = { ...result.metrics };
224
+ if (result?.evidence)
225
+ outcome.evidence = { ...result.evidence };
226
+ return outcome;
227
+ }
228
+ function mergeTaskRunnerHistory(opts) {
229
+ const merged = [];
230
+ const seen = new Set();
231
+ for (const entry of [opts.latest, ...runnerHistoryFromTask(opts.previous)]) {
232
+ if (seen.has(entry.run_id))
233
+ continue;
234
+ seen.add(entry.run_id);
235
+ merged.push(stripRunnerHistory(entry));
236
+ if (merged.length >= MAX_TASK_RUNNER_HISTORY)
237
+ break;
238
+ }
239
+ return merged;
240
+ }
241
+ function buildTaskRunnerOutcome(opts) {
242
+ const latest = buildTaskRunnerHistoryEntry(opts.projection);
243
+ const history = mergeTaskRunnerHistory({ latest, previous: opts.previous });
244
+ return history.length > 1 ? { ...latest, history } : latest;
245
+ }
246
+ function renderRunnerOutcomeHistory(opts) {
247
+ const history = opts.outcome.history?.length
248
+ ? opts.outcome.history
249
+ : [stripRunnerHistory(opts.outcome)];
250
+ const [latest, ...previous] = history;
251
+ return [
252
+ renderRunnerOutcomeEntry({
253
+ task_id: opts.task_id,
254
+ entry: latest,
255
+ projection: opts.projection,
256
+ }),
257
+ ...previous.map((entry) => renderRunnerOutcomeEntry({ task_id: opts.task_id, entry })),
258
+ ]
259
+ .join("\n")
260
+ .trimEnd();
261
+ }
262
+ function resolveRunnerUpdatedBy(task) {
263
+ const owner = typeof task.owner === "string" ? task.owner.trim() : "";
264
+ if (owner)
265
+ return owner;
266
+ const docUpdatedBy = typeof task.doc_updated_by === "string" ? task.doc_updated_by.trim() : "";
267
+ if (docUpdatedBy)
268
+ return docUpdatedBy;
269
+ return "agentplane";
270
+ }
271
+ export async function persistRunnerOutcomeToTask(opts) {
272
+ if (opts.bundle?.execution.mode === "dry_run" || opts.state.mode === "dry_run")
273
+ return;
274
+ const backend = opts.ctx.taskBackend;
275
+ if (!backend.writeTask) {
276
+ throw new CliError({
277
+ exitCode: 2,
278
+ code: "E_USAGE",
279
+ message: backendNotSupportedMessage("task writes"),
280
+ });
281
+ }
282
+ const useStore = backendIsLocalFileBackend(opts.ctx);
283
+ if (useStore) {
284
+ const store = getTaskStore(opts.ctx);
285
+ await store.mutate(opts.task_id, (current) => {
286
+ const projection = {
287
+ state: opts.state,
288
+ result: opts.state.result ?? null,
289
+ };
290
+ const outcome = buildTaskRunnerOutcome({
291
+ projection,
292
+ previous: current.runner ?? null,
293
+ });
294
+ const docVersion = normalizeTaskDocVersion(current.doc_version);
295
+ const observationSection = taskObservationSectionName(docVersion);
296
+ const writableSections = resolveWritableDocSections({
297
+ allowedSections: opts.ctx.config.tasks.doc.sections,
298
+ requiredSections: opts.ctx.config.tasks.doc.required_sections,
299
+ targetSection: observationSection,
300
+ });
301
+ const baseDoc = ensureDocSections(String(current.doc ?? ""), writableSections);
302
+ const currentObservation = extractDocSection(baseDoc, observationSection);
303
+ const nextObservation = replaceRunnerOutcomeSection(currentObservation, renderRunnerOutcomeHistory({
304
+ task_id: opts.task_id,
305
+ outcome,
306
+ projection,
307
+ }));
308
+ return [
309
+ setTaskFieldsIntent({ runner: outcome }),
310
+ setTaskSectionIntent({
311
+ section: observationSection,
312
+ text: nextObservation,
313
+ requiredSections: writableSections,
314
+ }),
315
+ touchTaskDocMetaIntent({
316
+ updatedBy: resolveRunnerUpdatedBy(current),
317
+ version: docVersion,
318
+ }),
319
+ ];
320
+ });
321
+ return;
322
+ }
323
+ const task = await loadTaskFromContext({ ctx: opts.ctx, taskId: opts.task_id });
324
+ const projection = {
325
+ state: opts.state,
326
+ result: opts.state.result ?? null,
327
+ };
328
+ const outcome = buildTaskRunnerOutcome({
329
+ projection,
330
+ previous: task.runner ?? null,
331
+ });
332
+ const writableSections = resolveWritableDocSections({
333
+ allowedSections: opts.ctx.config.tasks.doc.sections,
334
+ requiredSections: opts.ctx.config.tasks.doc.required_sections,
335
+ targetSection: taskObservationSectionName(normalizeTaskDocVersion(task.doc_version)),
336
+ });
337
+ const baseDoc = ensureDocSections(String(task.doc ?? ""), writableSections);
338
+ const docVersion = normalizeTaskDocVersion(task.doc_version);
339
+ const observationSection = taskObservationSectionName(docVersion);
340
+ const currentObservation = extractDocSection(baseDoc, observationSection);
341
+ const nextObservation = replaceRunnerOutcomeSection(currentObservation, renderRunnerOutcomeHistory({
342
+ task_id: opts.task_id,
343
+ outcome,
344
+ projection,
345
+ }));
346
+ const nextDoc = ensureDocSections(setMarkdownSection(baseDoc, observationSection, nextObservation), writableSections);
347
+ await backend.writeTask({
348
+ ...task,
349
+ runner: outcome,
350
+ doc: nextDoc,
351
+ doc_updated_at: opts.state.updated_at,
352
+ doc_updated_by: resolveRunnerUpdatedBy(task),
353
+ });
354
+ }
@@ -0,0 +1,30 @@
1
+ import type { RunnerContextBundle } from "./types.js";
2
+ type MakeRunnerContextBundleOptions = {
3
+ adapterId?: string;
4
+ taskId?: string;
5
+ runId?: string;
6
+ gitRoot?: string;
7
+ workflowDir?: string;
8
+ title?: string;
9
+ description?: string;
10
+ status?: string;
11
+ owner?: string;
12
+ priority?: string;
13
+ tags?: string[];
14
+ mode?: RunnerContextBundle["execution"]["mode"];
15
+ doc?: string;
16
+ sections?: Record<string, string>;
17
+ basePrompts?: RunnerContextBundle["base_prompts"];
18
+ target?: RunnerContextBundle["target"];
19
+ recipe?: RunnerContextBundle["recipe"];
20
+ repository?: Partial<RunnerContextBundle["repository"]>;
21
+ task?: Partial<RunnerContextBundle["task"]>;
22
+ execution?: Partial<Omit<RunnerContextBundle["execution"], "artifact_paths">> & {
23
+ artifact_paths?: Partial<RunnerContextBundle["execution"]["artifact_paths"]>;
24
+ };
25
+ };
26
+ export declare function setRunnerBundleRunDir(bundle: RunnerContextBundle, runDir: string): void;
27
+ export declare function makeRunnerContextBundle(opts?: MakeRunnerContextBundleOptions): RunnerContextBundle;
28
+ export declare function writeRunnerExecutable(root: string, commandName: string, content: string | readonly string[]): Promise<string>;
29
+ export {};
30
+ //# sourceMappingURL=test-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-helpers.d.ts","sourceRoot":"","sources":["../../src/runner/test-helpers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAItD,KAAK,8BAA8B,GAAG;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,CAAC,EAAE,mBAAmB,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;IAChD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,WAAW,CAAC,EAAE,mBAAmB,CAAC,cAAc,CAAC,CAAC;IAClD,MAAM,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACvC,MAAM,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACvC,UAAU,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC,CAAC;IACxD,IAAI,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5C,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,WAAW,CAAC,EAAE,gBAAgB,CAAC,CAAC,GAAG;QAC9E,cAAc,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;KAC9E,CAAC;CACH,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CASvF;AAED,wBAAgB,uBAAuB,CACrC,IAAI,GAAE,8BAAmC,GACxC,mBAAmB,CA8ErB;AAED,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAClC,OAAO,CAAC,MAAM,CAAC,CAEjB"}