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,366 @@
|
|
|
1
|
+
import { MayuraError } from '../../core/dist/index.js';
|
|
2
|
+
import { StorageError } from '../../storage-contracts/dist/index.js';
|
|
3
|
+
import { digest } from './definition.js';
|
|
4
|
+
const runPattern = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/;
|
|
5
|
+
const nodePattern = /^[A-Za-z][A-Za-z0-9._-]{0,127}$/;
|
|
6
|
+
const stable = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,255}$/;
|
|
7
|
+
const codePattern = /^[A-Z][A-Z0-9_]{0,63}$/;
|
|
8
|
+
const settled = new Set(['succeeded', 'failed', 'blocked', 'cancelled', 'outcome_unknown']);
|
|
9
|
+
/** Normalized (`lifecycle.` prefix removed) event types after which a step changes no more. */
|
|
10
|
+
const stepEnds = new Set(['step.completed', 'step.failed', 'step.blocked', 'step.skipped', 'step.bypassed', 'step.output_blocked', 'human.responded',
|
|
11
|
+
'human.timed_out', 'human.invalid', 'timer.fired', 'timer.invalid', 'workflow.wait_resolved', 'workflow.child_joined']);
|
|
12
|
+
const failures = new Set(['step.failed', 'step.blocked', 'step.output_blocked']);
|
|
13
|
+
function derived(domain, value, length) {
|
|
14
|
+
const hex = digest(domain, value).slice(0, length);
|
|
15
|
+
return /^0+$/.test(hex) ? `${hex.slice(0, -1)}1` : hex;
|
|
16
|
+
}
|
|
17
|
+
const nanos = (milliseconds) => (BigInt(milliseconds) * 1000000n).toString();
|
|
18
|
+
const spanStatus = (status) => status === 'succeeded' ? 'ok' : ['failed', 'blocked', 'outcome_unknown', 'unknown', 'timed_out'].includes(status) ? 'error' : 'unset';
|
|
19
|
+
const integer = (value) => typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
|
|
20
|
+
const field = (value, key) => value !== null && typeof value === 'object' && !Array.isArray(value) ? value[key] : undefined;
|
|
21
|
+
/** The root span of a run (no node), or the span of one of its steps. Parent your own spans under these. */
|
|
22
|
+
export function workflowTraceContext(runId, nodeId) {
|
|
23
|
+
if (typeof runId !== 'string' || !runPattern.test(runId) || (nodeId !== undefined && (typeof nodeId !== 'string' || !nodePattern.test(nodeId)))) {
|
|
24
|
+
throw new MayuraError('INVALID_INPUT', 'A workflow trace context requires a bounded run id and node id.');
|
|
25
|
+
}
|
|
26
|
+
return Object.freeze({ traceId: derived('mayura:workflow-trace:v1', { runId }, 32), spanId: derived('mayura:workflow-span:v1', { runId, nodeId: nodeId ?? null }, 16) });
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The span of the step a tool is executing in, from its execution context: every format calls a step's tool with
|
|
30
|
+
* `callId` `<runId>/step:<nodeId>`. Spans produced inside the tool (for example an agent run's, via
|
|
31
|
+
* `agentRunTraceSpans(events, { parent })`) then nest under that step in the run's trace.
|
|
32
|
+
*/
|
|
33
|
+
export function workflowStepTraceContext(context) {
|
|
34
|
+
const prefix = `${context?.runId}/step:`;
|
|
35
|
+
if (typeof context?.callId !== 'string' || !context.callId.startsWith(prefix))
|
|
36
|
+
throw new MayuraError('INVALID_INPUT', 'The execution context is not a workflow step call.');
|
|
37
|
+
return workflowTraceContext(context.runId, context.callId.slice(prefix.length));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Project a settled run into spans: the root (`workflow:<definitionId>`) spans the whole log, and each step
|
|
41
|
+
* (`<kind>:<nodeId>`) spans its first to its last settling event (or the run's end, for a step that never settled on
|
|
42
|
+
* its own, such as one skipped by cancellation). Times are the store's event timestamps.
|
|
43
|
+
*/
|
|
44
|
+
export function workflowTraceSpans(input) {
|
|
45
|
+
const { runId, snapshot, definition } = input;
|
|
46
|
+
const events = input.events;
|
|
47
|
+
if (!Array.isArray(events) || events.length === 0 || !snapshot || typeof snapshot.status !== 'string' || !snapshot.steps || typeof snapshot.steps !== 'object') {
|
|
48
|
+
throw new MayuraError('INVALID_INPUT', 'A workflow trace requires the settled snapshot and the complete event log.');
|
|
49
|
+
}
|
|
50
|
+
const root = workflowTraceContext(runId);
|
|
51
|
+
const times = events.map((event, index) => {
|
|
52
|
+
const time = Date.parse(event?.createdAt);
|
|
53
|
+
if (event?.sequence !== index + 1 || typeof event.type !== 'string' || !event.data || typeof event.data !== 'object' || !Number.isSafeInteger(time) || time < 0) {
|
|
54
|
+
throw new MayuraError('INVALID_INPUT', 'A workflow trace requires the complete, ordered event log from sequence 1.');
|
|
55
|
+
}
|
|
56
|
+
return time;
|
|
57
|
+
});
|
|
58
|
+
// Store clocks can step backwards across processes; clamp so no span ends before it starts or before the run.
|
|
59
|
+
const runStart = times[0];
|
|
60
|
+
const runEnd = Math.max(...times);
|
|
61
|
+
const nodes = new Map((definition?.nodes ?? []).map(node => [node.id, node]));
|
|
62
|
+
const seen = new Map();
|
|
63
|
+
events.forEach((event, index) => {
|
|
64
|
+
const nodeId = event.data['nodeId'];
|
|
65
|
+
if (typeof nodeId !== 'string' || !Object.hasOwn(snapshot.steps, nodeId))
|
|
66
|
+
return;
|
|
67
|
+
const type = event.type.startsWith('lifecycle.') ? event.type.slice('lifecycle.'.length) : event.type;
|
|
68
|
+
const entry = seen.get(nodeId) ?? { first: Math.max(runStart, times[index]) };
|
|
69
|
+
seen.set(nodeId, entry);
|
|
70
|
+
if (stepEnds.has(type))
|
|
71
|
+
entry.end = Math.max(entry.first, times[index]);
|
|
72
|
+
// Fixed upper-case codes only (BUDGET_EXCEEDED, PERMISSION_DENIED, OUTPUT_LIMIT, ...); never a message.
|
|
73
|
+
const code = event.data['code'] ?? event.data['reason'];
|
|
74
|
+
if (failures.has(type) && typeof code === 'string' && codePattern.test(code))
|
|
75
|
+
entry.code = code;
|
|
76
|
+
const child = event.data['childId'];
|
|
77
|
+
if (type === 'workflow.child_admitted' && typeof child === 'string' && stable.test(child))
|
|
78
|
+
entry.child = child;
|
|
79
|
+
});
|
|
80
|
+
const order = [...nodes.keys(), ...Object.keys(snapshot.steps).filter(id => !nodes.has(id)).sort()].filter(id => Object.hasOwn(snapshot.steps, id));
|
|
81
|
+
const steps = order.map((nodeId) => {
|
|
82
|
+
const step = snapshot.steps[nodeId];
|
|
83
|
+
const node = nodes.get(nodeId);
|
|
84
|
+
const entry = seen.get(nodeId);
|
|
85
|
+
const kind = typeof step.kind === 'string' && stable.test(step.kind) ? step.kind : 'step';
|
|
86
|
+
const status = typeof step.status === 'string' && stable.test(step.status) ? step.status : 'unknown';
|
|
87
|
+
const start = entry?.first ?? runEnd;
|
|
88
|
+
const end = Math.max(start, entry?.end ?? runEnd);
|
|
89
|
+
const attributes = { 'mayura.workflow.node.id': nodeId, 'mayura.workflow.node.kind': kind, 'mayura.workflow.step.status': status };
|
|
90
|
+
if (entry?.code)
|
|
91
|
+
attributes['mayura.workflow.step.code'] = entry.code;
|
|
92
|
+
const execution = field(field(step, 'receipt'), 'execution');
|
|
93
|
+
if (typeof execution === 'string' && stable.test(execution))
|
|
94
|
+
attributes['mayura.workflow.receipt.execution'] = execution;
|
|
95
|
+
const child = entry?.child ?? field(field(step, 'child'), 'runId');
|
|
96
|
+
if (typeof child === 'string' && stable.test(child))
|
|
97
|
+
attributes['mayura.workflow.child.run.id'] = child;
|
|
98
|
+
if (node?.tool && typeof node.tool.id === 'string' && stable.test(node.tool.id))
|
|
99
|
+
attributes['mayura.tool.id'] = node.tool.id;
|
|
100
|
+
if (node?.tool && typeof node.tool.version === 'string' && stable.test(node.tool.version))
|
|
101
|
+
attributes['mayura.tool.version'] = node.tool.version;
|
|
102
|
+
if (node?.tool && integer(node.tool.costMicros))
|
|
103
|
+
attributes['mayura.budget.step_cost_micros'] = node.tool.costMicros;
|
|
104
|
+
return Object.freeze({ traceId: root.traceId, spanId: workflowTraceContext(runId, nodeId).spanId, parentSpanId: root.spanId,
|
|
105
|
+
name: stable.test(`${kind}:${nodeId}`) ? `${kind}:${nodeId}` : 'workflow.step', runId, status: spanStatus(status),
|
|
106
|
+
startTimeUnixNano: nanos(start), endTimeUnixNano: nanos(end), attributes: Object.freeze(attributes) });
|
|
107
|
+
});
|
|
108
|
+
const attributes = { 'mayura.workflow.status': stable.test(snapshot.status) ? snapshot.status : 'unknown', 'mayura.workflow.events': events.length };
|
|
109
|
+
if (definition && stable.test(definition.id))
|
|
110
|
+
attributes['mayura.workflow.definition.id'] = definition.id;
|
|
111
|
+
if (definition && stable.test(definition.version))
|
|
112
|
+
attributes['mayura.workflow.definition.version'] = definition.version;
|
|
113
|
+
if (definition && /^[a-f0-9]{64}$/.test(definition.digest))
|
|
114
|
+
attributes['mayura.workflow.definition.digest'] = definition.digest;
|
|
115
|
+
for (const [key, name] of [['spentMicros', 'mayura.budget.spent_micros'], ['reservedMicros', 'mayura.budget.reserved_micros'], ['maxCostMicros', 'mayura.budget.max_micros']]) {
|
|
116
|
+
const value = field(snapshot.budget, key);
|
|
117
|
+
if (integer(value))
|
|
118
|
+
attributes[name] = value;
|
|
119
|
+
}
|
|
120
|
+
const name = definition && stable.test(`workflow:${definition.id}`) ? `workflow:${definition.id}` : 'workflow.run';
|
|
121
|
+
return [Object.freeze({ traceId: root.traceId, spanId: root.spanId, name, runId, status: spanStatus(snapshot.status),
|
|
122
|
+
startTimeUnixNano: nanos(runStart), endTimeUnixNano: nanos(runEnd), attributes: Object.freeze(attributes) }), ...steps];
|
|
123
|
+
}
|
|
124
|
+
const exportPattern = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/;
|
|
125
|
+
function bounded(value, fallback, maximum, name) {
|
|
126
|
+
const result = value ?? fallback;
|
|
127
|
+
if (!Number.isSafeInteger(result) || result < 1 || result > maximum)
|
|
128
|
+
throw new MayuraError('INVALID_CONFIG', `${name} is outside its bound.`);
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
const sleep = (milliseconds, signal) => new Promise(resolve => {
|
|
132
|
+
if (signal.aborted) {
|
|
133
|
+
resolve();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const timer = setTimeout(done, milliseconds);
|
|
137
|
+
function done() { clearTimeout(timer); signal.removeEventListener('abort', done); resolve(); }
|
|
138
|
+
signal.addEventListener('abort', done, { once: true });
|
|
139
|
+
});
|
|
140
|
+
/**
|
|
141
|
+
* Restart-safe export of settled workflow runs. Durable state is an outbox of tracked run ids and, per run, the log
|
|
142
|
+
* position last exported. A crash before the marker is written re-exports the run later with identical ids (a
|
|
143
|
+
* collector deduplicates); a crash after it only leaves the run in the outbox, where the next flush finds it unchanged
|
|
144
|
+
* and drops it. Nothing here can change, block or fail a workflow run.
|
|
145
|
+
*/
|
|
146
|
+
export function createWorkflowTraceExport(options) {
|
|
147
|
+
const { source, store, sink } = options;
|
|
148
|
+
if (!source || typeof source.inspect !== 'function' || typeof source.events !== 'function' || !store || typeof store.read !== 'function'
|
|
149
|
+
|| typeof store.create !== 'function' || typeof store.update !== 'function' || typeof sink !== 'function' || typeof options.exportId !== 'string'
|
|
150
|
+
|| !exportPattern.test(options.exportId) || typeof options.scope?.principalId !== 'string' || typeof options.scope?.projectId !== 'string' || !Array.isArray(options.definitions)) {
|
|
151
|
+
throw new MayuraError('INVALID_CONFIG', 'A workflow trace export requires a source, a store, a scope, a bounded export id, definitions and a sink.');
|
|
152
|
+
}
|
|
153
|
+
const maxBatchSize = bounded(options.maxBatchSize, 128, 256, 'maxBatchSize');
|
|
154
|
+
const maxPending = bounded(options.maxPending, 4_096, 16_384, 'maxPending');
|
|
155
|
+
const maxEvents = bounded(options.maxEvents, 100_000, 10_000_000, 'maxEvents');
|
|
156
|
+
const exportId = options.exportId;
|
|
157
|
+
const definitions = new Map(options.definitions.map(definition => {
|
|
158
|
+
if (typeof definition?.digest !== 'string' || !Array.isArray(definition.nodes))
|
|
159
|
+
throw new MayuraError('INVALID_CONFIG', 'Trace definitions must be workflow definitions with a digest.');
|
|
160
|
+
return [definition.digest, definition];
|
|
161
|
+
}));
|
|
162
|
+
const scope = digest('mayura:scope:v1', { principalId: options.scope.principalId, projectId: options.scope.projectId });
|
|
163
|
+
const formatHash = digest('mayura:workflow-trace-export-format:v1', {});
|
|
164
|
+
const outboxId = digest('mayura:workflow-trace-outbox:v1', { exportId });
|
|
165
|
+
const markerId = (runId) => digest('mayura:workflow-trace-export:v1', { exportId, runId });
|
|
166
|
+
const guarded = async (operation) => {
|
|
167
|
+
try {
|
|
168
|
+
return await operation();
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
if (error instanceof MayuraError || (error instanceof StorageError && error.code === 'CONFLICT'))
|
|
172
|
+
throw error;
|
|
173
|
+
throw new MayuraError('STORAGE_UNAVAILABLE', 'Workflow trace export storage is unavailable.');
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
const corrupt = () => { throw new MayuraError('STORAGE_UNAVAILABLE', 'Stored workflow trace export state failed integrity validation.'); };
|
|
177
|
+
const outboxOf = (record) => {
|
|
178
|
+
if (!record)
|
|
179
|
+
return [];
|
|
180
|
+
const state = record.state;
|
|
181
|
+
const pending = state['pending'];
|
|
182
|
+
if (record.scope !== scope || record.id !== outboxId || state['format'] !== 1 || state['exportId'] !== exportId || !Array.isArray(pending) || pending.length > 16_384
|
|
183
|
+
|| pending.some((id, index) => typeof id !== 'string' || !runPattern.test(id) || (index > 0 && id <= pending[index - 1])))
|
|
184
|
+
return corrupt();
|
|
185
|
+
return pending;
|
|
186
|
+
};
|
|
187
|
+
const markerOf = (record, runId) => {
|
|
188
|
+
if (!record)
|
|
189
|
+
return 0;
|
|
190
|
+
const state = record.state;
|
|
191
|
+
if (record.scope !== scope || record.id !== markerId(runId) || state['format'] !== 1 || state['exportId'] !== exportId || state['runId'] !== runId
|
|
192
|
+
|| !Number.isSafeInteger(state['sequence']) || state['sequence'] < 0)
|
|
193
|
+
return corrupt();
|
|
194
|
+
return state['sequence'];
|
|
195
|
+
};
|
|
196
|
+
/** Compare-and-set write of one export record; `next` returns undefined when nothing needs to change. */
|
|
197
|
+
const change = async (id, type, next) => {
|
|
198
|
+
for (let attempt = 0; attempt < 32; attempt++) {
|
|
199
|
+
const record = await guarded(() => store.read(scope, id));
|
|
200
|
+
const state = next(record);
|
|
201
|
+
if (state === undefined)
|
|
202
|
+
return;
|
|
203
|
+
try {
|
|
204
|
+
if (record) {
|
|
205
|
+
await guarded(() => store.update({ scope, id, expectedVersion: record.version, state, events: [{ type, data: {} }] }));
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
if ((await guarded(() => store.create({ scope, id, idempotencyKey: id, definitionHash: formatHash, state, events: [{ type, data: {} }] }))).created)
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
if (!(error instanceof StorageError && error.code === 'CONFLICT'))
|
|
213
|
+
throw error;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
throw new MayuraError('CONFLICT', 'Workflow trace export contention exceeded its bounded retry limit.');
|
|
217
|
+
};
|
|
218
|
+
const add = (runIds) => change(outboxId, 'workflow-trace.tracked', record => {
|
|
219
|
+
const pending = outboxOf(record);
|
|
220
|
+
const merged = [...new Set([...pending, ...runIds])].sort();
|
|
221
|
+
if (merged.length === pending.length)
|
|
222
|
+
return undefined;
|
|
223
|
+
if (merged.length > maxPending)
|
|
224
|
+
throw new MayuraError('LIMIT_EXCEEDED', 'The workflow trace outbox is full.');
|
|
225
|
+
return { format: 1, exportId, pending: merged };
|
|
226
|
+
});
|
|
227
|
+
const remove = (runIds) => change(outboxId, 'workflow-trace.exported', record => {
|
|
228
|
+
const pending = outboxOf(record);
|
|
229
|
+
const drop = new Set(runIds);
|
|
230
|
+
const kept = pending.filter(id => !drop.has(id));
|
|
231
|
+
return kept.length === pending.length ? undefined : { format: 1, exportId, pending: kept };
|
|
232
|
+
});
|
|
233
|
+
const validRun = (runId) => {
|
|
234
|
+
if (typeof runId !== 'string' || !runPattern.test(runId))
|
|
235
|
+
throw new MayuraError('INVALID_INPUT', 'A bounded workflow run id is required.');
|
|
236
|
+
return runId;
|
|
237
|
+
};
|
|
238
|
+
// The OTLP exporter is single-flight: one run's batches go out together, and runs queue behind each other.
|
|
239
|
+
let tail = Promise.resolve();
|
|
240
|
+
const exclusive = (operation) => { const result = tail.then(operation, operation); tail = result.catch(() => undefined); return result; };
|
|
241
|
+
const exportRun = async (rawId, runOptions = {}) => {
|
|
242
|
+
const runId = validRun(rawId);
|
|
243
|
+
const signal = runOptions.signal ?? new AbortController().signal;
|
|
244
|
+
const snapshot = await source.inspect(runId);
|
|
245
|
+
if (!settled.has(snapshot?.status))
|
|
246
|
+
return Object.freeze({ runId, status: 'unsettled', spans: 0, sequence: 0 });
|
|
247
|
+
const events = [];
|
|
248
|
+
for (;;) {
|
|
249
|
+
const page = await source.events(runId, events.length);
|
|
250
|
+
if (!Array.isArray(page))
|
|
251
|
+
throw new MayuraError('STORAGE_UNAVAILABLE', 'The workflow event source returned an invalid page.');
|
|
252
|
+
if (page.length === 0)
|
|
253
|
+
break;
|
|
254
|
+
events.push(...page);
|
|
255
|
+
if (events.length > maxEvents)
|
|
256
|
+
throw new MayuraError('LIMIT_EXCEEDED', 'The workflow run log exceeds the trace export bound.');
|
|
257
|
+
}
|
|
258
|
+
const sequence = events.length;
|
|
259
|
+
if (markerOf(await guarded(() => store.read(scope, markerId(runId))), runId) >= sequence)
|
|
260
|
+
return Object.freeze({ runId, status: 'unchanged', spans: 0, sequence });
|
|
261
|
+
const pinned = (await guarded(() => store.read(scope, runId)))?.definitionHash;
|
|
262
|
+
const definition = pinned === undefined ? undefined : definitions.get(pinned);
|
|
263
|
+
const spans = workflowTraceSpans({ runId, snapshot, events, ...(definition ? { definition } : {}) });
|
|
264
|
+
await exclusive(async () => {
|
|
265
|
+
for (let index = 0; index < spans.length; index += maxBatchSize) {
|
|
266
|
+
if (signal.aborted)
|
|
267
|
+
throw new MayuraError('CANCELLED', 'Workflow trace export was cancelled.');
|
|
268
|
+
await sink(Object.freeze(spans.slice(index, index + maxBatchSize)), { signal });
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
// Mark only after every batch was accepted; a later, longer log (a late receipt, a reconciliation) exports again.
|
|
272
|
+
await change(markerId(runId), 'workflow-trace.marked', record => markerOf(record, runId) >= sequence ? undefined : { format: 1, exportId, runId, sequence });
|
|
273
|
+
return Object.freeze({ runId, status: 'exported', spans: spans.length, sequence });
|
|
274
|
+
};
|
|
275
|
+
let cursor = '';
|
|
276
|
+
const flush = async (flushOptions = {}) => {
|
|
277
|
+
const limit = bounded(flushOptions.limit, 32, 1_024, 'limit');
|
|
278
|
+
const pending = outboxOf(await guarded(() => store.read(scope, outboxId)));
|
|
279
|
+
// Round robin from where the last flush stopped, so long-running runs cannot starve the rest.
|
|
280
|
+
const start = pending.findIndex(id => id > cursor);
|
|
281
|
+
const ordered = start < 0 ? pending : [...pending.slice(start), ...pending.slice(0, start)];
|
|
282
|
+
const counts = { examined: 0, exported: 0, unchanged: 0, unsettled: 0, missing: 0, failed: 0 };
|
|
283
|
+
let lastError = null;
|
|
284
|
+
const done = [];
|
|
285
|
+
for (const runId of ordered.slice(0, limit)) {
|
|
286
|
+
if (flushOptions.signal?.aborted)
|
|
287
|
+
break;
|
|
288
|
+
counts.examined++;
|
|
289
|
+
cursor = runId;
|
|
290
|
+
try {
|
|
291
|
+
const result = await exportRun(runId, flushOptions.signal ? { signal: flushOptions.signal } : {});
|
|
292
|
+
counts[result.status]++;
|
|
293
|
+
if (result.status !== 'unsettled')
|
|
294
|
+
done.push(runId);
|
|
295
|
+
}
|
|
296
|
+
catch (error) {
|
|
297
|
+
const code = error instanceof MayuraError ? error.code : 'TOOL_FAILED';
|
|
298
|
+
if (code === 'NOT_FOUND') {
|
|
299
|
+
counts.missing++;
|
|
300
|
+
done.push(runId);
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
counts.failed++;
|
|
304
|
+
lastError = code;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
if (done.length > 0)
|
|
309
|
+
await remove(done);
|
|
310
|
+
return Object.freeze({ ...counts, lastError });
|
|
311
|
+
};
|
|
312
|
+
return Object.freeze({
|
|
313
|
+
track: async (runId) => add([validRun(runId)]),
|
|
314
|
+
exportRun, flush,
|
|
315
|
+
pending: async () => Object.freeze([...outboxOf(await guarded(() => store.read(scope, outboxId)))]),
|
|
316
|
+
unit(unitOptions = {}) {
|
|
317
|
+
const intervalMs = bounded(unitOptions.intervalMs, 1_000, 3_600_000, 'intervalMs');
|
|
318
|
+
const limit = bounded(unitOptions.limit, 32, 1_024, 'limit');
|
|
319
|
+
const targets = [...(unitOptions.targets ?? [])];
|
|
320
|
+
if (targets.length > 32 || targets.some(target => typeof target?.discover !== 'function'))
|
|
321
|
+
throw new MayuraError('INVALID_CONFIG', 'Trace discovery takes up to 32 targets with discover().');
|
|
322
|
+
let controller;
|
|
323
|
+
let loop;
|
|
324
|
+
const discover = async (signal) => {
|
|
325
|
+
for (const target of targets) {
|
|
326
|
+
let next = null;
|
|
327
|
+
let pages = 0;
|
|
328
|
+
do {
|
|
329
|
+
const page = await target.discover(next, 32);
|
|
330
|
+
const ids = page.runIds.filter(id => typeof id === 'string' && runPattern.test(id));
|
|
331
|
+
if (ids.length > 0)
|
|
332
|
+
await add(ids);
|
|
333
|
+
next = page.nextCursor;
|
|
334
|
+
pages++;
|
|
335
|
+
} while (next !== null && pages < 64 && !signal.aborted);
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
const stop = async () => { controller?.abort(); await loop; controller = undefined; loop = undefined; };
|
|
339
|
+
return Object.freeze({
|
|
340
|
+
start() {
|
|
341
|
+
if (loop)
|
|
342
|
+
return;
|
|
343
|
+
controller = new AbortController();
|
|
344
|
+
const signal = controller.signal;
|
|
345
|
+
loop = (async () => {
|
|
346
|
+
while (!signal.aborted) {
|
|
347
|
+
// Telemetry is best effort: a failed cycle is retried on the next one and never stops the worker.
|
|
348
|
+
try {
|
|
349
|
+
await discover(signal);
|
|
350
|
+
}
|
|
351
|
+
catch { /* Discovery resumes next cycle. */ }
|
|
352
|
+
try {
|
|
353
|
+
await flush({ signal, limit });
|
|
354
|
+
}
|
|
355
|
+
catch { /* The outbox keeps every unexported run. */ }
|
|
356
|
+
await sleep(intervalMs, signal);
|
|
357
|
+
}
|
|
358
|
+
})();
|
|
359
|
+
},
|
|
360
|
+
stop,
|
|
361
|
+
async drain(_options) { await stop(); return Object.freeze({ drained: true, interrupted: 0 }); },
|
|
362
|
+
});
|
|
363
|
+
},
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
//# sourceMappingURL=traces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traces.js","sourceRoot":"","sources":["../src/traces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA+D,MAAM,cAAc,CAAC;AACxG,OAAO,EAAE,YAAY,EAA4D,MAAM,2BAA2B,CAAC;AACnH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AA8CzC,MAAM,UAAU,GAAG,sCAAsC,CAAC;AAC1D,MAAM,WAAW,GAAG,iCAAiC,CAAC;AACtD,MAAM,MAAM,GAAG,sCAAsC,CAAC;AACtD,MAAM,WAAW,GAAG,wBAAwB,CAAC;AAC7C,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAC5F,+FAA+F;AAC/F,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,gBAAgB,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,qBAAqB,EAAE,iBAAiB;IAClJ,iBAAiB,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,wBAAwB,EAAE,uBAAuB,CAAC,CAAC,CAAC;AAC1H,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAA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,KAAK,CAAC,QAA+B,IAAkC,MAAM,IAAI,EAAE,CAAC,CAAC,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;aACtJ,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { MayuraError, type ErrorCode, type JsonObject, type JsonValue, type Scope } from '@mayura/core';\nimport { StorageError, type AggregateStore, type StoredEvent, type StoredRecord } from '@mayura/storage-contracts';\nimport { digest } from './definition.js';\nimport type { WorkflowDrainOptions, WorkflowDrainReport } from './drain.js';\nimport type { WorkflowWorkerUnit } from './worker.js';\n\n/**\n * Metadata-only traces of durable workflow runs. A settled run's durable event log (plus its settled snapshot) is\n * projected into one root span and one span per step. The projection is pure: it reads only event types, node ids,\n * store timestamps, statuses, receipt execution states, fixed failure codes and budget integers, never inputs,\n * outputs, prompts, request/response digests, human identities or error text. Trace and span ids derive from the run\n * id and node id, so projecting the same run again (after a restart, or twice) yields identical ids.\n */\n\n/** Span attributes this projection emits; a subset of `@mayura/exporter-otlp`'s closed catalog. */\nexport type WorkflowTraceAttributeName =\n | 'mayura.workflow.definition.id' | 'mayura.workflow.definition.version' | 'mayura.workflow.definition.digest'\n | 'mayura.workflow.status' | 'mayura.workflow.events'\n | 'mayura.workflow.node.id' | 'mayura.workflow.node.kind' | 'mayura.workflow.step.status' | 'mayura.workflow.step.code'\n | 'mayura.workflow.receipt.execution' | 'mayura.workflow.child.run.id' | 'mayura.tool.id' | 'mayura.tool.version'\n | 'mayura.budget.spent_micros' | 'mayura.budget.reserved_micros' | 'mayura.budget.max_micros' | 'mayura.budget.step_cost_micros';\nexport type WorkflowTraceAttributes = Readonly<Partial<Record<WorkflowTraceAttributeName, string | number>>>;\n/** Structurally an `OtlpTraceSpan`: pass these straight to an OTLP trace exporter's `sink`. */\nexport interface WorkflowTraceSpan {\n readonly traceId: string; readonly spanId: string; readonly parentSpanId?: string; readonly name: string;\n readonly startTimeUnixNano: string; readonly endTimeUnixNano: string; readonly status: 'unset' | 'ok' | 'error';\n readonly runId?: string; readonly attributes?: WorkflowTraceAttributes;\n}\nexport interface WorkflowTraceContext { readonly traceId: string; readonly spanId: string }\n/** What the projection reads from a definition: identity and node ids, kinds and tool identities. Every format's definition qualifies. */\nexport interface WorkflowTraceDefinition {\n readonly id: string; readonly version: string; readonly digest: string;\n readonly nodes: readonly { readonly id: string; readonly kind: string; readonly tool?: { readonly id: string; readonly version: string; readonly costMicros?: number } }[];\n}\n/** What the projection reads from a settled snapshot. Every runtime's `inspect()` result qualifies. */\nexport interface WorkflowTraceSnapshot {\n readonly status: string;\n readonly steps: Readonly<Record<string, { readonly kind: string; readonly status: string }>>;\n readonly budget?: unknown;\n}\nexport interface WorkflowTraceInput {\n readonly runId: string;\n readonly snapshot: WorkflowTraceSnapshot;\n /** The run's complete durable log from sequence 1, as `runtime.events(id, after)` pages it. */\n readonly events: readonly StoredEvent[];\n readonly definition?: WorkflowTraceDefinition;\n}\n\nconst runPattern = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/;\nconst nodePattern = /^[A-Za-z][A-Za-z0-9._-]{0,127}$/;\nconst stable = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,255}$/;\nconst codePattern = /^[A-Z][A-Z0-9_]{0,63}$/;\nconst settled = new Set(['succeeded', 'failed', 'blocked', 'cancelled', 'outcome_unknown']);\n/** Normalized (`lifecycle.` prefix removed) event types after which a step changes no more. */\nconst stepEnds = new Set(['step.completed', 'step.failed', 'step.blocked', 'step.skipped', 'step.bypassed', 'step.output_blocked', 'human.responded',\n 'human.timed_out', 'human.invalid', 'timer.fired', 'timer.invalid', 'workflow.wait_resolved', 'workflow.child_joined']);\nconst failures = new Set(['step.failed', 'step.blocked', 'step.output_blocked']);\n\nfunction derived(domain: string, value: JsonObject, length: 16 | 32): string {\n const hex = digest(domain, value).slice(0, length);\n return /^0+$/.test(hex) ? `${hex.slice(0, -1)}1` : hex;\n}\nconst nanos = (milliseconds: number): string => (BigInt(milliseconds) * 1_000_000n).toString();\nconst spanStatus = (status: string): WorkflowTraceSpan['status'] =>\n status === 'succeeded' ? 'ok' : ['failed', 'blocked', 'outcome_unknown', 'unknown', 'timed_out'].includes(status) ? 'error' : 'unset';\nconst integer = (value: unknown): value is number => typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;\nconst field = (value: unknown, key: string): unknown => value !== null && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>)[key] : undefined;\n\n/** The root span of a run (no node), or the span of one of its steps. Parent your own spans under these. */\nexport function workflowTraceContext(runId: string, nodeId?: string): WorkflowTraceContext {\n if (typeof runId !== 'string' || !runPattern.test(runId) || (nodeId !== undefined && (typeof nodeId !== 'string' || !nodePattern.test(nodeId)))) {\n throw new MayuraError('INVALID_INPUT', 'A workflow trace context requires a bounded run id and node id.');\n }\n return Object.freeze({ traceId: derived('mayura:workflow-trace:v1', { runId }, 32), spanId: derived('mayura:workflow-span:v1', { runId, nodeId: nodeId ?? null }, 16) });\n}\n\n/**\n * The span of the step a tool is executing in, from its execution context: every format calls a step's tool with\n * `callId` `<runId>/step:<nodeId>`. Spans produced inside the tool (for example an agent run's, via\n * `agentRunTraceSpans(events, { parent })`) then nest under that step in the run's trace.\n */\nexport function workflowStepTraceContext(context: { readonly runId: string; readonly callId: string }): WorkflowTraceContext {\n const prefix = `${context?.runId}/step:`;\n if (typeof context?.callId !== 'string' || !context.callId.startsWith(prefix)) throw new MayuraError('INVALID_INPUT', 'The execution context is not a workflow step call.');\n return workflowTraceContext(context.runId, context.callId.slice(prefix.length));\n}\n\n/**\n * Project a settled run into spans: the root (`workflow:<definitionId>`) spans the whole log, and each step\n * (`<kind>:<nodeId>`) spans its first to its last settling event (or the run's end, for a step that never settled on\n * its own, such as one skipped by cancellation). Times are the store's event timestamps.\n */\nexport function workflowTraceSpans(input: WorkflowTraceInput): WorkflowTraceSpan[] {\n const { runId, snapshot, definition } = input; const events = input.events;\n if (!Array.isArray(events) || events.length === 0 || !snapshot || typeof snapshot.status !== 'string' || !snapshot.steps || typeof snapshot.steps !== 'object') {\n throw new MayuraError('INVALID_INPUT', 'A workflow trace requires the settled snapshot and the complete event log.');\n }\n const root = workflowTraceContext(runId);\n const times = events.map((event, index) => {\n const time = Date.parse(event?.createdAt);\n if (event?.sequence !== index + 1 || typeof event.type !== 'string' || !event.data || typeof event.data !== 'object' || !Number.isSafeInteger(time) || time < 0) {\n throw new MayuraError('INVALID_INPUT', 'A workflow trace requires the complete, ordered event log from sequence 1.');\n }\n return time;\n });\n // Store clocks can step backwards across processes; clamp so no span ends before it starts or before the run.\n const runStart = times[0]!; const runEnd = Math.max(...times);\n const nodes = new Map((definition?.nodes ?? []).map(node => [node.id, node]));\n const seen = new Map<string, { first: number; end?: number; code?: string; child?: string }>();\n events.forEach((event, index) => {\n const nodeId = event.data['nodeId']; if (typeof nodeId !== 'string' || !Object.hasOwn(snapshot.steps, nodeId)) return;\n const type = event.type.startsWith('lifecycle.') ? event.type.slice('lifecycle.'.length) : event.type;\n const entry = seen.get(nodeId) ?? { first: Math.max(runStart, times[index]!) }; seen.set(nodeId, entry);\n if (stepEnds.has(type)) entry.end = Math.max(entry.first, times[index]!);\n // Fixed upper-case codes only (BUDGET_EXCEEDED, PERMISSION_DENIED, OUTPUT_LIMIT, ...); never a message.\n const code = event.data['code'] ?? event.data['reason'];\n if (failures.has(type) && typeof code === 'string' && codePattern.test(code)) entry.code = code;\n const child = event.data['childId'];\n if (type === 'workflow.child_admitted' && typeof child === 'string' && stable.test(child)) entry.child = child;\n });\n const order = [...nodes.keys(), ...Object.keys(snapshot.steps).filter(id => !nodes.has(id)).sort()].filter(id => Object.hasOwn(snapshot.steps, id));\n const steps = order.map((nodeId): WorkflowTraceSpan => {\n const step = snapshot.steps[nodeId]!; const node = nodes.get(nodeId); const entry = seen.get(nodeId);\n const kind = typeof step.kind === 'string' && stable.test(step.kind) ? step.kind : 'step';\n const status = typeof step.status === 'string' && stable.test(step.status) ? step.status : 'unknown';\n const start = entry?.first ?? runEnd; const end = Math.max(start, entry?.end ?? runEnd);\n const attributes: Record<string, string | number> = { 'mayura.workflow.node.id': nodeId, 'mayura.workflow.node.kind': kind, 'mayura.workflow.step.status': status };\n if (entry?.code) attributes['mayura.workflow.step.code'] = entry.code;\n const execution = field(field(step, 'receipt'), 'execution');\n if (typeof execution === 'string' && stable.test(execution)) attributes['mayura.workflow.receipt.execution'] = execution;\n const child = entry?.child ?? field(field(step, 'child'), 'runId');\n if (typeof child === 'string' && stable.test(child)) attributes['mayura.workflow.child.run.id'] = child;\n if (node?.tool && typeof node.tool.id === 'string' && stable.test(node.tool.id)) attributes['mayura.tool.id'] = node.tool.id;\n if (node?.tool && typeof node.tool.version === 'string' && stable.test(node.tool.version)) attributes['mayura.tool.version'] = node.tool.version;\n if (node?.tool && integer(node.tool.costMicros)) attributes['mayura.budget.step_cost_micros'] = node.tool.costMicros;\n return Object.freeze({ traceId: root.traceId, spanId: workflowTraceContext(runId, nodeId).spanId, parentSpanId: root.spanId,\n name: stable.test(`${kind}:${nodeId}`) ? `${kind}:${nodeId}` : 'workflow.step', runId, status: spanStatus(status),\n startTimeUnixNano: nanos(start), endTimeUnixNano: nanos(end), attributes: Object.freeze(attributes) });\n });\n const attributes: Record<string, string | number> = { 'mayura.workflow.status': stable.test(snapshot.status) ? snapshot.status : 'unknown', 'mayura.workflow.events': events.length };\n if (definition && stable.test(definition.id)) attributes['mayura.workflow.definition.id'] = definition.id;\n if (definition && stable.test(definition.version)) attributes['mayura.workflow.definition.version'] = definition.version;\n if (definition && /^[a-f0-9]{64}$/.test(definition.digest)) attributes['mayura.workflow.definition.digest'] = definition.digest;\n for (const [key, name] of [['spentMicros', 'mayura.budget.spent_micros'], ['reservedMicros', 'mayura.budget.reserved_micros'], ['maxCostMicros', 'mayura.budget.max_micros']] as const) {\n const value = field(snapshot.budget, key); if (integer(value)) attributes[name] = value;\n }\n const name = definition && stable.test(`workflow:${definition.id}`) ? `workflow:${definition.id}` : 'workflow.run';\n return [Object.freeze({ traceId: root.traceId, spanId: root.spanId, name, runId, status: spanStatus(snapshot.status),\n startTimeUnixNano: nanos(runStart), endTimeUnixNano: nanos(runEnd), attributes: Object.freeze(attributes) }), ...steps];\n}\n\n// ---- Durable export --------------------------------------------------------------------------------------------------\n\n/** Any workflow runtime of the same format: `inspect` for the settled snapshot and `events` for its durable log. */\nexport interface WorkflowTraceSource {\n inspect(id: string): Promise<WorkflowTraceSnapshot>;\n events(id: string, after?: number): Promise<readonly StoredEvent[]>;\n}\n/** An OTLP trace exporter's `sink` qualifies. It is called one batch at a time. */\nexport type WorkflowTraceSink = (spans: readonly WorkflowTraceSpan[], context: { readonly signal: AbortSignal }) => Promise<void>;\nexport interface WorkflowTraceExportOptions {\n readonly source: WorkflowTraceSource;\n /** Holds the export's durable outbox and per-run markers. May be the store the workflows use. */\n readonly store: AggregateStore;\n readonly scope: Scope;\n /** Separates independent exports of the same runs, for example two collectors. */\n readonly exportId: string;\n /** Every definition version whose runs may be exported; runs of another digest export without definition attributes. */\n readonly definitions: readonly WorkflowTraceDefinition[];\n readonly sink: WorkflowTraceSink;\n /** Spans per sink call (default 128, at most 256: the OTLP exporter's batch bound). */\n readonly maxBatchSize?: number;\n /** Runs the durable outbox may hold (default 4096, at most 16384). `track` refuses beyond it. */\n readonly maxPending?: number;\n /** Events one run's log may hold for export (default 100000). */\n readonly maxEvents?: number;\n}\nexport interface WorkflowTraceExportResult {\n readonly runId: string;\n /** `exported`: sent and marked. `unchanged`: already exported at this log position. `unsettled`: not terminal yet. */\n readonly status: 'exported' | 'unchanged' | 'unsettled';\n readonly spans: number;\n /** The last event sequence the export covers (0 when unsettled). */\n readonly sequence: number;\n}\nexport interface WorkflowTraceFlushReport {\n readonly examined: number; readonly exported: number; readonly unchanged: number; readonly unsettled: number;\n /** Runs dropped from the outbox because the source no longer knows them. */\n readonly missing: number;\n readonly failed: number; readonly lastError: ErrorCode | null;\n}\nexport interface WorkflowTraceUnitOptions {\n readonly intervalMs?: number;\n /** Runs examined per flush (default 32). */\n readonly limit?: number;\n /** Optional discovery of active runs (any fleet or version target), tracked on every cycle as a safety net for runs never passed to `track`. */\n readonly targets?: readonly { discover(cursor: JsonValue | null, limit: number): Promise<{ readonly runIds: readonly string[]; readonly nextCursor: JsonValue | null }> }[];\n}\nexport interface WorkflowTraceExport {\n /** Durably remember a run (idempotent) so the unit or `flush` exports it once it settles, across restarts. */\n track(runId: string): Promise<void>;\n /** Export one run now if it has settled and its log grew since the last export. Safe to repeat: ids are deterministic. */\n exportRun(runId: string, options?: { readonly signal?: AbortSignal }): Promise<WorkflowTraceExportResult>;\n /** Export settled runs from the outbox (round robin, at most `limit`) and forget them once exported. */\n flush(options?: { readonly signal?: AbortSignal; readonly limit?: number }): Promise<WorkflowTraceFlushReport>;\n /** Run ids still waiting in the durable outbox. */\n pending(): Promise<readonly string[]>;\n /** A worker unit that discovers (optionally), then flushes, every `intervalMs` (default 1 s) while it runs. */\n unit(options?: WorkflowTraceUnitOptions): WorkflowWorkerUnit;\n}\n\nconst exportPattern = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/;\nfunction bounded(value: number | undefined, fallback: number, maximum: number, name: string): number {\n const result = value ?? fallback;\n if (!Number.isSafeInteger(result) || result < 1 || result > maximum) throw new MayuraError('INVALID_CONFIG', `${name} is outside its bound.`);\n return result;\n}\nconst sleep = (milliseconds: number, signal: AbortSignal): Promise<void> => new Promise(resolve => {\n if (signal.aborted) { resolve(); return; }\n const timer = setTimeout(done, milliseconds); function done(): void { clearTimeout(timer); signal.removeEventListener('abort', done); resolve(); }\n signal.addEventListener('abort', done, { once: true });\n});\n\n/**\n * Restart-safe export of settled workflow runs. Durable state is an outbox of tracked run ids and, per run, the log\n * position last exported. A crash before the marker is written re-exports the run later with identical ids (a\n * collector deduplicates); a crash after it only leaves the run in the outbox, where the next flush finds it unchanged\n * and drops it. Nothing here can change, block or fail a workflow run.\n */\nexport function createWorkflowTraceExport(options: WorkflowTraceExportOptions): WorkflowTraceExport {\n const { source, store, sink } = options;\n if (!source || typeof source.inspect !== 'function' || typeof source.events !== 'function' || !store || typeof store.read !== 'function'\n || typeof store.create !== 'function' || typeof store.update !== 'function' || typeof sink !== 'function' || typeof options.exportId !== 'string'\n || !exportPattern.test(options.exportId) || typeof options.scope?.principalId !== 'string' || typeof options.scope?.projectId !== 'string' || !Array.isArray(options.definitions)) {\n throw new MayuraError('INVALID_CONFIG', 'A workflow trace export requires a source, a store, a scope, a bounded export id, definitions and a sink.');\n }\n const maxBatchSize = bounded(options.maxBatchSize, 128, 256, 'maxBatchSize'); const maxPending = bounded(options.maxPending, 4_096, 16_384, 'maxPending');\n const maxEvents = bounded(options.maxEvents, 100_000, 10_000_000, 'maxEvents'); const exportId = options.exportId;\n const definitions = new Map(options.definitions.map(definition => {\n if (typeof definition?.digest !== 'string' || !Array.isArray(definition.nodes)) throw new MayuraError('INVALID_CONFIG', 'Trace definitions must be workflow definitions with a digest.');\n return [definition.digest, definition] as const;\n }));\n const scope = digest('mayura:scope:v1', { principalId: options.scope.principalId, projectId: options.scope.projectId });\n const formatHash = digest('mayura:workflow-trace-export-format:v1', {});\n const outboxId = digest('mayura:workflow-trace-outbox:v1', { exportId });\n const markerId = (runId: string): string => digest('mayura:workflow-trace-export:v1', { exportId, runId });\n const guarded = async <T>(operation: () => Promise<T>): Promise<T> => {\n try { return await operation(); }\n catch (error) { if (error instanceof MayuraError || (error instanceof StorageError && error.code === 'CONFLICT')) throw error;\n throw new MayuraError('STORAGE_UNAVAILABLE', 'Workflow trace export storage is unavailable.'); }\n };\n const corrupt = (): never => { throw new MayuraError('STORAGE_UNAVAILABLE', 'Stored workflow trace export state failed integrity validation.'); };\n const outboxOf = (record: StoredRecord | undefined): string[] => {\n if (!record) return []; const state = record.state; const pending = state['pending'];\n if (record.scope !== scope || record.id !== outboxId || state['format'] !== 1 || state['exportId'] !== exportId || !Array.isArray(pending) || pending.length > 16_384\n || pending.some((id, index) => typeof id !== 'string' || !runPattern.test(id) || (index > 0 && id <= (pending[index - 1] as string)))) return corrupt();\n return pending as string[];\n };\n const markerOf = (record: StoredRecord | undefined, runId: string): number => {\n if (!record) return 0; const state = record.state;\n if (record.scope !== scope || record.id !== markerId(runId) || state['format'] !== 1 || state['exportId'] !== exportId || state['runId'] !== runId\n || !Number.isSafeInteger(state['sequence']) || (state['sequence'] as number) < 0) return corrupt();\n return state['sequence'] as number;\n };\n /** Compare-and-set write of one export record; `next` returns undefined when nothing needs to change. */\n const change = async (id: string, type: string, next: (record: StoredRecord | undefined) => JsonObject | undefined): Promise<void> => {\n for (let attempt = 0; attempt < 32; attempt++) {\n const record = await guarded(() => store.read(scope, id)); const state = next(record); if (state === undefined) return;\n try {\n if (record) { await guarded(() => store.update({ scope, id, expectedVersion: record.version, state, events: [{ type, data: {} }] })); return; }\n if ((await guarded(() => store.create({ scope, id, idempotencyKey: id, definitionHash: formatHash, state, events: [{ type, data: {} }] }))).created) return;\n } catch (error) { if (!(error instanceof StorageError && error.code === 'CONFLICT')) throw error; }\n }\n throw new MayuraError('CONFLICT', 'Workflow trace export contention exceeded its bounded retry limit.');\n };\n const add = (runIds: readonly string[]): Promise<void> => change(outboxId, 'workflow-trace.tracked', record => {\n const pending = outboxOf(record); const merged = [...new Set([...pending, ...runIds])].sort();\n if (merged.length === pending.length) return undefined;\n if (merged.length > maxPending) throw new MayuraError('LIMIT_EXCEEDED', 'The workflow trace outbox is full.');\n return { format: 1, exportId, pending: merged };\n });\n const remove = (runIds: readonly string[]): Promise<void> => change(outboxId, 'workflow-trace.exported', record => {\n const pending = outboxOf(record); const drop = new Set(runIds); const kept = pending.filter(id => !drop.has(id));\n return kept.length === pending.length ? undefined : { format: 1, exportId, pending: kept };\n });\n const validRun = (runId: unknown): string => {\n if (typeof runId !== 'string' || !runPattern.test(runId)) throw new MayuraError('INVALID_INPUT', 'A bounded workflow run id is required.');\n return runId;\n };\n // The OTLP exporter is single-flight: one run's batches go out together, and runs queue behind each other.\n let tail: Promise<unknown> = Promise.resolve();\n const exclusive = <T>(operation: () => Promise<T>): Promise<T> => { const result = tail.then(operation, operation); tail = result.catch(() => undefined); return result; };\n\n const exportRun = async (rawId: string, runOptions: { readonly signal?: AbortSignal } = {}): Promise<WorkflowTraceExportResult> => {\n const runId = validRun(rawId); const signal = runOptions.signal ?? new AbortController().signal;\n const snapshot = await source.inspect(runId);\n if (!settled.has(snapshot?.status)) return Object.freeze({ runId, status: 'unsettled', spans: 0, sequence: 0 });\n const events: StoredEvent[] = [];\n for (;;) {\n const page = await source.events(runId, events.length);\n if (!Array.isArray(page)) throw new MayuraError('STORAGE_UNAVAILABLE', 'The workflow event source returned an invalid page.');\n if (page.length === 0) break;\n events.push(...page);\n if (events.length > maxEvents) throw new MayuraError('LIMIT_EXCEEDED', 'The workflow run log exceeds the trace export bound.');\n }\n const sequence = events.length;\n if (markerOf(await guarded(() => store.read(scope, markerId(runId))), runId) >= sequence) return Object.freeze({ runId, status: 'unchanged', spans: 0, sequence });\n const pinned = (await guarded(() => store.read(scope, runId)))?.definitionHash;\n const definition = pinned === undefined ? undefined : definitions.get(pinned);\n const spans = workflowTraceSpans({ runId, snapshot, events, ...(definition ? { definition } : {}) });\n await exclusive(async () => {\n for (let index = 0; index < spans.length; index += maxBatchSize) {\n if (signal.aborted) throw new MayuraError('CANCELLED', 'Workflow trace export was cancelled.');\n await sink(Object.freeze(spans.slice(index, index + maxBatchSize)), { signal });\n }\n });\n // Mark only after every batch was accepted; a later, longer log (a late receipt, a reconciliation) exports again.\n await change(markerId(runId), 'workflow-trace.marked', record => markerOf(record, runId) >= sequence ? undefined : { format: 1, exportId, runId, sequence });\n return Object.freeze({ runId, status: 'exported', spans: spans.length, sequence });\n };\n\n let cursor = '';\n const flush = async (flushOptions: { readonly signal?: AbortSignal; readonly limit?: number } = {}): Promise<WorkflowTraceFlushReport> => {\n const limit = bounded(flushOptions.limit, 32, 1_024, 'limit');\n const pending = outboxOf(await guarded(() => store.read(scope, outboxId)));\n // Round robin from where the last flush stopped, so long-running runs cannot starve the rest.\n const start = pending.findIndex(id => id > cursor); const ordered = start < 0 ? pending : [...pending.slice(start), ...pending.slice(0, start)];\n const counts = { examined: 0, exported: 0, unchanged: 0, unsettled: 0, missing: 0, failed: 0 }; let lastError: ErrorCode | null = null; const done: string[] = [];\n for (const runId of ordered.slice(0, limit)) {\n if (flushOptions.signal?.aborted) break;\n counts.examined++; cursor = runId;\n try {\n const result = await exportRun(runId, flushOptions.signal ? { signal: flushOptions.signal } : {});\n counts[result.status]++; if (result.status !== 'unsettled') done.push(runId);\n } catch (error) {\n const code: ErrorCode = error instanceof MayuraError ? error.code : 'TOOL_FAILED';\n if (code === 'NOT_FOUND') { counts.missing++; done.push(runId); } else { counts.failed++; lastError = code; }\n }\n }\n if (done.length > 0) await remove(done);\n return Object.freeze({ ...counts, lastError });\n };\n\n return Object.freeze<WorkflowTraceExport>({\n track: async runId => add([validRun(runId)]),\n exportRun, flush,\n pending: async () => Object.freeze([...outboxOf(await guarded(() => store.read(scope, outboxId)))]),\n unit(unitOptions = {}) {\n const intervalMs = bounded(unitOptions.intervalMs, 1_000, 3_600_000, 'intervalMs'); const limit = bounded(unitOptions.limit, 32, 1_024, 'limit');\n const targets = [...(unitOptions.targets ?? [])];\n if (targets.length > 32 || targets.some(target => typeof target?.discover !== 'function')) throw new MayuraError('INVALID_CONFIG', 'Trace discovery takes up to 32 targets with discover().');\n let controller: AbortController | undefined; let loop: Promise<void> | undefined;\n const discover = async (signal: AbortSignal): Promise<void> => {\n for (const target of targets) {\n let next: JsonValue | null = null; let pages = 0;\n do {\n const page = await target.discover(next, 32); const ids = page.runIds.filter(id => typeof id === 'string' && runPattern.test(id));\n if (ids.length > 0) await add(ids);\n next = page.nextCursor; pages++;\n } while (next !== null && pages < 64 && !signal.aborted);\n }\n };\n const stop = async (): Promise<void> => { controller?.abort(); await loop; controller = undefined; loop = undefined; };\n return Object.freeze<WorkflowWorkerUnit>({\n start() {\n if (loop) return; controller = new AbortController(); const signal = controller.signal;\n loop = (async () => {\n while (!signal.aborted) {\n // Telemetry is best effort: a failed cycle is retried on the next one and never stops the worker.\n try { await discover(signal); } catch { /* Discovery resumes next cycle. */ }\n try { await flush({ signal, limit }); } catch { /* The outbox keeps every unexported run. */ }\n await sleep(intervalMs, signal);\n }\n })();\n },\n stop,\n async drain(_options?: WorkflowDrainOptions): Promise<WorkflowDrainReport> { await stop(); return Object.freeze({ drained: true, interrupted: 0 }); },\n });\n },\n });\n}\n"]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type JsonValue, type Scope } from '../../core/dist/index.js';
|
|
2
|
+
import type { AggregateStore } from '../../storage-contracts/dist/index.js';
|
|
3
|
+
import type { WorkflowCompositeFleetRuntime } from './composite-fleet.js';
|
|
4
|
+
/**
|
|
5
|
+
* Definition-version policy. A durable run is pinned to its definition digest. A deployment either keeps every
|
|
6
|
+
* digest that still has active runs registered with its hosts (versions run side by side), or drains, or cancels
|
|
7
|
+
* those runs first. Mayura never interprets stored state with a different definition. This inventory is how
|
|
8
|
+
* operators and deploy gates see which versions are still required.
|
|
9
|
+
*/
|
|
10
|
+
/** Read-only discovery for one format. Every `WorkflowFleetTarget` is also a version target. */
|
|
11
|
+
export interface WorkflowVersionTarget {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
discover(cursor: JsonValue | null, limit: number): Promise<{
|
|
14
|
+
readonly runIds: readonly string[];
|
|
15
|
+
readonly nextCursor: JsonValue | null;
|
|
16
|
+
}>;
|
|
17
|
+
inspect(runId: string): Promise<{
|
|
18
|
+
readonly status: string;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
export interface WorkflowVersionEntry {
|
|
22
|
+
readonly definitionHash: string;
|
|
23
|
+
/** Non-terminal runs (running, waiting or paused) pinned to this digest. */
|
|
24
|
+
readonly activeRuns: number;
|
|
25
|
+
readonly registered: boolean;
|
|
26
|
+
readonly targets: readonly string[];
|
|
27
|
+
}
|
|
28
|
+
export interface WorkflowVersionInventory {
|
|
29
|
+
readonly versions: readonly WorkflowVersionEntry[];
|
|
30
|
+
/** Active digests no registered definition can execute: deploying without them strands runs. */
|
|
31
|
+
readonly unregistered: readonly string[];
|
|
32
|
+
/** Registered digests with no active run: safe to retire once new submissions use the new version. */
|
|
33
|
+
readonly retirable: readonly string[];
|
|
34
|
+
/** False when a bound stopped the scan early; a gate must not pass an incomplete inventory. */
|
|
35
|
+
readonly complete: boolean;
|
|
36
|
+
readonly scanned: number;
|
|
37
|
+
}
|
|
38
|
+
export interface WorkflowVersionInventoryOptions {
|
|
39
|
+
readonly store: AggregateStore;
|
|
40
|
+
readonly scope: Scope;
|
|
41
|
+
/** Every format's discovery; paused runs must be included (see `lifecycleFleetTarget(..., { includePaused: true })`). */
|
|
42
|
+
readonly targets: readonly WorkflowVersionTarget[];
|
|
43
|
+
/** Definitions (or digests) the next deployment will register. */
|
|
44
|
+
readonly registered: readonly ({
|
|
45
|
+
readonly digest: string;
|
|
46
|
+
} | string)[];
|
|
47
|
+
/** Maximum runs examined across all targets (default 10,000; maximum 1,000,000). */
|
|
48
|
+
readonly maxRuns?: number;
|
|
49
|
+
readonly pageLimit?: number;
|
|
50
|
+
}
|
|
51
|
+
/** Count active runs per pinned definition digest across the given format targets. Read-only. */
|
|
52
|
+
export declare function inventoryWorkflowVersions(options: WorkflowVersionInventoryOptions): Promise<WorkflowVersionInventory>;
|
|
53
|
+
/** Deploy gate: throws unless the inventory is complete and every active digest stays registered. */
|
|
54
|
+
export declare function assertWorkflowVersionsRetained(inventory: WorkflowVersionInventory): void;
|
|
55
|
+
/** Saga and loop runs from the composite fleet index, for inventories. */
|
|
56
|
+
export declare function compositeVersionTarget(runtime: WorkflowCompositeFleetRuntime, name?: string): WorkflowVersionTarget;
|
|
57
|
+
//# sourceMappingURL=versions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versions.d.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AM,CAAC;CAC1B;AACD,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,yHAAyH;IACzH,QAAQ,CAAC,OAAO,EAAE,SAAS,qBAAqB,EAAE,CAAC;IACnD,kEAAkE;IAClE,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,EAAE,CAAC;IACvE,oFAAoF;IACpF,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAKD,iGAAiG;AACjG,wBAAsB,yBAAyB,CAAC,OAAO,EAAE,+BAA+B,GAAG,OAAO,CAAC,wBAAwB,CAAC,CA0C3H;AAED,qGAAqG;AACrG,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,wBAAwB,GAAG,IAAI,CAKxF;AAED,0EAA0E;AAC1E,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,6BAA6B,EAAE,IAAI,SAAe,GAAG,qBAAqB,CAUzH"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { MayuraError } from '../../core/dist/index.js';
|
|
2
|
+
import { digest } from './definition.js';
|
|
3
|
+
const hashPattern = /^[a-f0-9]{64}$/;
|
|
4
|
+
const terminal = new Set(['succeeded', 'failed', 'blocked', 'cancelled', 'outcome_unknown', 'compensated', 'limit_exceeded']);
|
|
5
|
+
/** Count active runs per pinned definition digest across the given format targets. Read-only. */
|
|
6
|
+
export async function inventoryWorkflowVersions(options) {
|
|
7
|
+
const { store } = options;
|
|
8
|
+
if (!store || typeof store.read !== 'function' || !Array.isArray(options.targets) || options.targets.length > 32 || !Array.isArray(options.registered)) {
|
|
9
|
+
throw new MayuraError('INVALID_CONFIG', 'A version inventory requires a store, 0–32 fleet targets and the registered definitions.');
|
|
10
|
+
}
|
|
11
|
+
const maxRuns = options.maxRuns ?? 10_000;
|
|
12
|
+
const pageLimit = options.pageLimit ?? 128;
|
|
13
|
+
if (!Number.isSafeInteger(maxRuns) || maxRuns < 1 || maxRuns > 1_000_000 || !Number.isSafeInteger(pageLimit) || pageLimit < 1 || pageLimit > 1_000) {
|
|
14
|
+
throw new MayuraError('INVALID_CONFIG', 'Inventory bounds are outside their limits.');
|
|
15
|
+
}
|
|
16
|
+
const registered = new Set(options.registered.map(entry => {
|
|
17
|
+
const value = typeof entry === 'string' ? entry : entry?.digest;
|
|
18
|
+
if (typeof value !== 'string' || !hashPattern.test(value))
|
|
19
|
+
throw new MayuraError('INVALID_CONFIG', 'Registered definitions must carry a 64-hex digest.');
|
|
20
|
+
return value;
|
|
21
|
+
}));
|
|
22
|
+
const scopeKey = digest('mayura:scope:v1', { principalId: options.scope?.principalId, projectId: options.scope?.projectId });
|
|
23
|
+
const counts = new Map();
|
|
24
|
+
const seen = new Set();
|
|
25
|
+
let scanned = 0;
|
|
26
|
+
let complete = true;
|
|
27
|
+
for (const target of options.targets) {
|
|
28
|
+
let cursor = null;
|
|
29
|
+
do {
|
|
30
|
+
if (scanned >= maxRuns) {
|
|
31
|
+
complete = false;
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
const page = await target.discover(cursor, Math.min(pageLimit, maxRuns - scanned));
|
|
35
|
+
for (const runId of page.runIds) {
|
|
36
|
+
if (seen.has(`${target.name}:${runId}`))
|
|
37
|
+
continue;
|
|
38
|
+
seen.add(`${target.name}:${runId}`);
|
|
39
|
+
scanned++;
|
|
40
|
+
const status = (await target.inspect(runId)).status;
|
|
41
|
+
if (terminal.has(status))
|
|
42
|
+
continue;
|
|
43
|
+
const record = await store.read(scopeKey, runId);
|
|
44
|
+
if (!record || !hashPattern.test(record.definitionHash)) {
|
|
45
|
+
complete = false;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const entry = counts.get(record.definitionHash) ?? { activeRuns: 0, targets: new Set() };
|
|
49
|
+
entry.activeRuns++;
|
|
50
|
+
entry.targets.add(target.name);
|
|
51
|
+
counts.set(record.definitionHash, entry);
|
|
52
|
+
}
|
|
53
|
+
cursor = page.nextCursor;
|
|
54
|
+
} while (cursor !== null);
|
|
55
|
+
}
|
|
56
|
+
const versions = [...counts.entries()].sort(([a], [b]) => (a < b ? -1 : 1)).map(([definitionHash, entry]) => Object.freeze({
|
|
57
|
+
definitionHash, activeRuns: entry.activeRuns, registered: registered.has(definitionHash), targets: Object.freeze([...entry.targets].sort())
|
|
58
|
+
}));
|
|
59
|
+
return Object.freeze({
|
|
60
|
+
versions: Object.freeze(versions),
|
|
61
|
+
unregistered: Object.freeze(versions.filter(entry => !entry.registered).map(entry => entry.definitionHash)),
|
|
62
|
+
retirable: Object.freeze([...registered].filter(hash => !counts.has(hash)).sort()),
|
|
63
|
+
complete, scanned,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/** Deploy gate: throws unless the inventory is complete and every active digest stays registered. */
|
|
67
|
+
export function assertWorkflowVersionsRetained(inventory) {
|
|
68
|
+
if (!inventory.complete)
|
|
69
|
+
throw new MayuraError('LIMIT_EXCEEDED', 'The workflow version inventory is incomplete; raise maxRuns before deploying.');
|
|
70
|
+
if (inventory.unregistered.length > 0) {
|
|
71
|
+
throw new MayuraError('CONFLICT', `Active workflow runs are pinned to ${inventory.unregistered.length} definition version(s) the deployment does not register. Keep them registered, or drain or cancel those runs first.`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** Saga and loop runs from the composite fleet index, for inventories. */
|
|
75
|
+
export function compositeVersionTarget(runtime, name = 'composites') {
|
|
76
|
+
const kinds = new Map();
|
|
77
|
+
return Object.freeze({ name,
|
|
78
|
+
discover: async (cursor, limit) => {
|
|
79
|
+
const page = await runtime.scan({ cursor: cursor, limit: Math.min(limit, 128) });
|
|
80
|
+
for (const candidate of page.candidates)
|
|
81
|
+
kinds.set(candidate.runId, candidate.kind);
|
|
82
|
+
return { runIds: page.candidates.map(candidate => candidate.runId), nextCursor: page.nextCursor };
|
|
83
|
+
},
|
|
84
|
+
inspect: async (runId) => kinds.get(runId) === 'loop' ? runtime.loops.inspect(runId) : runtime.sagas.inspect(runId),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=versions.js.map
|