stitchkit 0.132.3 → 0.133.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 (335) hide show
  1. package/CHANGELOG.md +172 -1
  2. package/dist/agent-executor/acp/v1-connect.d.ts +12 -1
  3. package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -1
  4. package/dist/agent-executor/acp/v1-driver.d.ts +3 -1
  5. package/dist/agent-executor/acp/v1-driver.d.ts.map +1 -1
  6. package/dist/agent-executor/acp/v1-handlers.d.ts +9 -1
  7. package/dist/agent-executor/acp/v1-handlers.d.ts.map +1 -1
  8. package/dist/agent-executor/acp/v1-permission.d.ts +3 -2
  9. package/dist/agent-executor/acp/v1-permission.d.ts.map +1 -1
  10. package/dist/agent-executor/acp/v1-probe.d.ts +10 -1
  11. package/dist/agent-executor/acp/v1-probe.d.ts.map +1 -1
  12. package/dist/agent-executor/acp/v1-session.d.ts +11 -2
  13. package/dist/agent-executor/acp/v1-session.d.ts.map +1 -1
  14. package/dist/agent-executor/acp/v1-turn.d.ts +13 -10
  15. package/dist/agent-executor/acp/v1-turn.d.ts.map +1 -1
  16. package/dist/agent-executor/claude/cli-driver.d.ts +6 -0
  17. package/dist/agent-executor/claude/cli-driver.d.ts.map +1 -1
  18. package/dist/agent-executor/claude/record-router.d.ts +44 -0
  19. package/dist/agent-executor/claude/record-router.d.ts.map +1 -0
  20. package/dist/agent-executor/claude/session.d.ts +2 -0
  21. package/dist/agent-executor/claude/session.d.ts.map +1 -1
  22. package/dist/agent-executor/claude-sdk/driver.d.ts +20 -2
  23. package/dist/agent-executor/claude-sdk/driver.d.ts.map +1 -1
  24. package/dist/agent-executor/claude-sdk/engine-spawn.d.ts +18 -0
  25. package/dist/agent-executor/claude-sdk/engine-spawn.d.ts.map +1 -0
  26. package/dist/agent-executor/claude-sdk/query-loop.d.ts +8 -11
  27. package/dist/agent-executor/claude-sdk/query-loop.d.ts.map +1 -1
  28. package/dist/agent-executor/claude-sdk/query-manager.d.ts +4 -2
  29. package/dist/agent-executor/claude-sdk/query-manager.d.ts.map +1 -1
  30. package/dist/agent-executor/claude-sdk/query-options.d.ts +1 -0
  31. package/dist/agent-executor/claude-sdk/query-options.d.ts.map +1 -1
  32. package/dist/agent-executor/claude-sdk/session.d.ts.map +1 -1
  33. package/dist/agent-executor/codex/capabilities.d.ts +8 -0
  34. package/dist/agent-executor/codex/capabilities.d.ts.map +1 -0
  35. package/dist/agent-executor/codex/connect.d.ts +6 -1
  36. package/dist/agent-executor/codex/connect.d.ts.map +1 -1
  37. package/dist/agent-executor/codex/driver.d.ts +10 -0
  38. package/dist/agent-executor/codex/driver.d.ts.map +1 -1
  39. package/dist/agent-executor/codex/event-routing.d.ts +23 -1
  40. package/dist/agent-executor/codex/event-routing.d.ts.map +1 -1
  41. package/dist/agent-executor/codex/handlers.d.ts +23 -3
  42. package/dist/agent-executor/codex/handlers.d.ts.map +1 -1
  43. package/dist/agent-executor/codex/limits.d.ts +17 -0
  44. package/dist/agent-executor/codex/limits.d.ts.map +1 -1
  45. package/dist/agent-executor/codex/request-answers.d.ts +23 -3
  46. package/dist/agent-executor/codex/request-answers.d.ts.map +1 -1
  47. package/dist/agent-executor/codex/session-bind.d.ts +6 -1
  48. package/dist/agent-executor/codex/session-bind.d.ts.map +1 -1
  49. package/dist/agent-executor/codex/session-types.d.ts +5 -1
  50. package/dist/agent-executor/codex/session-types.d.ts.map +1 -1
  51. package/dist/agent-executor/codex/session.d.ts.map +1 -1
  52. package/dist/agent-executor/codex/shared-server.d.ts.map +1 -1
  53. package/dist/agent-executor/codex/shared-thread.d.ts +6 -8
  54. package/dist/agent-executor/codex/shared-thread.d.ts.map +1 -1
  55. package/dist/agent-executor/codex/thread-open.d.ts +12 -3
  56. package/dist/agent-executor/codex/thread-open.d.ts.map +1 -1
  57. package/dist/agent-executor/engine-requests.d.ts +42 -0
  58. package/dist/agent-executor/engine-requests.d.ts.map +1 -1
  59. package/dist/agent-executor/handoff-schemas.d.ts.map +1 -1
  60. package/dist/agent-executor/handoff.d.ts.map +1 -1
  61. package/dist/agent-executor/image-input.d.ts +6 -5
  62. package/dist/agent-executor/image-input.d.ts.map +1 -1
  63. package/dist/agent-executor/profile.d.ts +3 -5
  64. package/dist/agent-executor/profile.d.ts.map +1 -1
  65. package/dist/agent-executor/session-primitives.d.ts +64 -3
  66. package/dist/agent-executor/session-primitives.d.ts.map +1 -1
  67. package/dist/agent-executor/testing/claude-sdk-stubs.d.ts +5 -0
  68. package/dist/agent-executor/testing/claude-sdk-stubs.d.ts.map +1 -0
  69. package/dist/agent-executor/testing/conformance-lifecycle.d.ts +11 -0
  70. package/dist/agent-executor/testing/conformance-lifecycle.d.ts.map +1 -0
  71. package/dist/agent-executor/testing/conformance-support.d.ts +23 -0
  72. package/dist/agent-executor/testing/conformance-support.d.ts.map +1 -0
  73. package/dist/agent-executor/testing/conformance.d.ts +7 -2
  74. package/dist/agent-executor/testing/conformance.d.ts.map +1 -1
  75. package/dist/agent-executor/testing/consumer-stubs.d.ts +5 -3
  76. package/dist/agent-executor/testing/consumer-stubs.d.ts.map +1 -1
  77. package/dist/agent-executor/testing/fake-codex-app-server.d.ts +5 -1
  78. package/dist/agent-executor/testing/fake-codex-app-server.d.ts.map +1 -1
  79. package/dist/agent-executor/testing/replay-driver.d.ts +6 -0
  80. package/dist/agent-executor/testing/replay-driver.d.ts.map +1 -1
  81. package/dist/agent-executor/testing/replay-gate.d.ts +4 -1
  82. package/dist/agent-executor/testing/replay-gate.d.ts.map +1 -1
  83. package/dist/agent-runtime/deferred-tool-types.d.ts +2 -0
  84. package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
  85. package/dist/agent-runtime/deferred-tools.d.ts.map +1 -1
  86. package/dist/browser/client.d.ts.map +1 -1
  87. package/dist/browser/operation-refusal.d.ts +10 -0
  88. package/dist/browser/operation-refusal.d.ts.map +1 -0
  89. package/dist/contract/client-types.d.ts +13 -4
  90. package/dist/contract/client-types.d.ts.map +1 -1
  91. package/dist/contract/define-validation.d.ts +6 -0
  92. package/dist/contract/define-validation.d.ts.map +1 -1
  93. package/dist/contract/define.d.ts +3 -0
  94. package/dist/contract/define.d.ts.map +1 -1
  95. package/dist/contract/errors-factory.d.ts +8 -2
  96. package/dist/contract/errors-factory.d.ts.map +1 -1
  97. package/dist/contract/errors.d.ts +9 -0
  98. package/dist/contract/errors.d.ts.map +1 -1
  99. package/dist/contract/fingerprint.d.ts +4 -1
  100. package/dist/contract/fingerprint.d.ts.map +1 -1
  101. package/dist/contract/operation-refusals.d.ts +51 -0
  102. package/dist/contract/operation-refusals.d.ts.map +1 -0
  103. package/dist/contract/tool-options.d.ts +4 -0
  104. package/dist/contract/tool-options.d.ts.map +1 -1
  105. package/dist/entrypoints/agent-executor/acp.js +253 -210
  106. package/dist/entrypoints/agent-executor/claude-sdk.js +248 -173
  107. package/dist/entrypoints/agent-executor/claude.js +57 -109
  108. package/dist/entrypoints/agent-executor/codex.js +412 -335
  109. package/dist/entrypoints/agent-executor/testing/claude-sdk.d.ts +3 -0
  110. package/dist/entrypoints/agent-executor/testing/claude-sdk.d.ts.map +1 -0
  111. package/dist/entrypoints/agent-executor/testing/claude-sdk.js +329 -0
  112. package/dist/entrypoints/agent-executor/testing.d.ts +1 -2
  113. package/dist/entrypoints/agent-executor/testing.d.ts.map +1 -1
  114. package/dist/entrypoints/agent-executor/testing.js +413 -667
  115. package/dist/entrypoints/agent-executor.d.ts +1 -1
  116. package/dist/entrypoints/agent-executor.d.ts.map +1 -1
  117. package/dist/entrypoints/agent-executor.js +12 -12
  118. package/dist/entrypoints/agent-runtime/browser.js +2 -2
  119. package/dist/entrypoints/agent-runtime/coding-tools.js +3 -3
  120. package/dist/entrypoints/agent-runtime/harness.js +8 -8
  121. package/dist/entrypoints/agent-runtime/postgres.js +5 -5
  122. package/dist/entrypoints/agent-runtime/realtime.js +2 -2
  123. package/dist/entrypoints/agent-runtime/sandbox.js +3 -3
  124. package/dist/entrypoints/agent-runtime/sqlite/bun.js +6 -6
  125. package/dist/entrypoints/agent-runtime/sqlite/node.js +6 -6
  126. package/dist/entrypoints/agent-runtime/testing.js +5 -5
  127. package/dist/entrypoints/agent-runtime.js +26 -18
  128. package/dist/entrypoints/application/grammy.js +1 -1
  129. package/dist/entrypoints/application.js +2 -2
  130. package/dist/entrypoints/cli.js +8 -8
  131. package/dist/entrypoints/contract.d.ts +3 -2
  132. package/dist/entrypoints/contract.d.ts.map +1 -1
  133. package/dist/entrypoints/contract.js +6 -4
  134. package/dist/entrypoints/files/packaging.d.ts +4 -1
  135. package/dist/entrypoints/files/packaging.d.ts.map +1 -1
  136. package/dist/entrypoints/files/packaging.js +868 -167
  137. package/dist/entrypoints/files.js +1 -1
  138. package/dist/entrypoints/handler.js +7 -7
  139. package/dist/entrypoints/http.js +2 -2
  140. package/dist/entrypoints/index.js +10 -8
  141. package/dist/entrypoints/node.js +11 -11
  142. package/dist/entrypoints/observability.js +1 -1
  143. package/dist/entrypoints/process/bootstrap.d.ts +3 -0
  144. package/dist/entrypoints/process/bootstrap.d.ts.map +1 -0
  145. package/dist/entrypoints/process/bootstrap.js +16 -0
  146. package/dist/entrypoints/process.js +7 -7
  147. package/dist/entrypoints/realtime.js +3 -3
  148. package/dist/entrypoints/remote.js +8 -7
  149. package/dist/entrypoints/server.js +30 -14
  150. package/dist/entrypoints/service-host/macos.js +72 -206
  151. package/dist/entrypoints/service-host/work.d.ts +15 -0
  152. package/dist/entrypoints/service-host/work.d.ts.map +1 -0
  153. package/dist/entrypoints/service-host/work.js +676 -0
  154. package/dist/entrypoints/service-host.js +146 -536
  155. package/dist/entrypoints/telegram/screens.js +4 -4
  156. package/dist/entrypoints/telegram.js +4 -4
  157. package/dist/entrypoints/testing.d.ts +2 -1
  158. package/dist/entrypoints/testing.d.ts.map +1 -1
  159. package/dist/entrypoints/testing.js +27 -8
  160. package/dist/entrypoints/tools/agent.js +6 -6
  161. package/dist/entrypoints/tools/connections.js +2 -2
  162. package/dist/entrypoints/tools/invoker.js +5 -5
  163. package/dist/entrypoints/tools/mcp.js +8 -6
  164. package/dist/entrypoints/tools/toolkit.js +11 -9
  165. package/dist/entrypoints/tools.js +19 -17
  166. package/dist/entrypoints/tracking/contract.js +1 -1
  167. package/dist/entrypoints/tracking/performance.js +3 -3
  168. package/dist/files/client-artifact.d.ts +14 -42
  169. package/dist/files/client-artifact.d.ts.map +1 -1
  170. package/dist/files/client-build.d.ts +57 -0
  171. package/dist/files/client-build.d.ts.map +1 -0
  172. package/dist/files/client-declarations.d.ts +35 -0
  173. package/dist/files/client-declarations.d.ts.map +1 -0
  174. package/dist/files/client-package-contract.d.ts +162 -0
  175. package/dist/files/client-package-contract.d.ts.map +1 -0
  176. package/dist/files/client-package-proof.d.ts +38 -0
  177. package/dist/files/client-package-proof.d.ts.map +1 -0
  178. package/dist/files/client-package.d.ts +17 -0
  179. package/dist/files/client-package.d.ts.map +1 -0
  180. package/dist/files/declaration-specifiers.d.ts +30 -0
  181. package/dist/files/declaration-specifiers.d.ts.map +1 -0
  182. package/dist/{index-v759mzed.js → index-02r5sq9p.js} +36 -23
  183. package/dist/{index-0r15pkjq.js → index-0k1ba0ss.js} +1 -1
  184. package/dist/{index-znd1b57f.js → index-1dn2wjq6.js} +5 -4
  185. package/dist/{index-p06z7g7w.js → index-1p8q0yrt.js} +6 -5
  186. package/dist/{index-wa6h4tz6.js → index-1qwd54n3.js} +6 -5
  187. package/dist/index-2dzc7mv9.js +174 -0
  188. package/dist/index-2mz8hj58.js +155 -0
  189. package/dist/{index-17qgm6xe.js → index-34k82crg.js} +2 -2
  190. package/dist/index-3mcbr8sx.js +349 -0
  191. package/dist/{index-ybdq8kk2.js → index-3y2tzhr8.js} +3 -3
  192. package/dist/{index-fgahdc7s.js → index-5n3a8hd8.js} +5 -3
  193. package/dist/{index-jb4m241t.js → index-6918kxbf.js} +45 -1
  194. package/dist/{index-n3bm7zqq.js → index-6kmjcm81.js} +4 -4
  195. package/dist/{index-akf0xkrm.js → index-78da4g74.js} +1 -1
  196. package/dist/{index-9pv126eh.js → index-7fjbdga8.js} +7 -1
  197. package/dist/{index-zhshhxew.js → index-8jf4bt7v.js} +1 -1
  198. package/dist/{index-p16q492v.js → index-8t9dr41h.js} +18 -5
  199. package/dist/{index-xq4s9mka.js → index-8yt3rwe7.js} +1 -1
  200. package/dist/{index-39c2hj6h.js → index-9c76vfxf.js} +7 -3
  201. package/dist/index-9ft4n9j1.js +432 -0
  202. package/dist/{index-sd4e5x5j.js → index-9wdrwx3b.js} +8 -7
  203. package/dist/{index-z114ax5e.js → index-an7vcmwf.js} +49 -2
  204. package/dist/{index-pzhqydxb.js → index-d04w81fz.js} +1 -1
  205. package/dist/index-d2drhb9c.js +219 -0
  206. package/dist/{index-8gmmdz7k.js → index-dacxr7nf.js} +1 -1
  207. package/dist/{index-dnzxxf8a.js → index-dm6nxkn1.js} +1 -1
  208. package/dist/index-dxft2mnm.js +42 -0
  209. package/dist/{index-rxh3qy4x.js → index-fzd477xk.js} +1 -1
  210. package/dist/{index-xgae0bn7.js → index-g4gstmp1.js} +2 -2
  211. package/dist/{index-athc412x.js → index-g5fgeb6v.js} +1 -1
  212. package/dist/{index-z9d74jmb.js → index-gbhj370g.js} +3 -3
  213. package/dist/{index-3fym4j8n.js → index-gtaaxe9d.js} +1 -1
  214. package/dist/{index-v59pxmf1.js → index-jpecjm30.js} +2 -2
  215. package/dist/index-k9g061ma.js +164 -0
  216. package/dist/{index-669374qc.js → index-ma26mfnt.js} +84 -315
  217. package/dist/{index-ryxb427v.js → index-msxf2r8x.js} +16 -3
  218. package/dist/{index-rbd2rq3z.js → index-nr4fhfn4.js} +1 -1
  219. package/dist/{index-qa2jjb65.js → index-pbekeqzm.js} +1 -1
  220. package/dist/{index-mkfhpk11.js → index-pq6g1k9t.js} +2 -2
  221. package/dist/{index-gya4hwh3.js → index-pws5c3x6.js} +21 -1
  222. package/dist/{index-x2fb37t0.js → index-q427q23r.js} +3 -2
  223. package/dist/{index-jcrj0b8z.js → index-qggqqja2.js} +39 -2
  224. package/dist/{index-jxtg307y.js → index-rkjfzs0a.js} +1 -1
  225. package/dist/{index-5tdc0q43.js → index-rw8ze745.js} +5 -3
  226. package/dist/index-s43tr4my.js +129 -0
  227. package/dist/{index-f9p62ean.js → index-stpy56r3.js} +175 -249
  228. package/dist/index-t5g5rm9n.js +213 -0
  229. package/dist/{index-z20pdxeb.js → index-tmv3ez1h.js} +3 -3
  230. package/dist/{index-dcsxj68j.js → index-tqjamnax.js} +1 -1
  231. package/dist/{index-j15dhkda.js → index-wddcfbng.js} +1 -325
  232. package/dist/{index-9sfhje6y.js → index-wh70tmpd.js} +24 -234
  233. package/dist/index-wxjv4sqx.js +82 -0
  234. package/dist/{index-qhjmmsm2.js → index-x46y9z26.js} +2 -2
  235. package/dist/{index-nk0cy9g1.js → index-y53cqwke.js} +1 -1
  236. package/dist/{index-sv5svtq7.js → index-y68gavb5.js} +1 -1
  237. package/dist/{index-5y7j383h.js → index-yrhw10ef.js} +1 -1
  238. package/dist/process/bootstrap.d.ts +12 -0
  239. package/dist/process/bootstrap.d.ts.map +1 -0
  240. package/dist/process/owner-loss-guard.d.ts +2 -9
  241. package/dist/process/owner-loss-guard.d.ts.map +1 -1
  242. package/dist/process/work-root.d.ts +20 -0
  243. package/dist/process/work-root.d.ts.map +1 -0
  244. package/dist/server/contract-identity.d.ts.map +1 -1
  245. package/dist/server/contract-method.d.ts +12 -0
  246. package/dist/server/contract-method.d.ts.map +1 -1
  247. package/dist/server/implement.d.ts.map +1 -1
  248. package/dist/server/openapi.d.ts.map +1 -1
  249. package/dist/server/types.d.ts +10 -9
  250. package/dist/server/types.d.ts.map +1 -1
  251. package/dist/service-host/host-adapter.d.ts +2 -0
  252. package/dist/service-host/host-adapter.d.ts.map +1 -1
  253. package/dist/service-host/work/command.d.ts +72 -0
  254. package/dist/service-host/work/command.d.ts.map +1 -0
  255. package/dist/service-host/work/errors.d.ts +29 -0
  256. package/dist/service-host/work/errors.d.ts.map +1 -0
  257. package/dist/service-host/work/host.d.ts +38 -0
  258. package/dist/service-host/work/host.d.ts.map +1 -0
  259. package/dist/service-host/work/launch.d.ts +51 -0
  260. package/dist/service-host/work/launch.d.ts.map +1 -0
  261. package/dist/service-host/work/membership.d.ts +51 -0
  262. package/dist/service-host/work/membership.d.ts.map +1 -0
  263. package/dist/service-host/work/origin.d.ts +79 -0
  264. package/dist/service-host/work/origin.d.ts.map +1 -0
  265. package/dist/service-host/work/owner.d.ts +45 -0
  266. package/dist/service-host/work/owner.d.ts.map +1 -0
  267. package/dist/service-host/work/placement.d.ts +55 -0
  268. package/dist/service-host/work/placement.d.ts.map +1 -0
  269. package/dist/service-host/work/probe.d.ts +24 -0
  270. package/dist/service-host/work/probe.d.ts.map +1 -0
  271. package/dist/service-host/work/scope-command.d.ts +68 -0
  272. package/dist/service-host/work/scope-command.d.ts.map +1 -0
  273. package/dist/sync/session.d.ts +4 -1
  274. package/dist/sync/session.d.ts.map +1 -1
  275. package/dist/testing/surface-manifest-digest.d.ts +2 -0
  276. package/dist/testing/surface-manifest-digest.d.ts.map +1 -1
  277. package/dist/testing/surface-manifest.d.ts +32 -3
  278. package/dist/testing/surface-manifest.d.ts.map +1 -1
  279. package/dist/tools/agent.d.ts +2 -0
  280. package/dist/tools/agent.d.ts.map +1 -1
  281. package/dist/tools/cli/stream-surface.d.ts.map +1 -1
  282. package/dist/tools/internal/mcp-projection.d.ts +58 -0
  283. package/dist/tools/internal/mcp-projection.d.ts.map +1 -0
  284. package/dist/tools/internal/surface-projector.d.ts +3 -47
  285. package/dist/tools/internal/surface-projector.d.ts.map +1 -1
  286. package/dist/tools/invoker.d.ts +2 -0
  287. package/dist/tools/invoker.d.ts.map +1 -1
  288. package/dist/tools/manifest.d.ts +2 -0
  289. package/dist/tools/manifest.d.ts.map +1 -1
  290. package/dist/tools/mcp/handler.d.ts.map +1 -1
  291. package/dist/tools/mcp/lazy-discovery.d.ts.map +1 -1
  292. package/dist/tools/mcp/mount.d.ts +4 -0
  293. package/dist/tools/mcp/mount.d.ts.map +1 -1
  294. package/dist/tools/mcp/prepare.d.ts +5 -2
  295. package/dist/tools/mcp/prepare.d.ts.map +1 -1
  296. package/dist/tools/mount.d.ts +2 -0
  297. package/dist/tools/mount.d.ts.map +1 -1
  298. package/dist/tools/remote.d.ts.map +1 -1
  299. package/dist/tools/schema/nesting-limit.d.ts +8 -0
  300. package/dist/tools/schema/nesting-limit.d.ts.map +1 -0
  301. package/dist/tools/schema/presentation.d.ts +7 -0
  302. package/dist/tools/schema/presentation.d.ts.map +1 -1
  303. package/dist/tools/surface.d.ts.map +1 -1
  304. package/llms/agent-executor-acp.txt +3 -3
  305. package/llms/agent-executor-claude-sdk.txt +1 -1
  306. package/llms/agent-executor-claude.txt +1 -1
  307. package/llms/agent-executor-codex.txt +1 -1
  308. package/llms/agent-executor-testing-claude-sdk.txt +28 -0
  309. package/llms/agent-executor-testing.txt +7 -8
  310. package/llms/agent-executor.txt +27 -4
  311. package/llms/agent-runtime.txt +1 -1
  312. package/llms/contract.txt +8 -2
  313. package/llms/files-packaging.txt +11 -6
  314. package/llms/process-bootstrap.txt +18 -0
  315. package/llms/process.2.txt +215 -18
  316. package/llms/process.txt +130 -92
  317. package/llms/server.4.txt +49 -1
  318. package/llms/service-host-work.txt +34 -0
  319. package/llms/stitchkit.2.txt +31 -0
  320. package/llms/stitchkit.txt +78 -75
  321. package/llms/sync.txt +5 -2
  322. package/llms/testing.txt +1 -0
  323. package/llms/tools.2.txt +747 -775
  324. package/llms/tools.3.txt +846 -210
  325. package/llms/tools.4.txt +226 -0
  326. package/llms/tools.txt +3 -790
  327. package/llms/{upgrading-0.128.0-0.132.0.txt → upgrading-0.128.0-0.133.0.txt} +194 -6
  328. package/llms/upgrading.txt +1 -1
  329. package/llms-full.txt +746 -135
  330. package/llms.txt +18 -16
  331. package/package.json +12 -4
  332. package/dist/entrypoints/process/owner-loss.d.ts +0 -3
  333. package/dist/entrypoints/process/owner-loss.d.ts.map +0 -1
  334. package/dist/entrypoints/process/owner-loss.js +0 -7
  335. package/llms/process-owner-loss.txt +0 -18
