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.
Files changed (791) hide show
  1. package/CHANGELOG.md +134 -0
  2. package/README.md +5 -2
  3. package/dist/agent-runtime/children-control.d.ts +6 -0
  4. package/dist/agent-runtime/children-control.d.ts.map +1 -0
  5. package/dist/agent-runtime/children-spawn.d.ts +6 -0
  6. package/dist/agent-runtime/children-spawn.d.ts.map +1 -0
  7. package/dist/agent-runtime/children-state.d.ts +46 -0
  8. package/dist/agent-runtime/children-state.d.ts.map +1 -0
  9. package/dist/agent-runtime/children-usage.d.ts +8 -0
  10. package/dist/agent-runtime/children-usage.d.ts.map +1 -0
  11. package/dist/agent-runtime/children.d.ts +11 -14
  12. package/dist/agent-runtime/children.d.ts.map +1 -1
  13. package/dist/agent-runtime/coding-tool-contract.d.ts +2 -1
  14. package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -1
  15. package/dist/agent-runtime/deferred-tool-types.d.ts +2 -2
  16. package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
  17. package/dist/agent-runtime/events.d.ts +1 -1
  18. package/dist/agent-runtime/events.d.ts.map +1 -1
  19. package/dist/agent-runtime/managed-tools.d.ts +1 -1
  20. package/dist/agent-runtime/managed-tools.d.ts.map +1 -1
  21. package/dist/agent-runtime/observability.d.ts +1 -1
  22. package/dist/agent-runtime/observability.d.ts.map +1 -1
  23. package/dist/{agent-runtime-openrouter.d.ts → agent-runtime/openrouter.d.ts} +3 -3
  24. package/dist/agent-runtime/openrouter.d.ts.map +1 -0
  25. package/dist/agent-runtime/projections.d.ts +1 -1
  26. package/dist/agent-runtime/projections.d.ts.map +1 -1
  27. package/dist/agent-runtime/run-acquisition.d.ts +17 -0
  28. package/dist/agent-runtime/run-acquisition.d.ts.map +1 -0
  29. package/dist/agent-runtime/run-execution-state.d.ts +133 -0
  30. package/dist/agent-runtime/run-execution-state.d.ts.map +1 -0
  31. package/dist/agent-runtime/run-execution.d.ts +17 -33
  32. package/dist/agent-runtime/run-execution.d.ts.map +1 -1
  33. package/dist/agent-runtime/run-failure.d.ts +18 -0
  34. package/dist/agent-runtime/run-failure.d.ts.map +1 -0
  35. package/dist/agent-runtime/run-model-attempts.d.ts +6 -0
  36. package/dist/agent-runtime/run-model-attempts.d.ts.map +1 -0
  37. package/dist/agent-runtime/run-prompt-history.d.ts +58 -0
  38. package/dist/agent-runtime/run-prompt-history.d.ts.map +1 -0
  39. package/dist/agent-runtime/run-provider-ledger.d.ts +26 -0
  40. package/dist/agent-runtime/run-provider-ledger.d.ts.map +1 -0
  41. package/dist/agent-runtime/run-stream-parts.d.ts +17 -0
  42. package/dist/agent-runtime/run-stream-parts.d.ts.map +1 -0
  43. package/dist/agent-runtime/run-terminal.d.ts +11 -0
  44. package/dist/agent-runtime/run-terminal.d.ts.map +1 -0
  45. package/dist/agent-runtime/run-turn-preparation.d.ts +22 -0
  46. package/dist/agent-runtime/run-turn-preparation.d.ts.map +1 -0
  47. package/dist/agent-runtime/runtime-admission-gate.d.ts +29 -0
  48. package/dist/agent-runtime/runtime-admission-gate.d.ts.map +1 -0
  49. package/dist/agent-runtime/runtime-control.d.ts +9 -0
  50. package/dist/agent-runtime/runtime-control.d.ts.map +1 -0
  51. package/dist/agent-runtime/runtime-recovery.d.ts +10 -0
  52. package/dist/agent-runtime/runtime-recovery.d.ts.map +1 -0
  53. package/dist/agent-runtime/runtime-state.d.ts +36 -0
  54. package/dist/agent-runtime/runtime-state.d.ts.map +1 -0
  55. package/dist/agent-runtime/runtime-submit.d.ts +5 -0
  56. package/dist/agent-runtime/runtime-submit.d.ts.map +1 -0
  57. package/dist/agent-runtime/runtime.d.ts +9 -4
  58. package/dist/agent-runtime/runtime.d.ts.map +1 -1
  59. package/dist/{agent-runtime-sqlite-bun.d.ts → agent-runtime/sqlite-bun.d.ts} +5 -4
  60. package/dist/agent-runtime/sqlite-bun.d.ts.map +1 -0
  61. package/dist/agent-runtime/sqlite-events.d.ts +5 -0
  62. package/dist/agent-runtime/sqlite-events.d.ts.map +1 -0
  63. package/dist/agent-runtime/sqlite-history.d.ts +7 -0
  64. package/dist/agent-runtime/sqlite-history.d.ts.map +1 -0
  65. package/dist/agent-runtime/sqlite-ledger.d.ts +7 -0
  66. package/dist/agent-runtime/sqlite-ledger.d.ts.map +1 -0
  67. package/dist/{agent-runtime-sqlite-node.d.ts → agent-runtime/sqlite-node.d.ts} +5 -4
  68. package/dist/agent-runtime/sqlite-node.d.ts.map +1 -0
  69. package/dist/agent-runtime/sqlite-reads.d.ts +14 -0
  70. package/dist/agent-runtime/sqlite-reads.d.ts.map +1 -0
  71. package/dist/agent-runtime/sqlite-rows.d.ts +178 -0
  72. package/dist/agent-runtime/sqlite-rows.d.ts.map +1 -0
  73. package/dist/agent-runtime/sqlite-schema.d.ts +7 -0
  74. package/dist/agent-runtime/sqlite-schema.d.ts.map +1 -0
  75. package/dist/agent-runtime/sqlite-transactions.d.ts +25 -0
  76. package/dist/agent-runtime/sqlite-transactions.d.ts.map +1 -0
  77. package/dist/agent-runtime/sqlite.d.ts +10 -6
  78. package/dist/agent-runtime/sqlite.d.ts.map +1 -1
  79. package/dist/agent-runtime/store-archive.d.ts +16 -0
  80. package/dist/agent-runtime/store-archive.d.ts.map +1 -0
  81. package/dist/{testing/agent-store-conformance.d.ts → agent-runtime/store-conformance.d.ts} +2 -2
  82. package/dist/agent-runtime/store-conformance.d.ts.map +1 -0
  83. package/dist/agent-runtime/store-create.d.ts +11 -0
  84. package/dist/agent-runtime/store-create.d.ts.map +1 -0
  85. package/dist/agent-runtime/{store-driver.d.ts → store-driver-contract.d.ts} +7 -7
  86. package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -0
  87. package/dist/agent-runtime/store-events.d.ts +7 -89
  88. package/dist/agent-runtime/store-events.d.ts.map +1 -1
  89. package/dist/agent-runtime/store-memory.d.ts +4 -0
  90. package/dist/agent-runtime/store-memory.d.ts.map +1 -0
  91. package/dist/agent-runtime/store-mutate.d.ts +13 -0
  92. package/dist/agent-runtime/store-mutate.d.ts.map +1 -0
  93. package/dist/agent-runtime/store-purge.d.ts +1 -1
  94. package/dist/agent-runtime/store-purge.d.ts.map +1 -1
  95. package/dist/agent-runtime/store-reads.d.ts +29 -0
  96. package/dist/agent-runtime/store-reads.d.ts.map +1 -0
  97. package/dist/agent-runtime/store-reduce-history.d.ts +10 -0
  98. package/dist/agent-runtime/store-reduce-history.d.ts.map +1 -0
  99. package/dist/agent-runtime/store-reduce-run.d.ts +14 -0
  100. package/dist/agent-runtime/store-reduce-run.d.ts.map +1 -0
  101. package/dist/agent-runtime/store-reduce-shared.d.ts +76 -0
  102. package/dist/agent-runtime/store-reduce-shared.d.ts.map +1 -0
  103. package/dist/agent-runtime/store-reduce-terminal.d.ts +6 -0
  104. package/dist/agent-runtime/store-reduce-terminal.d.ts.map +1 -0
  105. package/dist/agent-runtime/store-reducer.d.ts +24 -0
  106. package/dist/agent-runtime/store-reducer.d.ts.map +1 -0
  107. package/dist/agent-runtime/store-snapshot.d.ts +19 -0
  108. package/dist/agent-runtime/store-snapshot.d.ts.map +1 -0
  109. package/dist/agent-runtime/store.d.ts +1 -1
  110. package/dist/agent-runtime/store.d.ts.map +1 -1
  111. package/dist/application/admission.d.ts +1 -1
  112. package/dist/application/admission.d.ts.map +1 -1
  113. package/dist/application/events.d.ts +1 -1
  114. package/dist/application/events.d.ts.map +1 -1
  115. package/dist/{server → application}/file-state-store.d.ts +1 -1
  116. package/dist/application/file-state-store.d.ts.map +1 -0
  117. package/dist/application/health.d.ts +1 -1
  118. package/dist/application/health.d.ts.map +1 -1
  119. package/dist/application/kernel-admission.d.ts +8 -0
  120. package/dist/application/kernel-admission.d.ts.map +1 -0
  121. package/dist/application/kernel-contract.d.ts +142 -0
  122. package/dist/application/kernel-contract.d.ts.map +1 -0
  123. package/dist/application/kernel-resource-context.d.ts +24 -0
  124. package/dist/application/kernel-resource-context.d.ts.map +1 -0
  125. package/dist/application/kernel-restart.d.ts +5 -0
  126. package/dist/application/kernel-restart.d.ts.map +1 -0
  127. package/dist/application/kernel-rollback.d.ts +4 -0
  128. package/dist/application/kernel-rollback.d.ts.map +1 -0
  129. package/dist/application/kernel-shutdown.d.ts +6 -0
  130. package/dist/application/kernel-shutdown.d.ts.map +1 -0
  131. package/dist/application/kernel-start.d.ts +20 -0
  132. package/dist/application/kernel-start.d.ts.map +1 -0
  133. package/dist/application/kernel-state.d.ts +116 -0
  134. package/dist/application/kernel-state.d.ts.map +1 -0
  135. package/dist/application/kernel.d.ts +9 -140
  136. package/dist/application/kernel.d.ts.map +1 -1
  137. package/dist/application/latest-sink.d.ts +1 -1
  138. package/dist/application/latest-sink.d.ts.map +1 -1
  139. package/dist/application/opentelemetry.d.ts +1 -1
  140. package/dist/application/opentelemetry.d.ts.map +1 -1
  141. package/dist/application/watch-hub.d.ts +2 -2
  142. package/dist/application/watch-hub.d.ts.map +1 -1
  143. package/dist/browser/client-multipart.d.ts +1 -1
  144. package/dist/browser/client-multipart.d.ts.map +1 -1
  145. package/dist/browser/client-url.d.ts +1 -1
  146. package/dist/browser/client-url.d.ts.map +1 -1
  147. package/dist/browser/client.d.ts +1 -1
  148. package/dist/browser/client.d.ts.map +1 -1
  149. package/dist/browser/contract-stream.d.ts +1 -1
  150. package/dist/browser/contract-stream.d.ts.map +1 -1
  151. package/dist/browser/http.d.ts +1 -1
  152. package/dist/browser/http.d.ts.map +1 -1
  153. package/dist/browser/resumable.d.ts +1 -28
  154. package/dist/browser/resumable.d.ts.map +1 -1
  155. package/dist/browser/retained.d.ts.map +1 -0
  156. package/dist/browser/socket-io.d.ts +23 -1
  157. package/dist/browser/socket-io.d.ts.map +1 -1
  158. package/dist/browser/stream.d.ts +14 -2
  159. package/dist/browser/stream.d.ts.map +1 -1
  160. package/dist/contract/define.d.ts +72 -65
  161. package/dist/contract/define.d.ts.map +1 -1
  162. package/dist/{internal/errors.d.ts → contract/normalize.d.ts} +3 -39
  163. package/dist/contract/normalize.d.ts.map +1 -0
  164. package/dist/contract/tool-view.d.ts +135 -0
  165. package/dist/contract/tool-view.d.ts.map +1 -0
  166. package/dist/declaration/declaration.d.ts.map +1 -0
  167. package/dist/{agent-runtime/durability-contract.d.ts → durability/contract.d.ts} +2 -2
  168. package/dist/durability/contract.d.ts.map +1 -0
  169. package/dist/{agent-runtime/durability.d.ts → durability/engine.d.ts} +4 -4
  170. package/dist/durability/engine.d.ts.map +1 -0
  171. package/dist/durability/events.d.ts +101 -0
  172. package/dist/durability/events.d.ts.map +1 -0
  173. package/dist/{agent-runtime/durability-json.d.ts → durability/json.d.ts} +1 -1
  174. package/dist/durability/json.d.ts.map +1 -0
  175. package/dist/{agent-runtime/durability-ledger.d.ts → durability/ledger.d.ts} +2 -2
  176. package/dist/durability/ledger.d.ts.map +1 -0
  177. package/dist/{agent-runtime/durability-scheduler.d.ts → durability/scheduler.d.ts} +2 -2
  178. package/dist/durability/scheduler.d.ts.map +1 -0
  179. package/dist/entrypoints/agent-runtime/browser.d.ts +5 -0
  180. package/dist/entrypoints/agent-runtime/browser.d.ts.map +1 -0
  181. package/dist/{agent-runtime-browser.js → entrypoints/agent-runtime/browser.js} +3 -3
  182. package/dist/{agent-runtime-coding-tools.d.ts → entrypoints/agent-runtime/coding-tools.d.ts} +2 -2
  183. package/dist/entrypoints/agent-runtime/coding-tools.d.ts.map +1 -0
  184. package/dist/entrypoints/agent-runtime/coding-tools.js +22 -0
  185. package/dist/{agent-runtime-harness.d.ts → entrypoints/agent-runtime/harness.d.ts} +2 -2
  186. package/dist/entrypoints/agent-runtime/harness.d.ts.map +1 -0
  187. package/dist/{agent-runtime-harness.js → entrypoints/agent-runtime/harness.js} +24 -25
  188. package/dist/entrypoints/agent-runtime/openrouter.d.ts +2 -0
  189. package/dist/entrypoints/agent-runtime/openrouter.d.ts.map +1 -0
  190. package/dist/{agent-runtime-openrouter.js → entrypoints/agent-runtime/openrouter.js} +3 -3
  191. package/dist/{agent-runtime-sandbox.d.ts → entrypoints/agent-runtime/sandbox.d.ts} +5 -5
  192. package/dist/entrypoints/agent-runtime/sandbox.d.ts.map +1 -0
  193. package/dist/{agent-runtime-sandbox.js → entrypoints/agent-runtime/sandbox.js} +11 -12
  194. package/dist/entrypoints/agent-runtime/sqlite/bun.d.ts +2 -0
  195. package/dist/entrypoints/agent-runtime/sqlite/bun.d.ts.map +1 -0
  196. package/dist/{agent-runtime-sqlite-bun.js → entrypoints/agent-runtime/sqlite/bun.js} +8 -6
  197. package/dist/entrypoints/agent-runtime/sqlite/node.d.ts +2 -0
  198. package/dist/entrypoints/agent-runtime/sqlite/node.d.ts.map +1 -0
  199. package/dist/{agent-runtime-sqlite-node.js → entrypoints/agent-runtime/sqlite/node.js} +8 -6
  200. package/dist/entrypoints/agent-runtime/testing.d.ts +4 -0
  201. package/dist/entrypoints/agent-runtime/testing.d.ts.map +1 -0
  202. package/dist/entrypoints/agent-runtime/testing.js +1084 -0
  203. package/dist/{agent-runtime.d.ts → entrypoints/agent-runtime.d.ts} +41 -37
  204. package/dist/entrypoints/agent-runtime.d.ts.map +1 -0
  205. package/dist/{agent-runtime.js → entrypoints/agent-runtime.js} +408 -366
  206. package/dist/{application-diagnostic-journal.d.ts → entrypoints/application/diagnostic-journal.d.ts} +2 -2
  207. package/dist/entrypoints/application/diagnostic-journal.d.ts.map +1 -0
  208. package/dist/{application-diagnostic-journal.js → entrypoints/application/diagnostic-journal.js} +3 -3
  209. package/dist/{application-grammy.d.ts → entrypoints/application/grammy.d.ts} +2 -2
  210. package/dist/entrypoints/application/grammy.d.ts.map +1 -0
  211. package/dist/{application-grammy.js → entrypoints/application/grammy.js} +2 -2
  212. package/dist/{application-opentelemetry.d.ts → entrypoints/application/opentelemetry.d.ts} +2 -2
  213. package/dist/entrypoints/application/opentelemetry.d.ts.map +1 -0
  214. package/dist/{application-opentelemetry.js → entrypoints/application/opentelemetry.js} +4 -4
  215. package/dist/{application-schemas.d.ts → entrypoints/application/schemas.d.ts} +2 -2
  216. package/dist/entrypoints/application/schemas.d.ts.map +1 -0
  217. package/dist/{application-schemas.js → entrypoints/application/schemas.js} +2 -2
  218. package/dist/{application.d.ts → entrypoints/application.d.ts} +22 -21
  219. package/dist/entrypoints/application.d.ts.map +1 -0
  220. package/dist/{application.js → entrypoints/application.js} +24 -22
  221. package/dist/entrypoints/bin/upgrade-cli.d.ts.map +1 -0
  222. package/dist/{upgrade-cli.js → entrypoints/bin/upgrade-cli.js} +3 -3
  223. package/dist/{cli.d.ts → entrypoints/cli.d.ts} +15 -15
  224. package/dist/entrypoints/cli.d.ts.map +1 -0
  225. package/dist/{cli.js → entrypoints/cli.js} +30 -32
  226. package/dist/entrypoints/contract.d.ts +9 -0
  227. package/dist/entrypoints/contract.d.ts.map +1 -0
  228. package/dist/{contract/index.js → entrypoints/contract.js} +14 -6
  229. package/dist/entrypoints/declaration.d.ts +2 -0
  230. package/dist/entrypoints/declaration.d.ts.map +1 -0
  231. package/dist/{declaration.js → entrypoints/declaration.js} +1 -1
  232. package/dist/{files.d.ts → entrypoints/files.d.ts} +2 -2
  233. package/dist/entrypoints/files.d.ts.map +1 -0
  234. package/dist/{files.js → entrypoints/files.js} +3 -3
  235. package/dist/{geo.d.ts → entrypoints/geo.d.ts} +1 -1
  236. package/dist/entrypoints/geo.d.ts.map +1 -0
  237. package/dist/{geo.js → entrypoints/geo.js} +4 -4
  238. package/dist/entrypoints/google.d.ts +2 -0
  239. package/dist/entrypoints/google.d.ts.map +1 -0
  240. package/dist/{google.js → entrypoints/google.js} +1 -1
  241. package/dist/{index.d.ts → entrypoints/index.d.ts} +14 -13
  242. package/dist/entrypoints/index.d.ts.map +1 -0
  243. package/dist/{index.js → entrypoints/index.js} +99 -33
  244. package/dist/{live.d.ts → entrypoints/live.d.ts} +4 -4
  245. package/dist/entrypoints/live.d.ts.map +1 -0
  246. package/dist/{live.js → entrypoints/live.js} +6 -4
  247. package/dist/{node.d.ts → entrypoints/node.d.ts} +11 -11
  248. package/dist/entrypoints/node.d.ts.map +1 -0
  249. package/dist/{node.js → entrypoints/node.js} +20 -16
  250. package/dist/entrypoints/oauth.d.ts +2 -0
  251. package/dist/entrypoints/oauth.d.ts.map +1 -0
  252. package/dist/{oauth.js → entrypoints/oauth.js} +3 -3
  253. package/dist/{observability/index.d.ts → entrypoints/observability.d.ts} +11 -11
  254. package/dist/entrypoints/observability.d.ts.map +1 -0
  255. package/dist/{observability/index.js → entrypoints/observability.js} +9 -11
  256. package/dist/entrypoints/primitives.d.ts +3 -0
  257. package/dist/entrypoints/primitives.d.ts.map +1 -0
  258. package/dist/{primitives.js → entrypoints/primitives.js} +1 -6
  259. package/dist/{react.d.ts → entrypoints/react.d.ts} +4 -4
  260. package/dist/entrypoints/react.d.ts.map +1 -0
  261. package/dist/{react.js → entrypoints/react.js} +3 -3
  262. package/dist/{release.d.ts → entrypoints/release.d.ts} +4 -4
  263. package/dist/entrypoints/release.d.ts.map +1 -0
  264. package/dist/{release.js → entrypoints/release.js} +1 -1
  265. package/dist/{remote.d.ts → entrypoints/remote.d.ts} +1 -1
  266. package/dist/entrypoints/remote.d.ts.map +1 -0
  267. package/dist/entrypoints/remote.js +66 -0
  268. package/dist/{server/index.d.ts → entrypoints/server.d.ts} +35 -34
  269. package/dist/entrypoints/server.d.ts.map +1 -0
  270. package/dist/{server/index.js → entrypoints/server.js} +294 -244
  271. package/dist/{telegram.d.ts → entrypoints/telegram.d.ts} +2 -2
  272. package/dist/entrypoints/telegram.d.ts.map +1 -0
  273. package/dist/{telegram.js → entrypoints/telegram.js} +1 -1
  274. package/dist/entrypoints/testing.d.ts +9 -0
  275. package/dist/entrypoints/testing.d.ts.map +1 -0
  276. package/dist/{testing.js → entrypoints/testing.js} +80 -919
  277. package/dist/{tools/connections/index.d.ts → entrypoints/tools/connections.d.ts} +6 -7
  278. package/dist/entrypoints/tools/connections.d.ts.map +1 -0
  279. package/dist/{tools/connections/index.js → entrypoints/tools/connections.js} +7 -4
  280. package/dist/{tools-contract.d.ts → entrypoints/tools/contract.d.ts} +5 -5
  281. package/dist/entrypoints/tools/contract.d.ts.map +1 -0
  282. package/dist/{tools-contract.js → entrypoints/tools/contract.js} +4 -4
  283. package/dist/{tool-invoker.d.ts → entrypoints/tools/invoker.d.ts} +2 -2
  284. package/dist/entrypoints/tools/invoker.d.ts.map +1 -0
  285. package/dist/entrypoints/tools/invoker.js +20 -0
  286. package/dist/entrypoints/tools.d.ts +51 -0
  287. package/dist/entrypoints/tools.d.ts.map +1 -0
  288. package/dist/{tools.js → entrypoints/tools.js} +1787 -1751
  289. package/dist/{tracking-server.d.ts → entrypoints/tracking/server.d.ts} +8 -8
  290. package/dist/entrypoints/tracking/server.d.ts.map +1 -0
  291. package/dist/{tracking.d.ts → entrypoints/tracking.d.ts} +15 -15
  292. package/dist/entrypoints/tracking.d.ts.map +1 -0
  293. package/dist/{tracking.js → entrypoints/tracking.js} +5 -8
  294. package/dist/google/google.d.ts.map +1 -0
  295. package/dist/{index-a916km3r.js → index-0b1ess5e.js} +6 -13
  296. package/dist/{index-zwkgfq1s.js → index-1nd48tm9.js} +113 -118
  297. package/dist/{index-7zbps32p.js → index-1zbbzgfh.js} +2 -2
  298. package/dist/{index-mzvgxp0n.js → index-2cr1cqhn.js} +16 -4
  299. package/dist/{index-f9mb610r.js → index-35mh5bhj.js} +2 -2
  300. package/dist/index-48ffdxgk.js +6 -0
  301. package/dist/index-58k4fp34.js +1023 -0
  302. package/dist/{index-p13mwz16.js → index-83bdg97s.js} +1 -1
  303. package/dist/index-97ac4gph.js +3618 -0
  304. package/dist/{index-kw9t5ayn.js → index-cq4qfycf.js} +5 -5
  305. package/dist/{index-7gnkny4z.js → index-d9pk3td4.js} +1 -1
  306. package/dist/{index-e42wzzz5.js → index-dcpdvjsc.js} +7 -7
  307. package/dist/{index-h9etkkyk.js → index-dydjcp8z.js} +102 -25
  308. package/dist/{index-sr93cwf9.js → index-e2z3ahw9.js} +2 -2
  309. package/dist/{index-yewwh1w4.js → index-e87kakm4.js} +96 -11
  310. package/dist/{index-cby4ar3v.js → index-eqqvgdb3.js} +1 -1
  311. package/dist/index-fdp6hdxn.js +942 -0
  312. package/dist/{index-0a349c33.js → index-gyr48nzg.js} +125 -198
  313. package/dist/{index-wnfk50r0.js → index-h6eeys1v.js} +1 -1
  314. package/dist/{index-77fekveh.js → index-hffjpmq9.js} +1 -15
  315. package/dist/{index-yn8remb1.js → index-j05z5gn4.js} +50 -14
  316. package/dist/index-k5hsfc3j.js +31 -0
  317. package/dist/{index-fq77yfzc.js → index-kj2wbeta.js} +1 -1
  318. package/dist/index-kvj7f4hq.js +39 -0
  319. package/dist/{index-4fpa9dy2.js → index-m9zn6cpq.js} +2 -2
  320. package/dist/{index-2na0qrfn.js → index-mdzh02yc.js} +7 -7
  321. package/dist/{index-ywd0y6m1.js → index-mkm15s49.js} +1 -1
  322. package/dist/index-mp5sn43f.js +1084 -0
  323. package/dist/{index-3bmnp41g.js → index-n6hxg8as.js} +507 -419
  324. package/dist/index-ngfhvfpd.js +30 -0
  325. package/dist/{index-e0znv5gn.js → index-p5r7qpdd.js} +2 -93
  326. package/dist/{index-n0f51dfn.js → index-p81267c2.js} +608 -549
  327. package/dist/{index-wc4x00bn.js → index-qwhynv6x.js} +1 -1
  328. package/dist/index-r7nmqpsg.js +154 -0
  329. package/dist/{index-bx75zwt7.js → index-rewkc2hj.js} +5 -4
  330. package/dist/{index-9f8ztey6.js → index-sees8yf8.js} +2 -2
  331. package/dist/{index-vjpvjqpn.js → index-v38qyerb.js} +16 -2
  332. package/dist/{index-2c2bjw3s.js → index-vcvkq30w.js} +3 -3
  333. package/dist/index-wqgjfstn.js +18 -0
  334. package/dist/{index-f477k430.js → index-x4799c19.js} +1 -1
  335. package/dist/{index-cxqhvq21.js → index-xnj9bgxe.js} +142 -129
  336. package/dist/index-xsqjkha9.js +281 -0
  337. package/dist/{index-6kyksz9y.js → index-yw4fzmdz.js} +1 -1
  338. package/dist/{index-3xwxfj4z.js → index-zeemqhqx.js} +1 -1
  339. package/dist/{index-tmwcrptx.js → index-zfrhfn82.js} +1 -1
  340. package/dist/index-znfs20ss.js +98 -0
  341. package/dist/internal/backoff.d.ts +29 -0
  342. package/dist/internal/backoff.d.ts.map +1 -0
  343. package/dist/internal/canonical-json.d.ts +21 -11
  344. package/dist/internal/canonical-json.d.ts.map +1 -1
  345. package/dist/internal/channel.d.ts.map +1 -0
  346. package/dist/internal/logger.d.ts.map +1 -0
  347. package/dist/internal/request.d.ts.map +1 -0
  348. package/dist/internal/stable-digest.d.ts +0 -43
  349. package/dist/internal/stable-digest.d.ts.map +1 -1
  350. package/dist/internal/typed.d.ts +0 -8
  351. package/dist/internal/typed.d.ts.map +1 -1
  352. package/dist/internal/zod-issues.d.ts +38 -0
  353. package/dist/internal/zod-issues.d.ts.map +1 -0
  354. package/dist/{tools/json-schema-dialect.d.ts → json-schema/dialect.d.ts} +1 -1
  355. package/dist/json-schema/dialect.d.ts.map +1 -0
  356. package/dist/json-schema/json-schema.d.ts.map +1 -0
  357. package/dist/live/watch-delta.d.ts.map +1 -1
  358. package/dist/{oauth.d.ts → oauth/authorization-code.d.ts} +1 -1
  359. package/dist/oauth/authorization-code.d.ts.map +1 -0
  360. package/dist/observability/audit.d.ts +2 -2
  361. package/dist/observability/audit.d.ts.map +1 -1
  362. package/dist/observability/bounded-logger.d.ts +1 -1
  363. package/dist/observability/bounded-logger.d.ts.map +1 -1
  364. package/dist/{internal/observability-sink.d.ts → observability/bounded-sink.d.ts} +2 -2
  365. package/dist/observability/bounded-sink.d.ts.map +1 -0
  366. package/dist/observability/context.d.ts +1 -1
  367. package/dist/observability/context.d.ts.map +1 -1
  368. package/dist/observability/event.d.ts +1 -1
  369. package/dist/observability/event.d.ts.map +1 -1
  370. package/dist/observability/work.d.ts +1 -1
  371. package/dist/observability/work.d.ts.map +1 -1
  372. package/dist/primitives/audit.d.ts +1 -1
  373. package/dist/primitives/audit.d.ts.map +1 -1
  374. package/dist/primitives/export-operation.d.ts +4 -2
  375. package/dist/primitives/export-operation.d.ts.map +1 -1
  376. package/dist/realtime/socket.d.ts +1 -1
  377. package/dist/realtime/socket.d.ts.map +1 -1
  378. package/dist/server/context-contribution.d.ts +1 -1
  379. package/dist/server/context-contribution.d.ts.map +1 -1
  380. package/dist/server/context.d.ts +2 -2
  381. package/dist/server/context.d.ts.map +1 -1
  382. package/dist/server/contract-method.d.ts +15 -0
  383. package/dist/server/contract-method.d.ts.map +1 -0
  384. package/dist/server/contract-stream.d.ts +1 -1
  385. package/dist/server/contract-stream.d.ts.map +1 -1
  386. package/dist/server/create.d.ts +8 -0
  387. package/dist/server/create.d.ts.map +1 -1
  388. package/dist/server/endpoint-dispatch.d.ts +10 -0
  389. package/dist/server/endpoint-dispatch.d.ts.map +1 -0
  390. package/dist/server/endpoint-response.d.ts +18 -0
  391. package/dist/server/endpoint-response.d.ts.map +1 -0
  392. package/dist/server/error-dispatch.d.ts +17 -1
  393. package/dist/server/error-dispatch.d.ts.map +1 -1
  394. package/dist/server/error-hook.d.ts +2 -2
  395. package/dist/server/error-hook.d.ts.map +1 -1
  396. package/dist/server/handler-state.d.ts +44 -0
  397. package/dist/server/handler-state.d.ts.map +1 -0
  398. package/dist/server/implement.d.ts +1 -1
  399. package/dist/server/implement.d.ts.map +1 -1
  400. package/dist/server/middleware/auth.d.ts +1 -1
  401. package/dist/server/middleware/auth.d.ts.map +1 -1
  402. package/dist/server/middleware/cors.d.ts +17 -0
  403. package/dist/server/middleware/cors.d.ts.map +1 -1
  404. package/dist/server/middleware/trust-fence.d.ts +1 -1
  405. package/dist/server/middleware/trust-fence.d.ts.map +1 -1
  406. package/dist/server/multipart.d.ts +1 -1
  407. package/dist/server/multipart.d.ts.map +1 -1
  408. package/dist/{tools/oauth-metadata.d.ts → server/oauth/metadata.d.ts} +2 -2
  409. package/dist/server/oauth/metadata.d.ts.map +1 -0
  410. package/dist/{tools/oauth-provider.d.ts → server/oauth/provider.d.ts} +2 -2
  411. package/dist/server/oauth/provider.d.ts.map +1 -0
  412. package/dist/server/realtime.d.ts +1 -1
  413. package/dist/server/realtime.d.ts.map +1 -1
  414. package/dist/server/request-completion.d.ts +16 -0
  415. package/dist/server/request-completion.d.ts.map +1 -0
  416. package/dist/server/response-metadata.d.ts +1 -1
  417. package/dist/server/response-metadata.d.ts.map +1 -1
  418. package/dist/server/route-table.d.ts +9 -0
  419. package/dist/server/route-table.d.ts.map +1 -0
  420. package/dist/server/stream.d.ts +0 -13
  421. package/dist/server/stream.d.ts.map +1 -1
  422. package/dist/server/types.d.ts +7 -4
  423. package/dist/server/types.d.ts.map +1 -1
  424. package/dist/testing/handler-clients.d.ts +31 -0
  425. package/dist/testing/handler-clients.d.ts.map +1 -0
  426. package/dist/testing/managed-resource-conformance-scenarios.d.ts.map +1 -1
  427. package/dist/testing/surface-conformance.d.ts +2 -1
  428. package/dist/testing/surface-conformance.d.ts.map +1 -1
  429. package/dist/testing/surface-manifest.d.ts +30 -4
  430. package/dist/testing/surface-manifest.d.ts.map +1 -1
  431. package/dist/tools/{cli-args.d.ts → cli/args.d.ts} +1 -1
  432. package/dist/tools/cli/args.d.ts.map +1 -0
  433. package/dist/tools/{cli-checkpoint.d.ts → cli/checkpoint.d.ts} +1 -1
  434. package/dist/tools/cli/checkpoint.d.ts.map +1 -0
  435. package/dist/tools/{cli-command.d.ts → cli/command.d.ts} +4 -4
  436. package/dist/tools/cli/command.d.ts.map +1 -0
  437. package/dist/tools/{cli.d.ts → cli/config.d.ts} +5 -9
  438. package/dist/tools/cli/config.d.ts.map +1 -0
  439. package/dist/tools/cli/create-cli.d.ts +36 -0
  440. package/dist/tools/cli/create-cli.d.ts.map +1 -0
  441. package/dist/tools/cli/download.d.ts +8 -0
  442. package/dist/tools/cli/download.d.ts.map +1 -0
  443. package/dist/tools/{cli-format.d.ts → cli/format.d.ts} +2 -2
  444. package/dist/tools/cli/format.d.ts.map +1 -0
  445. package/dist/tools/cli/help.d.ts +24 -0
  446. package/dist/tools/cli/help.d.ts.map +1 -0
  447. package/dist/tools/{cli-installer.d.ts → cli/installer.d.ts} +2 -2
  448. package/dist/tools/cli/installer.d.ts.map +1 -0
  449. package/dist/tools/{cli-invoke.d.ts → cli/invoke.d.ts} +8 -8
  450. package/dist/tools/cli/invoke.d.ts.map +1 -0
  451. package/dist/tools/cli/io.d.ts +10 -0
  452. package/dist/tools/cli/io.d.ts.map +1 -0
  453. package/dist/tools/cli/managed-surface.d.ts +30 -0
  454. package/dist/tools/cli/managed-surface.d.ts.map +1 -0
  455. package/dist/tools/{cli-manifest.d.ts → cli/manifest.d.ts} +1 -1
  456. package/dist/tools/cli/manifest.d.ts.map +1 -0
  457. package/dist/tools/{cli-policy.d.ts → cli/policy.d.ts} +2 -2
  458. package/dist/tools/cli/policy.d.ts.map +1 -0
  459. package/dist/tools/cli/prepare.d.ts +14 -0
  460. package/dist/tools/cli/prepare.d.ts.map +1 -0
  461. package/dist/tools/{cli-profile.d.ts → cli/profile.d.ts} +2 -2
  462. package/dist/tools/cli/profile.d.ts.map +1 -0
  463. package/dist/tools/cli/run-managed.d.ts +5 -0
  464. package/dist/tools/cli/run-managed.d.ts.map +1 -0
  465. package/dist/tools/cli/run-native.d.ts +9 -0
  466. package/dist/tools/cli/run-native.d.ts.map +1 -0
  467. package/dist/tools/cli/session.d.ts +40 -0
  468. package/dist/tools/cli/session.d.ts.map +1 -0
  469. package/dist/tools/{cli-signature.d.ts → cli/signature.d.ts} +2 -2
  470. package/dist/tools/cli/signature.d.ts.map +1 -0
  471. package/dist/tools/{cli-stream.d.ts → cli/stream.d.ts} +4 -4
  472. package/dist/tools/cli/stream.d.ts.map +1 -0
  473. package/dist/tools/{cli-update.d.ts → cli/update.d.ts} +3 -3
  474. package/dist/tools/cli/update.d.ts.map +1 -0
  475. package/dist/tools/{cli-view.d.ts → cli/view.d.ts} +2 -2
  476. package/dist/tools/cli/view.d.ts.map +1 -0
  477. package/dist/tools/{cli-wait.d.ts → cli/wait.d.ts} +2 -2
  478. package/dist/tools/cli/wait.d.ts.map +1 -0
  479. package/dist/tools/connections/runtime.d.ts +1 -1
  480. package/dist/tools/connections/runtime.d.ts.map +1 -1
  481. package/dist/tools/connections/types.d.ts +3 -3
  482. package/dist/tools/connections/types.d.ts.map +1 -1
  483. package/dist/tools/durability-context.d.ts +1 -1
  484. package/dist/tools/durability-context.d.ts.map +1 -1
  485. package/dist/tools/execute.d.ts +30 -3
  486. package/dist/tools/execute.d.ts.map +1 -1
  487. package/dist/tools/internal/surface-projector.d.ts +8 -6
  488. package/dist/tools/internal/surface-projector.d.ts.map +1 -1
  489. package/dist/tools/internal/tool-view.d.ts +41 -0
  490. package/dist/tools/internal/tool-view.d.ts.map +1 -0
  491. package/dist/tools/invoker.d.ts +11 -3
  492. package/dist/tools/invoker.d.ts.map +1 -1
  493. package/dist/tools/list-names.d.ts +3 -3
  494. package/dist/tools/list-names.d.ts.map +1 -1
  495. package/dist/tools/manifest.d.ts +2 -2
  496. package/dist/tools/manifest.d.ts.map +1 -1
  497. package/dist/tools/{mcp-app.d.ts → mcp/app.d.ts} +1 -1
  498. package/dist/tools/mcp/app.d.ts.map +1 -0
  499. package/dist/tools/{mcp-catalog.d.ts → mcp/catalog.d.ts} +2 -2
  500. package/dist/tools/mcp/catalog.d.ts.map +1 -0
  501. package/dist/tools/{mcp-handler.d.ts → mcp/handler.d.ts} +5 -5
  502. package/dist/tools/mcp/handler.d.ts.map +1 -0
  503. package/dist/tools/{mcp.d.ts → mcp/mount.d.ts} +9 -9
  504. package/dist/tools/mcp/mount.d.ts.map +1 -0
  505. package/dist/tools/{mcp-prepare.d.ts → mcp/prepare.d.ts} +9 -9
  506. package/dist/tools/mcp/prepare.d.ts.map +1 -0
  507. package/dist/tools/{mcp-progress.d.ts → mcp/progress.d.ts} +2 -2
  508. package/dist/tools/mcp/progress.d.ts.map +1 -0
  509. package/dist/tools/mcp/register.d.ts +35 -0
  510. package/dist/tools/mcp/register.d.ts.map +1 -0
  511. package/dist/tools/{mcp-round-policy.d.ts → mcp/round-policy.d.ts} +2 -2
  512. package/dist/tools/mcp/round-policy.d.ts.map +1 -0
  513. package/dist/tools/{mcp-round.d.ts → mcp/round.d.ts} +4 -4
  514. package/dist/tools/mcp/round.d.ts.map +1 -0
  515. package/dist/tools/mcp/runtime-tools.d.ts +24 -0
  516. package/dist/tools/mcp/runtime-tools.d.ts.map +1 -0
  517. package/dist/tools/{mcp-stdio-signals.d.ts → mcp/stdio-signals.d.ts} +3 -3
  518. package/dist/tools/mcp/stdio-signals.d.ts.map +1 -0
  519. package/dist/tools/{mcp-stdio.d.ts → mcp/stdio.d.ts} +4 -4
  520. package/dist/tools/mcp/stdio.d.ts.map +1 -0
  521. package/dist/tools/{mcp-trace.d.ts → mcp/trace.d.ts} +1 -1
  522. package/dist/tools/mcp/trace.d.ts.map +1 -0
  523. package/dist/tools/mount.d.ts +12 -7
  524. package/dist/tools/mount.d.ts.map +1 -1
  525. package/dist/tools/native-definition.d.ts +3 -3
  526. package/dist/tools/native-definition.d.ts.map +1 -1
  527. package/dist/tools/operations/async-operation-binding-types.d.ts +127 -0
  528. package/dist/tools/operations/async-operation-binding-types.d.ts.map +1 -0
  529. package/dist/tools/operations/async-operation-binding.d.ts +28 -0
  530. package/dist/tools/operations/async-operation-binding.d.ts.map +1 -0
  531. package/dist/tools/operations/async-operation-canonical-types.d.ts +110 -0
  532. package/dist/tools/operations/async-operation-canonical-types.d.ts.map +1 -0
  533. package/dist/tools/operations/async-operation-canonical.d.ts +7 -0
  534. package/dist/tools/operations/async-operation-canonical.d.ts.map +1 -0
  535. package/dist/tools/operations/async-operation-contract.d.ts.map +1 -0
  536. package/dist/tools/operations/async-operation-id.d.ts +23 -0
  537. package/dist/tools/operations/async-operation-id.d.ts.map +1 -0
  538. package/dist/tools/operations/async-operation-runtime-tools.d.ts +40 -0
  539. package/dist/tools/operations/async-operation-runtime-tools.d.ts.map +1 -0
  540. package/dist/tools/operations/async-operation-runtime-types.d.ts +68 -0
  541. package/dist/tools/operations/async-operation-runtime-types.d.ts.map +1 -0
  542. package/dist/tools/operations/async-operation-runtime.d.ts +5 -0
  543. package/dist/tools/operations/async-operation-runtime.d.ts.map +1 -0
  544. package/dist/tools/{define-wait-tool.d.ts → operations/define-wait-tool.d.ts} +2 -2
  545. package/dist/tools/operations/define-wait-tool.d.ts.map +1 -0
  546. package/dist/tools/operations/mount-wait.d.ts.map +1 -0
  547. package/dist/tools/operations/wait-core.d.ts.map +1 -0
  548. package/dist/tools/remote.d.ts +1 -1
  549. package/dist/tools/remote.d.ts.map +1 -1
  550. package/dist/tools/runtime-tool.d.ts +11 -4
  551. package/dist/tools/runtime-tool.d.ts.map +1 -1
  552. package/dist/tools/schema/coerce.d.ts.map +1 -0
  553. package/dist/tools/schema/flatten-join.d.ts.map +1 -0
  554. package/dist/tools/schema/flatten.d.ts.map +1 -0
  555. package/dist/tools/schema/portable-formats.d.ts.map +1 -0
  556. package/dist/tools/{presentation.d.ts → schema/presentation.d.ts} +2 -0
  557. package/dist/tools/schema/presentation.d.ts.map +1 -0
  558. package/dist/tools/schema/schema.d.ts.map +1 -0
  559. package/dist/tools/schema/untyped-properties.d.ts.map +1 -0
  560. package/dist/tools/surface.d.ts +2 -3
  561. package/dist/tools/surface.d.ts.map +1 -1
  562. package/dist/tools/toolkit.d.ts +4 -4
  563. package/dist/tools/toolkit.d.ts.map +1 -1
  564. package/dist/tools/{define-download-tool.d.ts → transfer/define-download-tool.d.ts} +4 -4
  565. package/dist/tools/transfer/define-download-tool.d.ts.map +1 -0
  566. package/dist/tools/{define-upload-tool.d.ts → transfer/define-upload-tool.d.ts} +3 -3
  567. package/dist/tools/transfer/define-upload-tool.d.ts.map +1 -0
  568. package/dist/tools/{define-view-file-tool.d.ts → transfer/define-view-file-tool.d.ts} +2 -2
  569. package/dist/tools/transfer/define-view-file-tool.d.ts.map +1 -0
  570. package/dist/tools/{download-core.d.ts → transfer/download-core.d.ts} +2 -2
  571. package/dist/tools/transfer/download-core.d.ts.map +1 -0
  572. package/dist/tools/{managed-file-error.d.ts → transfer/managed-file-error.d.ts} +1 -1
  573. package/dist/tools/transfer/managed-file-error.d.ts.map +1 -0
  574. package/dist/tools/{mount-download.d.ts → transfer/mount-download.d.ts} +1 -1
  575. package/dist/tools/transfer/mount-download.d.ts.map +1 -0
  576. package/dist/tools/{mount-upload.d.ts → transfer/mount-upload.d.ts} +1 -1
  577. package/dist/tools/transfer/mount-upload.d.ts.map +1 -0
  578. package/dist/tools/transfer/native-result.d.ts.map +1 -0
  579. package/dist/tools/{upload-core.d.ts → transfer/upload-core.d.ts} +1 -1
  580. package/dist/tools/transfer/upload-core.d.ts.map +1 -0
  581. package/dist/tools/transfer/view-file-contract.d.ts.map +1 -0
  582. package/dist/tools/{view-file.d.ts → transfer/view-file.d.ts} +1 -1
  583. package/dist/tools/transfer/view-file.d.ts.map +1 -0
  584. package/dist/tools/transports.d.ts +1 -1
  585. package/dist/tools/transports.d.ts.map +1 -1
  586. package/dist/tracking/contract.d.ts +1 -1
  587. package/dist/tracking/contract.d.ts.map +1 -1
  588. package/llms/agent-runtime-browser.txt +33 -0
  589. package/llms/agent-runtime-coding-tools.txt +58 -0
  590. package/llms/agent-runtime-harness.txt +45 -0
  591. package/llms/agent-runtime-openrouter.txt +22 -0
  592. package/llms/agent-runtime-sandbox.txt +159 -0
  593. package/llms/agent-runtime-sqlite-bun.txt +29 -0
  594. package/llms/agent-runtime-sqlite-node.txt +26 -0
  595. package/llms/agent-runtime-testing.txt +30 -0
  596. package/llms/agent-runtime.2.txt +550 -0
  597. package/llms/agent-runtime.3.txt +311 -0
  598. package/llms/agent-runtime.txt +893 -0
  599. package/llms/application-diagnostic-journal.txt +30 -0
  600. package/llms/application-grammy.txt +27 -0
  601. package/llms/application-opentelemetry.txt +27 -0
  602. package/llms/application-schemas.txt +42 -0
  603. package/llms/application.2.txt +223 -0
  604. package/llms/application.txt +1144 -0
  605. package/llms/cli.txt +977 -0
  606. package/llms/contract.txt +606 -0
  607. package/llms/declaration.txt +286 -0
  608. package/llms/files.txt +30 -0
  609. package/llms/geo.txt +114 -0
  610. package/llms/google.txt +27 -0
  611. package/llms/live.txt +471 -0
  612. package/llms/node.txt +43 -0
  613. package/llms/oauth.txt +136 -0
  614. package/llms/observability.txt +893 -0
  615. package/llms/primitives.txt +158 -0
  616. package/llms/react.txt +184 -0
  617. package/llms/release.txt +176 -0
  618. package/llms/remote.txt +25 -0
  619. package/llms/server.2.txt +361 -0
  620. package/llms/server.3.txt +1031 -0
  621. package/llms/server.4.txt +905 -0
  622. package/llms/server.5.txt +250 -0
  623. package/llms/server.txt +996 -0
  624. package/llms/stitchkit.2.txt +836 -0
  625. package/llms/stitchkit.3.txt +147 -0
  626. package/llms/stitchkit.txt +260 -0
  627. package/llms/telegram.txt +30 -0
  628. package/llms/testing.txt +676 -0
  629. package/llms/tools-connections.txt +45 -0
  630. package/llms/tools-contract.txt +9 -0
  631. package/llms/tools-invoker.txt +9 -0
  632. package/llms/tools.2.txt +838 -0
  633. package/llms/tools.txt +1004 -0
  634. package/llms/tracking-server.txt +32 -0
  635. package/llms/tracking.txt +263 -0
  636. package/llms/upgrading-0.37.0-0.50.0.txt +947 -0
  637. package/llms/upgrading-0.53.0-0.67.0.txt +1174 -0
  638. package/llms/upgrading-0.68.0-0.94.0.txt +1159 -0
  639. package/llms/upgrading.txt +215 -0
  640. package/llms-full.txt +214 -75
  641. package/llms.txt +54 -5
  642. package/package.json +84 -83
  643. package/dist/agent-runtime/durability-contract.d.ts.map +0 -1
  644. package/dist/agent-runtime/durability-json.d.ts.map +0 -1
  645. package/dist/agent-runtime/durability-ledger.d.ts.map +0 -1
  646. package/dist/agent-runtime/durability-scheduler.d.ts.map +0 -1
  647. package/dist/agent-runtime/durability.d.ts.map +0 -1
  648. package/dist/agent-runtime/store-driver.d.ts.map +0 -1
  649. package/dist/agent-runtime-browser.d.ts +0 -5
  650. package/dist/agent-runtime-browser.d.ts.map +0 -1
  651. package/dist/agent-runtime-coding-tools.d.ts.map +0 -1
  652. package/dist/agent-runtime-coding-tools.js +0 -23
  653. package/dist/agent-runtime-harness.d.ts.map +0 -1
  654. package/dist/agent-runtime-openrouter.d.ts.map +0 -1
  655. package/dist/agent-runtime-sandbox.d.ts.map +0 -1
  656. package/dist/agent-runtime-sqlite-bun.d.ts.map +0 -1
  657. package/dist/agent-runtime-sqlite-node.d.ts.map +0 -1
  658. package/dist/agent-runtime-testing.d.ts +0 -3
  659. package/dist/agent-runtime-testing.d.ts.map +0 -1
  660. package/dist/agent-runtime-testing.js +0 -156
  661. package/dist/agent-runtime.d.ts.map +0 -1
  662. package/dist/application/channel.d.ts.map +0 -1
  663. package/dist/application-diagnostic-journal.d.ts.map +0 -1
  664. package/dist/application-grammy.d.ts.map +0 -1
  665. package/dist/application-opentelemetry.d.ts.map +0 -1
  666. package/dist/application-schemas.d.ts.map +0 -1
  667. package/dist/application.d.ts.map +0 -1
  668. package/dist/cli.d.ts.map +0 -1
  669. package/dist/contract/index.d.ts +0 -8
  670. package/dist/contract/index.d.ts.map +0 -1
  671. package/dist/declaration.d.ts.map +0 -1
  672. package/dist/files.d.ts.map +0 -1
  673. package/dist/geo.d.ts.map +0 -1
  674. package/dist/google.d.ts.map +0 -1
  675. package/dist/index-0j3vcp5m.js +0 -28
  676. package/dist/index-a11g2kry.js +0 -866
  677. package/dist/index-cnyk6te3.js +0 -77
  678. package/dist/index-fadnxwna.js +0 -1046
  679. package/dist/index-hrbajay7.js +0 -1196
  680. package/dist/index-s8cnx02s.js +0 -90
  681. package/dist/index-v5573g1k.js +0 -142
  682. package/dist/index-vk3kq9sb.js +0 -3344
  683. package/dist/index.d.ts.map +0 -1
  684. package/dist/internal/errors.d.ts.map +0 -1
  685. package/dist/internal/observability-sink.d.ts.map +0 -1
  686. package/dist/live.d.ts.map +0 -1
  687. package/dist/logger.d.ts.map +0 -1
  688. package/dist/node.d.ts.map +0 -1
  689. package/dist/oauth.d.ts.map +0 -1
  690. package/dist/observability/index.d.ts.map +0 -1
  691. package/dist/primitives.d.ts +0 -3
  692. package/dist/primitives.d.ts.map +0 -1
  693. package/dist/react.d.ts.map +0 -1
  694. package/dist/release.d.ts.map +0 -1
  695. package/dist/remote.d.ts.map +0 -1
  696. package/dist/remote.js +0 -88
  697. package/dist/retained.d.ts.map +0 -1
  698. package/dist/server/file-state-store.d.ts.map +0 -1
  699. package/dist/server/index.d.ts.map +0 -1
  700. package/dist/server/request.d.ts.map +0 -1
  701. package/dist/telegram.d.ts.map +0 -1
  702. package/dist/testing/agent-store-conformance.d.ts.map +0 -1
  703. package/dist/testing.d.ts +0 -39
  704. package/dist/testing.d.ts.map +0 -1
  705. package/dist/tool-invoker.d.ts.map +0 -1
  706. package/dist/tool-invoker.js +0 -21
  707. package/dist/tools/async-operation-contract.d.ts.map +0 -1
  708. package/dist/tools/async-operation.d.ts +0 -332
  709. package/dist/tools/async-operation.d.ts.map +0 -1
  710. package/dist/tools/cli-args.d.ts.map +0 -1
  711. package/dist/tools/cli-checkpoint.d.ts.map +0 -1
  712. package/dist/tools/cli-command.d.ts.map +0 -1
  713. package/dist/tools/cli-format.d.ts.map +0 -1
  714. package/dist/tools/cli-installer.d.ts.map +0 -1
  715. package/dist/tools/cli-invoke.d.ts.map +0 -1
  716. package/dist/tools/cli-manifest.d.ts.map +0 -1
  717. package/dist/tools/cli-policy.d.ts.map +0 -1
  718. package/dist/tools/cli-profile.d.ts.map +0 -1
  719. package/dist/tools/cli-signature.d.ts.map +0 -1
  720. package/dist/tools/cli-stream.d.ts.map +0 -1
  721. package/dist/tools/cli-update.d.ts.map +0 -1
  722. package/dist/tools/cli-view.d.ts.map +0 -1
  723. package/dist/tools/cli-wait.d.ts.map +0 -1
  724. package/dist/tools/cli.d.ts.map +0 -1
  725. package/dist/tools/coerce.d.ts.map +0 -1
  726. package/dist/tools/connections/index.d.ts.map +0 -1
  727. package/dist/tools/define-download-tool.d.ts.map +0 -1
  728. package/dist/tools/define-upload-tool.d.ts.map +0 -1
  729. package/dist/tools/define-view-file-tool.d.ts.map +0 -1
  730. package/dist/tools/define-wait-tool.d.ts.map +0 -1
  731. package/dist/tools/download-core.d.ts.map +0 -1
  732. package/dist/tools/flatten-join.d.ts.map +0 -1
  733. package/dist/tools/flatten.d.ts.map +0 -1
  734. package/dist/tools/json-schema-dialect.d.ts.map +0 -1
  735. package/dist/tools/json-schema.d.ts.map +0 -1
  736. package/dist/tools/managed-file-error.d.ts.map +0 -1
  737. package/dist/tools/mcp-app.d.ts.map +0 -1
  738. package/dist/tools/mcp-catalog.d.ts.map +0 -1
  739. package/dist/tools/mcp-handler.d.ts.map +0 -1
  740. package/dist/tools/mcp-prepare.d.ts.map +0 -1
  741. package/dist/tools/mcp-progress.d.ts.map +0 -1
  742. package/dist/tools/mcp-round-policy.d.ts.map +0 -1
  743. package/dist/tools/mcp-round.d.ts.map +0 -1
  744. package/dist/tools/mcp-stdio-signals.d.ts.map +0 -1
  745. package/dist/tools/mcp-stdio.d.ts.map +0 -1
  746. package/dist/tools/mcp-trace.d.ts.map +0 -1
  747. package/dist/tools/mcp.d.ts.map +0 -1
  748. package/dist/tools/mount-download.d.ts.map +0 -1
  749. package/dist/tools/mount-upload.d.ts.map +0 -1
  750. package/dist/tools/mount-wait.d.ts.map +0 -1
  751. package/dist/tools/native-mcp.d.ts +0 -20
  752. package/dist/tools/native-mcp.d.ts.map +0 -1
  753. package/dist/tools/native-result.d.ts.map +0 -1
  754. package/dist/tools/oauth-metadata.d.ts.map +0 -1
  755. package/dist/tools/oauth-provider.d.ts.map +0 -1
  756. package/dist/tools/portable-formats.d.ts.map +0 -1
  757. package/dist/tools/presentation.d.ts.map +0 -1
  758. package/dist/tools/schema.d.ts.map +0 -1
  759. package/dist/tools/untyped-properties.d.ts.map +0 -1
  760. package/dist/tools/upload-core.d.ts.map +0 -1
  761. package/dist/tools/view-file-contract.d.ts.map +0 -1
  762. package/dist/tools/view-file.d.ts.map +0 -1
  763. package/dist/tools/wait-core.d.ts.map +0 -1
  764. package/dist/tools-contract.d.ts.map +0 -1
  765. package/dist/tools.d.ts +0 -50
  766. package/dist/tools.d.ts.map +0 -1
  767. package/dist/tracking-server.d.ts.map +0 -1
  768. package/dist/tracking.d.ts.map +0 -1
  769. package/dist/upgrade-cli.d.ts.map +0 -1
  770. package/dist/{retained.d.ts → browser/retained.d.ts} +0 -0
  771. package/dist/{declaration.d.ts → declaration/declaration.d.ts} +0 -0
  772. package/dist/{upgrade-cli.d.ts → entrypoints/bin/upgrade-cli.d.ts} +0 -0
  773. package/dist/{tracking-server.js → entrypoints/tracking/server.js} +0 -0
  774. package/dist/{google.d.ts → google/google.d.ts} +0 -0
  775. package/dist/{index-pq95qkbf.js → index-5jm36zv1.js} +0 -0
  776. package/dist/{index-actkayzn.js → index-70yj2ebz.js} +3 -3
  777. /package/dist/{application → internal}/channel.d.ts +0 -0
  778. /package/dist/{logger.d.ts → internal/logger.d.ts} +0 -0
  779. /package/dist/{server → internal}/request.d.ts +0 -0
  780. /package/dist/{tools → json-schema}/json-schema.d.ts +0 -0
  781. /package/dist/tools/{async-operation-contract.d.ts → operations/async-operation-contract.d.ts} +0 -0
  782. /package/dist/tools/{mount-wait.d.ts → operations/mount-wait.d.ts} +0 -0
  783. /package/dist/tools/{wait-core.d.ts → operations/wait-core.d.ts} +0 -0
  784. /package/dist/tools/{coerce.d.ts → schema/coerce.d.ts} +0 -0
  785. /package/dist/tools/{flatten-join.d.ts → schema/flatten-join.d.ts} +0 -0
  786. /package/dist/tools/{flatten.d.ts → schema/flatten.d.ts} +0 -0
  787. /package/dist/tools/{portable-formats.d.ts → schema/portable-formats.d.ts} +0 -0
  788. /package/dist/tools/{schema.d.ts → schema/schema.d.ts} +0 -0
  789. /package/dist/tools/{untyped-properties.d.ts → schema/untyped-properties.d.ts} +0 -0
  790. /package/dist/tools/{native-result.d.ts → transfer/native-result.d.ts} +0 -0
  791. /package/dist/tools/{view-file-contract.d.ts → transfer/view-file-contract.d.ts} +0 -0
