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/acp/macro-agent.ts
DELETED
|
@@ -1,995 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MacroAgent — ACP Agent implementation for macro-agent.
|
|
3
|
-
*
|
|
4
|
-
* Bridges the ACP protocol to macro-agent's V2 services:
|
|
5
|
-
* - session/new → agentManager.getOrCreateHeadManager()
|
|
6
|
-
* - session/prompt → agentManager.prompt() with streaming
|
|
7
|
-
* - Extension methods → spawn, mount, fork, hierarchy, tasks, etc.
|
|
8
|
-
*
|
|
9
|
-
* @module acp/macro-agent
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import type {
|
|
13
|
-
Agent as ACPAgent,
|
|
14
|
-
InitializeRequest,
|
|
15
|
-
InitializeResponse,
|
|
16
|
-
NewSessionRequest,
|
|
17
|
-
NewSessionResponse,
|
|
18
|
-
LoadSessionRequest,
|
|
19
|
-
LoadSessionResponse,
|
|
20
|
-
PromptRequest,
|
|
21
|
-
PromptResponse,
|
|
22
|
-
AuthenticateRequest,
|
|
23
|
-
AuthenticateResponse,
|
|
24
|
-
CancelNotification,
|
|
25
|
-
SessionNotification,
|
|
26
|
-
SessionUpdate,
|
|
27
|
-
} from "@agentclientprotocol/sdk";
|
|
28
|
-
import type { AgentSideConnection } from "@agentclientprotocol/sdk";
|
|
29
|
-
import { RequestError } from "@agentclientprotocol/sdk";
|
|
30
|
-
import type { ExtendedSessionUpdate, PermissionRequestUpdate } from "acp-factory";
|
|
31
|
-
import type { AgentManager } from "../agent/agent-manager.js";
|
|
32
|
-
import type { InboxAdapter, TasksAdapter } from "../adapters/types.js";
|
|
33
|
-
import type { MacroAgentSystemV2 } from "../boot-v2.js";
|
|
34
|
-
import { SessionMapper } from "./session-mapper.js";
|
|
35
|
-
import { ACPError } from "./types.js";
|
|
36
|
-
import type { MacroAgentInitConfig } from "./types.js";
|
|
37
|
-
import type { TrajectoryCheckpointPayload } from "../map/types.js";
|
|
38
|
-
import { execSync } from "node:child_process";
|
|
39
|
-
|
|
40
|
-
// ─────────────────────────────────────────────────────────────────
|
|
41
|
-
// Configuration
|
|
42
|
-
// ─────────────────────────────────────────────────────────────────
|
|
43
|
-
|
|
44
|
-
export interface MacroAgentConfig {
|
|
45
|
-
system: MacroAgentSystemV2;
|
|
46
|
-
initConfig?: MacroAgentInitConfig;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// ─────────────────────────────────────────────────────────────────
|
|
50
|
-
// Extension method names
|
|
51
|
-
// ─────────────────────────────────────────────────────────────────
|
|
52
|
-
|
|
53
|
-
const SUPPORTED_EXTENSIONS = [
|
|
54
|
-
"_macro/spawnAgent",
|
|
55
|
-
"_macro/getHierarchy",
|
|
56
|
-
"_macro/getTask",
|
|
57
|
-
"_macro/mountAgent",
|
|
58
|
-
"_macro/forkAgent",
|
|
59
|
-
"_macro/resume",
|
|
60
|
-
"_macro/getHistory",
|
|
61
|
-
"_macro/getModels",
|
|
62
|
-
"_macro/respondToPermission",
|
|
63
|
-
"_macro/cancelPermission",
|
|
64
|
-
"_macro/setPermissionMode",
|
|
65
|
-
] as const;
|
|
66
|
-
|
|
67
|
-
const STUBBED_PEER_EXTENSIONS = [
|
|
68
|
-
"_macro/listPeers",
|
|
69
|
-
"_macro/getPeer",
|
|
70
|
-
"_macro/sendToPeer",
|
|
71
|
-
"_macro/subscribePeer",
|
|
72
|
-
"_macro/unsubscribePeer",
|
|
73
|
-
"_macro/getCapabilities",
|
|
74
|
-
"_macro/setCapabilities",
|
|
75
|
-
"_macro/negotiateCapabilities",
|
|
76
|
-
] as const;
|
|
77
|
-
|
|
78
|
-
type SupportedExtension = (typeof SUPPORTED_EXTENSIONS)[number];
|
|
79
|
-
type StubbedExtension = (typeof STUBBED_PEER_EXTENSIONS)[number];
|
|
80
|
-
|
|
81
|
-
// ─────────────────────────────────────────────────────────────────
|
|
82
|
-
// Type Guards
|
|
83
|
-
// ─────────────────────────────────────────────────────────────────
|
|
84
|
-
|
|
85
|
-
/** ACP-standard session update type discriminants. */
|
|
86
|
-
const ACP_SESSION_UPDATE_TYPES = new Set([
|
|
87
|
-
"user_message_chunk",
|
|
88
|
-
"agent_message_chunk",
|
|
89
|
-
"agent_thought_chunk",
|
|
90
|
-
"tool_call",
|
|
91
|
-
"tool_call_update",
|
|
92
|
-
"plan",
|
|
93
|
-
"available_commands_update",
|
|
94
|
-
"current_mode_update",
|
|
95
|
-
"config_option_update",
|
|
96
|
-
"session_info_update",
|
|
97
|
-
]);
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Type guard: returns true if the update is an ACP-standard SessionUpdate
|
|
101
|
-
* (not an acp-factory extension like PermissionRequestUpdate or CompactionUpdate).
|
|
102
|
-
*/
|
|
103
|
-
function isACPSessionUpdate(
|
|
104
|
-
update: ExtendedSessionUpdate,
|
|
105
|
-
): update is SessionUpdate {
|
|
106
|
-
return (
|
|
107
|
-
"sessionUpdate" in update &&
|
|
108
|
-
ACP_SESSION_UPDATE_TYPES.has(
|
|
109
|
-
(update as { sessionUpdate: string }).sessionUpdate,
|
|
110
|
-
)
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Type guard: returns true if the update is a PermissionRequestUpdate
|
|
116
|
-
* from acp-factory (emitted when the agent is in interactive permission mode).
|
|
117
|
-
*/
|
|
118
|
-
function isPermissionRequestUpdate(
|
|
119
|
-
update: ExtendedSessionUpdate,
|
|
120
|
-
): update is PermissionRequestUpdate {
|
|
121
|
-
return (
|
|
122
|
-
"sessionUpdate" in update &&
|
|
123
|
-
(update as { sessionUpdate: string }).sessionUpdate === "permission_request"
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// ─────────────────────────────────────────────────────────────────
|
|
128
|
-
// Factory
|
|
129
|
-
// ─────────────────────────────────────────────────────────────────
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Create a macro-agent ACP handler for an AgentSideConnection.
|
|
133
|
-
*
|
|
134
|
-
* Usage:
|
|
135
|
-
* ```ts
|
|
136
|
-
* new AgentSideConnection(
|
|
137
|
-
* (conn) => createMacroAgent(conn, { system }),
|
|
138
|
-
* stream,
|
|
139
|
-
* );
|
|
140
|
-
* ```
|
|
141
|
-
*/
|
|
142
|
-
export function createMacroAgent(
|
|
143
|
-
connection: AgentSideConnection,
|
|
144
|
-
config: MacroAgentConfig,
|
|
145
|
-
): ACPAgent {
|
|
146
|
-
const { system, initConfig } = config;
|
|
147
|
-
const { agentManager, inboxAdapter, tasksAdapter } = system;
|
|
148
|
-
const sessionMapper = new SessionMapper();
|
|
149
|
-
|
|
150
|
-
const defaultCwd = initConfig?.defaultCwd ?? process.cwd();
|
|
151
|
-
|
|
152
|
-
// Per-session state for trajectory tracking
|
|
153
|
-
let checkpointCounter = 0;
|
|
154
|
-
let firstPrompt: string | null = null;
|
|
155
|
-
const sessionStartedAt = new Date().toISOString();
|
|
156
|
-
|
|
157
|
-
// Per-session update history for ACP session/load replay.
|
|
158
|
-
// Per the ACP spec, loadSession should re-emit all session/update notifications
|
|
159
|
-
// previously sent so the client can reconstruct state. We buffer them here
|
|
160
|
-
// keyed by ACP session ID.
|
|
161
|
-
const sessionUpdateHistory = new Map<string, SessionUpdate[]>();
|
|
162
|
-
function appendSessionUpdate(acpSessionId: string, update: SessionUpdate): void {
|
|
163
|
-
const arr = sessionUpdateHistory.get(acpSessionId);
|
|
164
|
-
if (arr) {
|
|
165
|
-
arr.push(update);
|
|
166
|
-
} else {
|
|
167
|
-
sessionUpdateHistory.set(acpSessionId, [update]);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// Git info (cached — read once per session)
|
|
172
|
-
let gitInfo: { branch: string | null; commitHash: string | null; remoteUrl: string | null } | null = null;
|
|
173
|
-
function getGitInfo(cwd: string): { branch: string | null; commitHash: string | null; remoteUrl: string | null } {
|
|
174
|
-
if (gitInfo) return gitInfo;
|
|
175
|
-
try {
|
|
176
|
-
const branch = execSync("git rev-parse --abbrev-ref HEAD", { cwd, timeout: 3000 }).toString().trim() || null;
|
|
177
|
-
const commitHash = execSync("git rev-parse HEAD", { cwd, timeout: 3000 }).toString().trim() || null;
|
|
178
|
-
let remoteUrl: string | null = null;
|
|
179
|
-
try {
|
|
180
|
-
remoteUrl = execSync("git remote get-url origin", { cwd, timeout: 3000 }).toString().trim() || null;
|
|
181
|
-
} catch { /* no remote */ }
|
|
182
|
-
gitInfo = { branch, commitHash, remoteUrl };
|
|
183
|
-
} catch {
|
|
184
|
-
gitInfo = { branch: null, commitHash: null, remoteUrl: null };
|
|
185
|
-
}
|
|
186
|
-
return gitInfo;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// ── Helpers ──────────────────────────────────────────────────
|
|
190
|
-
|
|
191
|
-
function getSessionOrThrow(sessionId: string) {
|
|
192
|
-
const mapping = sessionMapper.getMapping(sessionId);
|
|
193
|
-
if (!mapping) {
|
|
194
|
-
throw RequestError.invalidParams(
|
|
195
|
-
{ sessionId },
|
|
196
|
-
`Session not found: ${sessionId}`,
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
return mapping;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// ── Extension dispatcher ────────────────────────────────────
|
|
203
|
-
|
|
204
|
-
async function handleExtension(
|
|
205
|
-
method: string,
|
|
206
|
-
params: Record<string, unknown>,
|
|
207
|
-
): Promise<Record<string, unknown>> {
|
|
208
|
-
const normalizedMethod = method.startsWith("macro/")
|
|
209
|
-
? `_${method}`
|
|
210
|
-
: method;
|
|
211
|
-
|
|
212
|
-
// Check if it's a stubbed peer method
|
|
213
|
-
if (
|
|
214
|
-
(STUBBED_PEER_EXTENSIONS as readonly string[]).includes(normalizedMethod)
|
|
215
|
-
) {
|
|
216
|
-
throw new ACPError(
|
|
217
|
-
`Peer manager not available: ${normalizedMethod}`,
|
|
218
|
-
"NO_PEER_MANAGER",
|
|
219
|
-
{ method: normalizedMethod },
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
switch (normalizedMethod as SupportedExtension) {
|
|
224
|
-
case "_macro/spawnAgent": {
|
|
225
|
-
const task = params.task as string;
|
|
226
|
-
if (!task) throw RequestError.invalidParams(params, "task is required");
|
|
227
|
-
const spawned = await agentManager.spawn({
|
|
228
|
-
task,
|
|
229
|
-
parent: params.parent as string | undefined,
|
|
230
|
-
cwd: (params.cwd as string) ?? defaultCwd,
|
|
231
|
-
role: params.role as string | undefined,
|
|
232
|
-
permissionMode: params.permissionMode as "auto-approve" | undefined,
|
|
233
|
-
askForAllTools: params.askForAllTools as boolean | undefined,
|
|
234
|
-
});
|
|
235
|
-
return {
|
|
236
|
-
agentId: spawned.id,
|
|
237
|
-
sessionId: spawned.session_id,
|
|
238
|
-
role: spawned.agent.role,
|
|
239
|
-
state: spawned.agent.state,
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
case "_macro/getHierarchy": {
|
|
244
|
-
const agentId = params.agentId as string;
|
|
245
|
-
if (!agentId) throw RequestError.invalidParams(params, "agentId is required");
|
|
246
|
-
const hierarchy = agentManager.getHierarchy(agentId, {
|
|
247
|
-
depth: params.depth as number | undefined,
|
|
248
|
-
});
|
|
249
|
-
return { hierarchy: hierarchy ?? null } as Record<string, unknown>;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
case "_macro/getTask": {
|
|
253
|
-
const taskId = params.taskId as string;
|
|
254
|
-
if (!taskId) throw RequestError.invalidParams(params, "taskId is required");
|
|
255
|
-
const task = await tasksAdapter.getTask(taskId);
|
|
256
|
-
return { task } as Record<string, unknown>;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
case "_macro/mountAgent": {
|
|
260
|
-
const sessionId = params.sessionId as string;
|
|
261
|
-
const agentId = params.agentId as string;
|
|
262
|
-
if (!sessionId || !agentId) {
|
|
263
|
-
throw RequestError.invalidParams(
|
|
264
|
-
params,
|
|
265
|
-
"sessionId and agentId are required",
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// Verify the agent exists
|
|
270
|
-
const agent = agentManager.get(agentId);
|
|
271
|
-
if (!agent) {
|
|
272
|
-
throw new ACPError(
|
|
273
|
-
`Agent not found: ${agentId}`,
|
|
274
|
-
"AGENT_NOT_FOUND",
|
|
275
|
-
{ agentId },
|
|
276
|
-
);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
const previousAgentId = sessionMapper.mount(sessionId, agentId);
|
|
280
|
-
return {
|
|
281
|
-
mounted: true,
|
|
282
|
-
agentId,
|
|
283
|
-
previousAgentId: previousAgentId ?? null,
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
case "_macro/forkAgent": {
|
|
288
|
-
const sourceAgentId = params.sourceAgentId as string;
|
|
289
|
-
if (!sourceAgentId) {
|
|
290
|
-
throw RequestError.invalidParams(params, "sourceAgentId is required");
|
|
291
|
-
}
|
|
292
|
-
try {
|
|
293
|
-
const forked = await agentManager.forkAgent(sourceAgentId, {
|
|
294
|
-
name: params.name as string | undefined,
|
|
295
|
-
prompt: params.prompt as string | undefined,
|
|
296
|
-
cwd: params.cwd as string | undefined,
|
|
297
|
-
});
|
|
298
|
-
return {
|
|
299
|
-
agentId: forked.id,
|
|
300
|
-
sessionId: forked.session_id,
|
|
301
|
-
};
|
|
302
|
-
} catch (err) {
|
|
303
|
-
throw new ACPError(
|
|
304
|
-
`Fork failed: ${(err as Error).message}`,
|
|
305
|
-
"FORK_FAILED",
|
|
306
|
-
{ sourceAgentId },
|
|
307
|
-
);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
case "_macro/resume": {
|
|
312
|
-
const agentId = params.agentId as string;
|
|
313
|
-
if (!agentId) throw RequestError.invalidParams(params, "agentId is required");
|
|
314
|
-
const resumed = await agentManager.resume(agentId);
|
|
315
|
-
return {
|
|
316
|
-
agentId: resumed.id,
|
|
317
|
-
sessionId: resumed.session_id,
|
|
318
|
-
state: resumed.agent.state,
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
case "_macro/getHistory": {
|
|
323
|
-
const agentId = params.agentId as string;
|
|
324
|
-
if (!agentId) throw RequestError.invalidParams(params, "agentId is required");
|
|
325
|
-
|
|
326
|
-
if (params.threadTag) {
|
|
327
|
-
const thread = await inboxAdapter.readThread(
|
|
328
|
-
params.threadTag as string,
|
|
329
|
-
params.scope as string | undefined,
|
|
330
|
-
);
|
|
331
|
-
return { messages: thread };
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
const messages = await inboxAdapter.checkInbox(agentId, {
|
|
335
|
-
limit: params.limit as number | undefined,
|
|
336
|
-
});
|
|
337
|
-
return { messages };
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
case "_macro/getModels": {
|
|
341
|
-
// Models are not centrally tracked; return empty
|
|
342
|
-
return { models: [] };
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
case "_macro/respondToPermission": {
|
|
346
|
-
const agentId = params.agentId as string;
|
|
347
|
-
const requestId = params.requestId as string;
|
|
348
|
-
const optionId = params.optionId as string;
|
|
349
|
-
if (!agentId || !requestId || !optionId) {
|
|
350
|
-
throw RequestError.invalidParams(
|
|
351
|
-
params,
|
|
352
|
-
"agentId, requestId, and optionId are required",
|
|
353
|
-
);
|
|
354
|
-
}
|
|
355
|
-
const success = agentManager.respondToPermission(
|
|
356
|
-
agentId,
|
|
357
|
-
requestId,
|
|
358
|
-
optionId,
|
|
359
|
-
);
|
|
360
|
-
return { success };
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
case "_macro/cancelPermission": {
|
|
364
|
-
const agentId = params.agentId as string;
|
|
365
|
-
const requestId = params.requestId as string;
|
|
366
|
-
if (!agentId || !requestId) {
|
|
367
|
-
throw RequestError.invalidParams(
|
|
368
|
-
params,
|
|
369
|
-
"agentId and requestId are required",
|
|
370
|
-
);
|
|
371
|
-
}
|
|
372
|
-
const success = agentManager.cancelPermission(agentId, requestId);
|
|
373
|
-
return { success };
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
case "_macro/setPermissionMode": {
|
|
377
|
-
const agentId = params.agentId as string;
|
|
378
|
-
const mode = params.mode as string;
|
|
379
|
-
if (!agentId || !mode) {
|
|
380
|
-
throw RequestError.invalidParams(
|
|
381
|
-
params,
|
|
382
|
-
"agentId and mode are required",
|
|
383
|
-
);
|
|
384
|
-
}
|
|
385
|
-
const success = agentManager.setPermissionMode(
|
|
386
|
-
agentId,
|
|
387
|
-
mode as "auto-approve",
|
|
388
|
-
);
|
|
389
|
-
return { success };
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
default:
|
|
393
|
-
throw new ACPError(
|
|
394
|
-
`Unknown extension: ${method}`,
|
|
395
|
-
"INVALID_EXTENSION",
|
|
396
|
-
{ method },
|
|
397
|
-
);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
// ── ACP Agent Implementation ────────────────────────────────
|
|
402
|
-
|
|
403
|
-
const agent: ACPAgent = {
|
|
404
|
-
async initialize(
|
|
405
|
-
_params: InitializeRequest,
|
|
406
|
-
): Promise<InitializeResponse> {
|
|
407
|
-
return {
|
|
408
|
-
protocolVersion: 1,
|
|
409
|
-
agentInfo: {
|
|
410
|
-
name: "macro-agent",
|
|
411
|
-
version: "2.0.0",
|
|
412
|
-
},
|
|
413
|
-
agentCapabilities: {
|
|
414
|
-
loadSession: true,
|
|
415
|
-
sessionCapabilities: {
|
|
416
|
-
resume: {},
|
|
417
|
-
},
|
|
418
|
-
},
|
|
419
|
-
extensions: [
|
|
420
|
-
...SUPPORTED_EXTENSIONS.map((name) => ({
|
|
421
|
-
name,
|
|
422
|
-
description: `macro-agent extension: ${name}`,
|
|
423
|
-
})),
|
|
424
|
-
...STUBBED_PEER_EXTENSIONS.map((name) => ({
|
|
425
|
-
name,
|
|
426
|
-
description: `Peer extension (stub): ${name}`,
|
|
427
|
-
})),
|
|
428
|
-
],
|
|
429
|
-
} as InitializeResponse;
|
|
430
|
-
},
|
|
431
|
-
|
|
432
|
-
async newSession(
|
|
433
|
-
params: NewSessionRequest,
|
|
434
|
-
): Promise<NewSessionResponse> {
|
|
435
|
-
const cwd = params.cwd ?? defaultCwd;
|
|
436
|
-
|
|
437
|
-
// Two paths into newSession:
|
|
438
|
-
//
|
|
439
|
-
// 1. MAP-bound stream — initConfig.targetAgentId is set by the ACP
|
|
440
|
-
// bridge to the local agent ID this stream was opened against.
|
|
441
|
-
// Bind the session to that specific agent (any role), preserving
|
|
442
|
-
// the routing intent that brought the stream here. This matters
|
|
443
|
-
// when multiple coordinators share a cwd: cwd-based lookup would
|
|
444
|
-
// pick whichever the store returned first, which may not be the
|
|
445
|
-
// one the client actually wanted to talk to.
|
|
446
|
-
//
|
|
447
|
-
// 2. Fallback — pure ACP client with no agent context. Use
|
|
448
|
-
// cwd-based head-manager lookup (spawning one if needed). This
|
|
449
|
-
// keeps stock ACP clients working without protocol changes.
|
|
450
|
-
let target: { id: string; session_id: string };
|
|
451
|
-
if (initConfig?.targetAgentId) {
|
|
452
|
-
const bound = agentManager.getActiveAgentSession(
|
|
453
|
-
initConfig.targetAgentId as any,
|
|
454
|
-
);
|
|
455
|
-
if (!bound) {
|
|
456
|
-
throw new ACPError(
|
|
457
|
-
`Agent ${initConfig.targetAgentId} is not running or has no active session`,
|
|
458
|
-
"AGENT_NOT_FOUND",
|
|
459
|
-
{ agentId: initConfig.targetAgentId },
|
|
460
|
-
);
|
|
461
|
-
}
|
|
462
|
-
target = { id: bound.id, session_id: bound.session_id };
|
|
463
|
-
} else {
|
|
464
|
-
const headManager = await agentManager.getOrCreateHeadManager({ cwd });
|
|
465
|
-
target = { id: headManager.id, session_id: headManager.session_id };
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
// Create session mapping
|
|
469
|
-
const mapping = sessionMapper.createMapping(target.session_id, target.id);
|
|
470
|
-
|
|
471
|
-
// Annotate sessionlog with swarm metadata (best effort)
|
|
472
|
-
try {
|
|
473
|
-
const { annotateSession } = await import("../integrations/sessionlog.js");
|
|
474
|
-
annotateSession(cwd, {
|
|
475
|
-
swarmId: target.id,
|
|
476
|
-
scope: "macro-agent",
|
|
477
|
-
});
|
|
478
|
-
} catch {
|
|
479
|
-
// sessionlog not available — non-fatal
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
return {
|
|
483
|
-
sessionId: mapping.acpSessionId,
|
|
484
|
-
};
|
|
485
|
-
},
|
|
486
|
-
|
|
487
|
-
async loadSession(
|
|
488
|
-
params: LoadSessionRequest,
|
|
489
|
-
): Promise<LoadSessionResponse> {
|
|
490
|
-
const sessionId = params.sessionId;
|
|
491
|
-
|
|
492
|
-
/**
|
|
493
|
-
* Resolve the provider_session_id (Claude Code's UUID for the session)
|
|
494
|
-
* for a given macro-agent acp session. Needed to locate the JSONL
|
|
495
|
-
* transcript on disk as a fallback when the in-memory buffer is empty.
|
|
496
|
-
*/
|
|
497
|
-
const resolveProviderSessionId = (agentId: string): string | undefined => {
|
|
498
|
-
const store = (system as any).agentStore;
|
|
499
|
-
const rec = store?.getAgent?.(agentId);
|
|
500
|
-
const meta = rec?.metadata as Record<string, unknown> | undefined;
|
|
501
|
-
const psid = meta?.provider_session_id;
|
|
502
|
-
return typeof psid === "string" ? psid : undefined;
|
|
503
|
-
};
|
|
504
|
-
|
|
505
|
-
// Replay helper: re-emit session/update notifications so the client can
|
|
506
|
-
// rebuild its view of the conversation. Per the ACP spec, loadSession
|
|
507
|
-
// SHOULD emit all previously-sent session/update events.
|
|
508
|
-
//
|
|
509
|
-
// Two sources in priority order:
|
|
510
|
-
// 1. In-memory buffer (populated by prior prompts in this process).
|
|
511
|
-
// Fast and accurate — exactly what was streamed to the client.
|
|
512
|
-
// 2. Claude Code's JSONL transcript on disk (durable across restarts).
|
|
513
|
-
// Used when the buffer is empty — e.g., we got a loadSession for a
|
|
514
|
-
// session that was prompted but whose updates were never buffered,
|
|
515
|
-
// or after a process restart within the same session's lifetime.
|
|
516
|
-
//
|
|
517
|
-
// This is a workaround: the ACP spec expects the underlying agent
|
|
518
|
-
// (claude-code-acp) to emit session/update during loadSession, but its
|
|
519
|
-
// current implementation only passes `resume: sessionId` to Claude Code
|
|
520
|
-
// SDK for internal context restoration without surfacing history to the
|
|
521
|
-
// client. See claude-code-replay.ts for details.
|
|
522
|
-
const replayHistory = async (agentIdForLookup?: string, explicitProviderSessionId?: string): Promise<void> => {
|
|
523
|
-
const buffered = sessionUpdateHistory.get(sessionId);
|
|
524
|
-
if (buffered && buffered.length > 0) {
|
|
525
|
-
for (const update of buffered) {
|
|
526
|
-
try {
|
|
527
|
-
await connection.sessionUpdate({ sessionId, update });
|
|
528
|
-
} catch {
|
|
529
|
-
// Best effort — continue replaying remaining updates
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
return;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
// Buffer empty — fall back to Claude Code JSONL if we can locate it.
|
|
536
|
-
// Provider session ID resolution priority:
|
|
537
|
-
// 1. Explicit — passed via ACP LoadSessionRequest._meta.provider_session_id
|
|
538
|
-
// (survives macro-agent restart since it comes from the client)
|
|
539
|
-
// 2. From agent metadata — when sessionMapper still has the mapping
|
|
540
|
-
const providerSessionId =
|
|
541
|
-
explicitProviderSessionId ??
|
|
542
|
-
(agentIdForLookup ? resolveProviderSessionId(agentIdForLookup) : undefined);
|
|
543
|
-
if (!providerSessionId) return;
|
|
544
|
-
|
|
545
|
-
try {
|
|
546
|
-
const { replayClaudeCodeTranscript } = await import("./claude-code-replay.js");
|
|
547
|
-
const bufferForFuture: SessionUpdate[] = [];
|
|
548
|
-
for await (const update of replayClaudeCodeTranscript(providerSessionId)) {
|
|
549
|
-
try {
|
|
550
|
-
await connection.sessionUpdate({ sessionId, update });
|
|
551
|
-
bufferForFuture.push(update);
|
|
552
|
-
} catch {
|
|
553
|
-
// Best effort — continue
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
// Populate the in-memory buffer so subsequent loadSession calls use
|
|
557
|
-
// the fast path. Only if we actually read something.
|
|
558
|
-
if (bufferForFuture.length > 0) {
|
|
559
|
-
sessionUpdateHistory.set(sessionId, bufferForFuture);
|
|
560
|
-
}
|
|
561
|
-
} catch {
|
|
562
|
-
// Transcript read failed — no history to emit
|
|
563
|
-
}
|
|
564
|
-
};
|
|
565
|
-
|
|
566
|
-
// Extract optional provider_session_id from ACP LoadSessionRequest._meta.
|
|
567
|
-
// Clients (like OpenHive) that know the underlying Claude Code session ID
|
|
568
|
-
// can pass it here to enable history recovery across macro-agent restarts
|
|
569
|
-
// (when sessionMapper is empty because it's in-memory only).
|
|
570
|
-
const metaProviderSessionId =
|
|
571
|
-
typeof (params as any)._meta?.provider_session_id === "string"
|
|
572
|
-
? ((params as any)._meta.provider_session_id as string)
|
|
573
|
-
: undefined;
|
|
574
|
-
|
|
575
|
-
// Check if we already have a mapping for this session
|
|
576
|
-
let mapping = sessionMapper.getMapping(sessionId);
|
|
577
|
-
if (mapping) {
|
|
578
|
-
await replayHistory(mapping.agentId, metaProviderSessionId);
|
|
579
|
-
return {};
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
// Try to resume the agent associated with this session
|
|
583
|
-
// The session ID might be an agent ID in our system
|
|
584
|
-
const agent = agentManager.get(sessionId);
|
|
585
|
-
if (agent) {
|
|
586
|
-
const resumed = await agentManager.resume(sessionId);
|
|
587
|
-
mapping = sessionMapper.createMapping(
|
|
588
|
-
resumed.session_id,
|
|
589
|
-
resumed.id,
|
|
590
|
-
);
|
|
591
|
-
await replayHistory(resumed.id, metaProviderSessionId);
|
|
592
|
-
return {};
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
// No in-memory mapping and the ACP sessionId isn't an agent ID. If the
|
|
596
|
-
// client supplied provider_session_id via _meta, reverse-lookup the
|
|
597
|
-
// owning agent in the agent-store and resume it. This is the durable
|
|
598
|
-
// cross-restart recovery path: macro-agent's sessionMapper is
|
|
599
|
-
// in-memory, so after a process restart it's empty, but the agent +
|
|
600
|
-
// session records survive on disk keyed by provider_session_id.
|
|
601
|
-
//
|
|
602
|
-
// The critical piece is creating the sessionMapper entry here — without
|
|
603
|
-
// it, subsequent `prompt` calls throw `session not found` and the ACP
|
|
604
|
-
// layer catches that and returns stopReason:"cancelled", making the
|
|
605
|
-
// session appear unresponsive.
|
|
606
|
-
if (metaProviderSessionId) {
|
|
607
|
-
const store = (system as any).agentStore;
|
|
608
|
-
const sessionRec = typeof store?.findSessionByProviderSessionId === "function"
|
|
609
|
-
? store.findSessionByProviderSessionId(metaProviderSessionId)
|
|
610
|
-
: undefined;
|
|
611
|
-
if (sessionRec?.agent_id) {
|
|
612
|
-
const agentId = sessionRec.agent_id;
|
|
613
|
-
try {
|
|
614
|
-
// Idempotent: resume() throws ALREADY_RUNNING if the agent is
|
|
615
|
-
// already active (e.g. _macro/resumeAgent just brought it back).
|
|
616
|
-
// We still need to bind the ACP session to this agent.
|
|
617
|
-
if (!agentManager.hasActiveSession(agentId as any)) {
|
|
618
|
-
await agentManager.resume(agentId as any);
|
|
619
|
-
}
|
|
620
|
-
// Bind under BOTH the macro-agent ACP sessionId AND the provider
|
|
621
|
-
// session UUID. The MAP SDK's ACPStreamConnection often ends up
|
|
622
|
-
// storing _meta.provider_session_id as its stream.sessionId —
|
|
623
|
-
// which is what swarmcraft echoes back in session/prompt. Without
|
|
624
|
-
// the UUID mapping, prompt hits sessionMapper with the UUID key
|
|
625
|
-
// and fails (→ stopReason: cancelled).
|
|
626
|
-
sessionMapper.createMapping(sessionId, agentId);
|
|
627
|
-
if (metaProviderSessionId !== sessionId) {
|
|
628
|
-
sessionMapper.createMapping(metaProviderSessionId as any, agentId);
|
|
629
|
-
}
|
|
630
|
-
await replayHistory(agentId, metaProviderSessionId);
|
|
631
|
-
return {};
|
|
632
|
-
} catch {
|
|
633
|
-
// Fall through to history-only replay below
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
await replayHistory(undefined, metaProviderSessionId);
|
|
637
|
-
return {};
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
throw RequestError.invalidParams(
|
|
641
|
-
{ sessionId },
|
|
642
|
-
`Session not found: ${sessionId}`,
|
|
643
|
-
);
|
|
644
|
-
},
|
|
645
|
-
|
|
646
|
-
async authenticate(
|
|
647
|
-
_params: AuthenticateRequest,
|
|
648
|
-
): Promise<AuthenticateResponse> {
|
|
649
|
-
// No-op: macro-agent does not require authentication
|
|
650
|
-
return {};
|
|
651
|
-
},
|
|
652
|
-
|
|
653
|
-
async prompt(params: PromptRequest): Promise<PromptResponse> {
|
|
654
|
-
const mapping = getSessionOrThrow(params.sessionId);
|
|
655
|
-
const agentId = mapping.agentId;
|
|
656
|
-
|
|
657
|
-
// Extract text content from prompt blocks
|
|
658
|
-
const textParts: string[] = [];
|
|
659
|
-
for (const block of params.prompt) {
|
|
660
|
-
if ("text" in block && typeof block.text === "string") {
|
|
661
|
-
textParts.push(block.text);
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
const message = textParts.join("\n") || "";
|
|
665
|
-
|
|
666
|
-
// Record the user prompt as a user_message_chunk update in the replay
|
|
667
|
-
// buffer so session/load can reconstruct the full conversation. The
|
|
668
|
-
// agent itself doesn't emit this — the client sent it — but it IS part
|
|
669
|
-
// of the session's logical state.
|
|
670
|
-
for (const block of params.prompt) {
|
|
671
|
-
if ("text" in block && typeof block.text === "string" && block.text) {
|
|
672
|
-
const userChunk = {
|
|
673
|
-
sessionUpdate: "user_message_chunk",
|
|
674
|
-
content: { type: "text", text: block.text },
|
|
675
|
-
} as unknown as SessionUpdate;
|
|
676
|
-
appendSessionUpdate(params.sessionId, userChunk);
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
sessionMapper.setProcessing(params.sessionId, true);
|
|
681
|
-
|
|
682
|
-
// Capture first prompt for trajectory metadata (used as session description in OpenHive UI)
|
|
683
|
-
if (!firstPrompt) {
|
|
684
|
-
firstPrompt = message.slice(0, 200);
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
// Track data for trajectory checkpoint
|
|
688
|
-
const filesTouched = new Set<string>();
|
|
689
|
-
let toolCallCount = 0;
|
|
690
|
-
const promptStartTime = Date.now();
|
|
691
|
-
let tokenUsage = { input_tokens: 0, output_tokens: 0, cache_read_tokens: 0, cache_creation_tokens: 0 };
|
|
692
|
-
|
|
693
|
-
// Update agent state to "busy" — both local MAP server and upstream sidecar
|
|
694
|
-
try {
|
|
695
|
-
const mapServer = (system as any).mapServerInstance;
|
|
696
|
-
if (mapServer) {
|
|
697
|
-
const agents = mapServer.agents?.list?.() ?? [];
|
|
698
|
-
const mapAgent = agents.find(
|
|
699
|
-
(a: any) => a.metadata?.peerAgentId === agentId,
|
|
700
|
-
);
|
|
701
|
-
if (mapAgent) {
|
|
702
|
-
mapServer.agents.updateState(mapAgent.id, "busy");
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
} catch { /* best effort */ }
|
|
706
|
-
|
|
707
|
-
// Update upstream sidecar state (so OpenHive sees activity)
|
|
708
|
-
try {
|
|
709
|
-
const sidecarConn = (system as any).mapSidecar;
|
|
710
|
-
if (sidecarConn?.connected) {
|
|
711
|
-
// The sidecar's underlying AgentConnection has updateState
|
|
712
|
-
// but it's not directly exposed. Emit via the eventBus instead.
|
|
713
|
-
}
|
|
714
|
-
} catch { /* best effort */ }
|
|
715
|
-
|
|
716
|
-
try {
|
|
717
|
-
// Stream updates from agentManager.prompt()
|
|
718
|
-
const updates = agentManager.prompt(agentId, message);
|
|
719
|
-
|
|
720
|
-
for await (const update of updates) {
|
|
721
|
-
// Track tool calls, files, and token usage for trajectory checkpoint.
|
|
722
|
-
// Also emit task bridge events for TaskCreate/TaskUpdate tool calls.
|
|
723
|
-
if ("sessionUpdate" in update) {
|
|
724
|
-
const su = update as any;
|
|
725
|
-
if (su.sessionUpdate === "tool_call") {
|
|
726
|
-
toolCallCount++;
|
|
727
|
-
const input = su.rawInput as Record<string, unknown> | undefined;
|
|
728
|
-
if (input?.file_path) filesTouched.add(input.file_path as string);
|
|
729
|
-
if (input?.filePath) filesTouched.add(input.filePath as string);
|
|
730
|
-
if (input?.path) filesTouched.add(input.path as string);
|
|
731
|
-
if (input?.command) filesTouched.add(`[bash] ${(input.command as string).slice(0, 50)}`);
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
// Track token usage from session info updates
|
|
735
|
-
if (su.sessionUpdate === "session_info_update" && su.usage) {
|
|
736
|
-
const u = su.usage;
|
|
737
|
-
if (u.inputTokens) tokenUsage.input_tokens += u.inputTokens;
|
|
738
|
-
if (u.outputTokens) tokenUsage.output_tokens += u.outputTokens;
|
|
739
|
-
if (u.cacheReadTokens) tokenUsage.cache_read_tokens += u.cacheReadTokens;
|
|
740
|
-
if (u.cacheCreationTokens) tokenUsage.cache_creation_tokens += u.cacheCreationTokens;
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
// Bridge tool call completions to MAP events
|
|
744
|
-
if (su.sessionUpdate === "tool_call_update" && su.output !== undefined) {
|
|
745
|
-
const toolName = su.title ?? "";
|
|
746
|
-
const sidecar = (system as any).mapSidecar;
|
|
747
|
-
if (sidecar?.connected && toolName) {
|
|
748
|
-
try {
|
|
749
|
-
// Native task lifecycle events
|
|
750
|
-
if (toolName === "TaskCreate" || toolName.includes("TaskCreate")) {
|
|
751
|
-
const taskData = typeof su.output === "string"
|
|
752
|
-
? JSON.parse(su.output) : su.output;
|
|
753
|
-
sidecar.reportCheckpoint?.({
|
|
754
|
-
id: `task-created-${Date.now()}`,
|
|
755
|
-
session_id: params.sessionId,
|
|
756
|
-
agent: agentId,
|
|
757
|
-
branch: null,
|
|
758
|
-
files_touched: [],
|
|
759
|
-
checkpoints_count: checkpointCounter,
|
|
760
|
-
metadata: { phase: "active", event: "task.created", task: taskData },
|
|
761
|
-
}).catch(() => {});
|
|
762
|
-
} else if (toolName === "TaskUpdate" || toolName.includes("TaskUpdate")) {
|
|
763
|
-
const taskData = typeof su.output === "string"
|
|
764
|
-
? JSON.parse(su.output) : su.output;
|
|
765
|
-
sidecar.reportCheckpoint?.({
|
|
766
|
-
id: `task-updated-${Date.now()}`,
|
|
767
|
-
session_id: params.sessionId,
|
|
768
|
-
agent: agentId,
|
|
769
|
-
branch: null,
|
|
770
|
-
files_touched: [],
|
|
771
|
-
checkpoints_count: checkpointCounter,
|
|
772
|
-
metadata: { phase: "active", event: "task.status", task: taskData },
|
|
773
|
-
}).catch(() => {});
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
// Gap 3: Opentasks MCP bridge — bridge opentasks tool calls to MAP events
|
|
777
|
-
else if (toolName === "opentasks__create_task" || toolName.includes("create_task")) {
|
|
778
|
-
const taskData = typeof su.output === "string"
|
|
779
|
-
? JSON.parse(su.output) : su.output;
|
|
780
|
-
sidecar.reportCheckpoint?.({
|
|
781
|
-
id: `opentasks-created-${Date.now()}`,
|
|
782
|
-
session_id: params.sessionId,
|
|
783
|
-
agent: agentId,
|
|
784
|
-
branch: null,
|
|
785
|
-
files_touched: [],
|
|
786
|
-
checkpoints_count: checkpointCounter,
|
|
787
|
-
metadata: { phase: "active", event: "task.created", source: "opentasks", task: taskData },
|
|
788
|
-
}).catch(() => {});
|
|
789
|
-
} else if (toolName === "opentasks__update_task" || toolName.includes("update_task")) {
|
|
790
|
-
const taskData = typeof su.output === "string"
|
|
791
|
-
? JSON.parse(su.output) : su.output;
|
|
792
|
-
sidecar.reportCheckpoint?.({
|
|
793
|
-
id: `opentasks-status-${Date.now()}`,
|
|
794
|
-
session_id: params.sessionId,
|
|
795
|
-
agent: agentId,
|
|
796
|
-
branch: null,
|
|
797
|
-
files_touched: [],
|
|
798
|
-
checkpoints_count: checkpointCounter,
|
|
799
|
-
metadata: { phase: "active", event: "task.status", source: "opentasks", task: taskData },
|
|
800
|
-
}).catch(() => {});
|
|
801
|
-
} else if (toolName === "opentasks__link" || toolName.includes("opentasks") && toolName.includes("link")) {
|
|
802
|
-
const linkData = typeof su.output === "string"
|
|
803
|
-
? JSON.parse(su.output) : su.output;
|
|
804
|
-
sidecar.reportCheckpoint?.({
|
|
805
|
-
id: `opentasks-linked-${Date.now()}`,
|
|
806
|
-
session_id: params.sessionId,
|
|
807
|
-
agent: agentId,
|
|
808
|
-
branch: null,
|
|
809
|
-
files_touched: [],
|
|
810
|
-
checkpoints_count: checkpointCounter,
|
|
811
|
-
metadata: { phase: "active", event: "task.linked", source: "opentasks", link: linkData },
|
|
812
|
-
}).catch(() => {});
|
|
813
|
-
} else if (toolName === "opentasks__annotate" || toolName.includes("opentasks") && toolName.includes("annotate")) {
|
|
814
|
-
const annotateData = typeof su.output === "string"
|
|
815
|
-
? JSON.parse(su.output) : su.output;
|
|
816
|
-
sidecar.reportCheckpoint?.({
|
|
817
|
-
id: `opentasks-sync-${Date.now()}`,
|
|
818
|
-
session_id: params.sessionId,
|
|
819
|
-
agent: agentId,
|
|
820
|
-
branch: null,
|
|
821
|
-
files_touched: [],
|
|
822
|
-
checkpoints_count: checkpointCounter,
|
|
823
|
-
metadata: { phase: "active", event: "task.sync", source: "opentasks", annotation: annotateData },
|
|
824
|
-
}).catch(() => {});
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
// Gap 2: Memory sync — detect minimem write tools
|
|
828
|
-
else if (toolName.includes("memory_append") || toolName.includes("memory_upsert")) {
|
|
829
|
-
sidecar.reportCheckpoint?.({
|
|
830
|
-
id: `memory-sync-${Date.now()}`,
|
|
831
|
-
session_id: params.sessionId,
|
|
832
|
-
agent: agentId,
|
|
833
|
-
branch: null,
|
|
834
|
-
files_touched: [],
|
|
835
|
-
checkpoints_count: checkpointCounter,
|
|
836
|
-
metadata: { phase: "active", event: "memory.sync" },
|
|
837
|
-
}).catch(() => {});
|
|
838
|
-
}
|
|
839
|
-
} catch { /* ignore parse errors */ }
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
// Handle permission requests from the underlying agent.
|
|
845
|
-
// When the agent is in interactive mode, acp-factory yields
|
|
846
|
-
// PermissionRequestUpdate objects. Forward them as session updates
|
|
847
|
-
// instead of AgentSideConnection.requestPermission(): MAP-routed
|
|
848
|
-
// browser clients already consume session/update, and replies come
|
|
849
|
-
// back through _macro/respondToPermission or _macro/cancelPermission.
|
|
850
|
-
if (isPermissionRequestUpdate(update)) {
|
|
851
|
-
const forwardedUpdate = { ...update, _agentId: agentId };
|
|
852
|
-
appendSessionUpdate(params.sessionId, forwardedUpdate as any);
|
|
853
|
-
await connection.sessionUpdate({
|
|
854
|
-
sessionId: params.sessionId,
|
|
855
|
-
update: forwardedUpdate as any,
|
|
856
|
-
});
|
|
857
|
-
continue;
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
// Forward each update to the client as a session notification.
|
|
861
|
-
// Only forward ACP-compatible SessionUpdate types; skip
|
|
862
|
-
// acp-factory extended types like CompactionUpdate.
|
|
863
|
-
if ("sessionUpdate" in update && isACPSessionUpdate(update)) {
|
|
864
|
-
const notification: SessionNotification = {
|
|
865
|
-
sessionId: params.sessionId,
|
|
866
|
-
update,
|
|
867
|
-
};
|
|
868
|
-
// Buffer for replay on session/load. Per the ACP spec, loadSession
|
|
869
|
-
// should re-emit all previously sent session/update notifications
|
|
870
|
-
// so the client can reconstruct state after reconnect.
|
|
871
|
-
appendSessionUpdate(params.sessionId, update);
|
|
872
|
-
await connection.sessionUpdate(notification);
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
// Emit enriched trajectory checkpoint after prompt completes.
|
|
877
|
-
// Matches cc-swarm's wire format so OpenHive UI can display session data.
|
|
878
|
-
const sidecar = (system as any).mapSidecar;
|
|
879
|
-
if (sidecar) {
|
|
880
|
-
checkpointCounter++;
|
|
881
|
-
const agentRecord = (system as any).agentStore?.getAgent?.(agentId);
|
|
882
|
-
const agentCwd = agentRecord?.cwd ?? defaultCwd;
|
|
883
|
-
const git = getGitInfo(agentCwd);
|
|
884
|
-
|
|
885
|
-
// Determine sync level from sessionlog config (default: "full")
|
|
886
|
-
const syncLevel: string = (system as any)._sessionlogSyncLevel ?? "full";
|
|
887
|
-
|
|
888
|
-
// Build checkpoint with sync-level gating:
|
|
889
|
-
// - lifecycle: phase, turnId, startedAt, label
|
|
890
|
-
// - metrics: above + token_usage, files_touched, checkpoints_count, toolCallCount, duration_ms
|
|
891
|
-
// - full: everything
|
|
892
|
-
const isMetrics = syncLevel === "metrics" || syncLevel === "full";
|
|
893
|
-
const isFull = syncLevel === "full";
|
|
894
|
-
|
|
895
|
-
const checkpoint: TrajectoryCheckpointPayload = {
|
|
896
|
-
id: `${params.sessionId}-step${checkpointCounter}`,
|
|
897
|
-
session_id: params.sessionId,
|
|
898
|
-
agent: agentRecord?.name ?? agentId,
|
|
899
|
-
branch: git.branch,
|
|
900
|
-
files_touched: isMetrics ? Array.from(filesTouched) : [],
|
|
901
|
-
checkpoints_count: isMetrics ? checkpointCounter : 0,
|
|
902
|
-
// Token usage — only at metrics level or above
|
|
903
|
-
...(isMetrics && (tokenUsage.input_tokens > 0 || tokenUsage.output_tokens > 0)
|
|
904
|
-
? { token_usage: tokenUsage }
|
|
905
|
-
: {}),
|
|
906
|
-
metadata: {
|
|
907
|
-
// lifecycle fields (always included)
|
|
908
|
-
phase: "active",
|
|
909
|
-
startedAt: sessionStartedAt,
|
|
910
|
-
label: `Step ${checkpointCounter} (${toolCallCount} tool calls)`,
|
|
911
|
-
// Underlying Claude Code session ID — lets OpenHive find the
|
|
912
|
-
// JSONL transcript on disk for history recovery even if the
|
|
913
|
-
// macro-agent process dies.
|
|
914
|
-
provider_session_id:
|
|
915
|
-
(agentRecord as any)?.metadata?.provider_session_id ?? undefined,
|
|
916
|
-
// metrics fields
|
|
917
|
-
...(isMetrics ? {
|
|
918
|
-
duration_ms: Date.now() - promptStartTime,
|
|
919
|
-
toolCallCount,
|
|
920
|
-
} : {}),
|
|
921
|
-
// full fields
|
|
922
|
-
...(isFull ? {
|
|
923
|
-
project: agentCwd.split("/").pop() ?? "",
|
|
924
|
-
projectPath: agentCwd,
|
|
925
|
-
firstPrompt: firstPrompt ?? undefined,
|
|
926
|
-
gitCommitHash: git.commitHash ?? undefined,
|
|
927
|
-
gitRemoteUrl: git.remoteUrl ?? undefined,
|
|
928
|
-
} : {}),
|
|
929
|
-
},
|
|
930
|
-
};
|
|
931
|
-
// Enrich with sessionlog state if available (adds turn IDs, better token usage)
|
|
932
|
-
let enrichedCheckpoint = checkpoint;
|
|
933
|
-
try {
|
|
934
|
-
const { findActiveSession, enrichCheckpoint } = await import("../integrations/sessionlog.js");
|
|
935
|
-
const sessionState = findActiveSession(agentCwd);
|
|
936
|
-
if (sessionState) {
|
|
937
|
-
enrichedCheckpoint = enrichCheckpoint(sessionState, checkpoint);
|
|
938
|
-
}
|
|
939
|
-
} catch {
|
|
940
|
-
// sessionlog not available — use base checkpoint
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
sidecar.reportCheckpoint(enrichedCheckpoint).catch(() => {});
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
return { stopReason: "end_turn" };
|
|
947
|
-
} catch {
|
|
948
|
-
// If prompt fails, still return a valid response
|
|
949
|
-
return { stopReason: "cancelled" };
|
|
950
|
-
} finally {
|
|
951
|
-
sessionMapper.setProcessing(params.sessionId, false);
|
|
952
|
-
|
|
953
|
-
// Update agent state back to "idle" — local MAP server
|
|
954
|
-
try {
|
|
955
|
-
const mapServer = (system as any).mapServerInstance;
|
|
956
|
-
if (mapServer) {
|
|
957
|
-
const agents = mapServer.agents?.list?.() ?? [];
|
|
958
|
-
const mapAgent = agents.find(
|
|
959
|
-
(a: any) => a.metadata?.peerAgentId === agentId,
|
|
960
|
-
);
|
|
961
|
-
if (mapAgent) {
|
|
962
|
-
mapServer.agents.updateState(mapAgent.id, "idle");
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
} catch { /* best effort */ }
|
|
966
|
-
}
|
|
967
|
-
},
|
|
968
|
-
|
|
969
|
-
async cancel(params: CancelNotification): Promise<void> {
|
|
970
|
-
const mapping = sessionMapper.getMapping(params.sessionId);
|
|
971
|
-
if (!mapping) return;
|
|
972
|
-
|
|
973
|
-
try {
|
|
974
|
-
await agentManager.terminate(mapping.agentId, "cancelled");
|
|
975
|
-
} catch {
|
|
976
|
-
// Best effort cancellation
|
|
977
|
-
}
|
|
978
|
-
},
|
|
979
|
-
|
|
980
|
-
async extMethod(
|
|
981
|
-
method: string,
|
|
982
|
-
params: Record<string, unknown>,
|
|
983
|
-
): Promise<Record<string, unknown>> {
|
|
984
|
-
return handleExtension(method, params);
|
|
985
|
-
},
|
|
986
|
-
};
|
|
987
|
-
|
|
988
|
-
return agent;
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
/**
|
|
992
|
-
* Get the SessionMapper instance from a macro-agent.
|
|
993
|
-
* Exposed for testing and for the WebSocket server.
|
|
994
|
-
*/
|
|
995
|
-
export { SessionMapper };
|