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,673 @@
|
|
|
1
|
+
import { Budget, MayuraError, assertPositiveInteger, freezeJson, jsonValue, validate,
|
|
2
|
+
type ExecutionReceipt, type JsonObject, type JsonValue, type Permissions, type Scope } from '@mayura/core';
|
|
3
|
+
import { invokeTool } from '@mayura/tools';
|
|
4
|
+
import { createWorkflowDrainGate, type WorkflowDrainOptions, type WorkflowDrainReport } from './drain.js';
|
|
5
|
+
import { StorageError, assertWorkflowLifecycleStateMatchesManifest, initialWorkflowLifecycleState,
|
|
6
|
+
mergeWorkflowReceipt, workflowLifecycleOutputs, workflowLifecycleState,
|
|
7
|
+
type AggregateStore, type StoredRecord, type WorkflowLifecycleState as State,
|
|
8
|
+
type WorkflowLifecycleStatus, type WorkflowLifecycleStep } from '@mayura/storage-contracts';
|
|
9
|
+
import { charged, digest, resolveBinding, type Binding } from './definition.js';
|
|
10
|
+
import { assertWorkflowLifecycle, lifecycleManifest, type AnyWorkflowLifecycle,
|
|
11
|
+
type WorkflowLifecycleNode } from './lifecycle-definition.js';
|
|
12
|
+
import type { VerifiedHuman } from './runtime.js';
|
|
13
|
+
import { assertMigrationAllowed, assertWorkflowMigration, migrationCommand, migrationEvent, nodeEvidence, nodeFingerprint, planWorkflowMigration,
|
|
14
|
+
type MigrationBlocker, type MigrationCommand, type WorkflowMigration, type WorkflowMigrationResult } from './migration.js';
|
|
15
|
+
export type { WorkflowMigrationResult } from './migration.js';
|
|
16
|
+
|
|
17
|
+
export interface WorkflowLifecycleSnapshot {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly version: number;
|
|
20
|
+
readonly status: WorkflowLifecycleStatus;
|
|
21
|
+
readonly steps: Readonly<Record<string, Readonly<WorkflowLifecycleStep>>>;
|
|
22
|
+
readonly output: JsonValue;
|
|
23
|
+
readonly nextWakeAtMs: number | null;
|
|
24
|
+
readonly budget: { readonly spentMicros: number; readonly reservedMicros: number; readonly maxCostMicros: number };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface WorkflowLifecycleHumanRequest {
|
|
28
|
+
readonly runId: string;
|
|
29
|
+
readonly nodeId: string;
|
|
30
|
+
readonly status: 'waiting' | 'succeeded' | 'timed_out';
|
|
31
|
+
readonly kind: 'information' | 'correction' | 'plan_selection';
|
|
32
|
+
readonly schemaId: string;
|
|
33
|
+
readonly schemaDigest: string;
|
|
34
|
+
readonly prompt: string;
|
|
35
|
+
readonly digest: string;
|
|
36
|
+
readonly context: JsonValue | null;
|
|
37
|
+
readonly subjectDigest: string | null;
|
|
38
|
+
readonly deadlineAtMs: number | null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** What an operator approves: the exact tool call the approval digest binds, reconstructed and digest-verified. */
|
|
42
|
+
export interface WorkflowLifecycleApprovalRequest {
|
|
43
|
+
readonly runId: string;
|
|
44
|
+
readonly nodeId: string;
|
|
45
|
+
readonly status: 'waiting' | 'approved';
|
|
46
|
+
readonly toolId: string;
|
|
47
|
+
readonly toolVersion: string;
|
|
48
|
+
/** The validated tool input that runs once approved. */
|
|
49
|
+
readonly input: JsonValue;
|
|
50
|
+
readonly digest: string;
|
|
51
|
+
readonly expiresAtMs: number;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface WorkflowLifecycleRuntimeOptions {
|
|
55
|
+
readonly store: AggregateStore;
|
|
56
|
+
readonly scope: Scope;
|
|
57
|
+
readonly permissions: Permissions;
|
|
58
|
+
readonly policyVersion: string;
|
|
59
|
+
readonly maxCostMicros: number;
|
|
60
|
+
readonly approvalTtlMs?: number;
|
|
61
|
+
readonly maxOutputBytes?: number;
|
|
62
|
+
readonly callbackTimeoutMs?: number;
|
|
63
|
+
readonly maxPendingCallbacks?: number;
|
|
64
|
+
/** Trusted synchronized clock; never accepted from workflow input. */
|
|
65
|
+
readonly now?: () => number;
|
|
66
|
+
/** Trusted identity boundary. Credentials and verifier diagnostics are never persisted. */
|
|
67
|
+
readonly verifyHuman?: (credential: unknown) => Promise<VerifiedHuman>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Trusted host assertion. Never deserialize this shape directly from an unauthenticated request. */
|
|
71
|
+
export interface WorkflowLifecycleVerifiedActor { readonly id: string; readonly projectId: string }
|
|
72
|
+
|
|
73
|
+
export interface WorkflowLifecycleRuntime {
|
|
74
|
+
readonly profile: 'lifecycle-v1';
|
|
75
|
+
submit(definition: AnyWorkflowLifecycle, command: { readonly input: unknown; readonly idempotencyKey: string }): Promise<WorkflowLifecycleSnapshot>;
|
|
76
|
+
inspect(id: string): Promise<WorkflowLifecycleSnapshot>;
|
|
77
|
+
humanRequest(definition: AnyWorkflowLifecycle, id: string, nodeId: string): Promise<WorkflowLifecycleHumanRequest | undefined>;
|
|
78
|
+
/** The pending (or approved, not yet dispatched) approval of one tool node; undefined when none is outstanding. */
|
|
79
|
+
approvalRequest(definition: AnyWorkflowLifecycle, id: string, nodeId: string): Promise<WorkflowLifecycleApprovalRequest | undefined>;
|
|
80
|
+
events(id: string, after?: number): ReturnType<AggregateStore['events']>;
|
|
81
|
+
runUntilSettled(definition: AnyWorkflowLifecycle, id: string): Promise<WorkflowLifecycleSnapshot>;
|
|
82
|
+
approve(command: { readonly id: string; readonly nodeId: string; readonly digest: string; readonly credential: unknown }): Promise<WorkflowLifecycleSnapshot>;
|
|
83
|
+
respond(definition: AnyWorkflowLifecycle, command: { readonly id: string; readonly nodeId: string;
|
|
84
|
+
readonly requestDigest: string; readonly commandId: string; readonly credential: unknown; readonly value: unknown }): Promise<WorkflowLifecycleSnapshot>;
|
|
85
|
+
respondVerified(definition: AnyWorkflowLifecycle, command: { readonly id: string; readonly nodeId: string;
|
|
86
|
+
readonly requestDigest: string; readonly commandId: string; readonly actor: WorkflowLifecycleVerifiedActor; readonly value: unknown }): Promise<WorkflowLifecycleSnapshot>;
|
|
87
|
+
pause(id: string): Promise<WorkflowLifecycleSnapshot>;
|
|
88
|
+
resume(id: string): Promise<WorkflowLifecycleSnapshot>;
|
|
89
|
+
/**
|
|
90
|
+
* Plan (dryRun) or apply a reviewed migration of a paused run from `migration.from` to `migration.to`. The run stays
|
|
91
|
+
* paused afterwards; resume it once the result is reviewed. Waiting human requests are re-issued with new digests.
|
|
92
|
+
*/
|
|
93
|
+
migrate(migration: WorkflowMigration<AnyWorkflowLifecycle, AnyWorkflowLifecycle>, command: MigrationCommand): Promise<WorkflowMigrationResult<WorkflowLifecycleSnapshot>>;
|
|
94
|
+
cancel(id: string): Promise<WorkflowLifecycleSnapshot>;
|
|
95
|
+
recoverAbandoned(id: string): Promise<WorkflowLifecycleSnapshot>;
|
|
96
|
+
close(): void;
|
|
97
|
+
/** Admit no new wave, let admitted effects and receipts settle within the deadline, then close. */
|
|
98
|
+
drain(options?: WorkflowDrainOptions): Promise<WorkflowDrainReport>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const finalRunStatuses = new Set<WorkflowLifecycleStatus>(['succeeded', 'failed', 'blocked', 'cancelled', 'outcome_unknown']);
|
|
102
|
+
const terminalStepStatuses = new Set(['succeeded', 'failed', 'blocked', 'unknown', 'timed_out', 'skipped', 'bypassed']);
|
|
103
|
+
/** Statuses a dependent step may build on: success, or a condition that did not hold. */
|
|
104
|
+
const satisfiedStepStatuses = new Set(['succeeded', 'bypassed']);
|
|
105
|
+
const hashPattern = /^[a-f0-9]{64}$/;
|
|
106
|
+
const nodePattern = /^[A-Za-z][A-Za-z0-9._-]{0,127}$/;
|
|
107
|
+
|
|
108
|
+
async function bounded<T>(operation: () => Promise<T>, timeoutMs: number): Promise<T> {
|
|
109
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
110
|
+
try {
|
|
111
|
+
return await Promise.race([Promise.resolve().then(operation), new Promise<never>((_resolve, reject) => {
|
|
112
|
+
timer = setTimeout(() => reject(new MayuraError('TIMEOUT', 'Lifecycle validation or identity verification timed out.')), timeoutMs);
|
|
113
|
+
})]);
|
|
114
|
+
} finally { if (timer !== undefined) clearTimeout(timer); }
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async function storageCall<T>(operation: () => Promise<T>): Promise<T> {
|
|
118
|
+
try { return await operation(); }
|
|
119
|
+
catch (error) {
|
|
120
|
+
if (error instanceof StorageError && error.code === 'CONFLICT') throw new StorageError('CONFLICT', 'Workflow lifecycle storage version changed.');
|
|
121
|
+
throw new MayuraError('STORAGE_UNAVAILABLE', 'Workflow lifecycle storage is unavailable; reconcile uncertain actions before retrying.');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function stateFrom(record: StoredRecord): State {
|
|
126
|
+
try { return workflowLifecycleState(record); }
|
|
127
|
+
catch { throw new MayuraError('CONFLICT', 'Stored workflow lifecycle state failed integrity validation.'); }
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function outputs(state: State): Record<string, JsonValue> {
|
|
131
|
+
try { return workflowLifecycleOutputs(state); }
|
|
132
|
+
catch { throw new MayuraError('CONFLICT', 'Stored workflow lifecycle output failed integrity validation.'); }
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function receipt(previous: ExecutionReceipt | null, incoming: ExecutionReceipt): ExecutionReceipt {
|
|
136
|
+
try { return mergeWorkflowReceipt(previous, incoming); }
|
|
137
|
+
catch { throw new MayuraError('CONFLICT', 'Conflicting known execution evidence requires reconciliation.'); }
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function nextWake(state: State): number | null {
|
|
141
|
+
const deadlines = Object.values(state.steps).flatMap(step => step.kind === 'timer' && step.status === 'waiting' && step.fireAtMs !== null
|
|
142
|
+
? [step.fireAtMs] : step.kind === 'human' && step.status === 'waiting' && step.deadlineAtMs !== null
|
|
143
|
+
? [step.deadlineAtMs] : step.kind === 'tool' && step.status === 'waiting' && step.approval !== null ? [step.approval.expiresAt] : []);
|
|
144
|
+
return deadlines.length === 0 ? null : Math.min(...deadlines);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function publicSnapshot(record: StoredRecord): WorkflowLifecycleSnapshot {
|
|
148
|
+
const state = stateFrom(record);
|
|
149
|
+
return freezeJson(jsonValue({ id: record.id, version: record.version, status: state.status, steps: state.steps,
|
|
150
|
+
output: state.output, nextWakeAtMs: nextWake(state), budget: { spentMicros: state.spentMicros,
|
|
151
|
+
reservedMicros: state.reservedMicros, maxCostMicros: state.maxCostMicros } })) as unknown as WorkflowLifecycleSnapshot;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function exactTimestamp(value: JsonValue): number {
|
|
155
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0) throw new MayuraError('INVALID_INPUT', 'Lifecycle time binding must resolve to an absolute Unix epoch millisecond timestamp.');
|
|
156
|
+
return value;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function exactDigest(value: JsonValue): string {
|
|
160
|
+
if (typeof value !== 'string' || !hashPattern.test(value)) throw new MayuraError('INVALID_INPUT', 'Correction subject binding must resolve to a SHA-256 digest.');
|
|
161
|
+
return value;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** Conservative durable lifecycle driver. Waiting nodes never retain a callback, worker, or timer handle. */
|
|
165
|
+
export function createWorkflowLifecycleRuntime(options: WorkflowLifecycleRuntimeOptions): WorkflowLifecycleRuntime {
|
|
166
|
+
const store = options.store;
|
|
167
|
+
const scope = Object.freeze({ principalId: options.scope?.principalId, projectId: options.scope?.projectId });
|
|
168
|
+
if ([scope.principalId, scope.projectId, options.policyVersion].some(value => typeof value !== 'string' || value.length < 1 || value.length > 128)) {
|
|
169
|
+
throw new MayuraError('INVALID_CONFIG', 'Workflow lifecycle scope and policy version are required.');
|
|
170
|
+
}
|
|
171
|
+
if (!Array.isArray(options.permissions?.allow) || options.permissions.allow.length > 4_096
|
|
172
|
+
|| options.permissions.allow.some(grant => typeof grant !== 'string' || grant.length < 1 || grant.length > 256)) {
|
|
173
|
+
throw new MayuraError('INVALID_CONFIG', 'Workflow lifecycle permissions must be bounded explicit grants.');
|
|
174
|
+
}
|
|
175
|
+
if (!Number.isSafeInteger(options.maxCostMicros) || options.maxCostMicros < 0) throw new MayuraError('INVALID_CONFIG', 'A bounded lifecycle cost is required.');
|
|
176
|
+
const permissions = Object.freeze({ allow: Object.freeze([...options.permissions.allow]) });
|
|
177
|
+
const maxCostMicros = options.maxCostMicros;
|
|
178
|
+
const approvalTtlMs = options.approvalTtlMs ?? 3_600_000;
|
|
179
|
+
const maxOutputBytes = options.maxOutputBytes ?? 1_048_576;
|
|
180
|
+
const callbackTimeoutMs = options.callbackTimeoutMs ?? 30_000;
|
|
181
|
+
const maxPendingCallbacks = options.maxPendingCallbacks ?? 32;
|
|
182
|
+
assertPositiveInteger(approvalTtlMs, 'approvalTtlMs'); assertPositiveInteger(maxOutputBytes, 'maxOutputBytes');
|
|
183
|
+
assertPositiveInteger(callbackTimeoutMs, 'callbackTimeoutMs');
|
|
184
|
+
assertPositiveInteger(maxPendingCallbacks, 'maxPendingCallbacks');
|
|
185
|
+
if (maxPendingCallbacks > 128) throw new MayuraError('INVALID_CONFIG', 'maxPendingCallbacks must not exceed 128.');
|
|
186
|
+
let pendingCallbacks = 0;
|
|
187
|
+
const controlled = async <T>(operation: () => Promise<T>, timeoutMs = callbackTimeoutMs): Promise<T> => {
|
|
188
|
+
if (pendingCallbacks >= maxPendingCallbacks) throw new MayuraError('LIMIT_EXCEEDED', 'Lifecycle callback capacity is full.');
|
|
189
|
+
pendingCallbacks += 1;
|
|
190
|
+
let released = false;
|
|
191
|
+
const release = (): void => { if (!released) { released = true; pendingCallbacks -= 1; } };
|
|
192
|
+
const pending = Promise.resolve().then(operation);
|
|
193
|
+
void pending.then(release, release);
|
|
194
|
+
return bounded(() => pending, timeoutMs);
|
|
195
|
+
};
|
|
196
|
+
const now = (): number => {
|
|
197
|
+
let value: unknown;
|
|
198
|
+
try { value = (options.now ?? Date.now)(); }
|
|
199
|
+
catch { throw new MayuraError('STORAGE_UNAVAILABLE', 'The trusted lifecycle clock is unavailable.'); }
|
|
200
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0) throw new MayuraError('STORAGE_UNAVAILABLE', 'The trusted lifecycle clock returned an invalid timestamp.');
|
|
201
|
+
return value;
|
|
202
|
+
};
|
|
203
|
+
const scopeKey = digest('mayura:scope:v1', scope);
|
|
204
|
+
const policy = digest('mayura:workflow-lifecycle-policy:v1', { scope, permissions: [...permissions.allow].sort(),
|
|
205
|
+
policyVersion: options.policyVersion, maxCostMicros, maxOutputBytes, approvalTtlMs });
|
|
206
|
+
const active = new Map<string, AbortController>(); let closed = false; const gate = createWorkflowDrainGate();
|
|
207
|
+
const ensureOpen = (): void => { if (closed) throw new MayuraError('CANCELLED', 'Workflow lifecycle runtime is closed.'); };
|
|
208
|
+
const load = async (id: string, allowClosed = false): Promise<StoredRecord> => {
|
|
209
|
+
if (!allowClosed) ensureOpen();
|
|
210
|
+
if (typeof id !== 'string' || !hashPattern.test(id)) throw new MayuraError('INVALID_INPUT', 'A workflow lifecycle run ID is required.');
|
|
211
|
+
const record = await storageCall(() => store.read(scopeKey, id));
|
|
212
|
+
if (!record) throw new MayuraError('NOT_FOUND', 'Workflow lifecycle run was not found in this scope.');
|
|
213
|
+
if (record.scope !== scopeKey || record.id !== id) throw new MayuraError('CONFLICT', 'Stored lifecycle identity does not match its requested scope.');
|
|
214
|
+
stateFrom(record); return record;
|
|
215
|
+
};
|
|
216
|
+
const save = (record: StoredRecord, state: State, type: string, data: JsonObject = {}): Promise<StoredRecord> =>
|
|
217
|
+
storageCall(() => store.update({ scope: scopeKey, id: record.id, expectedVersion: record.version,
|
|
218
|
+
state: jsonValue(state) as JsonObject, events: [{ type, data }] }));
|
|
219
|
+
const mutate = async (id: string, transition: (state: State) => boolean, type: string,
|
|
220
|
+
data: JsonObject = {}, allowClosed = false): Promise<StoredRecord> => {
|
|
221
|
+
for (let attempt = 0; attempt < 32; attempt++) {
|
|
222
|
+
const record = await load(id, allowClosed); const state = stateFrom(record);
|
|
223
|
+
if (!transition(state)) return record;
|
|
224
|
+
try { return await save(record, state, type, data); }
|
|
225
|
+
catch (error) { if (!(error instanceof StorageError) || error.code !== 'CONFLICT') throw error; }
|
|
226
|
+
}
|
|
227
|
+
throw new MayuraError('CONFLICT', 'Workflow lifecycle contention exceeded the bounded retry limit.');
|
|
228
|
+
};
|
|
229
|
+
const checkedHuman = async (credential: unknown, approval: boolean): Promise<VerifiedHuman> => {
|
|
230
|
+
if (!options.verifyHuman) throw new MayuraError('PERMISSION_DENIED', 'A trusted human identity verifier is required.');
|
|
231
|
+
try {
|
|
232
|
+
const verified = await controlled(() => options.verifyHuman!(credential));
|
|
233
|
+
const human = { id: verified.id, projectId: verified.projectId, canApprove: verified.canApprove };
|
|
234
|
+
if (typeof human.id !== 'string' || human.id.length < 1 || human.id.length > 256
|
|
235
|
+
|| human.projectId !== scope.projectId || (approval && human.canApprove !== true)) throw new Error();
|
|
236
|
+
return Object.freeze(human);
|
|
237
|
+
} catch { throw new MayuraError('PERMISSION_DENIED', 'Human identity verification failed.'); }
|
|
238
|
+
};
|
|
239
|
+
const approvalCandidate = (node: Extract<WorkflowLifecycleNode, { kind: 'tool' }>, input: JsonValue,
|
|
240
|
+
runId: string, expiresAt: number | null): string => digest('mayura:approval:v1', { runId, nodeId: node.id,
|
|
241
|
+
tool: node.tool.id, toolVersion: node.tool.version, input, policy, expiresAt });
|
|
242
|
+
|
|
243
|
+
const schedulable = (state: State): boolean => state.status !== 'paused' && state.status !== 'cancelled';
|
|
244
|
+
|
|
245
|
+
const skip = (step: WorkflowLifecycleStep): boolean => {
|
|
246
|
+
if (terminalStepStatuses.has(step.status)) return false;
|
|
247
|
+
if (step.kind === 'tool') { step.status = 'skipped'; step.costReserved = 0; }
|
|
248
|
+
else if (step.kind === 'human') {
|
|
249
|
+
step.status = 'skipped'; step.output = null; step.requestDigest = null; step.responseDigest = null;
|
|
250
|
+
step.actorId = null; step.deadlineAtMs = null;
|
|
251
|
+
} else if (step.kind === 'timer') {
|
|
252
|
+
step.status = 'skipped'; step.output = null; step.fireAtMs = null; step.firedAtMs = null;
|
|
253
|
+
} else step.status = 'skipped';
|
|
254
|
+
return true;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
const bypass = (step: WorkflowLifecycleStep): boolean => {
|
|
258
|
+
if (step.status !== 'pending') return false;
|
|
259
|
+
step.status = 'bypassed'; return true;
|
|
260
|
+
};
|
|
261
|
+
/** Whether a `when` binding holds: it resolves to something other than `null` or `false`. */
|
|
262
|
+
const applies = (condition: Binding, state: State): boolean => {
|
|
263
|
+
let value: JsonValue;
|
|
264
|
+
try { value = resolveBinding(condition, state.input, outputs(state)); } catch (error) {
|
|
265
|
+
if (error instanceof MayuraError && error.code === 'INVALID_INPUT') return false; throw error;
|
|
266
|
+
}
|
|
267
|
+
return value !== null && value !== false;
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
async function executeNode(id: string, definition: AnyWorkflowLifecycle, node: WorkflowLifecycleNode, claimRetries = 0): Promise<void> {
|
|
271
|
+
const record = await load(id); const state = stateFrom(record); const step = state.steps[node.id];
|
|
272
|
+
if (!step || step.kind !== node.kind || state.policy !== policy || !schedulable(state)) return;
|
|
273
|
+
// A pause or cancellation may commit after this read; every scheduling transition rechecks the latest state.
|
|
274
|
+
const advance = (transition: (current: State) => boolean, type: string, data: JsonObject): Promise<StoredRecord> =>
|
|
275
|
+
mutate(id, current => schedulable(current) && transition(current), type, data);
|
|
276
|
+
const dependencies = (node.dependsOn ?? []).map(key => state.steps[key]!);
|
|
277
|
+
if (dependencies.some(item => terminalStepStatuses.has(item.status) && !satisfiedStepStatuses.has(item.status))) {
|
|
278
|
+
await advance(current => skip(current.steps[node.id]!), 'lifecycle.step.skipped', { nodeId: node.id }); return;
|
|
279
|
+
}
|
|
280
|
+
if (dependencies.some(item => !satisfiedStepStatuses.has(item.status))) return;
|
|
281
|
+
// A condition is decided once, before the step starts; a started step is never re-evaluated.
|
|
282
|
+
if (node.when !== undefined && step.status === 'pending' && !applies(node.when, state)) {
|
|
283
|
+
await advance(current => bypass(current.steps[node.id]!), 'lifecycle.step.bypassed', { nodeId: node.id }); return;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (node.kind === 'human') {
|
|
287
|
+
if (step.kind !== 'human' || !['pending', 'waiting'].includes(step.status)) return;
|
|
288
|
+
if (step.status === 'waiting') {
|
|
289
|
+
const observedAtMs = now();
|
|
290
|
+
if (step.deadlineAtMs === null || observedAtMs < step.deadlineAtMs) return;
|
|
291
|
+
await advance(current => {
|
|
292
|
+
const target = current.steps[node.id];
|
|
293
|
+
if (!target || target.kind !== 'human' || target.status !== 'waiting' || target.deadlineAtMs === null || observedAtMs < target.deadlineAtMs) return false;
|
|
294
|
+
target.status = 'timed_out'; current.status = 'running'; return true;
|
|
295
|
+
}, 'lifecycle.human.timed_out', { nodeId: node.id, observedAtMs });
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
let context: JsonValue | null = null; let subjectDigest: string | null = null; let deadlineAtMs: number | null = null;
|
|
299
|
+
try {
|
|
300
|
+
if (node.request.context) context = resolveBinding(node.request.context, state.input, outputs(state));
|
|
301
|
+
if (node.request.subjectDigest) subjectDigest = exactDigest(resolveBinding(node.request.subjectDigest, state.input, outputs(state)));
|
|
302
|
+
if (node.request.deadlineAtMs) deadlineAtMs = exactTimestamp(resolveBinding(node.request.deadlineAtMs, state.input, outputs(state)));
|
|
303
|
+
} catch {
|
|
304
|
+
await advance(current => skip(current.steps[node.id]!), 'lifecycle.human.invalid', { nodeId: node.id }); return;
|
|
305
|
+
}
|
|
306
|
+
const requestDigest = digest('mayura:human-request:v1', { format: 1, runId: id, nodeId: node.id,
|
|
307
|
+
definitionHash: definition.digest, kind: node.request.kind, schemaId: node.request.schemaId,
|
|
308
|
+
schemaDigest: node.request.schemaDigest, prompt: node.request.prompt, context, subjectDigest, deadlineAtMs });
|
|
309
|
+
const observedAtMs = now();
|
|
310
|
+
await advance(current => {
|
|
311
|
+
const target = current.steps[node.id]; if (!target || target.kind !== 'human' || target.status !== 'pending') return false;
|
|
312
|
+
target.requestDigest = requestDigest; target.deadlineAtMs = deadlineAtMs;
|
|
313
|
+
target.status = deadlineAtMs !== null && observedAtMs >= deadlineAtMs ? 'timed_out' : 'waiting';
|
|
314
|
+
current.status = target.status === 'waiting' ? 'waiting' : 'running'; return true;
|
|
315
|
+
}, deadlineAtMs !== null && observedAtMs >= deadlineAtMs ? 'lifecycle.human.timed_out' : 'lifecycle.human.requested',
|
|
316
|
+
{ nodeId: node.id, requestDigest });
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (node.kind === 'timer') {
|
|
321
|
+
if (step.kind !== 'timer' || !['pending', 'waiting'].includes(step.status)) return;
|
|
322
|
+
let fireAtMs: number;
|
|
323
|
+
try { fireAtMs = step.fireAtMs ?? exactTimestamp(resolveBinding(node.fireAtMs, state.input, outputs(state))); }
|
|
324
|
+
catch {
|
|
325
|
+
await advance(current => skip(current.steps[node.id]!), 'lifecycle.timer.invalid', { nodeId: node.id }); return;
|
|
326
|
+
}
|
|
327
|
+
const observedAtMs = now();
|
|
328
|
+
await advance(current => {
|
|
329
|
+
const target = current.steps[node.id]; if (!target || target.kind !== 'timer' || !['pending', 'waiting'].includes(target.status)) return false;
|
|
330
|
+
if (target.fireAtMs !== null && target.fireAtMs !== fireAtMs) throw new MayuraError('CONFLICT', 'Persisted timer deadline does not match its pinned binding.');
|
|
331
|
+
target.fireAtMs = fireAtMs;
|
|
332
|
+
if (observedAtMs >= fireAtMs) {
|
|
333
|
+
target.status = 'succeeded'; target.firedAtMs = observedAtMs; target.output = { fireAtMs, firedAtMs: observedAtMs }; current.status = 'running';
|
|
334
|
+
} else { target.status = 'waiting'; current.status = 'waiting'; }
|
|
335
|
+
return true;
|
|
336
|
+
}, observedAtMs >= fireAtMs ? 'lifecycle.timer.fired' : 'lifecycle.timer.scheduled', { nodeId: node.id, fireAtMs });
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if (node.kind === 'tool' && step.kind === 'tool' && step.status === 'waiting') {
|
|
341
|
+
if (!step.approval || step.approval.expiresAt > now()) return;
|
|
342
|
+
await advance(current => {
|
|
343
|
+
const target = current.steps[node.id];
|
|
344
|
+
if (!target || target.kind !== 'tool' || target.status !== 'waiting' || !target.approval || target.approval.expiresAt > now()) return false;
|
|
345
|
+
target.status = 'pending'; target.approval = null; current.status = 'running'; return true;
|
|
346
|
+
}, 'lifecycle.approval.expired', { nodeId: node.id }); return;
|
|
347
|
+
}
|
|
348
|
+
if (!['pending', 'approved'].includes(step.status)) return;
|
|
349
|
+
if (node.kind === 'join') {
|
|
350
|
+
step.output = dependencies.map(item => item.output); step.status = 'succeeded';
|
|
351
|
+
try { await save(record, state, 'lifecycle.step.completed', { nodeId: node.id }); }
|
|
352
|
+
catch (error) { if (!(error instanceof StorageError) || error.code !== 'CONFLICT') throw error; }
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
if (step.kind !== 'tool') return;
|
|
356
|
+
const required = [`tool:${node.tool.id}`, ...node.tool.capabilities,
|
|
357
|
+
...(node.tool.effects === 'none' ? [] : [`effect:${node.tool.effects}`])];
|
|
358
|
+
if (required.some(grant => !permissions.allow.includes(grant))) {
|
|
359
|
+
step.status = 'blocked';
|
|
360
|
+
try { await save(record, state, 'lifecycle.step.blocked', { nodeId: node.id, code: 'PERMISSION_DENIED' }); }
|
|
361
|
+
catch (error) { if (!(error instanceof StorageError) || error.code !== 'CONFLICT') throw error; }
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
let input: JsonValue;
|
|
365
|
+
try { input = jsonValue(await controlled(() => validate(node.tool.input,
|
|
366
|
+
resolveBinding(node.input, state.input, outputs(state)), 'input'), node.tool.timeoutMs), { maxBytes: maxOutputBytes }); }
|
|
367
|
+
catch {
|
|
368
|
+
step.status = 'failed';
|
|
369
|
+
try { await save(record, state, 'lifecycle.step.failed', { nodeId: node.id, code: 'INVALID_INPUT' }); }
|
|
370
|
+
catch (error) { if (!(error instanceof StorageError) || error.code !== 'CONFLICT') throw error; }
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
const observedAtMs = now(); const previousExpiry = step.approval?.expiresAt ?? 0;
|
|
374
|
+
const reviewExpiry = node.approval ? (previousExpiry > observedAtMs ? previousExpiry : observedAtMs + approvalTtlMs) : null;
|
|
375
|
+
const candidateHash = approvalCandidate(node, input, id, reviewExpiry);
|
|
376
|
+
if (node.approval && (step.status !== 'approved' || step.approval?.digest !== candidateHash || step.approval.expiresAt <= observedAtMs)) {
|
|
377
|
+
step.status = 'waiting'; step.approval = { digest: candidateHash, expiresAt: reviewExpiry!, humanId: null }; state.status = 'waiting';
|
|
378
|
+
try { await save(record, state, 'lifecycle.approval.requested', { nodeId: node.id, digest: candidateHash }); }
|
|
379
|
+
catch (error) { if (!(error instanceof StorageError) || error.code !== 'CONFLICT') throw error; }
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
const affordable = (current: State): boolean => node.tool.costMicros <= current.maxCostMicros - current.spentMicros - current.reservedMicros;
|
|
383
|
+
if (!affordable(state)) {
|
|
384
|
+
// Decided again on the latest state, so a concurrent write cannot drop the block while a sibling holds the budget;
|
|
385
|
+
// if the budget has been released meanwhile, the step stays pending for the next wave.
|
|
386
|
+
await advance(current => {
|
|
387
|
+
const target = current.steps[node.id];
|
|
388
|
+
if (!target || target.kind !== 'tool' || target.status !== step.status || affordable(current)) return false;
|
|
389
|
+
target.status = 'blocked'; return true;
|
|
390
|
+
}, 'lifecycle.step.blocked', { nodeId: node.id, code: 'BUDGET_EXCEEDED' });
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
step.status = 'dispatching'; step.candidateHash = candidateHash; step.costReserved = node.tool.costMicros;
|
|
394
|
+
state.reservedMicros += node.tool.costMicros; state.status = 'running';
|
|
395
|
+
try { await save(record, state, 'lifecycle.step.dispatching', { nodeId: node.id, callId: step.callId }); }
|
|
396
|
+
catch (error) {
|
|
397
|
+
if (error instanceof StorageError && error.code === 'CONFLICT' && claimRetries < 32) return executeNode(id, definition, node, claimRetries + 1);
|
|
398
|
+
throw error;
|
|
399
|
+
}
|
|
400
|
+
const controller = new AbortController(); const activeKey = `${id}/${node.id}`; active.set(activeKey, controller);
|
|
401
|
+
try {
|
|
402
|
+
const result = await invokeTool(node.tool, resolveBinding(node.input, state.input, outputs(state)), {
|
|
403
|
+
runId: id, callId: `${id}/${step.callId}`, scope, signal: controller.signal, permissions,
|
|
404
|
+
budget: new Budget(node.tool.costMicros, 1), maxOutputBytes,
|
|
405
|
+
beforeDispatch: async processed => {
|
|
406
|
+
const current = stateFrom(await load(id)); const target = current.steps[node.id];
|
|
407
|
+
if (!target || target.kind !== 'tool' || current.status !== 'running' || current.policy !== policy
|
|
408
|
+
|| target.status !== 'dispatching' || approvalCandidate(node, processed, id,
|
|
409
|
+
node.approval ? target.approval!.expiresAt : null) !== candidateHash) throw new MayuraError('CONFLICT', 'Lifecycle dispatch candidate is no longer authorized.');
|
|
410
|
+
if (node.approval && target.approval!.expiresAt <= now()) throw new MayuraError('PERMISSION_DENIED', 'Approval expired before dispatch.');
|
|
411
|
+
},
|
|
412
|
+
onExecutionReceipt: async (evidence, settlement) => {
|
|
413
|
+
await mutate(id, current => {
|
|
414
|
+
const target = current.steps[node.id]; if (!target || target.kind !== 'tool') return false;
|
|
415
|
+
target.receipt = receipt(target.receipt, evidence);
|
|
416
|
+
if (evidence.execution !== 'unknown' && target.costReserved > 0) {
|
|
417
|
+
current.reservedMicros -= target.costReserved;
|
|
418
|
+
// Charge what the tool reported (known plus unknown usage), never more than its reservation. A tool that
|
|
419
|
+
// reports nothing is charged its declared cost.
|
|
420
|
+
if (evidence.execution !== 'not_started') current.spentMicros += charged(settlement, target.costReserved);
|
|
421
|
+
target.costReserved = 0;
|
|
422
|
+
}
|
|
423
|
+
return true;
|
|
424
|
+
}, 'lifecycle.effect.receipt', { nodeId: node.id, execution: evidence.execution }, true);
|
|
425
|
+
},
|
|
426
|
+
});
|
|
427
|
+
await mutate(id, current => {
|
|
428
|
+
const target = current.steps[node.id]; if (!target || target.kind !== 'tool' || target.status !== 'dispatching') return false;
|
|
429
|
+
if (result.receipt) target.receipt = receipt(target.receipt, result.receipt);
|
|
430
|
+
if (result.status === 'succeeded') { target.status = 'succeeded'; target.output = jsonValue(result.output, { maxBytes: maxOutputBytes }); }
|
|
431
|
+
else target.status = result.status === 'outcome_unknown' ? 'unknown' : result.status === 'blocked' ? 'blocked' : 'failed';
|
|
432
|
+
if (result.receipt?.execution === 'not_started' && target.costReserved > 0) { current.reservedMicros -= target.costReserved; target.costReserved = 0; }
|
|
433
|
+
return true;
|
|
434
|
+
}, 'lifecycle.step.completed', { nodeId: node.id, outcome: result.status });
|
|
435
|
+
} finally { active.delete(activeKey); }
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/** The exact request a waiting human step shows, bound to the definition digest that issued it. */
|
|
439
|
+
const humanEvidence = (definition: AnyWorkflowLifecycle, node: Extract<WorkflowLifecycleNode, { kind: 'human' }>, id: string, state: State):
|
|
440
|
+
{ readonly requestDigest: string; readonly deadlineAtMs: number | null; readonly context: JsonValue | null; readonly subjectDigest: string | null } => {
|
|
441
|
+
let context: JsonValue | null = null; let subjectDigest: string | null = null; let deadlineAtMs: number | null = null;
|
|
442
|
+
try {
|
|
443
|
+
if (node.request.context) context = resolveBinding(node.request.context, state.input, outputs(state));
|
|
444
|
+
if (node.request.subjectDigest) subjectDigest = exactDigest(resolveBinding(node.request.subjectDigest, state.input, outputs(state)));
|
|
445
|
+
if (node.request.deadlineAtMs) deadlineAtMs = exactTimestamp(resolveBinding(node.request.deadlineAtMs, state.input, outputs(state)));
|
|
446
|
+
} catch { throw new MayuraError('CONFLICT', 'Persisted human request bindings no longer resolve.'); }
|
|
447
|
+
const requestDigest = digest('mayura:human-request:v1', { format: 1, runId: id, nodeId: node.id,
|
|
448
|
+
definitionHash: definition.digest, kind: node.request.kind, schemaId: node.request.schemaId,
|
|
449
|
+
schemaDigest: node.request.schemaDigest, prompt: node.request.prompt, context, subjectDigest, deadlineAtMs });
|
|
450
|
+
return { requestDigest, deadlineAtMs, context, subjectDigest };
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
const verifyDefinition = (definition: AnyWorkflowLifecycle, record: StoredRecord, state: State): void => {
|
|
454
|
+
assertWorkflowLifecycle(definition);
|
|
455
|
+
if (record.definitionHash !== definition.digest || state.definition !== definition.digest || state.policy !== policy
|
|
456
|
+
|| state.maxCostMicros !== maxCostMicros) throw new MayuraError('CONFLICT', 'Lifecycle definition or policy changed; explicit migration/review is required.');
|
|
457
|
+
try { assertWorkflowLifecycleStateMatchesManifest(state, lifecycleManifest(definition)); }
|
|
458
|
+
catch { throw new MayuraError('CONFLICT', 'Stored lifecycle steps do not match the pinned definition.'); }
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
const respondAs = async (definition: AnyWorkflowLifecycle, command: { readonly id: string; readonly nodeId: string;
|
|
462
|
+
readonly requestDigest: string; readonly commandId: string; readonly value: unknown }, actor: WorkflowLifecycleVerifiedActor): Promise<WorkflowLifecycleSnapshot> => {
|
|
463
|
+
ensureOpen(); assertWorkflowLifecycle(definition);
|
|
464
|
+
if (!hashPattern.test(command.id) || !nodePattern.test(command.nodeId) || !hashPattern.test(command.requestDigest)
|
|
465
|
+
|| typeof command.commandId !== 'string' || command.commandId.length < 1 || command.commandId.length > 128) {
|
|
466
|
+
throw new MayuraError('INVALID_INPUT', 'Human response requires exact run, node, request and command identifiers.');
|
|
467
|
+
}
|
|
468
|
+
if (!actor || typeof actor.id !== 'string' || actor.id.length < 1 || actor.id.length > 256 || actor.projectId !== scope.projectId) {
|
|
469
|
+
throw new MayuraError('PERMISSION_DENIED', 'Verified human actor does not belong to this lifecycle project.');
|
|
470
|
+
}
|
|
471
|
+
const node = definition.nodes.find(candidate => candidate.id === command.nodeId);
|
|
472
|
+
if (!node || node.kind !== 'human') throw new MayuraError('INVALID_INPUT', 'Human response node is not part of the lifecycle definition.');
|
|
473
|
+
const before = await load(command.id); verifyDefinition(definition, before, stateFrom(before));
|
|
474
|
+
const value = jsonValue(await controlled(() => validate(node.request.response, command.value, 'input')), { maxBytes: maxOutputBytes });
|
|
475
|
+
const responseDigest = digest('mayura:human-response:v1', { requestDigest: command.requestDigest,
|
|
476
|
+
commandId: command.commandId, actorId: actor.id, value });
|
|
477
|
+
const observedAtMs = now();
|
|
478
|
+
return publicSnapshot(await mutate(command.id, state => {
|
|
479
|
+
const step = state.steps[command.nodeId];
|
|
480
|
+
if (!step || step.kind !== 'human' || state.policy !== policy || step.requestDigest !== command.requestDigest) {
|
|
481
|
+
throw new MayuraError('CONFLICT', 'Human request is stale or mismatched.');
|
|
482
|
+
}
|
|
483
|
+
if (step.status === 'succeeded') {
|
|
484
|
+
if (step.responseDigest !== responseDigest) throw new MayuraError('CONFLICT', 'Human request already has a different response.');
|
|
485
|
+
return false;
|
|
486
|
+
}
|
|
487
|
+
if (step.status !== 'waiting' || (step.deadlineAtMs !== null && observedAtMs >= step.deadlineAtMs)) {
|
|
488
|
+
throw new MayuraError('CONFLICT', 'Human request is no longer accepting responses.');
|
|
489
|
+
}
|
|
490
|
+
step.status = 'succeeded'; step.responseDigest = responseDigest; step.actorId = actor.id; step.output = value;
|
|
491
|
+
if (state.status !== 'paused') state.status = 'running'; return true;
|
|
492
|
+
}, 'lifecycle.human.responded', { nodeId: command.nodeId, requestDigest: command.requestDigest,
|
|
493
|
+
responseDigest, actorId: actor.id }));
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
return Object.freeze<WorkflowLifecycleRuntime>({
|
|
497
|
+
profile: 'lifecycle-v1',
|
|
498
|
+
submit: async (definition, command) => {
|
|
499
|
+
ensureOpen(); assertWorkflowLifecycle(definition);
|
|
500
|
+
if (typeof command.idempotencyKey !== 'string' || command.idempotencyKey.length < 1 || command.idempotencyKey.length > 128) {
|
|
501
|
+
throw new MayuraError('INVALID_INPUT', 'A bounded lifecycle submission key is required.');
|
|
502
|
+
}
|
|
503
|
+
const inputSnapshot = freezeJson(jsonValue(command.input, { maxBytes: maxOutputBytes }));
|
|
504
|
+
const input = jsonValue(await controlled(() => validate(definition.input, inputSnapshot, 'input')), { maxBytes: maxOutputBytes });
|
|
505
|
+
const state = initialWorkflowLifecycleState(lifecycleManifest(definition), input, definition.digest, policy, maxCostMicros);
|
|
506
|
+
const id = digest('mayura:workflow-lifecycle-run-id:v1', { scope: scopeKey, submissionKey: command.idempotencyKey });
|
|
507
|
+
const created = await storageCall(() => store.create({ scope: scopeKey, id, idempotencyKey: `lifecycle:${command.idempotencyKey}`,
|
|
508
|
+
definitionHash: definition.digest, state: jsonValue(state) as JsonObject, events: [{ type: 'lifecycle.run.created', data: {} }] }));
|
|
509
|
+
verifyDefinition(definition, created.record, stateFrom(created.record)); return publicSnapshot(created.record);
|
|
510
|
+
},
|
|
511
|
+
inspect: async id => publicSnapshot(await load(id)),
|
|
512
|
+
humanRequest: async (definition, id, nodeId) => {
|
|
513
|
+
ensureOpen(); assertWorkflowLifecycle(definition);
|
|
514
|
+
if (!nodePattern.test(nodeId)) throw new MayuraError('INVALID_INPUT', 'A lifecycle human node ID is required.');
|
|
515
|
+
const record = await load(id); const state = stateFrom(record); verifyDefinition(definition, record, state);
|
|
516
|
+
const node = definition.nodes.find(candidate => candidate.id === nodeId);
|
|
517
|
+
const step = state.steps[nodeId];
|
|
518
|
+
if (!node || node.kind !== 'human' || !step || step.kind !== 'human') throw new MayuraError('NOT_FOUND', 'Lifecycle human request was not found.');
|
|
519
|
+
if (step.status === 'pending' || step.status === 'skipped' || step.status === 'bypassed') return undefined;
|
|
520
|
+
const { requestDigest, deadlineAtMs, context, subjectDigest } = humanEvidence(definition, node, id, state);
|
|
521
|
+
if (step.requestDigest !== requestDigest || step.deadlineAtMs !== deadlineAtMs) throw new MayuraError('CONFLICT', 'Persisted human request evidence does not match its definition.');
|
|
522
|
+
return freezeJson(jsonValue({ runId: id, nodeId, status: step.status, kind: node.request.kind,
|
|
523
|
+
schemaId: node.request.schemaId, schemaDigest: node.request.schemaDigest, prompt: node.request.prompt,
|
|
524
|
+
digest: requestDigest, context, subjectDigest, deadlineAtMs })) as unknown as WorkflowLifecycleHumanRequest;
|
|
525
|
+
},
|
|
526
|
+
approvalRequest: async (definition, id, nodeId) => {
|
|
527
|
+
ensureOpen(); assertWorkflowLifecycle(definition);
|
|
528
|
+
if (!nodePattern.test(nodeId)) throw new MayuraError('INVALID_INPUT', 'A lifecycle tool node ID is required.');
|
|
529
|
+
const record = await load(id); const state = stateFrom(record); verifyDefinition(definition, record, state);
|
|
530
|
+
const node = definition.nodes.find(candidate => candidate.id === nodeId);
|
|
531
|
+
const step = state.steps[nodeId];
|
|
532
|
+
if (!node || node.kind !== 'tool' || !step || step.kind !== 'tool') throw new MayuraError('NOT_FOUND', 'Lifecycle tool node was not found.');
|
|
533
|
+
if (!node.approval || !step.approval || (step.status !== 'waiting' && step.status !== 'approved')) return undefined;
|
|
534
|
+
// Rebuild the input exactly as preparation did; it must reproduce the persisted digest, or the evidence is refused.
|
|
535
|
+
const input = jsonValue(await controlled(() => validate(node.tool.input, resolveBinding(node.input, state.input, outputs(state)), 'input'),
|
|
536
|
+
node.tool.timeoutMs), { maxBytes: maxOutputBytes });
|
|
537
|
+
if (approvalCandidate(node, input, id, step.approval.expiresAt) !== step.approval.digest) {
|
|
538
|
+
throw new MayuraError('CONFLICT', 'Persisted approval evidence does not match its definition.');
|
|
539
|
+
}
|
|
540
|
+
return freezeJson(jsonValue({ runId: id, nodeId, status: step.status, toolId: node.tool.id, toolVersion: node.tool.version, input,
|
|
541
|
+
digest: step.approval.digest, expiresAtMs: step.approval.expiresAt })) as unknown as WorkflowLifecycleApprovalRequest;
|
|
542
|
+
},
|
|
543
|
+
events: (id, after = 0) => { ensureOpen(); return storageCall(() => store.events(scopeKey, id, after)); },
|
|
544
|
+
runUntilSettled: async (definition, id) => {
|
|
545
|
+
ensureOpen(); if (gate.draining) throw new MayuraError('CANCELLED', 'Workflow lifecycle runtime is draining.'); assertWorkflowLifecycle(definition);
|
|
546
|
+
for (let wave = 0; wave <= definition.nodes.length + 2; wave++) {
|
|
547
|
+
const before = await load(id); const state = stateFrom(before); verifyDefinition(definition, before, state);
|
|
548
|
+
if (state.status === 'paused' || finalRunStatuses.has(state.status)) return publicSnapshot(before);
|
|
549
|
+
// Each wave holds one drain admission until its effects and receipts settle.
|
|
550
|
+
const release = gate.enter(); if (!release) return publicSnapshot(before);
|
|
551
|
+
try { await Promise.all(definition.nodes.map(node => executeNode(id, definition, node))); } finally { release(); }
|
|
552
|
+
let after = await load(id); const next = stateFrom(after); verifyDefinition(definition, after, next);
|
|
553
|
+
const steps = Object.values(next.steps);
|
|
554
|
+
if (!schedulable(next)) return publicSnapshot(after);
|
|
555
|
+
if (steps.every(step => terminalStepStatuses.has(step.status))) {
|
|
556
|
+
if (steps.every(step => satisfiedStepStatuses.has(step.status))) {
|
|
557
|
+
try { next.output = jsonValue(await controlled(() => validate(definition.output,
|
|
558
|
+
resolveBinding(definition.result, next.input, outputs(next)), 'output')), { maxBytes: maxOutputBytes }); next.status = 'succeeded'; }
|
|
559
|
+
catch { next.status = 'failed'; }
|
|
560
|
+
} else next.status = steps.some(step => step.status === 'unknown') ? 'outcome_unknown'
|
|
561
|
+
: steps.some(step => step.status === 'blocked') ? 'blocked' : 'failed';
|
|
562
|
+
try { after = await save(after, next, 'lifecycle.run.completed', { status: next.status }); }
|
|
563
|
+
catch (error) { if (!(error instanceof StorageError) || error.code !== 'CONFLICT') throw error; after = await load(id); }
|
|
564
|
+
return publicSnapshot(after);
|
|
565
|
+
}
|
|
566
|
+
if (after.version === before.version) {
|
|
567
|
+
const waiting = steps.some(step => step.status === 'waiting');
|
|
568
|
+
if (waiting && next.status !== 'waiting') {
|
|
569
|
+
next.status = 'waiting';
|
|
570
|
+
try { after = await save(after, next, 'lifecycle.run.waiting'); }
|
|
571
|
+
catch (error) { if (!(error instanceof StorageError) || error.code !== 'CONFLICT') throw error; after = await load(id); }
|
|
572
|
+
}
|
|
573
|
+
return publicSnapshot(after);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
return publicSnapshot(await load(id));
|
|
577
|
+
},
|
|
578
|
+
approve: async command => {
|
|
579
|
+
ensureOpen();
|
|
580
|
+
if (!hashPattern.test(command.id) || !nodePattern.test(command.nodeId) || !hashPattern.test(command.digest)) {
|
|
581
|
+
throw new MayuraError('INVALID_INPUT', 'Approval requires exact run, node and candidate identifiers.');
|
|
582
|
+
}
|
|
583
|
+
const human = await checkedHuman(command.credential, true); const observedAtMs = now();
|
|
584
|
+
return publicSnapshot(await mutate(command.id, state => {
|
|
585
|
+
const step = state.steps[command.nodeId];
|
|
586
|
+
if (!step || step.kind !== 'tool' || state.policy !== policy || !step.approval || step.approval.digest !== command.digest) {
|
|
587
|
+
throw new MayuraError('CONFLICT', 'Approval request is stale, expired or mismatched.');
|
|
588
|
+
}
|
|
589
|
+
if (step.status !== 'waiting' && step.approval.humanId === human.id) return false;
|
|
590
|
+
if (state.status === 'cancelled' || step.status !== 'waiting' || step.approval.expiresAt <= observedAtMs) {
|
|
591
|
+
throw new MayuraError('CONFLICT', 'Approval request is stale, expired or mismatched.');
|
|
592
|
+
}
|
|
593
|
+
step.approval.humanId = human.id; step.status = 'approved'; if (state.status !== 'paused') state.status = 'running'; return true;
|
|
594
|
+
}, 'lifecycle.approval.resolved', { nodeId: command.nodeId, humanId: human.id }));
|
|
595
|
+
},
|
|
596
|
+
respond: async (definition, command) => {
|
|
597
|
+
if (!hashPattern.test(command.id) || !nodePattern.test(command.nodeId) || !hashPattern.test(command.requestDigest)
|
|
598
|
+
|| typeof command.commandId !== 'string' || command.commandId.length < 1 || command.commandId.length > 128) {
|
|
599
|
+
throw new MayuraError('INVALID_INPUT', 'Human response requires exact run, node, request and command identifiers.');
|
|
600
|
+
}
|
|
601
|
+
const human = await checkedHuman(command.credential, false);
|
|
602
|
+
return respondAs(definition, command, { id: human.id, projectId: human.projectId });
|
|
603
|
+
},
|
|
604
|
+
respondVerified: (definition, command) => respondAs(definition, command, command.actor),
|
|
605
|
+
pause: async id => publicSnapshot(await mutate(id, state => {
|
|
606
|
+
if (state.status === 'paused') return false;
|
|
607
|
+
if (finalRunStatuses.has(state.status)) throw new MayuraError('CONFLICT', 'A terminal lifecycle workflow cannot be paused.');
|
|
608
|
+
if (Object.values(state.steps).some(step => step.kind === 'tool' && step.status === 'dispatching')) {
|
|
609
|
+
throw new MayuraError('CONFLICT', 'A lifecycle workflow with an in-flight effect cannot enter the quiescent paused state.');
|
|
610
|
+
}
|
|
611
|
+
state.status = 'paused'; return true;
|
|
612
|
+
}, 'lifecycle.run.paused')),
|
|
613
|
+
migrate: async (migration, command) => {
|
|
614
|
+
ensureOpen(); assertWorkflowMigration(migration); assertWorkflowLifecycle(migration.from); assertWorkflowLifecycle(migration.to);
|
|
615
|
+
const { id, actorId, commandId, dryRun = false } = migrationCommand(command);
|
|
616
|
+
const record = await load(id); const state = stateFrom(record); verifyDefinition(migration.from, record, state);
|
|
617
|
+
const nodes = (definition: AnyWorkflowLifecycle) => lifecycleManifest(definition).graph.map(node =>
|
|
618
|
+
({ id: node.id, kind: node.kind, dependsOn: node.dependsOn, fingerprint: nodeFingerprint(node as unknown as Record<string, unknown>),
|
|
619
|
+
...(nodeEvidence(node) ? { evidence: nodeEvidence(node)! } : {}) }));
|
|
620
|
+
const preconditions: MigrationBlocker[] = [];
|
|
621
|
+
if (state.status !== 'paused') preconditions.push({ node: '*', reason: `The run is ${state.status}; pause it before migrating.` });
|
|
622
|
+
const plan = planWorkflowMigration({ migration, format: 'lifecycle-v1', runId: id, fromDigest: migration.from.digest, toDigest: migration.to.digest,
|
|
623
|
+
from: nodes(migration.from), to: nodes(migration.to), steps: Object.entries(state.steps).map(([step, value]) => ({ id: step, status: value.status })), preconditions });
|
|
624
|
+
if (dryRun) return freezeJson(jsonValue({ plan })) as unknown as WorkflowMigrationResult<WorkflowLifecycleSnapshot>;
|
|
625
|
+
assertMigrationAllowed(plan);
|
|
626
|
+
const fresh = initialWorkflowLifecycleState(lifecycleManifest(migration.to), state.input, migration.to.digest, policy, maxCostMicros);
|
|
627
|
+
const steps: Record<string, WorkflowLifecycleStep> = {};
|
|
628
|
+
for (const entry of plan.entries) {
|
|
629
|
+
if (!entry.target) continue;
|
|
630
|
+
steps[entry.target] = entry.action === 'keep' || entry.action === 'accept' ? state.steps[entry.source!]! : fresh.steps[entry.target]!;
|
|
631
|
+
}
|
|
632
|
+
const next: State = { ...state, definition: migration.to.digest,
|
|
633
|
+
steps: Object.fromEntries(migration.to.nodes.map(node => [node.id, steps[node.id]!])) };
|
|
634
|
+
// Released holds: only carried tool steps keep reserved cost.
|
|
635
|
+
next.reservedMicros = Object.values(next.steps).reduce((sum, step) => sum + (step.kind === 'tool' ? step.costReserved : 0), 0);
|
|
636
|
+
for (const node of migration.to.nodes) {
|
|
637
|
+
const step = next.steps[node.id]!;
|
|
638
|
+
if (node.kind === 'human' && step.kind === 'human' && step.status === 'waiting') {
|
|
639
|
+
const evidence = humanEvidence(migration.to, node, id, next); step.requestDigest = evidence.requestDigest; step.deadlineAtMs = evidence.deadlineAtMs;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
try { assertWorkflowLifecycleStateMatchesManifest(workflowLifecycleState({ id, state: jsonValue(next) as JsonObject }), lifecycleManifest(migration.to)); }
|
|
643
|
+
catch { throw new MayuraError('CONFLICT', 'Migration refused: the migrated state does not satisfy the new definition.'); }
|
|
644
|
+
if (typeof store.migrate !== 'function') throw new MayuraError('UNSUPPORTED_PROFILE', 'This store cannot migrate in-flight workflow runs.');
|
|
645
|
+
const migrated = await storageCall(() => store.migrate!({ scope: scopeKey, id, expectedVersion: record.version, expectedDefinitionHash: migration.from.digest,
|
|
646
|
+
definitionHash: migration.to.digest, state: jsonValue(next) as JsonObject, events: [migrationEvent(plan, actorId, commandId) as { type: string; data: JsonObject }] }));
|
|
647
|
+
verifyDefinition(migration.to, migrated, stateFrom(migrated));
|
|
648
|
+
return freezeJson(jsonValue({ plan, snapshot: publicSnapshot(migrated) })) as unknown as WorkflowMigrationResult<WorkflowLifecycleSnapshot>;
|
|
649
|
+
},
|
|
650
|
+
resume: async id => publicSnapshot(await mutate(id, state => {
|
|
651
|
+
if (state.status !== 'paused') throw new MayuraError('CONFLICT', 'Only a paused lifecycle workflow can be resumed.');
|
|
652
|
+
state.status = Object.values(state.steps).some(step => step.status === 'waiting') ? 'waiting' : 'running'; return true;
|
|
653
|
+
}, 'lifecycle.run.resumed')),
|
|
654
|
+
cancel: async id => {
|
|
655
|
+
const record = await mutate(id, state => {
|
|
656
|
+
if (finalRunStatuses.has(state.status)) return false;
|
|
657
|
+
for (const step of Object.values(state.steps)) if (step.status !== 'dispatching') skip(step);
|
|
658
|
+
state.status = 'cancelled'; return true;
|
|
659
|
+
}, 'lifecycle.run.cancelled');
|
|
660
|
+
for (const [key, controller] of active) if (key.startsWith(`${id}/`)) controller.abort();
|
|
661
|
+
return publicSnapshot(record);
|
|
662
|
+
},
|
|
663
|
+
recoverAbandoned: async id => publicSnapshot(await mutate(id, state => {
|
|
664
|
+
let changed = false;
|
|
665
|
+
for (const step of Object.values(state.steps)) if (step.kind === 'tool' && step.status === 'dispatching') {
|
|
666
|
+
step.status = step.receipt?.execution === 'succeeded' ? 'blocked' : 'unknown'; changed = true;
|
|
667
|
+
}
|
|
668
|
+
if (changed && state.status !== 'cancelled') state.status = 'running'; return changed;
|
|
669
|
+
}, 'lifecycle.run.recovery_required')),
|
|
670
|
+
close: () => { closed = true; for (const controller of active.values()) controller.abort(); },
|
|
671
|
+
drain: options => gate.drain(options, () => { closed = true; for (const controller of active.values()) controller.abort(); }),
|
|
672
|
+
});
|
|
673
|
+
}
|