agentplane 0.3.15 → 0.3.16

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 (423) hide show
  1. package/assets/policy/incidents.md +7 -0
  2. package/bin/agentplane.js +1 -1
  3. package/bin/framework-dev-contract.js +1 -0
  4. package/dist/.build-manifest.json +506 -321
  5. package/dist/backends/task-backend/load.d.ts.map +1 -1
  6. package/dist/backends/task-backend/load.js +32 -19
  7. package/dist/backends/task-backend/local-backend-doc.d.ts.map +1 -1
  8. package/dist/backends/task-backend/local-backend-doc.js +1 -1
  9. package/dist/backends/task-backend/redmine/backend-runtime.d.ts +147 -0
  10. package/dist/backends/task-backend/redmine/backend-runtime.d.ts.map +1 -0
  11. package/dist/backends/task-backend/redmine/backend-runtime.js +258 -0
  12. package/dist/backends/task-backend/redmine/backend-sync/context.d.ts +44 -0
  13. package/dist/backends/task-backend/redmine/backend-sync/context.d.ts.map +1 -0
  14. package/dist/backends/task-backend/redmine/backend-sync/context.js +8 -0
  15. package/dist/backends/task-backend/redmine/backend-sync/ids.d.ts +6 -0
  16. package/dist/backends/task-backend/redmine/backend-sync/ids.d.ts.map +1 -0
  17. package/dist/backends/task-backend/redmine/backend-sync/ids.js +21 -0
  18. package/dist/backends/task-backend/redmine/backend-sync/migration.d.ts +4 -0
  19. package/dist/backends/task-backend/redmine/backend-sync/migration.d.ts.map +1 -0
  20. package/dist/backends/task-backend/redmine/backend-sync/migration.js +87 -0
  21. package/dist/backends/task-backend/redmine/backend-sync/status.d.ts +10 -0
  22. package/dist/backends/task-backend/redmine/backend-sync/status.d.ts.map +1 -0
  23. package/dist/backends/task-backend/redmine/backend-sync/status.js +78 -0
  24. package/dist/backends/task-backend/redmine/backend-sync/sync.d.ts +12 -0
  25. package/dist/backends/task-backend/redmine/backend-sync/sync.d.ts.map +1 -0
  26. package/dist/backends/task-backend/redmine/backend-sync/sync.js +82 -0
  27. package/dist/backends/task-backend/redmine/backend-sync/write.d.ts +5 -0
  28. package/dist/backends/task-backend/redmine/backend-sync/write.d.ts.map +1 -0
  29. package/dist/backends/task-backend/redmine/backend-sync/write.js +100 -0
  30. package/dist/backends/task-backend/redmine/backend-sync.d.ts +6 -66
  31. package/dist/backends/task-backend/redmine/backend-sync.d.ts.map +1 -1
  32. package/dist/backends/task-backend/redmine/backend-sync.js +5 -367
  33. package/dist/backends/task-backend/redmine-backend.d.ts +2 -33
  34. package/dist/backends/task-backend/redmine-backend.d.ts.map +1 -1
  35. package/dist/backends/task-backend/redmine-backend.js +26 -241
  36. package/dist/backends/task-backend/shared/errors.d.ts +12 -0
  37. package/dist/backends/task-backend/shared/errors.d.ts.map +1 -1
  38. package/dist/backends/task-backend/shared/errors.js +12 -0
  39. package/dist/cli/archive.d.ts.map +1 -1
  40. package/dist/cli/archive.js +3 -5
  41. package/dist/cli/error-map.d.ts +7 -1
  42. package/dist/cli/error-map.d.ts.map +1 -1
  43. package/dist/cli/error-map.js +231 -19
  44. package/dist/cli/exit-codes.d.ts +14 -2
  45. package/dist/cli/exit-codes.d.ts.map +1 -1
  46. package/dist/cli/exit-codes.js +24 -11
  47. package/dist/cli/output.d.ts +3 -0
  48. package/dist/cli/output.d.ts.map +1 -1
  49. package/dist/cli/output.js +25 -14
  50. package/dist/cli/prompts.d.ts.map +1 -1
  51. package/dist/cli/prompts.js +44 -0
  52. package/dist/cli/run-cli/command-catalog/core.d.ts.map +1 -1
  53. package/dist/cli/run-cli/command-catalog/core.js +34 -76
  54. package/dist/cli/run-cli/command-catalog/lifecycle.d.ts.map +1 -1
  55. package/dist/cli/run-cli/command-catalog/lifecycle.js +23 -26
  56. package/dist/cli/run-cli/command-catalog/project.d.ts.map +1 -1
  57. package/dist/cli/run-cli/command-catalog/project.js +39 -54
  58. package/dist/cli/run-cli/command-catalog/shared.d.ts +15 -3
  59. package/dist/cli/run-cli/command-catalog/shared.d.ts.map +1 -1
  60. package/dist/cli/run-cli/command-catalog/shared.js +19 -6
  61. package/dist/cli/run-cli/command-catalog/task.d.ts.map +1 -1
  62. package/dist/cli/run-cli/command-catalog/task.js +63 -57
  63. package/dist/cli/run-cli/command-loaders.d.ts +174 -0
  64. package/dist/cli/run-cli/command-loaders.d.ts.map +1 -0
  65. package/dist/cli/run-cli/command-loaders.js +128 -0
  66. package/dist/cli/run-cli/commands/init/model.d.ts +42 -0
  67. package/dist/cli/run-cli/commands/init/model.d.ts.map +1 -0
  68. package/dist/cli/run-cli/commands/init/orchestrate.d.ts +9 -0
  69. package/dist/cli/run-cli/commands/init/orchestrate.d.ts.map +1 -0
  70. package/dist/cli/run-cli/commands/init/orchestrate.js +321 -0
  71. package/dist/cli/run-cli/commands/init/parsers.d.ts +5 -0
  72. package/dist/cli/run-cli/commands/init/parsers.d.ts.map +1 -0
  73. package/dist/cli/run-cli/commands/init/parsers.js +36 -0
  74. package/dist/cli/run-cli/commands/init/presets.d.ts +15 -0
  75. package/dist/cli/run-cli/commands/init/presets.d.ts.map +1 -0
  76. package/dist/cli/run-cli/commands/init/presets.js +63 -0
  77. package/dist/cli/run-cli/commands/init/spec.d.ts +5 -0
  78. package/dist/cli/run-cli/commands/init/spec.d.ts.map +1 -0
  79. package/dist/cli/run-cli/commands/init/spec.js +212 -0
  80. package/dist/cli/run-cli/commands/init/write-config.d.ts +1 -0
  81. package/dist/cli/run-cli/commands/init/write-config.d.ts.map +1 -1
  82. package/dist/cli/run-cli/commands/init/write-config.js +1 -0
  83. package/dist/cli/run-cli/commands/init/write-gitignore.js +1 -1
  84. package/dist/cli/run-cli/commands/init.d.ts +1 -28
  85. package/dist/cli/run-cli/commands/init.d.ts.map +1 -1
  86. package/dist/cli/run-cli/commands/init.js +1 -596
  87. package/dist/cli/run-cli/update-warning.d.ts +1 -0
  88. package/dist/cli/run-cli/update-warning.d.ts.map +1 -1
  89. package/dist/cli/run-cli/update-warning.js +10 -2
  90. package/dist/cli/run-cli.d.ts.map +1 -1
  91. package/dist/cli/run-cli.js +1 -2
  92. package/dist/cli/spec/errors.d.ts +13 -1
  93. package/dist/cli/spec/errors.d.ts.map +1 -1
  94. package/dist/cli/spec/errors.js +14 -4
  95. package/dist/commands/backend.d.ts.map +1 -1
  96. package/dist/commands/backend.js +66 -118
  97. package/dist/commands/block.spec.js +1 -1
  98. package/dist/commands/branch/work-start.js +1 -1
  99. package/dist/commands/commit.spec.js +1 -1
  100. package/dist/commands/doctor/branch-pr.js +1 -1
  101. package/dist/commands/doctor/fixes.js +1 -1
  102. package/dist/commands/doctor/runtime.d.ts.map +1 -1
  103. package/dist/commands/doctor/runtime.js +2 -2
  104. package/dist/commands/doctor/workspace.js +1 -1
  105. package/dist/commands/finish.spec.js +1 -1
  106. package/dist/commands/guard/commit.command.js +1 -1
  107. package/dist/commands/guard/impl/clean.d.ts +6 -0
  108. package/dist/commands/guard/impl/clean.d.ts.map +1 -0
  109. package/dist/commands/guard/impl/clean.js +29 -0
  110. package/dist/commands/guard/impl/close-dirt.d.ts +6 -0
  111. package/dist/commands/guard/impl/close-dirt.d.ts.map +1 -0
  112. package/dist/commands/guard/impl/close-dirt.js +56 -0
  113. package/dist/commands/guard/impl/commands.d.ts +4 -36
  114. package/dist/commands/guard/impl/commands.d.ts.map +1 -1
  115. package/dist/commands/guard/impl/commands.js +4 -549
  116. package/dist/commands/guard/impl/comment-commit.js +1 -1
  117. package/dist/commands/guard/impl/commit-diagnostics.d.ts +4 -0
  118. package/dist/commands/guard/impl/commit-diagnostics.d.ts.map +1 -0
  119. package/dist/commands/guard/impl/commit-diagnostics.js +150 -0
  120. package/dist/commands/guard/impl/commit.d.ts +25 -0
  121. package/dist/commands/guard/impl/commit.d.ts.map +1 -0
  122. package/dist/commands/guard/impl/commit.js +366 -0
  123. package/dist/commands/guard/impl/guard-commit.d.ts +3 -0
  124. package/dist/commands/guard/impl/guard-commit.d.ts.map +1 -0
  125. package/dist/commands/guard/impl/guard-commit.js +21 -0
  126. package/dist/commands/guard/impl/policy.d.ts +1 -0
  127. package/dist/commands/guard/impl/policy.d.ts.map +1 -1
  128. package/dist/commands/guard/impl/policy.js +9 -2
  129. package/dist/commands/guard/impl/suggest.d.ts +6 -0
  130. package/dist/commands/guard/impl/suggest.d.ts.map +1 -0
  131. package/dist/commands/guard/impl/suggest.js +33 -0
  132. package/dist/commands/hooks/index.d.ts +3 -0
  133. package/dist/commands/hooks/index.d.ts.map +1 -1
  134. package/dist/commands/hooks/index.js +27 -10
  135. package/dist/commands/pr/integrate/cmd.js +1 -1
  136. package/dist/commands/pr/integrate/internal/prepare.js +1 -1
  137. package/dist/commands/pr/internal/auto-commit.d.ts.map +1 -1
  138. package/dist/commands/pr/internal/auto-commit.js +2 -5
  139. package/dist/commands/pr/internal/gh-api.d.ts.map +1 -1
  140. package/dist/commands/pr/internal/gh-api.js +15 -8
  141. package/dist/commands/pr/internal/sync-branch.d.ts +0 -1
  142. package/dist/commands/pr/internal/sync-branch.d.ts.map +1 -1
  143. package/dist/commands/pr/internal/sync-branch.js +2 -5
  144. package/dist/commands/pr/internal/sync.d.ts.map +1 -1
  145. package/dist/commands/pr/internal/sync.js +30 -0
  146. package/dist/commands/pr/open.d.ts.map +1 -1
  147. package/dist/commands/pr/open.js +98 -8
  148. package/dist/commands/recipes/impl/resolver.js +1 -1
  149. package/dist/commands/recipes/impl/version.js +1 -1
  150. package/dist/commands/release/apply.command.js +1 -1
  151. package/dist/commands/release/apply.mutation.d.ts +1 -0
  152. package/dist/commands/release/apply.mutation.d.ts.map +1 -1
  153. package/dist/commands/release/apply.mutation.js +4 -0
  154. package/dist/commands/release/apply.pipeline/finalize.d.ts +21 -0
  155. package/dist/commands/release/apply.pipeline/finalize.d.ts.map +1 -0
  156. package/dist/commands/release/apply.pipeline/finalize.js +80 -0
  157. package/dist/commands/release/apply.pipeline/mutation.d.ts +18 -0
  158. package/dist/commands/release/apply.pipeline/mutation.d.ts.map +1 -0
  159. package/dist/commands/release/apply.pipeline/mutation.js +78 -0
  160. package/dist/commands/release/apply.pipeline/preflight.d.ts +25 -0
  161. package/dist/commands/release/apply.pipeline/preflight.d.ts.map +1 -0
  162. package/dist/commands/release/apply.pipeline/preflight.js +69 -0
  163. package/dist/commands/release/apply.pipeline/shared.d.ts +2 -0
  164. package/dist/commands/release/apply.pipeline/shared.d.ts.map +1 -0
  165. package/dist/commands/release/apply.pipeline/shared.js +5 -0
  166. package/dist/commands/release/apply.pipeline/state.d.ts +25 -0
  167. package/dist/commands/release/apply.pipeline/state.d.ts.map +1 -0
  168. package/dist/commands/release/apply.pipeline/state.js +129 -0
  169. package/dist/commands/release/apply.pipeline.d.ts +1 -1
  170. package/dist/commands/release/apply.pipeline.d.ts.map +1 -1
  171. package/dist/commands/release/apply.pipeline.js +4 -347
  172. package/dist/commands/release/apply.preflight.d.ts +9 -6
  173. package/dist/commands/release/apply.preflight.d.ts.map +1 -1
  174. package/dist/commands/release/apply.preflight.js +71 -51
  175. package/dist/commands/runtime.command.d.ts +2 -2
  176. package/dist/commands/runtime.command.d.ts.map +1 -1
  177. package/dist/commands/runtime.command.js +2 -2
  178. package/dist/commands/scenario/impl/commands.d.ts.map +1 -1
  179. package/dist/commands/scenario/impl/commands.js +52 -39
  180. package/dist/commands/scenario/impl/report.d.ts.map +1 -1
  181. package/dist/commands/scenario/impl/report.js +4 -7
  182. package/dist/commands/shared/allow-prefix-policy.d.ts.map +1 -0
  183. package/dist/{shared → commands/shared}/allow-prefix-policy.js +1 -1
  184. package/dist/commands/shared/comment-format.d.ts.map +1 -0
  185. package/dist/commands/shared/diagnostics.d.ts.map +1 -0
  186. package/dist/commands/shared/git-context.d.ts +1 -27
  187. package/dist/commands/shared/git-context.d.ts.map +1 -1
  188. package/dist/commands/shared/git-context.js +1 -156
  189. package/dist/commands/shared/git-diff.d.ts +1 -10
  190. package/dist/commands/shared/git-diff.d.ts.map +1 -1
  191. package/dist/commands/shared/git-diff.js +1 -49
  192. package/dist/commands/shared/git-ops.d.ts +1 -14
  193. package/dist/commands/shared/git-ops.d.ts.map +1 -1
  194. package/dist/commands/shared/git-ops.js +20 -150
  195. package/dist/commands/shared/git-worktree.d.ts +1 -9
  196. package/dist/commands/shared/git-worktree.d.ts.map +1 -1
  197. package/dist/commands/shared/git-worktree.js +1 -68
  198. package/dist/commands/shared/git.d.ts +1 -3
  199. package/dist/commands/shared/git.d.ts.map +1 -1
  200. package/dist/commands/shared/git.js +1 -14
  201. package/dist/commands/shared/policy-deny.d.ts +1 -1
  202. package/dist/commands/shared/reconcile-check.js +1 -1
  203. package/dist/commands/shared/task-backend.d.ts.map +1 -1
  204. package/dist/commands/shared/task-backend.js +24 -2
  205. package/dist/commands/shared/task-store/intents.d.ts.map +1 -1
  206. package/dist/commands/shared/task-store/intents.js +1 -1
  207. package/dist/commands/start.spec.js +1 -1
  208. package/dist/commands/task/close-tail-state.d.ts +7 -0
  209. package/dist/commands/task/close-tail-state.d.ts.map +1 -0
  210. package/dist/commands/task/close-tail-state.js +18 -0
  211. package/dist/commands/task/derive.js +1 -1
  212. package/dist/commands/task/finish-close.d.ts +22 -0
  213. package/dist/commands/task/finish-close.d.ts.map +1 -0
  214. package/dist/commands/task/finish-close.js +119 -0
  215. package/dist/commands/task/finish-command.d.ts +3 -0
  216. package/dist/commands/task/finish-command.d.ts.map +1 -0
  217. package/dist/commands/task/finish-command.js +56 -0
  218. package/dist/commands/task/finish-execute.d.ts +8 -0
  219. package/dist/commands/task/finish-execute.d.ts.map +1 -0
  220. package/dist/commands/task/finish-execute.js +272 -0
  221. package/dist/commands/task/finish-findings.d.ts +20 -0
  222. package/dist/commands/task/finish-findings.d.ts.map +1 -0
  223. package/dist/commands/task/finish-findings.js +27 -0
  224. package/dist/commands/task/finish-plan.d.ts +7 -0
  225. package/dist/commands/task/finish-plan.d.ts.map +1 -0
  226. package/dist/commands/task/finish-plan.js +157 -0
  227. package/dist/commands/task/finish-types.d.ts +69 -0
  228. package/dist/commands/task/finish-types.d.ts.map +1 -0
  229. package/dist/commands/task/finish.d.ts +1 -42
  230. package/dist/commands/task/finish.d.ts.map +1 -1
  231. package/dist/commands/task/finish.js +1 -527
  232. package/dist/commands/task/hosted-close-pr.command.d.ts.map +1 -1
  233. package/dist/commands/task/hosted-close-pr.command.js +29 -4
  234. package/dist/commands/task/hosted-merge-sync/builders.d.ts +35 -0
  235. package/dist/commands/task/hosted-merge-sync/builders.d.ts.map +1 -0
  236. package/dist/commands/task/hosted-merge-sync/builders.js +148 -0
  237. package/dist/commands/task/hosted-merge-sync/github.d.ts +10 -0
  238. package/dist/commands/task/hosted-merge-sync/github.d.ts.map +1 -0
  239. package/dist/commands/task/hosted-merge-sync/github.js +113 -0
  240. package/dist/commands/task/hosted-merge-sync/local-branch.d.ts +12 -0
  241. package/dist/commands/task/hosted-merge-sync/local-branch.d.ts.map +1 -0
  242. package/dist/commands/task/hosted-merge-sync/local-branch.js +143 -0
  243. package/dist/commands/task/hosted-merge-sync/model.d.ts +47 -0
  244. package/dist/commands/task/hosted-merge-sync/model.d.ts.map +1 -0
  245. package/dist/commands/task/hosted-merge-sync/pr-meta.d.ts +12 -0
  246. package/dist/commands/task/hosted-merge-sync/pr-meta.d.ts.map +1 -0
  247. package/dist/commands/task/hosted-merge-sync/pr-meta.js +26 -0
  248. package/dist/commands/task/hosted-merge-sync.d.ts +5 -63
  249. package/dist/commands/task/hosted-merge-sync.d.ts.map +1 -1
  250. package/dist/commands/task/hosted-merge-sync.js +10 -444
  251. package/dist/commands/task/new.js +1 -1
  252. package/dist/commands/task/set-status.command.js +1 -1
  253. package/dist/commands/task/shared/direct-work-lock.d.ts.map +1 -0
  254. package/dist/commands/task/shared/git-log.d.ts.map +1 -0
  255. package/dist/commands/task/shared/transitions.d.ts +1 -1
  256. package/dist/commands/task/shared/transitions.d.ts.map +1 -1
  257. package/dist/commands/task/shared/transitions.js +4 -6
  258. package/dist/commands/upgrade/apply.js +1 -1
  259. package/dist/commands/workflow-playbook.command.d.ts.map +1 -1
  260. package/dist/commands/workflow-playbook.command.js +8 -7
  261. package/dist/harness/hooks-lifecycle.d.ts.map +1 -1
  262. package/dist/harness/hooks-lifecycle.js +11 -7
  263. package/dist/meta/release.d.ts.map +1 -1
  264. package/dist/meta/release.js +8 -4
  265. package/dist/policy/engine.d.ts +1 -1
  266. package/dist/policy/evaluate.d.ts +1 -1
  267. package/dist/policy/{types.d.ts → model.d.ts} +1 -1
  268. package/dist/policy/{types.d.ts.map → model.d.ts.map} +1 -1
  269. package/dist/policy/result.d.ts +1 -1
  270. package/dist/policy/rules/allowlist.d.ts +1 -1
  271. package/dist/policy/rules/branch-pr-base.d.ts +1 -1
  272. package/dist/policy/rules/clean-tree.d.ts +1 -1
  273. package/dist/policy/rules/commit-subject.d.ts +1 -1
  274. package/dist/policy/rules/protected-paths.d.ts +1 -1
  275. package/dist/runner/adapters/base.d.ts +42 -0
  276. package/dist/runner/adapters/base.d.ts.map +1 -0
  277. package/dist/runner/adapters/base.js +107 -0
  278. package/dist/runner/adapters/codex-preparation.d.ts +7 -0
  279. package/dist/runner/adapters/codex-preparation.d.ts.map +1 -0
  280. package/dist/runner/adapters/codex-preparation.js +86 -0
  281. package/dist/runner/adapters/codex.d.ts.map +1 -1
  282. package/dist/runner/adapters/codex.js +30 -175
  283. package/dist/runner/adapters/custom-preparation.d.ts +9 -0
  284. package/dist/runner/adapters/custom-preparation.d.ts.map +1 -0
  285. package/dist/runner/adapters/custom-preparation.js +191 -0
  286. package/dist/runner/adapters/custom.d.ts.map +1 -1
  287. package/dist/runner/adapters/custom.js +26 -279
  288. package/dist/runner/process-supervision/run.d.ts +30 -0
  289. package/dist/runner/process-supervision/run.d.ts.map +1 -0
  290. package/dist/runner/process-supervision/run.js +349 -0
  291. package/dist/runner/process-supervision/signals.d.ts +16 -0
  292. package/dist/runner/process-supervision/signals.d.ts.map +1 -0
  293. package/dist/runner/process-supervision/signals.js +85 -0
  294. package/dist/runner/process-supervision/state.d.ts +10 -0
  295. package/dist/runner/process-supervision/state.d.ts.map +1 -0
  296. package/dist/runner/process-supervision/state.js +42 -0
  297. package/dist/runner/process-supervision/streams.d.ts +6 -0
  298. package/dist/runner/process-supervision/streams.d.ts.map +1 -0
  299. package/dist/runner/process-supervision/streams.js +23 -0
  300. package/dist/runner/process-supervision.d.ts +5 -47
  301. package/dist/runner/process-supervision.d.ts.map +1 -1
  302. package/dist/runner/process-supervision.js +3 -490
  303. package/dist/runner/usecases/scenario-materialize-task.js +1 -1
  304. package/dist/runtime/approvals/index.d.ts +1 -1
  305. package/dist/runtime/approvals/{types.d.ts → model.d.ts} +1 -1
  306. package/dist/runtime/approvals/{types.d.ts.map → model.d.ts.map} +1 -1
  307. package/dist/runtime/approvals/runtime.d.ts +1 -1
  308. package/dist/runtime/behavior/index.d.ts +1 -1
  309. package/dist/runtime/behavior/{types.d.ts → model.d.ts} +1 -1
  310. package/dist/runtime/behavior/{types.d.ts.map → model.d.ts.map} +1 -1
  311. package/dist/runtime/behavior/resolve.d.ts +1 -1
  312. package/dist/runtime/capabilities/backend.d.ts +1 -1
  313. package/dist/runtime/capabilities/index.d.ts +1 -1
  314. package/dist/runtime/capabilities/{types.d.ts → model.d.ts} +1 -1
  315. package/dist/runtime/capabilities/{types.d.ts.map → model.d.ts.map} +1 -1
  316. package/dist/runtime/capabilities/model.js +1 -0
  317. package/dist/runtime/capabilities/recipe.d.ts +1 -1
  318. package/dist/runtime/capabilities/registry.d.ts +1 -1
  319. package/dist/runtime/capabilities/runner.d.ts +1 -1
  320. package/dist/runtime/execution-context.d.ts.map +1 -1
  321. package/dist/runtime/execution-context.js +16 -0
  322. package/dist/runtime/execution-profile/index.d.ts +1 -1
  323. package/dist/runtime/execution-profile/{types.d.ts → model.d.ts} +1 -1
  324. package/dist/runtime/execution-profile/{types.d.ts.map → model.d.ts.map} +1 -1
  325. package/dist/runtime/execution-profile/model.js +1 -0
  326. package/dist/runtime/execution-profile/resolve.d.ts +1 -1
  327. package/dist/runtime/explain/index.d.ts +1 -1
  328. package/dist/runtime/explain/{types.d.ts → model.d.ts} +1 -1
  329. package/dist/runtime/explain/{types.d.ts.map → model.d.ts.map} +1 -1
  330. package/dist/runtime/explain/model.js +1 -0
  331. package/dist/runtime/explain/resolve.d.ts +1 -1
  332. package/dist/runtime/protocol/index.d.ts +1 -1
  333. package/dist/runtime/protocol/index.js +1 -1
  334. package/dist/runtime/protocol/{types.d.ts → model.d.ts} +1 -1
  335. package/dist/runtime/protocol/{types.d.ts.map → model.d.ts.map} +1 -1
  336. package/dist/runtime/protocol/resolve.d.ts +1 -1
  337. package/dist/runtime/protocol/resolve.js +1 -1
  338. package/dist/runtime/shared/repo-cli-version.d.ts.map +1 -0
  339. package/dist/{shared → runtime/shared}/repo-cli-version.js +1 -1
  340. package/dist/runtime/shared/runtime-artifacts.d.ts.map +1 -0
  341. package/dist/{shared → runtime/shared}/runtime-source.d.ts +1 -1
  342. package/dist/runtime/shared/runtime-source.d.ts.map +1 -0
  343. package/dist/{shared → runtime/shared}/runtime-source.js +1 -1
  344. package/dist/runtime/shared/version-compare.d.ts.map +1 -0
  345. package/dist/runtime/task-intake/resolve.js +1 -1
  346. package/dist/shared/errors.d.ts +52 -2
  347. package/dist/shared/errors.d.ts.map +1 -1
  348. package/dist/shared/errors.js +66 -4
  349. package/dist/shared/trace-events.d.ts +13 -0
  350. package/dist/shared/trace-events.d.ts.map +1 -0
  351. package/dist/shared/trace-events.js +17 -0
  352. package/dist/{shared/task-doc-conflicts.d.ts → task-doc/conflicts.d.ts} +1 -1
  353. package/dist/task-doc/conflicts.d.ts.map +1 -0
  354. package/dist/{shared/task-doc-conflicts.js → task-doc/conflicts.js} +1 -1
  355. package/dist/{shared/task-doc-state.d.ts → task-doc/state.d.ts} +1 -1
  356. package/dist/task-doc/state.d.ts.map +1 -0
  357. package/package.json +8 -8
  358. package/dist/cli/run-cli/error-guidance.d.ts +0 -9
  359. package/dist/cli/run-cli/error-guidance.d.ts.map +0 -1
  360. package/dist/cli/run-cli/error-guidance.js +0 -210
  361. package/dist/cli/run-cli.test-helpers.d.ts +0 -2
  362. package/dist/cli/run-cli.test-helpers.d.ts.map +0 -1
  363. package/dist/cli/run-cli.test-helpers.js +0 -1
  364. package/dist/commands/recipes.test-helpers.d.ts +0 -202
  365. package/dist/commands/recipes.test-helpers.d.ts.map +0 -1
  366. package/dist/commands/recipes.test-helpers.js +0 -483
  367. package/dist/commands/release.test-helpers.d.ts +0 -38
  368. package/dist/commands/release.test-helpers.d.ts.map +0 -1
  369. package/dist/commands/release.test-helpers.js +0 -55
  370. package/dist/commands/task.test-helpers.d.ts +0 -13
  371. package/dist/commands/task.test-helpers.d.ts.map +0 -1
  372. package/dist/commands/task.test-helpers.js +0 -65
  373. package/dist/runner/test-helpers.d.ts +0 -30
  374. package/dist/runner/test-helpers.d.ts.map +0 -1
  375. package/dist/runner/test-helpers.js +0 -97
  376. package/dist/shared/agent-emoji.d.ts +0 -5
  377. package/dist/shared/agent-emoji.d.ts.map +0 -1
  378. package/dist/shared/agent-emoji.js +0 -51
  379. package/dist/shared/allow-prefix-policy.d.ts.map +0 -1
  380. package/dist/shared/comment-format.d.ts.map +0 -1
  381. package/dist/shared/diagnostics.d.ts.map +0 -1
  382. package/dist/shared/direct-work-lock.d.ts.map +0 -1
  383. package/dist/shared/git-log.d.ts.map +0 -1
  384. package/dist/shared/repo-cli-version.d.ts.map +0 -1
  385. package/dist/shared/runtime-artifacts.d.ts.map +0 -1
  386. package/dist/shared/runtime-source.d.ts.map +0 -1
  387. package/dist/shared/task-doc-conflicts.d.ts.map +0 -1
  388. package/dist/shared/task-doc-state.d.ts.map +0 -1
  389. package/dist/shared/version-compare.d.ts.map +0 -1
  390. package/dist/testing/cli-harness/recipe-archives.d.ts +0 -28
  391. package/dist/testing/cli-harness/recipe-archives.d.ts.map +0 -1
  392. package/dist/testing/cli-harness/recipe-archives.js +0 -374
  393. package/dist/testing/cli-harness/stdio.d.ts +0 -26
  394. package/dist/testing/cli-harness/stdio.d.ts.map +0 -1
  395. package/dist/testing/cli-harness/stdio.js +0 -84
  396. package/dist/testing/cli-harness.d.ts +0 -25
  397. package/dist/testing/cli-harness.d.ts.map +0 -1
  398. package/dist/testing/cli-harness.js +0 -313
  399. package/dist/testing/index.d.ts +0 -2
  400. package/dist/testing/index.d.ts.map +0 -1
  401. package/dist/testing/index.js +0 -1
  402. /package/dist/{policy/types.js → cli/run-cli/commands/init/model.js} +0 -0
  403. /package/dist/{shared → commands/shared}/allow-prefix-policy.d.ts +0 -0
  404. /package/dist/{shared → commands/shared}/comment-format.d.ts +0 -0
  405. /package/dist/{shared → commands/shared}/comment-format.js +0 -0
  406. /package/dist/{shared → commands/shared}/diagnostics.d.ts +0 -0
  407. /package/dist/{shared → commands/shared}/diagnostics.js +0 -0
  408. /package/dist/{runtime/approvals/types.js → commands/task/finish-types.js} +0 -0
  409. /package/dist/{runtime/behavior/types.js → commands/task/hosted-merge-sync/model.js} +0 -0
  410. /package/dist/{shared → commands/task/shared}/direct-work-lock.d.ts +0 -0
  411. /package/dist/{shared → commands/task/shared}/direct-work-lock.js +0 -0
  412. /package/dist/{shared → commands/task/shared}/git-log.d.ts +0 -0
  413. /package/dist/{shared → commands/task/shared}/git-log.js +0 -0
  414. /package/dist/{runtime/capabilities/types.js → policy/model.js} +0 -0
  415. /package/dist/runtime/{execution-profile/types.js → approvals/model.js} +0 -0
  416. /package/dist/runtime/{explain/types.js → behavior/model.js} +0 -0
  417. /package/dist/runtime/protocol/{types.js → model.js} +0 -0
  418. /package/dist/{shared → runtime/shared}/repo-cli-version.d.ts +0 -0
  419. /package/dist/{shared → runtime/shared}/runtime-artifacts.d.ts +0 -0
  420. /package/dist/{shared → runtime/shared}/runtime-artifacts.js +0 -0
  421. /package/dist/{shared → runtime/shared}/version-compare.d.ts +0 -0
  422. /package/dist/{shared → runtime/shared}/version-compare.js +0 -0
  423. /package/dist/{shared/task-doc-state.js → task-doc/state.js} +0 -0
