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
package/llms-full.txt CHANGED
@@ -28,9 +28,9 @@ bun add stitchkit zod
28
28
 
29
29
  `zod` is a required peer — schemas are the source of truth everywhere. Other
30
30
  peers are optional and pulled in only when you use the matching feature
31
- (`@modelcontextprotocol/server` for MCP servers, `ai` for agents, `socket.io*` for
32
- realtime, `@tanstack/react-query` + `react-query-kit` for React). See
33
- [deps](#dependencies) below.
31
+ (`@modelcontextprotocol/server` for MCP servers, `ai` for AI SDK adapters,
32
+ `socket.io*` for realtime, `@tanstack/react-query` + `react-query-kit` for
33
+ React). See [deps](#dependencies) below.
34
34
 
35
35
  ## Entrypoints
36
36
 
@@ -47,83 +47,87 @@ own, recorded as an ADR.
47
47
 
48
48
  | Import | Use in | Maturity | Holds |
49
49
  |--------|--------|----------|-------|
50
- | `stitchkit` | browser **and** server | stable<br>_redefined in 5 of the 40 minors since 0.94.0, most recently 0.127.0_ | `defineContract`, `createClient`, `createHttpClient`, `createSocketIOClient`, `parseSSE`, the error model |
51
- | `stitchkit/http` | browser, React Native/Hermes **and** server | evolving<br>_redefined in 2 of the 40 minors since 0.94.0, most recently 0.127.0_ | typed HTTP client factories and `ApiError`, without optional realtime peers |
52
- | `stitchkit/realtime` | browser, React Native/Hermes **and** server | evolving<br>_redefined in 1 of the 40 minors since 0.94.0, most recently 0.127.0_ | typed realtime clients, binding to an existing socket and retained topics with a required explicit Socket.IO peer loader |
53
- | `stitchkit/contract` | browser **and** server | stable<br>_redefined in 5 of the 40 minors since 0.94.0, most recently 0.127.0_ | the contract layer alone — `defineContract`, errors, pagination |
54
- | `stitchkit/live` | browser **and** server | evolving<br>_redefined in 2 of the 40 minors since 0.94.0, most recently 0.127.0_ | `defineEvents` — topic declarations beside the operation contract — and watched reads: `createWatchClient`, the value/difference frame and its reassembly |
55
- | `stitchkit/primitives` | browser **and** server | evolving<br>_redefined in 0 of the 40 minors since 0.94.0_ | generic values and declarations for lifecycle, access, audit, delivery and exports, exact money and rounding tables |
56
- | `stitchkit/handler` | browser, React Native/Hermes **and** server | evolving<br>_redefined in 0 of the 7 minors since 0.127.0_ | portable `createHandler`, `implement`, errors and `serveBridge` over a string `postMessage` port, with no Node built-ins |
57
- | `stitchkit/server` | server (Bun) | stable<br>_redefined in 5 of the 40 minors since 0.94.0, most recently 0.127.0_ | `createServer`, `implement`, hooks, auth, Socket.IO server, server primitives |
58
- | `stitchkit/node` | server (Node ≥ 22.3) | stable<br>_redefined in 2 of the 40 minors since 0.94.0, most recently 0.127.0_ | `serveNode` + the runtime-agnostic core — the Node mirror of `/server` |
59
- | `stitchkit/tools` | server | stable<br>_redefined in 10 of the 40 minors since 0.94.0, most recently 0.127.0_ | the transport-neutral tool layer — registry, tool names and manifest, runtime tools, native tools, the OAuth provider, the durability engine; loads no optional peer at runtime |
60
- | `stitchkit/tools/mcp` | server (Bun or Node) | evolving<br>_redefined in 3 of the 40 minors since 0.94.0, most recently 0.127.0_ | the canonical MCP HTTP/stdio server, schemas and typed MCP presenters; only Zod and the MCP server SDK peers |
61
- | `stitchkit/tools/agent` | server (Bun or Node) | evolving<br>_redefined in 1 of the 40 minors since 0.94.0, most recently 0.127.0_ | `mountAgent` — a contract's operations as AI SDK tools; only Zod and the `ai` peer |
62
- | `stitchkit/tools/toolkit` | server (Bun or Node) | evolving<br>_redefined in 1 of the 40 minors since 0.94.0, most recently 0.127.0_ | `createToolkit` — one tool set served over MCP and to an AI SDK agent; the MCP server SDK and `ai` peers |
63
- | `stitchkit/tools/contract` | browser + server | evolving<br>_redefined in 2 of the 40 minors since 0.94.0, most recently 0.124.0_ | the shapes a tool surface speaks — async-operation contract, snapshot and cancel schemas, view-file input/output — without the runtime that serves them |
64
- | `stitchkit/tools/invoker` | server | stable<br>_redefined in 3 of the 40 minors since 0.94.0, most recently 0.127.0_ | peer-free `createToolInvoker` over the canonical contract tool runner |
65
- | `stitchkit/tools/connections` | server (Bun or Node) | evolving<br>_redefined in 3 of the 40 minors since 0.94.0, most recently 0.127.0_ | consume external MCP servers and a bounded OpenAPI subset — typed reauthorization, a per-request host fence and per-call credentials |
66
- | `stitchkit/cli` | server | stable<br>_redefined in 12 of the 40 minors since 0.94.0, most recently 0.128.0_ | `createCli` / `createCliInvoker` — runtime and strict NodeNext declarations without MCP SDK / `ai` |
67
- | `stitchkit/cli/publish` | build and release tooling (Bun or Node, POSIX) | evolving<br>_redefined in 0 of the 40 minors since 0.94.0_ | `publishCli` — commit a verified CLI distribution and move its public manifest last; see [CLI guide](cli.md#publishing-a-complete-version) |
68
- | `stitchkit/remote` | browser **and** server | stable<br>_redefined in 1 of the 40 minors since 0.94.0, most recently 0.104.0_ | peer-free `implementRemote` for thin HTTP proxy processes |
69
- | `stitchkit/process` | server (Bun or Node, POSIX) | evolving<br>_redefined in 4 of the 40 minors since 0.94.0, most recently 0.133.0_ | finite native commands, byte sinks, bounded capture, process-group cancellation and opt-in Linux/Darwin owner-loss cleanup; contract operations executed in one-call child processes |
70
- | `stitchkit/process/bootstrap` | bundled server entry (Bun, POSIX) | evolving<br>_redefined in 0 of the 1 minor since 0.133.0_ | narrow bootstrap that keeps the process runner lazy while carrying the package's own invocations — the owner-loss guard and the process root of launched work — in a single-file bundle |
71
- | `stitchkit/files/packaging` | build time (Bun or Node) | evolving<br>_redefined in 4 of the 40 minors since 0.94.0, most recently 0.133.0_ | installed native asset graph, integrity, Bun packaging plugin and the artifact loader check; a client bundled into one self-contained, hashed file; a typed client built into a proven npm package with several entries, declarations and external peers; no runtime install policy |
72
- | `stitchkit/files` | server (Bun or Node) | stable<br>_redefined in 5 of the 40 minors since 0.94.0, most recently 0.133.0_ | peer-free managed local-file boundary |
73
- | `stitchkit/spend` | server (Bun or Node) | evolving<br>_redefined in 0 of the 7 minors since 0.127.0_ | peer-free spend gateway for paid model APIs: the attempt recorded before the call and closed on every outcome, credentials only for the provider's origin, a spooled ledger, rank-merged receipts and a reconciler |
74
- | `stitchkit/spend/testing` | tests on Bun or Node | evolving<br>_redefined in 0 of the 7 minors since 0.127.0_ | the coverage guard: red on a model SDK import, a provider key or a provider host outside the gateway files |
75
- | `stitchkit/service-host` | server (Bun or Node) | evolving<br>_redefined in 0 of the 7 minors since 0.127.0_ | peer-free host service supervision — verified versioned artifact activation, Linux `systemd` and macOS `launchd` units (`plutil`, `bootout`/`bootstrap`, rollback), live process/Unix-socket identity verification, and an in-process config-watched reloader |
76
- | `stitchkit/service-host/macos` | server (Bun or Node, macOS) | evolving<br>_redefined in 0 of the 7 minors since 0.127.0_ | peer-free macOS daemon bundle toolkit — fail-closed Developer ID `codesign`, strict C11 launcher `.app` bundles with atomic `RENAME_SWAP` install/rollback, Apple 824×824 squircle `AppIcon.icns`, streaming `lsregister` maintenance, and TCC responsibility inspection |
77
- | `stitchkit/service-host/work` | server (Bun or Node; Linux with systemd ≥ 254, or a process root on Linux and macOS) | evolving<br>_redefined in 0 of the 1 minor since 0.133.0_ | peer-free launch of work in its own boundary with a declared owner — a transient systemd scope or a recorded process root, the typed owner record, the one inherited variable that names the boundary, and the membership check that asks the boundary; see [native I/O](native-io.md#work-in-its-own-boundary) |
78
- | `stitchkit/telegram` | server (Bun or Node) | evolving<br>_redefined in 8 of the 40 minors since 0.94.0, most recently 0.127.0_ | peer-free Telegram platform primitives — Mini App `initData` verification, widget limits and the `widget_query` and widget message schemas, send-failure classification, one outbound budget per bot token with weighted albums and per-chat 429 pauses, resumable broadcasts, the operator channel with dedupe, a Bot API transport that separates a request that never left from an unknown outcome, local Bot API files, the waveform of a voice message read from its PCM, webhook ownership and durable webhook update intake |
79
- | `stitchkit/telegram/grammy` | server (Bun or Node) | evolving<br>_redefined in 0 of the 40 minors since 0.94.0_ | the token's outbound budget as one grammY client transformer — a 429 that comes back as a response pauses its chat, and a cancelled wait is a request that never left; the widget methods over the same client |
80
- | `stitchkit/telegram/html` | browser and server | evolving<br>_redefined in 1 of the 40 minors since 0.94.0, most recently 0.127.0_ | Telegram's HTML as a tree — compile GFM Markdown to Telegram HTML with fence-aware splitting, clean any markup to what Telegram accepts, cut long text into valid parts by what the reader sees, check markup before it is sent |
81
- | `stitchkit/telegram/voice` | browser and server | evolving<br>_redefined in 0 of the 40 minors since 0.94.0_ | the waveform of a voice message as one format — packed for `sendVoice` the way Telegram Desktop scales it, unpacked to draw it, a `getMe` read of whether the server takes it |
82
- | `stitchkit/telegram/screens` | server (Bun or Node) | evolving<br>_redefined in 1 of the 40 minors since 0.94.0, most recently 0.127.0_ | a bot's menus as declared screens over grammY — typed paths, actions and input, message reconciliation, state in any `StorageAdapter`, a test chat |
83
- | `stitchkit/tracking` | browser **and** server | evolving<br>_redefined in 3 of the 40 minors since 0.94.0, most recently 0.127.0_ | visitor-tracking mechanics — `createTrackingClient`, the tab-shared outbox, the page-leave beacon, attribution, the contract factory; no event vocabulary, no React |
84
- | `stitchkit/tracking/contract` | browser **and** server | evolving<br>_redefined in 0 of the 40 minors since 0.94.0_ | the wire shapes — the contract factory, event and visit schemas, the performance sample and its trust threshold; brings `zod` |
85
- | `stitchkit/tracking/performance` | browser **and** server | evolving<br>_redefined in 1 of the 40 minors since 0.94.0, most recently 0.127.0_ | Web Vitals from real visitors, collected after load through the optional peer `web-vitals`; no `zod` |
86
- | `stitchkit/tracking/server` | server (Bun or Node) | evolving<br>_redefined in 0 of the 40 minors since 0.94.0_ | the decisions a tracking backend makes — dispositions, visit lease over an application-owned store, active intervals, presence; no database |
87
- | `stitchkit/release` | browser **and** server | evolving<br>_redefined in 1 of the 40 minors since 0.94.0, most recently 0.127.0_ | a page follows the release it was built for — `createReleaseMarker` on the server, `createReleaseWatcher` in the browser, the `X-Build-Id` header and a socket event between them |
88
- | `stitchkit/voice` | browser **and** server | evolving<br>_redefined in 0 of the 40 minors since 0.94.0_ | the mechanics of a live voice reply — `SentenceCutter`, `speakableText`, a `SpeechQueue` that synthesises ahead and stops on interruption, the conversation phases |
89
- | `stitchkit/sync` | browser **and** server | evolving<br>_redefined in 1 of the 7 minors since 0.127.0, most recently 0.132.0_ | the client half of an offline-first sync — which outbox rows leave next, pending edits on top of remote rows, deletes that win until acknowledged, the cursor session, the push and page wire with an open outcome vocabulary; no driver, runs in Hermes |
90
- | `stitchkit/sync/postgres` | server (Bun or Node) | evolving<br>_redefined in 0 of the 7 minors since 0.127.0_ | the server half — versions that commit in order, a ledger that runs each change once, a feed of what changed, inside the app's own transaction; a memory store and `checkSyncStore` |
91
- | `stitchkit/geo` | server (Bun or Node) | evolving<br>_redefined in 2 of the 40 minors since 0.94.0, most recently 0.127.0_ | managed GeoIP reader generations, last-known-good reload and the optional MaxMind adapter |
92
- | `stitchkit/geo/contract` | browser **and** server | evolving<br>_redefined in 0 of the 40 minors since 0.94.0_ | the place snapshot schema, for a shared contract that stores or sends `GeoAttribution`; brings `zod` |
93
- | `stitchkit/xlsx` | browser **and** server | evolving<br>_redefined in 0 of the 40 minors since 0.94.0_ | a workbook from rows and typed columns, with no dependency; text never runs as a formula |
94
- | `stitchkit/oauth` | browser **and** server | evolving<br>_redefined in 0 of the 40 minors since 0.94.0_ | provider-neutral Authorization Code + PKCE request and one-shot callback transaction mechanics |
95
- | `stitchkit/google` | server (Bun or Node) | evolving<br>_redefined in 1 of the 40 minors since 0.94.0, most recently 0.127.0_ | optional Google code exchange and verified OIDC identity adapter |
96
- | `stitchkit/observability` | server | stable<br>_redefined in 1 of the 40 minors since 0.94.0, most recently 0.127.0_ | request/tool event projections — `createObservability`, trace context, sanitisation |
97
- | `stitchkit/testing` | tests on Bun or Node | stable<br>_redefined in 3 of the 40 minors since 0.94.0, most recently 0.127.0_ | in-process generated clients over a real Fetch handler, the managed-resource conformance kit and manual time for schedules and retries |
98
- | `stitchkit/declaration` | browser + build and deployment tooling (Bun or Node) | evolving<br>_redefined in 1 of the 40 minors since 0.94.0, most recently 0.128.0_ | `ProjectDeclarationSchema` — the one machine-readable statement a repository makes about itself |
99
- | `stitchkit/react` | browser + server rendering | stable<br>_redefined in 2 of the 40 minors since 0.94.0, most recently 0.127.0_ | `createCursorQuery`, `createCacheBridge`, QueryClient and `ApiError` retry policy |
100
- | `stitchkit/react/keyboard` | browser | evolving<br>_redefined in 1 of the 40 minors since 0.94.0, most recently 0.115.0_ | which part of a screen gets a key — ordered layers, one Escape per level, list zones with real focus; see [keyboard guide](keyboard.md) |
101
- | `stitchkit/react/keyboard/testing` | server (Bun or Node) | evolving<br>_redefined in 0 of the 40 minors since 0.94.0_ | the keyboard layers and zones without a DOM — fakes for the window, elements and key events beside the two engines, to test the order of layers, `scope`/`inert` and the edges of a zone in milliseconds |
102
- | `stitchkit/agent-runtime` | server | evolving<br>_redefined in 9 of the 40 minors since 0.94.0, most recently 0.128.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
103
- | `stitchkit/agent-runtime/sandbox` | server | evolving<br>_redefined in 0 of the 40 minors since 0.94.0_ | optional Linux Bubblewrap sessions, host sandbox capability probes, durable workspaces and a host HTTP credential gateway; see [sandbox guide](sandbox.md) |
104
- | `stitchkit/agent-runtime/testing` | tests on Bun or Node | evolving<br>_redefined in 2 of the 40 minors since 0.94.0, most recently 0.127.0_ | credential-free replay, scripted provider faults, deterministic race controls and the agent-store conformance kit |
105
- | `stitchkit/agent-runtime/harness` | server | evolving<br>_redefined in 0 of the 40 minors since 0.94.0_ | resource-aware process-local facade over the canonical Agent runtime; supervision stays outside |
106
- | `stitchkit/agent-runtime/coding-tools` | server (Bun or Node) | evolving<br>_redefined in 3 of the 40 minors since 0.94.0, most recently 0.127.0_ | bounded host-authorized direct file and shell tools; a root boundary, not an OS sandbox |
107
- | `stitchkit/agent-runtime/openrouter` | server | evolving<br>_redefined in 1 of the 40 minors since 0.94.0, most recently 0.127.0_ | isolated OpenRouter language-model adapter |
108
- | `stitchkit/agent-runtime/browser` | browser + server | evolving<br>_redefined in 2 of the 40 minors since 0.94.0, most recently 0.127.0_ | canonical agent records, events, reconnect cursor and optional conversation controller |
109
- | `stitchkit/agent-runtime/react` | browser + server | evolving<br>_redefined in 0 of the 40 minors since 0.94.0_ | React subscription to an application-owned agent controller |
110
- | `stitchkit/agent-runtime/realtime` | server (Bun or Node) | evolving<br>_redefined in 2 of the 40 minors since 0.94.0, most recently 0.127.0_ | authorized agent control over the existing Socket.IO server |
111
- | `stitchkit/agent-executor` | server (Bun or Node) | evolving<br>_redefined in 4 of the 7 minors since 0.127.0, most recently 0.133.0_ | the executor ↔ server contract for external coding agents (Claude Code, Codex, ACP): delta vocabulary over the shared message parts, thread leases with a fence, turn phases and their reports |
112
- | `stitchkit/agent-executor/claude` | server (Bun or Node) | evolving<br>_redefined in 0 of the 7 minors since 0.127.0_ | the Claude Code driver: the unmodified CLI over `stream-json`, permission requests answered by the host, reconcile by the input's id in the profile's transcript |
113
- | `stitchkit/agent-executor/claude-sdk` | server (Bun or Node) | evolving<br>_redefined in 1 of the 7 minors since 0.127.0, most recently 0.131.0_ | Claude through the Agent SDK: the application's `query` (optional peer `@anthropic-ai/claude-agent-sdk`), the CLI's classifier, `canUseTool` asked of the host |
114
- | `stitchkit/agent-executor/acp` | server (Bun or Node) | evolving<br>_redefined in 0 of the 7 minors since 0.127.0_ | an Agent Client Protocol v1 agent over stdio: settings by category, images, MCP servers, `session/resume`/`load`/`list`, `session/cancel`; no reconcile |
115
- | `stitchkit/agent-executor/codex` | server (Bun or Node) | evolving<br>_redefined in 3 of the 7 minors since 0.127.0, most recently 0.133.0_ | the Codex driver: `codex app-server` over stdio or Unix-socket WebSocket (`unix-listen` / `unix-connect`), thread policy and live controls, approval and input requests answered by the host, unknown server requests refused, reconcile by the client id in `thread/turns/list` |
116
- | `stitchkit/agent-executor/testing` | server (Bun or Node) | evolving<br>_redefined in 1 of the 7 minors since 0.127.0, most recently 0.133.0_ | the engine conformance kit, deterministic replay driver, portable fake Codex app-server, fail-loud consumer stub factories, and schema-validated test fixtures; no optional peer |
117
- | `stitchkit/agent-executor/testing/claude-sdk` | server (Bun or Node) | evolving<br>_redefined in 0 of the 1 minor since 0.133.0_ | the multi-turn fake Claude SDK query harness and the Claude SDK session stub, typed by the optional peer `@anthropic-ai/claude-agent-sdk` |
118
- | `stitchkit/agent-runtime/postgres` | server (Bun or Node) | evolving<br>_redefined in 0 of the 7 minors since 0.127.0_ | the agent store, conversation reader and companion host on Postgres, over the application's own client (Bun SQL, Prisma, `pg`) |
119
- | `stitchkit/agent-runtime/sqlite/bun` | server (Bun) | evolving<br>_redefined in 1 of the 40 minors since 0.94.0, most recently 0.127.0_ | durable built-in SQLite store for the agent runtime |
120
- | `stitchkit/agent-runtime/sqlite/node` | server (Node ≥ 22.5) | evolving<br>_redefined in 1 of the 40 minors since 0.94.0, most recently 0.127.0_ | durable built-in SQLite store for the agent runtime |
50
+ | `stitchkit` | browser **and** server | stable<br>_redefined in 5 of the 41 minors since 0.94.0, most recently 0.127.0_ | `defineContract`, `createClient`, `createHttpClient`, `createSocketIOClient`, `parseSSE`, the error model |
51
+ | `stitchkit/http` | browser, React Native/Hermes **and** server | evolving<br>_redefined in 2 of the 41 minors since 0.94.0, most recently 0.127.0_ | typed HTTP client factories and `ApiError`, without optional realtime peers |
52
+ | `stitchkit/realtime` | browser, React Native/Hermes **and** server | evolving<br>_redefined in 1 of the 41 minors since 0.94.0, most recently 0.127.0_ | typed realtime clients, binding to an existing socket and retained topics with a required explicit Socket.IO peer loader |
53
+ | `stitchkit/device-relay` | browser, React Native/Hermes **and** server | evolving<br>_redefined in 0 of the 1 minor since 0.134.0_ | peer-free User Device Relay over realtime — `createDeviceRelayHub`, `createDeviceRelayAgent`, `createMemoryRelayBroker`, `deviceRelayRealtimeContract`, Fetch-compatible unary RPC and credit-paced cursor streams |
54
+ | `stitchkit/contract` | browser **and** server | stable<br>_redefined in 5 of the 41 minors since 0.94.0, most recently 0.127.0_ | the contract layer alone — `defineContract`, errors, pagination |
55
+ | `stitchkit/live` | browser **and** server | evolving<br>_redefined in 2 of the 41 minors since 0.94.0, most recently 0.127.0_ | `defineEvents` — topic declarations beside the operation contract — and watched reads: `createWatchClient`, the value/difference frame and its reassembly |
56
+ | `stitchkit/primitives` | browser **and** server | evolving<br>_redefined in 0 of the 41 minors since 0.94.0_ | generic values and declarations for lifecycle, access, audit, delivery and exports, exact money and rounding tables |
57
+ | `stitchkit/handler` | browser, React Native/Hermes **and** server | evolving<br>_redefined in 0 of the 8 minors since 0.127.0_ | portable `createHandler`, `implement`, errors and `serveBridge` over a string `postMessage` port, with no Node built-ins |
58
+ | `stitchkit/server` | server (Bun) | stable<br>_redefined in 5 of the 41 minors since 0.94.0, most recently 0.127.0_ | `createServer`, `implement`, hooks, auth, Socket.IO server, server primitives |
59
+ | `stitchkit/node` | server (Node ≥ 22.3) | stable<br>_redefined in 2 of the 41 minors since 0.94.0, most recently 0.127.0_ | `serveNode` + the runtime-agnostic core — the Node mirror of `/server` |
60
+ | `stitchkit/tools` | server | stable<br>_redefined in 11 of the 41 minors since 0.94.0, most recently 0.134.0_ | the transport-neutral tool layer — `mountAgentTools`, `defineAgentTool`, registry, tool names and manifest, runtime tools, native tools, the OAuth provider, the durability engine; loads no optional peer at runtime |
61
+ | `stitchkit/tools/mcp` | server (Bun or Node) | evolving<br>_redefined in 3 of the 41 minors since 0.94.0, most recently 0.127.0_ | the canonical MCP HTTP/stdio server, schemas and typed MCP presenters; only Zod and the MCP server SDK peers |
62
+ | `stitchkit/tools/agent` | server (Bun or Node) | evolving<br>_redefined in 2 of the 41 minors since 0.94.0, most recently 0.134.0_ | `mountAgent` — thin AI SDK `ToolSet` adapter over `mountAgentTools` for apps driving their own SDK loop; only Zod and the `ai` peer |
63
+ | `stitchkit/tools/toolkit` | server (Bun or Node) | evolving<br>_redefined in 1 of the 41 minors since 0.94.0, most recently 0.127.0_ | `createToolkit` — one tool set served over MCP and to an AI SDK agent; the MCP server SDK and `ai` peers |
64
+ | `stitchkit/tools/contract` | browser + server | evolving<br>_redefined in 2 of the 41 minors since 0.94.0, most recently 0.124.0_ | the shapes a tool surface speaks — async-operation contract, snapshot and cancel schemas, view-file input/output — without the runtime that serves them |
65
+ | `stitchkit/tools/invoker` | server | stable<br>_redefined in 3 of the 41 minors since 0.94.0, most recently 0.127.0_ | peer-free `createToolInvoker` over the canonical contract tool runner |
66
+ | `stitchkit/tools/connections` | server (Bun or Node) | evolving<br>_redefined in 3 of the 41 minors since 0.94.0, most recently 0.127.0_ | consume external MCP servers and a bounded OpenAPI subset — typed reauthorization, a per-request host fence and per-call credentials |
67
+ | `stitchkit/cli` | server | stable<br>_redefined in 12 of the 41 minors since 0.94.0, most recently 0.128.0_ | `createCli` / `createCliInvoker` — runtime and strict NodeNext declarations without MCP SDK / `ai` |
68
+ | `stitchkit/cli/publish` | build and release tooling (Bun or Node, POSIX) | evolving<br>_redefined in 0 of the 41 minors since 0.94.0_ | `publishCli` — commit a verified CLI distribution and move its public manifest last; see [CLI guide](cli.md#publishing-a-complete-version) |
69
+ | `stitchkit/remote` | browser **and** server | stable<br>_redefined in 1 of the 41 minors since 0.94.0, most recently 0.104.0_ | peer-free `implementRemote` for thin HTTP proxy processes |
70
+ | `stitchkit/process` | server (Bun or Node, POSIX) | evolving<br>_redefined in 4 of the 41 minors since 0.94.0, most recently 0.133.0_ | finite native commands, byte sinks, bounded capture, process-group cancellation and opt-in Linux/Darwin owner-loss cleanup; contract operations executed in one-call child processes |
71
+ | `stitchkit/process/bootstrap` | bundled server entry (Bun, POSIX) | evolving<br>_redefined in 0 of the 2 minors since 0.133.0_ | narrow bootstrap that keeps the process runner lazy while carrying the package's own invocations — the owner-loss guard and the process root of launched work — in a single-file bundle |
72
+ | `stitchkit/files/packaging` | build time (Bun or Node) | evolving<br>_redefined in 4 of the 41 minors since 0.94.0, most recently 0.133.0_ | installed native asset graph, integrity, Bun packaging plugin and the artifact loader check; a client bundled into one self-contained, hashed file; a typed client built into a proven npm package with several entries, declarations and external peers; no runtime install policy |
73
+ | `stitchkit/files` | server (Bun or Node) | stable<br>_redefined in 5 of the 41 minors since 0.94.0, most recently 0.133.0_ | peer-free managed local-file boundary |
74
+ | `stitchkit/spend` | server (Bun or Node) | evolving<br>_redefined in 0 of the 8 minors since 0.127.0_ | peer-free spend gateway for paid model APIs: the attempt recorded before the call and closed on every outcome, credentials only for the provider's origin, a spooled ledger, rank-merged receipts and a reconciler |
75
+ | `stitchkit/spend/testing` | tests on Bun or Node | evolving<br>_redefined in 0 of the 8 minors since 0.127.0_ | the coverage guard: red on a model SDK import, a provider key or a provider host outside the gateway files |
76
+ | `stitchkit/service-host` | server (Bun or Node) | evolving<br>_redefined in 0 of the 8 minors since 0.127.0_ | peer-free host service supervision — verified versioned artifact activation, Linux `systemd` and macOS `launchd` units (`plutil`, `bootout`/`bootstrap`, rollback), live process/Unix-socket identity verification, and an in-process config-watched reloader |
77
+ | `stitchkit/service-host/macos` | server (Bun or Node, macOS) | evolving<br>_redefined in 0 of the 8 minors since 0.127.0_ | peer-free macOS daemon bundle toolkit — fail-closed Developer ID `codesign`, strict C11 launcher `.app` bundles with atomic `RENAME_SWAP` install/rollback, Apple 824×824 squircle `AppIcon.icns`, streaming `lsregister` maintenance, and TCC responsibility inspection |
78
+ | `stitchkit/service-host/work` | server (Bun or Node; Linux with systemd ≥ 254, or a process root on Linux and macOS) | evolving<br>_redefined in 0 of the 2 minors since 0.133.0_ | peer-free launch of work in its own boundary with a declared owner — a transient systemd scope or a recorded process root, the typed owner record, the one inherited variable that names the boundary, and the membership check that asks the boundary; see [native I/O](native-io.md#work-in-its-own-boundary) |
79
+ | `stitchkit/telegram` | server (Bun or Node) | evolving<br>_redefined in 8 of the 41 minors since 0.94.0, most recently 0.127.0_ | peer-free Telegram platform primitives — Mini App `initData` verification, widget limits and the `widget_query` and widget message schemas, send-failure classification, one outbound budget per bot token with weighted albums and per-chat 429 pauses, resumable broadcasts, the operator channel with dedupe, a Bot API transport that separates a request that never left from an unknown outcome, local Bot API files, the waveform of a voice message read from its PCM, webhook ownership and durable webhook update intake |
80
+ | `stitchkit/telegram/grammy` | server (Bun or Node) | evolving<br>_redefined in 0 of the 41 minors since 0.94.0_ | the token's outbound budget as one grammY client transformer — a 429 that comes back as a response pauses its chat, and a cancelled wait is a request that never left; the widget methods over the same client |
81
+ | `stitchkit/telegram/html` | browser and server | evolving<br>_redefined in 1 of the 41 minors since 0.94.0, most recently 0.127.0_ | Telegram's HTML as a tree — compile GFM Markdown to Telegram HTML with fence-aware splitting, clean any markup to what Telegram accepts, cut long text into valid parts by what the reader sees, check markup before it is sent |
82
+ | `stitchkit/telegram/voice` | browser and server | evolving<br>_redefined in 0 of the 41 minors since 0.94.0_ | the waveform of a voice message as one format — packed for `sendVoice` the way Telegram Desktop scales it, unpacked to draw it, a `getMe` read of whether the server takes it |
83
+ | `stitchkit/telegram/screens` | server (Bun or Node) | evolving<br>_redefined in 1 of the 41 minors since 0.94.0, most recently 0.127.0_ | a bot's menus as declared screens over grammY — typed paths, actions and input, message reconciliation, state in any `StorageAdapter`, a test chat |
84
+ | `stitchkit/tracking` | browser **and** server | evolving<br>_redefined in 3 of the 41 minors since 0.94.0, most recently 0.127.0_ | visitor-tracking mechanics — `createTrackingClient`, the tab-shared outbox, the page-leave beacon, attribution, the contract factory; no event vocabulary, no React |
85
+ | `stitchkit/tracking/contract` | browser **and** server | evolving<br>_redefined in 0 of the 41 minors since 0.94.0_ | the wire shapes — the contract factory, event and visit schemas, the performance sample and its trust threshold; brings `zod` |
86
+ | `stitchkit/tracking/performance` | browser **and** server | evolving<br>_redefined in 1 of the 41 minors since 0.94.0, most recently 0.127.0_ | Web Vitals from real visitors, collected after load through the optional peer `web-vitals`; no `zod` |
87
+ | `stitchkit/tracking/server` | server (Bun or Node) | evolving<br>_redefined in 0 of the 41 minors since 0.94.0_ | the decisions a tracking backend makes — dispositions, visit lease over an application-owned store, active intervals, presence; no database |
88
+ | `stitchkit/release` | browser **and** server | evolving<br>_redefined in 1 of the 41 minors since 0.94.0, most recently 0.127.0_ | a page follows the release it was built for — `createReleaseMarker` on the server, `createReleaseWatcher` in the browser, the `X-Build-Id` header and a socket event between them |
89
+ | `stitchkit/voice` | browser **and** server | evolving<br>_redefined in 0 of the 41 minors since 0.94.0_ | the mechanics of a live voice reply — `SentenceCutter`, `speakableText`, a `SpeechQueue` that synthesises ahead and stops on interruption, the conversation phases |
90
+ | `stitchkit/sync` | browser **and** server | evolving<br>_redefined in 1 of the 8 minors since 0.127.0, most recently 0.132.0_ | the client half of an offline-first sync — which outbox rows leave next, pending edits on top of remote rows, deletes that win until acknowledged, the cursor session, the push and page wire with an open outcome vocabulary; no driver, runs in Hermes |
91
+ | `stitchkit/sync/postgres` | server (Bun or Node) | evolving<br>_redefined in 0 of the 8 minors since 0.127.0_ | the server half — versions that commit in order, a ledger that runs each change once, a feed of what changed, inside the app's own transaction; a memory store and `checkSyncStore` |
92
+ | `stitchkit/geo` | server (Bun or Node) | evolving<br>_redefined in 2 of the 41 minors since 0.94.0, most recently 0.127.0_ | managed GeoIP reader generations, last-known-good reload and the optional MaxMind adapter |
93
+ | `stitchkit/geo/contract` | browser **and** server | evolving<br>_redefined in 0 of the 41 minors since 0.94.0_ | the place snapshot schema, for a shared contract that stores or sends `GeoAttribution`; brings `zod` |
94
+ | `stitchkit/xlsx` | browser **and** server | evolving<br>_redefined in 0 of the 41 minors since 0.94.0_ | a workbook from rows and typed columns, with no dependency; text never runs as a formula |
95
+ | `stitchkit/oauth` | browser **and** server | evolving<br>_redefined in 0 of the 41 minors since 0.94.0_ | provider-neutral Authorization Code + PKCE request and one-shot callback transaction mechanics |
96
+ | `stitchkit/google` | server (Bun or Node) | evolving<br>_redefined in 1 of the 41 minors since 0.94.0, most recently 0.127.0_ | optional Google code exchange and verified OIDC identity adapter |
97
+ | `stitchkit/observability` | server | stable<br>_redefined in 1 of the 41 minors since 0.94.0, most recently 0.127.0_ | request/tool event projections — `createObservability`, trace context, sanitisation |
98
+ | `stitchkit/testing` | tests on Bun or Node | stable<br>_redefined in 3 of the 41 minors since 0.94.0, most recently 0.127.0_ | in-process generated clients over a real Fetch handler, the managed-resource conformance kit and manual time for schedules and retries |
99
+ | `stitchkit/declaration` | browser + build and deployment tooling (Bun or Node) | evolving<br>_redefined in 1 of the 41 minors since 0.94.0, most recently 0.128.0_ | `ProjectDeclarationSchema` — the one machine-readable statement a repository makes about itself |
100
+ | `stitchkit/react` | browser + server rendering | stable<br>_redefined in 2 of the 41 minors since 0.94.0, most recently 0.127.0_ | `createCursorQuery`, `createCacheBridge`, QueryClient and `ApiError` retry policy |
101
+ | `stitchkit/react/keyboard` | browser | evolving<br>_redefined in 1 of the 41 minors since 0.94.0, most recently 0.115.0_ | which part of a screen gets a key — ordered layers, one Escape per level, list zones with real focus; see [keyboard guide](keyboard.md) |
102
+ | `stitchkit/react/keyboard/testing` | server (Bun or Node) | evolving<br>_redefined in 0 of the 41 minors since 0.94.0_ | the keyboard layers and zones without a DOM — fakes for the window, elements and key events beside the two engines, to test the order of layers, `scope`/`inert` and the edges of a zone in milliseconds |
103
+ | `stitchkit/agent-runtime` | server | evolving<br>_redefined in 10 of the 41 minors since 0.94.0, most recently 0.134.0_ | peer-free durable conversation/run loop over `AgentModelDriver`, stateless `completeText`/`completeObject`, driver composition, history, models, prompts, fencing and events |
104
+ | `stitchkit/agent-runtime/sandbox` | server | evolving<br>_redefined in 0 of the 41 minors since 0.94.0_ | optional Linux Bubblewrap sessions, long-lived OS process sandboxes (`createProcessSandbox`, `probeProcessSandbox`, `buildSeatbeltProfile`), durable workspaces and a host HTTP credential gateway; see [sandbox guide](sandbox.md) |
105
+ | `stitchkit/agent-runtime/testing` | tests on Bun or Node | evolving<br>_redefined in 3 of the 41 minors since 0.94.0, most recently 0.134.0_ | peer-free `createScriptedModelDriver`, credential-free replay, scripted provider faults, deterministic race controls and the agent-store conformance kit |
106
+ | `stitchkit/agent-runtime/harness` | server | evolving<br>_redefined in 1 of the 41 minors since 0.94.0, most recently 0.134.0_ | peer-free resource-aware process-local facade over the canonical Agent runtime; supervision stays outside |
107
+ | `stitchkit/agent-runtime/coding-tools` | server (Bun or Node) | evolving<br>_redefined in 3 of the 41 minors since 0.94.0, most recently 0.127.0_ | bounded host-authorized direct file and shell tools; a root boundary, not an OS sandbox |
108
+ | `stitchkit/agent-runtime/openrouter` | server | evolving<br>_redefined in 2 of the 41 minors since 0.94.0, most recently 0.134.0_ | peer-free native OpenRouter Chat Completions SSE driver, catalog, admission, route pinning and spend reconciliation |
109
+ | `stitchkit/agent-runtime/openai` | server | evolving<br>_redefined in 0 of the 1 minor since 0.134.0_ | peer-free native OpenAI Responses API (`POST /v1/responses`) driver, policy schemas and provenance-aware usage normalization |
110
+ | `stitchkit/agent-runtime/anthropic` | server | evolving<br>_redefined in 0 of the 1 minor since 0.134.0_ | peer-free native Anthropic Messages API (`POST /v1/messages`) driver, thinking/cache policy schemas and provenance-aware usage normalization |
111
+ | `stitchkit/agent-runtime/ai-sdk` | server | evolving<br>_redefined in 0 of the 1 minor since 0.134.0_ | thin optional-peer adapter (`fromAiSdkModel`, `fromAiSdkTools`) bridging AI SDK v4 models and `ToolSet`s onto `AgentModelDriver` and `AgentToolSet`; requires `ai` |
112
+ | `stitchkit/agent-runtime/browser` | browser + server | evolving<br>_redefined in 2 of the 41 minors since 0.94.0, most recently 0.127.0_ | canonical agent records, events, reconnect cursor, interactive approval/input/permission-mode/host-status state (`deriveAgentConversationActivity`, `deriveAgentConversationState`, `delivery: 'unknown'` reconciliation) and optional conversation controller |
113
+ | `stitchkit/agent-runtime/react` | browser + server | evolving<br>_redefined in 0 of the 41 minors since 0.94.0_ | React subscription to an application-owned agent controller |
114
+ | `stitchkit/agent-runtime/realtime` | server (Bun or Node) | evolving<br>_redefined in 2 of the 41 minors since 0.94.0, most recently 0.127.0_ | authorized agent control over the existing Socket.IO server |
115
+ | `stitchkit/agent-executor` | server (Bun or Node) | evolving<br>_redefined in 4 of the 8 minors since 0.127.0, most recently 0.133.0_ | the executor ↔ server contract for external coding agents (Claude Code, Codex, ACP): delta vocabulary (including `ExecutorPlanDelta`) over the shared message parts, thread leases with a fence, turn phases and their reports |
116
+ | `stitchkit/agent-executor/claude` | server (Bun or Node) | evolving<br>_redefined in 0 of the 8 minors since 0.127.0_ | the Claude Code driver: the unmodified CLI over `stream-json`, permission requests answered by the host, reconcile by the input's id in the profile's transcript |
117
+ | `stitchkit/agent-executor/claude-sdk` | server (Bun or Node) | evolving<br>_redefined in 1 of the 8 minors since 0.127.0, most recently 0.131.0_ | Claude through the Agent SDK: the application's `query` (optional peer `@anthropic-ai/claude-agent-sdk`), the CLI's classifier, `canUseTool` asked of the host |
118
+ | `stitchkit/agent-executor/acp` | server (Bun or Node) | evolving<br>_redefined in 0 of the 8 minors since 0.127.0_ | an Agent Client Protocol v1 agent over stdio: settings by category, images, MCP servers, tool metadata (`title`/`kind`/`locations`), meaningful `tool_call_update` progress updates, typed `plan` deltas, `session/resume`/`load`/`list`, `session/cancel`; no reconcile |
119
+ | `stitchkit/agent-executor/codex` | server (Bun or Node) | evolving<br>_redefined in 3 of the 8 minors since 0.127.0, most recently 0.133.0_ | the Codex driver: `codex app-server` over stdio or Unix-socket WebSocket (`unix-listen` / `unix-connect`), thread policy and live controls, approval and input requests answered by the host, unknown server requests refused, reconcile by the client id in `thread/turns/list` |
120
+ | `stitchkit/agent-executor/testing` | server (Bun or Node) | evolving<br>_redefined in 1 of the 8 minors since 0.127.0, most recently 0.133.0_ | the engine conformance kit, deterministic replay driver, portable fake Codex app-server, fail-loud consumer stub factories, and schema-validated test fixtures; no optional peer |
121
+ | `stitchkit/agent-executor/testing/claude-sdk` | server (Bun or Node) | evolving<br>_redefined in 0 of the 2 minors since 0.133.0_ | the multi-turn fake Claude SDK query harness and the Claude SDK session stub, typed by the optional peer `@anthropic-ai/claude-agent-sdk` |
122
+ | `stitchkit/agent-runtime/postgres` | server (Bun or Node) | evolving<br>_redefined in 0 of the 8 minors since 0.127.0_ | the agent store, conversation reader and companion host on Postgres, over the application's own client (Bun SQL, Prisma, `pg`) |
123
+ | `stitchkit/agent-runtime/sqlite/bun` | server (Bun) | evolving<br>_redefined in 1 of the 41 minors since 0.94.0, most recently 0.127.0_ | durable built-in SQLite store for the agent runtime |
124
+ | `stitchkit/agent-runtime/sqlite/node` | server (Node ≥ 22.5) | evolving<br>_redefined in 1 of the 41 minors since 0.94.0, most recently 0.127.0_ | durable built-in SQLite store for the agent runtime |
121
125
  | `stitchkit-tui` | terminal (Bun) | evolving | optional official OpenTUI host over a caller-composed headless runtime |
122
- | `stitchkit/application` | browser + server | evolving<br>_redefined in 9 of the 40 minors since 0.94.0, most recently 0.127.0_ | managed resource graph, readiness, admission, schedules, subtree restart and bounded shutdown |
123
- | `stitchkit/application/grammy` | server | evolving<br>_redefined in 0 of the 40 minors since 0.94.0_ | a grammY bot as application resources — configuration, then polling with updates admitted by batch — and the webhook adapter |
124
- | `stitchkit/application/opentelemetry` | server | evolving<br>_redefined in 0 of the 40 minors since 0.94.0_ | maps application snapshots onto an injected OpenTelemetry `Meter` |
125
- | `stitchkit/application/diagnostic-journal` | server | evolving<br>_redefined in 3 of the 40 minors since 0.94.0, most recently 0.127.0_ | the local diagnostic journal — an exclusive bounded writer and snapshot reader with explicit anomalies |
126
- | `stitchkit/application/directory-inbox` | server | evolving<br>_redefined in 0 of the 40 minors since 0.94.0_ | the directory inbox — entries another program drops into a directory, delivered to the application at least once |
126
+ | `stitchkit/application` | browser + server | evolving<br>_redefined in 9 of the 41 minors since 0.94.0, most recently 0.127.0_ | managed resource graph, readiness, admission, schedules, subtree restart and bounded shutdown |
127
+ | `stitchkit/application/grammy` | server | evolving<br>_redefined in 0 of the 41 minors since 0.94.0_ | a grammY bot as application resources — configuration, then polling with updates admitted by batch — and the webhook adapter |
128
+ | `stitchkit/application/opentelemetry` | server | evolving<br>_redefined in 0 of the 41 minors since 0.94.0_ | maps application snapshots onto an injected OpenTelemetry `Meter` |
129
+ | `stitchkit/application/diagnostic-journal` | server | evolving<br>_redefined in 3 of the 41 minors since 0.94.0, most recently 0.127.0_ | the local diagnostic journal — an exclusive bounded writer and snapshot reader with explicit anomalies |
130
+ | `stitchkit/application/directory-inbox` | server | evolving<br>_redefined in 0 of the 41 minors since 0.94.0_ | the directory inbox — entries another program drops into a directory, delivered to the application at least once |
127
131
 
128
132
  Rule of thumb: browser code imports `stitchkit` and `stitchkit/react`; server
129
133
  code adds `stitchkit/server` (or `stitchkit/node` on Node) and opts into
@@ -225,10 +229,13 @@ map — feature → packages:
225
229
  | MCP server (`stitchkit/tools/mcp`) | `@modelcontextprotocol/server` |
226
230
  | AI SDK agent tools (`stitchkit/tools/agent`) | `ai` |
227
231
  | MCP and agent toolkit (`stitchkit/tools/toolkit`) | `@modelcontextprotocol/server` `ai` |
228
- | Agent application runtime (`stitchkit/agent-runtime`) | `ai` |
229
- | Headless Agent harness (`stitchkit/agent-runtime/harness`) | `ai` |
230
- | Agent coding tools (`stitchkit/agent-runtime/coding-tools`) | — |
231
- | OpenRouter runtime adapter (`stitchkit/agent-runtime/openrouter`) | `ai` `@openrouter/ai-sdk-provider` |
232
+ | Agent application runtime (`stitchkit/agent-runtime`) | — (peer-free) |
233
+ | Headless Agent harness (`stitchkit/agent-runtime/harness`) | — (peer-free) |
234
+ | Agent coding tools (`stitchkit/agent-runtime/coding-tools`) | — (peer-free) |
235
+ | OpenRouter native provider (`stitchkit/agent-runtime/openrouter`) | — (peer-free) |
236
+ | OpenAI native provider (`stitchkit/agent-runtime/openai`) | — (peer-free) |
237
+ | Anthropic native provider (`stitchkit/agent-runtime/anthropic`) | — (peer-free) |
238
+ | AI SDK runtime adapter (`stitchkit/agent-runtime/ai-sdk`) | `ai` |
232
239
  | Postgres agent store (`stitchkit/agent-runtime/postgres`) | — (the application's own Postgres client) |
233
240
  | SQLite agent store (`stitchkit/agent-runtime/sqlite/bun` or `/node`) | — (runtime built-in) |
234
241
  | Agent executor — Claude Agent SDK leaf (`stitchkit/agent-executor/claude-sdk`) | `@anthropic-ai/claude-agent-sdk` |
@@ -245,6 +252,7 @@ map — feature → packages:
245
252
  | **Socket.IO server on Bun** | `socket.io` `@socket.io/bun-engine` |
246
253
  | **Socket.IO server on Node** | `socket.io` |
247
254
  | Socket.IO client | `socket.io-client` (runtime peer; unrelated root declarations remain peer-free) |
255
+ | User Device Relay (`stitchkit/device-relay`) | — (peer-free; binds to any Socket.IO or compatible realtime transport) |
248
256
  | grammY lifecycle adapters (`stitchkit/application/grammy`) | `grammy` |
249
257
  | Telegram platform primitives (`stitchkit/telegram`) | — (peer-free) |
250
258
  | Telegram message markup (`stitchkit/telegram/html`) | — (peer-free) |
@@ -267,7 +275,7 @@ you import — both for `stitchkit/tools/toolkit`:
267
275
 
268
276
  ```bash
269
277
  bun add @modelcontextprotocol/server@^2 # stitchkit/tools/mcp
270
- bun add ai@^7 # stitchkit/tools/agent
278
+ bun add ai@^7 # stitchkit/tools/agent or stitchkit/agent-runtime/ai-sdk
271
279
  ```
272
280
 
273
281
  Browser, HTTP-client and React entrypoints remain usable without either MCP
@@ -1328,10 +1336,40 @@ Every handler receives one `ctx` argument:
1328
1336
  | `traceId` | `string` | per-request trace id |
1329
1337
  | `ipAddress` | `string` | caller IP |
1330
1338
  | `userAgent` | `string` | caller user-agent |
1339
+ | `remainingTimeoutMs?` | `(reserveMs?: number) => number \| undefined` | live remaining ms until the active request deadline (or `undefined` when unbounded; present on HTTP calls) |
1331
1340
 
1332
1341
  The same handler runs for HTTP, MCP and agent calls — `ctx.source` tells you
1333
1342
  which. Anything an auth hook attaches (e.g. the resolved user) is also on `ctx`.
1334
1343
 
1344
+ ### Inbound deadline budgets
1345
+
1346
+ When an HTTP caller sends a relative remaining budget in `x-stitchkit-timeout-ms` (for example via
1347
+ `createHttpClient({ propagateDeadline: true })`, a `createClient` endpoint with a declared
1348
+ `timeout`, or per-call `withOptions(..., { timeout })`):
1349
+
1350
+ - `createHandler` / `createServer` clamps the inbound budget to the endpoint's declared `timeout`
1351
+ (a caller can narrow its budget, never extend it past the server's own ceiling).
1352
+ - `hooks.authorize` (and route-group `authorize`) runs first so unauthorized callers still receive
1353
+ `401`/`403`; an inbound value of `0` then fails immediately with `REQUEST_TIMEOUT` (`408`) before
1354
+ payload parsing, `beforeHandle`, or the handler runs. Malformed non-integer values are ignored so
1355
+ the endpoint's declared timeout remains authoritative.
1356
+ - Inside the handler, `ctx.remainingTimeoutMs?.(reserveMs?)` returns the live remaining integer
1357
+ milliseconds (clamped to `>= 0`, subtracting optional `reserveMs` for response serialization), or
1358
+ `undefined` when neither an inbound header nor an endpoint `timeout` bounds the request. Always
1359
+ check `remaining <= 0` before forwarding `{ timeout: remaining }` so an exhausted budget fails with
1360
+ `408` instead of throwing a `RangeError` from timer validation:
1361
+
1362
+ ```ts
1363
+ const remaining = ctx.remainingTimeoutMs?.(200)
1364
+ if (remaining !== undefined && remaining <= 0) {
1365
+ throw new AppError('REQUEST_TIMEOUT', {
1366
+ status: 408,
1367
+ message: 'Request deadline budget exhausted',
1368
+ })
1369
+ }
1370
+ await downstream.list.withOptions(remaining !== undefined ? { timeout: remaining } : {})
1371
+ ```
1372
+
1335
1373
  ### Request attributes from the ingress
1336
1374
 
1337
1375
  When your own code builds the `Request` — a local socket ingress, a relay, a test harness —
@@ -3101,6 +3139,7 @@ without repeating transport configuration.
3101
3139
  | `suppressUnauthorizedFor` | `[]` | exact contract-derived operation matchers whose expected 401 does not emit `unauthorized` |
3102
3140
  | `parseError` | built-in | map an error body to `{ code, message, details, hint }` |
3103
3141
  | `trace` | `false` | emit a W3C `traceparent` header on every request |
3142
+ | `propagateDeadline` | `false` (`true` when per-call `timeout` is set) | emit relative `x-stitchkit-timeout-ms` remaining budget header on outbound requests |
3104
3143
  | `unix` | — | dial a unix domain socket instead of TCP (Bun only, see below) |
3105
3144
 
3106
3145
  `headers` as a function is the hook for runtime tokens — a bearer token or any
@@ -3431,6 +3470,27 @@ For an endpoint without contract arguments, pass only the options object:
3431
3470
  await api.health.withOptions({ signal: controller.signal })
3432
3471
  ```
3433
3472
 
3473
+ ### Deadline budget propagation
3474
+
3475
+ To avoid wasted work after a caller gives up, the client can send its remaining monotonic budget as
3476
+ a relative integer millisecond header (`x-stitchkit-timeout-ms`, `DEADLINE_BUDGET_HEADER`):
3477
+
3478
+ ```ts
3479
+ const http = createHttpClient({ baseUrl: '/api', propagateDeadline: true })
3480
+ // In createClient, an endpoint's declared `timeout` and per-call `timeout` both propagate
3481
+ // automatically unless `propagateDeadline: false` is passed:
3482
+ await api.reports.generate.withOptions({ id }, { timeout: 5_000 })
3483
+ await api.reports.generate.withOptions({ id }, { timeout: 5_000, propagateDeadline: false })
3484
+ ```
3485
+
3486
+ In `createClient`, deadline propagation is enabled automatically whenever either the endpoint
3487
+ declares `timeout` in its contract or the call passes a per-call `timeout` (override with
3488
+ `propagateDeadline: false`). Each transport retry recomputes the remaining budget before sending
3489
+ instead of replaying the original full timeout. When an explicit `x-stitchkit-timeout-ms` header is
3490
+ already set on the request, the client preserves it. On the server, `createHandler` /
3491
+ `createServer` clamps that budget against the endpoint's declared `timeout` and exposes
3492
+ `ctx.remainingTimeoutMs?.(reserveMs?)` (see [HTTP server](./server.md#inbound-deadline-budgets)).
3493
+
3434
3494
  ### Upload progress
3435
3495
 
3436
3496
  A call with a body can report it leaving:
@@ -6303,17 +6363,21 @@ identical. Write the handler once; it serves every surface.
6303
6363
  > **Maturity: evolving.** This surface is still finding its shape and may be
6304
6364
  > redefined in any minor release — always with a `### ⚠️ Breaking changes` entry
6305
6365
  > and a migration section, never silently. If your application already owns the
6306
- > conversation loop, `mountAgent` from `stitchkit/tools/agent` is the direct path.
6307
-
6308
- `stitchkit/agent-runtime` is the server-only, opinionated layer above
6309
- `mountAgent`. Use it when the application wants Stitchkit to own conversation
6310
- mechanics: durable acceptance, history projection, the AI SDK stream loop,
6311
- checkpoints, keyed interruption, terminal commit and stable application events.
6312
-
6313
- If the application already owns that loop, import `mountAgent` from
6314
- `stitchkit/tools/agent`. Neither `stitchkit/tools` nor `stitchkit/tools/agent` depends on
6315
- this entrypoint; this entrypoint uses the tool executor, but pulls no MCP peer, so
6316
- choosing `mountAgent` alone costs you nothing from here.
6366
+ > conversation loop, `mountAgentTools` from `stitchkit/tools` (or `mountAgent`
6367
+ > from `stitchkit/tools/agent` for an AI SDK loop) is the direct path.
6368
+
6369
+ `stitchkit/agent-runtime` is the peer-free, server-only, opinionated layer above
6370
+ `mountAgentTools`. Use it when the application wants Stitchkit to own conversation
6371
+ mechanics: durable acceptance, history projection, the native `AgentModelDriver`
6372
+ step loop, checkpoints, keyed interruption, terminal commit and stable application
6373
+ events.
6374
+
6375
+ If the application already owns that loop, import `mountAgentTools` from
6376
+ `stitchkit/tools` (peer-free) or `mountAgent` from `stitchkit/tools/agent` (AI SDK
6377
+ adapter). Neither `stitchkit/tools` nor `stitchkit/tools/agent` depends on this
6378
+ entrypoint; this entrypoint uses the tool executor, pulls no MCP peer and no AI SDK
6379
+ peer, and runs directly against three native providers (`openrouter`, `openai`,
6380
+ `anthropic`) or any custom `AgentModelDriver`.
6317
6381
 
6318
6382
  UI and shared DTO code must import canonical records and delivery validation from
6319
6383
  `stitchkit/agent-runtime/browser`, not from the server runtime barrel:
@@ -6333,16 +6397,22 @@ persistence, event sinks and every Node context dependency.
6333
6397
  ## Install
6334
6398
 
6335
6399
  ```sh
6336
- bun add stitchkit ai zod
6400
+ bun add stitchkit zod
6337
6401
  ```
6338
6402
 
6339
- `mountAgent` from `stitchkit/tools/agent` — used in the composition below — needs no
6340
- peer beyond `ai`.
6403
+ `stitchkit/agent-runtime`, `stitchkit/agent-runtime/harness`,
6404
+ `stitchkit/agent-runtime/testing`, `stitchkit/tools` (`mountAgentTools`,
6405
+ `defineAgentTool`), and all three native providers
6406
+ (`stitchkit/agent-runtime/openrouter`, `stitchkit/agent-runtime/openai`,
6407
+ `stitchkit/agent-runtime/anthropic`) are completely peer-free beyond `zod`.
6341
6408
 
6342
- OpenRouter is isolated so other runtime users do not resolve its package:
6409
+ Install `ai` only when bridging an existing AI SDK v4 `LanguageModel` or `ToolSet`
6410
+ through the thin optional-peer adapter `stitchkit/agent-runtime/ai-sdk`
6411
+ (`fromAiSdkModel`, `fromAiSdkTools`) or mounting an AI SDK `ToolSet` through
6412
+ `stitchkit/tools/agent` (`mountAgent`):
6343
6413
 
6344
6414
  ```sh
6345
- bun add @openrouter/ai-sdk-provider
6415
+ bun add ai@^7
6346
6416
  ```
6347
6417
 
6348
6418
  ## Minimal composition
@@ -6358,8 +6428,7 @@ import {
6358
6428
  defineModelRegistry,
6359
6429
  } from 'stitchkit/agent-runtime'
6360
6430
  import { openRouterProvider } from 'stitchkit/agent-runtime/openrouter'
6361
- import { composeToolLifecycle } from 'stitchkit/tools'
6362
- import { mountAgent } from 'stitchkit/tools/agent'
6431
+ import { composeToolLifecycle, mountAgentTools } from 'stitchkit/tools'
6363
6432
 
6364
6433
  const protocol = defineAgentProtocol({
6365
6434
  context: z.object({ userId: z.string() }),
@@ -6408,7 +6477,7 @@ const runtime = createAgentRuntime({
6408
6477
  },
6409
6478
  }),
6410
6479
  tools: ({ context, toolFenceLifecycle }) =>
6411
- mountAgent(service, {
6480
+ mountAgentTools(service, {
6412
6481
  context,
6413
6482
  access: { gate: composeToolLifecycle(authLifecycle, toolFenceLifecycle) },
6414
6483
  }),
@@ -6447,11 +6516,205 @@ await ticket.accepted
6447
6516
  const terminal = await ticket.result
6448
6517
  ```
6449
6518
 
6450
- A stop policy's `when` receives the steps so far together with the same run context
6451
- `prepareStep` gets — `context`, `run`, `signal`, `toolFenceLifecycle` and `contextUsage` —
6452
- typed by the runtime's `CONTEXT`. A rule that depends on its own run (a receipt bound to the
6453
- run's request, a per-tenant limit) reads it there; it needs no map of its own keyed by `runId`.
6454
- The first policy to return `true` ends the run as `policy_stop` with its `name` as `policyName`.
6519
+ A stop policy's `when` receives the completed `AgentStepResult[]` steps so far together with the
6520
+ same run context `prepareStep` gets — `context`, `run`, `signal`, `toolFenceLifecycle` and
6521
+ `contextUsage` — typed by the runtime's `CONTEXT`. A rule that depends on its own run (a receipt
6522
+ bound to the run's request, a per-tenant limit) reads it there; it needs no map of its own keyed
6523
+ by `runId`. The first policy to return `true` ends the run as `policy_stop` with its `name` as
6524
+ `policyName`.
6525
+
6526
+ ## Native model port, providers and driver composition
6527
+
6528
+ Every model call crosses one single-step port — `AgentModelDriver.stream(request, signal)` — with
6529
+ no SDK retries and no tool execution inside the driver (ADR 0336). Any throw out of `stream()` or
6530
+ while reading `parts` is provider-origin by construction; HTTP and stream failures surface as
6531
+ `AgentProviderError` (guard with `isAgentProviderError`) or `AgentProviderStreamCutError`.
6532
+ `AgentModelRequest.headers` merges per-request headers (such as `traceparent` or deadline headers)
6533
+ without allowing `content-type: application/json` to be overwritten. `AgentModelToolSpec` also
6534
+ reserves an additive `{ type: 'provider', id, name, config? }` union branch for provider-hosted
6535
+ tools; drivers that do not implement a declared provider tool fail fast with `TypeError`.
6536
+
6537
+ Three peer-free native providers implement `AgentModelDriverFactory` over Web `fetch` and SSE,
6538
+ all accepting either a static string or a dynamic `apiKey: () => string | Promise<string>` resolved
6539
+ freshly per stream call and reporting server `response.timestamp` alongside `modelId`:
6540
+
6541
+ - **`stitchkit/agent-runtime/openrouter`** (`openRouterProvider`): OpenRouter Chat Completions SSE
6542
+ with camelCase `baseUrl` and `providerApiKeys`, `looseTools` (sending `strict: false` while
6543
+ preserving explicit per-tool `strict: true`), `reasoning.effort: 'max'`, `sessionPerConversation`
6544
+ derived from `request.correlation.conversationId` without requiring `invocations`,
6545
+ `reasoning_details` and Gemini `thought_signature` round-trip, ≤ 4 cache breakpoints, BYOK
6546
+ `costDetails` (`cost + upstream_inference_cost`), and `native_finish_reason` abnormal-stop guards.
6547
+ - **`stitchkit/agent-runtime/openai`** (`openAiProvider`): OpenAI Responses API
6548
+ (`POST /v1/responses`) defaulting to stateless `store: false` with automatic
6549
+ `include: ['reasoning.encrypted_content']` round-trip, `role: 'developer'` instructions,
6550
+ `strict: false` default tool schemas, `item_id` (`fc_*`) vs `call_id` separation, `text.format`
6551
+ structured outputs, `cachePerConversation` (`prompt_cache_key`), and fail-fast `TypeError`
6552
+ refusal of unsupported call settings.
6553
+ - **`stitchkit/agent-runtime/anthropic`** (`anthropicProvider`): Anthropic Messages API
6554
+ (`POST /v1/messages`) with mandatory `maxOutputTokens` and
6555
+ `maxOutputTokens > thinking.budgetTokens` fail-fast validation, verbatim multi-block
6556
+ `thinking` + `signature` and `redacted_thinking` preservation, `computed` total `inputTokens`
6557
+ when cache counters are positive (ADR 0109), image splitting out of `is_error` tool results,
6558
+ ≤ 4 cache breakpoints with TTL-order checks, `output_config.format` JSON Schema (refusing
6559
+ schemaless `json-object`), and retryable `529 overloaded_error` classification.
6560
+
6561
+ For an existing AI SDK v4 model or `ToolSet`, import `fromAiSdkModel` and `fromAiSdkTools` from
6562
+ `stitchkit/agent-runtime/ai-sdk`. Both adapt directly onto `AgentModelDriver` and `AgentToolSet`
6563
+ (driving `model.doStream()` without importing `streamText` or `generateText`) and normalize legacy
6564
+ deprecated tool outputs into canonical `{ type: 'file', data, mediaType }` parts.
6565
+
6566
+ Wrap any driver with `wrapModelDriver` or `composeModelDrivers` for admission holds, credit
6567
+ reservations, request transforms, signal tightening (`transformSignal`, which links a tighter
6568
+ `AbortSignal` without ever loosening the caller's signal), or per-part telemetry. `onClose` runs
6569
+ once per stream on finish, error, early consumer break, or signal abort:
6570
+
6571
+ ```ts
6572
+ import { composeModelDrivers } from 'stitchkit/agent-runtime'
6573
+ import { openAiProvider } from 'stitchkit/agent-runtime/openai'
6574
+
6575
+ const base = openAiProvider({ apiKey: env.OPENAI_API_KEY }).create('gpt-5')
6576
+ const guarded = composeModelDrivers(base, [admissionDecorator, telemetryDecorator])
6577
+ ```
6578
+
6579
+ ### OpenRouter catalog snapshots, pricing ceilings, and cache
6580
+
6581
+ `stitchkit/agent-runtime/openrouter` also provides a peer-free, Web Fetch-clean catalog layer for
6582
+ discovering models, checking pricing ceilings, and keeping a cached catalog in sync across requests:
6583
+
6584
+ - `loadOpenRouterCatalogSnapshot` fetches `/models` (and optional per-model `/endpoints`) with
6585
+ unauthenticated public access or a static/dynamic `apiKey`, extracting `canonicalSlug`,
6586
+ `description`, `createdAt`, `aliasTarget`, `inputModalities`, `outputModalities`, `tokenizer`,
6587
+ `topProviderContextLength`, `maxCompletionTokens`, `reasoning`, per-unit/cache/conditional
6588
+ `pricingTiers`, and endpoint telemetry (`latencyP50Ms`, `throughputP50`, `uptime1d`, `tag`).
6589
+ - `resolveOpenRouterModelCeiling` returns the worst-case per-unit rates across base pricing and
6590
+ conditional tiers without understating unknown tiers; `summarizeOpenRouterEndpoints` aggregates
6591
+ distinct provider counts, median latency/throughput, and 1-day uptime.
6592
+ - `findOpenRouterModel` looks up a model by exact `id` or `canonicalSlug`, and
6593
+ `listOpenRouterModels` filters snapshots by `tools`, `reasoning`, modalities, `minContextLength`,
6594
+ price bounds, `freeOnly`, and `author`.
6595
+ - `createOpenRouterCatalogCache` wraps snapshot refreshes with single-flight coalescing, per-caller
6596
+ `AbortSignal` isolation, `freshMs` TTL, `retryBackoffMs` stale fallback, and an optional
6597
+ pluggable `OpenRouterCatalogStore` for durable hydration and persistence. `catalog.read()` returns
6598
+ a discriminated union (`status: 'current' | 'stale' | 'unavailable'`) so admission and billing
6599
+ callers can narrow on `res.status !== 'unavailable'` and observe stale or unavailable catalog
6600
+ state explicitly; the convenience helpers `getModel` and `listModels` map `'unavailable'` to
6601
+ `undefined` and `[]`.
6602
+
6603
+ ```ts
6604
+ import {
6605
+ createOpenRouterCatalogCache,
6606
+ evaluateOpenRouterModelAdmission,
6607
+ findOpenRouterModel,
6608
+ listOpenRouterModels,
6609
+ resolveOpenRouterModelCeiling,
6610
+ summarizeOpenRouterEndpoints,
6611
+ } from 'stitchkit/agent-runtime/openrouter'
6612
+
6613
+ const catalog = createOpenRouterCatalogCache({
6614
+ freshMs: 15 * 60_000,
6615
+ retryBackoffMs: 60_000,
6616
+ endpointsFor: ['anthropic/claude-sonnet-4.6'],
6617
+ })
6618
+
6619
+ // Admission and billing paths use catalog.read() to observe 'current', 'stale', and 'unavailable'.
6620
+ const res = await catalog.read()
6621
+ if (res.status !== 'unavailable') {
6622
+ const admission = evaluateOpenRouterModelAdmission({
6623
+ snapshot: res.snapshot,
6624
+ modelId: 'anthropic/claude-sonnet-4.6',
6625
+ policy: { maxSnapshotAgeMs: 30 * 60_000, requiredParameters: ['tools'] },
6626
+ })
6627
+ const reasoningTools = listOpenRouterModels(res.snapshot, { tools: true, reasoning: true })
6628
+ const sonnet = findOpenRouterModel(res.snapshot, 'anthropic/claude-sonnet-4.6')
6629
+ const ceiling = sonnet ? resolveOpenRouterModelCeiling(sonnet) : undefined
6630
+ const endpoints = sonnet?.endpoints ? summarizeOpenRouterEndpoints(sonnet.endpoints) : undefined
6631
+ void [admission, reasoningTools, ceiling, endpoints]
6632
+ }
6633
+ ```
6634
+
6635
+ ## Peer-free tools and stateless completions
6636
+
6637
+ Build standalone peer-free tools with `defineAgentTool` or project contracts and runtime tools
6638
+ with `mountAgentTools` from `stitchkit/tools` (including the single-argument
6639
+ `mountAgentTools({ runtimeTools, access })` form when no HTTP service contracts are mounted). Both
6640
+ return `AgentTool` / `AgentToolSet` carrying JSON Schema 2020-12 `inputSchema`, Zod `parseInput`,
6641
+ optional `needsApproval`, `onInputAvailable`, and `toModelOutput` returning `AgentToolModelOutput`.
6642
+
6643
+ When an operation needs one or a few model steps without a durable conversation store — structured
6644
+ extraction, classification, a bounded tool loop, or standalone streaming — call `completeText`,
6645
+ `streamComplete`, or `completeObject` from `stitchkit/agent-runtime`:
6646
+
6647
+ - Compile-time XOR enforces passing either `prompt` or `messages` (never both or neither).
6648
+ - Pass `onPart` on `completeText` / `completeObject` or use `streamComplete` to consume
6649
+ `text-delta`, `reasoning-delta`, `tool-input-start`, `tool-call`, `tool-result` (preliminary and
6650
+ final), `tool-error`, `attempt-reset`, `finish-step`, and `finish` events over a bounded async
6651
+ iterable without a store.
6652
+ - Standalone completions have no durable approval loop, so any tool with `needsApproval: true` (or
6653
+ a `needsApproval` predicate returning `true`) fails closed before execution with
6654
+ `AgentToolApprovalError` (`reason: 'approval-unsupported'`); a predicate returning `false` lets
6655
+ the safe call proceed.
6656
+ - Pass `retry` (`AgentRetryPolicy`) and optional `onAttemptDiscarded` for stateless retry with
6657
+ `Retry-After` handling; exhausting retries throws `AgentRetryExhaustedError` carrying every failed
6658
+ attempt, `lastError`, and accumulated billable `usage`.
6659
+ - Pass `stopPolicies` (`AgentCompleteStopPolicy[]`) and `idleTimeoutMs` to bound multi-step loops
6660
+ and stalled streams (suspending the idle timer during local tool execution).
6661
+
6662
+ ```ts
6663
+ import { z } from 'zod'
6664
+ import { AgentStructuredOutputError, completeObject } from 'stitchkit/agent-runtime'
6665
+ import { anthropicProvider } from 'stitchkit/agent-runtime/anthropic'
6666
+ import { defineAgentTool } from 'stitchkit/tools'
6667
+
6668
+ const driver = anthropicProvider(
6669
+ { apiKey: env.ANTHROPIC_API_KEY },
6670
+ { defaultPolicy: { maxOutputTokens: 2048 } },
6671
+ ).create('claude-sonnet-4-5')
6672
+
6673
+ const lookup = defineAgentTool({
6674
+ description: 'Fetch record summary',
6675
+ input: z.object({ id: z.string() }),
6676
+ execute: async ({ id }) => db.findSummary(id),
6677
+ })
6678
+
6679
+ const { object, usage, steps } = await completeObject({
6680
+ driver,
6681
+ instructions: 'Return the normalized verdict.',
6682
+ prompt: 'Classify ticket T-42',
6683
+ tools: { lookup },
6684
+ schema: z.object({ severity: z.enum(['low', 'high']), summary: z.string() }),
6685
+ })
6686
+ ```
6687
+
6688
+ `completeObject` projects the Zod schema through `toJsonSchema(schema, 'input')` (supporting
6689
+ `.transform()` and `.default()`), strips strict-mode synthesized `null`s on optional non-nullable
6690
+ fields before `schema.safeParse`, validates `schemaName` through `AgentModelResponseFormatSchema`,
6691
+ and throws `AgentStructuredOutputError` (`reason: 'truncated' | 'tool-calls' | 'content-filter' |
6692
+ 'provider-error' | 'interrupted' | 'empty' | 'invalid-json' | 'schema-mismatch'`, with
6693
+ `finishReason`, `rawText`, `steps`, and `usage`) when the response cannot satisfy the schema.
6694
+
6695
+ For durable runs, the native loop also exposes:
6696
+
6697
+ - `loop.maxDurationMs` — hard wall-clock run deadline (`number | null`) that never pauses during
6698
+ tool execution or resets on provider deltas, distinct from `loop.idleTimeoutMs`.
6699
+ - `loop.beforeStepToolCalls` — a whole-step batch policy invoked once all tool calls of a step are
6700
+ parsed and validated, returning `{ refuse: Map<toolCallId, Error> }` for any call to reject.
6701
+ - `loop.stepBarriers.onMaxReasoningChars: 'abort' | 'finish-length'` — `'abort'` (default) ends the
6702
+ run as `policy_stop`; `'finish-length'` cuts only the current step cleanly with
6703
+ `finishReason: 'length'` so `protocol.acceptTerminal` can run a recovery continuation.
6704
+ - `loop.stepBarriers.onPredecessorFailure: 'refuse'` — fail-cascades dependent calls waiting on
6705
+ the same entity with `STEP_PREDECESSOR_FAILED` when an earlier call fails execution, fails input
6706
+ validation, is refused by `beforeStepToolCalls`, or returns a payload matching
6707
+ `isToolResultFailure(output)`.
6708
+ - `loop.stepBarriers.stepText: 'after-tools'` with optional `stepTextOnInterrupt: 'drop' | 'flush'`
6709
+ and `filterStepText(text, { step, interrupted, finishReason, toolCalls, toolResults })` — holds
6710
+ premature step text when any tool fails (including `isToolResultFailure`) or requests approval,
6711
+ and lets callers flush or transform held text cleanly.
6712
+ - `loop.toolApproval` per-tool rule maps infer each tool's typed `input` from `TOOLS[K]`.
6713
+ - `protocol.acceptTerminal` returning `{ action: 'continue', message, instructions? }` — runs a
6714
+ bounded continuation step capped by `loop.maxContinuations` (default 3); use `carriedToolWork`
6715
+ to inspect whether earlier steps executed tools.
6716
+ - `loop.onAttemptDiscarded` and `loop.onToolInputStart` — observe discarded retry attempts (with
6717
+ failure reason and billed usage) and streamed tool-input starts.
6455
6718
 
6456
6719
  ## Bounded deferred tool catalogs
6457
6720
 
@@ -6557,7 +6820,7 @@ has no side effect; an external supervisor owns process placement and restart.
6557
6820
  | execution loop | `createAgentRuntime` | already available; do not copy a second loop |
6558
6821
  | model choice | `defineModelRegistry` and `models.resolve` | provider credentials/discovery stay application-owned |
6559
6822
  | resources | `createHeadlessAgentHarness` → `composeAgentPrompt` | paths, trust, precedence and watching stay application-owned |
6560
- | tools | `mountAgent` + `createAgentToolFenceLifecycle` | auth and domain effects stay application-owned |
6823
+ | tools | `mountAgentTools` + `createAgentToolFenceLifecycle` | auth and domain effects stay application-owned |
6561
6824
  | follow-up | `runs.inputPolicy: 'queue'` | durable FIFO after the current run |
6562
6825
  | interrupt | `interrupt` or `interrupt-next` | `interrupt-next` terminates the active run and gives the new durable admission next priority |
6563
6826
  | recovery | `runtime.recover` + `scanRecoverable` | replay safety and context reconstruction are explicit callbacks |
@@ -6576,13 +6839,14 @@ and requests a fresh snapshot. It never writes a second frame concurrently with
6576
6839
  `reduceAgentControlSnapshot` and `reduceAgentControlEvent`; the reducer owns no renderer and marks a
6577
6840
  conversation `resyncRequired` after a transient sequence gap.
6578
6841
 
6579
- Configure `loop.toolApproval` to use the installed AI SDK approval policy and
6580
- `loop.toolApprovalSecret` to sign exact requests. A request is stored on the terminal assistant
6581
- before any effect. `pendingApprovals()` derives unresolved requests from canonical messages;
6582
- `respondToApproval()` writes one tool-role approval response and queues a successor. The SDK
6583
- revalidates the signature/tool call/input before the original direct tool reaches its existing
6584
- fence. Reconnect and SQLite reopen require no promise registry. Remembered policy and a stronger
6585
- cross-crash exactly-once guarantee remain application concerns.
6842
+ Configure `loop.toolApproval` for the runtime's native approval policy and
6843
+ `loop.toolApprovalSecret` to bind exact requests with WebCrypto HMAC-SHA256 signatures. A request
6844
+ is stored on the terminal assistant before any effect. `pendingApprovals()` derives unresolved
6845
+ requests from canonical messages; `respondToApproval()` writes one tool-role approval response and
6846
+ queues a successor. The native loop revalidates the signature/tool call/input once before any
6847
+ retry attempts and before the original direct tool reaches its existing fence. Reconnect and SQLite
6848
+ reopen require no promise registry. Remembered policy and a stronger cross-crash exactly-once
6849
+ guarantee remain application concerns.
6586
6850
 
6587
6851
  Approval requests suspend a call; they do not settle its result. History carries exact call and
6588
6852
  approval identity across assistant/tool records, so an approved result can precede the next signed
@@ -7180,8 +7444,9 @@ Third-party drivers must provide atomic write transactions and archive support f
7180
7444
  requests and completed provider response identities enter the same append-only ledger. A
7181
7445
  `provider/response` payload binds `response: { id, provider? }` to its `runId`, retry `attempt` and
7182
7446
  `stepNumber`; `step-finished.response` projects the same object to the operator sink. The optional
7183
- upstream name comes from the model provider's own `resolveResponseProvider` — `openRouterProvider`
7184
- supplies it — so the runtime carries the fact without learning any gateway's metadata key. The normalized
7447
+ upstream name comes from the `AgentModelDriver` `finish.responseProvider` field (emitted directly by
7448
+ `openRouterProvider`, or supplied via `FromAiSdkModelOptions.resolveResponseProvider` for AI SDK
7449
+ models) so the runtime carries the fact without learning any gateway's metadata key. The normalized
7185
7450
  head/run/message tables remain the fast operational projection.
7186
7451
 
7187
7452
  For `runtime/transition` payload inspection, use `AgentStoreTransitionRecordSchema` and its
@@ -7230,7 +7495,7 @@ are built per run:
7230
7495
  createAgentRuntime({
7231
7496
  ...config,
7232
7497
  tools: (run) =>
7233
- mountAgent([], {
7498
+ mountAgentTools({
7234
7499
  access: { gate: run.toolFenceLifecycle },
7235
7500
  runtimeTools: createAgentStateTools({ state, run }),
7236
7501
  }),
@@ -7353,8 +7618,11 @@ behind its bounded result locator.
7353
7618
  `AgentStepSpend & AgentRuntimeRunContext<CONTEXT>` fact for every billed model step
7354
7619
  (`phase: 'step'`), billed retried attempt (`phase: 'abandoned-attempt'`), and compaction call
7355
7620
  (`phase: 'compaction'`), after the `provider/response` ledger entry (which now persists `usage` in
7356
- the non-audited ledger too) is written. The same fact feeds `observe` `step-finished` events and run
7357
- totals.
7621
+ the non-audited ledger too) is written. Step facts and `observe` `step-finished` events both carry
7622
+ `finishReason`, `rawFinishReason`, `toolCallCount`, `costDetails` (`promptCostUsd`, `outputCostUsd`,
7623
+ `isByok`), split `timings` (`ttftMs`, `responseTimeMs`, `toolExecutionMs`, `stepTimeMs`, plus
7624
+ optional `chunkIntervalsMs` percentiles when a step streams two or more output deltas), and
7625
+ `response.{id, provider, modelId, timestamp}`. The same fact feeds run totals.
7358
7626
 
7359
7627
  `onStepSpend` is awaited up to `stepSpendTimeoutMs` (default `5_000` ms): the run does not start its
7360
7628
  next step, or retry a discarded attempt, until the hook settles, so a slow hook adds its time to
@@ -7995,18 +8263,18 @@ and replay are detached snapshots; mutating a returned object cannot rewrite a r
7995
8263
  The optional [sandbox coding profile](sandbox.md#coding-tool-integration) reuses the
7996
8264
  same tool mounting, authorization and output handling for namespace-backed commands.
7997
8265
 
7998
- Always compose `toolFenceLifecycle` into `mountAgent`. It checks ownership
8266
+ Always compose `toolFenceLifecycle` into `mountAgentTools`. It checks ownership
7999
8267
  before a managed side effect and again before accepting its result. Fence loss
8000
8268
  uses an internal control signal: it stops the old loop and is not sent to the
8001
8269
  model as a tool error.
8002
8270
 
8003
- `mountAgent` sends failed runner outcomes through the AI SDK's tool-error
8004
- channel. AgentRuntime persists them with `outcome: 'error'`, publishes the same
8005
- safe envelope, and replays them as an error result on later turns. Classification
8006
- comes from the execution channel, never from inspecting output fields: a valid
8007
- successful result such as `{ error: 'domain value' }` remains successful. Typed
8008
- `AppError` codes and safe details may reach the model; arbitrary thrown causes
8009
- are retained for local hooks and reduced to `INTERNAL_SERVER_ERROR` outside.
8271
+ `mountAgentTools` throws `AgentToolError` for failed runner outcomes. AgentRuntime
8272
+ persists them with `outcome: 'error'`, publishes the same safe envelope, and replays
8273
+ them as an error result on later turns. Classification comes from the execution
8274
+ channel, never from inspecting output fields: a valid successful result such as
8275
+ `{ error: 'domain value' }` remains successful. Typed `AppError` codes and safe
8276
+ details may reach the model; arbitrary thrown causes are retained for local hooks
8277
+ and reduced to `INTERNAL_SERVER_ERROR` outside.
8010
8278
 
8011
8279
  The framework cannot undo an already-started non-cooperative external effect.
8012
8280
  Pass the stable call/run idempotency identity into business mutations when the
@@ -8014,8 +8282,8 @@ effect must be replay-safe.
8014
8282
 
8015
8283
  ## History, provider metadata and files
8016
8284
 
8017
- `projectAgentHistory` converts canonical engine records into provider-valid AI
8018
- SDK messages and pairs tool calls/results in persisted causal order. Adjacent
8285
+ `projectAgentHistory` converts canonical engine records into provider-valid
8286
+ `AgentModelMessage[]` and pairs tool calls/results in persisted causal order. Adjacent
8019
8287
  parallel calls stay in one assistant round and their adjacent results stay in
8020
8288
  one tool round; a dependent call after those results starts a new assistant
8021
8289
  round, and trailing final text remains after the last tool result. Provider-required metadata is kept
@@ -8029,8 +8297,10 @@ complete turns, protects system/summary, incomplete and configured recent turns,
8029
8297
  keep/remove reason with measured/estimated/unavailable token provenance. An oversized protected turn
8030
8298
  returns `oversized`; unavailable accounting returns `unavailable` without invented arithmetic.
8031
8299
 
8032
- `ComposedAgentPrompt.instructions` accepts the AI SDK `Instructions` contract.
8033
- Use `adaptInstructions` when a provider needs metadata on the system message:
8300
+ `ComposedAgentPrompt.instructions` accepts `AgentInstructions` (a string, one
8301
+ `AgentModelSystemMessage`, or an ordered array of `AgentModelSystemMessage`).
8302
+ Use `adaptInstructions` when a provider needs cache control or provider options on
8303
+ the system message:
8034
8304
 
8035
8305
  ```ts
8036
8306
  prompt({
@@ -8039,7 +8309,7 @@ prompt({
8039
8309
  adaptInstructions: (content) => ({
8040
8310
  role: 'system',
8041
8311
  content,
8042
- providerOptions: { openrouter: { cacheControl: { type: 'ephemeral' } } },
8312
+ cacheControl: { type: 'ephemeral' },
8043
8313
  }),
8044
8314
  })
8045
8315
  ```
@@ -8049,8 +8319,8 @@ stores a reference returned by `persistGeneratedFile`; it never silently puts
8049
8319
  base64 blobs into the neutral history store.
8050
8320
 
8051
8321
  To send a stored attachment back to a multimodal model, configure
8052
- `history.resolveFile`. It maps the neutral file reference to AI SDK file data
8053
- (URL, bytes, provider reference or text). Without a resolver the
8322
+ `history.resolveFile`. It maps the neutral file reference to tagged
8323
+ `AgentModelFileData` (`{ type: 'data' | 'url' | 'reference' | 'text', ... }`). Without a resolver the
8054
8324
  `unresolvedFile` policy applies, and it is **`omit`** by default: the file part
8055
8325
  simply does not reach the provider. Choose `text` for a describing placeholder —
8056
8326
  the filename or media type, never the storage reference, because that string is
@@ -8069,7 +8339,12 @@ and prompt. Pass `previousSummary` for a direct call, or configure
8069
8339
  `readPreviousSummary` for runtime-managed compaction, to merge and atomically
8070
8340
  replace a leading summary on the next compaction.
8071
8341
  Set `maxAttempts` to allow bounded conflict recovery. Every retry reloads the snapshot, reselects the
8072
- eligible range and recomputes the summary; the stale summary is never retried.
8342
+ eligible range and recomputes the summary; the stale summary is never retried. Inside
8343
+ `createAgentRuntime`, `history.compact` runs after `models.resolve` and receives the resolved
8344
+ `model` descriptor (including `contextWindow`), `tools`, and `context`. `structuredCompaction`'s
8345
+ `summarize` callback may return either the parsed summary directly or `{ summary, usage }` so
8346
+ `structuredCompaction` accumulates `usage` across `maxAttempts` CAS retries and hands it directly to
8347
+ run totals and `onStepSpend`.
8073
8348
 
8074
8349
  ### Recovering a prefix after a failed turn
8075
8350
 
@@ -8180,9 +8455,9 @@ Read the provenance before the number (→ ADR 0109):
8180
8455
  - **`provider-reported`** — the provider handed us exactly this. On
8181
8456
  `step-finished`, that is what a step's figures are.
8182
8457
  - **`computed`** — a total, added up over steps. **Every figure on a terminal
8183
- event is this**, tokens included: the AI SDK's `totalUsage` is a sum it
8184
- performed, not a number a provider reported for the run. It is not a figure to
8185
- bill against unchanged.
8458
+ event is this**, tokens included: the run sums step usage across steps rather
8459
+ than reporting one provider-stated total for the whole run. It is not a figure
8460
+ to bill against unchanged.
8186
8461
  - **`unavailable`** — nobody reported it. Not zero.
8187
8462
 
8188
8463
  Two rules follow from that last one, and they differ by field on purpose:
@@ -8377,14 +8652,14 @@ in SQLite — so admission costs the same on a long conversation as on a new one
8377
8652
  `store.findEventOnce({ conversationId, kind, key })` reads the same event back.
8378
8653
  Invocation payload artifacts are keyed by their artifact id the same way.
8379
8654
 
8380
- ### Migration from direct SDK completions
8655
+ ### Migration from direct provider completions
8381
8656
 
8382
8657
  **Who must act:** applications opting into shared completion/agent receipts.
8383
- Replace the direct `generateText` call with `invocations.complete`, configure host
8658
+ Replace direct unlogged model calls with `invocations.complete` (or `completeText` /
8659
+ `completeObject` when no durable receipt ledger is needed), configure host
8384
8660
  authorization and a retained payload key, and pass the same ledger in the agent's
8385
8661
  `invocations` option. Use the returned invocation ID and the paginated `read` method
8386
- for receipt queries; do not import runtime internals. Available since 0.100.0;
8387
- existing runtime configurations need no migration.
8662
+ for receipt queries; do not import runtime internals.
8388
8663
 
8389
8664
 
8390
8665
  ==============================================================================
@@ -9933,6 +10208,56 @@ Custom backends implement `SandboxDriver` byte I/O, `spawn` and policy enforceme
9933
10208
  workspace-relative or canonical `/workspace/...` paths. Unsupported policies must
9934
10209
  be refused explicitly by the backend.
9935
10210
 
10211
+ ## Long-lived process sandbox (`createProcessSandbox`)
10212
+
10213
+ When isolating a long-lived streaming stdio or IPC engine process (such as Codex or an ACP agent)
10214
+ that must keep its real host workspace path and streaming pipes, use `createProcessSandbox` and
10215
+ `probeProcessSandbox`. Its `wrapCommand` method matches `AcpDriverConfig.wrapCommand` and
10216
+ `CodexDriverConfig.wrapCommand` structurally:
10217
+
10218
+ ```ts
10219
+ import { createProcessSandbox, probeProcessSandbox } from 'stitchkit/agent-runtime/sandbox';
10220
+ import { createCodexDriver } from 'stitchkit/agent-executor/codex';
10221
+
10222
+ const probe = await probeProcessSandbox();
10223
+ if (!probe.available) throw new Error(probe.reason);
10224
+
10225
+ const sandbox = createProcessSandbox({
10226
+ profile: 'workspace-readonly', // or 'workspace-strict' for read-write workspace
10227
+ workspace: '/srv/spaces/space-a',
10228
+ writableDirs: ['/srv/profiles/codex-a'],
10229
+ denyPaths: ['/srv/state/control/api.sock'],
10230
+ unixSockets: [{ hostPath: '/srv/spaces/space-a/mcp.sock' }],
10231
+ homeDir: '/srv/profiles/codex-a',
10232
+ privateTmpDir: '/srv/tmp/space-a',
10233
+ envAllowlist: ['PATH', 'HOME', 'TMPDIR'],
10234
+ network: 'deny',
10235
+ });
10236
+
10237
+ const driver = createCodexDriver({ wrapCommand: sandbox.wrapCommand });
10238
+ ```
10239
+
10240
+ - **Fail-closed availability:** `wrapCommand` probes the OS backend before its first wrap and
10241
+ throws `SandboxError('SANDBOX_UNAVAILABLE', ...)` if `bwrap` or `sandbox-exec` is unavailable or
10242
+ the platform is unsupported; there is no unsandboxed fallback.
10243
+ - **Symlink-safe `workspace-readonly`:** `ProcessSandboxSpecSchema` resolves symlinks via
10244
+ `realpathSync` so none of `writableDirs`, `privateTmpDir`, or `homeDir` can overlap `workspace`
10245
+ through a symlink.
10246
+ - **Platform read/write models differ:**
10247
+ - **Linux (`bwrap`):** mount-namespace allowlist — only mounted system roots, `workspace`,
10248
+ `readOnlyPaths`, `writableDirs`, `privateTmpDir`, `homeDir`, and `unixSockets` exist inside the
10249
+ sandbox; unmounted host paths are absent, and `denyPaths` inside mounted roots (including
10250
+ `/bin` and `/sbin`) are masked over `/dev/null` or an empty `tmpfs`. A `cwd` outside mounted
10251
+ roots (such as `driver.info()` / `driver.status()`) falls back to `workspace`.
10252
+ - **macOS (`sandbox-exec` Seatbelt, compiled by `buildSeatbeltProfile`):** default-deny writes
10253
+ with default-allow reads — writes are denied globally except `privateTmpDir`, `workspace`
10254
+ (`workspace-strict`), `homeDir`, `writableDirs`, and explicitly allowed `unixSockets` (with
10255
+ `workspace` denied for writes in `workspace-readonly`, and explicit socket allows ordered after
10256
+ that deny and before `denyPaths`). Reads remain permitted by default for macOS frameworks and
10257
+ binaries except paths listed in `denyPaths`, so callers on macOS must explicitly add control
10258
+ sockets, sibling workspaces, and host secrets to `denyPaths`. Seatbelt cannot remap Unix socket
10259
+ paths: supplying `mountPath !== hostPath` fails closed with `SANDBOX_UNAVAILABLE`.
10260
+
9936
10261
 
9937
10262
  ==============================================================================
9938
10263
  # Guide: Native IO (docs/guide/native-io.md)
@@ -14482,6 +14807,115 @@ each exact argument set to its query key. No global domain/query registry or new
14482
14807
  UI components are needed. Reconnect and revision/delta recovery remain owned by the
14483
14808
  watch client; silent lost notifications are repaired by hub reconciliation.
14484
14809
 
14810
+ ## Account-scoped device presence
14811
+
14812
+ When an account spans multiple online devices (desktop, mobile, web) that advertise typed
14813
+ capability state and accept targeted remote commands, mount device presence onto your existing
14814
+ `RealtimeServerHandle` instead of opening a second connection:
14815
+
14816
+ ```ts
14817
+ // shared/presence.ts
14818
+ import { createDevicePresenceContract } from 'stitchkit/realtime'
14819
+ import { z } from 'zod'
14820
+
14821
+ export const devicePresence = createDevicePresenceContract({
14822
+ mic: {
14823
+ state: z.strictObject({ recording: z.boolean() }),
14824
+ command: z.discriminatedUnion('action', [
14825
+ z.strictObject({ action: z.literal('start') }),
14826
+ z.strictObject({ action: z.literal('stop') }),
14827
+ ]),
14828
+ result: z.strictObject({ recording: z.boolean() }),
14829
+ },
14830
+ })
14831
+
14832
+ // server (stitchkit/server)
14833
+ import { bindDevicePresence } from 'stitchkit/server'
14834
+
14835
+ const presence = bindDevicePresence(devicePresence, socket, {
14836
+ accountOf: (identity) => identity.userId ?? null, // null refuses non-user principals
14837
+ })
14838
+ // Call presence.readmit(socketId) after logout or permission changes to evict immediately.
14839
+
14840
+ // device client (stitchkit/realtime)
14841
+ import { createDevicePresenceClient } from 'stitchkit/realtime'
14842
+
14843
+ const client = createDevicePresenceClient(devicePresence, {
14844
+ transport,
14845
+ device: { deviceId: 'desktop-1', name: 'Desktop', platform: 'macos' },
14846
+ capabilities: ['mic'],
14847
+ initialStates: { mic: { recording: false } },
14848
+ })
14849
+
14850
+ const offMic = client.onCommand('mic', async (command) => ({
14851
+ recording: command.action === 'start',
14852
+ }))
14853
+
14854
+ // Send a typed command from another device in the same account:
14855
+ const ack = await client.sendCommand({
14856
+ targetDeviceId: 'desktop-1',
14857
+ capability: 'mic',
14858
+ command: { action: 'stop' },
14859
+ })
14860
+ ```
14861
+
14862
+ Each account's online device list is versioned (`revision`), capacity-bounded
14863
+ (`maxDevicesPerAccount`), and scoped strictly to `accountOf(handshakeIdentity)`. Local capability
14864
+ states are republished automatically after reconnect (`publishState(capability, state | null)`),
14865
+ and `createDevicePresenceRelayAdapter` in `stitchkit/realtime` can mirror a `DeviceRelayAgent`'s
14866
+ liveness into a `DevicePresenceRelayStateSchema` capability slot.
14867
+
14868
+ ## User Device Relay (`stitchkit/device-relay`)
14869
+
14870
+ `stitchkit/device-relay` is a peer-free evolving entrypoint for reaching a user-owned device behind
14871
+ NAT over an outbound realtime connection — multiplexing Fetch-compatible unary RPCs and
14872
+ credit-paced cursor streams without exposing inbound device ports:
14873
+
14874
+ ```ts
14875
+ // server (stitchkit/server + stitchkit/device-relay)
14876
+ import { bindRealtimeServer } from 'stitchkit/server'
14877
+ import {
14878
+ createDeviceRelayHub,
14879
+ createMemoryRelayBroker,
14880
+ DEVICE_RELAY_ORIGIN,
14881
+ deviceRelayRealtimeContract,
14882
+ } from 'stitchkit/device-relay'
14883
+
14884
+ const hub = createDeviceRelayHub<SocketIdentity>({
14885
+ broker: createMemoryRelayBroker(),
14886
+ authenticateDevice: ({ identity }) =>
14887
+ identity.userId ? { accountId: identity.userId, deviceId: identity.deviceId } : null,
14888
+ })
14889
+ const unbindRelay = hub.bindRealtime(bindRealtimeServer(deviceRelayRealtimeContract, socket))
14890
+
14891
+ const relayFetch = hub.createRelayFetch({ accountId: 'user-1', deviceId: 'mac-1' })
14892
+ // DEVICE_RELAY_ORIGIN is 'http://device-relay.invalid' (relative paths like '/local/status' also work):
14893
+ const response = await relayFetch(`${DEVICE_RELAY_ORIGIN}/local/status`)
14894
+
14895
+ // device agent (stitchkit/device-relay)
14896
+ import { createDeviceRelayAgent } from 'stitchkit/device-relay'
14897
+
14898
+ const agent = createDeviceRelayAgent({
14899
+ transport,
14900
+ deviceId: 'mac-1',
14901
+ capabilities: ['rpc'],
14902
+ allowRpc: [{ methods: ['GET'], pathPrefix: '/local/' }],
14903
+ fetch: (input, init) => localHandler(input, init),
14904
+ })
14905
+ ```
14906
+
14907
+ - **Fail-closed routing and bounds:** unknown/offline devices, unauthorized callers, unallowlisted
14908
+ paths or topics, oversized payloads, and RPC/stream capacity limits reject with typed
14909
+ `DeviceRelayError` codes (`UNAUTHORIZED`, `FORBIDDEN`, `IDENTITY_MISMATCH`,
14910
+ `OPERATION_NOT_ALLOWED`, `INVALID_REQUEST`, `PAYLOAD_TOO_LARGE`, `DEVICE_OFFLINE`,
14911
+ `DELIVERY_UNKNOWN`, `DEVICE_BUSY`, `STREAM_CAPACITY`, `STREAM_UNAVAILABLE`, `STREAM_OVERFLOW`,
14912
+ `FRAME_UNREPRESENTABLE`, `TIMEOUT`, `TRANSPORT_ERROR`, `BROKER_UNAVAILABLE`, `CLOSED`).
14913
+ - **Backpressure and resume:** `hub.openRelayStream({ accountId, deviceId, topic, cursor?, share? })`
14914
+ issues explicit credit frames (`DeviceRelayStreamCredit`) and carries opaque cursors so a
14915
+ reconnected consumer can resume without unbounded hub buffering.
14916
+ - **Horizontal scale:** replace `createMemoryRelayBroker()` with your own `RelayBrokerPort` (for
14917
+ example over Redis or Postgres pub/sub) when multiple server instances hold device sockets.
14918
+
14485
14919
 
14486
14920
  ==============================================================================
14487
14921
  # Guide: Live data (docs/guide/live.md)
@@ -16800,7 +17234,8 @@ fails a project's tests when a call goes around the gateway.
16800
17234
  ## The gateway
16801
17235
 
16802
17236
  ```ts
16803
- import { createOpenRouter } from '@openrouter/ai-sdk-provider';
17237
+ import { completeText, modelInvocationSpendAttribution } from 'stitchkit/agent-runtime';
17238
+ import { openRouterProvider } from 'stitchkit/agent-runtime/openrouter';
16804
17239
  import {
16805
17240
  createSpendGateway,
16806
17241
  openAiCompatibleUsage,
@@ -16821,11 +17256,14 @@ const gateway = createSpendGateway({
16821
17256
  context: modelInvocationSpendAttribution, // from stitchkit/agent-runtime
16822
17257
  });
16823
17258
 
16824
- // The gateway adds the real key; the SDK only needs a placeholder to start.
16825
- const openrouter = createOpenRouter({ apiKey: 'set-by-gateway', fetch: gateway.fetchFor('openrouter') });
17259
+ // The gateway adds the real key; the driver only needs a placeholder to start.
17260
+ const openrouter = openRouterProvider({
17261
+ apiKey: 'set-by-gateway',
17262
+ fetch: gateway.fetchFor('openrouter'),
17263
+ });
16826
17264
 
16827
17265
  await runWithSpendAttribution({ purpose: 'title', scope: spaceId, labels: { env } }, () =>
16828
- generateText({ model: openrouter('openai/gpt-5-mini'), prompt }),
17266
+ completeText({ driver: openrouter.create('openai/gpt-5-mini'), prompt }),
16829
17267
  );
16830
17268
  ```
16831
17269
 
@@ -16914,8 +17352,9 @@ test('every model call goes through the spend gateway', async () => {
16914
17352
  root: 'src',
16915
17353
  policy: {
16916
17354
  modules: [
16917
- { module: 'ai', symbols: ['streamText', 'generateText', 'generateObject', 'streamObject'] },
16918
- { module: '@openrouter/ai-sdk-provider' },
17355
+ { module: 'stitchkit/agent-runtime/openrouter', symbols: ['openRouterProvider'] },
17356
+ { module: 'stitchkit/agent-runtime/openai', symbols: ['openAiProvider'] },
17357
+ { module: 'stitchkit/agent-runtime/anthropic', symbols: ['anthropicProvider'] },
16919
17358
  ],
16920
17359
  envKeys: ['OPENROUTER_API_KEY'],
16921
17360
  hosts: ['openrouter.ai'],
@@ -20109,6 +20548,176 @@ charts, no merged cells and no streaming: an application that needs them takes a
20109
20548
 
20110
20549
  # Upgrading stitchkit
20111
20550
 
20551
+ ## Released migration: 0.134.0
20552
+
20553
+ ### agent-runtime-native-model-port
20554
+
20555
+ **Who must act:** applications using `stitchkit/agent-runtime` or `stitchkit/agent-runtime/harness` with AI SDK `LanguageModel`, `ToolSet`, `ModelMessage`, or `LanguageModelUsage` types.
20556
+
20557
+ `stitchkit/agent-runtime` now executes models exclusively through `AgentModelDriver` (one provider call per step, zero AI SDK dependencies). Migrate cleanly in two steps:
20558
+
20559
+ #### Step 1 — Mechanical compatibility (keep existing AI SDK models and tools)
20560
+
20561
+ 1. Rename `AgentLanguageModelProvider` to `AgentModelDriverFactory` and `AgentResolvedModel.model` to `AgentResolvedModel.driver`.
20562
+ 2. Wrap any AI SDK v4 `LanguageModel` with `fromAiSdkModel` and any AI SDK `ToolSet` (including `mountAgent(...)`) with `fromAiSdkTools` from `stitchkit/agent-runtime/ai-sdk`.
20563
+ 3. Update `history.resolveFile` to return tagged `AgentModelFileData` (`{ type: 'data', data }`, `{ type: 'url', url }`, `{ type: 'reference', reference }`, or `{ type: 'text', text }`), and read `AgentGeneratedFile` (`file.mediaType`, `file.data`, `file.uint8Array`, `file.base64`, `file.url`) in `persistGeneratedFile`.
20564
+ 4. Update `prepareStep` and `stopPolicies` to read peer-free `AgentStepResult` / `AgentModelMessage` / `AgentInstructions`. `AgentRuntimeStopPolicy<CONTEXT>` now takes a single `<CONTEXT>` generic (removing the unused first generic), and all tool events in `AgentModelStreamPart` and `CompleteStreamPart` use unified `toolCallId`.
20565
+
20566
+ ```ts
20567
+ // Before
20568
+ import { mountAgent } from 'stitchkit/tools/agent';
20569
+
20570
+ const runtime = createAgentRuntime({
20571
+ models: { resolve: () => ({ descriptor, model: aiSdkModel }) },
20572
+ tools: (ctx) =>
20573
+ mountAgent(services, {
20574
+ context: ctx.context,
20575
+ access: { gate: ctx.toolFenceLifecycle },
20576
+ }),
20577
+ // ...
20578
+ });
20579
+
20580
+ // After (Step 1: compatibility adapter)
20581
+ import { fromAiSdkModel, fromAiSdkTools } from 'stitchkit/agent-runtime/ai-sdk';
20582
+ import { mountAgent } from 'stitchkit/tools/agent';
20583
+
20584
+ const runtime = createAgentRuntime({
20585
+ models: { resolve: () => ({ descriptor, driver: fromAiSdkModel(aiSdkModel) }) },
20586
+ tools: (ctx) =>
20587
+ fromAiSdkTools(
20588
+ mountAgent(services, {
20589
+ context: ctx.context,
20590
+ access: { gate: ctx.toolFenceLifecycle },
20591
+ }),
20592
+ ),
20593
+ // ...
20594
+ });
20595
+ ```
20596
+
20597
+ #### Step 2 — Full peer-free migration (remove `ai` and `@openrouter/ai-sdk-provider`)
20598
+
20599
+ 1. Replace `fromAiSdkModel(...)` with one of the three peer-free native providers:
20600
+ - `openRouterProvider` from `stitchkit/agent-runtime/openrouter`
20601
+ - `openAiProvider` from `stitchkit/agent-runtime/openai`
20602
+ - `anthropicProvider` from `stitchkit/agent-runtime/anthropic`
20603
+ 2. Replace `fromAiSdkTools(mountAgent(...))` with `mountAgentTools(...)` from `stitchkit/tools`, and replace custom AI SDK `tool(...)` declarations with `defineAgentTool(...)` from `stitchkit/tools`.
20604
+ 3. Replace direct `generateText` / `generateObject` helper calls with `completeText` / `completeObject` from `stitchkit/agent-runtime`, and replace `wrapLanguageModel` middleware with `wrapModelDriver` / `composeModelDrivers`.
20605
+ 4. Remove `ai` and `@openrouter/ai-sdk-provider` from `package.json` if nothing else in your project uses `stitchkit/tools/agent` or `stitchkit/agent-runtime/ai-sdk`.
20606
+
20607
+ ```ts
20608
+ // After (Step 2: completely peer-free)
20609
+ import { openRouterProvider } from 'stitchkit/agent-runtime/openrouter';
20610
+ import { defineAgentTool, mountAgentTools } from 'stitchkit/tools';
20611
+
20612
+ const openrouter = openRouterProvider({ apiKey: env.OPENROUTER_API_KEY });
20613
+
20614
+ const runtime = createAgentRuntime({
20615
+ models: {
20616
+ resolve: () => ({ descriptor, driver: openrouter.create(descriptor.modelId) }),
20617
+ },
20618
+ tools: (ctx) =>
20619
+ mountAgentTools(services, {
20620
+ context: ctx.context,
20621
+ access: { gate: ctx.toolFenceLifecycle },
20622
+ }),
20623
+ // ...
20624
+ });
20625
+ ```
20626
+
20627
+ ### openrouter-native-driver
20628
+
20629
+ **Who must act:** applications using `stitchkit/agent-runtime/openrouter` with `baseURL`, `extraHeaders`, `provider_api_keys`, or `@openrouter/ai-sdk-provider`.
20630
+
20631
+ `openRouterProvider` now talks directly to OpenRouter's Chat Completions SSE endpoint over Web `fetch` and requires no optional peers. Update settings keys to camelCase and uninstall `@openrouter/ai-sdk-provider`:
20632
+
20633
+ ```ts
20634
+ // Before
20635
+ const provider = openRouterProvider({
20636
+ apiKey: env.OPENROUTER_API_KEY,
20637
+ baseURL: 'https://openrouter.ai/api/v1',
20638
+ });
20639
+
20640
+ // After
20641
+ const provider = openRouterProvider({
20642
+ apiKey: env.OPENROUTER_API_KEY,
20643
+ baseUrl: 'https://openrouter.ai/api/v1',
20644
+ appName: 'my-app',
20645
+ appUrl: 'https://example.com',
20646
+ providerApiKeys: { anthropic: env.ANTHROPIC_BYOK_KEY },
20647
+ });
20648
+ ```
20649
+
20650
+ `OpenRouterProviderAccess.sessionPerConversation` now reads `request.correlation.conversationId` directly and no longer requires configuring `invocations`.
20651
+
20652
+ ### tools-agent-tool-model-output
20653
+
20654
+ **Who must act:** callers of `stitchkit/tools` referencing `RuntimeAgentModelOutput` or returning legacy deprecated AI SDK tool-output shapes (`file-data`, `image-data`, `file-url`, `image-url`, `file-id`, `image-file-id`) from `present.agent`.
20655
+
20656
+ 1. Rename `RuntimeAgentModelOutput` imports to `AgentToolModelOutput` from `stitchkit/tools`.
20657
+ 2. Replace deprecated content part kinds inside `present.agent` with canonical `{ type: 'file', data, mediaType, filename? }`:
20658
+
20659
+ ```ts
20660
+ // Before
20661
+ import type { RuntimeAgentModelOutput } from 'stitchkit/tools';
20662
+ const output: RuntimeAgentModelOutput = {
20663
+ type: 'content',
20664
+ value: [
20665
+ { type: 'image-data', data: base64Png, mediaType: 'image/png' },
20666
+ { type: 'file-url', url: 'https://example.com/report.pdf', mediaType: 'application/pdf' },
20667
+ ],
20668
+ };
20669
+
20670
+ // After
20671
+ import type { AgentToolModelOutput } from 'stitchkit/tools';
20672
+ const output: AgentToolModelOutput = {
20673
+ type: 'content',
20674
+ value: [
20675
+ { type: 'file', data: { type: 'data', data: base64Png }, mediaType: 'image/png' },
20676
+ {
20677
+ type: 'file',
20678
+ data: { type: 'url', url: new URL('https://example.com/report.pdf') },
20679
+ mediaType: 'application/pdf',
20680
+ },
20681
+ ],
20682
+ };
20683
+ ```
20684
+
20685
+ Applications using `mountAgent` (`stitchkit/tools/agent`) with their own AI SDK loop continue to work unchanged and receive non-deprecated `{ type: 'file', data, mediaType }` tool outputs.
20686
+
20687
+ ### agent-runtime-testing-replay-driver
20688
+
20689
+ **Who must act:** tests calling `createReplayAgentProvider` from `stitchkit/agent-runtime/testing` expecting an AI SDK `LanguageModel` instead of an `AgentModelDriver`.
20690
+
20691
+ `createReplayAgentProvider` now returns an `AgentModelDriverFactory` whose `.create(modelId)` returns an `AgentModelDriver`. Assign it to `AgentResolvedModel.driver` (or pass it to `completeText`/`completeObject`). For scripted multi-step tests with direct request inspection, use `createScriptedModelDriver` from `stitchkit/agent-runtime/testing`:
20692
+
20693
+ ```ts
20694
+ import { createScriptedModelDriver } from 'stitchkit/agent-runtime/testing';
20695
+
20696
+ const driver = createScriptedModelDriver({
20697
+ steps: [
20698
+ [
20699
+ { type: 'text-delta', id: 't1', delta: 'Hello' },
20700
+ {
20701
+ type: 'finish',
20702
+ finishReason: 'stop',
20703
+ usage: {
20704
+ inputTokens: { value: 10, provenance: 'provider-reported' },
20705
+ outputTokens: { value: 2, provenance: 'provider-reported' },
20706
+ },
20707
+ },
20708
+ ],
20709
+ ],
20710
+ });
20711
+ ```
20712
+
20713
+ ### executor-acp-plan-and-tool-provider
20714
+
20715
+ **Who must act:** every caller of `stitchkit/agent-executor` that switches exhaustively on `ExecutorDelta['type']`, and every operator running an executor and its server on different releases across `0.134.0`.
20716
+
20717
+ `ExecutorDeltaSchema` / `ExecutorDelta` now includes `ExecutorPlanDeltaSchema` (`{ type: 'plan', action, planId?, entries, ... }`) for structured ACP plan lifecycle updates (`plan`, `plan_update`, `plan_removed`), and `ExecutorToolResultDeltaSchema` (plus `AgentToolResultPartSchema`) now carries an optional `provider` envelope for ACP tool metadata (`title`, `kind`, `locations`). `projectExecutorDeltas` ignores `plan` deltas automatically; add a `case 'plan':` branch to any custom exhaustive `switch (delta.type)`.
20718
+
20719
+ **Upgrade the server before any executor.** Every object on the executor ↔ server wire contract is strict (ADR 0334), so a server on `0.133.x` or older refuses a whole `report` carrying either `deltas[].type = 'plan'` or `tool-result.provider`. An older executor writes neither key and keeps working against a `0.134.0` server. In the reverse direction (`server → executor`), `offer.input` now permits an optional `provider` envelope on `text` and `tool-result` parts (because `AgentMessagePartSchema` parts are non-strict, an older executor strips those keys rather than rejecting the offer, so upgrade executors too if you rely on forwarding them). See the full release matrix in the [API reference](../api/reference.md#version-skew-between-an-executor-and-its-server).
20720
+
20112
20721
  ## Released migration: 0.133.0
20113
20722
 
20114
20723
  ### executor-testing-claude-sdk-subpath
@@ -27309,7 +27918,8 @@ from the root `stitchkit`.
27309
27918
  | `ContractDef` | _type_ | a defined contract |
27310
27919
  | `PathParams` | _type_ | infer named `:segments` and a terminal `*wildcard` from a path literal as string params |
27311
27920
  | `ContractMeta` | _type_ | a contract's `prefix` + optional `scope` and `meta` (a default every endpoint shallow-merges over) |
27312
- | `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) |
27921
+ | `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) |
27922
+ | `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?)`) |
27313
27923
  | `OperationEffect` / `OperationEffectSchema` | _type_ / schema | closed `'read' \| 'write'` side-effect classification declared on contract endpoints |
27314
27924
  | `contractOperationEffects` / `requireContractOperationEffects` | function | project declared endpoint `effect` tags from a contract; `requireContractOperationEffects` fails closed and lists every operation missing `effect` |
27315
27925
  | `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) |
@@ -27640,6 +28250,8 @@ Also re-exports the error helpers from `stitchkit/contract`.
27640
28250
 
27641
28251
  | `bindSocketRegistry` | function | room membership and consistent replay over an already-authenticated realtime server |
27642
28252
  | `AuthorizedSocketRoom` / `SocketRegistry` / `SocketRegistryConnection` / `SocketRegistryOptions` / `SocketRegistryServer` / `SocketRegistrySnapshot` / `SocketReplayFrame` | _type_ | authorized room token, structural server boundary, replay frames and immutable registry state |
28253
+ | `bindDevicePresence` | function | mounts account-scoped online device presence, ephemeral capability state slots and targeted remote commands onto an existing `RealtimeServerHandle` |
28254
+ | `DevicePresenceServer` / `DevicePresenceServerOptions` / `DevicePresenceServerSnapshot` / `DevicePresenceAccountResolver` | _type_ | mounted server registry handle, `accountOf` authorization callback and diagnostic snapshot for `bindDevicePresence` |
27643
28255
  | Export | Kind | Summary |
27644
28256
  |--------|------|---------|
27645
28257
  | `createSocketIOServer` | function | the typed Socket.IO server — [guide](../guide/realtime.md#server--createsocketioserver) |
@@ -28101,20 +28713,22 @@ server writing it.
28101
28713
 
28102
28714
  ## `stitchkit/agent-runtime`
28103
28715
 
28104
- Server-only optional application runtime. See the
28716
+ Server-only, peer-free optional application runtime. Runs models exclusively through `AgentModelDriver` (one provider call per step) with no AI SDK dependency. See the
28105
28717
  [agent runtime guide](../guide/agent-runtime.md).
28106
28718
 
28107
28719
  | Export | Kind | Summary |
28108
28720
  |--------|------|---------|
28109
- | `createAgentRuntime` | function | compose durable acceptance, stream loop, checkpoints, coordination, managed tools and winner-only terminal publication; reconciles same-owner terminal/interrupt/head CAS races before releasing the lane |
28110
- | `createDeferredAgentToolSurface` | function | bounded canonical catalog search plus durable same-run activation of direct `mountAgent` tools; supports one immutable surface or a finite identity-specific registry |
28721
+ | `createAgentRuntime` | function | compose durable acceptance, native `AgentModelDriver` step loop, tool parsing/validation, WebCrypto HMAC-SHA256 tool approvals, `beforeStepToolCalls`, bounded terminal continuations (`maxContinuations`), `onAttemptDiscarded`, `onToolInputStart`, checkpoints, coordination, managed tools and winner-only terminal publication; reconciles same-owner terminal/interrupt/head CAS races before releasing the lane |
28722
+ | `createDeferredAgentToolSurface` | function | bounded canonical catalog search plus durable same-run activation of direct `mountAgentTools` tools; supports one immutable surface or a finite identity-specific registry |
28111
28723
  | `DeferredAgentToolSearchInputSchema` / `DeferredAgentToolMatchSchema` / `DeferredAgentToolReceiptSchema` | schema | bounded search input, public match and versioned durable selection receipt |
28112
28724
  | `DeferredAgentToolSurfaceConfig` / `DeferredAgentToolCommonConfig` / `DeferredAgentToolSurfaceDefinition` / `DeferredAgentToolController` | _type_ | finite catalogs, selector, pin, budget and `mount`/`prepareStep` composition contracts |
28113
28725
  | `DeferredAgentRuntimeToolDefinition` / `DeferredAgentToolMountConfig` | _type_ | peer-free Agent-only runtime definition and canonical mount configuration accepted by the controller |
28114
28726
  | `DeferredAgentToolManifestEntry` / `DeferredAgentToolSearchContext` / `DeferredAgentToolReceipt` | _type_ | canonical selector input and inferred durable receipt records |
28115
28727
  | `DeferredAgentToolEvent` | _type_ | PII-free search/step evidence with surface, provenance, counts, canonical schema bytes and ceilings |
28116
- | `defineAgentProtocol` | function | declare context, input metadata, canonical parts and optional pre-CAS terminal acceptance (`allow-empty`, `require-output` or callback) |
28728
+ | `defineAgentProtocol` | function | declare context, input metadata, canonical parts and optional pre-CAS terminal acceptance (`allow-empty`, `require-output` or callback returning `AgentTerminalAcceptanceDecision`) |
28117
28729
  | `hasAgentTerminalOutput` | function | generic `require-output` predicate for non-blank text, generated files, structured provider parts and explicit tool-only policy stops |
28730
+ | `carriedToolWork` | function | pure helper returning whether any completed `AgentStepResult` performed client or provider tool work |
28731
+ | `AgentTerminalAcceptanceDecision` | _type_ | `boolean \| { action: 'accept' } \| { action: 'reject' } \| { action: 'continue', message, instructions? }` returned by `protocol.acceptTerminal` for bounded continuations (capped by `loop.maxContinuations`, default 3) |
28118
28732
  | `AgentMessageSchema` / `AgentRunSchema` / `AgentSnapshotSchema` | schema | versioned canonical engine records |
28119
28733
  | `AgentRunQueuePrioritySchema` | schema | durable opt-in priority for queued `interrupt-next` runs |
28120
28734
  | `AgentRuntimeStore` | _type_ | aggregate CAS transaction boundary for message, run and compaction mutations |
@@ -28139,8 +28753,8 @@ Server-only optional application runtime. See the
28139
28753
  | `AgentConversationPurgeResultSchema` / `AgentConversationPurgeResult` | schema / _type_ | typed deletion/refusal outcomes; active refusal includes run IDs |
28140
28754
  | `AgentConversationPurgedError` | class | runtime mutation rejected because its conversation ID is permanently purged |
28141
28755
  | `AgentConversationPurgeDriver` | _type_ | optional `driver.conversations` capability: serialized tombstone read and atomic removal of all owned records |
28142
- | `projectAgentHistory` | function | asynchronously project canonical records and resolved multimodal files into provider-valid AI SDK messages |
28143
- | `defineModelRegistry` | function | typed language-model descriptors, capabilities and provider construction |
28756
+ | `projectAgentHistory` | function | asynchronously project canonical records and resolved multimodal files into provider-valid peer-free `AgentModelMessage[]` |
28757
+ | `defineModelRegistry` | function | typed language-model descriptors, capabilities and `AgentModelDriverFactory` construction |
28144
28758
  | `AgentModelCatalogSchema` / `AgentModelCatalog` | schema / _type_ | provider-neutral complete/partial model catalog with separately sourced popularity, metrics, prices and observation time |
28145
28759
  | `AgentModelCatalogEntrySchema` / `AgentModelCatalogEntry` | schema / _type_ | one canonical provider model descriptor with optional price, popularity and metric evidence |
28146
28760
  | `AgentModelPriceSchema` / `AgentModelPrice` | schema / _type_ | normalized per-token input/output pricing and source currency |
@@ -28166,7 +28780,7 @@ Server-only optional application runtime. See the
28166
28780
  | `selectCompactableHistory` | function | which oldest whole complete turns may be summarised away — the half of compaction that needs no store (→ ADR 0142) |
28167
28781
  | `SelectCompactableHistoryOptions` / `CompactableHistory` | _type_ | message list, retained-turn count and evidence policy in; `leadingSummary`, `compactable` and `retained` out |
28168
28782
  | `createAgentSessionCoordinator` | function | strict process-local queue/interrupt/supersede lifecycle |
28169
- | `AgentRuntimeStopPolicy` | _type_ | named stop rule persisted and published on policy stop; `when` receives the AI SDK `steps` plus the run context `prepareStep` gets (`context`, `run`, `signal`, `toolFenceLifecycle`, `contextUsage`) |
28783
+ | `AgentRuntimeStopPolicy` | _type_ | named stop rule `AgentRuntimeStopPolicy<CONTEXT = unknown>` persisted and published on policy stop; `when` receives `AgentStepResult[]` plus the run context `prepareStep` gets (`context`, `run`, `signal`, `toolFenceLifecycle`, `contextUsage`) |
28170
28784
  | `AgentRuntimePrepareStep` | _type_ | per-run controlled step callback with typed domain context and managed run signal/fence |
28171
28785
  | `AgentContextOverflowError` | class | deliberate application budget refusal thrown from `loop.prepareStep`; terminalizes as `context_overflow` without classifying arbitrary error text |
28172
28786
  | `AgentRuntimeRecordIds` | _type_ | optional caller-provided input, run and assistant IDs for stable application records |
@@ -28180,7 +28794,7 @@ Server-only optional application runtime. See the
28180
28794
  | `AgentSessionCloseOptions` | _type_ | `gracePeriodMs` for natural settlement, then abort, then `forceTimeoutMs` for bounded settlement after it |
28181
28795
  | `AgentSessionCloseResult` | _type_ | what `close()` achieved: `settled`, or `timedOut` with `remaining` runs still in flight. Only omitting `forceTimeoutMs` guarantees nothing is in flight on return |
28182
28796
  | `AgentHistoryProjectionOptions` | _type_ | storage-neutral file resolver, explicit unresolved-file behavior, and how an interrupted turn reaches the model (`interruptedAssistant`) |
28183
- | `createAgentToolFenceLifecycle` | function | pre-effect and post-effect run ownership fence for `mountAgent`; compose beside application idempotency for [durable operations](../guide/mcp-and-agents.md#durable-application-owned-execution) |
28797
+ | `createAgentToolFenceLifecycle` | function | pre-effect and post-effect run ownership fence for `mountAgentTools` / `mountAgent`; compose beside application idempotency for [durable operations](../guide/mcp-and-agents.md#durable-application-owned-execution) |
28184
28798
  | `AgentRuntimeEventSchema` | schema | transient stream lifecycle plus post-commit admission/checkpoint/run-state/run-operation/terminal projections |
28185
28799
  | `AgentRunOperationKindSchema` / `AgentRunOperationPhaseSchema` / `AgentRunOperationSchema` / `AgentRunOperation` | schemas / _type_ | latest durable model-request or compaction phase with operation/step identity and original timestamps; request admission is awaited before provider invocation |
28186
28800
  | `RecordRunOperationSchema` / `RecordRunOperation` | schema / _type_ | owner/fencing/revision-checked mutation of `AgentRun.lastOperation` |
@@ -28215,7 +28829,38 @@ Server-only optional application runtime. See the
28215
28829
  | `AgentChildHandle` / `AgentChildManager` / `AgentChildManagerConfig` / `AgentChildRemainingBudget` / `createAgentChildManager` / `createAgentChildTools` / `AgentChildToolsConfig` / `AGENT_CHILD_TOOL_DESCRIPTORS` / `agentChildBudgetStopPolicy` | _types_ / functions / constant | host execution port, child lifecycle with required `remainingBudget` and `maxActiveChildren`, cascade (given to `createAgentRuntime` as `children`), messaging, Agent tools bound to the parent conversation of the run context `tools()` receives (plus their deeply frozen static catalog descriptors), and the child runtime's own budget stop policy — `recordStepUsage` at every step boundary, `policy_stop` as `child-budget` when spent |
28216
28830
  | `AgentCompanionHost` / `AgentCompanionScope` / `AgentSqlSession` / `AgentSqlTables` / `AgentSqlValue` | _types_ | the store's companion host — one store transaction with the purge check and the event append (`transaction(conversationId, work)`), a read transaction (`read(work)`), the companion tables — given by the SQLite and Postgres stores and taken by every companion |
28217
28831
  | `AgentToolDefinition` / `AgentToolDescriptor` | _types_ | peer-neutral executable shape returned by the bound agent-only tool factories and its non-executable static catalog descriptor shape (assignable to `SurfaceRuntimeToolDefinition` without an active run) |
28218
- | `AgentProviderStreamCutError` | class | explicit retryable provider stream truncation evidence |
28832
+ | `AgentProviderStreamCutError` / `AgentProviderStreamCutErrorOptions` | class / _type_ | explicit retryable provider stream truncation evidence and constructor options |
28833
+
28834
+ ### Native model port, driver composition and peer-free completions
28835
+
28836
+ `stitchkit/agent-runtime` executes models through `AgentModelDriver` — one provider call per step,
28837
+ no SDK retries and no tool execution inside the driver. `completeText` and `completeObject` reuse
28838
+ the same native step execution without requiring a store. → ADR 0336.
28839
+
28840
+ | Export | Kind | Summary |
28841
+ |--------|------|---------|
28842
+ | `AgentModelDriver` / `AgentModelDriverFactory` | _type_ | single-step model port (`stream(request, signal)`) and provider factory registered in `defineModelRegistry` |
28843
+ | `AgentModelRequest` / `AgentModelStream` / `AgentModelStreamPart` | _type_ | normalized single-step request (`instructions`, `messages`, `tools`, `toolChoice`, `responseFormat`, `cacheControl`, `settings`, `providerOptions`, `headers`, `correlation`) and ordered stream event union (including keepalive `ping`, multi-block reasoning/text/tool events with unified `toolCallId`, `file` with optional `filename`, and terminal `finish`) |
28844
+ | `AgentModelToolSpec` / `AgentModelFunctionToolSpec` / `AgentModelProviderToolSpec` / `AgentModelJsonValue` / `AgentModelToolChoice` / `AgentModelCallSettings` / `AgentModelCorrelation` | _type_ | union of client function tool specs (JSON Schema 2020-12) and provider-native tool specs (`type: 'provider'` with `AgentModelJsonValue` config), tool-choice directive, call sampling settings and non-secret request correlation (`conversationId`, `runId`, `invocationId`, `attemptId`, `step`) |
28845
+ | `AgentModelFinishReason` / `AgentModelResponseMetadata` / `AgentModelCostDetails` / `AgentStepTimings` / `AgentStepChunkIntervals` | _type_ | normalized step finish reason, response metadata (including server `modelId` and `timestamp`), optional provider-reported cost/BYOK breakdown (`promptCostUsd`, `outputCostUsd`, `isByok`), and measured step/response/tool/TTFT timings with optional inter-chunk interval percentiles (`min`, `p10`, `median`, `avg`, `p90`, `max`) |
28846
+ | `wrapModelDriver` / `composeModelDrivers` | function | wrap one `AgentModelDriver` with one or an ordered outer-to-inner list of lifecycle decorators whose `onClose` runs once on finish, error, early stream cancellation, or abort |
28847
+ | `AgentModelDriverDecorator` / `AgentModelDriverStreamOutcome` | _type_ | generic per-stream interceptor (`beforeStream`, `transformRequest`, `transformSignal`, `onPart`, `onClose`) and terminal stream outcome (`finished`, `errored`, `cancelled`) |
28848
+ | `completeText` / `streamComplete` / `CompleteTextInput` / `CompleteTextOptions` / `CompletePromptInput` / `CompleteTextResult` / `CompleteTextStream` / `CompleteStreamPart` / `CompletePrepareStep` / `AgentCompleteStopPolicy` | functions / _types_ | peer-free single- or multi-step completion and standalone async-iterable streaming over any `AgentModelDriver` (no store required), with compile-time XOR on `prompt` vs `messages`, `retry`, `stopPolicies`, `idleTimeoutMs`, `onPart`, `headers`, tools, `prepareStep`, `repairToolCall`, timings and usage |
28849
+ | `completeObject` / `CompleteObjectInput` / `CompleteObjectResult` | function / _types_ | peer-free structured-output completion emitting strict JSON Schema (`draft-2020-12` via `toJsonSchema(..., 'input')`), stripping strict-mode optional `null`s prior to Zod validation, and supporting multi-step tool loops |
28850
+ | `AgentStructuredOutputError` / `AgentStructuredOutputErrorReason` / `AgentStructuredOutputErrorDetails` | class / _types_ | typed error thrown by `completeObject` with `reason` (`'truncated' \| 'tool-calls' \| 'content-filter' \| 'provider-error' \| 'interrupted' \| 'empty' \| 'invalid-json' \| 'schema-mismatch'`), `finishReason`, `rawText`, `steps`, and `usage` |
28851
+ | `AgentRetryExhaustedError` / `AgentRetryExhaustedErrorDetails` / `AgentRetryAttemptRecord` | class / _types_ | typed error thrown when stateless completion retries exhaust `retry.maxAttempts` or `maxRetryDurationMs`, carrying every failed attempt, `lastError`, and accumulated billable `usage` |
28852
+ | `AgentProviderError` / `AgentProviderErrorDetails` / `isAgentProviderError` | class / _type_ / function | canonical provider HTTP/envelope error carrying `provider`, `statusCode`, `code`, `errorType`, `requestId`, `retryAfterMs`, `failureReason`, redacted safe message, and runtime type guard |
28853
+ | `AgentUnknownToolError` / `AgentInvalidToolInputError` | class | PII-safe tool-dispatch errors for unknown/inactive tools and invalid JSON or Zod tool inputs |
28854
+ | `AgentToolApprovalError` / `AgentToolApprovalErrorReason` / `AgentInvalidToolApprovalSignatureError` / `AgentToolCallNotFoundForApprovalError` | class / _type_ | typed failures and machine reason codes (`'invalid-signature' \| 'call-not-found' \| 'input-validation-failed' \| 'input-mutated' \| 'invalid-policy-decision' \| 'approval-unsupported'`) for invalid approval payloads, WebCrypto HMAC-SHA256 signature verification failure, unresolved approval call IDs, or standalone fail-closed `needsApproval` refusal |
28855
+ | `AgentToolApprovalConfiguration` / `AgentToolApprovalDecision` / `AgentToolApprovalCallOptions` / `AgentToolApprovalToolRule` | _type_ | per-call or per-tool approval policy evaluated by the native step loop |
28856
+ | `AgentStepToolCallBatchHook` / `AgentStepToolCallBatchInput` / `AgentStepToolCallBatchDecision` | _type_ | `loop.beforeStepToolCalls` whole-step batch policy invoked once all tool calls of a step are parsed and validated, able to refuse selected calls by `toolCallId` |
28857
+ | `AgentToolCallRepairFunction` / `AgentToolCallRepairInput` | _type_ | first-class `repairToolCall` hook that rewrites an unknown, inactive, or invalid tool call before execution |
28858
+ | `AgentPrepareStepInput` / `AgentPrepareStepResult` | _type_ | step-preparation input and per-step overrides (`driver`, `instructions`, `messages`, `activeTools`, `toolChoice`, `responseFormat`, `cacheControl`, sampling settings, `providerOptions`, `headers`) |
28859
+ | `AgentStepResult` / `AgentStepContentPart` / `AgentStepToolCall` / `AgentStepToolResult` | _type_ | peer-free completed step record delivered to `prepareStep`, `stopPolicies`, and `onStepFinish` |
28860
+ | `AgentModelMessageSchema` / `AgentModelMessage` / `AgentModelSystemMessageSchema` / `AgentModelSystemMessage` / `AgentModelUserMessageSchema` / `AgentModelUserMessage` / `AgentModelAssistantMessageSchema` / `AgentModelAssistantMessage` / `AgentModelToolMessageSchema` / `AgentModelToolMessage` / `AgentInstructions` | schemas / _types_ | canonical peer-free model-exchange message schemas and normalized instruction input |
28861
+ | `AgentModelUserContentPartSchema` / `AgentModelUserContentPart` / `AgentModelAssistantContentPartSchema` / `AgentModelAssistantContentPart` / `AgentModelToolContentPartSchema` / `AgentModelToolContentPart` / `AgentToolModelContentPart` / `AgentToolModelOutputSchema` | schemas / _types_ | non-deprecated content part schemas (`text`, `reasoning`, `file`, `reasoning-file`, `tool-call`, `tool-result`, approvals, `custom`) and structured tool-output schema |
28862
+ | `AgentModelFileDataSchema` / `AgentModelFileData` / `AgentGeneratedFile` / `AgentGeneratedFileData` | schema / _types_ | tagged file payload (`data`, `url`, `reference`, `text`) and generated model file (`mediaType`, `data`, optional `filename`, `url?`, lazy `base64`/`uint8Array`, `providerMetadata?`) handed to `persistGeneratedFile` |
28863
+ | `AgentModelResponseFormatSchema` / `AgentModelResponseFormat` / `AgentCacheControlSchema` / `AgentCacheControl` / `AgentModelProviderOptionsSchema` / `AgentModelProviderOptions` / `AgentModelProviderOptionValue` | schemas / _types_ | portable structured-output format (`text`, `json-object`, `json-schema`), prompt-cache breakpoint directive (`ephemeral`, optional `'5m' \| '1h'` TTL), and namespaced provider options with recursive `AgentModelProviderOptionValue` supporting optional `undefined` keys under `exactOptionalPropertyTypes` |
28219
28864
 
28220
28865
  ### Complete runtime inventory
28221
28866
 
@@ -28225,26 +28870,24 @@ transport adapters validate the same records. Runtime composition types are `Age
28225
28870
  `AgentRuntimeResult`, `AgentRuntimeInterruptInput`, `AgentRuntimeAbandonInput`, `AgentRuntimeRecoveryInput`,
28226
28871
  `AgentRuntimeRecoveryDecision`, `AgentRuntimeRecoveryOutcome`, `AgentRuntimePublisher`,
28227
28872
  `AgentInputPolicy`, `AgentStopReason`, `AgentCoordinatedRun`, `AgentRunTicket`,
28228
- `AgentSessionCoordinator`, `AgentCompactionContext`, `AgentCompactionResult` and
28229
- `StructuredCompactionConfig`.
28873
+ `AgentSessionCoordinator`, `AgentCompactionContext`, `AgentCompactionResult`,
28874
+ `AgentCompactionSummaryOutput` and `StructuredCompactionConfig`.
28230
28875
 
28231
28876
  A provider refusal is classified rather than phrased. `classifyProviderFailure` returns an
28232
28877
  `AgentProviderFailure` — an `AgentProviderFailureReason` (`insufficient-credits`, `rate-limited`,
28233
- `model-unavailable`, `context-overflow`, `timeout`, `cancelled`, `unknown`), the provider's `status`
28234
- when it supplied one, whether the same request is `retryable` unchanged, and the `evidence` the
28235
- answer rests on: `status` is the provider stating its own answer, `message` is us reading its prose,
28236
- and `none` is an honest refusal to guess. The sentence a user reads stays with the application —
28878
+ `overloaded`, `server-error`, `model-unavailable`, `context-overflow`, `timeout`, `cancelled`,
28879
+ `stream-cut`, `unknown`), the provider's `status` when it supplied one, optional `retryAfterMs`,
28880
+ whether the same request is `retryable` unchanged, and the `evidence` the answer rests on: `code`
28881
+ is a machine error code from the provider, `status` is the provider stating its own HTTP answer,
28882
+ `message` is us reading its prose, and `none` is an honest refusal to guess. The sentence a user reads stays with the application —
28237
28883
  its tone and its decision about what to admit are not the core's to make. `isToolResultFailure`
28238
28884
  recognises a failure carried inside a *successful* tool result, in both the bare and the
28239
28885
  `{ value: … }` envelope. Both are plain functions and need no runtime. → ADR 0141
28240
28886
 
28241
- `normalizeOpenRouterUsage` is the same normalisation `openRouterProvider`
28242
- applies, exported so an application calling the SDK directly gets provenance-correct numbers
28243
- without adopting the runtime. Pass each completed SDK step's usage, including `raw`.
28244
- Token provenance comes from the original OpenRouter fields: missing fields remain
28245
- `unavailable`, even when the SDK substitutes zero. Aggregate usage without `raw` cannot
28246
- establish reported token counts. Explicit zero remains `provider-reported`; cost is never
28247
- estimated from token prices.
28887
+ `normalizeOpenRouterUsage` (exported from `stitchkit/agent-runtime/openrouter`, alongside
28888
+ `normalizeOpenAiUsage` on `/openai` and `normalizeAnthropicUsage` on `/anthropic`) is the same
28889
+ provenance-aware normalisation `openRouterProvider` applies. Missing fields remain `unavailable`,
28890
+ explicit zero remains `provider-reported`, and cost is never estimated from token prices.
28248
28891
 
28249
28892
  `AgentContextUsage` reaches every step through `AgentRuntimeRunContext.contextUsage`: how full the
28250
28893
  model's context is, as `usedTokens` (an `AgentUsageValue`, so it carries the provenance that says
@@ -28259,7 +28902,7 @@ Canonical protocol exports are `AgentProtocol`, `AgentProtocolConfig`, `AgentTer
28259
28902
  `AgentTerminalAcceptanceInput`, `hasAgentTerminalOutput`, `AgentRecordIdSchema`, `AgentRecordVersionSchema`,
28260
28903
  `AgentTimestampSchema`, `AgentJsonObjectSchema`, `AgentProviderEnvelopeSchema`,
28261
28904
  `AgentProviderEnvelope`, `AgentMessagePartSchema`, `AgentMessagePart`, `AgentTextPartSchema`,
28262
- `AgentReasoningPartSchema`, `AgentFilePartSchema`, `AgentSourcePartSchema`,
28905
+ `AgentReasoningPartSchema`, `AgentFilePartSchema`, `AgentSourcePartSchema`, `AgentSourcePart`,
28263
28906
  `AgentToolCallPartSchema`, `AgentToolResultPartSchema`, `AgentOpaquePartSchema`,
28264
28907
  `AgentControlPartSchema`, `AgentMessageRoleSchema`, `AgentMessageStatusSchema`, `AgentMessage`,
28265
28908
  `AgentAssistantPlaceholderSchema`, `AgentAssistantPlaceholder`, `AgentRunStateSchema`,
@@ -28349,7 +28992,7 @@ Compaction never deletes canonical effect events or the retained terminal receip
28349
28992
  chronological completeness does not settle an external effect. See the
28350
28993
  [failed-prefix recovery contract](../guide/agent-runtime.md#recovering-a-prefix-after-a-failed-turn).
28351
28994
 
28352
- Model exports are `AgentLanguageModelProvider`, `AgentModelCapability`,
28995
+ Model exports are `AgentModelDriverFactory`, `AgentModelCapability`,
28353
28996
  `AgentModelCapabilitySchema`, `AgentModelDescriptor`,
28354
28997
  `AgentModelDescriptorSchema`, `AgentModelRegistry`, `AgentModelRegistryConfig`,
28355
28998
  `AgentModelRegistrySnapshot`, `AgentModelRegistrySnapshotSchema`, `AgentModelSnapshotPolicy`,
@@ -28410,7 +29053,7 @@ preserved) and reporting `InvocationPayloadTooLargeError` through `complete().re
28410
29053
  | `ModelInvocationAttemptContext` | type | conversation, operation, invocation, attempt, step and optional agent run identity |
28411
29054
  | `currentModelInvocationAttempt` | function | returns causal IDs inside the provider transport; undefined outside an invocation |
28412
29055
  | `modelInvocationSpendAttribution` | function | the current attempt as `stitchkit/spend` attribution fields (conversation, run, invocation, attempt, step) — a spend gateway's `context` |
28413
- | `AgentStepBarriers` / `AgentToolCallDependencies` | _type_ | `loop.stepBarriers`, guards on each model step, checked by `createAgentRuntime`: `maxToolCallsPerStep` (a call past it is refused to the model as a `STEP_TOOL_CALL_LIMIT` tool error, without asking for its approval), `toolDependencies` (in the order the model made the calls, a read of an entity waits for the step's earlier writes of it and a write for its earlier reads and writes), `maxReasoningCharsPerStep` (past it the run stops as `policy_stop`), `stepText: 'after-tools'` (a step's text is held to its end and shown only if none of its tool calls failed; held text of an interrupted step is not shown); a streaming tool still streams, a deferred tool catalog survives the wrapping |
29056
+ | `AgentStepBarriers` / `AgentToolCallDependencies` | _type_ | `loop.stepBarriers`, guards on each model step, checked by `createAgentRuntime`: `maxToolCallsPerStep` (a call past it is refused to the model as a `STEP_TOOL_CALL_LIMIT` tool error, without asking for its approval), `toolDependencies` (in the order the model made the calls, a read of an entity waits for the step's earlier writes of it and a write for its earlier reads and writes), `onPredecessorFailure` (`'run'` default, or `'refuse'` to fail-cascade dependent calls on the same entity with `STEP_PREDECESSOR_FAILED`), `maxReasoningCharsPerStep` (past it the run stops as `policy_stop`), `stepText: 'after-tools'` (a step's text is held to its end and shown only if none of its tool calls failed; held text of an interrupted step is not shown) |
28414
29057
  | `AgentStepBarrierError` | class | the run stopped at a step bound: `bound` is `reasoning` |
28415
29058
  | `createToolDependencyResolver` | function | `toolDependencies` from operation effects — the `effect` of each endpoint of `contracts`, under its mounted tool name, and `effects` (by tool name) for tools of no contract — and the application's `entityOf(toolName, input)`: a `write` tool writes its entity, a `read` tool reads it |
28416
29059
 
@@ -28424,14 +29067,16 @@ both one lookup instead of a scan of the conversation log.
28424
29067
 
28425
29068
  ## `stitchkit/agent-runtime/testing`
28426
29069
 
28427
- Credential-free provider and concurrency fixtures for Bun and Node tests.
29070
+ Peer-free, credential-free model drivers, provider fault servers, and concurrency fixtures for Bun and Node tests.
28428
29071
 
28429
29072
  | Export | Kind | Summary |
28430
29073
  |--------|------|---------|
29074
+ | `createScriptedModelDriver` | function | deterministic peer-free `AgentModelDriver` for tests: replays scripted stream parts, records every `AgentModelRequest`, and supports per-step throws or async stream factories |
29075
+ | `ScriptedModelDriver` / `ScriptedModelDriverOptions` / `ScriptedModelStep` | _types_ | scripted driver handle (exposing `requests`), driver options (`provider`, `modelId`, `steps`, `onRequest`), and one scripted turn (`AgentModelStreamPart[]`, `{ throw }`, or stream function) |
28431
29076
  | `createFaultProviderServer` | function | start an OpenAI-compatible local SSE endpoint with deterministic pass, connection-refused, timeout, stream-cut, HTTP, malformed JSON, slow-stream and missing-usage steps |
28432
29077
  | `AgentFaultStepSchema` / `AgentFaultStep` | schema / _type_ | strict fault-plan step vocabulary |
28433
29078
  | `defineAgentFaultPlan` | function | validate a non-empty deterministic fault sequence |
28434
- | `createReplayAgentProvider` | function | serve a declared sequence of credential-free language-model fixtures per model ID |
29079
+ | `createReplayAgentProvider` | function | serve a declared sequence of credential-free `AgentModelDriver` fixtures per model ID |
28435
29080
  | `createAgentRaceBarrier` / `AgentRaceBarrier` | function / _type_ | named bounded deterministic concurrency barrier |
28436
29081
  | `createAgentRaceTrace` / `AgentRaceTrace` / `AgentRaceTraceEntry` | function / _type_ | record and assert exact event order without wall-clock guesses |
28437
29082
  | `createAgentRaceDriver` / `AgentRaceDriver` | function / _type_ | collect named barriers and release their teardown together |
@@ -28447,8 +29092,8 @@ that exact run. Completion requires terminal reason `success`, not `policy_stop`
28447
29092
 
28448
29093
  ## `stitchkit/agent-runtime/harness`
28449
29094
 
28450
- Server-only evolving facade over the canonical Agent runtime. It requires the optional `ai` peer
28451
- and introduces no store, queue or model-provider implementation of its own.
29095
+ Server-only, peer-free evolving facade over the canonical Agent runtime. It introduces no store,
29096
+ queue or model-provider implementation of its own.
28452
29097
 
28453
29098
  | Export | Kind | Summary |
28454
29099
  |--------|------|---------|
@@ -28524,7 +29169,7 @@ not path filtering, to constrain its filesystem access. → ADR 0172.
28524
29169
 
28525
29170
  ## `stitchkit/agent-runtime/browser`
28526
29171
 
28527
- Browser-safe canonical agent data. It re-exports the run, message, part, usage,
29172
+ Browser-safe canonical agent data. It re-exports the run, message, part (including `AgentSourcePart`), usage,
28528
29173
  terminal and provider-envelope schemas/types listed under
28529
29174
  `stitchkit/agent-runtime`, together with all runtime delivery event schemas (durable and transient,
28530
29175
  including `AgentAttemptResetEventSchema` for `attempt-reset`),
@@ -28539,9 +29184,20 @@ run's streamed text, reasoning and running tool calls before its next checkpoint
28539
29184
  `AgentToolActivity` (one running call with its last reported progress),
28540
29185
  `AGENT_TOOL_PROGRESS_MESSAGE_MAX` (the longest progress message a run publishes),
28541
29186
  `advanceAgentMultiSessionCursor`, `createAgentControlView`, `reduceAgentControlSnapshot`,
28542
- `reduceAgentControlEvent` and
28543
- `agentDurableEventId`. It imports no model provider, executor, store, event sink
28544
- or Node context module.
29187
+ `reduceAgentControlEvent`, `reduceAgentControlDelivery`, `deriveAgentConversationActivity`,
29188
+ `deriveAgentConversationState` and
29189
+ `agentDurableEventId`. For interactive and remote-host runtimes, it also exports strict Zod schemas
29190
+ and types for pending approvals (`AgentPendingApprovalSchema` / `AgentPendingApproval`),
29191
+ structured input prompts (`AgentPendingInputSchema` / `AgentPendingInput`,
29192
+ `AgentInputQuestionSchema` / `AgentInputQuestion`, `AgentInputOptionSchema` / `AgentInputOption`,
29193
+ `AgentInputAnswerSchema` / `AgentInputAnswer`), permission modes (`AgentPermissionModeSchema` /
29194
+ `AgentPermissionMode`), host reachability (`AgentHostStatusSchema` / `AgentHostStatus`,
29195
+ `AgentHostAvailabilitySchema` / `AgentHostAvailability`), write delivery reconciliation
29196
+ (`AgentWriteOperationSchema` / `AgentWriteOperation`, `AgentControlDeliveryOutcomeSchema` /
29197
+ `AgentControlDeliveryOutcome`, `AgentPendingDeliverySchema` / `AgentPendingDelivery`), and derived
29198
+ conversation phases (`AgentConversationActivitySchema` / `AgentConversationActivity`,
29199
+ `AgentConversationStateSchema` / `AgentConversationState`). It imports no model provider, executor,
29200
+ store, event sink or Node context module.
28545
29201
 
28546
29202
  Use this entrypoint from client components and shared DTO packages. The full
28547
29203
  `stitchkit/agent-runtime` entrypoint remains server-only.
@@ -28561,10 +29217,13 @@ realtime `transport`, `conversationId`, `access` (`observe` or `control`), optio
28561
29217
  `maxPendingRequests` (32). All bounds are positive safe integers. One controller owns one
28562
29218
  attachment per conversation on that transport; share the controller between views.
28563
29219
 
28564
- `AgentController` exposes stable `subscribe`, `getSnapshot`, `request(command)` and async
28565
- `close`. `AgentBrowserCommand` uses the canonical operations, without request/conversation identity;
28566
- `submit` requires a caller-owned idempotency key. Unknown-outcome mutations are never
28567
- replayed automatically. `AgentControllerState` distinguishes connecting, ready,
29220
+ `AgentController` exposes stable `subscribe`, `getSnapshot`, `request(command)`, typed interactive
29221
+ actions `respondApproval` (`AgentApprovalResponseInput`), `respondInput`
29222
+ (`AgentInputResponseInput`) and `setPermissionMode`, and async `close`. `AgentBrowserCommand` uses
29223
+ the canonical operations, without request/conversation identity; `submit` requires a caller-owned
29224
+ idempotency key, and `respond-approval` / `respond-input` accept an optional `idempotencyKey`.
29225
+ Unknown-outcome mutations (`outcome: 'unknown', delivery: 'unknown'` or a mid-flight disconnect)
29226
+ record `pendingDelivery` on `AgentConversationView` and are never replayed automatically. `AgentControllerState` distinguishes connecting, ready,
28568
29227
  disconnected, error and closed and retains the canonical full `view` plus safe error
28569
29228
  code/message. Errors in automatic attach/refresh appear there, and so does an
28570
29229
  `access-denied` delivery: the server detached the conversation, the state becomes
@@ -28578,18 +29237,79 @@ See [agent composition](../guide/agent-composition.md) for a complete wiring exa
28578
29237
 
28579
29238
  ## `stitchkit/agent-runtime/openrouter`
28580
29239
 
29240
+ Server-only, peer-free native OpenRouter provider over Web `fetch` and Chat Completions SSE
29241
+ (no `@openrouter/ai-sdk-provider` or `ai` peer). Supports `reasoning_details` and Gemini
29242
+ `thought_signature` round-trip, prompt-cache budgeting (≤ 4 breakpoints), BYOK `costDetails`
29243
+ (`cost + upstream_inference_cost`), `native_finish_reason` abnormal-stop guards, and
29244
+ `AgentProviderError` classification. → ADR 0336.
29245
+
28581
29246
  | Export | Kind | Summary |
28582
29247
  |--------|------|---------|
28583
- | `openRouterProvider` / `OpenRouterProviderAccess` | function / _type_ | isolated `@openrouter/ai-sdk-provider` language-model factory; the optional second argument shapes every request and is the one place a request policy is applied — `defaultPolicy`, `resolvePolicy(modelId)` from the application's own model table, and `sessionPerConversation` (`session_id` = the agent runtime attempt's conversation, keeping a thread on one upstream); a provider-level `extraBody` that would overwrite `provider`, `reasoning`, `session_id` or `usage` is refused |
28584
- | `OpenRouterRequestPolicySchema` / `OpenRouterRequestPolicy` / `OpenRouterProviderRoutingSchema` / `OpenRouterProviderRouting` / `OpenRouterMaxPriceSchema` / `OpenRouterMaxPrice` / `OpenRouterReasoningEffortSchema` / `OpenRouterReasoningEffort` | schemas / _types_ | one request's policy: `sessionId` or `provider.order` (never both; an empty order is refused), routing (`allowFallbacks`, `requireParameters`, `dataCollection`, `zdr`, `only`, `ignore`, `sort`, `quantizations`), `maxPrice` in USD per million tokens or per request/image, `reasoning.effort` up to `max`, `looseTools` (every function tool and the response schema sent with `strict: false`; the SDK does not serialize a tool's `strict`, so `openRouterProvider` sets it on the wire); usage accounting is always on, and `effort: 'max'` and `session_id` travel in the raw body, where the SDK leaves them alone |
29248
+ | `openRouterProvider` / `OpenRouterProviderAccess` | function / _type_ | native peer-free `AgentModelDriverFactory` over OpenRouter Chat Completions SSE; the optional second argument shapes every request — `defaultPolicy`, `resolvePolicy(modelId)` from the application's own model table, and `sessionPerConversation` (`session_id` derived directly from `request.correlation.conversationId`, hashed when over 256 chars, without requiring `invocations`, yielding to explicit `provider.order`); a provider-level `extraBody` that would overwrite owned wire keys is refused |
29249
+ | `OpenRouterProviderSettings` | _type_ | `{ apiKey, baseUrl?, headers?, appName?, appUrl?, providerApiKeys?, fetch?, extraBody? }` — camelCase settings sending `HTTP-Referer`, `X-OpenRouter-Title`, and `X-Provider-API-Keys` with `redirect: 'error'` |
29250
+ | `OpenRouterRequestPolicySchema` / `OpenRouterRequestPolicy` / `OpenRouterProviderRoutingSchema` / `OpenRouterProviderRouting` / `OpenRouterMaxPriceSchema` / `OpenRouterMaxPrice` / `OpenRouterReasoningEffortSchema` / `OpenRouterReasoningEffort` | schemas / _types_ | one request's policy: `sessionId` or `provider.order` (never both; an empty order is refused), routing (`allowFallbacks`, `requireParameters`, `dataCollection`, `zdr`, `only`, `ignore`, `sort`, `quantizations`), `maxPrice` in USD per million tokens or per request/image, `reasoning.effort` up to `max`, `looseTools` (`strict: false` while preserving explicit per-tool `strict: true`), and optional portable `cacheControl` (`AgentCacheControl`) |
29251
+ | `normalizeOpenRouterUsage` | function | provenance-aware normalization of raw OpenRouter `usage` payloads (including BYOK `cost_details.upstream_inference_cost` with `computed` cost provenance; missing counters stay `unavailable`) |
28585
29252
  | `createOpenRouterRouteResolver` / `OpenRouterRouteResolver` / `createMemoryOpenRouterRouteStore` / `OpenRouterRouteStore` / `OpenRouterRoutePinSchema` / `OpenRouterRoutePin` | functions / _types_ / schema | keep a thread on one upstream outside the agent runtime: `session-sticky` (its `session_id`; a key over 256 characters is hashed) or `provider-order` (the upstream slug that answered first, from `record`, with `allowFallbacks: false` unless the base policy says otherwise); a pin replaces the base policy's route; the memory store is least-recently-used, bounded by `maxEntries` and `ttlMs` |
28586
- | `loadOpenRouterCatalogSnapshot` / `fetchOpenRouterModelEndpoints` / `OpenRouterSnapshotOptions` / `OpenRouterCatalogSnapshotSchema` / `OpenRouterCatalogSnapshot` / `OpenRouterSnapshotModelSchema` / `OpenRouterSnapshotModel` / `OpenRouterEndpointSchema` / `OpenRouterEndpoint` | functions / _types_ / schemas | a timestamped snapshot of `/models` (name, input modalities, prices per million — only plain non-negative decimals: OpenRouter's `-1`, an empty string or `0x…` stay absent, never zero) and, for named models, their upstreams; ids are checked as `author/slug` before the network, endpoint requests run 1–16 at once and stop at the first failure, bodies are bounded, redirects refused |
28587
- | `evaluateOpenRouterModelAdmission` / `OpenRouterAdmissionPolicySchema` / `OpenRouterAdmissionPolicy` / `OpenRouterModelAdmissionSchema` / `OpenRouterModelAdmission` / `OpenRouterAdmissionReasonSchema` / `OpenRouterAdmissionReason` | function / schemas / _types_ | decide one model from a stored snapshot: `admitted`, `unverified` (stale or future-dated snapshot, unknown price, no endpoint list) or `rejected` with a reason (`requiredParameters`, `requiredInputModalities`, context, price, live endpoint); `~`, `-latest`, `:batch`, `stealth/`, `openrouter/auto` and an `aliasOf` model are always refused; the result is a schema, so a stored decision reads back |
29253
+ | `loadOpenRouterCatalogSnapshot` / `fetchOpenRouterModelEndpoints` / `OpenRouterSnapshotOptions` / `OpenRouterCatalogSnapshotSchema` / `OpenRouterCatalogSnapshot` / `OpenRouterSnapshotModelSchema` / `OpenRouterSnapshotModel` / `OpenRouterEndpointSchema` / `OpenRouterEndpoint` / `OpenRouterPricingTierSchema` / `OpenRouterPricingTier` / `OpenRouterModelAliasTargetSchema` / `OpenRouterModelAliasTarget` / `OpenRouterModelReasoningMetaSchema` / `OpenRouterModelReasoningMeta` | functions / _types_ / schemas | a timestamped snapshot of `/models` (supporting unauthenticated public reads or static/async `apiKey`, full model metadata including `canonicalSlug`, `description`, `createdAt`, `aliasTarget`, `inputModalities`, `outputModalities`, `tokenizer`, `topProviderContextLength`, `maxCompletionTokens`, `reasoning`, per-million/request/image/cache prices including `cacheWrite1hUsdPerMillion` and conditional `pricingTiers` — distinguishing omitted keys from explicit `null`/`-1` unknowns, never treating unknown as zero — rejecting paginated truncation and duplicate ids) and per-model endpoints (including `cacheWrite1hUsdPerMillion`, `latencyP50Ms`, `throughputP50`, `uptime1d`, `tag`); ids are checked as `author/slug` (or `~author/slug`) before the network, endpoint requests run 1–16 at once and stop at the first failure, bodies are bounded, redirects refused |
29254
+ | `resolveOpenRouterModelCeiling` / `OpenRouterModelPricingCeilingSchema` / `OpenRouterModelPricingCeiling` / `summarizeOpenRouterEndpoints` / `OpenRouterEndpointSummarySchema` / `OpenRouterEndpointSummary` | functions / schemas / _types_ | compute the worst-case pricing ceiling across base rates, 5m/1h cache-write rates (`cacheWriteUsdPerMillion`, `cacheWrite1hUsdPerMillion`), conditional `pricingTiers`, and UTC-window overrides (refusing to understate unknown/unrepresentable conditional pricing) and aggregate distinct upstream provider count, median latency/throughput, and 1-day uptime across a model's endpoints |
29255
+ | `findOpenRouterModel` / `listOpenRouterModels` / `OpenRouterModelFilter` | functions / _type_ | query an `OpenRouterCatalogSnapshot` by exact `id` or `canonicalSlug`, or filter models by `tools`, `reasoning` (`reasoning`, `include_reasoning`, or declared efforts), `inputModalities`, `outputModalities`, `minContextLength` (via effective context `min(contextLength, topProviderContextLength)`), `maxPromptUsdPerMillion`, `maxCompletionUsdPerMillion`, `freeOnly`, and `author` |
29256
+ | `createOpenRouterCatalogCache` / `OpenRouterCatalogCache` / `OpenRouterCatalogCacheOptions` / `OpenRouterCatalogCacheReadResult` / `OpenRouterCatalogStore` | function / _types_ | Web Fetch-clean cached OpenRouter catalog reader with single-flight coalescing, per-caller `AbortSignal` isolation, `freshMs` TTL, `retryBackoffMs` stale fallback, optional pluggable persistence (`store`), and `read`/`refresh`/`getModel`/`listModels`; `OpenRouterCatalogCacheReadResult` is a discriminated union on `status` (`'current' \| 'stale' \| 'unavailable'`) narrowing `snapshot`, `observedAt`, `models`, and `lastError` without casts (use `read()` for admission/billing decisions; `getModel`/`listModels` map `'unavailable'` to `undefined`/`[]`) |
29257
+ | `evaluateOpenRouterModelAdmission` / `OpenRouterAdmissionPolicySchema` / `OpenRouterAdmissionPolicy` / `OpenRouterModelAdmissionSchema` / `OpenRouterModelAdmission` / `OpenRouterAdmissionReasonSchema` / `OpenRouterAdmissionReason` | function / schemas / _types_ | decide one model from a stored snapshot: `admitted`, `unverified` (stale or future-dated snapshot, `'context-unknown'`, `'price-unknown'`, `'endpoints-unknown'`) or `rejected` with a reason (`requiredParameters`, `requiredInputModalities`, effective context `min(contextLength, topProviderContextLength)`, worst-case pricing ceilings via `resolveOpenRouterModelCeiling`, live endpoint); `~`, `-latest`, `:batch`, `stealth/`, `openrouter/auto`, `aliasOf`, and `aliasTarget` models are always refused as `'floating-alias'`; the result is a schema, so a stored decision reads back |
28588
29258
  | `openRouterSpendProvider` / `createOpenRouterSpendReconciler` | functions | OpenRouter for `stitchkit/spend`: the gateway provider (origin, key read per call, usage format) and the reconciler that prices an attempt by its generation id (`GET /api/v1/generation`; a 404 is "not yet"; `apiKey` may be a function of the record, since OpenRouter prices a generation only for the key that made it) |
28589
29259
  | `OpenRouterHttpError` | class | a non-2xx answer from OpenRouter, with its `status` |
28590
- | `openRouterModelCatalog` | function | complete tool-capable text catalog plus independent weekly popularity and available benchmark observations; a `timeoutMs` that is not an integer from 1 to 2147483647 ms (the timer range) is refused when the catalog is created (`RangeError`) |
28591
- | `OpenRouterProviderSettings` | _type_ | official provider settings accepted by the factory |
28592
- | `OpenRouterModelCatalogOptions` / `OpenRouterCatalogFetch` | _type_ | credential, timeout, clock and injected fetch boundary for catalog loading |
29260
+ | `openRouterModelCatalog` | function | complete tool-capable text catalog plus independent weekly popularity and available benchmark observations (optional static or async `apiKey`); a `timeoutMs` that is not an integer from 1 to 2147483647 ms (the timer range) is refused when the catalog is created (`RangeError`) |
29261
+ | `OpenRouterModelCatalogOptions` / `OpenRouterCatalogFetch` | _type_ | optional static/dynamic credential, timeout, clock and injected fetch boundary for catalog loading |
29262
+
29263
+ ## `stitchkit/agent-runtime/openai`
29264
+
29265
+ Server-only, peer-free native OpenAI Responses API (`POST /v1/responses`) provider over Web
29266
+ `fetch` and SSE. Defaults to stateless (`store: false`) with automatic
29267
+ `include: ['reasoning.encrypted_content']` round-trip, `role: 'developer'` instructions,
29268
+ `strict: false` default tool schemas, `item_id` (`fc_*`) vs `call_id` separation, `text.format`
29269
+ structured outputs, `prompt_cache_key`, and fail-fast refusal of unsupported settings (I9).
29270
+ → ADR 0336.
29271
+
29272
+ | Export | Kind | Summary |
29273
+ |--------|------|---------|
29274
+ | `openAiProvider` | function | native peer-free `AgentModelDriverFactory` targeting OpenAI Responses (`POST /v1/responses`) |
29275
+ | `OpenAiProviderSettings` | _type_ | `{ apiKey, baseUrl?, organization?, project?, headers?, fetch?, extraBody? }` — refuses `extraBody` clashes with owned protocol keys and enforces `redirect: 'error'` |
29276
+ | `OpenAiProviderAccess` | _type_ | `{ defaultPolicy?, resolvePolicy?(modelId), cachePerConversation? }` — per-model policy resolution and automatic ≤ 64-char `prompt_cache_key` derivation from `correlation.conversationId` |
29277
+ | `OpenAiRequestPolicySchema` / `OpenAiRequestPolicy` | schema / _type_ | validated Responses API request policy (`store`, `reasoning`, `serviceTier`, `truncation`, `promptCacheKey`, `promptCacheRetention`, `parallelToolCalls`, `strictTools`, `include`, `user`) |
29278
+ | `OpenAiReasoningPolicySchema` / `OpenAiReasoningPolicy` | schema / _type_ | reasoning `effort` (`'none' \| 'minimal' \| 'low' \| 'medium' \| 'high' \| 'xhigh'`) and optional `summary` (`'auto' \| 'concise' \| 'detailed'`) |
29279
+ | `normalizeOpenAiUsage` | function | provenance-aware normalization of OpenAI Responses `usage` objects (`input_tokens`, `output_tokens`, `cached_tokens`, `reasoning_tokens`; corrupted sub-counters degrade to `unavailable`) |
29280
+
29281
+ ## `stitchkit/agent-runtime/anthropic`
29282
+
29283
+ Server-only, peer-free native Anthropic Messages API (`POST /v1/messages`) provider over Web
29284
+ `fetch` and SSE. Enforces mandatory `maxOutputTokens` and `maxOutputTokens > thinking.budgetTokens`
29285
+ fail-fast before any HTTP call, preserves verbatim multi-block `thinking` + `signature` and
29286
+ `redacted_thinking` blocks, splits images out of `is_error` tool results, budgets ≤ 4 cache
29287
+ breakpoints with TTL-order validation, computes total `inputTokens = input_tokens + cache_read +
29288
+ cache_creation` with `computed` provenance (ADR 0109), maps `output_config.format` JSON Schema
29289
+ (refusing schemaless `json-object`), and classifies `529 overloaded_error` as retryable.
29290
+ → ADR 0336.
29291
+
29292
+ | Export | Kind | Summary |
29293
+ |--------|------|---------|
29294
+ | `anthropicProvider` | function | native peer-free `AgentModelDriverFactory` targeting Anthropic Messages (`POST /v1/messages`) |
29295
+ | `AnthropicProviderSettings` | _type_ | `{ apiKey, baseUrl?, apiVersion?, betas?, headers?, fetch?, extraBody? }` — merges `anthropic-beta` flags deterministically, refuses `extraBody` clashes, and enforces `redirect: 'error'` |
29296
+ | `AnthropicProviderAccess` | _type_ | `{ defaultPolicy?, resolvePolicy?(modelId) }` — validates `defaultPolicy` up front and resolves per-model policy |
29297
+ | `AnthropicRequestPolicySchema` / `AnthropicRequestPolicy` | schema / _type_ | validated Messages API request policy (`maxOutputTokens`, `thinking`, `effort`, `cacheControl`, `eagerInputStreaming`, `disableParallelToolUse`, `serviceTier`, `betas`) |
29298
+ | `AnthropicThinkingPolicySchema` / `AnthropicThinkingPolicy` | schema / _type_ | thinking mode (`{ type: 'adaptive' }`, `{ type: 'enabled', budgetTokens }` with `budgetTokens >= 1024`, or `{ type: 'disabled' }`) |
29299
+ | `normalizeAnthropicUsage` | function | provenance-aware normalization of Anthropic `usage` objects, assembling total `inputTokens` with `computed` provenance when cache counters are positive |
29300
+
29301
+ ## `stitchkit/agent-runtime/ai-sdk`
29302
+
29303
+ Server-only evolving optional-peer adapter (`ai`). Adapts any AI SDK v4 `LanguageModel` or
29304
+ `ToolSet` onto `AgentModelDriver` and `AgentToolSet` without importing `streamText` or
29305
+ `generateText`, keeping `stitchkit/agent-runtime` and all three native providers free of AI SDK
29306
+ dependencies. → ADR 0336.
29307
+
29308
+ | Export | Kind | Summary |
29309
+ |--------|------|---------|
29310
+ | `fromAiSdkModel` | function | wrap an AI SDK v4 `LanguageModel` (`specificationVersion: 'v4'`) as a single-step `AgentModelDriver` driving `model.doStream()` directly |
29311
+ | `FromAiSdkModelOptions` | _type_ | optional `{ normalizeUsage?, resolveResponseProvider? }` hooks for mapping AI SDK step usage and gateway `providerMetadata` |
29312
+ | `fromAiSdkTools` | function | async adapter converting an AI SDK `ToolSet` into a peer-free `AgentToolSet`; refuses provider-defined tools (`type: 'provider'`) and normalizes legacy deprecated tool outputs into canonical `{ type: 'file', data, mediaType }` parts |
28593
29313
 
28594
29314
  ## `stitchkit/agent-executor`
28595
29315
 
@@ -28604,12 +29324,12 @@ leaves of their own; this entrypoint knows no vendor. Evolving.
28604
29324
  | `PlanLimitsSchema` / `PlanLimits` / `PlanWindowSchema` / `PlanWindow` | schemas / _types_ | a subscription's limits: `known`, `no-plan-limit` or `unpublished`, with optional `plan` and the last read's error beside the last answer; each window carries `name`, `usedPercent`, and optional `resetsAt`, `windowDurationMins`, `label`, and `scope` |
28605
29325
  | `ThreadClaimSchema` / `ThreadClaim` / `ThreadLeaseSchema` / `ThreadLease` / `ThreadRenewSchema` / `ThreadReleaseSchema` | schemas / _types_ | thread leases pinned to an executor and profile, under a fence |
28606
29326
  | `TurnOfferSchema` / `TurnOffer` / `TurnPhaseSchema` / `TurnPhase` / `TurnReportSchema` / `TurnReport` / `TurnReportAckSchema` / `TurnFailureKindSchema` / `TurnInterruptSchema` / `InteractionReplySchema` / `InteractionReply` / `EXECUTOR_ERRORS` | schemas / _types_ / constant | a turn offered under its thread's `turnOrdinal`, its phases and reports applied once by `executorSeq` (acknowledged `applied`, `duplicate` or `not-retained`), interrupts, answers to an engine's requests (`approve` with optional `scope: 'once' \| 'session'` and `updatedInput`, `deny` with optional `interrupt: boolean`), and the refusal codes |
28607
- | `ExecutorDeltaSchema` / `ExecutorDelta` / `ExecutorStatusDeltaSchema` / `ExecutorStartupPhaseSchema` / `ExecutorStartupPhase` / `ExecutorThreadDispositionSchema` / `ExecutorThreadDisposition` / `ExecutorErrorKindSchema` / `ExecutorErrorKind` / `ExecutorRawSchema` / `ExecutorTokenUsageSchema` / `ExecutorTokenUsage` / `ExecutorModelUsageSchema` / `ExecutorModelUsage` | schemas / _types_ | what an engine said: `agent-parts` blocks with `turnId`, `itemId` and `raw`, plus requests, usage (including optional `cacheCreationInputTokens`, `thinkingTokens`, `totalTokens`, cumulative `total`, and per-model `modelUsage`), the context gauge (`context-usage`), lifecycle `status` deltas (`ExecutorStartupPhase` is an open label of 1–64 trimmed characters; the drivers emit `spawning`, `initializing` and `verifying`, and a reader treats any other label as a phase it does not know), the end of the turn (with optional `threadDisposition`: `'reusable' \| 'broken'`, also carried on `TurnReportSchema.failure`), errors by kind and window resets |
28608
- | `projectExecutorDeltas` | function | fold a turn's deltas into the message parts the agent runtime stores (ignoring lifecycle `status` deltas) |
29327
+ | `ExecutorDeltaSchema` / `ExecutorDelta` / `ExecutorStatusDeltaSchema` / `ExecutorPlanDeltaSchema` / `ExecutorPlanDelta` / `ExecutorPlanEntrySchema` / `ExecutorPlanEntry` / `ExecutorPlanEntryStatusSchema` / `ExecutorPlanEntryStatus` / `ExecutorPlanEntryPrioritySchema` / `ExecutorPlanEntryPriority` / `ExecutorStartupPhaseSchema` / `ExecutorStartupPhase` / `ExecutorThreadDispositionSchema` / `ExecutorThreadDisposition` / `ExecutorErrorKindSchema` / `ExecutorErrorKind` / `ExecutorRawSchema` / `ExecutorTokenUsageSchema` / `ExecutorTokenUsage` / `ExecutorModelUsageSchema` / `ExecutorModelUsage` | schemas / _types_ | what an engine said: `agent-parts` blocks with `turnId`, `itemId` and `raw` (including optional `provider` metadata on `tool-call` and `tool-result`), live `plan` deltas (`set`, `update`, `remove` with typed `entries` carrying `content`, `status` and optional `priority`), plus requests, usage (including optional `cacheCreationInputTokens`, `thinkingTokens`, `totalTokens`, cumulative `total`, and per-model `modelUsage`), the context gauge (`context-usage`), lifecycle `status` deltas (`ExecutorStartupPhase` is an open label of 1–64 trimmed characters; the drivers emit `spawning`, `initializing` and `verifying`, and a reader treats any other label as a phase it does not know), the end of the turn (with optional `threadDisposition`: `'reusable' \| 'broken'`, also carried on `TurnReportSchema.failure`), errors by kind and window resets |
29328
+ | `projectExecutorDeltas` | function | fold a turn's deltas into the message parts the agent runtime stores (forwarding `provider` metadata on `tool-call` / `tool-result` and ignoring lifecycle `status` and `plan` deltas) |
28609
29329
  | `buildContextHandoff` / `withInlineHandoffContext` / `InlineHandoffComposition` / `ContextHandoffInputSchema` / `ContextHandoffInput` / `ContextHandoffEntrySchema` / `ContextHandoffEntry` / `ContextHandoffMessageEntrySchema` / `ContextHandoffClearEntrySchema` / `ContextHandoffBudgetSchema` / `ContextHandoffStrategySchema` / `ContextHandoffResultSchema` / `ContextHandoffResult` / `ContextHandoffSelectedItemSchema` / `ContextHandoffSelectedItem` / `ContextHandoffStructuredItemSchema` / `ContextHandoffStructuredItem` | functions / schemas / _types_ | pure portable context-handoff builder for cross-engine or cross-session transitions: supports `full` and `delta` (`afterItemId` or `afterTurnId`, fail-closed `missingAnchor: 'error'` or `'full'`) strategies respecting the latest `clear` barrier, keeps intact items by fixed priority (`last user → last assistant → first user → newest..oldest`) under strict `maxTokens` / `maxBytes` / `maxOmittedIds` (and optional `contextWindowTokens` / `usedTokens` / `workReserveTokens`; an omitted `usedTokens` counts as `0` — the caller's statement that the receiving thread is new, so a caller that does not know the fill of a thread in use omits `contextWindowTokens` too) ceilings while dropping non-text/binary/reasoning/provider parts, emits deterministic `inlineText` and Responses API `structuredItems`, and composes inline context ahead of a user prompt via `withInlineHandoffContext` (deferring on leading `/slash` commands) |
28610
29330
  | `AgentEngineDriver` / `AgentEngineSession` / `AgentEngineTurn` / `ExecutorEngineInfo` | _types_ | one vendor's engine behind one interface: info, declarative `capabilities`, login status, a session per connection (accepting `onStartupPhase` on `open`), turns with `interrupt` and `respond`, `findInput` for a `client-id` engine. A session stops for one reason, asked in one order — its `close()`, the loss of its engine, the caller's `signal`, its own abort: `open` given an aborted signal rejects with the signal's reason; an abort in a turn fails its stream with that reason, and `respond` and `startTurn` then reject with it; `respond` on a turn that failed rejects with that failure; `interrupt` on an ended turn or a stopped session resolves and tells the engine nothing; `close()` may be called again |
28611
29331
  | `dispatchTurn` / `DispatchOutcome` | function / _type_ | send a turn's input at most once through `LocalStepDurability.effect`: `sent`, `delivered` after a reconcile, or `unknown_after_restart` — never resent |
28612
- | `spawnEngineProcess` / `EngineProcess` | function / _type_ | an engine process talked to by lines over `stitchkit/process`: declared environment, owner-loss termination, optional leader `pid` / `pidReady`, `stdoutMode` (`'lines'` default or `'drain'` for socket-serving engines), bounded lines (`maxLineBytes`), stderr, queued stdin (`maxPendingStdinBytes`) and stdin written over the connection's life (`maxStdinBytes`, a refused `send()` that leaves the engine running); every option checked before the spawn |
29332
+ | `spawnEngineProcess` / `EngineProcess` / `EngineProcessCommandSpec` / `EngineProcessWrapCommand` | function / _types_ | an engine process talked to by lines over `stitchkit/process` plus the structural command-wrapper hook contract (`EngineProcessCommandSpec`, `EngineProcessWrapCommand`) accepted by ACP and Codex drivers: declared environment, owner-loss termination, optional leader `pid` / `pidReady`, `stdoutMode` (`'lines'` default or `'drain'` for socket-serving engines), bounded lines (`maxLineBytes`), stderr, queued stdin (`maxPendingStdinBytes`) and stdin written over the connection's life (`maxStdinBytes`, a refused `send()` that leaves the engine running); every option checked before the spawn |
28613
29333
  | `createExecutorLeases` / `memoryExecutorLeaseStore` / `ExecutorLeaseStateStore` / `ExecutorLeaseState` / `ExecutorLeaseStateSchema` / `ExecutorLeaseRefusal` | functions / _types_ / class | the server's thread leases and turn receipts over one atomically updated value, bounded by threads: each thread keeps the receipts of its last `retainedTurns` turns (default 64, at most 1024) and the highest `turnOrdinal` it let go, a report of a turn at or below it is `not-retained`, and `resume(resumable)` answers a hello the same way; a `StateStore` of `stitchkit/application` fits; a refusal is an `ExecutorLeaseRefusal` — an `AppError` with status 409 and a code of `EXECUTOR_ERRORS` — so an operation returning the service's promise answers `409 { error: { code } }` |
28614
29334
  | `ExecutorProfileConfigSchema` / `ExecutorProfileConfig` / `EXECUTOR_ENV_KEY_PATTERN` / `engineEnvironment` / `ownCredentials` / `helloProfile` / `CREDENTIAL_VARIABLES` | schema / _type_ / constants / functions | a profile on the executor's machine, the one rule for a declared variable's name (`EXECUTOR_ENV_KEY_PATTERN`: the schema refuses a profile whose `env` holds any other name, on every path a profile takes), the engine's allowlisted environment with an explicit profile's `home` as `CLAUDE_CONFIG_DIR`, `CODEX_HOME` or (ACP) `HOME` plus explicit `profile.env` pass-through for host-specific overrides (such as `TMPDIR`, `SSH_CONNECTION`, or agent-specific `AGY_*` variables), and `helloProfile({ profile, status, ambient })` carrying no path and no value; a driver refuses a profile whose `engine` is not its own with a `TypeError`, before it reads a file or starts the engine |
28615
29335
  | `mergeRateLimitEvent` / `planLimitsReadFailed` / `planLimitsDue` / `planWindowExpired` / `planWindowDurationMins` | functions | plan limits kept as three answers (`mergeRateLimitEvent` preserving `plan`, `planLimitsReadFailed`, `planLimitsDue` treating clean `no-plan-limit`/`unpublished` as not due, `planWindowExpired`, and `planWindowDurationMins` deriving durations in minutes) |
@@ -28641,6 +29361,10 @@ What a release added to the wire, and so what a reader older than it refuses:
28641
29361
  | 0.130.0 | executor → server | `report` | `deltas[].type = 'status'`, `turn-end.threadDisposition`, `usage.cacheCreationInputTokens`, `usage.thinkingTokens`, `usage.totalTokens`, `usage.total`, `usage.modelUsage`, `failure.threadDisposition` |
28642
29362
  | 0.130.0 | server → executor | `reply` | `approve.scope`, `approve.updatedInput`, `deny.interrupt` |
28643
29363
  | 0.131.0 | executor → server | `hello` | `profiles[].planLimits.plan`, `profiles[].planLimits.windows[].scope` |
29364
+ | 0.134.0 | executor → server | `report` | `deltas[].type = 'plan'`, `tool-result.provider` |
29365
+ | 0.134.0 | server → executor | `offer` | `input[type=text].provider`, `input[type=tool-result].provider` |
29366
+
29367
+ (`offer.input` uses non-strict `AgentMessagePartSchema` part objects, so an executor older than `0.134.0` strips `input[type=text].provider` and `input[type=tool-result].provider` instead of refusing the offer; `report` objects are strict, so an older server refuses `deltas[].type = 'plan'` and `tool-result.provider`.)
28644
29368
 
28645
29369
  For a Claude CLI or SDK profile that should use the user's native sign-in, pass
28646
29370
  `{ profileId: 'personal', engine: 'claude-sdk', home: join(homedir(), '.claude'), claudeConfigDir: 'default' }`.
@@ -28708,11 +29432,11 @@ approvals for unprompted tool calls. Explicit `approve` supports `scope: 'once'`
28708
29432
 
28709
29433
  | Export | Kind | Purpose |
28710
29434
  |--------|------|---------|
28711
- | `createAcpDriver` / `AcpDriver` / `AcpDriverConfig` | function / _types_ | the driver (`approvalEnforcement: 'agent-initiated'`): `executable` and `args`; optional `clientInfo`, `sessionMeta`, `stdoutLineFilter`, `probeMode` (`'ephemeral-session' \| 'initialize-only' \| 'passive'`) / `passiveVersion`, `model` / `thoughtLevel` / `mode` (also overridable per open via `AcpOpenInput`, falling back to `session/set_model`), `mcpServers`, `transformUpdate`, post-settle `onUpdate` / `onPermissionRequest`, `permissionRequestDelivery` (`'external-only' \| 'all'`), `onProviderPid` (fired during `open()`), `onDisconnect`, `onObserverError` (every failure of a host callback the driver contained, with the name of the option that failed; a `JsonRpcError` thrown by `onPermissionRequest` outside a turn is its refusal and is not reported), `watchPromptOutcome`, `usageInputIncludesCachedRead`, `steerMode` (`'none' \| 'prompt'`), `resolveFile`, `maxImageBytes` (5 MiB), `maxFrameBytes` (8 MiB), `ambient`, and `requestTimeoutMs` (60 s, capping `session/close` / `session/delete` to at most 5 s; a request the agent sends while `close()` waits for `session/close` is refused — `session/request_permission` with the `cancelled` outcome, any other method with `-32601` — and after an abort or a lost connection nothing is written); exposes `probeCapabilities(AcpProbeCapabilitiesInput)` for non-inference capability probing |
29435
+ | `createAcpDriver` / `AcpDriver` / `AcpDriverConfig` | function / _types_ | the driver (`approvalEnforcement: 'agent-initiated'`): `executable` and `args`; optional `clientInfo`, `sessionMeta`, `stdoutLineFilter`, `probeMode` (`'ephemeral-session' \| 'initialize-only' \| 'passive'`) / `passiveVersion`, `model` / `thoughtLevel` / `mode` (also overridable per open via `AcpOpenInput`, falling back to `session/set_model`), `mcpServers`, `transformUpdate`, post-settle `onUpdate` / `onPermissionRequest`, `permissionRequestDelivery` (`'external-only' \| 'all'`), `onProviderPid` (fired during `open()`), `onDisconnect`, `onObserverError` (every failure of a host callback the driver contained, with the name of the option that failed; a `JsonRpcError` thrown by `onPermissionRequest` outside a turn is its refusal and is not reported), `watchPromptOutcome`, `usageInputIncludesCachedRead`, `steerMode` (`'none' \| 'prompt'`), `resolveFile`, `maxImageBytes` (5 MiB), `maxFrameBytes` (8 MiB), `ambient`, `wrapCommand` (command wrapper invoked before spawn, e.g. an OS process sandbox), and `requestTimeoutMs` (60 s, capping `session/close` / `session/delete` to at most 5 s; a request the agent sends while `close()` waits for `session/close` is refused — `session/request_permission` with the `cancelled` outcome, any other method with `-32601` — and after an abort or a lost connection nothing is written); exposes `probeCapabilities(AcpProbeCapabilitiesInput)` for non-inference capability probing |
28712
29436
  | `AcpSession` / `AcpOpenInput` / `AcpSteerTurnInput` / `AcpConfigOption` / `AcpConfigOptionChoice` / `acpOptionChoices` / `acpOptionValues` / `AcpApprovalEnforcement` | _types_ / functions | a session's `providerPid`, its agent's `initialize` answer (`initialized`, with `agentCapabilities.promptCapabilities`), optional `sessionMeta` (`_meta` returned by `session/new`, `session/resume`, or `session/load` when it is a plain JSON object), settings, title and commands, `approvalEnforcement` (`'agent-initiated'`), `setConfigOption(category or id, value)`, `respond(interactionId, reply)` for pending permissions, `steerTurn(input)` when `steerMode: 'prompt'`, per-open overrides on `AcpOpenInput`, and flat/grouped config-option flattening helpers (`acpOptionChoices`, `acpOptionValues`) |
28713
29437
  | `AcpProbeCapabilitiesInput` / `AcpCapabilitiesProbe` / `AcpProbeMode` / `AcpSteerMode` / `AcpSessionMetaInput` / `AcpWatchPromptOutcome` / `AcpPromptOutcomeOverride` | _types_ | non-inference capability probe input/result (running regardless of `probeMode`; returns optional `sessionMeta` from `session/new` when `_meta` is a plain JSON object; `eachModel: true` also selects each `model` value in the ephemeral session and returns `optionsByModel`; once `session/new` answered, `session/close` and `session/delete` run even after an abort or timeout), probe strategy, steer mode, static or `initialize`-derived `_meta` attachment on session open, and prompt-outcome verification hook reclassifying masked `end_turn` failures with `errorKind` and `threadDisposition` |
28714
29438
  | `AcpTransformUpdate` / `AcpUpdateEvent` / `AcpPermissionRequestEvent` | _types_ | update normalizer (`transformUpdate`), live/post-settle `session/update` observer payload (`onUpdate`), and permission request payload with `duringActiveTurn`, full typed `request.options`, and shared single-shot `respond()` (`onPermissionRequest`) |
28715
- | `AcpClientInfoSchema` / `AcpClientInfo` / `AcpInitializeResultSchema` / `AcpInitializeResult` / `AcpConfigOptionSchema` / `AcpSessionUpdateSchema` / `AcpSessionUpdate` / `AcpPromptResult` / `AcpPromptUsage` / `AcpPermissionRequestSchema` / `AcpPermissionRequest` / `AcpPermissionOptionSchema` / `AcpPermissionOption` | schemas / _types_ | loose Zod schemas and typed ACP v1 wire payloads exposed to `sessionMeta`, `transformUpdate`, `onUpdate`, `onPermissionRequest`, and `watchPromptOutcome` |
29439
+ | `AcpClientInfoSchema` / `AcpClientInfo` / `AcpInitializeResultSchema` / `AcpInitializeResult` / `AcpConfigOptionSchema` / `AcpSessionUpdateSchema` / `AcpSessionUpdate` / `AcpToolLocationSchema` / `AcpToolLocation` / `AcpPlanEntrySchema` / `AcpPlanEntry` / `AcpPromptResult` / `AcpPromptUsage` / `AcpPermissionRequestSchema` / `AcpPermissionRequest` / `AcpPermissionOptionSchema` / `AcpPermissionOption` | schemas / _types_ | loose Zod schemas and typed ACP v1 wire payloads exposed to `sessionMeta`, `transformUpdate`, `onUpdate`, `onPermissionRequest`, and `watchPromptOutcome` (including tool `title`/`kind`/`locations`, meaningful `tool_call_update` progress updates, and `plan`/`plan_update`/`plan_removed` entries) |
28716
29440
  | `AcpSessionSummary` | _type_ | a session the agent keeps: id, working directory, title, last update |
28717
29441
  | `AcpMcpServerSchema` / `AcpMcpServer` | schema / _type_ | an MCP server as ACP v1 names it: a command with arguments and environment, or an `http`/`sse` URL with headers |
28718
29442
  | `ACP_PROTOCOL_VERSION` | constant | `1`; ACP v1 agents answering `protocolVersion >= 1` are accepted while protocol `< 1` and ACP v2 responses carrying `"info"` are refused at hello |
@@ -28737,7 +29461,7 @@ WebSocket-over-Unix-socket (`unix-listen` / `unix-connect`). Evolving.
28737
29461
 
28738
29462
  | Export | Kind | Purpose |
28739
29463
  |--------|------|---------|
28740
- | `createCodexDriver` / `CodexDriver` / `CodexDriverConfig` | function / _types_ | the driver: `transport` (`stdio`, `unix-listen`, `unix-connect`), `serverArgs`, thread policy (`model`, `modelProvider`, `approvalPolicy`, `sandbox`, `developerInstructions`, `runtimeWorkspaceRoots`, `config`), `prepareThread` / `verifyThread` lifecycle hooks, observers (`onNotification`, `onServerRequest`, `serverRequestDelivery` `'external-only' \| 'all'`, `onDisconnect`, and `onObserverError`, which receives every failure of a host callback the driver contained with the name of the option that failed, or `driver:notification` for a failure inside a shared server's own handling), `maxFrameBytes` (WebSocket/stdio frame ceiling), optional `resolveFile` and `maxImageBytes` (default 5 MiB) for turn-input images, `connectControl(input)` for threadless connections, opt-in `openSharedServer(input)` for headless `stdio` multi-thread multiplexing (ADR 0329), approvals and input asked of the host, and multi-bucket limits from `account/rateLimits/read`. Closing a session, a control connection or a shared server on a stdio app-server answers every server request it still holds, and any that arrives while the process stops, as stopped; after an abort or a lost connection nothing is written, and on a Unix-socket transport such a request is left for the TUI |
29464
+ | `createCodexDriver` / `CodexDriver` / `CodexDriverConfig` | function / _types_ | the driver: `transport` (`stdio`, `unix-listen`, `unix-connect`), `serverArgs`, `wrapCommand` (command wrapper invoked before spawn, e.g. an OS process sandbox), thread policy (`model`, `modelProvider`, `approvalPolicy`, `sandbox`, `developerInstructions`, `runtimeWorkspaceRoots`, `config`), `prepareThread` / `verifyThread` lifecycle hooks, observers (`onNotification`, `onServerRequest`, `serverRequestDelivery` `'external-only' \| 'all'`, `onDisconnect`, and `onObserverError`, which receives every failure of a host callback the driver contained with the name of the option that failed, or `driver:notification` for a failure inside a shared server's own handling), `maxFrameBytes` (WebSocket/stdio frame ceiling), optional `resolveFile` and `maxImageBytes` (default 5 MiB) for turn-input images, `connectControl(input)` for threadless connections, opt-in `openSharedServer(input)` for headless `stdio` multi-thread multiplexing (ADR 0329), approvals and input asked of the host, and multi-bucket limits from `account/rateLimits/read`. Closing a session, a control connection or a shared server on a stdio app-server answers every server request it still holds, and any that arrives while the process stops, as stopped; after an abort or a lost connection nothing is written, and on a Unix-socket transport such a request is left for the TUI |
28741
29465
  | `CodexTransportConfig` | _type_ | transport selector: `{ kind: 'stdio' }`, `{ kind: 'unix-listen', socketPath, listenTimeoutMs? }`, or `{ kind: 'unix-connect', socketPath, expectedOwnerUid? }` (resolving symlink chains on parent directories safely across Linux and Darwin) |
28742
29466
  | `CodexSession` / `CodexControlClient` / `CodexControlConnection` / `CodexControlConnectInput` / `CodexRpcCallOptions` | _types_ | extended session returned by `open()` and threadless connection returned by `connectControl()`: expose `providerPid`, `userAgent` (from `initialize`), `respond`, `readConfig`, `readThread`, `resumeThread`, `startThreadTurn` (threadless `turn/start` without occupying a local session turn slot), `interruptTurn`, `steerTurn`, `compactThread`, `listThreads`, `listLoadedThreads`, `listCollaborationModes`, `listTurns`, `listItems`, `archiveThread`, `unarchiveThread`, `unsubscribeThread`, `setThreadName`, `updateThreadMetadata`, `revertThread`, `injectItems`, `listMcpServerStatus`, `listSkills`, `listModels`, `readAccount`, and `readRateLimits`, each accepting optional per-call `CodexRpcCallOptions` (`{ timeoutMs?, signal? }`); `CodexSession` also exposes `threadContext`, `startTurn` (returning `CodexTurn`), and non-mutating `forkThread` |
28743
29467
  | `CodexSharedServer` / `CodexSharedServerOpenInput` / `CodexSharedServerThreadInput` | _types_ | opt-in headless `stdio` multi-thread server returned by `driver.openSharedServer()` exposing `userAgent` and multiplexing up to `maxThreads` (default `32`, hard cap `256`) independent `CodexSession` instances with per-thread routing and `thread/unsubscribe` cleanup on thread close (refuses `unix-listen` / `unix-connect` fail-closed) |
@@ -29049,6 +29773,12 @@ server SDK), [`stitchkit/tools/agent`](#stitchkittoolsagent) (the `ai` peer) and
29049
29773
 
29050
29774
  | Export | Kind | Summary |
29051
29775
  |--------|------|---------|
29776
+ | `mountAgentTools` | function | project contract services and runtime tools into a peer-free `AgentToolSet` — the single contract-to-agent projection executed by `stitchkit/agent-runtime` and adapted by `mountAgent` (→ ADR 0336) |
29777
+ | `defineAgentTool` | function | define one standalone peer-free `AgentTool` from a Zod input schema without importing any external SDK |
29778
+ | `DefineAgentToolConfig` | _type_ | declarative configuration (`input`, optional `output`, `description`, `strict`, `cacheControl`, `providerOptions`, `flattenUnionInput`, `needsApproval`, `onInputAvailable`, `toModelOutput`, `execute`) for `defineAgentTool` |
29779
+ | `AgentTool` / `AgentToolSet` / `AgentToolCall` / `AgentToolParseResult` / `AgentToolInputAvailableOptions` / `AgentToolToModelOutputOptions` | _types_ | peer-free executable agent tool contract, map, invocation context (`toolCallId`, `messages`, `abortSignal`, `durability`, `reportProgress`), parse verdict and callback option shapes |
29780
+ | `AgentMountConfig` / `AgentContext` | _types_ | configuration and context map shared by `mountAgentTools` and `mountAgent` |
29781
+ | `AgentToolModelOutput` | _type_ | peer-free model-facing text/JSON/content output returned by `present.agent` and `AgentTool.toModelOutput` (non-deprecated `{ type: 'file', data, mediaType }` parts) |
29052
29782
  | `defineRuntimeTool` | function | define one validated pathless operation for explicit MCP, Agent and/or CLI surfaces — [guide](../guide/mcp-and-agents.md#pathless-runtime-tools-and-multimodal-results) |
29053
29783
  | `createRuntimeToolFactory` | function | bind shared identity and Zod-validated per-call context for runtime tools — [guide](../guide/mcp-and-agents.md#pathless-runtime-tools-and-multimodal-results) |
29054
29784
  | `createToolInvoker` | function | compile an exposure-aware in-process dispatcher over the canonical tool runner; use `stitchkit/tools/invoker` or `stitchkit/tools`, both peer-free — [guide](../guide/mcp-and-agents.md#in-process-calls--createtoolinvoker) |
@@ -29071,7 +29801,7 @@ server SDK), [`stitchkit/tools/agent`](#stitchkittoolsagent) (the `ai` peer) and
29071
29801
  | `RuntimeToolIdentity` | _type_ | `{ serviceName, action, scope?, method, effect?, meta? }` for runtime lifecycle/audit and repeatable-read derivation (`readOnlyHint` → `effect: 'write'` → `effect: 'read'` → `GET`, guarded by `destructiveHint !== true`) |
29072
29802
  | `RuntimeToolHandlerContext` | _type_ | runtime context with the definition's parsed input |
29073
29803
  | `RuntimeToolOutput` | _type_ | output inferred from a runtime tool's optional Zod schema |
29074
- | `RuntimeToolPresenters` | _type_ | optional MCP and AI SDK `toModelOutput` presentation callbacks |
29804
+ | `RuntimeToolPresenters` | _type_ | optional MCP and peer-free `present.agent` (`AgentToolModelOutput`) presentation callbacks |
29075
29805
  | `RuntimeMcpPresentation` | _type_ | MCP content/metadata result without framework-owned `structuredContent` or `isError` |
29076
29806
  | `RuntimeMcpInput` | _type_ | typed accepted multi-round input for an opted-in runtime tool |
29077
29807
  | `OAuthClientRegistrationConfig` | _type_ | deterministic pre-registered → CIMD → explicit-DCR client resolution |
@@ -29082,7 +29812,6 @@ server SDK), [`stitchkit/tools/agent`](#stitchkittoolsagent) (the `ai` peer) and
29082
29812
  | `CimdCachePolicy` | _type_ | bounded HTTP-aware cache policy: separate positive/negative pools (`maxEntries`), per-client and server-wide resolution rate limits (`maxResolutionsPerClient` / `maxResolutions` per `resolutionWindowMs`) |
29083
29813
  | `CimdCacheEvent` | _type_ | observable CIMD cache hit, miss, revalidation and eviction event |
29084
29814
  | `createSecureClientMetadataFetcher` | function | production HTTPS, DNS/IP-pinned CIMD fetcher |
29085
- | `RuntimeAgentModelOutput` | _type_ | AI SDK model-facing text/JSON/content output returned by `present.agent` |
29086
29815
  | `AgentToolRegistry` / `AgentToolRegistryBuilder` / `AgentToolRegistryInput` | _type_ | the composed runtime surface and its builder: declared defaults, `replace`/`disable` by name, and the exact `{ tools, names }` a mount receives |
29087
29816
  | `defineToolRegistry` | function | compose runtime tools over one declared default set; an unknown `replace`/`disable` name is refused instead of silently leaving the default in place |
29088
29817
  | `ToolExtend` | _type_ | extra-args extension for `mountMcp` / `mountAgent` |
@@ -29335,14 +30064,16 @@ Interactive MCP resources — [ADR 0019](../decisions/0019-generic-native-tools.
29335
30064
 
29336
30065
  ## `stitchkit/tools/agent`
29337
30066
 
29338
- Server-only. A contract's operations as Vercel AI SDK tools; needs Zod and the `ai`
29339
- peer, not the MCP server SDK. → ADR 0284.
30067
+ Server-only thin adapter over `mountAgentTools` (`stitchkit/tools`) that projects a contract's
30068
+ operations into a Vercel AI SDK `ToolSet` emitting only non-deprecated `{ type: 'file', data,
30069
+ mediaType }` parts for applications running their own AI SDK loop. Needs Zod and the `ai` peer,
30070
+ not the MCP server SDK. → ADR 0284, ADR 0336.
29340
30071
 
29341
30072
  | Export | Kind | Summary |
29342
30073
  |--------|------|---------|
29343
- | `mountAgent` | function | a Vercel AI SDK `ToolSet` from a service; failed executions reject through the SDK tool-error channel with a safe typed envelope, while successful output is never classified by field name — [guide](../guide/mcp-and-agents.md#ai-agents--mountagent) |
29344
- | `AgentMountConfig` | _type_ | config for `mountAgent` |
29345
- | `AgentContext` | _type_ | the context merged into agent tool handlers |
30074
+ | `mountAgent` | function | adapt `mountAgentTools` into a Vercel AI SDK `ToolSet`; failed executions reject through the SDK tool-error channel with a safe typed envelope, while successful output is never classified by field name — [guide](../guide/mcp-and-agents.md#ai-agents--mountagent) |
30075
+ | `AgentMountConfig` | _type_ | config for `mountAgent` (shared with `mountAgentTools`) |
30076
+ | `AgentContext` | _type_ | the context merged into agent tool handlers (shared with `mountAgentTools`) |
29346
30077
 
29347
30078
  ## `stitchkit/tools/toolkit`
29348
30079
 
@@ -29352,7 +30083,7 @@ needs both the `@modelcontextprotocol/server` and `ai` peers. → ADR 0284.
29352
30083
  | Export | Kind | Summary |
29353
30084
  |--------|------|---------|
29354
30085
  | `createToolkit` | function | context-typed tool mounts — [guide](../guide/cli.md#typed-context) |
29355
- | `Toolkit` | _type_ | the context-pinned tool surface from `createToolkit` |
30086
+ | `Toolkit` | _type_ | the context-pinned tool surface from `createToolkit` (including both `mountAgentTools(services, config)` and single-argument `mountAgentTools(config)`) |
29356
30087
 
29357
30088
  ## `stitchkit/tools/connections`
29358
30089
 
@@ -30333,7 +31064,9 @@ host-only `SandboxCodingBinding`, with shared authorization, command collection
30333
31064
  Its types are `AgentSandboxGrade`, `AgentSandboxRestriction`, `BubblewrapSandboxConfig`, `SandboxBackend`, `SandboxCommand`,
30334
31065
  `SandboxCreateInput`, `SandboxDriver`, `SandboxHandle`, `SandboxNetworkPolicy`,
30335
31066
  `SandboxPrewarmInput`, `SandboxProcess`, `SandboxRunOptions`, `SandboxSession`,
30336
- and `SandboxState`. The [sandbox guide](../guide/sandbox.md) specifies lifecycle,
31067
+ and `SandboxState`. `createProcessSandbox`, `probeProcessSandbox`, and `buildSeatbeltProfile` provide a reusable fail-closed OS process sandbox wrapper for long-lived streaming stdio/IPC processes (`workspace-strict` and `workspace-readonly` profiles with real workspace paths, explicit `writableDirs`, `readOnlyPaths`, `denyPaths`, `unixSockets`, `network` policy, `envAllowlist`, `homeDir`, Linux `bwrap` and macOS Seatbelt `sandbox-exec`, throwing `SandboxError('SANDBOX_UNAVAILABLE', ...)` rather than falling back silently; its `wrapCommand` fits `AcpDriverConfig.wrapCommand` and `CodexDriverConfig.wrapCommand`). Its schemas and types are `ProcessSandboxSpecSchema`, `ProcessSandboxSpec`, `ProcessSandboxProfileSchema`, `ProcessSandboxProfile`, `ProcessSandboxNetworkSchema`, `ProcessSandboxNetwork`, `ProcessSandboxBackendKindSchema`, `ProcessSandboxBackendKind`, `ProcessSandboxUnixSocketSchema`, `ProcessSandboxUnixSocket`, `ProcessSandboxProbeResultSchema`, `ProcessSandboxProbeResult`, `ProcessSandboxProbeOptions`, `ProcessSandboxCommandSpec`, and `ProcessSandbox`.
31068
+
31069
+ The [sandbox guide](../guide/sandbox.md) specifies lifecycle,
30337
31070
  network enforcement, gateway credentials and platform/resource boundaries.
30338
31071
 
30339
31072
  ## `stitchkit/agent-runtime/realtime`
@@ -30528,3 +31261,41 @@ Native consumers import HTTP factories, `ApiError`, `createUrlBuilder`,
30528
31261
  `RealtimeClient`, `defineRealtimeContract`, `InferRealtimeEventMap`, `createRetainedTopics`
30529
31262
  and `RetainedTopics` from `stitchkit/realtime`. `createQueryClientFactory` remains in
30530
31263
  `stitchkit/react`. Shared modules must use the same public leaves throughout their graph.
31264
+
31265
+ ### Account device presence and remote command bus
31266
+
31267
+ Share one realtime connection across account-scoped online device presence, live capability state
31268
+ slots (media playback, active reading, relay status) and targeted remote commands with structured
31269
+ acknowledgements (`ok`, `DEVICE_OFFLINE`, `FORBIDDEN`, `TIMEOUT`, `UNSUPPORTED_CAPABILITY`,
31270
+ `HANDLER_ERROR`, `INVALID_COMMAND`, `DISCONNECTED`). Mount the server side with
31271
+ `bindDevicePresence` from `stitchkit/server`.
31272
+
31273
+ | Export | Kind | Summary |
31274
+ |--------|------|---------|
31275
+ | `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 |
31276
+ | `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 |
31277
+ | `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 |
31278
+ | `DevicePresenceIdentitySchema` / `DevicePresenceIdentity` / `DevicePresenceErrorCodeSchema` / `DevicePresenceErrorCode` | schemas / _types_ | strict device identity metadata and closed error code vocabulary |
31279
+ | `DevicePresenceDevice` / `DevicePresenceSnapshot` / `DevicePresenceStates` / `DevicePresenceStatesInput` / `DevicePresenceAnnouncePayload` / `DevicePresenceAnnounceAck` / `DevicePresenceStateUpdatePayload` / `DevicePresenceStateUpdateAck` / `DevicePresenceCommandRequest` / `DevicePresenceCommandDelivery` / `DevicePresenceCommandResult` | _types_ | inferred account presence snapshot, state update and targeted remote command wire payloads |
31280
+ | `DEFAULT_DEVICE_PRESENCE_PREFIX` / `DEFAULT_DEVICE_PRESENCE_COMMAND_TIMEOUT_MS` / `DEFAULT_DEVICE_PRESENCE_REQUEST_TIMEOUT_MS` | consts | default event namespace prefix and timeout bounds |
31281
+
31282
+ ## `stitchkit/device-relay`
31283
+
31284
+ Peer-free, browser- and Hermes-safe User Device Relay over realtime. Multiplexes unary Fetch RPCs
31285
+ and credit-paced resumable cursor streams over a single outbound realtime connection from a user's
31286
+ desktop machine to a multi-tenant backend hub.
31287
+
31288
+ | Export | Kind | Summary |
31289
+ |--------|------|---------|
31290
+ | `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) |
31291
+ | `DeviceRelayRealtimeServer` / `DeviceRelayServerConnection` / `DeviceRelayRawSocket` / `DeviceRelayDeviceAuthInput` / `DeviceRelayAuthenticatedDevice` / `DeviceRelayAccessRequest` | _types_ | peer-free structural server contracts satisfied directly by `bindRealtimeServer(deviceRelayRealtimeContract, io)` |
31292
+ | `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 |
31293
+ | `createMemoryRelayBroker` / `RelayBrokerPort` / `RelayBrokerInstanceHandler` / `RelayBrokerStreamHandle` / `RelayBrokerStreamSink` | function / _types_ | multi-replica routing port (`RelayBrokerPort`) and in-memory default broker (`createMemoryRelayBroker`) |
31294
+ | `DeviceRelayStream` / `DeviceRelayStreamFrame` | _types_ | async-iterable cursor stream handle and yielded frame shape |
31295
+ | `deviceRelayRealtimeContract` | const | namespaced Zod-validated `RealtimeContract` (`stitchkit.relay.*` hello, heartbeat, unary RPC and cursor stream frames) |
31296
+ | `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`) |
31297
+ | `DeviceRelayStateSchema` / `DeviceRelayState` / `DeviceRelayStatusSchema` / `DeviceRelayStatus` / `DeviceRelayOfflineReasonSchema` / `DeviceRelayOfflineReason` | schemas / _types_ | live presence snapshot, status (`online`, `offline`) and offline transition reasons (`disconnected`, `lease-expired`, `replaced`, `closed`) |
31298
+ | `DeviceRelayHelloSchema` / `DeviceRelayHello` / `DeviceRelayHelloAckSchema` / `DeviceRelayHelloAck` / `DeviceRelayHeartbeatSchema` / `DeviceRelayHeartbeat` / `DeviceRelayHeartbeatAckSchema` / `DeviceRelayHeartbeatAck` | schemas / _types_ | handshake registration and lease renewal wire frames |
31299
+ | `DeviceRelayRpcRequestSchema` / `DeviceRelayRpcRequest` / `DeviceRelayRpcCancelSchema` / `DeviceRelayRpcCancel` / `DeviceRelayRpcResponseSchema` / `DeviceRelayRpcResponse` / `DeviceRelayHeaderEntrySchema` / `DeviceRelayHeaderEntry` / `DeviceRelayBodyEncodingSchema` / `DeviceRelayBodyEncoding` | schemas / _types_ | unary HTTP-over-realtime request, cancel and response wire frames |
31300
+ | `DeviceRelayStreamOpenSchema` / `DeviceRelayStreamOpen` / `DeviceRelayStreamOpenAckSchema` / `DeviceRelayStreamOpenAck` / `DeviceRelayStreamCreditSchema` / `DeviceRelayStreamCredit` / `DeviceRelayStreamCloseSchema` / `DeviceRelayStreamClose` / `DeviceRelayStreamEventSchema` / `DeviceRelayStreamEvent` / `DeviceRelayJsonValueSchema` / `DeviceRelayJsonValue` | schemas / _types_ | cursor stream open, ack, credit, close and event wire frames |
31301
+ | `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 |