@mclawnet/swarm 0.1.12 → 0.1.14

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 (368) hide show
  1. package/dist/__tests__/always-on-activity-reader.test.d.ts +2 -0
  2. package/dist/__tests__/always-on-activity-reader.test.d.ts.map +1 -0
  3. package/dist/__tests__/always-on-activity-reader.test.js +193 -0
  4. package/dist/__tests__/always-on-activity-reader.test.js.map +1 -0
  5. package/dist/__tests__/always-on-config.test.d.ts +2 -0
  6. package/dist/__tests__/always-on-config.test.d.ts.map +1 -0
  7. package/dist/__tests__/always-on-config.test.js +285 -0
  8. package/dist/__tests__/always-on-config.test.js.map +1 -0
  9. package/dist/__tests__/always-on-manager.test.d.ts +2 -0
  10. package/dist/__tests__/always-on-manager.test.d.ts.map +1 -0
  11. package/dist/__tests__/always-on-manager.test.js +797 -0
  12. package/dist/__tests__/always-on-manager.test.js.map +1 -0
  13. package/dist/__tests__/always-on-parity.test.d.ts +2 -0
  14. package/dist/__tests__/always-on-parity.test.d.ts.map +1 -0
  15. package/dist/__tests__/always-on-parity.test.js +20 -0
  16. package/dist/__tests__/always-on-parity.test.js.map +1 -0
  17. package/dist/__tests__/cascade-picker.test.d.ts +2 -0
  18. package/dist/__tests__/cascade-picker.test.d.ts.map +1 -0
  19. package/dist/__tests__/cascade-picker.test.js +122 -0
  20. package/dist/__tests__/cascade-picker.test.js.map +1 -0
  21. package/dist/__tests__/coordinator-shipment.test.d.ts +2 -0
  22. package/dist/__tests__/coordinator-shipment.test.d.ts.map +1 -0
  23. package/dist/__tests__/coordinator-shipment.test.js +280 -0
  24. package/dist/__tests__/coordinator-shipment.test.js.map +1 -0
  25. package/dist/__tests__/coordinator-workspace-recover.test.d.ts +2 -0
  26. package/dist/__tests__/coordinator-workspace-recover.test.d.ts.map +1 -0
  27. package/dist/__tests__/coordinator-workspace-recover.test.js +140 -0
  28. package/dist/__tests__/coordinator-workspace-recover.test.js.map +1 -0
  29. package/dist/__tests__/coordinator-workspace.test.d.ts +2 -0
  30. package/dist/__tests__/coordinator-workspace.test.d.ts.map +1 -0
  31. package/dist/__tests__/coordinator-workspace.test.js +135 -0
  32. package/dist/__tests__/coordinator-workspace.test.js.map +1 -0
  33. package/dist/__tests__/default-runner-epipe.test.d.ts +2 -0
  34. package/dist/__tests__/default-runner-epipe.test.d.ts.map +1 -0
  35. package/dist/__tests__/default-runner-epipe.test.js +43 -0
  36. package/dist/__tests__/default-runner-epipe.test.js.map +1 -0
  37. package/dist/__tests__/discovery-scheduler.test.d.ts +2 -0
  38. package/dist/__tests__/discovery-scheduler.test.d.ts.map +1 -0
  39. package/dist/__tests__/discovery-scheduler.test.js +367 -0
  40. package/dist/__tests__/discovery-scheduler.test.js.map +1 -0
  41. package/dist/__tests__/env-forward-e2e.test.d.ts +2 -0
  42. package/dist/__tests__/env-forward-e2e.test.d.ts.map +1 -0
  43. package/dist/__tests__/env-forward-e2e.test.js +57 -0
  44. package/dist/__tests__/env-forward-e2e.test.js.map +1 -0
  45. package/dist/__tests__/gh-pr-creator.test.d.ts +2 -0
  46. package/dist/__tests__/gh-pr-creator.test.d.ts.map +1 -0
  47. package/dist/__tests__/gh-pr-creator.test.js +107 -0
  48. package/dist/__tests__/gh-pr-creator.test.js.map +1 -0
  49. package/dist/__tests__/git-worktree-provider.test.d.ts +2 -0
  50. package/dist/__tests__/git-worktree-provider.test.d.ts.map +1 -0
  51. package/dist/__tests__/git-worktree-provider.test.js +98 -0
  52. package/dist/__tests__/git-worktree-provider.test.js.map +1 -0
  53. package/dist/__tests__/gitignore-check.test.d.ts +2 -0
  54. package/dist/__tests__/gitignore-check.test.d.ts.map +1 -0
  55. package/dist/__tests__/gitignore-check.test.js +39 -0
  56. package/dist/__tests__/gitignore-check.test.js.map +1 -0
  57. package/dist/__tests__/idea-research-source.test.d.ts +2 -0
  58. package/dist/__tests__/idea-research-source.test.d.ts.map +1 -0
  59. package/dist/__tests__/idea-research-source.test.js +425 -0
  60. package/dist/__tests__/idea-research-source.test.js.map +1 -0
  61. package/dist/__tests__/idea-todo-source.test.d.ts +2 -0
  62. package/dist/__tests__/idea-todo-source.test.d.ts.map +1 -0
  63. package/dist/__tests__/idea-todo-source.test.js +258 -0
  64. package/dist/__tests__/idea-todo-source.test.js.map +1 -0
  65. package/dist/__tests__/inbox-store-notbefore.test.d.ts +2 -0
  66. package/dist/__tests__/inbox-store-notbefore.test.d.ts.map +1 -0
  67. package/dist/__tests__/inbox-store-notbefore.test.js +47 -0
  68. package/dist/__tests__/inbox-store-notbefore.test.js.map +1 -0
  69. package/dist/__tests__/inbox-store-swarmid-validation.test.d.ts +2 -0
  70. package/dist/__tests__/inbox-store-swarmid-validation.test.d.ts.map +1 -0
  71. package/dist/__tests__/inbox-store-swarmid-validation.test.js +32 -0
  72. package/dist/__tests__/inbox-store-swarmid-validation.test.js.map +1 -0
  73. package/dist/__tests__/introspection-dedupe.test.d.ts +2 -0
  74. package/dist/__tests__/introspection-dedupe.test.d.ts.map +1 -0
  75. package/dist/__tests__/introspection-dedupe.test.js +484 -0
  76. package/dist/__tests__/introspection-dedupe.test.js.map +1 -0
  77. package/dist/__tests__/introspection-source.test.d.ts +2 -0
  78. package/dist/__tests__/introspection-source.test.d.ts.map +1 -0
  79. package/dist/__tests__/introspection-source.test.js +1051 -0
  80. package/dist/__tests__/introspection-source.test.js.map +1 -0
  81. package/dist/__tests__/migration-roles.test.js +1 -22
  82. package/dist/__tests__/migration-roles.test.js.map +1 -1
  83. package/dist/__tests__/reconcile-researching.test.d.ts +2 -0
  84. package/dist/__tests__/reconcile-researching.test.d.ts.map +1 -0
  85. package/dist/__tests__/reconcile-researching.test.js +224 -0
  86. package/dist/__tests__/reconcile-researching.test.js.map +1 -0
  87. package/dist/__tests__/role-loader-editor.test.js +40 -10
  88. package/dist/__tests__/role-loader-editor.test.js.map +1 -1
  89. package/dist/__tests__/role-loader-preamble-all.test.js +3 -1
  90. package/dist/__tests__/role-loader-preamble-all.test.js.map +1 -1
  91. package/dist/__tests__/role-loader.test.js +95 -0
  92. package/dist/__tests__/role-loader.test.js.map +1 -1
  93. package/dist/__tests__/role-prompt-no-legacy-protocol.test.js +3 -1
  94. package/dist/__tests__/role-prompt-no-legacy-protocol.test.js.map +1 -1
  95. package/dist/__tests__/secret-scrub.test.d.ts +2 -0
  96. package/dist/__tests__/secret-scrub.test.d.ts.map +1 -0
  97. package/dist/__tests__/secret-scrub.test.js +55 -0
  98. package/dist/__tests__/secret-scrub.test.js.map +1 -0
  99. package/dist/__tests__/shipment-actions.test.d.ts +2 -0
  100. package/dist/__tests__/shipment-actions.test.d.ts.map +1 -0
  101. package/dist/__tests__/shipment-actions.test.js +378 -0
  102. package/dist/__tests__/shipment-actions.test.js.map +1 -0
  103. package/dist/__tests__/shipment-persistence.test.d.ts +2 -0
  104. package/dist/__tests__/shipment-persistence.test.d.ts.map +1 -0
  105. package/dist/__tests__/shipment-persistence.test.js +120 -0
  106. package/dist/__tests__/shipment-persistence.test.js.map +1 -0
  107. package/dist/__tests__/shipment-pipeline.test.d.ts +2 -0
  108. package/dist/__tests__/shipment-pipeline.test.d.ts.map +1 -0
  109. package/dist/__tests__/shipment-pipeline.test.js +392 -0
  110. package/dist/__tests__/shipment-pipeline.test.js.map +1 -0
  111. package/dist/__tests__/shipment-report.test.d.ts +2 -0
  112. package/dist/__tests__/shipment-report.test.d.ts.map +1 -0
  113. package/dist/__tests__/shipment-report.test.js +78 -0
  114. package/dist/__tests__/shipment-report.test.js.map +1 -0
  115. package/dist/__tests__/shipment-stdin-integration.test.d.ts +2 -0
  116. package/dist/__tests__/shipment-stdin-integration.test.d.ts.map +1 -0
  117. package/dist/__tests__/shipment-stdin-integration.test.js +49 -0
  118. package/dist/__tests__/shipment-stdin-integration.test.js.map +1 -0
  119. package/dist/__tests__/shipment-type-parity.test.d.ts +2 -0
  120. package/dist/__tests__/shipment-type-parity.test.d.ts.map +1 -0
  121. package/dist/__tests__/shipment-type-parity.test.js +10 -0
  122. package/dist/__tests__/shipment-type-parity.test.js.map +1 -0
  123. package/dist/__tests__/snapshot-copy-provider.test.d.ts +2 -0
  124. package/dist/__tests__/snapshot-copy-provider.test.d.ts.map +1 -0
  125. package/dist/__tests__/snapshot-copy-provider.test.js +88 -0
  126. package/dist/__tests__/snapshot-copy-provider.test.js.map +1 -0
  127. package/dist/__tests__/swarm-coordinator-backend.test.js +153 -0
  128. package/dist/__tests__/swarm-coordinator-backend.test.js.map +1 -1
  129. package/dist/__tests__/swarm-coordinator-complete-intercept.test.d.ts +2 -0
  130. package/dist/__tests__/swarm-coordinator-complete-intercept.test.d.ts.map +1 -0
  131. package/dist/__tests__/swarm-coordinator-complete-intercept.test.js +111 -0
  132. package/dist/__tests__/swarm-coordinator-complete-intercept.test.js.map +1 -0
  133. package/dist/__tests__/task-store-source.test.d.ts +2 -0
  134. package/dist/__tests__/task-store-source.test.d.ts.map +1 -0
  135. package/dist/__tests__/task-store-source.test.js +56 -0
  136. package/dist/__tests__/task-store-source.test.js.map +1 -0
  137. package/dist/__tests__/template-loader-editor.test.js +28 -13
  138. package/dist/__tests__/template-loader-editor.test.js.map +1 -1
  139. package/dist/__tests__/transport-detect.test.d.ts +2 -0
  140. package/dist/__tests__/transport-detect.test.d.ts.map +1 -0
  141. package/dist/__tests__/transport-detect.test.js +92 -0
  142. package/dist/__tests__/transport-detect.test.js.map +1 -0
  143. package/dist/__tests__/wakeup-end-to-end.test.d.ts +2 -0
  144. package/dist/__tests__/wakeup-end-to-end.test.d.ts.map +1 -0
  145. package/dist/__tests__/wakeup-end-to-end.test.js +80 -0
  146. package/dist/__tests__/wakeup-end-to-end.test.js.map +1 -0
  147. package/dist/__tests__/wakeup-scheduler-restore-fires.test.d.ts +2 -0
  148. package/dist/__tests__/wakeup-scheduler-restore-fires.test.d.ts.map +1 -0
  149. package/dist/__tests__/wakeup-scheduler-restore-fires.test.js +33 -0
  150. package/dist/__tests__/wakeup-scheduler-restore-fires.test.js.map +1 -0
  151. package/dist/__tests__/wakeup-scheduler-restore.test.d.ts +2 -0
  152. package/dist/__tests__/wakeup-scheduler-restore.test.d.ts.map +1 -0
  153. package/dist/__tests__/wakeup-scheduler-restore.test.js +62 -0
  154. package/dist/__tests__/wakeup-scheduler-restore.test.js.map +1 -0
  155. package/dist/__tests__/wakeup-scheduler.test.d.ts +2 -0
  156. package/dist/__tests__/wakeup-scheduler.test.d.ts.map +1 -0
  157. package/dist/__tests__/wakeup-scheduler.test.js +65 -0
  158. package/dist/__tests__/wakeup-scheduler.test.js.map +1 -0
  159. package/dist/__tests__/watch-manager.test.d.ts +2 -0
  160. package/dist/__tests__/watch-manager.test.d.ts.map +1 -0
  161. package/dist/__tests__/watch-manager.test.js +203 -0
  162. package/dist/__tests__/watch-manager.test.js.map +1 -0
  163. package/dist/__tests__/workcycle-runner-cascade.test.d.ts +2 -0
  164. package/dist/__tests__/workcycle-runner-cascade.test.d.ts.map +1 -0
  165. package/dist/__tests__/workcycle-runner-cascade.test.js +203 -0
  166. package/dist/__tests__/workcycle-runner-cascade.test.js.map +1 -0
  167. package/dist/__tests__/workcycle-runner.test.d.ts +2 -0
  168. package/dist/__tests__/workcycle-runner.test.d.ts.map +1 -0
  169. package/dist/__tests__/workcycle-runner.test.js +369 -0
  170. package/dist/__tests__/workcycle-runner.test.js.map +1 -0
  171. package/dist/__tests__/workspace-diff.test.d.ts +2 -0
  172. package/dist/__tests__/workspace-diff.test.d.ts.map +1 -0
  173. package/dist/__tests__/workspace-diff.test.js +62 -0
  174. package/dist/__tests__/workspace-diff.test.js.map +1 -0
  175. package/dist/__tests__/workspace-manager.test.d.ts +2 -0
  176. package/dist/__tests__/workspace-manager.test.d.ts.map +1 -0
  177. package/dist/__tests__/workspace-manager.test.js +120 -0
  178. package/dist/__tests__/workspace-manager.test.js.map +1 -0
  179. package/dist/__tests__/workspace-types.test.d.ts +2 -0
  180. package/dist/__tests__/workspace-types.test.d.ts.map +1 -0
  181. package/dist/__tests__/workspace-types.test.js +37 -0
  182. package/dist/__tests__/workspace-types.test.js.map +1 -0
  183. package/dist/__tests__/worktree-gc.test.d.ts +2 -0
  184. package/dist/__tests__/worktree-gc.test.d.ts.map +1 -0
  185. package/dist/__tests__/worktree-gc.test.js +183 -0
  186. package/dist/__tests__/worktree-gc.test.js.map +1 -0
  187. package/dist/always-on/activity-reader.d.ts +27 -0
  188. package/dist/always-on/activity-reader.d.ts.map +1 -0
  189. package/dist/always-on/activity-reader.js +95 -0
  190. package/dist/always-on/activity-reader.js.map +1 -0
  191. package/dist/always-on/always-on-manager.d.ts +170 -0
  192. package/dist/always-on/always-on-manager.d.ts.map +1 -0
  193. package/dist/always-on/always-on-manager.js +538 -0
  194. package/dist/always-on/always-on-manager.js.map +1 -0
  195. package/dist/always-on/config.d.ts +141 -0
  196. package/dist/always-on/config.d.ts.map +1 -0
  197. package/dist/always-on/config.js +324 -0
  198. package/dist/always-on/config.js.map +1 -0
  199. package/dist/always-on/discovery-scheduler.d.ts +60 -0
  200. package/dist/always-on/discovery-scheduler.d.ts.map +1 -0
  201. package/dist/always-on/discovery-scheduler.js +287 -0
  202. package/dist/always-on/discovery-scheduler.js.map +1 -0
  203. package/dist/always-on/ideas-client.d.ts +23 -0
  204. package/dist/always-on/ideas-client.d.ts.map +1 -0
  205. package/dist/always-on/ideas-client.js +13 -0
  206. package/dist/always-on/ideas-client.js.map +1 -0
  207. package/dist/always-on/reconcile-researching.d.ts +42 -0
  208. package/dist/always-on/reconcile-researching.d.ts.map +1 -0
  209. package/dist/always-on/reconcile-researching.js +133 -0
  210. package/dist/always-on/reconcile-researching.js.map +1 -0
  211. package/dist/always-on/task-sources/cascade-picker.d.ts +42 -0
  212. package/dist/always-on/task-sources/cascade-picker.d.ts.map +1 -0
  213. package/dist/always-on/task-sources/cascade-picker.js +65 -0
  214. package/dist/always-on/task-sources/cascade-picker.js.map +1 -0
  215. package/dist/always-on/task-sources/idea-dedupe.d.ts +62 -0
  216. package/dist/always-on/task-sources/idea-dedupe.d.ts.map +1 -0
  217. package/dist/always-on/task-sources/idea-dedupe.js +130 -0
  218. package/dist/always-on/task-sources/idea-dedupe.js.map +1 -0
  219. package/dist/always-on/task-sources/idea-research-source.d.ts +46 -0
  220. package/dist/always-on/task-sources/idea-research-source.d.ts.map +1 -0
  221. package/dist/always-on/task-sources/idea-research-source.js +308 -0
  222. package/dist/always-on/task-sources/idea-research-source.js.map +1 -0
  223. package/dist/always-on/task-sources/idea-sort.d.ts +3 -0
  224. package/dist/always-on/task-sources/idea-sort.d.ts.map +1 -0
  225. package/dist/always-on/task-sources/idea-sort.js +25 -0
  226. package/dist/always-on/task-sources/idea-sort.js.map +1 -0
  227. package/dist/always-on/task-sources/idea-todo-source.d.ts +48 -0
  228. package/dist/always-on/task-sources/idea-todo-source.d.ts.map +1 -0
  229. package/dist/always-on/task-sources/idea-todo-source.js +226 -0
  230. package/dist/always-on/task-sources/idea-todo-source.js.map +1 -0
  231. package/dist/always-on/task-sources/introspection-source.d.ts +101 -0
  232. package/dist/always-on/task-sources/introspection-source.d.ts.map +1 -0
  233. package/dist/always-on/task-sources/introspection-source.js +695 -0
  234. package/dist/always-on/task-sources/introspection-source.js.map +1 -0
  235. package/dist/always-on/task-sources/task-store-source.d.ts +15 -0
  236. package/dist/always-on/task-sources/task-store-source.d.ts.map +1 -0
  237. package/dist/always-on/task-sources/task-store-source.js +59 -0
  238. package/dist/always-on/task-sources/task-store-source.js.map +1 -0
  239. package/dist/always-on/task-sources/types.d.ts +108 -0
  240. package/dist/always-on/task-sources/types.d.ts.map +1 -0
  241. package/dist/always-on/task-sources/types.js +13 -0
  242. package/dist/always-on/task-sources/types.js.map +1 -0
  243. package/dist/always-on/types.d.ts +76 -0
  244. package/dist/always-on/types.d.ts.map +1 -0
  245. package/dist/always-on/types.js +17 -0
  246. package/dist/always-on/types.js.map +1 -0
  247. package/dist/always-on/workcycle-runner.d.ts +115 -0
  248. package/dist/always-on/workcycle-runner.d.ts.map +1 -0
  249. package/dist/always-on/workcycle-runner.js +285 -0
  250. package/dist/always-on/workcycle-runner.js.map +1 -0
  251. package/dist/always-on/worktree-gc.d.ts +41 -0
  252. package/dist/always-on/worktree-gc.d.ts.map +1 -0
  253. package/dist/always-on/worktree-gc.js +167 -0
  254. package/dist/always-on/worktree-gc.js.map +1 -0
  255. package/dist/inbox-store.d.ts +7 -0
  256. package/dist/inbox-store.d.ts.map +1 -1
  257. package/dist/inbox-store.js +8 -1
  258. package/dist/inbox-store.js.map +1 -1
  259. package/dist/index.d.ts +29 -3
  260. package/dist/index.d.ts.map +1 -1
  261. package/dist/index.js +27 -2
  262. package/dist/index.js.map +1 -1
  263. package/dist/persistence.d.ts +37 -1
  264. package/dist/persistence.d.ts.map +1 -1
  265. package/dist/persistence.js +48 -0
  266. package/dist/persistence.js.map +1 -1
  267. package/dist/retrospective.d.ts.map +1 -1
  268. package/dist/retrospective.js +6 -0
  269. package/dist/retrospective.js.map +1 -1
  270. package/dist/roles/role-loader.d.ts +31 -6
  271. package/dist/roles/role-loader.d.ts.map +1 -1
  272. package/dist/roles/role-loader.js +58 -32
  273. package/dist/roles/role-loader.js.map +1 -1
  274. package/dist/roles/types.d.ts +12 -0
  275. package/dist/roles/types.d.ts.map +1 -1
  276. package/dist/shipment/gh-pr-creator.d.ts +28 -0
  277. package/dist/shipment/gh-pr-creator.d.ts.map +1 -0
  278. package/dist/shipment/gh-pr-creator.js +80 -0
  279. package/dist/shipment/gh-pr-creator.js.map +1 -0
  280. package/dist/shipment/report.d.ts +27 -0
  281. package/dist/shipment/report.d.ts.map +1 -0
  282. package/dist/shipment/report.js +41 -0
  283. package/dist/shipment/report.js.map +1 -0
  284. package/dist/shipment/secret-scrub.d.ts +12 -0
  285. package/dist/shipment/secret-scrub.d.ts.map +1 -0
  286. package/dist/shipment/secret-scrub.js +30 -0
  287. package/dist/shipment/secret-scrub.js.map +1 -0
  288. package/dist/shipment/shipment-actions.d.ts +85 -0
  289. package/dist/shipment/shipment-actions.d.ts.map +1 -0
  290. package/dist/shipment/shipment-actions.js +190 -0
  291. package/dist/shipment/shipment-actions.js.map +1 -0
  292. package/dist/shipment/shipment-pipeline.d.ts +48 -0
  293. package/dist/shipment/shipment-pipeline.d.ts.map +1 -0
  294. package/dist/shipment/shipment-pipeline.js +256 -0
  295. package/dist/shipment/shipment-pipeline.js.map +1 -0
  296. package/dist/shipment/transport-detect.d.ts +16 -0
  297. package/dist/shipment/transport-detect.d.ts.map +1 -0
  298. package/dist/shipment/transport-detect.js +54 -0
  299. package/dist/shipment/transport-detect.js.map +1 -0
  300. package/dist/shipment/workspace-diff.d.ts +39 -0
  301. package/dist/shipment/workspace-diff.d.ts.map +1 -0
  302. package/dist/shipment/workspace-diff.js +64 -0
  303. package/dist/shipment/workspace-diff.js.map +1 -0
  304. package/dist/swarm-coordinator.d.ts +20 -1
  305. package/dist/swarm-coordinator.d.ts.map +1 -1
  306. package/dist/swarm-coordinator.js +193 -10
  307. package/dist/swarm-coordinator.js.map +1 -1
  308. package/dist/templates/template-loader.d.ts +23 -9
  309. package/dist/templates/template-loader.d.ts.map +1 -1
  310. package/dist/templates/template-loader.js +33 -26
  311. package/dist/templates/template-loader.js.map +1 -1
  312. package/dist/types.d.ts +62 -0
  313. package/dist/types.d.ts.map +1 -1
  314. package/dist/wakeup-scheduler.d.ts +36 -0
  315. package/dist/wakeup-scheduler.d.ts.map +1 -0
  316. package/dist/wakeup-scheduler.js +107 -0
  317. package/dist/wakeup-scheduler.js.map +1 -0
  318. package/dist/watch-manager.d.ts +32 -0
  319. package/dist/watch-manager.d.ts.map +1 -0
  320. package/dist/watch-manager.js +153 -0
  321. package/dist/watch-manager.js.map +1 -0
  322. package/dist/workspace/git-worktree-provider.d.ts +11 -0
  323. package/dist/workspace/git-worktree-provider.d.ts.map +1 -0
  324. package/dist/workspace/git-worktree-provider.js +123 -0
  325. package/dist/workspace/git-worktree-provider.js.map +1 -0
  326. package/dist/workspace/gitignore-check.d.ts +10 -0
  327. package/dist/workspace/gitignore-check.d.ts.map +1 -0
  328. package/dist/workspace/gitignore-check.js +25 -0
  329. package/dist/workspace/gitignore-check.js.map +1 -0
  330. package/dist/workspace/index.d.ts +5 -0
  331. package/dist/workspace/index.d.ts.map +1 -0
  332. package/dist/workspace/index.js +5 -0
  333. package/dist/workspace/index.js.map +1 -0
  334. package/dist/workspace/snapshot-copy-provider.d.ts +11 -0
  335. package/dist/workspace/snapshot-copy-provider.d.ts.map +1 -0
  336. package/dist/workspace/snapshot-copy-provider.js +66 -0
  337. package/dist/workspace/snapshot-copy-provider.js.map +1 -0
  338. package/dist/workspace/types.d.ts +36 -0
  339. package/dist/workspace/types.d.ts.map +1 -0
  340. package/dist/workspace/types.js +2 -0
  341. package/dist/workspace/types.js.map +1 -0
  342. package/dist/workspace/workspace-manager.d.ts +30 -0
  343. package/dist/workspace/workspace-manager.d.ts.map +1 -0
  344. package/dist/workspace/workspace-manager.js +104 -0
  345. package/dist/workspace/workspace-manager.js.map +1 -0
  346. package/package.json +5 -5
  347. package/roles/queen.md +1 -0
  348. package/templates/introspection.md +64 -0
  349. package/templates/research-only.md +58 -0
  350. package/roles/preset-analyst-simons.md +0 -39
  351. package/roles/preset-architect-knuth.md +0 -39
  352. package/roles/preset-designer-norman.md +0 -39
  353. package/roles/preset-designer.md +0 -39
  354. package/roles/preset-dev-carmack.md +0 -39
  355. package/roles/preset-dev-gosling.md +0 -39
  356. package/roles/preset-developer.md +0 -52
  357. package/roles/preset-manager-grove.md +0 -39
  358. package/roles/preset-manager-musk.md +0 -39
  359. package/roles/preset-pm.md +0 -78
  360. package/roles/preset-researcher-feynman.md +0 -39
  361. package/roles/preset-reviewer.md +0 -46
  362. package/roles/preset-strategist-buffett.md +0 -39
  363. package/roles/preset-strategist-munger.md +0 -39
  364. package/roles/preset-strategist-sunzi.md +0 -39
  365. package/roles/preset-tester-beck.md +0 -40
  366. package/roles/preset-tester.md +0 -47
  367. package/roles/preset-writer-orwell.md +0 -39
  368. package/roles/preset-writer.md +0 -39
