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,134 @@
|
|
|
1
|
+
import { assertSchema, jsonValue, MayuraError } from '../../core/dist/index.js';
|
|
2
|
+
import { readManagedGuardDefinition, snapshotLocalGuards } from '../../core/dist/host.js';
|
|
3
|
+
import { assertTool } from '../../tools/dist/index.js';
|
|
4
|
+
import { snapshotHooks } from './hooks.js';
|
|
5
|
+
const definitions = new WeakSet();
|
|
6
|
+
const identifier = /^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/;
|
|
7
|
+
/** Definition identifiers are bounded metadata, not arbitrary message or secret containers. */
|
|
8
|
+
export function isIdentifier(value) {
|
|
9
|
+
return typeof value === 'string' && identifier.test(value);
|
|
10
|
+
}
|
|
11
|
+
function snapshotGuards(guards) {
|
|
12
|
+
try {
|
|
13
|
+
if (!Array.isArray(guards))
|
|
14
|
+
throw new Error();
|
|
15
|
+
const fields = Object.getOwnPropertyDescriptors(guards);
|
|
16
|
+
const length = Object.getOwnPropertyDescriptor(guards, 'length');
|
|
17
|
+
if (!length || !('value' in length) || !Number.isSafeInteger(length.value) || length.value < 0 || length.value > 32
|
|
18
|
+
|| Reflect.ownKeys(fields).length !== length.value + 1)
|
|
19
|
+
throw new Error();
|
|
20
|
+
const seen = new Set();
|
|
21
|
+
const result = [];
|
|
22
|
+
for (let index = 0; index < length.value; index++) {
|
|
23
|
+
const entry = fields[String(index)];
|
|
24
|
+
if (!entry || !('value' in entry))
|
|
25
|
+
throw new Error();
|
|
26
|
+
const guard = entry.value;
|
|
27
|
+
const descriptor = readManagedGuardDefinition(guard);
|
|
28
|
+
const captured = descriptor ? guard : snapshotLocalGuards([guard])[0];
|
|
29
|
+
if (!isIdentifier(captured.id) || seen.has(captured.id))
|
|
30
|
+
throw new Error();
|
|
31
|
+
seen.add(captured.id);
|
|
32
|
+
result.push(captured); // Preserve genuine managed identity; never clone its authority.
|
|
33
|
+
}
|
|
34
|
+
return Object.freeze(result);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
throw new MayuraError('INVALID_CONFIG', 'Guards require a dense data list of unique local callbacks or genuinely registered managed definitions.');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function snapshotSchema(schema) {
|
|
41
|
+
const standard = schema['~standard'];
|
|
42
|
+
return Object.freeze({ '~standard': Object.freeze({ version: 1, vendor: standard.vendor, validate: standard.validate.bind(standard) }) });
|
|
43
|
+
}
|
|
44
|
+
/** Do not execute a newly introduced hooks accessor while capturing the agent configuration. */
|
|
45
|
+
function agentHooks(options) {
|
|
46
|
+
try {
|
|
47
|
+
const field = Object.getOwnPropertyDescriptor(options, 'hooks');
|
|
48
|
+
if (!field) {
|
|
49
|
+
if ('hooks' in options)
|
|
50
|
+
throw new Error();
|
|
51
|
+
return snapshotHooks([]);
|
|
52
|
+
}
|
|
53
|
+
if (!field.enumerable || !('value' in field))
|
|
54
|
+
throw new Error();
|
|
55
|
+
return snapshotHooks(field.value === undefined ? [] : field.value);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
throw new MayuraError('INVALID_CONFIG', 'Agent hooks must be an own data configuration containing genuine hook definitions.');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function streamPolicy(value) {
|
|
62
|
+
try {
|
|
63
|
+
const field = value.field;
|
|
64
|
+
const batch = value.batch ?? {};
|
|
65
|
+
if (!Array.isArray(field) || field.length < 1 || field.length > 8 || field.some(part => typeof part !== 'string' || part.length < 1 || part.length > 128))
|
|
66
|
+
throw new Error();
|
|
67
|
+
const minChars = batch.minChars ?? 24;
|
|
68
|
+
const maxChars = batch.maxChars ?? 512;
|
|
69
|
+
if (!Number.isSafeInteger(minChars) || !Number.isSafeInteger(maxChars) || minChars < 1 || maxChars < minChars || maxChars > 4_096)
|
|
70
|
+
throw new Error();
|
|
71
|
+
// Batch checks run on every release, so they must be local callbacks, never model-backed managed guards.
|
|
72
|
+
if (!Array.isArray(value.guards) || value.guards.some(guard => readManagedGuardDefinition(guard)))
|
|
73
|
+
throw new Error();
|
|
74
|
+
return Object.freeze({ field: Object.freeze([...field]), guards: snapshotGuards(value.guards), batch: Object.freeze({ minChars, maxChars }) });
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
throw new MayuraError('INVALID_CONFIG', 'Agent streaming needs a field path (1–8 parts), explicit local batch guards and bounded batch sizes.');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** Define an agent without opening connections, executing tools, or selecting a hidden provider. */
|
|
81
|
+
export function defineAgent(options) {
|
|
82
|
+
if (!isIdentifier(options.id) || !isIdentifier(options.version) || typeof options.instructions !== 'string') {
|
|
83
|
+
throw new MayuraError('INVALID_CONFIG', 'Agent identifiers, version, and instructions must be valid.');
|
|
84
|
+
}
|
|
85
|
+
jsonValue(options.instructions, { maxBytes: 65_536 });
|
|
86
|
+
assertSchema(options.input);
|
|
87
|
+
assertSchema(options.output);
|
|
88
|
+
const model = options.model;
|
|
89
|
+
if (!model || !isIdentifier(model.id) || typeof model.generate !== 'function'
|
|
90
|
+
|| typeof model.capabilities?.tools !== 'boolean' || typeof model.capabilities.structuredOutput !== 'boolean'
|
|
91
|
+
|| !Number.isSafeInteger(model.maxCostMicros) || model.maxCostMicros < 0) {
|
|
92
|
+
throw new MayuraError('INVALID_CONFIG', 'A model adapter with explicit capabilities and bounded cost is required.');
|
|
93
|
+
}
|
|
94
|
+
if (!Array.isArray(options.tools) || options.tools.length > 256) {
|
|
95
|
+
throw new MayuraError('INVALID_CONFIG', 'Agent tools must be an explicit bounded registry.');
|
|
96
|
+
}
|
|
97
|
+
const seen = new Set();
|
|
98
|
+
for (const tool of options.tools) {
|
|
99
|
+
assertTool(tool);
|
|
100
|
+
if (!tool || !isIdentifier(tool.id) || seen.has(tool.id)) {
|
|
101
|
+
throw new MayuraError('INVALID_CONFIG', 'Agent tools require unique identifiers.');
|
|
102
|
+
}
|
|
103
|
+
seen.add(tool.id);
|
|
104
|
+
}
|
|
105
|
+
if (!model.capabilities.structuredOutput || (options.tools.length > 0 && !model.capabilities.tools)) {
|
|
106
|
+
throw new MayuraError('INVALID_CONFIG', 'The model does not support the agent required capabilities.');
|
|
107
|
+
}
|
|
108
|
+
const definition = Object.freeze({
|
|
109
|
+
id: options.id,
|
|
110
|
+
version: options.version,
|
|
111
|
+
instructions: options.instructions,
|
|
112
|
+
model: Object.freeze({
|
|
113
|
+
id: model.id,
|
|
114
|
+
capabilities: Object.freeze({ tools: model.capabilities.tools, structuredOutput: model.capabilities.structuredOutput }),
|
|
115
|
+
maxCostMicros: model.maxCostMicros,
|
|
116
|
+
generate: model.generate.bind(model),
|
|
117
|
+
...(typeof model.stream === 'function' ? { stream: model.stream.bind(model) } : {}),
|
|
118
|
+
}),
|
|
119
|
+
tools: Object.freeze([...options.tools]),
|
|
120
|
+
input: snapshotSchema(options.input),
|
|
121
|
+
output: snapshotSchema(options.output),
|
|
122
|
+
guards: Object.freeze({ input: snapshotGuards(options.guards?.input ?? []), output: snapshotGuards(options.guards?.output ?? []) }),
|
|
123
|
+
hooks: agentHooks(options),
|
|
124
|
+
...(options.stream === undefined ? {} : { stream: streamPolicy(options.stream) }),
|
|
125
|
+
});
|
|
126
|
+
definitions.add(definition);
|
|
127
|
+
return definition;
|
|
128
|
+
}
|
|
129
|
+
/** Reject hand-built definitions whose admission checks never ran. */
|
|
130
|
+
export function assertAgent(value) {
|
|
131
|
+
if (!definitions.has(value))
|
|
132
|
+
throw new MayuraError('INVALID_CONFIG', 'Use defineAgent to register the agent definition.');
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,E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Ac,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,IAAI,EAAE,CAAC,EAAE,CAAC;QACnI,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC;QAC1B,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;KAClF,CAAC,CAAC;IACH,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC5B,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,WAAW,CAAC,KAAsB;IAChD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,WAAW,CAAC,gBAAgB,EAAE,mDAAmD,CAAC,CAAC;AAC5H,CAAC","sourcesContent":["import { assertSchema, jsonValue, MayuraError, type Guard, type ManagedGuardDefinition, type InferInput, type InferOutput, type ModelAdapter, type Schema } from '@mayura/core';\nimport { readManagedGuardDefinition, snapshotLocalGuards } from '@mayura/core/host';\nimport { assertTool, type AnyTool } from '@mayura/tools';\nimport { snapshotHooks, type HookDefinition } from './hooks.js';\n\nexport type AgentGuard = Guard | ManagedGuardDefinition;\n\n/** An immutable agent definition; executable adapters remain trusted application code. */\nexport interface AgentDefinition<I extends Schema = Schema, O extends Schema = Schema> {\n readonly id: string;\n readonly version: string;\n readonly instructions: string;\n readonly model: ModelAdapter;\n readonly tools: readonly AnyTool[];\n readonly input: Schema<InferInput<I>, InferOutput<I>>;\n readonly output: Schema<InferInput<O>, InferOutput<O>>;\n readonly guards: { readonly input: readonly AgentGuard[]; readonly output: readonly AgentGuard[] };\n readonly hooks: readonly HookDefinition[];\n readonly stream?: AgentStreamPolicy;\n}\n\n/**\n * Opt-in streaming of one text field of the final output (the \"guarded batches\" policy). Without it, output is\n * buffered: nothing is released until the complete output has passed validation and every output guard.\n */\nexport interface AgentStreamPolicy {\n /** Path of the string field to stream, for example `['reply']`. */\n readonly field: readonly string[];\n /**\n * Local guards run on each batch before it is released, with up to 512 characters of already released text for\n * context. A block (or an unavailable guard) stops further release for that model call. Pass `[]` explicitly to\n * stream without batch checks. Released text cannot be retracted by a later verdict; the complete output still\n * passes the agent's output guards before the run succeeds.\n */\n readonly guards: readonly Guard[];\n /** Characters per batch: at least `minChars` ending at whitespace (default 24), at most `maxChars` (default 512). */\n readonly batch?: { readonly minChars?: number; readonly maxChars?: number };\n}\n\nexport type AgentOutput<A extends AgentDefinition> = InferOutput<A['output']>;\nexport interface AgentOptions<I extends Schema, O extends Schema> {\n readonly id: string;\n readonly version: string;\n readonly instructions: string;\n readonly model: ModelAdapter;\n readonly tools: readonly AnyTool[];\n readonly input: I;\n readonly output: O;\n readonly guards?: { readonly input?: readonly AgentGuard[]; readonly output?: readonly AgentGuard[] };\n readonly hooks?: readonly HookDefinition[];\n readonly stream?: AgentStreamPolicy;\n}\n\nconst definitions = new WeakSet<object>();\nconst identifier = /^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/;\n\n/** Definition identifiers are bounded metadata, not arbitrary message or secret containers. */\nexport function isIdentifier(value: unknown): value is string {\n return typeof value === 'string' && identifier.test(value);\n}\n\nfunction snapshotGuards(guards: readonly AgentGuard[]): readonly AgentGuard[] {\n try {\n if (!Array.isArray(guards)) throw new Error();\n const fields = Object.getOwnPropertyDescriptors(guards);\n const length = Object.getOwnPropertyDescriptor(guards, 'length');\n if (!length || !('value' in length) || !Number.isSafeInteger(length.value) || length.value < 0 || length.value > 32\n || Reflect.ownKeys(fields).length !== length.value + 1) throw new Error();\n const seen = new Set<string>(); const result: AgentGuard[] = [];\n for (let index = 0; index < length.value; index++) {\n const entry = fields[String(index)];\n if (!entry || !('value' in entry)) throw new Error();\n const guard: unknown = entry.value;\n const descriptor = readManagedGuardDefinition(guard);\n const captured = descriptor ? guard as ManagedGuardDefinition : snapshotLocalGuards([guard as Guard])[0]!;\n if (!isIdentifier(captured.id) || seen.has(captured.id)) throw new Error();\n seen.add(captured.id);\n result.push(captured); // Preserve genuine managed identity; never clone its authority.\n }\n return Object.freeze(result);\n } catch { throw new MayuraError('INVALID_CONFIG', 'Guards require a dense data list of unique local callbacks or genuinely registered managed definitions.'); }\n}\n\nfunction snapshotSchema<S extends Schema>(schema: S): Schema<InferInput<S>, InferOutput<S>> {\n const standard = schema['~standard'];\n return Object.freeze({ '~standard': Object.freeze({ version: 1 as const, vendor: standard.vendor, validate: standard.validate.bind(standard) }) }) as Schema<InferInput<S>, InferOutput<S>>;\n}\n\n/** Do not execute a newly introduced hooks accessor while capturing the agent configuration. */\nfunction agentHooks(options: object): readonly HookDefinition[] {\n try {\n const field = Object.getOwnPropertyDescriptor(options, 'hooks');\n if (!field) {\n if ('hooks' in options) throw new Error();\n return snapshotHooks([]);\n }\n if (!field.enumerable || !('value' in field)) throw new Error();\n return snapshotHooks(field.value === undefined ? [] : field.value);\n } catch { throw new MayuraError('INVALID_CONFIG', 'Agent hooks must be an own data configuration containing genuine hook definitions.'); }\n}\n\nfunction streamPolicy(value: AgentStreamPolicy): AgentStreamPolicy {\n try {\n const field = value.field; const batch = value.batch ?? {};\n if (!Array.isArray(field) || field.length < 1 || field.length > 8 || field.some(part => typeof part !== 'string' || part.length < 1 || part.length > 128)) throw new Error();\n const minChars = batch.minChars ?? 24; const maxChars = batch.maxChars ?? 512;\n if (!Number.isSafeInteger(minChars) || !Number.isSafeInteger(maxChars) || minChars < 1 || maxChars < minChars || maxChars > 4_096) throw new Error();\n // Batch checks run on every release, so they must be local callbacks, never model-backed managed guards.\n if (!Array.isArray(value.guards) || value.guards.some(guard => readManagedGuardDefinition(guard))) throw new Error();\n return Object.freeze({ field: Object.freeze([...field]), guards: snapshotGuards(value.guards) as readonly Guard[], batch: Object.freeze({ minChars, maxChars }) });\n } catch { throw new MayuraError('INVALID_CONFIG', 'Agent streaming needs a field path (1–8 parts), explicit local batch guards and bounded batch sizes.'); }\n}\n\n/** Define an agent without opening connections, executing tools, or selecting a hidden provider. */\nexport function defineAgent<I extends Schema, O extends Schema>(options: AgentOptions<I, O>): AgentDefinition<I, O> {\n if (!isIdentifier(options.id) || !isIdentifier(options.version) || typeof options.instructions !== 'string') {\n throw new MayuraError('INVALID_CONFIG', 'Agent identifiers, version, and instructions must be valid.');\n }\n jsonValue(options.instructions, { maxBytes: 65_536 });\n assertSchema(options.input);\n assertSchema(options.output);\n const model = options.model;\n if (!model || !isIdentifier(model.id) || typeof model.generate !== 'function'\n || typeof model.capabilities?.tools !== 'boolean' || typeof model.capabilities.structuredOutput !== 'boolean'\n || !Number.isSafeInteger(model.maxCostMicros) || model.maxCostMicros < 0) {\n throw new MayuraError('INVALID_CONFIG', 'A model adapter with explicit capabilities and bounded cost is required.');\n }\n if (!Array.isArray(options.tools) || options.tools.length > 256) {\n throw new MayuraError('INVALID_CONFIG', 'Agent tools must be an explicit bounded registry.');\n }\n const seen = new Set<string>();\n for (const tool of options.tools) {\n assertTool(tool);\n if (!tool || !isIdentifier(tool.id) || seen.has(tool.id)) {\n throw new MayuraError('INVALID_CONFIG', 'Agent tools require unique identifiers.');\n }\n seen.add(tool.id);\n }\n if (!model.capabilities.structuredOutput || (options.tools.length > 0 && !model.capabilities.tools)) {\n throw new MayuraError('INVALID_CONFIG', 'The model does not support the agent required capabilities.');\n }\n const definition: AgentDefinition<I, O> = Object.freeze({\n id: options.id,\n version: options.version,\n instructions: options.instructions,\n model: Object.freeze({\n id: model.id,\n capabilities: Object.freeze({ tools: model.capabilities.tools, structuredOutput: model.capabilities.structuredOutput }),\n maxCostMicros: model.maxCostMicros,\n generate: model.generate.bind(model),\n ...(typeof model.stream === 'function' ? { stream: model.stream.bind(model) } : {}),\n }),\n tools: Object.freeze([...options.tools]),\n input: snapshotSchema(options.input),\n output: snapshotSchema(options.output),\n guards: Object.freeze({ input: snapshotGuards(options.guards?.input ?? []), output: snapshotGuards(options.guards?.output ?? []) }),\n hooks: agentHooks(options),\n ...(options.stream === undefined ? {} : { stream: streamPolicy(options.stream) }),\n });\n definitions.add(definition);\n return definition;\n}\n\n/** Reject hand-built definitions whose admission checks never ran. */\nexport function assertAgent(value: AgentDefinition): void {\n if (!definitions.has(value)) throw new MayuraError('INVALID_CONFIG', 'Use defineAgent to register the agent definition.');\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type InferOutput, type JsonObject, type Permissions, type RunHandle, type Schema } from '../../core/dist/index.js';
|
|
2
|
+
import { type AnyTool, type ToolDefinition } from '../../tools/dist/index.js';
|
|
3
|
+
import { type AgentDefinition } from './agent.js';
|
|
4
|
+
import type { RuntimeLimits } from './runtime.js';
|
|
5
|
+
export interface ChildOptions {
|
|
6
|
+
readonly permissions: Permissions;
|
|
7
|
+
readonly limits?: RuntimeLimits;
|
|
8
|
+
}
|
|
9
|
+
export interface AgentToolOptions extends ChildOptions {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly description: string;
|
|
12
|
+
readonly inputJsonSchema?: JsonObject;
|
|
13
|
+
}
|
|
14
|
+
/** Private execution capability, provided only to broker-minted contexts in the owning runtime. */
|
|
15
|
+
export declare const childGateway: import("../../tools/dist/index.js").ToolContextSlot<{
|
|
16
|
+
spawn(agent: AgentDefinition, input: unknown, options: ChildOptions, signal: AbortSignal): RunHandle<unknown>;
|
|
17
|
+
}>;
|
|
18
|
+
export declare function isAgentTool(tool: AnyTool): boolean;
|
|
19
|
+
/** Expose an agent through the same tool broker without new credit, authority, or transcript inheritance. */
|
|
20
|
+
export declare function agentAsTool<I extends Schema, O extends Schema>(agent: AgentDefinition<I, O>, options: AgentToolOptions): ToolDefinition<I, Schema<InferOutput<O>>>;
|
|
21
|
+
//# sourceMappingURL=composition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composition.d.ts","sourceRoot":"","sources":["../src/composition.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AACzJ,OAAO,EAAqC,KAAK,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AACrG,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC;CACjC;AACD,MAAM,WAAW,gBAAiB,SAAQ,YAAY;IACpD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,eAAe,CAAC,EAAE,UAAU,CAAC;CACvC;AACD,mGAAmG;AACnG,eAAO,MAAM,YAAY;iBACV,eAAe,SAAS,OAAO,WAAW,YAAY,UAAU,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC;EAC3G,CAAC;AAEL,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAA+B;AAElF,6GAA6G;AAC7G,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EAC5D,KAAK,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,gBAAgB,GACtD,cAAc,CAAC,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAsC3C"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsonValue, MayuraError } from '../../core/dist/index.js';
|
|
2
|
+
import { createToolContextSlot, defineTool } from '../../tools/dist/index.js';
|
|
3
|
+
import { assertAgent } from './agent.js';
|
|
4
|
+
/** Private execution capability, provided only to broker-minted contexts in the owning runtime. */
|
|
5
|
+
export const childGateway = createToolContextSlot();
|
|
6
|
+
const composed = new WeakSet();
|
|
7
|
+
export function isAgentTool(tool) { return composed.has(tool); }
|
|
8
|
+
/** Expose an agent through the same tool broker without new credit, authority, or transcript inheritance. */
|
|
9
|
+
export function agentAsTool(agent, options) {
|
|
10
|
+
assertAgent(agent);
|
|
11
|
+
const permissions = options.permissions;
|
|
12
|
+
if (!Array.isArray(permissions?.allow) || permissions.allow.length > 4096
|
|
13
|
+
|| permissions.allow.some((value) => typeof value !== 'string' || value.length === 0 || value.length > 256)) {
|
|
14
|
+
throw new MayuraError('INVALID_CONFIG', 'Child permissions must be an explicit bounded grant list.');
|
|
15
|
+
}
|
|
16
|
+
const childOptions = Object.freeze({
|
|
17
|
+
permissions: Object.freeze({ allow: Object.freeze([...new Set(permissions.allow)]) }),
|
|
18
|
+
...(options.limits === undefined ? {} : { limits: Object.freeze({ ...options.limits }) }),
|
|
19
|
+
});
|
|
20
|
+
// The child owns output schema transformation. The wrapper only checks bounded JSON.
|
|
21
|
+
const output = { '~standard': { version: 1, vendor: 'mayura', validate: (value) => ({ value: value }) } };
|
|
22
|
+
// Enforce the raw child's boundary before a transforming schema can shrink a large input.
|
|
23
|
+
const input = { '~standard': {
|
|
24
|
+
version: 1, vendor: 'mayura', validate: (value) => {
|
|
25
|
+
try {
|
|
26
|
+
jsonValue(value, { maxBytes: childOptions.limits?.maxInputBytes ?? 1_048_576 });
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return { issues: [{ message: 'Child input exceeds its JSON boundary.' }] };
|
|
30
|
+
}
|
|
31
|
+
return agent.input['~standard'].validate(value);
|
|
32
|
+
},
|
|
33
|
+
} };
|
|
34
|
+
const tool = defineTool({
|
|
35
|
+
id: options.id, version: agent.version, description: options.description, input, output,
|
|
36
|
+
effects: 'none', capabilities: ['agent:delegate'], costMicros: 0,
|
|
37
|
+
timeoutMs: options.limits?.maxDurationMs ?? 2_147_483_647,
|
|
38
|
+
...(options.inputJsonSchema === undefined ? {} : { inputJsonSchema: options.inputJsonSchema }),
|
|
39
|
+
execute: async (input, context) => {
|
|
40
|
+
const gateway = childGateway.get(context);
|
|
41
|
+
if (!gateway)
|
|
42
|
+
throw new MayuraError('PERMISSION_DENIED', 'Agent composition requires a live owning runtime.');
|
|
43
|
+
// Input has passed the broker's schema. The non-exported gateway records that provenance.
|
|
44
|
+
const child = gateway.spawn(agent, input, childOptions, context.signal);
|
|
45
|
+
const outcome = await child.result();
|
|
46
|
+
if (outcome.status !== 'succeeded')
|
|
47
|
+
throw new MayuraError('TOOL_FAILED', 'A required child did not succeed.');
|
|
48
|
+
return outcome.output;
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
composed.add(tool);
|
|
52
|
+
return tool;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=composition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composition.js","sourceRoot":"","sources":["../src/composition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAqG,MAAM,cAAc,CAAC;AACzJ,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAqC,MAAM,eAAe,CAAC;AACrG,OAAO,EAAE,WAAW,EAAwB,MAAM,YAAY,CAAC;AAY/D,mGAAmG;AACnG,MAAM,CAAC,MAAM,YAAY,GAAG,qBAAqB,EAE7C,CAAC;AACL,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAU,CAAC;AACvC,MAAM,UAAU,WAAW,CAAC,IAAa,IAAa,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAElF,6GAA6G;AAC7G,MAAM,UAAU,WAAW,CACzB,KAA4B,EAAE,OAAyB;IAEvD,WAAW,CAAC,KAAK,CAAC,CAAC;IACnB,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IACxC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,WA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AC,MAAmC,CAAC;QACrD,CAAC;KACF,CAAC,CAAC;IACH,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnB,OAAO,IAAiD,CAAC;AAC3D,CAAC","sourcesContent":["import { jsonValue, MayuraError, type InferInput, type InferOutput, type JsonObject, type Permissions, type RunHandle, type Schema } from '@mayura/core';\nimport { createToolContextSlot, defineTool, type AnyTool, type ToolDefinition } from '@mayura/tools';\nimport { assertAgent, type AgentDefinition } from './agent.js';\nimport type { RuntimeLimits } from './runtime.js';\n\nexport interface ChildOptions {\n readonly permissions: Permissions;\n readonly limits?: RuntimeLimits;\n}\nexport interface AgentToolOptions extends ChildOptions {\n readonly id: string;\n readonly description: string;\n readonly inputJsonSchema?: JsonObject;\n}\n/** Private execution capability, provided only to broker-minted contexts in the owning runtime. */\nexport const childGateway = createToolContextSlot<{\n spawn(agent: AgentDefinition, input: unknown, options: ChildOptions, signal: AbortSignal): RunHandle<unknown>;\n}>();\nconst composed = new WeakSet<object>();\nexport function isAgentTool(tool: AnyTool): boolean { return composed.has(tool); }\n\n/** Expose an agent through the same tool broker without new credit, authority, or transcript inheritance. */\nexport function agentAsTool<I extends Schema, O extends Schema>(\n agent: AgentDefinition<I, O>, options: AgentToolOptions,\n): ToolDefinition<I, Schema<InferOutput<O>>> {\n assertAgent(agent);\n const permissions = options.permissions;\n if (!Array.isArray(permissions?.allow) || permissions.allow.length > 4096\n || permissions.allow.some((value) => typeof value !== 'string' || value.length === 0 || value.length > 256)) {\n throw new MayuraError('INVALID_CONFIG', 'Child permissions must be an explicit bounded grant list.');\n }\n const childOptions: ChildOptions = Object.freeze({\n permissions: Object.freeze({ allow: Object.freeze([...new Set(permissions.allow)]) }),\n ...(options.limits === undefined ? {} : { limits: Object.freeze({ ...options.limits }) }),\n });\n // The child owns output schema transformation. The wrapper only checks bounded JSON.\n const output: Schema<InferOutput<O>> = { '~standard': { version: 1, vendor: 'mayura', validate: (value) => ({ value: value as InferOutput<O> }) } };\n // Enforce the raw child's boundary before a transforming schema can shrink a large input.\n const input: Schema<InferInput<I>, InferOutput<I>> = { '~standard': {\n version: 1, vendor: 'mayura', validate: (value) => {\n try { jsonValue(value, { maxBytes: childOptions.limits?.maxInputBytes ?? 1_048_576 }); }\n catch { return { issues: [{ message: 'Child input exceeds its JSON boundary.' }] }; }\n return agent.input['~standard'].validate(value);\n },\n } };\n const tool = defineTool<Schema<InferInput<I>, InferOutput<I>>, Schema<InferOutput<O>>>({\n id: options.id, version: agent.version, description: options.description, input, output,\n effects: 'none', capabilities: ['agent:delegate'], costMicros: 0,\n timeoutMs: options.limits?.maxDurationMs ?? 2_147_483_647,\n ...(options.inputJsonSchema === undefined ? {} : { inputJsonSchema: options.inputJsonSchema }),\n execute: async (input, context) => {\n const gateway = childGateway.get(context);\n if (!gateway) throw new MayuraError('PERMISSION_DENIED', 'Agent composition requires a live owning runtime.');\n // Input has passed the broker's schema. The non-exported gateway records that provenance.\n const child = gateway.spawn(agent, input, childOptions, context.signal);\n const outcome = await child.result();\n if (outcome.status !== 'succeeded') throw new MayuraError('TOOL_FAILED', 'A required child did not succeed.');\n return outcome.output as InferInput<typeof output>;\n },\n });\n composed.add(tool);\n return tool as ToolDefinition<I, Schema<InferOutput<O>>>;\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type RunEvent } from '../../core/dist/index.js';
|
|
2
|
+
/** Bounded process-local replay buffer. Observers share retained events, not private unbounded queues. */
|
|
3
|
+
export declare class EventBuffer {
|
|
4
|
+
private readonly runId;
|
|
5
|
+
private readonly capacity;
|
|
6
|
+
private events;
|
|
7
|
+
private sequence;
|
|
8
|
+
private terminal;
|
|
9
|
+
private readonly waiters;
|
|
10
|
+
constructor(runId: string, capacity: number);
|
|
11
|
+
emit(type: RunEvent['type'], metadata?: RunEvent['metadata']): void;
|
|
12
|
+
finish(): void;
|
|
13
|
+
observe(options?: {
|
|
14
|
+
readonly after?: number;
|
|
15
|
+
readonly signal?: AbortSignal;
|
|
16
|
+
}): AsyncIterable<RunEvent>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=event-buffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-buffer.d.ts","sourceRoot":"","sources":["../src/event-buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE1D,0GAA0G;AAC1G,qBAAa,WAAW;IAMV,OAAO,CAAC,QAAQ,CAAC,KAAK;IAAU,OAAO,CAAC,QAAQ,CAAC,QAAQ;IALrE,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IAEjD,YAA6B,KAAK,EAAE,MAAM,EAAmB,QAAQ,EAAE,MAAM,EAAI;IAEjF,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAE,QAAQ,CAAC,UAAU,CAAM,GAAG,IAAI,CAMtE;IAED,MAAM,IAAI,IAAI,CAIb;IAEM,OAAO,CAAC,OAAO,GAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAO,GAAG,aAAa,CAAC,QAAQ,CAAC,CA4BhH;CACF"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { MayuraError } from '../../core/dist/index.js';
|
|
2
|
+
/** Bounded process-local replay buffer. Observers share retained events, not private unbounded queues. */
|
|
3
|
+
export class EventBuffer {
|
|
4
|
+
runId;
|
|
5
|
+
capacity;
|
|
6
|
+
events = [];
|
|
7
|
+
sequence = 0;
|
|
8
|
+
terminal = false;
|
|
9
|
+
waiters = new Set();
|
|
10
|
+
constructor(runId, capacity) {
|
|
11
|
+
this.runId = runId;
|
|
12
|
+
this.capacity = capacity;
|
|
13
|
+
}
|
|
14
|
+
emit(type, metadata = {}) {
|
|
15
|
+
if (this.terminal)
|
|
16
|
+
return;
|
|
17
|
+
this.events.push(Object.freeze({ runId: this.runId, sequence: ++this.sequence, timestamp: new Date().toISOString(), type, metadata: Object.freeze({ ...metadata }) }));
|
|
18
|
+
if (this.events.length > this.capacity)
|
|
19
|
+
this.events.shift();
|
|
20
|
+
for (const wake of this.waiters)
|
|
21
|
+
wake();
|
|
22
|
+
this.waiters.clear();
|
|
23
|
+
}
|
|
24
|
+
finish() {
|
|
25
|
+
this.terminal = true;
|
|
26
|
+
for (const wake of this.waiters)
|
|
27
|
+
wake();
|
|
28
|
+
this.waiters.clear();
|
|
29
|
+
}
|
|
30
|
+
async *observe(options = {}) {
|
|
31
|
+
let cursor = options.after ?? 0;
|
|
32
|
+
if (!Number.isSafeInteger(cursor) || cursor < 0 || cursor > this.sequence) {
|
|
33
|
+
throw new MayuraError('INVALID_INPUT', 'Event cursor must refer to this process-local run history.');
|
|
34
|
+
}
|
|
35
|
+
while (!options.signal?.aborted) {
|
|
36
|
+
const oldest = this.events[0]?.sequence ?? this.sequence + 1;
|
|
37
|
+
if (cursor < oldest - 1) {
|
|
38
|
+
// Synthetic gap metadata is explicitly distinguished from retained execution evidence.
|
|
39
|
+
const previous = cursor;
|
|
40
|
+
cursor = oldest - 1;
|
|
41
|
+
yield Object.freeze({ runId: this.runId, sequence: cursor, timestamp: new Date().toISOString(), type: 'events.gap', metadata: Object.freeze({ from: previous + 1, to: cursor }) });
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const next = this.events.find((event) => event.sequence > cursor);
|
|
45
|
+
if (next) {
|
|
46
|
+
cursor = next.sequence;
|
|
47
|
+
yield next;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (this.terminal)
|
|
51
|
+
return;
|
|
52
|
+
await new Promise((resolve) => {
|
|
53
|
+
const wake = () => {
|
|
54
|
+
this.waiters.delete(wake);
|
|
55
|
+
options.signal?.removeEventListener('abort', wake);
|
|
56
|
+
resolve();
|
|
57
|
+
};
|
|
58
|
+
this.waiters.add(wake);
|
|
59
|
+
options.signal?.addEventListener('abort', wake, { once: true });
|
|
60
|
+
if (options.signal?.aborted)
|
|
61
|
+
wake();
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=event-buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-buffer.js","sourceRoot":"","sources":["../src/event-buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiB,MAAM,cAAc,CAAC;AAE1D,0GAA0G;AAC1G,MAAM,OAAO,WAAW;IAMO,KAAK;IAA2B,QAAQ;IAL7D,MAAM,GAAe,EAAE,CAAC;IACxB,QAAQ,GAAG,CAAC,CAAC;IACb,QAAQ,GAAG,KAAK,CAAC;IACR,OAAO,GAAG,IAAI,GAAG,EAAc,CAAC;IAEjD,YAA6B,KAAa,EAAmB,QAAgB;qBAAhD,KAAK;wBAA2B,QAAQ;IAAW,CAAC;IAEjF,IAAI,CAAC,IAAsB,EAAE,QAAQ,GAAyB,EAAE;QAC9D,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO;QAC1B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACvK,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ;YAAE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAC5D,KAAK,M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,EAAE,CAAC,EAAE,CAAC,CAAC;gBACnL,SAAS;YACX,CAAC;YACD,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC;YAClE,IAAI,IAAI,EAAE,CAAC;gBAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC;gBAAC,MAAM,IAAI,CAAC;gBAAC,SAAS;YAAC,CAAC;YAC3D,IAAI,IAAI,CAAC,QAAQ;gBAAE,OAAO;YAC1B,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;gBAClC,MAAM,IAAI,GAAG,GAAS,EAAE;oBACtB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;oBAC1B,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;oBACnD,OAAO,EAAE,CAAC;gBACZ,CAAC,CAAC;gBACF,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACvB,OAAO,CAAC,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;gBAChE,IAAI,OAAO,CAAC,MAAM,EAAE,OAAO;oBAAE,IAAI,EAAE,CAAC;YACtC,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF","sourcesContent":["import { MayuraError, type RunEvent } from '@mayura/core';\n\n/** Bounded process-local replay buffer. Observers share retained events, not private unbounded queues. */\nexport class EventBuffer {\n private events: RunEvent[] = [];\n private sequence = 0;\n private terminal = false;\n private readonly waiters = new Set<() => void>();\n\n constructor(private readonly runId: string, private readonly capacity: number) {}\n\n emit(type: RunEvent['type'], metadata: RunEvent['metadata'] = {}): void {\n if (this.terminal) return;\n this.events.push(Object.freeze({ runId: this.runId, sequence: ++this.sequence, timestamp: new Date().toISOString(), type, metadata: Object.freeze({ ...metadata }) }));\n if (this.events.length > this.capacity) this.events.shift();\n for (const wake of this.waiters) wake();\n this.waiters.clear();\n }\n\n finish(): void {\n this.terminal = true;\n for (const wake of this.waiters) wake();\n this.waiters.clear();\n }\n\n async *observe(options: { readonly after?: number; readonly signal?: AbortSignal } = {}): AsyncIterable<RunEvent> {\n let cursor = options.after ?? 0;\n if (!Number.isSafeInteger(cursor) || cursor < 0 || cursor > this.sequence) {\n throw new MayuraError('INVALID_INPUT', 'Event cursor must refer to this process-local run history.');\n }\n while (!options.signal?.aborted) {\n const oldest = this.events[0]?.sequence ?? this.sequence + 1;\n if (cursor < oldest - 1) {\n // Synthetic gap metadata is explicitly distinguished from retained execution evidence.\n const previous = cursor;\n cursor = oldest - 1;\n yield Object.freeze({ runId: this.runId, sequence: cursor, timestamp: new Date().toISOString(), type: 'events.gap', metadata: Object.freeze({ from: previous + 1, to: cursor }) });\n continue;\n }\n const next = this.events.find((event) => event.sequence > cursor);\n if (next) { cursor = next.sequence; yield next; continue; }\n if (this.terminal) return;\n await new Promise<void>((resolve) => {\n const wake = (): void => {\n this.waiters.delete(wake);\n options.signal?.removeEventListener('abort', wake);\n resolve();\n };\n this.waiters.add(wake);\n options.signal?.addEventListener('abort', wake, { once: true });\n if (options.signal?.aborted) wake();\n });\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type JsonValue, type Outcome } from '../../core/dist/index.js';
|
|
2
|
+
import type { AnyTool } from '../../tools/dist/index.js';
|
|
3
|
+
import type { HookContext, HookDescriptor, HookEvent } from './hooks.js';
|
|
4
|
+
import type { OperationPermits } from './permits.js';
|
|
5
|
+
type Failure = Exclude<Outcome<never>, {
|
|
6
|
+
readonly status: 'succeeded';
|
|
7
|
+
}>;
|
|
8
|
+
export type HookCompletion = 'continued' | 'blocked' | 'failed' | 'cancelled' | 'outcome_unknown';
|
|
9
|
+
/** All execution authority is supplied by the private owning-run closure, never by callback context. */
|
|
10
|
+
interface HookEvaluation {
|
|
11
|
+
readonly descriptor: Readonly<HookDescriptor>;
|
|
12
|
+
readonly event: HookEvent;
|
|
13
|
+
readonly context: Omit<HookContext, 'signal'>;
|
|
14
|
+
readonly signal: AbortSignal;
|
|
15
|
+
readonly operations: OperationPermits;
|
|
16
|
+
readonly assertActive: () => void;
|
|
17
|
+
/** Recheck/increment all ancestor hook counters synchronously after acquiring the actual permit. */
|
|
18
|
+
readonly onStarted: () => void;
|
|
19
|
+
readonly onCompleted: (status: HookCompletion) => void;
|
|
20
|
+
readonly preflight: (tool: AnyTool, input: JsonValue, signal: AbortSignal) => Promise<void>;
|
|
21
|
+
readonly invoke: (tool: AnyTool, input: JsonValue, callId: string, signal: AbortSignal) => Promise<Outcome<JsonValue>>;
|
|
22
|
+
readonly allocateCallId: (index: number) => string;
|
|
23
|
+
}
|
|
24
|
+
/** Required control hooks return a truthful tool failure, including uncertain effects, without retry. */
|
|
25
|
+
export declare function evaluateHook(options: HookEvaluation): Promise<Failure | undefined>;
|
|
26
|
+
export type ObserverCompletion = 'continued' | 'failed' | 'cancelled';
|
|
27
|
+
interface ObserverEvaluation {
|
|
28
|
+
readonly descriptor: Readonly<HookDescriptor>;
|
|
29
|
+
readonly event: HookEvent;
|
|
30
|
+
readonly context: Omit<HookContext, 'signal'>;
|
|
31
|
+
readonly signal: AbortSignal;
|
|
32
|
+
readonly operations: OperationPermits;
|
|
33
|
+
/** Recheck/increment all ancestor hook counters synchronously after acquiring the actual permit. */
|
|
34
|
+
readonly onStarted: () => void;
|
|
35
|
+
readonly onCompleted: (status: ObserverCompletion) => void;
|
|
36
|
+
}
|
|
37
|
+
/** Observers take no actions; any thrown error, timeout or non-undefined result is a failure. Never throws. */
|
|
38
|
+
export declare function evaluateObserver(options: ObserverEvaluation): Promise<ObserverCompletion>;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=hook-execution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;IACvH,QAAQ,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACpD;AA4FD,yGAAyG;AACzG,wBAAsB,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAoCxF;AAED,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;AACtE,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC;IAC9C,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAC9C,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;IACtC,oGAAoG;IACpG,QAAQ,CAAC,SAAS,EAAE,MAAM,IAAI,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;CAC5D;AAED,+GAA+G;AAC/G,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAqB/F"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { freezeJson, jsonValue, MayuraError } from '../../core/dist/index.js';
|
|
2
|
+
const errors = {
|
|
3
|
+
CANCELLED: 'The required lifecycle hook was cancelled.',
|
|
4
|
+
TIMEOUT: 'The required lifecycle hook exceeded its deadline.',
|
|
5
|
+
BUDGET_EXCEEDED: 'The owning execution budget could not admit the hook action.',
|
|
6
|
+
LIMIT_EXCEEDED: 'An owning execution limit prevented the required lifecycle hook.',
|
|
7
|
+
PERMISSION_DENIED: 'A required hook action was not authorized.',
|
|
8
|
+
GUARD_BLOCKED: 'A required lifecycle hook withheld this operation or output.',
|
|
9
|
+
GUARD_UNAVAILABLE: 'A required lifecycle hook could not establish a valid decision.',
|
|
10
|
+
};
|
|
11
|
+
/** Never invoke exception accessors/toJSON or disclose callback/schema-controlled text. */
|
|
12
|
+
function safeFailure(error) {
|
|
13
|
+
let code = 'GUARD_UNAVAILABLE';
|
|
14
|
+
try {
|
|
15
|
+
const descriptor = error instanceof MayuraError ? Object.getOwnPropertyDescriptor(error, 'code') : undefined;
|
|
16
|
+
const value = descriptor && 'value' in descriptor ? descriptor.value : undefined;
|
|
17
|
+
if (typeof value === 'string' && Object.hasOwn(errors, value))
|
|
18
|
+
code = value;
|
|
19
|
+
}
|
|
20
|
+
catch { /* In-process exception proxies cannot control public diagnostics. */ }
|
|
21
|
+
return new MayuraError(code, errors[code]);
|
|
22
|
+
}
|
|
23
|
+
/** A logical deadline; operation permits remain attached to the actual callback promise. */
|
|
24
|
+
class HookDeadline {
|
|
25
|
+
parent;
|
|
26
|
+
controller = new AbortController();
|
|
27
|
+
#end;
|
|
28
|
+
#timer;
|
|
29
|
+
#relay;
|
|
30
|
+
constructor(parent, timeoutMs) {
|
|
31
|
+
this.parent = parent;
|
|
32
|
+
this.#end = performance.now() + timeoutMs;
|
|
33
|
+
this.#relay = () => {
|
|
34
|
+
const reason = safeFailure(parent.reason);
|
|
35
|
+
this.controller.abort(reason.code === 'TIMEOUT' ? reason : new MayuraError('CANCELLED', errors.CANCELLED));
|
|
36
|
+
};
|
|
37
|
+
parent.addEventListener('abort', this.#relay, { once: true });
|
|
38
|
+
if (parent.aborted)
|
|
39
|
+
this.#relay();
|
|
40
|
+
this.#timer = setTimeout(() => this.controller.abort(new MayuraError('TIMEOUT', errors.TIMEOUT)), timeoutMs);
|
|
41
|
+
}
|
|
42
|
+
check() {
|
|
43
|
+
if (!this.controller.signal.aborted && performance.now() >= this.#end) {
|
|
44
|
+
this.controller.abort(new MayuraError('TIMEOUT', errors.TIMEOUT));
|
|
45
|
+
}
|
|
46
|
+
if (this.controller.signal.aborted)
|
|
47
|
+
throw this.controller.signal.reason;
|
|
48
|
+
}
|
|
49
|
+
async wait(operation) {
|
|
50
|
+
this.check();
|
|
51
|
+
const signal = this.controller.signal;
|
|
52
|
+
return await new Promise((resolve, reject) => {
|
|
53
|
+
const cleanup = () => signal.removeEventListener('abort', abort);
|
|
54
|
+
const abort = () => { cleanup(); reject(signal.reason); };
|
|
55
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
56
|
+
Promise.resolve().then(() => { this.check(); return operation(); })
|
|
57
|
+
.then(value => { cleanup(); resolve(value); }, (error) => { cleanup(); reject(error); });
|
|
58
|
+
if (signal.aborted)
|
|
59
|
+
abort();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
close() {
|
|
63
|
+
clearTimeout(this.#timer);
|
|
64
|
+
this.parent.removeEventListener('abort', this.#relay);
|
|
65
|
+
this.controller.abort(new MayuraError('CANCELLED', errors.CANCELLED));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function object(value) {
|
|
69
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
70
|
+
throw new Error();
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
function exact(record, required, optional = []) {
|
|
74
|
+
if (required.some(key => !Object.hasOwn(record, key)) || Object.keys(record).some(key => !required.includes(key) && !optional.includes(key)))
|
|
75
|
+
throw new Error();
|
|
76
|
+
}
|
|
77
|
+
/** Whole-list identity/result admission precedes every schema callback and every action. */
|
|
78
|
+
function decisionFor(raw, descriptor) {
|
|
79
|
+
const value = object(freezeJson(jsonValue(raw, { maxBytes: descriptor.maxResultBytes })));
|
|
80
|
+
if (value['decision'] === 'block') {
|
|
81
|
+
exact(value, ['decision']);
|
|
82
|
+
throw new MayuraError('GUARD_BLOCKED', errors.GUARD_BLOCKED);
|
|
83
|
+
}
|
|
84
|
+
exact(value, ['decision'], ['actions']);
|
|
85
|
+
if (value['decision'] !== 'continue')
|
|
86
|
+
throw new Error();
|
|
87
|
+
const actions = value['actions'] ?? [];
|
|
88
|
+
if (!Array.isArray(actions) || actions.length > descriptor.maxActions || (Object.hasOwn(value, 'actions') && value['actions'] === null))
|
|
89
|
+
throw new Error();
|
|
90
|
+
const tools = new Map(descriptor.tools.map(tool => [tool.id, tool]));
|
|
91
|
+
return actions.map(item => {
|
|
92
|
+
const action = object(item);
|
|
93
|
+
exact(action, ['toolId', 'input']);
|
|
94
|
+
const toolId = action['toolId'];
|
|
95
|
+
const tool = typeof toolId === 'string' ? tools.get(toolId) : undefined;
|
|
96
|
+
if (!tool)
|
|
97
|
+
throw new Error();
|
|
98
|
+
return Object.freeze({ tool, input: action['input'] });
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/** Required control hooks return a truthful tool failure, including uncertain effects, without retry. */
|
|
102
|
+
export async function evaluateHook(options) {
|
|
103
|
+
const deadline = new HookDeadline(options.signal, options.descriptor.timeoutMs);
|
|
104
|
+
const signal = deadline.controller.signal;
|
|
105
|
+
const active = () => { options.assertActive(); deadline.check(); };
|
|
106
|
+
let started = false;
|
|
107
|
+
let status = 'failed';
|
|
108
|
+
try {
|
|
109
|
+
active();
|
|
110
|
+
const context = Object.freeze({ ...options.context, signal });
|
|
111
|
+
const raw = await deadline.wait(() => options.operations.run(signal, async () => {
|
|
112
|
+
active();
|
|
113
|
+
options.onStarted();
|
|
114
|
+
started = true;
|
|
115
|
+
try {
|
|
116
|
+
return await options.descriptor.handler(options.event, context);
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
throw new MayuraError('GUARD_UNAVAILABLE', errors.GUARD_UNAVAILABLE);
|
|
120
|
+
}
|
|
121
|
+
}));
|
|
122
|
+
active();
|
|
123
|
+
const actions = decisionFor(raw, options.descriptor);
|
|
124
|
+
for (const action of actions) {
|
|
125
|
+
active();
|
|
126
|
+
await deadline.wait(() => options.preflight(action.tool, action.input, signal));
|
|
127
|
+
}
|
|
128
|
+
for (const [index, action] of actions.entries()) {
|
|
129
|
+
active();
|
|
130
|
+
// Do not race this against another generic timeout. The broker already observes this
|
|
131
|
+
// signal and must be allowed to classify/preserve an uncertain dispatched action.
|
|
132
|
+
const outcome = await options.invoke(action.tool, action.input, options.allocateCallId(index), signal);
|
|
133
|
+
if (outcome.status !== 'succeeded') {
|
|
134
|
+
status = outcome.status;
|
|
135
|
+
return outcome;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
active();
|
|
139
|
+
status = 'continued';
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
const safe = safeFailure(error);
|
|
144
|
+
status = safe.code === 'CANCELLED' ? 'cancelled'
|
|
145
|
+
: ['GUARD_BLOCKED', 'GUARD_UNAVAILABLE', 'PERMISSION_DENIED', 'BUDGET_EXCEEDED'].includes(safe.code) ? 'blocked' : 'failed';
|
|
146
|
+
return Object.freeze({ status, error: Object.freeze({ code: safe.code, message: safe.message }) });
|
|
147
|
+
}
|
|
148
|
+
finally {
|
|
149
|
+
if (started)
|
|
150
|
+
options.onCompleted(status);
|
|
151
|
+
deadline.close();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/** Observers take no actions; any thrown error, timeout or non-undefined result is a failure. Never throws. */
|
|
155
|
+
export async function evaluateObserver(options) {
|
|
156
|
+
const deadline = new HookDeadline(options.signal, options.descriptor.timeoutMs);
|
|
157
|
+
const signal = deadline.controller.signal;
|
|
158
|
+
let started = false;
|
|
159
|
+
let status = 'failed';
|
|
160
|
+
try {
|
|
161
|
+
deadline.check();
|
|
162
|
+
const context = Object.freeze({ ...options.context, signal });
|
|
163
|
+
const raw = await deadline.wait(() => options.operations.run(signal, async () => {
|
|
164
|
+
deadline.check();
|
|
165
|
+
options.onStarted();
|
|
166
|
+
started = true;
|
|
167
|
+
try {
|
|
168
|
+
return await options.descriptor.handler(options.event, context);
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
throw new MayuraError('GUARD_UNAVAILABLE', errors.GUARD_UNAVAILABLE);
|
|
172
|
+
}
|
|
173
|
+
}));
|
|
174
|
+
status = raw === undefined ? 'continued' : 'failed';
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
status = safeFailure(error).code === 'CANCELLED' ? 'cancelled' : 'failed';
|
|
178
|
+
}
|
|
179
|
+
finally {
|
|
180
|
+
if (started)
|
|
181
|
+
options.onCompleted(status);
|
|
182
|
+
deadline.close();
|
|
183
|
+
}
|
|
184
|
+
return status;
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=hook-execution.js.map
|