@atolis-hq/wake 0.2.97 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (442) hide show
  1. package/dist/src/activities/agent/agent-activity-definition.js +26 -0
  2. package/dist/src/activities/agent/agent-activity.js +171 -0
  3. package/dist/src/activities/agent/agent-result.js +149 -0
  4. package/dist/src/activities/contracts/activity.js +10 -0
  5. package/dist/src/activities/contracts/config.js +2 -0
  6. package/dist/src/activities/contracts/event-schema.js +302 -0
  7. package/dist/src/activities/contracts/events.js +42 -0
  8. package/dist/src/activities/contracts/identifiers.js +29 -0
  9. package/dist/src/activities/contracts/registry.js +71 -0
  10. package/dist/src/activities/contracts/streams.js +17 -0
  11. package/dist/src/activities/contracts/vocabulary.js +58 -0
  12. package/dist/src/activities/index.js +21 -0
  13. package/dist/src/activities/pr/activity-support.js +111 -0
  14. package/dist/src/activities/pr/application.js +158 -0
  15. package/dist/src/activities/pr/approve.js +85 -0
  16. package/dist/src/activities/pr/capability.js +11 -0
  17. package/dist/src/activities/pr/decision-claim.js +76 -0
  18. package/dist/src/activities/pr/event-drafts.js +66 -0
  19. package/dist/src/activities/pr/intent.js +37 -0
  20. package/dist/src/activities/pr/merge-authority-gate.js +14 -0
  21. package/dist/src/activities/pr/merge.js +110 -0
  22. package/dist/src/activities/pr/policy.js +135 -0
  23. package/dist/src/activities/pr/projection.js +130 -0
  24. package/dist/src/activities/pr/vocabulary.js +30 -0
  25. package/dist/src/activities/review/authorization.js +22 -0
  26. package/dist/src/activities/review/contracts.js +22 -0
  27. package/dist/src/activities/review/signals.js +3 -0
  28. package/dist/src/bootstrap/analytics-projection.js +26 -0
  29. package/dist/src/bootstrap/board-projection.js +337 -0
  30. package/dist/src/bootstrap/composition-root.js +382 -0
  31. package/dist/src/bootstrap/config/load-config.js +51 -0
  32. package/dist/src/bootstrap/config/root-schema.js +134 -0
  33. package/dist/src/bootstrap/external-ref.js +12 -0
  34. package/dist/src/bootstrap/fake-provider-files.js +44 -0
  35. package/dist/src/bootstrap/fake-scenarios.js +22 -0
  36. package/dist/src/bootstrap/index.js +48 -0
  37. package/dist/src/bootstrap/initialise.js +434 -0
  38. package/dist/src/bootstrap/paths.js +15 -0
  39. package/dist/src/bootstrap/projection-runtime.js +27 -0
  40. package/dist/src/bootstrap/runner-quota-reporter.js +21 -0
  41. package/dist/src/bootstrap/runner-registry.js +30 -0
  42. package/dist/src/bootstrap/schedule-checkpoint-store.js +49 -0
  43. package/dist/src/bootstrap/self-update-application.js +195 -0
  44. package/dist/src/bootstrap/self-update-failure-log.js +33 -0
  45. package/dist/src/bootstrap/source-update-port.js +47 -0
  46. package/dist/src/bootstrap/status-publish-activity.js +42 -0
  47. package/dist/src/bootstrap/surface-api-applications.js +325 -0
  48. package/dist/src/bootstrap/surface-api-execution-applications.js +95 -0
  49. package/dist/src/bootstrap/surface-api-metadata.js +12 -0
  50. package/dist/src/bootstrap/surface-api-projection-pages.js +22 -0
  51. package/dist/src/bootstrap/surface-api-run-context.js +5 -0
  52. package/dist/src/bootstrap/surface-api-transcripts.js +57 -0
  53. package/dist/src/bootstrap/surface-api-work-applications.js +199 -0
  54. package/dist/src/bootstrap/surface-applications.js +7 -0
  55. package/dist/src/bootstrap/surface-cli-applications.js +701 -0
  56. package/dist/src/bootstrap/update-ledger.js +61 -0
  57. package/dist/src/bootstrap/update-maintenance-lease.js +176 -0
  58. package/dist/src/{version.js → bootstrap/version.js} +35 -51
  59. package/dist/src/control-plane/application/advance-once.js +184 -0
  60. package/dist/src/control-plane/application/control-plane-projection.js +42 -0
  61. package/dist/src/control-plane/application/control-plane-service.js +42 -0
  62. package/dist/src/control-plane/application/intake-pipeline.js +29 -0
  63. package/dist/src/control-plane/application/runner-control-service.js +66 -0
  64. package/dist/src/control-plane/application/runner-pipeline.js +57 -0
  65. package/dist/src/control-plane/application/schedule-service.js +47 -0
  66. package/dist/src/control-plane/application/work-cancellation-policy.js +31 -0
  67. package/dist/src/control-plane/contracts/commands.js +10 -0
  68. package/dist/src/control-plane/contracts/config.js +22 -0
  69. package/dist/src/control-plane/contracts/events.js +81 -0
  70. package/dist/src/control-plane/contracts/streams.js +5 -0
  71. package/dist/src/control-plane/domain/dispatch-policy.js +15 -0
  72. package/dist/src/control-plane/domain/quota-policy.js +26 -0
  73. package/dist/src/control-plane/domain/runner-quota.js +35 -0
  74. package/dist/src/control-plane/domain/schedule-policy.js +46 -0
  75. package/dist/src/control-plane/index.js +20 -0
  76. package/dist/src/control-plane/infrastructure/intake-host.js +24 -0
  77. package/dist/src/control-plane/infrastructure/resident-host.js +45 -0
  78. package/dist/src/control-plane/infrastructure/tick-host.js +35 -0
  79. package/dist/src/execution/application/activation-claim.js +50 -0
  80. package/dist/src/execution/application/active-run-cancellation.js +14 -0
  81. package/dist/src/execution/application/execution-activity.js +97 -0
  82. package/dist/src/execution/application/execution-projection.js +17 -0
  83. package/dist/src/execution/application/execution-service.js +372 -0
  84. package/dist/src/execution/application/execution-validation.js +26 -0
  85. package/dist/src/execution/application/recovery-service.js +212 -0
  86. package/dist/src/execution/application/run-lifecycle.js +115 -0
  87. package/dist/src/execution/application/run-liveness-service.js +80 -0
  88. package/dist/src/execution/application/run-repository.js +27 -0
  89. package/dist/src/execution/contracts/commands.js +1 -0
  90. package/dist/src/execution/contracts/config.js +35 -0
  91. package/dist/src/execution/contracts/control-plane.js +1 -0
  92. package/dist/src/execution/contracts/event-factory.js +53 -0
  93. package/dist/src/execution/contracts/events.js +274 -0
  94. package/dist/src/execution/contracts/identifiers.js +5 -0
  95. package/dist/src/execution/contracts/liveness.js +1 -0
  96. package/dist/src/execution/contracts/results.js +1 -0
  97. package/dist/src/execution/contracts/runner.js +15 -0
  98. package/dist/src/execution/contracts/streams.js +10 -0
  99. package/dist/src/execution/contracts/views.js +1 -0
  100. package/dist/src/execution/contracts/vocabulary.js +43 -0
  101. package/dist/src/execution/contracts/workspace.js +1 -0
  102. package/dist/src/execution/domain/run-result.js +34 -0
  103. package/dist/src/execution/domain/run.js +142 -0
  104. package/dist/src/execution/index.js +31 -0
  105. package/dist/src/execution/infrastructure/agent-runner-adapter.js +114 -0
  106. package/dist/src/execution/infrastructure/process-execution.js +29 -0
  107. package/dist/src/execution/infrastructure/prompt-templates.js +42 -0
  108. package/dist/src/execution/infrastructure/runners/claude.js +120 -0
  109. package/dist/src/execution/infrastructure/runners/codex.js +143 -0
  110. package/dist/src/execution/infrastructure/runners/command.js +4 -0
  111. package/dist/src/execution/infrastructure/runners/cursor.js +69 -0
  112. package/dist/src/execution/infrastructure/runners/fake-scenarios.js +99 -0
  113. package/dist/src/execution/infrastructure/runners/fake.js +65 -0
  114. package/dist/src/execution/infrastructure/runners/registry.js +26 -0
  115. package/dist/src/execution/infrastructure/transcript-store.js +223 -0
  116. package/dist/src/execution/infrastructure/transcripts.js +11 -0
  117. package/dist/src/execution/infrastructure/workspace/fake-workspace.js +19 -0
  118. package/dist/src/execution/infrastructure/workspace/git-workspace.js +241 -0
  119. package/dist/src/integrations/application/agent-run-publication-reactor.js +111 -0
  120. package/dist/src/integrations/application/artifact-registration-reactor.js +159 -0
  121. package/dist/src/integrations/application/poll-service.js +25 -0
  122. package/dist/src/integrations/application/terminal-agent-run-report.js +40 -0
  123. package/dist/src/integrations/application/work-admission.js +31 -0
  124. package/dist/src/integrations/application/work-conclusion.js +19 -0
  125. package/dist/src/integrations/contracts/artifact-events.js +60 -0
  126. package/dist/src/integrations/contracts/artifact-vocabulary.js +9 -0
  127. package/dist/src/integrations/contracts/config.js +14 -0
  128. package/dist/src/integrations/contracts/identifiers.js +5 -0
  129. package/dist/src/integrations/contracts/intake-rules.js +14 -0
  130. package/dist/src/integrations/contracts/intake.js +1 -0
  131. package/dist/src/integrations/contracts/outcome-vocabulary.js +7 -0
  132. package/dist/src/integrations/contracts/provider.js +37 -0
  133. package/dist/src/integrations/contracts/streams.js +10 -0
  134. package/dist/src/integrations/delivery/application/delivery-outcome-reactor.js +75 -0
  135. package/dist/src/integrations/delivery/application/delivery-projector.js +165 -0
  136. package/dist/src/integrations/delivery/application/delivery-service.js +173 -0
  137. package/dist/src/integrations/delivery/contracts/commands.js +1 -0
  138. package/dist/src/integrations/delivery/contracts/config.js +1 -0
  139. package/dist/src/integrations/delivery/contracts/event-factory.js +18 -0
  140. package/dist/src/integrations/delivery/contracts/events.js +86 -0
  141. package/dist/src/integrations/delivery/contracts/intents.js +89 -0
  142. package/dist/src/integrations/delivery/contracts/views.js +1 -0
  143. package/dist/src/integrations/delivery/contracts/vocabulary.js +22 -0
  144. package/dist/src/integrations/fake/durable-delivery-provider.js +48 -0
  145. package/dist/src/integrations/fake/external-sink.js +9 -0
  146. package/dist/src/integrations/fake/external-source.js +44 -0
  147. package/dist/src/integrations/fake/inbound-translator.js +130 -0
  148. package/dist/src/integrations/fake/provider.js +95 -0
  149. package/dist/src/integrations/github/application/agent-context-reader.js +54 -0
  150. package/dist/src/integrations/github/application/agent-run-comment.js +94 -0
  151. package/dist/src/integrations/github/application/comment-history-reader.js +43 -0
  152. package/dist/src/integrations/github/application/inbound-context.js +10 -0
  153. package/dist/src/integrations/github/application/inbound-review-signals.js +159 -0
  154. package/dist/src/integrations/github/application/inbound-translator.js +231 -0
  155. package/dist/src/integrations/github/application/inbound-watch-gate-signals.js +84 -0
  156. package/dist/src/integrations/github/application/intake-policy.js +23 -0
  157. package/dist/src/integrations/github/application/outbound-translator.js +47 -0
  158. package/dist/src/integrations/github/application/poll-service.js +29 -0
  159. package/dist/src/integrations/github/application/pull-request-translation.js +10 -0
  160. package/dist/src/integrations/github/application/resource-links.js +8 -0
  161. package/dist/src/integrations/github/application/review-command-translator.js +16 -0
  162. package/dist/src/integrations/github/application/wake-labels.js +95 -0
  163. package/dist/src/integrations/github/contracts/config.js +47 -0
  164. package/dist/src/integrations/github/contracts/events.js +127 -0
  165. package/dist/src/integrations/github/contracts/external-key.js +19 -0
  166. package/dist/src/integrations/github/contracts/payloads.js +9 -0
  167. package/dist/src/integrations/github/contracts/vocabulary.js +55 -0
  168. package/dist/src/integrations/github/index.js +31 -0
  169. package/dist/src/integrations/github/infrastructure/client-reads.js +214 -0
  170. package/dist/src/integrations/github/infrastructure/client.js +132 -0
  171. package/dist/src/integrations/github/infrastructure/content-fingerprint.js +10 -0
  172. package/dist/src/integrations/github/infrastructure/delivery.js +31 -0
  173. package/dist/src/integrations/github/infrastructure/etag-cache.js +56 -0
  174. package/dist/src/integrations/github/infrastructure/gh-auth.js +19 -0
  175. package/dist/src/integrations/github/infrastructure/issue-source.js +109 -0
  176. package/dist/src/integrations/github/infrastructure/pr-source.js +186 -0
  177. package/dist/src/integrations/github/infrastructure/review-source.js +70 -0
  178. package/dist/src/integrations/github/infrastructure/source.js +108 -0
  179. package/dist/src/integrations/github/provider.js +96 -0
  180. package/dist/src/integrations/index.js +30 -0
  181. package/dist/src/kernel/contracts/checkpoint-store.js +1 -0
  182. package/dist/src/kernel/contracts/clock.js +1 -0
  183. package/dist/src/kernel/contracts/commands.js +1 -0
  184. package/dist/src/kernel/contracts/event-journal.js +2 -0
  185. package/dist/src/kernel/contracts/event-schema.js +54 -0
  186. package/dist/src/kernel/contracts/events.js +11 -0
  187. package/dist/src/kernel/contracts/id-generator.js +1 -0
  188. package/dist/src/kernel/contracts/identifiers.js +8 -0
  189. package/dist/src/kernel/contracts/projection-store.js +1 -0
  190. package/dist/src/kernel/contracts/relations.js +1 -0
  191. package/dist/src/kernel/contracts/schema.js +17 -0
  192. package/dist/src/kernel/contracts/vocabulary.js +6 -0
  193. package/dist/src/kernel/domain/event-envelope.js +29 -0
  194. package/dist/src/kernel/domain/match-mode.js +11 -0
  195. package/dist/src/kernel/domain/relation.js +10 -0
  196. package/dist/src/kernel/index.js +17 -0
  197. package/dist/src/{lib/clock.js → kernel/infrastructure/system-clock.js} +3 -3
  198. package/dist/src/kernel/infrastructure/ulid-id-generator.js +9 -0
  199. package/dist/src/main.js +137 -1030
  200. package/dist/src/orchestration/application/accept-activity-outcome.js +25 -0
  201. package/dist/src/orchestration/application/accept-signal.js +35 -0
  202. package/dist/src/orchestration/application/advance-workflow.js +160 -0
  203. package/dist/src/orchestration/application/coordination-claims.js +107 -0
  204. package/dist/src/orchestration/application/group-budget-recorder.js +43 -0
  205. package/dist/src/orchestration/application/orchestration-projection.js +20 -0
  206. package/dist/src/orchestration/application/orchestration-repository.js +36 -0
  207. package/dist/src/orchestration/application/orchestration-service.js +82 -0
  208. package/dist/src/orchestration/application/request-child.js +118 -0
  209. package/dist/src/orchestration/application/signal-reactor.js +17 -0
  210. package/dist/src/orchestration/application/start-workflow.js +51 -0
  211. package/dist/src/orchestration/application/watch-reactor.js +82 -0
  212. package/dist/src/orchestration/contracts/activity-outcome.js +18 -0
  213. package/dist/src/orchestration/contracts/commands.js +1 -0
  214. package/dist/src/orchestration/contracts/config.js +128 -0
  215. package/dist/src/orchestration/contracts/event-decoder.js +263 -0
  216. package/dist/src/orchestration/contracts/events.js +41 -0
  217. package/dist/src/orchestration/contracts/identifiers.js +35 -0
  218. package/dist/src/orchestration/contracts/streams.js +38 -0
  219. package/dist/src/orchestration/contracts/views.js +1 -0
  220. package/dist/src/orchestration/contracts/vocabulary.js +30 -0
  221. package/dist/src/orchestration/domain/activation-policy.js +55 -0
  222. package/dist/src/orchestration/domain/approval-defaults.js +17 -0
  223. package/dist/src/orchestration/domain/child-policy.js +63 -0
  224. package/dist/src/orchestration/domain/compiler.js +162 -0
  225. package/dist/src/orchestration/domain/coordination-events.js +25 -0
  226. package/dist/src/orchestration/domain/decision-events.js +47 -0
  227. package/dist/src/orchestration/domain/interpreter.js +49 -0
  228. package/dist/src/orchestration/domain/operator-retry-policy.js +34 -0
  229. package/dist/src/orchestration/domain/retry-policy.js +26 -0
  230. package/dist/src/orchestration/domain/signal-policy.js +120 -0
  231. package/dist/src/orchestration/domain/supplemental-policy.js +61 -0
  232. package/dist/src/orchestration/domain/transition.js +55 -0
  233. package/dist/src/orchestration/domain/workflow-graph.js +41 -0
  234. package/dist/src/orchestration/domain/workflow-instance-events.js +236 -0
  235. package/dist/src/orchestration/domain/workflow-instance.js +41 -0
  236. package/dist/src/orchestration/domain/workflow-selector.js +21 -0
  237. package/dist/src/orchestration/index.js +19 -0
  238. package/dist/src/persistence/application/projection-runner.js +79 -0
  239. package/dist/src/persistence/filesystem/file-checkpoint-store.js +35 -0
  240. package/dist/src/persistence/filesystem/file-event-journal.js +143 -0
  241. package/dist/src/persistence/filesystem/file-lock.js +91 -0
  242. package/dist/src/persistence/filesystem/file-projection-store.js +64 -0
  243. package/dist/src/persistence/index.js +8 -0
  244. package/dist/src/persistence/memory/in-memory-checkpoint-store.js +14 -0
  245. package/dist/src/persistence/memory/in-memory-event-journal.js +88 -0
  246. package/dist/src/persistence/memory/in-memory-projection-store.js +17 -0
  247. package/dist/src/resources/application/lookup-projections.js +48 -0
  248. package/dist/src/resources/application/resource-lookup.js +16 -0
  249. package/dist/src/resources/application/resource-projections.js +81 -0
  250. package/dist/src/resources/application/resource-repository.js +18 -0
  251. package/dist/src/resources/application/resource-service.js +83 -0
  252. package/dist/src/resources/contracts/commands.js +1 -0
  253. package/dist/src/resources/contracts/config.js +2 -0
  254. package/dist/src/resources/contracts/events.js +83 -0
  255. package/dist/src/resources/contracts/identifiers.js +15 -0
  256. package/dist/src/resources/contracts/streams.js +6 -0
  257. package/dist/src/resources/contracts/views.js +1 -0
  258. package/dist/src/resources/contracts/vocabulary.js +67 -0
  259. package/dist/src/resources/domain/correlation.js +8 -0
  260. package/dist/src/resources/domain/resource.js +58 -0
  261. package/dist/src/resources/index.js +14 -0
  262. package/dist/src/surfaces/api/contracts/activities.js +1 -0
  263. package/dist/src/surfaces/api/contracts/board.js +2 -0
  264. package/dist/src/surfaces/api/contracts/common.js +46 -0
  265. package/dist/src/surfaces/api/contracts/control-plane.js +5 -0
  266. package/dist/src/surfaces/api/contracts/events.js +1 -0
  267. package/dist/src/surfaces/api/contracts/execution.js +1 -0
  268. package/dist/src/surfaces/api/contracts/index.js +13 -0
  269. package/dist/src/surfaces/api/contracts/observability.js +1 -0
  270. package/dist/src/surfaces/api/contracts/orchestration.js +1 -0
  271. package/dist/src/surfaces/api/contracts/resources.js +1 -0
  272. package/dist/src/surfaces/api/contracts/status.js +1 -0
  273. package/dist/src/surfaces/api/contracts/system.js +1 -0
  274. package/dist/src/surfaces/api/contracts/transport-values.js +39 -0
  275. package/dist/src/surfaces/api/contracts/work.js +17 -0
  276. package/dist/src/surfaces/api/http-server.js +121 -0
  277. package/dist/src/surfaces/api/presenters/activities.js +1 -0
  278. package/dist/src/surfaces/api/presenters/board.js +3 -0
  279. package/dist/src/surfaces/api/presenters/control-plane.js +1 -0
  280. package/dist/src/surfaces/api/presenters/events.js +1 -0
  281. package/dist/src/surfaces/api/presenters/execution.js +59 -0
  282. package/dist/src/surfaces/api/presenters/observability.js +1 -0
  283. package/dist/src/surfaces/api/presenters/orchestration.js +19 -0
  284. package/dist/src/surfaces/api/presenters/resources.js +15 -0
  285. package/dist/src/surfaces/api/presenters/status.js +3 -0
  286. package/dist/src/surfaces/api/presenters/system.js +14 -0
  287. package/dist/src/surfaces/api/presenters/work.js +16 -0
  288. package/dist/src/surfaces/api/problem-details.js +9 -0
  289. package/dist/src/surfaces/api/router.js +13 -0
  290. package/dist/src/surfaces/api/routes/activities.js +1 -0
  291. package/dist/src/surfaces/api/routes/applications.js +1 -0
  292. package/dist/src/surfaces/api/routes/commands.js +82 -0
  293. package/dist/src/surfaces/api/routes/control-plane.js +6 -0
  294. package/dist/src/surfaces/api/routes/events.js +1 -0
  295. package/dist/src/surfaces/api/routes/execution.js +8 -0
  296. package/dist/src/surfaces/api/routes/index.js +18 -0
  297. package/dist/src/surfaces/api/routes/observability.js +1 -0
  298. package/dist/src/surfaces/api/routes/orchestration.js +1 -0
  299. package/dist/src/surfaces/api/routes/pagination.js +78 -0
  300. package/dist/src/surfaces/api/routes/read.js +135 -0
  301. package/dist/src/surfaces/api/routes/resources.js +1 -0
  302. package/dist/src/surfaces/api/routes/responses.js +67 -0
  303. package/dist/src/surfaces/api/routes/system.js +1 -0
  304. package/dist/src/surfaces/api/routes/work.js +9 -0
  305. package/dist/src/surfaces/cli/commands/api.js +1 -0
  306. package/dist/src/surfaces/cli/commands/audit.js +10 -0
  307. package/dist/src/surfaces/cli/commands/correlate.js +2 -0
  308. package/dist/src/surfaces/cli/commands/doctor.js +6 -0
  309. package/dist/src/surfaces/cli/commands/init.js +39 -0
  310. package/dist/src/surfaces/cli/commands/sandbox-entrypoint.js +33 -0
  311. package/dist/src/surfaces/cli/commands/sandbox-setup.js +29 -0
  312. package/dist/src/surfaces/cli/commands/sandbox.js +105 -0
  313. package/dist/src/surfaces/cli/commands/self-update.js +38 -0
  314. package/dist/src/surfaces/cli/commands/smoke.js +16 -0
  315. package/dist/src/surfaces/cli/commands/start.js +1 -0
  316. package/dist/src/surfaces/cli/commands/stop.js +13 -0
  317. package/dist/src/surfaces/cli/commands/tick.js +1 -0
  318. package/dist/src/surfaces/cli/commands/ui.js +2 -0
  319. package/dist/src/surfaces/cli/commands/validate-state.js +5 -0
  320. package/dist/src/surfaces/cli/infrastructure/docker-cli.js +221 -0
  321. package/dist/src/surfaces/cli/infrastructure/process-log.js +86 -0
  322. package/dist/src/surfaces/cli/main.js +140 -0
  323. package/dist/src/surfaces/cli/usage.js +33 -0
  324. package/dist/src/surfaces/contracts/config.js +34 -0
  325. package/dist/src/surfaces/index.js +47 -0
  326. package/dist/src/surfaces/web-assets/assets/index-Bfn4FwZG.css +1 -0
  327. package/dist/src/surfaces/web-assets/assets/index-ipB6JPGU.js +1090 -0
  328. package/dist/src/surfaces/web-assets/index.html +13 -0
  329. package/dist/src/surfaces/web-host/asset-source.js +1 -0
  330. package/dist/src/surfaces/web-host/packaged-assets.js +44 -0
  331. package/dist/src/work/application/work-projection.js +59 -0
  332. package/dist/src/work/application/work-repository.js +18 -0
  333. package/dist/src/work/application/work-service.js +117 -0
  334. package/dist/src/work/contracts/commands.js +1 -0
  335. package/dist/src/work/contracts/config.js +2 -0
  336. package/dist/src/work/contracts/events.js +103 -0
  337. package/dist/src/work/contracts/identifiers.js +5 -0
  338. package/dist/src/work/contracts/streams.js +6 -0
  339. package/dist/src/work/contracts/views.js +1 -0
  340. package/dist/src/work/contracts/vocabulary.js +6 -0
  341. package/dist/src/work/domain/work-item.js +89 -0
  342. package/dist/src/work/index.js +11 -0
  343. package/docker/Dockerfile +10 -6
  344. package/docker/Dockerfile.packaged +3 -3
  345. package/package.json +29 -4
  346. package/prompts/implement.md +2 -2
  347. package/templates/SETUP.md +7 -7
  348. package/dist/src/adapters/claude/claude-runner.js +0 -529
  349. package/dist/src/adapters/codex/codex-runner.js +0 -503
  350. package/dist/src/adapters/cursor/cursor-runner.js +0 -418
  351. package/dist/src/adapters/docker/docker-cli.js +0 -150
  352. package/dist/src/adapters/fake/fake-artifact-verifier.js +0 -14
  353. package/dist/src/adapters/fake/fake-github-pull-request-activity-source.js +0 -77
  354. package/dist/src/adapters/fake/fake-resource-index.js +0 -21
  355. package/dist/src/adapters/fake/fake-runner.js +0 -77
  356. package/dist/src/adapters/fake/fake-ticketing-system.js +0 -185
  357. package/dist/src/adapters/fake/fake-workspace-manager.js +0 -81
  358. package/dist/src/adapters/fs/resource-index.js +0 -126
  359. package/dist/src/adapters/fs/self-update-ledger.js +0 -17
  360. package/dist/src/adapters/fs/state-store.js +0 -775
  361. package/dist/src/adapters/git/git-workspace-manager.js +0 -289
  362. package/dist/src/adapters/github/github-artifact-verifier.js +0 -38
  363. package/dist/src/adapters/github/github-auth.js +0 -16
  364. package/dist/src/adapters/github/github-client.js +0 -249
  365. package/dist/src/adapters/github/github-etag-cache.js +0 -57
  366. package/dist/src/adapters/github/github-issues-work-source.js +0 -692
  367. package/dist/src/adapters/github/github-pull-request-activity-source.js +0 -584
  368. package/dist/src/adapters/github/github-pull-request-merge-actor.js +0 -45
  369. package/dist/src/adapters/http/ui-assets.js +0 -1188
  370. package/dist/src/adapters/http/ui-data.js +0 -1107
  371. package/dist/src/adapters/http/ui-server.js +0 -458
  372. package/dist/src/adapters/runner/cli-command.js +0 -73
  373. package/dist/src/adapters/runner/prompt-templates.js +0 -76
  374. package/dist/src/adapters/runner/runner-cli-adapter.js +0 -112
  375. package/dist/src/adapters/runner/runner-registry.js +0 -139
  376. package/dist/src/adapters/runner/runtime-events.js +0 -32
  377. package/dist/src/adapters/runner/stage-prompt.js +0 -268
  378. package/dist/src/adapters/runner/transcripts.js +0 -25
  379. package/dist/src/cli/audit-command.js +0 -36
  380. package/dist/src/cli/correlate-command.js +0 -62
  381. package/dist/src/cli/doctor-command.js +0 -48
  382. package/dist/src/cli/init-command.js +0 -18
  383. package/dist/src/cli/sandbox-command.js +0 -258
  384. package/dist/src/cli/sandbox-entrypoint-command.js +0 -88
  385. package/dist/src/cli/sandbox-exec-logging.js +0 -7
  386. package/dist/src/cli/sandbox-resume.js +0 -79
  387. package/dist/src/cli/sandbox-setup-command.js +0 -31
  388. package/dist/src/cli/scaffold-assets.js +0 -100
  389. package/dist/src/cli/self-update-command.js +0 -198
  390. package/dist/src/cli/startup-preflight.js +0 -134
  391. package/dist/src/cli/stop-command.js +0 -46
  392. package/dist/src/cli/ui-command.js +0 -27
  393. package/dist/src/config/defaults.js +0 -10
  394. package/dist/src/config/discover-config-files.js +0 -11
  395. package/dist/src/config/load-config.js +0 -69
  396. package/dist/src/config/split-config.js +0 -14
  397. package/dist/src/core/active-run-recovery.js +0 -44
  398. package/dist/src/core/approval-intents.js +0 -16
  399. package/dist/src/core/audit-events.js +0 -82
  400. package/dist/src/core/control-plane.js +0 -192
  401. package/dist/src/core/event-builders.js +0 -153
  402. package/dist/src/core/event-resolver.js +0 -249
  403. package/dist/src/core/lifecycle-service.js +0 -8
  404. package/dist/src/core/live-execution.js +0 -81
  405. package/dist/src/core/outbox.js +0 -198
  406. package/dist/src/core/policy-engine.js +0 -389
  407. package/dist/src/core/projection-updater.js +0 -693
  408. package/dist/src/core/quota-backoff.js +0 -69
  409. package/dist/src/core/run-lease.js +0 -38
  410. package/dist/src/core/scheduled-workflow-source.js +0 -199
  411. package/dist/src/core/sink-router.js +0 -107
  412. package/dist/src/core/stale-run-reconciler.js +0 -352
  413. package/dist/src/core/tick-runner.js +0 -2442
  414. package/dist/src/core/workspace-cleanup.js +0 -117
  415. package/dist/src/domain/branch-naming.js +0 -14
  416. package/dist/src/domain/custom-commands.js +0 -58
  417. package/dist/src/domain/event-types.js +0 -158
  418. package/dist/src/domain/manual-labels.js +0 -1
  419. package/dist/src/domain/resource-uri.js +0 -38
  420. package/dist/src/domain/runner-routing.js +0 -127
  421. package/dist/src/domain/runtime-events.js +0 -36
  422. package/dist/src/domain/schema.js +0 -1233
  423. package/dist/src/domain/sources.js +0 -16
  424. package/dist/src/domain/stages.js +0 -36
  425. package/dist/src/domain/work-item-labels.js +0 -48
  426. package/dist/src/domain/work-item-lifecycle.js +0 -10
  427. package/dist/src/domain/work-item-status.js +0 -33
  428. package/dist/src/domain/workflows.js +0 -159
  429. package/dist/src/lib/deep-merge.js +0 -14
  430. package/dist/src/lib/detached-process-logging.js +0 -46
  431. package/dist/src/lib/event-log.js +0 -21
  432. package/dist/src/lib/format.js +0 -41
  433. package/dist/src/lib/json-file.js +0 -23
  434. package/dist/src/lib/lock.js +0 -181
  435. package/dist/src/lib/log-rotation.js +0 -42
  436. package/dist/src/lib/paths.js +0 -52
  437. package/dist/src/lib/process-identity.js +0 -54
  438. package/dist/src/lib/state-health.js +0 -30
  439. package/dist/src/lib/work-id.js +0 -19
  440. package/dist/src/lib/yaml-file.js +0 -20
  441. /package/dist/src/{core → activities/pr}/contracts.js +0 -0
  442. /package/dist/src/{domain/types.js → control-plane/contracts/views.js} +0 -0