package/llms-full.txt CHANGED
@@ -47,81 +47,83 @@ 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 39 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 39 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 39 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 39 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 39 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 39 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 6 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 39 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 39 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 39 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 39 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 39 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 39 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 39 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 39 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 39 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 39 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 39 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 39 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 3 of the 39 minors since 0.94.0, most recently 0.127.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/owner-loss` | bundled server entry (Bun, POSIX) | evolving<br>_redefined in 0 of the 39 minors since 0.94.0_ | narrow bootstrap that keeps the process runner lazy while carrying its owner-loss guard in a single-file bundle |
71
- | `stitchkit/files/packaging` | build time (Bun or Node) | evolving<br>_redefined in 3 of the 39 minors since 0.94.0, most recently 0.108.0_ | installed native asset graph, integrity, Bun packaging plugin and the artifact loader check; a client bundled into one self-contained, hashed and verified file; no runtime install policy |
72
- | `stitchkit/files` | server (Bun or Node) | stable<br>_redefined in 4 of the 39 minors since 0.94.0, most recently 0.127.0_ | peer-free managed local-file boundary |
73
- | `stitchkit/spend` | server (Bun or Node) | evolving<br>_redefined in 0 of the 6 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 6 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 6 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 6 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/telegram` | server (Bun or Node) | evolving<br>_redefined in 8 of the 39 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 |
78
- | `stitchkit/telegram/grammy` | server (Bun or Node) | evolving<br>_redefined in 0 of the 39 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 |
79
- | `stitchkit/telegram/html` | browser and server | evolving<br>_redefined in 1 of the 39 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 |
80
- | `stitchkit/telegram/voice` | browser and server | evolving<br>_redefined in 0 of the 39 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 |
81
- | `stitchkit/telegram/screens` | server (Bun or Node) | evolving<br>_redefined in 1 of the 39 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 |
82
- | `stitchkit/tracking` | browser **and** server | evolving<br>_redefined in 3 of the 39 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 |
83
- | `stitchkit/tracking/contract` | browser **and** server | evolving<br>_redefined in 0 of the 39 minors since 0.94.0_ | the wire shapes — the contract factory, event and visit schemas, the performance sample and its trust threshold; brings `zod` |
84
- | `stitchkit/tracking/performance` | browser **and** server | evolving<br>_redefined in 1 of the 39 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` |
85
- | `stitchkit/tracking/server` | server (Bun or Node) | evolving<br>_redefined in 0 of the 39 minors since 0.94.0_ | the decisions a tracking backend makes — dispositions, visit lease over an application-owned store, active intervals, presence; no database |
86
- | `stitchkit/release` | browser **and** server | evolving<br>_redefined in 1 of the 39 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 |
87
- | `stitchkit/voice` | browser **and** server | evolving<br>_redefined in 0 of the 39 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 |
88
- | `stitchkit/sync` | browser **and** server | evolving<br>_redefined in 1 of the 6 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 |
89
- | `stitchkit/sync/postgres` | server (Bun or Node) | evolving<br>_redefined in 0 of the 6 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` |
90
- | `stitchkit/geo` | server (Bun or Node) | evolving<br>_redefined in 2 of the 39 minors since 0.94.0, most recently 0.127.0_ | managed GeoIP reader generations, last-known-good reload and the optional MaxMind adapter |
91
- | `stitchkit/geo/contract` | browser **and** server | evolving<br>_redefined in 0 of the 39 minors since 0.94.0_ | the place snapshot schema, for a shared contract that stores or sends `GeoAttribution`; brings `zod` |
92
- | `stitchkit/xlsx` | browser **and** server | evolving<br>_redefined in 0 of the 39 minors since 0.94.0_ | a workbook from rows and typed columns, with no dependency; text never runs as a formula |
93
- | `stitchkit/oauth` | browser **and** server | evolving<br>_redefined in 0 of the 39 minors since 0.94.0_ | provider-neutral Authorization Code + PKCE request and one-shot callback transaction mechanics |
94
- | `stitchkit/google` | server (Bun or Node) | evolving<br>_redefined in 1 of the 39 minors since 0.94.0, most recently 0.127.0_ | optional Google code exchange and verified OIDC identity adapter |
95
- | `stitchkit/observability` | server | stable<br>_redefined in 1 of the 39 minors since 0.94.0, most recently 0.127.0_ | request/tool event projections — `createObservability`, trace context, sanitisation |
96
- | `stitchkit/testing` | tests on Bun or Node | stable<br>_redefined in 3 of the 39 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 |
97
- | `stitchkit/declaration` | browser + build and deployment tooling (Bun or Node) | evolving<br>_redefined in 1 of the 39 minors since 0.94.0, most recently 0.128.0_ | `ProjectDeclarationSchema` — the one machine-readable statement a repository makes about itself |
98
- | `stitchkit/react` | browser + server rendering | stable<br>_redefined in 2 of the 39 minors since 0.94.0, most recently 0.127.0_ | `createCursorQuery`, `createCacheBridge`, QueryClient and `ApiError` retry policy |
99
- | `stitchkit/react/keyboard` | browser | evolving<br>_redefined in 1 of the 39 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) |
100
- | `stitchkit/react/keyboard/testing` | server (Bun or Node) | evolving<br>_redefined in 0 of the 39 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 |
101
- | `stitchkit/agent-runtime` | server | evolving<br>_redefined in 9 of the 39 minors since 0.94.0, most recently 0.128.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
102
- | `stitchkit/agent-runtime/sandbox` | server | evolving<br>_redefined in 0 of the 39 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) |
103
- | `stitchkit/agent-runtime/testing` | tests on Bun or Node | evolving<br>_redefined in 2 of the 39 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 |
104
- | `stitchkit/agent-runtime/harness` | server | evolving<br>_redefined in 0 of the 39 minors since 0.94.0_ | resource-aware process-local facade over the canonical Agent runtime; supervision stays outside |
105
- | `stitchkit/agent-runtime/coding-tools` | server (Bun or Node) | evolving<br>_redefined in 3 of the 39 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 |
106
- | `stitchkit/agent-runtime/openrouter` | server | evolving<br>_redefined in 1 of the 39 minors since 0.94.0, most recently 0.127.0_ | isolated OpenRouter language-model adapter |
107
- | `stitchkit/agent-runtime/browser` | browser + server | evolving<br>_redefined in 2 of the 39 minors since 0.94.0, most recently 0.127.0_ | canonical agent records, events, reconnect cursor and optional conversation controller |
108
- | `stitchkit/agent-runtime/react` | browser + server | evolving<br>_redefined in 0 of the 39 minors since 0.94.0_ | React subscription to an application-owned agent controller |
109
- | `stitchkit/agent-runtime/realtime` | server (Bun or Node) | evolving<br>_redefined in 2 of the 39 minors since 0.94.0, most recently 0.127.0_ | authorized agent control over the existing Socket.IO server |
110
- | `stitchkit/agent-executor` | server (Bun or Node) | evolving<br>_redefined in 3 of the 6 minors since 0.127.0, most recently 0.131.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 |
111
- | `stitchkit/agent-executor/claude` | server (Bun or Node) | evolving<br>_redefined in 0 of the 6 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 |
112
- | `stitchkit/agent-executor/claude-sdk` | server (Bun or Node) | evolving<br>_redefined in 1 of the 6 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 |
113
- | `stitchkit/agent-executor/acp` | server (Bun or Node) | evolving<br>_redefined in 0 of the 6 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 |
114
- | `stitchkit/agent-executor/codex` | server (Bun or Node) | evolving<br>_redefined in 2 of the 6 minors since 0.127.0, most recently 0.131.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` |
115
- | `stitchkit/agent-executor/testing` | server (Bun or Node) | evolving<br>_redefined in 0 of the 6 minors since 0.127.0_ | the engine conformance kit, deterministic replay driver, portable fake Codex app-server, multi-turn fake Claude SDK query harness, fail-loud consumer stub factories, and schema-validated test fixtures |
116
- | `stitchkit/agent-runtime/postgres` | server (Bun or Node) | evolving<br>_redefined in 0 of the 6 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`) |
117
- | `stitchkit/agent-runtime/sqlite/bun` | server (Bun) | evolving<br>_redefined in 1 of the 39 minors since 0.94.0, most recently 0.127.0_ | durable built-in SQLite store for the agent runtime |
118
- | `stitchkit/agent-runtime/sqlite/node` | server (Node ≥ 22.5) | evolving<br>_redefined in 1 of the 39 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 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 |
119
121
  | `stitchkit-tui` | terminal (Bun) | evolving | optional official OpenTUI host over a caller-composed headless runtime |
