macro-agent 0.2.5 → 0.2.6

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 (992) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +30 -56
  3. package/dist/acp/websocket-server.d.ts +6 -0
  4. package/dist/acp/websocket-server.d.ts.map +1 -1
  5. package/dist/acp/websocket-server.js +13 -0
  6. package/dist/acp/websocket-server.js.map +1 -1
  7. package/dist/acp/websocket-stream.d.ts +30 -0
  8. package/dist/acp/websocket-stream.d.ts.map +1 -0
  9. package/dist/acp/websocket-stream.js +118 -0
  10. package/dist/acp/websocket-stream.js.map +1 -0
  11. package/dist/activity/deduplication.d.ts +85 -0
  12. package/dist/activity/deduplication.d.ts.map +1 -0
  13. package/dist/activity/deduplication.js +149 -0
  14. package/dist/activity/deduplication.js.map +1 -0
  15. package/dist/activity/index.d.ts +16 -0
  16. package/dist/activity/index.d.ts.map +1 -0
  17. package/dist/activity/index.js +17 -0
  18. package/dist/activity/index.js.map +1 -0
  19. package/dist/activity/relevance.d.ts +81 -0
  20. package/dist/activity/relevance.d.ts.map +1 -0
  21. package/dist/activity/relevance.js +161 -0
  22. package/dist/activity/relevance.js.map +1 -0
  23. package/dist/activity/types.d.ts +169 -0
  24. package/dist/activity/types.d.ts.map +1 -0
  25. package/dist/activity/types.js +33 -0
  26. package/dist/activity/types.js.map +1 -0
  27. package/dist/activity/watcher.d.ts +64 -0
  28. package/dist/activity/watcher.d.ts.map +1 -0
  29. package/dist/activity/watcher.js +212 -0
  30. package/dist/activity/watcher.js.map +1 -0
  31. package/dist/adapters/federation.d.ts +8 -1
  32. package/dist/adapters/federation.d.ts.map +1 -1
  33. package/dist/adapters/federation.js +33 -2
  34. package/dist/adapters/federation.js.map +1 -1
  35. package/dist/agent/agent-manager-v2.d.ts.map +1 -1
  36. package/dist/agent/agent-manager-v2.js +7 -24
  37. package/dist/agent/agent-manager-v2.js.map +1 -1
  38. package/dist/agent/wake.d.ts +85 -0
  39. package/dist/agent/wake.d.ts.map +1 -0
  40. package/dist/agent/wake.js +278 -0
  41. package/dist/agent/wake.js.map +1 -0
  42. package/dist/api/server.d.ts.map +1 -1
  43. package/dist/api/server.js +41 -25
  44. package/dist/api/server.js.map +1 -1
  45. package/dist/api/types.d.ts +6 -0
  46. package/dist/api/types.d.ts.map +1 -1
  47. package/dist/auth/server-auth.d.ts +43 -0
  48. package/dist/auth/server-auth.d.ts.map +1 -0
  49. package/dist/auth/server-auth.js +80 -0
  50. package/dist/auth/server-auth.js.map +1 -0
  51. package/dist/auth/token.d.ts +4 -0
  52. package/dist/auth/token.d.ts.map +1 -1
  53. package/dist/auth/token.js +7 -6
  54. package/dist/auth/token.js.map +1 -1
  55. package/dist/boot-v2.d.ts +6 -3
  56. package/dist/boot-v2.d.ts.map +1 -1
  57. package/dist/boot-v2.js +44 -25
  58. package/dist/boot-v2.js.map +1 -1
  59. package/dist/cognitive/team-lifecycle.d.ts +82 -0
  60. package/dist/cognitive/team-lifecycle.d.ts.map +1 -0
  61. package/dist/cognitive/team-lifecycle.js +121 -0
  62. package/dist/cognitive/team-lifecycle.js.map +1 -0
  63. package/dist/cognitive/trajectory-extractor.d.ts +25 -0
  64. package/dist/cognitive/trajectory-extractor.d.ts.map +1 -0
  65. package/dist/cognitive/trajectory-extractor.js +134 -0
  66. package/dist/cognitive/trajectory-extractor.js.map +1 -0
  67. package/dist/control/control-server.d.ts.map +1 -1
  68. package/dist/control/control-server.js +10 -0
  69. package/dist/control/control-server.js.map +1 -1
  70. package/dist/dispatch/mail-inbound-consumer.d.ts.map +1 -1
  71. package/dist/dispatch/mail-inbound-consumer.js +43 -10
  72. package/dist/dispatch/mail-inbound-consumer.js.map +1 -1
  73. package/dist/index.d.ts +4 -0
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +6 -1
  76. package/dist/index.js.map +1 -1
  77. package/dist/lifecycle/handlers/generic.d.ts +27 -0
  78. package/dist/lifecycle/handlers/generic.d.ts.map +1 -0
  79. package/dist/lifecycle/handlers/generic.js +56 -0
  80. package/dist/lifecycle/handlers/generic.js.map +1 -0
  81. package/dist/lifecycle/handlers/index.d.ts +51 -0
  82. package/dist/lifecycle/handlers/index.d.ts.map +1 -0
  83. package/dist/lifecycle/handlers/index.js +110 -0
  84. package/dist/lifecycle/handlers/index.js.map +1 -0
  85. package/dist/lifecycle/handlers/integrator.d.ts +81 -0
  86. package/dist/lifecycle/handlers/integrator.d.ts.map +1 -0
  87. package/dist/lifecycle/handlers/integrator.js +451 -0
  88. package/dist/lifecycle/handlers/integrator.js.map +1 -0
  89. package/dist/lifecycle/handlers/monitor.d.ts +29 -0
  90. package/dist/lifecycle/handlers/monitor.d.ts.map +1 -0
  91. package/dist/lifecycle/handlers/monitor.js +79 -0
  92. package/dist/lifecycle/handlers/monitor.js.map +1 -0
  93. package/dist/lifecycle/handlers/worker.d.ts +56 -0
  94. package/dist/lifecycle/handlers/worker.d.ts.map +1 -0
  95. package/dist/lifecycle/handlers/worker.js +381 -0
  96. package/dist/lifecycle/handlers/worker.js.map +1 -0
  97. package/dist/lifecycle/handlers-v2.d.ts +0 -2
  98. package/dist/lifecycle/handlers-v2.d.ts.map +1 -1
  99. package/dist/lifecycle/handlers-v2.js +4 -55
  100. package/dist/lifecycle/handlers-v2.js.map +1 -1
  101. package/dist/mail/conversation-map.d.ts +33 -0
  102. package/dist/mail/conversation-map.d.ts.map +1 -0
  103. package/dist/mail/conversation-map.js +61 -0
  104. package/dist/mail/conversation-map.js.map +1 -0
  105. package/dist/mail/index.d.ts +11 -0
  106. package/dist/mail/index.d.ts.map +1 -0
  107. package/dist/mail/index.js +11 -0
  108. package/dist/mail/index.js.map +1 -0
  109. package/dist/mail/mail-service.d.ts +85 -0
  110. package/dist/mail/mail-service.d.ts.map +1 -0
  111. package/dist/mail/mail-service.js +121 -0
  112. package/dist/mail/mail-service.js.map +1 -0
  113. package/dist/mail/stores/eventstore-conversation-store.d.ts +40 -0
  114. package/dist/mail/stores/eventstore-conversation-store.d.ts.map +1 -0
  115. package/dist/mail/stores/eventstore-conversation-store.js +131 -0
  116. package/dist/mail/stores/eventstore-conversation-store.js.map +1 -0
  117. package/dist/mail/stores/eventstore-participant-store.d.ts +43 -0
  118. package/dist/mail/stores/eventstore-participant-store.d.ts.map +1 -0
  119. package/dist/mail/stores/eventstore-participant-store.js +145 -0
  120. package/dist/mail/stores/eventstore-participant-store.js.map +1 -0
  121. package/dist/mail/stores/eventstore-thread-store.d.ts +46 -0
  122. package/dist/mail/stores/eventstore-thread-store.d.ts.map +1 -0
  123. package/dist/mail/stores/eventstore-thread-store.js +118 -0
  124. package/dist/mail/stores/eventstore-thread-store.js.map +1 -0
  125. package/dist/mail/stores/eventstore-turn-store.d.ts +47 -0
  126. package/dist/mail/stores/eventstore-turn-store.d.ts.map +1 -0
  127. package/dist/mail/stores/eventstore-turn-store.js +153 -0
  128. package/dist/mail/stores/eventstore-turn-store.js.map +1 -0
  129. package/dist/mail/stores/index.d.ts +12 -0
  130. package/dist/mail/stores/index.d.ts.map +1 -0
  131. package/dist/mail/stores/index.js +12 -0
  132. package/dist/mail/stores/index.js.map +1 -0
  133. package/dist/mail/stores/types.d.ts +146 -0
  134. package/dist/mail/stores/types.d.ts.map +1 -0
  135. package/dist/mail/stores/types.js +13 -0
  136. package/dist/mail/stores/types.js.map +1 -0
  137. package/dist/mail/turn-recorder.d.ts +30 -0
  138. package/dist/mail/turn-recorder.d.ts.map +1 -0
  139. package/dist/mail/turn-recorder.js +98 -0
  140. package/dist/mail/turn-recorder.js.map +1 -0
  141. package/dist/map/adapter/acp-over-map.d.ts +115 -0
  142. package/dist/map/adapter/acp-over-map.d.ts.map +1 -0
  143. package/dist/map/adapter/acp-over-map.js +1024 -0
  144. package/dist/map/adapter/acp-over-map.js.map +1 -0
  145. package/dist/map/adapter/connection-manager.d.ts +150 -0
  146. package/dist/map/adapter/connection-manager.d.ts.map +1 -0
  147. package/dist/map/adapter/connection-manager.js +207 -0
  148. package/dist/map/adapter/connection-manager.js.map +1 -0
  149. package/dist/map/adapter/event-log.d.ts +87 -0
  150. package/dist/map/adapter/event-log.d.ts.map +1 -0
  151. package/dist/map/adapter/event-log.js +122 -0
  152. package/dist/map/adapter/event-log.js.map +1 -0
  153. package/dist/map/adapter/event-translator.d.ts +85 -0
  154. package/dist/map/adapter/event-translator.d.ts.map +1 -0
  155. package/dist/map/adapter/event-translator.js +295 -0
  156. package/dist/map/adapter/event-translator.js.map +1 -0
  157. package/dist/map/adapter/extensions/agent-detection.d.ts +49 -0
  158. package/dist/map/adapter/extensions/agent-detection.d.ts.map +1 -0
  159. package/dist/map/adapter/extensions/agent-detection.js +91 -0
  160. package/dist/map/adapter/extensions/agent-detection.js.map +1 -0
  161. package/dist/map/adapter/extensions/agent-lifecycle.d.ts +82 -0
  162. package/dist/map/adapter/extensions/agent-lifecycle.d.ts.map +1 -0
  163. package/dist/map/adapter/extensions/agent-lifecycle.js +164 -0
  164. package/dist/map/adapter/extensions/agent-lifecycle.js.map +1 -0
  165. package/dist/map/adapter/extensions/cognitive.d.ts +27 -0
  166. package/dist/map/adapter/extensions/cognitive.d.ts.map +1 -0
  167. package/dist/map/adapter/extensions/cognitive.js +158 -0
  168. package/dist/map/adapter/extensions/cognitive.js.map +1 -0
  169. package/dist/map/adapter/extensions/index.d.ts +95 -0
  170. package/dist/map/adapter/extensions/index.d.ts.map +1 -0
  171. package/dist/map/adapter/extensions/index.js +228 -0
  172. package/dist/map/adapter/extensions/index.js.map +1 -0
  173. package/dist/map/adapter/extensions/mcp-bridge.d.ts +57 -0
  174. package/dist/map/adapter/extensions/mcp-bridge.d.ts.map +1 -0
  175. package/dist/map/adapter/extensions/mcp-bridge.js +745 -0
  176. package/dist/map/adapter/extensions/mcp-bridge.js.map +1 -0
  177. package/dist/map/adapter/extensions/resume.d.ts +47 -0
  178. package/dist/map/adapter/extensions/resume.d.ts.map +1 -0
  179. package/dist/map/adapter/extensions/resume.js +59 -0
  180. package/dist/map/adapter/extensions/resume.js.map +1 -0
  181. package/dist/map/adapter/extensions/streams.d.ts +95 -0
  182. package/dist/map/adapter/extensions/streams.d.ts.map +1 -0
  183. package/dist/map/adapter/extensions/streams.js +515 -0
  184. package/dist/map/adapter/extensions/streams.js.map +1 -0
  185. package/dist/map/adapter/extensions/task.d.ts +40 -0
  186. package/dist/map/adapter/extensions/task.d.ts.map +1 -0
  187. package/dist/map/adapter/extensions/task.js +197 -0
  188. package/dist/map/adapter/extensions/task.js.map +1 -0
  189. package/dist/map/adapter/extensions/update-metadata.d.ts +29 -0
  190. package/dist/map/adapter/extensions/update-metadata.d.ts.map +1 -0
  191. package/dist/map/adapter/extensions/update-metadata.js +67 -0
  192. package/dist/map/adapter/extensions/update-metadata.js.map +1 -0
  193. package/dist/map/adapter/extensions/wake.d.ts +60 -0
  194. package/dist/map/adapter/extensions/wake.d.ts.map +1 -0
  195. package/dist/map/adapter/extensions/wake.js +144 -0
  196. package/dist/map/adapter/extensions/wake.js.map +1 -0
  197. package/dist/map/adapter/extensions/workspace-files.d.ts +42 -0
  198. package/dist/map/adapter/extensions/workspace-files.d.ts.map +1 -0
  199. package/dist/map/adapter/extensions/workspace-files.js +338 -0
  200. package/dist/map/adapter/extensions/workspace-files.js.map +1 -0
  201. package/dist/map/adapter/extensions/workspace.d.ts +57 -0
  202. package/dist/map/adapter/extensions/workspace.d.ts.map +1 -0
  203. package/dist/map/adapter/extensions/workspace.js +81 -0
  204. package/dist/map/adapter/extensions/workspace.js.map +1 -0
  205. package/dist/map/adapter/index.d.ts +20 -0
  206. package/dist/map/adapter/index.d.ts.map +1 -0
  207. package/dist/map/adapter/index.js +40 -0
  208. package/dist/map/adapter/index.js.map +1 -0
  209. package/dist/map/adapter/interface.d.ts +450 -0
  210. package/dist/map/adapter/interface.d.ts.map +1 -0
  211. package/dist/map/adapter/interface.js +24 -0
  212. package/dist/map/adapter/interface.js.map +1 -0
  213. package/dist/map/adapter/mail-handler-adapter.d.ts +27 -0
  214. package/dist/map/adapter/mail-handler-adapter.d.ts.map +1 -0
  215. package/dist/map/adapter/mail-handler-adapter.js +292 -0
  216. package/dist/map/adapter/mail-handler-adapter.js.map +1 -0
  217. package/dist/map/adapter/map-adapter.d.ts +200 -0
  218. package/dist/map/adapter/map-adapter.d.ts.map +1 -0
  219. package/dist/map/adapter/map-adapter.js +1199 -0
  220. package/dist/map/adapter/map-adapter.js.map +1 -0
  221. package/dist/map/adapter/rpc-handler.d.ts +263 -0
  222. package/dist/map/adapter/rpc-handler.d.ts.map +1 -0
  223. package/dist/map/adapter/rpc-handler.js +365 -0
  224. package/dist/map/adapter/rpc-handler.js.map +1 -0
  225. package/dist/map/adapter/subscription-manager.d.ts +174 -0
  226. package/dist/map/adapter/subscription-manager.d.ts.map +1 -0
  227. package/dist/map/adapter/subscription-manager.js +248 -0
  228. package/dist/map/adapter/subscription-manager.js.map +1 -0
  229. package/dist/map/adapter/types.d.ts +194 -0
  230. package/dist/map/adapter/types.d.ts.map +1 -0
  231. package/dist/map/adapter/types.js +27 -0
  232. package/dist/map/adapter/types.js.map +1 -0
  233. package/dist/map/adapter/websocket-integration.d.ts +113 -0
  234. package/dist/map/adapter/websocket-integration.d.ts.map +1 -0
  235. package/dist/map/adapter/websocket-integration.js +134 -0
  236. package/dist/map/adapter/websocket-integration.js.map +1 -0
  237. package/dist/map/cascade-action-handler.d.ts.map +1 -1
  238. package/dist/map/cascade-action-handler.js +19 -5
  239. package/dist/map/cascade-action-handler.js.map +1 -1
  240. package/dist/map/federation/envelope.d.ts +98 -0
  241. package/dist/map/federation/envelope.d.ts.map +1 -0
  242. package/dist/map/federation/envelope.js +160 -0
  243. package/dist/map/federation/envelope.js.map +1 -0
  244. package/dist/map/federation/federation-handler.d.ts +50 -0
  245. package/dist/map/federation/federation-handler.d.ts.map +1 -0
  246. package/dist/map/federation/federation-handler.js +306 -0
  247. package/dist/map/federation/federation-handler.js.map +1 -0
  248. package/dist/map/federation/index.d.ts +14 -0
  249. package/dist/map/federation/index.d.ts.map +1 -0
  250. package/dist/map/federation/index.js +13 -0
  251. package/dist/map/federation/index.js.map +1 -0
  252. package/dist/map/federation/types.d.ts +239 -0
  253. package/dist/map/federation/types.d.ts.map +1 -0
  254. package/dist/map/federation/types.js +23 -0
  255. package/dist/map/federation/types.js.map +1 -0
  256. package/dist/map/server.d.ts.map +1 -1
  257. package/dist/map/server.js +17 -2
  258. package/dist/map/server.js.map +1 -1
  259. package/dist/map/types.d.ts +6 -0
  260. package/dist/map/types.d.ts.map +1 -1
  261. package/dist/mcp/map-client.d.ts +39 -0
  262. package/dist/mcp/map-client.d.ts.map +1 -0
  263. package/dist/mcp/map-client.js +129 -0
  264. package/dist/mcp/map-client.js.map +1 -0
  265. package/dist/mcp/mcp-server.d.ts +72 -0
  266. package/dist/mcp/mcp-server.d.ts.map +1 -0
  267. package/dist/mcp/mcp-server.js +1027 -0
  268. package/dist/mcp/mcp-server.js.map +1 -0
  269. package/dist/mcp/tools/claim_task.d.ts +35 -0
  270. package/dist/mcp/tools/claim_task.d.ts.map +1 -0
  271. package/dist/mcp/tools/claim_task.js +58 -0
  272. package/dist/mcp/tools/claim_task.js.map +1 -0
  273. package/dist/mcp/tools/done-v2.d.ts +0 -1
  274. package/dist/mcp/tools/done-v2.d.ts.map +1 -1
  275. package/dist/mcp/tools/done-v2.js +0 -1
  276. package/dist/mcp/tools/done-v2.js.map +1 -1
  277. package/dist/mcp/tools/done.d.ts +102 -0
  278. package/dist/mcp/tools/done.d.ts.map +1 -0
  279. package/dist/mcp/tools/done.js +253 -0
  280. package/dist/mcp/tools/done.js.map +1 -0
  281. package/dist/mcp/tools/inject_context.d.ts +61 -0
  282. package/dist/mcp/tools/inject_context.d.ts.map +1 -0
  283. package/dist/mcp/tools/inject_context.js +123 -0
  284. package/dist/mcp/tools/inject_context.js.map +1 -0
  285. package/dist/mcp/tools/list_claimable_tasks.d.ts +38 -0
  286. package/dist/mcp/tools/list_claimable_tasks.d.ts.map +1 -0
  287. package/dist/mcp/tools/list_claimable_tasks.js +63 -0
  288. package/dist/mcp/tools/list_claimable_tasks.js.map +1 -0
  289. package/dist/mcp/tools/unclaim_task.d.ts +31 -0
  290. package/dist/mcp/tools/unclaim_task.d.ts.map +1 -0
  291. package/dist/mcp/tools/unclaim_task.js +47 -0
  292. package/dist/mcp/tools/unclaim_task.js.map +1 -0
  293. package/dist/mcp/tools/wait_for_activity.d.ts +60 -0
  294. package/dist/mcp/tools/wait_for_activity.d.ts.map +1 -0
  295. package/dist/mcp/tools/wait_for_activity.js +135 -0
  296. package/dist/mcp/tools/wait_for_activity.js.map +1 -0
  297. package/dist/monitor/health-check-service.d.ts +143 -0
  298. package/dist/monitor/health-check-service.d.ts.map +1 -0
  299. package/dist/monitor/health-check-service.js +240 -0
  300. package/dist/monitor/health-check-service.js.map +1 -0
  301. package/dist/monitor/index.d.ts +14 -0
  302. package/dist/monitor/index.d.ts.map +1 -0
  303. package/dist/monitor/index.js +14 -0
  304. package/dist/monitor/index.js.map +1 -0
  305. package/dist/monitor/stall-detector.d.ts +109 -0
  306. package/dist/monitor/stall-detector.d.ts.map +1 -0
  307. package/dist/monitor/stall-detector.js +152 -0
  308. package/dist/monitor/stall-detector.js.map +1 -0
  309. package/dist/peer/capability-manager.d.ts +56 -0
  310. package/dist/peer/capability-manager.d.ts.map +1 -0
  311. package/dist/peer/capability-manager.js +186 -0
  312. package/dist/peer/capability-manager.js.map +1 -0
  313. package/dist/peer/encapsulation-manager.d.ts +190 -0
  314. package/dist/peer/encapsulation-manager.d.ts.map +1 -0
  315. package/dist/peer/encapsulation-manager.js +486 -0
  316. package/dist/peer/encapsulation-manager.js.map +1 -0
  317. package/dist/peer/federation-manager.d.ts +223 -0
  318. package/dist/peer/federation-manager.d.ts.map +1 -0
  319. package/dist/peer/federation-manager.js +528 -0
  320. package/dist/peer/federation-manager.js.map +1 -0
  321. package/dist/peer/hierarchy-errors.d.ts +208 -0
  322. package/dist/peer/hierarchy-errors.d.ts.map +1 -0
  323. package/dist/peer/hierarchy-errors.js +268 -0
  324. package/dist/peer/hierarchy-errors.js.map +1 -0
  325. package/dist/peer/hierarchy-protocol.d.ts +159 -0
  326. package/dist/peer/hierarchy-protocol.d.ts.map +1 -0
  327. package/dist/peer/hierarchy-protocol.js +142 -0
  328. package/dist/peer/hierarchy-protocol.js.map +1 -0
  329. package/dist/peer/index.d.ts +15 -0
  330. package/dist/peer/index.d.ts.map +1 -0
  331. package/dist/peer/index.js +15 -0
  332. package/dist/peer/index.js.map +1 -0
  333. package/dist/peer/peer-manager.d.ts +99 -0
  334. package/dist/peer/peer-manager.d.ts.map +1 -0
  335. package/dist/peer/peer-manager.js +333 -0
  336. package/dist/peer/peer-manager.js.map +1 -0
  337. package/dist/peer/task-delegation.d.ts +189 -0
  338. package/dist/peer/task-delegation.d.ts.map +1 -0
  339. package/dist/peer/task-delegation.js +303 -0
  340. package/dist/peer/task-delegation.js.map +1 -0
  341. package/dist/peer/transports/index.d.ts +8 -0
  342. package/dist/peer/transports/index.d.ts.map +1 -0
  343. package/dist/peer/transports/index.js +8 -0
  344. package/dist/peer/transports/index.js.map +1 -0
  345. package/dist/peer/transports/local-transport.d.ts +56 -0
  346. package/dist/peer/transports/local-transport.d.ts.map +1 -0
  347. package/dist/peer/transports/local-transport.js +263 -0
  348. package/dist/peer/transports/local-transport.js.map +1 -0
  349. package/dist/peer/transports/websocket-transport.d.ts +86 -0
  350. package/dist/peer/transports/websocket-transport.d.ts.map +1 -0
  351. package/dist/peer/transports/websocket-transport.js +338 -0
  352. package/dist/peer/transports/websocket-transport.js.map +1 -0
  353. package/dist/peer/types.d.ts +268 -0
  354. package/dist/peer/types.d.ts.map +1 -0
  355. package/dist/peer/types.js +36 -0
  356. package/dist/peer/types.js.map +1 -0
  357. package/dist/router/address-resolver.d.ts +102 -0
  358. package/dist/router/address-resolver.d.ts.map +1 -0
  359. package/dist/router/address-resolver.js +198 -0
  360. package/dist/router/address-resolver.js.map +1 -0
  361. package/dist/router/broadcast.d.ts +53 -0
  362. package/dist/router/broadcast.d.ts.map +1 -0
  363. package/dist/router/broadcast.js +75 -0
  364. package/dist/router/broadcast.js.map +1 -0
  365. package/dist/router/channels.d.ts +148 -0
  366. package/dist/router/channels.d.ts.map +1 -0
  367. package/dist/router/channels.js +126 -0
  368. package/dist/router/channels.js.map +1 -0
  369. package/dist/router/index.d.ts +21 -0
  370. package/dist/router/index.d.ts.map +1 -0
  371. package/dist/router/index.js +18 -0
  372. package/dist/router/index.js.map +1 -0
  373. package/dist/router/message-router.d.ts +197 -0
  374. package/dist/router/message-router.d.ts.map +1 -0
  375. package/dist/router/message-router.js +903 -0
  376. package/dist/router/message-router.js.map +1 -0
  377. package/dist/router/message-types.d.ts +183 -0
  378. package/dist/router/message-types.d.ts.map +1 -0
  379. package/dist/router/message-types.js +79 -0
  380. package/dist/router/message-types.js.map +1 -0
  381. package/dist/router/role-resolver.d.ts +67 -0
  382. package/dist/router/role-resolver.d.ts.map +1 -0
  383. package/dist/router/role-resolver.js +106 -0
  384. package/dist/router/role-resolver.js.map +1 -0
  385. package/dist/router/signals.d.ts +253 -0
  386. package/dist/router/signals.d.ts.map +1 -0
  387. package/dist/router/signals.js +53 -0
  388. package/dist/router/signals.js.map +1 -0
  389. package/dist/router/types.d.ts +191 -0
  390. package/dist/router/types.d.ts.map +1 -0
  391. package/dist/router/types.js +34 -0
  392. package/dist/router/types.js.map +1 -0
  393. package/dist/router/wake.d.ts +111 -0
  394. package/dist/router/wake.d.ts.map +1 -0
  395. package/dist/router/wake.js +180 -0
  396. package/dist/router/wake.js.map +1 -0
  397. package/dist/server/combined-server.d.ts +95 -0
  398. package/dist/server/combined-server.d.ts.map +1 -0
  399. package/dist/server/combined-server.js +335 -0
  400. package/dist/server/combined-server.js.map +1 -0
  401. package/dist/steering/index.d.ts +11 -0
  402. package/dist/steering/index.d.ts.map +1 -0
  403. package/dist/steering/index.js +11 -0
  404. package/dist/steering/index.js.map +1 -0
  405. package/dist/steering/inject.d.ts +39 -0
  406. package/dist/steering/inject.d.ts.map +1 -0
  407. package/dist/steering/inject.js +197 -0
  408. package/dist/steering/inject.js.map +1 -0
  409. package/dist/steering/types.d.ts +100 -0
  410. package/dist/steering/types.d.ts.map +1 -0
  411. package/dist/steering/types.js +11 -0
  412. package/dist/steering/types.js.map +1 -0
  413. package/dist/store/backends/index.d.ts +11 -0
  414. package/dist/store/backends/index.d.ts.map +1 -0
  415. package/dist/store/backends/index.js +15 -0
  416. package/dist/store/backends/index.js.map +1 -0
  417. package/dist/store/backends/json-backend.d.ts +23 -0
  418. package/dist/store/backends/json-backend.d.ts.map +1 -0
  419. package/dist/store/backends/json-backend.js +220 -0
  420. package/dist/store/backends/json-backend.js.map +1 -0
  421. package/dist/store/backends/memory-backend.d.ts +12 -0
  422. package/dist/store/backends/memory-backend.d.ts.map +1 -0
  423. package/dist/store/backends/memory-backend.js +205 -0
  424. package/dist/store/backends/memory-backend.js.map +1 -0
  425. package/dist/store/backends/sqlite-backend.d.ts +27 -0
  426. package/dist/store/backends/sqlite-backend.d.ts.map +1 -0
  427. package/dist/store/backends/sqlite-backend.js +231 -0
  428. package/dist/store/backends/sqlite-backend.js.map +1 -0
  429. package/dist/store/backends/tinybase-backend.d.ts +22 -0
  430. package/dist/store/backends/tinybase-backend.d.ts.map +1 -0
  431. package/dist/store/backends/tinybase-backend.js +203 -0
  432. package/dist/store/backends/tinybase-backend.js.map +1 -0
  433. package/dist/store/backends/types.d.ts +175 -0
  434. package/dist/store/backends/types.d.ts.map +1 -0
  435. package/dist/store/backends/types.js +28 -0
  436. package/dist/store/backends/types.js.map +1 -0
  437. package/dist/store/event-store.d.ts +128 -0
  438. package/dist/store/event-store.d.ts.map +1 -0
  439. package/dist/store/event-store.js +1751 -0
  440. package/dist/store/event-store.js.map +1 -0
  441. package/dist/store/instance.d.ts +290 -0
  442. package/dist/store/instance.d.ts.map +1 -0
  443. package/dist/store/instance.js +363 -0
  444. package/dist/store/instance.js.map +1 -0
  445. package/dist/store/migrations.d.ts +41 -0
  446. package/dist/store/migrations.d.ts.map +1 -0
  447. package/dist/store/migrations.js +79 -0
  448. package/dist/store/migrations.js.map +1 -0
  449. package/dist/store/test-utils.d.ts +63 -0
  450. package/dist/store/test-utils.d.ts.map +1 -0
  451. package/dist/store/test-utils.js +63 -0
  452. package/dist/store/test-utils.js.map +1 -0
  453. package/dist/store/types/config.d.ts +16 -0
  454. package/dist/store/types/config.d.ts.map +1 -0
  455. package/dist/store/types/config.js +8 -0
  456. package/dist/store/types/config.js.map +1 -0
  457. package/dist/store/types/conversations.d.ts +91 -0
  458. package/dist/store/types/conversations.d.ts.map +1 -0
  459. package/dist/store/types/conversations.js +8 -0
  460. package/dist/store/types/conversations.js.map +1 -0
  461. package/dist/store/types/sessions.d.ts +44 -0
  462. package/dist/store/types/sessions.d.ts.map +1 -0
  463. package/dist/store/types/sessions.js +9 -0
  464. package/dist/store/types/sessions.js.map +1 -0
  465. package/dist/store/types.d.ts +115 -0
  466. package/dist/store/types.d.ts.map +1 -0
  467. package/dist/store/types.js +6 -0
  468. package/dist/store/types.js.map +1 -0
  469. package/dist/task/backend/index.d.ts +93 -0
  470. package/dist/task/backend/index.d.ts.map +1 -0
  471. package/dist/task/backend/index.js +178 -0
  472. package/dist/task/backend/index.js.map +1 -0
  473. package/dist/task/backend/memory.d.ts +70 -0
  474. package/dist/task/backend/memory.d.ts.map +1 -0
  475. package/dist/task/backend/memory.js +621 -0
  476. package/dist/task/backend/memory.js.map +1 -0
  477. package/dist/task/backend/opentasks/backend.d.ts +140 -0
  478. package/dist/task/backend/opentasks/backend.d.ts.map +1 -0
  479. package/dist/task/backend/opentasks/backend.js +1023 -0
  480. package/dist/task/backend/opentasks/backend.js.map +1 -0
  481. package/dist/task/backend/opentasks/client.d.ts +337 -0
  482. package/dist/task/backend/opentasks/client.d.ts.map +1 -0
  483. package/dist/task/backend/opentasks/client.js +225 -0
  484. package/dist/task/backend/opentasks/client.js.map +1 -0
  485. package/dist/task/backend/opentasks/daemon-manager.d.ts +89 -0
  486. package/dist/task/backend/opentasks/daemon-manager.d.ts.map +1 -0
  487. package/dist/task/backend/opentasks/daemon-manager.js +195 -0
  488. package/dist/task/backend/opentasks/daemon-manager.js.map +1 -0
  489. package/dist/task/backend/opentasks/index.d.ts +21 -0
  490. package/dist/task/backend/opentasks/index.d.ts.map +1 -0
  491. package/dist/task/backend/opentasks/index.js +21 -0
  492. package/dist/task/backend/opentasks/index.js.map +1 -0
  493. package/dist/task/backend/opentasks/mapping.d.ts +48 -0
  494. package/dist/task/backend/opentasks/mapping.d.ts.map +1 -0
  495. package/dist/task/backend/opentasks/mapping.js +77 -0
  496. package/dist/task/backend/opentasks/mapping.js.map +1 -0
  497. package/dist/task/backend/sudocode/__tests__/integration/test-utils.d.ts +54 -0
  498. package/dist/task/backend/sudocode/__tests__/integration/test-utils.d.ts.map +1 -0
  499. package/dist/task/backend/sudocode/__tests__/integration/test-utils.js +88 -0
  500. package/dist/task/backend/sudocode/__tests__/integration/test-utils.js.map +1 -0
  501. package/dist/task/backend/sudocode/backend.d.ts +155 -0
  502. package/dist/task/backend/sudocode/backend.d.ts.map +1 -0
  503. package/dist/task/backend/sudocode/backend.js +942 -0
  504. package/dist/task/backend/sudocode/backend.js.map +1 -0
  505. package/dist/task/backend/sudocode/client.d.ts +303 -0
  506. package/dist/task/backend/sudocode/client.d.ts.map +1 -0
  507. package/dist/task/backend/sudocode/client.js +101 -0
  508. package/dist/task/backend/sudocode/client.js.map +1 -0
  509. package/dist/task/backend/sudocode/index.d.ts +19 -0
  510. package/dist/task/backend/sudocode/index.d.ts.map +1 -0
  511. package/dist/task/backend/sudocode/index.js +17 -0
  512. package/dist/task/backend/sudocode/index.js.map +1 -0
  513. package/dist/task/backend/sudocode/mapping.d.ts +51 -0
  514. package/dist/task/backend/sudocode/mapping.d.ts.map +1 -0
  515. package/dist/task/backend/sudocode/mapping.js +86 -0
  516. package/dist/task/backend/sudocode/mapping.js.map +1 -0
  517. package/dist/task/backend/sudocode/server-client.d.ts +56 -0
  518. package/dist/task/backend/sudocode/server-client.d.ts.map +1 -0
  519. package/dist/task/backend/sudocode/server-client.js +367 -0
  520. package/dist/task/backend/sudocode/server-client.js.map +1 -0
  521. package/dist/task/backend/sudocode/standalone-client.d.ts +91 -0
  522. package/dist/task/backend/sudocode/standalone-client.d.ts.map +1 -0
  523. package/dist/task/backend/sudocode/standalone-client.js +476 -0
  524. package/dist/task/backend/sudocode/standalone-client.js.map +1 -0
  525. package/dist/task/backend/sudocode/sync-policy.d.ts +166 -0
  526. package/dist/task/backend/sudocode/sync-policy.d.ts.map +1 -0
  527. package/dist/task/backend/sudocode/sync-policy.js +221 -0
  528. package/dist/task/backend/sudocode/sync-policy.js.map +1 -0
  529. package/dist/task/backend/sudocode/tools.d.ts +87 -0
  530. package/dist/task/backend/sudocode/tools.d.ts.map +1 -0
  531. package/dist/task/backend/sudocode/tools.js +743 -0
  532. package/dist/task/backend/sudocode/tools.js.map +1 -0
  533. package/dist/task/backend/tool-provider.d.ts +56 -0
  534. package/dist/task/backend/tool-provider.d.ts.map +1 -0
  535. package/dist/task/backend/tool-provider.js +424 -0
  536. package/dist/task/backend/tool-provider.js.map +1 -0
  537. package/dist/task/backend/types.d.ts +297 -0
  538. package/dist/task/backend/types.d.ts.map +1 -0
  539. package/dist/task/backend/types.js +27 -0
  540. package/dist/task/backend/types.js.map +1 -0
  541. package/dist/task/backend/unified-tool-provider.d.ts +57 -0
  542. package/dist/task/backend/unified-tool-provider.d.ts.map +1 -0
  543. package/dist/task/backend/unified-tool-provider.js +623 -0
  544. package/dist/task/backend/unified-tool-provider.js.map +1 -0
  545. package/dist/task/index.d.ts +7 -0
  546. package/dist/task/index.d.ts.map +1 -0
  547. package/dist/task/index.js +7 -0
  548. package/dist/task/index.js.map +1 -0
  549. package/dist/task/retry-policy.d.ts +89 -0
  550. package/dist/task/retry-policy.d.ts.map +1 -0
  551. package/dist/task/retry-policy.js +160 -0
  552. package/dist/task/retry-policy.js.map +1 -0
  553. package/dist/task/task-manager.d.ts +70 -0
  554. package/dist/task/task-manager.d.ts.map +1 -0
  555. package/dist/task/task-manager.js +319 -0
  556. package/dist/task/task-manager.js.map +1 -0
  557. package/dist/task/types.d.ts +72 -0
  558. package/dist/task/types.d.ts.map +1 -0
  559. package/dist/task/types.js +33 -0
  560. package/dist/task/types.js.map +1 -0
  561. package/dist/teams/team-loader.d.ts +2 -1
  562. package/dist/teams/team-loader.d.ts.map +1 -1
  563. package/dist/teams/team-loader.js +2 -1
  564. package/dist/teams/team-loader.js.map +1 -1
  565. package/dist/teams/team-manager.d.ts +101 -0
  566. package/dist/teams/team-manager.d.ts.map +1 -0
  567. package/dist/teams/team-manager.js +260 -0
  568. package/dist/teams/team-manager.js.map +1 -0
  569. package/dist/teams/team-runtime-v2.d.ts +0 -3
  570. package/dist/teams/team-runtime-v2.d.ts.map +1 -1
  571. package/dist/teams/team-runtime-v2.js +8 -87
  572. package/dist/teams/team-runtime-v2.js.map +1 -1
  573. package/dist/teams/team-runtime.d.ts +245 -0
  574. package/dist/teams/team-runtime.d.ts.map +1 -0
  575. package/dist/teams/team-runtime.js +1023 -0
  576. package/dist/teams/team-runtime.js.map +1 -0
  577. package/dist/trigger/router/index.d.ts +11 -0
  578. package/dist/trigger/router/index.d.ts.map +1 -0
  579. package/dist/trigger/router/index.js +10 -0
  580. package/dist/trigger/router/index.js.map +1 -0
  581. package/dist/trigger/router/strategies/ai-router-strategy.d.ts +34 -0
  582. package/dist/trigger/router/strategies/ai-router-strategy.d.ts.map +1 -0
  583. package/dist/trigger/router/strategies/ai-router-strategy.js +359 -0
  584. package/dist/trigger/router/strategies/ai-router-strategy.js.map +1 -0
  585. package/dist/trigger/router/strategies/direct-strategy.d.ts +32 -0
  586. package/dist/trigger/router/strategies/direct-strategy.d.ts.map +1 -0
  587. package/dist/trigger/router/strategies/direct-strategy.js +119 -0
  588. package/dist/trigger/router/strategies/direct-strategy.js.map +1 -0
  589. package/dist/trigger/router/strategies/index.d.ts +11 -0
  590. package/dist/trigger/router/strategies/index.d.ts.map +1 -0
  591. package/dist/trigger/router/strategies/index.js +11 -0
  592. package/dist/trigger/router/strategies/index.js.map +1 -0
  593. package/dist/trigger/router/strategies/role-strategy.d.ts +39 -0
  594. package/dist/trigger/router/strategies/role-strategy.d.ts.map +1 -0
  595. package/dist/trigger/router/strategies/role-strategy.js +207 -0
  596. package/dist/trigger/router/strategies/role-strategy.js.map +1 -0
  597. package/dist/trigger/router/trigger-router.d.ts +54 -0
  598. package/dist/trigger/router/trigger-router.d.ts.map +1 -0
  599. package/dist/trigger/router/trigger-router.js +362 -0
  600. package/dist/trigger/router/trigger-router.js.map +1 -0
  601. package/dist/trigger/router/types.d.ts +225 -0
  602. package/dist/trigger/router/types.d.ts.map +1 -0
  603. package/dist/trigger/router/types.js +10 -0
  604. package/dist/trigger/router/types.js.map +1 -0
  605. package/dist/trigger/sources/cron/cron-service.d.ts.map +1 -1
  606. package/dist/trigger/sources/cron/cron-service.js +6 -3
  607. package/dist/trigger/sources/cron/cron-service.js.map +1 -1
  608. package/dist/trigger/trigger-system.d.ts +77 -0
  609. package/dist/trigger/trigger-system.d.ts.map +1 -0
  610. package/dist/trigger/trigger-system.js +84 -0
  611. package/dist/trigger/trigger-system.js.map +1 -0
  612. package/dist/util/git-safety.d.ts +33 -0
  613. package/dist/util/git-safety.d.ts.map +1 -0
  614. package/dist/util/git-safety.js +94 -0
  615. package/dist/util/git-safety.js.map +1 -0
  616. package/dist/workspace/dataplane-adapter.d.ts +260 -0
  617. package/dist/workspace/dataplane-adapter.d.ts.map +1 -0
  618. package/dist/workspace/dataplane-adapter.js +416 -0
  619. package/dist/workspace/dataplane-adapter.js.map +1 -0
  620. package/dist/workspace/index.d.ts +0 -1
  621. package/dist/workspace/index.d.ts.map +1 -1
  622. package/dist/workspace/index.js +0 -2
  623. package/dist/workspace/index.js.map +1 -1
  624. package/dist/workspace/landing/direct-push.d.ts.map +1 -1
  625. package/dist/workspace/landing/direct-push.js +22 -7
  626. package/dist/workspace/landing/direct-push.js.map +1 -1
  627. package/dist/workspace/landing/queue-to-branch.d.ts.map +1 -1
  628. package/dist/workspace/landing/queue-to-branch.js +1 -3
  629. package/dist/workspace/landing/queue-to-branch.js.map +1 -1
  630. package/dist/workspace/types.d.ts +0 -13
  631. package/dist/workspace/types.d.ts.map +1 -1
  632. package/dist/workspace/workspace-manager.d.ts +0 -11
  633. package/dist/workspace/workspace-manager.d.ts.map +1 -1
  634. package/dist/workspace/workspace-manager.js +0 -30
  635. package/dist/workspace/workspace-manager.js.map +1 -1
  636. package/package.json +28 -2
  637. package/templates/teams/self-driving/prompts/grinder.md +1 -0
  638. package/templates/teams/self-driving/prompts/judge.md +1 -0
  639. package/templates/teams/self-driving/prompts/planner.md +1 -0
  640. package/templates/teams/self-driving/roles/grinder.yaml +15 -0
  641. package/templates/teams/self-driving/roles/judge.yaml +10 -0
  642. package/templates/teams/self-driving/roles/planner.yaml +16 -0
  643. package/.claude/commands/openspec/apply.md +0 -23
  644. package/.claude/commands/openspec/archive.md +0 -27
  645. package/.claude/commands/openspec/proposal.md +0 -28
  646. package/.claude/settings.json +0 -133
  647. package/.gitattributes +0 -3
  648. package/.opentasks/config.json +0 -9
  649. package/.opentasks/graph.jsonl +0 -0
  650. package/.sessionlog/settings.json +0 -4
  651. package/.sudocode/issues.jsonl +0 -183
  652. package/.sudocode/specs.jsonl +0 -56
  653. package/AGENTS.md +0 -18
  654. package/CLAUDE.md +0 -923
  655. package/docs/architecture.md +0 -508
  656. package/docs/configuration.md +0 -323
  657. package/docs/conflict-recovery.md +0 -472
  658. package/docs/design/task-dispatcher.md +0 -880
  659. package/docs/design-subsystem-extraction.md +0 -627
  660. package/docs/git-cascade-integration-gaps.md +0 -678
  661. package/docs/implementation-details.md +0 -1127
  662. package/docs/implementation-summary.md +0 -448
  663. package/docs/lifecycle-events-design.md +0 -111
  664. package/docs/mail-integration.md +0 -608
  665. package/docs/openhive-capability-summary.md +0 -415
  666. package/docs/openhive-integration.md +0 -415
  667. package/docs/plan-self-driving-support.md +0 -433
  668. package/docs/roadmap-v2-gaps.md +0 -216
  669. package/docs/spec-self-driving-support.md +0 -462
  670. package/docs/team-templates.md +0 -860
  671. package/docs/teams.md +0 -306
  672. package/docs/trigger-system-design.md +0 -333
  673. package/docs/troubleshooting.md +0 -489
  674. package/docs/workspace-interfaces.md +0 -731
  675. package/docs/workspace-redesign-plan.md +0 -302
  676. package/examples/distributed-peer-communication.ts +0 -202
  677. package/examples/local-peer-communication.ts +0 -165
  678. package/index.js +0 -2
  679. package/mvp_docs/agent-execution-system.md +0 -347
  680. package/mvp_docs/agent-interface.md +0 -580
  681. package/mvp_docs/data-structures.md +0 -701
  682. package/mvp_docs/dynamic-meta-orchestration.md +0 -116
  683. package/mvp_docs/multi-agent-interaction-design.md +0 -779
  684. package/mvp_docs/mvp-implementation-plan.md +0 -1148
  685. package/renovate.json5 +0 -6
  686. package/scripts/test-acp-integration.ts +0 -422
  687. package/src/__tests__/boot-v2.test.ts +0 -631
  688. package/src/__tests__/e2e/acp-over-map-live.e2e.test.ts +0 -496
  689. package/src/__tests__/e2e/acp-over-map.e2e.test.ts +0 -457
  690. package/src/__tests__/e2e/agent-lifecycle.e2e.test.ts +0 -770
  691. package/src/__tests__/e2e/auto-sync.e2e.test.ts +0 -257
  692. package/src/__tests__/e2e/bootstrap.e2e.test.ts +0 -319
  693. package/src/__tests__/e2e/cascade-rebase.e2e.test.ts +0 -254
  694. package/src/__tests__/e2e/cc-swarm-bridge.e2e.test.ts +0 -253
  695. package/src/__tests__/e2e/cli-run.e2e.test.ts +0 -167
  696. package/src/__tests__/e2e/cognitive-workspace.e2e.test.ts +0 -282
  697. package/src/__tests__/e2e/dispatch-coordination.e2e.test.ts +0 -495
  698. package/src/__tests__/e2e/dispatch-live.e2e.test.ts +0 -564
  699. package/src/__tests__/e2e/dispatch-opentasks.e2e.test.ts +0 -496
  700. package/src/__tests__/e2e/dispatch-phase2-live.e2e.test.ts +0 -456
  701. package/src/__tests__/e2e/dispatch-phase2.e2e.test.ts +0 -386
  702. package/src/__tests__/e2e/dispatch.e2e.test.ts +0 -376
  703. package/src/__tests__/e2e/done-scenarios.e2e.test.ts +0 -322
  704. package/src/__tests__/e2e/live-agent.e2e.test.ts +0 -1330
  705. package/src/__tests__/e2e/map-server.e2e.test.ts +0 -128
  706. package/src/__tests__/e2e/map-sidecar.e2e.test.ts +0 -139
  707. package/src/__tests__/e2e/opentasks-integration.e2e.test.ts +0 -280
  708. package/src/__tests__/e2e/pull-mode.e2e.test.ts +0 -632
  709. package/src/__tests__/e2e/resume-continue.e2e.test.ts +0 -312
  710. package/src/__tests__/e2e/self-driving-v3.e2e.test.ts +0 -197
  711. package/src/__tests__/e2e/spawn-resolver.e2e.test.ts +0 -200
  712. package/src/__tests__/e2e/swarmkit-integration.e2e.test.ts +0 -562
  713. package/src/__tests__/e2e/swarmkit-live.e2e.test.ts +0 -1049
  714. package/src/__tests__/e2e/trajectory-tracking.e2e.test.ts +0 -258
  715. package/src/__tests__/e2e/trigger-wake.e2e.test.ts +0 -257
  716. package/src/__tests__/e2e/workspace-lifecycle.e2e.test.ts +0 -383
  717. package/src/__tests__/e2e/workspace-v3.e2e.test.ts +0 -413
  718. package/src/acp/__tests__/claude-code-replay.test.ts +0 -225
  719. package/src/acp/__tests__/macro-agent.test.ts +0 -387
  720. package/src/acp/__tests__/session-mapper.test.ts +0 -152
  721. package/src/acp/__tests__/websocket-server.test.ts +0 -194
  722. package/src/acp/claude-code-replay.ts +0 -208
  723. package/src/acp/index.ts +0 -32
  724. package/src/acp/macro-agent.ts +0 -995
  725. package/src/acp/map-bridge.ts +0 -193
  726. package/src/acp/session-mapper.ts +0 -116
  727. package/src/acp/types.ts +0 -99
  728. package/src/acp/websocket-server.ts +0 -213
  729. package/src/adapters/__tests__/federation.test.ts +0 -256
  730. package/src/adapters/__tests__/inbox-adapter.test.ts +0 -316
  731. package/src/adapters/__tests__/tasks-adapter.test.ts +0 -270
  732. package/src/adapters/federation.ts +0 -185
  733. package/src/adapters/inbox-adapter.ts +0 -292
  734. package/src/adapters/inbox-client-adapter.ts +0 -173
  735. package/src/adapters/index.ts +0 -44
  736. package/src/adapters/opentasks-daemon.ts +0 -252
  737. package/src/adapters/tasks-adapter.ts +0 -330
  738. package/src/adapters/types.ts +0 -286
  739. package/src/agent/__tests__/agent-manager-topology.test.ts +0 -73
  740. package/src/agent/__tests__/agent-manager-v2.completion-signal.test.ts +0 -284
  741. package/src/agent/__tests__/agent-manager-v2.permission-interception.test.ts +0 -296
  742. package/src/agent/__tests__/agent-manager-v2.permissions.test.ts +0 -233
  743. package/src/agent/__tests__/agent-manager-v2.test.ts +0 -614
  744. package/src/agent/__tests__/agent-store.test.ts +0 -465
  745. package/src/agent/__tests__/task-ref-resolution.test.ts +0 -231
  746. package/src/agent/agent-manager-v2.ts +0 -2187
  747. package/src/agent/agent-manager.ts +0 -403
  748. package/src/agent/agent-store.ts +0 -409
  749. package/src/agent/index.ts +0 -7
  750. package/src/agent/prompts/coordinator-signals.ts +0 -115
  751. package/src/agent/prompts/index.ts +0 -7
  752. package/src/agent/system-prompt.ts +0 -298
  753. package/src/agent/types.ts +0 -480
  754. package/src/agent-detection/__tests__/command-builder.test.ts +0 -336
  755. package/src/agent-detection/__tests__/detector.test.ts +0 -768
  756. package/src/agent-detection/__tests__/registry.test.ts +0 -254
  757. package/src/agent-detection/command-builder.ts +0 -90
  758. package/src/agent-detection/detector.ts +0 -307
  759. package/src/agent-detection/index.ts +0 -36
  760. package/src/agent-detection/registry.ts +0 -200
  761. package/src/agent-detection/types.ts +0 -184
  762. package/src/api/__tests__/server.test.ts +0 -292
  763. package/src/api/index.ts +0 -8
  764. package/src/api/server.ts +0 -380
  765. package/src/api/types.ts +0 -39
  766. package/src/auth/__tests__/token.test.ts +0 -100
  767. package/src/auth/index.ts +0 -1
  768. package/src/auth/token.ts +0 -82
  769. package/src/boot-v2.ts +0 -1343
  770. package/src/cli/__tests__/stable-instance-id.test.ts +0 -57
  771. package/src/cli/acp.ts +0 -101
  772. package/src/cli/inbox-mcp-proxy.ts +0 -56
  773. package/src/cli/index.ts +0 -566
  774. package/src/cli/mcp.ts +0 -305
  775. package/src/cli/parse-args.ts +0 -54
  776. package/src/cli/stable-instance-id.ts +0 -14
  777. package/src/cognitive/__tests__/macro-agent-backend.test.ts +0 -673
  778. package/src/cognitive/__tests__/session-converter.test.ts +0 -423
  779. package/src/cognitive/__tests__/workspace-handler.test.ts +0 -221
  780. package/src/cognitive/analyst-role.ts +0 -59
  781. package/src/cognitive/index.ts +0 -49
  782. package/src/cognitive/macro-agent-backend.ts +0 -402
  783. package/src/cognitive/session-converter.ts +0 -151
  784. package/src/cognitive/types.ts +0 -187
  785. package/src/cognitive/workspace-handler.ts +0 -163
  786. package/src/config/index.ts +0 -9
  787. package/src/config/project-config.ts +0 -294
  788. package/src/control/__tests__/control-resilience.test.ts +0 -251
  789. package/src/control/__tests__/control-socket.test.ts +0 -240
  790. package/src/control/control-client.ts +0 -337
  791. package/src/control/control-server.ts +0 -298
  792. package/src/control/index.ts +0 -17
  793. package/src/control/types.ts +0 -95
  794. package/src/dispatch/CLAUDE.md +0 -129
  795. package/src/dispatch/__tests__/loadout-translation.test.ts +0 -141
  796. package/src/dispatch/__tests__/mail-inbound-consumer.integration.test.ts +0 -519
  797. package/src/dispatch/__tests__/mail-inbound-consumer.test.ts +0 -800
  798. package/src/dispatch/__tests__/mail-inbound-reuse-consumer.test.ts +0 -575
  799. package/src/dispatch/__tests__/permission-evaluator.test.ts +0 -196
  800. package/src/dispatch/__tests__/permission-overlay.test.ts +0 -56
  801. package/src/dispatch/__tests__/permissions-handler.test.ts +0 -168
  802. package/src/dispatch/__tests__/spawn-agent-handler.test.ts +0 -282
  803. package/src/dispatch/loadout-translation.ts +0 -138
  804. package/src/dispatch/mail-inbound-consumer.ts +0 -560
  805. package/src/dispatch/mail-inbound-reuse-consumer.ts +0 -479
  806. package/src/dispatch/permission-evaluator.ts +0 -191
  807. package/src/dispatch/permission-overlay.ts +0 -89
  808. package/src/dispatch/permissions-handler.ts +0 -112
  809. package/src/dispatch/spawn-agent-handler.ts +0 -160
  810. package/src/index.ts +0 -117
  811. package/src/integrations/__tests__/context-builder.test.ts +0 -218
  812. package/src/integrations/__tests__/sessionlog.test.ts +0 -498
  813. package/src/integrations/__tests__/skilltree.test.ts +0 -136
  814. package/src/integrations/context-builder.ts +0 -280
  815. package/src/integrations/sessionlog.ts +0 -194
  816. package/src/integrations/skilltree.ts +0 -184
  817. package/src/lifecycle/__tests__/cascade-consolidation.test.ts +0 -240
  818. package/src/lifecycle/__tests__/handlers-v2.test.ts +0 -565
  819. package/src/lifecycle/cascade.ts +0 -335
  820. package/src/lifecycle/cleanup.ts +0 -373
  821. package/src/lifecycle/handlers-v2.ts +0 -508
  822. package/src/lifecycle/index.ts +0 -76
  823. package/src/lifecycle/types.ts +0 -260
  824. package/src/map/__tests__/cascade-bridge.test.ts +0 -229
  825. package/src/map/__tests__/cascade-diff-server.test.ts +0 -434
  826. package/src/map/__tests__/emit-event.test.ts +0 -71
  827. package/src/map/__tests__/lifecycle-bridge.test.ts +0 -430
  828. package/src/map/__tests__/mail-bridge.test.ts +0 -321
  829. package/src/map/__tests__/permission-forwarding.test.ts +0 -143
  830. package/src/map/__tests__/sidecar-diff-install-smoke.test.ts +0 -90
  831. package/src/map/__tests__/sidecar-integration.test.ts +0 -190
  832. package/src/map/__tests__/task-bridge.test.ts +0 -153
  833. package/src/map/__tests__/trajectory-reporter.test.ts +0 -173
  834. package/src/map/acp-bridge.ts +0 -293
  835. package/src/map/cascade-action-handler.ts +0 -205
  836. package/src/map/cascade-bridge.ts +0 -339
  837. package/src/map/cascade-diff-server.ts +0 -404
  838. package/src/map/cc-swarm-hooks.ts +0 -242
  839. package/src/map/coordination-handler.ts +0 -232
  840. package/src/map/index.ts +0 -18
  841. package/src/map/lifecycle-bridge.ts +0 -236
  842. package/src/map/mail-bridge.ts +0 -263
  843. package/src/map/repo-workspace.ts +0 -82
  844. package/src/map/server.ts +0 -758
  845. package/src/map/sidecar.ts +0 -826
  846. package/src/map/task-bridge.ts +0 -89
  847. package/src/map/trajectory-reporter.ts +0 -124
  848. package/src/map/types.ts +0 -304
  849. package/src/mcp/__tests__/mcp-server-v2.test.ts +0 -236
  850. package/src/mcp/index.ts +0 -6
  851. package/src/mcp/mcp-server-v2.ts +0 -485
  852. package/src/mcp/tools/done-v2.ts +0 -213
  853. package/src/mcp/types.ts +0 -432
  854. package/src/metrics/__tests__/metrics.test.ts +0 -205
  855. package/src/metrics/index.ts +0 -13
  856. package/src/metrics/metrics.ts +0 -151
  857. package/src/metrics/types.ts +0 -63
  858. package/src/roles/__tests__/config-loader.test.ts +0 -540
  859. package/src/roles/builtin/coordinator.ts +0 -75
  860. package/src/roles/builtin/generic.ts +0 -39
  861. package/src/roles/builtin/index.ts +0 -51
  862. package/src/roles/builtin/integrator.ts +0 -62
  863. package/src/roles/builtin/monitor.ts +0 -65
  864. package/src/roles/builtin/worker.ts +0 -134
  865. package/src/roles/capabilities.ts +0 -257
  866. package/src/roles/config-loader.ts +0 -405
  867. package/src/roles/index.ts +0 -141
  868. package/src/roles/registry.ts +0 -713
  869. package/src/roles/types.ts +0 -344
  870. package/src/store/index.ts +0 -8
  871. package/src/store/types/agents.ts +0 -69
  872. package/src/store/types/events.ts +0 -91
  873. package/src/store/types/index.ts +0 -9
  874. package/src/store/types/messages.ts +0 -32
  875. package/src/store/types/primitives.ts +0 -9
  876. package/src/store/types/tasks.ts +0 -124
  877. package/src/teams/__tests__/team-manager-v2.test.ts +0 -425
  878. package/src/teams/__tests__/team-runtime-v2.test.ts +0 -402
  879. package/src/teams/index.ts +0 -29
  880. package/src/teams/seed-defaults.ts +0 -83
  881. package/src/teams/team-loader.ts +0 -476
  882. package/src/teams/team-manager-v2.ts +0 -343
  883. package/src/teams/team-runtime-v2.ts +0 -943
  884. package/src/teams/types.ts +0 -276
  885. package/src/trigger/__tests__/cron-service.test.ts +0 -548
  886. package/src/trigger/__tests__/scheduler.test.ts +0 -371
  887. package/src/trigger/__tests__/system-event-queue.test.ts +0 -147
  888. package/src/trigger/__tests__/trigger-system-v2.test.ts +0 -257
  889. package/src/trigger/__tests__/wake-manager.test.ts +0 -356
  890. package/src/trigger/__tests__/webhook-handler.test.ts +0 -567
  891. package/src/trigger/index.ts +0 -110
  892. package/src/trigger/queue/index.ts +0 -21
  893. package/src/trigger/queue/system-event-queue.ts +0 -232
  894. package/src/trigger/queue/types.ts +0 -149
  895. package/src/trigger/sources/cron/cron-service.ts +0 -499
  896. package/src/trigger/sources/cron/index.ts +0 -41
  897. package/src/trigger/sources/cron/scheduler.ts +0 -344
  898. package/src/trigger/sources/cron/types.ts +0 -333
  899. package/src/trigger/sources/index.ts +0 -10
  900. package/src/trigger/sources/webhook/index.ts +0 -25
  901. package/src/trigger/sources/webhook/types.ts +0 -205
  902. package/src/trigger/sources/webhook/webhook-handler.ts +0 -410
  903. package/src/trigger/strategies/ai-router.ts +0 -170
  904. package/src/trigger/trigger-system-v2.ts +0 -536
  905. package/src/trigger/types.ts +0 -228
  906. package/src/trigger/wake/index.ts +0 -22
  907. package/src/trigger/wake/types.ts +0 -162
  908. package/src/trigger/wake/wake-manager.ts +0 -390
  909. package/src/workspace/__tests__/git-cascade-adapter.test.ts +0 -563
  910. package/src/workspace/__tests__/land-dispatch.test.ts +0 -214
  911. package/src/workspace/__tests__/self-driving-yaml.test.ts +0 -122
  912. package/src/workspace/__tests__/shared-worktree-refcount.test.ts +0 -154
  913. package/src/workspace/__tests__/standalone-mode.test.ts +0 -118
  914. package/src/workspace/__tests__/workspace-manager-v3.test.ts +0 -245
  915. package/src/workspace/__tests__/yaml-schema.test.ts +0 -210
  916. package/src/workspace/config.ts +0 -165
  917. package/src/workspace/git-cascade-adapter.ts +0 -1213
  918. package/src/workspace/index.ts +0 -110
  919. package/src/workspace/landing/__tests__/strategies.test.ts +0 -184
  920. package/src/workspace/landing/direct-push.ts +0 -91
  921. package/src/workspace/landing/index.ts +0 -40
  922. package/src/workspace/landing/merge-to-parent.ts +0 -229
  923. package/src/workspace/landing/optimistic-push.ts +0 -36
  924. package/src/workspace/landing/queue-to-branch.ts +0 -108
  925. package/src/workspace/merge-queue/__tests__/conflict-resolution-git.e2e.test.ts +0 -641
  926. package/src/workspace/merge-queue/__tests__/conflict-resolution.test.ts +0 -707
  927. package/src/workspace/merge-queue/__tests__/merge-queue-concurrent.test.ts +0 -628
  928. package/src/workspace/merge-queue/__tests__/merge-queue-edge-cases.test.ts +0 -1217
  929. package/src/workspace/merge-queue/__tests__/merge-queue.test.ts +0 -506
  930. package/src/workspace/merge-queue/__tests__/real-git-operations.e2e.test.ts +0 -556
  931. package/src/workspace/merge-queue/__tests__/resolver-flow.test.ts +0 -472
  932. package/src/workspace/merge-queue/index.ts +0 -38
  933. package/src/workspace/merge-queue/merge-queue.ts +0 -585
  934. package/src/workspace/merge-queue/schema.ts +0 -98
  935. package/src/workspace/merge-queue/types.ts +0 -316
  936. package/src/workspace/pool/__tests__/worktree-pool.integration.test.ts +0 -1281
  937. package/src/workspace/pool/__tests__/worktree-pool.test.ts +0 -590
  938. package/src/workspace/pool/index.ts +0 -26
  939. package/src/workspace/pool/types.ts +0 -276
  940. package/src/workspace/pool/worktree-pool.ts +0 -659
  941. package/src/workspace/recovery/__tests__/auto-resolve-integration.test.ts +0 -127
  942. package/src/workspace/recovery/__tests__/spawn-resolver.test.ts +0 -139
  943. package/src/workspace/recovery/__tests__/strategies.test.ts +0 -145
  944. package/src/workspace/recovery/abandon.ts +0 -51
  945. package/src/workspace/recovery/auto-resolve.ts +0 -119
  946. package/src/workspace/recovery/defer.ts +0 -23
  947. package/src/workspace/recovery/escalate.ts +0 -30
  948. package/src/workspace/recovery/index.ts +0 -58
  949. package/src/workspace/recovery/spawn-resolver.ts +0 -152
  950. package/src/workspace/recovery/types.ts +0 -54
  951. package/src/workspace/strategies/index.ts +0 -18
  952. package/src/workspace/strategies/optimistic.ts +0 -139
  953. package/src/workspace/strategies/queue.ts +0 -81
  954. package/src/workspace/strategies/registry.ts +0 -89
  955. package/src/workspace/strategies/trunk.ts +0 -123
  956. package/src/workspace/strategies/types.ts +0 -145
  957. package/src/workspace/topology/__tests__/yaml-driven.test.ts +0 -345
  958. package/src/workspace/topology/index.ts +0 -18
  959. package/src/workspace/topology/no-workspace.ts +0 -39
  960. package/src/workspace/topology/types.ts +0 -116
  961. package/src/workspace/topology/yaml-driven.ts +0 -316
  962. package/src/workspace/types-v3.ts +0 -162
  963. package/src/workspace/types.ts +0 -541
  964. package/src/workspace/workspace-manager.ts +0 -1577
  965. package/src/workspace/yaml-schema.ts +0 -216
  966. package/test_fixtures/README.md +0 -425
  967. package/test_fixtures/fixtures/behaviors/coordinators.ts +0 -196
  968. package/test_fixtures/fixtures/behaviors/index.ts +0 -62
  969. package/test_fixtures/fixtures/behaviors/integrators.ts +0 -143
  970. package/test_fixtures/fixtures/behaviors/monitors.ts +0 -199
  971. package/test_fixtures/fixtures/behaviors/workers.ts +0 -348
  972. package/test_fixtures/fixtures/index.ts +0 -7
  973. package/test_fixtures/fixtures/projects/index.ts +0 -23
  974. package/test_fixtures/fixtures/projects/project-with-specs.ts +0 -44
  975. package/test_fixtures/fixtures/projects/typescript-project.ts +0 -200
  976. package/test_fixtures/fixtures/repos/index.ts +0 -6
  977. package/test_fixtures/fixtures/repos/temp-repo-factory.ts +0 -299
  978. package/test_fixtures/fixtures/repos/types.ts +0 -174
  979. package/test_fixtures/harness/assertions/harness-assertions.ts +0 -752
  980. package/test_fixtures/harness/assertions/index.ts +0 -8
  981. package/test_fixtures/harness/index.ts +0 -15
  982. package/test_fixtures/harness/simulator/agent-simulator.ts +0 -768
  983. package/test_fixtures/harness/simulator/behavior-executor.ts +0 -580
  984. package/test_fixtures/harness/simulator/index.ts +0 -14
  985. package/test_fixtures/harness/simulator/types.ts +0 -459
  986. package/test_fixtures/harness/test-harness.ts +0 -770
  987. package/test_fixtures/harness/timing/event-stepper.ts +0 -344
  988. package/test_fixtures/harness/timing/index.ts +0 -8
  989. package/tsconfig.json +0 -21
  990. package/vitest.config.ts +0 -30
  991. package/vitest.e2e.config.ts +0 -28
  992. package/vitest.setup.ts +0 -12
