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,148 @@
|
|
|
1
|
+
import { freezeJson, jsonValue, MayuraError } from '../../core/dist/index.js';
|
|
2
|
+
import { StorageError } from '../../storage-contracts/dist/index.js';
|
|
3
|
+
import { assertWorkflowTree, treeManifest } from './children-definition.js';
|
|
4
|
+
import { createWorkflowTreeDiscovery } from './children-discovery.js';
|
|
5
|
+
import { createWorkflowTreeRuntime } from './children-runtime.js';
|
|
6
|
+
import { digest } from './definition.js';
|
|
7
|
+
const methods = ['initialize', 'submit', 'inspect', 'requestRootApproval', 'approveRootTool', 'prepareRootTool', 'claimPreparedRootTool', 'renewClaimedRootTool', 'startClaimedRootTool', 'recordRootToolReceipt', 'completeRootTool', 'inspectChild', 'admitChild', 'requestChildApproval', 'approveChildTool', 'prepareChildTool', 'claimPreparedChildTool', 'renewClaimedChildTool', 'startClaimedChildTool', 'recordChildToolReceipt', 'completeChildTool', 'finalizeChild', 'joinChild', 'finalizeRoot', 'cancelChild', 'cancelRoot', 'recoverExpired'];
|
|
8
|
+
const codes = new Set(['INVALID_CONFIG', 'INVALID_INPUT', 'INVALID_OUTPUT', 'INVALID_JSON', 'PERMISSION_DENIED', 'BUDGET_EXCEEDED', 'LIMIT_EXCEEDED', 'CANCELLED', 'TIMEOUT', 'TOOL_FAILED', 'MODEL_FAILED', 'GUARD_BLOCKED', 'GUARD_UNAVAILABLE', 'OUTCOME_UNKNOWN', 'UNSUPPORTED_PROFILE', 'NOT_FOUND', 'CONFLICT', 'STORAGE_UNAVAILABLE']);
|
|
9
|
+
const statuses = new Set(['running', 'waiting', 'paused', 'succeeded', 'failed', 'blocked', 'cancelled', 'outcome_unknown']);
|
|
10
|
+
const invalid = () => new MayuraError('INVALID_CONFIG', 'Workflow-tree coordination requires a bounded genuine catalog and explicit worker policy.');
|
|
11
|
+
function fields(value, allowed, required = []) { if (!value || typeof value !== 'object' || ![Object.prototype, null].includes(Object.getPrototypeOf(value)))
|
|
12
|
+
throw invalid(); const result = Object.getOwnPropertyDescriptors(value); if (Reflect.ownKeys(result).some(key => typeof key !== 'string' || !allowed.includes(key)) || Object.values(result).some(field => !field.enumerable || !('value' in field)) || required.some(key => !Object.hasOwn(result, key)))
|
|
13
|
+
throw invalid(); return result; }
|
|
14
|
+
function member(value, name) { let current = value; for (let depth = 0; current && depth < 16; depth++, current = Object.getPrototypeOf(current)) {
|
|
15
|
+
const descriptor = Object.getOwnPropertyDescriptor(current, name);
|
|
16
|
+
if (descriptor) {
|
|
17
|
+
if (!('value' in descriptor))
|
|
18
|
+
throw invalid();
|
|
19
|
+
return descriptor.value;
|
|
20
|
+
}
|
|
21
|
+
} throw invalid(); }
|
|
22
|
+
function captured(source, names) { if (!source || typeof source !== 'object')
|
|
23
|
+
throw invalid(); return Object.freeze(Object.fromEntries(names.map(name => { const method = member(source, name); if (typeof method !== 'function')
|
|
24
|
+
throw invalid(); return [name, (...args) => Reflect.apply(method, source, args)]; }))); }
|
|
25
|
+
function captureStore(value) { try {
|
|
26
|
+
if (!value || typeof value !== 'object')
|
|
27
|
+
throw invalid();
|
|
28
|
+
return Object.freeze({ ...captured(value, ['events']), workflowTrees: captured(member(value, 'workflowTrees'), methods), workflowTreeDiscovery: captured(member(value, 'workflowTreeDiscovery'), ['initialize', 'scan']) });
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
throw new MayuraError('UNSUPPORTED_PROFILE', 'The adapter must provide workflow-tree execution and discovery.');
|
|
32
|
+
} }
|
|
33
|
+
function catalog(value) { if (!Array.isArray(value) || value.length < 1 || value.length > 32)
|
|
34
|
+
throw invalid(); const descriptors = Object.getOwnPropertyDescriptors(value); if (Reflect.ownKeys(descriptors).length !== value.length + 1 || Object.getOwnPropertySymbols(value).length)
|
|
35
|
+
throw invalid(); const seen = new Set(); let bytes = 0; return Object.freeze(Array.from({ length: value.length }, (_, index) => { const item = descriptors[String(index)]; if (!item || !item.enumerable || !('value' in item))
|
|
36
|
+
throw invalid(); const definition = item.value; assertWorkflowTree(definition); const manifest = treeManifest(definition); if (digest('mayura:workflow-tree:v1', manifest) !== definition.digest || seen.has(definition.digest))
|
|
37
|
+
throw invalid(); seen.add(definition.digest); bytes += new TextEncoder().encode(JSON.stringify(manifest)).length; if (bytes > 4_194_304)
|
|
38
|
+
throw invalid(); return definition; })); }
|
|
39
|
+
function safeCode(error) { try {
|
|
40
|
+
if (error instanceof MayuraError || error instanceof StorageError) {
|
|
41
|
+
const field = Object.getOwnPropertyDescriptor(error, 'code');
|
|
42
|
+
const code = field && 'value' in field ? field.value : undefined;
|
|
43
|
+
if (code === 'QUEUE_FULL')
|
|
44
|
+
return 'LIMIT_EXCEEDED';
|
|
45
|
+
if (typeof code === 'string' && codes.has(code))
|
|
46
|
+
return code;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch { /* Safe diagnostic boundary. */ } return 'STORAGE_UNAVAILABLE'; }
|
|
50
|
+
function report(value) { return freezeJson(jsonValue(value, { maxBytes: 65_536, maxNodes: 4_096, maxDepth: 12 })); }
|
|
51
|
+
/** Finite fleet page over explicitly registered genuine format-4 definitions. */
|
|
52
|
+
export function createWorkflowTreeCoordinator(options) {
|
|
53
|
+
let descriptors;
|
|
54
|
+
let definitions;
|
|
55
|
+
try {
|
|
56
|
+
descriptors = fields(options, ['store', 'definitions', 'scope', 'permissions', 'policyVersion', 'maxCostMicros', 'maxCalls', 'workerId', 'leaseMs', 'maxConcurrentJobs', 'maxOutputBytes', 'approvalTtlMs', 'storageTimeoutMs', 'maxPendingStorageOperations', 'hold'], ['store', 'definitions', 'scope', 'permissions', 'policyVersion', 'maxCostMicros', 'maxCalls', 'workerId']);
|
|
57
|
+
definitions = catalog(descriptors['definitions'].value);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
throw invalid();
|
|
61
|
+
}
|
|
62
|
+
const store = captureStore(descriptors['store'].value);
|
|
63
|
+
const shared = { store, scope: descriptors['scope'].value, permissions: descriptors['permissions'].value, policyVersion: descriptors['policyVersion'].value, maxCostMicros: descriptors['maxCostMicros'].value, maxCalls: descriptors['maxCalls'].value, workerId: descriptors['workerId'].value, ...(descriptors['leaseMs'] ? { leaseMs: descriptors['leaseMs'].value } : {}), ...(descriptors['maxConcurrentJobs'] ? { maxConcurrentJobs: descriptors['maxConcurrentJobs'].value } : {}), ...(descriptors['maxOutputBytes'] ? { maxOutputBytes: descriptors['maxOutputBytes'].value } : {}), ...(descriptors['approvalTtlMs'] ? { approvalTtlMs: descriptors['approvalTtlMs'].value } : {}), ...(descriptors['storageTimeoutMs'] ? { storageTimeoutMs: descriptors['storageTimeoutMs'].value } : {}) };
|
|
64
|
+
// The existing constructors perform the canonical policy and finite limit validation.
|
|
65
|
+
const hold = descriptors['hold']?.value;
|
|
66
|
+
if (hold !== undefined && (hold === null || typeof hold !== 'object' || typeof hold.isHeld !== 'function'))
|
|
67
|
+
throw invalid();
|
|
68
|
+
const runtime = createWorkflowTreeRuntime({ ...shared, maxConcurrentRuns: 1 });
|
|
69
|
+
const discovery = createWorkflowTreeDiscovery({ store, scope: shared.scope, permissions: shared.permissions, policyVersion: shared.policyVersion, maxCostMicros: shared.maxCostMicros, maxCalls: shared.maxCalls, ...(shared.maxOutputBytes === undefined ? {} : { maxOutputBytes: shared.maxOutputBytes }), ...(shared.approvalTtlMs === undefined ? {} : { approvalTtlMs: shared.approvalTtlMs }), ...(shared.storageTimeoutMs === undefined ? {} : { storageTimeoutMs: shared.storageTimeoutMs }), ...(descriptors['maxPendingStorageOperations'] ? { maxPendingStorageOperations: descriptors['maxPendingStorageOperations'].value } : {}) });
|
|
70
|
+
const registered = new Map(definitions.map(definition => [definition.digest, definition]));
|
|
71
|
+
let closed = false;
|
|
72
|
+
let active = false;
|
|
73
|
+
let closing;
|
|
74
|
+
return Object.freeze({ async runPage(command = {}) {
|
|
75
|
+
if (closed)
|
|
76
|
+
throw new MayuraError('CANCELLED', 'Workflow-tree coordinator is closed.');
|
|
77
|
+
if (active)
|
|
78
|
+
throw new MayuraError('LIMIT_EXCEEDED', 'The coordinator already has one active page.');
|
|
79
|
+
active = true;
|
|
80
|
+
try {
|
|
81
|
+
let admitted;
|
|
82
|
+
try {
|
|
83
|
+
admitted = freezeJson(jsonValue(command, { maxBytes: 1_024 }));
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
throw new MayuraError('INVALID_INPUT', 'Workflow-tree coordination requires exact bounded page fields.');
|
|
87
|
+
}
|
|
88
|
+
// Fail closed: an unconfirmed hold state drives nothing.
|
|
89
|
+
if (hold) {
|
|
90
|
+
let held;
|
|
91
|
+
try {
|
|
92
|
+
held = await hold.isHeld() === true;
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
throw new MayuraError('STORAGE_UNAVAILABLE', 'Workflow-tree coordination could not confirm the fleet hold.');
|
|
96
|
+
}
|
|
97
|
+
if (held)
|
|
98
|
+
return report({ status: 'interrupted', examined: 0, retryCursor: admitted.cursor ?? null, code: 'CANCELLED', outcomes: [] });
|
|
99
|
+
}
|
|
100
|
+
let page;
|
|
101
|
+
try {
|
|
102
|
+
page = await discovery.scan(admitted);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
throw closed ? new MayuraError('CANCELLED', 'Workflow-tree coordinator is closed.') : new MayuraError(safeCode(error), 'Workflow-tree coordination could not discover a valid page.');
|
|
106
|
+
}
|
|
107
|
+
const outcomes = [];
|
|
108
|
+
let stopped;
|
|
109
|
+
for (const candidate of page.candidates) {
|
|
110
|
+
if (closed || stopped) {
|
|
111
|
+
stopped ??= 'CANCELLED';
|
|
112
|
+
outcomes.push({ kind: 'not_attempted', rootId: candidate.rootId, definitionHash: candidate.definitionHash });
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (candidate.status === 'paused') {
|
|
116
|
+
outcomes.push({ kind: 'skipped', rootId: candidate.rootId, definitionHash: candidate.definitionHash, reason: 'paused' });
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const definition = registered.get(candidate.definitionHash);
|
|
120
|
+
if (!definition) {
|
|
121
|
+
outcomes.push({ kind: 'skipped', rootId: candidate.rootId, definitionHash: candidate.definitionHash, reason: 'unregistered_definition' });
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
const result = await runtime.runUntilSettled(definition, candidate.rootId);
|
|
126
|
+
if (result.id !== candidate.rootId || result.version < candidate.version || !statuses.has(result.status))
|
|
127
|
+
throw new MayuraError('STORAGE_UNAVAILABLE', 'Continuation returned inconsistent identity metadata.');
|
|
128
|
+
outcomes.push({ kind: 'observed', rootId: candidate.rootId, definitionHash: candidate.definitionHash, version: result.version, status: result.status });
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
stopped = closed ? 'CANCELLED' : safeCode(error);
|
|
132
|
+
outcomes.push({ kind: 'failed', rootId: candidate.rootId, definitionHash: candidate.definitionHash, code: stopped });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (closed)
|
|
136
|
+
stopped = 'CANCELLED';
|
|
137
|
+
return stopped ? report({ status: 'interrupted', examined: page.examined, retryCursor: admitted.cursor ?? null, code: stopped, outcomes }) : report({ status: 'completed', examined: page.examined, nextCursor: page.nextCursor, outcomes });
|
|
138
|
+
}
|
|
139
|
+
finally {
|
|
140
|
+
active = false;
|
|
141
|
+
}
|
|
142
|
+
}, close() { if (!closing) {
|
|
143
|
+
closed = true;
|
|
144
|
+
closing = Promise.allSettled([discovery.close(), runtime.close()]).then(() => { });
|
|
145
|
+
} return closing; },
|
|
146
|
+
async drain(options) { const report = await runtime.drain(options); closed = true; closing ??= Promise.allSettled([discovery.close()]).then(() => { }); await closing; return report; } });
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=children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K,CAAC,KAAK,CAAC,OAAO,IAAE,MAAM,MAAM,GAAC,MAAM,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA,MAAM,GAAC,IAAI,CAAC,CAAA,OAAO,KAAG,OAAO,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAE,EAAE,GAAC,CAAC,CAAC,CAAC,CAAA,MAAM,OAAO,CAAC,CAAA,OAAO,MAAM,CAAC,CAAA,CAAC,EAAmC,CAAC,CAAC;AAChN,CAAC","sourcesContent":["import { freezeJson,jsonValue,MayuraError,type ErrorCode } from '@mayura/core';\nimport type { WorkflowFleetHoldReader } from './fleet-control.js';\nimport { StorageError,type WorkflowTreeDiscoveryAggregateStore,type WorkflowTreeDiscoveryCursor } from '@mayura/storage-contracts';\nimport { assertWorkflowTree,treeManifest,type AnyWorkflowTree } from './children-definition.js';\nimport { createWorkflowTreeDiscovery } from './children-discovery.js';\nimport { createWorkflowTreeRuntime,type WorkflowTreeRuntimeOptions,type WorkflowTreeSnapshot } from './children-runtime.js';\nimport { digest } from './definition.js';\nimport type { WorkflowDrainOptions, WorkflowDrainReport } from './drain.js';\n\nexport interface WorkflowTreeCoordinatorOptions extends Omit<WorkflowTreeRuntimeOptions,'store'|'verifyHuman'|'maxConcurrentRuns'>{readonly store:WorkflowTreeDiscoveryAggregateStore;readonly definitions:readonly AnyWorkflowTree[];readonly maxPendingStorageOperations?:number;\n /** Durable fleet hold consulted before each page; while held nothing is discovered or driven. */\n readonly hold?:WorkflowFleetHoldReader;}\nexport type WorkflowTreeCandidateOutcome=\n |{readonly kind:'observed';readonly rootId:string;readonly definitionHash:string;readonly version:number;readonly status:WorkflowTreeSnapshot['status']}\n |{readonly kind:'skipped';readonly rootId:string;readonly definitionHash:string;readonly reason:'unregistered_definition'|'paused'}\n |{readonly kind:'failed';readonly rootId:string;readonly definitionHash:string;readonly code:ErrorCode}\n |{readonly kind:'not_attempted';readonly rootId:string;readonly definitionHash:string};\nexport type WorkflowTreePageReport=\n |{readonly status:'completed';readonly examined:number;readonly nextCursor:WorkflowTreeDiscoveryCursor|null;readonly outcomes:readonly WorkflowTreeCandidateOutcome[]}\n |{readonly status:'interrupted';readonly examined:number;readonly retryCursor:WorkflowTreeDiscoveryCursor|null;readonly code:ErrorCode;readonly outcomes:readonly WorkflowTreeCandidateOutcome[]};\nexport interface WorkflowTreeCoordinator{runPage(command?:{readonly cursor?:WorkflowTreeDiscoveryCursor|null;readonly limit?:number}):Promise<WorkflowTreePageReport>;close():Promise<void>;\n /** Admit no new wave, let admitted effects settle within the deadline, then close. */\n drain(options?:WorkflowDrainOptions):Promise<WorkflowDrainReport>;}\n\nconst methods=['initialize','submit','inspect','requestRootApproval','approveRootTool','prepareRootTool','claimPreparedRootTool','renewClaimedRootTool','startClaimedRootTool','recordRootToolReceipt','completeRootTool','inspectChild','admitChild','requestChildApproval','approveChildTool','prepareChildTool','claimPreparedChildTool','renewClaimedChildTool','startClaimedChildTool','recordChildToolReceipt','completeChildTool','finalizeChild','joinChild','finalizeRoot','cancelChild','cancelRoot','recoverExpired'] as const;\nconst codes=new Set<ErrorCode>(['INVALID_CONFIG','INVALID_INPUT','INVALID_OUTPUT','INVALID_JSON','PERMISSION_DENIED','BUDGET_EXCEEDED','LIMIT_EXCEEDED','CANCELLED','TIMEOUT','TOOL_FAILED','MODEL_FAILED','GUARD_BLOCKED','GUARD_UNAVAILABLE','OUTCOME_UNKNOWN','UNSUPPORTED_PROFILE','NOT_FOUND','CONFLICT','STORAGE_UNAVAILABLE']);\nconst statuses=new Set<WorkflowTreeSnapshot['status']>(['running','waiting','paused','succeeded','failed','blocked','cancelled','outcome_unknown']);\nconst invalid=()=>new MayuraError('INVALID_CONFIG','Workflow-tree coordination requires a bounded genuine catalog and explicit worker policy.');\nfunction fields(value:unknown,allowed:readonly string[],required:readonly string[]=[]):PropertyDescriptorMap{if(!value||typeof value!=='object'||![Object.prototype,null].includes(Object.getPrototypeOf(value)))throw invalid();const result=Object.getOwnPropertyDescriptors(value);if(Reflect.ownKeys(result).some(key=>typeof key!=='string'||!allowed.includes(key))||Object.values(result).some(field=>!field.enumerable||!('value'in field))||required.some(key=>!Object.hasOwn(result,key)))throw invalid();return result;}\nfunction member(value:object,name:string):unknown{let current:object|null=value;for(let depth=0;current&&depth<16;depth++,current=Object.getPrototypeOf(current) as object|null){const descriptor=Object.getOwnPropertyDescriptor(current,name);if(descriptor){if(!('value'in descriptor))throw invalid();return descriptor.value;}}throw invalid();}\nfunction captured(source:unknown,names:readonly string[]){if(!source||typeof source!=='object')throw invalid();return Object.freeze(Object.fromEntries(names.map(name=>{const method=member(source,name);if(typeof method!=='function')throw invalid();return[name,(...args:unknown[])=>Reflect.apply(method,source,args)];})));}\nfunction captureStore(value:unknown):WorkflowTreeDiscoveryAggregateStore{try{if(!value||typeof value!=='object')throw invalid();return Object.freeze({...captured(value,['events']),workflowTrees:captured(member(value,'workflowTrees'),methods),workflowTreeDiscovery:captured(member(value,'workflowTreeDiscovery'),['initialize','scan'])}) as unknown as WorkflowTreeDiscoveryAggregateStore;}catch{throw new MayuraError('UNSUPPORTED_PROFILE','The adapter must provide workflow-tree execution and discovery.');}}\nfunction catalog(value:unknown):readonly AnyWorkflowTree[]{if(!Array.isArray(value)||value.length<1||value.length>32)throw invalid();const descriptors=Object.getOwnPropertyDescriptors(value);if(Reflect.ownKeys(descriptors).length!==value.length+1||Object.getOwnPropertySymbols(value).length)throw invalid();const seen=new Set<string>();let bytes=0;return Object.freeze(Array.from({length:value.length},(_,index)=>{const item=descriptors[String(index)];if(!item||!item.enumerable||!('value'in item))throw invalid();const definition=item.value as AnyWorkflowTree;assertWorkflowTree(definition);const manifest=treeManifest(definition);if(digest('mayura:workflow-tree:v1',manifest)!==definition.digest||seen.has(definition.digest))throw invalid();seen.add(definition.digest);bytes+=new TextEncoder().encode(JSON.stringify(manifest)).length;if(bytes>4_194_304)throw invalid();return definition;}));}\nfunction safeCode(error:unknown):ErrorCode{try{if(error instanceof MayuraError||error instanceof StorageError){const field=Object.getOwnPropertyDescriptor(error,'code');const code:unknown=field&&'value'in field?field.value:undefined;if(code==='QUEUE_FULL')return'LIMIT_EXCEEDED';if(typeof code==='string'&&codes.has(code as ErrorCode))return code as ErrorCode;}}catch{/* Safe diagnostic boundary. */}return'STORAGE_UNAVAILABLE';}\nfunction report(value:WorkflowTreePageReport):WorkflowTreePageReport{return freezeJson(jsonValue(value,{maxBytes:65_536,maxNodes:4_096,maxDepth:12})) as unknown as WorkflowTreePageReport;}\n\n/** Finite fleet page over explicitly registered genuine format-4 definitions. */\nexport function createWorkflowTreeCoordinator(options:WorkflowTreeCoordinatorOptions):WorkflowTreeCoordinator{\n let descriptors:PropertyDescriptorMap;let definitions:readonly AnyWorkflowTree[];\n try{descriptors=fields(options,['store','definitions','scope','permissions','policyVersion','maxCostMicros','maxCalls','workerId','leaseMs','maxConcurrentJobs','maxOutputBytes','approvalTtlMs','storageTimeoutMs','maxPendingStorageOperations','hold'],['store','definitions','scope','permissions','policyVersion','maxCostMicros','maxCalls','workerId']);definitions=catalog(descriptors['definitions']!.value);}catch{throw invalid();}\n const store=captureStore(descriptors['store']!.value);const shared={store,scope:descriptors['scope']!.value as WorkflowTreeRuntimeOptions['scope'],permissions:descriptors['permissions']!.value as WorkflowTreeRuntimeOptions['permissions'],policyVersion:descriptors['policyVersion']!.value as string,maxCostMicros:descriptors['maxCostMicros']!.value as number,maxCalls:descriptors['maxCalls']!.value as number,workerId:descriptors['workerId']!.value as string,...(descriptors['leaseMs']?{leaseMs:descriptors['leaseMs'].value as number}:{}),...(descriptors['maxConcurrentJobs']?{maxConcurrentJobs:descriptors['maxConcurrentJobs'].value as number}:{}),...(descriptors['maxOutputBytes']?{maxOutputBytes:descriptors['maxOutputBytes'].value as number}:{}),...(descriptors['approvalTtlMs']?{approvalTtlMs:descriptors['approvalTtlMs'].value as number}:{}),...(descriptors['storageTimeoutMs']?{storageTimeoutMs:descriptors['storageTimeoutMs'].value as number}:{})};\n // The existing constructors perform the canonical policy and finite limit validation.\n const hold=descriptors['hold']?.value as WorkflowFleetHoldReader|undefined;if(hold!==undefined&&(hold===null||typeof hold!=='object'||typeof hold.isHeld!=='function'))throw invalid();\n const runtime=createWorkflowTreeRuntime({...shared,maxConcurrentRuns:1});const discovery=createWorkflowTreeDiscovery({store,scope:shared.scope,permissions:shared.permissions,policyVersion:shared.policyVersion,maxCostMicros:shared.maxCostMicros,maxCalls:shared.maxCalls,...(shared.maxOutputBytes===undefined?{}:{maxOutputBytes:shared.maxOutputBytes}),...(shared.approvalTtlMs===undefined?{}:{approvalTtlMs:shared.approvalTtlMs}),...(shared.storageTimeoutMs===undefined?{}:{storageTimeoutMs:shared.storageTimeoutMs}),...(descriptors['maxPendingStorageOperations']?{maxPendingStorageOperations:descriptors['maxPendingStorageOperations'].value as number}:{})});const registered=new Map(definitions.map(definition=>[definition.digest,definition]));let closed=false;let active=false;let closing:Promise<void>|undefined;\n return Object.freeze({async runPage(command={}){if(closed)throw new MayuraError('CANCELLED','Workflow-tree coordinator is closed.');if(active)throw new MayuraError('LIMIT_EXCEEDED','The coordinator already has one active page.');active=true;try{let admitted:{readonly cursor?:WorkflowTreeDiscoveryCursor|null;readonly limit?:number};try{admitted=freezeJson(jsonValue(command,{maxBytes:1_024})) as typeof admitted;}catch{throw new MayuraError('INVALID_INPUT','Workflow-tree coordination requires exact bounded page fields.');}\n // Fail closed: an unconfirmed hold state drives nothing.\n if(hold){let held:boolean;try{held=await hold.isHeld()===true;}catch{throw new MayuraError('STORAGE_UNAVAILABLE','Workflow-tree coordination could not confirm the fleet hold.');}if(held)return report({status:'interrupted',examined:0,retryCursor:admitted.cursor??null,code:'CANCELLED',outcomes:[]});}\n let page;try{page=await discovery.scan(admitted);}catch(error){throw closed?new MayuraError('CANCELLED','Workflow-tree coordinator is closed.'):new MayuraError(safeCode(error),'Workflow-tree coordination could not discover a valid page.');}const outcomes:WorkflowTreeCandidateOutcome[]=[];let stopped:ErrorCode|undefined;for(const candidate of page.candidates){if(closed||stopped){stopped??='CANCELLED';outcomes.push({kind:'not_attempted',rootId:candidate.rootId,definitionHash:candidate.definitionHash});continue;}if(candidate.status==='paused'){outcomes.push({kind:'skipped',rootId:candidate.rootId,definitionHash:candidate.definitionHash,reason:'paused'});continue;}const definition=registered.get(candidate.definitionHash);if(!definition){outcomes.push({kind:'skipped',rootId:candidate.rootId,definitionHash:candidate.definitionHash,reason:'unregistered_definition'});continue;}try{const result=await runtime.runUntilSettled(definition,candidate.rootId);if(result.id!==candidate.rootId||result.version<candidate.version||!statuses.has(result.status))throw new MayuraError('STORAGE_UNAVAILABLE','Continuation returned inconsistent identity metadata.');outcomes.push({kind:'observed',rootId:candidate.rootId,definitionHash:candidate.definitionHash,version:result.version,status:result.status});}catch(error){stopped=closed?'CANCELLED':safeCode(error);outcomes.push({kind:'failed',rootId:candidate.rootId,definitionHash:candidate.definitionHash,code:stopped});}}if(closed)stopped='CANCELLED';return stopped?report({status:'interrupted',examined:page.examined,retryCursor:admitted.cursor??null,code:stopped,outcomes}):report({status:'completed',examined:page.examined,nextCursor:page.nextCursor,outcomes});}finally{active=false;}},close(){if(!closing){closed=true;closing=Promise.allSettled([discovery.close(),runtime.close()]).then(()=>{});}return closing;},\n async drain(options){const report=await runtime.drain(options);closed=true;closing??=Promise.allSettled([discovery.close()]).then(()=>{});await closing;return report;}} satisfies WorkflowTreeCoordinator);\n}\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type InferInput, type InferOutput, type Schema } from '../../core/dist/index.js';
|
|
2
|
+
import { type WorkflowResourcePlan, type WorkflowTreeChildPolicy, type WorkflowTreeManifest } from '../../storage-contracts/dist/index.js';
|
|
3
|
+
import { type AnyWorkflow, type Binding, type WorkflowDefinition, type WorkflowNode } from './definition.js';
|
|
4
|
+
export interface WorkflowTreeChildNode {
|
|
5
|
+
readonly kind: 'child';
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly dependsOn?: readonly string[];
|
|
8
|
+
readonly workflow: AnyWorkflow;
|
|
9
|
+
readonly input: Binding;
|
|
10
|
+
readonly policy: WorkflowTreeChildPolicy;
|
|
11
|
+
readonly resources?: WorkflowResourcePlan;
|
|
12
|
+
}
|
|
13
|
+
export type WorkflowTreeNode = WorkflowNode | WorkflowTreeChildNode;
|
|
14
|
+
export interface WorkflowTreeOptions<I extends Schema, O extends Schema> {
|
|
15
|
+
readonly id: string;
|
|
16
|
+
readonly version: string;
|
|
17
|
+
readonly input: I;
|
|
18
|
+
readonly output: O;
|
|
19
|
+
readonly nodes: readonly WorkflowTreeNode[];
|
|
20
|
+
readonly result: Binding;
|
|
21
|
+
}
|
|
22
|
+
declare const workflowTreeBrand: unique symbol;
|
|
23
|
+
export interface WorkflowTreeDefinition<I extends Schema = Schema, O extends Schema = Schema> {
|
|
24
|
+
readonly [workflowTreeBrand]: true;
|
|
25
|
+
readonly format: 4;
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly version: string;
|
|
28
|
+
readonly digest: string;
|
|
29
|
+
readonly input: Schema<InferInput<I>, InferOutput<I>>;
|
|
30
|
+
readonly output: Schema<InferInput<O>, InferOutput<O>>;
|
|
31
|
+
readonly nodes: readonly WorkflowTreeNode[];
|
|
32
|
+
readonly result: Binding;
|
|
33
|
+
}
|
|
34
|
+
export type AnyWorkflowTree = WorkflowTreeDefinition;
|
|
35
|
+
export type WorkflowTreeOutput<D extends AnyWorkflowTree> = InferOutput<D['output']>;
|
|
36
|
+
export declare function assertWorkflowTree(definition: AnyWorkflowTree): void;
|
|
37
|
+
export declare function treeManifest(definition: Pick<AnyWorkflowTree, 'id' | 'version' | 'nodes' | 'result'>): WorkflowTreeManifest;
|
|
38
|
+
/** Define a finite root with required, one-level tool/join workflow children. */
|
|
39
|
+
export declare function defineWorkflowTree<I extends Schema, O extends Schema>(options: WorkflowTreeOptions<I, O>): WorkflowTreeDefinition<I, O>;
|
|
40
|
+
/** Leaf definitions remain genuine format-2 workflows, never structural or nested format-4 values. */
|
|
41
|
+
export type WorkflowTreeLeaf = WorkflowDefinition;
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=children-definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"children-definition.d.ts","sourceRoot":"","sources":["../src/children-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAEzG,OAAO,EAEkB,KAAK,oBAAoB,EAAE,KAAK,uBAAuB,EAAE,KAAK,oBAAoB,EAC1G,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACmB,KAAK,WAAW,EAAE,KAAK,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,YAAY,EACnG,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpF,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxD,QAAQ,CAAC,MAAM,EAAE,uBAAuB,CAAC;IAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,oBAAoB,CAAC;CACrF;AACD,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,qBAAqB,CAAC;AACpE,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,MAAM,EAAC,CAAC,SAAS,MAAM;IACpE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACrF,QAAQ,CAAC,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AM,EAAE,OAAO,EAAE,mBAAmB,CAAC,CAAC,EAAC,CAAC,CAAC,GAAG,sBAAsB,CAAC,CAAC,EAAC,CAAC,CAAC,CAsBpI;AAED,sGAAsG;AACtG,MAAM,MAAM,gBAAgB,GAAG,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { assertSchema, MayuraError } from '../../core/dist/index.js';
|
|
2
|
+
import { assertTool } from '../../tools/dist/index.js';
|
|
3
|
+
import { workflowManifest, workflowResources, workflowTreeManifest, } from '../../storage-contracts/dist/index.js';
|
|
4
|
+
import { assertWorkflow, digest, } from './definition.js';
|
|
5
|
+
const definitions = new WeakSet();
|
|
6
|
+
export function assertWorkflowTree(definition) {
|
|
7
|
+
if (!definitions.has(definition))
|
|
8
|
+
throw new MayuraError('INVALID_CONFIG', 'Use defineWorkflowTree from this package instance.');
|
|
9
|
+
}
|
|
10
|
+
function manifestFor(definition) {
|
|
11
|
+
assertWorkflow(definition);
|
|
12
|
+
const manifest = workflowManifest({ id: definition.id, version: definition.version,
|
|
13
|
+
graph: definition.nodes.map(node => node.kind === 'join'
|
|
14
|
+
? { kind: 'join', id: node.id, dependsOn: node.dependsOn }
|
|
15
|
+
: { kind: 'tool', id: node.id, dependsOn: node.dependsOn ?? [], tool: node.tool.id, toolVersion: node.tool.version,
|
|
16
|
+
effects: node.tool.effects, capabilities: node.tool.capabilities, costMicros: node.tool.costMicros,
|
|
17
|
+
approval: node.approval ?? false, input: node.input }), result: definition.result });
|
|
18
|
+
if (digest('mayura:workflow:v1', manifest) !== definition.digest)
|
|
19
|
+
throw new MayuraError('INVALID_CONFIG', 'Child workflow metadata does not match its genuine definition.');
|
|
20
|
+
return manifest;
|
|
21
|
+
}
|
|
22
|
+
export function treeManifest(definition) {
|
|
23
|
+
try {
|
|
24
|
+
return workflowTreeManifest({ format: 4, id: definition.id, version: definition.version,
|
|
25
|
+
graph: definition.nodes.map(node => node.kind === 'join'
|
|
26
|
+
? { kind: 'join', id: node.id, dependsOn: node.dependsOn }
|
|
27
|
+
: node.kind === 'tool'
|
|
28
|
+
? { kind: 'tool', id: node.id, dependsOn: node.dependsOn ?? [], tool: node.tool.id, toolVersion: node.tool.version,
|
|
29
|
+
effects: node.tool.effects, capabilities: node.tool.capabilities, costMicros: node.tool.costMicros,
|
|
30
|
+
approval: node.approval ?? false, input: node.input }
|
|
31
|
+
: { kind: 'child', id: node.id, dependsOn: node.dependsOn ?? [], workflow: manifestFor(node.workflow),
|
|
32
|
+
policy: node.policy, resources: workflowResources(node.resources ?? {}, manifestFor(node.workflow)), input: node.input }),
|
|
33
|
+
result: definition.result });
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
throw new MayuraError('INVALID_CONFIG', 'Workflow tree metadata is invalid or exceeds its finite bounds.');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** Define a finite root with required, one-level tool/join workflow children. */
|
|
40
|
+
export function defineWorkflowTree(options) {
|
|
41
|
+
if (!options || !Array.isArray(options.nodes))
|
|
42
|
+
throw new MayuraError('INVALID_CONFIG', 'Workflow tree options are required.');
|
|
43
|
+
assertSchema(options.input);
|
|
44
|
+
assertSchema(options.output);
|
|
45
|
+
const tools = new Map();
|
|
46
|
+
const children = new Map();
|
|
47
|
+
for (const node of options.nodes) {
|
|
48
|
+
if (node.kind === 'tool') {
|
|
49
|
+
assertTool(node.tool);
|
|
50
|
+
tools.set(node.id, node.tool);
|
|
51
|
+
}
|
|
52
|
+
else if (node.kind === 'child') {
|
|
53
|
+
assertWorkflow(node.workflow);
|
|
54
|
+
children.set(node.id, node.workflow);
|
|
55
|
+
}
|
|
56
|
+
else if (node.kind !== 'join')
|
|
57
|
+
throw new MayuraError('INVALID_CONFIG', 'Unknown workflow-tree node kind.');
|
|
58
|
+
}
|
|
59
|
+
const manifest = treeManifest(options);
|
|
60
|
+
const nodes = Object.freeze(manifest.graph.map(node => node.kind === 'tool'
|
|
61
|
+
? Object.freeze({ ...node, tool: tools.get(node.id) })
|
|
62
|
+
: node.kind === 'child'
|
|
63
|
+
? Object.freeze({ ...node, workflow: children.get(node.id) })
|
|
64
|
+
: node));
|
|
65
|
+
const snapshot = (schema) => {
|
|
66
|
+
const standard = schema['~standard'];
|
|
67
|
+
return Object.freeze({ '~standard': Object.freeze({ version: 1, vendor: standard.vendor, validate: standard.validate.bind(standard) }) });
|
|
68
|
+
};
|
|
69
|
+
const definition = Object.freeze({ format: 4, id: manifest.id, version: manifest.version,
|
|
70
|
+
digest: digest('mayura:workflow-tree:v1', manifest), input: snapshot(options.input), output: snapshot(options.output), nodes, result: manifest.result });
|
|
71
|
+
definitions.add(definition);
|
|
72
|
+
return definition;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=children-definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"children-definition.js","sourceRoot":"","sources":["../src/children-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAkD,MAAM,cAAc,CAAC;AACzG,OAAO,EAAE,UAAU,EAAgB,MAAM,eAAe,CAAC;AACzD,OAAO,EACL,gBAAgB,EAAE,iBAAiB,EAAE,oBAAoB,GAE1D,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,cAAc,EAAE,MAAM,GACvB,MAAM,iBAAiB,CAAC;AAoBzB,MAAM,WAAW,GAAG,IAAI,OAAO,EAAU,CAAC;AAE1C,MAAM,UAAU,kBAAkB,CAAC,UAA2B;IAC5D,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC;QAAE,MAAM,IAAI,WAAW,CAAC,gBAAgB,EAAC,oDAAoD,CAAC,CAAC;AACjI,CAAC;AAED,SAAS,WAAW,CAAC,UAAuB;IAC1C,cAAc,CAAC,UAAU,CAAC,CAAC;IAC3B,MAAM,QAAQ,GAAG,gBAAgB,CAAC,EAAE,EAAE,EAAC,UAAU,CAAC,EAAE,EAAC,OAAO,EAAC,UAAU,CAAC,OAAO;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,CAAC,EAAE,CAAE,EAAC,CAAC;QACnD,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO;YACrB,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAC,GAAG,IAAI,EAAC,QAAQ,EAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAE,EAAC,CAAC;YAC1D,CAAC,CAAC,IAAI,CAAC,CAAgC,CAAC;IAC5C,MAAM,QAAQ,GAAG,CAAmB,MAAQ,EAAwC,EAAE;QACpF,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;QACrC,OAAO,MAAM,CAAC,MAAM,CAAC,EAAC,WAAW,EAAC,MAAM,CAAC,MAAM,CAAC,EAAC,OAAO,EAAC,CAAU,EAAC,MAAM,EAAC,QAAQ,CAAC,MAAM,EAAC,QAAQ,EAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAC,CAAC,EAAC,CAAyC,CAAC;IACnL,CAAC,CAAC;IACF,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,EAAC,MAAM,EAAC,CAAU,EAAC,EAAE,EAAC,QAAQ,CAAC,EAAE,EAAC,OAAO,EAAC,QAAQ,CAAC,OAAO;QACzF,MAAM,EAAC,MAAM,CAAC,yBAAyB,EAAC,QAAQ,CAAC,EAAC,KAAK,EAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAC,MAAM,EAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,EAAC,KAAK,EAAC,MAAM,EAAC,QAAQ,CAAC,MAAM,EAAC,CAAgC,CAAC;IAChL,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAAC,OAAO,UAAU,CAAC;AACjD,CAAC","sourcesContent":["import { assertSchema, MayuraError, type InferInput, type InferOutput, type Schema } from '@mayura/core';\nimport { assertTool, type AnyTool } from '@mayura/tools';\nimport {\n workflowManifest, workflowResources, workflowTreeManifest,\n type WorkflowManifest, type WorkflowResourcePlan, type WorkflowTreeChildPolicy, type WorkflowTreeManifest,\n} from '@mayura/storage-contracts';\nimport {\n assertWorkflow, digest, type AnyWorkflow, type Binding, type WorkflowDefinition, type WorkflowNode,\n} from './definition.js';\n\nexport interface WorkflowTreeChildNode {\n readonly kind: 'child'; readonly id: string; readonly dependsOn?: readonly string[];\n readonly workflow: AnyWorkflow; readonly input: Binding;\n readonly policy: WorkflowTreeChildPolicy; readonly resources?: WorkflowResourcePlan;\n}\nexport type WorkflowTreeNode = WorkflowNode | WorkflowTreeChildNode;\nexport interface WorkflowTreeOptions<I extends Schema,O extends Schema> {\n readonly id: string; readonly version: string; readonly input: I; readonly output: O;\n readonly nodes: readonly WorkflowTreeNode[]; readonly result: Binding;\n}\ndeclare const workflowTreeBrand: unique symbol;\nexport interface WorkflowTreeDefinition<I extends Schema=Schema,O extends Schema=Schema> {\n readonly [workflowTreeBrand]: true; readonly format: 4; readonly id: string; readonly version: string; readonly digest: string;\n readonly input: Schema<InferInput<I>,InferOutput<I>>; readonly output: Schema<InferInput<O>,InferOutput<O>>;\n readonly nodes: readonly WorkflowTreeNode[]; readonly result: Binding;\n}\nexport type AnyWorkflowTree = WorkflowTreeDefinition;\nexport type WorkflowTreeOutput<D extends AnyWorkflowTree> = InferOutput<D['output']>;\nconst definitions = new WeakSet<object>();\n\nexport function assertWorkflowTree(definition: AnyWorkflowTree): void {\n if (!definitions.has(definition)) throw new MayuraError('INVALID_CONFIG','Use defineWorkflowTree from this package instance.');\n}\n\nfunction manifestFor(definition: AnyWorkflow): WorkflowManifest {\n assertWorkflow(definition);\n const manifest = workflowManifest({ id:definition.id,version:definition.version,\n graph:definition.nodes.map(node => node.kind === 'join'\n ? {kind:'join',id:node.id,dependsOn:node.dependsOn}\n : {kind:'tool',id:node.id,dependsOn:node.dependsOn ?? [],tool:node.tool.id,toolVersion:node.tool.version,\n effects:node.tool.effects,capabilities:node.tool.capabilities,costMicros:node.tool.costMicros,\n approval:node.approval ?? false,input:node.input}),result:definition.result });\n if (digest('mayura:workflow:v1',manifest) !== definition.digest) throw new MayuraError('INVALID_CONFIG','Child workflow metadata does not match its genuine definition.');\n return manifest;\n}\n\nexport function treeManifest(definition: Pick<AnyWorkflowTree,'id'|'version'|'nodes'|'result'>): WorkflowTreeManifest {\n try {\n return workflowTreeManifest({ format:4,id:definition.id,version:definition.version,\n graph:definition.nodes.map(node => node.kind === 'join'\n ? {kind:'join',id:node.id,dependsOn:node.dependsOn}\n : node.kind === 'tool'\n ? {kind:'tool',id:node.id,dependsOn:node.dependsOn ?? [],tool:node.tool.id,toolVersion:node.tool.version,\n effects:node.tool.effects,capabilities:node.tool.capabilities,costMicros:node.tool.costMicros,\n approval:node.approval ?? false,input:node.input}\n : {kind:'child',id:node.id,dependsOn:node.dependsOn ?? [],workflow:manifestFor(node.workflow),\n policy:node.policy,resources:workflowResources(node.resources ?? {},manifestFor(node.workflow)),input:node.input}),\n result:definition.result });\n } catch { throw new MayuraError('INVALID_CONFIG','Workflow tree metadata is invalid or exceeds its finite bounds.'); }\n}\n\n/** Define a finite root with required, one-level tool/join workflow children. */\nexport function defineWorkflowTree<I extends Schema,O extends Schema>(options: WorkflowTreeOptions<I,O>): WorkflowTreeDefinition<I,O> {\n if (!options || !Array.isArray(options.nodes)) throw new MayuraError('INVALID_CONFIG','Workflow tree options are required.');\n assertSchema(options.input); assertSchema(options.output);\n const tools = new Map<string,AnyTool>(); const children = new Map<string,AnyWorkflow>();\n for (const node of options.nodes) {\n if (node.kind === 'tool') { assertTool(node.tool); tools.set(node.id,node.tool); }\n else if (node.kind === 'child') { assertWorkflow(node.workflow); children.set(node.id,node.workflow); }\n else if (node.kind !== 'join') throw new MayuraError('INVALID_CONFIG','Unknown workflow-tree node kind.');\n }\n const manifest = treeManifest(options as unknown as Pick<AnyWorkflowTree,'id'|'version'|'nodes'|'result'>);\n const nodes = Object.freeze(manifest.graph.map(node => node.kind === 'tool'\n ? Object.freeze({...node,tool:tools.get(node.id)!})\n : node.kind === 'child'\n ? Object.freeze({...node,workflow:children.get(node.id)!})\n : node)) as readonly WorkflowTreeNode[];\n const snapshot = <S extends Schema>(schema:S): Schema<InferInput<S>,InferOutput<S>> => {\n const standard = schema['~standard'];\n return Object.freeze({'~standard':Object.freeze({version:1 as const,vendor:standard.vendor,validate:standard.validate.bind(standard)})}) as Schema<InferInput<S>,InferOutput<S>>;\n };\n const definition = Object.freeze({format:4 as const,id:manifest.id,version:manifest.version,\n digest:digest('mayura:workflow-tree:v1',manifest),input:snapshot(options.input),output:snapshot(options.output),nodes,result:manifest.result}) as WorkflowTreeDefinition<I,O>;\n definitions.add(definition); return definition;\n}\n\n/** Leaf definitions remain genuine format-2 workflows, never structural or nested format-4 values. */\nexport type WorkflowTreeLeaf = WorkflowDefinition;\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type WorkflowTreeDiscoveryAggregateStore, type WorkflowTreeDiscoveryCursor, type WorkflowTreeDiscoveryPage } from '../../storage-contracts/dist/index.js';
|
|
2
|
+
import type { WorkflowTreeRuntimeOptions } from './children-runtime.js';
|
|
3
|
+
export type { WorkflowTreeDiscoveryCandidate, WorkflowTreeDiscoveryCursor, WorkflowTreeDiscoveryPage } from '../../storage-contracts/dist/index.js';
|
|
4
|
+
export interface WorkflowTreeDiscoveryOptions extends Pick<WorkflowTreeRuntimeOptions, 'scope' | 'permissions' | 'policyVersion' | 'maxCostMicros' | 'maxCalls' | 'maxOutputBytes' | 'approvalTtlMs'> {
|
|
5
|
+
readonly store: WorkflowTreeDiscoveryAggregateStore;
|
|
6
|
+
readonly storageTimeoutMs?: number;
|
|
7
|
+
readonly maxPendingStorageOperations?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface WorkflowTreeDiscovery {
|
|
10
|
+
scan(command?: {
|
|
11
|
+
readonly cursor?: WorkflowTreeDiscoveryCursor | null;
|
|
12
|
+
readonly limit?: number;
|
|
13
|
+
}): Promise<WorkflowTreeDiscoveryPage>;
|
|
14
|
+
/** The cursor that continues a scan after `rootId`, for callers that persist only the last root id. */
|
|
15
|
+
cursorAfter(rootId: string): WorkflowTreeDiscoveryCursor;
|
|
16
|
+
close(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
/** Finite metadata-only discovery; returned roots are hints, never dispatch grants. */
|
|
19
|
+
export declare function createWorkflowTreeDiscovery(options: WorkflowTreeDiscoveryOptions): WorkflowTreeDiscovery;
|
|
20
|
+
//# sourceMappingURL=children-discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"children-discovery.d.ts","sourceRoot":"","sources":["../src/children-discovery.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,mCAAmC,EAAC,KAAK,2BAA2B,EAAC,KAAK,yBAAyB,EAEzG,MAAM,2BAA2B,CAAC;AAGnC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAExE,YAAY,EAAE,8BAA8B,EAAC,2BAA2B,EAAC,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtI,MAAM,WAAW,4BAA6B,SAAQ,IAAI,CAAC,0BAA0B,EAAC,OAAO,GAAC,aAAa,GAAC,eAAe,GAAC,eAAe,GAAC,UAAU,GAAC,gBAAgB,GAAC,eAAe,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAC,mCAAmC,CAAC;IAAA,QAAQ,CAAC,gBAAgB,CAAC,EAAC,MAAM,CAAC;IAAA,QAAQ,CAAC,2BAA2B,CAAC,EAAC,MAAM,CAAC;CAAC;AAC5T,MAAM,WAAW,qBAAqB;IAAC,IAAI,CAAC,OAAO,CAAC,EAAC;QAAC,QAAQ,CAAC,MAAM,CAAC,EAAC,2BAA2B,GAAC,IAAI,CAAC;QAAA,QAAQ,CAAC,KAAK,CAAC,EAAC,MAAM,CAAA;KAAC,GAAE,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAClK,uGAAuG;IACvG,WAAW,CAAC,MAAM,EAAC,MAAM,GAAE,2BAA2B,CAAC;IAAA,KAAK,IAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAAC;AAShF,uFAAuF;AACvF,wBAAgB,2BAA2B,CAAC,OAAO,EAAC,4BAA4B,GAAE,qBAAqB,CAOtG"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { jsonValue, MayuraError } from '../../core/dist/index.js';
|
|
2
|
+
import { StorageError, workflowTreeDiscoveryCommand, workflowTreeDiscoveryPage, workflowTreePolicy, } from '../../storage-contracts/dist/index.js';
|
|
3
|
+
import { digest } from './definition.js';
|
|
4
|
+
import { scheduledCallback } from './scheduled-helpers.js';
|
|
5
|
+
const invalid = () => new MayuraError('INVALID_INPUT', 'Workflow-tree discovery requires exact bounded fields and a cursor matching its configured scope and policy.');
|
|
6
|
+
function object(value) { if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
7
|
+
throw invalid(); return value; }
|
|
8
|
+
function positive(value, fallback, maximum) { const result = value === undefined ? fallback : value; if (typeof result !== 'number' || !Number.isSafeInteger(result) || result < 1 || result > maximum)
|
|
9
|
+
throw invalid(); return result; }
|
|
10
|
+
function member(value, name) { let current = value; for (let depth = 0; current && depth < 16; depth++, current = Object.getPrototypeOf(current)) {
|
|
11
|
+
const field = Object.getOwnPropertyDescriptor(current, name);
|
|
12
|
+
if (field) {
|
|
13
|
+
if (!('value' in field))
|
|
14
|
+
throw invalid();
|
|
15
|
+
return field.value;
|
|
16
|
+
}
|
|
17
|
+
} throw invalid(); }
|
|
18
|
+
function adapter(store) { try {
|
|
19
|
+
if (!store || typeof store !== 'object')
|
|
20
|
+
throw invalid();
|
|
21
|
+
const source = member(store, 'workflowTreeDiscovery');
|
|
22
|
+
if (!source || typeof source !== 'object')
|
|
23
|
+
throw invalid();
|
|
24
|
+
const captured = {};
|
|
25
|
+
for (const name of ['initialize', 'scan']) {
|
|
26
|
+
const method = member(source, name);
|
|
27
|
+
if (typeof method !== 'function')
|
|
28
|
+
throw invalid();
|
|
29
|
+
captured[name] = (...args) => Reflect.apply(method, source, args);
|
|
30
|
+
}
|
|
31
|
+
return Object.freeze(captured);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
throw new MayuraError('UNSUPPORTED_PROFILE', 'This adapter does not provide workflow-tree discovery.');
|
|
35
|
+
} }
|
|
36
|
+
function storageFailure(error) { let code = 'STORAGE_UNAVAILABLE'; try {
|
|
37
|
+
const field = error instanceof StorageError ? Object.getOwnPropertyDescriptor(error, 'code') : undefined;
|
|
38
|
+
const value = field && 'value' in field ? field.value : undefined;
|
|
39
|
+
if (value === 'QUEUE_FULL')
|
|
40
|
+
code = 'LIMIT_EXCEEDED';
|
|
41
|
+
else if (['INVALID_INPUT', 'CONFLICT', 'NOT_FOUND', 'LIMIT_EXCEEDED'].includes(value))
|
|
42
|
+
code = value;
|
|
43
|
+
}
|
|
44
|
+
catch { /* Sanitized boundary. */ } return new MayuraError(code, 'Workflow-tree discovery could not confirm a valid observation page.'); }
|
|
45
|
+
/** Finite metadata-only discovery; returned roots are hints, never dispatch grants. */
|
|
46
|
+
export function createWorkflowTreeDiscovery(options) {
|
|
47
|
+
let fields;
|
|
48
|
+
let policy;
|
|
49
|
+
let timeoutMs;
|
|
50
|
+
let maxPending;
|
|
51
|
+
try {
|
|
52
|
+
if (!options || typeof options !== 'object' || ![Object.prototype, null].includes(Object.getPrototypeOf(options)))
|
|
53
|
+
throw invalid();
|
|
54
|
+
fields = Object.getOwnPropertyDescriptors(options);
|
|
55
|
+
const allowed = ['store', 'scope', 'permissions', 'policyVersion', 'maxCostMicros', 'maxCalls', 'maxOutputBytes', 'approvalTtlMs', 'storageTimeoutMs', 'maxPendingStorageOperations'];
|
|
56
|
+
if (Reflect.ownKeys(fields).some(name => typeof name !== 'string' || !allowed.includes(name)) || Object.values(fields).some(field => !field.enumerable || !('value' in field)))
|
|
57
|
+
throw invalid();
|
|
58
|
+
const raw = object(jsonValue({ scope: fields['scope']?.value, permissions: fields['permissions']?.value, policyVersion: fields['policyVersion']?.value, maxCostMicros: fields['maxCostMicros']?.value, maxCalls: fields['maxCalls']?.value, maxOutputBytes: fields['maxOutputBytes']?.value ?? 65_536, approvalTtlMs: fields['approvalTtlMs']?.value ?? 3_600_000 }));
|
|
59
|
+
const permissions = object(raw['permissions']);
|
|
60
|
+
if (Object.keys(permissions).length !== 1 || !Object.hasOwn(permissions, 'allow'))
|
|
61
|
+
throw invalid();
|
|
62
|
+
policy = workflowTreePolicy({ ...raw, permissions: permissions['allow'] });
|
|
63
|
+
timeoutMs = positive(fields['storageTimeoutMs']?.value, 10_000, 30_000);
|
|
64
|
+
maxPending = positive(fields['maxPendingStorageOperations']?.value, 64, 1_024);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
throw new MayuraError('INVALID_CONFIG', 'Workflow-tree discovery requires explicit tree policy and finite callback limits.');
|
|
68
|
+
}
|
|
69
|
+
const api = adapter(fields['store']?.value);
|
|
70
|
+
const scope = digest('mayura:scope:v1', policy.scope);
|
|
71
|
+
const policyHash = digest('mayura:workflow-tree-policy:v1', policy);
|
|
72
|
+
const shutdown = new AbortController();
|
|
73
|
+
let pending = 0;
|
|
74
|
+
let initialized;
|
|
75
|
+
const open = () => { if (shutdown.signal.aborted)
|
|
76
|
+
throw new MayuraError('CANCELLED', 'Workflow-tree discovery is closed.'); };
|
|
77
|
+
const call = async (operation) => { open(); if (pending >= maxPending)
|
|
78
|
+
throw new MayuraError('LIMIT_EXCEEDED', 'Workflow-tree discovery callback capacity is occupied.'); pending++; const actual = Promise.resolve().then(() => { open(); return operation(); }).finally(() => { pending--; }); void actual.catch(() => { }); try {
|
|
79
|
+
return await scheduledCallback(() => actual, timeoutMs, shutdown.signal);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
open();
|
|
83
|
+
throw storageFailure(error);
|
|
84
|
+
} };
|
|
85
|
+
const initialize = async () => { open(); initialized ??= (async () => { if (await call(() => api.initialize()) !== undefined)
|
|
86
|
+
throw new MayuraError('STORAGE_UNAVAILABLE', 'Invalid discovery initialization response.'); open(); })().catch(error => { initialized = undefined; throw error; }); await initialized; open(); };
|
|
87
|
+
return Object.freeze({ cursorAfter(rootId) { if (typeof rootId !== 'string' || !/^[a-f0-9]{64}$/.test(rootId))
|
|
88
|
+
throw invalid(); return Object.freeze({ format: 1, scope, policyHash, afterId: rootId }); }, async scan(command = {}) { open(); let admitted; try {
|
|
89
|
+
const raw = object(jsonValue(command, { maxBytes: 1_024 }));
|
|
90
|
+
if (Object.keys(raw).some(name => name !== 'cursor' && name !== 'limit'))
|
|
91
|
+
throw invalid();
|
|
92
|
+
admitted = workflowTreeDiscoveryCommand('scan', { scope, policyHash, cursor: Object.hasOwn(raw, 'cursor') ? raw['cursor'] : null, limit: Object.hasOwn(raw, 'limit') ? raw['limit'] : 16 });
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
throw invalid();
|
|
96
|
+
} await initialize(); const raw = await call(() => api.scan(admitted)); open(); try {
|
|
97
|
+
return workflowTreeDiscoveryPage(raw, admitted);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
throw new MayuraError('STORAGE_UNAVAILABLE', 'Workflow-tree discovery returned an invalid page.');
|
|
101
|
+
} }, async close() { shutdown.abort(); } });
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=children-discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"children-discovery.js","sourceRoot":"","sources":["../src/children-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAC,WAAW,EAAgD,MAAM,cAAc,CAAC;AACnG,OAAO,EACL,YAAY,EAAC,4BAA4B,EAAC,yBAAyB,EAAC,kBAAkB,GAGvF,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAS3D,MAAM,OAAO,GAAC,GAAE,EAA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,CAAC,CAAA,GAAG,CAAC,QAAQ,CAAC,CAAA,CAAC,CAAA,IAAI,EAAC,KAAK,EAAC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAC,OAAO,CAAC,CAAA,CAAC,CAAA,GAAG,CAAC,OAAO,CAAC,CAAA,CAAC,CAAA,EAAE,EAAC,CAAyC,CAAC;QAAA,CAAC;QAAA,MAAK,CAAC;YAAA,MAAM,OAAO,EAAE,CAAC;QAAA,CAAC,CAAA,MAAM,UAAU,EAAE,CAAC,CAAA,MAAM,GAAG,GAAC,MAAM,IAAI,CAAC,GAAE,EAAE,CAAA,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA,IAAI,EAAE,CAAC,CAAA,IAAG,CAAC;YAAA,OAAO,yBAAyB,CAAC,GAAG,EAAC,QAAQ,CAAC,CAAC;QAAA,CAAC;QAAA,MAAK,CAAC;YAAA,MAAM,IAAI,WAAW,CAAC,qBAAqB,EAAC,mDAAmD,CAAC,CAAC;QAAA,CAAC,CAAA,CAAC,EAAC,KAAK,CAAC,KAAK,KAAG,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA,CAAC,EAAiC,CAAC,CAAC;AAC59B,CAAC","sourcesContent":["import { jsonValue,MayuraError,type ErrorCode,type JsonObject,type JsonValue } from '@mayura/core';\nimport {\n StorageError,workflowTreeDiscoveryCommand,workflowTreeDiscoveryPage,workflowTreePolicy,\n type WorkflowTreeDiscoveryAggregateStore,type WorkflowTreeDiscoveryCursor,type WorkflowTreeDiscoveryPage,\n type WorkflowTreeDiscoveryScan,type WorkflowTreeDiscoveryStore,\n} from '@mayura/storage-contracts';\nimport { digest } from './definition.js';\nimport { scheduledCallback } from './scheduled-helpers.js';\nimport type { WorkflowTreeRuntimeOptions } from './children-runtime.js';\n\nexport type { WorkflowTreeDiscoveryCandidate,WorkflowTreeDiscoveryCursor,WorkflowTreeDiscoveryPage } from '@mayura/storage-contracts';\nexport interface WorkflowTreeDiscoveryOptions extends Pick<WorkflowTreeRuntimeOptions,'scope'|'permissions'|'policyVersion'|'maxCostMicros'|'maxCalls'|'maxOutputBytes'|'approvalTtlMs'>{readonly store:WorkflowTreeDiscoveryAggregateStore;readonly storageTimeoutMs?:number;readonly maxPendingStorageOperations?:number;}\nexport interface WorkflowTreeDiscovery{scan(command?:{readonly cursor?:WorkflowTreeDiscoveryCursor|null;readonly limit?:number}):Promise<WorkflowTreeDiscoveryPage>;\n /** The cursor that continues a scan after `rootId`, for callers that persist only the last root id. */\n cursorAfter(rootId:string):WorkflowTreeDiscoveryCursor;close():Promise<void>;}\n\nconst invalid=()=>new MayuraError('INVALID_INPUT','Workflow-tree discovery requires exact bounded fields and a cursor matching its configured scope and policy.');\nfunction object(value:JsonValue):JsonObject{if(!value||typeof value!=='object'||Array.isArray(value))throw invalid();return value;}\nfunction positive(value:unknown,fallback:number,maximum:number):number{const result=value===undefined?fallback:value;if(typeof result!=='number'||!Number.isSafeInteger(result)||result<1||result>maximum)throw invalid();return result;}\nfunction member(value:object,name:string):unknown{let current:object|null=value;for(let depth=0;current&&depth<16;depth++,current=Object.getPrototypeOf(current) as object|null){const field=Object.getOwnPropertyDescriptor(current,name);if(field){if(!('value'in field))throw invalid();return field.value;}}throw invalid();}\nfunction adapter(store:unknown):WorkflowTreeDiscoveryStore{try{if(!store||typeof store!=='object')throw invalid();const source=member(store,'workflowTreeDiscovery');if(!source||typeof source!=='object')throw invalid();const captured:Record<string,(...args:unknown[])=>unknown>={};for(const name of ['initialize','scan'] as const){const method=member(source,name);if(typeof method!=='function')throw invalid();captured[name]=(...args)=>Reflect.apply(method,source,args);}return Object.freeze(captured) as unknown as WorkflowTreeDiscoveryStore;}catch{throw new MayuraError('UNSUPPORTED_PROFILE','This adapter does not provide workflow-tree discovery.');}}\nfunction storageFailure(error:unknown):MayuraError{let code:ErrorCode='STORAGE_UNAVAILABLE';try{const field=error instanceof StorageError?Object.getOwnPropertyDescriptor(error,'code'):undefined;const value:unknown=field&&'value'in field?field.value:undefined;if(value==='QUEUE_FULL')code='LIMIT_EXCEEDED';else if(['INVALID_INPUT','CONFLICT','NOT_FOUND','LIMIT_EXCEEDED'].includes(value as string))code=value as ErrorCode;}catch{/* Sanitized boundary. */}return new MayuraError(code,'Workflow-tree discovery could not confirm a valid observation page.');}\n\n/** Finite metadata-only discovery; returned roots are hints, never dispatch grants. */\nexport function createWorkflowTreeDiscovery(options:WorkflowTreeDiscoveryOptions):WorkflowTreeDiscovery{\n let fields:PropertyDescriptorMap;let policy:ReturnType<typeof workflowTreePolicy>;let timeoutMs:number;let maxPending:number;\n try{if(!options||typeof options!=='object'||![Object.prototype,null].includes(Object.getPrototypeOf(options)))throw invalid();fields=Object.getOwnPropertyDescriptors(options);const allowed=['store','scope','permissions','policyVersion','maxCostMicros','maxCalls','maxOutputBytes','approvalTtlMs','storageTimeoutMs','maxPendingStorageOperations'];if(Reflect.ownKeys(fields).some(name=>typeof name!=='string'||!allowed.includes(name))||Object.values(fields).some(field=>!field.enumerable||!('value'in field)))throw invalid();const raw=object(jsonValue({scope:fields['scope']?.value,permissions:fields['permissions']?.value,policyVersion:fields['policyVersion']?.value,maxCostMicros:fields['maxCostMicros']?.value,maxCalls:fields['maxCalls']?.value,maxOutputBytes:fields['maxOutputBytes']?.value??65_536,approvalTtlMs:fields['approvalTtlMs']?.value??3_600_000}));const permissions=object(raw['permissions']!);if(Object.keys(permissions).length!==1||!Object.hasOwn(permissions,'allow'))throw invalid();policy=workflowTreePolicy({...raw,permissions:permissions['allow']});timeoutMs=positive(fields['storageTimeoutMs']?.value,10_000,30_000);maxPending=positive(fields['maxPendingStorageOperations']?.value,64,1_024);}catch{throw new MayuraError('INVALID_CONFIG','Workflow-tree discovery requires explicit tree policy and finite callback limits.');}\n const api=adapter(fields['store']?.value);const scope=digest('mayura:scope:v1',policy.scope);const policyHash=digest('mayura:workflow-tree-policy:v1',policy);const shutdown=new AbortController();let pending=0;let initialized:Promise<void>|undefined;const open=()=>{if(shutdown.signal.aborted)throw new MayuraError('CANCELLED','Workflow-tree discovery is closed.');};\n const call=async<T>(operation:()=>Promise<T>):Promise<T>=>{open();if(pending>=maxPending)throw new MayuraError('LIMIT_EXCEEDED','Workflow-tree discovery callback capacity is occupied.');pending++;const actual=Promise.resolve().then(()=>{open();return operation();}).finally(()=>{pending--;});void actual.catch(()=>{});try{return await scheduledCallback(()=>actual,timeoutMs,shutdown.signal);}catch(error){open();throw storageFailure(error);}};\n const initialize=async()=>{open();initialized??=(async()=>{if(await call(()=>api.initialize())!==undefined)throw new MayuraError('STORAGE_UNAVAILABLE','Invalid discovery initialization response.');open();})().catch(error=>{initialized=undefined;throw error;});await initialized;open();};\n return Object.freeze({cursorAfter(rootId:string):WorkflowTreeDiscoveryCursor{if(typeof rootId!=='string'||!/^[a-f0-9]{64}$/.test(rootId))throw invalid();return Object.freeze({format:1,scope,policyHash,afterId:rootId}) as WorkflowTreeDiscoveryCursor;},async scan(command={}){open();let admitted:WorkflowTreeDiscoveryScan;try{const raw=object(jsonValue(command,{maxBytes:1_024}));if(Object.keys(raw).some(name=>name!=='cursor'&&name!=='limit'))throw invalid();admitted=workflowTreeDiscoveryCommand('scan',{scope,policyHash,cursor:Object.hasOwn(raw,'cursor')?raw['cursor']:null,limit:Object.hasOwn(raw,'limit')?raw['limit']:16}) as unknown as WorkflowTreeDiscoveryScan;}catch{throw invalid();}await initialize();const raw=await call(()=>api.scan(admitted));open();try{return workflowTreeDiscoveryPage(raw,admitted);}catch{throw new MayuraError('STORAGE_UNAVAILABLE','Workflow-tree discovery returned an invalid page.');}},async close(){shutdown.abort();}} satisfies WorkflowTreeDiscovery);\n}\n"]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { type InferInput, type JsonValue, type Permissions, type Schema, type Scope } from '../../core/dist/index.js';
|
|
2
|
+
import { type WorkflowDrainOptions, type WorkflowDrainReport } from './drain.js';
|
|
3
|
+
import { workflowTreeState, type WorkflowTreeAggregateStore, type WorkflowTreeRootSnapshot as StoredTreeSnapshot } from '../../storage-contracts/dist/index.js';
|
|
4
|
+
import { type MigrationCommand, type WorkflowMigration, type WorkflowMigrationResult } from './migration.js';
|
|
5
|
+
import { type AnyWorkflowTree, type WorkflowTreeDefinition } from './children-definition.js';
|
|
6
|
+
import type { VerifiedHuman } from './runtime.js';
|
|
7
|
+
export interface WorkflowTreeRuntimeOptions {
|
|
8
|
+
readonly store: WorkflowTreeAggregateStore;
|
|
9
|
+
readonly scope: Scope;
|
|
10
|
+
readonly permissions: Permissions;
|
|
11
|
+
readonly policyVersion: string;
|
|
12
|
+
readonly maxCostMicros: number;
|
|
13
|
+
readonly maxCalls: number;
|
|
14
|
+
readonly workerId: string;
|
|
15
|
+
readonly leaseMs?: number;
|
|
16
|
+
readonly maxConcurrentJobs?: number;
|
|
17
|
+
readonly maxConcurrentRuns?: number;
|
|
18
|
+
readonly maxOutputBytes?: number;
|
|
19
|
+
readonly approvalTtlMs?: number;
|
|
20
|
+
readonly storageTimeoutMs?: number;
|
|
21
|
+
readonly verifyHuman?: (credential: unknown) => Promise<VerifiedHuman>;
|
|
22
|
+
}
|
|
23
|
+
export interface WorkflowTreeSnapshot {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly version: number;
|
|
26
|
+
readonly status: ReturnType<typeof workflowTreeState>['status'];
|
|
27
|
+
readonly steps: ReturnType<typeof workflowTreeState>['steps'];
|
|
28
|
+
readonly output: JsonValue;
|
|
29
|
+
readonly budget: StoredTreeSnapshot['budget'];
|
|
30
|
+
}
|
|
31
|
+
export interface WorkflowTreeChildSnapshot {
|
|
32
|
+
readonly id: string;
|
|
33
|
+
readonly version: number;
|
|
34
|
+
readonly status: ReturnType<typeof workflowTreeState>['status'];
|
|
35
|
+
readonly steps: ReturnType<typeof workflowTreeState>['steps'];
|
|
36
|
+
readonly output: JsonValue;
|
|
37
|
+
}
|
|
38
|
+
export interface WorkflowTreeRuntime {
|
|
39
|
+
readonly profile: 'scheduled-v3';
|
|
40
|
+
submit<I extends Schema, O extends Schema>(definition: WorkflowTreeDefinition<I, O>, command: {
|
|
41
|
+
readonly input: InferInput<I>;
|
|
42
|
+
readonly idempotencyKey: string;
|
|
43
|
+
}): Promise<WorkflowTreeSnapshot>;
|
|
44
|
+
inspect(id: string): Promise<WorkflowTreeSnapshot>;
|
|
45
|
+
inspectChild(id: string, childId: string): Promise<WorkflowTreeChildSnapshot>;
|
|
46
|
+
runUntilSettled(definition: AnyWorkflowTree, id: string): Promise<WorkflowTreeSnapshot>;
|
|
47
|
+
approve(command: {
|
|
48
|
+
readonly id: string;
|
|
49
|
+
readonly childId?: string;
|
|
50
|
+
readonly nodeId: string;
|
|
51
|
+
readonly digest: string;
|
|
52
|
+
readonly credential: unknown;
|
|
53
|
+
}): Promise<WorkflowTreeSnapshot>;
|
|
54
|
+
cancel(id: string): Promise<WorkflowTreeSnapshot>;
|
|
55
|
+
/** Persist a tree-wide quiescent pause; claimed or in-flight root or child effects must settle or be recovered first. */
|
|
56
|
+
pause(id: string): Promise<WorkflowTreeSnapshot>;
|
|
57
|
+
/** Resume scheduling only; unresolved approvals and child waits remain unresolved. */
|
|
58
|
+
resume(id: string): Promise<WorkflowTreeSnapshot>;
|
|
59
|
+
/**
|
|
60
|
+
* Plan (dryRun) or apply a reviewed migration of a paused tree. Root steps with a prepared job and child steps with an
|
|
61
|
+
* admitted child keep their exact definition; everything else follows the plan. The tree stays paused.
|
|
62
|
+
*/
|
|
63
|
+
migrate(migration: WorkflowMigration<AnyWorkflowTree, AnyWorkflowTree>, command: MigrationCommand): Promise<WorkflowMigrationResult<WorkflowTreeSnapshot>>;
|
|
64
|
+
recoverExpired(id: string): Promise<WorkflowTreeSnapshot>;
|
|
65
|
+
events(id: string, after?: number): ReturnType<WorkflowTreeAggregateStore['events']>;
|
|
66
|
+
close(): Promise<void>;
|
|
67
|
+
/** Admit no new wave, let admitted root/child effects and receipts settle within the deadline, then close. */
|
|
68
|
+
drain(options?: WorkflowDrainOptions): Promise<WorkflowDrainReport>;
|
|
69
|
+
}
|
|
70
|
+
/** Finite format-4 driver for root-local tools and one-level required children. */
|
|
71
|
+
export declare function createWorkflowTreeRuntime(options: WorkflowTreeRuntimeOptions): WorkflowTreeRuntime;
|
|
72
|
+
//# sourceMappingURL=children-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"children-runtime.d.ts","sourceRoot":"","sources":["../src/children-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsG,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,KAAK,MAAM,EAAE,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAE9M,OAAO,EAA2B,KAAK,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC1G,OAAO,EAC2D,iBAAiB,EAClD,KAAK,0BAA0B,EAAE,KAAK,wBAAwB,IAAI,kBAAkB,EACpH,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACkB,KAAK,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,KAAK,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC7H,OAAO,EAAoC,KAAK,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAC/H,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,KAAK,EAAC,0BAA0B,CAAC;IAAA,QAAQ,CAAC,KAAK,EAAC,KAAK,CAAC;IAAA,QAAQ,CAAC,WAAW,EAAC,WAAW,CAAC;IAAA,QAAQ,CAAC,aAAa,EAAC,MAAM,CAAC;IAC9H,QAAQ,CAAC,aAAa,EAAC,MAAM,CAAC;IAAA,QAAQ,CAAC,QAAQ,EAAC,MAAM,CAAC;IAAA,QAAQ,CAAC,QAAQ,EAAC,MAAM,CAAC;IAAA,QAAQ,CAAC,OAAO,CAAC,EAAC,MAAM,CAAC;IACzG,QAAQ,CAAC,i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