macro-agent 0.1.2 → 0.1.4
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/.gitattributes +3 -0
- package/.opentasks/config.json +9 -0
- package/CLAUDE.md +432 -206
- package/README.md +129 -371
- package/dist/acp/index.d.ts +9 -51
- package/dist/acp/index.d.ts.map +1 -1
- package/dist/acp/index.js +5 -46
- package/dist/acp/index.js.map +1 -1
- package/dist/acp/macro-agent.d.ts +28 -255
- package/dist/acp/macro-agent.d.ts.map +1 -1
- package/dist/acp/macro-agent.js +593 -1231
- package/dist/acp/macro-agent.js.map +1 -1
- package/dist/acp/map-bridge.d.ts +62 -0
- package/dist/acp/map-bridge.d.ts.map +1 -0
- package/dist/acp/map-bridge.js +123 -0
- package/dist/acp/map-bridge.js.map +1 -0
- package/dist/acp/session-mapper.d.ts +29 -126
- package/dist/acp/session-mapper.d.ts.map +1 -1
- package/dist/acp/session-mapper.js +36 -234
- package/dist/acp/session-mapper.js.map +1 -1
- package/dist/acp/types.d.ts +24 -535
- package/dist/acp/types.d.ts.map +1 -1
- package/dist/acp/types.js +7 -7
- package/dist/acp/types.js.map +1 -1
- package/dist/acp/websocket-server.d.ts +16 -136
- package/dist/acp/websocket-server.d.ts.map +1 -1
- package/dist/acp/websocket-server.js +131 -371
- package/dist/acp/websocket-server.js.map +1 -1
- package/dist/adapters/federation.d.ts +76 -0
- package/dist/adapters/federation.d.ts.map +1 -0
- package/dist/adapters/federation.js +120 -0
- package/dist/adapters/federation.js.map +1 -0
- package/dist/adapters/inbox-adapter.d.ts +72 -0
- package/dist/adapters/inbox-adapter.d.ts.map +1 -0
- package/dist/adapters/inbox-adapter.js +196 -0
- package/dist/adapters/inbox-adapter.js.map +1 -0
- package/dist/adapters/inbox-client-adapter.d.ts +40 -0
- package/dist/adapters/inbox-client-adapter.d.ts.map +1 -0
- package/dist/adapters/inbox-client-adapter.js +135 -0
- package/dist/adapters/inbox-client-adapter.js.map +1 -0
- package/dist/adapters/index.d.ts +11 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +10 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/opentasks-daemon.d.ts +32 -0
- package/dist/adapters/opentasks-daemon.d.ts.map +1 -0
- package/dist/adapters/opentasks-daemon.js +190 -0
- package/dist/adapters/opentasks-daemon.js.map +1 -0
- package/dist/adapters/tasks-adapter.d.ts +49 -0
- package/dist/adapters/tasks-adapter.d.ts.map +1 -0
- package/dist/adapters/tasks-adapter.js +209 -0
- package/dist/adapters/tasks-adapter.js.map +1 -0
- package/dist/adapters/types.d.ts +198 -0
- package/dist/adapters/types.d.ts.map +1 -0
- package/dist/adapters/types.js +13 -0
- package/dist/adapters/types.js.map +1 -0
- package/dist/agent/agent-manager-v2.d.ts +38 -0
- package/dist/agent/agent-manager-v2.d.ts.map +1 -0
- package/dist/agent/agent-manager-v2.js +1097 -0
- package/dist/agent/agent-manager-v2.js.map +1 -0
- package/dist/agent/agent-manager.d.ts +52 -42
- package/dist/agent/agent-manager.d.ts.map +1 -1
- package/dist/agent/agent-manager.js +11 -1318
- package/dist/agent/agent-manager.js.map +1 -1
- package/dist/agent/agent-store.d.ts +89 -0
- package/dist/agent/agent-store.d.ts.map +1 -0
- package/dist/agent/agent-store.js +279 -0
- package/dist/agent/agent-store.js.map +1 -0
- package/dist/api/index.d.ts +5 -3
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +4 -3
- package/dist/api/index.js.map +1 -1
- package/dist/api/server.d.ts +6 -127
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +235 -1574
- package/dist/api/server.js.map +1 -1
- package/dist/api/types.d.ts +20 -248
- package/dist/api/types.d.ts.map +1 -1
- package/dist/api/types.js +3 -1
- package/dist/api/types.js.map +1 -1
- package/dist/boot-v2.d.ts +165 -0
- package/dist/boot-v2.d.ts.map +1 -0
- package/dist/boot-v2.js +315 -0
- package/dist/boot-v2.js.map +1 -0
- package/dist/cli/acp.d.ts +6 -28
- package/dist/cli/acp.d.ts.map +1 -1
- package/dist/cli/acp.js +38 -442
- package/dist/cli/acp.js.map +1 -1
- package/dist/cli/index.d.ts +1 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +65 -453
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/mcp.d.ts +18 -8
- package/dist/cli/mcp.d.ts.map +1 -1
- package/dist/cli/mcp.js +231 -301
- package/dist/cli/mcp.js.map +1 -1
- package/dist/cognitive/analyst-role.d.ts +13 -0
- package/dist/cognitive/analyst-role.d.ts.map +1 -0
- package/dist/cognitive/analyst-role.js +48 -0
- package/dist/cognitive/analyst-role.js.map +1 -0
- package/dist/cognitive/index.d.ts +18 -0
- package/dist/cognitive/index.d.ts.map +1 -0
- package/dist/cognitive/index.js +21 -0
- package/dist/cognitive/index.js.map +1 -0
- package/dist/cognitive/macro-agent-backend.d.ts +40 -0
- package/dist/cognitive/macro-agent-backend.d.ts.map +1 -0
- package/dist/cognitive/macro-agent-backend.js +290 -0
- package/dist/cognitive/macro-agent-backend.js.map +1 -0
- package/dist/cognitive/session-converter.d.ts +30 -0
- package/dist/cognitive/session-converter.d.ts.map +1 -0
- package/dist/cognitive/session-converter.js +119 -0
- package/dist/cognitive/session-converter.js.map +1 -0
- package/dist/cognitive/types.d.ts +129 -0
- package/dist/cognitive/types.d.ts.map +1 -0
- package/dist/cognitive/types.js +12 -0
- package/dist/cognitive/types.js.map +1 -0
- package/dist/cognitive/workspace-handler.d.ts +38 -0
- package/dist/cognitive/workspace-handler.d.ts.map +1 -0
- package/dist/cognitive/workspace-handler.js +136 -0
- package/dist/cognitive/workspace-handler.js.map +1 -0
- package/dist/control/control-client.d.ts +63 -0
- package/dist/control/control-client.d.ts.map +1 -0
- package/dist/control/control-client.js +276 -0
- package/dist/control/control-client.js.map +1 -0
- package/dist/control/control-server.d.ts +46 -0
- package/dist/control/control-server.d.ts.map +1 -0
- package/dist/control/control-server.js +237 -0
- package/dist/control/control-server.js.map +1 -0
- package/dist/control/index.d.ts +9 -0
- package/dist/control/index.d.ts.map +1 -0
- package/dist/control/index.js +8 -0
- package/dist/control/index.js.map +1 -0
- package/dist/control/types.d.ts +64 -0
- package/dist/control/types.d.ts.map +1 -0
- package/dist/control/types.js +10 -0
- package/dist/control/types.js.map +1 -0
- package/dist/index.d.ts +14 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -34
- package/dist/index.js.map +1 -1
- package/dist/integrations/context-builder.d.ts +49 -0
- package/dist/integrations/context-builder.d.ts.map +1 -0
- package/dist/integrations/context-builder.js +160 -0
- package/dist/integrations/context-builder.js.map +1 -0
- package/dist/integrations/sessionlog.d.ts +58 -0
- package/dist/integrations/sessionlog.d.ts.map +1 -0
- package/dist/integrations/sessionlog.js +152 -0
- package/dist/integrations/sessionlog.js.map +1 -0
- package/dist/integrations/skilltree.d.ts +53 -0
- package/dist/integrations/skilltree.d.ts.map +1 -0
- package/dist/integrations/skilltree.js +140 -0
- package/dist/integrations/skilltree.js.map +1 -0
- package/dist/lifecycle/cleanup.d.ts +5 -14
- package/dist/lifecycle/cleanup.d.ts.map +1 -1
- package/dist/lifecycle/cleanup.js +4 -34
- package/dist/lifecycle/cleanup.js.map +1 -1
- package/dist/lifecycle/handlers-v2.d.ts +33 -0
- package/dist/lifecycle/handlers-v2.d.ts.map +1 -0
- package/dist/lifecycle/handlers-v2.js +319 -0
- package/dist/lifecycle/handlers-v2.js.map +1 -0
- package/dist/lifecycle/index.d.ts +3 -5
- package/dist/lifecycle/index.d.ts.map +1 -1
- package/dist/lifecycle/index.js +3 -12
- package/dist/lifecycle/index.js.map +1 -1
- package/dist/map/acp-bridge.d.ts +39 -0
- package/dist/map/acp-bridge.d.ts.map +1 -0
- package/dist/map/acp-bridge.js +180 -0
- package/dist/map/acp-bridge.js.map +1 -0
- package/dist/map/cc-swarm-hooks.d.ts +36 -0
- package/dist/map/cc-swarm-hooks.d.ts.map +1 -0
- package/dist/map/cc-swarm-hooks.js +218 -0
- package/dist/map/cc-swarm-hooks.js.map +1 -0
- package/dist/map/coordination-handler.d.ts +36 -0
- package/dist/map/coordination-handler.d.ts.map +1 -0
- package/dist/map/coordination-handler.js +170 -0
- package/dist/map/coordination-handler.js.map +1 -0
- package/dist/map/index.d.ts +5 -10
- package/dist/map/index.d.ts.map +1 -1
- package/dist/map/index.js +4 -13
- package/dist/map/index.js.map +1 -1
- package/dist/map/lifecycle-bridge.d.ts +34 -0
- package/dist/map/lifecycle-bridge.d.ts.map +1 -0
- package/dist/map/lifecycle-bridge.js +96 -0
- package/dist/map/lifecycle-bridge.js.map +1 -0
- package/dist/map/server.d.ts +38 -0
- package/dist/map/server.d.ts.map +1 -0
- package/dist/map/server.js +461 -0
- package/dist/map/server.js.map +1 -0
- package/dist/map/sidecar.d.ts +24 -0
- package/dist/map/sidecar.d.ts.map +1 -0
- package/dist/map/sidecar.js +277 -0
- package/dist/map/sidecar.js.map +1 -0
- package/dist/map/task-bridge.d.ts +22 -0
- package/dist/map/task-bridge.d.ts.map +1 -0
- package/dist/map/task-bridge.js +67 -0
- package/dist/map/task-bridge.js.map +1 -0
- package/dist/map/trajectory-reporter.d.ts +24 -0
- package/dist/map/trajectory-reporter.d.ts.map +1 -0
- package/dist/map/trajectory-reporter.js +86 -0
- package/dist/map/trajectory-reporter.js.map +1 -0
- package/dist/map/types.d.ts +162 -226
- package/dist/map/types.d.ts.map +1 -1
- package/dist/map/types.js +6 -165
- package/dist/map/types.js.map +1 -1
- package/dist/mcp/index.d.ts +2 -2
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +2 -2
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/mcp-server-v2.d.ts +44 -0
- package/dist/mcp/mcp-server-v2.d.ts.map +1 -0
- package/dist/mcp/mcp-server-v2.js +376 -0
- package/dist/mcp/mcp-server-v2.js.map +1 -0
- package/dist/mcp/tools/done-v2.d.ts +57 -0
- package/dist/mcp/tools/done-v2.d.ts.map +1 -0
- package/dist/mcp/tools/done-v2.js +129 -0
- package/dist/mcp/tools/done-v2.js.map +1 -0
- package/dist/metrics/index.d.ts +7 -1
- package/dist/metrics/index.d.ts.map +1 -1
- package/dist/metrics/index.js +6 -1
- package/dist/metrics/index.js.map +1 -1
- package/dist/metrics/metrics.d.ts +9 -70
- package/dist/metrics/metrics.d.ts.map +1 -1
- package/dist/metrics/metrics.js +89 -145
- package/dist/metrics/metrics.js.map +1 -1
- package/dist/metrics/types.d.ts +44 -0
- package/dist/metrics/types.d.ts.map +1 -0
- package/dist/metrics/types.js +7 -0
- package/dist/metrics/types.js.map +1 -0
- package/dist/store/index.d.ts +3 -6
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +3 -21
- package/dist/store/index.js.map +1 -1
- package/dist/store/types/events.d.ts +3 -60
- package/dist/store/types/events.d.ts.map +1 -1
- package/dist/store/types/events.js +3 -46
- package/dist/store/types/events.js.map +1 -1
- package/dist/store/types/index.d.ts +0 -3
- package/dist/store/types/index.d.ts.map +1 -1
- package/dist/store/types/index.js +0 -3
- package/dist/store/types/index.js.map +1 -1
- package/dist/teams/index.d.ts +0 -2
- package/dist/teams/index.d.ts.map +1 -1
- package/dist/teams/index.js +0 -2
- package/dist/teams/index.js.map +1 -1
- package/dist/teams/team-manager-v2.d.ts +87 -0
- package/dist/teams/team-manager-v2.d.ts.map +1 -0
- package/dist/teams/team-manager-v2.js +203 -0
- package/dist/teams/team-manager-v2.js.map +1 -0
- package/dist/teams/team-runtime-v2.d.ts +149 -0
- package/dist/teams/team-runtime-v2.d.ts.map +1 -0
- package/dist/teams/team-runtime-v2.js +741 -0
- package/dist/teams/team-runtime-v2.js.map +1 -0
- package/dist/trigger/index.d.ts +2 -2
- package/dist/trigger/index.d.ts.map +1 -1
- package/dist/trigger/index.js +4 -4
- package/dist/trigger/index.js.map +1 -1
- package/dist/trigger/sources/cron/cron-service.d.ts +1 -1
- package/dist/trigger/sources/cron/cron-service.d.ts.map +1 -1
- package/dist/trigger/sources/webhook/webhook-handler.d.ts +1 -1
- package/dist/trigger/sources/webhook/webhook-handler.d.ts.map +1 -1
- package/dist/trigger/strategies/ai-router.d.ts +31 -0
- package/dist/trigger/strategies/ai-router.d.ts.map +1 -0
- package/dist/trigger/strategies/ai-router.js +132 -0
- package/dist/trigger/strategies/ai-router.js.map +1 -0
- package/dist/trigger/trigger-system-v2.d.ts +106 -0
- package/dist/trigger/trigger-system-v2.d.ts.map +1 -0
- package/dist/trigger/trigger-system-v2.js +347 -0
- package/dist/trigger/trigger-system-v2.js.map +1 -0
- package/dist/trigger/types.d.ts +8 -0
- package/dist/trigger/types.d.ts.map +1 -1
- package/dist/trigger/types.js.map +1 -1
- package/dist/workspace/strategies/optimistic.d.ts +13 -3
- package/dist/workspace/strategies/optimistic.d.ts.map +1 -1
- package/dist/workspace/strategies/optimistic.js +4 -4
- package/dist/workspace/strategies/optimistic.js.map +1 -1
- package/docs/design-subsystem-extraction.md +627 -0
- package/docs/lifecycle-events-design.md +111 -0
- package/docs/openhive-capability-summary.md +415 -0
- package/docs/openhive-integration.md +415 -0
- package/docs/roadmap-v2-gaps.md +216 -0
- package/package.json +27 -7
- package/src/__tests__/boot-v2.test.ts +196 -0
- package/src/__tests__/e2e/acp-over-map-live.e2e.test.ts +496 -0
- package/src/__tests__/e2e/acp-over-map.e2e.test.ts +365 -0
- package/src/__tests__/e2e/agent-lifecycle.e2e.test.ts +770 -0
- package/src/__tests__/e2e/cc-swarm-bridge.e2e.test.ts +253 -0
- package/src/__tests__/e2e/cognitive-workspace.e2e.test.ts +282 -0
- package/src/__tests__/e2e/done-scenarios.e2e.test.ts +322 -0
- package/src/__tests__/e2e/live-agent.e2e.test.ts +1330 -0
- package/src/__tests__/e2e/map-server.e2e.test.ts +128 -0
- package/src/__tests__/e2e/map-sidecar.e2e.test.ts +139 -0
- package/src/__tests__/e2e/opentasks-integration.e2e.test.ts +280 -0
- package/src/__tests__/e2e/pull-mode.e2e.test.ts +632 -0
- package/src/__tests__/e2e/resume-continue.e2e.test.ts +312 -0
- package/src/__tests__/e2e/swarmkit-integration.e2e.test.ts +562 -0
- package/src/__tests__/e2e/swarmkit-live.e2e.test.ts +1049 -0
- package/src/__tests__/e2e/trajectory-tracking.e2e.test.ts +258 -0
- package/src/__tests__/e2e/trigger-wake.e2e.test.ts +257 -0
- package/src/__tests__/e2e/workspace-lifecycle.e2e.test.ts +375 -0
- package/src/acp/__tests__/macro-agent.test.ts +234 -945
- package/src/acp/__tests__/session-mapper.test.ts +82 -155
- package/src/acp/__tests__/websocket-server.test.ts +121 -270
- package/src/acp/index.ts +18 -118
- package/src/acp/macro-agent.ts +692 -1752
- package/src/acp/map-bridge.ts +193 -0
- package/src/acp/session-mapper.ts +43 -276
- package/src/acp/types.ts +39 -767
- package/src/acp/websocket-server.ts +152 -588
- package/src/adapters/__tests__/federation.test.ts +256 -0
- package/src/adapters/__tests__/inbox-adapter.test.ts +316 -0
- package/src/adapters/__tests__/tasks-adapter.test.ts +269 -0
- package/src/adapters/federation.ts +185 -0
- package/src/adapters/inbox-adapter.ts +292 -0
- package/src/adapters/inbox-client-adapter.ts +173 -0
- package/src/adapters/index.ts +44 -0
- package/src/adapters/opentasks-daemon.ts +252 -0
- package/src/adapters/tasks-adapter.ts +327 -0
- package/src/adapters/types.ts +285 -0
- package/src/agent/__tests__/agent-manager-v2.test.ts +554 -0
- package/src/agent/__tests__/agent-store.test.ts +413 -0
- package/src/agent/agent-manager-v2.ts +1476 -0
- package/src/agent/agent-manager.ts +41 -1794
- package/src/agent/agent-store.ts +385 -0
- package/src/api/__tests__/server.test.ts +235 -1157
- package/src/api/index.ts +5 -3
- package/src/api/server.ts +270 -1989
- package/src/api/types.ts +25 -339
- package/src/boot-v2.ts +527 -0
- package/src/cli/acp.ts +38 -500
- package/src/cli/index.ts +68 -470
- package/src/cli/mcp.ts +260 -340
- package/src/cognitive/__tests__/macro-agent-backend.test.ts +478 -0
- package/src/cognitive/__tests__/session-converter.test.ts +423 -0
- package/src/cognitive/__tests__/workspace-handler.test.ts +221 -0
- package/src/cognitive/analyst-role.ts +59 -0
- package/src/cognitive/index.ts +49 -0
- package/src/cognitive/macro-agent-backend.ts +354 -0
- package/src/cognitive/session-converter.ts +151 -0
- package/src/cognitive/types.ts +163 -0
- package/src/cognitive/workspace-handler.ts +160 -0
- package/src/control/__tests__/control-resilience.test.ts +251 -0
- package/src/control/__tests__/control-socket.test.ts +240 -0
- package/src/control/control-client.ts +337 -0
- package/src/control/control-server.ts +298 -0
- package/src/control/index.ts +17 -0
- package/src/control/types.ts +95 -0
- package/src/index.ts +42 -224
- package/src/integrations/__tests__/context-builder.test.ts +218 -0
- package/src/integrations/__tests__/sessionlog.test.ts +498 -0
- package/src/integrations/__tests__/skilltree.test.ts +136 -0
- package/src/integrations/context-builder.ts +280 -0
- package/src/integrations/sessionlog.ts +194 -0
- package/src/integrations/skilltree.ts +183 -0
- package/src/lifecycle/__tests__/handlers-v2.test.ts +565 -0
- package/src/lifecycle/cleanup.ts +6 -46
- package/src/lifecycle/handlers-v2.ts +437 -0
- package/src/lifecycle/index.ts +2 -28
- package/src/map/__tests__/lifecycle-bridge.test.ts +223 -0
- package/src/map/__tests__/permission-forwarding.test.ts +143 -0
- package/src/map/__tests__/sidecar-integration.test.ts +190 -0
- package/src/map/__tests__/task-bridge.test.ts +153 -0
- package/src/map/__tests__/trajectory-reporter.test.ts +173 -0
- package/src/map/acp-bridge.ts +270 -0
- package/src/map/cc-swarm-hooks.ts +242 -0
- package/src/map/coordination-handler.ts +224 -0
- package/src/map/index.ts +13 -14
- package/src/map/lifecycle-bridge.ts +140 -0
- package/src/map/server.ts +527 -0
- package/src/map/sidecar.ts +331 -0
- package/src/map/task-bridge.ts +89 -0
- package/src/map/trajectory-reporter.ts +124 -0
- package/src/map/types.ts +195 -367
- package/src/mcp/__tests__/mcp-server-v2.test.ts +236 -0
- package/src/mcp/index.ts +2 -2
- package/src/mcp/mcp-server-v2.ts +485 -0
- package/src/mcp/tools/done-v2.ts +203 -0
- package/src/metrics/__tests__/metrics.test.ts +205 -0
- package/src/metrics/index.ts +13 -9
- package/src/metrics/metrics.ts +110 -239
- package/src/metrics/types.ts +63 -0
- package/src/store/index.ts +3 -64
- package/src/store/types/events.ts +5 -100
- package/src/store/types/index.ts +0 -3
- package/src/teams/__tests__/team-manager-v2.test.ts +425 -0
- package/src/teams/__tests__/team-runtime-v2.test.ts +402 -0
- package/src/teams/index.ts +0 -2
- package/src/teams/team-manager-v2.ts +268 -0
- package/src/teams/team-runtime-v2.ts +898 -0
- package/src/trigger/__tests__/trigger-system-v2.test.ts +257 -0
- package/src/trigger/index.ts +16 -31
- package/src/trigger/sources/cron/cron-service.ts +1 -1
- package/src/trigger/sources/webhook/webhook-handler.ts +1 -1
- package/src/trigger/strategies/ai-router.ts +170 -0
- package/src/trigger/trigger-system-v2.ts +536 -0
- package/src/trigger/types.ts +13 -0
- package/src/workspace/strategies/optimistic.ts +9 -6
- package/.claude/settings.local.json +0 -61
- package/dist/acp/websocket-stream.d.ts +0 -30
- package/dist/acp/websocket-stream.d.ts.map +0 -1
- package/dist/acp/websocket-stream.js +0 -118
- package/dist/acp/websocket-stream.js.map +0 -1
- package/dist/activity/deduplication.d.ts +0 -85
- package/dist/activity/deduplication.d.ts.map +0 -1
- package/dist/activity/deduplication.js +0 -149
- package/dist/activity/deduplication.js.map +0 -1
- package/dist/activity/index.d.ts +0 -16
- package/dist/activity/index.d.ts.map +0 -1
- package/dist/activity/index.js +0 -17
- package/dist/activity/index.js.map +0 -1
- package/dist/activity/relevance.d.ts +0 -81
- package/dist/activity/relevance.d.ts.map +0 -1
- package/dist/activity/relevance.js +0 -161
- package/dist/activity/relevance.js.map +0 -1
- package/dist/activity/types.d.ts +0 -169
- package/dist/activity/types.d.ts.map +0 -1
- package/dist/activity/types.js +0 -33
- package/dist/activity/types.js.map +0 -1
- package/dist/activity/watcher.d.ts +0 -64
- package/dist/activity/watcher.d.ts.map +0 -1
- package/dist/activity/watcher.js +0 -212
- package/dist/activity/watcher.js.map +0 -1
- package/dist/agent/wake.d.ts +0 -85
- package/dist/agent/wake.d.ts.map +0 -1
- package/dist/agent/wake.js +0 -278
- package/dist/agent/wake.js.map +0 -1
- package/dist/lifecycle/handlers/generic.d.ts +0 -27
- package/dist/lifecycle/handlers/generic.d.ts.map +0 -1
- package/dist/lifecycle/handlers/generic.js +0 -56
- package/dist/lifecycle/handlers/generic.js.map +0 -1
- package/dist/lifecycle/handlers/index.d.ts +0 -51
- package/dist/lifecycle/handlers/index.d.ts.map +0 -1
- package/dist/lifecycle/handlers/index.js +0 -110
- package/dist/lifecycle/handlers/index.js.map +0 -1
- package/dist/lifecycle/handlers/integrator.d.ts +0 -81
- package/dist/lifecycle/handlers/integrator.d.ts.map +0 -1
- package/dist/lifecycle/handlers/integrator.js +0 -451
- package/dist/lifecycle/handlers/integrator.js.map +0 -1
- package/dist/lifecycle/handlers/monitor.d.ts +0 -29
- package/dist/lifecycle/handlers/monitor.d.ts.map +0 -1
- package/dist/lifecycle/handlers/monitor.js +0 -79
- package/dist/lifecycle/handlers/monitor.js.map +0 -1
- package/dist/lifecycle/handlers/worker.d.ts +0 -56
- package/dist/lifecycle/handlers/worker.d.ts.map +0 -1
- package/dist/lifecycle/handlers/worker.js +0 -381
- package/dist/lifecycle/handlers/worker.js.map +0 -1
- package/dist/mail/conversation-map.d.ts +0 -33
- package/dist/mail/conversation-map.d.ts.map +0 -1
- package/dist/mail/conversation-map.js +0 -61
- package/dist/mail/conversation-map.js.map +0 -1
- package/dist/mail/index.d.ts +0 -11
- package/dist/mail/index.d.ts.map +0 -1
- package/dist/mail/index.js +0 -11
- package/dist/mail/index.js.map +0 -1
- package/dist/mail/mail-service.d.ts +0 -85
- package/dist/mail/mail-service.d.ts.map +0 -1
- package/dist/mail/mail-service.js +0 -121
- package/dist/mail/mail-service.js.map +0 -1
- package/dist/mail/stores/eventstore-conversation-store.d.ts +0 -40
- package/dist/mail/stores/eventstore-conversation-store.d.ts.map +0 -1
- package/dist/mail/stores/eventstore-conversation-store.js +0 -131
- package/dist/mail/stores/eventstore-conversation-store.js.map +0 -1
- package/dist/mail/stores/eventstore-participant-store.d.ts +0 -43
- package/dist/mail/stores/eventstore-participant-store.d.ts.map +0 -1
- package/dist/mail/stores/eventstore-participant-store.js +0 -145
- package/dist/mail/stores/eventstore-participant-store.js.map +0 -1
- package/dist/mail/stores/eventstore-thread-store.d.ts +0 -46
- package/dist/mail/stores/eventstore-thread-store.d.ts.map +0 -1
- package/dist/mail/stores/eventstore-thread-store.js +0 -118
- package/dist/mail/stores/eventstore-thread-store.js.map +0 -1
- package/dist/mail/stores/eventstore-turn-store.d.ts +0 -47
- package/dist/mail/stores/eventstore-turn-store.d.ts.map +0 -1
- package/dist/mail/stores/eventstore-turn-store.js +0 -153
- package/dist/mail/stores/eventstore-turn-store.js.map +0 -1
- package/dist/mail/stores/index.d.ts +0 -12
- package/dist/mail/stores/index.d.ts.map +0 -1
- package/dist/mail/stores/index.js +0 -12
- package/dist/mail/stores/index.js.map +0 -1
- package/dist/mail/stores/types.d.ts +0 -146
- package/dist/mail/stores/types.d.ts.map +0 -1
- package/dist/mail/stores/types.js +0 -13
- package/dist/mail/stores/types.js.map +0 -1
- package/dist/mail/turn-recorder.d.ts +0 -30
- package/dist/mail/turn-recorder.d.ts.map +0 -1
- package/dist/mail/turn-recorder.js +0 -98
- package/dist/mail/turn-recorder.js.map +0 -1
- package/dist/map/adapter/acp-over-map.d.ts +0 -115
- package/dist/map/adapter/acp-over-map.d.ts.map +0 -1
- package/dist/map/adapter/acp-over-map.js +0 -1024
- package/dist/map/adapter/acp-over-map.js.map +0 -1
- package/dist/map/adapter/connection-manager.d.ts +0 -150
- package/dist/map/adapter/connection-manager.d.ts.map +0 -1
- package/dist/map/adapter/connection-manager.js +0 -207
- package/dist/map/adapter/connection-manager.js.map +0 -1
- package/dist/map/adapter/event-log.d.ts +0 -87
- package/dist/map/adapter/event-log.d.ts.map +0 -1
- package/dist/map/adapter/event-log.js +0 -122
- package/dist/map/adapter/event-log.js.map +0 -1
- package/dist/map/adapter/event-translator.d.ts +0 -85
- package/dist/map/adapter/event-translator.d.ts.map +0 -1
- package/dist/map/adapter/event-translator.js +0 -295
- package/dist/map/adapter/event-translator.js.map +0 -1
- package/dist/map/adapter/extensions/agent-detection.d.ts +0 -49
- package/dist/map/adapter/extensions/agent-detection.d.ts.map +0 -1
- package/dist/map/adapter/extensions/agent-detection.js +0 -91
- package/dist/map/adapter/extensions/agent-detection.js.map +0 -1
- package/dist/map/adapter/extensions/agent-lifecycle.d.ts +0 -82
- package/dist/map/adapter/extensions/agent-lifecycle.d.ts.map +0 -1
- package/dist/map/adapter/extensions/agent-lifecycle.js +0 -164
- package/dist/map/adapter/extensions/agent-lifecycle.js.map +0 -1
- package/dist/map/adapter/extensions/index.d.ts +0 -92
- package/dist/map/adapter/extensions/index.d.ts.map +0 -1
- package/dist/map/adapter/extensions/index.js +0 -214
- package/dist/map/adapter/extensions/index.js.map +0 -1
- package/dist/map/adapter/extensions/mcp-bridge.d.ts +0 -57
- package/dist/map/adapter/extensions/mcp-bridge.d.ts.map +0 -1
- package/dist/map/adapter/extensions/mcp-bridge.js +0 -745
- package/dist/map/adapter/extensions/mcp-bridge.js.map +0 -1
- package/dist/map/adapter/extensions/rename.d.ts +0 -29
- package/dist/map/adapter/extensions/rename.d.ts.map +0 -1
- package/dist/map/adapter/extensions/rename.js +0 -49
- package/dist/map/adapter/extensions/rename.js.map +0 -1
- package/dist/map/adapter/extensions/resume.d.ts +0 -47
- package/dist/map/adapter/extensions/resume.d.ts.map +0 -1
- package/dist/map/adapter/extensions/resume.js +0 -59
- package/dist/map/adapter/extensions/resume.js.map +0 -1
- package/dist/map/adapter/extensions/streams.d.ts +0 -95
- package/dist/map/adapter/extensions/streams.d.ts.map +0 -1
- package/dist/map/adapter/extensions/streams.js +0 -515
- package/dist/map/adapter/extensions/streams.js.map +0 -1
- package/dist/map/adapter/extensions/task.d.ts +0 -40
- package/dist/map/adapter/extensions/task.d.ts.map +0 -1
- package/dist/map/adapter/extensions/task.js +0 -197
- package/dist/map/adapter/extensions/task.js.map +0 -1
- package/dist/map/adapter/extensions/update-metadata.d.ts +0 -29
- package/dist/map/adapter/extensions/update-metadata.d.ts.map +0 -1
- package/dist/map/adapter/extensions/update-metadata.js +0 -67
- package/dist/map/adapter/extensions/update-metadata.js.map +0 -1
- package/dist/map/adapter/extensions/wake.d.ts +0 -60
- package/dist/map/adapter/extensions/wake.d.ts.map +0 -1
- package/dist/map/adapter/extensions/wake.js +0 -144
- package/dist/map/adapter/extensions/wake.js.map +0 -1
- package/dist/map/adapter/extensions/workspace-files.d.ts +0 -42
- package/dist/map/adapter/extensions/workspace-files.d.ts.map +0 -1
- package/dist/map/adapter/extensions/workspace-files.js +0 -338
- package/dist/map/adapter/extensions/workspace-files.js.map +0 -1
- package/dist/map/adapter/extensions/workspace.d.ts +0 -57
- package/dist/map/adapter/extensions/workspace.d.ts.map +0 -1
- package/dist/map/adapter/extensions/workspace.js +0 -81
- package/dist/map/adapter/extensions/workspace.js.map +0 -1
- package/dist/map/adapter/index.d.ts +0 -20
- package/dist/map/adapter/index.d.ts.map +0 -1
- package/dist/map/adapter/index.js +0 -40
- package/dist/map/adapter/index.js.map +0 -1
- package/dist/map/adapter/interface.d.ts +0 -450
- package/dist/map/adapter/interface.d.ts.map +0 -1
- package/dist/map/adapter/interface.js +0 -24
- package/dist/map/adapter/interface.js.map +0 -1
- package/dist/map/adapter/mail-handler-adapter.d.ts +0 -27
- package/dist/map/adapter/mail-handler-adapter.d.ts.map +0 -1
- package/dist/map/adapter/mail-handler-adapter.js +0 -292
- package/dist/map/adapter/mail-handler-adapter.js.map +0 -1
- package/dist/map/adapter/map-adapter.d.ts +0 -200
- package/dist/map/adapter/map-adapter.d.ts.map +0 -1
- package/dist/map/adapter/map-adapter.js +0 -1199
- package/dist/map/adapter/map-adapter.js.map +0 -1
- package/dist/map/adapter/rpc-handler.d.ts +0 -263
- package/dist/map/adapter/rpc-handler.d.ts.map +0 -1
- package/dist/map/adapter/rpc-handler.js +0 -365
- package/dist/map/adapter/rpc-handler.js.map +0 -1
- package/dist/map/adapter/subscription-manager.d.ts +0 -174
- package/dist/map/adapter/subscription-manager.d.ts.map +0 -1
- package/dist/map/adapter/subscription-manager.js +0 -248
- package/dist/map/adapter/subscription-manager.js.map +0 -1
- package/dist/map/adapter/types.d.ts +0 -194
- package/dist/map/adapter/types.d.ts.map +0 -1
- package/dist/map/adapter/types.js +0 -27
- package/dist/map/adapter/types.js.map +0 -1
- package/dist/map/adapter/websocket-integration.d.ts +0 -113
- package/dist/map/adapter/websocket-integration.d.ts.map +0 -1
- package/dist/map/adapter/websocket-integration.js +0 -134
- package/dist/map/adapter/websocket-integration.js.map +0 -1
- package/dist/map/federation/envelope.d.ts +0 -98
- package/dist/map/federation/envelope.d.ts.map +0 -1
- package/dist/map/federation/envelope.js +0 -160
- package/dist/map/federation/envelope.js.map +0 -1
- package/dist/map/federation/federation-handler.d.ts +0 -50
- package/dist/map/federation/federation-handler.d.ts.map +0 -1
- package/dist/map/federation/federation-handler.js +0 -306
- package/dist/map/federation/federation-handler.js.map +0 -1
- package/dist/map/federation/index.d.ts +0 -14
- package/dist/map/federation/index.d.ts.map +0 -1
- package/dist/map/federation/index.js +0 -13
- package/dist/map/federation/index.js.map +0 -1
- package/dist/map/federation/types.d.ts +0 -239
- package/dist/map/federation/types.d.ts.map +0 -1
- package/dist/map/federation/types.js +0 -23
- package/dist/map/federation/types.js.map +0 -1
- package/dist/map/utils/address-translation.d.ts +0 -99
- package/dist/map/utils/address-translation.d.ts.map +0 -1
- package/dist/map/utils/address-translation.js +0 -285
- package/dist/map/utils/address-translation.js.map +0 -1
- package/dist/map/utils/index.d.ts +0 -7
- package/dist/map/utils/index.d.ts.map +0 -1
- package/dist/map/utils/index.js +0 -7
- package/dist/map/utils/index.js.map +0 -1
- package/dist/mcp/map-client.d.ts +0 -39
- package/dist/mcp/map-client.d.ts.map +0 -1
- package/dist/mcp/map-client.js +0 -129
- package/dist/mcp/map-client.js.map +0 -1
- package/dist/mcp/mcp-server.d.ts +0 -72
- package/dist/mcp/mcp-server.d.ts.map +0 -1
- package/dist/mcp/mcp-server.js +0 -1024
- package/dist/mcp/mcp-server.js.map +0 -1
- package/dist/mcp/tools/claim_task.d.ts +0 -35
- package/dist/mcp/tools/claim_task.d.ts.map +0 -1
- package/dist/mcp/tools/claim_task.js +0 -58
- package/dist/mcp/tools/claim_task.js.map +0 -1
- package/dist/mcp/tools/done.d.ts +0 -102
- package/dist/mcp/tools/done.d.ts.map +0 -1
- package/dist/mcp/tools/done.js +0 -252
- package/dist/mcp/tools/done.js.map +0 -1
- package/dist/mcp/tools/inject_context.d.ts +0 -61
- package/dist/mcp/tools/inject_context.d.ts.map +0 -1
- package/dist/mcp/tools/inject_context.js +0 -123
- package/dist/mcp/tools/inject_context.js.map +0 -1
- package/dist/mcp/tools/list_claimable_tasks.d.ts +0 -38
- package/dist/mcp/tools/list_claimable_tasks.d.ts.map +0 -1
- package/dist/mcp/tools/list_claimable_tasks.js +0 -63
- package/dist/mcp/tools/list_claimable_tasks.js.map +0 -1
- package/dist/mcp/tools/unclaim_task.d.ts +0 -31
- package/dist/mcp/tools/unclaim_task.d.ts.map +0 -1
- package/dist/mcp/tools/unclaim_task.js +0 -47
- package/dist/mcp/tools/unclaim_task.js.map +0 -1
- package/dist/mcp/tools/wait_for_activity.d.ts +0 -60
- package/dist/mcp/tools/wait_for_activity.d.ts.map +0 -1
- package/dist/mcp/tools/wait_for_activity.js +0 -135
- package/dist/mcp/tools/wait_for_activity.js.map +0 -1
- package/dist/monitor/health-check-service.d.ts +0 -143
- package/dist/monitor/health-check-service.d.ts.map +0 -1
- package/dist/monitor/health-check-service.js +0 -240
- package/dist/monitor/health-check-service.js.map +0 -1
- package/dist/monitor/index.d.ts +0 -14
- package/dist/monitor/index.d.ts.map +0 -1
- package/dist/monitor/index.js +0 -14
- package/dist/monitor/index.js.map +0 -1
- package/dist/monitor/stall-detector.d.ts +0 -109
- package/dist/monitor/stall-detector.d.ts.map +0 -1
- package/dist/monitor/stall-detector.js +0 -152
- package/dist/monitor/stall-detector.js.map +0 -1
- package/dist/peer/capability-manager.d.ts +0 -56
- package/dist/peer/capability-manager.d.ts.map +0 -1
- package/dist/peer/capability-manager.js +0 -186
- package/dist/peer/capability-manager.js.map +0 -1
- package/dist/peer/encapsulation-manager.d.ts +0 -190
- package/dist/peer/encapsulation-manager.d.ts.map +0 -1
- package/dist/peer/encapsulation-manager.js +0 -486
- package/dist/peer/encapsulation-manager.js.map +0 -1
- package/dist/peer/federation-manager.d.ts +0 -223
- package/dist/peer/federation-manager.d.ts.map +0 -1
- package/dist/peer/federation-manager.js +0 -528
- package/dist/peer/federation-manager.js.map +0 -1
- package/dist/peer/hierarchy-errors.d.ts +0 -208
- package/dist/peer/hierarchy-errors.d.ts.map +0 -1
- package/dist/peer/hierarchy-errors.js +0 -268
- package/dist/peer/hierarchy-errors.js.map +0 -1
- package/dist/peer/hierarchy-protocol.d.ts +0 -159
- package/dist/peer/hierarchy-protocol.d.ts.map +0 -1
- package/dist/peer/hierarchy-protocol.js +0 -142
- package/dist/peer/hierarchy-protocol.js.map +0 -1
- package/dist/peer/index.d.ts +0 -15
- package/dist/peer/index.d.ts.map +0 -1
- package/dist/peer/index.js +0 -15
- package/dist/peer/index.js.map +0 -1
- package/dist/peer/peer-manager.d.ts +0 -99
- package/dist/peer/peer-manager.d.ts.map +0 -1
- package/dist/peer/peer-manager.js +0 -333
- package/dist/peer/peer-manager.js.map +0 -1
- package/dist/peer/task-delegation.d.ts +0 -189
- package/dist/peer/task-delegation.d.ts.map +0 -1
- package/dist/peer/task-delegation.js +0 -303
- package/dist/peer/task-delegation.js.map +0 -1
- package/dist/peer/transports/index.d.ts +0 -8
- package/dist/peer/transports/index.d.ts.map +0 -1
- package/dist/peer/transports/index.js +0 -8
- package/dist/peer/transports/index.js.map +0 -1
- package/dist/peer/transports/local-transport.d.ts +0 -56
- package/dist/peer/transports/local-transport.d.ts.map +0 -1
- package/dist/peer/transports/local-transport.js +0 -263
- package/dist/peer/transports/local-transport.js.map +0 -1
- package/dist/peer/transports/websocket-transport.d.ts +0 -86
- package/dist/peer/transports/websocket-transport.d.ts.map +0 -1
- package/dist/peer/transports/websocket-transport.js +0 -338
- package/dist/peer/transports/websocket-transport.js.map +0 -1
- package/dist/peer/types.d.ts +0 -268
- package/dist/peer/types.d.ts.map +0 -1
- package/dist/peer/types.js +0 -36
- package/dist/peer/types.js.map +0 -1
- package/dist/router/address-resolver.d.ts +0 -102
- package/dist/router/address-resolver.d.ts.map +0 -1
- package/dist/router/address-resolver.js +0 -198
- package/dist/router/address-resolver.js.map +0 -1
- package/dist/router/broadcast.d.ts +0 -53
- package/dist/router/broadcast.d.ts.map +0 -1
- package/dist/router/broadcast.js +0 -75
- package/dist/router/broadcast.js.map +0 -1
- package/dist/router/channels.d.ts +0 -148
- package/dist/router/channels.d.ts.map +0 -1
- package/dist/router/channels.js +0 -126
- package/dist/router/channels.js.map +0 -1
- package/dist/router/index.d.ts +0 -21
- package/dist/router/index.d.ts.map +0 -1
- package/dist/router/index.js +0 -18
- package/dist/router/index.js.map +0 -1
- package/dist/router/message-router.d.ts +0 -197
- package/dist/router/message-router.d.ts.map +0 -1
- package/dist/router/message-router.js +0 -903
- package/dist/router/message-router.js.map +0 -1
- package/dist/router/message-types.d.ts +0 -183
- package/dist/router/message-types.d.ts.map +0 -1
- package/dist/router/message-types.js +0 -79
- package/dist/router/message-types.js.map +0 -1
- package/dist/router/role-resolver.d.ts +0 -67
- package/dist/router/role-resolver.d.ts.map +0 -1
- package/dist/router/role-resolver.js +0 -106
- package/dist/router/role-resolver.js.map +0 -1
- package/dist/router/signals.d.ts +0 -253
- package/dist/router/signals.d.ts.map +0 -1
- package/dist/router/signals.js +0 -53
- package/dist/router/signals.js.map +0 -1
- package/dist/router/types.d.ts +0 -191
- package/dist/router/types.d.ts.map +0 -1
- package/dist/router/types.js +0 -34
- package/dist/router/types.js.map +0 -1
- package/dist/router/wake.d.ts +0 -111
- package/dist/router/wake.d.ts.map +0 -1
- package/dist/router/wake.js +0 -180
- package/dist/router/wake.js.map +0 -1
- package/dist/server/combined-server.d.ts +0 -95
- package/dist/server/combined-server.d.ts.map +0 -1
- package/dist/server/combined-server.js +0 -335
- package/dist/server/combined-server.js.map +0 -1
- package/dist/steering/index.d.ts +0 -11
- package/dist/steering/index.d.ts.map +0 -1
- package/dist/steering/index.js +0 -11
- package/dist/steering/index.js.map +0 -1
- package/dist/steering/inject.d.ts +0 -39
- package/dist/steering/inject.d.ts.map +0 -1
- package/dist/steering/inject.js +0 -197
- package/dist/steering/inject.js.map +0 -1
- package/dist/steering/types.d.ts +0 -100
- package/dist/steering/types.d.ts.map +0 -1
- package/dist/steering/types.js +0 -11
- package/dist/steering/types.js.map +0 -1
- package/dist/store/backends/index.d.ts +0 -11
- package/dist/store/backends/index.d.ts.map +0 -1
- package/dist/store/backends/index.js +0 -15
- package/dist/store/backends/index.js.map +0 -1
- package/dist/store/backends/json-backend.d.ts +0 -23
- package/dist/store/backends/json-backend.d.ts.map +0 -1
- package/dist/store/backends/json-backend.js +0 -220
- package/dist/store/backends/json-backend.js.map +0 -1
- package/dist/store/backends/memory-backend.d.ts +0 -12
- package/dist/store/backends/memory-backend.d.ts.map +0 -1
- package/dist/store/backends/memory-backend.js +0 -205
- package/dist/store/backends/memory-backend.js.map +0 -1
- package/dist/store/backends/sqlite-backend.d.ts +0 -27
- package/dist/store/backends/sqlite-backend.d.ts.map +0 -1
- package/dist/store/backends/sqlite-backend.js +0 -231
- package/dist/store/backends/sqlite-backend.js.map +0 -1
- package/dist/store/backends/tinybase-backend.d.ts +0 -22
- package/dist/store/backends/tinybase-backend.d.ts.map +0 -1
- package/dist/store/backends/tinybase-backend.js +0 -203
- package/dist/store/backends/tinybase-backend.js.map +0 -1
- package/dist/store/backends/types.d.ts +0 -175
- package/dist/store/backends/types.d.ts.map +0 -1
- package/dist/store/backends/types.js +0 -28
- package/dist/store/backends/types.js.map +0 -1
- package/dist/store/event-store.d.ts +0 -128
- package/dist/store/event-store.d.ts.map +0 -1
- package/dist/store/event-store.js +0 -1746
- package/dist/store/event-store.js.map +0 -1
- package/dist/store/instance.d.ts +0 -283
- package/dist/store/instance.d.ts.map +0 -1
- package/dist/store/instance.js +0 -363
- package/dist/store/instance.js.map +0 -1
- package/dist/store/migrations.d.ts +0 -41
- package/dist/store/migrations.d.ts.map +0 -1
- package/dist/store/migrations.js +0 -79
- package/dist/store/migrations.js.map +0 -1
- package/dist/store/types/config.d.ts +0 -16
- package/dist/store/types/config.d.ts.map +0 -1
- package/dist/store/types/config.js +0 -8
- package/dist/store/types/config.js.map +0 -1
- package/dist/store/types/conversations.d.ts +0 -91
- package/dist/store/types/conversations.d.ts.map +0 -1
- package/dist/store/types/conversations.js +0 -8
- package/dist/store/types/conversations.js.map +0 -1
- package/dist/store/types/sessions.d.ts +0 -44
- package/dist/store/types/sessions.d.ts.map +0 -1
- package/dist/store/types/sessions.js +0 -9
- package/dist/store/types/sessions.js.map +0 -1
- package/dist/task/backend/index.d.ts +0 -93
- package/dist/task/backend/index.d.ts.map +0 -1
- package/dist/task/backend/index.js +0 -178
- package/dist/task/backend/index.js.map +0 -1
- package/dist/task/backend/memory.d.ts +0 -70
- package/dist/task/backend/memory.d.ts.map +0 -1
- package/dist/task/backend/memory.js +0 -621
- package/dist/task/backend/memory.js.map +0 -1
- package/dist/task/backend/opentasks/backend.d.ts +0 -140
- package/dist/task/backend/opentasks/backend.d.ts.map +0 -1
- package/dist/task/backend/opentasks/backend.js +0 -1023
- package/dist/task/backend/opentasks/backend.js.map +0 -1
- package/dist/task/backend/opentasks/client.d.ts +0 -337
- package/dist/task/backend/opentasks/client.d.ts.map +0 -1
- package/dist/task/backend/opentasks/client.js +0 -225
- package/dist/task/backend/opentasks/client.js.map +0 -1
- package/dist/task/backend/opentasks/daemon-manager.d.ts +0 -89
- package/dist/task/backend/opentasks/daemon-manager.d.ts.map +0 -1
- package/dist/task/backend/opentasks/daemon-manager.js +0 -195
- package/dist/task/backend/opentasks/daemon-manager.js.map +0 -1
- package/dist/task/backend/opentasks/index.d.ts +0 -21
- package/dist/task/backend/opentasks/index.d.ts.map +0 -1
- package/dist/task/backend/opentasks/index.js +0 -21
- package/dist/task/backend/opentasks/index.js.map +0 -1
- package/dist/task/backend/opentasks/mapping.d.ts +0 -48
- package/dist/task/backend/opentasks/mapping.d.ts.map +0 -1
- package/dist/task/backend/opentasks/mapping.js +0 -77
- package/dist/task/backend/opentasks/mapping.js.map +0 -1
- package/dist/task/backend/sudocode/__tests__/integration/test-utils.d.ts +0 -54
- package/dist/task/backend/sudocode/__tests__/integration/test-utils.d.ts.map +0 -1
- package/dist/task/backend/sudocode/__tests__/integration/test-utils.js +0 -88
- package/dist/task/backend/sudocode/__tests__/integration/test-utils.js.map +0 -1
- package/dist/task/backend/sudocode/backend.d.ts +0 -155
- package/dist/task/backend/sudocode/backend.d.ts.map +0 -1
- package/dist/task/backend/sudocode/backend.js +0 -942
- package/dist/task/backend/sudocode/backend.js.map +0 -1
- package/dist/task/backend/sudocode/client.d.ts +0 -303
- package/dist/task/backend/sudocode/client.d.ts.map +0 -1
- package/dist/task/backend/sudocode/client.js +0 -101
- package/dist/task/backend/sudocode/client.js.map +0 -1
- package/dist/task/backend/sudocode/index.d.ts +0 -19
- package/dist/task/backend/sudocode/index.d.ts.map +0 -1
- package/dist/task/backend/sudocode/index.js +0 -17
- package/dist/task/backend/sudocode/index.js.map +0 -1
- package/dist/task/backend/sudocode/mapping.d.ts +0 -51
- package/dist/task/backend/sudocode/mapping.d.ts.map +0 -1
- package/dist/task/backend/sudocode/mapping.js +0 -86
- package/dist/task/backend/sudocode/mapping.js.map +0 -1
- package/dist/task/backend/sudocode/server-client.d.ts +0 -56
- package/dist/task/backend/sudocode/server-client.d.ts.map +0 -1
- package/dist/task/backend/sudocode/server-client.js +0 -367
- package/dist/task/backend/sudocode/server-client.js.map +0 -1
- package/dist/task/backend/sudocode/standalone-client.d.ts +0 -91
- package/dist/task/backend/sudocode/standalone-client.d.ts.map +0 -1
- package/dist/task/backend/sudocode/standalone-client.js +0 -476
- package/dist/task/backend/sudocode/standalone-client.js.map +0 -1
- package/dist/task/backend/sudocode/sync-policy.d.ts +0 -166
- package/dist/task/backend/sudocode/sync-policy.d.ts.map +0 -1
- package/dist/task/backend/sudocode/sync-policy.js +0 -221
- package/dist/task/backend/sudocode/sync-policy.js.map +0 -1
- package/dist/task/backend/sudocode/tools.d.ts +0 -87
- package/dist/task/backend/sudocode/tools.d.ts.map +0 -1
- package/dist/task/backend/sudocode/tools.js +0 -743
- package/dist/task/backend/sudocode/tools.js.map +0 -1
- package/dist/task/backend/tool-provider.d.ts +0 -56
- package/dist/task/backend/tool-provider.d.ts.map +0 -1
- package/dist/task/backend/tool-provider.js +0 -424
- package/dist/task/backend/tool-provider.js.map +0 -1
- package/dist/task/backend/types.d.ts +0 -297
- package/dist/task/backend/types.d.ts.map +0 -1
- package/dist/task/backend/types.js +0 -27
- package/dist/task/backend/types.js.map +0 -1
- package/dist/task/backend/unified-tool-provider.d.ts +0 -57
- package/dist/task/backend/unified-tool-provider.d.ts.map +0 -1
- package/dist/task/backend/unified-tool-provider.js +0 -623
- package/dist/task/backend/unified-tool-provider.js.map +0 -1
- package/dist/task/index.d.ts +0 -7
- package/dist/task/index.d.ts.map +0 -1
- package/dist/task/index.js +0 -7
- package/dist/task/index.js.map +0 -1
- package/dist/task/retry-policy.d.ts +0 -89
- package/dist/task/retry-policy.d.ts.map +0 -1
- package/dist/task/retry-policy.js +0 -160
- package/dist/task/retry-policy.js.map +0 -1
- package/dist/task/task-manager.d.ts +0 -70
- package/dist/task/task-manager.d.ts.map +0 -1
- package/dist/task/task-manager.js +0 -319
- package/dist/task/task-manager.js.map +0 -1
- package/dist/task/types.d.ts +0 -72
- package/dist/task/types.d.ts.map +0 -1
- package/dist/task/types.js +0 -33
- package/dist/task/types.js.map +0 -1
- package/dist/teams/team-manager.d.ts +0 -112
- package/dist/teams/team-manager.d.ts.map +0 -1
- package/dist/teams/team-manager.js +0 -305
- package/dist/teams/team-manager.js.map +0 -1
- package/dist/teams/team-runtime.d.ts +0 -245
- package/dist/teams/team-runtime.d.ts.map +0 -1
- package/dist/teams/team-runtime.js +0 -1023
- package/dist/teams/team-runtime.js.map +0 -1
- package/dist/trigger/router/index.d.ts +0 -11
- package/dist/trigger/router/index.d.ts.map +0 -1
- package/dist/trigger/router/index.js +0 -10
- package/dist/trigger/router/index.js.map +0 -1
- package/dist/trigger/router/strategies/ai-router-strategy.d.ts +0 -34
- package/dist/trigger/router/strategies/ai-router-strategy.d.ts.map +0 -1
- package/dist/trigger/router/strategies/ai-router-strategy.js +0 -359
- package/dist/trigger/router/strategies/ai-router-strategy.js.map +0 -1
- package/dist/trigger/router/strategies/direct-strategy.d.ts +0 -32
- package/dist/trigger/router/strategies/direct-strategy.d.ts.map +0 -1
- package/dist/trigger/router/strategies/direct-strategy.js +0 -119
- package/dist/trigger/router/strategies/direct-strategy.js.map +0 -1
- package/dist/trigger/router/strategies/index.d.ts +0 -11
- package/dist/trigger/router/strategies/index.d.ts.map +0 -1
- package/dist/trigger/router/strategies/index.js +0 -11
- package/dist/trigger/router/strategies/index.js.map +0 -1
- package/dist/trigger/router/strategies/role-strategy.d.ts +0 -39
- package/dist/trigger/router/strategies/role-strategy.d.ts.map +0 -1
- package/dist/trigger/router/strategies/role-strategy.js +0 -207
- package/dist/trigger/router/strategies/role-strategy.js.map +0 -1
- package/dist/trigger/router/trigger-router.d.ts +0 -54
- package/dist/trigger/router/trigger-router.d.ts.map +0 -1
- package/dist/trigger/router/trigger-router.js +0 -362
- package/dist/trigger/router/trigger-router.js.map +0 -1
- package/dist/trigger/router/types.d.ts +0 -225
- package/dist/trigger/router/types.d.ts.map +0 -1
- package/dist/trigger/router/types.js +0 -10
- package/dist/trigger/router/types.js.map +0 -1
- package/dist/trigger/trigger-system.d.ts +0 -77
- package/dist/trigger/trigger-system.d.ts.map +0 -1
- package/dist/trigger/trigger-system.js +0 -84
- package/dist/trigger/trigger-system.js.map +0 -1
- package/references/acp-factory-ref/CHANGELOG.md +0 -33
- package/references/acp-factory-ref/LICENSE +0 -21
- package/references/acp-factory-ref/README.md +0 -341
- package/references/acp-factory-ref/package-lock.json +0 -3102
- package/references/acp-factory-ref/package.json +0 -96
- package/references/acp-factory-ref/python/CHANGELOG.md +0 -33
- package/references/acp-factory-ref/python/LICENSE +0 -21
- package/references/acp-factory-ref/python/Makefile +0 -57
- package/references/acp-factory-ref/python/README.md +0 -253
- package/references/acp-factory-ref/python/pyproject.toml +0 -73
- package/references/acp-factory-ref/python/tests/e2e/__init__.py +0 -1
- package/references/acp-factory-ref/python/tests/e2e/test_codex_e2e.py +0 -349
- package/references/acp-factory-ref/python/tests/e2e/test_gemini_e2e.py +0 -165
- package/references/acp-factory-ref/python/tests/e2e/test_opencode_e2e.py +0 -296
- package/references/acp-factory-ref/python/tests/test_client_handler.py +0 -543
- package/references/acp-factory-ref/python/tests/test_pushable.py +0 -199
- package/references/claude-code-acp/.github/workflows/ci.yml +0 -45
- package/references/claude-code-acp/.github/workflows/publish.yml +0 -34
- package/references/claude-code-acp/.prettierrc.json +0 -4
- package/references/claude-code-acp/CHANGELOG.md +0 -249
- package/references/claude-code-acp/LICENSE +0 -222
- package/references/claude-code-acp/README.md +0 -53
- package/references/claude-code-acp/docs/RELEASES.md +0 -24
- package/references/claude-code-acp/eslint.config.js +0 -48
- package/references/claude-code-acp/package-lock.json +0 -4570
- package/references/claude-code-acp/package.json +0 -88
- package/references/claude-code-acp/scripts/release.sh +0 -119
- package/references/claude-code-acp/src/acp-agent.ts +0 -2076
- package/references/claude-code-acp/src/index.ts +0 -26
- package/references/claude-code-acp/src/lib.ts +0 -38
- package/references/claude-code-acp/src/mcp-server.ts +0 -911
- package/references/claude-code-acp/src/settings.ts +0 -522
- package/references/claude-code-acp/src/tests/.claude/commands/quick-math.md +0 -5
- package/references/claude-code-acp/src/tests/.claude/commands/say-hello.md +0 -6
- package/references/claude-code-acp/src/tests/acp-agent-fork.test.ts +0 -479
- package/references/claude-code-acp/src/tests/acp-agent.test.ts +0 -1502
- package/references/claude-code-acp/src/tests/extract-lines.test.ts +0 -103
- package/references/claude-code-acp/src/tests/fork-session.test.ts +0 -335
- package/references/claude-code-acp/src/tests/replace-and-calculate-location.test.ts +0 -334
- package/references/claude-code-acp/src/tests/settings.test.ts +0 -617
- package/references/claude-code-acp/src/tests/skills-options.test.ts +0 -187
- package/references/claude-code-acp/src/tests/tools.test.ts +0 -318
- package/references/claude-code-acp/src/tests/typescript-declarations.test.ts +0 -558
- package/references/claude-code-acp/src/tools.ts +0 -819
- package/references/claude-code-acp/src/utils.ts +0 -171
- package/references/claude-code-acp/tsconfig.json +0 -18
- package/references/claude-code-acp/vitest.config.ts +0 -19
- package/references/minimem/.claude/settings.json +0 -7
- package/references/minimem/.sudocode/issues.jsonl +0 -18
- package/references/minimem/.sudocode/specs.jsonl +0 -1
- package/references/minimem/CLAUDE.md +0 -310
- package/references/minimem/README.md +0 -562
- package/references/minimem/claude-plugin/.claude-plugin/plugin.json +0 -10
- package/references/minimem/claude-plugin/.mcp.json +0 -7
- package/references/minimem/claude-plugin/README.md +0 -158
- package/references/minimem/claude-plugin/commands/recall.md +0 -47
- package/references/minimem/claude-plugin/commands/remember.md +0 -41
- package/references/minimem/claude-plugin/hooks/__tests__/hooks.test.ts +0 -272
- package/references/minimem/claude-plugin/hooks/hooks.json +0 -27
- package/references/minimem/claude-plugin/hooks/session-end.sh +0 -86
- package/references/minimem/claude-plugin/hooks/session-start.sh +0 -85
- package/references/minimem/claude-plugin/skills/memory/SKILL.md +0 -108
- package/references/minimem/media/banner.png +0 -0
- package/references/minimem/package-lock.json +0 -5373
- package/references/minimem/package.json +0 -72
- package/references/minimem/scripts/postbuild.js +0 -35
- package/references/minimem/src/__tests__/edge-cases.test.ts +0 -371
- package/references/minimem/src/__tests__/errors.test.ts +0 -265
- package/references/minimem/src/__tests__/helpers.ts +0 -199
- package/references/minimem/src/__tests__/internal.test.ts +0 -407
- package/references/minimem/src/__tests__/knowledge.test.ts +0 -287
- package/references/minimem/src/__tests__/minimem.integration.test.ts +0 -1127
- package/references/minimem/src/__tests__/session.test.ts +0 -190
- package/references/minimem/src/cli/__tests__/commands.test.ts +0 -759
- package/references/minimem/src/cli/commands/__tests__/conflicts.test.ts +0 -141
- package/references/minimem/src/cli/commands/append.ts +0 -76
- package/references/minimem/src/cli/commands/config.ts +0 -262
- package/references/minimem/src/cli/commands/conflicts.ts +0 -413
- package/references/minimem/src/cli/commands/daemon.ts +0 -169
- package/references/minimem/src/cli/commands/index.ts +0 -12
- package/references/minimem/src/cli/commands/init.ts +0 -88
- package/references/minimem/src/cli/commands/mcp.ts +0 -177
- package/references/minimem/src/cli/commands/push-pull.ts +0 -213
- package/references/minimem/src/cli/commands/search.ts +0 -158
- package/references/minimem/src/cli/commands/status.ts +0 -84
- package/references/minimem/src/cli/commands/sync-init.ts +0 -290
- package/references/minimem/src/cli/commands/sync.ts +0 -70
- package/references/minimem/src/cli/commands/upsert.ts +0 -197
- package/references/minimem/src/cli/config.ts +0 -584
- package/references/minimem/src/cli/index.ts +0 -264
- package/references/minimem/src/cli/shared.ts +0 -161
- package/references/minimem/src/cli/sync/__tests__/central.test.ts +0 -152
- package/references/minimem/src/cli/sync/__tests__/conflicts.test.ts +0 -209
- package/references/minimem/src/cli/sync/__tests__/daemon.test.ts +0 -118
- package/references/minimem/src/cli/sync/__tests__/detection.test.ts +0 -207
- package/references/minimem/src/cli/sync/__tests__/integration.test.ts +0 -476
- package/references/minimem/src/cli/sync/__tests__/registry.test.ts +0 -363
- package/references/minimem/src/cli/sync/__tests__/state.test.ts +0 -255
- package/references/minimem/src/cli/sync/__tests__/validation.test.ts +0 -193
- package/references/minimem/src/cli/sync/__tests__/watcher.test.ts +0 -178
- package/references/minimem/src/cli/sync/central.ts +0 -292
- package/references/minimem/src/cli/sync/conflicts.ts +0 -204
- package/references/minimem/src/cli/sync/daemon.ts +0 -407
- package/references/minimem/src/cli/sync/detection.ts +0 -138
- package/references/minimem/src/cli/sync/index.ts +0 -107
- package/references/minimem/src/cli/sync/operations.ts +0 -373
- package/references/minimem/src/cli/sync/registry.ts +0 -279
- package/references/minimem/src/cli/sync/state.ts +0 -355
- package/references/minimem/src/cli/sync/validation.ts +0 -206
- package/references/minimem/src/cli/sync/watcher.ts +0 -234
- package/references/minimem/src/cli/version.ts +0 -34
- package/references/minimem/src/core/index.ts +0 -9
- package/references/minimem/src/core/indexer.ts +0 -628
- package/references/minimem/src/core/searcher.ts +0 -221
- package/references/minimem/src/db/schema.ts +0 -183
- package/references/minimem/src/db/sqlite-vec.ts +0 -24
- package/references/minimem/src/embeddings/__tests__/embeddings.test.ts +0 -431
- package/references/minimem/src/embeddings/batch-gemini.ts +0 -392
- package/references/minimem/src/embeddings/batch-openai.ts +0 -409
- package/references/minimem/src/embeddings/embeddings.ts +0 -434
- package/references/minimem/src/index.ts +0 -109
- package/references/minimem/src/internal.ts +0 -299
- package/references/minimem/src/minimem.ts +0 -1276
- package/references/minimem/src/search/__tests__/hybrid.test.ts +0 -247
- package/references/minimem/src/search/graph.ts +0 -234
- package/references/minimem/src/search/hybrid.ts +0 -151
- package/references/minimem/src/search/search.ts +0 -256
- package/references/minimem/src/server/__tests__/mcp.test.ts +0 -341
- package/references/minimem/src/server/__tests__/tools.test.ts +0 -364
- package/references/minimem/src/server/mcp.ts +0 -326
- package/references/minimem/src/server/tools.ts +0 -720
- package/references/minimem/src/session.ts +0 -460
- package/references/minimem/tsconfig.json +0 -19
- package/references/minimem/tsup.config.ts +0 -26
- package/references/minimem/vitest.config.ts +0 -24
- package/references/multi-agent-protocol/.sudocode/issues.jsonl +0 -111
- package/references/multi-agent-protocol/.sudocode/specs.jsonl +0 -13
- package/references/multi-agent-protocol/LICENSE +0 -21
- package/references/multi-agent-protocol/README.md +0 -113
- package/references/multi-agent-protocol/docs/00-design-specification.md +0 -496
- package/references/multi-agent-protocol/docs/01-open-questions.md +0 -1050
- package/references/multi-agent-protocol/docs/02-wire-protocol.md +0 -296
- package/references/multi-agent-protocol/docs/03-streaming-semantics.md +0 -252
- package/references/multi-agent-protocol/docs/04-error-handling.md +0 -231
- package/references/multi-agent-protocol/docs/05-connection-model.md +0 -244
- package/references/multi-agent-protocol/docs/06-visibility-permissions.md +0 -243
- package/references/multi-agent-protocol/docs/07-federation.md +0 -259
- package/references/multi-agent-protocol/docs/08-macro-agent-migration.md +0 -253
- package/references/multi-agent-protocol/docs/09-authentication.md +0 -680
- package/references/multi-agent-protocol/docs/10-mail-protocol.md +0 -553
- package/references/multi-agent-protocol/docs/agent-iam-integration.md +0 -877
- package/references/multi-agent-protocol/docs/agentic-mesh-integration-draft.md +0 -459
- package/references/multi-agent-protocol/docs/git-transport-draft.md +0 -251
- package/references/multi-agent-protocol/docs-site/Gemfile +0 -22
- package/references/multi-agent-protocol/docs-site/README.md +0 -82
- package/references/multi-agent-protocol/docs-site/_config.yml +0 -91
- package/references/multi-agent-protocol/docs-site/_includes/head_custom.html +0 -20
- package/references/multi-agent-protocol/docs-site/_sass/color_schemes/map.scss +0 -42
- package/references/multi-agent-protocol/docs-site/_sass/custom/custom.scss +0 -34
- package/references/multi-agent-protocol/docs-site/examples/full-integration.md +0 -510
- package/references/multi-agent-protocol/docs-site/examples/index.md +0 -138
- package/references/multi-agent-protocol/docs-site/examples/simple-chat.md +0 -282
- package/references/multi-agent-protocol/docs-site/examples/task-queue.md +0 -399
- package/references/multi-agent-protocol/docs-site/getting-started/index.md +0 -98
- package/references/multi-agent-protocol/docs-site/getting-started/installation.md +0 -219
- package/references/multi-agent-protocol/docs-site/getting-started/overview.md +0 -172
- package/references/multi-agent-protocol/docs-site/getting-started/quickstart.md +0 -237
- package/references/multi-agent-protocol/docs-site/index.md +0 -136
- package/references/multi-agent-protocol/docs-site/protocol/authentication.md +0 -391
- package/references/multi-agent-protocol/docs-site/protocol/connection-model.md +0 -376
- package/references/multi-agent-protocol/docs-site/protocol/design.md +0 -284
- package/references/multi-agent-protocol/docs-site/protocol/error-handling.md +0 -312
- package/references/multi-agent-protocol/docs-site/protocol/federation.md +0 -449
- package/references/multi-agent-protocol/docs-site/protocol/index.md +0 -129
- package/references/multi-agent-protocol/docs-site/protocol/permissions.md +0 -398
- package/references/multi-agent-protocol/docs-site/protocol/streaming.md +0 -353
- package/references/multi-agent-protocol/docs-site/protocol/wire-protocol.md +0 -369
- package/references/multi-agent-protocol/docs-site/sdk/api/agent.md +0 -357
- package/references/multi-agent-protocol/docs-site/sdk/api/client.md +0 -380
- package/references/multi-agent-protocol/docs-site/sdk/api/index.md +0 -62
- package/references/multi-agent-protocol/docs-site/sdk/api/server.md +0 -453
- package/references/multi-agent-protocol/docs-site/sdk/api/types.md +0 -468
- package/references/multi-agent-protocol/docs-site/sdk/guides/agent.md +0 -375
- package/references/multi-agent-protocol/docs-site/sdk/guides/authentication.md +0 -405
- package/references/multi-agent-protocol/docs-site/sdk/guides/client.md +0 -352
- package/references/multi-agent-protocol/docs-site/sdk/guides/index.md +0 -89
- package/references/multi-agent-protocol/docs-site/sdk/guides/server.md +0 -360
- package/references/multi-agent-protocol/docs-site/sdk/guides/testing.md +0 -446
- package/references/multi-agent-protocol/docs-site/sdk/guides/transports.md +0 -363
- package/references/multi-agent-protocol/docs-site/sdk/index.md +0 -206
- package/references/multi-agent-protocol/package-lock.json +0 -3886
- package/references/multi-agent-protocol/package.json +0 -56
- package/references/multi-agent-protocol/schema/meta.json +0 -467
- package/references/multi-agent-protocol/schema/schema.json +0 -2558
- package/references/openteams/.claude/settings.json +0 -6
- package/references/openteams/README.md +0 -1
- package/references/openteams/SKILL.md +0 -341
- package/references/openteams/design.md +0 -411
- package/references/openteams/examples/bmad-method/prompts/analyst/ROLE.md +0 -16
- package/references/openteams/examples/bmad-method/prompts/analyst/SOUL.md +0 -5
- package/references/openteams/examples/bmad-method/prompts/architect/ROLE.md +0 -24
- package/references/openteams/examples/bmad-method/prompts/architect/SOUL.md +0 -5
- package/references/openteams/examples/bmad-method/prompts/developer/ROLE.md +0 -25
- package/references/openteams/examples/bmad-method/prompts/developer/SOUL.md +0 -5
- package/references/openteams/examples/bmad-method/prompts/master/ROLE.md +0 -21
- package/references/openteams/examples/bmad-method/prompts/master/SOUL.md +0 -5
- package/references/openteams/examples/bmad-method/prompts/pm/ROLE.md +0 -20
- package/references/openteams/examples/bmad-method/prompts/pm/SOUL.md +0 -5
- package/references/openteams/examples/bmad-method/prompts/qa/ROLE.md +0 -17
- package/references/openteams/examples/bmad-method/prompts/qa/SOUL.md +0 -5
- package/references/openteams/examples/bmad-method/prompts/quick-flow-dev/ROLE.md +0 -23
- package/references/openteams/examples/bmad-method/prompts/quick-flow-dev/SOUL.md +0 -5
- package/references/openteams/examples/bmad-method/prompts/scrum-master/ROLE.md +0 -27
- package/references/openteams/examples/bmad-method/prompts/scrum-master/SOUL.md +0 -5
- package/references/openteams/examples/bmad-method/prompts/tech-writer/ROLE.md +0 -21
- package/references/openteams/examples/bmad-method/prompts/tech-writer/SOUL.md +0 -5
- package/references/openteams/examples/bmad-method/prompts/ux-designer/ROLE.md +0 -16
- package/references/openteams/examples/bmad-method/prompts/ux-designer/SOUL.md +0 -5
- package/references/openteams/examples/bmad-method/roles/analyst.yaml +0 -9
- package/references/openteams/examples/bmad-method/roles/architect.yaml +0 -9
- package/references/openteams/examples/bmad-method/roles/developer.yaml +0 -8
- package/references/openteams/examples/bmad-method/roles/master.yaml +0 -8
- package/references/openteams/examples/bmad-method/roles/pm.yaml +0 -9
- package/references/openteams/examples/bmad-method/roles/qa.yaml +0 -8
- package/references/openteams/examples/bmad-method/roles/quick-flow-dev.yaml +0 -8
- package/references/openteams/examples/bmad-method/roles/scrum-master.yaml +0 -9
- package/references/openteams/examples/bmad-method/roles/tech-writer.yaml +0 -8
- package/references/openteams/examples/bmad-method/roles/ux-designer.yaml +0 -8
- package/references/openteams/examples/bmad-method/team.yaml +0 -161
- package/references/openteams/examples/get-shit-done/prompts/codebase-mapper/ROLE.md +0 -17
- package/references/openteams/examples/get-shit-done/prompts/codebase-mapper/SOUL.md +0 -5
- package/references/openteams/examples/get-shit-done/prompts/debugger/ROLE.md +0 -25
- package/references/openteams/examples/get-shit-done/prompts/debugger/SOUL.md +0 -5
- package/references/openteams/examples/get-shit-done/prompts/executor/ROLE.md +0 -34
- package/references/openteams/examples/get-shit-done/prompts/executor/SOUL.md +0 -5
- package/references/openteams/examples/get-shit-done/prompts/integration-checker/ROLE.md +0 -18
- package/references/openteams/examples/get-shit-done/prompts/integration-checker/SOUL.md +0 -3
- package/references/openteams/examples/get-shit-done/prompts/orchestrator/ROLE.md +0 -42
- package/references/openteams/examples/get-shit-done/prompts/orchestrator/SOUL.md +0 -5
- package/references/openteams/examples/get-shit-done/prompts/phase-researcher/ROLE.md +0 -15
- package/references/openteams/examples/get-shit-done/prompts/phase-researcher/SOUL.md +0 -3
- package/references/openteams/examples/get-shit-done/prompts/plan-checker/ROLE.md +0 -17
- package/references/openteams/examples/get-shit-done/prompts/plan-checker/SOUL.md +0 -3
- package/references/openteams/examples/get-shit-done/prompts/planner/ROLE.md +0 -28
- package/references/openteams/examples/get-shit-done/prompts/planner/SOUL.md +0 -5
- package/references/openteams/examples/get-shit-done/prompts/project-researcher/ROLE.md +0 -16
- package/references/openteams/examples/get-shit-done/prompts/project-researcher/SOUL.md +0 -3
- package/references/openteams/examples/get-shit-done/prompts/research-synthesizer/ROLE.md +0 -13
- package/references/openteams/examples/get-shit-done/prompts/research-synthesizer/SOUL.md +0 -3
- package/references/openteams/examples/get-shit-done/prompts/roadmapper/ROLE.md +0 -14
- package/references/openteams/examples/get-shit-done/prompts/roadmapper/SOUL.md +0 -3
- package/references/openteams/examples/get-shit-done/prompts/verifier/ROLE.md +0 -19
- package/references/openteams/examples/get-shit-done/prompts/verifier/SOUL.md +0 -5
- package/references/openteams/examples/get-shit-done/roles/codebase-mapper.yaml +0 -8
- package/references/openteams/examples/get-shit-done/roles/debugger.yaml +0 -8
- package/references/openteams/examples/get-shit-done/roles/executor.yaml +0 -8
- package/references/openteams/examples/get-shit-done/roles/integration-checker.yaml +0 -8
- package/references/openteams/examples/get-shit-done/roles/orchestrator.yaml +0 -9
- package/references/openteams/examples/get-shit-done/roles/phase-researcher.yaml +0 -7
- package/references/openteams/examples/get-shit-done/roles/plan-checker.yaml +0 -8
- package/references/openteams/examples/get-shit-done/roles/planner.yaml +0 -8
- package/references/openteams/examples/get-shit-done/roles/project-researcher.yaml +0 -8
- package/references/openteams/examples/get-shit-done/roles/research-synthesizer.yaml +0 -7
- package/references/openteams/examples/get-shit-done/roles/roadmapper.yaml +0 -7
- package/references/openteams/examples/get-shit-done/roles/verifier.yaml +0 -8
- package/references/openteams/examples/get-shit-done/team.yaml +0 -154
- package/references/openteams/package-lock.json +0 -2181
- package/references/openteams/package.json +0 -48
- package/references/openteams/schema/role.schema.json +0 -125
- package/references/openteams/schema/team.schema.json +0 -284
- package/references/openteams/src/cli/agent.ts +0 -104
- package/references/openteams/src/cli/cli.test.ts +0 -381
- package/references/openteams/src/cli/generate.ts +0 -220
- package/references/openteams/src/cli/message.ts +0 -241
- package/references/openteams/src/cli/task.ts +0 -154
- package/references/openteams/src/cli/team.ts +0 -104
- package/references/openteams/src/cli/template.ts +0 -207
- package/references/openteams/src/cli.ts +0 -45
- package/references/openteams/src/db/database.test.ts +0 -185
- package/references/openteams/src/db/database.ts +0 -240
- package/references/openteams/src/generators/agent-prompt-generator.test.ts +0 -332
- package/references/openteams/src/generators/agent-prompt-generator.ts +0 -521
- package/references/openteams/src/generators/package-generator.test.ts +0 -129
- package/references/openteams/src/generators/package-generator.ts +0 -102
- package/references/openteams/src/generators/skill-generator.test.ts +0 -246
- package/references/openteams/src/generators/skill-generator.ts +0 -374
- package/references/openteams/src/index.ts +0 -104
- package/references/openteams/src/services/agent-service.test.ts +0 -158
- package/references/openteams/src/services/agent-service.ts +0 -84
- package/references/openteams/src/services/communication-service.test.ts +0 -455
- package/references/openteams/src/services/communication-service.ts +0 -371
- package/references/openteams/src/services/message-service.test.ts +0 -342
- package/references/openteams/src/services/message-service.ts +0 -203
- package/references/openteams/src/services/task-service.test.ts +0 -434
- package/references/openteams/src/services/task-service.ts +0 -239
- package/references/openteams/src/services/team-service.test.ts +0 -181
- package/references/openteams/src/services/team-service.ts +0 -139
- package/references/openteams/src/services/template-service.test.ts +0 -306
- package/references/openteams/src/services/template-service.ts +0 -182
- package/references/openteams/src/spawner/acp-factory.ts +0 -96
- package/references/openteams/src/spawner/interface.ts +0 -31
- package/references/openteams/src/spawner/mock.test.ts +0 -93
- package/references/openteams/src/spawner/mock.ts +0 -59
- package/references/openteams/src/template/loader.test.ts +0 -1319
- package/references/openteams/src/template/loader.ts +0 -698
- package/references/openteams/src/template/types.ts +0 -200
- package/references/openteams/src/types.ts +0 -205
- package/references/openteams/tsconfig.json +0 -18
- package/references/openteams/vitest.config.ts +0 -9
- package/references/skill-tree/.claude/settings.json +0 -6
- package/references/skill-tree/.sudocode/issues.jsonl +0 -11
- package/references/skill-tree/.sudocode/specs.jsonl +0 -1
- package/references/skill-tree/CLAUDE.md +0 -150
- package/references/skill-tree/README.md +0 -324
- package/references/skill-tree/docs/GAPS_v1.md +0 -221
- package/references/skill-tree/docs/INTEGRATION_PLAN.md +0 -467
- package/references/skill-tree/docs/TODOS.md +0 -91
- package/references/skill-tree/docs/anthropic_skill_guide.md +0 -1364
- package/references/skill-tree/docs/design/federated-skill-trees.md +0 -524
- package/references/skill-tree/docs/design/multi-agent-sync.md +0 -759
- package/references/skill-tree/docs/scraper/BRAINSTORM.md +0 -583
- package/references/skill-tree/docs/scraper/POC_PLAN.md +0 -420
- package/references/skill-tree/docs/scraper/README.md +0 -170
- package/references/skill-tree/examples/basic-usage.ts +0 -190
- package/references/skill-tree/package-lock.json +0 -1509
- package/references/skill-tree/package.json +0 -66
- package/references/skill-tree/scraper/README.md +0 -123
- package/references/skill-tree/scraper/docs/DESIGN.md +0 -683
- package/references/skill-tree/scraper/docs/PLAN.md +0 -336
- package/references/skill-tree/scraper/drizzle.config.ts +0 -10
- package/references/skill-tree/scraper/package-lock.json +0 -6329
- package/references/skill-tree/scraper/package.json +0 -68
- package/references/skill-tree/scraper/test/fixtures/invalid-skill/missing-description.md +0 -7
- package/references/skill-tree/scraper/test/fixtures/invalid-skill/missing-name.md +0 -7
- package/references/skill-tree/scraper/test/fixtures/minimal-skill/SKILL.md +0 -27
- package/references/skill-tree/scraper/test/fixtures/skill-json/SKILL.json +0 -21
- package/references/skill-tree/scraper/test/fixtures/skill-with-meta/SKILL.md +0 -54
- package/references/skill-tree/scraper/test/fixtures/skill-with-meta/_meta.json +0 -24
- package/references/skill-tree/scraper/test/fixtures/valid-skill/SKILL.md +0 -93
- package/references/skill-tree/scraper/test/fixtures/valid-skill/_meta.json +0 -22
- package/references/skill-tree/scraper/tsup.config.ts +0 -14
- package/references/skill-tree/scraper/vitest.config.ts +0 -17
- package/references/skill-tree/scripts/convert-to-vitest.ts +0 -166
- package/references/skill-tree/skills/skill-writer/SKILL.md +0 -339
- package/references/skill-tree/skills/skill-writer/references/examples.md +0 -326
- package/references/skill-tree/skills/skill-writer/references/patterns.md +0 -210
- package/references/skill-tree/skills/skill-writer/references/quality-checklist.md +0 -123
- package/references/skill-tree/test/run-all.ts +0 -106
- package/references/skill-tree/test/utils.ts +0 -128
- package/references/skill-tree/vitest.config.ts +0 -16
- package/src/__tests__/e2e/agent-spawn-visibility.e2e.test.ts +0 -761
- package/src/__tests__/e2e/cascade-termination.e2e.test.ts +0 -588
- package/src/__tests__/e2e/conflict-resolution-flow.e2e.test.ts +0 -790
- package/src/__tests__/e2e/full-agent-conflict-resolution.e2e.test.ts +0 -714
- package/src/__tests__/e2e/full-agent-orchestration.e2e.test.ts +0 -536
- package/src/__tests__/e2e/mcp-server-debug.e2e.test.ts +0 -372
- package/src/__tests__/e2e/mcp-thin-client-bridge.e2e.test.ts +0 -304
- package/src/__tests__/e2e/mcp-tools-available.e2e.test.ts +0 -324
- package/src/__tests__/e2e/multi-agent.e2e.test.ts +0 -1527
- package/src/__tests__/e2e/multi-coordinator.e2e.test.ts +0 -602
- package/src/__tests__/e2e/orchestration-flow.e2e.test.ts +0 -686
- package/src/__tests__/e2e/spawn-session-streaming.e2e.test.ts +0 -563
- package/src/__tests__/e2e/steering-task.e2e.test.ts +0 -840
- package/src/__tests__/integration.e2e.test.ts +0 -407
- package/src/acp/__tests__/combined-websocket-server.test.ts +0 -260
- package/src/acp/__tests__/history.test.ts +0 -530
- package/src/acp/__tests__/integration.test.ts +0 -1049
- package/src/acp/__tests__/multi-client-mounting.test.ts +0 -303
- package/src/acp/__tests__/session-persistence.test.ts +0 -276
- package/src/acp/__tests__/websocket-full.e2e.test.ts +0 -401
- package/src/acp/__tests__/websocket-integration.test.ts +0 -484
- package/src/acp/__tests__/websocket-stream.test.ts +0 -281
- package/src/acp/__tests__/websocket.e2e.test.ts +0 -390
- package/src/acp/websocket-stream.ts +0 -140
- package/src/activity/__tests__/deduplication.test.ts +0 -345
- package/src/activity/__tests__/relevance.test.ts +0 -347
- package/src/activity/__tests__/watcher.test.ts +0 -344
- package/src/activity/deduplication.ts +0 -219
- package/src/activity/index.ts +0 -51
- package/src/activity/relevance.ts +0 -258
- package/src/activity/types.ts +0 -263
- package/src/activity/watcher.ts +0 -345
- package/src/agent/__tests__/agent-manager.test.ts +0 -1382
- package/src/agent/__tests__/wake.test.ts +0 -768
- package/src/agent/wake.ts +0 -357
- package/src/api/__tests__/conversation-api.test.ts +0 -468
- package/src/cli/__tests__/acp.test.ts +0 -214
- package/src/lifecycle/__tests__/cascade-termination.test.ts +0 -919
- package/src/lifecycle/__tests__/cascade.test.ts +0 -595
- package/src/lifecycle/__tests__/cleanup.test.ts +0 -322
- package/src/lifecycle/__tests__/handlers.test.ts +0 -1879
- package/src/lifecycle/__tests__/lifecycle.e2e.test.ts +0 -354
- package/src/lifecycle/__tests__/merge-queue.e2e.test.ts +0 -602
- package/src/lifecycle/handlers/generic.ts +0 -87
- package/src/lifecycle/handlers/index.ts +0 -183
- package/src/lifecycle/handlers/integrator.ts +0 -672
- package/src/lifecycle/handlers/monitor.ts +0 -114
- package/src/lifecycle/handlers/worker.ts +0 -506
- package/src/mail/__tests__/conversation-lifecycle.test.ts +0 -409
- package/src/mail/__tests__/eventstore-stores.test.ts +0 -1073
- package/src/mail/__tests__/mail-full-agent.e2e.test.ts +0 -575
- package/src/mail/__tests__/mail-integration.test.ts +0 -759
- package/src/mail/__tests__/mail-map-protocol.e2e.test.ts +0 -1068
- package/src/mail/__tests__/mail-service.test.ts +0 -506
- package/src/mail/__tests__/turn-recorder.test.ts +0 -328
- package/src/mail/conversation-map.ts +0 -107
- package/src/mail/index.ts +0 -25
- package/src/mail/mail-service.ts +0 -257
- package/src/mail/stores/eventstore-conversation-store.ts +0 -146
- package/src/mail/stores/eventstore-participant-store.ts +0 -172
- package/src/mail/stores/eventstore-thread-store.ts +0 -129
- package/src/mail/stores/eventstore-turn-store.ts +0 -173
- package/src/mail/stores/index.ts +0 -12
- package/src/mail/stores/types.ts +0 -160
- package/src/mail/turn-recorder.ts +0 -124
- package/src/map/README.md +0 -79
- package/src/map/__tests__/adapter-types.test.ts +0 -326
- package/src/map/__tests__/interface-types.test.ts +0 -342
- package/src/map/__tests__/types.test.ts +0 -411
- package/src/map/adapter/__tests__/acp-over-map-cancel.test.ts +0 -820
- package/src/map/adapter/__tests__/acp-over-map-getmodels.test.ts +0 -355
- package/src/map/adapter/__tests__/acp-over-map-history.test.ts +0 -1386
- package/src/map/adapter/__tests__/acp-over-map-persistence.e2e.test.ts +0 -440
- package/src/map/adapter/__tests__/connection-manager.test.ts +0 -344
- package/src/map/adapter/__tests__/event-broadcast.test.ts +0 -420
- package/src/map/adapter/__tests__/event-log.test.ts +0 -527
- package/src/map/adapter/__tests__/event-translator.test.ts +0 -550
- package/src/map/adapter/__tests__/extensions.test.ts +0 -1387
- package/src/map/adapter/__tests__/map-adapter.test.ts +0 -926
- package/src/map/adapter/__tests__/mcp-bridge.test.ts +0 -1187
- package/src/map/adapter/__tests__/multi-client-broadcast.test.ts +0 -711
- package/src/map/adapter/__tests__/rpc-handler.test.ts +0 -644
- package/src/map/adapter/__tests__/stream-extensions.test.ts +0 -494
- package/src/map/adapter/__tests__/subscription-manager.test.ts +0 -536
- package/src/map/adapter/__tests__/websocket-integration.test.ts +0 -487
- package/src/map/adapter/__tests__/workspace-files.test.ts +0 -673
- package/src/map/adapter/acp-over-map.ts +0 -1483
- package/src/map/adapter/connection-manager.ts +0 -400
- package/src/map/adapter/event-log.ts +0 -208
- package/src/map/adapter/event-translator.ts +0 -415
- package/src/map/adapter/extensions/agent-detection.ts +0 -201
- package/src/map/adapter/extensions/agent-lifecycle.ts +0 -267
- package/src/map/adapter/extensions/index.ts +0 -316
- package/src/map/adapter/extensions/mcp-bridge.ts +0 -995
- package/src/map/adapter/extensions/resume.ts +0 -114
- package/src/map/adapter/extensions/streams.ts +0 -839
- package/src/map/adapter/extensions/task.ts +0 -326
- package/src/map/adapter/extensions/update-metadata.ts +0 -126
- package/src/map/adapter/extensions/wake.ts +0 -239
- package/src/map/adapter/extensions/workspace-files.ts +0 -449
- package/src/map/adapter/extensions/workspace.ts +0 -176
- package/src/map/adapter/index.ts +0 -163
- package/src/map/adapter/interface.ts +0 -581
- package/src/map/adapter/mail-handler-adapter.ts +0 -429
- package/src/map/adapter/map-adapter.ts +0 -1749
- package/src/map/adapter/rpc-handler.ts +0 -604
- package/src/map/adapter/subscription-manager.ts +0 -474
- package/src/map/adapter/types.ts +0 -266
- package/src/map/adapter/websocket-integration.ts +0 -229
- package/src/map/federation/__tests__/envelope.test.ts +0 -362
- package/src/map/federation/__tests__/federation-handler.test.ts +0 -461
- package/src/map/federation/envelope.ts +0 -243
- package/src/map/federation/federation-handler.ts +0 -442
- package/src/map/federation/index.ts +0 -65
- package/src/map/federation/types.ts +0 -344
- package/src/mcp/__tests__/map-client.test.ts +0 -386
- package/src/mcp/__tests__/mcp-server-thin-client.test.ts +0 -368
- package/src/mcp/__tests__/mcp-server.test.ts +0 -1002
- package/src/mcp/map-client.ts +0 -177
- package/src/mcp/mcp-server.ts +0 -1406
- package/src/mcp/tools/__tests__/done.test.ts +0 -484
- package/src/mcp/tools/claim_task.ts +0 -86
- package/src/mcp/tools/done.ts +0 -357
- package/src/mcp/tools/inject_context.ts +0 -173
- package/src/mcp/tools/list_claimable_tasks.ts +0 -93
- package/src/mcp/tools/unclaim_task.ts +0 -71
- package/src/mcp/tools/wait_for_activity.ts +0 -185
- package/src/monitor/__tests__/health-check-service.test.ts +0 -425
- package/src/monitor/__tests__/stale-agent-flow.integration.test.ts +0 -393
- package/src/monitor/__tests__/stall-detector.test.ts +0 -395
- package/src/monitor/health-check-service.ts +0 -359
- package/src/monitor/index.ts +0 -28
- package/src/monitor/stall-detector.ts +0 -238
- package/src/peer/__tests__/capability-manager.test.ts +0 -454
- package/src/peer/__tests__/encapsulation-manager.test.ts +0 -787
- package/src/peer/__tests__/federation-manager.test.ts +0 -828
- package/src/peer/__tests__/hierarchy-errors.test.ts +0 -307
- package/src/peer/__tests__/peer-manager.test.ts +0 -535
- package/src/peer/__tests__/task-delegation.test.ts +0 -741
- package/src/peer/capability-manager.ts +0 -289
- package/src/peer/encapsulation-manager.ts +0 -831
- package/src/peer/federation-manager.ts +0 -897
- package/src/peer/hierarchy-errors.ts +0 -382
- package/src/peer/hierarchy-protocol.ts +0 -328
- package/src/peer/index.ts +0 -15
- package/src/peer/peer-manager.ts +0 -540
- package/src/peer/task-delegation.ts +0 -594
- package/src/peer/transports/__tests__/local-transport.test.ts +0 -355
- package/src/peer/transports/__tests__/websocket-transport.test.ts +0 -270
- package/src/peer/transports/index.ts +0 -18
- package/src/peer/transports/local-transport.ts +0 -348
- package/src/peer/transports/websocket-transport.ts +0 -452
- package/src/peer/types.ts +0 -331
- package/src/roles/__tests__/capability-enforcement.test.ts +0 -989
- package/src/roles/__tests__/message-routing.e2e.test.ts +0 -464
- package/src/roles/__tests__/role-resolution.test.ts +0 -576
- package/src/router/README.md +0 -120
- package/src/router/__tests__/address-resolver.test.ts +0 -340
- package/src/router/__tests__/broadcast.test.ts +0 -185
- package/src/router/__tests__/message-router.test.ts +0 -1070
- package/src/router/__tests__/role-channel.test.ts +0 -213
- package/src/router/__tests__/send-to-address.test.ts +0 -731
- package/src/router/__tests__/wake.test.ts +0 -459
- package/src/router/address-resolver.ts +0 -303
- package/src/router/broadcast.ts +0 -117
- package/src/router/channels.ts +0 -283
- package/src/router/index.ts +0 -148
- package/src/router/message-router.ts +0 -1392
- package/src/router/message-types.ts +0 -294
- package/src/router/role-resolver.ts +0 -164
- package/src/router/signals.ts +0 -335
- package/src/router/types.ts +0 -306
- package/src/router/wake.ts +0 -270
- package/src/server/__tests__/combined-server.test.ts +0 -360
- package/src/server/combined-server.ts +0 -544
- package/src/steering/__tests__/inject.test.ts +0 -405
- package/src/steering/__tests__/injection.e2e.test.ts +0 -932
- package/src/steering/__tests__/steering-integration.test.ts +0 -747
- package/src/steering/index.ts +0 -25
- package/src/steering/inject.ts +0 -262
- package/src/steering/types.ts +0 -143
- package/src/store/README.md +0 -134
- package/src/store/__tests__/event-store-oob.test.ts +0 -109
- package/src/store/__tests__/event-store.test.ts +0 -1446
- package/src/store/__tests__/instance.test.ts +0 -556
- package/src/store/__tests__/migrations.test.ts +0 -109
- package/src/store/backends/__tests__/memory-backend.test.ts +0 -383
- package/src/store/backends/__tests__/sqlite-backend.test.ts +0 -427
- package/src/store/backends/index.ts +0 -42
- package/src/store/backends/json-backend.ts +0 -295
- package/src/store/backends/memory-backend.ts +0 -256
- package/src/store/backends/sqlite-backend.ts +0 -337
- package/src/store/backends/tinybase-backend.ts +0 -276
- package/src/store/backends/types.ts +0 -252
- package/src/store/event-store.ts +0 -2214
- package/src/store/instance.ts +0 -681
- package/src/store/migrations.ts +0 -96
- package/src/store/types/config.ts +0 -19
- package/src/store/types/conversations.ts +0 -129
- package/src/store/types/sessions.ts +0 -53
- package/src/task/__tests__/retry-policy.test.ts +0 -409
- package/src/task/__tests__/task-integration.test.ts +0 -457
- package/src/task/__tests__/task-manager.test.ts +0 -815
- package/src/task/backend/__tests__/create-task-backend.test.ts +0 -225
- package/src/task/backend/__tests__/e2e/unified-tool-provider-opentasks.e2e.test.ts +0 -524
- package/src/task/backend/__tests__/memory-pull-mode.test.ts +0 -153
- package/src/task/backend/__tests__/memory.test.ts +0 -1274
- package/src/task/backend/__tests__/unified-tool-provider.test.ts +0 -579
- package/src/task/backend/index.ts +0 -310
- package/src/task/backend/memory.ts +0 -828
- package/src/task/backend/opentasks/__tests__/backend.test.ts +0 -968
- package/src/task/backend/opentasks/__tests__/daemon-manager.test.ts +0 -406
- package/src/task/backend/opentasks/__tests__/mapping.test.ts +0 -84
- package/src/task/backend/opentasks/__tests__/opentasks-backend.e2e.test.ts +0 -1338
- package/src/task/backend/opentasks/backend.ts +0 -1323
- package/src/task/backend/opentasks/client.ts +0 -652
- package/src/task/backend/opentasks/daemon-manager.ts +0 -256
- package/src/task/backend/opentasks/index.ts +0 -69
- package/src/task/backend/opentasks/mapping.ts +0 -94
- package/src/task/backend/types.ts +0 -458
- package/src/task/backend/unified-tool-provider.ts +0 -779
- package/src/task/index.ts +0 -7
- package/src/task/retry-policy.ts +0 -204
- package/src/task/task-manager.ts +0 -515
- package/src/task/types.ts +0 -136
- package/src/teams/CLAUDE.md +0 -180
- package/src/teams/__tests__/cross-subsystem.integration.test.ts +0 -983
- package/src/teams/__tests__/e2e/team-runtime.e2e.test.ts +0 -553
- package/src/teams/__tests__/e2e/workspace-isolation.e2e.test.ts +0 -1263
- package/src/teams/__tests__/team-manager.test.ts +0 -814
- package/src/teams/__tests__/team-system.test.ts +0 -2563
- package/src/teams/team-manager.ts +0 -387
- package/src/teams/team-runtime.ts +0 -1198
- package/src/trigger/CLAUDE.md +0 -308
- package/src/trigger/README.md +0 -429
- package/src/trigger/__tests__/macro-agent-regression.test.ts +0 -946
- package/src/trigger/__tests__/routing-strategies.test.ts +0 -329
- package/src/trigger/__tests__/trigger-router.test.ts +0 -433
- package/src/trigger/__tests__/trigger-system-integration.test.ts +0 -581
- package/src/trigger/router/index.ts +0 -36
- package/src/trigger/router/strategies/ai-router-strategy.ts +0 -481
- package/src/trigger/router/strategies/direct-strategy.ts +0 -162
- package/src/trigger/router/strategies/index.ts +0 -26
- package/src/trigger/router/strategies/role-strategy.ts +0 -274
- package/src/trigger/router/trigger-router.ts +0 -463
- package/src/trigger/router/types.ts +0 -273
- package/src/trigger/trigger-system.ts +0 -206
- package/src/workspace/__tests__/multi-coordinator.test.ts +0 -1005
- package/src/workspace/__tests__/workspace-manager.test.ts +0 -391
- package/src/workspace/__tests__/workspace.e2e.test.ts +0 -1155
- package/src/workspace/merge-queue/__tests__/hierarchical-consolidation.e2e.test.ts +0 -414
- package/test_fixtures/harness/__tests__/behavior-executor-and-stepper.test.ts +0 -714
- package/test_fixtures/harness/__tests__/fixtures.test.ts +0 -347
- package/test_fixtures/harness/__tests__/merge-queue-and-worktrees.test.ts +0 -452
- package/test_fixtures/harness/__tests__/temp-repo-and-simulator.test.ts +0 -422
- package/test_fixtures/harness/__tests__/test-harness-and-assertions.test.ts +0 -568
- /package/{references/acp-factory-ref/python/tests/__init__.py → .opentasks/graph.jsonl} +0 -0
package/src/acp/macro-agent.ts
CHANGED
|
@@ -1,1887 +1,827 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MacroAgent
|
|
2
|
+
* MacroAgent — ACP Agent implementation for macro-agent.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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
|
|
6
10
|
*/
|
|
7
11
|
|
|
8
12
|
import type {
|
|
9
|
-
Agent,
|
|
10
|
-
AgentSideConnection,
|
|
13
|
+
Agent as ACPAgent,
|
|
11
14
|
InitializeRequest,
|
|
12
15
|
InitializeResponse,
|
|
13
16
|
NewSessionRequest,
|
|
14
17
|
NewSessionResponse,
|
|
15
18
|
LoadSessionRequest,
|
|
16
19
|
LoadSessionResponse,
|
|
17
|
-
AuthenticateRequest,
|
|
18
|
-
AuthenticateResponse,
|
|
19
20
|
PromptRequest,
|
|
20
21
|
PromptResponse,
|
|
22
|
+
AuthenticateRequest,
|
|
23
|
+
AuthenticateResponse,
|
|
21
24
|
CancelNotification,
|
|
22
25
|
SessionNotification,
|
|
23
|
-
|
|
26
|
+
SessionUpdate,
|
|
24
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";
|
|
25
31
|
import type { AgentManager } from "../agent/agent-manager.js";
|
|
26
|
-
import type {
|
|
27
|
-
import type {
|
|
28
|
-
import type { AgentId } from "../store/types/index.js";
|
|
32
|
+
import type { InboxAdapter, TasksAdapter } from "../adapters/types.js";
|
|
33
|
+
import type { MacroAgentSystemV2 } from "../boot-v2.js";
|
|
29
34
|
import { SessionMapper } from "./session-mapper.js";
|
|
30
|
-
import type {
|
|
31
|
-
ACPSessionId,
|
|
32
|
-
ACPExtensionMethod,
|
|
33
|
-
SpawnAgentRequest,
|
|
34
|
-
SpawnAgentResponse,
|
|
35
|
-
GetHierarchyRequest,
|
|
36
|
-
GetHierarchyResponse,
|
|
37
|
-
GetTaskRequest,
|
|
38
|
-
GetTaskResponse,
|
|
39
|
-
MountAgentRequest,
|
|
40
|
-
MountAgentResponse,
|
|
41
|
-
ForkAgentRequest,
|
|
42
|
-
ForkAgentResponse,
|
|
43
|
-
MacroAgentInitConfig,
|
|
44
|
-
SubAgentConfig,
|
|
45
|
-
SendPeerMessageACPRequest,
|
|
46
|
-
SendPeerMessageACPResponse,
|
|
47
|
-
SendPeerRequestACPRequest,
|
|
48
|
-
SendPeerRequestACPResponse,
|
|
49
|
-
DeliverPeerMessageRequest,
|
|
50
|
-
DeliverPeerMessageResponse,
|
|
51
|
-
DeliverPeerRequestRequest,
|
|
52
|
-
DeliverPeerRequestResponse,
|
|
53
|
-
GrantCapabilityRequest,
|
|
54
|
-
GrantCapabilityResponse,
|
|
55
|
-
RevokeCapabilityRequest,
|
|
56
|
-
RevokeCapabilityResponse,
|
|
57
|
-
GetCapabilitiesRequest,
|
|
58
|
-
GetCapabilitiesResponse,
|
|
59
|
-
CheckCapabilityRequest,
|
|
60
|
-
CheckCapabilityResponse,
|
|
61
|
-
RespondToPermissionRequest,
|
|
62
|
-
RespondToPermissionResponse,
|
|
63
|
-
CancelPermissionRequest,
|
|
64
|
-
CancelPermissionResponse,
|
|
65
|
-
SetPermissionModeRequest,
|
|
66
|
-
SetPermissionModeResponse,
|
|
67
|
-
ResumeAgentRequest,
|
|
68
|
-
ResumeAgentResponse,
|
|
69
|
-
GetHistoryRequest,
|
|
70
|
-
GetHistoryResponse,
|
|
71
|
-
HistoryTurn,
|
|
72
|
-
} from "./types.js";
|
|
73
35
|
import { ACPError } from "./types.js";
|
|
74
|
-
import type {
|
|
75
|
-
import type {
|
|
76
|
-
import
|
|
77
|
-
import type { RoleRegistry, Capability } from "../roles/types.js";
|
|
78
|
-
import { AGENT_CAPABILITIES } from "../roles/capabilities.js";
|
|
79
|
-
import { DefaultRoleRegistry } from "../roles/registry.js";
|
|
36
|
+
import type { MacroAgentInitConfig } from "./types.js";
|
|
37
|
+
import type { TrajectoryCheckpointPayload } from "../map/types.js";
|
|
38
|
+
import { execSync } from "node:child_process";
|
|
80
39
|
|
|
81
40
|
// ─────────────────────────────────────────────────────────────────
|
|
82
|
-
//
|
|
41
|
+
// Configuration
|
|
83
42
|
// ─────────────────────────────────────────────────────────────────
|
|
84
43
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (Array.isArray(rawOutput)) {
|
|
89
|
-
return rawOutput
|
|
90
|
-
.filter((item: any) => item.type === "text" && typeof item.text === "string")
|
|
91
|
-
.map((item: any) => item.text as string)
|
|
92
|
-
.join("\n") || undefined;
|
|
93
|
-
}
|
|
94
|
-
return undefined;
|
|
44
|
+
export interface MacroAgentConfig {
|
|
45
|
+
system: MacroAgentSystemV2;
|
|
46
|
+
initConfig?: MacroAgentInitConfig;
|
|
95
47
|
}
|
|
96
48
|
|
|
97
49
|
// ─────────────────────────────────────────────────────────────────
|
|
98
|
-
//
|
|
50
|
+
// Extension method names
|
|
99
51
|
// ─────────────────────────────────────────────────────────────────
|
|
100
52
|
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
const SUPPORTED_EXTENSIONS: ACPExtensionMethod[] = [
|
|
53
|
+
const SUPPORTED_EXTENSIONS = [
|
|
104
54
|
"_macro/spawnAgent",
|
|
105
55
|
"_macro/getHierarchy",
|
|
106
56
|
"_macro/getTask",
|
|
107
57
|
"_macro/mountAgent",
|
|
108
58
|
"_macro/forkAgent",
|
|
109
|
-
"_macro/sendPeerMessage",
|
|
110
|
-
"_macro/sendPeerRequest",
|
|
111
|
-
"_macro/deliverPeerMessage",
|
|
112
|
-
"_macro/deliverPeerRequest",
|
|
113
|
-
"_macro/grantCapability",
|
|
114
|
-
"_macro/revokeCapability",
|
|
115
|
-
"_macro/getCapabilities",
|
|
116
|
-
"_macro/checkCapability",
|
|
117
|
-
"_macro/respondToPermission",
|
|
118
|
-
"_macro/cancelPermission",
|
|
119
|
-
"_macro/setPermissionMode",
|
|
120
59
|
"_macro/resume",
|
|
121
60
|
"_macro/getHistory",
|
|
122
61
|
"_macro/getModels",
|
|
123
|
-
|
|
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];
|
|
124
80
|
|
|
125
81
|
// ─────────────────────────────────────────────────────────────────
|
|
126
|
-
//
|
|
82
|
+
// Type Guards
|
|
127
83
|
// ─────────────────────────────────────────────────────────────────
|
|
128
84
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
+
]);
|
|
138
98
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
+
);
|
|
150
112
|
}
|
|
151
113
|
|
|
152
|
-
// ─────────────────────────────────────────────────────────────────
|
|
153
|
-
// Helpers
|
|
154
|
-
// ─────────────────────────────────────────────────────────────────
|
|
155
|
-
|
|
156
114
|
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
115
|
+
* Type guard: returns true if the update is a PermissionRequestUpdate
|
|
116
|
+
* from acp-factory (emitted when the agent is in interactive permission mode).
|
|
159
117
|
*/
|
|
160
|
-
function
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
+
);
|
|
166
125
|
}
|
|
167
126
|
|
|
168
127
|
// ─────────────────────────────────────────────────────────────────
|
|
169
|
-
//
|
|
128
|
+
// Factory
|
|
170
129
|
// ─────────────────────────────────────────────────────────────────
|
|
171
130
|
|
|
172
131
|
/**
|
|
173
|
-
*
|
|
174
|
-
*
|
|
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
|
+
* ```
|
|
175
141
|
*/
|
|
176
|
-
export
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
constructor(connection: AgentSideConnection, config: MacroAgentConfig) {
|
|
207
|
-
this.connection = connection;
|
|
208
|
-
this.agentManager = config.agentManager;
|
|
209
|
-
this.eventStore = config.eventStore;
|
|
210
|
-
this.taskManager = config.taskManager;
|
|
211
|
-
this.peerManager = config.peerManager;
|
|
212
|
-
this.capabilityManager = config.capabilityManager;
|
|
213
|
-
this.roleRegistry = config.roleRegistry ?? new DefaultRoleRegistry();
|
|
214
|
-
this.sessionMapper = new SessionMapper(config.eventStore);
|
|
215
|
-
this.defaultCwd = config.defaultCwd ?? process.cwd();
|
|
216
|
-
|
|
217
|
-
// Recover persisted sessions from the EventStore
|
|
218
|
-
const recovered = this.sessionMapper.recoverFromStore();
|
|
219
|
-
if (recovered > 0) {
|
|
220
|
-
console.log(
|
|
221
|
-
`[MacroAgent] Recovered ${recovered} session(s) from EventStore`,
|
|
222
|
-
);
|
|
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
|
+
// Git info (cached — read once per session)
|
|
158
|
+
let gitInfo: { branch: string | null; commitHash: string | null; remoteUrl: string | null } | null = null;
|
|
159
|
+
function getGitInfo(cwd: string): { branch: string | null; commitHash: string | null; remoteUrl: string | null } {
|
|
160
|
+
if (gitInfo) return gitInfo;
|
|
161
|
+
try {
|
|
162
|
+
const branch = execSync("git rev-parse --abbrev-ref HEAD", { cwd, timeout: 3000 }).toString().trim() || null;
|
|
163
|
+
const commitHash = execSync("git rev-parse HEAD", { cwd, timeout: 3000 }).toString().trim() || null;
|
|
164
|
+
let remoteUrl: string | null = null;
|
|
165
|
+
try {
|
|
166
|
+
remoteUrl = execSync("git remote get-url origin", { cwd, timeout: 3000 }).toString().trim() || null;
|
|
167
|
+
} catch { /* no remote */ }
|
|
168
|
+
gitInfo = { branch, commitHash, remoteUrl };
|
|
169
|
+
} catch {
|
|
170
|
+
gitInfo = { branch: null, commitHash: null, remoteUrl: null };
|
|
223
171
|
}
|
|
172
|
+
return gitInfo;
|
|
224
173
|
}
|
|
225
174
|
|
|
226
|
-
//
|
|
227
|
-
// Core ACP Methods
|
|
228
|
-
// ─────────────────────────────────────────────────────────────────
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Initialize the connection and advertise capabilities
|
|
232
|
-
*
|
|
233
|
-
* Reads configuration from `params._meta?.macroConfig` if provided.
|
|
234
|
-
* This allows each macro-agent instance to have different settings.
|
|
235
|
-
*/
|
|
236
|
-
async initialize(params: InitializeRequest): Promise<InitializeResponse> {
|
|
237
|
-
// Extract macro-agent config from _meta if provided
|
|
238
|
-
const meta = params._meta as Record<string, unknown> | undefined;
|
|
239
|
-
if (meta?.macroConfig) {
|
|
240
|
-
this.initConfig = meta.macroConfig as MacroAgentInitConfig;
|
|
241
|
-
|
|
242
|
-
// Apply defaultCwd from init config if provided
|
|
243
|
-
if (this.initConfig.defaultCwd) {
|
|
244
|
-
this.defaultCwd = this.initConfig.defaultCwd;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
175
|
+
// ── Helpers ──────────────────────────────────────────────────
|
|
247
176
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
},
|
|
258
|
-
},
|
|
259
|
-
};
|
|
177
|
+
function getSessionOrThrow(sessionId: string) {
|
|
178
|
+
const mapping = sessionMapper.getMapping(sessionId);
|
|
179
|
+
if (!mapping) {
|
|
180
|
+
throw RequestError.invalidParams(
|
|
181
|
+
{ sessionId },
|
|
182
|
+
`Session not found: ${sessionId}`,
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
return mapping;
|
|
260
186
|
}
|
|
261
187
|
|
|
262
|
-
|
|
263
|
-
* Create a new session by spawning a head manager
|
|
264
|
-
*/
|
|
265
|
-
async newSession(params: NewSessionRequest): Promise<NewSessionResponse> {
|
|
266
|
-
const cwd = params.cwd ?? this.defaultCwd;
|
|
267
|
-
|
|
268
|
-
// Build head manager options from init config
|
|
269
|
-
const defaultConfig = this.initConfig.defaultSubAgentConfig;
|
|
270
|
-
const permissionModeToUse = defaultConfig?.permissionMode;
|
|
271
|
-
|
|
272
|
-
// Spawn a new head manager for this session
|
|
273
|
-
const spawned = await this.agentManager.getOrCreateHeadManager({
|
|
274
|
-
cwd,
|
|
275
|
-
forceNew: true, // Always create new for newSession
|
|
276
|
-
permissionMode: permissionModeToUse,
|
|
277
|
-
systemPrompt: this.buildSystemPrompt(),
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
// Create session mapping
|
|
281
|
-
const acpSessionId = spawned.session_id;
|
|
282
|
-
this.sessionMapper.createMapping(acpSessionId, spawned.id);
|
|
283
|
-
|
|
284
|
-
// Create abort controller for cancellation
|
|
285
|
-
this.cancellationControllers.set(acpSessionId, new AbortController());
|
|
286
|
-
|
|
287
|
-
// Create a conversation in EventStore for history tracking
|
|
288
|
-
this.ensureConversation(acpSessionId, spawned.id);
|
|
289
|
-
|
|
290
|
-
// Emit session_info_update so client has title/timestamps
|
|
291
|
-
await this.emitSessionInfo(acpSessionId);
|
|
292
|
-
|
|
293
|
-
return {
|
|
294
|
-
sessionId: acpSessionId,
|
|
295
|
-
models: buildModelState(spawned.session.models),
|
|
296
|
-
};
|
|
297
|
-
}
|
|
188
|
+
// ── Extension dispatcher ────────────────────────────────────
|
|
298
189
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
?.agentId as string | undefined;
|
|
312
|
-
if (metaAgentId) {
|
|
313
|
-
const agent = this.eventStore.getAgent(metaAgentId as AgentId);
|
|
314
|
-
if (!agent) {
|
|
315
|
-
throw new Error(`Agent not found: ${metaAgentId}`);
|
|
316
|
-
}
|
|
317
|
-
acpSessionId = agent.session_id;
|
|
318
|
-
console.log(
|
|
319
|
-
`[MacroAgent] loadSession: Resolved agentId ${metaAgentId} to session ${acpSessionId}`,
|
|
190
|
+
async function handleExtension(
|
|
191
|
+
method: string,
|
|
192
|
+
params: Record<string, unknown>,
|
|
193
|
+
): Promise<Record<string, unknown>> {
|
|
194
|
+
// Check if it's a stubbed peer method
|
|
195
|
+
if (
|
|
196
|
+
(STUBBED_PEER_EXTENSIONS as readonly string[]).includes(method)
|
|
197
|
+
) {
|
|
198
|
+
throw new ACPError(
|
|
199
|
+
`Peer manager not available: ${method}`,
|
|
200
|
+
"NO_PEER_MANAGER",
|
|
201
|
+
{ method },
|
|
320
202
|
);
|
|
321
203
|
}
|
|
322
204
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
this.sessionMapper.createMapping(acpSessionId, existing.id);
|
|
335
|
-
if (!this.cancellationControllers.has(acpSessionId)) {
|
|
336
|
-
this.cancellationControllers.set(acpSessionId, new AbortController());
|
|
337
|
-
}
|
|
338
|
-
this.ensureConversation(acpSessionId, existing.id);
|
|
339
|
-
await this.emitSessionInfo(acpSessionId);
|
|
340
|
-
const activeSession = this.agentManager.getSession(existing.id);
|
|
205
|
+
switch (method as SupportedExtension) {
|
|
206
|
+
case "_macro/spawnAgent": {
|
|
207
|
+
const task = params.task as string;
|
|
208
|
+
if (!task) throw RequestError.invalidParams(params, "task is required");
|
|
209
|
+
const spawned = await agentManager.spawn({
|
|
210
|
+
task,
|
|
211
|
+
parent: params.parent as string | undefined,
|
|
212
|
+
cwd: (params.cwd as string) ?? defaultCwd,
|
|
213
|
+
role: params.role as string | undefined,
|
|
214
|
+
permissionMode: params.permissionMode as "auto-approve" | undefined,
|
|
215
|
+
});
|
|
341
216
|
return {
|
|
342
|
-
|
|
217
|
+
agentId: spawned.id,
|
|
218
|
+
sessionId: spawned.session_id,
|
|
219
|
+
role: spawned.agent.role,
|
|
220
|
+
state: spawned.agent.state,
|
|
343
221
|
};
|
|
344
222
|
}
|
|
345
223
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
// Create session mapping
|
|
354
|
-
this.sessionMapper.createMapping(acpSessionId, spawned.id);
|
|
355
|
-
this.cancellationControllers.set(acpSessionId, new AbortController());
|
|
356
|
-
this.ensureConversation(acpSessionId, spawned.id);
|
|
357
|
-
await this.emitSessionInfo(acpSessionId);
|
|
358
|
-
|
|
359
|
-
return {
|
|
360
|
-
models: buildModelState(spawned.session.models),
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
// No existing agent found - try to get or create with the specific session ID
|
|
365
|
-
console.log(
|
|
366
|
-
`[MacroAgent] loadSession: No existing agent for session ${acpSessionId}, creating new`,
|
|
367
|
-
);
|
|
368
|
-
const defaultConfig = this.initConfig.defaultSubAgentConfig;
|
|
369
|
-
const spawned = await this.agentManager.getOrCreateHeadManager({
|
|
370
|
-
cwd,
|
|
371
|
-
sessionId: acpSessionId,
|
|
372
|
-
permissionMode: defaultConfig?.permissionMode,
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
// Create session mapping
|
|
376
|
-
this.sessionMapper.createMapping(acpSessionId, spawned.id);
|
|
377
|
-
this.cancellationControllers.set(acpSessionId, new AbortController());
|
|
378
|
-
this.ensureConversation(acpSessionId, spawned.id);
|
|
379
|
-
await this.emitSessionInfo(acpSessionId);
|
|
380
|
-
|
|
381
|
-
return {
|
|
382
|
-
models: buildModelState(spawned.session.models),
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* Authenticate - macro-agent doesn't require authentication
|
|
388
|
-
*/
|
|
389
|
-
async authenticate(
|
|
390
|
-
_params: AuthenticateRequest,
|
|
391
|
-
): Promise<AuthenticateResponse> {
|
|
392
|
-
// No authentication required
|
|
393
|
-
return {};
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* Process a prompt by routing to the mapped agent
|
|
398
|
-
*/
|
|
399
|
-
async prompt(params: PromptRequest): Promise<PromptResponse> {
|
|
400
|
-
const acpSessionId = params.sessionId;
|
|
401
|
-
|
|
402
|
-
// Get the mapped agent
|
|
403
|
-
const agentId = this.sessionMapper.getAgentIdOrThrow(acpSessionId);
|
|
404
|
-
|
|
405
|
-
// Get or set up abort controller
|
|
406
|
-
let abortController = this.cancellationControllers.get(acpSessionId);
|
|
407
|
-
if (!abortController || abortController.signal.aborted) {
|
|
408
|
-
abortController = new AbortController();
|
|
409
|
-
this.cancellationControllers.set(acpSessionId, abortController);
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
// Extract message content from prompt blocks
|
|
413
|
-
const messageContent = this.extractMessageContent(params.prompt);
|
|
414
|
-
|
|
415
|
-
// Mark session as processing (for health monitoring)
|
|
416
|
-
this.sessionMapper.setProcessing(acpSessionId, true);
|
|
417
|
-
|
|
418
|
-
// Initialize prompt buffer and tool info cache for history accumulation
|
|
419
|
-
this.promptBuffers.set(acpSessionId, { parts: [] });
|
|
420
|
-
this.toolInfoCaches.set(acpSessionId, new Map());
|
|
421
|
-
|
|
422
|
-
try {
|
|
423
|
-
// Stream responses from the agent
|
|
424
|
-
for await (const update of this.agentManager.prompt(
|
|
425
|
-
agentId,
|
|
426
|
-
messageContent,
|
|
427
|
-
)) {
|
|
428
|
-
// Check for cancellation
|
|
429
|
-
if (abortController.signal.aborted) {
|
|
430
|
-
return {
|
|
431
|
-
stopReason: "cancelled",
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
// Forward session updates to the client
|
|
436
|
-
await this.forwardSessionUpdate(acpSessionId, update);
|
|
224
|
+
case "_macro/getHierarchy": {
|
|
225
|
+
const agentId = params.agentId as string;
|
|
226
|
+
if (!agentId) throw RequestError.invalidParams(params, "agentId is required");
|
|
227
|
+
const hierarchy = agentManager.getHierarchy(agentId, {
|
|
228
|
+
depth: params.depth as number | undefined,
|
|
229
|
+
});
|
|
230
|
+
return { hierarchy: hierarchy ?? null } as Record<string, unknown>;
|
|
437
231
|
}
|
|
438
232
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
return {
|
|
446
|
-
stopReason: "end_turn",
|
|
447
|
-
};
|
|
448
|
-
} catch (error) {
|
|
449
|
-
// Handle errors
|
|
450
|
-
const errorMessage =
|
|
451
|
-
error instanceof Error ? error.message : "Unknown error";
|
|
452
|
-
|
|
453
|
-
// Send error as session update
|
|
454
|
-
await this.connection.sessionUpdate({
|
|
455
|
-
sessionId: acpSessionId,
|
|
456
|
-
update: {
|
|
457
|
-
sessionUpdate: "agent_message_chunk",
|
|
458
|
-
content: { type: "text", text: `Error: ${errorMessage}` },
|
|
459
|
-
},
|
|
460
|
-
});
|
|
461
|
-
|
|
462
|
-
return {
|
|
463
|
-
stopReason: "end_turn",
|
|
464
|
-
};
|
|
465
|
-
} finally {
|
|
466
|
-
// Mark session as not processing (for health monitoring)
|
|
467
|
-
this.sessionMapper.setProcessing(acpSessionId, false);
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
/**
|
|
472
|
-
* Cancel ongoing operations for a session
|
|
473
|
-
*/
|
|
474
|
-
async cancel(params: CancelNotification): Promise<void> {
|
|
475
|
-
const acpSessionId = params.sessionId;
|
|
476
|
-
|
|
477
|
-
// Signal cancellation
|
|
478
|
-
const controller = this.cancellationControllers.get(acpSessionId);
|
|
479
|
-
if (controller) {
|
|
480
|
-
controller.abort();
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
// Get the mapped agent ID for this session
|
|
484
|
-
const agentId = this.sessionMapper.getAgentId(acpSessionId);
|
|
485
|
-
if (!agentId) {
|
|
486
|
-
// No agent mapped - just clean up the controller
|
|
487
|
-
this.cancellationControllers.delete(acpSessionId);
|
|
488
|
-
return;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
// Terminate the agent (which kills the subprocess)
|
|
492
|
-
try {
|
|
493
|
-
await this.agentManager.terminate(agentId, "cancelled");
|
|
494
|
-
} catch (error) {
|
|
495
|
-
// Agent may already be stopped - log but don't throw
|
|
496
|
-
console.warn(
|
|
497
|
-
`[MacroAgent] Error terminating agent ${agentId}:`,
|
|
498
|
-
error instanceof Error ? error.message : String(error),
|
|
499
|
-
);
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
// Clean up resources
|
|
503
|
-
this.cancellationControllers.delete(acpSessionId);
|
|
504
|
-
this.sessionMapper.removeMapping(acpSessionId);
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
// ─────────────────────────────────────────────────────────────────
|
|
508
|
-
// Extension Methods
|
|
509
|
-
// ─────────────────────────────────────────────────────────────────
|
|
510
|
-
|
|
511
|
-
/**
|
|
512
|
-
* Route extension method calls to handlers
|
|
513
|
-
*/
|
|
514
|
-
async extMethod(
|
|
515
|
-
method: string,
|
|
516
|
-
params: Record<string, unknown>,
|
|
517
|
-
): Promise<Record<string, unknown>> {
|
|
518
|
-
// Method may come with or without underscore prefix depending on caller
|
|
519
|
-
// SDK calls with full name (e.g., "_macro/spawnAgent"), direct calls may omit it
|
|
520
|
-
const fullMethod = (
|
|
521
|
-
method.startsWith("_") ? method : `_${method}`
|
|
522
|
-
) as ACPExtensionMethod;
|
|
523
|
-
|
|
524
|
-
switch (fullMethod) {
|
|
525
|
-
case "_macro/spawnAgent":
|
|
526
|
-
return this.handleSpawnAgent(
|
|
527
|
-
params as unknown as SpawnAgentRequest,
|
|
528
|
-
) as unknown as Record<string, unknown>;
|
|
529
|
-
|
|
530
|
-
case "_macro/getHierarchy":
|
|
531
|
-
return this.handleGetHierarchy(
|
|
532
|
-
params as unknown as GetHierarchyRequest,
|
|
533
|
-
) as unknown as Record<string, unknown>;
|
|
534
|
-
|
|
535
|
-
case "_macro/getTask":
|
|
536
|
-
return this.handleGetTask(
|
|
537
|
-
params as unknown as GetTaskRequest,
|
|
538
|
-
) as unknown as Record<string, unknown>;
|
|
539
|
-
|
|
540
|
-
case "_macro/mountAgent":
|
|
541
|
-
return this.handleMountAgent(
|
|
542
|
-
params as unknown as MountAgentRequest,
|
|
543
|
-
) as unknown as Record<string, unknown>;
|
|
544
|
-
|
|
545
|
-
case "_macro/forkAgent":
|
|
546
|
-
return this.handleForkAgent(
|
|
547
|
-
params as unknown as ForkAgentRequest,
|
|
548
|
-
) as unknown as Record<string, unknown>;
|
|
549
|
-
|
|
550
|
-
case "_macro/sendPeerMessage":
|
|
551
|
-
return this.handleSendPeerMessage(
|
|
552
|
-
params as unknown as SendPeerMessageACPRequest,
|
|
553
|
-
) as unknown as Record<string, unknown>;
|
|
554
|
-
|
|
555
|
-
case "_macro/sendPeerRequest":
|
|
556
|
-
return this.handleSendPeerRequest(
|
|
557
|
-
params as unknown as SendPeerRequestACPRequest,
|
|
558
|
-
) as unknown as Record<string, unknown>;
|
|
559
|
-
|
|
560
|
-
case "_macro/deliverPeerMessage":
|
|
561
|
-
return this.handleDeliverPeerMessage(
|
|
562
|
-
params as unknown as DeliverPeerMessageRequest,
|
|
563
|
-
) as unknown as Record<string, unknown>;
|
|
564
|
-
|
|
565
|
-
case "_macro/deliverPeerRequest":
|
|
566
|
-
return this.handleDeliverPeerRequest(
|
|
567
|
-
params as unknown as DeliverPeerRequestRequest,
|
|
568
|
-
) as unknown as Record<string, unknown>;
|
|
569
|
-
|
|
570
|
-
case "_macro/grantCapability":
|
|
571
|
-
return this.handleGrantCapability(
|
|
572
|
-
params as unknown as GrantCapabilityRequest,
|
|
573
|
-
) as unknown as Record<string, unknown>;
|
|
574
|
-
|
|
575
|
-
case "_macro/revokeCapability":
|
|
576
|
-
return this.handleRevokeCapability(
|
|
577
|
-
params as unknown as RevokeCapabilityRequest,
|
|
578
|
-
) as unknown as Record<string, unknown>;
|
|
579
|
-
|
|
580
|
-
case "_macro/getCapabilities":
|
|
581
|
-
return this.handleGetCapabilities(
|
|
582
|
-
params as unknown as GetCapabilitiesRequest,
|
|
583
|
-
) as unknown as Record<string, unknown>;
|
|
584
|
-
|
|
585
|
-
case "_macro/checkCapability":
|
|
586
|
-
return this.handleCheckCapability(
|
|
587
|
-
params as unknown as CheckCapabilityRequest,
|
|
588
|
-
) as unknown as Record<string, unknown>;
|
|
589
|
-
|
|
590
|
-
case "_macro/respondToPermission":
|
|
591
|
-
return this.handleRespondToPermission(
|
|
592
|
-
params as unknown as RespondToPermissionRequest,
|
|
593
|
-
) as unknown as Record<string, unknown>;
|
|
594
|
-
|
|
595
|
-
case "_macro/cancelPermission":
|
|
596
|
-
return this.handleCancelPermission(
|
|
597
|
-
params as unknown as CancelPermissionRequest,
|
|
598
|
-
) as unknown as Record<string, unknown>;
|
|
599
|
-
|
|
600
|
-
case "_macro/setPermissionMode":
|
|
601
|
-
return this.handleSetPermissionMode(
|
|
602
|
-
params as unknown as SetPermissionModeRequest,
|
|
603
|
-
) as unknown as Record<string, unknown>;
|
|
604
|
-
|
|
605
|
-
case "_macro/resume":
|
|
606
|
-
return this.handleResumeAgent(
|
|
607
|
-
params as unknown as ResumeAgentRequest,
|
|
608
|
-
) as unknown as Record<string, unknown>;
|
|
609
|
-
|
|
610
|
-
case "_macro/getHistory":
|
|
611
|
-
return this.handleGetHistory(
|
|
612
|
-
params as unknown as GetHistoryRequest,
|
|
613
|
-
) as unknown as Record<string, unknown>;
|
|
614
|
-
|
|
615
|
-
case "_macro/getModels":
|
|
616
|
-
return this.handleGetModels(
|
|
617
|
-
params as { sessionId: string },
|
|
618
|
-
) as unknown as Record<string, unknown>;
|
|
619
|
-
|
|
620
|
-
default:
|
|
621
|
-
throw new ACPError(
|
|
622
|
-
`Unknown extension method: ${method}`,
|
|
623
|
-
"INVALID_EXTENSION",
|
|
624
|
-
);
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
// ─────────────────────────────────────────────────────────────────
|
|
629
|
-
// Extension Handlers
|
|
630
|
-
// ─────────────────────────────────────────────────────────────────
|
|
631
|
-
|
|
632
|
-
/**
|
|
633
|
-
* Spawn a new child agent
|
|
634
|
-
*/
|
|
635
|
-
private async handleSpawnAgent(
|
|
636
|
-
params: SpawnAgentRequest,
|
|
637
|
-
): Promise<SpawnAgentResponse> {
|
|
638
|
-
// Determine parent - use provided parentId or fall back to a session's mapped agent
|
|
639
|
-
let parentId = params.parentId;
|
|
640
|
-
|
|
641
|
-
// If no parentId provided, we need to find a suitable parent
|
|
642
|
-
// This would typically come from an ACP session context
|
|
643
|
-
if (!parentId) {
|
|
644
|
-
// Get the first head manager as default parent
|
|
645
|
-
const headManagers = this.agentManager.listHeadManagers();
|
|
646
|
-
if (headManagers.length > 0) {
|
|
647
|
-
parentId = headManagers[0].id;
|
|
233
|
+
case "_macro/getTask": {
|
|
234
|
+
const taskId = params.taskId as string;
|
|
235
|
+
if (!taskId) throw RequestError.invalidParams(params, "taskId is required");
|
|
236
|
+
const task = await tasksAdapter.getTask(taskId);
|
|
237
|
+
return { task } as Record<string, unknown>;
|
|
648
238
|
}
|
|
649
|
-
}
|
|
650
239
|
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
240
|
+
case "_macro/mountAgent": {
|
|
241
|
+
const sessionId = params.sessionId as string;
|
|
242
|
+
const agentId = params.agentId as string;
|
|
243
|
+
if (!sessionId || !agentId) {
|
|
244
|
+
throw RequestError.invalidParams(
|
|
245
|
+
params,
|
|
246
|
+
"sessionId and agentId are required",
|
|
247
|
+
);
|
|
248
|
+
}
|
|
657
249
|
|
|
658
|
-
//
|
|
659
|
-
const
|
|
660
|
-
if (!
|
|
250
|
+
// Verify the agent exists
|
|
251
|
+
const agent = agentManager.get(agentId);
|
|
252
|
+
if (!agent) {
|
|
661
253
|
throw new ACPError(
|
|
662
|
-
`
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
{
|
|
666
|
-
parentId,
|
|
667
|
-
parentRole,
|
|
668
|
-
childRole,
|
|
669
|
-
requiredCapability,
|
|
670
|
-
},
|
|
254
|
+
`Agent not found: ${agentId}`,
|
|
255
|
+
"AGENT_NOT_FOUND",
|
|
256
|
+
{ agentId },
|
|
671
257
|
);
|
|
672
258
|
}
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
259
|
|
|
676
|
-
|
|
677
|
-
const mergedConfig = this.mergeSubAgentConfig(
|
|
678
|
-
this.initConfig.defaultSubAgentConfig,
|
|
679
|
-
params.config,
|
|
680
|
-
);
|
|
681
|
-
|
|
682
|
-
// Spawn the agent with merged config
|
|
683
|
-
const spawned = await this.agentManager.spawn({
|
|
684
|
-
task: params.task_description,
|
|
685
|
-
parent: parentId ?? null,
|
|
686
|
-
role: params.role,
|
|
687
|
-
cwd: params.options?.cwd ?? this.defaultCwd,
|
|
688
|
-
subscribeParent: params.options?.subscribeParent ?? true,
|
|
689
|
-
topics: params.options?.topics,
|
|
690
|
-
permissionMode: mergedConfig?.permissionMode,
|
|
691
|
-
agentType: mergedConfig?.agentType,
|
|
692
|
-
config: this.toAgentConfig(mergedConfig),
|
|
693
|
-
});
|
|
694
|
-
|
|
695
|
-
return {
|
|
696
|
-
agentId: spawned.id,
|
|
697
|
-
taskId: spawned.agent.task_id!,
|
|
698
|
-
sessionId: spawned.session_id,
|
|
699
|
-
};
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
/**
|
|
703
|
-
* Map a child role name to the required spawn capability.
|
|
704
|
-
* Handles subroles like "worker.resolver" by checking base role.
|
|
705
|
-
*/
|
|
706
|
-
private getSpawnCapability(childRole: string): Capability {
|
|
707
|
-
// Extract base role (e.g., "worker.resolver" -> "worker")
|
|
708
|
-
const baseRole = childRole.split(".")[0];
|
|
709
|
-
|
|
710
|
-
switch (baseRole) {
|
|
711
|
-
case "worker":
|
|
712
|
-
return AGENT_CAPABILITIES.SPAWN_WORKER;
|
|
713
|
-
case "integrator":
|
|
714
|
-
return AGENT_CAPABILITIES.SPAWN_INTEGRATOR;
|
|
715
|
-
case "monitor":
|
|
716
|
-
return AGENT_CAPABILITIES.SPAWN_MONITOR;
|
|
717
|
-
case "coordinator":
|
|
718
|
-
// Coordinators require special handling - typically only other coordinators
|
|
719
|
-
// or system-level agents can spawn coordinators
|
|
720
|
-
return AGENT_CAPABILITIES.SPAWN_CUSTOM;
|
|
721
|
-
default:
|
|
722
|
-
// For custom roles, check against the custom spawn capability
|
|
723
|
-
return AGENT_CAPABILITIES.SPAWN_CUSTOM;
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
/**
|
|
728
|
-
* Get the agent hierarchy tree
|
|
729
|
-
*/
|
|
730
|
-
private async handleGetHierarchy(
|
|
731
|
-
params: GetHierarchyRequest,
|
|
732
|
-
): Promise<GetHierarchyResponse> {
|
|
733
|
-
let rootAgentId = params.rootAgentId;
|
|
734
|
-
|
|
735
|
-
// If no root specified, use the first head manager
|
|
736
|
-
if (!rootAgentId) {
|
|
737
|
-
const headManagers = this.agentManager.listHeadManagers();
|
|
738
|
-
if (headManagers.length === 0) {
|
|
739
|
-
// Return empty hierarchy if no agents
|
|
260
|
+
const previousAgentId = sessionMapper.mount(sessionId, agentId);
|
|
740
261
|
return {
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
},
|
|
745
|
-
totalAgents: 0,
|
|
746
|
-
depth: 0,
|
|
262
|
+
mounted: true,
|
|
263
|
+
agentId,
|
|
264
|
+
previousAgentId: previousAgentId ?? null,
|
|
747
265
|
};
|
|
748
266
|
}
|
|
749
|
-
rootAgentId = headManagers[0].id;
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
// Get hierarchy from agent manager
|
|
753
|
-
const hierarchy = this.agentManager.getHierarchy(rootAgentId);
|
|
754
|
-
|
|
755
|
-
if (!hierarchy) {
|
|
756
|
-
throw new ACPError(`Agent not found: ${rootAgentId}`, "AGENT_NOT_FOUND", {
|
|
757
|
-
agentId: rootAgentId,
|
|
758
|
-
});
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
return {
|
|
762
|
-
hierarchy: hierarchy.root,
|
|
763
|
-
totalAgents: hierarchy.totalAgents,
|
|
764
|
-
depth: hierarchy.depth,
|
|
765
|
-
};
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
/**
|
|
769
|
-
* Get task details by ID
|
|
770
|
-
*/
|
|
771
|
-
private async handleGetTask(
|
|
772
|
-
params: GetTaskRequest,
|
|
773
|
-
): Promise<GetTaskResponse> {
|
|
774
|
-
const task = this.taskManager.get(params.taskId);
|
|
775
|
-
|
|
776
|
-
if (!task) {
|
|
777
|
-
throw new ACPError(`Task not found: ${params.taskId}`, "TASK_NOT_FOUND", {
|
|
778
|
-
taskId: params.taskId,
|
|
779
|
-
});
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
return {
|
|
783
|
-
task,
|
|
784
|
-
};
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
/**
|
|
788
|
-
* Mount (attach to) an existing agent
|
|
789
|
-
*
|
|
790
|
-
* Remaps an ACP session to point to a different agent.
|
|
791
|
-
* Subsequent prompts will go to the mounted agent.
|
|
792
|
-
*/
|
|
793
|
-
private async handleMountAgent(
|
|
794
|
-
params: MountAgentRequest,
|
|
795
|
-
): Promise<MountAgentResponse> {
|
|
796
|
-
const { sessionId, agentId } = params;
|
|
797
|
-
|
|
798
|
-
// Verify the target agent exists
|
|
799
|
-
const agent = this.agentManager.get(agentId);
|
|
800
|
-
if (!agent) {
|
|
801
|
-
throw new ACPError(`Agent not found: ${agentId}`, "AGENT_NOT_FOUND", {
|
|
802
|
-
agentId,
|
|
803
|
-
});
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
// Verify the session exists in our mapper
|
|
807
|
-
const mapping = this.sessionMapper.getMapping(sessionId);
|
|
808
|
-
if (!mapping) {
|
|
809
|
-
throw new ACPError(
|
|
810
|
-
`Session not found: ${sessionId}`,
|
|
811
|
-
"SESSION_NOT_FOUND",
|
|
812
|
-
{ sessionId },
|
|
813
|
-
);
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
// Get the previous agent before mounting
|
|
817
|
-
const previousAgentId = mapping.agentId;
|
|
818
|
-
|
|
819
|
-
// Remap the session to the target agent
|
|
820
|
-
this.sessionMapper.mount(sessionId, agentId);
|
|
821
|
-
|
|
822
|
-
return {
|
|
823
|
-
sessionId,
|
|
824
|
-
agent,
|
|
825
|
-
previousAgentId,
|
|
826
|
-
};
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
/**
|
|
830
|
-
* Fork an agent (create a branch with same conversation context)
|
|
831
|
-
*
|
|
832
|
-
* Creates a new agent that starts from the same point as the original.
|
|
833
|
-
* Uses native fork if available, otherwise falls back to loadSession.
|
|
834
|
-
*/
|
|
835
|
-
private async handleForkAgent(
|
|
836
|
-
params: ForkAgentRequest,
|
|
837
|
-
): Promise<ForkAgentResponse> {
|
|
838
|
-
const { agentId, name, prompt, cwd } = params;
|
|
839
|
-
|
|
840
|
-
// Validate source agent exists
|
|
841
|
-
const originalAgent = this.agentManager.get(agentId);
|
|
842
|
-
if (!originalAgent) {
|
|
843
|
-
throw new ACPError(`Agent not found: ${agentId}`, "AGENT_NOT_FOUND", {
|
|
844
|
-
agentId,
|
|
845
|
-
});
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
// Check forkable: needs active session or persisted provider_session_id
|
|
849
|
-
if (
|
|
850
|
-
!this.agentManager.hasActiveSession(agentId) &&
|
|
851
|
-
!originalAgent.provider_session_id
|
|
852
|
-
) {
|
|
853
|
-
throw new ACPError(
|
|
854
|
-
`Agent has no session to fork: ${agentId}`,
|
|
855
|
-
"FORK_NOT_SUPPORTED",
|
|
856
|
-
{ agentId },
|
|
857
|
-
);
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
// Fork via AgentManager (handles forkWithFlush + new process + loadSession)
|
|
861
|
-
const forked = await this.agentManager.forkAgent(agentId, {
|
|
862
|
-
name,
|
|
863
|
-
cwd: cwd ?? originalAgent.cwd ?? this.defaultCwd,
|
|
864
|
-
});
|
|
865
267
|
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
268
|
+
case "_macro/forkAgent": {
|
|
269
|
+
const sourceAgentId = params.sourceAgentId as string;
|
|
270
|
+
if (!sourceAgentId) {
|
|
271
|
+
throw RequestError.invalidParams(params, "sourceAgentId is required");
|
|
272
|
+
}
|
|
869
273
|
try {
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
prompt,
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
274
|
+
const forked = await agentManager.forkAgent(sourceAgentId, {
|
|
275
|
+
name: params.name as string | undefined,
|
|
276
|
+
prompt: params.prompt as string | undefined,
|
|
277
|
+
cwd: params.cwd as string | undefined,
|
|
278
|
+
});
|
|
279
|
+
return {
|
|
280
|
+
agentId: forked.id,
|
|
281
|
+
sessionId: forked.session_id,
|
|
282
|
+
};
|
|
876
283
|
} catch (err) {
|
|
877
|
-
|
|
878
|
-
`
|
|
879
|
-
|
|
284
|
+
throw new ACPError(
|
|
285
|
+
`Fork failed: ${(err as Error).message}`,
|
|
286
|
+
"FORK_FAILED",
|
|
287
|
+
{ sourceAgentId },
|
|
880
288
|
);
|
|
881
289
|
}
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
return {
|
|
886
|
-
newAgentId: forked.id,
|
|
887
|
-
newSessionId: forked.session_id,
|
|
888
|
-
originalAgentId: agentId,
|
|
889
|
-
providerSessionId: forked.session.id,
|
|
890
|
-
};
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
// ─────────────────────────────────────────────────────────────────
|
|
894
|
-
// Peer Communication Extension Handlers
|
|
895
|
-
// ─────────────────────────────────────────────────────────────────
|
|
896
|
-
|
|
897
|
-
/**
|
|
898
|
-
* Send a peer message (outbound, fire-and-forget)
|
|
899
|
-
*
|
|
900
|
-
* Called by external clients to have an agent send a message to a peer.
|
|
901
|
-
*/
|
|
902
|
-
private async handleSendPeerMessage(
|
|
903
|
-
params: SendPeerMessageACPRequest,
|
|
904
|
-
): Promise<SendPeerMessageACPResponse> {
|
|
905
|
-
if (!this.peerManager) {
|
|
906
|
-
throw new ACPError(
|
|
907
|
-
"PeerManager not configured for this macro-agent",
|
|
908
|
-
"NO_PEER_MANAGER",
|
|
909
|
-
);
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
// Determine which agent is sending (use head manager by default)
|
|
913
|
-
const headManagers = this.agentManager.listHeadManagers();
|
|
914
|
-
if (headManagers.length === 0) {
|
|
915
|
-
throw new ACPError(
|
|
916
|
-
"No agents available to send peer message",
|
|
917
|
-
"AGENT_NOT_FOUND",
|
|
918
|
-
);
|
|
919
|
-
}
|
|
920
|
-
const sendingAgentId = headManagers[0].id;
|
|
921
|
-
|
|
922
|
-
try {
|
|
923
|
-
await this.peerManager.sendMessage(sendingAgentId, params.to, {
|
|
924
|
-
type: params.type,
|
|
925
|
-
payload: params.payload,
|
|
926
|
-
metadata: params.correlationId
|
|
927
|
-
? { correlationId: params.correlationId }
|
|
928
|
-
: undefined,
|
|
929
|
-
});
|
|
930
|
-
|
|
931
|
-
return {
|
|
932
|
-
success: true,
|
|
933
|
-
timestamp: Date.now(),
|
|
934
|
-
};
|
|
935
|
-
} catch (error) {
|
|
936
|
-
throw new ACPError(
|
|
937
|
-
`Failed to send peer message: ${error instanceof Error ? error.message : String(error)}`,
|
|
938
|
-
"PEER_SEND_FAILED",
|
|
939
|
-
{ to: params.to, error },
|
|
940
|
-
);
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
/**
|
|
945
|
-
* Send a peer request (outbound, request-response)
|
|
946
|
-
*
|
|
947
|
-
* Called by external clients to have an agent send a request to a peer
|
|
948
|
-
* and wait for a response.
|
|
949
|
-
*/
|
|
950
|
-
private async handleSendPeerRequest(
|
|
951
|
-
params: SendPeerRequestACPRequest,
|
|
952
|
-
): Promise<SendPeerRequestACPResponse> {
|
|
953
|
-
if (!this.peerManager) {
|
|
954
|
-
throw new ACPError(
|
|
955
|
-
"PeerManager not configured for this macro-agent",
|
|
956
|
-
"NO_PEER_MANAGER",
|
|
957
|
-
);
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
// Determine which agent is sending (use head manager by default)
|
|
961
|
-
const headManagers = this.agentManager.listHeadManagers();
|
|
962
|
-
if (headManagers.length === 0) {
|
|
963
|
-
throw new ACPError(
|
|
964
|
-
"No agents available to send peer request",
|
|
965
|
-
"AGENT_NOT_FOUND",
|
|
966
|
-
);
|
|
967
|
-
}
|
|
968
|
-
const sendingAgentId = headManagers[0].id;
|
|
969
|
-
|
|
970
|
-
try {
|
|
971
|
-
const response = await this.peerManager.sendRequest(
|
|
972
|
-
sendingAgentId,
|
|
973
|
-
params.to,
|
|
974
|
-
{
|
|
975
|
-
method: params.method,
|
|
976
|
-
params: params.params,
|
|
977
|
-
timeout: params.timeout,
|
|
978
|
-
},
|
|
979
|
-
);
|
|
980
|
-
|
|
981
|
-
return response;
|
|
982
|
-
} catch (error) {
|
|
983
|
-
throw new ACPError(
|
|
984
|
-
`Failed to send peer request: ${error instanceof Error ? error.message : String(error)}`,
|
|
985
|
-
"PEER_SEND_FAILED",
|
|
986
|
-
{ to: params.to, error },
|
|
987
|
-
);
|
|
988
|
-
}
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
/**
|
|
992
|
-
* Deliver a peer message (inbound, fire-and-forget)
|
|
993
|
-
*
|
|
994
|
-
* Called by external clients to route an inbound message from a peer
|
|
995
|
-
* to this macro-agent. The message is queued for the target agent.
|
|
996
|
-
*/
|
|
997
|
-
private async handleDeliverPeerMessage(
|
|
998
|
-
params: DeliverPeerMessageRequest,
|
|
999
|
-
): Promise<DeliverPeerMessageResponse> {
|
|
1000
|
-
if (!this.peerManager) {
|
|
1001
|
-
throw new ACPError(
|
|
1002
|
-
"PeerManager not configured for this macro-agent",
|
|
1003
|
-
"NO_PEER_MANAGER",
|
|
1004
|
-
);
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
// Use PeerManager's deliverMessage to queue the message
|
|
1008
|
-
const messageId = this.peerManager.deliverMessage(
|
|
1009
|
-
params.from,
|
|
1010
|
-
{
|
|
1011
|
-
type: params.type,
|
|
1012
|
-
payload: params.payload,
|
|
1013
|
-
metadata: params.correlationId
|
|
1014
|
-
? { correlationId: params.correlationId }
|
|
1015
|
-
: undefined,
|
|
1016
|
-
},
|
|
1017
|
-
params.targetAgentId,
|
|
1018
|
-
);
|
|
1019
|
-
|
|
1020
|
-
return {
|
|
1021
|
-
success: true,
|
|
1022
|
-
messageId,
|
|
1023
|
-
};
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
/**
|
|
1027
|
-
* Deliver a peer request (inbound, request-response)
|
|
1028
|
-
*
|
|
1029
|
-
* Called by external clients to route an inbound request from a peer
|
|
1030
|
-
* to this macro-agent. The request is queued and this waits for the
|
|
1031
|
-
* internal agent to respond.
|
|
1032
|
-
*/
|
|
1033
|
-
private async handleDeliverPeerRequest(
|
|
1034
|
-
params: DeliverPeerRequestRequest,
|
|
1035
|
-
): Promise<DeliverPeerRequestResponse> {
|
|
1036
|
-
if (!this.peerManager) {
|
|
1037
|
-
throw new ACPError(
|
|
1038
|
-
"PeerManager not configured for this macro-agent",
|
|
1039
|
-
"NO_PEER_MANAGER",
|
|
1040
|
-
);
|
|
1041
|
-
}
|
|
290
|
+
}
|
|
1042
291
|
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
);
|
|
1054
|
-
|
|
1055
|
-
return response;
|
|
1056
|
-
}
|
|
292
|
+
case "_macro/resume": {
|
|
293
|
+
const agentId = params.agentId as string;
|
|
294
|
+
if (!agentId) throw RequestError.invalidParams(params, "agentId is required");
|
|
295
|
+
const resumed = await agentManager.resume(agentId);
|
|
296
|
+
return {
|
|
297
|
+
agentId: resumed.id,
|
|
298
|
+
sessionId: resumed.session_id,
|
|
299
|
+
state: resumed.agent.state,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
1057
302
|
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
/**
|
|
1063
|
-
* Grant capabilities to a peer
|
|
1064
|
-
*/
|
|
1065
|
-
private async handleGrantCapability(
|
|
1066
|
-
params: GrantCapabilityRequest,
|
|
1067
|
-
): Promise<GrantCapabilityResponse> {
|
|
1068
|
-
if (!this.capabilityManager) {
|
|
1069
|
-
throw new ACPError(
|
|
1070
|
-
"CapabilityManager not configured for this macro-agent",
|
|
1071
|
-
"NO_PEER_MANAGER",
|
|
1072
|
-
);
|
|
1073
|
-
}
|
|
303
|
+
case "_macro/getHistory": {
|
|
304
|
+
const agentId = params.agentId as string;
|
|
305
|
+
if (!agentId) throw RequestError.invalidParams(params, "agentId is required");
|
|
1074
306
|
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
);
|
|
307
|
+
if (params.threadTag) {
|
|
308
|
+
const thread = await inboxAdapter.readThread(
|
|
309
|
+
params.threadTag as string,
|
|
310
|
+
params.scope as string | undefined,
|
|
311
|
+
);
|
|
312
|
+
return { messages: thread };
|
|
313
|
+
}
|
|
1083
314
|
|
|
1084
|
-
|
|
1085
|
-
|
|
315
|
+
const messages = await inboxAdapter.checkInbox(agentId, {
|
|
316
|
+
limit: params.limit as number | undefined,
|
|
317
|
+
});
|
|
318
|
+
return { messages };
|
|
319
|
+
}
|
|
1086
320
|
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
params: RevokeCapabilityRequest,
|
|
1092
|
-
): Promise<RevokeCapabilityResponse> {
|
|
1093
|
-
if (!this.capabilityManager) {
|
|
1094
|
-
throw new ACPError(
|
|
1095
|
-
"CapabilityManager not configured for this macro-agent",
|
|
1096
|
-
"NO_PEER_MANAGER",
|
|
1097
|
-
);
|
|
1098
|
-
}
|
|
321
|
+
case "_macro/getModels": {
|
|
322
|
+
// Models are not centrally tracked; return empty
|
|
323
|
+
return { models: [] };
|
|
324
|
+
}
|
|
1099
325
|
|
|
1100
|
-
|
|
326
|
+
case "_macro/respondToPermission": {
|
|
327
|
+
const agentId = params.agentId as string;
|
|
328
|
+
const requestId = params.requestId as string;
|
|
329
|
+
const optionId = params.optionId as string;
|
|
330
|
+
if (!agentId || !requestId || !optionId) {
|
|
331
|
+
throw RequestError.invalidParams(
|
|
332
|
+
params,
|
|
333
|
+
"agentId, requestId, and optionId are required",
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
const success = agentManager.respondToPermission(
|
|
337
|
+
agentId,
|
|
338
|
+
requestId,
|
|
339
|
+
optionId,
|
|
340
|
+
);
|
|
341
|
+
return { success };
|
|
342
|
+
}
|
|
1101
343
|
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
344
|
+
case "_macro/cancelPermission": {
|
|
345
|
+
const agentId = params.agentId as string;
|
|
346
|
+
const requestId = params.requestId as string;
|
|
347
|
+
if (!agentId || !requestId) {
|
|
348
|
+
throw RequestError.invalidParams(
|
|
349
|
+
params,
|
|
350
|
+
"agentId and requestId are required",
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
const success = agentManager.cancelPermission(agentId, requestId);
|
|
354
|
+
return { success };
|
|
355
|
+
}
|
|
1109
356
|
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
357
|
+
case "_macro/setPermissionMode": {
|
|
358
|
+
const agentId = params.agentId as string;
|
|
359
|
+
const mode = params.mode as string;
|
|
360
|
+
if (!agentId || !mode) {
|
|
361
|
+
throw RequestError.invalidParams(
|
|
362
|
+
params,
|
|
363
|
+
"agentId and mode are required",
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
const success = agentManager.setPermissionMode(
|
|
367
|
+
agentId,
|
|
368
|
+
mode as "auto-approve",
|
|
369
|
+
);
|
|
370
|
+
return { success };
|
|
371
|
+
}
|
|
1122
372
|
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
373
|
+
default:
|
|
374
|
+
throw new ACPError(
|
|
375
|
+
`Unknown extension: ${method}`,
|
|
376
|
+
"INVALID_EXTENSION",
|
|
377
|
+
{ method },
|
|
378
|
+
);
|
|
1127
379
|
}
|
|
1128
|
-
|
|
1129
|
-
return {
|
|
1130
|
-
authorizedPeers: this.capabilityManager.listAuthorizedPeers(),
|
|
1131
|
-
};
|
|
1132
380
|
}
|
|
1133
381
|
|
|
1134
|
-
|
|
1135
|
-
* Check if a peer has a required capability
|
|
1136
|
-
*/
|
|
1137
|
-
private async handleCheckCapability(
|
|
1138
|
-
params: CheckCapabilityRequest,
|
|
1139
|
-
): Promise<CheckCapabilityResponse> {
|
|
1140
|
-
if (!this.capabilityManager) {
|
|
1141
|
-
throw new ACPError(
|
|
1142
|
-
"CapabilityManager not configured for this macro-agent",
|
|
1143
|
-
"NO_PEER_MANAGER",
|
|
1144
|
-
);
|
|
1145
|
-
}
|
|
1146
|
-
|
|
1147
|
-
return {
|
|
1148
|
-
hasCapability: this.capabilityManager.hasCapability(
|
|
1149
|
-
params.peerId,
|
|
1150
|
-
params.required,
|
|
1151
|
-
),
|
|
1152
|
-
};
|
|
1153
|
-
}
|
|
382
|
+
// ── ACP Agent Implementation ────────────────────────────────
|
|
1154
383
|
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
/**
|
|
1160
|
-
* Respond to a permission request for a session
|
|
1161
|
-
*
|
|
1162
|
-
* Routes the response through the session mapper to find the agent,
|
|
1163
|
-
* then calls the agent manager to resolve the pending permission.
|
|
1164
|
-
*/
|
|
1165
|
-
private async handleRespondToPermission(
|
|
1166
|
-
params: RespondToPermissionRequest,
|
|
1167
|
-
): Promise<RespondToPermissionResponse> {
|
|
1168
|
-
const { sessionId, requestId, optionId } = params;
|
|
1169
|
-
|
|
1170
|
-
// Get the agent ID from session mapper
|
|
1171
|
-
const agentId = this.sessionMapper.getAgentId(sessionId);
|
|
1172
|
-
if (!agentId) {
|
|
384
|
+
const agent: ACPAgent = {
|
|
385
|
+
async initialize(
|
|
386
|
+
_params: InitializeRequest,
|
|
387
|
+
): Promise<InitializeResponse> {
|
|
1173
388
|
return {
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
389
|
+
protocolVersion: 1,
|
|
390
|
+
agentInfo: {
|
|
391
|
+
name: "macro-agent",
|
|
392
|
+
version: "2.0.0",
|
|
393
|
+
},
|
|
394
|
+
agentCapabilities: {
|
|
395
|
+
loadSession: true,
|
|
396
|
+
sessionCapabilities: {
|
|
397
|
+
resume: {},
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
extensions: [
|
|
401
|
+
...SUPPORTED_EXTENSIONS.map((name) => ({
|
|
402
|
+
name,
|
|
403
|
+
description: `macro-agent extension: ${name}`,
|
|
404
|
+
})),
|
|
405
|
+
...STUBBED_PEER_EXTENSIONS.map((name) => ({
|
|
406
|
+
name,
|
|
407
|
+
description: `Peer extension (stub): ${name}`,
|
|
408
|
+
})),
|
|
409
|
+
],
|
|
410
|
+
} as InitializeResponse;
|
|
411
|
+
},
|
|
412
|
+
|
|
413
|
+
async newSession(
|
|
414
|
+
params: NewSessionRequest,
|
|
415
|
+
): Promise<NewSessionResponse> {
|
|
416
|
+
const cwd = params.cwd ?? defaultCwd;
|
|
417
|
+
|
|
418
|
+
// Get or create a head manager for this workspace
|
|
419
|
+
const headManager = await agentManager.getOrCreateHeadManager({
|
|
420
|
+
cwd,
|
|
421
|
+
});
|
|
1185
422
|
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
423
|
+
// Create session mapping
|
|
424
|
+
const mapping = sessionMapper.createMapping(
|
|
425
|
+
headManager.session_id,
|
|
426
|
+
headManager.id,
|
|
1189
427
|
);
|
|
1190
|
-
return { success: true };
|
|
1191
|
-
} else {
|
|
1192
|
-
return {
|
|
1193
|
-
success: false,
|
|
1194
|
-
error: `Failed to respond to permission ${requestId} for agent ${agentId}`,
|
|
1195
|
-
};
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
|
|
1199
|
-
/**
|
|
1200
|
-
* Cancel a permission request for a session
|
|
1201
|
-
*
|
|
1202
|
-
* Routes the cancellation through the session mapper to find the agent,
|
|
1203
|
-
* then calls the agent manager to cancel the pending permission.
|
|
1204
|
-
*/
|
|
1205
|
-
private async handleCancelPermission(
|
|
1206
|
-
params: CancelPermissionRequest,
|
|
1207
|
-
): Promise<CancelPermissionResponse> {
|
|
1208
|
-
const { sessionId, requestId } = params;
|
|
1209
|
-
|
|
1210
|
-
// Get the agent ID from session mapper
|
|
1211
|
-
const agentId = this.sessionMapper.getAgentId(sessionId);
|
|
1212
|
-
if (!agentId) {
|
|
1213
|
-
return {
|
|
1214
|
-
success: false,
|
|
1215
|
-
error: `No agent found for session: ${sessionId}`,
|
|
1216
|
-
};
|
|
1217
|
-
}
|
|
1218
428
|
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
success: false,
|
|
1230
|
-
error: `Failed to cancel permission ${requestId} for agent ${agentId}`,
|
|
1231
|
-
};
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
429
|
+
// Annotate sessionlog with swarm metadata (best effort)
|
|
430
|
+
try {
|
|
431
|
+
const { annotateSession } = await import("../integrations/sessionlog.js");
|
|
432
|
+
annotateSession(cwd, {
|
|
433
|
+
swarmId: headManager.id,
|
|
434
|
+
scope: "macro-agent",
|
|
435
|
+
});
|
|
436
|
+
} catch {
|
|
437
|
+
// sessionlog not available — non-fatal
|
|
438
|
+
}
|
|
1234
439
|
|
|
1235
|
-
/**
|
|
1236
|
-
* Change the permission mode for a running agent at runtime
|
|
1237
|
-
*/
|
|
1238
|
-
private async handleSetPermissionMode(
|
|
1239
|
-
params: SetPermissionModeRequest,
|
|
1240
|
-
): Promise<SetPermissionModeResponse> {
|
|
1241
|
-
const { agentId, permissionMode } = params;
|
|
1242
|
-
|
|
1243
|
-
// Get the current mode before changing
|
|
1244
|
-
const previousMode = this.agentManager.getPermissionMode(
|
|
1245
|
-
agentId as AgentId,
|
|
1246
|
-
);
|
|
1247
|
-
|
|
1248
|
-
// Set the new mode via agent manager
|
|
1249
|
-
const success = this.agentManager.setPermissionMode(
|
|
1250
|
-
agentId as AgentId,
|
|
1251
|
-
permissionMode,
|
|
1252
|
-
);
|
|
1253
|
-
|
|
1254
|
-
if (success) {
|
|
1255
|
-
console.log(
|
|
1256
|
-
`[MacroAgent] Set permission mode for agent ${agentId} from ${previousMode} to ${permissionMode}`,
|
|
1257
|
-
);
|
|
1258
|
-
return {
|
|
1259
|
-
success: true,
|
|
1260
|
-
previousMode: previousMode ?? undefined,
|
|
1261
|
-
};
|
|
1262
|
-
} else {
|
|
1263
440
|
return {
|
|
1264
|
-
|
|
1265
|
-
error: `No active session found for agent ${agentId}`,
|
|
441
|
+
sessionId: mapping.acpSessionId,
|
|
1266
442
|
};
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
443
|
+
},
|
|
1269
444
|
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
params: ResumeAgentRequest,
|
|
1275
|
-
): Promise<ResumeAgentResponse> {
|
|
1276
|
-
const { agentId } = params;
|
|
445
|
+
async loadSession(
|
|
446
|
+
params: LoadSessionRequest,
|
|
447
|
+
): Promise<LoadSessionResponse> {
|
|
448
|
+
const sessionId = params.sessionId;
|
|
1277
449
|
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
const agent = this.eventStore.getAgent(agentId);
|
|
1284
|
-
if (!agent) {
|
|
1285
|
-
throw new ACPError(`Agent not found: ${agentId}`, "AGENT_NOT_FOUND");
|
|
1286
|
-
}
|
|
1287
|
-
|
|
1288
|
-
// Only resume stopped/failed agents
|
|
1289
|
-
if (agent.state !== "stopped" && agent.state !== "failed") {
|
|
1290
|
-
throw new ACPError(
|
|
1291
|
-
`Agent ${agentId} is ${agent.state} — only stopped or failed agents can be resumed`,
|
|
1292
|
-
"INVALID_EXTENSION",
|
|
1293
|
-
);
|
|
1294
|
-
}
|
|
1295
|
-
|
|
1296
|
-
console.log(`[MacroAgent] Resuming agent ${agentId}`);
|
|
1297
|
-
const spawned = await this.agentManager.resume(agentId);
|
|
1298
|
-
|
|
1299
|
-
return {
|
|
1300
|
-
success: true,
|
|
1301
|
-
agentId: spawned.id,
|
|
1302
|
-
sessionId: spawned.session_id,
|
|
1303
|
-
};
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1306
|
-
// ─────────────────────────────────────────────────────────────────
|
|
1307
|
-
// Helper Methods
|
|
1308
|
-
// ─────────────────────────────────────────────────────────────────
|
|
1309
|
-
|
|
1310
|
-
/**
|
|
1311
|
-
* Extract text content from prompt content blocks
|
|
1312
|
-
*/
|
|
1313
|
-
private extractMessageContent(prompt: PromptRequest["prompt"]): string {
|
|
1314
|
-
// Handle content blocks array
|
|
1315
|
-
if (Array.isArray(prompt)) {
|
|
1316
|
-
return prompt
|
|
1317
|
-
.map((block) => {
|
|
1318
|
-
if ("text" in block) {
|
|
1319
|
-
return block.text;
|
|
1320
|
-
}
|
|
1321
|
-
return "";
|
|
1322
|
-
})
|
|
1323
|
-
.filter(Boolean)
|
|
1324
|
-
.join("\n");
|
|
1325
|
-
}
|
|
450
|
+
// Check if we already have a mapping for this session
|
|
451
|
+
let mapping = sessionMapper.getMapping(sessionId);
|
|
452
|
+
if (mapping) {
|
|
453
|
+
return {};
|
|
454
|
+
}
|
|
1326
455
|
|
|
1327
|
-
|
|
1328
|
-
|
|
456
|
+
// Try to resume the agent associated with this session
|
|
457
|
+
// The session ID might be an agent ID in our system
|
|
458
|
+
const agent = agentManager.get(sessionId);
|
|
459
|
+
if (agent) {
|
|
460
|
+
const resumed = await agentManager.resume(sessionId);
|
|
461
|
+
mapping = sessionMapper.createMapping(
|
|
462
|
+
resumed.session_id,
|
|
463
|
+
resumed.id,
|
|
464
|
+
);
|
|
465
|
+
return {};
|
|
466
|
+
}
|
|
1329
467
|
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
* acp-factory already sends updates in ACP SDK format, so we forward
|
|
1334
|
-
* all updates directly. This handles all update types including:
|
|
1335
|
-
* - agent_message_chunk: Text content from agent
|
|
1336
|
-
* - agent_thought_chunk: Agent thinking/reasoning (if enabled)
|
|
1337
|
-
* - user_message_chunk: Echo of user messages
|
|
1338
|
-
* - tool_call: Tool invocation start
|
|
1339
|
-
* - tool_call_update: Tool execution progress/completion
|
|
1340
|
-
* - plan: Plan updates
|
|
1341
|
-
* - available_commands_update: Available slash commands
|
|
1342
|
-
* - current_mode_update: Mode changes (code/plan/etc)
|
|
1343
|
-
* - config_option_update: Configuration changes
|
|
1344
|
-
* - session_info_update: Session title and timestamps
|
|
1345
|
-
*
|
|
1346
|
-
* Permission requests are handled separately via the requestPermission RPC.
|
|
1347
|
-
*/
|
|
1348
|
-
private async forwardSessionUpdate(
|
|
1349
|
-
acpSessionId: ACPSessionId,
|
|
1350
|
-
update: unknown,
|
|
1351
|
-
): Promise<void> {
|
|
1352
|
-
const sessionUpdate = update as Record<string, unknown>;
|
|
1353
|
-
|
|
1354
|
-
// Check if this is a valid session update with the sessionUpdate discriminator
|
|
1355
|
-
if (!("sessionUpdate" in sessionUpdate)) {
|
|
1356
|
-
console.warn(
|
|
1357
|
-
`[MacroAgent] Received update without sessionUpdate field:`,
|
|
1358
|
-
JSON.stringify(update).substring(0, 200),
|
|
468
|
+
throw RequestError.invalidParams(
|
|
469
|
+
{ sessionId },
|
|
470
|
+
`Session not found: ${sessionId}`,
|
|
1359
471
|
);
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
);
|
|
472
|
+
},
|
|
473
|
+
|
|
474
|
+
async authenticate(
|
|
475
|
+
_params: AuthenticateRequest,
|
|
476
|
+
): Promise<AuthenticateResponse> {
|
|
477
|
+
// No-op: macro-agent does not require authentication
|
|
478
|
+
return {};
|
|
479
|
+
},
|
|
480
|
+
|
|
481
|
+
async prompt(params: PromptRequest): Promise<PromptResponse> {
|
|
482
|
+
const mapping = getSessionOrThrow(params.sessionId);
|
|
483
|
+
const agentId = mapping.agentId;
|
|
484
|
+
|
|
485
|
+
// Extract text content from prompt blocks
|
|
486
|
+
const textParts: string[] = [];
|
|
487
|
+
for (const block of params.prompt) {
|
|
488
|
+
if ("text" in block && typeof block.text === "string") {
|
|
489
|
+
textParts.push(block.text);
|
|
1378
490
|
}
|
|
1379
|
-
break;
|
|
1380
491
|
}
|
|
492
|
+
const message = textParts.join("\n") || "";
|
|
1381
493
|
|
|
1382
|
-
|
|
1383
|
-
const toolCallId = sessionUpdate.toolCallId as string;
|
|
1384
|
-
const title = sessionUpdate.title as string;
|
|
1385
|
-
const status = sessionUpdate.status as string;
|
|
1386
|
-
console.log(
|
|
1387
|
-
`[MacroAgent] Forwarding tool_call: id=${toolCallId}, title="${title}", status=${status}`,
|
|
1388
|
-
);
|
|
1389
|
-
break;
|
|
1390
|
-
}
|
|
494
|
+
sessionMapper.setProcessing(params.sessionId, true);
|
|
1391
495
|
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
console.log(
|
|
1396
|
-
`[MacroAgent] Forwarding tool_call_update: id=${toolCallId}, status=${status}`,
|
|
1397
|
-
);
|
|
1398
|
-
break;
|
|
496
|
+
// Capture first prompt for trajectory metadata (used as session description in OpenHive UI)
|
|
497
|
+
if (!firstPrompt) {
|
|
498
|
+
firstPrompt = message.slice(0, 200);
|
|
1399
499
|
}
|
|
1400
500
|
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
};
|
|
1415
|
-
options: Array<{
|
|
1416
|
-
kind: string;
|
|
1417
|
-
name: string;
|
|
1418
|
-
optionId: string;
|
|
1419
|
-
}>;
|
|
1420
|
-
};
|
|
1421
|
-
|
|
1422
|
-
// Look up agent ID using the ACP session ID (from the client connection),
|
|
1423
|
-
// NOT permReq.sessionId which is the agent's internal session ID.
|
|
1424
|
-
// The session mapper maps ACP session IDs → agent IDs, so using the
|
|
1425
|
-
// internal session ID would fail silently and drop the permission request.
|
|
1426
|
-
const agentId = this.sessionMapper.getAgentId(acpSessionId);
|
|
1427
|
-
if (!agentId) {
|
|
1428
|
-
console.warn(
|
|
1429
|
-
`[MacroAgent] No agent found for ACP session ${acpSessionId}, cannot forward permission request`,
|
|
501
|
+
// Track data for trajectory checkpoint
|
|
502
|
+
const filesTouched = new Set<string>();
|
|
503
|
+
let toolCallCount = 0;
|
|
504
|
+
const promptStartTime = Date.now();
|
|
505
|
+
let tokenUsage = { input_tokens: 0, output_tokens: 0, cache_read_tokens: 0, cache_creation_tokens: 0 };
|
|
506
|
+
|
|
507
|
+
// Update agent state to "busy" — both local MAP server and upstream sidecar
|
|
508
|
+
try {
|
|
509
|
+
const mapServer = (system as any).mapServerInstance;
|
|
510
|
+
if (mapServer) {
|
|
511
|
+
const agents = mapServer.agents?.list?.() ?? [];
|
|
512
|
+
const mapAgent = agents.find(
|
|
513
|
+
(a: any) => a.metadata?.localAgentId === agentId,
|
|
1430
514
|
);
|
|
1431
|
-
|
|
515
|
+
if (mapAgent) {
|
|
516
|
+
mapServer.agents.updateState(mapAgent.id, "busy");
|
|
517
|
+
}
|
|
1432
518
|
}
|
|
519
|
+
} catch { /* best effort */ }
|
|
520
|
+
|
|
521
|
+
// Update upstream sidecar state (so OpenHive sees activity)
|
|
522
|
+
try {
|
|
523
|
+
const sidecarConn = (system as any).mapSidecar;
|
|
524
|
+
if (sidecarConn?.connected) {
|
|
525
|
+
// The sidecar's underlying AgentConnection has updateState
|
|
526
|
+
// but it's not directly exposed. Emit via the eventBus instead.
|
|
527
|
+
}
|
|
528
|
+
} catch { /* best effort */ }
|
|
529
|
+
|
|
530
|
+
try {
|
|
531
|
+
// Stream updates from agentManager.prompt()
|
|
532
|
+
const updates = agentManager.prompt(agentId, message);
|
|
533
|
+
|
|
534
|
+
for await (const update of updates) {
|
|
535
|
+
// Track tool calls, files, and token usage for trajectory checkpoint.
|
|
536
|
+
// Also emit task bridge events for TaskCreate/TaskUpdate tool calls.
|
|
537
|
+
if ("sessionUpdate" in update) {
|
|
538
|
+
const su = update as any;
|
|
539
|
+
if (su.sessionUpdate === "tool_call") {
|
|
540
|
+
toolCallCount++;
|
|
541
|
+
const input = su.rawInput as Record<string, unknown> | undefined;
|
|
542
|
+
if (input?.file_path) filesTouched.add(input.file_path as string);
|
|
543
|
+
if (input?.filePath) filesTouched.add(input.filePath as string);
|
|
544
|
+
if (input?.path) filesTouched.add(input.path as string);
|
|
545
|
+
if (input?.command) filesTouched.add(`[bash] ${(input.command as string).slice(0, 50)}`);
|
|
546
|
+
}
|
|
1433
547
|
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
status: permReq.toolCall.status as
|
|
1443
|
-
| "pending"
|
|
1444
|
-
| "in_progress"
|
|
1445
|
-
| "completed"
|
|
1446
|
-
| "failed"
|
|
1447
|
-
| undefined,
|
|
1448
|
-
rawInput: permReq.toolCall.rawInput,
|
|
1449
|
-
},
|
|
1450
|
-
options: permReq.options as Array<{
|
|
1451
|
-
kind:
|
|
1452
|
-
| "allow_once"
|
|
1453
|
-
| "allow_always"
|
|
1454
|
-
| "reject_once"
|
|
1455
|
-
| "reject_always";
|
|
1456
|
-
name: string;
|
|
1457
|
-
optionId: string;
|
|
1458
|
-
}>,
|
|
1459
|
-
});
|
|
548
|
+
// Track token usage from session info updates
|
|
549
|
+
if (su.sessionUpdate === "session_info_update" && su.usage) {
|
|
550
|
+
const u = su.usage;
|
|
551
|
+
if (u.inputTokens) tokenUsage.input_tokens += u.inputTokens;
|
|
552
|
+
if (u.outputTokens) tokenUsage.output_tokens += u.outputTokens;
|
|
553
|
+
if (u.cacheReadTokens) tokenUsage.cache_read_tokens += u.cacheReadTokens;
|
|
554
|
+
if (u.cacheCreationTokens) tokenUsage.cache_creation_tokens += u.cacheCreationTokens;
|
|
555
|
+
}
|
|
1460
556
|
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
557
|
+
// Bridge tool call completions to MAP events
|
|
558
|
+
if (su.sessionUpdate === "tool_call_update" && su.output !== undefined) {
|
|
559
|
+
const toolName = su.title ?? "";
|
|
560
|
+
const sidecar = (system as any).mapSidecar;
|
|
561
|
+
if (sidecar?.connected && toolName) {
|
|
562
|
+
try {
|
|
563
|
+
// Native task lifecycle events
|
|
564
|
+
if (toolName === "TaskCreate" || toolName.includes("TaskCreate")) {
|
|
565
|
+
const taskData = typeof su.output === "string"
|
|
566
|
+
? JSON.parse(su.output) : su.output;
|
|
567
|
+
sidecar.reportCheckpoint?.({
|
|
568
|
+
id: `task-created-${Date.now()}`,
|
|
569
|
+
session_id: params.sessionId,
|
|
570
|
+
agent: agentId,
|
|
571
|
+
branch: null,
|
|
572
|
+
files_touched: [],
|
|
573
|
+
checkpoints_count: checkpointCounter,
|
|
574
|
+
metadata: { phase: "active", event: "task.created", task: taskData },
|
|
575
|
+
}).catch(() => {});
|
|
576
|
+
} else if (toolName === "TaskUpdate" || toolName.includes("TaskUpdate")) {
|
|
577
|
+
const taskData = typeof su.output === "string"
|
|
578
|
+
? JSON.parse(su.output) : su.output;
|
|
579
|
+
sidecar.reportCheckpoint?.({
|
|
580
|
+
id: `task-updated-${Date.now()}`,
|
|
581
|
+
session_id: params.sessionId,
|
|
582
|
+
agent: agentId,
|
|
583
|
+
branch: null,
|
|
584
|
+
files_touched: [],
|
|
585
|
+
checkpoints_count: checkpointCounter,
|
|
586
|
+
metadata: { phase: "active", event: "task.status", task: taskData },
|
|
587
|
+
}).catch(() => {});
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// Gap 3: Opentasks MCP bridge — bridge opentasks tool calls to MAP events
|
|
591
|
+
else if (toolName === "opentasks__create_task" || toolName.includes("create_task")) {
|
|
592
|
+
const taskData = typeof su.output === "string"
|
|
593
|
+
? JSON.parse(su.output) : su.output;
|
|
594
|
+
sidecar.reportCheckpoint?.({
|
|
595
|
+
id: `opentasks-created-${Date.now()}`,
|
|
596
|
+
session_id: params.sessionId,
|
|
597
|
+
agent: agentId,
|
|
598
|
+
branch: null,
|
|
599
|
+
files_touched: [],
|
|
600
|
+
checkpoints_count: checkpointCounter,
|
|
601
|
+
metadata: { phase: "active", event: "task.created", source: "opentasks", task: taskData },
|
|
602
|
+
}).catch(() => {});
|
|
603
|
+
} else if (toolName === "opentasks__update_task" || toolName.includes("update_task")) {
|
|
604
|
+
const taskData = typeof su.output === "string"
|
|
605
|
+
? JSON.parse(su.output) : su.output;
|
|
606
|
+
sidecar.reportCheckpoint?.({
|
|
607
|
+
id: `opentasks-status-${Date.now()}`,
|
|
608
|
+
session_id: params.sessionId,
|
|
609
|
+
agent: agentId,
|
|
610
|
+
branch: null,
|
|
611
|
+
files_touched: [],
|
|
612
|
+
checkpoints_count: checkpointCounter,
|
|
613
|
+
metadata: { phase: "active", event: "task.status", source: "opentasks", task: taskData },
|
|
614
|
+
}).catch(() => {});
|
|
615
|
+
} else if (toolName === "opentasks__link" || toolName.includes("opentasks") && toolName.includes("link")) {
|
|
616
|
+
const linkData = typeof su.output === "string"
|
|
617
|
+
? JSON.parse(su.output) : su.output;
|
|
618
|
+
sidecar.reportCheckpoint?.({
|
|
619
|
+
id: `opentasks-linked-${Date.now()}`,
|
|
620
|
+
session_id: params.sessionId,
|
|
621
|
+
agent: agentId,
|
|
622
|
+
branch: null,
|
|
623
|
+
files_touched: [],
|
|
624
|
+
checkpoints_count: checkpointCounter,
|
|
625
|
+
metadata: { phase: "active", event: "task.linked", source: "opentasks", link: linkData },
|
|
626
|
+
}).catch(() => {});
|
|
627
|
+
} else if (toolName === "opentasks__annotate" || toolName.includes("opentasks") && toolName.includes("annotate")) {
|
|
628
|
+
const annotateData = typeof su.output === "string"
|
|
629
|
+
? JSON.parse(su.output) : su.output;
|
|
630
|
+
sidecar.reportCheckpoint?.({
|
|
631
|
+
id: `opentasks-sync-${Date.now()}`,
|
|
632
|
+
session_id: params.sessionId,
|
|
633
|
+
agent: agentId,
|
|
634
|
+
branch: null,
|
|
635
|
+
files_touched: [],
|
|
636
|
+
checkpoints_count: checkpointCounter,
|
|
637
|
+
metadata: { phase: "active", event: "task.sync", source: "opentasks", annotation: annotateData },
|
|
638
|
+
}).catch(() => {});
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
// Gap 2: Memory sync — detect minimem write tools
|
|
642
|
+
else if (toolName.includes("memory_append") || toolName.includes("memory_upsert")) {
|
|
643
|
+
sidecar.reportCheckpoint?.({
|
|
644
|
+
id: `memory-sync-${Date.now()}`,
|
|
645
|
+
session_id: params.sessionId,
|
|
646
|
+
agent: agentId,
|
|
647
|
+
branch: null,
|
|
648
|
+
files_touched: [],
|
|
649
|
+
checkpoints_count: checkpointCounter,
|
|
650
|
+
metadata: { phase: "active", event: "memory.sync" },
|
|
651
|
+
}).catch(() => {});
|
|
652
|
+
}
|
|
653
|
+
} catch { /* ignore parse errors */ }
|
|
1476
654
|
}
|
|
1477
|
-
}
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
// Handle permission requests from the underlying agent.
|
|
659
|
+
// When the agent is in interactive mode, it yields
|
|
660
|
+
// PermissionRequestUpdate objects instead of auto-approving.
|
|
661
|
+
// We forward these to the client via AgentSideConnection's
|
|
662
|
+
// requestPermission() method (JSON-RPC agent→client request).
|
|
663
|
+
if (isPermissionRequestUpdate(update)) {
|
|
664
|
+
try {
|
|
665
|
+
const permResponse = await connection.requestPermission({
|
|
666
|
+
sessionId: params.sessionId,
|
|
667
|
+
toolCall: {
|
|
668
|
+
toolCallId: update.toolCall.toolCallId,
|
|
669
|
+
title: update.toolCall.title,
|
|
670
|
+
status: update.toolCall.status as any,
|
|
671
|
+
rawInput: update.toolCall.rawInput,
|
|
672
|
+
},
|
|
673
|
+
options: update.options,
|
|
674
|
+
});
|
|
675
|
+
// Relay the permission response back to the agent.
|
|
676
|
+
// ACP response: { outcome: { outcome: "selected", optionId } | { outcome: "cancelled" } }
|
|
677
|
+
const outcome = permResponse?.outcome;
|
|
678
|
+
if (outcome) {
|
|
679
|
+
if (outcome.outcome === "selected" && "optionId" in outcome) {
|
|
680
|
+
agentManager.respondToPermission(
|
|
681
|
+
agentId,
|
|
682
|
+
update.requestId,
|
|
683
|
+
outcome.optionId,
|
|
684
|
+
);
|
|
685
|
+
} else if (outcome.outcome === "cancelled") {
|
|
686
|
+
agentManager.cancelPermission(agentId, update.requestId);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
} catch {
|
|
690
|
+
// If the permission request fails (e.g., client disconnected),
|
|
691
|
+
// cancel it so the agent doesn't hang.
|
|
692
|
+
try {
|
|
693
|
+
agentManager.cancelPermission(agentId, update.requestId);
|
|
694
|
+
} catch {
|
|
695
|
+
// Best effort
|
|
1486
696
|
}
|
|
1487
697
|
}
|
|
698
|
+
continue;
|
|
1488
699
|
}
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
)
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
700
|
+
|
|
701
|
+
// Forward each update to the client as a session notification.
|
|
702
|
+
// Only forward ACP-compatible SessionUpdate types; skip
|
|
703
|
+
// acp-factory extended types like CompactionUpdate.
|
|
704
|
+
if ("sessionUpdate" in update && isACPSessionUpdate(update)) {
|
|
705
|
+
const notification: SessionNotification = {
|
|
706
|
+
sessionId: params.sessionId,
|
|
707
|
+
update,
|
|
708
|
+
};
|
|
709
|
+
await connection.sessionUpdate(notification);
|
|
1499
710
|
}
|
|
1500
711
|
}
|
|
1501
|
-
// Don't forward via sessionUpdate - we handled it via requestPermission
|
|
1502
|
-
return;
|
|
1503
|
-
}
|
|
1504
|
-
|
|
1505
|
-
default:
|
|
1506
|
-
// Log other update types at debug level
|
|
1507
|
-
console.log(`[MacroAgent] Forwarding ${updateType}`);
|
|
1508
|
-
}
|
|
1509
712
|
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
713
|
+
// Emit enriched trajectory checkpoint after prompt completes.
|
|
714
|
+
// Matches cc-swarm's wire format so OpenHive UI can display session data.
|
|
715
|
+
const sidecar = (system as any).mapSidecar;
|
|
716
|
+
if (sidecar) {
|
|
717
|
+
checkpointCounter++;
|
|
718
|
+
const agentRecord = (system as any).agentStore?.getAgent?.(agentId);
|
|
719
|
+
const agentCwd = agentRecord?.cwd ?? defaultCwd;
|
|
720
|
+
const git = getGitInfo(agentCwd);
|
|
721
|
+
|
|
722
|
+
// Determine sync level from sessionlog config (default: "full")
|
|
723
|
+
const syncLevel: string = (system as any)._sessionlogSyncLevel ?? "full";
|
|
724
|
+
|
|
725
|
+
// Build checkpoint with sync-level gating:
|
|
726
|
+
// - lifecycle: phase, turnId, startedAt, label
|
|
727
|
+
// - metrics: above + token_usage, files_touched, checkpoints_count, toolCallCount, duration_ms
|
|
728
|
+
// - full: everything
|
|
729
|
+
const isMetrics = syncLevel === "metrics" || syncLevel === "full";
|
|
730
|
+
const isFull = syncLevel === "full";
|
|
731
|
+
|
|
732
|
+
const checkpoint: TrajectoryCheckpointPayload = {
|
|
733
|
+
id: `${params.sessionId}-step${checkpointCounter}`,
|
|
734
|
+
session_id: params.sessionId,
|
|
735
|
+
agent: agentRecord?.name ?? agentId,
|
|
736
|
+
branch: git.branch,
|
|
737
|
+
files_touched: isMetrics ? Array.from(filesTouched) : [],
|
|
738
|
+
checkpoints_count: isMetrics ? checkpointCounter : 0,
|
|
739
|
+
// Token usage — only at metrics level or above
|
|
740
|
+
...(isMetrics && (tokenUsage.input_tokens > 0 || tokenUsage.output_tokens > 0)
|
|
741
|
+
? { token_usage: tokenUsage }
|
|
742
|
+
: {}),
|
|
743
|
+
metadata: {
|
|
744
|
+
// lifecycle fields (always included)
|
|
745
|
+
phase: "active",
|
|
746
|
+
startedAt: sessionStartedAt,
|
|
747
|
+
label: `Step ${checkpointCounter} (${toolCallCount} tool calls)`,
|
|
748
|
+
// metrics fields
|
|
749
|
+
...(isMetrics ? {
|
|
750
|
+
duration_ms: Date.now() - promptStartTime,
|
|
751
|
+
toolCallCount,
|
|
752
|
+
} : {}),
|
|
753
|
+
// full fields
|
|
754
|
+
...(isFull ? {
|
|
755
|
+
project: agentCwd.split("/").pop() ?? "",
|
|
756
|
+
projectPath: agentCwd,
|
|
757
|
+
firstPrompt: firstPrompt ?? undefined,
|
|
758
|
+
gitCommitHash: git.commitHash ?? undefined,
|
|
759
|
+
gitRemoteUrl: git.remoteUrl ?? undefined,
|
|
760
|
+
} : {}),
|
|
761
|
+
},
|
|
762
|
+
};
|
|
763
|
+
// Enrich with sessionlog state if available (adds turn IDs, better token usage)
|
|
764
|
+
let enrichedCheckpoint = checkpoint;
|
|
765
|
+
try {
|
|
766
|
+
const { findActiveSession, enrichCheckpoint } = await import("../integrations/sessionlog.js");
|
|
767
|
+
const sessionState = findActiveSession(agentCwd);
|
|
768
|
+
if (sessionState) {
|
|
769
|
+
enrichedCheckpoint = enrichCheckpoint(sessionState, checkpoint);
|
|
770
|
+
}
|
|
771
|
+
} catch {
|
|
772
|
+
// sessionlog not available — use base checkpoint
|
|
1523
773
|
}
|
|
1524
|
-
}
|
|
1525
|
-
} else if (
|
|
1526
|
-
updateType === "tool_call" ||
|
|
1527
|
-
updateType === "tool_call_update"
|
|
1528
|
-
) {
|
|
1529
|
-
const toolCallId = sessionUpdate.toolCallId as string | undefined;
|
|
1530
|
-
const status = sessionUpdate.status as string | undefined;
|
|
1531
|
-
const meta = sessionUpdate._meta as { claudeCode?: { toolName?: string } } | undefined;
|
|
1532
|
-
const toolInfoCache = this.toolInfoCaches.get(acpSessionId);
|
|
1533
|
-
|
|
1534
|
-
// Cache tool info from initial tool_call events
|
|
1535
|
-
if (updateType === "tool_call" && toolCallId && toolInfoCache) {
|
|
1536
|
-
toolInfoCache.set(toolCallId, {
|
|
1537
|
-
title: sessionUpdate.title as string | undefined,
|
|
1538
|
-
name: meta?.claudeCode?.toolName,
|
|
1539
|
-
input: sessionUpdate.rawInput,
|
|
1540
|
-
});
|
|
1541
|
-
}
|
|
1542
774
|
|
|
1543
|
-
|
|
1544
|
-
// Merge cached info for tool_call_update events that lack title/input
|
|
1545
|
-
const cached = toolCallId ? toolInfoCache?.get(toolCallId) : undefined;
|
|
1546
|
-
buffer.parts.push({
|
|
1547
|
-
type: "tool",
|
|
1548
|
-
toolCallId,
|
|
1549
|
-
title: sessionUpdate.title ?? cached?.title,
|
|
1550
|
-
name: meta?.claudeCode?.toolName ?? cached?.name,
|
|
1551
|
-
status: sessionUpdate.status,
|
|
1552
|
-
input: sessionUpdate.rawInput ?? cached?.input,
|
|
1553
|
-
output: extractToolOutput(sessionUpdate.rawOutput),
|
|
1554
|
-
});
|
|
775
|
+
sidecar.reportCheckpoint(enrichedCheckpoint).catch(() => {});
|
|
1555
776
|
}
|
|
1556
|
-
}
|
|
1557
|
-
}
|
|
1558
|
-
|
|
1559
|
-
// Forward updates via sessionUpdate (except permission_request which is handled above)
|
|
1560
|
-
try {
|
|
1561
|
-
await this.connection.sessionUpdate({
|
|
1562
|
-
sessionId: acpSessionId,
|
|
1563
|
-
update: sessionUpdate as Parameters<
|
|
1564
|
-
AgentSideConnection["sessionUpdate"]
|
|
1565
|
-
>[0]["update"],
|
|
1566
|
-
});
|
|
1567
|
-
} catch (err) {
|
|
1568
|
-
console.error(
|
|
1569
|
-
`[MacroAgent] Failed to forward ${updateType}:`,
|
|
1570
|
-
err instanceof Error ? err.message : err,
|
|
1571
|
-
);
|
|
1572
|
-
}
|
|
1573
|
-
}
|
|
1574
|
-
|
|
1575
|
-
/**
|
|
1576
|
-
* Emit a session_info_update with title and timestamps.
|
|
1577
|
-
* Uses agent task as title and session mapping timestamps.
|
|
1578
|
-
*/
|
|
1579
|
-
private async emitSessionInfo(acpSessionId: ACPSessionId): Promise<void> {
|
|
1580
|
-
const mapping = this.sessionMapper.getMapping(acpSessionId);
|
|
1581
|
-
const agentId = mapping?.agentId;
|
|
1582
|
-
const agent = agentId ? this.eventStore.getAgent(agentId) : null;
|
|
1583
|
-
|
|
1584
|
-
const title = agent?.task ?? null;
|
|
1585
|
-
const updatedAt = new Date(mapping?.updatedAt ?? Date.now()).toISOString();
|
|
1586
|
-
|
|
1587
|
-
try {
|
|
1588
|
-
await this.connection.sessionUpdate({
|
|
1589
|
-
sessionId: acpSessionId,
|
|
1590
|
-
update: {
|
|
1591
|
-
sessionUpdate: "session_info_update",
|
|
1592
|
-
title,
|
|
1593
|
-
updatedAt,
|
|
1594
|
-
} as Parameters<AgentSideConnection["sessionUpdate"]>[0]["update"],
|
|
1595
|
-
});
|
|
1596
|
-
} catch (err) {
|
|
1597
|
-
console.warn(
|
|
1598
|
-
`[MacroAgent] Failed to send session_info_update:`,
|
|
1599
|
-
err instanceof Error ? err.message : err,
|
|
1600
|
-
);
|
|
1601
|
-
}
|
|
1602
|
-
}
|
|
1603
|
-
|
|
1604
|
-
/**
|
|
1605
|
-
* Build system prompt with configured prefix/suffix
|
|
1606
|
-
*/
|
|
1607
|
-
private buildSystemPrompt(): string | undefined {
|
|
1608
|
-
const { systemPromptPrefix, systemPromptSuffix } = this.initConfig;
|
|
1609
|
-
|
|
1610
|
-
if (!systemPromptPrefix && !systemPromptSuffix) {
|
|
1611
|
-
return undefined;
|
|
1612
|
-
}
|
|
1613
|
-
|
|
1614
|
-
const parts: string[] = [];
|
|
1615
|
-
if (systemPromptPrefix) {
|
|
1616
|
-
parts.push(systemPromptPrefix);
|
|
1617
|
-
}
|
|
1618
|
-
if (systemPromptSuffix) {
|
|
1619
|
-
parts.push(systemPromptSuffix);
|
|
1620
|
-
}
|
|
1621
|
-
|
|
1622
|
-
return parts.join("\n\n");
|
|
1623
|
-
}
|
|
1624
777
|
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
private mergeSubAgentConfig(
|
|
1632
|
-
defaults?: SubAgentConfig,
|
|
1633
|
-
override?: SubAgentConfig,
|
|
1634
|
-
): SubAgentConfig | undefined {
|
|
1635
|
-
if (!defaults && !override) {
|
|
1636
|
-
return undefined;
|
|
1637
|
-
}
|
|
1638
|
-
|
|
1639
|
-
if (!defaults) {
|
|
1640
|
-
return override;
|
|
1641
|
-
}
|
|
1642
|
-
|
|
1643
|
-
if (!override) {
|
|
1644
|
-
return defaults;
|
|
1645
|
-
}
|
|
1646
|
-
|
|
1647
|
-
// Deep merge with override taking precedence
|
|
1648
|
-
return {
|
|
1649
|
-
model: override.model ?? defaults.model,
|
|
1650
|
-
maxTokens: override.maxTokens ?? defaults.maxTokens,
|
|
1651
|
-
temperature: override.temperature ?? defaults.temperature,
|
|
1652
|
-
permissionMode: override.permissionMode ?? defaults.permissionMode,
|
|
1653
|
-
agentType: override.agentType ?? defaults.agentType,
|
|
1654
|
-
// Merge env variables (override takes precedence for same keys)
|
|
1655
|
-
env:
|
|
1656
|
-
defaults.env || override.env
|
|
1657
|
-
? { ...defaults.env, ...override.env }
|
|
1658
|
-
: undefined,
|
|
1659
|
-
// Concatenate MCP servers (both default and override)
|
|
1660
|
-
mcpServers:
|
|
1661
|
-
[...(defaults.mcpServers ?? []), ...(override.mcpServers ?? [])]
|
|
1662
|
-
.length > 0
|
|
1663
|
-
? [...(defaults.mcpServers ?? []), ...(override.mcpServers ?? [])]
|
|
1664
|
-
: undefined,
|
|
1665
|
-
};
|
|
1666
|
-
}
|
|
778
|
+
return { stopReason: "end_turn" };
|
|
779
|
+
} catch (err) {
|
|
780
|
+
// If prompt fails, still return a valid response
|
|
781
|
+
return { stopReason: "cancelled" };
|
|
782
|
+
} finally {
|
|
783
|
+
sessionMapper.setProcessing(params.sessionId, false);
|
|
1667
784
|
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
mcpServers: config.mcpServers?.map((server) => ({
|
|
1682
|
-
name: server.name,
|
|
1683
|
-
command: server.command,
|
|
1684
|
-
args: server.args,
|
|
1685
|
-
env: server.env,
|
|
1686
|
-
})),
|
|
1687
|
-
};
|
|
1688
|
-
}
|
|
1689
|
-
|
|
1690
|
-
// ─────────────────────────────────────────────────────────────────
|
|
1691
|
-
// History Persistence Helpers
|
|
1692
|
-
// ─────────────────────────────────────────────────────────────────
|
|
1693
|
-
|
|
1694
|
-
/**
|
|
1695
|
-
* Ensure a conversation exists in the EventStore for a session.
|
|
1696
|
-
* Uses the ACP session ID as the conversation ID for direct lookup.
|
|
1697
|
-
*/
|
|
1698
|
-
private ensureConversation(
|
|
1699
|
-
acpSessionId: ACPSessionId,
|
|
1700
|
-
agentId: AgentId,
|
|
1701
|
-
): void {
|
|
1702
|
-
// Guard: EventStore may not support conversations (e.g., in tests with mocks)
|
|
1703
|
-
if (typeof this.eventStore.getConversation !== "function") return;
|
|
1704
|
-
|
|
1705
|
-
// Check if conversation already exists
|
|
1706
|
-
const existing = this.eventStore.getConversation(acpSessionId);
|
|
1707
|
-
if (existing) return;
|
|
1708
|
-
|
|
1709
|
-
try {
|
|
1710
|
-
this.eventStore.emit({
|
|
1711
|
-
type: "conversation",
|
|
1712
|
-
source: { agent_id: agentId },
|
|
1713
|
-
payload: {
|
|
1714
|
-
action: "created",
|
|
1715
|
-
conversation_id: acpSessionId,
|
|
1716
|
-
conversation_type: "session",
|
|
1717
|
-
subject: `ACP session ${acpSessionId}`,
|
|
1718
|
-
},
|
|
1719
|
-
});
|
|
1720
|
-
} catch (error) {
|
|
1721
|
-
console.warn(
|
|
1722
|
-
`[MacroAgent] Failed to create conversation for session ${acpSessionId}:`,
|
|
1723
|
-
error instanceof Error ? error.message : String(error),
|
|
1724
|
-
);
|
|
1725
|
-
}
|
|
1726
|
-
}
|
|
1727
|
-
|
|
1728
|
-
/**
|
|
1729
|
-
* Record user and assistant turns after a prompt completes.
|
|
1730
|
-
*/
|
|
1731
|
-
private recordPromptTurns(
|
|
1732
|
-
acpSessionId: ACPSessionId,
|
|
1733
|
-
agentId: AgentId,
|
|
1734
|
-
userMessage: string,
|
|
1735
|
-
): void {
|
|
1736
|
-
const buffer = this.promptBuffers.get(acpSessionId);
|
|
1737
|
-
if (!buffer) return;
|
|
1738
|
-
|
|
1739
|
-
const now = Date.now();
|
|
1740
|
-
|
|
1741
|
-
try {
|
|
1742
|
-
// Record user turn
|
|
1743
|
-
if (userMessage) {
|
|
1744
|
-
this.eventStore.emit({
|
|
1745
|
-
type: "turn",
|
|
1746
|
-
source: { agent_id: agentId },
|
|
1747
|
-
payload: {
|
|
1748
|
-
action: "recorded",
|
|
1749
|
-
turn_id: `turn_user_${now}_${Math.random().toString(36).slice(2, 8)}`,
|
|
1750
|
-
conversation_id: acpSessionId,
|
|
1751
|
-
participant: "user",
|
|
1752
|
-
timestamp: now,
|
|
1753
|
-
content_type: "user_prompt",
|
|
1754
|
-
content: userMessage,
|
|
1755
|
-
source_type: "explicit",
|
|
1756
|
-
},
|
|
1757
|
-
});
|
|
1758
|
-
}
|
|
1759
|
-
|
|
1760
|
-
// Record assistant turn with accumulated content (parts already in order)
|
|
1761
|
-
const parts = buffer.parts;
|
|
1762
|
-
|
|
1763
|
-
if (parts.length > 0) {
|
|
1764
|
-
this.eventStore.emit({
|
|
1765
|
-
type: "turn",
|
|
1766
|
-
source: { agent_id: agentId },
|
|
1767
|
-
payload: {
|
|
1768
|
-
action: "recorded",
|
|
1769
|
-
turn_id: `turn_asst_${now}_${Math.random().toString(36).slice(2, 8)}`,
|
|
1770
|
-
conversation_id: acpSessionId,
|
|
1771
|
-
participant: agentId,
|
|
1772
|
-
timestamp: now + 1, // +1ms to ensure ordering after user turn
|
|
1773
|
-
content_type: "assistant_response",
|
|
1774
|
-
content: { parts },
|
|
1775
|
-
source_type: "explicit",
|
|
1776
|
-
},
|
|
1777
|
-
});
|
|
785
|
+
// Update agent state back to "idle" — local MAP server
|
|
786
|
+
try {
|
|
787
|
+
const mapServer = (system as any).mapServerInstance;
|
|
788
|
+
if (mapServer) {
|
|
789
|
+
const agents = mapServer.agents?.list?.() ?? [];
|
|
790
|
+
const mapAgent = agents.find(
|
|
791
|
+
(a: any) => a.metadata?.localAgentId === agentId,
|
|
792
|
+
);
|
|
793
|
+
if (mapAgent) {
|
|
794
|
+
mapServer.agents.updateState(mapAgent.id, "idle");
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
} catch { /* best effort */ }
|
|
1778
798
|
}
|
|
1779
|
-
}
|
|
1780
|
-
console.warn(
|
|
1781
|
-
`[MacroAgent] Failed to record turns for session ${acpSessionId}:`,
|
|
1782
|
-
error instanceof Error ? error.message : String(error),
|
|
1783
|
-
);
|
|
1784
|
-
} finally {
|
|
1785
|
-
// Clean up the buffer and tool info cache
|
|
1786
|
-
this.promptBuffers.delete(acpSessionId);
|
|
1787
|
-
this.toolInfoCaches.delete(acpSessionId);
|
|
1788
|
-
}
|
|
1789
|
-
}
|
|
799
|
+
},
|
|
1790
800
|
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
* (via _model_state_update notification), so this allows the TUI to poll
|
|
1795
|
-
* for the model list once it's available.
|
|
1796
|
-
*
|
|
1797
|
-
* Returns full model info (modelId + name) since Claude Code uses shorthand
|
|
1798
|
-
* model IDs ("default", "sonnet") that don't match models.dev. The name
|
|
1799
|
-
* field (e.g., "Claude Sonnet 4") enables better model registry matching.
|
|
1800
|
-
*/
|
|
1801
|
-
private handleGetModels(params: { sessionId: string }): {
|
|
1802
|
-
currentModelId: string | null;
|
|
1803
|
-
availableModels: Array<{ modelId: string; name: string }>;
|
|
1804
|
-
} {
|
|
1805
|
-
const { sessionId } = params;
|
|
1806
|
-
const agentId = this.sessionMapper.getAgentId(sessionId);
|
|
1807
|
-
if (!agentId) {
|
|
1808
|
-
return { currentModelId: null, availableModels: [] };
|
|
1809
|
-
}
|
|
1810
|
-
const session = this.agentManager.getSession(agentId);
|
|
1811
|
-
if (!session) {
|
|
1812
|
-
return { currentModelId: null, availableModels: [] };
|
|
1813
|
-
}
|
|
1814
|
-
// Try clientHandler's model info store first (from _model_state_update notification)
|
|
1815
|
-
const clientHandler = (session as unknown as {
|
|
1816
|
-
clientHandler?: {
|
|
1817
|
-
getSessionModelInfo?: (id: string) => {
|
|
1818
|
-
currentModelId: string | null;
|
|
1819
|
-
availableModels: Array<{ modelId: string; name: string }>;
|
|
1820
|
-
} | null;
|
|
1821
|
-
};
|
|
1822
|
-
}).clientHandler;
|
|
1823
|
-
const modelInfo = clientHandler?.getSessionModelInfo?.(session.id);
|
|
1824
|
-
if (modelInfo && modelInfo.availableModels.length > 0) {
|
|
1825
|
-
return modelInfo;
|
|
1826
|
-
}
|
|
1827
|
-
// Fall back to Session.models (from initial session response — just IDs)
|
|
1828
|
-
if (session.models && session.models.length > 0) {
|
|
1829
|
-
return {
|
|
1830
|
-
currentModelId: session.models[0],
|
|
1831
|
-
availableModels: session.models.map((id) => ({ modelId: id, name: id })),
|
|
1832
|
-
};
|
|
1833
|
-
}
|
|
1834
|
-
return { currentModelId: null, availableModels: [] };
|
|
1835
|
-
}
|
|
1836
|
-
|
|
1837
|
-
/**
|
|
1838
|
-
* Handle _macro/getHistory extension — returns conversation turns for a session
|
|
1839
|
-
*/
|
|
1840
|
-
private handleGetHistory(params: GetHistoryRequest): GetHistoryResponse {
|
|
1841
|
-
const { sessionId, limit } = params;
|
|
1842
|
-
|
|
1843
|
-
// Query turns from EventStore (conversation ID = session ID)
|
|
1844
|
-
const turns = this.eventStore.listTurns({
|
|
1845
|
-
conversationId: sessionId,
|
|
1846
|
-
order: "asc",
|
|
1847
|
-
limit: limit ?? 200,
|
|
1848
|
-
});
|
|
1849
|
-
|
|
1850
|
-
// Convert to HistoryTurn format
|
|
1851
|
-
const historyTurns: HistoryTurn[] = turns.map((turn) => ({
|
|
1852
|
-
role:
|
|
1853
|
-
turn.contentType === "user_prompt"
|
|
1854
|
-
? ("user" as const)
|
|
1855
|
-
: ("assistant" as const),
|
|
1856
|
-
timestamp: turn.timestamp,
|
|
1857
|
-
content: turn.content,
|
|
1858
|
-
}));
|
|
1859
|
-
|
|
1860
|
-
return { turns: historyTurns };
|
|
1861
|
-
}
|
|
1862
|
-
|
|
1863
|
-
// ─────────────────────────────────────────────────────────────────
|
|
1864
|
-
// Accessors
|
|
1865
|
-
// ─────────────────────────────────────────────────────────────────
|
|
801
|
+
async cancel(params: CancelNotification): Promise<void> {
|
|
802
|
+
const mapping = sessionMapper.getMapping(params.sessionId);
|
|
803
|
+
if (!mapping) return;
|
|
1866
804
|
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
805
|
+
try {
|
|
806
|
+
await agentManager.terminate(mapping.agentId, "cancelled");
|
|
807
|
+
} catch {
|
|
808
|
+
// Best effort cancellation
|
|
809
|
+
}
|
|
810
|
+
},
|
|
811
|
+
|
|
812
|
+
async extMethod(
|
|
813
|
+
method: string,
|
|
814
|
+
params: Record<string, unknown>,
|
|
815
|
+
): Promise<Record<string, unknown>> {
|
|
816
|
+
return handleExtension(method, params);
|
|
817
|
+
},
|
|
818
|
+
};
|
|
1880
819
|
|
|
1881
|
-
|
|
1882
|
-
* Get the applied initialization config
|
|
1883
|
-
*/
|
|
1884
|
-
getInitConfig(): MacroAgentInitConfig {
|
|
1885
|
-
return this.initConfig;
|
|
1886
|
-
}
|
|
820
|
+
return agent;
|
|
1887
821
|
}
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* Get the SessionMapper instance from a macro-agent.
|
|
825
|
+
* Exposed for testing and for the WebSocket server.
|
|
826
|
+
*/
|
|
827
|
+
export { SessionMapper };
|