@@ -1,909 +1,77 @@
1
1
  import {
2
2
  createApplication
3
- } from "./index-a11g2kry.js";
4
- import"./index-3gye9wzb.js";
5
- import"./index-2k4yrqkc.js";
6
- import"./index-3z73fh2c.js";
7
- import {
8
- createMemoryAgentRuntimeStore
9
- } from "./index-hrbajay7.js";
10
- import {
11
- decodeAgentConversationArchive
12
- } from "./index-zwkgfq1s.js";
13
- import {
14
- AgentMessageSchema,
15
- AgentRunSchema
16
- } from "./index-gtj3zc53.js";
17
- import {
18
- createAgentRaceBarrier,
19
- createAgentRaceDriver,
20
- createAgentRaceTrace
21
- } from "./index-cnyk6te3.js";
3
+ } from "../index-fdp6hdxn.js";
4
+ import"../index-3gye9wzb.js";
5
+ import"../index-2k4yrqkc.js";
6
+ import"../index-3z73fh2c.js";
22
7
  import {
23
8
  RealtimeRejectDirectionSchema,
24
9
  RealtimeRejectFaultSchema,
25
10
  RealtimeRejectPhaseSchema,
26
11
  RealtimeRejectReasonSchema
27
- } from "./index-p7hgdyhb.js";
12
+ } from "../index-p7hgdyhb.js";
28
13
  import {
29
14
  createClient,
30
15
  createClients
31
- } from "./index-yewwh1w4.js";
16
+ } from "../index-e87kakm4.js";
32
17
  import {
33
18
  RealtimeRequestDisconnectedError,
34
19
  RealtimeRequestInvalidAcknowledgementError,
35
20
  RealtimeRequestTimeoutError
36
- } from "./index-2qzskm8h.js";
37
- import"./index-v5573g1k.js";
38
- import"./index-3xwxfj4z.js";
39
- import {
40
- compareCodepoints,
41
- serializeCanonicalJson
42
- } from "./index-0j3vcp5m.js";
43
- import"./index-e0znv5gn.js";
21
+ } from "../index-2qzskm8h.js";
22
+ import"../index-48ffdxgk.js";
23
+ import"../index-wqgjfstn.js";
24
+ import"../index-zeemqhqx.js";
44
25
  import {
26
+ TOOL_TRANSPORTS,
45
27
  joinRoutePath
46
- } from "./index-0a349c33.js";
47
- import"./index-rxfy4cq7.js";
48
- import"./index-6k1937bx.js";
49
- import"./index-zcgf3gqf.js";
28
+ } from "../index-gyr48nzg.js";
29
+ import"../index-zcgf3gqf.js";
50
30
  import {
51
31
  mcpProjectionCandidate,
52
32
  prepareProjectedMcpTools,
53
33
  projectToolSurface,
54
34
  staticInputRounds
55
- } from "./index-h9etkkyk.js";
35
+ } from "../index-dydjcp8z.js";
56
36
  import {
57
37
  toJsonSchema
58
- } from "./index-cby4ar3v.js";
59
- import"./index-2vtcmrj9.js";
60
- import"./index-kzfs85xp.js";
38
+ } from "../index-eqqvgdb3.js";
39
+ import"../index-znfs20ss.js";
40
+ import"../index-p5r7qpdd.js";
41
+ import"../index-2vtcmrj9.js";
42
+ import {
43
+ compareCodeUnits,
44
+ serializeCanonicalJson
45
+ } from "../index-k5hsfc3j.js";
46
+ import"../index-kzfs85xp.js";
61
47
  import {
62
48
  isRecord
63
- } from "./index-77fekveh.js";
64
- // src/testing/agent-store-conformance.ts
65
- function userMessage(conversationId, id) {
66
- return AgentMessageSchema.parse({
67
- schemaVersion: 1,
68
- id,
69
- conversationId,
70
- role: "user",
71
- status: "committed",
72
- parts: [{ type: "text", text: id }],
73
- createdAt: "2026-08-22T00:00:00.000Z",
74
- updatedAt: "2026-08-22T00:00:00.000Z"
75
- });
76
- }
77
- function queuedRun(conversationId, inputMessageId, id) {
78
- return AgentRunSchema.parse({
79
- schemaVersion: 1,
80
- id,
81
- conversationId,
82
- inputMessageIds: [inputMessageId],
83
- assistantMessageId: `${id}-assistant`,
84
- state: "queued",
85
- revision: 0,
86
- createdAt: "2026-08-22T00:00:00.000Z",
87
- updatedAt: "2026-08-22T00:00:00.000Z"
88
- });
89
- }
90
- function requireOutcome(actual, expected) {
91
- if (actual.outcome !== expected) {
92
- throw new Error(`Agent store conformance expected ${expected}, received ${actual.outcome}`);
49
+ } from "../index-hffjpmq9.js";
50
+
51
+ // src/testing/handler-clients.ts
52
+ function resolveTestBaseUrl(origin, pathPrefix) {
53
+ const base = new URL(origin ?? "http://stitchkit.test");
54
+ if (base.pathname !== "/" || base.search || base.hash) {
55
+ throw new TypeError("Handler test client origin must contain only an absolute origin");
93
56
  }
57
+ const prefix = pathPrefix?.replace(/^\/+|\/+$/g, "");
58
+ return prefix ? `${base.origin}/${prefix}` : base.origin;
94
59
  }
95
- async function runAgentStoreConformance(config) {
96
- const run = `conformance-${crypto.randomUUID()}`;
97
- const context = {
98
- conversationIds: [
99
- run,
100
- `${run}-recovery`,
101
- `${run}-absorb`,
102
- `${run}-causal-history`,
103
- `${run}-causal-active`,
104
- `${run}-interrupt-priority`,
105
- `${run}-ledger`,
106
- `${run}-archive`,
107
- `${run}-seed`
108
- ]
109
- };
110
- const store = await config.createStore(context);
111
- let failure;
112
- try {
113
- await conformanceScenario(store, context.conversationIds);
114
- } catch (error) {
115
- failure = error;
116
- }
117
- try {
118
- await config.cleanup?.(context);
119
- } catch (cleanupError) {
120
- if (failure === undefined)
121
- throw cleanupError;
122
- throw new AggregateError([failure, cleanupError], `${failure instanceof Error ? failure.message : String(failure)} (cleanup also failed: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)})`);
123
- }
124
- if (failure !== undefined)
125
- throw failure;
60
+ function createHandlerFetch(handler, server) {
61
+ return async (input, init) => handler(new Request(input, init), server);
126
62
  }
127
- async function seedScenario(store, conversationId) {
128
- const input = {
129
- conversationId,
130
- seedKey: "brief",
131
- inputs: [userMessage(conversationId, "seed-a"), userMessage(conversationId, "seed-b")]
63
+ function createTestClientConfig(config) {
64
+ return {
65
+ ...config.client,
66
+ baseUrl: resolveTestBaseUrl(config.origin, config.pathPrefix),
67
+ fetch: createHandlerFetch(config.handler, config.server)
132
68
  };
133
- const first = await store.seedConversationInput(input);
134
- requireOutcome(first, "applied");
135
- const before = await store.loadSnapshot(conversationId);
136
- if (before.messages.map((message) => message.id).join(",") !== "seed-a,seed-b")
137
- throw new Error("Seed conformance: complete ordered seed missing");
138
- await Promise.all([store.seedConversationInput(input), store.seedConversationInput(input)]);
139
- const repeated = await store.loadSnapshot(conversationId);
140
- if (repeated.version !== before.version || repeated.messages.length !== 2)
141
- throw new Error("Seed conformance: replay changed history");
142
- const compacted = await store.replaceCompactedRange({
143
- conversationId,
144
- expectedVersion: repeated.version,
145
- replacedMessageIds: ["seed-a", "seed-b"],
146
- summary: AgentMessageSchema.parse({
147
- ...userMessage(conversationId, "seed-summary"),
148
- role: "summary"
149
- })
150
- });
151
- requireOutcome(compacted, "applied");
152
- await store.seedConversationInput(input);
153
- const after = await store.loadSnapshot(conversationId);
154
- if (after.messages.some((message) => message.id === "seed-a" || message.id === "seed-b"))
155
- throw new Error("Seed conformance: compacted instructions resurrected");
156
69
  }
157
- async function conformanceScenario(store, conversationIds) {
158
- const [
159
- conversationId,
160
- recoveryConversationId,
161
- absorbConversationId,
162
- causalHistoryConversationId,
163
- causalActiveConversationId,
164
- interruptPriorityConversationId,
165
- ledgerConversationId,
166
- archiveConversationId,
167
- seedConversationId
168
- ] = conversationIds;
169
- if (seedConversationId)
170
- await seedScenario(store, seedConversationId);
171
- if (ledgerConversationId)
172
- await ledgerScenario(store, ledgerConversationId);
173
- if (archiveConversationId)
174
- await archiveScenario(store, archiveConversationId);
175
- if (!conversationId || !recoveryConversationId || !absorbConversationId || !causalHistoryConversationId || !causalActiveConversationId || !interruptPriorityConversationId) {
176
- throw new Error("Agent store conformance requires six conversation identities");
177
- }
178
- const absentConversationId = `${conversationId}-absent`;
179
- const firstInput = userMessage(conversationId, "input-1");
180
- const firstRun = queuedRun(conversationId, firstInput.id, "run-1");
181
- const accepted = await store.acceptInputAndAssignRun({
182
- idempotencyKey: "request-1",
183
- input: firstInput,
184
- run: firstRun
185
- });
186
- requireOutcome(accepted, "applied");
187
- const duplicate = await store.acceptInputAndAssignRun({
188
- idempotencyKey: "request-1",
189
- input: userMessage(conversationId, "discarded-input"),
190
- run: queuedRun(conversationId, "discarded-input", "discarded-run")
191
- });
192
- requireOutcome(duplicate, "duplicate");
193
- if (duplicate.input.id !== firstInput.id || duplicate.inputMessageId !== firstInput.id || duplicate.runId !== firstRun.id || duplicate.assistantMessageId !== firstRun.assistantMessageId) {
194
- throw new Error("Duplicate admission did not return its original durable identity");
195
- }
196
- const secondInput = userMessage(conversationId, "input-2");
197
- const coalesced = await store.acceptInputAndAssignRun({
198
- idempotencyKey: "request-2",
199
- input: secondInput,
200
- run: queuedRun(conversationId, secondInput.id, "discarded-coalesced-run"),
201
- coalesceIntoRunId: firstRun.id
202
- });
203
- requireOutcome(coalesced, "applied");
204
- const assigned = coalesced.snapshot.runs.find((run) => run.id === firstRun.id);
205
- if (assigned?.inputMessageIds.join(",") !== "input-1,input-2") {
206
- throw new Error("Coalesced admission did not preserve ordered input identities");
207
- }
208
- const collidingInput = userMessage(conversationId, assigned.assistantMessageId);
209
- await store.acceptInputAndAssignRun({
210
- idempotencyKey: "request-collision",
211
- input: collidingInput,
212
- run: queuedRun(conversationId, collidingInput.id, "discarded-collision-run"),
213
- coalesceIntoRunId: assigned.id
214
- }).then(() => {
215
- throw new Error("Coalesced input reused the reserved assistant identity");
216
- }, (error) => {
217
- if (!(error instanceof TypeError))
218
- throw error;
219
- });
220
- await store.replaceCompactedRange({
221
- conversationId,
222
- expectedVersion: coalesced.snapshot.version,
223
- replacedMessageIds: [firstInput.id, secondInput.id],
224
- summary: AgentMessageSchema.parse({
225
- schemaVersion: 1,
226
- id: assigned.assistantMessageId,
227
- conversationId,
228
- role: "summary",
229
- status: "committed",
230
- parts: [{ type: "text", text: "invalid reserved identity" }],
231
- createdAt: "2026-08-22T00:00:02.000Z",
232
- updatedAt: "2026-08-22T00:00:02.000Z"
233
- })
234
- }).then(() => {
235
- throw new Error("Compaction reused a reserved assistant identity");
236
- }, (error) => {
237
- if (!(error instanceof TypeError))
238
- throw error;
239
- });
240
- const compacted = await store.replaceCompactedRange({
241
- conversationId,
242
- expectedVersion: coalesced.snapshot.version,
243
- replacedMessageIds: [firstInput.id, secondInput.id],
244
- summary: AgentMessageSchema.parse({
245
- schemaVersion: 1,
246
- id: "summary-1",
247
- conversationId,
248
- role: "summary",
249
- status: "committed",
250
- parts: [{ type: "text", text: "two inputs" }],
251
- createdAt: "2026-08-22T00:00:02.000Z",
252
- updatedAt: "2026-08-22T00:00:02.000Z"
253
- })
254
- });
255
- requireOutcome(compacted, "applied");
256
- const duplicateAfterCompaction = await store.acceptInputAndAssignRun({
257
- idempotencyKey: "request-1",
258
- input: userMessage(conversationId, "discarded-after-compaction"),
259
- run: queuedRun(conversationId, "discarded-after-compaction", "discarded-run-2")
260
- });
261
- requireOutcome(duplicateAfterCompaction, "duplicate");
262
- if (duplicateAfterCompaction.input.id !== firstInput.id) {
263
- throw new Error("Compaction discarded the canonical duplicate admission input");
264
- }
265
- const acquired = await store.acquireRun({
266
- conversationId,
267
- runId: assigned.id,
268
- expectedRevision: assigned.revision,
269
- ownerId: "conformance-owner"
270
- });
271
- requireOutcome(acquired, "applied");
272
- const running = acquired.snapshot.runs.find((run) => run.id === assigned.id);
273
- if (!running)
274
- throw new Error("Acquired run disappeared");
275
- const stale = await store.checkpointRunAssistant({
276
- conversationId,
277
- runId: running.id,
278
- expectedRevision: running.revision - 1,
279
- ownerId: "conformance-owner",
280
- assistant: AgentMessageSchema.parse({
281
- schemaVersion: 1,
282
- id: running.assistantMessageId,
283
- conversationId,
284
- runId: running.id,
285
- role: "assistant",
286
- status: "streaming",
287
- parts: [],
288
- createdAt: "2026-08-22T00:00:00.000Z",
289
- updatedAt: "2026-08-22T00:00:01.000Z"
290
- })
291
- });
292
- requireOutcome(stale, "conflict");
293
- await store.recoverRun({
294
- conversationId,
295
- runId: running.id,
296
- expectedRevision: running.revision,
297
- action: "requeue"
298
- }).then(() => {
299
- throw new Error("Acquired recovery replayed without explicit safety evidence");
300
- }, (error) => {
301
- if (!(error instanceof TypeError))
302
- throw error;
303
- });
304
- const checkpoint = await store.checkpointRunAssistant({
305
- conversationId,
306
- runId: running.id,
307
- expectedRevision: running.revision,
308
- ownerId: "conformance-owner",
309
- assistant: AgentMessageSchema.parse({
310
- schemaVersion: 1,
311
- id: running.assistantMessageId,
312
- conversationId,
313
- runId: running.id,
314
- role: "assistant",
315
- status: "streaming",
316
- parts: [{ type: "text", text: "checkpoint" }],
317
- createdAt: "2026-08-22T00:00:00.000Z",
318
- updatedAt: "2026-08-22T00:00:01.000Z"
319
- }),
320
- usage: {
321
- inputTokens: { value: 1000, provenance: "provider-reported" },
322
- outputTokens: { value: 100, provenance: "provider-reported" },
323
- cost: { value: 0.25, currency: "USD", provenance: "provider-reported" }
324
- }
325
- });
326
- requireOutcome(checkpoint, "applied");
327
- const checkpointedRun = checkpoint.snapshot.runs.find((run) => run.id === running.id);
328
- if (!checkpointedRun)
329
- throw new Error("Checkpointed run disappeared");
330
- if (checkpointedRun.usage?.cost?.value !== 0.25) {
331
- throw new Error("Checkpoint did not persist the run usage it was given");
332
- }
333
- const terminalAssistant = AgentMessageSchema.parse({
334
- schemaVersion: 1,
335
- id: running.assistantMessageId,
336
- conversationId,
337
- runId: running.id,
338
- role: "assistant",
339
- status: "completed",
340
- parts: [{ type: "text", text: "done" }],
341
- createdAt: "2026-08-22T00:00:00.000Z",
342
- updatedAt: "2026-08-22T00:00:02.000Z"
343
- });
344
- if (checkpointedRun.fencingToken === undefined) {
345
- throw new Error("Acquisition must persist a fencing token the store can read back");
346
- }
347
- const staleFence = await store.checkpointRunAssistant({
348
- conversationId,
349
- runId: running.id,
350
- expectedRevision: checkpointedRun.revision,
351
- ownerId: "conformance-owner",
352
- fencingToken: checkpointedRun.fencingToken + 1,
353
- assistant: AgentMessageSchema.parse({
354
- schemaVersion: 1,
355
- id: running.assistantMessageId,
356
- conversationId,
357
- runId: running.id,
358
- role: "assistant",
359
- status: "streaming",
360
- parts: [{ type: "text", text: "stale fence" }],
361
- createdAt: "2026-08-22T00:00:00.000Z",
362
- updatedAt: "2026-08-22T00:00:01.500Z"
363
- })
364
- });
365
- if (staleFence.outcome !== "conflict") {
366
- throw new Error("A checkpoint with a stale fencing token must conflict");
367
- }
368
- const foreignOwner = await store.checkpointRunAssistant({
369
- conversationId,
370
- runId: running.id,
371
- expectedRevision: checkpointedRun.revision,
372
- ownerId: "a-different-runtime",
373
- assistant: AgentMessageSchema.parse({
374
- schemaVersion: 1,
375
- id: running.assistantMessageId,
376
- conversationId,
377
- runId: running.id,
378
- role: "assistant",
379
- status: "streaming",
380
- parts: [{ type: "text", text: "foreign owner" }],
381
- createdAt: "2026-08-22T00:00:00.000Z",
382
- updatedAt: "2026-08-22T00:00:01.700Z"
383
- })
384
- });
385
- if (foreignOwner.outcome !== "conflict") {
386
- throw new Error("A checkpoint from another owner must conflict");
387
- }
388
- const liveView = await store.loadRun({ conversationId, runId: running.id });
389
- if (!liveView)
390
- throw new Error("loadRun must find a run of this conversation");
391
- if (liveView.run.id !== running.id || liveView.run.conversationId !== conversationId) {
392
- throw new Error("loadRun returned a run it was not asked for");
393
- }
394
- if (liveView.run.revision !== checkpointedRun.revision) {
395
- throw new Error("loadRun must return the run as the last mutation left it");
396
- }
397
- if (liveView.run.usage?.cost?.value !== 0.25) {
398
- throw new Error("loadRun must carry the figure the run has spent so far");
399
- }
400
- if (liveView.snapshotVersion !== checkpoint.snapshot.version) {
401
- throw new Error("loadRun must report the conversation version it read at");
402
- }
403
- if (liveView.assistant !== undefined) {
404
- throw new Error("loadRun must not report a terminal answer for a live run");
405
- }
406
- if (await store.loadRun({ conversationId, runId: "no-such-run" })) {
407
- throw new Error("loadRun must return undefined for an unknown run");
408
- }
409
- if (await store.loadRun({ conversationId: absentConversationId, runId: running.id })) {
410
- throw new Error("loadRun must not cross conversation boundaries");
411
- }
412
- const activeRuns = await store.listActiveRuns(conversationId);
413
- if (!activeRuns.some((run) => run.id === running.id)) {
414
- throw new Error("listActiveRuns must report a run that is in flight");
415
- }
416
- if (activeRuns.some((run) => run.terminalReason !== undefined)) {
417
- throw new Error("listActiveRuns must not report a run that has ended");
418
- }
419
- for (let index = 1;index < activeRuns.length; index += 1) {
420
- const previous = activeRuns[index - 1];
421
- const current = activeRuns[index];
422
- if (!previous || !current)
423
- continue;
424
- const ordered = previous.createdAt === current.createdAt ? previous.id.localeCompare(current.id) < 0 : previous.createdAt < current.createdAt;
425
- if (!ordered) {
426
- throw new Error("listActiveRuns must order by createdAt and then by id");
427
- }
428
- }
429
- if ((await store.listActiveRuns(absentConversationId)).length !== 0) {
430
- throw new Error("listActiveRuns must be empty for an unknown conversation");
431
- }
432
- const recoverable = await store.scanRecoverable({ limit: 10 });
433
- if (!recoverable.items.some((item) => item.run.id === running.id)) {
434
- throw new Error("A running run must appear in a recoverable scan");
435
- }
436
- const operation = await store.recordRunOperation({
437
- conversationId,
438
- runId: running.id,
439
- expectedRevision: checkpointedRun.revision,
440
- ownerId: "conformance-owner",
441
- fencingToken: checkpointedRun.fencingToken,
442
- operation: {
443
- operationId: "model-call-1:0",
444
- kind: "model-request",
445
- phase: "first-output",
446
- step: 0,
447
- startedAt: "2026-08-22T00:00:01.800Z",
448
- firstOutputAt: "2026-08-22T00:00:01.900Z"
449
- }
450
- });
451
- requireOutcome(operation, "applied");
452
- const operatedRun = operation.snapshot.runs.find((run) => run.id === running.id);
453
- if (operatedRun?.lastOperation?.operationId !== "model-call-1:0") {
454
- throw new Error("Run operation identity did not survive its durable mutation");
455
- }
456
- const operatedView = await store.loadRun({ conversationId, runId: running.id });
457
- if (operatedView?.run.lastOperation?.startedAt !== "2026-08-22T00:00:01.800Z") {
458
- throw new Error("loadRun did not retain the original operation timestamp");
459
- }
460
- const interrupted = await store.requestRunInterrupt({
461
- conversationId,
462
- runId: running.id,
463
- expectedRevision: operatedRun.revision
464
- });
465
- requireOutcome(interrupted, "applied");
466
- const interruptedRun = interrupted.snapshot.runs.find((run) => run.id === running.id);
467
- if (interruptedRun?.state !== "interrupt_requested") {
468
- throw new Error("A durable interrupt must move the run to interrupt_requested");
469
- }
470
- if (interruptedRun.usage?.cost?.value !== 0.25) {
471
- throw new Error("An interrupt must not discard the figure the run had already spent");
472
- }
473
- const terminalUsage = {
474
- inputTokens: { value: 3000, provenance: "computed" },
475
- outputTokens: { value: 300, provenance: "computed" },
476
- reasoningTokens: { value: 30, provenance: "computed" },
477
- cacheReadTokens: { value: 200, provenance: "computed" },
478
- cacheWriteTokens: { value: 100, provenance: "computed" },
479
- cost: { value: 1.5, currency: "USD", provenance: "computed" }
480
- };
481
- const terminalResults = await Promise.all([
482
- store.commitRunTerminal({
483
- conversationId,
484
- runId: running.id,
485
- expectedRevision: interruptedRun.revision,
486
- ownerId: "conformance-owner",
487
- assistant: terminalAssistant,
488
- reason: "success",
489
- usage: terminalUsage
490
- }),
491
- store.commitRunTerminal({
492
- conversationId,
493
- runId: running.id,
494
- expectedRevision: interruptedRun.revision,
495
- ownerId: "conformance-owner",
496
- assistant: terminalAssistant,
497
- reason: "success",
498
- usage: terminalUsage
499
- })
500
- ]);
501
- const terminalOutcomes = terminalResults.map((result) => result.outcome).sort();
502
- if (terminalOutcomes.join(",") !== "applied,conflict") {
503
- throw new Error(`Terminal race was not linearized: ${terminalOutcomes.join(",")}`);
504
- }
505
- const terminalApplied = terminalResults.find((result) => result.outcome === "applied");
506
- if (terminalApplied?.outcome !== "applied") {
507
- throw new Error("Terminal race produced no applied result");
508
- }
509
- const settledRun = terminalApplied.snapshot.runs.find((run) => run.id === running.id);
510
- if (JSON.stringify(settledRun?.usage) !== JSON.stringify(terminalUsage)) {
511
- throw new Error("Terminal commit did not persist the run usage it was given");
512
- }
513
- const terminalView = await store.loadRun({ conversationId, runId: running.id });
514
- if (terminalView?.run.terminalReason !== "success") {
515
- throw new Error("loadRun must report the terminal reason a settled run ended with");
516
- }
517
- if (JSON.stringify(terminalView.run.usage) !== JSON.stringify(terminalUsage)) {
518
- throw new Error("loadRun must return every persisted terminal usage field");
519
- }
520
- if (JSON.stringify(terminalView.assistant) !== JSON.stringify(terminalAssistant)) {
521
- throw new Error("loadRun must retain the answer a settled run produced");
522
- }
523
- if ((await store.listActiveRuns(conversationId)).some((run) => run.id === running.id)) {
524
- throw new Error("listActiveRuns must drop a run once it has ended");
525
- }
526
- const compactedTerminal = await store.replaceCompactedRange({
527
- conversationId,
528
- expectedVersion: terminalApplied.snapshot.version,
529
- replacedMessageIds: ["summary-1", terminalAssistant.id],
530
- summary: AgentMessageSchema.parse({
531
- schemaVersion: 1,
532
- id: "summary-2",
533
- conversationId,
534
- role: "summary",
535
- status: "committed",
536
- parts: [{ type: "text", text: "terminal history" }],
537
- createdAt: "2026-08-22T00:00:03.000Z",
538
- updatedAt: "2026-08-22T00:00:03.000Z"
539
- })
540
- });
541
- requireOutcome(compactedTerminal, "applied");
542
- const duplicateTerminal = await store.acceptInputAndAssignRun({
543
- idempotencyKey: "request-1",
544
- input: userMessage(conversationId, "discarded-terminal-input"),
545
- run: queuedRun(conversationId, "discarded-terminal-input", "discarded-terminal-run")
546
- });
547
- requireOutcome(duplicateTerminal, "duplicate");
548
- if (duplicateTerminal.run.terminalReason !== "success" || JSON.stringify(duplicateTerminal.assistant) !== JSON.stringify(terminalAssistant)) {
549
- throw new Error("Compaction discarded the canonical duplicate terminal result");
550
- }
551
- const recoveryInput = userMessage(recoveryConversationId, "recovery-input");
552
- const recoveryRun = queuedRun(recoveryConversationId, recoveryInput.id, "recovery-run");
553
- const recoveryAccepted = await store.acceptInputAndAssignRun({
554
- idempotencyKey: "recovery-request",
555
- input: recoveryInput,
556
- run: recoveryRun
557
- });
558
- requireOutcome(recoveryAccepted, "applied");
559
- const recoveryAssigned = recoveryAccepted.snapshot.runs.find((run) => run.id === recoveryRun.id);
560
- if (!recoveryAssigned)
561
- throw new Error("Recovery run disappeared after admission");
562
- const recoveryAcquired = await store.acquireRun({
563
- conversationId: recoveryConversationId,
564
- runId: recoveryAssigned.id,
565
- expectedRevision: recoveryAssigned.revision,
566
- ownerId: "abandoned-owner"
567
- });
568
- requireOutcome(recoveryAcquired, "applied");
569
- const abandonedRun = recoveryAcquired.snapshot.runs.find((run) => run.id === recoveryRun.id);
570
- if (!abandonedRun)
571
- throw new Error("Recovery run disappeared after acquisition");
572
- const abandoned = await store.recoverRun({
573
- conversationId: recoveryConversationId,
574
- runId: abandonedRun.id,
575
- expectedRevision: abandonedRun.revision,
576
- action: "abandon"
577
- });
578
- requireOutcome(abandoned, "applied");
579
- const terminalRun = abandoned.snapshot.runs.find((run) => run.id === abandonedRun.id);
580
- const terminalMessage = abandoned.snapshot.messages.find((message) => message.id === abandonedRun.assistantMessageId);
581
- if (terminalRun?.state !== "abandoned" || terminalMessage?.status !== "failed") {
582
- throw new Error("Abandon recovery did not atomically terminalize its assistant record");
583
- }
584
- const abandonedView = await store.loadRun({
585
- conversationId: recoveryConversationId,
586
- runId: abandonedRun.id
587
- });
588
- if (abandonedView?.run.state !== "abandoned" || abandonedView.run.terminalReason !== "abandoned" || abandonedView.assistant?.status !== "failed") {
589
- throw new Error("The canonical run record disagrees with its abandoned index projection");
590
- }
591
- const afterAbandon = await store.scanRecoverable({ limit: 100 });
592
- if (afterAbandon.items.some((item) => item.run.id === abandonedRun.id)) {
593
- throw new Error("The recoverable index still exposes a canonically abandoned run");
594
- }
595
- await assertCausalHistoryOrder(store, causalHistoryConversationId);
596
- await assertActiveRunCausalOrder(store, causalActiveConversationId);
597
- await assertInterruptPriorityOrder(store, interruptPriorityConversationId);
598
- await assertAbsorptionIsAtomic(store, absorbConversationId);
599
- }
600
- async function assertInterruptPriorityOrder(store, conversationId) {
601
- const inputs = ["priority-a", "priority-b", "priority-c"].map((id) => userMessage(conversationId, id));
602
- const [inputA, inputB, inputC] = inputs;
603
- if (!inputA || !inputB || !inputC)
604
- throw new Error("Priority fixture is incomplete");
605
- const runA = queuedRun(conversationId, inputA.id, "priority-run-a");
606
- const runB = queuedRun(conversationId, inputB.id, "priority-run-b");
607
- const runC = AgentRunSchema.parse({
608
- ...queuedRun(conversationId, inputC.id, "priority-run-c"),
609
- queuePriority: "interrupt-next"
610
- });
611
- requireOutcome(await store.acceptInputAndAssignRun({ idempotencyKey: runA.id, input: inputA, run: runA }), "applied");
612
- const acquiredA = await store.acquireRun({
613
- conversationId,
614
- runId: runA.id,
615
- expectedRevision: runA.revision,
616
- ownerId: "priority-owner-a"
617
- });
618
- requireOutcome(acquiredA, "applied");
619
- const runningA = acquiredA.snapshot.runs.find((run) => run.id === runA.id);
620
- if (!runningA)
621
- throw new Error("Priority lead run disappeared after acquisition");
622
- requireOutcome(await store.acceptInputAndAssignRun({ idempotencyKey: runB.id, input: inputB, run: runB }), "applied");
623
- requireOutcome(await store.acceptInputAndAssignRun({ idempotencyKey: runC.id, input: inputC, run: runC }), "applied");
624
- const active = await store.listActiveRuns(conversationId);
625
- if (active.map((run) => run.id).join(",") !== `${runA.id},${runC.id},${runB.id}`) {
626
- throw new Error("Active runs did not place urgent work before ordinary pending work");
627
- }
628
- requireOutcome(await store.acquireRun({
629
- conversationId,
630
- runId: runB.id,
631
- expectedRevision: runB.revision,
632
- ownerId: "priority-owner-b"
633
- }), "conflict");
634
- const abandonedA = await store.recoverRun({
635
- conversationId,
636
- runId: runA.id,
637
- expectedRevision: runningA.revision,
638
- action: "abandon"
639
- });
640
- requireOutcome(abandonedA, "applied");
641
- const queuedC = abandonedA.snapshot.runs.find((run) => run.id === runC.id);
642
- if (!queuedC)
643
- throw new Error("Urgent run disappeared after predecessor settlement");
644
- const acquiredC = await store.acquireRun({
645
- conversationId,
646
- runId: runC.id,
647
- expectedRevision: queuedC.revision,
648
- ownerId: "priority-owner-c"
649
- });
650
- requireOutcome(acquiredC, "applied");
651
- const runningC = acquiredC.snapshot.runs.find((run) => run.id === runC.id);
652
- if (!runningC)
653
- throw new Error("Urgent run disappeared after acquisition");
654
- requireOutcome(await store.acquireRun({
655
- conversationId,
656
- runId: runB.id,
657
- expectedRevision: runB.revision,
658
- ownerId: "priority-owner-b"
659
- }), "conflict");
660
- const abandonedC = await store.recoverRun({
661
- conversationId,
662
- runId: runC.id,
663
- expectedRevision: runningC.revision,
664
- action: "abandon"
665
- });
666
- requireOutcome(abandonedC, "applied");
667
- const queuedB = abandonedC.snapshot.runs.find((run) => run.id === runB.id);
668
- if (!queuedB)
669
- throw new Error("Ordinary run disappeared after urgent settlement");
670
- const acquiredB = await store.acquireRun({
671
- conversationId,
672
- runId: runB.id,
673
- expectedRevision: queuedB.revision,
674
- ownerId: "priority-owner-b"
675
- });
676
- requireOutcome(acquiredB, "applied");
677
- const ordered = acquiredB.snapshot.runs.map((run) => run.id).join(",");
678
- if (ordered !== `${runA.id},${runC.id},${runB.id}`) {
679
- throw new Error(`Durable execution order was not preserved: ${ordered}`);
680
- }
681
- const [sequenceA, sequenceC, sequenceB] = acquiredB.snapshot.runs.map((run) => run.executionSequence);
682
- if (sequenceA === undefined || sequenceC === undefined || sequenceB === undefined || !(sequenceA < sequenceC && sequenceC < sequenceB)) {
683
- throw new Error("Acquisition did not persist increasing execution sequence values");
684
- }
685
- }
686
- async function assertActiveRunCausalOrder(store, conversationId) {
687
- for (const id of ["z-causal-run", "a-causal-run"]) {
688
- const input = userMessage(conversationId, `${id}-input`);
689
- requireOutcome(await store.acceptInputAndAssignRun({
690
- idempotencyKey: id,
691
- input,
692
- run: queuedRun(conversationId, input.id, id)
693
- }), "applied");
694
- }
695
- const active = await store.listActiveRuns(conversationId);
696
- if (active.map((run) => run.id).join(",") !== "z-causal-run,a-causal-run") {
697
- throw new Error("listActiveRuns must preserve causal history order for timestamp ties");
698
- }
699
- }
700
- async function assertCausalHistoryOrder(store, conversationId) {
701
- const leadInput = userMessage(conversationId, "causal-input-1");
702
- const leadRun = queuedRun(conversationId, leadInput.id, "causal-run-1");
703
- requireOutcome(await store.acceptInputAndAssignRun({
704
- idempotencyKey: "causal-request-1",
705
- input: leadInput,
706
- run: leadRun
707
- }), "applied");
708
- const acquired = await store.acquireRun({
709
- conversationId,
710
- runId: leadRun.id,
711
- expectedRevision: leadRun.revision,
712
- ownerId: "causal-owner"
713
- });
714
- requireOutcome(acquired, "applied");
715
- const running = acquired.snapshot.runs.find((run) => run.id === leadRun.id);
716
- if (!running)
717
- throw new Error("Causal-order run disappeared after acquisition");
718
- const successorInput = userMessage(conversationId, "causal-input-2");
719
- const successorRun = queuedRun(conversationId, successorInput.id, "causal-run-2");
720
- requireOutcome(await store.acceptInputAndAssignRun({
721
- idempotencyKey: "causal-request-2",
722
- input: successorInput,
723
- run: successorRun
724
- }), "applied");
725
- const assistant = AgentMessageSchema.parse({
726
- schemaVersion: 1,
727
- id: running.assistantMessageId,
728
- conversationId,
729
- runId: running.id,
730
- role: "assistant",
731
- status: "streaming",
732
- parts: [{ type: "text", text: "causal answer" }],
733
- createdAt: "2026-08-28T00:00:00.000Z",
734
- updatedAt: "2026-08-28T00:00:01.000Z"
735
- });
736
- const checkpoint = await store.checkpointRunAssistant({
737
- conversationId,
738
- runId: running.id,
739
- expectedRevision: running.revision,
740
- ownerId: "causal-owner",
741
- ...running.fencingToken !== undefined && { fencingToken: running.fencingToken },
742
- assistant
743
- });
744
- requireOutcome(checkpoint, "applied");
745
- const order = checkpoint.snapshot.messages.map((message) => message.id).join(",");
746
- if (order !== `${leadInput.id},${assistant.id},${successorInput.id}`) {
747
- throw new Error(`Agent history is not in causal run order: ${order}`);
748
- }
749
- }
750
- async function assertAbsorptionIsAtomic(store, conversationId) {
751
- const leadInput = userMessage(conversationId, "absorb-input-1");
752
- const leadRun = queuedRun(conversationId, leadInput.id, "absorb-run-1");
753
- const lead = await store.acceptInputAndAssignRun({
754
- idempotencyKey: "absorb-request-1",
755
- input: leadInput,
756
- run: leadRun
757
- });
758
- requireOutcome(lead, "applied");
759
- const successorInput = userMessage(conversationId, "absorb-input-2");
760
- const successorRun = queuedRun(conversationId, successorInput.id, "absorb-run-2");
761
- const successor = await store.acceptInputAndAssignRun({
762
- idempotencyKey: "absorb-request-2",
763
- input: successorInput,
764
- run: successorRun
765
- });
766
- requireOutcome(successor, "applied");
767
- const acquired = await store.acquireRun({
768
- conversationId,
769
- runId: leadRun.id,
770
- expectedRevision: 0,
771
- ownerId: "absorb-owner"
772
- });
773
- requireOutcome(acquired, "applied");
774
- const running = acquired.snapshot.runs.find((run) => run.id === leadRun.id);
775
- if (!running)
776
- throw new Error("Absorbing run disappeared after acquisition");
777
- const answer = AgentMessageSchema.parse({
778
- schemaVersion: 1,
779
- id: running.assistantMessageId,
780
- conversationId,
781
- runId: running.id,
782
- role: "assistant",
783
- status: "completed",
784
- parts: [{ type: "text", text: "answered both" }],
785
- createdAt: "2026-08-26T00:00:00.000Z",
786
- updatedAt: "2026-08-26T00:00:02.000Z"
787
- });
788
- await store.commitRunTerminal({
789
- conversationId,
790
- runId: running.id,
791
- expectedRevision: running.revision,
792
- ownerId: "absorb-owner",
793
- assistant: AgentMessageSchema.parse({ ...answer, status: "interrupted" }),
794
- reason: "interrupted",
795
- absorb: [{ runId: successorRun.id, inputMessageIds: [successorInput.id] }]
796
- }).then(() => {
797
- throw new Error("A non-completing run absorbed a queued successor");
798
- }, (error) => {
799
- if (!(error instanceof TypeError))
800
- throw error;
801
- });
802
- const committed = await store.commitRunTerminal({
803
- conversationId,
804
- runId: running.id,
805
- expectedRevision: running.revision,
806
- ownerId: "absorb-owner",
807
- assistant: answer,
808
- reason: "success",
809
- absorb: [{ runId: successorRun.id, inputMessageIds: [successorInput.id] }]
810
- });
811
- requireOutcome(committed, "applied");
812
- const absorbingView = await store.loadRun({ conversationId, runId: leadRun.id });
813
- if (absorbingView?.run.inputMessageIds.join(",") !== "absorb-input-1,absorb-input-2") {
814
- throw new Error("An absorbing run must record the inputs it answered");
815
- }
816
- const absorbedView = await store.loadRun({ conversationId, runId: successorRun.id });
817
- if (absorbedView?.run.terminalReason !== "absorbed") {
818
- throw new Error("An absorbed successor must be terminal in the same transaction");
819
- }
820
- if (absorbedView.run.absorbedIntoRunId !== leadRun.id) {
821
- throw new Error("An absorbed run must name the run that answered its input");
822
- }
823
- if (absorbedView.assistant !== undefined) {
824
- throw new Error("An absorbed run produced no answer and must retain none");
825
- }
826
- if ((await store.listActiveRuns(conversationId)).length !== 0) {
827
- throw new Error("An absorbed successor must leave the active listing");
828
- }
829
- const retried = await store.acceptInputAndAssignRun({
830
- idempotencyKey: "absorb-request-2",
831
- input: userMessage(conversationId, "absorb-discarded"),
832
- run: queuedRun(conversationId, "absorb-discarded", "absorb-discarded-run")
833
- });
834
- requireOutcome(retried, "duplicate");
835
- if (retried.runId !== leadRun.id || retried.assistant?.id !== answer.id) {
836
- throw new Error("A retried absorbed key must resolve to the run that answered it");
837
- }
838
- if (retried.inputMessageId !== successorInput.id) {
839
- throw new Error("A retried absorbed key must still name its own input");
840
- }
841
- }
842
- async function ledgerScenario(store, conversationId) {
843
- const first = await store.appendEvent({
844
- conversationId,
845
- kind: "state/set",
846
- payload: { n: 1 }
847
- });
848
- if (first.seq !== 1)
849
- throw new Error(`Agent store conformance expected seq 1, received ${first.seq}`);
850
- const appended = await Promise.all(Array.from({ length: 20 }, (_, index) => store.appendEvent({ conversationId, kind: "state/set", payload: { n: index + 2 } })));
851
- const seqs = [first.seq, ...appended.map((event) => event.seq)].sort((a, b) => a - b);
852
- for (let index = 0;index < seqs.length; index += 1) {
853
- if (seqs[index] !== index + 1) {
854
- throw new Error(`Agent store conformance expected contiguous seq, received ${seqs.join(",")}`);
855
- }
856
- }
857
- const page = await store.readEvents({ conversationId, fromSeq: 5, toSeq: 9, limit: 3 });
858
- if (page.items.map((event) => event.seq).join(",") !== "5,6,7" || page.nextSeq !== 8) {
859
- throw new Error(`Agent store conformance expected events 5,6,7 then 8, received ${page.items.map((event) => event.seq).join(",")} then ${page.nextSeq}`);
860
- }
861
- const ignorable = await store.appendEvent({
862
- conversationId,
863
- kind: "state/set",
864
- payload: { n: "ignorable" },
865
- ignorable: true
866
- });
867
- if (ignorable.ignorable !== true) {
868
- throw new Error("Agent store conformance expected the ignorable flag to persist");
869
- }
870
- const archive = await store.exportConversation(conversationId);
871
- const again = await store.exportConversation(conversationId);
872
- if (Buffer.compare(Buffer.from(archive), Buffer.from(again)) !== 0) {
873
- throw new Error("Agent store conformance expected two exports of a quiet store to be byte-equal");
874
- }
875
- const decoded = decodeAgentConversationArchive(archive);
876
- if (decoded.events.length !== 22) {
877
- throw new Error(`Agent store conformance expected 22 archived events, received ${decoded.events.length}`);
878
- }
70
+ function createHandlerTestClient(config) {
71
+ return createClient(config.contract, createTestClientConfig(config), config.contractConfig);
879
72
  }
880
- async function archiveScenario(store, conversationId) {
881
- const origin = createMemoryAgentRuntimeStore();
882
- const inputMessage = userMessage(conversationId, "archived-input");
883
- const run = queuedRun(conversationId, inputMessage.id, "archived-run");
884
- requireOutcome(await origin.acceptInputAndAssignRun({
885
- idempotencyKey: "archived-request",
886
- input: inputMessage,
887
- run
888
- }), "applied");
889
- await origin.appendEvent({
890
- conversationId,
891
- kind: "state/set",
892
- payload: { name: "topic", value: "archive" }
893
- });
894
- const imported = await store.importConversation(await origin.exportConversation(conversationId));
895
- if (imported.conversationId !== conversationId || imported.events !== 2) {
896
- throw new Error(`Agent store conformance expected 2 imported events for ${conversationId}, received ${imported.events} for ${imported.conversationId}`);
897
- }
898
- const restored = await store.loadSnapshot(conversationId);
899
- const expected = await origin.loadSnapshot(conversationId);
900
- if (restored.version !== expected.version || restored.messages.map((message) => message.id).join(",") !== expected.messages.map((message) => message.id).join(",") || restored.runs.map((entry) => `${entry.id}:${entry.state}`).join(",") !== expected.runs.map((entry) => `${entry.id}:${entry.state}`).join(",")) {
901
- throw new Error(`Agent store conformance expected the imported snapshot to match its archive, received version ${restored.version} with ${restored.messages.length} messages and ${restored.runs.length} runs`);
902
- }
903
- const events = await store.readEvents({ conversationId, limit: 10 });
904
- if (events.items.map((event) => event.kind).join(",") !== "runtime/transition,state/set") {
905
- throw new Error(`Agent store conformance expected the imported ledger to keep its kinds, received ${events.items.map((event) => event.kind).join(",")}`);
906
- }
73
+ function createHandlerTestClients(config) {
74
+ return createClients(config.contracts, createTestClientConfig(config), config.contractConfig);
907
75
  }
908
76
  // src/testing/managed-resource-conformance-contract.ts
909
77
  import { z } from "zod";
@@ -1489,7 +657,7 @@ import { createHash } from "node:crypto";
1489
657
  import { z as z2 } from "zod";
1490
658
  var SURFACE_MANIFEST_VERSION = 3;
1491
659
  var HttpMethodSchema = z2.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"]);
1492
- var ToolTransportSchema = z2.enum(["MCP", "AGENT", "CLI"]);
660
+ var ToolTransportSchema = z2.enum(TOOL_TRANSPORTS);
1493
661
  var SurfaceTransportSchema = z2.enum(["HTTP", "MCP", "AGENT", "CLI", "REALTIME"]);
1494
662
  var SurfaceSchemaDigestsSchema = z2.object({
1495
663
  params: z2.string().nullable(),
@@ -1503,6 +671,11 @@ var SurfaceManifestOperationMcpSchema = z2.object({
1503
671
  z2.literal("resolved-per-call")
1504
672
  ])
1505
673
  }).nullable();
674
+ var SurfaceManifestOperationToolViewSchema = z2.object({
675
+ defaults: z2.string().nullable(),
676
+ output: z2.string().nullable(),
677
+ project: z2.boolean()
678
+ });
1506
679
  var SurfaceManifestOperationSchema = z2.object({
1507
680
  kind: z2.enum(["contract", "runtime"]),
1508
681
  service: z2.string(),
@@ -1512,6 +685,7 @@ var SurfaceManifestOperationSchema = z2.object({
1512
685
  description: z2.string(),
1513
686
  schemas: SurfaceSchemaDigestsSchema,
1514
687
  mcp: SurfaceManifestOperationMcpSchema,
688
+ toolView: SurfaceManifestOperationToolViewSchema.optional(),
1515
689
  http: z2.array(z2.object({ method: HttpMethodSchema, path: z2.string() }))
1516
690
  });
1517
691
  var SurfaceManifestToolSchema = z2.object({
@@ -1564,12 +738,12 @@ function digestValue(value) {
1564
738
  function canonicalSchemaValue(value, parentKey) {
1565
739
  if (Array.isArray(value)) {
1566
740
  const entries = value.map((entry) => canonicalSchemaValue(entry));
1567
- return parentKey === "required" && entries.every((entry) => typeof entry === "string") ? entries.sort((left, right) => compareCodepoints(String(left), String(right))) : entries;
741
+ return parentKey === "required" && entries.every((entry) => typeof entry === "string") ? entries.sort((left, right) => compareCodeUnits(String(left), String(right))) : entries;
1568
742
  }
1569
743
  if (!isRecord(value))
1570
744
  return value;
1571
745
  const result = {};
1572
- for (const key of Object.keys(value).sort(compareCodepoints)) {
746
+ for (const key of Object.keys(value).sort(compareCodeUnits)) {
1573
747
  result[key] = canonicalSchemaValue(value[key], key);
1574
748
  }
1575
749
  return result;
@@ -1603,9 +777,24 @@ function operationFrom(kind, source) {
1603
777
  multipart: multipartDigest(source.multipart)
1604
778
  },
1605
779
  mcp: mcpRoundsOf(source),
780
+ ...toolViewEntry(source),
1606
781
  http: []
1607
782
  };
1608
783
  }
784
+ function toolViewOf(source) {
785
+ const view = source.toolView;
786
+ if (!view)
787
+ return null;
788
+ return {
789
+ defaults: view.defaults === undefined || Object.keys(view.defaults).length === 0 ? null : digestValue(view.defaults),
790
+ output: schemaDigest(view.output, "output"),
791
+ project: view.project !== undefined
792
+ };
793
+ }
794
+ function toolViewEntry(source) {
795
+ const toolView = toolViewOf(source);
796
+ return toolView ? { toolView } : {};
797
+ }
1609
798
  function mcpRoundsOf(source) {
1610
799
  if (!source.mcp)
1611
800
  return null;
@@ -1627,11 +816,12 @@ function operationFingerprint(source) {
1627
816
  desc: source.desc,
1628
817
  scope: source.scope ?? null,
1629
818
  path: source.path ?? null,
1630
- expose: source.expose ? [...source.expose].sort(compareCodepoints) : null,
819
+ expose: source.expose ? [...source.expose].sort(compareCodeUnits) : null,
1631
820
  toolName: source.toolName ?? null,
1632
821
  annotations: source.annotations ?? null,
1633
822
  ui: source.ui ?? null,
1634
823
  mcp,
824
+ toolView: toolViewOf(source),
1635
825
  rawBody: source.rawBody ?? false,
1636
826
  safelistedBody: source.safelistedBody ?? false,
1637
827
  rawResponse: source.rawResponse ?? false,
@@ -1649,7 +839,7 @@ function operationFingerprint(source) {
1649
839
  });
1650
840
  }
1651
841
  function sortTools(tools) {
1652
- return tools.sort((left, right) => compareCodepoints(left.name, right.name) || compareCodepoints(left.service, right.service) || compareCodepoints(left.action, right.action) || compareCodepoints(left.kind, right.kind));
842
+ return tools.sort((left, right) => compareCodeUnits(left.name, right.name) || compareCodeUnits(left.service, right.service) || compareCodeUnits(left.action, right.action) || compareCodeUnits(left.kind, right.kind));
1653
843
  }
1654
844
  function buildSurfaceManifest(config) {
1655
845
  const operations = new Map;
@@ -1748,7 +938,7 @@ function buildSurfaceManifest(config) {
1748
938
  if (explicitMcp)
1749
939
  addToolProjection("MCP", null, explicitMcp);
1750
940
  if (namedMcp) {
1751
- for (const name of Object.keys(namedMcp).sort(compareCodepoints)) {
941
+ for (const name of Object.keys(namedMcp).sort(compareCodeUnits)) {
1752
942
  const projection = namedMcp[name];
1753
943
  if (projection)
1754
944
  addToolProjection("MCP", name, projection);
@@ -1760,14 +950,14 @@ function buildSurfaceManifest(config) {
1760
950
  addToolProjection("AGENT", null, agent ?? shared, agent ?? {});
1761
951
  addToolProjection("CLI", null, config.toolSurfaces?.CLI ?? shared);
1762
952
  const realtime = [];
1763
- const realtimeContracts = Object.keys(config.realtime ?? {}).sort(compareCodepoints);
953
+ const realtimeContracts = Object.keys(config.realtime ?? {}).sort(compareCodeUnits);
1764
954
  for (const contractName of realtimeContracts) {
1765
955
  const contract = config.realtime?.[contractName];
1766
956
  if (!contract)
1767
957
  continue;
1768
958
  for (const direction of ["serverToClient", "clientToServer"]) {
1769
959
  const registry = contract[direction];
1770
- for (const event of Object.keys(registry).sort(compareCodepoints)) {
960
+ for (const event of Object.keys(registry).sort(compareCodeUnits)) {
1771
961
  const definition = registry[event];
1772
962
  if (!definition)
1773
963
  continue;
@@ -1798,19 +988,19 @@ function buildSurfaceManifest(config) {
1798
988
  description: command.description,
1799
989
  input: schemaDigest(command.input, "input") ?? digestValue({}),
1800
990
  output: schemaDigest(command.output, "output")
1801
- })).sort((left, right) => compareCodepoints(left.name, right.name));
991
+ })).sort((left, right) => compareCodeUnits(left.name, right.name));
1802
992
  for (const operation of operations.values()) {
1803
- operation.http.sort((left, right) => compareCodepoints(left.path, right.path) || compareCodepoints(left.method, right.method));
993
+ operation.http.sort((left, right) => compareCodeUnits(left.path, right.path) || compareCodeUnits(left.method, right.method));
1804
994
  }
1805
995
  return SurfaceManifestSchema.parse({
1806
996
  manifestVersion: SURFACE_MANIFEST_VERSION,
1807
997
  digestVersion: 1,
1808
- operations: [...operations.values()].sort((left, right) => compareCodepoints(left.service, right.service) || compareCodepoints(left.action, right.action) || compareCodepoints(left.kind, right.kind)),
1809
- toolSurfaces: toolSurfaces.sort((left, right) => compareCodepoints(left.transport, right.transport) || compareCodepoints(left.surface ?? "", right.surface ?? "")),
998
+ operations: [...operations.values()].sort((left, right) => compareCodeUnits(left.service, right.service) || compareCodeUnits(left.action, right.action) || compareCodeUnits(left.kind, right.kind)),
999
+ toolSurfaces: toolSurfaces.sort((left, right) => compareCodeUnits(left.transport, right.transport) || compareCodeUnits(left.surface ?? "", right.surface ?? "")),
1810
1000
  realtimeContracts,
1811
1001
  realtime,
1812
1002
  cliOnly,
1813
- extensions: [...config.extensions ?? []].sort((left, right) => compareCodepoints(left.transport, right.transport) || compareCodepoints(left.name, right.name))
1003
+ extensions: [...config.extensions ?? []].sort((left, right) => compareCodeUnits(left.transport, right.transport) || compareCodeUnits(left.name, right.name))
1814
1004
  });
1815
1005
  }
1816
1006
  function assertSurfaceManifestSnapshot(manifest, snapshot) {
@@ -2023,7 +1213,7 @@ function assertSurfaceDiscovery(manifest, observed) {
2023
1213
  if (observed.openApi) {
2024
1214
  assertSameSet("HTTP/OpenAPI", manifest.operations.flatMap((operation) => operation.http.map((entry) => `${entry.method}:${entry.path.replace(/:([^/]+)/g, "{$1}")}`)), openApiOperations(observed.openApi));
2025
1215
  }
2026
- for (const transport of ["MCP", "AGENT", "CLI"]) {
1216
+ for (const transport of TOOL_TRANSPORTS) {
2027
1217
  const names = observed[transport];
2028
1218
  if (names) {
2029
1219
  assertSameSet(`${transport} discovery`, expectedToolNames(manifest, transport, null), names);
@@ -2146,44 +1336,14 @@ actual: ${serializeSurfaceValue(actual)}`);
2146
1336
  throw failure;
2147
1337
  }
2148
1338
  }
2149
-
2150
- // src/testing.ts
2151
- function resolveTestBaseUrl(origin, pathPrefix) {
2152
- const base = new URL(origin ?? "http://stitchkit.test");
2153
- if (base.pathname !== "/" || base.search || base.hash) {
2154
- throw new TypeError("Handler test client origin must contain only an absolute origin");
2155
- }
2156
- const prefix = pathPrefix?.replace(/^\/+|\/+$/g, "");
2157
- return prefix ? `${base.origin}/${prefix}` : base.origin;
2158
- }
2159
- function createHandlerFetch(handler, server) {
2160
- return async (input, init) => handler(new Request(input, init), server);
2161
- }
2162
- function createTestClientConfig(config) {
2163
- return {
2164
- ...config.client,
2165
- baseUrl: resolveTestBaseUrl(config.origin, config.pathPrefix),
2166
- fetch: createHandlerFetch(config.handler, config.server)
2167
- };
2168
- }
2169
- function createHandlerTestClient(config) {
2170
- return createClient(config.contract, createTestClientConfig(config), config.contractConfig);
2171
- }
2172
- function createHandlerTestClients(config) {
2173
- return createClients(config.contracts, createTestClientConfig(config), config.contractConfig);
2174
- }
2175
1339
  export {
2176
1340
  serializeSurfaceValue,
2177
1341
  runSurfaceProbes,
2178
1342
  runManagedResourceConformance,
2179
- runAgentStoreConformance,
2180
1343
  defineRealtimeProbe,
2181
1344
  createRealtimeProbeDriver,
2182
1345
  createHandlerTestClients,
2183
1346
  createHandlerTestClient,
2184
- createAgentRaceTrace,
2185
- createAgentRaceDriver,
2186
- createAgentRaceBarrier,
2187
1347
  buildSurfaceManifest,
2188
1348
  assertSurfaceManifestSnapshot,
2189
1349
  assertSurfaceDiscovery,
@@ -2194,6 +1354,7 @@ export {
2194
1354
  SurfaceManifestToolSchema,
2195
1355
  SurfaceManifestSchema,
2196
1356
  SurfaceManifestRealtimeEventSchema,
1357
+ SurfaceManifestOperationToolViewSchema,
2197
1358
  SurfaceManifestOperationSchema,
2198
1359
  SurfaceManifestOperationMcpSchema,
2199
1360
  SurfaceManifestExtensionSchema,