@@ -0,0 +1,349 @@
1
+ import { appendFileSync } from "node:fs";
2
+ import { startProcess } from "@agentplaneorg/core";
3
+ import { appendRunnerEvent, evolveRunnerRunState, readRunnerRunState, writeRunnerRunState, } from "../artifacts.js";
4
+ import { finalizeTraceArtifact, redactTraceText } from "../trace-artifacts.js";
5
+ import { createRunnerTraceEvent, serializeRunnerTraceEvent } from "../trace.js";
6
+ import { isProcessAlive, normalizeSignal } from "./signals.js";
7
+ import { buildInvocationEventData, mergeSupervisionState, renderInvocationCommand, } from "./state.js";
8
+ import { appendTail, splitCompletedLines } from "./streams.js";
9
+ export async function runSupervisedProcess(opts) {
10
+ return await new Promise((resolve, reject) => {
11
+ const [command, ...args] = opts.invocation.argv;
12
+ if (!command) {
13
+ reject(new Error("Runner invocation is missing the executable command"));
14
+ return;
15
+ }
16
+ const child = startProcess({
17
+ command,
18
+ args,
19
+ cwd: opts.invocation.run_dir,
20
+ env: { ...process.env, ...opts.invocation.env },
21
+ stdin: "pipe",
22
+ stdout: "pipe",
23
+ stderr: "pipe",
24
+ });
25
+ const pid = typeof child.pid === "number" ? child.pid : null;
26
+ const started_at = new Date().toISOString();
27
+ let heartbeat_at = started_at;
28
+ let stdout_tail = "";
29
+ let stderr_tail = "";
30
+ let stdout_bytes = 0;
31
+ let stderr_bytes = 0;
32
+ let stdout_buffer = "";
33
+ let stderr_buffer = "";
34
+ let trace_seq = 0;
35
+ let settled = false;
36
+ const tracePolicy = opts.invocation.trace_policy;
37
+ const timeoutPolicy = opts.invocation.timeout_policy;
38
+ const traceMode = tracePolicy.mode;
39
+ const captureStderr = tracePolicy.capture_stderr;
40
+ const maxTailBytes = tracePolicy.max_tail_bytes;
41
+ const redactPatterns = tracePolicy.redact_patterns ?? [];
42
+ let timeoutReason = null;
43
+ let timeoutRequestedAt = null;
44
+ let terminateSentAt = null;
45
+ let killSentAt = null;
46
+ let idleTimer = null;
47
+ let wallTimer = null;
48
+ let killTimer = null;
49
+ const queueAppend = (kind, text) => {
50
+ if (kind === "trace" && traceMode !== "raw")
51
+ return;
52
+ if (kind === "stderr" && !captureStderr)
53
+ return;
54
+ const path = kind === "trace" ? opts.invocation.trace_path : opts.invocation.stderr_path;
55
+ try {
56
+ appendFileSync(path, text, "utf8");
57
+ }
58
+ catch (err) {
59
+ finishWithError(err);
60
+ }
61
+ };
62
+ const writeTraceLine = (stream, raw) => {
63
+ trace_seq += 1;
64
+ queueAppend("trace", serializeRunnerTraceEvent(createRunnerTraceEvent({
65
+ ts: new Date().toISOString(),
66
+ seq: trace_seq,
67
+ stream,
68
+ adapter_id: opts.invocation.adapter_id,
69
+ raw,
70
+ })));
71
+ };
72
+ const flushTraceBuffer = (buffer, stream) => {
73
+ const { lines, remainder } = splitCompletedLines(buffer);
74
+ for (const line of lines) {
75
+ writeTraceLine(stream, line);
76
+ }
77
+ return remainder;
78
+ };
79
+ const clearTimers = () => {
80
+ if (idleTimer)
81
+ clearTimeout(idleTimer);
82
+ if (wallTimer)
83
+ clearTimeout(wallTimer);
84
+ if (killTimer)
85
+ clearTimeout(killTimer);
86
+ idleTimer = null;
87
+ wallTimer = null;
88
+ killTimer = null;
89
+ };
90
+ const patchRunningSupervision = async (patch) => {
91
+ const currentState = await readRunnerRunState(opts.invocation.state_path);
92
+ if (!currentState)
93
+ return;
94
+ await writeRunnerRunState({
95
+ state_path: opts.invocation.state_path,
96
+ state: evolveRunnerRunState({
97
+ state: currentState,
98
+ status: currentState.status,
99
+ updated_at: new Date().toISOString(),
100
+ supervision: mergeSupervisionState(currentState.supervision, patch),
101
+ }),
102
+ });
103
+ };
104
+ const requestTimeout = (reason) => {
105
+ if (settled || timeoutReason)
106
+ return;
107
+ timeoutReason = reason;
108
+ timeoutRequestedAt = new Date().toISOString();
109
+ terminateSentAt = timeoutRequestedAt;
110
+ void patchRunningSupervision({
111
+ timeout_reason: reason,
112
+ timeout_requested_at: timeoutRequestedAt,
113
+ terminate_sent_at: terminateSentAt,
114
+ heartbeat_at: timeoutRequestedAt,
115
+ }).catch(finishWithError);
116
+ void appendRunnerEvent({
117
+ events_path: opts.invocation.events_path,
118
+ event: {
119
+ at: timeoutRequestedAt,
120
+ type: "runner_timeout_requested",
121
+ message: `runner timeout requested (${reason})`,
122
+ data: {
123
+ reason,
124
+ pid,
125
+ timeout_policy: timeoutPolicy,
126
+ },
127
+ },
128
+ }).catch(finishWithError);
129
+ if (pid && isProcessAlive(pid)) {
130
+ try {
131
+ process.kill(pid, "SIGTERM");
132
+ }
133
+ catch (err) {
134
+ const code = err?.code;
135
+ if (code !== "ESRCH") {
136
+ finishWithError(err);
137
+ return;
138
+ }
139
+ }
140
+ }
141
+ const graceMs = timeoutPolicy.terminate_grace_ms;
142
+ if (graceMs <= 0) {
143
+ killSentAt = new Date().toISOString();
144
+ void patchRunningSupervision({
145
+ timeout_reason: reason,
146
+ timeout_requested_at: timeoutRequestedAt,
147
+ terminate_sent_at: terminateSentAt,
148
+ kill_sent_at: killSentAt,
149
+ force_killed: true,
150
+ heartbeat_at: killSentAt,
151
+ }).catch(finishWithError);
152
+ if (pid && isProcessAlive(pid)) {
153
+ try {
154
+ process.kill(pid, "SIGKILL");
155
+ }
156
+ catch (err) {
157
+ const code = err?.code;
158
+ if (code !== "ESRCH") {
159
+ finishWithError(err);
160
+ }
161
+ }
162
+ }
163
+ return;
164
+ }
165
+ killTimer = setTimeout(() => {
166
+ if (settled || !timeoutReason)
167
+ return;
168
+ killSentAt = new Date().toISOString();
169
+ void patchRunningSupervision({
170
+ timeout_reason: timeoutReason,
171
+ timeout_requested_at: timeoutRequestedAt,
172
+ terminate_sent_at: terminateSentAt,
173
+ kill_sent_at: killSentAt,
174
+ force_killed: true,
175
+ heartbeat_at: killSentAt,
176
+ }).catch(finishWithError);
177
+ void appendRunnerEvent({
178
+ events_path: opts.invocation.events_path,
179
+ event: {
180
+ at: killSentAt,
181
+ type: "runner_timeout_force_kill",
182
+ message: `runner force-killed after timeout (${timeoutReason})`,
183
+ data: {
184
+ reason: timeoutReason,
185
+ pid,
186
+ timeout_policy: timeoutPolicy,
187
+ },
188
+ },
189
+ }).catch(finishWithError);
190
+ if (pid && isProcessAlive(pid)) {
191
+ try {
192
+ process.kill(pid, "SIGKILL");
193
+ }
194
+ catch (err) {
195
+ const code = err?.code;
196
+ if (code !== "ESRCH") {
197
+ finishWithError(err);
198
+ }
199
+ }
200
+ }
201
+ }, graceMs);
202
+ };
203
+ const resetIdleTimer = () => {
204
+ if (timeoutPolicy.idle_ms <= 0 || settled || timeoutReason)
205
+ return;
206
+ if (idleTimer)
207
+ clearTimeout(idleTimer);
208
+ idleTimer = setTimeout(() => {
209
+ requestTimeout("idle");
210
+ }, timeoutPolicy.idle_ms);
211
+ };
212
+ const updateRunningState = async () => {
213
+ const initialState = await readRunnerRunState(opts.invocation.state_path);
214
+ if (!initialState)
215
+ return;
216
+ const supervision = mergeSupervisionState(initialState.supervision, {
217
+ pid,
218
+ command: renderInvocationCommand(opts.invocation),
219
+ started_at,
220
+ heartbeat_at,
221
+ exit_signal: null,
222
+ timeout_reason: null,
223
+ });
224
+ await writeRunnerRunState({
225
+ state_path: opts.invocation.state_path,
226
+ state: evolveRunnerRunState({
227
+ state: initialState,
228
+ status: "running",
229
+ updated_at: started_at,
230
+ supervision,
231
+ }),
232
+ });
233
+ await appendRunnerEvent({
234
+ events_path: opts.invocation.events_path,
235
+ event: {
236
+ at: started_at,
237
+ type: "runner_execute_start",
238
+ message: opts.start_message,
239
+ data: buildInvocationEventData(opts.invocation, pid),
240
+ },
241
+ });
242
+ };
243
+ const finishWithError = (err) => {
244
+ if (settled)
245
+ return;
246
+ clearTimers();
247
+ settled = true;
248
+ reject(err instanceof Error ? err : new Error(String(err)));
249
+ };
250
+ void updateRunningState().catch((err) => {
251
+ if (pid && isProcessAlive(pid)) {
252
+ try {
253
+ process.kill(pid, "SIGKILL");
254
+ }
255
+ catch {
256
+ // best effort
257
+ }
258
+ }
259
+ finishWithError(err);
260
+ });
261
+ child.stdout?.on("data", (chunk) => {
262
+ const text = chunk.toString();
263
+ const persistedText = redactTraceText(text, redactPatterns);
264
+ heartbeat_at = new Date().toISOString();
265
+ resetIdleTimer();
266
+ stdout_bytes += Buffer.byteLength(text, "utf8");
267
+ stdout_tail = appendTail(stdout_tail, persistedText, maxTailBytes);
268
+ stdout_buffer = flushTraceBuffer(`${stdout_buffer}${persistedText}`, "stdout");
269
+ });
270
+ child.stderr?.on("data", (chunk) => {
271
+ const text = chunk.toString();
272
+ const persistedText = redactTraceText(text, redactPatterns);
273
+ heartbeat_at = new Date().toISOString();
274
+ resetIdleTimer();
275
+ stderr_bytes += Buffer.byteLength(text, "utf8");
276
+ stderr_tail = appendTail(stderr_tail, persistedText, maxTailBytes);
277
+ stderr_buffer = flushTraceBuffer(`${stderr_buffer}${persistedText}`, "stderr");
278
+ queueAppend("stderr", persistedText);
279
+ });
280
+ void child.on("error", finishWithError);
281
+ void child.on("close", async (code, signal) => {
282
+ if (settled)
283
+ return;
284
+ clearTimers();
285
+ const ended_at = new Date().toISOString();
286
+ if (stdout_buffer) {
287
+ writeTraceLine("stdout", stdout_buffer);
288
+ }
289
+ if (stderr_buffer) {
290
+ writeTraceLine("stderr", stderr_buffer);
291
+ }
292
+ if (settled)
293
+ return;
294
+ const normalizedSignal = normalizeSignal(signal);
295
+ const currentState = await readRunnerRunState(opts.invocation.state_path);
296
+ const supervision = currentState?.supervision;
297
+ const runStatus = supervision?.cancel_requested_at
298
+ ? "cancelled"
299
+ : timeoutReason
300
+ ? "failed"
301
+ : code === 0
302
+ ? "success"
303
+ : "failed";
304
+ const [traceArtifact, stderrArtifact] = await Promise.all([
305
+ finalizeTraceArtifact({
306
+ file_path: opts.invocation.trace_path,
307
+ policy: tracePolicy,
308
+ run_status: runStatus,
309
+ }),
310
+ finalizeTraceArtifact({
311
+ file_path: opts.invocation.stderr_path,
312
+ policy: tracePolicy,
313
+ run_status: runStatus,
314
+ }),
315
+ ]);
316
+ settled = true;
317
+ resolve({
318
+ exit_code: code,
319
+ exit_signal: normalizedSignal,
320
+ stdout_tail,
321
+ stderr_tail,
322
+ stdout_bytes,
323
+ stderr_bytes,
324
+ pid,
325
+ started_at,
326
+ ended_at,
327
+ cancel_requested_at: supervision?.cancel_requested_at ?? null,
328
+ cancel_signal: supervision?.cancel_signal ?? null,
329
+ timeout_reason: supervision?.timeout_reason ?? timeoutReason,
330
+ timeout_requested_at: supervision?.timeout_requested_at ?? timeoutRequestedAt,
331
+ terminate_sent_at: supervision?.terminate_sent_at ?? terminateSentAt,
332
+ kill_sent_at: supervision?.kill_sent_at ?? killSentAt,
333
+ force_killed: supervision?.force_killed === true || killSentAt !== null,
334
+ heartbeat_at: heartbeat_at || ended_at,
335
+ trace_artifact_path: traceArtifact.artifact_path,
336
+ trace_archive_path: traceArtifact.archive_path,
337
+ stderr_artifact_path: stderrArtifact.artifact_path,
338
+ stderr_archive_path: stderrArtifact.archive_path,
339
+ });
340
+ });
341
+ if (timeoutPolicy.wall_clock_ms > 0) {
342
+ wallTimer = setTimeout(() => {
343
+ requestTimeout("wall_clock");
344
+ }, timeoutPolicy.wall_clock_ms);
345
+ }
346
+ resetIdleTimer();
347
+ child.stdin?.end(opts.stdin_text);
348
+ });
349
+ }
@@ -0,0 +1,16 @@
1
+ import type { RunnerProcessSignal } from "../types.js";
2
+ export type ObservedProcessIdentity = {
3
+ pid: number;
4
+ command: string | null;
5
+ started_at: string | null;
6
+ };
7
+ export declare function normalizeSignal(signal: NodeJS.Signals | null): RunnerProcessSignal | null;
8
+ export declare function exitCodeForSignal(signal: RunnerProcessSignal | null): number | null;
9
+ export declare function isProcessAlive(pid: number): boolean;
10
+ export declare function readObservedProcessIdentity(pid: number): Promise<ObservedProcessIdentity | null>;
11
+ export declare function waitForProcessExit(opts: {
12
+ pid: number;
13
+ timeout_ms: number;
14
+ poll_ms?: number;
15
+ }): Promise<boolean>;
16
+ //# sourceMappingURL=signals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../../../src/runner/process-supervision/signals.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAUvD,MAAM,MAAM,uBAAuB,GAAG;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC;AAEF,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,GAAG,mBAAmB,GAAG,IAAI,CAKzF;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAOnF;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAUnD;AAED,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CA+BzC;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,OAAO,CAAC,CAQnB"}
@@ -0,0 +1,85 @@
1
+ import { runProcess } from "@agentplaneorg/core";
2
+ const SUPPORTED_SIGNALS = new Set([
3
+ "SIGHUP",
4
+ "SIGINT",
5
+ "SIGQUIT",
6
+ "SIGTERM",
7
+ "SIGKILL",
8
+ ]);
9
+ export function normalizeSignal(signal) {
10
+ if (!signal)
11
+ return null;
12
+ return SUPPORTED_SIGNALS.has(signal)
13
+ ? signal
14
+ : null;
15
+ }
16
+ export function exitCodeForSignal(signal) {
17
+ if (signal === "SIGINT")
18
+ return 130;
19
+ if (signal === "SIGTERM")
20
+ return 143;
21
+ if (signal === "SIGKILL")
22
+ return 137;
23
+ if (signal === "SIGHUP")
24
+ return 129;
25
+ if (signal === "SIGQUIT")
26
+ return 131;
27
+ return null;
28
+ }
29
+ export function isProcessAlive(pid) {
30
+ try {
31
+ process.kill(pid, 0);
32
+ return true;
33
+ }
34
+ catch (err) {
35
+ const code = err?.code;
36
+ if (code === "ESRCH")
37
+ return false;
38
+ if (code === "EPERM")
39
+ return true;
40
+ throw err;
41
+ }
42
+ }
43
+ export async function readObservedProcessIdentity(pid) {
44
+ try {
45
+ const { stdout } = await runProcess({
46
+ command: "ps",
47
+ args: ["-o", "lstart=,command=", "-p", String(pid)],
48
+ encoding: "utf8",
49
+ });
50
+ const line = String(stdout)
51
+ .split("\n")
52
+ .map((entry) => entry.trim())
53
+ .find((entry) => entry.length > 0);
54
+ if (!line)
55
+ return null;
56
+ const match = /^([A-Z][a-z]{2}\s+[A-Z][a-z]{2}\s+\d{1,2}\s+\d\d:\d\d:\d\d\s+\d{4})\s+(.*)$/u.exec(line);
57
+ const startedAtRaw = match?.[1]?.trim() ?? null;
58
+ const command = match?.[2]?.trim() ?? null;
59
+ const parsedStartedAt = startedAtRaw && !Number.isNaN(Date.parse(startedAtRaw))
60
+ ? new Date(startedAtRaw).toISOString()
61
+ : null;
62
+ return {
63
+ pid,
64
+ command,
65
+ started_at: parsedStartedAt,
66
+ };
67
+ }
68
+ catch (err) {
69
+ const errno = err?.code;
70
+ const exitCode = err?.code;
71
+ if (errno === "ESRCH" || exitCode === 1)
72
+ return null;
73
+ throw err;
74
+ }
75
+ }
76
+ export async function waitForProcessExit(opts) {
77
+ const started = Date.now();
78
+ const poll_ms = opts.poll_ms ?? 100;
79
+ while (Date.now() - started < opts.timeout_ms) {
80
+ if (!isProcessAlive(opts.pid))
81
+ return true;
82
+ await new Promise((resolve) => setTimeout(resolve, poll_ms));
83
+ }
84
+ return !isProcessAlive(opts.pid);
85
+ }
@@ -0,0 +1,10 @@
1
+ import type { RunnerInvocation, RunnerRunState, RunnerSupervisionState } from "../types.js";
2
+ export declare function renderInvocationCommand(invocation: RunnerInvocation): string | null;
3
+ export declare function mergeSupervisionState(current: RunnerSupervisionState | undefined, patch: Partial<RunnerSupervisionState>): RunnerSupervisionState;
4
+ export declare function buildInvocationEventData(invocation: RunnerInvocation, pid: number | null): Record<string, unknown>;
5
+ export declare function waitForRunnerStateStop(opts: {
6
+ state_path: string;
7
+ timeout_ms: number;
8
+ poll_ms?: number;
9
+ }): Promise<RunnerRunState | null>;
10
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/runner/process-supervision/state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE5F,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,gBAAgB,GAAG,MAAM,GAAG,IAAI,CAMnF;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,sBAAsB,GAAG,SAAS,EAC3C,KAAK,EAAE,OAAO,CAAC,sBAAsB,CAAC,GACrC,sBAAsB,CAKxB;AAED,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,gBAAgB,EAC5B,GAAG,EAAE,MAAM,GAAG,IAAI,GACjB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAmBzB;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAUjC"}
@@ -0,0 +1,42 @@
1
+ import { readRunnerRunState } from "../artifacts.js";
2
+ export function renderInvocationCommand(invocation) {
3
+ const commandLine = invocation.argv
4
+ .map((part) => part.trim())
5
+ .filter((part) => part.length > 0)
6
+ .join(" ");
7
+ return commandLine.length > 0 ? commandLine : null;
8
+ }
9
+ export function mergeSupervisionState(current, patch) {
10
+ return {
11
+ ...current,
12
+ ...Object.fromEntries(Object.entries(patch).filter(([, value]) => value !== undefined)),
13
+ };
14
+ }
15
+ export function buildInvocationEventData(invocation, pid) {
16
+ return {
17
+ executable: invocation.argv[0] ?? null,
18
+ argv_count: invocation.argv.length,
19
+ cwd: invocation.run_dir,
20
+ env_keys: Object.keys(invocation.env).toSorted(),
21
+ has_bootstrap_path: typeof invocation.bootstrap_path === "string" && invocation.bootstrap_path.trim().length > 0,
22
+ has_output_last_message_path: typeof invocation.output_last_message_path === "string" &&
23
+ invocation.output_last_message_path.trim().length > 0,
24
+ has_trace_path: typeof invocation.trace_path === "string" && invocation.trace_path.trim().length > 0,
25
+ has_stderr_path: typeof invocation.stderr_path === "string" && invocation.stderr_path.trim().length > 0,
26
+ trace_policy: invocation.trace_policy,
27
+ timeout_policy: invocation.timeout_policy,
28
+ pid,
29
+ };
30
+ }
31
+ export async function waitForRunnerStateStop(opts) {
32
+ const started = Date.now();
33
+ const poll_ms = opts.poll_ms ?? 100;
34
+ while (Date.now() - started < opts.timeout_ms) {
35
+ const state = await readRunnerRunState(opts.state_path);
36
+ if (state && state.status !== "running")
37
+ return state;
38
+ await new Promise((resolve) => setTimeout(resolve, poll_ms));
39
+ }
40
+ const state = await readRunnerRunState(opts.state_path);
41
+ return state && state.status !== "running" ? state : null;
42
+ }
@@ -0,0 +1,6 @@
1
+ export declare function appendTail(current: string, incoming: string, maxBytes: number): string;
2
+ export declare function splitCompletedLines(buffer: string): {
3
+ lines: string[];
4
+ remainder: string;
5
+ };
6
+ //# sourceMappingURL=streams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streams.d.ts","sourceRoot":"","sources":["../../../src/runner/process-supervision/streams.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAItF;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAgB1F"}
@@ -0,0 +1,23 @@
1
+ export function appendTail(current, incoming, maxBytes) {
2
+ const combined = Buffer.from(`${current}${incoming}`, "utf8");
3
+ if (combined.length <= maxBytes)
4
+ return combined.toString("utf8");
5
+ return combined.subarray(combined.length - maxBytes).toString("utf8");
6
+ }
7
+ export function splitCompletedLines(buffer) {
8
+ const lines = [];
9
+ let start = 0;
10
+ while (start < buffer.length) {
11
+ const newlineIndex = buffer.indexOf("\n", start);
12
+ if (newlineIndex === -1) {
13
+ return { lines, remainder: buffer.slice(start) };
14
+ }
15
+ let line = buffer.slice(start, newlineIndex);
16
+ if (line.endsWith("\r")) {
17
+ line = line.slice(0, -1);
18
+ }
19
+ lines.push(line);
20
+ start = newlineIndex + 1;
21
+ }
22
+ return { lines, remainder: "" };
23
+ }
@@ -1,48 +1,6 @@
1
- import type { RunnerInvocation, RunnerProcessSignal, RunnerRunState, RunnerTimeoutReason } from "./types.js";
2
- export type SupervisedProcessResult = {
3
- exit_code: number | null;
4
- exit_signal: RunnerProcessSignal | null;
5
- stdout_tail: string;
6
- stderr_tail: string;
7
- stdout_bytes: number;
8
- stderr_bytes: number;
9
- pid: number | null;
10
- started_at: string;
11
- ended_at: string;
12
- cancel_requested_at: string | null;
13
- cancel_signal: RunnerProcessSignal | null;
14
- timeout_reason: RunnerTimeoutReason | null;
15
- timeout_requested_at: string | null;
16
- terminate_sent_at: string | null;
17
- kill_sent_at: string | null;
18
- force_killed: boolean;
19
- heartbeat_at: string;
20
- trace_artifact_path: string | null;
21
- trace_archive_path: string | null;
22
- stderr_artifact_path: string | null;
23
- stderr_archive_path: string | null;
24
- };
25
- export type ObservedProcessIdentity = {
26
- pid: number;
27
- command: string | null;
28
- started_at: string | null;
29
- };
30
- export declare function exitCodeForSignal(signal: RunnerProcessSignal | null): number | null;
31
- export declare function isProcessAlive(pid: number): boolean;
32
- export declare function readObservedProcessIdentity(pid: number): Promise<ObservedProcessIdentity | null>;
33
- export declare function waitForProcessExit(opts: {
34
- pid: number;
35
- timeout_ms: number;
36
- poll_ms?: number;
37
- }): Promise<boolean>;
38
- export declare function runSupervisedProcess(opts: {
39
- invocation: RunnerInvocation;
40
- stdin_text: string;
41
- start_message: string;
42
- }): Promise<SupervisedProcessResult>;
43
- export declare function waitForRunnerStateStop(opts: {
44
- state_path: string;
45
- timeout_ms: number;
46
- poll_ms?: number;
47
- }): Promise<RunnerRunState | null>;
1
+ export type { SupervisedProcessResult } from "./process-supervision/run.js";
2
+ export { runSupervisedProcess } from "./process-supervision/run.js";
3
+ export type { ObservedProcessIdentity } from "./process-supervision/signals.js";
4
+ export { exitCodeForSignal, isProcessAlive, readObservedProcessIdentity, waitForProcessExit, } from "./process-supervision/signals.js";
5
+ export { waitForRunnerStateStop } from "./process-supervision/state.js";
48
6
  //# sourceMappingURL=process-supervision.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"process-supervision.d.ts","sourceRoot":"","sources":["../../src/runner/process-supervision.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EAEd,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAapB,MAAM,MAAM,uBAAuB,GAAG;IACpC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,aAAa,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAC1C,cAAc,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAC3C,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC;AA2EF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAOnF;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAUnD;AAED,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CA6BzC;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,OAAO,CAAC,CAQnB;AAED,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,UAAU,EAAE,gBAAgB,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA+UnC;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAUjC"}
1
+ {"version":3,"file":"process-supervision.d.ts","sourceRoot":"","sources":["../../src/runner/process-supervision.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,YAAY,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAChF,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,2BAA2B,EAC3B,kBAAkB,GACnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC"}