stitchkit 0.126.0 → 0.127.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/CHANGELOG.md +1636 -0
- package/README.md +12 -4
- package/dist/agent-executor/acp/scenarios.d.ts +4 -0
- package/dist/agent-executor/acp/scenarios.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-connect.d.ts +89 -0
- package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-driver.d.ts +31 -0
- package/dist/agent-executor/acp/v1-driver.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-map.d.ts +41 -0
- package/dist/agent-executor/acp/v1-map.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-protocol.d.ts +270 -0
- package/dist/agent-executor/acp/v1-protocol.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-session.d.ts +22 -0
- package/dist/agent-executor/acp/v1-session.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-turn.d.ts +25 -0
- package/dist/agent-executor/acp/v1-turn.d.ts.map +1 -0
- package/dist/agent-executor/claude/classify.d.ts +54 -0
- package/dist/agent-executor/claude/classify.d.ts.map +1 -0
- package/dist/agent-executor/claude/cli-driver.d.ts +27 -0
- package/dist/agent-executor/claude/cli-driver.d.ts.map +1 -0
- package/dist/agent-executor/claude/limits.d.ts +8 -0
- package/dist/agent-executor/claude/limits.d.ts.map +1 -0
- package/dist/agent-executor/claude/protocol.d.ts +188 -0
- package/dist/agent-executor/claude/protocol.d.ts.map +1 -0
- package/dist/agent-executor/claude/scenarios.d.ts +4 -0
- package/dist/agent-executor/claude/scenarios.d.ts.map +1 -0
- package/dist/agent-executor/claude/session.d.ts +22 -0
- package/dist/agent-executor/claude/session.d.ts.map +1 -0
- package/dist/agent-executor/claude/transcript.d.ts +33 -0
- package/dist/agent-executor/claude/transcript.d.ts.map +1 -0
- package/dist/agent-executor/claude-sdk/driver.d.ts +31 -0
- package/dist/agent-executor/claude-sdk/driver.d.ts.map +1 -0
- package/dist/agent-executor/claude-sdk/session.d.ts +10 -0
- package/dist/agent-executor/claude-sdk/session.d.ts.map +1 -0
- package/dist/agent-executor/codex/classify.d.ts +28 -0
- package/dist/agent-executor/codex/classify.d.ts.map +1 -0
- package/dist/agent-executor/codex/driver.d.ts +23 -0
- package/dist/agent-executor/codex/driver.d.ts.map +1 -0
- package/dist/agent-executor/codex/limits.d.ts +4 -0
- package/dist/agent-executor/codex/limits.d.ts.map +1 -0
- package/dist/agent-executor/codex/protocol.d.ts +152 -0
- package/dist/agent-executor/codex/protocol.d.ts.map +1 -0
- package/dist/agent-executor/codex/scenarios.d.ts +4 -0
- package/dist/agent-executor/codex/scenarios.d.ts.map +1 -0
- package/dist/agent-executor/codex/session.d.ts +41 -0
- package/dist/agent-executor/codex/session.d.ts.map +1 -0
- package/dist/agent-executor/contract.d.ts +454 -0
- package/dist/agent-executor/contract.d.ts.map +1 -0
- package/dist/agent-executor/dispatch.d.ts +41 -0
- package/dist/agent-executor/dispatch.d.ts.map +1 -0
- package/dist/agent-executor/engine-process.d.ts +45 -0
- package/dist/agent-executor/engine-process.d.ts.map +1 -0
- package/dist/agent-executor/engine-requests.d.ts +63 -0
- package/dist/agent-executor/engine-requests.d.ts.map +1 -0
- package/dist/agent-executor/engine.d.ts +64 -0
- package/dist/agent-executor/engine.d.ts.map +1 -0
- package/dist/agent-executor/executor-contract.d.ts +387 -0
- package/dist/agent-executor/executor-contract.d.ts.map +1 -0
- package/dist/agent-executor/executor-machine.d.ts +50 -0
- package/dist/agent-executor/executor-machine.d.ts.map +1 -0
- package/dist/agent-executor/hello.d.ts +235 -0
- package/dist/agent-executor/hello.d.ts.map +1 -0
- package/dist/agent-executor/json-rpc-peer.d.ts +48 -0
- package/dist/agent-executor/json-rpc-peer.d.ts.map +1 -0
- package/dist/agent-executor/leases.d.ts +159 -0
- package/dist/agent-executor/leases.d.ts.map +1 -0
- package/dist/agent-executor/plan-limits.d.ts +25 -0
- package/dist/agent-executor/plan-limits.d.ts.map +1 -0
- package/dist/agent-executor/profile.d.ts +52 -0
- package/dist/agent-executor/profile.d.ts.map +1 -0
- package/dist/agent-executor/projection.d.ts +14 -0
- package/dist/agent-executor/projection.d.ts.map +1 -0
- package/dist/agent-executor/session-primitives.d.ts +72 -0
- package/dist/agent-executor/session-primitives.d.ts.map +1 -0
- package/dist/agent-executor/testing/conformance.d.ts +55 -0
- package/dist/agent-executor/testing/conformance.d.ts.map +1 -0
- package/dist/agent-executor/testing/fake-claude-engine.d.ts +18 -0
- package/dist/agent-executor/testing/fake-claude-engine.d.ts.map +1 -0
- package/dist/agent-executor/testing/fake-engine.d.ts +52 -0
- package/dist/agent-executor/testing/fake-engine.d.ts.map +1 -0
- package/dist/agent-executor/turn-phases.d.ts +10 -0
- package/dist/agent-executor/turn-phases.d.ts.map +1 -0
- package/dist/agent-executor/vocabulary.d.ts +353 -0
- package/dist/agent-executor/vocabulary.d.ts.map +1 -0
- package/dist/agent-parts/parts.d.ts +160 -0
- package/dist/agent-parts/parts.d.ts.map +1 -0
- package/dist/agent-runtime/agent-tool.d.ts +1 -1
- package/dist/agent-runtime/agent-tool.d.ts.map +1 -1
- package/dist/agent-runtime/archive-projection.d.ts +5 -0
- package/dist/agent-runtime/archive-projection.d.ts.map +1 -1
- package/dist/agent-runtime/branch-contract.d.ts +59 -2
- package/dist/agent-runtime/branch-contract.d.ts.map +1 -1
- package/dist/agent-runtime/branch-events.d.ts +7 -0
- package/dist/agent-runtime/branch-events.d.ts.map +1 -1
- package/dist/agent-runtime/branch-identities.d.ts +40 -6
- package/dist/agent-runtime/branch-identities.d.ts.map +1 -1
- package/dist/agent-runtime/branch-messages.d.ts +11 -29
- package/dist/agent-runtime/branch-messages.d.ts.map +1 -1
- package/dist/agent-runtime/branch-observations.d.ts +138 -28
- package/dist/agent-runtime/branch-observations.d.ts.map +1 -1
- package/dist/agent-runtime/branch-provider.d.ts +32 -51
- package/dist/agent-runtime/branch-provider.d.ts.map +1 -1
- package/dist/agent-runtime/branch-refusal.d.ts +60 -0
- package/dist/agent-runtime/branch-refusal.d.ts.map +1 -0
- package/dist/agent-runtime/branch-runtime-tools.d.ts +14 -0
- package/dist/agent-runtime/branch-runtime-tools.d.ts.map +1 -0
- package/dist/agent-runtime/branch-source.d.ts +7 -2
- package/dist/agent-runtime/branch-source.d.ts.map +1 -1
- package/dist/agent-runtime/branch-transitions.d.ts.map +1 -1
- package/dist/agent-runtime/browser-control-contract.d.ts +2 -2
- package/dist/agent-runtime/browser-controller.d.ts.map +1 -1
- package/dist/agent-runtime/child-blocking.d.ts +17 -6
- package/dist/agent-runtime/child-blocking.d.ts.map +1 -1
- package/dist/agent-runtime/child-budget-policy.d.ts +4 -9
- package/dist/agent-runtime/child-budget-policy.d.ts.map +1 -1
- package/dist/agent-runtime/child-tools.d.ts +19 -8
- package/dist/agent-runtime/child-tools.d.ts.map +1 -1
- package/dist/agent-runtime/children-contract.d.ts +84 -3
- package/dist/agent-runtime/children-contract.d.ts.map +1 -1
- package/dist/agent-runtime/children-control.d.ts +23 -2
- package/dist/agent-runtime/children-control.d.ts.map +1 -1
- package/dist/agent-runtime/children-spawn.d.ts +9 -0
- package/dist/agent-runtime/children-spawn.d.ts.map +1 -1
- package/dist/agent-runtime/children-state.d.ts +121 -19
- package/dist/agent-runtime/children-state.d.ts.map +1 -1
- package/dist/agent-runtime/children-usage.d.ts +10 -1
- package/dist/agent-runtime/children-usage.d.ts.map +1 -1
- package/dist/agent-runtime/children.d.ts +3 -3
- package/dist/agent-runtime/children.d.ts.map +1 -1
- package/dist/agent-runtime/{sandbox-coding.d.ts → coding-sandbox.d.ts} +2 -9
- package/dist/agent-runtime/coding-sandbox.d.ts.map +1 -0
- package/dist/agent-runtime/coding-shell-process.d.ts +2 -0
- package/dist/agent-runtime/coding-shell-process.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts +32 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-shell.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tools.d.ts.map +1 -1
- package/dist/agent-runtime/compaction.d.ts.map +1 -1
- package/dist/agent-runtime/companion-host.d.ts +38 -0
- package/dist/agent-runtime/companion-host.d.ts.map +1 -0
- package/dist/agent-runtime/context-issue.d.ts +5 -0
- package/dist/agent-runtime/context-issue.d.ts.map +1 -0
- package/dist/agent-runtime/control-schema.d.ts +2 -2
- package/dist/agent-runtime/control-schema.d.ts.map +1 -1
- package/dist/agent-runtime/conversations.d.ts.map +1 -1
- package/dist/agent-runtime/coordinator.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tool-types.d.ts +17 -5
- package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tools-internal.d.ts +2 -0
- package/dist/agent-runtime/deferred-tools-internal.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tools.d.ts.map +1 -1
- package/dist/agent-runtime/event-durability.d.ts +8 -0
- package/dist/agent-runtime/event-durability.d.ts.map +1 -0
- package/dist/agent-runtime/event-schema.d.ts +13 -5
- package/dist/agent-runtime/event-schema.d.ts.map +1 -1
- package/dist/agent-runtime/event-search-postgres.d.ts +38 -0
- package/dist/agent-runtime/event-search-postgres.d.ts.map +1 -0
- package/dist/agent-runtime/event-search-terms.d.ts +37 -0
- package/dist/agent-runtime/event-search-terms.d.ts.map +1 -0
- package/dist/agent-runtime/event-search-tools.d.ts +64 -4
- package/dist/agent-runtime/event-search-tools.d.ts.map +1 -1
- package/dist/agent-runtime/event-search.d.ts +16 -3
- package/dist/agent-runtime/event-search.d.ts.map +1 -1
- package/dist/agent-runtime/fault-bench.d.ts.map +1 -1
- package/dist/agent-runtime/harness-control.d.ts +8 -0
- package/dist/agent-runtime/harness-control.d.ts.map +1 -1
- package/dist/agent-runtime/harness-realtime.d.ts +0 -2
- package/dist/agent-runtime/harness-realtime.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-read.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-schema.d.ts +23 -0
- package/dist/agent-runtime/invocation-schema.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-spend.d.ts +9 -0
- package/dist/agent-runtime/invocation-spend.d.ts.map +1 -0
- package/dist/agent-runtime/invocations.d.ts.map +1 -1
- package/dist/agent-runtime/managed-tools.d.ts +2 -2
- package/dist/agent-runtime/managed-tools.d.ts.map +1 -1
- package/dist/agent-runtime/observability.d.ts +42 -4
- package/dist/agent-runtime/observability.d.ts.map +1 -1
- package/dist/agent-runtime/openrouter-admission.d.ts +81 -0
- package/dist/agent-runtime/openrouter-admission.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-catalog.d.ts +83 -0
- package/dist/agent-runtime/openrouter-catalog.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-models.d.ts +66 -0
- package/dist/agent-runtime/openrouter-models.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-options.d.ts +106 -0
- package/dist/agent-runtime/openrouter-options.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-route.d.ts +50 -0
- package/dist/agent-runtime/openrouter-route.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-spend.d.ts +24 -0
- package/dist/agent-runtime/openrouter-spend.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter.d.ts +23 -2
- package/dist/agent-runtime/openrouter.d.ts.map +1 -1
- package/dist/agent-runtime/owned-provider-stream.d.ts.map +1 -1
- package/dist/agent-runtime/postgres-schema.d.ts +34 -0
- package/dist/agent-runtime/postgres-schema.d.ts.map +1 -0
- package/dist/agent-runtime/postgres-transactions.d.ts +54 -0
- package/dist/agent-runtime/postgres-transactions.d.ts.map +1 -0
- package/dist/agent-runtime/postgres.d.ts +72 -0
- package/dist/agent-runtime/postgres.d.ts.map +1 -0
- package/dist/agent-runtime/projections.d.ts +57 -17
- package/dist/agent-runtime/projections.d.ts.map +1 -1
- package/dist/agent-runtime/provider-journal.d.ts +57 -0
- package/dist/agent-runtime/provider-journal.d.ts.map +1 -1
- package/dist/agent-runtime/purge.d.ts.map +1 -1
- package/dist/agent-runtime/retry-policy.d.ts +6 -0
- package/dist/agent-runtime/retry-policy.d.ts.map +1 -1
- package/dist/agent-runtime/run-acquisition.d.ts.map +1 -1
- package/dist/agent-runtime/run-execution-state.d.ts +26 -2
- package/dist/agent-runtime/run-execution-state.d.ts.map +1 -1
- package/dist/agent-runtime/run-execution.d.ts.map +1 -1
- package/dist/agent-runtime/run-failure.d.ts.map +1 -1
- package/dist/agent-runtime/run-model-attempts.d.ts.map +1 -1
- package/dist/agent-runtime/run-provider-ledger.d.ts +2 -0
- package/dist/agent-runtime/run-provider-ledger.d.ts.map +1 -1
- package/dist/agent-runtime/run-step-barriers.d.ts +72 -0
- package/dist/agent-runtime/run-step-barriers.d.ts.map +1 -0
- package/dist/agent-runtime/run-step-spend.d.ts +319 -0
- package/dist/agent-runtime/run-step-spend.d.ts.map +1 -0
- package/dist/agent-runtime/run-stream-parts.d.ts +2 -0
- package/dist/agent-runtime/run-stream-parts.d.ts.map +1 -1
- package/dist/agent-runtime/{tool-progress.d.ts → run-tool-progress.d.ts} +1 -1
- package/dist/agent-runtime/run-tool-progress.d.ts.map +1 -0
- package/dist/agent-runtime/run-turn-preparation.d.ts +3 -1
- package/dist/agent-runtime/run-turn-preparation.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-admission-gate.d.ts +0 -14
- package/dist/agent-runtime/runtime-admission-gate.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-internals.d.ts +6 -0
- package/dist/agent-runtime/runtime-internals.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-state.d.ts.map +1 -1
- package/dist/agent-runtime/runtime.d.ts +31 -2
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox-binding.d.ts +10 -0
- package/dist/agent-runtime/sandbox-binding.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-bubblewrap-storage.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox-contract.d.ts +1 -1
- package/dist/agent-runtime/sandbox-contract.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox.d.ts +5 -0
- package/dist/agent-runtime/sandbox.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-contract.d.ts +3 -2
- package/dist/agent-runtime/schedule-contract.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-dispatch.d.ts +3 -2
- package/dist/agent-runtime/schedule-dispatch.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-records.d.ts +6 -6
- package/dist/agent-runtime/schedule-records.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-tools.d.ts +19 -8
- package/dist/agent-runtime/schedule-tools.d.ts.map +1 -1
- package/dist/agent-runtime/schedules.d.ts +13 -3
- package/dist/agent-runtime/schedules.d.ts.map +1 -1
- package/dist/agent-runtime/schemas-message.d.ts +118 -0
- package/dist/agent-runtime/schemas-message.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-provider.d.ts +8 -0
- package/dist/agent-runtime/schemas-provider.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-records.d.ts +5 -0
- package/dist/agent-runtime/schemas-records.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-run.d.ts +487 -0
- package/dist/agent-runtime/schemas-run.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-usage.d.ts +129 -0
- package/dist/agent-runtime/schemas-usage.d.ts.map +1 -0
- package/dist/agent-runtime/schemas.d.ts +11 -886
- package/dist/agent-runtime/schemas.d.ts.map +1 -1
- package/dist/agent-runtime/spill.d.ts +9 -7
- package/dist/agent-runtime/spill.d.ts.map +1 -1
- package/dist/agent-runtime/sql-events.d.ts +6 -0
- package/dist/agent-runtime/sql-events.d.ts.map +1 -0
- package/dist/agent-runtime/sql-history.d.ts +8 -0
- package/dist/agent-runtime/sql-history.d.ts.map +1 -0
- package/dist/agent-runtime/sql-ledger.d.ts +5 -0
- package/dist/agent-runtime/sql-ledger.d.ts.map +1 -0
- package/dist/agent-runtime/sql-purge.d.ts +13 -0
- package/dist/agent-runtime/sql-purge.d.ts.map +1 -0
- package/dist/agent-runtime/sql-reads.d.ts +16 -0
- package/dist/agent-runtime/sql-reads.d.ts.map +1 -0
- package/dist/agent-runtime/{sqlite-rows.d.ts → sql-rows.d.ts} +24 -10
- package/dist/agent-runtime/sql-rows.d.ts.map +1 -0
- package/dist/agent-runtime/sql-session.d.ts +71 -0
- package/dist/agent-runtime/sql-session.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-bun.d.ts +1 -1
- package/dist/agent-runtime/sqlite-bun.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-node.d.ts +1 -1
- package/dist/agent-runtime/sqlite-node.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-purge.d.ts +2 -3
- package/dist/agent-runtime/sqlite-purge.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-schema.d.ts +1 -1
- package/dist/agent-runtime/sqlite-schema.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-transactions.d.ts +10 -6
- package/dist/agent-runtime/sqlite-transactions.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite.d.ts +10 -29
- package/dist/agent-runtime/sqlite.d.ts.map +1 -1
- package/dist/agent-runtime/state-tools.d.ts +8 -4
- package/dist/agent-runtime/state-tools.d.ts.map +1 -1
- package/dist/agent-runtime/store-archive.d.ts.map +1 -1
- package/dist/agent-runtime/store-branch.d.ts +6 -1
- package/dist/agent-runtime/store-branch.d.ts.map +1 -1
- package/dist/agent-runtime/store-capabilities.d.ts +42 -0
- package/dist/agent-runtime/store-capabilities.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-branch.d.ts +5 -2
- package/dist/agent-runtime/store-conformance-branch.d.ts.map +1 -1
- package/dist/agent-runtime/store-conformance-capabilities.d.ts +6 -0
- package/dist/agent-runtime/store-conformance-capabilities.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-event-once.d.ts +12 -0
- package/dist/agent-runtime/store-conformance-event-once.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +20 -20
- package/dist/agent-runtime/store-conformance-seed.d.ts +8 -0
- package/dist/agent-runtime/store-conformance-seed.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance.d.ts +31 -8
- package/dist/agent-runtime/store-conformance.d.ts.map +1 -1
- package/dist/agent-runtime/store-create.d.ts +1 -1
- package/dist/agent-runtime/store-create.d.ts.map +1 -1
- package/dist/agent-runtime/store-driver-contract.d.ts +15 -8
- package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
- package/dist/agent-runtime/store-event-once.d.ts.map +1 -1
- package/dist/agent-runtime/store-events.d.ts +114 -0
- package/dist/agent-runtime/store-events.d.ts.map +1 -1
- package/dist/agent-runtime/store-memory-archive.d.ts +2 -0
- package/dist/agent-runtime/store-memory-archive.d.ts.map +1 -1
- package/dist/agent-runtime/store-memory.d.ts +2 -2
- package/dist/agent-runtime/store-memory.d.ts.map +1 -1
- package/dist/agent-runtime/store-mutate.d.ts.map +1 -1
- package/dist/agent-runtime/store-reduce-shared.d.ts +2 -1
- package/dist/agent-runtime/store-reduce-shared.d.ts.map +1 -1
- package/dist/agent-runtime/store-reducer.d.ts.map +1 -1
- package/dist/agent-runtime/store-replay.d.ts.map +1 -1
- package/dist/agent-runtime/store.d.ts +15 -2
- package/dist/agent-runtime/store.d.ts.map +1 -1
- package/dist/agent-runtime/terminal-commit.d.ts +10 -10
- package/dist/application/admission-run.d.ts.map +1 -1
- package/dist/application/admission.d.ts.map +1 -1
- package/dist/application/change-subscription.d.ts.map +1 -1
- package/dist/application/decisions.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-lock-format.d.ts +9 -0
- package/dist/application/diagnostic-journal-lock-format.d.ts.map +1 -0
- package/dist/application/diagnostic-journal-manager.d.ts.map +1 -1
- package/dist/application/directory-inbox-delivery.d.ts.map +1 -1
- package/dist/application/grammy-update-admission.d.ts.map +1 -1
- package/dist/application/health.d.ts.map +1 -1
- package/dist/application/kernel-admission.d.ts.map +1 -1
- package/dist/application/kernel-contract.d.ts.map +1 -1
- package/dist/application/kernel-restart.d.ts.map +1 -1
- package/dist/application/kernel-rollback.d.ts.map +1 -1
- package/dist/application/kernel-shutdown.d.ts.map +1 -1
- package/dist/application/kernel-state.d.ts.map +1 -1
- package/dist/application/notification-outbox-state.d.ts.map +1 -1
- package/dist/application/notification-outbox.d.ts +1 -1
- package/dist/application/notification-outbox.d.ts.map +1 -1
- package/dist/application/revision-signal.d.ts.map +1 -1
- package/dist/application/schedule-run.d.ts.map +1 -1
- package/dist/application/schedule.d.ts.map +1 -1
- package/dist/application/sqlite-migrations.d.ts +104 -0
- package/dist/application/sqlite-migrations.d.ts.map +1 -0
- package/dist/application/watch-hub-core.d.ts.map +1 -1
- package/dist/browser/bridge-errors.d.ts +24 -0
- package/dist/browser/bridge-errors.d.ts.map +1 -0
- package/dist/browser/bridge-fetch.d.ts +30 -0
- package/dist/browser/bridge-fetch.d.ts.map +1 -0
- package/dist/browser/bridge-inbound.d.ts +28 -0
- package/dist/browser/bridge-inbound.d.ts.map +1 -0
- package/dist/browser/cancellation.d.ts +10 -2
- package/dist/browser/cancellation.d.ts.map +1 -1
- package/dist/browser/chunked-upload.d.ts +1 -1
- package/dist/browser/chunked-upload.d.ts.map +1 -1
- package/dist/browser/client-call-arguments.d.ts +31 -0
- package/dist/browser/client-call-arguments.d.ts.map +1 -0
- package/dist/browser/client-executors.d.ts +6 -0
- package/dist/browser/client-executors.d.ts.map +1 -1
- package/dist/browser/client.d.ts +9 -0
- package/dist/browser/client.d.ts.map +1 -1
- package/dist/browser/http.d.ts +17 -2
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/browser/realtime-client.d.ts +0 -5
- package/dist/browser/realtime-client.d.ts.map +1 -1
- package/dist/browser/session-credentials-storage.d.ts +48 -0
- package/dist/browser/session-credentials-storage.d.ts.map +1 -0
- package/dist/browser/session-credentials.d.ts +26 -5
- package/dist/browser/session-credentials.d.ts.map +1 -1
- package/dist/browser/session-refresh-policy.d.ts +124 -0
- package/dist/browser/session-refresh-policy.d.ts.map +1 -0
- package/dist/browser/session-refresh-timer.d.ts +30 -0
- package/dist/browser/session-refresh-timer.d.ts.map +1 -0
- package/dist/browser/session.d.ts.map +1 -1
- package/dist/browser/socket-io-connection.d.ts.map +1 -1
- package/dist/browser/socket-io-explicit-peer.d.ts +0 -1
- package/dist/browser/socket-io-explicit-peer.d.ts.map +1 -1
- package/dist/browser/stream.d.ts +1 -1
- package/dist/browser/stream.d.ts.map +1 -1
- package/dist/browser/upload-progress.d.ts +3 -0
- package/dist/browser/upload-progress.d.ts.map +1 -1
- package/dist/contract/bridge-envelope.d.ts +155 -0
- package/dist/contract/bridge-envelope.d.ts.map +1 -0
- package/dist/contract/define-validation.d.ts +2 -0
- package/dist/contract/define-validation.d.ts.map +1 -1
- package/dist/contract/define.d.ts +3 -0
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/errors.d.ts +4 -4
- package/dist/contract/errors.d.ts.map +1 -1
- package/dist/contract/normalize.d.ts +3 -1
- package/dist/contract/normalize.d.ts.map +1 -1
- package/dist/contract/operation-effect.d.ts +29 -0
- package/dist/contract/operation-effect.d.ts.map +1 -0
- package/dist/contract/runtime-context.d.ts +2 -0
- package/dist/contract/runtime-context.d.ts.map +1 -1
- package/dist/contract/tool-options.d.ts +7 -0
- package/dist/contract/tool-options.d.ts.map +1 -1
- package/dist/declaration/command.d.ts +26 -0
- package/dist/declaration/command.d.ts.map +1 -0
- package/dist/declaration/declaration.d.ts +4 -22
- package/dist/declaration/declaration.d.ts.map +1 -1
- package/dist/declaration/machine-names.d.ts +11 -0
- package/dist/declaration/machine-names.d.ts.map +1 -0
- package/dist/durability/effect.d.ts.map +1 -1
- package/dist/durability/engine.d.ts.map +1 -1
- package/dist/durability/events.d.ts +5 -8
- package/dist/durability/events.d.ts.map +1 -1
- package/dist/durability/parks.d.ts +0 -5
- package/dist/durability/parks.d.ts.map +1 -1
- package/dist/durability/scheduler.d.ts +5 -0
- package/dist/durability/scheduler.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.d.ts +4 -0
- package/dist/entrypoints/agent-executor/acp.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/acp.js +910 -0
- package/dist/entrypoints/agent-executor/claude-sdk.d.ts +2 -0
- package/dist/entrypoints/agent-executor/claude-sdk.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/claude-sdk.js +309 -0
- package/dist/entrypoints/agent-executor/claude.d.ts +5 -0
- package/dist/entrypoints/agent-executor/claude.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/claude.js +403 -0
- package/dist/entrypoints/agent-executor/codex.d.ts +4 -0
- package/dist/entrypoints/agent-executor/codex.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/codex.js +798 -0
- package/dist/entrypoints/agent-executor/testing.d.ts +4 -0
- package/dist/entrypoints/agent-executor/testing.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/testing.js +375 -0
- package/dist/entrypoints/agent-executor.d.ts +15 -0
- package/dist/entrypoints/agent-executor.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor.js +455 -0
- package/dist/entrypoints/agent-runtime/browser.d.ts +1 -0
- package/dist/entrypoints/agent-runtime/browser.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/browser.js +60 -30
- package/dist/entrypoints/agent-runtime/coding-tools.js +9 -12
- package/dist/entrypoints/agent-runtime/harness.js +35 -22
- package/dist/entrypoints/agent-runtime/openrouter.d.ts +6 -0
- package/dist/entrypoints/agent-runtime/openrouter.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/openrouter.js +675 -45
- package/dist/entrypoints/agent-runtime/postgres.d.ts +4 -0
- package/dist/entrypoints/agent-runtime/postgres.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/postgres.js +330 -0
- package/dist/entrypoints/agent-runtime/realtime.js +46 -49
- package/dist/entrypoints/agent-runtime/sandbox.d.ts +3 -1
- package/dist/entrypoints/agent-runtime/sandbox.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/sandbox.js +74 -67
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +18 -18
- package/dist/entrypoints/agent-runtime/sqlite/node.js +18 -18
- package/dist/entrypoints/agent-runtime/testing.d.ts +1 -1
- package/dist/entrypoints/agent-runtime/testing.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/testing.js +394 -95
- package/dist/entrypoints/agent-runtime.d.ts +21 -13
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime.js +1280 -1086
- package/dist/entrypoints/application/diagnostic-journal.js +16 -11
- package/dist/entrypoints/application/directory-inbox.js +20 -14
- package/dist/entrypoints/application/grammy.js +11 -8
- package/dist/entrypoints/application/opentelemetry.js +3 -3
- package/dist/entrypoints/application.d.ts +4 -2
- package/dist/entrypoints/application.d.ts.map +1 -1
- package/dist/entrypoints/application.js +409 -108
- package/dist/entrypoints/bin/upgrade-cli.d.ts +0 -12
- package/dist/entrypoints/bin/upgrade-cli.d.ts.map +1 -1
- package/dist/entrypoints/bin/upgrade-cli.js +11 -7
- package/dist/entrypoints/cli/publish.js +10 -9
- package/dist/entrypoints/cli.d.ts +10 -3
- package/dist/entrypoints/cli.d.ts.map +1 -1
- package/dist/entrypoints/cli.js +91 -29
- package/dist/entrypoints/contract.d.ts +2 -1
- package/dist/entrypoints/contract.d.ts.map +1 -1
- package/dist/entrypoints/contract.js +13 -7
- package/dist/entrypoints/declaration.d.ts +2 -0
- package/dist/entrypoints/declaration.d.ts.map +1 -1
- package/dist/entrypoints/declaration.js +55 -44
- package/dist/entrypoints/files/packaging.js +8 -5
- package/dist/entrypoints/files.d.ts +5 -0
- package/dist/entrypoints/files.d.ts.map +1 -1
- package/dist/entrypoints/files.js +236 -47
- package/dist/entrypoints/geo.js +9 -4
- package/dist/entrypoints/google.js +14 -13
- package/dist/entrypoints/handler.d.ts +12 -0
- package/dist/entrypoints/handler.d.ts.map +1 -0
- package/dist/entrypoints/handler.js +350 -0
- package/dist/entrypoints/http.d.ts +4 -0
- package/dist/entrypoints/http.d.ts.map +1 -1
- package/dist/entrypoints/http.js +411 -5
- package/dist/entrypoints/index.d.ts +2 -0
- package/dist/entrypoints/index.d.ts.map +1 -1
- package/dist/entrypoints/index.js +664 -91
- package/dist/entrypoints/live.js +22 -12
- package/dist/entrypoints/node.d.ts +2 -1
- package/dist/entrypoints/node.d.ts.map +1 -1
- package/dist/entrypoints/node.js +34 -25
- package/dist/entrypoints/observability.d.ts +2 -0
- package/dist/entrypoints/observability.d.ts.map +1 -1
- package/dist/entrypoints/observability.js +205 -131
- package/dist/entrypoints/primitives.js +152 -14
- package/dist/entrypoints/process/owner-loss.js +2 -2
- package/dist/entrypoints/process.js +18 -92
- package/dist/entrypoints/react.js +6 -5
- package/dist/entrypoints/realtime.d.ts +1 -0
- package/dist/entrypoints/realtime.d.ts.map +1 -1
- package/dist/entrypoints/realtime.js +6 -3
- package/dist/entrypoints/release.js +4 -0
- package/dist/entrypoints/remote.js +7 -6
- package/dist/entrypoints/server.d.ts +3 -1
- package/dist/entrypoints/server.d.ts.map +1 -1
- package/dist/entrypoints/server.js +295 -194
- package/dist/entrypoints/service-host/macos.d.ts +16 -0
- package/dist/entrypoints/service-host/macos.d.ts.map +1 -0
- package/dist/entrypoints/service-host/macos.js +1998 -0
- package/dist/entrypoints/service-host.d.ts +23 -0
- package/dist/entrypoints/service-host.d.ts.map +1 -0
- package/dist/entrypoints/service-host.js +2544 -0
- package/dist/entrypoints/spend/testing.d.ts +2 -0
- package/dist/entrypoints/spend/testing.d.ts.map +1 -0
- package/dist/entrypoints/spend/testing.js +442 -0
- package/dist/entrypoints/spend.d.ts +8 -0
- package/dist/entrypoints/spend.d.ts.map +1 -0
- package/dist/entrypoints/spend.js +593 -0
- package/dist/entrypoints/sync/postgres.d.ts +12 -0
- package/dist/entrypoints/sync/postgres.d.ts.map +1 -0
- package/dist/entrypoints/sync/postgres.js +737 -0
- package/dist/entrypoints/sync.d.ts +12 -0
- package/dist/entrypoints/sync.d.ts.map +1 -0
- package/dist/entrypoints/sync.js +782 -0
- package/dist/entrypoints/telegram/grammy.js +5 -5
- package/dist/entrypoints/telegram/html.d.ts +2 -0
- package/dist/entrypoints/telegram/html.d.ts.map +1 -1
- package/dist/entrypoints/telegram/html.js +839 -2
- package/dist/entrypoints/telegram/screens.js +13 -15
- package/dist/entrypoints/telegram.d.ts +1 -1
- package/dist/entrypoints/telegram.d.ts.map +1 -1
- package/dist/entrypoints/telegram.js +286 -76
- package/dist/entrypoints/testing.js +33 -41
- package/dist/entrypoints/tools/agent.js +12 -9
- package/dist/entrypoints/tools/connections.js +664 -63
- package/dist/entrypoints/tools/contract.d.ts +2 -2
- package/dist/entrypoints/tools/contract.js +4 -1
- package/dist/entrypoints/tools/invoker.js +9 -7
- package/dist/entrypoints/tools/mcp.js +16 -13
- package/dist/entrypoints/tools/toolkit.js +21 -18
- package/dist/entrypoints/tools.d.ts +3 -1
- package/dist/entrypoints/tools.d.ts.map +1 -1
- package/dist/entrypoints/tools.js +105 -92
- package/dist/entrypoints/tracking/contract.js +2 -1
- package/dist/entrypoints/tracking/performance.js +4 -0
- package/dist/entrypoints/tracking.js +6 -1
- package/dist/entrypoints/voice.js +3 -3
- package/dist/entrypoints/xlsx.js +1 -1
- package/dist/files/boundary.d.ts.map +1 -1
- package/dist/files/chunk-spool.d.ts +27 -0
- package/dist/files/chunk-spool.d.ts.map +1 -1
- package/dist/files/directory-appearance.d.ts +44 -0
- package/dist/files/directory-appearance.d.ts.map +1 -0
- package/dist/files/file-io.d.ts.map +1 -1
- package/dist/files/file-stamp.d.ts +35 -0
- package/dist/files/file-stamp.d.ts.map +1 -0
- package/dist/files/json-file-reading.d.ts +37 -0
- package/dist/files/json-file-reading.d.ts.map +1 -0
- package/dist/files/native-packaging.d.ts.map +1 -1
- package/dist/files/polled-json.d.ts +121 -0
- package/dist/files/polled-json.d.ts.map +1 -0
- package/dist/files/regular-file.d.ts +125 -0
- package/dist/files/regular-file.d.ts.map +1 -0
- package/dist/geo/index.d.ts +2 -1
- package/dist/geo/index.d.ts.map +1 -1
- package/dist/geo/resolver.d.ts.map +1 -1
- package/dist/geo/types.d.ts +0 -1
- package/dist/geo/types.d.ts.map +1 -1
- package/dist/google/google.d.ts +6 -0
- package/dist/google/google.d.ts.map +1 -1
- package/dist/{index-w0eqdhyd.js → index-09f7w2qq.js} +6 -1
- package/dist/index-0djnptn8.js +501 -0
- package/dist/index-0hdm5sx6.js +1457 -0
- package/dist/{index-t05a2ry4.js → index-0p0s5hrj.js} +8 -14
- package/dist/{index-1c945ten.js → index-0r15pkjq.js} +1 -1
- package/dist/{index-v1swr26p.js → index-0tyt97nk.js} +2 -2
- package/dist/{index-332d0m9g.js → index-0x4mnwg5.js} +4 -0
- package/dist/index-118aebbg.js +48 -0
- package/dist/index-1q0n6zek.js +184 -0
- package/dist/index-27hck3z2.js +307 -0
- package/dist/index-2rf33y2h.js +77 -0
- package/dist/index-360j58vb.js +63 -0
- package/dist/{index-tt30h7mr.js → index-39n02e0q.js} +1 -1
- package/dist/index-3agqmmrg.js +42 -0
- package/dist/{index-n6hvd1r2.js → index-3b31z0pc.js} +22 -15
- package/dist/index-3djgv3ch.js +472 -0
- package/dist/{index-mfntvj58.js → index-3dq8466w.js} +1 -1
- package/dist/index-3gwp8ez6.js +200 -0
- package/dist/{index-x2d51zay.js → index-3ypvpkwr.js} +309 -345
- package/dist/index-4gk6k3zc.js +248 -0
- package/dist/index-4qvyhn23.js +40 -0
- package/dist/index-4s2w4g37.js +647 -0
- package/dist/index-4ynw5ktx.js +78 -0
- package/dist/index-5awtbyns.js +19 -0
- package/dist/{index-kxff9e9w.js → index-5e0zsbf7.js} +5 -4
- package/dist/{index-nz06qw5a.js → index-5jyjb4s0.js} +1 -1
- package/dist/{index-7zksb1ty.js → index-5ptwb6ka.js} +1 -1
- package/dist/{index-w3nv6kr8.js → index-5q0qpw3v.js} +54 -9
- package/dist/{index-mm89hd8v.js → index-5t4fpdct.js} +1 -1
- package/dist/{index-0v9xb8pz.js → index-5y7j383h.js} +5 -5
- package/dist/index-5zwac8ft.js +221 -0
- package/dist/{index-v62cpkx3.js → index-6g85s734.js} +1 -1
- package/dist/{index-sqc6ezrb.js → index-6kec3b14.js} +17 -4
- package/dist/{index-kqnd6a85.js → index-7416mhyh.js} +1 -1
- package/dist/{index-m0wsfmrc.js → index-7csn6pva.js} +37 -24
- package/dist/{index-dqpesdck.js → index-7grgs8cx.js} +25 -5
- package/dist/{index-jjvr9f15.js → index-7kfcb576.js} +129 -39
- package/dist/{index-cvjddnvd.js → index-7xp05h20.js} +19 -10
- package/dist/{index-48acz7z0.js → index-83n766x4.js} +91 -50
- package/dist/{index-ss67fxhj.js → index-877e9y8r.js} +7 -7
- package/dist/{index-aw6kx2e6.js → index-8gmmdz7k.js} +1 -1
- package/dist/{index-wt6rw7rf.js → index-8xr2eq99.js} +29 -21
- package/dist/{index-rz3z13e9.js → index-97q9kykw.js} +1 -1
- package/dist/index-97rp94ff.js +8 -0
- package/dist/{index-0w0hxp7n.js → index-9pv126eh.js} +3 -9
- package/dist/{index-x2rvpbtj.js → index-9wh98cpa.js} +110 -16
- package/dist/{index-egg0yp2j.js → index-9xr44d2g.js} +86 -210
- package/dist/{index-b2sey031.js → index-9y0afd5f.js} +24 -23
- package/dist/index-a725ayvz.js +405 -0
- package/dist/{index-nmaqxdx7.js → index-ac5rj3d4.js} +203 -90
- package/dist/{index-wqzw3qg9.js → index-agy5fqgf.js} +32 -13
- package/dist/index-ajmtxsky.js +193 -0
- package/dist/{index-ndjzbt2v.js → index-akf0xkrm.js} +4 -3
- package/dist/index-akfgymyr.js +8 -0
- package/dist/index-apv5xfef.js +13 -0
- package/dist/index-ax3wns1a.js +93 -0
- package/dist/{index-ft2wvst5.js → index-bbzvrq66.js} +1603 -342
- package/dist/index-bh4pmtr9.js +317 -0
- package/dist/{index-fa53vygr.js → index-bmaz3jzy.js} +3 -3
- package/dist/{index-8kzct1d6.js → index-bn2baakz.js} +143 -143
- package/dist/{index-m8ddk770.js → index-brhhaygm.js} +1 -1
- package/dist/index-caywx1c0.js +199 -0
- package/dist/index-cbhxhma2.js +90 -0
- package/dist/index-cfnmvcq8.js +11 -0
- package/dist/index-cv9b7fz2.js +42 -0
- package/dist/index-d4svrknj.js +156 -0
- package/dist/{index-a3z56mtn.js → index-d96c1n1q.js} +5 -3
- package/dist/{index-3ymcmpa9.js → index-dvd1qdwa.js} +33 -163
- package/dist/{index-v7rbjatr.js → index-dwa6pskj.js} +1837 -1151
- package/dist/{index-ne4j9998.js → index-e06z0tkb.js} +123 -94
- package/dist/{index-99nnsz39.js → index-en8e5zsj.js} +15 -135
- package/dist/index-fcw255hd.js +929 -0
- package/dist/{index-20hn8pbh.js → index-fmzg39a8.js} +1 -1
- package/dist/{index-fvd6pvw3.js → index-g1q7fwn9.js} +2 -2
- package/dist/index-g56ht6qf.js +98 -0
- package/dist/{index-f56ct5gb.js → index-gj1rjf78.js} +4 -3
- package/dist/{index-g6a3na27.js → index-gnjgkecx.js} +7 -3
- package/dist/index-hy4653g4.js +345 -0
- package/dist/index-j13gzgdv.js +403 -0
- package/dist/{index-pa9bhefy.js → index-j516jaaz.js} +37 -11
- package/dist/{index-t8jz0e20.js → index-j903yhp4.js} +30 -38
- package/dist/{index-9ypczvpj.js → index-jb4m241t.js} +2 -0
- package/dist/index-jrka9029.js +177 -0
- package/dist/{index-cjzaj7ev.js → index-jxtg307y.js} +23 -21
- package/dist/index-kmbpej2y.js +1152 -0
- package/dist/{index-bz9cmnqq.js → index-kt6dh1n6.js} +4 -4
- package/dist/index-ky3ardqn.js +80 -0
- package/dist/index-kyejf658.js +14 -0
- package/dist/{index-zyc64nbh.js → index-kynwa08q.js} +52 -47
- package/dist/index-kzavdze2.js +15 -0
- package/dist/{index-m200b8hs.js → index-mbd92r1w.js} +5 -3
- package/dist/index-mxt0wfjy.js +58 -0
- package/dist/{index-9cxxfkhb.js → index-n20tybgk.js} +14 -9
- package/dist/index-nbv44x0x.js +250 -0
- package/dist/index-ngwf1s3c.js +51 -0
- package/dist/{index-zfncctjp.js → index-nk0cy9g1.js} +5 -4
- package/dist/index-p1m9djt6.js +108 -0
- package/dist/{index-hs76yzt7.js → index-paff5y0r.js} +17 -11
- package/dist/{index-qaet40b2.js → index-prf6ayhf.js} +5 -7
- package/dist/{index-hkxgennw.js → index-ps3djm8d.js} +7 -1
- package/dist/{index-1v3k5zgx.js → index-qnzhmk2s.js} +528 -1129
- package/dist/{index-3bzk2645.js → index-r9kq5ark.js} +1 -1
- package/dist/{index-hkw233vx.js → index-rbd2rq3z.js} +2 -2
- package/dist/{index-r0xr7y4m.js → index-rhb33thr.js} +138 -33
- package/dist/{index-kffm4r8w.js → index-rj32hkkp.js} +2 -2
- package/dist/index-rptj3qnc.js +96 -0
- package/dist/{index-hqsbtvta.js → index-rpyn7geq.js} +11 -3
- package/dist/{index-m9hb9wnk.js → index-sfzfd2m2.js} +2 -2
- package/dist/{index-sqkttz7z.js → index-sv5svtq7.js} +1 -1
- package/dist/{index-srs8hj9c.js → index-sx3g49y2.js} +5 -1
- package/dist/{index-9mjrnqxs.js → index-t1a2jrg7.js} +21 -91
- package/dist/{index-a6w6mwda.js → index-tazm4dxf.js} +1 -1
- package/dist/{index-b51tzcgh.js → index-tf70nm22.js} +2 -2
- package/dist/index-ttexdtjj.js +28 -0
- package/dist/{index-103dp7fz.js → index-v37b2cd6.js} +1956 -3151
- package/dist/{index-0ndz5r8z.js → index-v59pxmf1.js} +17 -9
- package/dist/{index-rfkh44ss.js → index-vgytj9wp.js} +1 -1
- package/dist/{index-tnnmekgb.js → index-wa6h4tz6.js} +3 -3
- package/dist/{index-4efxzrht.js → index-wavv538x.js} +211 -196
- package/dist/{index-1szhrfsf.js → index-wbnpa8z6.js} +7 -5
- package/dist/index-werjqesf.js +43 -0
- package/dist/{index-7qyv50r4.js → index-wv8dqy7q.js} +2 -2
- package/dist/index-wz392jyz.js +10 -0
- package/dist/{index-1d7s7da0.js → index-x6sp5vpa.js} +36 -5
- package/dist/{index-bqzgaj57.js → index-x90w78yz.js} +183 -61
- package/dist/index-xgae0bn7.js +37 -0
- package/dist/index-xmr47znh.js +160 -0
- package/dist/{index-ftk3838x.js → index-xq4s9mka.js} +7 -2
- package/dist/{index-ww3gss55.js → index-xrgn784x.js} +1 -1
- package/dist/{index-fpwbskp2.js → index-xtby8rj3.js} +1 -1
- package/dist/index-xtkw9866.js +107 -0
- package/dist/{index-btjwc7xr.js → index-xypxnzhp.js} +15 -14
- package/dist/{index-yex7eg1v.js → index-y7sy1xdp.js} +6 -2
- package/dist/index-z4k0hqp9.js +476 -0
- package/dist/{index-a7ebd769.js → index-zwgwyvdt.js} +3 -3
- package/dist/internal/abort-error.d.ts +9 -0
- package/dist/internal/abort-error.d.ts.map +1 -0
- package/dist/internal/abort-race.d.ts +47 -4
- package/dist/internal/abort-race.d.ts.map +1 -1
- package/dist/internal/atomic-file.d.ts +19 -0
- package/dist/internal/atomic-file.d.ts.map +1 -1
- package/dist/internal/backoff.d.ts.map +1 -1
- package/dist/internal/bounded-body.d.ts +37 -1
- package/dist/internal/bounded-body.d.ts.map +1 -1
- package/dist/internal/bounded-file-read.d.ts +31 -15
- package/dist/internal/bounded-file-read.d.ts.map +1 -1
- package/dist/internal/bun-command.d.ts +11 -0
- package/dist/internal/bun-command.d.ts.map +1 -1
- package/dist/internal/channel.d.ts.map +1 -1
- package/dist/internal/darwin-binding-error.d.ts.map +1 -1
- package/dist/internal/darwin-binding.d.ts +10 -0
- package/dist/internal/darwin-binding.d.ts.map +1 -1
- package/dist/internal/deadline.d.ts +22 -2
- package/dist/internal/deadline.d.ts.map +1 -1
- package/dist/internal/exclusive-lock-owner.d.ts +20 -1
- package/dist/internal/exclusive-lock-owner.d.ts.map +1 -1
- package/dist/internal/exclusive-lock-read.d.ts +2 -0
- package/dist/internal/exclusive-lock-read.d.ts.map +1 -1
- package/dist/internal/exclusive-lock.d.ts +26 -0
- package/dist/internal/exclusive-lock.d.ts.map +1 -1
- package/dist/internal/file-observation.d.ts +49 -0
- package/dist/internal/file-observation.d.ts.map +1 -1
- package/dist/internal/json-response.d.ts +10 -0
- package/dist/internal/json-response.d.ts.map +1 -0
- package/dist/internal/open-descriptors.d.ts +5 -0
- package/dist/internal/open-descriptors.d.ts.map +1 -1
- package/dist/internal/optional-peer.d.ts.map +1 -1
- package/dist/internal/pinned-http.d.ts.map +1 -1
- package/dist/internal/positive-integer.d.ts +14 -6
- package/dist/internal/positive-integer.d.ts.map +1 -1
- package/dist/internal/postgres-query.d.ts +16 -0
- package/dist/internal/postgres-query.d.ts.map +1 -0
- package/dist/internal/process-identity.d.ts +21 -1
- package/dist/internal/process-identity.d.ts.map +1 -1
- package/dist/internal/process-instance.d.ts +6 -0
- package/dist/internal/process-instance.d.ts.map +1 -1
- package/dist/internal/request.d.ts +4 -0
- package/dist/internal/request.d.ts.map +1 -1
- package/dist/internal/secret-equal.d.ts +11 -0
- package/dist/internal/secret-equal.d.ts.map +1 -0
- package/dist/internal/secure-fetch.d.ts.map +1 -1
- package/dist/internal/sqlite.d.ts +8 -0
- package/dist/internal/sqlite.d.ts.map +1 -1
- package/dist/internal/timers.d.ts +20 -0
- package/dist/internal/timers.d.ts.map +1 -1
- package/dist/internal/typed.d.ts +11 -0
- package/dist/internal/typed.d.ts.map +1 -1
- package/dist/internal/unix-client-error.d.ts +21 -0
- package/dist/internal/unix-client-error.d.ts.map +1 -0
- package/dist/internal/unix-socket-lock.d.ts +23 -0
- package/dist/internal/unix-socket-lock.d.ts.map +1 -0
- package/dist/internal/unix-socket.d.ts +60 -0
- package/dist/internal/unix-socket.d.ts.map +1 -1
- package/dist/internal/upgrade-affects.d.ts +3 -3
- package/dist/internal/upgrade-affects.d.ts.map +1 -1
- package/dist/internal/upgrade-plan.d.ts.map +1 -1
- package/dist/json-schema/dialect.d.ts +0 -6
- package/dist/json-schema/dialect.d.ts.map +1 -1
- package/dist/json-schema/keywords.d.ts +116 -0
- package/dist/json-schema/keywords.d.ts.map +1 -0
- package/dist/json-schema/string-format.d.ts.map +1 -1
- package/dist/live/events.d.ts.map +1 -1
- package/dist/live/watch-client.d.ts.map +1 -1
- package/dist/observability/bounded-logger.d.ts +3 -0
- package/dist/observability/bounded-logger.d.ts.map +1 -1
- package/dist/observability/bounded-sink.d.ts.map +1 -1
- package/dist/observability/context.d.ts +12 -2
- package/dist/observability/context.d.ts.map +1 -1
- package/dist/observability/event-loop-delay.d.ts +62 -0
- package/dist/observability/event-loop-delay.d.ts.map +1 -0
- package/dist/observability/json-logger.d.ts.map +1 -1
- package/dist/observability/log-repeat.d.ts +44 -0
- package/dist/observability/log-repeat.d.ts.map +1 -0
- package/dist/observability/spool-core.d.ts +95 -0
- package/dist/observability/spool-core.d.ts.map +1 -0
- package/dist/observability/spool-file.d.ts +46 -0
- package/dist/observability/spool-file.d.ts.map +1 -0
- package/dist/observability/spool.d.ts +14 -8
- package/dist/observability/spool.d.ts.map +1 -1
- package/dist/observability/trace.d.ts.map +1 -1
- package/dist/observability/work.d.ts.map +1 -1
- package/dist/primitives/index.d.ts +1 -0
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/order-key.d.ts +37 -0
- package/dist/primitives/order-key.d.ts.map +1 -0
- package/dist/process/bun-child.d.ts.map +1 -1
- package/dist/process/command-owner.d.ts.map +1 -1
- package/dist/process/contract.d.ts +4 -3
- package/dist/process/contract.d.ts.map +1 -1
- package/dist/process/group-presence.d.ts.map +1 -1
- package/dist/process/group.d.ts +5 -1
- package/dist/process/group.d.ts.map +1 -1
- package/dist/process/launch.d.ts +5 -3
- package/dist/process/launch.d.ts.map +1 -1
- package/dist/process/owner-loss-guard.d.ts.map +1 -1
- package/dist/react/cache-bridge.d.ts.map +1 -1
- package/dist/release/watcher.d.ts.map +1 -1
- package/dist/server/bridge-host.d.ts +51 -0
- package/dist/server/bridge-host.d.ts.map +1 -0
- package/dist/server/bun.d.ts +4 -4
- package/dist/server/bun.d.ts.map +1 -1
- package/dist/server/context-contribution.d.ts.map +1 -1
- package/dist/server/contract-method.d.ts.map +1 -1
- package/dist/server/create.d.ts +1 -0
- package/dist/server/create.d.ts.map +1 -1
- package/dist/server/endpoint-dispatch.d.ts.map +1 -1
- package/dist/server/endpoint-response.d.ts.map +1 -1
- package/dist/server/error-dispatch.d.ts +2 -0
- package/dist/server/error-dispatch.d.ts.map +1 -1
- package/dist/server/error-hook.d.ts +2 -0
- package/dist/server/error-hook.d.ts.map +1 -1
- package/dist/server/handler-state.d.ts +13 -2
- package/dist/server/handler-state.d.ts.map +1 -1
- package/dist/server/implement.d.ts +1 -0
- package/dist/server/implement.d.ts.map +1 -1
- package/dist/server/local-host.d.ts +47 -0
- package/dist/server/local-host.d.ts.map +1 -0
- package/dist/server/logger.d.ts +20 -3
- package/dist/server/logger.d.ts.map +1 -1
- package/dist/server/logging.d.ts +2 -1
- package/dist/server/logging.d.ts.map +1 -1
- package/dist/server/middleware/cors.d.ts +1 -0
- package/dist/server/middleware/cors.d.ts.map +1 -1
- package/dist/server/middleware/signed-link.d.ts +42 -0
- package/dist/server/middleware/signed-link.d.ts.map +1 -0
- package/dist/server/multipart-reader.d.ts +3 -1
- package/dist/server/multipart-reader.d.ts.map +1 -1
- package/dist/server/multipart.d.ts.map +1 -1
- package/dist/server/oauth/cimd.d.ts.map +1 -1
- package/dist/server/oauth/endpoints.d.ts.map +1 -1
- package/dist/server/openapi.d.ts.map +1 -1
- package/dist/server/protocol-outcome.d.ts +17 -0
- package/dist/server/protocol-outcome.d.ts.map +1 -0
- package/dist/server/raw.d.ts.map +1 -1
- package/dist/server/request-completion.d.ts +3 -1
- package/dist/server/request-completion.d.ts.map +1 -1
- package/dist/server/shutdown.d.ts.map +1 -1
- package/dist/server/socket-io-config.d.ts +1 -1
- package/dist/server/socket-io-config.d.ts.map +1 -1
- package/dist/server/streaming-route.d.ts.map +1 -1
- package/dist/server/types.d.ts +13 -10
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/unix-client-body.d.ts +4 -1
- package/dist/server/unix-client-body.d.ts.map +1 -1
- package/dist/server/unix-client-bun.d.ts.map +1 -1
- package/dist/server/unix-client.d.ts +1 -1
- package/dist/server/unix-client.d.ts.map +1 -1
- package/dist/service-host/artifact-activation.d.ts +58 -0
- package/dist/service-host/artifact-activation.d.ts.map +1 -0
- package/dist/service-host/artifact-manifest.d.ts +68 -0
- package/dist/service-host/artifact-manifest.d.ts.map +1 -0
- package/dist/service-host/artifact.d.ts +43 -0
- package/dist/service-host/artifact.d.ts.map +1 -0
- package/dist/service-host/config-reloader-contract.d.ts +66 -0
- package/dist/service-host/config-reloader-contract.d.ts.map +1 -0
- package/dist/service-host/config-reloader-helpers.d.ts +32 -0
- package/dist/service-host/config-reloader-helpers.d.ts.map +1 -0
- package/dist/service-host/config-reloader-source.d.ts +47 -0
- package/dist/service-host/config-reloader-source.d.ts.map +1 -0
- package/dist/service-host/config-reloader.d.ts +6 -0
- package/dist/service-host/config-reloader.d.ts.map +1 -0
- package/dist/service-host/host-adapter.d.ts +72 -0
- package/dist/service-host/host-adapter.d.ts.map +1 -0
- package/dist/service-host/identity-unix-socket.d.ts +101 -0
- package/dist/service-host/identity-unix-socket.d.ts.map +1 -0
- package/dist/service-host/identity.d.ts +117 -0
- package/dist/service-host/identity.d.ts.map +1 -0
- package/dist/service-host/launchd-plist.d.ts +77 -0
- package/dist/service-host/launchd-plist.d.ts.map +1 -0
- package/dist/service-host/launchd-render.d.ts +91 -0
- package/dist/service-host/launchd-render.d.ts.map +1 -0
- package/dist/service-host/launchd.d.ts +82 -0
- package/dist/service-host/launchd.d.ts.map +1 -0
- package/dist/service-host/macos/bundle-plist.d.ts +50 -0
- package/dist/service-host/macos/bundle-plist.d.ts.map +1 -0
- package/dist/service-host/macos/bundle.d.ts +66 -0
- package/dist/service-host/macos/bundle.d.ts.map +1 -0
- package/dist/service-host/macos/codesign.d.ts +95 -0
- package/dist/service-host/macos/codesign.d.ts.map +1 -0
- package/dist/service-host/macos/icon.d.ts +93 -0
- package/dist/service-host/macos/icon.d.ts.map +1 -0
- package/dist/service-host/macos/launch-services.d.ts +88 -0
- package/dist/service-host/macos/launch-services.d.ts.map +1 -0
- package/dist/service-host/macos/launcher.d.ts +59 -0
- package/dist/service-host/macos/launcher.d.ts.map +1 -0
- package/dist/service-host/macos/responsibility.d.ts +90 -0
- package/dist/service-host/macos/responsibility.d.ts.map +1 -0
- package/dist/service-host/macos/runner.d.ts +69 -0
- package/dist/service-host/macos/runner.d.ts.map +1 -0
- package/dist/service-host/plist-xml.d.ts +48 -0
- package/dist/service-host/plist-xml.d.ts.map +1 -0
- package/dist/service-host/process-evidence.d.ts +17 -0
- package/dist/service-host/process-evidence.d.ts.map +1 -0
- package/dist/service-host/systemd-inspect.d.ts +126 -0
- package/dist/service-host/systemd-inspect.d.ts.map +1 -0
- package/dist/service-host/systemd-links.d.ts +23 -0
- package/dist/service-host/systemd-links.d.ts.map +1 -0
- package/dist/service-host/systemd-render.d.ts +93 -0
- package/dist/service-host/systemd-render.d.ts.map +1 -0
- package/dist/service-host/systemd.d.ts +50 -0
- package/dist/service-host/systemd.d.ts.map +1 -0
- package/dist/spend/attribution.d.ts +17 -0
- package/dist/spend/attribution.d.ts.map +1 -0
- package/dist/spend/coverage-guard.d.ts +60 -0
- package/dist/spend/coverage-guard.d.ts.map +1 -0
- package/dist/spend/coverage-lexer.d.ts +20 -0
- package/dist/spend/coverage-lexer.d.ts.map +1 -0
- package/dist/spend/facts.d.ts +23 -0
- package/dist/spend/facts.d.ts.map +1 -0
- package/dist/spend/gateway-stream.d.ts +25 -0
- package/dist/spend/gateway-stream.d.ts.map +1 -0
- package/dist/spend/gateway.d.ts +64 -0
- package/dist/spend/gateway.d.ts.map +1 -0
- package/dist/spend/receipt-merge.d.ts +13 -0
- package/dist/spend/receipt-merge.d.ts.map +1 -0
- package/dist/spend/receipt-spool.d.ts +35 -0
- package/dist/spend/receipt-spool.d.ts.map +1 -0
- package/dist/spend/reconcile.d.ts +45 -0
- package/dist/spend/reconcile.d.ts.map +1 -0
- package/dist/spend/schemas.d.ts +249 -0
- package/dist/spend/schemas.d.ts.map +1 -0
- package/dist/sync/outbox.d.ts +131 -0
- package/dist/sync/outbox.d.ts.map +1 -0
- package/dist/sync/overlay.d.ts +59 -0
- package/dist/sync/overlay.d.ts.map +1 -0
- package/dist/sync/protocol.d.ts +132 -0
- package/dist/sync/protocol.d.ts.map +1 -0
- package/dist/sync/server-store-check.d.ts +10 -0
- package/dist/sync/server-store-check.d.ts.map +1 -0
- package/dist/sync/server-store-memory.d.ts +14 -0
- package/dist/sync/server-store-memory.d.ts.map +1 -0
- package/dist/sync/server-store-postgres.d.ts +25 -0
- package/dist/sync/server-store-postgres.d.ts.map +1 -0
- package/dist/sync/server-store.d.ts +139 -0
- package/dist/sync/server-store.d.ts.map +1 -0
- package/dist/sync/session-machine.d.ts +79 -0
- package/dist/sync/session-machine.d.ts.map +1 -0
- package/dist/sync/session-snapshot.d.ts +19 -0
- package/dist/sync/session-snapshot.d.ts.map +1 -0
- package/dist/sync/session-steps.d.ts +15 -0
- package/dist/sync/session-steps.d.ts.map +1 -0
- package/dist/sync/session.d.ts +142 -0
- package/dist/sync/session.d.ts.map +1 -0
- package/dist/sync/tombstones.d.ts +53 -0
- package/dist/sync/tombstones.d.ts.map +1 -0
- package/dist/telegram/bot-api.d.ts.map +1 -1
- package/dist/telegram/broadcast-failure.d.ts.map +1 -1
- package/dist/telegram/budget-transformer.d.ts.map +1 -1
- package/dist/telegram/crypto.d.ts +2 -10
- package/dist/telegram/crypto.d.ts.map +1 -1
- package/dist/telegram/html/markdown-inline.d.ts +19 -0
- package/dist/telegram/html/markdown-inline.d.ts.map +1 -0
- package/dist/telegram/html/markdown-lines.d.ts +51 -0
- package/dist/telegram/html/markdown-lines.d.ts.map +1 -0
- package/dist/telegram/html/markdown-split.d.ts +49 -0
- package/dist/telegram/html/markdown-split.d.ts.map +1 -0
- package/dist/telegram/html/markdown.d.ts +14 -0
- package/dist/telegram/html/markdown.d.ts.map +1 -0
- package/dist/telegram/html/nodes.d.ts +26 -4
- package/dist/telegram/html/nodes.d.ts.map +1 -1
- package/dist/telegram/html/parse.d.ts.map +1 -1
- package/dist/telegram/html/render.d.ts.map +1 -1
- package/dist/telegram/init-data.d.ts.map +1 -1
- package/dist/telegram/local-files.d.ts.map +1 -1
- package/dist/telegram/operator-channel.d.ts +15 -2
- package/dist/telegram/operator-channel.d.ts.map +1 -1
- package/dist/telegram/outbound-budget.d.ts.map +1 -1
- package/dist/telegram/outbound-cost.d.ts +9 -1
- package/dist/telegram/outbound-cost.d.ts.map +1 -1
- package/dist/telegram/outbound-queue.d.ts +2 -1
- package/dist/telegram/outbound-queue.d.ts.map +1 -1
- package/dist/telegram/screens/outcome.d.ts.map +1 -1
- package/dist/telegram/send-failure.d.ts.map +1 -1
- package/dist/telegram/transport-connect.d.ts.map +1 -1
- package/dist/telegram/transport.d.ts.map +1 -1
- package/dist/telegram/update-intake.d.ts.map +1 -1
- package/dist/telegram/update-store-postgres.d.ts +2 -2
- package/dist/telegram/update-store-postgres.d.ts.map +1 -1
- package/dist/telegram/webhook.d.ts.map +1 -1
- package/dist/testing/managed-resource-conformance.d.ts.map +1 -1
- package/dist/testing/surface-conformance.d.ts.map +1 -1
- package/dist/testing/surface-manifest.d.ts +2 -0
- package/dist/testing/surface-manifest.d.ts.map +1 -1
- package/dist/tools/access.d.ts +34 -0
- package/dist/tools/access.d.ts.map +1 -0
- package/dist/tools/agent.d.ts +14 -6
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/cli/args-classify.d.ts +154 -0
- package/dist/tools/cli/args-classify.d.ts.map +1 -0
- package/dist/tools/cli/args-fields.d.ts +14 -7
- package/dist/tools/cli/args-fields.d.ts.map +1 -1
- package/dist/tools/cli/args-json.d.ts +1 -1
- package/dist/tools/cli/args-json.d.ts.map +1 -1
- package/dist/tools/cli/args-route.d.ts +4 -48
- package/dist/tools/cli/args-route.d.ts.map +1 -1
- package/dist/tools/cli/args-scan.d.ts +70 -0
- package/dist/tools/cli/args-scan.d.ts.map +1 -0
- package/dist/tools/cli/args-tokens.d.ts +2 -1
- package/dist/tools/cli/args-tokens.d.ts.map +1 -1
- package/dist/tools/cli/args.d.ts +31 -19
- package/dist/tools/cli/args.d.ts.map +1 -1
- package/dist/tools/cli/checkpoint.d.ts.map +1 -1
- package/dist/tools/cli/command-shape.d.ts +5 -0
- package/dist/tools/cli/command-shape.d.ts.map +1 -1
- package/dist/tools/cli/command.d.ts +57 -2
- package/dist/tools/cli/command.d.ts.map +1 -1
- package/dist/tools/cli/config.d.ts +15 -58
- package/dist/tools/cli/config.d.ts.map +1 -1
- package/dist/tools/cli/create-cli.d.ts +7 -3
- package/dist/tools/cli/create-cli.d.ts.map +1 -1
- package/dist/tools/cli/format.d.ts.map +1 -1
- package/dist/tools/cli/help.d.ts.map +1 -1
- package/dist/tools/cli/invoke.d.ts +70 -20
- package/dist/tools/cli/invoke.d.ts.map +1 -1
- package/dist/tools/cli/io.d.ts.map +1 -1
- package/dist/tools/cli/managed-surface.d.ts.map +1 -1
- package/dist/tools/cli/notices.d.ts.map +1 -1
- package/dist/tools/cli/policy.d.ts +66 -10
- package/dist/tools/cli/policy.d.ts.map +1 -1
- package/dist/tools/cli/prepare.d.ts +5 -4
- package/dist/tools/cli/prepare.d.ts.map +1 -1
- package/dist/tools/cli/run-managed.d.ts.map +1 -1
- package/dist/tools/cli/run-native.d.ts.map +1 -1
- package/dist/tools/cli/run-stream.d.ts.map +1 -1
- package/dist/tools/cli/runner.d.ts +28 -0
- package/dist/tools/cli/runner.d.ts.map +1 -0
- package/dist/tools/cli/session.d.ts +12 -6
- package/dist/tools/cli/session.d.ts.map +1 -1
- package/dist/tools/cli/stream-surface.d.ts.map +1 -1
- package/dist/tools/cli/stream.d.ts.map +1 -1
- package/dist/tools/cli/unavailable.d.ts +2 -0
- package/dist/tools/cli/unavailable.d.ts.map +1 -1
- package/dist/tools/cli/unix-outcome.d.ts +8 -0
- package/dist/tools/cli/unix-outcome.d.ts.map +1 -0
- package/dist/tools/cli/update.d.ts.map +1 -1
- package/dist/tools/cli/view-columns.d.ts +18 -0
- package/dist/tools/cli/view-columns.d.ts.map +1 -0
- package/dist/tools/cli/view.d.ts.map +1 -1
- package/dist/tools/connections/define.d.ts.map +1 -1
- package/dist/tools/connections/foreign-schema-join.d.ts +28 -0
- package/dist/tools/connections/foreign-schema-join.d.ts.map +1 -0
- package/dist/tools/connections/foreign-schema.d.ts +9 -0
- package/dist/tools/connections/foreign-schema.d.ts.map +1 -0
- package/dist/tools/connections/limits.d.ts +1 -1
- package/dist/tools/connections/limits.d.ts.map +1 -1
- package/dist/tools/connections/mcp-client.d.ts.map +1 -1
- package/dist/tools/connections/mcp.d.ts.map +1 -1
- package/dist/tools/connections/openapi.d.ts.map +1 -1
- package/dist/tools/connections/runtime.d.ts +18 -6
- package/dist/tools/connections/runtime.d.ts.map +1 -1
- package/dist/tools/connections/sse-session.d.ts.map +1 -1
- package/dist/tools/connections/types.d.ts +12 -2
- package/dist/tools/connections/types.d.ts.map +1 -1
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/internal/expose.d.ts +6 -0
- package/dist/tools/internal/expose.d.ts.map +1 -0
- package/dist/tools/internal/json-projection.d.ts +17 -0
- package/dist/tools/internal/json-projection.d.ts.map +1 -0
- package/dist/tools/internal/surface-projector.d.ts +18 -4
- package/dist/tools/internal/surface-projector.d.ts.map +1 -1
- package/dist/tools/invoker.d.ts +9 -2
- package/dist/tools/invoker.d.ts.map +1 -1
- package/dist/tools/lifecycle.d.ts +8 -2
- package/dist/tools/lifecycle.d.ts.map +1 -1
- package/dist/tools/list-names.d.ts +1 -1
- package/dist/tools/list-names.d.ts.map +1 -1
- package/dist/tools/manifest.d.ts +2 -0
- package/dist/tools/manifest.d.ts.map +1 -1
- package/dist/tools/mcp/handler.d.ts.map +1 -1
- package/dist/tools/mcp/mount.d.ts +26 -14
- package/dist/tools/mcp/mount.d.ts.map +1 -1
- package/dist/tools/mcp/prepare.d.ts +2 -0
- package/dist/tools/mcp/prepare.d.ts.map +1 -1
- package/dist/tools/mcp/register.d.ts.map +1 -1
- package/dist/tools/mcp/runtime-tools.d.ts +1 -1
- package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
- package/dist/tools/mcp/stdio.d.ts.map +1 -1
- package/dist/tools/mount.d.ts +7 -2
- package/dist/tools/mount.d.ts.map +1 -1
- package/dist/tools/native-definition.d.ts +1 -1
- package/dist/tools/native-definition.d.ts.map +1 -1
- package/dist/tools/operations/async-operation-runtime-tools.d.ts +2 -2
- package/dist/tools/operations/async-operation-runtime-tools.d.ts.map +1 -1
- package/dist/tools/operations/async-operation-runtime-types.d.ts +1 -1
- package/dist/tools/operations/async-operation-runtime-types.d.ts.map +1 -1
- package/dist/tools/operations/define-wait-tool.d.ts.map +1 -1
- package/dist/tools/operations/mount-wait.d.ts.map +1 -1
- package/dist/tools/operations/wait-core.d.ts.map +1 -1
- package/dist/tools/read-operation.d.ts +6 -4
- package/dist/tools/read-operation.d.ts.map +1 -1
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/runtime-tool-declaration.d.ts +4 -1
- package/dist/tools/runtime-tool-declaration.d.ts.map +1 -1
- package/dist/tools/runtime-tool.d.ts +6 -1
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/dist/tools/schema/coerce.d.ts.map +1 -1
- package/dist/tools/schema/inline-references.d.ts +7 -0
- package/dist/tools/schema/inline-references.d.ts.map +1 -0
- package/dist/tools/schema/json-schema-origin.d.ts +1 -1
- package/dist/tools/schema/json-schema-origin.d.ts.map +1 -1
- package/dist/tools/schema/presentation.d.ts +6 -0
- package/dist/tools/schema/presentation.d.ts.map +1 -1
- package/dist/tools/schema/schema.d.ts +2 -0
- package/dist/tools/schema/schema.d.ts.map +1 -1
- package/dist/tools/schema/untyped-properties.d.ts.map +1 -1
- package/dist/tools/surface.d.ts.map +1 -1
- package/dist/tools/toolkit.d.ts +6 -3
- package/dist/tools/toolkit.d.ts.map +1 -1
- package/dist/tools/transfer/define-download-tool.d.ts.map +1 -1
- package/dist/tools/transfer/define-upload-tool.d.ts.map +1 -1
- package/dist/tools/transfer/define-view-file-tool.d.ts +2 -1
- package/dist/tools/transfer/define-view-file-tool.d.ts.map +1 -1
- package/dist/tools/transfer/mount-download.d.ts.map +1 -1
- package/dist/tools/transfer/view-file-contract.d.ts +2 -2
- package/dist/tools/transfer/view-file.d.ts +1 -2
- package/dist/tools/transfer/view-file.d.ts.map +1 -1
- package/dist/tracking/client.d.ts +0 -13
- package/dist/tracking/client.d.ts.map +1 -1
- package/dist/tracking/delivery.d.ts.map +1 -1
- package/dist/tracking/performance/collector.d.ts.map +1 -1
- package/llms/agent-executor-acp.txt +51 -0
- package/llms/agent-executor-claude-sdk.txt +31 -0
- package/llms/agent-executor-claude.txt +29 -0
- package/llms/agent-executor-codex.txt +25 -0
- package/llms/agent-executor-testing.txt +26 -0
- package/llms/agent-executor.txt +40 -0
- package/llms/agent-runtime-harness.txt +68 -5
- package/llms/agent-runtime-openrouter.txt +8 -2
- package/llms/agent-runtime-postgres.txt +30 -0
- package/llms/agent-runtime-react.txt +1 -1
- package/llms/agent-runtime-realtime.txt +1 -1
- package/llms/agent-runtime-sandbox.txt +5 -2
- package/llms/agent-runtime-sqlite-bun.txt +2 -2
- package/llms/agent-runtime-sqlite-node.txt +2 -2
- package/llms/agent-runtime-testing.txt +2 -1
- package/llms/agent-runtime.2.txt +450 -501
- package/llms/agent-runtime.3.txt +229 -267
- package/llms/agent-runtime.4.txt +23 -242
- package/llms/agent-runtime.5.txt +1 -1
- package/llms/agent-runtime.txt +551 -2
- package/llms/application-diagnostic-journal.txt +2 -0
- package/llms/application.2.txt +3 -0
- package/llms/application.3.txt +21 -4
- package/llms/application.txt +4 -1
- package/llms/cli.2.txt +259 -99
- package/llms/cli.3.txt +90 -0
- package/llms/cli.txt +95 -184
- package/llms/contract.txt +7 -6
- package/llms/declaration.txt +1 -1
- package/llms/files.txt +11 -0
- package/llms/handler.txt +25 -0
- package/llms/http.txt +18 -1
- package/llms/node.txt +3 -2
- package/llms/observability.2.txt +105 -0
- package/llms/observability.txt +14 -90
- package/llms/primitives.txt +27 -0
- package/llms/process.2.txt +2 -2
- package/llms/process.txt +10 -9
- package/llms/realtime.txt +11 -0
- package/llms/server.2.txt +355 -0
- package/llms/server.4.txt +45 -6
- package/llms/server.5.txt +6 -1
- package/llms/server.txt +143 -256
- package/llms/service-host-macos.txt +53 -0
- package/llms/service-host.txt +69 -0
- package/llms/spend-testing.txt +21 -0
- package/llms/spend.txt +173 -0
- package/llms/stitchkit.2.txt +368 -42
- package/llms/stitchkit.3.txt +164 -13
- package/llms/stitchkit.txt +95 -417
- package/llms/sync-postgres.txt +31 -0
- package/llms/sync.txt +396 -0
- package/llms/telegram-html.txt +4 -1
- package/llms/telegram.2.txt +4 -4
- package/llms/telegram.txt +105 -14
- package/llms/testing.txt +4 -3
- package/llms/tools-connections.txt +4 -4
- package/llms/tools.2.txt +78 -17
- package/llms/tools.3.txt +12 -8
- package/llms/tools.txt +85 -78
- package/llms/upgrading-0.127.0.txt +1059 -0
- package/llms/upgrading.txt +1 -0
- package/llms-full.txt +3557 -531
- package/llms.txt +43 -27
- package/native/darwin-arm64.node +0 -0
- package/native/darwin-x64.node +0 -0
- package/native-assets.json +4 -4
- package/package.json +67 -9
- package/dist/agent-runtime/sandbox-coding.d.ts.map +0 -1
- package/dist/agent-runtime/sqlite-events.d.ts +0 -5
- package/dist/agent-runtime/sqlite-events.d.ts.map +0 -1
- package/dist/agent-runtime/sqlite-history.d.ts +0 -7
- package/dist/agent-runtime/sqlite-history.d.ts.map +0 -1
- package/dist/agent-runtime/sqlite-ledger.d.ts +0 -7
- package/dist/agent-runtime/sqlite-ledger.d.ts.map +0 -1
- package/dist/agent-runtime/sqlite-reads.d.ts +0 -14
- package/dist/agent-runtime/sqlite-reads.d.ts.map +0 -1
- package/dist/agent-runtime/sqlite-rows.d.ts.map +0 -1
- package/dist/agent-runtime/tool-progress.d.ts.map +0 -1
- package/dist/entrypoints/application/schemas.d.ts +0 -15
- package/dist/entrypoints/application/schemas.d.ts.map +0 -1
- package/dist/entrypoints/application/schemas.js +0 -27
- package/dist/index-0s4xebbg.js +0 -8
- package/dist/index-57ppvpw0.js +0 -1150
- package/dist/index-5dmk54h9.js +0 -256
- package/dist/index-7cn66qdk.js +0 -92
- package/dist/index-8x0q6yfb.js +0 -247
- package/dist/index-a5qr2rj6.js +0 -26
- package/dist/index-b0kddvzw.js +0 -35
- package/dist/index-drcjjhy1.js +0 -40
- package/dist/index-eemvahkc.js +0 -21
- package/dist/index-gfk7nrht.js +0 -0
- package/dist/index-jp2qd9jb.js +0 -108
- package/dist/index-nx6eazt0.js +0 -160
- package/dist/index-wxadzdb7.js +0 -55
- package/dist/internal/until-aborted.d.ts +0 -9
- package/dist/internal/until-aborted.d.ts.map +0 -1
- package/dist/server/unix-client-error.d.ts +0 -9
- package/dist/server/unix-client-error.d.ts.map +0 -1
- package/llms/application-schemas.txt +0 -42
|
@@ -1,23 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AgentCodingToolAuthorizationSchema2,
|
|
3
|
-
ShellOutputSchema,
|
|
4
|
-
AgentSandboxRestrictionSchema2,
|
|
5
|
-
AgentSandboxGradeSchema2,
|
|
6
|
-
AGENT_CODING_TOOL_NAMES
|
|
7
|
-
} from "./index-4efxzrht.js";
|
|
8
1
|
import {
|
|
9
2
|
AgentRecordIdSchema2,
|
|
3
|
+
AgentStoreEventEnvelopeSchema2,
|
|
4
|
+
AppendAgentStoreEventSchema2,
|
|
5
|
+
ReadAgentStoreEventsSchema2,
|
|
6
|
+
AgentStoreEventPageSchema2,
|
|
10
7
|
AgentRecordVersionSchema2,
|
|
11
8
|
AgentTimestampSchema2,
|
|
12
9
|
AgentMessageSchema2,
|
|
13
10
|
runStateForTerminalReason2,
|
|
14
11
|
AgentRunSchema2,
|
|
15
12
|
AgentSnapshotSchema2
|
|
16
|
-
} from "./index-
|
|
13
|
+
} from "./index-bn2baakz.js";
|
|
17
14
|
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
AgentCodingToolAuthorizationSchema2,
|
|
16
|
+
ShellOutputSchema,
|
|
17
|
+
ArtifactReadInputSchema,
|
|
18
|
+
ArtifactReadOutputSchema,
|
|
19
|
+
ArtifactSearchInputSchema,
|
|
20
|
+
ArtifactSearchOutputSchema,
|
|
21
|
+
AgentSandboxRestrictionSchema2,
|
|
22
|
+
AgentSandboxGradeSchema2,
|
|
23
|
+
AGENT_CODING_TOOL_NAMES
|
|
24
|
+
} from "./index-wavv538x.js";
|
|
25
|
+
import {
|
|
26
|
+
AgentRuntimeHeadSchema2,
|
|
27
|
+
AgentStoredRunSchema2,
|
|
28
|
+
AgentAdmissionReceiptSchema2,
|
|
29
|
+
AgentSeedReceiptSchema2,
|
|
30
|
+
isActiveRunState,
|
|
31
|
+
emptyHead,
|
|
21
32
|
AgentRunViewSchema2,
|
|
22
33
|
AcceptInputAndAssignRunSchema2,
|
|
23
34
|
AcquireAgentRunSchema2,
|
|
@@ -35,32 +46,86 @@ import {
|
|
|
35
46
|
canonicalAgentJson2,
|
|
36
47
|
encodeAgentConversationArchive2,
|
|
37
48
|
decodeAgentConversationArchive2,
|
|
38
|
-
|
|
49
|
+
conversationOfRun,
|
|
39
50
|
ProviderJournalMessageSchema,
|
|
40
51
|
ProviderJournalRequestSchema,
|
|
41
|
-
ProviderJournalResponseSchema
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
ProviderJournalResponseSchema
|
|
53
|
+
} from "./index-9xr44d2g.js";
|
|
54
|
+
import {
|
|
55
|
+
InvocationStartedSchema,
|
|
56
|
+
InvocationRequestSchema,
|
|
57
|
+
InvocationResponseSchema,
|
|
58
|
+
InvocationFinishedSchema,
|
|
59
|
+
InvocationPayloadReceiptSchema,
|
|
60
|
+
isModelInvocationRecord,
|
|
61
|
+
assistantStatus
|
|
62
|
+
} from "./index-ajmtxsky.js";
|
|
49
63
|
import {
|
|
50
64
|
StepEventPayloadSchema,
|
|
51
65
|
ParkEventPayloadSchema,
|
|
52
66
|
DeliveredEventPayloadSchema,
|
|
53
67
|
EffectEventPayloadSchema
|
|
54
68
|
} from "./index-snef22zr.js";
|
|
69
|
+
import {
|
|
70
|
+
assertPositiveSafeInteger
|
|
71
|
+
} from "./index-kzavdze2.js";
|
|
55
72
|
|
|
56
73
|
// src/agent-runtime/branch-contract.ts
|
|
74
|
+
import { z as z2 } from "zod";
|
|
75
|
+
|
|
76
|
+
// src/agent-runtime/branch-refusal.ts
|
|
57
77
|
import { z } from "zod";
|
|
58
|
-
var
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
78
|
+
var AgentBranchRefusalCodeSchema2 = z.enum([
|
|
79
|
+
"application-key-undeclared",
|
|
80
|
+
"application-key-source-identity",
|
|
81
|
+
"application-file-undeclared",
|
|
82
|
+
"artifact-authorization-missing",
|
|
83
|
+
"event-kind-unknown",
|
|
84
|
+
"integrity"
|
|
85
|
+
]);
|
|
86
|
+
var AgentBranchRefusalSchema2 = z.object({
|
|
87
|
+
code: AgentBranchRefusalCodeSchema2,
|
|
88
|
+
message: z.string().min(1),
|
|
89
|
+
seq: z.int().positive().optional(),
|
|
90
|
+
eventKind: z.string().min(1).optional(),
|
|
91
|
+
messageId: z.string().min(1).optional(),
|
|
92
|
+
toolName: z.string().min(1).optional(),
|
|
93
|
+
key: z.string().min(1).optional(),
|
|
94
|
+
path: z.string().optional(),
|
|
95
|
+
reference: z.string().min(1).optional()
|
|
62
96
|
}).strict();
|
|
63
|
-
var
|
|
97
|
+
var MAX_BRANCH_REFUSALS = 100;
|
|
98
|
+
function addressOf(refusal) {
|
|
99
|
+
const parts = [
|
|
100
|
+
refusal.seq !== undefined && `event ${refusal.seq}${refusal.eventKind ? ` ${refusal.eventKind}` : ""}`,
|
|
101
|
+
refusal.messageId !== undefined && `message ${refusal.messageId}`,
|
|
102
|
+
refusal.toolName !== undefined && `tool ${refusal.toolName}`
|
|
103
|
+
].filter((part) => typeof part === "string");
|
|
104
|
+
return parts.length > 0 ? ` (${parts.join(", ")})` : "";
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
class AgentConversationBranchRefusedError2 extends TypeError {
|
|
108
|
+
refusals;
|
|
109
|
+
omittedRefusals;
|
|
110
|
+
constructor(refusals, omittedRefusals = 0) {
|
|
111
|
+
const [first] = refusals;
|
|
112
|
+
if (!first)
|
|
113
|
+
throw new TypeError("A branch refusal names at least one refusal");
|
|
114
|
+
const more = refusals.length - 1 + omittedRefusals;
|
|
115
|
+
super(`${first.message}${addressOf(first)}${more > 0 ? `; and ${more} more refusal${more === 1 ? "" : "s"}` : ""}`);
|
|
116
|
+
this.name = "AgentConversationBranchRefusedError";
|
|
117
|
+
this.refusals = refusals;
|
|
118
|
+
this.omittedRefusals = omittedRefusals;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// src/agent-runtime/branch-contract.ts
|
|
123
|
+
var Hash = z2.string().regex(/^[a-f0-9]{64}$/);
|
|
124
|
+
var BranchApplicationFileSchema = z2.object({
|
|
125
|
+
reference: z2.string().min(1),
|
|
126
|
+
destinationReference: z2.string().min(1)
|
|
127
|
+
}).strict();
|
|
128
|
+
var BranchApplicationFilesSchema = z2.array(BranchApplicationFileSchema).superRefine((files, ctx) => {
|
|
64
129
|
for (const field of ["reference", "destinationReference"]) {
|
|
65
130
|
const values = files.map((file) => file[field]);
|
|
66
131
|
if (new Set(values).size !== values.length)
|
|
@@ -70,57 +135,313 @@ var BranchApplicationFilesSchema = z.array(BranchApplicationFileSchema).superRef
|
|
|
70
135
|
});
|
|
71
136
|
}
|
|
72
137
|
});
|
|
73
|
-
var
|
|
138
|
+
var BRANCH_RUNTIME_REFERENCE_KEYS = [
|
|
139
|
+
"reference",
|
|
140
|
+
"conversationId",
|
|
141
|
+
"runId",
|
|
142
|
+
"messageId",
|
|
143
|
+
"callId",
|
|
144
|
+
"toolCallId",
|
|
145
|
+
"approvalId",
|
|
146
|
+
"operationId",
|
|
147
|
+
"artifactId"
|
|
148
|
+
];
|
|
149
|
+
var BranchApplicationKeySchema = z2.object({
|
|
150
|
+
key: z2.enum(BRANCH_RUNTIME_REFERENCE_KEYS),
|
|
151
|
+
sourceIdentity: z2.enum(["refuse", "retain"]).default("refuse")
|
|
152
|
+
}).strict();
|
|
153
|
+
var BranchApplicationKeysSchema = z2.array(BranchApplicationKeySchema).superRefine((keys, ctx) => {
|
|
154
|
+
const names = keys.map((entry) => entry.key);
|
|
155
|
+
if (new Set(names).size !== names.length)
|
|
156
|
+
ctx.addIssue({ code: "custom", message: "Branch application keys repeat a key" });
|
|
157
|
+
});
|
|
158
|
+
var BranchAgentConversationInputSchema2 = z2.object({
|
|
74
159
|
requestKey: AgentRecordIdSchema2,
|
|
75
160
|
destinationConversationId: AgentRecordIdSchema2,
|
|
76
|
-
source:
|
|
77
|
-
|
|
78
|
-
kind:
|
|
161
|
+
source: z2.discriminatedUnion("kind", [
|
|
162
|
+
z2.object({
|
|
163
|
+
kind: z2.literal("conversation"),
|
|
79
164
|
conversationId: AgentRecordIdSchema2,
|
|
80
165
|
throughRunId: AgentRecordIdSchema2.optional()
|
|
81
166
|
}).strict(),
|
|
82
|
-
|
|
83
|
-
kind:
|
|
84
|
-
bytes:
|
|
167
|
+
z2.object({
|
|
168
|
+
kind: z2.literal("archive"),
|
|
169
|
+
bytes: z2.custom((value) => value instanceof Uint8Array)
|
|
85
170
|
}).strict()
|
|
86
171
|
]),
|
|
87
172
|
artifactAuthorization: AgentCodingToolAuthorizationSchema2.optional(),
|
|
88
173
|
applicationFiles: BranchApplicationFilesSchema.optional(),
|
|
89
|
-
applicationKeys:
|
|
174
|
+
applicationKeys: BranchApplicationKeysSchema.optional()
|
|
90
175
|
}).strict();
|
|
91
|
-
var AgentConversationBranchReceiptSchema2 =
|
|
92
|
-
schemaVersion:
|
|
176
|
+
var AgentConversationBranchReceiptSchema2 = z2.object({
|
|
177
|
+
schemaVersion: z2.literal(1),
|
|
93
178
|
requestKey: AgentRecordIdSchema2,
|
|
94
179
|
fingerprint: Hash,
|
|
95
180
|
conversationId: AgentRecordIdSchema2,
|
|
96
181
|
sourceConversationId: AgentRecordIdSchema2,
|
|
97
|
-
sourceKind:
|
|
182
|
+
sourceKind: z2.enum(["conversation", "archive"]),
|
|
98
183
|
throughRunId: AgentRecordIdSchema2.optional(),
|
|
99
|
-
sourceSeq:
|
|
100
|
-
sourceVersion:
|
|
184
|
+
sourceSeq: z2.int().nonnegative(),
|
|
185
|
+
sourceVersion: z2.int().nonnegative(),
|
|
101
186
|
sourceDigest: Hash,
|
|
102
187
|
createdAt: AgentTimestampSchema2
|
|
103
188
|
}).strict();
|
|
104
|
-
var AgentConversationBranchResultSchema2 =
|
|
105
|
-
outcome:
|
|
189
|
+
var AgentConversationBranchResultSchema2 = z2.object({
|
|
190
|
+
outcome: z2.enum(["created", "duplicate"]),
|
|
106
191
|
receipt: AgentConversationBranchReceiptSchema2
|
|
107
192
|
}).strict();
|
|
193
|
+
var AgentConversationBranchPlanSchema2 = z2.object({
|
|
194
|
+
ready: z2.boolean(),
|
|
195
|
+
fingerprint: z2.string().regex(/^[a-f0-9]{64}$/),
|
|
196
|
+
sourceArchiveDigest: z2.string().regex(/^[a-f0-9]{64}$/),
|
|
197
|
+
refusals: z2.array(AgentBranchRefusalSchema2),
|
|
198
|
+
omittedRefusals: z2.int().nonnegative(),
|
|
199
|
+
applicationFiles: z2.array(z2.string().min(1)),
|
|
200
|
+
undeclaredKeys: z2.array(z2.string().min(1))
|
|
201
|
+
}).strict();
|
|
202
|
+
|
|
203
|
+
// src/agent-runtime/agent-tool.ts
|
|
204
|
+
function defineAgentTool(definition) {
|
|
205
|
+
return {
|
|
206
|
+
...definition,
|
|
207
|
+
handler: (context) => definition.handler(context)
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// src/agent-runtime/children-contract.ts
|
|
212
|
+
import { z as z4 } from "zod";
|
|
213
|
+
|
|
214
|
+
// src/agent-runtime/sql-rows.ts
|
|
215
|
+
import { z as z3 } from "zod";
|
|
216
|
+
var SqlIntegerSchema = z3.union([z3.number(), z3.bigint(), z3.string().regex(/^-?\d+$/)]).transform(Number).pipe(z3.int());
|
|
217
|
+
var SqlFlagSchema = SqlIntegerSchema.pipe(z3.union([z3.literal(0), z3.literal(1)]));
|
|
218
|
+
var HeadRowSchema = z3.object({
|
|
219
|
+
version: SqlIntegerSchema.pipe(z3.int().nonnegative())
|
|
220
|
+
});
|
|
221
|
+
var RunRowSchema = z3.object({
|
|
222
|
+
payload: z3.string(),
|
|
223
|
+
terminal_assistant_payload: z3.string().nullable()
|
|
224
|
+
});
|
|
225
|
+
var MessageRowSchema = z3.object({ payload: z3.string() });
|
|
226
|
+
var PositionedMessageRowSchema = z3.object({
|
|
227
|
+
position: SqlIntegerSchema.pipe(z3.int().nonnegative())
|
|
228
|
+
});
|
|
229
|
+
var CountRowSchema = z3.object({
|
|
230
|
+
count: SqlIntegerSchema.pipe(z3.int().nonnegative())
|
|
231
|
+
});
|
|
232
|
+
var FlagSchema = SqlFlagSchema;
|
|
233
|
+
var EventRowSchema = z3.object({
|
|
234
|
+
event_id: z3.string(),
|
|
235
|
+
conversation_id: z3.string(),
|
|
236
|
+
seq: SqlIntegerSchema.pipe(z3.int().positive()),
|
|
237
|
+
schema_version: SqlIntegerSchema.pipe(z3.int().positive()),
|
|
238
|
+
kind: z3.string(),
|
|
239
|
+
occurred_at: z3.string(),
|
|
240
|
+
ignorable: SqlFlagSchema,
|
|
241
|
+
payload: z3.string()
|
|
242
|
+
});
|
|
243
|
+
var EVENT_COLUMNS = "event_id, conversation_id, seq, schema_version, kind, occurred_at, ignorable, payload";
|
|
244
|
+
function parseJson(value) {
|
|
245
|
+
return JSON.parse(value);
|
|
246
|
+
}
|
|
247
|
+
function encodeJson(value) {
|
|
248
|
+
return JSON.stringify(value);
|
|
249
|
+
}
|
|
250
|
+
function missing(value) {
|
|
251
|
+
return value === null || value === undefined;
|
|
252
|
+
}
|
|
253
|
+
function placeholders(count) {
|
|
254
|
+
return Array.from({ length: count }, () => "?").join(", ");
|
|
255
|
+
}
|
|
256
|
+
function parseRunRow(value) {
|
|
257
|
+
const row = RunRowSchema.parse(value);
|
|
258
|
+
return AgentStoredRunSchema2.parse({
|
|
259
|
+
schemaVersion: 1,
|
|
260
|
+
run: AgentRunSchema2.parse(parseJson(row.payload)),
|
|
261
|
+
...row.terminal_assistant_payload === null ? {} : {
|
|
262
|
+
terminalAssistant: AgentMessageSchema2.parse(parseJson(row.terminal_assistant_payload))
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
function parseEventRow(value) {
|
|
267
|
+
const row = EventRowSchema.parse(value);
|
|
268
|
+
return AgentStoreEventEnvelopeSchema2.parse({
|
|
269
|
+
schemaVersion: row.schema_version,
|
|
270
|
+
eventId: row.event_id,
|
|
271
|
+
conversationId: row.conversation_id,
|
|
272
|
+
seq: row.seq,
|
|
273
|
+
kind: row.kind,
|
|
274
|
+
occurredAt: row.occurred_at,
|
|
275
|
+
payload: parseJson(row.payload),
|
|
276
|
+
...row.ignorable === 1 && { ignorable: true }
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
async function nextEventSeqByMaximum(dialect, session, conversationId) {
|
|
280
|
+
const row = await session.get(`SELECT COALESCE(MAX(seq), 0) AS count FROM ${dialect.tables.events} WHERE conversation_id = ?`, [conversationId]);
|
|
281
|
+
return CountRowSchema.parse(row).count + 1;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// src/agent-runtime/children-contract.ts
|
|
285
|
+
var AgentChildBudgetSchema2 = z4.object({
|
|
286
|
+
usd: z4.number().positive().optional(),
|
|
287
|
+
tokens: z4.int().positive().optional(),
|
|
288
|
+
milliseconds: z4.int().positive().optional()
|
|
289
|
+
}).strict();
|
|
290
|
+
var AgentChildStateSchema2 = z4.enum([
|
|
291
|
+
"spawned",
|
|
292
|
+
"running",
|
|
293
|
+
"finished",
|
|
294
|
+
"stopped",
|
|
295
|
+
"lost"
|
|
296
|
+
]);
|
|
297
|
+
var ChildUsageMetricsSchema = z4.object({
|
|
298
|
+
tokens: z4.int().nonnegative(),
|
|
299
|
+
usd: z4.number().nonnegative(),
|
|
300
|
+
milliseconds: z4.int().nonnegative()
|
|
301
|
+
}).strict();
|
|
302
|
+
var AgentChildRecordSchema2 = z4.object({
|
|
303
|
+
parentConversationId: z4.string().min(1),
|
|
304
|
+
childConversationId: z4.string().min(1),
|
|
305
|
+
seedUptoSeq: z4.int().nonnegative(),
|
|
306
|
+
state: AgentChildStateSchema2,
|
|
307
|
+
budget: AgentChildBudgetSchema2,
|
|
308
|
+
usage: ChildUsageMetricsSchema,
|
|
309
|
+
resultReference: z4.string().optional(),
|
|
310
|
+
createdAt: z4.string(),
|
|
311
|
+
updatedAt: z4.string()
|
|
312
|
+
}).strict();
|
|
313
|
+
var AgentChildBlockingKindSchema2 = z4.enum(["approval", "input"]);
|
|
314
|
+
var AgentChildBlockingSourceSchema2 = z4.object({
|
|
315
|
+
approvalId: z4.string().min(1),
|
|
316
|
+
callId: z4.string().min(1),
|
|
317
|
+
toolName: z4.string().min(1),
|
|
318
|
+
input: z4.json(),
|
|
319
|
+
kind: AgentChildBlockingKindSchema2.default("approval"),
|
|
320
|
+
batchId: z4.string().min(1).optional()
|
|
321
|
+
}).strict();
|
|
322
|
+
var AgentChildBlockingEventSchema2 = z4.object({
|
|
323
|
+
parentConversationId: z4.string().min(1),
|
|
324
|
+
childConversationId: z4.string().min(1),
|
|
325
|
+
kind: AgentChildBlockingKindSchema2,
|
|
326
|
+
approvalId: z4.string().min(1),
|
|
327
|
+
childApprovalId: z4.string().min(1),
|
|
328
|
+
callId: z4.string().min(1),
|
|
329
|
+
toolName: z4.string().min(1),
|
|
330
|
+
input: z4.json(),
|
|
331
|
+
batchId: z4.string().min(1),
|
|
332
|
+
presentedAt: z4.string()
|
|
333
|
+
}).strict();
|
|
334
|
+
var ChildBlockingDecisionSchema = z4.union([
|
|
335
|
+
z4.object({
|
|
336
|
+
approvalId: z4.string().min(1),
|
|
337
|
+
approved: z4.boolean(),
|
|
338
|
+
reason: z4.string().optional()
|
|
339
|
+
}).strict(),
|
|
340
|
+
z4.object({ approvalId: z4.string().min(1), value: z4.json() }).strict()
|
|
341
|
+
]);
|
|
342
|
+
var ChildSpawnedEventPayloadSchema = z4.object({
|
|
343
|
+
childConversationId: z4.string().min(1),
|
|
344
|
+
seedUptoSeq: z4.int().nonnegative(),
|
|
345
|
+
budget: AgentChildBudgetSchema2
|
|
346
|
+
}).strict();
|
|
347
|
+
var ChildTransitionStateEventPayloadSchema = z4.object({
|
|
348
|
+
childConversationId: z4.string().min(1).optional(),
|
|
349
|
+
parentConversationId: z4.string().min(1).optional(),
|
|
350
|
+
state: AgentChildStateSchema2,
|
|
351
|
+
resultReference: z4.string().min(1).optional(),
|
|
352
|
+
reason: z4.string().optional(),
|
|
353
|
+
policyName: z4.string().min(1).optional(),
|
|
354
|
+
enforced: z4.boolean().optional(),
|
|
355
|
+
stopDurationMs: z4.number().nonnegative().optional(),
|
|
356
|
+
usage: ChildUsageMetricsSchema.optional(),
|
|
357
|
+
overrun: ChildUsageMetricsSchema.optional()
|
|
358
|
+
}).strict().refine((value) => value.childConversationId !== undefined || value.parentConversationId !== undefined, { message: "Child state event requires childConversationId or parentConversationId" });
|
|
359
|
+
var ChildMessageSentEventPayloadSchema = z4.object({
|
|
360
|
+
childConversationId: z4.string().min(1),
|
|
361
|
+
action: z4.literal("message-sent")
|
|
362
|
+
}).strict();
|
|
363
|
+
var ChildBlockingPresentedEventPayloadSchema = z4.object({
|
|
364
|
+
action: z4.literal("blocking-presented"),
|
|
365
|
+
childConversationId: z4.string().min(1),
|
|
366
|
+
approvalId: z4.string().min(1),
|
|
367
|
+
childApprovalId: z4.string().min(1),
|
|
368
|
+
kind: AgentChildBlockingKindSchema2,
|
|
369
|
+
callId: z4.string().min(1),
|
|
370
|
+
toolName: z4.string().min(1),
|
|
371
|
+
input: z4.json(),
|
|
372
|
+
batchId: z4.string().min(1),
|
|
373
|
+
presentedAt: z4.string()
|
|
374
|
+
}).strict();
|
|
375
|
+
var ChildBlockingResolvedApprovalEventPayloadSchema = z4.object({
|
|
376
|
+
action: z4.literal("blocking-resolved"),
|
|
377
|
+
childConversationId: z4.string().min(1),
|
|
378
|
+
approvalId: z4.string().min(1),
|
|
379
|
+
batchId: z4.string().min(1),
|
|
380
|
+
approved: z4.boolean()
|
|
381
|
+
}).strict();
|
|
382
|
+
var ChildBlockingResolvedInputEventPayloadSchema = z4.object({
|
|
383
|
+
action: z4.literal("blocking-resolved"),
|
|
384
|
+
childConversationId: z4.string().min(1),
|
|
385
|
+
approvalId: z4.string().min(1),
|
|
386
|
+
batchId: z4.string().min(1),
|
|
387
|
+
kind: z4.literal("input")
|
|
388
|
+
}).strict();
|
|
389
|
+
var ChildStateEventPayloadSchema = z4.union([
|
|
390
|
+
ChildTransitionStateEventPayloadSchema,
|
|
391
|
+
ChildMessageSentEventPayloadSchema,
|
|
392
|
+
ChildBlockingPresentedEventPayloadSchema,
|
|
393
|
+
ChildBlockingResolvedApprovalEventPayloadSchema,
|
|
394
|
+
ChildBlockingResolvedInputEventPayloadSchema
|
|
395
|
+
]);
|
|
396
|
+
var ChildRowSchema = z4.object({
|
|
397
|
+
parent_conversation_id: z4.string(),
|
|
398
|
+
child_conversation_id: z4.string(),
|
|
399
|
+
seed_upto_seq: SqlIntegerSchema.pipe(z4.int().nonnegative()),
|
|
400
|
+
state: AgentChildStateSchema2,
|
|
401
|
+
budget_payload: z4.string(),
|
|
402
|
+
usage_payload: z4.string(),
|
|
403
|
+
result_reference: z4.string().nullable(),
|
|
404
|
+
created_at: z4.string(),
|
|
405
|
+
updated_at: z4.string()
|
|
406
|
+
});
|
|
407
|
+
function parseChild(raw) {
|
|
408
|
+
const row = ChildRowSchema.parse(raw);
|
|
409
|
+
return AgentChildRecordSchema2.parse({
|
|
410
|
+
parentConversationId: row.parent_conversation_id,
|
|
411
|
+
childConversationId: row.child_conversation_id,
|
|
412
|
+
seedUptoSeq: row.seed_upto_seq,
|
|
413
|
+
state: row.state,
|
|
414
|
+
budget: JSON.parse(row.budget_payload),
|
|
415
|
+
usage: JSON.parse(row.usage_payload),
|
|
416
|
+
...row.result_reference && { resultReference: row.result_reference },
|
|
417
|
+
createdAt: row.created_at,
|
|
418
|
+
updatedAt: row.updated_at
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
function usageNumbers(usage) {
|
|
422
|
+
const inputTokens = usage.inputTokens.value;
|
|
423
|
+
const outputTokens = usage.outputTokens.value;
|
|
424
|
+
return {
|
|
425
|
+
...inputTokens !== undefined && outputTokens !== undefined ? { tokens: inputTokens + outputTokens } : {},
|
|
426
|
+
...usage.cost?.currency === "USD" && usage.cost.value !== undefined ? { usd: usage.cost.value } : {}
|
|
427
|
+
};
|
|
428
|
+
}
|
|
108
429
|
|
|
109
430
|
// src/agent-runtime/purge.ts
|
|
110
|
-
import { z as
|
|
111
|
-
var AgentConversationPurgeInputSchema2 =
|
|
431
|
+
import { z as z5 } from "zod";
|
|
432
|
+
var AgentConversationPurgeInputSchema2 = z5.strictObject({
|
|
112
433
|
conversationId: AgentRecordIdSchema2,
|
|
113
434
|
expectedVersion: AgentRecordVersionSchema2.optional()
|
|
114
435
|
});
|
|
115
|
-
var AgentConversationPurgeResultSchema2 =
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
outcome:
|
|
121
|
-
runIds:
|
|
436
|
+
var AgentConversationPurgeResultSchema2 = z5.discriminatedUnion("outcome", [
|
|
437
|
+
z5.strictObject({ outcome: z5.literal("purged") }),
|
|
438
|
+
z5.strictObject({ outcome: z5.literal("already_purged") }),
|
|
439
|
+
z5.strictObject({ outcome: z5.literal("unsupported") }),
|
|
440
|
+
z5.strictObject({
|
|
441
|
+
outcome: z5.literal("active"),
|
|
442
|
+
runIds: z5.array(AgentRecordIdSchema2).min(1)
|
|
122
443
|
}),
|
|
123
|
-
|
|
444
|
+
z5.strictObject({ outcome: z5.literal("conflict"), actualVersion: AgentRecordVersionSchema2 })
|
|
124
445
|
]);
|
|
125
446
|
|
|
126
447
|
class AgentConversationPurgedError2 extends Error {
|
|
@@ -136,15 +457,659 @@ async function purgeAgentConversation2(store, input) {
|
|
|
136
457
|
return AgentConversationPurgeResultSchema2.parse(await store.purgeConversation(parsed));
|
|
137
458
|
}
|
|
138
459
|
|
|
460
|
+
// src/agent-runtime/deferred-tool-types.ts
|
|
461
|
+
import { z as z6 } from "zod";
|
|
462
|
+
var DeferredAgentToolSearchInputSchema2 = z6.object({
|
|
463
|
+
query: z6.string().min(1).describe("An exact tool name, or words describing the tool. Matched as one phrase first, then word by word."),
|
|
464
|
+
reason: z6.enum(["inactive_call"]).optional().describe("Written by the runtime. Leave it out.")
|
|
465
|
+
});
|
|
466
|
+
var DeferredAgentToolMatchSchema2 = z6.object({
|
|
467
|
+
name: z6.string(),
|
|
468
|
+
description: z6.string()
|
|
469
|
+
});
|
|
470
|
+
var DeferredAgentToolReceiptSchema2 = z6.object({
|
|
471
|
+
schemaVersion: z6.literal(1),
|
|
472
|
+
kind: z6.literal("stitchkit.deferred-tool-selection"),
|
|
473
|
+
status: z6.enum(["SELECTED", "SEARCH_REQUIRED", "NO_MATCH", "SELECTION_REFUSED"]),
|
|
474
|
+
runId: z6.string(),
|
|
475
|
+
surfaceKey: z6.string(),
|
|
476
|
+
selected: z6.array(z6.string()),
|
|
477
|
+
matches: z6.array(DeferredAgentToolMatchSchema2),
|
|
478
|
+
truncated: z6.boolean()
|
|
479
|
+
}).superRefine((receipt, context) => {
|
|
480
|
+
const selected = receipt.status === "SELECTED" || receipt.status === "SEARCH_REQUIRED";
|
|
481
|
+
if (selected !== receipt.selected.length > 0) {
|
|
482
|
+
context.addIssue({
|
|
483
|
+
code: "custom",
|
|
484
|
+
path: ["selected"],
|
|
485
|
+
message: `${receipt.status} receipt has inconsistent selected tools`
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
// src/agent-runtime/event-search.ts
|
|
491
|
+
import { z as z9 } from "zod";
|
|
492
|
+
|
|
493
|
+
// src/agent-runtime/event-search-postgres.ts
|
|
494
|
+
import { z as z8 } from "zod";
|
|
495
|
+
|
|
496
|
+
// src/agent-runtime/event-search-terms.ts
|
|
497
|
+
import { z as z7 } from "zod";
|
|
498
|
+
var MAX_SEARCH_TERMS = 64;
|
|
499
|
+
function extractSearchTerms(query) {
|
|
500
|
+
const terms = query.split(/\s+/u).filter((term) => /[\p{L}\p{N}]/u.test(term));
|
|
501
|
+
if (terms.length === 0)
|
|
502
|
+
throw new TypeError("Event search query must contain searchable terms");
|
|
503
|
+
if (terms.length > MAX_SEARCH_TERMS) {
|
|
504
|
+
throw new TypeError(`Event search query has ${terms.length} terms, at most ${MAX_SEARCH_TERMS} are searched`);
|
|
505
|
+
}
|
|
506
|
+
return terms;
|
|
507
|
+
}
|
|
508
|
+
var SearchRowSchema = z7.object({
|
|
509
|
+
conversation_id: z7.string(),
|
|
510
|
+
event_seq: SqlIntegerSchema.pipe(z7.int().positive()),
|
|
511
|
+
occurred_at: z7.string(),
|
|
512
|
+
snippet: z7.string()
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
// src/agent-runtime/sql-session.ts
|
|
516
|
+
function agentSqlTables(prefix) {
|
|
517
|
+
return {
|
|
518
|
+
meta: `${prefix}_meta`,
|
|
519
|
+
heads: `${prefix}_heads`,
|
|
520
|
+
runs: `${prefix}_runs`,
|
|
521
|
+
admissions: `${prefix}_admissions`,
|
|
522
|
+
messages: `${prefix}_messages`,
|
|
523
|
+
seeds: `${prefix}_seeds`,
|
|
524
|
+
events: `${prefix}_events`,
|
|
525
|
+
eventSeq: `${prefix}_event_seq`,
|
|
526
|
+
projections: `${prefix}_projections`,
|
|
527
|
+
spills: `${prefix}_spills`,
|
|
528
|
+
schedules: `${prefix}_schedules`,
|
|
529
|
+
children: `${prefix}_children`,
|
|
530
|
+
purged: `${prefix}_purged`,
|
|
531
|
+
eventSearch: `${prefix}_event_search`,
|
|
532
|
+
eventSearchState: `${prefix}_event_search_state`
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
function toNumberedPlaceholders(sql) {
|
|
536
|
+
let out = "";
|
|
537
|
+
let index = 0;
|
|
538
|
+
let quote;
|
|
539
|
+
for (const char of sql) {
|
|
540
|
+
if (quote !== undefined) {
|
|
541
|
+
if (char === quote)
|
|
542
|
+
quote = undefined;
|
|
543
|
+
out += char;
|
|
544
|
+
continue;
|
|
545
|
+
}
|
|
546
|
+
if (char === "'" || char === '"') {
|
|
547
|
+
quote = char;
|
|
548
|
+
out += char;
|
|
549
|
+
continue;
|
|
550
|
+
}
|
|
551
|
+
if (char === "?") {
|
|
552
|
+
index += 1;
|
|
553
|
+
out += `$${index}`;
|
|
554
|
+
continue;
|
|
555
|
+
}
|
|
556
|
+
out += char;
|
|
557
|
+
}
|
|
558
|
+
return out;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// src/agent-runtime/postgres-transactions.ts
|
|
562
|
+
var RETRYABLE = new Set(["40001", "40P01"]);
|
|
563
|
+
var MAX_ERROR_DEPTH = 6;
|
|
564
|
+
function* postgresErrorNodes(error, depth = 0, visited = new Set) {
|
|
565
|
+
if (depth >= MAX_ERROR_DEPTH || typeof error !== "object" || error === null)
|
|
566
|
+
return;
|
|
567
|
+
if (visited.has(error))
|
|
568
|
+
return;
|
|
569
|
+
visited.add(error);
|
|
570
|
+
yield error;
|
|
571
|
+
const meta = Reflect.get(error, "meta");
|
|
572
|
+
if (typeof meta === "object" && meta !== null) {
|
|
573
|
+
yield* postgresErrorNodes(Reflect.get(meta, "driverAdapterError"), depth + 1, visited);
|
|
574
|
+
yield* postgresErrorNodes(meta, depth + 1, visited);
|
|
575
|
+
}
|
|
576
|
+
yield* postgresErrorNodes(Reflect.get(error, "cause"), depth + 1, visited);
|
|
577
|
+
}
|
|
578
|
+
function nodeSqlState(node) {
|
|
579
|
+
for (const key of ["errno", "code", "originalCode", "sqlState"]) {
|
|
580
|
+
const field = Reflect.get(node, key);
|
|
581
|
+
if (typeof field === "string" && /^[0-9A-Z]{5}$/.test(field) && !/^P\d{4}$/.test(field)) {
|
|
582
|
+
return field;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
function p2010SqlState(node) {
|
|
588
|
+
if (Reflect.get(node, "code") !== "P2010")
|
|
589
|
+
return;
|
|
590
|
+
const message = Reflect.get(node, "message");
|
|
591
|
+
if (typeof message !== "string")
|
|
592
|
+
return;
|
|
593
|
+
const backticked = /Code:\s*`([0-9A-Z]{5})`/.exec(message);
|
|
594
|
+
if (backticked?.[1] !== undefined && !/^P\d{4}$/.test(backticked[1])) {
|
|
595
|
+
return backticked[1];
|
|
596
|
+
}
|
|
597
|
+
const retryable = /\b(40001|40P01)\b/.exec(message);
|
|
598
|
+
return retryable?.[1];
|
|
599
|
+
}
|
|
600
|
+
function postgresErrorState(error) {
|
|
601
|
+
let fromMessage;
|
|
602
|
+
for (const node of postgresErrorNodes(error)) {
|
|
603
|
+
const direct = nodeSqlState(node);
|
|
604
|
+
if (direct !== undefined)
|
|
605
|
+
return direct;
|
|
606
|
+
fromMessage ??= p2010SqlState(node);
|
|
607
|
+
}
|
|
608
|
+
return fromMessage;
|
|
609
|
+
}
|
|
610
|
+
function isRetryablePostgresConflict(error) {
|
|
611
|
+
const state = postgresErrorState(error);
|
|
612
|
+
if (state !== undefined && RETRYABLE.has(state))
|
|
613
|
+
return true;
|
|
614
|
+
for (const node of postgresErrorNodes(error)) {
|
|
615
|
+
if (Reflect.get(node, "code") === "P2034")
|
|
616
|
+
return true;
|
|
617
|
+
if (Reflect.get(node, "kind") === "TransactionWriteConflict")
|
|
618
|
+
return true;
|
|
619
|
+
}
|
|
620
|
+
return false;
|
|
621
|
+
}
|
|
622
|
+
var POSTGRES_ISOLATION = {
|
|
623
|
+
write: "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE",
|
|
624
|
+
read: "SET TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ ONLY"
|
|
625
|
+
};
|
|
626
|
+
function postgresSession(query, tx) {
|
|
627
|
+
const texts = new Map;
|
|
628
|
+
const text = (sql) => {
|
|
629
|
+
let numbered = texts.get(sql);
|
|
630
|
+
if (numbered === undefined) {
|
|
631
|
+
numbered = toNumberedPlaceholders(sql);
|
|
632
|
+
texts.set(sql, numbered);
|
|
633
|
+
}
|
|
634
|
+
return numbered;
|
|
635
|
+
};
|
|
636
|
+
return {
|
|
637
|
+
all: (sql, parameters = []) => query(tx, text(sql), parameters),
|
|
638
|
+
get: async (sql, parameters = []) => (await query(tx, text(sql), parameters))[0],
|
|
639
|
+
run: async (sql, parameters = []) => {
|
|
640
|
+
await query(tx, text(sql), parameters);
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
function backoff(attempt) {
|
|
645
|
+
const ceiling = Math.min(200, 2 ** attempt);
|
|
646
|
+
return new Promise((resolve) => setTimeout(resolve, Math.random() * ceiling));
|
|
647
|
+
}
|
|
648
|
+
async function setPostgresTransactionIsolation(session, statement) {
|
|
649
|
+
try {
|
|
650
|
+
await session.run(statement);
|
|
651
|
+
} catch (error) {
|
|
652
|
+
if (postgresErrorState(error) === "25001") {
|
|
653
|
+
throw new Error("The Postgres agent store opens its own transactions: `transaction` must start a new one, with no statement run in it before the store's", { cause: error });
|
|
654
|
+
}
|
|
655
|
+
throw error;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
async function runPostgresTransaction(runner, access, work) {
|
|
659
|
+
for (let attempt = 1;; attempt += 1) {
|
|
660
|
+
try {
|
|
661
|
+
return await runner.transaction(async (tx) => {
|
|
662
|
+
const session = postgresSession(runner.query, tx);
|
|
663
|
+
await setPostgresTransactionIsolation(session, runner.isolation[access]);
|
|
664
|
+
return work(session);
|
|
665
|
+
});
|
|
666
|
+
} catch (error) {
|
|
667
|
+
if (attempt >= runner.maxAttempts || !runner.isRetryable(error))
|
|
668
|
+
throw error;
|
|
669
|
+
await backoff(attempt);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
// src/agent-runtime/event-search-postgres.ts
|
|
675
|
+
var BATCH = 500;
|
|
676
|
+
var EventRowSchema2 = z8.object({
|
|
677
|
+
seq: SqlIntegerSchema.pipe(z8.int().positive()),
|
|
678
|
+
occurred_at: z8.string(),
|
|
679
|
+
payload: z8.string()
|
|
680
|
+
});
|
|
681
|
+
var BehindRowSchema = z8.object({
|
|
682
|
+
conversation_id: z8.string(),
|
|
683
|
+
last_seq: SqlIntegerSchema,
|
|
684
|
+
indexed_seq: SqlIntegerSchema
|
|
685
|
+
});
|
|
686
|
+
var MetaRowSchema = z8.object({ value: z8.string() });
|
|
687
|
+
var IndexedRowSchema = z8.object({ indexed_seq: SqlIntegerSchema });
|
|
688
|
+
var CountSchema = z8.object({ count: SqlIntegerSchema });
|
|
689
|
+
function positive(name, value, fallback) {
|
|
690
|
+
assertPositiveSafeInteger(`Event search: ${name}`, value);
|
|
691
|
+
return value ?? fallback;
|
|
692
|
+
}
|
|
693
|
+
async function refuseOtherDiacriticsSettings(session, metaTable, diacritics) {
|
|
694
|
+
if (diacritics === "unaccent") {
|
|
695
|
+
const present = await session.get("SELECT 1 AS present FROM pg_extension WHERE extname = 'unaccent'");
|
|
696
|
+
if (present === undefined) {
|
|
697
|
+
throw new TypeError("Event search: diacritics 'unaccent' needs Postgres's unaccent extension (CREATE EXTENSION unaccent)");
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
const row = await session.get(`SELECT value FROM ${metaTable} WHERE key = 'event_search_diacritics'`);
|
|
701
|
+
if (row === undefined)
|
|
702
|
+
return false;
|
|
703
|
+
const recorded = MetaRowSchema.parse(row).value;
|
|
704
|
+
if (recorded !== diacritics) {
|
|
705
|
+
throw new TypeError(`Event search: the index was built with diacritics '${recorded}', this search asks for '${diacritics}'`);
|
|
706
|
+
}
|
|
707
|
+
return true;
|
|
708
|
+
}
|
|
709
|
+
function postgresEventSearchBackend(host, config = {}) {
|
|
710
|
+
const diacritics = config.diacritics ?? "preserve";
|
|
711
|
+
if (diacritics !== "preserve" && diacritics !== "unaccent") {
|
|
712
|
+
throw new TypeError("Event search: diacritics must be 'preserve' or 'unaccent'");
|
|
713
|
+
}
|
|
714
|
+
const maxIndexedChars = positive("maxIndexedChars", config.maxIndexedChars, 65536);
|
|
715
|
+
const maxSyncEvents = positive("maxSyncEvents", config.maxSyncEvents, 1e4);
|
|
716
|
+
const index = host.tables.eventSearch;
|
|
717
|
+
const state = host.tables.eventSearchState;
|
|
718
|
+
const fold = (expression) => diacritics === "unaccent" ? `unaccent(${expression})` : expression;
|
|
719
|
+
const refuseOtherSettings = (session) => refuseOtherDiacriticsSettings(session, host.tables.meta, diacritics);
|
|
720
|
+
const indexOne = async (session, conversationId, event) => {
|
|
721
|
+
for (let chars = maxIndexedChars;; chars = Math.floor(chars / 2)) {
|
|
722
|
+
await session.run("SAVEPOINT stitchkit_event_search");
|
|
723
|
+
try {
|
|
724
|
+
await session.run(`INSERT INTO ${index} (conversation_id, seq, occurred_at, body, document)
|
|
725
|
+
VALUES (?, ?, ?, left(?, ?), to_tsvector('simple', ${fold("left(?, ?)")}))
|
|
726
|
+
ON CONFLICT (conversation_id, seq) DO NOTHING`, [
|
|
727
|
+
conversationId,
|
|
728
|
+
event.seq,
|
|
729
|
+
event.occurred_at,
|
|
730
|
+
event.payload,
|
|
731
|
+
chars,
|
|
732
|
+
event.payload,
|
|
733
|
+
chars
|
|
734
|
+
]);
|
|
735
|
+
await session.run("RELEASE SAVEPOINT stitchkit_event_search");
|
|
736
|
+
return;
|
|
737
|
+
} catch (error) {
|
|
738
|
+
try {
|
|
739
|
+
await session.run("ROLLBACK TO SAVEPOINT stitchkit_event_search");
|
|
740
|
+
} catch (rollbackError) {
|
|
741
|
+
throw new AggregateError([error, rollbackError], "Event search could not index an event, and its savepoint rollback failed too", { cause: error });
|
|
742
|
+
}
|
|
743
|
+
if (postgresErrorState(error) !== "54000" || chars === 0)
|
|
744
|
+
throw error;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
const catchUp = (conversationId, budget) => host.transaction(conversationId, async (scope) => {
|
|
749
|
+
if (!await refuseOtherSettings(scope)) {
|
|
750
|
+
await scope.run(`INSERT INTO ${host.tables.meta} (key, value) VALUES ('event_search_diacritics', ?)
|
|
751
|
+
ON CONFLICT (key) DO NOTHING`, [diacritics]);
|
|
752
|
+
await refuseOtherSettings(scope);
|
|
753
|
+
}
|
|
754
|
+
const done = await scope.get(`SELECT indexed_seq FROM ${state} WHERE conversation_id = ?`, [conversationId]);
|
|
755
|
+
const from = done === undefined ? 0 : IndexedRowSchema.parse(done).indexed_seq;
|
|
756
|
+
const events = (await scope.all(`SELECT seq, occurred_at, payload FROM ${host.tables.events}
|
|
757
|
+
WHERE conversation_id = ? AND seq > ? ORDER BY seq LIMIT ?`, [conversationId, from, Math.min(budget, BATCH)])).map((row) => EventRowSchema2.parse(row));
|
|
758
|
+
for (const event of events)
|
|
759
|
+
await indexOne(scope, conversationId, event);
|
|
760
|
+
const last = events.at(-1);
|
|
761
|
+
if (last !== undefined) {
|
|
762
|
+
await scope.run(`INSERT INTO ${state} (conversation_id, indexed_seq) VALUES (?, ?)
|
|
763
|
+
ON CONFLICT (conversation_id) DO UPDATE SET indexed_seq = excluded.indexed_seq`, [conversationId, last.seq]);
|
|
764
|
+
}
|
|
765
|
+
return events.length;
|
|
766
|
+
}).catch((error) => {
|
|
767
|
+
if (error instanceof AgentConversationPurgedError2)
|
|
768
|
+
return 0;
|
|
769
|
+
throw error;
|
|
770
|
+
});
|
|
771
|
+
const behind = (target) => host.read(async (session) => (await session.all(`SELECT q.conversation_id, q.last_seq, COALESCE(s.indexed_seq, 0) AS indexed_seq
|
|
772
|
+
FROM ${host.tables.eventSeq} q LEFT JOIN ${state} s USING (conversation_id)
|
|
773
|
+
WHERE q.last_seq > COALESCE(s.indexed_seq, 0)
|
|
774
|
+
${target === undefined ? "" : "AND q.conversation_id = ?"}
|
|
775
|
+
ORDER BY q.conversation_id`, target === undefined ? [] : [target])).map((row) => BehindRowSchema.parse(row)));
|
|
776
|
+
const sync = async (target) => {
|
|
777
|
+
let budget = maxSyncEvents;
|
|
778
|
+
const initial = await behind(target);
|
|
779
|
+
if (initial.length === 0)
|
|
780
|
+
return;
|
|
781
|
+
const watermarks = new Map(initial.map((row) => [row.conversation_id, row.last_seq]));
|
|
782
|
+
for (const conversation of initial) {
|
|
783
|
+
let pending = conversation.last_seq - conversation.indexed_seq;
|
|
784
|
+
while (pending > 0 && budget > 0) {
|
|
785
|
+
const indexed = await catchUp(conversation.conversation_id, budget);
|
|
786
|
+
if (indexed === 0)
|
|
787
|
+
break;
|
|
788
|
+
pending -= indexed;
|
|
789
|
+
budget -= indexed;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
const left = (await behind(target)).reduce((sum, row) => {
|
|
793
|
+
const watermark = watermarks.get(row.conversation_id);
|
|
794
|
+
if (watermark === undefined)
|
|
795
|
+
return sum;
|
|
796
|
+
return sum + Math.max(0, watermark - row.indexed_seq);
|
|
797
|
+
}, 0);
|
|
798
|
+
if (left > 0) {
|
|
799
|
+
throw new TypeError(`Event search: the index is ${left} events behind after indexing ${maxSyncEvents - budget}; search again to continue`);
|
|
800
|
+
}
|
|
801
|
+
};
|
|
802
|
+
return {
|
|
803
|
+
async prepare(request) {
|
|
804
|
+
await host.read(async (session) => {
|
|
805
|
+
await refuseOtherSettings(session);
|
|
806
|
+
for (const term of request.terms) {
|
|
807
|
+
const row = await session.get(`SELECT numnode(phraseto_tsquery('simple', ${fold("?")})) AS count`, [term]);
|
|
808
|
+
if (CountSchema.parse(row).count === 0) {
|
|
809
|
+
throw new TypeError("Event search query must contain searchable terms");
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
});
|
|
813
|
+
await sync(request.target);
|
|
814
|
+
},
|
|
815
|
+
async candidates(request) {
|
|
816
|
+
return host.read(async (session) => {
|
|
817
|
+
const query = request.terms.map(() => `phraseto_tsquery('simple', ${fold("?")})`).join(" && ");
|
|
818
|
+
const values = [...request.terms];
|
|
819
|
+
if (request.target)
|
|
820
|
+
values.push(request.target);
|
|
821
|
+
if (request.since)
|
|
822
|
+
values.push(request.since);
|
|
823
|
+
const rows = await session.all(`SELECT s.conversation_id, s.seq AS event_seq, s.occurred_at,
|
|
824
|
+
ts_headline('simple', ${fold("s.body")}, q.query,
|
|
825
|
+
'StartSel=[, StopSel=], MaxWords=24, MinWords=8, MaxFragments=2, FragmentDelimiter=" … "') AS snippet
|
|
826
|
+
FROM ${index} s, (SELECT ${query} AS query) q
|
|
827
|
+
WHERE s.document @@ q.query
|
|
828
|
+
${request.target ? "AND s.conversation_id = ?" : ""}
|
|
829
|
+
${request.since ? "AND s.occurred_at::timestamptz >= ?::timestamptz" : ""}
|
|
830
|
+
ORDER BY ts_rank_cd(s.document, q.query) DESC, s.occurred_at DESC, s.seq
|
|
831
|
+
LIMIT ? OFFSET ?`, [...values, request.limit, request.offset]);
|
|
832
|
+
return rows.map((row) => SearchRowSchema.parse(row));
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
// src/agent-runtime/event-search.ts
|
|
839
|
+
var AgentEventSearchResultSchema2 = z9.object({
|
|
840
|
+
conversationId: z9.string().min(1),
|
|
841
|
+
seq: z9.int().positive(),
|
|
842
|
+
occurredAt: z9.string(),
|
|
843
|
+
snippet: z9.string()
|
|
844
|
+
}).strict();
|
|
845
|
+
function sqliteBackend(host) {
|
|
846
|
+
const fts = `${host.tables.events}_fts`;
|
|
847
|
+
return {
|
|
848
|
+
async candidates(request) {
|
|
849
|
+
const values = [
|
|
850
|
+
request.terms.map((term) => `"${term.replaceAll('"', '""')}"`).join(" AND ")
|
|
851
|
+
];
|
|
852
|
+
if (request.target)
|
|
853
|
+
values.push(request.target);
|
|
854
|
+
if (request.since)
|
|
855
|
+
values.push(request.since);
|
|
856
|
+
const rows = await host.read((session) => session.all(`SELECT f.conversation_id, f.event_seq, f.occurred_at,
|
|
857
|
+
snippet(${fts}, 3, '[', ']', ' … ', 24) AS snippet
|
|
858
|
+
FROM ${fts} AS f
|
|
859
|
+
WHERE ${fts} MATCH ?
|
|
860
|
+
${request.target ? "AND f.conversation_id = ?" : ""}
|
|
861
|
+
${request.since ? "AND f.occurred_at >= ?" : ""}
|
|
862
|
+
ORDER BY bm25(${fts}), f.occurred_at DESC, f.rowid
|
|
863
|
+
LIMIT ? OFFSET ?`, [...values, request.limit, request.offset]));
|
|
864
|
+
return rows.map((row) => SearchRowSchema.parse(row));
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
function createAgentEventSearch2(input) {
|
|
869
|
+
const { host } = input;
|
|
870
|
+
if (host.dialect === "sqlite" && input.postgres !== undefined) {
|
|
871
|
+
throw new TypeError("Event search: `postgres` options apply to the Postgres store only");
|
|
872
|
+
}
|
|
873
|
+
const backend = host.dialect === "sqlite" ? sqliteBackend(host) : postgresEventSearchBackend(host, input.postgres);
|
|
874
|
+
return async (request) => {
|
|
875
|
+
if (request.query.trim().length === 0)
|
|
876
|
+
throw new TypeError("Event search query must not be empty");
|
|
877
|
+
const terms = extractSearchTerms(request.query);
|
|
878
|
+
if (request.limit !== undefined) {
|
|
879
|
+
assertPositiveSafeInteger("Event search limit", request.limit, TypeError);
|
|
880
|
+
}
|
|
881
|
+
const limit = Math.min(request.limit ?? 20, 200);
|
|
882
|
+
const target = request.conversationId ?? (input.authorizeConversation ? undefined : request.requestingConversationId);
|
|
883
|
+
const since = request.since ? z9.iso.datetime({ offset: true }).parse(request.since) : undefined;
|
|
884
|
+
await backend.prepare?.({ terms, ...target !== undefined && { target } });
|
|
885
|
+
const page = limit * 4;
|
|
886
|
+
const candidatesFrom = (offset) => backend.candidates({
|
|
887
|
+
terms,
|
|
888
|
+
...target !== undefined && { target },
|
|
889
|
+
...since !== undefined && { since },
|
|
890
|
+
limit: page,
|
|
891
|
+
offset
|
|
892
|
+
});
|
|
893
|
+
const authorization = new Map;
|
|
894
|
+
const results = [];
|
|
895
|
+
let offset = 0;
|
|
896
|
+
let candidates = await candidatesFrom(offset);
|
|
897
|
+
while (candidates.length > 0 && results.length < limit) {
|
|
898
|
+
for (const row of candidates) {
|
|
899
|
+
if (row.conversation_id !== request.requestingConversationId) {
|
|
900
|
+
let allowed = authorization.get(row.conversation_id);
|
|
901
|
+
if (allowed === undefined) {
|
|
902
|
+
allowed = input.authorizeConversation ? await input.authorizeConversation({
|
|
903
|
+
requestingConversationId: request.requestingConversationId,
|
|
904
|
+
targetConversationId: row.conversation_id
|
|
905
|
+
}) : false;
|
|
906
|
+
authorization.set(row.conversation_id, allowed);
|
|
907
|
+
}
|
|
908
|
+
if (!allowed)
|
|
909
|
+
continue;
|
|
910
|
+
}
|
|
911
|
+
results.push(AgentEventSearchResultSchema2.parse({
|
|
912
|
+
conversationId: row.conversation_id,
|
|
913
|
+
seq: row.event_seq,
|
|
914
|
+
occurredAt: row.occurred_at,
|
|
915
|
+
snippet: row.snippet
|
|
916
|
+
}));
|
|
917
|
+
if (results.length === limit)
|
|
918
|
+
break;
|
|
919
|
+
}
|
|
920
|
+
offset += page;
|
|
921
|
+
candidates = results.length < limit ? await candidatesFrom(offset) : [];
|
|
922
|
+
}
|
|
923
|
+
return results;
|
|
924
|
+
};
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
// src/agent-runtime/event-search-tools.ts
|
|
928
|
+
import { z as z10 } from "zod";
|
|
929
|
+
var AGENT_EVENT_SEARCH_TOOL_NAMES = {
|
|
930
|
+
search: "session_search",
|
|
931
|
+
trace: "session_trace",
|
|
932
|
+
event: "session_event"
|
|
933
|
+
};
|
|
934
|
+
var EventAddressSchema = z10.object({ conversationId: z10.string(), seq: z10.int().positive() }).strict();
|
|
935
|
+
var EventOutputSchema = z10.object({
|
|
936
|
+
conversationId: z10.string(),
|
|
937
|
+
seq: z10.int().positive(),
|
|
938
|
+
kind: z10.string(),
|
|
939
|
+
occurredAt: z10.string(),
|
|
940
|
+
payload: z10.json()
|
|
941
|
+
}).strict();
|
|
942
|
+
var SearchInputSchema = z10.object({
|
|
943
|
+
query: z10.string().min(1),
|
|
944
|
+
conversationId: z10.string().min(1).optional(),
|
|
945
|
+
since: z10.iso.datetime({ offset: true }).optional(),
|
|
946
|
+
limit: z10.int().positive().max(200).optional()
|
|
947
|
+
}).strict();
|
|
948
|
+
var SearchOutputSchema = z10.object({ results: z10.array(AgentEventSearchResultSchema2) }).strict();
|
|
949
|
+
var TraceInputSchema = z10.object({
|
|
950
|
+
fromSeq: z10.int().positive().optional(),
|
|
951
|
+
toSeq: z10.int().positive().optional(),
|
|
952
|
+
limit: z10.int().positive().max(1000).default(100)
|
|
953
|
+
}).strict();
|
|
954
|
+
var TraceOutputSchema = z10.object({ events: z10.array(EventOutputSchema), nextSeq: z10.number().optional() }).strict();
|
|
955
|
+
var AGENT_EVENT_SEARCH_TOOL_SCHEMAS = {
|
|
956
|
+
[AGENT_EVENT_SEARCH_TOOL_NAMES.search]: {
|
|
957
|
+
input: SearchInputSchema,
|
|
958
|
+
output: SearchOutputSchema
|
|
959
|
+
},
|
|
960
|
+
[AGENT_EVENT_SEARCH_TOOL_NAMES.trace]: {
|
|
961
|
+
input: TraceInputSchema,
|
|
962
|
+
output: TraceOutputSchema
|
|
963
|
+
},
|
|
964
|
+
[AGENT_EVENT_SEARCH_TOOL_NAMES.event]: {
|
|
965
|
+
input: EventAddressSchema,
|
|
966
|
+
output: EventOutputSchema
|
|
967
|
+
}
|
|
968
|
+
};
|
|
969
|
+
function createAgentEventSearchTools2(config) {
|
|
970
|
+
const input = {
|
|
971
|
+
...config,
|
|
972
|
+
conversationId: conversationOfRun(config.run, "createAgentEventSearchTools")
|
|
973
|
+
};
|
|
974
|
+
const readExact = async (address) => {
|
|
975
|
+
if (address.conversationId !== input.conversationId) {
|
|
976
|
+
const allowed = await input.authorizeConversation?.({
|
|
977
|
+
requestingConversationId: input.conversationId,
|
|
978
|
+
targetConversationId: address.conversationId
|
|
979
|
+
});
|
|
980
|
+
if (!allowed)
|
|
981
|
+
throw new TypeError("Event address is outside the authorized conversation");
|
|
982
|
+
}
|
|
983
|
+
const page = await input.store.readEvents({
|
|
984
|
+
conversationId: address.conversationId,
|
|
985
|
+
fromSeq: address.seq,
|
|
986
|
+
toSeq: address.seq,
|
|
987
|
+
limit: 1
|
|
988
|
+
});
|
|
989
|
+
const event = page.items[0];
|
|
990
|
+
if (!event || event.seq !== address.seq)
|
|
991
|
+
throw new TypeError("Unknown event address");
|
|
992
|
+
return {
|
|
993
|
+
conversationId: event.conversationId,
|
|
994
|
+
seq: event.seq,
|
|
995
|
+
kind: event.kind,
|
|
996
|
+
occurredAt: event.occurredAt,
|
|
997
|
+
payload: event.payload
|
|
998
|
+
};
|
|
999
|
+
};
|
|
1000
|
+
return [
|
|
1001
|
+
defineAgentTool({
|
|
1002
|
+
name: AGENT_EVENT_SEARCH_TOOL_NAMES.search,
|
|
1003
|
+
description: "Search authorized durable conversation events and return exact addresses.",
|
|
1004
|
+
identity: { serviceName: "agent-events", action: "search", method: "POST" },
|
|
1005
|
+
input: SearchInputSchema,
|
|
1006
|
+
output: SearchOutputSchema,
|
|
1007
|
+
expose: ["AGENT"],
|
|
1008
|
+
handler: async ({ input: request }) => ({
|
|
1009
|
+
results: [
|
|
1010
|
+
...await input.search({
|
|
1011
|
+
requestingConversationId: input.conversationId,
|
|
1012
|
+
...request
|
|
1013
|
+
})
|
|
1014
|
+
]
|
|
1015
|
+
})
|
|
1016
|
+
}),
|
|
1017
|
+
defineAgentTool({
|
|
1018
|
+
name: AGENT_EVENT_SEARCH_TOOL_NAMES.trace,
|
|
1019
|
+
description: "Read a bounded contiguous slice of this conversation event trace.",
|
|
1020
|
+
identity: { serviceName: "agent-events", action: "trace", method: "GET" },
|
|
1021
|
+
input: TraceInputSchema,
|
|
1022
|
+
output: TraceOutputSchema,
|
|
1023
|
+
expose: ["AGENT"],
|
|
1024
|
+
handler: async ({ input: request }) => {
|
|
1025
|
+
const page = await input.store.readEvents({
|
|
1026
|
+
conversationId: input.conversationId,
|
|
1027
|
+
...request
|
|
1028
|
+
});
|
|
1029
|
+
return {
|
|
1030
|
+
events: page.items.map((event) => ({
|
|
1031
|
+
conversationId: event.conversationId,
|
|
1032
|
+
seq: event.seq,
|
|
1033
|
+
kind: event.kind,
|
|
1034
|
+
occurredAt: event.occurredAt,
|
|
1035
|
+
payload: event.payload
|
|
1036
|
+
})),
|
|
1037
|
+
...page.nextSeq !== undefined && { nextSeq: page.nextSeq }
|
|
1038
|
+
};
|
|
1039
|
+
}
|
|
1040
|
+
}),
|
|
1041
|
+
defineAgentTool({
|
|
1042
|
+
name: AGENT_EVENT_SEARCH_TOOL_NAMES.event,
|
|
1043
|
+
description: "Read one durable event by exact conversation and sequence address.",
|
|
1044
|
+
identity: { serviceName: "agent-events", action: "read", method: "GET" },
|
|
1045
|
+
input: EventAddressSchema,
|
|
1046
|
+
output: EventOutputSchema,
|
|
1047
|
+
expose: ["AGENT"],
|
|
1048
|
+
handler: ({ input: request }) => readExact(request)
|
|
1049
|
+
})
|
|
1050
|
+
];
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
// src/agent-runtime/store-capabilities.ts
|
|
1054
|
+
import { z as z11 } from "zod";
|
|
1055
|
+
var AgentStoreOptionalCapabilitySchema = z11.enum(["archive", "historyRestore"]);
|
|
1056
|
+
var AgentRuntimeStoreCapabilitiesSchema = z11.strictObject({
|
|
1057
|
+
archive: z11.boolean(),
|
|
1058
|
+
historyRestore: z11.boolean(),
|
|
1059
|
+
purge: z11.boolean()
|
|
1060
|
+
});
|
|
1061
|
+
|
|
1062
|
+
class AgentStoreUnsupportedCapabilityError2 extends TypeError {
|
|
1063
|
+
capability;
|
|
1064
|
+
constructor(capability, need) {
|
|
1065
|
+
super(`The agent store driver does not implement ${capability === "archive" ? "archive" : "history.restore"}: ${need}`);
|
|
1066
|
+
this.name = "AgentStoreUnsupportedCapabilityError";
|
|
1067
|
+
this.capability = capability;
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
function driverCapabilities(driver) {
|
|
1071
|
+
const archive = driver.archive;
|
|
1072
|
+
if (archive !== undefined && (typeof archive.export !== "function" || typeof archive.import !== "function"))
|
|
1073
|
+
throw new TypeError("An agent store driver archive needs both export and import");
|
|
1074
|
+
if (driver.history.restore !== undefined && typeof driver.history.restore !== "function")
|
|
1075
|
+
throw new TypeError("An agent store driver history.restore must be a function");
|
|
1076
|
+
return Object.freeze(AgentRuntimeStoreCapabilitiesSchema.parse({
|
|
1077
|
+
archive: archive !== undefined,
|
|
1078
|
+
historyRestore: driver.history.restore !== undefined,
|
|
1079
|
+
purge: driver.conversations !== undefined
|
|
1080
|
+
}));
|
|
1081
|
+
}
|
|
1082
|
+
function assertSourceCapabilities(driver, source) {
|
|
1083
|
+
if (!driver.archive && source.spills > 0)
|
|
1084
|
+
throw new AgentStoreUnsupportedCapabilityError2("archive", "the source carries spills");
|
|
1085
|
+
if (!driver.archive && source.projections > 0)
|
|
1086
|
+
throw new AgentStoreUnsupportedCapabilityError2("archive", "the source carries companion projections");
|
|
1087
|
+
if (!driver.history.restore && source.compacted > 0)
|
|
1088
|
+
throw new AgentStoreUnsupportedCapabilityError2("historyRestore", "the source baseline carries compacted history");
|
|
1089
|
+
}
|
|
1090
|
+
|
|
139
1091
|
// src/agent-runtime/store-create.ts
|
|
140
|
-
import { z as
|
|
1092
|
+
import { z as z24 } from "zod";
|
|
141
1093
|
|
|
142
1094
|
// src/agent-runtime/store-archive.ts
|
|
143
|
-
import { z as
|
|
1095
|
+
import { z as z14 } from "zod";
|
|
1096
|
+
|
|
1097
|
+
// src/agent-runtime/archive-projection.ts
|
|
1098
|
+
import { z as z12 } from "zod";
|
|
1099
|
+
var ArchiveProjectionSchema = z12.object({
|
|
1100
|
+
name: z12.string(),
|
|
1101
|
+
version: z12.int().positive(),
|
|
1102
|
+
uptoSeq: z12.int().nonnegative(),
|
|
1103
|
+
value: z12.json(),
|
|
1104
|
+
updatedAt: z12.string()
|
|
1105
|
+
}).strict();
|
|
1106
|
+
function isRuntimeSnapshotEntry(entry) {
|
|
1107
|
+
return typeof entry === "object" && entry !== null && !Array.isArray(entry) && Reflect.get(entry, "archiveType") === "runtime-snapshot" && "snapshot" in entry;
|
|
1108
|
+
}
|
|
144
1109
|
|
|
145
1110
|
// src/agent-runtime/branch-replay.ts
|
|
146
1111
|
import { createHash as createHash2 } from "node:crypto";
|
|
147
|
-
import { z as
|
|
1112
|
+
import { z as z13 } from "zod";
|
|
148
1113
|
|
|
149
1114
|
// src/agent-runtime/store-reducer.ts
|
|
150
1115
|
import { createHash } from "node:crypto";
|
|
@@ -594,9 +1559,16 @@ function reduceTerminal(current, run, input) {
|
|
|
594
1559
|
// src/agent-runtime/store-reducer.ts
|
|
595
1560
|
function transitionRecord(operation, reduced) {
|
|
596
1561
|
if (operation.type === "recover" && operation.input.action === "abandon") {
|
|
597
|
-
const
|
|
598
|
-
|
|
599
|
-
|
|
1562
|
+
const record = reduced?.runRecords?.find((candidate) => candidate.run.id === operation.input.runId);
|
|
1563
|
+
const assistant = record?.terminalAssistant;
|
|
1564
|
+
const usage = record?.run.usage;
|
|
1565
|
+
if (assistant || usage) {
|
|
1566
|
+
return {
|
|
1567
|
+
...operation,
|
|
1568
|
+
...assistant && { assistant },
|
|
1569
|
+
...usage && { usage }
|
|
1570
|
+
};
|
|
1571
|
+
}
|
|
600
1572
|
}
|
|
601
1573
|
if (operation.type !== "checkpoint")
|
|
602
1574
|
return operation;
|
|
@@ -646,14 +1618,14 @@ function operationConversationId(operation) {
|
|
|
646
1618
|
}
|
|
647
1619
|
|
|
648
1620
|
// src/agent-runtime/branch-replay.ts
|
|
649
|
-
var BranchBaselineSchema =
|
|
650
|
-
migratedAt:
|
|
651
|
-
asOf:
|
|
1621
|
+
var BranchBaselineSchema = z13.object({
|
|
1622
|
+
migratedAt: z13.iso.datetime({ offset: true }),
|
|
1623
|
+
asOf: z13.iso.datetime({ offset: true }).optional(),
|
|
652
1624
|
head: AgentRuntimeHeadSchema2,
|
|
653
|
-
messages:
|
|
654
|
-
compacted:
|
|
655
|
-
runs:
|
|
656
|
-
admissions:
|
|
1625
|
+
messages: z13.array(AgentMessageSchema2),
|
|
1626
|
+
compacted: z13.array(z13.string().min(1)).optional(),
|
|
1627
|
+
runs: z13.array(AgentStoredRunSchema2),
|
|
1628
|
+
admissions: z13.array(AgentAdmissionReceiptSchema2)
|
|
657
1629
|
}).strict();
|
|
658
1630
|
function branchTransition(event) {
|
|
659
1631
|
const checkpoint = AgentStoreCheckpointRecordSchema.safeParse(event.payload);
|
|
@@ -866,6 +1838,8 @@ async function persistRuntimeReplay(driver, tx, replay) {
|
|
|
866
1838
|
messages: baseline.messages,
|
|
867
1839
|
compactedMessageIds: baseline.compacted ?? []
|
|
868
1840
|
});
|
|
1841
|
+
else if (baseline.compacted?.length)
|
|
1842
|
+
throw new AgentStoreUnsupportedCapabilityError2("historyRestore", "the baseline carries compacted history");
|
|
869
1843
|
else
|
|
870
1844
|
for (const message of baseline.messages)
|
|
871
1845
|
await driver.history.apply(tx, { type: "admit", input: message });
|
|
@@ -892,6 +1866,17 @@ function exportConversation(driver, conversationId) {
|
|
|
892
1866
|
}
|
|
893
1867
|
async function importConversation(driver, bytes) {
|
|
894
1868
|
const archive = decodeAgentConversationArchive2(bytes);
|
|
1869
|
+
const snapshotEntry = archive.projections.find(isRuntimeSnapshotEntry);
|
|
1870
|
+
const snapshot = snapshotEntry === undefined ? undefined : AgentSnapshotSchema2.parse(snapshotEntry.snapshot);
|
|
1871
|
+
if (snapshot && snapshot.conversationId !== archive.conversationId) {
|
|
1872
|
+
throw new TypeError("Conversation archive snapshot belongs to another conversation");
|
|
1873
|
+
}
|
|
1874
|
+
const replay = snapshot && replayBranchEvents(archive.conversationId, archive.events, snapshot);
|
|
1875
|
+
assertSourceCapabilities(driver, {
|
|
1876
|
+
spills: archive.spills.length,
|
|
1877
|
+
projections: archive.projections.filter((entry) => !isRuntimeSnapshotEntry(entry)).length,
|
|
1878
|
+
compacted: replay?.baseline?.compacted?.length ?? 0
|
|
1879
|
+
});
|
|
895
1880
|
return driver.transaction(async (transaction) => {
|
|
896
1881
|
const existing = await driver.events.list(transaction, {
|
|
897
1882
|
conversationId: archive.conversationId,
|
|
@@ -914,12 +1899,7 @@ async function importConversation(driver, bytes) {
|
|
|
914
1899
|
throw new TypeError("Conversation archive event sequence is not contiguous");
|
|
915
1900
|
}
|
|
916
1901
|
}
|
|
917
|
-
|
|
918
|
-
if (snapshotEntry && typeof snapshotEntry === "object" && !Array.isArray(snapshotEntry)) {
|
|
919
|
-
const snapshot = AgentSnapshotSchema2.parse(snapshotEntry.snapshot);
|
|
920
|
-
if (snapshot.conversationId !== archive.conversationId) {
|
|
921
|
-
throw new TypeError("Conversation archive snapshot belongs to another conversation");
|
|
922
|
-
}
|
|
1902
|
+
if (snapshot && replay) {
|
|
923
1903
|
if (snapshot.version > 0 || snapshot.messages.length > 0 || snapshot.runs.length > 0) {
|
|
924
1904
|
const outcome = await driver.head.compareAndSwap(transaction, {
|
|
925
1905
|
conversationId: snapshot.conversationId,
|
|
@@ -934,7 +1914,6 @@ async function importConversation(driver, bytes) {
|
|
|
934
1914
|
throw new TypeError("Conversation archive snapshot target is not empty");
|
|
935
1915
|
}
|
|
936
1916
|
}
|
|
937
|
-
const replay = replayBranchEvents(archive.conversationId, archive.events, snapshot);
|
|
938
1917
|
await persistRuntimeReplay(driver, transaction, replay);
|
|
939
1918
|
for (const run of snapshot.runs) {
|
|
940
1919
|
const terminalAssistant = snapshot.messages.find((message) => message.id === run.assistantMessageId);
|
|
@@ -979,7 +1958,7 @@ async function exportConversationIn(driver, transaction, conversationId) {
|
|
|
979
1958
|
conversationId,
|
|
980
1959
|
events,
|
|
981
1960
|
projections: [
|
|
982
|
-
{ archiveType: "runtime-snapshot", snapshot:
|
|
1961
|
+
{ archiveType: "runtime-snapshot", snapshot: z14.json().parse(snapshot) },
|
|
983
1962
|
...durable.projections
|
|
984
1963
|
],
|
|
985
1964
|
spills: durable.spills
|
|
@@ -988,82 +1967,148 @@ async function exportConversationIn(driver, transaction, conversationId) {
|
|
|
988
1967
|
|
|
989
1968
|
// src/agent-runtime/store-branch.ts
|
|
990
1969
|
import { createHash as createHash7 } from "node:crypto";
|
|
991
|
-
import { z as
|
|
1970
|
+
import { z as z22 } from "zod";
|
|
992
1971
|
|
|
993
1972
|
// src/agent-runtime/branch-events.ts
|
|
994
|
-
import { z as
|
|
1973
|
+
import { z as z19 } from "zod";
|
|
995
1974
|
|
|
996
1975
|
// src/agent-runtime/branch-messages.ts
|
|
997
|
-
import { z as
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
for (const key of [
|
|
1003
|
-
"reference",
|
|
1004
|
-
"conversationId",
|
|
1005
|
-
"runId",
|
|
1006
|
-
"messageId",
|
|
1007
|
-
"callId",
|
|
1008
|
-
"toolCallId",
|
|
1009
|
-
"approvalId",
|
|
1010
|
-
"operationId",
|
|
1011
|
-
"artifactId"
|
|
1012
|
-
]) {
|
|
1013
|
-
if (!(key in value))
|
|
1014
|
-
continue;
|
|
1015
|
-
const entry = value[key];
|
|
1016
|
-
if (!ids.isApplicationKey(key))
|
|
1017
|
-
throw new TypeError(`Branch cannot rekey an opaque payload containing ${key}; declare it in applicationKeys if it is application data`);
|
|
1018
|
-
if (typeof entry === "string" && ids.isSourceIdentity(entry))
|
|
1019
|
-
throw new TypeError(`Branch cannot carry a source identity under the application key ${key}`);
|
|
1020
|
-
}
|
|
1021
|
-
for (const entry of Object.values(value))
|
|
1022
|
-
branchOpaqueJson(ids, entry);
|
|
1023
|
-
}
|
|
1024
|
-
return value;
|
|
1025
|
-
}
|
|
1026
|
-
var ArtifactReadSchema = z5.object({
|
|
1027
|
-
reference: z5.string(),
|
|
1028
|
-
offset: z5.int().nonnegative(),
|
|
1029
|
-
maxBytes: z5.int().positive().optional()
|
|
1030
|
-
}).strict();
|
|
1031
|
-
var ArtifactSearchSchema = z5.object({
|
|
1032
|
-
reference: z5.string(),
|
|
1033
|
-
query: z5.string(),
|
|
1034
|
-
maxMatches: z5.int().positive().optional()
|
|
1035
|
-
}).strict();
|
|
1036
|
-
var ArtifactReadResultSchema = z5.object({
|
|
1037
|
-
reference: z5.string(),
|
|
1038
|
-
offset: z5.int().nonnegative(),
|
|
1039
|
-
text: z5.string(),
|
|
1040
|
-
bytes: z5.int().nonnegative(),
|
|
1041
|
-
totalBytes: z5.int().nonnegative().optional()
|
|
1042
|
-
}).strict();
|
|
1043
|
-
var ArtifactSearchResultSchema = z5.object({
|
|
1044
|
-
reference: z5.string(),
|
|
1045
|
-
matches: z5.array(z5.object({ line: z5.int().positive(), text: z5.string() }).strict())
|
|
1046
|
-
}).strict();
|
|
1047
|
-
function branchToolJson(ids, name, value, output) {
|
|
1976
|
+
import { z as z16 } from "zod";
|
|
1977
|
+
|
|
1978
|
+
// src/agent-runtime/branch-runtime-tools.ts
|
|
1979
|
+
import { z as z15 } from "zod";
|
|
1980
|
+
function codingToolRecord(ids, name, value, output) {
|
|
1048
1981
|
if (name === AGENT_CODING_TOOL_NAMES.readOutput || name === AGENT_CODING_TOOL_NAMES.searchOutput) {
|
|
1049
|
-
const
|
|
1050
|
-
|
|
1982
|
+
const schema = output ? name === AGENT_CODING_TOOL_NAMES.readOutput ? ArtifactReadOutputSchema : ArtifactSearchOutputSchema : name === AGENT_CODING_TOOL_NAMES.readOutput ? ArtifactReadInputSchema : ArtifactSearchInputSchema;
|
|
1983
|
+
const parsed = schema.safeParse(value);
|
|
1984
|
+
if (!parsed.success)
|
|
1985
|
+
return;
|
|
1986
|
+
return { ...parsed.data, reference: ids.reference("spill", parsed.data.reference) };
|
|
1051
1987
|
}
|
|
1052
1988
|
if (output && name === AGENT_CODING_TOOL_NAMES.runCommand) {
|
|
1053
|
-
const parsed = ShellOutputSchema.
|
|
1989
|
+
const parsed = ShellOutputSchema.safeParse(value);
|
|
1990
|
+
if (!parsed.success)
|
|
1991
|
+
return;
|
|
1054
1992
|
return {
|
|
1055
|
-
...parsed,
|
|
1056
|
-
...parsed.artifact && {
|
|
1993
|
+
...parsed.data,
|
|
1994
|
+
...parsed.data.artifact && {
|
|
1057
1995
|
artifact: {
|
|
1058
|
-
...parsed.artifact,
|
|
1059
|
-
reference: ids.reference("spill", parsed.artifact.reference)
|
|
1996
|
+
...parsed.data.artifact,
|
|
1997
|
+
reference: ids.reference("spill", parsed.data.artifact.reference)
|
|
1060
1998
|
}
|
|
1061
1999
|
}
|
|
1062
2000
|
};
|
|
1063
2001
|
}
|
|
1064
|
-
return
|
|
2002
|
+
return;
|
|
2003
|
+
}
|
|
2004
|
+
function selectionReceipt(ids, value) {
|
|
2005
|
+
const receipt = DeferredAgentToolReceiptSchema2.safeParse(value);
|
|
2006
|
+
if (!receipt.success || canonicalAgentJson2(receipt.data) !== canonicalAgentJson2(value))
|
|
2007
|
+
return;
|
|
2008
|
+
if (!ids.sourceIdentitiesOf(receipt.data.runId).has("run"))
|
|
2009
|
+
return;
|
|
2010
|
+
return { ...receipt.data, runId: ids.reference("run", receipt.data.runId) };
|
|
2011
|
+
}
|
|
2012
|
+
var PayloadEventSchema = z15.object({ kind: z15.literal("provider/payload"), payload: z15.json() }).passthrough();
|
|
2013
|
+
var PayloadObservationSchema = z15.object({
|
|
2014
|
+
kind: z15.literal("runtime/branch-observation"),
|
|
2015
|
+
payload: z15.object({ sourceKind: z15.literal("provider/payload"), payload: z15.json() })
|
|
2016
|
+
}).passthrough();
|
|
2017
|
+
function withoutPayloadBody(event) {
|
|
2018
|
+
const stripped = (payload) => {
|
|
2019
|
+
const receipt = InvocationPayloadReceiptSchema.safeParse(payload);
|
|
2020
|
+
if (!receipt.success)
|
|
2021
|
+
return payload;
|
|
2022
|
+
const { iv: _iv, tag: _tag, ciphertext: _body, ...rest } = receipt.data;
|
|
2023
|
+
return rest;
|
|
2024
|
+
};
|
|
2025
|
+
const raw = PayloadEventSchema.safeParse(event);
|
|
2026
|
+
if (raw.success)
|
|
2027
|
+
return { ...raw.data, payload: stripped(raw.data.payload) };
|
|
2028
|
+
const observed = PayloadObservationSchema.safeParse(event);
|
|
2029
|
+
if (observed.success)
|
|
2030
|
+
return {
|
|
2031
|
+
...observed.data,
|
|
2032
|
+
payload: { ...observed.data.payload, payload: stripped(observed.data.payload.payload) }
|
|
2033
|
+
};
|
|
2034
|
+
return event;
|
|
2035
|
+
}
|
|
2036
|
+
function eventSearchSchemas(name) {
|
|
2037
|
+
return Object.entries(AGENT_EVENT_SEARCH_TOOL_SCHEMAS).find(([tool]) => tool === name)?.[1];
|
|
2038
|
+
}
|
|
2039
|
+
function eventSearchRecord(name, value, output) {
|
|
2040
|
+
const schemas = eventSearchSchemas(name);
|
|
2041
|
+
if (!schemas)
|
|
2042
|
+
return;
|
|
2043
|
+
if (!output) {
|
|
2044
|
+
const keys = Object.keys(schemas.input.shape);
|
|
2045
|
+
const isInput = value !== null && typeof value === "object" && !Array.isArray(value) && Object.keys(value).every((key) => keys.includes(key));
|
|
2046
|
+
return isInput ? value : undefined;
|
|
2047
|
+
}
|
|
2048
|
+
if (!schemas.output.safeParse(value).success)
|
|
2049
|
+
return;
|
|
2050
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
2051
|
+
return value;
|
|
2052
|
+
const events = value.events;
|
|
2053
|
+
if (Array.isArray(events))
|
|
2054
|
+
return { ...value, events: events.map(withoutPayloadBody) };
|
|
2055
|
+
return withoutPayloadBody(value);
|
|
2056
|
+
}
|
|
2057
|
+
function branchRuntimeToolRecord(ids, name, value, output) {
|
|
2058
|
+
return codingToolRecord(ids, name, value, output) ?? (output ? selectionReceipt(ids, value) : undefined) ?? eventSearchRecord(name, value, output);
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
// src/agent-runtime/branch-messages.ts
|
|
2062
|
+
var RETAINABLE = new Set(["conversation", "run", "message"]);
|
|
2063
|
+
function branchOpaqueJson(ids, value, path = "") {
|
|
2064
|
+
if (Array.isArray(value)) {
|
|
2065
|
+
value.forEach((entry, index) => {
|
|
2066
|
+
branchOpaqueJson(ids, entry, `${path}[${index}]`);
|
|
2067
|
+
});
|
|
2068
|
+
return value;
|
|
2069
|
+
}
|
|
2070
|
+
if (value !== null && typeof value === "object") {
|
|
2071
|
+
for (const key of BRANCH_RUNTIME_REFERENCE_KEYS) {
|
|
2072
|
+
if (!(key in value))
|
|
2073
|
+
continue;
|
|
2074
|
+
const at = path ? `${path}.${key}` : key;
|
|
2075
|
+
const mode = ids.applicationKey(key);
|
|
2076
|
+
if (mode === undefined) {
|
|
2077
|
+
ids.refuse({
|
|
2078
|
+
code: "application-key-undeclared",
|
|
2079
|
+
message: `Branch cannot rekey an opaque payload containing ${key} at ${at}; declare it in applicationKeys if it is application data`,
|
|
2080
|
+
key,
|
|
2081
|
+
path: at
|
|
2082
|
+
});
|
|
2083
|
+
continue;
|
|
2084
|
+
}
|
|
2085
|
+
const entry = value[key];
|
|
2086
|
+
if (typeof entry !== "string")
|
|
2087
|
+
continue;
|
|
2088
|
+
for (const kind of ids.sourceIdentitiesOf(entry)) {
|
|
2089
|
+
if (mode === "retain" && RETAINABLE.has(kind))
|
|
2090
|
+
continue;
|
|
2091
|
+
ids.refuse({
|
|
2092
|
+
code: "application-key-source-identity",
|
|
2093
|
+
message: mode === "retain" ? `Branch cannot carry a source ${kind} under the application key ${key} at ${at}` : `Branch cannot carry a source identity under the application key ${key} at ${at}`,
|
|
2094
|
+
key,
|
|
2095
|
+
path: at
|
|
2096
|
+
});
|
|
2097
|
+
break;
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
for (const [key, entry] of Object.entries(value))
|
|
2101
|
+
branchOpaqueJson(ids, entry, path ? `${path}.${key}` : key);
|
|
2102
|
+
}
|
|
2103
|
+
return value;
|
|
2104
|
+
}
|
|
2105
|
+
function branchToolJson(ids, name, value, output) {
|
|
2106
|
+
return branchRuntimeToolRecord(ids, name, value, output) ?? branchOpaqueJson(ids, value);
|
|
1065
2107
|
}
|
|
1066
2108
|
function branchPart(ids, part) {
|
|
2109
|
+
return "toolName" in part && typeof part.toolName === "string" ? ids.within({ toolName: part.toolName }, () => branchPartAt(ids, part)) : branchPartAt(ids, part);
|
|
2110
|
+
}
|
|
2111
|
+
function branchPartAt(ids, part) {
|
|
1067
2112
|
switch (part.type) {
|
|
1068
2113
|
case "file":
|
|
1069
2114
|
return { ...part, reference: ids.fileReference(part.reference) };
|
|
@@ -1105,16 +2150,16 @@ function branchPart(ids, part) {
|
|
|
1105
2150
|
function branchMessage(ids, sourceConversationId, message) {
|
|
1106
2151
|
if (message.conversationId !== sourceConversationId)
|
|
1107
2152
|
throw new TypeError("Branch message belongs to another conversation");
|
|
1108
|
-
return {
|
|
2153
|
+
return ids.within({ messageId: message.id }, () => ({
|
|
1109
2154
|
...message,
|
|
1110
2155
|
id: ids.reference("message", message.id),
|
|
1111
2156
|
conversationId: ids.conversationId,
|
|
1112
2157
|
...message.runId && { runId: ids.reference("run", message.runId) },
|
|
1113
2158
|
parts: message.parts.map((part) => branchPart(ids, part)),
|
|
1114
2159
|
...message.metadata && {
|
|
1115
|
-
metadata:
|
|
2160
|
+
metadata: z16.record(z16.string(), z16.json()).parse(branchOpaqueJson(ids, message.metadata))
|
|
1116
2161
|
}
|
|
1117
|
-
};
|
|
2162
|
+
}));
|
|
1118
2163
|
}
|
|
1119
2164
|
function branchRun(ids, sourceConversationId, run, settled) {
|
|
1120
2165
|
if (run.conversationId !== sourceConversationId)
|
|
@@ -1141,124 +2186,218 @@ function branchRun(ids, sourceConversationId, run, settled) {
|
|
|
1141
2186
|
}
|
|
1142
2187
|
|
|
1143
2188
|
// src/agent-runtime/branch-observations.ts
|
|
1144
|
-
import { z as
|
|
1145
|
-
var Id =
|
|
1146
|
-
var Hash2 =
|
|
1147
|
-
var State =
|
|
2189
|
+
import { z as z17 } from "zod";
|
|
2190
|
+
var Id = z17.string().min(1);
|
|
2191
|
+
var Hash2 = z17.string().regex(/^[a-f0-9]{64}$/);
|
|
2192
|
+
var State = z17.object({
|
|
1148
2193
|
name: Id,
|
|
1149
|
-
version:
|
|
1150
|
-
value:
|
|
1151
|
-
actor:
|
|
2194
|
+
version: z17.int().positive(),
|
|
2195
|
+
value: z17.json(),
|
|
2196
|
+
actor: z17.enum(["agent", "human", "system"])
|
|
1152
2197
|
}).strict();
|
|
1153
|
-
var Retry =
|
|
1154
|
-
attempt:
|
|
1155
|
-
delayMs:
|
|
1156
|
-
reason:
|
|
2198
|
+
var Retry = z17.object({
|
|
2199
|
+
attempt: z17.int().positive(),
|
|
2200
|
+
delayMs: z17.number().nonnegative().optional(),
|
|
2201
|
+
reason: z17.string().optional()
|
|
1157
2202
|
}).strict();
|
|
1158
|
-
var Spill =
|
|
1159
|
-
var Schedule =
|
|
2203
|
+
var Spill = z17.object({ reference: Id, bytes: z17.int().nonnegative(), sha256: Hash2.optional() }).strict();
|
|
2204
|
+
var Schedule = z17.object({
|
|
1160
2205
|
id: Id,
|
|
1161
|
-
kind:
|
|
1162
|
-
nextAt:
|
|
1163
|
-
occurrence:
|
|
1164
|
-
lateByMs:
|
|
1165
|
-
state:
|
|
1166
|
-
message:
|
|
1167
|
-
attempts:
|
|
1168
|
-
retryAt:
|
|
1169
|
-
terminal:
|
|
1170
|
-
skipped:
|
|
1171
|
-
}).strict();
|
|
1172
|
-
var Child = z6.object({
|
|
1173
|
-
childConversationId: Id.optional(),
|
|
1174
|
-
parentConversationId: Id.optional(),
|
|
1175
|
-
seedUptoSeq: z6.int().nonnegative().optional(),
|
|
1176
|
-
budget: z6.json().optional(),
|
|
1177
|
-
state: z6.string().optional(),
|
|
1178
|
-
resultReference: Id.optional(),
|
|
1179
|
-
reason: z6.string().optional(),
|
|
1180
|
-
action: z6.enum(["message-sent", "blocking-presented", "blocking-resolved"]).optional(),
|
|
1181
|
-
approvalId: Id.optional(),
|
|
1182
|
-
childApprovalId: Id.optional(),
|
|
1183
|
-
callId: Id.optional(),
|
|
1184
|
-
toolName: Id.optional(),
|
|
1185
|
-
input: z6.json().optional(),
|
|
1186
|
-
batchId: Id.optional(),
|
|
1187
|
-
kind: z6.string().optional(),
|
|
1188
|
-
presentedAt: z6.string().optional(),
|
|
1189
|
-
approved: z6.boolean().optional()
|
|
2206
|
+
kind: z17.enum(["at", "after", "every"]).optional(),
|
|
2207
|
+
nextAt: z17.string().nullable().optional(),
|
|
2208
|
+
occurrence: z17.int().nonnegative().optional(),
|
|
2209
|
+
lateByMs: z17.number().nonnegative().optional(),
|
|
2210
|
+
state: z17.string().optional(),
|
|
2211
|
+
message: z17.string().optional(),
|
|
2212
|
+
attempts: z17.int().nonnegative().optional(),
|
|
2213
|
+
retryAt: z17.string().nullable().optional(),
|
|
2214
|
+
terminal: z17.boolean().optional(),
|
|
2215
|
+
skipped: z17.boolean().optional()
|
|
1190
2216
|
}).strict();
|
|
1191
|
-
var Rejection =
|
|
1192
|
-
function
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
2217
|
+
var Rejection = z17.object({ approvalId: Id, callId: Id, toolName: Id, reason: z17.string() }).strict();
|
|
2218
|
+
function durability(ids, raw, kind) {
|
|
2219
|
+
const value = kind === "durability/step" ? StepEventPayloadSchema.parse(raw) : kind === "durability/park" ? ParkEventPayloadSchema.parse(raw) : kind === "durability/event" ? DeliveredEventPayloadSchema.parse(raw) : EffectEventPayloadSchema.parse(raw);
|
|
2220
|
+
if (canonicalAgentJson2(value) !== canonicalAgentJson2(raw))
|
|
2221
|
+
throw new TypeError("Branch cannot rekey opaque durability payload");
|
|
2222
|
+
if ("encoded" in value)
|
|
2223
|
+
branchOpaqueJson(ids, z17.json().parse(JSON.parse(value.encoded)));
|
|
2224
|
+
return {
|
|
2225
|
+
...value,
|
|
2226
|
+
runId: ids.reference("run", value.runId),
|
|
2227
|
+
..."id" in value && { id: ids.define("key", value.id) }
|
|
2228
|
+
};
|
|
2229
|
+
}
|
|
2230
|
+
function spill(ids, raw) {
|
|
2231
|
+
const value = Spill.parse(raw);
|
|
2232
|
+
return { ...value, reference: ids.reference("spill", value.reference) };
|
|
2233
|
+
}
|
|
2234
|
+
function schedule(ids, raw) {
|
|
2235
|
+
const value = Schedule.parse(raw);
|
|
2236
|
+
return { ...value, id: ids.define("schedule", value.id) };
|
|
2237
|
+
}
|
|
2238
|
+
function rekeyChildConversation(ids, conversationId) {
|
|
2239
|
+
return conversationId === ids.sourceConversationId ? ids.conversationId : ids.define("child", conversationId);
|
|
2240
|
+
}
|
|
2241
|
+
function childSpawned(ids, raw) {
|
|
2242
|
+
const value = ChildSpawnedEventPayloadSchema.parse(raw);
|
|
2243
|
+
return {
|
|
2244
|
+
...value,
|
|
2245
|
+
childConversationId: rekeyChildConversation(ids, value.childConversationId)
|
|
2246
|
+
};
|
|
2247
|
+
}
|
|
2248
|
+
function childState(ids, raw) {
|
|
2249
|
+
const value = ChildStateEventPayloadSchema.parse(raw);
|
|
2250
|
+
if ("action" in value) {
|
|
2251
|
+
if (value.action === "blocking-presented") {
|
|
2252
|
+
branchOpaqueJson(ids, value.input);
|
|
2253
|
+
return {
|
|
2254
|
+
...value,
|
|
2255
|
+
childConversationId: rekeyChildConversation(ids, value.childConversationId),
|
|
2256
|
+
approvalId: ids.define("approval", value.approvalId),
|
|
2257
|
+
childApprovalId: ids.define("approval", value.childApprovalId),
|
|
2258
|
+
callId: ids.define("call", value.callId),
|
|
2259
|
+
batchId: ids.define("key", value.batchId)
|
|
2260
|
+
};
|
|
2261
|
+
}
|
|
2262
|
+
if (value.action === "blocking-resolved") {
|
|
2263
|
+
return {
|
|
2264
|
+
...value,
|
|
2265
|
+
childConversationId: rekeyChildConversation(ids, value.childConversationId),
|
|
2266
|
+
approvalId: ids.define("approval", value.approvalId),
|
|
2267
|
+
batchId: ids.define("key", value.batchId)
|
|
2268
|
+
};
|
|
2269
|
+
}
|
|
1199
2270
|
return {
|
|
1200
2271
|
...value,
|
|
1201
|
-
|
|
1202
|
-
..."id" in value && { id: ids.define("key", value.id) }
|
|
2272
|
+
childConversationId: rekeyChildConversation(ids, value.childConversationId)
|
|
1203
2273
|
};
|
|
1204
2274
|
}
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
2275
|
+
return {
|
|
2276
|
+
...value,
|
|
2277
|
+
...value.childConversationId && {
|
|
2278
|
+
childConversationId: rekeyChildConversation(ids, value.childConversationId)
|
|
2279
|
+
},
|
|
2280
|
+
...value.parentConversationId && {
|
|
2281
|
+
parentConversationId: rekeyChildConversation(ids, value.parentConversationId)
|
|
2282
|
+
},
|
|
2283
|
+
...value.resultReference && {
|
|
2284
|
+
resultReference: ids.reference("spill", value.resultReference)
|
|
2285
|
+
}
|
|
2286
|
+
};
|
|
2287
|
+
}
|
|
2288
|
+
function invocation(ids, value, inherited) {
|
|
2289
|
+
if (inherited)
|
|
2290
|
+
return value;
|
|
2291
|
+
if (value.conversationId !== ids.sourceConversationId)
|
|
2292
|
+
throw new TypeError("Branch invocation record belongs to another conversation");
|
|
2293
|
+
if (value.runId !== undefined)
|
|
2294
|
+
ids.reference("run", value.runId);
|
|
2295
|
+
return value;
|
|
2296
|
+
}
|
|
2297
|
+
function invocationPayload(ids, raw, inherited) {
|
|
2298
|
+
const {
|
|
2299
|
+
iv: _iv,
|
|
2300
|
+
tag: _tag,
|
|
2301
|
+
ciphertext: _body,
|
|
2302
|
+
...receipt
|
|
2303
|
+
} = InvocationPayloadReceiptSchema.parse(raw);
|
|
2304
|
+
return invocation(ids, receipt, inherited);
|
|
2305
|
+
}
|
|
2306
|
+
var retry = (_ids, raw) => Retry.parse(raw);
|
|
2307
|
+
var OBSERVATION_RULES = {
|
|
2308
|
+
"durability/step": durability,
|
|
2309
|
+
"durability/park": durability,
|
|
2310
|
+
"durability/event": durability,
|
|
2311
|
+
"durability/effect": durability,
|
|
2312
|
+
"sandbox/probed": (_ids, raw) => z17.object({
|
|
2313
|
+
result: AgentSandboxGradeSchema2,
|
|
2314
|
+
required: z17.array(AgentSandboxRestrictionSchema2),
|
|
2315
|
+
missing: z17.array(AgentSandboxRestrictionSchema2)
|
|
2316
|
+
}).strict().parse(raw),
|
|
2317
|
+
"state/set": (ids, raw) => {
|
|
1212
2318
|
const value = State.parse(raw);
|
|
1213
2319
|
branchOpaqueJson(ids, value.value);
|
|
1214
2320
|
return value;
|
|
1215
|
-
}
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
if (value.budget)
|
|
1229
|
-
branchOpaqueJson(ids, value.budget);
|
|
1230
|
-
if (value.input)
|
|
1231
|
-
branchOpaqueJson(ids, value.input);
|
|
1232
|
-
return {
|
|
1233
|
-
...value,
|
|
1234
|
-
...value.childConversationId && {
|
|
1235
|
-
childConversationId: value.childConversationId === ids.sourceConversationId ? ids.conversationId : ids.define("child", value.childConversationId)
|
|
1236
|
-
},
|
|
1237
|
-
...value.parentConversationId && {
|
|
1238
|
-
parentConversationId: value.parentConversationId === ids.sourceConversationId ? ids.conversationId : ids.define("child", value.parentConversationId)
|
|
1239
|
-
},
|
|
1240
|
-
...value.resultReference && {
|
|
1241
|
-
resultReference: ids.reference("spill", value.resultReference)
|
|
1242
|
-
},
|
|
1243
|
-
...value.approvalId && { approvalId: ids.define("approval", value.approvalId) },
|
|
1244
|
-
...value.childApprovalId && {
|
|
1245
|
-
childApprovalId: ids.define("approval", value.childApprovalId)
|
|
1246
|
-
},
|
|
1247
|
-
...value.callId && { callId: ids.reference("call", value.callId) },
|
|
1248
|
-
...value.batchId && { batchId: ids.define("key", value.batchId) }
|
|
1249
|
-
};
|
|
1250
|
-
}
|
|
1251
|
-
if (kind === "approval/response-rejected") {
|
|
2321
|
+
},
|
|
2322
|
+
"retry/scheduled": retry,
|
|
2323
|
+
"retry/started": retry,
|
|
2324
|
+
"spill/created": spill,
|
|
2325
|
+
"spill/deleted": spill,
|
|
2326
|
+
"schedule/set": schedule,
|
|
2327
|
+
"schedule/fired": schedule,
|
|
2328
|
+
"schedule/cancelled": schedule,
|
|
2329
|
+
"schedule/late": schedule,
|
|
2330
|
+
"schedule/failed": schedule,
|
|
2331
|
+
"child/spawned": childSpawned,
|
|
2332
|
+
"child/state": childState,
|
|
2333
|
+
"approval/response-rejected": (ids, raw) => {
|
|
1252
2334
|
const value = Rejection.parse(raw);
|
|
1253
2335
|
return {
|
|
1254
2336
|
...value,
|
|
1255
2337
|
approvalId: ids.reference("approval", value.approvalId),
|
|
1256
2338
|
callId: ids.reference("call", value.callId)
|
|
1257
2339
|
};
|
|
2340
|
+
},
|
|
2341
|
+
"invocation/started": (ids, raw, _kind, inherited) => invocation(ids, InvocationStartedSchema.parse(raw), inherited),
|
|
2342
|
+
"invocation/finished": (ids, raw, _kind, inherited) => invocation(ids, InvocationFinishedSchema.parse(raw), inherited),
|
|
2343
|
+
"provider/request": (ids, raw, _kind, inherited) => invocation(ids, InvocationRequestSchema.parse(raw), inherited),
|
|
2344
|
+
"provider/response": (ids, raw, _kind, inherited) => invocation(ids, InvocationResponseSchema.parse(raw), inherited),
|
|
2345
|
+
"provider/payload": (ids, raw, _kind, inherited) => invocationPayload(ids, raw, inherited)
|
|
2346
|
+
};
|
|
2347
|
+
function isObservedKind(kind) {
|
|
2348
|
+
return Object.hasOwn(OBSERVATION_RULES, kind);
|
|
2349
|
+
}
|
|
2350
|
+
function branchObservation(ids, kind, raw, inherited = false) {
|
|
2351
|
+
if (!isObservedKind(kind)) {
|
|
2352
|
+
ids.refuse({
|
|
2353
|
+
code: "event-kind-unknown",
|
|
2354
|
+
message: `Branch cannot rekey opaque event kind ${kind}`
|
|
2355
|
+
});
|
|
2356
|
+
return raw;
|
|
1258
2357
|
}
|
|
1259
|
-
|
|
2358
|
+
return OBSERVATION_RULES[kind](ids, raw, kind, inherited);
|
|
1260
2359
|
}
|
|
1261
|
-
var
|
|
2360
|
+
var Defines = z17.object({
|
|
2361
|
+
id: Id.optional(),
|
|
2362
|
+
childConversationId: Id.optional(),
|
|
2363
|
+
parentConversationId: Id.optional(),
|
|
2364
|
+
approvalId: Id.optional(),
|
|
2365
|
+
childApprovalId: Id.optional(),
|
|
2366
|
+
callId: Id.optional(),
|
|
2367
|
+
batchId: Id.optional()
|
|
2368
|
+
}).passthrough();
|
|
2369
|
+
function collectObservationDefinitions(ids, kind, raw) {
|
|
2370
|
+
const value = Defines.safeParse(raw);
|
|
2371
|
+
if (!value.success)
|
|
2372
|
+
return;
|
|
2373
|
+
const {
|
|
2374
|
+
id,
|
|
2375
|
+
childConversationId,
|
|
2376
|
+
parentConversationId,
|
|
2377
|
+
approvalId,
|
|
2378
|
+
childApprovalId,
|
|
2379
|
+
callId,
|
|
2380
|
+
batchId
|
|
2381
|
+
} = value.data;
|
|
2382
|
+
if (kind.startsWith("durability/") && id)
|
|
2383
|
+
ids.define("key", id);
|
|
2384
|
+
if (kind.startsWith("schedule/") && id)
|
|
2385
|
+
ids.define("schedule", id);
|
|
2386
|
+
if (!kind.startsWith("child/"))
|
|
2387
|
+
return;
|
|
2388
|
+
for (const child of [childConversationId, parentConversationId])
|
|
2389
|
+
if (child && child !== ids.sourceConversationId)
|
|
2390
|
+
ids.define("child", child);
|
|
2391
|
+
if (approvalId)
|
|
2392
|
+
ids.define("approval", approvalId);
|
|
2393
|
+
if (childApprovalId)
|
|
2394
|
+
ids.define("approval", childApprovalId);
|
|
2395
|
+
if (callId)
|
|
2396
|
+
ids.define("call", callId);
|
|
2397
|
+
if (batchId)
|
|
2398
|
+
ids.define("key", batchId);
|
|
2399
|
+
}
|
|
2400
|
+
var BranchObservationSchema = z17.object({ sourceKind: Id, payload: z17.json() }).strict();
|
|
1262
2401
|
|
|
1263
2402
|
// src/agent-runtime/branch-provider.ts
|
|
1264
2403
|
import { createHash as createHash3 } from "node:crypto";
|
|
@@ -1370,7 +2509,7 @@ class BranchProvider {
|
|
|
1370
2509
|
}
|
|
1371
2510
|
|
|
1372
2511
|
// src/agent-runtime/branch-transitions.ts
|
|
1373
|
-
import { z as
|
|
2512
|
+
import { z as z18 } from "zod";
|
|
1374
2513
|
function rekeyBranchTransition(ids, source, operation) {
|
|
1375
2514
|
const message = (value) => branchMessage(ids, source, value);
|
|
1376
2515
|
const input = operation.input;
|
|
@@ -1420,6 +2559,7 @@ function rekeyBranchTransition(ids, source, operation) {
|
|
|
1420
2559
|
return AgentStoreTransitionSchema2.parse({
|
|
1421
2560
|
type: operation.type,
|
|
1422
2561
|
...operation.type === "recover" && operation.assistant && { assistant: message(operation.assistant) },
|
|
2562
|
+
...operation.type === "recover" && operation.usage && { usage: operation.usage },
|
|
1423
2563
|
input: {
|
|
1424
2564
|
...common,
|
|
1425
2565
|
...operation.type === "checkpoint" || operation.type === "terminal" ? { assistant: message(operation.input.assistant) } : {},
|
|
@@ -1441,30 +2581,38 @@ function rekeyBranchTransition(ids, source, operation) {
|
|
|
1441
2581
|
}
|
|
1442
2582
|
}
|
|
1443
2583
|
function branchJson(value) {
|
|
1444
|
-
return
|
|
2584
|
+
return z18.json().parse(value);
|
|
1445
2585
|
}
|
|
1446
2586
|
|
|
1447
2587
|
// src/agent-runtime/branch-events.ts
|
|
1448
|
-
var Hash3 =
|
|
2588
|
+
var Hash3 = z19.string().regex(/^[a-f0-9]{64}$/);
|
|
1449
2589
|
function rekeyBranchEvents(ids, source, events, retainedMessages = new Map) {
|
|
1450
|
-
|
|
1451
|
-
const
|
|
1452
|
-
|
|
2590
|
+
try {
|
|
2591
|
+
const hydrated = events.map((event) => atEvent(ids, event, () => {
|
|
2592
|
+
const assistant = retainedMessages.get(event.eventId);
|
|
2593
|
+
if (!assistant)
|
|
2594
|
+
return event;
|
|
2595
|
+
ids.collectMessage(assistant);
|
|
2596
|
+
const operation = event.kind === "runtime/transition" ? branchTransition(event) : undefined;
|
|
2597
|
+
if (operation?.type === "recover" && operation.input.action === "abandon" && !operation.assistant)
|
|
2598
|
+
return { ...event, payload: branchJson({ ...operation, assistant }) };
|
|
1453
2599
|
return event;
|
|
1454
|
-
|
|
1455
|
-
const
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
2600
|
+
}));
|
|
2601
|
+
for (const event of hydrated)
|
|
2602
|
+
atEvent(ids, event, () => collectBranchEvent(ids, event));
|
|
2603
|
+
for (const event of hydrated) {
|
|
2604
|
+
const assistant = retainedMessages.get(event.eventId);
|
|
2605
|
+
if (assistant)
|
|
2606
|
+
atEvent(ids, event, () => branchMessage(ids, source, assistant));
|
|
2607
|
+
}
|
|
2608
|
+
const provider = new BranchProvider(ids);
|
|
2609
|
+
return hydrated.map((event) => atEvent(ids, event, () => rekeyBranchEvent(ids, source, event, provider)));
|
|
2610
|
+
} catch (error) {
|
|
2611
|
+
throw ids.integrityError(error);
|
|
1465
2612
|
}
|
|
1466
|
-
|
|
1467
|
-
|
|
2613
|
+
}
|
|
2614
|
+
function atEvent(ids, event, work) {
|
|
2615
|
+
return ids.within({ seq: event.seq, eventKind: event.kind }, work);
|
|
1468
2616
|
}
|
|
1469
2617
|
function collectBranchEvent(ids, event) {
|
|
1470
2618
|
ids.define("event", event.eventId);
|
|
@@ -1480,7 +2628,16 @@ function collectBranchEvent(ids, event) {
|
|
|
1480
2628
|
ids.collectRun(record.run);
|
|
1481
2629
|
for (const message of baseline.messages)
|
|
1482
2630
|
ids.collectMessage(message);
|
|
2631
|
+
for (const receipt of baseline.admissions)
|
|
2632
|
+
ids.define("key", receipt.idempotencyKey);
|
|
1483
2633
|
}
|
|
2634
|
+
if (event.kind === "runtime/branched")
|
|
2635
|
+
ids.define("key", AgentConversationBranchReceiptSchema2.parse(event.payload).requestKey);
|
|
2636
|
+
if (event.kind === "runtime/branch-observation") {
|
|
2637
|
+
const observation = BranchObservationSchema.parse(event.payload);
|
|
2638
|
+
collectObservationDefinitions(ids, observation.sourceKind, observation.payload);
|
|
2639
|
+
} else
|
|
2640
|
+
collectObservationDefinitions(ids, event.kind, event.payload);
|
|
1484
2641
|
}
|
|
1485
2642
|
function rekeyBranchEvent(ids, source, event, provider) {
|
|
1486
2643
|
const envelope = {
|
|
@@ -1492,14 +2649,14 @@ function rekeyBranchEvent(ids, source, event, provider) {
|
|
|
1492
2649
|
if (event.kind === "runtime/transition") {
|
|
1493
2650
|
const operation = branchTransition(event);
|
|
1494
2651
|
const rekeyed = rekeyBranchTransition(ids, source, operation);
|
|
1495
|
-
const raw =
|
|
1496
|
-
type:
|
|
1497
|
-
input:
|
|
1498
|
-
assistant:
|
|
2652
|
+
const raw = z19.object({
|
|
2653
|
+
type: z19.string(),
|
|
2654
|
+
input: z19.object({
|
|
2655
|
+
assistant: z19.object({
|
|
1499
2656
|
sha256: Hash3.optional(),
|
|
1500
2657
|
sourceSha256: Hash3.optional(),
|
|
1501
|
-
bytes:
|
|
1502
|
-
parts:
|
|
2658
|
+
bytes: z19.int(),
|
|
2659
|
+
parts: z19.int()
|
|
1503
2660
|
}).passthrough()
|
|
1504
2661
|
}).passthrough()
|
|
1505
2662
|
}).passthrough().safeParse(event.payload);
|
|
@@ -1566,7 +2723,7 @@ function rekeyBranchEvent(ids, source, event, provider) {
|
|
|
1566
2723
|
})
|
|
1567
2724
|
};
|
|
1568
2725
|
}
|
|
1569
|
-
if (event.kind === "provider/message" || event.kind === "provider/request" || event.kind === "provider/response")
|
|
2726
|
+
if (event.kind === "provider/message" || (event.kind === "provider/request" || event.kind === "provider/response") && !isModelInvocationRecord(event.payload))
|
|
1570
2727
|
return { ...envelope, payload: branchJson(provider.rekey(event.kind, event.payload)) };
|
|
1571
2728
|
const observation = event.kind === "runtime/branch-observation" ? BranchObservationSchema.parse(event.payload) : { sourceKind: event.kind, payload: event.payload };
|
|
1572
2729
|
return {
|
|
@@ -1574,22 +2731,27 @@ function rekeyBranchEvent(ids, source, event, provider) {
|
|
|
1574
2731
|
kind: "runtime/branch-observation",
|
|
1575
2732
|
payload: branchJson({
|
|
1576
2733
|
sourceKind: observation.sourceKind,
|
|
1577
|
-
payload: branchObservation(ids, observation.sourceKind, observation.payload)
|
|
2734
|
+
payload: branchObservation(ids, observation.sourceKind, observation.payload, event.kind === "runtime/branch-observation")
|
|
1578
2735
|
})
|
|
1579
2736
|
};
|
|
1580
2737
|
}
|
|
1581
2738
|
|
|
1582
2739
|
// src/agent-runtime/branch-identities.ts
|
|
1583
2740
|
import { createHash as createHash4 } from "node:crypto";
|
|
2741
|
+
var raisedAt = new WeakMap;
|
|
1584
2742
|
|
|
1585
2743
|
class BranchIdentities {
|
|
1586
2744
|
conversationId;
|
|
1587
2745
|
requestKey;
|
|
1588
2746
|
sourceConversationId;
|
|
1589
2747
|
definitions = new Map;
|
|
2748
|
+
found = [];
|
|
2749
|
+
omitted = 0;
|
|
2750
|
+
address = {};
|
|
2751
|
+
files = new Set;
|
|
1590
2752
|
references = new Map;
|
|
1591
2753
|
applicationFiles = new Map;
|
|
1592
|
-
applicationKeys = new
|
|
2754
|
+
applicationKeys = new Map;
|
|
1593
2755
|
constructor(conversationId, requestKey, sourceConversationId) {
|
|
1594
2756
|
this.conversationId = conversationId;
|
|
1595
2757
|
this.requestKey = requestKey;
|
|
@@ -1602,6 +2764,42 @@ class BranchIdentities {
|
|
|
1602
2764
|
this.definitions.set(kind, values);
|
|
1603
2765
|
return target;
|
|
1604
2766
|
}
|
|
2767
|
+
within(address, work) {
|
|
2768
|
+
const outer = this.address;
|
|
2769
|
+
this.address = { ...outer, ...address };
|
|
2770
|
+
try {
|
|
2771
|
+
return work();
|
|
2772
|
+
} catch (error) {
|
|
2773
|
+
if (typeof error === "object" && error !== null && !raisedAt.has(error))
|
|
2774
|
+
raisedAt.set(error, this.address);
|
|
2775
|
+
throw error;
|
|
2776
|
+
} finally {
|
|
2777
|
+
this.address = outer;
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
refuse(refusal) {
|
|
2781
|
+
if (this.found.length >= MAX_BRANCH_REFUSALS) {
|
|
2782
|
+
this.omitted += 1;
|
|
2783
|
+
return;
|
|
2784
|
+
}
|
|
2785
|
+
this.found.push({ ...this.address, ...refusal });
|
|
2786
|
+
}
|
|
2787
|
+
refusedError() {
|
|
2788
|
+
return this.found.length > 0 ? new AgentConversationBranchRefusedError2(this.found, this.omitted) : undefined;
|
|
2789
|
+
}
|
|
2790
|
+
integrityError(error) {
|
|
2791
|
+
if (error instanceof AgentConversationBranchRefusedError2)
|
|
2792
|
+
return error;
|
|
2793
|
+
if (!(error instanceof Error))
|
|
2794
|
+
return error;
|
|
2795
|
+
if (error.name !== "TypeError" && error.name !== "ZodError")
|
|
2796
|
+
return error;
|
|
2797
|
+
const at = raisedAt.get(error) ?? this.address;
|
|
2798
|
+
return new AgentConversationBranchRefusedError2([...this.found, { ...at, code: "integrity", message: error.message }], this.omitted);
|
|
2799
|
+
}
|
|
2800
|
+
applicationFileReferences() {
|
|
2801
|
+
return [...this.files].sort();
|
|
2802
|
+
}
|
|
1605
2803
|
reference(kind, source) {
|
|
1606
2804
|
const target = this.definitions.get(kind)?.get(source);
|
|
1607
2805
|
if (!target)
|
|
@@ -1619,26 +2817,36 @@ class BranchIdentities {
|
|
|
1619
2817
|
}
|
|
1620
2818
|
}
|
|
1621
2819
|
declareApplicationKeys(keys) {
|
|
1622
|
-
for (const key of keys)
|
|
1623
|
-
this.applicationKeys.
|
|
2820
|
+
for (const { key, sourceIdentity } of keys)
|
|
2821
|
+
this.applicationKeys.set(key, sourceIdentity);
|
|
1624
2822
|
}
|
|
1625
|
-
|
|
1626
|
-
return this.applicationKeys.
|
|
2823
|
+
applicationKey(key) {
|
|
2824
|
+
return this.applicationKeys.get(key);
|
|
1627
2825
|
}
|
|
1628
|
-
|
|
2826
|
+
sourceIdentitiesOf(value) {
|
|
2827
|
+
const kinds = new Set;
|
|
1629
2828
|
if (value === this.sourceConversationId)
|
|
1630
|
-
|
|
1631
|
-
for (const values of this.definitions
|
|
2829
|
+
kinds.add("conversation");
|
|
2830
|
+
for (const [kind, values] of this.definitions)
|
|
1632
2831
|
if (values.has(value))
|
|
1633
|
-
|
|
1634
|
-
|
|
2832
|
+
kinds.add(kind);
|
|
2833
|
+
if (this.applicationFiles.has(value))
|
|
2834
|
+
kinds.add("file");
|
|
2835
|
+
return kinds;
|
|
1635
2836
|
}
|
|
1636
2837
|
fileReference(source) {
|
|
1637
2838
|
if (this.definitions.get("spill")?.has(source))
|
|
1638
2839
|
return this.reference("spill", source);
|
|
2840
|
+
this.files.add(source);
|
|
1639
2841
|
const target = this.applicationFiles.get(source);
|
|
1640
|
-
if (target === undefined)
|
|
1641
|
-
|
|
2842
|
+
if (target === undefined) {
|
|
2843
|
+
this.refuse({
|
|
2844
|
+
code: "application-file-undeclared",
|
|
2845
|
+
message: "Branch contains a foreign or missing file reference; declare it in applicationFiles if the application owns it",
|
|
2846
|
+
reference: source
|
|
2847
|
+
});
|
|
2848
|
+
return source;
|
|
2849
|
+
}
|
|
1642
2850
|
return target;
|
|
1643
2851
|
}
|
|
1644
2852
|
referenced(kind) {
|
|
@@ -1655,13 +2863,19 @@ class BranchIdentities {
|
|
|
1655
2863
|
}
|
|
1656
2864
|
collectRun(run) {
|
|
1657
2865
|
this.define("run", run.id);
|
|
2866
|
+
if (run.ownerId)
|
|
2867
|
+
this.define("owner", run.ownerId);
|
|
1658
2868
|
this.define("message", run.assistantMessageId);
|
|
1659
2869
|
if (run.lastOperation)
|
|
1660
2870
|
this.define("operation", run.lastOperation.operationId);
|
|
1661
2871
|
}
|
|
1662
2872
|
collectOperation(operation) {
|
|
2873
|
+
const input = operation.input;
|
|
2874
|
+
if ("ownerId" in input && typeof input.ownerId === "string")
|
|
2875
|
+
this.define("owner", input.ownerId);
|
|
1663
2876
|
switch (operation.type) {
|
|
1664
2877
|
case "accept":
|
|
2878
|
+
this.define("key", operation.input.idempotencyKey);
|
|
1665
2879
|
this.collectRun(operation.input.run);
|
|
1666
2880
|
this.collectMessage(operation.input.input);
|
|
1667
2881
|
break;
|
|
@@ -1677,6 +2891,7 @@ class BranchIdentities {
|
|
|
1677
2891
|
this.collectMessage(operation.input.summary);
|
|
1678
2892
|
break;
|
|
1679
2893
|
case "seed":
|
|
2894
|
+
this.define("key", operation.input.seedKey);
|
|
1680
2895
|
for (const message of operation.input.inputs)
|
|
1681
2896
|
this.collectMessage(message);
|
|
1682
2897
|
break;
|
|
@@ -1689,32 +2904,22 @@ class BranchIdentities {
|
|
|
1689
2904
|
|
|
1690
2905
|
// src/agent-runtime/branch-source.ts
|
|
1691
2906
|
import { createHash as createHash6 } from "node:crypto";
|
|
1692
|
-
import { z as
|
|
1693
|
-
|
|
1694
|
-
// src/agent-runtime/archive-projection.ts
|
|
1695
|
-
import { z as z9 } from "zod";
|
|
1696
|
-
var ArchiveProjectionSchema = z9.object({
|
|
1697
|
-
name: z9.string(),
|
|
1698
|
-
version: z9.int().positive(),
|
|
1699
|
-
uptoSeq: z9.int().nonnegative(),
|
|
1700
|
-
value: z9.json(),
|
|
1701
|
-
updatedAt: z9.string()
|
|
1702
|
-
}).strict();
|
|
2907
|
+
import { z as z21 } from "zod";
|
|
1703
2908
|
|
|
1704
2909
|
// src/agent-runtime/archive-spill.ts
|
|
1705
2910
|
import { createHash as createHash5 } from "node:crypto";
|
|
1706
|
-
import { z as
|
|
1707
|
-
var ArchiveSpillSchema =
|
|
1708
|
-
reference:
|
|
1709
|
-
runId:
|
|
1710
|
-
toolCallId:
|
|
1711
|
-
mediaType:
|
|
1712
|
-
bytes:
|
|
1713
|
-
sha256:
|
|
1714
|
-
createdAt:
|
|
1715
|
-
expiresAt:
|
|
2911
|
+
import { z as z20 } from "zod";
|
|
2912
|
+
var ArchiveSpillSchema = z20.object({
|
|
2913
|
+
reference: z20.string().min(1),
|
|
2914
|
+
runId: z20.string().min(1).optional(),
|
|
2915
|
+
toolCallId: z20.string().min(1).optional(),
|
|
2916
|
+
mediaType: z20.string().min(1),
|
|
2917
|
+
bytes: z20.int().nonnegative(),
|
|
2918
|
+
sha256: z20.string().regex(/^[a-f0-9]{64}$/),
|
|
2919
|
+
createdAt: z20.iso.datetime({ offset: true }),
|
|
2920
|
+
expiresAt: z20.iso.datetime({ offset: true }).optional(),
|
|
1716
2921
|
authorization: AgentCodingToolAuthorizationSchema2.optional(),
|
|
1717
|
-
base64:
|
|
2922
|
+
base64: z20.string()
|
|
1718
2923
|
}).strict().superRefine((spill, ctx) => {
|
|
1719
2924
|
const bytes = Buffer.from(spill.base64, "base64");
|
|
1720
2925
|
if (bytes.toString("base64") !== spill.base64 || bytes.byteLength !== spill.bytes || createHash5("sha256").update(bytes).digest("hex") !== spill.sha256) {
|
|
@@ -1726,7 +2931,7 @@ var ArchiveSpillSchema = z10.object({
|
|
|
1726
2931
|
});
|
|
1727
2932
|
|
|
1728
2933
|
// src/agent-runtime/branch-source.ts
|
|
1729
|
-
var SnapshotProjection =
|
|
2934
|
+
var SnapshotProjection = z21.object({ archiveType: z21.literal("runtime-snapshot"), snapshot: AgentSnapshotSchema2 }).strict();
|
|
1730
2935
|
function branchHash(value) {
|
|
1731
2936
|
return createHash6("sha256").update(canonicalAgentJson2(value)).digest("hex");
|
|
1732
2937
|
}
|
|
@@ -1743,13 +2948,13 @@ function boundary(events, throughRunId) {
|
|
|
1743
2948
|
for (const event of events) {
|
|
1744
2949
|
if (event.kind !== "runtime/transition")
|
|
1745
2950
|
continue;
|
|
1746
|
-
const candidate =
|
|
1747
|
-
type:
|
|
1748
|
-
input:
|
|
1749
|
-
runId:
|
|
1750
|
-
reason:
|
|
1751
|
-
action:
|
|
1752
|
-
absorb:
|
|
2951
|
+
const candidate = z21.object({
|
|
2952
|
+
type: z21.string(),
|
|
2953
|
+
input: z21.object({
|
|
2954
|
+
runId: z21.string().optional(),
|
|
2955
|
+
reason: z21.string().optional(),
|
|
2956
|
+
action: z21.string().optional(),
|
|
2957
|
+
absorb: z21.array(z21.object({ runId: z21.string() })).optional()
|
|
1753
2958
|
})
|
|
1754
2959
|
}).safeParse(event.payload);
|
|
1755
2960
|
if (!candidate.success)
|
|
@@ -1772,7 +2977,7 @@ function prepareBranchSource(bytes, {
|
|
|
1772
2977
|
if (event.seq !== index + 1)
|
|
1773
2978
|
throw new TypeError("Branch source event sequence is incomplete");
|
|
1774
2979
|
}
|
|
1775
|
-
const projections = archive.projections.map((value) =>
|
|
2980
|
+
const projections = archive.projections.map((value) => z21.union([SnapshotProjection, ArchiveProjectionSchema]).parse(value));
|
|
1776
2981
|
if (projections.some((value, index) => canonicalAgentJson2(value) !== canonicalAgentJson2(archive.projections[index])))
|
|
1777
2982
|
throw new TypeError("Branch archive snapshot contains an unknown opaque field");
|
|
1778
2983
|
const snapshots = projections.filter((value) => ("archiveType" in value));
|
|
@@ -1805,6 +3010,7 @@ function prepareBranchSource(bytes, {
|
|
|
1805
3010
|
if (spill.toolCallId)
|
|
1806
3011
|
validationIds.reference("call", spill.toolCallId);
|
|
1807
3012
|
}
|
|
3013
|
+
const refused = validationIds.refusedError();
|
|
1808
3014
|
if (canonicalAgentJson2(visibleSnapshot(full.snapshot)) !== canonicalAgentJson2(visibleSnapshot(expected)))
|
|
1809
3015
|
throw new TypeError("Branch archive snapshot disagrees with its event log");
|
|
1810
3016
|
const seq = boundary(archive.events, source.kind === "conversation" ? source.throughRunId : undefined);
|
|
@@ -1829,6 +3035,8 @@ function prepareBranchSource(bytes, {
|
|
|
1829
3035
|
events,
|
|
1830
3036
|
spills,
|
|
1831
3037
|
replay,
|
|
3038
|
+
...refused && { refused },
|
|
3039
|
+
applicationFiles: validationIds.applicationFileReferences(),
|
|
1832
3040
|
digest: branchHash({
|
|
1833
3041
|
conversationId: archive.conversationId,
|
|
1834
3042
|
events,
|
|
@@ -1849,7 +3057,7 @@ async function destinationEvents(driver, tx, conversationId) {
|
|
|
1849
3057
|
} while (fromSeq !== undefined);
|
|
1850
3058
|
return events;
|
|
1851
3059
|
}
|
|
1852
|
-
|
|
3060
|
+
function branchRequest(raw) {
|
|
1853
3061
|
const parsed = BranchAgentConversationInputSchema2.parse(raw);
|
|
1854
3062
|
const input = {
|
|
1855
3063
|
...parsed,
|
|
@@ -1861,13 +3069,78 @@ async function branchConversation(driver, raw) {
|
|
|
1861
3069
|
applicationFiles: input.applicationFiles.toSorted((left, right) => left.reference.localeCompare(right.reference))
|
|
1862
3070
|
},
|
|
1863
3071
|
...input.applicationKeys && {
|
|
1864
|
-
applicationKeys:
|
|
3072
|
+
applicationKeys: input.applicationKeys.toSorted((left, right) => left.key.localeCompare(right.key))
|
|
1865
3073
|
},
|
|
1866
3074
|
source: input.source.kind === "archive" ? {
|
|
1867
3075
|
kind: "archive",
|
|
1868
3076
|
digest: createHash7("sha256").update(input.source.bytes).digest("hex")
|
|
1869
3077
|
} : input.source
|
|
1870
3078
|
});
|
|
3079
|
+
return { input, fingerprint };
|
|
3080
|
+
}
|
|
3081
|
+
async function sourceBytes(driver, tx, input) {
|
|
3082
|
+
if (input.source.kind === "archive")
|
|
3083
|
+
return input.source.bytes;
|
|
3084
|
+
if (await driver.conversations?.isPurged(tx, input.source.conversationId))
|
|
3085
|
+
throw new AgentConversationPurgedError2;
|
|
3086
|
+
if (!await driver.head.load(tx, input.source.conversationId) && (await driver.events.list(tx, { conversationId: input.source.conversationId, limit: 1 })).items.length === 0)
|
|
3087
|
+
throw new TypeError("Branch source conversation was not found");
|
|
3088
|
+
return exportConversationIn(driver, tx, input.source.conversationId);
|
|
3089
|
+
}
|
|
3090
|
+
function assertBranchDriverCapabilities(driver, source) {
|
|
3091
|
+
assertSourceCapabilities(driver, {
|
|
3092
|
+
spills: source.spills.length,
|
|
3093
|
+
projections: 0,
|
|
3094
|
+
compacted: source.replay.baseline?.compacted?.length ?? 0
|
|
3095
|
+
});
|
|
3096
|
+
}
|
|
3097
|
+
function requestRefusal(input, source) {
|
|
3098
|
+
const missingAuthorization = source.spills.length > 0 && !input.artifactAuthorization;
|
|
3099
|
+
if (!source.refused && !missingAuthorization)
|
|
3100
|
+
return;
|
|
3101
|
+
return new AgentConversationBranchRefusedError2([
|
|
3102
|
+
...source.refused?.refusals ?? [],
|
|
3103
|
+
...missingAuthorization ? [
|
|
3104
|
+
{
|
|
3105
|
+
code: "artifact-authorization-missing",
|
|
3106
|
+
message: "Branch spills require fresh destination artifact authorization"
|
|
3107
|
+
}
|
|
3108
|
+
] : []
|
|
3109
|
+
], source.refused?.omittedRefusals ?? 0);
|
|
3110
|
+
}
|
|
3111
|
+
async function planConversationBranch(driver, raw) {
|
|
3112
|
+
const { input, fingerprint } = branchRequest(raw);
|
|
3113
|
+
return driver.transaction(async (tx) => {
|
|
3114
|
+
const bytes = await sourceBytes(driver, tx, input);
|
|
3115
|
+
const sourceArchiveDigest = createHash7("sha256").update(bytes).digest("hex");
|
|
3116
|
+
let source;
|
|
3117
|
+
try {
|
|
3118
|
+
source = prepareBranchSource(bytes, input);
|
|
3119
|
+
} catch (error) {
|
|
3120
|
+
if (!(error instanceof AgentConversationBranchRefusedError2))
|
|
3121
|
+
throw error;
|
|
3122
|
+
return planOf(fingerprint, sourceArchiveDigest, error, []);
|
|
3123
|
+
}
|
|
3124
|
+
assertBranchDriverCapabilities(driver, source);
|
|
3125
|
+
return planOf(fingerprint, sourceArchiveDigest, requestRefusal(input, source), source.applicationFiles);
|
|
3126
|
+
}, { access: "read" });
|
|
3127
|
+
}
|
|
3128
|
+
function planOf(fingerprint, sourceArchiveDigest, refused, applicationFiles) {
|
|
3129
|
+
const refusals = refused?.refusals ?? [];
|
|
3130
|
+
return AgentConversationBranchPlanSchema2.parse({
|
|
3131
|
+
ready: refusals.length === 0,
|
|
3132
|
+
fingerprint,
|
|
3133
|
+
sourceArchiveDigest,
|
|
3134
|
+
refusals,
|
|
3135
|
+
omittedRefusals: refused?.omittedRefusals ?? 0,
|
|
3136
|
+
applicationFiles,
|
|
3137
|
+
undeclaredKeys: [
|
|
3138
|
+
...new Set(refusals.flatMap((refusal) => refusal.code === "application-key-undeclared" && refusal.key ? [refusal.key] : []))
|
|
3139
|
+
].sort()
|
|
3140
|
+
});
|
|
3141
|
+
}
|
|
3142
|
+
async function branchConversation(driver, raw) {
|
|
3143
|
+
const { input, fingerprint } = branchRequest(raw);
|
|
1871
3144
|
return driver.transaction(async (tx) => {
|
|
1872
3145
|
if (await driver.conversations?.isPurged(tx, input.destinationConversationId))
|
|
1873
3146
|
throw new AgentConversationPurgedError2;
|
|
@@ -1881,25 +3154,24 @@ async function branchConversation(driver, raw) {
|
|
|
1881
3154
|
}
|
|
1882
3155
|
if (driver.conversations?.isEmpty && !await driver.conversations.isEmpty(tx, input.destinationConversationId) || existing.length > 0 || await driver.head.load(tx, input.destinationConversationId) || (await driver.history.load(tx, input.destinationConversationId)).length > 0)
|
|
1883
3156
|
throw new TypeError("Branch destination must be empty");
|
|
1884
|
-
|
|
1885
|
-
throw new AgentConversationPurgedError2;
|
|
1886
|
-
if (input.source.kind === "conversation" && !await driver.head.load(tx, input.source.conversationId) && (await driver.events.list(tx, { conversationId: input.source.conversationId, limit: 1 })).items.length === 0)
|
|
1887
|
-
throw new TypeError("Branch source conversation was not found");
|
|
1888
|
-
const bytes = input.source.kind === "archive" ? input.source.bytes : await exportConversationIn(driver, tx, input.source.conversationId);
|
|
3157
|
+
const bytes = await sourceBytes(driver, tx, input);
|
|
1889
3158
|
const source = prepareBranchSource(bytes, input);
|
|
1890
3159
|
if (source.conversationId === input.destinationConversationId)
|
|
1891
3160
|
throw new TypeError("Branch requires a new conversation identity");
|
|
1892
|
-
|
|
1893
|
-
|
|
3161
|
+
assertBranchDriverCapabilities(driver, source);
|
|
3162
|
+
const refused = requestRefusal(input, source);
|
|
3163
|
+
if (refused)
|
|
3164
|
+
throw refused;
|
|
1894
3165
|
const ids = new BranchIdentities(input.destinationConversationId, input.requestKey, source.conversationId);
|
|
1895
3166
|
for (const spill of source.spills)
|
|
1896
3167
|
ids.define("spill", spill.reference);
|
|
1897
3168
|
ids.declareApplicationFiles(input.applicationFiles ?? []);
|
|
1898
3169
|
ids.declareApplicationKeys(input.applicationKeys ?? []);
|
|
1899
3170
|
const events = rekeyBranchEvents(ids, source.conversationId, source.events, source.replay.retainedMessages);
|
|
3171
|
+
const late = ids.refusedError();
|
|
3172
|
+
if (late)
|
|
3173
|
+
throw late;
|
|
1900
3174
|
const replay = replayBranchEvents(input.destinationConversationId, events);
|
|
1901
|
-
if (replay.baseline?.compacted?.length && !driver.history.restore)
|
|
1902
|
-
throw new TypeError("Branch baseline requires inactive history restoration support");
|
|
1903
3175
|
const spills = source.spills.map(({ authorization: _sourceAuthority, ...spill }) => ({
|
|
1904
3176
|
...spill,
|
|
1905
3177
|
reference: ids.reference("spill", spill.reference),
|
|
@@ -1954,12 +3226,12 @@ async function branchConversation(driver, raw) {
|
|
|
1954
3226
|
conversationId: input.destinationConversationId,
|
|
1955
3227
|
events: [],
|
|
1956
3228
|
projections: [],
|
|
1957
|
-
spills:
|
|
3229
|
+
spills: z22.array(z22.json()).parse(spills)
|
|
1958
3230
|
});
|
|
1959
3231
|
await driver.events.append(tx, agentStoreEventDraft({
|
|
1960
3232
|
conversationId: input.destinationConversationId,
|
|
1961
3233
|
kind: "runtime/branched",
|
|
1962
|
-
payload:
|
|
3234
|
+
payload: z22.json().parse(receipt)
|
|
1963
3235
|
}));
|
|
1964
3236
|
return { outcome: "created", receipt };
|
|
1965
3237
|
});
|
|
@@ -1972,23 +3244,6 @@ function eventOnceId(conversationId, kind, key) {
|
|
|
1972
3244
|
throw new TypeError("Event admission key must not be empty");
|
|
1973
3245
|
return createHash8("sha256").update(JSON.stringify([conversationId, kind, key])).digest("hex");
|
|
1974
3246
|
}
|
|
1975
|
-
async function findEvent(driver, transaction, conversationId, eventId) {
|
|
1976
|
-
if (driver.events.find)
|
|
1977
|
-
return driver.events.find(transaction, { conversationId, eventId });
|
|
1978
|
-
let fromSeq;
|
|
1979
|
-
do {
|
|
1980
|
-
const page = await driver.events.list(transaction, {
|
|
1981
|
-
conversationId,
|
|
1982
|
-
fromSeq,
|
|
1983
|
-
limit: 1e4
|
|
1984
|
-
});
|
|
1985
|
-
const found = page.items.find((event) => event.eventId === eventId);
|
|
1986
|
-
if (found)
|
|
1987
|
-
return found;
|
|
1988
|
-
fromSeq = page.nextSeq;
|
|
1989
|
-
} while (fromSeq !== undefined);
|
|
1990
|
-
return;
|
|
1991
|
-
}
|
|
1992
3247
|
function appendEventOnce(driver, input, key) {
|
|
1993
3248
|
const parsed = AppendAgentStoreEventSchema2.parse(input);
|
|
1994
3249
|
const eventId = eventOnceId(parsed.conversationId, parsed.kind, key);
|
|
@@ -1996,7 +3251,10 @@ function appendEventOnce(driver, input, key) {
|
|
|
1996
3251
|
if (await driver.conversations?.isPurged(transaction, parsed.conversationId)) {
|
|
1997
3252
|
throw new AgentConversationPurgedError2;
|
|
1998
3253
|
}
|
|
1999
|
-
const previous = await
|
|
3254
|
+
const previous = await driver.events.find(transaction, {
|
|
3255
|
+
conversationId: parsed.conversationId,
|
|
3256
|
+
eventId
|
|
3257
|
+
});
|
|
2000
3258
|
if (previous)
|
|
2001
3259
|
return { outcome: "duplicate", event: previous };
|
|
2002
3260
|
const event = await driver.events.append(transaction, {
|
|
@@ -2008,11 +3266,11 @@ function appendEventOnce(driver, input, key) {
|
|
|
2008
3266
|
}
|
|
2009
3267
|
function findEventOnce(driver, input) {
|
|
2010
3268
|
const eventId = eventOnceId(input.conversationId, input.kind, input.key);
|
|
2011
|
-
return driver.transaction((transaction) =>
|
|
3269
|
+
return driver.transaction((transaction) => driver.events.find(transaction, { conversationId: input.conversationId, eventId }), { access: "read" });
|
|
2012
3270
|
}
|
|
2013
3271
|
|
|
2014
3272
|
// src/agent-runtime/store-mutate.ts
|
|
2015
|
-
import { z as
|
|
3273
|
+
import { z as z23 } from "zod";
|
|
2016
3274
|
function validateAdmissionReceipt(receipt, record, conversationId) {
|
|
2017
3275
|
const input = receipt.input;
|
|
2018
3276
|
const run = record.run;
|
|
@@ -2055,7 +3313,7 @@ async function settledSeed(driver, transaction, read, input) {
|
|
|
2055
3313
|
return { outcome: "applied", snapshot: current };
|
|
2056
3314
|
let collisions = 0;
|
|
2057
3315
|
for (const message of input.inputs) {
|
|
2058
|
-
if (current.messages.some((candidate) => candidate.id === message.id) ||
|
|
3316
|
+
if (current.messages.some((candidate) => candidate.id === message.id) || await driver.history.hasMessage(transaction, {
|
|
2059
3317
|
conversationId,
|
|
2060
3318
|
messageId: message.id
|
|
2061
3319
|
}))
|
|
@@ -2159,7 +3417,7 @@ async function persistApplied(driver, transaction, read, operation, reduced) {
|
|
|
2159
3417
|
await driver.events.append(transaction, agentStoreEventDraft({
|
|
2160
3418
|
conversationId,
|
|
2161
3419
|
kind: "runtime/transition",
|
|
2162
|
-
payload:
|
|
3420
|
+
payload: z23.json().parse(transitionRecord(operation, reduced))
|
|
2163
3421
|
}));
|
|
2164
3422
|
return { outcome: "applied", snapshot: reduced.snapshot };
|
|
2165
3423
|
}
|
|
@@ -2208,14 +3466,17 @@ function createStoreConversationPurge(driver, conversations) {
|
|
|
2208
3466
|
}
|
|
2209
3467
|
|
|
2210
3468
|
// src/agent-runtime/store-create.ts
|
|
2211
|
-
var AgentRecoverableScanInputSchema =
|
|
2212
|
-
cursor:
|
|
2213
|
-
limit:
|
|
3469
|
+
var AgentRecoverableScanInputSchema = z24.object({
|
|
3470
|
+
cursor: z24.string().min(1).optional(),
|
|
3471
|
+
limit: z24.number().int().min(1).max(1000)
|
|
2214
3472
|
});
|
|
2215
3473
|
function createAgentRuntimeStore2(driver) {
|
|
3474
|
+
const capabilities = driverCapabilities(driver);
|
|
2216
3475
|
const mutate = (operation) => mutateStore(driver, operation);
|
|
2217
3476
|
return {
|
|
3477
|
+
capabilities,
|
|
2218
3478
|
branchConversation: (input) => branchConversation(driver, input),
|
|
3479
|
+
planConversationBranch: (input) => planConversationBranch(driver, input),
|
|
2219
3480
|
loadSnapshot: (conversationId) => loadSnapshot(driver, conversationId),
|
|
2220
3481
|
loadRun: (input) => loadRun(driver, input),
|
|
2221
3482
|
listActiveRuns: (conversationId) => listActiveRuns(driver, conversationId),
|
|
@@ -2262,4 +3523,4 @@ function createAgentRuntimeStore2(driver) {
|
|
|
2262
3523
|
};
|
|
2263
3524
|
}
|
|
2264
3525
|
|
|
2265
|
-
export { BranchAgentConversationInputSchema2, AgentConversationBranchReceiptSchema2, AgentConversationBranchResultSchema2, AgentConversationPurgeInputSchema2, AgentConversationPurgeResultSchema2, AgentConversationPurgedError2, purgeAgentConversation2,
|
|
3526
|
+
export { AgentBranchRefusalCodeSchema2, AgentBranchRefusalSchema2, AgentConversationBranchRefusedError2, BranchAgentConversationInputSchema2, AgentConversationBranchReceiptSchema2, AgentConversationBranchResultSchema2, AgentConversationBranchPlanSchema2, defineAgentTool, SqlIntegerSchema, HeadRowSchema, MessageRowSchema, PositionedMessageRowSchema, CountRowSchema, FlagSchema, EVENT_COLUMNS, parseJson, encodeJson, missing, placeholders, parseRunRow, parseEventRow, nextEventSeqByMaximum, AgentChildBudgetSchema2, AgentChildStateSchema2, AgentChildRecordSchema2, AgentChildBlockingKindSchema2, AgentChildBlockingSourceSchema2, AgentChildBlockingEventSchema2, ChildBlockingDecisionSchema, ChildSpawnedEventPayloadSchema, ChildStateEventPayloadSchema, parseChild, usageNumbers, AgentConversationPurgeInputSchema2, AgentConversationPurgeResultSchema2, AgentConversationPurgedError2, purgeAgentConversation2, DeferredAgentToolSearchInputSchema2, DeferredAgentToolMatchSchema2, DeferredAgentToolReceiptSchema2, agentSqlTables, isRetryablePostgresConflict, POSTGRES_ISOLATION, postgresSession, setPostgresTransactionIsolation, runPostgresTransaction, AgentEventSearchResultSchema2, createAgentEventSearch2, createAgentEventSearchTools2, AgentStoreUnsupportedCapabilityError2, ArchiveProjectionSchema, isRuntimeSnapshotEntry, replaceMessage, appendEventIn, ArchiveSpillSchema, createAgentRuntimeStore2 };
|