agentic-orchestrator 0.1.0
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/.dockerignore +24 -0
- package/.github/workflows/mcp-contract-validation.yml +38 -0
- package/Agentic-Orchestrator.iml +9 -0
- package/LICENSE +21 -0
- package/README.md +679 -0
- package/agentic/orchestrator/agents.yaml +14 -0
- package/agentic/orchestrator/gates.yaml +31 -0
- package/agentic/orchestrator/policy.yaml +145 -0
- package/agentic/orchestrator/prompts/builder.system.md +1 -0
- package/agentic/orchestrator/prompts/planner.system.md +15 -0
- package/agentic/orchestrator/prompts/qa.system.md +1 -0
- package/agentic/orchestrator/schemas/agents.schema.json +49 -0
- package/agentic/orchestrator/schemas/gates.schema.json +65 -0
- package/agentic/orchestrator/schemas/index.schema.json +108 -0
- package/agentic/orchestrator/schemas/plan.schema.json +127 -0
- package/agentic/orchestrator/schemas/policy.schema.json +227 -0
- package/agentic/orchestrator/schemas/qa_test_index.schema.json +53 -0
- package/agentic/orchestrator/schemas/state.schema.json +92 -0
- package/agentic/orchestrator/tools/catalog.json +399 -0
- package/agentic/orchestrator/tools/errors.schema.json +21 -0
- package/agentic/orchestrator/tools/protocol.json +8 -0
- package/agentic/orchestrator/tools/schemas/input/collisions.scan.input.schema.json +7 -0
- package/agentic/orchestrator/tools/schemas/input/evidence.latest.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/input/feature.delete.input.schema.json +42 -0
- package/agentic/orchestrator/tools/schemas/input/feature.discover_specs.input.schema.json +7 -0
- package/agentic/orchestrator/tools/schemas/input/feature.get_context.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/input/feature.init.input.schema.json +21 -0
- package/agentic/orchestrator/tools/schemas/input/feature.log_append.input.schema.json +26 -0
- package/agentic/orchestrator/tools/schemas/input/feature.ready_to_merge.input.schema.json +34 -0
- package/agentic/orchestrator/tools/schemas/input/feature.state_get.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/input/feature.state_patch.input.schema.json +28 -0
- package/agentic/orchestrator/tools/schemas/input/gates.list.input.schema.json +11 -0
- package/agentic/orchestrator/tools/schemas/input/gates.run.input.schema.json +29 -0
- package/agentic/orchestrator/tools/schemas/input/locks.acquire.input.schema.json +29 -0
- package/agentic/orchestrator/tools/schemas/input/locks.release.input.schema.json +26 -0
- package/agentic/orchestrator/tools/schemas/input/mutating.schema.json +14 -0
- package/agentic/orchestrator/tools/schemas/input/plan.get.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/input/plan.submit.input.schema.json +28 -0
- package/agentic/orchestrator/tools/schemas/input/plan.update.input.schema.json +29 -0
- package/agentic/orchestrator/tools/schemas/input/qa.test_index_get.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/input/qa.test_index_update.input.schema.json +38 -0
- package/agentic/orchestrator/tools/schemas/input/read.schema.json +6 -0
- package/agentic/orchestrator/tools/schemas/input/repo.apply_patch.input.schema.json +25 -0
- package/agentic/orchestrator/tools/schemas/input/repo.diff.input.schema.json +21 -0
- package/agentic/orchestrator/tools/schemas/input/repo.diff_bundle.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/input/repo.ensure_worktree.input.schema.json +21 -0
- package/agentic/orchestrator/tools/schemas/input/repo.read_file.input.schema.json +20 -0
- package/agentic/orchestrator/tools/schemas/input/repo.search.input.schema.json +20 -0
- package/agentic/orchestrator/tools/schemas/input/repo.status.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/input/report.dashboard.input.schema.json +7 -0
- package/agentic/orchestrator/tools/schemas/input/report.feature_summary.input.schema.json +15 -0
- package/agentic/orchestrator/tools/schemas/output/collisions.scan.output.schema.json +17 -0
- package/agentic/orchestrator/tools/schemas/output/evidence.latest.output.schema.json +20 -0
- package/agentic/orchestrator/tools/schemas/output/feature.delete.output.schema.json +224 -0
- package/agentic/orchestrator/tools/schemas/output/feature.discover_specs.output.schema.json +32 -0
- package/agentic/orchestrator/tools/schemas/output/feature.get_context.output.schema.json +40 -0
- package/agentic/orchestrator/tools/schemas/output/feature.init.output.schema.json +24 -0
- package/agentic/orchestrator/tools/schemas/output/feature.log_append.output.schema.json +24 -0
- package/agentic/orchestrator/tools/schemas/output/feature.ready_to_merge.output.schema.json +30 -0
- package/agentic/orchestrator/tools/schemas/output/feature.state_get.output.schema.json +18 -0
- package/agentic/orchestrator/tools/schemas/output/feature.state_patch.output.schema.json +24 -0
- package/agentic/orchestrator/tools/schemas/output/gates.list.output.schema.json +42 -0
- package/agentic/orchestrator/tools/schemas/output/gates.run.output.schema.json +37 -0
- package/agentic/orchestrator/tools/schemas/output/locks.acquire.output.schema.json +34 -0
- package/agentic/orchestrator/tools/schemas/output/locks.release.output.schema.json +24 -0
- package/agentic/orchestrator/tools/schemas/output/plan.get.output.schema.json +26 -0
- package/agentic/orchestrator/tools/schemas/output/plan.submit.output.schema.json +23 -0
- package/agentic/orchestrator/tools/schemas/output/plan.update.output.schema.json +23 -0
- package/agentic/orchestrator/tools/schemas/output/qa.test_index_get.output.schema.json +22 -0
- package/agentic/orchestrator/tools/schemas/output/qa.test_index_update.output.schema.json +19 -0
- package/agentic/orchestrator/tools/schemas/output/repo.apply_patch.output.schema.json +33 -0
- package/agentic/orchestrator/tools/schemas/output/repo.diff.output.schema.json +19 -0
- package/agentic/orchestrator/tools/schemas/output/repo.diff_bundle.output.schema.json +32 -0
- package/agentic/orchestrator/tools/schemas/output/repo.ensure_worktree.output.schema.json +29 -0
- package/agentic/orchestrator/tools/schemas/output/repo.read_file.output.schema.json +24 -0
- package/agentic/orchestrator/tools/schemas/output/repo.search.output.schema.json +26 -0
- package/agentic/orchestrator/tools/schemas/output/repo.status.output.schema.json +27 -0
- package/agentic/orchestrator/tools/schemas/output/report.dashboard.output.schema.json +21 -0
- package/agentic/orchestrator/tools/schemas/output/report.feature_summary.output.schema.json +36 -0
- package/agentic/orchestrator/tools/schemas/output/standard_success.schema.json +6 -0
- package/agentic/orchestrator/tools.md +32 -0
- package/apps/control-plane/project.json +39 -0
- package/apps/control-plane/scripts/validate-architecture-rules.mjs +170 -0
- package/apps/control-plane/scripts/validate-docker-mcp-contract.mjs +84 -0
- package/apps/control-plane/scripts/validate-mcp-contracts.ts +61 -0
- package/apps/control-plane/src/application/services/collision-queue-service.ts +227 -0
- package/apps/control-plane/src/application/services/feature-deletion-service.ts +459 -0
- package/apps/control-plane/src/application/services/feature-lifecycle-service.ts +177 -0
- package/apps/control-plane/src/application/services/feature-state-service.ts +125 -0
- package/apps/control-plane/src/application/services/gate-service.ts +232 -0
- package/apps/control-plane/src/application/services/lock-service.ts +298 -0
- package/apps/control-plane/src/application/services/merge-service.ts +246 -0
- package/apps/control-plane/src/application/services/patch-service.ts +259 -0
- package/apps/control-plane/src/application/services/plan-service.ts +302 -0
- package/apps/control-plane/src/application/services/qa-index-service.ts +98 -0
- package/apps/control-plane/src/application/services/reporting-service.ts +120 -0
- package/apps/control-plane/src/application/services/run-lease-service.ts +340 -0
- package/apps/control-plane/src/application/tools/tool-metadata.ts +56 -0
- package/apps/control-plane/src/application/tools/tool-router.ts +43 -0
- package/apps/control-plane/src/cli/aop.ts +31 -0
- package/apps/control-plane/src/cli/cli-argument-parser.ts +116 -0
- package/apps/control-plane/src/cli/delete-command-handler.ts +90 -0
- package/apps/control-plane/src/cli/io.ts +14 -0
- package/apps/control-plane/src/cli/resume-command-handler.ts +228 -0
- package/apps/control-plane/src/cli/run-command-handler.ts +57 -0
- package/apps/control-plane/src/cli/spec-ingestion-service.ts +88 -0
- package/apps/control-plane/src/cli/spec-input-resolver.ts +95 -0
- package/apps/control-plane/src/cli/spec-utils.ts +40 -0
- package/apps/control-plane/src/cli/status-command-handler.ts +17 -0
- package/apps/control-plane/src/cli/stop-command-handler.ts +5 -0
- package/apps/control-plane/src/cli/tooling.ts +36 -0
- package/apps/control-plane/src/cli/types.ts +34 -0
- package/apps/control-plane/src/core/collisions.ts +121 -0
- package/apps/control-plane/src/core/constants.ts +72 -0
- package/apps/control-plane/src/core/error-codes.ts +54 -0
- package/apps/control-plane/src/core/frontmatter.ts +42 -0
- package/apps/control-plane/src/core/fs.ts +173 -0
- package/apps/control-plane/src/core/gates.ts +361 -0
- package/apps/control-plane/src/core/git.ts +115 -0
- package/apps/control-plane/src/core/kernel.ts +1077 -0
- package/apps/control-plane/src/core/patch.ts +152 -0
- package/apps/control-plane/src/core/path-layout.ts +113 -0
- package/apps/control-plane/src/core/path-rules.ts +71 -0
- package/apps/control-plane/src/core/qa-index.ts +179 -0
- package/apps/control-plane/src/core/response.ts +62 -0
- package/apps/control-plane/src/core/runtime-sessions.ts +20 -0
- package/apps/control-plane/src/core/schemas.ts +125 -0
- package/apps/control-plane/src/index.ts +21 -0
- package/apps/control-plane/src/interfaces/cli/bootstrap.ts +100 -0
- package/apps/control-plane/src/mcp/kernel-tool-executor.ts +39 -0
- package/apps/control-plane/src/mcp/mcp-server-adapter.ts +74 -0
- package/apps/control-plane/src/mcp/operation-ledger.ts +108 -0
- package/apps/control-plane/src/mcp/protocol-contract.ts +9 -0
- package/apps/control-plane/src/mcp/runtime-factory.ts +105 -0
- package/apps/control-plane/src/mcp/runtime-types.ts +44 -0
- package/apps/control-plane/src/mcp/token-auth-verifier.ts +63 -0
- package/apps/control-plane/src/mcp/token-claims-validator.ts +72 -0
- package/apps/control-plane/src/mcp/token-codec.ts +62 -0
- package/apps/control-plane/src/mcp/tool-authorizer.ts +43 -0
- package/apps/control-plane/src/mcp/tool-client.ts +78 -0
- package/apps/control-plane/src/mcp/tool-contract-validator.ts +83 -0
- package/apps/control-plane/src/mcp/tool-registry-loader.ts +135 -0
- package/apps/control-plane/src/mcp/tool-runtime.ts +336 -0
- package/apps/control-plane/src/mcp/tools-markdown-generator.ts +26 -0
- package/apps/control-plane/src/mcp/transport-types.ts +16 -0
- package/apps/control-plane/src/mcp/types.ts +2 -0
- package/apps/control-plane/src/providers/providers.ts +177 -0
- package/apps/control-plane/src/supervisor/build-wave-executor.ts +55 -0
- package/apps/control-plane/src/supervisor/lease-heartbeat-service.ts +22 -0
- package/apps/control-plane/src/supervisor/planning-wave-executor.ts +316 -0
- package/apps/control-plane/src/supervisor/prompt-bundle-loader.ts +62 -0
- package/apps/control-plane/src/supervisor/qa-wave-executor.ts +99 -0
- package/apps/control-plane/src/supervisor/run-coordinator.ts +224 -0
- package/apps/control-plane/src/supervisor/runtime.ts +347 -0
- package/apps/control-plane/src/supervisor/session-orchestrator.ts +268 -0
- package/apps/control-plane/src/supervisor/types.ts +149 -0
- package/apps/control-plane/src/supervisor/worker-decision-loop.ts +299 -0
- package/apps/control-plane/test/aop.spec.ts +101 -0
- package/apps/control-plane/test/cli-helpers.spec.ts +102 -0
- package/apps/control-plane/test/cli.spec.ts +12 -0
- package/apps/control-plane/test/cli.unit.spec.ts +609 -0
- package/apps/control-plane/test/collision-queue.spec.ts +158 -0
- package/apps/control-plane/test/collisions.spec.ts +138 -0
- package/apps/control-plane/test/core-utils.spec.ts +102 -0
- package/apps/control-plane/test/delete-command-handler.spec.ts +202 -0
- package/apps/control-plane/test/epoch-tracking.spec.ts +121 -0
- package/apps/control-plane/test/gates.spec.ts +452 -0
- package/apps/control-plane/test/helpers.ts +68 -0
- package/apps/control-plane/test/index.spec.ts +18 -0
- package/apps/control-plane/test/kernel-collision-replay.spec.ts +222 -0
- package/apps/control-plane/test/kernel.branches.spec.ts +321 -0
- package/apps/control-plane/test/kernel.coverage.spec.ts +408 -0
- package/apps/control-plane/test/kernel.spec.ts +369 -0
- package/apps/control-plane/test/mcp-helpers.spec.ts +195 -0
- package/apps/control-plane/test/mcp.spec.ts +776 -0
- package/apps/control-plane/test/merge-service.spec.ts +357 -0
- package/apps/control-plane/test/plan-service.spec.ts +195 -0
- package/apps/control-plane/test/planning-wave-executor.spec.ts +229 -0
- package/apps/control-plane/test/providers.spec.ts +168 -0
- package/apps/control-plane/test/qa-index-service.spec.ts +187 -0
- package/apps/control-plane/test/qa-index.spec.ts +317 -0
- package/apps/control-plane/test/response.spec.ts +55 -0
- package/apps/control-plane/test/run-coordinator.spec.ts +334 -0
- package/apps/control-plane/test/schema-date-time.spec.ts +170 -0
- package/apps/control-plane/test/service-retry-paths.spec.ts +305 -0
- package/apps/control-plane/test/services.spec.ts +693 -0
- package/apps/control-plane/test/spec-input-resolver.spec.ts +76 -0
- package/apps/control-plane/test/supervisor-collaborators.spec.ts +201 -0
- package/apps/control-plane/test/supervisor.calltool.spec.ts +120 -0
- package/apps/control-plane/test/supervisor.spec.ts +415 -0
- package/apps/control-plane/test/supervisor.unit.spec.ts +522 -0
- package/apps/control-plane/test/token-auth-verifier.spec.ts +111 -0
- package/apps/control-plane/test/tool-registry-loader.spec.ts +268 -0
- package/apps/control-plane/test/tool-runtime.spec.ts +294 -0
- package/apps/control-plane/test/worker-decision-loop.spec.ts +587 -0
- package/apps/control-plane/tsconfig.build.json +17 -0
- package/apps/control-plane/tsconfig.json +11 -0
- package/apps/control-plane/vitest.config.ts +28 -0
- package/dist/apps/control-plane/application/services/collision-queue-service.d.ts +69 -0
- package/dist/apps/control-plane/application/services/collision-queue-service.js +158 -0
- package/dist/apps/control-plane/application/services/collision-queue-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/feature-deletion-service.d.ts +79 -0
- package/dist/apps/control-plane/application/services/feature-deletion-service.js +336 -0
- package/dist/apps/control-plane/application/services/feature-deletion-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/feature-lifecycle-service.d.ts +81 -0
- package/dist/apps/control-plane/application/services/feature-lifecycle-service.js +117 -0
- package/dist/apps/control-plane/application/services/feature-lifecycle-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/feature-state-service.d.ts +34 -0
- package/dist/apps/control-plane/application/services/feature-state-service.js +90 -0
- package/dist/apps/control-plane/application/services/feature-state-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/gate-service.d.ts +46 -0
- package/dist/apps/control-plane/application/services/gate-service.js +160 -0
- package/dist/apps/control-plane/application/services/gate-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/lock-service.d.ts +56 -0
- package/dist/apps/control-plane/application/services/lock-service.js +242 -0
- package/dist/apps/control-plane/application/services/lock-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/merge-service.d.ts +33 -0
- package/dist/apps/control-plane/application/services/merge-service.js +194 -0
- package/dist/apps/control-plane/application/services/merge-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/patch-service.d.ts +39 -0
- package/dist/apps/control-plane/application/services/patch-service.js +189 -0
- package/dist/apps/control-plane/application/services/patch-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/plan-service.d.ts +60 -0
- package/dist/apps/control-plane/application/services/plan-service.js +234 -0
- package/dist/apps/control-plane/application/services/plan-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/qa-index-service.d.ts +26 -0
- package/dist/apps/control-plane/application/services/qa-index-service.js +66 -0
- package/dist/apps/control-plane/application/services/qa-index-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/reporting-service.d.ts +47 -0
- package/dist/apps/control-plane/application/services/reporting-service.js +90 -0
- package/dist/apps/control-plane/application/services/reporting-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/run-lease-service.d.ts +74 -0
- package/dist/apps/control-plane/application/services/run-lease-service.js +263 -0
- package/dist/apps/control-plane/application/services/run-lease-service.js.map +1 -0
- package/dist/apps/control-plane/application/tools/tool-metadata.d.ts +8 -0
- package/dist/apps/control-plane/application/tools/tool-metadata.js +37 -0
- package/dist/apps/control-plane/application/tools/tool-metadata.js.map +1 -0
- package/dist/apps/control-plane/application/tools/tool-router.d.ts +16 -0
- package/dist/apps/control-plane/application/tools/tool-router.js +25 -0
- package/dist/apps/control-plane/application/tools/tool-router.js.map +1 -0
- package/dist/apps/control-plane/cli/aop.d.ts +5 -0
- package/dist/apps/control-plane/cli/aop.js +19 -0
- package/dist/apps/control-plane/cli/aop.js.map +1 -0
- package/dist/apps/control-plane/cli/cli-argument-parser.d.ts +5 -0
- package/dist/apps/control-plane/cli/cli-argument-parser.js +109 -0
- package/dist/apps/control-plane/cli/cli-argument-parser.js.map +1 -0
- package/dist/apps/control-plane/cli/delete-command-handler.d.ts +8 -0
- package/dist/apps/control-plane/cli/delete-command-handler.js +77 -0
- package/dist/apps/control-plane/cli/delete-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/io.d.ts +2 -0
- package/dist/apps/control-plane/cli/io.js +14 -0
- package/dist/apps/control-plane/cli/io.js.map +1 -0
- package/dist/apps/control-plane/cli/resume-command-handler.d.ts +17 -0
- package/dist/apps/control-plane/cli/resume-command-handler.js +178 -0
- package/dist/apps/control-plane/cli/resume-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/run-command-handler.d.ts +15 -0
- package/dist/apps/control-plane/cli/run-command-handler.js +39 -0
- package/dist/apps/control-plane/cli/run-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/spec-ingestion-service.d.ts +8 -0
- package/dist/apps/control-plane/cli/spec-ingestion-service.js +77 -0
- package/dist/apps/control-plane/cli/spec-ingestion-service.js.map +1 -0
- package/dist/apps/control-plane/cli/spec-input-resolver.d.ts +9 -0
- package/dist/apps/control-plane/cli/spec-input-resolver.js +81 -0
- package/dist/apps/control-plane/cli/spec-input-resolver.js.map +1 -0
- package/dist/apps/control-plane/cli/spec-utils.d.ts +3 -0
- package/dist/apps/control-plane/cli/spec-utils.js +36 -0
- package/dist/apps/control-plane/cli/spec-utils.js.map +1 -0
- package/dist/apps/control-plane/cli/status-command-handler.d.ts +7 -0
- package/dist/apps/control-plane/cli/status-command-handler.js +14 -0
- package/dist/apps/control-plane/cli/status-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/stop-command-handler.d.ts +3 -0
- package/dist/apps/control-plane/cli/stop-command-handler.js +6 -0
- package/dist/apps/control-plane/cli/stop-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/tooling.d.ts +4 -0
- package/dist/apps/control-plane/cli/tooling.js +24 -0
- package/dist/apps/control-plane/cli/tooling.js.map +1 -0
- package/dist/apps/control-plane/cli/types.d.ts +31 -0
- package/dist/apps/control-plane/cli/types.js +2 -0
- package/dist/apps/control-plane/cli/types.js.map +1 -0
- package/dist/apps/control-plane/core/collisions.d.ts +39 -0
- package/dist/apps/control-plane/core/collisions.js +78 -0
- package/dist/apps/control-plane/core/collisions.js.map +1 -0
- package/dist/apps/control-plane/core/constants.d.ts +64 -0
- package/dist/apps/control-plane/core/constants.js +64 -0
- package/dist/apps/control-plane/core/constants.js.map +1 -0
- package/dist/apps/control-plane/core/error-codes.d.ts +50 -0
- package/dist/apps/control-plane/core/error-codes.js +52 -0
- package/dist/apps/control-plane/core/error-codes.js.map +1 -0
- package/dist/apps/control-plane/core/frontmatter.d.ts +11 -0
- package/dist/apps/control-plane/core/frontmatter.js +30 -0
- package/dist/apps/control-plane/core/frontmatter.js.map +1 -0
- package/dist/apps/control-plane/core/fs.d.ts +33 -0
- package/dist/apps/control-plane/core/fs.js +134 -0
- package/dist/apps/control-plane/core/fs.js.map +1 -0
- package/dist/apps/control-plane/core/gates.d.ts +88 -0
- package/dist/apps/control-plane/core/gates.js +229 -0
- package/dist/apps/control-plane/core/gates.js.map +1 -0
- package/dist/apps/control-plane/core/git.d.ts +31 -0
- package/dist/apps/control-plane/core/git.js +79 -0
- package/dist/apps/control-plane/core/git.js.map +1 -0
- package/dist/apps/control-plane/core/kernel.d.ts +445 -0
- package/dist/apps/control-plane/core/kernel.js +805 -0
- package/dist/apps/control-plane/core/kernel.js.map +1 -0
- package/dist/apps/control-plane/core/patch.d.ts +23 -0
- package/dist/apps/control-plane/core/patch.js +118 -0
- package/dist/apps/control-plane/core/patch.js.map +1 -0
- package/dist/apps/control-plane/core/path-layout.d.ts +23 -0
- package/dist/apps/control-plane/core/path-layout.js +90 -0
- package/dist/apps/control-plane/core/path-layout.js.map +1 -0
- package/dist/apps/control-plane/core/path-rules.d.ts +13 -0
- package/dist/apps/control-plane/core/path-rules.js +52 -0
- package/dist/apps/control-plane/core/path-rules.js.map +1 -0
- package/dist/apps/control-plane/core/qa-index.d.ts +53 -0
- package/dist/apps/control-plane/core/qa-index.js +112 -0
- package/dist/apps/control-plane/core/qa-index.js.map +1 -0
- package/dist/apps/control-plane/core/response.d.ts +19 -0
- package/dist/apps/control-plane/core/response.js +34 -0
- package/dist/apps/control-plane/core/response.js.map +1 -0
- package/dist/apps/control-plane/core/runtime-sessions.d.ts +19 -0
- package/dist/apps/control-plane/core/runtime-sessions.js +2 -0
- package/dist/apps/control-plane/core/runtime-sessions.js.map +1 -0
- package/dist/apps/control-plane/core/schemas.d.ts +23 -0
- package/dist/apps/control-plane/core/schemas.js +80 -0
- package/dist/apps/control-plane/core/schemas.js.map +1 -0
- package/dist/apps/control-plane/index.d.ts +11 -0
- package/dist/apps/control-plane/index.js +9 -0
- package/dist/apps/control-plane/index.js.map +1 -0
- package/dist/apps/control-plane/interfaces/cli/bootstrap.d.ts +2 -0
- package/dist/apps/control-plane/interfaces/cli/bootstrap.js +86 -0
- package/dist/apps/control-plane/interfaces/cli/bootstrap.js.map +1 -0
- package/dist/apps/control-plane/mcp/kernel-tool-executor.d.ts +14 -0
- package/dist/apps/control-plane/mcp/kernel-tool-executor.js +26 -0
- package/dist/apps/control-plane/mcp/kernel-tool-executor.js.map +1 -0
- package/dist/apps/control-plane/mcp/mcp-server-adapter.d.ts +19 -0
- package/dist/apps/control-plane/mcp/mcp-server-adapter.js +55 -0
- package/dist/apps/control-plane/mcp/mcp-server-adapter.js.map +1 -0
- package/dist/apps/control-plane/mcp/operation-ledger.d.ts +21 -0
- package/dist/apps/control-plane/mcp/operation-ledger.js +75 -0
- package/dist/apps/control-plane/mcp/operation-ledger.js.map +1 -0
- package/dist/apps/control-plane/mcp/protocol-contract.d.ts +8 -0
- package/dist/apps/control-plane/mcp/protocol-contract.js +9 -0
- package/dist/apps/control-plane/mcp/protocol-contract.js.map +1 -0
- package/dist/apps/control-plane/mcp/runtime-factory.d.ts +38 -0
- package/dist/apps/control-plane/mcp/runtime-factory.js +71 -0
- package/dist/apps/control-plane/mcp/runtime-factory.js.map +1 -0
- package/dist/apps/control-plane/mcp/runtime-types.d.ts +40 -0
- package/dist/apps/control-plane/mcp/runtime-types.js +2 -0
- package/dist/apps/control-plane/mcp/runtime-types.js.map +1 -0
- package/dist/apps/control-plane/mcp/token-auth-verifier.d.ts +24 -0
- package/dist/apps/control-plane/mcp/token-auth-verifier.js +45 -0
- package/dist/apps/control-plane/mcp/token-auth-verifier.js.map +1 -0
- package/dist/apps/control-plane/mcp/token-claims-validator.d.ts +9 -0
- package/dist/apps/control-plane/mcp/token-claims-validator.js +62 -0
- package/dist/apps/control-plane/mcp/token-claims-validator.js.map +1 -0
- package/dist/apps/control-plane/mcp/token-codec.d.ts +11 -0
- package/dist/apps/control-plane/mcp/token-codec.js +46 -0
- package/dist/apps/control-plane/mcp/token-codec.js.map +1 -0
- package/dist/apps/control-plane/mcp/tool-authorizer.d.ts +8 -0
- package/dist/apps/control-plane/mcp/tool-authorizer.js +36 -0
- package/dist/apps/control-plane/mcp/tool-authorizer.js.map +1 -0
- package/dist/apps/control-plane/mcp/tool-client.d.ts +30 -0
- package/dist/apps/control-plane/mcp/tool-client.js +50 -0
- package/dist/apps/control-plane/mcp/tool-client.js.map +1 -0
- package/dist/apps/control-plane/mcp/tool-contract-validator.d.ts +29 -0
- package/dist/apps/control-plane/mcp/tool-contract-validator.js +61 -0
- package/dist/apps/control-plane/mcp/tool-contract-validator.js.map +1 -0
- package/dist/apps/control-plane/mcp/tool-registry-loader.d.ts +15 -0
- package/dist/apps/control-plane/mcp/tool-registry-loader.js +109 -0
- package/dist/apps/control-plane/mcp/tool-registry-loader.js.map +1 -0
- package/dist/apps/control-plane/mcp/tool-runtime.d.ts +34 -0
- package/dist/apps/control-plane/mcp/tool-runtime.js +252 -0
- package/dist/apps/control-plane/mcp/tool-runtime.js.map +1 -0
- package/dist/apps/control-plane/mcp/tools-markdown-generator.d.ts +7 -0
- package/dist/apps/control-plane/mcp/tools-markdown-generator.js +22 -0
- package/dist/apps/control-plane/mcp/tools-markdown-generator.js.map +1 -0
- package/dist/apps/control-plane/mcp/transport-types.d.ts +14 -0
- package/dist/apps/control-plane/mcp/transport-types.js +2 -0
- package/dist/apps/control-plane/mcp/transport-types.js.map +1 -0
- package/dist/apps/control-plane/mcp/types.d.ts +2 -0
- package/dist/apps/control-plane/mcp/types.js +3 -0
- package/dist/apps/control-plane/mcp/types.js.map +1 -0
- package/dist/apps/control-plane/providers/providers.d.ts +72 -0
- package/dist/apps/control-plane/providers/providers.js +94 -0
- package/dist/apps/control-plane/providers/providers.js.map +1 -0
- package/dist/apps/control-plane/supervisor/build-wave-executor.d.ts +13 -0
- package/dist/apps/control-plane/supervisor/build-wave-executor.js +40 -0
- package/dist/apps/control-plane/supervisor/build-wave-executor.js.map +1 -0
- package/dist/apps/control-plane/supervisor/lease-heartbeat-service.d.ts +12 -0
- package/dist/apps/control-plane/supervisor/lease-heartbeat-service.js +14 -0
- package/dist/apps/control-plane/supervisor/lease-heartbeat-service.js.map +1 -0
- package/dist/apps/control-plane/supervisor/planning-wave-executor.d.ts +19 -0
- package/dist/apps/control-plane/supervisor/planning-wave-executor.js +249 -0
- package/dist/apps/control-plane/supervisor/planning-wave-executor.js.map +1 -0
- package/dist/apps/control-plane/supervisor/prompt-bundle-loader.d.ts +9 -0
- package/dist/apps/control-plane/supervisor/prompt-bundle-loader.js +53 -0
- package/dist/apps/control-plane/supervisor/prompt-bundle-loader.js.map +1 -0
- package/dist/apps/control-plane/supervisor/qa-wave-executor.d.ts +24 -0
- package/dist/apps/control-plane/supervisor/qa-wave-executor.js +70 -0
- package/dist/apps/control-plane/supervisor/qa-wave-executor.js.map +1 -0
- package/dist/apps/control-plane/supervisor/run-coordinator.d.ts +49 -0
- package/dist/apps/control-plane/supervisor/run-coordinator.js +162 -0
- package/dist/apps/control-plane/supervisor/run-coordinator.js.map +1 -0
- package/dist/apps/control-plane/supervisor/runtime.d.ts +58 -0
- package/dist/apps/control-plane/supervisor/runtime.js +270 -0
- package/dist/apps/control-plane/supervisor/runtime.js.map +1 -0
- package/dist/apps/control-plane/supervisor/session-orchestrator.d.ts +29 -0
- package/dist/apps/control-plane/supervisor/session-orchestrator.js +211 -0
- package/dist/apps/control-plane/supervisor/session-orchestrator.js.map +1 -0
- package/dist/apps/control-plane/supervisor/types.d.ts +148 -0
- package/dist/apps/control-plane/supervisor/types.js +2 -0
- package/dist/apps/control-plane/supervisor/types.js.map +1 -0
- package/dist/apps/control-plane/supervisor/worker-decision-loop.d.ts +37 -0
- package/dist/apps/control-plane/supervisor/worker-decision-loop.js +236 -0
- package/dist/apps/control-plane/supervisor/worker-decision-loop.js.map +1 -0
- package/docker/mcp.Dockerfile +14 -0
- package/docker/mcp.compose.yaml +15 -0
- package/docker/mcp.entrypoint.sh +17 -0
- package/eslint.config.mjs +93 -0
- package/example-configurations/README.md +26 -0
- package/example-configurations/java/agents.yaml +14 -0
- package/example-configurations/java/gates.yaml +29 -0
- package/example-configurations/java/policy.yaml +148 -0
- package/example-configurations/node/agents.yaml +14 -0
- package/example-configurations/node/gates.yaml +32 -0
- package/example-configurations/node/policy.yaml +143 -0
- package/nx.json +16 -0
- package/package.json +39 -0
- package/prompts/vitest-testing-standards.instructions.md +204 -0
- package/scripts/dev-shell-env.sh +7 -0
- package/scripts/nx-safe.mjs +33 -0
- package/spec-files/agentic_orchestrator_cli_delete_command_spec.md +310 -0
- package/spec-files/agentic_orchestrator_dot_aop_generated_artifacts_spec.md +211 -0
- package/spec-files/agentic_orchestrator_mcp_formalization_spec.md +379 -0
- package/spec-files/agentic_orchestrator_oop_refactor_spec.md +415 -0
- package/spec-files/agentic_orchestrator_single_global_orchestrator_spec.md +265 -0
- package/spec-files/agentic_orchestrator_spec.md +1334 -0
- package/spec-files/progress.md +452 -0
- package/tsconfig.base.json +15 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { fail, type FailResponse, type ToolResponse } from '../core/response.js';
|
|
2
|
+
import { ERROR_CODES } from '../core/error-codes.js';
|
|
3
|
+
import { stableHash } from '../core/fs.js';
|
|
4
|
+
import type { LoadedToolRegistry, ToolCatalogEntry, VerifiedActorClaims } from './runtime-types.js';
|
|
5
|
+
import type { ToolDescriptor } from './transport-types.js';
|
|
6
|
+
import { type ToolRegistryLoader } from './tool-registry-loader.js';
|
|
7
|
+
import { type ToolContractValidator } from './tool-contract-validator.js';
|
|
8
|
+
import { type ToolAuthorizer } from './tool-authorizer.js';
|
|
9
|
+
import { type OperationLedger } from './operation-ledger.js';
|
|
10
|
+
import { type KernelToolExecutor } from './kernel-tool-executor.js';
|
|
11
|
+
|
|
12
|
+
function canonicalize(value: unknown): unknown {
|
|
13
|
+
if (Array.isArray(value)) {
|
|
14
|
+
return value.map((item) => canonicalize(item));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (value && typeof value === 'object') {
|
|
18
|
+
const record = value as Record<string, unknown>;
|
|
19
|
+
const out: Record<string, unknown> = {};
|
|
20
|
+
for (const key of Object.keys(record).sort((a, b) => a.localeCompare(b))) {
|
|
21
|
+
out[key] = canonicalize(record[key]);
|
|
22
|
+
}
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function hashRequest(toolName: string, args: Record<string, unknown>): string {
|
|
30
|
+
const normalized = canonicalize({ tool_name: toolName, args });
|
|
31
|
+
return stableHash(JSON.stringify(normalized));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function normalizeOperationId(args: Record<string, unknown>): string | null {
|
|
35
|
+
const operationId = args.operation_id;
|
|
36
|
+
return typeof operationId === 'string' && operationId.length >= 8 ? operationId : null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function featureScopeAllows(claims: VerifiedActorClaims, args: Record<string, unknown>): boolean {
|
|
40
|
+
if (!claims.feature_scope || claims.feature_scope.length === 0) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const requestedFeature = args.feature_id;
|
|
45
|
+
if (typeof requestedFeature !== 'string') {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return claims.feature_scope.includes(requestedFeature);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function emitToolLog(params: {
|
|
53
|
+
claims: VerifiedActorClaims;
|
|
54
|
+
toolName: string;
|
|
55
|
+
args: Record<string, unknown>;
|
|
56
|
+
latencyMs: number;
|
|
57
|
+
response: ToolResponse;
|
|
58
|
+
}): void {
|
|
59
|
+
const operationId = typeof params.args.operation_id === 'string' ? params.args.operation_id : null;
|
|
60
|
+
const featureId = typeof params.args.feature_id === 'string' ? params.args.feature_id : null;
|
|
61
|
+
const errorCode = isFailResponse(params.response) ? params.response.error.code : null;
|
|
62
|
+
const payload = {
|
|
63
|
+
run_id: params.claims.run_id,
|
|
64
|
+
operation_id: operationId,
|
|
65
|
+
feature_id: featureId,
|
|
66
|
+
tool_name: params.toolName,
|
|
67
|
+
actor_type: params.claims.actor_type,
|
|
68
|
+
latency_ms: params.latencyMs,
|
|
69
|
+
result: params.response.ok ? 'ok' : 'error',
|
|
70
|
+
error_code: errorCode
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
process.stderr.write(`${JSON.stringify(payload)}\n`);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function isFailResponse(response: ToolResponse): response is FailResponse {
|
|
77
|
+
return response.ok === false;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export class ToolRuntime {
|
|
81
|
+
readonly registry: LoadedToolRegistry;
|
|
82
|
+
readonly loader: ToolRegistryLoader;
|
|
83
|
+
readonly validator: ToolContractValidator;
|
|
84
|
+
readonly authorizer: ToolAuthorizer;
|
|
85
|
+
readonly ledger: OperationLedger;
|
|
86
|
+
readonly executor: KernelToolExecutor;
|
|
87
|
+
|
|
88
|
+
constructor(params: {
|
|
89
|
+
registry: LoadedToolRegistry;
|
|
90
|
+
loader: ToolRegistryLoader;
|
|
91
|
+
validator: ToolContractValidator;
|
|
92
|
+
authorizer: ToolAuthorizer;
|
|
93
|
+
ledger: OperationLedger;
|
|
94
|
+
executor: KernelToolExecutor;
|
|
95
|
+
}) {
|
|
96
|
+
this.registry = params.registry;
|
|
97
|
+
this.loader = params.loader;
|
|
98
|
+
this.validator = params.validator;
|
|
99
|
+
this.authorizer = params.authorizer;
|
|
100
|
+
this.ledger = params.ledger;
|
|
101
|
+
this.executor = params.executor;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async listTools(): Promise<ToolDescriptor[]> {
|
|
105
|
+
const descriptors: ToolDescriptor[] = [];
|
|
106
|
+
const sorted = [...this.registry.toolsByName.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
107
|
+
|
|
108
|
+
for (const tool of sorted) {
|
|
109
|
+
descriptors.push({
|
|
110
|
+
name: tool.name,
|
|
111
|
+
description: tool.description,
|
|
112
|
+
input_schema: await this.loader.readSchemaByRef(tool.input_schema_ref),
|
|
113
|
+
output_schema: await this.loader.readSchemaByRef(tool.output_schema_ref),
|
|
114
|
+
mutating: tool.mutating,
|
|
115
|
+
requires_operation_id: tool.requires_operation_id
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return descriptors;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async callTool(toolName: string, args: Record<string, unknown>, claims: VerifiedActorClaims): Promise<ToolResponse> {
|
|
123
|
+
const started = Date.now();
|
|
124
|
+
const safeArgs = { ...(args ?? {}) };
|
|
125
|
+
const tool = this.lookupTool(toolName);
|
|
126
|
+
if (!tool) {
|
|
127
|
+
return this.finalize(started, claims, toolName, safeArgs, this.unknownToolResponse(toolName));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const scopeAuthorizationResult = this.authorizeFeatureScope(claims, safeArgs);
|
|
131
|
+
if (scopeAuthorizationResult) {
|
|
132
|
+
return this.finalize(started, claims, toolName, safeArgs, scopeAuthorizationResult);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const roleAuthorizationResult = this.authorizeRole(claims, toolName);
|
|
136
|
+
if (roleAuthorizationResult) {
|
|
137
|
+
return this.finalize(started, claims, toolName, safeArgs, roleAuthorizationResult);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const inputValidationResult = await this.validateInput(tool, toolName, safeArgs);
|
|
141
|
+
if (inputValidationResult) {
|
|
142
|
+
return this.finalize(started, claims, toolName, safeArgs, inputValidationResult);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const idempotencyResolution = await this.resolveIdempotency(tool, toolName, safeArgs, claims);
|
|
146
|
+
if (idempotencyResolution.result) {
|
|
147
|
+
return this.finalize(started, claims, toolName, safeArgs, idempotencyResolution.result);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const executionResponse = await this.executor.execute(tool, safeArgs, claims);
|
|
151
|
+
const outputValidationResult = await this.validateExecutionResponse(tool, toolName, executionResponse);
|
|
152
|
+
if (outputValidationResult) {
|
|
153
|
+
return this.finalize(started, claims, toolName, safeArgs, outputValidationResult);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (idempotencyResolution.operationId && idempotencyResolution.requestHash) {
|
|
157
|
+
await this.ledger.recordOperation(
|
|
158
|
+
claims.run_id,
|
|
159
|
+
idempotencyResolution.operationId,
|
|
160
|
+
toolName,
|
|
161
|
+
idempotencyResolution.requestHash,
|
|
162
|
+
executionResponse
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return this.finalize(started, claims, toolName, safeArgs, executionResponse);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
private lookupTool(toolName: string): ToolCatalogEntry | null {
|
|
170
|
+
return this.registry.toolsByName.get(toolName) ?? null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
private unknownToolResponse(toolName: string): ToolResponse {
|
|
174
|
+
return fail(ERROR_CODES.INVALID_ARGUMENT, `Unknown tool ${toolName}`, {
|
|
175
|
+
retryable: false,
|
|
176
|
+
requires_human: true
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
private authorizeFeatureScope(
|
|
181
|
+
claims: VerifiedActorClaims,
|
|
182
|
+
args: Record<string, unknown>
|
|
183
|
+
): ToolResponse | null {
|
|
184
|
+
if (featureScopeAllows(claims, args)) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
return fail(ERROR_CODES.FORBIDDEN_TOOL_FOR_ROLE, 'feature_scope_violation', {
|
|
188
|
+
retryable: false,
|
|
189
|
+
requires_human: true,
|
|
190
|
+
feature_scope: claims.feature_scope,
|
|
191
|
+
feature_id: args.feature_id
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
private authorizeRole(claims: VerifiedActorClaims, toolName: string): ToolResponse | null {
|
|
196
|
+
if (this.authorizer.isAuthorized(claims.actor_type, toolName)) {
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
return fail(ERROR_CODES.FORBIDDEN_TOOL_FOR_ROLE, `Tool ${toolName} is not allowed for role ${claims.actor_type}`, {
|
|
200
|
+
retryable: false,
|
|
201
|
+
requires_human: true,
|
|
202
|
+
actor_type: claims.actor_type,
|
|
203
|
+
tool_name: toolName
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
private async validateInput(
|
|
208
|
+
tool: ToolCatalogEntry,
|
|
209
|
+
toolName: string,
|
|
210
|
+
args: Record<string, unknown>
|
|
211
|
+
): Promise<ToolResponse | null> {
|
|
212
|
+
const inputValidation = await this.validator.validateInput(tool, args);
|
|
213
|
+
if (inputValidation.valid) {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
return fail(ERROR_CODES.INVALID_ARGUMENT, 'tool_input_schema_validation_failed', {
|
|
217
|
+
retryable: false,
|
|
218
|
+
requires_human: true,
|
|
219
|
+
errors: inputValidation.errors,
|
|
220
|
+
tool_name: toolName
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
private async validateExecutionResponse(
|
|
225
|
+
tool: ToolCatalogEntry,
|
|
226
|
+
toolName: string,
|
|
227
|
+
response: ToolResponse
|
|
228
|
+
): Promise<ToolResponse | null> {
|
|
229
|
+
if (response.ok) {
|
|
230
|
+
const outputValidation = await this.validator.validateOutput(tool, response.data);
|
|
231
|
+
if (outputValidation.valid) {
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
return fail(ERROR_CODES.INTERNAL_ERROR, 'tool_output_schema_validation_failed', {
|
|
235
|
+
retryable: false,
|
|
236
|
+
requires_human: true,
|
|
237
|
+
errors: outputValidation.errors,
|
|
238
|
+
tool_name: toolName
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const envelope = this.validator.validateErrorEnvelope(response);
|
|
243
|
+
if (envelope.valid) {
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
return fail(ERROR_CODES.INTERNAL_ERROR, 'tool_error_envelope_validation_failed', {
|
|
247
|
+
retryable: false,
|
|
248
|
+
requires_human: true,
|
|
249
|
+
errors: envelope.errors,
|
|
250
|
+
tool_name: toolName
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
private finalize(
|
|
255
|
+
started: number,
|
|
256
|
+
claims: VerifiedActorClaims,
|
|
257
|
+
toolName: string,
|
|
258
|
+
args: Record<string, unknown>,
|
|
259
|
+
response: ToolResponse
|
|
260
|
+
): ToolResponse {
|
|
261
|
+
emitToolLog({
|
|
262
|
+
claims,
|
|
263
|
+
toolName,
|
|
264
|
+
args,
|
|
265
|
+
latencyMs: Date.now() - started,
|
|
266
|
+
response
|
|
267
|
+
});
|
|
268
|
+
return response;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
private async resolveIdempotency(
|
|
272
|
+
tool: ToolCatalogEntry,
|
|
273
|
+
toolName: string,
|
|
274
|
+
args: Record<string, unknown>,
|
|
275
|
+
claims: VerifiedActorClaims
|
|
276
|
+
): Promise<{ operationId: string | null; requestHash: string | null; result: ToolResponse | null }> {
|
|
277
|
+
if (!tool.mutating) {
|
|
278
|
+
return { operationId: null, requestHash: null, result: null };
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
const operationId = normalizeOperationId(args);
|
|
282
|
+
if (tool.requires_operation_id && !operationId) {
|
|
283
|
+
return {
|
|
284
|
+
operationId: null,
|
|
285
|
+
requestHash: null,
|
|
286
|
+
result: fail(ERROR_CODES.OPERATION_ID_REQUIRED, 'operation_id is required for mutating tools', {
|
|
287
|
+
retryable: false,
|
|
288
|
+
requires_human: true,
|
|
289
|
+
tool_name: toolName
|
|
290
|
+
})
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
if (!operationId) {
|
|
294
|
+
return {
|
|
295
|
+
operationId: null,
|
|
296
|
+
requestHash: null,
|
|
297
|
+
result: fail(ERROR_CODES.OPERATION_ID_REQUIRED, 'operation_id is required for mutating tools', {
|
|
298
|
+
retryable: false,
|
|
299
|
+
requires_human: true,
|
|
300
|
+
tool_name: toolName
|
|
301
|
+
})
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const requestHash = hashRequest(toolName, args);
|
|
306
|
+
const dedupe = await this.ledger.resolveOperation(claims.run_id, operationId, requestHash);
|
|
307
|
+
if (dedupe.status === 'replay') {
|
|
308
|
+
return {
|
|
309
|
+
operationId,
|
|
310
|
+
requestHash,
|
|
311
|
+
result: dedupe.response
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (dedupe.status === 'mismatch') {
|
|
316
|
+
return {
|
|
317
|
+
operationId,
|
|
318
|
+
requestHash,
|
|
319
|
+
result: fail(ERROR_CODES.OPERATION_ID_REUSE_MISMATCH, 'operation_id_reuse_mismatch', {
|
|
320
|
+
retryable: false,
|
|
321
|
+
requires_human: true,
|
|
322
|
+
operation_id: operationId,
|
|
323
|
+
request_hash: requestHash,
|
|
324
|
+
existing_hash: dedupe.existing_hash,
|
|
325
|
+
tool_name: toolName
|
|
326
|
+
})
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
return {
|
|
331
|
+
operationId,
|
|
332
|
+
requestHash,
|
|
333
|
+
result: null
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { atomicWriteFile } from '../core/fs.js';
|
|
3
|
+
import type { ToolCatalog } from './runtime-types.js';
|
|
4
|
+
|
|
5
|
+
export class ToolsMarkdownGenerator {
|
|
6
|
+
readonly repoRoot: string;
|
|
7
|
+
|
|
8
|
+
constructor(repoRoot: string) {
|
|
9
|
+
this.repoRoot = repoRoot;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
renderFromCatalog(catalog: ToolCatalog): string {
|
|
13
|
+
const names = [...catalog.tools].map((tool) => tool.name).sort((a, b) => a.localeCompare(b));
|
|
14
|
+
const lines = ['# AOP MCP Tool Surface', '', 'Generated from `agentic/orchestrator/tools/catalog.json`.', ''];
|
|
15
|
+
for (const name of names) {
|
|
16
|
+
lines.push(`- ${name}`);
|
|
17
|
+
}
|
|
18
|
+
lines.push('');
|
|
19
|
+
return lines.join('\n');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async writeFromCatalog(catalog: ToolCatalog): Promise<void> {
|
|
23
|
+
const outPath = path.join(this.repoRoot, 'agentic', 'orchestrator', 'tools.md');
|
|
24
|
+
await atomicWriteFile(outPath, this.renderFromCatalog(catalog));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { VerifiedActorClaims } from './runtime-types.js';
|
|
2
|
+
|
|
3
|
+
export interface ToolDescriptor {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
input_schema: Record<string, unknown>;
|
|
7
|
+
output_schema: Record<string, unknown>;
|
|
8
|
+
mutating: boolean;
|
|
9
|
+
requires_operation_id: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ToolCallRequest {
|
|
13
|
+
tool_name: string;
|
|
14
|
+
args: Record<string, unknown>;
|
|
15
|
+
claims: VerifiedActorClaims;
|
|
16
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import { ERROR_CODES } from '../core/error-codes.js';
|
|
3
|
+
|
|
4
|
+
export interface AppError extends Error {
|
|
5
|
+
code?: string;
|
|
6
|
+
details?: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ProviderSelection {
|
|
10
|
+
provider: 'codex' | 'claude' | 'gemini' | 'custom';
|
|
11
|
+
model: string;
|
|
12
|
+
provider_config_env: string | null;
|
|
13
|
+
provider_config_ref: string | null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface ResolveSelectionInput {
|
|
17
|
+
cli: Record<string, string | undefined>;
|
|
18
|
+
env: NodeJS.ProcessEnv;
|
|
19
|
+
agentsConfig?: {
|
|
20
|
+
runtime?: {
|
|
21
|
+
default_provider?: string;
|
|
22
|
+
default_model?: string;
|
|
23
|
+
provider_config_env?: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const SUPPORTED_PROVIDERS = new Set<ProviderSelection['provider']>(['codex', 'claude', 'gemini', 'custom']);
|
|
29
|
+
export type ProviderSelectionResolver = (input: ResolveSelectionInput) => ProviderSelection;
|
|
30
|
+
|
|
31
|
+
export const resolveProviderSelection: ProviderSelectionResolver = ({ cli, env, agentsConfig }) => {
|
|
32
|
+
const provider =
|
|
33
|
+
cli.agent_provider ||
|
|
34
|
+
env.AOP_AGENT_PROVIDER ||
|
|
35
|
+
agentsConfig?.runtime?.default_provider ||
|
|
36
|
+
null;
|
|
37
|
+
|
|
38
|
+
const model =
|
|
39
|
+
cli.agent_model ||
|
|
40
|
+
env.AOP_AGENT_MODEL ||
|
|
41
|
+
agentsConfig?.runtime?.default_model ||
|
|
42
|
+
null;
|
|
43
|
+
|
|
44
|
+
const providerConfigEnv =
|
|
45
|
+
cli.provider_config_env ||
|
|
46
|
+
env.AOP_PROVIDER_CONFIG_ENV ||
|
|
47
|
+
agentsConfig?.runtime?.provider_config_env ||
|
|
48
|
+
null;
|
|
49
|
+
|
|
50
|
+
if (!provider) {
|
|
51
|
+
const error = new Error(ERROR_CODES.AGENT_PROVIDER_NOT_CONFIGURED) as AppError;
|
|
52
|
+
error.code = ERROR_CODES.AGENT_PROVIDER_NOT_CONFIGURED;
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!SUPPORTED_PROVIDERS.has(provider as ProviderSelection['provider'])) {
|
|
57
|
+
const error = new Error(ERROR_CODES.UNSUPPORTED_AGENT_PROVIDER) as AppError;
|
|
58
|
+
error.code = ERROR_CODES.UNSUPPORTED_AGENT_PROVIDER;
|
|
59
|
+
error.details = { provider };
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (provider !== 'custom' && (!providerConfigEnv || !env[providerConfigEnv])) {
|
|
64
|
+
const error = new Error(ERROR_CODES.PROVIDER_AUTH_MISSING) as AppError;
|
|
65
|
+
error.code = ERROR_CODES.PROVIDER_AUTH_MISSING;
|
|
66
|
+
error.details = {
|
|
67
|
+
provider,
|
|
68
|
+
provider_config_env: providerConfigEnv
|
|
69
|
+
};
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
provider: provider as ProviderSelection['provider'],
|
|
75
|
+
model: model ?? `${provider}-default`,
|
|
76
|
+
provider_config_env: providerConfigEnv,
|
|
77
|
+
provider_config_ref: providerConfigEnv ? env[providerConfigEnv] ?? null : null
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export interface WorkerSession {
|
|
82
|
+
session_id: string;
|
|
83
|
+
role: string;
|
|
84
|
+
feature_id: string;
|
|
85
|
+
system_prompt_loaded: boolean;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface WorkerProvider {
|
|
89
|
+
selection: ProviderSelection;
|
|
90
|
+
createSession(role: string, featureId: string, systemPrompt: string | null): Promise<WorkerSession>;
|
|
91
|
+
reattachSession(sessionId: string): Promise<WorkerSession | null>;
|
|
92
|
+
closeSession(sessionId: string): Promise<{ closed: true }>;
|
|
93
|
+
runWorker(input: {
|
|
94
|
+
role: string;
|
|
95
|
+
feature_id: string;
|
|
96
|
+
context_bundle?: Record<string, unknown>;
|
|
97
|
+
instructions?: string;
|
|
98
|
+
last_tool_results?: Array<Record<string, unknown>>;
|
|
99
|
+
runtime_selection?: {
|
|
100
|
+
provider: string;
|
|
101
|
+
model: string;
|
|
102
|
+
provider_config_ref: string | null;
|
|
103
|
+
};
|
|
104
|
+
}): Promise<Record<string, unknown>>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export class NullWorkerProvider implements WorkerProvider {
|
|
108
|
+
selection: ProviderSelection;
|
|
109
|
+
|
|
110
|
+
constructor(selection: ProviderSelection) {
|
|
111
|
+
this.selection = selection;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
createSession(role: string, featureId: string, systemPrompt: string | null): Promise<WorkerSession> {
|
|
115
|
+
return Promise.resolve({
|
|
116
|
+
session_id: `${role}-${featureId}-${crypto.randomUUID()}`,
|
|
117
|
+
role,
|
|
118
|
+
feature_id: featureId,
|
|
119
|
+
system_prompt_loaded: Boolean(systemPrompt)
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
reattachSession(sessionId: string): Promise<WorkerSession | null> {
|
|
123
|
+
if (!sessionId || sessionId === 'unknown') {
|
|
124
|
+
return Promise.resolve(null);
|
|
125
|
+
}
|
|
126
|
+
return Promise.resolve({
|
|
127
|
+
session_id: sessionId,
|
|
128
|
+
role: 'orchestrator',
|
|
129
|
+
feature_id: 'global',
|
|
130
|
+
system_prompt_loaded: false
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
closeSession(_sessionId: string): Promise<{ closed: true }> {
|
|
134
|
+
return Promise.resolve({ closed: true });
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
runWorker({
|
|
138
|
+
role,
|
|
139
|
+
feature_id,
|
|
140
|
+
context_bundle
|
|
141
|
+
}: {
|
|
142
|
+
role: string;
|
|
143
|
+
feature_id: string;
|
|
144
|
+
context_bundle?: Record<string, unknown>;
|
|
145
|
+
instructions?: string;
|
|
146
|
+
last_tool_results?: Array<Record<string, unknown>>;
|
|
147
|
+
runtime_selection?: {
|
|
148
|
+
provider: string;
|
|
149
|
+
model: string;
|
|
150
|
+
provider_config_ref: string | null;
|
|
151
|
+
};
|
|
152
|
+
}): Promise<Record<string, unknown>> {
|
|
153
|
+
if (role === 'planner') {
|
|
154
|
+
const state = context_bundle?.state;
|
|
155
|
+
const frontMatter =
|
|
156
|
+
state && typeof state === 'object'
|
|
157
|
+
? (state as Record<string, unknown>).front_matter
|
|
158
|
+
: null;
|
|
159
|
+
const status =
|
|
160
|
+
frontMatter && typeof frontMatter === 'object'
|
|
161
|
+
? (frontMatter as Record<string, unknown>).status
|
|
162
|
+
: null;
|
|
163
|
+
return Promise.resolve({
|
|
164
|
+
type: 'NOTE',
|
|
165
|
+
content: `Planner session active for ${feature_id}.`,
|
|
166
|
+
context_snapshot: {
|
|
167
|
+
status: typeof status === 'string' ? status : 'unknown'
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return Promise.resolve({
|
|
173
|
+
type: 'NOTE',
|
|
174
|
+
content: `${role} session active for ${feature_id}.`
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { STATUS, TOOLS } from '../core/constants.js';
|
|
2
|
+
import type { FeatureStatePayload, SupervisorToolCaller } from './types.js';
|
|
3
|
+
import { NOOP_WORKER_DECISION_RUNNER, type WorkerDecisionRunner } from './worker-decision-loop.js';
|
|
4
|
+
|
|
5
|
+
interface BuildWaveExecutorDependencies {
|
|
6
|
+
toolCaller: SupervisorToolCaller;
|
|
7
|
+
workerDecisionRunner?: WorkerDecisionRunner;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class BuildWaveExecutor {
|
|
11
|
+
private readonly toolCaller: SupervisorToolCaller;
|
|
12
|
+
private readonly workerDecisionRunner: WorkerDecisionRunner;
|
|
13
|
+
|
|
14
|
+
constructor(dependencies: BuildWaveExecutorDependencies) {
|
|
15
|
+
this.toolCaller = dependencies.toolCaller;
|
|
16
|
+
this.workerDecisionRunner = dependencies.workerDecisionRunner ?? NOOP_WORKER_DECISION_RUNNER;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async run(featureIds: string[], maxParallelGateRuns: number): Promise<void> {
|
|
20
|
+
const batch: string[] = [];
|
|
21
|
+
for (const featureId of featureIds) {
|
|
22
|
+
const state = await this.toolCaller.callTool<FeatureStatePayload>('builder', TOOLS.FEATURE_STATE_GET, {
|
|
23
|
+
feature_id: featureId
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (state.data.front_matter.status === STATUS.BUILDING) {
|
|
27
|
+
batch.push(featureId);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const selected = batch.slice(0, maxParallelGateRuns);
|
|
32
|
+
for (const featureId of selected) {
|
|
33
|
+
const context = await this.toolCaller.callTool('builder', TOOLS.FEATURE_GET_CONTEXT, {
|
|
34
|
+
feature_id: featureId
|
|
35
|
+
});
|
|
36
|
+
await this.workerDecisionRunner.execute({
|
|
37
|
+
role: 'builder',
|
|
38
|
+
featureId,
|
|
39
|
+
contextBundle: context.data,
|
|
40
|
+
instructions:
|
|
41
|
+
'Emit PATCH outputs for code changes, NOTE outputs for progress context, and REQUEST outputs for lock/context needs.'
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const executing = selected.map((featureId) =>
|
|
46
|
+
this.toolCaller.callTool('builder', TOOLS.GATES_RUN, {
|
|
47
|
+
feature_id: featureId,
|
|
48
|
+
profile: null,
|
|
49
|
+
mode: 'fast'
|
|
50
|
+
})
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
await Promise.allSettled(executing);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { FeatureOrchestrationPort, SupervisorRuntimeState } from './types.js';
|
|
2
|
+
|
|
3
|
+
interface LeaseHeartbeatServiceDependencies {
|
|
4
|
+
kernel: FeatureOrchestrationPort;
|
|
5
|
+
state: SupervisorRuntimeState;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class LeaseHeartbeatService {
|
|
9
|
+
private readonly kernel: FeatureOrchestrationPort;
|
|
10
|
+
private readonly state: SupervisorRuntimeState;
|
|
11
|
+
|
|
12
|
+
constructor(dependencies: LeaseHeartbeatServiceDependencies) {
|
|
13
|
+
this.kernel = dependencies.kernel;
|
|
14
|
+
this.state = dependencies.state;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async renew(): Promise<void> {
|
|
18
|
+
const featureIds = [...this.state.sessionsByFeature.keys()];
|
|
19
|
+
await this.kernel.renewLeases(featureIds);
|
|
20
|
+
await this.kernel.renewRunLease(this.state.runId, this.state.ownerInstanceId);
|
|
21
|
+
}
|
|
22
|
+
}
|