stitchkit 0.125.0 → 0.127.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1707 -1
- package/README.md +12 -4
- package/dist/agent-executor/acp/scenarios.d.ts +4 -0
- package/dist/agent-executor/acp/scenarios.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-connect.d.ts +89 -0
- package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-driver.d.ts +31 -0
- package/dist/agent-executor/acp/v1-driver.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-map.d.ts +41 -0
- package/dist/agent-executor/acp/v1-map.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-protocol.d.ts +270 -0
- package/dist/agent-executor/acp/v1-protocol.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-session.d.ts +22 -0
- package/dist/agent-executor/acp/v1-session.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-turn.d.ts +25 -0
- package/dist/agent-executor/acp/v1-turn.d.ts.map +1 -0
- package/dist/agent-executor/claude/classify.d.ts +54 -0
- package/dist/agent-executor/claude/classify.d.ts.map +1 -0
- package/dist/agent-executor/claude/cli-driver.d.ts +27 -0
- package/dist/agent-executor/claude/cli-driver.d.ts.map +1 -0
- package/dist/agent-executor/claude/limits.d.ts +8 -0
- package/dist/agent-executor/claude/limits.d.ts.map +1 -0
- package/dist/agent-executor/claude/protocol.d.ts +188 -0
- package/dist/agent-executor/claude/protocol.d.ts.map +1 -0
- package/dist/agent-executor/claude/scenarios.d.ts +4 -0
- package/dist/agent-executor/claude/scenarios.d.ts.map +1 -0
- package/dist/agent-executor/claude/session.d.ts +22 -0
- package/dist/agent-executor/claude/session.d.ts.map +1 -0
- package/dist/agent-executor/claude/transcript.d.ts +33 -0
- package/dist/agent-executor/claude/transcript.d.ts.map +1 -0
- package/dist/agent-executor/claude-sdk/driver.d.ts +31 -0
- package/dist/agent-executor/claude-sdk/driver.d.ts.map +1 -0
- package/dist/agent-executor/claude-sdk/session.d.ts +10 -0
- package/dist/agent-executor/claude-sdk/session.d.ts.map +1 -0
- package/dist/agent-executor/codex/classify.d.ts +28 -0
- package/dist/agent-executor/codex/classify.d.ts.map +1 -0
- package/dist/agent-executor/codex/driver.d.ts +23 -0
- package/dist/agent-executor/codex/driver.d.ts.map +1 -0
- package/dist/agent-executor/codex/limits.d.ts +4 -0
- package/dist/agent-executor/codex/limits.d.ts.map +1 -0
- package/dist/agent-executor/codex/protocol.d.ts +152 -0
- package/dist/agent-executor/codex/protocol.d.ts.map +1 -0
- package/dist/agent-executor/codex/scenarios.d.ts +4 -0
- package/dist/agent-executor/codex/scenarios.d.ts.map +1 -0
- package/dist/agent-executor/codex/session.d.ts +41 -0
- package/dist/agent-executor/codex/session.d.ts.map +1 -0
- package/dist/agent-executor/contract.d.ts +454 -0
- package/dist/agent-executor/contract.d.ts.map +1 -0
- package/dist/agent-executor/dispatch.d.ts +41 -0
- package/dist/agent-executor/dispatch.d.ts.map +1 -0
- package/dist/agent-executor/engine-process.d.ts +45 -0
- package/dist/agent-executor/engine-process.d.ts.map +1 -0
- package/dist/agent-executor/engine-requests.d.ts +63 -0
- package/dist/agent-executor/engine-requests.d.ts.map +1 -0
- package/dist/agent-executor/engine.d.ts +64 -0
- package/dist/agent-executor/engine.d.ts.map +1 -0
- package/dist/agent-executor/executor-contract.d.ts +387 -0
- package/dist/agent-executor/executor-contract.d.ts.map +1 -0
- package/dist/agent-executor/executor-machine.d.ts +50 -0
- package/dist/agent-executor/executor-machine.d.ts.map +1 -0
- package/dist/agent-executor/hello.d.ts +235 -0
- package/dist/agent-executor/hello.d.ts.map +1 -0
- package/dist/agent-executor/json-rpc-peer.d.ts +48 -0
- package/dist/agent-executor/json-rpc-peer.d.ts.map +1 -0
- package/dist/agent-executor/leases.d.ts +159 -0
- package/dist/agent-executor/leases.d.ts.map +1 -0
- package/dist/agent-executor/plan-limits.d.ts +25 -0
- package/dist/agent-executor/plan-limits.d.ts.map +1 -0
- package/dist/agent-executor/profile.d.ts +52 -0
- package/dist/agent-executor/profile.d.ts.map +1 -0
- package/dist/agent-executor/projection.d.ts +14 -0
- package/dist/agent-executor/projection.d.ts.map +1 -0
- package/dist/agent-executor/session-primitives.d.ts +72 -0
- package/dist/agent-executor/session-primitives.d.ts.map +1 -0
- package/dist/agent-executor/testing/conformance.d.ts +55 -0
- package/dist/agent-executor/testing/conformance.d.ts.map +1 -0
- package/dist/agent-executor/testing/fake-claude-engine.d.ts +18 -0
- package/dist/agent-executor/testing/fake-claude-engine.d.ts.map +1 -0
- package/dist/agent-executor/testing/fake-engine.d.ts +52 -0
- package/dist/agent-executor/testing/fake-engine.d.ts.map +1 -0
- package/dist/agent-executor/turn-phases.d.ts +10 -0
- package/dist/agent-executor/turn-phases.d.ts.map +1 -0
- package/dist/agent-executor/vocabulary.d.ts +353 -0
- package/dist/agent-executor/vocabulary.d.ts.map +1 -0
- package/dist/agent-parts/parts.d.ts +160 -0
- package/dist/agent-parts/parts.d.ts.map +1 -0
- package/dist/agent-runtime/agent-tool.d.ts +1 -1
- package/dist/agent-runtime/agent-tool.d.ts.map +1 -1
- package/dist/agent-runtime/archive-projection.d.ts +5 -0
- package/dist/agent-runtime/archive-projection.d.ts.map +1 -1
- package/dist/agent-runtime/branch-contract.d.ts +63 -1
- 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 +53 -1
- package/dist/agent-runtime/branch-identities.d.ts.map +1 -1
- package/dist/agent-runtime/branch-messages.d.ts +15 -26
- package/dist/agent-runtime/branch-messages.d.ts.map +1 -1
- package/dist/agent-runtime/branch-observations.d.ts +138 -28
- package/dist/agent-runtime/branch-observations.d.ts.map +1 -1
- package/dist/agent-runtime/branch-provider.d.ts +32 -51
- package/dist/agent-runtime/branch-provider.d.ts.map +1 -1
- package/dist/agent-runtime/branch-refusal.d.ts +60 -0
- package/dist/agent-runtime/branch-refusal.d.ts.map +1 -0
- package/dist/agent-runtime/branch-runtime-tools.d.ts +14 -0
- package/dist/agent-runtime/branch-runtime-tools.d.ts.map +1 -0
- package/dist/agent-runtime/branch-source.d.ts +7 -2
- package/dist/agent-runtime/branch-source.d.ts.map +1 -1
- package/dist/agent-runtime/branch-transitions.d.ts.map +1 -1
- package/dist/agent-runtime/browser-control-contract.d.ts +2 -2
- package/dist/agent-runtime/browser-controller.d.ts.map +1 -1
- package/dist/agent-runtime/child-blocking.d.ts +17 -6
- package/dist/agent-runtime/child-blocking.d.ts.map +1 -1
- package/dist/agent-runtime/child-budget-policy.d.ts +4 -9
- package/dist/agent-runtime/child-budget-policy.d.ts.map +1 -1
- package/dist/agent-runtime/child-tools.d.ts +19 -8
- package/dist/agent-runtime/child-tools.d.ts.map +1 -1
- package/dist/agent-runtime/children-contract.d.ts +84 -3
- package/dist/agent-runtime/children-contract.d.ts.map +1 -1
- package/dist/agent-runtime/children-control.d.ts +23 -2
- package/dist/agent-runtime/children-control.d.ts.map +1 -1
- package/dist/agent-runtime/children-spawn.d.ts +9 -0
- package/dist/agent-runtime/children-spawn.d.ts.map +1 -1
- package/dist/agent-runtime/children-state.d.ts +121 -19
- package/dist/agent-runtime/children-state.d.ts.map +1 -1
- package/dist/agent-runtime/children-usage.d.ts +10 -1
- package/dist/agent-runtime/children-usage.d.ts.map +1 -1
- package/dist/agent-runtime/children.d.ts +3 -3
- package/dist/agent-runtime/children.d.ts.map +1 -1
- package/dist/agent-runtime/{sandbox-coding.d.ts → coding-sandbox.d.ts} +2 -9
- package/dist/agent-runtime/coding-sandbox.d.ts.map +1 -0
- package/dist/agent-runtime/coding-shell-process.d.ts +2 -0
- package/dist/agent-runtime/coding-shell-process.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts +32 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-shell.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tools.d.ts.map +1 -1
- package/dist/agent-runtime/compaction.d.ts.map +1 -1
- package/dist/agent-runtime/companion-host.d.ts +38 -0
- package/dist/agent-runtime/companion-host.d.ts.map +1 -0
- package/dist/agent-runtime/context-issue.d.ts +5 -0
- package/dist/agent-runtime/context-issue.d.ts.map +1 -0
- package/dist/agent-runtime/control-schema.d.ts +2 -2
- package/dist/agent-runtime/control-schema.d.ts.map +1 -1
- package/dist/agent-runtime/conversations.d.ts.map +1 -1
- package/dist/agent-runtime/coordinator.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tool-types.d.ts +17 -5
- package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tools-internal.d.ts +2 -0
- package/dist/agent-runtime/deferred-tools-internal.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tools.d.ts.map +1 -1
- package/dist/agent-runtime/event-durability.d.ts +8 -0
- package/dist/agent-runtime/event-durability.d.ts.map +1 -0
- package/dist/agent-runtime/event-schema.d.ts +13 -5
- package/dist/agent-runtime/event-schema.d.ts.map +1 -1
- package/dist/agent-runtime/event-search-postgres.d.ts +38 -0
- package/dist/agent-runtime/event-search-postgres.d.ts.map +1 -0
- package/dist/agent-runtime/event-search-terms.d.ts +37 -0
- package/dist/agent-runtime/event-search-terms.d.ts.map +1 -0
- package/dist/agent-runtime/event-search-tools.d.ts +64 -4
- package/dist/agent-runtime/event-search-tools.d.ts.map +1 -1
- package/dist/agent-runtime/event-search.d.ts +16 -3
- package/dist/agent-runtime/event-search.d.ts.map +1 -1
- package/dist/agent-runtime/fault-bench.d.ts.map +1 -1
- package/dist/agent-runtime/harness-control.d.ts +8 -0
- package/dist/agent-runtime/harness-control.d.ts.map +1 -1
- package/dist/agent-runtime/harness-realtime.d.ts +0 -2
- package/dist/agent-runtime/harness-realtime.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-read.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-schema.d.ts +23 -0
- package/dist/agent-runtime/invocation-schema.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-spend.d.ts +9 -0
- package/dist/agent-runtime/invocation-spend.d.ts.map +1 -0
- package/dist/agent-runtime/invocations.d.ts.map +1 -1
- package/dist/agent-runtime/managed-tools.d.ts +2 -2
- package/dist/agent-runtime/managed-tools.d.ts.map +1 -1
- package/dist/agent-runtime/observability.d.ts +42 -4
- package/dist/agent-runtime/observability.d.ts.map +1 -1
- package/dist/agent-runtime/openrouter-admission.d.ts +81 -0
- package/dist/agent-runtime/openrouter-admission.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-catalog.d.ts +83 -0
- package/dist/agent-runtime/openrouter-catalog.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-models.d.ts +66 -0
- package/dist/agent-runtime/openrouter-models.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-options.d.ts +106 -0
- package/dist/agent-runtime/openrouter-options.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-route.d.ts +50 -0
- package/dist/agent-runtime/openrouter-route.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-spend.d.ts +24 -0
- package/dist/agent-runtime/openrouter-spend.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter.d.ts +23 -2
- package/dist/agent-runtime/openrouter.d.ts.map +1 -1
- package/dist/agent-runtime/owned-provider-stream.d.ts.map +1 -1
- package/dist/agent-runtime/postgres-schema.d.ts +34 -0
- package/dist/agent-runtime/postgres-schema.d.ts.map +1 -0
- package/dist/agent-runtime/postgres-transactions.d.ts +54 -0
- package/dist/agent-runtime/postgres-transactions.d.ts.map +1 -0
- package/dist/agent-runtime/postgres.d.ts +72 -0
- package/dist/agent-runtime/postgres.d.ts.map +1 -0
- package/dist/agent-runtime/projections.d.ts +57 -17
- package/dist/agent-runtime/projections.d.ts.map +1 -1
- package/dist/agent-runtime/provider-journal.d.ts +57 -0
- package/dist/agent-runtime/provider-journal.d.ts.map +1 -1
- package/dist/agent-runtime/purge.d.ts.map +1 -1
- package/dist/agent-runtime/retry-policy.d.ts +6 -0
- package/dist/agent-runtime/retry-policy.d.ts.map +1 -1
- package/dist/agent-runtime/run-acquisition.d.ts.map +1 -1
- package/dist/agent-runtime/run-execution-state.d.ts +26 -2
- package/dist/agent-runtime/run-execution-state.d.ts.map +1 -1
- package/dist/agent-runtime/run-execution.d.ts.map +1 -1
- package/dist/agent-runtime/run-failure.d.ts.map +1 -1
- package/dist/agent-runtime/run-model-attempts.d.ts.map +1 -1
- package/dist/agent-runtime/run-provider-ledger.d.ts +2 -0
- package/dist/agent-runtime/run-provider-ledger.d.ts.map +1 -1
- package/dist/agent-runtime/run-step-barriers.d.ts +72 -0
- package/dist/agent-runtime/run-step-barriers.d.ts.map +1 -0
- package/dist/agent-runtime/run-step-spend.d.ts +319 -0
- package/dist/agent-runtime/run-step-spend.d.ts.map +1 -0
- package/dist/agent-runtime/run-stream-parts.d.ts +2 -0
- package/dist/agent-runtime/run-stream-parts.d.ts.map +1 -1
- package/dist/agent-runtime/{tool-progress.d.ts → run-tool-progress.d.ts} +1 -1
- package/dist/agent-runtime/run-tool-progress.d.ts.map +1 -0
- package/dist/agent-runtime/run-turn-preparation.d.ts +3 -1
- package/dist/agent-runtime/run-turn-preparation.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-admission-gate.d.ts +0 -14
- package/dist/agent-runtime/runtime-admission-gate.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-internals.d.ts +6 -0
- package/dist/agent-runtime/runtime-internals.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-state.d.ts.map +1 -1
- package/dist/agent-runtime/runtime.d.ts +31 -2
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox-binding.d.ts +10 -0
- package/dist/agent-runtime/sandbox-binding.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-bubblewrap-storage.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox-contract.d.ts +1 -1
- package/dist/agent-runtime/sandbox-contract.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox.d.ts +5 -0
- package/dist/agent-runtime/sandbox.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-contract.d.ts +3 -2
- package/dist/agent-runtime/schedule-contract.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-dispatch.d.ts +3 -2
- package/dist/agent-runtime/schedule-dispatch.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-records.d.ts +6 -6
- package/dist/agent-runtime/schedule-records.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-tools.d.ts +19 -8
- package/dist/agent-runtime/schedule-tools.d.ts.map +1 -1
- package/dist/agent-runtime/schedules.d.ts +13 -3
- package/dist/agent-runtime/schedules.d.ts.map +1 -1
- package/dist/agent-runtime/schemas-message.d.ts +118 -0
- package/dist/agent-runtime/schemas-message.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-provider.d.ts +8 -0
- package/dist/agent-runtime/schemas-provider.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-records.d.ts +5 -0
- package/dist/agent-runtime/schemas-records.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-run.d.ts +487 -0
- package/dist/agent-runtime/schemas-run.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-usage.d.ts +129 -0
- package/dist/agent-runtime/schemas-usage.d.ts.map +1 -0
- package/dist/agent-runtime/schemas.d.ts +11 -886
- package/dist/agent-runtime/schemas.d.ts.map +1 -1
- package/dist/agent-runtime/spill.d.ts +9 -7
- package/dist/agent-runtime/spill.d.ts.map +1 -1
- package/dist/agent-runtime/sql-events.d.ts +6 -0
- package/dist/agent-runtime/sql-events.d.ts.map +1 -0
- package/dist/agent-runtime/sql-history.d.ts +8 -0
- package/dist/agent-runtime/sql-history.d.ts.map +1 -0
- package/dist/agent-runtime/sql-ledger.d.ts +5 -0
- package/dist/agent-runtime/sql-ledger.d.ts.map +1 -0
- package/dist/agent-runtime/sql-purge.d.ts +13 -0
- package/dist/agent-runtime/sql-purge.d.ts.map +1 -0
- package/dist/agent-runtime/sql-reads.d.ts +16 -0
- package/dist/agent-runtime/sql-reads.d.ts.map +1 -0
- package/dist/agent-runtime/{sqlite-rows.d.ts → sql-rows.d.ts} +24 -10
- package/dist/agent-runtime/sql-rows.d.ts.map +1 -0
- package/dist/agent-runtime/sql-session.d.ts +71 -0
- package/dist/agent-runtime/sql-session.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-bun.d.ts +1 -1
- package/dist/agent-runtime/sqlite-bun.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-node.d.ts +1 -1
- package/dist/agent-runtime/sqlite-node.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-purge.d.ts +2 -3
- package/dist/agent-runtime/sqlite-purge.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-schema.d.ts +1 -1
- package/dist/agent-runtime/sqlite-schema.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-transactions.d.ts +10 -6
- package/dist/agent-runtime/sqlite-transactions.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite.d.ts +10 -29
- package/dist/agent-runtime/sqlite.d.ts.map +1 -1
- package/dist/agent-runtime/state-tools.d.ts +8 -4
- package/dist/agent-runtime/state-tools.d.ts.map +1 -1
- package/dist/agent-runtime/store-archive.d.ts.map +1 -1
- package/dist/agent-runtime/store-branch.d.ts +6 -1
- package/dist/agent-runtime/store-branch.d.ts.map +1 -1
- package/dist/agent-runtime/store-capabilities.d.ts +42 -0
- package/dist/agent-runtime/store-capabilities.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-branch.d.ts +5 -2
- package/dist/agent-runtime/store-conformance-branch.d.ts.map +1 -1
- package/dist/agent-runtime/store-conformance-capabilities.d.ts +6 -0
- package/dist/agent-runtime/store-conformance-capabilities.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-event-once.d.ts +12 -0
- package/dist/agent-runtime/store-conformance-event-once.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +20 -20
- package/dist/agent-runtime/store-conformance-seed.d.ts +8 -0
- package/dist/agent-runtime/store-conformance-seed.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance.d.ts +31 -8
- package/dist/agent-runtime/store-conformance.d.ts.map +1 -1
- package/dist/agent-runtime/store-create.d.ts +1 -1
- package/dist/agent-runtime/store-create.d.ts.map +1 -1
- package/dist/agent-runtime/store-driver-contract.d.ts +15 -8
- package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
- package/dist/agent-runtime/store-event-once.d.ts.map +1 -1
- package/dist/agent-runtime/store-events.d.ts +114 -0
- package/dist/agent-runtime/store-events.d.ts.map +1 -1
- package/dist/agent-runtime/store-memory-archive.d.ts +2 -0
- package/dist/agent-runtime/store-memory-archive.d.ts.map +1 -1
- package/dist/agent-runtime/store-memory.d.ts +2 -2
- package/dist/agent-runtime/store-memory.d.ts.map +1 -1
- package/dist/agent-runtime/store-mutate.d.ts.map +1 -1
- package/dist/agent-runtime/store-reduce-shared.d.ts +2 -1
- package/dist/agent-runtime/store-reduce-shared.d.ts.map +1 -1
- package/dist/agent-runtime/store-reducer.d.ts.map +1 -1
- package/dist/agent-runtime/store-replay.d.ts.map +1 -1
- package/dist/agent-runtime/store.d.ts +15 -2
- package/dist/agent-runtime/store.d.ts.map +1 -1
- package/dist/agent-runtime/terminal-commit.d.ts +10 -10
- package/dist/application/admission-run.d.ts.map +1 -1
- package/dist/application/admission.d.ts.map +1 -1
- package/dist/application/change-subscription.d.ts.map +1 -1
- package/dist/application/decisions.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-lock-format.d.ts +9 -0
- package/dist/application/diagnostic-journal-lock-format.d.ts.map +1 -0
- package/dist/application/diagnostic-journal-manager.d.ts.map +1 -1
- package/dist/application/directory-inbox-delivery.d.ts.map +1 -1
- package/dist/application/grammy-update-admission.d.ts.map +1 -1
- package/dist/application/health.d.ts.map +1 -1
- package/dist/application/kernel-admission.d.ts.map +1 -1
- package/dist/application/kernel-contract.d.ts.map +1 -1
- package/dist/application/kernel-restart.d.ts.map +1 -1
- package/dist/application/kernel-rollback.d.ts.map +1 -1
- package/dist/application/kernel-shutdown.d.ts.map +1 -1
- package/dist/application/kernel-state.d.ts.map +1 -1
- package/dist/application/notification-outbox-state.d.ts.map +1 -1
- package/dist/application/notification-outbox.d.ts +1 -1
- package/dist/application/notification-outbox.d.ts.map +1 -1
- package/dist/application/revision-signal.d.ts.map +1 -1
- package/dist/application/schedule-run.d.ts.map +1 -1
- package/dist/application/schedule.d.ts.map +1 -1
- package/dist/application/sqlite-migrations.d.ts +104 -0
- package/dist/application/sqlite-migrations.d.ts.map +1 -0
- package/dist/application/watch-hub-core.d.ts +2 -1
- package/dist/application/watch-hub-core.d.ts.map +1 -1
- package/dist/application/watch-hub-source.d.ts +2 -0
- package/dist/application/watch-hub-source.d.ts.map +1 -1
- package/dist/application/watch-hub.d.ts +20 -1
- package/dist/application/watch-hub.d.ts.map +1 -1
- package/dist/browser/bridge-errors.d.ts +24 -0
- package/dist/browser/bridge-errors.d.ts.map +1 -0
- package/dist/browser/bridge-fetch.d.ts +30 -0
- package/dist/browser/bridge-fetch.d.ts.map +1 -0
- package/dist/browser/bridge-inbound.d.ts +28 -0
- package/dist/browser/bridge-inbound.d.ts.map +1 -0
- package/dist/browser/cancellation.d.ts +10 -2
- package/dist/browser/cancellation.d.ts.map +1 -1
- package/dist/browser/chunked-upload.d.ts +1 -1
- package/dist/browser/chunked-upload.d.ts.map +1 -1
- package/dist/browser/client-call-arguments.d.ts +31 -0
- package/dist/browser/client-call-arguments.d.ts.map +1 -0
- package/dist/browser/client-executors.d.ts +6 -0
- package/dist/browser/client-executors.d.ts.map +1 -1
- package/dist/browser/client.d.ts +9 -0
- package/dist/browser/client.d.ts.map +1 -1
- package/dist/browser/http.d.ts +17 -2
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/browser/realtime-client.d.ts +0 -5
- package/dist/browser/realtime-client.d.ts.map +1 -1
- package/dist/browser/session-credentials-storage.d.ts +48 -0
- package/dist/browser/session-credentials-storage.d.ts.map +1 -0
- package/dist/browser/session-credentials.d.ts +26 -5
- package/dist/browser/session-credentials.d.ts.map +1 -1
- package/dist/browser/session-refresh-policy.d.ts +124 -0
- package/dist/browser/session-refresh-policy.d.ts.map +1 -0
- package/dist/browser/session-refresh-timer.d.ts +30 -0
- package/dist/browser/session-refresh-timer.d.ts.map +1 -0
- package/dist/browser/session.d.ts.map +1 -1
- package/dist/browser/socket-io-connection.d.ts.map +1 -1
- package/dist/browser/socket-io-explicit-peer.d.ts +0 -1
- package/dist/browser/socket-io-explicit-peer.d.ts.map +1 -1
- package/dist/browser/stream.d.ts +1 -1
- package/dist/browser/stream.d.ts.map +1 -1
- package/dist/browser/upload-progress.d.ts +3 -0
- package/dist/browser/upload-progress.d.ts.map +1 -1
- package/dist/contract/bridge-envelope.d.ts +155 -0
- package/dist/contract/bridge-envelope.d.ts.map +1 -0
- package/dist/contract/define-validation.d.ts +2 -0
- package/dist/contract/define-validation.d.ts.map +1 -1
- package/dist/contract/define.d.ts +3 -0
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/errors.d.ts +4 -4
- package/dist/contract/errors.d.ts.map +1 -1
- package/dist/contract/normalize.d.ts +3 -1
- package/dist/contract/normalize.d.ts.map +1 -1
- package/dist/contract/operation-effect.d.ts +29 -0
- package/dist/contract/operation-effect.d.ts.map +1 -0
- package/dist/contract/runtime-context.d.ts +2 -0
- package/dist/contract/runtime-context.d.ts.map +1 -1
- package/dist/contract/tool-options.d.ts +7 -0
- package/dist/contract/tool-options.d.ts.map +1 -1
- package/dist/declaration/command.d.ts +26 -0
- package/dist/declaration/command.d.ts.map +1 -0
- package/dist/declaration/declaration.d.ts +4 -22
- package/dist/declaration/declaration.d.ts.map +1 -1
- package/dist/declaration/machine-names.d.ts +11 -0
- package/dist/declaration/machine-names.d.ts.map +1 -0
- package/dist/durability/effect.d.ts.map +1 -1
- package/dist/durability/engine.d.ts.map +1 -1
- package/dist/durability/events.d.ts +5 -8
- package/dist/durability/events.d.ts.map +1 -1
- package/dist/durability/parks.d.ts +0 -5
- package/dist/durability/parks.d.ts.map +1 -1
- package/dist/durability/scheduler.d.ts +5 -0
- package/dist/durability/scheduler.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.d.ts +4 -0
- package/dist/entrypoints/agent-executor/acp.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/acp.js +910 -0
- package/dist/entrypoints/agent-executor/claude-sdk.d.ts +2 -0
- package/dist/entrypoints/agent-executor/claude-sdk.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/claude-sdk.js +309 -0
- package/dist/entrypoints/agent-executor/claude.d.ts +5 -0
- package/dist/entrypoints/agent-executor/claude.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/claude.js +403 -0
- package/dist/entrypoints/agent-executor/codex.d.ts +4 -0
- package/dist/entrypoints/agent-executor/codex.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/codex.js +798 -0
- package/dist/entrypoints/agent-executor/testing.d.ts +4 -0
- package/dist/entrypoints/agent-executor/testing.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/testing.js +375 -0
- package/dist/entrypoints/agent-executor.d.ts +15 -0
- package/dist/entrypoints/agent-executor.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor.js +455 -0
- package/dist/entrypoints/agent-runtime/browser.d.ts +1 -0
- package/dist/entrypoints/agent-runtime/browser.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/browser.js +60 -30
- package/dist/entrypoints/agent-runtime/coding-tools.js +9 -12
- package/dist/entrypoints/agent-runtime/harness.js +35 -22
- package/dist/entrypoints/agent-runtime/openrouter.d.ts +6 -0
- package/dist/entrypoints/agent-runtime/openrouter.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/openrouter.js +675 -45
- package/dist/entrypoints/agent-runtime/postgres.d.ts +4 -0
- package/dist/entrypoints/agent-runtime/postgres.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/postgres.js +330 -0
- package/dist/entrypoints/agent-runtime/realtime.js +46 -49
- package/dist/entrypoints/agent-runtime/sandbox.d.ts +3 -1
- package/dist/entrypoints/agent-runtime/sandbox.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/sandbox.js +74 -67
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +18 -18
- package/dist/entrypoints/agent-runtime/sqlite/node.js +18 -18
- package/dist/entrypoints/agent-runtime/testing.d.ts +1 -1
- package/dist/entrypoints/agent-runtime/testing.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/testing.js +419 -96
- package/dist/entrypoints/agent-runtime.d.ts +21 -13
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime.js +1280 -1086
- package/dist/entrypoints/application/diagnostic-journal.js +16 -11
- package/dist/entrypoints/application/directory-inbox.js +20 -14
- package/dist/entrypoints/application/grammy.js +11 -8
- package/dist/entrypoints/application/opentelemetry.js +3 -3
- package/dist/entrypoints/application.d.ts +5 -3
- package/dist/entrypoints/application.d.ts.map +1 -1
- package/dist/entrypoints/application.js +464 -116
- 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 +13 -7
- package/dist/entrypoints/cli/publish.js +10 -9
- package/dist/entrypoints/cli.d.ts +10 -3
- package/dist/entrypoints/cli.d.ts.map +1 -1
- package/dist/entrypoints/cli.js +91 -29
- package/dist/entrypoints/contract.d.ts +2 -1
- package/dist/entrypoints/contract.d.ts.map +1 -1
- package/dist/entrypoints/contract.js +13 -7
- package/dist/entrypoints/declaration.d.ts +2 -0
- package/dist/entrypoints/declaration.d.ts.map +1 -1
- package/dist/entrypoints/declaration.js +55 -44
- package/dist/entrypoints/files/packaging.js +8 -5
- package/dist/entrypoints/files.d.ts +5 -0
- package/dist/entrypoints/files.d.ts.map +1 -1
- package/dist/entrypoints/files.js +236 -47
- package/dist/entrypoints/geo.js +9 -4
- package/dist/entrypoints/google.js +14 -13
- package/dist/entrypoints/handler.d.ts +12 -0
- package/dist/entrypoints/handler.d.ts.map +1 -0
- package/dist/entrypoints/handler.js +350 -0
- package/dist/entrypoints/http.d.ts +4 -0
- package/dist/entrypoints/http.d.ts.map +1 -1
- package/dist/entrypoints/http.js +411 -5
- package/dist/entrypoints/index.d.ts +2 -0
- package/dist/entrypoints/index.d.ts.map +1 -1
- package/dist/entrypoints/index.js +664 -91
- package/dist/entrypoints/live.js +22 -12
- package/dist/entrypoints/node.d.ts +2 -1
- package/dist/entrypoints/node.d.ts.map +1 -1
- package/dist/entrypoints/node.js +34 -24
- 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 +4 -2
- package/dist/entrypoints/server.d.ts.map +1 -1
- package/dist/entrypoints/server.js +300 -199
- package/dist/entrypoints/service-host/macos.d.ts +16 -0
- package/dist/entrypoints/service-host/macos.d.ts.map +1 -0
- package/dist/entrypoints/service-host/macos.js +1998 -0
- package/dist/entrypoints/service-host.d.ts +23 -0
- package/dist/entrypoints/service-host.d.ts.map +1 -0
- package/dist/entrypoints/service-host.js +2544 -0
- package/dist/entrypoints/spend/testing.d.ts +2 -0
- package/dist/entrypoints/spend/testing.d.ts.map +1 -0
- package/dist/entrypoints/spend/testing.js +442 -0
- package/dist/entrypoints/spend.d.ts +8 -0
- package/dist/entrypoints/spend.d.ts.map +1 -0
- package/dist/entrypoints/spend.js +593 -0
- package/dist/entrypoints/sync/postgres.d.ts +12 -0
- package/dist/entrypoints/sync/postgres.d.ts.map +1 -0
- package/dist/entrypoints/sync/postgres.js +737 -0
- package/dist/entrypoints/sync.d.ts +12 -0
- package/dist/entrypoints/sync.d.ts.map +1 -0
- package/dist/entrypoints/sync.js +782 -0
- package/dist/entrypoints/telegram/grammy.js +5 -5
- package/dist/entrypoints/telegram/html.d.ts +2 -0
- package/dist/entrypoints/telegram/html.d.ts.map +1 -1
- package/dist/entrypoints/telegram/html.js +839 -2
- package/dist/entrypoints/telegram/screens.js +13 -15
- package/dist/entrypoints/telegram.d.ts +1 -1
- package/dist/entrypoints/telegram.d.ts.map +1 -1
- package/dist/entrypoints/telegram.js +286 -76
- package/dist/entrypoints/testing.js +33 -41
- package/dist/entrypoints/tools/agent.js +12 -9
- package/dist/entrypoints/tools/connections.js +664 -63
- package/dist/entrypoints/tools/contract.d.ts +2 -2
- package/dist/entrypoints/tools/contract.js +4 -1
- package/dist/entrypoints/tools/invoker.js +9 -7
- package/dist/entrypoints/tools/mcp.js +16 -11
- package/dist/entrypoints/tools/toolkit.js +21 -16
- package/dist/entrypoints/tools.d.ts +3 -1
- package/dist/entrypoints/tools.d.ts.map +1 -1
- package/dist/entrypoints/tools.js +107 -94
- package/dist/entrypoints/tracking/contract.js +2 -1
- package/dist/entrypoints/tracking/performance.js +4 -0
- package/dist/entrypoints/tracking.js +6 -1
- package/dist/entrypoints/voice.js +3 -3
- package/dist/entrypoints/xlsx.js +1 -1
- package/dist/files/boundary.d.ts.map +1 -1
- package/dist/files/chunk-spool.d.ts +27 -0
- package/dist/files/chunk-spool.d.ts.map +1 -1
- package/dist/files/directory-appearance.d.ts +44 -0
- package/dist/files/directory-appearance.d.ts.map +1 -0
- package/dist/files/file-io.d.ts.map +1 -1
- package/dist/files/file-stamp.d.ts +35 -0
- package/dist/files/file-stamp.d.ts.map +1 -0
- package/dist/files/json-file-reading.d.ts +37 -0
- package/dist/files/json-file-reading.d.ts.map +1 -0
- package/dist/files/native-packaging.d.ts.map +1 -1
- package/dist/files/polled-json.d.ts +121 -0
- package/dist/files/polled-json.d.ts.map +1 -0
- package/dist/files/regular-file.d.ts +125 -0
- package/dist/files/regular-file.d.ts.map +1 -0
- package/dist/geo/index.d.ts +2 -1
- package/dist/geo/index.d.ts.map +1 -1
- package/dist/geo/resolver.d.ts.map +1 -1
- package/dist/geo/types.d.ts +0 -1
- package/dist/geo/types.d.ts.map +1 -1
- package/dist/google/google.d.ts +6 -0
- package/dist/google/google.d.ts.map +1 -1
- package/dist/{index-w0eqdhyd.js → index-09f7w2qq.js} +6 -1
- package/dist/index-0djnptn8.js +501 -0
- package/dist/index-0hdm5sx6.js +1457 -0
- package/dist/{index-t05a2ry4.js → index-0p0s5hrj.js} +8 -14
- package/dist/{index-1c945ten.js → index-0r15pkjq.js} +1 -1
- package/dist/{index-v1swr26p.js → index-0tyt97nk.js} +2 -2
- package/dist/{index-332d0m9g.js → index-0x4mnwg5.js} +4 -0
- package/dist/index-118aebbg.js +48 -0
- package/dist/index-1q0n6zek.js +184 -0
- package/dist/index-27hck3z2.js +307 -0
- package/dist/index-2rf33y2h.js +77 -0
- package/dist/index-360j58vb.js +63 -0
- package/dist/{index-tt30h7mr.js → index-39n02e0q.js} +1 -1
- package/dist/index-3agqmmrg.js +42 -0
- package/dist/{index-n6hvd1r2.js → index-3b31z0pc.js} +22 -15
- package/dist/index-3djgv3ch.js +472 -0
- package/dist/{index-mfntvj58.js → index-3dq8466w.js} +1 -1
- package/dist/index-3gwp8ez6.js +200 -0
- package/dist/{index-x2d51zay.js → index-3ypvpkwr.js} +309 -345
- package/dist/index-4gk6k3zc.js +248 -0
- package/dist/index-4qvyhn23.js +40 -0
- package/dist/index-4s2w4g37.js +647 -0
- package/dist/index-4ynw5ktx.js +78 -0
- package/dist/index-5awtbyns.js +19 -0
- package/dist/{index-kxff9e9w.js → index-5e0zsbf7.js} +5 -4
- package/dist/{index-nz06qw5a.js → index-5jyjb4s0.js} +1 -1
- package/dist/{index-7q05ag0z.js → index-5ptwb6ka.js} +1 -1
- package/dist/{index-w3nv6kr8.js → index-5q0qpw3v.js} +54 -9
- package/dist/{index-mm89hd8v.js → index-5t4fpdct.js} +1 -1
- package/dist/{index-0v9xb8pz.js → index-5y7j383h.js} +5 -5
- package/dist/index-5zwac8ft.js +221 -0
- package/dist/{index-v62cpkx3.js → index-6g85s734.js} +1 -1
- package/dist/{index-sqc6ezrb.js → index-6kec3b14.js} +17 -4
- package/dist/{index-kqnd6a85.js → index-7416mhyh.js} +1 -1
- package/dist/{index-m0wsfmrc.js → index-7csn6pva.js} +37 -24
- package/dist/{index-dqpesdck.js → index-7grgs8cx.js} +25 -5
- package/dist/{index-gdqawggb.js → index-7kfcb576.js} +143 -39
- package/dist/{index-cvjddnvd.js → index-7xp05h20.js} +19 -10
- package/dist/{index-fgzbc06j.js → index-83n766x4.js} +91 -50
- package/dist/{index-ss67fxhj.js → index-877e9y8r.js} +7 -7
- package/dist/{index-aw6kx2e6.js → index-8gmmdz7k.js} +1 -1
- package/dist/{index-wt6rw7rf.js → index-8xr2eq99.js} +29 -21
- package/dist/{index-rz3z13e9.js → index-97q9kykw.js} +1 -1
- package/dist/index-97rp94ff.js +8 -0
- package/dist/{index-0w0hxp7n.js → index-9pv126eh.js} +3 -9
- package/dist/{index-x2rvpbtj.js → index-9wh98cpa.js} +110 -16
- package/dist/{index-egg0yp2j.js → index-9xr44d2g.js} +86 -210
- package/dist/{index-b2sey031.js → index-9y0afd5f.js} +24 -23
- package/dist/index-a725ayvz.js +405 -0
- package/dist/{index-nmaqxdx7.js → index-ac5rj3d4.js} +203 -90
- package/dist/{index-wqzw3qg9.js → index-agy5fqgf.js} +32 -13
- package/dist/index-ajmtxsky.js +193 -0
- package/dist/{index-ndjzbt2v.js → index-akf0xkrm.js} +4 -3
- package/dist/index-akfgymyr.js +8 -0
- package/dist/index-apv5xfef.js +13 -0
- package/dist/index-ax3wns1a.js +93 -0
- package/dist/{index-0sg3wnzr.js → index-bbzvrq66.js} +1670 -340
- package/dist/index-bh4pmtr9.js +317 -0
- package/dist/{index-fa53vygr.js → index-bmaz3jzy.js} +3 -3
- package/dist/{index-8kzct1d6.js → index-bn2baakz.js} +143 -143
- package/dist/{index-m8ddk770.js → index-brhhaygm.js} +1 -1
- package/dist/index-caywx1c0.js +199 -0
- package/dist/index-cbhxhma2.js +90 -0
- package/dist/index-cfnmvcq8.js +11 -0
- package/dist/index-cv9b7fz2.js +42 -0
- package/dist/index-d4svrknj.js +156 -0
- package/dist/{index-a3z56mtn.js → index-d96c1n1q.js} +5 -3
- package/dist/{index-3ymcmpa9.js → index-dvd1qdwa.js} +33 -163
- package/dist/{index-v7rbjatr.js → index-dwa6pskj.js} +1837 -1151
- package/dist/{index-ne4j9998.js → index-e06z0tkb.js} +123 -94
- package/dist/{index-99nnsz39.js → index-en8e5zsj.js} +15 -135
- package/dist/index-fcw255hd.js +929 -0
- package/dist/{index-20hn8pbh.js → index-fmzg39a8.js} +1 -1
- package/dist/{index-fvd6pvw3.js → index-g1q7fwn9.js} +2 -2
- package/dist/index-g56ht6qf.js +98 -0
- package/dist/{index-f56ct5gb.js → index-gj1rjf78.js} +4 -3
- package/dist/{index-g6a3na27.js → index-gnjgkecx.js} +7 -3
- package/dist/index-hy4653g4.js +345 -0
- package/dist/index-j13gzgdv.js +403 -0
- package/dist/{index-r8swbw1x.js → index-j516jaaz.js} +37 -11
- package/dist/{index-t8jz0e20.js → index-j903yhp4.js} +30 -38
- package/dist/{index-9ypczvpj.js → index-jb4m241t.js} +2 -0
- package/dist/index-jrka9029.js +177 -0
- package/dist/{index-cjzaj7ev.js → index-jxtg307y.js} +23 -21
- package/dist/index-kmbpej2y.js +1152 -0
- package/dist/{index-bz9cmnqq.js → index-kt6dh1n6.js} +4 -4
- package/dist/index-ky3ardqn.js +80 -0
- package/dist/index-kyejf658.js +14 -0
- package/dist/{index-zyc64nbh.js → index-kynwa08q.js} +52 -47
- package/dist/index-kzavdze2.js +15 -0
- package/dist/{index-pq7rkwkk.js → index-mbd92r1w.js} +67 -12
- package/dist/index-mxt0wfjy.js +58 -0
- package/dist/{index-9cxxfkhb.js → index-n20tybgk.js} +14 -9
- package/dist/index-nbv44x0x.js +250 -0
- package/dist/index-ngwf1s3c.js +51 -0
- package/dist/{index-zfncctjp.js → index-nk0cy9g1.js} +5 -4
- package/dist/index-p1m9djt6.js +108 -0
- package/dist/{index-hs76yzt7.js → index-paff5y0r.js} +17 -11
- package/dist/{index-qaet40b2.js → index-prf6ayhf.js} +5 -7
- package/dist/{index-hkxgennw.js → index-ps3djm8d.js} +7 -1
- package/dist/{index-1v3k5zgx.js → index-qnzhmk2s.js} +528 -1129
- package/dist/{index-3bzk2645.js → index-r9kq5ark.js} +1 -1
- package/dist/{index-hkw233vx.js → index-rbd2rq3z.js} +2 -2
- package/dist/{index-r0xr7y4m.js → index-rhb33thr.js} +138 -33
- package/dist/{index-kffm4r8w.js → index-rj32hkkp.js} +2 -2
- package/dist/index-rptj3qnc.js +96 -0
- package/dist/{index-hqsbtvta.js → index-rpyn7geq.js} +11 -3
- package/dist/{index-m9hb9wnk.js → index-sfzfd2m2.js} +2 -2
- package/dist/{index-sqkttz7z.js → index-sv5svtq7.js} +1 -1
- package/dist/{index-srs8hj9c.js → index-sx3g49y2.js} +5 -1
- package/dist/{index-9mjrnqxs.js → index-t1a2jrg7.js} +21 -91
- package/dist/{index-568w258r.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-gbj964dt.js → index-v37b2cd6.js} +1970 -3142
- package/dist/{index-0ndz5r8z.js → index-v59pxmf1.js} +17 -9
- package/dist/{index-rfkh44ss.js → index-vgytj9wp.js} +1 -1
- package/dist/{index-tnnmekgb.js → index-wa6h4tz6.js} +3 -3
- package/dist/{index-8wzhmgpa.js → index-wavv538x.js} +211 -196
- package/dist/{index-1szhrfsf.js → index-wbnpa8z6.js} +7 -5
- package/dist/index-werjqesf.js +43 -0
- package/dist/{index-7qyv50r4.js → index-wv8dqy7q.js} +2 -2
- package/dist/index-wz392jyz.js +10 -0
- package/dist/{index-1d7s7da0.js → index-x6sp5vpa.js} +36 -5
- package/dist/{index-bqzgaj57.js → index-x90w78yz.js} +183 -61
- package/dist/index-xgae0bn7.js +37 -0
- package/dist/index-xmr47znh.js +160 -0
- package/dist/{index-ftk3838x.js → index-xq4s9mka.js} +7 -2
- package/dist/{index-ww3gss55.js → index-xrgn784x.js} +1 -1
- package/dist/{index-fpwbskp2.js → index-xtby8rj3.js} +1 -1
- package/dist/index-xtkw9866.js +107 -0
- package/dist/{index-btjwc7xr.js → index-xypxnzhp.js} +15 -14
- package/dist/{index-yex7eg1v.js → index-y7sy1xdp.js} +6 -2
- package/dist/index-z4k0hqp9.js +476 -0
- package/dist/{index-a7ebd769.js → index-zwgwyvdt.js} +3 -3
- package/dist/internal/abort-error.d.ts +9 -0
- package/dist/internal/abort-error.d.ts.map +1 -0
- package/dist/internal/abort-race.d.ts +47 -4
- package/dist/internal/abort-race.d.ts.map +1 -1
- package/dist/internal/atomic-file.d.ts +19 -0
- package/dist/internal/atomic-file.d.ts.map +1 -1
- package/dist/internal/backoff.d.ts.map +1 -1
- package/dist/internal/bounded-body.d.ts +37 -1
- package/dist/internal/bounded-body.d.ts.map +1 -1
- package/dist/internal/bounded-file-read.d.ts +31 -15
- package/dist/internal/bounded-file-read.d.ts.map +1 -1
- package/dist/internal/bun-command.d.ts +11 -0
- package/dist/internal/bun-command.d.ts.map +1 -1
- package/dist/internal/channel.d.ts.map +1 -1
- package/dist/internal/coalesced-task.d.ts +14 -2
- package/dist/internal/coalesced-task.d.ts.map +1 -1
- package/dist/internal/darwin-binding-error.d.ts.map +1 -1
- package/dist/internal/darwin-binding.d.ts +10 -0
- package/dist/internal/darwin-binding.d.ts.map +1 -1
- package/dist/internal/deadline.d.ts +22 -2
- package/dist/internal/deadline.d.ts.map +1 -1
- package/dist/internal/exclusive-lock-owner.d.ts +20 -1
- package/dist/internal/exclusive-lock-owner.d.ts.map +1 -1
- package/dist/internal/exclusive-lock-read.d.ts +2 -0
- package/dist/internal/exclusive-lock-read.d.ts.map +1 -1
- package/dist/internal/exclusive-lock.d.ts +26 -0
- package/dist/internal/exclusive-lock.d.ts.map +1 -1
- package/dist/internal/file-observation.d.ts +49 -0
- package/dist/internal/file-observation.d.ts.map +1 -1
- package/dist/internal/json-response.d.ts +10 -0
- package/dist/internal/json-response.d.ts.map +1 -0
- package/dist/internal/open-descriptors.d.ts +5 -0
- package/dist/internal/open-descriptors.d.ts.map +1 -1
- package/dist/internal/optional-peer.d.ts.map +1 -1
- package/dist/internal/pinned-http.d.ts.map +1 -1
- package/dist/internal/positive-integer.d.ts +14 -6
- package/dist/internal/positive-integer.d.ts.map +1 -1
- package/dist/internal/postgres-query.d.ts +16 -0
- package/dist/internal/postgres-query.d.ts.map +1 -0
- package/dist/internal/process-identity.d.ts +21 -1
- package/dist/internal/process-identity.d.ts.map +1 -1
- package/dist/internal/process-instance.d.ts +6 -0
- package/dist/internal/process-instance.d.ts.map +1 -1
- package/dist/internal/request.d.ts +4 -0
- package/dist/internal/request.d.ts.map +1 -1
- package/dist/internal/secret-equal.d.ts +11 -0
- package/dist/internal/secret-equal.d.ts.map +1 -0
- package/dist/internal/secure-fetch.d.ts.map +1 -1
- package/dist/internal/sqlite.d.ts +8 -0
- package/dist/internal/sqlite.d.ts.map +1 -1
- package/dist/internal/timers.d.ts +20 -0
- package/dist/internal/timers.d.ts.map +1 -1
- package/dist/internal/typed.d.ts +11 -0
- package/dist/internal/typed.d.ts.map +1 -1
- package/dist/internal/unix-client-error.d.ts +21 -0
- package/dist/internal/unix-client-error.d.ts.map +1 -0
- package/dist/internal/unix-socket-lock.d.ts +23 -0
- package/dist/internal/unix-socket-lock.d.ts.map +1 -0
- package/dist/internal/unix-socket.d.ts +60 -0
- package/dist/internal/unix-socket.d.ts.map +1 -1
- package/dist/internal/upgrade-affects.d.ts +3 -3
- package/dist/internal/upgrade-affects.d.ts.map +1 -1
- package/dist/internal/upgrade-plan.d.ts.map +1 -1
- package/dist/json-schema/dialect.d.ts +0 -6
- package/dist/json-schema/dialect.d.ts.map +1 -1
- package/dist/json-schema/keywords.d.ts +116 -0
- package/dist/json-schema/keywords.d.ts.map +1 -0
- package/dist/json-schema/string-format.d.ts.map +1 -1
- package/dist/live/events.d.ts.map +1 -1
- package/dist/live/watch-client.d.ts.map +1 -1
- package/dist/observability/bounded-logger.d.ts +3 -0
- package/dist/observability/bounded-logger.d.ts.map +1 -1
- package/dist/observability/bounded-sink.d.ts.map +1 -1
- package/dist/observability/context.d.ts +12 -2
- package/dist/observability/context.d.ts.map +1 -1
- package/dist/observability/event-loop-delay.d.ts +62 -0
- package/dist/observability/event-loop-delay.d.ts.map +1 -0
- package/dist/observability/json-logger.d.ts.map +1 -1
- package/dist/observability/log-repeat.d.ts +44 -0
- package/dist/observability/log-repeat.d.ts.map +1 -0
- package/dist/observability/spool-core.d.ts +95 -0
- package/dist/observability/spool-core.d.ts.map +1 -0
- package/dist/observability/spool-file.d.ts +46 -0
- package/dist/observability/spool-file.d.ts.map +1 -0
- package/dist/observability/spool.d.ts +14 -8
- package/dist/observability/spool.d.ts.map +1 -1
- package/dist/observability/trace.d.ts.map +1 -1
- package/dist/observability/work.d.ts.map +1 -1
- package/dist/primitives/index.d.ts +1 -0
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/order-key.d.ts +37 -0
- package/dist/primitives/order-key.d.ts.map +1 -0
- package/dist/process/bun-child.d.ts.map +1 -1
- package/dist/process/command-owner.d.ts.map +1 -1
- package/dist/process/contract.d.ts +4 -3
- package/dist/process/contract.d.ts.map +1 -1
- package/dist/process/group-presence.d.ts.map +1 -1
- package/dist/process/group-settlement.d.ts +2 -0
- package/dist/process/group-settlement.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/context.d.ts +2 -2
- package/dist/server/context.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 +4 -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 +16 -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 +49 -3
- 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 +20 -11
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/unix-client-body.d.ts +4 -1
- package/dist/server/unix-client-body.d.ts.map +1 -1
- package/dist/server/unix-client-bun.d.ts.map +1 -1
- package/dist/server/unix-client.d.ts +1 -1
- package/dist/server/unix-client.d.ts.map +1 -1
- package/dist/service-host/artifact-activation.d.ts +58 -0
- package/dist/service-host/artifact-activation.d.ts.map +1 -0
- package/dist/service-host/artifact-manifest.d.ts +68 -0
- package/dist/service-host/artifact-manifest.d.ts.map +1 -0
- package/dist/service-host/artifact.d.ts +43 -0
- package/dist/service-host/artifact.d.ts.map +1 -0
- package/dist/service-host/config-reloader-contract.d.ts +66 -0
- package/dist/service-host/config-reloader-contract.d.ts.map +1 -0
- package/dist/service-host/config-reloader-helpers.d.ts +32 -0
- package/dist/service-host/config-reloader-helpers.d.ts.map +1 -0
- package/dist/service-host/config-reloader-source.d.ts +47 -0
- package/dist/service-host/config-reloader-source.d.ts.map +1 -0
- package/dist/service-host/config-reloader.d.ts +6 -0
- package/dist/service-host/config-reloader.d.ts.map +1 -0
- package/dist/service-host/host-adapter.d.ts +72 -0
- package/dist/service-host/host-adapter.d.ts.map +1 -0
- package/dist/service-host/identity-unix-socket.d.ts +101 -0
- package/dist/service-host/identity-unix-socket.d.ts.map +1 -0
- package/dist/service-host/identity.d.ts +117 -0
- package/dist/service-host/identity.d.ts.map +1 -0
- package/dist/service-host/launchd-plist.d.ts +77 -0
- package/dist/service-host/launchd-plist.d.ts.map +1 -0
- package/dist/service-host/launchd-render.d.ts +91 -0
- package/dist/service-host/launchd-render.d.ts.map +1 -0
- package/dist/service-host/launchd.d.ts +82 -0
- package/dist/service-host/launchd.d.ts.map +1 -0
- package/dist/service-host/macos/bundle-plist.d.ts +50 -0
- package/dist/service-host/macos/bundle-plist.d.ts.map +1 -0
- package/dist/service-host/macos/bundle.d.ts +66 -0
- package/dist/service-host/macos/bundle.d.ts.map +1 -0
- package/dist/service-host/macos/codesign.d.ts +95 -0
- package/dist/service-host/macos/codesign.d.ts.map +1 -0
- package/dist/service-host/macos/icon.d.ts +93 -0
- package/dist/service-host/macos/icon.d.ts.map +1 -0
- package/dist/service-host/macos/launch-services.d.ts +88 -0
- package/dist/service-host/macos/launch-services.d.ts.map +1 -0
- package/dist/service-host/macos/launcher.d.ts +59 -0
- package/dist/service-host/macos/launcher.d.ts.map +1 -0
- package/dist/service-host/macos/responsibility.d.ts +90 -0
- package/dist/service-host/macos/responsibility.d.ts.map +1 -0
- package/dist/service-host/macos/runner.d.ts +69 -0
- package/dist/service-host/macos/runner.d.ts.map +1 -0
- package/dist/service-host/plist-xml.d.ts +48 -0
- package/dist/service-host/plist-xml.d.ts.map +1 -0
- package/dist/service-host/process-evidence.d.ts +17 -0
- package/dist/service-host/process-evidence.d.ts.map +1 -0
- package/dist/service-host/systemd-inspect.d.ts +126 -0
- package/dist/service-host/systemd-inspect.d.ts.map +1 -0
- package/dist/service-host/systemd-links.d.ts +23 -0
- package/dist/service-host/systemd-links.d.ts.map +1 -0
- package/dist/service-host/systemd-render.d.ts +93 -0
- package/dist/service-host/systemd-render.d.ts.map +1 -0
- package/dist/service-host/systemd.d.ts +50 -0
- package/dist/service-host/systemd.d.ts.map +1 -0
- package/dist/spend/attribution.d.ts +17 -0
- package/dist/spend/attribution.d.ts.map +1 -0
- package/dist/spend/coverage-guard.d.ts +60 -0
- package/dist/spend/coverage-guard.d.ts.map +1 -0
- package/dist/spend/coverage-lexer.d.ts +20 -0
- package/dist/spend/coverage-lexer.d.ts.map +1 -0
- package/dist/spend/facts.d.ts +23 -0
- package/dist/spend/facts.d.ts.map +1 -0
- package/dist/spend/gateway-stream.d.ts +25 -0
- package/dist/spend/gateway-stream.d.ts.map +1 -0
- package/dist/spend/gateway.d.ts +64 -0
- package/dist/spend/gateway.d.ts.map +1 -0
- package/dist/spend/receipt-merge.d.ts +13 -0
- package/dist/spend/receipt-merge.d.ts.map +1 -0
- package/dist/spend/receipt-spool.d.ts +35 -0
- package/dist/spend/receipt-spool.d.ts.map +1 -0
- package/dist/spend/reconcile.d.ts +45 -0
- package/dist/spend/reconcile.d.ts.map +1 -0
- package/dist/spend/schemas.d.ts +249 -0
- package/dist/spend/schemas.d.ts.map +1 -0
- package/dist/sync/outbox.d.ts +131 -0
- package/dist/sync/outbox.d.ts.map +1 -0
- package/dist/sync/overlay.d.ts +59 -0
- package/dist/sync/overlay.d.ts.map +1 -0
- package/dist/sync/protocol.d.ts +132 -0
- package/dist/sync/protocol.d.ts.map +1 -0
- package/dist/sync/server-store-check.d.ts +10 -0
- package/dist/sync/server-store-check.d.ts.map +1 -0
- package/dist/sync/server-store-memory.d.ts +14 -0
- package/dist/sync/server-store-memory.d.ts.map +1 -0
- package/dist/sync/server-store-postgres.d.ts +25 -0
- package/dist/sync/server-store-postgres.d.ts.map +1 -0
- package/dist/sync/server-store.d.ts +139 -0
- package/dist/sync/server-store.d.ts.map +1 -0
- package/dist/sync/session-machine.d.ts +79 -0
- package/dist/sync/session-machine.d.ts.map +1 -0
- package/dist/sync/session-snapshot.d.ts +19 -0
- package/dist/sync/session-snapshot.d.ts.map +1 -0
- package/dist/sync/session-steps.d.ts +15 -0
- package/dist/sync/session-steps.d.ts.map +1 -0
- package/dist/sync/session.d.ts +142 -0
- package/dist/sync/session.d.ts.map +1 -0
- package/dist/sync/tombstones.d.ts +53 -0
- package/dist/sync/tombstones.d.ts.map +1 -0
- package/dist/telegram/bot-api.d.ts.map +1 -1
- package/dist/telegram/broadcast-failure.d.ts.map +1 -1
- package/dist/telegram/budget-transformer.d.ts.map +1 -1
- package/dist/telegram/crypto.d.ts +2 -10
- package/dist/telegram/crypto.d.ts.map +1 -1
- package/dist/telegram/html/markdown-inline.d.ts +19 -0
- package/dist/telegram/html/markdown-inline.d.ts.map +1 -0
- package/dist/telegram/html/markdown-lines.d.ts +51 -0
- package/dist/telegram/html/markdown-lines.d.ts.map +1 -0
- package/dist/telegram/html/markdown-split.d.ts +49 -0
- package/dist/telegram/html/markdown-split.d.ts.map +1 -0
- package/dist/telegram/html/markdown.d.ts +14 -0
- package/dist/telegram/html/markdown.d.ts.map +1 -0
- package/dist/telegram/html/nodes.d.ts +26 -4
- package/dist/telegram/html/nodes.d.ts.map +1 -1
- package/dist/telegram/html/parse.d.ts.map +1 -1
- package/dist/telegram/html/render.d.ts.map +1 -1
- package/dist/telegram/init-data.d.ts.map +1 -1
- package/dist/telegram/local-files.d.ts.map +1 -1
- package/dist/telegram/operator-channel.d.ts +15 -2
- package/dist/telegram/operator-channel.d.ts.map +1 -1
- package/dist/telegram/outbound-budget.d.ts.map +1 -1
- package/dist/telegram/outbound-cost.d.ts +9 -1
- package/dist/telegram/outbound-cost.d.ts.map +1 -1
- package/dist/telegram/outbound-queue.d.ts +2 -1
- package/dist/telegram/outbound-queue.d.ts.map +1 -1
- package/dist/telegram/screens/outcome.d.ts.map +1 -1
- package/dist/telegram/send-failure.d.ts.map +1 -1
- package/dist/telegram/transport-connect.d.ts.map +1 -1
- package/dist/telegram/transport.d.ts.map +1 -1
- package/dist/telegram/update-intake.d.ts.map +1 -1
- package/dist/telegram/update-store-postgres.d.ts +2 -2
- package/dist/telegram/update-store-postgres.d.ts.map +1 -1
- package/dist/telegram/webhook.d.ts.map +1 -1
- package/dist/testing/managed-resource-conformance.d.ts.map +1 -1
- package/dist/testing/surface-conformance.d.ts.map +1 -1
- package/dist/testing/surface-manifest.d.ts +2 -0
- package/dist/testing/surface-manifest.d.ts.map +1 -1
- package/dist/tools/access.d.ts +34 -0
- package/dist/tools/access.d.ts.map +1 -0
- package/dist/tools/agent.d.ts +14 -6
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/cli/args-classify.d.ts +154 -0
- package/dist/tools/cli/args-classify.d.ts.map +1 -0
- package/dist/tools/cli/args-fields.d.ts +14 -7
- package/dist/tools/cli/args-fields.d.ts.map +1 -1
- package/dist/tools/cli/args-json.d.ts +1 -1
- package/dist/tools/cli/args-json.d.ts.map +1 -1
- package/dist/tools/cli/args-route.d.ts +4 -48
- package/dist/tools/cli/args-route.d.ts.map +1 -1
- package/dist/tools/cli/args-scan.d.ts +70 -0
- package/dist/tools/cli/args-scan.d.ts.map +1 -0
- package/dist/tools/cli/args-tokens.d.ts +2 -1
- package/dist/tools/cli/args-tokens.d.ts.map +1 -1
- package/dist/tools/cli/args.d.ts +31 -19
- package/dist/tools/cli/args.d.ts.map +1 -1
- package/dist/tools/cli/checkpoint.d.ts.map +1 -1
- package/dist/tools/cli/command-shape.d.ts +5 -0
- package/dist/tools/cli/command-shape.d.ts.map +1 -1
- package/dist/tools/cli/command.d.ts +57 -2
- package/dist/tools/cli/command.d.ts.map +1 -1
- package/dist/tools/cli/config.d.ts +15 -58
- package/dist/tools/cli/config.d.ts.map +1 -1
- package/dist/tools/cli/create-cli.d.ts +7 -3
- package/dist/tools/cli/create-cli.d.ts.map +1 -1
- package/dist/tools/cli/format.d.ts.map +1 -1
- package/dist/tools/cli/help.d.ts.map +1 -1
- package/dist/tools/cli/invoke.d.ts +70 -20
- package/dist/tools/cli/invoke.d.ts.map +1 -1
- package/dist/tools/cli/io.d.ts.map +1 -1
- package/dist/tools/cli/managed-surface.d.ts.map +1 -1
- package/dist/tools/cli/notices.d.ts.map +1 -1
- package/dist/tools/cli/policy.d.ts +66 -10
- package/dist/tools/cli/policy.d.ts.map +1 -1
- package/dist/tools/cli/prepare.d.ts +5 -4
- package/dist/tools/cli/prepare.d.ts.map +1 -1
- package/dist/tools/cli/run-managed.d.ts.map +1 -1
- package/dist/tools/cli/run-native.d.ts.map +1 -1
- package/dist/tools/cli/run-stream.d.ts.map +1 -1
- package/dist/tools/cli/runner.d.ts +28 -0
- package/dist/tools/cli/runner.d.ts.map +1 -0
- package/dist/tools/cli/session.d.ts +12 -6
- package/dist/tools/cli/session.d.ts.map +1 -1
- package/dist/tools/cli/stream-surface.d.ts.map +1 -1
- package/dist/tools/cli/stream.d.ts.map +1 -1
- package/dist/tools/cli/unavailable.d.ts +2 -0
- package/dist/tools/cli/unavailable.d.ts.map +1 -1
- package/dist/tools/cli/unix-outcome.d.ts +8 -0
- package/dist/tools/cli/unix-outcome.d.ts.map +1 -0
- package/dist/tools/cli/update.d.ts.map +1 -1
- package/dist/tools/cli/view-columns.d.ts +18 -0
- package/dist/tools/cli/view-columns.d.ts.map +1 -0
- package/dist/tools/cli/view.d.ts.map +1 -1
- package/dist/tools/connections/define.d.ts.map +1 -1
- package/dist/tools/connections/foreign-schema-join.d.ts +28 -0
- package/dist/tools/connections/foreign-schema-join.d.ts.map +1 -0
- package/dist/tools/connections/foreign-schema.d.ts +9 -0
- package/dist/tools/connections/foreign-schema.d.ts.map +1 -0
- package/dist/tools/connections/limits.d.ts +1 -1
- package/dist/tools/connections/limits.d.ts.map +1 -1
- package/dist/tools/connections/mcp-client.d.ts.map +1 -1
- package/dist/tools/connections/mcp.d.ts.map +1 -1
- package/dist/tools/connections/openapi.d.ts.map +1 -1
- package/dist/tools/connections/runtime.d.ts +18 -6
- package/dist/tools/connections/runtime.d.ts.map +1 -1
- package/dist/tools/connections/sse-session.d.ts.map +1 -1
- package/dist/tools/connections/types.d.ts +12 -2
- package/dist/tools/connections/types.d.ts.map +1 -1
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/internal/expose.d.ts +6 -0
- package/dist/tools/internal/expose.d.ts.map +1 -0
- package/dist/tools/internal/json-projection.d.ts +17 -0
- package/dist/tools/internal/json-projection.d.ts.map +1 -0
- package/dist/tools/internal/surface-projector.d.ts +18 -4
- package/dist/tools/internal/surface-projector.d.ts.map +1 -1
- package/dist/tools/invoker.d.ts +9 -2
- package/dist/tools/invoker.d.ts.map +1 -1
- package/dist/tools/lifecycle.d.ts +8 -2
- package/dist/tools/lifecycle.d.ts.map +1 -1
- package/dist/tools/list-names.d.ts +1 -1
- package/dist/tools/list-names.d.ts.map +1 -1
- package/dist/tools/manifest.d.ts +2 -0
- package/dist/tools/manifest.d.ts.map +1 -1
- package/dist/tools/mcp/handler.d.ts.map +1 -1
- package/dist/tools/mcp/mount.d.ts +26 -14
- package/dist/tools/mcp/mount.d.ts.map +1 -1
- package/dist/tools/mcp/prepare.d.ts +2 -0
- package/dist/tools/mcp/prepare.d.ts.map +1 -1
- package/dist/tools/mcp/register.d.ts.map +1 -1
- package/dist/tools/mcp/runtime-tools.d.ts +1 -1
- package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
- package/dist/tools/mcp/stdio.d.ts.map +1 -1
- package/dist/tools/mount.d.ts +7 -2
- package/dist/tools/mount.d.ts.map +1 -1
- package/dist/tools/native-definition.d.ts +1 -1
- package/dist/tools/native-definition.d.ts.map +1 -1
- package/dist/tools/operations/async-operation-runtime-tools.d.ts +2 -2
- package/dist/tools/operations/async-operation-runtime-tools.d.ts.map +1 -1
- package/dist/tools/operations/async-operation-runtime-types.d.ts +1 -1
- package/dist/tools/operations/async-operation-runtime-types.d.ts.map +1 -1
- package/dist/tools/operations/define-wait-tool.d.ts.map +1 -1
- package/dist/tools/operations/mount-wait.d.ts.map +1 -1
- package/dist/tools/operations/wait-core.d.ts.map +1 -1
- package/dist/tools/read-operation.d.ts +6 -4
- package/dist/tools/read-operation.d.ts.map +1 -1
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/runtime-tool-declaration.d.ts +4 -1
- package/dist/tools/runtime-tool-declaration.d.ts.map +1 -1
- package/dist/tools/runtime-tool.d.ts +6 -1
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/dist/tools/schema/coerce.d.ts.map +1 -1
- package/dist/tools/schema/inline-references.d.ts +7 -0
- package/dist/tools/schema/inline-references.d.ts.map +1 -0
- package/dist/tools/schema/json-schema-origin.d.ts +1 -1
- package/dist/tools/schema/json-schema-origin.d.ts.map +1 -1
- package/dist/tools/schema/presentation.d.ts +6 -0
- package/dist/tools/schema/presentation.d.ts.map +1 -1
- package/dist/tools/schema/schema.d.ts +2 -0
- package/dist/tools/schema/schema.d.ts.map +1 -1
- package/dist/tools/schema/untyped-properties.d.ts.map +1 -1
- package/dist/tools/surface.d.ts.map +1 -1
- package/dist/tools/toolkit.d.ts +6 -3
- package/dist/tools/toolkit.d.ts.map +1 -1
- package/dist/tools/transfer/define-download-tool.d.ts.map +1 -1
- package/dist/tools/transfer/define-upload-tool.d.ts.map +1 -1
- package/dist/tools/transfer/define-view-file-tool.d.ts +2 -1
- package/dist/tools/transfer/define-view-file-tool.d.ts.map +1 -1
- package/dist/tools/transfer/mount-download.d.ts.map +1 -1
- package/dist/tools/transfer/view-file-contract.d.ts +2 -2
- package/dist/tools/transfer/view-file.d.ts +1 -2
- package/dist/tools/transfer/view-file.d.ts.map +1 -1
- package/dist/tracking/client.d.ts +0 -13
- package/dist/tracking/client.d.ts.map +1 -1
- package/dist/tracking/delivery.d.ts.map +1 -1
- package/dist/tracking/performance/collector.d.ts.map +1 -1
- package/llms/agent-executor-acp.txt +51 -0
- package/llms/agent-executor-claude-sdk.txt +31 -0
- package/llms/agent-executor-claude.txt +29 -0
- package/llms/agent-executor-codex.txt +25 -0
- package/llms/agent-executor-testing.txt +26 -0
- package/llms/agent-executor.txt +40 -0
- package/llms/agent-runtime-harness.txt +68 -5
- package/llms/agent-runtime-openrouter.txt +8 -2
- package/llms/agent-runtime-postgres.txt +30 -0
- package/llms/agent-runtime-react.txt +1 -1
- package/llms/agent-runtime-realtime.txt +1 -1
- package/llms/agent-runtime-sandbox.txt +5 -2
- package/llms/agent-runtime-sqlite-bun.txt +2 -2
- package/llms/agent-runtime-sqlite-node.txt +2 -2
- package/llms/agent-runtime-testing.txt +2 -1
- package/llms/agent-runtime.2.txt +475 -496
- package/llms/agent-runtime.3.txt +229 -267
- package/llms/agent-runtime.4.txt +23 -242
- package/llms/agent-runtime.5.txt +1 -1
- package/llms/agent-runtime.txt +551 -2
- package/llms/application-diagnostic-journal.txt +2 -0
- package/llms/application.2.txt +3 -0
- package/llms/application.3.txt +30 -7
- package/llms/application.txt +4 -1
- package/llms/cli.2.txt +259 -99
- package/llms/cli.3.txt +90 -0
- package/llms/cli.txt +95 -184
- package/llms/contract.txt +7 -6
- package/llms/declaration.txt +1 -1
- package/llms/files.txt +11 -0
- package/llms/handler.txt +25 -0
- package/llms/http.txt +18 -1
- package/llms/live.txt +28 -1
- package/llms/node.txt +3 -2
- package/llms/observability.2.txt +105 -0
- package/llms/observability.txt +14 -90
- package/llms/primitives.txt +27 -0
- package/llms/process.2.txt +2 -2
- package/llms/process.txt +10 -9
- package/llms/realtime.txt +11 -0
- package/llms/server.2.txt +355 -0
- package/llms/server.3.txt +2 -1
- package/llms/server.4.txt +45 -6
- package/llms/server.5.txt +9 -2
- package/llms/server.txt +185 -255
- package/llms/service-host-macos.txt +53 -0
- package/llms/service-host.txt +69 -0
- package/llms/spend-testing.txt +21 -0
- package/llms/spend.txt +173 -0
- package/llms/stitchkit.2.txt +368 -42
- package/llms/stitchkit.3.txt +164 -13
- package/llms/stitchkit.txt +95 -417
- package/llms/sync-postgres.txt +31 -0
- package/llms/sync.txt +396 -0
- package/llms/telegram-html.txt +4 -1
- package/llms/telegram.2.txt +4 -4
- package/llms/telegram.txt +105 -14
- package/llms/testing.txt +4 -3
- package/llms/tools-connections.txt +4 -4
- package/llms/tools.2.txt +78 -17
- package/llms/tools.3.txt +12 -8
- package/llms/tools.txt +85 -78
- package/llms/{upgrading-0.106.0-0.125.0.txt → upgrading-0.106.0-0.126.0.txt} +42 -3
- package/llms/upgrading-0.127.0.txt +1059 -0
- package/llms/upgrading.txt +2 -1
- package/llms-full.txt +3692 -518
- package/llms.txt +45 -29
- package/native/darwin-arm64.node +0 -0
- package/native/darwin-x64.node +0 -0
- package/native-assets.json +4 -4
- package/package.json +69 -11
- 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-5dmk54h9.js +0 -256
- package/dist/index-7cn66qdk.js +0 -92
- package/dist/index-8x0q6yfb.js +0 -247
- package/dist/index-a5qr2rj6.js +0 -26
- package/dist/index-b0kddvzw.js +0 -35
- package/dist/index-cj5f0x4y.js +0 -1150
- 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,87 @@
|
|
|
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
|
+
ModelInvocationTraceSchema2,
|
|
15
|
+
CompletionInvocationInputSchema2,
|
|
16
|
+
InvocationCallerSchema,
|
|
17
|
+
InvocationStartedSchema,
|
|
18
|
+
ModelInvocationRecordSchema2,
|
|
19
|
+
InvocationPayloadSchema,
|
|
20
|
+
isModelInvocationRecord,
|
|
21
|
+
createToolChronology,
|
|
22
|
+
advanceToolChronology,
|
|
23
|
+
canProjectToolChronology,
|
|
24
|
+
isAssistantHistoryEvidence2,
|
|
25
|
+
isCompleteAgentHistoryTurn,
|
|
26
|
+
assistantStatus
|
|
27
|
+
} from "./index-ajmtxsky.js";
|
|
28
|
+
import {
|
|
29
|
+
withStoreRetries,
|
|
30
|
+
AgentRuntimeConflictError2,
|
|
31
|
+
AgentRunUnsettledError2,
|
|
32
|
+
appliedSnapshot,
|
|
33
|
+
terminalOfSnapshot,
|
|
34
|
+
terminalOfRunView,
|
|
35
|
+
commitAgentRunTerminal,
|
|
36
|
+
findRun,
|
|
37
|
+
jsonValue,
|
|
38
|
+
providerEnvelope,
|
|
39
|
+
providerResponseIdentity,
|
|
40
|
+
appendText,
|
|
41
|
+
abortTerminalReason,
|
|
42
|
+
mergeModelTotals,
|
|
43
|
+
statedUsage,
|
|
44
|
+
normalizeSdkUsage,
|
|
45
|
+
createIdleDeadline,
|
|
46
|
+
adoptSnapshot,
|
|
47
|
+
transientSequence,
|
|
48
|
+
runUsage,
|
|
49
|
+
updateReasoning,
|
|
50
|
+
checkpoint,
|
|
51
|
+
DEFAULT_STEP_SPEND_TIMEOUT_MS,
|
|
52
|
+
normalizeStepUsage,
|
|
53
|
+
recordStepSpend,
|
|
54
|
+
InvocationReceiptError,
|
|
55
|
+
invocationHash,
|
|
56
|
+
createInvocationPayloads,
|
|
57
|
+
isOwnInputRefusal,
|
|
58
|
+
markProviderOrigin,
|
|
59
|
+
hasProviderOrigin,
|
|
60
|
+
markProviderStream,
|
|
61
|
+
wrapInvocationModel
|
|
62
|
+
} from "./index-kmbpej2y.js";
|
|
18
63
|
import {
|
|
19
64
|
AGENT_TOOL_PROGRESS_MESSAGE_MAX2,
|
|
20
65
|
agentDurableEventId2
|
|
21
|
-
} from "./index-
|
|
66
|
+
} from "./index-paff5y0r.js";
|
|
67
|
+
import {
|
|
68
|
+
ToolExecutionControlError2,
|
|
69
|
+
isToolExecutionControlError2
|
|
70
|
+
} from "./index-9wh98cpa.js";
|
|
71
|
+
import {
|
|
72
|
+
contractOperationEffects2
|
|
73
|
+
} from "./index-werjqesf.js";
|
|
22
74
|
import {
|
|
23
75
|
createLocalStepDurability2
|
|
24
|
-
} from "./index-
|
|
76
|
+
} from "./index-kynwa08q.js";
|
|
25
77
|
import {
|
|
78
|
+
isActiveRunState,
|
|
26
79
|
canonicalAgentJson2,
|
|
27
|
-
|
|
28
|
-
advanceToolChronology,
|
|
29
|
-
canProjectToolChronology,
|
|
30
|
-
isAssistantHistoryEvidence2,
|
|
31
|
-
isCompleteAgentHistoryTurn,
|
|
32
|
-
assistantStatus,
|
|
80
|
+
issueRunContext,
|
|
33
81
|
ProviderJournalMessageSchema,
|
|
34
82
|
ProviderJournalRequestSchema,
|
|
35
|
-
ProviderJournalResponseSchema
|
|
36
|
-
|
|
37
|
-
} from "./index-egg0yp2j.js";
|
|
38
|
-
import {
|
|
39
|
-
messageOf
|
|
40
|
-
} from "./index-3bzk2645.js";
|
|
83
|
+
ProviderJournalResponseSchema
|
|
84
|
+
} from "./index-9xr44d2g.js";
|
|
41
85
|
import {
|
|
42
86
|
createRuntimeToolContext
|
|
43
87
|
} from "./index-eh71zr32.js";
|
|
@@ -45,398 +89,31 @@ import {
|
|
|
45
89
|
createMutationQueue
|
|
46
90
|
} from "./index-sykb5ag7.js";
|
|
47
91
|
import {
|
|
92
|
+
messageOf
|
|
93
|
+
} from "./index-r9kq5ark.js";
|
|
94
|
+
import {
|
|
95
|
+
listContractToolNames2
|
|
96
|
+
} from "./index-3agqmmrg.js";
|
|
97
|
+
import {
|
|
98
|
+
AgentToolError2,
|
|
48
99
|
isAgentToolError2
|
|
49
100
|
} from "./index-1psbyyhj.js";
|
|
50
101
|
import {
|
|
51
102
|
assertPositiveSafeInteger
|
|
52
|
-
} from "./index-
|
|
53
|
-
import {
|
|
54
|
-
serializeCanonicalJson
|
|
55
|
-
} from "./index-20hn8pbh.js";
|
|
103
|
+
} from "./index-kzavdze2.js";
|
|
56
104
|
import {
|
|
57
105
|
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
|
-
}
|
|
106
|
+
transportResult,
|
|
107
|
+
mapObjectTypeBoundary
|
|
108
|
+
} from "./index-ps3djm8d.js";
|
|
109
|
+
import {
|
|
110
|
+
assertTimerMs,
|
|
111
|
+
withDeadline
|
|
112
|
+
} from "./index-agy5fqgf.js";
|
|
113
|
+
import {
|
|
114
|
+
raceAbort,
|
|
115
|
+
linkAbortSignals
|
|
116
|
+
} from "./index-rptj3qnc.js";
|
|
440
117
|
|
|
441
118
|
// src/agent-runtime/context-refusal.ts
|
|
442
119
|
class AgentContextOverflowError2 extends Error {
|
|
@@ -448,11 +125,8 @@ class AgentContextOverflowError2 extends Error {
|
|
|
448
125
|
|
|
449
126
|
// src/agent-runtime/coordinator.ts
|
|
450
127
|
function assertCloseBudgets(options) {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
throw new TypeError(`${name} must be a non-negative safe integer`);
|
|
454
|
-
}
|
|
455
|
-
}
|
|
128
|
+
assertTimerMs("Agent session close gracePeriodMs", options.gracePeriodMs, { min: 0 });
|
|
129
|
+
assertTimerMs("Agent session close forceTimeoutMs", options.forceTimeoutMs, { min: 0 });
|
|
456
130
|
}
|
|
457
131
|
function createAgentSessionCoordinator2() {
|
|
458
132
|
const lanes = new Map;
|
|
@@ -460,15 +134,7 @@ function createAgentSessionCoordinator2() {
|
|
|
460
134
|
const waitWithin = async (settled, timeoutMs) => {
|
|
461
135
|
if (timeoutMs === 0)
|
|
462
136
|
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;
|
|
137
|
+
return (await withDeadline(settled, timeoutMs)).settled;
|
|
472
138
|
};
|
|
473
139
|
const laneFor = (key) => {
|
|
474
140
|
const existing = lanes.get(key);
|
|
@@ -603,6 +269,14 @@ function registerDeferredToolCatalog(tools, searchName, names) {
|
|
|
603
269
|
if (search && typeof search === "object")
|
|
604
270
|
catalogs.set(search, names);
|
|
605
271
|
}
|
|
272
|
+
function carryDeferredToolCatalog(from, to) {
|
|
273
|
+
for (const [name, tool] of Object.entries(from)) {
|
|
274
|
+
const names = tool && typeof tool === "object" ? catalogs.get(tool) : undefined;
|
|
275
|
+
const next = to[name];
|
|
276
|
+
if (names && next && typeof next === "object")
|
|
277
|
+
catalogs.set(next, names);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
606
280
|
function deferredToolCatalog(tools, searchName) {
|
|
607
281
|
const search = tools[searchName];
|
|
608
282
|
return search && typeof search === "object" ? catalogs.get(search) : undefined;
|
|
@@ -884,468 +558,18 @@ async function projectAgentHistory2(messages, options = {}) {
|
|
|
884
558
|
return [...(await projectAgentHistoryDetailed2(messages, options)).messages];
|
|
885
559
|
}
|
|
886
560
|
|
|
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
561
|
// src/agent-runtime/invocations.ts
|
|
1338
|
-
import { randomUUID
|
|
562
|
+
import { randomUUID } from "node:crypto";
|
|
1339
563
|
import { hostname } from "node:os";
|
|
1340
564
|
import { generateText } from "ai";
|
|
1341
|
-
import { z as
|
|
565
|
+
import { z as z2 } from "zod";
|
|
1342
566
|
|
|
1343
567
|
// src/agent-runtime/invocation-read.ts
|
|
1344
|
-
import { z
|
|
1345
|
-
var InvocationReadInputSchema =
|
|
1346
|
-
conversationId:
|
|
1347
|
-
fromSeq:
|
|
1348
|
-
limit:
|
|
568
|
+
import { z } from "zod";
|
|
569
|
+
var InvocationReadInputSchema = z.object({
|
|
570
|
+
conversationId: z.string().min(1),
|
|
571
|
+
fromSeq: z.int().positive().optional(),
|
|
572
|
+
limit: z.int().positive().max(1e4)
|
|
1349
573
|
}).strict();
|
|
1350
574
|
async function readInvocationRecords(store, input) {
|
|
1351
575
|
const page = await store.readEvents(InvocationReadInputSchema.parse(input));
|
|
@@ -1358,7 +582,7 @@ async function readInvocationRecords(store, input) {
|
|
|
1358
582
|
"provider/response"
|
|
1359
583
|
].includes(event.kind))
|
|
1360
584
|
return [];
|
|
1361
|
-
if (!
|
|
585
|
+
if (!isModelInvocationRecord(event.payload))
|
|
1362
586
|
return [];
|
|
1363
587
|
return [
|
|
1364
588
|
{
|
|
@@ -1399,7 +623,7 @@ async function readInvocationPayload(store, payloads, input) {
|
|
|
1399
623
|
}
|
|
1400
624
|
|
|
1401
625
|
// src/agent-runtime/invocations.ts
|
|
1402
|
-
var executingProcess = { instanceId:
|
|
626
|
+
var executingProcess = { instanceId: randomUUID(), pid: process.pid, hostname: hostname() };
|
|
1403
627
|
var agentBindings = new WeakMap;
|
|
1404
628
|
function beginAgentInvocation(ledger, store, input, context) {
|
|
1405
629
|
const binding = agentBindings.get(ledger);
|
|
@@ -1436,7 +660,7 @@ function createModelInvocationLedger2(config) {
|
|
|
1436
660
|
const appendOnce = store.appendEventOnce?.bind(store);
|
|
1437
661
|
if (!appendOnce)
|
|
1438
662
|
throw new TypeError("Model invocations require atomic store.appendEventOnce");
|
|
1439
|
-
const maxPayloadBytes =
|
|
663
|
+
const maxPayloadBytes = z2.int().min(1024).max(64 * 1024 * 1024).parse(config.maxPayloadBytes ?? 4 * 1024 * 1024);
|
|
1440
664
|
const payloads = createInvocationPayloads(store, config.payloadKey, maxPayloadBytes);
|
|
1441
665
|
const authorize = async (input) => InvocationCallerSchema.parse(await config.authorize(input));
|
|
1442
666
|
const start = async (input) => {
|
|
@@ -1455,7 +679,7 @@ function createModelInvocationLedger2(config) {
|
|
|
1455
679
|
});
|
|
1456
680
|
const identity = {
|
|
1457
681
|
conversationId: input.conversationId,
|
|
1458
|
-
invocationId:
|
|
682
|
+
invocationId: randomUUID(),
|
|
1459
683
|
operationId: trace.operationId,
|
|
1460
684
|
...input.runId && { runId: input.runId }
|
|
1461
685
|
};
|
|
@@ -1512,12 +736,13 @@ function createModelInvocationLedger2(config) {
|
|
|
1512
736
|
if (duplicate)
|
|
1513
737
|
return { invocationId, outcome: "duplicate" };
|
|
1514
738
|
const deadline = AbortSignal.timeout(input.timeoutMs);
|
|
1515
|
-
const abortSignal
|
|
739
|
+
const { signal: abortSignal, release } = linkAbortSignals(signal, deadline);
|
|
1516
740
|
let text;
|
|
1517
741
|
try {
|
|
1518
742
|
text = await generateWithFallback(config.models, writer, input, abortSignal);
|
|
1519
743
|
} catch (error) {
|
|
1520
744
|
const status = abortSignal.aborted ? "cancelled" : "failed";
|
|
745
|
+
release();
|
|
1521
746
|
try {
|
|
1522
747
|
const artifact = await payloads.write(writer.identity, { error });
|
|
1523
748
|
await finish(writer, status, {
|
|
@@ -1532,6 +757,7 @@ function createModelInvocationLedger2(config) {
|
|
|
1532
757
|
}
|
|
1533
758
|
return withReceipt({ invocationId, outcome: status }, writer);
|
|
1534
759
|
}
|
|
760
|
+
release();
|
|
1535
761
|
try {
|
|
1536
762
|
await finish(writer, "succeeded");
|
|
1537
763
|
} catch (receiptError) {
|
|
@@ -1605,9 +831,9 @@ function createAgentToolFenceLifecycle2(config) {
|
|
|
1605
831
|
}
|
|
1606
832
|
|
|
1607
833
|
// src/agent-runtime/prompt.ts
|
|
1608
|
-
import { z as
|
|
1609
|
-
var AgentTokenCountSchema2 =
|
|
1610
|
-
value:
|
|
834
|
+
import { z as z3 } from "zod";
|
|
835
|
+
var AgentTokenCountSchema2 = z3.object({
|
|
836
|
+
value: z3.int().nonnegative().optional(),
|
|
1611
837
|
provenance: AgentProvenanceSchema2.extract([
|
|
1612
838
|
"measured",
|
|
1613
839
|
"computed",
|
|
@@ -1727,7 +953,7 @@ function knownValue(value) {
|
|
|
1727
953
|
}
|
|
1728
954
|
function composeAgentPrompt2(sections) {
|
|
1729
955
|
return async (options) => {
|
|
1730
|
-
const event =
|
|
956
|
+
const event = z3.enum(["session.started", "turn.started"]).parse(options.event ?? "turn.started");
|
|
1731
957
|
const rendered = [];
|
|
1732
958
|
let systemTotal = 0;
|
|
1733
959
|
let userTotal = 0;
|
|
@@ -1913,12 +1139,16 @@ function parseJson(value) {
|
|
|
1913
1139
|
}
|
|
1914
1140
|
|
|
1915
1141
|
// src/agent-runtime/retry-policy.ts
|
|
1142
|
+
function assertAgentRetryPolicy(subject, policy) {
|
|
1143
|
+
assertPositiveSafeInteger(`${subject}.maxAttempts`, policy.maxAttempts, TypeError, {
|
|
1144
|
+
absent: "refused"
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1916
1147
|
async function recordAgentRetryDecision2(input) {
|
|
1148
|
+
assertAgentRetryPolicy("Retry policy", input.policy);
|
|
1917
1149
|
const retry = input.failure.retryable && input.attempt < input.policy.maxAttempts;
|
|
1918
1150
|
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
|
-
}
|
|
1151
|
+
assertTimerMs("Retry delayMs", delayMs, { min: 0, absent: "refused" });
|
|
1922
1152
|
if (retry) {
|
|
1923
1153
|
await input.store.appendEvent({
|
|
1924
1154
|
conversationId: input.conversationId,
|
|
@@ -1929,6 +1159,246 @@ async function recordAgentRetryDecision2(input) {
|
|
|
1929
1159
|
return { retry, delayMs };
|
|
1930
1160
|
}
|
|
1931
1161
|
|
|
1162
|
+
// src/agent-runtime/run-step-barriers.ts
|
|
1163
|
+
class AgentStepBarrierError2 extends Error {
|
|
1164
|
+
bound;
|
|
1165
|
+
constructor(bound, message) {
|
|
1166
|
+
super(message);
|
|
1167
|
+
this.bound = bound;
|
|
1168
|
+
this.name = "AgentStepBarrierError";
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
function assertStepBarriers(barriers) {
|
|
1172
|
+
if (!barriers)
|
|
1173
|
+
return;
|
|
1174
|
+
assertPositiveSafeInteger("stepBarriers.maxToolCallsPerStep", barriers.maxToolCallsPerStep, RangeError);
|
|
1175
|
+
assertPositiveSafeInteger("stepBarriers.maxReasoningCharsPerStep", barriers.maxReasoningCharsPerStep, RangeError);
|
|
1176
|
+
if (barriers.stepText !== undefined && !["immediate", "after-tools"].includes(barriers.stepText))
|
|
1177
|
+
throw new RangeError("stepBarriers.stepText must be 'immediate' or 'after-tools'");
|
|
1178
|
+
}
|
|
1179
|
+
function isAsyncIterable(value) {
|
|
1180
|
+
return value !== null && typeof value === "object" && typeof Reflect.get(value, Symbol.asyncIterator) === "function";
|
|
1181
|
+
}
|
|
1182
|
+
function isAsyncGeneratorFunction(value) {
|
|
1183
|
+
return Object.prototype.toString.call(value) === "[object AsyncGeneratorFunction]";
|
|
1184
|
+
}
|
|
1185
|
+
async function finalOutput(value) {
|
|
1186
|
+
if (!isAsyncIterable(value))
|
|
1187
|
+
return value;
|
|
1188
|
+
let last;
|
|
1189
|
+
for await (const output of value)
|
|
1190
|
+
last = output;
|
|
1191
|
+
return last;
|
|
1192
|
+
}
|
|
1193
|
+
function createStepLedger(barriers) {
|
|
1194
|
+
let current;
|
|
1195
|
+
return (messages, toolCallId, toolName, input) => {
|
|
1196
|
+
if (current === undefined || current.messages !== messages)
|
|
1197
|
+
current = { messages, count: 0, calls: new Map, entities: new Map };
|
|
1198
|
+
const ledger = current;
|
|
1199
|
+
const known = ledger.calls.get(toolCallId);
|
|
1200
|
+
if (known)
|
|
1201
|
+
return known;
|
|
1202
|
+
ledger.count += 1;
|
|
1203
|
+
const limit = barriers.maxToolCallsPerStep;
|
|
1204
|
+
const refused = limit !== undefined && ledger.count > limit;
|
|
1205
|
+
const own = Promise.withResolvers();
|
|
1206
|
+
const dependencies = refused ? undefined : barriers.toolDependencies?.({ toolName, input });
|
|
1207
|
+
const writes = new Set(dependencies?.writes ?? []);
|
|
1208
|
+
const reads = new Set([...dependencies?.reads ?? []].filter((entity) => !writes.has(entity)));
|
|
1209
|
+
const stateOf = (entity) => {
|
|
1210
|
+
const known = ledger.entities.get(entity);
|
|
1211
|
+
if (known)
|
|
1212
|
+
return known;
|
|
1213
|
+
const fresh = { reads: [] };
|
|
1214
|
+
ledger.entities.set(entity, fresh);
|
|
1215
|
+
return fresh;
|
|
1216
|
+
};
|
|
1217
|
+
const ahead = [];
|
|
1218
|
+
for (const entity of reads) {
|
|
1219
|
+
const state = stateOf(entity);
|
|
1220
|
+
if (state.write)
|
|
1221
|
+
ahead.push(state.write);
|
|
1222
|
+
state.reads.push(own.promise);
|
|
1223
|
+
}
|
|
1224
|
+
for (const entity of writes) {
|
|
1225
|
+
const state = stateOf(entity);
|
|
1226
|
+
if (state.write)
|
|
1227
|
+
ahead.push(state.write);
|
|
1228
|
+
ahead.push(...state.reads);
|
|
1229
|
+
state.write = own.promise;
|
|
1230
|
+
state.reads = [];
|
|
1231
|
+
}
|
|
1232
|
+
const entry = { refused, ahead, settle: () => own.resolve() };
|
|
1233
|
+
ledger.calls.set(toolCallId, entry);
|
|
1234
|
+
return entry;
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
function isPromiseLike(value) {
|
|
1238
|
+
return (typeof value === "object" || typeof value === "function") && value !== null && typeof Reflect.get(value, "then") === "function";
|
|
1239
|
+
}
|
|
1240
|
+
function settleOnDecision(entry, produce, skipsExecute) {
|
|
1241
|
+
let result;
|
|
1242
|
+
try {
|
|
1243
|
+
result = produce();
|
|
1244
|
+
} catch (error) {
|
|
1245
|
+
entry.settle();
|
|
1246
|
+
throw error;
|
|
1247
|
+
}
|
|
1248
|
+
if (isPromiseLike(result)) {
|
|
1249
|
+
return Promise.resolve(result).then((value) => {
|
|
1250
|
+
if (skipsExecute(value))
|
|
1251
|
+
entry.settle();
|
|
1252
|
+
return value;
|
|
1253
|
+
}, (error) => {
|
|
1254
|
+
entry.settle();
|
|
1255
|
+
throw error;
|
|
1256
|
+
});
|
|
1257
|
+
}
|
|
1258
|
+
if (skipsExecute(result))
|
|
1259
|
+
entry.settle();
|
|
1260
|
+
return result;
|
|
1261
|
+
}
|
|
1262
|
+
function approvalSkipsExecute(decision) {
|
|
1263
|
+
if (decision === undefined)
|
|
1264
|
+
return false;
|
|
1265
|
+
const status = typeof decision === "object" && decision !== null && "type" in decision ? Reflect.get(decision, "type") : decision;
|
|
1266
|
+
return status !== "approved" && status !== "not-applicable";
|
|
1267
|
+
}
|
|
1268
|
+
var callLimitRefusal = (limit) => new AgentToolError2({
|
|
1269
|
+
code: "STEP_TOOL_CALL_LIMIT",
|
|
1270
|
+
message: `Refused: a step may make at most ${limit} tool calls; make the rest in the next step`
|
|
1271
|
+
});
|
|
1272
|
+
function applyStepBarriers(tools, toolApproval, barriers) {
|
|
1273
|
+
if (!barriers || barriers.maxToolCallsPerStep === undefined && !barriers.toolDependencies)
|
|
1274
|
+
return { tools, toolApproval };
|
|
1275
|
+
const enter = createStepLedger(barriers);
|
|
1276
|
+
const limit = barriers.maxToolCallsPerStep;
|
|
1277
|
+
const executableTools = new Set;
|
|
1278
|
+
const wrapped = mapObjectTypeBoundary(tools, (name, tool) => {
|
|
1279
|
+
const toolName = String(name);
|
|
1280
|
+
const execute = tool.execute;
|
|
1281
|
+
if (typeof execute !== "function")
|
|
1282
|
+
return tool;
|
|
1283
|
+
executableTools.add(toolName);
|
|
1284
|
+
const { onInputAvailable, needsApproval } = tool;
|
|
1285
|
+
const settled = (entry, result) => {
|
|
1286
|
+
if (isAsyncIterable(result))
|
|
1287
|
+
return async function* () {
|
|
1288
|
+
try {
|
|
1289
|
+
yield* result;
|
|
1290
|
+
} finally {
|
|
1291
|
+
entry.settle();
|
|
1292
|
+
}
|
|
1293
|
+
}();
|
|
1294
|
+
return Promise.resolve(result).then(finalOutput).finally(entry.settle);
|
|
1295
|
+
};
|
|
1296
|
+
return {
|
|
1297
|
+
...tool,
|
|
1298
|
+
onInputAvailable: async (options) => {
|
|
1299
|
+
const entry = enter(options.messages, options.toolCallId, toolName, options.input);
|
|
1300
|
+
if (!onInputAvailable)
|
|
1301
|
+
return;
|
|
1302
|
+
try {
|
|
1303
|
+
await onInputAvailable.call(tool, options);
|
|
1304
|
+
} catch (error) {
|
|
1305
|
+
entry.settle();
|
|
1306
|
+
throw error;
|
|
1307
|
+
}
|
|
1308
|
+
},
|
|
1309
|
+
...needsApproval !== undefined && {
|
|
1310
|
+
needsApproval: (input, options) => {
|
|
1311
|
+
const entry = enter(options.messages, options.toolCallId, toolName, input);
|
|
1312
|
+
if (entry.refused)
|
|
1313
|
+
return false;
|
|
1314
|
+
return settleOnDecision(entry, () => typeof needsApproval === "function" ? needsApproval.call(tool, input, options) : needsApproval, (value) => Boolean(value));
|
|
1315
|
+
}
|
|
1316
|
+
},
|
|
1317
|
+
execute: (input, options) => {
|
|
1318
|
+
const entry = enter(options.messages, options.toolCallId, toolName, input);
|
|
1319
|
+
if (entry.refused) {
|
|
1320
|
+
entry.settle();
|
|
1321
|
+
throw callLimitRefusal(limit);
|
|
1322
|
+
}
|
|
1323
|
+
if (entry.ahead.length === 0) {
|
|
1324
|
+
try {
|
|
1325
|
+
return settled(entry, execute.call(tool, input, options));
|
|
1326
|
+
} catch (error) {
|
|
1327
|
+
entry.settle();
|
|
1328
|
+
throw error;
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
const waitAhead = () => {
|
|
1332
|
+
const all = Promise.all(entry.ahead);
|
|
1333
|
+
return options.abortSignal ? raceAbort(all, options.abortSignal) : all;
|
|
1334
|
+
};
|
|
1335
|
+
const start = () => waitAhead().then(() => execute.call(tool, input, options));
|
|
1336
|
+
if (isAsyncGeneratorFunction(execute))
|
|
1337
|
+
return async function* () {
|
|
1338
|
+
try {
|
|
1339
|
+
const result = await start();
|
|
1340
|
+
if (isAsyncIterable(result))
|
|
1341
|
+
yield* result;
|
|
1342
|
+
} finally {
|
|
1343
|
+
entry.settle();
|
|
1344
|
+
}
|
|
1345
|
+
}();
|
|
1346
|
+
return Promise.resolve().then(start).then(finalOutput).finally(entry.settle);
|
|
1347
|
+
}
|
|
1348
|
+
};
|
|
1349
|
+
});
|
|
1350
|
+
carryDeferredToolCatalog(tools, wrapped);
|
|
1351
|
+
return { tools: wrapped, toolApproval: boundApproval(toolApproval, enter, executableTools) };
|
|
1352
|
+
}
|
|
1353
|
+
function boundApproval(approval, enter, executableTools) {
|
|
1354
|
+
if (approval === undefined)
|
|
1355
|
+
return;
|
|
1356
|
+
if (typeof approval === "function")
|
|
1357
|
+
return (options) => {
|
|
1358
|
+
if (!executableTools.has(options.toolCall.toolName) || options.toolCall.providerExecuted === true) {
|
|
1359
|
+
return approval(options);
|
|
1360
|
+
}
|
|
1361
|
+
const entry = enter(options.messages, options.toolCall.toolCallId, options.toolCall.toolName, options.toolCall.input);
|
|
1362
|
+
if (entry.refused)
|
|
1363
|
+
return "not-applicable";
|
|
1364
|
+
return settleOnDecision(entry, () => approval(options), approvalSkipsExecute);
|
|
1365
|
+
};
|
|
1366
|
+
return mapObjectTypeBoundary(approval, (name, decide) => {
|
|
1367
|
+
const toolName = String(name);
|
|
1368
|
+
if (!executableTools.has(toolName) || decide === undefined)
|
|
1369
|
+
return decide;
|
|
1370
|
+
return (input, options) => {
|
|
1371
|
+
const entry = enter(options.messages, options.toolCallId, toolName, input);
|
|
1372
|
+
if (entry.refused)
|
|
1373
|
+
return "not-applicable";
|
|
1374
|
+
return settleOnDecision(entry, () => typeof decide === "function" ? Reflect.apply(decide, undefined, [input, options]) : decide, approvalSkipsExecute);
|
|
1375
|
+
};
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
1378
|
+
function createToolDependencyResolver2(input) {
|
|
1379
|
+
const effects = new Map;
|
|
1380
|
+
for (const contract of input.contracts ?? []) {
|
|
1381
|
+
const byEndpoint = contractOperationEffects2(contract);
|
|
1382
|
+
for (const entry of listContractToolNames2([contract])) {
|
|
1383
|
+
const effect = byEndpoint[entry.method];
|
|
1384
|
+
if (effect !== undefined)
|
|
1385
|
+
effects.set(entry.name, effect);
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
for (const [toolName, effect] of Object.entries(input.effects ?? {})) {
|
|
1389
|
+
if (effects.has(toolName))
|
|
1390
|
+
throw new RangeError(`Tool "${toolName}" already has the effect of its contract endpoint`);
|
|
1391
|
+
effects.set(toolName, effect);
|
|
1392
|
+
}
|
|
1393
|
+
return ({ toolName, input: callInput }) => {
|
|
1394
|
+
const effect = effects.get(toolName);
|
|
1395
|
+
const entity = effect && input.entityOf(toolName, callInput);
|
|
1396
|
+
if (entity === undefined || effect === undefined)
|
|
1397
|
+
return;
|
|
1398
|
+
return effect === "write" ? { writes: [entity] } : { reads: [entity] };
|
|
1399
|
+
};
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1932
1402
|
// src/agent-runtime/runtime-control.ts
|
|
1933
1403
|
async function interruptAgentRun(state, input) {
|
|
1934
1404
|
const { store } = state.config;
|
|
@@ -2042,15 +1512,7 @@ function createRuntimeAdmissionGate() {
|
|
|
2042
1512
|
await settled;
|
|
2043
1513
|
return 0;
|
|
2044
1514
|
}
|
|
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);
|
|
1515
|
+
await withDeadline(settled, budgetMs);
|
|
2054
1516
|
return stranded;
|
|
2055
1517
|
};
|
|
2056
1518
|
return { closed: false, begin, drain };
|
|
@@ -2340,83 +1802,8 @@ function createAgentInjectionRegistry() {
|
|
|
2340
1802
|
};
|
|
2341
1803
|
}
|
|
2342
1804
|
|
|
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
1805
|
// src/agent-runtime/run-operation-lifecycle.ts
|
|
2419
|
-
import { wrapLanguageModel
|
|
1806
|
+
import { wrapLanguageModel } from "ai";
|
|
2420
1807
|
function createAgentRunOperationLifecycle(config) {
|
|
2421
1808
|
let active;
|
|
2422
1809
|
let providerCallId;
|
|
@@ -2468,7 +1855,7 @@ function createAgentRunOperationLifecycle(config) {
|
|
|
2468
1855
|
await startModelRequest(fallbackCallId, step);
|
|
2469
1856
|
return model;
|
|
2470
1857
|
}
|
|
2471
|
-
return
|
|
1858
|
+
return wrapLanguageModel({
|
|
2472
1859
|
model,
|
|
2473
1860
|
middleware: {
|
|
2474
1861
|
specificationVersion: "v4",
|
|
@@ -2606,6 +1993,7 @@ async function acquireRun(dependencies, input) {
|
|
|
2606
1993
|
usage: input.acceptedRun.usage,
|
|
2607
1994
|
sawProviderFinish: false,
|
|
2608
1995
|
step: 0,
|
|
1996
|
+
stepGuard: { text: "", toolFailed: false, reasoningChars: 0 },
|
|
2609
1997
|
selectedModel: undefined,
|
|
2610
1998
|
internalCause: undefined,
|
|
2611
1999
|
providerStreamCleanupFailure: undefined,
|
|
@@ -2684,6 +2072,8 @@ function failureThisRuntimeOwns(error) {
|
|
|
2684
2072
|
return "context_overflow";
|
|
2685
2073
|
if (error instanceof AgentRuntimeConflictError2)
|
|
2686
2074
|
return "storage_conflict";
|
|
2075
|
+
if (error instanceof AgentStepBarrierError2)
|
|
2076
|
+
return "policy_stop";
|
|
2687
2077
|
if (isOwnInputRefusal(error))
|
|
2688
2078
|
return "runtime_failure";
|
|
2689
2079
|
return;
|
|
@@ -2744,16 +2134,8 @@ import {
|
|
|
2744
2134
|
// src/agent-runtime/owned-provider-stream.ts
|
|
2745
2135
|
var DEFAULT_CLEANUP_TIMEOUT_MS = 1000;
|
|
2746
2136
|
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
|
-
}
|
|
2137
|
+
if (!(await withDeadline(operation, timeoutMs)).settled)
|
|
2138
|
+
throw new Error(`Provider stream cleanup exceeded ${timeoutMs} ms`);
|
|
2757
2139
|
}
|
|
2758
2140
|
async function* ownedProviderStream(input) {
|
|
2759
2141
|
const iterator = input.stream[Symbol.asyncIterator]();
|
|
@@ -2783,14 +2165,14 @@ async function* ownedProviderStream(input) {
|
|
|
2783
2165
|
}
|
|
2784
2166
|
|
|
2785
2167
|
// src/agent-runtime/run-provider-ledger.ts
|
|
2786
|
-
import { createHash
|
|
2168
|
+
import { createHash } from "node:crypto";
|
|
2787
2169
|
function withoutBinaryParts(message) {
|
|
2788
2170
|
const reference = (value) => {
|
|
2789
2171
|
if (value instanceof Uint8Array || value instanceof ArrayBuffer) {
|
|
2790
2172
|
const bytes = value instanceof ArrayBuffer ? new Uint8Array(value) : value;
|
|
2791
2173
|
return {
|
|
2792
2174
|
binary: true,
|
|
2793
|
-
sha256:
|
|
2175
|
+
sha256: createHash("sha256").update(bytes).digest("hex"),
|
|
2794
2176
|
bytes: bytes.byteLength
|
|
2795
2177
|
};
|
|
2796
2178
|
}
|
|
@@ -2845,7 +2227,7 @@ async function createRunProviderLedger(input) {
|
|
|
2845
2227
|
const messageShas = [];
|
|
2846
2228
|
for (const message of request.messages) {
|
|
2847
2229
|
const body = canonicalAgentJson2(JSON.parse(JSON.stringify(withoutBinaryParts(message))));
|
|
2848
|
-
const sha256 =
|
|
2230
|
+
const sha256 = createHash("sha256").update(body).digest("hex");
|
|
2849
2231
|
messageShas.push(sha256);
|
|
2850
2232
|
if (knownMessageShas.has(sha256))
|
|
2851
2233
|
continue;
|
|
@@ -2856,8 +2238,8 @@ async function createRunProviderLedger(input) {
|
|
|
2856
2238
|
});
|
|
2857
2239
|
knownMessageShas.add(sha256);
|
|
2858
2240
|
}
|
|
2859
|
-
const instructionsSha256 =
|
|
2860
|
-
const bodySha256 =
|
|
2241
|
+
const instructionsSha256 = createHash("sha256").update(typeof request.instructions === "string" ? request.instructions : canonicalAgentJson2(JSON.parse(JSON.stringify(withoutBinaryParts(request.instructions))))).digest("hex");
|
|
2242
|
+
const bodySha256 = createHash("sha256").update(instructionsSha256).update(messageShas.join(",")).digest("hex");
|
|
2861
2243
|
await store.appendEvent({
|
|
2862
2244
|
conversationId: state.run.conversationId,
|
|
2863
2245
|
kind: "provider/request",
|
|
@@ -2883,7 +2265,8 @@ async function createRunProviderLedger(input) {
|
|
|
2883
2265
|
runId: state.run.id,
|
|
2884
2266
|
attempt: response.attempt,
|
|
2885
2267
|
stepNumber: response.stepNumber,
|
|
2886
|
-
response: identity
|
|
2268
|
+
response: identity,
|
|
2269
|
+
usage: response.usage
|
|
2887
2270
|
})
|
|
2888
2271
|
});
|
|
2889
2272
|
return identity;
|
|
@@ -2904,11 +2287,14 @@ function transientHead(execution) {
|
|
|
2904
2287
|
function isOutputPart(part) {
|
|
2905
2288
|
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
2289
|
}
|
|
2907
|
-
var
|
|
2290
|
+
var TOOL_STATUS_PARTS = [
|
|
2908
2291
|
"tool-call",
|
|
2909
2292
|
"tool-result",
|
|
2910
2293
|
"tool-error",
|
|
2911
|
-
"tool-output-denied"
|
|
2294
|
+
"tool-output-denied"
|
|
2295
|
+
];
|
|
2296
|
+
var STRUCTURAL_BOUNDARY_PARTS = [
|
|
2297
|
+
...TOOL_STATUS_PARTS,
|
|
2912
2298
|
"tool-approval-request",
|
|
2913
2299
|
"tool-approval-response",
|
|
2914
2300
|
"finish-step"
|
|
@@ -2916,7 +2302,10 @@ var STRUCTURAL_BOUNDARY_PARTS = [
|
|
|
2916
2302
|
async function applyTextPart(execution, part) {
|
|
2917
2303
|
const { publish, now } = execution.dependencies;
|
|
2918
2304
|
const { state } = execution;
|
|
2919
|
-
|
|
2305
|
+
const barriers = execution.dependencies.config.loop?.stepBarriers;
|
|
2306
|
+
if (part.type === "text-delta" && barriers?.stepText === "after-tools") {
|
|
2307
|
+
state.stepGuard.text += part.text;
|
|
2308
|
+
} else if (part.type === "text-delta") {
|
|
2920
2309
|
appendText(state.parts, part.text);
|
|
2921
2310
|
await publish({
|
|
2922
2311
|
type: "assistant-delta",
|
|
@@ -2935,6 +2324,12 @@ async function applyTextPart(execution, part) {
|
|
|
2935
2324
|
emittedAt: now().toISOString()
|
|
2936
2325
|
});
|
|
2937
2326
|
} else if (part.type === "reasoning-delta") {
|
|
2327
|
+
const limit = barriers?.maxReasoningCharsPerStep;
|
|
2328
|
+
state.stepGuard.reasoningChars += part.text.length;
|
|
2329
|
+
if (limit !== undefined && state.stepGuard.reasoningChars > limit) {
|
|
2330
|
+
state.terminalPolicyName = "stepBarriers.maxReasoningCharsPerStep";
|
|
2331
|
+
throw new AgentStepBarrierError2("reasoning", `A step reasoned past its bound of ${limit} characters`);
|
|
2332
|
+
}
|
|
2938
2333
|
updateReasoning(state, part.text, part.providerMetadata);
|
|
2939
2334
|
const provider = providerEnvelope(part.providerMetadata);
|
|
2940
2335
|
await publish({
|
|
@@ -2957,7 +2352,6 @@ async function applyTextPart(execution, part) {
|
|
|
2957
2352
|
}
|
|
2958
2353
|
}
|
|
2959
2354
|
async function applyToolPart(execution, part) {
|
|
2960
|
-
const { publish, now } = execution.dependencies;
|
|
2961
2355
|
const { state } = execution;
|
|
2962
2356
|
if (part.type === "tool-call") {
|
|
2963
2357
|
const provider = providerEnvelope(part.providerMetadata);
|
|
@@ -2968,16 +2362,15 @@ async function applyToolPart(execution, part) {
|
|
|
2968
2362
|
input: jsonValue(part.input),
|
|
2969
2363
|
...provider && { provider }
|
|
2970
2364
|
}));
|
|
2971
|
-
await
|
|
2972
|
-
type: "tool-status",
|
|
2973
|
-
...transientHead(execution),
|
|
2365
|
+
await checkpoint(execution, {
|
|
2974
2366
|
callId: part.toolCallId,
|
|
2975
2367
|
toolName: part.toolName,
|
|
2976
2368
|
status: "started",
|
|
2977
|
-
input: jsonValue(part.input)
|
|
2978
|
-
emittedAt: now().toISOString()
|
|
2369
|
+
input: jsonValue(part.input)
|
|
2979
2370
|
});
|
|
2980
2371
|
} else if (part.type === "tool-result") {
|
|
2372
|
+
if (part.preliminary === true)
|
|
2373
|
+
return;
|
|
2981
2374
|
state.settledToolCalls.add(part.toolCallId);
|
|
2982
2375
|
state.parts.push(AgentMessagePartSchema2.parse({
|
|
2983
2376
|
type: "tool-result",
|
|
@@ -2986,30 +2379,24 @@ async function applyToolPart(execution, part) {
|
|
|
2986
2379
|
outcome: "success",
|
|
2987
2380
|
output: jsonValue(part.output)
|
|
2988
2381
|
}));
|
|
2989
|
-
await
|
|
2990
|
-
type: "tool-status",
|
|
2991
|
-
...transientHead(execution),
|
|
2382
|
+
await checkpoint(execution, {
|
|
2992
2383
|
callId: part.toolCallId,
|
|
2993
2384
|
toolName: part.toolName,
|
|
2994
2385
|
status: "completed",
|
|
2995
|
-
output: jsonValue(part.output)
|
|
2996
|
-
emittedAt: now().toISOString()
|
|
2386
|
+
output: jsonValue(part.output)
|
|
2997
2387
|
});
|
|
2998
2388
|
} else if (part.type === "tool-error") {
|
|
2999
2389
|
state.settledToolCalls.add(part.toolCallId);
|
|
3000
2390
|
state.internalCause = part.error;
|
|
3001
2391
|
if (isToolExecutionControlError2(part.error)) {
|
|
3002
|
-
await
|
|
3003
|
-
type: "tool-status",
|
|
3004
|
-
...transientHead(execution),
|
|
2392
|
+
await checkpoint(execution, {
|
|
3005
2393
|
callId: part.toolCallId,
|
|
3006
2394
|
toolName: part.toolName,
|
|
3007
|
-
status: "interrupted"
|
|
3008
|
-
emittedAt: now().toISOString()
|
|
2395
|
+
status: "interrupted"
|
|
3009
2396
|
});
|
|
3010
|
-
await checkpoint(execution);
|
|
3011
2397
|
throw part.error;
|
|
3012
2398
|
}
|
|
2399
|
+
state.stepGuard.toolFailed = true;
|
|
3013
2400
|
const output = isAgentToolError2(part.error) ? jsonValue(part.error.output) : { message: "Tool execution failed" };
|
|
3014
2401
|
state.parts.push(AgentMessagePartSchema2.parse({
|
|
3015
2402
|
type: "tool-result",
|
|
@@ -3018,17 +2405,15 @@ async function applyToolPart(execution, part) {
|
|
|
3018
2405
|
outcome: "error",
|
|
3019
2406
|
output
|
|
3020
2407
|
}));
|
|
3021
|
-
await
|
|
3022
|
-
type: "tool-status",
|
|
3023
|
-
...transientHead(execution),
|
|
2408
|
+
await checkpoint(execution, {
|
|
3024
2409
|
callId: part.toolCallId,
|
|
3025
2410
|
toolName: part.toolName,
|
|
3026
2411
|
status: "failed",
|
|
3027
|
-
output
|
|
3028
|
-
emittedAt: now().toISOString()
|
|
2412
|
+
output
|
|
3029
2413
|
});
|
|
3030
2414
|
} else if (part.type === "tool-output-denied") {
|
|
3031
2415
|
state.settledToolCalls.add(part.toolCallId);
|
|
2416
|
+
state.stepGuard.toolFailed = true;
|
|
3032
2417
|
state.parts.push(AgentMessagePartSchema2.parse({
|
|
3033
2418
|
type: "tool-result",
|
|
3034
2419
|
callId: part.toolCallId,
|
|
@@ -3036,14 +2421,11 @@ async function applyToolPart(execution, part) {
|
|
|
3036
2421
|
outcome: "error",
|
|
3037
2422
|
output: { message: "Tool output denied" }
|
|
3038
2423
|
}));
|
|
3039
|
-
await
|
|
3040
|
-
type: "tool-status",
|
|
3041
|
-
...transientHead(execution),
|
|
2424
|
+
await checkpoint(execution, {
|
|
3042
2425
|
callId: part.toolCallId,
|
|
3043
2426
|
toolName: part.toolName,
|
|
3044
2427
|
status: "failed",
|
|
3045
|
-
output: { message: "Tool output denied" }
|
|
3046
|
-
emittedAt: now().toISOString()
|
|
2428
|
+
output: { message: "Tool output denied" }
|
|
3047
2429
|
});
|
|
3048
2430
|
}
|
|
3049
2431
|
}
|
|
@@ -3116,40 +2498,34 @@ async function applyRecordedPart(execution, part) {
|
|
|
3116
2498
|
async function applyFinishStep(execution, scope, part) {
|
|
3117
2499
|
if (part.type !== "finish-step")
|
|
3118
2500
|
return;
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
2501
|
+
await releaseStepText(execution);
|
|
2502
|
+
await recordStepSpend(execution, {
|
|
2503
|
+
phase: "step",
|
|
2504
|
+
part,
|
|
2505
|
+
attempt: scope.providerAttempt,
|
|
2506
|
+
selectedModel: scope.selectedModel,
|
|
2507
|
+
ledger: scope.ledger
|
|
3126
2508
|
});
|
|
3127
2509
|
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,
|
|
2510
|
+
execution.state.step += 1;
|
|
2511
|
+
}
|
|
2512
|
+
async function releaseStepText(execution) {
|
|
2513
|
+
const { state } = execution;
|
|
2514
|
+
const { text, toolFailed } = state.stepGuard;
|
|
2515
|
+
state.stepGuard = { text: "", toolFailed: false, reasoningChars: 0 };
|
|
2516
|
+
if (text.length === 0 || toolFailed)
|
|
2517
|
+
return;
|
|
2518
|
+
appendText(state.parts, text);
|
|
2519
|
+
if (state.firstOutputAt === undefined)
|
|
2520
|
+
state.firstOutputAt = performance.now();
|
|
2521
|
+
await execution.operationLifecycle.firstOutput();
|
|
2522
|
+
const { publish, now } = execution.dependencies;
|
|
2523
|
+
await publish({
|
|
2524
|
+
type: "assistant-delta",
|
|
2525
|
+
...transientHead(execution),
|
|
2526
|
+
textDelta: text,
|
|
3150
2527
|
emittedAt: now().toISOString()
|
|
3151
2528
|
});
|
|
3152
|
-
state.step += 1;
|
|
3153
2529
|
}
|
|
3154
2530
|
async function applyStreamPart(execution, scope, part) {
|
|
3155
2531
|
const { state } = execution;
|
|
@@ -3182,6 +2558,9 @@ async function applyStreamPart(execution, scope, part) {
|
|
|
3182
2558
|
state.terminalReason = failureThisRuntimeOwns(part.error) ?? "provider_failure";
|
|
3183
2559
|
state.internalCause = part.error;
|
|
3184
2560
|
break;
|
|
2561
|
+
case "start-step":
|
|
2562
|
+
state.stepGuard = { text: "", toolFailed: false, reasoningChars: 0 };
|
|
2563
|
+
break;
|
|
3185
2564
|
case "finish-step":
|
|
3186
2565
|
await applyFinishStep(execution, scope, part);
|
|
3187
2566
|
break;
|
|
@@ -3194,12 +2573,12 @@ async function applyStreamPart(execution, scope, part) {
|
|
|
3194
2573
|
}
|
|
3195
2574
|
state.sawProviderFinish = true;
|
|
3196
2575
|
state.modelUsage = mergeModelTotals(normalizeSdkUsage(part.totalUsage), state.modelUsage);
|
|
3197
|
-
state.usage =
|
|
2576
|
+
state.usage = runUsage(state);
|
|
3198
2577
|
break;
|
|
3199
2578
|
}
|
|
3200
2579
|
}
|
|
3201
2580
|
|
|
3202
|
-
// src/agent-runtime/tool-progress.ts
|
|
2581
|
+
// src/agent-runtime/run-tool-progress.ts
|
|
3203
2582
|
var TOOL_PROGRESS_MIN_INTERVAL_MS = 250;
|
|
3204
2583
|
function finite(value) {
|
|
3205
2584
|
return value !== undefined && Number.isFinite(value) ? value : undefined;
|
|
@@ -3275,10 +2654,7 @@ async function prepareAttemptStep(context, attempt, options) {
|
|
|
3275
2654
|
const { state } = execution;
|
|
3276
2655
|
const previousStep = options.steps.at(-1);
|
|
3277
2656
|
if (previousStep) {
|
|
3278
|
-
state.lastPromptTokens = state.selectedModel
|
|
3279
|
-
usage: previousStep.usage,
|
|
3280
|
-
providerMetadata: previousStep.providerMetadata
|
|
3281
|
-
})?.inputTokens ?? normalizeSdkUsage(previousStep.usage).inputTokens;
|
|
2657
|
+
state.lastPromptTokens = normalizeStepUsage(state.selectedModel, previousStep.usage, previousStep.providerMetadata).inputTokens;
|
|
3282
2658
|
}
|
|
3283
2659
|
const prepared = await config.loop?.prepareStep?.({
|
|
3284
2660
|
...options,
|
|
@@ -3324,15 +2700,11 @@ function runToolDurability(context, toolName, toolCallId, signal) {
|
|
|
3324
2700
|
signal
|
|
3325
2701
|
});
|
|
3326
2702
|
}
|
|
3327
|
-
function startAttemptStream(context, attempt, stopConditions) {
|
|
2703
|
+
function startAttemptStream(context, attempt, stopConditions, attemptSignal) {
|
|
3328
2704
|
const { execution, turn } = context;
|
|
3329
2705
|
const { config } = execution.dependencies;
|
|
3330
2706
|
const { idleDeadline, operationLifecycle } = execution;
|
|
3331
2707
|
const { tools } = turn;
|
|
3332
|
-
const attemptSignal = AbortSignal.any([
|
|
3333
|
-
execution.executionSignal,
|
|
3334
|
-
attempt.attemptAbort.signal
|
|
3335
|
-
]);
|
|
3336
2708
|
return streamAgentTextBoundary({
|
|
3337
2709
|
model: turn.selectedModel.model,
|
|
3338
2710
|
tools,
|
|
@@ -3358,8 +2730,8 @@ function startAttemptStream(context, attempt, stopConditions) {
|
|
|
3358
2730
|
onToolExecutionStart: () => idleDeadline.suspend(),
|
|
3359
2731
|
onToolExecutionEnd: () => idleDeadline.resume(),
|
|
3360
2732
|
repairToolCall: deferredToolRepair(config.loop?.prepareStep),
|
|
3361
|
-
...
|
|
3362
|
-
toolApproval:
|
|
2733
|
+
...turn.toolApproval && {
|
|
2734
|
+
toolApproval: turn.toolApproval,
|
|
3363
2735
|
runtimeContext: execution.input.context
|
|
3364
2736
|
},
|
|
3365
2737
|
...config.loop?.toolApprovalSecret && {
|
|
@@ -3371,20 +2743,13 @@ function startAttemptStream(context, attempt, stopConditions) {
|
|
|
3371
2743
|
async function drainAbandonedPart(context, attempt, part) {
|
|
3372
2744
|
if (part.type !== "finish-step")
|
|
3373
2745
|
return;
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
2746
|
+
await recordStepSpend(context.execution, {
|
|
2747
|
+
phase: "abandoned-attempt",
|
|
2748
|
+
part,
|
|
2749
|
+
attempt: attempt.providerAttempt,
|
|
2750
|
+
selectedModel: context.turn.selectedModel,
|
|
2751
|
+
ledger: context.ledger
|
|
3380
2752
|
});
|
|
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
2753
|
}
|
|
3389
2754
|
async function retryAfterProviderError(context, attempt, error) {
|
|
3390
2755
|
const { execution, loop } = context;
|
|
@@ -3457,12 +2822,17 @@ async function consumeAttempt(context, attempt, stream) {
|
|
|
3457
2822
|
if (part.type === "error" && await retryAfterProviderError(context, attempt, part.error)) {
|
|
3458
2823
|
continue;
|
|
3459
2824
|
}
|
|
3460
|
-
|
|
2825
|
+
const held = part.type === "text-delta" && context.execution.dependencies.config.loop?.stepBarriers?.stepText === "after-tools";
|
|
2826
|
+
if (isOutputPart(part) && !held) {
|
|
3461
2827
|
if (state.firstOutputAt === undefined)
|
|
3462
2828
|
state.firstOutputAt = performance.now();
|
|
3463
2829
|
await operationLifecycle.firstOutput();
|
|
3464
2830
|
}
|
|
3465
2831
|
await applyStreamPart(execution, scope, part);
|
|
2832
|
+
if (TOOL_STATUS_PARTS.includes(part.type)) {
|
|
2833
|
+
state.eventsSinceCheckpoint = 0;
|
|
2834
|
+
continue;
|
|
2835
|
+
}
|
|
3466
2836
|
const structuralBoundary = STRUCTURAL_BOUNDARY_PARTS.includes(part.type);
|
|
3467
2837
|
if (structuralBoundary || state.eventsSinceCheckpoint >= checkpointEveryEvents) {
|
|
3468
2838
|
await checkpoint(execution);
|
|
@@ -3496,10 +2866,16 @@ async function runModelAttempts(execution, turn) {
|
|
|
3496
2866
|
draining: false,
|
|
3497
2867
|
attemptAbort: new AbortController
|
|
3498
2868
|
};
|
|
3499
|
-
const
|
|
3500
|
-
|
|
2869
|
+
const link = linkAbortSignals(execution.executionSignal, attempt.attemptAbort.signal);
|
|
2870
|
+
try {
|
|
2871
|
+
const result = startAttemptStream(context, attempt, stopConditions, link.signal);
|
|
2872
|
+
await consumeAttempt(context, attempt, result.stream);
|
|
2873
|
+
} finally {
|
|
2874
|
+
link.release();
|
|
2875
|
+
}
|
|
3501
2876
|
if (!attempt.retrying)
|
|
3502
2877
|
break;
|
|
2878
|
+
state.stepGuard = { text: "", toolFailed: false, reasoningChars: 0 };
|
|
3503
2879
|
await publish({
|
|
3504
2880
|
type: "attempt-reset",
|
|
3505
2881
|
conversationId: state.run.conversationId,
|
|
@@ -3670,10 +3046,10 @@ async function commitRunTerminal(execution) {
|
|
|
3670
3046
|
}
|
|
3671
3047
|
|
|
3672
3048
|
// src/agent-runtime/run-prompt-history.ts
|
|
3673
|
-
import { createHash as
|
|
3049
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
3674
3050
|
|
|
3675
3051
|
// src/agent-runtime/state-slots.ts
|
|
3676
|
-
import { z as
|
|
3052
|
+
import { z as z4 } from "zod";
|
|
3677
3053
|
function defineStateSlot2(input) {
|
|
3678
3054
|
if (input.name.length === 0)
|
|
3679
3055
|
throw new TypeError("State slot name must not be empty");
|
|
@@ -3688,11 +3064,11 @@ function defineStateSlot2(input) {
|
|
|
3688
3064
|
...input.description && { description: input.description }
|
|
3689
3065
|
};
|
|
3690
3066
|
}
|
|
3691
|
-
var StateSetPayloadSchema =
|
|
3692
|
-
name:
|
|
3693
|
-
version:
|
|
3694
|
-
value:
|
|
3695
|
-
actor:
|
|
3067
|
+
var StateSetPayloadSchema = z4.object({
|
|
3068
|
+
name: z4.string().min(1),
|
|
3069
|
+
version: z4.int().positive(),
|
|
3070
|
+
value: z4.json(),
|
|
3071
|
+
actor: z4.enum(["agent", "human", "system"])
|
|
3696
3072
|
}).strict();
|
|
3697
3073
|
function slotRegistry(definitions) {
|
|
3698
3074
|
const result = new Map;
|
|
@@ -3774,18 +3150,18 @@ function renderAgentStateSlots2(values) {
|
|
|
3774
3150
|
var agentGoalStateSlot2 = defineStateSlot2({
|
|
3775
3151
|
name: "goal",
|
|
3776
3152
|
description: "The durable objective and lifecycle of this conversation.",
|
|
3777
|
-
schema:
|
|
3778
|
-
objective:
|
|
3779
|
-
status:
|
|
3153
|
+
schema: z4.object({
|
|
3154
|
+
objective: z4.string().min(1),
|
|
3155
|
+
status: z4.enum(["active", "complete", "blocked"])
|
|
3780
3156
|
}).strict()
|
|
3781
3157
|
});
|
|
3782
3158
|
var agentTodoStateSlot2 = defineStateSlot2({
|
|
3783
3159
|
name: "todo",
|
|
3784
3160
|
description: "The durable ordered work plan for this conversation.",
|
|
3785
|
-
schema:
|
|
3786
|
-
items:
|
|
3787
|
-
step:
|
|
3788
|
-
status:
|
|
3161
|
+
schema: z4.object({
|
|
3162
|
+
items: z4.array(z4.object({
|
|
3163
|
+
step: z4.string().min(1),
|
|
3164
|
+
status: z4.enum(["pending", "in_progress", "completed"])
|
|
3789
3165
|
}).strict())
|
|
3790
3166
|
}).strict()
|
|
3791
3167
|
});
|
|
@@ -3809,7 +3185,7 @@ var USER_INSTRUCTION_SEED_KEY = "prompt.user-instructions";
|
|
|
3809
3185
|
function seededInstructionMessage(input) {
|
|
3810
3186
|
return AgentMessageSchema2.parse({
|
|
3811
3187
|
schemaVersion: 1,
|
|
3812
|
-
id:
|
|
3188
|
+
id: createHash2("sha256").update(`${input.conversationId}\x00${input.seedKey}\x00${input.index}`).digest("hex"),
|
|
3813
3189
|
conversationId: input.conversationId,
|
|
3814
3190
|
role: "user",
|
|
3815
3191
|
status: "committed",
|
|
@@ -3894,8 +3270,6 @@ async function compactHistory(execution) {
|
|
|
3894
3270
|
store: config.store,
|
|
3895
3271
|
signal: executionSignal
|
|
3896
3272
|
});
|
|
3897
|
-
adoptSnapshot(state, compacted.snapshot);
|
|
3898
|
-
await operationLifecycle.finish("completed");
|
|
3899
3273
|
} catch (error) {
|
|
3900
3274
|
const latest = await config.store.loadRun({
|
|
3901
3275
|
conversationId: state.run.conversationId,
|
|
@@ -3909,10 +3283,14 @@ async function compactHistory(execution) {
|
|
|
3909
3283
|
throw error;
|
|
3910
3284
|
}
|
|
3911
3285
|
if (compacted.usage) {
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3286
|
+
await recordStepSpend(execution, {
|
|
3287
|
+
phase: "compaction",
|
|
3288
|
+
usage: compacted.usage,
|
|
3289
|
+
attempt: compacted.attempts
|
|
3290
|
+
});
|
|
3915
3291
|
}
|
|
3292
|
+
adoptSnapshot(state, compacted.snapshot);
|
|
3293
|
+
await operationLifecycle.finish("completed");
|
|
3916
3294
|
}
|
|
3917
3295
|
function createRuntimeContext(execution) {
|
|
3918
3296
|
const { runtimeEpoch, config } = execution.dependencies;
|
|
@@ -3942,9 +3320,11 @@ function createRuntimeContext(execution) {
|
|
|
3942
3320
|
...state.run.fencingToken !== undefined && { fencingToken: state.run.fencingToken }
|
|
3943
3321
|
})
|
|
3944
3322
|
});
|
|
3945
|
-
return {
|
|
3323
|
+
return issueRunContext({
|
|
3946
3324
|
context: execution.input.context,
|
|
3947
|
-
run
|
|
3325
|
+
get run() {
|
|
3326
|
+
return state.run;
|
|
3327
|
+
},
|
|
3948
3328
|
signal: executionSignal,
|
|
3949
3329
|
toolFenceLifecycle,
|
|
3950
3330
|
get contextUsage() {
|
|
@@ -3952,8 +3332,11 @@ function createRuntimeContext(execution) {
|
|
|
3952
3332
|
if (!descriptor)
|
|
3953
3333
|
return;
|
|
3954
3334
|
return { usedTokens: state.lastPromptTokens, contextWindow: descriptor.contextWindow };
|
|
3335
|
+
},
|
|
3336
|
+
get selectedModel() {
|
|
3337
|
+
return state.selectedModel;
|
|
3955
3338
|
}
|
|
3956
|
-
};
|
|
3339
|
+
});
|
|
3957
3340
|
}
|
|
3958
3341
|
async function seedUserInstructions(execution, prompt) {
|
|
3959
3342
|
const { config, now } = execution.dependencies;
|
|
@@ -3982,8 +3365,9 @@ async function seedUserInstructions(execution, prompt) {
|
|
|
3982
3365
|
async function prepareTurn(execution) {
|
|
3983
3366
|
const { config } = execution.dependencies;
|
|
3984
3367
|
const { state, executionSignal } = execution;
|
|
3985
|
-
await compactHistory(execution);
|
|
3986
3368
|
const runtimeContext = createRuntimeContext(execution);
|
|
3369
|
+
execution.runtimeContext = runtimeContext;
|
|
3370
|
+
await compactHistory(execution);
|
|
3987
3371
|
const selectedModel = await config.models.resolve({
|
|
3988
3372
|
context: execution.input.context,
|
|
3989
3373
|
conversationId: state.run.conversationId,
|
|
@@ -3992,7 +3376,7 @@ async function prepareTurn(execution) {
|
|
|
3992
3376
|
});
|
|
3993
3377
|
state.selectedModel = selectedModel;
|
|
3994
3378
|
let promptSnapshot = snapshotForRunPrompt(state.snapshot, state.run.id);
|
|
3995
|
-
const [composedPrompt,
|
|
3379
|
+
const [composedPrompt, rawTools] = await Promise.all([
|
|
3996
3380
|
config.prompt({
|
|
3997
3381
|
context: execution.input.context,
|
|
3998
3382
|
signal: executionSignal,
|
|
@@ -4002,6 +3386,7 @@ async function prepareTurn(execution) {
|
|
|
4002
3386
|
}),
|
|
4003
3387
|
config.tools(runtimeContext)
|
|
4004
3388
|
]);
|
|
3389
|
+
const { tools, toolApproval } = applyStepBarriers(rawTools, config.loop?.toolApproval, config.loop?.stepBarriers);
|
|
4005
3390
|
let prompt = composedPrompt;
|
|
4006
3391
|
const userInstructionsInserted = await seedUserInstructions(execution, prompt);
|
|
4007
3392
|
if (userInstructionsInserted !== undefined) {
|
|
@@ -4021,7 +3406,7 @@ async function prepareTurn(execution) {
|
|
|
4021
3406
|
durableSystem: await loadDurableSystem(config, state.run.conversationId)
|
|
4022
3407
|
});
|
|
4023
3408
|
const history = [...await projection.projectHistory(promptSnapshot)];
|
|
4024
|
-
return { selectedModel, runtimeContext, prompt, tools, history, projection };
|
|
3409
|
+
return { selectedModel, runtimeContext, prompt, tools, toolApproval, history, projection };
|
|
4025
3410
|
}
|
|
4026
3411
|
|
|
4027
3412
|
// src/agent-runtime/run-unacquired.ts
|
|
@@ -4118,26 +3503,33 @@ function createRunExecutor(dependencies) {
|
|
|
4118
3503
|
const { execution } = acquisition;
|
|
4119
3504
|
const runId = execution.state.run.id;
|
|
4120
3505
|
executing.add(runId);
|
|
3506
|
+
let result;
|
|
4121
3507
|
try {
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
3508
|
+
try {
|
|
3509
|
+
await beginRunExecution(execution);
|
|
3510
|
+
const invocations = dependencies.config.invocations;
|
|
3511
|
+
if (invocations) {
|
|
3512
|
+
const trace = await invocations.trace({
|
|
3513
|
+
context: input.context,
|
|
3514
|
+
conversationId: execution.state.run.conversationId,
|
|
3515
|
+
run: execution.state.run
|
|
3516
|
+
});
|
|
3517
|
+
execution.invocationTrace = trace;
|
|
3518
|
+
execution.invocation = await beginAgentInvocation(invocations.ledger, dependencies.config.store, { run: execution.state.run, trace }, input.context);
|
|
3519
|
+
}
|
|
3520
|
+
const turn = await prepareTurn(execution);
|
|
3521
|
+
await runModelAttempts(execution, turn);
|
|
3522
|
+
await settleStreamOutcome(execution);
|
|
3523
|
+
} catch (error) {
|
|
3524
|
+
await classifyRunFailure(execution, error);
|
|
3525
|
+
} finally {
|
|
3526
|
+
execution.idleDeadline.dispose();
|
|
4131
3527
|
}
|
|
4132
|
-
|
|
4133
|
-
await runModelAttempts(execution, turn);
|
|
4134
|
-
await settleStreamOutcome(execution);
|
|
4135
|
-
} catch (error) {
|
|
4136
|
-
await classifyRunFailure(execution, error);
|
|
3528
|
+
result = await commitRunTerminal(execution);
|
|
4137
3529
|
} finally {
|
|
4138
|
-
|
|
3530
|
+
executing.delete(runId);
|
|
3531
|
+
execution.idleDeadline.release();
|
|
4139
3532
|
}
|
|
4140
|
-
const result = await commitRunTerminal(execution).finally(() => executing.delete(runId));
|
|
4141
3533
|
await execution.invocation?.finish(result.reason === "success" ? "succeeded" : ["interrupted", "cancelled", "timeout", "shutdown"].includes(result.reason) ? "cancelled" : "failed");
|
|
4142
3534
|
return result;
|
|
4143
3535
|
};
|
|
@@ -4149,9 +3541,14 @@ function resolveLoopLimits(config) {
|
|
|
4149
3541
|
const maxSteps = config.loop?.maxSteps ?? 50;
|
|
4150
3542
|
const declaredIdleTimeoutMs = config.loop?.idleTimeoutMs;
|
|
4151
3543
|
const idleTimeoutMs = declaredIdleTimeoutMs === null ? undefined : declaredIdleTimeoutMs ?? 60000;
|
|
3544
|
+
const stepSpendTimeoutMs = config.stepSpendTimeoutMs ?? DEFAULT_STEP_SPEND_TIMEOUT_MS;
|
|
4152
3545
|
assertPositiveSafeInteger("checkpointEveryEvents", checkpointEveryEvents);
|
|
4153
3546
|
assertPositiveSafeInteger("maxSteps", maxSteps);
|
|
4154
|
-
|
|
3547
|
+
assertTimerMs("idleTimeoutMs", idleTimeoutMs);
|
|
3548
|
+
assertTimerMs("stepSpendTimeoutMs", stepSpendTimeoutMs);
|
|
3549
|
+
if (config.loop?.retry)
|
|
3550
|
+
assertAgentRetryPolicy("loop.retry", config.loop.retry);
|
|
3551
|
+
assertStepBarriers(config.loop?.stepBarriers);
|
|
4155
3552
|
const policyNames = new Set(["max-steps"]);
|
|
4156
3553
|
for (const policy of config.loop?.stopPolicies ?? []) {
|
|
4157
3554
|
if (!policy.name || policyNames.has(policy.name)) {
|
|
@@ -4162,7 +3559,8 @@ function resolveLoopLimits(config) {
|
|
|
4162
3559
|
return {
|
|
4163
3560
|
checkpointEveryEvents,
|
|
4164
3561
|
maxSteps,
|
|
4165
|
-
...idleTimeoutMs !== undefined && { idleTimeoutMs }
|
|
3562
|
+
...idleTimeoutMs !== undefined && { idleTimeoutMs },
|
|
3563
|
+
stepSpendTimeoutMs
|
|
4166
3564
|
};
|
|
4167
3565
|
}
|
|
4168
3566
|
function createAgentRuntimeState(config) {
|
|
@@ -4173,7 +3571,7 @@ function createAgentRuntimeState(config) {
|
|
|
4173
3571
|
const admissionLanes = createRuntimeAdmissionLanes();
|
|
4174
3572
|
const injectionPossible = typeof config.runs?.inputPolicy === "function" || config.runs?.inputPolicy === "inject";
|
|
4175
3573
|
const injection = injectionPossible ? createAgentInjectionRegistry() : undefined;
|
|
4176
|
-
const { checkpointEveryEvents, maxSteps, idleTimeoutMs } = resolveLoopLimits(config);
|
|
3574
|
+
const { checkpointEveryEvents, maxSteps, idleTimeoutMs, stepSpendTimeoutMs } = resolveLoopLimits(config);
|
|
4177
3575
|
const publish = async (event) => {
|
|
4178
3576
|
try {
|
|
4179
3577
|
await config.publish?.(event);
|
|
@@ -4192,6 +3590,7 @@ function createAgentRuntimeState(config) {
|
|
|
4192
3590
|
checkpointEveryEvents,
|
|
4193
3591
|
maxSteps,
|
|
4194
3592
|
...idleTimeoutMs !== undefined && { idleTimeoutMs },
|
|
3593
|
+
stepSpendTimeoutMs,
|
|
4195
3594
|
...injection && { injection }
|
|
4196
3595
|
});
|
|
4197
3596
|
return {
|
|
@@ -4516,4 +3915,4 @@ function createAgentRuntime2(config) {
|
|
|
4516
3915
|
};
|
|
4517
3916
|
}
|
|
4518
3917
|
|
|
4519
|
-
export {
|
|
3918
|
+
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 };
|