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,145 @@
|
|
|
1
|
+
import type { JsonValue, LifecycleControl, Scope } from '../../core/dist/index.js';
|
|
2
|
+
export type ContextKind = 'evidence' | 'instruction' | 'hard_constraint' | 'pending_approval' | 'unresolved_blocker' | 'outstanding_task';
|
|
3
|
+
export type ContextTrust = 'untrusted' | 'reviewed' | 'trusted';
|
|
4
|
+
export type Sensitivity = 'public' | 'internal' | 'confidential' | 'restricted';
|
|
5
|
+
export type SourceKind = 'document' | 'conversation' | 'memory' | 'artifact' | 'repository' | 'tool' | 'application';
|
|
6
|
+
export interface ContextSource {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly revision: string;
|
|
9
|
+
readonly kind: SourceKind;
|
|
10
|
+
}
|
|
11
|
+
/** Original evidence identity; distinct from a memory record's current canonical ID/version. */
|
|
12
|
+
export interface UpstreamEvidence {
|
|
13
|
+
readonly sourceId: string;
|
|
14
|
+
readonly revision: string;
|
|
15
|
+
readonly sha256: string;
|
|
16
|
+
}
|
|
17
|
+
/** Inclusive start and exclusive end, with null denoting no declared expiry. */
|
|
18
|
+
export interface ContextValidity {
|
|
19
|
+
readonly from: string;
|
|
20
|
+
readonly until: string | null;
|
|
21
|
+
}
|
|
22
|
+
export interface ContextProvenance {
|
|
23
|
+
readonly reference: string;
|
|
24
|
+
/** Canonical UTC ISO string, compatible with native-memory timestamps. */
|
|
25
|
+
readonly observedAt: string;
|
|
26
|
+
readonly origin: 'observed' | 'inferred';
|
|
27
|
+
readonly confidence: number;
|
|
28
|
+
readonly author?: string;
|
|
29
|
+
readonly upstream?: UpstreamEvidence;
|
|
30
|
+
}
|
|
31
|
+
export interface ContextCandidate {
|
|
32
|
+
readonly id: string;
|
|
33
|
+
readonly scope: Scope;
|
|
34
|
+
readonly source: ContextSource;
|
|
35
|
+
readonly provenance: ContextProvenance;
|
|
36
|
+
readonly trust: ContextTrust;
|
|
37
|
+
readonly sensitivity: Sensitivity;
|
|
38
|
+
readonly kind: ContextKind;
|
|
39
|
+
readonly priority?: number;
|
|
40
|
+
readonly pinned?: boolean;
|
|
41
|
+
readonly validity?: ContextValidity;
|
|
42
|
+
readonly content: JsonValue;
|
|
43
|
+
}
|
|
44
|
+
export interface SourceState {
|
|
45
|
+
readonly scope: Scope;
|
|
46
|
+
readonly id: string;
|
|
47
|
+
readonly revision: string;
|
|
48
|
+
readonly status: 'active' | 'deleted';
|
|
49
|
+
}
|
|
50
|
+
export interface ContextBudget {
|
|
51
|
+
readonly maxBytes: number;
|
|
52
|
+
readonly maxEstimatedTokens: number;
|
|
53
|
+
readonly reservedBytes?: number;
|
|
54
|
+
readonly reservedTokens?: number;
|
|
55
|
+
}
|
|
56
|
+
/** Trusted local deterministic estimator, not a paid model call or a guaranteed tokenizer. */
|
|
57
|
+
export interface TokenEstimator {
|
|
58
|
+
readonly id: string;
|
|
59
|
+
estimate(serialized: string): number;
|
|
60
|
+
}
|
|
61
|
+
export interface AssembleContextOptions {
|
|
62
|
+
readonly scope: Scope;
|
|
63
|
+
readonly policyVersion: string;
|
|
64
|
+
readonly candidates: readonly ContextCandidate[];
|
|
65
|
+
readonly sources: readonly SourceState[];
|
|
66
|
+
readonly allowedSensitivities: readonly Sensitivity[];
|
|
67
|
+
readonly budget: ContextBudget;
|
|
68
|
+
readonly estimator?: TokenEstimator;
|
|
69
|
+
/** Canonical UTC ISO timestamp; omitted means snapshot the current time once. */
|
|
70
|
+
readonly asOf?: string;
|
|
71
|
+
/** Fail-closed lifecycle hooks around assembly; either can block. */
|
|
72
|
+
readonly hooks?: ContextHooks;
|
|
73
|
+
/** Cancels a pending hook callback; assembly itself performs no I/O. */
|
|
74
|
+
readonly signal?: AbortSignal;
|
|
75
|
+
}
|
|
76
|
+
/** Metadata-only view before selection. Candidate content is not included. */
|
|
77
|
+
export interface BeforeContextBuildEvent {
|
|
78
|
+
readonly scope: Scope;
|
|
79
|
+
readonly policyVersion: string;
|
|
80
|
+
readonly asOf: string;
|
|
81
|
+
readonly candidateCount: number;
|
|
82
|
+
readonly sourceCount: number;
|
|
83
|
+
readonly budget: Required<ContextBudget>;
|
|
84
|
+
}
|
|
85
|
+
/** Metadata-only view of the finished assembly; selected content is identified by digest, not included. */
|
|
86
|
+
export interface AfterContextBuildEvent {
|
|
87
|
+
readonly scope: Scope;
|
|
88
|
+
readonly policyVersion: string;
|
|
89
|
+
readonly asOf: string;
|
|
90
|
+
readonly fingerprint: string;
|
|
91
|
+
readonly selected: readonly {
|
|
92
|
+
readonly id: string;
|
|
93
|
+
readonly sourceId: string;
|
|
94
|
+
readonly revision: string;
|
|
95
|
+
readonly contentDigest: string;
|
|
96
|
+
}[];
|
|
97
|
+
readonly excluded: readonly ContextExclusion[];
|
|
98
|
+
readonly usage: ContextUsage;
|
|
99
|
+
}
|
|
100
|
+
export interface ContextHooks {
|
|
101
|
+
readonly beforeContextBuild?: LifecycleControl<BeforeContextBuildEvent, 'beforeContextBuild'>;
|
|
102
|
+
readonly afterContextBuild?: LifecycleControl<AfterContextBuildEvent, 'afterContextBuild'>;
|
|
103
|
+
/** Per-callback deadline in milliseconds (default 5000, maximum 30000). */
|
|
104
|
+
readonly timeoutMs?: number;
|
|
105
|
+
}
|
|
106
|
+
export type ReadonlyJson = string | number | boolean | null | readonly ReadonlyJson[] | {
|
|
107
|
+
readonly [key: string]: ReadonlyJson;
|
|
108
|
+
};
|
|
109
|
+
export interface ContextItem extends Omit<ContextCandidate, 'content' | 'pinned' | 'priority'> {
|
|
110
|
+
readonly content: ReadonlyJson;
|
|
111
|
+
readonly priority: number;
|
|
112
|
+
readonly pinned: boolean;
|
|
113
|
+
readonly required: boolean;
|
|
114
|
+
readonly contentDigest: string;
|
|
115
|
+
}
|
|
116
|
+
export type ExclusionReason = 'scope_mismatch' | 'sensitivity_denied' | 'source_missing' | 'source_deleted' | 'stale_revision' | 'not_yet_valid' | 'expired' | 'byte_budget' | 'token_budget';
|
|
117
|
+
export interface ContextExclusion {
|
|
118
|
+
readonly position: number;
|
|
119
|
+
readonly reason: ExclusionReason;
|
|
120
|
+
/** Omitted for scope or sensitivity denials; excluded content is never returned. */
|
|
121
|
+
readonly candidateId?: string;
|
|
122
|
+
readonly sourceId?: string;
|
|
123
|
+
readonly revision?: string;
|
|
124
|
+
}
|
|
125
|
+
export interface ContextUsage {
|
|
126
|
+
readonly bytes: number;
|
|
127
|
+
readonly estimatedTokens: number;
|
|
128
|
+
readonly reservedBytes: number;
|
|
129
|
+
readonly reservedTokens: number;
|
|
130
|
+
readonly maxBytes: number;
|
|
131
|
+
readonly maxEstimatedTokens: number;
|
|
132
|
+
readonly estimatorId: string;
|
|
133
|
+
}
|
|
134
|
+
export interface ContextAssembly {
|
|
135
|
+
readonly scope: Scope;
|
|
136
|
+
readonly policyVersion: string;
|
|
137
|
+
readonly asOf: string;
|
|
138
|
+
readonly selected: readonly ContextItem[];
|
|
139
|
+
readonly excluded: readonly ContextExclusion[];
|
|
140
|
+
readonly usage: ContextUsage;
|
|
141
|
+
/** Exact canonical JSON payload measured by usage; it does not assign provider message authority. */
|
|
142
|
+
readonly serialized: string;
|
|
143
|
+
readonly fingerprint: string;
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAEvE,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,aAAa,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,oBAAoB,GAAG,kBAAkB,CAAC;AAC1I,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;AAChE,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,cAAc,GAAG,YAAY,CAAC;AAChF,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,cAAc,GAAG,QAAQ,GAAG,UAAU,GAAG,YAAY,GAAG,MAAM,GAAG,aAAa,CAAC;AACrH,MAAM,WAAW,aAAa;IAAG,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE;AAC5G,gGAAgG;AAChG,MAAM,WAAW,gBAAgB;IAAG,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AACnH,gFAAgF;AAChF,MAAM,WAAW,eAAe;IAAG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE;AACzF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,0EAA0E;IAC1E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC;IACzC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC;CACtC;AACD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,eAAe,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;CAC7B;AACD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAC;CACvC;AACD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AACD,8FAA8F;AAC9F,MAAM,WAAW,cAAc;IAAG,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE;AAC7F,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACjD,QAAQ,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,CAAC;IACzC,QAAQ,CAAC,oBAAoB,EAAE,SAAS,WAAW,EAAE,CAAC;IACtD,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,SAAS,CAAC,EAAE,cAAc,CAAC;IACpC,iFAAiF;IACjF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,qEAAqE;IACrE,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B,wEAAwE;IACxE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AACD,8EAA8E;AAC9E,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;CAC1C;AACD,2GAA2G;AAC3G,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,SAAS;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC5I,QAAQ,CAAC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC/C,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;CAC9B;AACD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,kBAAkB,CAAC,EAAE,gBAAgB,CAAC,uBAAuB,EAAE,oBAAoB,CAAC,CAAC;IAC9F,QAAQ,CAAC,iBAAiB,CAAC,EAAE,gBAAgB,CAAC,sBAAsB,EAAE,mBAAmB,CAAC,CAAC;IAC3F,2EAA2E;IAC3E,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AACD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,YAAY,EAAE,GAAG;IAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,YAAY,CAAA;CAAE,CAAC;AACjI,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,gBAAgB,EAAE,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;IAC5F,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AACD,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG,oBAAoB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,eAAe,GAAG,SAAS,GAAG,aAAa,GAAG,cAAc,CAAC;AAC9L,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACjC,oFAAoF;IACpF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AACD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AACD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,CAAC;IAC1C,QAAQ,CAAC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC/C,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,qGAAqG;IACrG,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"","sourcesContent":["import type { JsonValue, LifecycleControl, Scope } from '@mayura/core';\n\nexport type ContextKind = 'evidence' | 'instruction' | 'hard_constraint' | 'pending_approval' | 'unresolved_blocker' | 'outstanding_task';\nexport type ContextTrust = 'untrusted' | 'reviewed' | 'trusted';\nexport type Sensitivity = 'public' | 'internal' | 'confidential' | 'restricted';\nexport type SourceKind = 'document' | 'conversation' | 'memory' | 'artifact' | 'repository' | 'tool' | 'application';\nexport interface ContextSource { readonly id: string; readonly revision: string; readonly kind: SourceKind }\n/** Original evidence identity; distinct from a memory record's current canonical ID/version. */\nexport interface UpstreamEvidence { readonly sourceId: string; readonly revision: string; readonly sha256: string }\n/** Inclusive start and exclusive end, with null denoting no declared expiry. */\nexport interface ContextValidity { readonly from: string; readonly until: string | null }\nexport interface ContextProvenance {\n readonly reference: string;\n /** Canonical UTC ISO string, compatible with native-memory timestamps. */\n readonly observedAt: string;\n readonly origin: 'observed' | 'inferred';\n readonly confidence: number;\n readonly author?: string;\n readonly upstream?: UpstreamEvidence;\n}\nexport interface ContextCandidate {\n readonly id: string;\n readonly scope: Scope;\n readonly source: ContextSource;\n readonly provenance: ContextProvenance;\n readonly trust: ContextTrust;\n readonly sensitivity: Sensitivity;\n readonly kind: ContextKind;\n readonly priority?: number;\n readonly pinned?: boolean;\n readonly validity?: ContextValidity;\n readonly content: JsonValue;\n}\nexport interface SourceState {\n readonly scope: Scope;\n readonly id: string;\n readonly revision: string;\n readonly status: 'active' | 'deleted';\n}\nexport interface ContextBudget {\n readonly maxBytes: number;\n readonly maxEstimatedTokens: number;\n readonly reservedBytes?: number;\n readonly reservedTokens?: number;\n}\n/** Trusted local deterministic estimator, not a paid model call or a guaranteed tokenizer. */\nexport interface TokenEstimator { readonly id: string; estimate(serialized: string): number }\nexport interface AssembleContextOptions {\n readonly scope: Scope;\n readonly policyVersion: string;\n readonly candidates: readonly ContextCandidate[];\n readonly sources: readonly SourceState[];\n readonly allowedSensitivities: readonly Sensitivity[];\n readonly budget: ContextBudget;\n readonly estimator?: TokenEstimator;\n /** Canonical UTC ISO timestamp; omitted means snapshot the current time once. */\n readonly asOf?: string;\n /** Fail-closed lifecycle hooks around assembly; either can block. */\n readonly hooks?: ContextHooks;\n /** Cancels a pending hook callback; assembly itself performs no I/O. */\n readonly signal?: AbortSignal;\n}\n/** Metadata-only view before selection. Candidate content is not included. */\nexport interface BeforeContextBuildEvent {\n readonly scope: Scope;\n readonly policyVersion: string;\n readonly asOf: string;\n readonly candidateCount: number;\n readonly sourceCount: number;\n readonly budget: Required<ContextBudget>;\n}\n/** Metadata-only view of the finished assembly; selected content is identified by digest, not included. */\nexport interface AfterContextBuildEvent {\n readonly scope: Scope;\n readonly policyVersion: string;\n readonly asOf: string;\n readonly fingerprint: string;\n readonly selected: readonly { readonly id: string; readonly sourceId: string; readonly revision: string; readonly contentDigest: string }[];\n readonly excluded: readonly ContextExclusion[];\n readonly usage: ContextUsage;\n}\nexport interface ContextHooks {\n readonly beforeContextBuild?: LifecycleControl<BeforeContextBuildEvent, 'beforeContextBuild'>;\n readonly afterContextBuild?: LifecycleControl<AfterContextBuildEvent, 'afterContextBuild'>;\n /** Per-callback deadline in milliseconds (default 5000, maximum 30000). */\n readonly timeoutMs?: number;\n}\nexport type ReadonlyJson = string | number | boolean | null | readonly ReadonlyJson[] | { readonly [key: string]: ReadonlyJson };\nexport interface ContextItem extends Omit<ContextCandidate, 'content' | 'pinned' | 'priority'> {\n readonly content: ReadonlyJson;\n readonly priority: number;\n readonly pinned: boolean;\n readonly required: boolean;\n readonly contentDigest: string;\n}\nexport type ExclusionReason = 'scope_mismatch' | 'sensitivity_denied' | 'source_missing' | 'source_deleted' | 'stale_revision' | 'not_yet_valid' | 'expired' | 'byte_budget' | 'token_budget';\nexport interface ContextExclusion {\n readonly position: number;\n readonly reason: ExclusionReason;\n /** Omitted for scope or sensitivity denials; excluded content is never returned. */\n readonly candidateId?: string;\n readonly sourceId?: string;\n readonly revision?: string;\n}\nexport interface ContextUsage {\n readonly bytes: number;\n readonly estimatedTokens: number;\n readonly reservedBytes: number;\n readonly reservedTokens: number;\n readonly maxBytes: number;\n readonly maxEstimatedTokens: number;\n readonly estimatorId: string;\n}\nexport interface ContextAssembly {\n readonly scope: Scope;\n readonly policyVersion: string;\n readonly asOf: string;\n readonly selected: readonly ContextItem[];\n readonly excluded: readonly ContextExclusion[];\n readonly usage: ContextUsage;\n /** Exact canonical JSON payload measured by usage; it does not assign provider message authority. */\n readonly serialized: string;\n readonly fingerprint: string;\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { assembleContext, byteTokenEstimator } from './assemble.js';
|
|
2
|
+
export type { ContextKind, ContextTrust, Sensitivity, SourceKind, ContextSource, UpstreamEvidence, ContextValidity, ContextProvenance, ContextCandidate, SourceState, ContextBudget, TokenEstimator, AssembleContextOptions, ReadonlyJson, ContextItem, ContextExclusion, ExclusionReason, ContextUsage, ContextAssembly, ContextHooks, BeforeContextBuildEvent, AfterContextBuildEvent } from './contracts.js';
|
|
3
|
+
export { createContextCache, type ContextCache, type ContextCacheOptions, type ContextCacheStats, type ContextChangeFeed } from './cache.js';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACpE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,sBAAsB,EAAE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAChZ,OAAO,EAAE,kBAAkB,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAE,kBAAkB,EAA+F,MAAM,YAAY,CAAC","sourcesContent":["export { assembleContext, byteTokenEstimator } from './assemble.js';\nexport type { ContextKind, ContextTrust, Sensitivity, SourceKind, ContextSource, UpstreamEvidence, ContextValidity, ContextProvenance, ContextCandidate, SourceState, ContextBudget, TokenEstimator, AssembleContextOptions, ReadonlyJson, ContextItem, ContextExclusion, ExclusionReason, ContextUsage, ContextAssembly, ContextHooks, BeforeContextBuildEvent, AfterContextBuildEvent } from './contracts.js';\nexport { createContextCache, type ContextCache, type ContextCacheOptions, type ContextCacheStats, type ContextChangeFeed } from './cache.js';\n"]}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { assertPositiveInteger, freezeJson, jsonValue, MayuraError, type JsonValue, type Scope } from '@mayura/core';
|
|
2
|
+
import { evaluateLifecycleControl, snapshotHookOptions } from '@mayura/core/host';
|
|
3
|
+
import type { AssembleContextOptions, ContextAssembly, ContextHooks, ContextCandidate, ContextExclusion, ContextItem, ContextKind, ContextProvenance, ContextSource, ContextTrust, ContextValidity, ExclusionReason, Sensitivity, SourceKind, SourceState, TokenEstimator, UpstreamEvidence } from './contracts.js';
|
|
4
|
+
|
|
5
|
+
const encoder = new TextEncoder();
|
|
6
|
+
const inputBytes = 4_194_304;
|
|
7
|
+
const protectedKinds = new Set<ContextKind>(['hard_constraint', 'pending_approval', 'unresolved_blocker', 'outstanding_task']);
|
|
8
|
+
const kinds = new Set<ContextKind>(['evidence', 'instruction', ...protectedKinds]);
|
|
9
|
+
const sensitivities = new Set<Sensitivity>(['public', 'internal', 'confidential', 'restricted']);
|
|
10
|
+
const trusts = new Set<ContextTrust>(['untrusted', 'reviewed', 'trusted']);
|
|
11
|
+
const sourceKinds = new Set<SourceKind>(['document', 'conversation', 'memory', 'artifact', 'repository', 'tool', 'application']);
|
|
12
|
+
|
|
13
|
+
/** A transparent heuristic; provider framing/tokenization must still be admitted separately. */
|
|
14
|
+
export const byteTokenEstimator: TokenEstimator = Object.freeze({ id: 'utf8-bytes-v1', estimate: (text: string) => encoder.encode(text).length });
|
|
15
|
+
|
|
16
|
+
function invalid(message: string): never { throw new MayuraError('INVALID_INPUT', message); }
|
|
17
|
+
function text(value: unknown, label: string, maximum = 256): string {
|
|
18
|
+
if (typeof value !== 'string' || value.length === 0 || value.length > maximum) return invalid(`${label} must be a bounded nonempty string.`);
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
function object(value: unknown): Record<string, unknown> {
|
|
22
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return invalid('Context metadata must be a plain JSON object.');
|
|
23
|
+
return value as Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
function scopeOf(value: unknown): Scope {
|
|
26
|
+
const scope = object(value);
|
|
27
|
+
return Object.freeze({ principalId: text(scope['principalId'], 'principalId'), projectId: text(scope['projectId'], 'projectId') });
|
|
28
|
+
}
|
|
29
|
+
function sameScope(one: Scope, two: Scope): boolean { return one.principalId === two.principalId && one.projectId === two.projectId; }
|
|
30
|
+
function safeJson(value: unknown, maxBytes = inputBytes): JsonValue {
|
|
31
|
+
try { return freezeJson(jsonValue(value, { maxBytes })); }
|
|
32
|
+
catch { return invalid('Context input must satisfy plain-JSON and input-size limits.'); }
|
|
33
|
+
}
|
|
34
|
+
function canonical(value: JsonValue): string {
|
|
35
|
+
if (value === null || typeof value !== 'object') return JSON.stringify(value);
|
|
36
|
+
if (Array.isArray(value)) return `[${value.map(canonical).join(',')}]`;
|
|
37
|
+
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonical(value[key]!)}`).join(',')}}`;
|
|
38
|
+
}
|
|
39
|
+
async function hash(domain: string, value: string): Promise<string> {
|
|
40
|
+
const bytes = await crypto.subtle.digest('SHA-256', encoder.encode(`${domain}\0${value}`));
|
|
41
|
+
return [...new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
42
|
+
}
|
|
43
|
+
function canonicalTime(value: unknown, label = 'observedAt'): string {
|
|
44
|
+
const timestamp = text(value, label, 32);
|
|
45
|
+
const time = Date.parse(timestamp);
|
|
46
|
+
if (!Number.isFinite(time) || new Date(time).toISOString() !== timestamp) return invalid(`${label} must be a canonical UTC ISO timestamp.`);
|
|
47
|
+
return timestamp;
|
|
48
|
+
}
|
|
49
|
+
function upstreamOf(value: unknown): UpstreamEvidence {
|
|
50
|
+
const supplied = object(value);
|
|
51
|
+
const sha256 = supplied['sha256'];
|
|
52
|
+
if (typeof sha256 !== 'string' || !/^[a-f0-9]{64}$/.test(sha256)) return invalid('Upstream evidence SHA-256 must contain 64 lowercase hexadecimal characters.');
|
|
53
|
+
return Object.freeze({ sourceId: text(supplied['sourceId'], 'upstream.sourceId'), revision: text(supplied['revision'], 'upstream.revision'), sha256 });
|
|
54
|
+
}
|
|
55
|
+
function validityOf(value: unknown): ContextValidity {
|
|
56
|
+
const supplied = object(value);
|
|
57
|
+
const from = canonicalTime(supplied['from'], 'validity.from');
|
|
58
|
+
const until = supplied['until'] === null ? null : canonicalTime(supplied['until'], 'validity.until');
|
|
59
|
+
if (until !== null && Date.parse(until) <= Date.parse(from)) return invalid('Context validity must end after it begins.');
|
|
60
|
+
return Object.freeze({ from, until });
|
|
61
|
+
}
|
|
62
|
+
function readCandidate(value: Record<string, unknown>, scope: Scope): ContextCandidate & { readonly priority: number; readonly pinned: boolean; readonly required: boolean } {
|
|
63
|
+
const sourceInput = object(value['source']);
|
|
64
|
+
const source: ContextSource = Object.freeze({ id: text(sourceInput['id'], 'source.id'), revision: text(sourceInput['revision'], 'source.revision'), kind: sourceInput['kind'] as SourceKind });
|
|
65
|
+
if (!sourceKinds.has(source.kind)) return invalid('Unknown context source kind.');
|
|
66
|
+
const supplied = object(value['provenance']);
|
|
67
|
+
const confidence = supplied['confidence'];
|
|
68
|
+
if (typeof confidence !== 'number' || !Number.isFinite(confidence) || confidence < 0 || confidence > 1) return invalid('Provenance confidence must be between zero and one.');
|
|
69
|
+
const origin = supplied['origin'];
|
|
70
|
+
if (origin !== 'observed' && origin !== 'inferred') return invalid('Unknown provenance origin.');
|
|
71
|
+
const provenance: ContextProvenance = Object.freeze({ reference: text(supplied['reference'], 'provenance.reference', 2_048), observedAt: canonicalTime(supplied['observedAt']), origin, confidence,
|
|
72
|
+
...(supplied['author'] === undefined ? {} : { author: text(supplied['author'], 'provenance.author') }),
|
|
73
|
+
...(supplied['upstream'] === undefined ? {} : { upstream: upstreamOf(supplied['upstream']) }),
|
|
74
|
+
});
|
|
75
|
+
const kind = value['kind'] as ContextKind; const trust = value['trust'] as ContextTrust; const sensitivity = value['sensitivity'] as Sensitivity;
|
|
76
|
+
if (!kinds.has(kind) || !trusts.has(trust) || !sensitivities.has(sensitivity)) return invalid('Unknown context category, trust, or sensitivity.');
|
|
77
|
+
const priority = value['priority'] ?? 0; const pinned = value['pinned'] ?? false;
|
|
78
|
+
if (typeof priority !== 'number' || !Number.isSafeInteger(priority) || Math.abs(priority) > 1_000_000 || typeof pinned !== 'boolean') return invalid('Context priority or pin metadata is invalid.');
|
|
79
|
+
return Object.freeze({ id: text(value['id'], 'candidate.id'), scope, source, provenance, kind, trust, sensitivity, priority, pinned,
|
|
80
|
+
...(value['validity'] === undefined ? {} : { validity: validityOf(value['validity']) }),
|
|
81
|
+
required: pinned || protectedKinds.has(kind), content: safeJson(value['content'], 262_144),
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Select current authorized evidence without silently dropping required continuity items or inventing summaries. */
|
|
86
|
+
export async function assembleContext(options: AssembleContextOptions): Promise<ContextAssembly> {
|
|
87
|
+
// Snapshot all caller-controlled JSON before the first await; later mutations cannot change admission.
|
|
88
|
+
const suppliedAsOf = options.asOf;
|
|
89
|
+
const asOf = canonicalTime(suppliedAsOf === undefined ? new Date().toISOString() : suppliedAsOf, 'asOf');
|
|
90
|
+
const asOfTime = Date.parse(asOf);
|
|
91
|
+
const scope = scopeOf(safeJson(options.scope));
|
|
92
|
+
const policyVersion = text(options.policyVersion, 'policyVersion', 128);
|
|
93
|
+
const rawCandidates = safeJson(options.candidates);
|
|
94
|
+
const rawSources = safeJson(options.sources, 1_048_576);
|
|
95
|
+
if (!Array.isArray(rawCandidates) || rawCandidates.length > 512 || !Array.isArray(rawSources) || rawSources.length > 1_024) return invalid('At most 512 context candidates and 1024 source states are supported per assembly.');
|
|
96
|
+
const allowedInput = safeJson(options.allowedSensitivities, 256);
|
|
97
|
+
if (!Array.isArray(allowedInput) || allowedInput.some((value) => typeof value !== 'string' || !sensitivities.has(value as Sensitivity))) return invalid('An explicit sensitivity allow-list is required.');
|
|
98
|
+
const allowed = new Set(allowedInput as Sensitivity[]);
|
|
99
|
+
const suppliedBudget = object(safeJson(options.budget, 1_024));
|
|
100
|
+
const maxBytes = suppliedBudget['maxBytes'] as number; const maxEstimatedTokens = suppliedBudget['maxEstimatedTokens'] as number;
|
|
101
|
+
assertPositiveInteger(maxBytes, 'maxBytes'); assertPositiveInteger(maxEstimatedTokens, 'maxEstimatedTokens');
|
|
102
|
+
const reservedBytes = suppliedBudget['reservedBytes'] ?? 0; const reservedTokens = suppliedBudget['reservedTokens'] ?? 0;
|
|
103
|
+
if (typeof reservedBytes !== 'number' || !Number.isSafeInteger(reservedBytes) || reservedBytes < 0 || typeof reservedTokens !== 'number' || !Number.isSafeInteger(reservedTokens) || reservedTokens < 0) return invalid('Reserved capacity must be non-negative safe integers.');
|
|
104
|
+
if (reservedBytes > maxBytes || reservedTokens > maxEstimatedTokens) throw new MayuraError('LIMIT_EXCEEDED', 'Reserved capacity exhausts the configured context budget.');
|
|
105
|
+
const estimatorInput = options.estimator ?? byteTokenEstimator;
|
|
106
|
+
const estimatorId = text(estimatorInput.id, 'estimator.id', 128);
|
|
107
|
+
if (typeof estimatorInput.estimate !== 'function') return invalid('A callable local token estimator is required.');
|
|
108
|
+
const estimate = estimatorInput.estimate.bind(estimatorInput);
|
|
109
|
+
const hooks = contextHooks(options.hooks); const signal = options.signal;
|
|
110
|
+
if (signal !== undefined && !(signal instanceof AbortSignal)) return invalid('signal must be an AbortSignal.');
|
|
111
|
+
if (hooks.before) await evaluateLifecycleControl({ stage: 'beforeContextBuild', handler: hooks.before, timeoutMs: hooks.timeoutMs, ...(signal ? { signal } : {}),
|
|
112
|
+
event: { scope: { ...scope }, policyVersion, asOf, candidateCount: rawCandidates.length, sourceCount: rawSources.length,
|
|
113
|
+
budget: { maxBytes, maxEstimatedTokens, reservedBytes, reservedTokens } } });
|
|
114
|
+
const sources = new Map<string, SourceState>();
|
|
115
|
+
for (const raw of rawSources) {
|
|
116
|
+
const value = object(raw); const sourceScope = scopeOf(value['scope']);
|
|
117
|
+
if (!sameScope(sourceScope, scope)) continue;
|
|
118
|
+
const id = text(value['id'], 'source.id'); const revision = text(value['revision'], 'source.revision'); const status = value['status'];
|
|
119
|
+
if (status !== 'active' && status !== 'deleted') return invalid('Unknown current source state.');
|
|
120
|
+
if (sources.has(id)) throw new MayuraError('CONFLICT', 'Current-scope source states must have unique IDs.');
|
|
121
|
+
sources.set(id, Object.freeze({ scope: sourceScope, id, revision, status }));
|
|
122
|
+
}
|
|
123
|
+
const excluded: ContextExclusion[] = [];
|
|
124
|
+
const eligible: { readonly item: ReturnType<typeof readCandidate>; readonly position: number }[] = [];
|
|
125
|
+
const candidateIds = new Set<string>();
|
|
126
|
+
for (const [position, raw] of rawCandidates.entries()) {
|
|
127
|
+
const value = object(raw); const candidateScope = scopeOf(value['scope']);
|
|
128
|
+
if (!sameScope(candidateScope, scope)) { excluded.push(Object.freeze({ position, reason: 'scope_mismatch' })); continue; }
|
|
129
|
+
const candidate = readCandidate(value, candidateScope);
|
|
130
|
+
if (candidateIds.has(candidate.id)) throw new MayuraError('CONFLICT', 'Current-scope context candidates must have unique IDs.');
|
|
131
|
+
candidateIds.add(candidate.id);
|
|
132
|
+
let reason: ExclusionReason | undefined;
|
|
133
|
+
const current = sources.get(candidate.source.id);
|
|
134
|
+
if (!allowed.has(candidate.sensitivity)) reason = 'sensitivity_denied';
|
|
135
|
+
else if (!current) reason = 'source_missing';
|
|
136
|
+
else if (current.status === 'deleted') reason = 'source_deleted';
|
|
137
|
+
else if (current.revision !== candidate.source.revision) reason = 'stale_revision';
|
|
138
|
+
else if (candidate.validity && Date.parse(candidate.validity.from) > asOfTime) reason = 'not_yet_valid';
|
|
139
|
+
else if (candidate.validity?.until !== undefined && candidate.validity.until !== null && Date.parse(candidate.validity.until) <= asOfTime) reason = 'expired';
|
|
140
|
+
if (reason) {
|
|
141
|
+
if (candidate.required) throw new MayuraError(reason === 'sensitivity_denied' ? 'PERMISSION_DENIED' : 'CONFLICT', 'A required continuity item is unavailable, stale, deleted, outside its validity interval, or denied; refresh or resolve it explicitly.');
|
|
142
|
+
excluded.push(Object.freeze({ position, reason, ...(reason === 'sensitivity_denied' ? {} : { candidateId: candidate.id, sourceId: candidate.source.id, revision: candidate.source.revision }) }));
|
|
143
|
+
} else eligible.push({ item: candidate, position });
|
|
144
|
+
}
|
|
145
|
+
eligible.sort((left, right) => {
|
|
146
|
+
const one = left.item; const two = right.item;
|
|
147
|
+
if (one.required !== two.required) return one.required ? -1 : 1;
|
|
148
|
+
if (one.priority !== two.priority) return two.priority - one.priority;
|
|
149
|
+
if (one.provenance.observedAt !== two.provenance.observedAt) return Date.parse(one.provenance.observedAt) > Date.parse(two.provenance.observedAt) ? -1 : 1;
|
|
150
|
+
return one.id < two.id ? -1 : one.id > two.id ? 1 : 0;
|
|
151
|
+
});
|
|
152
|
+
const candidates = await Promise.all(eligible.map(async ({ item, position }) => ({ position, item: Object.freeze({ ...item, contentDigest: await hash('mayura:context-content:v1', canonical(item.content)) }) as ContextItem })));
|
|
153
|
+
const encode = (items: readonly ContextItem[]): string => canonical(jsonValue({ format: 1, scope, policyVersion, asOf, items }, { maxBytes: 8_388_608 }));
|
|
154
|
+
const measure = (items: readonly ContextItem[]) => {
|
|
155
|
+
const serialized = encode(items); const bytes = encoder.encode(serialized).length;
|
|
156
|
+
let estimatedTokens: number;
|
|
157
|
+
try { estimatedTokens = estimate(serialized); }
|
|
158
|
+
catch { throw new MayuraError('INVALID_CONFIG', 'The token estimator failed; raw exception details are withheld.'); }
|
|
159
|
+
if (!Number.isSafeInteger(estimatedTokens) || estimatedTokens < 0) throw new MayuraError('INVALID_CONFIG', 'The token estimator must return a non-negative safe integer.');
|
|
160
|
+
const reason = bytes > maxBytes - reservedBytes ? 'byte_budget' as const : estimatedTokens > maxEstimatedTokens - reservedTokens ? 'token_budget' as const : undefined;
|
|
161
|
+
return { serialized, bytes, estimatedTokens, reason };
|
|
162
|
+
};
|
|
163
|
+
const selected = candidates.filter(({ item }) => item.required).map(({ item }) => item);
|
|
164
|
+
let measured = measure(selected);
|
|
165
|
+
if (measured.reason) throw new MayuraError('LIMIT_EXCEEDED', 'Required continuity items and context framing do not fit the reserved context budget.');
|
|
166
|
+
for (const candidate of candidates) {
|
|
167
|
+
if (candidate.item.required) continue;
|
|
168
|
+
const next = measure([...selected, candidate.item]);
|
|
169
|
+
if (next.reason) excluded.push(Object.freeze({ position: candidate.position, reason: next.reason,
|
|
170
|
+
candidateId: candidate.item.id, sourceId: candidate.item.source.id, revision: candidate.item.source.revision,
|
|
171
|
+
}));
|
|
172
|
+
else { selected.push(candidate.item); measured = next; }
|
|
173
|
+
}
|
|
174
|
+
excluded.sort((one, two) => one.position - two.position);
|
|
175
|
+
const budget = { maxBytes, maxEstimatedTokens, reservedBytes, reservedTokens };
|
|
176
|
+
const fingerprint = await hash('mayura:context-assembly:v1', canonical(jsonValue({ serialized: measured.serialized, budget, estimatorId, allowedSensitivities: [...allowed].sort() }, { maxBytes: 16_777_216 })));
|
|
177
|
+
const assembly: ContextAssembly = Object.freeze({ scope, policyVersion, asOf, selected: Object.freeze(selected), excluded: Object.freeze(excluded), serialized: measured.serialized, fingerprint,
|
|
178
|
+
usage: Object.freeze({ bytes: measured.bytes, estimatedTokens: measured.estimatedTokens, reservedBytes, reservedTokens, maxBytes, maxEstimatedTokens, estimatorId }),
|
|
179
|
+
});
|
|
180
|
+
if (hooks.after) await evaluateLifecycleControl({ stage: 'afterContextBuild', handler: hooks.after, timeoutMs: hooks.timeoutMs, ...(signal ? { signal } : {}),
|
|
181
|
+
event: { scope: { ...scope }, policyVersion, asOf, fingerprint,
|
|
182
|
+
selected: selected.map(item => ({ id: item.id, sourceId: item.source.id, revision: item.source.revision, contentDigest: item.contentDigest })),
|
|
183
|
+
excluded: excluded.map(entry => ({ ...entry })), usage: { ...assembly.usage } } });
|
|
184
|
+
return assembly;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Read hook options once, as own data properties, before the first await. */
|
|
188
|
+
function contextHooks(value: ContextHooks | undefined): { readonly before?: NonNullable<ContextHooks['beforeContextBuild']>; readonly after?: NonNullable<ContextHooks['afterContextBuild']>; readonly timeoutMs: number } {
|
|
189
|
+
const { handlers, timeoutMs } = snapshotHookOptions(value, ['beforeContextBuild', 'afterContextBuild'] as const,
|
|
190
|
+
'Context hooks require callable beforeContextBuild/afterContextBuild handlers and a bounded timeout.');
|
|
191
|
+
return { ...(handlers.beforeContextBuild ? { before: handlers.beforeContextBuild as NonNullable<ContextHooks['beforeContextBuild']> } : {}),
|
|
192
|
+
...(handlers.afterContextBuild ? { after: handlers.afterContextBuild as NonNullable<ContextHooks['afterContextBuild']> } : {}), timeoutMs };
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Internal cache key: a digest of every admission input except hooks and signals, which a cache re-runs.
|
|
197
|
+
* Any change to candidates, source revisions, scope, policy, time, sensitivity profile, budget or estimator changes it.
|
|
198
|
+
*/
|
|
199
|
+
export async function admissionKey(options: AssembleContextOptions, asOf: string): Promise<string> {
|
|
200
|
+
const material = safeJson({ scope: options.scope as unknown as JsonValue, policyVersion: options.policyVersion, asOf,
|
|
201
|
+
candidates: options.candidates as unknown as JsonValue, sources: options.sources as unknown as JsonValue,
|
|
202
|
+
allowedSensitivities: options.allowedSensitivities as unknown as JsonValue, budget: options.budget as unknown as JsonValue,
|
|
203
|
+
estimatorId: (options.estimator ?? byteTokenEstimator).id });
|
|
204
|
+
return hash('mayura:context-admission:v1', canonical(material));
|
|
205
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { MayuraError, type Scope } from '@mayura/core';
|
|
2
|
+
import { evaluateLifecycleControl, snapshotHookOptions } from '@mayura/core/host';
|
|
3
|
+
import { admissionKey, assembleContext } from './assemble.js';
|
|
4
|
+
import type { AssembleContextOptions, ContextAssembly, ContextHooks } from './contracts.js';
|
|
5
|
+
|
|
6
|
+
export interface ContextCacheOptions {
|
|
7
|
+
/** Default 256, maximum 10,000 entries; least recently used entries are evicted. */
|
|
8
|
+
readonly maxEntries?: number;
|
|
9
|
+
/** Default 5 minutes, maximum 24 hours. */
|
|
10
|
+
readonly ttlMs?: number;
|
|
11
|
+
/** Granularity used for `asOf` when a caller omits it (default 1000 ms), so repeated calls can share an entry. */
|
|
12
|
+
readonly asOfResolutionMs?: number;
|
|
13
|
+
/** Background prefetch concurrency (default 2, maximum 8). */
|
|
14
|
+
readonly maxPrefetch?: number;
|
|
15
|
+
readonly now?: () => number;
|
|
16
|
+
}
|
|
17
|
+
/** Any source of content-free change events, such as native memory's `changes`. */
|
|
18
|
+
export interface ContextChangeFeed { changes(options: { readonly after?: number; readonly limit?: number }): Promise<readonly { readonly sequence: number; readonly id: string }[]> }
|
|
19
|
+
export interface ContextCacheStats { readonly entries: number; readonly hits: number; readonly misses: number; readonly invalidated: number; readonly prefetched: number }
|
|
20
|
+
export interface ContextCache {
|
|
21
|
+
/** Same contract as `assembleContext`; a hit returns the stored assembly after re-running any hooks. */
|
|
22
|
+
assemble(options: AssembleContextOptions): Promise<ContextAssembly>;
|
|
23
|
+
/** Start a bounded background assembly; it is used only by a later `assemble` with an identical admission key. */
|
|
24
|
+
prefetch(options: AssembleContextOptions): void;
|
|
25
|
+
/** Drop entries for a scope and/or entries that include any of the given sources. Returns the number removed. */
|
|
26
|
+
invalidate(filter: { readonly scope?: Scope; readonly sourceIds?: readonly string[] }): number;
|
|
27
|
+
/** Consume a change feed from the last cursor and invalidate entries that include a changed source. */
|
|
28
|
+
follow(feed: ContextChangeFeed, options?: { readonly sourceIdFor?: (id: string) => string }): Promise<number>;
|
|
29
|
+
clear(): void;
|
|
30
|
+
stats(): ContextCacheStats;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface Entry { readonly assembly: ContextAssembly; readonly sources: ReadonlySet<string>; readonly scope: string; readonly expiresAt: number }
|
|
34
|
+
|
|
35
|
+
function bounded(value: unknown, fallback: number, minimum: number, maximum: number, label: string): number {
|
|
36
|
+
const result = value === undefined ? fallback : value;
|
|
37
|
+
if (typeof result !== 'number' || !Number.isSafeInteger(result) || result < minimum || result > maximum) throw new MayuraError('INVALID_CONFIG', `${label} must be an integer from ${minimum} to ${maximum}.`);
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
const scopeText = (scope: Scope): string => JSON.stringify([scope.principalId, scope.projectId]);
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A cache of assemblies, never of generated answers or approvals. Keys cover every admission input, so any changed
|
|
44
|
+
* source revision misses; `invalidate` and `follow` handle deletion, revocation and permission changes.
|
|
45
|
+
*/
|
|
46
|
+
export function createContextCache(options: ContextCacheOptions = {}): ContextCache {
|
|
47
|
+
const maxEntries = bounded(options.maxEntries, 256, 1, 10_000, 'maxEntries');
|
|
48
|
+
const ttlMs = bounded(options.ttlMs, 300_000, 1, 86_400_000, 'ttlMs');
|
|
49
|
+
const resolution = bounded(options.asOfResolutionMs, 1_000, 1, 3_600_000, 'asOfResolutionMs');
|
|
50
|
+
const maxPrefetch = bounded(options.maxPrefetch, 2, 1, 8, 'maxPrefetch');
|
|
51
|
+
const now = (): number => { const value = (options.now ?? Date.now)(); if (!Number.isSafeInteger(value) || value < 0) throw new MayuraError('INVALID_CONFIG', 'Cache clock returned an invalid time.'); return value; };
|
|
52
|
+
const entries = new Map<string, Entry>(); const pending = new Map<string, Promise<ContextAssembly>>();
|
|
53
|
+
let hits = 0; let misses = 0; let invalidated = 0; let prefetched = 0; let cursor = 0; let generation = 0;
|
|
54
|
+
|
|
55
|
+
const prepare = async (input: AssembleContextOptions): Promise<{ key: string; request: AssembleContextOptions }> => {
|
|
56
|
+
const asOf = input.asOf ?? new Date(Math.floor(now() / resolution) * resolution).toISOString();
|
|
57
|
+
const request = { ...input, asOf };
|
|
58
|
+
return { key: await admissionKey(request, asOf), request };
|
|
59
|
+
};
|
|
60
|
+
const store = (key: string, assembly: ContextAssembly, request: AssembleContextOptions, admittedGeneration: number): void => {
|
|
61
|
+
// An invalidation that raced this assembly wins: the result is returned but not cached.
|
|
62
|
+
if (admittedGeneration !== generation) return;
|
|
63
|
+
const sources = new Set([...assembly.selected.map(item => item.source.id), ...request.sources.map(source => source.id)]);
|
|
64
|
+
entries.delete(key); entries.set(key, { assembly, sources, scope: scopeText(assembly.scope), expiresAt: now() + ttlMs });
|
|
65
|
+
while (entries.size > maxEntries) entries.delete(entries.keys().next().value!);
|
|
66
|
+
};
|
|
67
|
+
const compute = (key: string, request: AssembleContextOptions, started: number): Promise<ContextAssembly> => {
|
|
68
|
+
const existing = pending.get(key); if (existing) return existing;
|
|
69
|
+
// Hooks run on the returned path, not inside the shared computation.
|
|
70
|
+
const { hooks: _hooks, signal: _signal, ...plain } = request; void _hooks; void _signal;
|
|
71
|
+
const promise = assembleContext(plain).then(assembly => { store(key, assembly, request, started); return assembly; })
|
|
72
|
+
.finally(() => pending.delete(key));
|
|
73
|
+
pending.set(key, promise); return promise;
|
|
74
|
+
};
|
|
75
|
+
/** Cached assemblies are re-admitted: hooks see the same views an uncached assembly would produce. */
|
|
76
|
+
const admit = async (assembly: ContextAssembly, request: AssembleContextOptions): Promise<ContextAssembly> => {
|
|
77
|
+
const { handlers, timeoutMs } = snapshotHookOptions(request.hooks, ['beforeContextBuild', 'afterContextBuild'] as const,
|
|
78
|
+
'Context hooks require callable beforeContextBuild/afterContextBuild handlers and a bounded timeout.');
|
|
79
|
+
const signal = request.signal;
|
|
80
|
+
const budget = { reservedBytes: 0, reservedTokens: 0, ...request.budget };
|
|
81
|
+
if (handlers.beforeContextBuild) await evaluateLifecycleControl({ stage: 'beforeContextBuild', handler: handlers.beforeContextBuild as NonNullable<ContextHooks['beforeContextBuild']>, timeoutMs, ...(signal ? { signal } : {}),
|
|
82
|
+
event: { scope: { ...assembly.scope }, policyVersion: assembly.policyVersion, asOf: assembly.asOf, candidateCount: request.candidates.length, sourceCount: request.sources.length,
|
|
83
|
+
budget: { maxBytes: budget.maxBytes, maxEstimatedTokens: budget.maxEstimatedTokens, reservedBytes: budget.reservedBytes, reservedTokens: budget.reservedTokens } } });
|
|
84
|
+
if (handlers.afterContextBuild) await evaluateLifecycleControl({ stage: 'afterContextBuild', handler: handlers.afterContextBuild as NonNullable<ContextHooks['afterContextBuild']>, timeoutMs, ...(signal ? { signal } : {}),
|
|
85
|
+
event: { scope: { ...assembly.scope }, policyVersion: assembly.policyVersion, asOf: assembly.asOf, fingerprint: assembly.fingerprint,
|
|
86
|
+
selected: assembly.selected.map(item => ({ id: item.id, sourceId: item.source.id, revision: item.source.revision, contentDigest: item.contentDigest })),
|
|
87
|
+
excluded: assembly.excluded.map(entry => ({ ...entry })), usage: { ...assembly.usage } } });
|
|
88
|
+
return assembly;
|
|
89
|
+
};
|
|
90
|
+
const drop = (predicate: (entry: Entry) => boolean): number => {
|
|
91
|
+
let removed = 0; generation++;
|
|
92
|
+
for (const [key, entry] of entries) if (predicate(entry)) { entries.delete(key); removed++; }
|
|
93
|
+
invalidated += removed; return removed;
|
|
94
|
+
};
|
|
95
|
+
let running = 0; const queue: AssembleContextOptions[] = [];
|
|
96
|
+
const pump = (): void => {
|
|
97
|
+
while (running < maxPrefetch && queue.length > 0) {
|
|
98
|
+
const next = queue.shift()!; running++; const started = generation;
|
|
99
|
+
void prepare(next).then(({ key, request }) => entries.has(key) ? undefined : compute(key, request, started).then(() => { prefetched++; }))
|
|
100
|
+
.catch(() => { /* A failed prefetch is simply not cached; the foreground call reports its own error. */ })
|
|
101
|
+
.finally(() => { running--; pump(); });
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
return Object.freeze<ContextCache>({
|
|
106
|
+
async assemble(input) {
|
|
107
|
+
// Captured before any await: an invalidation at any point during this call prevents caching its result.
|
|
108
|
+
const started = generation;
|
|
109
|
+
const { key, request } = await prepare(input);
|
|
110
|
+
const entry = entries.get(key);
|
|
111
|
+
if (entry && entry.expiresAt > now()) {
|
|
112
|
+
hits++; entries.delete(key); entries.set(key, entry);
|
|
113
|
+
return admit(entry.assembly, request);
|
|
114
|
+
}
|
|
115
|
+
if (entry) entries.delete(key);
|
|
116
|
+
misses++;
|
|
117
|
+
return admit(await compute(key, request, started), request);
|
|
118
|
+
},
|
|
119
|
+
prefetch(input) {
|
|
120
|
+
if (queue.length >= 64) return;
|
|
121
|
+
queue.push(input); pump();
|
|
122
|
+
},
|
|
123
|
+
invalidate(filter) {
|
|
124
|
+
if (!filter || typeof filter !== 'object') throw new MayuraError('INVALID_INPUT', 'An invalidation filter is required.');
|
|
125
|
+
const scope = filter.scope ? scopeText(filter.scope) : undefined; const sources = filter.sourceIds ? new Set(filter.sourceIds) : undefined;
|
|
126
|
+
if (scope === undefined && sources === undefined) throw new MayuraError('INVALID_INPUT', 'Invalidate by scope and/or source ids; use clear() to drop everything.');
|
|
127
|
+
return drop(entry => (scope === undefined || entry.scope === scope) && (sources === undefined || [...entry.sources].some(id => sources.has(id))));
|
|
128
|
+
},
|
|
129
|
+
async follow(feed, followOptions = {}) {
|
|
130
|
+
const map = followOptions.sourceIdFor ?? ((id: string) => id); let removed = 0;
|
|
131
|
+
for (;;) {
|
|
132
|
+
const page = await feed.changes({ after: cursor, limit: 1_000 });
|
|
133
|
+
if (page.length === 0) return removed;
|
|
134
|
+
const changed = new Set(page.map(change => map(change.id)));
|
|
135
|
+
removed += drop(entry => [...entry.sources].some(id => changed.has(id)));
|
|
136
|
+
cursor = page.at(-1)!.sequence;
|
|
137
|
+
if (page.length < 1_000) return removed;
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
clear() { drop(() => true); },
|
|
141
|
+
stats: () => Object.freeze({ entries: entries.size, hits, misses, invalidated, prefetched }),
|
|
142
|
+
});
|
|
143
|
+
}
|