macro-agent 0.0.11 → 0.0.12

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 (408) hide show
  1. package/.macro-agent/teams/self-driving/prompts/grinder.md +27 -0
  2. package/.macro-agent/teams/self-driving/prompts/judge.md +27 -0
  3. package/.macro-agent/teams/self-driving/prompts/planner.md +33 -0
  4. package/.macro-agent/teams/self-driving/roles/grinder.yaml +17 -0
  5. package/.macro-agent/teams/self-driving/roles/judge.yaml +24 -0
  6. package/.macro-agent/teams/self-driving/roles/planner.yaml +18 -0
  7. package/.macro-agent/teams/self-driving/team.yaml +103 -0
  8. package/.macro-agent/teams/structured/prompts/developer.md +26 -0
  9. package/.macro-agent/teams/structured/prompts/lead.md +25 -0
  10. package/.macro-agent/teams/structured/prompts/reviewer.md +24 -0
  11. package/.macro-agent/teams/structured/roles/developer.yaml +12 -0
  12. package/.macro-agent/teams/structured/roles/lead.yaml +11 -0
  13. package/.macro-agent/teams/structured/roles/reviewer.yaml +19 -0
  14. package/.macro-agent/teams/structured/team.yaml +89 -0
  15. package/.sudocode/issues.jsonl +6 -0
  16. package/.sudocode/specs.jsonl +7 -0
  17. package/CLAUDE.md +110 -30
  18. package/README.md +60 -3
  19. package/dist/acp/macro-agent.d.ts +4 -0
  20. package/dist/acp/macro-agent.d.ts.map +1 -1
  21. package/dist/acp/macro-agent.js +50 -4
  22. package/dist/acp/macro-agent.js.map +1 -1
  23. package/dist/acp/session-mapper.d.ts +20 -1
  24. package/dist/acp/session-mapper.d.ts.map +1 -1
  25. package/dist/acp/session-mapper.js +90 -1
  26. package/dist/acp/session-mapper.js.map +1 -1
  27. package/dist/acp/types.d.ts +24 -1
  28. package/dist/acp/types.d.ts.map +1 -1
  29. package/dist/acp/types.js.map +1 -1
  30. package/dist/agent/agent-manager.d.ts +25 -1
  31. package/dist/agent/agent-manager.d.ts.map +1 -1
  32. package/dist/agent/agent-manager.js +93 -7
  33. package/dist/agent/agent-manager.js.map +1 -1
  34. package/dist/agent/types.d.ts +22 -0
  35. package/dist/agent/types.d.ts.map +1 -1
  36. package/dist/agent/types.js.map +1 -1
  37. package/dist/agent-detection/command-builder.d.ts +30 -0
  38. package/dist/agent-detection/command-builder.d.ts.map +1 -0
  39. package/dist/agent-detection/command-builder.js +71 -0
  40. package/dist/agent-detection/command-builder.js.map +1 -0
  41. package/dist/agent-detection/detector.d.ts +84 -0
  42. package/dist/agent-detection/detector.d.ts.map +1 -0
  43. package/dist/agent-detection/detector.js +240 -0
  44. package/dist/agent-detection/detector.js.map +1 -0
  45. package/dist/agent-detection/index.d.ts +12 -0
  46. package/dist/agent-detection/index.d.ts.map +1 -0
  47. package/dist/agent-detection/index.js +14 -0
  48. package/dist/agent-detection/index.js.map +1 -0
  49. package/dist/agent-detection/registry.d.ts +53 -0
  50. package/dist/agent-detection/registry.d.ts.map +1 -0
  51. package/dist/agent-detection/registry.js +177 -0
  52. package/dist/agent-detection/registry.js.map +1 -0
  53. package/dist/agent-detection/types.d.ts +121 -0
  54. package/dist/agent-detection/types.d.ts.map +1 -0
  55. package/dist/agent-detection/types.js +20 -0
  56. package/dist/agent-detection/types.js.map +1 -0
  57. package/dist/api/server.d.ts.map +1 -1
  58. package/dist/api/server.js +95 -0
  59. package/dist/api/server.js.map +1 -1
  60. package/dist/cli/index.js +29 -0
  61. package/dist/cli/index.js.map +1 -1
  62. package/dist/cli/mcp.js +38 -0
  63. package/dist/cli/mcp.js.map +1 -1
  64. package/dist/config/index.d.ts +2 -0
  65. package/dist/config/index.d.ts.map +1 -0
  66. package/dist/config/index.js +2 -0
  67. package/dist/config/index.js.map +1 -0
  68. package/dist/config/project-config.d.ts +46 -0
  69. package/dist/config/project-config.d.ts.map +1 -0
  70. package/dist/config/project-config.js +68 -0
  71. package/dist/config/project-config.js.map +1 -0
  72. package/dist/lifecycle/cascade.d.ts +1 -1
  73. package/dist/lifecycle/cascade.d.ts.map +1 -1
  74. package/dist/lifecycle/handlers/index.d.ts +4 -0
  75. package/dist/lifecycle/handlers/index.d.ts.map +1 -1
  76. package/dist/lifecycle/handlers/index.js +2 -0
  77. package/dist/lifecycle/handlers/index.js.map +1 -1
  78. package/dist/lifecycle/handlers/worker.d.ts +4 -0
  79. package/dist/lifecycle/handlers/worker.d.ts.map +1 -1
  80. package/dist/lifecycle/handlers/worker.js +35 -3
  81. package/dist/lifecycle/handlers/worker.js.map +1 -1
  82. package/dist/map/adapter/acp-over-map.d.ts.map +1 -1
  83. package/dist/map/adapter/acp-over-map.js +32 -2
  84. package/dist/map/adapter/acp-over-map.js.map +1 -1
  85. package/dist/map/adapter/event-translator.d.ts.map +1 -1
  86. package/dist/map/adapter/event-translator.js +1 -0
  87. package/dist/map/adapter/event-translator.js.map +1 -1
  88. package/dist/map/adapter/extensions/agent-detection.d.ts +49 -0
  89. package/dist/map/adapter/extensions/agent-detection.d.ts.map +1 -0
  90. package/dist/map/adapter/extensions/agent-detection.js +91 -0
  91. package/dist/map/adapter/extensions/agent-detection.js.map +1 -0
  92. package/dist/map/adapter/extensions/index.d.ts +10 -1
  93. package/dist/map/adapter/extensions/index.d.ts.map +1 -1
  94. package/dist/map/adapter/extensions/index.js +39 -0
  95. package/dist/map/adapter/extensions/index.js.map +1 -1
  96. package/dist/map/adapter/extensions/resume.d.ts +47 -0
  97. package/dist/map/adapter/extensions/resume.d.ts.map +1 -0
  98. package/dist/map/adapter/extensions/resume.js +59 -0
  99. package/dist/map/adapter/extensions/resume.js.map +1 -0
  100. package/dist/map/adapter/extensions/workspace-files.d.ts +42 -0
  101. package/dist/map/adapter/extensions/workspace-files.d.ts.map +1 -0
  102. package/dist/map/adapter/extensions/workspace-files.js +338 -0
  103. package/dist/map/adapter/extensions/workspace-files.js.map +1 -0
  104. package/dist/mcp/mcp-server.d.ts +6 -0
  105. package/dist/mcp/mcp-server.d.ts.map +1 -1
  106. package/dist/mcp/mcp-server.js +45 -0
  107. package/dist/mcp/mcp-server.js.map +1 -1
  108. package/dist/mcp/tools/claim_task.d.ts +35 -0
  109. package/dist/mcp/tools/claim_task.d.ts.map +1 -0
  110. package/dist/mcp/tools/claim_task.js +58 -0
  111. package/dist/mcp/tools/claim_task.js.map +1 -0
  112. package/dist/mcp/tools/done.d.ts +11 -2
  113. package/dist/mcp/tools/done.d.ts.map +1 -1
  114. package/dist/mcp/tools/done.js +15 -10
  115. package/dist/mcp/tools/done.js.map +1 -1
  116. package/dist/mcp/tools/list_claimable_tasks.d.ts +38 -0
  117. package/dist/mcp/tools/list_claimable_tasks.d.ts.map +1 -0
  118. package/dist/mcp/tools/list_claimable_tasks.js +63 -0
  119. package/dist/mcp/tools/list_claimable_tasks.js.map +1 -0
  120. package/dist/mcp/tools/unclaim_task.d.ts +31 -0
  121. package/dist/mcp/tools/unclaim_task.d.ts.map +1 -0
  122. package/dist/mcp/tools/unclaim_task.js +47 -0
  123. package/dist/mcp/tools/unclaim_task.js.map +1 -0
  124. package/dist/metrics/index.d.ts +2 -0
  125. package/dist/metrics/index.d.ts.map +1 -0
  126. package/dist/metrics/index.js +2 -0
  127. package/dist/metrics/index.js.map +1 -0
  128. package/dist/metrics/metrics.d.ts +79 -0
  129. package/dist/metrics/metrics.d.ts.map +1 -0
  130. package/dist/metrics/metrics.js +166 -0
  131. package/dist/metrics/metrics.js.map +1 -0
  132. package/dist/roles/capabilities.d.ts +1 -0
  133. package/dist/roles/capabilities.d.ts.map +1 -1
  134. package/dist/roles/capabilities.js +3 -0
  135. package/dist/roles/capabilities.js.map +1 -1
  136. package/dist/roles/types.d.ts +1 -1
  137. package/dist/roles/types.d.ts.map +1 -1
  138. package/dist/router/message-router.d.ts +41 -0
  139. package/dist/router/message-router.d.ts.map +1 -1
  140. package/dist/router/message-router.js +136 -5
  141. package/dist/router/message-router.js.map +1 -1
  142. package/dist/store/event-store.d.ts +8 -1
  143. package/dist/store/event-store.d.ts.map +1 -1
  144. package/dist/store/event-store.js +120 -4
  145. package/dist/store/event-store.js.map +1 -1
  146. package/dist/store/types/agents.d.ts +1 -1
  147. package/dist/store/types/agents.d.ts.map +1 -1
  148. package/dist/store/types/events.d.ts +1 -1
  149. package/dist/store/types/events.d.ts.map +1 -1
  150. package/dist/store/types/events.js.map +1 -1
  151. package/dist/store/types/index.d.ts +1 -0
  152. package/dist/store/types/index.d.ts.map +1 -1
  153. package/dist/store/types/index.js +1 -0
  154. package/dist/store/types/index.js.map +1 -1
  155. package/dist/store/types/sessions.d.ts +44 -0
  156. package/dist/store/types/sessions.d.ts.map +1 -0
  157. package/dist/store/types/sessions.js +9 -0
  158. package/dist/store/types/sessions.js.map +1 -0
  159. package/dist/store/types/tasks.d.ts +2 -0
  160. package/dist/store/types/tasks.d.ts.map +1 -1
  161. package/dist/task/backend/memory.d.ts +4 -1
  162. package/dist/task/backend/memory.d.ts.map +1 -1
  163. package/dist/task/backend/memory.js +81 -0
  164. package/dist/task/backend/memory.js.map +1 -1
  165. package/dist/task/backend/types.d.ts +30 -0
  166. package/dist/task/backend/types.d.ts.map +1 -1
  167. package/dist/task/backend/types.js.map +1 -1
  168. package/dist/teams/index.d.ts +4 -0
  169. package/dist/teams/index.d.ts.map +1 -0
  170. package/dist/teams/index.js +4 -0
  171. package/dist/teams/index.js.map +1 -0
  172. package/dist/teams/team-loader.d.ts +20 -0
  173. package/dist/teams/team-loader.d.ts.map +1 -0
  174. package/dist/teams/team-loader.js +293 -0
  175. package/dist/teams/team-loader.js.map +1 -0
  176. package/dist/teams/team-runtime.d.ts +139 -0
  177. package/dist/teams/team-runtime.d.ts.map +1 -0
  178. package/dist/teams/team-runtime.js +613 -0
  179. package/dist/teams/team-runtime.js.map +1 -0
  180. package/dist/teams/types.d.ts +266 -0
  181. package/dist/teams/types.d.ts.map +1 -0
  182. package/dist/teams/types.js +20 -0
  183. package/dist/teams/types.js.map +1 -0
  184. package/dist/workspace/dataplane-adapter.d.ts +1 -1
  185. package/dist/workspace/dataplane-adapter.d.ts.map +1 -1
  186. package/dist/workspace/dataplane-adapter.js +1 -1
  187. package/dist/workspace/dataplane-adapter.js.map +1 -1
  188. package/dist/workspace/index.d.ts +1 -1
  189. package/dist/workspace/index.d.ts.map +1 -1
  190. package/dist/workspace/strategies/index.d.ts +6 -0
  191. package/dist/workspace/strategies/index.d.ts.map +1 -0
  192. package/dist/workspace/strategies/index.js +5 -0
  193. package/dist/workspace/strategies/index.js.map +1 -0
  194. package/dist/workspace/strategies/optimistic.d.ts +26 -0
  195. package/dist/workspace/strategies/optimistic.d.ts.map +1 -0
  196. package/dist/workspace/strategies/optimistic.js +121 -0
  197. package/dist/workspace/strategies/optimistic.js.map +1 -0
  198. package/dist/workspace/strategies/queue.d.ts +26 -0
  199. package/dist/workspace/strategies/queue.d.ts.map +1 -0
  200. package/dist/workspace/strategies/queue.js +67 -0
  201. package/dist/workspace/strategies/queue.js.map +1 -0
  202. package/dist/workspace/strategies/registry.d.ts +37 -0
  203. package/dist/workspace/strategies/registry.d.ts.map +1 -0
  204. package/dist/workspace/strategies/registry.js +63 -0
  205. package/dist/workspace/strategies/registry.js.map +1 -0
  206. package/dist/workspace/strategies/trunk.d.ts +20 -0
  207. package/dist/workspace/strategies/trunk.d.ts.map +1 -0
  208. package/dist/workspace/strategies/trunk.js +108 -0
  209. package/dist/workspace/strategies/trunk.js.map +1 -0
  210. package/dist/workspace/strategies/types.d.ts +104 -0
  211. package/dist/workspace/strategies/types.d.ts.map +1 -0
  212. package/dist/workspace/strategies/types.js +11 -0
  213. package/dist/workspace/strategies/types.js.map +1 -0
  214. package/dist/workspace/types.d.ts +1 -1
  215. package/dist/workspace/types.d.ts.map +1 -1
  216. package/dist/workspace/workspace-manager.d.ts +1 -1
  217. package/dist/workspace/workspace-manager.d.ts.map +1 -1
  218. package/docs/implementation-details.md +1127 -0
  219. package/docs/implementation-summary.md +448 -0
  220. package/docs/plan-self-driving-support.md +433 -0
  221. package/docs/spec-self-driving-support.md +462 -0
  222. package/docs/team-templates.md +860 -0
  223. package/docs/teams.md +233 -0
  224. package/package.json +4 -2
  225. package/src/acp/__tests__/integration.test.ts +161 -1
  226. package/src/acp/__tests__/macro-agent.test.ts +95 -0
  227. package/src/acp/__tests__/session-persistence.test.ts +276 -0
  228. package/src/acp/macro-agent.ts +79 -7
  229. package/src/acp/session-mapper.ts +108 -1
  230. package/src/acp/types.ts +33 -1
  231. package/src/agent/agent-manager.ts +158 -6
  232. package/src/agent/types.ts +27 -0
  233. package/src/agent-detection/__tests__/command-builder.test.ts +336 -0
  234. package/src/agent-detection/__tests__/detector.test.ts +768 -0
  235. package/src/agent-detection/__tests__/registry.test.ts +254 -0
  236. package/src/agent-detection/command-builder.ts +90 -0
  237. package/src/agent-detection/detector.ts +307 -0
  238. package/src/agent-detection/index.ts +36 -0
  239. package/src/agent-detection/registry.ts +200 -0
  240. package/src/agent-detection/types.ts +184 -0
  241. package/src/api/server.ts +110 -0
  242. package/src/cli/index.ts +44 -0
  243. package/src/cli/mcp.ts +47 -0
  244. package/src/config/index.ts +9 -0
  245. package/src/config/project-config.ts +107 -0
  246. package/src/lifecycle/cascade.ts +1 -1
  247. package/src/lifecycle/handlers/index.ts +8 -0
  248. package/src/lifecycle/handlers/worker.ts +48 -3
  249. package/src/map/adapter/__tests__/extensions.test.ts +359 -0
  250. package/src/map/adapter/__tests__/workspace-files.test.ts +673 -0
  251. package/src/map/adapter/acp-over-map.ts +45 -2
  252. package/src/map/adapter/event-translator.ts +1 -0
  253. package/src/map/adapter/extensions/agent-detection.ts +201 -0
  254. package/src/map/adapter/extensions/index.ts +63 -0
  255. package/src/map/adapter/extensions/resume.ts +114 -0
  256. package/src/map/adapter/extensions/workspace-files.ts +449 -0
  257. package/src/mcp/mcp-server.ts +67 -0
  258. package/src/mcp/tools/claim_task.ts +86 -0
  259. package/src/mcp/tools/done.ts +24 -10
  260. package/src/mcp/tools/list_claimable_tasks.ts +93 -0
  261. package/src/mcp/tools/unclaim_task.ts +71 -0
  262. package/src/metrics/index.ts +9 -0
  263. package/src/metrics/metrics.ts +280 -0
  264. package/src/roles/capabilities.ts +3 -0
  265. package/src/roles/types.ts +2 -1
  266. package/src/router/__tests__/message-router.test.ts +561 -0
  267. package/src/router/message-router.ts +223 -6
  268. package/src/store/event-store.ts +151 -3
  269. package/src/store/types/agents.ts +1 -1
  270. package/src/store/types/events.ts +2 -1
  271. package/src/store/types/index.ts +1 -0
  272. package/src/store/types/sessions.ts +53 -0
  273. package/src/store/types/tasks.ts +3 -0
  274. package/src/task/backend/memory.ts +116 -0
  275. package/src/task/backend/types.ts +43 -0
  276. package/src/teams/__tests__/cross-subsystem.integration.test.ts +983 -0
  277. package/src/teams/__tests__/e2e/team-runtime.e2e.test.ts +553 -0
  278. package/src/teams/__tests__/team-system.test.ts +1280 -0
  279. package/src/teams/index.ts +13 -0
  280. package/src/teams/team-loader.ts +434 -0
  281. package/src/teams/team-runtime.ts +727 -0
  282. package/src/teams/types.ts +377 -0
  283. package/src/workspace/dataplane-adapter.ts +1 -1
  284. package/src/workspace/index.ts +1 -1
  285. package/src/workspace/strategies/index.ts +18 -0
  286. package/src/workspace/strategies/optimistic.ts +136 -0
  287. package/src/workspace/strategies/queue.ts +81 -0
  288. package/src/workspace/strategies/registry.ts +89 -0
  289. package/src/workspace/strategies/trunk.ts +123 -0
  290. package/src/workspace/strategies/types.ts +145 -0
  291. package/src/workspace/types.ts +1 -1
  292. package/src/workspace/workspace-manager.ts +1 -1
  293. package/.claude/settings.local.json +0 -59
  294. package/dist/map/utils/address-translation.d.ts +0 -99
  295. package/dist/map/utils/address-translation.d.ts.map +0 -1
  296. package/dist/map/utils/address-translation.js +0 -285
  297. package/dist/map/utils/address-translation.js.map +0 -1
  298. package/dist/map/utils/index.d.ts +0 -7
  299. package/dist/map/utils/index.d.ts.map +0 -1
  300. package/dist/map/utils/index.js +0 -7
  301. package/dist/map/utils/index.js.map +0 -1
  302. package/references/acp-factory-ref/CHANGELOG.md +0 -33
  303. package/references/acp-factory-ref/LICENSE +0 -21
  304. package/references/acp-factory-ref/README.md +0 -341
  305. package/references/acp-factory-ref/package-lock.json +0 -3102
  306. package/references/acp-factory-ref/package.json +0 -96
  307. package/references/acp-factory-ref/python/CHANGELOG.md +0 -33
  308. package/references/acp-factory-ref/python/LICENSE +0 -21
  309. package/references/acp-factory-ref/python/Makefile +0 -57
  310. package/references/acp-factory-ref/python/README.md +0 -253
  311. package/references/acp-factory-ref/python/pyproject.toml +0 -73
  312. package/references/acp-factory-ref/python/tests/__init__.py +0 -0
  313. package/references/acp-factory-ref/python/tests/e2e/__init__.py +0 -1
  314. package/references/acp-factory-ref/python/tests/e2e/test_codex_e2e.py +0 -349
  315. package/references/acp-factory-ref/python/tests/e2e/test_gemini_e2e.py +0 -165
  316. package/references/acp-factory-ref/python/tests/e2e/test_opencode_e2e.py +0 -296
  317. package/references/acp-factory-ref/python/tests/test_client_handler.py +0 -543
  318. package/references/acp-factory-ref/python/tests/test_pushable.py +0 -199
  319. package/references/claude-code-acp/.github/workflows/ci.yml +0 -45
  320. package/references/claude-code-acp/.github/workflows/publish.yml +0 -34
  321. package/references/claude-code-acp/.prettierrc.json +0 -4
  322. package/references/claude-code-acp/CHANGELOG.md +0 -249
  323. package/references/claude-code-acp/LICENSE +0 -222
  324. package/references/claude-code-acp/README.md +0 -53
  325. package/references/claude-code-acp/docs/RELEASES.md +0 -24
  326. package/references/claude-code-acp/eslint.config.js +0 -48
  327. package/references/claude-code-acp/package-lock.json +0 -4570
  328. package/references/claude-code-acp/package.json +0 -88
  329. package/references/claude-code-acp/scripts/release.sh +0 -119
  330. package/references/claude-code-acp/src/acp-agent.ts +0 -2065
  331. package/references/claude-code-acp/src/index.ts +0 -26
  332. package/references/claude-code-acp/src/lib.ts +0 -38
  333. package/references/claude-code-acp/src/mcp-server.ts +0 -911
  334. package/references/claude-code-acp/src/settings.ts +0 -522
  335. package/references/claude-code-acp/src/tests/.claude/commands/quick-math.md +0 -5
  336. package/references/claude-code-acp/src/tests/.claude/commands/say-hello.md +0 -6
  337. package/references/claude-code-acp/src/tests/acp-agent-fork.test.ts +0 -479
  338. package/references/claude-code-acp/src/tests/acp-agent.test.ts +0 -1502
  339. package/references/claude-code-acp/src/tests/extract-lines.test.ts +0 -103
  340. package/references/claude-code-acp/src/tests/fork-session.test.ts +0 -335
  341. package/references/claude-code-acp/src/tests/replace-and-calculate-location.test.ts +0 -334
  342. package/references/claude-code-acp/src/tests/settings.test.ts +0 -617
  343. package/references/claude-code-acp/src/tests/skills-options.test.ts +0 -187
  344. package/references/claude-code-acp/src/tests/tools.test.ts +0 -318
  345. package/references/claude-code-acp/src/tests/typescript-declarations.test.ts +0 -558
  346. package/references/claude-code-acp/src/tools.ts +0 -819
  347. package/references/claude-code-acp/src/utils.ts +0 -171
  348. package/references/claude-code-acp/tsconfig.json +0 -18
  349. package/references/claude-code-acp/vitest.config.ts +0 -19
  350. package/references/multi-agent-protocol/.sudocode/issues.jsonl +0 -111
  351. package/references/multi-agent-protocol/.sudocode/specs.jsonl +0 -13
  352. package/references/multi-agent-protocol/LICENSE +0 -21
  353. package/references/multi-agent-protocol/README.md +0 -113
  354. package/references/multi-agent-protocol/docs/00-design-specification.md +0 -496
  355. package/references/multi-agent-protocol/docs/01-open-questions.md +0 -1050
  356. package/references/multi-agent-protocol/docs/02-wire-protocol.md +0 -296
  357. package/references/multi-agent-protocol/docs/03-streaming-semantics.md +0 -252
  358. package/references/multi-agent-protocol/docs/04-error-handling.md +0 -231
  359. package/references/multi-agent-protocol/docs/05-connection-model.md +0 -244
  360. package/references/multi-agent-protocol/docs/06-visibility-permissions.md +0 -243
  361. package/references/multi-agent-protocol/docs/07-federation.md +0 -259
  362. package/references/multi-agent-protocol/docs/08-macro-agent-migration.md +0 -253
  363. package/references/multi-agent-protocol/docs/09-authentication.md +0 -680
  364. package/references/multi-agent-protocol/docs/10-mail-protocol.md +0 -553
  365. package/references/multi-agent-protocol/docs/agent-iam-integration.md +0 -877
  366. package/references/multi-agent-protocol/docs/agentic-mesh-integration-draft.md +0 -459
  367. package/references/multi-agent-protocol/docs/git-transport-draft.md +0 -251
  368. package/references/multi-agent-protocol/docs-site/Gemfile +0 -22
  369. package/references/multi-agent-protocol/docs-site/README.md +0 -82
  370. package/references/multi-agent-protocol/docs-site/_config.yml +0 -91
  371. package/references/multi-agent-protocol/docs-site/_includes/head_custom.html +0 -20
  372. package/references/multi-agent-protocol/docs-site/_sass/color_schemes/map.scss +0 -42
  373. package/references/multi-agent-protocol/docs-site/_sass/custom/custom.scss +0 -34
  374. package/references/multi-agent-protocol/docs-site/examples/full-integration.md +0 -510
  375. package/references/multi-agent-protocol/docs-site/examples/index.md +0 -138
  376. package/references/multi-agent-protocol/docs-site/examples/simple-chat.md +0 -282
  377. package/references/multi-agent-protocol/docs-site/examples/task-queue.md +0 -399
  378. package/references/multi-agent-protocol/docs-site/getting-started/index.md +0 -98
  379. package/references/multi-agent-protocol/docs-site/getting-started/installation.md +0 -219
  380. package/references/multi-agent-protocol/docs-site/getting-started/overview.md +0 -172
  381. package/references/multi-agent-protocol/docs-site/getting-started/quickstart.md +0 -237
  382. package/references/multi-agent-protocol/docs-site/index.md +0 -136
  383. package/references/multi-agent-protocol/docs-site/protocol/authentication.md +0 -391
  384. package/references/multi-agent-protocol/docs-site/protocol/connection-model.md +0 -376
  385. package/references/multi-agent-protocol/docs-site/protocol/design.md +0 -284
  386. package/references/multi-agent-protocol/docs-site/protocol/error-handling.md +0 -312
  387. package/references/multi-agent-protocol/docs-site/protocol/federation.md +0 -449
  388. package/references/multi-agent-protocol/docs-site/protocol/index.md +0 -129
  389. package/references/multi-agent-protocol/docs-site/protocol/permissions.md +0 -398
  390. package/references/multi-agent-protocol/docs-site/protocol/streaming.md +0 -353
  391. package/references/multi-agent-protocol/docs-site/protocol/wire-protocol.md +0 -369
  392. package/references/multi-agent-protocol/docs-site/sdk/api/agent.md +0 -357
  393. package/references/multi-agent-protocol/docs-site/sdk/api/client.md +0 -380
  394. package/references/multi-agent-protocol/docs-site/sdk/api/index.md +0 -62
  395. package/references/multi-agent-protocol/docs-site/sdk/api/server.md +0 -453
  396. package/references/multi-agent-protocol/docs-site/sdk/api/types.md +0 -468
  397. package/references/multi-agent-protocol/docs-site/sdk/guides/agent.md +0 -375
  398. package/references/multi-agent-protocol/docs-site/sdk/guides/authentication.md +0 -405
  399. package/references/multi-agent-protocol/docs-site/sdk/guides/client.md +0 -352
  400. package/references/multi-agent-protocol/docs-site/sdk/guides/index.md +0 -89
  401. package/references/multi-agent-protocol/docs-site/sdk/guides/server.md +0 -360
  402. package/references/multi-agent-protocol/docs-site/sdk/guides/testing.md +0 -446
  403. package/references/multi-agent-protocol/docs-site/sdk/guides/transports.md +0 -363
  404. package/references/multi-agent-protocol/docs-site/sdk/index.md +0 -206
  405. package/references/multi-agent-protocol/package-lock.json +0 -3886
  406. package/references/multi-agent-protocol/package.json +0 -56
  407. package/references/multi-agent-protocol/schema/meta.json +0 -467
  408. package/references/multi-agent-protocol/schema/schema.json +0 -2558
