mayura 0.1.0-dev.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/LICENSE +201 -0
- package/NOTICE +8 -0
- package/README.md +55 -0
- package/lib/adapter-code-docker/dist/index.d.ts +65 -0
- package/lib/adapter-code-docker/dist/index.d.ts.map +1 -0
- package/lib/adapter-code-docker/dist/index.js +228 -0
- package/lib/adapter-code-docker/dist/index.js.map +1 -0
- package/lib/adapter-code-docker/image/Dockerfile +12 -0
- package/lib/adapter-code-docker/package.json +5 -0
- package/lib/adapter-code-docker/src/index.ts +244 -0
- package/lib/adapter-code-quickjs/dist/index.d.ts +40 -0
- package/lib/adapter-code-quickjs/dist/index.d.ts.map +1 -0
- package/lib/adapter-code-quickjs/dist/index.js +169 -0
- package/lib/adapter-code-quickjs/dist/index.js.map +1 -0
- package/lib/adapter-code-quickjs/dist/worker.d.ts +2 -0
- package/lib/adapter-code-quickjs/dist/worker.d.ts.map +1 -0
- package/lib/adapter-code-quickjs/dist/worker.js +164 -0
- package/lib/adapter-code-quickjs/dist/worker.js.map +1 -0
- package/lib/adapter-code-quickjs/package.json +5 -0
- package/lib/adapter-code-quickjs/src/index.ts +174 -0
- package/lib/adapter-code-quickjs/src/worker.ts +142 -0
- package/lib/adapter-mcp/dist/index.d.ts +29 -0
- package/lib/adapter-mcp/dist/index.d.ts.map +1 -0
- package/lib/adapter-mcp/dist/index.js +54 -0
- package/lib/adapter-mcp/dist/index.js.map +1 -0
- package/lib/adapter-mcp/package.json +5 -0
- package/lib/adapter-mcp/src/index.ts +82 -0
- package/lib/artifacts/dist/contracts.d.ts +139 -0
- package/lib/artifacts/dist/contracts.d.ts.map +1 -0
- package/lib/artifacts/dist/contracts.js +2 -0
- package/lib/artifacts/dist/contracts.js.map +1 -0
- package/lib/artifacts/dist/index.d.ts +3 -0
- package/lib/artifacts/dist/index.d.ts.map +1 -0
- package/lib/artifacts/dist/index.js +2 -0
- package/lib/artifacts/dist/index.js.map +1 -0
- package/lib/artifacts/dist/local-store.d.ts +3 -0
- package/lib/artifacts/dist/local-store.d.ts.map +1 -0
- package/lib/artifacts/dist/local-store.js +922 -0
- package/lib/artifacts/dist/local-store.js.map +1 -0
- package/lib/artifacts/package.json +5 -0
- package/lib/artifacts/src/contracts.ts +159 -0
- package/lib/artifacts/src/index.ts +26 -0
- package/lib/artifacts/src/local-store.ts +816 -0
- package/lib/cli/dist/application.d.ts +85 -0
- package/lib/cli/dist/application.d.ts.map +1 -0
- package/lib/cli/dist/application.js +116 -0
- package/lib/cli/dist/application.js.map +1 -0
- package/lib/cli/dist/bin.d.ts +3 -0
- package/lib/cli/dist/bin.d.ts.map +1 -0
- package/lib/cli/dist/bin.js +394 -0
- package/lib/cli/dist/bin.js.map +1 -0
- package/lib/cli/dist/dev.d.ts +21 -0
- package/lib/cli/dist/dev.d.ts.map +1 -0
- package/lib/cli/dist/dev.js +205 -0
- package/lib/cli/dist/dev.js.map +1 -0
- package/lib/cli/dist/index.d.ts +72 -0
- package/lib/cli/dist/index.d.ts.map +1 -0
- package/lib/cli/dist/index.js +423 -0
- package/lib/cli/dist/index.js.map +1 -0
- package/lib/cli/dist/interactive.d.ts +19 -0
- package/lib/cli/dist/interactive.d.ts.map +1 -0
- package/lib/cli/dist/interactive.js +163 -0
- package/lib/cli/dist/interactive.js.map +1 -0
- package/lib/cli/dist/operations.d.ts +215 -0
- package/lib/cli/dist/operations.d.ts.map +1 -0
- package/lib/cli/dist/operations.js +580 -0
- package/lib/cli/dist/operations.js.map +1 -0
- package/lib/cli/dist/output.d.ts +29 -0
- package/lib/cli/dist/output.d.ts.map +1 -0
- package/lib/cli/dist/output.js +244 -0
- package/lib/cli/dist/output.js.map +1 -0
- package/lib/cli/dist/providers.d.ts +54 -0
- package/lib/cli/dist/providers.d.ts.map +1 -0
- package/lib/cli/dist/providers.js +96 -0
- package/lib/cli/dist/providers.js.map +1 -0
- package/lib/cli/package.json +5 -0
- package/lib/cli/src/application.ts +109 -0
- package/lib/cli/src/bin.ts +261 -0
- package/lib/cli/src/dev.ts +139 -0
- package/lib/cli/src/index.ts +386 -0
- package/lib/cli/src/interactive.ts +132 -0
- package/lib/cli/src/operations.ts +458 -0
- package/lib/cli/src/output.ts +205 -0
- package/lib/cli/src/providers.ts +102 -0
- package/lib/cli/starters/approval-workflow/Dockerfile +20 -0
- package/lib/cli/starters/approval-workflow/README.md +102 -0
- package/lib/cli/starters/approval-workflow/compose.yaml +33 -0
- package/lib/cli/starters/approval-workflow/dot-dockerignore +7 -0
- package/lib/cli/starters/approval-workflow/dot-env.example +41 -0
- package/lib/cli/starters/approval-workflow/dot-github/workflows/ci.yml +13 -0
- package/lib/cli/starters/approval-workflow/dot-gitignore +10 -0
- package/lib/cli/starters/approval-workflow/mayura.project.json +16 -0
- package/lib/cli/starters/approval-workflow/package.json +30 -0
- package/lib/cli/starters/approval-workflow/src/app.ts +19 -0
- package/lib/cli/starters/approval-workflow/src/auth.ts +68 -0
- package/lib/cli/starters/approval-workflow/src/config.ts +107 -0
- package/lib/cli/starters/approval-workflow/src/dev.ts +59 -0
- package/lib/cli/starters/approval-workflow/src/intake.ts +104 -0
- package/lib/cli/starters/approval-workflow/src/model.ts +33 -0
- package/lib/cli/starters/approval-workflow/src/server.ts +56 -0
- package/lib/cli/starters/approval-workflow/src/services.ts +26 -0
- package/lib/cli/starters/approval-workflow/src/token.ts +6 -0
- package/lib/cli/starters/approval-workflow/src/worker.ts +18 -0
- package/lib/cli/starters/approval-workflow/src/workflow.ts +100 -0
- package/lib/cli/starters/approval-workflow/test/refunds.test.ts +140 -0
- package/lib/cli/starters/approval-workflow/tsconfig.json +20 -0
- package/lib/cli/starters/event-automation/Dockerfile +21 -0
- package/lib/cli/starters/event-automation/README.md +150 -0
- package/lib/cli/starters/event-automation/compose.yaml +41 -0
- package/lib/cli/starters/event-automation/dot-dockerignore +7 -0
- package/lib/cli/starters/event-automation/dot-env.example +51 -0
- package/lib/cli/starters/event-automation/dot-github/workflows/ci.yml +13 -0
- package/lib/cli/starters/event-automation/dot-gitignore +10 -0
- package/lib/cli/starters/event-automation/mayura.project.json +17 -0
- package/lib/cli/starters/event-automation/package.json +32 -0
- package/lib/cli/starters/event-automation/src/app.ts +19 -0
- package/lib/cli/starters/event-automation/src/auth.ts +61 -0
- package/lib/cli/starters/event-automation/src/config.ts +138 -0
- package/lib/cli/starters/event-automation/src/dev.ts +54 -0
- package/lib/cli/starters/event-automation/src/ingress.ts +129 -0
- package/lib/cli/starters/event-automation/src/mcp.ts +139 -0
- package/lib/cli/starters/event-automation/src/model.ts +33 -0
- package/lib/cli/starters/event-automation/src/send-sample.ts +29 -0
- package/lib/cli/starters/event-automation/src/server.ts +58 -0
- package/lib/cli/starters/event-automation/src/services.ts +54 -0
- package/lib/cli/starters/event-automation/src/signing.ts +30 -0
- package/lib/cli/starters/event-automation/src/token.ts +7 -0
- package/lib/cli/starters/event-automation/src/tracker/main.ts +18 -0
- package/lib/cli/starters/event-automation/src/tracker/mcp-server.ts +145 -0
- package/lib/cli/starters/event-automation/src/tracker/samples.ts +19 -0
- package/lib/cli/starters/event-automation/src/tracker/tickets.ts +54 -0
- package/lib/cli/starters/event-automation/src/tracker-tools.ts +38 -0
- package/lib/cli/starters/event-automation/src/triage.ts +151 -0
- package/lib/cli/starters/event-automation/src/worker.ts +19 -0
- package/lib/cli/starters/event-automation/src/workflows.ts +57 -0
- package/lib/cli/starters/event-automation/test/automation.test.ts +200 -0
- package/lib/cli/starters/event-automation/tsconfig.json +20 -0
- package/lib/cli/starters/research-team/Dockerfile +22 -0
- package/lib/cli/starters/research-team/README.md +189 -0
- package/lib/cli/starters/research-team/compose.yaml +38 -0
- package/lib/cli/starters/research-team/dot-dockerignore +7 -0
- package/lib/cli/starters/research-team/dot-env.example +49 -0
- package/lib/cli/starters/research-team/dot-github/workflows/ci.yml +13 -0
- package/lib/cli/starters/research-team/dot-gitignore +10 -0
- package/lib/cli/starters/research-team/mayura.project.json +22 -0
- package/lib/cli/starters/research-team/package.json +30 -0
- package/lib/cli/starters/research-team/src/app.ts +19 -0
- package/lib/cli/starters/research-team/src/auth.ts +56 -0
- package/lib/cli/starters/research-team/src/config.ts +170 -0
- package/lib/cli/starters/research-team/src/desk.ts +124 -0
- package/lib/cli/starters/research-team/src/dev.ts +58 -0
- package/lib/cli/starters/research-team/src/library/corpus.ts +76 -0
- package/lib/cli/starters/research-team/src/library/index.ts +109 -0
- package/lib/cli/starters/research-team/src/model.ts +33 -0
- package/lib/cli/starters/research-team/src/server.ts +69 -0
- package/lib/cli/starters/research-team/src/services.ts +48 -0
- package/lib/cli/starters/research-team/src/team.ts +173 -0
- package/lib/cli/starters/research-team/src/telemetry.ts +95 -0
- package/lib/cli/starters/research-team/src/token.ts +6 -0
- package/lib/cli/starters/research-team/src/worker.ts +21 -0
- package/lib/cli/starters/research-team/src/workflow.ts +197 -0
- package/lib/cli/starters/research-team/test/research.test.ts +271 -0
- package/lib/cli/starters/research-team/tsconfig.json +20 -0
- package/lib/cli/starters/support-agent/Dockerfile +21 -0
- package/lib/cli/starters/support-agent/README.md +128 -0
- package/lib/cli/starters/support-agent/compose.yaml +33 -0
- package/lib/cli/starters/support-agent/dot-dockerignore +7 -0
- package/lib/cli/starters/support-agent/dot-env.example +44 -0
- package/lib/cli/starters/support-agent/dot-github/workflows/ci.yml +13 -0
- package/lib/cli/starters/support-agent/dot-gitignore +10 -0
- package/lib/cli/starters/support-agent/mayura.project.json +18 -0
- package/lib/cli/starters/support-agent/package.json +43 -0
- package/lib/cli/starters/support-agent/src/app.ts +19 -0
- package/lib/cli/starters/support-agent/src/assistant.ts +313 -0
- package/lib/cli/starters/support-agent/src/auth.ts +69 -0
- package/lib/cli/starters/support-agent/src/config.ts +120 -0
- package/lib/cli/starters/support-agent/src/dev.ts +115 -0
- package/lib/cli/starters/support-agent/src/guardrails.ts +71 -0
- package/lib/cli/starters/support-agent/src/model.ts +33 -0
- package/lib/cli/starters/support-agent/src/orders.ts +62 -0
- package/lib/cli/starters/support-agent/src/returns.ts +86 -0
- package/lib/cli/starters/support-agent/src/server.ts +72 -0
- package/lib/cli/starters/support-agent/src/services.ts +32 -0
- package/lib/cli/starters/support-agent/src/session.ts +55 -0
- package/lib/cli/starters/support-agent/src/token.ts +9 -0
- package/lib/cli/starters/support-agent/src/worker.ts +19 -0
- package/lib/cli/starters/support-agent/test/support.test.ts +263 -0
- package/lib/cli/starters/support-agent/tsconfig.json +20 -0
- package/lib/cli/starters/support-agent/web/index.html +12 -0
- package/lib/cli/starters/support-agent/web/src/App.tsx +43 -0
- package/lib/cli/starters/support-agent/web/src/components/chat.tsx +161 -0
- package/lib/cli/starters/support-agent/web/src/components/ui/button.tsx +33 -0
- package/lib/cli/starters/support-agent/web/src/components/ui/primitives.tsx +48 -0
- package/lib/cli/starters/support-agent/web/src/env.d.ts +1 -0
- package/lib/cli/starters/support-agent/web/src/lib/api.ts +56 -0
- package/lib/cli/starters/support-agent/web/src/lib/utils.ts +4 -0
- package/lib/cli/starters/support-agent/web/src/main.tsx +6 -0
- package/lib/cli/starters/support-agent/web/src/styles.css +86 -0
- package/lib/cli/starters/support-agent/web/tsconfig.json +9 -0
- package/lib/cli/starters/support-agent/web/vite.config.ts +13 -0
- package/lib/cli/templates/basic-agent.ts +10 -0
- package/lib/cli/templates/capability-policy.ts +18 -0
- package/lib/cli/templates/code-mode-workflow.ts +34 -0
- package/lib/cli/templates/durable-approval.ts +25 -0
- package/lib/cli/templates/guarded-streaming-app.ts +23 -0
- package/lib/cli/templates/native-memory.ts +15 -0
- package/lib/cli/templates/parallel-research.ts +21 -0
- package/lib/cli/templates/typed-tool-runner.ts +15 -0
- package/lib/client/dist/forms.d.ts +77 -0
- package/lib/client/dist/forms.d.ts.map +1 -0
- package/lib/client/dist/forms.js +282 -0
- package/lib/client/dist/forms.js.map +1 -0
- package/lib/client/dist/headless.d.ts +84 -0
- package/lib/client/dist/headless.d.ts.map +1 -0
- package/lib/client/dist/headless.js +376 -0
- package/lib/client/dist/headless.js.map +1 -0
- package/lib/client/dist/index.d.ts +266 -0
- package/lib/client/dist/index.d.ts.map +1 -0
- package/lib/client/dist/index.js +814 -0
- package/lib/client/dist/index.js.map +1 -0
- package/lib/client/dist/workflows.d.ts +128 -0
- package/lib/client/dist/workflows.d.ts.map +1 -0
- package/lib/client/dist/workflows.js +379 -0
- package/lib/client/dist/workflows.js.map +1 -0
- package/lib/client/package.json +5 -0
- package/lib/client/src/forms.ts +215 -0
- package/lib/client/src/headless.ts +265 -0
- package/lib/client/src/index.ts +646 -0
- package/lib/client/src/workflows.ts +307 -0
- package/lib/client-react/dist/components.d.ts +70 -0
- package/lib/client-react/dist/components.d.ts.map +1 -0
- package/lib/client-react/dist/components.js +173 -0
- package/lib/client-react/dist/components.js.map +1 -0
- package/lib/client-react/dist/index.d.ts +29 -0
- package/lib/client-react/dist/index.d.ts.map +1 -0
- package/lib/client-react/dist/index.js +57 -0
- package/lib/client-react/dist/index.js.map +1 -0
- package/lib/client-react/package.json +5 -0
- package/lib/client-react/src/components.ts +183 -0
- package/lib/client-react/src/index.ts +70 -0
- package/lib/code-mode/dist/index.d.ts +142 -0
- package/lib/code-mode/dist/index.d.ts.map +1 -0
- package/lib/code-mode/dist/index.js +498 -0
- package/lib/code-mode/dist/index.js.map +1 -0
- package/lib/code-mode/package.json +5 -0
- package/lib/code-mode/src/index.ts +605 -0
- package/lib/code-mode-workflows/dist/index.d.ts +51 -0
- package/lib/code-mode-workflows/dist/index.d.ts.map +1 -0
- package/lib/code-mode-workflows/dist/index.js +231 -0
- package/lib/code-mode-workflows/dist/index.js.map +1 -0
- package/lib/code-mode-workflows/package.json +5 -0
- package/lib/code-mode-workflows/src/index.ts +259 -0
- package/lib/context/dist/assemble.d.ts +11 -0
- package/lib/context/dist/assemble.d.ts.map +1 -0
- package/lib/context/dist/assemble.js +265 -0
- package/lib/context/dist/assemble.js.map +1 -0
- package/lib/context/dist/cache.d.ts +53 -0
- package/lib/context/dist/cache.d.ts.map +1 -0
- package/lib/context/dist/cache.js +147 -0
- package/lib/context/dist/cache.js.map +1 -0
- package/lib/context/dist/contracts.d.ts +145 -0
- package/lib/context/dist/contracts.d.ts.map +1 -0
- package/lib/context/dist/contracts.js +2 -0
- package/lib/context/dist/contracts.js.map +1 -0
- package/lib/context/dist/index.d.ts +4 -0
- package/lib/context/dist/index.d.ts.map +1 -0
- package/lib/context/dist/index.js +3 -0
- package/lib/context/dist/index.js.map +1 -0
- package/lib/context/package.json +5 -0
- package/lib/context/src/assemble.ts +205 -0
- package/lib/context/src/cache.ts +143 -0
- package/lib/context/src/contracts.ts +124 -0
- package/lib/context/src/index.ts +3 -0
- package/lib/core/dist/budget.d.ts +85 -0
- package/lib/core/dist/budget.d.ts.map +1 -0
- package/lib/core/dist/budget.js +328 -0
- package/lib/core/dist/budget.js.map +1 -0
- package/lib/core/dist/contracts.d.ts +156 -0
- package/lib/core/dist/contracts.d.ts.map +1 -0
- package/lib/core/dist/contracts.js +13 -0
- package/lib/core/dist/contracts.js.map +1 -0
- package/lib/core/dist/errors.d.ts +17 -0
- package/lib/core/dist/errors.d.ts.map +1 -0
- package/lib/core/dist/errors.js +22 -0
- package/lib/core/dist/errors.js.map +1 -0
- package/lib/core/dist/event-stream.d.ts +26 -0
- package/lib/core/dist/event-stream.d.ts.map +1 -0
- package/lib/core/dist/event-stream.js +116 -0
- package/lib/core/dist/event-stream.js.map +1 -0
- package/lib/core/dist/host.d.ts +7 -0
- package/lib/core/dist/host.d.ts.map +1 -0
- package/lib/core/dist/host.js +7 -0
- package/lib/core/dist/host.js.map +1 -0
- package/lib/core/dist/index.d.ts +8 -0
- package/lib/core/dist/index.d.ts.map +1 -0
- package/lib/core/dist/index.js +7 -0
- package/lib/core/dist/index.js.map +1 -0
- package/lib/core/dist/json.d.ts +18 -0
- package/lib/core/dist/json.d.ts.map +1 -0
- package/lib/core/dist/json.js +100 -0
- package/lib/core/dist/json.js.map +1 -0
- package/lib/core/dist/lifecycle.d.ts +45 -0
- package/lib/core/dist/lifecycle.d.ts.map +1 -0
- package/lib/core/dist/lifecycle.js +114 -0
- package/lib/core/dist/lifecycle.js.map +1 -0
- package/lib/core/dist/local-guards.d.ts +4 -0
- package/lib/core/dist/local-guards.d.ts.map +1 -0
- package/lib/core/dist/local-guards.js +47 -0
- package/lib/core/dist/local-guards.js.map +1 -0
- package/lib/core/dist/managed-guards.d.ts +44 -0
- package/lib/core/dist/managed-guards.d.ts.map +1 -0
- package/lib/core/dist/managed-guards.js +146 -0
- package/lib/core/dist/managed-guards.js.map +1 -0
- package/lib/core/dist/schema.d.ts +36 -0
- package/lib/core/dist/schema.d.ts.map +1 -0
- package/lib/core/dist/schema.js +24 -0
- package/lib/core/dist/schema.js.map +1 -0
- package/lib/core/package.json +5 -0
- package/lib/core/src/budget.ts +366 -0
- package/lib/core/src/contracts.ts +107 -0
- package/lib/core/src/errors.ts +33 -0
- package/lib/core/src/event-stream.ts +87 -0
- package/lib/core/src/host.ts +6 -0
- package/lib/core/src/index.ts +7 -0
- package/lib/core/src/json.ts +81 -0
- package/lib/core/src/lifecycle.ts +133 -0
- package/lib/core/src/local-guards.ts +37 -0
- package/lib/core/src/managed-guards.ts +154 -0
- package/lib/core/src/schema.ts +43 -0
- package/lib/exporter-otlp/dist/contracts.d.ts +112 -0
- package/lib/exporter-otlp/dist/contracts.d.ts.map +1 -0
- package/lib/exporter-otlp/dist/contracts.js +2 -0
- package/lib/exporter-otlp/dist/contracts.js.map +1 -0
- package/lib/exporter-otlp/dist/index.d.ts +5 -0
- package/lib/exporter-otlp/dist/index.d.ts.map +1 -0
- package/lib/exporter-otlp/dist/index.js +4 -0
- package/lib/exporter-otlp/dist/index.js.map +1 -0
- package/lib/exporter-otlp/dist/otlp-http-json.d.ts +4 -0
- package/lib/exporter-otlp/dist/otlp-http-json.d.ts.map +1 -0
- package/lib/exporter-otlp/dist/otlp-http-json.js +286 -0
- package/lib/exporter-otlp/dist/otlp-http-json.js.map +1 -0
- package/lib/exporter-otlp/dist/run-traces.d.ts +15 -0
- package/lib/exporter-otlp/dist/run-traces.d.ts.map +1 -0
- package/lib/exporter-otlp/dist/run-traces.js +114 -0
- package/lib/exporter-otlp/dist/run-traces.js.map +1 -0
- package/lib/exporter-otlp/dist/signals.d.ts +4 -0
- package/lib/exporter-otlp/dist/signals.d.ts.map +1 -0
- package/lib/exporter-otlp/dist/signals.js +330 -0
- package/lib/exporter-otlp/dist/signals.js.map +1 -0
- package/lib/exporter-otlp/package.json +5 -0
- package/lib/exporter-otlp/src/contracts.ts +119 -0
- package/lib/exporter-otlp/src/index.ts +23 -0
- package/lib/exporter-otlp/src/otlp-http-json.ts +189 -0
- package/lib/exporter-otlp/src/run-traces.ts +86 -0
- package/lib/exporter-otlp/src/signals.ts +185 -0
- package/lib/guardrails/dist/agent-guard.d.ts +9 -0
- package/lib/guardrails/dist/agent-guard.d.ts.map +1 -0
- package/lib/guardrails/dist/agent-guard.js +23 -0
- package/lib/guardrails/dist/agent-guard.js.map +1 -0
- package/lib/guardrails/dist/auxiliary-helpers.d.ts +63 -0
- package/lib/guardrails/dist/auxiliary-helpers.d.ts.map +1 -0
- package/lib/guardrails/dist/auxiliary-helpers.js +147 -0
- package/lib/guardrails/dist/auxiliary-helpers.js.map +1 -0
- package/lib/guardrails/dist/auxiliary.d.ts +51 -0
- package/lib/guardrails/dist/auxiliary.d.ts.map +1 -0
- package/lib/guardrails/dist/auxiliary.js +230 -0
- package/lib/guardrails/dist/auxiliary.js.map +1 -0
- package/lib/guardrails/dist/batches.d.ts +18 -0
- package/lib/guardrails/dist/batches.d.ts.map +1 -0
- package/lib/guardrails/dist/batches.js +160 -0
- package/lib/guardrails/dist/batches.js.map +1 -0
- package/lib/guardrails/dist/disclosure.d.ts +30 -0
- package/lib/guardrails/dist/disclosure.d.ts.map +1 -0
- package/lib/guardrails/dist/disclosure.js +109 -0
- package/lib/guardrails/dist/disclosure.js.map +1 -0
- package/lib/guardrails/dist/helpers.d.ts +20 -0
- package/lib/guardrails/dist/helpers.d.ts.map +1 -0
- package/lib/guardrails/dist/helpers.js +72 -0
- package/lib/guardrails/dist/helpers.js.map +1 -0
- package/lib/guardrails/dist/index.d.ts +9 -0
- package/lib/guardrails/dist/index.d.ts.map +1 -0
- package/lib/guardrails/dist/index.js +9 -0
- package/lib/guardrails/dist/index.js.map +1 -0
- package/lib/guardrails/dist/managed.d.ts +18 -0
- package/lib/guardrails/dist/managed.d.ts.map +1 -0
- package/lib/guardrails/dist/managed.js +67 -0
- package/lib/guardrails/dist/managed.js.map +1 -0
- package/lib/guardrails/dist/pipeline.d.ts +55 -0
- package/lib/guardrails/dist/pipeline.d.ts.map +1 -0
- package/lib/guardrails/dist/pipeline.js +201 -0
- package/lib/guardrails/dist/pipeline.js.map +1 -0
- package/lib/guardrails/package.json +5 -0
- package/lib/guardrails/src/agent-guard.ts +22 -0
- package/lib/guardrails/src/auxiliary-helpers.ts +146 -0
- package/lib/guardrails/src/auxiliary.ts +202 -0
- package/lib/guardrails/src/batches.ts +130 -0
- package/lib/guardrails/src/disclosure.ts +92 -0
- package/lib/guardrails/src/helpers.ts +67 -0
- package/lib/guardrails/src/index.ts +8 -0
- package/lib/guardrails/src/managed.ts +64 -0
- package/lib/guardrails/src/pipeline.ts +185 -0
- package/lib/helpers/dist/concurrency.d.ts +25 -0
- package/lib/helpers/dist/concurrency.d.ts.map +1 -0
- package/lib/helpers/dist/concurrency.js +106 -0
- package/lib/helpers/dist/concurrency.js.map +1 -0
- package/lib/helpers/dist/configuration.d.ts +42 -0
- package/lib/helpers/dist/configuration.d.ts.map +1 -0
- package/lib/helpers/dist/configuration.js +119 -0
- package/lib/helpers/dist/configuration.js.map +1 -0
- package/lib/helpers/dist/control.d.ts +61 -0
- package/lib/helpers/dist/control.d.ts.map +1 -0
- package/lib/helpers/dist/control.js +220 -0
- package/lib/helpers/dist/control.js.map +1 -0
- package/lib/helpers/dist/credentials.d.ts +42 -0
- package/lib/helpers/dist/credentials.d.ts.map +1 -0
- package/lib/helpers/dist/credentials.js +126 -0
- package/lib/helpers/dist/credentials.js.map +1 -0
- package/lib/helpers/dist/data.d.ts +30 -0
- package/lib/helpers/dist/data.d.ts.map +1 -0
- package/lib/helpers/dist/data.js +90 -0
- package/lib/helpers/dist/data.js.map +1 -0
- package/lib/helpers/dist/index.d.ts +6 -0
- package/lib/helpers/dist/index.d.ts.map +1 -0
- package/lib/helpers/dist/index.js +6 -0
- package/lib/helpers/dist/index.js.map +1 -0
- package/lib/helpers/package.json +5 -0
- package/lib/helpers/src/concurrency.ts +92 -0
- package/lib/helpers/src/configuration.ts +131 -0
- package/lib/helpers/src/control.ts +231 -0
- package/lib/helpers/src/credentials.ts +113 -0
- package/lib/helpers/src/data.ts +105 -0
- package/lib/helpers/src/index.ts +5 -0
- package/lib/memory/dist/contracts.d.ts +146 -0
- package/lib/memory/dist/contracts.d.ts.map +1 -0
- package/lib/memory/dist/contracts.js +2 -0
- package/lib/memory/dist/contracts.js.map +1 -0
- package/lib/memory/dist/index.d.ts +10 -0
- package/lib/memory/dist/index.d.ts.map +1 -0
- package/lib/memory/dist/index.js +316 -0
- package/lib/memory/dist/index.js.map +1 -0
- package/lib/memory/dist/native.d.ts +157 -0
- package/lib/memory/dist/native.d.ts.map +1 -0
- package/lib/memory/dist/native.js +664 -0
- package/lib/memory/dist/native.js.map +1 -0
- package/lib/memory/dist/validation.d.ts +21 -0
- package/lib/memory/dist/validation.d.ts.map +1 -0
- package/lib/memory/dist/validation.js +123 -0
- package/lib/memory/dist/validation.js.map +1 -0
- package/lib/memory/dist/vectors.d.ts +40 -0
- package/lib/memory/dist/vectors.d.ts.map +1 -0
- package/lib/memory/dist/vectors.js +134 -0
- package/lib/memory/dist/vectors.js.map +1 -0
- package/lib/memory/package.json +5 -0
- package/lib/memory/src/contracts.ts +113 -0
- package/lib/memory/src/index.ts +241 -0
- package/lib/memory/src/native.ts +568 -0
- package/lib/memory/src/validation.ts +103 -0
- package/lib/memory/src/vectors.ts +121 -0
- package/lib/memory-remote/dist/index.d.ts +91 -0
- package/lib/memory-remote/dist/index.d.ts.map +1 -0
- package/lib/memory-remote/dist/index.js +434 -0
- package/lib/memory-remote/dist/index.js.map +1 -0
- package/lib/memory-remote/package.json +5 -0
- package/lib/memory-remote/src/index.ts +367 -0
- package/lib/observability/dist/contracts.d.ts +102 -0
- package/lib/observability/dist/contracts.d.ts.map +1 -0
- package/lib/observability/dist/contracts.js +2 -0
- package/lib/observability/dist/contracts.js.map +1 -0
- package/lib/observability/dist/index.d.ts +5 -0
- package/lib/observability/dist/index.d.ts.map +1 -0
- package/lib/observability/dist/index.js +4 -0
- package/lib/observability/dist/index.js.map +1 -0
- package/lib/observability/dist/observer.d.ts +4 -0
- package/lib/observability/dist/observer.d.ts.map +1 -0
- package/lib/observability/dist/observer.js +354 -0
- package/lib/observability/dist/observer.js.map +1 -0
- package/lib/observability/dist/validation.d.ts +6 -0
- package/lib/observability/dist/validation.d.ts.map +1 -0
- package/lib/observability/dist/validation.js +203 -0
- package/lib/observability/dist/validation.js.map +1 -0
- package/lib/observability/package.json +5 -0
- package/lib/observability/src/contracts.ts +85 -0
- package/lib/observability/src/index.ts +4 -0
- package/lib/observability/src/observer.ts +246 -0
- package/lib/observability/src/validation.ts +132 -0
- package/lib/provider-anthropic/dist/index.d.ts +19 -0
- package/lib/provider-anthropic/dist/index.d.ts.map +1 -0
- package/lib/provider-anthropic/dist/index.js +342 -0
- package/lib/provider-anthropic/dist/index.js.map +1 -0
- package/lib/provider-anthropic/package.json +5 -0
- package/lib/provider-anthropic/src/index.ts +317 -0
- package/lib/provider-openai/dist/index.d.ts +77 -0
- package/lib/provider-openai/dist/index.d.ts.map +1 -0
- package/lib/provider-openai/dist/index.js +577 -0
- package/lib/provider-openai/dist/index.js.map +1 -0
- package/lib/provider-openai/package.json +5 -0
- package/lib/provider-openai/src/index.ts +459 -0
- package/lib/runtime/dist/agent.d.ts +63 -0
- package/lib/runtime/dist/agent.d.ts.map +1 -0
- package/lib/runtime/dist/agent.js +134 -0
- package/lib/runtime/dist/agent.js.map +1 -0
- package/lib/runtime/dist/composition.d.ts +21 -0
- package/lib/runtime/dist/composition.d.ts.map +1 -0
- package/lib/runtime/dist/composition.js +54 -0
- package/lib/runtime/dist/composition.js.map +1 -0
- package/lib/runtime/dist/event-buffer.d.ts +18 -0
- package/lib/runtime/dist/event-buffer.d.ts.map +1 -0
- package/lib/runtime/dist/event-buffer.js +66 -0
- package/lib/runtime/dist/event-buffer.js.map +1 -0
- package/lib/runtime/dist/hook-execution.d.ts +40 -0
- package/lib/runtime/dist/hook-execution.d.ts.map +1 -0
- package/lib/runtime/dist/hook-execution.js +186 -0
- package/lib/runtime/dist/hook-execution.js.map +1 -0
- package/lib/runtime/dist/hooks.d.ts +178 -0
- package/lib/runtime/dist/hooks.d.ts.map +1 -0
- package/lib/runtime/dist/hooks.js +120 -0
- package/lib/runtime/dist/hooks.js.map +1 -0
- package/lib/runtime/dist/index.d.ts +6 -0
- package/lib/runtime/dist/index.d.ts.map +1 -0
- package/lib/runtime/dist/index.js +6 -0
- package/lib/runtime/dist/index.js.map +1 -0
- package/lib/runtime/dist/managed-guards.d.ts +27 -0
- package/lib/runtime/dist/managed-guards.d.ts.map +1 -0
- package/lib/runtime/dist/managed-guards.js +183 -0
- package/lib/runtime/dist/managed-guards.js.map +1 -0
- package/lib/runtime/dist/permits.d.ts +9 -0
- package/lib/runtime/dist/permits.d.ts.map +1 -0
- package/lib/runtime/dist/permits.js +77 -0
- package/lib/runtime/dist/permits.js.map +1 -0
- package/lib/runtime/dist/response.d.ts +8 -0
- package/lib/runtime/dist/response.d.ts.map +1 -0
- package/lib/runtime/dist/response.js +83 -0
- package/lib/runtime/dist/response.js.map +1 -0
- package/lib/runtime/dist/router.d.ts +51 -0
- package/lib/runtime/dist/router.d.ts.map +1 -0
- package/lib/runtime/dist/router.js +181 -0
- package/lib/runtime/dist/router.js.map +1 -0
- package/lib/runtime/dist/runtime.d.ts +98 -0
- package/lib/runtime/dist/runtime.d.ts.map +1 -0
- package/lib/runtime/dist/runtime.js +945 -0
- package/lib/runtime/dist/runtime.js.map +1 -0
- package/lib/runtime/dist/stream.d.ts +25 -0
- package/lib/runtime/dist/stream.d.ts.map +1 -0
- package/lib/runtime/dist/stream.js +226 -0
- package/lib/runtime/dist/stream.js.map +1 -0
- package/lib/runtime/package.json +5 -0
- package/lib/runtime/src/agent.ts +167 -0
- package/lib/runtime/src/composition.ts +63 -0
- package/lib/runtime/src/event-buffer.ts +55 -0
- package/lib/runtime/src/hook-execution.ts +188 -0
- package/lib/runtime/src/hooks.ts +227 -0
- package/lib/runtime/src/index.ts +5 -0
- package/lib/runtime/src/managed-guards.ts +176 -0
- package/lib/runtime/src/permits.ts +65 -0
- package/lib/runtime/src/response.ts +68 -0
- package/lib/runtime/src/router.ts +178 -0
- package/lib/runtime/src/runtime.ts +909 -0
- package/lib/runtime/src/stream.ts +130 -0
- package/lib/sdk/dist/index.d.ts +5 -0
- package/lib/sdk/dist/index.d.ts.map +1 -0
- package/lib/sdk/dist/index.js +5 -0
- package/lib/sdk/dist/index.js.map +1 -0
- package/lib/sdk/package.json +5 -0
- package/lib/sdk/src/index.ts +4 -0
- package/lib/server/dist/index.d.ts +343 -0
- package/lib/server/dist/index.d.ts.map +1 -0
- package/lib/server/dist/index.js +1356 -0
- package/lib/server/dist/index.js.map +1 -0
- package/lib/server/dist/inspector-bundle.d.ts +6 -0
- package/lib/server/dist/inspector-bundle.d.ts.map +1 -0
- package/lib/server/dist/inspector-bundle.js +6 -0
- package/lib/server/dist/inspector-bundle.js.map +1 -0
- package/lib/server/dist/inspector.d.ts +3 -0
- package/lib/server/dist/inspector.d.ts.map +1 -0
- package/lib/server/dist/inspector.js +27 -0
- package/lib/server/dist/inspector.js.map +1 -0
- package/lib/server/package.json +5 -0
- package/lib/server/src/index.ts +1033 -0
- package/lib/server/src/inspector-bundle.ts +5 -0
- package/lib/server/src/inspector.ts +27 -0
- package/lib/server-node/dist/hardening.d.ts +19 -0
- package/lib/server-node/dist/hardening.d.ts.map +1 -0
- package/lib/server-node/dist/hardening.js +79 -0
- package/lib/server-node/dist/hardening.js.map +1 -0
- package/lib/server-node/dist/index.d.ts +18 -0
- package/lib/server-node/dist/index.d.ts.map +1 -0
- package/lib/server-node/dist/index.js +53 -0
- package/lib/server-node/dist/index.js.map +1 -0
- package/lib/server-node/dist/probe.d.ts +13 -0
- package/lib/server-node/dist/probe.d.ts.map +1 -0
- package/lib/server-node/dist/probe.js +44 -0
- package/lib/server-node/dist/probe.js.map +1 -0
- package/lib/server-node/dist/production.d.ts +32 -0
- package/lib/server-node/dist/production.d.ts.map +1 -0
- package/lib/server-node/dist/production.js +125 -0
- package/lib/server-node/dist/production.js.map +1 -0
- package/lib/server-node/package.json +5 -0
- package/lib/server-node/src/hardening.ts +79 -0
- package/lib/server-node/src/index.ts +58 -0
- package/lib/server-node/src/probe.ts +36 -0
- package/lib/server-node/src/production.ts +116 -0
- package/lib/storage/dist/index.d.ts +4 -0
- package/lib/storage/dist/index.d.ts.map +1 -0
- package/lib/storage/dist/index.js +5 -0
- package/lib/storage/dist/index.js.map +1 -0
- package/lib/storage/package.json +5 -0
- package/lib/storage/src/index.ts +5 -0
- package/lib/storage-contracts/dist/contracts.d.ts +69 -0
- package/lib/storage-contracts/dist/contracts.d.ts.map +1 -0
- package/lib/storage-contracts/dist/contracts.js +15 -0
- package/lib/storage-contracts/dist/contracts.js.map +1 -0
- package/lib/storage-contracts/dist/durable-budget-contracts.d.ts +110 -0
- package/lib/storage-contracts/dist/durable-budget-contracts.d.ts.map +1 -0
- package/lib/storage-contracts/dist/durable-budget-contracts.js +430 -0
- package/lib/storage-contracts/dist/durable-budget-contracts.js.map +1 -0
- package/lib/storage-contracts/dist/execution-wait-contracts.d.ts +74 -0
- package/lib/storage-contracts/dist/execution-wait-contracts.d.ts.map +1 -0
- package/lib/storage-contracts/dist/execution-wait-contracts.js +159 -0
- package/lib/storage-contracts/dist/execution-wait-contracts.js.map +1 -0
- package/lib/storage-contracts/dist/index.d.ts +18 -0
- package/lib/storage-contracts/dist/index.d.ts.map +1 -0
- package/lib/storage-contracts/dist/index.js +18 -0
- package/lib/storage-contracts/dist/index.js.map +1 -0
- package/lib/storage-contracts/dist/memory-contracts.d.ts +208 -0
- package/lib/storage-contracts/dist/memory-contracts.d.ts.map +1 -0
- package/lib/storage-contracts/dist/memory-contracts.js +350 -0
- package/lib/storage-contracts/dist/memory-contracts.js.map +1 -0
- package/lib/storage-contracts/dist/scheduled-workflow-contracts.d.ts +171 -0
- package/lib/storage-contracts/dist/scheduled-workflow-contracts.d.ts.map +1 -0
- package/lib/storage-contracts/dist/scheduled-workflow-contracts.js +2 -0
- package/lib/storage-contracts/dist/scheduled-workflow-contracts.js.map +1 -0
- package/lib/storage-contracts/dist/scheduler-contracts.d.ts +133 -0
- package/lib/storage-contracts/dist/scheduler-contracts.d.ts.map +1 -0
- package/lib/storage-contracts/dist/scheduler-contracts.js +2 -0
- package/lib/storage-contracts/dist/scheduler-contracts.js.map +1 -0
- package/lib/storage-contracts/dist/submission-journal.d.ts +21 -0
- package/lib/storage-contracts/dist/submission-journal.d.ts.map +1 -0
- package/lib/storage-contracts/dist/submission-journal.js +51 -0
- package/lib/storage-contracts/dist/submission-journal.js.map +1 -0
- package/lib/storage-contracts/dist/workflow-format2.d.ts +54 -0
- package/lib/storage-contracts/dist/workflow-format2.d.ts.map +1 -0
- package/lib/storage-contracts/dist/workflow-format2.js +398 -0
- package/lib/storage-contracts/dist/workflow-format2.js.map +1 -0
- package/lib/storage-contracts/dist/workflow-format3.d.ts +20 -0
- package/lib/storage-contracts/dist/workflow-format3.d.ts.map +1 -0
- package/lib/storage-contracts/dist/workflow-format3.js +309 -0
- package/lib/storage-contracts/dist/workflow-format3.js.map +1 -0
- package/lib/storage-contracts/dist/workflow-format4.d.ts +48 -0
- package/lib/storage-contracts/dist/workflow-format4.d.ts.map +1 -0
- package/lib/storage-contracts/dist/workflow-format4.js +132 -0
- package/lib/storage-contracts/dist/workflow-format4.js.map +1 -0
- package/lib/storage-contracts/dist/workflow-format5.d.ts +94 -0
- package/lib/storage-contracts/dist/workflow-format5.d.ts.map +1 -0
- package/lib/storage-contracts/dist/workflow-format5.js +365 -0
- package/lib/storage-contracts/dist/workflow-format5.js.map +1 -0
- package/lib/storage-contracts/dist/workflow-graph-contracts.d.ts +69 -0
- package/lib/storage-contracts/dist/workflow-graph-contracts.d.ts.map +1 -0
- package/lib/storage-contracts/dist/workflow-graph-contracts.js +2 -0
- package/lib/storage-contracts/dist/workflow-graph-contracts.js.map +1 -0
- package/lib/storage-contracts/dist/workflow-graph-discovery.d.ts +45 -0
- package/lib/storage-contracts/dist/workflow-graph-discovery.d.ts.map +1 -0
- package/lib/storage-contracts/dist/workflow-graph-discovery.js +101 -0
- package/lib/storage-contracts/dist/workflow-graph-discovery.js.map +1 -0
- package/lib/storage-contracts/dist/workflow-loop-format1.d.ts +52 -0
- package/lib/storage-contracts/dist/workflow-loop-format1.d.ts.map +1 -0
- package/lib/storage-contracts/dist/workflow-loop-format1.js +134 -0
- package/lib/storage-contracts/dist/workflow-loop-format1.js.map +1 -0
- package/lib/storage-contracts/dist/workflow-saga-format1.d.ts +52 -0
- package/lib/storage-contracts/dist/workflow-saga-format1.d.ts.map +1 -0
- package/lib/storage-contracts/dist/workflow-saga-format1.js +235 -0
- package/lib/storage-contracts/dist/workflow-saga-format1.js.map +1 -0
- package/lib/storage-contracts/dist/workflow-tree-contracts.d.ts +428 -0
- package/lib/storage-contracts/dist/workflow-tree-contracts.d.ts.map +1 -0
- package/lib/storage-contracts/dist/workflow-tree-contracts.js +151 -0
- package/lib/storage-contracts/dist/workflow-tree-contracts.js.map +1 -0
- package/lib/storage-contracts/dist/workflow-tree-discovery.d.ts +38 -0
- package/lib/storage-contracts/dist/workflow-tree-discovery.d.ts.map +1 -0
- package/lib/storage-contracts/dist/workflow-tree-discovery.js +57 -0
- package/lib/storage-contracts/dist/workflow-tree-discovery.js.map +1 -0
- package/lib/storage-contracts/package.json +5 -0
- package/lib/storage-contracts/src/contracts.ts +73 -0
- package/lib/storage-contracts/src/durable-budget-contracts.ts +266 -0
- package/lib/storage-contracts/src/execution-wait-contracts.ts +169 -0
- package/lib/storage-contracts/src/index.ts +17 -0
- package/lib/storage-contracts/src/memory-contracts.ts +322 -0
- package/lib/storage-contracts/src/scheduled-workflow-contracts.ts +88 -0
- package/lib/storage-contracts/src/scheduler-contracts.ts +68 -0
- package/lib/storage-contracts/src/submission-journal.ts +50 -0
- package/lib/storage-contracts/src/workflow-format2.ts +288 -0
- package/lib/storage-contracts/src/workflow-format3.ts +201 -0
- package/lib/storage-contracts/src/workflow-format4.ts +96 -0
- package/lib/storage-contracts/src/workflow-format5.ts +375 -0
- package/lib/storage-contracts/src/workflow-graph-contracts.ts +44 -0
- package/lib/storage-contracts/src/workflow-graph-discovery.ts +107 -0
- package/lib/storage-contracts/src/workflow-loop-format1.ts +102 -0
- package/lib/storage-contracts/src/workflow-saga-format1.ts +165 -0
- package/lib/storage-contracts/src/workflow-tree-contracts.ts +191 -0
- package/lib/storage-contracts/src/workflow-tree-discovery.ts +39 -0
- package/lib/storage-postgres/dist/index.d.ts +2 -0
- package/lib/storage-postgres/dist/index.d.ts.map +1 -0
- package/lib/storage-postgres/dist/index.js +2 -0
- package/lib/storage-postgres/dist/index.js.map +1 -0
- package/lib/storage-postgres/dist/postgres.d.ts +8 -0
- package/lib/storage-postgres/dist/postgres.d.ts.map +1 -0
- package/lib/storage-postgres/dist/postgres.js +233 -0
- package/lib/storage-postgres/dist/postgres.js.map +1 -0
- package/lib/storage-postgres/package.json +5 -0
- package/lib/storage-postgres/src/index.ts +1 -0
- package/lib/storage-postgres/src/postgres.ts +222 -0
- package/lib/storage-sql/dist/aggregate-session.d.ts +31 -0
- package/lib/storage-sql/dist/aggregate-session.d.ts.map +1 -0
- package/lib/storage-sql/dist/aggregate-session.js +78 -0
- package/lib/storage-sql/dist/aggregate-session.js.map +1 -0
- package/lib/storage-sql/dist/contracts.d.ts +2 -0
- package/lib/storage-sql/dist/contracts.d.ts.map +1 -0
- package/lib/storage-sql/dist/contracts.js +3 -0
- package/lib/storage-sql/dist/contracts.js.map +1 -0
- package/lib/storage-sql/dist/durable-budget-database.d.ts +33 -0
- package/lib/storage-sql/dist/durable-budget-database.d.ts.map +1 -0
- package/lib/storage-sql/dist/durable-budget-database.js +191 -0
- package/lib/storage-sql/dist/durable-budget-database.js.map +1 -0
- package/lib/storage-sql/dist/durable-budget-state.d.ts +24 -0
- package/lib/storage-sql/dist/durable-budget-state.d.ts.map +1 -0
- package/lib/storage-sql/dist/durable-budget-state.js +211 -0
- package/lib/storage-sql/dist/durable-budget-state.js.map +1 -0
- package/lib/storage-sql/dist/durable-budget-validation.d.ts +5 -0
- package/lib/storage-sql/dist/durable-budget-validation.d.ts.map +1 -0
- package/lib/storage-sql/dist/durable-budget-validation.js +22 -0
- package/lib/storage-sql/dist/durable-budget-validation.js.map +1 -0
- package/lib/storage-sql/dist/execution-completions.d.ts +12 -0
- package/lib/storage-sql/dist/execution-completions.d.ts.map +1 -0
- package/lib/storage-sql/dist/execution-completions.js +60 -0
- package/lib/storage-sql/dist/execution-completions.js.map +1 -0
- package/lib/storage-sql/dist/execution-wait-database.d.ts +22 -0
- package/lib/storage-sql/dist/execution-wait-database.d.ts.map +1 -0
- package/lib/storage-sql/dist/execution-wait-database.js +288 -0
- package/lib/storage-sql/dist/execution-wait-database.js.map +1 -0
- package/lib/storage-sql/dist/execution-wait-validation.d.ts +8 -0
- package/lib/storage-sql/dist/execution-wait-validation.d.ts.map +1 -0
- package/lib/storage-sql/dist/execution-wait-validation.js +125 -0
- package/lib/storage-sql/dist/execution-wait-validation.js.map +1 -0
- package/lib/storage-sql/dist/host.d.ts +22 -0
- package/lib/storage-sql/dist/host.d.ts.map +1 -0
- package/lib/storage-sql/dist/host.js +21 -0
- package/lib/storage-sql/dist/host.js.map +1 -0
- package/lib/storage-sql/dist/memory-database.d.ts +24 -0
- package/lib/storage-sql/dist/memory-database.d.ts.map +1 -0
- package/lib/storage-sql/dist/memory-database.js +359 -0
- package/lib/storage-sql/dist/memory-database.js.map +1 -0
- package/lib/storage-sql/dist/scheduled-database.d.ts +74 -0
- package/lib/storage-sql/dist/scheduled-database.d.ts.map +1 -0
- package/lib/storage-sql/dist/scheduled-database.js +1152 -0
- package/lib/storage-sql/dist/scheduled-database.js.map +1 -0
- package/lib/storage-sql/dist/scheduled-validation.d.ts +9 -0
- package/lib/storage-sql/dist/scheduled-validation.d.ts.map +1 -0
- package/lib/storage-sql/dist/scheduled-validation.js +200 -0
- package/lib/storage-sql/dist/scheduled-validation.js.map +1 -0
- package/lib/storage-sql/dist/scheduler-contracts.d.ts +2 -0
- package/lib/storage-sql/dist/scheduler-contracts.d.ts.map +1 -0
- package/lib/storage-sql/dist/scheduler-contracts.js +3 -0
- package/lib/storage-sql/dist/scheduler-contracts.js.map +1 -0
- package/lib/storage-sql/dist/scheduler-database.d.ts +55 -0
- package/lib/storage-sql/dist/scheduler-database.d.ts.map +1 -0
- package/lib/storage-sql/dist/scheduler-database.js +655 -0
- package/lib/storage-sql/dist/scheduler-database.js.map +1 -0
- package/lib/storage-sql/dist/scheduler-validation.d.ts +22 -0
- package/lib/storage-sql/dist/scheduler-validation.d.ts.map +1 -0
- package/lib/storage-sql/dist/scheduler-validation.js +201 -0
- package/lib/storage-sql/dist/scheduler-validation.js.map +1 -0
- package/lib/storage-sql/dist/validation.d.ts +14 -0
- package/lib/storage-sql/dist/validation.d.ts.map +1 -0
- package/lib/storage-sql/dist/validation.js +106 -0
- package/lib/storage-sql/dist/validation.js.map +1 -0
- package/lib/storage-sql/dist/workflow-graph-discovery-index.d.ts +7 -0
- package/lib/storage-sql/dist/workflow-graph-discovery-index.d.ts.map +1 -0
- package/lib/storage-sql/dist/workflow-graph-discovery-index.js +55 -0
- package/lib/storage-sql/dist/workflow-graph-discovery-index.js.map +1 -0
- package/lib/storage-sql/dist/workflow-graph-discovery-validation.d.ts +5 -0
- package/lib/storage-sql/dist/workflow-graph-discovery-validation.d.ts.map +1 -0
- package/lib/storage-sql/dist/workflow-graph-discovery-validation.js +22 -0
- package/lib/storage-sql/dist/workflow-graph-discovery-validation.js.map +1 -0
- package/lib/storage-sql/dist/workflow-tree-database.d.ts +270 -0
- package/lib/storage-sql/dist/workflow-tree-database.d.ts.map +1 -0
- package/lib/storage-sql/dist/workflow-tree-database.js +1692 -0
- package/lib/storage-sql/dist/workflow-tree-database.js.map +1 -0
- package/lib/storage-sql/dist/workflow-tree-discovery-validation.d.ts +5 -0
- package/lib/storage-sql/dist/workflow-tree-discovery-validation.d.ts.map +1 -0
- package/lib/storage-sql/dist/workflow-tree-discovery-validation.js +15 -0
- package/lib/storage-sql/dist/workflow-tree-discovery-validation.js.map +1 -0
- package/lib/storage-sql/dist/workflow-tree-validation.d.ts +9 -0
- package/lib/storage-sql/dist/workflow-tree-validation.d.ts.map +1 -0
- package/lib/storage-sql/dist/workflow-tree-validation.js +576 -0
- package/lib/storage-sql/dist/workflow-tree-validation.js.map +1 -0
- package/lib/storage-sql/package.json +5 -0
- package/lib/storage-sql/src/aggregate-session.ts +72 -0
- package/lib/storage-sql/src/contracts.ts +2 -0
- package/lib/storage-sql/src/durable-budget-database.ts +180 -0
- package/lib/storage-sql/src/durable-budget-state.ts +155 -0
- package/lib/storage-sql/src/durable-budget-validation.ts +23 -0
- package/lib/storage-sql/src/execution-completions.ts +58 -0
- package/lib/storage-sql/src/execution-wait-database.ts +219 -0
- package/lib/storage-sql/src/execution-wait-validation.ts +108 -0
- package/lib/storage-sql/src/host.ts +21 -0
- package/lib/storage-sql/src/memory-database.ts +320 -0
- package/lib/storage-sql/src/scheduled-database.ts +811 -0
- package/lib/storage-sql/src/scheduled-validation.ts +89 -0
- package/lib/storage-sql/src/scheduler-contracts.ts +2 -0
- package/lib/storage-sql/src/scheduler-database.ts +475 -0
- package/lib/storage-sql/src/scheduler-validation.ts +112 -0
- package/lib/storage-sql/src/validation.ts +104 -0
- package/lib/storage-sql/src/workflow-graph-discovery-index.ts +60 -0
- package/lib/storage-sql/src/workflow-graph-discovery-validation.ts +21 -0
- package/lib/storage-sql/src/workflow-tree-database.ts +450 -0
- package/lib/storage-sql/src/workflow-tree-discovery-validation.ts +13 -0
- package/lib/storage-sql/src/workflow-tree-validation.ts +166 -0
- package/lib/storage-sqlite/dist/backup.d.ts +24 -0
- package/lib/storage-sqlite/dist/backup.d.ts.map +1 -0
- package/lib/storage-sqlite/dist/backup.js +84 -0
- package/lib/storage-sqlite/dist/backup.js.map +1 -0
- package/lib/storage-sqlite/dist/index.d.ts +4 -0
- package/lib/storage-sqlite/dist/index.d.ts.map +1 -0
- package/lib/storage-sqlite/dist/index.js +4 -0
- package/lib/storage-sqlite/dist/index.js.map +1 -0
- package/lib/storage-sqlite/dist/migrations.d.ts +6 -0
- package/lib/storage-sqlite/dist/migrations.d.ts.map +1 -0
- package/lib/storage-sqlite/dist/migrations.js +50 -0
- package/lib/storage-sqlite/dist/migrations.js.map +1 -0
- package/lib/storage-sqlite/dist/sqlite-database.d.ts +36 -0
- package/lib/storage-sqlite/dist/sqlite-database.d.ts.map +1 -0
- package/lib/storage-sqlite/dist/sqlite-database.js +179 -0
- package/lib/storage-sqlite/dist/sqlite-database.js.map +1 -0
- package/lib/storage-sqlite/dist/sqlite-worker.d.ts +2 -0
- package/lib/storage-sqlite/dist/sqlite-worker.d.ts.map +1 -0
- package/lib/storage-sqlite/dist/sqlite-worker.js +95 -0
- package/lib/storage-sqlite/dist/sqlite-worker.js.map +1 -0
- package/lib/storage-sqlite/dist/sqlite.d.ts +7 -0
- package/lib/storage-sqlite/dist/sqlite.d.ts.map +1 -0
- package/lib/storage-sqlite/dist/sqlite.js +78 -0
- package/lib/storage-sqlite/dist/sqlite.js.map +1 -0
- package/lib/storage-sqlite/package.json +5 -0
- package/lib/storage-sqlite/src/backup.ts +58 -0
- package/lib/storage-sqlite/src/index.ts +3 -0
- package/lib/storage-sqlite/src/migrations.ts +46 -0
- package/lib/storage-sqlite/src/sqlite-database.ts +172 -0
- package/lib/storage-sqlite/src/sqlite-worker.ts +52 -0
- package/lib/storage-sqlite/src/sqlite.ts +72 -0
- package/lib/testing/dist/index.d.ts +10 -0
- package/lib/testing/dist/index.d.ts.map +1 -0
- package/lib/testing/dist/index.js +24 -0
- package/lib/testing/dist/index.js.map +1 -0
- package/lib/testing/package.json +5 -0
- package/lib/testing/src/index.ts +26 -0
- package/lib/tools/dist/batch.d.ts +71 -0
- package/lib/tools/dist/batch.d.ts.map +1 -0
- package/lib/tools/dist/batch.js +542 -0
- package/lib/tools/dist/batch.js.map +1 -0
- package/lib/tools/dist/budget-binding.d.ts +18 -0
- package/lib/tools/dist/budget-binding.d.ts.map +1 -0
- package/lib/tools/dist/budget-binding.js +65 -0
- package/lib/tools/dist/budget-binding.js.map +1 -0
- package/lib/tools/dist/context.d.ts +17 -0
- package/lib/tools/dist/context.d.ts.map +1 -0
- package/lib/tools/dist/context.js +52 -0
- package/lib/tools/dist/context.js.map +1 -0
- package/lib/tools/dist/host.d.ts +3 -0
- package/lib/tools/dist/host.d.ts.map +1 -0
- package/lib/tools/dist/host.js +3 -0
- package/lib/tools/dist/host.js.map +1 -0
- package/lib/tools/dist/index.d.ts +79 -0
- package/lib/tools/dist/index.d.ts.map +1 -0
- package/lib/tools/dist/index.js +462 -0
- package/lib/tools/dist/index.js.map +1 -0
- package/lib/tools/package.json +5 -0
- package/lib/tools/src/batch.ts +496 -0
- package/lib/tools/src/budget-binding.ts +63 -0
- package/lib/tools/src/context.ts +56 -0
- package/lib/tools/src/host.ts +2 -0
- package/lib/tools/src/index.ts +479 -0
- package/lib/workflows/dist/agents.d.ts +24 -0
- package/lib/workflows/dist/agents.d.ts.map +1 -0
- package/lib/workflows/dist/agents.js +55 -0
- package/lib/workflows/dist/agents.js.map +1 -0
- package/lib/workflows/dist/children-coordinator.d.ts +58 -0
- package/lib/workflows/dist/children-coordinator.d.ts.map +1 -0
- package/lib/workflows/dist/children-coordinator.js +148 -0
- package/lib/workflows/dist/children-coordinator.js.map +1 -0
- package/lib/workflows/dist/children-definition.d.ts +43 -0
- package/lib/workflows/dist/children-definition.d.ts.map +1 -0
- package/lib/workflows/dist/children-definition.js +74 -0
- package/lib/workflows/dist/children-definition.js.map +1 -0
- package/lib/workflows/dist/children-discovery.d.ts +20 -0
- package/lib/workflows/dist/children-discovery.d.ts.map +1 -0
- package/lib/workflows/dist/children-discovery.js +103 -0
- package/lib/workflows/dist/children-discovery.js.map +1 -0
- package/lib/workflows/dist/children-runtime.d.ts +72 -0
- package/lib/workflows/dist/children-runtime.d.ts.map +1 -0
- package/lib/workflows/dist/children-runtime.js +600 -0
- package/lib/workflows/dist/children-runtime.js.map +1 -0
- package/lib/workflows/dist/children.d.ts +9 -0
- package/lib/workflows/dist/children.d.ts.map +1 -0
- package/lib/workflows/dist/children.js +6 -0
- package/lib/workflows/dist/children.js.map +1 -0
- package/lib/workflows/dist/composite-fleet.d.ts +87 -0
- package/lib/workflows/dist/composite-fleet.d.ts.map +1 -0
- package/lib/workflows/dist/composite-fleet.js +259 -0
- package/lib/workflows/dist/composite-fleet.js.map +1 -0
- package/lib/workflows/dist/composite-host.d.ts +45 -0
- package/lib/workflows/dist/composite-host.d.ts.map +1 -0
- package/lib/workflows/dist/composite-host.js +132 -0
- package/lib/workflows/dist/composite-host.js.map +1 -0
- package/lib/workflows/dist/composites.d.ts +4 -0
- package/lib/workflows/dist/composites.d.ts.map +1 -0
- package/lib/workflows/dist/composites.js +3 -0
- package/lib/workflows/dist/composites.js.map +1 -0
- package/lib/workflows/dist/definition.d.ts +61 -0
- package/lib/workflows/dist/definition.d.ts.map +1 -0
- package/lib/workflows/dist/definition.js +112 -0
- package/lib/workflows/dist/definition.js.map +1 -0
- package/lib/workflows/dist/drain.d.ts +21 -0
- package/lib/workflows/dist/drain.d.ts.map +1 -0
- package/lib/workflows/dist/drain.js +53 -0
- package/lib/workflows/dist/drain.js.map +1 -0
- package/lib/workflows/dist/ephemeral.d.ts +24 -0
- package/lib/workflows/dist/ephemeral.d.ts.map +1 -0
- package/lib/workflows/dist/ephemeral.js +122 -0
- package/lib/workflows/dist/ephemeral.js.map +1 -0
- package/lib/workflows/dist/fleet-control.d.ts +129 -0
- package/lib/workflows/dist/fleet-control.d.ts.map +1 -0
- package/lib/workflows/dist/fleet-control.js +356 -0
- package/lib/workflows/dist/fleet-control.js.map +1 -0
- package/lib/workflows/dist/graph-coordinator.d.ts +60 -0
- package/lib/workflows/dist/graph-coordinator.d.ts.map +1 -0
- package/lib/workflows/dist/graph-coordinator.js +266 -0
- package/lib/workflows/dist/graph-coordinator.js.map +1 -0
- package/lib/workflows/dist/graph-definition.d.ts +40 -0
- package/lib/workflows/dist/graph-definition.d.ts.map +1 -0
- package/lib/workflows/dist/graph-definition.js +58 -0
- package/lib/workflows/dist/graph-definition.js.map +1 -0
- package/lib/workflows/dist/graph-discovery.d.ts +27 -0
- package/lib/workflows/dist/graph-discovery.d.ts.map +1 -0
- package/lib/workflows/dist/graph-discovery.js +165 -0
- package/lib/workflows/dist/graph-discovery.js.map +1 -0
- package/lib/workflows/dist/graphs.d.ts +55 -0
- package/lib/workflows/dist/graphs.d.ts.map +1 -0
- package/lib/workflows/dist/graphs.js +10 -0
- package/lib/workflows/dist/graphs.js.map +1 -0
- package/lib/workflows/dist/hook-relay.d.ts +67 -0
- package/lib/workflows/dist/hook-relay.d.ts.map +1 -0
- package/lib/workflows/dist/hook-relay.js +157 -0
- package/lib/workflows/dist/hook-relay.js.map +1 -0
- package/lib/workflows/dist/index.d.ts +16 -0
- package/lib/workflows/dist/index.d.ts.map +1 -0
- package/lib/workflows/dist/index.js +15 -0
- package/lib/workflows/dist/index.js.map +1 -0
- package/lib/workflows/dist/leadership.d.ts +33 -0
- package/lib/workflows/dist/leadership.d.ts.map +1 -0
- package/lib/workflows/dist/leadership.js +109 -0
- package/lib/workflows/dist/leadership.js.map +1 -0
- package/lib/workflows/dist/lifecycle-definition.d.ts +89 -0
- package/lib/workflows/dist/lifecycle-definition.d.ts.map +1 -0
- package/lib/workflows/dist/lifecycle-definition.js +137 -0
- package/lib/workflows/dist/lifecycle-definition.js.map +1 -0
- package/lib/workflows/dist/lifecycle-fleet.d.ts +90 -0
- package/lib/workflows/dist/lifecycle-fleet.d.ts.map +1 -0
- package/lib/workflows/dist/lifecycle-fleet.js +406 -0
- package/lib/workflows/dist/lifecycle-fleet.js.map +1 -0
- package/lib/workflows/dist/lifecycle-host.d.ts +44 -0
- package/lib/workflows/dist/lifecycle-host.d.ts.map +1 -0
- package/lib/workflows/dist/lifecycle-host.js +133 -0
- package/lib/workflows/dist/lifecycle-host.js.map +1 -0
- package/lib/workflows/dist/lifecycle-human-transport.d.ts +67 -0
- package/lib/workflows/dist/lifecycle-human-transport.d.ts.map +1 -0
- package/lib/workflows/dist/lifecycle-human-transport.js +149 -0
- package/lib/workflows/dist/lifecycle-human-transport.js.map +1 -0
- package/lib/workflows/dist/lifecycle-runtime.d.ts +115 -0
- package/lib/workflows/dist/lifecycle-runtime.d.ts.map +1 -0
- package/lib/workflows/dist/lifecycle-runtime.js +831 -0
- package/lib/workflows/dist/lifecycle-runtime.js.map +1 -0
- package/lib/workflows/dist/lifecycle.d.ts +10 -0
- package/lib/workflows/dist/lifecycle.d.ts.map +1 -0
- package/lib/workflows/dist/lifecycle.js +7 -0
- package/lib/workflows/dist/lifecycle.js.map +1 -0
- package/lib/workflows/dist/loop-definition.d.ts +46 -0
- package/lib/workflows/dist/loop-definition.d.ts.map +1 -0
- package/lib/workflows/dist/loop-definition.js +55 -0
- package/lib/workflows/dist/loop-definition.js.map +1 -0
- package/lib/workflows/dist/loop-runtime.d.ts +47 -0
- package/lib/workflows/dist/loop-runtime.d.ts.map +1 -0
- package/lib/workflows/dist/loop-runtime.js +358 -0
- package/lib/workflows/dist/loop-runtime.js.map +1 -0
- package/lib/workflows/dist/loops.d.ts +6 -0
- package/lib/workflows/dist/loops.d.ts.map +1 -0
- package/lib/workflows/dist/loops.js +4 -0
- package/lib/workflows/dist/loops.js.map +1 -0
- package/lib/workflows/dist/migration-service.d.ts +55 -0
- package/lib/workflows/dist/migration-service.d.ts.map +1 -0
- package/lib/workflows/dist/migration-service.js +73 -0
- package/lib/workflows/dist/migration-service.js.map +1 -0
- package/lib/workflows/dist/migration.d.ts +123 -0
- package/lib/workflows/dist/migration.d.ts.map +1 -0
- package/lib/workflows/dist/migration.js +217 -0
- package/lib/workflows/dist/migration.js.map +1 -0
- package/lib/workflows/dist/operator-transports.d.ts +265 -0
- package/lib/workflows/dist/operator-transports.d.ts.map +1 -0
- package/lib/workflows/dist/operator-transports.js +404 -0
- package/lib/workflows/dist/operator-transports.js.map +1 -0
- package/lib/workflows/dist/reconciliation.d.ts +25 -0
- package/lib/workflows/dist/reconciliation.d.ts.map +1 -0
- package/lib/workflows/dist/reconciliation.js +109 -0
- package/lib/workflows/dist/reconciliation.js.map +1 -0
- package/lib/workflows/dist/runtime.d.ts +65 -0
- package/lib/workflows/dist/runtime.d.ts.map +1 -0
- package/lib/workflows/dist/runtime.js +492 -0
- package/lib/workflows/dist/runtime.js.map +1 -0
- package/lib/workflows/dist/saga-definition.d.ts +46 -0
- package/lib/workflows/dist/saga-definition.d.ts.map +1 -0
- package/lib/workflows/dist/saga-definition.js +71 -0
- package/lib/workflows/dist/saga-definition.js.map +1 -0
- package/lib/workflows/dist/saga-runtime.d.ts +51 -0
- package/lib/workflows/dist/saga-runtime.d.ts.map +1 -0
- package/lib/workflows/dist/saga-runtime.js +499 -0
- package/lib/workflows/dist/saga-runtime.js.map +1 -0
- package/lib/workflows/dist/sagas.d.ts +6 -0
- package/lib/workflows/dist/sagas.d.ts.map +1 -0
- package/lib/workflows/dist/sagas.js +4 -0
- package/lib/workflows/dist/sagas.js.map +1 -0
- package/lib/workflows/dist/scheduled-helpers.d.ts +53 -0
- package/lib/workflows/dist/scheduled-helpers.d.ts.map +1 -0
- package/lib/workflows/dist/scheduled-helpers.js +230 -0
- package/lib/workflows/dist/scheduled-helpers.js.map +1 -0
- package/lib/workflows/dist/scheduled.d.ts +116 -0
- package/lib/workflows/dist/scheduled.d.ts.map +1 -0
- package/lib/workflows/dist/scheduled.js +781 -0
- package/lib/workflows/dist/scheduled.js.map +1 -0
- package/lib/workflows/dist/traces.d.ts +158 -0
- package/lib/workflows/dist/traces.d.ts.map +1 -0
- package/lib/workflows/dist/traces.js +366 -0
- package/lib/workflows/dist/traces.js.map +1 -0
- package/lib/workflows/dist/versions.d.ts +57 -0
- package/lib/workflows/dist/versions.d.ts.map +1 -0
- package/lib/workflows/dist/versions.js +87 -0
- package/lib/workflows/dist/versions.js.map +1 -0
- package/lib/workflows/dist/worker.d.ts +51 -0
- package/lib/workflows/dist/worker.d.ts.map +1 -0
- package/lib/workflows/dist/worker.js +143 -0
- package/lib/workflows/dist/worker.js.map +1 -0
- package/lib/workflows/package.json +5 -0
- package/lib/workflows/src/agents.ts +65 -0
- package/lib/workflows/src/children-coordinator.ts +50 -0
- package/lib/workflows/src/children-definition.ts +88 -0
- package/lib/workflows/src/children-discovery.ts +32 -0
- package/lib/workflows/src/children-runtime.ts +169 -0
- package/lib/workflows/src/children.ts +12 -0
- package/lib/workflows/src/composite-fleet.ts +155 -0
- package/lib/workflows/src/composite-host.ts +67 -0
- package/lib/workflows/src/composites.ts +6 -0
- package/lib/workflows/src/definition.ts +113 -0
- package/lib/workflows/src/drain.ts +56 -0
- package/lib/workflows/src/ephemeral.ts +124 -0
- package/lib/workflows/src/fleet-control.ts +326 -0
- package/lib/workflows/src/graph-coordinator.ts +223 -0
- package/lib/workflows/src/graph-definition.ts +70 -0
- package/lib/workflows/src/graph-discovery.ts +145 -0
- package/lib/workflows/src/graphs.ts +56 -0
- package/lib/workflows/src/hook-relay.ts +177 -0
- package/lib/workflows/src/index.ts +27 -0
- package/lib/workflows/src/leadership.ts +102 -0
- package/lib/workflows/src/lifecycle-definition.ts +194 -0
- package/lib/workflows/src/lifecycle-fleet.ts +346 -0
- package/lib/workflows/src/lifecycle-host.ts +109 -0
- package/lib/workflows/src/lifecycle-human-transport.ts +170 -0
- package/lib/workflows/src/lifecycle-runtime.ts +673 -0
- package/lib/workflows/src/lifecycle.ts +59 -0
- package/lib/workflows/src/loop-definition.ts +62 -0
- package/lib/workflows/src/loop-runtime.ts +260 -0
- package/lib/workflows/src/loops.ts +7 -0
- package/lib/workflows/src/migration-service.ts +83 -0
- package/lib/workflows/src/migration.ts +242 -0
- package/lib/workflows/src/operator-transports.ts +439 -0
- package/lib/workflows/src/reconciliation.ts +121 -0
- package/lib/workflows/src/runtime.ts +348 -0
- package/lib/workflows/src/saga-definition.ts +104 -0
- package/lib/workflows/src/saga-runtime.ts +406 -0
- package/lib/workflows/src/sagas.ts +24 -0
- package/lib/workflows/src/scheduled-helpers.ts +214 -0
- package/lib/workflows/src/scheduled.ts +707 -0
- package/lib/workflows/src/traces.ts +381 -0
- package/lib/workflows/src/versions.ts +114 -0
- package/lib/workflows/src/worker.ts +115 -0
- package/lib/workstream/dist/executions.d.ts +34 -0
- package/lib/workstream/dist/executions.d.ts.map +1 -0
- package/lib/workstream/dist/executions.js +344 -0
- package/lib/workstream/dist/executions.js.map +1 -0
- package/lib/workstream/dist/humans.d.ts +76 -0
- package/lib/workstream/dist/humans.d.ts.map +1 -0
- package/lib/workstream/dist/humans.js +273 -0
- package/lib/workstream/dist/humans.js.map +1 -0
- package/lib/workstream/dist/index.d.ts +61 -0
- package/lib/workstream/dist/index.d.ts.map +1 -0
- package/lib/workstream/dist/index.js +310 -0
- package/lib/workstream/dist/index.js.map +1 -0
- package/lib/workstream/dist/timers.d.ts +41 -0
- package/lib/workstream/dist/timers.d.ts.map +1 -0
- package/lib/workstream/dist/timers.js +240 -0
- package/lib/workstream/dist/timers.js.map +1 -0
- package/lib/workstream/dist/webhooks.d.ts +69 -0
- package/lib/workstream/dist/webhooks.d.ts.map +1 -0
- package/lib/workstream/dist/webhooks.js +313 -0
- package/lib/workstream/dist/webhooks.js.map +1 -0
- package/lib/workstream/package.json +5 -0
- package/lib/workstream/src/executions.ts +253 -0
- package/lib/workstream/src/humans.ts +323 -0
- package/lib/workstream/src/index.ts +279 -0
- package/lib/workstream/src/timers.ts +212 -0
- package/lib/workstream/src/webhooks.ts +180 -0
- package/package.json +281 -0
|
@@ -0,0 +1,707 @@
|
|
|
1
|
+
import { Budget, MayuraError, assertPositiveInteger, freezeJson, jsonValue, validate, type ExecutionReceipt, type ExecutionSettlement, type JsonObject, type JsonValue, type Schema, type InferInput, type Scope } from '@mayura/core';
|
|
2
|
+
import { invokeTool } from '@mayura/tools';
|
|
3
|
+
import { createWorkflowDrainGate, type WorkflowDrainOptions, type WorkflowDrainReport } from './drain.js';
|
|
4
|
+
import {
|
|
5
|
+
StorageError, executionRef, workflowPolicy, workflowResources, workflowOutputs,
|
|
6
|
+
workflowGraphOutputs, workflowGraphResources, workflowGraphTargets, assertWorkflowGraphStateMatchesManifest,
|
|
7
|
+
type Claim, type ScheduledWrite, type ScheduledWorkflowAggregateStore,
|
|
8
|
+
type ScheduledWorkflowStore, type WorkflowResourcePlan, type ExecutionRef, type StoredRecord,
|
|
9
|
+
type WorkflowGraphAggregateStore, type WorkflowGraphStore, type WorkflowFormat2State, type WorkflowGraphFormat3State,
|
|
10
|
+
type ScheduledMigrate, initialWorkflowState, initialWorkflowGraphState, type WorkflowManifest, type WorkflowGraphManifest,
|
|
11
|
+
} from '@mayura/storage-contracts';
|
|
12
|
+
import { assertMigrationAllowed, assertWorkflowMigration, migrationCommand, nodeEvidence, nodeFingerprint, planWorkflowMigration,
|
|
13
|
+
type MigrationBlocker, type MigrationCommand, type WorkflowMigration, type WorkflowMigrationResult } from './migration.js';
|
|
14
|
+
import { assertWorkflow, digest, resolveBinding, type AnyWorkflow, type WorkflowDefinition } from './definition.js';
|
|
15
|
+
import { assertWorkflowGraph, graphManifest, type AnyWorkflowGraph } from './graph-definition.js';
|
|
16
|
+
import type { WorkflowGraphRuntimeOptions } from './graphs.js';
|
|
17
|
+
import type { WorkflowRuntimeOptions, WorkflowSnapshot, VerifiedHuman } from './runtime.js';
|
|
18
|
+
import { isReviewExpired, isStorageCode, safeScheduledJson, scheduledCallback, scheduledClaim, scheduledClaims, scheduledEvents, scheduledManifest, scheduledSnapshot, scheduledState, scheduledStorage as persist, scheduledSubmission, scheduledTransition, scheduledView, type ScheduledTransition, type ScheduledStoredSnapshot, type ScheduledPublicSnapshot, type ScheduledProfile } from './scheduled-helpers.js';
|
|
19
|
+
|
|
20
|
+
export interface ScheduledWorkflowRuntimeOptions extends Omit<WorkflowRuntimeOptions, 'store'> {
|
|
21
|
+
readonly store: ScheduledWorkflowAggregateStore;
|
|
22
|
+
readonly workerId: string;
|
|
23
|
+
readonly leaseMs?: number;
|
|
24
|
+
/** Shared across this worker instance, including uncertain handlers that have not settled. */
|
|
25
|
+
readonly maxConcurrentJobs?: number;
|
|
26
|
+
readonly maxConcurrentRuns?: number;
|
|
27
|
+
/** Bounds each adapter wait, not its underlying transaction; timeout never grants replay. */
|
|
28
|
+
readonly storageTimeoutMs?: number;
|
|
29
|
+
/** Timed-out adapter callbacks retain these slots until their actual promises settle. */
|
|
30
|
+
readonly maxPendingStorageOperations?: number;
|
|
31
|
+
/** Explicit resource identities per tool node; immutable after the run is enrolled. */
|
|
32
|
+
readonly resources?: WorkflowResourcePlan;
|
|
33
|
+
/** Trusted provider boundary for resolving one persisted unknown external effect. */
|
|
34
|
+
readonly verifyExecution?: (request: ExternalEffectReconciliationRequest, credential: unknown) => PromiseLike<VerifiedExternalEffect>;
|
|
35
|
+
readonly reconciliationTimeoutMs?: number;
|
|
36
|
+
}
|
|
37
|
+
export interface ExternalEffectReconciliationRequest {
|
|
38
|
+
readonly runId: string;
|
|
39
|
+
readonly definitionHash: string;
|
|
40
|
+
readonly nodeId: string;
|
|
41
|
+
readonly jobId: string;
|
|
42
|
+
readonly fence: number;
|
|
43
|
+
readonly callId: string;
|
|
44
|
+
readonly toolId: string;
|
|
45
|
+
readonly toolVersion: string;
|
|
46
|
+
readonly maximumCostMicros: number;
|
|
47
|
+
readonly scope: Scope;
|
|
48
|
+
}
|
|
49
|
+
export interface VerifiedExternalEffect {
|
|
50
|
+
readonly authorityId: string;
|
|
51
|
+
readonly attestationId: string;
|
|
52
|
+
readonly execution: 'not_started' | 'succeeded' | 'failed';
|
|
53
|
+
readonly knownCostMicros: number;
|
|
54
|
+
}
|
|
55
|
+
export interface ReconcileExternalEffectCommand {
|
|
56
|
+
readonly id: string;
|
|
57
|
+
readonly nodeId: string;
|
|
58
|
+
readonly credential: unknown;
|
|
59
|
+
}
|
|
60
|
+
export interface ScheduledWorkflowRuntime {
|
|
61
|
+
readonly profile: 'scheduled-v1';
|
|
62
|
+
submit<I extends Schema, O extends Schema>(definition: WorkflowDefinition<I, O>, command: { readonly input: InferInput<I>; readonly idempotencyKey: string }): Promise<WorkflowSnapshot>;
|
|
63
|
+
attach(definition: AnyWorkflow, id: string): Promise<WorkflowSnapshot>;
|
|
64
|
+
inspect(id: string): Promise<WorkflowSnapshot>;
|
|
65
|
+
/** Scoped immutable identity data, not a capability or proof of backend identity. */
|
|
66
|
+
reference(id: string): Promise<ExecutionRef>;
|
|
67
|
+
events(id: string, after?: number): ReturnType<ScheduledWorkflowAggregateStore['events']>;
|
|
68
|
+
runUntilSettled(definition: AnyWorkflow, id: string): Promise<WorkflowSnapshot>;
|
|
69
|
+
reconcile(definition: AnyWorkflow, command: ReconcileExternalEffectCommand): Promise<WorkflowSnapshot>;
|
|
70
|
+
approve(command: { readonly id: string; readonly nodeId: string; readonly digest: string; readonly credential: unknown }): Promise<WorkflowSnapshot>;
|
|
71
|
+
cancel(id: string): Promise<WorkflowSnapshot>;
|
|
72
|
+
/** Persist a quiescent operator pause; claimed or in-flight effects must settle or be recovered first. */
|
|
73
|
+
pause(id: string): Promise<WorkflowSnapshot>;
|
|
74
|
+
resume(id: string): Promise<WorkflowSnapshot>;
|
|
75
|
+
/**
|
|
76
|
+
* Plan (dryRun) or apply a reviewed migration of a paused run to a new definition version. Storage re-verifies the
|
|
77
|
+
* migrated state inside its transaction; steps with scheduler history must be unchanged. The run stays paused.
|
|
78
|
+
*/
|
|
79
|
+
migrate(migration: WorkflowMigration<AnyWorkflow, AnyWorkflow>, command: MigrationCommand): Promise<WorkflowMigrationResult<WorkflowSnapshot>>;
|
|
80
|
+
recoverExpired(id: string): Promise<WorkflowSnapshot>;
|
|
81
|
+
/** Stops this worker, not the shared workflow. Keeps caller-owned storage available for late evidence. */
|
|
82
|
+
close(): Promise<void>;
|
|
83
|
+
/** Claim no new work, let admitted effects and receipts settle within the deadline, then close. */
|
|
84
|
+
drain(options?: WorkflowDrainOptions): Promise<WorkflowDrainReport>;
|
|
85
|
+
}
|
|
86
|
+
const terminal = new Set(['succeeded', 'failed', 'blocked', 'cancelled', 'outcome_unknown']);
|
|
87
|
+
/** A paused run is nonterminal but schedules nothing until an explicit resume. */
|
|
88
|
+
const halted = (status: string): boolean => terminal.has(status) || status === 'paused';
|
|
89
|
+
const methods = ['initialize', 'submit', 'attach', 'inspect', 'requestApproval', 'approve', 'prepare', 'claim', 'renew', 'start',
|
|
90
|
+
'recordReceipt', 'complete', 'abandon', 'failNode', 'advance', 'finalize', 'cancel', 'recover'] as const;
|
|
91
|
+
|
|
92
|
+
/** Explicit finite scheduled driver. All persistence authority stays in atomic storage commands. */
|
|
93
|
+
export function createScheduledWorkflowRuntime(options: ScheduledWorkflowRuntimeOptions): ScheduledWorkflowRuntime {
|
|
94
|
+
return createScheduledDriver(options, 'scheduled-v1') as ScheduledWorkflowRuntime;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
type DriverDefinition = AnyWorkflow | AnyWorkflowGraph;
|
|
98
|
+
type DriverStoreControls = {
|
|
99
|
+
[K in Exclude<keyof ScheduledWorkflowStore, 'submit' | 'attach' | 'pause' | 'resume' | 'migrate'>]:
|
|
100
|
+
(...args: Parameters<ScheduledWorkflowStore[K]>) => Promise<Awaited<ReturnType<ScheduledWorkflowStore[K]>> | Awaited<ReturnType<WorkflowGraphStore[K]>>>;
|
|
101
|
+
};
|
|
102
|
+
interface ScheduledDriverRuntime {
|
|
103
|
+
readonly profile: ScheduledProfile;
|
|
104
|
+
submit(definition: DriverDefinition, command: { readonly input: unknown; readonly idempotencyKey: string }): Promise<ScheduledPublicSnapshot>;
|
|
105
|
+
readonly attach?: (definition: AnyWorkflow, id: string) => Promise<ScheduledPublicSnapshot>;
|
|
106
|
+
inspect(id: string): Promise<ScheduledPublicSnapshot>;
|
|
107
|
+
reference(id: string): Promise<ExecutionRef>;
|
|
108
|
+
events(id: string, after?: number): ReturnType<ScheduledWorkflowAggregateStore['events']>;
|
|
109
|
+
runUntilSettled(definition: DriverDefinition, id: string): Promise<ScheduledPublicSnapshot>;
|
|
110
|
+
reconcile(definition: DriverDefinition, command: ReconcileExternalEffectCommand): Promise<ScheduledPublicSnapshot>;
|
|
111
|
+
approve(command: Parameters<ScheduledWorkflowRuntime['approve']>[0]): Promise<ScheduledPublicSnapshot>;
|
|
112
|
+
cancel(id: string): Promise<ScheduledPublicSnapshot>;
|
|
113
|
+
pause(id: string): Promise<ScheduledPublicSnapshot>;
|
|
114
|
+
resume(id: string): Promise<ScheduledPublicSnapshot>;
|
|
115
|
+
migrate(migration: WorkflowMigration<DriverDefinition, DriverDefinition>, command: MigrationCommand): Promise<WorkflowMigrationResult<ScheduledPublicSnapshot>>;
|
|
116
|
+
recoverExpired(id: string): Promise<ScheduledPublicSnapshot>;
|
|
117
|
+
close(): Promise<void>;
|
|
118
|
+
drain(options?: WorkflowDrainOptions): Promise<WorkflowDrainReport>;
|
|
119
|
+
}
|
|
120
|
+
/** Internal catalog input only; public runtimes retain their single resource-plan option. */
|
|
121
|
+
interface ScheduledGraphCatalogEntry { readonly definition: AnyWorkflowGraph; readonly resources: WorkflowResourcePlan }
|
|
122
|
+
|
|
123
|
+
/** Shared finite worker engine. Only exact profile compilers, decoders and capabilities vary. */
|
|
124
|
+
export function createScheduledDriver(options: ScheduledWorkflowRuntimeOptions | WorkflowGraphRuntimeOptions, profile: ScheduledProfile,
|
|
125
|
+
catalog?: readonly ScheduledGraphCatalogEntry[]): ScheduledDriverRuntime {
|
|
126
|
+
const { store } = options;
|
|
127
|
+
let api: DriverStoreControls;
|
|
128
|
+
let read: ScheduledWorkflowAggregateStore['read'];
|
|
129
|
+
let events: ScheduledWorkflowAggregateStore['events'];
|
|
130
|
+
// Optional controls: custom adapters without them keep working until pause or migration is requested.
|
|
131
|
+
let controls: {
|
|
132
|
+
readonly pause?: (command: ScheduledWrite) => Promise<ScheduledStoredSnapshot>;
|
|
133
|
+
readonly resume?: (command: ScheduledWrite) => Promise<ScheduledStoredSnapshot>;
|
|
134
|
+
readonly migrate?: (command: ScheduledMigrate) => Promise<ScheduledStoredSnapshot>;
|
|
135
|
+
} = {};
|
|
136
|
+
try {
|
|
137
|
+
const source = profile === 'scheduled-v1' ? store?.workflows : (store as WorkflowGraphAggregateStore)?.workflowGraphs;
|
|
138
|
+
const required = methods.filter(method => profile === 'scheduled-v1' || method !== 'attach');
|
|
139
|
+
if (!source || required.some(method => typeof (source as ScheduledWorkflowStore)[method] !== 'function')) throw new Error();
|
|
140
|
+
api = Object.freeze(Object.fromEntries(required.map(method => [method, (source as ScheduledWorkflowStore)[method].bind(source)]))) as unknown as DriverStoreControls;
|
|
141
|
+
read = store.read.bind(store); events = store.events.bind(store);
|
|
142
|
+
const optional = source as unknown as Record<'pause' | 'resume' | 'migrate', ((command: never) => Promise<ScheduledStoredSnapshot>) | undefined>;
|
|
143
|
+
controls = Object.freeze(Object.fromEntries((['pause', 'resume', 'migrate'] as const)
|
|
144
|
+
.filter(method => typeof optional[method] === 'function').map(method => [method, optional[method]!.bind(source)]))) as typeof controls;
|
|
145
|
+
} catch { throw new MayuraError('UNSUPPORTED_PROFILE', 'This adapter does not provide atomic scheduled workflow storage.'); }
|
|
146
|
+
let policy: ReturnType<typeof workflowPolicy>;
|
|
147
|
+
try {
|
|
148
|
+
policy = workflowPolicy({ scope: options.scope, permissions: options.permissions?.allow,
|
|
149
|
+
policyVersion: options.policyVersion, maxCostMicros: options.maxCostMicros,
|
|
150
|
+
maxOutputBytes: options.maxOutputBytes ?? 65_536, approvalTtlMs: options.approvalTtlMs ?? 3_600_000,
|
|
151
|
+
});
|
|
152
|
+
} catch { throw new MayuraError('INVALID_CONFIG', 'Scheduled execution requires explicit bounded scope, grants and policy; output cannot exceed 64 KiB.'); }
|
|
153
|
+
const scope = policy.scope;
|
|
154
|
+
const scopeKey = digest('mayura:scope:v1', scope);
|
|
155
|
+
const policyHash = digest('mayura:policy:v1', { ...policy, permissions: [...policy.permissions].sort() });
|
|
156
|
+
const stateFrom = (record: StoredRecord) => scheduledState(record, profile);
|
|
157
|
+
const snapshot = (record: StoredRecord) => scheduledSnapshot(record, profile);
|
|
158
|
+
const view = (raw: ScheduledStoredSnapshot, id: string): ScheduledStoredSnapshot => {
|
|
159
|
+
const checked = scheduledView(raw, scopeKey, id, policyHash, profile);
|
|
160
|
+
if (profile === 'scheduled-v2') {
|
|
161
|
+
try {
|
|
162
|
+
const state = stateFrom(checked.record);
|
|
163
|
+
if (state.maxCostMicros !== policy.maxCostMicros) throw new Error();
|
|
164
|
+
jsonValue(state.input, { maxBytes: policy.maxOutputBytes });
|
|
165
|
+
jsonValue(state.output, { maxBytes: policy.maxOutputBytes });
|
|
166
|
+
for (const step of Object.values(state.steps)) jsonValue(step.output, { maxBytes: policy.maxOutputBytes });
|
|
167
|
+
} catch { throw new MayuraError('STORAGE_UNAVAILABLE', 'Scheduled graph response exceeds its configured policy bounds.'); }
|
|
168
|
+
}
|
|
169
|
+
const activeDefinition = drivers.get(id)?.definition;
|
|
170
|
+
// While driving a registered graph, structural validity alone cannot authorize continuation.
|
|
171
|
+
if (profile === 'scheduled-v2' && activeDefinition) matches(activeDefinition, checked);
|
|
172
|
+
return checked;
|
|
173
|
+
};
|
|
174
|
+
const outputs = (state: WorkflowFormat2State | WorkflowGraphFormat3State) => state.format === 2 ? workflowOutputs(state) : workflowGraphOutputs(state);
|
|
175
|
+
const assertDefinition = (definition: DriverDefinition): void => {
|
|
176
|
+
if (profile === 'scheduled-v1') assertWorkflow(definition as AnyWorkflow);
|
|
177
|
+
else assertWorkflowGraph(definition as AnyWorkflowGraph);
|
|
178
|
+
};
|
|
179
|
+
const permissions = Object.freeze({ allow: policy.permissions });
|
|
180
|
+
const workerId = options.workerId;
|
|
181
|
+
if (typeof workerId !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/.test(workerId)) throw new MayuraError('INVALID_CONFIG', 'A bounded worker identity is required.');
|
|
182
|
+
const leaseMs = options.leaseMs ?? 3_000;
|
|
183
|
+
const maxConcurrentJobs = options.maxConcurrentJobs ?? 4;
|
|
184
|
+
const maxConcurrentRuns = options.maxConcurrentRuns ?? 16;
|
|
185
|
+
const storageTimeoutMs = options.storageTimeoutMs ?? 10_000;
|
|
186
|
+
const maxPendingStorageOperations = options.maxPendingStorageOperations ?? 64;
|
|
187
|
+
const reconciliationTimeoutMs = options.reconciliationTimeoutMs ?? 30_000;
|
|
188
|
+
for (const [name, value] of Object.entries({ leaseMs, maxConcurrentJobs, maxConcurrentRuns, storageTimeoutMs, maxPendingStorageOperations, reconciliationTimeoutMs })) assertPositiveInteger(value, name);
|
|
189
|
+
if (leaseMs < 1_000 || leaseMs > 300_000 || maxConcurrentJobs > 32 || maxConcurrentRuns > 128 || storageTimeoutMs > 30_000
|
|
190
|
+
|| maxPendingStorageOperations > 1_024 || reconciliationTimeoutMs > 30_000) throw new MayuraError('INVALID_CONFIG', 'Scheduled worker limits exceed supported bounds.');
|
|
191
|
+
const resourceInput = safeScheduledJson(options.resources ?? {}, 1_048_576, 'input') as WorkflowResourcePlan;
|
|
192
|
+
const verifyHuman = options.verifyHuman;
|
|
193
|
+
const verifyExecution = options.verifyExecution;
|
|
194
|
+
const shutdown = new AbortController();
|
|
195
|
+
let pendingStorage = 0;
|
|
196
|
+
// A cancelled/expired wait never cancels a committed database fact or authorizes a replay.
|
|
197
|
+
const scheduledStorage = <T>(operation: () => Promise<T>, evidence = false): Promise<T> => persist(async () => {
|
|
198
|
+
if (pendingStorage >= maxPendingStorageOperations) throw new StorageError('QUEUE_FULL', 'The worker persistence capacity is occupied.');
|
|
199
|
+
pendingStorage++;
|
|
200
|
+
try { return await operation(); } finally { pendingStorage--; }
|
|
201
|
+
}, storageTimeoutMs, evidence ? undefined : shutdown.signal);
|
|
202
|
+
const active = new Map<string, AbortController>();
|
|
203
|
+
const drivers = new Map<string, { readonly definition: DriverDefinition; readonly definitionHash: string; readonly operation: Promise<ScheduledPublicSnapshot> }>();
|
|
204
|
+
let slots = 0;
|
|
205
|
+
let closed = false;
|
|
206
|
+
let initialized: Promise<void> | undefined;
|
|
207
|
+
let closing: Promise<void> | undefined; const gate = createWorkflowDrainGate();
|
|
208
|
+
const open = (): void => { if (closed) throw new MayuraError('CANCELLED', 'Scheduled worker is closed.'); };
|
|
209
|
+
const initialize = (): Promise<void> => {
|
|
210
|
+
initialized ??= scheduledStorage(() => api.initialize()).catch((error: unknown) => { initialized = undefined; throw error; });
|
|
211
|
+
return initialized;
|
|
212
|
+
};
|
|
213
|
+
const access = (id: string) => {
|
|
214
|
+
if (typeof id !== 'string' || !/^[a-f0-9]{64}$/.test(id)) throw new MayuraError('INVALID_INPUT', 'An exact workflow run ID is required.');
|
|
215
|
+
return { scope: scopeKey, id, policyHash };
|
|
216
|
+
};
|
|
217
|
+
const load = async (id: string): Promise<ScheduledStoredSnapshot> => {
|
|
218
|
+
const key = access(id); await initialize();
|
|
219
|
+
return view(await scheduledStorage(() => api.inspect(key)), id);
|
|
220
|
+
};
|
|
221
|
+
const write = async <T extends ScheduledTransition>(id: string, operation: (command: ScheduledWrite, current: ScheduledStoredSnapshot) => Promise<T>, signal?: AbortSignal): Promise<T> => {
|
|
222
|
+
const commandId = crypto.randomUUID();
|
|
223
|
+
for (let attempt = 0; attempt < 32; attempt++) {
|
|
224
|
+
(signal ?? shutdown.signal).throwIfAborted();
|
|
225
|
+
const current = await load(id);
|
|
226
|
+
(signal ?? shutdown.signal).throwIfAborted();
|
|
227
|
+
try {
|
|
228
|
+
const result = await scheduledStorage(() => operation({ ...access(id), commandId, expectedVersion: current.record.version }, current));
|
|
229
|
+
const checked = scheduledTransition(result, scopeKey, id, policyHash, profile);
|
|
230
|
+
// Mutation acknowledgements must meet the same registered graph checks as reads.
|
|
231
|
+
if (profile === 'scheduled-v2') view('snapshot' in checked ? checked.snapshot : checked, id);
|
|
232
|
+
return checked;
|
|
233
|
+
}
|
|
234
|
+
// An expired review is final for this call, not contention: retrying the same command cannot succeed.
|
|
235
|
+
catch (error) { if (!isStorageCode(error, 'CONFLICT') || isReviewExpired(error)) throw error; }
|
|
236
|
+
}
|
|
237
|
+
throw new MayuraError('CONFLICT', 'Scheduled contention exceeded the bounded retry limit.');
|
|
238
|
+
};
|
|
239
|
+
const compileEnrollment = (definition: DriverDefinition, resources: WorkflowResourcePlan = resourceInput) => {
|
|
240
|
+
if (profile === 'scheduled-v2') {
|
|
241
|
+
const manifest = graphManifest(definition as AnyWorkflowGraph);
|
|
242
|
+
if (digest('mayura:workflow:v2', manifest) !== definition.digest) throw new MayuraError('INVALID_CONFIG', 'Workflow graph metadata does not match its registered definition.');
|
|
243
|
+
return { manifest, policy, resources: workflowGraphResources(resources, manifest) };
|
|
244
|
+
}
|
|
245
|
+
const manifest = scheduledManifest(definition as AnyWorkflow);
|
|
246
|
+
if (digest('mayura:workflow:v1', manifest) !== definition.digest) throw new MayuraError('INVALID_CONFIG', 'Workflow metadata does not match its registered definition.');
|
|
247
|
+
return { manifest, policy, resources: workflowResources(resources, manifest) };
|
|
248
|
+
};
|
|
249
|
+
const enrollments = new WeakMap<DriverDefinition, { readonly registered: ReturnType<typeof compileEnrollment>; readonly resourceHash: string }>();
|
|
250
|
+
const enrollment = (definition: DriverDefinition) => {
|
|
251
|
+
// Factory branding is checked before consulting identity caches. Definitions,
|
|
252
|
+
// manifests, policy and the captured resource plan are immutable snapshots.
|
|
253
|
+
assertDefinition(definition);
|
|
254
|
+
let known = enrollments.get(definition);
|
|
255
|
+
if (!known) {
|
|
256
|
+
if (catalog !== undefined) throw new MayuraError('INVALID_CONFIG', 'This graph definition is not registered in the immutable worker catalog.');
|
|
257
|
+
const registered = Object.freeze(compileEnrollment(definition));
|
|
258
|
+
known = { registered, resourceHash: digest('mayura:workflow-resources:v1', registered.resources) };
|
|
259
|
+
enrollments.set(definition, known);
|
|
260
|
+
}
|
|
261
|
+
return known.registered;
|
|
262
|
+
};
|
|
263
|
+
if (catalog !== undefined) {
|
|
264
|
+
if (profile !== 'scheduled-v2') throw new MayuraError('INVALID_CONFIG', 'Catalog enrollment requires the graph worker profile.');
|
|
265
|
+
for (const entry of catalog) {
|
|
266
|
+
assertDefinition(entry.definition);
|
|
267
|
+
if (enrollments.has(entry.definition)) throw new MayuraError('INVALID_CONFIG', 'Duplicate worker catalog definition.');
|
|
268
|
+
const registered = Object.freeze(compileEnrollment(entry.definition, entry.resources));
|
|
269
|
+
enrollments.set(entry.definition, { registered, resourceHash: digest('mayura:workflow-resources:v1', registered.resources) });
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const matches = (definition: DriverDefinition, current: ScheduledStoredSnapshot): void => {
|
|
273
|
+
const registered = enrollment(definition);
|
|
274
|
+
if (current.manifestHash !== definition.digest || current.record.definitionHash !== definition.digest
|
|
275
|
+
|| current.resourceHash !== enrollments.get(definition)!.resourceHash) throw new MayuraError('CONFLICT', 'Scheduled definition or resource plan changed; explicit migration is required.');
|
|
276
|
+
if ('format' in registered.manifest) {
|
|
277
|
+
try {
|
|
278
|
+
const state = stateFrom(current.record); if (state.format !== 3) throw new Error();
|
|
279
|
+
assertWorkflowGraphStateMatchesManifest(state, registered.manifest);
|
|
280
|
+
} catch { throw new MayuraError('STORAGE_UNAVAILABLE', 'Scheduled graph state does not match its registered definition.'); }
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
const receiptId = (jobId: string, fence: number, receipt: ExecutionReceipt, settlement: ExecutionSettlement): string =>
|
|
284
|
+
digest('mayura:workflow-receipt:v2', { jobId, fence, receipt, settlement });
|
|
285
|
+
const pendingNode = (current: ScheduledStoredSnapshot, nodeId: string): boolean => {
|
|
286
|
+
const state = stateFrom(current.record);
|
|
287
|
+
return !halted(state.status) && !current.jobs.some(job => job.nodeId === nodeId)
|
|
288
|
+
&& ['pending', 'waiting', 'approved'].includes(state.steps[nodeId]?.status ?? '');
|
|
289
|
+
};
|
|
290
|
+
const updatePendingNode = (id: string, nodeId: string, operation: (command: ScheduledWrite) => Promise<ScheduledStoredSnapshot>): Promise<ScheduledStoredSnapshot> =>
|
|
291
|
+
write(id, (command, current) => pendingNode(current, nodeId) ? operation(command) : Promise.resolve(current));
|
|
292
|
+
|
|
293
|
+
async function executeClaim(definition: DriverDefinition, id: string, jobId: string, originalClaim: Claim): Promise<void> {
|
|
294
|
+
const controller = new AbortController();
|
|
295
|
+
active.set(jobId, controller);
|
|
296
|
+
const relay = (): void => { controller.abort(); };
|
|
297
|
+
shutdown.signal.addEventListener('abort', relay, { once: true });
|
|
298
|
+
if (shutdown.signal.aborted) relay();
|
|
299
|
+
let token = originalClaim;
|
|
300
|
+
let dispatchSignal = controller.signal;
|
|
301
|
+
let renewal: ReturnType<typeof setTimeout> | undefined;
|
|
302
|
+
let renewing: Promise<void> | undefined;
|
|
303
|
+
let finished = false; let acquired = false; let handlerSettled = false; let logicalSettled = false; let released = false;
|
|
304
|
+
let observedSettlement: ExecutionSettlement | undefined;
|
|
305
|
+
const releaseSlot = (): void => {
|
|
306
|
+
if (!released && logicalSettled && (!acquired || handlerSettled)) { released = true; slots--; }
|
|
307
|
+
};
|
|
308
|
+
const scheduleRenewal = (): void => {
|
|
309
|
+
if (finished || controller.signal.aborted) return;
|
|
310
|
+
renewal = setTimeout(() => {
|
|
311
|
+
renewing = scheduledStorage(() => api.renew({ ...access(id), claim: token, leaseMs }))
|
|
312
|
+
.then(next => { if (!controller.signal.aborted) { token = scheduledClaim(next, originalClaim); scheduleRenewal(); } })
|
|
313
|
+
.catch(() => { controller.abort(); });
|
|
314
|
+
}, Math.max(100, Math.floor(leaseMs / 3)));
|
|
315
|
+
};
|
|
316
|
+
const stopRenewal = async (): Promise<void> => {
|
|
317
|
+
// A renewal commits the same aggregate version that completion compares.
|
|
318
|
+
// Stop future heartbeats and drain its bounded adapter wait before final CAS;
|
|
319
|
+
// otherwise this worker can repeatedly invalidate its own completion read.
|
|
320
|
+
finished = true;
|
|
321
|
+
if (renewal) clearTimeout(renewal);
|
|
322
|
+
await renewing;
|
|
323
|
+
};
|
|
324
|
+
const ownsJob = (current: ScheduledStoredSnapshot, state: 'leased' | 'started'): boolean => {
|
|
325
|
+
const job = current.jobs.find(item => item.jobId === jobId);
|
|
326
|
+
return !terminal.has(stateFrom(current.record).status) && job?.state === state
|
|
327
|
+
&& job.fence === originalClaim.fence && job.workerId === originalClaim.workerId
|
|
328
|
+
&& !job.cancelRequested && !job.leaseRevoked;
|
|
329
|
+
};
|
|
330
|
+
const record = async (receipt: ExecutionReceipt, settlement: ExecutionSettlement): Promise<string> => {
|
|
331
|
+
const withheld = Object.freeze({ ...receipt, disclosure: 'withheld' as const });
|
|
332
|
+
const evidenceId = receiptId(jobId, originalClaim.fence, withheld, settlement);
|
|
333
|
+
// Actual completion evidence outlives worker shutdown; only its wait is deadline-bounded.
|
|
334
|
+
const result = await scheduledStorage(() => api.recordReceipt({ ...access(id), jobId, fence: originalClaim.fence, evidenceId, receipt: withheld, settlement }), true);
|
|
335
|
+
view(result, id);
|
|
336
|
+
return evidenceId;
|
|
337
|
+
};
|
|
338
|
+
try {
|
|
339
|
+
const initial = await load(id); matches(definition, initial);
|
|
340
|
+
const job = initial.jobs.find(item => item.jobId === jobId);
|
|
341
|
+
const node = definition.nodes.find(item => item.kind === 'tool' && item.id === job?.nodeId);
|
|
342
|
+
if (!job || !node || node.kind !== 'tool' || job.intent['toolId'] !== node.tool.id || job.intent['callId'] !== `${id}/step:${node.id}`) throw new MayuraError('CONFLICT', 'Scheduled claim does not match this registered tool node.');
|
|
343
|
+
scheduleRenewal();
|
|
344
|
+
const state = stateFrom(initial.record);
|
|
345
|
+
const raw = resolveBinding(node.input, state.input, outputs(state));
|
|
346
|
+
const result = await invokeTool(node.tool, raw, {
|
|
347
|
+
runId: id, callId: `${id}/step:${node.id}`, scope, permissions, signal: controller.signal,
|
|
348
|
+
budget: new Budget(node.tool.costMicros, 1), maxOutputBytes: policy.maxOutputBytes,
|
|
349
|
+
acquireExecution: async signal => {
|
|
350
|
+
signal.throwIfAborted(); acquired = true; dispatchSignal = signal;
|
|
351
|
+
return () => { handlerSettled = true; releaseSlot(); };
|
|
352
|
+
},
|
|
353
|
+
beforeDispatch: async input => {
|
|
354
|
+
const started = await write(id, command => api.start({ ...command, claim: token, input }), dispatchSignal);
|
|
355
|
+
if (started.status !== 'started') throw new MayuraError('CONFLICT', 'The claim does not grant a fresh dispatch.');
|
|
356
|
+
},
|
|
357
|
+
onExecutionReceipt: async (receipt, settlement) => { observedSettlement = settlement; await record(receipt, settlement); },
|
|
358
|
+
});
|
|
359
|
+
const current = await load(id);
|
|
360
|
+
const currentJob = current.jobs.find(item => item.jobId === jobId);
|
|
361
|
+
if (!currentJob || currentJob.fence !== originalClaim.fence) return;
|
|
362
|
+
if (currentJob.startedAtMs === null) {
|
|
363
|
+
// Worker shutdown hands never-started leases back to expiry/recovery, not a run cancellation.
|
|
364
|
+
if (!closed && currentJob.state === 'leased') {
|
|
365
|
+
await stopRenewal();
|
|
366
|
+
await write(id, (command, latest) => ownsJob(latest, 'leased')
|
|
367
|
+
? api.abandon({ ...command, claim: token, outcome: result.status === 'failed' ? 'failed' : 'blocked' })
|
|
368
|
+
: Promise.resolve(latest));
|
|
369
|
+
}
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
if (!result.receipt) return;
|
|
373
|
+
const settlement = observedSettlement ?? Object.freeze(result.receipt.execution === 'unknown'
|
|
374
|
+
? { knownCostMicros: 0, unknownCostMicros: node.tool.costMicros }
|
|
375
|
+
: result.receipt.execution === 'not_started' ? { knownCostMicros: 0, unknownCostMicros: 0 }
|
|
376
|
+
: { knownCostMicros: node.tool.costMicros, unknownCostMicros: 0 });
|
|
377
|
+
const evidenceId = await scheduledCallback(() => record(result.receipt!, settlement), storageTimeoutMs, shutdown.signal);
|
|
378
|
+
if (result.receipt.execution === 'unknown') return;
|
|
379
|
+
const outcome = result.status === 'succeeded' ? 'succeeded' : result.receipt.execution === 'failed' ? 'failed' : 'blocked';
|
|
380
|
+
await stopRenewal();
|
|
381
|
+
await write(id, (command, latest) => {
|
|
382
|
+
// Receipt persistence, cancellation or recovery may have committed lost
|
|
383
|
+
// authority. That is not a version conflict: retain the known evidence and
|
|
384
|
+
// withheld output without retrying a permanently ineligible completion.
|
|
385
|
+
if (!ownsJob(latest, 'started')) return Promise.resolve(latest);
|
|
386
|
+
return api.complete({ ...command, claim: token, evidenceId, outcome,
|
|
387
|
+
output: result.status === 'succeeded' ? safeScheduledJson(result.output, policy.maxOutputBytes, 'output') : null,
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
} catch (error) {
|
|
391
|
+
// Lost authority never causes a handler replay or a generic aggregate replacement.
|
|
392
|
+
if (!isStorageCode(error, 'STALE_CLAIM') && !isStorageCode(error, 'CONFLICT')) throw error;
|
|
393
|
+
} finally {
|
|
394
|
+
finished = true; if (renewal) clearTimeout(renewal);
|
|
395
|
+
shutdown.signal.removeEventListener('abort', relay); active.delete(jobId);
|
|
396
|
+
logicalSettled = true; releaseSlot();
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
async function drive(definition: DriverDefinition, id: string): Promise<ScheduledPublicSnapshot> {
|
|
401
|
+
for (let wave = 0; wave < definition.nodes.length * 2 + 8; wave++) {
|
|
402
|
+
open();
|
|
403
|
+
let current = await load(id); matches(definition, current);
|
|
404
|
+
if (halted(stateFrom(current.record).status)) return snapshot(current.record);
|
|
405
|
+
// Each wave holds one drain admission, covering its claims, effects and receipts.
|
|
406
|
+
const release = gate.enter(); if (!release) return snapshot(current.record);
|
|
407
|
+
try {
|
|
408
|
+
const before = current.record.version;
|
|
409
|
+
current = await write(id, command => api.recover(command));
|
|
410
|
+
current = await write(id, command => api.advance(command));
|
|
411
|
+
if (halted(stateFrom(current.record).status)) return snapshot(current.record);
|
|
412
|
+
let preparingState = stateFrom(current.record);
|
|
413
|
+
for (const node of definition.nodes) {
|
|
414
|
+
if (node.kind !== 'tool') continue;
|
|
415
|
+
// A validated terminal step or immutable prepared-job link can never become a new
|
|
416
|
+
// preparation candidate. Avoid re-reading the entire aggregate for each such node.
|
|
417
|
+
// Potential candidates still receive a fresh read and the same authoritative CAS.
|
|
418
|
+
const observedStep = preparingState.steps[node.id];
|
|
419
|
+
if (!observedStep || !['pending', 'waiting', 'approved'].includes(observedStep.status)
|
|
420
|
+
|| current.jobs.some(job => job.nodeId === node.id)) continue;
|
|
421
|
+
current = await load(id);
|
|
422
|
+
const state = stateFrom(current.record); preparingState = state; const step = state.steps[node.id];
|
|
423
|
+
if (halted(state.status)) return snapshot(current.record);
|
|
424
|
+
if (!step || !['pending', 'waiting', 'approved'].includes(step.status) || current.jobs.some(job => job.nodeId === node.id)
|
|
425
|
+
|| (node.dependsOn ?? []).some(dependency => state.steps[dependency]?.status !== 'succeeded')) continue;
|
|
426
|
+
const required = [`tool:${node.tool.id}`, ...node.tool.capabilities, ...(node.tool.effects === 'none' ? [] : [`effect:${node.tool.effects}`])];
|
|
427
|
+
if (required.some(grant => !permissions.allow.includes(grant))) {
|
|
428
|
+
current = await updatePendingNode(id, node.id, command => api.failNode({ ...command, nodeId: node.id, outcome: 'blocked' }));
|
|
429
|
+
preparingState = stateFrom(current.record); continue;
|
|
430
|
+
}
|
|
431
|
+
let input: JsonValue;
|
|
432
|
+
try {
|
|
433
|
+
const raw = resolveBinding(node.input, state.input, outputs(state));
|
|
434
|
+
input = safeScheduledJson(await scheduledCallback(() => validate(node.tool.input, raw, 'input', { maxBytes: policy.maxOutputBytes }), node.tool.timeoutMs, shutdown.signal), policy.maxOutputBytes, 'input');
|
|
435
|
+
} catch {
|
|
436
|
+
open(); current = await updatePendingNode(id, node.id, command => api.failNode({ ...command, nodeId: node.id, outcome: 'failed' }));
|
|
437
|
+
preparingState = stateFrom(current.record); continue;
|
|
438
|
+
}
|
|
439
|
+
if (node.approval) {
|
|
440
|
+
current = await updatePendingNode(id, node.id, command => api.requestApproval({ ...command, nodeId: node.id, input }));
|
|
441
|
+
preparingState = stateFrom(current.record);
|
|
442
|
+
if (preparingState.steps[node.id]?.status !== 'approved') continue;
|
|
443
|
+
}
|
|
444
|
+
try { current = await updatePendingNode(id, node.id, command => api.prepare({ ...command, nodeId: node.id, input })); }
|
|
445
|
+
catch (error) {
|
|
446
|
+
if (!node.approval || !isReviewExpired(error)) throw error;
|
|
447
|
+
// The approval lapsed before admission: ask for a fresh review instead of admitting on an expired one.
|
|
448
|
+
current = await updatePendingNode(id, node.id, command => api.requestApproval({ ...command, nodeId: node.id, input }));
|
|
449
|
+
}
|
|
450
|
+
preparingState = stateFrom(current.record);
|
|
451
|
+
}
|
|
452
|
+
const available = maxConcurrentJobs - slots;
|
|
453
|
+
let count = 0;
|
|
454
|
+
if (available > 0 && !closed) {
|
|
455
|
+
slots += available;
|
|
456
|
+
let claims: Awaited<ReturnType<ScheduledWorkflowStore['claim']>>;
|
|
457
|
+
try { claims = scheduledClaims(await scheduledStorage(() => api.claim({ ...access(id), workerId, limit: available, leaseMs })), scopeKey, id, workerId, available); }
|
|
458
|
+
catch (error) { slots -= available; throw error; }
|
|
459
|
+
slots -= available - claims.length; count = claims.length;
|
|
460
|
+
// A sibling storage failure does not detach already claimed local work from this driver.
|
|
461
|
+
const results = await Promise.allSettled(claims.map(item => executeClaim(definition, id, item.job.jobId, item.claim)));
|
|
462
|
+
const failure = results.find(result => result.status === 'rejected');
|
|
463
|
+
if (failure?.status === 'rejected') throw failure.reason;
|
|
464
|
+
}
|
|
465
|
+
current = await write(id, command => api.advance(command));
|
|
466
|
+
const state = stateFrom(current.record);
|
|
467
|
+
if (halted(state.status)) return snapshot(current.record);
|
|
468
|
+
if (Object.values(state.steps).every(step => step.status === 'succeeded')) {
|
|
469
|
+
let final: { validation: 'passed'; output: JsonValue } | { validation: 'failed' };
|
|
470
|
+
try {
|
|
471
|
+
const raw = resolveBinding(definition.result, state.input, outputs(state));
|
|
472
|
+
const output = await scheduledCallback(() => validate(definition.output, raw, 'output', { maxBytes: policy.maxOutputBytes }), 30_000, shutdown.signal);
|
|
473
|
+
final = { validation: 'passed', output: safeScheduledJson(output, policy.maxOutputBytes, 'output') };
|
|
474
|
+
} catch { open(); final = { validation: 'failed' }; }
|
|
475
|
+
try {
|
|
476
|
+
const committed = await scheduledStorage(() => api.finalize({ ...access(id), expectedVersion: current.record.version, commandId: crypto.randomUUID(), ...final }));
|
|
477
|
+
return snapshot(view(committed, id).record);
|
|
478
|
+
} catch (error) { if (!isStorageCode(error, 'CONFLICT')) throw error; }
|
|
479
|
+
}
|
|
480
|
+
if (count === 0 && current.record.version === before) return snapshot(current.record);
|
|
481
|
+
} finally { release(); }
|
|
482
|
+
}
|
|
483
|
+
return snapshot((await load(id)).record);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
return Object.freeze<ScheduledDriverRuntime>({
|
|
487
|
+
profile,
|
|
488
|
+
async submit(definition, command): Promise<ScheduledPublicSnapshot> {
|
|
489
|
+
open(); const registered = enrollment(definition);
|
|
490
|
+
const key = command.idempotencyKey;
|
|
491
|
+
if (typeof key !== 'string' || !key.length || key.length > 128) throw new MayuraError('INVALID_INPUT', 'A bounded stable submission key is required.');
|
|
492
|
+
const raw = safeScheduledJson(command.input, policy.maxOutputBytes, 'input');
|
|
493
|
+
const input = safeScheduledJson(await scheduledCallback(() => validate(definition.input, raw, 'input'), 30_000, shutdown.signal), policy.maxOutputBytes, 'input');
|
|
494
|
+
if ('format' in registered.manifest) {
|
|
495
|
+
try { workflowGraphTargets(registered.manifest, input); }
|
|
496
|
+
catch { throw new MayuraError('INVALID_INPUT', 'Workflow graph wait targets are invalid or exceed their finite bounds.'); }
|
|
497
|
+
}
|
|
498
|
+
open(); await initialize();
|
|
499
|
+
const submission = { ...registered, input, idempotencyKey: key };
|
|
500
|
+
const result = await scheduledStorage<{ readonly snapshot: ScheduledStoredSnapshot; readonly created: boolean }>(() => profile === 'scheduled-v1'
|
|
501
|
+
? (api as ScheduledWorkflowStore).submit(submission as Parameters<ScheduledWorkflowStore['submit']>[0])
|
|
502
|
+
: (api as WorkflowGraphStore).submit(submission as Parameters<WorkflowGraphStore['submit']>[0]));
|
|
503
|
+
const id = digest('mayura:run-id:v1', { scope: scopeKey, submissionKey: key });
|
|
504
|
+
const current = view(scheduledSubmission(result).snapshot, id); matches(definition, current);
|
|
505
|
+
if (profile === 'scheduled-v2' && (current.record.idempotencyKey !== key
|
|
506
|
+
|| digest('mayura:workflow-input:v1', stateFrom(current.record).input) !== digest('mayura:workflow-input:v1', input))) {
|
|
507
|
+
throw new MayuraError('STORAGE_UNAVAILABLE', 'Workflow graph submission acknowledgement changed admitted input or identity.');
|
|
508
|
+
}
|
|
509
|
+
return snapshot(current.record);
|
|
510
|
+
},
|
|
511
|
+
...(profile === 'scheduled-v1' ? { async attach(definition: AnyWorkflow, id: string) {
|
|
512
|
+
open(); const registered = enrollment(definition); await initialize();
|
|
513
|
+
// Explicit enrollment reads the ordinary pristine aggregate; it has no sidecar to inspect yet.
|
|
514
|
+
const record = await scheduledStorage(() => read(scopeKey, access(id).id));
|
|
515
|
+
if (!record) throw new MayuraError('NOT_FOUND', 'Workflow was not found in this scope.');
|
|
516
|
+
const result = await scheduledStorage(() => (api as ScheduledWorkflowStore).attach({ ...access(id), expectedVersion: record.version, commandId: crypto.randomUUID(), ...registered } as Parameters<ScheduledWorkflowStore['attach']>[0]));
|
|
517
|
+
const current = view(result, id); matches(definition, current);
|
|
518
|
+
return snapshot(current.record);
|
|
519
|
+
} } : {}),
|
|
520
|
+
async inspect(id) { open(); return snapshot((await load(id)).record); },
|
|
521
|
+
async reference(id) {
|
|
522
|
+
open(); const current = await load(id); open();
|
|
523
|
+
return executionRef({ kind: 'scheduled-workflow', runId: current.record.id,
|
|
524
|
+
definitionHash: current.record.definitionHash, policyHash: current.policyHash });
|
|
525
|
+
},
|
|
526
|
+
async events(id, after = 0) {
|
|
527
|
+
open(); access(id);
|
|
528
|
+
if (!Number.isSafeInteger(after) || after < 0) throw new MayuraError('INVALID_INPUT', 'A non-negative event cursor is required.');
|
|
529
|
+
await load(id);
|
|
530
|
+
return scheduledEvents(await scheduledStorage(() => events(scopeKey, id, after)), after);
|
|
531
|
+
},
|
|
532
|
+
runUntilSettled(definition, id) {
|
|
533
|
+
open(); if (gate.draining) return Promise.reject(new MayuraError('CANCELLED', 'Scheduled worker is draining.'));
|
|
534
|
+
assertDefinition(definition); access(id); enrollment(definition);
|
|
535
|
+
const existing = drivers.get(id);
|
|
536
|
+
if (existing) return existing.definitionHash === definition.digest ? existing.operation
|
|
537
|
+
: Promise.reject(new MayuraError('CONFLICT', 'The active driver uses a different workflow definition.'));
|
|
538
|
+
if (drivers.size >= maxConcurrentRuns) return Promise.reject(new MayuraError('LIMIT_EXCEEDED', 'This worker has reached its active-run limit.'));
|
|
539
|
+
const operation = drive(definition, id).finally(() => { drivers.delete(id); });
|
|
540
|
+
drivers.set(id, { definition, definitionHash: definition.digest, operation }); return operation;
|
|
541
|
+
},
|
|
542
|
+
async reconcile(definition, command) {
|
|
543
|
+
open(); assertDefinition(definition); enrollment(definition);
|
|
544
|
+
const { id, nodeId, credential } = command; access(id);
|
|
545
|
+
if (typeof nodeId !== 'string' || !/^[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(nodeId)
|
|
546
|
+
|| ['constructor', 'prototype', '__proto__'].includes(nodeId)) throw new MayuraError('INVALID_INPUT', 'Reconciliation requires an exact tool node.');
|
|
547
|
+
if (!verifyExecution) throw new MayuraError('PERMISSION_DENIED', 'A trusted external-effect verifier is required.');
|
|
548
|
+
const current = await load(id); matches(definition, current);
|
|
549
|
+
const state = stateFrom(current.record);
|
|
550
|
+
const node = definition.nodes.find(item => item.kind === 'tool' && item.id === nodeId);
|
|
551
|
+
const job = current.jobs.find(item => item.nodeId === nodeId);
|
|
552
|
+
if (!node || node.kind !== 'tool' || !job || job.state !== 'outcome_unknown' || job.startedAtMs === null || job.fence < 1
|
|
553
|
+
|| job.intent['toolId'] !== node.tool.id || job.intent['callId'] !== `${id}/step:${node.id}`
|
|
554
|
+
|| !state.steps[nodeId] || state.steps[nodeId]!.kind !== 'tool') {
|
|
555
|
+
throw new MayuraError('CONFLICT', 'Only the exact persisted unknown tool attempt may be reconciled.');
|
|
556
|
+
}
|
|
557
|
+
const request = safeScheduledJson({
|
|
558
|
+
runId: id, definitionHash: definition.digest, nodeId, jobId: job.jobId, fence: job.fence,
|
|
559
|
+
callId: `${id}/step:${node.id}`, toolId: node.tool.id, toolVersion: node.tool.version,
|
|
560
|
+
maximumCostMicros: node.tool.costMicros, scope,
|
|
561
|
+
}, 8_192, 'input') as unknown as ExternalEffectReconciliationRequest;
|
|
562
|
+
let verified: VerifiedExternalEffect;
|
|
563
|
+
try {
|
|
564
|
+
const raw = await scheduledCallback(() => verifyExecution(request, credential), reconciliationTimeoutMs, shutdown.signal);
|
|
565
|
+
const value = safeScheduledJson(raw, 4_096, 'output');
|
|
566
|
+
if (value === null || Array.isArray(value) || typeof value !== 'object'
|
|
567
|
+
|| Object.keys(value).length !== 4 || !['authorityId', 'attestationId', 'execution', 'knownCostMicros'].every(key => Object.hasOwn(value, key))
|
|
568
|
+
|| typeof value['authorityId'] !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._:/-]{0,255}$/.test(value['authorityId'])
|
|
569
|
+
|| typeof value['attestationId'] !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._:/-]{0,255}$/.test(value['attestationId'])
|
|
570
|
+
|| !['not_started', 'succeeded', 'failed'].includes(value['execution'] as string)
|
|
571
|
+
|| typeof value['knownCostMicros'] !== 'number' || !Number.isSafeInteger(value['knownCostMicros'])
|
|
572
|
+
|| value['knownCostMicros'] < 0 || value['knownCostMicros'] > node.tool.costMicros
|
|
573
|
+
|| (value['execution'] === 'not_started' && value['knownCostMicros'] !== 0)) throw new Error();
|
|
574
|
+
verified = value as unknown as VerifiedExternalEffect;
|
|
575
|
+
} catch {
|
|
576
|
+
if (shutdown.signal.aborted) throw new MayuraError('CANCELLED', 'Scheduled worker is closed.');
|
|
577
|
+
throw new MayuraError('PERMISSION_DENIED', 'External effect verification did not authorize reconciliation.');
|
|
578
|
+
}
|
|
579
|
+
open();
|
|
580
|
+
const latest = await load(id); matches(definition, latest);
|
|
581
|
+
const latestJob = latest.jobs.find(item => item.jobId === job.jobId);
|
|
582
|
+
if (!latestJob || latestJob.nodeId !== nodeId || latestJob.fence !== job.fence || latestJob.state !== 'outcome_unknown'
|
|
583
|
+
|| latestJob.startedAtMs === null) throw new MayuraError('CONFLICT', 'The unknown tool attempt changed during reconciliation.');
|
|
584
|
+
const receipt = Object.freeze({ callId: request.callId, toolId: request.toolId,
|
|
585
|
+
execution: verified.execution, disclosure: 'withheld' as const });
|
|
586
|
+
const settlement = Object.freeze({ knownCostMicros: verified.knownCostMicros, unknownCostMicros: 0 });
|
|
587
|
+
const source = Object.freeze({ kind: 'external_reconciliation' as const, authorityId: verified.authorityId,
|
|
588
|
+
attestationHash: digest('mayura:external-attestation:v1', { authorityId: verified.authorityId, attestationId: verified.attestationId }) });
|
|
589
|
+
const evidenceId = digest('mayura:workflow-reconciliation:v1', {
|
|
590
|
+
jobId: job.jobId, fence: job.fence, source, receipt, settlement,
|
|
591
|
+
});
|
|
592
|
+
const result = await scheduledStorage(() => api.recordReceipt({ ...access(id), jobId: job.jobId,
|
|
593
|
+
fence: job.fence, evidenceId, receipt, settlement, source }), true);
|
|
594
|
+
const reconciled = view(result, id); matches(definition, reconciled);
|
|
595
|
+
return snapshot(reconciled.record);
|
|
596
|
+
},
|
|
597
|
+
async approve(command) {
|
|
598
|
+
open(); const { id, nodeId, digest: approvalDigest, credential } = command; access(id);
|
|
599
|
+
if (typeof nodeId !== 'string' || !/^[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(nodeId) || ['constructor', 'prototype', '__proto__'].includes(nodeId)
|
|
600
|
+
|| typeof approvalDigest !== 'string' || !/^[a-f0-9]{64}$/.test(approvalDigest)) throw new MayuraError('INVALID_INPUT', 'Approval requires an exact node and review digest.');
|
|
601
|
+
if (!verifyHuman) throw new MayuraError('PERMISSION_DENIED', 'A trusted human verifier is required.');
|
|
602
|
+
let human: VerifiedHuman;
|
|
603
|
+
try {
|
|
604
|
+
const value = await scheduledCallback(() => verifyHuman(credential), 30_000, shutdown.signal);
|
|
605
|
+
human = { id: value.id, projectId: value.projectId, canApprove: value.canApprove };
|
|
606
|
+
if (typeof human.id !== 'string' || !human.id.length || human.id.length > 256 || human.projectId !== scope.projectId || human.canApprove !== true) throw new Error();
|
|
607
|
+
} catch { throw new MayuraError('PERMISSION_DENIED', 'Human verification did not authorize this approval.'); }
|
|
608
|
+
open();
|
|
609
|
+
return snapshot((await write(id, base => api.approve({ ...base, nodeId, digest: approvalDigest, humanId: human.id }), shutdown.signal)).record);
|
|
610
|
+
},
|
|
611
|
+
async cancel(id) {
|
|
612
|
+
open(); const result = await write(id, command => api.cancel(command));
|
|
613
|
+
for (const job of result.jobs) active.get(job.jobId)?.abort();
|
|
614
|
+
return snapshot(result.record);
|
|
615
|
+
},
|
|
616
|
+
async pause(id: string) {
|
|
617
|
+
open(); const pause = controls.pause;
|
|
618
|
+
if (typeof pause !== 'function') throw new MayuraError('UNSUPPORTED_PROFILE', 'This adapter does not provide durable workflow pause.');
|
|
619
|
+
// Inadmissible states return the observed snapshot unchanged; throwing inside a storage write would hide the conflict.
|
|
620
|
+
const result = await write(id, (command, current) => {
|
|
621
|
+
const status = stateFrom(current.record).status;
|
|
622
|
+
const quiescent = !current.jobs.some(job => job.state === 'leased' || job.state === 'started');
|
|
623
|
+
return status !== 'paused' && !terminal.has(status) && quiescent ? pause(command) : Promise.resolve(current);
|
|
624
|
+
});
|
|
625
|
+
const status = stateFrom(result.record).status;
|
|
626
|
+
if (terminal.has(status)) throw new MayuraError('CONFLICT', 'A terminal workflow cannot be paused.');
|
|
627
|
+
if (status !== 'paused') throw new MayuraError('CONFLICT', 'A workflow with a claimed or in-flight effect cannot enter the quiescent paused state.');
|
|
628
|
+
return snapshot(result.record);
|
|
629
|
+
},
|
|
630
|
+
async resume(id: string) {
|
|
631
|
+
open(); const resume = controls.resume;
|
|
632
|
+
if (typeof resume !== 'function') throw new MayuraError('UNSUPPORTED_PROFILE', 'This adapter does not provide durable workflow pause.');
|
|
633
|
+
let applied = false;
|
|
634
|
+
const result = await write(id, (command, current) => {
|
|
635
|
+
applied = stateFrom(current.record).status === 'paused';
|
|
636
|
+
return applied ? resume(command) : Promise.resolve(current);
|
|
637
|
+
});
|
|
638
|
+
if (!applied) throw new MayuraError('CONFLICT', 'Only a paused workflow can be resumed.');
|
|
639
|
+
return snapshot(result.record);
|
|
640
|
+
},
|
|
641
|
+
async migrate(migration, command) {
|
|
642
|
+
open(); assertWorkflowMigration(migration); assertDefinition(migration.from); assertDefinition(migration.to);
|
|
643
|
+
const { id, actorId, commandId, dryRun = false } = migrationCommand(command);
|
|
644
|
+
const from = enrollment(migration.from); const to = enrollment(migration.to);
|
|
645
|
+
const current = await load(id); matches(migration.from, current);
|
|
646
|
+
const state = stateFrom(current.record);
|
|
647
|
+
// Resources are part of what a node does: a changed resource identity is a changed node.
|
|
648
|
+
const nodes = (registered: typeof from) => (registered.manifest as WorkflowManifest | WorkflowGraphManifest).graph.map(node => ({ id: node.id, kind: node.kind,
|
|
649
|
+
dependsOn: node.dependsOn, fingerprint: nodeFingerprint({ ...node, resources: registered.resources[node.id] ?? null } as unknown as Record<string, unknown>),
|
|
650
|
+
...(nodeEvidence(node) ? { evidence: nodeEvidence(node)! } : {}) }));
|
|
651
|
+
const fromNodes = nodes(from); const toNodes = nodes(to);
|
|
652
|
+
const preconditions: MigrationBlocker[] = [];
|
|
653
|
+
if (state.status !== 'paused') preconditions.push({ node: '*', reason: `The run is ${state.status}; pause it before migrating.` });
|
|
654
|
+
if (drivers.has(id)) preconditions.push({ node: '*', reason: 'This worker is still driving the run; wait for its driver to stop.' });
|
|
655
|
+
if (current.jobs.some(job => job.state === 'leased' || job.state === 'started')) preconditions.push({ node: '*', reason: 'A job is leased or started; let it settle or recover it first.' });
|
|
656
|
+
// Scheduler jobs are durable history keyed by node: such a node must survive unchanged under its own id.
|
|
657
|
+
for (const nodeId of new Set(current.jobs.map(job => job.nodeId))) {
|
|
658
|
+
const before = fromNodes.find(node => node.id === nodeId); const after = toNodes.find(node => node.id === nodeId);
|
|
659
|
+
if (!after || before?.fingerprint !== after.fingerprint || Object.values(migration.renames).includes(nodeId)) {
|
|
660
|
+
preconditions.push({ node: nodeId, reason: `Step "${nodeId}" has scheduler history; it must be kept unchanged.` });
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
const plan = planWorkflowMigration({ migration, format: profile === 'scheduled-v1' ? 'scheduled-v1' : 'graph-v3', runId: id,
|
|
664
|
+
fromDigest: migration.from.digest, toDigest: migration.to.digest, from: fromNodes, to: toNodes,
|
|
665
|
+
steps: Object.entries(state.steps).map(([step, value]) => ({ id: step, status: value.status })), preconditions });
|
|
666
|
+
if (dryRun) return freezeJson(jsonValue({ plan })) as unknown as WorkflowMigrationResult<ScheduledPublicSnapshot>;
|
|
667
|
+
assertMigrationAllowed(plan);
|
|
668
|
+
const store = controls.migrate;
|
|
669
|
+
if (typeof store !== 'function') throw new MayuraError('UNSUPPORTED_PROFILE', 'This adapter cannot migrate in-flight workflow runs.');
|
|
670
|
+
const fresh = profile === 'scheduled-v1'
|
|
671
|
+
? initialWorkflowState(to.manifest as WorkflowManifest, state.input, migration.to.digest, state.policy, state.maxCostMicros)
|
|
672
|
+
: initialWorkflowGraphState(to.manifest as WorkflowGraphManifest, state.input, migration.to.digest, state.policy, state.maxCostMicros);
|
|
673
|
+
const carried: Record<string, unknown> = {};
|
|
674
|
+
for (const entry of plan.entries) if (entry.target) {
|
|
675
|
+
carried[entry.target] = entry.action === 'keep' || entry.action === 'accept' ? state.steps[entry.source!] : fresh.steps[entry.target];
|
|
676
|
+
}
|
|
677
|
+
const steps = Object.fromEntries((to.manifest as WorkflowManifest | WorkflowGraphManifest).graph.map(node => [node.id, carried[node.id]]));
|
|
678
|
+
const next = { ...state, definition: migration.to.digest, steps,
|
|
679
|
+
reservedMicros: Object.values(steps).reduce<number>((sum, step) => sum + (step as { costReserved: number }).costReserved, 0) };
|
|
680
|
+
// One attempt at the planned version: a concurrent change needs a fresh review, and a storage refusal keeps its reason.
|
|
681
|
+
let result: ScheduledStoredSnapshot;
|
|
682
|
+
try {
|
|
683
|
+
const raw = await scheduledStorage(() => store({ ...access(id), expectedVersion: current.record.version, commandId, manifest: to.manifest,
|
|
684
|
+
resources: to.resources, state: jsonValue(next) as JsonObject, migrationId: migration.id, actorId } as ScheduledMigrate));
|
|
685
|
+
const checked = scheduledTransition(raw, scopeKey, id, policyHash, profile);
|
|
686
|
+
result = ('snapshot' in checked ? checked.snapshot : checked) as ScheduledStoredSnapshot;
|
|
687
|
+
} catch (error) {
|
|
688
|
+
if (!isStorageCode(error, 'CONFLICT')) throw error;
|
|
689
|
+
const reason = error instanceof Error && error.message.startsWith('Migration refused:') ? error.message : 'The run changed after the migration was planned; plan it again.';
|
|
690
|
+
throw new MayuraError('CONFLICT', reason);
|
|
691
|
+
}
|
|
692
|
+
const migrated = view(result, id); matches(migration.to, migrated);
|
|
693
|
+
return freezeJson(jsonValue({ plan, snapshot: snapshot(migrated.record) })) as unknown as WorkflowMigrationResult<ScheduledPublicSnapshot>;
|
|
694
|
+
},
|
|
695
|
+
async recoverExpired(id) { open(); return snapshot((await write(id, command => api.recover(command))).record); },
|
|
696
|
+
close() {
|
|
697
|
+
if (!closing) { closed = true; shutdown.abort(); closing = Promise.allSettled([...drivers.values()].map(driver => driver.operation)).then(() => {}); }
|
|
698
|
+
return closing;
|
|
699
|
+
},
|
|
700
|
+
drain(options) {
|
|
701
|
+
return gate.drain(options, () => {
|
|
702
|
+
if (!closing) { closed = true; shutdown.abort(); closing = Promise.allSettled([...drivers.values()].map(driver => driver.operation)).then(() => {}); }
|
|
703
|
+
return closing;
|
|
704
|
+
});
|
|
705
|
+
},
|
|
706
|
+
});
|
|
707
|
+
}
|