@@ -1,117 +0,0 @@
1
- import { readdir, readFile, rm, stat, writeFile } from 'node:fs/promises';
2
- import { isAbsolute, join, relative } from 'node:path';
3
- import { WORKSPACE_CLEANED_EVENT, WORKSPACE_CLEANUP_FAILED_EVENT } from '../domain/event-types.js';
4
- import { createEventEnvelope } from '../lib/event-log.js';
5
- const TRANSCRIPT_CLEANED_AT_MARKER = '.cleaned-at';
6
- // Cleans up per-issue workspaces and applies transcript retention once the
7
- // originating issue is closed. A cleanup failure is recorded as an event and
8
- // skipped rather than aborting the sweep.
9
- export function createWorkspaceCleanup(deps) {
10
- function eventStampNow() {
11
- return deps.clock.now().toISOString();
12
- }
13
- function isPerIssueWorkspacePath(workspacePath) {
14
- const workspacesRoot = join(deps.config.paths.wakeRoot, 'workspaces');
15
- const rel = relative(workspacesRoot, workspacePath);
16
- return !rel.startsWith('..') && !isAbsolute(rel) && rel.length > 0;
17
- }
18
- async function markTranscriptDirectoryCleaned(workItemKey, cleanedAt) {
19
- const transcriptDir = deps.stateStore.paths.transcriptWorkDir(workItemKey);
20
- const transcriptDirStat = await stat(transcriptDir).catch(() => undefined);
21
- if (transcriptDirStat === undefined || !transcriptDirStat.isDirectory()) {
22
- return;
23
- }
24
- await writeFile(join(transcriptDir, TRANSCRIPT_CLEANED_AT_MARKER), `${cleanedAt}\n`, 'utf8');
25
- }
26
- async function applyTranscriptCleanupRetention(workItemKey, cleanedAt) {
27
- if (deps.config.transcripts.retentionMs === 0) {
28
- await rm(deps.stateStore.paths.transcriptWorkDir(workItemKey), {
29
- recursive: true,
30
- force: true,
31
- });
32
- return;
33
- }
34
- await markTranscriptDirectoryCleaned(workItemKey, cleanedAt);
35
- }
36
- async function sweepExpiredTranscriptDirs() {
37
- const retentionMs = deps.config.transcripts.retentionMs;
38
- const transcriptDirs = await readdir(deps.stateStore.paths.transcriptsRoot, {
39
- withFileTypes: true,
40
- }).catch(() => []);
41
- const nowMs = deps.clock.now().getTime();
42
- for (const entry of transcriptDirs) {
43
- if (!entry.isDirectory()) {
44
- continue;
45
- }
46
- const transcriptDir = join(deps.stateStore.paths.transcriptsRoot, entry.name);
47
- const markerPath = join(transcriptDir, TRANSCRIPT_CLEANED_AT_MARKER);
48
- const marker = await readFile(markerPath, 'utf8').catch(() => undefined);
49
- if (marker === undefined) {
50
- continue;
51
- }
52
- const cleanedAtMs = Date.parse(marker.trim());
53
- if (!Number.isFinite(cleanedAtMs)) {
54
- continue;
55
- }
56
- if (nowMs - cleanedAtMs >= retentionMs) {
57
- await rm(transcriptDir, { recursive: true, force: true });
58
- }
59
- }
60
- }
61
- async function cleanupClosedIssueWorkspaces(projections) {
62
- for (const projection of projections) {
63
- const { workspacePath } = projection.wake;
64
- if (projection.issue.state === 'closed' &&
65
- workspacePath !== undefined &&
66
- isPerIssueWorkspacePath(workspacePath)) {
67
- try {
68
- await deps.workspaceManager.cleanupWorkspace({ workspacePath });
69
- await applyTranscriptCleanupRetention(projection.workItemKey, eventStampNow());
70
- }
71
- catch (error) {
72
- const failedAt = eventStampNow();
73
- await deps.stateStore.appendEventEnvelope(createEventEnvelope({
74
- eventId: `workspace-cleanup-failed-${projection.issue.repo.replace(/[^a-z0-9]+/gi, '-')}-${projection.issue.number}`,
75
- workItemKey: projection.workItemKey,
76
- streamScope: 'work-item',
77
- direction: 'internal',
78
- sourceSystem: 'wake',
79
- sourceEventType: WORKSPACE_CLEANUP_FAILED_EVENT,
80
- sourceRefs: {
81
- repo: projection.issue.repo,
82
- issueNumber: projection.issue.number,
83
- },
84
- occurredAt: failedAt,
85
- ingestedAt: failedAt,
86
- trigger: 'context-only',
87
- payload: {
88
- workspacePath,
89
- error: error instanceof Error ? error.message : String(error),
90
- },
91
- }));
92
- continue;
93
- }
94
- const cleanedAt = eventStampNow();
95
- const cleanupEvent = createEventEnvelope({
96
- eventId: `workspace-cleaned-${projection.issue.repo.replace(/[^a-z0-9]+/gi, '-')}-${projection.issue.number}-${deps.clock.now().getTime()}`,
97
- workItemKey: projection.workItemKey,
98
- streamScope: 'work-item',
99
- direction: 'internal',
100
- sourceSystem: 'wake',
101
- sourceEventType: WORKSPACE_CLEANED_EVENT,
102
- sourceRefs: {
103
- repo: projection.issue.repo,
104
- issueNumber: projection.issue.number,
105
- },
106
- occurredAt: cleanedAt,
107
- ingestedAt: cleanedAt,
108
- trigger: 'immediate',
109
- payload: { workspacePath },
110
- });
111
- await deps.stateStore.appendEventEnvelope(cleanupEvent);
112
- await deps.projectionUpdater.rebuildFromEvents([cleanupEvent]);
113
- }
114
- }
115
- }
116
- return { cleanupClosedIssueWorkspaces, sweepExpiredTranscriptDirs };
117
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * Wake's branch-naming convention for a work item's implementation branch,
3
- * keyed on the originating ticket's issue number (spec D2 — human-readable,
4
- * not the opaque work id).
5
- *
6
- * Lives in domain/ (not the git adapter) because it is pure vocabulary with
7
- * no IO: `core/` needs it to compute the branch a run should have pushed to
8
- * when verifying agent-reported artifacts, and `core/` may import domain/
9
- * but never a concrete adapter directly. `adapters/git/git-workspace-manager.ts`
10
- * re-exports this for its own callers so existing imports keep working.
11
- */
12
- export function branchNameForIssue(issueNumber) {
13
- return `wake/issue-${issueNumber}`;
14
- }
@@ -1,58 +0,0 @@
1
- export const reservedCommandNames = ['approved', 'changes', 'interrupt'];
2
- function latestUnhandledHumanComment(issue) {
3
- const context = issue.context;
4
- const handledCommentId = typeof context.lastHandledCommentId === 'string' ? context.lastHandledCommentId : undefined;
5
- const lastBotIndex = issue.comments.reduce((acc, c, i) => (c.isBotAuthored ? i : acc), -1);
6
- const humanCommentsAfterBot = issue.comments
7
- .slice(lastBotIndex + 1)
8
- .filter((c) => !c.isBotAuthored);
9
- const latestHumanComment = humanCommentsAfterBot.at(-1);
10
- if (latestHumanComment === undefined || latestHumanComment.id === handledCommentId) {
11
- return undefined;
12
- }
13
- return latestHumanComment;
14
- }
15
- function commandNameFromBody(body) {
16
- for (const line of body.split(/\r?\n/)) {
17
- const match = /^\/([A-Za-z0-9_.-]+)\b/.exec(line.trim());
18
- if (match?.[1] !== undefined) {
19
- return match[1].toLowerCase();
20
- }
21
- }
22
- return null;
23
- }
24
- export function customCommandAction(command, config) {
25
- const entry = Object.entries(config.commands).find(([name]) => name.toLowerCase() === command.toLowerCase());
26
- if (entry === undefined) {
27
- return undefined;
28
- }
29
- const [name, definition] = entry;
30
- return definition.action ?? name;
31
- }
32
- export function isCustomCommandAction(action, config) {
33
- return Object.entries(config.commands).some(([name, definition]) => (definition.action ?? name) === action);
34
- }
35
- export function customCommandWorkspace(action, config) {
36
- return Object.entries(config.commands).find(([name, definition]) => (definition.action ?? name) === action)?.[1].workspace;
37
- }
38
- export function resolveCustomCommand(issue, config) {
39
- const latestHumanComment = latestUnhandledHumanComment(issue);
40
- if (latestHumanComment === undefined) {
41
- return null;
42
- }
43
- const command = commandNameFromBody(latestHumanComment.body);
44
- if (command === null) {
45
- return null;
46
- }
47
- const definitionEntry = Object.entries(config.commands).find(([name]) => name.toLowerCase() === command);
48
- if (definitionEntry === undefined) {
49
- return null;
50
- }
51
- const [configuredName, definition] = definitionEntry;
52
- return {
53
- action: definition.action ?? configuredName,
54
- command: configuredName,
55
- comment: latestHumanComment,
56
- workspace: definition.workspace,
57
- };
58
- }
@@ -1,158 +0,0 @@
1
- export const AUTONOMOUS_DECISION_AUDIT_EVENT = 'wake.audit.autonomous-decision';
2
- export const CORRELATION_PRIMARY_CONFLICT_EVENT = 'wake.correlation.primary-conflict';
3
- export const CORRELATION_REGISTERED_EVENT = 'wake.correlation.registered';
4
- export const CORRELATION_RETRACTED_EVENT = 'wake.correlation.retracted';
5
- export const LABELS_REQUESTED_EVENT = 'wake.labels.requested';
6
- export const PR_AUTO_MERGE_ENABLED_EVENT = 'wake.pr-auto-merge.enabled';
7
- export const PR_REVIEW_APPROVED_EVENT = 'wake.pr-review.approved';
8
- export const PUBLISH_CONFIRMED_EVENT = 'wake.publish.confirmed';
9
- export const PUBLISH_FAILED_EVENT = 'wake.publish.failed';
10
- export const PUBLISH_INTENT_REQUESTED_EVENT = 'wake.publish.intent.requested';
11
- export const PUBLISH_SENT_UNCONFIRMED_EVENT = 'wake.publish.sent-unconfirmed';
12
- export const RETRY_REQUESTED_EVENT = 'wake.retry.requested';
13
- export const RUN_REQUESTED_EVENT = 'wake.run.requested';
14
- export const RUN_CLAIMED_EVENT = 'wake.run.claimed';
15
- export const RUN_COMPLETED_EVENT = 'wake.run.completed';
16
- export const WORKFLOW_SELECTED_EVENT = 'wake.workflow.selected';
17
- export const WORK_ITEM_CREATED_EVENT = 'wake.workitem.created';
18
- export const WORK_ITEM_DELETED_EVENT = 'wake.workitem.deleted';
19
- export const WORK_ITEM_FROZEN_EVENT = 'wake.workitem.frozen';
20
- export const WORK_ITEM_UNFROZEN_EVENT = 'wake.workitem.unfrozen';
21
- export const WORKSPACE_CLEANED_EVENT = 'wake.workspace.cleaned';
22
- export const WORKSPACE_CLEANUP_FAILED_EVENT = 'wake.workspace.cleanup-failed';
23
- export const wakeEventTypeValues = [
24
- AUTONOMOUS_DECISION_AUDIT_EVENT,
25
- CORRELATION_PRIMARY_CONFLICT_EVENT,
26
- CORRELATION_REGISTERED_EVENT,
27
- CORRELATION_RETRACTED_EVENT,
28
- LABELS_REQUESTED_EVENT,
29
- PR_AUTO_MERGE_ENABLED_EVENT,
30
- PR_REVIEW_APPROVED_EVENT,
31
- PUBLISH_CONFIRMED_EVENT,
32
- PUBLISH_FAILED_EVENT,
33
- PUBLISH_INTENT_REQUESTED_EVENT,
34
- PUBLISH_SENT_UNCONFIRMED_EVENT,
35
- RETRY_REQUESTED_EVENT,
36
- RUN_REQUESTED_EVENT,
37
- RUN_CLAIMED_EVENT,
38
- RUN_COMPLETED_EVENT,
39
- WORKFLOW_SELECTED_EVENT,
40
- WORK_ITEM_CREATED_EVENT,
41
- WORK_ITEM_DELETED_EVENT,
42
- WORK_ITEM_FROZEN_EVENT,
43
- WORK_ITEM_UNFROZEN_EVENT,
44
- WORKSPACE_CLEANED_EVENT,
45
- WORKSPACE_CLEANUP_FAILED_EVENT,
46
- ];
47
- export const wakeEventTypeDefinitions = [
48
- {
49
- type: AUTONOMOUS_DECISION_AUDIT_EVENT,
50
- description: 'Records an autonomous workflow decision and the inputs used to make it.',
51
- payloadShape: '{ decisionType, workItemId, runId, workflowRevision, inputsConsidered, outcome, timestamp }',
52
- },
53
- {
54
- type: CORRELATION_PRIMARY_CONFLICT_EVENT,
55
- description: 'Warns that a requested primary resource correlation was downgraded because another work item already owns the resource.',
56
- payloadShape: '{ resourceUri, incumbentWorkItemKey }',
57
- },
58
- {
59
- type: CORRELATION_REGISTERED_EVENT,
60
- description: 'Registers a resource URI as correlated to a work item.',
61
- payloadShape: '{ resourceUri, role, relation, provenance, registeredBy? }',
62
- },
63
- {
64
- type: CORRELATION_RETRACTED_EVENT,
65
- description: 'Removes a resource URI correlation from a work item.',
66
- payloadShape: '{ resourceUri }',
67
- },
68
- {
69
- type: LABELS_REQUESTED_EVENT,
70
- description: 'Requests outbound synchronization of Wake status, stage, and workflow labels.',
71
- payloadShape: "{ statusLabel, stageLabel, workflowLabel, origin, idempotencyKey, deliveryState: 'PENDING' }",
72
- },
73
- {
74
- type: PR_AUTO_MERGE_ENABLED_EVENT,
75
- description: 'Records that Wake enabled auto-merge for an approved pull request.',
76
- payloadShape: '{ idempotencyKey }',
77
- },
78
- {
79
- type: PR_REVIEW_APPROVED_EVENT,
80
- description: 'Records that Wake approved a pull request review after approval policy passed.',
81
- payloadShape: '{ idempotencyKey }',
82
- },
83
- {
84
- type: PUBLISH_CONFIRMED_EVENT,
85
- description: 'Confirms that an outbound publish intent was delivered or intentionally suppressed.',
86
- payloadShape: "{ intentEventId, idempotencyKey, deliveryState: 'CONFIRMED', ...sinkDetails }",
87
- },
88
- {
89
- type: PUBLISH_FAILED_EVENT,
90
- description: 'Records a failed outbound publish attempt for bounded retry.',
91
- payloadShape: "{ intentEventId, intentEventType, idempotencyKey, deliveryState: 'PENDING', error }",
92
- },
93
- {
94
- type: PUBLISH_INTENT_REQUESTED_EVENT,
95
- description: 'Requests an outbound comment, reply, status update, question, or approval card.',
96
- payloadShape: "{ kind, origin, body, action, sentinel, runId, idempotencyKey, deliveryState: 'PENDING', sessionId?, model?, cli?, duration?, tokens?, cost?, workspacePath?, failureRepeated?, previousFailureClass? }",
97
- },
98
- {
99
- type: PUBLISH_SENT_UNCONFIRMED_EVENT,
100
- description: 'Marks an outbound publish intent as sent before Wake has observed confirmation.',
101
- payloadShape: "{ intentEventId, intentEventType, idempotencyKey, deliveryState: 'SENT_UNCONFIRMED' }",
102
- },
103
- {
104
- type: RETRY_REQUESTED_EVENT,
105
- description: 'Requests that a failed work item be retried.',
106
- payloadShape: '{ requestedBy }',
107
- },
108
- {
109
- type: RUN_REQUESTED_EVENT,
110
- description: 'Requests that a scheduled work item be run immediately.',
111
- payloadShape: '{ requestedBy }',
112
- },
113
- {
114
- type: RUN_CLAIMED_EVENT,
115
- description: 'Records that Wake claimed a work item for an agent run.',
116
- payloadShape: '{ action, priorStage, claimedStage?, sourceRevision, watcherRun?, watcherTrigger? }',
117
- },
118
- {
119
- type: RUN_COMPLETED_EVENT,
120
- description: 'Records the terminal result of an agent run or internal lifecycle transition.',
121
- payloadShape: '{ action?, sentinel, nextStage?, runId, sessionId?, sessionCli?, workspacePath?, reason?, handledCommentId?, failureClass?, blockReason?, executionOutcome?, workflowOutcome?, watcherRun?, allowAutoApproval?, body? }',
122
- },
123
- {
124
- type: WORKFLOW_SELECTED_EVENT,
125
- description: 'Pins the workflow selected for a newly minted work item.',
126
- payloadShape: '{ workflow, selectedFromEventId }',
127
- },
128
- {
129
- type: WORK_ITEM_CREATED_EVENT,
130
- description: 'Mints a Wake work item identity before resource correlation is registered.',
131
- payloadShape: '{}',
132
- },
133
- {
134
- type: WORK_ITEM_DELETED_EVENT,
135
- description: 'Soft-deletes a work item and excludes it from board display and execution.',
136
- payloadShape: '{ requestedBy }',
137
- },
138
- {
139
- type: WORK_ITEM_FROZEN_EVENT,
140
- description: 'Marks a work item as frozen so runner ticks will not execute it.',
141
- payloadShape: '{ requestedBy }',
142
- },
143
- {
144
- type: WORK_ITEM_UNFROZEN_EVENT,
145
- description: 'Clears a work item freeze so runner ticks may execute it again.',
146
- payloadShape: '{ requestedBy }',
147
- },
148
- {
149
- type: WORKSPACE_CLEANED_EVENT,
150
- description: 'Records successful cleanup of a closed issue workspace.',
151
- payloadShape: '{ workspacePath }',
152
- },
153
- {
154
- type: WORKSPACE_CLEANUP_FAILED_EVENT,
155
- description: 'Records a workspace cleanup failure without aborting the cleanup sweep.',
156
- payloadShape: '{ workspacePath, error }',
157
- },
158
- ];
@@ -1 +0,0 @@
1
- export const alwaysManualIgnoredLabels = ['security', 'wake:manual', 'wake:always-manual'];
@@ -1,38 +0,0 @@
1
- import { z } from 'zod';
2
- /**
3
- * Resource URI grammar: `<provider>:<kind>:<locator>`.
4
- *
5
- * `provider` matches the adapter's registered source/sink name; `kind` uses
6
- * the provider's native vocabulary (`github:pr:…` but `gitlab:mr:…`). The
7
- * locator grammar is provider-specific and opaque to core — everything after
8
- * the second colon is matched as a single blob and never inspected here.
9
- * Core compares URIs for equality only (ADR 0001 §1).
10
- */
11
- const RESOURCE_URI_PATTERN = /^[a-z0-9][a-z0-9-]*:[a-z0-9][a-z0-9-]*:.+$/;
12
- export const resourceUriSchema = z
13
- .string()
14
- .regex(RESOURCE_URI_PATTERN, 'must match <provider>:<kind>:<locator>');
15
- export function buildResourceUri(provider, kind, locator) {
16
- return resourceUriSchema.parse(`${provider}:${kind}:${locator}`);
17
- }
18
- /**
19
- * Wake-owned relationship vocabulary — the graph edge type, deliberately
20
- * independent of the URI's provider-native `kind`. A new provider adds URI
21
- * kinds, never new roles; a new role is a Wake modelling decision.
22
- */
23
- export const correlationRoleSchema = z.enum([
24
- 'representation',
25
- 'implementation',
26
- 'discussion',
27
- 'review',
28
- 'documentation',
29
- 'decision',
30
- ]);
31
- /** Exactly one work item may hold `primary` per resource URI (ADR 0001 §2). */
32
- export const correlationRelationSchema = z.enum(['primary', 'secondary']);
33
- export const correlationProvenanceSchema = z.enum([
34
- 'wake-created',
35
- 'agent-reported',
36
- 'detected',
37
- 'operator-declared',
38
- ]);
@@ -1,127 +0,0 @@
1
- import { defaultWorkflowName } from './workflows.js';
2
- export function maxConfiguredRunnerTimeoutMs(config) {
3
- const activeRunnerNames = new Set(Object.values(config.tiers).flatMap((candidates) => candidates));
4
- for (const workflow of Object.values(config.workflows)) {
5
- for (const stageRoute of Object.values(workflow.stages)) {
6
- if (stageRoute.runner !== undefined) {
7
- activeRunnerNames.add(stageRoute.runner);
8
- }
9
- }
10
- }
11
- for (const commandRoute of Object.values(config.commands)) {
12
- if (commandRoute.runner !== undefined) {
13
- activeRunnerNames.add(commandRoute.runner);
14
- }
15
- }
16
- const registryTimeouts = [...activeRunnerNames]
17
- .map((name) => config.runners[name])
18
- .map((entry) => (entry === undefined || entry.kind === 'fake' ? undefined : entry.timeoutMs))
19
- .filter((timeout) => timeout !== undefined);
20
- return registryTimeouts.length > 0 ? Math.max(...registryTimeouts) : Infinity;
21
- }
22
- // How often an 'estimated' pause (exponential-backoff guess, not a reset time
23
- // the CLI actually reported) gets a recovery probe: a real attempt let through
24
- // early in case the guess overshot and quota actually reset sooner. 'reported'
25
- // pauses (an actual reset time) are trusted for their full duration - no
26
- // probing needed since we already know when they clear.
27
- const recoveryProbeIntervalMs = 15 * 60_000;
28
- function isRunnerPaused(input) {
29
- const health = input.ledger?.runners?.[input.runnerName];
30
- const pausedUntil = health?.pausedUntil;
31
- if (pausedUntil === undefined || Date.parse(pausedUntil) <= input.now.getTime()) {
32
- return { paused: false, isProbe: false };
33
- }
34
- if (health?.pausedUntilSource === 'estimated' && health.lastFailureAt !== undefined) {
35
- const sinceLastFailureMs = input.now.getTime() - Date.parse(health.lastFailureAt);
36
- if (sinceLastFailureMs >= recoveryProbeIntervalMs) {
37
- return { paused: false, isProbe: true };
38
- }
39
- }
40
- return { paused: true, isProbe: false };
41
- }
42
- /**
43
- * Resolves which named runner should execute a stage/action.
44
- *
45
- * A stage pinned directly to a runner (`stages[stage].runner`) has no
46
- * fallback list, so it always returns that runner regardless of health.
47
- * A stage routed through a `tier` walks the tier's ordered candidates and
48
- * skips any currently quota-paused per the ledger (#67 sideways fallback),
49
- * returning `null` only when every candidate in the tier is paused - callers
50
- * should treat that as "nothing to do this tick", not a config error. Once a
51
- * higher-priority candidate's pause expires, it is preferred again on the
52
- * next call, which is the "rotation" back to the primary runner.
53
- */
54
- export function resolveRunnerRouting(input) {
55
- const workflowName = input.workflowName ?? defaultWorkflowName(input.config);
56
- const workflow = input.config.workflows[workflowName];
57
- if (workflow === undefined) {
58
- throw new Error(`Unknown workflow "${workflowName}".`);
59
- }
60
- const commandRouteEntry = input.command === undefined
61
- ? Object.entries(input.config.commands).find(([name, route]) => (route.action ?? name) === input.action)
62
- : Object.entries(input.config.commands).find(([name]) => name.toLowerCase() === input.command?.toLowerCase());
63
- const commandRoute = commandRouteEntry?.[1];
64
- if (commandRoute?.runner !== undefined) {
65
- const runnerName = commandRoute.runner;
66
- const entry = input.config.runners[runnerName];
67
- if (entry === undefined) {
68
- throw new Error(`Command ${input.action} pins unknown runner "${runnerName}".`);
69
- }
70
- return {
71
- runnerName,
72
- runnerKind: entry.kind,
73
- ...(commandRoute.tier === undefined ? {} : { tier: commandRoute.tier }),
74
- reason: `command ${input.action} pins runner ${runnerName}`,
75
- };
76
- }
77
- const stageRoute = workflow.stages[input.stage];
78
- if (stageRoute?.runner !== undefined) {
79
- const entry = input.config.runners[stageRoute.runner];
80
- if (entry === undefined) {
81
- throw new Error(`Stage ${input.stage} pins unknown runner "${stageRoute.runner}".`);
82
- }
83
- return {
84
- runnerName: stageRoute.runner,
85
- runnerKind: entry.kind,
86
- ...(stageRoute.tier === undefined ? {} : { tier: stageRoute.tier }),
87
- reason: `stage ${input.stage} pins runner ${stageRoute.runner}`,
88
- };
89
- }
90
- const tier = commandRoute?.tier ?? stageRoute?.tier ?? input.config.defaultTier;
91
- const candidates = input.config.tiers[tier];
92
- if (candidates === undefined || candidates.length === 0) {
93
- throw new Error(`Stage ${input.stage} routes to unknown or empty tier "${tier}".`);
94
- }
95
- const now = input.now ?? new Date();
96
- let selected;
97
- for (const candidate of candidates) {
98
- const status = isRunnerPaused({ runnerName: candidate, ledger: input.ledger, now });
99
- if (!status.paused) {
100
- selected = { runnerName: candidate, isProbe: status.isProbe };
101
- break;
102
- }
103
- }
104
- if (selected === undefined) {
105
- return null;
106
- }
107
- const { runnerName, isProbe } = selected;
108
- const entry = input.config.runners[runnerName];
109
- if (entry === undefined) {
110
- throw new Error(`Tier ${tier} references unknown runner "${runnerName}".`);
111
- }
112
- const isFallback = runnerName !== candidates[0];
113
- return {
114
- runnerName,
115
- runnerKind: entry.kind,
116
- tier,
117
- reason: isProbe
118
- ? `tier ${tier} recovery probe on ${runnerName} (estimated pause not yet elapsed)`
119
- : isFallback
120
- ? `tier ${tier} fell back to ${runnerName} (higher-priority candidates paused)`
121
- : commandRoute?.tier !== undefined
122
- ? `command ${input.action} tier ${tier} selected runner ${runnerName}`
123
- : stageRoute?.tier === undefined
124
- ? `defaultTier ${tier} selected runner ${runnerName}`
125
- : `stage ${input.stage} tier ${tier} selected runner ${runnerName}`,
126
- };
127
- }
@@ -1,36 +0,0 @@
1
- export const runtimeEventTypeValues = [
2
- 'run.claimed',
3
- 'run.started',
4
- 'workspace.preparing',
5
- 'workspace.ready',
6
- 'agent.process.started',
7
- 'agent.session.started',
8
- 'agent.progress',
9
- 'agent.tool.requested',
10
- 'agent.approval.requested',
11
- 'agent.input.required',
12
- 'agent.usage.updated',
13
- 'agent.turn.completed',
14
- 'agent.process.exited',
15
- 'run.completed',
16
- 'run.failed',
17
- 'run.stalled',
18
- 'run.canceled',
19
- ];
20
- export function isMeaningfulRuntimeEvent(event) {
21
- return (event.type === 'agent.progress' ||
22
- event.type === 'agent.tool.requested' ||
23
- event.type === 'agent.approval.requested' ||
24
- event.type === 'agent.input.required' ||
25
- event.type === 'agent.usage.updated' ||
26
- event.type === 'agent.turn.completed');
27
- }
28
- export function runtimeEventPayload(input) {
29
- return {
30
- ...(input.message === undefined ? {} : { message: input.message }),
31
- ...(input.raw === undefined ? {} : { raw: input.raw }),
32
- ...(input.exitCode === undefined ? {} : { exitCode: input.exitCode }),
33
- ...(input.timedOut === undefined ? {} : { timedOut: input.timedOut }),
34
- ...(input.tokenUsage === undefined ? {} : { tokenUsage: input.tokenUsage }),
35
- };
36
- }