@@ -1,433 +0,0 @@
1
- # Self-Driving Codebases Support
2
-
3
- Plan for enabling macro-agent to support Cursor-style autonomous multi-agent workflows through a modular team template layer and a set of new primitives.
4
-
5
- ## Context
6
-
7
- macro-agent currently provides a structured, correctness-oriented multi-agent orchestration system with four built-in roles (Worker, Integrator, Coordinator, Monitor), workspace isolation via git worktrees, a serialized merge queue, and push-based task assignment.
8
-
9
- Cursor's ["Towards Self-Driving Codebases"](https://cursor.com/blog/self-driving-codebases) demonstrates a different paradigm: hundreds of agents running autonomously for weeks, committing directly to trunk, tolerating transient errors, and self-converging without centralized integration gates. Their system uses Planners (continuous exploration + task creation), Workers (pull tasks, grind, push), and Judges (periodic quality evaluation).
10
-
11
- The goal is to enable macro-agent to support **both** paradigms — the existing structured mode and a self-driving mode — through a modular team template layer and a set of new primitives. macro-agent's core remains role-agnostic; the self-driving patterns are expressed as a loadable team configuration on top.
12
-
13
- ## Goals
14
-
15
- 1. **Team Templates**: A modular system for loading pre-configured agent team structures that define roles, spawn patterns, integration strategies, and coordination protocols — without modifying macro-agent core.
16
- 2. **Task Pull Model**: Primitives for agents to discover and claim available tasks, enabling decoupled planning/execution and elastic scaling.
17
- 3. **Pluggable Integration Strategies**: A strategy interface that the worker done() handler dispatches to, with built-in implementations for merge-queue, trunk-based, and optimistic integration — and the ability to register custom strategies.
18
- 4. **Session Continuations**: Persist agent session history so long-running agents can be resumed across process restarts, enabling multi-day autonomous operation.
19
- 5. **Autonomous Observability**: Metrics primitives for monitoring throughput, error rates, and convergence during long-running multi-agent runs.
20
-
21
- ## Non-Goals
22
-
23
- - Rewriting the existing role system — team templates compose on top of it
24
- - Building a full dashboard UI — only the data/API layer
25
- - Implementing specific team templates beyond one reference "self-driving" template
26
- - Changing the ACP/process model — session continuations are about history, not in-process agent lifecycle
27
- - Horizontal scaling across machines — single-machine focus for now
28
-
29
- ---
30
-
31
- ## Design Decisions
32
-
33
- ### D1: Team Templates as Configuration, Not Code
34
-
35
- Team templates are directories of YAML configuration files that compose roles, define spawn graphs, set integration strategies, and configure coordination protocols. They are loaded by the existing `RoleRegistry` layered config system and a new `TeamLoader`.
36
-
37
- **Alternatives considered**:
38
- - **Programmatic API**: Define teams in TypeScript. More flexible but requires code changes for each team shape. Rejected — config is more accessible and shareable.
39
- - **Single monolithic config**: One file per team. Rejected — doesn't compose well with the existing layered role override system.
40
-
41
- **Rationale**: The existing `.multiagent/roles/*.yaml` pattern already supports custom roles with inheritance. Team templates extend this with a `team.yaml` manifest that declares which roles participate, how they're spawned, and what strategies they use. The same role definitions work in both structured and self-driving modes — only the orchestration layer differs.
42
-
43
- ### D2: Task Pull via `claim_task` with Optimistic Locking
44
-
45
- Add a `claim_task` MCP tool and corresponding `TaskBackend.claim()` method. Workers call `claim_task` with optional filters (status, tags, role). The backend atomically transitions the task from `pending`/`ready` to `assigned` using optimistic locking (compare-and-swap on version/status). If the claim fails (another worker got it), the worker retries or picks a different task.
46
-
47
- **Alternatives considered**:
48
- - **Central dispatcher**: A coordinator assigns tasks to workers. This is the current push model — works but creates a bottleneck at scale.
49
- - **Message-based bidding**: Workers bid on tasks via messages, coordinator selects winner. Too much round-trip overhead for high-throughput scenarios.
50
-
51
- **Rationale**: Pull-based with optimistic locking is the simplest model that scales. No coordinator bottleneck, no bidding overhead. Workers are autonomous — they claim, execute, and report. The task backend is the only coordination point, and SQLite handles contention well for single-machine deployments.
52
-
53
- ### D3: Integration Strategy as a Pluggable Interface
54
-
55
- Integration is handled through an `IntegrationStrategy` interface that the worker `done()` handler dispatches to. The interface has a single responsibility: take a worker's completed work and land it on the integration branch.
56
-
57
- ```typescript
58
- /**
59
- * Pluggable integration strategy interface.
60
- *
61
- * Implementations control how worker changes are landed onto
62
- * the integration branch. The worker done() handler dispatches
63
- * to the active strategy instead of hardcoding merge queue logic.
64
- */
65
- interface IntegrationStrategy {
66
- /** Unique identifier for this strategy */
67
- readonly name: string;
68
-
69
- /**
70
- * Land a worker's completed changes onto the integration branch.
71
- *
72
- * @returns Result indicating success, conflict, or abandonment
73
- */
74
- land(request: LandRequest): Promise<LandResult>;
75
-
76
- /**
77
- * Called when the strategy is initialized for a stream.
78
- * Opportunity to set up any backing resources (queues, branches, etc).
79
- */
80
- initialize?(streamId: string, config: Record<string, unknown>): Promise<void>;
81
-
82
- /**
83
- * Called when the strategy is torn down.
84
- */
85
- close?(): Promise<void>;
86
- }
87
-
88
- interface LandRequest {
89
- /** Stream (integration branch) this targets */
90
- streamId: string;
91
- /** Worker's branch containing changes */
92
- workerBranch: string;
93
- /** Target integration branch */
94
- integrationBranch: string;
95
- /** ID of the worker agent */
96
- workerAgentId: string;
97
- /** Task ID this completes */
98
- taskId: string;
99
- /** Workspace path for git operations */
100
- workspacePath: string;
101
- /** Strategy-specific options from team config */
102
- options?: Record<string, unknown>;
103
- }
104
-
105
- type LandResult =
106
- | { status: 'landed'; mergeCommit: string }
107
- | { status: 'conflict'; conflictFiles: string[]; action: 'abandoned' | 'queued_for_resolution' }
108
- | { status: 'retry_exhausted'; attempts: number }
109
- | { status: 'failed'; error: string };
110
- ```
111
-
112
- Three built-in implementations, plus support for custom strategies:
113
-
114
- | Strategy | Class | Behavior |
115
- |----------|-------|----------|
116
- | `queue` | `QueueIntegrationStrategy` | Wraps existing `MergeQueueInterface`. Submits merge request to queue; integrator processes serially. Current behavior, no changes. |
117
- | `trunk` | `TrunkIntegrationStrategy` | Direct push to integration branch. On conflict: rebase and retry up to `maxRetries` times. On exhaustion: `conflictAction` determines abandon vs. resolve. |
118
- | `optimistic` | `OptimisticIntegrationStrategy` | Push immediately. Emit `validation:requested` event. Background validator checks CI; creates fixup tasks on failure; snapshots green branch on success. |
119
- | custom | User-provided | Register via `IntegrationStrategyRegistry.register(name, factory)`. Factory receives config from `team.yaml`. |
120
-
121
- **Alternatives considered**:
122
- - **Per-agent strategy**: Each worker chooses its integration approach. Rejected — creates unpredictable behavior and merge chaos.
123
- - **Hardcoded strategy selection via switch/case**: Simpler but not extensible. Rejected — users need to implement custom strategies for their specific CI/CD pipelines.
124
- - **Hardcoded trunk-only**: Remove merge queue entirely. Rejected — existing users depend on the queue for correctness.
125
-
126
- **Rationale**: A pluggable interface makes integration strategies a first-class extension point. The `queue` strategy wraps existing behavior with zero changes. The worker `done()` handler becomes simpler — it delegates to `strategy.land()` instead of containing merge queue logic directly. Custom strategies can implement organization-specific workflows (e.g., PR-based integration, CI-gated merge, staging branch promotion).
127
-
128
- **Integration with worker done() handler**: Today, the worker handler in `src/lifecycle/handlers/worker.ts` directly submits to the merge queue (Step 4, lines ~229-387). This gets replaced with:
129
-
130
- ```typescript
131
- // Step 4: Land changes via integration strategy
132
- if (args.status === 'completed' && context.workspacePath) {
133
- const strategy = deps.integrationStrategy; // injected via WorkerHandlerDeps
134
- const result = await strategy.land({
135
- streamId: context.streamId,
136
- workerBranch: sourceBranch,
137
- integrationBranch: targetBranch,
138
- workerAgentId: context.agentId,
139
- taskId: context.taskId,
140
- workspacePath: context.workspacePath,
141
- });
142
- // Handle result...
143
- }
144
- ```
145
-
146
- ### D4: Session Continuations via Persisted Conversation History
147
-
148
- Agent session history (the conversation transcript with the LLM) is persisted to the EventStore. When an agent needs to resume (after a crash, timeout, or deliberate pause), a new process is spawned with the prior conversation loaded as context. The agent receives a resume prompt explaining it's continuing a previous session.
149
-
150
- This is explicitly NOT about keeping a process alive forever. Long-running operation means: work -> pause -> resume -> work -> pause -> resume, potentially across days.
151
-
152
- **Alternatives considered**:
153
- - **Keep processes alive**: Run agent processes indefinitely. Rejected — processes crash, machines restart, and context windows fill up. Resumption is more robust than persistence.
154
- - **Checkpoint-based**: Save structured state (current task, progress, decisions). Rejected — too lossy. The conversation transcript IS the state; structured checkpoints can't capture the nuance of in-flight reasoning.
155
-
156
- **Rationale**: Long-running agents are about continuing session history, not keeping processes alive. This aligns with how Claude Code already works — sessions can be resumed. We just need to persist the transcript and provide a clean resume mechanism at the macro-agent level.
157
-
158
- ### D5: Observability as EventStore Materialized Views
159
-
160
- Add new materialized views to the EventStore for autonomous operation metrics:
161
- - **Throughput view**: commits/hour, tasks completed/hour, tasks created/hour (sliding window)
162
- - **Health view**: build pass rate, error rate, agent utilization (active/idle/blocked)
163
- - **Convergence view**: time-to-fix after breakage, conflict frequency
164
-
165
- These are computed from existing events (spawn, terminate, task status changes, merge events). No new event types needed — just new projections over existing data.
166
-
167
- **Alternatives considered**:
168
- - **External metrics system**: Export to Prometheus/Grafana. Rejected for now — adds infrastructure dependency. Can be added later as an adapter.
169
- - **Per-query computation**: Calculate metrics on demand from raw events. Rejected — too slow for dashboards with thousands of events.
170
-
171
- **Rationale**: The EventStore already supports materialized views (agent view, task view, message queue). Adding metric views follows the same pattern. The API server can expose these via new endpoints, and a future dashboard can consume them.
172
-
173
- ---
174
-
175
- ## Architecture
176
-
177
- ### Team Template System
178
-
179
- ```
180
- ┌─────────────────────────────────────────────────────────────┐
181
- │ Team Template │
182
- │ .multiagent/teams/self-driving/ │
183
- │ ├── team.yaml # Manifest: roles, strategy, config │
184
- │ ├── roles/ # Role overrides/extensions │
185
- │ │ ├── planner.yaml # extends: coordinator │
186
- │ │ ├── grinder.yaml # extends: worker │
187
- │ │ └── judge.yaml # extends: monitor │
188
- │ └── prompts/ # Custom prompt templates │
189
- │ ├── planner.md │
190
- │ └── judge.md │
191
- └───────────────────────────┬─────────────────────────────────┘
192
- │ TeamLoader.load()
193
- ┌───────────────────────────▼─────────────────────────────────┐
194
- │ Team Runtime │
195
- │ - Registers roles into RoleRegistry │
196
- │ - Selects IntegrationStrategy from registry │
197
- │ - Sets up task backend with pull/push mode │
198
- │ - Initializes observability views │
199
- │ - Provides team-aware system prompt context │
200
- └───────────────────────────┬─────────────────────────────────┘
201
-
202
- ┌───────────────────┼───────────────────┐
203
- ▼ ▼ ▼
204
- RoleRegistry IntegrationStrategy TaskBackend
205
- (roles added) Registry (strategy) (claim enabled)
206
- ```
207
-
208
- ### Team Manifest Schema (team.yaml)
209
-
210
- ```yaml
211
- name: self-driving
212
- description: "Cursor-style autonomous codebase development"
213
- version: 1
214
-
215
- # Roles this team uses (references files in roles/ or built-ins)
216
- roles:
217
- - planner # Custom role extending coordinator
218
- - grinder # Custom role extending worker
219
- - judge # Custom role extending monitor
220
-
221
- # How the team bootstraps
222
- bootstrap:
223
- root:
224
- role: planner
225
- config:
226
- model: sonnet
227
- prompt: "prompts/planner.md"
228
- companions:
229
- - role: judge
230
- config:
231
- model: haiku
232
-
233
- # Integration strategy for this team
234
- integration:
235
- strategy: trunk # queue | trunk | optimistic | <custom-name>
236
- config: # Passed to strategy.initialize()
237
- maxRetries: 3
238
- conflictAction: abandon
239
-
240
- # Task configuration
241
- tasks:
242
- mode: pull # push | pull
243
- pull:
244
- idleTimeout: 300
245
- claimFilters:
246
- status: [pending]
247
- maxConcurrentPerAgent: 1
248
-
249
- # Observability
250
- observability:
251
- metricsWindow: 3600
252
- snapshotInterval: 300
253
- ```
254
-
255
- ### Integration Strategy Architecture
256
-
257
- ```
258
- ┌─────────────────────────────────────────────────────────────┐
259
- │ Worker done() Handler │
260
- │ (src/lifecycle/handlers/worker.ts) │
261
- │ │
262
- │ Step 4: Land changes │
263
- │ strategy.land(request) ──────────────────┐ │
264
- └───────────────────────────────────────────┤ │
265
- ▼ │
266
- ┌─────────────────────────────────────────────────────────────┐
267
- │ IntegrationStrategyRegistry │
268
- │ .get(name) → IntegrationStrategy │
269
- │ .register(name, factory) → void │
270
- │ │
271
- │ Built-in: │
272
- │ ┌──────────────┬──────────────┬────────────────┐ │
273
- │ │ queue │ trunk │ optimistic │ │
274
- │ │ │ │ │ │
275
- │ │ Wraps │ Direct push │ Push + async │ │
276
- │ │ MergeQueue │ + rebase │ validation │ │
277
- │ │ Interface │ + retry │ + fixup tasks │ │
278
- │ └──────────────┴──────────────┴────────────────┘ │
279
- │ │
280
- │ Custom: │
281
- │ ┌────────────────────────────────┐ │
282
- │ │ pr-based, staging-promote, │ │
283
- │ │ ci-gated, ... │ │
284
- │ └────────────────────────────────┘ │
285
- └─────────────────────────────────────────────────────────────┘
286
- ```
287
-
288
- ### Data Flow: Self-Driving Mode
289
-
290
- ```
291
- 1. Team boots → Planner + Judge spawned
292
- 2. Planner explores codebase → creates tasks in TaskBackend
293
- 3. Planner spawns N workers (or pool auto-scales)
294
- 4. Workers claim tasks (pull model):
295
- claim_task() → work → commit → strategy.land() → done() → claim_task()
296
- 5. On conflict: strategy-specific handling (rebase+retry for trunk, fixup task for optimistic)
297
- 6. On failure: task marked failed, re-enters pool for retry
298
- 7. Judge runs periodically:
299
- - Checks build/test status
300
- - Creates fixup tasks for failures
301
- - Snapshots "green" state to release branch
302
- 8. Planner monitors progress:
303
- - Creates new tasks as areas are completed
304
- - Adjusts priorities based on convergence
305
- - Spawns/terminates workers based on queue depth
306
- ```
307
-
308
- ---
309
-
310
- ## Affected Code
311
-
312
- | Area | Files | Change Type |
313
- |------|-------|-------------|
314
- | Team system | `src/teams/` (new module) | New: types, loader, runtime |
315
- | Integration strategies | `src/workspace/strategies/` (new) | New: interface, registry, 3 implementations |
316
- | Task pull | `src/task/backend/types.ts`, `memory.ts` | Modified: claim(), unclaim(), tags |
317
- | MCP tools | `src/mcp/tools/` (3 new tools) | New: claim_task, unclaim_task, list_claimable_tasks |
318
- | Worker lifecycle | `src/lifecycle/handlers/worker.ts` | Modified: dispatch to strategy instead of direct merge queue |
319
- | Agent manager | `src/agent/agent-manager.ts` | Modified: team context propagation, resume() |
320
- | System prompts | `src/agent/system-prompt.ts` | Modified: team-aware prompt generation |
321
- | EventStore | `src/store/` | Modified: session history, metric views |
322
- | CLI | `src/cli/index.ts` | Modified: --team flag |
323
- | API | `src/api/server.ts` | Modified: metrics + team status endpoints |
324
- | Capabilities | `src/roles/capabilities.ts` | Modified: task.claim capability |
325
-
326
- ---
327
-
328
- ## Risks / Trade-offs
329
-
330
- | Risk | Impact | Mitigation |
331
- |------|--------|------------|
332
- | Trunk-based integration can break the build | Workers see broken state, waste tokens | Judge creates fixup tasks quickly; optimistic strategy adds async validation |
333
- | Task claim contention under high concurrency | Workers waste cycles on failed claims | Randomized backoff; claim with multiple candidates |
334
- | Session continuations bloat EventStore | Large conversation transcripts stored | Compress transcripts; configurable retention policy |
335
- | Team templates add configuration complexity | Users confused by two config systems | Clear docs; templates are optional; existing roles still work standalone |
336
- | Backward compatibility | Existing coordinator/integrator/worker flows break | `queue` strategy is the default; team templates are additive |
337
- | Custom integration strategies with bugs | Broken landing corrupts integration branch | Strategy receives a sandboxed workspace; failures are recoverable |
338
-
339
- ## Open Questions
340
-
341
- 1. **Should team templates be shareable packages?** (e.g., `npm install @macro-agent/team-self-driving`) — Deferred to future work. Start with local directory convention.
342
- 2. **Should the Judge role have write access to create a "green" branch?** — Yes, but only `git.branch.create` + `git.push` on a specific release branch, not arbitrary write access.
343
- 3. **How much session history should be loaded on resume?** — Start with last N messages (configurable), with option to load full transcript. Context window limits are the practical constraint.
344
- 4. **Should workers in pull mode be able to reject a claimed task?** — Yes, via `unclaim_task` which returns it to `pending`.
345
-
346
- ---
347
-
348
- ## Implementation Phases
349
-
350
- ### Phase 1: Team Template System (Foundation)
351
-
352
- Everything else builds on this. Delivers the modular team loading layer.
353
-
354
- - [ ] 1.1 Define `TeamManifest` TypeScript types in `src/teams/types.ts` — covers team.yaml schema: name, description, version, roles, bootstrap, integration, tasks, observability sections
355
- - [ ] 1.2 Implement `TeamLoader` in `src/teams/team-loader.ts` — reads `.multiagent/teams/<name>/` directory, parses `team.yaml`, validates schema, reads role YAML files, reads prompt template files
356
- - [ ] 1.3 Implement `TeamRuntime` in `src/teams/team-runtime.ts` — takes a parsed `TeamManifest` and wires it into the system: registers roles into RoleRegistry, selects integration strategy, sets TaskBackend mode, stores active team state
357
- - [ ] 1.4 Add team context to `AgentManager.spawn()` — propagate `MACRO_TEAM_NAME`, `MACRO_INTEGRATION_STRATEGY`, `MACRO_TASK_MODE` environment variables; include team section in system prompt generation
358
- - [ ] 1.5 Add `--team <name>` flag to CLI start command — loads team via TeamLoader, initializes TeamRuntime, then proceeds with existing boot flow
359
- - [ ] 1.6 Implement team bootstrap — after TeamRuntime initializes, spawn root agent and companion agents per manifest `bootstrap` section
360
- - [ ] 1.7 Add `GET /api/team` endpoint — returns active team config or `{ active: false }`
361
- - [ ] 1.8 Write unit tests for TeamLoader (manifest parsing, validation, defaults) and TeamRuntime (role registration, config propagation)
362
- - [ ] 1.9 Write integration test: load a test team template, verify roles registered, agents spawned with correct env vars and prompts
363
- - [ ] 1.10 Create reference team template `.multiagent/teams/self-driving/` with team.yaml, planner/grinder/judge role definitions, and prompt templates
364
-
365
- ### Phase 2: Pluggable Integration Strategies (can parallelize with Phase 3)
366
-
367
- Depends on: Phase 1 (team template sets `integration.strategy`)
368
-
369
- - [ ] 2.1 Define `IntegrationStrategy` interface and `LandRequest`/`LandResult` types in `src/workspace/strategies/types.ts`
370
- - [ ] 2.2 Implement `IntegrationStrategyRegistry` in `src/workspace/strategies/registry.ts` — register/get strategies by name, factory pattern accepting config from team.yaml
371
- - [ ] 2.3 Implement `QueueIntegrationStrategy` in `src/workspace/strategies/queue.ts` — wraps existing `MergeQueueInterface`, same behavior as current worker done() handler Step 4
372
- - [ ] 2.4 Implement `TrunkIntegrationStrategy` in `src/workspace/strategies/trunk.ts` — commit, push to integration branch, rebase-and-retry on conflict, max retries, configurable conflict action (abandon/resolve)
373
- - [ ] 2.5 Implement `OptimisticIntegrationStrategy` in `src/workspace/strategies/optimistic.ts` — push immediately, emit validation request event, background validator logic
374
- - [ ] 2.6 Refactor worker `done()` handler to dispatch to `IntegrationStrategy.land()` instead of directly using merge queue — add `integrationStrategy` to `WorkerHandlerDeps`
375
- - [ ] 2.7 Wire strategy selection into `TeamRuntime` — look up strategy by name from registry, initialize with stream config
376
- - [ ] 2.8 Register built-in strategies in module init — queue, trunk, optimistic available by default
377
- - [ ] 2.9 Ensure `queue` strategy is backward-compatible default — verify all existing merge queue tests pass unchanged
378
- - [ ] 2.10 Write unit tests for each strategy (queue passthrough, trunk push/rebase/retry/exhaust, optimistic push/validate/fixup)
379
- - [ ] 2.11 Write integration test: run workers with each strategy, verify correct landing behavior
380
-
381
- ### Phase 3: Task Pull Model (can parallelize with Phase 2)
382
-
383
- Depends on: Phase 1 (team template sets `tasks.mode: pull`)
384
-
385
- - [ ] 3.1 Add `tags` field to task types in `src/task/backend/types.ts` and `src/store/types/tasks.ts`
386
- - [ ] 3.2 Implement `claim(agentId, filters?)` on `TaskBackend` interface — atomic find-and-assign with optimistic locking
387
- - [ ] 3.3 Implement `claim()` in `InMemoryTaskBackend` — scan pending tasks matching filters, CAS on status
388
- - [ ] 3.4 Implement `unclaim(agentId, taskId, reason?)` on `TaskBackend` interface and `InMemoryTaskBackend`
389
- - [ ] 3.5 Add `task.claim` capability to `src/roles/capabilities.ts` capability-tool map
390
- - [ ] 3.6 Implement `claim_task` MCP tool in `src/mcp/tools/claim_task.ts` — schema, handler calling TaskBackend.claim(), response formatting
391
- - [ ] 3.7 Implement `unclaim_task` MCP tool in `src/mcp/tools/unclaim_task.ts`
392
- - [ ] 3.8 Implement `list_claimable_tasks` MCP tool in `src/mcp/tools/list_claimable_tasks.ts`
393
- - [ ] 3.9 Register new tools in `src/mcp/mcp-server.ts` with `task.claim` capability gating
394
- - [ ] 3.10 Modify worker `done()` handler — when task mode is `pull` and status is `completed`, do NOT set `shouldTerminate: true`; allow the worker to continue its claim loop
395
- - [ ] 3.11 Add idle timeout logic — worker tracks last successful claim time; if idle timeout exceeded, self-terminate with `done({ status: "completed", summary: "idle exit" })`
396
- - [ ] 3.12 Write unit tests for claim/unclaim (including contention), MCP tools, and pull-mode done handler
397
- - [ ] 3.13 Write integration test: spawn workers in pull mode, create tasks, verify workers claim and complete them, verify idle timeout termination
398
-
399
- ### Phase 4: Session Continuations
400
-
401
- Depends on: Phase 1 (team template configures `lifecycle.continuation`)
402
-
403
- - [ ] 4.1 Define session history event type in `src/store/types/events.ts` — `session_history` event with transcript, message count, token estimate
404
- - [ ] 4.2 Implement session history storage in EventStore — `storeSessionHistory(agentId, transcript)` and `getSessionHistory(agentId, options?)`
405
- - [ ] 4.3 Add session history persistence to agent termination flow in `AgentManager.terminate()` — when `lifecycle.continuation` is enabled for the role, persist the transcript
406
- - [ ] 4.4 Add periodic checkpoint persistence — after each agent tool-call round-trip, persist incremental session state (if continuation enabled)
407
- - [ ] 4.5 Implement `AgentManager.resume(agentId, options?)` — load session history, apply context window limits, generate resume prompt, spawn new agent process with history as initial context
408
- - [ ] 4.6 Add `lifecycle.continuation` to `RoleDefinition` type and capability checks
409
- - [ ] 4.7 Add `continuations` section to team manifest schema and TeamRuntime propagation
410
- - [ ] 4.8 Write unit tests for session storage/retrieval, context window limiting, resume prompt generation
411
- - [ ] 4.9 Write integration test: spawn agent, terminate, resume, verify context continuity
412
-
413
- ### Phase 5: Autonomous Observability
414
-
415
- Depends on: Phase 1 (team template configures `observability`), partially Phases 2+3 (task/commit metrics)
416
-
417
- - [ ] 5.1 Define metric event types in `src/store/types/events.ts` — `metric.task_completed`, `metric.commit_pushed`, `metric.conflict_detected`
418
- - [ ] 5.2 Emit metric events from done() handlers, integration strategies, and conflict detection paths
419
- - [ ] 5.3 Implement throughput materialized view in EventStore — sliding window computation over task and commit metric events
420
- - [ ] 5.4 Implement utilization materialized view in EventStore — derived from agent state transitions (spawn, claim, done, terminate)
421
- - [ ] 5.5 Implement error rate materialized view in EventStore — derived from task.failed and conflict events
422
- - [ ] 5.6 Add `GET /api/metrics/throughput`, `GET /api/metrics/utilization`, `GET /api/metrics/errors` endpoints to API server
423
- - [ ] 5.7 Write unit tests for each materialized view (window computation, edge cases)
424
- - [ ] 5.8 Write integration test: run a multi-agent session, query metrics endpoints, verify counts match actual activity
425
-
426
- ### Phase 6: Reference Templates and Documentation
427
-
428
- Depends on: All previous phases
429
-
430
- - [ ] 6.1 Finalize the `self-driving` reference team template with tested role definitions and prompts
431
- - [ ] 6.2 Create a `structured` reference template codifying the existing coordinator/integrator/worker pattern as a team template
432
- - [ ] 6.3 Add team template documentation to `docs/teams.md` — schema reference, custom strategy guide, how to create custom templates, examples
433
- - [ ] 6.4 Run end-to-end test with self-driving template: planner creates tasks, workers claim and execute, judge monitors quality, trunk integration, metrics reporting
@@ -1,216 +0,0 @@
1
- # V2 Roadmap: Deferred Gaps
2
-
3
- > Post-migration backlog from the V1→V2 subsystem extraction.
4
- > Each item was intentionally scoped out of the initial migration.
5
- > Ordered by priority (what to build next).
6
-
7
- ## Phase A: External Connectivity
8
-
9
- The entire network layer was deleted. V2 is CLI-only. These items restore programmatic and remote access.
10
-
11
- ### A1. REST API Server
12
- **Priority:** High
13
- **Effort:** Medium
14
- **Why:** No programmatic HTTP access to the system. Dashboards, monitoring tools, and IDE integrations can't connect.
15
-
16
- What V1 had:
17
- - Express routes: GET/POST agents, tasks, teams, metrics, hierarchy
18
- - WebSocket subscriptions for real-time agent/task/turn events
19
- - Health endpoints
20
-
21
- What V2 needs:
22
- - Express (or Hono/Fastify) server in `src/api/`
23
- - Routes that delegate to `MacroAgentSystemV2` services (agentManager, inboxAdapter, tasksAdapter, triggerSystem)
24
- - Optional — can run standalone or embedded in boot-v2
25
-
26
- Key decisions:
27
- - Framework choice (Express is still a dep candidate, or go lighter)
28
- - WebSocket for real-time updates (subscribe to inbox delivery events + agent lifecycle)
29
- - Auth model (token-based, same as V1's `agentTokenManager`)
30
-
31
- ### A2. ACP WebSocket Server
32
- **Priority:** High (if IDE/remote integration needed)
33
- **Effort:** High
34
- **Why:** The Agent Communication Protocol over WebSocket was how external tools (IDEs, remote agents) interacted with macro-agent. Without it, only local CLI access works.
35
-
36
- What V1 had:
37
- - `websocket-server.ts` — Multi-client WebSocket server at `/acp`
38
- - `macro-agent.ts` — ACP agent implementation (initialize, newSession, loadSession, prompt, cancel, extensions)
39
- - `session-mapper.ts` — Maps ACP session IDs to internal agent IDs
40
- - Extension methods: `_macro/spawnAgent`, `_macro/getHierarchy`, `_macro/sendPeerMessage`, etc.
41
-
42
- What V2 needs:
43
- - WebSocket server wrapping `AgentManager` + `InboxAdapter` + `ControlServer`
44
- - ACP protocol handler translating JSON-RPC to V2 service calls
45
- - Session management (session → head manager mapping)
46
- - Extension methods updated for V2 (no EventStore, use adapters)
47
-
48
- Dependencies: A1 (shares the HTTP server)
49
-
50
- ### A3. MAP Protocol Bridge
51
- **Priority:** Medium
52
- **Effort:** Medium
53
- **Why:** MAP (Multi-Agent Protocol) was the standard interop layer for connecting to other agent systems. With agent-inbox embedded, MAP support partially exists (inbox speaks MAP natively), but there's no server-side MAP endpoint for external MAP clients to connect to.
54
-
55
- What V1 had:
56
- - `map/adapter/` — Full MAP JSON-RPC adapter with connection/subscription lifecycle
57
- - `map/federation/` — Cross-system message relay
58
-
59
- What V2 can leverage:
60
- - agent-inbox already supports MAP via `MapClient` and federation
61
- - The gap is exposing macro-agent's MAP endpoint to external clients
62
- - Could be as simple as wiring agent-inbox's MAP server to the HTTP/WS server from A1
63
-
64
- ### A4. Peer-to-Peer Multi-Instance
65
- **Priority:** Low
66
- **Effort:** High
67
- **Why:** P2P communication between separate macro-agent instances. Only needed for distributed deployments.
68
-
69
- What V1 had:
70
- - `PeerManager` with WebSocket and local transports
71
- - `CapabilityManager` for delegating capabilities across instances
72
-
73
- What V2 can leverage:
74
- - agent-inbox federation (encrypted P2P via agentic-mesh)
75
- - Each macro-agent instance embeds its own agent-inbox
76
- - Federation connects inboxes across instances automatically
77
-
78
- The messaging layer is covered by inbox federation. The gap is coordination-level operations (spawn on remote instance, cross-instance hierarchy queries). This is a new design problem, not a restore.
79
-
80
- ---
81
-
82
- ## Phase B: Operational Gaps
83
-
84
- Features that affect reliability and observability in production.
85
-
86
- ### B1. Metrics and Observability
87
- **Priority:** High (for production)
88
- **Effort:** Medium
89
- **Why:** No aggregate throughput, utilization, or error metrics. Can't answer "how many tasks completed per hour?" or "which agents are idle?"
90
-
91
- What V1 had:
92
- - `ThroughputMetrics` — tasks completed/failed/created per time window, avg completion time
93
- - `UtilizationMetrics` — active agents by role/state
94
- - `ErrorMetrics` — errors by type/agent
95
-
96
- What V2 needs:
97
- - `src/metrics/` module that reads from AgentStore + ControlServer health data
98
- - Counters: tasks created/completed/failed (from tasksAdapter or opentasks events)
99
- - Gauges: running agents by role, active sessions, queue depth
100
- - Histograms: task completion time, agent lifetime
101
- - Export format: Prometheus-compatible or simple JSON endpoint (ties into A1)
102
-
103
- ### B2. Event Deduplication
104
- **Priority:** Medium
105
- **Effort:** Low
106
- **Why:** Rapid inbox messages to the same agent can cause alert storms. V1's `deduplication.ts` used slot-based dedup to coalesce rapid events.
107
-
108
- What V2 needs:
109
- - Add dedup layer in `trigger-system-v2.ts` delivery handler
110
- - Before enqueuing, check if an event with the same `sourceKey` was recently processed
111
- - Simple time-window dedup: `Map<sourceKey, lastSeenTimestamp>` with TTL
112
-
113
- Implementation: ~50 lines in the delivery handler. The `SystemEventQueue` already supports `sourceKey` for dedup hints — just need to check it before enqueuing.
114
-
115
- ### B3. Automated Health Check Escalation
116
- **Priority:** Medium
117
- **Effort:** Low
118
- **Why:** V2 tracks heartbeats from MCP subprocesses via ControlServer but doesn't act on stale heartbeats automatically.
119
-
120
- What V1 had:
121
- - `HealthCheckService` — periodic check loop, consecutive failure counting, STALE_AGENT signal emission, zombie session cleanup
122
-
123
- What V2 needs:
124
- - Periodic loop in `boot-v2.ts` or `agent-manager-v2.ts` that calls `controlServer.getUnhealthyAgents(60000)`
125
- - For unhealthy agents: emit warning via inbox to parent, optionally terminate after N missed heartbeats
126
- - ~30 lines of `setInterval` logic
127
-
128
- ---
129
-
130
- ## Phase C: Feature Gaps
131
-
132
- Capabilities that existed in V1 but were not essential for the V2 architecture migration.
133
-
134
- ### C1. Integrator Resolver Spawning
135
- **Priority:** Medium
136
- **Effort:** Medium
137
- **Why:** V1's integrator done handler could detect merge conflicts and automatically spawn a "worker.resolver" agent to fix them. V2's integrator handler just emits `INTEGRATOR_DONE`.
138
-
139
- What V1 had:
140
- - `handleIntegratorDone()` processed merge queue, attempted merges, detected conflicts
141
- - On conflict: spawned `worker.resolver` with conflict context, MR ID, resolver branch
142
- - Resolver worked in a worktree, committed fix, emitted `RESOLVER_DONE`
143
- - Integrator then merged the resolver's branch inline
144
-
145
- What V2 needs:
146
- - Re-add conflict detection to the integrator's done flow or to `AgentManagerV2.terminate()`
147
- - Spawn resolver worker with workspace on conflict branch
148
- - This ties into the workspace isolation flow
149
-
150
- ### C2. wait_for_activity MCP Tool
151
- **Priority:** Low
152
- **Effort:** Low
153
- **Why:** Agents could block until a matching event occurred (e.g., "wait for child to complete"). V2 agents must poll `check_inbox` instead.
154
-
155
- What V2 could do:
156
- - Add `wait_for_activity` tool to `mcp-server-v2.ts`
157
- - Implementation: poll `inboxAdapter.checkInbox()` with a timeout loop
158
- - Or: use control socket to subscribe to events from main process
159
-
160
- ### C3. AI Router Strategy
161
- **Priority:** Low
162
- **Effort:** Medium
163
- **Why:** V1 could fork a Claude session to make routing decisions for trigger events. Expensive but powerful for complex routing.
164
-
165
- What V2 has:
166
- - Pluggable `RoutingStrategy` interface already exists
167
- - `registerStrategy()` API is available
168
-
169
- What's needed:
170
- - Implement `AIRouterStrategy` that spawns a lightweight Claude session
171
- - Provide system state (agents, tasks, recent events) as context
172
- - Parse routing decision from response
173
- - Register via `triggerSystem.router.registerStrategy()`
174
-
175
- ### C4. Store Change Subscriptions
176
- **Priority:** Low
177
- **Effort:** Medium
178
- **Why:** V1's EventStore had `onAgentChange()` and `onTaskChange()` subscriptions that components used for reactive updates. V2 has no equivalent.
179
-
180
- What V2 does instead:
181
- - Agent lifecycle callbacks via `agentManager.onLifecycleEvent()`
182
- - Inbox delivery events via `inboxAdapter.onDelivery()`
183
- - These cover the main reactive use cases
184
-
185
- What's missing:
186
- - No way to subscribe to AgentStore changes from outside the main process
187
- - MCP subprocesses can't be notified when an agent's state changes
188
-
189
- Low priority because the main use cases are covered by existing callbacks.
190
-
191
- ---
192
-
193
- ## Implementation Order
194
-
195
- ```
196
- Immediate (high value, low effort):
197
- B2. Event Deduplication (~50 lines)
198
- B3. Health Check Escalation (~30 lines)
199
-
200
- Next sprint (high value):
201
- B1. Metrics/Observability
202
- A1. REST API Server
203
-
204
- When needed:
205
- A2. ACP WebSocket Server
206
- C1. Integrator Resolver Spawning
207
-
208
- Later:
209
- A3. MAP Protocol Bridge
210
- C2. wait_for_activity Tool
211
- C3. AI Router Strategy
212
- C4. Store Change Subscriptions
213
-
214
- Not until distributed deployment:
215
- A4. Peer-to-Peer Multi-Instance
216
- ```