stitchkit 0.133.2 → 0.134.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 (616) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/README.md +14 -11
  3. package/dist/agent-executor/acp/v1-connect.d.ts +3 -0
  4. package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -1
  5. package/dist/agent-executor/acp/v1-map.d.ts +13 -3
  6. package/dist/agent-executor/acp/v1-map.d.ts.map +1 -1
  7. package/dist/agent-executor/acp/v1-protocol.d.ts +59 -0
  8. package/dist/agent-executor/acp/v1-protocol.d.ts.map +1 -1
  9. package/dist/agent-executor/codex/connect.d.ts +2 -0
  10. package/dist/agent-executor/codex/connect.d.ts.map +1 -1
  11. package/dist/agent-executor/codex/driver.d.ts +3 -0
  12. package/dist/agent-executor/codex/driver.d.ts.map +1 -1
  13. package/dist/agent-executor/contract.d.ts +42 -0
  14. package/dist/agent-executor/contract.d.ts.map +1 -1
  15. package/dist/agent-executor/engine-process.d.ts +20 -0
  16. package/dist/agent-executor/engine-process.d.ts.map +1 -1
  17. package/dist/agent-executor/executor-contract.d.ts +42 -0
  18. package/dist/agent-executor/executor-contract.d.ts.map +1 -1
  19. package/dist/agent-executor/handoff-schemas.d.ts +30 -0
  20. package/dist/agent-executor/handoff-schemas.d.ts.map +1 -1
  21. package/dist/agent-executor/projection.d.ts.map +1 -1
  22. package/dist/agent-executor/session-primitives.d.ts +4 -1
  23. package/dist/agent-executor/session-primitives.d.ts.map +1 -1
  24. package/dist/agent-executor/vocabulary.d.ts +100 -0
  25. package/dist/agent-executor/vocabulary.d.ts.map +1 -1
  26. package/dist/agent-parts/model.d.ts +1559 -0
  27. package/dist/agent-parts/model.d.ts.map +1 -0
  28. package/dist/agent-parts/parts.d.ts +21 -0
  29. package/dist/agent-parts/parts.d.ts.map +1 -1
  30. package/dist/agent-runtime/ai-sdk-convert.d.ts +15 -0
  31. package/dist/agent-runtime/ai-sdk-convert.d.ts.map +1 -0
  32. package/dist/agent-runtime/ai-sdk.d.ts +31 -0
  33. package/dist/agent-runtime/ai-sdk.d.ts.map +1 -0
  34. package/dist/agent-runtime/anthropic-media.d.ts +11 -0
  35. package/dist/agent-runtime/anthropic-media.d.ts.map +1 -0
  36. package/dist/agent-runtime/anthropic-messages.d.ts +24 -0
  37. package/dist/agent-runtime/anthropic-messages.d.ts.map +1 -0
  38. package/dist/agent-runtime/anthropic-options.d.ts +79 -0
  39. package/dist/agent-runtime/anthropic-options.d.ts.map +1 -0
  40. package/dist/agent-runtime/anthropic-response.d.ts +19 -0
  41. package/dist/agent-runtime/anthropic-response.d.ts.map +1 -0
  42. package/dist/agent-runtime/anthropic-sse.d.ts +4 -0
  43. package/dist/agent-runtime/anthropic-sse.d.ts.map +1 -0
  44. package/dist/agent-runtime/anthropic.d.ts +27 -0
  45. package/dist/agent-runtime/anthropic.d.ts.map +1 -0
  46. package/dist/agent-runtime/branch-observations.d.ts +25 -25
  47. package/dist/agent-runtime/branch-provider.d.ts +86 -0
  48. package/dist/agent-runtime/branch-provider.d.ts.map +1 -1
  49. package/dist/agent-runtime/branch-replay.d.ts +30 -0
  50. package/dist/agent-runtime/branch-replay.d.ts.map +1 -1
  51. package/dist/agent-runtime/browser-control-contract.d.ts +204 -0
  52. package/dist/agent-runtime/browser-control-contract.d.ts.map +1 -1
  53. package/dist/agent-runtime/browser-controller-view.d.ts +44 -0
  54. package/dist/agent-runtime/browser-controller-view.d.ts.map +1 -0
  55. package/dist/agent-runtime/browser-controller.d.ts +12 -8
  56. package/dist/agent-runtime/browser-controller.d.ts.map +1 -1
  57. package/dist/agent-runtime/child-budget-policy.d.ts +2 -3
  58. package/dist/agent-runtime/child-budget-policy.d.ts.map +1 -1
  59. package/dist/agent-runtime/compaction.d.ts +27 -10
  60. package/dist/agent-runtime/compaction.d.ts.map +1 -1
  61. package/dist/agent-runtime/control-interaction-schema.d.ts +157 -0
  62. package/dist/agent-runtime/control-interaction-schema.d.ts.map +1 -0
  63. package/dist/agent-runtime/control-schema.d.ts +183 -27
  64. package/dist/agent-runtime/control-schema.d.ts.map +1 -1
  65. package/dist/agent-runtime/control-view.d.ts +64 -0
  66. package/dist/agent-runtime/control-view.d.ts.map +1 -0
  67. package/dist/agent-runtime/conversations.d.ts +10 -0
  68. package/dist/agent-runtime/conversations.d.ts.map +1 -1
  69. package/dist/agent-runtime/deferred-tool-selection.d.ts +2 -2
  70. package/dist/agent-runtime/deferred-tool-selection.d.ts.map +1 -1
  71. package/dist/agent-runtime/deferred-tool-types.d.ts +2 -2
  72. package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
  73. package/dist/agent-runtime/deferred-tools-internal.d.ts +8 -11
  74. package/dist/agent-runtime/deferred-tools-internal.d.ts.map +1 -1
  75. package/dist/agent-runtime/deferred-tools.d.ts.map +1 -1
  76. package/dist/agent-runtime/event-schema.d.ts +80 -0
  77. package/dist/agent-runtime/event-schema.d.ts.map +1 -1
  78. package/dist/agent-runtime/harness-contract.d.ts +2 -2
  79. package/dist/agent-runtime/harness-contract.d.ts.map +1 -1
  80. package/dist/agent-runtime/harness-control.d.ts.map +1 -1
  81. package/dist/agent-runtime/harness-realtime.d.ts.map +1 -1
  82. package/dist/agent-runtime/harness.d.ts +2 -2
  83. package/dist/agent-runtime/harness.d.ts.map +1 -1
  84. package/dist/agent-runtime/history.d.ts +25 -16
  85. package/dist/agent-runtime/history.d.ts.map +1 -1
  86. package/dist/agent-runtime/invocation-attempt.d.ts +7 -3
  87. package/dist/agent-runtime/invocation-attempt.d.ts.map +1 -1
  88. package/dist/agent-runtime/invocation-payload.d.ts +13 -7
  89. package/dist/agent-runtime/invocation-payload.d.ts.map +1 -1
  90. package/dist/agent-runtime/invocation-stream.d.ts +20 -0
  91. package/dist/agent-runtime/invocation-stream.d.ts.map +1 -0
  92. package/dist/agent-runtime/invocations.d.ts +2 -2
  93. package/dist/agent-runtime/invocations.d.ts.map +1 -1
  94. package/dist/agent-runtime/models-driver-step.d.ts +212 -0
  95. package/dist/agent-runtime/models-driver-step.d.ts.map +1 -0
  96. package/dist/agent-runtime/models-driver-telemetry.d.ts +42 -0
  97. package/dist/agent-runtime/models-driver-telemetry.d.ts.map +1 -0
  98. package/dist/agent-runtime/models-driver.d.ts +235 -0
  99. package/dist/agent-runtime/models-driver.d.ts.map +1 -0
  100. package/dist/agent-runtime/models.d.ts +3 -26
  101. package/dist/agent-runtime/models.d.ts.map +1 -1
  102. package/dist/agent-runtime/observability.d.ts +64 -0
  103. package/dist/agent-runtime/observability.d.ts.map +1 -1
  104. package/dist/agent-runtime/openai-messages.d.ts +11 -0
  105. package/dist/agent-runtime/openai-messages.d.ts.map +1 -0
  106. package/dist/agent-runtime/openai-options.d.ts +91 -0
  107. package/dist/agent-runtime/openai-options.d.ts.map +1 -0
  108. package/dist/agent-runtime/openai-response.d.ts +77 -0
  109. package/dist/agent-runtime/openai-response.d.ts.map +1 -0
  110. package/dist/agent-runtime/openai-sse-state.d.ts +54 -0
  111. package/dist/agent-runtime/openai-sse-state.d.ts.map +1 -0
  112. package/dist/agent-runtime/openai-sse.d.ts +4 -0
  113. package/dist/agent-runtime/openai-sse.d.ts.map +1 -0
  114. package/dist/agent-runtime/openai.d.ts +31 -0
  115. package/dist/agent-runtime/openai.d.ts.map +1 -0
  116. package/dist/agent-runtime/openrouter-admission.d.ts +3 -0
  117. package/dist/agent-runtime/openrouter-admission.d.ts.map +1 -1
  118. package/dist/agent-runtime/openrouter-benchmarks.d.ts +17 -0
  119. package/dist/agent-runtime/openrouter-benchmarks.d.ts.map +1 -0
  120. package/dist/agent-runtime/openrouter-catalog-cache.d.ts +70 -0
  121. package/dist/agent-runtime/openrouter-catalog-cache.d.ts.map +1 -0
  122. package/dist/agent-runtime/openrouter-catalog-query.d.ts +57 -0
  123. package/dist/agent-runtime/openrouter-catalog-query.d.ts.map +1 -0
  124. package/dist/agent-runtime/openrouter-catalog.d.ts +189 -14
  125. package/dist/agent-runtime/openrouter-catalog.d.ts.map +1 -1
  126. package/dist/agent-runtime/openrouter-models.d.ts +168 -31
  127. package/dist/agent-runtime/openrouter-models.d.ts.map +1 -1
  128. package/dist/agent-runtime/openrouter-options.d.ts +45 -15
  129. package/dist/agent-runtime/openrouter-options.d.ts.map +1 -1
  130. package/dist/agent-runtime/openrouter-response.d.ts +22 -0
  131. package/dist/agent-runtime/openrouter-response.d.ts.map +1 -0
  132. package/dist/agent-runtime/openrouter.d.ts +21 -24
  133. package/dist/agent-runtime/openrouter.d.ts.map +1 -1
  134. package/dist/agent-runtime/owned-provider-stream.d.ts +4 -4
  135. package/dist/agent-runtime/owned-provider-stream.d.ts.map +1 -1
  136. package/dist/agent-runtime/prompt.d.ts +3 -3
  137. package/dist/agent-runtime/prompt.d.ts.map +1 -1
  138. package/dist/agent-runtime/protocol.d.ts +28 -3
  139. package/dist/agent-runtime/protocol.d.ts.map +1 -1
  140. package/dist/agent-runtime/provider-cache.d.ts +30 -0
  141. package/dist/agent-runtime/provider-cache.d.ts.map +1 -0
  142. package/dist/agent-runtime/provider-content.d.ts +147 -0
  143. package/dist/agent-runtime/provider-content.d.ts.map +1 -1
  144. package/dist/agent-runtime/provider-failure.d.ts +51 -26
  145. package/dist/agent-runtime/provider-failure.d.ts.map +1 -1
  146. package/dist/agent-runtime/provider-history.d.ts +13 -0
  147. package/dist/agent-runtime/provider-history.d.ts.map +1 -0
  148. package/dist/agent-runtime/provider-http.d.ts +68 -0
  149. package/dist/agent-runtime/provider-http.d.ts.map +1 -0
  150. package/dist/agent-runtime/provider-journal.d.ts +149 -0
  151. package/dist/agent-runtime/provider-journal.d.ts.map +1 -1
  152. package/dist/agent-runtime/provider-json-schema-strip.d.ts +8 -0
  153. package/dist/agent-runtime/provider-json-schema-strip.d.ts.map +1 -0
  154. package/dist/agent-runtime/provider-json-schema.d.ts +28 -0
  155. package/dist/agent-runtime/provider-json-schema.d.ts.map +1 -0
  156. package/dist/agent-runtime/provider-media.d.ts +49 -0
  157. package/dist/agent-runtime/provider-media.d.ts.map +1 -0
  158. package/dist/agent-runtime/provider-openai-chat-helpers.d.ts +27 -0
  159. package/dist/agent-runtime/provider-openai-chat-helpers.d.ts.map +1 -0
  160. package/dist/agent-runtime/provider-openai-chat-sse.d.ts +25 -0
  161. package/dist/agent-runtime/provider-openai-chat-sse.d.ts.map +1 -0
  162. package/dist/agent-runtime/provider-openai-chat.d.ts +27 -0
  163. package/dist/agent-runtime/provider-openai-chat.d.ts.map +1 -0
  164. package/dist/agent-runtime/provider-origin.d.ts +3 -12
  165. package/dist/agent-runtime/provider-origin.d.ts.map +1 -1
  166. package/dist/agent-runtime/provider-sse.d.ts +30 -0
  167. package/dist/agent-runtime/provider-sse.d.ts.map +1 -0
  168. package/dist/agent-runtime/provider-stream-parts.d.ts +5 -0
  169. package/dist/agent-runtime/provider-stream-parts.d.ts.map +1 -0
  170. package/dist/agent-runtime/provider-stream-segments.d.ts +63 -0
  171. package/dist/agent-runtime/provider-stream-segments.d.ts.map +1 -0
  172. package/dist/agent-runtime/provider-usage.d.ts +24 -0
  173. package/dist/agent-runtime/provider-usage.d.ts.map +1 -0
  174. package/dist/agent-runtime/retry-policy.d.ts +19 -3
  175. package/dist/agent-runtime/retry-policy.d.ts.map +1 -1
  176. package/dist/agent-runtime/run-acquisition.d.ts +4 -4
  177. package/dist/agent-runtime/run-acquisition.d.ts.map +1 -1
  178. package/dist/agent-runtime/run-approval.d.ts +82 -0
  179. package/dist/agent-runtime/run-approval.d.ts.map +1 -0
  180. package/dist/agent-runtime/run-complete-retry.d.ts +24 -0
  181. package/dist/agent-runtime/run-complete-retry.d.ts.map +1 -0
  182. package/dist/agent-runtime/run-complete-stream.d.ts +9 -0
  183. package/dist/agent-runtime/run-complete-stream.d.ts.map +1 -0
  184. package/dist/agent-runtime/run-complete-tools.d.ts +21 -0
  185. package/dist/agent-runtime/run-complete-tools.d.ts.map +1 -0
  186. package/dist/agent-runtime/run-complete-types.d.ts +168 -0
  187. package/dist/agent-runtime/run-complete-types.d.ts.map +1 -0
  188. package/dist/agent-runtime/run-complete.d.ts +25 -0
  189. package/dist/agent-runtime/run-complete.d.ts.map +1 -0
  190. package/dist/agent-runtime/run-driver-compose.d.ts +21 -0
  191. package/dist/agent-runtime/run-driver-compose.d.ts.map +1 -0
  192. package/dist/agent-runtime/run-execution-state.d.ts +23 -10
  193. package/dist/agent-runtime/run-execution-state.d.ts.map +1 -1
  194. package/dist/agent-runtime/run-execution.d.ts +2 -2
  195. package/dist/agent-runtime/run-execution.d.ts.map +1 -1
  196. package/dist/agent-runtime/run-failure.d.ts +2 -2
  197. package/dist/agent-runtime/run-failure.d.ts.map +1 -1
  198. package/dist/agent-runtime/run-history-parts.d.ts +14 -0
  199. package/dist/agent-runtime/run-history-parts.d.ts.map +1 -0
  200. package/dist/agent-runtime/run-loop-events.d.ts +126 -0
  201. package/dist/agent-runtime/run-loop-events.d.ts.map +1 -0
  202. package/dist/agent-runtime/run-model-attempts.d.ts +2 -2
  203. package/dist/agent-runtime/run-model-attempts.d.ts.map +1 -1
  204. package/dist/agent-runtime/run-model-messages.d.ts +9 -0
  205. package/dist/agent-runtime/run-model-messages.d.ts.map +1 -0
  206. package/dist/agent-runtime/run-model-step.d.ts +43 -0
  207. package/dist/agent-runtime/run-model-step.d.ts.map +1 -0
  208. package/dist/agent-runtime/run-model-stream.d.ts +27 -0
  209. package/dist/agent-runtime/run-model-stream.d.ts.map +1 -0
  210. package/dist/agent-runtime/run-operation-lifecycle.d.ts +8 -4
  211. package/dist/agent-runtime/run-operation-lifecycle.d.ts.map +1 -1
  212. package/dist/agent-runtime/run-prompt-history.d.ts +8 -13
  213. package/dist/agent-runtime/run-prompt-history.d.ts.map +1 -1
  214. package/dist/agent-runtime/run-provider-ledger.d.ts +7 -4
  215. package/dist/agent-runtime/run-provider-ledger.d.ts.map +1 -1
  216. package/dist/agent-runtime/run-step-barriers.d.ts +58 -16
  217. package/dist/agent-runtime/run-step-barriers.d.ts.map +1 -1
  218. package/dist/agent-runtime/run-step-helpers.d.ts +49 -0
  219. package/dist/agent-runtime/run-step-helpers.d.ts.map +1 -0
  220. package/dist/agent-runtime/run-step-prepare.d.ts +34 -0
  221. package/dist/agent-runtime/run-step-prepare.d.ts.map +1 -0
  222. package/dist/agent-runtime/run-step-spend.d.ts +85 -10
  223. package/dist/agent-runtime/run-step-spend.d.ts.map +1 -1
  224. package/dist/agent-runtime/run-stream-parts.d.ts +13 -9
  225. package/dist/agent-runtime/run-stream-parts.d.ts.map +1 -1
  226. package/dist/agent-runtime/run-stream-recorded.d.ts +8 -0
  227. package/dist/agent-runtime/run-stream-recorded.d.ts.map +1 -0
  228. package/dist/agent-runtime/run-stream-step-text.d.ts +29 -0
  229. package/dist/agent-runtime/run-stream-step-text.d.ts.map +1 -0
  230. package/dist/agent-runtime/run-terminal.d.ts +3 -3
  231. package/dist/agent-runtime/run-terminal.d.ts.map +1 -1
  232. package/dist/agent-runtime/run-tool-approval-flow.d.ts +36 -0
  233. package/dist/agent-runtime/run-tool-approval-flow.d.ts.map +1 -0
  234. package/dist/agent-runtime/run-tool-approval-records.d.ts +24 -0
  235. package/dist/agent-runtime/run-tool-approval-records.d.ts.map +1 -0
  236. package/dist/agent-runtime/run-tool-call.d.ts +73 -0
  237. package/dist/agent-runtime/run-tool-call.d.ts.map +1 -0
  238. package/dist/agent-runtime/run-tool-errors.d.ts +29 -0
  239. package/dist/agent-runtime/run-tool-errors.d.ts.map +1 -0
  240. package/dist/agent-runtime/run-tool-executor.d.ts +34 -0
  241. package/dist/agent-runtime/run-tool-executor.d.ts.map +1 -0
  242. package/dist/agent-runtime/run-tool-progress.d.ts +2 -2
  243. package/dist/agent-runtime/run-tool-progress.d.ts.map +1 -1
  244. package/dist/agent-runtime/run-turn-preparation.d.ts +7 -6
  245. package/dist/agent-runtime/run-turn-preparation.d.ts.map +1 -1
  246. package/dist/agent-runtime/run-unacquired.d.ts +2 -2
  247. package/dist/agent-runtime/run-unacquired.d.ts.map +1 -1
  248. package/dist/agent-runtime/runtime-control.d.ts +4 -4
  249. package/dist/agent-runtime/runtime-control.d.ts.map +1 -1
  250. package/dist/agent-runtime/runtime-internals.d.ts +35 -44
  251. package/dist/agent-runtime/runtime-internals.d.ts.map +1 -1
  252. package/dist/agent-runtime/runtime-recovery.d.ts +3 -3
  253. package/dist/agent-runtime/runtime-recovery.d.ts.map +1 -1
  254. package/dist/agent-runtime/runtime-state.d.ts +3 -3
  255. package/dist/agent-runtime/runtime-state.d.ts.map +1 -1
  256. package/dist/agent-runtime/runtime-submit.d.ts +2 -2
  257. package/dist/agent-runtime/runtime-submit.d.ts.map +1 -1
  258. package/dist/agent-runtime/runtime.d.ts +51 -16
  259. package/dist/agent-runtime/runtime.d.ts.map +1 -1
  260. package/dist/agent-runtime/sandbox-process-linux.d.ts +8 -0
  261. package/dist/agent-runtime/sandbox-process-linux.d.ts.map +1 -0
  262. package/dist/agent-runtime/sandbox-process-macos.d.ts +21 -0
  263. package/dist/agent-runtime/sandbox-process-macos.d.ts.map +1 -0
  264. package/dist/agent-runtime/sandbox-process-spec.d.ts +114 -0
  265. package/dist/agent-runtime/sandbox-process-spec.d.ts.map +1 -0
  266. package/dist/agent-runtime/sandbox-process-wrapper.d.ts +19 -0
  267. package/dist/agent-runtime/sandbox-process-wrapper.d.ts.map +1 -0
  268. package/dist/agent-runtime/schemas-message.d.ts +10 -0
  269. package/dist/agent-runtime/schemas-message.d.ts.map +1 -1
  270. package/dist/agent-runtime/schemas-provider.d.ts +2 -0
  271. package/dist/agent-runtime/schemas-provider.d.ts.map +1 -1
  272. package/dist/agent-runtime/schemas-run.d.ts +10 -0
  273. package/dist/agent-runtime/schemas-run.d.ts.map +1 -1
  274. package/dist/agent-runtime/schemas-usage-state.d.ts +6 -0
  275. package/dist/agent-runtime/schemas-usage-state.d.ts.map +1 -0
  276. package/dist/agent-runtime/schemas-usage.d.ts +8 -0
  277. package/dist/agent-runtime/schemas-usage.d.ts.map +1 -1
  278. package/dist/agent-runtime/sql-rows.d.ts +20 -10
  279. package/dist/agent-runtime/sql-rows.d.ts.map +1 -1
  280. package/dist/agent-runtime/store-conformance-lifecycle.d.ts +40 -20
  281. package/dist/agent-runtime/store-conformance-lifecycle.d.ts.map +1 -1
  282. package/dist/agent-runtime/store-conformance-support.d.ts +20 -10
  283. package/dist/agent-runtime/store-conformance-support.d.ts.map +1 -1
  284. package/dist/agent-runtime/store-driver-contract.d.ts +70 -0
  285. package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
  286. package/dist/agent-runtime/store-events.d.ts +120 -0
  287. package/dist/agent-runtime/store-events.d.ts.map +1 -1
  288. package/dist/agent-runtime/store.d.ts +140 -0
  289. package/dist/agent-runtime/store.d.ts.map +1 -1
  290. package/dist/agent-runtime/terminal-commit.d.ts +10 -0
  291. package/dist/agent-runtime/terminal-commit.d.ts.map +1 -1
  292. package/dist/agent-runtime/testing.d.ts +20 -0
  293. package/dist/agent-runtime/testing.d.ts.map +1 -1
  294. package/dist/browser/client-call-arguments.d.ts.map +1 -1
  295. package/dist/browser/client-executors.d.ts.map +1 -1
  296. package/dist/browser/client-url.d.ts.map +1 -1
  297. package/dist/browser/client.d.ts +6 -0
  298. package/dist/browser/client.d.ts.map +1 -1
  299. package/dist/browser/device-presence-client.d.ts +42 -0
  300. package/dist/browser/device-presence-client.d.ts.map +1 -0
  301. package/dist/browser/device-presence-ops.d.ts +47 -0
  302. package/dist/browser/device-presence-ops.d.ts.map +1 -0
  303. package/dist/browser/device-presence-relay-adapter.d.ts +37 -0
  304. package/dist/browser/device-presence-relay-adapter.d.ts.map +1 -0
  305. package/dist/browser/http-fetch.d.ts +7 -2
  306. package/dist/browser/http-fetch.d.ts.map +1 -1
  307. package/dist/browser/http-helpers.d.ts +15 -0
  308. package/dist/browser/http-helpers.d.ts.map +1 -0
  309. package/dist/browser/http.d.ts +8 -0
  310. package/dist/browser/http.d.ts.map +1 -1
  311. package/dist/contract/client-types.d.ts +8 -0
  312. package/dist/contract/client-types.d.ts.map +1 -1
  313. package/dist/contract/runtime-context.d.ts +13 -1
  314. package/dist/contract/runtime-context.d.ts.map +1 -1
  315. package/dist/device-relay/agent-handlers.d.ts +45 -0
  316. package/dist/device-relay/agent-handlers.d.ts.map +1 -0
  317. package/dist/device-relay/agent.d.ts +80 -0
  318. package/dist/device-relay/agent.d.ts.map +1 -0
  319. package/dist/device-relay/broker.d.ts +49 -0
  320. package/dist/device-relay/broker.d.ts.map +1 -0
  321. package/dist/device-relay/contract.d.ts +614 -0
  322. package/dist/device-relay/contract.d.ts.map +1 -0
  323. package/dist/device-relay/encoding.d.ts +30 -0
  324. package/dist/device-relay/encoding.d.ts.map +1 -0
  325. package/dist/device-relay/hub-connection.d.ts +43 -0
  326. package/dist/device-relay/hub-connection.d.ts.map +1 -0
  327. package/dist/device-relay/hub-dispatch.d.ts +19 -0
  328. package/dist/device-relay/hub-dispatch.d.ts.map +1 -0
  329. package/dist/device-relay/hub-handshake.d.ts +20 -0
  330. package/dist/device-relay/hub-handshake.d.ts.map +1 -0
  331. package/dist/device-relay/hub-shared-streams.d.ts +24 -0
  332. package/dist/device-relay/hub-shared-streams.d.ts.map +1 -0
  333. package/dist/device-relay/hub-streams.d.ts +57 -0
  334. package/dist/device-relay/hub-streams.d.ts.map +1 -0
  335. package/dist/device-relay/hub.d.ts +117 -0
  336. package/dist/device-relay/hub.d.ts.map +1 -0
  337. package/dist/entrypoints/agent-executor/acp.d.ts +1 -1
  338. package/dist/entrypoints/agent-executor/acp.d.ts.map +1 -1
  339. package/dist/entrypoints/agent-executor/acp.js +183 -29
  340. package/dist/entrypoints/agent-executor/claude-sdk.js +15 -15
  341. package/dist/entrypoints/agent-executor/claude.js +13 -15
  342. package/dist/entrypoints/agent-executor/codex.js +88 -48
  343. package/dist/entrypoints/agent-executor/testing/claude-sdk.js +5 -5
  344. package/dist/entrypoints/agent-executor/testing.js +31 -30
  345. package/dist/entrypoints/agent-executor.d.ts +2 -2
  346. package/dist/entrypoints/agent-executor.d.ts.map +1 -1
  347. package/dist/entrypoints/agent-executor.js +23 -17
  348. package/dist/entrypoints/agent-runtime/ai-sdk.d.ts +9 -0
  349. package/dist/entrypoints/agent-runtime/ai-sdk.d.ts.map +1 -0
  350. package/dist/entrypoints/agent-runtime/ai-sdk.js +821 -0
  351. package/dist/entrypoints/agent-runtime/anthropic.d.ts +4 -0
  352. package/dist/entrypoints/agent-runtime/anthropic.d.ts.map +1 -0
  353. package/dist/entrypoints/agent-runtime/anthropic.js +1260 -0
  354. package/dist/entrypoints/agent-runtime/browser.d.ts +4 -1
  355. package/dist/entrypoints/agent-runtime/browser.d.ts.map +1 -1
  356. package/dist/entrypoints/agent-runtime/browser.js +449 -50
  357. package/dist/entrypoints/agent-runtime/coding-tools.js +3 -3
  358. package/dist/entrypoints/agent-runtime/harness.js +24 -19
  359. package/dist/entrypoints/agent-runtime/openai.d.ts +4 -0
  360. package/dist/entrypoints/agent-runtime/openai.d.ts.map +1 -0
  361. package/dist/entrypoints/agent-runtime/openai.js +1246 -0
  362. package/dist/entrypoints/agent-runtime/openrouter.d.ts +5 -2
  363. package/dist/entrypoints/agent-runtime/openrouter.d.ts.map +1 -1
  364. package/dist/entrypoints/agent-runtime/openrouter.js +2355 -371
  365. package/dist/entrypoints/agent-runtime/postgres.js +12 -10
  366. package/dist/entrypoints/agent-runtime/realtime.js +11 -10
  367. package/dist/entrypoints/agent-runtime/sandbox.d.ts +3 -0
  368. package/dist/entrypoints/agent-runtime/sandbox.d.ts.map +1 -1
  369. package/dist/entrypoints/agent-runtime/sandbox.js +530 -7
  370. package/dist/entrypoints/agent-runtime/sqlite/bun.js +13 -11
  371. package/dist/entrypoints/agent-runtime/sqlite/node.js +13 -11
  372. package/dist/entrypoints/agent-runtime/testing.d.ts +1 -1
  373. package/dist/entrypoints/agent-runtime/testing.d.ts.map +1 -1
  374. package/dist/entrypoints/agent-runtime/testing.js +56 -15
  375. package/dist/entrypoints/agent-runtime.d.ts +14 -6
  376. package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
  377. package/dist/entrypoints/agent-runtime.js +1412 -115
  378. package/dist/entrypoints/application/diagnostic-journal.js +6 -6
  379. package/dist/entrypoints/application/directory-inbox.js +6 -6
  380. package/dist/entrypoints/application/opentelemetry.js +3 -3
  381. package/dist/entrypoints/application.js +17 -17
  382. package/dist/entrypoints/cli/publish.js +8 -8
  383. package/dist/entrypoints/cli.js +14 -15
  384. package/dist/entrypoints/contract.d.ts +1 -0
  385. package/dist/entrypoints/contract.d.ts.map +1 -1
  386. package/dist/entrypoints/contract.js +13 -9
  387. package/dist/entrypoints/device-relay.d.ts +10 -0
  388. package/dist/entrypoints/device-relay.d.ts.map +1 -0
  389. package/dist/entrypoints/device-relay.js +2517 -0
  390. package/dist/entrypoints/files/packaging.js +3 -3
  391. package/dist/entrypoints/files.js +11 -11
  392. package/dist/entrypoints/geo.js +5 -5
  393. package/dist/entrypoints/google.js +1 -1
  394. package/dist/entrypoints/handler.js +6 -6
  395. package/dist/entrypoints/http.js +9 -9
  396. package/dist/entrypoints/index.js +21 -17
  397. package/dist/entrypoints/live.js +4 -4
  398. package/dist/entrypoints/node.js +13 -13
  399. package/dist/entrypoints/observability.js +9 -9
  400. package/dist/entrypoints/process/bootstrap.js +1 -1
  401. package/dist/entrypoints/process.js +5 -5
  402. package/dist/entrypoints/react.js +4 -4
  403. package/dist/entrypoints/realtime.d.ts +3 -0
  404. package/dist/entrypoints/realtime.d.ts.map +1 -1
  405. package/dist/entrypoints/realtime.js +413 -4
  406. package/dist/entrypoints/release.js +1 -1
  407. package/dist/entrypoints/remote.js +10 -10
  408. package/dist/entrypoints/server.d.ts +1 -0
  409. package/dist/entrypoints/server.d.ts.map +1 -1
  410. package/dist/entrypoints/server.js +546 -40
  411. package/dist/entrypoints/service-host/macos.js +10 -10
  412. package/dist/entrypoints/service-host/work.js +7 -7
  413. package/dist/entrypoints/service-host.js +15 -15
  414. package/dist/entrypoints/spend.js +3 -3
  415. package/dist/entrypoints/sync.js +4 -4
  416. package/dist/entrypoints/telegram/screens.js +6 -6
  417. package/dist/entrypoints/telegram.js +20 -20
  418. package/dist/entrypoints/testing.js +14 -14
  419. package/dist/entrypoints/tools/agent.d.ts +2 -1
  420. package/dist/entrypoints/tools/agent.d.ts.map +1 -1
  421. package/dist/entrypoints/tools/agent.js +8 -7
  422. package/dist/entrypoints/tools/connections.js +5 -5
  423. package/dist/entrypoints/tools/invoker.js +3 -4
  424. package/dist/entrypoints/tools/mcp.js +8 -9
  425. package/dist/entrypoints/tools/toolkit.js +32 -13
  426. package/dist/entrypoints/tools.d.ts +3 -1
  427. package/dist/entrypoints/tools.d.ts.map +1 -1
  428. package/dist/entrypoints/tools.js +37 -35
  429. package/dist/entrypoints/tracking/contract.js +1 -1
  430. package/dist/entrypoints/tracking/performance.js +4 -4
  431. package/dist/entrypoints/tracking.js +3 -3
  432. package/dist/{index-09f7w2qq.js → index-02kdtrcd.js} +1 -1
  433. package/dist/{index-y53cqwke.js → index-033tyx59.js} +1 -1
  434. package/dist/{index-9ft4n9j1.js → index-05b65gj4.js} +2 -2
  435. package/dist/{index-d04w81fz.js → index-0sxj3y45.js} +1 -1
  436. package/dist/{index-dm6nxkn1.js → index-18pf56dq.js} +4 -6
  437. package/dist/index-1gmgwfn3.js +439 -0
  438. package/dist/index-23wn8sgf.js +47 -0
  439. package/dist/{index-tqjamnax.js → index-27srek2g.js} +15 -13
  440. package/dist/{index-2nwvn7m2.js → index-29v1p1f4.js} +2 -2
  441. package/dist/index-36dmtzjr.js +194 -0
  442. package/dist/{index-ycr4pk0z.js → index-42n9jycn.js} +3 -3
  443. package/dist/{index-ke02kxsr.js → index-43k180c2.js} +1 -1
  444. package/dist/{index-pbekeqzm.js → index-5c4m8zdf.js} +2 -2
  445. package/dist/{index-qggqqja2.js → index-5dxgx3yj.js} +1 -1
  446. package/dist/{index-x5ayy5bn.js → index-5gdexvke.js} +3 -1
  447. package/dist/{index-t1a2jrg7.js → index-5xsxvk2x.js} +1 -1
  448. package/dist/{index-mbd92r1w.js → index-654rhe5d.js} +1 -1
  449. package/dist/{index-2dzc7mv9.js → index-67pnt4bh.js} +1 -1
  450. package/dist/index-6kpwkpgx.js +415 -0
  451. package/dist/{index-s43tr4my.js → index-6kwdfb9m.js} +18 -3
  452. package/dist/{index-1qwd54n3.js → index-6nzzj7qr.js} +1 -1
  453. package/dist/{index-rkjfzs0a.js → index-6p5pshcd.js} +2 -2
  454. package/dist/{index-118aebbg.js → index-6t4c98gr.js} +1 -1
  455. package/dist/{index-pws5c3x6.js → index-6xw1wf4m.js} +51 -32
  456. package/dist/{index-kwsr7j5k.js → index-6yb4stq3.js} +1 -1
  457. package/dist/{index-8jf4bt7v.js → index-76yhxa41.js} +8 -8
  458. package/dist/{index-7416mhyh.js → index-79vqbjcz.js} +1 -1
  459. package/dist/{index-13wmzpa6.js → index-7an2fs5h.js} +1 -1
  460. package/dist/index-7qza24g1.js +14 -0
  461. package/dist/{index-gtaaxe9d.js → index-8cek82ar.js} +1 -1
  462. package/dist/index-9f60gnfn.js +393 -0
  463. package/dist/{index-stpy56r3.js → index-aacwkve4.js} +209 -10
  464. package/dist/{index-rpyn7geq.js → index-ac3rfec5.js} +2 -2
  465. package/dist/{index-d2drhb9c.js → index-b0mh2t9x.js} +2 -2
  466. package/dist/index-b23s6e2c.js +158 -0
  467. package/dist/{index-an7vcmwf.js → index-bvpevwt6.js} +5 -5
  468. package/dist/{index-msxf2r8x.js → index-by8w2461.js} +1 -1
  469. package/dist/{index-8t9dr41h.js → index-c0yym4a0.js} +4 -4
  470. package/dist/{index-wddcfbng.js → index-c7fj4yw9.js} +1 -1
  471. package/dist/{index-tf70nm22.js → index-cb4nnvfr.js} +8 -6
  472. package/dist/{index-205456mf.js → index-d3s070eh.js} +2 -2
  473. package/dist/{index-apf5g7y9.js → index-dz6tstcp.js} +2 -2
  474. package/dist/{index-agy5fqgf.js → index-e1y74yra.js} +15 -8
  475. package/dist/index-edtg4tak.js +55 -0
  476. package/dist/{index-pq6g1k9t.js → index-ek9w11r0.js} +2 -2
  477. package/dist/{index-x46y9z26.js → index-epyj7ptp.js} +7 -5
  478. package/dist/{index-6kmjcm81.js → index-er483f3w.js} +93 -4
  479. package/dist/{index-827bgv33.js → index-f16b7rze.js} +1 -1
  480. package/dist/{index-gbhj370g.js → index-fec05c9k.js} +21 -21
  481. package/dist/{index-9wdrwx3b.js → index-fjac2w5e.js} +20 -22
  482. package/dist/{index-6918kxbf.js → index-fthw8dwa.js} +1 -0
  483. package/dist/{index-2mz8hj58.js → index-g04hszcm.js} +1 -1
  484. package/dist/{index-rw8ze745.js → index-ga6avd48.js} +1 -1
  485. package/dist/{index-paff5y0r.js → index-grhhsrd5.js} +9 -7
  486. package/dist/{index-mxt0wfjy.js → index-h20qcyh5.js} +5 -2
  487. package/dist/index-j3r7r1mh.js +150 -0
  488. package/dist/{index-vgytj9wp.js → index-jmaw365j.js} +1 -1
  489. package/dist/{index-cjytermm.js → index-jzdbkanz.js} +3 -3
  490. package/dist/index-k137ezb6.js +79 -0
  491. package/dist/{index-tazm4dxf.js → index-kdw0n92g.js} +1 -1
  492. package/dist/{index-wh70tmpd.js → index-ke6jtxkd.js} +1 -1
  493. package/dist/index-kgj8j7bv.js +83 -0
  494. package/dist/{index-9kpxz49v.js → index-kgkevngs.js} +1 -1
  495. package/dist/{index-hab790s6.js → index-kp1j7cc8.js} +4 -4
  496. package/dist/{index-jcge9tx3.js → index-krekhmp7.js} +142 -123
  497. package/dist/{index-3y2tzhr8.js → index-ky79wwgs.js} +4 -4
  498. package/dist/{index-39rmc00v.js → index-mfe9a266.js} +1 -1
  499. package/dist/{index-qpzyahe3.js → index-mgr0mdqp.js} +5 -2
  500. package/dist/{index-n20tybgk.js → index-mh3jdb25.js} +2 -2
  501. package/dist/{index-g5fgeb6v.js → index-mkmep637.js} +1 -1
  502. package/dist/{index-02r5sq9p.js → index-mrng24wq.js} +19 -21
  503. package/dist/index-mx2gya05.js +465 -0
  504. package/dist/{index-8yt3rwe7.js → index-n2t87ggz.js} +5 -5
  505. package/dist/index-nfeafbzh.js +7379 -0
  506. package/dist/{index-j0ef04jw.js → index-nfm15ej7.js} +4 -4
  507. package/dist/index-pd9e8rz4.js +193 -0
  508. package/dist/{index-zwgwyvdt.js → index-pdcbjd6a.js} +1 -1
  509. package/dist/{index-q427q23r.js → index-pjjh91vw.js} +2 -2
  510. package/dist/{index-gnjgkecx.js → index-q46b16xz.js} +1 -1
  511. package/dist/{index-9xr44d2g.js → index-qv5v6w9c.js} +330 -106
  512. package/dist/{index-tmv3ez1h.js → index-qymek778.js} +69 -12
  513. package/dist/{index-yrr3n391.js → index-ry8m2mhg.js} +2 -2
  514. package/dist/{index-93n6jwy0.js → index-s0n0nnz5.js} +3 -3
  515. package/dist/{index-1p8q0yrt.js → index-t5zp1jjj.js} +5 -7
  516. package/dist/{index-2rf33y2h.js → index-tav72wz5.js} +4 -2
  517. package/dist/{index-jpecjm30.js → index-tgehj4bp.js} +1 -1
  518. package/dist/{index-ma26mfnt.js → index-v5hmyef8.js} +1 -1
  519. package/dist/index-vebzvse6.js +230 -0
  520. package/dist/index-vv0hxrmy.js +295 -0
  521. package/dist/index-vxm0ya3f.js +707 -0
  522. package/dist/{index-t3qcac2a.js → index-w3s79kcb.js} +1 -1
  523. package/dist/{index-r97ppg0g.js → index-x1r7kxzd.js} +1 -1
  524. package/dist/{index-kynwa08q.js → index-xrsryvd2.js} +2 -2
  525. package/dist/{index-3mcbr8sx.js → index-xtxxt87z.js} +1 -1
  526. package/dist/index-zk839vzf.js +231 -0
  527. package/dist/{index-9c76vfxf.js → index-zyyerdny.js} +4 -4
  528. package/dist/internal/base64.d.ts +9 -0
  529. package/dist/internal/base64.d.ts.map +1 -0
  530. package/dist/internal/deadline-budget.d.ts +57 -0
  531. package/dist/internal/deadline-budget.d.ts.map +1 -0
  532. package/dist/internal/deadline.d.ts.map +1 -1
  533. package/dist/internal/timers.d.ts +2 -0
  534. package/dist/internal/timers.d.ts.map +1 -1
  535. package/dist/realtime/device-presence-contract.d.ts +194 -0
  536. package/dist/realtime/device-presence-contract.d.ts.map +1 -0
  537. package/dist/server/context-contribution.d.ts.map +1 -1
  538. package/dist/server/contract-method.d.ts.map +1 -1
  539. package/dist/server/device-presence-handlers.d.ts +54 -0
  540. package/dist/server/device-presence-handlers.d.ts.map +1 -0
  541. package/dist/server/device-presence-registry.d.ts +35 -0
  542. package/dist/server/device-presence-registry.d.ts.map +1 -0
  543. package/dist/server/device-presence.d.ts +45 -0
  544. package/dist/server/device-presence.d.ts.map +1 -0
  545. package/dist/server/endpoint-dispatch.d.ts.map +1 -1
  546. package/dist/server/middleware/cors.d.ts +3 -1
  547. package/dist/server/middleware/cors.d.ts.map +1 -1
  548. package/dist/server/types.d.ts +4 -11
  549. package/dist/server/types.d.ts.map +1 -1
  550. package/dist/service-host/systemd-render-shared.d.ts.map +1 -1
  551. package/dist/tools/agent-messages.d.ts +6 -0
  552. package/dist/tools/agent-messages.d.ts.map +1 -0
  553. package/dist/tools/agent-tool-error.d.ts +2 -2
  554. package/dist/tools/agent-tools.d.ts +153 -0
  555. package/dist/tools/agent-tools.d.ts.map +1 -0
  556. package/dist/tools/agent.d.ts +6 -56
  557. package/dist/tools/agent.d.ts.map +1 -1
  558. package/dist/tools/runtime-tool.d.ts +3 -4
  559. package/dist/tools/runtime-tool.d.ts.map +1 -1
  560. package/dist/tools/toolkit.d.ts +3 -1
  561. package/dist/tools/toolkit.d.ts.map +1 -1
  562. package/dist/tools/transfer/define-view-file-tool.d.ts.map +1 -1
  563. package/llms/agent-executor-acp.txt +2 -2
  564. package/llms/agent-executor-codex.txt +1 -1
  565. package/llms/agent-executor.txt +7 -3
  566. package/llms/agent-runtime-ai-sdk.txt +26 -0
  567. package/llms/agent-runtime-anthropic.txt +33 -0
  568. package/llms/agent-runtime-browser.txt +22 -8
  569. package/llms/agent-runtime-harness.txt +2 -2
  570. package/llms/agent-runtime-openai.txt +31 -0
  571. package/llms/agent-runtime-openrouter.txt +17 -7
  572. package/llms/agent-runtime-sandbox.txt +53 -1
  573. package/llms/agent-runtime-testing.txt +4 -2
  574. package/llms/agent-runtime.2.txt +158 -271
  575. package/llms/agent-runtime.3.txt +289 -243
  576. package/llms/agent-runtime.4.txt +273 -216
  577. package/llms/agent-runtime.5.txt +209 -2
  578. package/llms/agent-runtime.txt +238 -181
  579. package/llms/contract.txt +2 -1
  580. package/llms/device-relay.txt +34 -0
  581. package/llms/realtime.txt +20 -0
  582. package/llms/server.2.txt +125 -1
  583. package/llms/server.3.txt +111 -122
  584. package/llms/server.4.txt +1 -1
  585. package/llms/server.5.txt +3 -1
  586. package/llms/server.txt +31 -1
  587. package/llms/spend.txt +11 -6
  588. package/llms/stitchkit.2.txt +21 -43
  589. package/llms/stitchkit.3.txt +43 -0
  590. package/llms/stitchkit.txt +93 -84
  591. package/llms/tools-agent.txt +7 -5
  592. package/llms/tools-toolkit.txt +1 -1
  593. package/llms/tools.4.txt +7 -2
  594. package/llms/{upgrading-0.128.0-0.133.0.txt → upgrading-0.128.0-0.134.0.txt} +173 -3
  595. package/llms/upgrading.txt +1 -1
  596. package/llms-full.txt +981 -210
  597. package/llms.txt +21 -17
  598. package/package.json +18 -7
  599. package/dist/index-0p0s5hrj.js +0 -249
  600. package/dist/index-1dn2wjq6.js +0 -135
  601. package/dist/index-1psbyyhj.js +0 -21
  602. package/dist/index-34k82crg.js +0 -3961
  603. package/dist/index-5n3a8hd8.js +0 -102
  604. package/dist/index-97rp94ff.js +0 -8
  605. package/dist/index-bn2baakz.js +0 -336
  606. package/dist/index-eh71zr32.js +0 -14
  607. package/dist/index-emgrmavr.js +0 -1193
  608. package/dist/index-fzd477xk.js +0 -135
  609. package/dist/index-vgzhw2zk.js +0 -304
  610. package/dist/internal/ai-sdk-typed.d.ts +0 -14
  611. package/dist/internal/ai-sdk-typed.d.ts.map +0 -1
  612. package/dist/tools/runtime-call-context.d.ts +0 -15
  613. package/dist/tools/runtime-call-context.d.ts.map +0 -1
  614. package/dist/{index-vmbxj75t.js → index-jwtmw39p.js} +0 -0
  615. package/dist/{index-877e9y8r.js → index-sk03xe0n.js} +3 -3
  616. package/dist/{index-21cfxc4z.js → index-vh4291qh.js} +3 -3