120
- | `stitchkit/application` | browser + server | evolving<br>_redefined in 9 of the 39 minors since 0.94.0, most recently 0.127.0_ | managed resource graph, readiness, admission, schedules, subtree restart and bounded shutdown |
121
- | `stitchkit/application/grammy` | server | evolving<br>_redefined in 0 of the 39 minors since 0.94.0_ | a grammY bot as application resources — configuration, then polling with updates admitted by batch — and the webhook adapter |
122
- | `stitchkit/application/opentelemetry` | server | evolving<br>_redefined in 0 of the 39 minors since 0.94.0_ | maps application snapshots onto an injected OpenTelemetry `Meter` |
123
- | `stitchkit/application/diagnostic-journal` | server | evolving<br>_redefined in 3 of the 39 minors since 0.94.0, most recently 0.127.0_ | the local diagnostic journal — an exclusive bounded writer and snapshot reader with explicit anomalies |
124
- | `stitchkit/application/directory-inbox` | server | evolving<br>_redefined in 0 of the 39 minors since 0.94.0_ | the directory inbox — entries another program drops into a directory, delivered to the application at least once |
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 |
125
127
 
126
128
  Rule of thumb: browser code imports `stitchkit` and `stitchkit/react`; server
127
129
  code adds `stitchkit/server` (or `stitchkit/node` on Node) and opts into