@@ -0,0 +1,37 @@
1
+ import { describe, it, expect } from "vitest";
2
+ describe("WorkspaceProvider types", () => {
3
+ it("WorkspaceHandle has the expected shape (compile-time + runtime sanity)", () => {
4
+ const h = {
5
+ swarmId: "s1",
6
+ projectRoot: "/proj",
7
+ strategy: "git-worktree",
8
+ cwd: "/proj/.worktrees/s1",
9
+ metadata: { repoRoot: "/proj", baseCommit: "abc123", branchName: "clawnet/swarm-s1" },
10
+ };
11
+ expect(h.strategy).toBe("git-worktree");
12
+ expect(h.metadata.branchName).toBe("clawnet/swarm-s1");
13
+ });
14
+ it("WorkspaceStrategy union admits both variants", () => {
15
+ const a = "git-worktree";
16
+ const b = "snapshot-copy";
17
+ expect([a, b]).toHaveLength(2);
18
+ });
19
+ it("WorkspaceProvider interface enforces the four members", () => {
20
+ // Compile-time only: this fake implementation must satisfy the interface.
21
+ const fake = {
22
+ id: "git-worktree",
23
+ priority: 1,
24
+ isApplicable: async () => true,
25
+ prepare: async (input) => ({
26
+ swarmId: input.swarmId,
27
+ projectRoot: input.projectRoot,
28
+ strategy: "git-worktree",
29
+ cwd: "/x",
30
+ metadata: {},
31
+ }),
32
+ dispose: async () => { },
33
+ };
34
+ expect(fake.id).toBe("git-worktree");
35
+ });
36
+ });
37
+ //# sourceMappingURL=workspace-types.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-types.test.js","sourceRoot":"","sources":["../../src/__tests__/workspace-types.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAG9C,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,EAAE,CAAC,wEAAwE,EAAE,GAAG,EAAE;QAChF,MAAM,CAAC,GAAoB;YACzB,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,OAAO;YACpB,QAAQ,EAAE,cAAc;YACxB,GAAG,EAAE,qBAAqB;YAC1B,QAAQ,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,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/worktree-gc.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,183 @@
1
+ import { describe, it, expect, beforeEach, afterEach } from "vitest";
2
+ import { mkdirSync, mkdtempSync, rmSync, writeFileSync, existsSync, utimesSync, } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ import { projectRoot } from "@mclawnet/task";
6
+ import { gcWorktrees, DEFAULT_WORKTREE_GC_AGE_MS } from "../always-on/worktree-gc.js";
7
+ let WORK;
8
+ let HOME;
9
+ beforeEach(() => {
10
+ WORK = mkdtempSync(join(tmpdir(), "wgc-work-"));
11
+ HOME = mkdtempSync(join(tmpdir(), "wgc-home-"));
12
+ mkdirSync(join(WORK, ".worktrees"), { recursive: true });
13
+ });
14
+ afterEach(() => {
15
+ try {
16
+ rmSync(WORK, { recursive: true, force: true });
17
+ }
18
+ catch { /* ignore */ }
19
+ try {
20
+ rmSync(HOME, { recursive: true, force: true });
21
+ }
22
+ catch { /* ignore */ }
23
+ });
24
+ /** Create a fake worktree dir with one file; back-date its mtime by `ageMs`. */
25
+ function seedWorktree(name, ageMs, fileBytes = 100) {
26
+ const dir = join(WORK, ".worktrees", name);
27
+ mkdirSync(dir, { recursive: true });
28
+ const fp = join(dir, "fake-file.txt");
29
+ writeFileSync(fp, "x".repeat(fileBytes));
30
+ const past = new Date(Date.now() - ageMs);
31
+ utimesSync(dir, past, past);
32
+ utimesSync(fp, past, past);
33
+ return dir;
34
+ }
35
+ /** Create a swarm snapshot at the conventional path with `status`. */
36
+ function seedSnapshot(swarmId, status) {
37
+ const dir = join(projectRoot(WORK, HOME), "swarms", swarmId);
38
+ mkdirSync(dir, { recursive: true });
39
+ writeFileSync(join(dir, "recovery.json"), JSON.stringify({ id: swarmId, workDir: WORK, status }));
40
+ }
41
+ describe("gcWorktrees (PR-B Sub-PR-B4)", () => {
42
+ it("retains active swarms regardless of age", async () => {
43
+ // An old dir but its swarm is still running → must NOT delete
44
+ seedWorktree("active-old", 48 * 3600 * 1000); // 48h ago
45
+ seedSnapshot("active-old", "running");
46
+ const r = gcWorktrees({ workDir: WORK, home: HOME });
47
+ expect(r.scanned).toBe(1);
48
+ expect(r.removed).toBe(0);
49
+ expect(r.retained).toBe(1);
50
+ expect(r.decisions[0]).toMatchObject({ name: "active-old", action: "retained-active" });
51
+ expect(existsSync(join(WORK, ".worktrees", "active-old"))).toBe(true);
52
+ });
53
+ it("retains young dirs (within 24h debug window) even when swarm is terminal", async () => {
54
+ seedWorktree("young-failed", 1 * 3600 * 1000); // 1h ago
55
+ seedSnapshot("young-failed", "failed");
56
+ const r = gcWorktrees({ workDir: WORK, home: HOME });
57
+ expect(r.removed).toBe(0);
58
+ expect(r.retained).toBe(1);
59
+ expect(r.decisions[0].action).toBe("retained-young");
60
+ expect(existsSync(join(WORK, ".worktrees", "young-failed"))).toBe(true);
61
+ });
62
+ it("removes old dirs whose swarm is terminal (completed/failed/cancelled)", async () => {
63
+ seedWorktree("old-completed", 48 * 3600 * 1000);
64
+ seedSnapshot("old-completed", "completed");
65
+ const r = gcWorktrees({ workDir: WORK, home: HOME });
66
+ expect(r.removed).toBe(1);
67
+ expect(r.retained).toBe(0);
68
+ expect(r.decisions[0].action).toBe("removed");
69
+ expect(existsSync(join(WORK, ".worktrees", "old-completed"))).toBe(false);
70
+ });
71
+ it("removes old dirs with NO matching snapshot at all (snapshot already cleaned up)", async () => {
72
+ seedWorktree("orphan-old", 48 * 3600 * 1000);
73
+ // No snapshot seeded — coordinator already evicted it
74
+ const r = gcWorktrees({ workDir: WORK, home: HOME });
75
+ expect(r.removed).toBe(1);
76
+ expect(existsSync(join(WORK, ".worktrees", "orphan-old"))).toBe(false);
77
+ });
78
+ it("treats paused as ACTIVE (D14 runner will promote it next tick)", async () => {
79
+ seedWorktree("paused-old", 48 * 3600 * 1000);
80
+ seedSnapshot("paused-old", "paused");
81
+ const r = gcWorktrees({ workDir: WORK, home: HOME });
82
+ expect(r.removed).toBe(0);
83
+ expect(r.retained).toBe(1);
84
+ expect(r.decisions[0].action).toBe("retained-active");
85
+ });
86
+ it("scans + reaps multiple entries without touching worktree contents", async () => {
87
+ // PR-B follow-up — replaces the original "reports total bytes" case.
88
+ // Size telemetry was deleted because the recursive readdirSync/statSync
89
+ // walk it required pegged the agent at 99% CPU for ~15min per tick
90
+ // when worktrees contained node_modules (~70k files each). The reap
91
+ // decision only needs scanned/removed/retained — never the byte total.
92
+ seedWorktree("a-active", 1000, 200);
93
+ seedSnapshot("a-active", "running");
94
+ seedWorktree("b-removed", 48 * 3600 * 1000, 500);
95
+ seedSnapshot("b-removed", "completed");
96
+ seedWorktree("c-young", 1000, 300);
97
+ const r = gcWorktrees({ workDir: WORK, home: HOME });
98
+ expect(r.scanned).toBe(3);
99
+ expect(r.removed).toBe(1);
100
+ expect(r.retained).toBe(2);
101
+ // Size telemetry intentionally absent — re-introducing it MUST NOT
102
+ // walk worktree contents. See the doc comment at the top of
103
+ // worktree-gc.ts. Type-level + runtime double guard: ts-expect-error
104
+ // catches the regression at `tsc` time (no need to run vitest),
105
+ // toHaveProperty catches it at runtime in case someone adds the
106
+ // field via index signature / Record cast.
107
+ // @ts-expect-error — totalBytesBefore intentionally removed; see worktree-gc.ts header
108
+ void r.totalBytesBefore;
109
+ // @ts-expect-error — totalBytesAfter intentionally removed; see worktree-gc.ts header
110
+ void r.totalBytesAfter;
111
+ // @ts-expect-error — decisions[i].bytes intentionally removed; see worktree-gc.ts header
112
+ void r.decisions[0].bytes;
113
+ expect(r).not.toHaveProperty("totalBytesBefore");
114
+ expect(r).not.toHaveProperty("totalBytesAfter");
115
+ expect(r.decisions[0]).not.toHaveProperty("bytes");
116
+ });
117
+ it("dryRun=true counts but doesn't actually delete", async () => {
118
+ seedWorktree("dry-old", 48 * 3600 * 1000);
119
+ seedSnapshot("dry-old", "completed");
120
+ const r = gcWorktrees({ workDir: WORK, home: HOME, dryRun: true });
121
+ expect(r.removed).toBe(1);
122
+ expect(r.decisions[0].action).toBe("removed");
123
+ // BUT the dir still exists
124
+ expect(existsSync(join(WORK, ".worktrees", "dry-old"))).toBe(true);
125
+ });
126
+ it("no .worktrees/ dir → empty result, no error", () => {
127
+ const fresh = mkdtempSync(join(tmpdir(), "wgc-empty-"));
128
+ try {
129
+ const r = gcWorktrees({ workDir: fresh, home: HOME });
130
+ expect(r.scanned).toBe(0);
131
+ expect(r.removed).toBe(0);
132
+ expect(r.retained).toBe(0);
133
+ expect(r.decisions).toEqual([]);
134
+ }
135
+ finally {
136
+ rmSync(fresh, { recursive: true, force: true });
137
+ }
138
+ });
139
+ it("default maxAgeMs is 24h", () => {
140
+ expect(DEFAULT_WORKTREE_GC_AGE_MS).toBe(24 * 60 * 60 * 1000);
141
+ });
142
+ // PR-B follow-up regression — the original safeDirBytes walked every
143
+ // file under every worktree synchronously, including node_modules. In
144
+ // production this issued ~1M sync stat syscalls per tick, pegged the
145
+ // agent at 99% CPU for ~15min, and froze the Node event loop (silent
146
+ // log, agent_timeout from hub, InboxWatcher fs.watch never fires,
147
+ // swarm_complete_request stays delivered=false). The fix deleted the
148
+ // recursive walker entirely. This test pins that door shut: even when
149
+ // a worktree contains a fake node_modules tree, the result shape MUST
150
+ // NOT carry per-entry byte counts. Anyone re-introducing the walker
151
+ // would have to re-add the fields too, which fails the structural
152
+ // assertions below.
153
+ it("retains heavy worktree without exposing per-entry byte fields", () => {
154
+ const wtName = "fake-heavy";
155
+ const wtDir = join(WORK, ".worktrees", wtName);
156
+ mkdirSync(wtDir, { recursive: true });
157
+ seedSnapshot(wtName, "running"); // mark active → retained-active branch
158
+ // Realistic-shape fake node_modules under the worktree: 200 files
159
+ // across 20 sub-dirs. Detail doesn't matter to the assertion — it's
160
+ // here purely to fail-fast if any code re-adds a recursive walker
161
+ // that would inflate per-tick wall clock.
162
+ const nm = join(wtDir, "node_modules");
163
+ for (let i = 0; i < 20; i++) {
164
+ const pkg = join(nm, `pkg-${i}`);
165
+ mkdirSync(pkg, { recursive: true });
166
+ for (let j = 0; j < 10; j++) {
167
+ writeFileSync(join(pkg, `f-${j}.js`), "x".repeat(50));
168
+ }
169
+ }
170
+ const r = gcWorktrees({ workDir: WORK, home: HOME });
171
+ expect(r.scanned).toBe(1);
172
+ expect(r.retained).toBe(1);
173
+ expect(r.decisions[0].action).toBe("retained-active");
174
+ // The structural guard: byte counts are gone. If a future change
175
+ // re-introduces safeDirBytes (or any sync recursive walk over
176
+ // worktree contents), it'll need to add these fields back AND
177
+ // update consumers — these assertions force the conversation.
178
+ expect(r).not.toHaveProperty("totalBytesBefore");
179
+ expect(r).not.toHaveProperty("totalBytesAfter");
180
+ expect(r.decisions[0]).not.toHaveProperty("bytes");
181
+ });
182
+ });
183
+ //# sourceMappingURL=worktree-gc.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worktree-gc.test.js","sourceRoot":"","sources":["../../src/__tests__/worktree-gc.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EACL,SAAS,EACT,WAAW,EACX,MAAM,EACN,aAAa,EACb,UAAU,EACV,UAAU,GACX,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAEtF,IAAI,IAAY,CAAC;AACjB,IAAI,IAAY,CAAC;AAEjB,UAAU,CAAC,GAAG,EAAE;IACd,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC;IAChD,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC;IAChD,SAAS,CAAC,IAAI,CAA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AAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC5B,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;QAED,MAAM,CAAC,GAAG,WAAW,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAErD,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC1B,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC3B,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAEtD,iEAAiE;QACjE,8DAA8D;QAC9D,8DAA8D;QAC9D,8DAA8D;QAC9D,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;QACjD,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;QAChD,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { AlwaysOnActivityRecord } from "@mclawnet/shared";
2
+ export interface ReadActivityOptions {
3
+ /** Clamped to [1, 500] by readAlwaysOnActivity. Default 100. */
4
+ limit?: number;
5
+ /** Default 0. */
6
+ skip?: number;
7
+ /** Optional filter on tick decision. */
8
+ decision?: "fired" | "skipped" | "halted";
9
+ }
10
+ export interface ReadActivityResult {
11
+ ticks: AlwaysOnActivityRecord[];
12
+ hasMore: boolean;
13
+ /** Total count AFTER decision filter, BEFORE pagination. */
14
+ total: number;
15
+ }
16
+ /**
17
+ * Parse the always-on.log file under <projectRoot> and return a paginated
18
+ * newest-first slice.
19
+ *
20
+ * Tolerant by design:
21
+ * - Missing file → empty result (NOT an error).
22
+ * - Blank lines → skipped.
23
+ * - JSON.parse errors → that line is skipped (NOT thrown), so a single
24
+ * corrupt line never 500s the endpoint.
25
+ */
26
+ export declare function readAlwaysOnActivity(workDir: string, home: string, opts?: ReadActivityOptions): ReadActivityResult;
27
+ //# sourceMappingURL=activity-reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activity-reader.d.ts","sourceRoot":"","sources":["../../src/always-on/activity-reader.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAI/D,MAAM,WAAW,mBAAmB;IAClC,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;CAC3C;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,sBAAsB,EAAE,CAAC;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAC;CACf;AAKD;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,mBAAwB,GAC7B,kBAAkB,CAuCpB"}
@@ -0,0 +1,95 @@
1
+ // Always-on activity log reader (M9 t1).
2
+ //
3
+ // Pure read-path over `<projectRoot>/always-on.log` (JSONL, one tick per
4
+ // line). Written by AlwaysOnManager.appendLog; this module never touches
5
+ // the writer. Returns wire-shape records (AlwaysOnActivityRecord) so the
6
+ // Hub REST layer can pass them through verbatim.
7
+ //
8
+ // Known limitations (MVP):
9
+ // - Reads only `always-on.log`; the rotated `.log.1` backup is ignored.
10
+ // - Whole-file read + reverse: fine at ≤10MB cap; revisit if cap grows.
11
+ import { readFileSync } from "node:fs";
12
+ import { join } from "node:path";
13
+ import { projectRoot } from "@mclawnet/task";
14
+ const LOG_FILENAME = "always-on.log";
15
+ const DEFAULT_LIMIT = 100;
16
+ const MAX_LIMIT = 500;
17
+ /**
18
+ * Parse the always-on.log file under <projectRoot> and return a paginated
19
+ * newest-first slice.
20
+ *
21
+ * Tolerant by design:
22
+ * - Missing file → empty result (NOT an error).
23
+ * - Blank lines → skipped.
24
+ * - JSON.parse errors → that line is skipped (NOT thrown), so a single
25
+ * corrupt line never 500s the endpoint.
26
+ */
27
+ export function readAlwaysOnActivity(workDir, home, opts = {}) {
28
+ const limit = clampLimit(opts.limit);
29
+ const skip = Math.max(0, Math.floor(opts.skip ?? 0));
30
+ const decision = opts.decision;
31
+ const path = join(projectRoot(workDir, home), LOG_FILENAME);
32
+ let raw;
33
+ try {
34
+ raw = readFileSync(path, "utf-8");
35
+ }
36
+ catch (err) {
37
+ if (err?.code === "ENOENT") {
38
+ return { ticks: [], hasMore: false, total: 0 };
39
+ }
40
+ throw err;
41
+ }
42
+ const records = [];
43
+ for (const line of raw.split("\n")) {
44
+ const trimmed = line.trim();
45
+ if (!trimmed)
46
+ continue;
47
+ let parsed;
48
+ try {
49
+ parsed = JSON.parse(trimmed);
50
+ }
51
+ catch {
52
+ // Corrupt line — skip silently. Don't fail the whole read.
53
+ continue;
54
+ }
55
+ if (!isActivityRecord(parsed))
56
+ continue;
57
+ if (decision && parsed.decision !== decision)
58
+ continue;
59
+ records.push(parsed);
60
+ }
61
+ // Newest-first. JSONL is append-only chronological, so reversing is enough.
62
+ records.reverse();
63
+ const total = records.length;
64
+ const slice = records.slice(skip, skip + limit);
65
+ const hasMore = skip + slice.length < total;
66
+ return { ticks: slice, hasMore, total };
67
+ }
68
+ function clampLimit(input) {
69
+ if (input == null || !Number.isFinite(input))
70
+ return DEFAULT_LIMIT;
71
+ const n = Math.floor(input);
72
+ if (n < 1)
73
+ return 1;
74
+ if (n > MAX_LIMIT)
75
+ return MAX_LIMIT;
76
+ return n;
77
+ }
78
+ function isActivityRecord(value) {
79
+ if (!value || typeof value !== "object")
80
+ return false;
81
+ const obj = value;
82
+ if (typeof obj.at !== "string")
83
+ return false;
84
+ if (obj.decision !== "fired" &&
85
+ obj.decision !== "skipped" &&
86
+ obj.decision !== "halted") {
87
+ return false;
88
+ }
89
+ if (!Array.isArray(obj.gateBreakdown))
90
+ return false;
91
+ if (typeof obj.durationMs !== "number")
92
+ return false;
93
+ return true;
94
+ }
95
+ //# sourceMappingURL=activity-reader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activity-reader.js","sourceRoot":"","sources":["../../src/always-on/activity-reader.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,yEAAyE;AACzE,yEAAyE;AACzE,yEAAyE;AACzE,iDAAiD;AACjD,EAAE;AACF,2BAA2B;AAC3B,0EAA0E;AAC1E,0EAA0E;AAE1E,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,MAAM,YAAY,GAAG,eAAe,CAAC;AAkBrC,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAe,EACf,IAAY,EACZ,OAA4B,EAAE;IAE9B,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;I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skSource } from "./task-sources/types.js";
4
+ import type { TaskStore } from "@mclawnet/task";
5
+ import { type AlwaysOnConfig, type AlwaysOnPersistedConfig } from "./config.js";
6
+ import type { SwarmCoordinator } from "../swarm-coordinator.js";
7
+ export interface AlwaysOnManagerOptions {
8
+ home: string;
9
+ swarmCoordinator: SwarmCoordinator;
10
+ /**
11
+ * Picks the next task for a given project; null = nothing actionable.
12
+ * Backwards-compat (M7) single-source DI. When `taskSources` is also
13
+ * provided the cascade picker takes precedence — `pickNextTask` is then
14
+ * ignored, but kept in the type for callers that still pass it.
15
+ */
16
+ pickNextTask?: (projectRoot: string) => Promise<TaskRef | null>;
17
+ /**
18
+ * M8.0 cascade source list. When provided the manager builds a
19
+ * CascadePicker over these sources and wires it into the runner with the
20
+ * source lifecycle hooks active. When omitted, falls back to the M7
21
+ * single-source `pickNextTask` DI above (or a TaskStore-backed source
22
+ * when `taskStore` is provided).
23
+ */
24
+ taskSources?: TaskSource[];
25
+ /**
26
+ * Convenience: when neither `pickNextTask` nor `taskSources` is provided
27
+ * but a TaskStore factory is, the manager auto-wraps it into a default
28
+ * single-source cascade. Lets the agent pass just the store factory and
29
+ * get the same picking behaviour as M7.
30
+ */
31
+ taskStore?: (projectRoot: string) => TaskStore | undefined;
32
+ /** Optional clock injection for tests. */
33
+ now?: () => Date;
34
+ /** Override the user-active window (tests). */
35
+ userActiveWindowMs?: number;
36
+ /** Override the log rotation byte cap (tests). */
37
+ logRotateBytes?: number;
38
+ /**
39
+ * Construct a WorkCycleRunner. Defaults to a real runner bound to the
40
+ * shared SwarmCoordinator + provided pickNextTask. Test-only override.
41
+ */
42
+ runnerFactory?: (workDir: string) => WorkCycleRunner;
43
+ }
44
+ export declare class AlwaysOnManager {
45
+ private readonly home;
46
+ private readonly swarmCoordinator;
47
+ private readonly pickNextTask;
48
+ private readonly cascadePicker;
49
+ /**
50
+ * R3 I-B — kept around so `drainPending(workDir)` can iterate sources
51
+ * BEFORE the cascade runs each tick. The cascade picker itself only
52
+ * exposes filtered-pick semantics; the drain must bypass the filter so
53
+ * a source whose toggle was flipped off mid-flight still gets to reap
54
+ * its in-flight work.
55
+ */
56
+ private readonly taskSources;
57
+ private readonly now;
58
+ private readonly userActiveWindowMs;
59
+ private readonly logRotateBytes;
60
+ private readonly runnerFactory?;
61
+ private readonly entries;
62
+ constructor(opts: AlwaysOnManagerOptions);
63
+ /**
64
+ * Boot (or rebuild) the scheduler for one project. Loads config from disk;
65
+ * restores ticksToday/lastFireAt when the persisted date matches today; if
66
+ * mode === "off", the scheduler is created but left stopped (cheap, lets
67
+ * `applyConfig` flip the switch later without re-instantiating).
68
+ *
69
+ * Idempotent: calling start() twice for the same project rebuilds; the old
70
+ * scheduler is stopped first to avoid duplicate timers.
71
+ */
72
+ start(workDir: string): Promise<void>;
73
+ /** Stop the scheduler for a project and drop the entry. Idempotent. */
74
+ stop(workDir: string): Promise<void>;
75
+ /**
76
+ * Returns the live snapshot serialised to the wire format (Date → ISO),
77
+ * or null when no scheduler is booted for the project.
78
+ */
79
+ snapshot(workDir: string): AlwaysOnSnapshot | null;
80
+ /**
81
+ * Re-sync the live scheduler with whatever's on disk right now (M7.3).
82
+ * The M7.2 projects-handler already does load→merge→save, then calls our
83
+ * hook with the new config. Rather than re-doing the persistence here we
84
+ * just pull the canonical state off disk and push it into the scheduler.
85
+ * Auto-boots if the project never started; idempotent otherwise.
86
+ */
87
+ refreshFromDisk(workDir: string): Promise<void>;
88
+ /**
89
+ * Apply a config patch: merges over the persisted baseline, writes it back,
90
+ * updates the live scheduler in place. Auto-boots the scheduler when the
91
+ * project has never been started (UI may flip a mode on a fresh project).
92
+ *
93
+ * Returns the merged config and the post-update snapshot so callers can
94
+ * hand both back to the UI in one round trip.
95
+ */
96
+ applyConfig(workDir: string, patch: Omit<Partial<AlwaysOnConfig>, "pausedUntil"> & {
97
+ pausedUntil?: string | null;
98
+ lastIntrospectionAt?: string | null;
99
+ lastIntrospectionRejected?: boolean | null;
100
+ pendingIntrospectionSwarmId?: string | null;
101
+ pendingIntrospectionWorkspaceCwd?: string | null;
102
+ }): Promise<{
103
+ config: AlwaysOnPersistedConfig;
104
+ snapshot: AlwaysOnSnapshot;
105
+ }>;
106
+ /**
107
+ * Record agent activity for the userActive gate. S1 hotfix: scoped per
108
+ * project. Pass `workDir` to update one project only; omit (or pass null)
109
+ * to broadcast to every entry — preserves the old global behaviour for
110
+ * callers that can't resolve a workDir from an inbound hub frame.
111
+ */
112
+ recordActivity(workDir?: string | null): void;
113
+ /**
114
+ * B6 — force a tick immediately, clearing the per-project userActive
115
+ * timestamp first so the gate cascade doesn't skip on "user active <30min
116
+ * ago". Dev-only entrypoint: the hub gates the corresponding HTTP route on
117
+ * `NODE_ENV !== "production"` so this never reaches the agent in prod.
118
+ *
119
+ * Returns the TickRecord (decision + gateBreakdown + durationMs) and the
120
+ * post-tick snapshot in one call so the caller can show in dev tooling
121
+ * whether the force-tick fired or still skipped (e.g. on a real
122
+ * pausedUntil that genuinely should block).
123
+ *
124
+ * Note: only `lastActivityAt` is cleared. Other gates (pausedUntil,
125
+ * dailyBudget) intentionally still apply — force-tick is for bypassing
126
+ * the "I'm typing, don't fire" UX gate, not the user's explicit pause or
127
+ * the daily budget. Throws when no scheduler is booted for the project.
128
+ */
129
+ forceTick(workDir: string): Promise<{
130
+ record: AlwaysOnTickRecord;
131
+ snapshot: AlwaysOnSnapshot;
132
+ }>;
133
+ /** Stop every per-project scheduler. Called on agent shutdown. */
134
+ disposeAll(): Promise<void>;
135
+ /**
136
+ * R3 I-B — public test/ops hook. Invokes `drainPending(workDir)` on every
137
+ * TaskSource that defines it, regardless of whether its toggle is on. This
138
+ * is the same drain that runs automatically inside `onFire` before each
139
+ * tick; exposed publicly so:
140
+ * - tests can simulate "user toggled off mid-flight → next tick reaps
141
+ * cleanly" without driving the scheduler timer, and
142
+ * - future ops surfaces (admin reseed, manual reconcile) can request a
143
+ * drain pass without firing a work cycle.
144
+ * Failures inside a single source are logged and swallowed — one source's
145
+ * drain must not break the manager's tick loop.
146
+ */
147
+ drainAllSources(workDir: string): Promise<void>;
148
+ /**
149
+ * Hotfix C1 — map a TaskSource onto its taskSources toggle flag and
150
+ * resolve against the project's persisted config. Unknown source names
151
+ * default to enabled so non-standard sources (e.g. tests, future M9
152
+ * sources not yet listed in `AlwaysOnTaskSourcesConfig`) aren't silently
153
+ * dropped. Called fresh per pick by the cascade picker filter, so toggling
154
+ * a source on/off in the UI takes effect on the very next tick — no
155
+ * scheduler/picker rebuild required (the JSON read is cheap compared to a
156
+ * swarm spawn).
157
+ */
158
+ private isSourceEnabledForProject;
159
+ /** User-facing gates: pausedUntil + userActive. */
160
+ private buildGates;
161
+ /**
162
+ * Persist ticksToday/lastFireAt AND append a jsonl line to always-on.log.
163
+ * Hooked into DiscoveryScheduler.onTick so every fired / skipped / halted
164
+ * decision is captured. Best-effort — write failures are logged but never
165
+ * thrown back into the scheduler tick loop.
166
+ */
167
+ private onTick;
168
+ private appendLog;
169
+ }
170
+ //# sourceMappingURL=always-on-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"always-on-manager.d.ts","sourceRoot":"","sources":["../../src/always-on/always-on-manager.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,UAAU,EAA8C,MAAM,yBAAyB,CAAC;AAGtG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAOL,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC7B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAWhE,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,gBAAgB,CAAC;IACnC;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