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,215 @@
|
|
|
1
|
+
import { ClientError, type MayuraClient, type RemoteHumanRequest } from './index.js';
|
|
2
|
+
|
|
3
|
+
export interface HumanTextField {
|
|
4
|
+
readonly kind: 'text' | 'textarea'; readonly name: string; readonly label: string; readonly required?: boolean;
|
|
5
|
+
readonly minLength?: number; readonly maxLength?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface HumanNumberField {
|
|
8
|
+
readonly kind: 'number' | 'integer'; readonly name: string; readonly label: string; readonly required?: boolean;
|
|
9
|
+
readonly minimum?: number; readonly maximum?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface HumanBooleanField { readonly kind: 'boolean'; readonly name: string; readonly label: string; readonly required?: boolean }
|
|
12
|
+
export interface HumanSelectOption { readonly value: string; readonly label: string }
|
|
13
|
+
export interface HumanSelectField {
|
|
14
|
+
readonly kind: 'select'; readonly name: string; readonly label: string; readonly required?: boolean;
|
|
15
|
+
readonly options: readonly HumanSelectOption[];
|
|
16
|
+
}
|
|
17
|
+
export type HumanResponseField = HumanTextField | HumanNumberField | HumanBooleanField | HumanSelectField;
|
|
18
|
+
export interface HumanResponseFormDefinition {
|
|
19
|
+
readonly schemaId: string; readonly schemaDigest: string; readonly fields: readonly HumanResponseField[];
|
|
20
|
+
}
|
|
21
|
+
export type HumanResponseDraft = Readonly<Record<string, string | boolean>>;
|
|
22
|
+
export interface HumanResponseSubmission {
|
|
23
|
+
readonly id: string; readonly digest: string; readonly value: Readonly<Record<string, string | number | boolean>>;
|
|
24
|
+
}
|
|
25
|
+
export type HumanResponseCommandStatus = 'idle' | 'submitting' | 'succeeded' | 'conflict' | 'failed' | 'disposed';
|
|
26
|
+
export interface HumanResponseCommandState {
|
|
27
|
+
readonly revision: number; readonly status: HumanResponseCommandStatus; readonly requestId: string; readonly requestDigest: string;
|
|
28
|
+
readonly responseStatus: RemoteHumanRequest['status'] | null; readonly errorCode: string | null;
|
|
29
|
+
}
|
|
30
|
+
export interface HumanResponseControllerOptions {
|
|
31
|
+
readonly client: Pick<MayuraClient, 'respondHumanRequest'>; readonly request: RemoteHumanRequest; readonly maxSubscribers?: number;
|
|
32
|
+
}
|
|
33
|
+
export interface HumanResponseController {
|
|
34
|
+
getSnapshot(): HumanResponseCommandState;
|
|
35
|
+
subscribe(listener: () => void): () => void;
|
|
36
|
+
submit(submission: HumanResponseSubmission, options: { readonly commandId: string; readonly signal?: AbortSignal }): Promise<RemoteHumanRequest>;
|
|
37
|
+
reset(): HumanResponseCommandState;
|
|
38
|
+
dispose(): void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const idPattern = /^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/;
|
|
42
|
+
const fieldPattern = /^[A-Za-z][A-Za-z0-9._-]{0,63}$/;
|
|
43
|
+
const forbidden = new Set(['__proto__', 'constructor', 'prototype']);
|
|
44
|
+
const definitions = new WeakSet<object>();
|
|
45
|
+
const submissions = new WeakSet<object>();
|
|
46
|
+
const encoder = new TextEncoder();
|
|
47
|
+
function invalid(code = 'INVALID_FORM_CONFIG'): never { throw new ClientError(code); }
|
|
48
|
+
function text(value: unknown, maximum: number): string {
|
|
49
|
+
if (typeof value !== 'string' || value.length < 1 || value.includes('\0') || /[\uD800-\uDFFF]/u.test(value) || encoder.encode(value).byteLength > maximum) return invalid();
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
function own(value: unknown, allowed: readonly string[], required: readonly string[]): Record<string, PropertyDescriptor> {
|
|
53
|
+
if (!value || typeof value !== 'object' || Array.isArray(value) || ![null, Object.prototype].includes(Object.getPrototypeOf(value))) return invalid();
|
|
54
|
+
const descriptors = Object.getOwnPropertyDescriptors(value); const keys = Reflect.ownKeys(descriptors);
|
|
55
|
+
if (keys.some(key => typeof key !== 'string' || !allowed.includes(key) || !('value' in descriptors[key]!)) || required.some(key => !descriptors[key])) return invalid();
|
|
56
|
+
return descriptors;
|
|
57
|
+
}
|
|
58
|
+
function integer(value: unknown, minimum: number, maximum: number): number {
|
|
59
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < minimum || value > maximum) return invalid(); return value;
|
|
60
|
+
}
|
|
61
|
+
function finite(value: unknown): number { if (typeof value !== 'number' || !Number.isFinite(value)) return invalid(); return value; }
|
|
62
|
+
function validRequest(request: unknown): request is RemoteHumanRequest {
|
|
63
|
+
if (!request || typeof request !== 'object' || !Object.isFrozen(request) || Array.isArray(request)
|
|
64
|
+
|| ![null, Object.prototype].includes(Object.getPrototypeOf(request))) return false;
|
|
65
|
+
const descriptors = Object.getOwnPropertyDescriptors(request); const allowed = ['id', 'agentId', 'kind', 'schemaId', 'schemaDigest', 'prompt', 'digest', 'status', 'context', 'subjectDigest', 'deadlineAtMs'];
|
|
66
|
+
const keys = Reflect.ownKeys(descriptors);
|
|
67
|
+
if (keys.some(key => typeof key !== 'string' || !allowed.includes(key) || !('value' in descriptors[key]!))
|
|
68
|
+
|| ['id', 'agentId', 'kind', 'schemaId', 'schemaDigest', 'prompt', 'digest', 'status'].some(key => !descriptors[key])) return false;
|
|
69
|
+
const value = Object.fromEntries(Object.entries(descriptors).map(([key, descriptor]) => [key, descriptor.value])) as Record<string, unknown>;
|
|
70
|
+
return typeof value['id'] === 'string' && /^[A-Za-z0-9][A-Za-z0-9._-]{0,79}$/.test(value['id'])
|
|
71
|
+
&& typeof value['agentId'] === 'string' && idPattern.test(value['agentId']) && typeof value['schemaId'] === 'string' && idPattern.test(value['schemaId'])
|
|
72
|
+
&& typeof value['schemaDigest'] === 'string' && /^[a-f0-9]{64}$/.test(value['schemaDigest']) && typeof value['digest'] === 'string' && /^[a-f0-9]{64}$/.test(value['digest'])
|
|
73
|
+
&& typeof value['prompt'] === 'string' && encoder.encode(value['prompt']).byteLength >= 1 && encoder.encode(value['prompt']).byteLength <= 1_024
|
|
74
|
+
&& ['information', 'correction', 'plan_selection'].includes(String(value['kind'])) && ['waiting', 'answered', 'cancelled', 'timed_out'].includes(String(value['status']))
|
|
75
|
+
&& (value['subjectDigest'] === undefined || (typeof value['subjectDigest'] === 'string' && /^[a-f0-9]{64}$/.test(value['subjectDigest'])))
|
|
76
|
+
&& ((value['kind'] === 'correction') === (value['subjectDigest'] !== undefined))
|
|
77
|
+
&& (value['deadlineAtMs'] === undefined || (Number.isSafeInteger(value['deadlineAtMs']) && (value['deadlineAtMs'] as number) >= 0));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Capture an ergonomic finite field declaration as a deeply immutable, schema-bound form definition. */
|
|
81
|
+
export function defineHumanResponseForm(input: HumanResponseFormDefinition): HumanResponseFormDefinition {
|
|
82
|
+
const root = own(input, ['schemaId', 'schemaDigest', 'fields'], ['schemaId', 'schemaDigest', 'fields']);
|
|
83
|
+
const schemaId = root['schemaId']!.value; const schemaDigest = root['schemaDigest']!.value; const supplied = root['fields']!.value;
|
|
84
|
+
if (typeof schemaId !== 'string' || !idPattern.test(schemaId) || typeof schemaDigest !== 'string' || !/^[a-f0-9]{64}$/.test(schemaDigest)
|
|
85
|
+
|| !Array.isArray(supplied) || supplied.length < 1 || supplied.length > 32) return invalid();
|
|
86
|
+
const names = new Set<string>(); const fields: HumanResponseField[] = [];
|
|
87
|
+
for (const raw of supplied) {
|
|
88
|
+
const common = own(raw, ['kind', 'name', 'label', 'required', 'minLength', 'maxLength', 'minimum', 'maximum', 'options'], ['kind', 'name', 'label']);
|
|
89
|
+
const kind = common['kind']!.value; const name = common['name']!.value; const label = text(common['label']!.value, 256); const required = common['required']?.value ?? false;
|
|
90
|
+
if (!['text', 'textarea', 'number', 'integer', 'boolean', 'select'].includes(String(kind)) || typeof name !== 'string' || !fieldPattern.test(name)
|
|
91
|
+
|| forbidden.has(name) || names.has(name) || typeof required !== 'boolean') return invalid(); names.add(name);
|
|
92
|
+
if (kind === 'text' || kind === 'textarea') {
|
|
93
|
+
if (common['minimum'] || common['maximum'] || common['options']) return invalid();
|
|
94
|
+
const minLength = common['minLength'] ? integer(common['minLength'].value, 0, 16_384) : 0;
|
|
95
|
+
const maxLength = common['maxLength'] ? integer(common['maxLength'].value, 1, 16_384) : 4_096;
|
|
96
|
+
if (minLength > maxLength || (required && maxLength < 1)) return invalid();
|
|
97
|
+
fields.push(Object.freeze({ kind, name, label, required, minLength, maxLength })); continue;
|
|
98
|
+
}
|
|
99
|
+
if (kind === 'number' || kind === 'integer') {
|
|
100
|
+
if (common['minLength'] || common['maxLength'] || common['options']) return invalid();
|
|
101
|
+
const minimum = common['minimum'] ? finite(common['minimum'].value) : -Number.MAX_SAFE_INTEGER;
|
|
102
|
+
const maximum = common['maximum'] ? finite(common['maximum'].value) : Number.MAX_SAFE_INTEGER;
|
|
103
|
+
if (minimum > maximum || (kind === 'integer' && (!Number.isSafeInteger(minimum) || !Number.isSafeInteger(maximum)))) return invalid();
|
|
104
|
+
fields.push(Object.freeze({ kind, name, label, required, minimum, maximum })); continue;
|
|
105
|
+
}
|
|
106
|
+
if (kind === 'boolean') {
|
|
107
|
+
if (common['minLength'] || common['maxLength'] || common['minimum'] || common['maximum'] || common['options']) return invalid();
|
|
108
|
+
fields.push(Object.freeze({ kind, name, label, required })); continue;
|
|
109
|
+
}
|
|
110
|
+
if (common['minLength'] || common['maxLength'] || common['minimum'] || common['maximum']) return invalid();
|
|
111
|
+
const options = common['options']?.value;
|
|
112
|
+
if (!Array.isArray(options) || options.length < 1 || options.length > 64) return invalid(); const values = new Set<string>();
|
|
113
|
+
const captured = options.map(option => { const item = own(option, ['value', 'label'], ['value', 'label']); const value = item['value']!.value;
|
|
114
|
+
if (typeof value !== 'string' || !fieldPattern.test(value) || forbidden.has(value) || values.has(value)) return invalid(); values.add(value);
|
|
115
|
+
return Object.freeze({ value, label: text(item['label']!.value, 256) }); });
|
|
116
|
+
fields.push(Object.freeze({ kind: 'select', name, label, required, options: Object.freeze(captured) }));
|
|
117
|
+
}
|
|
118
|
+
const definition = Object.freeze({ schemaId, schemaDigest, fields: Object.freeze(fields) }); definitions.add(definition); return definition;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Validate a UI draft and bind the typed value to one exact authenticated request/digest. */
|
|
122
|
+
export function validateHumanResponse(request: RemoteHumanRequest, definition: HumanResponseFormDefinition, draft: HumanResponseDraft): HumanResponseSubmission {
|
|
123
|
+
if (!validRequest(request) || !definitions.has(definition) || request.schemaId !== definition.schemaId || request.schemaDigest !== definition.schemaDigest
|
|
124
|
+
|| request.status !== 'waiting' || !draft || typeof draft !== 'object' || Array.isArray(draft) || ![null, Object.prototype].includes(Object.getPrototypeOf(draft))
|
|
125
|
+
|| !Object.isFrozen(draft)) return invalid('INVALID_FORM_VALUE');
|
|
126
|
+
const descriptors = Object.getOwnPropertyDescriptors(draft); const keys = Reflect.ownKeys(descriptors);
|
|
127
|
+
if (keys.some(key => typeof key !== 'string' || forbidden.has(key) || !('value' in descriptors[key]!)) || keys.length > definition.fields.length) return invalid('INVALID_FORM_VALUE');
|
|
128
|
+
const fields = new Map(definition.fields.map(field => [field.name, field])); if (keys.some(key => !fields.has(key as string))) return invalid('INVALID_FORM_VALUE');
|
|
129
|
+
const result: Record<string, string | number | boolean> = Object.create(null) as Record<string, string | number | boolean>;
|
|
130
|
+
for (const field of definition.fields) {
|
|
131
|
+
const supplied = descriptors[field.name]?.value;
|
|
132
|
+
if (field.kind === 'boolean') { if (supplied === undefined && !field.required) continue; if (typeof supplied !== 'boolean') return invalid('INVALID_FORM_VALUE'); result[field.name] = supplied; continue; }
|
|
133
|
+
if (supplied === undefined || supplied === '') { if (field.required) return invalid('INVALID_FORM_VALUE'); continue; }
|
|
134
|
+
if (typeof supplied !== 'string' || supplied.includes('\0') || /[\uD800-\uDFFF]/u.test(supplied)) return invalid('INVALID_FORM_VALUE');
|
|
135
|
+
if (field.kind === 'text' || field.kind === 'textarea') {
|
|
136
|
+
const length = [...supplied].length;
|
|
137
|
+
if (length < (field.minLength ?? 0) || length > (field.maxLength ?? 4_096) || encoder.encode(supplied).byteLength > 65_536) return invalid('INVALID_FORM_VALUE');
|
|
138
|
+
result[field.name] = supplied; continue;
|
|
139
|
+
}
|
|
140
|
+
if (field.kind === 'select') { if (!field.options.some(option => option.value === supplied)) return invalid('INVALID_FORM_VALUE'); result[field.name] = supplied; continue; }
|
|
141
|
+
if (field.kind !== 'number' && field.kind !== 'integer') return invalid('INVALID_FORM_VALUE');
|
|
142
|
+
if (supplied.length > 128 || !/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/.test(supplied)) return invalid('INVALID_FORM_VALUE'); const value = Number(supplied);
|
|
143
|
+
if (!Number.isFinite(value) || value < (field.minimum ?? -Number.MAX_SAFE_INTEGER) || value > (field.maximum ?? Number.MAX_SAFE_INTEGER)
|
|
144
|
+
|| (field.kind === 'integer' && !Number.isSafeInteger(value))) return invalid('INVALID_FORM_VALUE'); result[field.name] = value;
|
|
145
|
+
}
|
|
146
|
+
const submission = Object.freeze({ id: request.id, digest: request.digest, value: Object.freeze(result) }); submissions.add(submission); return submission;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function commandState(state: HumanResponseCommandState): HumanResponseCommandState { return Object.freeze({ ...state }); }
|
|
150
|
+
function safeCommandError(error: unknown): ClientError {
|
|
151
|
+
const allowed = new Set(['ABORTED', 'TRANSPORT_FAILED', 'REDIRECT_DENIED', 'HTTP_ERROR', 'INVALID_RESPONSE', 'INVALID_JSON', 'RESPONSE_LIMIT', 'INVALID_REQUEST',
|
|
152
|
+
'FORM_SUBMISSION_CONFLICT']);
|
|
153
|
+
return error instanceof ClientError && allowed.has(error.code) ? error : new ClientError('FORM_SUBMISSION_FAILED');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Explicit single-flight response command state. It never retries, refreshes or sends work until submit is called. */
|
|
157
|
+
export function createHumanResponseController(options: HumanResponseControllerOptions): HumanResponseController {
|
|
158
|
+
if (!options || !options.client || typeof options.client.respondHumanRequest !== 'function' || !validRequest(options.request) || options.request.status !== 'waiting')
|
|
159
|
+
throw new ClientError('INVALID_FORM_CONTROLLER');
|
|
160
|
+
const maxSubscribers = options.maxSubscribers ?? 64;
|
|
161
|
+
if (!Number.isSafeInteger(maxSubscribers) || maxSubscribers < 1 || maxSubscribers > 256) throw new ClientError('INVALID_FORM_CONTROLLER');
|
|
162
|
+
const client = options.client; const request = options.request; const listeners = new Set<() => void>(); let active: AbortController | null = null; let disposed = false;
|
|
163
|
+
let state = commandState({ revision: 0, status: 'idle', requestId: request.id, requestDigest: request.digest, responseStatus: null, errorCode: null });
|
|
164
|
+
const publish = (change: Omit<Partial<HumanResponseCommandState>, 'revision' | 'requestId' | 'requestDigest'>): HumanResponseCommandState => {
|
|
165
|
+
state = commandState({ ...state, ...change, revision: state.revision + 1 });
|
|
166
|
+
for (const listener of [...listeners]) { try { listener(); } catch { /* Presentation listeners cannot break command accounting. */ } }
|
|
167
|
+
return state;
|
|
168
|
+
};
|
|
169
|
+
return Object.freeze<HumanResponseController>({
|
|
170
|
+
getSnapshot: () => state,
|
|
171
|
+
subscribe: listener => {
|
|
172
|
+
if (disposed) throw new ClientError('FORM_DISPOSED');
|
|
173
|
+
if (typeof listener !== 'function') throw new ClientError('INVALID_FORM_CONTROLLER');
|
|
174
|
+
if (listeners.size >= maxSubscribers) throw new ClientError('FORM_SUBSCRIBER_LIMIT');
|
|
175
|
+
listeners.add(listener); let subscribed = true;
|
|
176
|
+
return () => { if (subscribed) { subscribed = false; listeners.delete(listener); } };
|
|
177
|
+
},
|
|
178
|
+
submit: async (submission, settings) => {
|
|
179
|
+
if (disposed) throw new ClientError('FORM_DISPOSED');
|
|
180
|
+
if (active) throw new ClientError('FORM_BUSY');
|
|
181
|
+
if (!submissions.has(submission) || submission.id !== request.id || submission.digest !== request.digest || !settings
|
|
182
|
+
|| typeof settings.commandId !== 'string' || !idPattern.test(settings.commandId)) throw new ClientError('INVALID_FORM_SUBMISSION');
|
|
183
|
+
const controller = new AbortController(); const abort = (): void => controller.abort(); active = controller;
|
|
184
|
+
settings.signal?.addEventListener('abort', abort, { once: true }); if (settings.signal?.aborted) abort();
|
|
185
|
+
publish({ status: 'submitting', responseStatus: null, errorCode: null });
|
|
186
|
+
try {
|
|
187
|
+
if (controller.signal.aborted) throw new ClientError('ABORTED');
|
|
188
|
+
const response = await client.respondHumanRequest(request.id, request.digest, submission.value, { commandId: settings.commandId, signal: controller.signal });
|
|
189
|
+
if (disposed || controller.signal.aborted) throw new ClientError('ABORTED');
|
|
190
|
+
if (!validRequest(response) || response.id !== request.id || response.agentId !== request.agentId || response.kind !== request.kind
|
|
191
|
+
|| response.schemaId !== request.schemaId || response.schemaDigest !== request.schemaDigest || response.digest !== request.digest || response.status === 'waiting')
|
|
192
|
+
throw new ClientError('INVALID_RESPONSE');
|
|
193
|
+
if (response.status !== 'answered') {
|
|
194
|
+
publish({ status: 'conflict', responseStatus: response.status, errorCode: 'FORM_SUBMISSION_CONFLICT' });
|
|
195
|
+
throw new ClientError('FORM_SUBMISSION_CONFLICT');
|
|
196
|
+
}
|
|
197
|
+
publish({ status: 'succeeded', responseStatus: 'answered', errorCode: null }); return response;
|
|
198
|
+
} catch (error) {
|
|
199
|
+
const safe = safeCommandError(error);
|
|
200
|
+
if (!disposed && state.status !== 'conflict') {
|
|
201
|
+
const conflict = safe.code === 'HTTP_ERROR' && (safe.status === 409 || safe.status === 412);
|
|
202
|
+
publish({ status: conflict ? 'conflict' : 'failed', responseStatus: null, errorCode: conflict ? 'FORM_SUBMISSION_CONFLICT' : safe.code });
|
|
203
|
+
}
|
|
204
|
+
throw safe;
|
|
205
|
+
} finally { settings.signal?.removeEventListener('abort', abort); if (active === controller) active = null; }
|
|
206
|
+
},
|
|
207
|
+
reset: () => {
|
|
208
|
+
if (disposed) throw new ClientError('FORM_DISPOSED'); if (active) throw new ClientError('FORM_BUSY');
|
|
209
|
+
return publish({ status: 'idle', responseStatus: null, errorCode: null });
|
|
210
|
+
},
|
|
211
|
+
dispose: () => {
|
|
212
|
+
if (disposed) return; disposed = true; active?.abort(); publish({ status: 'disposed', responseStatus: null, errorCode: null }); listeners.clear();
|
|
213
|
+
},
|
|
214
|
+
});
|
|
215
|
+
}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { ClientError, type ClientEvent, type RemoteHumanRequest, type RemoteRun, type RemoteSnapshot } from './index.js';
|
|
2
|
+
|
|
3
|
+
export type RunConnection = 'idle' | 'loading' | 'observing' | 'stopped' | 'error' | 'disposed';
|
|
4
|
+
export interface HeadlessRunState {
|
|
5
|
+
readonly revision: number; readonly connection: RunConnection; readonly snapshot: RemoteSnapshot | null;
|
|
6
|
+
readonly events: readonly ClientEvent[]; readonly lastSequence: number; readonly hasGap: boolean;
|
|
7
|
+
readonly activity: { readonly models: number | null; readonly tools: number | null; readonly hooks: number | null };
|
|
8
|
+
readonly errorCode: string | null;
|
|
9
|
+
/**
|
|
10
|
+
* Text streamed so far for the latest model call of an agent that streams its output, or null. Provisional: the
|
|
11
|
+
* run's final output is authoritative. `withheld` means a batch guard stopped the stream; `complete` is false when
|
|
12
|
+
* an event gap or the size bound means some text is missing.
|
|
13
|
+
*/
|
|
14
|
+
readonly streamedOutput: { readonly modelCall: number; readonly text: string; readonly withheld: boolean; readonly complete: boolean } | null;
|
|
15
|
+
}
|
|
16
|
+
export interface HeadlessRunStoreOptions {
|
|
17
|
+
readonly run: RemoteRun; readonly maxEvents?: number; readonly maxSubscribers?: number;
|
|
18
|
+
/** Most streamed characters kept (default 65,536). */
|
|
19
|
+
readonly maxStreamedChars?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface HeadlessRunStore {
|
|
22
|
+
getSnapshot(): HeadlessRunState;
|
|
23
|
+
subscribe(listener: () => void): () => void;
|
|
24
|
+
refresh(options?: { readonly signal?: AbortSignal }): Promise<HeadlessRunState>;
|
|
25
|
+
observe(options?: { readonly signal?: AbortSignal }): Promise<HeadlessRunState>;
|
|
26
|
+
cancel(options?: { readonly signal?: AbortSignal }): Promise<void>;
|
|
27
|
+
dispose(): void;
|
|
28
|
+
}
|
|
29
|
+
export interface HumanRequestView {
|
|
30
|
+
readonly id: string; readonly agentId: string; readonly kind: RemoteHumanRequest['kind']; readonly status: RemoteHumanRequest['status'];
|
|
31
|
+
readonly prompt: string; readonly canRespond: boolean; readonly urgency: 'normal' | 'due_soon' | 'expired' | 'resolved';
|
|
32
|
+
readonly statusText: string; readonly actionText: string | null; readonly deadlineAtMs: number | null;
|
|
33
|
+
}
|
|
34
|
+
export type RunActivityKind = 'run' | 'step' | 'model' | 'tool' | 'hook' | 'delegate';
|
|
35
|
+
export type RunActivityStatus = 'active' | 'completed' | 'failed' | 'blocked' | 'cancelled' | 'outcome_unknown' | 'unknown';
|
|
36
|
+
export interface RunActivityItem {
|
|
37
|
+
readonly id: string; readonly kind: RunActivityKind; readonly label: string; readonly status: RunActivityStatus;
|
|
38
|
+
readonly startedSequence: number | null; readonly completedSequence: number | null;
|
|
39
|
+
readonly startedAt: string | null; readonly completedAt: string | null;
|
|
40
|
+
}
|
|
41
|
+
export interface RunActivityProjection {
|
|
42
|
+
readonly revision: number; readonly complete: boolean; readonly items: readonly RunActivityItem[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const runStatuses = new Set(['running', 'succeeded', 'failed', 'blocked', 'cancelled', 'outcome_unknown']);
|
|
46
|
+
const eventTypes = new Set(['run.started', 'model.started', 'model.completed', 'tool.started', 'tool.completed', 'hook.started', 'hook.completed',
|
|
47
|
+
'step.started', 'step.completed', 'delegate.started', 'delegate.completed', 'run.completed', 'events.gap', 'output.delta', 'output.withheld']);
|
|
48
|
+
type StreamedOutput = HeadlessRunState['streamedOutput'];
|
|
49
|
+
/** Append one streamed event to the provisional output; a new model call starts over. */
|
|
50
|
+
function streamed(current: StreamedOutput, item: ClientEvent, gap: boolean, maxChars: number): StreamedOutput {
|
|
51
|
+
const modelCall = item.metadata['modelCall'] as number;
|
|
52
|
+
const base = current && current.modelCall === modelCall ? current : { modelCall, text: '', withheld: false, complete: true };
|
|
53
|
+
if (item.type === 'output.withheld') return Object.freeze({ ...base, withheld: true });
|
|
54
|
+
const text = base.text + String(item.metadata['text']);
|
|
55
|
+
return Object.freeze({ modelCall, withheld: base.withheld, text: text.slice(0, maxChars), complete: base.complete && !gap && text.length <= maxChars });
|
|
56
|
+
}
|
|
57
|
+
const terminal = new Set(['succeeded', 'failed', 'blocked', 'cancelled', 'outcome_unknown']);
|
|
58
|
+
const remoteErrorCodes = new Set(['ABORTED', 'TRANSPORT_FAILED', 'REDIRECT_DENIED', 'HTTP_ERROR', 'INVALID_RESPONSE', 'INVALID_JSON', 'RESPONSE_LIMIT',
|
|
59
|
+
'INVALID_OUTPUT', 'INVALID_REQUEST', 'INVALID_CURSOR', 'INVALID_IDEMPOTENCY_KEY', 'INVALID_STREAM', 'OBSERVATION_FAILED', 'STREAM_LIMIT', 'TRUNCATED_STREAM',
|
|
60
|
+
'INVALID_VIEW_INPUT']);
|
|
61
|
+
const encoder = new TextEncoder();
|
|
62
|
+
function viewError(error: unknown): ClientError { return error instanceof ClientError && remoteErrorCodes.has(error.code) ? error : new ClientError('VIEW_FAILED'); }
|
|
63
|
+
function snapshot(value: RemoteSnapshot, id: string): RemoteSnapshot {
|
|
64
|
+
if (!value || !Object.isFrozen(value)) throw new ClientError('INVALID_VIEW_INPUT');
|
|
65
|
+
const fields = Object.getOwnPropertyDescriptors(value);
|
|
66
|
+
if (Reflect.ownKeys(fields).length !== 4 || ['id', 'status', 'budget', 'evidence'].some(key => !fields[key] || !('value' in fields[key]!))) throw new ClientError('INVALID_VIEW_INPUT');
|
|
67
|
+
const observedId = fields['id']!.value; const status = fields['status']!.value; const observedBudget: unknown = fields['budget']!.value; const observedEvidence: unknown = fields['evidence']!.value;
|
|
68
|
+
if (observedId !== id || typeof status !== 'string' || !runStatuses.has(status) || !observedBudget || typeof observedBudget !== 'object' || !Object.isFrozen(observedBudget)
|
|
69
|
+
|| !Array.isArray(observedEvidence) || !Object.isFrozen(observedEvidence) || observedEvidence.length > 4_096) throw new ClientError('INVALID_VIEW_INPUT');
|
|
70
|
+
const budget = Object.getOwnPropertyDescriptors(observedBudget);
|
|
71
|
+
if (Reflect.ownKeys(budget).length !== 3 || ['spentMicros', 'reservedMicros', 'calls'].some(key => !budget[key] || !('value' in budget[key]!))) throw new ClientError('INVALID_VIEW_INPUT');
|
|
72
|
+
const spent: unknown = budget['spentMicros']!.value; const reserved: unknown = budget['reservedMicros']!.value; const calls: unknown = budget['calls']!.value;
|
|
73
|
+
if ((typeof spent === 'string' ? !/^\d{1,64}$/.test(spent) : typeof spent !== 'number' || !Number.isSafeInteger(spent) || spent < 0)
|
|
74
|
+
|| typeof reserved !== 'number' || !Number.isSafeInteger(reserved) || reserved < 0 || typeof calls !== 'number' || !Number.isSafeInteger(calls) || calls < 0) throw new ClientError('INVALID_VIEW_INPUT');
|
|
75
|
+
for (const raw of observedEvidence) { if (!raw || typeof raw !== 'object' || !Object.isFrozen(raw)) throw new ClientError('INVALID_VIEW_INPUT');
|
|
76
|
+
const entry = Object.getOwnPropertyDescriptors(raw); if (Reflect.ownKeys(entry).length !== 2 || ['runId', 'receipt'].some(key => !entry[key] || !('value' in entry[key]!))) throw new ClientError('INVALID_VIEW_INPUT');
|
|
77
|
+
const runId: unknown = entry['runId']!.value; const rawReceipt: unknown = entry['receipt']!.value;
|
|
78
|
+
if (typeof runId !== 'string' || runId.length > 36 || !rawReceipt || typeof rawReceipt !== 'object' || !Object.isFrozen(rawReceipt)) throw new ClientError('INVALID_VIEW_INPUT');
|
|
79
|
+
const receipt = Object.getOwnPropertyDescriptors(rawReceipt); if (Reflect.ownKeys(receipt).length !== 4 || ['callId', 'toolId', 'execution', 'disclosure'].some(key => !receipt[key] || !('value' in receipt[key]!))) throw new ClientError('INVALID_VIEW_INPUT');
|
|
80
|
+
if (typeof receipt['callId']!.value !== 'string' || receipt['callId']!.value.length > 256 || typeof receipt['toolId']!.value !== 'string' || receipt['toolId']!.value.length > 256
|
|
81
|
+
|| !['not_started', 'succeeded', 'failed', 'unknown'].includes(String(receipt['execution']!.value)) || !['released', 'withheld'].includes(String(receipt['disclosure']!.value))) throw new ClientError('INVALID_VIEW_INPUT'); }
|
|
82
|
+
return value;
|
|
83
|
+
}
|
|
84
|
+
function event(value: ClientEvent, id: string, after: number): ClientEvent {
|
|
85
|
+
if (!value || !Object.isFrozen(value)) throw new ClientError('INVALID_VIEW_INPUT'); const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
86
|
+
if (Reflect.ownKeys(descriptors).length !== 5 || ['runId', 'sequence', 'timestamp', 'type', 'metadata'].some(key => !descriptors[key] || !('value' in descriptors[key]!))) throw new ClientError('INVALID_VIEW_INPUT');
|
|
87
|
+
const runId: unknown = descriptors['runId']!.value; const sequence: unknown = descriptors['sequence']!.value; const type: unknown = descriptors['type']!.value;
|
|
88
|
+
const timestamp: unknown = descriptors['timestamp']!.value; const observedMetadata: unknown = descriptors['metadata']!.value;
|
|
89
|
+
if (runId !== id || typeof type !== 'string' || !eventTypes.has(type) || typeof sequence !== 'number' || !Number.isSafeInteger(sequence) || sequence <= after
|
|
90
|
+
|| (type !== 'events.gap' && sequence !== after + 1) || typeof timestamp !== 'string' || !Number.isFinite(Date.parse(timestamp))
|
|
91
|
+
|| !observedMetadata || typeof observedMetadata !== 'object' || !Object.isFrozen(observedMetadata)) throw new ClientError('INVALID_VIEW_INPUT');
|
|
92
|
+
const metadata = Object.getOwnPropertyDescriptors(observedMetadata); const keys = Reflect.ownKeys(metadata);
|
|
93
|
+
if (keys.length > 64 || keys.some(key => typeof key !== 'string' || ['__proto__', 'constructor', 'prototype'].includes(key)
|
|
94
|
+
|| !('value' in metadata[key]!) || !['string', 'number', 'boolean'].includes(typeof metadata[key]!.value)
|
|
95
|
+
|| (typeof metadata[key]!.value === 'number' && !Number.isFinite(metadata[key]!.value)))) throw new ClientError('INVALID_VIEW_INPUT');
|
|
96
|
+
if (type === 'events.gap' && (metadata['from']?.value !== after + 1 || metadata['to']?.value !== sequence)) throw new ClientError('INVALID_VIEW_INPUT');
|
|
97
|
+
if (type === 'output.delta' || type === 'output.withheld') {
|
|
98
|
+
const required = type === 'output.delta' ? ['step', 'modelCall', 'index', 'text'] : ['step', 'modelCall'];
|
|
99
|
+
if (keys.length !== required.length || required.some(key => !metadata[key])
|
|
100
|
+
|| ['step', 'modelCall', ...(type === 'output.delta' ? ['index'] : [])].some(key => !Number.isSafeInteger(metadata[key]!.value) || (metadata[key]!.value as number) < 0)
|
|
101
|
+
|| (type === 'output.delta' && (typeof metadata['text']!.value !== 'string' || (metadata['text']!.value as string).length > 4_096))) throw new ClientError('INVALID_VIEW_INPUT');
|
|
102
|
+
}
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
105
|
+
function frozen(state: Omit<HeadlessRunState, 'activity' | 'events'> & { readonly activity: HeadlessRunState['activity']; readonly events: readonly ClientEvent[] }): HeadlessRunState {
|
|
106
|
+
return Object.freeze({ ...state, activity: Object.freeze({ ...state.activity }), events: Object.freeze([...state.events]) });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Framework-neutral external store for React, Vue, Svelte and DOM adapters. It never retries commands or opens a connection implicitly. */
|
|
110
|
+
export function createHeadlessRunStore(options: HeadlessRunStoreOptions): HeadlessRunStore {
|
|
111
|
+
if (!options || !options.run || typeof options.run.inspect !== 'function' || typeof options.run.events !== 'function' || typeof options.run.cancel !== 'function'
|
|
112
|
+
|| typeof options.run.id !== 'string') throw new ClientError('INVALID_VIEW_CONFIG');
|
|
113
|
+
const maxEvents = options.maxEvents ?? 256; const maxSubscribers = options.maxSubscribers ?? 64; const maxStreamedChars = options.maxStreamedChars ?? 65_536;
|
|
114
|
+
if (!Number.isSafeInteger(maxStreamedChars) || maxStreamedChars < 1 || maxStreamedChars > 1_048_576) throw new ClientError('INVALID_VIEW_CONFIG');
|
|
115
|
+
if (!Number.isSafeInteger(maxEvents) || maxEvents < 1 || maxEvents > 1_024 || !Number.isSafeInteger(maxSubscribers) || maxSubscribers < 1 || maxSubscribers > 256) throw new ClientError('INVALID_VIEW_CONFIG');
|
|
116
|
+
const run = options.run; const subscribers = new Set<() => void>(); const controllers = new Set<AbortController>();
|
|
117
|
+
let observing = false; let cancelling = false; let disposed = false; let refreshGeneration = 0;
|
|
118
|
+
let state = frozen({ revision: 0, connection: 'idle', snapshot: null, events: [], lastSequence: 0, hasGap: false,
|
|
119
|
+
activity: { models: 0, tools: 0, hooks: 0 }, errorCode: null, streamedOutput: null });
|
|
120
|
+
const publish = (change: Partial<Omit<HeadlessRunState, 'revision'>>): HeadlessRunState => {
|
|
121
|
+
if (disposed && change.connection !== 'disposed') return state;
|
|
122
|
+
state = frozen({ ...state, ...change, revision: state.revision + 1 });
|
|
123
|
+
for (const listener of [...subscribers]) { try { listener(); } catch { /* UI callbacks cannot break the store. */ } }
|
|
124
|
+
return state;
|
|
125
|
+
};
|
|
126
|
+
const operation = (external?: AbortSignal) => {
|
|
127
|
+
const controller = new AbortController(); const abort = (): void => controller.abort(); controllers.add(controller);
|
|
128
|
+
external?.addEventListener('abort', abort, { once: true }); if (external?.aborted) abort();
|
|
129
|
+
return { signal: controller.signal, close: () => { external?.removeEventListener('abort', abort); controllers.delete(controller); } };
|
|
130
|
+
};
|
|
131
|
+
const fail = (error: unknown, connection: RunConnection = observing ? 'observing' : 'error'): ClientError => {
|
|
132
|
+
const safe = viewError(error); if (!disposed) publish({ connection, errorCode: safe.code }); return safe;
|
|
133
|
+
};
|
|
134
|
+
const refresh = async (settings?: { readonly signal?: AbortSignal }): Promise<HeadlessRunState> => {
|
|
135
|
+
if (disposed) throw new ClientError('VIEW_DISPOSED'); const generation = ++refreshGeneration; const control = operation(settings?.signal);
|
|
136
|
+
publish({ connection: observing ? 'observing' : 'loading', errorCode: null });
|
|
137
|
+
try { const current = snapshot(await run.inspect({ signal: control.signal }), run.id);
|
|
138
|
+
if (generation !== refreshGeneration || disposed) return state;
|
|
139
|
+
return publish({ snapshot: current, connection: observing ? 'observing' : 'stopped',
|
|
140
|
+
...(terminal.has(current.status) ? { activity: { models: 0, tools: 0, hooks: 0 } } : {}), errorCode: null });
|
|
141
|
+
} catch (error) { if (generation !== refreshGeneration || disposed) throw viewError(error); throw fail(error); } finally { control.close(); }
|
|
142
|
+
};
|
|
143
|
+
return Object.freeze<HeadlessRunStore>({
|
|
144
|
+
getSnapshot: () => state,
|
|
145
|
+
subscribe: listener => { if (disposed) throw new ClientError('VIEW_DISPOSED'); if (typeof listener !== 'function') throw new ClientError('INVALID_VIEW_INPUT');
|
|
146
|
+
if (subscribers.size >= maxSubscribers) throw new ClientError('VIEW_SUBSCRIBER_LIMIT');
|
|
147
|
+
subscribers.add(listener); let active = true; return () => { if (active) { active = false; subscribers.delete(listener); } }; },
|
|
148
|
+
refresh,
|
|
149
|
+
observe: async settings => {
|
|
150
|
+
if (disposed) throw new ClientError('VIEW_DISPOSED'); if (observing) throw new ClientError('VIEW_BUSY'); observing = true;
|
|
151
|
+
const control = operation(settings?.signal); publish({ connection: 'observing', errorCode: null });
|
|
152
|
+
try {
|
|
153
|
+
for await (const received of run.events({ after: state.lastSequence, signal: control.signal })) {
|
|
154
|
+
const item = event(received, run.id, state.lastSequence); const gap = state.hasGap || item.type === 'events.gap';
|
|
155
|
+
const activity = gap ? { models: null, tools: null, hooks: null } : { ...state.activity };
|
|
156
|
+
if (!gap) {
|
|
157
|
+
const field = item.type.startsWith('model.') ? 'models' : item.type.startsWith('tool.') ? 'tools' : item.type.startsWith('hook.') ? 'hooks' : null;
|
|
158
|
+
if (field) activity[field] = Math.max(0, (activity[field] ?? 0) + (item.type.endsWith('.started') ? 1 : -1));
|
|
159
|
+
}
|
|
160
|
+
const output = item.type === 'output.delta' || item.type === 'output.withheld' ? { streamedOutput: streamed(state.streamedOutput, item, gap, maxStreamedChars) }
|
|
161
|
+
: item.type === 'events.gap' && state.streamedOutput ? { streamedOutput: Object.freeze({ ...state.streamedOutput, complete: false }) } : {};
|
|
162
|
+
publish({ events: [...state.events, item].slice(-maxEvents), lastSequence: item.sequence, hasGap: gap, activity, ...output });
|
|
163
|
+
}
|
|
164
|
+
const current = snapshot(await run.inspect({ signal: control.signal }), run.id);
|
|
165
|
+
return publish({ snapshot: current, connection: 'stopped', errorCode: null,
|
|
166
|
+
...(terminal.has(current.status) ? { activity: { models: 0, tools: 0, hooks: 0 } } : {}) });
|
|
167
|
+
} catch (error) { if (disposed) return state; observing = false; throw fail(error, 'error'); }
|
|
168
|
+
finally { observing = false; control.close(); }
|
|
169
|
+
},
|
|
170
|
+
cancel: async settings => { if (disposed) throw new ClientError('VIEW_DISPOSED'); if (cancelling) throw new ClientError('VIEW_BUSY'); cancelling = true;
|
|
171
|
+
const control = operation(settings?.signal); try { await run.cancel({ signal: control.signal }); } catch (error) { throw fail(error); }
|
|
172
|
+
finally { cancelling = false; control.close(); } },
|
|
173
|
+
dispose: () => { if (disposed) return; disposed = true; refreshGeneration += 1; for (const controller of controllers) controller.abort();
|
|
174
|
+
publish({ connection: 'disposed', errorCode: null }); subscribers.clear(); },
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** Safe text-only presentation metadata for an authenticated human request. Rendering code must still use `textContent`. */
|
|
179
|
+
export function createHumanRequestView(request: RemoteHumanRequest, nowMs: number): HumanRequestView {
|
|
180
|
+
if (!request || !Object.isFrozen(request) || !Number.isSafeInteger(nowMs) || nowMs < 0) throw new ClientError('INVALID_VIEW_INPUT');
|
|
181
|
+
const descriptors = Object.getOwnPropertyDescriptors(request); const allowed = new Set(['id', 'agentId', 'kind', 'schemaId', 'schemaDigest', 'prompt', 'digest', 'status', 'context', 'subjectDigest', 'deadlineAtMs']);
|
|
182
|
+
if (Reflect.ownKeys(descriptors).some(key => typeof key !== 'string' || !allowed.has(key) || !('value' in descriptors[key]!))) throw new ClientError('INVALID_VIEW_INPUT');
|
|
183
|
+
const values = Object.fromEntries(Object.entries(descriptors).map(([key, descriptor]) => [key, descriptor.value])) as Record<string, unknown>;
|
|
184
|
+
if (typeof values['id'] !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._-]{0,79}$/.test(values['id']) || typeof values['agentId'] !== 'string'
|
|
185
|
+
|| !/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/.test(values['agentId']) || !['information', 'correction', 'plan_selection'].includes(String(values['kind']))
|
|
186
|
+
|| typeof values['schemaId'] !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/.test(values['schemaId'])
|
|
187
|
+
|| typeof values['schemaDigest'] !== 'string' || !/^[a-f0-9]{64}$/.test(values['schemaDigest']) || typeof values['digest'] !== 'string' || !/^[a-f0-9]{64}$/.test(values['digest'])
|
|
188
|
+
|| !['waiting', 'answered', 'cancelled', 'timed_out'].includes(String(values['status'])) || typeof values['prompt'] !== 'string'
|
|
189
|
+
|| encoder.encode(values['prompt']).byteLength < 1 || encoder.encode(values['prompt']).byteLength > 1_024
|
|
190
|
+
|| (values['subjectDigest'] !== undefined && (typeof values['subjectDigest'] !== 'string' || !/^[a-f0-9]{64}$/.test(values['subjectDigest'])))
|
|
191
|
+
|| ((values['kind'] === 'correction') !== (values['subjectDigest'] !== undefined))
|
|
192
|
+
|| (values['deadlineAtMs'] !== undefined && (!Number.isSafeInteger(values['deadlineAtMs']) || (values['deadlineAtMs'] as number) < 0))) throw new ClientError('INVALID_VIEW_INPUT');
|
|
193
|
+
const item = values as unknown as RemoteHumanRequest;
|
|
194
|
+
const waiting = item.status === 'waiting'; const deadline = item.deadlineAtMs ?? null; const remaining = deadline === null ? null : deadline - nowMs;
|
|
195
|
+
const urgency: HumanRequestView['urgency'] = !waiting ? 'resolved' : remaining !== null && remaining <= 0 ? 'expired' : remaining !== null && remaining <= 300_000 ? 'due_soon' : 'normal';
|
|
196
|
+
const statusText = item.status === 'waiting' ? (urgency === 'expired' ? 'Response deadline passed' : 'Response required')
|
|
197
|
+
: item.status === 'answered' ? 'Answered' : item.status === 'cancelled' ? 'Cancelled' : 'Timed out';
|
|
198
|
+
const actionText = !waiting || urgency === 'expired' ? null : item.kind === 'information' ? 'Provide information'
|
|
199
|
+
: item.kind === 'correction' ? 'Submit correction' : 'Select plan';
|
|
200
|
+
return Object.freeze({ id: item.id, agentId: item.agentId, kind: item.kind, status: item.status, prompt: item.prompt,
|
|
201
|
+
canRespond: actionText !== null, urgency, statusText, actionText, deadlineAtMs: deadline });
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function activityIdentity(value: unknown): string | null {
|
|
205
|
+
return typeof value === 'string' && /^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/.test(value) ? value : null;
|
|
206
|
+
}
|
|
207
|
+
function activityStatus(value: unknown): Exclude<RunActivityStatus, 'active' | 'completed' | 'unknown'> | null {
|
|
208
|
+
return typeof value === 'string' && ['failed', 'blocked', 'cancelled', 'outcome_unknown'].includes(value)
|
|
209
|
+
? value as Exclude<RunActivityStatus, 'active' | 'completed' | 'unknown'> : null;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Project validated, content-free run events into a stable presentation timeline. Missing history remains explicit. */
|
|
213
|
+
export function createRunActivityProjection(state: HeadlessRunState): RunActivityProjection {
|
|
214
|
+
if (!state || !Object.isFrozen(state) || !Array.isArray(state.events) || !Object.isFrozen(state.events)
|
|
215
|
+
|| !Number.isSafeInteger(state.revision) || state.revision < 0 || state.events.length > 1_024) throw new ClientError('INVALID_VIEW_INPUT');
|
|
216
|
+
type MutableItem = { id: string; kind: RunActivityKind; label: string; status: RunActivityStatus; startedSequence: number | null;
|
|
217
|
+
completedSequence: number | null; startedAt: string | null; completedAt: string | null };
|
|
218
|
+
const items = new Map<string, MutableItem>(); let prior = 0; let terminalSeen = false;
|
|
219
|
+
let observedRunId: string | null = state.snapshot?.id ?? null; let complete = !state.hasGap;
|
|
220
|
+
const keyFor = (item: ClientEvent): { key: string; kind: RunActivityKind; label: string } | null => {
|
|
221
|
+
const metadata = item.metadata;
|
|
222
|
+
if (item.type.startsWith('run.')) return { key: 'run', kind: 'run', label: 'Run' };
|
|
223
|
+
if (item.type.startsWith('tool.')) { const id = activityIdentity(metadata['callId']); const label = activityIdentity(metadata['toolId']);
|
|
224
|
+
return { key: `tool:${id ?? item.sequence}`, kind: 'tool', label: label ?? 'Tool call' }; }
|
|
225
|
+
if (item.type.startsWith('hook.')) { const id = activityIdentity(metadata['invocationId']); const label = activityIdentity(metadata['hookId']);
|
|
226
|
+
return { key: `hook:${id ?? item.sequence}`, kind: 'hook', label: label ?? 'Lifecycle hook' }; }
|
|
227
|
+
if (item.type.startsWith('step.')) { const step = Number.isSafeInteger(metadata['step']) && (metadata['step'] as number) >= 0 ? metadata['step'] as number : null;
|
|
228
|
+
return { key: `step:${step ?? item.sequence}`, kind: 'step', label: step === null ? 'Step' : `Step ${step + 1}` }; }
|
|
229
|
+
if (item.type.startsWith('delegate.')) { const id = activityIdentity(metadata['childRunId']); const label = activityIdentity(metadata['childAgentId']);
|
|
230
|
+
return { key: `delegate:${id ?? item.sequence}`, kind: 'delegate', label: label ?? 'Delegated run' }; }
|
|
231
|
+
if (item.type.startsWith('model.')) {
|
|
232
|
+
const purpose = metadata['purpose'] === 'guardrail' ? 'guardrail' : 'primary';
|
|
233
|
+
const discriminator = purpose === 'guardrail'
|
|
234
|
+
? [activityIdentity(metadata['modelId']), activityIdentity(metadata['checkId']), activityIdentity(metadata['callId'])].filter(Boolean).join(':')
|
|
235
|
+
: Number.isSafeInteger(metadata['step']) && (metadata['step'] as number) >= 0 ? `step:${metadata['step']}` : '';
|
|
236
|
+
return { key: `model:${purpose}:${discriminator || item.sequence}`, kind: 'model', label: purpose === 'guardrail' ? 'Guardrail model call' : 'Model call' };
|
|
237
|
+
}
|
|
238
|
+
return null;
|
|
239
|
+
};
|
|
240
|
+
for (const item of state.events) {
|
|
241
|
+
if (!item || !Object.isFrozen(item) || (observedRunId !== null && item.runId !== observedRunId)
|
|
242
|
+
|| !Number.isSafeInteger(item.sequence) || item.sequence <= prior || typeof item.timestamp !== 'string' || !Number.isFinite(Date.parse(item.timestamp))
|
|
243
|
+
|| !Object.isFrozen(item.metadata)) throw new ClientError('INVALID_VIEW_INPUT');
|
|
244
|
+
observedRunId ??= item.runId;
|
|
245
|
+
if ((prior === 0 && item.sequence !== 1) || (prior !== 0 && item.sequence !== prior + 1)) complete = false;
|
|
246
|
+
prior = item.sequence; if (item.type === 'events.gap') { complete = false; continue; }
|
|
247
|
+
// Streamed output is text, not activity; `streamedOutput` carries it.
|
|
248
|
+
if (item.type === 'output.delta' || item.type === 'output.withheld') continue;
|
|
249
|
+
const identity = keyFor(item); if (!identity) throw new ClientError('INVALID_VIEW_INPUT'); const started = item.type.endsWith('.started');
|
|
250
|
+
if (item.type === 'run.completed') terminalSeen = true;
|
|
251
|
+
const existing = items.get(identity.key);
|
|
252
|
+
if (started) {
|
|
253
|
+
if (!existing) items.set(identity.key, { id: identity.key, kind: identity.kind, label: identity.label, status: 'active',
|
|
254
|
+
startedSequence: item.sequence, completedSequence: null, startedAt: item.timestamp, completedAt: null });
|
|
255
|
+
else complete = false;
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
const status = activityStatus(item.metadata['status']) ?? (item.metadata['decision'] === 'block' ? 'blocked' : 'completed');
|
|
259
|
+
if (existing && existing.status === 'active') { existing.status = status; existing.completedSequence = item.sequence; existing.completedAt = item.timestamp; }
|
|
260
|
+
else { complete = false; items.set(`${identity.key}:completed:${item.sequence}`, { id: `${identity.key}:completed:${item.sequence}`, kind: identity.kind,
|
|
261
|
+
label: identity.label, status, startedSequence: null, completedSequence: item.sequence, startedAt: null, completedAt: item.timestamp }); }
|
|
262
|
+
}
|
|
263
|
+
const result = [...items.values()].map(item => Object.freeze({ ...item, ...(item.status === 'active' && (!complete || terminalSeen) ? { status: 'unknown' as const } : {}) }));
|
|
264
|
+
return Object.freeze({ revision: state.revision, complete, items: Object.freeze(result) });
|
|
265
|
+
}
|