stitchkit 0.93.0 → 0.94.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +134 -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-tool-contract.d.ts +2 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tool-types.d.ts +2 -2
- 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/managed-tools.d.ts +1 -1
- 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 → agent-runtime/openrouter.d.ts} +3 -3
- 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 +9 -4
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/{agent-runtime-sqlite-bun.d.ts → agent-runtime/sqlite-bun.d.ts} +5 -4
- 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 → agent-runtime/sqlite-node.d.ts} +5 -4
- 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/{testing/agent-store-conformance.d.ts → agent-runtime/store-conformance.d.ts} +2 -2
- 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.d.ts → store-driver-contract.d.ts} +7 -7
- 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.d.ts +1 -1
- package/dist/application/admission.d.ts.map +1 -1
- package/dist/application/events.d.ts +1 -1
- package/dist/application/events.d.ts.map +1 -1
- package/dist/{server → application}/file-state-store.d.ts +1 -1
- 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/opentelemetry.d.ts +1 -1
- package/dist/application/opentelemetry.d.ts.map +1 -1
- package/dist/application/watch-hub.d.ts +2 -2
- package/dist/application/watch-hub.d.ts.map +1 -1
- 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 +1 -1
- 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.d.ts +1 -1
- package/dist/browser/http.d.ts.map +1 -1
- 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.d.ts +23 -1
- 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/define.d.ts +72 -65
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/{internal/errors.d.ts → contract/normalize.d.ts} +3 -39
- package/dist/contract/normalize.d.ts.map +1 -0
- package/dist/contract/tool-view.d.ts +135 -0
- package/dist/contract/tool-view.d.ts.map +1 -0
- package/dist/declaration/declaration.d.ts.map +1 -0
- package/dist/{agent-runtime/durability-contract.d.ts → durability/contract.d.ts} +2 -2
- package/dist/durability/contract.d.ts.map +1 -0
- package/dist/{agent-runtime/durability.d.ts → durability/engine.d.ts} +4 -4
- package/dist/durability/engine.d.ts.map +1 -0
- package/dist/durability/events.d.ts +101 -0
- package/dist/durability/events.d.ts.map +1 -0
- package/dist/{agent-runtime/durability-json.d.ts → durability/json.d.ts} +1 -1
- package/dist/durability/json.d.ts.map +1 -0
- package/dist/{agent-runtime/durability-ledger.d.ts → durability/ledger.d.ts} +2 -2
- package/dist/durability/ledger.d.ts.map +1 -0
- package/dist/{agent-runtime/durability-scheduler.d.ts → durability/scheduler.d.ts} +2 -2
- 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/{agent-runtime-browser.js → entrypoints/agent-runtime/browser.js} +3 -3
- package/dist/{agent-runtime-coding-tools.d.ts → entrypoints/agent-runtime/coding-tools.d.ts} +2 -2
- package/dist/entrypoints/agent-runtime/coding-tools.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/coding-tools.js +22 -0
- package/dist/{agent-runtime-harness.d.ts → entrypoints/agent-runtime/harness.d.ts} +2 -2
- package/dist/entrypoints/agent-runtime/harness.d.ts.map +1 -0
- package/dist/{agent-runtime-harness.js → entrypoints/agent-runtime/harness.js} +24 -25
- package/dist/entrypoints/agent-runtime/openrouter.d.ts +2 -0
- package/dist/entrypoints/agent-runtime/openrouter.d.ts.map +1 -0
- package/dist/{agent-runtime-openrouter.js → entrypoints/agent-runtime/openrouter.js} +3 -3
- package/dist/{agent-runtime-sandbox.d.ts → entrypoints/agent-runtime/sandbox.d.ts} +5 -5
- package/dist/entrypoints/agent-runtime/sandbox.d.ts.map +1 -0
- package/dist/{agent-runtime-sandbox.js → entrypoints/agent-runtime/sandbox.js} +11 -12
- 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/{agent-runtime-sqlite-bun.js → entrypoints/agent-runtime/sqlite/bun.js} +8 -6
- 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/{agent-runtime-sqlite-node.js → entrypoints/agent-runtime/sqlite/node.js} +8 -6
- 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 +1084 -0
- package/dist/{agent-runtime.d.ts → entrypoints/agent-runtime.d.ts} +41 -37
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -0
- package/dist/{agent-runtime.js → entrypoints/agent-runtime.js} +408 -366
- package/dist/{application-diagnostic-journal.d.ts → entrypoints/application/diagnostic-journal.d.ts} +2 -2
- package/dist/entrypoints/application/diagnostic-journal.d.ts.map +1 -0
- package/dist/{application-diagnostic-journal.js → entrypoints/application/diagnostic-journal.js} +3 -3
- package/dist/{application-grammy.d.ts → entrypoints/application/grammy.d.ts} +2 -2
- package/dist/entrypoints/application/grammy.d.ts.map +1 -0
- package/dist/{application-grammy.js → entrypoints/application/grammy.js} +2 -2
- package/dist/{application-opentelemetry.d.ts → entrypoints/application/opentelemetry.d.ts} +2 -2
- package/dist/entrypoints/application/opentelemetry.d.ts.map +1 -0
- package/dist/{application-opentelemetry.js → entrypoints/application/opentelemetry.js} +4 -4
- package/dist/{application-schemas.d.ts → entrypoints/application/schemas.d.ts} +2 -2
- package/dist/entrypoints/application/schemas.d.ts.map +1 -0
- package/dist/{application-schemas.js → entrypoints/application/schemas.js} +2 -2
- package/dist/{application.d.ts → entrypoints/application.d.ts} +22 -21
- package/dist/entrypoints/application.d.ts.map +1 -0
- package/dist/{application.js → entrypoints/application.js} +24 -22
- package/dist/entrypoints/bin/upgrade-cli.d.ts.map +1 -0
- package/dist/{upgrade-cli.js → entrypoints/bin/upgrade-cli.js} +3 -3
- package/dist/{cli.d.ts → entrypoints/cli.d.ts} +15 -15
- package/dist/entrypoints/cli.d.ts.map +1 -0
- package/dist/{cli.js → entrypoints/cli.js} +30 -32
- package/dist/entrypoints/contract.d.ts +9 -0
- package/dist/entrypoints/contract.d.ts.map +1 -0
- package/dist/{contract/index.js → entrypoints/contract.js} +14 -6
- package/dist/entrypoints/declaration.d.ts +2 -0
- package/dist/entrypoints/declaration.d.ts.map +1 -0
- package/dist/{declaration.js → entrypoints/declaration.js} +1 -1
- package/dist/{files.d.ts → entrypoints/files.d.ts} +2 -2
- package/dist/entrypoints/files.d.ts.map +1 -0
- package/dist/{files.js → entrypoints/files.js} +3 -3
- package/dist/{geo.d.ts → entrypoints/geo.d.ts} +1 -1
- package/dist/entrypoints/geo.d.ts.map +1 -0
- package/dist/{geo.js → entrypoints/geo.js} +4 -4
- package/dist/entrypoints/google.d.ts +2 -0
- package/dist/entrypoints/google.d.ts.map +1 -0
- package/dist/{google.js → entrypoints/google.js} +1 -1
- package/dist/{index.d.ts → entrypoints/index.d.ts} +14 -13
- package/dist/entrypoints/index.d.ts.map +1 -0
- package/dist/{index.js → entrypoints/index.js} +99 -33
- package/dist/{live.d.ts → entrypoints/live.d.ts} +4 -4
- package/dist/entrypoints/live.d.ts.map +1 -0
- package/dist/{live.js → entrypoints/live.js} +6 -4
- package/dist/{node.d.ts → entrypoints/node.d.ts} +11 -11
- package/dist/entrypoints/node.d.ts.map +1 -0
- package/dist/{node.js → entrypoints/node.js} +20 -16
- package/dist/entrypoints/oauth.d.ts +2 -0
- package/dist/entrypoints/oauth.d.ts.map +1 -0
- package/dist/{oauth.js → entrypoints/oauth.js} +3 -3
- package/dist/{observability/index.d.ts → entrypoints/observability.d.ts} +11 -11
- package/dist/entrypoints/observability.d.ts.map +1 -0
- package/dist/{observability/index.js → entrypoints/observability.js} +9 -11
- package/dist/entrypoints/primitives.d.ts +3 -0
- package/dist/entrypoints/primitives.d.ts.map +1 -0
- package/dist/{primitives.js → entrypoints/primitives.js} +1 -6
- package/dist/{react.d.ts → entrypoints/react.d.ts} +4 -4
- package/dist/entrypoints/react.d.ts.map +1 -0
- package/dist/{react.js → entrypoints/react.js} +3 -3
- package/dist/{release.d.ts → entrypoints/release.d.ts} +4 -4
- package/dist/entrypoints/release.d.ts.map +1 -0
- package/dist/{release.js → entrypoints/release.js} +1 -1
- package/dist/{remote.d.ts → entrypoints/remote.d.ts} +1 -1
- package/dist/entrypoints/remote.d.ts.map +1 -0
- package/dist/entrypoints/remote.js +66 -0
- package/dist/{server/index.d.ts → entrypoints/server.d.ts} +35 -34
- package/dist/entrypoints/server.d.ts.map +1 -0
- package/dist/{server/index.js → entrypoints/server.js} +294 -244
- package/dist/{telegram.d.ts → entrypoints/telegram.d.ts} +2 -2
- package/dist/entrypoints/telegram.d.ts.map +1 -0
- package/dist/{telegram.js → entrypoints/telegram.js} +1 -1
- package/dist/entrypoints/testing.d.ts +9 -0
- package/dist/entrypoints/testing.d.ts.map +1 -0
- package/dist/{testing.js → entrypoints/testing.js} +80 -919
- package/dist/{tools/connections/index.d.ts → entrypoints/tools/connections.d.ts} +6 -7
- package/dist/entrypoints/tools/connections.d.ts.map +1 -0
- package/dist/{tools/connections/index.js → entrypoints/tools/connections.js} +7 -4
- package/dist/{tools-contract.d.ts → entrypoints/tools/contract.d.ts} +5 -5
- package/dist/entrypoints/tools/contract.d.ts.map +1 -0
- package/dist/{tools-contract.js → entrypoints/tools/contract.js} +4 -4
- package/dist/{tool-invoker.d.ts → entrypoints/tools/invoker.d.ts} +2 -2
- package/dist/entrypoints/tools/invoker.d.ts.map +1 -0
- package/dist/entrypoints/tools/invoker.js +20 -0
- package/dist/entrypoints/tools.d.ts +51 -0
- package/dist/entrypoints/tools.d.ts.map +1 -0
- package/dist/{tools.js → entrypoints/tools.js} +1787 -1751
- package/dist/{tracking-server.d.ts → entrypoints/tracking/server.d.ts} +8 -8
- package/dist/entrypoints/tracking/server.d.ts.map +1 -0
- package/dist/{tracking.d.ts → entrypoints/tracking.d.ts} +15 -15
- package/dist/entrypoints/tracking.d.ts.map +1 -0
- package/dist/{tracking.js → entrypoints/tracking.js} +5 -8
- package/dist/google/google.d.ts.map +1 -0
- package/dist/{index-a916km3r.js → index-0b1ess5e.js} +6 -13
- package/dist/{index-zwkgfq1s.js → index-1nd48tm9.js} +113 -118
- package/dist/{index-7zbps32p.js → index-1zbbzgfh.js} +2 -2
- package/dist/{index-mzvgxp0n.js → index-2cr1cqhn.js} +16 -4
- package/dist/{index-f9mb610r.js → index-35mh5bhj.js} +2 -2
- package/dist/index-48ffdxgk.js +6 -0
- package/dist/index-58k4fp34.js +1023 -0
- package/dist/{index-p13mwz16.js → index-83bdg97s.js} +1 -1
- package/dist/index-97ac4gph.js +3618 -0
- package/dist/{index-kw9t5ayn.js → index-cq4qfycf.js} +5 -5
- package/dist/{index-7gnkny4z.js → index-d9pk3td4.js} +1 -1
- package/dist/{index-e42wzzz5.js → index-dcpdvjsc.js} +7 -7
- package/dist/{index-h9etkkyk.js → index-dydjcp8z.js} +102 -25
- package/dist/{index-sr93cwf9.js → index-e2z3ahw9.js} +2 -2
- package/dist/{index-yewwh1w4.js → index-e87kakm4.js} +96 -11
- package/dist/{index-cby4ar3v.js → index-eqqvgdb3.js} +1 -1
- package/dist/index-fdp6hdxn.js +942 -0
- package/dist/{index-0a349c33.js → index-gyr48nzg.js} +125 -198
- package/dist/{index-wnfk50r0.js → index-h6eeys1v.js} +1 -1
- package/dist/{index-77fekveh.js → index-hffjpmq9.js} +1 -15
- package/dist/{index-yn8remb1.js → index-j05z5gn4.js} +50 -14
- package/dist/index-k5hsfc3j.js +31 -0
- package/dist/{index-fq77yfzc.js → index-kj2wbeta.js} +1 -1
- package/dist/index-kvj7f4hq.js +39 -0
- package/dist/{index-4fpa9dy2.js → index-m9zn6cpq.js} +2 -2
- package/dist/{index-2na0qrfn.js → index-mdzh02yc.js} +7 -7
- package/dist/{index-ywd0y6m1.js → index-mkm15s49.js} +1 -1
- package/dist/index-mp5sn43f.js +1084 -0
- package/dist/{index-3bmnp41g.js → index-n6hxg8as.js} +507 -419
- package/dist/index-ngfhvfpd.js +30 -0
- package/dist/{index-e0znv5gn.js → index-p5r7qpdd.js} +2 -93
- package/dist/{index-n0f51dfn.js → index-p81267c2.js} +608 -549
- package/dist/{index-wc4x00bn.js → index-qwhynv6x.js} +1 -1
- package/dist/index-r7nmqpsg.js +154 -0
- package/dist/{index-bx75zwt7.js → index-rewkc2hj.js} +5 -4
- package/dist/{index-9f8ztey6.js → index-sees8yf8.js} +2 -2
- package/dist/{index-vjpvjqpn.js → index-v38qyerb.js} +16 -2
- package/dist/{index-2c2bjw3s.js → index-vcvkq30w.js} +3 -3
- package/dist/index-wqgjfstn.js +18 -0
- package/dist/{index-f477k430.js → index-x4799c19.js} +1 -1
- package/dist/{index-cxqhvq21.js → index-xnj9bgxe.js} +142 -129
- package/dist/index-xsqjkha9.js +281 -0
- package/dist/{index-6kyksz9y.js → index-yw4fzmdz.js} +1 -1
- package/dist/{index-3xwxfj4z.js → index-zeemqhqx.js} +1 -1
- package/dist/{index-tmwcrptx.js → index-zfrhfn82.js} +1 -1
- package/dist/index-znfs20ss.js +98 -0
- 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/logger.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/zod-issues.d.ts +38 -0
- package/dist/internal/zod-issues.d.ts.map +1 -0
- package/dist/{tools/json-schema-dialect.d.ts → json-schema/dialect.d.ts} +1 -1
- 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-delta.d.ts.map +1 -1
- package/dist/{oauth.d.ts → oauth/authorization-code.d.ts} +1 -1
- package/dist/oauth/authorization-code.d.ts.map +1 -0
- package/dist/observability/audit.d.ts +2 -2
- 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/{internal/observability-sink.d.ts → observability/bounded-sink.d.ts} +2 -2
- 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 +1 -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/socket.d.ts +1 -1
- package/dist/realtime/socket.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 +18 -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.d.ts +1 -1
- package/dist/server/implement.d.ts.map +1 -1
- package/dist/server/middleware/auth.d.ts +1 -1
- 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/trust-fence.d.ts +1 -1
- package/dist/server/middleware/trust-fence.d.ts.map +1 -1
- package/dist/server/multipart.d.ts +1 -1
- package/dist/server/multipart.d.ts.map +1 -1
- package/dist/{tools/oauth-metadata.d.ts → server/oauth/metadata.d.ts} +2 -2
- package/dist/server/oauth/metadata.d.ts.map +1 -0
- package/dist/{tools/oauth-provider.d.ts → server/oauth/provider.d.ts} +2 -2
- 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/types.d.ts +7 -4
- package/dist/server/types.d.ts.map +1 -1
- package/dist/testing/handler-clients.d.ts +31 -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/surface-conformance.d.ts +2 -1
- package/dist/testing/surface-conformance.d.ts.map +1 -1
- package/dist/testing/surface-manifest.d.ts +30 -4
- package/dist/testing/surface-manifest.d.ts.map +1 -1
- package/dist/tools/{cli-args.d.ts → cli/args.d.ts} +1 -1
- package/dist/tools/cli/args.d.ts.map +1 -0
- package/dist/tools/{cli-checkpoint.d.ts → cli/checkpoint.d.ts} +1 -1
- package/dist/tools/cli/checkpoint.d.ts.map +1 -0
- package/dist/tools/{cli-command.d.ts → cli/command.d.ts} +4 -4
- package/dist/tools/cli/command.d.ts.map +1 -0
- package/dist/tools/{cli.d.ts → cli/config.d.ts} +5 -9
- 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 → cli/format.d.ts} +2 -2
- 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 → cli/installer.d.ts} +2 -2
- package/dist/tools/cli/installer.d.ts.map +1 -0
- package/dist/tools/{cli-invoke.d.ts → cli/invoke.d.ts} +8 -8
- 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 → cli/manifest.d.ts} +1 -1
- package/dist/tools/cli/manifest.d.ts.map +1 -0
- package/dist/tools/{cli-policy.d.ts → cli/policy.d.ts} +2 -2
- 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 → cli/profile.d.ts} +2 -2
- 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 → cli/signature.d.ts} +2 -2
- package/dist/tools/cli/signature.d.ts.map +1 -0
- package/dist/tools/{cli-stream.d.ts → cli/stream.d.ts} +4 -4
- package/dist/tools/cli/stream.d.ts.map +1 -0
- package/dist/tools/{cli-update.d.ts → cli/update.d.ts} +3 -3
- package/dist/tools/cli/update.d.ts.map +1 -0
- package/dist/tools/{cli-view.d.ts → cli/view.d.ts} +2 -2
- package/dist/tools/cli/view.d.ts.map +1 -0
- package/dist/tools/{cli-wait.d.ts → cli/wait.d.ts} +2 -2
- 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.d.ts +30 -3
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/internal/surface-projector.d.ts +8 -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 +11 -3
- package/dist/tools/invoker.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 → mcp/app.d.ts} +1 -1
- package/dist/tools/mcp/app.d.ts.map +1 -0
- package/dist/tools/{mcp-catalog.d.ts → mcp/catalog.d.ts} +2 -2
- package/dist/tools/mcp/catalog.d.ts.map +1 -0
- package/dist/tools/{mcp-handler.d.ts → mcp/handler.d.ts} +5 -5
- package/dist/tools/mcp/handler.d.ts.map +1 -0
- package/dist/tools/{mcp.d.ts → mcp/mount.d.ts} +9 -9
- package/dist/tools/mcp/mount.d.ts.map +1 -0
- package/dist/tools/{mcp-prepare.d.ts → mcp/prepare.d.ts} +9 -9
- package/dist/tools/mcp/prepare.d.ts.map +1 -0
- package/dist/tools/{mcp-progress.d.ts → mcp/progress.d.ts} +2 -2
- package/dist/tools/mcp/progress.d.ts.map +1 -0
- package/dist/tools/mcp/register.d.ts +35 -0
- package/dist/tools/mcp/register.d.ts.map +1 -0
- package/dist/tools/{mcp-round-policy.d.ts → mcp/round-policy.d.ts} +2 -2
- package/dist/tools/mcp/round-policy.d.ts.map +1 -0
- package/dist/tools/{mcp-round.d.ts → mcp/round.d.ts} +4 -4
- package/dist/tools/mcp/round.d.ts.map +1 -0
- package/dist/tools/mcp/runtime-tools.d.ts +24 -0
- package/dist/tools/mcp/runtime-tools.d.ts.map +1 -0
- package/dist/tools/{mcp-stdio-signals.d.ts → mcp/stdio-signals.d.ts} +3 -3
- package/dist/tools/mcp/stdio-signals.d.ts.map +1 -0
- package/dist/tools/{mcp-stdio.d.ts → mcp/stdio.d.ts} +4 -4
- package/dist/tools/mcp/stdio.d.ts.map +1 -0
- package/dist/tools/{mcp-trace.d.ts → mcp/trace.d.ts} +1 -1
- package/dist/tools/mcp/trace.d.ts.map +1 -0
- package/dist/tools/mount.d.ts +12 -7
- package/dist/tools/mount.d.ts.map +1 -1
- package/dist/tools/native-definition.d.ts +3 -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 +40 -0
- package/dist/tools/operations/async-operation-runtime-tools.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-runtime-types.d.ts +68 -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/{define-wait-tool.d.ts → operations/define-wait-tool.d.ts} +2 -2
- 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 +11 -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/{presentation.d.ts → schema/presentation.d.ts} +2 -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/toolkit.d.ts +4 -4
- package/dist/tools/toolkit.d.ts.map +1 -1
- package/dist/tools/{define-download-tool.d.ts → transfer/define-download-tool.d.ts} +4 -4
- package/dist/tools/transfer/define-download-tool.d.ts.map +1 -0
- package/dist/tools/{define-upload-tool.d.ts → transfer/define-upload-tool.d.ts} +3 -3
- package/dist/tools/transfer/define-upload-tool.d.ts.map +1 -0
- package/dist/tools/{define-view-file-tool.d.ts → transfer/define-view-file-tool.d.ts} +2 -2
- package/dist/tools/transfer/define-view-file-tool.d.ts.map +1 -0
- package/dist/tools/{download-core.d.ts → transfer/download-core.d.ts} +2 -2
- package/dist/tools/transfer/download-core.d.ts.map +1 -0
- package/dist/tools/{managed-file-error.d.ts → transfer/managed-file-error.d.ts} +1 -1
- package/dist/tools/transfer/managed-file-error.d.ts.map +1 -0
- package/dist/tools/{mount-download.d.ts → transfer/mount-download.d.ts} +1 -1
- package/dist/tools/transfer/mount-download.d.ts.map +1 -0
- package/dist/tools/{mount-upload.d.ts → transfer/mount-upload.d.ts} +1 -1
- 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/{upload-core.d.ts → transfer/upload-core.d.ts} +1 -1
- 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/{view-file.d.ts → transfer/view-file.d.ts} +1 -1
- 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/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 +223 -0
- package/llms/application.txt +1144 -0
- package/llms/cli.txt +977 -0
- package/llms/contract.txt +606 -0
- package/llms/declaration.txt +286 -0
- package/llms/files.txt +30 -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 +838 -0
- package/llms/tools.txt +1004 -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 +214 -75
- package/llms.txt +54 -5
- package/package.json +84 -83
- package/dist/agent-runtime/durability-contract.d.ts.map +0 -1
- package/dist/agent-runtime/durability-json.d.ts.map +0 -1
- package/dist/agent-runtime/durability-ledger.d.ts.map +0 -1
- package/dist/agent-runtime/durability-scheduler.d.ts.map +0 -1
- package/dist/agent-runtime/durability.d.ts.map +0 -1
- 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-coding-tools.d.ts.map +0 -1
- package/dist/agent-runtime-coding-tools.js +0 -23
- package/dist/agent-runtime-harness.d.ts.map +0 -1
- package/dist/agent-runtime-openrouter.d.ts.map +0 -1
- package/dist/agent-runtime-sandbox.d.ts.map +0 -1
- package/dist/agent-runtime-sqlite-bun.d.ts.map +0 -1
- package/dist/agent-runtime-sqlite-node.d.ts.map +0 -1
- 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.map +0 -1
- package/dist/application/channel.d.ts.map +0 -1
- package/dist/application-diagnostic-journal.d.ts.map +0 -1
- package/dist/application-grammy.d.ts.map +0 -1
- package/dist/application-opentelemetry.d.ts.map +0 -1
- package/dist/application-schemas.d.ts.map +0 -1
- package/dist/application.d.ts.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/contract/index.d.ts +0 -8
- package/dist/contract/index.d.ts.map +0 -1
- package/dist/declaration.d.ts.map +0 -1
- package/dist/files.d.ts.map +0 -1
- package/dist/geo.d.ts.map +0 -1
- package/dist/google.d.ts.map +0 -1
- package/dist/index-0j3vcp5m.js +0 -28
- package/dist/index-a11g2kry.js +0 -866
- package/dist/index-cnyk6te3.js +0 -77
- package/dist/index-fadnxwna.js +0 -1046
- package/dist/index-hrbajay7.js +0 -1196
- package/dist/index-s8cnx02s.js +0 -90
- package/dist/index-v5573g1k.js +0 -142
- package/dist/index-vk3kq9sb.js +0 -3344
- package/dist/index.d.ts.map +0 -1
- package/dist/internal/errors.d.ts.map +0 -1
- package/dist/internal/observability-sink.d.ts.map +0 -1
- package/dist/live.d.ts.map +0 -1
- package/dist/logger.d.ts.map +0 -1
- package/dist/node.d.ts.map +0 -1
- package/dist/oauth.d.ts.map +0 -1
- package/dist/observability/index.d.ts.map +0 -1
- package/dist/primitives.d.ts +0 -3
- package/dist/primitives.d.ts.map +0 -1
- package/dist/react.d.ts.map +0 -1
- package/dist/release.d.ts.map +0 -1
- 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.map +0 -1
- package/dist/server/index.d.ts.map +0 -1
- package/dist/server/request.d.ts.map +0 -1
- package/dist/telegram.d.ts.map +0 -1
- 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/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.map +0 -1
- package/dist/tools/cli-checkpoint.d.ts.map +0 -1
- package/dist/tools/cli-command.d.ts.map +0 -1
- package/dist/tools/cli-format.d.ts.map +0 -1
- package/dist/tools/cli-installer.d.ts.map +0 -1
- package/dist/tools/cli-invoke.d.ts.map +0 -1
- package/dist/tools/cli-manifest.d.ts.map +0 -1
- package/dist/tools/cli-policy.d.ts.map +0 -1
- package/dist/tools/cli-profile.d.ts.map +0 -1
- package/dist/tools/cli-signature.d.ts.map +0 -1
- package/dist/tools/cli-stream.d.ts.map +0 -1
- package/dist/tools/cli-update.d.ts.map +0 -1
- package/dist/tools/cli-view.d.ts.map +0 -1
- package/dist/tools/cli-wait.d.ts.map +0 -1
- 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.map +0 -1
- package/dist/tools/define-download-tool.d.ts.map +0 -1
- package/dist/tools/define-upload-tool.d.ts.map +0 -1
- package/dist/tools/define-view-file-tool.d.ts.map +0 -1
- package/dist/tools/define-wait-tool.d.ts.map +0 -1
- 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.map +0 -1
- package/dist/tools/json-schema.d.ts.map +0 -1
- package/dist/tools/managed-file-error.d.ts.map +0 -1
- package/dist/tools/mcp-app.d.ts.map +0 -1
- package/dist/tools/mcp-catalog.d.ts.map +0 -1
- package/dist/tools/mcp-handler.d.ts.map +0 -1
- package/dist/tools/mcp-prepare.d.ts.map +0 -1
- package/dist/tools/mcp-progress.d.ts.map +0 -1
- package/dist/tools/mcp-round-policy.d.ts.map +0 -1
- package/dist/tools/mcp-round.d.ts.map +0 -1
- package/dist/tools/mcp-stdio-signals.d.ts.map +0 -1
- package/dist/tools/mcp-stdio.d.ts.map +0 -1
- package/dist/tools/mcp-trace.d.ts.map +0 -1
- package/dist/tools/mcp.d.ts.map +0 -1
- package/dist/tools/mount-download.d.ts.map +0 -1
- 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.map +0 -1
- 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.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.map +0 -1
- package/dist/tools/view-file-contract.d.ts.map +0 -1
- 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.map +0 -1
- package/dist/tools.d.ts +0 -50
- package/dist/tools.d.ts.map +0 -1
- package/dist/tracking-server.d.ts.map +0 -1
- package/dist/tracking.d.ts.map +0 -1
- package/dist/upgrade-cli.d.ts.map +0 -1
- 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/{index-actkayzn.js → index-70yj2ebz.js} +3 -3
- /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,1023 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AcceptInputAndAssignRunSchema,
|
|
3
|
+
AcquireAgentRunSchema,
|
|
4
|
+
AgentRecoverablePageSchema,
|
|
5
|
+
AgentRunViewSchema,
|
|
6
|
+
AgentStoreEventPageSchema,
|
|
7
|
+
AgentStoreTransitionSchema,
|
|
8
|
+
AppendAgentStoreEventSchema,
|
|
9
|
+
CheckpointRunAssistantSchema,
|
|
10
|
+
CommitRunTerminalSchema,
|
|
11
|
+
ReadAgentStoreEventsSchema,
|
|
12
|
+
RecordRunOperationSchema,
|
|
13
|
+
RecoverAgentRunSchema,
|
|
14
|
+
ReplaceCompactedRangeSchema,
|
|
15
|
+
RequestRunInterruptSchema,
|
|
16
|
+
SeedConversationInputSchema,
|
|
17
|
+
agentStoreEventDraft,
|
|
18
|
+
assistantStatus,
|
|
19
|
+
canonicalAgentJson,
|
|
20
|
+
decodeAgentConversationArchive,
|
|
21
|
+
encodeAgentConversationArchive
|
|
22
|
+
} from "./index-1nd48tm9.js";
|
|
23
|
+
import {
|
|
24
|
+
AgentMessageSchema,
|
|
25
|
+
AgentRecordIdSchema,
|
|
26
|
+
AgentRecordVersionSchema,
|
|
27
|
+
AgentRunSchema,
|
|
28
|
+
AgentSnapshotSchema,
|
|
29
|
+
runStateForTerminalReason
|
|
30
|
+
} from "./index-gtj3zc53.js";
|
|
31
|
+
|
|
32
|
+
// src/agent-runtime/purge.ts
|
|
33
|
+
import { z } from "zod";
|
|
34
|
+
var AgentConversationPurgeInputSchema = z.strictObject({
|
|
35
|
+
conversationId: AgentRecordIdSchema,
|
|
36
|
+
expectedVersion: AgentRecordVersionSchema.optional()
|
|
37
|
+
});
|
|
38
|
+
var AgentConversationPurgeResultSchema = z.discriminatedUnion("outcome", [
|
|
39
|
+
z.strictObject({ outcome: z.literal("purged") }),
|
|
40
|
+
z.strictObject({ outcome: z.literal("already_purged") }),
|
|
41
|
+
z.strictObject({ outcome: z.literal("unsupported") }),
|
|
42
|
+
z.strictObject({
|
|
43
|
+
outcome: z.literal("active"),
|
|
44
|
+
runIds: z.array(AgentRecordIdSchema).min(1)
|
|
45
|
+
}),
|
|
46
|
+
z.strictObject({ outcome: z.literal("conflict"), actualVersion: AgentRecordVersionSchema })
|
|
47
|
+
]);
|
|
48
|
+
|
|
49
|
+
class AgentConversationPurgedError extends Error {
|
|
50
|
+
constructor() {
|
|
51
|
+
super("Agent conversation has been purged; use a new conversation ID");
|
|
52
|
+
this.name = "AgentConversationPurgedError";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function purgeAgentConversation(store, input) {
|
|
56
|
+
const parsed = AgentConversationPurgeInputSchema.parse(input);
|
|
57
|
+
if (!store.purgeConversation)
|
|
58
|
+
return { outcome: "unsupported" };
|
|
59
|
+
return AgentConversationPurgeResultSchema.parse(await store.purgeConversation(parsed));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/agent-runtime/store-driver-contract.ts
|
|
63
|
+
import { z as z2 } from "zod";
|
|
64
|
+
var AgentRuntimeHeadSchema = z2.object({
|
|
65
|
+
schemaVersion: z2.literal(1),
|
|
66
|
+
conversationId: AgentRecordIdSchema,
|
|
67
|
+
version: AgentRecordVersionSchema
|
|
68
|
+
});
|
|
69
|
+
var AgentStoredRunSchema = z2.object({
|
|
70
|
+
schemaVersion: z2.literal(1),
|
|
71
|
+
run: AgentRunSchema,
|
|
72
|
+
terminalAssistant: AgentMessageSchema.optional()
|
|
73
|
+
});
|
|
74
|
+
var AgentAdmissionReceiptSchema = z2.object({
|
|
75
|
+
schemaVersion: z2.literal(1),
|
|
76
|
+
conversationId: AgentRecordIdSchema,
|
|
77
|
+
idempotencyKey: z2.string().min(1),
|
|
78
|
+
input: AgentMessageSchema,
|
|
79
|
+
runId: AgentRecordIdSchema,
|
|
80
|
+
assistantMessageId: AgentRecordIdSchema
|
|
81
|
+
});
|
|
82
|
+
var AgentSeedReceiptSchema = z2.object({
|
|
83
|
+
schemaVersion: z2.literal(1),
|
|
84
|
+
conversationId: AgentRecordIdSchema,
|
|
85
|
+
seedKey: z2.string().min(1),
|
|
86
|
+
messageIds: z2.array(AgentRecordIdSchema).min(1)
|
|
87
|
+
});
|
|
88
|
+
var AgentHistoryMutationSchema = z2.discriminatedUnion("type", [
|
|
89
|
+
z2.object({ type: z2.literal("admit"), input: AgentMessageSchema }),
|
|
90
|
+
z2.object({
|
|
91
|
+
type: z2.literal("upsert-assistant"),
|
|
92
|
+
message: AgentMessageSchema
|
|
93
|
+
}),
|
|
94
|
+
z2.object({
|
|
95
|
+
type: z2.literal("replace-compacted-range"),
|
|
96
|
+
replacedMessageIds: z2.array(AgentRecordIdSchema).min(1),
|
|
97
|
+
summary: AgentMessageSchema
|
|
98
|
+
}),
|
|
99
|
+
z2.object({
|
|
100
|
+
type: z2.literal("seed"),
|
|
101
|
+
message: AgentMessageSchema
|
|
102
|
+
})
|
|
103
|
+
]);
|
|
104
|
+
var ACTIVE_AGENT_RUN_STATES = [
|
|
105
|
+
"queued",
|
|
106
|
+
"running",
|
|
107
|
+
"interrupt_requested"
|
|
108
|
+
];
|
|
109
|
+
function isActiveRunState(state) {
|
|
110
|
+
return ACTIVE_AGENT_RUN_STATES.includes(state);
|
|
111
|
+
}
|
|
112
|
+
function emptyHead(conversationId) {
|
|
113
|
+
return AgentRuntimeHeadSchema.parse({
|
|
114
|
+
schemaVersion: 1,
|
|
115
|
+
conversationId,
|
|
116
|
+
version: 0
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// src/agent-runtime/store-create.ts
|
|
121
|
+
import { z as z5 } from "zod";
|
|
122
|
+
|
|
123
|
+
// src/agent-runtime/store-archive.ts
|
|
124
|
+
import { z as z3 } from "zod";
|
|
125
|
+
|
|
126
|
+
// src/agent-runtime/store-snapshot.ts
|
|
127
|
+
function historyPositions(messages) {
|
|
128
|
+
const positions = new Map;
|
|
129
|
+
messages.forEach((message, index) => {
|
|
130
|
+
if (!positions.has(message.id))
|
|
131
|
+
positions.set(message.id, index);
|
|
132
|
+
});
|
|
133
|
+
return (run) => {
|
|
134
|
+
let earliest = Number.MAX_SAFE_INTEGER;
|
|
135
|
+
for (const id of [...run.inputMessageIds, run.assistantMessageId]) {
|
|
136
|
+
const position = positions.get(id);
|
|
137
|
+
if (position !== undefined && position < earliest)
|
|
138
|
+
earliest = position;
|
|
139
|
+
}
|
|
140
|
+
return earliest;
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function orderRuns(messages, runs) {
|
|
144
|
+
const positionOf = historyPositions(messages);
|
|
145
|
+
const fallback = (left, right) => left.createdAt.localeCompare(right.createdAt) || positionOf(left) - positionOf(right) || left.id.localeCompare(right.id);
|
|
146
|
+
return [...runs].sort((left, right) => {
|
|
147
|
+
if (left.executionSequence !== undefined && right.executionSequence !== undefined && left.executionSequence !== right.executionSequence) {
|
|
148
|
+
return left.executionSequence - right.executionSequence;
|
|
149
|
+
}
|
|
150
|
+
const leftStarted = left.executionSequence !== undefined || left.state !== "queued";
|
|
151
|
+
const rightStarted = right.executionSequence !== undefined || right.state !== "queued";
|
|
152
|
+
if (leftStarted !== rightStarted)
|
|
153
|
+
return leftStarted ? -1 : 1;
|
|
154
|
+
if (!leftStarted && !rightStarted) {
|
|
155
|
+
const priority = Number(right.queuePriority !== undefined) - Number(left.queuePriority !== undefined);
|
|
156
|
+
if (priority !== 0)
|
|
157
|
+
return priority;
|
|
158
|
+
}
|
|
159
|
+
return fallback(left, right);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
function orderRunMessages(messages, runs) {
|
|
163
|
+
const byId = new Map(messages.map((message) => [message.id, message]));
|
|
164
|
+
const ownedIds = new Set(runs.flatMap((run) => [...run.inputMessageIds, run.assistantMessageId]));
|
|
165
|
+
const orderedOwned = runs.flatMap((run) => [...run.inputMessageIds, run.assistantMessageId].flatMap((id) => {
|
|
166
|
+
const message = byId.get(id);
|
|
167
|
+
return message ? [message] : [];
|
|
168
|
+
}));
|
|
169
|
+
let ownedIndex = 0;
|
|
170
|
+
return messages.map((message) => {
|
|
171
|
+
if (!ownedIds.has(message.id))
|
|
172
|
+
return message;
|
|
173
|
+
const ordered = orderedOwned[ownedIndex];
|
|
174
|
+
if (!ordered)
|
|
175
|
+
throw new TypeError("Stored agent history lost a run-owned message");
|
|
176
|
+
ownedIndex += 1;
|
|
177
|
+
return ordered;
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
function snapshotOf(head, messages, records) {
|
|
181
|
+
validateSnapshot(head, messages, records);
|
|
182
|
+
const runs = orderRuns(messages, records.map((record) => record.run));
|
|
183
|
+
return AgentSnapshotSchema.parse({
|
|
184
|
+
schemaVersion: 1,
|
|
185
|
+
conversationId: head.conversationId,
|
|
186
|
+
version: head.version,
|
|
187
|
+
messages: orderRunMessages(messages, runs),
|
|
188
|
+
runs
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
function validateSnapshot(head, messages, records) {
|
|
192
|
+
const runIds = new Set;
|
|
193
|
+
const assistantIds = new Set;
|
|
194
|
+
const messageIds = new Set;
|
|
195
|
+
for (const record of records) {
|
|
196
|
+
const run = record.run;
|
|
197
|
+
if (run.conversationId !== head.conversationId || runIds.has(run.id) || assistantIds.has(run.assistantMessageId)) {
|
|
198
|
+
throw new TypeError("Stored agent runs contain inconsistent identities");
|
|
199
|
+
}
|
|
200
|
+
if (record.terminalAssistant && (record.terminalAssistant.id !== run.assistantMessageId || record.terminalAssistant.conversationId !== run.conversationId || record.terminalAssistant.runId !== run.id || record.terminalAssistant.role !== "assistant" || run.terminalReason === undefined)) {
|
|
201
|
+
throw new TypeError("Retained terminal assistant does not match its run");
|
|
202
|
+
}
|
|
203
|
+
runIds.add(run.id);
|
|
204
|
+
assistantIds.add(run.assistantMessageId);
|
|
205
|
+
}
|
|
206
|
+
for (const message of messages) {
|
|
207
|
+
if (message.conversationId !== head.conversationId || messageIds.has(message.id)) {
|
|
208
|
+
throw new TypeError("Stored agent history contains inconsistent message identities");
|
|
209
|
+
}
|
|
210
|
+
messageIds.add(message.id);
|
|
211
|
+
if (assistantIds.has(message.id) && message.runId === undefined) {
|
|
212
|
+
throw new TypeError("Stored history occupies a reserved assistant identity");
|
|
213
|
+
}
|
|
214
|
+
if (message.runId !== undefined) {
|
|
215
|
+
const run = records.find((candidate) => candidate.run.id === message.runId)?.run;
|
|
216
|
+
if (!run || message.role !== "assistant" || run.assistantMessageId !== message.id) {
|
|
217
|
+
throw new TypeError("Stored assistant history does not match its reserved run identity");
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function replaceRun(runs, next) {
|
|
223
|
+
return runs.map((run) => run.id === next.id ? next : run);
|
|
224
|
+
}
|
|
225
|
+
function replaceMessage(messages, next) {
|
|
226
|
+
return messages.some((message) => message.id === next.id) ? messages.map((message) => message.id === next.id ? next : message) : [...messages, next];
|
|
227
|
+
}
|
|
228
|
+
function mergeRunRecords(...groups) {
|
|
229
|
+
const records = new Map;
|
|
230
|
+
for (const group of groups) {
|
|
231
|
+
for (const rawRecord of group) {
|
|
232
|
+
const record = AgentStoredRunSchema.parse(rawRecord);
|
|
233
|
+
const previous = records.get(record.run.id);
|
|
234
|
+
if (previous && previous.run.assistantMessageId !== record.run.assistantMessageId) {
|
|
235
|
+
throw new TypeError("Stored agent run identity changed across normalized records");
|
|
236
|
+
}
|
|
237
|
+
records.set(record.run.id, record);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return [...records.values()];
|
|
241
|
+
}
|
|
242
|
+
function referencedRunIds(messages) {
|
|
243
|
+
return [...new Set(messages.flatMap((message) => message.runId ? [message.runId] : []))];
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// src/agent-runtime/store-reads.ts
|
|
247
|
+
async function snapshotIn(driver, transaction, conversationId) {
|
|
248
|
+
const [stored, messages, activeRecords] = await Promise.all([
|
|
249
|
+
driver.head.load(transaction, conversationId),
|
|
250
|
+
driver.history.load(transaction, conversationId),
|
|
251
|
+
driver.runs.listActive(transaction, conversationId)
|
|
252
|
+
]);
|
|
253
|
+
const head = AgentRuntimeHeadSchema.parse(stored ?? emptyHead(conversationId));
|
|
254
|
+
const referencedRecords = await driver.runs.loadMany(transaction, {
|
|
255
|
+
conversationId,
|
|
256
|
+
runIds: referencedRunIds(messages)
|
|
257
|
+
});
|
|
258
|
+
return snapshotOf(head, messages, mergeRunRecords(activeRecords, referencedRecords));
|
|
259
|
+
}
|
|
260
|
+
function loadSnapshot(driver, conversationId) {
|
|
261
|
+
return driver.transaction((transaction) => snapshotIn(driver, transaction, conversationId), {
|
|
262
|
+
access: "read"
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
function loadRun(driver, input) {
|
|
266
|
+
return driver.transaction(async (transaction) => {
|
|
267
|
+
const [stored, record] = await Promise.all([
|
|
268
|
+
driver.head.load(transaction, input.conversationId),
|
|
269
|
+
driver.runs.load(transaction, input)
|
|
270
|
+
]);
|
|
271
|
+
if (!record)
|
|
272
|
+
return;
|
|
273
|
+
const parsed = AgentStoredRunSchema.parse(record);
|
|
274
|
+
if (parsed.run.conversationId !== input.conversationId || parsed.run.id !== input.runId) {
|
|
275
|
+
throw new TypeError("Stored run does not match the identity it was loaded by");
|
|
276
|
+
}
|
|
277
|
+
const head = AgentRuntimeHeadSchema.parse(stored ?? emptyHead(input.conversationId));
|
|
278
|
+
return AgentRunViewSchema.parse({
|
|
279
|
+
snapshotVersion: head.version,
|
|
280
|
+
run: parsed.run,
|
|
281
|
+
...parsed.terminalAssistant && { assistant: parsed.terminalAssistant }
|
|
282
|
+
});
|
|
283
|
+
}, { access: "read" });
|
|
284
|
+
}
|
|
285
|
+
function listActiveRuns(driver, conversationId) {
|
|
286
|
+
return driver.transaction(async (transaction) => {
|
|
287
|
+
const [records, messages] = await Promise.all([
|
|
288
|
+
driver.runs.listActive(transaction, conversationId),
|
|
289
|
+
driver.history.load(transaction, conversationId)
|
|
290
|
+
]);
|
|
291
|
+
const runs = records.map((record) => AgentStoredRunSchema.parse(record).run);
|
|
292
|
+
for (const run of runs) {
|
|
293
|
+
if (run.conversationId !== conversationId) {
|
|
294
|
+
throw new TypeError("Active run belongs to another conversation");
|
|
295
|
+
}
|
|
296
|
+
if (!isActiveRunState(run.state)) {
|
|
297
|
+
throw new TypeError("Active run listing returned a terminal run");
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return orderRuns(messages, runs);
|
|
301
|
+
}, { access: "read" });
|
|
302
|
+
}
|
|
303
|
+
function appendEvent(driver, input) {
|
|
304
|
+
const parsed = AppendAgentStoreEventSchema.parse(input);
|
|
305
|
+
return driver.transaction((transaction) => appendEventIn(driver, transaction, parsed));
|
|
306
|
+
}
|
|
307
|
+
async function appendEventIn(driver, transaction, parsed) {
|
|
308
|
+
if (await driver.conversations?.isPurged(transaction, parsed.conversationId)) {
|
|
309
|
+
throw new AgentConversationPurgedError;
|
|
310
|
+
}
|
|
311
|
+
return driver.events.append(transaction, agentStoreEventDraft(parsed));
|
|
312
|
+
}
|
|
313
|
+
function readEvents(driver, input) {
|
|
314
|
+
const parsed = ReadAgentStoreEventsSchema.parse(input);
|
|
315
|
+
return driver.transaction(async (transaction) => AgentStoreEventPageSchema.parse(await driver.events.list(transaction, parsed)), { access: "read" });
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// src/agent-runtime/store-archive.ts
|
|
319
|
+
function exportConversation(driver, conversationId) {
|
|
320
|
+
return driver.transaction(async (transaction) => {
|
|
321
|
+
const events = [];
|
|
322
|
+
let fromSeq;
|
|
323
|
+
do {
|
|
324
|
+
const page = AgentStoreEventPageSchema.parse(await driver.events.list(transaction, ReadAgentStoreEventsSchema.parse({
|
|
325
|
+
conversationId,
|
|
326
|
+
...fromSeq && { fromSeq },
|
|
327
|
+
limit: 1e4
|
|
328
|
+
})));
|
|
329
|
+
events.push(...page.items);
|
|
330
|
+
fromSeq = page.nextSeq;
|
|
331
|
+
} while (fromSeq !== undefined);
|
|
332
|
+
const durable = await driver.archive?.export(transaction, conversationId) ?? {
|
|
333
|
+
projections: [],
|
|
334
|
+
spills: []
|
|
335
|
+
};
|
|
336
|
+
const snapshot = await snapshotIn(driver, transaction, conversationId);
|
|
337
|
+
return encodeAgentConversationArchive({
|
|
338
|
+
format: "stitchkit.agent-conversation",
|
|
339
|
+
formatVersion: 1,
|
|
340
|
+
conversationId,
|
|
341
|
+
events,
|
|
342
|
+
projections: [
|
|
343
|
+
{ archiveType: "runtime-snapshot", snapshot: z3.json().parse(snapshot) },
|
|
344
|
+
...durable.projections
|
|
345
|
+
],
|
|
346
|
+
spills: durable.spills
|
|
347
|
+
});
|
|
348
|
+
}, { access: "read" });
|
|
349
|
+
}
|
|
350
|
+
async function importConversation(driver, bytes) {
|
|
351
|
+
const archive = decodeAgentConversationArchive(bytes);
|
|
352
|
+
return driver.transaction(async (transaction) => {
|
|
353
|
+
const existing = await driver.events.list(transaction, {
|
|
354
|
+
conversationId: archive.conversationId,
|
|
355
|
+
limit: 1
|
|
356
|
+
});
|
|
357
|
+
if (existing.items.length > 0) {
|
|
358
|
+
throw new TypeError("Conversation event log must be empty before import");
|
|
359
|
+
}
|
|
360
|
+
for (const event of archive.events) {
|
|
361
|
+
const appended = await driver.events.append(transaction, {
|
|
362
|
+
schemaVersion: event.schemaVersion,
|
|
363
|
+
eventId: event.eventId,
|
|
364
|
+
conversationId: event.conversationId,
|
|
365
|
+
kind: event.kind,
|
|
366
|
+
occurredAt: event.occurredAt,
|
|
367
|
+
payload: event.payload,
|
|
368
|
+
...event.ignorable && { ignorable: true }
|
|
369
|
+
});
|
|
370
|
+
if (appended.seq !== event.seq) {
|
|
371
|
+
throw new TypeError("Conversation archive event sequence is not contiguous");
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
const snapshotEntry = archive.projections.find((entry) => typeof entry === "object" && entry !== null && !Array.isArray(entry) && entry.archiveType === "runtime-snapshot");
|
|
375
|
+
if (snapshotEntry && typeof snapshotEntry === "object" && !Array.isArray(snapshotEntry)) {
|
|
376
|
+
const snapshot = AgentSnapshotSchema.parse(snapshotEntry.snapshot);
|
|
377
|
+
if (snapshot.conversationId !== archive.conversationId) {
|
|
378
|
+
throw new TypeError("Conversation archive snapshot belongs to another conversation");
|
|
379
|
+
}
|
|
380
|
+
if (snapshot.version > 0 || snapshot.messages.length > 0 || snapshot.runs.length > 0) {
|
|
381
|
+
const outcome = await driver.head.compareAndSwap(transaction, {
|
|
382
|
+
conversationId: snapshot.conversationId,
|
|
383
|
+
expectedVersion: 0,
|
|
384
|
+
next: AgentRuntimeHeadSchema.parse({
|
|
385
|
+
schemaVersion: 1,
|
|
386
|
+
conversationId: snapshot.conversationId,
|
|
387
|
+
version: snapshot.version
|
|
388
|
+
})
|
|
389
|
+
});
|
|
390
|
+
if (outcome.outcome !== "applied") {
|
|
391
|
+
throw new TypeError("Conversation archive snapshot target is not empty");
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
for (const run of snapshot.runs) {
|
|
395
|
+
const terminalAssistant = snapshot.messages.find((message) => message.id === run.assistantMessageId);
|
|
396
|
+
await driver.runs.save(transaction, AgentStoredRunSchema.parse({
|
|
397
|
+
schemaVersion: 1,
|
|
398
|
+
run,
|
|
399
|
+
...terminalAssistant && { terminalAssistant }
|
|
400
|
+
}));
|
|
401
|
+
}
|
|
402
|
+
for (const message of snapshot.messages) {
|
|
403
|
+
await driver.history.apply(transaction, { type: "admit", input: message });
|
|
404
|
+
}
|
|
405
|
+
for (const event of archive.events) {
|
|
406
|
+
if (event.kind !== "runtime/transition")
|
|
407
|
+
continue;
|
|
408
|
+
const transition = AgentStoreTransitionSchema.parse(event.payload);
|
|
409
|
+
if (transition.type !== "accept")
|
|
410
|
+
continue;
|
|
411
|
+
const assigned = snapshot.runs.find((run) => run.inputMessageIds.includes(transition.input.input.id));
|
|
412
|
+
if (!assigned) {
|
|
413
|
+
throw new TypeError("Conversation archive admission has no assigned run");
|
|
414
|
+
}
|
|
415
|
+
await driver.admissions.create(transaction, AgentAdmissionReceiptSchema.parse({
|
|
416
|
+
schemaVersion: 1,
|
|
417
|
+
conversationId: archive.conversationId,
|
|
418
|
+
idempotencyKey: transition.input.idempotencyKey,
|
|
419
|
+
input: transition.input.input,
|
|
420
|
+
runId: assigned.id,
|
|
421
|
+
assistantMessageId: assigned.assistantMessageId
|
|
422
|
+
}));
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
await driver.archive?.import(transaction, archive);
|
|
426
|
+
return { conversationId: archive.conversationId, events: archive.events.length };
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// src/agent-runtime/store-mutate.ts
|
|
431
|
+
import { z as z4 } from "zod";
|
|
432
|
+
|
|
433
|
+
// src/agent-runtime/store-reduce-shared.ts
|
|
434
|
+
function conflict(actualVersion) {
|
|
435
|
+
return { outcome: "conflict", actualVersion };
|
|
436
|
+
}
|
|
437
|
+
function applied(current, input, effects) {
|
|
438
|
+
const runs = input.runs ?? current.runs;
|
|
439
|
+
const messages = input.messages ?? current.messages;
|
|
440
|
+
return {
|
|
441
|
+
outcome: "applied",
|
|
442
|
+
snapshot: AgentSnapshotSchema.parse({
|
|
443
|
+
...current,
|
|
444
|
+
version: current.version + 1,
|
|
445
|
+
runs,
|
|
446
|
+
messages: orderRunMessages(messages, runs)
|
|
447
|
+
}),
|
|
448
|
+
...effects?.runRecords?.length && { runRecords: effects.runRecords },
|
|
449
|
+
...effects?.admissionReceipt && { admissionReceipt: effects.admissionReceipt },
|
|
450
|
+
...effects?.seedReceipt && { seedReceipt: effects.seedReceipt },
|
|
451
|
+
...effects?.historyMutations?.length && { historyMutations: effects.historyMutations }
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// src/agent-runtime/store-reducer.ts
|
|
456
|
+
import { createHash } from "node:crypto";
|
|
457
|
+
|
|
458
|
+
// src/agent-runtime/store-reduce-history.ts
|
|
459
|
+
function reduceAccept(current, input) {
|
|
460
|
+
if (input.expectedVersion !== undefined && input.expectedVersion !== current.version) {
|
|
461
|
+
return conflict(current.version);
|
|
462
|
+
}
|
|
463
|
+
const coalescedRun = input.coalesceIntoRunId ? current.runs.find((candidate) => candidate.id === input.coalesceIntoRunId) : undefined;
|
|
464
|
+
if (input.coalesceIntoRunId !== undefined && (!coalescedRun || coalescedRun.conversationId !== input.input.conversationId || coalescedRun.state !== "queued" || coalescedRun.ownerId !== undefined || coalescedRun.terminalReason !== undefined)) {
|
|
465
|
+
return coalescedRun ? conflict(coalescedRun.revision) : { outcome: "not_found" };
|
|
466
|
+
}
|
|
467
|
+
if (input.run.conversationId !== input.input.conversationId || input.run.inputMessageIds.length !== 1 || input.run.inputMessageIds[0] !== input.input.id || input.run.state !== "queued" || input.run.revision !== 0 || input.run.executionSequence !== undefined || input.run.ownerId !== undefined || input.run.terminalReason !== undefined || input.run.terminalPolicyName !== undefined || input.input.role !== "user" && input.input.role !== "tool" || input.input.status !== "committed" || input.input.runId !== undefined || current.messages.some((message) => message.id === input.input.id) || coalescedRun !== undefined && input.input.id === coalescedRun.assistantMessageId || !coalescedRun && (input.run.assistantMessageId === input.input.id || current.runs.some((candidate) => candidate.id === input.run.id) || current.runs.some((candidate) => candidate.assistantMessageId === input.run.assistantMessageId) || current.messages.some((message) => message.id === input.run.assistantMessageId))) {
|
|
468
|
+
throw new TypeError("Input and queued run do not form one valid assignment");
|
|
469
|
+
}
|
|
470
|
+
const assignedRun = coalescedRun ? AgentRunSchema.parse({
|
|
471
|
+
...coalescedRun,
|
|
472
|
+
inputMessageIds: [...coalescedRun.inputMessageIds, input.input.id],
|
|
473
|
+
revision: coalescedRun.revision + 1,
|
|
474
|
+
updatedAt: new Date().toISOString()
|
|
475
|
+
}) : input.run;
|
|
476
|
+
const admissionReceipt = AgentAdmissionReceiptSchema.parse({
|
|
477
|
+
schemaVersion: 1,
|
|
478
|
+
conversationId: input.input.conversationId,
|
|
479
|
+
idempotencyKey: input.idempotencyKey,
|
|
480
|
+
input: input.input,
|
|
481
|
+
runId: assignedRun.id,
|
|
482
|
+
assistantMessageId: assignedRun.assistantMessageId
|
|
483
|
+
});
|
|
484
|
+
return applied(current, {
|
|
485
|
+
messages: [...current.messages, input.input],
|
|
486
|
+
runs: coalescedRun ? replaceRun(current.runs, assignedRun) : [...current.runs, assignedRun]
|
|
487
|
+
}, {
|
|
488
|
+
runRecords: [AgentStoredRunSchema.parse({ schemaVersion: 1, run: assignedRun })],
|
|
489
|
+
admissionReceipt,
|
|
490
|
+
historyMutations: [{ type: "admit", input: input.input }]
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
function reduceSeed(current, input) {
|
|
494
|
+
const conversationId = input.conversationId;
|
|
495
|
+
if (current.conversationId !== conversationId)
|
|
496
|
+
return { outcome: "not_found" };
|
|
497
|
+
for (const message of input.inputs) {
|
|
498
|
+
if (message.conversationId !== conversationId || message.role !== "user" || message.status !== "committed" || message.runId !== undefined) {
|
|
499
|
+
throw new TypeError("Seeded conversation input must be committed unowned user messages");
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
return applied(current, { messages: [...input.inputs, ...current.messages] }, {
|
|
503
|
+
seedReceipt: AgentSeedReceiptSchema.parse({
|
|
504
|
+
schemaVersion: 1,
|
|
505
|
+
conversationId,
|
|
506
|
+
seedKey: input.seedKey,
|
|
507
|
+
messageIds: input.inputs.map((message) => message.id)
|
|
508
|
+
}),
|
|
509
|
+
historyMutations: [...input.inputs].reverse().map((message) => ({
|
|
510
|
+
type: "seed",
|
|
511
|
+
message
|
|
512
|
+
}))
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
function reduceCompact(current, input) {
|
|
516
|
+
if (current.conversationId !== input.conversationId)
|
|
517
|
+
return { outcome: "not_found" };
|
|
518
|
+
if (current.version !== input.expectedVersion)
|
|
519
|
+
return conflict(current.version);
|
|
520
|
+
const replaced = new Set(input.replacedMessageIds);
|
|
521
|
+
if (!input.replacedMessageIds.every((id) => current.messages.some((m) => m.id === id))) {
|
|
522
|
+
return { outcome: "not_found" };
|
|
523
|
+
}
|
|
524
|
+
const liveAssistant = current.runs.find((candidate) => isActiveRunState(candidate.state) && replaced.has(candidate.assistantMessageId));
|
|
525
|
+
if (liveAssistant) {
|
|
526
|
+
throw new TypeError(`Compaction may not replace the assistant message of run ${liveAssistant.id}, which has not finished`);
|
|
527
|
+
}
|
|
528
|
+
const positions = current.messages.map((message, index) => replaced.has(message.id) ? index : undefined).filter((index) => index !== undefined);
|
|
529
|
+
const first = positions[0];
|
|
530
|
+
if (first === undefined || positions.some((position, offset) => position !== first + offset) || input.summary.conversationId !== input.conversationId || input.summary.runId !== undefined || input.summary.role !== "summary" || input.summary.status !== "committed" || current.messages.some((message) => message.id === input.summary.id) || current.runs.some((candidate) => candidate.assistantMessageId === input.summary.id)) {
|
|
531
|
+
throw new TypeError("Compaction replacement must be one valid contiguous history range");
|
|
532
|
+
}
|
|
533
|
+
const messages = [
|
|
534
|
+
...current.messages.slice(0, first),
|
|
535
|
+
input.summary,
|
|
536
|
+
...current.messages.slice(first + positions.length)
|
|
537
|
+
];
|
|
538
|
+
return applied(current, { messages }, {
|
|
539
|
+
historyMutations: [
|
|
540
|
+
{
|
|
541
|
+
type: "replace-compacted-range",
|
|
542
|
+
replacedMessageIds: input.replacedMessageIds,
|
|
543
|
+
summary: input.summary
|
|
544
|
+
}
|
|
545
|
+
]
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// src/agent-runtime/store-reduce-run.ts
|
|
550
|
+
function reduceAcquire(current, run, input) {
|
|
551
|
+
const runPosition = current.runs.findIndex((candidate) => candidate.id === run.id);
|
|
552
|
+
const acquisitionBlocked = current.runs.some((candidate, index) => candidate.id !== run.id && (candidate.state === "running" || candidate.state === "interrupt_requested" || index < runPosition && candidate.state === "queued"));
|
|
553
|
+
if (run.revision !== input.expectedRevision || run.state !== "queued" || acquisitionBlocked) {
|
|
554
|
+
return conflict(run.revision);
|
|
555
|
+
}
|
|
556
|
+
const next = AgentRunSchema.parse({
|
|
557
|
+
...run,
|
|
558
|
+
state: "running",
|
|
559
|
+
executionSequence: run.executionSequence ?? current.version + 1,
|
|
560
|
+
ownerId: input.ownerId,
|
|
561
|
+
fencingToken: (run.fencingToken ?? 0) + 1,
|
|
562
|
+
revision: run.revision + 1,
|
|
563
|
+
updatedAt: new Date().toISOString()
|
|
564
|
+
});
|
|
565
|
+
return applied(current, { runs: replaceRun(current.runs, next) }, {
|
|
566
|
+
runRecords: [AgentStoredRunSchema.parse({ schemaVersion: 1, run: next })]
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
function reduceCheckpoint(current, run, input) {
|
|
570
|
+
if (run.revision !== input.expectedRevision || run.state !== "running" || run.ownerId !== input.ownerId || input.fencingToken !== undefined && run.fencingToken !== input.fencingToken || input.assistant.runId !== run.id || input.assistant.id !== run.assistantMessageId || input.assistant.conversationId !== run.conversationId || input.assistant.role !== "assistant" || input.assistant.status !== "streaming") {
|
|
571
|
+
return conflict(run.revision);
|
|
572
|
+
}
|
|
573
|
+
const next = AgentRunSchema.parse({
|
|
574
|
+
...run,
|
|
575
|
+
...input.usage && { usage: input.usage },
|
|
576
|
+
revision: run.revision + 1,
|
|
577
|
+
updatedAt: new Date().toISOString()
|
|
578
|
+
});
|
|
579
|
+
return applied(current, {
|
|
580
|
+
runs: replaceRun(current.runs, next),
|
|
581
|
+
messages: replaceMessage(current.messages, input.assistant)
|
|
582
|
+
}, {
|
|
583
|
+
runRecords: [AgentStoredRunSchema.parse({ schemaVersion: 1, run: next })],
|
|
584
|
+
historyMutations: [{ type: "upsert-assistant", message: input.assistant }]
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
function reduceOperation(current, run, input) {
|
|
588
|
+
if (run.revision !== input.expectedRevision || run.state !== "running" && run.state !== "interrupt_requested" || run.ownerId !== input.ownerId || input.fencingToken !== undefined && run.fencingToken !== input.fencingToken) {
|
|
589
|
+
return conflict(run.revision);
|
|
590
|
+
}
|
|
591
|
+
const next = AgentRunSchema.parse({
|
|
592
|
+
...run,
|
|
593
|
+
lastOperation: input.operation,
|
|
594
|
+
revision: run.revision + 1,
|
|
595
|
+
updatedAt: new Date().toISOString()
|
|
596
|
+
});
|
|
597
|
+
return applied(current, { runs: replaceRun(current.runs, next) }, { runRecords: [AgentStoredRunSchema.parse({ schemaVersion: 1, run: next })] });
|
|
598
|
+
}
|
|
599
|
+
function reduceInterrupt(current, run, input) {
|
|
600
|
+
if (run.revision !== input.expectedRevision || run.state !== "running") {
|
|
601
|
+
return conflict(run.revision);
|
|
602
|
+
}
|
|
603
|
+
const next = AgentRunSchema.parse({
|
|
604
|
+
...run,
|
|
605
|
+
state: "interrupt_requested",
|
|
606
|
+
revision: run.revision + 1,
|
|
607
|
+
updatedAt: new Date().toISOString()
|
|
608
|
+
});
|
|
609
|
+
return applied(current, { runs: replaceRun(current.runs, next) }, {
|
|
610
|
+
runRecords: [AgentStoredRunSchema.parse({ schemaVersion: 1, run: next })]
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
function reduceRecover(current, run, input) {
|
|
614
|
+
if (run.revision !== input.expectedRevision || !isActiveRunState(run.state)) {
|
|
615
|
+
return conflict(run.revision);
|
|
616
|
+
}
|
|
617
|
+
if (input.action === "requeue" && run.state !== "queued" && input.replaySafe !== true) {
|
|
618
|
+
throw new TypeError("Recovering an acquired run requires explicit replaySafe evidence");
|
|
619
|
+
}
|
|
620
|
+
const { ownerId: _released, ...carried } = run;
|
|
621
|
+
const next = AgentRunSchema.parse({
|
|
622
|
+
...carried,
|
|
623
|
+
state: input.action === "requeue" ? "queued" : "abandoned",
|
|
624
|
+
revision: run.revision + 1,
|
|
625
|
+
...input.action === "abandon" && { terminalReason: "abandoned" },
|
|
626
|
+
updatedAt: new Date().toISOString()
|
|
627
|
+
});
|
|
628
|
+
if (input.action === "abandon") {
|
|
629
|
+
const existingAssistant = current.messages.find((message) => message.id === run.assistantMessageId);
|
|
630
|
+
const assistant = AgentMessageSchema.parse({
|
|
631
|
+
...existingAssistant ?? {
|
|
632
|
+
schemaVersion: 1,
|
|
633
|
+
id: run.assistantMessageId,
|
|
634
|
+
conversationId: run.conversationId,
|
|
635
|
+
runId: run.id,
|
|
636
|
+
role: "assistant",
|
|
637
|
+
parts: [],
|
|
638
|
+
createdAt: run.createdAt
|
|
639
|
+
},
|
|
640
|
+
status: "failed",
|
|
641
|
+
updatedAt: new Date().toISOString()
|
|
642
|
+
});
|
|
643
|
+
return applied(current, {
|
|
644
|
+
runs: replaceRun(current.runs, next),
|
|
645
|
+
messages: replaceMessage(current.messages, assistant)
|
|
646
|
+
}, {
|
|
647
|
+
runRecords: [
|
|
648
|
+
AgentStoredRunSchema.parse({
|
|
649
|
+
schemaVersion: 1,
|
|
650
|
+
run: next,
|
|
651
|
+
terminalAssistant: assistant
|
|
652
|
+
})
|
|
653
|
+
],
|
|
654
|
+
historyMutations: [{ type: "upsert-assistant", message: assistant }]
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
return applied(current, { runs: replaceRun(current.runs, next) }, {
|
|
658
|
+
runRecords: [AgentStoredRunSchema.parse({ schemaVersion: 1, run: next })]
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
// src/agent-runtime/store-reduce-terminal.ts
|
|
663
|
+
function reduceTerminal(current, run, input) {
|
|
664
|
+
if (input.reason === "absorbed") {
|
|
665
|
+
throw new TypeError("A run is absorbed by another run, never terminalized as absorbed");
|
|
666
|
+
}
|
|
667
|
+
if (run.revision !== input.expectedRevision || run.state !== "running" && run.state !== "interrupt_requested" || run.ownerId !== input.ownerId || input.fencingToken !== undefined && run.fencingToken !== input.fencingToken || input.assistant.runId !== run.id || input.assistant.id !== run.assistantMessageId || input.assistant.conversationId !== run.conversationId || input.assistant.role !== "assistant" || input.assistant.status !== assistantStatus(input.reason)) {
|
|
668
|
+
return conflict(run.revision);
|
|
669
|
+
}
|
|
670
|
+
if (input.absorb && runStateForTerminalReason(input.reason) !== "completed") {
|
|
671
|
+
throw new TypeError("Only a completing run may absorb a queued successor");
|
|
672
|
+
}
|
|
673
|
+
const named = new Set((input.absorb ?? []).map((entry) => entry.runId));
|
|
674
|
+
if (named.size !== (input.absorb ?? []).length || named.has(run.id)) {
|
|
675
|
+
throw new TypeError("An absorption names each successor once, and never the absorbing run");
|
|
676
|
+
}
|
|
677
|
+
const absorbable = (input.absorb ?? []).filter((entry) => {
|
|
678
|
+
const candidate = current.runs.find((item) => item.id === entry.runId);
|
|
679
|
+
return candidate !== undefined && candidate.id !== run.id && candidate.state === "queued" && candidate.conversationId === run.conversationId && candidate.inputMessageIds.length === entry.inputMessageIds.length && candidate.inputMessageIds.every((id, index) => id === entry.inputMessageIds[index]);
|
|
680
|
+
});
|
|
681
|
+
const absorbedIds = new Set(absorbable.flatMap((entry) => entry.inputMessageIds));
|
|
682
|
+
const next = AgentRunSchema.parse({
|
|
683
|
+
...run,
|
|
684
|
+
state: runStateForTerminalReason(input.reason),
|
|
685
|
+
terminalReason: input.reason,
|
|
686
|
+
...input.policyName && { terminalPolicyName: input.policyName },
|
|
687
|
+
...input.usage && { usage: input.usage },
|
|
688
|
+
...absorbedIds.size > 0 && {
|
|
689
|
+
inputMessageIds: [
|
|
690
|
+
...run.inputMessageIds,
|
|
691
|
+
...[...absorbedIds].filter((id) => !run.inputMessageIds.includes(id))
|
|
692
|
+
]
|
|
693
|
+
},
|
|
694
|
+
revision: run.revision + 1,
|
|
695
|
+
updatedAt: new Date().toISOString()
|
|
696
|
+
});
|
|
697
|
+
const absorbedRuns = absorbable.map((entry) => {
|
|
698
|
+
const candidate = current.runs.find((item) => item.id === entry.runId);
|
|
699
|
+
if (!candidate)
|
|
700
|
+
throw new TypeError("Absorbed run disappeared inside the reducer");
|
|
701
|
+
return AgentRunSchema.parse({
|
|
702
|
+
...candidate,
|
|
703
|
+
state: runStateForTerminalReason("absorbed"),
|
|
704
|
+
terminalReason: "absorbed",
|
|
705
|
+
absorbedIntoRunId: next.id,
|
|
706
|
+
revision: candidate.revision + 1,
|
|
707
|
+
updatedAt: new Date().toISOString()
|
|
708
|
+
});
|
|
709
|
+
});
|
|
710
|
+
const runs = absorbedRuns.reduce((accumulated, absorbed) => replaceRun(accumulated, absorbed), replaceRun(current.runs, next));
|
|
711
|
+
return applied(current, {
|
|
712
|
+
runs,
|
|
713
|
+
messages: replaceMessage(current.messages, input.assistant)
|
|
714
|
+
}, {
|
|
715
|
+
runRecords: [
|
|
716
|
+
AgentStoredRunSchema.parse({
|
|
717
|
+
schemaVersion: 1,
|
|
718
|
+
run: next,
|
|
719
|
+
terminalAssistant: input.assistant
|
|
720
|
+
}),
|
|
721
|
+
...absorbedRuns.map((absorbed) => AgentStoredRunSchema.parse({ schemaVersion: 1, run: absorbed }))
|
|
722
|
+
],
|
|
723
|
+
historyMutations: [{ type: "upsert-assistant", message: input.assistant }]
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
// src/agent-runtime/store-reducer.ts
|
|
728
|
+
function transitionRecord(operation) {
|
|
729
|
+
if (operation.type !== "checkpoint")
|
|
730
|
+
return operation;
|
|
731
|
+
const { assistant, ...rest } = operation.input;
|
|
732
|
+
const body = canonicalAgentJson(assistant);
|
|
733
|
+
return {
|
|
734
|
+
type: operation.type,
|
|
735
|
+
input: {
|
|
736
|
+
...rest,
|
|
737
|
+
assistant: {
|
|
738
|
+
id: assistant.id,
|
|
739
|
+
status: assistant.status,
|
|
740
|
+
sha256: createHash("sha256").update(body).digest("hex"),
|
|
741
|
+
parts: assistant.parts.length,
|
|
742
|
+
bytes: Buffer.byteLength(body)
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
function reduceStore(current, operation) {
|
|
748
|
+
if (operation.type === "accept")
|
|
749
|
+
return reduceAccept(current, operation.input);
|
|
750
|
+
if (operation.type === "seed")
|
|
751
|
+
return reduceSeed(current, operation.input);
|
|
752
|
+
if (operation.type === "compact")
|
|
753
|
+
return reduceCompact(current, operation.input);
|
|
754
|
+
const run = current.runs.find((candidate) => candidate.id === operation.input.runId);
|
|
755
|
+
if (!run)
|
|
756
|
+
return { outcome: "not_found" };
|
|
757
|
+
switch (operation.type) {
|
|
758
|
+
case "acquire":
|
|
759
|
+
return reduceAcquire(current, run, operation.input);
|
|
760
|
+
case "checkpoint":
|
|
761
|
+
return reduceCheckpoint(current, run, operation.input);
|
|
762
|
+
case "operation":
|
|
763
|
+
return reduceOperation(current, run, operation.input);
|
|
764
|
+
case "interrupt":
|
|
765
|
+
return reduceInterrupt(current, run, operation.input);
|
|
766
|
+
case "recover":
|
|
767
|
+
return reduceRecover(current, run, operation.input);
|
|
768
|
+
case "terminal":
|
|
769
|
+
return reduceTerminal(current, run, operation.input);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
function operationConversationId(operation) {
|
|
773
|
+
return operation.type === "accept" ? operation.input.input.conversationId : operation.input.conversationId;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
// src/agent-runtime/store-mutate.ts
|
|
777
|
+
function validateAdmissionReceipt(receipt, record, conversationId) {
|
|
778
|
+
const input = receipt.input;
|
|
779
|
+
const run = record.run;
|
|
780
|
+
if (receipt.conversationId !== conversationId || input.conversationId !== conversationId || input.role !== "user" || input.status !== "committed" || input.runId !== undefined || receipt.runId !== run.id || receipt.assistantMessageId !== run.assistantMessageId || !run.inputMessageIds.includes(input.id)) {
|
|
781
|
+
throw new TypeError("Admission receipt does not match its canonical run assignment");
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
async function readForMutation(driver, transaction, operation) {
|
|
785
|
+
const conversationId = operationConversationId(operation);
|
|
786
|
+
if (await driver.conversations?.isPurged(transaction, conversationId)) {
|
|
787
|
+
throw new AgentConversationPurgedError;
|
|
788
|
+
}
|
|
789
|
+
const operationRunId = operation.type === "accept" ? operation.input.coalesceIntoRunId : operation.type === "compact" || operation.type === "seed" ? undefined : operation.input.runId;
|
|
790
|
+
const [stored, messages, activeRecords, operationRecord, duplicateReceipt] = await Promise.all([
|
|
791
|
+
driver.head.load(transaction, conversationId),
|
|
792
|
+
driver.history.load(transaction, conversationId),
|
|
793
|
+
driver.runs.listActive(transaction, conversationId),
|
|
794
|
+
operationRunId ? driver.runs.load(transaction, { conversationId, runId: operationRunId }) : undefined,
|
|
795
|
+
operation.type === "accept" ? driver.admissions.load(transaction, {
|
|
796
|
+
conversationId,
|
|
797
|
+
idempotencyKey: operation.input.idempotencyKey
|
|
798
|
+
}) : undefined
|
|
799
|
+
]);
|
|
800
|
+
const head = AgentRuntimeHeadSchema.parse(stored ?? emptyHead(conversationId));
|
|
801
|
+
const referencedRecords = await driver.runs.loadMany(transaction, {
|
|
802
|
+
conversationId,
|
|
803
|
+
runIds: referencedRunIds(messages)
|
|
804
|
+
});
|
|
805
|
+
const records = mergeRunRecords(activeRecords, referencedRecords, operationRecord ? [operationRecord] : []);
|
|
806
|
+
const current = snapshotOf(head, messages, records);
|
|
807
|
+
return { conversationId, head, messages, records, current, duplicateReceipt };
|
|
808
|
+
}
|
|
809
|
+
async function settledSeed(driver, transaction, read, input) {
|
|
810
|
+
const { conversationId, current } = read;
|
|
811
|
+
const existing = await driver.seeds.load(transaction, {
|
|
812
|
+
conversationId,
|
|
813
|
+
seedKey: input.seedKey
|
|
814
|
+
});
|
|
815
|
+
if (existing)
|
|
816
|
+
return { outcome: "applied", snapshot: current };
|
|
817
|
+
let collisions = 0;
|
|
818
|
+
for (const message of input.inputs) {
|
|
819
|
+
if (current.messages.some((candidate) => candidate.id === message.id) || driver.history.hasMessage && await driver.history.hasMessage(transaction, {
|
|
820
|
+
conversationId,
|
|
821
|
+
messageId: message.id
|
|
822
|
+
}))
|
|
823
|
+
collisions++;
|
|
824
|
+
}
|
|
825
|
+
if (collisions > 0 && collisions < input.inputs.length) {
|
|
826
|
+
throw new TypeError("Partial instruction seed collision: restore the complete seed before retrying");
|
|
827
|
+
}
|
|
828
|
+
if (collisions > 0) {
|
|
829
|
+
await driver.seeds.create(transaction, AgentSeedReceiptSchema.parse({
|
|
830
|
+
schemaVersion: 1,
|
|
831
|
+
conversationId,
|
|
832
|
+
seedKey: input.seedKey,
|
|
833
|
+
messageIds: input.inputs.map((message) => message.id)
|
|
834
|
+
}));
|
|
835
|
+
return { outcome: "applied", snapshot: current };
|
|
836
|
+
}
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
async function duplicateAdmission(driver, transaction, read, duplicateReceipt) {
|
|
840
|
+
const { conversationId, head, messages, records } = read;
|
|
841
|
+
const duplicateRecord = await driver.runs.load(transaction, {
|
|
842
|
+
conversationId,
|
|
843
|
+
runId: duplicateReceipt.runId
|
|
844
|
+
});
|
|
845
|
+
if (!duplicateRecord) {
|
|
846
|
+
throw new TypeError("Admission receipt points to a missing canonical run");
|
|
847
|
+
}
|
|
848
|
+
validateAdmissionReceipt(duplicateReceipt, duplicateRecord, conversationId);
|
|
849
|
+
const answering = duplicateRecord.run.absorbedIntoRunId ? await driver.runs.load(transaction, {
|
|
850
|
+
conversationId,
|
|
851
|
+
runId: duplicateRecord.run.absorbedIntoRunId
|
|
852
|
+
}) : undefined;
|
|
853
|
+
if (duplicateRecord.run.absorbedIntoRunId && !answering) {
|
|
854
|
+
throw new TypeError("Absorbed run points to a missing absorbing run");
|
|
855
|
+
}
|
|
856
|
+
const canonical = answering ?? duplicateRecord;
|
|
857
|
+
return {
|
|
858
|
+
outcome: "duplicate",
|
|
859
|
+
input: duplicateReceipt.input,
|
|
860
|
+
inputMessageId: duplicateReceipt.input.id,
|
|
861
|
+
runId: canonical.run.id,
|
|
862
|
+
assistantMessageId: canonical.run.assistantMessageId,
|
|
863
|
+
run: canonical.run,
|
|
864
|
+
...canonical.terminalAssistant && {
|
|
865
|
+
assistant: canonical.terminalAssistant
|
|
866
|
+
},
|
|
867
|
+
snapshot: snapshotOf(head, messages, mergeRunRecords(records, [duplicateRecord], answering ? [answering] : []))
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
async function assertAdmissionIdentitiesFree(driver, transaction, conversationId, input) {
|
|
871
|
+
const inputCollision = await driver.admissions.loadByInputMessageId(transaction, {
|
|
872
|
+
conversationId,
|
|
873
|
+
inputMessageId: input.input.id
|
|
874
|
+
});
|
|
875
|
+
if (inputCollision) {
|
|
876
|
+
throw new TypeError("Input message identity is already assigned to an admission");
|
|
877
|
+
}
|
|
878
|
+
if (!input.coalesceIntoRunId) {
|
|
879
|
+
const [runCollision, assistantCollision] = await Promise.all([
|
|
880
|
+
driver.runs.load(transaction, {
|
|
881
|
+
conversationId,
|
|
882
|
+
runId: input.run.id
|
|
883
|
+
}),
|
|
884
|
+
driver.runs.loadByAssistantMessageId(transaction, {
|
|
885
|
+
conversationId,
|
|
886
|
+
assistantMessageId: input.run.assistantMessageId
|
|
887
|
+
})
|
|
888
|
+
]);
|
|
889
|
+
if (runCollision || assistantCollision) {
|
|
890
|
+
throw new TypeError("Queued run identities are already reserved");
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
async function persistApplied(driver, transaction, read, operation, reduced) {
|
|
895
|
+
const { conversationId, current } = read;
|
|
896
|
+
const nextHead = AgentRuntimeHeadSchema.parse({
|
|
897
|
+
schemaVersion: 1,
|
|
898
|
+
conversationId,
|
|
899
|
+
version: reduced.snapshot.version
|
|
900
|
+
});
|
|
901
|
+
const outcome = await driver.head.compareAndSwap(transaction, {
|
|
902
|
+
conversationId,
|
|
903
|
+
expectedVersion: current.version,
|
|
904
|
+
next: nextHead
|
|
905
|
+
});
|
|
906
|
+
if (outcome.outcome === "conflict")
|
|
907
|
+
return conflict(outcome.actualVersion);
|
|
908
|
+
for (const record of reduced.runRecords ?? []) {
|
|
909
|
+
await driver.runs.save(transaction, record);
|
|
910
|
+
}
|
|
911
|
+
if (reduced.admissionReceipt) {
|
|
912
|
+
await driver.admissions.create(transaction, reduced.admissionReceipt);
|
|
913
|
+
}
|
|
914
|
+
if (reduced.seedReceipt) {
|
|
915
|
+
await driver.seeds.create(transaction, reduced.seedReceipt);
|
|
916
|
+
}
|
|
917
|
+
for (const mutation of reduced.historyMutations ?? []) {
|
|
918
|
+
await driver.history.apply(transaction, mutation);
|
|
919
|
+
}
|
|
920
|
+
await driver.events.append(transaction, agentStoreEventDraft({
|
|
921
|
+
conversationId,
|
|
922
|
+
kind: "runtime/transition",
|
|
923
|
+
payload: z4.json().parse(transitionRecord(operation))
|
|
924
|
+
}));
|
|
925
|
+
return { outcome: "applied", snapshot: reduced.snapshot };
|
|
926
|
+
}
|
|
927
|
+
function mutateStore(driver, operation) {
|
|
928
|
+
return driver.transaction(async (transaction) => {
|
|
929
|
+
const read = await readForMutation(driver, transaction, operation);
|
|
930
|
+
if (operation.type === "seed") {
|
|
931
|
+
const settled = await settledSeed(driver, transaction, read, operation.input);
|
|
932
|
+
if (settled)
|
|
933
|
+
return settled;
|
|
934
|
+
}
|
|
935
|
+
if (read.duplicateReceipt) {
|
|
936
|
+
return duplicateAdmission(driver, transaction, read, read.duplicateReceipt);
|
|
937
|
+
}
|
|
938
|
+
if (operation.type === "accept") {
|
|
939
|
+
await assertAdmissionIdentitiesFree(driver, transaction, read.conversationId, operation.input);
|
|
940
|
+
}
|
|
941
|
+
const reduced = reduceStore(read.current, operation);
|
|
942
|
+
if (reduced.outcome !== "applied")
|
|
943
|
+
return reduced;
|
|
944
|
+
return persistApplied(driver, transaction, read, operation, reduced);
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
// src/agent-runtime/store-purge.ts
|
|
949
|
+
function createStoreConversationPurge(driver, conversations) {
|
|
950
|
+
return async (input) => {
|
|
951
|
+
const { conversationId, expectedVersion } = AgentConversationPurgeInputSchema.parse(input);
|
|
952
|
+
return driver.transaction(async (transaction) => {
|
|
953
|
+
if (await conversations.isPurged(transaction, conversationId)) {
|
|
954
|
+
return { outcome: "already_purged" };
|
|
955
|
+
}
|
|
956
|
+
const head = await driver.head.load(transaction, conversationId);
|
|
957
|
+
const actualVersion = head?.version ?? 0;
|
|
958
|
+
if (expectedVersion !== undefined && expectedVersion !== actualVersion) {
|
|
959
|
+
return { outcome: "conflict", actualVersion };
|
|
960
|
+
}
|
|
961
|
+
const active = await driver.runs.listActive(transaction, conversationId);
|
|
962
|
+
if (active.length > 0) {
|
|
963
|
+
return { outcome: "active", runIds: active.map((record) => record.run.id) };
|
|
964
|
+
}
|
|
965
|
+
await conversations.remove(transaction, conversationId);
|
|
966
|
+
return { outcome: "purged" };
|
|
967
|
+
});
|
|
968
|
+
};
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
// src/agent-runtime/store-create.ts
|
|
972
|
+
var AgentRecoverableScanInputSchema = z5.object({
|
|
973
|
+
cursor: z5.string().min(1).optional(),
|
|
974
|
+
limit: z5.number().int().min(1).max(1000)
|
|
975
|
+
});
|
|
976
|
+
function createAgentRuntimeStore(driver) {
|
|
977
|
+
const mutate = (operation) => mutateStore(driver, operation);
|
|
978
|
+
return {
|
|
979
|
+
loadSnapshot: (conversationId) => loadSnapshot(driver, conversationId),
|
|
980
|
+
loadRun: (input) => loadRun(driver, input),
|
|
981
|
+
listActiveRuns: (conversationId) => listActiveRuns(driver, conversationId),
|
|
982
|
+
appendEvent: (input) => appendEvent(driver, input),
|
|
983
|
+
readEvents: (input) => readEvents(driver, input),
|
|
984
|
+
exportConversation: (conversationId) => exportConversation(driver, conversationId),
|
|
985
|
+
importConversation: (bytes) => importConversation(driver, bytes),
|
|
986
|
+
...driver.conversations && {
|
|
987
|
+
purgeConversation: createStoreConversationPurge(driver, driver.conversations)
|
|
988
|
+
},
|
|
989
|
+
acceptInputAndAssignRun: (input) => mutate({
|
|
990
|
+
type: "accept",
|
|
991
|
+
input: AcceptInputAndAssignRunSchema.parse(input)
|
|
992
|
+
}),
|
|
993
|
+
acquireRun: (input) => mutate({ type: "acquire", input: AcquireAgentRunSchema.parse(input) }),
|
|
994
|
+
checkpointRunAssistant: (input) => mutate({
|
|
995
|
+
type: "checkpoint",
|
|
996
|
+
input: CheckpointRunAssistantSchema.parse(input)
|
|
997
|
+
}),
|
|
998
|
+
recordRunOperation: (input) => mutate({
|
|
999
|
+
type: "operation",
|
|
1000
|
+
input: RecordRunOperationSchema.parse(input)
|
|
1001
|
+
}),
|
|
1002
|
+
requestRunInterrupt: (input) => mutate({
|
|
1003
|
+
type: "interrupt",
|
|
1004
|
+
input: RequestRunInterruptSchema.parse(input)
|
|
1005
|
+
}),
|
|
1006
|
+
recoverRun: (input) => mutate({ type: "recover", input: RecoverAgentRunSchema.parse(input) }),
|
|
1007
|
+
commitRunTerminal: (input) => mutate({ type: "terminal", input: CommitRunTerminalSchema.parse(input) }),
|
|
1008
|
+
replaceCompactedRange: (input) => mutate({
|
|
1009
|
+
type: "compact",
|
|
1010
|
+
input: ReplaceCompactedRangeSchema.parse(input)
|
|
1011
|
+
}),
|
|
1012
|
+
seedConversationInput: (input) => mutate({
|
|
1013
|
+
type: "seed",
|
|
1014
|
+
input: SeedConversationInputSchema.parse(input)
|
|
1015
|
+
}),
|
|
1016
|
+
async scanRecoverable(input) {
|
|
1017
|
+
const parsed = AgentRecoverableScanInputSchema.parse(input);
|
|
1018
|
+
return AgentRecoverablePageSchema.parse(await driver.scanRecoverable(parsed));
|
|
1019
|
+
}
|
|
1020
|
+
};
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
export { AgentConversationPurgeInputSchema, AgentConversationPurgeResultSchema, AgentConversationPurgedError, purgeAgentConversation, AgentRuntimeHeadSchema, AgentStoredRunSchema, AgentAdmissionReceiptSchema, AgentSeedReceiptSchema, AgentHistoryMutationSchema, ACTIVE_AGENT_RUN_STATES, isActiveRunState, replaceMessage, appendEventIn, createAgentRuntimeStore };
|