@josstei/maestro 1.6.4-rc.1
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/.agents/plugins/marketplace.json +20 -0
- package/CHANGELOG.md +485 -0
- package/EXAMPLES.md +255 -0
- package/GEMINI.md +231 -0
- package/LICENSE +201 -0
- package/QWEN.md +241 -0
- package/README.md +220 -0
- package/agents/accessibility_specialist.md +20 -0
- package/agents/analytics_engineer.md +22 -0
- package/agents/api_designer.md +19 -0
- package/agents/architect.md +19 -0
- package/agents/cloud_architect.md +19 -0
- package/agents/cobol_engineer.md +22 -0
- package/agents/code_reviewer.md +17 -0
- package/agents/coder.md +22 -0
- package/agents/compliance_reviewer.md +19 -0
- package/agents/content_strategist.md +19 -0
- package/agents/copywriter.md +19 -0
- package/agents/data_engineer.md +22 -0
- package/agents/database_administrator.md +21 -0
- package/agents/db2_dba.md +21 -0
- package/agents/debugger.md +19 -0
- package/agents/design_system_engineer.md +22 -0
- package/agents/devops_engineer.md +23 -0
- package/agents/hlasm_assembler_specialist.md +22 -0
- package/agents/i18n_specialist.md +21 -0
- package/agents/ibm_i_specialist.md +22 -0
- package/agents/integration_engineer.md +23 -0
- package/agents/ml_engineer.md +23 -0
- package/agents/mlops_engineer.md +23 -0
- package/agents/mobile_engineer.md +23 -0
- package/agents/observability_engineer.md +23 -0
- package/agents/performance_engineer.md +21 -0
- package/agents/platform_engineer.md +24 -0
- package/agents/product_manager.md +20 -0
- package/agents/prompt_engineer.md +22 -0
- package/agents/refactor.md +22 -0
- package/agents/release_manager.md +22 -0
- package/agents/security_engineer.md +21 -0
- package/agents/seo_specialist.md +21 -0
- package/agents/site_reliability_engineer.md +21 -0
- package/agents/solutions_architect.md +19 -0
- package/agents/technical_writer.md +21 -0
- package/agents/tester.md +23 -0
- package/agents/ux_designer.md +20 -0
- package/agents/zos_sysprog.md +21 -0
- package/bin/maestro-mcp-server.js +10 -0
- package/claude/.claude-plugin/plugin.json +21 -0
- package/claude/.mcp.json +11 -0
- package/claude/README.md +191 -0
- package/claude/agents/accessibility-specialist.md +36 -0
- package/claude/agents/analytics-engineer.md +38 -0
- package/claude/agents/api-designer.md +33 -0
- package/claude/agents/architect.md +33 -0
- package/claude/agents/cloud-architect.md +33 -0
- package/claude/agents/cobol-engineer.md +38 -0
- package/claude/agents/code-reviewer.md +31 -0
- package/claude/agents/coder.md +38 -0
- package/claude/agents/compliance-reviewer.md +33 -0
- package/claude/agents/content-strategist.md +33 -0
- package/claude/agents/copywriter.md +33 -0
- package/claude/agents/data-engineer.md +37 -0
- package/claude/agents/database-administrator.md +37 -0
- package/claude/agents/db2-dba.md +37 -0
- package/claude/agents/debugger.md +32 -0
- package/claude/agents/design-system-engineer.md +38 -0
- package/claude/agents/devops-engineer.md +39 -0
- package/claude/agents/hlasm-assembler-specialist.md +38 -0
- package/claude/agents/i18n-specialist.md +37 -0
- package/claude/agents/ibm-i-specialist.md +38 -0
- package/claude/agents/integration-engineer.md +39 -0
- package/claude/agents/ml-engineer.md +39 -0
- package/claude/agents/mlops-engineer.md +39 -0
- package/claude/agents/mobile-engineer.md +39 -0
- package/claude/agents/observability-engineer.md +39 -0
- package/claude/agents/performance-engineer.md +34 -0
- package/claude/agents/platform-engineer.md +40 -0
- package/claude/agents/product-manager.md +34 -0
- package/claude/agents/prompt-engineer.md +38 -0
- package/claude/agents/refactor.md +38 -0
- package/claude/agents/release-manager.md +38 -0
- package/claude/agents/security-engineer.md +37 -0
- package/claude/agents/seo-specialist.md +37 -0
- package/claude/agents/site-reliability-engineer.md +37 -0
- package/claude/agents/solutions-architect.md +33 -0
- package/claude/agents/technical-writer.md +37 -0
- package/claude/agents/tester.md +39 -0
- package/claude/agents/ux-designer.md +34 -0
- package/claude/agents/zos-sysprog.md +37 -0
- package/claude/hooks/claude-hooks.json +48 -0
- package/claude/mcp/maestro-server.js +9 -0
- package/claude/mcp-config.example.json +9 -0
- package/claude/scripts/adapters/claude-adapter.js +7 -0
- package/claude/scripts/hook-runner.js +8 -0
- package/claude/scripts/policy-enforcer.js +294 -0
- package/claude/skills/a11y-audit/SKILL.md +26 -0
- package/claude/skills/archive/SKILL.md +24 -0
- package/claude/skills/code-review/SKILL.md +7 -0
- package/claude/skills/compliance-check/SKILL.md +26 -0
- package/claude/skills/debug-workflow/SKILL.md +27 -0
- package/claude/skills/delegation/SKILL.md +7 -0
- package/claude/skills/design-dialogue/SKILL.md +7 -0
- package/claude/skills/execute/SKILL.md +38 -0
- package/claude/skills/execution/SKILL.md +7 -0
- package/claude/skills/implementation-planning/SKILL.md +7 -0
- package/claude/skills/orchestrate/SKILL.md +38 -0
- package/claude/skills/perf-check/SKILL.md +26 -0
- package/claude/skills/resume-session/SKILL.md +38 -0
- package/claude/skills/review-code/SKILL.md +27 -0
- package/claude/skills/security-audit/SKILL.md +28 -0
- package/claude/skills/seo-audit/SKILL.md +26 -0
- package/claude/skills/session-management/SKILL.md +7 -0
- package/claude/skills/status/SKILL.md +22 -0
- package/claude/skills/validation/SKILL.md +7 -0
- package/claude/src/agents/accessibility-specialist.md +163 -0
- package/claude/src/agents/analytics-engineer.md +182 -0
- package/claude/src/agents/api-designer.md +124 -0
- package/claude/src/agents/architect.md +120 -0
- package/claude/src/agents/cloud-architect.md +134 -0
- package/claude/src/agents/cobol-engineer.md +127 -0
- package/claude/src/agents/code-reviewer.md +123 -0
- package/claude/src/agents/coder.md +132 -0
- package/claude/src/agents/compliance-reviewer.md +219 -0
- package/claude/src/agents/content-strategist.md +111 -0
- package/claude/src/agents/copywriter.md +113 -0
- package/claude/src/agents/data-engineer.md +130 -0
- package/claude/src/agents/database-administrator.md +126 -0
- package/claude/src/agents/db2-dba.md +124 -0
- package/claude/src/agents/debugger.md +133 -0
- package/claude/src/agents/design-system-engineer.md +258 -0
- package/claude/src/agents/devops-engineer.md +138 -0
- package/claude/src/agents/hlasm-assembler-specialist.md +134 -0
- package/claude/src/agents/i18n-specialist.md +241 -0
- package/claude/src/agents/ibm-i-specialist.md +132 -0
- package/claude/src/agents/integration-engineer.md +133 -0
- package/claude/src/agents/ml-engineer.md +115 -0
- package/claude/src/agents/mlops-engineer.md +116 -0
- package/claude/src/agents/mobile-engineer.md +115 -0
- package/claude/src/agents/observability-engineer.md +133 -0
- package/claude/src/agents/performance-engineer.md +139 -0
- package/claude/src/agents/platform-engineer.md +129 -0
- package/claude/src/agents/product-manager.md +170 -0
- package/claude/src/agents/prompt-engineer.md +129 -0
- package/claude/src/agents/refactor.md +138 -0
- package/claude/src/agents/release-manager.md +132 -0
- package/claude/src/agents/security-engineer.md +143 -0
- package/claude/src/agents/seo-specialist.md +129 -0
- package/claude/src/agents/site-reliability-engineer.md +131 -0
- package/claude/src/agents/solutions-architect.md +137 -0
- package/claude/src/agents/technical-writer.md +129 -0
- package/claude/src/agents/tester.md +135 -0
- package/claude/src/agents/ux-designer.md +168 -0
- package/claude/src/agents/zos-sysprog.md +134 -0
- package/claude/src/config/setting-resolver.js +32 -0
- package/claude/src/core/agent-registry.js +67 -0
- package/claude/src/core/canonical-source.js +39 -0
- package/claude/src/core/env-file-parser.js +82 -0
- package/claude/src/core/feature-blocks.js +34 -0
- package/claude/src/core/logger.js +12 -0
- package/claude/src/core/markdown-state.js +36 -0
- package/claude/src/core/policy-rules.js +32 -0
- package/claude/src/core/project-root-resolver.js +184 -0
- package/claude/src/core/stdin-reader.js +77 -0
- package/claude/src/core/version.js +50 -0
- package/claude/src/entry-points/core-command-registry.js +37 -0
- package/claude/src/entry-points/preamble-builders.js +54 -0
- package/claude/src/entry-points/registry.js +199 -0
- package/claude/src/entry-points/templates/claude-core-command.md.tmpl +38 -0
- package/claude/src/entry-points/templates/claude-skill.md.tmpl +18 -0
- package/claude/src/entry-points/templates/codex-core-command.md.tmpl +16 -0
- package/claude/src/entry-points/templates/codex-skill.md.tmpl +11 -0
- package/claude/src/entry-points/templates/gemini-command.toml.tmpl +17 -0
- package/claude/src/entry-points/templates/gemini-core-command.toml.tmpl +30 -0
- package/claude/src/generated/agent-registry.json +630 -0
- package/claude/src/generated/hook-registry.json +18 -0
- package/claude/src/generated/resource-registry.json +16 -0
- package/claude/src/hooks/logic/after-agent-logic.js +54 -0
- package/claude/src/hooks/logic/before-agent-logic.js +57 -0
- package/claude/src/hooks/logic/hook-state.js +127 -0
- package/claude/src/hooks/logic/session-end-logic.js +17 -0
- package/claude/src/hooks/logic/session-start-logic.js +25 -0
- package/claude/src/lib/discovery/index.js +172 -0
- package/claude/src/lib/errors/index.js +104 -0
- package/claude/src/lib/framework-detection.js +50 -0
- package/claude/src/lib/frontmatter/index.js +262 -0
- package/claude/src/lib/io/index.js +96 -0
- package/claude/src/lib/naming/index.js +94 -0
- package/claude/src/lib/validation/index.js +124 -0
- package/claude/src/lib/yaml-emit.js +38 -0
- package/claude/src/mcp/content/provider.js +68 -0
- package/claude/src/mcp/content/runtime-content.js +188 -0
- package/claude/src/mcp/contracts/cache-path-rejector.js +39 -0
- package/claude/src/mcp/contracts/downstream-context.js +106 -0
- package/claude/src/mcp/contracts/plan-schema.js +148 -0
- package/claude/src/mcp/contracts/workspace-marker.js +61 -0
- package/claude/src/mcp/core/create-server.js +76 -0
- package/claude/src/mcp/core/line-reader.js +35 -0
- package/claude/src/mcp/core/project-root-cache.js +120 -0
- package/claude/src/mcp/core/protocol-dispatcher.js +274 -0
- package/claude/src/mcp/core/recovery-hints.js +43 -0
- package/claude/src/mcp/core/tool-outcome.js +77 -0
- package/claude/src/mcp/core/tool-registry.js +82 -0
- package/claude/src/mcp/handlers/assess-task-complexity.js +108 -0
- package/claude/src/mcp/handlers/blocker-parser.js +34 -0
- package/claude/src/mcp/handlers/design-gate.js +393 -0
- package/claude/src/mcp/handlers/get-agent.js +54 -0
- package/claude/src/mcp/handlers/get-runtime-context.js +49 -0
- package/claude/src/mcp/handlers/get-skill-content.js +51 -0
- package/claude/src/mcp/handlers/initialize-workspace.js +45 -0
- package/claude/src/mcp/handlers/reconciliation.js +224 -0
- package/claude/src/mcp/handlers/resolve-settings.js +39 -0
- package/claude/src/mcp/handlers/session-state-core.js +108 -0
- package/claude/src/mcp/handlers/session-state-tools.js +562 -0
- package/claude/src/mcp/handlers/validate-plan.js +76 -0
- package/claude/src/mcp/maestro-server.js +122 -0
- package/claude/src/mcp/runtime/runtime-config-map.js +70 -0
- package/claude/src/mcp/tool-packs/content/index.js +80 -0
- package/claude/src/mcp/tool-packs/contracts.js +30 -0
- package/claude/src/mcp/tool-packs/index.js +15 -0
- package/claude/src/mcp/tool-packs/session/index.js +243 -0
- package/claude/src/mcp/tool-packs/workspace/index.js +98 -0
- package/claude/src/mcp/utils/extension-root.js +31 -0
- package/claude/src/mcp/validation/agent-checker.js +81 -0
- package/claude/src/mcp/validation/dag-checker.js +214 -0
- package/claude/src/mcp/validation/file-overlap-checker.js +63 -0
- package/claude/src/mcp/validation/schema-checker.js +108 -0
- package/claude/src/platforms/claude/runtime-config.js +60 -0
- package/claude/src/platforms/shared/adapters/claude-adapter.js +36 -0
- package/claude/src/platforms/shared/adapters/conventions.js +29 -0
- package/claude/src/platforms/shared/adapters/exit-codes.js +6 -0
- package/claude/src/platforms/shared/adapters/factory.js +40 -0
- package/claude/src/platforms/shared/agent-names.js +10 -0
- package/claude/src/platforms/shared/hook-runner.js +52 -0
- package/claude/src/references/architecture.md +139 -0
- package/claude/src/references/orchestration-steps.md +193 -0
- package/claude/src/skills/shared/code-review/SKILL.md +145 -0
- package/claude/src/skills/shared/delegation/SKILL.md +370 -0
- package/claude/src/skills/shared/delegation/protocols/agent-base-protocol.md +145 -0
- package/claude/src/skills/shared/delegation/protocols/filesystem-safety-protocol.md +31 -0
- package/claude/src/skills/shared/design-dialogue/SKILL.md +284 -0
- package/claude/src/skills/shared/execution/SKILL.md +258 -0
- package/claude/src/skills/shared/implementation-planning/SKILL.md +303 -0
- package/claude/src/skills/shared/session-management/SKILL.md +314 -0
- package/claude/src/skills/shared/validation/SKILL.md +204 -0
- package/claude/src/state/session-state.js +113 -0
- package/claude/src/templates/design-document.md +95 -0
- package/claude/src/templates/implementation-plan.md +86 -0
- package/claude/src/templates/session-state.md +68 -0
- package/claude/src/version.json +3 -0
- package/commands/maestro/a11y-audit.toml +22 -0
- package/commands/maestro/archive.toml +23 -0
- package/commands/maestro/compliance-check.toml +22 -0
- package/commands/maestro/debug.toml +23 -0
- package/commands/maestro/execute.toml +30 -0
- package/commands/maestro/orchestrate.toml +30 -0
- package/commands/maestro/perf-check.toml +22 -0
- package/commands/maestro/resume.toml +38 -0
- package/commands/maestro/review.toml +23 -0
- package/commands/maestro/security-audit.toml +24 -0
- package/commands/maestro/seo-audit.toml +22 -0
- package/commands/maestro/status.toml +21 -0
- package/docs/architecture.md +310 -0
- package/docs/cicd.md +647 -0
- package/docs/flow.md +255 -0
- package/docs/maestro-cheatsheet.md +199 -0
- package/docs/overview.md +141 -0
- package/docs/runtime-claude.md +190 -0
- package/docs/runtime-codex.md +197 -0
- package/docs/runtime-gemini.md +170 -0
- package/docs/runtime-qwen.md +147 -0
- package/docs/usage.md +312 -0
- package/gemini-extension.json +55 -0
- package/hooks/adapters/gemini-adapter.js +2 -0
- package/hooks/adapters/qwen-adapter.js +2 -0
- package/hooks/hook-runner.js +3 -0
- package/hooks/hooks.json +56 -0
- package/mcp/maestro-server.js +4 -0
- package/package.json +93 -0
- package/plugins/maestro/.app.json +3 -0
- package/plugins/maestro/.codex-plugin/plugin.json +41 -0
- package/plugins/maestro/.mcp.json +16 -0
- package/plugins/maestro/README.md +57 -0
- package/plugins/maestro/references/runtime-guide.md +125 -0
- package/plugins/maestro/skills/a11y-audit/SKILL.md +16 -0
- package/plugins/maestro/skills/archive/SKILL.md +16 -0
- package/plugins/maestro/skills/code-review/SKILL.md +6 -0
- package/plugins/maestro/skills/compliance-check/SKILL.md +16 -0
- package/plugins/maestro/skills/debug-workflow/SKILL.md +16 -0
- package/plugins/maestro/skills/delegation/SKILL.md +6 -0
- package/plugins/maestro/skills/design-dialogue/SKILL.md +6 -0
- package/plugins/maestro/skills/execute/SKILL.md +16 -0
- package/plugins/maestro/skills/execution/SKILL.md +6 -0
- package/plugins/maestro/skills/implementation-planning/SKILL.md +6 -0
- package/plugins/maestro/skills/orchestrate/SKILL.md +16 -0
- package/plugins/maestro/skills/perf-check/SKILL.md +16 -0
- package/plugins/maestro/skills/resume-session/SKILL.md +16 -0
- package/plugins/maestro/skills/review-code/SKILL.md +16 -0
- package/plugins/maestro/skills/security-audit/SKILL.md +16 -0
- package/plugins/maestro/skills/seo-audit/SKILL.md +16 -0
- package/plugins/maestro/skills/session-management/SKILL.md +6 -0
- package/plugins/maestro/skills/status/SKILL.md +14 -0
- package/plugins/maestro/skills/validation/SKILL.md +6 -0
- package/plugins/maestro/src/agents/accessibility-specialist.md +163 -0
- package/plugins/maestro/src/agents/analytics-engineer.md +182 -0
- package/plugins/maestro/src/agents/api-designer.md +124 -0
- package/plugins/maestro/src/agents/architect.md +120 -0
- package/plugins/maestro/src/agents/cloud-architect.md +134 -0
- package/plugins/maestro/src/agents/cobol-engineer.md +127 -0
- package/plugins/maestro/src/agents/code-reviewer.md +123 -0
- package/plugins/maestro/src/agents/coder.md +132 -0
- package/plugins/maestro/src/agents/compliance-reviewer.md +219 -0
- package/plugins/maestro/src/agents/content-strategist.md +111 -0
- package/plugins/maestro/src/agents/copywriter.md +113 -0
- package/plugins/maestro/src/agents/data-engineer.md +130 -0
- package/plugins/maestro/src/agents/database-administrator.md +126 -0
- package/plugins/maestro/src/agents/db2-dba.md +124 -0
- package/plugins/maestro/src/agents/debugger.md +133 -0
- package/plugins/maestro/src/agents/design-system-engineer.md +258 -0
- package/plugins/maestro/src/agents/devops-engineer.md +138 -0
- package/plugins/maestro/src/agents/hlasm-assembler-specialist.md +134 -0
- package/plugins/maestro/src/agents/i18n-specialist.md +241 -0
- package/plugins/maestro/src/agents/ibm-i-specialist.md +132 -0
- package/plugins/maestro/src/agents/integration-engineer.md +133 -0
- package/plugins/maestro/src/agents/ml-engineer.md +115 -0
- package/plugins/maestro/src/agents/mlops-engineer.md +116 -0
- package/plugins/maestro/src/agents/mobile-engineer.md +115 -0
- package/plugins/maestro/src/agents/observability-engineer.md +133 -0
- package/plugins/maestro/src/agents/performance-engineer.md +139 -0
- package/plugins/maestro/src/agents/platform-engineer.md +129 -0
- package/plugins/maestro/src/agents/product-manager.md +170 -0
- package/plugins/maestro/src/agents/prompt-engineer.md +129 -0
- package/plugins/maestro/src/agents/refactor.md +138 -0
- package/plugins/maestro/src/agents/release-manager.md +132 -0
- package/plugins/maestro/src/agents/security-engineer.md +143 -0
- package/plugins/maestro/src/agents/seo-specialist.md +129 -0
- package/plugins/maestro/src/agents/site-reliability-engineer.md +131 -0
- package/plugins/maestro/src/agents/solutions-architect.md +137 -0
- package/plugins/maestro/src/agents/technical-writer.md +129 -0
- package/plugins/maestro/src/agents/tester.md +135 -0
- package/plugins/maestro/src/agents/ux-designer.md +168 -0
- package/plugins/maestro/src/agents/zos-sysprog.md +134 -0
- package/plugins/maestro/src/config/setting-resolver.js +32 -0
- package/plugins/maestro/src/core/agent-registry.js +67 -0
- package/plugins/maestro/src/core/canonical-source.js +39 -0
- package/plugins/maestro/src/core/env-file-parser.js +82 -0
- package/plugins/maestro/src/core/feature-blocks.js +34 -0
- package/plugins/maestro/src/core/logger.js +12 -0
- package/plugins/maestro/src/core/markdown-state.js +36 -0
- package/plugins/maestro/src/core/policy-rules.js +32 -0
- package/plugins/maestro/src/core/project-root-resolver.js +184 -0
- package/plugins/maestro/src/core/stdin-reader.js +77 -0
- package/plugins/maestro/src/core/version.js +50 -0
- package/plugins/maestro/src/entry-points/core-command-registry.js +37 -0
- package/plugins/maestro/src/entry-points/preamble-builders.js +54 -0
- package/plugins/maestro/src/entry-points/registry.js +199 -0
- package/plugins/maestro/src/entry-points/templates/claude-core-command.md.tmpl +38 -0
- package/plugins/maestro/src/entry-points/templates/claude-skill.md.tmpl +18 -0
- package/plugins/maestro/src/entry-points/templates/codex-core-command.md.tmpl +16 -0
- package/plugins/maestro/src/entry-points/templates/codex-skill.md.tmpl +11 -0
- package/plugins/maestro/src/entry-points/templates/gemini-command.toml.tmpl +17 -0
- package/plugins/maestro/src/entry-points/templates/gemini-core-command.toml.tmpl +30 -0
- package/plugins/maestro/src/generated/agent-registry.json +630 -0
- package/plugins/maestro/src/generated/hook-registry.json +18 -0
- package/plugins/maestro/src/generated/resource-registry.json +16 -0
- package/plugins/maestro/src/hooks/logic/after-agent-logic.js +54 -0
- package/plugins/maestro/src/hooks/logic/before-agent-logic.js +57 -0
- package/plugins/maestro/src/hooks/logic/hook-state.js +127 -0
- package/plugins/maestro/src/hooks/logic/session-end-logic.js +17 -0
- package/plugins/maestro/src/hooks/logic/session-start-logic.js +25 -0
- package/plugins/maestro/src/lib/discovery/index.js +172 -0
- package/plugins/maestro/src/lib/errors/index.js +104 -0
- package/plugins/maestro/src/lib/framework-detection.js +50 -0
- package/plugins/maestro/src/lib/frontmatter/index.js +262 -0
- package/plugins/maestro/src/lib/io/index.js +96 -0
- package/plugins/maestro/src/lib/naming/index.js +94 -0
- package/plugins/maestro/src/lib/validation/index.js +124 -0
- package/plugins/maestro/src/lib/yaml-emit.js +38 -0
- package/plugins/maestro/src/mcp/content/provider.js +68 -0
- package/plugins/maestro/src/mcp/content/runtime-content.js +188 -0
- package/plugins/maestro/src/mcp/contracts/cache-path-rejector.js +39 -0
- package/plugins/maestro/src/mcp/contracts/downstream-context.js +106 -0
- package/plugins/maestro/src/mcp/contracts/plan-schema.js +148 -0
- package/plugins/maestro/src/mcp/contracts/workspace-marker.js +61 -0
- package/plugins/maestro/src/mcp/core/create-server.js +76 -0
- package/plugins/maestro/src/mcp/core/line-reader.js +35 -0
- package/plugins/maestro/src/mcp/core/project-root-cache.js +120 -0
- package/plugins/maestro/src/mcp/core/protocol-dispatcher.js +274 -0
- package/plugins/maestro/src/mcp/core/recovery-hints.js +43 -0
- package/plugins/maestro/src/mcp/core/tool-outcome.js +77 -0
- package/plugins/maestro/src/mcp/core/tool-registry.js +82 -0
- package/plugins/maestro/src/mcp/handlers/assess-task-complexity.js +108 -0
- package/plugins/maestro/src/mcp/handlers/blocker-parser.js +34 -0
- package/plugins/maestro/src/mcp/handlers/design-gate.js +393 -0
- package/plugins/maestro/src/mcp/handlers/get-agent.js +54 -0
- package/plugins/maestro/src/mcp/handlers/get-runtime-context.js +49 -0
- package/plugins/maestro/src/mcp/handlers/get-skill-content.js +51 -0
- package/plugins/maestro/src/mcp/handlers/initialize-workspace.js +45 -0
- package/plugins/maestro/src/mcp/handlers/reconciliation.js +224 -0
- package/plugins/maestro/src/mcp/handlers/resolve-settings.js +39 -0
- package/plugins/maestro/src/mcp/handlers/session-state-core.js +108 -0
- package/plugins/maestro/src/mcp/handlers/session-state-tools.js +562 -0
- package/plugins/maestro/src/mcp/handlers/validate-plan.js +76 -0
- package/plugins/maestro/src/mcp/maestro-server.js +122 -0
- package/plugins/maestro/src/mcp/runtime/runtime-config-map.js +70 -0
- package/plugins/maestro/src/mcp/tool-packs/content/index.js +80 -0
- package/plugins/maestro/src/mcp/tool-packs/contracts.js +30 -0
- package/plugins/maestro/src/mcp/tool-packs/index.js +15 -0
- package/plugins/maestro/src/mcp/tool-packs/session/index.js +243 -0
- package/plugins/maestro/src/mcp/tool-packs/workspace/index.js +98 -0
- package/plugins/maestro/src/mcp/utils/extension-root.js +31 -0
- package/plugins/maestro/src/mcp/validation/agent-checker.js +81 -0
- package/plugins/maestro/src/mcp/validation/dag-checker.js +214 -0
- package/plugins/maestro/src/mcp/validation/file-overlap-checker.js +63 -0
- package/plugins/maestro/src/mcp/validation/schema-checker.js +108 -0
- package/plugins/maestro/src/platforms/codex/runtime-config.js +58 -0
- package/plugins/maestro/src/platforms/shared/adapters/conventions.js +29 -0
- package/plugins/maestro/src/platforms/shared/adapters/exit-codes.js +6 -0
- package/plugins/maestro/src/platforms/shared/adapters/factory.js +40 -0
- package/plugins/maestro/src/platforms/shared/agent-names.js +10 -0
- package/plugins/maestro/src/platforms/shared/hook-runner.js +52 -0
- package/plugins/maestro/src/references/architecture.md +139 -0
- package/plugins/maestro/src/references/orchestration-steps.md +193 -0
- package/plugins/maestro/src/skills/shared/code-review/SKILL.md +145 -0
- package/plugins/maestro/src/skills/shared/delegation/SKILL.md +370 -0
- package/plugins/maestro/src/skills/shared/delegation/protocols/agent-base-protocol.md +145 -0
- package/plugins/maestro/src/skills/shared/delegation/protocols/filesystem-safety-protocol.md +31 -0
- package/plugins/maestro/src/skills/shared/design-dialogue/SKILL.md +284 -0
- package/plugins/maestro/src/skills/shared/execution/SKILL.md +258 -0
- package/plugins/maestro/src/skills/shared/implementation-planning/SKILL.md +303 -0
- package/plugins/maestro/src/skills/shared/session-management/SKILL.md +314 -0
- package/plugins/maestro/src/skills/shared/validation/SKILL.md +204 -0
- package/plugins/maestro/src/state/session-state.js +113 -0
- package/plugins/maestro/src/templates/design-document.md +95 -0
- package/plugins/maestro/src/templates/implementation-plan.md +86 -0
- package/plugins/maestro/src/templates/session-state.md +68 -0
- package/plugins/maestro/src/version.json +3 -0
- package/policies/maestro.toml +44 -0
- package/qwen/agents/accessibility_specialist.md +18 -0
- package/qwen/agents/analytics_engineer.md +20 -0
- package/qwen/agents/api_designer.md +17 -0
- package/qwen/agents/architect.md +17 -0
- package/qwen/agents/cloud_architect.md +17 -0
- package/qwen/agents/cobol_engineer.md +20 -0
- package/qwen/agents/code_reviewer.md +15 -0
- package/qwen/agents/coder.md +20 -0
- package/qwen/agents/compliance_reviewer.md +17 -0
- package/qwen/agents/content_strategist.md +17 -0
- package/qwen/agents/copywriter.md +17 -0
- package/qwen/agents/data_engineer.md +20 -0
- package/qwen/agents/database_administrator.md +19 -0
- package/qwen/agents/db2_dba.md +19 -0
- package/qwen/agents/debugger.md +17 -0
- package/qwen/agents/design_system_engineer.md +20 -0
- package/qwen/agents/devops_engineer.md +21 -0
- package/qwen/agents/hlasm_assembler_specialist.md +20 -0
- package/qwen/agents/i18n_specialist.md +19 -0
- package/qwen/agents/ibm_i_specialist.md +20 -0
- package/qwen/agents/integration_engineer.md +21 -0
- package/qwen/agents/ml_engineer.md +21 -0
- package/qwen/agents/mlops_engineer.md +21 -0
- package/qwen/agents/mobile_engineer.md +21 -0
- package/qwen/agents/observability_engineer.md +21 -0
- package/qwen/agents/performance_engineer.md +19 -0
- package/qwen/agents/platform_engineer.md +22 -0
- package/qwen/agents/product_manager.md +18 -0
- package/qwen/agents/prompt_engineer.md +20 -0
- package/qwen/agents/refactor.md +20 -0
- package/qwen/agents/release_manager.md +20 -0
- package/qwen/agents/security_engineer.md +19 -0
- package/qwen/agents/seo_specialist.md +19 -0
- package/qwen/agents/site_reliability_engineer.md +19 -0
- package/qwen/agents/solutions_architect.md +17 -0
- package/qwen/agents/technical_writer.md +19 -0
- package/qwen/agents/tester.md +21 -0
- package/qwen/agents/ux_designer.md +18 -0
- package/qwen/agents/zos_sysprog.md +19 -0
- package/qwen/hooks.json +56 -0
- package/qwen-extension.json +55 -0
- package/scripts/check-layer-boundaries.js +74 -0
- package/scripts/generate.js +155 -0
- package/scripts/install-codex-plugin.js +167 -0
- package/scripts/install-git-hooks.js +43 -0
- package/scripts/npm-publish-idempotent.js +150 -0
- package/scripts/package-release-artifacts.js +156 -0
- package/scripts/release-artifact-manifest.js +378 -0
- package/scripts/release-version-metadata.js +129 -0
- package/scripts/update-versions.js +33 -0
- package/scripts/verify-npm-pack.js +85 -0
- package/scripts/verify-release-artifacts.js +95 -0
- package/src/agents/accessibility-specialist.md +163 -0
- package/src/agents/analytics-engineer.md +182 -0
- package/src/agents/api-designer.md +124 -0
- package/src/agents/architect.md +120 -0
- package/src/agents/cloud-architect.md +134 -0
- package/src/agents/cobol-engineer.md +127 -0
- package/src/agents/code-reviewer.md +123 -0
- package/src/agents/coder.md +132 -0
- package/src/agents/compliance-reviewer.md +219 -0
- package/src/agents/content-strategist.md +111 -0
- package/src/agents/copywriter.md +113 -0
- package/src/agents/data-engineer.md +130 -0
- package/src/agents/database-administrator.md +126 -0
- package/src/agents/db2-dba.md +124 -0
- package/src/agents/debugger.md +133 -0
- package/src/agents/design-system-engineer.md +258 -0
- package/src/agents/devops-engineer.md +138 -0
- package/src/agents/hlasm-assembler-specialist.md +134 -0
- package/src/agents/i18n-specialist.md +241 -0
- package/src/agents/ibm-i-specialist.md +132 -0
- package/src/agents/integration-engineer.md +133 -0
- package/src/agents/ml-engineer.md +115 -0
- package/src/agents/mlops-engineer.md +116 -0
- package/src/agents/mobile-engineer.md +115 -0
- package/src/agents/observability-engineer.md +133 -0
- package/src/agents/performance-engineer.md +139 -0
- package/src/agents/platform-engineer.md +129 -0
- package/src/agents/product-manager.md +170 -0
- package/src/agents/prompt-engineer.md +129 -0
- package/src/agents/refactor.md +138 -0
- package/src/agents/release-manager.md +132 -0
- package/src/agents/security-engineer.md +143 -0
- package/src/agents/seo-specialist.md +129 -0
- package/src/agents/site-reliability-engineer.md +131 -0
- package/src/agents/solutions-architect.md +137 -0
- package/src/agents/technical-writer.md +129 -0
- package/src/agents/tester.md +135 -0
- package/src/agents/ux-designer.md +168 -0
- package/src/agents/zos-sysprog.md +134 -0
- package/src/config/setting-resolver.js +32 -0
- package/src/core/agent-registry.js +67 -0
- package/src/core/canonical-source.js +39 -0
- package/src/core/env-file-parser.js +82 -0
- package/src/core/feature-blocks.js +34 -0
- package/src/core/logger.js +12 -0
- package/src/core/markdown-state.js +36 -0
- package/src/core/policy-rules.js +32 -0
- package/src/core/project-root-resolver.js +184 -0
- package/src/core/stdin-reader.js +77 -0
- package/src/core/version.js +50 -0
- package/src/entry-points/core-command-registry.js +37 -0
- package/src/entry-points/preamble-builders.js +54 -0
- package/src/entry-points/registry.js +199 -0
- package/src/entry-points/templates/claude-core-command.md.tmpl +38 -0
- package/src/entry-points/templates/claude-skill.md.tmpl +18 -0
- package/src/entry-points/templates/codex-core-command.md.tmpl +16 -0
- package/src/entry-points/templates/codex-skill.md.tmpl +11 -0
- package/src/entry-points/templates/gemini-command.toml.tmpl +17 -0
- package/src/entry-points/templates/gemini-core-command.toml.tmpl +30 -0
- package/src/generated/agent-registry.json +630 -0
- package/src/generated/hook-registry.json +18 -0
- package/src/generated/resource-registry.json +16 -0
- package/src/generator/entry-point-expander.js +182 -0
- package/src/generator/file-writer.js +167 -0
- package/src/generator/generation-session.js +62 -0
- package/src/generator/manifest-curator.js +31 -0
- package/src/generator/manifest-expander.js +256 -0
- package/src/generator/payload-builder.js +217 -0
- package/src/generator/registry-scanner.js +130 -0
- package/src/generator/stale-pruner.js +101 -0
- package/src/hooks/logic/after-agent-logic.js +54 -0
- package/src/hooks/logic/before-agent-logic.js +57 -0
- package/src/hooks/logic/hook-state.js +127 -0
- package/src/hooks/logic/session-end-logic.js +17 -0
- package/src/hooks/logic/session-start-logic.js +25 -0
- package/src/lib/discovery/index.js +172 -0
- package/src/lib/errors/index.js +104 -0
- package/src/lib/framework-detection.js +50 -0
- package/src/lib/frontmatter/index.js +262 -0
- package/src/lib/io/index.js +96 -0
- package/src/lib/naming/index.js +94 -0
- package/src/lib/validation/index.js +124 -0
- package/src/lib/yaml-emit.js +38 -0
- package/src/manifest.js +11 -0
- package/src/mcp/content/provider.js +68 -0
- package/src/mcp/content/runtime-content.js +188 -0
- package/src/mcp/contracts/cache-path-rejector.js +39 -0
- package/src/mcp/contracts/downstream-context.js +106 -0
- package/src/mcp/contracts/plan-schema.js +148 -0
- package/src/mcp/contracts/workspace-marker.js +61 -0
- package/src/mcp/core/create-server.js +76 -0
- package/src/mcp/core/line-reader.js +35 -0
- package/src/mcp/core/project-root-cache.js +120 -0
- package/src/mcp/core/protocol-dispatcher.js +274 -0
- package/src/mcp/core/recovery-hints.js +43 -0
- package/src/mcp/core/tool-outcome.js +77 -0
- package/src/mcp/core/tool-registry.js +82 -0
- package/src/mcp/handlers/assess-task-complexity.js +108 -0
- package/src/mcp/handlers/blocker-parser.js +34 -0
- package/src/mcp/handlers/design-gate.js +393 -0
- package/src/mcp/handlers/get-agent.js +54 -0
- package/src/mcp/handlers/get-runtime-context.js +49 -0
- package/src/mcp/handlers/get-skill-content.js +51 -0
- package/src/mcp/handlers/initialize-workspace.js +45 -0
- package/src/mcp/handlers/reconciliation.js +224 -0
- package/src/mcp/handlers/resolve-settings.js +39 -0
- package/src/mcp/handlers/session-state-core.js +108 -0
- package/src/mcp/handlers/session-state-tools.js +562 -0
- package/src/mcp/handlers/validate-plan.js +76 -0
- package/src/mcp/maestro-server.js +122 -0
- package/src/mcp/runtime/runtime-config-map.js +70 -0
- package/src/mcp/tool-packs/content/index.js +80 -0
- package/src/mcp/tool-packs/contracts.js +30 -0
- package/src/mcp/tool-packs/index.js +15 -0
- package/src/mcp/tool-packs/session/index.js +243 -0
- package/src/mcp/tool-packs/workspace/index.js +98 -0
- package/src/mcp/utils/extension-root.js +31 -0
- package/src/mcp/validation/agent-checker.js +81 -0
- package/src/mcp/validation/dag-checker.js +214 -0
- package/src/mcp/validation/file-overlap-checker.js +63 -0
- package/src/mcp/validation/schema-checker.js +108 -0
- package/src/platforms/claude/metadata.js +96 -0
- package/src/platforms/claude/runtime-config.js +60 -0
- package/src/platforms/codex/metadata.js +107 -0
- package/src/platforms/codex/runtime-config.js +58 -0
- package/src/platforms/gemini/metadata.js +27 -0
- package/src/platforms/gemini/runtime-config.js +62 -0
- package/src/platforms/metadata-shared.js +131 -0
- package/src/platforms/metadata.js +29 -0
- package/src/platforms/qwen/metadata.js +27 -0
- package/src/platforms/qwen/runtime-config.js +62 -0
- package/src/platforms/shared/adapters/claude-adapter.js +36 -0
- package/src/platforms/shared/adapters/conventions.js +29 -0
- package/src/platforms/shared/adapters/exit-codes.js +6 -0
- package/src/platforms/shared/adapters/factory.js +40 -0
- package/src/platforms/shared/adapters/gemini-adapter.js +34 -0
- package/src/platforms/shared/adapters/qwen-adapter.js +93 -0
- package/src/platforms/shared/agent-names.js +10 -0
- package/src/platforms/shared/hook-runner.js +52 -0
- package/src/references/architecture.md +139 -0
- package/src/references/orchestration-steps.md +193 -0
- package/src/scripts/ensure-workspace.js +14 -0
- package/src/scripts/read-active-session.js +26 -0
- package/src/scripts/read-setting.js +18 -0
- package/src/scripts/read-state.js +17 -0
- package/src/scripts/write-state.js +22 -0
- package/src/skills/shared/code-review/SKILL.md +145 -0
- package/src/skills/shared/delegation/SKILL.md +370 -0
- package/src/skills/shared/delegation/protocols/agent-base-protocol.md +145 -0
- package/src/skills/shared/delegation/protocols/filesystem-safety-protocol.md +31 -0
- package/src/skills/shared/design-dialogue/SKILL.md +284 -0
- package/src/skills/shared/execution/SKILL.md +258 -0
- package/src/skills/shared/implementation-planning/SKILL.md +303 -0
- package/src/skills/shared/session-management/SKILL.md +314 -0
- package/src/skills/shared/validation/SKILL.md +204 -0
- package/src/state/session-state.js +113 -0
- package/src/templates/design-document.md +95 -0
- package/src/templates/implementation-plan.md +86 -0
- package/src/templates/session-state.md +68 -0
- package/src/transforms/agent-stub.js +29 -0
- package/src/transforms/extract-examples.js +63 -0
- package/src/transforms/index.js +35 -0
- package/src/transforms/parse-frontmatter.js +23 -0
- package/src/transforms/rebuild-frontmatter.js +147 -0
- package/src/transforms/skill-discovery-stub.js +27 -0
- package/src/transforms/skill-metadata.js +14 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const PHASE_REQUIRED_FIELDS = ['id', 'name', 'agent', 'parallel', 'blocked_by'];
|
|
4
|
+
|
|
5
|
+
const PHASE_ID_SCHEMA = {
|
|
6
|
+
oneOf: [
|
|
7
|
+
{ type: 'integer', minimum: 1 },
|
|
8
|
+
{ type: 'string', minLength: 1 },
|
|
9
|
+
],
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const PHASE_ITEM_SCHEMA = {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
id: PHASE_ID_SCHEMA,
|
|
16
|
+
name: { type: 'string', minLength: 1 },
|
|
17
|
+
agent: { type: 'string', minLength: 1 },
|
|
18
|
+
parallel: { type: 'boolean' },
|
|
19
|
+
blocked_by: { type: 'array', items: PHASE_ID_SCHEMA },
|
|
20
|
+
files: { type: 'array', items: { type: 'string', minLength: 1 } },
|
|
21
|
+
},
|
|
22
|
+
required: PHASE_REQUIRED_FIELDS,
|
|
23
|
+
additionalProperties: true,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function isNonEmptyString(value) {
|
|
27
|
+
return typeof value === 'string' && value.length > 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function isValidPhaseId(value) {
|
|
31
|
+
if (typeof value === 'string') return value.length > 0;
|
|
32
|
+
return Number.isInteger(value) && value >= 1;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function isValidBlockerId(value) {
|
|
36
|
+
if (typeof value === 'string') return value.length > 0;
|
|
37
|
+
return Number.isInteger(value) && value >= 1;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Validate an array of plan-phase objects against the shared phase schema.
|
|
42
|
+
*
|
|
43
|
+
* Required fields per phase: id, name, agent, parallel, blocked_by.
|
|
44
|
+
*
|
|
45
|
+
* Optional field: `files` — the planning-time file manifest. When supplied,
|
|
46
|
+
* T9 `create_session` maps it to the session state's `planned_files` field
|
|
47
|
+
* for later reconciliation. The runtime-populated manifests
|
|
48
|
+
* (`files_created`, `files_modified`, `files_deleted`) are NOT plan inputs;
|
|
49
|
+
* they are set by `transition_phase` after an agent completes, and they
|
|
50
|
+
* pass through this schema via `additionalProperties: true` without
|
|
51
|
+
* validation. Plan authors should populate `files`, not the runtime fields.
|
|
52
|
+
*
|
|
53
|
+
* @param {unknown} phases - Input value expected to be an array of phase objects.
|
|
54
|
+
* @returns {{ valid: boolean, violations: Array<object> }}
|
|
55
|
+
*/
|
|
56
|
+
function validatePhases(phases) {
|
|
57
|
+
const violations = [];
|
|
58
|
+
if (!Array.isArray(phases)) {
|
|
59
|
+
return {
|
|
60
|
+
valid: false,
|
|
61
|
+
violations: [
|
|
62
|
+
{ rule: 'invalid_phases', detail: 'phases must be an array', severity: 'error' },
|
|
63
|
+
],
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
for (const phase of phases) {
|
|
68
|
+
const phaseId = phase && phase.id;
|
|
69
|
+
for (const field of PHASE_REQUIRED_FIELDS) {
|
|
70
|
+
if (!phase || !Object.prototype.hasOwnProperty.call(phase, field)) {
|
|
71
|
+
violations.push({
|
|
72
|
+
rule: 'missing_required_field',
|
|
73
|
+
phase_id: phaseId ?? null,
|
|
74
|
+
field,
|
|
75
|
+
severity: 'error',
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (!phase) continue;
|
|
81
|
+
|
|
82
|
+
if ('id' in phase && !isValidPhaseId(phase.id)) {
|
|
83
|
+
violations.push({
|
|
84
|
+
rule: 'invalid_field_type',
|
|
85
|
+
phase_id: phaseId ?? null,
|
|
86
|
+
field: 'id',
|
|
87
|
+
severity: 'error',
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
if ('name' in phase && !isNonEmptyString(phase.name)) {
|
|
91
|
+
violations.push({
|
|
92
|
+
rule: 'invalid_field_type',
|
|
93
|
+
phase_id: phaseId ?? null,
|
|
94
|
+
field: 'name',
|
|
95
|
+
severity: 'error',
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if ('agent' in phase && !isNonEmptyString(phase.agent)) {
|
|
99
|
+
violations.push({
|
|
100
|
+
rule: 'invalid_field_type',
|
|
101
|
+
phase_id: phaseId ?? null,
|
|
102
|
+
field: 'agent',
|
|
103
|
+
severity: 'error',
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
if ('parallel' in phase && typeof phase.parallel !== 'boolean') {
|
|
107
|
+
violations.push({
|
|
108
|
+
rule: 'invalid_field_type',
|
|
109
|
+
phase_id: phaseId ?? null,
|
|
110
|
+
field: 'parallel',
|
|
111
|
+
severity: 'error',
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
if ('blocked_by' in phase) {
|
|
115
|
+
if (
|
|
116
|
+
!Array.isArray(phase.blocked_by) ||
|
|
117
|
+
!phase.blocked_by.every(isValidBlockerId)
|
|
118
|
+
) {
|
|
119
|
+
violations.push({
|
|
120
|
+
rule: 'invalid_field_type',
|
|
121
|
+
phase_id: phaseId ?? null,
|
|
122
|
+
field: 'blocked_by',
|
|
123
|
+
severity: 'error',
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if ('files' in phase) {
|
|
128
|
+
if (!Array.isArray(phase.files) || !phase.files.every(isNonEmptyString)) {
|
|
129
|
+
violations.push({
|
|
130
|
+
rule: 'invalid_field_value',
|
|
131
|
+
phase_id: phaseId ?? null,
|
|
132
|
+
field: 'files',
|
|
133
|
+
severity: 'error',
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return { valid: violations.length === 0, violations };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
module.exports = {
|
|
143
|
+
PHASE_ID_SCHEMA,
|
|
144
|
+
PHASE_ITEM_SCHEMA,
|
|
145
|
+
PHASE_REQUIRED_FIELDS,
|
|
146
|
+
isValidPhaseId,
|
|
147
|
+
validatePhases,
|
|
148
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
|
|
6
|
+
const MARKER_FILENAME = '.workspace-root';
|
|
7
|
+
const SCHEMA_VERSION = 1;
|
|
8
|
+
|
|
9
|
+
function markerPathFor(stateDir) {
|
|
10
|
+
return path.join(stateDir, MARKER_FILENAME);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Reads and validates the workspace marker file from the given state directory.
|
|
15
|
+
*
|
|
16
|
+
* Returns null when the file is absent, contains malformed JSON, or was written
|
|
17
|
+
* by an incompatible schema version.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} stateDir - Absolute path to the Maestro state directory.
|
|
20
|
+
* @returns {{ workspace_path: string, written_at: string, schema_version: number } | null}
|
|
21
|
+
*/
|
|
22
|
+
function readWorkspaceMarker(stateDir) {
|
|
23
|
+
const markerPath = markerPathFor(stateDir);
|
|
24
|
+
if (!fs.existsSync(markerPath)) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const parsed = JSON.parse(fs.readFileSync(markerPath, 'utf8'));
|
|
29
|
+
if (
|
|
30
|
+
!parsed ||
|
|
31
|
+
typeof parsed.workspace_path !== 'string' ||
|
|
32
|
+
parsed.schema_version !== SCHEMA_VERSION
|
|
33
|
+
) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
return parsed;
|
|
37
|
+
} catch {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Writes a workspace marker file into the given state directory.
|
|
44
|
+
*
|
|
45
|
+
* Creates the state directory if it does not already exist.
|
|
46
|
+
*
|
|
47
|
+
* @param {string} stateDir - Absolute path to the Maestro state directory.
|
|
48
|
+
* @param {string} workspacePath - Absolute path to the resolved workspace root.
|
|
49
|
+
* @returns {void}
|
|
50
|
+
*/
|
|
51
|
+
function writeWorkspaceMarker(stateDir, workspacePath) {
|
|
52
|
+
const payload = {
|
|
53
|
+
workspace_path: workspacePath,
|
|
54
|
+
written_at: new Date().toISOString(),
|
|
55
|
+
schema_version: SCHEMA_VERSION,
|
|
56
|
+
};
|
|
57
|
+
fs.mkdirSync(stateDir, { recursive: true });
|
|
58
|
+
fs.writeFileSync(markerPathFor(stateDir), JSON.stringify(payload, null, 2));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = { MARKER_FILENAME, SCHEMA_VERSION, readWorkspaceMarker, writeWorkspaceMarker };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { createToolRegistry } = require('./tool-registry');
|
|
4
|
+
const {
|
|
5
|
+
createToolSuccess,
|
|
6
|
+
createUnknownToolFailure,
|
|
7
|
+
normalizeToolError,
|
|
8
|
+
sanitizeErrorMessage,
|
|
9
|
+
} = require('./tool-outcome');
|
|
10
|
+
const { requireWorkspaceRoot } = require('../../core/project-root-resolver');
|
|
11
|
+
|
|
12
|
+
function createServer(options = {}) {
|
|
13
|
+
const { runtimeConfig = {}, services = {} } = options;
|
|
14
|
+
const registry = createToolRegistry({
|
|
15
|
+
runtimeConfig,
|
|
16
|
+
services,
|
|
17
|
+
toolPacks: options.toolPacks,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const postCallHandlers = new Map();
|
|
21
|
+
|
|
22
|
+
function invokePostCall(name, outcome, args) {
|
|
23
|
+
const handler = postCallHandlers.get(name);
|
|
24
|
+
if (typeof handler === 'function') {
|
|
25
|
+
try {
|
|
26
|
+
handler(outcome, args);
|
|
27
|
+
} catch {
|
|
28
|
+
// Post-call handlers must not mask tool results.
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
runtimeConfig,
|
|
35
|
+
services,
|
|
36
|
+
toolPacks: registry.toolPacks,
|
|
37
|
+
schemas: registry.schemas,
|
|
38
|
+
handlers: registry.handlers,
|
|
39
|
+
metadata: registry.metadata,
|
|
40
|
+
getToolSchemas() {
|
|
41
|
+
return registry.schemas.slice();
|
|
42
|
+
},
|
|
43
|
+
getToolHandler(name) {
|
|
44
|
+
return registry.handlers[name];
|
|
45
|
+
},
|
|
46
|
+
getToolMetadata(name) {
|
|
47
|
+
return registry.metadata[name] || null;
|
|
48
|
+
},
|
|
49
|
+
onToolCall(name, handler) {
|
|
50
|
+
postCallHandlers.set(name, handler);
|
|
51
|
+
},
|
|
52
|
+
async callTool(name, args = {}, projectRoot) {
|
|
53
|
+
const handler = registry.handlers[name];
|
|
54
|
+
if (!handler) {
|
|
55
|
+
return createUnknownToolFailure(name);
|
|
56
|
+
}
|
|
57
|
+
const meta = registry.metadata[name];
|
|
58
|
+
try {
|
|
59
|
+
if (meta && meta.requiresWorkspace) {
|
|
60
|
+
requireWorkspaceRoot(projectRoot, name);
|
|
61
|
+
}
|
|
62
|
+
const result = await handler(args, projectRoot);
|
|
63
|
+
const outcome = createToolSuccess(result);
|
|
64
|
+
invokePostCall(name, result, args);
|
|
65
|
+
return outcome;
|
|
66
|
+
} catch (error) {
|
|
67
|
+
return normalizeToolError(name, error);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
module.exports = {
|
|
74
|
+
createServer,
|
|
75
|
+
sanitizeErrorMessage,
|
|
76
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const readline = require('node:readline');
|
|
4
|
+
|
|
5
|
+
const { log } = require('../../core/logger');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Create a readline-based line dispatcher for a stdin stream.
|
|
9
|
+
* Each non-empty JSON line is parsed and forwarded to `onMessage`.
|
|
10
|
+
* Parse errors are logged and dropped; the reader keeps running.
|
|
11
|
+
*/
|
|
12
|
+
function createLineDispatcher(stdin, onMessage) {
|
|
13
|
+
const lineReader = readline.createInterface({
|
|
14
|
+
input: stdin,
|
|
15
|
+
crlfDelay: Infinity,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
lineReader.on('line', (line) => {
|
|
19
|
+
if (!line.trim()) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
onMessage(JSON.parse(line));
|
|
25
|
+
} catch (error) {
|
|
26
|
+
log('error', `Failed to parse MCP message: ${error.message}`);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return lineReader;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = {
|
|
34
|
+
createLineDispatcher,
|
|
35
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const { pathToFileURL, fileURLToPath } = require('node:url');
|
|
6
|
+
|
|
7
|
+
const { isExtensionCachePath } = require('../contracts/cache-path-rejector');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Project-root cache for the MCP session.
|
|
11
|
+
*
|
|
12
|
+
* After this refactor, the workspace path is authoritative only when the
|
|
13
|
+
* orchestrator has passed it to `initialize_workspace`. Before that call,
|
|
14
|
+
* stateful tools reject with a structured error.
|
|
15
|
+
*
|
|
16
|
+
* The cache also computes a `workspace_suggestion` from the env var declared
|
|
17
|
+
* by the runtime-config, any MCP roots supplied by the client, and the
|
|
18
|
+
* runtime's cwd. The suggestion is exposed through `get_runtime_context` so
|
|
19
|
+
* the orchestrator can pass it into `initialize_workspace`. It is never
|
|
20
|
+
* used as a fallback for other tools.
|
|
21
|
+
*/
|
|
22
|
+
function createProjectRootCache(options) {
|
|
23
|
+
const {
|
|
24
|
+
runtimeConfig,
|
|
25
|
+
requestClientRoots,
|
|
26
|
+
env = process.env,
|
|
27
|
+
getCwd = () => process.cwd(),
|
|
28
|
+
} = options;
|
|
29
|
+
|
|
30
|
+
let explicitWorkspacePath = null;
|
|
31
|
+
let clientRoots = [];
|
|
32
|
+
let clientSupportsRoots = false;
|
|
33
|
+
|
|
34
|
+
function envSuggestion() {
|
|
35
|
+
const envVarName =
|
|
36
|
+
runtimeConfig && runtimeConfig.env ? runtimeConfig.env.workspacePath : null;
|
|
37
|
+
if (!envVarName) return null;
|
|
38
|
+
const value = env[envVarName];
|
|
39
|
+
if (!value || value.includes('${')) return null;
|
|
40
|
+
const resolved = path.resolve(value);
|
|
41
|
+
if (!fs.existsSync(resolved)) return null;
|
|
42
|
+
if (isExtensionCachePath(resolved)) return null;
|
|
43
|
+
return resolved;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function rootsSuggestion() {
|
|
47
|
+
for (const root of clientRoots) {
|
|
48
|
+
const uri = typeof root === 'string' ? root : root && root.uri;
|
|
49
|
+
if (typeof uri !== 'string') continue;
|
|
50
|
+
try {
|
|
51
|
+
const parsed = new URL(uri);
|
|
52
|
+
if (parsed.protocol !== 'file:') continue;
|
|
53
|
+
const resolved = fileURLToPath(parsed);
|
|
54
|
+
if (!fs.existsSync(resolved)) continue;
|
|
55
|
+
if (isExtensionCachePath(resolved)) continue;
|
|
56
|
+
return resolved;
|
|
57
|
+
} catch {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function cwdSuggestion() {
|
|
65
|
+
const cwd = path.resolve(getCwd());
|
|
66
|
+
if (isExtensionCachePath(cwd)) return null;
|
|
67
|
+
return cwd;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function refreshClientRoots() {
|
|
71
|
+
if (!clientSupportsRoots || typeof requestClientRoots !== 'function') {
|
|
72
|
+
clientRoots = [];
|
|
73
|
+
return clientRoots;
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
const result = await requestClientRoots();
|
|
77
|
+
clientRoots = result && Array.isArray(result.roots) ? result.roots : [];
|
|
78
|
+
} catch {
|
|
79
|
+
clientRoots = [];
|
|
80
|
+
}
|
|
81
|
+
return clientRoots;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function workspaceSuggestion() {
|
|
85
|
+
return envSuggestion() || rootsSuggestion() || cwdSuggestion();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function setExplicitWorkspacePath(value) {
|
|
89
|
+
explicitWorkspacePath = value || null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async function getProjectRoot() {
|
|
93
|
+
if (!explicitWorkspacePath) {
|
|
94
|
+
const error = new Error(
|
|
95
|
+
'Workspace not initialized. Call initialize_workspace(workspace_path=...) before any stateful tool.'
|
|
96
|
+
);
|
|
97
|
+
error.code = 'WORKSPACE_NOT_INITIALIZED';
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
return explicitWorkspacePath;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
getProjectRoot,
|
|
105
|
+
setExplicitWorkspacePath,
|
|
106
|
+
workspaceSuggestion,
|
|
107
|
+
setClientSupportsRoots(supports) {
|
|
108
|
+
clientSupportsRoots = Boolean(supports);
|
|
109
|
+
},
|
|
110
|
+
refreshClientRoots,
|
|
111
|
+
invalidateProjectRoot() {
|
|
112
|
+
explicitWorkspacePath = null;
|
|
113
|
+
},
|
|
114
|
+
invalidateClientRoots() {
|
|
115
|
+
clientRoots = [];
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
module.exports = { createProjectRootCache };
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { log } = require('../../core/logger');
|
|
4
|
+
|
|
5
|
+
const DEFAULT_PROTOCOL_VERSION = '2025-03-26';
|
|
6
|
+
const DEFAULT_CLIENT_REQUEST_TIMEOUT_MS = 5000;
|
|
7
|
+
|
|
8
|
+
function writeMessage(output, message) {
|
|
9
|
+
output.write(JSON.stringify(message) + '\n');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function buildInitializeResult(protocolVersion, serverInfo) {
|
|
13
|
+
return {
|
|
14
|
+
protocolVersion: protocolVersion || DEFAULT_PROTOCOL_VERSION,
|
|
15
|
+
capabilities: {
|
|
16
|
+
tools: {},
|
|
17
|
+
},
|
|
18
|
+
serverInfo,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function createToolErrorResult(errorOrOutcome, recoveryHint) {
|
|
23
|
+
const outcome =
|
|
24
|
+
errorOrOutcome &&
|
|
25
|
+
typeof errorOrOutcome === 'object' &&
|
|
26
|
+
!Array.isArray(errorOrOutcome) &&
|
|
27
|
+
Object.prototype.hasOwnProperty.call(errorOrOutcome, 'error')
|
|
28
|
+
? errorOrOutcome
|
|
29
|
+
: { error: errorOrOutcome, recovery_hint: recoveryHint };
|
|
30
|
+
|
|
31
|
+
const payload = {
|
|
32
|
+
error: outcome.error,
|
|
33
|
+
recovery_hint: outcome.recovery_hint ?? null,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
if (outcome.code) {
|
|
37
|
+
payload.code = outcome.code;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (outcome.details !== undefined) {
|
|
41
|
+
payload.details = outcome.details;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
content: [
|
|
46
|
+
{
|
|
47
|
+
type: 'text',
|
|
48
|
+
text: JSON.stringify(payload),
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
isError: true,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function createToolSuccessResult(result) {
|
|
56
|
+
return {
|
|
57
|
+
content: [
|
|
58
|
+
{
|
|
59
|
+
type: 'text',
|
|
60
|
+
text: JSON.stringify(result),
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Create a JSON-RPC 2.0 dispatcher for the MCP wire protocol.
|
|
68
|
+
*
|
|
69
|
+
* Handles `initialize`, `tools/list`, `tools/call`, `ping`, notification
|
|
70
|
+
* methods, and outbound server-to-client requests (via `requestFromClient`).
|
|
71
|
+
* Unknown methods get a -32601 response.
|
|
72
|
+
*
|
|
73
|
+
* @returns {{
|
|
74
|
+
* requestFromClient: (method: string, params?: object) => Promise<any>,
|
|
75
|
+
* respond: (message: object) => Promise<void>
|
|
76
|
+
* }}
|
|
77
|
+
*/
|
|
78
|
+
function createProtocolHandlers(server, getProjectRoot, stdout, options = {}) {
|
|
79
|
+
const {
|
|
80
|
+
serverInfo,
|
|
81
|
+
callbacks = {},
|
|
82
|
+
clientRequestTimeoutMs = DEFAULT_CLIENT_REQUEST_TIMEOUT_MS,
|
|
83
|
+
} = options;
|
|
84
|
+
|
|
85
|
+
const pendingClientRequests = new Map();
|
|
86
|
+
let nextClientRequestId = 1;
|
|
87
|
+
|
|
88
|
+
function settleClientRequest(message) {
|
|
89
|
+
if (!message || message.id == null) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const entry = pendingClientRequests.get(message.id);
|
|
94
|
+
if (!entry) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
pendingClientRequests.delete(message.id);
|
|
99
|
+
clearTimeout(entry.timeout);
|
|
100
|
+
|
|
101
|
+
if (message.error) {
|
|
102
|
+
entry.reject(new Error(message.error.message || JSON.stringify(message.error)));
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
entry.resolve(message.result);
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function requestFromClient(method, params = {}) {
|
|
111
|
+
return new Promise((resolve, reject) => {
|
|
112
|
+
const id = `server-${nextClientRequestId++}`;
|
|
113
|
+
const timeout = setTimeout(() => {
|
|
114
|
+
pendingClientRequests.delete(id);
|
|
115
|
+
reject(new Error(`Timed out waiting for client response to ${method}`));
|
|
116
|
+
}, clientRequestTimeoutMs);
|
|
117
|
+
|
|
118
|
+
pendingClientRequests.set(id, { resolve, reject, timeout });
|
|
119
|
+
writeMessage(stdout, {
|
|
120
|
+
jsonrpc: '2.0',
|
|
121
|
+
id,
|
|
122
|
+
method,
|
|
123
|
+
params,
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
async function respond(message) {
|
|
129
|
+
if (!message || typeof message !== 'object') {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (settleClientRequest(message)) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (typeof message.method !== 'string') {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (message.method === 'initialize') {
|
|
142
|
+
if (typeof callbacks.onInitialize === 'function') {
|
|
143
|
+
await Promise.resolve(callbacks.onInitialize(message.params || {}));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
writeMessage(stdout, {
|
|
147
|
+
jsonrpc: '2.0',
|
|
148
|
+
id: message.id,
|
|
149
|
+
result: buildInitializeResult(
|
|
150
|
+
message.params && message.params.protocolVersion,
|
|
151
|
+
serverInfo
|
|
152
|
+
),
|
|
153
|
+
});
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (message.method === 'notifications/initialized') {
|
|
158
|
+
if (typeof callbacks.onInitialized === 'function') {
|
|
159
|
+
await Promise.resolve(callbacks.onInitialized());
|
|
160
|
+
}
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (message.method === 'notifications/roots/list_changed') {
|
|
165
|
+
if (typeof callbacks.onRootsListChanged === 'function') {
|
|
166
|
+
await Promise.resolve(callbacks.onRootsListChanged());
|
|
167
|
+
}
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (
|
|
172
|
+
message.method === 'notifications/cancelled' ||
|
|
173
|
+
message.method === '$/cancelRequest'
|
|
174
|
+
) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (message.method === 'ping') {
|
|
179
|
+
writeMessage(stdout, {
|
|
180
|
+
jsonrpc: '2.0',
|
|
181
|
+
id: message.id,
|
|
182
|
+
result: {},
|
|
183
|
+
});
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (message.method === 'tools/list') {
|
|
188
|
+
writeMessage(stdout, {
|
|
189
|
+
jsonrpc: '2.0',
|
|
190
|
+
id: message.id,
|
|
191
|
+
result: {
|
|
192
|
+
tools: server.getToolSchemas(),
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (message.method === 'tools/call') {
|
|
199
|
+
const name = message.params && message.params.name;
|
|
200
|
+
const args =
|
|
201
|
+
message.params && message.params.arguments && typeof message.params.arguments === 'object'
|
|
202
|
+
? message.params.arguments
|
|
203
|
+
: {};
|
|
204
|
+
let projectRoot = null;
|
|
205
|
+
try {
|
|
206
|
+
projectRoot = await getProjectRoot();
|
|
207
|
+
} catch (error) {
|
|
208
|
+
if (error && error.code !== 'WORKSPACE_NOT_INITIALIZED') {
|
|
209
|
+
log(
|
|
210
|
+
'warn',
|
|
211
|
+
`getProjectRoot failed unexpectedly while handling ${name || '(unknown)'}: ${error.message}`
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
projectRoot = null;
|
|
215
|
+
}
|
|
216
|
+
const outcome = await server.callTool(name, args, projectRoot);
|
|
217
|
+
|
|
218
|
+
if (outcome.ok) {
|
|
219
|
+
writeMessage(stdout, {
|
|
220
|
+
jsonrpc: '2.0',
|
|
221
|
+
id: message.id,
|
|
222
|
+
result: createToolSuccessResult(outcome.result),
|
|
223
|
+
});
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
log('error', `Tool ${name || '(unknown)'} failed: ${outcome.error}`);
|
|
228
|
+
writeMessage(stdout, {
|
|
229
|
+
jsonrpc: '2.0',
|
|
230
|
+
id: message.id,
|
|
231
|
+
result: createToolErrorResult(outcome),
|
|
232
|
+
});
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (message.id == null) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
writeMessage(stdout, {
|
|
241
|
+
jsonrpc: '2.0',
|
|
242
|
+
id: message.id,
|
|
243
|
+
error: {
|
|
244
|
+
code: -32601,
|
|
245
|
+
message: `Method not found: ${message.method}`,
|
|
246
|
+
},
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Clear all pending outbound client-request timeouts and reject their
|
|
252
|
+
* promises. Call during server shutdown so Node can exit promptly and
|
|
253
|
+
* callers do not receive late timeout rejections.
|
|
254
|
+
*/
|
|
255
|
+
function drain() {
|
|
256
|
+
for (const [id, entry] of pendingClientRequests) {
|
|
257
|
+
clearTimeout(entry.timeout);
|
|
258
|
+
entry.reject(new Error(`MCP server closing; request ${id} aborted`));
|
|
259
|
+
}
|
|
260
|
+
pendingClientRequests.clear();
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return { requestFromClient, respond, drain };
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
module.exports = {
|
|
267
|
+
DEFAULT_PROTOCOL_VERSION,
|
|
268
|
+
DEFAULT_CLIENT_REQUEST_TIMEOUT_MS,
|
|
269
|
+
writeMessage,
|
|
270
|
+
buildInitializeResult,
|
|
271
|
+
createToolErrorResult,
|
|
272
|
+
createToolSuccessResult,
|
|
273
|
+
createProtocolHandlers,
|
|
274
|
+
};
|