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,646 @@
|
|
|
1
|
+
/** Browser-safe wire values; this package has no privileged runtime or Node imports. */
|
|
2
|
+
import type { WorkflowViewFormat, WorkflowViewInput, WorkflowViewNodeKind, WorkflowViewRunStatus } from './workflows.js';
|
|
3
|
+
|
|
4
|
+
export type ClientJson = null | boolean | number | string | readonly ClientJson[] | { readonly [key: string]: ClientJson };
|
|
5
|
+
export interface ClientSchema<T> {
|
|
6
|
+
readonly '~standard': { readonly version: 1; validate(value: unknown): { readonly value: T; readonly issues?: undefined } | { readonly issues: readonly unknown[] } | PromiseLike<{ readonly value: T; readonly issues?: undefined } | { readonly issues: readonly unknown[] }> };
|
|
7
|
+
}
|
|
8
|
+
export type RemoteStatus = 'running' | 'succeeded' | 'failed' | 'blocked' | 'cancelled' | 'outcome_unknown';
|
|
9
|
+
export type RemoteOutcome<T> = { readonly status: 'succeeded'; readonly output: T; readonly evidence: readonly RemoteReceipt[] }
|
|
10
|
+
| { readonly status: Exclude<RemoteStatus, 'running' | 'succeeded'>; readonly error: { readonly code: string }; readonly evidence: readonly RemoteReceipt[] };
|
|
11
|
+
export interface RemoteReceipt {
|
|
12
|
+
readonly runId: string;
|
|
13
|
+
readonly receipt: { readonly callId: string; readonly toolId: string; readonly execution: 'not_started' | 'succeeded' | 'failed' | 'unknown'; readonly disclosure: 'released' | 'withheld' };
|
|
14
|
+
}
|
|
15
|
+
export interface RemoteSnapshot {
|
|
16
|
+
readonly id: string; readonly status: RemoteStatus;
|
|
17
|
+
readonly budget: { readonly spentMicros: number | string; readonly reservedMicros: number; readonly calls: number };
|
|
18
|
+
readonly evidence: readonly RemoteReceipt[];
|
|
19
|
+
}
|
|
20
|
+
export interface ClientEvent {
|
|
21
|
+
readonly runId: string; readonly sequence: number; readonly timestamp: string;
|
|
22
|
+
readonly type: 'run.started' | 'model.started' | 'model.completed' | 'tool.started' | 'tool.completed'
|
|
23
|
+
| 'hook.started' | 'hook.completed' | 'step.started' | 'step.completed' | 'delegate.started' | 'delegate.completed'
|
|
24
|
+
| 'run.completed' | 'events.gap' | 'output.delta' | 'output.withheld';
|
|
25
|
+
readonly metadata: Readonly<Record<string, string | number | boolean>>;
|
|
26
|
+
}
|
|
27
|
+
export interface RemoteRun {
|
|
28
|
+
readonly id: string;
|
|
29
|
+
inspect(options?: { readonly signal?: AbortSignal }): Promise<RemoteSnapshot>;
|
|
30
|
+
/** Returns undefined while running; terminal output requires a wire-output schema. No polling/retry is implicit. */
|
|
31
|
+
result<T>(schema: ClientSchema<T>, options?: { readonly signal?: AbortSignal }): Promise<RemoteOutcome<T> | undefined>;
|
|
32
|
+
cancel(options?: { readonly signal?: AbortSignal }): Promise<void>;
|
|
33
|
+
events(options?: { readonly after?: number; readonly signal?: AbortSignal }): AsyncIterable<ClientEvent>;
|
|
34
|
+
}
|
|
35
|
+
export interface RemoteHumanRequest {
|
|
36
|
+
readonly id: string; readonly agentId: string; readonly kind: 'information' | 'correction' | 'plan_selection';
|
|
37
|
+
readonly schemaId: string; readonly schemaDigest: string; readonly prompt: string; readonly digest: string;
|
|
38
|
+
readonly status: 'waiting' | 'answered' | 'cancelled' | 'timed_out'; readonly context?: ClientJson;
|
|
39
|
+
readonly subjectDigest?: string; readonly deadlineAtMs?: number;
|
|
40
|
+
}
|
|
41
|
+
export interface RemoteHumanRequestPage { readonly items: readonly RemoteHumanRequest[]; readonly next: string | null }
|
|
42
|
+
export interface WorkflowCommandOptions { readonly commandId: string; readonly signal?: AbortSignal }
|
|
43
|
+
export interface WorkflowApprovalCommand {
|
|
44
|
+
readonly revision: number; readonly nodeId: string; readonly approvalDigest: string; readonly childRunId?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface WorkflowSignalCommand {
|
|
47
|
+
readonly revision: number; readonly signalId: string; readonly signalName: string; readonly value: ClientJson;
|
|
48
|
+
}
|
|
49
|
+
export interface WorkflowIndexEntry {
|
|
50
|
+
readonly format: WorkflowViewFormat; readonly definitionId: string; readonly definitionVersion: string; readonly runId: string;
|
|
51
|
+
readonly revision: number; readonly status: WorkflowViewRunStatus;
|
|
52
|
+
/** Only in the settled view: when the run reached its final status. */
|
|
53
|
+
readonly settledAtMs?: number;
|
|
54
|
+
}
|
|
55
|
+
export interface WorkflowIndexPage { readonly items: readonly WorkflowIndexEntry[]; readonly next: string | null }
|
|
56
|
+
export interface WorkflowFleetHold { readonly held: boolean; readonly generation: number; readonly changedAtMs: number | null }
|
|
57
|
+
export type WorkflowFleetSweepOutcome =
|
|
58
|
+
| { readonly target: string; readonly runId: string;
|
|
59
|
+
readonly outcome: 'paused' | 'already_paused' | 'terminal' | 'busy' | 'resumed' | 'not_paused' | 'missing' | 'unregistered' }
|
|
60
|
+
| { readonly target: string; readonly runId: string; readonly outcome: 'failed'; readonly code: string };
|
|
61
|
+
/** One content-free sweep page. Pass `nextCursor` back unchanged to continue; null means the sweep is complete. */
|
|
62
|
+
export interface WorkflowFleetSweep { readonly outcomes: readonly WorkflowFleetSweepOutcome[]; readonly nextCursor: ClientJson | null }
|
|
63
|
+
/** A reviewed migration offered for runs pinned to its source definition version. */
|
|
64
|
+
export interface WorkflowMigrationOffer {
|
|
65
|
+
readonly id: string; readonly description: string;
|
|
66
|
+
readonly fromVersion: string; readonly toVersion: string; readonly fromDigest: string; readonly toDigest: string;
|
|
67
|
+
}
|
|
68
|
+
export type WorkflowMigrationAction = 'keep' | 'update' | 'reset' | 'accept' | 'add' | 'remove';
|
|
69
|
+
/** What a migration would do to one run; `allowed` is false exactly when `blockers` is non-empty. */
|
|
70
|
+
export interface WorkflowMigrationPlan {
|
|
71
|
+
readonly migrationId: string; readonly format: string; readonly runId: string; readonly fromDigest: string; readonly toDigest: string;
|
|
72
|
+
readonly entries: readonly { readonly action: WorkflowMigrationAction; readonly target?: string; readonly source?: string; readonly status?: string }[];
|
|
73
|
+
readonly blockers: readonly { readonly node: string; readonly reason: string }[];
|
|
74
|
+
readonly allowed: boolean;
|
|
75
|
+
}
|
|
76
|
+
export interface ClientOptions {
|
|
77
|
+
readonly baseUrl: string;
|
|
78
|
+
readonly token: () => string | Promise<string>;
|
|
79
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
80
|
+
readonly maxResponseBytes?: number;
|
|
81
|
+
readonly maxEventBytes?: number;
|
|
82
|
+
readonly requestTimeoutMs?: number;
|
|
83
|
+
}
|
|
84
|
+
export interface MayuraClient {
|
|
85
|
+
agents(options?: { readonly signal?: AbortSignal }): Promise<readonly { readonly id: string; readonly version: string }[]>;
|
|
86
|
+
submit(agentId: string, input: unknown, options: { readonly idempotencyKey: string; readonly signal?: AbortSignal }): Promise<RemoteRun>;
|
|
87
|
+
run(id: string): RemoteRun;
|
|
88
|
+
humanRequests(options?: { readonly after?: string; readonly limit?: number; readonly signal?: AbortSignal }): Promise<RemoteHumanRequestPage>;
|
|
89
|
+
humanRequest(id: string, options?: { readonly signal?: AbortSignal }): Promise<RemoteHumanRequest>;
|
|
90
|
+
workflow(id: string, options?: { readonly signal?: AbortSignal }): Promise<WorkflowViewInput>;
|
|
91
|
+
/** Active runs, or with `view: 'settled'` recently finished runs and runs whose outcome is unknown (needs reconciling). */
|
|
92
|
+
workflows(options?: { readonly after?: string; readonly limit?: number; readonly view?: 'active' | 'settled'; readonly signal?: AbortSignal }): Promise<WorkflowIndexPage>;
|
|
93
|
+
cancelWorkflow(id: string, revision: number, options: WorkflowCommandOptions): Promise<WorkflowViewInput>;
|
|
94
|
+
approveWorkflow(id: string, command: WorkflowApprovalCommand, options: WorkflowCommandOptions): Promise<WorkflowViewInput>;
|
|
95
|
+
signalWorkflow(id: string, command: WorkflowSignalCommand, options: WorkflowCommandOptions): Promise<WorkflowViewInput>;
|
|
96
|
+
resumeWorkflow(id: string, revision: number, options: WorkflowCommandOptions): Promise<WorkflowViewInput>;
|
|
97
|
+
/** Read the durable fleet hold for the authenticated scope. */
|
|
98
|
+
workflowFleet(options?: { readonly signal?: AbortSignal }): Promise<WorkflowFleetHold>;
|
|
99
|
+
/** Durably hold the authenticated scope's fleet; idempotent. Requires `workflows:fleet`. */
|
|
100
|
+
holdWorkflowFleet(options?: { readonly signal?: AbortSignal }): Promise<WorkflowFleetHold>;
|
|
101
|
+
/** Durably lift the fleet hold; resumes no run by itself. Requires `workflows:fleet`. */
|
|
102
|
+
releaseWorkflowFleet(options?: { readonly signal?: AbortSignal }): Promise<WorkflowFleetHold>;
|
|
103
|
+
/** Run one bounded pause or resume sweep page. Requires `workflows:fleet`; a wrong hold state is HTTP 409. */
|
|
104
|
+
sweepWorkflowFleet(phase: 'pause' | 'resume', command: { readonly cursor: ClientJson | null; readonly limit?: number },
|
|
105
|
+
options?: { readonly signal?: AbortSignal }): Promise<WorkflowFleetSweep>;
|
|
106
|
+
pauseWorkflow(id: string, revision: number, options: WorkflowCommandOptions): Promise<WorkflowViewInput>;
|
|
107
|
+
/** Reviewed migrations whose source is the run's pinned definition. Requires `workflows:read`. */
|
|
108
|
+
workflowMigrations(id: string, options?: { readonly signal?: AbortSignal }): Promise<readonly WorkflowMigrationOffer[]>;
|
|
109
|
+
/** Dry run of one migration against the run's real state; writes nothing. Requires `workflows:read`. */
|
|
110
|
+
planWorkflowMigration(id: string, migrationId: string, options?: { readonly signal?: AbortSignal }): Promise<WorkflowMigrationPlan>;
|
|
111
|
+
/**
|
|
112
|
+
* Apply a reviewed migration to a paused run at its exact revision. Requires `workflows:migrate`. A refused plan or a
|
|
113
|
+
* changed revision is HTTP 409: plan again to see the blockers.
|
|
114
|
+
*/
|
|
115
|
+
migrateWorkflow(id: string, migrationId: string, revision: number, options: WorkflowCommandOptions): Promise<{ readonly plan: WorkflowMigrationPlan; readonly workflow: WorkflowViewInput }>;
|
|
116
|
+
respondHumanRequest(id: string, requestDigest: string, value: unknown,
|
|
117
|
+
options: { readonly commandId: string; readonly signal?: AbortSignal }): Promise<RemoteHumanRequest>;
|
|
118
|
+
}
|
|
119
|
+
/** Safe machine-readable transport error; server/provider response bodies are never used as its message. */
|
|
120
|
+
export class ClientError extends Error {
|
|
121
|
+
constructor(readonly code: string, readonly status?: number) { super(`Mayura request failed (${code}).`); this.name = 'ClientError'; Object.freeze(this); }
|
|
122
|
+
}
|
|
123
|
+
const encoder = new TextEncoder();
|
|
124
|
+
const migrationIdPattern = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
125
|
+
const migrationNodePattern = /^[A-Za-z][A-Za-z0-9._-]{0,127}$/;
|
|
126
|
+
const migrationActions: readonly string[] = ['keep', 'update', 'reset', 'accept', 'add', 'remove'];
|
|
127
|
+
function plainObject(value: unknown): Record<string, unknown> {
|
|
128
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value)) return fail(); return value as Record<string, unknown>;
|
|
129
|
+
}
|
|
130
|
+
function exactKeys(value: Record<string, unknown>, keys: readonly string[]): void {
|
|
131
|
+
if (Object.keys(value).length !== keys.length || keys.some(key => !Object.hasOwn(value, key))) fail();
|
|
132
|
+
}
|
|
133
|
+
function migrationOffer(value: unknown): WorkflowMigrationOffer {
|
|
134
|
+
const raw = plainObject(value); exactKeys(raw, ['id', 'description', 'fromVersion', 'toVersion', 'fromDigest', 'toDigest']);
|
|
135
|
+
if (typeof raw['id'] !== 'string' || !migrationIdPattern.test(raw['id']) || typeof raw['description'] !== 'string' || raw['description'].length > 2_048
|
|
136
|
+
|| typeof raw['fromVersion'] !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._+-]{0,127}$/.test(raw['fromVersion'])
|
|
137
|
+
|| typeof raw['toVersion'] !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._+-]{0,127}$/.test(raw['toVersion'])
|
|
138
|
+
|| typeof raw['fromDigest'] !== 'string' || !/^[a-f0-9]{64}$/.test(raw['fromDigest'])
|
|
139
|
+
|| typeof raw['toDigest'] !== 'string' || !/^[a-f0-9]{64}$/.test(raw['toDigest'])) fail();
|
|
140
|
+
return Object.freeze({ ...raw }) as unknown as WorkflowMigrationOffer;
|
|
141
|
+
}
|
|
142
|
+
function migrationPlan(value: unknown, runId: string, migrationId: string): WorkflowMigrationPlan {
|
|
143
|
+
const raw = plainObject(value); exactKeys(raw, ['migrationId', 'format', 'runId', 'fromDigest', 'toDigest', 'entries', 'blockers', 'allowed']);
|
|
144
|
+
const entries = raw['entries']; const blockers = raw['blockers'];
|
|
145
|
+
if (raw['migrationId'] !== migrationId || raw['runId'] !== runId || typeof raw['format'] !== 'string' || !/^[a-z0-9-]{1,32}$/.test(raw['format'])
|
|
146
|
+
|| typeof raw['fromDigest'] !== 'string' || !/^[a-f0-9]{64}$/.test(raw['fromDigest']) || typeof raw['toDigest'] !== 'string' || !/^[a-f0-9]{64}$/.test(raw['toDigest'])
|
|
147
|
+
|| !Array.isArray(entries) || entries.length > 512 || !Array.isArray(blockers) || blockers.length > 512 || raw['allowed'] !== (blockers.length === 0)) fail();
|
|
148
|
+
const frozenEntries = (entries as unknown[]).map(item => {
|
|
149
|
+
const entry = plainObject(item);
|
|
150
|
+
if (Object.keys(entry).some(key => !['action', 'target', 'source', 'status'].includes(key)) || !migrationActions.includes(String(entry['action']))
|
|
151
|
+
|| (entry['target'] === undefined && entry['source'] === undefined)
|
|
152
|
+
|| [entry['target'], entry['source']].some(node => node !== undefined && (typeof node !== 'string' || !migrationNodePattern.test(node)))
|
|
153
|
+
|| (entry['status'] !== undefined && (typeof entry['status'] !== 'string' || !/^[a-z_]{1,32}$/.test(entry['status'])))) fail();
|
|
154
|
+
return Object.freeze({ ...entry });
|
|
155
|
+
});
|
|
156
|
+
const frozenBlockers = (blockers as unknown[]).map(item => {
|
|
157
|
+
const blocker = plainObject(item); exactKeys(blocker, ['node', 'reason']);
|
|
158
|
+
if (typeof blocker['node'] !== 'string' || !(blocker['node'] === '*' || migrationNodePattern.test(blocker['node']))
|
|
159
|
+
|| typeof blocker['reason'] !== 'string' || !blocker['reason'] || blocker['reason'].length > 512) fail();
|
|
160
|
+
return Object.freeze({ node: blocker['node'], reason: blocker['reason'] });
|
|
161
|
+
});
|
|
162
|
+
return Object.freeze({ ...raw, entries: Object.freeze(frozenEntries), blockers: Object.freeze(frozenBlockers) }) as unknown as WorkflowMigrationPlan;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Encode untrusted text for an HTML text node. Prefer DOM `textContent` when a DOM is available. */
|
|
166
|
+
export function escapeHtmlText(value: string, maxBytes = 1_048_576): string {
|
|
167
|
+
if (typeof value !== 'string' || !Number.isSafeInteger(maxBytes) || maxBytes < 1 || maxBytes > 1_048_576) throw new ClientError('INVALID_RENDER_INPUT');
|
|
168
|
+
if (encoder.encode(value).length > maxBytes) throw new ClientError('RESPONSE_LIMIT');
|
|
169
|
+
return value.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>').replaceAll('"', '"').replaceAll("'", ''');
|
|
170
|
+
}
|
|
171
|
+
const statuses: readonly string[] = ['running', 'succeeded', 'failed', 'blocked', 'cancelled', 'outcome_unknown'];
|
|
172
|
+
const eventTypes: readonly string[] = ['run.started', 'model.started', 'model.completed', 'tool.started', 'tool.completed', 'hook.started', 'hook.completed',
|
|
173
|
+
'step.started', 'step.completed', 'delegate.started', 'delegate.completed', 'run.completed', 'events.gap', 'output.delta', 'output.withheld'];
|
|
174
|
+
/** Streamed output is released text with an exact position; nothing else rides along. */
|
|
175
|
+
function outputMetadata(metadata: Record<string, unknown>, delta: boolean): void {
|
|
176
|
+
const required = delta ? ['step', 'modelCall', 'index', 'text'] : ['step', 'modelCall'];
|
|
177
|
+
if (Object.keys(metadata).length !== required.length || required.some(key => !Object.hasOwn(metadata, key))) throw new ClientError('INVALID_STREAM');
|
|
178
|
+
for (const key of ['step', 'modelCall', ...(delta ? ['index'] : [])]) {
|
|
179
|
+
if (typeof metadata[key] !== 'number' || !Number.isSafeInteger(metadata[key]) || (metadata[key] as number) < 0) throw new ClientError('INVALID_STREAM');
|
|
180
|
+
}
|
|
181
|
+
if (delta && (typeof metadata['text'] !== 'string' || (metadata['text'] as string).length > 4_096)) throw new ClientError('INVALID_STREAM');
|
|
182
|
+
}
|
|
183
|
+
const hookFields = ['hookId', 'hookVersion', 'stage', 'invocationId', 'step', 'attempt'] as const;
|
|
184
|
+
const hookStages: readonly string[] = ['beforeExecution', 'beforeStep', 'beforeModelCall', 'beforeToolCall', 'beforeDelegate', 'beforeOutputRelease',
|
|
185
|
+
'afterStep', 'afterModelCall', 'afterToolCall', 'afterDelegate', 'onViolation', 'afterExecution', 'onError', 'onCancel', 'onBlocked', 'onFinally'];
|
|
186
|
+
const hookStatuses: readonly string[] = ['continued', 'blocked', 'failed', 'cancelled', 'outcome_unknown'];
|
|
187
|
+
/** Hook observations have an exact content-free schema; the browser never admits hook arguments or messages. */
|
|
188
|
+
function hookMetadata(metadata: Record<string, unknown>, completed: boolean): void {
|
|
189
|
+
const required = completed ? [...hookFields, 'status'] : hookFields;
|
|
190
|
+
if (Object.keys(metadata).length !== required.length || required.some(key => !Object.hasOwn(metadata, key))) throw new ClientError('INVALID_STREAM');
|
|
191
|
+
for (const key of ['hookId', 'hookVersion']) {
|
|
192
|
+
if (typeof metadata[key] !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/.test(metadata[key] as string)) throw new ClientError('INVALID_STREAM');
|
|
193
|
+
}
|
|
194
|
+
const stage = metadata['stage']; const invocation = metadata['invocationId']; const step = metadata['step'];
|
|
195
|
+
if (typeof stage !== 'string' || !hookStages.includes(stage)
|
|
196
|
+
|| typeof invocation !== 'string' || !/^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/.test(invocation)
|
|
197
|
+
|| typeof step !== 'number' || !Number.isSafeInteger(step) || step < 0 || (stage === 'beforeExecution' && step !== 0)
|
|
198
|
+
|| metadata['attempt'] !== 1 || (completed && (typeof metadata['status'] !== 'string' || !hookStatuses.includes(metadata['status'] as string)))) {
|
|
199
|
+
throw new ClientError('INVALID_STREAM');
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function fail(): never { throw new ClientError('INVALID_RESPONSE'); }
|
|
203
|
+
const fleetOutcomes = new Set(['paused', 'already_paused', 'terminal', 'busy', 'resumed', 'not_paused', 'missing', 'unregistered']);
|
|
204
|
+
function fleetHold(value: unknown): WorkflowFleetHold {
|
|
205
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return fail();
|
|
206
|
+
const raw = value as Record<string, unknown>; const keys = Object.keys(raw);
|
|
207
|
+
if (keys.length !== 3 || !['held', 'generation', 'changedAtMs'].every(key => Object.hasOwn(raw, key))) return fail();
|
|
208
|
+
const { held, generation, changedAtMs } = raw;
|
|
209
|
+
if (typeof held !== 'boolean' || typeof generation !== 'number' || !Number.isSafeInteger(generation) || generation < (held ? 1 : 0)
|
|
210
|
+
|| (changedAtMs !== null && (typeof changedAtMs !== 'number' || !Number.isSafeInteger(changedAtMs) || changedAtMs < 0))) return fail();
|
|
211
|
+
return Object.freeze({ held, generation, changedAtMs: changedAtMs as number | null });
|
|
212
|
+
}
|
|
213
|
+
function fleetSweep(value: unknown, limit: number): WorkflowFleetSweep {
|
|
214
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return fail();
|
|
215
|
+
const raw = value as Record<string, unknown>;
|
|
216
|
+
if (Object.keys(raw).length !== 2 || !Array.isArray(raw['outcomes']) || !Object.hasOwn(raw, 'nextCursor') || raw['outcomes'].length > limit) return fail();
|
|
217
|
+
const outcomes = raw['outcomes'].map((entry: unknown) => {
|
|
218
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) return fail();
|
|
219
|
+
const item = entry as Record<string, unknown>; const failed = item['outcome'] === 'failed';
|
|
220
|
+
if (Object.keys(item).length !== (failed ? 4 : 3) || typeof item['target'] !== 'string' || !/^[a-z][a-z0-9-]{0,31}$/.test(item['target'])
|
|
221
|
+
|| typeof item['runId'] !== 'string' || !/^[a-f0-9]{64}$/.test(item['runId'])
|
|
222
|
+
|| (failed ? typeof item['code'] !== 'string' || !/^[A-Z][A-Z_]{0,39}$/.test(item['code']) : !fleetOutcomes.has(String(item['outcome'])))) return fail();
|
|
223
|
+
return Object.freeze({ ...item }) as unknown as WorkflowFleetSweepOutcome;
|
|
224
|
+
});
|
|
225
|
+
const next = raw['nextCursor'];
|
|
226
|
+
if (next !== null && (!next || typeof next !== 'object' || Array.isArray(next))) return fail();
|
|
227
|
+
return Object.freeze({ outcomes: Object.freeze(outcomes), nextCursor: next === null ? null : json(next, 4_096) });
|
|
228
|
+
}
|
|
229
|
+
function record(value: unknown): Record<string, unknown> { if (typeof value !== 'object' || value === null || Array.isArray(value)) return fail(); return value as Record<string, unknown>; }
|
|
230
|
+
function text(value: unknown, maximum = 256): string { if (typeof value !== 'string' || value.length === 0 || value.length > maximum) return fail(); return value; }
|
|
231
|
+
function natural(value: unknown): number { if (!Number.isSafeInteger(value) || (value as number) < 0) return fail(); return value as number; }
|
|
232
|
+
function runId(value: unknown): string { const id = text(value, 36); if (!/^[a-f0-9-]{36}$/.test(id)) return fail(); return id; }
|
|
233
|
+
function json(value: unknown, maximum: number): ClientJson {
|
|
234
|
+
let nodes = 0;
|
|
235
|
+
const seen = new Set<object>();
|
|
236
|
+
const copy = (item: unknown, depth: number): ClientJson => {
|
|
237
|
+
if (++nodes > 100_000 || depth > 32) return fail();
|
|
238
|
+
if (typeof item === 'string' && item.length > maximum) return fail();
|
|
239
|
+
if (item === null || typeof item === 'boolean' || typeof item === 'string') return item;
|
|
240
|
+
if (typeof item === 'number' && Number.isFinite(item) && (!Number.isInteger(item) || Number.isSafeInteger(item))) return item;
|
|
241
|
+
if (typeof item !== 'object' || seen.has(item) || (!Array.isArray(item) && ![null, Object.prototype].includes(Object.getPrototypeOf(item)))) return fail();
|
|
242
|
+
seen.add(item);
|
|
243
|
+
const descriptors = Object.getOwnPropertyDescriptors(item);
|
|
244
|
+
let result: ClientJson;
|
|
245
|
+
if (Array.isArray(item)) {
|
|
246
|
+
const entries: ClientJson[] = [];
|
|
247
|
+
for (let index = 0; index < item.length; index++) {
|
|
248
|
+
const descriptor = descriptors[String(index)]; if (!descriptor || !('value' in descriptor)) return fail();
|
|
249
|
+
entries.push(copy(descriptor.value, depth + 1));
|
|
250
|
+
}
|
|
251
|
+
result = Object.freeze(entries);
|
|
252
|
+
} else {
|
|
253
|
+
const entries: Record<string, ClientJson> = {};
|
|
254
|
+
for (const key of Reflect.ownKeys(descriptors)) {
|
|
255
|
+
if (typeof key !== 'string' || ['__proto__', 'constructor', 'prototype'].includes(key)) return fail();
|
|
256
|
+
const descriptor = descriptors[key]!;
|
|
257
|
+
if (!('value' in descriptor) || !descriptor.enumerable) return fail();
|
|
258
|
+
entries[key] = copy(descriptor.value, depth + 1);
|
|
259
|
+
}
|
|
260
|
+
result = Object.freeze(entries);
|
|
261
|
+
}
|
|
262
|
+
seen.delete(item); return result;
|
|
263
|
+
};
|
|
264
|
+
try {
|
|
265
|
+
const result = copy(value, 0);
|
|
266
|
+
if (encoder.encode(JSON.stringify(result)).byteLength > maximum) throw new Error();
|
|
267
|
+
return result;
|
|
268
|
+
} catch { throw new ClientError('INVALID_JSON'); }
|
|
269
|
+
}
|
|
270
|
+
function workflowView(value: unknown, expectedId: string): WorkflowViewInput {
|
|
271
|
+
const raw = record(value); const expected = ['format', 'definitionId', 'definitionVersion', 'runId', 'revision', 'status', 'nodes', 'steps'];
|
|
272
|
+
if (!Object.isFrozen(raw) || Object.keys(raw).length !== expected.length || expected.some(key => !Object.hasOwn(raw, key))) return fail();
|
|
273
|
+
const format = raw['format']; const nodes = raw['nodes']; const steps = raw['steps'];
|
|
274
|
+
const admittedKinds: Readonly<Record<number, readonly string[]>> = { 2: ['tool', 'join'], 3: ['tool', 'join', 'wait'], 4: ['tool', 'join', 'child'], 5: ['tool', 'join', 'human', 'timer'] };
|
|
275
|
+
const runStatuses = ['running', 'waiting', 'paused', 'succeeded', 'failed', 'blocked', 'cancelled', 'outcome_unknown'];
|
|
276
|
+
const stepStatuses = ['pending', 'waiting', 'approved', 'dispatching', 'succeeded', 'failed', 'blocked', 'unknown', 'skipped', 'timed_out'];
|
|
277
|
+
if (typeof format !== 'number' || ![2, 3, 4, 5].includes(format) || typeof raw['definitionId'] !== 'string' || !/^[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(raw['definitionId'])
|
|
278
|
+
|| typeof raw['definitionVersion'] !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._+-]{0,127}$/.test(raw['definitionVersion']) || raw['runId'] !== expectedId
|
|
279
|
+
|| typeof raw['revision'] !== 'number' || !Number.isSafeInteger(raw['revision']) || raw['revision'] < 1 || typeof raw['status'] !== 'string' || !runStatuses.includes(raw['status'])
|
|
280
|
+
|| !Array.isArray(nodes) || !Object.isFrozen(nodes) || nodes.length < 1 || nodes.length > 128 || !Array.isArray(steps) || !Object.isFrozen(steps) || steps.length !== nodes.length) return fail();
|
|
281
|
+
const ids = new Map<string, WorkflowViewNodeKind>(); let edgeCount = 0;
|
|
282
|
+
for (const candidate of nodes) {
|
|
283
|
+
if (!candidate || typeof candidate !== 'object' || !Object.isFrozen(candidate)) return fail(); const node = Object.getOwnPropertyDescriptors(candidate);
|
|
284
|
+
if (Reflect.ownKeys(node).length !== 3 || ['id', 'kind', 'dependsOn'].some(key => !node[key] || !('value' in node[key]!))) return fail();
|
|
285
|
+
const nodeId = node['id']!.value; const kind = node['kind']!.value; const dependencies = node['dependsOn']!.value;
|
|
286
|
+
if (typeof nodeId !== 'string' || !/^[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(nodeId) || ids.has(nodeId) || typeof kind !== 'string' || !admittedKinds[format]!.includes(kind)
|
|
287
|
+
|| !Array.isArray(dependencies) || !Object.isFrozen(dependencies) || dependencies.length > 127 || new Set(dependencies).size !== dependencies.length
|
|
288
|
+
|| dependencies.some(dependency => typeof dependency !== 'string' || !/^[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(dependency))) return fail();
|
|
289
|
+
edgeCount += dependencies.length; if (edgeCount > 512) return fail(); ids.set(nodeId, kind as WorkflowViewNodeKind);
|
|
290
|
+
}
|
|
291
|
+
const seen = new Set<string>();
|
|
292
|
+
for (const candidate of steps) {
|
|
293
|
+
if (!candidate || typeof candidate !== 'object' || !Object.isFrozen(candidate)) return fail(); const step = Object.getOwnPropertyDescriptors(candidate);
|
|
294
|
+
const keys = Reflect.ownKeys(step); const allowed = ['id', 'kind', 'status', 'childRunId', 'approval'];
|
|
295
|
+
if (keys.some(key => typeof key !== 'string' || !allowed.includes(key) || !('value' in step[key]!)) || !['id', 'kind', 'status'].every(key => step[key])) return fail();
|
|
296
|
+
const stepId = step['id']!.value; const kind = step['kind']!.value; const status = step['status']!.value; const childRunId = step['childRunId']?.value;
|
|
297
|
+
const approval = step['approval']?.value;
|
|
298
|
+
if (typeof stepId !== 'string' || seen.has(stepId) || kind !== ids.get(stepId) || typeof status !== 'string' || !stepStatuses.includes(status)
|
|
299
|
+
|| (childRunId !== undefined && (kind !== 'child' || typeof childRunId !== 'string' || !/^[a-f0-9]{64}$/.test(childRunId)))
|
|
300
|
+
|| (approval !== undefined && (kind !== 'tool' || status !== 'waiting' || !workflowApproval(approval)))) return fail();
|
|
301
|
+
seen.add(stepId);
|
|
302
|
+
}
|
|
303
|
+
if (seen.size !== ids.size) return fail();
|
|
304
|
+
return raw as unknown as WorkflowViewInput;
|
|
305
|
+
}
|
|
306
|
+
/** A pending approval: exact digest, expiry and optionally the verified tool call it binds. */
|
|
307
|
+
function workflowApproval(value: unknown): boolean {
|
|
308
|
+
if (!value || typeof value !== 'object' || Array.isArray(value) || !Object.isFrozen(value)) return false;
|
|
309
|
+
const approval = value as Record<string, unknown>; const subject = approval['subject'] as Record<string, unknown> | undefined;
|
|
310
|
+
return Object.keys(approval).every(key => ['digest', 'expiresAtMs', 'subject'].includes(key)) && typeof approval['digest'] === 'string'
|
|
311
|
+
&& /^[a-f0-9]{64}$/.test(approval['digest']) && typeof approval['expiresAtMs'] === 'number' && Number.isSafeInteger(approval['expiresAtMs']) && approval['expiresAtMs'] > 0
|
|
312
|
+
&& (subject === undefined || (!!subject && typeof subject === 'object' && !Array.isArray(subject) && Object.isFrozen(subject) && Object.keys(subject).length === 3
|
|
313
|
+
&& Object.hasOwn(subject, 'input') && typeof subject['toolId'] === 'string' && /^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/.test(subject['toolId'])
|
|
314
|
+
&& typeof subject['toolVersion'] === 'string' && /^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/.test(subject['toolVersion'])));
|
|
315
|
+
}
|
|
316
|
+
function workflowIndexEntry(value: unknown, settled = false): WorkflowIndexEntry {
|
|
317
|
+
const raw = record(value); const expected = ['format', 'definitionId', 'definitionVersion', 'runId', 'revision', 'status', ...(settled ? ['settledAtMs'] : [])];
|
|
318
|
+
if (settled && (typeof raw['settledAtMs'] !== 'number' || !Number.isSafeInteger(raw['settledAtMs']) || raw['settledAtMs'] < 0
|
|
319
|
+
|| ['running', 'waiting', 'paused'].includes(raw['status'] as string))) return fail();
|
|
320
|
+
if (!Object.isFrozen(raw) || Object.keys(raw).length !== expected.length || expected.some(key => !Object.hasOwn(raw, key))
|
|
321
|
+
|| typeof raw['format'] !== 'number' || ![2, 3, 4, 5].includes(raw['format']) || typeof raw['definitionId'] !== 'string'
|
|
322
|
+
|| !/^[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(raw['definitionId']) || typeof raw['definitionVersion'] !== 'string'
|
|
323
|
+
|| !/^[A-Za-z0-9][A-Za-z0-9._+-]{0,127}$/.test(raw['definitionVersion']) || typeof raw['runId'] !== 'string'
|
|
324
|
+
|| !/^[a-f0-9]{64}$/.test(raw['runId']) || typeof raw['revision'] !== 'number' || !Number.isSafeInteger(raw['revision']) || raw['revision'] < 1
|
|
325
|
+
|| typeof raw['status'] !== 'string' || !['running', 'waiting', 'paused', 'succeeded', 'failed', 'blocked', 'cancelled', 'outcome_unknown'].includes(raw['status'])) return fail();
|
|
326
|
+
return raw as unknown as WorkflowIndexEntry;
|
|
327
|
+
}
|
|
328
|
+
async function race<T>(work: PromiseLike<T>, signal: AbortSignal): Promise<T> {
|
|
329
|
+
if (signal.aborted) { void Promise.resolve(work).catch(() => {}); throw new ClientError('ABORTED'); }
|
|
330
|
+
return await new Promise<T>((resolve, reject) => {
|
|
331
|
+
const abort = (): void => { cleanup(); reject(new ClientError('ABORTED')); };
|
|
332
|
+
const cleanup = (): void => { signal.removeEventListener('abort', abort); };
|
|
333
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
334
|
+
Promise.resolve(work).then(value => { cleanup(); resolve(value); }, () => { cleanup(); reject(new ClientError('TRANSPORT_FAILED')); });
|
|
335
|
+
if (signal.aborted) abort();
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/** Explicit credentials and destination. Commands never retry automatically or follow redirects. */
|
|
340
|
+
export function createClient(options: ClientOptions): MayuraClient {
|
|
341
|
+
const base = new URL(options.baseUrl);
|
|
342
|
+
if (!['https:', 'http:'].includes(base.protocol) || base.username || base.password || base.pathname !== '/' || base.search || base.hash) throw new ClientError('INVALID_CONFIG');
|
|
343
|
+
if (base.protocol === 'http:' && !['localhost', '127.0.0.1', '[::1]'].includes(base.hostname)) throw new ClientError('INVALID_CONFIG');
|
|
344
|
+
if (typeof options.token !== 'function') throw new ClientError('INVALID_CONFIG');
|
|
345
|
+
const token = options.token; const transport = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
346
|
+
const maxBytes = options.maxResponseBytes ?? 4_194_304; const frameBytes = options.maxEventBytes ?? 16_384; const timeout = options.requestTimeoutMs ?? 30_000;
|
|
347
|
+
if ([maxBytes, frameBytes, timeout].some(value => !Number.isSafeInteger(value) || value < 1 || value > 16_777_216)) throw new ClientError('INVALID_CONFIG');
|
|
348
|
+
|
|
349
|
+
const request = async (path: string, method: 'GET' | 'POST', signal: AbortSignal, body?: ClientJson, key?: string): Promise<Response> => {
|
|
350
|
+
const credential = await race(Promise.resolve().then(() => { if (signal.aborted) throw new ClientError('ABORTED'); return token(); }), signal);
|
|
351
|
+
if (typeof credential !== 'string' || !/^[\x21-\x7e]{1,8192}$/.test(credential)) throw new ClientError('INVALID_CREDENTIAL');
|
|
352
|
+
const headers: Record<string, string> = { Authorization: `Bearer ${credential}` };
|
|
353
|
+
if (body !== undefined) headers['Content-Type'] = 'application/json';
|
|
354
|
+
if (key !== undefined) headers['Idempotency-Key'] = key;
|
|
355
|
+
if (signal.aborted) throw new ClientError('ABORTED');
|
|
356
|
+
const response = await race(Promise.resolve().then(() => {
|
|
357
|
+
if (signal.aborted) throw new ClientError('ABORTED');
|
|
358
|
+
return transport(new URL(path, base), {
|
|
359
|
+
method, headers, signal, redirect: 'error', credentials: 'omit', cache: 'no-store',
|
|
360
|
+
...(body === undefined ? {} : { body: JSON.stringify(body) }),
|
|
361
|
+
});
|
|
362
|
+
}).then(response => {
|
|
363
|
+
if (signal.aborted) {
|
|
364
|
+
void response.body?.cancel().catch(() => {});
|
|
365
|
+
throw new ClientError('ABORTED');
|
|
366
|
+
}
|
|
367
|
+
return response;
|
|
368
|
+
}), signal);
|
|
369
|
+
if (response.redirected || (response.url && new URL(response.url).origin !== base.origin) || !response.ok) {
|
|
370
|
+
void response.body?.cancel().catch(() => {});
|
|
371
|
+
throw new ClientError(response.redirected ? 'REDIRECT_DENIED' : 'HTTP_ERROR', response.status);
|
|
372
|
+
}
|
|
373
|
+
return response;
|
|
374
|
+
};
|
|
375
|
+
const scope = (external?: AbortSignal) => {
|
|
376
|
+
const controller = new AbortController(); const abort = (): void => { controller.abort(); };
|
|
377
|
+
external?.addEventListener('abort', abort, { once: true }); if (external?.aborted) abort();
|
|
378
|
+
const timer = setTimeout(abort, timeout);
|
|
379
|
+
return { signal: controller.signal, close() { clearTimeout(timer); external?.removeEventListener('abort', abort); controller.abort(); } };
|
|
380
|
+
};
|
|
381
|
+
const readJson = async (response: Response, signal: AbortSignal): Promise<Record<string, unknown>> => {
|
|
382
|
+
if (!/^application\/json(?:\s*;|$)/i.test(response.headers.get('content-type') ?? '')) { void response.body?.cancel().catch(() => {}); return fail(); }
|
|
383
|
+
const reader = response.body?.getReader(); if (!reader) return fail();
|
|
384
|
+
const chunks: Uint8Array[] = []; let size = 0; let done = false;
|
|
385
|
+
try {
|
|
386
|
+
while (true) {
|
|
387
|
+
const next = await race(reader.read(), signal); if (next.done) { done = true; break; }
|
|
388
|
+
size += next.value.byteLength; if (size > maxBytes) throw new ClientError('RESPONSE_LIMIT'); chunks.push(next.value);
|
|
389
|
+
}
|
|
390
|
+
const bytes = new Uint8Array(size); let offset = 0;
|
|
391
|
+
for (const chunk of chunks) { bytes.set(chunk, offset); offset += chunk.byteLength; }
|
|
392
|
+
try { return record(json(JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes)), maxBytes)); }
|
|
393
|
+
catch { return fail(); }
|
|
394
|
+
} finally { if (!done) void reader.cancel().catch(() => {}); reader.releaseLock(); }
|
|
395
|
+
};
|
|
396
|
+
const command = async (path: string, method: 'GET' | 'POST', external?: AbortSignal, body?: ClientJson, key?: string) => {
|
|
397
|
+
const control = scope(external);
|
|
398
|
+
try { return await readJson(await request(path, method, control.signal, body, key), control.signal); }
|
|
399
|
+
finally { control.close(); }
|
|
400
|
+
};
|
|
401
|
+
const snapshot = (raw: Record<string, unknown>, id: string): RemoteSnapshot => {
|
|
402
|
+
if (raw['id'] !== id || !statuses.includes(String(raw['status']))) return fail();
|
|
403
|
+
const budget = record(raw['budget']); const spent = budget['spentMicros'];
|
|
404
|
+
if (typeof spent === 'string' ? !/^\d{1,64}$/.test(spent) : natural(spent) < 0) return fail();
|
|
405
|
+
if (!Array.isArray(raw['evidence']) || raw['evidence'].length > 4096) return fail();
|
|
406
|
+
const evidence = raw['evidence'].map(value => {
|
|
407
|
+
const entry = record(value); const receipt = record(entry['receipt']);
|
|
408
|
+
if (!['not_started', 'succeeded', 'failed', 'unknown'].includes(String(receipt['execution'])) || !['released', 'withheld'].includes(String(receipt['disclosure']))) return fail();
|
|
409
|
+
return Object.freeze({ runId: runId(entry['runId']), receipt: Object.freeze({ callId: text(receipt['callId']), toolId: text(receipt['toolId']), execution: receipt['execution'], disclosure: receipt['disclosure'] }) }) as RemoteReceipt;
|
|
410
|
+
});
|
|
411
|
+
return Object.freeze({ id, status: raw['status'] as RemoteStatus, budget: Object.freeze({ spentMicros: spent as number | string, reservedMicros: natural(budget['reservedMicros']), calls: natural(budget['calls']) }), evidence: Object.freeze(evidence) });
|
|
412
|
+
};
|
|
413
|
+
const human = (value: unknown): RemoteHumanRequest => {
|
|
414
|
+
const item = record(value); const allowed = ['id', 'agentId', 'kind', 'schemaId', 'schemaDigest', 'prompt', 'digest', 'status', 'context', 'subjectDigest', 'deadlineAtMs'];
|
|
415
|
+
if (Object.keys(item).some(key => !allowed.includes(key)) || !['id', 'agentId', 'kind', 'schemaId', 'schemaDigest', 'prompt', 'digest', 'status'].every(key => Object.hasOwn(item, key))) return fail();
|
|
416
|
+
const humanId = text(item['id'], 80); const agentId = text(item['agentId']); const schemaId = text(item['schemaId']);
|
|
417
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,79}$/.test(humanId) || !/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/.test(agentId)
|
|
418
|
+
|| !/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/.test(schemaId) || !['information', 'correction', 'plan_selection'].includes(String(item['kind']))
|
|
419
|
+
|| !/^[a-f0-9]{64}$/.test(String(item['schemaDigest'])) || !/^[a-f0-9]{64}$/.test(String(item['digest']))
|
|
420
|
+
|| !['waiting', 'answered', 'cancelled', 'timed_out'].includes(String(item['status'])) || typeof item['prompt'] !== 'string' || encoder.encode(item['prompt']).byteLength < 1 || encoder.encode(item['prompt']).byteLength > 1_024
|
|
421
|
+
|| (item['subjectDigest'] !== undefined && !/^[a-f0-9]{64}$/.test(String(item['subjectDigest'])))
|
|
422
|
+
|| ((item['kind'] === 'correction') !== (item['subjectDigest'] !== undefined))
|
|
423
|
+
|| (item['deadlineAtMs'] !== undefined && (!Number.isSafeInteger(item['deadlineAtMs']) || (item['deadlineAtMs'] as number) < 0))) return fail();
|
|
424
|
+
return Object.freeze({ id: humanId, agentId, kind: item['kind'] as RemoteHumanRequest['kind'], schemaId,
|
|
425
|
+
schemaDigest: item['schemaDigest'] as string, prompt: item['prompt'], digest: item['digest'] as string, status: item['status'] as RemoteHumanRequest['status'],
|
|
426
|
+
...(item['context'] === undefined ? {} : { context: json(item['context'], maxBytes) }),
|
|
427
|
+
...(item['subjectDigest'] === undefined ? {} : { subjectDigest: item['subjectDigest'] as string }),
|
|
428
|
+
...(item['deadlineAtMs'] === undefined ? {} : { deadlineAtMs: item['deadlineAtMs'] as number }) });
|
|
429
|
+
};
|
|
430
|
+
const run = (id: string): RemoteRun => {
|
|
431
|
+
runId(id); const path = `/v1/runs/${id}`;
|
|
432
|
+
return Object.freeze({
|
|
433
|
+
id,
|
|
434
|
+
async inspect(settings?: { readonly signal?: AbortSignal }) { return snapshot(await command(path, 'GET', settings?.signal), id); },
|
|
435
|
+
async result<T>(schema: ClientSchema<T>, settings?: { readonly signal?: AbortSignal }): Promise<RemoteOutcome<T> | undefined> {
|
|
436
|
+
const raw = await command(path, 'GET', settings?.signal); const state = snapshot(raw, id);
|
|
437
|
+
if (state.status === 'running') return undefined;
|
|
438
|
+
const outcome = record(raw['outcome']); if (outcome['status'] !== state.status) return fail();
|
|
439
|
+
if (outcome['status'] !== 'succeeded') return Object.freeze({ status: state.status as Exclude<RemoteStatus, 'running' | 'succeeded'>, error: Object.freeze({ code: text(record(outcome['error'])['code'], 128) }), evidence: state.evidence });
|
|
440
|
+
let validationAborted = false;
|
|
441
|
+
try {
|
|
442
|
+
if (schema['~standard'].version !== 1) throw new Error();
|
|
443
|
+
const control = scope(settings?.signal);
|
|
444
|
+
try {
|
|
445
|
+
const validated = await race(Promise.resolve(schema['~standard'].validate(outcome['output'])), control.signal);
|
|
446
|
+
if (validated.issues) throw new Error();
|
|
447
|
+
return Object.freeze({ status: 'succeeded' as const, output: json(validated.value, maxBytes) as T, evidence: state.evidence });
|
|
448
|
+
} catch (error) { validationAborted = control.signal.aborted; throw error; }
|
|
449
|
+
finally { control.close(); }
|
|
450
|
+
} catch { throw new ClientError(validationAborted ? 'ABORTED' : 'INVALID_OUTPUT'); }
|
|
451
|
+
},
|
|
452
|
+
async cancel(settings?: { readonly signal?: AbortSignal }) {
|
|
453
|
+
const value = await command(`${path}/cancel`, 'POST', settings?.signal);
|
|
454
|
+
if (value['id'] !== id || value['cancellationRequested'] !== true) fail();
|
|
455
|
+
},
|
|
456
|
+
async *events(settings?: { readonly after?: number; readonly signal?: AbortSignal }): AsyncIterable<ClientEvent> {
|
|
457
|
+
let cursor = natural(settings?.after ?? 0); const control = scope(settings?.signal);
|
|
458
|
+
let reader: ReadableStreamDefaultReader<Uint8Array> | undefined;
|
|
459
|
+
try {
|
|
460
|
+
const response = await request(`${path}/events?after=${cursor}`, 'GET', control.signal);
|
|
461
|
+
if (!/^text\/event-stream(?:\s*;|$)/i.test(response.headers.get('content-type') ?? '')) { void response.body?.cancel().catch(() => {}); fail(); }
|
|
462
|
+
reader = response.body?.getReader(); if (!reader) fail();
|
|
463
|
+
const decoder = new TextDecoder('utf-8', { fatal: true }); let pending = '';
|
|
464
|
+
while (true) {
|
|
465
|
+
const next = await race(reader.read(), control.signal);
|
|
466
|
+
if (!next.done && next.value.byteLength > maxBytes) throw new ClientError('STREAM_LIMIT');
|
|
467
|
+
try { pending += next.done ? decoder.decode() : decoder.decode(next.value, { stream: true }); }
|
|
468
|
+
catch { throw new ClientError('INVALID_STREAM'); }
|
|
469
|
+
// Handle LF/CRLF independently of how UTF-8/network chunks were split.
|
|
470
|
+
while (true) {
|
|
471
|
+
const boundary = /\r?\n\r?\n/.exec(pending); if (!boundary || boundary.index === undefined) break;
|
|
472
|
+
const frame = pending.slice(0, boundary.index); pending = pending.slice(boundary.index + boundary[0].length);
|
|
473
|
+
if (encoder.encode(frame).byteLength > frameBytes) throw new ClientError('STREAM_LIMIT');
|
|
474
|
+
let event = ''; let eventId = ''; const data: string[] = [];
|
|
475
|
+
for (const line of frame.split(/\r?\n/)) {
|
|
476
|
+
if (!line || line.startsWith(':')) continue;
|
|
477
|
+
const colon = line.indexOf(':'); const key = colon < 0 ? line : line.slice(0, colon); const value = colon < 0 ? '' : line.slice(colon + 1).replace(/^ /, '');
|
|
478
|
+
if (key === 'event') event = value; else if (key === 'id') eventId = value; else if (key === 'data') data.push(value);
|
|
479
|
+
}
|
|
480
|
+
if (data.length === 0) continue;
|
|
481
|
+
if (event === 'stream.error') throw new ClientError('OBSERVATION_FAILED');
|
|
482
|
+
let raw: Record<string, unknown>;
|
|
483
|
+
try { raw = record(json(JSON.parse(data.join('\n')), frameBytes)); } catch { throw new ClientError('INVALID_STREAM'); }
|
|
484
|
+
const sequence = natural(raw['sequence']);
|
|
485
|
+
if (!eventTypes.includes(event) || raw['type'] !== event || raw['runId'] !== id || String(sequence) !== eventId || sequence <= cursor) throw new ClientError('INVALID_STREAM');
|
|
486
|
+
const metadata = record(raw['metadata']);
|
|
487
|
+
if (Object.keys(metadata).length > 64 || Object.values(metadata).some(value => !['string', 'number', 'boolean'].includes(typeof value))) throw new ClientError('INVALID_STREAM');
|
|
488
|
+
if (event === 'hook.started' || event === 'hook.completed') hookMetadata(metadata, event === 'hook.completed');
|
|
489
|
+
if (event === 'output.delta' || event === 'output.withheld') outputMetadata(metadata, event === 'output.delta');
|
|
490
|
+
if (event === 'events.gap') {
|
|
491
|
+
if (metadata['from'] !== cursor + 1 || metadata['to'] !== sequence
|
|
492
|
+
|| !Number.isSafeInteger(metadata['from']) || !Number.isSafeInteger(metadata['to']) || (metadata['to'] as number) < (metadata['from'] as number)) throw new ClientError('INVALID_STREAM');
|
|
493
|
+
} else if (sequence !== cursor + 1) throw new ClientError('INVALID_STREAM');
|
|
494
|
+
const timestamp = text(raw['timestamp'], 64); if (!Number.isFinite(Date.parse(timestamp))) throw new ClientError('INVALID_STREAM');
|
|
495
|
+
cursor = sequence;
|
|
496
|
+
yield Object.freeze({ runId: id, sequence, timestamp, type: event as ClientEvent['type'], metadata: Object.freeze(metadata) as ClientEvent['metadata'] });
|
|
497
|
+
}
|
|
498
|
+
if (encoder.encode(pending).byteLength > frameBytes) throw new ClientError('STREAM_LIMIT');
|
|
499
|
+
if (next.done) { if (pending.trim()) throw new ClientError('TRUNCATED_STREAM'); break; }
|
|
500
|
+
}
|
|
501
|
+
} finally { control.close(); if (reader) { void reader.cancel().catch(() => {}); reader.releaseLock(); } }
|
|
502
|
+
},
|
|
503
|
+
});
|
|
504
|
+
};
|
|
505
|
+
return Object.freeze({
|
|
506
|
+
run,
|
|
507
|
+
async agents(settings?: { readonly signal?: AbortSignal }) {
|
|
508
|
+
const raw = await command('/v1/agents', 'GET', settings?.signal);
|
|
509
|
+
if (!Array.isArray(raw['agents']) || raw['agents'].length > 256) return fail();
|
|
510
|
+
return Object.freeze(raw['agents'].map(value => { const item = record(value); return Object.freeze({ id: text(item['id']), version: text(item['version']) }); }));
|
|
511
|
+
},
|
|
512
|
+
async submit(agentId: string, input: unknown, settings: { readonly idempotencyKey: string; readonly signal?: AbortSignal }) {
|
|
513
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(settings.idempotencyKey)) throw new ClientError('INVALID_IDEMPOTENCY_KEY');
|
|
514
|
+
const raw = await command('/v1/runs', 'POST', settings.signal, json({ agentId, input }, maxBytes), settings.idempotencyKey);
|
|
515
|
+
if (raw['profile'] !== 'ephemeral') return fail(); return run(runId(raw['id']));
|
|
516
|
+
},
|
|
517
|
+
async humanRequests(settings?: { readonly after?: string; readonly limit?: number; readonly signal?: AbortSignal }) {
|
|
518
|
+
const after = settings?.after; const limit = settings?.limit ?? 50;
|
|
519
|
+
if ((after !== undefined && !/^[A-Za-z0-9._:-]{1,128}$/.test(after)) || !Number.isSafeInteger(limit) || limit < 1 || limit > 100) throw new ClientError('INVALID_CURSOR');
|
|
520
|
+
const query = new URLSearchParams({ limit: String(limit), ...(after === undefined ? {} : { after }) });
|
|
521
|
+
const raw = await command(`/v1/human-requests?${query}`, 'GET', settings?.signal);
|
|
522
|
+
if (!Array.isArray(raw['items']) || raw['items'].length > limit || (raw['next'] !== null && (typeof raw['next'] !== 'string' || !/^[A-Za-z0-9._:-]{1,128}$/.test(raw['next'])))) return fail();
|
|
523
|
+
const items = raw['items'].map(human); if (new Set(items.map(item => item.id)).size !== items.length) return fail();
|
|
524
|
+
return Object.freeze({ items: Object.freeze(items), next: raw['next'] as string | null });
|
|
525
|
+
},
|
|
526
|
+
async humanRequest(id: string, settings?: { readonly signal?: AbortSignal }) {
|
|
527
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,79}$/.test(id)) throw new ClientError('INVALID_REQUEST');
|
|
528
|
+
const result = human(record((await command(`/v1/human-requests/${id}`, 'GET', settings?.signal))['request']));
|
|
529
|
+
if (result.id !== id) return fail(); return result;
|
|
530
|
+
},
|
|
531
|
+
async workflow(id: string, settings?: { readonly signal?: AbortSignal }) {
|
|
532
|
+
if (!/^[a-f0-9]{64}$/.test(id)) throw new ClientError('INVALID_REQUEST');
|
|
533
|
+
const raw = await command(`/v1/workflow-runs/${id}`, 'GET', settings?.signal);
|
|
534
|
+
if (Object.keys(raw).length !== 1 || !Object.hasOwn(raw, 'workflow')) return fail(); return workflowView(raw['workflow'], id);
|
|
535
|
+
},
|
|
536
|
+
async workflows(settings?: { readonly after?: string; readonly limit?: number; readonly view?: 'active' | 'settled'; readonly signal?: AbortSignal }) {
|
|
537
|
+
const limit = settings?.limit ?? 20; const after = settings?.after; const view = settings?.view ?? 'active';
|
|
538
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 100 || (after !== undefined && !/^[A-Za-z0-9._:-]{1,128}$/.test(after))
|
|
539
|
+
|| (view !== 'active' && view !== 'settled')) throw new ClientError('INVALID_REQUEST');
|
|
540
|
+
const settled = view === 'settled';
|
|
541
|
+
const query = new URLSearchParams({ limit: String(limit), ...(after === undefined ? {} : { after }), ...(settled ? { view } : {}) });
|
|
542
|
+
const raw = await command(`/v1/workflow-runs?${query}`, 'GET', settings?.signal); const keys = Object.keys(raw);
|
|
543
|
+
if (keys.length !== 2 || !Object.hasOwn(raw, 'items') || !Object.hasOwn(raw, 'next') || !Array.isArray(raw['items']) || raw['items'].length > limit
|
|
544
|
+
|| (raw['next'] !== null && (typeof raw['next'] !== 'string' || !/^[A-Za-z0-9._:-]{1,128}$/.test(raw['next']) || raw['next'] === after))) return fail();
|
|
545
|
+
const items = raw['items'].map(item => workflowIndexEntry(item, settled)); if (new Set(items.map(item => item.runId)).size !== items.length) return fail();
|
|
546
|
+
return Object.freeze({ items: Object.freeze(items), next: raw['next'] as string | null });
|
|
547
|
+
},
|
|
548
|
+
async cancelWorkflow(id: string, revision: number, settings: WorkflowCommandOptions) {
|
|
549
|
+
if (!/^[a-f0-9]{64}$/.test(id) || !Number.isSafeInteger(revision) || revision < 1 || !settings
|
|
550
|
+
|| typeof settings.commandId !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/.test(settings.commandId)) throw new ClientError('INVALID_REQUEST');
|
|
551
|
+
const raw = await command(`/v1/workflow-runs/${id}/cancel`, 'POST', settings.signal,
|
|
552
|
+
json({ commandId: settings.commandId, revision }, maxBytes));
|
|
553
|
+
if (Object.keys(raw).length !== 1 || !Object.hasOwn(raw, 'workflow')) return fail(); return workflowView(raw['workflow'], id);
|
|
554
|
+
},
|
|
555
|
+
async approveWorkflow(id: string, approval: WorkflowApprovalCommand, settings: WorkflowCommandOptions) {
|
|
556
|
+
if (!/^[a-f0-9]{64}$/.test(id) || !approval || typeof approval.revision !== 'number' || !Number.isSafeInteger(approval.revision) || approval.revision < 1
|
|
557
|
+
|| typeof approval.nodeId !== 'string' || !/^[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(approval.nodeId)
|
|
558
|
+
|| typeof approval.approvalDigest !== 'string' || !/^[a-f0-9]{64}$/.test(approval.approvalDigest)
|
|
559
|
+
|| (approval.childRunId !== undefined && (typeof approval.childRunId !== 'string' || !/^[a-f0-9]{64}$/.test(approval.childRunId)))
|
|
560
|
+
|| !settings || typeof settings.commandId !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/.test(settings.commandId)) throw new ClientError('INVALID_REQUEST');
|
|
561
|
+
const raw = await command(`/v1/workflow-runs/${id}/approvals`, 'POST', settings.signal,
|
|
562
|
+
json({ commandId: settings.commandId, revision: approval.revision, nodeId: approval.nodeId,
|
|
563
|
+
approvalDigest: approval.approvalDigest, childRunId: approval.childRunId ?? null }, maxBytes));
|
|
564
|
+
if (Object.keys(raw).length !== 1 || !Object.hasOwn(raw, 'workflow')) return fail(); return workflowView(raw['workflow'], id);
|
|
565
|
+
},
|
|
566
|
+
async signalWorkflow(id: string, workflowSignal: WorkflowSignalCommand, settings: WorkflowCommandOptions) {
|
|
567
|
+
if (!/^[a-f0-9]{64}$/.test(id) || !workflowSignal || typeof workflowSignal.revision !== 'number'
|
|
568
|
+
|| !Number.isSafeInteger(workflowSignal.revision) || workflowSignal.revision < 1
|
|
569
|
+
|| typeof workflowSignal.signalId !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/.test(workflowSignal.signalId)
|
|
570
|
+
|| typeof workflowSignal.signalName !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/.test(workflowSignal.signalName)
|
|
571
|
+
|| !settings || typeof settings.commandId !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/.test(settings.commandId))
|
|
572
|
+
throw new ClientError('INVALID_REQUEST');
|
|
573
|
+
let value: ClientJson; try { value = json(workflowSignal.value, 4_096); } catch { throw new ClientError('INVALID_REQUEST'); }
|
|
574
|
+
const raw = await command(`/v1/workflow-runs/${id}/signals`, 'POST', settings.signal,
|
|
575
|
+
json({ commandId: settings.commandId, revision: workflowSignal.revision, signalId: workflowSignal.signalId,
|
|
576
|
+
signalName: workflowSignal.signalName, value }, maxBytes));
|
|
577
|
+
if (Object.keys(raw).length !== 1 || !Object.hasOwn(raw, 'workflow')) return fail(); return workflowView(raw['workflow'], id);
|
|
578
|
+
},
|
|
579
|
+
async resumeWorkflow(id: string, revision: number, settings: WorkflowCommandOptions) {
|
|
580
|
+
if (!/^[a-f0-9]{64}$/.test(id) || !Number.isSafeInteger(revision) || revision < 1 || !settings
|
|
581
|
+
|| typeof settings.commandId !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/.test(settings.commandId)) throw new ClientError('INVALID_REQUEST');
|
|
582
|
+
const raw = await command(`/v1/workflow-runs/${id}/resume`, 'POST', settings.signal,
|
|
583
|
+
json({ commandId: settings.commandId, revision }, maxBytes));
|
|
584
|
+
if (Object.keys(raw).length !== 1 || !Object.hasOwn(raw, 'workflow')) return fail(); return workflowView(raw['workflow'], id);
|
|
585
|
+
},
|
|
586
|
+
async pauseWorkflow(id: string, revision: number, settings: WorkflowCommandOptions) {
|
|
587
|
+
if (!/^[a-f0-9]{64}$/.test(id) || !Number.isSafeInteger(revision) || revision < 1 || !settings
|
|
588
|
+
|| typeof settings.commandId !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/.test(settings.commandId)) throw new ClientError('INVALID_REQUEST');
|
|
589
|
+
const raw = await command(`/v1/workflow-runs/${id}/pause`, 'POST', settings.signal,
|
|
590
|
+
json({ commandId: settings.commandId, revision }, maxBytes));
|
|
591
|
+
if (Object.keys(raw).length !== 1 || !Object.hasOwn(raw, 'workflow')) return fail(); return workflowView(raw['workflow'], id);
|
|
592
|
+
},
|
|
593
|
+
async workflowMigrations(id: string, settings?: { readonly signal?: AbortSignal }) {
|
|
594
|
+
if (!/^[a-f0-9]{64}$/.test(id)) throw new ClientError('INVALID_REQUEST');
|
|
595
|
+
const raw = await command(`/v1/workflow-runs/${id}/migrations`, 'GET', settings?.signal);
|
|
596
|
+
if (Object.keys(raw).length !== 1 || !Array.isArray(raw['migrations']) || raw['migrations'].length > 256) return fail();
|
|
597
|
+
const offers = raw['migrations'].map(migrationOffer); if (new Set(offers.map(item => item.id)).size !== offers.length) return fail();
|
|
598
|
+
return Object.freeze(offers);
|
|
599
|
+
},
|
|
600
|
+
async planWorkflowMigration(id: string, migrationId: string, settings?: { readonly signal?: AbortSignal }) {
|
|
601
|
+
if (!/^[a-f0-9]{64}$/.test(id) || typeof migrationId !== 'string' || !migrationIdPattern.test(migrationId)) throw new ClientError('INVALID_REQUEST');
|
|
602
|
+
const raw = await command(`/v1/workflow-runs/${id}/migrations/${migrationId}`, 'GET', settings?.signal);
|
|
603
|
+
if (Object.keys(raw).length !== 1 || !Object.hasOwn(raw, 'plan')) return fail(); return migrationPlan(raw['plan'], id, migrationId);
|
|
604
|
+
},
|
|
605
|
+
async migrateWorkflow(id: string, migrationId: string, revision: number, settings: WorkflowCommandOptions) {
|
|
606
|
+
if (!/^[a-f0-9]{64}$/.test(id) || typeof migrationId !== 'string' || !migrationIdPattern.test(migrationId) || !Number.isSafeInteger(revision) || revision < 1 || !settings
|
|
607
|
+
|| typeof settings.commandId !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/.test(settings.commandId)) throw new ClientError('INVALID_REQUEST');
|
|
608
|
+
const raw = await command(`/v1/workflow-runs/${id}/migrations/${migrationId}`, 'POST', settings.signal, json({ commandId: settings.commandId, revision }, maxBytes));
|
|
609
|
+
if (Object.keys(raw).length !== 2 || !Object.hasOwn(raw, 'plan') || !Object.hasOwn(raw, 'workflow')) return fail();
|
|
610
|
+
const plan = migrationPlan(raw['plan'], id, migrationId); const workflow = workflowView(raw['workflow'], id);
|
|
611
|
+
if (!plan.allowed || workflow.revision <= revision) return fail();
|
|
612
|
+
return Object.freeze({ plan, workflow });
|
|
613
|
+
},
|
|
614
|
+
async workflowFleet(settings?: { readonly signal?: AbortSignal }) {
|
|
615
|
+
const raw = await command('/v1/workflow-fleet', 'GET', settings?.signal);
|
|
616
|
+
if (Object.keys(raw).length !== 1 || !Object.hasOwn(raw, 'fleet')) return fail(); return fleetHold(raw['fleet']);
|
|
617
|
+
},
|
|
618
|
+
async holdWorkflowFleet(settings?: { readonly signal?: AbortSignal }) {
|
|
619
|
+
const raw = await command('/v1/workflow-fleet/hold', 'POST', settings?.signal, json({}, maxBytes));
|
|
620
|
+
if (Object.keys(raw).length !== 1 || !Object.hasOwn(raw, 'fleet')) return fail();
|
|
621
|
+
const fleet = fleetHold(raw['fleet']); if (!fleet.held) return fail(); return fleet;
|
|
622
|
+
},
|
|
623
|
+
async releaseWorkflowFleet(settings?: { readonly signal?: AbortSignal }) {
|
|
624
|
+
const raw = await command('/v1/workflow-fleet/release', 'POST', settings?.signal, json({}, maxBytes));
|
|
625
|
+
if (Object.keys(raw).length !== 1 || !Object.hasOwn(raw, 'fleet')) return fail();
|
|
626
|
+
const fleet = fleetHold(raw['fleet']); if (fleet.held) return fail(); return fleet;
|
|
627
|
+
},
|
|
628
|
+
async sweepWorkflowFleet(phase: 'pause' | 'resume', sweep: { readonly cursor: ClientJson | null; readonly limit?: number }, settings?: { readonly signal?: AbortSignal }) {
|
|
629
|
+
const limit = sweep?.limit ?? 32;
|
|
630
|
+
if (!['pause', 'resume'].includes(phase) || !Number.isSafeInteger(limit) || limit < 1 || limit > 128
|
|
631
|
+
|| (sweep.cursor !== null && (!sweep.cursor || typeof sweep.cursor !== 'object' || Array.isArray(sweep.cursor)))) throw new ClientError('INVALID_REQUEST');
|
|
632
|
+
let cursor: ClientJson | null;
|
|
633
|
+
try { cursor = sweep.cursor === null ? null : json(sweep.cursor, 4_096); } catch { throw new ClientError('INVALID_REQUEST'); }
|
|
634
|
+
const raw = await command(`/v1/workflow-fleet/sweeps/${phase}`, 'POST', settings?.signal, json({ cursor, limit }, maxBytes));
|
|
635
|
+
if (Object.keys(raw).length !== 1 || !Object.hasOwn(raw, 'sweep')) return fail(); return fleetSweep(raw['sweep'], limit);
|
|
636
|
+
},
|
|
637
|
+
async respondHumanRequest(id: string, requestDigest: string, value: unknown, settings: { readonly commandId: string; readonly signal?: AbortSignal }) {
|
|
638
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,79}$/.test(id) || !/^[a-f0-9]{64}$/.test(requestDigest)
|
|
639
|
+
|| !/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/.test(settings.commandId)) throw new ClientError('INVALID_REQUEST');
|
|
640
|
+
const raw = await command(`/v1/human-requests/${id}/responses`, 'POST', settings.signal,
|
|
641
|
+
json({ commandId: settings.commandId, requestDigest, value }, maxBytes));
|
|
642
|
+
const result = human(record(raw['request']));
|
|
643
|
+
if (result.id !== id || result.digest !== requestDigest || result.status === 'waiting') return fail(); return result;
|
|
644
|
+
},
|
|
645
|
+
});
|
|
646
|
+
}
|