@openrig/cli 0.2.0 → 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 (469) hide show
  1. package/daemon/dist/adapters/claude-code-adapter.d.ts +10 -0
  2. package/daemon/dist/adapters/claude-code-adapter.d.ts.map +1 -1
  3. package/daemon/dist/adapters/claude-code-adapter.js +41 -3
  4. package/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
  5. package/daemon/dist/builtins/workflow-specs/basic-loop.yaml +76 -0
  6. package/daemon/dist/builtins/workflow-specs/conveyor.yaml +80 -0
  7. package/daemon/dist/db/migrations/026_inbox_entries.d.ts +1 -1
  8. package/daemon/dist/db/migrations/026_inbox_entries.js +1 -1
  9. package/daemon/dist/db/migrations/029_classifier_leases.d.ts +1 -1
  10. package/daemon/dist/db/migrations/029_classifier_leases.js +1 -1
  11. package/daemon/dist/db/migrations/037_mission_control_actions.d.ts +51 -0
  12. package/daemon/dist/db/migrations/037_mission_control_actions.d.ts.map +1 -0
  13. package/daemon/dist/db/migrations/037_mission_control_actions.js +74 -0
  14. package/daemon/dist/db/migrations/037_mission_control_actions.js.map +1 -0
  15. package/daemon/dist/db/migrations/038_workspace_primitive.d.ts +16 -0
  16. package/daemon/dist/db/migrations/038_workspace_primitive.d.ts.map +1 -0
  17. package/daemon/dist/db/migrations/038_workspace_primitive.js +20 -0
  18. package/daemon/dist/db/migrations/038_workspace_primitive.js.map +1 -0
  19. package/daemon/dist/db/migrations/039_queue_target_repo.d.ts +16 -0
  20. package/daemon/dist/db/migrations/039_queue_target_repo.d.ts.map +1 -0
  21. package/daemon/dist/db/migrations/039_queue_target_repo.js +21 -0
  22. package/daemon/dist/db/migrations/039_queue_target_repo.js.map +1 -0
  23. package/daemon/dist/domain/active-lens-store.d.ts +23 -0
  24. package/daemon/dist/domain/active-lens-store.d.ts.map +1 -0
  25. package/daemon/dist/domain/active-lens-store.js +87 -0
  26. package/daemon/dist/domain/active-lens-store.js.map +1 -0
  27. package/daemon/dist/domain/agent-images/agent-image-library-service.d.ts +68 -0
  28. package/daemon/dist/domain/agent-images/agent-image-library-service.d.ts.map +1 -0
  29. package/daemon/dist/domain/agent-images/agent-image-library-service.js +339 -0
  30. package/daemon/dist/domain/agent-images/agent-image-library-service.js.map +1 -0
  31. package/daemon/dist/domain/agent-images/agent-image-types.d.ts +113 -0
  32. package/daemon/dist/domain/agent-images/agent-image-types.d.ts.map +1 -0
  33. package/daemon/dist/domain/agent-images/agent-image-types.js +24 -0
  34. package/daemon/dist/domain/agent-images/agent-image-types.js.map +1 -0
  35. package/daemon/dist/domain/agent-images/evidence-guard.d.ts +26 -0
  36. package/daemon/dist/domain/agent-images/evidence-guard.d.ts.map +1 -0
  37. package/daemon/dist/domain/agent-images/evidence-guard.js +185 -0
  38. package/daemon/dist/domain/agent-images/evidence-guard.js.map +1 -0
  39. package/daemon/dist/domain/agent-images/manifest-parser.d.ts +3 -0
  40. package/daemon/dist/domain/agent-images/manifest-parser.d.ts.map +1 -0
  41. package/daemon/dist/domain/agent-images/manifest-parser.js +114 -0
  42. package/daemon/dist/domain/agent-images/manifest-parser.js.map +1 -0
  43. package/daemon/dist/domain/agent-images/resume-token-discovery.d.ts +28 -0
  44. package/daemon/dist/domain/agent-images/resume-token-discovery.d.ts.map +1 -0
  45. package/daemon/dist/domain/agent-images/resume-token-discovery.js +83 -0
  46. package/daemon/dist/domain/agent-images/resume-token-discovery.js.map +1 -0
  47. package/daemon/dist/domain/agent-images/snapshot-capturer.d.ts +36 -0
  48. package/daemon/dist/domain/agent-images/snapshot-capturer.d.ts.map +1 -0
  49. package/daemon/dist/domain/agent-images/snapshot-capturer.js +58 -0
  50. package/daemon/dist/domain/agent-images/snapshot-capturer.js.map +1 -0
  51. package/daemon/dist/domain/agent-starter-resolver.d.ts +10 -16
  52. package/daemon/dist/domain/agent-starter-resolver.d.ts.map +1 -1
  53. package/daemon/dist/domain/agent-starter-resolver.js +11 -13
  54. package/daemon/dist/domain/agent-starter-resolver.js.map +1 -1
  55. package/daemon/dist/domain/classifier-lease-manager.d.ts +1 -1
  56. package/daemon/dist/domain/classifier-lease-manager.js +1 -1
  57. package/daemon/dist/domain/conflict-detector.d.ts.map +1 -1
  58. package/daemon/dist/domain/conflict-detector.js +6 -3
  59. package/daemon/dist/domain/conflict-detector.js.map +1 -1
  60. package/daemon/dist/domain/context-monitor.d.ts +5 -4
  61. package/daemon/dist/domain/context-monitor.d.ts.map +1 -1
  62. package/daemon/dist/domain/context-monitor.js +26 -11
  63. package/daemon/dist/domain/context-monitor.js.map +1 -1
  64. package/daemon/dist/domain/context-packs/bundle-assembler.d.ts +49 -0
  65. package/daemon/dist/domain/context-packs/bundle-assembler.d.ts.map +1 -0
  66. package/daemon/dist/domain/context-packs/bundle-assembler.js +81 -0
  67. package/daemon/dist/domain/context-packs/bundle-assembler.js.map +1 -0
  68. package/daemon/dist/domain/context-packs/context-pack-library-service.d.ts +41 -0
  69. package/daemon/dist/domain/context-packs/context-pack-library-service.d.ts.map +1 -0
  70. package/daemon/dist/domain/context-packs/context-pack-library-service.js +148 -0
  71. package/daemon/dist/domain/context-packs/context-pack-library-service.js.map +1 -0
  72. package/daemon/dist/domain/context-packs/context-pack-types.d.ts +64 -0
  73. package/daemon/dist/domain/context-packs/context-pack-types.d.ts.map +1 -0
  74. package/daemon/dist/domain/context-packs/context-pack-types.js +22 -0
  75. package/daemon/dist/domain/context-packs/context-pack-types.js.map +1 -0
  76. package/daemon/dist/domain/context-packs/manifest-parser.d.ts +3 -0
  77. package/daemon/dist/domain/context-packs/manifest-parser.d.ts.map +1 -0
  78. package/daemon/dist/domain/context-packs/manifest-parser.js +74 -0
  79. package/daemon/dist/domain/context-packs/manifest-parser.js.map +1 -0
  80. package/daemon/dist/domain/context-usage-store.d.ts +14 -1
  81. package/daemon/dist/domain/context-usage-store.d.ts.map +1 -1
  82. package/daemon/dist/domain/context-usage-store.js +156 -1
  83. package/daemon/dist/domain/context-usage-store.js.map +1 -1
  84. package/daemon/dist/domain/files/file-write-service.d.ts +61 -0
  85. package/daemon/dist/domain/files/file-write-service.d.ts.map +1 -0
  86. package/daemon/dist/domain/files/file-write-service.js +180 -0
  87. package/daemon/dist/domain/files/file-write-service.js.map +1 -0
  88. package/daemon/dist/domain/files/path-safety.d.ts +47 -0
  89. package/daemon/dist/domain/files/path-safety.d.ts.map +1 -0
  90. package/daemon/dist/domain/files/path-safety.js +176 -0
  91. package/daemon/dist/domain/files/path-safety.js.map +1 -0
  92. package/daemon/dist/domain/graph-projection.d.ts +14 -1
  93. package/daemon/dist/domain/graph-projection.d.ts.map +1 -1
  94. package/daemon/dist/domain/graph-projection.js +8 -0
  95. package/daemon/dist/domain/graph-projection.js.map +1 -1
  96. package/daemon/dist/domain/install-engine.d.ts.map +1 -1
  97. package/daemon/dist/domain/install-engine.js +22 -6
  98. package/daemon/dist/domain/install-engine.js.map +1 -1
  99. package/daemon/dist/domain/install-verifier.d.ts.map +1 -1
  100. package/daemon/dist/domain/install-verifier.js +10 -5
  101. package/daemon/dist/domain/install-verifier.js.map +1 -1
  102. package/daemon/dist/domain/managed-blocks.d.ts.map +1 -1
  103. package/daemon/dist/domain/managed-blocks.js +22 -3
  104. package/daemon/dist/domain/managed-blocks.js.map +1 -1
  105. package/daemon/dist/domain/mission-control/audit-browse.d.ts +26 -0
  106. package/daemon/dist/domain/mission-control/audit-browse.d.ts.map +1 -0
  107. package/daemon/dist/domain/mission-control/audit-browse.js +101 -0
  108. package/daemon/dist/domain/mission-control/audit-browse.js.map +1 -0
  109. package/daemon/dist/domain/mission-control/mission-control-action-log.d.ts +51 -0
  110. package/daemon/dist/domain/mission-control/mission-control-action-log.d.ts.map +1 -0
  111. package/daemon/dist/domain/mission-control/mission-control-action-log.js +124 -0
  112. package/daemon/dist/domain/mission-control/mission-control-action-log.js.map +1 -0
  113. package/daemon/dist/domain/mission-control/mission-control-fleet-cli-capability.d.ts +131 -0
  114. package/daemon/dist/domain/mission-control/mission-control-fleet-cli-capability.d.ts.map +1 -0
  115. package/daemon/dist/domain/mission-control/mission-control-fleet-cli-capability.js +232 -0
  116. package/daemon/dist/domain/mission-control/mission-control-fleet-cli-capability.js.map +1 -0
  117. package/daemon/dist/domain/mission-control/mission-control-read-layer.d.ts +85 -0
  118. package/daemon/dist/domain/mission-control/mission-control-read-layer.d.ts.map +1 -0
  119. package/daemon/dist/domain/mission-control/mission-control-read-layer.js +265 -0
  120. package/daemon/dist/domain/mission-control/mission-control-read-layer.js.map +1 -0
  121. package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts +69 -0
  122. package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts.map +1 -0
  123. package/daemon/dist/domain/mission-control/mission-control-write-contract.js +300 -0
  124. package/daemon/dist/domain/mission-control/mission-control-write-contract.js.map +1 -0
  125. package/daemon/dist/domain/mission-control/notification-adapter-ntfy.d.ts +18 -0
  126. package/daemon/dist/domain/mission-control/notification-adapter-ntfy.d.ts.map +1 -0
  127. package/daemon/dist/domain/mission-control/notification-adapter-ntfy.js +48 -0
  128. package/daemon/dist/domain/mission-control/notification-adapter-ntfy.js.map +1 -0
  129. package/daemon/dist/domain/mission-control/notification-adapter-types.d.ts +25 -0
  130. package/daemon/dist/domain/mission-control/notification-adapter-types.d.ts.map +1 -0
  131. package/daemon/dist/domain/mission-control/notification-adapter-types.js +7 -0
  132. package/daemon/dist/domain/mission-control/notification-adapter-types.js.map +1 -0
  133. package/daemon/dist/domain/mission-control/notification-adapter-webhook.d.ts +27 -0
  134. package/daemon/dist/domain/mission-control/notification-adapter-webhook.d.ts.map +1 -0
  135. package/daemon/dist/domain/mission-control/notification-adapter-webhook.js +47 -0
  136. package/daemon/dist/domain/mission-control/notification-adapter-webhook.js.map +1 -0
  137. package/daemon/dist/domain/mission-control/notification-dispatcher.d.ts +53 -0
  138. package/daemon/dist/domain/mission-control/notification-dispatcher.d.ts.map +1 -0
  139. package/daemon/dist/domain/mission-control/notification-dispatcher.js +181 -0
  140. package/daemon/dist/domain/mission-control/notification-dispatcher.js.map +1 -0
  141. package/daemon/dist/domain/node-inventory.d.ts.map +1 -1
  142. package/daemon/dist/domain/node-inventory.js +24 -0
  143. package/daemon/dist/domain/node-inventory.js.map +1 -1
  144. package/daemon/dist/domain/node-launcher.d.ts.map +1 -1
  145. package/daemon/dist/domain/node-launcher.js +7 -5
  146. package/daemon/dist/domain/node-launcher.js.map +1 -1
  147. package/daemon/dist/domain/preview/preview-rate-limiter.d.ts +20 -0
  148. package/daemon/dist/domain/preview/preview-rate-limiter.d.ts.map +1 -0
  149. package/daemon/dist/domain/preview/preview-rate-limiter.js +46 -0
  150. package/daemon/dist/domain/preview/preview-rate-limiter.js.map +1 -0
  151. package/daemon/dist/domain/profile-resolver.d.ts +5 -0
  152. package/daemon/dist/domain/profile-resolver.d.ts.map +1 -1
  153. package/daemon/dist/domain/profile-resolver.js +62 -8
  154. package/daemon/dist/domain/profile-resolver.js.map +1 -1
  155. package/daemon/dist/domain/progress/progress-indexer.d.ts +73 -0
  156. package/daemon/dist/domain/progress/progress-indexer.d.ts.map +1 -0
  157. package/daemon/dist/domain/progress/progress-indexer.js +210 -0
  158. package/daemon/dist/domain/progress/progress-indexer.js.map +1 -0
  159. package/daemon/dist/domain/project-classifier.d.ts +1 -1
  160. package/daemon/dist/domain/queue-repository.d.ts +22 -4
  161. package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
  162. package/daemon/dist/domain/queue-repository.js +80 -22
  163. package/daemon/dist/domain/queue-repository.js.map +1 -1
  164. package/daemon/dist/domain/rehydrate-eligibility.d.ts +16 -0
  165. package/daemon/dist/domain/rehydrate-eligibility.d.ts.map +1 -0
  166. package/daemon/dist/domain/rehydrate-eligibility.js +43 -0
  167. package/daemon/dist/domain/rehydrate-eligibility.js.map +1 -0
  168. package/daemon/dist/domain/restore-check-service.d.ts.map +1 -1
  169. package/daemon/dist/domain/restore-check-service.js +19 -6
  170. package/daemon/dist/domain/restore-check-service.js.map +1 -1
  171. package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
  172. package/daemon/dist/domain/restore-orchestrator.js +4 -2
  173. package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
  174. package/daemon/dist/domain/rig-repository.d.ts +14 -0
  175. package/daemon/dist/domain/rig-repository.d.ts.map +1 -1
  176. package/daemon/dist/domain/rig-repository.js +41 -0
  177. package/daemon/dist/domain/rig-repository.js.map +1 -1
  178. package/daemon/dist/domain/rig-teardown.d.ts.map +1 -1
  179. package/daemon/dist/domain/rig-teardown.js +5 -0
  180. package/daemon/dist/domain/rig-teardown.js.map +1 -1
  181. package/daemon/dist/domain/rigspec-codec.d.ts.map +1 -1
  182. package/daemon/dist/domain/rigspec-codec.js +15 -0
  183. package/daemon/dist/domain/rigspec-codec.js.map +1 -1
  184. package/daemon/dist/domain/rigspec-instantiator.d.ts +29 -0
  185. package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
  186. package/daemon/dist/domain/rigspec-instantiator.js +136 -4
  187. package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
  188. package/daemon/dist/domain/rigspec-schema.d.ts.map +1 -1
  189. package/daemon/dist/domain/rigspec-schema.js +157 -4
  190. package/daemon/dist/domain/rigspec-schema.js.map +1 -1
  191. package/daemon/dist/domain/runtime-adapter.d.ts +11 -0
  192. package/daemon/dist/domain/runtime-adapter.d.ts.map +1 -1
  193. package/daemon/dist/domain/runtime-adapter.js.map +1 -1
  194. package/daemon/dist/domain/skill-discovery.d.ts +51 -0
  195. package/daemon/dist/domain/skill-discovery.d.ts.map +1 -0
  196. package/daemon/dist/domain/skill-discovery.js +144 -0
  197. package/daemon/dist/domain/skill-discovery.js.map +1 -0
  198. package/daemon/dist/domain/slices/slice-detail-projector.d.ts +182 -0
  199. package/daemon/dist/domain/slices/slice-detail-projector.d.ts.map +1 -0
  200. package/daemon/dist/domain/slices/slice-detail-projector.js +508 -0
  201. package/daemon/dist/domain/slices/slice-detail-projector.js.map +1 -0
  202. package/daemon/dist/domain/slices/slice-indexer.d.ts +118 -0
  203. package/daemon/dist/domain/slices/slice-indexer.d.ts.map +1 -0
  204. package/daemon/dist/domain/slices/slice-indexer.js +503 -0
  205. package/daemon/dist/domain/slices/slice-indexer.js.map +1 -0
  206. package/daemon/dist/domain/spec-library-service.d.ts +17 -2
  207. package/daemon/dist/domain/spec-library-service.d.ts.map +1 -1
  208. package/daemon/dist/domain/spec-library-service.js +31 -1
  209. package/daemon/dist/domain/spec-library-service.js.map +1 -1
  210. package/daemon/dist/domain/spec-library-workflow-scanner.d.ts +81 -0
  211. package/daemon/dist/domain/spec-library-workflow-scanner.d.ts.map +1 -0
  212. package/daemon/dist/domain/spec-library-workflow-scanner.js +171 -0
  213. package/daemon/dist/domain/spec-library-workflow-scanner.js.map +1 -0
  214. package/daemon/dist/domain/startup-validation.d.ts.map +1 -1
  215. package/daemon/dist/domain/startup-validation.js +57 -11
  216. package/daemon/dist/domain/startup-validation.js.map +1 -1
  217. package/daemon/dist/domain/steering/health-summary.d.ts +39 -0
  218. package/daemon/dist/domain/steering/health-summary.d.ts.map +1 -0
  219. package/daemon/dist/domain/steering/health-summary.js +100 -0
  220. package/daemon/dist/domain/steering/health-summary.js.map +1 -0
  221. package/daemon/dist/domain/steering/steering-composer.d.ts +102 -0
  222. package/daemon/dist/domain/steering/steering-composer.d.ts.map +1 -0
  223. package/daemon/dist/domain/steering/steering-composer.js +263 -0
  224. package/daemon/dist/domain/steering/steering-composer.js.map +1 -0
  225. package/daemon/dist/domain/transcript-capture.d.ts.map +1 -1
  226. package/daemon/dist/domain/transcript-capture.js +7 -4
  227. package/daemon/dist/domain/transcript-capture.js.map +1 -1
  228. package/daemon/dist/domain/transcript-rotation.d.ts +29 -0
  229. package/daemon/dist/domain/transcript-rotation.d.ts.map +1 -0
  230. package/daemon/dist/domain/transcript-rotation.js +109 -0
  231. package/daemon/dist/domain/transcript-rotation.js.map +1 -0
  232. package/daemon/dist/domain/transcript-store.d.ts.map +1 -1
  233. package/daemon/dist/domain/transcript-store.js +7 -1
  234. package/daemon/dist/domain/transcript-store.js.map +1 -1
  235. package/daemon/dist/domain/types.d.ts +101 -2
  236. package/daemon/dist/domain/types.d.ts.map +1 -1
  237. package/daemon/dist/domain/types.js +8 -1
  238. package/daemon/dist/domain/types.js.map +1 -1
  239. package/daemon/dist/domain/user-settings/settings-store.d.ts +42 -0
  240. package/daemon/dist/domain/user-settings/settings-store.d.ts.map +1 -0
  241. package/daemon/dist/domain/user-settings/settings-store.js +364 -0
  242. package/daemon/dist/domain/user-settings/settings-store.js.map +1 -0
  243. package/daemon/dist/domain/view-event-bridge.d.ts.map +1 -1
  244. package/daemon/dist/domain/view-event-bridge.js +2 -3
  245. package/daemon/dist/domain/view-event-bridge.js.map +1 -1
  246. package/daemon/dist/domain/whoami-service.d.ts +29 -0
  247. package/daemon/dist/domain/whoami-service.d.ts.map +1 -1
  248. package/daemon/dist/domain/whoami-service.js +68 -0
  249. package/daemon/dist/domain/whoami-service.js.map +1 -1
  250. package/daemon/dist/domain/workflow/slice-workflow-binding.d.ts +21 -0
  251. package/daemon/dist/domain/workflow/slice-workflow-binding.d.ts.map +1 -0
  252. package/daemon/dist/domain/workflow/slice-workflow-binding.js +103 -0
  253. package/daemon/dist/domain/workflow/slice-workflow-binding.js.map +1 -0
  254. package/daemon/dist/domain/workflow/slice-workflow-projection.d.ts +81 -0
  255. package/daemon/dist/domain/workflow/slice-workflow-projection.d.ts.map +1 -0
  256. package/daemon/dist/domain/workflow/slice-workflow-projection.js +127 -0
  257. package/daemon/dist/domain/workflow/slice-workflow-projection.js.map +1 -0
  258. package/daemon/dist/domain/workflow/starter-spec-loader.d.ts +51 -0
  259. package/daemon/dist/domain/workflow/starter-spec-loader.d.ts.map +1 -0
  260. package/daemon/dist/domain/workflow/starter-spec-loader.js +140 -0
  261. package/daemon/dist/domain/workflow/starter-spec-loader.js.map +1 -0
  262. package/daemon/dist/domain/workflow-projector.js +11 -3
  263. package/daemon/dist/domain/workflow-projector.js.map +1 -1
  264. package/daemon/dist/domain/workflow-spec-cache.d.ts +7 -0
  265. package/daemon/dist/domain/workflow-spec-cache.d.ts.map +1 -1
  266. package/daemon/dist/domain/workflow-spec-cache.js +62 -15
  267. package/daemon/dist/domain/workflow-spec-cache.js.map +1 -1
  268. package/daemon/dist/domain/workspace/default-workspace-scaffold.d.ts +6 -0
  269. package/daemon/dist/domain/workspace/default-workspace-scaffold.d.ts.map +1 -0
  270. package/daemon/dist/domain/workspace/default-workspace-scaffold.js +207 -0
  271. package/daemon/dist/domain/workspace/default-workspace-scaffold.js.map +1 -0
  272. package/daemon/dist/domain/workspace/frontmatter-validator.d.ts +40 -0
  273. package/daemon/dist/domain/workspace/frontmatter-validator.d.ts.map +1 -0
  274. package/daemon/dist/domain/workspace/frontmatter-validator.js +185 -0
  275. package/daemon/dist/domain/workspace/frontmatter-validator.js.map +1 -0
  276. package/daemon/dist/domain/workspace/workspace-resolver.d.ts +25 -0
  277. package/daemon/dist/domain/workspace/workspace-resolver.d.ts.map +1 -0
  278. package/daemon/dist/domain/workspace/workspace-resolver.js +86 -0
  279. package/daemon/dist/domain/workspace/workspace-resolver.js.map +1 -0
  280. package/daemon/dist/index.d.ts.map +1 -1
  281. package/daemon/dist/index.js +10 -1
  282. package/daemon/dist/index.js.map +1 -1
  283. package/daemon/dist/middleware/auth-bearer-token.d.ts +49 -0
  284. package/daemon/dist/middleware/auth-bearer-token.d.ts.map +1 -0
  285. package/daemon/dist/middleware/auth-bearer-token.js +135 -0
  286. package/daemon/dist/middleware/auth-bearer-token.js.map +1 -0
  287. package/daemon/dist/openrig-compat.d.ts +1 -1
  288. package/daemon/dist/openrig-compat.d.ts.map +1 -1
  289. package/daemon/dist/openrig-compat.js +6 -4
  290. package/daemon/dist/openrig-compat.js.map +1 -1
  291. package/daemon/dist/routes/agent-images.d.ts +8 -0
  292. package/daemon/dist/routes/agent-images.d.ts.map +1 -0
  293. package/daemon/dist/routes/agent-images.js +253 -0
  294. package/daemon/dist/routes/agent-images.js.map +1 -0
  295. package/daemon/dist/routes/config.d.ts +3 -0
  296. package/daemon/dist/routes/config.d.ts.map +1 -0
  297. package/daemon/dist/routes/config.js +109 -0
  298. package/daemon/dist/routes/config.js.map +1 -0
  299. package/daemon/dist/routes/context-packs.d.ts +3 -0
  300. package/daemon/dist/routes/context-packs.d.ts.map +1 -0
  301. package/daemon/dist/routes/context-packs.js +129 -0
  302. package/daemon/dist/routes/context-packs.js.map +1 -0
  303. package/daemon/dist/routes/files.d.ts +17 -0
  304. package/daemon/dist/routes/files.d.ts.map +1 -0
  305. package/daemon/dist/routes/files.js +262 -0
  306. package/daemon/dist/routes/files.js.map +1 -0
  307. package/daemon/dist/routes/health-summary.d.ts +9 -0
  308. package/daemon/dist/routes/health-summary.d.ts.map +1 -0
  309. package/daemon/dist/routes/health-summary.js +33 -0
  310. package/daemon/dist/routes/health-summary.js.map +1 -0
  311. package/daemon/dist/routes/mission-control.d.ts +37 -0
  312. package/daemon/dist/routes/mission-control.d.ts.map +1 -0
  313. package/daemon/dist/routes/mission-control.js +283 -0
  314. package/daemon/dist/routes/mission-control.js.map +1 -0
  315. package/daemon/dist/routes/progress.d.ts +7 -0
  316. package/daemon/dist/routes/progress.d.ts.map +1 -0
  317. package/daemon/dist/routes/progress.js +33 -0
  318. package/daemon/dist/routes/progress.js.map +1 -0
  319. package/daemon/dist/routes/queue.d.ts.map +1 -1
  320. package/daemon/dist/routes/queue.js +52 -1
  321. package/daemon/dist/routes/queue.js.map +1 -1
  322. package/daemon/dist/routes/rigs.d.ts +3 -0
  323. package/daemon/dist/routes/rigs.d.ts.map +1 -1
  324. package/daemon/dist/routes/rigs.js +73 -7
  325. package/daemon/dist/routes/rigs.js.map +1 -1
  326. package/daemon/dist/routes/rigspec.js +6 -3
  327. package/daemon/dist/routes/rigspec.js.map +1 -1
  328. package/daemon/dist/routes/sessions.d.ts.map +1 -1
  329. package/daemon/dist/routes/sessions.js +119 -0
  330. package/daemon/dist/routes/sessions.js.map +1 -1
  331. package/daemon/dist/routes/slices.d.ts +9 -0
  332. package/daemon/dist/routes/slices.d.ts.map +1 -0
  333. package/daemon/dist/routes/slices.js +192 -0
  334. package/daemon/dist/routes/slices.js.map +1 -0
  335. package/daemon/dist/routes/spec-library.d.ts.map +1 -1
  336. package/daemon/dist/routes/spec-library.js +72 -5
  337. package/daemon/dist/routes/spec-library.js.map +1 -1
  338. package/daemon/dist/routes/steering.d.ts +7 -0
  339. package/daemon/dist/routes/steering.d.ts.map +1 -0
  340. package/daemon/dist/routes/steering.js +27 -0
  341. package/daemon/dist/routes/steering.js.map +1 -0
  342. package/daemon/dist/routes/up.d.ts.map +1 -1
  343. package/daemon/dist/routes/up.js +21 -3
  344. package/daemon/dist/routes/up.js.map +1 -1
  345. package/daemon/dist/routes/whoami.d.ts.map +1 -1
  346. package/daemon/dist/routes/whoami.js +6 -1
  347. package/daemon/dist/routes/whoami.js.map +1 -1
  348. package/daemon/dist/routes/workflow.d.ts.map +1 -1
  349. package/daemon/dist/routes/workflow.js +43 -0
  350. package/daemon/dist/routes/workflow.js.map +1 -1
  351. package/daemon/dist/routes/workspace.d.ts +3 -0
  352. package/daemon/dist/routes/workspace.d.ts.map +1 -0
  353. package/daemon/dist/routes/workspace.js +53 -0
  354. package/daemon/dist/routes/workspace.js.map +1 -0
  355. package/daemon/dist/server.d.ts +51 -0
  356. package/daemon/dist/server.d.ts.map +1 -1
  357. package/daemon/dist/server.js +52 -1
  358. package/daemon/dist/server.js.map +1 -1
  359. package/daemon/dist/startup.d.ts +9 -0
  360. package/daemon/dist/startup.d.ts.map +1 -1
  361. package/daemon/dist/startup.js +385 -2
  362. package/daemon/dist/startup.js.map +1 -1
  363. package/daemon/docs/reference/agent-spec.md +7 -7
  364. package/daemon/docs/reference/agent-startup-guide.md +2 -2
  365. package/daemon/docs/reference/project-workspace.md +102 -0
  366. package/daemon/specs/agents/apps/vault-specialist/agent.yaml +1 -1
  367. package/daemon/specs/agents/apps/vault-specialist/guidance/role.md +0 -1
  368. package/daemon/specs/agents/conveyor/builder/agent.yaml +35 -0
  369. package/daemon/specs/agents/conveyor/builder/guidance/role.md +31 -0
  370. package/daemon/specs/agents/conveyor/builder/startup/context.md +9 -0
  371. package/daemon/specs/agents/conveyor/lead/agent.yaml +35 -0
  372. package/daemon/specs/agents/conveyor/lead/guidance/role.md +34 -0
  373. package/daemon/specs/agents/conveyor/lead/startup/context.md +15 -0
  374. package/daemon/specs/agents/conveyor/planner/agent.yaml +35 -0
  375. package/daemon/specs/agents/conveyor/planner/guidance/role.md +29 -0
  376. package/daemon/specs/agents/conveyor/planner/startup/context.md +12 -0
  377. package/daemon/specs/agents/conveyor/reviewer/agent.yaml +35 -0
  378. package/daemon/specs/agents/conveyor/reviewer/guidance/role.md +29 -0
  379. package/daemon/specs/agents/conveyor/reviewer/startup/context.md +10 -0
  380. package/daemon/specs/agents/development/implementer/agent.yaml +1 -1
  381. package/daemon/specs/agents/development/implementer/guidance/role.md +0 -1
  382. package/daemon/specs/agents/orchestration/orchestrator/agent.yaml +1 -1
  383. package/daemon/specs/agents/orchestration/orchestrator/guidance/role.md +2 -3
  384. package/daemon/specs/agents/shared/agent.yaml +0 -2
  385. package/daemon/specs/agents/shared/skills/core/openrig-user/SKILL.md +25 -0
  386. package/daemon/specs/agents/shared/skills/core/openrig-user-settings/SKILL.md +153 -0
  387. package/daemon/specs/agents/shared/skills/rig-architect/SKILL.md +1 -1
  388. package/daemon/specs/rigs/launch/conveyor/CULTURE.md +34 -0
  389. package/daemon/specs/rigs/launch/conveyor/README.md +33 -0
  390. package/daemon/specs/rigs/launch/conveyor/rig.yaml +72 -0
  391. package/daemon/specs/rigs/preview/product-team/CULTURE.md +2 -2
  392. package/daemon/specs/rigs/preview/product-team/rig.yaml +3 -4
  393. package/dist/commands/agent-image.d.ts +4 -0
  394. package/dist/commands/agent-image.d.ts.map +1 -0
  395. package/dist/commands/agent-image.js +352 -0
  396. package/dist/commands/agent-image.js.map +1 -0
  397. package/dist/commands/config-init-workspace.d.ts +35 -0
  398. package/dist/commands/config-init-workspace.d.ts.map +1 -0
  399. package/dist/commands/config-init-workspace.js +300 -0
  400. package/dist/commands/config-init-workspace.js.map +1 -0
  401. package/dist/commands/config.d.ts.map +1 -1
  402. package/dist/commands/config.js +78 -18
  403. package/dist/commands/config.js.map +1 -1
  404. package/dist/commands/context-pack.d.ts +4 -0
  405. package/dist/commands/context-pack.d.ts.map +1 -0
  406. package/dist/commands/context-pack.js +357 -0
  407. package/dist/commands/context-pack.js.map +1 -0
  408. package/dist/commands/daemon.d.ts.map +1 -1
  409. package/dist/commands/daemon.js +8 -0
  410. package/dist/commands/daemon.js.map +1 -1
  411. package/dist/commands/import.d.ts.map +1 -1
  412. package/dist/commands/import.js +7 -2
  413. package/dist/commands/import.js.map +1 -1
  414. package/dist/commands/ps.d.ts.map +1 -1
  415. package/dist/commands/ps.js +173 -14
  416. package/dist/commands/ps.js.map +1 -1
  417. package/dist/commands/queue.d.ts.map +1 -1
  418. package/dist/commands/queue.js +9 -0
  419. package/dist/commands/queue.js.map +1 -1
  420. package/dist/commands/send.d.ts +7 -0
  421. package/dist/commands/send.d.ts.map +1 -1
  422. package/dist/commands/send.js +24 -1
  423. package/dist/commands/send.js.map +1 -1
  424. package/dist/commands/specs.d.ts +4 -2
  425. package/dist/commands/specs.d.ts.map +1 -1
  426. package/dist/commands/specs.js +12 -8
  427. package/dist/commands/specs.js.map +1 -1
  428. package/dist/commands/up.d.ts.map +1 -1
  429. package/dist/commands/up.js +17 -3
  430. package/dist/commands/up.js.map +1 -1
  431. package/dist/commands/whoami.d.ts.map +1 -1
  432. package/dist/commands/whoami.js +9 -4
  433. package/dist/commands/whoami.js.map +1 -1
  434. package/dist/commands/workflow.d.ts.map +1 -1
  435. package/dist/commands/workflow.js +37 -0
  436. package/dist/commands/workflow.js.map +1 -1
  437. package/dist/commands/workspace.d.ts +6 -0
  438. package/dist/commands/workspace.d.ts.map +1 -0
  439. package/dist/commands/workspace.js +83 -0
  440. package/dist/commands/workspace.js.map +1 -0
  441. package/dist/config-store.d.ts +73 -1
  442. package/dist/config-store.d.ts.map +1 -1
  443. package/dist/config-store.js +314 -42
  444. package/dist/config-store.js.map +1 -1
  445. package/dist/daemon-lifecycle.d.ts +22 -0
  446. package/dist/daemon-lifecycle.d.ts.map +1 -1
  447. package/dist/daemon-lifecycle.js +41 -0
  448. package/dist/daemon-lifecycle.js.map +1 -1
  449. package/dist/index.d.ts +4 -0
  450. package/dist/index.d.ts.map +1 -1
  451. package/dist/index.js +6 -0
  452. package/dist/index.js.map +1 -1
  453. package/dist/openrig-compat.d.ts +1 -1
  454. package/dist/openrig-compat.d.ts.map +1 -1
  455. package/dist/openrig-compat.js +6 -4
  456. package/dist/openrig-compat.js.map +1 -1
  457. package/dist/restore-packet/claude-transcript-parser.js +1 -1
  458. package/dist/restore-packet/claude-transcript-parser.js.map +1 -1
  459. package/dist/restore-packet/codex-jsonl-parser.js +1 -1
  460. package/dist/restore-packet/codex-jsonl-parser.js.map +1 -1
  461. package/package.json +2 -2
  462. package/ui/dist/assets/index-BDHU1JUK.js +412 -0
  463. package/ui/dist/assets/index-DXTyJSqu.css +1 -0
  464. package/ui/dist/graphics/operator-climber-monochrome.png +0 -0
  465. package/ui/dist/index.html +3 -2
  466. package/daemon/specs/agents/shared/skills/mental-model-ha/SKILL.md +0 -956
  467. package/ui/dist/assets/index-B09doO8H.js +0 -139
  468. package/ui/dist/assets/index-Dec25siz.css +0 -1
  469. package/ui/dist/assets/index-GNYaWmBj.js +0 -225
