macro-agent 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.macro-agent/teams/self-driving/prompts/grinder.md +27 -0
- package/.macro-agent/teams/self-driving/prompts/judge.md +27 -0
- package/.macro-agent/teams/self-driving/prompts/planner.md +33 -0
- package/.macro-agent/teams/self-driving/roles/grinder.yaml +17 -0
- package/.macro-agent/teams/self-driving/roles/judge.yaml +24 -0
- package/.macro-agent/teams/self-driving/roles/planner.yaml +18 -0
- package/.macro-agent/teams/self-driving/team.yaml +103 -0
- package/.macro-agent/teams/structured/prompts/developer.md +26 -0
- package/.macro-agent/teams/structured/prompts/lead.md +25 -0
- package/.macro-agent/teams/structured/prompts/reviewer.md +24 -0
- package/.macro-agent/teams/structured/roles/developer.yaml +12 -0
- package/.macro-agent/teams/structured/roles/lead.yaml +11 -0
- package/.macro-agent/teams/structured/roles/reviewer.yaml +19 -0
- package/.macro-agent/teams/structured/team.yaml +89 -0
- package/.sudocode/issues.jsonl +6 -0
- package/.sudocode/specs.jsonl +7 -0
- package/CLAUDE.md +110 -30
- package/README.md +60 -3
- package/dist/acp/macro-agent.d.ts +4 -0
- package/dist/acp/macro-agent.d.ts.map +1 -1
- package/dist/acp/macro-agent.js +50 -4
- package/dist/acp/macro-agent.js.map +1 -1
- package/dist/acp/session-mapper.d.ts +20 -1
- package/dist/acp/session-mapper.d.ts.map +1 -1
- package/dist/acp/session-mapper.js +90 -1
- package/dist/acp/session-mapper.js.map +1 -1
- package/dist/acp/types.d.ts +24 -1
- package/dist/acp/types.d.ts.map +1 -1
- package/dist/acp/types.js.map +1 -1
- package/dist/agent/agent-manager.d.ts +25 -1
- package/dist/agent/agent-manager.d.ts.map +1 -1
- package/dist/agent/agent-manager.js +93 -7
- package/dist/agent/agent-manager.js.map +1 -1
- package/dist/agent/types.d.ts +22 -0
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/agent-detection/command-builder.d.ts +30 -0
- package/dist/agent-detection/command-builder.d.ts.map +1 -0
- package/dist/agent-detection/command-builder.js +71 -0
- package/dist/agent-detection/command-builder.js.map +1 -0
- package/dist/agent-detection/detector.d.ts +84 -0
- package/dist/agent-detection/detector.d.ts.map +1 -0
- package/dist/agent-detection/detector.js +240 -0
- package/dist/agent-detection/detector.js.map +1 -0
- package/dist/agent-detection/index.d.ts +12 -0
- package/dist/agent-detection/index.d.ts.map +1 -0
- package/dist/agent-detection/index.js +14 -0
- package/dist/agent-detection/index.js.map +1 -0
- package/dist/agent-detection/registry.d.ts +53 -0
- package/dist/agent-detection/registry.d.ts.map +1 -0
- package/dist/agent-detection/registry.js +177 -0
- package/dist/agent-detection/registry.js.map +1 -0
- package/dist/agent-detection/types.d.ts +121 -0
- package/dist/agent-detection/types.d.ts.map +1 -0
- package/dist/agent-detection/types.js +20 -0
- package/dist/agent-detection/types.js.map +1 -0
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +95 -0
- package/dist/api/server.js.map +1 -1
- package/dist/cli/index.js +29 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/mcp.js +38 -0
- package/dist/cli/mcp.js.map +1 -1
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +2 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/project-config.d.ts +46 -0
- package/dist/config/project-config.d.ts.map +1 -0
- package/dist/config/project-config.js +68 -0
- package/dist/config/project-config.js.map +1 -0
- package/dist/lifecycle/cascade.d.ts +1 -1
- package/dist/lifecycle/cascade.d.ts.map +1 -1
- package/dist/lifecycle/handlers/index.d.ts +4 -0
- package/dist/lifecycle/handlers/index.d.ts.map +1 -1
- package/dist/lifecycle/handlers/index.js +2 -0
- package/dist/lifecycle/handlers/index.js.map +1 -1
- package/dist/lifecycle/handlers/worker.d.ts +4 -0
- package/dist/lifecycle/handlers/worker.d.ts.map +1 -1
- package/dist/lifecycle/handlers/worker.js +35 -3
- package/dist/lifecycle/handlers/worker.js.map +1 -1
- package/dist/map/adapter/acp-over-map.d.ts.map +1 -1
- package/dist/map/adapter/acp-over-map.js +32 -2
- package/dist/map/adapter/acp-over-map.js.map +1 -1
- package/dist/map/adapter/event-translator.d.ts.map +1 -1
- package/dist/map/adapter/event-translator.js +1 -0
- package/dist/map/adapter/event-translator.js.map +1 -1
- package/dist/map/adapter/extensions/agent-detection.d.ts +49 -0
- package/dist/map/adapter/extensions/agent-detection.d.ts.map +1 -0
- package/dist/map/adapter/extensions/agent-detection.js +91 -0
- package/dist/map/adapter/extensions/agent-detection.js.map +1 -0
- package/dist/map/adapter/extensions/index.d.ts +10 -1
- package/dist/map/adapter/extensions/index.d.ts.map +1 -1
- package/dist/map/adapter/extensions/index.js +39 -0
- package/dist/map/adapter/extensions/index.js.map +1 -1
- package/dist/map/adapter/extensions/resume.d.ts +47 -0
- package/dist/map/adapter/extensions/resume.d.ts.map +1 -0
- package/dist/map/adapter/extensions/resume.js +59 -0
- package/dist/map/adapter/extensions/resume.js.map +1 -0
- package/dist/map/adapter/extensions/workspace-files.d.ts +42 -0
- package/dist/map/adapter/extensions/workspace-files.d.ts.map +1 -0
- package/dist/map/adapter/extensions/workspace-files.js +338 -0
- package/dist/map/adapter/extensions/workspace-files.js.map +1 -0
- package/dist/mcp/mcp-server.d.ts +6 -0
- package/dist/mcp/mcp-server.d.ts.map +1 -1
- package/dist/mcp/mcp-server.js +45 -0
- package/dist/mcp/mcp-server.js.map +1 -1
- package/dist/mcp/tools/claim_task.d.ts +35 -0
- package/dist/mcp/tools/claim_task.d.ts.map +1 -0
- package/dist/mcp/tools/claim_task.js +58 -0
- package/dist/mcp/tools/claim_task.js.map +1 -0
- package/dist/mcp/tools/done.d.ts +11 -2
- package/dist/mcp/tools/done.d.ts.map +1 -1
- package/dist/mcp/tools/done.js +15 -10
- package/dist/mcp/tools/done.js.map +1 -1
- package/dist/mcp/tools/list_claimable_tasks.d.ts +38 -0
- package/dist/mcp/tools/list_claimable_tasks.d.ts.map +1 -0
- package/dist/mcp/tools/list_claimable_tasks.js +63 -0
- package/dist/mcp/tools/list_claimable_tasks.js.map +1 -0
- package/dist/mcp/tools/unclaim_task.d.ts +31 -0
- package/dist/mcp/tools/unclaim_task.d.ts.map +1 -0
- package/dist/mcp/tools/unclaim_task.js +47 -0
- package/dist/mcp/tools/unclaim_task.js.map +1 -0
- package/dist/metrics/index.d.ts +2 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js +2 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/metrics/metrics.d.ts +79 -0
- package/dist/metrics/metrics.d.ts.map +1 -0
- package/dist/metrics/metrics.js +166 -0
- package/dist/metrics/metrics.js.map +1 -0
- package/dist/roles/capabilities.d.ts +1 -0
- package/dist/roles/capabilities.d.ts.map +1 -1
- package/dist/roles/capabilities.js +3 -0
- package/dist/roles/capabilities.js.map +1 -1
- package/dist/roles/types.d.ts +1 -1
- package/dist/roles/types.d.ts.map +1 -1
- package/dist/router/message-router.d.ts +41 -0
- package/dist/router/message-router.d.ts.map +1 -1
- package/dist/router/message-router.js +136 -5
- package/dist/router/message-router.js.map +1 -1
- package/dist/store/event-store.d.ts +8 -1
- package/dist/store/event-store.d.ts.map +1 -1
- package/dist/store/event-store.js +120 -4
- package/dist/store/event-store.js.map +1 -1
- package/dist/store/types/agents.d.ts +1 -1
- package/dist/store/types/agents.d.ts.map +1 -1
- package/dist/store/types/events.d.ts +1 -1
- package/dist/store/types/events.d.ts.map +1 -1
- package/dist/store/types/events.js.map +1 -1
- package/dist/store/types/index.d.ts +1 -0
- package/dist/store/types/index.d.ts.map +1 -1
- package/dist/store/types/index.js +1 -0
- package/dist/store/types/index.js.map +1 -1
- package/dist/store/types/sessions.d.ts +44 -0
- package/dist/store/types/sessions.d.ts.map +1 -0
- package/dist/store/types/sessions.js +9 -0
- package/dist/store/types/sessions.js.map +1 -0
- package/dist/store/types/tasks.d.ts +2 -0
- package/dist/store/types/tasks.d.ts.map +1 -1
- package/dist/task/backend/memory.d.ts +4 -1
- package/dist/task/backend/memory.d.ts.map +1 -1
- package/dist/task/backend/memory.js +81 -0
- package/dist/task/backend/memory.js.map +1 -1
- package/dist/task/backend/types.d.ts +30 -0
- package/dist/task/backend/types.d.ts.map +1 -1
- package/dist/task/backend/types.js.map +1 -1
- package/dist/teams/index.d.ts +4 -0
- package/dist/teams/index.d.ts.map +1 -0
- package/dist/teams/index.js +4 -0
- package/dist/teams/index.js.map +1 -0
- package/dist/teams/team-loader.d.ts +20 -0
- package/dist/teams/team-loader.d.ts.map +1 -0
- package/dist/teams/team-loader.js +293 -0
- package/dist/teams/team-loader.js.map +1 -0
- package/dist/teams/team-runtime.d.ts +139 -0
- package/dist/teams/team-runtime.d.ts.map +1 -0
- package/dist/teams/team-runtime.js +613 -0
- package/dist/teams/team-runtime.js.map +1 -0
- package/dist/teams/types.d.ts +266 -0
- package/dist/teams/types.d.ts.map +1 -0
- package/dist/teams/types.js +20 -0
- package/dist/teams/types.js.map +1 -0
- package/dist/workspace/dataplane-adapter.d.ts +1 -1
- package/dist/workspace/dataplane-adapter.d.ts.map +1 -1
- package/dist/workspace/dataplane-adapter.js +1 -1
- package/dist/workspace/dataplane-adapter.js.map +1 -1
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/strategies/index.d.ts +6 -0
- package/dist/workspace/strategies/index.d.ts.map +1 -0
- package/dist/workspace/strategies/index.js +5 -0
- package/dist/workspace/strategies/index.js.map +1 -0
- package/dist/workspace/strategies/optimistic.d.ts +26 -0
- package/dist/workspace/strategies/optimistic.d.ts.map +1 -0
- package/dist/workspace/strategies/optimistic.js +121 -0
- package/dist/workspace/strategies/optimistic.js.map +1 -0
- package/dist/workspace/strategies/queue.d.ts +26 -0
- package/dist/workspace/strategies/queue.d.ts.map +1 -0
- package/dist/workspace/strategies/queue.js +67 -0
- package/dist/workspace/strategies/queue.js.map +1 -0
- package/dist/workspace/strategies/registry.d.ts +37 -0
- package/dist/workspace/strategies/registry.d.ts.map +1 -0
- package/dist/workspace/strategies/registry.js +63 -0
- package/dist/workspace/strategies/registry.js.map +1 -0
- package/dist/workspace/strategies/trunk.d.ts +20 -0
- package/dist/workspace/strategies/trunk.d.ts.map +1 -0
- package/dist/workspace/strategies/trunk.js +108 -0
- package/dist/workspace/strategies/trunk.js.map +1 -0
- package/dist/workspace/strategies/types.d.ts +104 -0
- package/dist/workspace/strategies/types.d.ts.map +1 -0
- package/dist/workspace/strategies/types.js +11 -0
- package/dist/workspace/strategies/types.js.map +1 -0
- package/dist/workspace/types.d.ts +1 -1
- package/dist/workspace/types.d.ts.map +1 -1
- package/dist/workspace/workspace-manager.d.ts +1 -1
- package/dist/workspace/workspace-manager.d.ts.map +1 -1
- package/docs/implementation-details.md +1127 -0
- package/docs/implementation-summary.md +448 -0
- package/docs/plan-self-driving-support.md +433 -0
- package/docs/spec-self-driving-support.md +462 -0
- package/docs/team-templates.md +860 -0
- package/docs/teams.md +233 -0
- package/package.json +4 -2
- package/src/acp/__tests__/integration.test.ts +161 -1
- package/src/acp/__tests__/macro-agent.test.ts +95 -0
- package/src/acp/__tests__/session-persistence.test.ts +276 -0
- package/src/acp/macro-agent.ts +79 -7
- package/src/acp/session-mapper.ts +108 -1
- package/src/acp/types.ts +33 -1
- package/src/agent/agent-manager.ts +158 -6
- package/src/agent/types.ts +27 -0
- package/src/agent-detection/__tests__/command-builder.test.ts +336 -0
- package/src/agent-detection/__tests__/detector.test.ts +768 -0
- package/src/agent-detection/__tests__/registry.test.ts +254 -0
- package/src/agent-detection/command-builder.ts +90 -0
- package/src/agent-detection/detector.ts +307 -0
- package/src/agent-detection/index.ts +36 -0
- package/src/agent-detection/registry.ts +200 -0
- package/src/agent-detection/types.ts +184 -0
- package/src/api/server.ts +110 -0
- package/src/cli/index.ts +44 -0
- package/src/cli/mcp.ts +47 -0
- package/src/config/index.ts +9 -0
- package/src/config/project-config.ts +107 -0
- package/src/lifecycle/cascade.ts +1 -1
- package/src/lifecycle/handlers/index.ts +8 -0
- package/src/lifecycle/handlers/worker.ts +48 -3
- package/src/map/adapter/__tests__/extensions.test.ts +359 -0
- package/src/map/adapter/__tests__/workspace-files.test.ts +673 -0
- package/src/map/adapter/acp-over-map.ts +45 -2
- package/src/map/adapter/event-translator.ts +1 -0
- package/src/map/adapter/extensions/agent-detection.ts +201 -0
- package/src/map/adapter/extensions/index.ts +63 -0
- package/src/map/adapter/extensions/resume.ts +114 -0
- package/src/map/adapter/extensions/workspace-files.ts +449 -0
- package/src/mcp/mcp-server.ts +67 -0
- package/src/mcp/tools/claim_task.ts +86 -0
- package/src/mcp/tools/done.ts +24 -10
- package/src/mcp/tools/list_claimable_tasks.ts +93 -0
- package/src/mcp/tools/unclaim_task.ts +71 -0
- package/src/metrics/index.ts +9 -0
- package/src/metrics/metrics.ts +280 -0
- package/src/roles/capabilities.ts +3 -0
- package/src/roles/types.ts +2 -1
- package/src/router/__tests__/message-router.test.ts +561 -0
- package/src/router/message-router.ts +223 -6
- package/src/store/event-store.ts +151 -3
- package/src/store/types/agents.ts +1 -1
- package/src/store/types/events.ts +2 -1
- package/src/store/types/index.ts +1 -0
- package/src/store/types/sessions.ts +53 -0
- package/src/store/types/tasks.ts +3 -0
- package/src/task/backend/memory.ts +116 -0
- package/src/task/backend/types.ts +43 -0
- package/src/teams/__tests__/cross-subsystem.integration.test.ts +983 -0
- package/src/teams/__tests__/e2e/team-runtime.e2e.test.ts +553 -0
- package/src/teams/__tests__/team-system.test.ts +1280 -0
- package/src/teams/index.ts +13 -0
- package/src/teams/team-loader.ts +434 -0
- package/src/teams/team-runtime.ts +727 -0
- package/src/teams/types.ts +377 -0
- package/src/workspace/dataplane-adapter.ts +1 -1
- package/src/workspace/index.ts +1 -1
- package/src/workspace/strategies/index.ts +18 -0
- package/src/workspace/strategies/optimistic.ts +136 -0
- package/src/workspace/strategies/queue.ts +81 -0
- package/src/workspace/strategies/registry.ts +89 -0
- package/src/workspace/strategies/trunk.ts +123 -0
- package/src/workspace/strategies/types.ts +145 -0
- package/src/workspace/types.ts +1 -1
- package/src/workspace/workspace-manager.ts +1 -1
- package/.claude/settings.local.json +0 -59
- 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/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/__init__.py +0 -0
- 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 -2065
- 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/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
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace File Search Extension Methods (_macro/workspace/files/*)
|
|
3
|
+
*
|
|
4
|
+
* Exposes file search and read capabilities for agent workspaces to
|
|
5
|
+
* external MAP clients (e.g., TUI file attachment system).
|
|
6
|
+
*
|
|
7
|
+
* Methods:
|
|
8
|
+
* - _macro/workspace/files/search - Search files by query
|
|
9
|
+
* - _macro/workspace/files/list - List files in a directory
|
|
10
|
+
* - _macro/workspace/files/read - Read file contents
|
|
11
|
+
*
|
|
12
|
+
* Security: All file operations are scoped to the agent's workspace path.
|
|
13
|
+
* Path traversal is rejected.
|
|
14
|
+
*
|
|
15
|
+
* @see specs/s-5vx8 File Attachment System
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type { MAPAdapter, ExtensionHandler, ExtensionContext } from "../interface.js";
|
|
19
|
+
import type { AgentId } from "../../../store/types/index.js";
|
|
20
|
+
import type { InternalWorkspace } from "./workspace.js";
|
|
21
|
+
import { RPCError } from "../rpc-handler.js";
|
|
22
|
+
import * as fs from "fs";
|
|
23
|
+
import * as path from "path";
|
|
24
|
+
|
|
25
|
+
// =============================================================================
|
|
26
|
+
// Request/Response Types
|
|
27
|
+
// =============================================================================
|
|
28
|
+
|
|
29
|
+
interface FileSearchParams {
|
|
30
|
+
/** Agent whose workspace to search */
|
|
31
|
+
agentId: string;
|
|
32
|
+
/** Search query (matched against filenames) */
|
|
33
|
+
query: string;
|
|
34
|
+
/** Subdirectory to search within (relative to workspace root) */
|
|
35
|
+
cwd?: string;
|
|
36
|
+
/** Max results to return (default 50) */
|
|
37
|
+
limit?: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface FileListParams {
|
|
41
|
+
/** Agent whose workspace to list */
|
|
42
|
+
agentId: string;
|
|
43
|
+
/** Directory to list (relative to workspace root, default ".") */
|
|
44
|
+
directory?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface FileReadParams {
|
|
48
|
+
/** Agent whose workspace to read from */
|
|
49
|
+
agentId: string;
|
|
50
|
+
/** File path relative to workspace root */
|
|
51
|
+
path: string;
|
|
52
|
+
/** Optional line range */
|
|
53
|
+
lineRange?: { start: number; end: number };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* File search result
|
|
58
|
+
*/
|
|
59
|
+
interface FileSearchResult {
|
|
60
|
+
/** Relative path from workspace root */
|
|
61
|
+
path: string;
|
|
62
|
+
/** Whether this is a directory */
|
|
63
|
+
isDirectory: boolean;
|
|
64
|
+
/** File size in bytes (undefined for directories) */
|
|
65
|
+
size?: number;
|
|
66
|
+
/** MIME type guess based on extension */
|
|
67
|
+
mime?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// =============================================================================
|
|
71
|
+
// Constants
|
|
72
|
+
// =============================================================================
|
|
73
|
+
|
|
74
|
+
/** Directories to always exclude from search */
|
|
75
|
+
const EXCLUDED_DIRS = new Set([
|
|
76
|
+
"node_modules",
|
|
77
|
+
".git",
|
|
78
|
+
"dist",
|
|
79
|
+
"build",
|
|
80
|
+
".next",
|
|
81
|
+
".nuxt",
|
|
82
|
+
"__pycache__",
|
|
83
|
+
".venv",
|
|
84
|
+
"venv",
|
|
85
|
+
".tox",
|
|
86
|
+
"target",
|
|
87
|
+
"vendor",
|
|
88
|
+
".cache",
|
|
89
|
+
".turbo",
|
|
90
|
+
]);
|
|
91
|
+
|
|
92
|
+
/** Binary file extensions to exclude from search */
|
|
93
|
+
const BINARY_EXTENSIONS = new Set([
|
|
94
|
+
".png", ".jpg", ".jpeg", ".gif", ".bmp", ".ico", ".svg",
|
|
95
|
+
".mp3", ".mp4", ".wav", ".avi", ".mov",
|
|
96
|
+
".zip", ".tar", ".gz", ".bz2", ".7z", ".rar",
|
|
97
|
+
".woff", ".woff2", ".ttf", ".eot",
|
|
98
|
+
".pdf", ".doc", ".docx", ".xls", ".xlsx",
|
|
99
|
+
".exe", ".dll", ".so", ".dylib",
|
|
100
|
+
".sqlite", ".db",
|
|
101
|
+
]);
|
|
102
|
+
|
|
103
|
+
/** Common MIME type mappings */
|
|
104
|
+
const MIME_MAP: Record<string, string> = {
|
|
105
|
+
".ts": "text/typescript",
|
|
106
|
+
".tsx": "text/typescript",
|
|
107
|
+
".js": "text/javascript",
|
|
108
|
+
".jsx": "text/javascript",
|
|
109
|
+
".json": "application/json",
|
|
110
|
+
".md": "text/markdown",
|
|
111
|
+
".css": "text/css",
|
|
112
|
+
".html": "text/html",
|
|
113
|
+
".py": "text/x-python",
|
|
114
|
+
".rs": "text/x-rust",
|
|
115
|
+
".go": "text/x-go",
|
|
116
|
+
".java": "text/x-java",
|
|
117
|
+
".c": "text/x-c",
|
|
118
|
+
".cpp": "text/x-c++",
|
|
119
|
+
".h": "text/x-c",
|
|
120
|
+
".rb": "text/x-ruby",
|
|
121
|
+
".sh": "text/x-shellscript",
|
|
122
|
+
".yaml": "text/yaml",
|
|
123
|
+
".yml": "text/yaml",
|
|
124
|
+
".toml": "text/toml",
|
|
125
|
+
".xml": "text/xml",
|
|
126
|
+
".sql": "text/x-sql",
|
|
127
|
+
".txt": "text/plain",
|
|
128
|
+
".env": "text/plain",
|
|
129
|
+
".gitignore": "text/plain",
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const DEFAULT_LIMIT = 50;
|
|
133
|
+
const MAX_LIMIT = 200;
|
|
134
|
+
const MAX_FILE_READ_SIZE = 10 * 1024 * 1024; // 10MB
|
|
135
|
+
|
|
136
|
+
// =============================================================================
|
|
137
|
+
// Extension Services
|
|
138
|
+
// =============================================================================
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Services required for workspace file search extension
|
|
142
|
+
*/
|
|
143
|
+
export interface WorkspaceFileServices {
|
|
144
|
+
/** Get workspace for an agent */
|
|
145
|
+
getWorkspace: (agentId: AgentId) => InternalWorkspace | null;
|
|
146
|
+
/** Check if agent exists */
|
|
147
|
+
agentExists: (agentId: AgentId) => boolean;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// =============================================================================
|
|
151
|
+
// Utilities
|
|
152
|
+
// =============================================================================
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Resolve and validate a path within a workspace root.
|
|
156
|
+
* Rejects path traversal attempts.
|
|
157
|
+
*/
|
|
158
|
+
function resolveWorkspacePath(workspacePath: string, relativePath: string): string {
|
|
159
|
+
const resolved = path.resolve(workspacePath, relativePath);
|
|
160
|
+
if (!resolved.startsWith(workspacePath)) {
|
|
161
|
+
throw RPCError.invalidParams("Path traversal not allowed");
|
|
162
|
+
}
|
|
163
|
+
return resolved;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Guess MIME type from file extension
|
|
168
|
+
*/
|
|
169
|
+
function guessMime(filePath: string): string {
|
|
170
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
171
|
+
return MIME_MAP[ext] ?? "text/plain";
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Check if a directory name should be excluded from search
|
|
176
|
+
*/
|
|
177
|
+
function isExcludedDir(name: string): boolean {
|
|
178
|
+
return EXCLUDED_DIRS.has(name) || name.startsWith(".");
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Check if a file has a binary extension
|
|
183
|
+
*/
|
|
184
|
+
function isBinaryFile(name: string): boolean {
|
|
185
|
+
const ext = path.extname(name).toLowerCase();
|
|
186
|
+
return BINARY_EXTENSIONS.has(ext);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Recursively search for files matching a query.
|
|
191
|
+
*/
|
|
192
|
+
async function searchFiles(
|
|
193
|
+
rootDir: string,
|
|
194
|
+
searchDir: string,
|
|
195
|
+
query: string,
|
|
196
|
+
limit: number,
|
|
197
|
+
): Promise<FileSearchResult[]> {
|
|
198
|
+
const results: FileSearchResult[] = [];
|
|
199
|
+
const queryLower = query.toLowerCase();
|
|
200
|
+
const hasPathSeparator = query.includes("/");
|
|
201
|
+
|
|
202
|
+
async function walk(dir: string, depth: number): Promise<void> {
|
|
203
|
+
if (results.length >= limit || depth > 20) return;
|
|
204
|
+
|
|
205
|
+
let entries: fs.Dirent[];
|
|
206
|
+
try {
|
|
207
|
+
entries = await fs.promises.readdir(dir, { withFileTypes: true });
|
|
208
|
+
} catch {
|
|
209
|
+
return; // Skip unreadable directories
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
for (const entry of entries) {
|
|
213
|
+
if (results.length >= limit) break;
|
|
214
|
+
|
|
215
|
+
if (entry.isDirectory()) {
|
|
216
|
+
if (isExcludedDir(entry.name)) continue;
|
|
217
|
+
|
|
218
|
+
const relativePath = path.relative(rootDir, path.join(dir, entry.name));
|
|
219
|
+
|
|
220
|
+
// For path queries, check if directory path matches
|
|
221
|
+
if (hasPathSeparator && relativePath.toLowerCase().includes(queryLower)) {
|
|
222
|
+
results.push({ path: relativePath + "/", isDirectory: true });
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
await walk(path.join(dir, entry.name), depth + 1);
|
|
226
|
+
} else {
|
|
227
|
+
if (isBinaryFile(entry.name)) continue;
|
|
228
|
+
|
|
229
|
+
const relativePath = path.relative(rootDir, path.join(dir, entry.name));
|
|
230
|
+
const matchTarget = hasPathSeparator ? relativePath : entry.name;
|
|
231
|
+
|
|
232
|
+
if (matchTarget.toLowerCase().includes(queryLower)) {
|
|
233
|
+
let size: number | undefined;
|
|
234
|
+
try {
|
|
235
|
+
const stat = await fs.promises.stat(path.join(dir, entry.name));
|
|
236
|
+
size = stat.size;
|
|
237
|
+
} catch {
|
|
238
|
+
// Skip files we can't stat
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
results.push({
|
|
242
|
+
path: relativePath,
|
|
243
|
+
isDirectory: false,
|
|
244
|
+
size,
|
|
245
|
+
mime: guessMime(entry.name),
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
await walk(searchDir, 0);
|
|
253
|
+
|
|
254
|
+
// Sort: path depth (shallow first) → alphabetical
|
|
255
|
+
results.sort((a, b) => {
|
|
256
|
+
const aDepth = a.path.split("/").length;
|
|
257
|
+
const bDepth = b.path.split("/").length;
|
|
258
|
+
if (aDepth !== bDepth) return aDepth - bDepth;
|
|
259
|
+
return a.path.localeCompare(b.path);
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
return results.slice(0, limit);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// =============================================================================
|
|
266
|
+
// Handler Implementations
|
|
267
|
+
// =============================================================================
|
|
268
|
+
|
|
269
|
+
function createSearchHandler(services: WorkspaceFileServices): ExtensionHandler {
|
|
270
|
+
return async (_context: ExtensionContext, params: unknown) => {
|
|
271
|
+
const { agentId, query, cwd, limit: rawLimit } = (params ?? {}) as FileSearchParams;
|
|
272
|
+
|
|
273
|
+
if (!agentId) {
|
|
274
|
+
throw RPCError.invalidParams("agentId is required");
|
|
275
|
+
}
|
|
276
|
+
if (!query || typeof query !== "string") {
|
|
277
|
+
throw RPCError.invalidParams("query is required and must be a string");
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if (!services.agentExists(agentId as AgentId)) {
|
|
281
|
+
throw RPCError.notFound("agent", agentId);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const workspace = services.getWorkspace(agentId as AgentId);
|
|
285
|
+
if (!workspace) {
|
|
286
|
+
return { files: [] };
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const limit = Math.min(rawLimit ?? DEFAULT_LIMIT, MAX_LIMIT);
|
|
290
|
+
const searchRoot = cwd
|
|
291
|
+
? resolveWorkspacePath(workspace.path, cwd)
|
|
292
|
+
: workspace.path;
|
|
293
|
+
|
|
294
|
+
const files = await searchFiles(workspace.path, searchRoot, query, limit);
|
|
295
|
+
return { files };
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function createListHandler(services: WorkspaceFileServices): ExtensionHandler {
|
|
300
|
+
return async (_context: ExtensionContext, params: unknown) => {
|
|
301
|
+
const { agentId, directory = "." } = (params ?? {}) as FileListParams;
|
|
302
|
+
|
|
303
|
+
if (!agentId) {
|
|
304
|
+
throw RPCError.invalidParams("agentId is required");
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (!services.agentExists(agentId as AgentId)) {
|
|
308
|
+
throw RPCError.notFound("agent", agentId);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const workspace = services.getWorkspace(agentId as AgentId);
|
|
312
|
+
if (!workspace) {
|
|
313
|
+
return { files: [] };
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
const dirPath = resolveWorkspacePath(workspace.path, directory);
|
|
317
|
+
|
|
318
|
+
let entries: fs.Dirent[];
|
|
319
|
+
try {
|
|
320
|
+
entries = await fs.promises.readdir(dirPath, { withFileTypes: true });
|
|
321
|
+
} catch {
|
|
322
|
+
throw RPCError.invalidParams(`Directory not found: ${directory}`);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const files: FileSearchResult[] = [];
|
|
326
|
+
for (const entry of entries) {
|
|
327
|
+
if (entry.isDirectory()) {
|
|
328
|
+
if (isExcludedDir(entry.name)) continue;
|
|
329
|
+
files.push({
|
|
330
|
+
path: path.relative(workspace.path, path.join(dirPath, entry.name)) + "/",
|
|
331
|
+
isDirectory: true,
|
|
332
|
+
});
|
|
333
|
+
} else {
|
|
334
|
+
if (isBinaryFile(entry.name)) continue;
|
|
335
|
+
let size: number | undefined;
|
|
336
|
+
try {
|
|
337
|
+
const stat = await fs.promises.stat(path.join(dirPath, entry.name));
|
|
338
|
+
size = stat.size;
|
|
339
|
+
} catch {
|
|
340
|
+
// Skip
|
|
341
|
+
}
|
|
342
|
+
files.push({
|
|
343
|
+
path: path.relative(workspace.path, path.join(dirPath, entry.name)),
|
|
344
|
+
isDirectory: false,
|
|
345
|
+
size,
|
|
346
|
+
mime: guessMime(entry.name),
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// Sort directories first, then alphabetically
|
|
352
|
+
files.sort((a, b) => {
|
|
353
|
+
if (a.isDirectory !== b.isDirectory) return a.isDirectory ? -1 : 1;
|
|
354
|
+
return a.path.localeCompare(b.path);
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
return { files };
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function createReadHandler(services: WorkspaceFileServices): ExtensionHandler {
|
|
362
|
+
return async (_context: ExtensionContext, params: unknown) => {
|
|
363
|
+
const { agentId, path: filePath, lineRange } = (params ?? {}) as FileReadParams;
|
|
364
|
+
|
|
365
|
+
if (!agentId) {
|
|
366
|
+
throw RPCError.invalidParams("agentId is required");
|
|
367
|
+
}
|
|
368
|
+
if (!filePath || typeof filePath !== "string") {
|
|
369
|
+
throw RPCError.invalidParams("path is required and must be a string");
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
if (!services.agentExists(agentId as AgentId)) {
|
|
373
|
+
throw RPCError.notFound("agent", agentId);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
const workspace = services.getWorkspace(agentId as AgentId);
|
|
377
|
+
if (!workspace) {
|
|
378
|
+
throw RPCError.invalidParams(`Agent ${agentId} has no workspace`);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
const absolutePath = resolveWorkspacePath(workspace.path, filePath);
|
|
382
|
+
|
|
383
|
+
// Check file exists and get size
|
|
384
|
+
let stat: fs.Stats;
|
|
385
|
+
try {
|
|
386
|
+
stat = await fs.promises.stat(absolutePath);
|
|
387
|
+
} catch {
|
|
388
|
+
throw RPCError.invalidParams(`File not found: ${filePath}`);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
if (stat.isDirectory()) {
|
|
392
|
+
throw RPCError.invalidParams(`Path is a directory: ${filePath}`);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
if (stat.size > MAX_FILE_READ_SIZE) {
|
|
396
|
+
throw RPCError.resourceLimitExceeded(
|
|
397
|
+
`File too large: ${stat.size} bytes (max ${MAX_FILE_READ_SIZE})`
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
let text = await fs.promises.readFile(absolutePath, "utf-8");
|
|
402
|
+
|
|
403
|
+
// Apply line range if specified
|
|
404
|
+
if (lineRange) {
|
|
405
|
+
const { start, end } = lineRange;
|
|
406
|
+
if (typeof start !== "number" || typeof end !== "number" || start < 1 || end < start) {
|
|
407
|
+
throw RPCError.invalidParams("lineRange must have start >= 1 and end >= start");
|
|
408
|
+
}
|
|
409
|
+
const lines = text.split("\n");
|
|
410
|
+
text = lines.slice(start - 1, end).join("\n");
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
return {
|
|
414
|
+
text,
|
|
415
|
+
mime: guessMime(filePath),
|
|
416
|
+
size: stat.size,
|
|
417
|
+
};
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// =============================================================================
|
|
422
|
+
// Registration
|
|
423
|
+
// =============================================================================
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Register workspace file search extension methods with the MAPAdapter.
|
|
427
|
+
*
|
|
428
|
+
* @param adapter - MAPAdapter instance
|
|
429
|
+
* @param services - Workspace file search services
|
|
430
|
+
*/
|
|
431
|
+
export function registerWorkspaceFileExtensions(
|
|
432
|
+
adapter: MAPAdapter,
|
|
433
|
+
services: WorkspaceFileServices,
|
|
434
|
+
): void {
|
|
435
|
+
adapter.registerExtension("_macro/workspace/files/search", createSearchHandler(services));
|
|
436
|
+
adapter.registerExtension("_macro/workspace/files/list", createListHandler(services));
|
|
437
|
+
adapter.registerExtension("_macro/workspace/files/read", createReadHandler(services));
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Unregister workspace file search extension methods.
|
|
442
|
+
*
|
|
443
|
+
* @param adapter - MAPAdapter instance
|
|
444
|
+
*/
|
|
445
|
+
export function unregisterWorkspaceFileExtensions(adapter: MAPAdapter): void {
|
|
446
|
+
adapter.unregisterExtension("_macro/workspace/files/search");
|
|
447
|
+
adapter.unregisterExtension("_macro/workspace/files/list");
|
|
448
|
+
adapter.unregisterExtension("_macro/workspace/files/read");
|
|
449
|
+
}
|
package/src/mcp/mcp-server.ts
CHANGED
|
@@ -36,6 +36,21 @@ import {
|
|
|
36
36
|
formatInjectContextResult,
|
|
37
37
|
INJECT_CONTEXT_TOOL_INFO,
|
|
38
38
|
} from "./tools/inject_context.js";
|
|
39
|
+
import {
|
|
40
|
+
ClaimTaskSchema,
|
|
41
|
+
createClaimTaskHandler,
|
|
42
|
+
CLAIM_TASK_TOOL_INFO,
|
|
43
|
+
} from "./tools/claim_task.js";
|
|
44
|
+
import {
|
|
45
|
+
UnclaimTaskSchema,
|
|
46
|
+
createUnclaimTaskHandler,
|
|
47
|
+
UNCLAIM_TASK_TOOL_INFO,
|
|
48
|
+
} from "./tools/unclaim_task.js";
|
|
49
|
+
import {
|
|
50
|
+
ListClaimableTasksSchema,
|
|
51
|
+
createListClaimableTasksHandler,
|
|
52
|
+
LIST_CLAIMABLE_TASKS_TOOL_INFO,
|
|
53
|
+
} from "./tools/list_claimable_tasks.js";
|
|
39
54
|
import type { TaskToolProvider } from "../task/backend/types.js";
|
|
40
55
|
import type { RoleRegistry, RoleDefinition } from "../roles/types.js";
|
|
41
56
|
import { DefaultRoleRegistry } from "../roles/registry.js";
|
|
@@ -82,6 +97,12 @@ export interface MCPServices {
|
|
|
82
97
|
taskToolProvider?: TaskToolProvider;
|
|
83
98
|
/** Optional role registry for role-based tool filtering */
|
|
84
99
|
roleRegistry?: RoleRegistry;
|
|
100
|
+
/** Optional task mode from team config (push or pull) */
|
|
101
|
+
taskMode?: "push" | "pull";
|
|
102
|
+
/** Optional integration strategy from team config */
|
|
103
|
+
integrationStrategy?: import("../workspace/strategies/types.js").IntegrationStrategy;
|
|
104
|
+
/** Optional task backend for pull model tools (claim/unclaim) */
|
|
105
|
+
taskBackend?: import("../task/backend/types.js").TaskBackend;
|
|
85
106
|
}
|
|
86
107
|
|
|
87
108
|
// ─────────────────────────────────────────────────────────────────
|
|
@@ -1093,6 +1114,9 @@ export function createMCPServer(
|
|
|
1093
1114
|
agentManager,
|
|
1094
1115
|
messageRouter,
|
|
1095
1116
|
taskManager,
|
|
1117
|
+
roleRegistry,
|
|
1118
|
+
integrationStrategy: services.integrationStrategy,
|
|
1119
|
+
taskMode: services.taskMode,
|
|
1096
1120
|
});
|
|
1097
1121
|
|
|
1098
1122
|
try {
|
|
@@ -1134,6 +1158,49 @@ export function createMCPServer(
|
|
|
1134
1158
|
});
|
|
1135
1159
|
}
|
|
1136
1160
|
|
|
1161
|
+
// ─────────────────────────────────────────────────────────────────
|
|
1162
|
+
// Tools: claim_task, unclaim_task, list_claimable_tasks (pull model)
|
|
1163
|
+
// ─────────────────────────────────────────────────────────────────
|
|
1164
|
+
|
|
1165
|
+
if (services.taskBackend && shouldRegisterTool("claim_task")) {
|
|
1166
|
+
server.registerTool(CLAIM_TASK_TOOL_INFO.name, {
|
|
1167
|
+
description: CLAIM_TASK_TOOL_INFO.description,
|
|
1168
|
+
inputSchema: ClaimTaskSchema,
|
|
1169
|
+
}, async (args) => {
|
|
1170
|
+
const handler = createClaimTaskHandler(context, {
|
|
1171
|
+
taskBackend: services.taskBackend!,
|
|
1172
|
+
});
|
|
1173
|
+
const result = await handler(args as { tags?: string[]; root_tasks_only?: boolean });
|
|
1174
|
+
return { content: [{ type: "text" as const, text: JSON.stringify(result) }] };
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
if (services.taskBackend && shouldRegisterTool("unclaim_task")) {
|
|
1179
|
+
server.registerTool(UNCLAIM_TASK_TOOL_INFO.name, {
|
|
1180
|
+
description: UNCLAIM_TASK_TOOL_INFO.description,
|
|
1181
|
+
inputSchema: UnclaimTaskSchema,
|
|
1182
|
+
}, async (args) => {
|
|
1183
|
+
const handler = createUnclaimTaskHandler(context, {
|
|
1184
|
+
taskBackend: services.taskBackend!,
|
|
1185
|
+
});
|
|
1186
|
+
const result = await handler(args as { task_id: string });
|
|
1187
|
+
return { content: [{ type: "text" as const, text: JSON.stringify(result) }] };
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
if (services.taskBackend && shouldRegisterTool("list_claimable_tasks")) {
|
|
1192
|
+
server.registerTool(LIST_CLAIMABLE_TASKS_TOOL_INFO.name, {
|
|
1193
|
+
description: LIST_CLAIMABLE_TASKS_TOOL_INFO.description,
|
|
1194
|
+
inputSchema: ListClaimableTasksSchema,
|
|
1195
|
+
}, async (args) => {
|
|
1196
|
+
const handler = createListClaimableTasksHandler(context, {
|
|
1197
|
+
taskBackend: services.taskBackend!,
|
|
1198
|
+
});
|
|
1199
|
+
const result = await handler(args as { tags?: string[]; root_tasks_only?: boolean; limit?: number });
|
|
1200
|
+
return { content: [{ type: "text" as const, text: JSON.stringify(result) }] };
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1137
1204
|
// ─────────────────────────────────────────────────────────────────
|
|
1138
1205
|
// Tool: inject_context (always allowed - parent-to-child communication)
|
|
1139
1206
|
// ─────────────────────────────────────────────────────────────────
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* claim_task() MCP Tool
|
|
3
|
+
*
|
|
4
|
+
* Allows agents with `task.claim` capability to claim the next available task.
|
|
5
|
+
* Used in the pull model where agents autonomously pick up work.
|
|
6
|
+
*
|
|
7
|
+
* @module mcp/tools/claim_task
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import type { TaskBackend, ClaimFilter, ExtendedTask } from "../../task/backend/types.js";
|
|
12
|
+
import type { ToolContext } from "../types.js";
|
|
13
|
+
|
|
14
|
+
// =============================================================================
|
|
15
|
+
// Schema
|
|
16
|
+
// =============================================================================
|
|
17
|
+
|
|
18
|
+
export const ClaimTaskSchema = {
|
|
19
|
+
tags: z
|
|
20
|
+
.array(z.string())
|
|
21
|
+
.optional()
|
|
22
|
+
.describe("Only claim tasks with at least one matching tag"),
|
|
23
|
+
root_tasks_only: z
|
|
24
|
+
.boolean()
|
|
25
|
+
.optional()
|
|
26
|
+
.describe("Only claim root tasks (no parent)"),
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// =============================================================================
|
|
30
|
+
// Handler
|
|
31
|
+
// =============================================================================
|
|
32
|
+
|
|
33
|
+
export interface ClaimTaskDeps {
|
|
34
|
+
taskBackend: TaskBackend;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function createClaimTaskHandler(
|
|
38
|
+
context: ToolContext,
|
|
39
|
+
deps: ClaimTaskDeps
|
|
40
|
+
) {
|
|
41
|
+
return async (args: {
|
|
42
|
+
tags?: string[];
|
|
43
|
+
root_tasks_only?: boolean;
|
|
44
|
+
}): Promise<{
|
|
45
|
+
claimed: boolean;
|
|
46
|
+
task?: ExtendedTask;
|
|
47
|
+
message: string;
|
|
48
|
+
}> => {
|
|
49
|
+
if (!deps.taskBackend.claim) {
|
|
50
|
+
return {
|
|
51
|
+
claimed: false,
|
|
52
|
+
message: "Task backend does not support claim operations",
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const filter: ClaimFilter = {};
|
|
57
|
+
if (args.tags) filter.tags = args.tags;
|
|
58
|
+
if (args.root_tasks_only) filter.rootTasksOnly = args.root_tasks_only;
|
|
59
|
+
|
|
60
|
+
const task = await deps.taskBackend.claim(context.agent_id, filter);
|
|
61
|
+
|
|
62
|
+
if (!task) {
|
|
63
|
+
return {
|
|
64
|
+
claimed: false,
|
|
65
|
+
message: "No claimable tasks available",
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
claimed: true,
|
|
71
|
+
task,
|
|
72
|
+
message: `Claimed task ${task.id}: ${task.description}`,
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// =============================================================================
|
|
78
|
+
// Tool Info
|
|
79
|
+
// =============================================================================
|
|
80
|
+
|
|
81
|
+
export const CLAIM_TASK_TOOL_INFO = {
|
|
82
|
+
name: "claim_task",
|
|
83
|
+
description:
|
|
84
|
+
"Claim the next available task from the task pool. Returns the claimed task or null if none available. Requires task.claim capability.",
|
|
85
|
+
schema: ClaimTaskSchema,
|
|
86
|
+
};
|