@@ -0,0 +1,613 @@
1
+ /**
2
+ * Team Runtime
3
+ *
4
+ * Wires a loaded TeamManifest into the running system: registers roles,
5
+ * sets up integration strategy, configures communication topology,
6
+ * and manages the team lifecycle.
7
+ *
8
+ * @module teams/team-runtime
9
+ */
10
+ // =============================================================================
11
+ // TeamRuntime
12
+ // =============================================================================
13
+ export class TeamRuntime {
14
+ manifest;
15
+ services;
16
+ rootAgentId;
17
+ companionAgentIds = [];
18
+ roleRegistry;
19
+ lifecycleUnsubscribe;
20
+ integrationStrategy;
21
+ /** Role name → spawned agent ID mapping (populated during bootstrap) */
22
+ roleAgentMap = new Map();
23
+ /** Peer connections that couldn't be wired at bootstrap (target role not yet spawned) */
24
+ pendingPeerRoutes = [];
25
+ /** Per-agent signal filters from peer connections. Key: "fromAgentId→toAgentId" */
26
+ peerSignalFilters = new Map();
27
+ /** Reverse mapping: agent ID → role name (for signal filter lookups) */
28
+ agentRoleMap = new Map();
29
+ /** Lifecycle unsubscribe for deferred peer wiring */
30
+ peerWiringUnsubscribe;
31
+ constructor(manifest, services) {
32
+ this.manifest = manifest;
33
+ this.services = services;
34
+ this.roleRegistry = services.agentManager.getRoleRegistry();
35
+ }
36
+ // ─────────────────────────────────────────────────────────────
37
+ // Initialization
38
+ // ─────────────────────────────────────────────────────────────
39
+ /**
40
+ * Wire team configuration into running services.
41
+ *
42
+ * 1. Register team roles into RoleRegistry
43
+ * 2. Store team_config event in EventStore (for MCP subprocess discovery)
44
+ * 3. Register spawn interceptor on AgentManager
45
+ */
46
+ async initialize() {
47
+ const { agentManager, eventStore } = this.services;
48
+ // 1. Register team roles into RoleRegistry (custom layer, highest priority)
49
+ for (const [, resolved] of this.manifest._resolvedRoles) {
50
+ this.roleRegistry.registerRole(resolved.roleDefinition);
51
+ }
52
+ // 2. Store team config in EventStore for cross-process access (RD2)
53
+ const taskMode = this.manifest.macro_agent.task_assignment?.mode ?? "push";
54
+ const strategyName = this.manifest.macro_agent.integration?.strategy ?? "queue";
55
+ const strategyConfig = this.manifest.macro_agent.integration?.config ?? {};
56
+ const enforcement = this.manifest.communication.enforcement ?? "permissive";
57
+ // Serialize resolved roles for MCP subprocess capability checks
58
+ const serializedRoles = {};
59
+ for (const [name, resolved] of this.manifest._resolvedRoles) {
60
+ const rd = resolved.roleDefinition;
61
+ serializedRoles[name] = {
62
+ name: rd.name,
63
+ capabilities: [...rd.capabilities],
64
+ ...(rd.tools && { tools: rd.tools }),
65
+ ...(rd.lifecycle && { lifecycle: rd.lifecycle }),
66
+ ...(rd.description && { description: rd.description }),
67
+ };
68
+ }
69
+ eventStore.emit({
70
+ type: "status",
71
+ source: { agent_id: "system" },
72
+ payload: {
73
+ status_type: "discovery",
74
+ summary: `Team '${this.manifest.name}' initialized`,
75
+ team_config: {
76
+ teamName: this.manifest.name,
77
+ strategy: strategyName,
78
+ strategyConfig,
79
+ taskMode,
80
+ enforcement,
81
+ roles: serializedRoles,
82
+ peerRoutes: this.manifest.communication.routing?.peers ?? [],
83
+ emissions: this.manifest.communication.emissions ?? {},
84
+ },
85
+ },
86
+ });
87
+ await eventStore.persist();
88
+ // 2b. Instantiate integration strategy and call lifecycle hook
89
+ try {
90
+ const { defaultStrategyRegistry } = await import("../workspace/strategies/registry.js");
91
+ this.integrationStrategy = defaultStrategyRegistry.get(strategyName, strategyConfig);
92
+ if (this.integrationStrategy.initialize) {
93
+ await this.integrationStrategy.initialize();
94
+ }
95
+ }
96
+ catch {
97
+ // Strategy instantiation is best-effort — queue strategy needs merge queue set later
98
+ }
99
+ // 3. Register spawn interceptor
100
+ agentManager.setSpawnInterceptor(this.createSpawnInterceptor());
101
+ }
102
+ // ─────────────────────────────────────────────────────────────
103
+ // Bootstrap
104
+ // ─────────────────────────────────────────────────────────────
105
+ /**
106
+ * Spawn root and companion agents per the team topology.
107
+ */
108
+ async bootstrap() {
109
+ const { agentManager, messageRouter } = this.services;
110
+ const { topology } = this.manifest;
111
+ // 1. Spawn root agent
112
+ const rootPrompt = this.getPromptForTopologyNode(topology.root);
113
+ const root = await agentManager.spawn({
114
+ task: rootPrompt
115
+ ? `[${this.manifest.name}] ${topology.root.role}`
116
+ : `Team ${this.manifest.name} root: ${topology.root.role}`,
117
+ parent: null,
118
+ role: topology.root.role,
119
+ config: {
120
+ model: topology.root.config?.model,
121
+ },
122
+ customPrompt: rootPrompt,
123
+ interactionPatterns: this.getInteractionPatterns(),
124
+ });
125
+ this.rootAgentId = root.id;
126
+ // 2. Spawn companions (peers, not children)
127
+ const companionIds = [];
128
+ for (const companion of topology.companions ?? []) {
129
+ const companionPrompt = this.getPromptForTopologyNode(companion);
130
+ const agent = await agentManager.spawn({
131
+ task: `[${this.manifest.name}] ${companion.role}`,
132
+ parent: null,
133
+ role: companion.role,
134
+ config: {
135
+ model: companion.config?.model,
136
+ },
137
+ customPrompt: companionPrompt,
138
+ interactionPatterns: this.getInteractionPatterns(),
139
+ });
140
+ companionIds.push(agent.id);
141
+ }
142
+ this.companionAgentIds = companionIds;
143
+ // 3. Build role↔agent mappings and wire peer subscriptions
144
+ this.roleAgentMap.set(topology.root.role, root.id);
145
+ this.agentRoleMap.set(root.id, topology.root.role);
146
+ for (let i = 0; i < (topology.companions ?? []).length; i++) {
147
+ this.roleAgentMap.set(topology.companions[i].role, companionIds[i]);
148
+ this.agentRoleMap.set(companionIds[i], topology.companions[i].role);
149
+ }
150
+ this.wirePeerRoutes();
151
+ // 4. Install signal filter on message router
152
+ this.installSignalFilter();
153
+ // 5. Install emission validator on message router
154
+ this.installEmissionValidator();
155
+ // 6. Set up continuation monitoring for daemon agents (P4.2)
156
+ this.monitorContinuations();
157
+ return {
158
+ rootId: root.id,
159
+ companionIds,
160
+ };
161
+ }
162
+ // ─────────────────────────────────────────────────────────────
163
+ // Teardown
164
+ // ─────────────────────────────────────────────────────────────
165
+ /**
166
+ * Tear down team: remove spawn interceptor, stop continuation monitoring.
167
+ */
168
+ async teardown() {
169
+ this.services.agentManager.setSpawnInterceptor(null);
170
+ if (this.lifecycleUnsubscribe) {
171
+ this.lifecycleUnsubscribe();
172
+ this.lifecycleUnsubscribe = undefined;
173
+ }
174
+ if (this.peerWiringUnsubscribe) {
175
+ this.peerWiringUnsubscribe();
176
+ this.peerWiringUnsubscribe = undefined;
177
+ }
178
+ // Call strategy lifecycle close hook
179
+ if (this.integrationStrategy?.close) {
180
+ try {
181
+ await this.integrationStrategy.close();
182
+ }
183
+ catch {
184
+ // Best-effort cleanup
185
+ }
186
+ }
187
+ }
188
+ // ─────────────────────────────────────────────────────────────
189
+ // Getters
190
+ // ─────────────────────────────────────────────────────────────
191
+ /** Get task assignment mode */
192
+ getTaskMode() {
193
+ return this.manifest.macro_agent.task_assignment?.mode ?? "push";
194
+ }
195
+ /** Get integration strategy name */
196
+ getStrategyName() {
197
+ return this.manifest.macro_agent.integration?.strategy ?? "queue";
198
+ }
199
+ /** Get the active manifest (for API) */
200
+ getManifest() {
201
+ return this.manifest;
202
+ }
203
+ /** Get root agent ID (after bootstrap) */
204
+ getRootAgentId() {
205
+ return this.rootAgentId;
206
+ }
207
+ /** Get companion agent IDs (after bootstrap) */
208
+ getCompanionAgentIds() {
209
+ return [...this.companionAgentIds];
210
+ }
211
+ /** Get the instantiated integration strategy (after initialize) */
212
+ getIntegrationStrategy() {
213
+ return this.integrationStrategy;
214
+ }
215
+ /** Get signal filters for peer connections (for use by signal filtering - i-3o8g) */
216
+ getPeerSignalFilters() {
217
+ return this.peerSignalFilters;
218
+ }
219
+ // ─────────────────────────────────────────────────────────────
220
+ // Continuation Monitoring (P4.2)
221
+ // ─────────────────────────────────────────────────────────────
222
+ /**
223
+ * Monitor agent lifecycle events for auto-continuation of daemon agents.
224
+ *
225
+ * When a root or companion agent terminates unexpectedly and the team's
226
+ * lifecycle config enables continuations, automatically spawn a continuation.
227
+ */
228
+ monitorContinuations() {
229
+ const lifecycleConfig = this.manifest.macro_agent.lifecycle;
230
+ if (!lifecycleConfig?.continuations?.enabled)
231
+ return;
232
+ const { agentManager } = this.services;
233
+ const monitoredAgents = new Set([
234
+ this.rootAgentId,
235
+ ...this.companionAgentIds,
236
+ ]);
237
+ this.lifecycleUnsubscribe = agentManager.onLifecycleEvent((event) => {
238
+ if (event.type !== "stopped")
239
+ return;
240
+ if (!monitoredAgents.has(event.agent.id))
241
+ return;
242
+ // Only auto-continue on unexpected stops (not explicit completion)
243
+ const reason = event.reason;
244
+ if (reason === "completed" || reason === "cancelled")
245
+ return;
246
+ // Schedule auto-continuation (async, fire-and-forget)
247
+ setTimeout(async () => {
248
+ try {
249
+ const newAgent = await agentManager.continueAgent(event.agent.id);
250
+ // Update monitoring set
251
+ monitoredAgents.delete(event.agent.id);
252
+ monitoredAgents.add(newAgent.id);
253
+ if (event.agent.id === this.rootAgentId) {
254
+ this.rootAgentId = newAgent.id;
255
+ }
256
+ else {
257
+ const idx = this.companionAgentIds.indexOf(event.agent.id);
258
+ if (idx >= 0) {
259
+ this.companionAgentIds[idx] = newAgent.id;
260
+ }
261
+ }
262
+ }
263
+ catch {
264
+ // Failed to continue — agent is gone
265
+ }
266
+ }, 1000);
267
+ });
268
+ }
269
+ // ─────────────────────────────────────────────────────────────
270
+ // Spawn Interceptor
271
+ // ─────────────────────────────────────────────────────────────
272
+ /**
273
+ * Create the spawn interceptor that injects team context into spawn options.
274
+ */
275
+ createSpawnInterceptor() {
276
+ return (options) => {
277
+ const roleName = options.role;
278
+ if (!roleName)
279
+ return options;
280
+ const resolved = this.manifest._resolvedRoles.get(roleName);
281
+ if (!resolved)
282
+ return options; // Unknown role — pass through
283
+ // Compute topics from communication topology
284
+ const teamTopics = this.getTopicsForRole(roleName);
285
+ // Get MCP servers for this role
286
+ const teamMcpServers = this.getMcpServersForRole(roleName);
287
+ // Get prompt from role definition or topology
288
+ const teamPrompt = this.getPromptForRole(roleName);
289
+ // Build team env vars
290
+ const teamEnv = {
291
+ MACRO_TEAM_NAME: this.manifest.name,
292
+ MACRO_TASK_MODE: this.getTaskMode(),
293
+ };
294
+ const strategyName = this.getStrategyName();
295
+ if (strategyName) {
296
+ teamEnv.MACRO_INTEGRATION_STRATEGY = strategyName;
297
+ }
298
+ return {
299
+ ...options,
300
+ // Merge topics
301
+ topics: [
302
+ ...(options.topics ?? []),
303
+ ...teamTopics,
304
+ ],
305
+ // Merge config
306
+ config: {
307
+ ...options.config,
308
+ mcpServers: [
309
+ ...(options.config?.mcpServers ?? []),
310
+ ...teamMcpServers.map((s) => ({
311
+ name: s.name,
312
+ command: s.command,
313
+ args: s.args,
314
+ env: s.env,
315
+ })),
316
+ ],
317
+ env: {
318
+ ...options.config?.env,
319
+ ...teamEnv,
320
+ },
321
+ },
322
+ // Set team prompt (only if not already provided by caller)
323
+ customPrompt: options.customPrompt ?? teamPrompt,
324
+ // Set interaction patterns (only if not already provided)
325
+ interactionPatterns: options.interactionPatterns ?? this.getInteractionPatterns(),
326
+ };
327
+ };
328
+ }
329
+ // ─────────────────────────────────────────────────────────────
330
+ // Communication Topology Helpers
331
+ // ─────────────────────────────────────────────────────────────
332
+ /**
333
+ * Get topic names a role should subscribe to based on communication config.
334
+ */
335
+ getTopicsForRole(roleName) {
336
+ const topics = [];
337
+ const subs = this.manifest.communication.subscriptions?.[roleName] ?? [];
338
+ for (const sub of subs) {
339
+ // Channel name becomes the topic name
340
+ if (!topics.includes(sub.channel)) {
341
+ topics.push(sub.channel);
342
+ }
343
+ }
344
+ return topics;
345
+ }
346
+ /**
347
+ * Get MCP servers configured for a role.
348
+ */
349
+ getMcpServersForRole(roleName) {
350
+ return this.manifest._mcpServers.get(roleName) ?? [];
351
+ }
352
+ /**
353
+ * Get the loaded prompt content for a role.
354
+ */
355
+ getPromptForRole(roleName) {
356
+ const resolved = this.manifest._resolvedRoles.get(roleName);
357
+ if (!resolved?.prompt)
358
+ return undefined;
359
+ return this.manifest._loadedPrompts.get(resolved.prompt);
360
+ }
361
+ /**
362
+ * Get the prompt for a topology node (root or companion).
363
+ */
364
+ getPromptForTopologyNode(node) {
365
+ // Prefer topology-level prompt reference
366
+ if (node.prompt) {
367
+ return this.manifest._loadedPrompts.get(node.prompt);
368
+ }
369
+ // Fall back to role-level prompt
370
+ return this.getPromptForRole(node.role);
371
+ }
372
+ /**
373
+ * Generate interaction pattern injection sections based on team config.
374
+ */
375
+ getInteractionPatterns() {
376
+ const patterns = [];
377
+ const taskMode = this.getTaskMode();
378
+ if (taskMode === "pull") {
379
+ const pullConfig = this.manifest.macro_agent.task_assignment?.pull;
380
+ const idleTimeout = pullConfig?.idle_timeout_s ?? 300;
381
+ patterns.push(`## Task Claiming
382
+
383
+ You operate in PULL mode. After completing a task:
384
+ 1. Call done() with your results
385
+ 2. Call claim_task() to get your next task
386
+ 3. If no tasks available, wait briefly and retry
387
+ 4. After ${idleTimeout} seconds idle, call done() to exit gracefully
388
+
389
+ Claim and execute independently — do not wait for instructions.`);
390
+ }
391
+ const strategy = this.getStrategyName();
392
+ if (strategy === "trunk") {
393
+ patterns.push(`## Integration
394
+
395
+ Your changes are integrated via trunk-based development. When you call done(),
396
+ your work is pushed directly to the integration branch. If there's a conflict,
397
+ the system will rebase and retry automatically. Write small, focused changes
398
+ to minimize conflict probability.`);
399
+ }
400
+ else if (strategy === "optimistic") {
401
+ patterns.push(`## Integration
402
+
403
+ Your changes are integrated optimistically. They are pushed immediately and
404
+ validated asynchronously. If validation fails, a fixup task will be created.
405
+ Focus on correctness — your changes go live immediately.`);
406
+ }
407
+ return patterns;
408
+ }
409
+ // ─────────────────────────────────────────────────────────────
410
+ // Signal Filtering
411
+ // ─────────────────────────────────────────────────────────────
412
+ /**
413
+ * Install a signal filter on the message router.
414
+ *
415
+ * Combines two filter sources:
416
+ * 1. Channel subscription filters (per-role, per-topic): from communication.subscriptions
417
+ * 2. Peer connection filters (per-agent-pair): from communication.routing.peers
418
+ *
419
+ * Status events with no details.signal always pass through (backwards compat).
420
+ */
421
+ installSignalFilter() {
422
+ const { messageRouter } = this.services;
423
+ // Pre-compute per-role allowed signals from channel subscriptions.
424
+ // Key: role name, Value: Set of allowed signal names.
425
+ // If a role has any subscription without a signals filter, it receives all signals.
426
+ const roleAllowedSignals = new Map();
427
+ for (const [roleName, subs] of Object.entries(this.manifest.communication.subscriptions ?? {})) {
428
+ let allowed = new Set();
429
+ for (const sub of subs) {
430
+ if (!sub.signals || sub.signals.length === 0) {
431
+ // No filter on this subscription — role receives all signals
432
+ allowed = "all";
433
+ break;
434
+ }
435
+ for (const sig of sub.signals) {
436
+ allowed.add(sig);
437
+ }
438
+ }
439
+ roleAllowedSignals.set(roleName, allowed);
440
+ }
441
+ if (messageRouter.setSignalFilter) {
442
+ messageRouter.setSignalFilter((from, to, signal) => {
443
+ // Untagged status events always pass through
444
+ if (!signal)
445
+ return true;
446
+ // Check peer connection filter (directional: from→to)
447
+ const peerFilter = this.peerSignalFilters.get(`${from}→${to}`);
448
+ if (peerFilter) {
449
+ return peerFilter.includes(signal);
450
+ }
451
+ // Check channel subscription filter for recipient's role
452
+ const recipientRole = this.agentRoleMap.get(to);
453
+ if (recipientRole) {
454
+ const allowed = roleAllowedSignals.get(recipientRole);
455
+ if (allowed && allowed !== "all") {
456
+ return allowed.has(signal);
457
+ }
458
+ }
459
+ // No filter configured — allow delivery
460
+ return true;
461
+ });
462
+ }
463
+ }
464
+ // ─────────────────────────────────────────────────────────────
465
+ // Emission Validation
466
+ // ─────────────────────────────────────────────────────────────
467
+ /**
468
+ * Install emission validator on the message router.
469
+ * Checks whether an agent's emitted signal is in its role's allowed emissions list.
470
+ * Behavior depends on enforcement mode: strict (reject), permissive (warn), audit (record).
471
+ */
472
+ installEmissionValidator() {
473
+ const { messageRouter } = this.services;
474
+ const emissions = this.manifest.communication.emissions;
475
+ const enforcement = this.manifest.communication.enforcement ?? "permissive";
476
+ // No emissions config — nothing to enforce
477
+ if (!emissions || Object.keys(emissions).length === 0)
478
+ return;
479
+ if (messageRouter.setEmissionValidator) {
480
+ messageRouter.setEmissionValidator((agentId, signal) => {
481
+ // Untagged status events are always allowed
482
+ if (!signal)
483
+ return { action: "allow" };
484
+ const role = this.agentRoleMap.get(agentId);
485
+ if (!role)
486
+ return { action: "allow" };
487
+ const allowedSignals = emissions[role];
488
+ if (!allowedSignals)
489
+ return { action: "allow" };
490
+ if (allowedSignals.includes(signal)) {
491
+ return { action: "allow" };
492
+ }
493
+ // Signal not in allowed list — enforce
494
+ const message = `Agent '${agentId}' (role: ${role}) emitted disallowed signal '${signal}'. Allowed: [${allowedSignals.join(", ")}]`;
495
+ switch (enforcement) {
496
+ case "strict":
497
+ return { action: "reject", message };
498
+ case "audit":
499
+ return { action: "audit", message };
500
+ case "permissive":
501
+ default:
502
+ return { action: "warn", message };
503
+ }
504
+ });
505
+ }
506
+ }
507
+ // ─────────────────────────────────────────────────────────────
508
+ // Peer Routing
509
+ // ─────────────────────────────────────────────────────────────
510
+ /**
511
+ * Wire peer subscriptions from communication config.
512
+ * Falls back to legacy bidirectional subtree subs when no peers config exists.
513
+ */
514
+ wirePeerRoutes() {
515
+ const peers = this.manifest.communication.routing?.peers;
516
+ if (!peers || peers.length === 0) {
517
+ // Fallback: hardcoded mutual subtree subscriptions (backwards compat)
518
+ this.setupLegacyPeerSubscriptions();
519
+ return;
520
+ }
521
+ this.pendingPeerRoutes = [];
522
+ for (const peer of peers) {
523
+ const fromAgent = this.roleAgentMap.get(peer.from);
524
+ const toAgent = this.roleAgentMap.get(peer.to);
525
+ if (!fromAgent || !toAgent) {
526
+ // One or both roles not yet spawned — defer
527
+ this.pendingPeerRoutes.push(peer);
528
+ continue;
529
+ }
530
+ this.wireSinglePeerRoute(peer, fromAgent, toAgent);
531
+ }
532
+ // If there are pending routes, set up lifecycle listener for deferred wiring
533
+ if (this.pendingPeerRoutes.length > 0) {
534
+ this.setupDeferredPeerWiring();
535
+ }
536
+ }
537
+ /**
538
+ * Wire a single peer connection based on its `via` type.
539
+ */
540
+ wireSinglePeerRoute(peer, fromAgent, toAgent) {
541
+ const { messageRouter } = this.services;
542
+ switch (peer.via) {
543
+ case "direct":
544
+ // Directional: from receives status events from to's subtree
545
+ messageRouter.subscribe(fromAgent, { type: "subtree", target: toAgent });
546
+ break;
547
+ case "topic": {
548
+ // Both agents share a named topic
549
+ const topicName = `peer:${peer.from}:${peer.to}`;
550
+ messageRouter.subscribe(fromAgent, { type: "topic", target: topicName });
551
+ messageRouter.subscribe(toAgent, { type: "topic", target: topicName });
552
+ break;
553
+ }
554
+ case "scope":
555
+ // from subscribes to to's role channel
556
+ messageRouter.subscribe(fromAgent, { type: "role", target: peer.to });
557
+ break;
558
+ }
559
+ // Store signal filter if specified
560
+ if (peer.signals && peer.signals.length > 0) {
561
+ const key = `${fromAgent}→${toAgent}`;
562
+ this.peerSignalFilters.set(key, peer.signals);
563
+ }
564
+ }
565
+ /**
566
+ * Legacy bidirectional subtree subscriptions between root and companions.
567
+ * Used when no `routing.peers` config is defined (backwards compat).
568
+ */
569
+ setupLegacyPeerSubscriptions() {
570
+ const { messageRouter } = this.services;
571
+ if (!this.rootAgentId)
572
+ return;
573
+ for (const companionId of this.companionAgentIds) {
574
+ messageRouter.subscribe(this.rootAgentId, { type: "subtree", target: companionId });
575
+ messageRouter.subscribe(companionId, { type: "subtree", target: this.rootAgentId });
576
+ }
577
+ }
578
+ /**
579
+ * Listen for agent spawns and wire pending peer routes when roles become available.
580
+ */
581
+ setupDeferredPeerWiring() {
582
+ const { agentManager } = this.services;
583
+ this.peerWiringUnsubscribe = agentManager.onLifecycleEvent((event) => {
584
+ if (event.type !== "spawned")
585
+ return;
586
+ const role = event.agent.role;
587
+ if (!role)
588
+ return;
589
+ // Update role↔agent mappings
590
+ this.roleAgentMap.set(role, event.agent.id);
591
+ this.agentRoleMap.set(event.agent.id, role);
592
+ // Try to wire any pending routes involving this role
593
+ const stillPending = [];
594
+ for (const peer of this.pendingPeerRoutes) {
595
+ const fromAgent = this.roleAgentMap.get(peer.from);
596
+ const toAgent = this.roleAgentMap.get(peer.to);
597
+ if (fromAgent && toAgent) {
598
+ this.wireSinglePeerRoute(peer, fromAgent, toAgent);
599
+ }
600
+ else {
601
+ stillPending.push(peer);
602
+ }
603
+ }
604
+ this.pendingPeerRoutes = stillPending;
605
+ // All wired — unsubscribe
606
+ if (stillPending.length === 0 && this.peerWiringUnsubscribe) {
607
+ this.peerWiringUnsubscribe();
608
+ this.peerWiringUnsubscribe = undefined;
609
+ }
610
+ });
611
+ }
612
+ }
613
+ //# sourceMappingURL=team-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"team-runtime.js","sourceRoot":"","sources":["../../src/teams/team-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA8BH,gFAAgF;AAChF,cAAc;AACd,gFAAgF;AAEhF,MAAM,OAAO,WAAW;IAuBH;IACA;IAvBX,WAAW,CAAU;IACrB,iBAAiB,GAAa,EAAE,CAAC;IACjC,YAAY,CAAe;IAC3B,oBAAoB,CAAc;IAClC,mBAAmB,CAAuB;IAElD,wEAAwE;IAChE,YAAY,GAAG,IAAI,GAAG,EAAmB,CAAC;IAElD,yFAAyF;IACjF,iBAAiB,GAAqB,EAAE,CAAC;IAEjD,mFAAmF;IAC3E,iBAAiB,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