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.
- package/LICENSE +1 -1
- package/README.md +30 -56
- package/dist/acp/websocket-server.d.ts +6 -0
- package/dist/acp/websocket-server.d.ts.map +1 -1
- package/dist/acp/websocket-server.js +13 -0
- package/dist/acp/websocket-server.js.map +1 -1
- package/dist/acp/websocket-stream.d.ts +30 -0
- package/dist/acp/websocket-stream.d.ts.map +1 -0
- package/dist/acp/websocket-stream.js +118 -0
- package/dist/acp/websocket-stream.js.map +1 -0
- package/dist/activity/deduplication.d.ts +85 -0
- package/dist/activity/deduplication.d.ts.map +1 -0
- package/dist/activity/deduplication.js +149 -0
- package/dist/activity/deduplication.js.map +1 -0
- package/dist/activity/index.d.ts +16 -0
- package/dist/activity/index.d.ts.map +1 -0
- package/dist/activity/index.js +17 -0
- package/dist/activity/index.js.map +1 -0
- package/dist/activity/relevance.d.ts +81 -0
- package/dist/activity/relevance.d.ts.map +1 -0
- package/dist/activity/relevance.js +161 -0
- package/dist/activity/relevance.js.map +1 -0
- package/dist/activity/types.d.ts +169 -0
- package/dist/activity/types.d.ts.map +1 -0
- package/dist/activity/types.js +33 -0
- package/dist/activity/types.js.map +1 -0
- package/dist/activity/watcher.d.ts +64 -0
- package/dist/activity/watcher.d.ts.map +1 -0
- package/dist/activity/watcher.js +212 -0
- package/dist/activity/watcher.js.map +1 -0
- package/dist/adapters/federation.d.ts +8 -1
- package/dist/adapters/federation.d.ts.map +1 -1
- package/dist/adapters/federation.js +33 -2
- package/dist/adapters/federation.js.map +1 -1
- package/dist/agent/agent-manager-v2.d.ts.map +1 -1
- package/dist/agent/agent-manager-v2.js +7 -24
- package/dist/agent/agent-manager-v2.js.map +1 -1
- package/dist/agent/wake.d.ts +85 -0
- package/dist/agent/wake.d.ts.map +1 -0
- package/dist/agent/wake.js +278 -0
- package/dist/agent/wake.js.map +1 -0
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +41 -25
- package/dist/api/server.js.map +1 -1
- package/dist/api/types.d.ts +6 -0
- package/dist/api/types.d.ts.map +1 -1
- package/dist/auth/server-auth.d.ts +43 -0
- package/dist/auth/server-auth.d.ts.map +1 -0
- package/dist/auth/server-auth.js +80 -0
- package/dist/auth/server-auth.js.map +1 -0
- package/dist/auth/token.d.ts +4 -0
- package/dist/auth/token.d.ts.map +1 -1
- package/dist/auth/token.js +7 -6
- package/dist/auth/token.js.map +1 -1
- package/dist/boot-v2.d.ts +6 -3
- package/dist/boot-v2.d.ts.map +1 -1
- package/dist/boot-v2.js +44 -25
- package/dist/boot-v2.js.map +1 -1
- package/dist/cognitive/team-lifecycle.d.ts +82 -0
- package/dist/cognitive/team-lifecycle.d.ts.map +1 -0
- package/dist/cognitive/team-lifecycle.js +121 -0
- package/dist/cognitive/team-lifecycle.js.map +1 -0
- package/dist/cognitive/trajectory-extractor.d.ts +25 -0
- package/dist/cognitive/trajectory-extractor.d.ts.map +1 -0
- package/dist/cognitive/trajectory-extractor.js +134 -0
- package/dist/cognitive/trajectory-extractor.js.map +1 -0
- package/dist/control/control-server.d.ts.map +1 -1
- package/dist/control/control-server.js +10 -0
- package/dist/control/control-server.js.map +1 -1
- package/dist/dispatch/mail-inbound-consumer.d.ts.map +1 -1
- package/dist/dispatch/mail-inbound-consumer.js +43 -10
- package/dist/dispatch/mail-inbound-consumer.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/lifecycle/handlers/generic.d.ts +27 -0
- package/dist/lifecycle/handlers/generic.d.ts.map +1 -0
- package/dist/lifecycle/handlers/generic.js +56 -0
- package/dist/lifecycle/handlers/generic.js.map +1 -0
- package/dist/lifecycle/handlers/index.d.ts +51 -0
- package/dist/lifecycle/handlers/index.d.ts.map +1 -0
- package/dist/lifecycle/handlers/index.js +110 -0
- package/dist/lifecycle/handlers/index.js.map +1 -0
- package/dist/lifecycle/handlers/integrator.d.ts +81 -0
- package/dist/lifecycle/handlers/integrator.d.ts.map +1 -0
- package/dist/lifecycle/handlers/integrator.js +451 -0
- package/dist/lifecycle/handlers/integrator.js.map +1 -0
- package/dist/lifecycle/handlers/monitor.d.ts +29 -0
- package/dist/lifecycle/handlers/monitor.d.ts.map +1 -0
- package/dist/lifecycle/handlers/monitor.js +79 -0
- package/dist/lifecycle/handlers/monitor.js.map +1 -0
- package/dist/lifecycle/handlers/worker.d.ts +56 -0
- package/dist/lifecycle/handlers/worker.d.ts.map +1 -0
- package/dist/lifecycle/handlers/worker.js +381 -0
- package/dist/lifecycle/handlers/worker.js.map +1 -0
- package/dist/lifecycle/handlers-v2.d.ts +0 -2
- package/dist/lifecycle/handlers-v2.d.ts.map +1 -1
- package/dist/lifecycle/handlers-v2.js +4 -55
- package/dist/lifecycle/handlers-v2.js.map +1 -1
- package/dist/mail/conversation-map.d.ts +33 -0
- package/dist/mail/conversation-map.d.ts.map +1 -0
- package/dist/mail/conversation-map.js +61 -0
- package/dist/mail/conversation-map.js.map +1 -0
- package/dist/mail/index.d.ts +11 -0
- package/dist/mail/index.d.ts.map +1 -0
- package/dist/mail/index.js +11 -0
- package/dist/mail/index.js.map +1 -0
- package/dist/mail/mail-service.d.ts +85 -0
- package/dist/mail/mail-service.d.ts.map +1 -0
- package/dist/mail/mail-service.js +121 -0
- package/dist/mail/mail-service.js.map +1 -0
- package/dist/mail/stores/eventstore-conversation-store.d.ts +40 -0
- package/dist/mail/stores/eventstore-conversation-store.d.ts.map +1 -0
- package/dist/mail/stores/eventstore-conversation-store.js +131 -0
- package/dist/mail/stores/eventstore-conversation-store.js.map +1 -0
- package/dist/mail/stores/eventstore-participant-store.d.ts +43 -0
- package/dist/mail/stores/eventstore-participant-store.d.ts.map +1 -0
- package/dist/mail/stores/eventstore-participant-store.js +145 -0
- package/dist/mail/stores/eventstore-participant-store.js.map +1 -0
- package/dist/mail/stores/eventstore-thread-store.d.ts +46 -0
- package/dist/mail/stores/eventstore-thread-store.d.ts.map +1 -0
- package/dist/mail/stores/eventstore-thread-store.js +118 -0
- package/dist/mail/stores/eventstore-thread-store.js.map +1 -0
- package/dist/mail/stores/eventstore-turn-store.d.ts +47 -0
- package/dist/mail/stores/eventstore-turn-store.d.ts.map +1 -0
- package/dist/mail/stores/eventstore-turn-store.js +153 -0
- package/dist/mail/stores/eventstore-turn-store.js.map +1 -0
- package/dist/mail/stores/index.d.ts +12 -0
- package/dist/mail/stores/index.d.ts.map +1 -0
- package/dist/mail/stores/index.js +12 -0
- package/dist/mail/stores/index.js.map +1 -0
- package/dist/mail/stores/types.d.ts +146 -0
- package/dist/mail/stores/types.d.ts.map +1 -0
- package/dist/mail/stores/types.js +13 -0
- package/dist/mail/stores/types.js.map +1 -0
- package/dist/mail/turn-recorder.d.ts +30 -0
- package/dist/mail/turn-recorder.d.ts.map +1 -0
- package/dist/mail/turn-recorder.js +98 -0
- package/dist/mail/turn-recorder.js.map +1 -0
- package/dist/map/adapter/acp-over-map.d.ts +115 -0
- package/dist/map/adapter/acp-over-map.d.ts.map +1 -0
- package/dist/map/adapter/acp-over-map.js +1024 -0
- package/dist/map/adapter/acp-over-map.js.map +1 -0
- package/dist/map/adapter/connection-manager.d.ts +150 -0
- package/dist/map/adapter/connection-manager.d.ts.map +1 -0
- package/dist/map/adapter/connection-manager.js +207 -0
- package/dist/map/adapter/connection-manager.js.map +1 -0
- package/dist/map/adapter/event-log.d.ts +87 -0
- package/dist/map/adapter/event-log.d.ts.map +1 -0
- package/dist/map/adapter/event-log.js +122 -0
- package/dist/map/adapter/event-log.js.map +1 -0
- package/dist/map/adapter/event-translator.d.ts +85 -0
- package/dist/map/adapter/event-translator.d.ts.map +1 -0
- package/dist/map/adapter/event-translator.js +295 -0
- package/dist/map/adapter/event-translator.js.map +1 -0
- package/dist/map/adapter/extensions/agent-detection.d.ts +49 -0
- package/dist/map/adapter/extensions/agent-detection.d.ts.map +1 -0
- package/dist/map/adapter/extensions/agent-detection.js +91 -0
- package/dist/map/adapter/extensions/agent-detection.js.map +1 -0
- package/dist/map/adapter/extensions/agent-lifecycle.d.ts +82 -0
- package/dist/map/adapter/extensions/agent-lifecycle.d.ts.map +1 -0
- package/dist/map/adapter/extensions/agent-lifecycle.js +164 -0
- package/dist/map/adapter/extensions/agent-lifecycle.js.map +1 -0
- package/dist/map/adapter/extensions/cognitive.d.ts +27 -0
- package/dist/map/adapter/extensions/cognitive.d.ts.map +1 -0
- package/dist/map/adapter/extensions/cognitive.js +158 -0
- package/dist/map/adapter/extensions/cognitive.js.map +1 -0
- package/dist/map/adapter/extensions/index.d.ts +95 -0
- package/dist/map/adapter/extensions/index.d.ts.map +1 -0
- package/dist/map/adapter/extensions/index.js +228 -0
- package/dist/map/adapter/extensions/index.js.map +1 -0
- package/dist/map/adapter/extensions/mcp-bridge.d.ts +57 -0
- package/dist/map/adapter/extensions/mcp-bridge.d.ts.map +1 -0
- package/dist/map/adapter/extensions/mcp-bridge.js +745 -0
- package/dist/map/adapter/extensions/mcp-bridge.js.map +1 -0
- package/dist/map/adapter/extensions/resume.d.ts +47 -0
- package/dist/map/adapter/extensions/resume.d.ts.map +1 -0
- package/dist/map/adapter/extensions/resume.js +59 -0
- package/dist/map/adapter/extensions/resume.js.map +1 -0
- package/dist/map/adapter/extensions/streams.d.ts +95 -0
- package/dist/map/adapter/extensions/streams.d.ts.map +1 -0
- package/dist/map/adapter/extensions/streams.js +515 -0
- package/dist/map/adapter/extensions/streams.js.map +1 -0
- package/dist/map/adapter/extensions/task.d.ts +40 -0
- package/dist/map/adapter/extensions/task.d.ts.map +1 -0
- package/dist/map/adapter/extensions/task.js +197 -0
- package/dist/map/adapter/extensions/task.js.map +1 -0
- package/dist/map/adapter/extensions/update-metadata.d.ts +29 -0
- package/dist/map/adapter/extensions/update-metadata.d.ts.map +1 -0
- package/dist/map/adapter/extensions/update-metadata.js +67 -0
- package/dist/map/adapter/extensions/update-metadata.js.map +1 -0
- package/dist/map/adapter/extensions/wake.d.ts +60 -0
- package/dist/map/adapter/extensions/wake.d.ts.map +1 -0
- package/dist/map/adapter/extensions/wake.js +144 -0
- package/dist/map/adapter/extensions/wake.js.map +1 -0
- package/dist/map/adapter/extensions/workspace-files.d.ts +42 -0
- package/dist/map/adapter/extensions/workspace-files.d.ts.map +1 -0
- package/dist/map/adapter/extensions/workspace-files.js +338 -0
- package/dist/map/adapter/extensions/workspace-files.js.map +1 -0
- package/dist/map/adapter/extensions/workspace.d.ts +57 -0
- package/dist/map/adapter/extensions/workspace.d.ts.map +1 -0
- package/dist/map/adapter/extensions/workspace.js +81 -0
- package/dist/map/adapter/extensions/workspace.js.map +1 -0
- package/dist/map/adapter/index.d.ts +20 -0
- package/dist/map/adapter/index.d.ts.map +1 -0
- package/dist/map/adapter/index.js +40 -0
- package/dist/map/adapter/index.js.map +1 -0
- package/dist/map/adapter/interface.d.ts +450 -0
- package/dist/map/adapter/interface.d.ts.map +1 -0
- package/dist/map/adapter/interface.js +24 -0
- package/dist/map/adapter/interface.js.map +1 -0
- package/dist/map/adapter/mail-handler-adapter.d.ts +27 -0
- package/dist/map/adapter/mail-handler-adapter.d.ts.map +1 -0
- package/dist/map/adapter/mail-handler-adapter.js +292 -0
- package/dist/map/adapter/mail-handler-adapter.js.map +1 -0
- package/dist/map/adapter/map-adapter.d.ts +200 -0
- package/dist/map/adapter/map-adapter.d.ts.map +1 -0
- package/dist/map/adapter/map-adapter.js +1199 -0
- package/dist/map/adapter/map-adapter.js.map +1 -0
- package/dist/map/adapter/rpc-handler.d.ts +263 -0
- package/dist/map/adapter/rpc-handler.d.ts.map +1 -0
- package/dist/map/adapter/rpc-handler.js +365 -0
- package/dist/map/adapter/rpc-handler.js.map +1 -0
- package/dist/map/adapter/subscription-manager.d.ts +174 -0
- package/dist/map/adapter/subscription-manager.d.ts.map +1 -0
- package/dist/map/adapter/subscription-manager.js +248 -0
- package/dist/map/adapter/subscription-manager.js.map +1 -0
- package/dist/map/adapter/types.d.ts +194 -0
- package/dist/map/adapter/types.d.ts.map +1 -0
- package/dist/map/adapter/types.js +27 -0
- package/dist/map/adapter/types.js.map +1 -0
- package/dist/map/adapter/websocket-integration.d.ts +113 -0
- package/dist/map/adapter/websocket-integration.d.ts.map +1 -0
- package/dist/map/adapter/websocket-integration.js +134 -0
- package/dist/map/adapter/websocket-integration.js.map +1 -0
- package/dist/map/cascade-action-handler.d.ts.map +1 -1
- package/dist/map/cascade-action-handler.js +19 -5
- package/dist/map/cascade-action-handler.js.map +1 -1
- package/dist/map/federation/envelope.d.ts +98 -0
- package/dist/map/federation/envelope.d.ts.map +1 -0
- package/dist/map/federation/envelope.js +160 -0
- package/dist/map/federation/envelope.js.map +1 -0
- package/dist/map/federation/federation-handler.d.ts +50 -0
- package/dist/map/federation/federation-handler.d.ts.map +1 -0
- package/dist/map/federation/federation-handler.js +306 -0
- package/dist/map/federation/federation-handler.js.map +1 -0
- package/dist/map/federation/index.d.ts +14 -0
- package/dist/map/federation/index.d.ts.map +1 -0
- package/dist/map/federation/index.js +13 -0
- package/dist/map/federation/index.js.map +1 -0
- package/dist/map/federation/types.d.ts +239 -0
- package/dist/map/federation/types.d.ts.map +1 -0
- package/dist/map/federation/types.js +23 -0
- package/dist/map/federation/types.js.map +1 -0
- package/dist/map/server.d.ts.map +1 -1
- package/dist/map/server.js +17 -2
- package/dist/map/server.js.map +1 -1
- package/dist/map/types.d.ts +6 -0
- package/dist/map/types.d.ts.map +1 -1
- package/dist/mcp/map-client.d.ts +39 -0
- package/dist/mcp/map-client.d.ts.map +1 -0
- package/dist/mcp/map-client.js +129 -0
- package/dist/mcp/map-client.js.map +1 -0
- package/dist/mcp/mcp-server.d.ts +72 -0
- package/dist/mcp/mcp-server.d.ts.map +1 -0
- package/dist/mcp/mcp-server.js +1027 -0
- package/dist/mcp/mcp-server.js.map +1 -0
- package/dist/mcp/tools/claim_task.d.ts +35 -0
- package/dist/mcp/tools/claim_task.d.ts.map +1 -0
- package/dist/mcp/tools/claim_task.js +58 -0
- package/dist/mcp/tools/claim_task.js.map +1 -0
- package/dist/mcp/tools/done-v2.d.ts +0 -1
- package/dist/mcp/tools/done-v2.d.ts.map +1 -1
- package/dist/mcp/tools/done-v2.js +0 -1
- package/dist/mcp/tools/done-v2.js.map +1 -1
- package/dist/mcp/tools/done.d.ts +102 -0
- package/dist/mcp/tools/done.d.ts.map +1 -0
- package/dist/mcp/tools/done.js +253 -0
- package/dist/mcp/tools/done.js.map +1 -0
- package/dist/mcp/tools/inject_context.d.ts +61 -0
- package/dist/mcp/tools/inject_context.d.ts.map +1 -0
- package/dist/mcp/tools/inject_context.js +123 -0
- package/dist/mcp/tools/inject_context.js.map +1 -0
- package/dist/mcp/tools/list_claimable_tasks.d.ts +38 -0
- package/dist/mcp/tools/list_claimable_tasks.d.ts.map +1 -0
- package/dist/mcp/tools/list_claimable_tasks.js +63 -0
- package/dist/mcp/tools/list_claimable_tasks.js.map +1 -0
- package/dist/mcp/tools/unclaim_task.d.ts +31 -0
- package/dist/mcp/tools/unclaim_task.d.ts.map +1 -0
- package/dist/mcp/tools/unclaim_task.js +47 -0
- package/dist/mcp/tools/unclaim_task.js.map +1 -0
- package/dist/mcp/tools/wait_for_activity.d.ts +60 -0
- package/dist/mcp/tools/wait_for_activity.d.ts.map +1 -0
- package/dist/mcp/tools/wait_for_activity.js +135 -0
- package/dist/mcp/tools/wait_for_activity.js.map +1 -0
- package/dist/monitor/health-check-service.d.ts +143 -0
- package/dist/monitor/health-check-service.d.ts.map +1 -0
- package/dist/monitor/health-check-service.js +240 -0
- package/dist/monitor/health-check-service.js.map +1 -0
- package/dist/monitor/index.d.ts +14 -0
- package/dist/monitor/index.d.ts.map +1 -0
- package/dist/monitor/index.js +14 -0
- package/dist/monitor/index.js.map +1 -0
- package/dist/monitor/stall-detector.d.ts +109 -0
- package/dist/monitor/stall-detector.d.ts.map +1 -0
- package/dist/monitor/stall-detector.js +152 -0
- package/dist/monitor/stall-detector.js.map +1 -0
- package/dist/peer/capability-manager.d.ts +56 -0
- package/dist/peer/capability-manager.d.ts.map +1 -0
- package/dist/peer/capability-manager.js +186 -0
- package/dist/peer/capability-manager.js.map +1 -0
- package/dist/peer/encapsulation-manager.d.ts +190 -0
- package/dist/peer/encapsulation-manager.d.ts.map +1 -0
- package/dist/peer/encapsulation-manager.js +486 -0
- package/dist/peer/encapsulation-manager.js.map +1 -0
- package/dist/peer/federation-manager.d.ts +223 -0
- package/dist/peer/federation-manager.d.ts.map +1 -0
- package/dist/peer/federation-manager.js +528 -0
- package/dist/peer/federation-manager.js.map +1 -0
- package/dist/peer/hierarchy-errors.d.ts +208 -0
- package/dist/peer/hierarchy-errors.d.ts.map +1 -0
- package/dist/peer/hierarchy-errors.js +268 -0
- package/dist/peer/hierarchy-errors.js.map +1 -0
- package/dist/peer/hierarchy-protocol.d.ts +159 -0
- package/dist/peer/hierarchy-protocol.d.ts.map +1 -0
- package/dist/peer/hierarchy-protocol.js +142 -0
- package/dist/peer/hierarchy-protocol.js.map +1 -0
- package/dist/peer/index.d.ts +15 -0
- package/dist/peer/index.d.ts.map +1 -0
- package/dist/peer/index.js +15 -0
- package/dist/peer/index.js.map +1 -0
- package/dist/peer/peer-manager.d.ts +99 -0
- package/dist/peer/peer-manager.d.ts.map +1 -0
- package/dist/peer/peer-manager.js +333 -0
- package/dist/peer/peer-manager.js.map +1 -0
- package/dist/peer/task-delegation.d.ts +189 -0
- package/dist/peer/task-delegation.d.ts.map +1 -0
- package/dist/peer/task-delegation.js +303 -0
- package/dist/peer/task-delegation.js.map +1 -0
- package/dist/peer/transports/index.d.ts +8 -0
- package/dist/peer/transports/index.d.ts.map +1 -0
- package/dist/peer/transports/index.js +8 -0
- package/dist/peer/transports/index.js.map +1 -0
- package/dist/peer/transports/local-transport.d.ts +56 -0
- package/dist/peer/transports/local-transport.d.ts.map +1 -0
- package/dist/peer/transports/local-transport.js +263 -0
- package/dist/peer/transports/local-transport.js.map +1 -0
- package/dist/peer/transports/websocket-transport.d.ts +86 -0
- package/dist/peer/transports/websocket-transport.d.ts.map +1 -0
- package/dist/peer/transports/websocket-transport.js +338 -0
- package/dist/peer/transports/websocket-transport.js.map +1 -0
- package/dist/peer/types.d.ts +268 -0
- package/dist/peer/types.d.ts.map +1 -0
- package/dist/peer/types.js +36 -0
- package/dist/peer/types.js.map +1 -0
- package/dist/router/address-resolver.d.ts +102 -0
- package/dist/router/address-resolver.d.ts.map +1 -0
- package/dist/router/address-resolver.js +198 -0
- package/dist/router/address-resolver.js.map +1 -0
- package/dist/router/broadcast.d.ts +53 -0
- package/dist/router/broadcast.d.ts.map +1 -0
- package/dist/router/broadcast.js +75 -0
- package/dist/router/broadcast.js.map +1 -0
- package/dist/router/channels.d.ts +148 -0
- package/dist/router/channels.d.ts.map +1 -0
- package/dist/router/channels.js +126 -0
- package/dist/router/channels.js.map +1 -0
- package/dist/router/index.d.ts +21 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js +18 -0
- package/dist/router/index.js.map +1 -0
- package/dist/router/message-router.d.ts +197 -0
- package/dist/router/message-router.d.ts.map +1 -0
- package/dist/router/message-router.js +903 -0
- package/dist/router/message-router.js.map +1 -0
- package/dist/router/message-types.d.ts +183 -0
- package/dist/router/message-types.d.ts.map +1 -0
- package/dist/router/message-types.js +79 -0
- package/dist/router/message-types.js.map +1 -0
- package/dist/router/role-resolver.d.ts +67 -0
- package/dist/router/role-resolver.d.ts.map +1 -0
- package/dist/router/role-resolver.js +106 -0
- package/dist/router/role-resolver.js.map +1 -0
- package/dist/router/signals.d.ts +253 -0
- package/dist/router/signals.d.ts.map +1 -0
- package/dist/router/signals.js +53 -0
- package/dist/router/signals.js.map +1 -0
- package/dist/router/types.d.ts +191 -0
- package/dist/router/types.d.ts.map +1 -0
- package/dist/router/types.js +34 -0
- package/dist/router/types.js.map +1 -0
- package/dist/router/wake.d.ts +111 -0
- package/dist/router/wake.d.ts.map +1 -0
- package/dist/router/wake.js +180 -0
- package/dist/router/wake.js.map +1 -0
- package/dist/server/combined-server.d.ts +95 -0
- package/dist/server/combined-server.d.ts.map +1 -0
- package/dist/server/combined-server.js +335 -0
- package/dist/server/combined-server.js.map +1 -0
- package/dist/steering/index.d.ts +11 -0
- package/dist/steering/index.d.ts.map +1 -0
- package/dist/steering/index.js +11 -0
- package/dist/steering/index.js.map +1 -0
- package/dist/steering/inject.d.ts +39 -0
- package/dist/steering/inject.d.ts.map +1 -0
- package/dist/steering/inject.js +197 -0
- package/dist/steering/inject.js.map +1 -0
- package/dist/steering/types.d.ts +100 -0
- package/dist/steering/types.d.ts.map +1 -0
- package/dist/steering/types.js +11 -0
- package/dist/steering/types.js.map +1 -0
- package/dist/store/backends/index.d.ts +11 -0
- package/dist/store/backends/index.d.ts.map +1 -0
- package/dist/store/backends/index.js +15 -0
- package/dist/store/backends/index.js.map +1 -0
- package/dist/store/backends/json-backend.d.ts +23 -0
- package/dist/store/backends/json-backend.d.ts.map +1 -0
- package/dist/store/backends/json-backend.js +220 -0
- package/dist/store/backends/json-backend.js.map +1 -0
- package/dist/store/backends/memory-backend.d.ts +12 -0
- package/dist/store/backends/memory-backend.d.ts.map +1 -0
- package/dist/store/backends/memory-backend.js +205 -0
- package/dist/store/backends/memory-backend.js.map +1 -0
- package/dist/store/backends/sqlite-backend.d.ts +27 -0
- package/dist/store/backends/sqlite-backend.d.ts.map +1 -0
- package/dist/store/backends/sqlite-backend.js +231 -0
- package/dist/store/backends/sqlite-backend.js.map +1 -0
- package/dist/store/backends/tinybase-backend.d.ts +22 -0
- package/dist/store/backends/tinybase-backend.d.ts.map +1 -0
- package/dist/store/backends/tinybase-backend.js +203 -0
- package/dist/store/backends/tinybase-backend.js.map +1 -0
- package/dist/store/backends/types.d.ts +175 -0
- package/dist/store/backends/types.d.ts.map +1 -0
- package/dist/store/backends/types.js +28 -0
- package/dist/store/backends/types.js.map +1 -0
- package/dist/store/event-store.d.ts +128 -0
- package/dist/store/event-store.d.ts.map +1 -0
- package/dist/store/event-store.js +1751 -0
- package/dist/store/event-store.js.map +1 -0
- package/dist/store/instance.d.ts +290 -0
- package/dist/store/instance.d.ts.map +1 -0
- package/dist/store/instance.js +363 -0
- package/dist/store/instance.js.map +1 -0
- package/dist/store/migrations.d.ts +41 -0
- package/dist/store/migrations.d.ts.map +1 -0
- package/dist/store/migrations.js +79 -0
- package/dist/store/migrations.js.map +1 -0
- package/dist/store/test-utils.d.ts +63 -0
- package/dist/store/test-utils.d.ts.map +1 -0
- package/dist/store/test-utils.js +63 -0
- package/dist/store/test-utils.js.map +1 -0
- package/dist/store/types/config.d.ts +16 -0
- package/dist/store/types/config.d.ts.map +1 -0
- package/dist/store/types/config.js +8 -0
- package/dist/store/types/config.js.map +1 -0
- package/dist/store/types/conversations.d.ts +91 -0
- package/dist/store/types/conversations.d.ts.map +1 -0
- package/dist/store/types/conversations.js +8 -0
- package/dist/store/types/conversations.js.map +1 -0
- package/dist/store/types/sessions.d.ts +44 -0
- package/dist/store/types/sessions.d.ts.map +1 -0
- package/dist/store/types/sessions.js +9 -0
- package/dist/store/types/sessions.js.map +1 -0
- package/dist/store/types.d.ts +115 -0
- package/dist/store/types.d.ts.map +1 -0
- package/dist/store/types.js +6 -0
- package/dist/store/types.js.map +1 -0
- package/dist/task/backend/index.d.ts +93 -0
- package/dist/task/backend/index.d.ts.map +1 -0
- package/dist/task/backend/index.js +178 -0
- package/dist/task/backend/index.js.map +1 -0
- package/dist/task/backend/memory.d.ts +70 -0
- package/dist/task/backend/memory.d.ts.map +1 -0
- package/dist/task/backend/memory.js +621 -0
- package/dist/task/backend/memory.js.map +1 -0
- package/dist/task/backend/opentasks/backend.d.ts +140 -0
- package/dist/task/backend/opentasks/backend.d.ts.map +1 -0
- package/dist/task/backend/opentasks/backend.js +1023 -0
- package/dist/task/backend/opentasks/backend.js.map +1 -0
- package/dist/task/backend/opentasks/client.d.ts +337 -0
- package/dist/task/backend/opentasks/client.d.ts.map +1 -0
- package/dist/task/backend/opentasks/client.js +225 -0
- package/dist/task/backend/opentasks/client.js.map +1 -0
- package/dist/task/backend/opentasks/daemon-manager.d.ts +89 -0
- package/dist/task/backend/opentasks/daemon-manager.d.ts.map +1 -0
- package/dist/task/backend/opentasks/daemon-manager.js +195 -0
- package/dist/task/backend/opentasks/daemon-manager.js.map +1 -0
- package/dist/task/backend/opentasks/index.d.ts +21 -0
- package/dist/task/backend/opentasks/index.d.ts.map +1 -0
- package/dist/task/backend/opentasks/index.js +21 -0
- package/dist/task/backend/opentasks/index.js.map +1 -0
- package/dist/task/backend/opentasks/mapping.d.ts +48 -0
- package/dist/task/backend/opentasks/mapping.d.ts.map +1 -0
- package/dist/task/backend/opentasks/mapping.js +77 -0
- package/dist/task/backend/opentasks/mapping.js.map +1 -0
- package/dist/task/backend/sudocode/__tests__/integration/test-utils.d.ts +54 -0
- package/dist/task/backend/sudocode/__tests__/integration/test-utils.d.ts.map +1 -0
- package/dist/task/backend/sudocode/__tests__/integration/test-utils.js +88 -0
- package/dist/task/backend/sudocode/__tests__/integration/test-utils.js.map +1 -0
- package/dist/task/backend/sudocode/backend.d.ts +155 -0
- package/dist/task/backend/sudocode/backend.d.ts.map +1 -0
- package/dist/task/backend/sudocode/backend.js +942 -0
- package/dist/task/backend/sudocode/backend.js.map +1 -0
- package/dist/task/backend/sudocode/client.d.ts +303 -0
- package/dist/task/backend/sudocode/client.d.ts.map +1 -0
- package/dist/task/backend/sudocode/client.js +101 -0
- package/dist/task/backend/sudocode/client.js.map +1 -0
- package/dist/task/backend/sudocode/index.d.ts +19 -0
- package/dist/task/backend/sudocode/index.d.ts.map +1 -0
- package/dist/task/backend/sudocode/index.js +17 -0
- package/dist/task/backend/sudocode/index.js.map +1 -0
- package/dist/task/backend/sudocode/mapping.d.ts +51 -0
- package/dist/task/backend/sudocode/mapping.d.ts.map +1 -0
- package/dist/task/backend/sudocode/mapping.js +86 -0
- package/dist/task/backend/sudocode/mapping.js.map +1 -0
- package/dist/task/backend/sudocode/server-client.d.ts +56 -0
- package/dist/task/backend/sudocode/server-client.d.ts.map +1 -0
- package/dist/task/backend/sudocode/server-client.js +367 -0
- package/dist/task/backend/sudocode/server-client.js.map +1 -0
- package/dist/task/backend/sudocode/standalone-client.d.ts +91 -0
- package/dist/task/backend/sudocode/standalone-client.d.ts.map +1 -0
- package/dist/task/backend/sudocode/standalone-client.js +476 -0
- package/dist/task/backend/sudocode/standalone-client.js.map +1 -0
- package/dist/task/backend/sudocode/sync-policy.d.ts +166 -0
- package/dist/task/backend/sudocode/sync-policy.d.ts.map +1 -0
- package/dist/task/backend/sudocode/sync-policy.js +221 -0
- package/dist/task/backend/sudocode/sync-policy.js.map +1 -0
- package/dist/task/backend/sudocode/tools.d.ts +87 -0
- package/dist/task/backend/sudocode/tools.d.ts.map +1 -0
- package/dist/task/backend/sudocode/tools.js +743 -0
- package/dist/task/backend/sudocode/tools.js.map +1 -0
- package/dist/task/backend/tool-provider.d.ts +56 -0
- package/dist/task/backend/tool-provider.d.ts.map +1 -0
- package/dist/task/backend/tool-provider.js +424 -0
- package/dist/task/backend/tool-provider.js.map +1 -0
- package/dist/task/backend/types.d.ts +297 -0
- package/dist/task/backend/types.d.ts.map +1 -0
- package/dist/task/backend/types.js +27 -0
- package/dist/task/backend/types.js.map +1 -0
- package/dist/task/backend/unified-tool-provider.d.ts +57 -0
- package/dist/task/backend/unified-tool-provider.d.ts.map +1 -0
- package/dist/task/backend/unified-tool-provider.js +623 -0
- package/dist/task/backend/unified-tool-provider.js.map +1 -0
- package/dist/task/index.d.ts +7 -0
- package/dist/task/index.d.ts.map +1 -0
- package/dist/task/index.js +7 -0
- package/dist/task/index.js.map +1 -0
- package/dist/task/retry-policy.d.ts +89 -0
- package/dist/task/retry-policy.d.ts.map +1 -0
- package/dist/task/retry-policy.js +160 -0
- package/dist/task/retry-policy.js.map +1 -0
- package/dist/task/task-manager.d.ts +70 -0
- package/dist/task/task-manager.d.ts.map +1 -0
- package/dist/task/task-manager.js +319 -0
- package/dist/task/task-manager.js.map +1 -0
- package/dist/task/types.d.ts +72 -0
- package/dist/task/types.d.ts.map +1 -0
- package/dist/task/types.js +33 -0
- package/dist/task/types.js.map +1 -0
- package/dist/teams/team-loader.d.ts +2 -1
- package/dist/teams/team-loader.d.ts.map +1 -1
- package/dist/teams/team-loader.js +2 -1
- package/dist/teams/team-loader.js.map +1 -1
- package/dist/teams/team-manager.d.ts +101 -0
- package/dist/teams/team-manager.d.ts.map +1 -0
- package/dist/teams/team-manager.js +260 -0
- package/dist/teams/team-manager.js.map +1 -0
- package/dist/teams/team-runtime-v2.d.ts +0 -3
- package/dist/teams/team-runtime-v2.d.ts.map +1 -1
- package/dist/teams/team-runtime-v2.js +8 -87
- package/dist/teams/team-runtime-v2.js.map +1 -1
- package/dist/teams/team-runtime.d.ts +245 -0
- package/dist/teams/team-runtime.d.ts.map +1 -0
- package/dist/teams/team-runtime.js +1023 -0
- package/dist/teams/team-runtime.js.map +1 -0
- package/dist/trigger/router/index.d.ts +11 -0
- package/dist/trigger/router/index.d.ts.map +1 -0
- package/dist/trigger/router/index.js +10 -0
- package/dist/trigger/router/index.js.map +1 -0
- package/dist/trigger/router/strategies/ai-router-strategy.d.ts +34 -0
- package/dist/trigger/router/strategies/ai-router-strategy.d.ts.map +1 -0
- package/dist/trigger/router/strategies/ai-router-strategy.js +359 -0
- package/dist/trigger/router/strategies/ai-router-strategy.js.map +1 -0
- package/dist/trigger/router/strategies/direct-strategy.d.ts +32 -0
- package/dist/trigger/router/strategies/direct-strategy.d.ts.map +1 -0
- package/dist/trigger/router/strategies/direct-strategy.js +119 -0
- package/dist/trigger/router/strategies/direct-strategy.js.map +1 -0
- package/dist/trigger/router/strategies/index.d.ts +11 -0
- package/dist/trigger/router/strategies/index.d.ts.map +1 -0
- package/dist/trigger/router/strategies/index.js +11 -0
- package/dist/trigger/router/strategies/index.js.map +1 -0
- package/dist/trigger/router/strategies/role-strategy.d.ts +39 -0
- package/dist/trigger/router/strategies/role-strategy.d.ts.map +1 -0
- package/dist/trigger/router/strategies/role-strategy.js +207 -0
- package/dist/trigger/router/strategies/role-strategy.js.map +1 -0
- package/dist/trigger/router/trigger-router.d.ts +54 -0
- package/dist/trigger/router/trigger-router.d.ts.map +1 -0
- package/dist/trigger/router/trigger-router.js +362 -0
- package/dist/trigger/router/trigger-router.js.map +1 -0
- package/dist/trigger/router/types.d.ts +225 -0
- package/dist/trigger/router/types.d.ts.map +1 -0
- package/dist/trigger/router/types.js +10 -0
- package/dist/trigger/router/types.js.map +1 -0
- package/dist/trigger/sources/cron/cron-service.d.ts.map +1 -1
- package/dist/trigger/sources/cron/cron-service.js +6 -3
- package/dist/trigger/sources/cron/cron-service.js.map +1 -1
- package/dist/trigger/trigger-system.d.ts +77 -0
- package/dist/trigger/trigger-system.d.ts.map +1 -0
- package/dist/trigger/trigger-system.js +84 -0
- package/dist/trigger/trigger-system.js.map +1 -0
- package/dist/util/git-safety.d.ts +33 -0
- package/dist/util/git-safety.d.ts.map +1 -0
- package/dist/util/git-safety.js +94 -0
- package/dist/util/git-safety.js.map +1 -0
- package/dist/workspace/dataplane-adapter.d.ts +260 -0
- package/dist/workspace/dataplane-adapter.d.ts.map +1 -0
- package/dist/workspace/dataplane-adapter.js +416 -0
- package/dist/workspace/dataplane-adapter.js.map +1 -0
- package/dist/workspace/index.d.ts +0 -1
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +0 -2
- package/dist/workspace/index.js.map +1 -1
- package/dist/workspace/landing/direct-push.d.ts.map +1 -1
- package/dist/workspace/landing/direct-push.js +22 -7
- package/dist/workspace/landing/direct-push.js.map +1 -1
- package/dist/workspace/landing/queue-to-branch.d.ts.map +1 -1
- package/dist/workspace/landing/queue-to-branch.js +1 -3
- package/dist/workspace/landing/queue-to-branch.js.map +1 -1
- package/dist/workspace/types.d.ts +0 -13
- package/dist/workspace/types.d.ts.map +1 -1
- package/dist/workspace/workspace-manager.d.ts +0 -11
- package/dist/workspace/workspace-manager.d.ts.map +1 -1
- package/dist/workspace/workspace-manager.js +0 -30
- package/dist/workspace/workspace-manager.js.map +1 -1
- package/package.json +28 -2
- package/templates/teams/self-driving/prompts/grinder.md +1 -0
- package/templates/teams/self-driving/prompts/judge.md +1 -0
- package/templates/teams/self-driving/prompts/planner.md +1 -0
- package/templates/teams/self-driving/roles/grinder.yaml +15 -0
- package/templates/teams/self-driving/roles/judge.yaml +10 -0
- package/templates/teams/self-driving/roles/planner.yaml +16 -0
- package/.claude/commands/openspec/apply.md +0 -23
- package/.claude/commands/openspec/archive.md +0 -27
- package/.claude/commands/openspec/proposal.md +0 -28
- package/.claude/settings.json +0 -133
- package/.gitattributes +0 -3
- package/.opentasks/config.json +0 -9
- package/.opentasks/graph.jsonl +0 -0
- package/.sessionlog/settings.json +0 -4
- package/.sudocode/issues.jsonl +0 -183
- package/.sudocode/specs.jsonl +0 -56
- package/AGENTS.md +0 -18
- package/CLAUDE.md +0 -923
- package/docs/architecture.md +0 -508
- package/docs/configuration.md +0 -323
- package/docs/conflict-recovery.md +0 -472
- package/docs/design/task-dispatcher.md +0 -880
- package/docs/design-subsystem-extraction.md +0 -627
- package/docs/git-cascade-integration-gaps.md +0 -678
- package/docs/implementation-details.md +0 -1127
- package/docs/implementation-summary.md +0 -448
- package/docs/lifecycle-events-design.md +0 -111
- package/docs/mail-integration.md +0 -608
- package/docs/openhive-capability-summary.md +0 -415
- package/docs/openhive-integration.md +0 -415
- package/docs/plan-self-driving-support.md +0 -433
- package/docs/roadmap-v2-gaps.md +0 -216
- package/docs/spec-self-driving-support.md +0 -462
- package/docs/team-templates.md +0 -860
- package/docs/teams.md +0 -306
- package/docs/trigger-system-design.md +0 -333
- package/docs/troubleshooting.md +0 -489
- package/docs/workspace-interfaces.md +0 -731
- package/docs/workspace-redesign-plan.md +0 -302
- package/examples/distributed-peer-communication.ts +0 -202
- package/examples/local-peer-communication.ts +0 -165
- package/index.js +0 -2
- package/mvp_docs/agent-execution-system.md +0 -347
- package/mvp_docs/agent-interface.md +0 -580
- package/mvp_docs/data-structures.md +0 -701
- package/mvp_docs/dynamic-meta-orchestration.md +0 -116
- package/mvp_docs/multi-agent-interaction-design.md +0 -779
- package/mvp_docs/mvp-implementation-plan.md +0 -1148
- package/renovate.json5 +0 -6
- package/scripts/test-acp-integration.ts +0 -422
- package/src/__tests__/boot-v2.test.ts +0 -631
- package/src/__tests__/e2e/acp-over-map-live.e2e.test.ts +0 -496
- package/src/__tests__/e2e/acp-over-map.e2e.test.ts +0 -457
- package/src/__tests__/e2e/agent-lifecycle.e2e.test.ts +0 -770
- package/src/__tests__/e2e/auto-sync.e2e.test.ts +0 -257
- package/src/__tests__/e2e/bootstrap.e2e.test.ts +0 -319
- package/src/__tests__/e2e/cascade-rebase.e2e.test.ts +0 -254
- package/src/__tests__/e2e/cc-swarm-bridge.e2e.test.ts +0 -253
- package/src/__tests__/e2e/cli-run.e2e.test.ts +0 -167
- package/src/__tests__/e2e/cognitive-workspace.e2e.test.ts +0 -282
- package/src/__tests__/e2e/dispatch-coordination.e2e.test.ts +0 -495
- package/src/__tests__/e2e/dispatch-live.e2e.test.ts +0 -564
- package/src/__tests__/e2e/dispatch-opentasks.e2e.test.ts +0 -496
- package/src/__tests__/e2e/dispatch-phase2-live.e2e.test.ts +0 -456
- package/src/__tests__/e2e/dispatch-phase2.e2e.test.ts +0 -386
- package/src/__tests__/e2e/dispatch.e2e.test.ts +0 -376
- package/src/__tests__/e2e/done-scenarios.e2e.test.ts +0 -322
- package/src/__tests__/e2e/live-agent.e2e.test.ts +0 -1330
- package/src/__tests__/e2e/map-server.e2e.test.ts +0 -128
- package/src/__tests__/e2e/map-sidecar.e2e.test.ts +0 -139
- package/src/__tests__/e2e/opentasks-integration.e2e.test.ts +0 -280
- package/src/__tests__/e2e/pull-mode.e2e.test.ts +0 -632
- package/src/__tests__/e2e/resume-continue.e2e.test.ts +0 -312
- package/src/__tests__/e2e/self-driving-v3.e2e.test.ts +0 -197
- package/src/__tests__/e2e/spawn-resolver.e2e.test.ts +0 -200
- package/src/__tests__/e2e/swarmkit-integration.e2e.test.ts +0 -562
- package/src/__tests__/e2e/swarmkit-live.e2e.test.ts +0 -1049
- package/src/__tests__/e2e/trajectory-tracking.e2e.test.ts +0 -258
- package/src/__tests__/e2e/trigger-wake.e2e.test.ts +0 -257
- package/src/__tests__/e2e/workspace-lifecycle.e2e.test.ts +0 -383
- package/src/__tests__/e2e/workspace-v3.e2e.test.ts +0 -413
- package/src/acp/__tests__/claude-code-replay.test.ts +0 -225
- package/src/acp/__tests__/macro-agent.test.ts +0 -387
- package/src/acp/__tests__/session-mapper.test.ts +0 -152
- package/src/acp/__tests__/websocket-server.test.ts +0 -194
- package/src/acp/claude-code-replay.ts +0 -208
- package/src/acp/index.ts +0 -32
- package/src/acp/macro-agent.ts +0 -995
- package/src/acp/map-bridge.ts +0 -193
- package/src/acp/session-mapper.ts +0 -116
- package/src/acp/types.ts +0 -99
- package/src/acp/websocket-server.ts +0 -213
- package/src/adapters/__tests__/federation.test.ts +0 -256
- package/src/adapters/__tests__/inbox-adapter.test.ts +0 -316
- package/src/adapters/__tests__/tasks-adapter.test.ts +0 -270
- package/src/adapters/federation.ts +0 -185
- package/src/adapters/inbox-adapter.ts +0 -292
- package/src/adapters/inbox-client-adapter.ts +0 -173
- package/src/adapters/index.ts +0 -44
- package/src/adapters/opentasks-daemon.ts +0 -252
- package/src/adapters/tasks-adapter.ts +0 -330
- package/src/adapters/types.ts +0 -286
- package/src/agent/__tests__/agent-manager-topology.test.ts +0 -73
- package/src/agent/__tests__/agent-manager-v2.completion-signal.test.ts +0 -284
- package/src/agent/__tests__/agent-manager-v2.permission-interception.test.ts +0 -296
- package/src/agent/__tests__/agent-manager-v2.permissions.test.ts +0 -233
- package/src/agent/__tests__/agent-manager-v2.test.ts +0 -614
- package/src/agent/__tests__/agent-store.test.ts +0 -465
- package/src/agent/__tests__/task-ref-resolution.test.ts +0 -231
- package/src/agent/agent-manager-v2.ts +0 -2187
- package/src/agent/agent-manager.ts +0 -403
- package/src/agent/agent-store.ts +0 -409
- package/src/agent/index.ts +0 -7
- package/src/agent/prompts/coordinator-signals.ts +0 -115
- package/src/agent/prompts/index.ts +0 -7
- package/src/agent/system-prompt.ts +0 -298
- package/src/agent/types.ts +0 -480
- package/src/agent-detection/__tests__/command-builder.test.ts +0 -336
- package/src/agent-detection/__tests__/detector.test.ts +0 -768
- package/src/agent-detection/__tests__/registry.test.ts +0 -254
- package/src/agent-detection/command-builder.ts +0 -90
- package/src/agent-detection/detector.ts +0 -307
- package/src/agent-detection/index.ts +0 -36
- package/src/agent-detection/registry.ts +0 -200
- package/src/agent-detection/types.ts +0 -184
- package/src/api/__tests__/server.test.ts +0 -292
- package/src/api/index.ts +0 -8
- package/src/api/server.ts +0 -380
- package/src/api/types.ts +0 -39
- package/src/auth/__tests__/token.test.ts +0 -100
- package/src/auth/index.ts +0 -1
- package/src/auth/token.ts +0 -82
- package/src/boot-v2.ts +0 -1343
- package/src/cli/__tests__/stable-instance-id.test.ts +0 -57
- package/src/cli/acp.ts +0 -101
- package/src/cli/inbox-mcp-proxy.ts +0 -56
- package/src/cli/index.ts +0 -566
- package/src/cli/mcp.ts +0 -305
- package/src/cli/parse-args.ts +0 -54
- package/src/cli/stable-instance-id.ts +0 -14
- package/src/cognitive/__tests__/macro-agent-backend.test.ts +0 -673
- package/src/cognitive/__tests__/session-converter.test.ts +0 -423
- package/src/cognitive/__tests__/workspace-handler.test.ts +0 -221
- package/src/cognitive/analyst-role.ts +0 -59
- package/src/cognitive/index.ts +0 -49
- package/src/cognitive/macro-agent-backend.ts +0 -402
- package/src/cognitive/session-converter.ts +0 -151
- package/src/cognitive/types.ts +0 -187
- package/src/cognitive/workspace-handler.ts +0 -163
- package/src/config/index.ts +0 -9
- package/src/config/project-config.ts +0 -294
- package/src/control/__tests__/control-resilience.test.ts +0 -251
- package/src/control/__tests__/control-socket.test.ts +0 -240
- package/src/control/control-client.ts +0 -337
- package/src/control/control-server.ts +0 -298
- package/src/control/index.ts +0 -17
- package/src/control/types.ts +0 -95
- package/src/dispatch/CLAUDE.md +0 -129
- package/src/dispatch/__tests__/loadout-translation.test.ts +0 -141
- package/src/dispatch/__tests__/mail-inbound-consumer.integration.test.ts +0 -519
- package/src/dispatch/__tests__/mail-inbound-consumer.test.ts +0 -800
- package/src/dispatch/__tests__/mail-inbound-reuse-consumer.test.ts +0 -575
- package/src/dispatch/__tests__/permission-evaluator.test.ts +0 -196
- package/src/dispatch/__tests__/permission-overlay.test.ts +0 -56
- package/src/dispatch/__tests__/permissions-handler.test.ts +0 -168
- package/src/dispatch/__tests__/spawn-agent-handler.test.ts +0 -282
- package/src/dispatch/loadout-translation.ts +0 -138
- package/src/dispatch/mail-inbound-consumer.ts +0 -560
- package/src/dispatch/mail-inbound-reuse-consumer.ts +0 -479
- package/src/dispatch/permission-evaluator.ts +0 -191
- package/src/dispatch/permission-overlay.ts +0 -89
- package/src/dispatch/permissions-handler.ts +0 -112
- package/src/dispatch/spawn-agent-handler.ts +0 -160
- package/src/index.ts +0 -117
- package/src/integrations/__tests__/context-builder.test.ts +0 -218
- package/src/integrations/__tests__/sessionlog.test.ts +0 -498
- package/src/integrations/__tests__/skilltree.test.ts +0 -136
- package/src/integrations/context-builder.ts +0 -280
- package/src/integrations/sessionlog.ts +0 -194
- package/src/integrations/skilltree.ts +0 -184
- package/src/lifecycle/__tests__/cascade-consolidation.test.ts +0 -240
- package/src/lifecycle/__tests__/handlers-v2.test.ts +0 -565
- package/src/lifecycle/cascade.ts +0 -335
- package/src/lifecycle/cleanup.ts +0 -373
- package/src/lifecycle/handlers-v2.ts +0 -508
- package/src/lifecycle/index.ts +0 -76
- package/src/lifecycle/types.ts +0 -260
- package/src/map/__tests__/cascade-bridge.test.ts +0 -229
- package/src/map/__tests__/cascade-diff-server.test.ts +0 -434
- package/src/map/__tests__/emit-event.test.ts +0 -71
- package/src/map/__tests__/lifecycle-bridge.test.ts +0 -430
- package/src/map/__tests__/mail-bridge.test.ts +0 -321
- package/src/map/__tests__/permission-forwarding.test.ts +0 -143
- package/src/map/__tests__/sidecar-diff-install-smoke.test.ts +0 -90
- package/src/map/__tests__/sidecar-integration.test.ts +0 -190
- package/src/map/__tests__/task-bridge.test.ts +0 -153
- package/src/map/__tests__/trajectory-reporter.test.ts +0 -173
- package/src/map/acp-bridge.ts +0 -293
- package/src/map/cascade-action-handler.ts +0 -205
- package/src/map/cascade-bridge.ts +0 -339
- package/src/map/cascade-diff-server.ts +0 -404
- package/src/map/cc-swarm-hooks.ts +0 -242
- package/src/map/coordination-handler.ts +0 -232
- package/src/map/index.ts +0 -18
- package/src/map/lifecycle-bridge.ts +0 -236
- package/src/map/mail-bridge.ts +0 -263
- package/src/map/repo-workspace.ts +0 -82
- package/src/map/server.ts +0 -758
- package/src/map/sidecar.ts +0 -826
- package/src/map/task-bridge.ts +0 -89
- package/src/map/trajectory-reporter.ts +0 -124
- package/src/map/types.ts +0 -304
- package/src/mcp/__tests__/mcp-server-v2.test.ts +0 -236
- package/src/mcp/index.ts +0 -6
- package/src/mcp/mcp-server-v2.ts +0 -485
- package/src/mcp/tools/done-v2.ts +0 -213
- package/src/mcp/types.ts +0 -432
- package/src/metrics/__tests__/metrics.test.ts +0 -205
- package/src/metrics/index.ts +0 -13
- package/src/metrics/metrics.ts +0 -151
- package/src/metrics/types.ts +0 -63
- package/src/roles/__tests__/config-loader.test.ts +0 -540
- package/src/roles/builtin/coordinator.ts +0 -75
- package/src/roles/builtin/generic.ts +0 -39
- package/src/roles/builtin/index.ts +0 -51
- package/src/roles/builtin/integrator.ts +0 -62
- package/src/roles/builtin/monitor.ts +0 -65
- package/src/roles/builtin/worker.ts +0 -134
- package/src/roles/capabilities.ts +0 -257
- package/src/roles/config-loader.ts +0 -405
- package/src/roles/index.ts +0 -141
- package/src/roles/registry.ts +0 -713
- package/src/roles/types.ts +0 -344
- package/src/store/index.ts +0 -8
- package/src/store/types/agents.ts +0 -69
- package/src/store/types/events.ts +0 -91
- package/src/store/types/index.ts +0 -9
- package/src/store/types/messages.ts +0 -32
- package/src/store/types/primitives.ts +0 -9
- package/src/store/types/tasks.ts +0 -124
- package/src/teams/__tests__/team-manager-v2.test.ts +0 -425
- package/src/teams/__tests__/team-runtime-v2.test.ts +0 -402
- package/src/teams/index.ts +0 -29
- package/src/teams/seed-defaults.ts +0 -83
- package/src/teams/team-loader.ts +0 -476
- package/src/teams/team-manager-v2.ts +0 -343
- package/src/teams/team-runtime-v2.ts +0 -943
- package/src/teams/types.ts +0 -276
- package/src/trigger/__tests__/cron-service.test.ts +0 -548
- package/src/trigger/__tests__/scheduler.test.ts +0 -371
- package/src/trigger/__tests__/system-event-queue.test.ts +0 -147
- package/src/trigger/__tests__/trigger-system-v2.test.ts +0 -257
- package/src/trigger/__tests__/wake-manager.test.ts +0 -356
- package/src/trigger/__tests__/webhook-handler.test.ts +0 -567
- package/src/trigger/index.ts +0 -110
- package/src/trigger/queue/index.ts +0 -21
- package/src/trigger/queue/system-event-queue.ts +0 -232
- package/src/trigger/queue/types.ts +0 -149
- package/src/trigger/sources/cron/cron-service.ts +0 -499
- package/src/trigger/sources/cron/index.ts +0 -41
- package/src/trigger/sources/cron/scheduler.ts +0 -344
- package/src/trigger/sources/cron/types.ts +0 -333
- package/src/trigger/sources/index.ts +0 -10
- package/src/trigger/sources/webhook/index.ts +0 -25
- package/src/trigger/sources/webhook/types.ts +0 -205
- package/src/trigger/sources/webhook/webhook-handler.ts +0 -410
- package/src/trigger/strategies/ai-router.ts +0 -170
- package/src/trigger/trigger-system-v2.ts +0 -536
- package/src/trigger/types.ts +0 -228
- package/src/trigger/wake/index.ts +0 -22
- package/src/trigger/wake/types.ts +0 -162
- package/src/trigger/wake/wake-manager.ts +0 -390
- package/src/workspace/__tests__/git-cascade-adapter.test.ts +0 -563
- package/src/workspace/__tests__/land-dispatch.test.ts +0 -214
- package/src/workspace/__tests__/self-driving-yaml.test.ts +0 -122
- package/src/workspace/__tests__/shared-worktree-refcount.test.ts +0 -154
- package/src/workspace/__tests__/standalone-mode.test.ts +0 -118
- package/src/workspace/__tests__/workspace-manager-v3.test.ts +0 -245
- package/src/workspace/__tests__/yaml-schema.test.ts +0 -210
- package/src/workspace/config.ts +0 -165
- package/src/workspace/git-cascade-adapter.ts +0 -1213
- package/src/workspace/index.ts +0 -110
- package/src/workspace/landing/__tests__/strategies.test.ts +0 -184
- package/src/workspace/landing/direct-push.ts +0 -91
- package/src/workspace/landing/index.ts +0 -40
- package/src/workspace/landing/merge-to-parent.ts +0 -229
- package/src/workspace/landing/optimistic-push.ts +0 -36
- package/src/workspace/landing/queue-to-branch.ts +0 -108
- package/src/workspace/merge-queue/__tests__/conflict-resolution-git.e2e.test.ts +0 -641
- package/src/workspace/merge-queue/__tests__/conflict-resolution.test.ts +0 -707
- package/src/workspace/merge-queue/__tests__/merge-queue-concurrent.test.ts +0 -628
- package/src/workspace/merge-queue/__tests__/merge-queue-edge-cases.test.ts +0 -1217
- package/src/workspace/merge-queue/__tests__/merge-queue.test.ts +0 -506
- package/src/workspace/merge-queue/__tests__/real-git-operations.e2e.test.ts +0 -556
- package/src/workspace/merge-queue/__tests__/resolver-flow.test.ts +0 -472
- package/src/workspace/merge-queue/index.ts +0 -38
- package/src/workspace/merge-queue/merge-queue.ts +0 -585
- package/src/workspace/merge-queue/schema.ts +0 -98
- package/src/workspace/merge-queue/types.ts +0 -316
- package/src/workspace/pool/__tests__/worktree-pool.integration.test.ts +0 -1281
- package/src/workspace/pool/__tests__/worktree-pool.test.ts +0 -590
- package/src/workspace/pool/index.ts +0 -26
- package/src/workspace/pool/types.ts +0 -276
- package/src/workspace/pool/worktree-pool.ts +0 -659
- package/src/workspace/recovery/__tests__/auto-resolve-integration.test.ts +0 -127
- package/src/workspace/recovery/__tests__/spawn-resolver.test.ts +0 -139
- package/src/workspace/recovery/__tests__/strategies.test.ts +0 -145
- package/src/workspace/recovery/abandon.ts +0 -51
- package/src/workspace/recovery/auto-resolve.ts +0 -119
- package/src/workspace/recovery/defer.ts +0 -23
- package/src/workspace/recovery/escalate.ts +0 -30
- package/src/workspace/recovery/index.ts +0 -58
- package/src/workspace/recovery/spawn-resolver.ts +0 -152
- package/src/workspace/recovery/types.ts +0 -54
- package/src/workspace/strategies/index.ts +0 -18
- package/src/workspace/strategies/optimistic.ts +0 -139
- package/src/workspace/strategies/queue.ts +0 -81
- package/src/workspace/strategies/registry.ts +0 -89
- package/src/workspace/strategies/trunk.ts +0 -123
- package/src/workspace/strategies/types.ts +0 -145
- package/src/workspace/topology/__tests__/yaml-driven.test.ts +0 -345
- package/src/workspace/topology/index.ts +0 -18
- package/src/workspace/topology/no-workspace.ts +0 -39
- package/src/workspace/topology/types.ts +0 -116
- package/src/workspace/topology/yaml-driven.ts +0 -316
- package/src/workspace/types-v3.ts +0 -162
- package/src/workspace/types.ts +0 -541
- package/src/workspace/workspace-manager.ts +0 -1577
- package/src/workspace/yaml-schema.ts +0 -216
- package/test_fixtures/README.md +0 -425
- package/test_fixtures/fixtures/behaviors/coordinators.ts +0 -196
- package/test_fixtures/fixtures/behaviors/index.ts +0 -62
- package/test_fixtures/fixtures/behaviors/integrators.ts +0 -143
- package/test_fixtures/fixtures/behaviors/monitors.ts +0 -199
- package/test_fixtures/fixtures/behaviors/workers.ts +0 -348
- package/test_fixtures/fixtures/index.ts +0 -7
- package/test_fixtures/fixtures/projects/index.ts +0 -23
- package/test_fixtures/fixtures/projects/project-with-specs.ts +0 -44
- package/test_fixtures/fixtures/projects/typescript-project.ts +0 -200
- package/test_fixtures/fixtures/repos/index.ts +0 -6
- package/test_fixtures/fixtures/repos/temp-repo-factory.ts +0 -299
- package/test_fixtures/fixtures/repos/types.ts +0 -174
- package/test_fixtures/harness/assertions/harness-assertions.ts +0 -752
- package/test_fixtures/harness/assertions/index.ts +0 -8
- package/test_fixtures/harness/index.ts +0 -15
- package/test_fixtures/harness/simulator/agent-simulator.ts +0 -768
- package/test_fixtures/harness/simulator/behavior-executor.ts +0 -580
- package/test_fixtures/harness/simulator/index.ts +0 -14
- package/test_fixtures/harness/simulator/types.ts +0 -459
- package/test_fixtures/harness/test-harness.ts +0 -770
- package/test_fixtures/harness/timing/event-stepper.ts +0 -344
- package/test_fixtures/harness/timing/index.ts +0 -8
- package/tsconfig.json +0 -21
- package/vitest.config.ts +0 -30
- package/vitest.e2e.config.ts +0 -28
- package/vitest.setup.ts +0 -12
package/src/boot-v2.ts
DELETED
|
@@ -1,1343 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Boot V2 — Wires all V2 components into a running macro-agent system.
|
|
3
|
-
*
|
|
4
|
-
* This is the single entry point for the restructured architecture:
|
|
5
|
-
* - AgentStore for lifecycle state
|
|
6
|
-
* - InboxAdapter (embedded agent-inbox) for messaging
|
|
7
|
-
* - TasksAdapter (opentasks client) for task management
|
|
8
|
-
* - AgentManagerV2 for agent lifecycle
|
|
9
|
-
* - TeamRuntimeV2 for team topology
|
|
10
|
-
* - TriggerSystemV2 for wake/cron/webhooks
|
|
11
|
-
* - ControlServer for MCP subprocess lifecycle RPC
|
|
12
|
-
* - MCPServerV2 for per-agent tools
|
|
13
|
-
*
|
|
14
|
-
* Usage:
|
|
15
|
-
* const system = await bootV2({ cwd: process.cwd() });
|
|
16
|
-
* // system.agentManager, system.inboxAdapter, etc.
|
|
17
|
-
* await system.shutdown();
|
|
18
|
-
*
|
|
19
|
-
* @module boot-v2
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
import * as path from "path";
|
|
23
|
-
import * as os from "os";
|
|
24
|
-
import * as fs from "fs";
|
|
25
|
-
import * as crypto from "crypto";
|
|
26
|
-
import { AgentStore } from "./agent/agent-store.js";
|
|
27
|
-
import {
|
|
28
|
-
DefaultInboxAdapter,
|
|
29
|
-
type InboxAdapterConfig,
|
|
30
|
-
} from "./adapters/inbox-adapter.js";
|
|
31
|
-
import {
|
|
32
|
-
DefaultTasksAdapter,
|
|
33
|
-
type TasksAdapterConfig,
|
|
34
|
-
} from "./adapters/tasks-adapter.js";
|
|
35
|
-
import { createAgentManagerV2 } from "./agent/agent-manager-v2.js";
|
|
36
|
-
import { createTriggerSystemV2 } from "./trigger/trigger-system-v2.js";
|
|
37
|
-
import { ControlServer } from "./control/control-server.js";
|
|
38
|
-
import type { AgentManager } from "./agent/agent-manager.js";
|
|
39
|
-
import type { InboxAdapter, TasksAdapter } from "./adapters/types.js";
|
|
40
|
-
import type { TriggerSystemV2 } from "./trigger/trigger-system-v2.js";
|
|
41
|
-
import type { RoleRegistry } from "./roles/types.js";
|
|
42
|
-
import { DefaultRoleRegistry } from "./roles/registry.js";
|
|
43
|
-
import type { WorkspaceManager } from "./workspace/types.js";
|
|
44
|
-
import type { PermissionMode } from "acp-factory";
|
|
45
|
-
import type { ApiServer } from "./api/types.js";
|
|
46
|
-
import type { WebSocketACPServer } from "./acp/websocket-server.js";
|
|
47
|
-
|
|
48
|
-
// =============================================================================
|
|
49
|
-
// Configuration
|
|
50
|
-
// =============================================================================
|
|
51
|
-
|
|
52
|
-
export interface BootV2Config {
|
|
53
|
-
/** Working directory (default: process.cwd()) */
|
|
54
|
-
cwd?: string;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Stable identifier for this macro-agent run. Controls the default on-disk
|
|
58
|
-
* layout at `~/.macro-agent/<instanceId>/` (agents.db, inbox.db, sockets).
|
|
59
|
-
*
|
|
60
|
-
* Precedence when choosing an id:
|
|
61
|
-
* 1. explicit `instanceId` (this field)
|
|
62
|
-
* 2. `map.swarmId` (the MAP identity, when provided)
|
|
63
|
-
* 3. `inst_<sha256(cwd)[:12]>` (stable per-project fallback)
|
|
64
|
-
*
|
|
65
|
-
* Explicit `baseDir` overrides all of the above. Hosts that manage their
|
|
66
|
-
* own storage layout (openswarm spawns hosted swarms with a unique
|
|
67
|
-
* per-spawn data dir) still win by setting `baseDir` directly.
|
|
68
|
-
*/
|
|
69
|
-
instanceId?: string;
|
|
70
|
-
|
|
71
|
-
/** Base directory for data storage. Default: `~/.macro-agent/<instanceId>/` */
|
|
72
|
-
baseDir?: string;
|
|
73
|
-
|
|
74
|
-
/** Default permission mode for spawned agents */
|
|
75
|
-
defaultPermissionMode?: PermissionMode;
|
|
76
|
-
|
|
77
|
-
/** Default agent type (default: "claude-code") */
|
|
78
|
-
defaultAgentType?: string;
|
|
79
|
-
|
|
80
|
-
/** Role registry (default: DefaultRoleRegistry with built-in roles) */
|
|
81
|
-
roleRegistry?: RoleRegistry;
|
|
82
|
-
|
|
83
|
-
/** Workspace manager for git worktree isolation */
|
|
84
|
-
workspaceManager?: WorkspaceManager;
|
|
85
|
-
|
|
86
|
-
/** Inbox adapter config overrides */
|
|
87
|
-
inbox?: Partial<InboxAdapterConfig>;
|
|
88
|
-
|
|
89
|
-
/** Tasks adapter config overrides */
|
|
90
|
-
tasks?: Partial<TasksAdapterConfig>;
|
|
91
|
-
|
|
92
|
-
/** Trigger system config */
|
|
93
|
-
trigger?: {
|
|
94
|
-
enableHeartbeat?: boolean;
|
|
95
|
-
heartbeatIntervalMs?: number;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
/** Server URL for MCP thin-client mode */
|
|
99
|
-
serverUrl?: string;
|
|
100
|
-
|
|
101
|
-
/** Server token for thin-client auth */
|
|
102
|
-
serverToken?: string;
|
|
103
|
-
|
|
104
|
-
/** REST API server config */
|
|
105
|
-
api?: { enabled?: boolean; port?: number; host?: string };
|
|
106
|
-
|
|
107
|
-
/** ACP WebSocket server config */
|
|
108
|
-
acp?: { enabled?: boolean; port?: number; host?: string; path?: string };
|
|
109
|
-
|
|
110
|
-
/** Federation config for cross-instance communication */
|
|
111
|
-
federation?: {
|
|
112
|
-
systemId: string;
|
|
113
|
-
peers?: Array<{ systemId: string; url?: string; meshPeerId?: string }>;
|
|
114
|
-
trust?: { allowedSystems?: string[] };
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
/** MAP server config (accept inbound connections from TUI/clients) */
|
|
118
|
-
mapServer?: {
|
|
119
|
-
enabled?: boolean;
|
|
120
|
-
port?: number;
|
|
121
|
-
host?: string;
|
|
122
|
-
path?: string;
|
|
123
|
-
name?: string;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
/** MAP sidecar config (connect to OpenHive hub) */
|
|
127
|
-
map?: {
|
|
128
|
-
enabled?: boolean;
|
|
129
|
-
server?: string;
|
|
130
|
-
token?: string;
|
|
131
|
-
scope?: string;
|
|
132
|
-
systemId?: string;
|
|
133
|
-
credential?: string;
|
|
134
|
-
agentName?: string;
|
|
135
|
-
swarmId?: string;
|
|
136
|
-
trajectorySyncLevel?: "off" | "lifecycle" | "metrics" | "full";
|
|
137
|
-
reconnectIntervalMs?: number;
|
|
138
|
-
reconnection?: {
|
|
139
|
-
enabled?: boolean;
|
|
140
|
-
maxRetries?: number;
|
|
141
|
-
baseDelayMs?: number;
|
|
142
|
-
maxDelayMs?: number;
|
|
143
|
-
};
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Cascade event binding config. Controls how cascade events emitted by
|
|
148
|
-
* git-cascade-backed agents get tagged with external task references for
|
|
149
|
-
* hub projection (changelog, task↔stream binding). Independent of MAP
|
|
150
|
-
* transport: cascade events are data/identity, not transport.
|
|
151
|
-
*/
|
|
152
|
-
cascade?: {
|
|
153
|
-
/**
|
|
154
|
-
* Default OpenTasks resource ID for this swarm. When set, the agent
|
|
155
|
-
* manager auto-builds `taskRef = { resource_id, node_id: task_id }`
|
|
156
|
-
* for spawned agents so cascade events carry the binding without
|
|
157
|
-
* callers constructing refs by hand.
|
|
158
|
-
*
|
|
159
|
-
* Leave undefined if:
|
|
160
|
-
* - The swarm touches multiple opentasks graphs (use `resolveTaskRef`).
|
|
161
|
-
* - Every caller sets `SpawnAgentOptions.taskRef` explicitly.
|
|
162
|
-
* - You don't care about hub task↔stream binding.
|
|
163
|
-
*/
|
|
164
|
-
taskResourceId?: string;
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Custom resolver for multi-graph deployments. Called at every spawn;
|
|
168
|
-
* return a `TaskRef` to set the binding or `undefined` to skip.
|
|
169
|
-
* Precedence: explicit `SpawnAgentOptions.taskRef` > `resolveTaskRef` >
|
|
170
|
-
* `taskResourceId` fallback (combined with `spawnOptions.task_id`).
|
|
171
|
-
*
|
|
172
|
-
* Keep implementations cheap — this runs on every spawn.
|
|
173
|
-
*
|
|
174
|
-
* @example
|
|
175
|
-
* resolveTaskRef: (opts) => {
|
|
176
|
-
* const graph = graphForCwd(opts.cwd ?? process.cwd());
|
|
177
|
-
* return graph ? { resource_id: graph.resourceId, node_id: String(opts.task_id) } : undefined;
|
|
178
|
-
* }
|
|
179
|
-
*/
|
|
180
|
-
resolveTaskRef?: (
|
|
181
|
-
spawnOptions: import("./agent/types.js").SpawnAgentOptions,
|
|
182
|
-
) => import("git-cascade/events").TaskRef | undefined;
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Override the default `x-cascade` event prefix. Useful for branded
|
|
186
|
-
* deployments or isolating cascade namespaces in testing. Affects all
|
|
187
|
-
* events emitted by the tracker embedded in this swarm.
|
|
188
|
-
*/
|
|
189
|
-
eventPrefix?: string;
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
/** minimem (agent memory) — registers as MCP server for all agents */
|
|
193
|
-
minimem?: {
|
|
194
|
-
enabled?: boolean;
|
|
195
|
-
dir?: string; // default: ".swarm/minimem/"
|
|
196
|
-
provider?: string; // "auto" | "openai" | "gemini" | "local"
|
|
197
|
-
global?: boolean; // also search ~/.minimem
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
/** skill-tree (per-role skills) — compiles loadouts at team start, injects into prompts */
|
|
201
|
-
skilltree?: {
|
|
202
|
-
enabled?: boolean;
|
|
203
|
-
basePath?: string; // default: ".swarm/skill-tree/"
|
|
204
|
-
defaultProfile?: string;
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
/** sessionlog — enriches trajectory checkpoints with session state data */
|
|
208
|
-
sessionlog?: {
|
|
209
|
-
enabled?: boolean;
|
|
210
|
-
sync?: "off" | "lifecycle" | "metrics" | "full";
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
/** agentic-mesh — P2P encrypted transport for MAP sidecar */
|
|
214
|
-
mesh?: {
|
|
215
|
-
enabled?: boolean;
|
|
216
|
-
peerId?: string;
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
/** Task dispatch config — opt-in autonomous task dispatch mode */
|
|
220
|
-
dispatch?: {
|
|
221
|
-
enabled?: boolean;
|
|
222
|
-
pollIntervalMs?: number;
|
|
223
|
-
maxConcurrent?: number;
|
|
224
|
-
defaultRole?: string;
|
|
225
|
-
tags?: string[];
|
|
226
|
-
maxRetries?: number;
|
|
227
|
-
retryBaseDelayMs?: number;
|
|
228
|
-
retryMaxDelayMs?: number;
|
|
229
|
-
reconcile?: {
|
|
230
|
-
enabled?: boolean;
|
|
231
|
-
intervalMs?: number;
|
|
232
|
-
stallTimeoutMs?: number;
|
|
233
|
-
};
|
|
234
|
-
eligibility?: import("swarm-dispatch").EligibilityConfig;
|
|
235
|
-
/** Dispatch mode: route-only, spawn-only, prefer-route, prefer-spawn. Default: prefer-route when inbox available, spawn-only otherwise. */
|
|
236
|
-
dispatchMode?: import("swarm-dispatch").DispatchMode;
|
|
237
|
-
/** Enable mail-based work routing via agent-inbox (default: true when dispatch enabled). */
|
|
238
|
-
enableMailRouting?: boolean;
|
|
239
|
-
/** Enable roster-based agent discovery for route-first dispatch (default: true when dispatch enabled). */
|
|
240
|
-
enableRoster?: boolean;
|
|
241
|
-
/** Continuation config. */
|
|
242
|
-
continuation?: { delayMs?: number; maxTurns?: number };
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Boot-time agents to spawn after AgentManager is ready.
|
|
247
|
-
*
|
|
248
|
-
* Currently supports `coordinator` — when set, fires a non-blocking
|
|
249
|
-
* `agentManager.spawn({ role: 'coordinator', parent: null, cwd, ... })`
|
|
250
|
-
* during boot so the swarm has a default head manager ready for chat
|
|
251
|
-
* without an explicit spawn call. Pass `true` for defaults (uses the
|
|
252
|
-
* boot config's cwd) or an object for fine control.
|
|
253
|
-
*
|
|
254
|
-
* Also driven by env var `MACRO_BOOTSTRAP_COORDINATOR=true` (with
|
|
255
|
-
* optional `MACRO_BOOTSTRAP_CWD=<path>`) when this field is unset —
|
|
256
|
-
* lets indirect callers (e.g. openswarm host) opt in without modifying
|
|
257
|
-
* the bootConfig pass-through whitelist.
|
|
258
|
-
*/
|
|
259
|
-
bootstrap?: {
|
|
260
|
-
coordinator?: boolean | {
|
|
261
|
-
cwd?: string;
|
|
262
|
-
permissionMode?: PermissionMode;
|
|
263
|
-
agentType?: string;
|
|
264
|
-
customPrompt?: string;
|
|
265
|
-
task?: string;
|
|
266
|
-
/**
|
|
267
|
-
* When true, spawn the bootstrap coordinator with
|
|
268
|
-
* `askForAllTools: true` and `permissionMode: 'interactive'` so the
|
|
269
|
-
* Claude SDK consults `canUseTool` for every tool call and
|
|
270
|
-
* acp-factory emits the resulting requests as `permission_request`
|
|
271
|
-
* session updates. This is the prerequisite for ACP+reuse dispatch
|
|
272
|
-
* to actually enforce per-dispatch loadout deny rules via the
|
|
273
|
-
* runtime overlay registry — the prompt iterator can only deny
|
|
274
|
-
* tools the SDK asks about.
|
|
275
|
-
*
|
|
276
|
-
* Trade-off: every tool call roundtrips through the host (~1-5ms
|
|
277
|
-
* latency penalty per call). Acceptable for autonomous dispatch
|
|
278
|
-
* targets; would be heavy for high-frequency interactive chat.
|
|
279
|
-
*
|
|
280
|
-
* Defaults to false (preserves the existing chat-friendly mode).
|
|
281
|
-
*/
|
|
282
|
-
dispatchTarget?: boolean;
|
|
283
|
-
};
|
|
284
|
-
/**
|
|
285
|
-
* Optional parented worker spawn after the bootstrap coordinator
|
|
286
|
-
* comes up. Used by live tests (e.g., `live-mail-reuse-dispatch`)
|
|
287
|
-
* to provide a parented dispatch target that survives mail+reuse
|
|
288
|
-
* `done()` cleanly (the worker terminates as designed; the parent
|
|
289
|
-
* coord receives the `WORKER_DONE` signal — no orphan).
|
|
290
|
-
*
|
|
291
|
-
* Default `role`: `'reuse-target'`. Choose a role that does NOT
|
|
292
|
-
* collide with the sidecar's projected `'worker'` role in the
|
|
293
|
-
* hub-side roster — otherwise prefer-route may tie-break to the
|
|
294
|
-
* sidecar instead of this worker.
|
|
295
|
-
*/
|
|
296
|
-
worker?: boolean | {
|
|
297
|
-
role?: string;
|
|
298
|
-
task?: string;
|
|
299
|
-
};
|
|
300
|
-
/**
|
|
301
|
-
* Rehydration policy for agents that existed before this boot. Controls
|
|
302
|
-
* what the boot script does with agents that outlived their previous
|
|
303
|
-
* host process (agent-store is durable; a restart finds agents still
|
|
304
|
-
* marked `state='running'` but without any live ACP session).
|
|
305
|
-
*
|
|
306
|
-
* - `'none'` — skip rehydration entirely. Always fall through to fresh
|
|
307
|
-
* bootstrap spawn (or no spawn if `bootstrap.coordinator` is unset).
|
|
308
|
-
* - `'coordinators'` (default) — revive only root coordinators for
|
|
309
|
-
* this cwd. Matches the common openhive case where the workspace
|
|
310
|
-
* intent is "I want a coordinator here" and workers are ephemeral.
|
|
311
|
-
* - `'all'` — revive every `state='running'` agent at this cwd
|
|
312
|
-
* (coordinators plus workers/integrators/monitors). Parent-first
|
|
313
|
-
* ordering; children are skipped if their parent failed to revive
|
|
314
|
-
* or is `state='stopped'` (deliberately down).
|
|
315
|
-
*
|
|
316
|
-
* Hosted swarms pass `'all'` via `MACRO_BOOTSTRAP_REHYDRATE=all` so a
|
|
317
|
-
* restart restores the full macro-agent team, not just head managers.
|
|
318
|
-
*/
|
|
319
|
-
rehydrate?: "none" | "coordinators" | "all";
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* Wire-delivered openteams binding from the host (e.g. OpenHive's
|
|
323
|
-
* spawn manager packing this into `OPENSWARM_BOOTSTRAP_TOKEN`).
|
|
324
|
-
* When `team_content` is present, bootV2 spawns the bootstrap
|
|
325
|
-
* agents via TeamRuntimeV2 from the inline manifest — no
|
|
326
|
-
* filesystem write, no MAP fetch. Path B of the OpenHive ↔
|
|
327
|
-
* macro-agent openteams integration.
|
|
328
|
-
*/
|
|
329
|
-
openteams?: {
|
|
330
|
-
loadout_bundle_id?: string;
|
|
331
|
-
team_bundle_id?: string;
|
|
332
|
-
role?: string;
|
|
333
|
-
mcp_servers?: unknown[];
|
|
334
|
-
prompt_addendum?: string;
|
|
335
|
-
team_content?: {
|
|
336
|
-
manifest: import("openteams").TeamManifest;
|
|
337
|
-
roles?: Record<string, import("./roles/types.js").RoleDefinition>;
|
|
338
|
-
loadouts?: Record<string, unknown>;
|
|
339
|
-
prompts?: Record<string, unknown>;
|
|
340
|
-
};
|
|
341
|
-
};
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// =============================================================================
|
|
346
|
-
// System Interface
|
|
347
|
-
// =============================================================================
|
|
348
|
-
|
|
349
|
-
export interface MacroAgentSystemV2 {
|
|
350
|
-
/** Agent lifecycle manager */
|
|
351
|
-
agentManager: AgentManager;
|
|
352
|
-
|
|
353
|
-
/** Agent lifecycle store */
|
|
354
|
-
agentStore: AgentStore;
|
|
355
|
-
|
|
356
|
-
/** Messaging adapter (embedded agent-inbox) */
|
|
357
|
-
inboxAdapter: InboxAdapter;
|
|
358
|
-
|
|
359
|
-
/** Task management adapter (opentasks client) */
|
|
360
|
-
tasksAdapter: TasksAdapter;
|
|
361
|
-
|
|
362
|
-
/** Trigger system (wake, cron, webhooks) */
|
|
363
|
-
triggerSystem: TriggerSystemV2;
|
|
364
|
-
|
|
365
|
-
/** Control server (lifecycle RPC for MCP subprocesses) */
|
|
366
|
-
controlServer: ControlServer;
|
|
367
|
-
|
|
368
|
-
/** Role registry */
|
|
369
|
-
roleRegistry: RoleRegistry;
|
|
370
|
-
|
|
371
|
-
/** Control socket path (for MCP subprocess connection) */
|
|
372
|
-
controlSocketPath: string;
|
|
373
|
-
|
|
374
|
-
/** Task dispatcher (if dispatch mode enabled) */
|
|
375
|
-
taskDispatcher?: import("swarm-dispatch").TaskDispatcher;
|
|
376
|
-
|
|
377
|
-
/** REST API server (if enabled) */
|
|
378
|
-
apiServer?: ApiServer;
|
|
379
|
-
|
|
380
|
-
/** ACP WebSocket server (if enabled) */
|
|
381
|
-
acpServer?: WebSocketACPServer;
|
|
382
|
-
|
|
383
|
-
/** MAP server for inbound connections (if enabled) */
|
|
384
|
-
mapServerInstance?: import("./map/types.js").MAPServerInstance;
|
|
385
|
-
|
|
386
|
-
/** MAP sidecar for outbound hub connection (if enabled) */
|
|
387
|
-
mapSidecar?: import("./map/types.js").MAPSidecar;
|
|
388
|
-
|
|
389
|
-
/** Sessionlog sync level for trajectory checkpoint gating */
|
|
390
|
-
_sessionlogSyncLevel?: string;
|
|
391
|
-
|
|
392
|
-
/** Shut down all components */
|
|
393
|
-
shutdown(): Promise<void>;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
// =============================================================================
|
|
397
|
-
// Boot Function
|
|
398
|
-
// =============================================================================
|
|
399
|
-
|
|
400
|
-
export async function bootV2(
|
|
401
|
-
config: BootV2Config = {},
|
|
402
|
-
): Promise<MacroAgentSystemV2> {
|
|
403
|
-
const cwd = config.cwd ?? process.cwd();
|
|
404
|
-
// Resolve the instance id with three-tier precedence so the on-disk layout
|
|
405
|
-
// stays meaningful across standalone, MAP-connected, and hosted runs:
|
|
406
|
-
//
|
|
407
|
-
// 1. Explicit `instanceId` — caller-chosen, human-readable.
|
|
408
|
-
// 2. `map.swarmId` — the MAP identity when the caller has pre-registered
|
|
409
|
-
// one. This ties macro-agent's local store to its hub identity, so a
|
|
410
|
-
// swarm with swarm_id=X always resumes its own state.
|
|
411
|
-
// 3. A stable hash of the resolved cwd — the last-resort fallback so two
|
|
412
|
-
// processes in different projects never collide on agents.db, inbox.db,
|
|
413
|
-
// or the control socket. Reruns in the same project reuse their store.
|
|
414
|
-
//
|
|
415
|
-
// Hosts that manage their own storage layout (e.g. openswarm spawning
|
|
416
|
-
// per-swarm instances under a unique data dir) still win by passing
|
|
417
|
-
// `baseDir` directly. Legacy `~/.macro-agent/*.db` from pre-instancing
|
|
418
|
-
// versions is left alone — new boots start fresh under their own subdir.
|
|
419
|
-
const instanceId =
|
|
420
|
-
config.instanceId
|
|
421
|
-
?? config.map?.swarmId
|
|
422
|
-
?? ("inst_" + crypto.createHash("sha256").update(path.resolve(cwd)).digest("hex").slice(0, 12));
|
|
423
|
-
const baseDir = config.baseDir ?? path.join(os.homedir(), ".macro-agent", instanceId);
|
|
424
|
-
|
|
425
|
-
// Env-var bridge for hosts that pass through bootConfig with a fixed
|
|
426
|
-
// whitelist (e.g. openswarm). Translates MACRO_BOOTSTRAP_COORDINATOR /
|
|
427
|
-
// MACRO_BOOTSTRAP_CWD / MACRO_BOOTSTRAP_REHYDRATE into the structured
|
|
428
|
-
// bootstrap field if not already set programmatically. Programmatic
|
|
429
|
-
// config wins per field.
|
|
430
|
-
// OpenHive openteams binding bridge. The host (openswarm) only forwards
|
|
431
|
-
// a fixed-shape `bootConfig` to `bootV2` — it doesn't propagate the
|
|
432
|
-
// raw OPENSWARM_BOOTSTRAP_TOKEN.openteams block. Pull it out of the env
|
|
433
|
-
// ourselves so wire-delivered teams (Path B) work without requiring
|
|
434
|
-
// openswarm to learn a new field.
|
|
435
|
-
if (
|
|
436
|
-
process.env.OPENSWARM_BOOTSTRAP_TOKEN &&
|
|
437
|
-
!config.bootstrap?.openteams
|
|
438
|
-
) {
|
|
439
|
-
try {
|
|
440
|
-
const raw = Buffer.from(
|
|
441
|
-
process.env.OPENSWARM_BOOTSTRAP_TOKEN,
|
|
442
|
-
"base64",
|
|
443
|
-
).toString("utf-8");
|
|
444
|
-
const token = JSON.parse(raw) as { openteams?: unknown };
|
|
445
|
-
if (token.openteams && typeof token.openteams === "object") {
|
|
446
|
-
config = {
|
|
447
|
-
...config,
|
|
448
|
-
bootstrap: {
|
|
449
|
-
...(config.bootstrap ?? {}),
|
|
450
|
-
openteams: token.openteams as NonNullable<
|
|
451
|
-
BootV2Config["bootstrap"]
|
|
452
|
-
>["openteams"],
|
|
453
|
-
},
|
|
454
|
-
};
|
|
455
|
-
}
|
|
456
|
-
} catch {
|
|
457
|
-
// Token malformed or missing fields — non-fatal; the bootstrap
|
|
458
|
-
// coordinator just runs without the openteams binding.
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
if (
|
|
463
|
-
process.env.MACRO_BOOTSTRAP_COORDINATOR === "true" &&
|
|
464
|
-
!config.bootstrap?.coordinator
|
|
465
|
-
) {
|
|
466
|
-
const envCwd = process.env.MACRO_BOOTSTRAP_CWD;
|
|
467
|
-
const dispatchTarget =
|
|
468
|
-
process.env.MACRO_BOOTSTRAP_COORDINATOR_DISPATCH_TARGET === "true";
|
|
469
|
-
const coordObj: Record<string, unknown> = {};
|
|
470
|
-
if (envCwd) coordObj.cwd = envCwd;
|
|
471
|
-
if (dispatchTarget) coordObj.dispatchTarget = true;
|
|
472
|
-
config = {
|
|
473
|
-
...config,
|
|
474
|
-
bootstrap: {
|
|
475
|
-
...(config.bootstrap ?? {}),
|
|
476
|
-
coordinator:
|
|
477
|
-
Object.keys(coordObj).length > 0
|
|
478
|
-
? (coordObj as never)
|
|
479
|
-
: true,
|
|
480
|
-
},
|
|
481
|
-
};
|
|
482
|
-
}
|
|
483
|
-
if (
|
|
484
|
-
process.env.MACRO_BOOTSTRAP_WORKER === "true" &&
|
|
485
|
-
!config.bootstrap?.worker
|
|
486
|
-
) {
|
|
487
|
-
const envWorkerRole = process.env.MACRO_BOOTSTRAP_WORKER_ROLE;
|
|
488
|
-
config = {
|
|
489
|
-
...config,
|
|
490
|
-
bootstrap: {
|
|
491
|
-
...(config.bootstrap ?? {}),
|
|
492
|
-
worker: envWorkerRole ? { role: envWorkerRole } : true,
|
|
493
|
-
},
|
|
494
|
-
};
|
|
495
|
-
}
|
|
496
|
-
const envRehydrate = process.env.MACRO_BOOTSTRAP_REHYDRATE;
|
|
497
|
-
if (
|
|
498
|
-
(envRehydrate === "none" ||
|
|
499
|
-
envRehydrate === "coordinators" ||
|
|
500
|
-
envRehydrate === "all") &&
|
|
501
|
-
config.bootstrap?.rehydrate === undefined
|
|
502
|
-
) {
|
|
503
|
-
config = {
|
|
504
|
-
...config,
|
|
505
|
-
bootstrap: {
|
|
506
|
-
...(config.bootstrap ?? {}),
|
|
507
|
-
rehydrate: envRehydrate,
|
|
508
|
-
},
|
|
509
|
-
};
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
// Ensure base directory exists
|
|
513
|
-
fs.mkdirSync(baseDir, { recursive: true });
|
|
514
|
-
|
|
515
|
-
// 1. Agent Store (minimal SQLite)
|
|
516
|
-
const agentStorePath = path.join(baseDir, "agents.db");
|
|
517
|
-
const agentStore = new AgentStore(agentStorePath);
|
|
518
|
-
|
|
519
|
-
// 2. Inbox Adapter (embedded agent-inbox, hybrid mode)
|
|
520
|
-
const inboxSocketPath =
|
|
521
|
-
config.inbox?.socketPath ?? path.join(baseDir, "inbox.sock");
|
|
522
|
-
const inboxSqlitePath = path.join(baseDir, "inbox.db");
|
|
523
|
-
|
|
524
|
-
const inboxAdapter = new DefaultInboxAdapter({
|
|
525
|
-
socketPath: inboxSocketPath,
|
|
526
|
-
sqlitePath: inboxSqlitePath,
|
|
527
|
-
defaultScope: "default",
|
|
528
|
-
...config.inbox,
|
|
529
|
-
// Pass federation config if provided
|
|
530
|
-
...(config.federation && {
|
|
531
|
-
federation: {
|
|
532
|
-
systemId: config.federation.systemId,
|
|
533
|
-
peers: config.federation.peers,
|
|
534
|
-
trust: config.federation.trust
|
|
535
|
-
? { allowedServers: config.federation.trust.allowedSystems }
|
|
536
|
-
: undefined,
|
|
537
|
-
},
|
|
538
|
-
}),
|
|
539
|
-
});
|
|
540
|
-
await inboxAdapter.initialize();
|
|
541
|
-
|
|
542
|
-
// 3. Tasks Adapter (opentasks client, auto-discovers daemon)
|
|
543
|
-
const tasksAdapter = new DefaultTasksAdapter({
|
|
544
|
-
...config.tasks,
|
|
545
|
-
});
|
|
546
|
-
try {
|
|
547
|
-
await tasksAdapter.connect();
|
|
548
|
-
} catch {
|
|
549
|
-
// opentasks daemon may not be available — non-fatal
|
|
550
|
-
console.warn(
|
|
551
|
-
"[boot-v2] opentasks daemon not available. Task operations will fail until connected.",
|
|
552
|
-
);
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
// 4. Role Registry
|
|
556
|
-
const roleRegistry = config.roleRegistry ?? new DefaultRoleRegistry();
|
|
557
|
-
|
|
558
|
-
// 5. Agent Manager V2
|
|
559
|
-
const controlSocketPath = path.join(baseDir, "control.sock");
|
|
560
|
-
const agentManager = createAgentManagerV2(
|
|
561
|
-
agentStore,
|
|
562
|
-
inboxAdapter,
|
|
563
|
-
tasksAdapter,
|
|
564
|
-
{
|
|
565
|
-
defaultPermissionMode: config.defaultPermissionMode ?? "auto-approve",
|
|
566
|
-
defaultAgentType: config.defaultAgentType ?? "claude-code",
|
|
567
|
-
defaultCwd: cwd,
|
|
568
|
-
roleRegistry,
|
|
569
|
-
workspaceManager: config.workspaceManager,
|
|
570
|
-
serverUrl: config.serverUrl,
|
|
571
|
-
serverToken: config.serverToken,
|
|
572
|
-
controlSocketPath,
|
|
573
|
-
taskResourceId: config.cascade?.taskResourceId,
|
|
574
|
-
resolveTaskRef: config.cascade?.resolveTaskRef,
|
|
575
|
-
},
|
|
576
|
-
);
|
|
577
|
-
|
|
578
|
-
// 6. Federation (cross-instance communication)
|
|
579
|
-
let federationCleanup: (() => void) | null = null;
|
|
580
|
-
if (config.federation) {
|
|
581
|
-
const { setupFederation } = await import("./adapters/federation.js");
|
|
582
|
-
federationCleanup = setupFederation(
|
|
583
|
-
agentManager,
|
|
584
|
-
inboxAdapter,
|
|
585
|
-
config.federation,
|
|
586
|
-
);
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
// 7. Trigger System V2
|
|
590
|
-
const triggerSystem = createTriggerSystemV2(
|
|
591
|
-
{
|
|
592
|
-
agentManager,
|
|
593
|
-
agentStore,
|
|
594
|
-
inboxAdapter,
|
|
595
|
-
},
|
|
596
|
-
{
|
|
597
|
-
wake: {
|
|
598
|
-
enableHeartbeat: config.trigger?.enableHeartbeat ?? false,
|
|
599
|
-
heartbeatIntervalMs: config.trigger?.heartbeatIntervalMs,
|
|
600
|
-
},
|
|
601
|
-
},
|
|
602
|
-
);
|
|
603
|
-
await triggerSystem.start();
|
|
604
|
-
|
|
605
|
-
// 7a. Task Dispatch (opt-in autonomous task dispatch mode)
|
|
606
|
-
let taskDispatcher: import("swarm-dispatch").TaskDispatcher | null = null;
|
|
607
|
-
// Hoisted so the MAP sidecar (step 13) can forward it to the mail bridge.
|
|
608
|
-
let dispatcherAgentId: string | undefined;
|
|
609
|
-
// Mail-inbound consumer — always wired (does not require dispatch.enabled).
|
|
610
|
-
let mailInboundConsumer: import("./dispatch/mail-inbound-consumer.js").MailInboundConsumer | null = null;
|
|
611
|
-
// Mail-inbound REUSE consumer — handles `x-dispatch/work` envelopes
|
|
612
|
-
// addressed to non-sidecar agents (long-lived workers/coordinators) and
|
|
613
|
-
// drives them through the dispatch turn using their existing session.
|
|
614
|
-
// Always wired so reuse routing works even without the outbound
|
|
615
|
-
// orchestrator. Filters non-overlapping with mailInboundConsumer.
|
|
616
|
-
let mailInboundReuseConsumer:
|
|
617
|
-
| import("./dispatch/mail-inbound-reuse-consumer.js").MailInboundReuseConsumer
|
|
618
|
-
| null = null;
|
|
619
|
-
|
|
620
|
-
{
|
|
621
|
-
// Stable dispatcher ID used as the inbox recipient for bridged envelopes.
|
|
622
|
-
// Matches the id the mail-bridge registers and delivers to. The outbound
|
|
623
|
-
// orchestrator (below, opt-in) reuses the same id so both code paths share
|
|
624
|
-
// one inbox recipient — no double-processing because the consumer only
|
|
625
|
-
// fires spawn() while the orchestrator fires spawn() only when polling
|
|
626
|
-
// opentasks (different trigger paths).
|
|
627
|
-
const { getStableInstanceId } = await import("./cli/stable-instance-id.js");
|
|
628
|
-
const inboundClaimantId = `${os.hostname()}:${process.pid}:${getStableInstanceId(cwd)}`;
|
|
629
|
-
const inboundDispatcherId = `dispatcher:${inboundClaimantId}`;
|
|
630
|
-
dispatcherAgentId = inboundDispatcherId;
|
|
631
|
-
|
|
632
|
-
// Register the inbox recipient so mail-bridge's registerAgent call is a
|
|
633
|
-
// no-op (it uses an upsert) and the inbox accepts deliveries immediately.
|
|
634
|
-
await inboxAdapter.registerAgent(inboundDispatcherId, {
|
|
635
|
-
role: "dispatcher",
|
|
636
|
-
scope: "default",
|
|
637
|
-
});
|
|
638
|
-
|
|
639
|
-
const rawInbox = inboxAdapter.getInbox();
|
|
640
|
-
const { createMailInboundConsumer } = await import(
|
|
641
|
-
"./dispatch/mail-inbound-consumer.js"
|
|
642
|
-
);
|
|
643
|
-
mailInboundConsumer = createMailInboundConsumer({
|
|
644
|
-
dispatcherAgentId: inboundDispatcherId,
|
|
645
|
-
inboxEvents: rawInbox.events as any,
|
|
646
|
-
agentManager,
|
|
647
|
-
agentStore,
|
|
648
|
-
getSidecar: () => (systemRef as any).mapSidecar ?? null,
|
|
649
|
-
getRepoManager: () => (systemRef as any).mapSidecar?.getWorkspaceManager?.() ?? null,
|
|
650
|
-
getRepoTransport: () => (systemRef as any).mapSidecar?.getRepoTransport?.() ?? null,
|
|
651
|
-
log: (msg) => console.log(msg),
|
|
652
|
-
});
|
|
653
|
-
|
|
654
|
-
// Reuse consumer for envelopes addressed to long-lived workers/
|
|
655
|
-
// coordinators. Non-overlapping filter (event.agentId !== sidecarId).
|
|
656
|
-
const { createMailInboundReuseConsumer } = await import(
|
|
657
|
-
"./dispatch/mail-inbound-reuse-consumer.js"
|
|
658
|
-
);
|
|
659
|
-
mailInboundReuseConsumer = createMailInboundReuseConsumer({
|
|
660
|
-
dispatcherAgentId: inboundDispatcherId,
|
|
661
|
-
inboxEvents: rawInbox.events as any,
|
|
662
|
-
agentManager,
|
|
663
|
-
agentStore,
|
|
664
|
-
getSidecar: () => (systemRef as any).mapSidecar ?? null,
|
|
665
|
-
log: (msg) => console.log(msg),
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
if (config.dispatch?.enabled && tasksAdapter) {
|
|
670
|
-
const { createOrchestrator, createOpenTasksSource, createAgentInboxPort } =
|
|
671
|
-
await import("swarm-dispatch");
|
|
672
|
-
|
|
673
|
-
// dispatcherAgentId is already set by the unconditional mail-inbound block above.
|
|
674
|
-
// Use it directly so both paths share the same inbox recipient.
|
|
675
|
-
const dispatchAgentId = dispatcherAgentId!;
|
|
676
|
-
|
|
677
|
-
// Adapt opentasks client → DispatchTaskSource
|
|
678
|
-
const opentasksClient = (tasksAdapter as any).client;
|
|
679
|
-
const source = opentasksClient
|
|
680
|
-
? createOpenTasksSource(opentasksClient)
|
|
681
|
-
: {
|
|
682
|
-
// Fallback adapter when opentasks client is available via TasksAdapter methods
|
|
683
|
-
queryReady: async (opts?: { tags?: string[]; limit?: number }) =>
|
|
684
|
-
tasksAdapter.queryReady(opts),
|
|
685
|
-
claim: async (taskId: string, claimantIdArg: string) => {
|
|
686
|
-
try {
|
|
687
|
-
await tasksAdapter.assignTask(taskId, claimantIdArg);
|
|
688
|
-
return { success: true as const };
|
|
689
|
-
} catch {
|
|
690
|
-
return { success: false as const };
|
|
691
|
-
}
|
|
692
|
-
},
|
|
693
|
-
release: async (taskId: string) => tasksAdapter.unclaimTask(taskId),
|
|
694
|
-
transition: async (
|
|
695
|
-
taskId: string,
|
|
696
|
-
action: "start" | "complete" | "fail",
|
|
697
|
-
) => tasksAdapter.transitionTask(taskId, action),
|
|
698
|
-
getTask: async (taskId: string) => tasksAdapter.getTask(taskId),
|
|
699
|
-
listInProgress: async () =>
|
|
700
|
-
tasksAdapter.listTasks({ status: "in_progress" }),
|
|
701
|
-
};
|
|
702
|
-
|
|
703
|
-
// Adapt AgentManagerV2 → DispatchAgentRuntime
|
|
704
|
-
const runtime: import("swarm-dispatch").DispatchAgentRuntime = {
|
|
705
|
-
spawn: async (opts: { prompt: string; taskId: string; role: string }) => {
|
|
706
|
-
const spawned = await agentManager.spawn({
|
|
707
|
-
task: opts.prompt,
|
|
708
|
-
task_id: opts.taskId,
|
|
709
|
-
role: opts.role,
|
|
710
|
-
parent: null,
|
|
711
|
-
});
|
|
712
|
-
return { id: spawned.id };
|
|
713
|
-
},
|
|
714
|
-
terminate: async (agentId: string, reason?: string) => {
|
|
715
|
-
await agentManager.terminate(agentId, (reason ?? "cancelled") as any);
|
|
716
|
-
},
|
|
717
|
-
onStopped: (callback: (agentId: string, reason: string) => void) =>
|
|
718
|
-
agentManager.onLifecycleEvent((event) => {
|
|
719
|
-
if (event.type === "stopped") {
|
|
720
|
-
callback(event.agent.id, event.reason);
|
|
721
|
-
}
|
|
722
|
-
}),
|
|
723
|
-
};
|
|
724
|
-
|
|
725
|
-
// Phase 2: Wire MessagePort via agent-inbox for mail-based work routing
|
|
726
|
-
let messagePort: import("swarm-dispatch").MessagePort | undefined;
|
|
727
|
-
if (config.dispatch.enableMailRouting !== false) {
|
|
728
|
-
const inbox = inboxAdapter.getInbox();
|
|
729
|
-
messagePort = createAgentInboxPort(
|
|
730
|
-
inbox.router as any,
|
|
731
|
-
inbox.events as any,
|
|
732
|
-
{
|
|
733
|
-
dispatcherAgentId: dispatchAgentId,
|
|
734
|
-
classifyMessage: (msg: any) => {
|
|
735
|
-
// Classify inbox messages as dispatchable work when they carry
|
|
736
|
-
// the x-dispatch/work schema. Other messages are ignored.
|
|
737
|
-
const content = msg.content as {
|
|
738
|
-
type?: string;
|
|
739
|
-
schema?: string;
|
|
740
|
-
data?: any;
|
|
741
|
-
_conversationId?: string;
|
|
742
|
-
};
|
|
743
|
-
if (content?.schema !== "x-dispatch/work") return null;
|
|
744
|
-
const data = content.data;
|
|
745
|
-
if (!data?.taskId) return null;
|
|
746
|
-
return {
|
|
747
|
-
messageId: msg.id,
|
|
748
|
-
correlationId: msg.thread_tag ?? msg.id,
|
|
749
|
-
replyTo: msg.sender_id ? { agentId: msg.sender_id } : undefined,
|
|
750
|
-
task: {
|
|
751
|
-
id: data.taskId,
|
|
752
|
-
title: data.title ?? `Delegated: ${data.taskId}`,
|
|
753
|
-
status: "open",
|
|
754
|
-
content: data.prompt ?? data.content,
|
|
755
|
-
tags: data.tags,
|
|
756
|
-
metadata: {
|
|
757
|
-
...data.metadata,
|
|
758
|
-
role: data.role,
|
|
759
|
-
// Thread conversation_id through so the reply bridge can post
|
|
760
|
-
// the worker's output back to the hub's mail conversation.
|
|
761
|
-
...(content._conversationId
|
|
762
|
-
? { _mailConversationId: content._conversationId }
|
|
763
|
-
: {}),
|
|
764
|
-
},
|
|
765
|
-
},
|
|
766
|
-
};
|
|
767
|
-
},
|
|
768
|
-
},
|
|
769
|
-
);
|
|
770
|
-
// Note: registerAgent for dispatchAgentId was already called in the
|
|
771
|
-
// unconditional mail-inbound block above — no need to repeat here.
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
// Phase 2: Wire AgentRoster via inbox agent listing for route-first dispatch
|
|
775
|
-
let roster: import("swarm-dispatch").AgentRoster | undefined;
|
|
776
|
-
if (config.dispatch.enableRoster !== false) {
|
|
777
|
-
const inbox = inboxAdapter.getInbox();
|
|
778
|
-
roster = {
|
|
779
|
-
async findAvailable(criteria) {
|
|
780
|
-
// List agents from inbox storage, filter by role and idle state
|
|
781
|
-
const agents = inbox.storage.listAgents();
|
|
782
|
-
return agents
|
|
783
|
-
.filter((a: any) => {
|
|
784
|
-
if (a.agentId === dispatchAgentId) return false;
|
|
785
|
-
if (criteria.role && a.role && a.role !== criteria.role)
|
|
786
|
-
return false;
|
|
787
|
-
if (criteria.notBusy && a.status === "busy") return false;
|
|
788
|
-
return true;
|
|
789
|
-
})
|
|
790
|
-
.map((a: any) => ({
|
|
791
|
-
agentId: a.agentId ?? a.agent_id ?? a.id,
|
|
792
|
-
host: a.host,
|
|
793
|
-
}));
|
|
794
|
-
},
|
|
795
|
-
};
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
// Determine dispatch mode
|
|
799
|
-
const hasRouting = !!messagePort && !!roster;
|
|
800
|
-
const dispatchMode =
|
|
801
|
-
config.dispatch.dispatchMode ??
|
|
802
|
-
(hasRouting ? ("prefer-route" as const) : ("spawn-only" as const));
|
|
803
|
-
|
|
804
|
-
taskDispatcher = createOrchestrator(source, runtime, {
|
|
805
|
-
claimantId: dispatchAgentId,
|
|
806
|
-
pollIntervalMs: config.dispatch.pollIntervalMs ?? 15_000,
|
|
807
|
-
defaultRole: config.dispatch.defaultRole ?? "worker",
|
|
808
|
-
concurrency: { global: config.dispatch.maxConcurrent ?? 3 },
|
|
809
|
-
retry: {
|
|
810
|
-
maxRetries: config.dispatch.maxRetries ?? 3,
|
|
811
|
-
baseDelayMs: config.dispatch.retryBaseDelayMs ?? 10_000,
|
|
812
|
-
maxDelayMs: config.dispatch.retryMaxDelayMs ?? 300_000,
|
|
813
|
-
},
|
|
814
|
-
eligibility: config.dispatch.eligibility,
|
|
815
|
-
tags: config.dispatch.tags,
|
|
816
|
-
reconcile: {
|
|
817
|
-
enabled: config.dispatch.reconcile?.enabled ?? true,
|
|
818
|
-
intervalMs: config.dispatch.reconcile?.intervalMs ?? 60_000,
|
|
819
|
-
stallTimeoutMs: config.dispatch.reconcile?.stallTimeoutMs,
|
|
820
|
-
},
|
|
821
|
-
...(config.dispatch.continuation && {
|
|
822
|
-
continuation: {
|
|
823
|
-
delayMs: config.dispatch.continuation.delayMs ?? 1_000,
|
|
824
|
-
maxTurns: config.dispatch.continuation.maxTurns ?? 20,
|
|
825
|
-
},
|
|
826
|
-
}),
|
|
827
|
-
messagePort,
|
|
828
|
-
roster,
|
|
829
|
-
dispatchMode,
|
|
830
|
-
});
|
|
831
|
-
|
|
832
|
-
await taskDispatcher.start();
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
// 7b. Control Server (lifecycle RPC for MCP subprocesses)
|
|
836
|
-
const controlServer = new ControlServer(agentManager, {
|
|
837
|
-
socketPath: controlSocketPath,
|
|
838
|
-
});
|
|
839
|
-
await controlServer.start();
|
|
840
|
-
|
|
841
|
-
// 8. Health check escalation loop
|
|
842
|
-
// Periodically check for unhealthy agents (stale MCP heartbeats)
|
|
843
|
-
// and notify their parents via inbox.
|
|
844
|
-
const HEALTH_CHECK_INTERVAL_MS = 30_000;
|
|
845
|
-
const UNHEALTHY_THRESHOLD_MS = 60_000;
|
|
846
|
-
|
|
847
|
-
const healthCheckTimer = setInterval(async () => {
|
|
848
|
-
try {
|
|
849
|
-
const unhealthy = controlServer.getUnhealthyAgents(
|
|
850
|
-
UNHEALTHY_THRESHOLD_MS,
|
|
851
|
-
);
|
|
852
|
-
for (const { agentId, lastSeen } of unhealthy) {
|
|
853
|
-
const agent = agentStore.getAgent(agentId);
|
|
854
|
-
if (!agent || agent.state !== "running") continue;
|
|
855
|
-
|
|
856
|
-
// Notify parent (if any) that this agent's MCP subprocess may be stale
|
|
857
|
-
if (agent.parent_id) {
|
|
858
|
-
try {
|
|
859
|
-
await inboxAdapter.send(
|
|
860
|
-
"system",
|
|
861
|
-
agent.parent_id,
|
|
862
|
-
{
|
|
863
|
-
type: "event",
|
|
864
|
-
event: "STALE_AGENT",
|
|
865
|
-
data: {
|
|
866
|
-
agentId,
|
|
867
|
-
role: agent.role,
|
|
868
|
-
lastSeen,
|
|
869
|
-
staleSinceMs: Date.now() - lastSeen,
|
|
870
|
-
},
|
|
871
|
-
},
|
|
872
|
-
{ importance: "high", threadTag: `health:${agentId}` },
|
|
873
|
-
);
|
|
874
|
-
} catch {
|
|
875
|
-
// Best effort notification
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
} catch {
|
|
880
|
-
// Best effort health check
|
|
881
|
-
}
|
|
882
|
-
}, HEALTH_CHECK_INTERVAL_MS);
|
|
883
|
-
healthCheckTimer.unref(); // Don't prevent process exit
|
|
884
|
-
|
|
885
|
-
// Shared mutable system reference — passed to ACP server, MAP server, API server.
|
|
886
|
-
// Components created before the sidecar (steps 9-11) receive this object.
|
|
887
|
-
// When the sidecar is created (step 13), it's attached here so all components
|
|
888
|
-
// see it via the same reference (e.g., ACP handler accessing system.mapSidecar).
|
|
889
|
-
const systemRef = {
|
|
890
|
-
agentManager,
|
|
891
|
-
agentStore,
|
|
892
|
-
inboxAdapter,
|
|
893
|
-
tasksAdapter,
|
|
894
|
-
triggerSystem,
|
|
895
|
-
controlServer,
|
|
896
|
-
roleRegistry,
|
|
897
|
-
controlSocketPath,
|
|
898
|
-
} as any;
|
|
899
|
-
|
|
900
|
-
// 9. REST API server (optional)
|
|
901
|
-
let apiServer: ApiServer | null = null;
|
|
902
|
-
if (config.api?.enabled) {
|
|
903
|
-
const { createApiServer } = await import("./api/server.js");
|
|
904
|
-
apiServer = createApiServer(systemRef, {
|
|
905
|
-
port: config.api.port,
|
|
906
|
-
host: config.api.host,
|
|
907
|
-
});
|
|
908
|
-
await apiServer.start();
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
// 10. ACP WebSocket server (optional)
|
|
912
|
-
let acpServer: WebSocketACPServer | null = null;
|
|
913
|
-
if (config.acp?.enabled) {
|
|
914
|
-
const { createWebSocketACPServer } =
|
|
915
|
-
await import("./acp/websocket-server.js");
|
|
916
|
-
acpServer = createWebSocketACPServer(systemRef, {
|
|
917
|
-
port: config.acp.port,
|
|
918
|
-
host: config.acp.host,
|
|
919
|
-
path: config.acp.path,
|
|
920
|
-
});
|
|
921
|
-
await acpServer.start();
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
// 11. MAP Server (optional — accept inbound connections from TUI/clients)
|
|
925
|
-
let mapServerInstance: import("./map/types.js").MAPServerInstance | null =
|
|
926
|
-
null;
|
|
927
|
-
if (config.mapServer?.enabled) {
|
|
928
|
-
try {
|
|
929
|
-
const { createMAPServerInstance } = await import("./map/server.js");
|
|
930
|
-
mapServerInstance = createMAPServerInstance(
|
|
931
|
-
{
|
|
932
|
-
agentManager,
|
|
933
|
-
agentStore,
|
|
934
|
-
inboxAdapter,
|
|
935
|
-
tasksAdapter,
|
|
936
|
-
system: systemRef,
|
|
937
|
-
},
|
|
938
|
-
{
|
|
939
|
-
port: config.mapServer.port,
|
|
940
|
-
host: config.mapServer.host,
|
|
941
|
-
path: config.mapServer.path,
|
|
942
|
-
name: config.mapServer.name,
|
|
943
|
-
},
|
|
944
|
-
);
|
|
945
|
-
await mapServerInstance.start();
|
|
946
|
-
|
|
947
|
-
// Tell AgentManager the MAP server URL so spawned agents' cc-swarm
|
|
948
|
-
// hooks connect to this local server instead of an external hub.
|
|
949
|
-
agentManager.setMapServerUrl(mapServerInstance.getUrl());
|
|
950
|
-
} catch (err) {
|
|
951
|
-
console.warn(
|
|
952
|
-
`[boot-v2] MAP server failed to start: ${(err as Error).message}`,
|
|
953
|
-
);
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
// 12. Swarmkit integrations (minimem, skill-tree, sessionlog)
|
|
958
|
-
agentManager.setIntegrationConfigs({
|
|
959
|
-
minimem: config.minimem?.enabled ? (config.minimem as any) : undefined,
|
|
960
|
-
skilltree: config.skilltree?.enabled
|
|
961
|
-
? (config.skilltree as any)
|
|
962
|
-
: undefined,
|
|
963
|
-
sessionlog: config.sessionlog?.enabled
|
|
964
|
-
? (config.sessionlog as any)
|
|
965
|
-
: undefined,
|
|
966
|
-
});
|
|
967
|
-
|
|
968
|
-
// 12b. Skill-tree loadout compilation (if enabled)
|
|
969
|
-
if (config.skilltree?.enabled) {
|
|
970
|
-
try {
|
|
971
|
-
const { compileAllRoleLoadouts } =
|
|
972
|
-
await import("./integrations/skilltree.js");
|
|
973
|
-
// Gather roles from the role registry
|
|
974
|
-
const registeredRoles = roleRegistry.listRoles();
|
|
975
|
-
const roleNames = registeredRoles.map((r) => r.name);
|
|
976
|
-
if (roleNames.length > 0) {
|
|
977
|
-
const loadouts = await compileAllRoleLoadouts(
|
|
978
|
-
roleNames.filter(Boolean),
|
|
979
|
-
config.skilltree,
|
|
980
|
-
);
|
|
981
|
-
for (const [role, content] of loadouts) {
|
|
982
|
-
agentManager.setSkillLoadout(role, content);
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
} catch {
|
|
986
|
-
// skill-tree not available — non-fatal
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
// 13. MAP Sidecar (optional — connect to OpenHive hub)
|
|
991
|
-
let mapSidecar: import("./map/types.js").MAPSidecar | null = null;
|
|
992
|
-
if (config.map?.enabled && config.map.server) {
|
|
993
|
-
try {
|
|
994
|
-
const { createMAPSidecar } = await import("./map/sidecar.js");
|
|
995
|
-
// If a workspace manager is present, pull out its GitCascadeAdapter
|
|
996
|
-
// so the sidecar can forward cascade events to the hub.
|
|
997
|
-
const wsMgr = config.workspaceManager as
|
|
998
|
-
| {
|
|
999
|
-
getGitCascadeAdapter?: () =>
|
|
1000
|
-
| import("./workspace/git-cascade-adapter.js").GitCascadeAdapter
|
|
1001
|
-
| undefined;
|
|
1002
|
-
}
|
|
1003
|
-
| undefined;
|
|
1004
|
-
const gitCascadeAdapter = wsMgr?.getGitCascadeAdapter?.();
|
|
1005
|
-
mapSidecar = createMAPSidecar(
|
|
1006
|
-
{
|
|
1007
|
-
agentManager,
|
|
1008
|
-
agentStore,
|
|
1009
|
-
inboxAdapter,
|
|
1010
|
-
tasksAdapter,
|
|
1011
|
-
getLocalMapId: mapServerInstance
|
|
1012
|
-
? (id: string) => mapServerInstance!.getLocalMapId(id)
|
|
1013
|
-
: undefined,
|
|
1014
|
-
gitCascadeAdapter,
|
|
1015
|
-
dispatcherAgentId,
|
|
1016
|
-
},
|
|
1017
|
-
{
|
|
1018
|
-
server: config.map.server,
|
|
1019
|
-
token: config.map.token,
|
|
1020
|
-
scope: config.map.scope,
|
|
1021
|
-
systemId: config.map.systemId,
|
|
1022
|
-
credential: config.map.credential,
|
|
1023
|
-
agentName: config.map.agentName,
|
|
1024
|
-
swarmId: config.map.swarmId,
|
|
1025
|
-
trajectorySyncLevel: config.map.trajectorySyncLevel,
|
|
1026
|
-
reconnectIntervalMs: config.map.reconnectIntervalMs,
|
|
1027
|
-
reconnection: config.map.reconnection,
|
|
1028
|
-
mesh: config.mesh?.enabled ? config.mesh : undefined,
|
|
1029
|
-
},
|
|
1030
|
-
);
|
|
1031
|
-
await mapSidecar.start();
|
|
1032
|
-
// Wire sidecar into agent manager for session-end checkpoints
|
|
1033
|
-
agentManager.setSidecar(mapSidecar);
|
|
1034
|
-
|
|
1035
|
-
// Bridge dispatch events to MAP for observability. Spread the source
|
|
1036
|
-
// event first, then namespace the `type` field — otherwise tsc warns
|
|
1037
|
-
// about the literal key being overwritten by the spread.
|
|
1038
|
-
if (taskDispatcher && mapSidecar.emitEvent) {
|
|
1039
|
-
taskDispatcher.onEvent((event) => {
|
|
1040
|
-
mapSidecar!.emitEvent!({
|
|
1041
|
-
...event,
|
|
1042
|
-
type: `dispatch.${event.type}`,
|
|
1043
|
-
});
|
|
1044
|
-
});
|
|
1045
|
-
}
|
|
1046
|
-
// Attach to shared system ref so ACP/MAP handlers can access it
|
|
1047
|
-
systemRef.mapSidecar = mapSidecar;
|
|
1048
|
-
} catch (err) {
|
|
1049
|
-
// Non-fatal — MAP hub connectivity is optional
|
|
1050
|
-
console.warn(
|
|
1051
|
-
`[boot-v2] MAP sidecar failed to start: ${(err as Error).message}`,
|
|
1052
|
-
);
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
|
-
// 13. Boot-time agents (opt-in)
|
|
1057
|
-
// Fire after all subsystems are wired so the agent's lifecycle events
|
|
1058
|
-
// (spawned/started) flow through the lifecycle bridge → MAP hub. Non-
|
|
1059
|
-
// blocking: don't gate boot completion on agent process startup, which
|
|
1060
|
-
// takes seconds. Failures are logged but do not abort boot.
|
|
1061
|
-
//
|
|
1062
|
-
// Rehydration on restart: the agent-store persists across process
|
|
1063
|
-
// restarts. When we boot into a workspace that already has one or more
|
|
1064
|
-
// coordinators (e.g. openhive spawned this swarm previously + auto-
|
|
1065
|
-
// revived it), resume THOSE agents instead of spawning a brand-new one.
|
|
1066
|
-
// Otherwise the UI shows a different coordinator name after every
|
|
1067
|
-
// server restart — the prior conversations still exist on disk but get
|
|
1068
|
-
// buried under stale, state='stopped' records that the UI treats as
|
|
1069
|
-
// dead.
|
|
1070
|
-
// OpenHive wire-delivered team (Path B). When the bootstrap token
|
|
1071
|
-
// carries `openteams.team_content`, instantiate a TeamManagerV2 and
|
|
1072
|
-
// start the team in-memory — no filesystem write, no MAP fetch. The
|
|
1073
|
-
// team's own `topology.root` + companions become the bootstrap
|
|
1074
|
-
// agents, so we short-circuit the generic `bootstrap.coordinator`
|
|
1075
|
-
// path below (those are mutually exclusive: a team-aware swarm has
|
|
1076
|
-
// its head decided by the team manifest, not by a generic
|
|
1077
|
-
// coordinator spawn).
|
|
1078
|
-
const openteamsContent = config.bootstrap?.openteams?.team_content as
|
|
1079
|
-
| {
|
|
1080
|
-
manifest: import("openteams").TeamManifest;
|
|
1081
|
-
roles?: Record<string, import("./roles/types.js").RoleDefinition>;
|
|
1082
|
-
loadouts?: Record<string, unknown>;
|
|
1083
|
-
prompts?: Record<string, unknown>;
|
|
1084
|
-
}
|
|
1085
|
-
| undefined;
|
|
1086
|
-
if (openteamsContent && config.bootstrap?.coordinator) {
|
|
1087
|
-
try {
|
|
1088
|
-
const { TeamManagerV2 } = await import("./teams/team-manager-v2.js");
|
|
1089
|
-
const teamManager = new TeamManagerV2({
|
|
1090
|
-
agentManager,
|
|
1091
|
-
inboxAdapter,
|
|
1092
|
-
tasksAdapter,
|
|
1093
|
-
workspaceManager: config.workspaceManager,
|
|
1094
|
-
});
|
|
1095
|
-
teamManager.install();
|
|
1096
|
-
const teamName =
|
|
1097
|
-
(openteamsContent.manifest?.name as string | undefined) ?? "openhive-team";
|
|
1098
|
-
const instanceId = await teamManager.startTeamFromContent(
|
|
1099
|
-
teamName,
|
|
1100
|
-
openteamsContent,
|
|
1101
|
-
);
|
|
1102
|
-
console.log(
|
|
1103
|
-
`[boot-v2] Wire-delivered team started: ${teamName} (instance ${instanceId})`,
|
|
1104
|
-
);
|
|
1105
|
-
} catch (err) {
|
|
1106
|
-
console.warn(
|
|
1107
|
-
`[boot-v2] Wire-delivered team start failed; falling back to generic coordinator: ${
|
|
1108
|
-
(err as Error).message
|
|
1109
|
-
}`,
|
|
1110
|
-
);
|
|
1111
|
-
}
|
|
1112
|
-
} else if (config.bootstrap?.coordinator) {
|
|
1113
|
-
const opts = config.bootstrap.coordinator === true
|
|
1114
|
-
? {}
|
|
1115
|
-
: config.bootstrap.coordinator;
|
|
1116
|
-
const bootstrapCwd = opts.cwd ?? cwd;
|
|
1117
|
-
const policy = config.bootstrap.rehydrate ?? "coordinators";
|
|
1118
|
-
|
|
1119
|
-
// Build the revival set based on policy:
|
|
1120
|
-
// - 'none' → empty set (always fall through to fresh spawn)
|
|
1121
|
-
// - 'coordinators' → root coordinators at this cwd, running or stopped
|
|
1122
|
-
// - 'all' → every agent at this cwd, running or stopped
|
|
1123
|
-
//
|
|
1124
|
-
// Both 'running' and 'stopped' count as revival candidates. The
|
|
1125
|
-
// hosted-swarm graceful-restart path transitions agents to 'stopped'
|
|
1126
|
-
// on shutdown; an abrupt parent crash leaves them as 'running'.
|
|
1127
|
-
// Either way, the workspace intent survives the restart and we want
|
|
1128
|
-
// the same coordinators + their children back. Agents that a user
|
|
1129
|
-
// explicitly terminated are tracked with a distinct `stop_reason`
|
|
1130
|
-
// and — since explicit termination clears them from the cascade — do
|
|
1131
|
-
// not appear in the listAgents result at a cwd they no longer
|
|
1132
|
-
// inhabit. The `state='failed'` set is also excluded.
|
|
1133
|
-
let priors: import("./agent/agent-store.js").AgentRecord[] = [];
|
|
1134
|
-
if (policy === "coordinators") {
|
|
1135
|
-
priors = agentStore
|
|
1136
|
-
.listAgents({ parent_id: null, role: "coordinator" })
|
|
1137
|
-
.filter(
|
|
1138
|
-
(a) =>
|
|
1139
|
-
a.cwd === bootstrapCwd &&
|
|
1140
|
-
(a.state === "running" || a.state === "stopped"),
|
|
1141
|
-
);
|
|
1142
|
-
} else if (policy === "all") {
|
|
1143
|
-
priors = agentStore
|
|
1144
|
-
.listAgents()
|
|
1145
|
-
.filter(
|
|
1146
|
-
(a) =>
|
|
1147
|
-
a.cwd === bootstrapCwd &&
|
|
1148
|
-
(a.state === "running" || a.state === "stopped"),
|
|
1149
|
-
);
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
const rehydrateOrSpawn = async () => {
|
|
1153
|
-
if (priors.length > 0) {
|
|
1154
|
-
// Parent-first ordering so a child's `resume()` sees its parent
|
|
1155
|
-
// already back (lineage bookkeeping, inbox subscriptions). Depth
|
|
1156
|
-
// = lineage.length: roots are 0, direct children of roots are 1.
|
|
1157
|
-
const byDepth = new Map<number, typeof priors>();
|
|
1158
|
-
for (const p of priors) {
|
|
1159
|
-
const d = p.lineage.length;
|
|
1160
|
-
if (!byDepth.has(d)) byDepth.set(d, []);
|
|
1161
|
-
byDepth.get(d)!.push(p);
|
|
1162
|
-
}
|
|
1163
|
-
const depths = Array.from(byDepth.keys()).sort((a, b) => a - b);
|
|
1164
|
-
|
|
1165
|
-
const priorIds = new Set(priors.map((p) => p.id));
|
|
1166
|
-
const resumed = new Set<string>();
|
|
1167
|
-
const failed = new Set<string>();
|
|
1168
|
-
|
|
1169
|
-
// Stagger spawns — each resume fires a Claude Code subprocess and
|
|
1170
|
-
// we don't want a coordinator + five workers all booting at once.
|
|
1171
|
-
const CONCURRENCY = 2;
|
|
1172
|
-
|
|
1173
|
-
for (const depth of depths) {
|
|
1174
|
-
const atDepth = byDepth.get(depth)!;
|
|
1175
|
-
const eligible = atDepth.filter((a) => {
|
|
1176
|
-
if (!a.parent_id) return true; // roots are always eligible
|
|
1177
|
-
// Skip children whose parent isn't being revived at all
|
|
1178
|
-
// (deliberately stopped, or out of scope for this policy).
|
|
1179
|
-
if (!priorIds.has(a.parent_id)) {
|
|
1180
|
-
console.warn(
|
|
1181
|
-
`[boot-v2] Skipping ${a.role} ${a.id}: parent ${a.parent_id} not in revival set`,
|
|
1182
|
-
);
|
|
1183
|
-
return false;
|
|
1184
|
-
}
|
|
1185
|
-
// Skip children whose parent resume failed.
|
|
1186
|
-
if (failed.has(a.parent_id)) {
|
|
1187
|
-
console.warn(
|
|
1188
|
-
`[boot-v2] Skipping ${a.role} ${a.id}: parent ${a.parent_id} failed to resume`,
|
|
1189
|
-
);
|
|
1190
|
-
return false;
|
|
1191
|
-
}
|
|
1192
|
-
return resumed.has(a.parent_id);
|
|
1193
|
-
});
|
|
1194
|
-
|
|
1195
|
-
for (let i = 0; i < eligible.length; i += CONCURRENCY) {
|
|
1196
|
-
const batch = eligible.slice(i, i + CONCURRENCY);
|
|
1197
|
-
await Promise.all(
|
|
1198
|
-
batch.map(async (prior) => {
|
|
1199
|
-
try {
|
|
1200
|
-
const r = await agentManager.resume(prior.id);
|
|
1201
|
-
resumed.add(prior.id);
|
|
1202
|
-
console.log(
|
|
1203
|
-
`[boot-v2] Rehydrated ${prior.role}: ${(r as any).name ?? r.id} at ${prior.cwd}`,
|
|
1204
|
-
);
|
|
1205
|
-
} catch (err) {
|
|
1206
|
-
const msg = (err as Error).message;
|
|
1207
|
-
if (/ALREADY_RUNNING/i.test(msg)) {
|
|
1208
|
-
// Rare lifecycle race — treat as success so children
|
|
1209
|
-
// aren't held back waiting on a parent that's actually
|
|
1210
|
-
// already alive.
|
|
1211
|
-
resumed.add(prior.id);
|
|
1212
|
-
} else {
|
|
1213
|
-
failed.add(prior.id);
|
|
1214
|
-
console.warn(
|
|
1215
|
-
`[boot-v2] Failed to rehydrate ${prior.role} ${prior.id}: ${msg}`,
|
|
1216
|
-
);
|
|
1217
|
-
}
|
|
1218
|
-
}
|
|
1219
|
-
}),
|
|
1220
|
-
);
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
return;
|
|
1224
|
-
}
|
|
1225
|
-
// No priors matched the policy → fresh spawn (first boot, or 'none').
|
|
1226
|
-
// dispatchTarget mode: bake askForAllTools + permissionMode='interactive'
|
|
1227
|
-
// into the spawn so the SDK funnels every tool call through canUseTool
|
|
1228
|
-
// and acp-factory emits permission_request session updates the prompt
|
|
1229
|
-
// iterator's overlay-enforcement path can consume.
|
|
1230
|
-
const isDispatchTarget = opts.dispatchTarget === true;
|
|
1231
|
-
const spawned = await agentManager.spawn({
|
|
1232
|
-
role: "coordinator",
|
|
1233
|
-
parent: null,
|
|
1234
|
-
cwd: bootstrapCwd,
|
|
1235
|
-
task: opts.task ?? "Default coordinator (auto-spawn on boot)",
|
|
1236
|
-
permissionMode: isDispatchTarget
|
|
1237
|
-
? "interactive"
|
|
1238
|
-
: opts.permissionMode,
|
|
1239
|
-
agentType: opts.agentType,
|
|
1240
|
-
customPrompt: opts.customPrompt,
|
|
1241
|
-
...(isDispatchTarget ? { askForAllTools: true } : {}),
|
|
1242
|
-
});
|
|
1243
|
-
console.log(
|
|
1244
|
-
`[boot-v2] Bootstrap coordinator spawned: ${(spawned as any).name ?? spawned.id} at ${bootstrapCwd}`,
|
|
1245
|
-
);
|
|
1246
|
-
|
|
1247
|
-
// Optional: bootstrap an additional worker for live tests
|
|
1248
|
-
// exercising mail+reuse semantics. Spawned with parent=null
|
|
1249
|
-
// because:
|
|
1250
|
-
// - The role-capability check only fires for parented spawns
|
|
1251
|
-
// (agent-manager-v2 line 559-572); bypassing it lets us use
|
|
1252
|
-
// a custom role (e.g., 'reuse-target') that doesn't collide
|
|
1253
|
-
// with the sidecar's projected 'worker' in the hub-side
|
|
1254
|
-
// dispatch roster.
|
|
1255
|
-
// - The worker's done() lifecycle is the same as the bootstrap
|
|
1256
|
-
// coord's: terminate cleanly. Phase 2C's `_lastSummary`
|
|
1257
|
-
// fallback (handlers-v2 + mail-inbound-reuse-consumer)
|
|
1258
|
-
// ensures the dispatch reply path recovers the summary from
|
|
1259
|
-
// metadata even if the prompt iterator's update stream races
|
|
1260
|
-
// the ACP connection close on terminate.
|
|
1261
|
-
if (config.bootstrap?.worker) {
|
|
1262
|
-
const workerOpts = config.bootstrap.worker === true
|
|
1263
|
-
? {}
|
|
1264
|
-
: config.bootstrap.worker;
|
|
1265
|
-
const workerRole = workerOpts.role ?? "reuse-target";
|
|
1266
|
-
try {
|
|
1267
|
-
const workerSpawned = await agentManager.spawn({
|
|
1268
|
-
role: workerRole,
|
|
1269
|
-
parent: null,
|
|
1270
|
-
cwd: bootstrapCwd,
|
|
1271
|
-
task: workerOpts.task ?? "Await dispatch",
|
|
1272
|
-
// Funnel every tool call through the host so the prompt-iterator
|
|
1273
|
-
// handler can apply per-dispatch overlay deny rules at runtime
|
|
1274
|
-
// (Phase 3). Two layers must both be set:
|
|
1275
|
-
// - askForAllTools=true → settings.permissions.ask=['*'] so
|
|
1276
|
-
// the Claude SDK actually consults canUseTool for every
|
|
1277
|
-
// tool (without this, default mode auto-approves "safe"
|
|
1278
|
-
// tools like Read).
|
|
1279
|
-
// - permissionMode='interactive' → acp-factory emits the
|
|
1280
|
-
// resulting requestPermission as a `permission_request`
|
|
1281
|
-
// session update instead of auto-approving it (which is
|
|
1282
|
-
// macro-agent's default 'auto-approve' behavior).
|
|
1283
|
-
// Bootstrap dispatch targets are autonomous + latency-tolerant
|
|
1284
|
-
// so the per-call host roundtrip is acceptable.
|
|
1285
|
-
askForAllTools: true,
|
|
1286
|
-
permissionMode: "interactive",
|
|
1287
|
-
});
|
|
1288
|
-
console.log(
|
|
1289
|
-
`[boot-v2] Bootstrap dispatch-target spawned: ${(workerSpawned as any).name ?? workerSpawned.id} ` +
|
|
1290
|
-
`(role=${workerRole}, parent=null)`,
|
|
1291
|
-
);
|
|
1292
|
-
} catch (err) {
|
|
1293
|
-
console.warn(
|
|
1294
|
-
`[boot-v2] Bootstrap worker spawn failed: ${(err as Error).message}`,
|
|
1295
|
-
);
|
|
1296
|
-
}
|
|
1297
|
-
}
|
|
1298
|
-
};
|
|
1299
|
-
|
|
1300
|
-
rehydrateOrSpawn().catch((err: Error) => {
|
|
1301
|
-
console.warn(
|
|
1302
|
-
`[boot-v2] Bootstrap coordinator init failed: ${err.message}`,
|
|
1303
|
-
);
|
|
1304
|
-
});
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
// 14. Return system handle
|
|
1308
|
-
return {
|
|
1309
|
-
agentManager,
|
|
1310
|
-
agentStore,
|
|
1311
|
-
inboxAdapter,
|
|
1312
|
-
tasksAdapter,
|
|
1313
|
-
triggerSystem,
|
|
1314
|
-
controlServer,
|
|
1315
|
-
roleRegistry,
|
|
1316
|
-
controlSocketPath,
|
|
1317
|
-
...(taskDispatcher ? { taskDispatcher } : {}),
|
|
1318
|
-
...(apiServer ? { apiServer } : {}),
|
|
1319
|
-
...(acpServer ? { acpServer } : {}),
|
|
1320
|
-
...(mapServerInstance ? { mapServerInstance } : {}),
|
|
1321
|
-
...(mapSidecar ? { mapSidecar } : {}),
|
|
1322
|
-
_sessionlogSyncLevel:
|
|
1323
|
-
config.sessionlog?.sync ?? config.map?.trajectorySyncLevel ?? "full",
|
|
1324
|
-
|
|
1325
|
-
async shutdown(): Promise<void> {
|
|
1326
|
-
clearInterval(healthCheckTimer);
|
|
1327
|
-
if (mailInboundConsumer) mailInboundConsumer.stop();
|
|
1328
|
-
if (mailInboundReuseConsumer) mailInboundReuseConsumer.stop();
|
|
1329
|
-
if (taskDispatcher) await taskDispatcher.stop();
|
|
1330
|
-
if (mapSidecar) await mapSidecar.stop();
|
|
1331
|
-
if (mapServerInstance) await mapServerInstance.stop();
|
|
1332
|
-
if (federationCleanup) federationCleanup();
|
|
1333
|
-
if (acpServer) await acpServer.stop();
|
|
1334
|
-
if (apiServer) await apiServer.stop();
|
|
1335
|
-
await controlServer.stop();
|
|
1336
|
-
await triggerSystem.stop();
|
|
1337
|
-
await agentManager.close();
|
|
1338
|
-
tasksAdapter.disconnect();
|
|
1339
|
-
await inboxAdapter.stop();
|
|
1340
|
-
agentStore.close();
|
|
1341
|
-
},
|
|
1342
|
-
};
|
|
1343
|
-
}
|