stitchkit 0.126.0 → 0.128.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 +1767 -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 +97 -0
- package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-driver.d.ts +37 -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 +30 -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 +31 -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 +206 -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 +23 -0
- package/dist/agent-executor/claude/session.d.ts.map +1 -0
- package/dist/agent-executor/claude/transcript.d.ts +36 -0
- package/dist/agent-executor/claude/transcript.d.ts.map +1 -0
- package/dist/agent-executor/claude-sdk/driver.d.ts +35 -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 +27 -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 +176 -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 +43 -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/image-input.d.ts +71 -0
- package/dist/agent-executor/image-input.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 +69 -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 +22 -8
- 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 +60 -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 +43 -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 +153 -30
- package/dist/agent-runtime/branch-observations.d.ts.map +1 -1
- package/dist/agent-runtime/branch-provider.d.ts +43 -56
- 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 +19 -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 +82 -7
- 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 +141 -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-attempt.d.ts +1 -1
- package/dist/agent-runtime/invocation-attempt.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-payload.d.ts +12 -0
- package/dist/agent-runtime/invocation-payload.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-read.d.ts +6 -3
- package/dist/agent-runtime/invocation-read.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-schema.d.ts +70 -5
- 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 +20 -9
- 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 +49 -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-invocation-payload.d.ts +48 -0
- package/dist/agent-runtime/schemas-invocation-payload.d.ts.map +1 -0
- 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 +82 -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 +63 -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-seed.d.ts +8 -0
- package/dist/agent-runtime/store-conformance-seed.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-support.d.ts +10 -10
- 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 +27 -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-events.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 +22 -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 +10 -25
- 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 +921 -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 +325 -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 +422 -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 +858 -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 +34 -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 +335 -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 +26 -16
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime.js +1439 -1198
- 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 +92 -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 +54 -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 +259 -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 +26 -0
- package/dist/entrypoints/service-host.d.ts.map +1 -0
- package/dist/entrypoints/service-host.js +3155 -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 +13 -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 +10 -7
- package/dist/entrypoints/tools/mcp.js +17 -13
- package/dist/entrypoints/tools/toolkit.js +22 -18
- package/dist/entrypoints/tools.d.ts +4 -2
- package/dist/entrypoints/tools.d.ts.map +1 -1
- package/dist/entrypoints/tools.js +105 -90
- 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 +55 -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 +135 -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-0gqs8ght.js +558 -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-13dnv6d0.js +296 -0
- package/dist/index-1q0n6zek.js +184 -0
- package/dist/index-1qwrczr1.js +405 -0
- package/dist/index-27hck3z2.js +307 -0
- package/dist/index-2c5w2d1d.js +107 -0
- package/dist/{index-fvd6pvw3.js → index-2nwvn7m2.js} +2 -2
- 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-mfntvj58.js → index-3dq8466w.js} +1 -1
- package/dist/index-3tnwtz38.js +725 -0
- package/dist/{index-x2d51zay.js → index-3ypvpkwr.js} +309 -345
- package/dist/index-4gk6k3zc.js +248 -0
- package/dist/{index-kxff9e9w.js → index-4j8efqr3.js} +5 -4
- package/dist/index-4qvyhn23.js +40 -0
- package/dist/index-4ynw5ktx.js +78 -0
- package/dist/index-5awtbyns.js +19 -0
- 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-5v5vg85s.js +108 -0
- package/dist/{index-0v9xb8pz.js → index-5y7j383h.js} +5 -5
- package/dist/{index-bqzgaj57.js → index-673drwkn.js} +198 -61
- package/dist/{index-v62cpkx3.js → index-6g85s734.js} +1 -1
- package/dist/{index-sqc6ezrb.js → index-6kec3b14.js} +17 -4
- package/dist/{index-cvjddnvd.js → index-6wp4dn9d.js} +17 -8
- 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-ss67fxhj.js → index-877e9y8r.js} +7 -7
- package/dist/{index-aw6kx2e6.js → index-8gmmdz7k.js} +1 -1
- package/dist/index-8x22nprv.js +1461 -0
- 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-egg0yp2j.js → index-9xr44d2g.js} +86 -210
- package/dist/{index-b2sey031.js → index-9y0afd5f.js} +24 -23
- package/dist/{index-nmaqxdx7.js → index-ac5rj3d4.js} +203 -90
- package/dist/{index-wqzw3qg9.js → index-agy5fqgf.js} +32 -13
- 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-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-bz3gn6cs.js +407 -0
- package/dist/index-c5gp2gh6.js +51 -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-1szhrfsf.js → index-d54npte7.js} +7 -5
- package/dist/{index-ne4j9998.js → index-e06z0tkb.js} +123 -94
- package/dist/index-emgrmavr.js +1193 -0
- package/dist/{index-99nnsz39.js → index-en8e5zsj.js} +15 -135
- package/dist/{index-20hn8pbh.js → index-fmzg39a8.js} +1 -1
- package/dist/{index-ft2wvst5.js → index-g3e57qj6.js} +1928 -414
- package/dist/index-g56ht6qf.js +98 -0
- package/dist/{index-7cn66qdk.js → index-gf92hc87.js} +15 -7
- package/dist/{index-f56ct5gb.js → index-gj1rjf78.js} +4 -3
- package/dist/{index-g6a3na27.js → index-gnjgkecx.js} +7 -3
- package/dist/index-gzny6zsw.js +487 -0
- package/dist/{index-n6hvd1r2.js → index-hj1zq7mh.js} +26 -13
- package/dist/index-hy4653g4.js +345 -0
- package/dist/{index-t8jz0e20.js → index-j903yhp4.js} +30 -38
- package/dist/{index-9ypczvpj.js → index-jb4m241t.js} +2 -0
- package/dist/{index-wt6rw7rf.js → index-jfecdk1e.js} +29 -21
- package/dist/{index-cjzaj7ev.js → index-jxtg307y.js} +23 -21
- package/dist/{index-3ymcmpa9.js → index-ke02kxsr.js} +33 -163
- 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-48acz7z0.js → index-m18xm96h.js} +93 -46
- 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-1v3k5zgx.js → index-n7f89hjw.js} +610 -1168
- package/dist/index-ngwf1s3c.js +51 -0
- package/dist/{index-zfncctjp.js → index-nk0cy9g1.js} +5 -4
- package/dist/{index-hs76yzt7.js → index-paff5y0r.js} +17 -11
- package/dist/index-pn5b11ce.js +40 -0
- package/dist/{index-qaet40b2.js → index-prf6ayhf.js} +5 -7
- package/dist/{index-hkxgennw.js → index-ps3djm8d.js} +7 -1
- package/dist/index-pwskmywy.js +195 -0
- 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-x2rvpbtj.js → index-rxnyygke.js} +151 -17
- package/dist/index-rzeezh79.js +508 -0
- package/dist/index-s2e3h616.js +351 -0
- 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-t7wa7k12.js +221 -0
- 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-btjwc7xr.js → index-v1mxss62.js} +15 -14
- 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-vgzhw2zk.js +304 -0
- package/dist/index-vmbxj75t.js +177 -0
- package/dist/{index-tnnmekgb.js → index-wa6h4tz6.js} +3 -3
- package/dist/{index-pa9bhefy.js → index-waa6t4zx.js} +83 -10
- package/dist/{index-4efxzrht.js → index-wavv538x.js} +211 -196
- 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-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-xv9jb84s.js +929 -0
- package/dist/{index-v7rbjatr.js → index-y065r8g5.js} +1881 -1156
- package/dist/{index-yex7eg1v.js → index-y7sy1xdp.js} +6 -2
- 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-confirm.d.ts +32 -0
- package/dist/internal/bounded-file-confirm.d.ts.map +1 -0
- package/dist/internal/bounded-file-read.d.ts +34 -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 +53 -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 +14 -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 +62 -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 +8 -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 +128 -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-shared.d.ts +64 -0
- package/dist/service-host/systemd-render-shared.d.ts.map +1 -0
- package/dist/service-host/systemd-render.d.ts +98 -0
- package/dist/service-host/systemd-render.d.ts.map +1 -0
- package/dist/service-host/systemd-timer-render.d.ts +31 -0
- package/dist/service-host/systemd-timer-render.d.ts.map +1 -0
- package/dist/service-host/systemd-timer-rollback.d.ts +26 -0
- package/dist/service-host/systemd-timer-rollback.d.ts.map +1 -0
- package/dist/service-host/systemd-timer.d.ts +82 -0
- package/dist/service-host/systemd-timer.d.ts.map +1 -0
- package/dist/service-host/systemd-unit-ops.d.ts +26 -0
- package/dist/service-host/systemd-unit-ops.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 +63 -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 +75 -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 +37 -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 +71 -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 +10 -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 +3 -4
- package/dist/tools/list-names.d.ts.map +1 -1
- package/dist/tools/manifest.d.ts +4 -3
- 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 +2 -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 +55 -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 +39 -246
- 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 +96 -184
- package/llms/contract.txt +7 -6
- package/llms/declaration.txt +3 -3
- package/llms/files.txt +11 -0
- package/llms/handler.txt +25 -0
- package/llms/http.txt +18 -1
- package/llms/node.txt +5 -4
- 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 +8 -3
- 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 +99 -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 +14 -9
- package/llms/tools.txt +85 -78
- package/llms/upgrading-0.127.0.txt +1059 -0
- package/llms/upgrading-0.128.0.txt +147 -0
- package/llms/upgrading.txt +2 -0
- package/llms-full.txt +3727 -542
- package/llms.txt +44 -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-8x0q6yfb.js +0 -247
- package/dist/index-a3z56mtn.js +0 -48
- 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,43 +1,91 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
AgentMessagePartSchema2
|
|
3
|
+
} from "./index-2rf33y2h.js";
|
|
4
|
+
import {
|
|
5
5
|
AgentMessageSchema2,
|
|
6
6
|
AgentAssistantPlaceholderSchema2,
|
|
7
|
+
AgentProvenanceSchema2,
|
|
7
8
|
AgentRunOperationSchema2,
|
|
8
9
|
runStateForTerminalReason2,
|
|
9
|
-
AgentProvenanceSchema2,
|
|
10
|
-
AgentUsageSchema2,
|
|
11
10
|
AgentRunSchema2,
|
|
12
11
|
AgentSnapshotSchema2
|
|
13
|
-
} from "./index-
|
|
12
|
+
} from "./index-bn2baakz.js";
|
|
14
13
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
InvocationPayloadSchema,
|
|
15
|
+
InvocationExpiredPayloadSchema,
|
|
16
|
+
PurgeInvocationPayloadsInputSchema2,
|
|
17
|
+
ModelInvocationTraceSchema2,
|
|
18
|
+
CompletionInvocationInputSchema2,
|
|
19
|
+
InvocationCallerSchema,
|
|
20
|
+
InvocationStartedSchema,
|
|
21
|
+
ModelInvocationRecordSchema2,
|
|
22
|
+
InvocationStoredPayloadSchema,
|
|
23
|
+
ModelInvocationPayloadReadSchema2,
|
|
24
|
+
isModelInvocationRecord,
|
|
25
|
+
createToolChronology,
|
|
26
|
+
advanceToolChronology,
|
|
27
|
+
canProjectToolChronology,
|
|
28
|
+
isAssistantHistoryEvidence2,
|
|
29
|
+
isCompleteAgentHistoryTurn,
|
|
30
|
+
assistantStatus
|
|
31
|
+
} from "./index-vgzhw2zk.js";
|
|
32
|
+
import {
|
|
33
|
+
withStoreRetries,
|
|
34
|
+
AgentRuntimeConflictError2,
|
|
35
|
+
AgentRunUnsettledError2,
|
|
36
|
+
appliedSnapshot,
|
|
37
|
+
terminalOfSnapshot,
|
|
38
|
+
terminalOfRunView,
|
|
39
|
+
commitAgentRunTerminal,
|
|
40
|
+
findRun,
|
|
41
|
+
jsonValue,
|
|
42
|
+
providerEnvelope,
|
|
43
|
+
providerResponseIdentity,
|
|
44
|
+
appendText,
|
|
45
|
+
abortTerminalReason,
|
|
46
|
+
mergeModelTotals,
|
|
47
|
+
statedUsage,
|
|
48
|
+
normalizeSdkUsage,
|
|
49
|
+
createIdleDeadline,
|
|
50
|
+
adoptSnapshot,
|
|
51
|
+
transientSequence,
|
|
52
|
+
runUsage,
|
|
53
|
+
updateReasoning,
|
|
54
|
+
checkpoint,
|
|
55
|
+
DEFAULT_STEP_SPEND_TIMEOUT_MS,
|
|
56
|
+
normalizeStepUsage,
|
|
57
|
+
recordStepSpend,
|
|
58
|
+
InvocationReceiptError,
|
|
59
|
+
invocationHash,
|
|
60
|
+
createInvocationPayloads,
|
|
61
|
+
isOwnInputRefusal,
|
|
62
|
+
markProviderOrigin,
|
|
63
|
+
hasProviderOrigin,
|
|
64
|
+
markProviderStream,
|
|
65
|
+
wrapInvocationModel
|
|
66
|
+
} from "./index-emgrmavr.js";
|
|
18
67
|
import {
|
|
19
68
|
AGENT_TOOL_PROGRESS_MESSAGE_MAX2,
|
|
20
69
|
agentDurableEventId2
|
|
21
|
-
} from "./index-
|
|
70
|
+
} from "./index-paff5y0r.js";
|
|
71
|
+
import {
|
|
72
|
+
ToolExecutionControlError2,
|
|
73
|
+
isToolExecutionControlError2
|
|
74
|
+
} from "./index-rxnyygke.js";
|
|
75
|
+
import {
|
|
76
|
+
contractOperationEffects2
|
|
77
|
+
} from "./index-werjqesf.js";
|
|
22
78
|
import {
|
|
23
79
|
createLocalStepDurability2
|
|
24
|
-
} from "./index-
|
|
80
|
+
} from "./index-kynwa08q.js";
|
|
25
81
|
import {
|
|
82
|
+
isActiveRunState,
|
|
26
83
|
canonicalAgentJson2,
|
|
27
|
-
|
|
28
|
-
advanceToolChronology,
|
|
29
|
-
canProjectToolChronology,
|
|
30
|
-
isAssistantHistoryEvidence2,
|
|
31
|
-
isCompleteAgentHistoryTurn,
|
|
32
|
-
assistantStatus,
|
|
84
|
+
issueRunContext,
|
|
33
85
|
ProviderJournalMessageSchema,
|
|
34
86
|
ProviderJournalRequestSchema,
|
|
35
|
-
ProviderJournalResponseSchema
|
|
36
|
-
|
|
37
|
-
} from "./index-egg0yp2j.js";
|
|
38
|
-
import {
|
|
39
|
-
messageOf
|
|
40
|
-
} from "./index-3bzk2645.js";
|
|
87
|
+
ProviderJournalResponseSchema
|
|
88
|
+
} from "./index-9xr44d2g.js";
|
|
41
89
|
import {
|
|
42
90
|
createRuntimeToolContext
|
|
43
91
|
} from "./index-eh71zr32.js";
|
|
@@ -45,398 +93,31 @@ import {
|
|
|
45
93
|
createMutationQueue
|
|
46
94
|
} from "./index-sykb5ag7.js";
|
|
47
95
|
import {
|
|
96
|
+
messageOf
|
|
97
|
+
} from "./index-r9kq5ark.js";
|
|
98
|
+
import {
|
|
99
|
+
listContractToolNames2
|
|
100
|
+
} from "./index-pn5b11ce.js";
|
|
101
|
+
import {
|
|
102
|
+
AgentToolError2,
|
|
48
103
|
isAgentToolError2
|
|
49
104
|
} from "./index-1psbyyhj.js";
|
|
50
105
|
import {
|
|
51
106
|
assertPositiveSafeInteger
|
|
52
|
-
} from "./index-
|
|
53
|
-
import {
|
|
54
|
-
serializeCanonicalJson
|
|
55
|
-
} from "./index-20hn8pbh.js";
|
|
107
|
+
} from "./index-kzavdze2.js";
|
|
56
108
|
import {
|
|
57
109
|
isRecord,
|
|
58
|
-
transportResult
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
async function withStoreRetries(work) {
|
|
70
|
-
for (let failures = 0;; failures += 1) {
|
|
71
|
-
try {
|
|
72
|
-
return await work();
|
|
73
|
-
} catch (error) {
|
|
74
|
-
const delay = storeRetryDelay(failures);
|
|
75
|
-
if (delay === undefined)
|
|
76
|
-
throw error;
|
|
77
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// src/agent-runtime/terminal-commit.ts
|
|
83
|
-
class AgentRuntimeConflictError2 extends Error {
|
|
84
|
-
constructor(operation) {
|
|
85
|
-
super(`Agent runtime store conflict during ${operation}`);
|
|
86
|
-
this.name = "AgentRuntimeConflictError";
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
class AgentRunUnsettledError2 extends Error {
|
|
91
|
-
run;
|
|
92
|
-
ownerId;
|
|
93
|
-
constructor(run, ownerId, cause) {
|
|
94
|
-
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
95
|
-
super(`Agent run ${run.id} is still ${run.state} with no executor: ${reason}`, { cause });
|
|
96
|
-
this.name = "AgentRunUnsettledError";
|
|
97
|
-
this.run = run;
|
|
98
|
-
this.ownerId = ownerId;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
function appliedSnapshot(result, operation) {
|
|
102
|
-
if (result.outcome === "applied" || result.outcome === "duplicate")
|
|
103
|
-
return result.snapshot;
|
|
104
|
-
throw new AgentRuntimeConflictError2(operation);
|
|
105
|
-
}
|
|
106
|
-
function viewOfSnapshot(snapshot, runId, retainedAssistant) {
|
|
107
|
-
const run = snapshot.runs.find((candidate) => candidate.id === runId);
|
|
108
|
-
const assistant = snapshot.messages.find((message) => message.id === run?.assistantMessageId) ?? retainedAssistant;
|
|
109
|
-
return {
|
|
110
|
-
snapshotVersion: snapshot.version,
|
|
111
|
-
conversationId: snapshot.conversationId,
|
|
112
|
-
...run && { run },
|
|
113
|
-
...assistant && { assistant }
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
function terminalOfSnapshot(snapshot, runId) {
|
|
117
|
-
return canonicalTerminal(viewOfSnapshot(snapshot, runId));
|
|
118
|
-
}
|
|
119
|
-
function terminalOfRunView(view, conversationId) {
|
|
120
|
-
return canonicalTerminal(viewOfRun(view, conversationId));
|
|
121
|
-
}
|
|
122
|
-
function viewOfRun(view, conversationId) {
|
|
123
|
-
return {
|
|
124
|
-
snapshotVersion: view.snapshotVersion,
|
|
125
|
-
conversationId,
|
|
126
|
-
run: view.run,
|
|
127
|
-
...view.assistant && { assistant: view.assistant }
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
function canonicalTerminal(view) {
|
|
131
|
-
const { run, assistant } = view;
|
|
132
|
-
if (!run?.terminalReason)
|
|
133
|
-
return;
|
|
134
|
-
if (view.conversationId !== run.conversationId || !assistant || assistant.id !== run.assistantMessageId || assistant.conversationId !== run.conversationId || assistant.runId !== run.id || assistant.role !== "assistant" || assistant.status !== assistantStatus(run.terminalReason)) {
|
|
135
|
-
throw new AgentRuntimeConflictError2("terminal result projection");
|
|
136
|
-
}
|
|
137
|
-
return {
|
|
138
|
-
snapshotVersion: view.snapshotVersion,
|
|
139
|
-
run,
|
|
140
|
-
assistant,
|
|
141
|
-
reason: run.terminalReason,
|
|
142
|
-
committedByCaller: false,
|
|
143
|
-
...run.terminalPolicyName && { policyName: run.terminalPolicyName },
|
|
144
|
-
...run.usage && { usage: run.usage }
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
function interruptedCandidate(candidate, run, now) {
|
|
148
|
-
const reason = candidate.reason === "superseded" ? "superseded" : "interrupted";
|
|
149
|
-
const hasInterruptControl = candidate.assistant.parts.some((part) => part.type === "control" && part.reason === "run-interrupted");
|
|
150
|
-
const parts = hasInterruptControl ? candidate.assistant.parts : [
|
|
151
|
-
...candidate.assistant.parts,
|
|
152
|
-
AgentMessagePartSchema2.parse({ type: "control", reason: "run-interrupted" })
|
|
153
|
-
];
|
|
154
|
-
return {
|
|
155
|
-
...candidate.usage && { usage: candidate.usage },
|
|
156
|
-
run,
|
|
157
|
-
assistant: AgentMessageSchema2.parse({
|
|
158
|
-
...candidate.assistant,
|
|
159
|
-
status: assistantStatus(reason),
|
|
160
|
-
parts,
|
|
161
|
-
updatedAt: now().toISOString()
|
|
162
|
-
}),
|
|
163
|
-
reason
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
function canRetryTerminal(current, previous, runtimeEpoch) {
|
|
167
|
-
return (current.state === "running" || current.state === "interrupt_requested") && current.ownerId === runtimeEpoch && current.fencingToken === previous.fencingToken;
|
|
168
|
-
}
|
|
169
|
-
var TERMINAL_COMMIT_ATTEMPTS = 32;
|
|
170
|
-
async function attemptTerminalCommit(input, candidate) {
|
|
171
|
-
const committed = await input.store.commitRunTerminal({
|
|
172
|
-
conversationId: candidate.run.conversationId,
|
|
173
|
-
runId: candidate.run.id,
|
|
174
|
-
expectedRevision: candidate.run.revision,
|
|
175
|
-
ownerId: input.runtimeEpoch,
|
|
176
|
-
...candidate.run.fencingToken !== undefined && {
|
|
177
|
-
fencingToken: candidate.run.fencingToken
|
|
178
|
-
},
|
|
179
|
-
assistant: candidate.assistant,
|
|
180
|
-
reason: candidate.reason,
|
|
181
|
-
...candidate.policyName && { policyName: candidate.policyName },
|
|
182
|
-
...candidate.usage && { usage: candidate.usage },
|
|
183
|
-
...candidate.absorb?.length && { absorb: candidate.absorb }
|
|
184
|
-
});
|
|
185
|
-
if (committed.outcome === "applied") {
|
|
186
|
-
const terminal = canonicalTerminal(viewOfSnapshot(committed.snapshot, candidate.run.id));
|
|
187
|
-
if (!terminal)
|
|
188
|
-
throw new AgentRuntimeConflictError2("terminal result projection");
|
|
189
|
-
const absorbed = committed.snapshot.runs.filter((run) => run.absorbedIntoRunId === candidate.run.id);
|
|
190
|
-
return {
|
|
191
|
-
settled: {
|
|
192
|
-
...terminal,
|
|
193
|
-
committedByCaller: true,
|
|
194
|
-
...absorbed.length > 0 && { absorbed }
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
if (committed.outcome === "duplicate") {
|
|
199
|
-
const terminal = canonicalTerminal(viewOfSnapshot(committed.snapshot, candidate.run.id, committed.assistant));
|
|
200
|
-
if (!terminal)
|
|
201
|
-
throw new AgentRuntimeConflictError2("terminal result projection");
|
|
202
|
-
return { settled: terminal };
|
|
203
|
-
}
|
|
204
|
-
if (committed.outcome !== "conflict") {
|
|
205
|
-
throw new AgentRuntimeConflictError2("terminal commit");
|
|
206
|
-
}
|
|
207
|
-
const latest = await input.store.loadRun({
|
|
208
|
-
conversationId: candidate.run.conversationId,
|
|
209
|
-
runId: candidate.run.id
|
|
210
|
-
});
|
|
211
|
-
const terminal = latest ? canonicalTerminal(viewOfRun(latest, candidate.run.conversationId)) : undefined;
|
|
212
|
-
if (terminal)
|
|
213
|
-
return { settled: terminal };
|
|
214
|
-
const current = latest?.run;
|
|
215
|
-
if (!current || !canRetryTerminal(current, candidate.run, input.runtimeEpoch)) {
|
|
216
|
-
throw new AgentRuntimeConflictError2("terminal commit");
|
|
217
|
-
}
|
|
218
|
-
return {
|
|
219
|
-
candidate: current.state === "interrupt_requested" ? interruptedCandidate(candidate, current, input.now) : { ...candidate, run: current }
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
async function absorbedBy(store, candidate) {
|
|
223
|
-
const views = await Promise.all((candidate.absorb ?? []).map(({ runId }) => store.loadRun({ conversationId: candidate.run.conversationId, runId }).catch(() => {
|
|
224
|
-
return;
|
|
225
|
-
})));
|
|
226
|
-
return views.flatMap((view) => view?.run.absorbedIntoRunId === candidate.run.id ? [view.run] : []);
|
|
227
|
-
}
|
|
228
|
-
async function commitAgentRunTerminal(input) {
|
|
229
|
-
let candidate = input.candidate;
|
|
230
|
-
let storeFailures = 0;
|
|
231
|
-
for (let attempt = 0;attempt < TERMINAL_COMMIT_ATTEMPTS; attempt += 1) {
|
|
232
|
-
try {
|
|
233
|
-
const round = await attemptTerminalCommit(input, candidate);
|
|
234
|
-
if (!round.settled) {
|
|
235
|
-
candidate = round.candidate;
|
|
236
|
-
continue;
|
|
237
|
-
}
|
|
238
|
-
const owned = storeFailures > 0 && round.settled.run.ownerId === input.runtimeEpoch && round.settled.run.fencingToken === candidate.run.fencingToken;
|
|
239
|
-
if (!owned)
|
|
240
|
-
return round.settled;
|
|
241
|
-
const absorbed = await absorbedBy(input.store, candidate);
|
|
242
|
-
return {
|
|
243
|
-
...round.settled,
|
|
244
|
-
committedByCaller: true,
|
|
245
|
-
...absorbed.length > 0 && { absorbed }
|
|
246
|
-
};
|
|
247
|
-
} catch (error) {
|
|
248
|
-
if (error instanceof AgentRuntimeConflictError2)
|
|
249
|
-
throw error;
|
|
250
|
-
const delay = storeRetryDelay(storeFailures);
|
|
251
|
-
if (delay === undefined)
|
|
252
|
-
throw error;
|
|
253
|
-
storeFailures += 1;
|
|
254
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
throw new AgentRuntimeConflictError2("terminal commit");
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// src/agent-runtime/runtime-internals.ts
|
|
261
|
-
function findRun(runs, runId) {
|
|
262
|
-
const run = runs.find((candidate) => candidate.id === runId);
|
|
263
|
-
if (!run)
|
|
264
|
-
throw new AgentRuntimeConflictError2("run lookup");
|
|
265
|
-
return run;
|
|
266
|
-
}
|
|
267
|
-
function jsonValue(value) {
|
|
268
|
-
const parsed = z.json().safeParse(value);
|
|
269
|
-
return parsed.success ? parsed.data : { message: "Non-JSON tool output omitted" };
|
|
270
|
-
}
|
|
271
|
-
function providerEnvelope(value) {
|
|
272
|
-
const parsed = AgentJsonObjectSchema2.safeParse(value);
|
|
273
|
-
if (!parsed.success)
|
|
274
|
-
return;
|
|
275
|
-
return { schemaVersion: 1, provider: "ai-sdk", data: parsed.data };
|
|
276
|
-
}
|
|
277
|
-
function providerResponseIdentity(id, provider) {
|
|
278
|
-
return AgentProviderResponseSchema2.parse({
|
|
279
|
-
id,
|
|
280
|
-
...typeof provider === "string" && provider.length > 0 ? { provider } : {}
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
function appendText(parts, text) {
|
|
284
|
-
const previous = parts.at(-1);
|
|
285
|
-
if (previous?.type === "text") {
|
|
286
|
-
const next = AgentMessagePartSchema2.parse({ ...previous, text: previous.text + text });
|
|
287
|
-
parts.splice(parts.length - 1, 1, next);
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
parts.push(AgentMessagePartSchema2.parse({ type: "text", text }));
|
|
291
|
-
}
|
|
292
|
-
function abortTerminalReason(signal) {
|
|
293
|
-
if (signal.reason === "shutdown")
|
|
294
|
-
return "shutdown";
|
|
295
|
-
if (signal.reason === "timeout")
|
|
296
|
-
return "timeout";
|
|
297
|
-
if (signal.reason === "supersede")
|
|
298
|
-
return "superseded";
|
|
299
|
-
return "interrupted";
|
|
300
|
-
}
|
|
301
|
-
function addUsage(total, step) {
|
|
302
|
-
const sum = (left, right) => {
|
|
303
|
-
if (left?.value === undefined && right?.value === undefined) {
|
|
304
|
-
return { provenance: "unavailable" };
|
|
305
|
-
}
|
|
306
|
-
if (left?.value === undefined)
|
|
307
|
-
return { ...right, provenance: "computed" };
|
|
308
|
-
if (right?.value === undefined)
|
|
309
|
-
return { ...left, provenance: "computed" };
|
|
310
|
-
return { value: left.value + right.value, provenance: "computed" };
|
|
311
|
-
};
|
|
312
|
-
const sumCost = (left, right) => {
|
|
313
|
-
if (left?.value === undefined || right?.value === undefined) {
|
|
314
|
-
return { provenance: "unavailable" };
|
|
315
|
-
}
|
|
316
|
-
if (left.currency !== right.currency)
|
|
317
|
-
return { provenance: "unavailable" };
|
|
318
|
-
return {
|
|
319
|
-
value: left.value + right.value,
|
|
320
|
-
...left.currency && { currency: left.currency },
|
|
321
|
-
provenance: "computed"
|
|
322
|
-
};
|
|
323
|
-
};
|
|
324
|
-
if (!total)
|
|
325
|
-
return step;
|
|
326
|
-
const cost = sumCost(total.cost, step.cost);
|
|
327
|
-
return {
|
|
328
|
-
inputTokens: sum(total.inputTokens, step.inputTokens),
|
|
329
|
-
outputTokens: sum(total.outputTokens, step.outputTokens),
|
|
330
|
-
reasoningTokens: sum(total.reasoningTokens, step.reasoningTokens),
|
|
331
|
-
cacheReadTokens: sum(total.cacheReadTokens, step.cacheReadTokens),
|
|
332
|
-
cacheWriteTokens: sum(total.cacheWriteTokens, step.cacheWriteTokens),
|
|
333
|
-
...cost && { cost }
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
function mergeModelTotals(sdkTotal, accumulated) {
|
|
337
|
-
const pick = (total, ours) => {
|
|
338
|
-
if (ours?.provenance === "unavailable")
|
|
339
|
-
return ours;
|
|
340
|
-
return total?.value !== undefined ? { value: total.value, provenance: "computed" } : ours ?? { provenance: "unavailable" };
|
|
341
|
-
};
|
|
342
|
-
return {
|
|
343
|
-
inputTokens: pick(sdkTotal.inputTokens, accumulated?.inputTokens),
|
|
344
|
-
outputTokens: pick(sdkTotal.outputTokens, accumulated?.outputTokens),
|
|
345
|
-
reasoningTokens: pick(sdkTotal.reasoningTokens, accumulated?.reasoningTokens),
|
|
346
|
-
cacheReadTokens: pick(sdkTotal.cacheReadTokens, accumulated?.cacheReadTokens),
|
|
347
|
-
cacheWriteTokens: pick(sdkTotal.cacheWriteTokens, accumulated?.cacheWriteTokens),
|
|
348
|
-
cost: accumulated?.cost ?? { provenance: "unavailable" }
|
|
349
|
-
};
|
|
350
|
-
}
|
|
351
|
-
function statedUsage(usage) {
|
|
352
|
-
const stated = (value) => value ?? { provenance: "unavailable" };
|
|
353
|
-
if (!usage)
|
|
354
|
-
return unknownUsage();
|
|
355
|
-
return {
|
|
356
|
-
inputTokens: stated(usage.inputTokens),
|
|
357
|
-
outputTokens: stated(usage.outputTokens),
|
|
358
|
-
reasoningTokens: stated(usage.reasoningTokens),
|
|
359
|
-
cacheReadTokens: stated(usage.cacheReadTokens),
|
|
360
|
-
cacheWriteTokens: stated(usage.cacheWriteTokens),
|
|
361
|
-
cost: stated(usage.cost)
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
function unknownUsage() {
|
|
365
|
-
const nothing = { provenance: "unavailable" };
|
|
366
|
-
return {
|
|
367
|
-
inputTokens: nothing,
|
|
368
|
-
outputTokens: nothing,
|
|
369
|
-
reasoningTokens: nothing,
|
|
370
|
-
cacheReadTokens: nothing,
|
|
371
|
-
cacheWriteTokens: nothing,
|
|
372
|
-
cost: nothing
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
function normalizeSdkUsage(value) {
|
|
376
|
-
const reported = (tokens) => tokens === undefined || !Number.isSafeInteger(tokens) || tokens < 0 ? { provenance: "unavailable" } : { value: tokens, provenance: "provider-reported" };
|
|
377
|
-
return {
|
|
378
|
-
inputTokens: reported(value.inputTokens),
|
|
379
|
-
outputTokens: reported(value.outputTokens),
|
|
380
|
-
reasoningTokens: reported(value.outputTokenDetails.reasoningTokens),
|
|
381
|
-
cacheReadTokens: reported(value.inputTokenDetails.cacheReadTokens),
|
|
382
|
-
cacheWriteTokens: reported(value.inputTokenDetails.cacheWriteTokens)
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
function createIdleDeadline(parent, timeoutMs) {
|
|
386
|
-
if (timeoutMs === undefined) {
|
|
387
|
-
const noop = () => {
|
|
388
|
-
return;
|
|
389
|
-
};
|
|
390
|
-
return {
|
|
391
|
-
signal: parent,
|
|
392
|
-
touch: noop,
|
|
393
|
-
start: noop,
|
|
394
|
-
stop: noop,
|
|
395
|
-
suspend: noop,
|
|
396
|
-
resume: noop,
|
|
397
|
-
dispose: noop
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
const controller = new AbortController;
|
|
401
|
-
let timer;
|
|
402
|
-
let active = false;
|
|
403
|
-
let suspended = 0;
|
|
404
|
-
const clear = () => {
|
|
405
|
-
if (timer !== undefined)
|
|
406
|
-
clearTimeout(timer);
|
|
407
|
-
timer = undefined;
|
|
408
|
-
};
|
|
409
|
-
const touch = () => {
|
|
410
|
-
clear();
|
|
411
|
-
if (!active || suspended > 0 || controller.signal.aborted)
|
|
412
|
-
return;
|
|
413
|
-
timer = setTimeout(() => controller.abort("timeout"), timeoutMs);
|
|
414
|
-
};
|
|
415
|
-
return {
|
|
416
|
-
signal: AbortSignal.any([parent, controller.signal]),
|
|
417
|
-
touch,
|
|
418
|
-
start() {
|
|
419
|
-
active = true;
|
|
420
|
-
touch();
|
|
421
|
-
},
|
|
422
|
-
stop() {
|
|
423
|
-
active = false;
|
|
424
|
-
clear();
|
|
425
|
-
},
|
|
426
|
-
suspend() {
|
|
427
|
-
suspended += 1;
|
|
428
|
-
clear();
|
|
429
|
-
},
|
|
430
|
-
resume() {
|
|
431
|
-
suspended = Math.max(0, suspended - 1);
|
|
432
|
-
touch();
|
|
433
|
-
},
|
|
434
|
-
dispose() {
|
|
435
|
-
active = false;
|
|
436
|
-
clear();
|
|
437
|
-
}
|
|
438
|
-
};
|
|
439
|
-
}
|
|
110
|
+
transportResult,
|
|
111
|
+
mapObjectTypeBoundary
|
|
112
|
+
} from "./index-ps3djm8d.js";
|
|
113
|
+
import {
|
|
114
|
+
assertTimerMs,
|
|
115
|
+
withDeadline
|
|
116
|
+
} from "./index-agy5fqgf.js";
|
|
117
|
+
import {
|
|
118
|
+
raceAbort,
|
|
119
|
+
linkAbortSignals
|
|
120
|
+
} from "./index-rptj3qnc.js";
|
|
440
121
|
|
|
441
122
|
// src/agent-runtime/context-refusal.ts
|
|
442
123
|
class AgentContextOverflowError2 extends Error {
|
|
@@ -448,11 +129,8 @@ class AgentContextOverflowError2 extends Error {
|
|
|
448
129
|
|
|
449
130
|
// src/agent-runtime/coordinator.ts
|
|
450
131
|
function assertCloseBudgets(options) {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
throw new TypeError(`${name} must be a non-negative safe integer`);
|
|
454
|
-
}
|
|
455
|
-
}
|
|
132
|
+
assertTimerMs("Agent session close gracePeriodMs", options.gracePeriodMs, { min: 0 });
|
|
133
|
+
assertTimerMs("Agent session close forceTimeoutMs", options.forceTimeoutMs, { min: 0 });
|
|
456
134
|
}
|
|
457
135
|
function createAgentSessionCoordinator2() {
|
|
458
136
|
const lanes = new Map;
|
|
@@ -460,15 +138,7 @@ function createAgentSessionCoordinator2() {
|
|
|
460
138
|
const waitWithin = async (settled, timeoutMs) => {
|
|
461
139
|
if (timeoutMs === 0)
|
|
462
140
|
return false;
|
|
463
|
-
|
|
464
|
-
const timeout = new Promise((resolve) => {
|
|
465
|
-
timer = setTimeout(() => resolve(false), timeoutMs);
|
|
466
|
-
});
|
|
467
|
-
const completed = settled.then(() => true);
|
|
468
|
-
const result = await Promise.race([completed, timeout]);
|
|
469
|
-
if (timer !== undefined)
|
|
470
|
-
clearTimeout(timer);
|
|
471
|
-
return result;
|
|
141
|
+
return (await withDeadline(settled, timeoutMs)).settled;
|
|
472
142
|
};
|
|
473
143
|
const laneFor = (key) => {
|
|
474
144
|
const existing = lanes.get(key);
|
|
@@ -603,6 +273,14 @@ function registerDeferredToolCatalog(tools, searchName, names) {
|
|
|
603
273
|
if (search && typeof search === "object")
|
|
604
274
|
catalogs.set(search, names);
|
|
605
275
|
}
|
|
276
|
+
function carryDeferredToolCatalog(from, to) {
|
|
277
|
+
for (const [name, tool] of Object.entries(from)) {
|
|
278
|
+
const names = tool && typeof tool === "object" ? catalogs.get(tool) : undefined;
|
|
279
|
+
const next = to[name];
|
|
280
|
+
if (names && next && typeof next === "object")
|
|
281
|
+
catalogs.set(next, names);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
606
284
|
function deferredToolCatalog(tools, searchName) {
|
|
607
285
|
const search = tools[searchName];
|
|
608
286
|
return search && typeof search === "object" ? catalogs.get(search) : undefined;
|
|
@@ -884,468 +562,18 @@ async function projectAgentHistory2(messages, options = {}) {
|
|
|
884
562
|
return [...(await projectAgentHistoryDetailed2(messages, options)).messages];
|
|
885
563
|
}
|
|
886
564
|
|
|
887
|
-
// src/agent-runtime/invocation-attempt.ts
|
|
888
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
889
|
-
import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypto";
|
|
890
|
-
import { wrapLanguageModel } from "ai";
|
|
891
|
-
|
|
892
|
-
// src/agent-runtime/invocation-failure.ts
|
|
893
|
-
class InvocationReceiptError extends Error {
|
|
894
|
-
constructor(cause) {
|
|
895
|
-
super("Model invocation receipt could not be recorded", { cause });
|
|
896
|
-
this.name = "InvocationReceiptError";
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
async function invocationAudit(work) {
|
|
900
|
-
try {
|
|
901
|
-
return await work();
|
|
902
|
-
} catch (error) {
|
|
903
|
-
throw error instanceof InvocationReceiptError ? error : new InvocationReceiptError(error);
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
// src/agent-runtime/invocation-payload.ts
|
|
908
|
-
import {
|
|
909
|
-
createCipheriv,
|
|
910
|
-
createDecipheriv,
|
|
911
|
-
createHash,
|
|
912
|
-
randomBytes,
|
|
913
|
-
randomUUID
|
|
914
|
-
} from "node:crypto";
|
|
915
|
-
import { z as z3 } from "zod";
|
|
916
|
-
|
|
917
|
-
// src/agent-runtime/invocation-schema.ts
|
|
918
|
-
import { z as z2 } from "zod";
|
|
919
|
-
var Id = z2.string().min(1).max(512);
|
|
920
|
-
var Hash = z2.string().regex(/^[a-f0-9]{64}$/);
|
|
921
|
-
var ModelInvocationTraceSchema2 = z2.object({
|
|
922
|
-
operationId: Id,
|
|
923
|
-
purpose: Id,
|
|
924
|
-
project: Id,
|
|
925
|
-
parent: z2.object({ traceId: Id, invocationId: Id.optional() }).strict().optional(),
|
|
926
|
-
experiment: Id.optional(),
|
|
927
|
-
case: Id.optional(),
|
|
928
|
-
profile: Id.optional()
|
|
929
|
-
}).strict();
|
|
930
|
-
var CompletionInvocationInputSchema2 = z2.object({
|
|
931
|
-
conversationId: Id,
|
|
932
|
-
idempotencyKey: Id,
|
|
933
|
-
trace: ModelInvocationTraceSchema2,
|
|
934
|
-
prompt: z2.string().min(1),
|
|
935
|
-
models: z2.array(Id).min(1).max(8),
|
|
936
|
-
settings: z2.object({
|
|
937
|
-
maxOutputTokens: z2.int().positive().optional(),
|
|
938
|
-
temperature: z2.number().finite().optional(),
|
|
939
|
-
topP: z2.number().min(0).max(1).optional(),
|
|
940
|
-
seed: z2.int().optional()
|
|
941
|
-
}).strict().optional(),
|
|
942
|
-
timeoutMs: z2.int().positive().max(3600000)
|
|
943
|
-
}).strict();
|
|
944
|
-
var Identity = z2.object({
|
|
945
|
-
provider: Id.nullable(),
|
|
946
|
-
modelId: Id.nullable(),
|
|
947
|
-
responseId: Id.nullable()
|
|
948
|
-
}).strict();
|
|
949
|
-
var InvocationCallerSchema = z2.object({ subject: Id }).strict();
|
|
950
|
-
var InvocationProcessSchema = z2.object({
|
|
951
|
-
instanceId: Id,
|
|
952
|
-
pid: z2.int().positive(),
|
|
953
|
-
hostname: Id
|
|
954
|
-
}).strict();
|
|
955
|
-
var Base = z2.object({
|
|
956
|
-
conversationId: Id,
|
|
957
|
-
invocationId: Id,
|
|
958
|
-
operationId: Id,
|
|
959
|
-
runId: Id.optional()
|
|
960
|
-
});
|
|
961
|
-
var InvocationStartedSchema = Base.extend({
|
|
962
|
-
type: z2.literal("invocation/started"),
|
|
963
|
-
mode: z2.enum(["completion", "agent"]),
|
|
964
|
-
trace: ModelInvocationTraceSchema2,
|
|
965
|
-
caller: InvocationCallerSchema,
|
|
966
|
-
executingProcess: InvocationProcessSchema,
|
|
967
|
-
fingerprint: Hash,
|
|
968
|
-
requested: z2.object({ models: z2.array(Id), payloadSha256: Hash }).strict()
|
|
969
|
-
}).strict();
|
|
970
|
-
var InvocationAttemptContextSchema = Base.extend({
|
|
971
|
-
attemptId: Id,
|
|
972
|
-
step: z2.int().nonnegative()
|
|
973
|
-
}).strict();
|
|
974
|
-
var Attempt = Base.extend({ attemptId: Id, step: z2.int().nonnegative() });
|
|
975
|
-
var InvocationRequestSchema = Attempt.extend({
|
|
976
|
-
type: z2.literal("provider/request"),
|
|
977
|
-
requested: z2.object({ modelId: Id, provider: Id }).strict(),
|
|
978
|
-
executingProcess: InvocationProcessSchema,
|
|
979
|
-
sent: z2.object({
|
|
980
|
-
modelId: Id,
|
|
981
|
-
provider: Id,
|
|
982
|
-
payloadSha256: Hash,
|
|
983
|
-
artifactId: Id,
|
|
984
|
-
tools: z2.int().nonnegative()
|
|
985
|
-
}).strict()
|
|
986
|
-
}).strict();
|
|
987
|
-
var InvocationResponseSchema = Attempt.extend({
|
|
988
|
-
type: z2.literal("provider/response"),
|
|
989
|
-
status: z2.enum(["succeeded", "failed", "cancelled"]),
|
|
990
|
-
effective: Identity,
|
|
991
|
-
usage: AgentUsageSchema2,
|
|
992
|
-
artifactId: Id,
|
|
993
|
-
payloadSha256: Hash
|
|
994
|
-
}).strict();
|
|
995
|
-
var InvocationFinishedSchema = Base.extend({
|
|
996
|
-
type: z2.literal("invocation/finished"),
|
|
997
|
-
failure: z2.object({ artifactId: Id, payloadSha256: Hash }).strict().optional(),
|
|
998
|
-
status: z2.enum(["succeeded", "failed", "cancelled"])
|
|
999
|
-
}).strict();
|
|
1000
|
-
var ModelInvocationRecordSchema2 = z2.discriminatedUnion("type", [
|
|
1001
|
-
InvocationStartedSchema,
|
|
1002
|
-
InvocationRequestSchema,
|
|
1003
|
-
InvocationResponseSchema,
|
|
1004
|
-
InvocationFinishedSchema
|
|
1005
|
-
]);
|
|
1006
|
-
var InvocationPayloadSchema = Base.extend({
|
|
1007
|
-
artifactId: Id,
|
|
1008
|
-
sha256: Hash,
|
|
1009
|
-
bytes: z2.int().nonnegative(),
|
|
1010
|
-
iv: z2.string(),
|
|
1011
|
-
tag: z2.string(),
|
|
1012
|
-
ciphertext: z2.string()
|
|
1013
|
-
}).strict();
|
|
1014
|
-
|
|
1015
|
-
// src/agent-runtime/invocation-payload.ts
|
|
1016
|
-
function invocationJson(value) {
|
|
1017
|
-
const errors = new WeakSet;
|
|
1018
|
-
return z3.json().parse(JSON.parse(JSON.stringify(value, (_key, item) => {
|
|
1019
|
-
if (item instanceof Uint8Array)
|
|
1020
|
-
return { base64: Buffer.from(item).toString("base64") };
|
|
1021
|
-
if (item instanceof ArrayBuffer)
|
|
1022
|
-
return { base64: Buffer.from(item).toString("base64") };
|
|
1023
|
-
if (item instanceof Error) {
|
|
1024
|
-
if (errors.has(item))
|
|
1025
|
-
return { name: item.name, message: item.message };
|
|
1026
|
-
errors.add(item);
|
|
1027
|
-
return { name: item.name, message: item.message, cause: item.cause };
|
|
1028
|
-
}
|
|
1029
|
-
return item;
|
|
1030
|
-
})));
|
|
1031
|
-
}
|
|
1032
|
-
function invocationHash(value) {
|
|
1033
|
-
return createHash("sha256").update(serializeCanonicalJson(invocationJson(value))).digest("hex");
|
|
1034
|
-
}
|
|
1035
|
-
function createInvocationPayloads(store, key, maxBytes) {
|
|
1036
|
-
if (key.byteLength !== 32)
|
|
1037
|
-
throw new TypeError("Invocation payload key must contain 32 bytes");
|
|
1038
|
-
const encryptionKey = Uint8Array.from(key);
|
|
1039
|
-
return {
|
|
1040
|
-
maxBytes,
|
|
1041
|
-
async write(identity, value) {
|
|
1042
|
-
const data = Buffer.from(serializeCanonicalJson(invocationJson(value)));
|
|
1043
|
-
if (data.byteLength > maxBytes)
|
|
1044
|
-
throw new RangeError("Invocation payload exceeds maxPayloadBytes");
|
|
1045
|
-
const artifactId = randomUUID();
|
|
1046
|
-
const sha256 = createHash("sha256").update(data).digest("hex");
|
|
1047
|
-
const iv = randomBytes(12);
|
|
1048
|
-
const cipher = createCipheriv("aes-256-gcm", encryptionKey, iv);
|
|
1049
|
-
cipher.setAAD(Buffer.from(JSON.stringify([identity.conversationId, identity.invocationId, artifactId])));
|
|
1050
|
-
const ciphertext = Buffer.concat([cipher.update(data), cipher.final()]);
|
|
1051
|
-
const { conversationId } = identity;
|
|
1052
|
-
if (!store.appendEventOnce)
|
|
1053
|
-
throw new TypeError("Invocation payloads require atomic store.appendEventOnce");
|
|
1054
|
-
await store.appendEventOnce({
|
|
1055
|
-
conversationId,
|
|
1056
|
-
kind: "provider/payload",
|
|
1057
|
-
payload: {
|
|
1058
|
-
...identity,
|
|
1059
|
-
artifactId,
|
|
1060
|
-
sha256,
|
|
1061
|
-
bytes: data.byteLength,
|
|
1062
|
-
iv: iv.toString("base64"),
|
|
1063
|
-
tag: cipher.getAuthTag().toString("base64"),
|
|
1064
|
-
ciphertext: ciphertext.toString("base64")
|
|
1065
|
-
}
|
|
1066
|
-
}, artifactId);
|
|
1067
|
-
return { artifactId, sha256 };
|
|
1068
|
-
},
|
|
1069
|
-
decrypt(conversationId, value) {
|
|
1070
|
-
const payload = InvocationPayloadSchema.parse(value);
|
|
1071
|
-
if (payload.bytes > maxBytes || payload.ciphertext.length > Math.ceil(maxBytes / 3) * 4) {
|
|
1072
|
-
throw new RangeError("Invocation payload exceeds maxPayloadBytes");
|
|
1073
|
-
}
|
|
1074
|
-
const decipher = createDecipheriv("aes-256-gcm", encryptionKey, Buffer.from(payload.iv, "base64"));
|
|
1075
|
-
decipher.setAAD(Buffer.from(JSON.stringify([conversationId, payload.invocationId, payload.artifactId])));
|
|
1076
|
-
decipher.setAuthTag(Buffer.from(payload.tag, "base64"));
|
|
1077
|
-
const data = Buffer.concat([
|
|
1078
|
-
decipher.update(Buffer.from(payload.ciphertext, "base64")),
|
|
1079
|
-
decipher.final()
|
|
1080
|
-
]);
|
|
1081
|
-
if (data.length !== payload.bytes || createHash("sha256").update(data).digest("hex") !== payload.sha256) {
|
|
1082
|
-
throw new Error("Invocation payload integrity mismatch");
|
|
1083
|
-
}
|
|
1084
|
-
return z3.json().parse(JSON.parse(data.toString("utf8")));
|
|
1085
|
-
}
|
|
1086
|
-
};
|
|
1087
|
-
}
|
|
1088
|
-
|
|
1089
|
-
// src/agent-runtime/provider-origin.ts
|
|
1090
|
-
import {
|
|
1091
|
-
InvalidToolApprovalError,
|
|
1092
|
-
InvalidToolApprovalSignatureError,
|
|
1093
|
-
ToolCallNotFoundForApprovalError
|
|
1094
|
-
} from "ai";
|
|
1095
|
-
var providerOrigin = new WeakSet;
|
|
1096
|
-
function isOwnInputRefusal(error) {
|
|
1097
|
-
return InvalidToolApprovalSignatureError.isInstance(error) || InvalidToolApprovalError.isInstance(error) || ToolCallNotFoundForApprovalError.isInstance(error);
|
|
1098
|
-
}
|
|
1099
|
-
function markProviderOrigin(error) {
|
|
1100
|
-
if (typeof error === "object" && error !== null)
|
|
1101
|
-
providerOrigin.add(error);
|
|
1102
|
-
return error;
|
|
1103
|
-
}
|
|
1104
|
-
function hasProviderOrigin(error) {
|
|
1105
|
-
return typeof error === "object" && error !== null && providerOrigin.has(error);
|
|
1106
|
-
}
|
|
1107
|
-
function markProviderStream(stream) {
|
|
1108
|
-
const reader = stream.getReader();
|
|
1109
|
-
return new ReadableStream({
|
|
1110
|
-
async pull(controller) {
|
|
1111
|
-
let read;
|
|
1112
|
-
try {
|
|
1113
|
-
read = await reader.read();
|
|
1114
|
-
} catch (error) {
|
|
1115
|
-
controller.error(isOwnInputRefusal(error) ? error : markProviderOrigin(error));
|
|
1116
|
-
return;
|
|
1117
|
-
}
|
|
1118
|
-
if (read.done)
|
|
1119
|
-
controller.close();
|
|
1120
|
-
else
|
|
1121
|
-
controller.enqueue(read.value);
|
|
1122
|
-
},
|
|
1123
|
-
cancel(reason) {
|
|
1124
|
-
return reader.cancel(reason);
|
|
1125
|
-
}
|
|
1126
|
-
});
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
// src/agent-runtime/invocation-attempt.ts
|
|
1130
|
-
var currentAttempt = new AsyncLocalStorage;
|
|
1131
|
-
function currentModelInvocationAttempt2() {
|
|
1132
|
-
const value = currentAttempt.getStore();
|
|
1133
|
-
return value && { ...value };
|
|
1134
|
-
}
|
|
1135
|
-
function wrapInvocationModel(writer, selected, step, model = selected.model) {
|
|
1136
|
-
if (typeof model === "string")
|
|
1137
|
-
throw new TypeError("Invocation receipts require a resolved model object");
|
|
1138
|
-
const begin = async (params) => invocationAudit(async () => {
|
|
1139
|
-
const context = { ...writer.identity, step, attemptId: randomUUID2() };
|
|
1140
|
-
const { headers: _headers, abortSignal: _signal, ...payload } = params;
|
|
1141
|
-
const artifact = await writer.payloads.write(writer.identity, payload);
|
|
1142
|
-
await writer.append({
|
|
1143
|
-
...writer.identity,
|
|
1144
|
-
type: "provider/request",
|
|
1145
|
-
attemptId: context.attemptId,
|
|
1146
|
-
step,
|
|
1147
|
-
executingProcess: writer.process,
|
|
1148
|
-
requested: {
|
|
1149
|
-
modelId: selected.descriptor.modelId,
|
|
1150
|
-
provider: selected.descriptor.provider
|
|
1151
|
-
},
|
|
1152
|
-
sent: {
|
|
1153
|
-
modelId: model.modelId,
|
|
1154
|
-
provider: model.provider,
|
|
1155
|
-
payloadSha256: artifact.sha256,
|
|
1156
|
-
artifactId: artifact.artifactId,
|
|
1157
|
-
tools: params.tools?.length ?? 0
|
|
1158
|
-
}
|
|
1159
|
-
});
|
|
1160
|
-
try {
|
|
1161
|
-
await writer.onAttempt?.({ ...context });
|
|
1162
|
-
} catch (error) {
|
|
1163
|
-
await finish(context, "failed", { phase: "transport-audit", error });
|
|
1164
|
-
throw error;
|
|
1165
|
-
}
|
|
1166
|
-
return context;
|
|
1167
|
-
});
|
|
1168
|
-
const finish = (...args) => recordResponse(...args).catch((error) => {
|
|
1169
|
-
writer.receiptErrors.push(error);
|
|
1170
|
-
});
|
|
1171
|
-
const recordResponse = async (context, status, payload, usage, response, providerMetadata) => invocationAudit(async () => {
|
|
1172
|
-
const artifact = await writer.payloads.write(writer.identity, boundedEvidence(payload, Math.floor(writer.payloads.maxBytes / 2)));
|
|
1173
|
-
await writer.append({
|
|
1174
|
-
...writer.identity,
|
|
1175
|
-
type: "provider/response",
|
|
1176
|
-
attemptId: context.attemptId,
|
|
1177
|
-
step,
|
|
1178
|
-
status,
|
|
1179
|
-
effective: {
|
|
1180
|
-
provider: selected.resolveResponseProvider?.({ providerMetadata }) ?? null,
|
|
1181
|
-
modelId: response?.modelId ?? null,
|
|
1182
|
-
responseId: response?.id ?? null
|
|
1183
|
-
},
|
|
1184
|
-
usage: reportedUsage(selected, usage, providerMetadata),
|
|
1185
|
-
artifactId: artifact.artifactId,
|
|
1186
|
-
payloadSha256: artifact.sha256
|
|
1187
|
-
});
|
|
1188
|
-
});
|
|
1189
|
-
return wrapLanguageModel({
|
|
1190
|
-
model,
|
|
1191
|
-
middleware: {
|
|
1192
|
-
specificationVersion: "v4",
|
|
1193
|
-
async wrapGenerate({ doGenerate, params }) {
|
|
1194
|
-
const context = await begin(params);
|
|
1195
|
-
let result;
|
|
1196
|
-
try {
|
|
1197
|
-
result = await currentAttempt.run(context, doGenerate);
|
|
1198
|
-
} catch (error) {
|
|
1199
|
-
await finish(context, params.abortSignal?.aborted ? "cancelled" : "failed", {
|
|
1200
|
-
error
|
|
1201
|
-
});
|
|
1202
|
-
throw markProviderOrigin(error);
|
|
1203
|
-
}
|
|
1204
|
-
await finish(context, result.finishReason.unified === "error" ? "failed" : "succeeded", {
|
|
1205
|
-
content: result.content,
|
|
1206
|
-
usage: result.usage,
|
|
1207
|
-
response: result.response,
|
|
1208
|
-
providerMetadata: result.providerMetadata
|
|
1209
|
-
}, result.usage, result.response, result.providerMetadata);
|
|
1210
|
-
if (result.finishReason.unified === "error") {
|
|
1211
|
-
throw markProviderOrigin(new Error("Provider returned an error finish reason"));
|
|
1212
|
-
}
|
|
1213
|
-
return result;
|
|
1214
|
-
},
|
|
1215
|
-
async wrapStream({ doStream, params }) {
|
|
1216
|
-
const context = await begin(params);
|
|
1217
|
-
let result;
|
|
1218
|
-
try {
|
|
1219
|
-
result = await currentAttempt.run(context, doStream);
|
|
1220
|
-
} catch (error) {
|
|
1221
|
-
await finish(context, params.abortSignal?.aborted ? "cancelled" : "failed", {
|
|
1222
|
-
error
|
|
1223
|
-
});
|
|
1224
|
-
throw markProviderOrigin(error);
|
|
1225
|
-
}
|
|
1226
|
-
const reader = result.stream.getReader();
|
|
1227
|
-
let ended = false;
|
|
1228
|
-
let failed = false;
|
|
1229
|
-
let response;
|
|
1230
|
-
const evidence = streamEvidence(Math.floor(writer.payloads.maxBytes / 2));
|
|
1231
|
-
const end = async (status, value, usage, metadata) => {
|
|
1232
|
-
if (ended)
|
|
1233
|
-
return;
|
|
1234
|
-
ended = true;
|
|
1235
|
-
await finish(context, status, evidence.payload(value), usage, response, metadata);
|
|
1236
|
-
};
|
|
1237
|
-
return {
|
|
1238
|
-
...result,
|
|
1239
|
-
stream: new ReadableStream({
|
|
1240
|
-
async pull(controller) {
|
|
1241
|
-
let next;
|
|
1242
|
-
try {
|
|
1243
|
-
next = await currentAttempt.run(context, () => reader.read());
|
|
1244
|
-
} catch (error) {
|
|
1245
|
-
await end(params.abortSignal?.aborted ? "cancelled" : "failed", { error });
|
|
1246
|
-
controller.error(markProviderOrigin(error));
|
|
1247
|
-
return;
|
|
1248
|
-
}
|
|
1249
|
-
if (next.done) {
|
|
1250
|
-
await end("failed", { reason: "stream-ended-without-finish" });
|
|
1251
|
-
controller.close();
|
|
1252
|
-
return;
|
|
1253
|
-
}
|
|
1254
|
-
const part = next.value;
|
|
1255
|
-
if (part.type === "response-metadata")
|
|
1256
|
-
response = part;
|
|
1257
|
-
if (part.type === "finish") {
|
|
1258
|
-
await end(failed || part.finishReason.unified === "error" ? "failed" : "succeeded", part, part.usage, part.providerMetadata);
|
|
1259
|
-
} else {
|
|
1260
|
-
if (part.type === "error")
|
|
1261
|
-
failed = true;
|
|
1262
|
-
evidence.record(part);
|
|
1263
|
-
}
|
|
1264
|
-
controller.enqueue(part);
|
|
1265
|
-
},
|
|
1266
|
-
async cancel(reason) {
|
|
1267
|
-
try {
|
|
1268
|
-
await currentAttempt.run(context, () => reader.cancel(reason));
|
|
1269
|
-
} finally {
|
|
1270
|
-
await end("cancelled", { reason: "consumer-cancelled" });
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
})
|
|
1274
|
-
};
|
|
1275
|
-
}
|
|
1276
|
-
}
|
|
1277
|
-
});
|
|
1278
|
-
}
|
|
1279
|
-
function boundedEvidence(payload, limit) {
|
|
1280
|
-
const serialized = JSON.stringify(invocationJson(payload));
|
|
1281
|
-
const bytes = Buffer.byteLength(serialized);
|
|
1282
|
-
if (bytes <= limit)
|
|
1283
|
-
return payload;
|
|
1284
|
-
return {
|
|
1285
|
-
truncated: { bytes, sha256: createHash2("sha256").update(serialized).digest("hex") }
|
|
1286
|
-
};
|
|
1287
|
-
}
|
|
1288
|
-
function streamEvidence(limit) {
|
|
1289
|
-
const output = [];
|
|
1290
|
-
const whole = createHash2("sha256");
|
|
1291
|
-
let bytes = 0;
|
|
1292
|
-
let parts = 0;
|
|
1293
|
-
let truncated = false;
|
|
1294
|
-
return {
|
|
1295
|
-
record(part) {
|
|
1296
|
-
const json = invocationJson(part);
|
|
1297
|
-
const serialized = JSON.stringify(json);
|
|
1298
|
-
whole.update(serialized).update(`
|
|
1299
|
-
`);
|
|
1300
|
-
parts += 1;
|
|
1301
|
-
const size = Buffer.byteLength(serialized);
|
|
1302
|
-
if (!truncated && bytes + size > limit)
|
|
1303
|
-
truncated = true;
|
|
1304
|
-
if (truncated)
|
|
1305
|
-
return;
|
|
1306
|
-
bytes += size;
|
|
1307
|
-
output.push(json);
|
|
1308
|
-
},
|
|
1309
|
-
payload(terminal) {
|
|
1310
|
-
return {
|
|
1311
|
-
output,
|
|
1312
|
-
terminal,
|
|
1313
|
-
...truncated && { truncated: { parts, sha256: whole.digest("hex") } }
|
|
1314
|
-
};
|
|
1315
|
-
}
|
|
1316
|
-
};
|
|
1317
|
-
}
|
|
1318
|
-
function reportedUsage(selected, value, providerMetadata) {
|
|
1319
|
-
const usage = {
|
|
1320
|
-
inputTokens: value?.inputTokens.total,
|
|
1321
|
-
outputTokens: value?.outputTokens.total,
|
|
1322
|
-
totalTokens: undefined,
|
|
1323
|
-
inputTokenDetails: {
|
|
1324
|
-
noCacheTokens: value?.inputTokens.noCache,
|
|
1325
|
-
cacheReadTokens: value?.inputTokens.cacheRead,
|
|
1326
|
-
cacheWriteTokens: value?.inputTokens.cacheWrite
|
|
1327
|
-
},
|
|
1328
|
-
outputTokenDetails: {
|
|
1329
|
-
textTokens: value?.outputTokens.text,
|
|
1330
|
-
reasoningTokens: value?.outputTokens.reasoning
|
|
1331
|
-
},
|
|
1332
|
-
...value?.raw && { raw: value.raw }
|
|
1333
|
-
};
|
|
1334
|
-
return selected.normalizeUsage?.({ usage, providerMetadata }) ?? normalizeSdkUsage(usage);
|
|
1335
|
-
}
|
|
1336
|
-
|
|
1337
565
|
// src/agent-runtime/invocations.ts
|
|
1338
|
-
import { randomUUID
|
|
566
|
+
import { randomUUID } from "node:crypto";
|
|
1339
567
|
import { hostname } from "node:os";
|
|
1340
568
|
import { generateText } from "ai";
|
|
1341
|
-
import { z as
|
|
569
|
+
import { z as z2 } from "zod";
|
|
1342
570
|
|
|
1343
571
|
// src/agent-runtime/invocation-read.ts
|
|
1344
|
-
import { z
|
|
1345
|
-
var InvocationReadInputSchema =
|
|
1346
|
-
conversationId:
|
|
1347
|
-
fromSeq:
|
|
1348
|
-
limit:
|
|
572
|
+
import { z } from "zod";
|
|
573
|
+
var InvocationReadInputSchema = z.object({
|
|
574
|
+
conversationId: z.string().min(1),
|
|
575
|
+
fromSeq: z.int().positive().optional(),
|
|
576
|
+
limit: z.int().positive().max(1e4)
|
|
1349
577
|
}).strict();
|
|
1350
578
|
async function readInvocationRecords(store, input) {
|
|
1351
579
|
const page = await store.readEvents(InvocationReadInputSchema.parse(input));
|
|
@@ -1358,7 +586,7 @@ async function readInvocationRecords(store, input) {
|
|
|
1358
586
|
"provider/response"
|
|
1359
587
|
].includes(event.kind))
|
|
1360
588
|
return [];
|
|
1361
|
-
if (!
|
|
589
|
+
if (!isModelInvocationRecord(event.payload))
|
|
1362
590
|
return [];
|
|
1363
591
|
return [
|
|
1364
592
|
{
|
|
@@ -1371,6 +599,27 @@ async function readInvocationRecords(store, input) {
|
|
|
1371
599
|
...page.nextSeq !== undefined && { nextSeq: page.nextSeq }
|
|
1372
600
|
};
|
|
1373
601
|
}
|
|
602
|
+
function decodeStoredPayload(payloads, conversationId, raw) {
|
|
603
|
+
const expired = InvocationExpiredPayloadSchema.safeParse(raw);
|
|
604
|
+
if (expired.success) {
|
|
605
|
+
return ModelInvocationPayloadReadSchema2.parse({
|
|
606
|
+
status: "expired",
|
|
607
|
+
artifactId: expired.data.artifactId,
|
|
608
|
+
sha256: expired.data.sha256,
|
|
609
|
+
bytes: expired.data.bytes,
|
|
610
|
+
expiredAt: expired.data.expiredAt
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
const live = InvocationPayloadSchema.parse(raw);
|
|
614
|
+
const payload = payloads.decrypt(conversationId, live);
|
|
615
|
+
return ModelInvocationPayloadReadSchema2.parse({
|
|
616
|
+
status: "available",
|
|
617
|
+
artifactId: live.artifactId,
|
|
618
|
+
sha256: live.sha256,
|
|
619
|
+
bytes: live.bytes,
|
|
620
|
+
payload
|
|
621
|
+
});
|
|
622
|
+
}
|
|
1374
623
|
async function readInvocationPayload(store, payloads, input) {
|
|
1375
624
|
const keyed = await store.findEventOnce?.({
|
|
1376
625
|
conversationId: input.conversationId,
|
|
@@ -1378,7 +627,7 @@ async function readInvocationPayload(store, payloads, input) {
|
|
|
1378
627
|
key: input.artifactId
|
|
1379
628
|
});
|
|
1380
629
|
if (keyed)
|
|
1381
|
-
return payloads
|
|
630
|
+
return decodeStoredPayload(payloads, input.conversationId, keyed.payload);
|
|
1382
631
|
let fromSeq;
|
|
1383
632
|
do {
|
|
1384
633
|
const page = await store.readEvents({
|
|
@@ -1389,9 +638,10 @@ async function readInvocationPayload(store, payloads, input) {
|
|
|
1389
638
|
for (const event of page.items) {
|
|
1390
639
|
if (event.kind !== "provider/payload")
|
|
1391
640
|
continue;
|
|
1392
|
-
const
|
|
1393
|
-
if (
|
|
1394
|
-
return payloads
|
|
641
|
+
const stored = InvocationStoredPayloadSchema.parse(event.payload);
|
|
642
|
+
if (stored.artifactId === input.artifactId) {
|
|
643
|
+
return decodeStoredPayload(payloads, input.conversationId, stored);
|
|
644
|
+
}
|
|
1395
645
|
}
|
|
1396
646
|
fromSeq = page.nextSeq;
|
|
1397
647
|
} while (fromSeq !== undefined);
|
|
@@ -1399,7 +649,7 @@ async function readInvocationPayload(store, payloads, input) {
|
|
|
1399
649
|
}
|
|
1400
650
|
|
|
1401
651
|
// src/agent-runtime/invocations.ts
|
|
1402
|
-
var executingProcess = { instanceId:
|
|
652
|
+
var executingProcess = { instanceId: randomUUID(), pid: process.pid, hostname: hostname() };
|
|
1403
653
|
var agentBindings = new WeakMap;
|
|
1404
654
|
function beginAgentInvocation(ledger, store, input, context) {
|
|
1405
655
|
const binding = agentBindings.get(ledger);
|
|
@@ -1431,12 +681,52 @@ async function generateWithFallback(models, writer, input, abortSignal) {
|
|
|
1431
681
|
}
|
|
1432
682
|
throw new Error("No completion model attempt available");
|
|
1433
683
|
}
|
|
684
|
+
function finishInvocation(writer, status, failure) {
|
|
685
|
+
return writer.append({
|
|
686
|
+
...writer.identity,
|
|
687
|
+
type: "invocation/finished",
|
|
688
|
+
status,
|
|
689
|
+
...failure && { failure }
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
async function runCompletion(config, payloads, writer, input, signal) {
|
|
693
|
+
const invocationId = writer.identity.invocationId;
|
|
694
|
+
const deadline = AbortSignal.timeout(input.timeoutMs);
|
|
695
|
+
const { signal: abortSignal, release } = linkAbortSignals(signal, deadline);
|
|
696
|
+
let text;
|
|
697
|
+
try {
|
|
698
|
+
text = await generateWithFallback(config.models, writer, input, abortSignal);
|
|
699
|
+
} catch (error) {
|
|
700
|
+
const status = abortSignal.aborted ? "cancelled" : "failed";
|
|
701
|
+
release();
|
|
702
|
+
try {
|
|
703
|
+
const artifact = await payloads.write(writer.identity, { error });
|
|
704
|
+
await finishInvocation(writer, status, {
|
|
705
|
+
artifactId: artifact.artifactId,
|
|
706
|
+
payloadSha256: artifact.sha256
|
|
707
|
+
});
|
|
708
|
+
} catch (receiptError) {
|
|
709
|
+
writer.receiptErrors.push(receiptError);
|
|
710
|
+
await finishInvocation(writer, status).catch((appendError) => {
|
|
711
|
+
writer.receiptErrors.push(appendError);
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
return withReceipt({ invocationId, outcome: status }, writer);
|
|
715
|
+
}
|
|
716
|
+
release();
|
|
717
|
+
try {
|
|
718
|
+
await finishInvocation(writer, "succeeded");
|
|
719
|
+
} catch (receiptError) {
|
|
720
|
+
writer.receiptErrors.push(receiptError);
|
|
721
|
+
}
|
|
722
|
+
return withReceipt({ invocationId, outcome: "succeeded", text }, writer);
|
|
723
|
+
}
|
|
1434
724
|
function createModelInvocationLedger2(config) {
|
|
1435
725
|
const { store } = config;
|
|
1436
726
|
const appendOnce = store.appendEventOnce?.bind(store);
|
|
1437
727
|
if (!appendOnce)
|
|
1438
728
|
throw new TypeError("Model invocations require atomic store.appendEventOnce");
|
|
1439
|
-
const maxPayloadBytes =
|
|
729
|
+
const maxPayloadBytes = z2.int().min(1024).max(64 * 1024 * 1024).parse(config.maxPayloadBytes ?? 4 * 1024 * 1024);
|
|
1440
730
|
const payloads = createInvocationPayloads(store, config.payloadKey, maxPayloadBytes);
|
|
1441
731
|
const authorize = async (input) => InvocationCallerSchema.parse(await config.authorize(input));
|
|
1442
732
|
const start = async (input) => {
|
|
@@ -1455,7 +745,7 @@ function createModelInvocationLedger2(config) {
|
|
|
1455
745
|
});
|
|
1456
746
|
const identity = {
|
|
1457
747
|
conversationId: input.conversationId,
|
|
1458
|
-
invocationId:
|
|
748
|
+
invocationId: randomUUID(),
|
|
1459
749
|
operationId: trace.operationId,
|
|
1460
750
|
...input.runId && { runId: input.runId }
|
|
1461
751
|
};
|
|
@@ -1490,12 +780,6 @@ function createModelInvocationLedger2(config) {
|
|
|
1490
780
|
};
|
|
1491
781
|
return { writer, duplicate: admission.outcome === "duplicate" };
|
|
1492
782
|
};
|
|
1493
|
-
const finish = (writer, status, failure) => writer.append({
|
|
1494
|
-
...writer.identity,
|
|
1495
|
-
type: "invocation/finished",
|
|
1496
|
-
status,
|
|
1497
|
-
...failure && { failure }
|
|
1498
|
-
});
|
|
1499
783
|
const ledger = {
|
|
1500
784
|
async complete(rawInput, context, signal) {
|
|
1501
785
|
const input = CompletionInvocationInputSchema2.parse(rawInput);
|
|
@@ -1508,36 +792,9 @@ function createModelInvocationLedger2(config) {
|
|
|
1508
792
|
requested: input,
|
|
1509
793
|
models: input.models
|
|
1510
794
|
});
|
|
1511
|
-
const invocationId = writer.identity.invocationId;
|
|
1512
795
|
if (duplicate)
|
|
1513
|
-
return { invocationId, outcome: "duplicate" };
|
|
1514
|
-
|
|
1515
|
-
const abortSignal = signal ? AbortSignal.any([signal, deadline]) : deadline;
|
|
1516
|
-
let text;
|
|
1517
|
-
try {
|
|
1518
|
-
text = await generateWithFallback(config.models, writer, input, abortSignal);
|
|
1519
|
-
} catch (error) {
|
|
1520
|
-
const status = abortSignal.aborted ? "cancelled" : "failed";
|
|
1521
|
-
try {
|
|
1522
|
-
const artifact = await payloads.write(writer.identity, { error });
|
|
1523
|
-
await finish(writer, status, {
|
|
1524
|
-
artifactId: artifact.artifactId,
|
|
1525
|
-
payloadSha256: artifact.sha256
|
|
1526
|
-
});
|
|
1527
|
-
} catch (receiptError) {
|
|
1528
|
-
writer.receiptErrors.push(receiptError);
|
|
1529
|
-
await finish(writer, status).catch((error) => {
|
|
1530
|
-
writer.receiptErrors.push(error);
|
|
1531
|
-
});
|
|
1532
|
-
}
|
|
1533
|
-
return withReceipt({ invocationId, outcome: status }, writer);
|
|
1534
|
-
}
|
|
1535
|
-
try {
|
|
1536
|
-
await finish(writer, "succeeded");
|
|
1537
|
-
} catch (receiptError) {
|
|
1538
|
-
writer.receiptErrors.push(receiptError);
|
|
1539
|
-
}
|
|
1540
|
-
return withReceipt({ invocationId, outcome: "succeeded", text }, writer);
|
|
796
|
+
return { invocationId: writer.identity.invocationId, outcome: "duplicate" };
|
|
797
|
+
return runCompletion(config, payloads, writer, input, signal);
|
|
1541
798
|
},
|
|
1542
799
|
async read(rawInput, context) {
|
|
1543
800
|
const input = InvocationReadInputSchema.parse(rawInput);
|
|
@@ -1551,6 +808,18 @@ function createModelInvocationLedger2(config) {
|
|
|
1551
808
|
action: "read-payload"
|
|
1552
809
|
});
|
|
1553
810
|
return readInvocationPayload(store, payloads, input);
|
|
811
|
+
},
|
|
812
|
+
async purgePayloads(rawInput, context) {
|
|
813
|
+
const input = PurgeInvocationPayloadsInputSchema2.parse(rawInput);
|
|
814
|
+
await authorize({
|
|
815
|
+
context,
|
|
816
|
+
...input.conversationId !== undefined && { conversationId: input.conversationId },
|
|
817
|
+
action: "purge-payloads"
|
|
818
|
+
});
|
|
819
|
+
if (!store.purgeExpiredPayloads) {
|
|
820
|
+
throw new TypeError("Model invocation payload purge requires store.purgeExpiredPayloads");
|
|
821
|
+
}
|
|
822
|
+
return store.purgeExpiredPayloads(input);
|
|
1554
823
|
}
|
|
1555
824
|
};
|
|
1556
825
|
agentBindings.set(ledger, {
|
|
@@ -1573,7 +842,7 @@ function createModelInvocationLedger2(config) {
|
|
|
1573
842
|
});
|
|
1574
843
|
return {
|
|
1575
844
|
wrap: (selected, step, override) => wrapInvocationModel(writer, selected, step, override),
|
|
1576
|
-
finish: (status) =>
|
|
845
|
+
finish: (status) => finishInvocation(writer, status)
|
|
1577
846
|
};
|
|
1578
847
|
}
|
|
1579
848
|
});
|
|
@@ -1605,9 +874,9 @@ function createAgentToolFenceLifecycle2(config) {
|
|
|
1605
874
|
}
|
|
1606
875
|
|
|
1607
876
|
// src/agent-runtime/prompt.ts
|
|
1608
|
-
import { z as
|
|
1609
|
-
var AgentTokenCountSchema2 =
|
|
1610
|
-
value:
|
|
877
|
+
import { z as z3 } from "zod";
|
|
878
|
+
var AgentTokenCountSchema2 = z3.object({
|
|
879
|
+
value: z3.int().nonnegative().optional(),
|
|
1611
880
|
provenance: AgentProvenanceSchema2.extract([
|
|
1612
881
|
"measured",
|
|
1613
882
|
"computed",
|
|
@@ -1727,7 +996,7 @@ function knownValue(value) {
|
|
|
1727
996
|
}
|
|
1728
997
|
function composeAgentPrompt2(sections) {
|
|
1729
998
|
return async (options) => {
|
|
1730
|
-
const event =
|
|
999
|
+
const event = z3.enum(["session.started", "turn.started"]).parse(options.event ?? "turn.started");
|
|
1731
1000
|
const rendered = [];
|
|
1732
1001
|
let systemTotal = 0;
|
|
1733
1002
|
let userTotal = 0;
|
|
@@ -1913,12 +1182,16 @@ function parseJson(value) {
|
|
|
1913
1182
|
}
|
|
1914
1183
|
|
|
1915
1184
|
// src/agent-runtime/retry-policy.ts
|
|
1185
|
+
function assertAgentRetryPolicy(subject, policy) {
|
|
1186
|
+
assertPositiveSafeInteger(`${subject}.maxAttempts`, policy.maxAttempts, TypeError, {
|
|
1187
|
+
absent: "refused"
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1916
1190
|
async function recordAgentRetryDecision2(input) {
|
|
1191
|
+
assertAgentRetryPolicy("Retry policy", input.policy);
|
|
1917
1192
|
const retry = input.failure.retryable && input.attempt < input.policy.maxAttempts;
|
|
1918
1193
|
const delayMs = retry ? input.policy.delayMs({ attempt: input.attempt, failure: input.failure }) : 0;
|
|
1919
|
-
|
|
1920
|
-
throw new TypeError("Retry delay must be a non-negative integer");
|
|
1921
|
-
}
|
|
1194
|
+
assertTimerMs("Retry delayMs", delayMs, { min: 0, absent: "refused" });
|
|
1922
1195
|
if (retry) {
|
|
1923
1196
|
await input.store.appendEvent({
|
|
1924
1197
|
conversationId: input.conversationId,
|
|
@@ -1929,6 +1202,246 @@ async function recordAgentRetryDecision2(input) {
|
|
|
1929
1202
|
return { retry, delayMs };
|
|
1930
1203
|
}
|
|
1931
1204
|
|
|
1205
|
+
// src/agent-runtime/run-step-barriers.ts
|
|
1206
|
+
class AgentStepBarrierError2 extends Error {
|
|
1207
|
+
bound;
|
|
1208
|
+
constructor(bound, message) {
|
|
1209
|
+
super(message);
|
|
1210
|
+
this.bound = bound;
|
|
1211
|
+
this.name = "AgentStepBarrierError";
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
function assertStepBarriers(barriers) {
|
|
1215
|
+
if (!barriers)
|
|
1216
|
+
return;
|
|
1217
|
+
assertPositiveSafeInteger("stepBarriers.maxToolCallsPerStep", barriers.maxToolCallsPerStep, RangeError);
|
|
1218
|
+
assertPositiveSafeInteger("stepBarriers.maxReasoningCharsPerStep", barriers.maxReasoningCharsPerStep, RangeError);
|
|
1219
|
+
if (barriers.stepText !== undefined && !["immediate", "after-tools"].includes(barriers.stepText))
|
|
1220
|
+
throw new RangeError("stepBarriers.stepText must be 'immediate' or 'after-tools'");
|
|
1221
|
+
}
|
|
1222
|
+
function isAsyncIterable(value) {
|
|
1223
|
+
return value !== null && typeof value === "object" && typeof Reflect.get(value, Symbol.asyncIterator) === "function";
|
|
1224
|
+
}
|
|
1225
|
+
function isAsyncGeneratorFunction(value) {
|
|
1226
|
+
return Object.prototype.toString.call(value) === "[object AsyncGeneratorFunction]";
|
|
1227
|
+
}
|
|
1228
|
+
async function finalOutput(value) {
|
|
1229
|
+
if (!isAsyncIterable(value))
|
|
1230
|
+
return value;
|
|
1231
|
+
let last;
|
|
1232
|
+
for await (const output of value)
|
|
1233
|
+
last = output;
|
|
1234
|
+
return last;
|
|
1235
|
+
}
|
|
1236
|
+
function createStepLedger(barriers) {
|
|
1237
|
+
let current;
|
|
1238
|
+
return (messages, toolCallId, toolName, input) => {
|
|
1239
|
+
if (current === undefined || current.messages !== messages)
|
|
1240
|
+
current = { messages, count: 0, calls: new Map, entities: new Map };
|
|
1241
|
+
const ledger = current;
|
|
1242
|
+
const known = ledger.calls.get(toolCallId);
|
|
1243
|
+
if (known)
|
|
1244
|
+
return known;
|
|
1245
|
+
ledger.count += 1;
|
|
1246
|
+
const limit = barriers.maxToolCallsPerStep;
|
|
1247
|
+
const refused = limit !== undefined && ledger.count > limit;
|
|
1248
|
+
const own = Promise.withResolvers();
|
|
1249
|
+
const dependencies = refused ? undefined : barriers.toolDependencies?.({ toolName, input });
|
|
1250
|
+
const writes = new Set(dependencies?.writes ?? []);
|
|
1251
|
+
const reads = new Set([...dependencies?.reads ?? []].filter((entity) => !writes.has(entity)));
|
|
1252
|
+
const stateOf = (entity) => {
|
|
1253
|
+
const known = ledger.entities.get(entity);
|
|
1254
|
+
if (known)
|
|
1255
|
+
return known;
|
|
1256
|
+
const fresh = { reads: [] };
|
|
1257
|
+
ledger.entities.set(entity, fresh);
|
|
1258
|
+
return fresh;
|
|
1259
|
+
};
|
|
1260
|
+
const ahead = [];
|
|
1261
|
+
for (const entity of reads) {
|
|
1262
|
+
const state = stateOf(entity);
|
|
1263
|
+
if (state.write)
|
|
1264
|
+
ahead.push(state.write);
|
|
1265
|
+
state.reads.push(own.promise);
|
|
1266
|
+
}
|
|
1267
|
+
for (const entity of writes) {
|
|
1268
|
+
const state = stateOf(entity);
|
|
1269
|
+
if (state.write)
|
|
1270
|
+
ahead.push(state.write);
|
|
1271
|
+
ahead.push(...state.reads);
|
|
1272
|
+
state.write = own.promise;
|
|
1273
|
+
state.reads = [];
|
|
1274
|
+
}
|
|
1275
|
+
const entry = { refused, ahead, settle: () => own.resolve() };
|
|
1276
|
+
ledger.calls.set(toolCallId, entry);
|
|
1277
|
+
return entry;
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1280
|
+
function isPromiseLike(value) {
|
|
1281
|
+
return (typeof value === "object" || typeof value === "function") && value !== null && typeof Reflect.get(value, "then") === "function";
|
|
1282
|
+
}
|
|
1283
|
+
function settleOnDecision(entry, produce, skipsExecute) {
|
|
1284
|
+
let result;
|
|
1285
|
+
try {
|
|
1286
|
+
result = produce();
|
|
1287
|
+
} catch (error) {
|
|
1288
|
+
entry.settle();
|
|
1289
|
+
throw error;
|
|
1290
|
+
}
|
|
1291
|
+
if (isPromiseLike(result)) {
|
|
1292
|
+
return Promise.resolve(result).then((value) => {
|
|
1293
|
+
if (skipsExecute(value))
|
|
1294
|
+
entry.settle();
|
|
1295
|
+
return value;
|
|
1296
|
+
}, (error) => {
|
|
1297
|
+
entry.settle();
|
|
1298
|
+
throw error;
|
|
1299
|
+
});
|
|
1300
|
+
}
|
|
1301
|
+
if (skipsExecute(result))
|
|
1302
|
+
entry.settle();
|
|
1303
|
+
return result;
|
|
1304
|
+
}
|
|
1305
|
+
function approvalSkipsExecute(decision) {
|
|
1306
|
+
if (decision === undefined)
|
|
1307
|
+
return false;
|
|
1308
|
+
const status = typeof decision === "object" && decision !== null && "type" in decision ? Reflect.get(decision, "type") : decision;
|
|
1309
|
+
return status !== "approved" && status !== "not-applicable";
|
|
1310
|
+
}
|
|
1311
|
+
var callLimitRefusal = (limit) => new AgentToolError2({
|
|
1312
|
+
code: "STEP_TOOL_CALL_LIMIT",
|
|
1313
|
+
message: `Refused: a step may make at most ${limit} tool calls; make the rest in the next step`
|
|
1314
|
+
});
|
|
1315
|
+
function applyStepBarriers(tools, toolApproval, barriers) {
|
|
1316
|
+
if (!barriers || barriers.maxToolCallsPerStep === undefined && !barriers.toolDependencies)
|
|
1317
|
+
return { tools, toolApproval };
|
|
1318
|
+
const enter = createStepLedger(barriers);
|
|
1319
|
+
const limit = barriers.maxToolCallsPerStep;
|
|
1320
|
+
const executableTools = new Set;
|
|
1321
|
+
const wrapped = mapObjectTypeBoundary(tools, (name, tool) => {
|
|
1322
|
+
const toolName = String(name);
|
|
1323
|
+
const execute = tool.execute;
|
|
1324
|
+
if (typeof execute !== "function")
|
|
1325
|
+
return tool;
|
|
1326
|
+
executableTools.add(toolName);
|
|
1327
|
+
const { onInputAvailable, needsApproval } = tool;
|
|
1328
|
+
const settled = (entry, result) => {
|
|
1329
|
+
if (isAsyncIterable(result))
|
|
1330
|
+
return async function* () {
|
|
1331
|
+
try {
|
|
1332
|
+
yield* result;
|
|
1333
|
+
} finally {
|
|
1334
|
+
entry.settle();
|
|
1335
|
+
}
|
|
1336
|
+
}();
|
|
1337
|
+
return Promise.resolve(result).then(finalOutput).finally(entry.settle);
|
|
1338
|
+
};
|
|
1339
|
+
return {
|
|
1340
|
+
...tool,
|
|
1341
|
+
onInputAvailable: async (options) => {
|
|
1342
|
+
const entry = enter(options.messages, options.toolCallId, toolName, options.input);
|
|
1343
|
+
if (!onInputAvailable)
|
|
1344
|
+
return;
|
|
1345
|
+
try {
|
|
1346
|
+
await onInputAvailable.call(tool, options);
|
|
1347
|
+
} catch (error) {
|
|
1348
|
+
entry.settle();
|
|
1349
|
+
throw error;
|
|
1350
|
+
}
|
|
1351
|
+
},
|
|
1352
|
+
...needsApproval !== undefined && {
|
|
1353
|
+
needsApproval: (input, options) => {
|
|
1354
|
+
const entry = enter(options.messages, options.toolCallId, toolName, input);
|
|
1355
|
+
if (entry.refused)
|
|
1356
|
+
return false;
|
|
1357
|
+
return settleOnDecision(entry, () => typeof needsApproval === "function" ? needsApproval.call(tool, input, options) : needsApproval, (value) => Boolean(value));
|
|
1358
|
+
}
|
|
1359
|
+
},
|
|
1360
|
+
execute: (input, options) => {
|
|
1361
|
+
const entry = enter(options.messages, options.toolCallId, toolName, input);
|
|
1362
|
+
if (entry.refused) {
|
|
1363
|
+
entry.settle();
|
|
1364
|
+
throw callLimitRefusal(limit);
|
|
1365
|
+
}
|
|
1366
|
+
if (entry.ahead.length === 0) {
|
|
1367
|
+
try {
|
|
1368
|
+
return settled(entry, execute.call(tool, input, options));
|
|
1369
|
+
} catch (error) {
|
|
1370
|
+
entry.settle();
|
|
1371
|
+
throw error;
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
const waitAhead = () => {
|
|
1375
|
+
const all = Promise.all(entry.ahead);
|
|
1376
|
+
return options.abortSignal ? raceAbort(all, options.abortSignal) : all;
|
|
1377
|
+
};
|
|
1378
|
+
const start = () => waitAhead().then(() => execute.call(tool, input, options));
|
|
1379
|
+
if (isAsyncGeneratorFunction(execute))
|
|
1380
|
+
return async function* () {
|
|
1381
|
+
try {
|
|
1382
|
+
const result = await start();
|
|
1383
|
+
if (isAsyncIterable(result))
|
|
1384
|
+
yield* result;
|
|
1385
|
+
} finally {
|
|
1386
|
+
entry.settle();
|
|
1387
|
+
}
|
|
1388
|
+
}();
|
|
1389
|
+
return Promise.resolve().then(start).then(finalOutput).finally(entry.settle);
|
|
1390
|
+
}
|
|
1391
|
+
};
|
|
1392
|
+
});
|
|
1393
|
+
carryDeferredToolCatalog(tools, wrapped);
|
|
1394
|
+
return { tools: wrapped, toolApproval: boundApproval(toolApproval, enter, executableTools) };
|
|
1395
|
+
}
|
|
1396
|
+
function boundApproval(approval, enter, executableTools) {
|
|
1397
|
+
if (approval === undefined)
|
|
1398
|
+
return;
|
|
1399
|
+
if (typeof approval === "function")
|
|
1400
|
+
return (options) => {
|
|
1401
|
+
if (!executableTools.has(options.toolCall.toolName) || options.toolCall.providerExecuted === true) {
|
|
1402
|
+
return approval(options);
|
|
1403
|
+
}
|
|
1404
|
+
const entry = enter(options.messages, options.toolCall.toolCallId, options.toolCall.toolName, options.toolCall.input);
|
|
1405
|
+
if (entry.refused)
|
|
1406
|
+
return "not-applicable";
|
|
1407
|
+
return settleOnDecision(entry, () => approval(options), approvalSkipsExecute);
|
|
1408
|
+
};
|
|
1409
|
+
return mapObjectTypeBoundary(approval, (name, decide) => {
|
|
1410
|
+
const toolName = String(name);
|
|
1411
|
+
if (!executableTools.has(toolName) || decide === undefined)
|
|
1412
|
+
return decide;
|
|
1413
|
+
return (input, options) => {
|
|
1414
|
+
const entry = enter(options.messages, options.toolCallId, toolName, input);
|
|
1415
|
+
if (entry.refused)
|
|
1416
|
+
return "not-applicable";
|
|
1417
|
+
return settleOnDecision(entry, () => typeof decide === "function" ? Reflect.apply(decide, undefined, [input, options]) : decide, approvalSkipsExecute);
|
|
1418
|
+
};
|
|
1419
|
+
});
|
|
1420
|
+
}
|
|
1421
|
+
function createToolDependencyResolver2(input) {
|
|
1422
|
+
const effects = new Map;
|
|
1423
|
+
for (const contract of input.contracts ?? []) {
|
|
1424
|
+
const byEndpoint = contractOperationEffects2(contract);
|
|
1425
|
+
for (const entry of listContractToolNames2([contract])) {
|
|
1426
|
+
const effect = byEndpoint[entry.method];
|
|
1427
|
+
if (effect !== undefined)
|
|
1428
|
+
effects.set(entry.name, effect);
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
for (const [toolName, effect] of Object.entries(input.effects ?? {})) {
|
|
1432
|
+
if (effects.has(toolName))
|
|
1433
|
+
throw new RangeError(`Tool "${toolName}" already has the effect of its contract endpoint`);
|
|
1434
|
+
effects.set(toolName, effect);
|
|
1435
|
+
}
|
|
1436
|
+
return ({ toolName, input: callInput }) => {
|
|
1437
|
+
const effect = effects.get(toolName);
|
|
1438
|
+
const entity = effect && input.entityOf(toolName, callInput);
|
|
1439
|
+
if (entity === undefined || effect === undefined)
|
|
1440
|
+
return;
|
|
1441
|
+
return effect === "write" ? { writes: [entity] } : { reads: [entity] };
|
|
1442
|
+
};
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1932
1445
|
// src/agent-runtime/runtime-control.ts
|
|
1933
1446
|
async function interruptAgentRun(state, input) {
|
|
1934
1447
|
const { store } = state.config;
|
|
@@ -2042,15 +1555,7 @@ function createRuntimeAdmissionGate() {
|
|
|
2042
1555
|
await settled;
|
|
2043
1556
|
return 0;
|
|
2044
1557
|
}
|
|
2045
|
-
|
|
2046
|
-
await Promise.race([
|
|
2047
|
-
settled,
|
|
2048
|
-
new Promise((resolve) => {
|
|
2049
|
-
timer = setTimeout(resolve, budgetMs);
|
|
2050
|
-
})
|
|
2051
|
-
]);
|
|
2052
|
-
if (timer !== undefined)
|
|
2053
|
-
clearTimeout(timer);
|
|
1558
|
+
await withDeadline(settled, budgetMs);
|
|
2054
1559
|
return stranded;
|
|
2055
1560
|
};
|
|
2056
1561
|
return { closed: false, begin, drain };
|
|
@@ -2340,83 +1845,8 @@ function createAgentInjectionRegistry() {
|
|
|
2340
1845
|
};
|
|
2341
1846
|
}
|
|
2342
1847
|
|
|
2343
|
-
// src/agent-runtime/run-execution-state.ts
|
|
2344
|
-
function adoptSnapshot(state, next) {
|
|
2345
|
-
state.snapshot = next;
|
|
2346
|
-
state.observedVersion = next.version;
|
|
2347
|
-
state.run = findRun(next.runs, state.run.id);
|
|
2348
|
-
}
|
|
2349
|
-
function transientSequence(state) {
|
|
2350
|
-
state.sequence += 1;
|
|
2351
|
-
return state.sequence;
|
|
2352
|
-
}
|
|
2353
|
-
function billedUsage(state) {
|
|
2354
|
-
return state.abandonedUsage && state.modelUsage ? addUsage(state.abandonedUsage, state.modelUsage) : state.abandonedUsage ?? state.modelUsage;
|
|
2355
|
-
}
|
|
2356
|
-
function updateReasoning(state, text, metadata) {
|
|
2357
|
-
const { parts } = state;
|
|
2358
|
-
const provider = providerEnvelope(metadata);
|
|
2359
|
-
if (state.reasoningPartIndex === undefined) {
|
|
2360
|
-
state.reasoningPartIndex = parts.length;
|
|
2361
|
-
parts.push(AgentMessagePartSchema2.parse({
|
|
2362
|
-
type: "reasoning",
|
|
2363
|
-
text,
|
|
2364
|
-
...provider && { provider }
|
|
2365
|
-
}));
|
|
2366
|
-
return;
|
|
2367
|
-
}
|
|
2368
|
-
const current = parts[state.reasoningPartIndex];
|
|
2369
|
-
if (current?.type !== "reasoning") {
|
|
2370
|
-
throw new AgentRuntimeConflictError2("reasoning accumulator");
|
|
2371
|
-
}
|
|
2372
|
-
parts.splice(state.reasoningPartIndex, 1, AgentMessagePartSchema2.parse({
|
|
2373
|
-
...current,
|
|
2374
|
-
text: current.text + text,
|
|
2375
|
-
...provider && { provider }
|
|
2376
|
-
}));
|
|
2377
|
-
}
|
|
2378
|
-
function checkpoint(execution) {
|
|
2379
|
-
const { config, runtimeEpoch, publish, now } = execution.dependencies;
|
|
2380
|
-
const { state } = execution;
|
|
2381
|
-
return execution.serialize(async () => {
|
|
2382
|
-
state.assistant = AgentMessageSchema2.parse({
|
|
2383
|
-
...state.assistant,
|
|
2384
|
-
parts: state.parts,
|
|
2385
|
-
updatedAt: now().toISOString()
|
|
2386
|
-
});
|
|
2387
|
-
const run = state.run;
|
|
2388
|
-
adoptSnapshot(state, appliedSnapshot(await config.store.checkpointRunAssistant({
|
|
2389
|
-
conversationId: run.conversationId,
|
|
2390
|
-
runId: run.id,
|
|
2391
|
-
expectedRevision: run.revision,
|
|
2392
|
-
ownerId: runtimeEpoch,
|
|
2393
|
-
...run.fencingToken !== undefined && { fencingToken: run.fencingToken },
|
|
2394
|
-
assistant: state.assistant,
|
|
2395
|
-
usage: statedUsage(state.usage)
|
|
2396
|
-
}), "assistant checkpoint"));
|
|
2397
|
-
const checkpointMetrics = {
|
|
2398
|
-
partial: true,
|
|
2399
|
-
durationMs: performance.now() - execution.runStartedAt,
|
|
2400
|
-
usage: statedUsage(state.usage),
|
|
2401
|
-
...state.firstOutputAt !== undefined && {
|
|
2402
|
-
ttftMs: state.firstOutputAt - execution.runStartedAt
|
|
2403
|
-
}
|
|
2404
|
-
};
|
|
2405
|
-
await publish({
|
|
2406
|
-
type: "assistant-checkpoint",
|
|
2407
|
-
eventId: agentDurableEventId2("assistant-checkpoint", state.run.id, state.observedVersion),
|
|
2408
|
-
conversationId: state.run.conversationId,
|
|
2409
|
-
runId: state.run.id,
|
|
2410
|
-
snapshotVersion: state.observedVersion,
|
|
2411
|
-
message: state.assistant,
|
|
2412
|
-
metrics: checkpointMetrics,
|
|
2413
|
-
emittedAt: now().toISOString()
|
|
2414
|
-
});
|
|
2415
|
-
});
|
|
2416
|
-
}
|
|
2417
|
-
|
|
2418
1848
|
// src/agent-runtime/run-operation-lifecycle.ts
|
|
2419
|
-
import { wrapLanguageModel
|
|
1849
|
+
import { wrapLanguageModel } from "ai";
|
|
2420
1850
|
function createAgentRunOperationLifecycle(config) {
|
|
2421
1851
|
let active;
|
|
2422
1852
|
let providerCallId;
|
|
@@ -2468,7 +1898,7 @@ function createAgentRunOperationLifecycle(config) {
|
|
|
2468
1898
|
await startModelRequest(fallbackCallId, step);
|
|
2469
1899
|
return model;
|
|
2470
1900
|
}
|
|
2471
|
-
return
|
|
1901
|
+
return wrapLanguageModel({
|
|
2472
1902
|
model,
|
|
2473
1903
|
middleware: {
|
|
2474
1904
|
specificationVersion: "v4",
|
|
@@ -2606,6 +2036,7 @@ async function acquireRun(dependencies, input) {
|
|
|
2606
2036
|
usage: input.acceptedRun.usage,
|
|
2607
2037
|
sawProviderFinish: false,
|
|
2608
2038
|
step: 0,
|
|
2039
|
+
stepGuard: { text: "", toolFailed: false, reasoningChars: 0 },
|
|
2609
2040
|
selectedModel: undefined,
|
|
2610
2041
|
internalCause: undefined,
|
|
2611
2042
|
providerStreamCleanupFailure: undefined,
|
|
@@ -2684,6 +2115,8 @@ function failureThisRuntimeOwns(error) {
|
|
|
2684
2115
|
return "context_overflow";
|
|
2685
2116
|
if (error instanceof AgentRuntimeConflictError2)
|
|
2686
2117
|
return "storage_conflict";
|
|
2118
|
+
if (error instanceof AgentStepBarrierError2)
|
|
2119
|
+
return "policy_stop";
|
|
2687
2120
|
if (isOwnInputRefusal(error))
|
|
2688
2121
|
return "runtime_failure";
|
|
2689
2122
|
return;
|
|
@@ -2744,16 +2177,8 @@ import {
|
|
|
2744
2177
|
// src/agent-runtime/owned-provider-stream.ts
|
|
2745
2178
|
var DEFAULT_CLEANUP_TIMEOUT_MS = 1000;
|
|
2746
2179
|
async function settleCleanup(operation, timeoutMs) {
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
timeout = setTimeout(() => reject(new Error(`Provider stream cleanup exceeded ${timeoutMs} ms`)), timeoutMs);
|
|
2750
|
-
});
|
|
2751
|
-
try {
|
|
2752
|
-
await Promise.race([operation, deadline]);
|
|
2753
|
-
} finally {
|
|
2754
|
-
if (timeout !== undefined)
|
|
2755
|
-
clearTimeout(timeout);
|
|
2756
|
-
}
|
|
2180
|
+
if (!(await withDeadline(operation, timeoutMs)).settled)
|
|
2181
|
+
throw new Error(`Provider stream cleanup exceeded ${timeoutMs} ms`);
|
|
2757
2182
|
}
|
|
2758
2183
|
async function* ownedProviderStream(input) {
|
|
2759
2184
|
const iterator = input.stream[Symbol.asyncIterator]();
|
|
@@ -2783,14 +2208,14 @@ async function* ownedProviderStream(input) {
|
|
|
2783
2208
|
}
|
|
2784
2209
|
|
|
2785
2210
|
// src/agent-runtime/run-provider-ledger.ts
|
|
2786
|
-
import { createHash
|
|
2211
|
+
import { createHash } from "node:crypto";
|
|
2787
2212
|
function withoutBinaryParts(message) {
|
|
2788
2213
|
const reference = (value) => {
|
|
2789
2214
|
if (value instanceof Uint8Array || value instanceof ArrayBuffer) {
|
|
2790
2215
|
const bytes = value instanceof ArrayBuffer ? new Uint8Array(value) : value;
|
|
2791
2216
|
return {
|
|
2792
2217
|
binary: true,
|
|
2793
|
-
sha256:
|
|
2218
|
+
sha256: createHash("sha256").update(bytes).digest("hex"),
|
|
2794
2219
|
bytes: bytes.byteLength
|
|
2795
2220
|
};
|
|
2796
2221
|
}
|
|
@@ -2845,7 +2270,7 @@ async function createRunProviderLedger(input) {
|
|
|
2845
2270
|
const messageShas = [];
|
|
2846
2271
|
for (const message of request.messages) {
|
|
2847
2272
|
const body = canonicalAgentJson2(JSON.parse(JSON.stringify(withoutBinaryParts(message))));
|
|
2848
|
-
const sha256 =
|
|
2273
|
+
const sha256 = createHash("sha256").update(body).digest("hex");
|
|
2849
2274
|
messageShas.push(sha256);
|
|
2850
2275
|
if (knownMessageShas.has(sha256))
|
|
2851
2276
|
continue;
|
|
@@ -2856,8 +2281,8 @@ async function createRunProviderLedger(input) {
|
|
|
2856
2281
|
});
|
|
2857
2282
|
knownMessageShas.add(sha256);
|
|
2858
2283
|
}
|
|
2859
|
-
const instructionsSha256 =
|
|
2860
|
-
const bodySha256 =
|
|
2284
|
+
const instructionsSha256 = createHash("sha256").update(typeof request.instructions === "string" ? request.instructions : canonicalAgentJson2(JSON.parse(JSON.stringify(withoutBinaryParts(request.instructions))))).digest("hex");
|
|
2285
|
+
const bodySha256 = createHash("sha256").update(instructionsSha256).update(messageShas.join(",")).digest("hex");
|
|
2861
2286
|
await store.appendEvent({
|
|
2862
2287
|
conversationId: state.run.conversationId,
|
|
2863
2288
|
kind: "provider/request",
|
|
@@ -2883,7 +2308,8 @@ async function createRunProviderLedger(input) {
|
|
|
2883
2308
|
runId: state.run.id,
|
|
2884
2309
|
attempt: response.attempt,
|
|
2885
2310
|
stepNumber: response.stepNumber,
|
|
2886
|
-
response: identity
|
|
2311
|
+
response: identity,
|
|
2312
|
+
usage: response.usage
|
|
2887
2313
|
})
|
|
2888
2314
|
});
|
|
2889
2315
|
return identity;
|
|
@@ -2904,11 +2330,14 @@ function transientHead(execution) {
|
|
|
2904
2330
|
function isOutputPart(part) {
|
|
2905
2331
|
return part.type === "text-delta" && part.text.length > 0 || part.type === "reasoning-delta" && part.text.length > 0 || part.type === "tool-input-delta" && part.delta.length > 0 || part.type === "tool-call";
|
|
2906
2332
|
}
|
|
2907
|
-
var
|
|
2333
|
+
var TOOL_STATUS_PARTS = [
|
|
2908
2334
|
"tool-call",
|
|
2909
2335
|
"tool-result",
|
|
2910
2336
|
"tool-error",
|
|
2911
|
-
"tool-output-denied"
|
|
2337
|
+
"tool-output-denied"
|
|
2338
|
+
];
|
|
2339
|
+
var STRUCTURAL_BOUNDARY_PARTS = [
|
|
2340
|
+
...TOOL_STATUS_PARTS,
|
|
2912
2341
|
"tool-approval-request",
|
|
2913
2342
|
"tool-approval-response",
|
|
2914
2343
|
"finish-step"
|
|
@@ -2916,7 +2345,10 @@ var STRUCTURAL_BOUNDARY_PARTS = [
|
|
|
2916
2345
|
async function applyTextPart(execution, part) {
|
|
2917
2346
|
const { publish, now } = execution.dependencies;
|
|
2918
2347
|
const { state } = execution;
|
|
2919
|
-
|
|
2348
|
+
const barriers = execution.dependencies.config.loop?.stepBarriers;
|
|
2349
|
+
if (part.type === "text-delta" && barriers?.stepText === "after-tools") {
|
|
2350
|
+
state.stepGuard.text += part.text;
|
|
2351
|
+
} else if (part.type === "text-delta") {
|
|
2920
2352
|
appendText(state.parts, part.text);
|
|
2921
2353
|
await publish({
|
|
2922
2354
|
type: "assistant-delta",
|
|
@@ -2935,6 +2367,12 @@ async function applyTextPart(execution, part) {
|
|
|
2935
2367
|
emittedAt: now().toISOString()
|
|
2936
2368
|
});
|
|
2937
2369
|
} else if (part.type === "reasoning-delta") {
|
|
2370
|
+
const limit = barriers?.maxReasoningCharsPerStep;
|
|
2371
|
+
state.stepGuard.reasoningChars += part.text.length;
|
|
2372
|
+
if (limit !== undefined && state.stepGuard.reasoningChars > limit) {
|
|
2373
|
+
state.terminalPolicyName = "stepBarriers.maxReasoningCharsPerStep";
|
|
2374
|
+
throw new AgentStepBarrierError2("reasoning", `A step reasoned past its bound of ${limit} characters`);
|
|
2375
|
+
}
|
|
2938
2376
|
updateReasoning(state, part.text, part.providerMetadata);
|
|
2939
2377
|
const provider = providerEnvelope(part.providerMetadata);
|
|
2940
2378
|
await publish({
|
|
@@ -2957,7 +2395,6 @@ async function applyTextPart(execution, part) {
|
|
|
2957
2395
|
}
|
|
2958
2396
|
}
|
|
2959
2397
|
async function applyToolPart(execution, part) {
|
|
2960
|
-
const { publish, now } = execution.dependencies;
|
|
2961
2398
|
const { state } = execution;
|
|
2962
2399
|
if (part.type === "tool-call") {
|
|
2963
2400
|
const provider = providerEnvelope(part.providerMetadata);
|
|
@@ -2968,16 +2405,15 @@ async function applyToolPart(execution, part) {
|
|
|
2968
2405
|
input: jsonValue(part.input),
|
|
2969
2406
|
...provider && { provider }
|
|
2970
2407
|
}));
|
|
2971
|
-
await
|
|
2972
|
-
type: "tool-status",
|
|
2973
|
-
...transientHead(execution),
|
|
2408
|
+
await checkpoint(execution, {
|
|
2974
2409
|
callId: part.toolCallId,
|
|
2975
2410
|
toolName: part.toolName,
|
|
2976
2411
|
status: "started",
|
|
2977
|
-
input: jsonValue(part.input)
|
|
2978
|
-
emittedAt: now().toISOString()
|
|
2412
|
+
input: jsonValue(part.input)
|
|
2979
2413
|
});
|
|
2980
2414
|
} else if (part.type === "tool-result") {
|
|
2415
|
+
if (part.preliminary === true)
|
|
2416
|
+
return;
|
|
2981
2417
|
state.settledToolCalls.add(part.toolCallId);
|
|
2982
2418
|
state.parts.push(AgentMessagePartSchema2.parse({
|
|
2983
2419
|
type: "tool-result",
|
|
@@ -2986,30 +2422,24 @@ async function applyToolPart(execution, part) {
|
|
|
2986
2422
|
outcome: "success",
|
|
2987
2423
|
output: jsonValue(part.output)
|
|
2988
2424
|
}));
|
|
2989
|
-
await
|
|
2990
|
-
type: "tool-status",
|
|
2991
|
-
...transientHead(execution),
|
|
2425
|
+
await checkpoint(execution, {
|
|
2992
2426
|
callId: part.toolCallId,
|
|
2993
2427
|
toolName: part.toolName,
|
|
2994
2428
|
status: "completed",
|
|
2995
|
-
output: jsonValue(part.output)
|
|
2996
|
-
emittedAt: now().toISOString()
|
|
2429
|
+
output: jsonValue(part.output)
|
|
2997
2430
|
});
|
|
2998
2431
|
} else if (part.type === "tool-error") {
|
|
2999
2432
|
state.settledToolCalls.add(part.toolCallId);
|
|
3000
2433
|
state.internalCause = part.error;
|
|
3001
2434
|
if (isToolExecutionControlError2(part.error)) {
|
|
3002
|
-
await
|
|
3003
|
-
type: "tool-status",
|
|
3004
|
-
...transientHead(execution),
|
|
2435
|
+
await checkpoint(execution, {
|
|
3005
2436
|
callId: part.toolCallId,
|
|
3006
2437
|
toolName: part.toolName,
|
|
3007
|
-
status: "interrupted"
|
|
3008
|
-
emittedAt: now().toISOString()
|
|
2438
|
+
status: "interrupted"
|
|
3009
2439
|
});
|
|
3010
|
-
await checkpoint(execution);
|
|
3011
2440
|
throw part.error;
|
|
3012
2441
|
}
|
|
2442
|
+
state.stepGuard.toolFailed = true;
|
|
3013
2443
|
const output = isAgentToolError2(part.error) ? jsonValue(part.error.output) : { message: "Tool execution failed" };
|
|
3014
2444
|
state.parts.push(AgentMessagePartSchema2.parse({
|
|
3015
2445
|
type: "tool-result",
|
|
@@ -3018,17 +2448,15 @@ async function applyToolPart(execution, part) {
|
|
|
3018
2448
|
outcome: "error",
|
|
3019
2449
|
output
|
|
3020
2450
|
}));
|
|
3021
|
-
await
|
|
3022
|
-
type: "tool-status",
|
|
3023
|
-
...transientHead(execution),
|
|
2451
|
+
await checkpoint(execution, {
|
|
3024
2452
|
callId: part.toolCallId,
|
|
3025
2453
|
toolName: part.toolName,
|
|
3026
2454
|
status: "failed",
|
|
3027
|
-
output
|
|
3028
|
-
emittedAt: now().toISOString()
|
|
2455
|
+
output
|
|
3029
2456
|
});
|
|
3030
2457
|
} else if (part.type === "tool-output-denied") {
|
|
3031
2458
|
state.settledToolCalls.add(part.toolCallId);
|
|
2459
|
+
state.stepGuard.toolFailed = true;
|
|
3032
2460
|
state.parts.push(AgentMessagePartSchema2.parse({
|
|
3033
2461
|
type: "tool-result",
|
|
3034
2462
|
callId: part.toolCallId,
|
|
@@ -3036,14 +2464,11 @@ async function applyToolPart(execution, part) {
|
|
|
3036
2464
|
outcome: "error",
|
|
3037
2465
|
output: { message: "Tool output denied" }
|
|
3038
2466
|
}));
|
|
3039
|
-
await
|
|
3040
|
-
type: "tool-status",
|
|
3041
|
-
...transientHead(execution),
|
|
2467
|
+
await checkpoint(execution, {
|
|
3042
2468
|
callId: part.toolCallId,
|
|
3043
2469
|
toolName: part.toolName,
|
|
3044
2470
|
status: "failed",
|
|
3045
|
-
output: { message: "Tool output denied" }
|
|
3046
|
-
emittedAt: now().toISOString()
|
|
2471
|
+
output: { message: "Tool output denied" }
|
|
3047
2472
|
});
|
|
3048
2473
|
}
|
|
3049
2474
|
}
|
|
@@ -3116,40 +2541,34 @@ async function applyRecordedPart(execution, part) {
|
|
|
3116
2541
|
async function applyFinishStep(execution, scope, part) {
|
|
3117
2542
|
if (part.type !== "finish-step")
|
|
3118
2543
|
return;
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
2544
|
+
await releaseStepText(execution);
|
|
2545
|
+
await recordStepSpend(execution, {
|
|
2546
|
+
phase: "step",
|
|
2547
|
+
part,
|
|
2548
|
+
attempt: scope.providerAttempt,
|
|
2549
|
+
selectedModel: scope.selectedModel,
|
|
2550
|
+
ledger: scope.ledger
|
|
3126
2551
|
});
|
|
3127
2552
|
await execution.operationLifecycle.finish(part.finishReason === "error" ? "failed" : "completed");
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
}
|
|
3133
|
-
state.
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
state: state.run.state,
|
|
3146
|
-
modelId: scope.selectedModel.descriptor.modelId,
|
|
3147
|
-
step: state.step,
|
|
3148
|
-
usage: stepUsage,
|
|
3149
|
-
response,
|
|
2553
|
+
execution.state.step += 1;
|
|
2554
|
+
}
|
|
2555
|
+
async function releaseStepText(execution) {
|
|
2556
|
+
const { state } = execution;
|
|
2557
|
+
const { text, toolFailed } = state.stepGuard;
|
|
2558
|
+
state.stepGuard = { text: "", toolFailed: false, reasoningChars: 0 };
|
|
2559
|
+
if (text.length === 0 || toolFailed)
|
|
2560
|
+
return;
|
|
2561
|
+
appendText(state.parts, text);
|
|
2562
|
+
if (state.firstOutputAt === undefined)
|
|
2563
|
+
state.firstOutputAt = performance.now();
|
|
2564
|
+
await execution.operationLifecycle.firstOutput();
|
|
2565
|
+
const { publish, now } = execution.dependencies;
|
|
2566
|
+
await publish({
|
|
2567
|
+
type: "assistant-delta",
|
|
2568
|
+
...transientHead(execution),
|
|
2569
|
+
textDelta: text,
|
|
3150
2570
|
emittedAt: now().toISOString()
|
|
3151
2571
|
});
|
|
3152
|
-
state.step += 1;
|
|
3153
2572
|
}
|
|
3154
2573
|
async function applyStreamPart(execution, scope, part) {
|
|
3155
2574
|
const { state } = execution;
|
|
@@ -3182,6 +2601,9 @@ async function applyStreamPart(execution, scope, part) {
|
|
|
3182
2601
|
state.terminalReason = failureThisRuntimeOwns(part.error) ?? "provider_failure";
|
|
3183
2602
|
state.internalCause = part.error;
|
|
3184
2603
|
break;
|
|
2604
|
+
case "start-step":
|
|
2605
|
+
state.stepGuard = { text: "", toolFailed: false, reasoningChars: 0 };
|
|
2606
|
+
break;
|
|
3185
2607
|
case "finish-step":
|
|
3186
2608
|
await applyFinishStep(execution, scope, part);
|
|
3187
2609
|
break;
|
|
@@ -3194,12 +2616,12 @@ async function applyStreamPart(execution, scope, part) {
|
|
|
3194
2616
|
}
|
|
3195
2617
|
state.sawProviderFinish = true;
|
|
3196
2618
|
state.modelUsage = mergeModelTotals(normalizeSdkUsage(part.totalUsage), state.modelUsage);
|
|
3197
|
-
state.usage =
|
|
2619
|
+
state.usage = runUsage(state);
|
|
3198
2620
|
break;
|
|
3199
2621
|
}
|
|
3200
2622
|
}
|
|
3201
2623
|
|
|
3202
|
-
// src/agent-runtime/tool-progress.ts
|
|
2624
|
+
// src/agent-runtime/run-tool-progress.ts
|
|
3203
2625
|
var TOOL_PROGRESS_MIN_INTERVAL_MS = 250;
|
|
3204
2626
|
function finite(value) {
|
|
3205
2627
|
return value !== undefined && Number.isFinite(value) ? value : undefined;
|
|
@@ -3275,10 +2697,7 @@ async function prepareAttemptStep(context, attempt, options) {
|
|
|
3275
2697
|
const { state } = execution;
|
|
3276
2698
|
const previousStep = options.steps.at(-1);
|
|
3277
2699
|
if (previousStep) {
|
|
3278
|
-
state.lastPromptTokens = state.selectedModel
|
|
3279
|
-
usage: previousStep.usage,
|
|
3280
|
-
providerMetadata: previousStep.providerMetadata
|
|
3281
|
-
})?.inputTokens ?? normalizeSdkUsage(previousStep.usage).inputTokens;
|
|
2700
|
+
state.lastPromptTokens = normalizeStepUsage(state.selectedModel, previousStep.usage, previousStep.providerMetadata).inputTokens;
|
|
3282
2701
|
}
|
|
3283
2702
|
const prepared = await config.loop?.prepareStep?.({
|
|
3284
2703
|
...options,
|
|
@@ -3324,15 +2743,11 @@ function runToolDurability(context, toolName, toolCallId, signal) {
|
|
|
3324
2743
|
signal
|
|
3325
2744
|
});
|
|
3326
2745
|
}
|
|
3327
|
-
function startAttemptStream(context, attempt, stopConditions) {
|
|
2746
|
+
function startAttemptStream(context, attempt, stopConditions, attemptSignal) {
|
|
3328
2747
|
const { execution, turn } = context;
|
|
3329
2748
|
const { config } = execution.dependencies;
|
|
3330
2749
|
const { idleDeadline, operationLifecycle } = execution;
|
|
3331
2750
|
const { tools } = turn;
|
|
3332
|
-
const attemptSignal = AbortSignal.any([
|
|
3333
|
-
execution.executionSignal,
|
|
3334
|
-
attempt.attemptAbort.signal
|
|
3335
|
-
]);
|
|
3336
2751
|
return streamAgentTextBoundary({
|
|
3337
2752
|
model: turn.selectedModel.model,
|
|
3338
2753
|
tools,
|
|
@@ -3358,8 +2773,8 @@ function startAttemptStream(context, attempt, stopConditions) {
|
|
|
3358
2773
|
onToolExecutionStart: () => idleDeadline.suspend(),
|
|
3359
2774
|
onToolExecutionEnd: () => idleDeadline.resume(),
|
|
3360
2775
|
repairToolCall: deferredToolRepair(config.loop?.prepareStep),
|
|
3361
|
-
...
|
|
3362
|
-
toolApproval:
|
|
2776
|
+
...turn.toolApproval && {
|
|
2777
|
+
toolApproval: turn.toolApproval,
|
|
3363
2778
|
runtimeContext: execution.input.context
|
|
3364
2779
|
},
|
|
3365
2780
|
...config.loop?.toolApprovalSecret && {
|
|
@@ -3371,20 +2786,13 @@ function startAttemptStream(context, attempt, stopConditions) {
|
|
|
3371
2786
|
async function drainAbandonedPart(context, attempt, part) {
|
|
3372
2787
|
if (part.type !== "finish-step")
|
|
3373
2788
|
return;
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
2789
|
+
await recordStepSpend(context.execution, {
|
|
2790
|
+
phase: "abandoned-attempt",
|
|
2791
|
+
part,
|
|
2792
|
+
attempt: attempt.providerAttempt,
|
|
2793
|
+
selectedModel: context.turn.selectedModel,
|
|
2794
|
+
ledger: context.ledger
|
|
3380
2795
|
});
|
|
3381
|
-
const failedStepUsage = context.turn.selectedModel.normalizeUsage?.({
|
|
3382
|
-
usage: part.usage,
|
|
3383
|
-
providerMetadata: part.providerMetadata
|
|
3384
|
-
}) ?? normalizeSdkUsage(part.usage);
|
|
3385
|
-
state.abandonedUsage = state.abandonedUsage ? addUsage(state.abandonedUsage, failedStepUsage) : failedStepUsage;
|
|
3386
|
-
const billed = billedUsage(state);
|
|
3387
|
-
state.usage = state.nonModelUsage && billed ? addUsage(state.nonModelUsage, billed) : billed ?? state.nonModelUsage;
|
|
3388
2796
|
}
|
|
3389
2797
|
async function retryAfterProviderError(context, attempt, error) {
|
|
3390
2798
|
const { execution, loop } = context;
|
|
@@ -3457,12 +2865,17 @@ async function consumeAttempt(context, attempt, stream) {
|
|
|
3457
2865
|
if (part.type === "error" && await retryAfterProviderError(context, attempt, part.error)) {
|
|
3458
2866
|
continue;
|
|
3459
2867
|
}
|
|
3460
|
-
|
|
2868
|
+
const held = part.type === "text-delta" && context.execution.dependencies.config.loop?.stepBarriers?.stepText === "after-tools";
|
|
2869
|
+
if (isOutputPart(part) && !held) {
|
|
3461
2870
|
if (state.firstOutputAt === undefined)
|
|
3462
2871
|
state.firstOutputAt = performance.now();
|
|
3463
2872
|
await operationLifecycle.firstOutput();
|
|
3464
2873
|
}
|
|
3465
2874
|
await applyStreamPart(execution, scope, part);
|
|
2875
|
+
if (TOOL_STATUS_PARTS.includes(part.type)) {
|
|
2876
|
+
state.eventsSinceCheckpoint = 0;
|
|
2877
|
+
continue;
|
|
2878
|
+
}
|
|
3466
2879
|
const structuralBoundary = STRUCTURAL_BOUNDARY_PARTS.includes(part.type);
|
|
3467
2880
|
if (structuralBoundary || state.eventsSinceCheckpoint >= checkpointEveryEvents) {
|
|
3468
2881
|
await checkpoint(execution);
|
|
@@ -3496,10 +2909,16 @@ async function runModelAttempts(execution, turn) {
|
|
|
3496
2909
|
draining: false,
|
|
3497
2910
|
attemptAbort: new AbortController
|
|
3498
2911
|
};
|
|
3499
|
-
const
|
|
3500
|
-
|
|
2912
|
+
const link = linkAbortSignals(execution.executionSignal, attempt.attemptAbort.signal);
|
|
2913
|
+
try {
|
|
2914
|
+
const result = startAttemptStream(context, attempt, stopConditions, link.signal);
|
|
2915
|
+
await consumeAttempt(context, attempt, result.stream);
|
|
2916
|
+
} finally {
|
|
2917
|
+
link.release();
|
|
2918
|
+
}
|
|
3501
2919
|
if (!attempt.retrying)
|
|
3502
2920
|
break;
|
|
2921
|
+
state.stepGuard = { text: "", toolFailed: false, reasoningChars: 0 };
|
|
3503
2922
|
await publish({
|
|
3504
2923
|
type: "attempt-reset",
|
|
3505
2924
|
conversationId: state.run.conversationId,
|
|
@@ -3670,10 +3089,10 @@ async function commitRunTerminal(execution) {
|
|
|
3670
3089
|
}
|
|
3671
3090
|
|
|
3672
3091
|
// src/agent-runtime/run-prompt-history.ts
|
|
3673
|
-
import { createHash as
|
|
3092
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
3674
3093
|
|
|
3675
3094
|
// src/agent-runtime/state-slots.ts
|
|
3676
|
-
import { z as
|
|
3095
|
+
import { z as z4 } from "zod";
|
|
3677
3096
|
function defineStateSlot2(input) {
|
|
3678
3097
|
if (input.name.length === 0)
|
|
3679
3098
|
throw new TypeError("State slot name must not be empty");
|
|
@@ -3688,11 +3107,11 @@ function defineStateSlot2(input) {
|
|
|
3688
3107
|
...input.description && { description: input.description }
|
|
3689
3108
|
};
|
|
3690
3109
|
}
|
|
3691
|
-
var StateSetPayloadSchema =
|
|
3692
|
-
name:
|
|
3693
|
-
version:
|
|
3694
|
-
value:
|
|
3695
|
-
actor:
|
|
3110
|
+
var StateSetPayloadSchema = z4.object({
|
|
3111
|
+
name: z4.string().min(1),
|
|
3112
|
+
version: z4.int().positive(),
|
|
3113
|
+
value: z4.json(),
|
|
3114
|
+
actor: z4.enum(["agent", "human", "system"])
|
|
3696
3115
|
}).strict();
|
|
3697
3116
|
function slotRegistry(definitions) {
|
|
3698
3117
|
const result = new Map;
|
|
@@ -3774,18 +3193,18 @@ function renderAgentStateSlots2(values) {
|
|
|
3774
3193
|
var agentGoalStateSlot2 = defineStateSlot2({
|
|
3775
3194
|
name: "goal",
|
|
3776
3195
|
description: "The durable objective and lifecycle of this conversation.",
|
|
3777
|
-
schema:
|
|
3778
|
-
objective:
|
|
3779
|
-
status:
|
|
3196
|
+
schema: z4.object({
|
|
3197
|
+
objective: z4.string().min(1),
|
|
3198
|
+
status: z4.enum(["active", "complete", "blocked"])
|
|
3780
3199
|
}).strict()
|
|
3781
3200
|
});
|
|
3782
3201
|
var agentTodoStateSlot2 = defineStateSlot2({
|
|
3783
3202
|
name: "todo",
|
|
3784
3203
|
description: "The durable ordered work plan for this conversation.",
|
|
3785
|
-
schema:
|
|
3786
|
-
items:
|
|
3787
|
-
step:
|
|
3788
|
-
status:
|
|
3204
|
+
schema: z4.object({
|
|
3205
|
+
items: z4.array(z4.object({
|
|
3206
|
+
step: z4.string().min(1),
|
|
3207
|
+
status: z4.enum(["pending", "in_progress", "completed"])
|
|
3789
3208
|
}).strict())
|
|
3790
3209
|
}).strict()
|
|
3791
3210
|
});
|
|
@@ -3809,7 +3228,7 @@ var USER_INSTRUCTION_SEED_KEY = "prompt.user-instructions";
|
|
|
3809
3228
|
function seededInstructionMessage(input) {
|
|
3810
3229
|
return AgentMessageSchema2.parse({
|
|
3811
3230
|
schemaVersion: 1,
|
|
3812
|
-
id:
|
|
3231
|
+
id: createHash2("sha256").update(`${input.conversationId}\x00${input.seedKey}\x00${input.index}`).digest("hex"),
|
|
3813
3232
|
conversationId: input.conversationId,
|
|
3814
3233
|
role: "user",
|
|
3815
3234
|
status: "committed",
|
|
@@ -3894,8 +3313,6 @@ async function compactHistory(execution) {
|
|
|
3894
3313
|
store: config.store,
|
|
3895
3314
|
signal: executionSignal
|
|
3896
3315
|
});
|
|
3897
|
-
adoptSnapshot(state, compacted.snapshot);
|
|
3898
|
-
await operationLifecycle.finish("completed");
|
|
3899
3316
|
} catch (error) {
|
|
3900
3317
|
const latest = await config.store.loadRun({
|
|
3901
3318
|
conversationId: state.run.conversationId,
|
|
@@ -3909,10 +3326,14 @@ async function compactHistory(execution) {
|
|
|
3909
3326
|
throw error;
|
|
3910
3327
|
}
|
|
3911
3328
|
if (compacted.usage) {
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3329
|
+
await recordStepSpend(execution, {
|
|
3330
|
+
phase: "compaction",
|
|
3331
|
+
usage: compacted.usage,
|
|
3332
|
+
attempt: compacted.attempts
|
|
3333
|
+
});
|
|
3915
3334
|
}
|
|
3335
|
+
adoptSnapshot(state, compacted.snapshot);
|
|
3336
|
+
await operationLifecycle.finish("completed");
|
|
3916
3337
|
}
|
|
3917
3338
|
function createRuntimeContext(execution) {
|
|
3918
3339
|
const { runtimeEpoch, config } = execution.dependencies;
|
|
@@ -3942,9 +3363,11 @@ function createRuntimeContext(execution) {
|
|
|
3942
3363
|
...state.run.fencingToken !== undefined && { fencingToken: state.run.fencingToken }
|
|
3943
3364
|
})
|
|
3944
3365
|
});
|
|
3945
|
-
return {
|
|
3366
|
+
return issueRunContext({
|
|
3946
3367
|
context: execution.input.context,
|
|
3947
|
-
run
|
|
3368
|
+
get run() {
|
|
3369
|
+
return state.run;
|
|
3370
|
+
},
|
|
3948
3371
|
signal: executionSignal,
|
|
3949
3372
|
toolFenceLifecycle,
|
|
3950
3373
|
get contextUsage() {
|
|
@@ -3952,8 +3375,11 @@ function createRuntimeContext(execution) {
|
|
|
3952
3375
|
if (!descriptor)
|
|
3953
3376
|
return;
|
|
3954
3377
|
return { usedTokens: state.lastPromptTokens, contextWindow: descriptor.contextWindow };
|
|
3378
|
+
},
|
|
3379
|
+
get selectedModel() {
|
|
3380
|
+
return state.selectedModel;
|
|
3955
3381
|
}
|
|
3956
|
-
};
|
|
3382
|
+
});
|
|
3957
3383
|
}
|
|
3958
3384
|
async function seedUserInstructions(execution, prompt) {
|
|
3959
3385
|
const { config, now } = execution.dependencies;
|
|
@@ -3982,8 +3408,9 @@ async function seedUserInstructions(execution, prompt) {
|
|
|
3982
3408
|
async function prepareTurn(execution) {
|
|
3983
3409
|
const { config } = execution.dependencies;
|
|
3984
3410
|
const { state, executionSignal } = execution;
|
|
3985
|
-
await compactHistory(execution);
|
|
3986
3411
|
const runtimeContext = createRuntimeContext(execution);
|
|
3412
|
+
execution.runtimeContext = runtimeContext;
|
|
3413
|
+
await compactHistory(execution);
|
|
3987
3414
|
const selectedModel = await config.models.resolve({
|
|
3988
3415
|
context: execution.input.context,
|
|
3989
3416
|
conversationId: state.run.conversationId,
|
|
@@ -3992,7 +3419,7 @@ async function prepareTurn(execution) {
|
|
|
3992
3419
|
});
|
|
3993
3420
|
state.selectedModel = selectedModel;
|
|
3994
3421
|
let promptSnapshot = snapshotForRunPrompt(state.snapshot, state.run.id);
|
|
3995
|
-
const [composedPrompt,
|
|
3422
|
+
const [composedPrompt, rawTools] = await Promise.all([
|
|
3996
3423
|
config.prompt({
|
|
3997
3424
|
context: execution.input.context,
|
|
3998
3425
|
signal: executionSignal,
|
|
@@ -4002,6 +3429,7 @@ async function prepareTurn(execution) {
|
|
|
4002
3429
|
}),
|
|
4003
3430
|
config.tools(runtimeContext)
|
|
4004
3431
|
]);
|
|
3432
|
+
const { tools, toolApproval } = applyStepBarriers(rawTools, config.loop?.toolApproval, config.loop?.stepBarriers);
|
|
4005
3433
|
let prompt = composedPrompt;
|
|
4006
3434
|
const userInstructionsInserted = await seedUserInstructions(execution, prompt);
|
|
4007
3435
|
if (userInstructionsInserted !== undefined) {
|
|
@@ -4021,7 +3449,7 @@ async function prepareTurn(execution) {
|
|
|
4021
3449
|
durableSystem: await loadDurableSystem(config, state.run.conversationId)
|
|
4022
3450
|
});
|
|
4023
3451
|
const history = [...await projection.projectHistory(promptSnapshot)];
|
|
4024
|
-
return { selectedModel, runtimeContext, prompt, tools, history, projection };
|
|
3452
|
+
return { selectedModel, runtimeContext, prompt, tools, toolApproval, history, projection };
|
|
4025
3453
|
}
|
|
4026
3454
|
|
|
4027
3455
|
// src/agent-runtime/run-unacquired.ts
|
|
@@ -4118,26 +3546,33 @@ function createRunExecutor(dependencies) {
|
|
|
4118
3546
|
const { execution } = acquisition;
|
|
4119
3547
|
const runId = execution.state.run.id;
|
|
4120
3548
|
executing.add(runId);
|
|
3549
|
+
let result;
|
|
4121
3550
|
try {
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
3551
|
+
try {
|
|
3552
|
+
await beginRunExecution(execution);
|
|
3553
|
+
const invocations = dependencies.config.invocations;
|
|
3554
|
+
if (invocations) {
|
|
3555
|
+
const trace = await invocations.trace({
|
|
3556
|
+
context: input.context,
|
|
3557
|
+
conversationId: execution.state.run.conversationId,
|
|
3558
|
+
run: execution.state.run
|
|
3559
|
+
});
|
|
3560
|
+
execution.invocationTrace = trace;
|
|
3561
|
+
execution.invocation = await beginAgentInvocation(invocations.ledger, dependencies.config.store, { run: execution.state.run, trace }, input.context);
|
|
3562
|
+
}
|
|
3563
|
+
const turn = await prepareTurn(execution);
|
|
3564
|
+
await runModelAttempts(execution, turn);
|
|
3565
|
+
await settleStreamOutcome(execution);
|
|
3566
|
+
} catch (error) {
|
|
3567
|
+
await classifyRunFailure(execution, error);
|
|
3568
|
+
} finally {
|
|
3569
|
+
execution.idleDeadline.dispose();
|
|
4131
3570
|
}
|
|
4132
|
-
|
|
4133
|
-
await runModelAttempts(execution, turn);
|
|
4134
|
-
await settleStreamOutcome(execution);
|
|
4135
|
-
} catch (error) {
|
|
4136
|
-
await classifyRunFailure(execution, error);
|
|
3571
|
+
result = await commitRunTerminal(execution);
|
|
4137
3572
|
} finally {
|
|
4138
|
-
|
|
3573
|
+
executing.delete(runId);
|
|
3574
|
+
execution.idleDeadline.release();
|
|
4139
3575
|
}
|
|
4140
|
-
const result = await commitRunTerminal(execution).finally(() => executing.delete(runId));
|
|
4141
3576
|
await execution.invocation?.finish(result.reason === "success" ? "succeeded" : ["interrupted", "cancelled", "timeout", "shutdown"].includes(result.reason) ? "cancelled" : "failed");
|
|
4142
3577
|
return result;
|
|
4143
3578
|
};
|
|
@@ -4149,9 +3584,14 @@ function resolveLoopLimits(config) {
|
|
|
4149
3584
|
const maxSteps = config.loop?.maxSteps ?? 50;
|
|
4150
3585
|
const declaredIdleTimeoutMs = config.loop?.idleTimeoutMs;
|
|
4151
3586
|
const idleTimeoutMs = declaredIdleTimeoutMs === null ? undefined : declaredIdleTimeoutMs ?? 60000;
|
|
3587
|
+
const stepSpendTimeoutMs = config.stepSpendTimeoutMs ?? DEFAULT_STEP_SPEND_TIMEOUT_MS;
|
|
4152
3588
|
assertPositiveSafeInteger("checkpointEveryEvents", checkpointEveryEvents);
|
|
4153
3589
|
assertPositiveSafeInteger("maxSteps", maxSteps);
|
|
4154
|
-
|
|
3590
|
+
assertTimerMs("idleTimeoutMs", idleTimeoutMs);
|
|
3591
|
+
assertTimerMs("stepSpendTimeoutMs", stepSpendTimeoutMs);
|
|
3592
|
+
if (config.loop?.retry)
|
|
3593
|
+
assertAgentRetryPolicy("loop.retry", config.loop.retry);
|
|
3594
|
+
assertStepBarriers(config.loop?.stepBarriers);
|
|
4155
3595
|
const policyNames = new Set(["max-steps"]);
|
|
4156
3596
|
for (const policy of config.loop?.stopPolicies ?? []) {
|
|
4157
3597
|
if (!policy.name || policyNames.has(policy.name)) {
|
|
@@ -4162,7 +3602,8 @@ function resolveLoopLimits(config) {
|
|
|
4162
3602
|
return {
|
|
4163
3603
|
checkpointEveryEvents,
|
|
4164
3604
|
maxSteps,
|
|
4165
|
-
...idleTimeoutMs !== undefined && { idleTimeoutMs }
|
|
3605
|
+
...idleTimeoutMs !== undefined && { idleTimeoutMs },
|
|
3606
|
+
stepSpendTimeoutMs
|
|
4166
3607
|
};
|
|
4167
3608
|
}
|
|
4168
3609
|
function createAgentRuntimeState(config) {
|
|
@@ -4173,7 +3614,7 @@ function createAgentRuntimeState(config) {
|
|
|
4173
3614
|
const admissionLanes = createRuntimeAdmissionLanes();
|
|
4174
3615
|
const injectionPossible = typeof config.runs?.inputPolicy === "function" || config.runs?.inputPolicy === "inject";
|
|
4175
3616
|
const injection = injectionPossible ? createAgentInjectionRegistry() : undefined;
|
|
4176
|
-
const { checkpointEveryEvents, maxSteps, idleTimeoutMs } = resolveLoopLimits(config);
|
|
3617
|
+
const { checkpointEveryEvents, maxSteps, idleTimeoutMs, stepSpendTimeoutMs } = resolveLoopLimits(config);
|
|
4177
3618
|
const publish = async (event) => {
|
|
4178
3619
|
try {
|
|
4179
3620
|
await config.publish?.(event);
|
|
@@ -4192,6 +3633,7 @@ function createAgentRuntimeState(config) {
|
|
|
4192
3633
|
checkpointEveryEvents,
|
|
4193
3634
|
maxSteps,
|
|
4194
3635
|
...idleTimeoutMs !== undefined && { idleTimeoutMs },
|
|
3636
|
+
stepSpendTimeoutMs,
|
|
4195
3637
|
...injection && { injection }
|
|
4196
3638
|
});
|
|
4197
3639
|
return {
|
|
@@ -4516,4 +3958,4 @@ function createAgentRuntime2(config) {
|
|
|
4516
3958
|
};
|
|
4517
3959
|
}
|
|
4518
3960
|
|
|
4519
|
-
export {
|
|
3961
|
+
export { AgentContextOverflowError2, createAgentSessionCoordinator2, registerDeferredToolRepair, registerDeferredToolCatalog, deferredToolCatalog, repairedSearchCall, projectAgentHistoryDetailed2, projectAgentHistory2, createModelInvocationLedger2, createAgentToolFenceLifecycle2, AgentTokenCountSchema2, selectAgentHistory2, composeAgentPrompt2, AgentProviderStreamCutError2, classifyProviderFailure2, isToolResultFailure2, recordAgentRetryDecision2, AgentStepBarrierError2, createToolDependencyResolver2, defineStateSlot2, createAgentStateSlotStore2, renderAgentStateSlots2, agentGoalStateSlot2, agentTodoStateSlot2, createAgentRuntime2 };
|