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,945 @@
|
|
|
1
|
+
import { assertPositiveInteger, Budget, freezeJson, jsonValue, MayuraError, publicError, validate, } from '../../core/dist/index.js';
|
|
2
|
+
import { readManagedGuardDefinition } from '../../core/dist/host.js';
|
|
3
|
+
import { invokeTool } from '../../tools/dist/index.js';
|
|
4
|
+
import { bindToolBudgetTicket } from '../../tools/dist/host.js';
|
|
5
|
+
import { assertAgent, isIdentifier } from './agent.js';
|
|
6
|
+
import { EventBuffer } from './event-buffer.js';
|
|
7
|
+
import { modelCost, modelFailureCost, modelResponse } from './response.js';
|
|
8
|
+
import { createBatcher, createFieldExtractor } from './stream.js';
|
|
9
|
+
import { childGateway, isAgentTool } from './composition.js';
|
|
10
|
+
import { OperationPermits } from './permits.js';
|
|
11
|
+
import { evaluateManagedGuard } from './managed-guards.js';
|
|
12
|
+
import { readHookDefinition } from './hooks.js';
|
|
13
|
+
import { evaluateHook, evaluateObserver } from './hook-execution.js';
|
|
14
|
+
const defaults = Object.freeze({
|
|
15
|
+
maxSteps: 16, maxModelCalls: 16, maxToolCalls: 64, maxHookCalls: 128, maxDurationMs: 60_000,
|
|
16
|
+
maxInputBytes: 1_048_576, maxOutputBytes: 1_048_576, maxContextBytes: 2_097_152,
|
|
17
|
+
maxOutputTokens: 4_096, maxCostMicros: 0, maxEventRetention: 256, maxConcurrentRuns: 32,
|
|
18
|
+
maxDescendantRuns: 64, maxDepth: 8, maxConcurrentOperations: 32,
|
|
19
|
+
});
|
|
20
|
+
function limitsFor(options) {
|
|
21
|
+
const result = { ...defaults, ...options };
|
|
22
|
+
if (Object.keys(result).some((key) => !(key in defaults)))
|
|
23
|
+
throw new MayuraError('INVALID_CONFIG', 'Unknown runtime limit.');
|
|
24
|
+
for (const [key, value] of Object.entries(result)) {
|
|
25
|
+
// Zero is meaningful for cost and tool calls (an agent with no tools makes none); every other limit is positive.
|
|
26
|
+
if (key === 'maxCostMicros' || key === 'maxToolCalls') {
|
|
27
|
+
if (!Number.isSafeInteger(value) || value < 0)
|
|
28
|
+
throw new MayuraError('INVALID_CONFIG', `${key} must be a non-negative safe integer.`);
|
|
29
|
+
}
|
|
30
|
+
else
|
|
31
|
+
assertPositiveInteger(value, key);
|
|
32
|
+
}
|
|
33
|
+
if (result.maxDurationMs > 2_147_483_647 || !Number.isSafeInteger(result.maxModelCalls + result.maxToolCalls)) {
|
|
34
|
+
throw new MayuraError('INVALID_CONFIG', 'Runtime limits exceed the supported counter or timer range.');
|
|
35
|
+
}
|
|
36
|
+
if (result.maxDepth > 32 || result.maxDescendantRuns > 1023 || result.maxConcurrentOperations > 1024
|
|
37
|
+
|| result.maxConcurrentRuns > 1024 || result.maxModelCalls > 4096 || result.maxToolCalls > 4096 || result.maxHookCalls > 4096) {
|
|
38
|
+
throw new MayuraError('INVALID_CONFIG', 'Runtime tree or operation limits exceed supported bounds.');
|
|
39
|
+
}
|
|
40
|
+
return Object.freeze(result);
|
|
41
|
+
}
|
|
42
|
+
/** Race cooperative async work against cancellation; retained rejection handlers prevent late unhandled failures. */
|
|
43
|
+
async function cancellable(operation, signal) {
|
|
44
|
+
if (signal.aborted)
|
|
45
|
+
throw signal.reason;
|
|
46
|
+
return await new Promise((resolve, reject) => {
|
|
47
|
+
const abort = () => { cleanup(); reject(signal.reason); };
|
|
48
|
+
const cleanup = () => { signal.removeEventListener('abort', abort); };
|
|
49
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
50
|
+
Promise.resolve().then(() => {
|
|
51
|
+
if (signal.aborted)
|
|
52
|
+
throw signal.reason;
|
|
53
|
+
return operation();
|
|
54
|
+
}).then((value) => { cleanup(); resolve(value); }, (error) => { cleanup(); reject(error); });
|
|
55
|
+
if (signal.aborted)
|
|
56
|
+
abort();
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function outcomeFor(error) {
|
|
60
|
+
const safe = publicError(error, 'MODEL_FAILED');
|
|
61
|
+
const status = safe.code === 'CANCELLED' ? 'cancelled'
|
|
62
|
+
: ['PERMISSION_DENIED', 'BUDGET_EXCEEDED', 'GUARD_BLOCKED', 'GUARD_UNAVAILABLE'].includes(safe.code) ? 'blocked'
|
|
63
|
+
: 'failed';
|
|
64
|
+
return Object.freeze({ status, error: Object.freeze(safe) });
|
|
65
|
+
}
|
|
66
|
+
function permissionsFor(supplied, required = false) {
|
|
67
|
+
const allow = supplied?.allow ?? (required ? undefined : []);
|
|
68
|
+
if (!Array.isArray(allow) || allow.length > 4096 || allow.some((grant) => typeof grant !== 'string' || grant.length === 0 || grant.length > 256)) {
|
|
69
|
+
throw new MayuraError('INVALID_CONFIG', 'Permissions must be an explicit list of bounded capability names.');
|
|
70
|
+
}
|
|
71
|
+
return Object.freeze({ allow: Object.freeze([...new Set(allow)]) });
|
|
72
|
+
}
|
|
73
|
+
function ancestors(state) {
|
|
74
|
+
const path = [];
|
|
75
|
+
for (let current = state; current; current = current.parent)
|
|
76
|
+
path.push(current);
|
|
77
|
+
return path;
|
|
78
|
+
}
|
|
79
|
+
function subtree(state) { return [state, ...state.children.flatMap(subtree)]; }
|
|
80
|
+
function evidenceFor(state) {
|
|
81
|
+
return Object.freeze(subtree(state).flatMap((run) => [...run.receipts.values()].map((receipt) => Object.freeze({ runId: run.id, receipt }))));
|
|
82
|
+
}
|
|
83
|
+
/** Preserve known late evidence when a stale cancellation snapshot still says unknown. */
|
|
84
|
+
function record(state, receipt) {
|
|
85
|
+
const old = state.receipts.get(receipt.callId);
|
|
86
|
+
const execution = old && ['succeeded', 'failed'].includes(old.execution) && !['succeeded', 'failed'].includes(receipt.execution)
|
|
87
|
+
? old.execution : receipt.execution;
|
|
88
|
+
state.receipts.set(receipt.callId, Object.freeze({ ...receipt, execution }));
|
|
89
|
+
}
|
|
90
|
+
function checkCalls(state, kind, count) {
|
|
91
|
+
for (const current of ancestors(state)) {
|
|
92
|
+
const remaining = kind === 'model' ? current.limits.maxModelCalls - current.modelCalls - current.heldModelCalls
|
|
93
|
+
: current.limits.maxToolCalls - current.toolCalls - current.heldToolCalls;
|
|
94
|
+
if (count > remaining)
|
|
95
|
+
throw new MayuraError('LIMIT_EXCEEDED', 'An ancestor execution-call limit was reached.');
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/** Internal atomic projection: only freshly-created primitive records reach the core commit. */
|
|
99
|
+
function reserveCalls(state, operations) {
|
|
100
|
+
const path = ancestors(state);
|
|
101
|
+
const modelCount = operations.filter(operation => operation.kind === 'model').length;
|
|
102
|
+
const toolCount = operations.length - modelCount;
|
|
103
|
+
checkCalls(state, 'model', modelCount);
|
|
104
|
+
checkCalls(state, 'tool', toolCount);
|
|
105
|
+
const bundleId = crypto.randomUUID();
|
|
106
|
+
const bundle = state.budget.reserveBundle(operations.map((operation, index) => ({ id: `${state.id}/${bundleId}/${index}`, maxCostMicros: operation.maxCostMicros })));
|
|
107
|
+
// No application callback, await, hook or logger occurs between the two ledger projections.
|
|
108
|
+
for (const account of path) {
|
|
109
|
+
account.heldModelCalls += modelCount;
|
|
110
|
+
account.heldToolCalls += toolCount;
|
|
111
|
+
}
|
|
112
|
+
const entries = operations.map((operation, index) => ({ ticket: bundle.tickets[index], kind: operation.kind, counted: false, cancelled: false }));
|
|
113
|
+
let closed = false;
|
|
114
|
+
const result = { entries, close: () => {
|
|
115
|
+
if (closed)
|
|
116
|
+
return;
|
|
117
|
+
bundle.close();
|
|
118
|
+
for (const entry of entries)
|
|
119
|
+
if (!entry.counted) {
|
|
120
|
+
for (const account of path) {
|
|
121
|
+
if (entry.kind === 'model')
|
|
122
|
+
account.heldModelCalls--;
|
|
123
|
+
else
|
|
124
|
+
account.heldToolCalls--;
|
|
125
|
+
}
|
|
126
|
+
entry.cancelled = true;
|
|
127
|
+
}
|
|
128
|
+
closed = true;
|
|
129
|
+
state.bundles.delete(result);
|
|
130
|
+
} };
|
|
131
|
+
state.bundles.add(result);
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
function consumeCall(state, entry, kind) {
|
|
135
|
+
if (entry.kind !== kind || entry.counted || entry.cancelled)
|
|
136
|
+
throw new MayuraError('CONFLICT', 'The runtime invocation was already consumed, cancelled or has the wrong kind.');
|
|
137
|
+
const reservation = kind === 'model' ? entry.ticket.start() : undefined;
|
|
138
|
+
for (const account of ancestors(state)) {
|
|
139
|
+
if (kind === 'model') {
|
|
140
|
+
account.heldModelCalls--;
|
|
141
|
+
account.modelCalls++;
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
account.heldToolCalls--;
|
|
145
|
+
account.toolCalls++;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
entry.counted = true;
|
|
149
|
+
return reservation;
|
|
150
|
+
}
|
|
151
|
+
const violationBoundary = {
|
|
152
|
+
beforeExecution: 'execution', beforeStep: 'execution', beforeModelCall: 'model', beforeToolCall: 'tool', beforeDelegate: 'delegate', beforeOutputRelease: 'output',
|
|
153
|
+
};
|
|
154
|
+
function canonicalJson(value) {
|
|
155
|
+
if (value === null || typeof value !== 'object')
|
|
156
|
+
return JSON.stringify(value);
|
|
157
|
+
if (Array.isArray(value))
|
|
158
|
+
return `[${value.map(canonicalJson).join(',')}]`;
|
|
159
|
+
return `{${Object.keys(value).sort().map(key => `${JSON.stringify(key)}:${canonicalJson(value[key])}`).join(',')}}`;
|
|
160
|
+
}
|
|
161
|
+
function terminalView(stage, outcome) {
|
|
162
|
+
return Object.freeze({ stage, status: outcome.status, ...(outcome.status === 'succeeded' ? {} : { error: Object.freeze({ code: outcome.error.code }) }) });
|
|
163
|
+
}
|
|
164
|
+
/** Process-local structured concurrency. No restart recovery or hard callback isolation is promised. */
|
|
165
|
+
export function createRuntime(options) {
|
|
166
|
+
if (options.profile !== 'ephemeral')
|
|
167
|
+
throw new MayuraError('UNSUPPORTED_PROFILE', 'Only the explicit ephemeral profile is supported by this runtime.');
|
|
168
|
+
const rootLimits = limitsFor(options.limits);
|
|
169
|
+
const rootPermissions = permissionsFor(options.permissions);
|
|
170
|
+
const suppliedScope = options.scope ?? { principalId: 'local', projectId: 'default' };
|
|
171
|
+
if (!isIdentifier(suppliedScope.principalId) || !isIdentifier(suppliedScope.projectId)) {
|
|
172
|
+
throw new MayuraError('INVALID_CONFIG', 'Scope requires bounded principal and project identifiers.');
|
|
173
|
+
}
|
|
174
|
+
const scope = Object.freeze({ principalId: suppliedScope.principalId, projectId: suppliedScope.projectId });
|
|
175
|
+
const active = new Map();
|
|
176
|
+
const states = new WeakMap();
|
|
177
|
+
const operations = new OperationPermits(rootLimits.maxConcurrentOperations, Math.min(65536, rootLimits.maxConcurrentRuns * (rootLimits.maxDescendantRuns + 1)));
|
|
178
|
+
let activeRoots = 0;
|
|
179
|
+
let closed = false;
|
|
180
|
+
const lookup = (handle) => {
|
|
181
|
+
const state = states.get(handle);
|
|
182
|
+
if (!state)
|
|
183
|
+
throw new MayuraError('PERMISSION_DENIED', 'A genuine handle from this runtime is required.');
|
|
184
|
+
return state;
|
|
185
|
+
};
|
|
186
|
+
const admitChild = (parent, agent, input, child, inputAdmitted = false, signal, speculative = false) => {
|
|
187
|
+
if (Date.now() >= parent.deadline && !parent.controller.signal.aborted)
|
|
188
|
+
parent.controller.abort(new MayuraError('TIMEOUT', 'The parent deadline elapsed.'));
|
|
189
|
+
if (closed || !parent.accepting || parent.status !== 'running' || parent.controller.signal.aborted || signal?.aborted) {
|
|
190
|
+
throw new MayuraError('CONFLICT', 'The parent no longer accepts child execution.');
|
|
191
|
+
}
|
|
192
|
+
assertAgent(agent);
|
|
193
|
+
if (!parent.permissions.allow.includes('agent:delegate'))
|
|
194
|
+
throw new MayuraError('PERMISSION_DENIED', 'Child delegation is not authorized.');
|
|
195
|
+
const path = ancestors(parent);
|
|
196
|
+
if (path.some((item) => item.agent === agent || item.agent.id === agent.id))
|
|
197
|
+
throw new MayuraError('CONFLICT', 'Recursive agent ancestry is not supported.');
|
|
198
|
+
if (path.some((item) => item.descendants >= item.limits.maxDescendantRuns) || parent.depth + 1 > parent.limits.maxDepth) {
|
|
199
|
+
throw new MayuraError('LIMIT_EXCEEDED', 'The descendant or depth limit was reached.');
|
|
200
|
+
}
|
|
201
|
+
const limits = limitsFor({ ...parent.limits, ...child.limits });
|
|
202
|
+
if (limits.maxConcurrentRuns !== parent.limits.maxConcurrentRuns)
|
|
203
|
+
throw new MayuraError('INVALID_CONFIG', 'maxConcurrentRuns controls root admission only.');
|
|
204
|
+
if (parent.depth + 1 > limits.maxDepth)
|
|
205
|
+
throw new MayuraError('LIMIT_EXCEEDED', 'The child depth ceiling was reached.');
|
|
206
|
+
if (Object.entries(limits).some(([key, value]) => value > parent.limits[key])) {
|
|
207
|
+
throw new MayuraError('INVALID_CONFIG', 'Child limits cannot exceed parent ceilings.');
|
|
208
|
+
}
|
|
209
|
+
const requested = permissionsFor(child.permissions, true);
|
|
210
|
+
const permissions = permissionsFor({ allow: requested.allow.filter((grant) => parent.permissions.allow.includes(grant)) });
|
|
211
|
+
return start(agent, input, limits, permissions, parent, inputAdmitted, signal, speculative);
|
|
212
|
+
};
|
|
213
|
+
const start = (agent, suppliedInput, limits, permissions, parent, inputAdmitted = false, externalSignal, speculative = false) => {
|
|
214
|
+
if (closed)
|
|
215
|
+
throw new MayuraError('CONFLICT', 'Runtime is closed and cannot accept new runs.');
|
|
216
|
+
assertAgent(agent);
|
|
217
|
+
if (!parent && activeRoots >= rootLimits.maxConcurrentRuns)
|
|
218
|
+
throw new MayuraError('LIMIT_EXCEEDED', 'The runtime concurrent-root limit is reached.');
|
|
219
|
+
let input;
|
|
220
|
+
try {
|
|
221
|
+
input = freezeJson(jsonValue(suppliedInput, { maxBytes: limits.maxInputBytes }));
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
throw new MayuraError('INVALID_INPUT', 'Submitted input must satisfy the JSON and size limits.');
|
|
225
|
+
}
|
|
226
|
+
const id = crypto.randomUUID();
|
|
227
|
+
const controller = new AbortController();
|
|
228
|
+
const events = new EventBuffer(id, limits.maxEventRetention);
|
|
229
|
+
const budget = parent ? parent.budget.fork({ id, maxCostMicros: limits.maxCostMicros, maxCalls: limits.maxModelCalls + limits.maxToolCalls })
|
|
230
|
+
: new Budget(limits.maxCostMicros, limits.maxModelCalls + limits.maxToolCalls);
|
|
231
|
+
const grants = new Set(permissions.allow);
|
|
232
|
+
const tools = new Map(agent.tools.map((tool) => [tool.id, tool]));
|
|
233
|
+
const callIds = new Set();
|
|
234
|
+
let terminal = false;
|
|
235
|
+
let settle;
|
|
236
|
+
const result = new Promise((resolve) => { settle = resolve; });
|
|
237
|
+
const deadline = Math.min(Date.now() + limits.maxDurationMs, parent?.deadline ?? Infinity);
|
|
238
|
+
const timer = setTimeout(() => {
|
|
239
|
+
if (!terminal)
|
|
240
|
+
controller.abort(new MayuraError('TIMEOUT', 'The run deadline elapsed; no new work will be dispatched.'));
|
|
241
|
+
}, Math.max(0, deadline - Date.now()));
|
|
242
|
+
const handle = Object.freeze({
|
|
243
|
+
id, profile: 'ephemeral', result: () => result,
|
|
244
|
+
observe: (observerOptions) => events.observe(observerOptions),
|
|
245
|
+
cancel: () => { if (!terminal && !controller.signal.aborted)
|
|
246
|
+
controller.abort(new MayuraError('CANCELLED', 'Run cancellation was requested.')); },
|
|
247
|
+
});
|
|
248
|
+
const runOperations = (parent?.operations ?? operations).fork(limits.maxConcurrentOperations);
|
|
249
|
+
const state = { id, events, agent, parent, depth: parent ? parent.depth + 1 : 0, deadline, limits, permissions, budget, operations: runOperations, controller,
|
|
250
|
+
handle, children: [], speculative, receipts: new Map(), accepting: true, status: 'running', descendants: 0, modelCalls: 0, toolCalls: 0, hookCalls: 0,
|
|
251
|
+
heldModelCalls: 0, heldToolCalls: 0, bundles: new Set() };
|
|
252
|
+
Object.defineProperty(state, 'root', { value: parent?.root ?? state });
|
|
253
|
+
const relayParent = () => { if (!controller.signal.aborted)
|
|
254
|
+
controller.abort(parent?.controller.signal.reason); };
|
|
255
|
+
const relayExternal = () => { if (!controller.signal.aborted)
|
|
256
|
+
controller.abort(new MayuraError('CANCELLED', 'The composing invocation was cancelled.')); };
|
|
257
|
+
parent?.controller.signal.addEventListener('abort', relayParent, { once: true });
|
|
258
|
+
externalSignal?.addEventListener('abort', relayExternal, { once: true });
|
|
259
|
+
if (parent?.controller.signal.aborted)
|
|
260
|
+
relayParent();
|
|
261
|
+
if (externalSignal?.aborted)
|
|
262
|
+
relayExternal();
|
|
263
|
+
// Closing admissions never releases unknown charges; callback settlement remains valid.
|
|
264
|
+
controller.signal.addEventListener('abort', () => {
|
|
265
|
+
state.accepting = false;
|
|
266
|
+
budget.close();
|
|
267
|
+
for (const bundle of state.bundles)
|
|
268
|
+
bundle.close();
|
|
269
|
+
}, { once: true });
|
|
270
|
+
if (parent) {
|
|
271
|
+
parent.children.push(state);
|
|
272
|
+
for (const item of ancestors(parent))
|
|
273
|
+
item.descendants++;
|
|
274
|
+
parent.events.emit('delegate.started', { childRunId: id, childAgentId: agent.id });
|
|
275
|
+
}
|
|
276
|
+
else
|
|
277
|
+
activeRoots++;
|
|
278
|
+
states.set(handle, state);
|
|
279
|
+
active.set(id, handle);
|
|
280
|
+
const checkCancelled = (signal = controller.signal) => {
|
|
281
|
+
if (Date.now() >= deadline && !controller.signal.aborted)
|
|
282
|
+
controller.abort(new MayuraError('TIMEOUT', 'The run deadline elapsed.'));
|
|
283
|
+
if (controller.signal.aborted)
|
|
284
|
+
throw controller.signal.reason;
|
|
285
|
+
if (signal.aborted)
|
|
286
|
+
throw signal.reason;
|
|
287
|
+
};
|
|
288
|
+
const managed = (checks) => checks.flatMap(check => {
|
|
289
|
+
const descriptor = readManagedGuardDefinition(check);
|
|
290
|
+
return descriptor ? [{ handle: check, descriptor }] : [];
|
|
291
|
+
});
|
|
292
|
+
const requiredChecks = (checks) => {
|
|
293
|
+
const definitions = managed(checks);
|
|
294
|
+
for (const { descriptor } of definitions)
|
|
295
|
+
if (!grants.has(`model:${descriptor.model.id}`)) {
|
|
296
|
+
throw new MayuraError('PERMISSION_DENIED', 'A required managed guard model destination is not authorized.');
|
|
297
|
+
}
|
|
298
|
+
return definitions;
|
|
299
|
+
};
|
|
300
|
+
const operationBundle = (kind, maxCostMicros) => {
|
|
301
|
+
const definitions = requiredChecks(agent.guards.output);
|
|
302
|
+
return reserveCalls(state, [{ kind, maxCostMicros }, ...definitions.map(({ descriptor }) => ({ kind: 'model', maxCostMicros: descriptor.model.maxCostMicros }))]);
|
|
303
|
+
};
|
|
304
|
+
/** Runs the guards and returns the content to use: the original, or what local guards rewrote it to. */
|
|
305
|
+
const guard = async (checks, value, boundary, callId, held, signal = controller.signal) => {
|
|
306
|
+
try {
|
|
307
|
+
return await guardChecks(checks, value, boundary, callId, held, signal);
|
|
308
|
+
}
|
|
309
|
+
catch (error) {
|
|
310
|
+
if (error instanceof MayuraError && error.code === 'GUARD_BLOCKED') {
|
|
311
|
+
await observe(Object.freeze({ stage: 'onViolation', source: 'guard', boundary, code: 'GUARD_BLOCKED', callId }), null, { signal });
|
|
312
|
+
}
|
|
313
|
+
throw error;
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
/**
|
|
317
|
+
* Guard `value`; if a guard rewrote it, validate the rewrite against `schema` again so a rewrite can never hand on a
|
|
318
|
+
* value its boundary would have refused. Returns the frozen content to use.
|
|
319
|
+
*/
|
|
320
|
+
const guarded = async (checks, value, schema, boundary, callId, maxBytes, held, signal = controller.signal) => {
|
|
321
|
+
const result = await guard(checks, value, boundary, callId, held, signal);
|
|
322
|
+
if (result === value)
|
|
323
|
+
return value;
|
|
324
|
+
const revalidated = await cancellable(() => runOperations.run(signal, async () => {
|
|
325
|
+
checkCancelled(signal);
|
|
326
|
+
return await validate(schema, result, boundary, { maxBytes });
|
|
327
|
+
}), signal);
|
|
328
|
+
return freezeJson(jsonValue(revalidated, { maxBytes }));
|
|
329
|
+
};
|
|
330
|
+
const guardChecks = async (checks, value, boundary, callId, held, signal = controller.signal) => {
|
|
331
|
+
checkCancelled(signal);
|
|
332
|
+
const definitions = managed(checks);
|
|
333
|
+
const local = checks.filter(check => !readManagedGuardDefinition(check));
|
|
334
|
+
// Local guards run in declared order, each on the content the one before it allowed or rewrote.
|
|
335
|
+
let current = value;
|
|
336
|
+
for (const check of local) {
|
|
337
|
+
const verdict = await cancellable(() => runOperations.run(signal, async () => {
|
|
338
|
+
try {
|
|
339
|
+
checkCancelled(signal);
|
|
340
|
+
const raw = await check.check(current, Object.freeze({ runId: id, callId, scope, signal, boundary }));
|
|
341
|
+
// Read adapter-owned properties inside the redaction boundary; do not retain a mutable verdict.
|
|
342
|
+
const decision = raw?.decision;
|
|
343
|
+
if (decision === 'allow' || decision === 'block')
|
|
344
|
+
return { decision };
|
|
345
|
+
if (decision === 'rewrite')
|
|
346
|
+
return { decision, value: freezeJson(jsonValue(raw.value, { maxBytes: limits.maxOutputBytes })) };
|
|
347
|
+
throw new Error();
|
|
348
|
+
}
|
|
349
|
+
catch {
|
|
350
|
+
throw new MayuraError('GUARD_UNAVAILABLE', 'A required guard could not complete its check.');
|
|
351
|
+
}
|
|
352
|
+
}), signal);
|
|
353
|
+
checkCancelled(signal);
|
|
354
|
+
if (verdict.decision === 'block')
|
|
355
|
+
throw new MayuraError('GUARD_BLOCKED', 'A required guard withheld this content.');
|
|
356
|
+
if (verdict.decision === 'rewrite')
|
|
357
|
+
current = verdict.value;
|
|
358
|
+
}
|
|
359
|
+
if (definitions.length === 0)
|
|
360
|
+
return current;
|
|
361
|
+
requiredChecks(checks);
|
|
362
|
+
const owned = held === undefined ? reserveCalls(state, definitions.map(({ descriptor }) => ({ kind: 'model', maxCostMicros: descriptor.model.maxCostMicros }))) : undefined;
|
|
363
|
+
const entries = held ?? owned.entries;
|
|
364
|
+
try {
|
|
365
|
+
if (entries.length !== definitions.length)
|
|
366
|
+
throw new MayuraError('CONFLICT', 'Required guard reservations do not match this barrier.');
|
|
367
|
+
const results = await cancellable(() => Promise.allSettled(definitions.map(({ descriptor }, index) => {
|
|
368
|
+
const entry = entries[index];
|
|
369
|
+
const metadata = { purpose: 'guardrail', modelId: descriptor.model.id, checkId: descriptor.id, checkVersion: descriptor.version, boundary, callId };
|
|
370
|
+
return evaluateManagedGuard({ descriptor, candidate: current,
|
|
371
|
+
context: Object.freeze({ runId: id, callId, scope, signal, boundary }), limits, operations: runOperations,
|
|
372
|
+
assertActive: () => checkCancelled(signal),
|
|
373
|
+
start: () => {
|
|
374
|
+
checkCancelled(signal);
|
|
375
|
+
if (!grants.has(`model:${descriptor.model.id}`))
|
|
376
|
+
throw new MayuraError('PERMISSION_DENIED', 'The managed guard model destination is not authorized.');
|
|
377
|
+
return consumeCall(state, entry, 'model');
|
|
378
|
+
},
|
|
379
|
+
onStarted: () => { events.emit('model.started', { ...metadata, modelCall: state.modelCalls }); },
|
|
380
|
+
onCompleted: (decision) => { events.emit('model.completed', { ...metadata, response: 'final', decision }); },
|
|
381
|
+
});
|
|
382
|
+
})), signal);
|
|
383
|
+
const rejected = results.find(result => result.status === 'rejected');
|
|
384
|
+
if (rejected?.status === 'rejected')
|
|
385
|
+
throw rejected.reason;
|
|
386
|
+
checkCancelled(signal);
|
|
387
|
+
}
|
|
388
|
+
finally {
|
|
389
|
+
owned?.close();
|
|
390
|
+
}
|
|
391
|
+
return current;
|
|
392
|
+
};
|
|
393
|
+
const preflight = async (tool, rawInput, signal = controller.signal) => {
|
|
394
|
+
checkCancelled(signal);
|
|
395
|
+
const required = [`tool:${tool.id}`, ...tool.capabilities, ...(tool.effects === 'none' ? [] : [`effect:${tool.effects}`])];
|
|
396
|
+
if (required.some((grant) => !grants.has(grant))) {
|
|
397
|
+
await observe(Object.freeze({ stage: 'onViolation', source: 'permission', boundary: 'tool', code: 'PERMISSION_DENIED' }), null, { signal });
|
|
398
|
+
throw new MayuraError('PERMISSION_DENIED', 'The requested tool is not authorized.');
|
|
399
|
+
}
|
|
400
|
+
await cancellable(() => runOperations.run(signal, async () => {
|
|
401
|
+
checkCancelled(signal);
|
|
402
|
+
return await validate(tool.input, rawInput, 'input', { maxBytes: limits.maxInputBytes });
|
|
403
|
+
}), signal);
|
|
404
|
+
checkCancelled(signal);
|
|
405
|
+
};
|
|
406
|
+
const control = async (event, step, signal = controller.signal) => {
|
|
407
|
+
for (const handle of agent.hooks) {
|
|
408
|
+
if (handle.stage !== event.stage)
|
|
409
|
+
continue;
|
|
410
|
+
checkCancelled(signal);
|
|
411
|
+
const descriptor = readHookDefinition(handle);
|
|
412
|
+
const invocationId = crypto.randomUUID();
|
|
413
|
+
const metadata = { hookId: handle.id, hookVersion: handle.version, stage: handle.stage, invocationId, step: step ?? 0, attempt: 1 };
|
|
414
|
+
const failure = await evaluateHook({ descriptor, event,
|
|
415
|
+
context: Object.freeze({ runId: id, rootId: state.root.id, ...(parent ? { parentId: parent.id } : {}),
|
|
416
|
+
agentId: agent.id, scope, invocationId, hookId: handle.id, hookVersion: handle.version, step, attempt: 1 }),
|
|
417
|
+
signal, operations: runOperations, assertActive: () => checkCancelled(signal),
|
|
418
|
+
onStarted: () => {
|
|
419
|
+
checkCancelled(signal);
|
|
420
|
+
const path = ancestors(state);
|
|
421
|
+
if (path.some(account => account.hookCalls >= account.limits.maxHookCalls)) {
|
|
422
|
+
throw new MayuraError('LIMIT_EXCEEDED', 'An ancestor lifecycle-hook call limit was reached.');
|
|
423
|
+
}
|
|
424
|
+
// No callback/await between the ancestor check and historical admission.
|
|
425
|
+
for (const account of path)
|
|
426
|
+
account.hookCalls++;
|
|
427
|
+
events.emit('hook.started', metadata);
|
|
428
|
+
},
|
|
429
|
+
onCompleted: status => events.emit('hook.completed', { ...metadata, status }),
|
|
430
|
+
preflight,
|
|
431
|
+
invoke: (tool, input, callId, actionSignal) => invokeRunTool(tool, input, callId, step ?? 0, actionSignal, false),
|
|
432
|
+
allocateCallId: index => {
|
|
433
|
+
const callId = `hook:${invocationId}:${index}`;
|
|
434
|
+
if (callIds.has(callId))
|
|
435
|
+
throw new MayuraError('CONFLICT', 'Hook invocation identifiers must be unique.');
|
|
436
|
+
callIds.add(callId);
|
|
437
|
+
return callId;
|
|
438
|
+
},
|
|
439
|
+
});
|
|
440
|
+
if (failure) {
|
|
441
|
+
if (failure.status === 'blocked' && failure.error.code === 'GUARD_BLOCKED') {
|
|
442
|
+
const callId = event.stage === 'beforeToolCall' ? event.proposal.callId : event.stage === 'beforeOutputRelease' ? event.callId : undefined;
|
|
443
|
+
await observe(Object.freeze({ stage: 'onViolation', source: 'hook', boundary: violationBoundary[event.stage],
|
|
444
|
+
code: 'GUARD_BLOCKED', ...(callId === undefined ? {} : { callId }) }), step, { signal });
|
|
445
|
+
}
|
|
446
|
+
return failure;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
checkCancelled(signal);
|
|
450
|
+
return undefined;
|
|
451
|
+
};
|
|
452
|
+
const observe = async (event, step, options = {}) => {
|
|
453
|
+
let failure;
|
|
454
|
+
for (const handle of agent.hooks) {
|
|
455
|
+
if (handle.stage !== event.stage)
|
|
456
|
+
continue;
|
|
457
|
+
const descriptor = readHookDefinition(handle);
|
|
458
|
+
// Terminal observers run after this run's signal and budget closed; they get a deadline-only signal.
|
|
459
|
+
const signal = options.terminal ? new AbortController().signal : options.signal ?? controller.signal;
|
|
460
|
+
const invocationId = crypto.randomUUID();
|
|
461
|
+
const metadata = { hookId: handle.id, hookVersion: handle.version, stage: handle.stage, invocationId, step: step ?? 0, attempt: 1 };
|
|
462
|
+
const status = await evaluateObserver({ descriptor, event, signal, operations: runOperations,
|
|
463
|
+
context: Object.freeze({ runId: id, rootId: state.root.id, ...(parent ? { parentId: parent.id } : {}),
|
|
464
|
+
agentId: agent.id, scope, invocationId, hookId: handle.id, hookVersion: handle.version, step, attempt: 1 }),
|
|
465
|
+
onStarted: () => {
|
|
466
|
+
const path = ancestors(state);
|
|
467
|
+
if (path.some(account => account.hookCalls >= account.limits.maxHookCalls)) {
|
|
468
|
+
throw new MayuraError('LIMIT_EXCEEDED', 'An ancestor lifecycle-hook call limit was reached.');
|
|
469
|
+
}
|
|
470
|
+
for (const account of path)
|
|
471
|
+
account.hookCalls++;
|
|
472
|
+
events.emit('hook.started', metadata);
|
|
473
|
+
},
|
|
474
|
+
onCompleted: completion => events.emit('hook.completed', { ...metadata, status: completion }),
|
|
475
|
+
});
|
|
476
|
+
if (status === 'failed' && descriptor.mandatory && !failure) {
|
|
477
|
+
failure = Object.freeze({ status: 'blocked', error: Object.freeze({ code: 'GUARD_UNAVAILABLE', message: 'A mandatory lifecycle observer could not complete.' }) });
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
return failure;
|
|
481
|
+
};
|
|
482
|
+
state.control = control;
|
|
483
|
+
state.observe = observe;
|
|
484
|
+
/** Ordinary proposals and hook actions share the same broker, exact account and output barriers. */
|
|
485
|
+
const invokeRunTool = async (tool, rawInput, callId, step, signal = controller.signal, withHooks = true) => {
|
|
486
|
+
checkCancelled(signal);
|
|
487
|
+
// Model envelopes are validated JSON but not frozen. Do not expose their live history
|
|
488
|
+
// objects to callbacks or let a proposal hook rewrite the later executor's arguments.
|
|
489
|
+
const input = freezeJson(jsonValue(rawInput, { maxBytes: limits.maxInputBytes }));
|
|
490
|
+
const toolBundle = operationBundle('tool', tool.costMicros);
|
|
491
|
+
try {
|
|
492
|
+
if (withHooks) {
|
|
493
|
+
const failure = await control(Object.freeze({ stage: 'beforeToolCall', phase: 'proposal',
|
|
494
|
+
proposal: Object.freeze({ callId, toolId: tool.id, input }) }), step, signal);
|
|
495
|
+
if (failure)
|
|
496
|
+
return failure;
|
|
497
|
+
}
|
|
498
|
+
checkCancelled(signal);
|
|
499
|
+
consumeCall(state, toolBundle.entries[0], 'tool');
|
|
500
|
+
events.emit('tool.started', { callId, toolId: tool.id });
|
|
501
|
+
let outcome = await invokeTool(tool, input, {
|
|
502
|
+
runId: id, callId, scope, signal, permissions, budget,
|
|
503
|
+
budgetBinding: bindToolBudgetTicket(tool, toolBundle.entries[0].ticket, { budget, runId: id, callId, scope, signal }),
|
|
504
|
+
maxOutputBytes: limits.maxOutputBytes,
|
|
505
|
+
acquireCallback: (callbackSignal) => runOperations.acquire(callbackSignal),
|
|
506
|
+
onExecutionReceipt: async (receipt) => { record(state, receipt); },
|
|
507
|
+
...(isAgentTool(tool) ? {
|
|
508
|
+
contextBindings: [childGateway.bind(Object.freeze({
|
|
509
|
+
spawn: (childAgent, childInput, childOptions, childSignal) => admitChild(state, childAgent, childInput, childOptions, true, childSignal),
|
|
510
|
+
}))],
|
|
511
|
+
} : { acquireExecution: (executionSignal) => runOperations.acquire(executionSignal) }),
|
|
512
|
+
});
|
|
513
|
+
if (outcome.receipt)
|
|
514
|
+
record(state, outcome.status === 'succeeded'
|
|
515
|
+
? Object.freeze({ ...outcome.receipt, disclosure: 'withheld' }) : outcome.receipt);
|
|
516
|
+
if (outcome.status === 'cancelled' && signal.aborted && signal.reason instanceof MayuraError && signal.reason.code === 'TIMEOUT') {
|
|
517
|
+
outcome = { ...outcome, status: 'failed', error: publicError(signal.reason) };
|
|
518
|
+
}
|
|
519
|
+
if (outcome.status !== 'succeeded') {
|
|
520
|
+
const completion = { callId, toolId: tool.id, status: outcome.status,
|
|
521
|
+
...(outcome.receipt ? { execution: outcome.receipt.execution, disclosure: outcome.receipt.disclosure } : {}) };
|
|
522
|
+
events.emit('tool.completed', completion);
|
|
523
|
+
// The tool already failed; an observer failure cannot make the outcome worse or better.
|
|
524
|
+
if (withHooks)
|
|
525
|
+
await observe(Object.freeze({ stage: 'afterToolCall', step, ...completion }), step, { signal });
|
|
526
|
+
return outcome;
|
|
527
|
+
}
|
|
528
|
+
let toolOutput = freezeJson(jsonValue(outcome.output, { maxBytes: limits.maxOutputBytes }));
|
|
529
|
+
let failure;
|
|
530
|
+
let observed = false;
|
|
531
|
+
try {
|
|
532
|
+
// A rewritten tool result (for example redacted) is what the model sees, validated again by the tool's schema.
|
|
533
|
+
toolOutput = await guarded(agent.guards.output, toolOutput, tool.output, 'output', callId, limits.maxOutputBytes, toolBundle.entries.slice(1), signal);
|
|
534
|
+
if (withHooks)
|
|
535
|
+
failure = await control(Object.freeze({ stage: 'beforeOutputRelease', source: 'tool', callId,
|
|
536
|
+
toolId: tool.id, candidate: toolOutput }), step, signal);
|
|
537
|
+
// Observe the real released outcome before it enters model history; a mandatory failure withholds it.
|
|
538
|
+
if (withHooks && !failure) {
|
|
539
|
+
observed = true;
|
|
540
|
+
failure = await observe(Object.freeze({ stage: 'afterToolCall', step, callId, toolId: tool.id, status: 'succeeded',
|
|
541
|
+
execution: 'succeeded', disclosure: 'released' }), step, { signal });
|
|
542
|
+
}
|
|
543
|
+
if (!failure)
|
|
544
|
+
checkCancelled(signal);
|
|
545
|
+
}
|
|
546
|
+
catch (error) {
|
|
547
|
+
failure = outcomeFor(error);
|
|
548
|
+
}
|
|
549
|
+
if (failure) {
|
|
550
|
+
events.emit('tool.completed', { callId, toolId: tool.id, status: failure.status, execution: 'succeeded', disclosure: 'withheld' });
|
|
551
|
+
if (withHooks && !observed)
|
|
552
|
+
await observe(Object.freeze({ stage: 'afterToolCall', step, callId, toolId: tool.id, status: failure.status,
|
|
553
|
+
execution: 'succeeded', disclosure: 'withheld' }), step, { signal });
|
|
554
|
+
const receipt = outcome.receipt ? Object.freeze({ ...outcome.receipt, disclosure: 'withheld' }) : undefined;
|
|
555
|
+
if (receipt)
|
|
556
|
+
record(state, receipt);
|
|
557
|
+
// An uncertain hook action owns the primary failure receipt. The original known
|
|
558
|
+
// success remains withheld in the run-qualified evidence rather than replacing it.
|
|
559
|
+
return { ...failure, ...(!failure.receipt && receipt ? { receipt } : {}) };
|
|
560
|
+
}
|
|
561
|
+
if (outcome.receipt)
|
|
562
|
+
record(state, outcome.receipt);
|
|
563
|
+
events.emit('tool.completed', { callId, toolId: tool.id, status: 'succeeded', execution: 'succeeded', disclosure: 'released' });
|
|
564
|
+
return Object.freeze({ ...outcome, output: toolOutput });
|
|
565
|
+
}
|
|
566
|
+
finally {
|
|
567
|
+
toolBundle.close();
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
const execute = async () => {
|
|
571
|
+
events.emit('run.started', { profile: 'ephemeral', rootId: state.root.id, agentId: agent.id, ...(parent ? { parentId: parent.id } : {}) });
|
|
572
|
+
checkCancelled();
|
|
573
|
+
if (parent) {
|
|
574
|
+
// The parent's own hooks decide delegation, in the parent's context and under its hook ceiling.
|
|
575
|
+
const delegateFailure = await parent.control(Object.freeze({ stage: 'beforeDelegate', childRunId: id, childAgentId: agent.id, input }), null, controller.signal);
|
|
576
|
+
if (delegateFailure)
|
|
577
|
+
return delegateFailure;
|
|
578
|
+
}
|
|
579
|
+
const validated = inputAdmitted ? input : await cancellable(() => runOperations.run(controller.signal, async () => {
|
|
580
|
+
checkCancelled();
|
|
581
|
+
return await validate(agent.input, input, 'input', { maxBytes: limits.maxInputBytes });
|
|
582
|
+
}), controller.signal);
|
|
583
|
+
const approvedInput = await guarded(agent.guards.input, freezeJson(jsonValue(validated, { maxBytes: limits.maxInputBytes })), agent.input, 'input', 'input', limits.maxInputBytes);
|
|
584
|
+
const inputFailure = await control(Object.freeze({ stage: 'beforeExecution', input: approvedInput }), null);
|
|
585
|
+
if (inputFailure)
|
|
586
|
+
return inputFailure;
|
|
587
|
+
const messages = [{ role: 'user', content: approvedInput }];
|
|
588
|
+
let continuation;
|
|
589
|
+
/**
|
|
590
|
+
* Consume a streamed model call. Only the configured string field of the final output is released, in batches,
|
|
591
|
+
* each after the batch guards allow it; the returned complete response is then handled exactly like `generate`.
|
|
592
|
+
* Batch guards run directly rather than through operation permits: this code already holds the model call's
|
|
593
|
+
* permit, and a nested acquisition could wait on itself.
|
|
594
|
+
*/
|
|
595
|
+
const streamModel = async (request, step, modelCall) => {
|
|
596
|
+
const policy = agent.stream;
|
|
597
|
+
const extractor = createFieldExtractor(policy.field);
|
|
598
|
+
const batcher = createBatcher(policy.batch?.minChars, policy.batch?.maxChars);
|
|
599
|
+
let released = '';
|
|
600
|
+
let withheld = false;
|
|
601
|
+
let index = 0;
|
|
602
|
+
let response;
|
|
603
|
+
let received = 0;
|
|
604
|
+
const release = async (batches) => {
|
|
605
|
+
for (const batch of batches) {
|
|
606
|
+
if (withheld || batch.length === 0)
|
|
607
|
+
return;
|
|
608
|
+
// Guards run in order on the batch with already released context; a guard may rewrite the batch (for
|
|
609
|
+
// example to redact it), and the next guard sees the rewrite. Context before the batch is never changed.
|
|
610
|
+
const context = released.slice(-512);
|
|
611
|
+
let text = batch;
|
|
612
|
+
let blocked = false;
|
|
613
|
+
for (const check of policy.guards) {
|
|
614
|
+
let verdict;
|
|
615
|
+
try {
|
|
616
|
+
verdict = await cancellable(async () => check.check(context + text, Object.freeze({ runId: id, callId: `model.${modelCall}.stream`, scope, signal: controller.signal, boundary: 'output' })), controller.signal);
|
|
617
|
+
}
|
|
618
|
+
catch {
|
|
619
|
+
blocked = true;
|
|
620
|
+
break;
|
|
621
|
+
}
|
|
622
|
+
checkCancelled();
|
|
623
|
+
if (verdict?.decision === 'allow')
|
|
624
|
+
continue;
|
|
625
|
+
// A rewrite must keep the released context unchanged and return the rest as bounded text.
|
|
626
|
+
if (verdict?.decision === 'rewrite' && typeof verdict.value === 'string' && verdict.value.startsWith(context) && verdict.value.length - context.length <= 4_096) {
|
|
627
|
+
text = verdict.value.slice(context.length);
|
|
628
|
+
continue;
|
|
629
|
+
}
|
|
630
|
+
blocked = true;
|
|
631
|
+
break;
|
|
632
|
+
}
|
|
633
|
+
if (blocked) {
|
|
634
|
+
withheld = true;
|
|
635
|
+
events.emit('output.withheld', { step, modelCall });
|
|
636
|
+
await observe(Object.freeze({ stage: 'onViolation', source: 'guard', boundary: 'output', code: 'GUARD_BLOCKED', callId: `model.${modelCall}.stream` }), step);
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
if (text.length === 0)
|
|
640
|
+
continue;
|
|
641
|
+
released += text;
|
|
642
|
+
events.emit('output.delta', { step, modelCall, index: index++, text });
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
for await (const event of agent.model.stream(request)) {
|
|
646
|
+
checkCancelled();
|
|
647
|
+
if (response !== undefined)
|
|
648
|
+
throw new MayuraError('MODEL_FAILED', 'The model stream continued after its response.');
|
|
649
|
+
if (event?.type === 'output.delta' && typeof event.text === 'string') {
|
|
650
|
+
received += event.text.length;
|
|
651
|
+
if (received > limits.maxOutputBytes)
|
|
652
|
+
throw new MayuraError('MODEL_FAILED', 'The model stream exceeded the output bound.');
|
|
653
|
+
if (!withheld && !extractor.done)
|
|
654
|
+
await release(batcher.push(extractor.feed(event.text)));
|
|
655
|
+
}
|
|
656
|
+
else if (event?.type === 'response')
|
|
657
|
+
response = event.response;
|
|
658
|
+
else
|
|
659
|
+
throw new MayuraError('MODEL_FAILED', 'The model stream produced an invalid event.');
|
|
660
|
+
}
|
|
661
|
+
if (response === undefined)
|
|
662
|
+
throw new MayuraError('MODEL_FAILED', 'The model stream ended without a response.');
|
|
663
|
+
// The tail is released only for a final answer; a tool-call response releases nothing further.
|
|
664
|
+
if (response.type === 'final' && !withheld)
|
|
665
|
+
await release(batcher.flush());
|
|
666
|
+
return response;
|
|
667
|
+
};
|
|
668
|
+
const runStep = async (step) => {
|
|
669
|
+
const stepFailure = await control(Object.freeze({ stage: 'beforeStep', step }), step);
|
|
670
|
+
if (stepFailure)
|
|
671
|
+
return { done: true, outcome: stepFailure };
|
|
672
|
+
if (!grants.has(`model:${agent.model.id}`)) {
|
|
673
|
+
await observe(Object.freeze({ stage: 'onViolation', source: 'permission', boundary: 'model', code: 'PERMISSION_DENIED' }), step);
|
|
674
|
+
throw new MayuraError('PERMISSION_DENIED', 'The model adapter is not authorized.');
|
|
675
|
+
}
|
|
676
|
+
checkCalls(state, 'model', 1);
|
|
677
|
+
// Freeze a bounded copy: a provider cannot mutate history or the tool registry between checks.
|
|
678
|
+
const snapshot = freezeJson(jsonValue(messages, { maxBytes: limits.maxContextBytes }));
|
|
679
|
+
const modelTools = agent.tools.map((tool) => Object.freeze({ id: tool.id, description: tool.description,
|
|
680
|
+
...(tool.inputJsonSchema === undefined ? {} : { inputJsonSchema: freezeJson(jsonValue(tool.inputJsonSchema)) }),
|
|
681
|
+
}));
|
|
682
|
+
const requestData = freezeJson(jsonValue({ instructions: agent.instructions, messages: snapshot, tools: modelTools, ...(continuation === undefined ? {} : { continuation }) }, { maxBytes: limits.maxContextBytes }));
|
|
683
|
+
const primaryBundle = operationBundle('model', agent.model.maxCostMicros);
|
|
684
|
+
try {
|
|
685
|
+
// A content-only projection: private instructions and provider continuation never
|
|
686
|
+
// enter hook context. These immutable fields are the same ones sent to the adapter.
|
|
687
|
+
const modelFailure = await control(Object.freeze({ stage: 'beforeModelCall', purpose: 'primary', modelId: agent.model.id,
|
|
688
|
+
request: Object.freeze({ messages: requestData.messages, tools: requestData.tools, maxOutputTokens: limits.maxOutputTokens }) }), step);
|
|
689
|
+
if (modelFailure)
|
|
690
|
+
return { done: true, outcome: modelFailure };
|
|
691
|
+
const rawResponse = await cancellable(() => runOperations.run(controller.signal, async () => {
|
|
692
|
+
checkCancelled();
|
|
693
|
+
const reservation = consumeCall(state, primaryBundle.entries[0], 'model');
|
|
694
|
+
events.emit('model.started', { step, modelCall: state.modelCalls });
|
|
695
|
+
let raw;
|
|
696
|
+
const modelRequest = Object.freeze({ ...requestData, signal: controller.signal, maxOutputTokens: limits.maxOutputTokens });
|
|
697
|
+
try {
|
|
698
|
+
raw = agent.stream && agent.model.stream ? await streamModel(modelRequest, step, state.modelCalls) : await agent.model.generate(modelRequest);
|
|
699
|
+
}
|
|
700
|
+
catch (error) {
|
|
701
|
+
const cost = modelFailureCost(error);
|
|
702
|
+
if (cost !== undefined)
|
|
703
|
+
reservation.settle(cost);
|
|
704
|
+
throw new MayuraError('MODEL_FAILED', 'The model adapter failed to produce a response.');
|
|
705
|
+
}
|
|
706
|
+
// Account independently validated usage even when the content envelope is malformed.
|
|
707
|
+
// The callback may complete after cooperative cancellation; it cannot re-open disclosure.
|
|
708
|
+
reservation.settle(modelCost(raw));
|
|
709
|
+
return raw;
|
|
710
|
+
}), controller.signal);
|
|
711
|
+
checkCancelled();
|
|
712
|
+
const response = modelResponse(rawResponse, limits.maxOutputBytes, limits.maxToolCalls);
|
|
713
|
+
continuation = response.continuation === undefined ? undefined : freezeJson(jsonValue(response.continuation, { maxBytes: limits.maxContextBytes }));
|
|
714
|
+
events.emit('model.completed', { step, response: response.type });
|
|
715
|
+
const modelObserved = await observe(Object.freeze({ stage: 'afterModelCall', step, modelId: agent.model.id, response: response.type,
|
|
716
|
+
toolCalls: response.type === 'final' ? 0 : response.calls.length }), step);
|
|
717
|
+
if (modelObserved)
|
|
718
|
+
return { done: true, outcome: modelObserved };
|
|
719
|
+
if (response.type === 'final') {
|
|
720
|
+
const output = await cancellable(() => runOperations.run(controller.signal, async () => {
|
|
721
|
+
checkCancelled();
|
|
722
|
+
return await validate(agent.output, response.output, 'output', { maxBytes: limits.maxOutputBytes });
|
|
723
|
+
}), controller.signal);
|
|
724
|
+
const callId = `model.${state.modelCalls}`;
|
|
725
|
+
const approvedOutput = await guarded(agent.guards.output, freezeJson(jsonValue(output, { maxBytes: limits.maxOutputBytes })), agent.output, 'output', callId, limits.maxOutputBytes, primaryBundle.entries.slice(1));
|
|
726
|
+
const outputFailure = await control(Object.freeze({ stage: 'beforeOutputRelease', source: 'agent',
|
|
727
|
+
callId, candidate: approvedOutput }), step);
|
|
728
|
+
if (outputFailure)
|
|
729
|
+
return { done: true, outcome: outputFailure };
|
|
730
|
+
checkCancelled();
|
|
731
|
+
return { done: true, outcome: Object.freeze({ status: 'succeeded', output: approvedOutput }) };
|
|
732
|
+
}
|
|
733
|
+
// A validated tool proposal has no final candidate; these holds cannot fund a later invocation.
|
|
734
|
+
primaryBundle.close();
|
|
735
|
+
checkCalls(state, 'tool', response.calls.length);
|
|
736
|
+
// Preflight every proposed grant/schema/identity before the first effect. Money/call
|
|
737
|
+
// holds are per dispatch and include its required checks, not every future batch member.
|
|
738
|
+
let batchCost = 0;
|
|
739
|
+
for (const call of response.calls) {
|
|
740
|
+
if (callIds.has(call.id))
|
|
741
|
+
throw new MayuraError('CONFLICT', 'Tool call identifiers must be unique within a run.');
|
|
742
|
+
const tool = tools.get(call.toolId);
|
|
743
|
+
if (!tool)
|
|
744
|
+
throw new MayuraError('NOT_FOUND', 'The model requested an unregistered tool.');
|
|
745
|
+
await preflight(tool, call.input);
|
|
746
|
+
batchCost += tool.costMicros;
|
|
747
|
+
if (!Number.isSafeInteger(batchCost))
|
|
748
|
+
throw new MayuraError('BUDGET_EXCEEDED', 'Tool batch cost exceeds supported accounting bounds.');
|
|
749
|
+
}
|
|
750
|
+
const ledger = budget.snapshot();
|
|
751
|
+
if (typeof ledger.spentMicros !== 'number' || batchCost > limits.maxCostMicros - ledger.spentMicros - ledger.reservedMicros) {
|
|
752
|
+
throw new MayuraError('BUDGET_EXCEEDED', 'The complete tool batch cannot be admitted within the budget.');
|
|
753
|
+
}
|
|
754
|
+
for (const call of response.calls)
|
|
755
|
+
callIds.add(call.id);
|
|
756
|
+
messages.push({ role: 'assistant', calls: response.calls });
|
|
757
|
+
for (const call of response.calls) {
|
|
758
|
+
const outcome = await invokeRunTool(tools.get(call.toolId), call.input, call.id, step);
|
|
759
|
+
if (outcome.status !== 'succeeded')
|
|
760
|
+
return { done: true, outcome };
|
|
761
|
+
messages.push({ role: 'tool', callId: call.id, toolId: call.toolId, result: outcome.output });
|
|
762
|
+
}
|
|
763
|
+
return { done: false };
|
|
764
|
+
}
|
|
765
|
+
finally {
|
|
766
|
+
primaryBundle.close();
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
const finishStep = async (step, result) => {
|
|
770
|
+
const failure = await observe(Object.freeze({ stage: 'afterStep', step, result }), step);
|
|
771
|
+
events.emit('step.completed', { step, result });
|
|
772
|
+
return failure;
|
|
773
|
+
};
|
|
774
|
+
for (let step = 0; step < limits.maxSteps; step++) {
|
|
775
|
+
checkCancelled();
|
|
776
|
+
events.emit('step.started', { step });
|
|
777
|
+
let result;
|
|
778
|
+
try {
|
|
779
|
+
result = await runStep(step);
|
|
780
|
+
}
|
|
781
|
+
catch (error) {
|
|
782
|
+
await finishStep(step, 'stopped');
|
|
783
|
+
throw error;
|
|
784
|
+
}
|
|
785
|
+
const observed = await finishStep(step, !result.done ? 'tool_calls' : result.outcome.status === 'succeeded' ? 'final' : 'stopped');
|
|
786
|
+
// A mandatory afterStep failure stops a continuing step and withholds a final output; it never masks an earlier failure.
|
|
787
|
+
if (observed && (!result.done || result.outcome.status === 'succeeded'))
|
|
788
|
+
return observed;
|
|
789
|
+
if (result.done)
|
|
790
|
+
return result.outcome;
|
|
791
|
+
}
|
|
792
|
+
throw new MayuraError('LIMIT_EXCEEDED', 'The agent step limit was reached.');
|
|
793
|
+
};
|
|
794
|
+
queueMicrotask(() => {
|
|
795
|
+
void execute().catch(outcomeFor).then(async (candidate) => {
|
|
796
|
+
state.accepting = false;
|
|
797
|
+
// Accepted descendants remain required even if the parent's model has already finished.
|
|
798
|
+
if (candidate.status !== 'succeeded' && !controller.signal.aborted) {
|
|
799
|
+
controller.abort(new MayuraError('CANCELLED', 'Parent execution ended before its required children.'));
|
|
800
|
+
}
|
|
801
|
+
const settled = await Promise.all(state.children.map((child) => child.handle.result()));
|
|
802
|
+
const children = settled.filter((_, index) => !state.children[index].speculative);
|
|
803
|
+
let outcome = candidate;
|
|
804
|
+
if (outcome.status === 'succeeded' && controller.signal.aborted)
|
|
805
|
+
outcome = outcomeFor(controller.signal.reason);
|
|
806
|
+
const unknown = children.find((child) => child.status === 'outcome_unknown');
|
|
807
|
+
const failed = children.find((child) => child.status !== 'succeeded');
|
|
808
|
+
if (unknown)
|
|
809
|
+
outcome = unknown;
|
|
810
|
+
else if (failed && (outcome.status === 'succeeded' || outcome.error.code === 'TOOL_FAILED'))
|
|
811
|
+
outcome = failed;
|
|
812
|
+
if (agent.hooks.length > 0) {
|
|
813
|
+
const stage = outcome.status === 'succeeded' ? 'afterExecution' : outcome.status === 'cancelled' ? 'onCancel'
|
|
814
|
+
: outcome.status === 'blocked' ? 'onBlocked' : 'onError';
|
|
815
|
+
const terminalFailure = await observe(terminalView(stage, outcome), null, { terminal: true });
|
|
816
|
+
// Only a mandatory afterExecution can change the outcome: it withholds a successful output.
|
|
817
|
+
if (terminalFailure && outcome.status === 'succeeded')
|
|
818
|
+
outcome = terminalFailure;
|
|
819
|
+
await observe(terminalView('onFinally', outcome), null, { terminal: true });
|
|
820
|
+
}
|
|
821
|
+
if (parent && parent.agent.hooks.length > 0) {
|
|
822
|
+
const delegated = await parent.observe(Object.freeze({ stage: 'afterDelegate', childRunId: id, childAgentId: agent.id, status: outcome.status }), null, { terminal: true });
|
|
823
|
+
if (delegated && outcome.status === 'succeeded')
|
|
824
|
+
outcome = delegated;
|
|
825
|
+
}
|
|
826
|
+
if (state.children.length > 0 || agent.hooks.length > 0)
|
|
827
|
+
outcome = { ...outcome, evidence: evidenceFor(state) };
|
|
828
|
+
terminal = true;
|
|
829
|
+
state.status = outcome.status;
|
|
830
|
+
for (const bundle of state.bundles)
|
|
831
|
+
bundle.close();
|
|
832
|
+
budget.close();
|
|
833
|
+
clearTimeout(timer);
|
|
834
|
+
parent?.controller.signal.removeEventListener('abort', relayParent);
|
|
835
|
+
externalSignal?.removeEventListener('abort', relayExternal);
|
|
836
|
+
events.emit('run.completed', { status: outcome.status, ...budget.snapshot() });
|
|
837
|
+
events.finish();
|
|
838
|
+
parent?.events.emit('delegate.completed', { childRunId: id, status: outcome.status });
|
|
839
|
+
active.delete(id);
|
|
840
|
+
if (!parent)
|
|
841
|
+
activeRoots--;
|
|
842
|
+
settle(Object.freeze(outcome));
|
|
843
|
+
});
|
|
844
|
+
});
|
|
845
|
+
return handle;
|
|
846
|
+
};
|
|
847
|
+
return Object.freeze({
|
|
848
|
+
profile: 'ephemeral',
|
|
849
|
+
submit: (agent, submission) => start(agent, submission.input, rootLimits, rootPermissions),
|
|
850
|
+
spawn: (parent, agent, submission) => admitChild(lookup(parent), agent, submission.input, submission),
|
|
851
|
+
speculate: async (parentHandle, speculation) => {
|
|
852
|
+
const parent = lookup(parentHandle);
|
|
853
|
+
const branches = speculation?.branches;
|
|
854
|
+
const verify = speculation?.verify;
|
|
855
|
+
const verifyTimeoutMs = speculation?.verifyTimeoutMs ?? 5_000;
|
|
856
|
+
if (!Array.isArray(branches) || branches.length < 1 || branches.length > 8 || typeof verify !== 'function'
|
|
857
|
+
|| !Number.isSafeInteger(verifyTimeoutMs) || verifyTimeoutMs < 1 || verifyTimeoutMs > 30_000
|
|
858
|
+
|| new Set(branches.map(branch => branch?.id)).size !== branches.length || branches.some(branch => !isIdentifier(branch?.id))) {
|
|
859
|
+
throw new MayuraError('INVALID_CONFIG', 'Speculation needs 1–8 uniquely identified branches, a verify function and a bounded verify deadline.');
|
|
860
|
+
}
|
|
861
|
+
const prepared = await Promise.all(branches.map(async (branch) => {
|
|
862
|
+
const permissions = permissionsFor(branch.permissions, true);
|
|
863
|
+
// No speculative external writes, host execution, further delegation or durable memory promotion.
|
|
864
|
+
if (permissions.allow.some(grant => grant === 'agent:delegate' || (grant.startsWith('effect:') && grant !== 'effect:read')
|
|
865
|
+
|| (grant.startsWith('memory:') && grant !== 'memory:read'))) {
|
|
866
|
+
throw new MayuraError('PERMISSION_DENIED', 'Speculative branches cannot hold write, host, delegation or memory-mutation grants.');
|
|
867
|
+
}
|
|
868
|
+
let assumptions;
|
|
869
|
+
try {
|
|
870
|
+
assumptions = freezeJson(jsonValue(branch.assumptions, { maxBytes: 65_536 }));
|
|
871
|
+
}
|
|
872
|
+
catch {
|
|
873
|
+
throw new MayuraError('INVALID_INPUT', 'Branch assumptions must be bounded plain JSON.');
|
|
874
|
+
}
|
|
875
|
+
const bytes = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(`mayura:speculation-assumptions:v1\0${canonicalJson(assumptions)}`));
|
|
876
|
+
return { branch, permissions, digest: [...new Uint8Array(bytes)].map(byte => byte.toString(16).padStart(2, '0')).join('') };
|
|
877
|
+
}));
|
|
878
|
+
const handles = [];
|
|
879
|
+
try {
|
|
880
|
+
for (const { branch, permissions } of prepared) {
|
|
881
|
+
handles.push(admitChild(parent, branch.agent, branch.input, { permissions, ...(branch.limits ? { limits: branch.limits } : {}) }, false, undefined, true));
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
catch (error) {
|
|
885
|
+
for (const handle of handles)
|
|
886
|
+
handle.cancel();
|
|
887
|
+
throw error;
|
|
888
|
+
}
|
|
889
|
+
const outcomes = new Map();
|
|
890
|
+
const verified = new Set();
|
|
891
|
+
let winner;
|
|
892
|
+
const pending = new Map(handles.map((handle, index) => [index, handle.result().then(outcome => ({ index, outcome }))]));
|
|
893
|
+
while (pending.size > 0 && winner === undefined) {
|
|
894
|
+
const { index, outcome } = await Promise.race(pending.values());
|
|
895
|
+
pending.delete(index);
|
|
896
|
+
outcomes.set(index, outcome);
|
|
897
|
+
if (outcome.status !== 'succeeded')
|
|
898
|
+
continue;
|
|
899
|
+
let accepted = false;
|
|
900
|
+
try {
|
|
901
|
+
accepted = await new Promise((resolve, reject) => {
|
|
902
|
+
const timer = setTimeout(() => resolve(false), verifyTimeoutMs);
|
|
903
|
+
Promise.resolve().then(() => verify(Object.freeze({ branchId: prepared[index].branch.id, assumptionsDigest: prepared[index].digest, output: outcome.output })))
|
|
904
|
+
.then(value => { clearTimeout(timer); resolve(value === true); }, error => { clearTimeout(timer); reject(error); });
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
catch {
|
|
908
|
+
accepted = false;
|
|
909
|
+
}
|
|
910
|
+
if (accepted) {
|
|
911
|
+
verified.add(index);
|
|
912
|
+
winner = index;
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
for (const [index, handle] of handles.entries())
|
|
916
|
+
if (index !== winner && !outcomes.has(index))
|
|
917
|
+
handle.cancel();
|
|
918
|
+
for (const [index, promise] of pending)
|
|
919
|
+
outcomes.set(index, (await promise).outcome);
|
|
920
|
+
const promoted = winner === undefined ? undefined : outcomes.get(winner);
|
|
921
|
+
return Object.freeze({
|
|
922
|
+
status: winner === undefined ? 'none' : 'promoted',
|
|
923
|
+
...(winner === undefined || promoted?.status !== 'succeeded' ? {} : { branchId: prepared[winner].branch.id, output: promoted.output, assumptionsDigest: prepared[winner].digest }),
|
|
924
|
+
branches: Object.freeze(prepared.map(({ branch, digest }, index) => Object.freeze({ id: branch.id, runId: handles[index].id,
|
|
925
|
+
status: outcomes.get(index).status, assumptionsDigest: digest, verified: verified.has(index) }))),
|
|
926
|
+
});
|
|
927
|
+
},
|
|
928
|
+
inspect: (handle) => {
|
|
929
|
+
const state = lookup(handle);
|
|
930
|
+
return Object.freeze({ id: state.id, rootId: state.root.id, ...(state.parent ? { parentId: state.parent.id } : {}),
|
|
931
|
+
agentId: state.agent.id, status: state.status, budget: state.budget.snapshot(),
|
|
932
|
+
runs: Object.freeze(subtree(state).map((run) => Object.freeze({ id: run.id, ...(run.parent ? { parentId: run.parent.id } : {}), agentId: run.agent.id, status: run.status }))),
|
|
933
|
+
evidence: evidenceFor(state),
|
|
934
|
+
});
|
|
935
|
+
},
|
|
936
|
+
close: async () => {
|
|
937
|
+
closed = true;
|
|
938
|
+
const runs = [...active.values()];
|
|
939
|
+
for (const run of runs)
|
|
940
|
+
run.cancel();
|
|
941
|
+
await Promise.all(runs.map((run) => run.result()));
|
|
942
|
+
},
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
//# sourceMappingURL=runtime.js.map
|