@@ -230,7 +232,8 @@ map — feature → packages:
230
232
  | Postgres agent store (`stitchkit/agent-runtime/postgres`) | — (the application's own Postgres client) |
231
233
  | SQLite agent store (`stitchkit/agent-runtime/sqlite/bun` or `/node`) | — (runtime built-in) |
232
234
  | Agent executor — Claude Agent SDK leaf (`stitchkit/agent-executor/claude-sdk`) | `@anthropic-ai/claude-agent-sdk` |
233
- | Agent executor — consumer testing kit (`stitchkit/agent-executor/testing`) | `@anthropic-ai/claude-agent-sdk` (types only; runtime peer-free) |
235
+ | Agent executor — consumer testing kit (`stitchkit/agent-executor/testing`) | — |
236
+ | Agent executor — Claude SDK testing kit (`stitchkit/agent-executor/testing/claude-sdk`) | `@anthropic-ai/claude-agent-sdk` (types only; runtime peer-free) |
234
237
  | MCP host/client tests | `@modelcontextprotocol/client` |
235
238
  | MCP Apps UI widgets | `@modelcontextprotocol/ext-apps` |
236
239
  | React data layer (`stitchkit/react`) | `@tanstack/react-query` `react-query-kit` |
@@ -3834,6 +3837,37 @@ seventh constructor argument remains `ErrorOptions`, including `cause`; the opti
3834
3837
  retryability argument is eighth. Closed error/frame schemas must accept the new optional
3835
3838
  field before their producer declares it.
3836
3839
 
3840
+ ### Read a refusal the operation declared
3841
+
3842
+ When an endpoint declares `refuses` ([Auth & errors](./auth-and-errors.md#the-codes-an-operation-refuses-with)),
3843
+ every client method carries `refusal(error)`. It returns the rejection as one of
3844
+ that operation's refusals — `code` narrowed to the declared codes plus the
3845
+ framework codes (`STITCH_ERROR_STATUS`) and the client's own (`CLIENT_ERROR_CODES`),
3846
+ `details` typed by the declared code's schema — or `undefined` for anything else:
3847
+
3848
+ ```ts
3849
+ try {
3850
+ await api.sleep({ id })
3851
+ } catch (error) {
3852
+ const refusal = api.sleep.refusal(error)
3853
+ switch (refusal?.code) {
3854
+ case 'NOT_IDLE':
3855
+ return showBusy()
3856
+ case 'MIN_AWAKE':
3857
+ return showMinimum(refusal.details.minimum) // number, from the schema
3858
+ case 'REQUEST_TIMEOUT':
3859
+ return retryLater()
3860
+ }
3861
+ throw error
3862
+ }
3863
+ ```
3864
+
3865
+ `undefined` covers an error that is no `ApiError`, a code the operation did not
3866
+ declare (a newer server, another vocabulary) and details its schema refuses — the
3867
+ client never hands back a type the value does not have. Comparing with a code the
3868
+ operation did not declare does not type-check. An endpoint without `refuses` still
3869
+ reads the framework and client codes.
3870
+
3837
3871
  ## Which contract does the server speak
3838
3872
 
3839
3873
  A client is built from one version of a contract and a server from another
@@ -4601,6 +4635,7 @@ await mcp.close()
4601
4635
  | `coerceJsonArgs` | coerce JSON-stringified object/array arguments (default `true`) |
4602
4636
  | `flattenUnionInput` | advertise discriminated unions as one object (default `false`) |
4603
4637
  | `inputRecursionDepth` | advertise inputs with no `$ref`, recursion unrolled this many levels (default: references stay) |
4638
+ | `inputNestingDepth` | keep every advertised input within this many nesting levels, as a provider counts them (default: no limit) |
4604
4639
  | `errorHint` | add a project-owned hint to failed tool results |
4605
4640
  | `onOutputStrip` | observe output keys removed by contract validation |
4606
4641
  | `protectedResource` | RFC 9728 metadata used by HTTP `401` responses |
@@ -5142,8 +5177,8 @@ createStdioMcpServer({
5142
5177
  ```
5143
5178
 
5144
5179
  - **Opt-in only.** Omitting `discovery` keeps the default full `tools/list` surface untouched. In `'lazy'` mode `initialTools` is required (pass `[]` to hide every contract tool initially).
5145
- - **Session-isolated reveal.** Every contract tool outside `initialTools` starts disabled on that `McpServer` instance. Calling `tool_search` ranks hidden tools by name and description (exact/phrase matches first, then deduplicated word matches), enables up to `maxResults` matches on that session's `McpServer`, and emits a single `notifications/tools/list_changed` when at least one new tool is revealed. Enabling tools in one session never mutates another session or the shared prepared surface.
5146
- - **Identical access & catalog stamp.** `tool_search` and every revealed tool enforce the exact same `access` policy (`gate` / `inspect` / `open`), hooks, and `stitchkit/catalog` `_meta` stamp (which fingerprints the full underlying contract and runtime tool catalog, excluding synthetic `tool_search`). Unknown names in `initialTools`, `searchToolName` collisions with real tools, and out-of-range `maxResults` throw synchronously at mount time.
5180
+ - **Session-isolated reveal.** Every contract tool outside `initialTools` starts disabled on that `McpServer` instance. Calling `tool_search` ranks the still-hidden tools by name and description (exact/phrase matches first, then deduplicated word matches), enables up to `maxResults` of them on that session's `McpServer` — tools already enabled never take a slot, so repeating a search reaches the matches past the first `maxResults`; they are listed after the new ones with `newlyEnabled: false` — and emits a single `notifications/tools/list_changed` when at least one new tool is revealed. Enabling tools in one session never mutates another session or the shared prepared surface.
5181
+ - **Identical access, no catalog stamp.** `tool_search` and every revealed tool enforce the exact same `access` policy (`gate` / `inspect` / `open`) and hooks. A surface with discovery sends no `stitchkit/catalog` stamp: each session lists its own subset, which no digest of the whole surface describes, so a connection's catalog store lists afresh instead of keeping one session's view. Unknown names in `initialTools`, `searchToolName` collisions with real tools, and out-of-range `maxResults` throw synchronously at mount time.
5147
5182
  - **Stateful mounts only.** `createMcpHandler` creates a fresh stateless `McpServer` per HTTP request and therefore refuses `discovery` synchronously with `TypeError`; use `discovery` on stateful mounts (`createStdioMcpServer`, `buildMcpServer`, `mountMcp`).
5148
5183
 
5149
5184
  ### MCP schema validation profile
@@ -5316,6 +5351,34 @@ The depth is a number, not a size: a provider may limit nesting from above, and
5316
5351
  model forced to call the tool may need more levels from below. Measure the cost
5317
5352
  with `describeToolCatalog({ …, maxSchemaBytes })`. → [ADR 0319](../decisions/0319-a-tool-input-can-be-advertised-without-references.md).
5318
5353
 
5354
+ ### A provider's nesting limit — `inputNestingDepth`
5355
+
5356
+ Some providers refuse the whole tool set when one input document is nested deeper than a fixed
5357
+ number of levels. `inputNestingDepth` keeps every advertised input within such a limit, counting
5358
+ as such a provider counts: a level per step `properties → property` or `items`; `anyOf`, `oneOf`,
5359
+ `allOf` and `additionalProperties` cost nothing; a property named `items` or `properties` costs two.
5360
+
5361
+ ```ts
5362
+ const projection = { flattenUnionInput: true, inputRecursionDepth: 1, inputNestingDepth: 10 } as const
5363
+ mountAgent(services, { access, runtimeTools, ...projection })
5364
+
5365
+ // one tool may say its own, as with inputRecursionDepth
5366
+ put: { method: 'POST', path: '/put', input, tool: { name: 'lesson_put', inputNestingDepth: 10 } }
5367
+ ```
5368
+
5369
+ - A document at or under the limit is unchanged. Deeper, the node whose next step would cross the
5370
+ limit becomes an open node `{}` (its `description` kept), as deep as the limit allows: the rest
5371
+ of the structure stays visible to the model.
5372
+ - The open node accepts every value — the document widens, it never narrows — and the handler still
5373
+ parses the contract's own schema. An array whose `items` would cross the limit is opened itself,
5374
+ so no array is left without `items`.
5375
+ - The limit applies last, to the document as it is advertised: after `inputRecursionDepth` writes
5376
+ references out (so it also bounds the unrolled recursion), `flattenUnionInput` and tool defaults.
5377
+ With references kept, a `$ref` counts as a leaf.
5378
+ - `schemaValidation.requireTypedProperties` accepts the open nodes: the limit declared them.
5379
+ - `tool.inputNestingDepth` wins over the surface's value, as `tool.inputRecursionDepth` does; runtime
5380
+ tools and the deferred tool surface take the surface's value.
5381
+
5319
5382
  ## `mountMcp`
5320
5383
 
5321
5384
  If you already run an `McpServer` from the SDK, `mountMcp` adds contract tools
@@ -6455,7 +6518,7 @@ the field is ignored and the query is ranked as usual.
6455
6518
 
6456
6519
  Every ceiling is required. `maxSchemaBytes` measures UTF-8 bytes over canonical
6457
6520
  name, description and presentation schema. The options that shape how inputs are
6458
- advertised — `extend`, `flattenUnionInput`, `inputRecursionDepth` — are set on
6521
+ advertised — `extend`, `flattenUnionInput`, `inputRecursionDepth`, `inputNestingDepth` — are set on
6459
6522
  `createDeferredAgentToolSurface`, not on `mount`, so the manifest the selector
6460
6523
  ranks and the ceilings measure is the one the model receives; a `mount` that
6461
6524
  names one is refused. It is useful for before/after
@@ -10142,20 +10205,21 @@ exit status, deadlines, cancellation and `onLeaderSettled` retain the requested
10142
10205
 
10143
10206
  An unbundled application already launches the package's own guard module. A single-file bundle
10144
10207
  whose application entry also owns argv routing must load the narrow bootstrap before its dispatcher
10145
- and skip dispatch when it claims the private guard invocation. This is especially relevant when the
10208
+ and skip dispatch when it claims a private package invocation. This is especially relevant when the
10146
10209
  full command runner stays behind a dynamic import:
10147
10210
 
10148
10211
  ```ts
10149
- import { bootstrapNativeCommandOwnerLoss } from 'stitchkit/process/owner-loss'
10212
+ import { bootstrapPackageProcess } from 'stitchkit/process/bootstrap'
10150
10213
 
10151
- if (!bootstrapNativeCommandOwnerLoss()) {
10214
+ if (!bootstrapPackageProcess()) {
10152
10215
  await dispatch(process.argv.slice(2)) // may lazy-import `stitchkit/process`
10153
10216
  }
10154
10217
  ```
10155
10218
 
10156
- The bootstrap carries the package-owned guard into the bundle. It returns `false` for application
10157
- argv and `true` only for the private child started by `runNativeCommand`, so the application does
10158
- not read a guard flag or filename. The built file is self-contained; no installed `node_modules`
10219
+ The bootstrap carries the package-owned invocations into the bundle: the owner-loss guard, and the
10220
+ process root of [work launched in its own boundary](#work-in-its-own-boundary). It returns `false`
10221
+ for application argv and `true` only for a private invocation the package serves, so the
10222
+ application does not read a flag or filename. The built file is self-contained; no installed `node_modules`
10159
10223
  is needed beside it.
10160
10224
 
10161
10225
  ### Stopping a command: the `stop` policy
@@ -10250,6 +10314,129 @@ refused there and nothing is stopped after its leader exits. A command whose gro
10250
10314
  launcher supplied by a host) has no group to stop, and `descendants` has nothing to act on there.
10251
10315
 
10252
10316
 
10317
+ ## Work in its own boundary
10318
+
10319
+ A machine that runs many launchers ends up with one service holding a hundred processes and no
10320
+ answer to "who started this one". `stitchkit/service-host/work` launches a command in a boundary
10321
+ of its own and declares who owns it:
10322
+
10323
+ ```ts
10324
+ import { inheritedWork, launchWork } from 'stitchkit/service-host/work'
10325
+
10326
+ const launch = await launchWork({
10327
+ owner: {
10328
+ launcher: 'session-host', // your launcher's own name
10329
+ id: session.id, // unique among your live work on this machine
10330
+ label: session.title,
10331
+ project: session.project, // or null
10332
+ agent: session.agent, // { harness, model, address } or null
10333
+ parent: await inheritedWork(), // the work this process itself runs in, or null
10334
+ },
10335
+ placement: { kind: 'transient-scope', manager: 'system', slice: 'caller' },
10336
+ command: { executable, args, env, stdio: 'inherit', signal: shutdown.signal },
10337
+ })
10338
+
10339
+ launch.unit // { manager: 'system', name: 'session-host-<id>.scope' }
10340
+ launch.root // { pid, instance } — the process the work started as
10341
+ await launch.stop() // ends the whole boundary
10342
+ ```
10343
+
10344
+ The owner record is yours to keep and to serve to whoever asks; the package gives its schema
10345
+ (`WorkOwnerSchema`), the launch and the check. Every field of the record is answered: `project`,
10346
+ `agent` and `parent` take `null` as a declared "none", and a missing field is refused.
10347
+
10348
+ ### The variable names, the boundary proves
10349
+
10350
+ The launched command and everything it starts inherit one variable, `STITCHKIT_WORK_ORIGIN`: a
10351
+ small JSON value with the work's reference (`launcher`, `id`) and its boundary. A process that
10352
+ leaves the boundary keeps the variable, and anyone can set it, so it is only a claim.
10353
+ `checkWorkMembership({ pid, boundary })` asks the boundary itself:
10354
+
10355
+ | answer | meaning |
10356
+ |---|---|
10357
+ | `{ state: 'member', via }` | the process is in the boundary; `via` names the evidence (`cgroup`, `root`, `process-group`, `ancestry`) |
10358
+ | `{ state: 'outside', observed }` | it is not, with the control group or the group and parent chain that was seen instead |
10359
+ | `{ state: 'gone' }` | there is no such process |
10360
+ | `{ state: 'unavailable', reason, cause }` | the boundary could not be asked; never read this as `outside` |
10361
+
10362
+ `readWorkOrigin()` parses the variable of the current process (`null` when absent; a value that
10363
+ does not parse throws `WorkLaunchError` with reason `origin-unreadable`). `inheritedWork()` returns
10364
+ the reference only when the current process is proven to be inside the boundary the variable
10365
+ names — that is what a nested launcher declares as `parent`.
10366
+
10367
+ To find the owner of an arbitrary process on Linux, read its control group, take the `*.scope`
10368
+ component and compare it with `workUnitName(record)` of each launcher's records. The unit name is
10369
+ `<launcher>-<id>.scope`; it is computed one way and never parsed back, because two different
10370
+ owners can spell the same name.
10371
+
10372
+ ### Placement
10373
+
10374
+ Placement is always written out; a host that cannot make the boundary you asked for throws
10375
+ `WorkLaunchError` with a `reason`, and nothing is started as a plain child instead.
10376
+
10377
+ | placement | boundary | holds |
10378
+ |---|---|---|
10379
+ | `{ kind: 'transient-scope', manager, slice, limits? }` | a transient systemd scope (Linux, systemd 254 or newer, cgroup v2) | every descendant, including one that called `setsid` |
10380
+ | `{ kind: 'process-root' }` | a recorded root process (Linux and macOS) | the root, the process group it leads, and processes whose parent chain reaches the live root |
10381
+
10382
+ For a scope:
10383
+
10384
+ - `manager` is `'system'` or `'user'`. The user manager is reached through `XDG_RUNTIME_DIR`, or
10385
+ through `/run/user/<uid>` when that directory is the caller's own; otherwise the launch refuses
10386
+ with `user-manager-unreachable`. The system manager takes scopes from root only: a non-root
10387
+ caller is refused with `manager-unauthorized` before anything starts, because the system
10388
+ manager may let it start a unit and then deny stopping it (polkit asks for interactive
10389
+ authentication), which would leave work its launcher cannot end. Such a caller uses `'user'`.
10390
+ - `slice: 'caller'` keeps the caller's own slice, and so the resource limits that slice carries; a
10391
+ caller with no slice under that manager is refused with `slice-unresolvable`. Any other value
10392
+ names a slice in full (`'build.slice'`).
10393
+ - `limits` become properties of the unit: `memoryMaxMb`, `memorySwapMaxMb`, `cpuQuotaPercent`,
10394
+ `cpuWeight` and `runtimeMaxSeconds`.
10395
+ - The command's arguments arrive as written. `systemd-run` would otherwise expand `${VAR}` and `$$`
10396
+ in them, so the scope is started with `--expand-environment=no`, an option systemd has since
10397
+ version 254; an older systemd is refused with `systemd-too-old`.
10398
+ - A launcher id that is still running refuses a second launch with `unit-exists`. The name is free
10399
+ again once the scope has emptied and the manager has collected it.
10400
+ - A scope is not part of its launcher's service: restarting the launcher's service leaves its
10401
+ scopes running. Stop them with `launch.stop()` — or `systemctl stop <unit>` — when they must not
10402
+ outlive it.
10403
+
10404
+ `probeWorkBoundary(placement)` answers `{ state: 'available' }` or `{ state: 'unavailable',
10405
+ reason, cause }` without launching anything.
10406
+
10407
+ A process root has one stated limit: a descendant that left the group with `setsid` **and** lost
10408
+ its parent is `outside`. A scope would still hold it. Use a process root where there is no
10409
+ transient scope — macOS, or a Linux host without systemd — and name it yourself: the package never
10410
+ substitutes one boundary for the other. The root is a package-owned entry that measures its own
10411
+ process instance, writes it into the variable and replaces itself with your command through
10412
+ `process.execve`, so the root pid is your command's pid; the runtime must provide `process.execve`.
10413
+ A single-file bundle carries that entry through
10414
+ [`bootstrapPackageProcess()`](#commands).
10415
+
10416
+ ### When another program does the spawning
10417
+
10418
+ A terminal multiplexer, a remote shell or another supervisor starts the command itself. Hand it
10419
+ the wrapped command instead:
10420
+
10421
+ ```ts
10422
+ import { workCommand } from 'stitchkit/service-host/work'
10423
+
10424
+ const placed = await workCommand({ owner, placement, executable, args, env })
10425
+ // placed.executable, placed.args, placed.env — run exactly these
10426
+ ```
10427
+
10428
+ `env` is written out (`{}` for none): the result extends it with `STITCHKIT_WORK_ORIGIN`, and for
10429
+ the user manager with `XDG_RUNTIME_DIR`. A bare executable name is found on the `PATH` the command
10430
+ is given.
10431
+
10432
+ ### What the launch's own signal stops
10433
+
10434
+ `command` takes the options of `runNativeCommand` except `group`, `ownerLoss` and
10435
+ `onLeaderStarted`. Its `signal`, `timeoutMs` and `stop` policy act on the root's process group, as
10436
+ they do for any command; `launch.stop()` ends the whole boundary — for a scope, through the
10437
+ manager, which also ends processes that left the group. `launch.result` settles like
10438
+ `runNativeCommand`.
10439
+
10253
10440
  ## A contract operation in a process of its own
10254
10441
 
10255
10442
  A handler that reads gigabytes holds the server's event loop while it reads, and every cheap
@@ -10675,8 +10862,7 @@ The plugin does not parse consumer JS or establish a second runtime native imple
10675
10862
 
10676
10863
  A package that owns a server usually ships a typed client for it, and the client's consumers
10677
10864
  must not inherit the server's dependencies. `buildClientArtifact` (`stitchkit/files/packaging`)
10678
- bundles one entry module into a single file, publishes its SHA-256 beside it and can prove an
10679
- npm archive of it:
10865
+ bundles one entry module into a single file and publishes its SHA-256 beside it:
10680
10866
 
10681
10867
  ```ts
10682
10868
  import { buildClientArtifact } from 'stitchkit/files/packaging'
@@ -10685,30 +10871,142 @@ const artifact = await buildClientArtifact({
10685
10871
  entry: 'src/api-client.ts',
10686
10872
  outFile: 'dist/api-client.js', // + dist/api-client.js.sha256
10687
10873
  forbiddenModules: ['chalk', '@acme/terminal-ui', 'src/terminal/', /providers\//],
10688
- package: {
10689
- name: '@acme/api-client', version: '1.4.0', outDir: 'dist',
10690
- exports: ['createApiClient'],
10691
- },
10692
10874
  })
10693
- // artifact.file, artifact.sha256, artifact.bytes, artifact.modules, artifact.package.tarball
10875
+ // artifact.file, artifact.sha256, artifact.bytes, artifact.modules
10694
10876
  ```
10695
10877
 
10696
10878
  - **`forbiddenModules`** refuses a bundle whose module graph reaches a listed module with a
10697
10879
  `ForbiddenModuleError` naming the module and what imports it. A bare or scoped name
10698
- (`'chalk'`, `'@scope/pkg'`) is a package: it is matched by the specifier that imports it, so a
10699
- linked or workspace package is caught wherever it really lives, and by its installed path. A
10700
- string with a slash matches a fragment of the project's own source path; a `RegExp` is tested
10701
- against each module's absolute path. Nothing is left at `outFile` when the build is refused.
10702
- - **`package`** packs the file as an npm archive, installs it into an empty directory, imports
10703
- it by name and checks every name in `exports`. A client that still reaches for the building
10704
- package's `node_modules` fails there, before it reaches a consumer; a failed proof removes the
10705
- file and its hash again.
10880
+ (`'chalk'`, `'@scope/pkg'`, `'node:child_process'`) is a package or a platform module: it is
10881
+ matched by the specifier that imports it, so a linked or workspace package is caught wherever
10882
+ it really lives and a platform module is caught although it is never bundled, and by its
10883
+ installed path. A string with a slash matches a fragment of the project's own source path; a
10884
+ `RegExp` is tested against each bundled module's absolute path. Nothing is left at `outFile`
10885
+ when the build is refused.
10706
10886
  - **`runtime`** is the platform the file is built for — `node` by default, which Bun also runs,
10707
10887
  or `bun` or `browser`; a module the platform does not have fails the build.
10708
10888
 
10709
- The build, the pack and the verification each run Bun as a bounded command: `timeoutMs`
10710
- (default 120 s) is the deadline of each step, `signal` cancels, and `executable` names the Bun
10711
- binary when it is not `bun` on `PATH`.
10889
+ The build runs Bun as a bounded command: `timeoutMs` (default 120 s) is its deadline, `signal`
10890
+ cancels, and `executables.bun` names the Bun binary when it is not `bun` on `PATH`.
10891
+
10892
+ The file is for a consumer that copies it. A client published to a registry — with types,
10893
+ several entries and peers the consumer already has — is the next section.
10894
+
10895
+ ## A typed client as an npm package
10896
+
10897
+ `buildClientPackage` (`stitchkit/files/packaging`) builds a typed client into an npm archive and
10898
+ returns it only after the archive was installed and used the way a consumer uses it:
10899
+
10900
+ ```ts
10901
+ import { buildClientPackage } from 'stitchkit/files/packaging'
10902
+
10903
+ const client = await buildClientPackage({
10904
+ name: '@acme/api-client',
10905
+ version: '1.4.0',
10906
+ entries: { '.': 'src/client/index.ts', './monitoring': 'src/client/monitoring.ts' },
10907
+ tsconfig: 'tsconfig.json',
10908
+ peerDependencies: { stitchkit: '^0.133.0', zod: '^4.6.0' },
10909
+ outDir: 'dist', // dist/acme-api-client-1.4.0.tgz
10910
+ })
10911
+ // client.tarball, client.sha256, client.files, client.exports, client.sharedExports, client.proof
10912
+ ```
10913
+
10914
+ Publishing the archive, and its provenance, stay with your release.
10915
+
10916
+ ### One module graph for every entry
10917
+
10918
+ All `entries` are built in one pass, so a module two of them import is emitted once, as a shared
10919
+ chunk. A schema or an error class exported from `.` and from `./monitoring` is then one object:
10920
+ `===` and `instanceof` hold across the entries, in Node and in Bun. Two separate builds of the
10921
+ same entries give two copies, and both comparisons are false.
10922
+
10923
+ The proof checks it on the installed package: every name more than one subpath exports must be
10924
+ the same value in all of them, and `client.sharedExports` lists the names proven. A name two
10925
+ entries export as different values on purpose goes into `proof.distinctExports`; any other is
10926
+ refused as `shared-export-split`, with the names in `details.names`.
10927
+
10928
+ ### Peers and dependencies stay outside
10929
+
10930
+ Each package in `peerDependencies` and `dependencies` is left out of the output and written to
10931
+ the archive's `package.json` under the same key. Both must be installed where the client is
10932
+ built: the proof installs them from there, and refuses with `peer-range` when an installed
10933
+ version is outside the range you declared.
10934
+
10935
+ - An import that reaches into a peer's directory by path — a workspace neighbour imported as
10936
+ `../../packages/kit/index.js` — would bundle it all the same, and is refused as
10937
+ `bundled-peer`. Import the package by its name.
10938
+ - `forbiddenModules` takes the rules of `buildClientArtifact` and also reads imports left
10939
+ outside: `'stitchkit/server'` refuses a client that imports that subpath of a peer, while
10940
+ `stitchkit/contract` stays allowed.
10941
+
10942
+ ### Declarations for Bundler and NodeNext
10943
+
10944
+ Declarations are emitted with `tsconfig`, for the entries and what they import — nothing else of
10945
+ the project is typechecked or shipped. The tsconfig's directory is the root: every entry lies
10946
+ under it, and `dist/` in the archive mirrors it. A `typescript` package must be installed in the
10947
+ project; the build runs its compiler with the runtime that runs the build (Bun or Node), and
10948
+ writes a temporary `.client-package-*.tsconfig.json` beside your tsconfig for the length of the
10949
+ emit.
10950
+
10951
+ The compiler leaves relative specifiers in a declaration as the source wrote them, and a
10952
+ consumer under `moduleResolution: NodeNext` cannot resolve an extensionless one. The build
10953
+ rewrites every relative specifier to the `.js` file it stands for, whether the source wrote
10954
+ `'./schema'` or `'./schema.ts'`. What a consumer could not resolve is refused:
10955
+
10956
+ | `reason` | The declaration names | What to do |
10957
+ |---|---|---|
10958
+ | `declaration-unresolved` | a relative module with no declaration in the package — a hand-written `.d.ts` beside the sources, or a `/// <reference path>` | move the types into a `.ts` module |
10959
+ | `declaration-dependency` | a package that is neither a peer nor a dependency — including a tsconfig path alias such as `@/schema` | declare the package, or keep its types out of the public surface; import own modules relatively |
10960
+
10961
+ ### What the proof runs
10962
+
10963
+ The archive is installed into an empty directory beside its peers. There the build:
10964
+
10965
+ 1. compares every installed file with the one it built;
10966
+ 2. imports every subpath by the package name — in Node and Bun for `runtime: 'node'` (the
10967
+ default), in Bun for `'bun'` and `'browser'` — and checks `proof.exports` and shared names;
10968
+ 3. typechecks a strict consumer (`strict`, `skipLibCheck: false`) that re-exports every subpath,
10969
+ under `moduleResolution: bundler` and under `NodeNext`.
10970
+
10971
+ ```ts
10972
+ proof: {
10973
+ typecheck: ['src/client/consumer-proof.ts'], // your own consumer source, both resolutions
10974
+ exports: { '.': ['createApiClient'], './monitoring': ['readSessions'] },
10975
+ types: ['@types/node'], // type packages the declarations need
10976
+ }
10977
+ ```
10978
+
10979
+ A `proof.typecheck` file imports the package by name and nothing relative. Give it a negative
10980
+ assertion — a `// @ts-expect-error` over a value the types must reject — so a type that silently
10981
+ became `any` fails the proof. The consumer typecheck loads the `ES2023` and `DOM` libraries and
10982
+ only the type packages in `proof.types`, installed from the project.
10983
+
10984
+ Peers are installed from the project's own `node_modules`; what they depend on in turn comes
10985
+ from the package manager's cache or registry.
10986
+
10987
+ ### Refusals
10988
+
10989
+ A refusal is a `ClientPackageError`: switch on `reason`, read `details`. A forbidden module is a
10990
+ `ForbiddenModuleError`, as for the file. No archive is left in `outDir` after either.
10991
+
10992
+ | `reason` | When | `details` |
10993
+ |---|---|---|
10994
+ | `build` | the bundler failed | `output` |
10995
+ | `declarations` | the compiler reported an error in the client's graph | `output` |
10996
+ | `declaration-unresolved`, `declaration-dependency` | see above | `file`, `specifier`, `package` |
10997
+ | `bundled-peer` | code of a peer or dependency is in the package | `package`, `module` |
10998
+ | `manifest-owned-field` | `manifest` sets a field the build writes | `field` |
10999
+ | `install` | a peer is not installed for the build, or packing, installing or importing the archive failed | `package` or `output`, `runtime` |
11000
+ | `peer-range` | an installed peer or dependency is outside its declared range | `package`, `range`, `installed` |
11001
+ | `missing-export` | a subpath lacks a name from `proof.exports` | `subpath`, `names`, `runtime` |
11002
+ | `shared-export-split` | several subpaths export one name as different values | `names`, `runtime` |
11003
+ | `typecheck` | the strict consumer did not typecheck | `resolution`, `output` |
11004
+
11005
+ `manifest` adds descriptive `package.json` fields (`description`, `license`, `repository`, …);
11006
+ `name`, `version`, `type`, `exports`, `files` and the dependency maps come from the build and are
11007
+ refused there. `files` maps a path inside the package to a source file, for a README or a
11008
+ licence. Each tool runs as a bounded command under `timeoutMs` (default 120 s per step) and
11009
+ `signal`; `executables` names `bun`, `node` or `tsc` when the default is not the one to use.
10712
11010
 
10713
11011
  ## Qualification boundaries
10714
11012
 
@@ -15189,7 +15487,7 @@ core never models them (ADR 0002). But stitchkit itself emits a set of its own:
15189
15487
  `WAIT_TIMEOUT`,
15190
15488
  `WAIT_FAILED`, `CLI_COMMAND_UNAVAILABLE`, `CLI_PRESENTATION_FAILED`, `DOWNLOAD_NOT_FOUND`, `VIEW_HTTP_ERROR`,
15191
15489
  `CONNECTION_TIMEOUT`, `CONNECTION_RESPONSE_TOO_LARGE`,
15192
- `CONNECTION_REQUEST_FAILED`, `UPSTREAM_TOOL_ERROR`, `MCP_STRUCTURED_CONTENT_MISSING`,
15490
+ `CONNECTION_REQUEST_FAILED`, `HTTP_ERROR`, `UPSTREAM_TOOL_ERROR`, `MCP_STRUCTURED_CONTENT_MISSING`,
15193
15491
  `OPERATION_NOT_SUCCEEDED`, `OPERATION_BUSY`, `OPERATION_RESPONSE_TOO_LARGE`,
15194
15492
  `OPERATION_PROCESS_FAILED`, `STREAM_ITEM_INVALID`, `STREAM_FRAME_TOO_LARGE`,
15195
15493
  `STREAM_TERMINAL_MISSING`, `STREAM_LIFETIME_EXCEEDED`,
@@ -15334,6 +15632,54 @@ their established model-facing projection (code/details/hint, without HTTP
15334
15632
  status), while `invokeOrThrow` recovers the exact normalized `AppError`. The
15335
15633
  codes and schemas remain application-owned; Stitchkit stays domain-free.
15336
15634
 
15635
+ ### The codes an operation refuses with
15636
+
15637
+ An endpoint names the domain codes it can refuse with in `refuses`, by listing the
15638
+ factories `defineErrors` returned. Every factory carries its `code` and
15639
+ `definition`, so the list is the declaration — no second string list to drift:
15640
+
15641
+ ```ts
15642
+ const { errors } = defineErrors({
15643
+ NOT_IDLE: { status: 409, message: 'Session is busy' },
15644
+ MIN_AWAKE: { status: 409, details: z.object({ profile: z.string(), minimum: z.number().int() }) },
15645
+ PROFILE_UNAVAILABLE: { status: 503 },
15646
+ })
15647
+
15648
+ export const sessions = defineContract({ prefix: 'session' }, {
15649
+ sleep: {
15650
+ method: 'POST', path: '/sleep', desc: 'Put a session to sleep',
15651
+ input: z.object({ id: z.string() }),
15652
+ output: z.object({ ok: z.boolean() }),
15653
+ refuses: [errors.NOT_IDLE, errors.MIN_AWAKE],
15654
+ },
15655
+ })
15656
+ ```
15657
+
15658
+ One declaration, three readers:
15659
+
15660
+ - **The server holds the handler to it.** An `AppError` whose code the operation
15661
+ did not declare — and that is no framework code (`NOT_FOUND`, `FORBIDDEN`, …) —
15662
+ leaves as `INTERNAL_SERVER_ERROR` (500) with the message `Operation session.sleep
15663
+ failed with a code it does not declare`, on HTTP, MCP, the agent surface, the CLI
15664
+ and mid-stream alike, exactly as an output that breaks its schema does. The
15665
+ original error stays on `cause`, so `onError` and the logs still see it; the
15666
+ caller does not. An `implementRemote` proxy is held to the same list even when its
15667
+ origin is not. A failure that is no `AppError` keeps its usual handling, and an
15668
+ operation without `refuses` runs unchanged.
15669
+ - **The typed client reads it.** [`client.sleep.refusal(error)`](client.md#read-a-refusal-the-operation-declared)
15670
+ narrows `code` to the declared codes plus the framework and client codes, and
15671
+ types `details` by the code's schema.
15672
+ - **The descriptor carries it** for a reader without types: `MethodDef.refuses`
15673
+ (code, status, retryability, message, details schema), `x-stitchkit-refusals`
15674
+ with one response per declared status in OpenAPI, `refusals` in the surface
15675
+ manifest, and the contract fingerprint. Each changes only for an operation that
15676
+ declares `refuses`.
15677
+
15678
+ `defineContract` refuses an entry that is not a factory from `defineErrors` (a bare
15679
+ code string) and a code listed twice, naming the endpoint and the index.
15680
+ Declaring is opt-in per operation: start with the operations whose callers branch
15681
+ on a code. → ADR 0330
15682
+
15337
15683
  ## `createErrorHook`
15338
15684
 
15339
15685
  `createErrorHook` is the code-map above, packaged — you supply a `codeMap` and
@@ -18089,7 +18435,7 @@ import { createSyncSession } from 'stitchkit/sync';
18089
18435
  const session = createSyncSession({
18090
18436
  isConnected: () => socket.connected,
18091
18437
  readCursor: () => db.cursor(), // null starts a snapshot; a saved version, including 0, starts the feed
18092
- beginFullSync: () => db.resetCursor(), // keeps the projection; nothing is deleted yet
18438
+ beginFullSync: () => db.resetCursor(), // resets the saved cursor to null, never to 0; keeps the projection
18093
18439
  send: (request) => socket.emit('sync_request', toWire(request)),
18094
18440
  apply: (page, context) => db.applyPage(page, context), // { current, snapshot }: see above
18095
18441
  saveCursor: (version) => db.saveCursor(version),
@@ -18128,7 +18474,10 @@ page the cursor is the version it began at, and the feed catches up from there.
18128
18474
 
18129
18475
  A cursor older than the feed the server keeps is refused with `stale_cursor` (`SYNC_STALE_CURSOR`,
18130
18476
  passed to `handleError`): the session begins a full snapshot at once, without a pause. Inside a
18131
- snapshot the same refusal starts it over after a pause. `beginFullSync` keeps the outbox, and after
18477
+ snapshot the same refusal starts it over after a pause. `beginFullSync` resets the saved cursor to
18478
+ `null` — the value `readCursor` returns for a replica that holds no completed snapshot. A reset to `0`
18479
+ is a saved version: a session restarted before the snapshot's first page was saved would read the feed
18480
+ after version zero instead of starting the snapshot again. `beginFullSync` keeps the outbox, and after
18132
18481
  the last page of any full snapshot — asked for, forced by the server or after `stale_cursor` —
18133
18482
  `rebasePending` merges pending local changes onto what it brought, before its cursor is saved; a
18134
18483
  refusal there is `rebase_failed` and the session retries. Ids come from `crypto.randomUUID`, falling back to
@@ -19727,19 +20076,189 @@ charts, no merged cells and no streaming: an application that needs them takes a
19727
20076
 
19728
20077
  # Upgrading stitchkit
19729
20078
 
20079
+ ## Released migration: 0.133.0
20080
+
20081
+ ### executor-testing-claude-sdk-subpath
20082
+
20083
+ **Who must act:** tests that import `createFakeClaudeSdkQuery`, `createStubClaudeSdkSession` or a `FakeClaudeSdk*` type from `stitchkit/agent-executor/testing`.
20084
+
20085
+ Import them from `stitchkit/agent-executor/testing/claude-sdk`. Nothing else changes: the functions, their options and `StubOverrides` (still exported by `stitchkit/agent-executor/testing`) are the same.
20086
+
20087
+ ```ts
20088
+ // Before
20089
+ import { createFakeClaudeSdkQuery, createStubClaudeSdkSession } from 'stitchkit/agent-executor/testing';
20090
+ // After
20091
+ import { createFakeClaudeSdkQuery, createStubClaudeSdkSession } from 'stitchkit/agent-executor/testing/claude-sdk';
20092
+ ```
20093
+
20094
+ `stitchkit/agent-executor/testing` no longer names the types of `@anthropic-ai/claude-agent-sdk`, so a project that tests a Codex or ACP driver needs neither the SDK nor `skipLibCheck`.
20095
+
20096
+ ### executor-profile-env-sanitizer
20097
+
20098
+ **Who must act:** callers of `sanitizeProfileEnv` from `stitchkit/agent-executor`.
20099
+
20100
+ The function is removed: it dropped a variable whose name the profile schema refuses, so one bad name had two outcomes. Pass the variables to the profile and let `ExecutorProfileConfigSchema` refuse a bad name, or filter in the application where dropping is a decision:
20101
+
20102
+ ```ts
20103
+ // Before
20104
+ const env = sanitizeProfileEnv(untrusted);
20105
+ // After
20106
+ const env = Object.fromEntries(
20107
+ Object.entries(untrusted).filter(
20108
+ (entry): entry is [string, string] =>
20109
+ typeof entry[1] === 'string' && EXECUTOR_ENV_KEY_PATTERN.test(entry[0]),
20110
+ ),
20111
+ );
20112
+ ```
20113
+
20114
+ ### executor-conformance-lifecycle
20115
+
20116
+ **Who must act:** tests that run `runAgentEngineConformance` (`stitchkit/agent-executor/testing`) on a driver written outside this package.
20117
+
20118
+ The kit now proves what a driver does when its session stops, and fails by the name of the rule a driver breaks. The drivers of this package and the replay driver pass. For your own driver, make each of these true:
20119
+
20120
+ - `open({ signal })` rejects with `signal.reason` when the signal is already aborted, and when it aborts while `open` runs — the kit aborts it from `onStartupPhase`. A driver that reports no startup phase is not asked the second.
20121
+ - An abort while a turn runs fails that turn's `deltas` with `signal.reason`; afterwards `turn.respond()` and `session.startTurn()` reject with the same reason.
20122
+ - `turn.interrupt()` resolves, without an error, once the turn ended, the signal aborted or the session closed.
20123
+ - `session.close()` during a turn fails the turn's `deltas` instead of leaving them open, resolves when called twice at once and again later, and `onStartupPhase` is not called after it.
20124
+ - `(await driver.info()).capabilities` equals `driver.capabilities` — both absent, or the same object by value.
20125
+
20126
+ ```ts
20127
+ // Before: nothing followed the caller's signal, and the kit did not ask.
20128
+ async open(input) {
20129
+ return openSession(input.profile, input.cwd);
20130
+ }
20131
+ // After
20132
+ async open(input) {
20133
+ input.signal?.throwIfAborted();
20134
+ const session = await openSession(input.profile, input.cwd);
20135
+ input.signal?.addEventListener('abort', () => session.fail(input.signal?.reason), { once: true });
20136
+ return session;
20137
+ }
20138
+ ```
20139
+
20140
+ Each wait in these checks is bounded at 10 s and a hang fails as `… did not settle within 10000 ms`; give the conformance test a timeout above that (the tests of this package use 30–60 s), or the runner's own timeout reports the hang without the name.
20141
+
20142
+ ### codex-owned-thread-unsubscribe
20143
+
20144
+ **Who must act:** callers of `stitchkit/agent-executor/codex` that call `unsubscribeThread` on a thread their own driver opened.
20145
+
20146
+ `CodexSession.unsubscribeThread()` without a `threadId`, with the session's own id, or with the id of any thread open on the same shared server now rejects with `TypeError`. Close the session instead: `close()` interrupts the thread's turn, answers what it still holds and unsubscribes it, and a shared server frees its slot.
20147
+
20148
+ ```ts
20149
+ // Before: detached the thread behind the driver; a shared server kept counting it.
20150
+ await session.unsubscribeThread();
20151
+ await server.unsubscribeThread({ threadId: session.nativeThreadId });
20152
+ // After: one way to detach a thread the driver opened.
20153
+ await session.close();
20154
+ ```
20155
+
20156
+ A thread the driver did not open — an external TUI thread, a sibling client's thread — is still unsubscribed with one raw `thread/unsubscribe`.
20157
+
20158
+ ### process-bootstrap-rename
20159
+
20160
+ **Who must act:** single-file applications (a `bun build` output that routes its own argv) that import `stitchkit/process/owner-loss`.
20161
+
20162
+ The narrow bootstrap entry now carries every invocation the package starts for itself — the owner-loss guard of `runNativeCommand` and the process root of `stitchkit/service-host/work` — so both the subpath and the function are renamed. Nothing else changes: call it once before your argv dispatcher and skip the dispatcher when it returns `true`.
20163
+
20164
+ ```ts
20165
+ // Before
20166
+ import { bootstrapNativeCommandOwnerLoss } from 'stitchkit/process/owner-loss';
20167
+ if (!bootstrapNativeCommandOwnerLoss()) await main();
20168
+ // After
20169
+ import { bootstrapPackageProcess } from 'stitchkit/process/bootstrap';
20170
+ if (!bootstrapPackageProcess()) await main();
20171
+ ```
20172
+
20173
+ The rename is mechanical; these two commands find every site:
20174
+
20175
+ ```bash
20176
+ rg "stitchkit/process/owner-loss" .
20177
+ rg "bootstrapNativeCommandOwnerLoss" .
20178
+ ```
20179
+
20180
+ An application that does not bundle itself into one file, or that never imported the old subpath, has nothing to do.
20181
+
20182
+ ### client-artifact-package-option
20183
+
20184
+ **Who must act:** builds that call `buildClientArtifact` (`stitchkit/files/packaging`) with `package` or `executable`, or read `artifact.package`.
20185
+
20186
+ `buildClientArtifact` now builds the self-contained file and its hash, nothing else. Find the calls:
20187
+
20188
+ ```bash
20189
+ rg "buildClientArtifact" .
20190
+ ```
20191
+
20192
+ 1. A call with `executable` and no `package`: rename the option.
20193
+
20194
+ ```ts
20195
+ // Before
20196
+ await buildClientArtifact({ entry, outFile, executable: '/opt/bun/bin/bun' });
20197
+ // After
20198
+ await buildClientArtifact({ entry, outFile, executables: { bun: '/opt/bun/bin/bun' } });
20199
+ ```
20200
+
20201
+ 2. A call with `package`: the npm archive is built by `buildClientPackage`. It builds from the
20202
+ entry itself, not from the bundled file, so keep the `buildClientArtifact` call only if you
20203
+ still ship the single file.
20204
+
20205
+ ```ts
20206
+ // Before
20207
+ const artifact = await buildClientArtifact({
20208
+ entry: 'src/api-client.ts',
20209
+ outFile: 'dist/api-client.js',
20210
+ forbiddenModules: ['src/terminal/'],
20211
+ package: { name: '@acme/api-client', version: '1.4.0', outDir: 'dist', exports: ['createApiClient'] },
20212
+ });
20213
+ publish(artifact.package.tarball);
20214
+ // After
20215
+ const client = await buildClientPackage({
20216
+ name: '@acme/api-client',
20217
+ version: '1.4.0',
20218
+ entries: { '.': 'src/api-client.ts' },
20219
+ tsconfig: 'tsconfig.json',
20220
+ peerDependencies: { zod: '^4.6.0' },
20221
+ forbiddenModules: ['src/terminal/'],
20222
+ outDir: 'dist',
20223
+ proof: { exports: { '.': ['createApiClient'] } },
20224
+ });
20225
+ publish(client.tarball);
20226
+ ```
20227
+
20228
+ What differs from the old archive, and may refuse a client the old one packed:
20229
+
20230
+ - The entry is a `.ts` or `.tsx` module under the directory of `tsconfig`, and a `typescript`
20231
+ package is installed in the project: the archive now carries declarations.
20232
+ - A package the client imports is bundled unless you list it in `peerDependencies` or
20233
+ `dependencies`. A public type that names a package you did not list is refused as
20234
+ `declaration-dependency` — list it, usually as a peer.
20235
+ - The main module moves from `index.js` to `dist/<path under the tsconfig directory>.js`, behind
20236
+ `exports`. A consumer that imports the package by name is unaffected; one that reached for
20237
+ `<package>/index.js` imports the package name instead.
20238
+ - A failure is a `ClientPackageError` with a `reason` (`missing-export` for a name in
20239
+ `proof.exports`), not an `Error` to match by message.
20240
+
20241
+ [The guide](native-io.md#a-typed-client-as-an-npm-package) describes the options and every refusal.
20242
+
19730
20243
  ## Released migration: 0.132.0
19731
20244
 
19732
20245
  ### saved-sync-cursor-zero
19733
20246
 
19734
- **Who must act:** users of `stitchkit/sync` whose cursor reader returns zero for an uninitialized replica.
20247
+ **Who must act:** users of `stitchkit/sync` whose cursor reader returns zero for an uninitialized replica, or whose `beginFullSync` resets the saved cursor to zero.
19735
20248
 
19736
20249
  Return `null` until the first snapshot completes. A saved `0` requests the incremental feed after version zero.
20250
+ `beginFullSync` follows the same rule: reset the saved cursor to `null`, not to `0`, or a session
20251
+ restarted before the snapshot's first page was saved reads the feed instead of starting the snapshot again.
19737
20252
 
19738
20253
  ```ts
19739
20254
  // Before: a missing row and a completed snapshot at zero shared the same marker.
19740
20255
  readCursor: () => row?.version ?? 0
19741
20256
  // After: preserve every published server version.
19742
20257
  readCursor: () => row?.version ?? null
20258
+ // Before: the reset wrote the same marker a completed snapshot at zero has.
20259
+ beginFullSync: () => db.run('UPDATE sync_state SET version = 0')
20260
+ // After: the reset is "no completed snapshot".
20261
+ beginFullSync: () => db.run('UPDATE sync_state SET version = NULL')
19743
20262
  ```
19744
20263
 
19745
20264
  If an old store persisted zero for both states and has no completion marker, perform one full
@@ -19804,9 +20323,9 @@ const shouldPoll =
19804
20323
 
19805
20324
  ### executor-status-delta
19806
20325
 
19807
- **Who must act:** every caller of `stitchkit/agent-executor` that switches exhaustively on `ExecutorDelta['type']` or validates wire `TurnReport.deltas` against a `0.129.0` server schema.
20326
+ **Who must act:** every caller of `stitchkit/agent-executor` that switches exhaustively on `ExecutorDelta['type']`, and every operator who runs an executor and its server on different releases across `0.130.0`.
19808
20327
 
19809
- `ExecutorDeltaSchema` / `ExecutorDelta` now includes `ExecutorStatusDeltaSchema` (`{ type: 'status', phase: 'spawning' | 'initializing' | 'verifying', ... }`) for structured startup lifecycle deltas. `projectExecutorDeltas` ignores `status` deltas automatically; add a `case 'status':` branch to any custom exhaustive `switch (delta.type)`:
20328
+ `ExecutorDeltaSchema` / `ExecutorDelta` now includes `ExecutorStatusDeltaSchema` (`{ type: 'status', phase, ... }`) for structured startup lifecycle deltas. `phase` 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 rather than refusing it. `projectExecutorDeltas` ignores `status` deltas automatically; add a `case 'status':` branch to any custom exhaustive `switch (delta.type)`:
19810
20329
 
19811
20330
  ```ts
19812
20331
  // before
@@ -19827,6 +20346,24 @@ switch (delta.type) {
19827
20346
  }
19828
20347
  ```
19829
20348
 
20349
+ **The wire changed in both directions, not only by the `status` delta.** Every object of the
20350
+ executor ↔ server contract is strict, so a reader on `0.129.x` refuses a whole message that carries
20351
+ a key `0.130.0` added:
20352
+
20353
+ | Travels | Message | A `0.129.x` reader refuses |
20354
+ |---------|---------|----------------------------|
20355
+ | executor → server | `hello` | `engines[].capabilities` — written by every driver, so the handshake itself fails |
20356
+ | executor → server | `report` | a `status` delta; `threadDisposition` on `turn-end` and on `failure`; `cacheCreationInputTokens`, `thinkingTokens`, `totalTokens`, `total` and `modelUsage` on a `usage` delta |
20357
+ | server → executor | `reply` | `scope` and `updatedInput` on `approve`; `interrupt` on `deny` |
20358
+
20359
+ Upgrade the server before any executor: an older executor writes none of these keys and keeps
20360
+ working. Until every executor is upgraded, the server sends `scope: 'session'`, `updatedInput` and
20361
+ `interrupt` only to an executor whose `hello` declared `sessionApproval`, `updatedToolInput` and
20362
+ `interruptOnDeny` for the engine — an engine announced without `capabilities` is on `0.129.x`.
20363
+ `0.131.0` added `plan` and `windows[].scope` to `planLimits` in `hello` the same way. The rule
20364
+ and the table of every release are in the
20365
+ [API reference](../api/reference.md#version-skew-between-an-executor-and-its-server) (ADR 0334).
20366
+
19830
20367
  ## Released migration: 0.129.0
19831
20368
 
19832
20369
  ### codex-plan-window-keys
@@ -26743,7 +27280,8 @@ from the root `stitchkit`.
26743
27280
  | `OperationEffect` / `OperationEffectSchema` | _type_ / schema | closed `'read' \| 'write'` side-effect classification declared on contract endpoints |
26744
27281
  | `contractOperationEffects` / `requireContractOperationEffects` | function | project declared endpoint `effect` tags from a contract; `requireContractOperationEffects` fails closed and lists every operation missing `effect` |
26745
27282
  | `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) |
26746
- | `EndpointToolOptions` | _type_ | an endpoint's `tool` group — `name`, `view`, `ui`, `annotations`, `mcp`, `inputRecursionDepth`: what the tool surfaces read that HTTP does not |
27283
+ | `EndpointToolOptions` | _type_ | an endpoint's `tool` group — `name`, `view`, `ui`, `annotations`, `mcp`, `inputRecursionDepth`, `inputNestingDepth`: what the tool surfaces read that HTTP does not |
27284
+ | `OperationToolOption` | _type_ | the `tool` options an operation's identity carries to every tool transport — `ui`, `annotations`, `mcp`, `inputRecursionDepth`, `inputNestingDepth` |
26747
27285
  | `EndpointToolView` | _type_ | the stored shape of a tool view (`MethodDef.toolView`) |
26748
27286
  | `DeclaredToolView` | _type_ | a tool view as `withToolView` produces it — the only form `tool.view` accepts |
26749
27287
  | `WithToolView` | _type_ | the endpoint `withToolView` returns: its own tool options plus the declared view in `tool.view` — name it when a helper returns such an endpoint |
@@ -26809,7 +27347,12 @@ from the root `stitchkit`.
26809
27347
  | `ErrorDetailsSchema` | _type_ | required or optional Zod object accepted for structured details |
26810
27348
  | `ErrorDetailsOutput` | _type_ | parsed details inferred from one definition |
26811
27349
  | `ErrorFactoryArguments` | _type_ | options tuple with forbidden/required/optional details inferred per code |
26812
- | `ErrorFactory` | _type_ | one typed `AppError` constructor |
27350
+ | `ErrorFactory` | _type_ | one typed `AppError` constructor; it carries its `code` and `definition`, so an endpoint can list it in `refuses` |
27351
+ | `RefusalDeclaration` | _type_ | one entry of an endpoint's `refuses` — an `ErrorFactory` (`{ code, definition }`) — [guide](../guide/auth-and-errors.md#the-codes-an-operation-refuses-with) |
27352
+ | `DescribedRefusal` | _type_ | a declared refusal resolved for a reader without types — `{ code, status, retryable, message?, details? }`, on `MethodDef.refuses` |
27353
+ | `OperationRefusal` | _type_ | every refusal a call of one endpoint can end with — its declared codes with typed `details`, plus framework and client codes; what `client.op.refusal(error)` returns |
27354
+ | `DeclaredRefusal` | _type_ | the `ApiError` shape `OperationRefusal` narrows — `{ code, status, details, message, hint?, traceId?, retryable? }` |
27355
+ | `CLIENT_ERROR_CODES` / `ClientErrorCode` | const / _type_ | codes only the typed client raises, with no server status — `UNKNOWN_ERROR`, `STREAM_TRUNCATED`, `STREAM_PROTOCOL_ERROR` |
26813
27356
  | `ErrorFactories` | _type_ | mapped constructor registry derived from all definitions |
26814
27357
  | `FrozenErrorDefinitions` | _type_ | read-only definition registry returned to consumers |
26815
27358
  | `STITCH_ERROR_STATUS` | const | `code → HTTP status` map for stitchkit's own error codes — [guide](../guide/auth-and-errors.md#stitch-codes-vs-your-codes) |
@@ -28028,14 +28571,14 @@ leaves of their own; this entrypoint knows no vendor. Evolving.
28028
28571
  | `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` |
28029
28572
  | `ThreadClaimSchema` / `ThreadClaim` / `ThreadLeaseSchema` / `ThreadLease` / `ThreadRenewSchema` / `ThreadReleaseSchema` | schemas / _types_ | thread leases pinned to an executor and profile, under a fence |
28030
28573
  | `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 |
28031
- | `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`: `spawning`, `initializing`, `verifying`), the end of the turn (with optional `threadDisposition`: `'reusable' \| 'broken'`, also carried on `TurnReportSchema.failure`), errors by kind and window resets |
28574
+ | `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 |
28032
28575
  | `projectExecutorDeltas` | function | fold a turn's deltas into the message parts the agent runtime stores (ignoring lifecycle `status` deltas) |
28033
- | `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`) 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) |
28034
- | `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 |
28576
+ | `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) |
28577
+ | `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 |
28035
28578
  | `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 |
28036
28579
  | `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 |
28037
28580
  | `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 } }` |
28038
- | `ExecutorProfileConfigSchema` / `ExecutorProfileConfig` / `EXECUTOR_ENV_KEY_PATTERN` / `sanitizeProfileEnv` / `engineEnvironment` / `ownCredentials` / `helloProfile` / `CREDENTIAL_VARIABLES` | schema / _type_ / constants / functions | a profile on the executor's machine, profile env-key filtering (`EXECUTOR_ENV_KEY_PATTERN`, `sanitizeProfileEnv`), 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 |
28581
+ | `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 |
28039
28582
  | `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) |
28040
28583
  | `canAdvanceTurnPhase` / `isTerminalTurnPhase` | functions | the turn phase machine: a terminal phase is never left |
28041
28584
  | `advanceExecutorConnection` / `canAcceptTurn` / `INITIAL_EXECUTOR_CONNECTION` / `ExecutorConnectionState` / `ExecutorConnectionEvent` | functions / constant / _types_ | the executor's connection as a pure machine with generations: an answer of an earlier connection never acts on a later one |
@@ -28043,6 +28586,29 @@ leaves of their own; this entrypoint knows no vendor. Evolving.
28043
28586
 
28044
28587
  ---
28045
28588
 
28589
+ ### Version skew between an executor and its server
28590
+
28591
+ Every object of the contract is strict: a message with a key its reader does not declare is
28592
+ refused whole, and `protocol: 1` negotiates nothing. An executor and a server on different
28593
+ releases therefore agree only on what the older one declares (ADR 0334):
28594
+
28595
+ - **Upgrade the server first.** It reads `hello` and `report`; a driver writes `capabilities` on
28596
+ every engine it announces, so an executor newer than its server has its handshake refused. An
28597
+ older executor keeps working against a newer server: every added key is optional.
28598
+ - **A server writes an added reply key only to an executor that can read it.** `scope: 'session'`
28599
+ needs the engine's `sessionApproval`, `updatedInput` its `updatedToolInput`, `interrupt` its
28600
+ `interruptOnDeny`, as that executor's `hello` declared them; an engine announced without
28601
+ `capabilities` is sent none of the three.
28602
+
28603
+ What a release added to the wire, and so what a reader older than it refuses:
28604
+
28605
+ | Added in | Travels | Message | A reader older than the release refuses |
28606
+ |----------|---------|---------|------------------------------------------|
28607
+ | 0.130.0 | executor → server | `hello` | `engines[].capabilities` |
28608
+ | 0.130.0 | executor → server | `report` | `deltas[].type = 'status'`, `turn-end.threadDisposition`, `usage.cacheCreationInputTokens`, `usage.thinkingTokens`, `usage.totalTokens`, `usage.total`, `usage.modelUsage`, `failure.threadDisposition` |
28609
+ | 0.130.0 | server → executor | `reply` | `approve.scope`, `approve.updatedInput`, `deny.interrupt` |
28610
+ | 0.131.0 | executor → server | `hello` | `profiles[].planLimits.plan`, `profiles[].planLimits.windows[].scope` |
28611
+
28046
28612
  For a Claude CLI or SDK profile that should use the user's native sign-in, pass
28047
28613
  `{ profileId: 'personal', engine: 'claude-sdk', home: join(homedir(), '.claude'), claudeConfigDir: 'default' }`.
28048
28614
  The child uses its native configuration and the executor still reads transcripts from `home`.
@@ -28058,7 +28624,7 @@ Evolving.
28058
28624
 
28059
28625
  | Export | Kind | Purpose |
28060
28626
  |--------|------|---------|
28061
- | `createClaudeCliDriver` / `ClaudeCliDriverConfig` | function / _type_ | the driver; `permissionMode` defaults to `default`, so the server decides every tool the profile does not already allow; optional `resolveFile` and `maxImageBytes` (default 5 MiB) enable ordered turn-input image attachments |
28627
+ | `createClaudeCliDriver` / `ClaudeCliDriverConfig` | function / _type_ | the driver; `permissionMode` defaults to `default`, so the server decides every tool the profile does not already allow; optional `resolveFile` and `maxImageBytes` (default 5 MiB) enable ordered turn-input image attachments; `onObserverError(error, hook)` receives every failure of a host callback the driver contained, with the name of the option that failed; without it such a failure is contained and dropped. |
28062
28628
  | `claudeFakeScenarios` | constant | the conformance scenarios in this dialect, for a scripted engine |
28063
28629
  | `claudeTranscriptPath` / `claudeTranscriptHasUuid` / `findTranscriptInput` | functions | offline Claude transcript path resolution (resolving `realpath` of `cwd` or its nearest existing ancestor) and bounded streaming UUID lookup / reconciliation without instantiating a driver |
28064
28630
  | `claudePlanWindows` / `claudeUsagePlanLimits` | functions | Claude's `rate_limit_event` windows and open-bucket usage / `/api/oauth/usage` `PlanLimits` mapping preserving `plan` and the reported model name as `scope` and `label` on model-scoped windows |
@@ -28079,7 +28645,7 @@ profile's transcript. Evolving.
28079
28645
 
28080
28646
  | Export | Kind | Purpose |
28081
28647
  |--------|------|---------|
28082
- | `createClaudeSdkDriver` / `ClaudeSdkDriver` / `ClaudeSdkDriverConfig` | function / _types_ | the driver: `query` and `sdkVersion` required; optional `forkSession`, `model`, `permissionMode` (default `default`), `allowDangerouslySkipPermissions`, `pathToClaudeCodeExecutable`, `systemPrompt`, `settingSources`, `enableFileCheckpointing`, `supportedDialogKinds` / `onUserDialog`, `hooks`, `tools`, `allowedTools`, `disallowedTools`, `mcpServers`, `mcpServersDelivery`, `strictMcpConfig`, `plugins`, `agents`, `extraArgs`, `stderr`, `spawnClaudeCodeProcess`, `onProviderPid`, `onQueryExit`, `onElicitation`, `onPermissionRequest`, `onEvent`, `onTurnUsage`, `verifyDelegation`, `resolveFile`, `maxImageBytes` (default 5 MiB), and `ambient`. Exposes `probeCapabilities(input)` for isolated never-yielding capability probes, `status` over passive `rate_limit_event` or active `readUsage()`, and `forkSession(sessionId, options?)` |
28648
+ | `createClaudeSdkDriver` / `ClaudeSdkDriver` / `ClaudeSdkDriverConfig` | function / _types_ | the driver: `query` and `sdkVersion` required; optional `forkSession`, `model`, `permissionMode` (default `default`), `allowDangerouslySkipPermissions`, `pathToClaudeCodeExecutable`, `systemPrompt`, `settingSources`, `enableFileCheckpointing`, `supportedDialogKinds` / `onUserDialog`, `hooks`, `tools`, `allowedTools`, `disallowedTools`, `mcpServers`, `mcpServersDelivery`, `strictMcpConfig`, `plugins`, `agents`, `extraArgs`, `stderr`, `spawnClaudeCodeProcess`, `onProviderPid`, `onQueryExit`, `onElicitation`, `onPermissionRequest`, `onEvent`, `onTurnUsage`, `verifyDelegation`, `resolveFile`, `maxImageBytes` (default 5 MiB), `ambient`, and `onObserverError`. `onObserverError(error, hook)` receives every failure of a host callback the driver contained, with the name of the option that failed; without it such a failure is contained and dropped. Exposes `probeCapabilities(input)` for isolated never-yielding capability probes, `status` over passive `rate_limit_event` or active `readUsage()`, and `forkSession(sessionId, options?)` |
28083
28649
  | `ClaudeSdkSession` / `ClaudeSdkOpenInput` / `ClaudeSdkUsageRead` / `ClaudeSdkQueryExitContext` / `ClaudeSdkPermissionRequestMeta` / `ClaudeSdkFlagSettings` | _types_ | extended session returned by `open(ClaudeSdkOpenInput)` (supporting `resumeSessionAt`, `resumeDropsTurn`, and `onStartupPhase`): exposes `providerPid`, `readUsage(opts?)`, `setModel`, `setPermissionMode` (returning `SDKControlSetPermissionModeResponse \| undefined`), `applyFlagSettings(ClaudeSdkFlagSettings)`, `initializationResult`, `supportedModels`, `supportedCommands`, `accountInfo`, `getContextUsage`, `mcpServerStatus`, `toggleMcpServer`, `reconnectMcpServer`, `setMcpServers`, `stopTask`, `backgroundTasks`, and `rewindFiles`; supports `approve` with `updatedInput` for `AskUserQuestion` and emits `ClaudeSdkPermissionRequestMeta` (`input: Readonly<Record<string, JsonRpcValue>>`) to `onPermissionRequest` |
28084
28650
  | `ClaudeRuntimeEventSchema` / `ClaudeRuntimeEvent` / `ClaudeTaskUsageSchema` / `ClaudeTaskUsage` / `ClaudeSdkTurnUsageSchema` / `ClaudeSdkTurnUsage` / `ClaudeSdkTokenPairSchema` / `ClaudeSdkTokenPair` | schemas / _types_ | structured runtime events delivered to `onEvent` during and after turns (`task_started`, `task_updated`, `task_progress`, `task_notification`, `background_tasks_changed`, `tool_progress`, `api_retry`, `elicitation_complete`) alongside `compact_boundary` → `window { reset: 'context' }`, plus per-turn additive `modelUsage` deltas and `otherUsage` delivered to `onTurnUsage` |
28085
28651
  | `ClaudeSdkProbeCapabilitiesInput` / `ClaudeSdkCapabilitiesProbe` | _types_ | input and result shapes for `driver.probeCapabilities(input)`: runs an isolated never-yielding SDK query to inspect models, commands, account info, and optional usage, always closing the query in `finally` |
@@ -28109,9 +28675,9 @@ approvals for unprompted tool calls. Explicit `approve` supports `scope: 'once'`
28109
28675
 
28110
28676
  | Export | Kind | Purpose |
28111
28677
  |--------|------|---------|
28112
- | `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`, `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); exposes `probeCapabilities(AcpProbeCapabilitiesInput)` for non-inference capability probing |
28113
- | `AcpSession` / `AcpOpenInput` / `AcpSteerTurnInput` / `AcpConfigOption` / `AcpConfigOptionChoice` / `acpOptionChoices` / `acpOptionValues` / `AcpApprovalEnforcement` | _types_ / functions | a session's `providerPid`, 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`) |
28114
- | `AcpProbeCapabilitiesInput` / `AcpCapabilitiesProbe` / `AcpProbeMode` / `AcpSteerMode` / `AcpSessionMetaInput` / `AcpWatchPromptOutcome` / `AcpPromptOutcomeOverride` | _types_ | non-inference capability probe input/result (running regardless of `probeMode` and calling both `session/close` and `session/delete` in `finally`), 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` |
28678
+ | `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 |
28679
+ | `AcpSession` / `AcpOpenInput` / `AcpSteerTurnInput` / `AcpConfigOption` / `AcpConfigOptionChoice` / `acpOptionChoices` / `acpOptionValues` / `AcpApprovalEnforcement` | _types_ / functions | a session's `providerPid`, its agent's `initialize` answer (`initialized`, with `agentCapabilities.promptCapabilities`), 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`) |
28680
+ | `AcpProbeCapabilitiesInput` / `AcpCapabilitiesProbe` / `AcpProbeMode` / `AcpSteerMode` / `AcpSessionMetaInput` / `AcpWatchPromptOutcome` / `AcpPromptOutcomeOverride` | _types_ | non-inference capability probe input/result (running regardless of `probeMode`; `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` |
28115
28681
  | `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`) |
28116
28682
  | `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` |
28117
28683
  | `AcpSessionSummary` | _type_ | a session the agent keeps: id, working directory, title, last update |
@@ -28138,7 +28704,7 @@ WebSocket-over-Unix-socket (`unix-listen` / `unix-connect`). Evolving.
28138
28704
 
28139
28705
  | Export | Kind | Purpose |
28140
28706
  |--------|------|---------|
28141
- | `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`), `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` |
28707
+ | `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 |
28142
28708
  | `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) |
28143
28709
  | `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` |
28144
28710
  | `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) |
@@ -28160,18 +28726,32 @@ WebSocket-over-Unix-socket (`unix-listen` / `unix-connect`). Evolving.
28160
28726
 
28161
28727
  | Export | Kind | Purpose |
28162
28728
  |--------|------|---------|
28163
- | `runAgentEngineConformance` / `AgentEngineConformanceConfig` / `AgentEngineDialectScenarios` | function / _types_ | prove a driver against its dialect's scripted engine: capabilities shape, text and reconcile, approvals, failures by kind, interrupts (including `interruptDuringApproval`, whose request must close with `request-resolved`, and `requestAfterInterrupt`, which the driver must refuse rather than offer), a request still held when the turn ends (`requestAtTurnEnd`, closed with `request-resolved` before the end) or when the engine dies (`requestThenCrash`), neither left open to the consumer's answer, a dead or garbled engine, unknown records, and a dispatch never sent twice |
28164
- | `createReplayExecutorDriver` / `ReplayExecutorDriver` / `ReplayExecutorDriverConfig` | function / _types_ | in-process, zero-subprocess, deterministic replay `AgentEngineDriver` over validated NDJSON transcripts for local dev and e2e tests; emulates any existing `ExecutorEngine` without widening `ExecutorEngineSchema` and provides `inputsFor`, `wasAnswered`, and `assertComplete` |
28165
- | `createReplayGate` / `ReplayGate` | function / _type_ | deterministic label-based synchronization gate pausing `{ kind: 'gate', label }` steps until `waitForReached` / `release` without timers |
28729
+ | `runAgentEngineConformance` / `AgentEngineConformanceConfig` / `AgentEngineDialectScenarios` | function / _types_ | prove a driver against its dialect's scripted engine: capabilities (what the driver declares is what `info()` reports, declared or not; a declared set matches the schema), text and reconcile, approvals, failures by kind, interrupts (including `interruptDuringApproval`, whose request must close with `request-resolved`, and `requestAfterInterrupt`, which the driver must refuse rather than offer), a request still held when the turn ends (`requestAtTurnEnd`, closed with `request-resolved` before the end) or when the engine dies (`requestThenCrash`), neither left open to the consumer's answer, a dead or garbled engine, unknown records, a dispatch never sent twice, and the session's life: `open` given an aborted signal, or one aborted from `onStartupPhase`, rejects with the signal's reason; an abort in a turn fails its stream with that reason and `respond` and `startTurn` reject with it; `interrupt` after the turn's end, an abort or a close resolves; `close()` in a turn fails the turn, resolves however often it is called and leaves `onStartupPhase` silent. Each of these waits at most 10 s, so a driver that hangs fails by the name of its check — give the test a longer timeout to read it |
28730
+ | `createReplayExecutorDriver` / `ReplayExecutorDriver` / `ReplayExecutorDriverConfig` | function / _types_ | in-process, zero-subprocess, deterministic replay `AgentEngineDriver` over validated NDJSON transcripts for local dev and e2e tests; emulates any existing `ExecutorEngine` without widening `ExecutorEngineSchema` and provides `inputsFor`, `wasAnswered`, and `assertComplete`; `onObserverError(error, hook)` receives a throwing `onStartupPhase`, as the real drivers' option does |
28731
+ | `createReplayGate` / `ReplayGate` | function / _type_ | deterministic label-based synchronization gate pausing `{ kind: 'gate', label }` steps until `waitForReached` / `release` without timers; a label is compared without its surrounding whitespace on every call |
28166
28732
  | `ExecutorReplayTranscriptSchema` / `ExecutorReplayTranscript` / `ExecutorReplayStepSchema` / `ExecutorReplayStep` / `parseReplayTranscript` / `ParseReplayTranscriptOptions` / `formatReplayTranscript` | schemas / functions / _types_ | strict Zod-validated NDJSON transcript format (bounded by `maxBytes` and `maxSteps`, substituting `<workspace>` placeholders) and round-trip parser/formatter |
28167
28733
  | `REPLAY_SCENARIOS` / `unpackReplayScenario` / `replayDialectScenarios` | constant / functions | built-in deterministic scenario presets (`'text-stream'`, `'approval'`, `'user-input'`, `'tool-calls'`, `'rate-limit'`, `'multi-turn'`, `'crash-mid-turn'`) and conformance dialect adapter |
28168
- | `createFakeCodexAppServer` / `FakeCodexAppServer` / `FakeCodexAppServerConfig` / `FakeCodexRpcHandler` / `FakeCodexRpcHandlerOutcome` / `FakeCodexRpcErrorOutcome` / `RecordedJsonRpcRequest` | function / _types_ | portable (Bun and Node.js) real Unix-socket WebSocket JSON-RPC fake Codex app-server for integration tests with `createCodexDriver({ transport: { kind: 'unix-connect' } })`: automatic `initialize` handshake, `'hang'` / DTO / RPC error handlers, `requests` recording, `sendNotification`, `sendRequest`, `sendRaw`, `disconnect()`, and idempotent `close()` |
28169
- | `createFakeClaudeSdkQuery` / `FakeClaudeSdkQueryConfig` / `FakeClaudeSdkQueryHarness` / `FakeClaudeSdkRunController` / `FakeClaudeSdkScriptedTurn` / `FakeClaudeSdkRecordedCall` | function / _types_ | scripted multi-turn in-process `ClaudeSdkQuery` harness over real `createClaudeSdkDriver` supporting `canUseTool` via `askPermission`, live control call recording, optional experimental usage attachment, and non-inference `probeCapabilities` |
28170
- | `createStubCodexControlClient` / `createStubCodexControlConnection` / `createStubCodexSession` / `createStubCodexSharedServer` / `createStubCodexTurn` / `createStubAgentEngineTurn` / `createStubClaudeSdkSession` / `createStubAcpSession` / `StubOverrides` / `StubAgentEngineTurnOverrides` / `StubCodexTurnOverrides` | functions / _types_ | fail-loud typed consumer stub factories (`exactOptionalPropertyTypes: true`-safe `StubOverrides<T>`, no-op `close()`, unexpected-call throws on unset methods) |
28734
+ | `createFakeCodexAppServer` / `FakeCodexAppServer` / `FakeCodexAppServerConfig` / `FakeCodexRpcHandler` / `FakeCodexRpcHandlerOutcome` / `FakeCodexRpcErrorOutcome` / `RecordedJsonRpcRequest` | function / _types_ | portable (Bun and Node.js) real Unix-socket WebSocket JSON-RPC fake Codex app-server for integration tests with `createCodexDriver({ transport: { kind: 'unix-connect' } })`: automatic `initialize` handshake, `'hang'` / DTO / RPC error handlers, `requests` recording, `sendNotification`, `sendRequest`, `sendRaw`, `disconnect()`, and idempotent `close()`; a server `error` after startup drops the connected clients, rejects their pending `sendRequest` calls and makes every later send throw with that error as `cause` |
28735
+ | `createStubCodexControlClient` / `createStubCodexControlConnection` / `createStubCodexSession` / `createStubCodexSharedServer` / `createStubCodexTurn` / `createStubAgentEngineTurn` / `createStubAcpSession` / `StubOverrides` / `StubAgentEngineTurnOverrides` / `StubCodexTurnOverrides` | functions / _types_ | fail-loud typed consumer stub factories (`exactOptionalPropertyTypes: true`-safe `StubOverrides<T>`, no-op `close()`, unexpected-call throws on unset methods); `createStubCodexSharedServer` declares the capabilities `createCodexDriver()` declares on its shared server |
28171
28736
  | `makeExecutorDelta` / `ExecutorDeltaInput` / `makeCodexNotificationEvent` / `CodexNotificationEventOverrides` / `makeCodexThreadFixture` | functions / _types_ | schema-validated fixture factories for `ExecutorDelta`, `CodexNotificationEvent`, and `CodexThread` |
28172
28737
  | `FakeEngineScenarioSchema` / `FakeEngineScenario` / `FakeEngineStepSchema` / `FakeEngineStep` | schemas / _types_ | a scripted engine turn in any dialect: expect, emit, delay, crash, exit |
28173
28738
  | `runFakeClaudeEngine` | function | play a scenario as Claude Code does on `stream-json` — the engine side of a Claude-dialect conformance test |
28174
28739
 
28740
+ This entrypoint declares no optional peer: a Codex or ACP driver's tests import it without
28741
+ `@anthropic-ai/claude-agent-sdk` installed, with `skipLibCheck: false`.
28742
+
28743
+ ---
28744
+
28745
+ ## `stitchkit/agent-executor/testing/claude-sdk`
28746
+
28747
+ The testing kit's Claude Agent SDK half. Its declarations name the types of the optional peer
28748
+ `@anthropic-ai/claude-agent-sdk`; it runs without the SDK. Evolving.
28749
+
28750
+ | Export | Kind | Purpose |
28751
+ |--------|------|---------|
28752
+ | `createFakeClaudeSdkQuery` / `FakeClaudeSdkQueryConfig` / `FakeClaudeSdkQueryHarness` / `FakeClaudeSdkRunController` / `FakeClaudeSdkScriptedTurn` / `FakeClaudeSdkRecordedCall` | function / _types_ | scripted multi-turn in-process `ClaudeSdkQuery` harness over real `createClaudeSdkDriver` supporting `canUseTool` via `askPermission`, live control call recording, optional experimental usage attachment, and non-inference `probeCapabilities` |
28753
+ | `createStubClaudeSdkSession` | function | fail-loud typed `ClaudeSdkSession` stub taking `StubOverrides<ClaudeSdkSession>` from `stitchkit/agent-executor/testing`: no-op `close()`, unexpected-call throws on unset methods |
28754
+
28175
28755
  ---
28176
28756
 
28177
28757
 
@@ -28830,6 +29410,7 @@ handler pipeline without opening a TCP port.
28830
29410
  | `SurfaceManifestOperation` / `SurfaceManifestOperationSchema` | _type_ / schema | one contract or runtime operation row |
28831
29411
  | `SurfaceManifestOperationMcp` / `SurfaceManifestOperationMcpSchema` | _type_ / schema | the rounds an operation declares before it runs: a fixed list, `'resolved-per-call'`, or `null` for no MCP policy |
28832
29412
  | `SurfaceManifestOperationToolView` / `SurfaceManifestOperationToolViewSchema` | _type_ / schema | an operation's declared tool view — digests of its defaults and output, and whether it projects; present only where a view is declared |
29413
+ | `SurfaceManifestOperationRefusal` / `SurfaceManifestOperationRefusalSchema` | _type_ / schema | one declared refusal of an operation — `{ code, status, details }` with the details schema digest; `refusals` is present only where an operation declares `refuses` |
28833
29414
  | `SURFACE_MANIFEST_VERSION` | const | the format version this build writes; a committed snapshot on an older one is refused by name |
28834
29415
  | `SurfaceManifestTool` / `SurfaceManifestToolSchema` | _type_ / schema | one mounted tool row with advertised input digest |
28835
29416
  | `SurfaceManifestToolSurface` / `SurfaceManifestToolSurfaceSchema` | _type_ / schema | one static transport projection, optionally keyed for a finite MCP surface |
@@ -29020,6 +29601,31 @@ Peer-free server-only evolving entrypoint for macOS signed `.app` launcher bundl
29020
29601
  | `CLANG_PATH` / `CODESIGN_PATH` / `ICONUTIL_PATH` / `PS_PATH` / `QLMANAGE_PATH` / `SECURITY_PATH` / `SIPS_PATH` / `canonicalizeMacosPath` / `normalizeMacosSyntheticPath` / `isPathWithinDirectory` / `createDefaultMacosCommandRunner` / `MacosCommandOptions` / `MacosCommandResult` / `MacosCommandRunner` | const / function / _types_ | absolute macOS utility paths, synthetic `/var`/`/tmp` path helpers and injectable command runner; the default runner passes a declared environment only (fixed `PATH`; `HOME`, `TMPDIR`, `DEVELOPER_DIR`, `SDKROOT`, `TOOLCHAINS` when set; the call's `env` on top) |
29021
29602
 
29022
29603
 
29604
+ ## `stitchkit/service-host/work`
29605
+
29606
+ Work launched in its own boundary with a declared owner. Guide: [Work in its own boundary](../guide/native-io.md#work-in-its-own-boundary). → ADR 0332
29607
+
29608
+ | Export | Kind | Summary |
29609
+ |--------|------|---------|
29610
+ | `launchWork` | function | launches a command in its boundary through the one native-command owner and resolves once its root is observed there; throws `WorkLaunchError` and starts nothing outside the asked boundary |
29611
+ | `WorkLaunchInput` / `WorkLaunchCommand` | type | `{ owner, placement, command }`; `command` is `NativeCommandOptions` without `group`, `ownerLoss` and `onLeaderStarted` |
29612
+ | `WorkLaunch` | type | `origin` (what the variable holds), `unit` (`{ manager, name }` or `null`), `root` (`{ pid, instance }`), `result` (settles like `runNativeCommand`) and `stop()` (ends the whole boundary) |
29613
+ | `workCommand` | function | the same placement as argv and environment for any spawner; a scope gets `STITCHKIT_WORK_ORIGIN` in `env`, a process root writes it itself |
29614
+ | `WorkCommandInput` / `WorkCommand` | type | `{ owner, placement, executable, args?, env }` → `{ executable, args, env, work, unit }` |
29615
+ | `probeWorkBoundary` / `WorkBoundaryAvailability` | function / type | whether this host can make a placement, without launching: `available`, or `unavailable` with `reason` and `cause` |
29616
+ | `checkWorkMembership` / `WorkMembership` / `WorkMembershipUnavailableReason` | function / type / type | asks the boundary whether a pid belongs to it: `member` (`via` `cgroup`, `root`, `process-group` or `ancestry`), `outside` with what was observed, `gone`, or `unavailable` (`platform-unsupported`, `proc-unreadable`, `cgroup-v2-required`, `root-unobservable`, `process-table-failed`) |
29617
+ | `inheritedWork` | function | the `WorkRef` the current process is proven to run in, or `null`; throws when the variable is unreadable or the boundary cannot be asked |
29618
+ | `readWorkOrigin` / `WORK_ORIGIN_ENV` | function / const | parses `STITCHKIT_WORK_ORIGIN` from an environment: `null` when absent, `WorkLaunchError('origin-unreadable')` when it does not parse or is of another version |
29619
+ | `WorkOriginSchema` / `WorkOrigin` | schema / type | `{ v: 1, work, boundary }` — the value of the variable |
29620
+ | `WorkBoundarySchema` / `WorkBoundary` | schema / type | `{ kind: 'transient-scope', manager, unit }` or `{ kind: 'process-root', root: { pid, instance } }` |
29621
+ | `WorkOwnerSchema` / `WorkOwner` | schema / type | the owner record: `launcher`, `id`, `label`, and `project`, `agent`, `parent` as a value or `null`; no optional field |
29622
+ | `WorkRefSchema` / `WorkRef` | schema / type | `{ launcher, id }` — a pointer to one owner record |
29623
+ | `WorkAgentSchema` / `WorkAgent` | schema / type | `{ harness, model, address }` of the agent that asked for the work |
29624
+ | `WorkPlacement` / `WorkScopePlacement` / `WorkScopeLimits` | type | `{ kind: 'transient-scope', manager: 'system' \| 'user', slice: 'caller' \| '<name>.slice', limits? }` or `{ kind: 'process-root' }`; limits `memoryMaxMb`, `memorySwapMaxMb`, `cpuQuotaPercent`, `cpuWeight`, `runtimeMaxSeconds` become unit properties |
29625
+ | `workUnitName` | function | `<launcher>-<id>.scope` for a `WorkRef`; one way only |
29626
+ | `WorkLaunchError` / `WorkLaunchErrorReason` | class / type | `reason` is `origin-unreadable`, `platform-unsupported`, `systemd-unavailable`, `systemd-too-old` (older than 254), `manager-unreachable`, `manager-unauthorized` (the system manager for a non-root caller), `user-manager-unreachable`, `slice-unresolvable`, `unit-exists`, `scope-refused`, `root-unobservable`, `root-unobserved`, `membership-unavailable` or `stop-failed`; `cause` holds what the host answered |
29627
+
29628
+
29023
29629
  ## `stitchkit/telegram`
29024
29630
 
29025
29631
  Peer-free server-only Telegram platform primitives — the Bot API's own
@@ -29756,13 +30362,13 @@ Native POSIX Bun/Node one-shot command execution. See [native IO](../guide/nativ
29756
30362
  | `ProcessInstanceSchema` / `ProcessInstance` | schema / type | platform, boot ID, namespace and process start identity from the shared native reader |
29757
30363
  | `probeProcessOwner` / `ProcessOwnerEvidence` | function / type | compare lifetimes on one caller-established machine; matched, boot change, reused PID, gone, legacy or unavailable with cause |
29758
30364
 
29759
- ## `stitchkit/process/owner-loss`
30365
+ ## `stitchkit/process/bootstrap`
29760
30366
 
29761
- Narrow startup entry for single-file applications that lazy-import `stitchkit/process`.
30367
+ Narrow startup entry for single-file applications that lazy-import `stitchkit/process` or `stitchkit/service-host/work`.
29762
30368
 
29763
30369
  | Export | Kind | Purpose |
29764
30370
  |---|---|---|
29765
- | `bootstrapNativeCommandOwnerLoss` | function | call before application argv routing; returns `true` only when the package guard owns this invocation, so the application skips its dispatcher while preserving a lazy import of the full command runner |
30371
+ | `bootstrapPackageProcess` | function | call before application argv routing; returns `true` only when the package owns this invocation — the owner-loss guard of `runNativeCommand`, or a process root of `stitchkit/service-host/work` that could not become its command — so the application skips its dispatcher while preserving a lazy import of the full runner |
29766
30372
 
29767
30373
  ## `stitchkit/files/packaging`
29768
30374
 
@@ -29802,15 +30408,20 @@ without splitting, preserve every output, and write each asset's `bytes` to its
29802
30408
  This evolving entrypoint is a build dependency; runtime imports do not reach it.
29803
30409
  The detailed recipe is in [native IO](../guide/native-io.md#public-native-packaging).
29804
30410
 
29805
- It also owns the build of a client into one self-contained file:
30411
+ It also owns the two builds of a client — one self-contained file, and a typed npm package:
29806
30412
 
29807
30413
  | Export | Kind | Summary |
29808
30414
  |--------|------|---------|
29809
- | `buildClientArtifact` | function | bundle a client entry into one self-contained file with its SHA-256, refuse forbidden modules in the graph, optionally pack and verify an npm archive — [guide](../guide/native-io.md#a-client-as-one-self-contained-file) |
29810
- | `ClientArtifactOptions` | _type_ | entry, output file, runtime, forbidden modules and the optional package to pack and verify |
29811
- | `ClientArtifact` | _type_ | the built file, its SHA-256 and size, the bundled modules and the verified archive |
29812
- | `ForbiddenModule` | _type_ | a package name, a source path fragment or a `RegExp` over module paths |
29813
- | `ForbiddenModuleError` | class | the refusal of a bundle that reaches a forbidden module: `module` and `importedBy` |
30415
+ | `buildClientArtifact` | function | bundle a client entry into one self-contained file with its SHA-256 and refuse forbidden modules in the graph — [guide](../guide/native-io.md#a-client-as-one-self-contained-file) |
30416
+ | `ClientArtifactOptions` | _type_ | entry, output file, runtime, forbidden modules, `executables.bun`, deadline and signal |
30417
+ | `ClientArtifact` | _type_ | the built file, its SHA-256 and size, and the bundled modules |
30418
+ | `buildClientPackage` | function | build several entries of a typed client into one npm archive over one module graph, with peers and dependencies outside and declarations that resolve under Bundler and NodeNext, and return it only after the archive was installed, imported in Node and Bun and typechecked by a strict consumer — [guide](../guide/native-io.md#a-typed-client-as-an-npm-package), [ADR 0331](../decisions/0331-a-client-package-is-one-module-graph-proven-installed.md) |
30419
+ | `ClientPackageOptions` | _type_ | name, version, `entries` by subpath, `tsconfig`, peers and dependencies, forbidden modules, runtime, output directory, `manifest`, extra `files`, `proof` (consumer sources, required and distinct exports, type packages), `executables`, deadline and signal |
30420
+ | `ClientPackageManifest` | _type_ | descriptive `package.json` fields of the package; a field the build writes itself is refused |
30421
+ | `ClientPackage` | _type_ | the archive with its SHA-256 and size, every packed file with its digest, the bundled modules, exports per subpath, the names proven shared across subpaths, and what the proof ran |
30422
+ | `ClientPackageError` | class | the refusal of a client package: a closed `reason` and `details` naming the file, specifier, package or names |
30423
+ | `ForbiddenModule` | _type_ | a package name or subpath, a source path fragment or a `RegExp` over module paths |
30424
+ | `ForbiddenModuleError` | class | the refusal of a client that reaches a forbidden module, bundled or left external: `module` and `importedBy` |
29814
30425
 
29815
30426
  ## `stitchkit/handler`
29816
30427