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,68 @@
|
|
|
1
|
+
import type { ExecutionReceipt, ExecutionSettlement, JsonObject, JsonValue } from '@mayura/core';
|
|
2
|
+
import type { AggregateStore, StoredEvent } from './contracts.js';
|
|
3
|
+
|
|
4
|
+
export type JobState = 'ready' | 'leased' | 'started' | 'succeeded' | 'failed' | 'blocked' | 'cancelled' | 'outcome_unknown';
|
|
5
|
+
export interface JobKey { readonly scope: string; readonly jobId: string }
|
|
6
|
+
export interface Claim extends JobKey {
|
|
7
|
+
readonly workerId: string; readonly fence: number;
|
|
8
|
+
/** Informational only; the store always checks its persisted expiry. */
|
|
9
|
+
readonly leaseUntilMs: number;
|
|
10
|
+
}
|
|
11
|
+
export interface JobReservation extends JobKey {
|
|
12
|
+
readonly reservationKey: string; readonly runId: string; readonly nodeId: string; readonly invocationId: string;
|
|
13
|
+
readonly definitionHash: string; readonly candidateHash: string;
|
|
14
|
+
/** Safe bounded metadata, including required toolId and callId; never credentials. */
|
|
15
|
+
readonly intent: JsonObject;
|
|
16
|
+
readonly resourceKeys: readonly string[];
|
|
17
|
+
readonly delayMs: number; readonly deadlineAfterMs?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface JobRecord extends JobKey {
|
|
20
|
+
readonly runId: string; readonly nodeId: string; readonly invocationId: string;
|
|
21
|
+
readonly definitionHash: string; readonly candidateHash: string; readonly intent: JsonObject;
|
|
22
|
+
readonly resourceKeys: readonly string[]; readonly state: JobState; readonly version: number; readonly fence: number;
|
|
23
|
+
readonly workerId: string | null; readonly dueAtMs: number; readonly deadlineAtMs: number | null;
|
|
24
|
+
readonly leaseUntilMs: number | null; readonly startedAtMs: number | null;
|
|
25
|
+
readonly leaseRevoked: boolean; readonly cancelRequested: boolean;
|
|
26
|
+
readonly receipt: ExecutionReceipt | null; readonly output: JsonValue | null;
|
|
27
|
+
}
|
|
28
|
+
export type EvidenceDisposition = 'current' | 'late' | 'conflicting';
|
|
29
|
+
export interface SchedulerEvidenceSource {
|
|
30
|
+
readonly kind: 'external_reconciliation';
|
|
31
|
+
readonly authorityId: string;
|
|
32
|
+
/** Domain-separated digest of the verifier's stable attestation ID; never a credential. */
|
|
33
|
+
readonly attestationHash: string;
|
|
34
|
+
}
|
|
35
|
+
export interface SchedulerEvidence {
|
|
36
|
+
readonly evidenceId: string; readonly receipt: ExecutionReceipt;
|
|
37
|
+
/** Optional for generic scheduler users; integrated metered workflows require it. */
|
|
38
|
+
readonly settlement?: ExecutionSettlement;
|
|
39
|
+
readonly source?: SchedulerEvidenceSource;
|
|
40
|
+
readonly disposition: EvidenceDisposition; readonly recordedAtMs: number;
|
|
41
|
+
}
|
|
42
|
+
export interface ReceiptCommand extends JobKey {
|
|
43
|
+
readonly fence: number; readonly evidenceId: string; readonly receipt: ExecutionReceipt;
|
|
44
|
+
readonly settlement?: ExecutionSettlement;
|
|
45
|
+
readonly source?: SchedulerEvidenceSource;
|
|
46
|
+
}
|
|
47
|
+
export interface CompleteJobCommand {
|
|
48
|
+
readonly claim: Claim; readonly commandId: string; readonly evidenceId: string;
|
|
49
|
+
readonly outcome: 'succeeded' | 'failed' | 'blocked'; readonly output: JsonValue | null;
|
|
50
|
+
}
|
|
51
|
+
/** Trusted standalone job ledger. It does not fence ordinary AggregateStore/workflow writes. */
|
|
52
|
+
export interface SchedulerStore {
|
|
53
|
+
initialize(): Promise<void>;
|
|
54
|
+
reserve(command: JobReservation): Promise<{ readonly job: JobRecord; readonly created: boolean }>;
|
|
55
|
+
read(key: JobKey): Promise<JobRecord | undefined>;
|
|
56
|
+
claim(command: { readonly scope: string; readonly workerId: string; readonly limit: number; readonly leaseMs: number }): Promise<readonly { readonly job: JobRecord; readonly claim: Claim }[]>;
|
|
57
|
+
renew(command: { readonly claim: Claim; readonly leaseMs: number }): Promise<Claim>;
|
|
58
|
+
/** Only status=started grants one fresh dispatch; retries never grant a second dispatch. */
|
|
59
|
+
start(command: { readonly claim: Claim; readonly candidateHash: string }): Promise<{ readonly status: 'started' | 'already_started'; readonly job: JobRecord }>;
|
|
60
|
+
recordReceipt(command: ReceiptCommand): Promise<{ readonly disposition: EvidenceDisposition; readonly job: JobRecord }>;
|
|
61
|
+
receipts(command: JobKey & { readonly fence: number }): Promise<readonly SchedulerEvidence[]>;
|
|
62
|
+
complete(command: CompleteJobCommand): Promise<JobRecord>;
|
|
63
|
+
cancel(command: JobKey & { readonly commandId: string }): Promise<JobRecord>;
|
|
64
|
+
recover(command: { readonly scope: string; readonly limit: number }): Promise<readonly JobRecord[]>;
|
|
65
|
+
events(command: { readonly scope: string; readonly runId: string; readonly after?: number; readonly limit?: number }): Promise<readonly StoredEvent[]>;
|
|
66
|
+
}
|
|
67
|
+
/** Scheduler and aggregate operations share one backend and lifecycle. */
|
|
68
|
+
export interface SchedulerAggregateStore extends AggregateStore { readonly scheduler: SchedulerStore }
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { MayuraError } from '@mayura/core';
|
|
2
|
+
import { StorageError, type AggregateStore } from './contracts.js';
|
|
3
|
+
import { workflowHashMaterial } from './workflow-format2.js';
|
|
4
|
+
|
|
5
|
+
/** Structurally matches `AgentServerOptions.submissionJournal`; the server package does not depend on storage. */
|
|
6
|
+
export interface SubmissionJournal {
|
|
7
|
+
claim(input: { readonly owner: string; readonly key: string; readonly digest: string; readonly signal?: AbortSignal }):
|
|
8
|
+
Promise<{ readonly status: 'claimed' } | { readonly status: 'existing'; readonly digest: string }>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const encoder = new TextEncoder();
|
|
12
|
+
async function sha256(domain: string, value: unknown): Promise<string> {
|
|
13
|
+
const bytes = await crypto.subtle.digest('SHA-256', encoder.encode(workflowHashMaterial(domain, value)));
|
|
14
|
+
return [...new Uint8Array(bytes)].map(byte => byte.toString(16).padStart(2, '0')).join('');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Durable claim of every HTTP submission key before a run starts. A retry that reaches a new process after a
|
|
19
|
+
* restart finds the claim and cannot start a duplicate run. Claims are permanent: they record only digests.
|
|
20
|
+
*/
|
|
21
|
+
export function createAggregateSubmissionJournal(store: AggregateStore): SubmissionJournal {
|
|
22
|
+
if (!store || typeof store.create !== 'function') throw new MayuraError('INVALID_CONFIG', 'A submission journal requires an aggregate store.');
|
|
23
|
+
return Object.freeze<SubmissionJournal>({
|
|
24
|
+
async claim(input) {
|
|
25
|
+
if (typeof input?.owner !== 'string' || input.owner.length < 1 || input.owner.length > 4_096 || typeof input.key !== 'string'
|
|
26
|
+
|| !/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(input.key) || typeof input.digest !== 'string' || !/^[a-f0-9]{64}$/.test(input.digest)) {
|
|
27
|
+
throw new MayuraError('INVALID_INPUT', 'A submission claim requires an owner, a bounded key and a request digest.');
|
|
28
|
+
}
|
|
29
|
+
input.signal?.throwIfAborted();
|
|
30
|
+
const scope = await sha256('mayura:submission-journal-scope:v1', { owner: input.owner });
|
|
31
|
+
const id = await sha256('mayura:submission-journal-entry:v1', { owner: input.owner, key: input.key });
|
|
32
|
+
const existing = async (): Promise<{ readonly status: 'existing'; readonly digest: string }> => {
|
|
33
|
+
const record = await store.read(scope, id); const digest = record?.state['digest'];
|
|
34
|
+
if (!record || record.state['format'] !== 1 || typeof digest !== 'string' || !/^[a-f0-9]{64}$/.test(digest)) {
|
|
35
|
+
throw new MayuraError('STORAGE_UNAVAILABLE', 'Stored submission claim failed integrity validation.');
|
|
36
|
+
}
|
|
37
|
+
return { status: 'existing' as const, digest };
|
|
38
|
+
};
|
|
39
|
+
if (await store.read(scope, id)) return existing();
|
|
40
|
+
// Create-if-absent is the atomic primitive: exactly one claimant creates the record. A concurrent claimant with the
|
|
41
|
+
// same digest sees created:false; one with a different digest is rejected as a conflict. Both then read the winner.
|
|
42
|
+
try {
|
|
43
|
+
const created = await store.create({ scope, id, idempotencyKey: id, definitionHash: await sha256('mayura:submission-journal-format:v1', {}),
|
|
44
|
+
state: { format: 1, digest: input.digest }, events: [{ type: 'submission.claimed', data: {} }] });
|
|
45
|
+
if (created.created) return { status: 'claimed' as const };
|
|
46
|
+
} catch (error) { if (!(error instanceof StorageError) || error.code !== 'CONFLICT') throw error; }
|
|
47
|
+
return existing();
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { freezeJson, jsonValue, type ExecutionReceipt, type JsonObject, type JsonValue } from '@mayura/core';
|
|
2
|
+
import { StorageError, type StoredRecord } from './contracts.js';
|
|
3
|
+
import type { WorkflowBinding, WorkflowManifest, WorkflowPolicyManifest, WorkflowResourcePlan } from './scheduled-workflow-contracts.js';
|
|
4
|
+
|
|
5
|
+
export type WorkflowFormat2StepStatus = 'pending' | 'waiting' | 'approved' | 'dispatching' | 'succeeded' | 'failed' | 'blocked' | 'unknown' | 'skipped';
|
|
6
|
+
export type WorkflowFormat2Status = 'running' | 'waiting' | 'paused' | 'succeeded' | 'failed' | 'blocked' | 'cancelled' | 'outcome_unknown';
|
|
7
|
+
export interface WorkflowFormat2Approval { digest: string; expiresAt: number; humanId: string | null }
|
|
8
|
+
export interface WorkflowFormat2Step {
|
|
9
|
+
kind: 'tool' | 'join'; status: WorkflowFormat2StepStatus; callId: string; output: JsonValue;
|
|
10
|
+
receipt: ExecutionReceipt | null; approval: WorkflowFormat2Approval | null; costReserved: number; candidateHash: string | null;
|
|
11
|
+
}
|
|
12
|
+
/** Exact legacy durable representation. Scheduler ownership must live outside this format. */
|
|
13
|
+
export interface WorkflowFormat2State {
|
|
14
|
+
format: 2; definition: string; policy: string; input: JsonValue; status: WorkflowFormat2Status;
|
|
15
|
+
steps: Record<string, WorkflowFormat2Step>; maxCostMicros: number; spentMicros: number; reservedMicros: number; output: JsonValue;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const nodeId = /^[A-Za-z][A-Za-z0-9._-]{0,127}$/;
|
|
19
|
+
const toolId = /^[A-Za-z][A-Za-z0-9._/-]{0,127}$/;
|
|
20
|
+
const forbidden = new Set(['constructor', 'prototype', '__proto__']);
|
|
21
|
+
const statuses = new Set(['running', 'waiting', 'paused', 'succeeded', 'failed', 'blocked', 'cancelled', 'outcome_unknown']);
|
|
22
|
+
const stepStatuses = new Set(['pending', 'waiting', 'approved', 'dispatching', 'succeeded', 'failed', 'blocked', 'unknown', 'skipped']);
|
|
23
|
+
const encoder = new TextEncoder();
|
|
24
|
+
const stateKeys = ['format', 'definition', 'policy', 'input', 'status', 'steps', 'maxCostMicros', 'spentMicros', 'reservedMicros', 'output'];
|
|
25
|
+
const stepKeys = ['kind', 'status', 'callId', 'output', 'receipt', 'approval', 'costReserved', 'candidateHash'];
|
|
26
|
+
|
|
27
|
+
function invalid(): never { throw new StorageError('INVALID_INPUT', 'Invalid bounded workflow metadata.'); }
|
|
28
|
+
function corrupt(): never { throw new StorageError('CONFLICT', 'Stored workflow state failed integrity validation.'); }
|
|
29
|
+
function object(value: JsonValue | undefined): JsonObject {
|
|
30
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value)) return invalid();
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
function fields(value: JsonObject, expected: readonly string[]): void {
|
|
34
|
+
if (Object.keys(value).length !== expected.length || expected.some(key => !Object.hasOwn(value, key))) invalid();
|
|
35
|
+
}
|
|
36
|
+
function integer(value: unknown, minimum = 0, maximum = Number.MAX_SAFE_INTEGER): number {
|
|
37
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < minimum || value > maximum) return invalid();
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
function text(value: unknown, maximum: number): string {
|
|
41
|
+
if (typeof value !== 'string' || value.length === 0 || value.length > maximum) return invalid();
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
function identity(value: unknown, maximum = 256): string {
|
|
45
|
+
// A valid pair is one Unicode code point; reject only unpaired surrogate units
|
|
46
|
+
// so distinct identities cannot alias after SQL's UTF-8 replacement encoding.
|
|
47
|
+
if (typeof value !== 'string' || value.length === 0 || value.length > maximum || /[\uD800-\uDFFF]/u.test(value) || encoder.encode(value).length > maximum || value.includes('\0')) return invalid();
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
function hash(value: unknown): string {
|
|
51
|
+
if (typeof value !== 'string' || !/^[a-f0-9]{64}$/.test(value)) return invalid();
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
function stepIdentity(value: unknown): string {
|
|
55
|
+
if (typeof value !== 'string' || !nodeId.test(value) || forbidden.has(value)) return invalid();
|
|
56
|
+
return value;
|
|
57
|
+
}
|
|
58
|
+
function toolIdentity(value: unknown): string {
|
|
59
|
+
if (typeof value !== 'string' || !toolId.test(value)) return invalid();
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
function list(value: JsonValue | undefined, maximum: number): JsonValue[] {
|
|
63
|
+
if (!Array.isArray(value) || value.length > maximum) return invalid();
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
function binding(value: JsonValue | undefined, ids?: ReadonlySet<string>): WorkflowBinding {
|
|
67
|
+
const item = object(value);
|
|
68
|
+
if (item['kind'] === 'literal') fields(item, ['kind', 'value']);
|
|
69
|
+
else if (item['kind'] === 'input' || item['kind'] === 'step') {
|
|
70
|
+
fields(item, item['kind'] === 'input' ? ['kind', 'path'] : ['kind', 'stepId', 'path']);
|
|
71
|
+
for (const segment of list(item['path'], 32)) if (typeof segment !== 'string' || forbidden.has(segment)) invalid();
|
|
72
|
+
if (item['kind'] === 'step') {
|
|
73
|
+
const id = stepIdentity(item['stepId']); if (ids && !ids.has(id)) invalid();
|
|
74
|
+
}
|
|
75
|
+
} else invalid();
|
|
76
|
+
return item as unknown as WorkflowBinding;
|
|
77
|
+
}
|
|
78
|
+
function receipt(value: unknown): ExecutionReceipt {
|
|
79
|
+
const item = object(jsonValue(value, { maxBytes: 2_048 }));
|
|
80
|
+
fields(item, ['callId', 'toolId', 'execution', 'disclosure']);
|
|
81
|
+
identity(item['callId'], 512); toolIdentity(item['toolId']);
|
|
82
|
+
if (!['not_started', 'succeeded', 'failed', 'unknown'].includes(item['execution'] as string)
|
|
83
|
+
|| !['released', 'withheld'].includes(item['disclosure'] as string)
|
|
84
|
+
|| (item['disclosure'] === 'released' && item['execution'] !== 'succeeded')) invalid();
|
|
85
|
+
return item as unknown as ExecutionReceipt;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Deeply snapshot the exact data-only graph material used by legacy definition hashing. */
|
|
89
|
+
export function workflowManifest(value: unknown): WorkflowManifest {
|
|
90
|
+
try {
|
|
91
|
+
const manifest = object(jsonValue(value)); fields(manifest, ['id', 'version', 'graph', 'result']);
|
|
92
|
+
// Workflow IDs historically permit these names; only step IDs prohibit prototype keys.
|
|
93
|
+
if (typeof manifest['id'] !== 'string' || !nodeId.test(manifest['id'])) invalid();
|
|
94
|
+
text(manifest['version'], 128);
|
|
95
|
+
const graph = list(manifest['graph'], 128); if (graph.length === 0) invalid();
|
|
96
|
+
const ids = new Set<string>();
|
|
97
|
+
for (const raw of graph) { const id = stepIdentity(object(raw)['id']); if (ids.has(id)) invalid(); ids.add(id); }
|
|
98
|
+
const dependencies = new Map<string, readonly string[]>();
|
|
99
|
+
for (const raw of graph) {
|
|
100
|
+
const node = object(raw); const id = stepIdentity(node['id']);
|
|
101
|
+
const deps = list(node['dependsOn'], 128).map(stepIdentity);
|
|
102
|
+
if (new Set(deps).size !== deps.length || deps.some(dependency => !ids.has(dependency))) invalid();
|
|
103
|
+
dependencies.set(id, deps);
|
|
104
|
+
if (node['kind'] === 'join') fields(node, ['id', 'kind', 'dependsOn']);
|
|
105
|
+
else if (node['kind'] === 'tool') {
|
|
106
|
+
fields(node, ['id', 'kind', 'dependsOn', 'tool', 'toolVersion', 'effects', 'capabilities', 'costMicros', 'approval', 'input']);
|
|
107
|
+
toolIdentity(node['tool']); text(node['toolVersion'], 128);
|
|
108
|
+
if (!['none', 'read', 'write', 'host'].includes(node['effects'] as string) || typeof node['approval'] !== 'boolean') invalid();
|
|
109
|
+
integer(node['costMicros']);
|
|
110
|
+
const capabilities = list(node['capabilities'], 128).map(capability => text(capability, 256));
|
|
111
|
+
if (new Set(capabilities).size !== capabilities.length) invalid();
|
|
112
|
+
const source = binding(node['input'], ids);
|
|
113
|
+
if (source.kind === 'step' && !deps.includes(source.stepId)) invalid();
|
|
114
|
+
} else invalid();
|
|
115
|
+
}
|
|
116
|
+
// Bounded depth-first validation supports forward declarations without permitting cycles.
|
|
117
|
+
const visiting = new Set<string>(); const visited = new Set<string>();
|
|
118
|
+
const visit = (id: string): void => {
|
|
119
|
+
if (visiting.has(id)) invalid(); if (visited.has(id)) return;
|
|
120
|
+
visiting.add(id); for (const dependency of dependencies.get(id)!) visit(dependency);
|
|
121
|
+
visiting.delete(id); visited.add(id);
|
|
122
|
+
};
|
|
123
|
+
for (const id of ids) visit(id);
|
|
124
|
+
binding(manifest['result'], ids);
|
|
125
|
+
return freezeJson(manifest) as unknown as WorkflowManifest;
|
|
126
|
+
} catch { return invalid(); }
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Scheduled-profile policy snapshot. Sorted permissions intentionally retain legacy duplicates. */
|
|
130
|
+
export function workflowPolicy(value: unknown): WorkflowPolicyManifest {
|
|
131
|
+
try {
|
|
132
|
+
const policy = object(jsonValue(value));
|
|
133
|
+
fields(policy, ['scope', 'permissions', 'policyVersion', 'maxCostMicros', 'maxOutputBytes', 'approvalTtlMs']);
|
|
134
|
+
const scope = object(policy['scope']); fields(scope, ['principalId', 'projectId']);
|
|
135
|
+
text(scope['principalId'], 128); text(scope['projectId'], 128); text(policy['policyVersion'], 128);
|
|
136
|
+
policy['permissions'] = list(policy['permissions'], 4_096).map(grant => text(grant, 256)).sort();
|
|
137
|
+
integer(policy['maxCostMicros']); integer(policy['maxOutputBytes'], 1, 65_536); integer(policy['approvalTtlMs'], 1);
|
|
138
|
+
return freezeJson(policy) as unknown as WorkflowPolicyManifest;
|
|
139
|
+
} catch { return invalid(); }
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Canonical per-tool exact resources; omission means [], never an inferred resource identity. */
|
|
143
|
+
export function workflowResources(value: unknown, definition: WorkflowManifest): WorkflowResourcePlan {
|
|
144
|
+
try {
|
|
145
|
+
const manifest = workflowManifest(definition); const supplied = object(jsonValue(value));
|
|
146
|
+
const tools = new Set(manifest.graph.filter(node => node.kind === 'tool').map(node => node.id));
|
|
147
|
+
if (Object.keys(supplied).some(id => !tools.has(id))) invalid();
|
|
148
|
+
const result: JsonObject = {};
|
|
149
|
+
for (const id of [...tools].sort()) {
|
|
150
|
+
const requested = Object.hasOwn(supplied, id) ? list(supplied[id], 32) : [];
|
|
151
|
+
result[id] = [...new Set(requested.map(value => identity(value)))].sort();
|
|
152
|
+
}
|
|
153
|
+
return freezeJson(jsonValue(result)) as unknown as WorkflowResourcePlan;
|
|
154
|
+
} catch { return invalid(); }
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Legacy canonical JSON v1 material, including its exact domain/newline separator. No hashing or I/O. */
|
|
158
|
+
export function workflowHashMaterial(domain: string, value: unknown): string {
|
|
159
|
+
try {
|
|
160
|
+
if (typeof domain !== 'string' || !/^[A-Za-z0-9:._/-]{1,128}$/.test(domain)) invalid();
|
|
161
|
+
const canonical = (item: JsonValue): string => {
|
|
162
|
+
if (item === null || typeof item !== 'object') return JSON.stringify(item);
|
|
163
|
+
if (Array.isArray(item)) return `[${item.map(canonical).join(',')}]`;
|
|
164
|
+
return `{${Object.keys(item).sort().map(key => `${JSON.stringify(key)}:${canonical(item[key]!)}`).join(',')}}`;
|
|
165
|
+
};
|
|
166
|
+
return `${domain}\n${canonical(jsonValue(value))}`;
|
|
167
|
+
} catch { return invalid(); }
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Decode a fresh mutable format-2 copy; input records and nested objects are never mutated. */
|
|
171
|
+
export function workflowState(record: Pick<StoredRecord, 'id' | 'state'>): WorkflowFormat2State {
|
|
172
|
+
try {
|
|
173
|
+
// Read own data descriptors so external storage accessors cannot execute at this boundary.
|
|
174
|
+
const idDescriptor = Object.getOwnPropertyDescriptor(record, 'id'); const stateDescriptor = Object.getOwnPropertyDescriptor(record, 'state');
|
|
175
|
+
if (!idDescriptor || !('value' in idDescriptor) || !stateDescriptor || !('value' in stateDescriptor)) corrupt();
|
|
176
|
+
const runId = identity(idDescriptor.value); const state = object(jsonValue(stateDescriptor.value)); fields(state, stateKeys);
|
|
177
|
+
if (state['format'] !== 2 || !statuses.has(state['status'] as string)) corrupt();
|
|
178
|
+
hash(state['definition']); hash(state['policy']);
|
|
179
|
+
const maxCost = integer(state['maxCostMicros']); const spent = integer(state['spentMicros']); const totalReserved = integer(state['reservedMicros']);
|
|
180
|
+
const steps = object(state['steps']); const entries = Object.entries(steps); if (entries.length === 0 || entries.length > 128) corrupt();
|
|
181
|
+
let reserved = 0;
|
|
182
|
+
for (const [id, raw] of entries) {
|
|
183
|
+
stepIdentity(id); const step = object(raw); fields(step, stepKeys);
|
|
184
|
+
if (!['tool', 'join'].includes(step['kind'] as string) || !stepStatuses.has(step['status'] as string) || step['callId'] !== `step:${id}`) corrupt();
|
|
185
|
+
const amount = integer(step['costReserved']); reserved += amount; integer(reserved);
|
|
186
|
+
if (step['candidateHash'] !== null) hash(step['candidateHash']);
|
|
187
|
+
if (step['approval'] !== null) {
|
|
188
|
+
const approval = object(step['approval']); fields(approval, ['digest', 'expiresAt', 'humanId']);
|
|
189
|
+
hash(approval['digest']); integer(approval['expiresAt'], 1);
|
|
190
|
+
if (approval['humanId'] !== null) text(approval['humanId'], 256);
|
|
191
|
+
}
|
|
192
|
+
if (step['status'] === 'approved' && (step['approval'] === null || !object(step['approval'])['humanId'])) corrupt();
|
|
193
|
+
if (step['receipt'] !== null) {
|
|
194
|
+
const evidence = receipt(step['receipt']); if (evidence.callId !== `${runId}/step:${id}`) corrupt();
|
|
195
|
+
}
|
|
196
|
+
if (step['status'] !== 'succeeded' && step['output'] !== null) corrupt();
|
|
197
|
+
if (step['kind'] === 'join' && (step['receipt'] !== null || step['approval'] !== null || step['candidateHash'] !== null || amount !== 0)) corrupt();
|
|
198
|
+
if (step['status'] === 'succeeded') {
|
|
199
|
+
if (amount !== 0) corrupt();
|
|
200
|
+
if (step['kind'] === 'tool' && (step['receipt'] === null || object(step['receipt'])['execution'] !== 'succeeded'
|
|
201
|
+
|| object(step['receipt'])['disclosure'] !== 'released' || step['candidateHash'] === null)) corrupt();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (reserved !== totalReserved || spent > maxCost - totalReserved) corrupt();
|
|
205
|
+
if (state['status'] === 'succeeded' && entries.some(([, raw]) => object(raw)['status'] !== 'succeeded')) corrupt();
|
|
206
|
+
if (state['status'] !== 'succeeded' && state['output'] !== null) corrupt();
|
|
207
|
+
return state as unknown as WorkflowFormat2State;
|
|
208
|
+
} catch { return corrupt(); }
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Cross-check stored graph evidence against its immutable manifest, not just its shape. */
|
|
212
|
+
export function assertWorkflowStateMatchesManifest(state: WorkflowFormat2State, definition: WorkflowManifest): void {
|
|
213
|
+
try {
|
|
214
|
+
const manifest = workflowManifest(definition);
|
|
215
|
+
// Callers must decode the state first; this helper additionally snapshots to reject accessors.
|
|
216
|
+
const value = object(jsonValue(state)); const steps = object(value['steps']);
|
|
217
|
+
if (Object.keys(steps).length !== manifest.graph.length) corrupt();
|
|
218
|
+
for (const node of manifest.graph) {
|
|
219
|
+
const step = object(steps[node.id]);
|
|
220
|
+
if (step['kind'] !== node.kind || (node.kind === 'tool' && step['receipt'] !== null && object(step['receipt'])['toolId'] !== node.tool)) corrupt();
|
|
221
|
+
if (step['status'] === 'succeeded' && node.dependsOn.some(id => object(steps[id])['status'] !== 'succeeded')) corrupt();
|
|
222
|
+
if (node.kind === 'tool') {
|
|
223
|
+
const reserved = integer(step['costReserved']);
|
|
224
|
+
if ((step['approval'] !== null && !node.approval) || reserved > node.costMicros
|
|
225
|
+
|| (reserved !== 0 && reserved !== node.costMicros && step['status'] !== 'unknown')) corrupt();
|
|
226
|
+
if (node.approval && step['candidateHash'] !== null
|
|
227
|
+
&& (step['approval'] === null || object(step['approval'])['digest'] !== step['candidateHash'])) corrupt();
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
} catch { return corrupt(); }
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** Construct unchanged legacy initial state; input schema admission remains outside this module. */
|
|
234
|
+
export function initialWorkflowState(definition: WorkflowManifest, input: JsonValue, definitionHash: string, policyHash: string, maxCostMicros: number): WorkflowFormat2State {
|
|
235
|
+
try {
|
|
236
|
+
const manifest = workflowManifest(definition); hash(definitionHash); hash(policyHash); integer(maxCostMicros);
|
|
237
|
+
const state: WorkflowFormat2State = { format: 2, definition: definitionHash, policy: policyHash, input: jsonValue(input), status: 'running',
|
|
238
|
+
maxCostMicros, spentMicros: 0, reservedMicros: 0, output: null,
|
|
239
|
+
steps: Object.fromEntries(manifest.graph.map(node => [node.id, { kind: node.kind, status: 'pending', callId: `step:${node.id}`,
|
|
240
|
+
output: null, receipt: null, approval: null, costReserved: 0, candidateHash: null }])) };
|
|
241
|
+
// Input and structural overhead share the same aggregate boundary, not independent allowances.
|
|
242
|
+
return jsonValue(state) as unknown as WorkflowFormat2State;
|
|
243
|
+
} catch { return invalid(); }
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** Project only released successful step outputs; callers receive a detached JSON copy. */
|
|
247
|
+
export function workflowOutputs(state: WorkflowFormat2State): Record<string, JsonValue> {
|
|
248
|
+
try {
|
|
249
|
+
const steps = object(object(jsonValue(state))['steps']);
|
|
250
|
+
return Object.fromEntries(Object.entries(steps).filter(([, step]) => object(step)['status'] === 'succeeded').map(([id, raw]) => {
|
|
251
|
+
const step = object(raw);
|
|
252
|
+
if (step['kind'] === 'tool') {
|
|
253
|
+
const evidence = receipt(step['receipt']);
|
|
254
|
+
if (evidence.execution !== 'succeeded' || evidence.disclosure !== 'released') corrupt();
|
|
255
|
+
} else if (step['kind'] !== 'join') corrupt();
|
|
256
|
+
if (!Object.hasOwn(step, 'output')) corrupt();
|
|
257
|
+
return [id, step['output']!];
|
|
258
|
+
}));
|
|
259
|
+
} catch { return corrupt(); }
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** Known receipt facts never regress to unknown; conflicting known facts require reconciliation. */
|
|
263
|
+
export function mergeWorkflowReceipt(previous: ExecutionReceipt | null, incoming: ExecutionReceipt): ExecutionReceipt {
|
|
264
|
+
try {
|
|
265
|
+
const next = receipt(incoming); const before = previous === null ? null : receipt(previous);
|
|
266
|
+
if (before && (before.callId !== next.callId || before.toolId !== next.toolId)) corrupt();
|
|
267
|
+
if (before && before.execution !== 'unknown') {
|
|
268
|
+
if (next.execution === 'unknown') return Object.freeze(before);
|
|
269
|
+
if (before.execution !== next.execution) corrupt();
|
|
270
|
+
if (before.disclosure === 'released') return Object.freeze(before);
|
|
271
|
+
}
|
|
272
|
+
return Object.freeze(next);
|
|
273
|
+
} catch { return corrupt(); }
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** Resolve an admitted JSON binding without prototype traversal or executable expressions. */
|
|
277
|
+
export function resolveWorkflowBinding(source: WorkflowBinding, input: JsonValue, outputs: Readonly<Record<string, JsonValue>>): JsonValue {
|
|
278
|
+
try {
|
|
279
|
+
const selected = binding(jsonValue(source));
|
|
280
|
+
if (selected.kind === 'literal') return jsonValue(selected.value);
|
|
281
|
+
const values = object(jsonValue(outputs)); let value: JsonValue | undefined = selected.kind === 'input' ? jsonValue(input) : values[selected.stepId];
|
|
282
|
+
for (const segment of selected.path) {
|
|
283
|
+
if (value === null || typeof value !== 'object' || !Object.hasOwn(value, segment)) invalid();
|
|
284
|
+
value = (value as JsonObject)[segment];
|
|
285
|
+
}
|
|
286
|
+
return jsonValue(value);
|
|
287
|
+
} catch { throw new StorageError('INVALID_INPUT', 'Workflow binding cannot resolve its path.'); }
|
|
288
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { freezeJson, jsonValue, type ExecutionReceipt, type JsonObject, type JsonValue } from '@mayura/core';
|
|
2
|
+
import { StorageError, type StoredRecord } from './contracts.js';
|
|
3
|
+
import { executionCompletion, executionRef, type ExecutionCompletion, type ExecutionRef } from './execution-wait-contracts.js';
|
|
4
|
+
import { mergeWorkflowReceipt, resolveWorkflowBinding, workflowHashMaterial, workflowManifest, workflowResources } from './workflow-format2.js';
|
|
5
|
+
import type { WorkflowBinding, WorkflowManifest, WorkflowResourcePlan } from './scheduled-workflow-contracts.js';
|
|
6
|
+
import type { WorkflowGraphFormat3State, WorkflowGraphManifest } from './workflow-graph-contracts.js';
|
|
7
|
+
|
|
8
|
+
const forbidden = new Set(['constructor', 'prototype', '__proto__']);
|
|
9
|
+
const idPattern = /^[A-Za-z][A-Za-z0-9._-]{0,127}$/;
|
|
10
|
+
const statuses = new Set(['running', 'waiting', 'paused', 'succeeded', 'failed', 'blocked', 'cancelled', 'outcome_unknown']);
|
|
11
|
+
const stepStatuses = new Set(['pending', 'waiting', 'approved', 'dispatching', 'succeeded', 'failed', 'blocked', 'unknown', 'skipped']);
|
|
12
|
+
const waitStatuses = new Set(['pending', 'waiting', 'succeeded', 'failed', 'skipped']);
|
|
13
|
+
// Only this decoder's successfully validated, detached and recursively frozen results qualify.
|
|
14
|
+
// Weak ownership does not retain manifests or cache mutable adapter state between database loads.
|
|
15
|
+
const ownedManifests = new WeakSet<object>();
|
|
16
|
+
function invalid(): never { throw new StorageError('INVALID_INPUT', 'Invalid bounded workflow graph metadata.'); }
|
|
17
|
+
function corrupt(): never { throw new StorageError('CONFLICT', 'Stored workflow graph failed integrity validation.'); }
|
|
18
|
+
function object(value: JsonValue | undefined): JsonObject {
|
|
19
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value)) invalid(); return value;
|
|
20
|
+
}
|
|
21
|
+
function fields(value: JsonObject, names: readonly string[]): void {
|
|
22
|
+
if (Object.keys(value).length !== names.length || names.some(name => !Object.hasOwn(value, name))) invalid();
|
|
23
|
+
}
|
|
24
|
+
function hash(value: unknown): string { if (typeof value !== 'string' || !/^[a-f0-9]{64}$/.test(value)) invalid(); return value; }
|
|
25
|
+
function integer(value: unknown, minimum = 0): number {
|
|
26
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < minimum) invalid(); return value;
|
|
27
|
+
}
|
|
28
|
+
function id(value: unknown): string { if (typeof value !== 'string' || !idPattern.test(value) || forbidden.has(value)) invalid(); return value; }
|
|
29
|
+
function same(a: unknown, b: unknown): boolean { return workflowHashMaterial('compare', a) === workflowHashMaterial('compare', b); }
|
|
30
|
+
function targets(value: unknown): readonly ExecutionRef[] {
|
|
31
|
+
const copy = jsonValue(value, { maxBytes: 65_536 });
|
|
32
|
+
if (!Array.isArray(copy) || copy.length < 1 || copy.length > 32) invalid();
|
|
33
|
+
const values = copy.map(executionRef);
|
|
34
|
+
if (new Set(values.map(item => item.runId)).size !== values.length || values.some(item => item.policyHash !== values[0]!.policyHash)) invalid();
|
|
35
|
+
return Object.freeze(values);
|
|
36
|
+
}
|
|
37
|
+
function binding(raw: JsonValue | undefined, ids: ReadonlySet<string>, wait = false): WorkflowBinding {
|
|
38
|
+
const value = object(raw);
|
|
39
|
+
if (value['kind'] === 'literal') { fields(value, ['kind', 'value']); if (wait) targets(value['value']); }
|
|
40
|
+
else if (value['kind'] === 'input' || (!wait && value['kind'] === 'step')) {
|
|
41
|
+
fields(value, value['kind'] === 'input' ? ['kind', 'path'] : ['kind', 'stepId', 'path']);
|
|
42
|
+
if (!Array.isArray(value['path']) || value['path'].length > 32 || value['path'].some(key => typeof key !== 'string' || forbidden.has(key))) invalid();
|
|
43
|
+
if (value['kind'] === 'step' && !ids.has(id(value['stepId']))) invalid();
|
|
44
|
+
} else invalid();
|
|
45
|
+
return value as unknown as WorkflowBinding;
|
|
46
|
+
}
|
|
47
|
+
/** Common tool/join graph validation is reused only for those nodes; waits keep their own exact codec. */
|
|
48
|
+
function commonManifest(definition: WorkflowGraphManifest): WorkflowManifest {
|
|
49
|
+
return { id: definition.id, version: definition.version, graph: definition.graph.map(node => node.kind === 'wait'
|
|
50
|
+
? { kind: 'join', id: node.id, dependsOn: node.dependsOn } : node), result: definition.result };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Decode an exact format-3 manifest without changing the legacy manifest validator or hash domain. */
|
|
54
|
+
export function workflowGraphManifest(value: unknown): WorkflowGraphManifest {
|
|
55
|
+
try {
|
|
56
|
+
if (value !== null && typeof value === 'object' && ownedManifests.has(value)) return value as WorkflowGraphManifest;
|
|
57
|
+
const copy = object(jsonValue(value)); fields(copy, ['format', 'id', 'version', 'graph', 'result']);
|
|
58
|
+
if (copy['format'] !== 3 || !Array.isArray(copy['graph']) || copy['graph'].length < 1 || copy['graph'].length > 128) invalid();
|
|
59
|
+
const graph = copy['graph'].map(object); const ids = new Set(graph.map(node => id(node['id'])));
|
|
60
|
+
if (ids.size !== graph.length) invalid();
|
|
61
|
+
for (const node of graph) if (node['kind'] === 'wait') {
|
|
62
|
+
fields(node, ['kind', 'id', 'dependsOn', 'targets']); binding(node['targets'], ids, true);
|
|
63
|
+
} else if (node['kind'] !== 'tool' && node['kind'] !== 'join') invalid();
|
|
64
|
+
const manifest = copy as unknown as WorkflowGraphManifest;
|
|
65
|
+
// The projection validates shared DAG/binding/tool rules only; it is never hashed, stored or executed.
|
|
66
|
+
workflowManifest(commonManifest(manifest));
|
|
67
|
+
const owned = freezeJson(copy) as unknown as WorkflowGraphManifest;
|
|
68
|
+
ownedManifests.add(owned); return owned;
|
|
69
|
+
} catch { return invalid(); }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Resolve every wait before parent creation. Bounds count edges, including reuse across separate waits. */
|
|
73
|
+
export function workflowGraphTargets(definition: WorkflowGraphManifest, input: unknown): Readonly<Record<string, readonly ExecutionRef[]>> {
|
|
74
|
+
try {
|
|
75
|
+
const manifest = workflowGraphManifest(definition); const admitted = jsonValue(input);
|
|
76
|
+
const result: Record<string, readonly ExecutionRef[]> = {}; let count = 0; let policy: string | undefined;
|
|
77
|
+
for (const node of manifest.graph) if (node.kind === 'wait') {
|
|
78
|
+
const values = targets(node.targets.kind === 'literal' ? node.targets.value : resolveWorkflowBinding(node.targets, admitted, {})); count += values.length;
|
|
79
|
+
policy ??= values[0]!.policyHash;
|
|
80
|
+
if (count > 128 || values.some(item => item.policyHash !== policy)) invalid();
|
|
81
|
+
result[node.id] = values;
|
|
82
|
+
}
|
|
83
|
+
return Object.freeze(result);
|
|
84
|
+
} catch { return invalid(); }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Resource names still apply exclusively to real tool nodes, never waits or joins. */
|
|
88
|
+
export function workflowGraphResources(value: unknown, definition: WorkflowGraphManifest): WorkflowResourcePlan {
|
|
89
|
+
try { return workflowResources(value, commonManifest(workflowGraphManifest(definition))); } catch { return invalid(); }
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function observations(value: JsonValue | undefined, runId?: string): readonly ExecutionCompletion[] {
|
|
93
|
+
if (!Array.isArray(value) || value.length < 1 || value.length > 32) invalid();
|
|
94
|
+
const items = value.map(executionCompletion);
|
|
95
|
+
if (new Set(items.map(item => item.reference.runId)).size !== items.length || items.some(item => item.reference.runId === runId)) invalid();
|
|
96
|
+
return items;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Fresh mutable state copy; wait effect fields and metadata observations have explicit independent rules. */
|
|
100
|
+
export function workflowGraphState(record: Pick<StoredRecord, 'id' | 'state'>): WorkflowGraphFormat3State {
|
|
101
|
+
try {
|
|
102
|
+
const idDescriptor = Object.getOwnPropertyDescriptor(record, 'id'); const stateDescriptor = Object.getOwnPropertyDescriptor(record, 'state');
|
|
103
|
+
if (!idDescriptor || !('value' in idDescriptor) || !stateDescriptor || !('value' in stateDescriptor)) corrupt();
|
|
104
|
+
const runId = hash(idDescriptor.value); const state = object(jsonValue(stateDescriptor.value));
|
|
105
|
+
fields(state, ['format', 'definition', 'policy', 'input', 'status', 'steps', 'maxCostMicros', 'spentMicros', 'reservedMicros', 'output']);
|
|
106
|
+
if (state['format'] !== 3 || !statuses.has(state['status'] as string)) corrupt();
|
|
107
|
+
hash(state['definition']); const policy = hash(state['policy']);
|
|
108
|
+
const maximum = integer(state['maxCostMicros']); const spent = integer(state['spentMicros']); const reservedTotal = integer(state['reservedMicros']);
|
|
109
|
+
const entries = Object.entries(object(state['steps'])); if (entries.length < 1 || entries.length > 128) corrupt();
|
|
110
|
+
let reserved = 0;
|
|
111
|
+
for (const [nodeId, raw] of entries) {
|
|
112
|
+
id(nodeId); const step = object(raw);
|
|
113
|
+
fields(step, ['kind', 'status', 'callId', 'output', 'receipt', 'approval', 'costReserved', 'candidateHash']);
|
|
114
|
+
if (!['tool', 'join', 'wait'].includes(step['kind'] as string) || !stepStatuses.has(step['status'] as string) || step['callId'] !== `step:${nodeId}`) corrupt();
|
|
115
|
+
const amount = integer(step['costReserved']); reserved = integer(reserved + amount);
|
|
116
|
+
if (step['candidateHash'] !== null) hash(step['candidateHash']);
|
|
117
|
+
if (step['approval'] !== null) {
|
|
118
|
+
const approval = object(step['approval']); fields(approval, ['digest', 'expiresAt', 'humanId']); hash(approval['digest']); integer(approval['expiresAt'], 1);
|
|
119
|
+
if (approval['humanId'] !== null && (typeof approval['humanId'] !== 'string' || approval['humanId'].length < 1 || approval['humanId'].length > 256)) corrupt();
|
|
120
|
+
}
|
|
121
|
+
if (step['status'] === 'approved' && (step['approval'] === null || !object(step['approval'])['humanId'])) corrupt();
|
|
122
|
+
if (step['receipt'] !== null) {
|
|
123
|
+
const receipt = mergeWorkflowReceipt(null, step['receipt'] as unknown as ExecutionReceipt); if (receipt.callId !== `${runId}/step:${nodeId}`) corrupt();
|
|
124
|
+
}
|
|
125
|
+
if (step['status'] !== 'succeeded' && step['output'] !== null) corrupt();
|
|
126
|
+
if (step['kind'] !== 'tool' && (step['receipt'] !== null || step['approval'] !== null || step['candidateHash'] !== null || amount !== 0)) corrupt();
|
|
127
|
+
if (step['kind'] === 'wait') {
|
|
128
|
+
if (!waitStatuses.has(step['status'] as string)) corrupt();
|
|
129
|
+
if (['cancelled', 'failed', 'blocked', 'outcome_unknown'].includes(state['status'] as string)
|
|
130
|
+
&& ['pending', 'waiting'].includes(step['status'] as string)) corrupt();
|
|
131
|
+
}
|
|
132
|
+
if (step['status'] === 'succeeded') {
|
|
133
|
+
if (amount !== 0) corrupt();
|
|
134
|
+
if (step['kind'] === 'tool' && (step['receipt'] === null || object(step['receipt'])['execution'] !== 'succeeded'
|
|
135
|
+
|| object(step['receipt'])['disclosure'] !== 'released' || step['candidateHash'] === null)) corrupt();
|
|
136
|
+
if (step['kind'] === 'wait' && observations(step['output'], runId).some(item => item.reference.policyHash !== policy)) corrupt();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (reserved !== reservedTotal || spent > maximum - reservedTotal) corrupt();
|
|
140
|
+
if (state['status'] === 'succeeded' && entries.some(([, raw]) => object(raw)['status'] !== 'succeeded')) corrupt();
|
|
141
|
+
if (state['status'] !== 'succeeded' && state['output'] !== null) corrupt();
|
|
142
|
+
return state as unknown as WorkflowGraphFormat3State;
|
|
143
|
+
} catch { return corrupt(); }
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Definition/target checks supplement structural decoding; SQL separately proves immutable completion facts. */
|
|
147
|
+
export function assertWorkflowGraphStateMatchesManifest(state: WorkflowGraphFormat3State, definition: WorkflowGraphManifest): void {
|
|
148
|
+
try {
|
|
149
|
+
const manifest = workflowGraphManifest(definition); const value = object(jsonValue(state));
|
|
150
|
+
if (value['format'] !== 3) corrupt();
|
|
151
|
+
const steps = object(value['steps']); const pinned = workflowGraphTargets(manifest, value['input']);
|
|
152
|
+
if (Object.keys(steps).length !== manifest.graph.length || Object.values(pinned).flat().some(item => item.policyHash !== value['policy'])) corrupt();
|
|
153
|
+
for (const node of manifest.graph) {
|
|
154
|
+
const step = object(steps[node.id]); if (step['kind'] !== node.kind) corrupt();
|
|
155
|
+
const activated = step['status'] === 'succeeded' || (node.kind === 'wait' && ['waiting', 'failed'].includes(step['status'] as string));
|
|
156
|
+
if (activated && node.dependsOn.some(dependency => object(steps[dependency])['status'] !== 'succeeded')) corrupt();
|
|
157
|
+
if (node.kind === 'tool') {
|
|
158
|
+
if (step['receipt'] !== null && object(step['receipt'])['toolId'] !== node.tool) corrupt();
|
|
159
|
+
const amount = integer(step['costReserved']);
|
|
160
|
+
if ((step['approval'] !== null && !node.approval) || amount > node.costMicros
|
|
161
|
+
|| (amount !== 0 && amount !== node.costMicros && step['status'] !== 'unknown')) corrupt();
|
|
162
|
+
if (node.approval && step['candidateHash'] !== null && (step['approval'] === null || object(step['approval'])['digest'] !== step['candidateHash'])) corrupt();
|
|
163
|
+
} else if (node.kind === 'wait' && step['status'] === 'succeeded') {
|
|
164
|
+
const output = observations(step['output']);
|
|
165
|
+
if (output.length !== pinned[node.id]!.length || output.some((item, index) => !same(item.reference, pinned[node.id]![index]))) corrupt();
|
|
166
|
+
} else if (node.kind === 'join' && step['status'] === 'succeeded'
|
|
167
|
+
&& !same(step['output'], node.dependsOn.map(dependency => object(steps[dependency])['output']))) corrupt();
|
|
168
|
+
}
|
|
169
|
+
} catch { return corrupt(); }
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Create only the new representation; resolved targets still require trusted storage admission. */
|
|
173
|
+
export function initialWorkflowGraphState(definition: WorkflowGraphManifest, input: JsonValue, definitionHash: string, policyHash: string, maxCostMicros: number): WorkflowGraphFormat3State {
|
|
174
|
+
try {
|
|
175
|
+
const manifest = workflowGraphManifest(definition); hash(definitionHash); hash(policyHash); integer(maxCostMicros);
|
|
176
|
+
const admitted = jsonValue(input); const pinned = workflowGraphTargets(manifest, admitted);
|
|
177
|
+
if (Object.values(pinned).flat().some(item => item.policyHash !== policyHash)) invalid();
|
|
178
|
+
return jsonValue({ format: 3, definition: definitionHash, policy: policyHash, input: admitted, status: 'running',
|
|
179
|
+
maxCostMicros, spentMicros: 0, reservedMicros: 0, output: null,
|
|
180
|
+
steps: Object.fromEntries(manifest.graph.map(node => [node.id, { kind: node.kind, status: 'pending', callId: `step:${node.id}`,
|
|
181
|
+
output: null, receipt: null, approval: null, costReserved: 0, candidateHash: null }])) }) as unknown as WorkflowGraphFormat3State;
|
|
182
|
+
} catch { return invalid(); }
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Project only released successful effects or validated control-node output, never pending metadata. */
|
|
186
|
+
export function workflowGraphOutputs(state: WorkflowGraphFormat3State): Record<string, JsonValue> {
|
|
187
|
+
try {
|
|
188
|
+
const value = object(jsonValue(state)); if (value['format'] !== 3) corrupt();
|
|
189
|
+
const result: Record<string, JsonValue> = {};
|
|
190
|
+
for (const [nodeId, raw] of Object.entries(object(value['steps']))) {
|
|
191
|
+
id(nodeId); const step = object(raw); if (step['status'] !== 'succeeded') continue;
|
|
192
|
+
if (step['kind'] === 'tool') {
|
|
193
|
+
const receipt = mergeWorkflowReceipt(null, step['receipt'] as unknown as ExecutionReceipt); if (receipt.execution !== 'succeeded' || receipt.disclosure !== 'released') corrupt();
|
|
194
|
+
} else if (step['kind'] === 'wait') {
|
|
195
|
+
if (observations(step['output']).some(item => item.reference.policyHash !== value['policy'])) corrupt();
|
|
196
|
+
} else if (step['kind'] !== 'join') corrupt();
|
|
197
|
+
result[nodeId] = jsonValue(step['output']);
|
|
198
|
+
}
|
|
199
|
+
return result;
|
|
200
|
+
} catch { return corrupt(); }
|
|
201
|
+
}
|