@@ -8,8 +8,8 @@ Parts of this slice:
8
8
  - `llms/agent-runtime.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md)
9
9
  - `llms/agent-runtime.2.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md)
10
10
  - `llms/agent-runtime.3.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md)
11
- - `llms/agent-runtime.4.txt`: API reference: `stitchkit/agent-runtime` (docs/api/reference.md)
12
- - `llms/agent-runtime.5.txt`: API reference: `stitchkit-tui` (docs/api/reference.md)
11
+ - `llms/agent-runtime.4.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md) · API reference: `stitchkit/agent-runtime` (docs/api/reference.md)
12
+ - `llms/agent-runtime.5.txt`: API reference: `stitchkit/agent-runtime` (docs/api/reference.md) · API reference: `stitchkit-tui` (docs/api/reference.md)
13
13
 
14
14
  ==============================================================================
15
15
  # Guide: Agent application runtime (docs/guide/agent-runtime.md)
@@ -20,17 +20,21 @@ Parts of this slice:
20
20
  > **Maturity: evolving.** This surface is still finding its shape and may be
21
21
  > redefined in any minor release — always with a `### ⚠️ Breaking changes` entry
22
22
  > and a migration section, never silently. If your application already owns the
23
- > conversation loop, `mountAgent` from `stitchkit/tools/agent` is the direct path.
24
-
25
- `stitchkit/agent-runtime` is the server-only, opinionated layer above
26
- `mountAgent`. Use it when the application wants Stitchkit to own conversation
27
- mechanics: durable acceptance, history projection, the AI SDK stream loop,
28
- checkpoints, keyed interruption, terminal commit and stable application events.
29
-
30
- If the application already owns that loop, import `mountAgent` from
31
- `stitchkit/tools/agent`. Neither `stitchkit/tools` nor `stitchkit/tools/agent` depends on
32
- this entrypoint; this entrypoint uses the tool executor, but pulls no MCP peer, so
33
- choosing `mountAgent` alone costs you nothing from here.
23
+ > conversation loop, `mountAgentTools` from `stitchkit/tools` (or `mountAgent`
24
+ > from `stitchkit/tools/agent` for an AI SDK loop) is the direct path.
25
+
26
+ `stitchkit/agent-runtime` is the peer-free, server-only, opinionated layer above
27
+ `mountAgentTools`. Use it when the application wants Stitchkit to own conversation
28
+ mechanics: durable acceptance, history projection, the native `AgentModelDriver`
29
+ step loop, checkpoints, keyed interruption, terminal commit and stable application
30
+ events.
31
+
32
+ If the application already owns that loop, import `mountAgentTools` from
33
+ `stitchkit/tools` (peer-free) or `mountAgent` from `stitchkit/tools/agent` (AI SDK
34
+ adapter). Neither `stitchkit/tools` nor `stitchkit/tools/agent` depends on this
35
+ entrypoint; this entrypoint uses the tool executor, pulls no MCP peer and no AI SDK
36
+ peer, and runs directly against three native providers (`openrouter`, `openai`,
37
+ `anthropic`) or any custom `AgentModelDriver`.
34
38
 
