stitchkit 0.93.0 → 0.94.1
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 +198 -0
- package/README.md +5 -2
- package/dist/agent-runtime/children-control.d.ts +6 -0
- package/dist/agent-runtime/children-control.d.ts.map +1 -0
- package/dist/agent-runtime/children-spawn.d.ts +6 -0
- package/dist/agent-runtime/children-spawn.d.ts.map +1 -0
- package/dist/agent-runtime/children-state.d.ts +46 -0
- package/dist/agent-runtime/children-state.d.ts.map +1 -0
- package/dist/agent-runtime/children-usage.d.ts +8 -0
- package/dist/agent-runtime/children-usage.d.ts.map +1 -0
- package/dist/agent-runtime/children.d.ts +11 -14
- package/dist/agent-runtime/children.d.ts.map +1 -1
- package/dist/agent-runtime/coding-shell-process.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts +2 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-listing.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-search-patch.d.ts.map +1 -1
- package/dist/agent-runtime/contained-darwin.d.ts +38 -0
- package/dist/agent-runtime/contained-darwin.d.ts.map +1 -0
- package/dist/agent-runtime/contained-files.d.ts +11 -26
- package/dist/agent-runtime/contained-files.d.ts.map +1 -1
- package/dist/agent-runtime/contained-scan.d.ts +21 -0
- package/dist/agent-runtime/contained-scan.d.ts.map +1 -0
- package/dist/agent-runtime/contained-write.d.ts +9 -0
- package/dist/agent-runtime/contained-write.d.ts.map +1 -0
- package/dist/agent-runtime/deferred-tool-types.d.ts +4 -3
- package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
- package/dist/agent-runtime/events.d.ts +1 -1
- package/dist/agent-runtime/events.d.ts.map +1 -1
- package/dist/agent-runtime/harness-control.d.ts +0 -1
- package/dist/agent-runtime/harness-control.d.ts.map +1 -1
- package/dist/agent-runtime/harness.d.ts +0 -5
- package/dist/agent-runtime/harness.d.ts.map +1 -1
- package/dist/agent-runtime/managed-tools.d.ts +3 -2
- package/dist/agent-runtime/managed-tools.d.ts.map +1 -1
- package/dist/agent-runtime/observability.d.ts +1 -1
- package/dist/agent-runtime/observability.d.ts.map +1 -1
- package/dist/agent-runtime/openrouter.d.ts +29 -0
- package/dist/agent-runtime/openrouter.d.ts.map +1 -0
- package/dist/agent-runtime/projections.d.ts +1 -1
- package/dist/agent-runtime/projections.d.ts.map +1 -1
- package/dist/agent-runtime/run-acquisition.d.ts +17 -0
- package/dist/agent-runtime/run-acquisition.d.ts.map +1 -0
- package/dist/agent-runtime/run-execution-state.d.ts +133 -0
- package/dist/agent-runtime/run-execution-state.d.ts.map +1 -0
- package/dist/agent-runtime/run-execution.d.ts +17 -33
- package/dist/agent-runtime/run-execution.d.ts.map +1 -1
- package/dist/agent-runtime/run-failure.d.ts +18 -0
- package/dist/agent-runtime/run-failure.d.ts.map +1 -0
- package/dist/agent-runtime/run-model-attempts.d.ts +6 -0
- package/dist/agent-runtime/run-model-attempts.d.ts.map +1 -0
- package/dist/agent-runtime/run-prompt-history.d.ts +58 -0
- package/dist/agent-runtime/run-prompt-history.d.ts.map +1 -0
- package/dist/agent-runtime/run-provider-ledger.d.ts +26 -0
- package/dist/agent-runtime/run-provider-ledger.d.ts.map +1 -0
- package/dist/agent-runtime/run-stream-parts.d.ts +17 -0
- package/dist/agent-runtime/run-stream-parts.d.ts.map +1 -0
- package/dist/agent-runtime/run-terminal.d.ts +11 -0
- package/dist/agent-runtime/run-terminal.d.ts.map +1 -0
- package/dist/agent-runtime/run-turn-preparation.d.ts +22 -0
- package/dist/agent-runtime/run-turn-preparation.d.ts.map +1 -0
- package/dist/agent-runtime/runtime-admission-gate.d.ts +29 -0
- package/dist/agent-runtime/runtime-admission-gate.d.ts.map +1 -0
- package/dist/agent-runtime/runtime-control.d.ts +9 -0
- package/dist/agent-runtime/runtime-control.d.ts.map +1 -0
- package/dist/agent-runtime/runtime-recovery.d.ts +10 -0
- package/dist/agent-runtime/runtime-recovery.d.ts.map +1 -0
- package/dist/agent-runtime/runtime-state.d.ts +36 -0
- package/dist/agent-runtime/runtime-state.d.ts.map +1 -0
- package/dist/agent-runtime/runtime-submit.d.ts +5 -0
- package/dist/agent-runtime/runtime-submit.d.ts.map +1 -0
- package/dist/agent-runtime/runtime.d.ts +10 -5
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-records.d.ts +34 -0
- package/dist/agent-runtime/schedule-records.d.ts.map +1 -0
- package/dist/agent-runtime/schedules.d.ts +34 -0
- package/dist/agent-runtime/schedules.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-bun.d.ts +12 -0
- package/dist/agent-runtime/sqlite-bun.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-events.d.ts +5 -0
- package/dist/agent-runtime/sqlite-events.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-history.d.ts +7 -0
- package/dist/agent-runtime/sqlite-history.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-ledger.d.ts +7 -0
- package/dist/agent-runtime/sqlite-ledger.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-node.d.ts +12 -0
- package/dist/agent-runtime/sqlite-node.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-reads.d.ts +14 -0
- package/dist/agent-runtime/sqlite-reads.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-rows.d.ts +178 -0
- package/dist/agent-runtime/sqlite-rows.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-schema.d.ts +7 -0
- package/dist/agent-runtime/sqlite-schema.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-transactions.d.ts +25 -0
- package/dist/agent-runtime/sqlite-transactions.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite.d.ts +10 -6
- package/dist/agent-runtime/sqlite.d.ts.map +1 -1
- package/dist/agent-runtime/store-archive.d.ts +16 -0
- package/dist/agent-runtime/store-archive.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +434 -0
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-ordering.d.ts +18 -0
- package/dist/agent-runtime/store-conformance-ordering.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-support.d.ts +130 -0
- package/dist/agent-runtime/store-conformance-support.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-terminal.d.ts +12 -0
- package/dist/agent-runtime/store-conformance-terminal.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance.d.ts +40 -0
- package/dist/agent-runtime/store-conformance.d.ts.map +1 -0
- package/dist/agent-runtime/store-create.d.ts +11 -0
- package/dist/agent-runtime/store-create.d.ts.map +1 -0
- package/dist/agent-runtime/store-driver-contract.d.ts +814 -0
- package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -0
- package/dist/agent-runtime/store-events.d.ts +7 -89
- package/dist/agent-runtime/store-events.d.ts.map +1 -1
- package/dist/agent-runtime/store-memory.d.ts +4 -0
- package/dist/agent-runtime/store-memory.d.ts.map +1 -0
- package/dist/agent-runtime/store-mutate.d.ts +13 -0
- package/dist/agent-runtime/store-mutate.d.ts.map +1 -0
- package/dist/agent-runtime/store-purge.d.ts +1 -1
- package/dist/agent-runtime/store-purge.d.ts.map +1 -1
- package/dist/agent-runtime/store-reads.d.ts +29 -0
- package/dist/agent-runtime/store-reads.d.ts.map +1 -0
- package/dist/agent-runtime/store-reduce-history.d.ts +10 -0
- package/dist/agent-runtime/store-reduce-history.d.ts.map +1 -0
- package/dist/agent-runtime/store-reduce-run.d.ts +14 -0
- package/dist/agent-runtime/store-reduce-run.d.ts.map +1 -0
- package/dist/agent-runtime/store-reduce-shared.d.ts +76 -0
- package/dist/agent-runtime/store-reduce-shared.d.ts.map +1 -0
- package/dist/agent-runtime/store-reduce-terminal.d.ts +6 -0
- package/dist/agent-runtime/store-reduce-terminal.d.ts.map +1 -0
- package/dist/agent-runtime/store-reducer.d.ts +24 -0
- package/dist/agent-runtime/store-reducer.d.ts.map +1 -0
- package/dist/agent-runtime/store-snapshot.d.ts +19 -0
- package/dist/agent-runtime/store-snapshot.d.ts.map +1 -0
- package/dist/agent-runtime/store.d.ts +1 -1
- package/dist/agent-runtime/store.d.ts.map +1 -1
- package/dist/application/admission-rate.d.ts +21 -0
- package/dist/application/admission-rate.d.ts.map +1 -0
- package/dist/application/admission-run.d.ts +8 -0
- package/dist/application/admission-run.d.ts.map +1 -0
- package/dist/application/admission.d.ts +1 -1
- package/dist/application/admission.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-lock.d.ts +9 -34
- package/dist/application/diagnostic-journal-lock.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-manager.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-storage.d.ts.map +1 -1
- package/dist/application/events.d.ts +1 -1
- package/dist/application/events.d.ts.map +1 -1
- package/dist/application/file-state-store.d.ts +23 -0
- package/dist/application/file-state-store.d.ts.map +1 -0
- package/dist/application/health.d.ts +1 -1
- package/dist/application/health.d.ts.map +1 -1
- package/dist/application/kernel-admission.d.ts +8 -0
- package/dist/application/kernel-admission.d.ts.map +1 -0
- package/dist/application/kernel-contract.d.ts +142 -0
- package/dist/application/kernel-contract.d.ts.map +1 -0
- package/dist/application/kernel-resource-context.d.ts +24 -0
- package/dist/application/kernel-resource-context.d.ts.map +1 -0
- package/dist/application/kernel-restart.d.ts +5 -0
- package/dist/application/kernel-restart.d.ts.map +1 -0
- package/dist/application/kernel-rollback.d.ts +4 -0
- package/dist/application/kernel-rollback.d.ts.map +1 -0
- package/dist/application/kernel-shutdown.d.ts +6 -0
- package/dist/application/kernel-shutdown.d.ts.map +1 -0
- package/dist/application/kernel-start.d.ts +20 -0
- package/dist/application/kernel-start.d.ts.map +1 -0
- package/dist/application/kernel-state.d.ts +116 -0
- package/dist/application/kernel-state.d.ts.map +1 -0
- package/dist/application/kernel.d.ts +9 -140
- package/dist/application/kernel.d.ts.map +1 -1
- package/dist/application/latest-sink.d.ts +1 -1
- package/dist/application/latest-sink.d.ts.map +1 -1
- package/dist/application/notification-outbox.d.ts.map +1 -1
- package/dist/application/opentelemetry.d.ts +1 -1
- package/dist/application/opentelemetry.d.ts.map +1 -1
- package/dist/application/schedule.d.ts +0 -1
- package/dist/application/schedule.d.ts.map +1 -1
- package/dist/application/watch-hub-core.d.ts +122 -0
- package/dist/application/watch-hub-core.d.ts.map +1 -0
- package/dist/application/watch-hub.d.ts +3 -3
- package/dist/application/watch-hub.d.ts.map +1 -1
- package/dist/browser/client-executors.d.ts +14 -0
- package/dist/browser/client-executors.d.ts.map +1 -0
- package/dist/browser/client-multipart.d.ts +1 -1
- package/dist/browser/client-multipart.d.ts.map +1 -1
- package/dist/browser/client-url.d.ts +1 -1
- package/dist/browser/client-url.d.ts.map +1 -1
- package/dist/browser/client.d.ts +3 -2
- package/dist/browser/client.d.ts.map +1 -1
- package/dist/browser/contract-stream.d.ts +1 -1
- package/dist/browser/contract-stream.d.ts.map +1 -1
- package/dist/browser/http-fetch.d.ts +22 -0
- package/dist/browser/http-fetch.d.ts.map +1 -0
- package/dist/browser/http.d.ts +2 -4
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/browser/live-state-core.d.ts +63 -0
- package/dist/browser/live-state-core.d.ts.map +1 -0
- package/dist/browser/live-state.d.ts.map +1 -1
- package/dist/browser/realtime-client.d.ts +26 -0
- package/dist/browser/realtime-client.d.ts.map +1 -0
- package/dist/browser/resumable.d.ts +1 -28
- package/dist/browser/resumable.d.ts.map +1 -1
- package/dist/browser/retained.d.ts.map +1 -0
- package/dist/browser/socket-io-connection.d.ts +82 -0
- package/dist/browser/socket-io-connection.d.ts.map +1 -0
- package/dist/browser/socket-io-peer.d.ts +20 -0
- package/dist/browser/socket-io-peer.d.ts.map +1 -0
- package/dist/browser/socket-io-trace.d.ts +31 -0
- package/dist/browser/socket-io-trace.d.ts.map +1 -0
- package/dist/browser/socket-io.d.ts +24 -18
- package/dist/browser/socket-io.d.ts.map +1 -1
- package/dist/browser/stream.d.ts +14 -2
- package/dist/browser/stream.d.ts.map +1 -1
- package/dist/contract/client-types.d.ts +134 -0
- package/dist/contract/client-types.d.ts.map +1 -0
- package/dist/contract/define-validation.d.ts +30 -0
- package/dist/contract/define-validation.d.ts.map +1 -0
- package/dist/contract/define.d.ts +47 -394
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/normalize.d.ts +56 -0
- package/dist/contract/normalize.d.ts.map +1 -0
- package/dist/contract/runtime-context.d.ts +131 -0
- package/dist/contract/runtime-context.d.ts.map +1 -0
- package/dist/contract/tool-options.d.ts +105 -0
- package/dist/contract/tool-options.d.ts.map +1 -0
- package/dist/contract/tool-view.d.ts +148 -0
- package/dist/contract/tool-view.d.ts.map +1 -0
- package/dist/declaration/declaration.d.ts.map +1 -0
- package/dist/durability/contract.d.ts +259 -0
- package/dist/durability/contract.d.ts.map +1 -0
- package/dist/durability/effect.d.ts +24 -0
- package/dist/durability/effect.d.ts.map +1 -0
- package/dist/durability/engine.d.ts +14 -0
- package/dist/durability/engine.d.ts.map +1 -0
- package/dist/durability/events.d.ts +103 -0
- package/dist/durability/events.d.ts.map +1 -0
- package/dist/durability/json.d.ts +3 -0
- package/dist/durability/json.d.ts.map +1 -0
- package/dist/durability/ledger.d.ts +27 -0
- package/dist/durability/ledger.d.ts.map +1 -0
- package/dist/durability/parks.d.ts +22 -0
- package/dist/durability/parks.d.ts.map +1 -0
- package/dist/durability/scheduler.d.ts +30 -0
- package/dist/durability/scheduler.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/browser.d.ts +5 -0
- package/dist/entrypoints/agent-runtime/browser.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/browser.js +124 -0
- package/dist/entrypoints/agent-runtime/coding-tools.d.ts +2 -0
- package/dist/entrypoints/agent-runtime/coding-tools.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/coding-tools.js +22 -0
- package/dist/entrypoints/agent-runtime/harness.d.ts +2 -0
- package/dist/entrypoints/agent-runtime/harness.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/harness.js +739 -0
- package/dist/entrypoints/agent-runtime/openrouter.d.ts +2 -0
- package/dist/entrypoints/agent-runtime/openrouter.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/openrouter.js +270 -0
- package/dist/entrypoints/agent-runtime/sandbox.d.ts +5 -0
- package/dist/entrypoints/agent-runtime/sandbox.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/sandbox.js +797 -0
- package/dist/entrypoints/agent-runtime/sqlite/bun.d.ts +2 -0
- package/dist/entrypoints/agent-runtime/sqlite/bun.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +44 -0
- package/dist/entrypoints/agent-runtime/sqlite/node.d.ts +2 -0
- package/dist/entrypoints/agent-runtime/sqlite/node.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/sqlite/node.js +46 -0
- package/dist/entrypoints/agent-runtime/testing.d.ts +4 -0
- package/dist/entrypoints/agent-runtime/testing.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/testing.js +1116 -0
- package/dist/entrypoints/agent-runtime.d.ts +42 -0
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime.js +2670 -0
- package/dist/entrypoints/application/diagnostic-journal.d.ts +21 -0
- package/dist/entrypoints/application/diagnostic-journal.d.ts.map +1 -0
- package/dist/entrypoints/application/diagnostic-journal.js +492 -0
- package/dist/entrypoints/application/grammy.d.ts +2 -0
- package/dist/entrypoints/application/grammy.d.ts.map +1 -0
- package/dist/entrypoints/application/grammy.js +169 -0
- package/dist/entrypoints/application/opentelemetry.d.ts +2 -0
- package/dist/entrypoints/application/opentelemetry.d.ts.map +1 -0
- package/dist/entrypoints/application/opentelemetry.js +250 -0
- package/dist/entrypoints/application/schemas.d.ts +15 -0
- package/dist/entrypoints/application/schemas.d.ts.map +1 -0
- package/dist/entrypoints/application/schemas.js +27 -0
- package/dist/entrypoints/application.d.ts +23 -0
- package/dist/entrypoints/application.d.ts.map +1 -0
- package/dist/entrypoints/application.js +2016 -0
- package/dist/entrypoints/bin/upgrade-cli.d.ts.map +1 -0
- package/dist/entrypoints/bin/upgrade-cli.js +177 -0
- package/dist/entrypoints/cli.d.ts +44 -0
- package/dist/entrypoints/cli.d.ts.map +1 -0
- package/dist/entrypoints/cli.js +773 -0
- package/dist/entrypoints/contract.d.ts +12 -0
- package/dist/entrypoints/contract.d.ts.map +1 -0
- package/dist/entrypoints/contract.js +64 -0
- package/dist/entrypoints/declaration.d.ts +2 -0
- package/dist/entrypoints/declaration.d.ts.map +1 -0
- package/dist/entrypoints/declaration.js +183 -0
- package/dist/entrypoints/files.d.ts +5 -0
- package/dist/entrypoints/files.d.ts.map +1 -0
- package/dist/entrypoints/files.js +111 -0
- package/dist/entrypoints/geo.d.ts +3 -0
- package/dist/entrypoints/geo.d.ts.map +1 -0
- package/dist/entrypoints/geo.js +245 -0
- package/dist/entrypoints/google.d.ts +2 -0
- package/dist/entrypoints/google.d.ts.map +1 -0
- package/dist/entrypoints/google.js +175 -0
- package/dist/entrypoints/index.d.ts +17 -0
- package/dist/entrypoints/index.d.ts.map +1 -0
- package/dist/entrypoints/index.js +764 -0
- package/dist/entrypoints/live.d.ts +19 -0
- package/dist/entrypoints/live.d.ts.map +1 -0
- package/dist/entrypoints/live.js +302 -0
- package/dist/entrypoints/node.d.ts +19 -0
- package/dist/entrypoints/node.d.ts.map +1 -0
- package/dist/entrypoints/node.js +308 -0
- package/dist/entrypoints/oauth.d.ts +2 -0
- package/dist/entrypoints/oauth.d.ts.map +1 -0
- package/dist/entrypoints/oauth.js +170 -0
- package/dist/entrypoints/observability.d.ts +19 -0
- package/dist/entrypoints/observability.d.ts.map +1 -0
- package/dist/entrypoints/observability.js +567 -0
- package/dist/entrypoints/primitives.d.ts +3 -0
- package/dist/entrypoints/primitives.d.ts.map +1 -0
- package/dist/entrypoints/primitives.js +749 -0
- package/dist/entrypoints/react.d.ts +5 -0
- package/dist/entrypoints/react.d.ts.map +1 -0
- package/dist/entrypoints/react.js +403 -0
- package/dist/entrypoints/release.d.ts +15 -0
- package/dist/entrypoints/release.d.ts.map +1 -0
- package/dist/entrypoints/release.js +196 -0
- package/dist/entrypoints/remote.d.ts +9 -0
- package/dist/entrypoints/remote.d.ts.map +1 -0
- package/dist/entrypoints/remote.js +66 -0
- package/dist/entrypoints/server.d.ts +39 -0
- package/dist/entrypoints/server.d.ts.map +1 -0
- package/dist/entrypoints/server.js +2009 -0
- package/dist/entrypoints/telegram.d.ts +3 -0
- package/dist/entrypoints/telegram.d.ts.map +1 -0
- package/dist/entrypoints/telegram.js +224 -0
- package/dist/entrypoints/testing.d.ts +10 -0
- package/dist/entrypoints/testing.d.ts.map +1 -0
- package/dist/entrypoints/testing.js +1377 -0
- package/dist/entrypoints/tools/connections.d.ts +19 -0
- package/dist/entrypoints/tools/connections.d.ts.map +1 -0
- package/dist/entrypoints/tools/connections.js +1110 -0
- package/dist/entrypoints/tools/contract.d.ts +29 -0
- package/dist/entrypoints/tools/contract.d.ts.map +1 -0
- package/dist/entrypoints/tools/contract.js +24 -0
- package/dist/entrypoints/tools/invoker.d.ts +9 -0
- package/dist/entrypoints/tools/invoker.d.ts.map +1 -0
- package/dist/entrypoints/tools/invoker.js +20 -0
- package/dist/entrypoints/tools.d.ts +54 -0
- package/dist/entrypoints/tools.d.ts.map +1 -0
- package/dist/entrypoints/tools.js +3009 -0
- package/dist/entrypoints/tracking/server.d.ts +15 -0
- package/dist/entrypoints/tracking/server.d.ts.map +1 -0
- package/dist/entrypoints/tracking.d.ts +24 -0
- package/dist/entrypoints/tracking.d.ts.map +1 -0
- package/dist/entrypoints/tracking.js +1140 -0
- package/dist/files/boundary.d.ts.map +1 -1
- package/dist/files/file-io.d.ts +14 -0
- package/dist/files/file-io.d.ts.map +1 -0
- package/dist/google/google.d.ts.map +1 -0
- package/dist/index-0b1ess5e.js +38 -0
- package/dist/index-1j8pm5t0.js +412 -0
- package/dist/index-1zbbzgfh.js +89 -0
- package/dist/index-2bxbyab0.js +47 -0
- package/dist/index-2gxzjvyr.js +266 -0
- package/dist/index-35mh5bhj.js +177 -0
- package/dist/index-48ffdxgk.js +6 -0
- package/dist/index-4gcnakhx.js +82 -0
- package/dist/index-55hkhm67.js +343 -0
- package/dist/index-79z7m7dt.js +675 -0
- package/dist/index-7f68ghdn.js +3618 -0
- package/dist/index-7p1f0vp2.js +154 -0
- package/dist/index-83bdg97s.js +16 -0
- package/dist/index-863ea9jb.js +154 -0
- package/dist/index-8p52kd5p.js +242 -0
- package/dist/index-d9pk3td4.js +326 -0
- package/dist/index-dce5wxcq.js +63 -0
- package/dist/index-e01r054k.js +105 -0
- package/dist/index-ensd0r74.js +595 -0
- package/dist/index-eqqvgdb3.js +46 -0
- package/dist/index-gxrt5h6v.js +341 -0
- package/dist/index-h6eeys1v.js +211 -0
- package/dist/index-ham5sz8m.js +734 -0
- package/dist/index-het2he5g.js +1387 -0
- package/dist/index-hffjpmq9.js +30 -0
- package/dist/index-hmp4800j.js +51 -0
- package/dist/index-k30h66yd.js +317 -0
- package/dist/index-k5hsfc3j.js +31 -0
- package/dist/index-khtgb21r.js +92 -0
- package/dist/index-m9zn6cpq.js +51 -0
- package/dist/index-ndddxtyx.js +324 -0
- package/dist/index-ngfhvfpd.js +30 -0
- package/dist/index-np4m8hd3.js +1205 -0
- package/dist/index-p3vsv1fb.js +3493 -0
- package/dist/index-p5r7qpdd.js +85 -0
- package/dist/index-p9e0w8hs.js +1084 -0
- package/dist/index-p9sh0xx4.js +64 -0
- package/dist/index-paz6sgdp.js +371 -0
- package/dist/index-px2gm2jp.js +448 -0
- package/dist/index-qwhynv6x.js +103 -0
- package/dist/index-s812ycat.js +65 -0
- package/dist/index-sp1tzwnb.js +281 -0
- package/dist/index-t9rhjr9f.js +2306 -0
- package/dist/index-v260df89.js +342 -0
- package/dist/index-w906953s.js +946 -0
- package/dist/index-wdkt63w3.js +214 -0
- package/dist/index-wqgjfstn.js +18 -0
- package/dist/index-wsm5w4ee.js +1023 -0
- package/dist/index-xw3s75nj.js +100 -0
- package/dist/index-yw4fzmdz.js +268 -0
- package/dist/index-zfrhfn82.js +85 -0
- package/dist/index-znfs20ss.js +98 -0
- package/dist/internal/atomic-file.d.ts +23 -2
- package/dist/internal/atomic-file.d.ts.map +1 -1
- package/dist/internal/backoff.d.ts +29 -0
- package/dist/internal/backoff.d.ts.map +1 -0
- package/dist/internal/canonical-json.d.ts +21 -11
- package/dist/internal/canonical-json.d.ts.map +1 -1
- package/dist/internal/channel.d.ts.map +1 -0
- package/dist/internal/exclusive-lock.d.ts +51 -0
- package/dist/internal/exclusive-lock.d.ts.map +1 -0
- package/dist/internal/logger.d.ts.map +1 -0
- package/dist/internal/process-identity.d.ts +47 -0
- package/dist/internal/process-identity.d.ts.map +1 -0
- package/dist/internal/request.d.ts.map +1 -0
- package/dist/internal/stable-digest.d.ts +0 -43
- package/dist/internal/stable-digest.d.ts.map +1 -1
- package/dist/internal/typed.d.ts +0 -8
- package/dist/internal/typed.d.ts.map +1 -1
- package/dist/internal/with-exclusive-lock.d.ts +67 -0
- package/dist/internal/with-exclusive-lock.d.ts.map +1 -0
- package/dist/internal/zod-issues.d.ts +38 -0
- package/dist/internal/zod-issues.d.ts.map +1 -0
- package/dist/json-schema/dialect.d.ts +17 -0
- package/dist/json-schema/dialect.d.ts.map +1 -0
- package/dist/json-schema/json-schema.d.ts.map +1 -0
- package/dist/live/watch-client.d.ts.map +1 -1
- package/dist/live/watch-delta.d.ts.map +1 -1
- package/dist/oauth/authorization-code.d.ts +57 -0
- package/dist/oauth/authorization-code.d.ts.map +1 -0
- package/dist/observability/audit.d.ts +3 -3
- package/dist/observability/audit.d.ts.map +1 -1
- package/dist/observability/bounded-logger.d.ts +1 -1
- package/dist/observability/bounded-logger.d.ts.map +1 -1
- package/dist/observability/bounded-sink.d.ts +81 -0
- package/dist/observability/bounded-sink.d.ts.map +1 -0
- package/dist/observability/context.d.ts +1 -1
- package/dist/observability/context.d.ts.map +1 -1
- package/dist/observability/event.d.ts +2 -1
- package/dist/observability/event.d.ts.map +1 -1
- package/dist/observability/work.d.ts +1 -1
- package/dist/observability/work.d.ts.map +1 -1
- package/dist/primitives/audit.d.ts +1 -1
- package/dist/primitives/audit.d.ts.map +1 -1
- package/dist/primitives/export-operation.d.ts +4 -2
- package/dist/primitives/export-operation.d.ts.map +1 -1
- package/dist/realtime/registry.d.ts +0 -5
- package/dist/realtime/registry.d.ts.map +1 -1
- package/dist/realtime/socket.d.ts +1 -1
- package/dist/realtime/socket.d.ts.map +1 -1
- package/dist/server/bun.d.ts +0 -1
- package/dist/server/bun.d.ts.map +1 -1
- package/dist/server/context-contribution.d.ts +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 +15 -0
- package/dist/server/contract-method.d.ts.map +1 -0
- package/dist/server/contract-stream.d.ts +1 -1
- package/dist/server/contract-stream.d.ts.map +1 -1
- package/dist/server/create.d.ts +8 -0
- package/dist/server/create.d.ts.map +1 -1
- package/dist/server/endpoint-dispatch.d.ts +10 -0
- package/dist/server/endpoint-dispatch.d.ts.map +1 -0
- package/dist/server/endpoint-response.d.ts +19 -0
- package/dist/server/endpoint-response.d.ts.map +1 -0
- package/dist/server/error-dispatch.d.ts +17 -1
- package/dist/server/error-dispatch.d.ts.map +1 -1
- package/dist/server/error-hook.d.ts +2 -2
- package/dist/server/error-hook.d.ts.map +1 -1
- package/dist/server/handler-state.d.ts +44 -0
- package/dist/server/handler-state.d.ts.map +1 -0
- package/dist/server/implement-registry.d.ts +54 -0
- package/dist/server/implement-registry.d.ts.map +1 -0
- package/dist/server/implement.d.ts +9 -55
- package/dist/server/implement.d.ts.map +1 -1
- package/dist/server/middleware/auth.d.ts +1 -31
- package/dist/server/middleware/auth.d.ts.map +1 -1
- package/dist/server/middleware/cors.d.ts +17 -0
- package/dist/server/middleware/cors.d.ts.map +1 -1
- package/dist/server/middleware/jwt.d.ts +31 -0
- package/dist/server/middleware/jwt.d.ts.map +1 -0
- package/dist/server/middleware/trust-fence.d.ts +1 -1
- package/dist/server/middleware/trust-fence.d.ts.map +1 -1
- package/dist/server/multipart-reader.d.ts +22 -0
- package/dist/server/multipart-reader.d.ts.map +1 -0
- package/dist/server/multipart.d.ts +1 -1
- package/dist/server/multipart.d.ts.map +1 -1
- package/dist/server/oauth/cimd.d.ts +88 -0
- package/dist/server/oauth/cimd.d.ts.map +1 -0
- package/dist/server/oauth/endpoints.d.ts +39 -0
- package/dist/server/oauth/endpoints.d.ts.map +1 -0
- package/dist/server/oauth/metadata.d.ts +28 -0
- package/dist/server/oauth/metadata.d.ts.map +1 -0
- package/dist/server/oauth/provider.d.ts +117 -0
- package/dist/server/oauth/provider.d.ts.map +1 -0
- package/dist/server/realtime.d.ts +1 -1
- package/dist/server/realtime.d.ts.map +1 -1
- package/dist/server/request-completion.d.ts +16 -0
- package/dist/server/request-completion.d.ts.map +1 -0
- package/dist/server/response-metadata.d.ts +1 -1
- package/dist/server/response-metadata.d.ts.map +1 -1
- package/dist/server/route-table.d.ts +9 -0
- package/dist/server/route-table.d.ts.map +1 -0
- package/dist/server/stream.d.ts +0 -13
- package/dist/server/stream.d.ts.map +1 -1
- package/dist/server/streaming-pump.d.ts +66 -0
- package/dist/server/streaming-pump.d.ts.map +1 -0
- package/dist/server/streaming-route.d.ts +12 -5
- package/dist/server/streaming-route.d.ts.map +1 -1
- package/dist/server/types.d.ts +10 -4
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/unix-client-bun.d.ts.map +1 -1
- package/dist/server/unix-client-http1.d.ts +76 -0
- package/dist/server/unix-client-http1.d.ts.map +1 -0
- package/dist/server/unix-client.d.ts.map +1 -1
- package/dist/testing/handler-clients.d.ts +32 -0
- package/dist/testing/handler-clients.d.ts.map +1 -0
- package/dist/testing/managed-resource-conformance-scenarios.d.ts.map +1 -1
- package/dist/testing/realtime-probe.d.ts +33 -0
- package/dist/testing/realtime-probe.d.ts.map +1 -0
- package/dist/testing/surface-conformance.d.ts +2 -32
- package/dist/testing/surface-conformance.d.ts.map +1 -1
- package/dist/testing/surface-manifest-digest.d.ts +44 -0
- package/dist/testing/surface-manifest-digest.d.ts.map +1 -0
- package/dist/testing/surface-manifest.d.ts +30 -4
- package/dist/testing/surface-manifest.d.ts.map +1 -1
- package/dist/tools/agent.d.ts +1 -1
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/cli/args-fields.d.ts +31 -0
- package/dist/tools/cli/args-fields.d.ts.map +1 -0
- package/dist/tools/cli/args-route.d.ts +42 -0
- package/dist/tools/cli/args-route.d.ts.map +1 -0
- package/dist/tools/cli/args-view.d.ts +32 -0
- package/dist/tools/cli/args-view.d.ts.map +1 -0
- package/dist/tools/cli/args.d.ts +80 -0
- package/dist/tools/cli/args.d.ts.map +1 -0
- package/dist/tools/cli/argument-error.d.ts +5 -0
- package/dist/tools/cli/argument-error.d.ts.map +1 -0
- package/dist/tools/cli/checkpoint.d.ts +24 -0
- package/dist/tools/cli/checkpoint.d.ts.map +1 -0
- package/dist/tools/cli/command.d.ts +70 -0
- package/dist/tools/cli/command.d.ts.map +1 -0
- package/dist/tools/cli/config.d.ts +90 -0
- package/dist/tools/cli/config.d.ts.map +1 -0
- package/dist/tools/cli/create-cli.d.ts +36 -0
- package/dist/tools/cli/create-cli.d.ts.map +1 -0
- package/dist/tools/cli/download.d.ts +8 -0
- package/dist/tools/cli/download.d.ts.map +1 -0
- package/dist/tools/cli/format.d.ts +50 -0
- package/dist/tools/cli/format.d.ts.map +1 -0
- package/dist/tools/cli/help.d.ts +24 -0
- package/dist/tools/cli/help.d.ts.map +1 -0
- package/dist/tools/cli/installer.d.ts +34 -0
- package/dist/tools/cli/installer.d.ts.map +1 -0
- package/dist/tools/cli/invoke.d.ts +144 -0
- package/dist/tools/cli/invoke.d.ts.map +1 -0
- package/dist/tools/cli/io.d.ts +10 -0
- package/dist/tools/cli/io.d.ts.map +1 -0
- package/dist/tools/cli/managed-surface.d.ts +30 -0
- package/dist/tools/cli/managed-surface.d.ts.map +1 -0
- package/dist/tools/cli/manifest.d.ts +80 -0
- package/dist/tools/cli/manifest.d.ts.map +1 -0
- package/dist/tools/cli/policy.d.ts +27 -0
- package/dist/tools/cli/policy.d.ts.map +1 -0
- package/dist/tools/cli/prepare.d.ts +14 -0
- package/dist/tools/cli/prepare.d.ts.map +1 -0
- package/dist/tools/cli/profile.d.ts +40 -0
- package/dist/tools/cli/profile.d.ts.map +1 -0
- package/dist/tools/cli/run-managed.d.ts +5 -0
- package/dist/tools/cli/run-managed.d.ts.map +1 -0
- package/dist/tools/cli/run-native.d.ts +9 -0
- package/dist/tools/cli/run-native.d.ts.map +1 -0
- package/dist/tools/cli/session.d.ts +40 -0
- package/dist/tools/cli/session.d.ts.map +1 -0
- package/dist/tools/cli/signature.d.ts +81 -0
- package/dist/tools/cli/signature.d.ts.map +1 -0
- package/dist/tools/cli/stream.d.ts +93 -0
- package/dist/tools/cli/stream.d.ts.map +1 -0
- package/dist/tools/cli/update.d.ts +145 -0
- package/dist/tools/cli/update.d.ts.map +1 -0
- package/dist/tools/cli/view.d.ts +12 -0
- package/dist/tools/cli/view.d.ts.map +1 -0
- package/dist/tools/cli/wait.d.ts +54 -0
- package/dist/tools/cli/wait.d.ts.map +1 -0
- package/dist/tools/connections/runtime.d.ts +1 -1
- package/dist/tools/connections/runtime.d.ts.map +1 -1
- package/dist/tools/connections/types.d.ts +3 -3
- package/dist/tools/connections/types.d.ts.map +1 -1
- package/dist/tools/durability-context.d.ts +1 -1
- package/dist/tools/durability-context.d.ts.map +1 -1
- package/dist/tools/execute-args.d.ts +23 -0
- package/dist/tools/execute-args.d.ts.map +1 -0
- package/dist/tools/execute-hooks.d.ts +146 -0
- package/dist/tools/execute-hooks.d.ts.map +1 -0
- package/dist/tools/execute-result.d.ts +40 -0
- package/dist/tools/execute-result.d.ts.map +1 -0
- package/dist/tools/execute.d.ts +31 -193
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/internal/surface-projector.d.ts +9 -6
- package/dist/tools/internal/surface-projector.d.ts.map +1 -1
- package/dist/tools/internal/tool-view.d.ts +41 -0
- package/dist/tools/internal/tool-view.d.ts.map +1 -0
- package/dist/tools/invoker.d.ts +13 -4
- package/dist/tools/invoker.d.ts.map +1 -1
- package/dist/tools/lifecycle.d.ts +1 -1
- package/dist/tools/lifecycle.d.ts.map +1 -1
- package/dist/tools/list-names.d.ts +3 -3
- package/dist/tools/list-names.d.ts.map +1 -1
- package/dist/tools/manifest.d.ts +2 -2
- package/dist/tools/manifest.d.ts.map +1 -1
- package/dist/tools/mcp/app.d.ts +62 -0
- package/dist/tools/mcp/app.d.ts.map +1 -0
- package/dist/tools/mcp/catalog.d.ts +68 -0
- package/dist/tools/mcp/catalog.d.ts.map +1 -0
- package/dist/tools/mcp/handler.d.ts +46 -0
- package/dist/tools/mcp/handler.d.ts.map +1 -0
- package/dist/tools/mcp/mount.d.ts +152 -0
- package/dist/tools/mcp/mount.d.ts.map +1 -0
- package/dist/tools/mcp/prepare.d.ts +76 -0
- package/dist/tools/mcp/prepare.d.ts.map +1 -0
- package/dist/tools/mcp/progress.d.ts +46 -0
- package/dist/tools/mcp/progress.d.ts.map +1 -0
- package/dist/tools/mcp/register.d.ts +36 -0
- package/dist/tools/mcp/register.d.ts.map +1 -0
- package/dist/tools/mcp/round-context.d.ts +38 -0
- package/dist/tools/mcp/round-context.d.ts.map +1 -0
- package/dist/tools/mcp/round-policy.d.ts +33 -0
- package/dist/tools/mcp/round-policy.d.ts.map +1 -0
- package/dist/tools/mcp/round.d.ts +53 -0
- package/dist/tools/mcp/round.d.ts.map +1 -0
- package/dist/tools/mcp/runtime-tools.d.ts +25 -0
- package/dist/tools/mcp/runtime-tools.d.ts.map +1 -0
- package/dist/tools/mcp/stdio-signals.d.ts +33 -0
- package/dist/tools/mcp/stdio-signals.d.ts.map +1 -0
- package/dist/tools/mcp/stdio.d.ts +20 -0
- package/dist/tools/mcp/stdio.d.ts.map +1 -0
- package/dist/tools/mcp/trace.d.ts +12 -0
- package/dist/tools/mcp/trace.d.ts.map +1 -0
- package/dist/tools/mount.d.ts +14 -7
- package/dist/tools/mount.d.ts.map +1 -1
- package/dist/tools/native-definition.d.ts +4 -3
- package/dist/tools/native-definition.d.ts.map +1 -1
- package/dist/tools/operations/async-operation-binding-types.d.ts +127 -0
- package/dist/tools/operations/async-operation-binding-types.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-binding.d.ts +28 -0
- package/dist/tools/operations/async-operation-binding.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-canonical-types.d.ts +110 -0
- package/dist/tools/operations/async-operation-canonical-types.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-canonical.d.ts +7 -0
- package/dist/tools/operations/async-operation-canonical.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-contract.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-id.d.ts +23 -0
- package/dist/tools/operations/async-operation-id.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-runtime-tools.d.ts +41 -0
- package/dist/tools/operations/async-operation-runtime-tools.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-runtime-types.d.ts +69 -0
- package/dist/tools/operations/async-operation-runtime-types.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-runtime.d.ts +5 -0
- package/dist/tools/operations/async-operation-runtime.d.ts.map +1 -0
- package/dist/tools/operations/define-wait-tool.d.ts +22 -0
- package/dist/tools/operations/define-wait-tool.d.ts.map +1 -0
- package/dist/tools/operations/mount-wait.d.ts.map +1 -0
- package/dist/tools/operations/wait-core.d.ts.map +1 -0
- package/dist/tools/remote.d.ts +1 -1
- package/dist/tools/remote.d.ts.map +1 -1
- package/dist/tools/runtime-tool.d.ts +13 -4
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/dist/tools/schema/coerce.d.ts.map +1 -0
- package/dist/tools/schema/flatten-join.d.ts.map +1 -0
- package/dist/tools/schema/flatten.d.ts.map +1 -0
- package/dist/tools/schema/portable-formats.d.ts.map +1 -0
- package/dist/tools/schema/presentation.d.ts +24 -0
- package/dist/tools/schema/presentation.d.ts.map +1 -0
- package/dist/tools/schema/schema.d.ts.map +1 -0
- package/dist/tools/schema/untyped-properties.d.ts.map +1 -0
- package/dist/tools/surface.d.ts +2 -3
- package/dist/tools/surface.d.ts.map +1 -1
- package/dist/tools/tool-logger.d.ts +1 -1
- package/dist/tools/tool-logger.d.ts.map +1 -1
- package/dist/tools/toolkit.d.ts +4 -4
- package/dist/tools/toolkit.d.ts.map +1 -1
- package/dist/tools/transfer/define-download-tool.d.ts +18 -0
- package/dist/tools/transfer/define-download-tool.d.ts.map +1 -0
- package/dist/tools/transfer/define-upload-tool.d.ts +16 -0
- package/dist/tools/transfer/define-upload-tool.d.ts.map +1 -0
- package/dist/tools/transfer/define-view-file-tool.d.ts +10 -0
- package/dist/tools/transfer/define-view-file-tool.d.ts.map +1 -0
- package/dist/tools/transfer/download-core.d.ts +20 -0
- package/dist/tools/transfer/download-core.d.ts.map +1 -0
- package/dist/tools/transfer/managed-file-error.d.ts +6 -0
- package/dist/tools/transfer/managed-file-error.d.ts.map +1 -0
- package/dist/tools/transfer/mount-download.d.ts +41 -0
- package/dist/tools/transfer/mount-download.d.ts.map +1 -0
- package/dist/tools/transfer/mount-upload.d.ts +21 -0
- package/dist/tools/transfer/mount-upload.d.ts.map +1 -0
- package/dist/tools/transfer/native-result.d.ts.map +1 -0
- package/dist/tools/transfer/upload-core.d.ts +4 -0
- package/dist/tools/transfer/upload-core.d.ts.map +1 -0
- package/dist/tools/transfer/view-file-contract.d.ts.map +1 -0
- package/dist/tools/transfer/view-file.d.ts +62 -0
- package/dist/tools/transfer/view-file.d.ts.map +1 -0
- package/dist/tools/transports.d.ts +1 -1
- package/dist/tools/transports.d.ts.map +1 -1
- package/dist/tracking/client-listeners.d.ts +30 -0
- package/dist/tracking/client-listeners.d.ts.map +1 -0
- package/dist/tracking/client-visit.d.ts +61 -0
- package/dist/tracking/client-visit.d.ts.map +1 -0
- package/dist/tracking/client.d.ts +3 -2
- package/dist/tracking/client.d.ts.map +1 -1
- package/dist/tracking/contract.d.ts +1 -1
- package/dist/tracking/contract.d.ts.map +1 -1
- package/llms/agent-runtime-browser.txt +33 -0
- package/llms/agent-runtime-coding-tools.txt +58 -0
- package/llms/agent-runtime-harness.txt +45 -0
- package/llms/agent-runtime-openrouter.txt +22 -0
- package/llms/agent-runtime-sandbox.txt +159 -0
- package/llms/agent-runtime-sqlite-bun.txt +29 -0
- package/llms/agent-runtime-sqlite-node.txt +26 -0
- package/llms/agent-runtime-testing.txt +30 -0
- package/llms/agent-runtime.2.txt +550 -0
- package/llms/agent-runtime.3.txt +311 -0
- package/llms/agent-runtime.txt +893 -0
- package/llms/application-diagnostic-journal.txt +30 -0
- package/llms/application-grammy.txt +27 -0
- package/llms/application-opentelemetry.txt +27 -0
- package/llms/application-schemas.txt +42 -0
- package/llms/application.2.txt +487 -0
- package/llms/application.txt +886 -0
- package/llms/cli.2.txt +80 -0
- package/llms/cli.txt +948 -0
- package/llms/contract.txt +606 -0
- package/llms/declaration.txt +286 -0
- package/llms/files.txt +33 -0
- package/llms/geo.txt +114 -0
- package/llms/google.txt +27 -0
- package/llms/live.txt +471 -0
- package/llms/node.txt +43 -0
- package/llms/oauth.txt +136 -0
- package/llms/observability.txt +893 -0
- package/llms/primitives.txt +158 -0
- package/llms/react.txt +184 -0
- package/llms/release.txt +176 -0
- package/llms/remote.txt +25 -0
- package/llms/server.2.txt +361 -0
- package/llms/server.3.txt +1031 -0
- package/llms/server.4.txt +905 -0
- package/llms/server.5.txt +250 -0
- package/llms/server.txt +996 -0
- package/llms/stitchkit.2.txt +836 -0
- package/llms/stitchkit.3.txt +147 -0
- package/llms/stitchkit.txt +260 -0
- package/llms/telegram.txt +30 -0
- package/llms/testing.txt +676 -0
- package/llms/tools-connections.txt +45 -0
- package/llms/tools-contract.txt +9 -0
- package/llms/tools-invoker.txt +9 -0
- package/llms/tools.2.txt +647 -0
- package/llms/tools.3.txt +288 -0
- package/llms/tools.txt +966 -0
- package/llms/tracking-server.txt +32 -0
- package/llms/tracking.txt +263 -0
- package/llms/upgrading-0.37.0-0.50.0.txt +947 -0
- package/llms/upgrading-0.53.0-0.67.0.txt +1174 -0
- package/llms/upgrading-0.68.0-0.94.0.txt +1159 -0
- package/llms/upgrading.txt +215 -0
- package/llms-full.txt +312 -77
- package/llms.txt +54 -5
- package/package.json +84 -83
- package/dist/agent-runtime/durability-contract.d.ts +0 -176
- package/dist/agent-runtime/durability-contract.d.ts.map +0 -1
- package/dist/agent-runtime/durability-json.d.ts +0 -3
- package/dist/agent-runtime/durability-json.d.ts.map +0 -1
- package/dist/agent-runtime/durability-ledger.d.ts +0 -16
- package/dist/agent-runtime/durability-ledger.d.ts.map +0 -1
- package/dist/agent-runtime/durability-scheduler.d.ts +0 -29
- package/dist/agent-runtime/durability-scheduler.d.ts.map +0 -1
- package/dist/agent-runtime/durability.d.ts +0 -14
- package/dist/agent-runtime/durability.d.ts.map +0 -1
- package/dist/agent-runtime/store-driver.d.ts +0 -814
- package/dist/agent-runtime/store-driver.d.ts.map +0 -1
- package/dist/agent-runtime-browser.d.ts +0 -5
- package/dist/agent-runtime-browser.d.ts.map +0 -1
- package/dist/agent-runtime-browser.js +0 -124
- package/dist/agent-runtime-coding-tools.d.ts +0 -2
- package/dist/agent-runtime-coding-tools.d.ts.map +0 -1
- package/dist/agent-runtime-coding-tools.js +0 -23
- package/dist/agent-runtime-harness.d.ts +0 -2
- package/dist/agent-runtime-harness.d.ts.map +0 -1
- package/dist/agent-runtime-harness.js +0 -729
- package/dist/agent-runtime-openrouter.d.ts +0 -29
- package/dist/agent-runtime-openrouter.d.ts.map +0 -1
- package/dist/agent-runtime-openrouter.js +0 -270
- package/dist/agent-runtime-sandbox.d.ts +0 -5
- package/dist/agent-runtime-sandbox.d.ts.map +0 -1
- package/dist/agent-runtime-sandbox.js +0 -798
- package/dist/agent-runtime-sqlite-bun.d.ts +0 -11
- package/dist/agent-runtime-sqlite-bun.d.ts.map +0 -1
- package/dist/agent-runtime-sqlite-bun.js +0 -42
- package/dist/agent-runtime-sqlite-node.d.ts +0 -11
- package/dist/agent-runtime-sqlite-node.d.ts.map +0 -1
- package/dist/agent-runtime-sqlite-node.js +0 -44
- package/dist/agent-runtime-testing.d.ts +0 -3
- package/dist/agent-runtime-testing.d.ts.map +0 -1
- package/dist/agent-runtime-testing.js +0 -156
- package/dist/agent-runtime.d.ts +0 -38
- package/dist/agent-runtime.d.ts.map +0 -1
- package/dist/agent-runtime.js +0 -2607
- package/dist/application/channel.d.ts.map +0 -1
- package/dist/application-diagnostic-journal.d.ts +0 -21
- package/dist/application-diagnostic-journal.d.ts.map +0 -1
- package/dist/application-diagnostic-journal.js +0 -632
- package/dist/application-grammy.d.ts +0 -2
- package/dist/application-grammy.d.ts.map +0 -1
- package/dist/application-grammy.js +0 -169
- package/dist/application-opentelemetry.d.ts +0 -2
- package/dist/application-opentelemetry.d.ts.map +0 -1
- package/dist/application-opentelemetry.js +0 -250
- package/dist/application-schemas.d.ts +0 -15
- package/dist/application-schemas.d.ts.map +0 -1
- package/dist/application-schemas.js +0 -27
- package/dist/application.d.ts +0 -22
- package/dist/application.d.ts.map +0 -1
- package/dist/application.js +0 -1977
- package/dist/cli.d.ts +0 -41
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -753
- package/dist/contract/index.d.ts +0 -8
- package/dist/contract/index.d.ts.map +0 -1
- package/dist/contract/index.js +0 -55
- package/dist/declaration.d.ts.map +0 -1
- package/dist/declaration.js +0 -183
- package/dist/files.d.ts +0 -3
- package/dist/files.d.ts.map +0 -1
- package/dist/files.js +0 -15
- package/dist/geo.d.ts +0 -3
- package/dist/geo.d.ts.map +0 -1
- package/dist/geo.js +0 -245
- package/dist/google.d.ts.map +0 -1
- package/dist/google.js +0 -175
- package/dist/index-0a349c33.js +0 -470
- package/dist/index-0j3vcp5m.js +0 -28
- package/dist/index-2c2bjw3s.js +0 -51
- package/dist/index-2na0qrfn.js +0 -214
- package/dist/index-2qzskm8h.js +0 -63
- package/dist/index-3bmnp41g.js +0 -2169
- package/dist/index-3xwxfj4z.js +0 -334
- package/dist/index-4fpa9dy2.js +0 -51
- package/dist/index-6kyksz9y.js +0 -268
- package/dist/index-77fekveh.js +0 -44
- package/dist/index-7gnkny4z.js +0 -326
- package/dist/index-7zbps32p.js +0 -89
- package/dist/index-9f8ztey6.js +0 -588
- package/dist/index-a11g2kry.js +0 -866
- package/dist/index-a916km3r.js +0 -45
- package/dist/index-actkayzn.js +0 -367
- package/dist/index-bn2cjajt.js +0 -524
- package/dist/index-bx75zwt7.js +0 -63
- package/dist/index-cby4ar3v.js +0 -46
- package/dist/index-cnyk6te3.js +0 -77
- package/dist/index-cxqhvq21.js +0 -413
- package/dist/index-e0znv5gn.js +0 -176
- package/dist/index-e42wzzz5.js +0 -154
- package/dist/index-f477k430.js +0 -324
- package/dist/index-f9mb610r.js +0 -177
- package/dist/index-fadnxwna.js +0 -1046
- package/dist/index-fq77yfzc.js +0 -1303
- package/dist/index-h9etkkyk.js +0 -1126
- package/dist/index-hrbajay7.js +0 -1196
- package/dist/index-kw9t5ayn.js +0 -507
- package/dist/index-mzvgxp0n.js +0 -80
- package/dist/index-n0f51dfn.js +0 -3170
- package/dist/index-p13mwz16.js +0 -16
- package/dist/index-s8cnx02s.js +0 -90
- package/dist/index-sr93cwf9.js +0 -325
- package/dist/index-tmwcrptx.js +0 -85
- package/dist/index-v5573g1k.js +0 -142
- package/dist/index-vjpvjqpn.js +0 -86
- package/dist/index-vk3kq9sb.js +0 -3344
- package/dist/index-wc4x00bn.js +0 -103
- package/dist/index-wnfk50r0.js +0 -211
- package/dist/index-yewwh1w4.js +0 -647
- package/dist/index-yn8remb1.js +0 -290
- package/dist/index-ywd0y6m1.js +0 -394
- package/dist/index-zwkgfq1s.js +0 -345
- package/dist/index.d.ts +0 -14
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -632
- package/dist/internal/errors.d.ts +0 -92
- package/dist/internal/errors.d.ts.map +0 -1
- package/dist/internal/observability-sink.d.ts +0 -81
- package/dist/internal/observability-sink.d.ts.map +0 -1
- package/dist/live.d.ts +0 -19
- package/dist/live.d.ts.map +0 -1
- package/dist/live.js +0 -282
- package/dist/logger.d.ts.map +0 -1
- package/dist/node.d.ts +0 -18
- package/dist/node.d.ts.map +0 -1
- package/dist/node.js +0 -303
- package/dist/oauth.d.ts +0 -57
- package/dist/oauth.d.ts.map +0 -1
- package/dist/oauth.js +0 -170
- package/dist/observability/index.d.ts +0 -19
- package/dist/observability/index.d.ts.map +0 -1
- package/dist/observability/index.js +0 -569
- package/dist/primitives.d.ts +0 -3
- package/dist/primitives.d.ts.map +0 -1
- package/dist/primitives.js +0 -754
- package/dist/react.d.ts +0 -5
- package/dist/react.d.ts.map +0 -1
- package/dist/react.js +0 -403
- package/dist/release.d.ts +0 -15
- package/dist/release.d.ts.map +0 -1
- package/dist/release.js +0 -196
- package/dist/remote.d.ts +0 -9
- package/dist/remote.d.ts.map +0 -1
- package/dist/remote.js +0 -88
- package/dist/retained.d.ts.map +0 -1
- package/dist/server/file-state-store.d.ts +0 -23
- package/dist/server/file-state-store.d.ts.map +0 -1
- package/dist/server/index.d.ts +0 -36
- package/dist/server/index.d.ts.map +0 -1
- package/dist/server/index.js +0 -1745
- package/dist/server/request.d.ts.map +0 -1
- package/dist/telegram.d.ts +0 -3
- package/dist/telegram.d.ts.map +0 -1
- package/dist/telegram.js +0 -224
- package/dist/testing/agent-store-conformance.d.ts +0 -40
- package/dist/testing/agent-store-conformance.d.ts.map +0 -1
- package/dist/testing.d.ts +0 -39
- package/dist/testing.d.ts.map +0 -1
- package/dist/testing.js +0 -2209
- package/dist/tool-invoker.d.ts +0 -9
- package/dist/tool-invoker.d.ts.map +0 -1
- package/dist/tool-invoker.js +0 -21
- package/dist/tools/async-operation-contract.d.ts.map +0 -1
- package/dist/tools/async-operation.d.ts +0 -332
- package/dist/tools/async-operation.d.ts.map +0 -1
- package/dist/tools/cli-args.d.ts +0 -143
- package/dist/tools/cli-args.d.ts.map +0 -1
- package/dist/tools/cli-checkpoint.d.ts +0 -24
- package/dist/tools/cli-checkpoint.d.ts.map +0 -1
- package/dist/tools/cli-command.d.ts +0 -70
- package/dist/tools/cli-command.d.ts.map +0 -1
- package/dist/tools/cli-format.d.ts +0 -49
- package/dist/tools/cli-format.d.ts.map +0 -1
- package/dist/tools/cli-installer.d.ts +0 -34
- package/dist/tools/cli-installer.d.ts.map +0 -1
- package/dist/tools/cli-invoke.d.ts +0 -143
- package/dist/tools/cli-invoke.d.ts.map +0 -1
- package/dist/tools/cli-manifest.d.ts +0 -80
- package/dist/tools/cli-manifest.d.ts.map +0 -1
- package/dist/tools/cli-policy.d.ts +0 -27
- package/dist/tools/cli-policy.d.ts.map +0 -1
- package/dist/tools/cli-profile.d.ts +0 -40
- package/dist/tools/cli-profile.d.ts.map +0 -1
- package/dist/tools/cli-signature.d.ts +0 -81
- package/dist/tools/cli-signature.d.ts.map +0 -1
- package/dist/tools/cli-stream.d.ts +0 -93
- package/dist/tools/cli-stream.d.ts.map +0 -1
- package/dist/tools/cli-update.d.ts +0 -126
- package/dist/tools/cli-update.d.ts.map +0 -1
- package/dist/tools/cli-view.d.ts +0 -12
- package/dist/tools/cli-view.d.ts.map +0 -1
- package/dist/tools/cli-wait.d.ts +0 -54
- package/dist/tools/cli-wait.d.ts.map +0 -1
- package/dist/tools/cli.d.ts +0 -94
- package/dist/tools/cli.d.ts.map +0 -1
- package/dist/tools/coerce.d.ts.map +0 -1
- package/dist/tools/connections/index.d.ts +0 -20
- package/dist/tools/connections/index.d.ts.map +0 -1
- package/dist/tools/connections/index.js +0 -1107
- package/dist/tools/define-download-tool.d.ts +0 -18
- package/dist/tools/define-download-tool.d.ts.map +0 -1
- package/dist/tools/define-upload-tool.d.ts +0 -16
- package/dist/tools/define-upload-tool.d.ts.map +0 -1
- package/dist/tools/define-view-file-tool.d.ts +0 -10
- package/dist/tools/define-view-file-tool.d.ts.map +0 -1
- package/dist/tools/define-wait-tool.d.ts +0 -22
- package/dist/tools/define-wait-tool.d.ts.map +0 -1
- package/dist/tools/download-core.d.ts +0 -20
- package/dist/tools/download-core.d.ts.map +0 -1
- package/dist/tools/flatten-join.d.ts.map +0 -1
- package/dist/tools/flatten.d.ts.map +0 -1
- package/dist/tools/json-schema-dialect.d.ts +0 -17
- package/dist/tools/json-schema-dialect.d.ts.map +0 -1
- package/dist/tools/json-schema.d.ts.map +0 -1
- package/dist/tools/managed-file-error.d.ts +0 -6
- package/dist/tools/managed-file-error.d.ts.map +0 -1
- package/dist/tools/mcp-app.d.ts +0 -62
- package/dist/tools/mcp-app.d.ts.map +0 -1
- package/dist/tools/mcp-catalog.d.ts +0 -68
- package/dist/tools/mcp-catalog.d.ts.map +0 -1
- package/dist/tools/mcp-handler.d.ts +0 -46
- package/dist/tools/mcp-handler.d.ts.map +0 -1
- package/dist/tools/mcp-prepare.d.ts +0 -75
- package/dist/tools/mcp-prepare.d.ts.map +0 -1
- package/dist/tools/mcp-progress.d.ts +0 -46
- package/dist/tools/mcp-progress.d.ts.map +0 -1
- package/dist/tools/mcp-round-policy.d.ts +0 -33
- package/dist/tools/mcp-round-policy.d.ts.map +0 -1
- package/dist/tools/mcp-round.d.ts +0 -61
- package/dist/tools/mcp-round.d.ts.map +0 -1
- package/dist/tools/mcp-stdio-signals.d.ts +0 -33
- package/dist/tools/mcp-stdio-signals.d.ts.map +0 -1
- package/dist/tools/mcp-stdio.d.ts +0 -20
- package/dist/tools/mcp-stdio.d.ts.map +0 -1
- package/dist/tools/mcp-trace.d.ts +0 -12
- package/dist/tools/mcp-trace.d.ts.map +0 -1
- package/dist/tools/mcp.d.ts +0 -152
- package/dist/tools/mcp.d.ts.map +0 -1
- package/dist/tools/mount-download.d.ts +0 -41
- package/dist/tools/mount-download.d.ts.map +0 -1
- package/dist/tools/mount-upload.d.ts +0 -21
- package/dist/tools/mount-upload.d.ts.map +0 -1
- package/dist/tools/mount-wait.d.ts.map +0 -1
- package/dist/tools/native-mcp.d.ts +0 -20
- package/dist/tools/native-mcp.d.ts.map +0 -1
- package/dist/tools/native-result.d.ts.map +0 -1
- package/dist/tools/oauth-metadata.d.ts +0 -28
- package/dist/tools/oauth-metadata.d.ts.map +0 -1
- package/dist/tools/oauth-provider.d.ts +0 -184
- package/dist/tools/oauth-provider.d.ts.map +0 -1
- package/dist/tools/portable-formats.d.ts.map +0 -1
- package/dist/tools/presentation.d.ts +0 -22
- package/dist/tools/presentation.d.ts.map +0 -1
- package/dist/tools/schema.d.ts.map +0 -1
- package/dist/tools/untyped-properties.d.ts.map +0 -1
- package/dist/tools/upload-core.d.ts +0 -4
- package/dist/tools/upload-core.d.ts.map +0 -1
- package/dist/tools/view-file-contract.d.ts.map +0 -1
- package/dist/tools/view-file.d.ts +0 -62
- package/dist/tools/view-file.d.ts.map +0 -1
- package/dist/tools/wait-core.d.ts.map +0 -1
- package/dist/tools-contract.d.ts +0 -29
- package/dist/tools-contract.d.ts.map +0 -1
- package/dist/tools-contract.js +0 -24
- package/dist/tools.d.ts +0 -50
- package/dist/tools.d.ts.map +0 -1
- package/dist/tools.js +0 -2930
- package/dist/tracking-server.d.ts +0 -15
- package/dist/tracking-server.d.ts.map +0 -1
- package/dist/tracking.d.ts +0 -24
- package/dist/tracking.d.ts.map +0 -1
- package/dist/tracking.js +0 -1092
- package/dist/upgrade-cli.d.ts.map +0 -1
- package/dist/upgrade-cli.js +0 -177
- /package/dist/{retained.d.ts → browser/retained.d.ts} +0 -0
- /package/dist/{declaration.d.ts → declaration/declaration.d.ts} +0 -0
- /package/dist/{upgrade-cli.d.ts → entrypoints/bin/upgrade-cli.d.ts} +0 -0
- /package/dist/{tracking-server.js → entrypoints/tracking/server.js} +0 -0
- /package/dist/{google.d.ts → google/google.d.ts} +0 -0
- /package/dist/{index-pq95qkbf.js → index-5jm36zv1.js} +0 -0
- /package/dist/{application → internal}/channel.d.ts +0 -0
- /package/dist/{logger.d.ts → internal/logger.d.ts} +0 -0
- /package/dist/{server → internal}/request.d.ts +0 -0
- /package/dist/{tools → json-schema}/json-schema.d.ts +0 -0
- /package/dist/tools/{async-operation-contract.d.ts → operations/async-operation-contract.d.ts} +0 -0
- /package/dist/tools/{mount-wait.d.ts → operations/mount-wait.d.ts} +0 -0
- /package/dist/tools/{wait-core.d.ts → operations/wait-core.d.ts} +0 -0
- /package/dist/tools/{coerce.d.ts → schema/coerce.d.ts} +0 -0
- /package/dist/tools/{flatten-join.d.ts → schema/flatten-join.d.ts} +0 -0
- /package/dist/tools/{flatten.d.ts → schema/flatten.d.ts} +0 -0
- /package/dist/tools/{portable-formats.d.ts → schema/portable-formats.d.ts} +0 -0
- /package/dist/tools/{schema.d.ts → schema/schema.d.ts} +0 -0
- /package/dist/tools/{untyped-properties.d.ts → schema/untyped-properties.d.ts} +0 -0
- /package/dist/tools/{native-result.d.ts → transfer/native-result.d.ts} +0 -0
- /package/dist/tools/{view-file-contract.d.ts → transfer/view-file-contract.d.ts} +0 -0
|
@@ -0,0 +1,2670 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AgentContextOverflowError,
|
|
3
|
+
AgentProviderStreamCutError,
|
|
4
|
+
AgentRuntimeConflictError,
|
|
5
|
+
AgentTokenCountSchema,
|
|
6
|
+
agentGoalStateSlot,
|
|
7
|
+
agentTodoStateSlot,
|
|
8
|
+
classifyProviderFailure,
|
|
9
|
+
composeAgentPrompt,
|
|
10
|
+
createAgentRuntime,
|
|
11
|
+
createAgentRuntimeEventSink,
|
|
12
|
+
createAgentSessionCoordinator,
|
|
13
|
+
createAgentStateSlotStore,
|
|
14
|
+
createAgentToolFenceLifecycle,
|
|
15
|
+
deferredToolCatalog,
|
|
16
|
+
defineStateSlot,
|
|
17
|
+
isToolResultFailure,
|
|
18
|
+
normalizeSdkUsage,
|
|
19
|
+
projectAgentHistory,
|
|
20
|
+
projectAgentHistoryDetailed,
|
|
21
|
+
recordAgentRetryDecision,
|
|
22
|
+
registerDeferredToolCatalog,
|
|
23
|
+
registerDeferredToolRepair,
|
|
24
|
+
renderAgentStateSlots,
|
|
25
|
+
repairedSearchCall,
|
|
26
|
+
selectAgentHistory
|
|
27
|
+
} from "../index-7f68ghdn.js";
|
|
28
|
+
import"../index-83bdg97s.js";
|
|
29
|
+
import {
|
|
30
|
+
AgentAdmissionEventSchema,
|
|
31
|
+
AgentAttemptResetEventSchema,
|
|
32
|
+
AgentCheckpointEventSchema,
|
|
33
|
+
AgentReasoningDeltaEventSchema,
|
|
34
|
+
AgentReasoningEndEventSchema,
|
|
35
|
+
AgentReasoningStartEventSchema,
|
|
36
|
+
AgentRunOperationEventSchema,
|
|
37
|
+
AgentRunStateEventSchema,
|
|
38
|
+
AgentRuntimeEventCursorSchema,
|
|
39
|
+
AgentRuntimeEventSchema,
|
|
40
|
+
AgentTerminalEventSchema,
|
|
41
|
+
AgentToolStatusEventSchema,
|
|
42
|
+
AgentTransientDeltaEventSchema,
|
|
43
|
+
advanceAgentRuntimeEventCursor,
|
|
44
|
+
agentDurableEventId
|
|
45
|
+
} from "../index-y64k3s0h.js";
|
|
46
|
+
import {
|
|
47
|
+
AgentModelCapabilitySchema,
|
|
48
|
+
AgentModelCatalogEntrySchema,
|
|
49
|
+
AgentModelCatalogSchema,
|
|
50
|
+
AgentModelDescriptorSchema,
|
|
51
|
+
AgentModelMetricSchema,
|
|
52
|
+
AgentModelPopularitySchema,
|
|
53
|
+
AgentModelPriceSchema,
|
|
54
|
+
AgentModelRegistrySnapshotSchema,
|
|
55
|
+
AgentModelSearchInputSchema,
|
|
56
|
+
AgentModelSearchResultSchema,
|
|
57
|
+
AgentModelSelectionSchema,
|
|
58
|
+
createMemoryAgentModelSelectionStore,
|
|
59
|
+
defineModelRegistry,
|
|
60
|
+
searchAgentModelCatalog,
|
|
61
|
+
validateAgentModelSnapshot
|
|
62
|
+
} from "../index-mqv3b5rh.js";
|
|
63
|
+
import {
|
|
64
|
+
AgentConversationMessagePageSchema,
|
|
65
|
+
AgentConversationPageSchema,
|
|
66
|
+
AgentConversationSummarySchema
|
|
67
|
+
} from "../index-crykmqkr.js";
|
|
68
|
+
import {
|
|
69
|
+
createBoundedSinkManager
|
|
70
|
+
} from "../index-h6eeys1v.js";
|
|
71
|
+
import {
|
|
72
|
+
AgentSandboxGradeSchema,
|
|
73
|
+
AgentSandboxRestrictionSchema,
|
|
74
|
+
missingSandboxRestrictions,
|
|
75
|
+
probeAgentProcessSandbox,
|
|
76
|
+
recordAgentSandboxProbe,
|
|
77
|
+
refuseUnknownSpillReference
|
|
78
|
+
} from "../index-qmy6zq75.js";
|
|
79
|
+
import {
|
|
80
|
+
createMemoryAgentRuntimeStore
|
|
81
|
+
} from "../index-sp1tzwnb.js";
|
|
82
|
+
import {
|
|
83
|
+
ACTIVE_AGENT_RUN_STATES,
|
|
84
|
+
AgentAdmissionReceiptSchema,
|
|
85
|
+
AgentConversationPurgeInputSchema,
|
|
86
|
+
AgentConversationPurgeResultSchema,
|
|
87
|
+
AgentConversationPurgedError,
|
|
88
|
+
AgentHistoryMutationSchema,
|
|
89
|
+
AgentRuntimeHeadSchema,
|
|
90
|
+
AgentSeedReceiptSchema,
|
|
91
|
+
AgentStoredRunSchema,
|
|
92
|
+
createAgentRuntimeStore,
|
|
93
|
+
purgeAgentConversation
|
|
94
|
+
} from "../index-wsm5w4ee.js";
|
|
95
|
+
import {
|
|
96
|
+
AcceptInputAndAssignRunSchema,
|
|
97
|
+
AcquireAgentRunSchema,
|
|
98
|
+
AgentConversationArchiveSchema,
|
|
99
|
+
AgentRecoverableDescriptorSchema,
|
|
100
|
+
AgentRecoverablePageSchema,
|
|
101
|
+
AgentRunViewSchema,
|
|
102
|
+
AgentStoreAppliedSchema,
|
|
103
|
+
AgentStoreConflictSchema,
|
|
104
|
+
AgentStoreDuplicateSchema,
|
|
105
|
+
AgentStoreEventEnvelopeSchema,
|
|
106
|
+
AgentStoreEventKindSchema,
|
|
107
|
+
AgentStoreEventPageSchema,
|
|
108
|
+
AgentStoreMutationResultSchema,
|
|
109
|
+
AgentStoreNotFoundSchema,
|
|
110
|
+
AgentStoreTransitionSchema,
|
|
111
|
+
AppendAgentStoreEventSchema,
|
|
112
|
+
CheckpointRunAssistantSchema,
|
|
113
|
+
CommitRunTerminalSchema,
|
|
114
|
+
ReadAgentStoreEventsSchema,
|
|
115
|
+
RecordRunOperationSchema,
|
|
116
|
+
RecoverAgentRunSchema,
|
|
117
|
+
ReplaceCompactedRangeSchema,
|
|
118
|
+
RequestRunInterruptSchema,
|
|
119
|
+
SeedConversationInputSchema,
|
|
120
|
+
canonicalAgentJson,
|
|
121
|
+
decodeAgentConversationArchive,
|
|
122
|
+
decodeAgentStoreEvent,
|
|
123
|
+
encodeAgentConversationArchive,
|
|
124
|
+
isAssistantHistoryEvidence,
|
|
125
|
+
isCompleteAgentHistoryTurn
|
|
126
|
+
} from "../index-gxrt5h6v.js";
|
|
127
|
+
import {
|
|
128
|
+
AgentAssistantPlaceholderSchema,
|
|
129
|
+
AgentControlPartSchema,
|
|
130
|
+
AgentCostValueSchema,
|
|
131
|
+
AgentFilePartSchema,
|
|
132
|
+
AgentJsonObjectSchema,
|
|
133
|
+
AgentMessagePartSchema,
|
|
134
|
+
AgentMessageRoleSchema,
|
|
135
|
+
AgentMessageSchema,
|
|
136
|
+
AgentMessageStatusSchema,
|
|
137
|
+
AgentOpaquePartSchema,
|
|
138
|
+
AgentProvenanceSchema,
|
|
139
|
+
AgentProviderEnvelopeSchema,
|
|
140
|
+
AgentProviderResponseSchema,
|
|
141
|
+
AgentReasoningPartSchema,
|
|
142
|
+
AgentRecordIdSchema,
|
|
143
|
+
AgentRecordVersionSchema,
|
|
144
|
+
AgentRunMetricsSchema,
|
|
145
|
+
AgentRunOperationKindSchema,
|
|
146
|
+
AgentRunOperationPhaseSchema,
|
|
147
|
+
AgentRunOperationSchema,
|
|
148
|
+
AgentRunQueuePrioritySchema,
|
|
149
|
+
AgentRunSchema,
|
|
150
|
+
AgentRunStateSchema,
|
|
151
|
+
AgentSnapshotSchema,
|
|
152
|
+
AgentSourcePartSchema,
|
|
153
|
+
AgentTerminalReasonSchema,
|
|
154
|
+
AgentTextPartSchema,
|
|
155
|
+
AgentTimestampSchema,
|
|
156
|
+
AgentToolApprovalRequestPartSchema,
|
|
157
|
+
AgentToolApprovalResponsePartSchema,
|
|
158
|
+
AgentToolCallPartSchema,
|
|
159
|
+
AgentToolResultPartSchema,
|
|
160
|
+
AgentUsageSchema,
|
|
161
|
+
AgentUsageValueSchema,
|
|
162
|
+
runStateForTerminalReason
|
|
163
|
+
} from "../index-gtj3zc53.js";
|
|
164
|
+
import {
|
|
165
|
+
buildToolManifest,
|
|
166
|
+
mountAgent
|
|
167
|
+
} from "../index-863ea9jb.js";
|
|
168
|
+
import {
|
|
169
|
+
DURABILITY_STEP_EVENT_KIND,
|
|
170
|
+
ParkAbortedError,
|
|
171
|
+
ParkRecordDecodeError,
|
|
172
|
+
StepAbortedError,
|
|
173
|
+
StepResultDecodeError,
|
|
174
|
+
StepResultNotSerializableError
|
|
175
|
+
} from "../index-79z7m7dt.js";
|
|
176
|
+
import"../index-hmp4800j.js";
|
|
177
|
+
import"../index-khtgb21r.js";
|
|
178
|
+
import"../index-55hkhm67.js";
|
|
179
|
+
import"../index-zfrhfn82.js";
|
|
180
|
+
import"../index-35mh5bhj.js";
|
|
181
|
+
import {
|
|
182
|
+
childSpan,
|
|
183
|
+
createTraceContext
|
|
184
|
+
} from "../index-zcgf3gqf.js";
|
|
185
|
+
import"../index-1zbbzgfh.js";
|
|
186
|
+
import {
|
|
187
|
+
defineRuntimeTool,
|
|
188
|
+
executableAgentRuntimeTools
|
|
189
|
+
} from "../index-xw3s75nj.js";
|
|
190
|
+
import"../index-np4m8hd3.js";
|
|
191
|
+
import"../index-eqqvgdb3.js";
|
|
192
|
+
import"../index-znfs20ss.js";
|
|
193
|
+
import"../index-p5r7qpdd.js";
|
|
194
|
+
import"../index-2vtcmrj9.js";
|
|
195
|
+
import"../index-k5hsfc3j.js";
|
|
196
|
+
import"../index-kzfs85xp.js";
|
|
197
|
+
import"../index-hffjpmq9.js";
|
|
198
|
+
|
|
199
|
+
// src/agent-runtime/child-tools.ts
|
|
200
|
+
import { z as z2 } from "zod";
|
|
201
|
+
|
|
202
|
+
// src/agent-runtime/agent-tool.ts
|
|
203
|
+
function defineAgentTool(definition) {
|
|
204
|
+
return {
|
|
205
|
+
...definition,
|
|
206
|
+
handler: (context) => definition.handler(context)
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// src/agent-runtime/children-contract.ts
|
|
211
|
+
import { z } from "zod";
|
|
212
|
+
var AgentChildBudgetSchema = z.object({
|
|
213
|
+
usd: z.number().positive().optional(),
|
|
214
|
+
tokens: z.int().positive().optional(),
|
|
215
|
+
milliseconds: z.int().positive().optional()
|
|
216
|
+
}).strict();
|
|
217
|
+
var AgentChildStateSchema = z.enum([
|
|
218
|
+
"spawned",
|
|
219
|
+
"running",
|
|
220
|
+
"finished",
|
|
221
|
+
"stopped",
|
|
222
|
+
"lost"
|
|
223
|
+
]);
|
|
224
|
+
var AgentChildRecordSchema = z.object({
|
|
225
|
+
parentConversationId: z.string().min(1),
|
|
226
|
+
childConversationId: z.string().min(1),
|
|
227
|
+
seedUptoSeq: z.int().nonnegative(),
|
|
228
|
+
state: AgentChildStateSchema,
|
|
229
|
+
budget: AgentChildBudgetSchema,
|
|
230
|
+
usage: z.object({
|
|
231
|
+
tokens: z.int().nonnegative(),
|
|
232
|
+
usd: z.number().nonnegative(),
|
|
233
|
+
milliseconds: z.int().nonnegative()
|
|
234
|
+
}).strict(),
|
|
235
|
+
resultReference: z.string().optional(),
|
|
236
|
+
createdAt: z.string(),
|
|
237
|
+
updatedAt: z.string()
|
|
238
|
+
}).strict();
|
|
239
|
+
var AgentChildBlockingKindSchema = z.enum(["approval", "input"]);
|
|
240
|
+
var AgentChildBlockingSourceSchema = z.object({
|
|
241
|
+
approvalId: z.string().min(1),
|
|
242
|
+
callId: z.string().min(1),
|
|
243
|
+
toolName: z.string().min(1),
|
|
244
|
+
input: z.json(),
|
|
245
|
+
kind: AgentChildBlockingKindSchema.default("approval"),
|
|
246
|
+
batchId: z.string().min(1).optional()
|
|
247
|
+
}).strict();
|
|
248
|
+
var AgentChildBlockingEventSchema = z.object({
|
|
249
|
+
parentConversationId: z.string().min(1),
|
|
250
|
+
childConversationId: z.string().min(1),
|
|
251
|
+
kind: AgentChildBlockingKindSchema,
|
|
252
|
+
approvalId: z.string().min(1),
|
|
253
|
+
childApprovalId: z.string().min(1),
|
|
254
|
+
callId: z.string().min(1),
|
|
255
|
+
toolName: z.string().min(1),
|
|
256
|
+
input: z.json(),
|
|
257
|
+
batchId: z.string().min(1),
|
|
258
|
+
presentedAt: z.string()
|
|
259
|
+
}).strict();
|
|
260
|
+
var ChildBlockingDecisionSchema = z.union([
|
|
261
|
+
z.object({
|
|
262
|
+
approvalId: z.string().min(1),
|
|
263
|
+
approved: z.boolean(),
|
|
264
|
+
reason: z.string().optional()
|
|
265
|
+
}).strict(),
|
|
266
|
+
z.object({ approvalId: z.string().min(1), value: z.json() }).strict()
|
|
267
|
+
]);
|
|
268
|
+
var ChildRowSchema = z.object({
|
|
269
|
+
parent_conversation_id: z.string(),
|
|
270
|
+
child_conversation_id: z.string(),
|
|
271
|
+
seed_upto_seq: z.int().nonnegative(),
|
|
272
|
+
state: AgentChildStateSchema,
|
|
273
|
+
budget_payload: z.string(),
|
|
274
|
+
usage_payload: z.string(),
|
|
275
|
+
result_reference: z.string().nullable(),
|
|
276
|
+
created_at: z.string(),
|
|
277
|
+
updated_at: z.string()
|
|
278
|
+
});
|
|
279
|
+
function parseChild(raw) {
|
|
280
|
+
const row = ChildRowSchema.parse(raw);
|
|
281
|
+
return AgentChildRecordSchema.parse({
|
|
282
|
+
parentConversationId: row.parent_conversation_id,
|
|
283
|
+
childConversationId: row.child_conversation_id,
|
|
284
|
+
seedUptoSeq: row.seed_upto_seq,
|
|
285
|
+
state: row.state,
|
|
286
|
+
budget: JSON.parse(row.budget_payload),
|
|
287
|
+
usage: JSON.parse(row.usage_payload),
|
|
288
|
+
...row.result_reference && { resultReference: row.result_reference },
|
|
289
|
+
createdAt: row.created_at,
|
|
290
|
+
updatedAt: row.updated_at
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
function usageNumbers(usage) {
|
|
294
|
+
const inputTokens = usage.inputTokens.value;
|
|
295
|
+
const outputTokens = usage.outputTokens.value;
|
|
296
|
+
return {
|
|
297
|
+
...inputTokens !== undefined && outputTokens !== undefined ? { tokens: inputTokens + outputTokens } : {},
|
|
298
|
+
...usage.cost?.currency === "USD" && usage.cost.value !== undefined ? { usd: usage.cost.value } : {}
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// src/agent-runtime/child-blocking.ts
|
|
303
|
+
function createChildBlockingRelay(input) {
|
|
304
|
+
const { store, now, handles, listChildren, activeChild, bounded } = input;
|
|
305
|
+
const presentedBlocking = new Map;
|
|
306
|
+
const retiredBlocking = new Set;
|
|
307
|
+
let blockingQueue = Promise.resolve();
|
|
308
|
+
const serializeBlocking = (work) => {
|
|
309
|
+
const run = blockingQueue.then(work, work);
|
|
310
|
+
blockingQueue = run.then(() => {
|
|
311
|
+
return;
|
|
312
|
+
}, () => {
|
|
313
|
+
return;
|
|
314
|
+
});
|
|
315
|
+
return run;
|
|
316
|
+
};
|
|
317
|
+
const childScopedBlockingId = (childConversationId, childApprovalId) => `${encodeURIComponent(childConversationId)}:${encodeURIComponent(childApprovalId)}`;
|
|
318
|
+
const retireChildBlocking = (childConversationId) => {
|
|
319
|
+
for (const [id, entry] of presentedBlocking) {
|
|
320
|
+
if (entry.event.childConversationId === childConversationId) {
|
|
321
|
+
presentedBlocking.delete(id);
|
|
322
|
+
retiredBlocking.add(id);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
const listChildBlockingInner = async (parentConversationId) => {
|
|
327
|
+
const live = listChildren(parentConversationId).filter((record) => record.state === "spawned" || record.state === "running");
|
|
328
|
+
for (const record of live) {
|
|
329
|
+
const handle = handles.get(record.childConversationId);
|
|
330
|
+
if (!handle?.blockingEvents)
|
|
331
|
+
continue;
|
|
332
|
+
const reported = await bounded(Promise.resolve(handle.blockingEvents()), []);
|
|
333
|
+
const fresh = reported.map((source) => AgentChildBlockingSourceSchema.parse(source)).filter((source) => {
|
|
334
|
+
const id = childScopedBlockingId(record.childConversationId, source.approvalId);
|
|
335
|
+
return !presentedBlocking.has(id) && !retiredBlocking.has(id);
|
|
336
|
+
});
|
|
337
|
+
if (fresh.length === 0)
|
|
338
|
+
continue;
|
|
339
|
+
const presentedAt = now().toISOString();
|
|
340
|
+
for (const source of fresh) {
|
|
341
|
+
const approvalId = childScopedBlockingId(record.childConversationId, source.approvalId);
|
|
342
|
+
const batchId = source.batchId ? `${record.childConversationId}:${source.batchId}` : approvalId;
|
|
343
|
+
const event = AgentChildBlockingEventSchema.parse({
|
|
344
|
+
parentConversationId,
|
|
345
|
+
childConversationId: record.childConversationId,
|
|
346
|
+
kind: source.kind,
|
|
347
|
+
approvalId,
|
|
348
|
+
childApprovalId: source.approvalId,
|
|
349
|
+
callId: source.callId,
|
|
350
|
+
toolName: source.toolName,
|
|
351
|
+
input: source.input,
|
|
352
|
+
batchId,
|
|
353
|
+
presentedAt
|
|
354
|
+
});
|
|
355
|
+
await store.appendEvent({
|
|
356
|
+
conversationId: parentConversationId,
|
|
357
|
+
kind: "child/state",
|
|
358
|
+
occurredAt: presentedAt,
|
|
359
|
+
payload: {
|
|
360
|
+
action: "blocking-presented",
|
|
361
|
+
childConversationId: event.childConversationId,
|
|
362
|
+
approvalId: event.approvalId,
|
|
363
|
+
childApprovalId: event.childApprovalId,
|
|
364
|
+
kind: event.kind,
|
|
365
|
+
callId: event.callId,
|
|
366
|
+
toolName: event.toolName,
|
|
367
|
+
input: event.input,
|
|
368
|
+
batchId: event.batchId,
|
|
369
|
+
presentedAt
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
presentedBlocking.set(approvalId, { event, batchId });
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return [...presentedBlocking.values()].map((entry) => entry.event).filter((event) => event.parentConversationId === parentConversationId);
|
|
376
|
+
};
|
|
377
|
+
const listChildBlocking = (parentConversationId) => serializeBlocking(() => listChildBlockingInner(parentConversationId));
|
|
378
|
+
const respondToChildBlockingInner = async (parentConversationId, decision) => {
|
|
379
|
+
const entry = presentedBlocking.get(decision.approvalId);
|
|
380
|
+
if (!entry || entry.event.parentConversationId !== parentConversationId) {
|
|
381
|
+
throw new TypeError("Child blocking request is missing, stale or already answered");
|
|
382
|
+
}
|
|
383
|
+
const { handle } = activeChild(parentConversationId, entry.event.childConversationId);
|
|
384
|
+
if (!handle.respondToBlocking) {
|
|
385
|
+
throw new TypeError("Child host cannot answer blocking requests");
|
|
386
|
+
}
|
|
387
|
+
const parsed = ChildBlockingDecisionSchema.parse(decision);
|
|
388
|
+
if (entry.event.kind === "input" !== "value" in parsed)
|
|
389
|
+
throw new TypeError("Child response kind does not match the pending request");
|
|
390
|
+
await handle.respondToBlocking({ ...parsed, approvalId: entry.event.childApprovalId });
|
|
391
|
+
presentedBlocking.delete(decision.approvalId);
|
|
392
|
+
retiredBlocking.add(decision.approvalId);
|
|
393
|
+
await store.appendEvent({
|
|
394
|
+
conversationId: parentConversationId,
|
|
395
|
+
kind: "child/state",
|
|
396
|
+
payload: {
|
|
397
|
+
action: "blocking-resolved",
|
|
398
|
+
childConversationId: entry.event.childConversationId,
|
|
399
|
+
approvalId: entry.event.approvalId,
|
|
400
|
+
batchId: entry.batchId,
|
|
401
|
+
..."approved" in parsed ? { approved: parsed.approved } : { kind: "input" }
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
};
|
|
405
|
+
const respondToChildBlocking = (parentConversationId, decision) => serializeBlocking(() => respondToChildBlockingInner(parentConversationId, decision));
|
|
406
|
+
return { retireChildBlocking, listChildBlocking, respondToChildBlocking };
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// src/agent-runtime/children-state.ts
|
|
410
|
+
function createChildManagerState(config) {
|
|
411
|
+
return {
|
|
412
|
+
config,
|
|
413
|
+
database: config.sqlite.database,
|
|
414
|
+
store: config.sqlite.store,
|
|
415
|
+
now: config.now ?? (() => new Date),
|
|
416
|
+
handles: new Map,
|
|
417
|
+
settlements: new Map
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
function currentState(state, childConversationId) {
|
|
421
|
+
const raw = state.database.prepare("SELECT state FROM stitchkit_agent_runtime_children WHERE child_conversation_id = ?").get(childConversationId);
|
|
422
|
+
return raw === null || raw === undefined ? undefined : AgentChildStateSchema.parse(raw.state);
|
|
423
|
+
}
|
|
424
|
+
function isLive(state, childConversationId) {
|
|
425
|
+
const current = currentState(state, childConversationId);
|
|
426
|
+
return current === "spawned" || current === "running";
|
|
427
|
+
}
|
|
428
|
+
function settleable(state, childConversationId) {
|
|
429
|
+
const current = currentState(state, childConversationId);
|
|
430
|
+
return current === undefined || current === "spawned" || current === "running";
|
|
431
|
+
}
|
|
432
|
+
var STOP_BOUND_MS = 1e4;
|
|
433
|
+
async function bounded(work, fallback) {
|
|
434
|
+
let timer;
|
|
435
|
+
try {
|
|
436
|
+
return await Promise.race([
|
|
437
|
+
Promise.resolve(work),
|
|
438
|
+
new Promise((resolve) => {
|
|
439
|
+
timer = setTimeout(() => resolve(fallback), STOP_BOUND_MS);
|
|
440
|
+
})
|
|
441
|
+
]);
|
|
442
|
+
} finally {
|
|
443
|
+
if (timer)
|
|
444
|
+
clearTimeout(timer);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
function listChildren(state, parentConversationId) {
|
|
448
|
+
return state.database.prepare(`
|
|
449
|
+
SELECT parent_conversation_id, child_conversation_id, seed_upto_seq, state,
|
|
450
|
+
budget_payload, usage_payload, result_reference, created_at, updated_at
|
|
451
|
+
FROM stitchkit_agent_runtime_children
|
|
452
|
+
WHERE parent_conversation_id = ? ORDER BY created_at, child_conversation_id
|
|
453
|
+
`).all(parentConversationId).map(parseChild);
|
|
454
|
+
}
|
|
455
|
+
async function updateState(state, record, next, resultReference, details = {}) {
|
|
456
|
+
const updatedAt = state.now().toISOString();
|
|
457
|
+
const payload = {
|
|
458
|
+
childConversationId: record.childConversationId,
|
|
459
|
+
state: next,
|
|
460
|
+
...resultReference && { resultReference },
|
|
461
|
+
...details
|
|
462
|
+
};
|
|
463
|
+
const childPayload = {
|
|
464
|
+
parentConversationId: record.parentConversationId,
|
|
465
|
+
state: next,
|
|
466
|
+
...resultReference && { resultReference },
|
|
467
|
+
...details
|
|
468
|
+
};
|
|
469
|
+
const write = (audience) => state.config.sqlite.transaction(async (scope) => {
|
|
470
|
+
scope.database.prepare(`
|
|
471
|
+
UPDATE stitchkit_agent_runtime_children
|
|
472
|
+
SET state = ?, result_reference = ?, updated_at = ? WHERE child_conversation_id = ?
|
|
473
|
+
`).run(next, resultReference ?? null, updatedAt, record.childConversationId);
|
|
474
|
+
if (audience === "both") {
|
|
475
|
+
await scope.appendEvent({
|
|
476
|
+
conversationId: record.parentConversationId,
|
|
477
|
+
kind: "child/state",
|
|
478
|
+
occurredAt: updatedAt,
|
|
479
|
+
payload
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
if (audience !== "row") {
|
|
483
|
+
await scope.appendEvent({
|
|
484
|
+
conversationId: record.childConversationId,
|
|
485
|
+
kind: "child/state",
|
|
486
|
+
occurredAt: updatedAt,
|
|
487
|
+
payload: childPayload
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
try {
|
|
492
|
+
await write("both");
|
|
493
|
+
} catch (error) {
|
|
494
|
+
if (!(error instanceof AgentConversationPurgedError))
|
|
495
|
+
throw error;
|
|
496
|
+
try {
|
|
497
|
+
await write("child");
|
|
498
|
+
} catch (inner) {
|
|
499
|
+
if (!(inner instanceof AgentConversationPurgedError))
|
|
500
|
+
throw inner;
|
|
501
|
+
await write("row");
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
function activeChild(state, parentConversationId, childConversationId) {
|
|
506
|
+
const child = listChildren(state, parentConversationId).find((record) => record.childConversationId === childConversationId);
|
|
507
|
+
if (!child)
|
|
508
|
+
throw new TypeError("Unknown child conversation for this parent");
|
|
509
|
+
if (child.state !== "running" && child.state !== "spawned") {
|
|
510
|
+
throw new TypeError("Child conversation is not active");
|
|
511
|
+
}
|
|
512
|
+
const handle = state.handles.get(childConversationId);
|
|
513
|
+
if (!handle)
|
|
514
|
+
throw new TypeError("Child host handle is unavailable");
|
|
515
|
+
return { child, handle };
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
// src/agent-runtime/children-control.ts
|
|
519
|
+
async function stopChildren(state, retireChildBlocking, parentConversationId) {
|
|
520
|
+
const records = listChildren(state, parentConversationId).filter((record) => record.state === "spawned" || record.state === "running");
|
|
521
|
+
await Promise.all(records.map((record) => stopChild(state, retireChildBlocking, record)));
|
|
522
|
+
}
|
|
523
|
+
async function stopChild(state, retireChildBlocking, record) {
|
|
524
|
+
const startedAt = performance.now();
|
|
525
|
+
const handle = state.handles.get(record.childConversationId);
|
|
526
|
+
const reachable = handle ? handle.reachable ? await bounded(handle.reachable(), false) : true : false;
|
|
527
|
+
if (!reachable) {
|
|
528
|
+
if (isLive(state, record.childConversationId)) {
|
|
529
|
+
await updateState(state, record, "lost", undefined, {
|
|
530
|
+
stopDurationMs: Math.max(0, performance.now() - startedAt)
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
retireChildBlocking(record.childConversationId);
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
await bounded(Promise.resolve(handle?.stopPolicy("parent-stopped")).then(() => true), false);
|
|
537
|
+
if (!isLive(state, record.childConversationId))
|
|
538
|
+
return;
|
|
539
|
+
await updateState(state, record, "stopped", undefined, {
|
|
540
|
+
stopDurationMs: Math.max(0, performance.now() - startedAt)
|
|
541
|
+
});
|
|
542
|
+
retireChildBlocking(record.childConversationId);
|
|
543
|
+
}
|
|
544
|
+
async function sendMessage(state, parentConversationId, childConversationId, message) {
|
|
545
|
+
const { handle } = activeChild(state, parentConversationId, childConversationId);
|
|
546
|
+
if (!handle.sendMessage)
|
|
547
|
+
throw new TypeError("Child host does not support messages");
|
|
548
|
+
await handle.sendMessage(message);
|
|
549
|
+
await state.store.appendEvent({
|
|
550
|
+
conversationId: parentConversationId,
|
|
551
|
+
kind: "child/state",
|
|
552
|
+
payload: { childConversationId, action: "message-sent" }
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
async function interruptChild(state, retireChildBlocking, parentConversationId, childConversationId) {
|
|
556
|
+
const { child, handle } = activeChild(state, parentConversationId, childConversationId);
|
|
557
|
+
const startedAt = performance.now();
|
|
558
|
+
await handle.stopPolicy("parent-interrupt");
|
|
559
|
+
await updateState(state, child, "stopped", undefined, {
|
|
560
|
+
policyName: "parent-interrupt",
|
|
561
|
+
stopDurationMs: Math.max(0, performance.now() - startedAt)
|
|
562
|
+
});
|
|
563
|
+
retireChildBlocking(childConversationId);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
// src/agent-runtime/children-spawn.ts
|
|
567
|
+
import { randomUUID } from "node:crypto";
|
|
568
|
+
async function grantedBudget(state, request) {
|
|
569
|
+
const requestedBudget = AgentChildBudgetSchema.parse(request.budget);
|
|
570
|
+
const remaining = state.config.remainingBudget ? AgentChildBudgetSchema.parse(await state.config.remainingBudget(request.parentConversationId)) : undefined;
|
|
571
|
+
const bounded2 = (requested, available) => {
|
|
572
|
+
if (requested === undefined)
|
|
573
|
+
return available;
|
|
574
|
+
if (available === undefined)
|
|
575
|
+
return requested;
|
|
576
|
+
return Math.min(requested, available);
|
|
577
|
+
};
|
|
578
|
+
const usd = bounded2(requestedBudget.usd, remaining?.usd);
|
|
579
|
+
const tokens = bounded2(requestedBudget.tokens, remaining?.tokens);
|
|
580
|
+
const milliseconds = bounded2(requestedBudget.milliseconds, remaining?.milliseconds);
|
|
581
|
+
return AgentChildBudgetSchema.parse({
|
|
582
|
+
...usd !== undefined && { usd },
|
|
583
|
+
...tokens !== undefined && { tokens },
|
|
584
|
+
...milliseconds !== undefined && { milliseconds }
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
async function readSeedEvents(state, request) {
|
|
588
|
+
const events = [];
|
|
589
|
+
let cursor = 1;
|
|
590
|
+
for (;; ) {
|
|
591
|
+
const page = await state.store.readEvents({
|
|
592
|
+
conversationId: request.parentConversationId,
|
|
593
|
+
fromSeq: cursor,
|
|
594
|
+
...request.seedUptoSeq !== undefined && { toSeq: request.seedUptoSeq },
|
|
595
|
+
limit: 1000
|
|
596
|
+
});
|
|
597
|
+
events.push(...page.items);
|
|
598
|
+
if (page.nextSeq === undefined)
|
|
599
|
+
break;
|
|
600
|
+
cursor = page.nextSeq;
|
|
601
|
+
}
|
|
602
|
+
return events;
|
|
603
|
+
}
|
|
604
|
+
async function persistSpawn(state, record, handle) {
|
|
605
|
+
const { childConversationId, createdAt } = record;
|
|
606
|
+
try {
|
|
607
|
+
await state.config.sqlite.transaction(async (scope) => {
|
|
608
|
+
scope.database.prepare(`
|
|
609
|
+
INSERT INTO stitchkit_agent_runtime_children (
|
|
610
|
+
parent_conversation_id, child_conversation_id, seed_upto_seq, state,
|
|
611
|
+
budget_payload, usage_payload, result_reference, created_at, updated_at
|
|
612
|
+
) VALUES (?, ?, ?, ?, ?, ?, NULL, ?, ?)
|
|
613
|
+
`).run(record.parentConversationId, record.childConversationId, record.seedUptoSeq, record.state, JSON.stringify(record.budget), JSON.stringify(record.usage), createdAt, createdAt);
|
|
614
|
+
await scope.appendEvent({
|
|
615
|
+
conversationId: record.parentConversationId,
|
|
616
|
+
kind: "child/spawned",
|
|
617
|
+
occurredAt: createdAt,
|
|
618
|
+
payload: {
|
|
619
|
+
childConversationId,
|
|
620
|
+
seedUptoSeq: record.seedUptoSeq,
|
|
621
|
+
budget: record.budget
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
});
|
|
625
|
+
await updateState(state, record, "running");
|
|
626
|
+
} catch (cause) {
|
|
627
|
+
try {
|
|
628
|
+
await handle.stopPolicy("spawn-persistence-failed");
|
|
629
|
+
} catch (cleanup) {
|
|
630
|
+
throw new AggregateError([cause, cleanup], "Child persistence and stop both failed");
|
|
631
|
+
}
|
|
632
|
+
try {
|
|
633
|
+
if (isLive(state, childConversationId))
|
|
634
|
+
await updateState(state, record, "lost", undefined, {
|
|
635
|
+
reason: "spawn-persistence-failed"
|
|
636
|
+
});
|
|
637
|
+
} catch (cleanup) {
|
|
638
|
+
throw new AggregateError([cause, cleanup], "Child stopped but persistence reconciliation failed");
|
|
639
|
+
}
|
|
640
|
+
throw cause;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
function watchSettlement(state, record, handle, retireChildBlocking) {
|
|
644
|
+
const { childConversationId } = record;
|
|
645
|
+
state.handles.set(childConversationId, handle);
|
|
646
|
+
const settlement = handle.result.then(async (result) => {
|
|
647
|
+
state.handles.delete(childConversationId);
|
|
648
|
+
retireChildBlocking(childConversationId);
|
|
649
|
+
if (settleable(state, childConversationId)) {
|
|
650
|
+
await updateState(state, record, "finished", result.resultReference);
|
|
651
|
+
}
|
|
652
|
+
}, async () => {
|
|
653
|
+
state.handles.delete(childConversationId);
|
|
654
|
+
retireChildBlocking(childConversationId);
|
|
655
|
+
if (settleable(state, childConversationId))
|
|
656
|
+
await updateState(state, record, "stopped");
|
|
657
|
+
});
|
|
658
|
+
state.settlements.set(childConversationId, settlement);
|
|
659
|
+
settlement.catch(() => {
|
|
660
|
+
return;
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
async function spawnChild(state, retireChildBlocking, request) {
|
|
664
|
+
const budget = await grantedBudget(state, request);
|
|
665
|
+
const events = await readSeedEvents(state, request);
|
|
666
|
+
const seedUptoSeq = events.at(-1)?.seq ?? 0;
|
|
667
|
+
const childConversationId = request.childConversationId ?? randomUUID();
|
|
668
|
+
const createdAt = state.now().toISOString();
|
|
669
|
+
const record = AgentChildRecordSchema.parse({
|
|
670
|
+
parentConversationId: request.parentConversationId,
|
|
671
|
+
childConversationId,
|
|
672
|
+
seedUptoSeq,
|
|
673
|
+
state: "spawned",
|
|
674
|
+
budget,
|
|
675
|
+
usage: { tokens: 0, usd: 0, milliseconds: 0 },
|
|
676
|
+
createdAt,
|
|
677
|
+
updatedAt: createdAt
|
|
678
|
+
});
|
|
679
|
+
const seedArchive = encodeAgentConversationArchive({
|
|
680
|
+
format: "stitchkit.agent-conversation",
|
|
681
|
+
formatVersion: 1,
|
|
682
|
+
conversationId: request.parentConversationId,
|
|
683
|
+
events,
|
|
684
|
+
projections: [],
|
|
685
|
+
spills: []
|
|
686
|
+
});
|
|
687
|
+
const handle = await state.config.spawn({
|
|
688
|
+
parentConversationId: record.parentConversationId,
|
|
689
|
+
childConversationId,
|
|
690
|
+
seedArchive,
|
|
691
|
+
childInput: request.childInput,
|
|
692
|
+
budget
|
|
693
|
+
});
|
|
694
|
+
handle.result.catch(() => {
|
|
695
|
+
return;
|
|
696
|
+
});
|
|
697
|
+
await persistSpawn(state, record, handle);
|
|
698
|
+
watchSettlement(state, record, handle, retireChildBlocking);
|
|
699
|
+
return { ...record, state: "running", updatedAt: state.now().toISOString() };
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
// src/agent-runtime/children-usage.ts
|
|
703
|
+
async function recordStepUsage(state, request) {
|
|
704
|
+
const { database, handles, now } = state;
|
|
705
|
+
const raw = database.prepare(`
|
|
706
|
+
SELECT parent_conversation_id, child_conversation_id, seed_upto_seq, state,
|
|
707
|
+
budget_payload, usage_payload, result_reference, created_at, updated_at
|
|
708
|
+
FROM stitchkit_agent_runtime_children WHERE child_conversation_id = ?
|
|
709
|
+
`).get(request.childConversationId);
|
|
710
|
+
if (raw === null || raw === undefined)
|
|
711
|
+
throw new TypeError("Unknown child conversation");
|
|
712
|
+
const record = parseChild(raw);
|
|
713
|
+
const measured = usageNumbers(request.usage);
|
|
714
|
+
if (record.budget.tokens !== undefined && measured.tokens === undefined) {
|
|
715
|
+
throw new TypeError("Cannot enforce child token budget without measured token usage");
|
|
716
|
+
}
|
|
717
|
+
if (record.budget.usd !== undefined && measured.usd === undefined) {
|
|
718
|
+
throw new TypeError("Cannot enforce child USD budget without USD usage");
|
|
719
|
+
}
|
|
720
|
+
const usage = {
|
|
721
|
+
tokens: record.usage.tokens + (measured.tokens ?? 0),
|
|
722
|
+
usd: record.usage.usd + (measured.usd ?? 0),
|
|
723
|
+
milliseconds: record.usage.milliseconds + request.elapsedMs
|
|
724
|
+
};
|
|
725
|
+
const updatedAt = now().toISOString();
|
|
726
|
+
const overrun = {
|
|
727
|
+
tokens: Math.max(0, usage.tokens - (record.budget.tokens ?? Number.POSITIVE_INFINITY)),
|
|
728
|
+
usd: Math.max(0, usage.usd - (record.budget.usd ?? Number.POSITIVE_INFINITY)),
|
|
729
|
+
milliseconds: Math.max(0, usage.milliseconds - (record.budget.milliseconds ?? Number.POSITIVE_INFINITY))
|
|
730
|
+
};
|
|
731
|
+
const stop = record.budget.tokens !== undefined && usage.tokens >= record.budget.tokens || record.budget.usd !== undefined && usage.usd >= record.budget.usd || record.budget.milliseconds !== undefined && usage.milliseconds >= record.budget.milliseconds;
|
|
732
|
+
const handle = handles.get(request.childConversationId);
|
|
733
|
+
let enforced = false;
|
|
734
|
+
if (stop && handle) {
|
|
735
|
+
enforced = await bounded(Promise.resolve().then(() => handle.stopPolicy("child-budget")).then(() => true, () => false), false);
|
|
736
|
+
}
|
|
737
|
+
const payload = {
|
|
738
|
+
childConversationId: record.childConversationId,
|
|
739
|
+
state: "running",
|
|
740
|
+
usage,
|
|
741
|
+
overrun,
|
|
742
|
+
...stop && { policyName: "child-budget", enforced }
|
|
743
|
+
};
|
|
744
|
+
await state.config.sqlite.transaction(async (scope) => {
|
|
745
|
+
scope.database.prepare("UPDATE stitchkit_agent_runtime_children SET usage_payload = ?, updated_at = ? WHERE child_conversation_id = ?").run(JSON.stringify(usage), updatedAt, request.childConversationId);
|
|
746
|
+
await scope.appendEvent({
|
|
747
|
+
conversationId: record.parentConversationId,
|
|
748
|
+
kind: "child/state",
|
|
749
|
+
occurredAt: updatedAt,
|
|
750
|
+
payload
|
|
751
|
+
});
|
|
752
|
+
await scope.appendEvent({
|
|
753
|
+
conversationId: record.childConversationId,
|
|
754
|
+
kind: "child/state",
|
|
755
|
+
occurredAt: updatedAt,
|
|
756
|
+
payload: { parentConversationId: record.parentConversationId, ...payload }
|
|
757
|
+
});
|
|
758
|
+
});
|
|
759
|
+
return { stop, enforced, ...stop && { policyName: "child-budget" }, overrun };
|
|
760
|
+
}
|
|
761
|
+
// src/agent-runtime/child-budget-policy.ts
|
|
762
|
+
function agentChildBudgetStopPolicy(input) {
|
|
763
|
+
let stepsSeen = 0;
|
|
764
|
+
let lastBoundary = performance.now();
|
|
765
|
+
return {
|
|
766
|
+
name: "child-budget",
|
|
767
|
+
when: async ({ steps }) => {
|
|
768
|
+
const step = steps.at(-1);
|
|
769
|
+
if (!step || steps.length <= stepsSeen)
|
|
770
|
+
return false;
|
|
771
|
+
stepsSeen = steps.length;
|
|
772
|
+
const elapsedMs = Math.max(0, performance.now() - lastBoundary);
|
|
773
|
+
lastBoundary = performance.now();
|
|
774
|
+
const usage = normalizeSdkUsage(step.usage);
|
|
775
|
+
const cost = input.cost?.({ usage: step.usage });
|
|
776
|
+
const boundary = await input.manager.recordStepUsage({
|
|
777
|
+
childConversationId: input.childConversationId,
|
|
778
|
+
usage: { ...usage, ...cost && { cost } },
|
|
779
|
+
elapsedMs
|
|
780
|
+
});
|
|
781
|
+
return boundary.stop;
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
// src/agent-runtime/children.ts
|
|
787
|
+
function createSqliteAgentChildManager(input) {
|
|
788
|
+
const state = createChildManagerState(input);
|
|
789
|
+
const list = (parentConversationId) => listChildren(state, parentConversationId);
|
|
790
|
+
const { retireChildBlocking, listChildBlocking, respondToChildBlocking } = createChildBlockingRelay({
|
|
791
|
+
store: state.store,
|
|
792
|
+
now: state.now,
|
|
793
|
+
handles: state.handles,
|
|
794
|
+
listChildren: list,
|
|
795
|
+
activeChild: (parentConversationId, childConversationId) => activeChild(state, parentConversationId, childConversationId),
|
|
796
|
+
bounded
|
|
797
|
+
});
|
|
798
|
+
return {
|
|
799
|
+
spawnChild: (request) => spawnChild(state, retireChildBlocking, request),
|
|
800
|
+
listChildren: list,
|
|
801
|
+
recordStepUsage: (request) => recordStepUsage(state, request),
|
|
802
|
+
stopChildren: (parentConversationId) => stopChildren(state, retireChildBlocking, parentConversationId),
|
|
803
|
+
sendMessage: (parentConversationId, childConversationId, message) => sendMessage(state, parentConversationId, childConversationId, message),
|
|
804
|
+
interruptChild: (parentConversationId, childConversationId) => interruptChild(state, retireChildBlocking, parentConversationId, childConversationId),
|
|
805
|
+
waitChild: async (childConversationId) => {
|
|
806
|
+
await state.settlements.get(childConversationId);
|
|
807
|
+
},
|
|
808
|
+
listChildBlocking,
|
|
809
|
+
respondToChildBlocking
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
// src/agent-runtime/child-tools.ts
|
|
814
|
+
function childTool(manager, fork) {
|
|
815
|
+
return defineAgentTool({
|
|
816
|
+
name: fork ? "subagent_fork" : "subagent",
|
|
817
|
+
description: fork ? "Run a child conversation seeded from the parent through one exact event sequence." : "Run a child conversation seeded from the current durable parent history.",
|
|
818
|
+
identity: {
|
|
819
|
+
serviceName: "agent-children",
|
|
820
|
+
action: fork ? "fork" : "spawn",
|
|
821
|
+
method: "POST"
|
|
822
|
+
},
|
|
823
|
+
input: z2.object({
|
|
824
|
+
parentConversationId: z2.string().min(1),
|
|
825
|
+
childInput: z2.json(),
|
|
826
|
+
budget: AgentChildBudgetSchema,
|
|
827
|
+
seedUptoSeq: z2.int().positive().optional()
|
|
828
|
+
}).strict(),
|
|
829
|
+
output: z2.object({
|
|
830
|
+
childConversationId: z2.string(),
|
|
831
|
+
state: z2.string(),
|
|
832
|
+
resultReference: z2.string().optional()
|
|
833
|
+
}),
|
|
834
|
+
transports: ["AGENT"],
|
|
835
|
+
handler: async ({ input }) => {
|
|
836
|
+
if (fork && input.seedUptoSeq === undefined) {
|
|
837
|
+
throw new TypeError("subagent_fork requires seedUptoSeq");
|
|
838
|
+
}
|
|
839
|
+
const child = await manager.spawnChild({
|
|
840
|
+
parentConversationId: input.parentConversationId,
|
|
841
|
+
childInput: input.childInput,
|
|
842
|
+
budget: input.budget,
|
|
843
|
+
...input.seedUptoSeq !== undefined && { seedUptoSeq: input.seedUptoSeq }
|
|
844
|
+
});
|
|
845
|
+
await manager.waitChild(child.childConversationId);
|
|
846
|
+
const finished = manager.listChildren(input.parentConversationId).find((record) => record.childConversationId === child.childConversationId);
|
|
847
|
+
if (!finished)
|
|
848
|
+
throw new Error("Child record disappeared after settlement");
|
|
849
|
+
return {
|
|
850
|
+
childConversationId: finished.childConversationId,
|
|
851
|
+
state: finished.state,
|
|
852
|
+
...finished.resultReference && { resultReference: finished.resultReference }
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
function createAgentChildTools(manager) {
|
|
858
|
+
return [
|
|
859
|
+
childTool(manager, false),
|
|
860
|
+
childTool(manager, true),
|
|
861
|
+
defineAgentTool({
|
|
862
|
+
name: "list_agents",
|
|
863
|
+
description: "List the durable child graph for one parent conversation.",
|
|
864
|
+
identity: { serviceName: "agent-children", action: "list", method: "GET" },
|
|
865
|
+
input: z2.object({ parentConversationId: z2.string().min(1) }).strict(),
|
|
866
|
+
output: z2.object({ children: z2.array(AgentChildRecordSchema) }),
|
|
867
|
+
transports: ["AGENT"],
|
|
868
|
+
handler: ({ input }) => ({
|
|
869
|
+
children: [...manager.listChildren(input.parentConversationId)]
|
|
870
|
+
})
|
|
871
|
+
}),
|
|
872
|
+
defineAgentTool({
|
|
873
|
+
name: "send_message",
|
|
874
|
+
description: "Send one follow-up input to an active child conversation.",
|
|
875
|
+
identity: { serviceName: "agent-children", action: "message", method: "POST" },
|
|
876
|
+
input: z2.object({
|
|
877
|
+
parentConversationId: z2.string().min(1),
|
|
878
|
+
childConversationId: z2.string().min(1),
|
|
879
|
+
input: z2.json()
|
|
880
|
+
}).strict(),
|
|
881
|
+
output: z2.object({ sent: z2.literal(true) }),
|
|
882
|
+
transports: ["AGENT"],
|
|
883
|
+
handler: async ({ input }) => {
|
|
884
|
+
await manager.sendMessage(input.parentConversationId, input.childConversationId, input.input);
|
|
885
|
+
return { sent: true };
|
|
886
|
+
}
|
|
887
|
+
}),
|
|
888
|
+
defineAgentTool({
|
|
889
|
+
name: "interrupt_agent",
|
|
890
|
+
description: "Stop one active child conversation at a durable policy boundary.",
|
|
891
|
+
identity: { serviceName: "agent-children", action: "interrupt", method: "POST" },
|
|
892
|
+
input: z2.object({
|
|
893
|
+
parentConversationId: z2.string().min(1),
|
|
894
|
+
childConversationId: z2.string().min(1)
|
|
895
|
+
}).strict(),
|
|
896
|
+
output: z2.object({ interrupted: z2.literal(true) }),
|
|
897
|
+
transports: ["AGENT"],
|
|
898
|
+
handler: async ({ input }) => {
|
|
899
|
+
await manager.interruptChild(input.parentConversationId, input.childConversationId);
|
|
900
|
+
return { interrupted: true };
|
|
901
|
+
}
|
|
902
|
+
})
|
|
903
|
+
];
|
|
904
|
+
}
|
|
905
|
+
// src/agent-runtime/compaction.ts
|
|
906
|
+
function groupProviderTurns(messages, evidencePolicy) {
|
|
907
|
+
const turns = [];
|
|
908
|
+
let current = [];
|
|
909
|
+
for (const message of messages) {
|
|
910
|
+
if (message.role === "user" && current.length > 0) {
|
|
911
|
+
turns.push({
|
|
912
|
+
messages: current,
|
|
913
|
+
complete: isCompleteAgentHistoryTurn(current, evidencePolicy)
|
|
914
|
+
});
|
|
915
|
+
current = [];
|
|
916
|
+
}
|
|
917
|
+
current.push(message);
|
|
918
|
+
}
|
|
919
|
+
if (current.length > 0) {
|
|
920
|
+
turns.push({
|
|
921
|
+
messages: current,
|
|
922
|
+
complete: isCompleteAgentHistoryTurn(current, evidencePolicy)
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
return turns;
|
|
926
|
+
}
|
|
927
|
+
function selectCompactableHistory(options) {
|
|
928
|
+
if (!Number.isSafeInteger(options.keepRecentTurns) || options.keepRecentTurns < 0) {
|
|
929
|
+
throw new TypeError("keepRecentTurns must be a non-negative safe integer");
|
|
930
|
+
}
|
|
931
|
+
const leadingSummary = options.messages[0]?.role === "summary" ? options.messages[0] : undefined;
|
|
932
|
+
const rest = leadingSummary ? options.messages.slice(1) : options.messages;
|
|
933
|
+
const turns = groupProviderTurns(rest, options.evidencePolicy);
|
|
934
|
+
const firstIncomplete = turns.findIndex((turn) => !turn.complete);
|
|
935
|
+
const completeTurns = firstIncomplete === -1 ? turns : turns.slice(0, firstIncomplete);
|
|
936
|
+
const eligibleCount = Math.max(0, completeTurns.length - options.keepRecentTurns);
|
|
937
|
+
const compactable = completeTurns.slice(0, eligibleCount).flatMap((turn) => turn.messages);
|
|
938
|
+
return {
|
|
939
|
+
...leadingSummary !== undefined && { leadingSummary },
|
|
940
|
+
compactable,
|
|
941
|
+
retained: rest.slice(compactable.length)
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
function mutationSnapshot(result, fallback, attempts) {
|
|
945
|
+
if (result.outcome === "applied" || result.outcome === "duplicate") {
|
|
946
|
+
return { outcome: "applied", snapshot: result.snapshot, attempts };
|
|
947
|
+
}
|
|
948
|
+
return { outcome: result.outcome, snapshot: fallback, attempts };
|
|
949
|
+
}
|
|
950
|
+
function structuredCompaction(config) {
|
|
951
|
+
if (!Number.isSafeInteger(config.keepRecentTurns) || config.keepRecentTurns < 1) {
|
|
952
|
+
throw new TypeError("keepRecentTurns must be a positive safe integer");
|
|
953
|
+
}
|
|
954
|
+
const maxAttempts = config.maxAttempts ?? 1;
|
|
955
|
+
if (!Number.isSafeInteger(maxAttempts) || maxAttempts < 1) {
|
|
956
|
+
throw new TypeError("maxAttempts must be a positive safe integer");
|
|
957
|
+
}
|
|
958
|
+
return async (input) => {
|
|
959
|
+
let lastSnapshot = await input.store.loadSnapshot(input.conversationId);
|
|
960
|
+
for (let attempt = 1;attempt <= maxAttempts; attempt += 1) {
|
|
961
|
+
const snapshot = attempt === 1 ? lastSnapshot : await input.store.loadSnapshot(input.conversationId);
|
|
962
|
+
lastSnapshot = snapshot;
|
|
963
|
+
if (!await config.threshold(snapshot)) {
|
|
964
|
+
return { outcome: "not_needed", snapshot, attempts: attempt };
|
|
965
|
+
}
|
|
966
|
+
const { leadingSummary, compactable: eligibleMessages } = selectCompactableHistory({
|
|
967
|
+
messages: snapshot.messages,
|
|
968
|
+
keepRecentTurns: config.keepRecentTurns,
|
|
969
|
+
...config.evidencePolicy !== undefined && { evidencePolicy: config.evidencePolicy }
|
|
970
|
+
});
|
|
971
|
+
if (eligibleMessages.length === 0) {
|
|
972
|
+
return { outcome: "nothing_eligible", snapshot, attempts: attempt };
|
|
973
|
+
}
|
|
974
|
+
const previousSummary = leadingSummary && config.readPreviousSummary ? config.schema.parse(config.readPreviousSummary(leadingSummary)) : attempt === 1 ? input.previousSummary : undefined;
|
|
975
|
+
const rawSummary = await config.summarize({
|
|
976
|
+
conversationId: input.conversationId,
|
|
977
|
+
snapshot,
|
|
978
|
+
eligibleMessages,
|
|
979
|
+
...previousSummary !== undefined && { previousSummary },
|
|
980
|
+
signal: input.signal
|
|
981
|
+
});
|
|
982
|
+
const summary = config.schema.parse(rawSummary);
|
|
983
|
+
if (input.signal.aborted)
|
|
984
|
+
throw input.signal.reason;
|
|
985
|
+
const summaryMessage = config.createSummaryMessage({
|
|
986
|
+
conversationId: input.conversationId,
|
|
987
|
+
summary,
|
|
988
|
+
compactedMessages: eligibleMessages
|
|
989
|
+
});
|
|
990
|
+
if (summaryMessage.role !== "summary" || summaryMessage.status !== "committed") {
|
|
991
|
+
throw new TypeError("Compaction summary must be one committed summary message");
|
|
992
|
+
}
|
|
993
|
+
const applied = await input.store.replaceCompactedRange({
|
|
994
|
+
conversationId: input.conversationId,
|
|
995
|
+
expectedVersion: snapshot.version,
|
|
996
|
+
replacedMessageIds: [
|
|
997
|
+
...leadingSummary ? [leadingSummary.id] : [],
|
|
998
|
+
...eligibleMessages.map((message) => message.id)
|
|
999
|
+
],
|
|
1000
|
+
summary: summaryMessage
|
|
1001
|
+
});
|
|
1002
|
+
if (applied.outcome !== "conflict" || attempt === maxAttempts) {
|
|
1003
|
+
return mutationSnapshot(applied, snapshot, attempt);
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
return { outcome: "conflict", snapshot: lastSnapshot, attempts: maxAttempts };
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
// src/agent-runtime/deferred-tool-types.ts
|
|
1010
|
+
import { z as z3 } from "zod";
|
|
1011
|
+
var DeferredAgentToolSearchInputSchema = z3.object({
|
|
1012
|
+
query: z3.string().min(1).describe("An exact tool name, or words describing the tool. Matched as one phrase first, then word by word."),
|
|
1013
|
+
reason: z3.enum(["inactive_call"]).optional()
|
|
1014
|
+
});
|
|
1015
|
+
var DeferredAgentToolMatchSchema = z3.object({
|
|
1016
|
+
name: z3.string(),
|
|
1017
|
+
description: z3.string()
|
|
1018
|
+
});
|
|
1019
|
+
var DeferredAgentToolReceiptSchema = z3.object({
|
|
1020
|
+
schemaVersion: z3.literal(1),
|
|
1021
|
+
kind: z3.literal("stitchkit.deferred-tool-selection"),
|
|
1022
|
+
status: z3.enum(["SELECTED", "SEARCH_REQUIRED", "NO_MATCH", "SELECTION_REFUSED"]),
|
|
1023
|
+
runId: z3.string(),
|
|
1024
|
+
surfaceKey: z3.string(),
|
|
1025
|
+
selected: z3.array(z3.string()),
|
|
1026
|
+
matches: z3.array(DeferredAgentToolMatchSchema),
|
|
1027
|
+
truncated: z3.boolean()
|
|
1028
|
+
}).superRefine((receipt, context) => {
|
|
1029
|
+
const selected = receipt.status === "SELECTED" || receipt.status === "SEARCH_REQUIRED";
|
|
1030
|
+
if (selected !== receipt.selected.length > 0) {
|
|
1031
|
+
context.addIssue({
|
|
1032
|
+
code: "custom",
|
|
1033
|
+
path: ["selected"],
|
|
1034
|
+
message: `${receipt.status} receipt has inconsistent selected tools`
|
|
1035
|
+
});
|
|
1036
|
+
}
|
|
1037
|
+
});
|
|
1038
|
+
|
|
1039
|
+
// src/agent-runtime/deferred-tool-selection.ts
|
|
1040
|
+
var encoder = new TextEncoder;
|
|
1041
|
+
function utf8Bytes(value) {
|
|
1042
|
+
return encoder.encode(typeof value === "string" ? value : JSON.stringify(value)).byteLength;
|
|
1043
|
+
}
|
|
1044
|
+
function positive(name, value) {
|
|
1045
|
+
if (!Number.isInteger(value) || value <= 0)
|
|
1046
|
+
throw new Error(`${name} must be a positive integer`);
|
|
1047
|
+
}
|
|
1048
|
+
function uniqueKnown(names, surface) {
|
|
1049
|
+
const seen = new Set;
|
|
1050
|
+
let rejected = 0;
|
|
1051
|
+
for (const name of names) {
|
|
1052
|
+
if (seen.has(name) || !surface.byName.has(name)) {
|
|
1053
|
+
rejected += 1;
|
|
1054
|
+
continue;
|
|
1055
|
+
}
|
|
1056
|
+
seen.add(name);
|
|
1057
|
+
}
|
|
1058
|
+
return { names: [...seen], rejected };
|
|
1059
|
+
}
|
|
1060
|
+
function schemaBytes(names, surface) {
|
|
1061
|
+
let bytes = 0;
|
|
1062
|
+
for (const name of names) {
|
|
1063
|
+
const entry = name === surface.searchEntry.name ? surface.searchEntry : surface.byName.get(name);
|
|
1064
|
+
if (entry)
|
|
1065
|
+
bytes += utf8Bytes(entry);
|
|
1066
|
+
}
|
|
1067
|
+
return bytes;
|
|
1068
|
+
}
|
|
1069
|
+
function ranked(query, manifest) {
|
|
1070
|
+
const phrase = rankedByPhrase(query, manifest);
|
|
1071
|
+
return phrase.length > 0 ? phrase : rankedByWords(query, manifest);
|
|
1072
|
+
}
|
|
1073
|
+
function rankedByWords(query, manifest) {
|
|
1074
|
+
const words = [
|
|
1075
|
+
...new Set(query.trim().toLocaleLowerCase().split(/\s+/u).filter((word) => word.length > 0))
|
|
1076
|
+
];
|
|
1077
|
+
if (words.length < 2)
|
|
1078
|
+
return [];
|
|
1079
|
+
return manifest.map((entry, order) => {
|
|
1080
|
+
const haystack = `${entry.name} ${entry.description}`.toLocaleLowerCase();
|
|
1081
|
+
const hits = words.filter((word) => haystack.includes(word)).length;
|
|
1082
|
+
return { name: entry.name, order, hits };
|
|
1083
|
+
}).filter((entry) => entry.hits > 0).sort((left, right) => right.hits - left.hits || left.order - right.order).map((entry) => entry.name);
|
|
1084
|
+
}
|
|
1085
|
+
function rankedByPhrase(query, manifest) {
|
|
1086
|
+
const needle = query.trim().toLocaleLowerCase();
|
|
1087
|
+
return manifest.map((entry, order) => {
|
|
1088
|
+
const name = entry.name.toLocaleLowerCase();
|
|
1089
|
+
const description = entry.description.toLocaleLowerCase();
|
|
1090
|
+
const score = name === needle ? 0 : name.startsWith(needle) ? 1 : name.split(/[_-]/u).some((token) => token.startsWith(needle)) ? 2 : name.includes(needle) ? 3 : description.includes(needle) ? 4 : 5;
|
|
1091
|
+
return { name: entry.name, order, score };
|
|
1092
|
+
}).filter((entry) => entry.score < 5).sort((left, right) => left.score - right.score || left.order - right.order).map((entry) => entry.name);
|
|
1093
|
+
}
|
|
1094
|
+
function latestSelection(messages, searchName, runId, surface, maxSelectedTools) {
|
|
1095
|
+
let selected = [];
|
|
1096
|
+
let found = false;
|
|
1097
|
+
for (const message of messages) {
|
|
1098
|
+
if (message.role !== "tool" || typeof message.content === "string")
|
|
1099
|
+
continue;
|
|
1100
|
+
const replacement = [];
|
|
1101
|
+
let validReceipts = 0;
|
|
1102
|
+
for (const part of message.content) {
|
|
1103
|
+
if (part.type !== "tool-result" || part.toolName !== searchName)
|
|
1104
|
+
continue;
|
|
1105
|
+
if (part.output.type !== "json")
|
|
1106
|
+
continue;
|
|
1107
|
+
const parsed = DeferredAgentToolReceiptSchema.safeParse(part.output.value);
|
|
1108
|
+
if (!parsed.success || parsed.data.runId !== runId || parsed.data.surfaceKey !== surface.key)
|
|
1109
|
+
continue;
|
|
1110
|
+
const known = uniqueKnown(parsed.data.selected, surface);
|
|
1111
|
+
if (known.rejected > 0 || known.names.length !== parsed.data.selected.length)
|
|
1112
|
+
continue;
|
|
1113
|
+
replacement.push(...known.names);
|
|
1114
|
+
validReceipts += 1;
|
|
1115
|
+
}
|
|
1116
|
+
if (validReceipts > 0) {
|
|
1117
|
+
const merged = uniqueKnown(replacement, surface).names;
|
|
1118
|
+
if (merged.length > maxSelectedTools)
|
|
1119
|
+
continue;
|
|
1120
|
+
selected = merged;
|
|
1121
|
+
found = true;
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
return { selected, source: found ? "durable" : "catalog" };
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
// src/agent-runtime/deferred-tool-search.ts
|
|
1128
|
+
var description = "Search the available tool catalog and select exact tools for the next step. " + "The query is matched as one phrase against tool names and descriptions; " + "if nothing matches the phrase, its individual words are matched and the " + "tools matching the most words rank first. An exact tool name always wins, " + "so prefer one when you know it.";
|
|
1129
|
+
function placeholderDeferredSearch(name) {
|
|
1130
|
+
return defineRuntimeTool({
|
|
1131
|
+
name,
|
|
1132
|
+
description,
|
|
1133
|
+
identity: { serviceName: "agent-runtime", action: "deferred-tool-search", method: "POST" },
|
|
1134
|
+
input: DeferredAgentToolSearchInputSchema,
|
|
1135
|
+
output: DeferredAgentToolReceiptSchema,
|
|
1136
|
+
transports: ["AGENT"],
|
|
1137
|
+
handler: () => ({
|
|
1138
|
+
schemaVersion: 1,
|
|
1139
|
+
kind: "stitchkit.deferred-tool-selection",
|
|
1140
|
+
status: "NO_MATCH",
|
|
1141
|
+
runId: "construction",
|
|
1142
|
+
surfaceKey: "construction",
|
|
1143
|
+
selected: [],
|
|
1144
|
+
matches: [],
|
|
1145
|
+
truncated: false
|
|
1146
|
+
})
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
function createDeferredSearchTool(config, runContext, surface) {
|
|
1150
|
+
return defineRuntimeTool({
|
|
1151
|
+
name: config.search.name,
|
|
1152
|
+
description,
|
|
1153
|
+
identity: { serviceName: "agent-runtime", action: "deferred-tool-search", method: "POST" },
|
|
1154
|
+
input: DeferredAgentToolSearchInputSchema,
|
|
1155
|
+
output: DeferredAgentToolReceiptSchema,
|
|
1156
|
+
transports: ["AGENT"],
|
|
1157
|
+
handler: async ({ input }) => {
|
|
1158
|
+
const queryOversized = utf8Bytes(input.query) > config.search.maxQueryBytes;
|
|
1159
|
+
const proposed = queryOversized ? [] : input.reason === "inactive_call" ? [input.query] : config.search.select ? await config.search.select({
|
|
1160
|
+
query: input.query,
|
|
1161
|
+
manifest: surface.manifest,
|
|
1162
|
+
context: runContext.context,
|
|
1163
|
+
runId: runContext.run.id,
|
|
1164
|
+
surfaceKey: surface.key
|
|
1165
|
+
}) : ranked(input.query, surface.manifest);
|
|
1166
|
+
const known = uniqueKnown(proposed, surface);
|
|
1167
|
+
const selected = known.names.slice(0, config.search.maxResults);
|
|
1168
|
+
const candidateActive = [config.search.name, ...surface.alwaysOn, ...selected];
|
|
1169
|
+
const refused = queryOversized || selected.length > config.activation.maxSelectedTools || candidateActive.length > config.activation.maxActiveTools || schemaBytes(candidateActive, surface) > config.activation.maxSchemaBytes;
|
|
1170
|
+
const admitted = refused ? [] : selected;
|
|
1171
|
+
const matches = [];
|
|
1172
|
+
let truncated = known.names.length > selected.length;
|
|
1173
|
+
for (const name of selected) {
|
|
1174
|
+
const entry = surface.byName.get(name);
|
|
1175
|
+
if (!entry)
|
|
1176
|
+
continue;
|
|
1177
|
+
const next = [...matches, { name, description: entry.description }];
|
|
1178
|
+
if (utf8Bytes({
|
|
1179
|
+
schemaVersion: 1,
|
|
1180
|
+
kind: "stitchkit.deferred-tool-selection",
|
|
1181
|
+
status: "SELECTED",
|
|
1182
|
+
runId: runContext.run.id,
|
|
1183
|
+
surfaceKey: surface.key,
|
|
1184
|
+
selected: admitted,
|
|
1185
|
+
matches: next,
|
|
1186
|
+
truncated
|
|
1187
|
+
}) > config.search.maxResultBytes) {
|
|
1188
|
+
truncated = true;
|
|
1189
|
+
break;
|
|
1190
|
+
}
|
|
1191
|
+
matches.push({ name, description: entry.description });
|
|
1192
|
+
}
|
|
1193
|
+
const status = refused ? "SELECTION_REFUSED" : input.reason === "inactive_call" && admitted.length > 0 ? "SEARCH_REQUIRED" : admitted.length > 0 ? "SELECTED" : "NO_MATCH";
|
|
1194
|
+
let receipt = {
|
|
1195
|
+
schemaVersion: 1,
|
|
1196
|
+
kind: "stitchkit.deferred-tool-selection",
|
|
1197
|
+
status,
|
|
1198
|
+
runId: runContext.run.id,
|
|
1199
|
+
surfaceKey: surface.key,
|
|
1200
|
+
selected: admitted,
|
|
1201
|
+
matches,
|
|
1202
|
+
truncated
|
|
1203
|
+
};
|
|
1204
|
+
if (utf8Bytes(receipt) > config.search.maxResultBytes) {
|
|
1205
|
+
receipt = {
|
|
1206
|
+
schemaVersion: 1,
|
|
1207
|
+
kind: "stitchkit.deferred-tool-selection",
|
|
1208
|
+
status: "SELECTION_REFUSED",
|
|
1209
|
+
runId: runContext.run.id,
|
|
1210
|
+
surfaceKey: surface.key,
|
|
1211
|
+
selected: [],
|
|
1212
|
+
matches: [],
|
|
1213
|
+
truncated: true
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1216
|
+
if (utf8Bytes(receipt) > config.search.maxResultBytes) {
|
|
1217
|
+
throw new AgentContextOverflowError("Deferred Agent search receipt exceeds its byte ceiling");
|
|
1218
|
+
}
|
|
1219
|
+
config.observe?.({
|
|
1220
|
+
schemaVersion: 1,
|
|
1221
|
+
type: "search",
|
|
1222
|
+
runId: runContext.run.id,
|
|
1223
|
+
surfaceKey: surface.key,
|
|
1224
|
+
catalogTools: surface.manifest.length,
|
|
1225
|
+
baseTools: surface.alwaysOn.length + 1,
|
|
1226
|
+
pinnedTools: 0,
|
|
1227
|
+
selectedTools: receipt.selected.length,
|
|
1228
|
+
activeTools: surface.alwaysOn.length + receipt.selected.length + 1,
|
|
1229
|
+
activeSchemaBytes: schemaBytes([config.search.name, ...surface.alwaysOn, ...receipt.selected], surface),
|
|
1230
|
+
rejectedNames: known.rejected,
|
|
1231
|
+
replacementTools: receipt.selected.length,
|
|
1232
|
+
source: "current"
|
|
1233
|
+
});
|
|
1234
|
+
return receipt;
|
|
1235
|
+
}
|
|
1236
|
+
});
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
// src/agent-runtime/deferred-tools.ts
|
|
1240
|
+
function configuredSurfaces(config) {
|
|
1241
|
+
return "surfaces" in config ? config.surfaces : { default: config };
|
|
1242
|
+
}
|
|
1243
|
+
function resolveSurface(config, surfaces, runContext) {
|
|
1244
|
+
const key = "surfaces" in config ? config.selectSurface(runContext) : "default";
|
|
1245
|
+
const surface = surfaces.get(key);
|
|
1246
|
+
if (!surface)
|
|
1247
|
+
throw new Error(`Unknown deferred Agent tool surface "${key}"`);
|
|
1248
|
+
return surface;
|
|
1249
|
+
}
|
|
1250
|
+
function resolveAllSurfaces(config) {
|
|
1251
|
+
const placeholderSearch = placeholderDeferredSearch(config.search.name);
|
|
1252
|
+
const surfaces = new Map;
|
|
1253
|
+
for (const [key, definition] of Object.entries(configuredSurfaces(config))) {
|
|
1254
|
+
const runtimeTools = executableAgentRuntimeTools(definition.runtimeTools ?? []);
|
|
1255
|
+
const fullManifest = buildToolManifest({
|
|
1256
|
+
...definition,
|
|
1257
|
+
runtimeTools: [...runtimeTools, placeholderSearch],
|
|
1258
|
+
transport: "AGENT"
|
|
1259
|
+
});
|
|
1260
|
+
const searchEntry = fullManifest.find((entry) => entry.name === config.search.name);
|
|
1261
|
+
if (!searchEntry)
|
|
1262
|
+
throw new Error(`Search tool "${config.search.name}" is not Agent-exposed`);
|
|
1263
|
+
const manifest = fullManifest.filter((entry) => entry.name !== config.search.name);
|
|
1264
|
+
const byName = new Map(manifest.map((entry) => [entry.name, entry]));
|
|
1265
|
+
const provisional = {
|
|
1266
|
+
key,
|
|
1267
|
+
definition,
|
|
1268
|
+
manifest,
|
|
1269
|
+
byName,
|
|
1270
|
+
searchEntry,
|
|
1271
|
+
alwaysOn: []
|
|
1272
|
+
};
|
|
1273
|
+
const alwaysOn = uniqueKnown(definition.alwaysOn ?? [], provisional);
|
|
1274
|
+
if (alwaysOn.rejected > 0)
|
|
1275
|
+
throw new Error(`Surface "${key}" has an unknown or duplicate alwaysOn tool`);
|
|
1276
|
+
surfaces.set(key, { ...provisional, alwaysOn: alwaysOn.names });
|
|
1277
|
+
}
|
|
1278
|
+
if (surfaces.size === 0)
|
|
1279
|
+
throw new Error("Deferred Agent tool surface registry must not be empty");
|
|
1280
|
+
return surfaces;
|
|
1281
|
+
}
|
|
1282
|
+
function assertConstructionBudgets(config, surfaces) {
|
|
1283
|
+
for (const surface of surfaces.values()) {
|
|
1284
|
+
const base = [...surface.alwaysOn, config.search.name];
|
|
1285
|
+
if (base.length > config.activation.maxActiveTools) {
|
|
1286
|
+
throw new Error(`Surface "${surface.key}" base tools exceed maxActiveTools`);
|
|
1287
|
+
}
|
|
1288
|
+
if (schemaBytes(base, surface) > config.activation.maxSchemaBytes) {
|
|
1289
|
+
throw new Error(`Surface "${surface.key}" base tools exceed maxSchemaBytes`);
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
const minimumReceipt = {
|
|
1293
|
+
schemaVersion: 1,
|
|
1294
|
+
kind: "stitchkit.deferred-tool-selection",
|
|
1295
|
+
status: "NO_MATCH",
|
|
1296
|
+
runId: "run",
|
|
1297
|
+
surfaceKey: "surface",
|
|
1298
|
+
selected: [],
|
|
1299
|
+
matches: [],
|
|
1300
|
+
truncated: false
|
|
1301
|
+
};
|
|
1302
|
+
if (config.search.maxResultBytes < utf8Bytes(minimumReceipt)) {
|
|
1303
|
+
throw new Error("search.maxResultBytes cannot contain the minimum search receipt");
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
function assertActiveBudget(config, names, surface) {
|
|
1307
|
+
if (names.length > config.activation.maxActiveTools) {
|
|
1308
|
+
throw new AgentContextOverflowError("Deferred Agent active-tool ceiling exceeded");
|
|
1309
|
+
}
|
|
1310
|
+
const bytes = schemaBytes(names, surface);
|
|
1311
|
+
if (bytes > config.activation.maxSchemaBytes) {
|
|
1312
|
+
throw new AgentContextOverflowError("Deferred Agent schema-byte ceiling exceeded");
|
|
1313
|
+
}
|
|
1314
|
+
return bytes;
|
|
1315
|
+
}
|
|
1316
|
+
function createDeferredAgentToolSurface(config) {
|
|
1317
|
+
positive("search.maxQueryBytes", config.search.maxQueryBytes);
|
|
1318
|
+
positive("search.maxResults", config.search.maxResults);
|
|
1319
|
+
positive("search.maxResultBytes", config.search.maxResultBytes);
|
|
1320
|
+
positive("activation.maxSelectedTools", config.activation.maxSelectedTools);
|
|
1321
|
+
positive("activation.maxActiveTools", config.activation.maxActiveTools);
|
|
1322
|
+
positive("activation.maxSchemaBytes", config.activation.maxSchemaBytes);
|
|
1323
|
+
const surfaces = resolveAllSurfaces(config);
|
|
1324
|
+
assertConstructionBudgets(config, surfaces);
|
|
1325
|
+
return {
|
|
1326
|
+
mount(runContext, mountConfig = {}) {
|
|
1327
|
+
const surface = resolveSurface(config, surfaces, runContext);
|
|
1328
|
+
const runtimeTools = [
|
|
1329
|
+
...executableAgentRuntimeTools(surface.definition.runtimeTools ?? []),
|
|
1330
|
+
createDeferredSearchTool(config, runContext, surface)
|
|
1331
|
+
];
|
|
1332
|
+
const tools = mountAgent([...surface.definition.services ?? []], {
|
|
1333
|
+
...mountConfig,
|
|
1334
|
+
runtimeTools
|
|
1335
|
+
});
|
|
1336
|
+
registerDeferredToolCatalog(tools, config.search.name, new Set(surface.byName.keys()));
|
|
1337
|
+
return tools;
|
|
1338
|
+
},
|
|
1339
|
+
prepareStep(applicationPrepareStep) {
|
|
1340
|
+
const prepared = async (input) => {
|
|
1341
|
+
const application = await applicationPrepareStep?.(input);
|
|
1342
|
+
const surface = resolveSurface(config, surfaces, input);
|
|
1343
|
+
const selection = latestSelection(input.messages, config.search.name, input.run.id, surface, config.activation.maxSelectedTools);
|
|
1344
|
+
const currentSelection = latestSelection(input.responseMessages, config.search.name, input.run.id, surface, config.activation.maxSelectedTools);
|
|
1345
|
+
const pins = uniqueKnown(config.pins?.(input) ?? [], surface);
|
|
1346
|
+
if (pins.rejected > 0) {
|
|
1347
|
+
throw new AgentContextOverflowError("Deferred Agent pins contain unknown or duplicate tools");
|
|
1348
|
+
}
|
|
1349
|
+
const selected = uniqueKnown(selection.selected, surface);
|
|
1350
|
+
const names = uniqueKnown([config.search.name, ...surface.alwaysOn, ...pins.names, ...selected.names], surface).names;
|
|
1351
|
+
if (!names.includes(config.search.name))
|
|
1352
|
+
names.unshift(config.search.name);
|
|
1353
|
+
const bytes = assertActiveBudget(config, names, surface);
|
|
1354
|
+
config.observe?.({
|
|
1355
|
+
schemaVersion: 1,
|
|
1356
|
+
type: "step",
|
|
1357
|
+
runId: input.run.id,
|
|
1358
|
+
surfaceKey: surface.key,
|
|
1359
|
+
catalogTools: surface.manifest.length,
|
|
1360
|
+
baseTools: surface.alwaysOn.length + 1,
|
|
1361
|
+
pinnedTools: pins.names.length,
|
|
1362
|
+
selectedTools: selected.names.length,
|
|
1363
|
+
activeTools: names.length,
|
|
1364
|
+
activeSchemaBytes: bytes,
|
|
1365
|
+
rejectedNames: selected.rejected,
|
|
1366
|
+
replacementTools: selected.names.length,
|
|
1367
|
+
source: currentSelection.source === "durable" ? "current" : selection.source
|
|
1368
|
+
});
|
|
1369
|
+
return { ...application, activeTools: names };
|
|
1370
|
+
};
|
|
1371
|
+
const repair = async ({ toolCall, tools, error }) => {
|
|
1372
|
+
const catalog = deferredToolCatalog(tools, config.search.name);
|
|
1373
|
+
if (!("toolName" in error) || !catalog?.has(toolCall.toolName) || toolCall.toolName in tools) {
|
|
1374
|
+
return null;
|
|
1375
|
+
}
|
|
1376
|
+
return repairedSearchCall(toolCall, config.search.name);
|
|
1377
|
+
};
|
|
1378
|
+
registerDeferredToolRepair(prepared, repair);
|
|
1379
|
+
return prepared;
|
|
1380
|
+
}
|
|
1381
|
+
};
|
|
1382
|
+
}
|
|
1383
|
+
// src/agent-runtime/event-search.ts
|
|
1384
|
+
import { z as z4 } from "zod";
|
|
1385
|
+
var AgentEventSearchResultSchema = z4.object({
|
|
1386
|
+
conversationId: z4.string().min(1),
|
|
1387
|
+
seq: z4.int().positive(),
|
|
1388
|
+
occurredAt: z4.string(),
|
|
1389
|
+
snippet: z4.string()
|
|
1390
|
+
}).strict();
|
|
1391
|
+
var SearchRowSchema = z4.object({
|
|
1392
|
+
conversation_id: z4.string(),
|
|
1393
|
+
event_seq: z4.int().positive(),
|
|
1394
|
+
occurred_at: z4.string(),
|
|
1395
|
+
snippet: z4.string()
|
|
1396
|
+
});
|
|
1397
|
+
function literalFtsQuery(query) {
|
|
1398
|
+
const terms = query.split(/\s+/u).filter((term) => /[\p{L}\p{N}]/u.test(term));
|
|
1399
|
+
if (terms.length === 0)
|
|
1400
|
+
throw new TypeError("Event search query must contain searchable terms");
|
|
1401
|
+
return terms.map((term) => `"${term.replaceAll('"', '""')}"`).join(" AND ");
|
|
1402
|
+
}
|
|
1403
|
+
function createSqliteAgentEventSearch(input) {
|
|
1404
|
+
return async (request) => {
|
|
1405
|
+
if (request.query.trim().length === 0)
|
|
1406
|
+
throw new TypeError("Event search query must not be empty");
|
|
1407
|
+
const limit = Math.min(request.limit ?? 20, 200);
|
|
1408
|
+
const target = request.conversationId ?? (input.authorizeConversation ? undefined : request.requestingConversationId);
|
|
1409
|
+
const values = [literalFtsQuery(request.query)];
|
|
1410
|
+
const targetClause = target ? "AND f.conversation_id = ?" : "";
|
|
1411
|
+
if (target)
|
|
1412
|
+
values.push(target);
|
|
1413
|
+
const sinceClause = request.since ? "AND f.occurred_at >= ?" : "";
|
|
1414
|
+
if (request.since)
|
|
1415
|
+
values.push(z4.iso.datetime({ offset: true }).parse(request.since));
|
|
1416
|
+
const page = limit * 4;
|
|
1417
|
+
const candidatesFrom = (offset2) => input.database.prepare(`
|
|
1418
|
+
SELECT f.conversation_id, f.event_seq, f.occurred_at,
|
|
1419
|
+
snippet(stitchkit_agent_runtime_events_fts, 3, '[', ']', ' … ', 24) AS snippet
|
|
1420
|
+
FROM stitchkit_agent_runtime_events_fts AS f
|
|
1421
|
+
WHERE stitchkit_agent_runtime_events_fts MATCH ? ${targetClause} ${sinceClause}
|
|
1422
|
+
ORDER BY bm25(stitchkit_agent_runtime_events_fts), f.occurred_at DESC, f.rowid
|
|
1423
|
+
LIMIT ? OFFSET ?
|
|
1424
|
+
`).all(...values, page, offset2).map((row) => SearchRowSchema.parse(row));
|
|
1425
|
+
const authorization = new Map;
|
|
1426
|
+
const results = [];
|
|
1427
|
+
let offset = 0;
|
|
1428
|
+
let candidates = candidatesFrom(offset);
|
|
1429
|
+
while (candidates.length > 0 && results.length < limit) {
|
|
1430
|
+
for (const row of candidates) {
|
|
1431
|
+
if (row.conversation_id !== request.requestingConversationId) {
|
|
1432
|
+
let allowed = authorization.get(row.conversation_id);
|
|
1433
|
+
if (allowed === undefined) {
|
|
1434
|
+
allowed = input.authorizeConversation ? await input.authorizeConversation({
|
|
1435
|
+
requestingConversationId: request.requestingConversationId,
|
|
1436
|
+
targetConversationId: row.conversation_id
|
|
1437
|
+
}) : false;
|
|
1438
|
+
authorization.set(row.conversation_id, allowed);
|
|
1439
|
+
}
|
|
1440
|
+
if (!allowed)
|
|
1441
|
+
continue;
|
|
1442
|
+
}
|
|
1443
|
+
results.push(AgentEventSearchResultSchema.parse({
|
|
1444
|
+
conversationId: row.conversation_id,
|
|
1445
|
+
seq: row.event_seq,
|
|
1446
|
+
occurredAt: row.occurred_at,
|
|
1447
|
+
snippet: row.snippet
|
|
1448
|
+
}));
|
|
1449
|
+
if (results.length === limit)
|
|
1450
|
+
break;
|
|
1451
|
+
}
|
|
1452
|
+
offset += page;
|
|
1453
|
+
candidates = results.length < limit ? candidatesFrom(offset) : [];
|
|
1454
|
+
}
|
|
1455
|
+
return results;
|
|
1456
|
+
};
|
|
1457
|
+
}
|
|
1458
|
+
// src/agent-runtime/event-search-tools.ts
|
|
1459
|
+
import { z as z5 } from "zod";
|
|
1460
|
+
function createAgentEventSearchTools(input) {
|
|
1461
|
+
const EventAddressSchema = z5.object({ conversationId: z5.string(), seq: z5.int().positive() }).strict();
|
|
1462
|
+
const EventOutputSchema = z5.object({
|
|
1463
|
+
conversationId: z5.string(),
|
|
1464
|
+
seq: z5.int().positive(),
|
|
1465
|
+
kind: z5.string(),
|
|
1466
|
+
occurredAt: z5.string(),
|
|
1467
|
+
payload: z5.json()
|
|
1468
|
+
}).strict();
|
|
1469
|
+
const readExact = async (address) => {
|
|
1470
|
+
if (address.conversationId !== input.conversationId) {
|
|
1471
|
+
const allowed = await input.authorizeConversation?.({
|
|
1472
|
+
requestingConversationId: input.conversationId,
|
|
1473
|
+
targetConversationId: address.conversationId
|
|
1474
|
+
});
|
|
1475
|
+
if (!allowed)
|
|
1476
|
+
throw new TypeError("Event address is outside the authorized conversation");
|
|
1477
|
+
}
|
|
1478
|
+
const page = await input.store.readEvents({
|
|
1479
|
+
conversationId: address.conversationId,
|
|
1480
|
+
fromSeq: address.seq,
|
|
1481
|
+
toSeq: address.seq,
|
|
1482
|
+
limit: 1
|
|
1483
|
+
});
|
|
1484
|
+
const event = page.items[0];
|
|
1485
|
+
if (!event || event.seq !== address.seq)
|
|
1486
|
+
throw new TypeError("Unknown event address");
|
|
1487
|
+
return {
|
|
1488
|
+
conversationId: event.conversationId,
|
|
1489
|
+
seq: event.seq,
|
|
1490
|
+
kind: event.kind,
|
|
1491
|
+
occurredAt: event.occurredAt,
|
|
1492
|
+
payload: event.payload
|
|
1493
|
+
};
|
|
1494
|
+
};
|
|
1495
|
+
return [
|
|
1496
|
+
defineAgentTool({
|
|
1497
|
+
name: "session_search",
|
|
1498
|
+
description: "Search authorized durable conversation events and return exact addresses.",
|
|
1499
|
+
identity: { serviceName: "agent-events", action: "search", method: "POST" },
|
|
1500
|
+
input: z5.object({
|
|
1501
|
+
query: z5.string().min(1),
|
|
1502
|
+
conversationId: z5.string().min(1).optional(),
|
|
1503
|
+
since: z5.iso.datetime({ offset: true }).optional(),
|
|
1504
|
+
limit: z5.int().positive().max(200).optional()
|
|
1505
|
+
}).strict(),
|
|
1506
|
+
output: z5.object({ results: z5.array(AgentEventSearchResultSchema) }).strict(),
|
|
1507
|
+
transports: ["AGENT"],
|
|
1508
|
+
handler: async ({ input: request }) => ({
|
|
1509
|
+
results: [
|
|
1510
|
+
...await input.search({
|
|
1511
|
+
requestingConversationId: input.conversationId,
|
|
1512
|
+
...request
|
|
1513
|
+
})
|
|
1514
|
+
]
|
|
1515
|
+
})
|
|
1516
|
+
}),
|
|
1517
|
+
defineAgentTool({
|
|
1518
|
+
name: "session_trace",
|
|
1519
|
+
description: "Read a bounded contiguous slice of this conversation event trace.",
|
|
1520
|
+
identity: { serviceName: "agent-events", action: "trace", method: "GET" },
|
|
1521
|
+
input: z5.object({
|
|
1522
|
+
fromSeq: z5.int().positive().optional(),
|
|
1523
|
+
toSeq: z5.int().positive().optional(),
|
|
1524
|
+
limit: z5.int().positive().max(1000).default(100)
|
|
1525
|
+
}).strict(),
|
|
1526
|
+
output: z5.object({ events: z5.array(EventOutputSchema), nextSeq: z5.number().optional() }),
|
|
1527
|
+
transports: ["AGENT"],
|
|
1528
|
+
handler: async ({ input: request }) => {
|
|
1529
|
+
const page = await input.store.readEvents({
|
|
1530
|
+
conversationId: input.conversationId,
|
|
1531
|
+
...request
|
|
1532
|
+
});
|
|
1533
|
+
return {
|
|
1534
|
+
events: page.items.map((event) => ({
|
|
1535
|
+
conversationId: event.conversationId,
|
|
1536
|
+
seq: event.seq,
|
|
1537
|
+
kind: event.kind,
|
|
1538
|
+
occurredAt: event.occurredAt,
|
|
1539
|
+
payload: event.payload
|
|
1540
|
+
})),
|
|
1541
|
+
...page.nextSeq !== undefined && { nextSeq: page.nextSeq }
|
|
1542
|
+
};
|
|
1543
|
+
}
|
|
1544
|
+
}),
|
|
1545
|
+
defineAgentTool({
|
|
1546
|
+
name: "session_event",
|
|
1547
|
+
description: "Read one durable event by exact conversation and sequence address.",
|
|
1548
|
+
identity: { serviceName: "agent-events", action: "read", method: "GET" },
|
|
1549
|
+
input: EventAddressSchema,
|
|
1550
|
+
output: EventOutputSchema,
|
|
1551
|
+
transports: ["AGENT"],
|
|
1552
|
+
handler: ({ input: request }) => readExact(request)
|
|
1553
|
+
})
|
|
1554
|
+
];
|
|
1555
|
+
}
|
|
1556
|
+
// src/agent-runtime/observability.ts
|
|
1557
|
+
import { z as z6 } from "zod";
|
|
1558
|
+
var AgentRunEventBaseSchema = z6.object({
|
|
1559
|
+
schemaVersion: z6.literal(1),
|
|
1560
|
+
eventId: AgentRecordIdSchema,
|
|
1561
|
+
conversationId: AgentRecordIdSchema,
|
|
1562
|
+
runId: AgentRecordIdSchema,
|
|
1563
|
+
traceId: z6.string().min(1),
|
|
1564
|
+
spanId: z6.string().min(1),
|
|
1565
|
+
parentSpanId: z6.string().min(1).optional(),
|
|
1566
|
+
state: AgentRunStateSchema,
|
|
1567
|
+
modelId: z6.string().min(1).optional(),
|
|
1568
|
+
durationMs: z6.number().nonnegative().optional(),
|
|
1569
|
+
emittedAt: AgentTimestampSchema
|
|
1570
|
+
});
|
|
1571
|
+
var AgentRunStartedEventSchema = AgentRunEventBaseSchema.extend({
|
|
1572
|
+
type: z6.literal("run-started"),
|
|
1573
|
+
queueWaitMs: z6.number().nonnegative().optional()
|
|
1574
|
+
});
|
|
1575
|
+
var AgentStepFinishedEventSchema = AgentRunEventBaseSchema.extend({
|
|
1576
|
+
type: z6.literal("step-finished"),
|
|
1577
|
+
step: z6.int().nonnegative(),
|
|
1578
|
+
ttftMs: z6.number().nonnegative().optional(),
|
|
1579
|
+
usage: AgentUsageSchema,
|
|
1580
|
+
response: AgentProviderResponseSchema
|
|
1581
|
+
});
|
|
1582
|
+
var AgentRunTerminalEventSchema = AgentRunEventBaseSchema.extend({
|
|
1583
|
+
type: z6.literal("run-terminal"),
|
|
1584
|
+
terminalReason: AgentTerminalReasonSchema,
|
|
1585
|
+
ttftMs: z6.number().nonnegative().optional(),
|
|
1586
|
+
internalCause: z6.unknown().optional(),
|
|
1587
|
+
usage: AgentUsageSchema
|
|
1588
|
+
});
|
|
1589
|
+
var AgentRunEventSchema = z6.discriminatedUnion("type", [
|
|
1590
|
+
AgentRunStartedEventSchema,
|
|
1591
|
+
AgentStepFinishedEventSchema,
|
|
1592
|
+
AgentRunTerminalEventSchema
|
|
1593
|
+
]);
|
|
1594
|
+
function createAgentObservability(config) {
|
|
1595
|
+
const manager = createBoundedSinkManager({
|
|
1596
|
+
write: config.write,
|
|
1597
|
+
...config.filter && { filter: config.filter },
|
|
1598
|
+
...config.maxPending !== undefined && { maxPending: config.maxPending },
|
|
1599
|
+
...config.onSinkError && { onSinkError: config.onSinkError },
|
|
1600
|
+
...config.onDrop && { onDrop: config.onDrop }
|
|
1601
|
+
});
|
|
1602
|
+
const DEDUPLICATION_WINDOW = 1e4;
|
|
1603
|
+
const emitted = new Set;
|
|
1604
|
+
const ring = new Array(DEDUPLICATION_WINDOW).fill(undefined);
|
|
1605
|
+
let cursor = 0;
|
|
1606
|
+
const remember = (eventId) => {
|
|
1607
|
+
emitted.add(eventId);
|
|
1608
|
+
const evicted = ring[cursor];
|
|
1609
|
+
ring[cursor] = eventId;
|
|
1610
|
+
cursor = (cursor + 1) % DEDUPLICATION_WINDOW;
|
|
1611
|
+
if (evicted !== undefined)
|
|
1612
|
+
emitted.delete(evicted);
|
|
1613
|
+
};
|
|
1614
|
+
return {
|
|
1615
|
+
rootTrace(parent) {
|
|
1616
|
+
const trace = parent ? childSpan(parent) : createTraceContext();
|
|
1617
|
+
return trace;
|
|
1618
|
+
},
|
|
1619
|
+
emit(rawEvent) {
|
|
1620
|
+
const parsed = AgentRunEventSchema.parse(rawEvent);
|
|
1621
|
+
if ((config.deduplicate ?? true) && emitted.has(parsed.eventId))
|
|
1622
|
+
return;
|
|
1623
|
+
remember(parsed.eventId);
|
|
1624
|
+
manager.submit(() => {
|
|
1625
|
+
if (config.includeInternalCause)
|
|
1626
|
+
return parsed;
|
|
1627
|
+
if (parsed.type !== "run-terminal")
|
|
1628
|
+
return parsed;
|
|
1629
|
+
return AgentRunTerminalEventSchema.omit({ internalCause: true }).parse(parsed);
|
|
1630
|
+
});
|
|
1631
|
+
},
|
|
1632
|
+
flush: (bound) => manager.flush(bound),
|
|
1633
|
+
getStatus: () => manager.getStatus(),
|
|
1634
|
+
close: (bound) => manager.close(bound)
|
|
1635
|
+
};
|
|
1636
|
+
}
|
|
1637
|
+
// src/agent-runtime/projections.ts
|
|
1638
|
+
import { z as z7 } from "zod";
|
|
1639
|
+
function defineAgentProjection(definition) {
|
|
1640
|
+
if (definition.name.length === 0)
|
|
1641
|
+
throw new TypeError("Projection name must not be empty");
|
|
1642
|
+
if (!Number.isInteger(definition.version) || definition.version < 1) {
|
|
1643
|
+
throw new TypeError("Projection version must be a positive integer");
|
|
1644
|
+
}
|
|
1645
|
+
definition.schema.parse(definition.initial());
|
|
1646
|
+
return definition;
|
|
1647
|
+
}
|
|
1648
|
+
function createAgentProjectionRegistry(definitions) {
|
|
1649
|
+
const registry = new Map;
|
|
1650
|
+
for (const definition of definitions) {
|
|
1651
|
+
const previous = registry.get(definition.name);
|
|
1652
|
+
if (previous)
|
|
1653
|
+
throw new TypeError(`Duplicate agent projection: ${definition.name}`);
|
|
1654
|
+
registry.set(definition.name, definition);
|
|
1655
|
+
}
|
|
1656
|
+
return registry;
|
|
1657
|
+
}
|
|
1658
|
+
var ProjectionRowSchema = z7.object({
|
|
1659
|
+
conversation_id: z7.string().optional(),
|
|
1660
|
+
version: z7.int().positive(),
|
|
1661
|
+
upto_seq: z7.int().nonnegative(),
|
|
1662
|
+
payload: z7.string(),
|
|
1663
|
+
updated_at: z7.string()
|
|
1664
|
+
});
|
|
1665
|
+
function projectionPayload(value) {
|
|
1666
|
+
return JSON.parse(value);
|
|
1667
|
+
}
|
|
1668
|
+
function createSqliteAgentProjectionStore(input) {
|
|
1669
|
+
const database = input.sqlite.database;
|
|
1670
|
+
const store = input.sqlite.store;
|
|
1671
|
+
const load = (conversationId, definition) => {
|
|
1672
|
+
const raw = database.prepare(`
|
|
1673
|
+
SELECT version, upto_seq, payload, updated_at
|
|
1674
|
+
FROM stitchkit_agent_runtime_projections
|
|
1675
|
+
WHERE conversation_id = ? AND name = ?
|
|
1676
|
+
`).get(conversationId, definition.name);
|
|
1677
|
+
if (raw === null || raw === undefined)
|
|
1678
|
+
return;
|
|
1679
|
+
const row = ProjectionRowSchema.parse(raw);
|
|
1680
|
+
if (row.version !== definition.version)
|
|
1681
|
+
return;
|
|
1682
|
+
return {
|
|
1683
|
+
name: definition.name,
|
|
1684
|
+
version: row.version,
|
|
1685
|
+
uptoSeq: row.upto_seq,
|
|
1686
|
+
updatedAt: row.updated_at,
|
|
1687
|
+
value: definition.schema.parse(projectionPayload(row.payload))
|
|
1688
|
+
};
|
|
1689
|
+
};
|
|
1690
|
+
const advance = async (conversationId, definition) => {
|
|
1691
|
+
const current = load(conversationId, definition);
|
|
1692
|
+
let value = current?.value ?? definition.initial();
|
|
1693
|
+
let uptoSeq = current?.uptoSeq ?? 0;
|
|
1694
|
+
let cursor = uptoSeq + 1;
|
|
1695
|
+
let updatedAt = current?.updatedAt ?? new Date(0).toISOString();
|
|
1696
|
+
for (;; ) {
|
|
1697
|
+
const page = await store.readEvents({
|
|
1698
|
+
conversationId,
|
|
1699
|
+
fromSeq: cursor,
|
|
1700
|
+
limit: 1000
|
|
1701
|
+
});
|
|
1702
|
+
for (const event of page.items) {
|
|
1703
|
+
value = definition.schema.parse(definition.fold(value, event));
|
|
1704
|
+
uptoSeq = event.seq;
|
|
1705
|
+
updatedAt = event.occurredAt;
|
|
1706
|
+
}
|
|
1707
|
+
if (page.nextSeq === undefined)
|
|
1708
|
+
break;
|
|
1709
|
+
cursor = page.nextSeq;
|
|
1710
|
+
}
|
|
1711
|
+
await input.sqlite.transaction(async (scope) => {
|
|
1712
|
+
scope.database.prepare(`
|
|
1713
|
+
INSERT INTO stitchkit_agent_runtime_projections
|
|
1714
|
+
(conversation_id, name, version, upto_seq, payload, updated_at)
|
|
1715
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
1716
|
+
ON CONFLICT (conversation_id, name) DO UPDATE SET
|
|
1717
|
+
version = excluded.version,
|
|
1718
|
+
upto_seq = excluded.upto_seq,
|
|
1719
|
+
payload = excluded.payload,
|
|
1720
|
+
updated_at = excluded.updated_at
|
|
1721
|
+
`).run(conversationId, definition.name, definition.version, uptoSeq, JSON.stringify(value), updatedAt);
|
|
1722
|
+
});
|
|
1723
|
+
return { name: definition.name, version: definition.version, uptoSeq, updatedAt, value };
|
|
1724
|
+
};
|
|
1725
|
+
const list = (definition) => database.prepare(`
|
|
1726
|
+
SELECT conversation_id, version, upto_seq, payload, updated_at
|
|
1727
|
+
FROM stitchkit_agent_runtime_projections
|
|
1728
|
+
WHERE name = ? AND version = ? ORDER BY updated_at DESC, conversation_id
|
|
1729
|
+
`).all(definition.name, definition.version).map((raw) => {
|
|
1730
|
+
const row = ProjectionRowSchema.parse(raw);
|
|
1731
|
+
if (!row.conversation_id)
|
|
1732
|
+
throw new TypeError("Projection list row has no conversation id");
|
|
1733
|
+
return {
|
|
1734
|
+
conversationId: row.conversation_id,
|
|
1735
|
+
projection: {
|
|
1736
|
+
name: definition.name,
|
|
1737
|
+
version: row.version,
|
|
1738
|
+
uptoSeq: row.upto_seq,
|
|
1739
|
+
updatedAt: row.updated_at,
|
|
1740
|
+
value: definition.schema.parse(projectionPayload(row.payload))
|
|
1741
|
+
}
|
|
1742
|
+
};
|
|
1743
|
+
});
|
|
1744
|
+
return { load, advance, list };
|
|
1745
|
+
}
|
|
1746
|
+
var ConversationCardSchema = z7.object({
|
|
1747
|
+
eventCount: z7.int().nonnegative(),
|
|
1748
|
+
lastKind: z7.string().optional(),
|
|
1749
|
+
lastOccurredAt: z7.string().optional()
|
|
1750
|
+
});
|
|
1751
|
+
var agentConversationCardProjection = defineAgentProjection({
|
|
1752
|
+
name: "conversation-card",
|
|
1753
|
+
version: 1,
|
|
1754
|
+
schema: ConversationCardSchema,
|
|
1755
|
+
initial: () => ({ eventCount: 0 }),
|
|
1756
|
+
fold: (state, event) => ({
|
|
1757
|
+
eventCount: state.eventCount + 1,
|
|
1758
|
+
lastKind: event.kind,
|
|
1759
|
+
lastOccurredAt: event.occurredAt
|
|
1760
|
+
})
|
|
1761
|
+
});
|
|
1762
|
+
var StateSlotsProjectionSchema = z7.record(z7.string(), z7.json());
|
|
1763
|
+
var agentStateSlotsProjection = defineAgentProjection({
|
|
1764
|
+
name: "state-slots",
|
|
1765
|
+
version: 1,
|
|
1766
|
+
schema: StateSlotsProjectionSchema,
|
|
1767
|
+
initial: () => ({}),
|
|
1768
|
+
fold: (state, event) => {
|
|
1769
|
+
if (event.kind !== "state/set")
|
|
1770
|
+
return state;
|
|
1771
|
+
const payload = z7.object({ name: z7.string().min(1), value: z7.json() }).passthrough().parse(event.payload);
|
|
1772
|
+
return { ...state, [payload.name]: payload.value };
|
|
1773
|
+
}
|
|
1774
|
+
});
|
|
1775
|
+
var ScheduleSummarySchema = z7.object({
|
|
1776
|
+
scheduled: z7.int().nonnegative(),
|
|
1777
|
+
fired: z7.int().nonnegative(),
|
|
1778
|
+
cancelled: z7.int().nonnegative(),
|
|
1779
|
+
late: z7.int().nonnegative()
|
|
1780
|
+
});
|
|
1781
|
+
var agentScheduleSummaryProjection = defineAgentProjection({
|
|
1782
|
+
name: "schedule-summary",
|
|
1783
|
+
version: 1,
|
|
1784
|
+
schema: ScheduleSummarySchema,
|
|
1785
|
+
initial: () => ({ scheduled: 0, fired: 0, cancelled: 0, late: 0 }),
|
|
1786
|
+
fold: (state, event) => {
|
|
1787
|
+
if (event.kind === "schedule/set")
|
|
1788
|
+
return { ...state, scheduled: state.scheduled + 1 };
|
|
1789
|
+
if (event.kind === "schedule/fired")
|
|
1790
|
+
return { ...state, fired: state.fired + 1 };
|
|
1791
|
+
if (event.kind === "schedule/cancelled")
|
|
1792
|
+
return { ...state, cancelled: state.cancelled + 1 };
|
|
1793
|
+
if (event.kind === "schedule/late")
|
|
1794
|
+
return { ...state, late: state.late + 1 };
|
|
1795
|
+
return state;
|
|
1796
|
+
}
|
|
1797
|
+
});
|
|
1798
|
+
var RuntimeSummarySchema = z7.object({
|
|
1799
|
+
eventCount: z7.int().nonnegative(),
|
|
1800
|
+
lastSeq: z7.int().nonnegative(),
|
|
1801
|
+
lastKind: z7.string().optional(),
|
|
1802
|
+
lastOccurredAt: z7.string().optional(),
|
|
1803
|
+
lastModelId: z7.string().optional()
|
|
1804
|
+
}).strict();
|
|
1805
|
+
var agentSummaryProjection = defineAgentProjection({
|
|
1806
|
+
name: "summary",
|
|
1807
|
+
version: 1,
|
|
1808
|
+
schema: RuntimeSummarySchema,
|
|
1809
|
+
initial: () => ({ eventCount: 0, lastSeq: 0 }),
|
|
1810
|
+
fold: (state, event) => {
|
|
1811
|
+
const request = event.kind === "provider/request" ? z7.object({ modelId: z7.string().optional() }).passthrough().safeParse(event.payload) : undefined;
|
|
1812
|
+
return {
|
|
1813
|
+
eventCount: state.eventCount + 1,
|
|
1814
|
+
lastSeq: event.seq,
|
|
1815
|
+
lastKind: event.kind,
|
|
1816
|
+
lastOccurredAt: event.occurredAt,
|
|
1817
|
+
...request?.success && request.data.modelId ? { lastModelId: request.data.modelId } : state.lastModelId ? { lastModelId: state.lastModelId } : {}
|
|
1818
|
+
};
|
|
1819
|
+
}
|
|
1820
|
+
});
|
|
1821
|
+
var RuntimeUsageSchema = z7.object({
|
|
1822
|
+
inputTokens: z7.number().nonnegative(),
|
|
1823
|
+
outputTokens: z7.number().nonnegative(),
|
|
1824
|
+
cost: z7.number().nonnegative(),
|
|
1825
|
+
sources: z7.array(z7.string())
|
|
1826
|
+
}).strict();
|
|
1827
|
+
var agentUsageProjection = defineAgentProjection({
|
|
1828
|
+
name: "usage",
|
|
1829
|
+
version: 1,
|
|
1830
|
+
schema: RuntimeUsageSchema,
|
|
1831
|
+
initial: () => ({ inputTokens: 0, outputTokens: 0, cost: 0, sources: [] }),
|
|
1832
|
+
fold: (state, event) => {
|
|
1833
|
+
const parsed = z7.object({
|
|
1834
|
+
inputTokens: z7.number().nonnegative().optional(),
|
|
1835
|
+
outputTokens: z7.number().nonnegative().optional(),
|
|
1836
|
+
cost: z7.number().nonnegative().optional(),
|
|
1837
|
+
source: z7.string().min(1).optional()
|
|
1838
|
+
}).passthrough().safeParse(event.payload);
|
|
1839
|
+
if (!parsed.success)
|
|
1840
|
+
return state;
|
|
1841
|
+
const source = parsed.data.source;
|
|
1842
|
+
return {
|
|
1843
|
+
inputTokens: state.inputTokens + (parsed.data.inputTokens ?? 0),
|
|
1844
|
+
outputTokens: state.outputTokens + (parsed.data.outputTokens ?? 0),
|
|
1845
|
+
cost: state.cost + (parsed.data.cost ?? 0),
|
|
1846
|
+
sources: source && !state.sources.includes(source) ? [...state.sources, source] : state.sources
|
|
1847
|
+
};
|
|
1848
|
+
}
|
|
1849
|
+
});
|
|
1850
|
+
var RuntimeOutlineSchema = z7.object({
|
|
1851
|
+
requests: z7.array(z7.object({
|
|
1852
|
+
seq: z7.int().positive(),
|
|
1853
|
+
occurredAt: z7.string(),
|
|
1854
|
+
runId: z7.string().optional()
|
|
1855
|
+
}).strict())
|
|
1856
|
+
}).strict();
|
|
1857
|
+
var agentOutlineProjection = defineAgentProjection({
|
|
1858
|
+
name: "outline",
|
|
1859
|
+
version: 1,
|
|
1860
|
+
schema: RuntimeOutlineSchema,
|
|
1861
|
+
initial: () => ({ requests: [] }),
|
|
1862
|
+
fold: (state, event) => {
|
|
1863
|
+
if (event.kind !== "provider/request")
|
|
1864
|
+
return state;
|
|
1865
|
+
const payload = z7.object({ runId: z7.string().optional() }).passthrough().parse(event.payload);
|
|
1866
|
+
return {
|
|
1867
|
+
requests: [
|
|
1868
|
+
...state.requests,
|
|
1869
|
+
{
|
|
1870
|
+
seq: event.seq,
|
|
1871
|
+
occurredAt: event.occurredAt,
|
|
1872
|
+
...payload.runId && { runId: payload.runId }
|
|
1873
|
+
}
|
|
1874
|
+
]
|
|
1875
|
+
};
|
|
1876
|
+
}
|
|
1877
|
+
});
|
|
1878
|
+
// src/agent-runtime/protocol.ts
|
|
1879
|
+
function hasAgentTerminalOutput(input) {
|
|
1880
|
+
for (const part of input.message.parts) {
|
|
1881
|
+
if (part.type === "text" && part.text.trim().length > 0)
|
|
1882
|
+
return true;
|
|
1883
|
+
if (part.type === "file" || part.type === "provider")
|
|
1884
|
+
return true;
|
|
1885
|
+
if (input.reason === "policy_stop" && (part.type === "tool-call" || part.type === "tool-result")) {
|
|
1886
|
+
return true;
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
return false;
|
|
1890
|
+
}
|
|
1891
|
+
function defineAgentProtocol(config) {
|
|
1892
|
+
const acceptance = config.terminalAcceptance;
|
|
1893
|
+
return {
|
|
1894
|
+
contextSchema: config.context,
|
|
1895
|
+
inputMetadataSchema: config.inputMetadata,
|
|
1896
|
+
parseContext: (input) => config.context.parse(input),
|
|
1897
|
+
parseInputMetadata: (input) => AgentJsonObjectSchema.parse(config.inputMetadata.parse(input)),
|
|
1898
|
+
parseMessage: (input) => AgentMessageSchema.parse(input),
|
|
1899
|
+
parsePart: (input) => AgentMessageSchema.shape.parts.element.parse(input),
|
|
1900
|
+
...acceptance !== undefined && acceptance !== "allow-empty" && {
|
|
1901
|
+
acceptTerminal: acceptance === "require-output" ? hasAgentTerminalOutput : acceptance
|
|
1902
|
+
}
|
|
1903
|
+
};
|
|
1904
|
+
}
|
|
1905
|
+
// src/agent-runtime/schedule-tools.ts
|
|
1906
|
+
import { z as z8 } from "zod";
|
|
1907
|
+
var ScheduledOutputSchema = z8.object({ scheduleId: z8.string(), nextAt: z8.string() }).strict();
|
|
1908
|
+
var ConversationInputSchema = z8.object({ conversationId: z8.string().min(1) }).strict();
|
|
1909
|
+
function createAgentScheduleTools(service) {
|
|
1910
|
+
const schedule = async (request) => {
|
|
1911
|
+
const result = await service.scheduleInput(request);
|
|
1912
|
+
return { scheduleId: result.id, nextAt: result.nextAt };
|
|
1913
|
+
};
|
|
1914
|
+
return [
|
|
1915
|
+
defineAgentTool({
|
|
1916
|
+
name: "schedule_after",
|
|
1917
|
+
description: "Schedule durable input after a relative delay.",
|
|
1918
|
+
identity: { serviceName: "agent-schedules", action: "after", method: "POST" },
|
|
1919
|
+
input: z8.object({
|
|
1920
|
+
conversationId: z8.string().min(1),
|
|
1921
|
+
input: z8.json(),
|
|
1922
|
+
afterMs: z8.int().positive()
|
|
1923
|
+
}).strict(),
|
|
1924
|
+
output: ScheduledOutputSchema,
|
|
1925
|
+
transports: ["AGENT"],
|
|
1926
|
+
handler: ({ input }) => schedule(input)
|
|
1927
|
+
}),
|
|
1928
|
+
defineAgentTool({
|
|
1929
|
+
name: "schedule_at",
|
|
1930
|
+
description: "Schedule durable input at an absolute timestamp with an explicit offset.",
|
|
1931
|
+
identity: { serviceName: "agent-schedules", action: "at", method: "POST" },
|
|
1932
|
+
input: z8.object({ conversationId: z8.string().min(1), input: z8.json(), at: z8.string().min(1) }).strict(),
|
|
1933
|
+
output: ScheduledOutputSchema,
|
|
1934
|
+
transports: ["AGENT"],
|
|
1935
|
+
handler: ({ input }) => schedule(input)
|
|
1936
|
+
}),
|
|
1937
|
+
defineAgentTool({
|
|
1938
|
+
name: "schedule_every",
|
|
1939
|
+
description: "Schedule recurring durable input in an explicit conversation timezone.",
|
|
1940
|
+
identity: { serviceName: "agent-schedules", action: "every", method: "POST" },
|
|
1941
|
+
input: z8.object({
|
|
1942
|
+
conversationId: z8.string().min(1),
|
|
1943
|
+
input: z8.json(),
|
|
1944
|
+
everyMs: z8.int().positive(),
|
|
1945
|
+
timeZone: z8.string().min(1)
|
|
1946
|
+
}).strict(),
|
|
1947
|
+
output: ScheduledOutputSchema,
|
|
1948
|
+
transports: ["AGENT"],
|
|
1949
|
+
handler: ({ input }) => schedule(input)
|
|
1950
|
+
}),
|
|
1951
|
+
defineAgentTool({
|
|
1952
|
+
name: "schedule_list",
|
|
1953
|
+
description: "List durable schedules for one conversation.",
|
|
1954
|
+
identity: { serviceName: "agent-schedules", action: "list", method: "GET" },
|
|
1955
|
+
input: ConversationInputSchema,
|
|
1956
|
+
output: z8.object({ schedules: z8.array(z8.json()) }).strict(),
|
|
1957
|
+
transports: ["AGENT"],
|
|
1958
|
+
handler: ({ input }) => ({
|
|
1959
|
+
schedules: [...service.listSchedules(input.conversationId)]
|
|
1960
|
+
})
|
|
1961
|
+
}),
|
|
1962
|
+
defineAgentTool({
|
|
1963
|
+
name: "schedule_cancel",
|
|
1964
|
+
description: "Cancel one durable deferred-input schedule.",
|
|
1965
|
+
identity: { serviceName: "agent-schedules", action: "cancel", method: "POST" },
|
|
1966
|
+
input: z8.object({ conversationId: z8.string().min(1), scheduleId: z8.string().min(1) }).strict(),
|
|
1967
|
+
output: z8.object({ cancelled: z8.boolean() }).strict(),
|
|
1968
|
+
transports: ["AGENT"],
|
|
1969
|
+
handler: async ({ input }) => ({
|
|
1970
|
+
cancelled: await service.cancelSchedule(input.conversationId, input.scheduleId)
|
|
1971
|
+
})
|
|
1972
|
+
})
|
|
1973
|
+
];
|
|
1974
|
+
}
|
|
1975
|
+
// src/agent-runtime/schedules.ts
|
|
1976
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
1977
|
+
import { z as z10 } from "zod";
|
|
1978
|
+
|
|
1979
|
+
// src/agent-runtime/schedule-records.ts
|
|
1980
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
1981
|
+
import { z as z9 } from "zod";
|
|
1982
|
+
function newSchedule(request, observedAt) {
|
|
1983
|
+
const modes = [
|
|
1984
|
+
request.at !== undefined,
|
|
1985
|
+
request.afterMs !== undefined,
|
|
1986
|
+
request.everyMs !== undefined
|
|
1987
|
+
];
|
|
1988
|
+
if (modes.filter(Boolean).length !== 1)
|
|
1989
|
+
throw new TypeError("Declare exactly one schedule mode");
|
|
1990
|
+
if (request.everyMs !== undefined && !request.timeZone) {
|
|
1991
|
+
throw new TypeError("Repeating schedules require an explicit timeZone");
|
|
1992
|
+
}
|
|
1993
|
+
if (request.timeZone) {
|
|
1994
|
+
try {
|
|
1995
|
+
new Intl.DateTimeFormat("en", { timeZone: request.timeZone }).format(new Date(0));
|
|
1996
|
+
} catch {
|
|
1997
|
+
throw new TypeError(`Unknown schedule timeZone: ${request.timeZone}`);
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
const kind = request.at !== undefined ? "at" : request.afterMs !== undefined ? "after" : "every";
|
|
2001
|
+
const intervalMs = request.everyMs;
|
|
2002
|
+
const delay = request.afterMs ?? request.everyMs;
|
|
2003
|
+
if (delay !== undefined && (!Number.isSafeInteger(delay) || delay < 1)) {
|
|
2004
|
+
throw new TypeError("Schedule delay must be a positive safe integer");
|
|
2005
|
+
}
|
|
2006
|
+
const nextAt = request.at ? new Date(z9.iso.datetime({ offset: true }).parse(request.at)).toISOString() : new Date(observedAt.getTime() + (delay ?? 0)).toISOString();
|
|
2007
|
+
const schedule = AgentScheduleSchema.parse({
|
|
2008
|
+
id: randomUUID2(),
|
|
2009
|
+
conversationId: request.conversationId,
|
|
2010
|
+
kind,
|
|
2011
|
+
nextAt,
|
|
2012
|
+
...intervalMs !== undefined && { intervalMs },
|
|
2013
|
+
...request.timeZone && { timeZone: request.timeZone },
|
|
2014
|
+
input: z9.json().parse(request.input),
|
|
2015
|
+
state: "scheduled",
|
|
2016
|
+
occurrence: 0,
|
|
2017
|
+
createdAt: observedAt.toISOString(),
|
|
2018
|
+
updatedAt: observedAt.toISOString()
|
|
2019
|
+
});
|
|
2020
|
+
return schedule;
|
|
2021
|
+
}
|
|
2022
|
+
async function insertSchedule(sqlite, schedule) {
|
|
2023
|
+
await sqlite.transaction(async (scope) => {
|
|
2024
|
+
scope.database.prepare(`
|
|
2025
|
+
INSERT INTO stitchkit_agent_runtime_schedules (
|
|
2026
|
+
id, conversation_id, kind, next_at, interval_ms, time_zone,
|
|
2027
|
+
input_payload, state, occurrence, created_at, updated_at
|
|
2028
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, 'scheduled', 0, ?, ?)
|
|
2029
|
+
`).run(schedule.id, schedule.conversationId, schedule.kind, schedule.nextAt, schedule.intervalMs ?? null, schedule.timeZone ?? null, JSON.stringify(schedule.input), schedule.createdAt, schedule.updatedAt);
|
|
2030
|
+
await scope.appendEvent({
|
|
2031
|
+
conversationId: schedule.conversationId,
|
|
2032
|
+
kind: "schedule/set",
|
|
2033
|
+
occurredAt: schedule.createdAt,
|
|
2034
|
+
payload: { id: schedule.id, kind: schedule.kind, nextAt: schedule.nextAt }
|
|
2035
|
+
});
|
|
2036
|
+
});
|
|
2037
|
+
}
|
|
2038
|
+
async function recordDispatchFailure(sqlite, { schedule, occurrence, at, owner }, error) {
|
|
2039
|
+
await sqlite.transaction(async (scope) => {
|
|
2040
|
+
scope.database.prepare(`
|
|
2041
|
+
UPDATE stitchkit_agent_runtime_schedules
|
|
2042
|
+
SET claim_owner = NULL, claim_until = NULL, updated_at = ?
|
|
2043
|
+
WHERE id = ? AND claim_owner = ?
|
|
2044
|
+
`).run(at, schedule.id, owner);
|
|
2045
|
+
await scope.appendEvent({
|
|
2046
|
+
conversationId: schedule.conversationId,
|
|
2047
|
+
kind: "schedule/failed",
|
|
2048
|
+
occurredAt: at,
|
|
2049
|
+
payload: {
|
|
2050
|
+
id: schedule.id,
|
|
2051
|
+
occurrence,
|
|
2052
|
+
message: error instanceof Error ? error.message : String(error)
|
|
2053
|
+
}
|
|
2054
|
+
});
|
|
2055
|
+
});
|
|
2056
|
+
}
|
|
2057
|
+
async function settleFiring(sqlite, { schedule, occurrence, at, owner }, observedAt, lateByMs) {
|
|
2058
|
+
let nextAt = schedule.nextAt;
|
|
2059
|
+
if (schedule.kind === "every" && schedule.intervalMs) {
|
|
2060
|
+
let next = new Date(schedule.nextAt).getTime() + schedule.intervalMs;
|
|
2061
|
+
while (next <= observedAt.getTime())
|
|
2062
|
+
next += schedule.intervalMs;
|
|
2063
|
+
nextAt = new Date(next).toISOString();
|
|
2064
|
+
}
|
|
2065
|
+
const state = schedule.kind === "every" ? "scheduled" : "completed";
|
|
2066
|
+
await sqlite.transaction(async (scope) => {
|
|
2067
|
+
const held = scope.database.prepare(`
|
|
2068
|
+
SELECT state, claim_owner FROM stitchkit_agent_runtime_schedules WHERE id = ?
|
|
2069
|
+
`).get(schedule.id);
|
|
2070
|
+
const settled = held !== null && held !== undefined && (() => {
|
|
2071
|
+
const row = FinalizeRowSchema.parse(held);
|
|
2072
|
+
return row.state === "scheduled" && row.claim_owner === owner;
|
|
2073
|
+
})();
|
|
2074
|
+
if (settled) {
|
|
2075
|
+
scope.database.prepare(`
|
|
2076
|
+
UPDATE stitchkit_agent_runtime_schedules
|
|
2077
|
+
SET state = ?, occurrence = ?, next_at = ?, updated_at = ?,
|
|
2078
|
+
claim_owner = NULL, claim_until = NULL
|
|
2079
|
+
WHERE id = ?
|
|
2080
|
+
`).run(state, occurrence, nextAt, at, schedule.id);
|
|
2081
|
+
}
|
|
2082
|
+
if (lateByMs > 0) {
|
|
2083
|
+
await scope.appendEvent({
|
|
2084
|
+
conversationId: schedule.conversationId,
|
|
2085
|
+
kind: "schedule/late",
|
|
2086
|
+
occurredAt: at,
|
|
2087
|
+
payload: { id: schedule.id, occurrence, lateByMs }
|
|
2088
|
+
});
|
|
2089
|
+
}
|
|
2090
|
+
await scope.appendEvent({
|
|
2091
|
+
conversationId: schedule.conversationId,
|
|
2092
|
+
kind: "schedule/fired",
|
|
2093
|
+
occurredAt: at,
|
|
2094
|
+
payload: {
|
|
2095
|
+
id: schedule.id,
|
|
2096
|
+
occurrence,
|
|
2097
|
+
lateByMs,
|
|
2098
|
+
nextAt,
|
|
2099
|
+
state: settled ? state : "cancelled"
|
|
2100
|
+
}
|
|
2101
|
+
});
|
|
2102
|
+
});
|
|
2103
|
+
}
|
|
2104
|
+
function claimSchedule(sqlite, owner, id, until, at) {
|
|
2105
|
+
return sqlite.transaction(async (scope) => {
|
|
2106
|
+
const raw = scope.database.prepare(`
|
|
2107
|
+
SELECT state, claim_until FROM stitchkit_agent_runtime_schedules WHERE id = ?
|
|
2108
|
+
`).get(id);
|
|
2109
|
+
if (raw === null || raw === undefined)
|
|
2110
|
+
return false;
|
|
2111
|
+
const row = ClaimRowSchema.parse(raw);
|
|
2112
|
+
if (row.state !== "scheduled")
|
|
2113
|
+
return false;
|
|
2114
|
+
if (row.claim_until !== null && row.claim_until >= at)
|
|
2115
|
+
return false;
|
|
2116
|
+
scope.database.prepare(`
|
|
2117
|
+
UPDATE stitchkit_agent_runtime_schedules
|
|
2118
|
+
SET claim_owner = ?, claim_until = ?, updated_at = ?
|
|
2119
|
+
WHERE id = ?
|
|
2120
|
+
`).run(owner, until, at, id);
|
|
2121
|
+
return true;
|
|
2122
|
+
});
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
// src/agent-runtime/schedules.ts
|
|
2126
|
+
var AgentScheduleSchema = z10.object({
|
|
2127
|
+
id: z10.string().min(1),
|
|
2128
|
+
conversationId: z10.string().min(1),
|
|
2129
|
+
kind: z10.enum(["at", "after", "every"]),
|
|
2130
|
+
nextAt: z10.iso.datetime({ offset: true }),
|
|
2131
|
+
intervalMs: z10.int().positive().optional(),
|
|
2132
|
+
timeZone: z10.string().min(1).optional(),
|
|
2133
|
+
input: z10.json(),
|
|
2134
|
+
state: z10.enum(["scheduled", "cancelled", "completed"]),
|
|
2135
|
+
occurrence: z10.int().nonnegative(),
|
|
2136
|
+
createdAt: z10.iso.datetime({ offset: true }),
|
|
2137
|
+
updatedAt: z10.iso.datetime({ offset: true })
|
|
2138
|
+
}).strict();
|
|
2139
|
+
var ScheduleRowSchema = z10.object({
|
|
2140
|
+
id: z10.string(),
|
|
2141
|
+
conversation_id: z10.string(),
|
|
2142
|
+
kind: z10.enum(["at", "after", "every"]),
|
|
2143
|
+
next_at: z10.string(),
|
|
2144
|
+
interval_ms: z10.number().int().positive().nullable(),
|
|
2145
|
+
time_zone: z10.string().nullable(),
|
|
2146
|
+
input_payload: z10.string(),
|
|
2147
|
+
state: z10.enum(["scheduled", "cancelled", "completed"]),
|
|
2148
|
+
occurrence: z10.int().nonnegative(),
|
|
2149
|
+
created_at: z10.string(),
|
|
2150
|
+
updated_at: z10.string()
|
|
2151
|
+
});
|
|
2152
|
+
var ClaimRowSchema = z10.object({
|
|
2153
|
+
state: z10.enum(["scheduled", "cancelled", "completed"]),
|
|
2154
|
+
claim_until: z10.string().nullable()
|
|
2155
|
+
});
|
|
2156
|
+
var FinalizeRowSchema = z10.object({
|
|
2157
|
+
state: z10.enum(["scheduled", "cancelled", "completed"]),
|
|
2158
|
+
claim_owner: z10.string().nullable()
|
|
2159
|
+
});
|
|
2160
|
+
var StateRowSchema = z10.object({
|
|
2161
|
+
state: z10.enum(["scheduled", "cancelled", "completed"])
|
|
2162
|
+
});
|
|
2163
|
+
function parseSchedule(raw) {
|
|
2164
|
+
const row = ScheduleRowSchema.parse(raw);
|
|
2165
|
+
return AgentScheduleSchema.parse({
|
|
2166
|
+
id: row.id,
|
|
2167
|
+
conversationId: row.conversation_id,
|
|
2168
|
+
kind: row.kind,
|
|
2169
|
+
nextAt: row.next_at,
|
|
2170
|
+
...row.interval_ms !== null && { intervalMs: row.interval_ms },
|
|
2171
|
+
...row.time_zone !== null && { timeZone: row.time_zone },
|
|
2172
|
+
input: JSON.parse(row.input_payload),
|
|
2173
|
+
state: row.state,
|
|
2174
|
+
occurrence: row.occurrence,
|
|
2175
|
+
createdAt: row.created_at,
|
|
2176
|
+
updatedAt: row.updated_at
|
|
2177
|
+
});
|
|
2178
|
+
}
|
|
2179
|
+
function createAgentScheduleService(input) {
|
|
2180
|
+
const onError = input.onError ?? ((error) => {
|
|
2181
|
+
console.error("[stitchkit] agent schedule tick failed", error);
|
|
2182
|
+
});
|
|
2183
|
+
const now = input.now ?? (() => new Date);
|
|
2184
|
+
const database = input.sqlite.database;
|
|
2185
|
+
const setTimer = input.setTimer ?? ((callback, delay) => setTimeout(callback, delay));
|
|
2186
|
+
const clearTimer = input.clearTimer ?? clearTimeout;
|
|
2187
|
+
let timer;
|
|
2188
|
+
let closed = false;
|
|
2189
|
+
const listSchedules = (conversationId) => database.prepare(`
|
|
2190
|
+
SELECT id, conversation_id, kind, next_at, interval_ms, time_zone,
|
|
2191
|
+
input_payload, state, occurrence, created_at, updated_at
|
|
2192
|
+
FROM stitchkit_agent_runtime_schedules
|
|
2193
|
+
WHERE conversation_id = ? ORDER BY created_at, id
|
|
2194
|
+
`).all(conversationId).map(parseSchedule);
|
|
2195
|
+
const arm = () => {
|
|
2196
|
+
if (timer)
|
|
2197
|
+
clearTimer(timer);
|
|
2198
|
+
if (closed)
|
|
2199
|
+
return;
|
|
2200
|
+
try {
|
|
2201
|
+
armNext();
|
|
2202
|
+
} catch (error) {
|
|
2203
|
+
onError(error);
|
|
2204
|
+
}
|
|
2205
|
+
};
|
|
2206
|
+
const armNext = () => {
|
|
2207
|
+
const raw = database.prepare(`
|
|
2208
|
+
SELECT MAX(next_at, COALESCE(claim_until, next_at)) AS due_at
|
|
2209
|
+
FROM stitchkit_agent_runtime_schedules
|
|
2210
|
+
WHERE state = 'scheduled' ORDER BY due_at, id LIMIT 1
|
|
2211
|
+
`).get();
|
|
2212
|
+
if (raw === null || raw === undefined || typeof raw.due_at !== "string")
|
|
2213
|
+
return;
|
|
2214
|
+
const delay = Math.max(0, new Date(raw.due_at).getTime() - now().getTime());
|
|
2215
|
+
timer = setTimer(() => void tick(), Math.min(delay, 2147483647));
|
|
2216
|
+
};
|
|
2217
|
+
const owner = randomUUID3();
|
|
2218
|
+
const CLAIM_MS = 60000;
|
|
2219
|
+
let ticking;
|
|
2220
|
+
const claim = (id, until, at) => claimSchedule(input.sqlite, owner, id, until, at);
|
|
2221
|
+
const runTick = async () => {
|
|
2222
|
+
if (closed)
|
|
2223
|
+
return;
|
|
2224
|
+
const observedAt = now();
|
|
2225
|
+
const due = database.prepare(`
|
|
2226
|
+
SELECT id, conversation_id, kind, next_at, interval_ms, time_zone,
|
|
2227
|
+
input_payload, state, occurrence, created_at, updated_at
|
|
2228
|
+
FROM stitchkit_agent_runtime_schedules
|
|
2229
|
+
WHERE state = 'scheduled' AND next_at <= ? ORDER BY next_at, id
|
|
2230
|
+
`).all(observedAt.toISOString()).map(parseSchedule);
|
|
2231
|
+
for (const schedule of due) {
|
|
2232
|
+
const at = observedAt.toISOString();
|
|
2233
|
+
if (!await claim(schedule.id, new Date(observedAt.getTime() + CLAIM_MS).toISOString(), at)) {
|
|
2234
|
+
continue;
|
|
2235
|
+
}
|
|
2236
|
+
const occurrence = schedule.occurrence + 1;
|
|
2237
|
+
const lateByMs = Math.max(0, observedAt.getTime() - new Date(schedule.nextAt).getTime());
|
|
2238
|
+
try {
|
|
2239
|
+
await input.dispatch({
|
|
2240
|
+
conversationId: schedule.conversationId,
|
|
2241
|
+
idempotencyKey: `schedule:${schedule.id}:${occurrence}`,
|
|
2242
|
+
input: schedule.input,
|
|
2243
|
+
schedule: { id: schedule.id, occurrence, lateByMs }
|
|
2244
|
+
});
|
|
2245
|
+
} catch (error) {
|
|
2246
|
+
await recordDispatchFailure(input.sqlite, { schedule, occurrence, at, owner }, error);
|
|
2247
|
+
continue;
|
|
2248
|
+
}
|
|
2249
|
+
await settleFiring(input.sqlite, { schedule, occurrence, at, owner }, observedAt, lateByMs);
|
|
2250
|
+
}
|
|
2251
|
+
};
|
|
2252
|
+
const tick = () => {
|
|
2253
|
+
if (ticking)
|
|
2254
|
+
return ticking;
|
|
2255
|
+
ticking = runTick().catch(onError).finally(() => {
|
|
2256
|
+
ticking = undefined;
|
|
2257
|
+
arm();
|
|
2258
|
+
});
|
|
2259
|
+
return ticking;
|
|
2260
|
+
};
|
|
2261
|
+
const scheduleInput = async (request) => {
|
|
2262
|
+
const schedule = newSchedule(request, now());
|
|
2263
|
+
await insertSchedule(input.sqlite, schedule);
|
|
2264
|
+
arm();
|
|
2265
|
+
return schedule;
|
|
2266
|
+
};
|
|
2267
|
+
const cancelSchedule = async (conversationId, id) => {
|
|
2268
|
+
const observedAt = now().toISOString();
|
|
2269
|
+
const changed = await input.sqlite.transaction(async (scope) => {
|
|
2270
|
+
const raw = scope.database.prepare(`
|
|
2271
|
+
SELECT state FROM stitchkit_agent_runtime_schedules
|
|
2272
|
+
WHERE id = ? AND conversation_id = ?
|
|
2273
|
+
`).get(id, conversationId);
|
|
2274
|
+
if (raw === null || raw === undefined)
|
|
2275
|
+
return false;
|
|
2276
|
+
if (StateRowSchema.parse(raw).state !== "scheduled")
|
|
2277
|
+
return false;
|
|
2278
|
+
scope.database.prepare(`
|
|
2279
|
+
UPDATE stitchkit_agent_runtime_schedules SET state = 'cancelled', updated_at = ?
|
|
2280
|
+
WHERE id = ? AND conversation_id = ?
|
|
2281
|
+
`).run(observedAt, id, conversationId);
|
|
2282
|
+
await scope.appendEvent({
|
|
2283
|
+
conversationId,
|
|
2284
|
+
kind: "schedule/cancelled",
|
|
2285
|
+
occurredAt: observedAt,
|
|
2286
|
+
payload: { id }
|
|
2287
|
+
});
|
|
2288
|
+
return true;
|
|
2289
|
+
});
|
|
2290
|
+
if (changed)
|
|
2291
|
+
arm();
|
|
2292
|
+
return changed;
|
|
2293
|
+
};
|
|
2294
|
+
return {
|
|
2295
|
+
scheduleInput,
|
|
2296
|
+
cancelSchedule,
|
|
2297
|
+
listSchedules,
|
|
2298
|
+
tick,
|
|
2299
|
+
start: arm,
|
|
2300
|
+
close() {
|
|
2301
|
+
closed = true;
|
|
2302
|
+
if (timer)
|
|
2303
|
+
clearTimer(timer);
|
|
2304
|
+
}
|
|
2305
|
+
};
|
|
2306
|
+
}
|
|
2307
|
+
// src/agent-runtime/spill.ts
|
|
2308
|
+
import { createHash, randomUUID as randomUUID4 } from "node:crypto";
|
|
2309
|
+
import { z as z11 } from "zod";
|
|
2310
|
+
var SpillRowSchema = z11.object({
|
|
2311
|
+
payload: z11.instanceof(Uint8Array),
|
|
2312
|
+
bytes: z11.int().nonnegative(),
|
|
2313
|
+
authorization_payload: z11.string().nullable()
|
|
2314
|
+
});
|
|
2315
|
+
var SpillMetadataRowSchema = z11.object({
|
|
2316
|
+
reference_id: z11.string(),
|
|
2317
|
+
bytes: z11.int().nonnegative(),
|
|
2318
|
+
created_at: z11.string()
|
|
2319
|
+
});
|
|
2320
|
+
function decodeAuthorization(value) {
|
|
2321
|
+
if (value === null)
|
|
2322
|
+
return;
|
|
2323
|
+
return JSON.parse(value);
|
|
2324
|
+
}
|
|
2325
|
+
function createSqliteAgentSpillStore(input) {
|
|
2326
|
+
const now = input.now ?? (() => new Date);
|
|
2327
|
+
const database = input.sqlite.database;
|
|
2328
|
+
const rowFor = (reference) => {
|
|
2329
|
+
const raw = database.prepare(`
|
|
2330
|
+
SELECT payload, bytes, authorization_payload
|
|
2331
|
+
FROM stitchkit_agent_runtime_spills
|
|
2332
|
+
WHERE reference_id = ? AND conversation_id = ?
|
|
2333
|
+
`).get(reference, input.conversationId);
|
|
2334
|
+
if (raw === null || raw === undefined)
|
|
2335
|
+
refuseUnknownSpillReference(reference);
|
|
2336
|
+
return SpillRowSchema.parse(raw);
|
|
2337
|
+
};
|
|
2338
|
+
const authorization = (reference) => decodeAuthorization(rowFor(reference).authorization_payload);
|
|
2339
|
+
const write = async (request) => {
|
|
2340
|
+
const reference = randomUUID4();
|
|
2341
|
+
const createdAt = now();
|
|
2342
|
+
const expiresAt = input.retentionMs ? new Date(createdAt.getTime() + input.retentionMs).toISOString() : null;
|
|
2343
|
+
const sha256 = createHash("sha256").update(request.data).digest("hex");
|
|
2344
|
+
await input.sqlite.transaction(async (scope) => {
|
|
2345
|
+
scope.database.prepare(`
|
|
2346
|
+
INSERT INTO stitchkit_agent_runtime_spills (
|
|
2347
|
+
reference_id, conversation_id, run_id, tool_call_id, media_type,
|
|
2348
|
+
bytes, sha256, created_at, expires_at, payload, authorization_payload
|
|
2349
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
2350
|
+
`).run(reference, input.conversationId, input.runId ?? null, input.toolCallId ?? null, request.mediaType, request.data.byteLength, sha256, createdAt.toISOString(), expiresAt, request.data, request.authorization ? JSON.stringify(request.authorization) : null);
|
|
2351
|
+
await scope.appendEvent({
|
|
2352
|
+
conversationId: input.conversationId,
|
|
2353
|
+
kind: "spill/created",
|
|
2354
|
+
occurredAt: createdAt.toISOString(),
|
|
2355
|
+
payload: { reference, bytes: request.data.byteLength, sha256 }
|
|
2356
|
+
});
|
|
2357
|
+
});
|
|
2358
|
+
return { reference };
|
|
2359
|
+
};
|
|
2360
|
+
const read = async (request) => {
|
|
2361
|
+
const row = rowFor(request.reference);
|
|
2362
|
+
return {
|
|
2363
|
+
data: row.payload.slice(request.offset, request.offset + request.maxBytes),
|
|
2364
|
+
totalBytes: row.bytes,
|
|
2365
|
+
...decodeAuthorization(row.authorization_payload) && {
|
|
2366
|
+
authorization: decodeAuthorization(row.authorization_payload)
|
|
2367
|
+
}
|
|
2368
|
+
};
|
|
2369
|
+
};
|
|
2370
|
+
const search = (request) => {
|
|
2371
|
+
const row = rowFor(request.reference);
|
|
2372
|
+
const matches = [];
|
|
2373
|
+
new TextDecoder("utf-8", { fatal: true }).decode(row.payload).split(`
|
|
2374
|
+
`).forEach((text, index) => {
|
|
2375
|
+
if (matches.length < request.maxMatches && text.includes(request.query)) {
|
|
2376
|
+
matches.push({ line: index + 1, text });
|
|
2377
|
+
}
|
|
2378
|
+
});
|
|
2379
|
+
return matches;
|
|
2380
|
+
};
|
|
2381
|
+
const cleanup = async () => {
|
|
2382
|
+
const expired = database.prepare(`
|
|
2383
|
+
SELECT reference_id, bytes, created_at
|
|
2384
|
+
FROM stitchkit_agent_runtime_spills
|
|
2385
|
+
WHERE conversation_id = ? AND expires_at IS NOT NULL AND expires_at <= ?
|
|
2386
|
+
ORDER BY created_at, reference_id
|
|
2387
|
+
`).all(input.conversationId, now().toISOString()).map((row) => SpillMetadataRowSchema.parse(row));
|
|
2388
|
+
let bytes = 0;
|
|
2389
|
+
for (const spill of expired) {
|
|
2390
|
+
await input.sqlite.transaction(async (scope) => {
|
|
2391
|
+
scope.database.prepare("DELETE FROM stitchkit_agent_runtime_spills WHERE reference_id = ?").run(spill.reference_id);
|
|
2392
|
+
await scope.appendEvent({
|
|
2393
|
+
conversationId: input.conversationId,
|
|
2394
|
+
kind: "spill/deleted",
|
|
2395
|
+
payload: { reference: spill.reference_id, bytes: spill.bytes }
|
|
2396
|
+
});
|
|
2397
|
+
});
|
|
2398
|
+
bytes += spill.bytes;
|
|
2399
|
+
}
|
|
2400
|
+
return { deleted: expired.length, bytes };
|
|
2401
|
+
};
|
|
2402
|
+
return { authorization, write, read, search, cleanup };
|
|
2403
|
+
}
|
|
2404
|
+
// src/agent-runtime/state-tools.ts
|
|
2405
|
+
import { z as z12 } from "zod";
|
|
2406
|
+
var GoalSchema = z12.object({
|
|
2407
|
+
objective: z12.string().min(1),
|
|
2408
|
+
status: z12.enum(["active", "complete", "blocked"])
|
|
2409
|
+
}).strict();
|
|
2410
|
+
var TodoItemSchema = z12.object({
|
|
2411
|
+
step: z12.string().min(1),
|
|
2412
|
+
status: z12.enum(["pending", "in_progress", "completed"])
|
|
2413
|
+
}).strict();
|
|
2414
|
+
function createAgentStateTools(input) {
|
|
2415
|
+
const writeGoal = async (value) => {
|
|
2416
|
+
const stored = await input.state.set({
|
|
2417
|
+
conversationId: input.conversationId,
|
|
2418
|
+
name: "goal",
|
|
2419
|
+
value,
|
|
2420
|
+
actor: "agent"
|
|
2421
|
+
});
|
|
2422
|
+
return GoalSchema.parse(stored.value);
|
|
2423
|
+
};
|
|
2424
|
+
return [
|
|
2425
|
+
defineAgentTool({
|
|
2426
|
+
name: "create_goal",
|
|
2427
|
+
description: "Create the durable objective for this conversation.",
|
|
2428
|
+
identity: { serviceName: "agent-state", action: "create-goal", method: "POST" },
|
|
2429
|
+
input: z12.object({ objective: z12.string().min(1) }).strict(),
|
|
2430
|
+
output: GoalSchema,
|
|
2431
|
+
transports: ["AGENT"],
|
|
2432
|
+
handler: async ({ input: request }) => {
|
|
2433
|
+
if (await input.state.get(input.conversationId, "goal")) {
|
|
2434
|
+
throw new TypeError("A durable goal already exists for this conversation");
|
|
2435
|
+
}
|
|
2436
|
+
return writeGoal({ objective: request.objective, status: "active" });
|
|
2437
|
+
}
|
|
2438
|
+
}),
|
|
2439
|
+
defineAgentTool({
|
|
2440
|
+
name: "update_goal",
|
|
2441
|
+
description: "Update the durable objective or lifecycle status.",
|
|
2442
|
+
identity: { serviceName: "agent-state", action: "update-goal", method: "POST" },
|
|
2443
|
+
input: z12.object({
|
|
2444
|
+
objective: z12.string().min(1).optional(),
|
|
2445
|
+
status: z12.enum(["active", "complete", "blocked"]).optional()
|
|
2446
|
+
}).strict().refine((request) => request.objective !== undefined || request.status !== undefined, {
|
|
2447
|
+
message: "At least one goal field must be supplied"
|
|
2448
|
+
}),
|
|
2449
|
+
output: GoalSchema,
|
|
2450
|
+
transports: ["AGENT"],
|
|
2451
|
+
handler: async ({ input: request }) => {
|
|
2452
|
+
const current = await input.state.get(input.conversationId, "goal");
|
|
2453
|
+
if (!current)
|
|
2454
|
+
throw new TypeError("No durable goal exists for this conversation");
|
|
2455
|
+
const goal = GoalSchema.parse(current.value);
|
|
2456
|
+
return writeGoal({ ...goal, ...request });
|
|
2457
|
+
}
|
|
2458
|
+
}),
|
|
2459
|
+
defineAgentTool({
|
|
2460
|
+
name: "get_goal",
|
|
2461
|
+
description: "Read the durable objective for this conversation.",
|
|
2462
|
+
identity: { serviceName: "agent-state", action: "get-goal", method: "GET" },
|
|
2463
|
+
input: z12.object({}).strict(),
|
|
2464
|
+
output: z12.object({ goal: GoalSchema.optional() }).strict(),
|
|
2465
|
+
transports: ["AGENT"],
|
|
2466
|
+
handler: async () => {
|
|
2467
|
+
const current = await input.state.get(input.conversationId, "goal");
|
|
2468
|
+
return { ...current && { goal: GoalSchema.parse(current.value) } };
|
|
2469
|
+
}
|
|
2470
|
+
}),
|
|
2471
|
+
defineAgentTool({
|
|
2472
|
+
name: "todo_write",
|
|
2473
|
+
description: "Replace the durable ordered work plan for this conversation.",
|
|
2474
|
+
identity: { serviceName: "agent-state", action: "write-todo", method: "POST" },
|
|
2475
|
+
input: z12.object({ items: z12.array(TodoItemSchema) }).strict(),
|
|
2476
|
+
output: z12.object({ items: z12.array(TodoItemSchema) }).strict(),
|
|
2477
|
+
transports: ["AGENT"],
|
|
2478
|
+
handler: async ({ input: request }) => {
|
|
2479
|
+
const stored = await input.state.set({
|
|
2480
|
+
conversationId: input.conversationId,
|
|
2481
|
+
name: "todo",
|
|
2482
|
+
value: request,
|
|
2483
|
+
actor: "agent"
|
|
2484
|
+
});
|
|
2485
|
+
return z12.object({ items: z12.array(TodoItemSchema) }).strict().parse(stored.value);
|
|
2486
|
+
}
|
|
2487
|
+
})
|
|
2488
|
+
];
|
|
2489
|
+
}
|
|
2490
|
+
export {
|
|
2491
|
+
validateAgentModelSnapshot,
|
|
2492
|
+
structuredCompaction,
|
|
2493
|
+
selectCompactableHistory,
|
|
2494
|
+
selectAgentHistory,
|
|
2495
|
+
searchAgentModelCatalog,
|
|
2496
|
+
runStateForTerminalReason,
|
|
2497
|
+
renderAgentStateSlots,
|
|
2498
|
+
recordAgentSandboxProbe,
|
|
2499
|
+
recordAgentRetryDecision,
|
|
2500
|
+
purgeAgentConversation,
|
|
2501
|
+
projectAgentHistoryDetailed,
|
|
2502
|
+
projectAgentHistory,
|
|
2503
|
+
probeAgentProcessSandbox,
|
|
2504
|
+
missingSandboxRestrictions,
|
|
2505
|
+
isToolResultFailure,
|
|
2506
|
+
isAssistantHistoryEvidence,
|
|
2507
|
+
hasAgentTerminalOutput,
|
|
2508
|
+
encodeAgentConversationArchive,
|
|
2509
|
+
defineStateSlot,
|
|
2510
|
+
defineModelRegistry,
|
|
2511
|
+
defineAgentProtocol,
|
|
2512
|
+
defineAgentProjection,
|
|
2513
|
+
decodeAgentStoreEvent,
|
|
2514
|
+
decodeAgentConversationArchive,
|
|
2515
|
+
createSqliteAgentSpillStore,
|
|
2516
|
+
createSqliteAgentProjectionStore,
|
|
2517
|
+
createSqliteAgentEventSearch,
|
|
2518
|
+
createSqliteAgentChildManager,
|
|
2519
|
+
createMemoryAgentRuntimeStore,
|
|
2520
|
+
createMemoryAgentModelSelectionStore,
|
|
2521
|
+
createDeferredAgentToolSurface,
|
|
2522
|
+
createAgentToolFenceLifecycle,
|
|
2523
|
+
createAgentStateTools,
|
|
2524
|
+
createAgentStateSlotStore,
|
|
2525
|
+
createAgentSessionCoordinator,
|
|
2526
|
+
createAgentScheduleTools,
|
|
2527
|
+
createAgentScheduleService,
|
|
2528
|
+
createAgentRuntimeStore,
|
|
2529
|
+
createAgentRuntimeEventSink,
|
|
2530
|
+
createAgentRuntime,
|
|
2531
|
+
createAgentProjectionRegistry,
|
|
2532
|
+
createAgentObservability,
|
|
2533
|
+
createAgentEventSearchTools,
|
|
2534
|
+
createAgentChildTools,
|
|
2535
|
+
composeAgentPrompt,
|
|
2536
|
+
classifyProviderFailure,
|
|
2537
|
+
canonicalAgentJson,
|
|
2538
|
+
agentUsageProjection,
|
|
2539
|
+
agentTodoStateSlot,
|
|
2540
|
+
agentSummaryProjection,
|
|
2541
|
+
agentStateSlotsProjection,
|
|
2542
|
+
agentScheduleSummaryProjection,
|
|
2543
|
+
agentOutlineProjection,
|
|
2544
|
+
agentGoalStateSlot,
|
|
2545
|
+
agentDurableEventId,
|
|
2546
|
+
agentConversationCardProjection,
|
|
2547
|
+
agentChildBudgetStopPolicy,
|
|
2548
|
+
advanceAgentRuntimeEventCursor,
|
|
2549
|
+
StepResultNotSerializableError,
|
|
2550
|
+
StepResultDecodeError,
|
|
2551
|
+
StepAbortedError,
|
|
2552
|
+
SeedConversationInputSchema,
|
|
2553
|
+
RequestRunInterruptSchema,
|
|
2554
|
+
ReplaceCompactedRangeSchema,
|
|
2555
|
+
RecoverAgentRunSchema,
|
|
2556
|
+
RecordRunOperationSchema,
|
|
2557
|
+
ReadAgentStoreEventsSchema,
|
|
2558
|
+
ParkRecordDecodeError,
|
|
2559
|
+
ParkAbortedError,
|
|
2560
|
+
DeferredAgentToolSearchInputSchema,
|
|
2561
|
+
DeferredAgentToolReceiptSchema,
|
|
2562
|
+
DeferredAgentToolMatchSchema,
|
|
2563
|
+
DURABILITY_STEP_EVENT_KIND,
|
|
2564
|
+
CommitRunTerminalSchema,
|
|
2565
|
+
CheckpointRunAssistantSchema,
|
|
2566
|
+
AppendAgentStoreEventSchema,
|
|
2567
|
+
AgentUsageValueSchema,
|
|
2568
|
+
AgentUsageSchema,
|
|
2569
|
+
AgentTransientDeltaEventSchema,
|
|
2570
|
+
AgentToolStatusEventSchema,
|
|
2571
|
+
AgentToolResultPartSchema,
|
|
2572
|
+
AgentToolCallPartSchema,
|
|
2573
|
+
AgentToolApprovalResponsePartSchema,
|
|
2574
|
+
AgentToolApprovalRequestPartSchema,
|
|
2575
|
+
AgentTokenCountSchema,
|
|
2576
|
+
AgentTimestampSchema,
|
|
2577
|
+
AgentTextPartSchema,
|
|
2578
|
+
AgentTerminalReasonSchema,
|
|
2579
|
+
AgentTerminalEventSchema,
|
|
2580
|
+
AgentStoredRunSchema,
|
|
2581
|
+
AgentStoreTransitionSchema,
|
|
2582
|
+
AgentStoreNotFoundSchema,
|
|
2583
|
+
AgentStoreMutationResultSchema,
|
|
2584
|
+
AgentStoreEventPageSchema,
|
|
2585
|
+
AgentStoreEventKindSchema,
|
|
2586
|
+
AgentStoreEventEnvelopeSchema,
|
|
2587
|
+
AgentStoreDuplicateSchema,
|
|
2588
|
+
AgentStoreConflictSchema,
|
|
2589
|
+
AgentStoreAppliedSchema,
|
|
2590
|
+
AgentStepFinishedEventSchema,
|
|
2591
|
+
AgentSourcePartSchema,
|
|
2592
|
+
AgentSnapshotSchema,
|
|
2593
|
+
AgentSeedReceiptSchema,
|
|
2594
|
+
AgentScheduleSchema,
|
|
2595
|
+
AgentSandboxRestrictionSchema,
|
|
2596
|
+
AgentSandboxGradeSchema,
|
|
2597
|
+
AgentRuntimeHeadSchema,
|
|
2598
|
+
AgentRuntimeEventSchema,
|
|
2599
|
+
AgentRuntimeEventCursorSchema,
|
|
2600
|
+
AgentRuntimeConflictError,
|
|
2601
|
+
AgentRunViewSchema,
|
|
2602
|
+
AgentRunTerminalEventSchema,
|
|
2603
|
+
AgentRunStateSchema,
|
|
2604
|
+
AgentRunStateEventSchema,
|
|
2605
|
+
AgentRunStartedEventSchema,
|
|
2606
|
+
AgentRunSchema,
|
|
2607
|
+
AgentRunQueuePrioritySchema,
|
|
2608
|
+
AgentRunOperationSchema,
|
|
2609
|
+
AgentRunOperationPhaseSchema,
|
|
2610
|
+
AgentRunOperationKindSchema,
|
|
2611
|
+
AgentRunOperationEventSchema,
|
|
2612
|
+
AgentRunMetricsSchema,
|
|
2613
|
+
AgentRunEventSchema,
|
|
2614
|
+
AgentRecoverablePageSchema,
|
|
2615
|
+
AgentRecoverableDescriptorSchema,
|
|
2616
|
+
AgentRecordVersionSchema,
|
|
2617
|
+
AgentRecordIdSchema,
|
|
2618
|
+
AgentReasoningStartEventSchema,
|
|
2619
|
+
AgentReasoningPartSchema,
|
|
2620
|
+
AgentReasoningEndEventSchema,
|
|
2621
|
+
AgentReasoningDeltaEventSchema,
|
|
2622
|
+
AgentProviderStreamCutError,
|
|
2623
|
+
AgentProviderResponseSchema,
|
|
2624
|
+
AgentProviderEnvelopeSchema,
|
|
2625
|
+
AgentProvenanceSchema,
|
|
2626
|
+
AgentOpaquePartSchema,
|
|
2627
|
+
AgentModelSelectionSchema,
|
|
2628
|
+
AgentModelSearchResultSchema,
|
|
2629
|
+
AgentModelSearchInputSchema,
|
|
2630
|
+
AgentModelRegistrySnapshotSchema,
|
|
2631
|
+
AgentModelPriceSchema,
|
|
2632
|
+
AgentModelPopularitySchema,
|
|
2633
|
+
AgentModelMetricSchema,
|
|
2634
|
+
AgentModelDescriptorSchema,
|
|
2635
|
+
AgentModelCatalogSchema,
|
|
2636
|
+
AgentModelCatalogEntrySchema,
|
|
2637
|
+
AgentModelCapabilitySchema,
|
|
2638
|
+
AgentMessageStatusSchema,
|
|
2639
|
+
AgentMessageSchema,
|
|
2640
|
+
AgentMessageRoleSchema,
|
|
2641
|
+
AgentMessagePartSchema,
|
|
2642
|
+
AgentJsonObjectSchema,
|
|
2643
|
+
AgentHistoryMutationSchema,
|
|
2644
|
+
AgentFilePartSchema,
|
|
2645
|
+
AgentEventSearchResultSchema,
|
|
2646
|
+
AgentCostValueSchema,
|
|
2647
|
+
AgentConversationSummarySchema,
|
|
2648
|
+
AgentConversationPurgedError,
|
|
2649
|
+
AgentConversationPurgeResultSchema,
|
|
2650
|
+
AgentConversationPurgeInputSchema,
|
|
2651
|
+
AgentConversationPageSchema,
|
|
2652
|
+
AgentConversationMessagePageSchema,
|
|
2653
|
+
AgentConversationArchiveSchema,
|
|
2654
|
+
AgentControlPartSchema,
|
|
2655
|
+
AgentContextOverflowError,
|
|
2656
|
+
AgentChildStateSchema,
|
|
2657
|
+
AgentChildRecordSchema,
|
|
2658
|
+
AgentChildBudgetSchema,
|
|
2659
|
+
AgentChildBlockingSourceSchema,
|
|
2660
|
+
AgentChildBlockingKindSchema,
|
|
2661
|
+
AgentChildBlockingEventSchema,
|
|
2662
|
+
AgentCheckpointEventSchema,
|
|
2663
|
+
AgentAttemptResetEventSchema,
|
|
2664
|
+
AgentAssistantPlaceholderSchema,
|
|
2665
|
+
AgentAdmissionReceiptSchema,
|
|
2666
|
+
AgentAdmissionEventSchema,
|
|
2667
|
+
AcquireAgentRunSchema,
|
|
2668
|
+
AcceptInputAndAssignRunSchema,
|
|
2669
|
+
ACTIVE_AGENT_RUN_STATES
|
|
2670
|
+
};
|