@@ -0,0 +1,265 @@
1
+ // PL-005 Phase A: Mission Control read layer.
2
+ //
3
+ // Maps the 7 Mission Control views to data sources:
4
+ // - my-queue → queue_items where destination_session = operator
5
+ // AND tier='human-gate'
6
+ // - human-gate → queue_items where tier='human-gate'
7
+ // - fleet → shell out to `rig ps --nodes --json` (graceful
8
+ // degradation per 4-sub-clause spec)
9
+ // - active-work → queue_items where state in (pending, in-progress,
10
+ // blocked) sorted by priority
11
+ // - recent-ships → queue_items where state in (done, handed-off)
12
+ // ORDER BY ts_updated DESC LIMIT 10
13
+ // - recently-active → PL-004 Phase B ViewProjector built-in view
14
+ // - recent-observations → stream_items table (Phase A daemon-backed source)
15
+ // with ~/.openrig/stream/<date>.jsonl as graceful
16
+ // degradation fallback
17
+ //
18
+ // Each row carries the 9-field phone-friendly content model (PRD § Acceptance
19
+ // Criteria item 1; non-negotiable across all 7 views regardless of UI density).
20
+ //
21
+ // Source-of-truth integration: PL-004 daemon-backed coordination services
22
+ // are the primary read path. Filesystem/CLI fallbacks are for graceful
23
+ // degradation only.
24
+ export const MISSION_CONTROL_VIEWS = [
25
+ "my-queue",
26
+ "human-gate",
27
+ "fleet",
28
+ "active-work",
29
+ "recent-ships",
30
+ "recently-active",
31
+ "recent-observations",
32
+ ];
33
+ const DEFAULT_OPERATOR_SESSION = "human-operator@kernel";
34
+ const RECENT_SHIPS_LIMIT = 10;
35
+ const ACTIVE_WORK_LIMIT = 50;
36
+ const RECENT_OBSERVATIONS_LIMIT = 50;
37
+ const PRIORITY_RANK = {
38
+ critical: 0,
39
+ high: 1,
40
+ routine: 2,
41
+ background: 3,
42
+ };
43
+ export class MissionControlReadLayer {
44
+ queueRepo;
45
+ viewProjector;
46
+ streamStore;
47
+ fleetCliCapability;
48
+ defaultOperatorSession;
49
+ constructor(deps) {
50
+ this.queueRepo = deps.queueRepo;
51
+ this.viewProjector = deps.viewProjector;
52
+ this.streamStore = deps.streamStore;
53
+ this.fleetCliCapability = deps.fleetCliCapability;
54
+ this.defaultOperatorSession = deps.defaultOperatorSession ?? DEFAULT_OPERATOR_SESSION;
55
+ }
56
+ async readView(viewName, opts) {
57
+ switch (viewName) {
58
+ case "my-queue":
59
+ return this.readMyQueue(opts?.operatorSession ?? this.defaultOperatorSession);
60
+ case "human-gate":
61
+ return this.readHumanGate();
62
+ case "fleet":
63
+ return this.readFleet();
64
+ case "active-work":
65
+ return this.readActiveWork();
66
+ case "recent-ships":
67
+ return this.readRecentShips();
68
+ case "recently-active":
69
+ return this.readRecentlyActive();
70
+ case "recent-observations":
71
+ return this.readRecentObservations();
72
+ }
73
+ }
74
+ readMyQueue(operatorSession) {
75
+ const items = this.queueRepo.list({
76
+ destinationSession: operatorSession,
77
+ state: ["pending", "in-progress", "blocked"],
78
+ limit: ACTIVE_WORK_LIMIT,
79
+ });
80
+ const humanGateOnly = items.filter((q) => q.tier === "human-gate");
81
+ return {
82
+ viewName: "my-queue",
83
+ rows: humanGateOnly.map((q) => qitemToRow(q, { defaultReadCost: "skim/approve" })),
84
+ meta: { rowCount: humanGateOnly.length },
85
+ };
86
+ }
87
+ readHumanGate() {
88
+ const items = this.queueRepo.list({
89
+ state: ["pending", "in-progress", "blocked"],
90
+ limit: ACTIVE_WORK_LIMIT,
91
+ });
92
+ const humanGateOnly = items.filter((q) => q.tier === "human-gate");
93
+ return {
94
+ viewName: "human-gate",
95
+ rows: humanGateOnly.map((q) => qitemToRow(q, { defaultReadCost: "skim/approve" })),
96
+ meta: { rowCount: humanGateOnly.length },
97
+ };
98
+ }
99
+ async readFleet() {
100
+ const fleet = await this.fleetCliCapability.rollupFleet();
101
+ const rows = fleet.rows.map((r) => fleetRowToCompactRow(r));
102
+ return {
103
+ viewName: "fleet",
104
+ rows,
105
+ meta: {
106
+ rowCount: rows.length,
107
+ rigsRunningStaleCli: fleet.staleCliCount,
108
+ degradedFields: fleet.degradedFields.length > 0 ? fleet.degradedFields : undefined,
109
+ sourceFallback: fleet.sourceFallback ?? undefined,
110
+ },
111
+ };
112
+ }
113
+ readActiveWork() {
114
+ const items = this.queueRepo.list({
115
+ state: ["pending", "in-progress", "blocked"],
116
+ limit: ACTIVE_WORK_LIMIT,
117
+ });
118
+ items.sort((a, b) => {
119
+ const ar = PRIORITY_RANK[a.priority] ?? 99;
120
+ const br = PRIORITY_RANK[b.priority] ?? 99;
121
+ if (ar !== br)
122
+ return ar - br;
123
+ return a.tsUpdated.localeCompare(b.tsUpdated);
124
+ });
125
+ return {
126
+ viewName: "active-work",
127
+ rows: items.map((q) => qitemToRow(q, { defaultReadCost: "full" })),
128
+ meta: { rowCount: items.length },
129
+ };
130
+ }
131
+ readRecentShips() {
132
+ const done = this.queueRepo.list({
133
+ state: ["done", "handed-off"],
134
+ limit: RECENT_SHIPS_LIMIT * 4,
135
+ });
136
+ done.sort((a, b) => b.tsUpdated.localeCompare(a.tsUpdated));
137
+ const top = done.slice(0, RECENT_SHIPS_LIMIT);
138
+ return {
139
+ viewName: "recent-ships",
140
+ rows: top.map((q) => qitemToRow(q, { defaultReadCost: "summary-only" })),
141
+ meta: { rowCount: top.length },
142
+ };
143
+ }
144
+ readRecentlyActive() {
145
+ // Delegates to PL-004 Phase B's built-in `recently-active` view.
146
+ const result = this.viewProjector.show("recently-active");
147
+ const rows = result.rows.map((row) => builtinViewRowToCompactRow("recently-active", row));
148
+ return {
149
+ viewName: "recently-active",
150
+ rows,
151
+ meta: { rowCount: rows.length },
152
+ };
153
+ }
154
+ readRecentObservations() {
155
+ if (!this.streamStore) {
156
+ return {
157
+ viewName: "recent-observations",
158
+ rows: [],
159
+ meta: { rowCount: 0, sourceFallback: "stream-store-not-wired" },
160
+ };
161
+ }
162
+ const items = this.streamStore.list({ limit: RECENT_OBSERVATIONS_LIMIT });
163
+ const rows = items.map((s) => streamItemToCompactRow(s));
164
+ return {
165
+ viewName: "recent-observations",
166
+ rows,
167
+ meta: { rowCount: rows.length },
168
+ };
169
+ }
170
+ }
171
+ function qitemToRow(q, opts) {
172
+ const state = qitemStateToCompactState(q.state);
173
+ const nextAction = q.state === "blocked" ? `unblock: ${q.blockedOn ?? "external-gate"}` : null;
174
+ const pendingHumanDecision = q.tier === "human-gate" ? `${q.priority} human-gate item` : null;
175
+ return {
176
+ rigOrMissionName: q.destinationSession,
177
+ currentPhase: q.tier ?? null,
178
+ state,
179
+ nextAction,
180
+ pendingHumanDecision,
181
+ readCost: opts.defaultReadCost,
182
+ lastUpdate: q.tsUpdated,
183
+ confidenceFreshness: q.priority,
184
+ evidenceLink: null,
185
+ qitemId: q.qitemId,
186
+ rawSourceRef: q.sourceSession,
187
+ qitemSummary: summarizeBody(q.body),
188
+ qitemBody: q.body,
189
+ };
190
+ }
191
+ function summarizeBody(body) {
192
+ const compact = body.replace(/\s+/g, " ").trim();
193
+ if (compact.length <= 120)
194
+ return compact;
195
+ return `${compact.slice(0, 117).trimEnd()}...`;
196
+ }
197
+ function qitemStateToCompactState(state) {
198
+ switch (state) {
199
+ case "in-progress":
200
+ return "active";
201
+ case "pending":
202
+ return "idle";
203
+ case "blocked":
204
+ return "blocked";
205
+ case "failed":
206
+ case "denied":
207
+ case "canceled":
208
+ return "degraded";
209
+ case "done":
210
+ case "handed-off":
211
+ return "idle";
212
+ }
213
+ }
214
+ function fleetRowToCompactRow(r) {
215
+ return {
216
+ rigOrMissionName: r.rigName,
217
+ currentPhase: r.lifecycleState ?? null,
218
+ state: r.activityState,
219
+ nextAction: r.attentionReason ?? null,
220
+ pendingHumanDecision: null,
221
+ readCost: "summary-only",
222
+ lastUpdate: r.lastUpdate,
223
+ confidenceFreshness: r.cliVersionLabel,
224
+ evidenceLink: null,
225
+ qitemId: null,
226
+ rawSourceRef: r.rigName,
227
+ };
228
+ }
229
+ function builtinViewRowToCompactRow(viewName, row) {
230
+ const get = (k) => {
231
+ const v = row[k];
232
+ if (v === undefined || v === null)
233
+ return null;
234
+ return String(v);
235
+ };
236
+ return {
237
+ rigOrMissionName: get("destination_session") ?? get("rig_name") ?? get("rigName") ?? viewName,
238
+ currentPhase: get("tier") ?? get("state") ?? null,
239
+ state: "idle",
240
+ nextAction: null,
241
+ pendingHumanDecision: null,
242
+ readCost: "summary-only",
243
+ lastUpdate: get("ts_updated") ?? get("ts_emitted") ?? new Date().toISOString(),
244
+ confidenceFreshness: get("priority") ?? null,
245
+ evidenceLink: null,
246
+ qitemId: get("qitem_id"),
247
+ rawSourceRef: get("source_session"),
248
+ };
249
+ }
250
+ function streamItemToCompactRow(s) {
251
+ return {
252
+ rigOrMissionName: s.sourceSession,
253
+ currentPhase: s.hintType ?? null,
254
+ state: s.hintUrgency === "critical" ? "attention" : "idle",
255
+ nextAction: s.hintDestination ?? null,
256
+ pendingHumanDecision: null,
257
+ readCost: "summary-only",
258
+ lastUpdate: s.tsEmitted,
259
+ confidenceFreshness: s.hintUrgency ?? null,
260
+ evidenceLink: null,
261
+ qitemId: null,
262
+ rawSourceRef: s.streamItemId,
263
+ };
264
+ }
265
+ //# sourceMappingURL=mission-control-read-layer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mission-control-read-layer.js","sourceRoot":"","sources":["../../../src/domain/mission-control/mission-control-read-layer.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,EAAE;AACF,oDAAoD;AACpD,6EAA6E;AAC7E,mDAAmD;AACnD,gEAAgE;AAChE,2EAA2E;AAC3E,gEAAgE;AAChE,8EAA8E;AAC9E,yDAAyD;AACzD,0EAA0E;AAC1E,+DAA+D;AAC/D,uEAAuE;AACvE,8EAA8E;AAC9E,6EAA6E;AAC7E,kDAAkD;AAClD,EAAE;AACF,8EAA8E;AAC9E,gFAAgF;AAChF,EAAE;AACF,0EAA0E;AAC1E,uEAAuE;AACvE,oBAAoB;AAQpB,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,UAAU;IACV,YAAY;IACZ,OAAO;IACP,aAAa;IACb,cAAc;IACd,iBAAiB;IACjB,qBAAqB;CACb,CAAC;AAiEX,MAAM,wBAAwB,GAAG,uBAAuB,CAAC;AACzD,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAErC,MAAM,aAAa,GAA2B;IAC5C,QAAQ,EAAE,CAAC;IACX,IAAI,EAAE,CAAC;IACP,OAAO,EAAE,CAAC;IACV,UAAU,EAAE,CAAC;CACd,CAAC;AAEF,MAAM,OAAO,uBAAuB;IACjB,SAAS,CAAkB;IAC3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ACJ,CAAC"}
@@ -0,0 +1,69 @@
1
+ import type Database from "better-sqlite3";
2
+ import type { EventBus } from "../event-bus.js";
3
+ import type { QueueRepository, QueueItem } from "../queue-repository.js";
4
+ import { MissionControlActionLog, type MissionControlVerb } from "./mission-control-action-log.js";
5
+ export declare class MissionControlWriteContractError extends Error {
6
+ readonly code: string;
7
+ readonly details?: Record<string, unknown> | undefined;
8
+ constructor(code: string, message: string, details?: Record<string, unknown> | undefined);
9
+ }
10
+ export interface MissionControlActionInput {
11
+ verb: MissionControlVerb;
12
+ qitemId: string;
13
+ actorSession: string;
14
+ /** Required for `route` and `handoff`. */
15
+ destinationSession?: string;
16
+ /** Body for the new packet on `route`/`handoff`; defaults to source body. */
17
+ body?: string;
18
+ /** Required for `annotate`. */
19
+ annotation?: string;
20
+ /** Required for `hold` and `drop`; optional advisory text otherwise. */
21
+ reason?: string;
22
+ /** Operator-supplied audit context. */
23
+ auditNotes?: Record<string, unknown>;
24
+ /**
25
+ * For handoff: opt-in best-effort wake. Default true (PL-004 Phase A R1
26
+ * pattern: durable + waking by default; operators opt out for cold queues).
27
+ * notify failure does NOT roll back durable state.
28
+ */
29
+ notify?: boolean;
30
+ }
31
+ export interface MissionControlActionResult {
32
+ actionId: string;
33
+ verb: MissionControlVerb;
34
+ qitemId: string;
35
+ closedQitem: QueueItem | null;
36
+ createdQitemId: string | null;
37
+ notifyAttempted: boolean;
38
+ notifyResult: string | null;
39
+ auditedAt: string;
40
+ }
41
+ interface WriteContractDeps {
42
+ db: Database.Database;
43
+ eventBus: EventBus;
44
+ queueRepo: QueueRepository;
45
+ actionLog: MissionControlActionLog;
46
+ now?: () => Date;
47
+ }
48
+ export declare class MissionControlWriteContract {
49
+ private readonly db;
50
+ private readonly eventBus;
51
+ private readonly queueRepo;
52
+ private readonly actionLog;
53
+ private readonly now;
54
+ constructor(deps: WriteContractDeps);
55
+ /**
56
+ * Execute one verb. Atomic at the durable layer: queue mutation +
57
+ * audit record + event persistence in one transaction. Post-commit:
58
+ * notify subscribers + opt-in transport wake (handoff only).
59
+ */
60
+ act(input: MissionControlActionInput): Promise<MissionControlActionResult>;
61
+ /**
62
+ * Annotate has no queue mutation — only an audit record + event.
63
+ * Still wrapped in a transaction so the audit + event are atomic.
64
+ */
65
+ private annotateOnly;
66
+ private requireMutableQitem;
67
+ }
68
+ export {};
69
+ //# sourceMappingURL=mission-control-write-contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mission-control-write-contract.d.ts","sourceRoot":"","sources":["../../../src/domain/mission-control/mission-control-write-contract.ts"],"names":[],"mappings":"AAyCA,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEzE,OAAO,EACL,uBAAuB,EAEvB,KAAK,kBAAkB,EACxB,MAAM,iCAAiC,CAAC;AAEzC,qBAAa,gCAAiC,SAAQ,KAAK;aAEvC,IAAI,EAAE,MAAM;aAEZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gBAFjC,IAAI,EAAE,MAAM,EAC5B,OAAO,EAAE,MAAM,EACC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA;CAKpD;AAED,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,kBAAkB,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,kBAAkB,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,SAAS,GAAG,IAAI,CAAC;IAC9B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,eAAe,EAAE,OAAO,CAAC;IACzB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,iBAAiB;IACzB,EAAE,EAAE,QAAQ,CAAC,QAAQ,CAAC;IACtB,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,eAAe,CAAC;IAC3B,SAAS,EAAE,uBAAuB,CAAC;IACnC,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAClB;AAED,qBAAa,2BAA2B;IACtC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAoB;IACvC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;IACpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;IAC5C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA0B;IACpD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAa;gBAErB,IAAI,EAAE,iBAAiB;IAQnC;;;;OAIG;IACG,GAAG,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IA+HhF;;;OAGG;YACW,YAAY;IAkD1B,OAAO,CAAC,mBAAmB;CAkB5B"}
@@ -0,0 +1,300 @@
1
+ // PL-005 Phase A: Mission Control write-contract — atomic 7-verb actions.
2
+ //
3
+ // LOAD-BEARING. Per PRD § Acceptance Criteria + slice IMPL § Guard
4
+ // Checkpoint Focus item 2: each of 7 verbs is one atomic transaction.
5
+ // The 4-step `handoff` shape (source-update + destination-create +
6
+ // opt-in best-effort notify + audit-record append) is the canonical
7
+ // proof case; other 6 verbs follow the same atomic-update + audit
8
+ // shape with verb-specific metadata.
9
+ //
10
+ // Composition (one db.transaction per verb call):
11
+ // 1. Verify the target qitem exists and isn't already terminal.
12
+ // 2. Compute the verb-specific queue mutation via Phase D's
13
+ // QueueRepository.updateWithinTransaction (preserves Phase A
14
+ // hot-potato closure validation; emits queue.updated event).
15
+ // 3. For handoff: also call QueueRepository.createWithinTransaction
16
+ // to make the destination packet (the same outer txn).
17
+ // 4. Append the mission_control_actions audit record with before +
18
+ // after state snapshots.
19
+ // 5. Persist the mission_control.action_executed event.
20
+ //
21
+ // Post-commit (outside the transaction): notifySubscribers + opt-in
22
+ // best-effort transport notify. Notify failure does NOT roll back
23
+ // durable mutations (PRD invariant: "notify failure does NOT roll
24
+ // back durable mutations").
25
+ //
26
+ // Verb mappings:
27
+ // approve → state="done", closure_reason="no-follow-on"
28
+ // deny → state="done", closure_reason="denied"
29
+ // route → state="done", closure_reason="handed_off_to",
30
+ // closure_target+handed_off_to=<route target>;
31
+ // creates new qitem at the route target (1-hop)
32
+ // annotate → no queue mutation; audit record only (annotation field
33
+ // attached to mission_control_actions)
34
+ // hold → state="blocked", closure_reason="blocked_on",
35
+ // closure_target+blocked_on=<reason text>
36
+ // drop → state="done", closure_reason="canceled",
37
+ // closure_target=<reason>
38
+ // handoff → state="handed-off", closure_reason="handed_off_to",
39
+ // closure_target+handed_off_to=<destination>;
40
+ // creates new qitem at destination (4-step canonical)
41
+ import { MissionControlActionLogError, } from "./mission-control-action-log.js";
42
+ export class MissionControlWriteContractError extends Error {
43
+ code;
44
+ details;
45
+ constructor(code, message, details) {
46
+ super(message);
47
+ this.code = code;
48
+ this.details = details;
49
+ this.name = "MissionControlWriteContractError";
50
+ }
51
+ }
52
+ export class MissionControlWriteContract {
53
+ db;
54
+ eventBus;
55
+ queueRepo;
56
+ actionLog;
57
+ now;
58
+ constructor(deps) {
59
+ this.db = deps.db;
60
+ this.eventBus = deps.eventBus;
61
+ this.queueRepo = deps.queueRepo;
62
+ this.actionLog = deps.actionLog;
63
+ this.now = deps.now ?? (() => new Date());
64
+ }
65
+ /**
66
+ * Execute one verb. Atomic at the durable layer: queue mutation +
67
+ * audit record + event persistence in one transaction. Post-commit:
68
+ * notify subscribers + opt-in transport wake (handoff only).
69
+ */
70
+ async act(input) {
71
+ if (input.verb === "annotate") {
72
+ return this.annotateOnly(input);
73
+ }
74
+ const source = this.requireMutableQitem(input.qitemId);
75
+ if ((input.verb === "route" || input.verb === "handoff") && !input.destinationSession) {
76
+ throw new MissionControlWriteContractError("destination_required", `verb=${input.verb} requires destinationSession`, { verb: input.verb });
77
+ }
78
+ const evaluatedAt = this.now().toISOString();
79
+ const closure = verbToClosure(input);
80
+ const beforeSnapshot = snapshotQitem(source);
81
+ let createdQitemId = null;
82
+ let createdDestination;
83
+ let createdNudge;
84
+ let actionEntry = null;
85
+ const persistedEvents = [];
86
+ const txn = this.db.transaction(() => {
87
+ // 1. Close/transition the source via Phase A's queue closure primitive.
88
+ const closeResult = this.queueRepo.updateWithinTransaction({
89
+ qitemId: input.qitemId,
90
+ actorSession: input.actorSession,
91
+ state: closure.state,
92
+ closureReason: closure.closureReason,
93
+ closureTarget: closure.closureTarget ?? undefined,
94
+ handedOffTo: closure.handedOffTo,
95
+ blockedOn: closure.blockedOn,
96
+ transitionNote: `mission-control:${input.verb}${input.reason ? ` (${input.reason})` : ""}`,
97
+ });
98
+ persistedEvents.push(closeResult.persistedEvent);
99
+ // 2. For route/handoff: create the destination packet in same txn.
100
+ if ((input.verb === "route" || input.verb === "handoff") && input.destinationSession) {
101
+ const created = this.queueRepo.createWithinTransaction({
102
+ sourceSession: input.actorSession,
103
+ destinationSession: input.destinationSession,
104
+ body: input.body ?? source.body,
105
+ priority: source.priority,
106
+ tier: source.tier ?? undefined,
107
+ tags: source.tags
108
+ ? [...source.tags, `mission-control:${input.verb}`]
109
+ : [`mission-control:${input.verb}`],
110
+ chainOfRecord: [...(source.chainOfRecord ?? []), input.qitemId],
111
+ // Default nudge handled post-commit per Phase D pattern.
112
+ nudge: input.notify,
113
+ });
114
+ createdQitemId = created.qitemId;
115
+ createdDestination = created.destinationSession;
116
+ createdNudge = created.nudge;
117
+ persistedEvents.push(created.persistedEvent);
118
+ }
119
+ // 3. Append the audit record. Snapshot the closed qitem state.
120
+ const closedQitem = this.queueRepo.getById(input.qitemId);
121
+ const afterSnapshot = closedQitem ? snapshotQitem(closedQitem) : null;
122
+ actionEntry = this.actionLog.record({
123
+ actionVerb: input.verb,
124
+ qitemId: input.qitemId,
125
+ actorSession: input.actorSession,
126
+ actedAt: evaluatedAt,
127
+ beforeState: beforeSnapshot,
128
+ afterState: afterSnapshot,
129
+ reason: input.reason ?? null,
130
+ annotation: input.annotation ?? null,
131
+ notifyAttempted: false,
132
+ notifyResult: null,
133
+ auditNotes: input.auditNotes ?? null,
134
+ });
135
+ // 4. Persist the mission_control.action_executed event in same txn.
136
+ persistedEvents.push(this.eventBus.persistWithinTransaction({
137
+ type: "mission_control.action_executed",
138
+ actionId: actionEntry.actionId,
139
+ actionVerb: input.verb,
140
+ qitemId: input.qitemId,
141
+ actorSession: input.actorSession,
142
+ }));
143
+ });
144
+ try {
145
+ txn();
146
+ }
147
+ catch (err) {
148
+ if (err instanceof MissionControlActionLogError) {
149
+ throw new MissionControlWriteContractError(err.code, err.message, err.details);
150
+ }
151
+ throw err;
152
+ }
153
+ // Post-commit: fan out events.
154
+ for (const e of persistedEvents)
155
+ this.eventBus.notifySubscribers(e);
156
+ // Post-commit best-effort notify on handoff/route. Default true per
157
+ // PL-004 R1 pattern; failure does NOT roll back durable mutations.
158
+ let notifyAttempted = false;
159
+ let notifyResult = null;
160
+ if (createdQitemId && createdDestination && (input.verb === "route" || input.verb === "handoff")) {
161
+ try {
162
+ await this.queueRepo.maybeNudge(createdQitemId, createdDestination, createdNudge);
163
+ notifyAttempted = createdNudge !== false;
164
+ notifyResult = notifyAttempted ? "attempted-best-effort" : "skipped";
165
+ }
166
+ catch (err) {
167
+ notifyAttempted = true;
168
+ notifyResult = `failed:${err instanceof Error ? err.message : String(err)}`;
169
+ }
170
+ }
171
+ return {
172
+ actionId: actionEntry.actionId,
173
+ verb: input.verb,
174
+ qitemId: input.qitemId,
175
+ closedQitem: this.queueRepo.getById(input.qitemId),
176
+ createdQitemId,
177
+ notifyAttempted,
178
+ notifyResult,
179
+ auditedAt: evaluatedAt,
180
+ };
181
+ }
182
+ /**
183
+ * Annotate has no queue mutation — only an audit record + event.
184
+ * Still wrapped in a transaction so the audit + event are atomic.
185
+ */
186
+ async annotateOnly(input) {
187
+ if (!input.annotation) {
188
+ throw new MissionControlWriteContractError("annotation_required", `verb=annotate requires annotation`, { verb: input.verb });
189
+ }
190
+ const source = this.requireMutableQitem(input.qitemId);
191
+ const snapshot = snapshotQitem(source);
192
+ const evaluatedAt = this.now().toISOString();
193
+ let actionEntry = null;
194
+ const persistedEvents = [];
195
+ const txn = this.db.transaction(() => {
196
+ actionEntry = this.actionLog.record({
197
+ actionVerb: "annotate",
198
+ qitemId: input.qitemId,
199
+ actorSession: input.actorSession,
200
+ actedAt: evaluatedAt,
201
+ beforeState: snapshot,
202
+ afterState: snapshot,
203
+ annotation: input.annotation,
204
+ auditNotes: input.auditNotes ?? null,
205
+ });
206
+ persistedEvents.push(this.eventBus.persistWithinTransaction({
207
+ type: "mission_control.action_executed",
208
+ actionId: actionEntry.actionId,
209
+ actionVerb: "annotate",
210
+ qitemId: input.qitemId,
211
+ actorSession: input.actorSession,
212
+ }));
213
+ });
214
+ txn();
215
+ for (const e of persistedEvents)
216
+ this.eventBus.notifySubscribers(e);
217
+ return {
218
+ actionId: actionEntry.actionId,
219
+ verb: "annotate",
220
+ qitemId: input.qitemId,
221
+ closedQitem: this.queueRepo.getById(input.qitemId),
222
+ createdQitemId: null,
223
+ notifyAttempted: false,
224
+ notifyResult: null,
225
+ auditedAt: evaluatedAt,
226
+ };
227
+ }
228
+ requireMutableQitem(qitemId) {
229
+ const source = this.queueRepo.getById(qitemId);
230
+ if (!source) {
231
+ throw new MissionControlWriteContractError("qitem_not_found", `qitem ${qitemId} not found`, { qitemId });
232
+ }
233
+ if (source.state === "done" || source.state === "handed-off") {
234
+ throw new MissionControlWriteContractError("qitem_already_terminal", `qitem ${qitemId} is already terminal (state=${source.state}); Mission Control cannot mutate terminal items`, { qitemId, state: source.state });
235
+ }
236
+ return source;
237
+ }
238
+ }
239
+ function verbToClosure(input) {
240
+ switch (input.verb) {
241
+ case "approve":
242
+ return {
243
+ state: "done",
244
+ closureReason: "no-follow-on",
245
+ closureTarget: input.reason ?? null,
246
+ };
247
+ case "deny":
248
+ return {
249
+ state: "done",
250
+ closureReason: "denied",
251
+ closureTarget: input.reason ?? "operator denied",
252
+ };
253
+ case "route":
254
+ return {
255
+ state: "handed-off",
256
+ closureReason: "handed_off_to",
257
+ closureTarget: input.destinationSession,
258
+ handedOffTo: input.destinationSession,
259
+ };
260
+ case "hold":
261
+ return {
262
+ state: "blocked",
263
+ closureReason: "blocked_on",
264
+ closureTarget: input.reason,
265
+ blockedOn: input.reason,
266
+ };
267
+ case "drop":
268
+ return {
269
+ state: "done",
270
+ closureReason: "canceled",
271
+ closureTarget: input.reason,
272
+ };
273
+ case "handoff":
274
+ return {
275
+ state: "handed-off",
276
+ closureReason: "handed_off_to",
277
+ closureTarget: input.destinationSession,
278
+ handedOffTo: input.destinationSession,
279
+ };
280
+ case "annotate":
281
+ // Should never reach here — annotate is handled by annotateOnly().
282
+ throw new MissionControlWriteContractError("internal_invariant", "annotate verb should have been routed to annotateOnly");
283
+ }
284
+ }
285
+ function snapshotQitem(q) {
286
+ return {
287
+ qitemId: q.qitemId,
288
+ state: q.state,
289
+ sourceSession: q.sourceSession,
290
+ destinationSession: q.destinationSession,
291
+ priority: q.priority,
292
+ tier: q.tier,
293
+ closureReason: q.closureReason,
294
+ closureTarget: q.closureTarget,
295
+ handedOffTo: q.handedOffTo,
296
+ blockedOn: q.blockedOn,
297
+ tsUpdated: q.tsUpdated,
298
+ };
299
+ }
300
+ //# sourceMappingURL=mission-control-write-contract.js.map