35
39
  UI and shared DTO code must import canonical records and delivery validation from
36
40
  `stitchkit/agent-runtime/browser`, not from the server runtime barrel:
@@ -50,16 +54,22 @@ persistence, event sinks and every Node context dependency.
50
54
  ## Install
51
55
 
52
56
  ```sh
53
- bun add stitchkit ai zod
57
+ bun add stitchkit zod
54
58
  ```
55
59
 
56
- `mountAgent` from `stitchkit/tools/agent` — used in the composition below — needs no
57
- peer beyond `ai`.
60
+ `stitchkit/agent-runtime`, `stitchkit/agent-runtime/harness`,
61
+ `stitchkit/agent-runtime/testing`, `stitchkit/tools` (`mountAgentTools`,
62
+ `defineAgentTool`), and all three native providers
63
+ (`stitchkit/agent-runtime/openrouter`, `stitchkit/agent-runtime/openai`,
64
+ `stitchkit/agent-runtime/anthropic`) are completely peer-free beyond `zod`.
58
65
 
59
- OpenRouter is isolated so other runtime users do not resolve its package:
66
+ Install `ai` only when bridging an existing AI SDK v4 `LanguageModel` or `ToolSet`
67
+ through the thin optional-peer adapter `stitchkit/agent-runtime/ai-sdk`
68
+ (`fromAiSdkModel`, `fromAiSdkTools`) or mounting an AI SDK `ToolSet` through
69
+ `stitchkit/tools/agent` (`mountAgent`):
60
70
 
