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,279 @@
|
|
|
1
|
+
import { freezeJson, jsonValue, MayuraError, type JsonObject, type JsonValue, type Scope } from '@mayura/core';
|
|
2
|
+
import { StorageError, type AggregateStore, type StoredEvent, type StoredEventInput, type StoredRecord } from '@mayura/storage-contracts';
|
|
3
|
+
|
|
4
|
+
export interface SignalRecord { readonly id: string; readonly name: string; readonly value: JsonValue; readonly sequence: number }
|
|
5
|
+
export interface WaitCondition { readonly id: string; readonly name: string; readonly after?: number }
|
|
6
|
+
export interface WaitDefinition {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly mode: 'all' | 'any';
|
|
9
|
+
readonly conditions: readonly WaitCondition[];
|
|
10
|
+
/** Absolute Unix epoch deadline. The configured trusted clock decides when it is due. */
|
|
11
|
+
readonly deadlineAtMs?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface WaitMatch { readonly conditionId: string; readonly signal: SignalRecord }
|
|
14
|
+
export interface WaitSnapshot extends WaitDefinition {
|
|
15
|
+
readonly status: 'waiting' | 'succeeded' | 'cancelled' | 'timed_out';
|
|
16
|
+
readonly matches: readonly WaitMatch[];
|
|
17
|
+
}
|
|
18
|
+
export interface WorkStreamOptions {
|
|
19
|
+
readonly store: AggregateStore;
|
|
20
|
+
readonly scope: Scope;
|
|
21
|
+
readonly streamId: string;
|
|
22
|
+
/** Trusted host clock. Override only for deterministic tests or a synchronized platform clock. */
|
|
23
|
+
readonly now?: () => number;
|
|
24
|
+
}
|
|
25
|
+
export interface WorkStream {
|
|
26
|
+
initialize(): Promise<void>;
|
|
27
|
+
signal(input: { readonly id: string; readonly name: string; readonly value: JsonValue }): Promise<SignalRecord>;
|
|
28
|
+
register(definition: WaitDefinition): Promise<WaitSnapshot>;
|
|
29
|
+
inspect(id: string): Promise<WaitSnapshot | undefined>;
|
|
30
|
+
cancel(id: string): Promise<WaitSnapshot>;
|
|
31
|
+
/** Atomically expires due waits. Repeated calls and competing workers are idempotent. */
|
|
32
|
+
sweepDeadlines(options?: { readonly limit?: number }): Promise<readonly WaitSnapshot[]>;
|
|
33
|
+
signals(options?: { readonly after?: number; readonly limit?: number }): Promise<{ readonly items: readonly SignalRecord[]; readonly next: number }>;
|
|
34
|
+
events(after?: number): Promise<readonly StoredEvent[]>;
|
|
35
|
+
}
|
|
36
|
+
interface State { format: 1; streamId: string; signals: SignalRecord[]; waits: WaitSnapshot[] }
|
|
37
|
+
const SIGNALS = 256;
|
|
38
|
+
const WAITS = 128;
|
|
39
|
+
const CONDITIONS = 32;
|
|
40
|
+
const VALUE_BYTES = 4096;
|
|
41
|
+
const STATE_BYTES = 1_048_576;
|
|
42
|
+
const FORMAT_HASH = 'mayura-workstream-v1';
|
|
43
|
+
|
|
44
|
+
function identifier(value: unknown): asserts value is string {
|
|
45
|
+
if (typeof value !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/.test(value)) throw new MayuraError('INVALID_INPUT', 'WorkStream identifiers must be bounded simple identifiers.');
|
|
46
|
+
}
|
|
47
|
+
function cursor(value: unknown): asserts value is number {
|
|
48
|
+
if (!Number.isSafeInteger(value) || typeof value !== 'number' || value < 0) throw new MayuraError('INVALID_INPUT', 'A signal cursor must be a nonnegative safe integer.');
|
|
49
|
+
}
|
|
50
|
+
function timestamp(value: unknown): asserts value is number {
|
|
51
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0) throw new MayuraError('INVALID_INPUT', 'A wait deadline must be a nonnegative safe Unix epoch millisecond value.');
|
|
52
|
+
}
|
|
53
|
+
function object(value: JsonValue | undefined): JsonObject {
|
|
54
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) throw new MayuraError('INVALID_INPUT', 'WorkStream data must be a plain JSON object.');
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
function canonical(value: JsonValue): string {
|
|
58
|
+
if (value === null || typeof value !== 'object') return JSON.stringify(value);
|
|
59
|
+
if (Array.isArray(value)) return `[${value.map(canonical).join(',')}]`;
|
|
60
|
+
return `{${Object.keys(value).sort().map(key => `${JSON.stringify(key)}:${canonical(value[key]!)}`).join(',')}}`;
|
|
61
|
+
}
|
|
62
|
+
function equal(left: unknown, right: unknown): boolean { return canonical(jsonValue(left)) === canonical(jsonValue(right)); }
|
|
63
|
+
function immutable<T>(value: T): T { return freezeJson(jsonValue(value, { maxBytes: STATE_BYTES })) as T; }
|
|
64
|
+
function definition(value: unknown): WaitDefinition {
|
|
65
|
+
const raw = object(jsonValue(value));
|
|
66
|
+
identifier(raw['id']);
|
|
67
|
+
if ((raw['mode'] !== 'all' && raw['mode'] !== 'any') || !Array.isArray(raw['conditions']) || raw['conditions'].length < 1 || raw['conditions'].length > CONDITIONS || Object.keys(raw).some(key => !['id', 'mode', 'conditions', 'deadlineAtMs'].includes(key))) {
|
|
68
|
+
throw new MayuraError('INVALID_INPUT', 'A wait needs a mode and 1–32 named conditions.');
|
|
69
|
+
}
|
|
70
|
+
const conditions = raw['conditions'].map(item => {
|
|
71
|
+
const part = object(item); identifier(part['id']); identifier(part['name']);
|
|
72
|
+
if (Object.keys(part).some(key => !['id', 'name', 'after'].includes(key))) throw new MayuraError('INVALID_INPUT', 'Unknown wait-condition field.');
|
|
73
|
+
const after = part['after'] === undefined ? 0 : part['after']; cursor(after);
|
|
74
|
+
return { id: part['id'], name: part['name'], after };
|
|
75
|
+
});
|
|
76
|
+
if (new Set(conditions.map(condition => condition.id)).size !== conditions.length) throw new MayuraError('INVALID_INPUT', 'Wait condition IDs must be unique.');
|
|
77
|
+
if (raw['deadlineAtMs'] !== undefined) timestamp(raw['deadlineAtMs']);
|
|
78
|
+
return immutable({ id: raw['id'], mode: raw['mode'], conditions, ...(raw['deadlineAtMs'] === undefined ? {} : { deadlineAtMs: raw['deadlineAtMs'] }) });
|
|
79
|
+
}
|
|
80
|
+
function matched(wait: WaitDefinition, signals: readonly SignalRecord[]): readonly WaitMatch[] | undefined {
|
|
81
|
+
const matches: WaitMatch[] = [];
|
|
82
|
+
for (const condition of wait.conditions) {
|
|
83
|
+
const signal = signals.find(item => item.name === condition.name && item.sequence > (condition.after ?? 0));
|
|
84
|
+
if (signal) matches.push({ conditionId: condition.id, signal });
|
|
85
|
+
}
|
|
86
|
+
if (wait.mode === 'all') return matches.length === wait.conditions.length ? matches : undefined;
|
|
87
|
+
if (matches.length === 0) return undefined;
|
|
88
|
+
// Stable sort preserves declared condition order when two conditions see the same signal.
|
|
89
|
+
matches.sort((left, right) => left.signal.sequence - right.signal.sequence);
|
|
90
|
+
return [matches[0]!];
|
|
91
|
+
}
|
|
92
|
+
function settle(state: State): StoredEventInput[] {
|
|
93
|
+
const events: StoredEventInput[] = [];
|
|
94
|
+
state.waits = state.waits.map(wait => {
|
|
95
|
+
if (wait.status !== 'waiting') return wait;
|
|
96
|
+
const matches = matched(wait, state.signals);
|
|
97
|
+
if (!matches) return wait;
|
|
98
|
+
events.push({ type: 'wait.succeeded', data: { waitId: wait.id } });
|
|
99
|
+
const disposed = wait.mode === 'any' ? wait.conditions.length - 1 : 0;
|
|
100
|
+
if (disposed > 0) events.push({ type: 'wait.subscriptions.disposed', data: { waitId: wait.id, reason: 'succeeded', count: disposed } });
|
|
101
|
+
return { ...wait, status: 'succeeded', matches };
|
|
102
|
+
});
|
|
103
|
+
return events;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Validate the persisted wire shape and its derivable match invariants before any disclosure. */
|
|
107
|
+
function stateFrom(record: StoredRecord, streamId: string, scopeKey: string): State {
|
|
108
|
+
try {
|
|
109
|
+
const state = object(jsonValue(record.state, { maxBytes: STATE_BYTES }));
|
|
110
|
+
if (record.scope !== scopeKey || record.id !== streamId || record.definitionHash !== FORMAT_HASH || state['format'] !== 1 || state['streamId'] !== streamId || Object.keys(state).some(key => !['format', 'streamId', 'signals', 'waits'].includes(key)) || !Array.isArray(state['signals']) || state['signals'].length > SIGNALS || !Array.isArray(state['waits']) || state['waits'].length > WAITS) throw new Error();
|
|
111
|
+
const signals = state['signals'].map((raw, index): SignalRecord => {
|
|
112
|
+
const item = object(raw); identifier(item['id']); identifier(item['name']);
|
|
113
|
+
if (item['sequence'] !== index + 1 || !Object.hasOwn(item, 'value') || Object.keys(item).some(key => !['id', 'name', 'value', 'sequence'].includes(key))) throw new Error();
|
|
114
|
+
return { id: item['id'], name: item['name'], sequence: index + 1, value: jsonValue(item['value'], { maxBytes: VALUE_BYTES }) };
|
|
115
|
+
});
|
|
116
|
+
if (new Set(signals.map(item => item.id)).size !== signals.length) throw new Error();
|
|
117
|
+
const waits = state['waits'].map((raw): WaitSnapshot => {
|
|
118
|
+
const item = object(raw);
|
|
119
|
+
const def = definition({ id: item['id'], mode: item['mode'], conditions: item['conditions'], ...(item['deadlineAtMs'] === undefined ? {} : { deadlineAtMs: item['deadlineAtMs'] }) });
|
|
120
|
+
if (typeof item['status'] !== 'string' || !['waiting', 'succeeded', 'cancelled', 'timed_out'].includes(item['status']) || !Array.isArray(item['matches']) || Object.keys(item).some(key => !['id', 'mode', 'conditions', 'deadlineAtMs', 'status', 'matches'].includes(key))) throw new Error();
|
|
121
|
+
const result = matched(def, signals);
|
|
122
|
+
if (item['status'] === 'succeeded') {
|
|
123
|
+
if (!result || !equal(result, item['matches'])) throw new Error();
|
|
124
|
+
return { ...def, status: 'succeeded', matches: result };
|
|
125
|
+
}
|
|
126
|
+
if (item['matches'].length !== 0 || (item['status'] === 'waiting' && result)) throw new Error();
|
|
127
|
+
return { ...def, status: item['status'] as 'waiting' | 'cancelled' | 'timed_out', matches: [] };
|
|
128
|
+
});
|
|
129
|
+
if (new Set(waits.map(item => item.id)).size !== waits.length) throw new Error();
|
|
130
|
+
return { format: 1, streamId, signals, waits };
|
|
131
|
+
} catch { throw new MayuraError('INVALID_INPUT', 'Stored WorkStream data failed format or integrity validation.'); }
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Durable bounded broadcast signals. The caller supplies verified identity and owns storage lifecycle. */
|
|
135
|
+
export function createWorkStream(options: WorkStreamOptions): WorkStream {
|
|
136
|
+
identifier(options.streamId); identifier(options.scope?.principalId); identifier(options.scope?.projectId);
|
|
137
|
+
const streamId = options.streamId;
|
|
138
|
+
const scope = { principalId: options.scope.principalId, projectId: options.scope.projectId };
|
|
139
|
+
const store = options.store;
|
|
140
|
+
const now = options.now ?? Date.now;
|
|
141
|
+
const currentTime = (): number => {
|
|
142
|
+
let value: unknown;
|
|
143
|
+
try { value = now(); } catch { throw new MayuraError('STORAGE_UNAVAILABLE', 'The trusted WorkStream clock is unavailable.'); }
|
|
144
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0) throw new MayuraError('STORAGE_UNAVAILABLE', 'The trusted WorkStream clock returned an invalid timestamp.');
|
|
145
|
+
return value;
|
|
146
|
+
};
|
|
147
|
+
let scopeKey: string | undefined;
|
|
148
|
+
let initializePromise: Promise<void> | undefined;
|
|
149
|
+
const storage = async <T>(operation: () => Promise<T>): Promise<T> => {
|
|
150
|
+
try { return await operation(); }
|
|
151
|
+
catch (error) {
|
|
152
|
+
if (error instanceof StorageError && error.code === 'CONFLICT') throw new MayuraError('CONFLICT', 'The WorkStream record changed concurrently.');
|
|
153
|
+
throw new MayuraError('STORAGE_UNAVAILABLE', 'WorkStream storage is unavailable; retry the same stable command after recovery.');
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const requireScope = (): string => {
|
|
157
|
+
if (!scopeKey) throw new MayuraError('INVALID_CONFIG', 'Initialize WorkStream before accessing it.');
|
|
158
|
+
return scopeKey;
|
|
159
|
+
};
|
|
160
|
+
const read = async (): Promise<{ record: StoredRecord; state: State }> => {
|
|
161
|
+
const key = requireScope();
|
|
162
|
+
const record = await storage(() => store.read(key, streamId));
|
|
163
|
+
if (!record) throw new MayuraError('NOT_FOUND', 'WorkStream was not found in the configured scope.');
|
|
164
|
+
return { record, state: stateFrom(record, streamId, key) };
|
|
165
|
+
};
|
|
166
|
+
const update = async <T>(transition: (state: State) => { result: T; events: StoredEventInput[] }): Promise<T> => {
|
|
167
|
+
for (let attempt = 0; attempt < 32; attempt++) {
|
|
168
|
+
const { record, state } = await read();
|
|
169
|
+
const { result, events } = transition(state);
|
|
170
|
+
if (events.length === 0) return immutable(result);
|
|
171
|
+
let serialized: JsonObject;
|
|
172
|
+
try { serialized = object(jsonValue(state, { maxBytes: STATE_BYTES })); }
|
|
173
|
+
catch { throw new MayuraError('LIMIT_EXCEEDED', 'The bounded WorkStream state is full.'); }
|
|
174
|
+
try {
|
|
175
|
+
await store.update({ scope: requireScope(), id: streamId, expectedVersion: record.version, state: serialized, events });
|
|
176
|
+
return immutable(result);
|
|
177
|
+
} catch (error) {
|
|
178
|
+
if (error instanceof StorageError && error.code === 'CONFLICT') continue;
|
|
179
|
+
throw new MayuraError('STORAGE_UNAVAILABLE', 'WorkStream update could not be confirmed; retry the same stable command.');
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
throw new MayuraError('CONFLICT', 'WorkStream remained busy after bounded conflict retries.');
|
|
183
|
+
};
|
|
184
|
+
return Object.freeze({
|
|
185
|
+
initialize: async (): Promise<void> => {
|
|
186
|
+
if (!initializePromise) initializePromise = (async () => {
|
|
187
|
+
const hash = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(`mayura:workstream-scope:v1\0${canonical(scope)}`));
|
|
188
|
+
const key = [...new Uint8Array(hash)].map(byte => byte.toString(16).padStart(2, '0')).join('');
|
|
189
|
+
const created = await storage(() => store.create({ scope: key, id: streamId, idempotencyKey: streamId, definitionHash: FORMAT_HASH,
|
|
190
|
+
state: { format: 1, streamId, signals: [], waits: [] }, events: [{ type: 'stream.created', data: {} }],
|
|
191
|
+
}));
|
|
192
|
+
stateFrom(created.record, streamId, key); scopeKey = key;
|
|
193
|
+
})().catch((error: unknown) => { initializePromise = undefined; throw error; });
|
|
194
|
+
await initializePromise;
|
|
195
|
+
},
|
|
196
|
+
signal: async (input: { readonly id: string; readonly name: string; readonly value: JsonValue }): Promise<SignalRecord> => {
|
|
197
|
+
const raw = object(jsonValue(input, { maxBytes: VALUE_BYTES + 1024 }));
|
|
198
|
+
identifier(raw['id']); identifier(raw['name']);
|
|
199
|
+
if (!Object.hasOwn(raw, 'value') || Object.keys(raw).some(key => !['id', 'name', 'value'].includes(key))) throw new MayuraError('INVALID_INPUT', 'Signal requires only id, name and bounded JSON value.');
|
|
200
|
+
const signal = { id: raw['id'], name: raw['name'], value: jsonValue(raw['value'], { maxBytes: VALUE_BYTES }) };
|
|
201
|
+
return update(state => {
|
|
202
|
+
const existing = state.signals.find(item => item.id === signal.id);
|
|
203
|
+
if (existing) {
|
|
204
|
+
if (!equal({ id: existing.id, name: existing.name, value: existing.value }, signal)) throw new MayuraError('CONFLICT', 'Signal ID already identifies different content.');
|
|
205
|
+
return { result: existing, events: [] };
|
|
206
|
+
}
|
|
207
|
+
if (state.signals.length >= SIGNALS) throw new MayuraError('LIMIT_EXCEEDED', 'The stream signal-retention limit was reached.');
|
|
208
|
+
const entry: SignalRecord = { ...signal, sequence: state.signals.length + 1 };
|
|
209
|
+
state.signals.push(entry);
|
|
210
|
+
return { result: entry, events: [{ type: 'signal.received', data: { signalId: entry.id, sequence: entry.sequence } }, ...settle(state)] };
|
|
211
|
+
});
|
|
212
|
+
},
|
|
213
|
+
register: async (input: WaitDefinition): Promise<WaitSnapshot> => {
|
|
214
|
+
const def = definition(input);
|
|
215
|
+
return update(state => {
|
|
216
|
+
const existing = state.waits.find(wait => wait.id === def.id);
|
|
217
|
+
if (existing) {
|
|
218
|
+
if (!equal({ id: existing.id, mode: existing.mode, conditions: existing.conditions, ...(existing.deadlineAtMs === undefined ? {} : { deadlineAtMs: existing.deadlineAtMs }) }, def)) throw new MayuraError('CONFLICT', 'Wait ID already identifies a different definition.');
|
|
219
|
+
return { result: existing, events: [] };
|
|
220
|
+
}
|
|
221
|
+
if (state.waits.length >= WAITS) throw new MayuraError('LIMIT_EXCEEDED', 'The stream wait-retention limit was reached.');
|
|
222
|
+
state.waits.push({ ...def, status: 'waiting', matches: [] });
|
|
223
|
+
const completed = settle(state);
|
|
224
|
+
return { result: state.waits.find(wait => wait.id === def.id)!, events: [{ type: 'wait.registered', data: { waitId: def.id } }, ...completed] };
|
|
225
|
+
});
|
|
226
|
+
},
|
|
227
|
+
inspect: async (id: string): Promise<WaitSnapshot | undefined> => {
|
|
228
|
+
identifier(id); const { state } = await read(); const wait = state.waits.find(item => item.id === id);
|
|
229
|
+
return wait ? immutable(wait) : undefined;
|
|
230
|
+
},
|
|
231
|
+
cancel: async (id: string): Promise<WaitSnapshot> => {
|
|
232
|
+
identifier(id);
|
|
233
|
+
return update(state => {
|
|
234
|
+
const index = state.waits.findIndex(wait => wait.id === id); const current = state.waits[index];
|
|
235
|
+
if (!current) throw new MayuraError('NOT_FOUND', 'Wait was not found in this stream.');
|
|
236
|
+
if (current.status !== 'waiting') return { result: current, events: [] };
|
|
237
|
+
const cancelled: WaitSnapshot = { ...current, status: 'cancelled', matches: [] };
|
|
238
|
+
state.waits[index] = cancelled;
|
|
239
|
+
return { result: cancelled, events: [
|
|
240
|
+
{ type: 'wait.cancelled', data: { waitId: id } },
|
|
241
|
+
{ type: 'wait.subscriptions.disposed', data: { waitId: id, reason: 'cancelled', count: current.conditions.length } },
|
|
242
|
+
] };
|
|
243
|
+
});
|
|
244
|
+
},
|
|
245
|
+
sweepDeadlines: async (input: { readonly limit?: number } = {}): Promise<readonly WaitSnapshot[]> => {
|
|
246
|
+
const raw = object(jsonValue(input, { maxBytes: 1024 }));
|
|
247
|
+
if (Object.keys(raw).some(key => key !== 'limit')) throw new MayuraError('INVALID_INPUT', 'Deadline sweep accepts only a bounded limit.');
|
|
248
|
+
const limit = raw['limit'] === undefined ? 32 : raw['limit'];
|
|
249
|
+
if (typeof limit !== 'number' || !Number.isSafeInteger(limit) || limit < 1 || limit > WAITS) throw new MayuraError('INVALID_INPUT', 'Deadline sweep limit must be between 1 and 128.');
|
|
250
|
+
const observedAtMs = currentTime();
|
|
251
|
+
return update(state => {
|
|
252
|
+
const expired: WaitSnapshot[] = []; const events: StoredEventInput[] = [];
|
|
253
|
+
state.waits = state.waits.map(wait => {
|
|
254
|
+
if (expired.length >= limit || wait.status !== 'waiting' || wait.deadlineAtMs === undefined || wait.deadlineAtMs > observedAtMs) return wait;
|
|
255
|
+
const timedOut: WaitSnapshot = { ...wait, status: 'timed_out', matches: [] };
|
|
256
|
+
expired.push(timedOut);
|
|
257
|
+
events.push(
|
|
258
|
+
{ type: 'wait.timed_out', data: { waitId: wait.id, deadlineAtMs: wait.deadlineAtMs } },
|
|
259
|
+
{ type: 'wait.subscriptions.disposed', data: { waitId: wait.id, reason: 'timed_out', count: wait.conditions.length } },
|
|
260
|
+
);
|
|
261
|
+
return timedOut;
|
|
262
|
+
});
|
|
263
|
+
return { result: expired, events };
|
|
264
|
+
});
|
|
265
|
+
},
|
|
266
|
+
signals: async (options: { readonly after?: number; readonly limit?: number } = {}) => {
|
|
267
|
+
const after = options.after === undefined ? 0 : options.after;
|
|
268
|
+
const limit = options.limit === undefined ? 100 : options.limit; cursor(after);
|
|
269
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 100) throw new MayuraError('INVALID_INPUT', 'Signal page size must be between 1 and 100.');
|
|
270
|
+
const { state } = await read();
|
|
271
|
+
const items = state.signals.filter(signal => signal.sequence > after).slice(0, limit);
|
|
272
|
+
return immutable({ items, next: items.at(-1)?.sequence ?? after });
|
|
273
|
+
},
|
|
274
|
+
events: async (after = 0): Promise<readonly StoredEvent[]> => {
|
|
275
|
+
cursor(after); const key = requireScope();
|
|
276
|
+
return immutable(await storage(() => store.events(key, streamId, after)));
|
|
277
|
+
},
|
|
278
|
+
});
|
|
279
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { freezeJson, jsonValue, MayuraError, type JsonObject, type JsonValue, type Scope } from '@mayura/core';
|
|
2
|
+
import { StorageError, type AggregateStore, type StoredEvent, type StoredEventInput, type StoredRecord } from '@mayura/storage-contracts';
|
|
3
|
+
|
|
4
|
+
export interface TimerDefinition {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
/** Absolute Unix epoch millisecond due time. */
|
|
7
|
+
readonly dueAtMs: number;
|
|
8
|
+
/** Safe bounded application correlation data; not execution authority. */
|
|
9
|
+
readonly payload?: JsonValue;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface TimerSnapshot extends TimerDefinition {
|
|
13
|
+
readonly status: 'scheduled' | 'fired' | 'cancelled';
|
|
14
|
+
readonly firedAtMs?: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface TimerWorkStreamOptions {
|
|
18
|
+
readonly store: AggregateStore;
|
|
19
|
+
readonly scope: Scope;
|
|
20
|
+
readonly streamId: string;
|
|
21
|
+
/** Trusted synchronized host clock. */
|
|
22
|
+
readonly now?: () => number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface TimerWorkStream {
|
|
26
|
+
initialize(): Promise<void>;
|
|
27
|
+
schedule(definition: TimerDefinition): Promise<TimerSnapshot>;
|
|
28
|
+
inspect(id: string): Promise<TimerSnapshot | undefined>;
|
|
29
|
+
cancel(id: string): Promise<TimerSnapshot>;
|
|
30
|
+
/** Atomically fires at most `limit` due timers in due-time/ID order. */
|
|
31
|
+
sweepDue(options?: { readonly limit?: number }): Promise<readonly TimerSnapshot[]>;
|
|
32
|
+
list(options?: { readonly afterId?: string; readonly limit?: number }): Promise<{ readonly items: readonly TimerSnapshot[]; readonly next: string | null }>;
|
|
33
|
+
events(after?: number): Promise<readonly StoredEvent[]>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface State { format: 1; streamId: string; timers: TimerSnapshot[] }
|
|
37
|
+
const TIMERS = 256;
|
|
38
|
+
const PAYLOAD_BYTES = 2_048;
|
|
39
|
+
const STATE_BYTES = 1_048_576;
|
|
40
|
+
const FORMAT_HASH = 'mayura-timer-workstream-v1';
|
|
41
|
+
const idPattern = /^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/;
|
|
42
|
+
|
|
43
|
+
function identifier(value: unknown): asserts value is string {
|
|
44
|
+
if (typeof value !== 'string' || !idPattern.test(value)) throw new MayuraError('INVALID_INPUT', 'Timer identifiers must be bounded simple identifiers.');
|
|
45
|
+
}
|
|
46
|
+
function timestamp(value: unknown): asserts value is number {
|
|
47
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0) throw new MayuraError('INVALID_INPUT', 'Timer due time must be a nonnegative safe Unix epoch millisecond value.');
|
|
48
|
+
}
|
|
49
|
+
function object(value: JsonValue | undefined): JsonObject {
|
|
50
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) throw new MayuraError('INVALID_INPUT', 'Timer data must be a plain JSON object.');
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
function canonical(value: JsonValue): string {
|
|
54
|
+
if (value === null || typeof value !== 'object') return JSON.stringify(value);
|
|
55
|
+
if (Array.isArray(value)) return `[${value.map(canonical).join(',')}]`;
|
|
56
|
+
return `{${Object.keys(value).sort().map(key => `${JSON.stringify(key)}:${canonical(value[key]!)}`).join(',')}}`;
|
|
57
|
+
}
|
|
58
|
+
function immutable<T>(value: T): T { return freezeJson(jsonValue(value, { maxBytes: STATE_BYTES })) as unknown as T; }
|
|
59
|
+
function equal(left: JsonValue, right: JsonValue): boolean { return canonical(left) === canonical(right); }
|
|
60
|
+
function compareId(left: string, right: string): number { return left < right ? -1 : left > right ? 1 : 0; }
|
|
61
|
+
|
|
62
|
+
function definition(value: unknown): TimerDefinition {
|
|
63
|
+
const raw = object(jsonValue(value, { maxBytes: PAYLOAD_BYTES + 1_024 }));
|
|
64
|
+
if (Object.keys(raw).some(key => !['id', 'dueAtMs', 'payload'].includes(key))) throw new MayuraError('INVALID_INPUT', 'Timer definition contains an unknown field.');
|
|
65
|
+
identifier(raw['id']); timestamp(raw['dueAtMs']);
|
|
66
|
+
return immutable({ id: raw['id'], dueAtMs: raw['dueAtMs'], ...(raw['payload'] === undefined ? {} : { payload: jsonValue(raw['payload'], { maxBytes: PAYLOAD_BYTES }) }) });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function stateFrom(record: StoredRecord, streamId: string, scopeKey: string): State {
|
|
70
|
+
try {
|
|
71
|
+
const raw = object(jsonValue(record.state, { maxBytes: STATE_BYTES }));
|
|
72
|
+
if (record.scope !== scopeKey || record.id !== streamId || record.definitionHash !== FORMAT_HASH || raw['format'] !== 1 || raw['streamId'] !== streamId
|
|
73
|
+
|| Object.keys(raw).some(key => !['format', 'streamId', 'timers'].includes(key)) || !Array.isArray(raw['timers']) || raw['timers'].length > TIMERS) throw new Error();
|
|
74
|
+
const timers = raw['timers'].map(item => {
|
|
75
|
+
const value = object(item); const base = definition({ id: value['id'], dueAtMs: value['dueAtMs'], ...(value['payload'] === undefined ? {} : { payload: value['payload'] }) });
|
|
76
|
+
if (!['scheduled', 'fired', 'cancelled'].includes(value['status'] as string)
|
|
77
|
+
|| Object.keys(value).some(key => !['id', 'dueAtMs', 'payload', 'status', 'firedAtMs'].includes(key))) throw new Error();
|
|
78
|
+
if (value['status'] === 'fired') {
|
|
79
|
+
timestamp(value['firedAtMs']);
|
|
80
|
+
if ((value['firedAtMs'] as number) < base.dueAtMs) throw new Error();
|
|
81
|
+
return { ...base, status: 'fired' as const, firedAtMs: value['firedAtMs'] as number };
|
|
82
|
+
}
|
|
83
|
+
if (value['firedAtMs'] !== undefined) throw new Error();
|
|
84
|
+
return { ...base, status: value['status'] as 'scheduled' | 'cancelled' };
|
|
85
|
+
});
|
|
86
|
+
if (new Set(timers.map(timer => timer.id)).size !== timers.length) throw new Error();
|
|
87
|
+
return { format: 1, streamId, timers };
|
|
88
|
+
} catch { throw new MayuraError('INTEGRITY_VIOLATION', 'Stored timer WorkStream data failed format or integrity validation.'); }
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Finite durable timers. Applications explicitly schedule sweeps; this facade starts no background work. */
|
|
92
|
+
export function createTimerWorkStream(options: TimerWorkStreamOptions): TimerWorkStream {
|
|
93
|
+
identifier(options.streamId); identifier(options.scope?.principalId); identifier(options.scope?.projectId);
|
|
94
|
+
const streamId = options.streamId; const scope = { principalId: options.scope.principalId, projectId: options.scope.projectId };
|
|
95
|
+
const store = options.store; const now = options.now ?? Date.now;
|
|
96
|
+
let scopeKey: string | undefined; let initializePromise: Promise<void> | undefined;
|
|
97
|
+
const currentTime = (): number => {
|
|
98
|
+
let value: unknown;
|
|
99
|
+
try { value = now(); } catch { throw new MayuraError('STORAGE_UNAVAILABLE', 'The trusted timer clock is unavailable.'); }
|
|
100
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0) throw new MayuraError('STORAGE_UNAVAILABLE', 'The trusted timer clock returned an invalid timestamp.');
|
|
101
|
+
return value;
|
|
102
|
+
};
|
|
103
|
+
const storage = async <T>(operation: () => Promise<T>): Promise<T> => {
|
|
104
|
+
try { return await operation(); }
|
|
105
|
+
catch (error) {
|
|
106
|
+
if (error instanceof StorageError && error.code === 'CONFLICT') throw new MayuraError('CONFLICT', 'The timer WorkStream changed concurrently.');
|
|
107
|
+
throw new MayuraError('STORAGE_UNAVAILABLE', 'Timer WorkStream storage is unavailable; retry the same stable command after recovery.');
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const key = (): string => {
|
|
111
|
+
if (!scopeKey) throw new MayuraError('INVALID_CONFIG', 'Initialize the timer WorkStream before accessing it.');
|
|
112
|
+
return scopeKey;
|
|
113
|
+
};
|
|
114
|
+
const read = async (): Promise<{ record: StoredRecord; state: State }> => {
|
|
115
|
+
const selected = key(); const record = await storage(() => store.read(selected, streamId));
|
|
116
|
+
if (!record) throw new MayuraError('NOT_FOUND', 'Timer WorkStream was not found in the configured scope.');
|
|
117
|
+
return { record, state: stateFrom(record, streamId, selected) };
|
|
118
|
+
};
|
|
119
|
+
const update = async <T>(transition: (state: State) => { result: T; events: readonly StoredEventInput[] }): Promise<T> => {
|
|
120
|
+
for (let attempt = 0; attempt < 32; attempt++) {
|
|
121
|
+
const { record, state } = await read(); const changed = transition(state);
|
|
122
|
+
if (changed.events.length === 0) return immutable(changed.result);
|
|
123
|
+
let serialized: JsonObject;
|
|
124
|
+
try { serialized = object(jsonValue(state, { maxBytes: STATE_BYTES })); }
|
|
125
|
+
catch { throw new MayuraError('LIMIT_EXCEEDED', 'The bounded timer WorkStream state is full.'); }
|
|
126
|
+
try {
|
|
127
|
+
await store.update({ scope: key(), id: streamId, expectedVersion: record.version, state: serialized, events: changed.events });
|
|
128
|
+
return immutable(changed.result);
|
|
129
|
+
} catch (error) {
|
|
130
|
+
if (error instanceof StorageError && error.code === 'CONFLICT') continue;
|
|
131
|
+
throw new MayuraError('STORAGE_UNAVAILABLE', 'Timer WorkStream update could not be confirmed; retry the same stable command.');
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
throw new MayuraError('CONFLICT', 'Timer WorkStream remained busy after bounded conflict retries.');
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
return Object.freeze<TimerWorkStream>({
|
|
138
|
+
initialize: async () => {
|
|
139
|
+
if (!initializePromise) initializePromise = (async () => {
|
|
140
|
+
const bytes = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(`mayura:timer-scope:v1\0${canonical(scope)}`));
|
|
141
|
+
const selected = [...new Uint8Array(bytes)].map(byte => byte.toString(16).padStart(2, '0')).join('');
|
|
142
|
+
const created = await storage(() => store.create({ scope: selected, id: streamId, idempotencyKey: streamId, definitionHash: FORMAT_HASH,
|
|
143
|
+
state: { format: 1, streamId, timers: [] }, events: [{ type: 'timer-stream.created', data: {} }] }));
|
|
144
|
+
stateFrom(created.record, streamId, selected); scopeKey = selected;
|
|
145
|
+
})().catch((error: unknown) => { initializePromise = undefined; throw error; });
|
|
146
|
+
await initializePromise;
|
|
147
|
+
},
|
|
148
|
+
schedule: async input => {
|
|
149
|
+
const timer = definition(input);
|
|
150
|
+
return update(state => {
|
|
151
|
+
const existing = state.timers.find(item => item.id === timer.id);
|
|
152
|
+
if (existing) {
|
|
153
|
+
const comparable = { id: existing.id, dueAtMs: existing.dueAtMs, ...(existing.payload === undefined ? {} : { payload: existing.payload }) };
|
|
154
|
+
if (!equal(jsonValue(comparable), jsonValue(timer))) throw new MayuraError('CONFLICT', 'Timer ID already identifies a different definition.');
|
|
155
|
+
return { result: existing, events: [] };
|
|
156
|
+
}
|
|
157
|
+
if (state.timers.length >= TIMERS) throw new MayuraError('LIMIT_EXCEEDED', 'The timer retention limit was reached.');
|
|
158
|
+
const scheduled: TimerSnapshot = { ...timer, status: 'scheduled' }; state.timers.push(scheduled);
|
|
159
|
+
return { result: scheduled, events: [{ type: 'timer.scheduled', data: { timerId: timer.id, dueAtMs: timer.dueAtMs } }] };
|
|
160
|
+
});
|
|
161
|
+
},
|
|
162
|
+
inspect: async id => {
|
|
163
|
+
identifier(id); const { state } = await read(); const timer = state.timers.find(item => item.id === id);
|
|
164
|
+
return timer ? immutable(timer) : undefined;
|
|
165
|
+
},
|
|
166
|
+
cancel: async id => {
|
|
167
|
+
identifier(id);
|
|
168
|
+
return update(state => {
|
|
169
|
+
const index = state.timers.findIndex(timer => timer.id === id); const timer = state.timers[index];
|
|
170
|
+
if (!timer) throw new MayuraError('NOT_FOUND', 'Timer was not found in this stream.');
|
|
171
|
+
if (timer.status !== 'scheduled') return { result: timer, events: [] };
|
|
172
|
+
const cancelled: TimerSnapshot = { ...timer, status: 'cancelled' }; state.timers[index] = cancelled;
|
|
173
|
+
return { result: cancelled, events: [{ type: 'timer.cancelled', data: { timerId: id } }] };
|
|
174
|
+
});
|
|
175
|
+
},
|
|
176
|
+
sweepDue: async (input = {}) => {
|
|
177
|
+
const raw = object(jsonValue(input, { maxBytes: 1_024 }));
|
|
178
|
+
if (Object.keys(raw).some(field => field !== 'limit')) throw new MayuraError('INVALID_INPUT', 'Timer sweep accepts only a bounded limit.');
|
|
179
|
+
const limit = raw['limit'] === undefined ? 32 : raw['limit'];
|
|
180
|
+
if (typeof limit !== 'number' || !Number.isSafeInteger(limit) || limit < 1 || limit > TIMERS) throw new MayuraError('INVALID_INPUT', 'Timer sweep limit must be between 1 and 256.');
|
|
181
|
+
const observedAtMs = currentTime();
|
|
182
|
+
return update(state => {
|
|
183
|
+
const eligible = state.timers.filter(timer => timer.status === 'scheduled' && timer.dueAtMs <= observedAtMs)
|
|
184
|
+
.sort((left, right) => left.dueAtMs - right.dueAtMs || compareId(left.id, right.id)).slice(0, limit);
|
|
185
|
+
if (eligible.length === 0) return { result: [] as TimerSnapshot[], events: [] };
|
|
186
|
+
const ids = new Set(eligible.map(timer => timer.id)); const fired: TimerSnapshot[] = []; const events: StoredEventInput[] = [];
|
|
187
|
+
state.timers = state.timers.map(timer => {
|
|
188
|
+
if (!ids.has(timer.id)) return timer;
|
|
189
|
+
const result: TimerSnapshot = { ...timer, status: 'fired', firedAtMs: observedAtMs }; fired.push(result);
|
|
190
|
+
events.push({ type: 'timer.fired', data: { timerId: timer.id, dueAtMs: timer.dueAtMs, firedAtMs: observedAtMs } }); return result;
|
|
191
|
+
});
|
|
192
|
+
fired.sort((left, right) => left.dueAtMs - right.dueAtMs || compareId(left.id, right.id));
|
|
193
|
+
return { result: fired, events };
|
|
194
|
+
});
|
|
195
|
+
},
|
|
196
|
+
list: async (input = {}) => {
|
|
197
|
+
const raw = object(jsonValue(input, { maxBytes: 1_024 }));
|
|
198
|
+
if (Object.keys(raw).some(field => !['afterId', 'limit'].includes(field))) throw new MayuraError('INVALID_INPUT', 'Timer list accepts only cursor and limit.');
|
|
199
|
+
const afterId = raw['afterId'] === undefined ? '' : raw['afterId'];
|
|
200
|
+
if (afterId !== '') identifier(afterId);
|
|
201
|
+
const limit = raw['limit'] === undefined ? 100 : raw['limit'];
|
|
202
|
+
if (typeof limit !== 'number' || !Number.isSafeInteger(limit) || limit < 1 || limit > 100) throw new MayuraError('INVALID_INPUT', 'Timer page size must be between 1 and 100.');
|
|
203
|
+
const { state } = await read(); const ordered = [...state.timers].sort((left, right) => compareId(left.id, right.id));
|
|
204
|
+
const items = ordered.filter(timer => timer.id > afterId).slice(0, limit); const hasMore = ordered.some(timer => timer.id > (items.at(-1)?.id ?? afterId));
|
|
205
|
+
return immutable({ items, next: hasMore ? items.at(-1)?.id ?? null : null });
|
|
206
|
+
},
|
|
207
|
+
events: async (after = 0) => {
|
|
208
|
+
if (!Number.isSafeInteger(after) || after < 0) throw new MayuraError('INVALID_INPUT', 'Timer event cursor must be a nonnegative safe integer.');
|
|
209
|
+
return immutable(await storage(() => store.events(key(), streamId, after)));
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
}
|