stageflow 0.23.0 → 0.27.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/README.md +24 -5
- package/dist/a2a/configDiscovery.d.ts +9 -0
- package/dist/a2a/configDiscovery.js +18 -0
- package/dist/a2a/contracts.d.ts +94 -0
- package/dist/a2a/contracts.js +164 -0
- package/dist/a2a/limits.d.ts +14 -0
- package/dist/a2a/limits.js +29 -0
- package/dist/a2a/registry.d.ts +46 -0
- package/dist/a2a/registry.js +178 -0
- package/dist/a2a/server.d.ts +36 -0
- package/dist/a2a/server.js +344 -0
- package/dist/a2a/service.d.ts +97 -0
- package/dist/a2a/service.js +545 -0
- package/dist/a2a/store.d.ts +109 -0
- package/dist/a2a/store.js +202 -0
- package/dist/agent/activity.d.ts +3 -0
- package/dist/agent/bootProviderConfig.d.ts +21 -0
- package/dist/agent/bootProviderConfig.js +74 -0
- package/dist/agent/piAdapter.d.ts +9 -1
- package/dist/agent/piAdapter.js +58 -3
- package/dist/agent/piIsolatedMcp.d.ts +2 -0
- package/dist/agent/piIsolatedMcp.js +10 -2
- package/dist/agent/port.d.ts +6 -0
- package/dist/agent/streamLogRedact.d.ts +1 -1
- package/dist/agent/streamLogRedact.js +4 -11
- package/dist/cli/a2aCommand.d.ts +8 -0
- package/dist/cli/a2aCommand.js +131 -0
- package/dist/cli/artifactCommand.js +9 -16
- package/dist/cli/backupCommand.d.ts +9 -0
- package/dist/cli/backupCommand.js +111 -0
- package/dist/cli/debugRunCommand.d.ts +10 -0
- package/dist/cli/debugRunCommand.js +109 -0
- package/dist/cli/doctorCommand.d.ts +32 -0
- package/dist/cli/doctorCommand.js +453 -0
- package/dist/cli/envelopeCommand.js +9 -2
- package/dist/cli/exportAllCommand.d.ts +55 -0
- package/dist/cli/exportAllCommand.js +218 -0
- package/dist/cli/exportRunCommand.js +23 -21
- package/dist/cli/hostClient.d.ts +21 -3
- package/dist/cli/hostClient.js +93 -12
- package/dist/cli/initTemplates.d.ts +1 -1
- package/dist/cli/initTemplates.js +8 -1
- package/dist/cli/resolveSafeOutPath.d.ts +2 -0
- package/dist/cli/resolveSafeOutPath.js +40 -0
- package/dist/cli/restoreCommand.d.ts +10 -0
- package/dist/cli/restoreCommand.js +90 -0
- package/dist/cli/runCommand.d.ts +3 -2
- package/dist/cli/runCommand.js +93 -11
- package/dist/cli/runOutput.d.ts +4 -0
- package/dist/cli/runOutput.js +33 -7
- package/dist/cli/runStageCommand.d.ts +34 -0
- package/dist/cli/runStageCommand.js +426 -0
- package/dist/cli/runsCommand.d.ts +1 -1
- package/dist/cli/runsCommand.js +162 -8
- package/dist/cli.js +190 -30
- package/dist/config/catalogRelativePath.d.ts +62 -0
- package/dist/config/catalogRelativePath.js +118 -0
- package/dist/config/configOrigin.d.ts +27 -0
- package/dist/config/configOrigin.js +59 -0
- package/dist/config/hostConfig.d.ts +55 -0
- package/dist/config/hostConfig.js +333 -0
- package/dist/config/listSkills.d.ts +26 -0
- package/dist/config/listSkills.js +190 -3
- package/dist/config/loadOutcome.d.ts +1 -1
- package/dist/config/loadPipeline.js +23 -2
- package/dist/config/loadStage.js +18 -0
- package/dist/config/loadTask.d.ts +2 -0
- package/dist/config/loadTask.js +57 -18
- package/dist/config/materializeStageModels.js +5 -1
- package/dist/config/mergePipelineIncludes.d.ts +3 -0
- package/dist/config/mergePipelineIncludes.js +19 -0
- package/dist/config/migrateYaml.js +6 -11
- package/dist/config/multiProjectCatalog.d.ts +30 -0
- package/dist/config/multiProjectCatalog.js +142 -0
- package/dist/config/normalizePipelineStageEntry.js +20 -1
- package/dist/config/pipelineStageKeys.js +2 -0
- package/dist/config/resolveCatalogRoots.d.ts +27 -0
- package/dist/config/resolveCatalogRoots.js +76 -0
- package/dist/config/resolveModel.d.ts +7 -1
- package/dist/config/resolveModel.js +11 -1
- package/dist/config/resolveStageMcpServers.d.ts +9 -1
- package/dist/config/resolveStageMcpServers.js +36 -9
- package/dist/config/secretFromEnvOrFile.d.ts +9 -0
- package/dist/config/secretFromEnvOrFile.js +34 -0
- package/dist/config/seededCatalog.d.ts +11 -0
- package/dist/config/seededCatalog.js +29 -0
- package/dist/config/toolRequires.d.ts +24 -0
- package/dist/config/toolRequires.js +115 -0
- package/dist/config/validateCatalog.d.ts +5 -1
- package/dist/config/validateCatalog.js +140 -1
- package/dist/diagnostics/checks.d.ts +39 -0
- package/dist/diagnostics/checks.js +135 -0
- package/dist/errors/codes.d.ts +14 -0
- package/dist/errors/codes.js +59 -0
- package/dist/git/cache.d.ts +14 -0
- package/dist/git/cache.js +150 -0
- package/dist/git/credentials.d.ts +9 -0
- package/dist/git/credentials.js +88 -0
- package/dist/git/errors.d.ts +20 -0
- package/dist/git/errors.js +94 -0
- package/dist/git/exec.d.ts +16 -0
- package/dist/git/exec.js +135 -0
- package/dist/git/operations.d.ts +29 -0
- package/dist/git/operations.js +153 -0
- package/dist/git/version.d.ts +1 -0
- package/dist/git/version.js +10 -0
- package/dist/logging/audit.d.ts +16 -0
- package/dist/logging/audit.js +19 -0
- package/dist/logging/commonWords.d.ts +2 -0
- package/dist/logging/commonWords.js +13 -0
- package/dist/logging/logger.d.ts +49 -0
- package/dist/logging/logger.js +193 -0
- package/dist/logging/namedSecrets.d.ts +6 -0
- package/dist/logging/namedSecrets.js +58 -0
- package/dist/logging/redact.d.ts +13 -0
- package/dist/logging/redact.js +88 -0
- package/dist/mcp/catalogTools.js +591 -76
- package/dist/mcp/checkoutTools.d.ts +52 -0
- package/dist/mcp/checkoutTools.js +332 -0
- package/dist/mcp/controlTools.js +179 -5
- package/dist/mcp/deps.d.ts +1 -0
- package/dist/mcp/getStartedTool.d.ts +3 -0
- package/dist/mcp/getStartedTool.js +62 -0
- package/dist/mcp/readArtifact.d.ts +11 -0
- package/dist/mcp/readArtifact.js +46 -30
- package/dist/mcp/server.js +1 -0
- package/dist/mcp/tools.js +4 -0
- package/dist/net/proxy.d.ts +14 -0
- package/dist/net/proxy.js +78 -0
- package/dist/package-meta.d.ts +2 -1
- package/dist/package-meta.js +2 -1
- package/dist/preflight/bash.d.ts +8 -0
- package/dist/preflight/bash.js +34 -0
- package/dist/preflight/claudeRoot.d.ts +11 -0
- package/dist/preflight/claudeRoot.js +23 -0
- package/dist/preflight/mcpCommands.d.ts +8 -0
- package/dist/preflight/mcpCommands.js +36 -0
- package/dist/preflight/pipelinePreflight.d.ts +40 -0
- package/dist/preflight/pipelinePreflight.js +192 -0
- package/dist/preflight/tls.d.ts +6 -0
- package/dist/preflight/tls.js +18 -0
- package/dist/preflight/toolchain.d.ts +45 -0
- package/dist/preflight/toolchain.js +219 -0
- package/dist/project/findProjectRoot.js +3 -4
- package/dist/project/globalHome.d.ts +7 -0
- package/dist/project/globalHome.js +63 -2
- package/dist/project/resolveProjectContext.js +2 -2
- package/dist/project/resolveStageflowContext.js +2 -2
- package/dist/projection/projectRun.d.ts +2 -1
- package/dist/projection/projectRun.js +1 -0
- package/dist/runstore/assertTmpdir.d.ts +1 -0
- package/dist/runstore/assertTmpdir.js +21 -0
- package/dist/runstore/backup.d.ts +52 -0
- package/dist/runstore/backup.js +292 -0
- package/dist/runstore/createStore.d.ts +27 -0
- package/dist/runstore/createStore.js +75 -7
- package/dist/runstore/debugBundle.d.ts +60 -0
- package/dist/runstore/debugBundle.js +143 -0
- package/dist/runstore/diskUsage.d.ts +50 -0
- package/dist/runstore/diskUsage.js +214 -0
- package/dist/runstore/exportRunPayload.d.ts +8 -0
- package/dist/runstore/exportRunPayload.js +23 -0
- package/dist/runstore/normalizeCatalogPath.d.ts +1 -0
- package/dist/runstore/normalizeCatalogPath.js +10 -0
- package/dist/runstore/paths.d.ts +5 -0
- package/dist/runstore/paths.js +145 -1
- package/dist/runstore/port.d.ts +119 -8
- package/dist/runstore/port.js +8 -1
- package/dist/runstore/restore.d.ts +81 -0
- package/dist/runstore/restore.js +355 -0
- package/dist/runstore/retention.d.ts +27 -0
- package/dist/runstore/retention.js +74 -0
- package/dist/runstore/runManifest.d.ts +146 -0
- package/dist/runstore/runManifest.js +288 -0
- package/dist/runstore/runProjection.d.ts +3 -1
- package/dist/runstore/runProjection.js +63 -1
- package/dist/runstore/sqlite/SqliteRunStore.d.ts +37 -3
- package/dist/runstore/sqlite/SqliteRunStore.js +401 -227
- package/dist/runstore/sqlite/applyStorePragmas.d.ts +39 -0
- package/dist/runstore/sqlite/applyStorePragmas.js +145 -0
- package/dist/runstore/sqlite/migrations/001-baseline.d.ts +7 -0
- package/dist/runstore/sqlite/migrations/001-baseline.js +10 -0
- package/dist/runstore/sqlite/migrations/002-repository-binding.d.ts +7 -0
- package/dist/runstore/sqlite/migrations/002-repository-binding.js +29 -0
- package/dist/runstore/sqlite/migrations/003-run-lifecycle.d.ts +7 -0
- package/dist/runstore/sqlite/migrations/003-run-lifecycle.js +28 -0
- package/dist/runstore/sqlite/migrations/004-auto-resume-count.d.ts +7 -0
- package/dist/runstore/sqlite/migrations/004-auto-resume-count.js +19 -0
- package/dist/runstore/sqlite/migrations/005-config-origins.d.ts +7 -0
- package/dist/runstore/sqlite/migrations/005-config-origins.js +19 -0
- package/dist/runstore/sqlite/migrations/006-pipeline-body-and-caller.d.ts +7 -0
- package/dist/runstore/sqlite/migrations/006-pipeline-body-and-caller.js +28 -0
- package/dist/runstore/sqlite/migrations/007-projects-registry.d.ts +7 -0
- package/dist/runstore/sqlite/migrations/007-projects-registry.js +31 -0
- package/dist/runstore/sqlite/migrations/index.d.ts +21 -0
- package/dist/runstore/sqlite/migrations/index.js +72 -0
- package/dist/runstore/sqlite/schema.d.ts +20 -1
- package/dist/runstore/sqlite/schema.js +283 -1
- package/dist/runstore/sqlite/storeOpenError.d.ts +6 -0
- package/dist/runstore/sqlite/storeOpenError.js +11 -0
- package/dist/runstore/sqlite/storeSchemaError.d.ts +5 -0
- package/dist/runstore/sqlite/storeSchemaError.js +8 -0
- package/dist/runstore/stageExecution.js +3 -0
- package/dist/runstore/storeFilesystem.d.ts +32 -0
- package/dist/runstore/storeFilesystem.js +148 -0
- package/dist/runstore/submission.d.ts +11 -0
- package/dist/runstore/submission.js +7 -0
- package/dist/runstore/trackProjection.js +2 -0
- package/dist/runstore/workspaceLayout.d.ts +13 -0
- package/dist/runstore/workspaceLayout.js +76 -0
- package/dist/runtime/completionCheckRunner.d.ts +3 -0
- package/dist/runtime/completionCheckRunner.js +45 -7
- package/dist/runtime/containerLimits.d.ts +16 -0
- package/dist/runtime/containerLimits.js +84 -0
- package/dist/runtime/credentialMaterialisation.d.ts +28 -0
- package/dist/runtime/credentialMaterialisation.js +128 -0
- package/dist/runtime/gitCheckoutCapability.js +7 -13
- package/dist/runtime/pipelineRunner.d.ts +38 -1
- package/dist/runtime/pipelineRunner.js +179 -15
- package/dist/runtime/pipelineScheduler.d.ts +15 -0
- package/dist/runtime/pipelineScheduler.js +167 -42
- package/dist/runtime/reloadRunCatalog.js +12 -1
- package/dist/runtime/repositoryMaterialize.d.ts +47 -0
- package/dist/runtime/repositoryMaterialize.js +235 -0
- package/dist/runtime/resolveEnvelopeRef.d.ts +30 -0
- package/dist/runtime/resolveEnvelopeRef.js +79 -0
- package/dist/runtime/resumeTimedOut.d.ts +1 -1
- package/dist/runtime/resumeTimedOut.js +5 -2
- package/dist/runtime/runChangeBus.js +9 -0
- package/dist/runtime/runDeletion.d.ts +7 -0
- package/dist/runtime/runDeletion.js +37 -0
- package/dist/runtime/runManager.d.ts +179 -4
- package/dist/runtime/runManager.js +1644 -83
- package/dist/runtime/runRetentionSweep.d.ts +31 -0
- package/dist/runtime/runRetentionSweep.js +328 -0
- package/dist/runtime/runRetryCoordinator.d.ts +2 -0
- package/dist/runtime/runRetryCoordinator.js +19 -2
- package/dist/runtime/runSkills.d.ts +40 -0
- package/dist/runtime/runSkills.js +173 -0
- package/dist/runtime/stageAttemptBootstrap.d.ts +5 -1
- package/dist/runtime/stageAttemptBootstrap.js +195 -24
- package/dist/runtime/stageCacheEnv.d.ts +6 -0
- package/dist/runtime/stageCacheEnv.js +34 -0
- package/dist/runtime/stageConcurrency.d.ts +2 -1
- package/dist/runtime/stageConcurrency.js +4 -2
- package/dist/runtime/stageEnvironment.d.ts +38 -0
- package/dist/runtime/stageEnvironment.js +193 -0
- package/dist/runtime/stageProcessLauncher.d.ts +18 -0
- package/dist/runtime/stageProcessLauncher.js +194 -38
- package/dist/runtime/stageRecovery.d.ts +3 -1
- package/dist/runtime/stageRecovery.js +19 -4
- package/dist/runtime/stageRoots.d.ts +38 -1
- package/dist/runtime/stageRoots.js +118 -0
- package/dist/runtime/stageRunner.d.ts +1 -0
- package/dist/runtime/stageRunner.js +3 -1
- package/dist/runtime/stageSecretDecl.d.ts +9 -0
- package/dist/runtime/stageSecretDecl.js +102 -0
- package/dist/runtime/stageSecrets.d.ts +40 -0
- package/dist/runtime/stageSecrets.js +181 -0
- package/dist/runtime/stageWorker.d.ts +3 -2
- package/dist/runtime/stageWorker.js +58 -10
- package/dist/runtime/stageWorkerProtocol.d.ts +5 -0
- package/dist/runtime/stageWorkerProtocol.js +8 -0
- package/dist/runtime/startPayload.d.ts +32 -0
- package/dist/runtime/startPayload.js +59 -0
- package/dist/runtime/taskInput.js +14 -5
- package/dist/runtime/verifiedStageExecution.d.ts +1 -0
- package/dist/runtime/verifiedStageExecution.js +2 -1
- package/dist/runtime/workspaceBinding.d.ts +20 -0
- package/dist/runtime/workspaceBinding.js +60 -0
- package/dist/server/allowedHosts.d.ts +19 -0
- package/dist/server/allowedHosts.js +179 -0
- package/dist/server/bootstrap.d.ts +38 -2
- package/dist/server/bootstrap.js +219 -4
- package/dist/server/controlToken.d.ts +47 -0
- package/dist/server/controlToken.js +241 -0
- package/dist/server/createHttpHost.d.ts +11 -2
- package/dist/server/createHttpHost.js +109 -10
- package/dist/server/ensureGlobalService.d.ts +5 -1
- package/dist/server/ensureGlobalService.js +35 -1
- package/dist/server/healthSurfaces.d.ts +6 -0
- package/dist/server/healthSurfaces.js +98 -0
- package/dist/server/http.d.ts +12 -1
- package/dist/server/http.js +1085 -485
- package/dist/server/listenHost.d.ts +5 -0
- package/dist/server/listenHost.js +56 -0
- package/dist/server/mcpHost.d.ts +10 -1
- package/dist/server/mcpHost.js +36 -6
- package/dist/server/operatorResults.d.ts +2 -2
- package/dist/server/operatorResults.js +40 -29
- package/dist/server/requestAuthContext.d.ts +12 -0
- package/dist/server/requestAuthContext.js +21 -0
- package/dist/server/shutdown.d.ts +69 -0
- package/dist/server/shutdown.js +219 -0
- package/dist/types/pipeline.d.ts +7 -0
- package/dist/types/stage.d.ts +8 -0
- package/dist/types/task.d.ts +8 -0
- package/dist/ui/assets/index-B6hlSXXn.js +120 -0
- package/dist/ui/index.html +1 -1
- package/examples/README.md +98 -0
- package/examples/archify-on-pr/README.md +213 -0
- package/examples/archify-on-pr/archify-on-pr.pipeline.yaml +19 -0
- package/examples/archify-on-pr/archify-on-pr.task.yaml +19 -0
- package/examples/archify-on-pr/author-diagrams.yaml +106 -0
- package/examples/archify-on-pr/detect-changes.yaml +89 -0
- package/examples/ci-validate/README.md +35 -0
- package/examples/ci-validate/check.yaml +13 -0
- package/examples/ci-validate/ci-demo.pipeline.yaml +4 -0
- package/examples/ci-validate/validate.sh +5 -0
- package/examples/compliance-review-demo/README.md +125 -0
- package/examples/compliance-review-demo/compliance-review-demo.pipeline.yaml +29 -0
- package/examples/compliance-review-demo/connect-account.yaml +47 -0
- package/examples/compliance-review-demo/map-to-control.yaml +123 -0
- package/examples/compliance-review-demo/poll-bucket-config.yaml +103 -0
- package/examples/compliance-review-demo/publish-report.yaml +79 -0
- package/examples/compliance-review-demo/review-verdict.yaml +122 -0
- package/examples/compliance-review-demo/run-compliance-check.yaml +96 -0
- package/examples/compliance-review-demo/store-evidence.yaml +143 -0
- package/examples/conditional-fork/README.md +89 -0
- package/examples/conditional-fork/branch-a.yaml +13 -0
- package/examples/conditional-fork/branch-b.yaml +13 -0
- package/examples/conditional-fork/decide.yaml +35 -0
- package/examples/conditional-fork/fork-demo.pipeline.yaml +20 -0
- package/examples/conditional-fork/fork-demo.task.yaml +8 -0
- package/examples/context7-mcp/README.md +42 -0
- package/examples/context7-mcp/context7-mcp.pipeline.yaml +15 -0
- package/examples/context7-mcp/context7-mcp.task.yaml +4 -0
- package/examples/context7-mcp/fetch-docs.yaml +52 -0
- package/examples/context7-mcp/resolve-library.yaml +31 -0
- package/examples/context7-mcp/write-brief.yaml +52 -0
- package/examples/feature-loop/README.md +104 -0
- package/examples/feature-loop/address-feedback.yaml +148 -0
- package/examples/feature-loop/align.yaml +116 -0
- package/examples/feature-loop/decompose.yaml +86 -0
- package/examples/feature-loop/default-model-hierarchy.task.yaml +58 -0
- package/examples/feature-loop/feature-loop.pipeline.yaml +140 -0
- package/examples/feature-loop/feature-loop.task.yaml +25 -0
- package/examples/feature-loop/implement.yaml +128 -0
- package/examples/feature-loop/plan.yaml +111 -0
- package/examples/feature-loop/publish.yaml +167 -0
- package/examples/feature-loop/review.yaml +146 -0
- package/examples/feature-loop/verify.yaml +106 -0
- package/examples/feedback-loop/README.md +72 -0
- package/examples/feedback-loop/VERIFY.md +208 -0
- package/examples/feedback-loop/continue-only.task.yaml +4 -0
- package/examples/feedback-loop/exhaust-require-continue.task.yaml +6 -0
- package/examples/feedback-loop/exhaust-wait-human.task.yaml +11 -0
- package/examples/feedback-loop/feedback-loop-wait-human.pipeline.yaml +23 -0
- package/examples/feedback-loop/feedback-loop.pipeline.yaml +23 -0
- package/examples/feedback-loop/feedback-loop.task.yaml +4 -0
- package/examples/feedback-loop/implement.yaml +14 -0
- package/examples/feedback-loop/plan.yaml +14 -0
- package/examples/feedback-loop/review.yaml +15 -0
- package/examples/feedback-loop/send-back-once.task.yaml +6 -0
- package/examples/feedback-loop/submit.yaml +12 -0
- package/examples/generic-fan-in/README.md +151 -0
- package/examples/generic-fan-in/clarify.yaml +18 -0
- package/examples/generic-fan-in/generic-fan-in-accepted.pipeline.yaml +19 -0
- package/examples/generic-fan-in/generic-fan-in-accepted.task.yaml +8 -0
- package/examples/generic-fan-in/generic-fan-in.pipeline.yaml +18 -0
- package/examples/generic-fan-in/generic-fan-in.task.yaml +9 -0
- package/examples/generic-fan-in/research.yaml +45 -0
- package/examples/generic-fan-in/synthesize.yaml +66 -0
- package/examples/generic-fan-in/validation.yaml +45 -0
- package/examples/github-release/README.md +78 -0
- package/examples/github-release/draft-release-notes.yaml +64 -0
- package/examples/github-release/github-release.pipeline.yaml +11 -0
- package/examples/github-release/github-release.task.yaml +13 -0
- package/examples/github-release/publish-github-release.yaml +64 -0
- package/examples/hello-world/README.md +28 -0
- package/examples/hello-world/hello.pipeline.yaml +4 -0
- package/examples/hello-world/my-task.task.yaml +6 -0
- package/examples/hello-world/research.yaml +18 -0
- package/examples/mcp-hitl-tour/README.md +113 -0
- package/examples/mcp-hitl-tour/draft-angle.yaml +33 -0
- package/examples/mcp-hitl-tour/draft-short.yaml +32 -0
- package/examples/mcp-hitl-tour/emit-angles.yaml +45 -0
- package/examples/mcp-hitl-tour/gather.yaml +31 -0
- package/examples/mcp-hitl-tour/intake.yaml +62 -0
- package/examples/mcp-hitl-tour/mcp-hitl-tour-exhaust.task.yaml +13 -0
- package/examples/mcp-hitl-tour/mcp-hitl-tour.pipeline.yaml +54 -0
- package/examples/mcp-hitl-tour/mcp-hitl-tour.task.yaml +16 -0
- package/examples/mcp-hitl-tour/polish.yaml +33 -0
- package/examples/mcp-hitl-tour/review.yaml +17 -0
- package/examples/mcp-hitl-tour/ship.yaml +25 -0
- package/examples/oss-issue-contribution/README.md +218 -0
- package/examples/oss-issue-contribution/oss-address-review-feedback.yaml +117 -0
- package/examples/oss-issue-contribution/oss-approve-contribution.yaml +181 -0
- package/examples/oss-issue-contribution/oss-approve-plan.yaml +111 -0
- package/examples/oss-issue-contribution/oss-explain-fix.yaml +108 -0
- package/examples/oss-issue-contribution/oss-explain-issue.yaml +114 -0
- package/examples/oss-issue-contribution/oss-implement-source-fix.yaml +171 -0
- package/examples/oss-issue-contribution/oss-investigate-area.yaml +116 -0
- package/examples/oss-issue-contribution/oss-issue-contribution.pipeline.yaml +125 -0
- package/examples/oss-issue-contribution/oss-issue-intake.yaml +106 -0
- package/examples/oss-issue-contribution/oss-plan-investigation.yaml +112 -0
- package/examples/oss-issue-contribution/oss-plan-review.yaml +109 -0
- package/examples/oss-issue-contribution/oss-reproduce-issue.yaml +140 -0
- package/examples/oss-issue-contribution/oss-review-change.yaml +107 -0
- package/examples/oss-issue-contribution/oss-verify-fix.yaml +130 -0
- package/examples/oss-issue-contribution/oss-write-regression-test.yaml +135 -0
- package/examples/oss-issue-contribution/pi-7629.task.yaml +79 -0
- package/examples/oss-issue-contribution/pi-8919.task.yaml +75 -0
- package/examples/oss-issue-contribution/pydantic-ai-7971.task.yaml +53 -0
- package/examples/oss-quick-fix/README.md +65 -0
- package/examples/oss-quick-fix/implement-fix.yaml +84 -0
- package/examples/oss-quick-fix/oss-quick-fix.pipeline.yaml +35 -0
- package/examples/oss-quick-fix/oss-quick-fix.task.yaml +19 -0
- package/examples/oss-quick-fix/ship-fix.yaml +81 -0
- package/examples/oss-quick-fix/understand-issue.yaml +67 -0
- package/examples/oss-quick-fix/verify-fix.yaml +73 -0
- package/examples/plan-review/README.md +37 -0
- package/examples/plan-review/plan-review-followup.yaml +13 -0
- package/examples/plan-review/plan-review.pipeline.yaml +9 -0
- package/examples/plan-review/plan-review.task.yaml +9 -0
- package/examples/plan-review/plan-review.yaml +25 -0
- package/examples/playwright-mcp/README.md +39 -0
- package/examples/playwright-mcp/playwright-mcp.pipeline.yaml +5 -0
- package/examples/playwright-mcp/playwright-mcp.task.yaml +4 -0
- package/examples/playwright-mcp/screenshot.yaml +40 -0
- package/examples/retry-tour/README.md +75 -0
- package/examples/retry-tour/retry-tour.pipeline.yaml +122 -0
- package/examples/retry-tour/retry-tour.task.yaml +9 -0
- package/examples/route-if-tour/README.md +202 -0
- package/examples/route-if-tour/route-if-tour.pipeline.yaml +950 -0
- package/examples/route-if-tour/route-if-tour.task.yaml +4 -0
- package/examples/route-wiring-smoke-test/01-core-routing.pipeline.yaml +168 -0
- package/examples/route-wiring-smoke-test/02-on-gating.pipeline.yaml +44 -0
- package/examples/route-wiring-smoke-test/03-two-entry-points.pipeline.yaml +28 -0
- package/examples/route-wiring-smoke-test/04-entry-false-equivalent-to-omitted.pipeline.yaml +27 -0
- package/examples/route-wiring-smoke-test/05-fork-choice.pipeline.yaml +110 -0
- package/examples/route-wiring-smoke-test/06-fan-out-fan-in.pipeline.yaml +82 -0
- package/examples/route-wiring-smoke-test/07-loop-human-decision.pipeline.yaml +82 -0
- package/examples/route-wiring-smoke-test/08-skip-fallback-and-multi-on-gate.pipeline.yaml +77 -0
- package/examples/route-wiring-smoke-test/09-multi-loop-targets.pipeline.yaml +102 -0
- package/examples/route-wiring-smoke-test/10-uses-dialect-fork.pipeline.yaml +23 -0
- package/examples/route-wiring-smoke-test/11-sequential-io-handoff.pipeline.yaml +37 -0
- package/examples/route-wiring-smoke-test/12-complex-io-schemas.pipeline.yaml +138 -0
- package/examples/route-wiring-smoke-test/13-ref-io-handoff.pipeline.yaml +84 -0
- package/examples/route-wiring-smoke-test/14-if-eq-gating.pipeline.yaml +50 -0
- package/examples/route-wiring-smoke-test/15-if-all-gated.pipeline.yaml +37 -0
- package/examples/route-wiring-smoke-test/16-if-composition.pipeline.yaml +65 -0
- package/examples/route-wiring-smoke-test/17-if-join.pipeline.yaml +80 -0
- package/examples/route-wiring-smoke-test/README.md +377 -0
- package/examples/route-wiring-smoke-test/rejected/01-reject-legacy-needs.pipeline.yaml +26 -0
- package/examples/route-wiring-smoke-test/rejected/02-reject-legacy-fork.pipeline.yaml +25 -0
- package/examples/route-wiring-smoke-test/rejected/03-reject-legacy-feedback-loop.pipeline.yaml +30 -0
- package/examples/route-wiring-smoke-test/rejected/04-reject-missing-entry.pipeline.yaml +24 -0
- package/examples/route-wiring-smoke-test/rejected/05-reject-unreachable.pipeline.yaml +35 -0
- package/examples/route-wiring-smoke-test/rejected/06-reject-allow-none-without-route-select.pipeline.yaml +37 -0
- package/examples/route-wiring-smoke-test/rejected/07-reject-cycle.pipeline.yaml +27 -0
- package/examples/route-wiring-smoke-test/rejected/08-reject-loop-non-ancestor.pipeline.yaml +42 -0
- package/examples/route-wiring-smoke-test/rejected/09-reject-route-select-leaf.pipeline.yaml +26 -0
- package/examples/route-wiring-smoke-test/rejected/12-reject-loop-replay-unsafe.pipeline.yaml +55 -0
- package/examples/route-wiring-smoke-test/rejected/13-reject-multiple-loop-entries.pipeline.yaml +51 -0
- package/examples/route-wiring-smoke-test/rejected/14-reject-duplicate-stage-id.pipeline.yaml +35 -0
- package/examples/route-wiring-smoke-test/rejected/15-reject-unknown-route-target.pipeline.yaml +15 -0
- package/examples/route-wiring-smoke-test/rejected/16-reject-malformed-route-item.pipeline.yaml +15 -0
- package/examples/route-wiring-smoke-test/rejected/17-reject-io-incompatible.pipeline.yaml +33 -0
- package/examples/route-wiring-smoke-test/rejected/18-reject-nested-io.pipeline.yaml +51 -0
- package/examples/route-wiring-smoke-test/rejected/19-reject-array-item-io.pipeline.yaml +55 -0
- package/examples/route-wiring-smoke-test/rejected/20-reject-closed-io.pipeline.yaml +36 -0
- package/examples/route-wiring-smoke-test/rejected/21-reject-ref-io.pipeline.yaml +42 -0
- package/examples/route-wiring-smoke-test/rejected/22-reject-if-unknown-field.pipeline.yaml +33 -0
- package/examples/route-wiring-smoke-test/rejected/23-reject-if-optional-field.pipeline.yaml +32 -0
- package/examples/route-wiring-smoke-test/rejected/24-reject-if-empty-all.pipeline.yaml +31 -0
- package/examples/route-wiring-smoke-test/rejected/25-reject-if-gt-on-string.pipeline.yaml +33 -0
- package/examples/route-wiring-smoke-test/rejected/26-reject-if-optional-nested.pipeline.yaml +36 -0
- package/examples/route-wiring-smoke-test/rejected/27-reject-if-on-loop.pipeline.yaml +63 -0
- package/examples/route-wiring-smoke-test/rejected/29-reject-if-on-failed.pipeline.yaml +46 -0
- package/examples/route-wiring-smoke-test/smoke-test.task.yaml +4 -0
- package/examples/route-wiring-smoke-test/stages/branch-a.yaml +12 -0
- package/examples/route-wiring-smoke-test/stages/branch-b.yaml +12 -0
- package/examples/route-wiring-smoke-test/stages/decide.yaml +12 -0
- package/examples/route-wiring-smoke-test/stages/finish.yaml +12 -0
- package/examples/ship-feature/README.md +190 -0
- package/examples/ship-feature/feat-address-feedback.yaml +119 -0
- package/examples/ship-feature/feat-implement.yaml +180 -0
- package/examples/ship-feature/feat-plan.yaml +120 -0
- package/examples/ship-feature/feat-review.yaml +109 -0
- package/examples/ship-feature/feat-ship.yaml +203 -0
- package/examples/ship-feature/ship-feature.pipeline.yaml +44 -0
- package/examples/ship-feature/ship-feature.task.yaml +78 -0
- package/examples/stage-mcp/README.md +144 -0
- package/examples/stage-mcp/echo-mcp.mjs +20 -0
- package/examples/stage-mcp/stage-mcp-dead.pipeline.yaml +5 -0
- package/examples/stage-mcp/stage-mcp-dead.task.yaml +3 -0
- package/examples/stage-mcp/stage-mcp-missing-var.pipeline.yaml +5 -0
- package/examples/stage-mcp/stage-mcp-missing-var.task.yaml +3 -0
- package/examples/stage-mcp/stage-mcp.pipeline.yaml +5 -0
- package/examples/stage-mcp/stage-mcp.task.yaml +4 -0
- package/examples/stage-mcp/use-echo.yaml +20 -0
- package/examples/verify-tour/README.md +80 -0
- package/examples/verify-tour/verify-tour.pipeline.yaml +162 -0
- package/examples/verify-tour/verify-tour.task.yaml +11 -0
- package/package.json +6 -1
- package/skills/stageflow/SKILL.md +6 -6
- package/skills/stageflow/references/control-surface.md +11 -5
- package/skills/stageflow/scripts/detect-host.mjs +14 -1
- package/skills/stageflow/scripts/detect-host.test.mjs +29 -1
- package/skills/stageflow-author/SKILL.md +4 -3
- package/skills/stageflow-author/references/catalog-mapping.md +16 -0
- package/skills/stageflow-author/references/catalog-write-conventions.md +1 -1
- package/skills/stageflow-run/SKILL.md +20 -12
- package/skills/stageflow-run/references/mcp-call.md +9 -1
- package/skills/stageflow-run/references/task-and-pipeline-selection.md +16 -5
- package/skills/stageflow-run/scripts/mcp-call.mjs +46 -6
- package/skills/stageflow-run/scripts/mcp-call.test.mjs +64 -0
- package/skills/stageflow-session-capture/references/catalog-authoring.md +2 -0
- package/skills/stageflow-setup/SKILL.md +40 -8
- package/dist/ui/assets/index-Da5EHU6M.js +0 -119
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { AgentCard, Role, TaskState, } from "@a2a-js/sdk";
|
|
2
|
+
import { JsonRpcTransportHandler, ServerCallContext, validateVersion } from "@a2a-js/sdk/server";
|
|
3
|
+
import { A2AError, RequestMalformedError, TaskNotCancelableError, TaskNotFoundError, UnsupportedOperationError, } from "@a2a-js/sdk/errors";
|
|
4
|
+
import { PACKAGE_VERSION } from "../package-meta.js";
|
|
5
|
+
import { A2aApplicationError } from "./contracts.js";
|
|
6
|
+
import { loadPublicationRegistry } from "./registry.js";
|
|
7
|
+
import { createA2aInvocations } from "./service.js";
|
|
8
|
+
export const A2A_BODY_LIMIT = 1024 * 1024;
|
|
9
|
+
/** Single source of truth for the two sub-routes so the URL builders below and the router in `createA2aHost` can never drift apart. */
|
|
10
|
+
const CONTRACT_ROUTE_PREFIX = "/a2a/contracts/";
|
|
11
|
+
const ARTIFACT_ROUTE_PREFIX = "/a2a/artifacts/";
|
|
12
|
+
function contractUrl(publicUrl, publicationId) {
|
|
13
|
+
return publicUrl + CONTRACT_ROUTE_PREFIX + publicationId;
|
|
14
|
+
}
|
|
15
|
+
function artifactUrl(publicUrl, taskId, artifactId) {
|
|
16
|
+
return publicUrl + ARTIFACT_ROUTE_PREFIX + taskId + "/" + artifactId;
|
|
17
|
+
}
|
|
18
|
+
export function publicationCard(registry, caller) {
|
|
19
|
+
return AgentCard.fromJSON({
|
|
20
|
+
name: "Stageflow",
|
|
21
|
+
description: "Invoke published Stageflow pipelines as A2A capabilities.",
|
|
22
|
+
version: PACKAGE_VERSION,
|
|
23
|
+
supportedInterfaces: [{ url: registry.publicUrl + "/a2a", protocolBinding: "JSONRPC", protocolVersion: "1.0" }],
|
|
24
|
+
capabilities: { streaming: false, pushNotifications: false, extendedAgentCard: true },
|
|
25
|
+
securitySchemes: { bearer: { httpAuthSecurityScheme: { scheme: "bearer" } } },
|
|
26
|
+
securityRequirements: [{ schemes: { bearer: { list: [] } } }],
|
|
27
|
+
defaultInputModes: ["application/json"],
|
|
28
|
+
defaultOutputModes: ["application/json"],
|
|
29
|
+
skills: registry.list(caller).map((publication) => ({
|
|
30
|
+
id: publication.id,
|
|
31
|
+
name: publication.name,
|
|
32
|
+
description: publication.description + " Contract: " + contractUrl(registry.publicUrl, publication.id),
|
|
33
|
+
tags: ["pipeline"],
|
|
34
|
+
inputModes: ["application/json"],
|
|
35
|
+
outputModes: ["application/json"],
|
|
36
|
+
})),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function mapState(state) {
|
|
40
|
+
switch (state) {
|
|
41
|
+
case "submitted":
|
|
42
|
+
return TaskState.TASK_STATE_SUBMITTED;
|
|
43
|
+
case "working":
|
|
44
|
+
return TaskState.TASK_STATE_WORKING;
|
|
45
|
+
case "input-required":
|
|
46
|
+
return TaskState.TASK_STATE_INPUT_REQUIRED;
|
|
47
|
+
case "completed":
|
|
48
|
+
return TaskState.TASK_STATE_COMPLETED;
|
|
49
|
+
case "failed":
|
|
50
|
+
return TaskState.TASK_STATE_FAILED;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function dataPart(value) {
|
|
54
|
+
return { content: { $case: "data", value }, metadata: undefined, filename: "", mediaType: "application/json" };
|
|
55
|
+
}
|
|
56
|
+
function urlPart(url, filename, mediaType) {
|
|
57
|
+
return { content: { $case: "url", value: url }, metadata: undefined, filename, mediaType };
|
|
58
|
+
}
|
|
59
|
+
function statusMessage(taskId, contextId, parts) {
|
|
60
|
+
return {
|
|
61
|
+
messageId: "status-" + taskId + "-" + Date.now().toString(36),
|
|
62
|
+
contextId,
|
|
63
|
+
taskId,
|
|
64
|
+
role: Role.ROLE_AGENT,
|
|
65
|
+
parts,
|
|
66
|
+
metadata: undefined,
|
|
67
|
+
extensions: [],
|
|
68
|
+
referenceTaskIds: [],
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function toWireTask(publicUrl, task) {
|
|
72
|
+
const parts = [];
|
|
73
|
+
if (task.state === "input-required" && task.questions) {
|
|
74
|
+
parts.push(dataPart({ questions: task.questions }));
|
|
75
|
+
}
|
|
76
|
+
const artifacts = [];
|
|
77
|
+
if (task.result) {
|
|
78
|
+
if (task.result.payload !== undefined) {
|
|
79
|
+
artifacts.push({
|
|
80
|
+
artifactId: "result",
|
|
81
|
+
name: "result",
|
|
82
|
+
description: task.result.summary,
|
|
83
|
+
parts: [dataPart(task.result.payload)],
|
|
84
|
+
metadata: undefined,
|
|
85
|
+
extensions: [],
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
for (const file of task.result.artifacts) {
|
|
89
|
+
artifacts.push({
|
|
90
|
+
artifactId: file.id,
|
|
91
|
+
name: file.name,
|
|
92
|
+
description: "",
|
|
93
|
+
parts: [urlPart(artifactUrl(publicUrl, task.id, file.id), file.name, file.mediaType ?? "application/octet-stream")],
|
|
94
|
+
metadata: undefined,
|
|
95
|
+
extensions: [],
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
id: task.id,
|
|
101
|
+
contextId: task.contextId,
|
|
102
|
+
status: {
|
|
103
|
+
state: mapState(task.state),
|
|
104
|
+
message: parts.length > 0 ? statusMessage(task.id, task.contextId, parts) : undefined,
|
|
105
|
+
timestamp: task.updatedAt,
|
|
106
|
+
},
|
|
107
|
+
artifacts,
|
|
108
|
+
history: [],
|
|
109
|
+
// Only ever set for a "standalone" (ADR-0001 run_stage) task — see PublicTask.runId.
|
|
110
|
+
// This is how a caller learns the run id it needs to chain into its next
|
|
111
|
+
// run_stage call via envelope_ref (ADR-0002); invoke's published-capability
|
|
112
|
+
// tasks keep the run id opaque, unchanged from before this field existed.
|
|
113
|
+
metadata: task.runId ? { runId: task.runId } : undefined,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function mapApplicationError(err) {
|
|
117
|
+
if (err instanceof A2aApplicationError) {
|
|
118
|
+
if (err.category === "not-found") {
|
|
119
|
+
throw new TaskNotFoundError({ message: err.message });
|
|
120
|
+
}
|
|
121
|
+
if (err.category === "busy" || err.category === "export-failed") {
|
|
122
|
+
throw new A2AError({ message: err.message, metadata: { category: err.category } });
|
|
123
|
+
}
|
|
124
|
+
throw new RequestMalformedError({ message: err.message, metadata: { category: err.category } });
|
|
125
|
+
}
|
|
126
|
+
throw err;
|
|
127
|
+
}
|
|
128
|
+
function realHandler(card, invocations, publicUrl) {
|
|
129
|
+
const unsupportedStream = async function* () {
|
|
130
|
+
throw new UnsupportedOperationError("Streaming is not enabled");
|
|
131
|
+
};
|
|
132
|
+
const pushUnsupported = async () => {
|
|
133
|
+
throw new UnsupportedOperationError("Push notifications are not enabled");
|
|
134
|
+
};
|
|
135
|
+
return {
|
|
136
|
+
getAgentCard: async () => card,
|
|
137
|
+
getAuthenticatedExtendedAgentCard: async () => card,
|
|
138
|
+
async sendMessage(params, context) {
|
|
139
|
+
if (!params.message)
|
|
140
|
+
throw new RequestMalformedError({ message: "A message is required" });
|
|
141
|
+
try {
|
|
142
|
+
const task = await invocations.send({ id: context.user.userName }, params.message);
|
|
143
|
+
return toWireTask(publicUrl, task);
|
|
144
|
+
}
|
|
145
|
+
catch (err) {
|
|
146
|
+
return mapApplicationError(err);
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
async getTask(params, context) {
|
|
150
|
+
try {
|
|
151
|
+
const task = await invocations.get({ id: context.user.userName }, params.id);
|
|
152
|
+
return toWireTask(publicUrl, task);
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
return mapApplicationError(err);
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
async listTasks(params, context) {
|
|
159
|
+
try {
|
|
160
|
+
const tasks = await invocations.list({ id: context.user.userName }, params.contextId || undefined);
|
|
161
|
+
const size = params.pageSize && params.pageSize > 0 ? Math.min(params.pageSize, 100) : 50;
|
|
162
|
+
const limited = tasks.slice(0, size);
|
|
163
|
+
return { tasks: limited.map((task) => toWireTask(publicUrl, task)), nextPageToken: "", pageSize: limited.length, totalSize: tasks.length };
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
return mapApplicationError(err);
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
async cancelTask(params, context) {
|
|
170
|
+
try {
|
|
171
|
+
await invocations.get({ id: context.user.userName }, params.id);
|
|
172
|
+
}
|
|
173
|
+
catch (err) {
|
|
174
|
+
return mapApplicationError(err);
|
|
175
|
+
}
|
|
176
|
+
throw new TaskNotCancelableError({ message: "Active pipeline cancellation is not available yet" });
|
|
177
|
+
},
|
|
178
|
+
sendMessageStream: unsupportedStream,
|
|
179
|
+
resubscribe: unsupportedStream,
|
|
180
|
+
createTaskPushNotificationConfig: pushUnsupported,
|
|
181
|
+
getTaskPushNotificationConfig: pushUnsupported,
|
|
182
|
+
listTaskPushNotificationConfigs: pushUnsupported,
|
|
183
|
+
deleteTaskPushNotificationConfig: pushUnsupported,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
function respond(res, status, value) {
|
|
187
|
+
res.writeHead(status, { "Content-Type": "application/json", "Cache-Control": "no-store", "Vary": "Authorization" });
|
|
188
|
+
res.end(JSON.stringify(value));
|
|
189
|
+
}
|
|
190
|
+
async function readBody(req) {
|
|
191
|
+
const chunks = [];
|
|
192
|
+
let length = 0;
|
|
193
|
+
for await (const chunk of req) {
|
|
194
|
+
const bytes = Buffer.from(chunk);
|
|
195
|
+
length += bytes.length;
|
|
196
|
+
if (length > A2A_BODY_LIMIT)
|
|
197
|
+
throw new Error("body_too_large");
|
|
198
|
+
chunks.push(bytes);
|
|
199
|
+
}
|
|
200
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
201
|
+
}
|
|
202
|
+
const RETENTION_SWEEP_INTERVAL_MS = 60 * 60 * 1000;
|
|
203
|
+
export async function createA2aHost(runtime, configPath, env = process.env) {
|
|
204
|
+
let registry;
|
|
205
|
+
let invocations;
|
|
206
|
+
const status = { state: "disabled" };
|
|
207
|
+
if (configPath) {
|
|
208
|
+
status.configPath = configPath;
|
|
209
|
+
try {
|
|
210
|
+
registry = await loadPublicationRegistry(configPath, env);
|
|
211
|
+
status.configPath = registry.configPath;
|
|
212
|
+
status.state = "enabled";
|
|
213
|
+
invocations = createA2aInvocations(registry, runtime.manager, runtime.runStore, runtime.rootDir, runtime.connection, undefined, runtime.a2aStore);
|
|
214
|
+
}
|
|
215
|
+
catch (err) {
|
|
216
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
217
|
+
status.state = "configuration_error";
|
|
218
|
+
status.error = { code: "a2a_configuration_error", message };
|
|
219
|
+
console.error(`stageflow: A2A configuration error: ${message}`);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
const sweep = invocations
|
|
223
|
+
? setInterval(() => {
|
|
224
|
+
invocations.pruneExpired().catch(() => undefined);
|
|
225
|
+
}, RETENTION_SWEEP_INTERVAL_MS).unref()
|
|
226
|
+
: undefined;
|
|
227
|
+
return {
|
|
228
|
+
status,
|
|
229
|
+
async pruneExpired(now) {
|
|
230
|
+
return (await invocations?.pruneExpired(now)) ?? { removedTasks: 0, removedMessages: 0 };
|
|
231
|
+
},
|
|
232
|
+
close() {
|
|
233
|
+
if (sweep)
|
|
234
|
+
clearInterval(sweep);
|
|
235
|
+
invocations?.close();
|
|
236
|
+
},
|
|
237
|
+
async handle(req, res, pathname) {
|
|
238
|
+
const isRoute = pathname === "/a2a" ||
|
|
239
|
+
pathname === "/.well-known/agent-card.json" ||
|
|
240
|
+
pathname.startsWith(CONTRACT_ROUTE_PREFIX) ||
|
|
241
|
+
pathname.startsWith(ARTIFACT_ROUTE_PREFIX);
|
|
242
|
+
if (!isRoute)
|
|
243
|
+
return false;
|
|
244
|
+
if (!registry || !invocations) {
|
|
245
|
+
respond(res, status.state === "disabled" ? 404 : 503, { error: "A2A unavailable" });
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
const caller = registry.authenticate(req.headers.authorization);
|
|
249
|
+
if (!caller) {
|
|
250
|
+
res.setHeader("WWW-Authenticate", 'Bearer realm="stageflow-a2a"');
|
|
251
|
+
respond(res, 401, { error: "Authentication required" });
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
254
|
+
if (pathname.startsWith(ARTIFACT_ROUTE_PREFIX)) {
|
|
255
|
+
if (req.method !== "GET") {
|
|
256
|
+
res.setHeader("Allow", "GET");
|
|
257
|
+
respond(res, 405, { error: "Method not allowed" });
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
const segments = pathname.slice(ARTIFACT_ROUTE_PREFIX.length).split("/");
|
|
261
|
+
if (segments.length !== 2) {
|
|
262
|
+
respond(res, 404, { error: "Artifact not found" });
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
try {
|
|
266
|
+
const artifact = await invocations.readArtifact({ id: caller }, segments[0], segments[1]);
|
|
267
|
+
res.writeHead(200, {
|
|
268
|
+
"Content-Type": artifact.mediaType ?? "application/octet-stream",
|
|
269
|
+
"Content-Length": artifact.bytes.length,
|
|
270
|
+
"Cache-Control": "no-store",
|
|
271
|
+
"Vary": "Authorization",
|
|
272
|
+
});
|
|
273
|
+
res.end(artifact.bytes);
|
|
274
|
+
}
|
|
275
|
+
catch {
|
|
276
|
+
respond(res, 404, { error: "Artifact not found" });
|
|
277
|
+
}
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
const card = publicationCard(registry, caller);
|
|
281
|
+
if (pathname !== "/a2a") {
|
|
282
|
+
if (req.method !== "GET") {
|
|
283
|
+
res.setHeader("Allow", "GET");
|
|
284
|
+
respond(res, 405, { error: "Method not allowed" });
|
|
285
|
+
}
|
|
286
|
+
else if (pathname === "/.well-known/agent-card.json") {
|
|
287
|
+
respond(res, 200, AgentCard.toJSON(card));
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
const publication = registry.get(caller, pathname.slice(CONTRACT_ROUTE_PREFIX.length));
|
|
291
|
+
if (!publication)
|
|
292
|
+
respond(res, 404, { error: "Contract not found" });
|
|
293
|
+
else
|
|
294
|
+
respond(res, 200, {
|
|
295
|
+
contractVersion: 1,
|
|
296
|
+
capability: publication.id,
|
|
297
|
+
revision: publication.revision,
|
|
298
|
+
executionEnabled: true,
|
|
299
|
+
inputSchema: publication.inputSchema,
|
|
300
|
+
outputSchema: publication.outputSchema,
|
|
301
|
+
artifacts: publication.results.artifacts,
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
if (req.method !== "POST") {
|
|
307
|
+
res.setHeader("Allow", "POST");
|
|
308
|
+
respond(res, 405, { error: "Method not allowed" });
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
if (req.headers["content-type"]?.split(";")[0].trim().toLowerCase() !== "application/json") {
|
|
312
|
+
respond(res, 415, { error: "Expected application/json" });
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
if (Number(req.headers["content-length"]) > A2A_BODY_LIMIT) {
|
|
316
|
+
respond(res, 413, { error: "Request too large" });
|
|
317
|
+
return true;
|
|
318
|
+
}
|
|
319
|
+
const version = req.headers["a2a-version"];
|
|
320
|
+
try {
|
|
321
|
+
validateVersion(typeof version === "string" ? version : "0.3", card, "JSONRPC");
|
|
322
|
+
}
|
|
323
|
+
catch (error) {
|
|
324
|
+
respond(res, 400, { jsonrpc: "2.0", id: null, error: JsonRpcTransportHandler.mapToJSONRPCError(error) });
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
req.setTimeout(30_000, () => req.destroy());
|
|
328
|
+
try {
|
|
329
|
+
const body = await readBody(req);
|
|
330
|
+
const context = new ServerCallContext({ user: { isAuthenticated: true, userName: caller }, requestedVersion: "1.0" });
|
|
331
|
+
const result = await new JsonRpcTransportHandler(realHandler(card, invocations, registry.publicUrl)).handle(body, context);
|
|
332
|
+
respond(res, 200, result);
|
|
333
|
+
}
|
|
334
|
+
catch (error) {
|
|
335
|
+
if (!res.destroyed)
|
|
336
|
+
respond(res, error instanceof Error && error.message === "body_too_large" ? 413 : 400, { error: "Invalid request body" });
|
|
337
|
+
}
|
|
338
|
+
finally {
|
|
339
|
+
req.setTimeout(0);
|
|
340
|
+
}
|
|
341
|
+
return true;
|
|
342
|
+
},
|
|
343
|
+
};
|
|
344
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { RunStore } from "../runstore/port.js";
|
|
2
|
+
import type { RunManager } from "../runtime/runManager.js";
|
|
3
|
+
import type { PublicationRegistry } from "./registry.js";
|
|
4
|
+
import { type IncomingMessage } from "./contracts.js";
|
|
5
|
+
import type Database from "better-sqlite3";
|
|
6
|
+
import { A2aStore, type TaskState } from "./store.js";
|
|
7
|
+
import { RateLimiter } from "./limits.js";
|
|
8
|
+
export type Caller = {
|
|
9
|
+
id: string;
|
|
10
|
+
};
|
|
11
|
+
export type PublicQuestion = {
|
|
12
|
+
handle: string;
|
|
13
|
+
message: string;
|
|
14
|
+
};
|
|
15
|
+
export type PublicArtifact = {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
mediaType?: string;
|
|
19
|
+
size: number;
|
|
20
|
+
};
|
|
21
|
+
export type PublicTask = {
|
|
22
|
+
id: string;
|
|
23
|
+
contextId: string;
|
|
24
|
+
state: TaskState;
|
|
25
|
+
publication: string;
|
|
26
|
+
createdAt: string;
|
|
27
|
+
updatedAt: string;
|
|
28
|
+
questions?: PublicQuestion[];
|
|
29
|
+
waitingForOperator?: boolean;
|
|
30
|
+
result?: {
|
|
31
|
+
summary: string;
|
|
32
|
+
payload?: Record<string, unknown>;
|
|
33
|
+
artifacts: PublicArtifact[];
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* The underlying run id — only ever populated for a "standalone" (ADR-0001
|
|
37
|
+
* run_stage) task. Published-capability (`invoke`) tasks keep the run id
|
|
38
|
+
* opaque, unchanged from before this field existed. Exposing it here is
|
|
39
|
+
* what makes ADR-0002's `envelope_ref` chaining ({runId, stageId}) usable
|
|
40
|
+
* from an A2A caller in the first place: run_stage's response is the only
|
|
41
|
+
* place a caller can learn the run id of a standalone call it just made,
|
|
42
|
+
* to hand to its *next* run_stage call.
|
|
43
|
+
*/
|
|
44
|
+
runId?: string;
|
|
45
|
+
};
|
|
46
|
+
export type ArtifactRead = {
|
|
47
|
+
bytes: Buffer;
|
|
48
|
+
name: string;
|
|
49
|
+
mediaType?: string;
|
|
50
|
+
};
|
|
51
|
+
export declare class A2aInvocations {
|
|
52
|
+
private readonly registry;
|
|
53
|
+
private readonly manager;
|
|
54
|
+
private readonly runStore;
|
|
55
|
+
/** Base directory a `stage`/`pipeline` filesystem reference in a run_stage call resolves against. */
|
|
56
|
+
private readonly rootDir;
|
|
57
|
+
private readonly store;
|
|
58
|
+
private readonly rateLimiter;
|
|
59
|
+
constructor(registry: PublicationRegistry, manager: RunManager, runStore: RunStore,
|
|
60
|
+
/** Base directory a `stage`/`pipeline` filesystem reference in a run_stage call resolves against. */
|
|
61
|
+
rootDir: string, store: A2aStore, rateLimiter?: RateLimiter);
|
|
62
|
+
close(): void;
|
|
63
|
+
/** Deletes terminal tasks and message tombstones past their retention window. Call periodically; the core logic takes an explicit clock so it stays deterministic to test. */
|
|
64
|
+
pruneExpired(now?: Date): Promise<{
|
|
65
|
+
removedTasks: number;
|
|
66
|
+
removedMessages: number;
|
|
67
|
+
}>;
|
|
68
|
+
private checkRate;
|
|
69
|
+
send(caller: Caller, raw: IncomingMessage): Promise<PublicTask>;
|
|
70
|
+
get(caller: Caller, taskId: string): Promise<PublicTask>;
|
|
71
|
+
list(caller: Caller, contextId: string | undefined): Promise<PublicTask[]>;
|
|
72
|
+
readArtifact(caller: Caller, taskId: string, artifactId: string): Promise<ArtifactRead>;
|
|
73
|
+
private requireOwnedTask;
|
|
74
|
+
/**
|
|
75
|
+
* (caller, messageId) dedup shared by invoke and answer: a resend of a message already recorded with
|
|
76
|
+
* the same content hash replays its prior outcome; a resend with different content is a conflict.
|
|
77
|
+
* Returns undefined only for a message this caller has not sent before.
|
|
78
|
+
*/
|
|
79
|
+
private replayOrThrow;
|
|
80
|
+
private invoke;
|
|
81
|
+
/**
|
|
82
|
+
* ADR-0001's wildcard-access operation: run any catalog or inline
|
|
83
|
+
* stage/pipeline directly. Deliberately does NOT call `this.registry.get`/
|
|
84
|
+
* `.list` — that allowlist lookup is the entire mechanism `invoke` uses to
|
|
85
|
+
* restrict a caller to its published capabilities, and this operation's
|
|
86
|
+
* whole point is to bypass it. The caller is still authenticated (by the
|
|
87
|
+
* time `send` reaches here) and still rate-limited/admission-capped like
|
|
88
|
+
* any other task.
|
|
89
|
+
*/
|
|
90
|
+
private runStandalone;
|
|
91
|
+
private answer;
|
|
92
|
+
private maybeFinalize;
|
|
93
|
+
/** The five PublicTask fields every projection shares; call sites layer in only what differs per state. */
|
|
94
|
+
private buildTask;
|
|
95
|
+
private projectTask;
|
|
96
|
+
}
|
|
97
|
+
export declare function createA2aInvocations(registry: PublicationRegistry, manager: RunManager, runStore: RunStore, rootDir: string, connection?: Database.Database, rateLimiter?: RateLimiter, a2aStore?: A2aStore): A2aInvocations;
|