61
71
  ```sh
62
- bun add @openrouter/ai-sdk-provider
72
+ bun add ai@^7
63
73
  ```
64
74
 
65
75
  ## Minimal composition
@@ -75,8 +85,7 @@ import {
75
85
  defineModelRegistry,
76
86
  } from 'stitchkit/agent-runtime'
77
87
  import { openRouterProvider } from 'stitchkit/agent-runtime/openrouter'
78
- import { composeToolLifecycle } from 'stitchkit/tools'
79
- import { mountAgent } from 'stitchkit/tools/agent'
88
+ import { composeToolLifecycle, mountAgentTools } from 'stitchkit/tools'
80
89
 
81
90
  const protocol = defineAgentProtocol({
82
91
  context: z.object({ userId: z.string() }),
@@ -125,7 +134,7 @@ const runtime = createAgentRuntime({
125
134
  },
126
135
  }),
127
136
  tools: ({ context, toolFenceLifecycle }) =>
128
- mountAgent(service, {
137
+ mountAgentTools(service, {
129
138
  context,
130
139
  access: { gate: composeToolLifecycle(authLifecycle, toolFenceLifecycle) },
131
140
  }),
@@ -164,11 +173,205 @@ await ticket.accepted
164
173
  const terminal = await ticket.result
165
174
  ```
166
175
 
167
- A stop policy's `when` receives the steps so far together with the same run context
168
- `prepareStep` gets — `context`, `run`, `signal`, `toolFenceLifecycle` and `contextUsage` —
169
- typed by the runtime's `CONTEXT`. A rule that depends on its own run (a receipt bound to the
170
- run's request, a per-tenant limit) reads it there; it needs no map of its own keyed by `runId`.
171
- The first policy to return `true` ends the run as `policy_stop` with its `name` as `policyName`.
176
+ A stop policy's `when` receives the completed `AgentStepResult[]` steps so far together with the
177
+ same run context `prepareStep` gets — `context`, `run`, `signal`, `toolFenceLifecycle` and
178
+ `contextUsage` — typed by the runtime's `CONTEXT`. A rule that depends on its own run (a receipt
179
+ bound to the run's request, a per-tenant limit) reads it there; it needs no map of its own keyed
180
+ by `runId`. The first policy to return `true` ends the run as `policy_stop` with its `name` as
181
+ `policyName`.
182
+
183
+ ## Native model port, providers and driver composition
184
+
185
+ Every model call crosses one single-step port — `AgentModelDriver.stream(request, signal)` — with
186
+ no SDK retries and no tool execution inside the driver (ADR 0336). Any throw out of `stream()` or
187
+ while reading `parts` is provider-origin by construction; HTTP and stream failures surface as
188
+ `AgentProviderError` (guard with `isAgentProviderError`) or `AgentProviderStreamCutError`.
189
+ `AgentModelRequest.headers` merges per-request headers (such as `traceparent` or deadline headers)
190
+ without allowing `content-type: application/json` to be overwritten. `AgentModelToolSpec` also
191
+ reserves an additive `{ type: 'provider', id, name, config? }` union branch for provider-hosted
192
+ tools; drivers that do not implement a declared provider tool fail fast with `TypeError`.
193
+
194
+ Three peer-free native providers implement `AgentModelDriverFactory` over Web `fetch` and SSE,
195
+ all accepting either a static string or a dynamic `apiKey: () => string | Promise<string>` resolved
196
+ freshly per stream call and reporting server `response.timestamp` alongside `modelId`:
197
+
198
+ - **`stitchkit/agent-runtime/openrouter`** (`openRouterProvider`): OpenRouter Chat Completions SSE
199
+ with camelCase `baseUrl` and `providerApiKeys`, `looseTools` (sending `strict: false` while
200
+ preserving explicit per-tool `strict: true`), `reasoning.effort: 'max'`, `sessionPerConversation`
201
+ derived from `request.correlation.conversationId` without requiring `invocations`,
202
+ `reasoning_details` and Gemini `thought_signature` round-trip, ≤ 4 cache breakpoints, BYOK
203
+ `costDetails` (`cost + upstream_inference_cost`), and `native_finish_reason` abnormal-stop guards.
204
+ - **`stitchkit/agent-runtime/openai`** (`openAiProvider`): OpenAI Responses API
205
+ (`POST /v1/responses`) defaulting to stateless `store: false` with automatic
206
+ `include: ['reasoning.encrypted_content']` round-trip, `role: 'developer'` instructions,
207
+ `strict: false` default tool schemas, `item_id` (`fc_*`) vs `call_id` separation, `text.format`
208
+ structured outputs, `cachePerConversation` (`prompt_cache_key`), and fail-fast `TypeError`
209
+ refusal of unsupported call settings.
210
+ - **`stitchkit/agent-runtime/anthropic`** (`anthropicProvider`): Anthropic Messages API
211
+ (`POST /v1/messages`) with mandatory `maxOutputTokens` and
212
+ `maxOutputTokens > thinking.budgetTokens` fail-fast validation, verbatim multi-block
213
+ `thinking` + `signature` and `redacted_thinking` preservation, `computed` total `inputTokens`
214
+ when cache counters are positive (ADR 0109), image splitting out of `is_error` tool results,
215
+ ≤ 4 cache breakpoints with TTL-order checks, `output_config.format` JSON Schema (refusing
216
+ schemaless `json-object`), and retryable `529 overloaded_error` classification.
217
+
218
+ For an existing AI SDK v4 model or `ToolSet`, import `fromAiSdkModel` and `fromAiSdkTools` from
219
+ `stitchkit/agent-runtime/ai-sdk`. Both adapt directly onto `AgentModelDriver` and `AgentToolSet`
220
+ (driving `model.doStream()` without importing `streamText` or `generateText`) and normalize legacy
221
+ deprecated tool outputs into canonical `{ type: 'file', data, mediaType }` parts.
222
+
223
+ Wrap any driver with `wrapModelDriver` or `composeModelDrivers` for admission holds, credit
224
+ reservations, request transforms, signal tightening (`transformSignal`, which links a tighter
225
+ `AbortSignal` without ever loosening the caller's signal), or per-part telemetry. `onClose` runs
226
+ once per stream on finish, error, early consumer break, or signal abort:
227
+
228
+ ```ts
229
+ import { composeModelDrivers } from 'stitchkit/agent-runtime'
230
+ import { openAiProvider } from 'stitchkit/agent-runtime/openai'
231
+
232
+ const base = openAiProvider({ apiKey: env.OPENAI_API_KEY }).create('gpt-5')
233
+ const guarded = composeModelDrivers(base, [admissionDecorator, telemetryDecorator])
234
+ ```
235
+
236
+ ### OpenRouter catalog snapshots, pricing ceilings, and cache
237
+
238
+ `stitchkit/agent-runtime/openrouter` also provides a peer-free, Web Fetch-clean catalog layer for
239
+ discovering models, checking pricing ceilings, and keeping a cached catalog in sync across requests:
240
+
241
+ - `loadOpenRouterCatalogSnapshot` fetches `/models` (and optional per-model `/endpoints`) with
242
+ unauthenticated public access or a static/dynamic `apiKey`, extracting `canonicalSlug`,
243
+ `description`, `createdAt`, `aliasTarget`, `inputModalities`, `outputModalities`, `tokenizer`,
244
+ `topProviderContextLength`, `maxCompletionTokens`, `reasoning`, per-unit/cache/conditional
245
+ `pricingTiers`, and endpoint telemetry (`latencyP50Ms`, `throughputP50`, `uptime1d`, `tag`).
246
+ - `resolveOpenRouterModelCeiling` returns the worst-case per-unit rates across base pricing and
247
+ conditional tiers without understating unknown tiers; `summarizeOpenRouterEndpoints` aggregates
248
+ distinct provider counts, median latency/throughput, and 1-day uptime.
249
+ - `findOpenRouterModel` looks up a model by exact `id` or `canonicalSlug`, and
250
+ `listOpenRouterModels` filters snapshots by `tools`, `reasoning`, modalities, `minContextLength`,
251
+ price bounds, `freeOnly`, and `author`.
252
+ - `createOpenRouterCatalogCache` wraps snapshot refreshes with single-flight coalescing, per-caller
253
+ `AbortSignal` isolation, `freshMs` TTL, `retryBackoffMs` stale fallback, and an optional
254
+ pluggable `OpenRouterCatalogStore` for durable hydration and persistence. `catalog.read()` returns
255
+ a discriminated union (`status: 'current' | 'stale' | 'unavailable'`) so admission and billing
256
+ callers can narrow on `res.status !== 'unavailable'` and observe stale or unavailable catalog
257
+ state explicitly; the convenience helpers `getModel` and `listModels` map `'unavailable'` to
258
+ `undefined` and `[]`.
259
+
260
+ ```ts
261
+ import {
262
+ createOpenRouterCatalogCache,
263
+ evaluateOpenRouterModelAdmission,
264
+ findOpenRouterModel,
265
+ listOpenRouterModels,
266
+ resolveOpenRouterModelCeiling,
267
+ summarizeOpenRouterEndpoints,
268
+ } from 'stitchkit/agent-runtime/openrouter'
269
+
270
+ const catalog = createOpenRouterCatalogCache({
271
+ freshMs: 15 * 60_000,
272
+ retryBackoffMs: 60_000,
273
+ endpointsFor: ['anthropic/claude-sonnet-4.6'],
274
+ })
275
+
276
+ // Admission and billing paths use catalog.read() to observe 'current', 'stale', and 'unavailable'.
277
+ const res = await catalog.read()
278
+ if (res.status !== 'unavailable') {
279
+ const admission = evaluateOpenRouterModelAdmission({
280
+ snapshot: res.snapshot,
281
+ modelId: 'anthropic/claude-sonnet-4.6',
282
+ policy: { maxSnapshotAgeMs: 30 * 60_000, requiredParameters: ['tools'] },
283
+ })
284
+ const reasoningTools = listOpenRouterModels(res.snapshot, { tools: true, reasoning: true })
285
+ const sonnet = findOpenRouterModel(res.snapshot, 'anthropic/claude-sonnet-4.6')
286
+ const ceiling = sonnet ? resolveOpenRouterModelCeiling(sonnet) : undefined
287
+ const endpoints = sonnet?.endpoints ? summarizeOpenRouterEndpoints(sonnet.endpoints) : undefined
288
+ void [admission, reasoningTools, ceiling, endpoints]
289
+ }
290
+ ```
291
+
292
+ ## Peer-free tools and stateless completions
293
+
294
+ Build standalone peer-free tools with `defineAgentTool` or project contracts and runtime tools
295
+ with `mountAgentTools` from `stitchkit/tools` (including the single-argument
296
+ `mountAgentTools({ runtimeTools, access })` form when no HTTP service contracts are mounted). Both
297
+ return `AgentTool` / `AgentToolSet` carrying JSON Schema 2020-12 `inputSchema`, Zod `parseInput`,
298
+ optional `needsApproval`, `onInputAvailable`, and `toModelOutput` returning `AgentToolModelOutput`.
299
+
300
+ When an operation needs one or a few model steps without a durable conversation store — structured
301
+ extraction, classification, a bounded tool loop, or standalone streaming — call `completeText`,
302
+ `streamComplete`, or `completeObject` from `stitchkit/agent-runtime`:
303
+
304
+ - Compile-time XOR enforces passing either `prompt` or `messages` (never both or neither).
305
+ - Pass `onPart` on `completeText` / `completeObject` or use `streamComplete` to consume
306
+ `text-delta`, `reasoning-delta`, `tool-input-start`, `tool-call`, `tool-result` (preliminary and
307
+ final), `tool-error`, `attempt-reset`, `finish-step`, and `finish` events over a bounded async
308
+ iterable without a store.
309
+ - Standalone completions have no durable approval loop, so any tool with `needsApproval: true` (or
310
+ a `needsApproval` predicate returning `true`) fails closed before execution with
311
+ `AgentToolApprovalError` (`reason: 'approval-unsupported'`); a predicate returning `false` lets
312
+ the safe call proceed.
313
+ - Pass `retry` (`AgentRetryPolicy`) and optional `onAttemptDiscarded` for stateless retry with
314
+ `Retry-After` handling; exhausting retries throws `AgentRetryExhaustedError` carrying every failed
315
+ attempt, `lastError`, and accumulated billable `usage`.
316
+ - Pass `stopPolicies` (`AgentCompleteStopPolicy[]`) and `idleTimeoutMs` to bound multi-step loops
317
+ and stalled streams (suspending the idle timer during local tool execution).
318
+
319
+ ```ts
320
+ import { z } from 'zod'
321
+ import { AgentStructuredOutputError, completeObject } from 'stitchkit/agent-runtime'
322
+ import { anthropicProvider } from 'stitchkit/agent-runtime/anthropic'
323
+ import { defineAgentTool } from 'stitchkit/tools'
324
+
325
+ const driver = anthropicProvider(
326
+ { apiKey: env.ANTHROPIC_API_KEY },
327
+ { defaultPolicy: { maxOutputTokens: 2048 } },
328
+ ).create('claude-sonnet-4-5')
329
+
330
+ const lookup = defineAgentTool({
331
+ description: 'Fetch record summary',
332
+ input: z.object({ id: z.string() }),
333
+ execute: async ({ id }) => db.findSummary(id),
334
+ })
335
+
336
+ const { object, usage, steps } = await completeObject({
337
+ driver,
338
+ instructions: 'Return the normalized verdict.',
339
+ prompt: 'Classify ticket T-42',
340
+ tools: { lookup },
341
+ schema: z.object({ severity: z.enum(['low', 'high']), summary: z.string() }),
342
+ })
343
+ ```
344
+
345
+ `completeObject` projects the Zod schema through `toJsonSchema(schema, 'input')` (supporting
346
+ `.transform()` and `.default()`), strips strict-mode synthesized `null`s on optional non-nullable
347
+ fields before `schema.safeParse`, validates `schemaName` through `AgentModelResponseFormatSchema`,
348
+ and throws `AgentStructuredOutputError` (`reason: 'truncated' | 'tool-calls' | 'content-filter' |
349
+ 'provider-error' | 'interrupted' | 'empty' | 'invalid-json' | 'schema-mismatch'`, with
350
+ `finishReason`, `rawText`, `steps`, and `usage`) when the response cannot satisfy the schema.
351
+
352
+ For durable runs, the native loop also exposes:
353
+
354
+ - `loop.maxDurationMs` — hard wall-clock run deadline (`number | null`) that never pauses during
355
+ tool execution or resets on provider deltas, distinct from `loop.idleTimeoutMs`.
356
+ - `loop.beforeStepToolCalls` — a whole-step batch policy invoked once all tool calls of a step are
357
+ parsed and validated, returning `{ refuse: Map<toolCallId, Error> }` for any call to reject.
358
+ - `loop.stepBarriers.onMaxReasoningChars: 'abort' | 'finish-length'` — `'abort'` (default) ends the
359
+ run as `policy_stop`; `'finish-length'` cuts only the current step cleanly with
360
+ `finishReason: 'length'` so `protocol.acceptTerminal` can run a recovery continuation.
361
+ - `loop.stepBarriers.onPredecessorFailure: 'refuse'` — fail-cascades dependent calls waiting on
362
+ the same entity with `STEP_PREDECESSOR_FAILED` when an earlier call fails execution, fails input
363
+ validation, is refused by `beforeStepToolCalls`, or returns a payload matching
364
+ `isToolResultFailure(output)`.
365
+ - `loop.stepBarriers.stepText: 'after-tools'` with optional `stepTextOnInterrupt: 'drop' | 'flush'`
366
+ and `filterStepText(text, { step, interrupted, finishReason, toolCalls, toolResults })` — holds
367
+ premature step text when any tool fails (including `isToolResultFailure`) or requests approval,
368
+ and lets callers flush or transform held text cleanly.
369
+ - `loop.toolApproval` per-tool rule maps infer each tool's typed `input` from `TOOLS[K]`.
370
+ - `protocol.acceptTerminal` returning `{ action: 'continue', message, instructions? }` — runs a
371
+ bounded continuation step capped by `loop.maxContinuations` (default 3); use `carriedToolWork`
372
+ to inspect whether earlier steps executed tools.
373
+ - `loop.onAttemptDiscarded` and `loop.onToolInputStart` — observe discarded retry attempts (with
374
+ failure reason and billed usage) and streamed tool-input starts.
172
375
 
173
376
  ## Bounded deferred tool catalogs
174
377
 
@@ -274,7 +477,7 @@ has no side effect; an external supervisor owns process placement and restart.
274
477
  | execution loop | `createAgentRuntime` | already available; do not copy a second loop |
275
478
  | model choice | `defineModelRegistry` and `models.resolve` | provider credentials/discovery stay application-owned |
276
479
  | resources | `createHeadlessAgentHarness` → `composeAgentPrompt` | paths, trust, precedence and watching stay application-owned |
277
- | tools | `mountAgent` + `createAgentToolFenceLifecycle` | auth and domain effects stay application-owned |
480
+ | tools | `mountAgentTools` + `createAgentToolFenceLifecycle` | auth and domain effects stay application-owned |
278
481
  | follow-up | `runs.inputPolicy: 'queue'` | durable FIFO after the current run |
279
482
  | interrupt | `interrupt` or `interrupt-next` | `interrupt-next` terminates the active run and gives the new durable admission next priority |
280
483
  | recovery | `runtime.recover` + `scanRecoverable` | replay safety and context reconstruction are explicit callbacks |
@@ -293,13 +496,14 @@ and requests a fresh snapshot. It never writes a second frame concurrently with
293
496
  `reduceAgentControlSnapshot` and `reduceAgentControlEvent`; the reducer owns no renderer and marks a
294
497
  conversation `resyncRequired` after a transient sequence gap.
295
498
 
296
- Configure `loop.toolApproval` to use the installed AI SDK approval policy and
297
- `loop.toolApprovalSecret` to sign exact requests. A request is stored on the terminal assistant
298
- before any effect. `pendingApprovals()` derives unresolved requests from canonical messages;
299
- `respondToApproval()` writes one tool-role approval response and queues a successor. The SDK
300
- revalidates the signature/tool call/input before the original direct tool reaches its existing
301
- fence. Reconnect and SQLite reopen require no promise registry. Remembered policy and a stronger
302
- cross-crash exactly-once guarantee remain application concerns.
499
+ Configure `loop.toolApproval` for the runtime's native approval policy and
500
+ `loop.toolApprovalSecret` to bind exact requests with WebCrypto HMAC-SHA256 signatures. A request
501
+ is stored on the terminal assistant before any effect. `pendingApprovals()` derives unresolved
502
+ requests from canonical messages; `respondToApproval()` writes one tool-role approval response and
503
+ queues a successor. The native loop revalidates the signature/tool call/input once before any
504
+ retry attempts and before the original direct tool reaches its existing fence. Reconnect and SQLite
505
+ reopen require no promise registry. Remembered policy and a stronger cross-crash exactly-once
506
+ guarantee remain application concerns.
303
507
 
304
508
  Approval requests suspend a call; they do not settle its result. History carries exact call and
305
509
  approval identity across assistant/tool records, so an approved result can precede the next signed
@@ -571,150 +775,3 @@ schema version, conversation identity and monotonic version. Runs and admission
571
775
  recovery queries active run states directly instead of maintaining a second projection.
572
776
  An admission receipt retains its canonical input, and a terminal run retains its canonical
573
777
  assistant, so physical product-history compaction cannot break idempotent retries.
574
-
575
- ### Built-in SQLite persistence
576
-
577
- Use the runtime-specific leaf; the neutral agent runtime never imports either
578
- SQLite built-in:
579
-
580
- ```ts
581
- // Bun
582
- import { createBunSqliteAgentRuntimeStore } from 'stitchkit/agent-runtime/sqlite/bun'
583
-
584
- const sqlite = createBunSqliteAgentRuntimeStore({ filename: './agent-runtime.sqlite' })
585
- const runtime = createAgentRuntime({ ...config, store: sqlite.store })
586
-
587
- await runtime.close()
588
- await sqlite.close()
589
- ```
590
-
591
- ```ts
592
- // Node 22.5+
593
- import { createNodeSqliteAgentRuntimeStore } from 'stitchkit/agent-runtime/sqlite/node'
594
-
595
- const sqlite = createNodeSqliteAgentRuntimeStore({ filename: './agent-runtime.sqlite' })
596
- ```
597
-
598
- Initialization creates only `stitchkit_agent_runtime_*` tables and records
599
- schema version 2 in `stitchkit_agent_runtime_meta`; it does not use
600
- `PRAGMA user_version` or mutate application tables. An unknown schema version or
601
- unversioned partial Stitchkit schema is refused. The connection is owned by the
602
- returned handle and closes only after accepted operations drain.
603
-
604
- Each handle serializes its transactions. Separate connections use
605
- `busy_timeout = 0`: a competing synchronous writer fails promptly with
606
- SQLite's lock error, so an awaited transaction can resume and commit or roll
607
- back. Retry that explicit error with an application-owned bounded policy; do
608
- not configure a blocking busy timeout on the same JavaScript thread.
609
-
610
- Aggregate reads and catalog pages use `BEGIN`, so a WAL writer may remain active
611
- while the reader sees one committed snapshot. Mutations and purge use
612
- `BEGIN IMMEDIATE`: they reserve the writer slot before reading state for CAS and
613
- never attempt a deferred read-to-write upgrade. A custom driver may inspect the
614
- additive `transaction` option `{ access: 'read' }`; ignoring it preserves the
615
- previous write-safe behavior.
616
-
617
- The adapter proves canonical durability across reopen and process restart. It
618
- does not make external tool effects exactly once, join application projections
619
- atomically or replace an application outbox. If a product row must commit with
620
- an agent transition, implement `AgentRuntimeStoreDriver` over the application's
621
- own transaction boundary instead.
622
-
623
- Opening a version 1 store migrates it in one transaction, forward only — back
624
- the file up first, a 0.85.x package refuses a migrated file. Existing
625
- normalized state becomes one `runtime/baseline` event per conversation, dated
626
- when the migration ran and carrying `asOf` for the last message it describes;
627
- search and projections address that pre-migration history as one snapshot at
628
- `seq 1`. New transitions continue the monotonic conversation sequence. Version
629
- 2 requires SQLite FTS5 because event search is an advertised capability, so a
630
- build without FTS5 is a startup error (`requires FTS5 support`) rather than an
631
- empty search result; check with
632
- `SELECT sqlite_compileoption_used('ENABLE_FTS5')`.
633
-
634
- The handle returned by `createBunSqliteAgentRuntimeStore` /
635
- `createNodeSqliteAgentRuntimeStore` is `{ store, conversations, host, close }`.
636
- `host` is where the companions keep their rows — `createAgentProjectionStore`,
637
- `createAgentSpillStore`, `createAgentChildManager`,
638
- `createAgentScheduleService` and `createAgentEventSearch` take it (the child
639
- manager and the projection store `{ store, host }`). `host.transaction(conversationId, work)`
640
- is one write transaction of the store: it refuses a purged conversation, and
641
- the companion's row and its event commit together or not at all.
642
- `host.read(work)` is a read transaction. Companions exist on the SQLite and
643
- Postgres stores; the memory store and a hand-written driver have none. The
644
- event search uses FTS5 on SQLite and a `tsvector` index on Postgres.
645
-
646
- ### On Postgres
647
-
648
- `stitchkit/agent-runtime/postgres` is the same store on Postgres, over the
649
- application's own client:
650
-
651
- ```ts
652
- import { SQL } from 'bun'
653
- import { createPostgresAgentRuntimeStore } from 'stitchkit/agent-runtime/postgres'
654
-
655
- const sql = new SQL(process.env.DATABASE_URL)
656
- const { store, conversations, host } = createPostgresAgentRuntimeStore<SQL>({
657
- transaction: (work) => sql.begin((tx) => work(tx)),
658
- query: (tx, text, parameters) => tx.unsafe(text, [...parameters]),
659
- })
660
- ```
661
-
662
- With Prisma, `transaction: (work) => prisma.$transaction(work)` and
663
- `query: (tx, text, parameters) => tx.$queryRawUnsafe(text, ...parameters)`.
664
-
665
- The store owns its transactions, unlike the sync store, which writes inside
666
- the application's transaction so a change commits with the application's own
667
- rows. Every write runs SERIALIZABLE, and a serialization conflict — on any
668
- statement, or on `COMMIT` — is cured only by running the whole unit again,
669
- which only the code that opened the transaction can do. So `transaction` must
670
- open a fresh transaction on every call, and the store's isolation statement is
671
- the first in it; a transaction the application already used is refused in
672
- words. Retrying is the driver's duty: `withStoreRetries` around a store call
673
- does not replace it.
674
-
675
- The schema is versioned and created on first use under an advisory lock, so
676
- processes starting at once agree on it; a schema of another version or with
677
- tables missing is refused, not repaired. When migrations own the schema, pass
678
- `createTables: false` and put `postgresAgentRuntimeStoreDdl(prefix)` in one;
679
- the version is still checked. `prefix` (default `stitchkit_agent_runtime`)
680
- keeps two stores in one database apart. Identifiers and timestamps are stored
681
- as written, byte for byte, so an archive exported from Postgres imports into
682
- SQLite and back unchanged.
683
-
684
- `conversations.messages` pages the model's history: what compaction removed is
685
- not in it, which is the point of compaction. A person reading back their own
686
- conversation needs the other view, and asks for it explicitly:
687
-
688
- ```ts
689
- const page = await conversations.messages({
690
- conversationId,
691
- limit: 50,
692
- direction: 'after',
693
- includeCompacted: true,
694
- })
695
- const removed = new Set(page.compacted)
696
- ```
697
-
698
- `items` stays one sequence in the order it happened, and `compacted` names the
699
- ids inside it that the model no longer sees — the boundary is a mark on the
700
- conversation, not a second list. A compaction summary sits at the position of
701
- the last message it replaced, so the block reads through and the summary
702
- arrives after it, where it was written; in the model's history, where every
703
- replaced message is gone, it occupies the block's place either way. Without
704
- the flag the page is exactly what it was, `compacted`
705
- empty. The v1 → v2 migration baseline records the same thing: the whole
706
- sequence, with `compacted` naming what had been folded away. A file migrated
707
- by 0.86.0 has a baseline built from the active history only — the messages
708
- themselves are still in the store and this read reaches them, but that one
709
- event cannot be rewritten after the fact.
710
-
711
- ### Retried provider streams
712
-
713
- With `loop.retry` set, a provider stream that fails before any tool call in the
714
- attempt is retried at the step boundary. Subscribers see `attempt-reset` for the
715
- run before the next attempt's first delta and drop what the failed attempt
716
- streamed; the durable draft is checkpointed after that output is discarded; an
717
- input injected into the failed attempt is taken again by the retry; and the
718
- failed attempt's reported usage stays in the run's spend. Transient events —
719
- deltas, reasoning, `attempt-reset` — are numbered from 1 per run, counting only
720
- what was published, so a cursor sees no gap on an ordinary stream.
package/llms/contract.txt CHANGED
@@ -542,7 +542,8 @@ from the root `stitchkit`.
542
542
  | `ContractDef` | _type_ | a defined contract |
543
543
  | `PathParams` | _type_ | infer named `:segments` and a terminal `*wildcard` from a path literal as string params |
544
544
  | `ContractMeta` | _type_ | a contract's `prefix` + optional `scope` and `meta` (a default every endpoint shallow-merges over) |
545
- | `EndpointDef` | _type_ | a single endpoint definition; `output` declares JSON response presence (`null` is data, `undefined` is invalid); optional `effect?: OperationEffect` declares `'read' \| 'write'` side effects; `safelistedBody: true` admits the JSON body as `text/plain` from an allow-listed `Origin` — [guide](../guide/server.md#safelisted-request-bodies-beacons) |
545
+ | `EndpointDef` | _type_ | a single endpoint definition; `output` declares JSON response presence (`null` is data, `undefined` is invalid); optional `timeout` bounds both client calls and server-side deadline clamping; optional `effect?: OperationEffect` declares `'read' \| 'write'` side effects; `safelistedBody: true` admits the JSON body as `text/plain` from an allow-listed `Origin` — [guide](../guide/server.md#safelisted-request-bodies-beacons) |
546
+ | `DEADLINE_BUDGET_HEADER` | constant | `'x-stitchkit-timeout-ms'` — relative remaining call budget in integer milliseconds propagated across HTTP hops (`createHttpClient` / `createClient` outbound, `createHandler` / `createServer` inbound with contract-ceiling clamping, `408 REQUEST_TIMEOUT` on `'0'`, linked `ctx.signal`, and `ctx.remainingTimeoutMs(reserveMs?)`) |
546
547
  | `OperationEffect` / `OperationEffectSchema` | _type_ / schema | closed `'read' \| 'write'` side-effect classification declared on contract endpoints |
547
548
  | `contractOperationEffects` / `requireContractOperationEffects` | function | project declared endpoint `effect` tags from a contract; `requireContractOperationEffects` fails closed and lists every operation missing `effect` |
548
549
  | `withToolView` | function | declare an endpoint's call and answer on the tool surface (MCP, AGENT, CLI): input `defaults`, and optionally a view `output` and a `project`, typed against the endpoint's own schemas; HTTP keeps the full answer — [guide](../guide/mcp-and-agents.md#a-different-answer-for-tools--withtoolview) |
@@ -0,0 +1,34 @@
1
+ # stitchkit/device-relay — stitchkit docs slice
2
+
3
+ > Generated from the `docs/` tree by `bun run gen:llms`. The index of all slices is
4
+ > `llms.txt` in this package.
5
+
6
+ Contains: API reference: `stitchkit/device-relay` (docs/api/reference.md)
7
+
8
+ Also read:
9
+ - see `llms/server.txt` for the Realtime guide
10
+
11
+ ==============================================================================
12
+ # API reference: `stitchkit/device-relay` (docs/api/reference.md)
13
+ ==============================================================================
14
+
15
+ ## `stitchkit/device-relay`
16
+
17
+ Peer-free, browser- and Hermes-safe User Device Relay over realtime. Multiplexes unary Fetch RPCs
18
+ and credit-paced resumable cursor streams over a single outbound realtime connection from a user's
19
+ desktop machine to a multi-tenant backend hub.
20
+
21
+ | Export | Kind | Summary |
22
+ |--------|------|---------|
23
+ | `createDeviceRelayHub` / `DeviceRelayHub` / `DeviceRelayHubConfig` / `DeviceRelayFetchOptions` / `DeviceRelayStreamOpenOptions` | function / _types_ | backend hub binding authenticated `(accountId, deviceId)` sockets with conservative heartbeat leases, strict owner-only default access (`FORBIDDEN` for foreign accounts), Fetch-compatible `createRelayFetch`, and `openRelayStream` (with optional `share: true` fan-out that closes upstream when the last subscriber leaves) |
24
+ | `DeviceRelayRealtimeServer` / `DeviceRelayServerConnection` / `DeviceRelayRawSocket` / `DeviceRelayDeviceAuthInput` / `DeviceRelayAuthenticatedDevice` / `DeviceRelayAccessRequest` | _types_ | peer-free structural server contracts satisfied directly by `bindRealtimeServer(deviceRelayRealtimeContract, io)` |
25
+ | `createDeviceRelayAgent` / `DeviceRelayAgent` / `DeviceRelayAgentConfig` / `DeviceRelayAgentState` / `DeviceRelayRpcAllowRule` / `DeviceRelayAgentStreamInput` / `DeviceRelayUpstreamFrame` | function / _types_ | desktop-side relay agent with default-deny local allowlists (`allowRpc`, `allowStreamTopics`), credit-paced stream pumping, bounded payloads, and non-retryable auth refusal handling |
26
+ | `createMemoryRelayBroker` / `RelayBrokerPort` / `RelayBrokerInstanceHandler` / `RelayBrokerStreamHandle` / `RelayBrokerStreamSink` | function / _types_ | multi-replica routing port (`RelayBrokerPort`) and in-memory default broker (`createMemoryRelayBroker`) |
27
+ | `DeviceRelayStream` / `DeviceRelayStreamFrame` | _types_ | async-iterable cursor stream handle and yielded frame shape |
28
+ | `deviceRelayRealtimeContract` | const | namespaced Zod-validated `RealtimeContract` (`stitchkit.relay.*` hello, heartbeat, unary RPC and cursor stream frames) |
29
+ | `DeviceRelayError` / `DeviceRelayErrorCodeSchema` / `DeviceRelayErrorCode` / `DeviceRelayDeliveryStateSchema` / `DeviceRelayDeliveryState` / `isDeviceRelayRetryableCode` / `isRetryableDeviceRelayError` | class / schemas / functions | typed relay error vocabulary separating retryable transport/offline faults from non-retryable refusals and carrying honest `delivery` (`not-sent`, `unknown`, `delivered`) |
30
+ | `DeviceRelayStateSchema` / `DeviceRelayState` / `DeviceRelayStatusSchema` / `DeviceRelayStatus` / `DeviceRelayOfflineReasonSchema` / `DeviceRelayOfflineReason` | schemas / _types_ | live presence snapshot, status (`online`, `offline`) and offline transition reasons (`disconnected`, `lease-expired`, `replaced`, `closed`) |
31
+ | `DeviceRelayHelloSchema` / `DeviceRelayHello` / `DeviceRelayHelloAckSchema` / `DeviceRelayHelloAck` / `DeviceRelayHeartbeatSchema` / `DeviceRelayHeartbeat` / `DeviceRelayHeartbeatAckSchema` / `DeviceRelayHeartbeatAck` | schemas / _types_ | handshake registration and lease renewal wire frames |
32
+ | `DeviceRelayRpcRequestSchema` / `DeviceRelayRpcRequest` / `DeviceRelayRpcCancelSchema` / `DeviceRelayRpcCancel` / `DeviceRelayRpcResponseSchema` / `DeviceRelayRpcResponse` / `DeviceRelayHeaderEntrySchema` / `DeviceRelayHeaderEntry` / `DeviceRelayBodyEncodingSchema` / `DeviceRelayBodyEncoding` | schemas / _types_ | unary HTTP-over-realtime request, cancel and response wire frames |
33
+ | `DeviceRelayStreamOpenSchema` / `DeviceRelayStreamOpen` / `DeviceRelayStreamOpenAckSchema` / `DeviceRelayStreamOpenAck` / `DeviceRelayStreamCreditSchema` / `DeviceRelayStreamCredit` / `DeviceRelayStreamCloseSchema` / `DeviceRelayStreamClose` / `DeviceRelayStreamEventSchema` / `DeviceRelayStreamEvent` / `DeviceRelayJsonValueSchema` / `DeviceRelayJsonValue` | schemas / _types_ | cursor stream open, ack, credit, close and event wire frames |
34
+ | `DEVICE_RELAY_ORIGIN` / `DEFAULT_DEVICE_RELAY_LEASE_TTL_MS` / `DEFAULT_DEVICE_RELAY_HEARTBEAT_INTERVAL_MS` / `DEFAULT_DEVICE_RELAY_RPC_TIMEOUT_MS` / `DEFAULT_DEVICE_RELAY_MAX_REQUEST_BYTES` / `DEFAULT_DEVICE_RELAY_MAX_RESPONSE_BYTES` / `DEFAULT_DEVICE_RELAY_MAX_STREAM_FRAME_BYTES` / `DEFAULT_DEVICE_RELAY_MAX_IN_FLIGHT_RPCS` / `DEFAULT_DEVICE_RELAY_MAX_CONCURRENT_STREAMS` / `DEFAULT_DEVICE_RELAY_MAX_BUFFERED_FRAMES` | consts | declared default bounds and synthetic path-parsing origin |
package/llms/realtime.txt CHANGED
@@ -5,6 +5,9 @@
5
5
 
6
6
  Contains: API reference: `stitchkit/realtime` (docs/api/reference.md)
7
7
 
8
+ Also read:
9
+ - see `llms/server.txt` for the Realtime guide
10
+
8
11
  ==============================================================================
9
12
  # API reference: `stitchkit/realtime` (docs/api/reference.md)
10
13
  ==============================================================================
@@ -40,3 +43,20 @@ Native consumers import HTTP factories, `ApiError`, `createUrlBuilder`,
40
43
  `RealtimeClient`, `defineRealtimeContract`, `InferRealtimeEventMap`, `createRetainedTopics`
41
44
  and `RetainedTopics` from `stitchkit/realtime`. `createQueryClientFactory` remains in
42
45
  `stitchkit/react`. Shared modules must use the same public leaves throughout their graph.
46
+
47
+ ### Account device presence and remote command bus
48
+
49
+ Share one realtime connection across account-scoped online device presence, live capability state
50
+ slots (media playback, active reading, relay status) and targeted remote commands with structured
51
+ acknowledgements (`ok`, `DEVICE_OFFLINE`, `FORBIDDEN`, `TIMEOUT`, `UNSUPPORTED_CAPABILITY`,
52
+ `HANDLER_ERROR`, `INVALID_COMMAND`, `DISCONNECTED`). Mount the server side with
53
+ `bindDevicePresence` from `stitchkit/server`.
54
+
55
+ | Export | Kind | Summary |
56
+ |--------|------|---------|
57
+ | `createDevicePresenceContract` / `DevicePresenceContract` / `DevicePresenceContractOptions` / `DevicePresenceCapabilityDef` / `DevicePresenceCapabilityMap` / `DevicePresenceCapabilityKey` / `DevicePresenceCapabilityResult` / `DevicePresenceEventNames` / `DevicePresenceSchemas` | function / _types_ | capability-driven strict Zod contract (`{ [capability]: { state, command, result? } }`) generating namespaced wire events and schemas |
58
+ | `createDevicePresenceClient` / `DevicePresenceClient` / `DevicePresenceClientConfig` / `DevicePresenceSubscriber` / `DevicePresenceSendCommandInput` / `DevicePresenceCommandHandler` / `DevicePresenceCommandContext` | function / _types_ | typed browser / native client over `RealtimeClientTransport` with `subscribe`, `publishState`, `sendCommand`, `onCommand`, automatic re-announce and local state republication after reconnect |
59
+ | `createDevicePresenceRelayAdapter` / `DevicePresenceRelayAdapter` / `DevicePresenceRelayAdapterConfig` / `DevicePresenceRelayStateSource` / `DevicePresenceRelayStateSchema` / `DevicePresenceRelayState` | function / schema / _types_ | connects a desktop or mobile relay host's lifecycle state to a presence capability slot over the shared socket |
60
+ | `DevicePresenceIdentitySchema` / `DevicePresenceIdentity` / `DevicePresenceErrorCodeSchema` / `DevicePresenceErrorCode` | schemas / _types_ | strict device identity metadata and closed error code vocabulary |
61
+ | `DevicePresenceDevice` / `DevicePresenceSnapshot` / `DevicePresenceStates` / `DevicePresenceStatesInput` / `DevicePresenceAnnouncePayload` / `DevicePresenceAnnounceAck` / `DevicePresenceStateUpdatePayload` / `DevicePresenceStateUpdateAck` / `DevicePresenceCommandRequest` / `DevicePresenceCommandDelivery` / `DevicePresenceCommandResult` | _types_ | inferred account presence snapshot, state update and targeted remote command wire payloads |
62
+ | `DEFAULT_DEVICE_PRESENCE_PREFIX` / `DEFAULT_DEVICE_PRESENCE_COMMAND_TIMEOUT_MS` / `DEFAULT_DEVICE_PRESENCE_REQUEST_TIMEOUT_MS` | consts | default event namespace prefix and timeout bounds |