stitchkit 0.136.7 → 0.137.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 (358) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/dist/agent-runtime/stores/branch-observations.d.ts +19 -19
  3. package/dist/agent-runtime/stores/schedule-contract.d.ts.map +1 -1
  4. package/dist/agent-runtime/stores/schedule-records.d.ts.map +1 -1
  5. package/dist/agent-runtime/stores/schedule-tools.d.ts.map +1 -1
  6. package/dist/agent-runtime/stores/sql-rows.d.ts +36 -36
  7. package/dist/agent-runtime/terminal-commit.d.ts +5 -5
  8. package/dist/agent-runtime/testing/store-conformance-lifecycle.d.ts +52 -52
  9. package/dist/agent-runtime/testing/store-conformance-support.d.ts +26 -26
  10. package/dist/browser/client-executors.d.ts +2 -3
  11. package/dist/browser/client-executors.d.ts.map +1 -1
  12. package/dist/browser/realtime-client.d.ts +6 -1
  13. package/dist/browser/realtime-client.d.ts.map +1 -1
  14. package/dist/browser/socket-io-client.d.ts.map +1 -1
  15. package/dist/browser/socket-io-contract.d.ts +2 -0
  16. package/dist/browser/socket-io-contract.d.ts.map +1 -1
  17. package/dist/contract/define-validation.d.ts +6 -0
  18. package/dist/contract/define-validation.d.ts.map +1 -1
  19. package/dist/contract/define.d.ts +1 -1
  20. package/dist/contract/define.d.ts.map +1 -1
  21. package/dist/contract/error-mapping.d.ts +71 -0
  22. package/dist/contract/error-mapping.d.ts.map +1 -0
  23. package/dist/contract/errors.d.ts +8 -0
  24. package/dist/contract/errors.d.ts.map +1 -1
  25. package/dist/contract/factory.d.ts +8 -0
  26. package/dist/contract/factory.d.ts.map +1 -1
  27. package/dist/contract/fragments.d.ts +45 -0
  28. package/dist/contract/fragments.d.ts.map +1 -0
  29. package/dist/contract/normalize.d.ts +6 -3
  30. package/dist/contract/normalize.d.ts.map +1 -1
  31. package/dist/contract/operation-read.d.ts +38 -0
  32. package/dist/contract/operation-read.d.ts.map +1 -0
  33. package/dist/contract/stream.d.ts.map +1 -1
  34. package/dist/contract/time-zone.d.ts +31 -0
  35. package/dist/contract/time-zone.d.ts.map +1 -0
  36. package/dist/contract/tool-options.d.ts +1 -1
  37. package/dist/contract/tool-options.d.ts.map +1 -1
  38. package/dist/device-relay/hub.d.ts +1 -1
  39. package/dist/device-relay/hub.d.ts.map +1 -1
  40. package/dist/entrypoints/agent-executor/acp.js +9 -9
  41. package/dist/entrypoints/agent-executor/claude-sdk.js +11 -11
  42. package/dist/entrypoints/agent-executor/claude.js +8 -8
  43. package/dist/entrypoints/agent-executor/codex.js +15 -15
  44. package/dist/entrypoints/agent-executor/testing.js +11 -11
  45. package/dist/entrypoints/agent-executor.js +14 -13
  46. package/dist/entrypoints/agent-runtime/ai-sdk.js +5 -5
  47. package/dist/entrypoints/agent-runtime/anthropic.js +1 -1
  48. package/dist/entrypoints/agent-runtime/browser.js +5 -5
  49. package/dist/entrypoints/agent-runtime/coding-tools.js +3 -3
  50. package/dist/entrypoints/agent-runtime/harness.js +14 -15
  51. package/dist/entrypoints/agent-runtime/openai.js +1 -1
  52. package/dist/entrypoints/agent-runtime/openrouter.js +7 -7
  53. package/dist/entrypoints/agent-runtime/postgres.js +5 -5
  54. package/dist/entrypoints/agent-runtime/realtime.js +8 -8
  55. package/dist/entrypoints/agent-runtime/sandbox.js +7 -7
  56. package/dist/entrypoints/agent-runtime/sqlite/bun.js +6 -6
  57. package/dist/entrypoints/agent-runtime/sqlite/node.js +6 -6
  58. package/dist/entrypoints/agent-runtime/testing.js +5 -5
  59. package/dist/entrypoints/agent-runtime.js +33 -29
  60. package/dist/entrypoints/application/diagnostic-journal.js +3 -3
  61. package/dist/entrypoints/application/directory-inbox.js +1 -1
  62. package/dist/entrypoints/application/grammy.js +1 -1
  63. package/dist/entrypoints/application/opentelemetry.js +2 -2
  64. package/dist/entrypoints/application.js +10 -10
  65. package/dist/entrypoints/cli/publish.d.ts +4 -4
  66. package/dist/entrypoints/cli/publish.d.ts.map +1 -1
  67. package/dist/entrypoints/cli/publish.js +160 -52
  68. package/dist/entrypoints/cli.d.ts +3 -1
  69. package/dist/entrypoints/cli.d.ts.map +1 -1
  70. package/dist/entrypoints/cli.js +520 -59
  71. package/dist/entrypoints/contract.d.ts +5 -1
  72. package/dist/entrypoints/contract.d.ts.map +1 -1
  73. package/dist/entrypoints/contract.js +25 -7
  74. package/dist/entrypoints/device-relay.js +20 -10
  75. package/dist/entrypoints/files/packaging.js +2 -2
  76. package/dist/entrypoints/files.js +10 -10
  77. package/dist/entrypoints/handler.d.ts +1 -1
  78. package/dist/entrypoints/handler.d.ts.map +1 -1
  79. package/dist/entrypoints/handler.js +12 -12
  80. package/dist/entrypoints/http.js +13 -12
  81. package/dist/entrypoints/index.js +36 -18
  82. package/dist/entrypoints/live.d.ts +2 -1
  83. package/dist/entrypoints/live.d.ts.map +1 -1
  84. package/dist/entrypoints/live.js +630 -1
  85. package/dist/entrypoints/node.d.ts +5 -0
  86. package/dist/entrypoints/node.d.ts.map +1 -1
  87. package/dist/entrypoints/node.js +36 -16
  88. package/dist/entrypoints/observability.js +25 -10
  89. package/dist/entrypoints/postgres.d.ts +4 -1
  90. package/dist/entrypoints/postgres.d.ts.map +1 -1
  91. package/dist/entrypoints/postgres.js +312 -0
  92. package/dist/entrypoints/primitives.js +11 -4
  93. package/dist/entrypoints/process.js +7 -7
  94. package/dist/entrypoints/react.js +1 -1
  95. package/dist/entrypoints/realtime.js +3 -3
  96. package/dist/entrypoints/remote.js +6 -29
  97. package/dist/entrypoints/server.d.ts +6 -1
  98. package/dist/entrypoints/server.d.ts.map +1 -1
  99. package/dist/entrypoints/server.js +93 -32
  100. package/dist/entrypoints/service-host/macos.js +6 -6
  101. package/dist/entrypoints/service-host/work.js +6 -6
  102. package/dist/entrypoints/service-host.js +10 -10
  103. package/dist/entrypoints/spend.js +2 -1
  104. package/dist/entrypoints/sync.js +5 -5
  105. package/dist/entrypoints/telegram.js +8 -8
  106. package/dist/entrypoints/testing.d.ts +1 -0
  107. package/dist/entrypoints/testing.d.ts.map +1 -1
  108. package/dist/entrypoints/testing.js +1501 -13
  109. package/dist/entrypoints/tools/agent.js +6 -7
  110. package/dist/entrypoints/tools/connections.js +9 -11
  111. package/dist/entrypoints/tools/contract.js +1 -2
  112. package/dist/entrypoints/tools/invoker.js +4 -5
  113. package/dist/entrypoints/tools/mcp.js +10 -11
  114. package/dist/entrypoints/tools/toolkit.d.ts +1 -1
  115. package/dist/entrypoints/tools/toolkit.d.ts.map +1 -1
  116. package/dist/entrypoints/tools/toolkit.js +29 -24
  117. package/dist/entrypoints/tools.js +28 -30
  118. package/dist/entrypoints/tracking/contract.js +2 -1
  119. package/dist/entrypoints/xlsx.js +5 -8
  120. package/dist/{index-033tyx59.js → index-0zw0hcyg.js} +4 -1
  121. package/dist/{index-zcq3dby3.js → index-1bjwfnnj.js} +1 -1
  122. package/dist/{index-f103md2v.js → index-1cfacbe2.js} +88 -23
  123. package/dist/{index-gj4wdts6.js → index-1ckh9qx1.js} +1 -1
  124. package/dist/index-1pvwmbxp.js +1435 -0
  125. package/dist/{index-0s75mjh7.js → index-2e4hdh32.js} +1 -1
  126. package/dist/{index-3shdhzt6.js → index-2j0pqxkn.js} +12 -6
  127. package/dist/index-3k8w02se.js +28 -0
  128. package/dist/{index-7fjbdga8.js → index-3pb4ccj2.js} +8 -0
  129. package/dist/{index-w7e402wx.js → index-48kb4gqq.js} +46 -7
  130. package/dist/{index-cv9b7fz2.js → index-6rws2xf5.js} +8 -0
  131. package/dist/{index-bbpygynk.js → index-77w5vx0g.js} +1 -1
  132. package/dist/index-7dz1ngaf.js +35 -0
  133. package/dist/{index-y68gavb5.js → index-7n4atsm4.js} +1 -1
  134. package/dist/index-8ef1bfea.js +71 -0
  135. package/dist/{index-0x4mnwg5.js → index-8k3y9nd4.js} +6 -9
  136. package/dist/{index-ezwsqyad.js → index-8rkdkefj.js} +40 -23
  137. package/dist/{index-3cwq5byx.js → index-9nax7tkn.js} +2 -2
  138. package/dist/{index-dz6tstcp.js → index-9r6emjwz.js} +1 -1
  139. package/dist/{index-32ew02z1.js → index-c4b7d6ej.js} +5 -5
  140. package/dist/index-ceshyndf.js +284 -0
  141. package/dist/{index-w161azza.js → index-d13rw31w.js} +6 -6
  142. package/dist/{index-1h0dtfz3.js → index-dmm7vs3f.js} +1 -1
  143. package/dist/{index-ypm85xwe.js → index-dp8j2e77.js} +1 -1
  144. package/dist/{index-qqd979f7.js → index-edycjvrv.js} +9 -9
  145. package/dist/{index-18qdpbcq.js → index-egpf9dv0.js} +200 -1479
  146. package/dist/{index-fatke81t.js → index-ezgvsj9w.js} +2 -2
  147. package/dist/{index-chapre0y.js → index-f3e7tj1g.js} +1 -1
  148. package/dist/{index-df5xr2f9.js → index-frsd2a94.js} +16 -1
  149. package/dist/index-fy9mmek1.js +95 -0
  150. package/dist/{index-2331y2tf.js → index-g0gvfzrx.js} +12 -12
  151. package/dist/index-gpe8d1ka.js +19 -0
  152. package/dist/{index-4p2zx593.js → index-gyw4qd0m.js} +1 -1
  153. package/dist/index-gzqy81tw.js +172 -0
  154. package/dist/{index-yrhw10ef.js → index-h34c510q.js} +8 -4
  155. package/dist/{index-rr94xcj6.js → index-h527p1yj.js} +10 -4
  156. package/dist/{index-qj0sq69b.js → index-hgf1tbgz.js} +76 -16
  157. package/dist/{index-smvmnz5y.js → index-hvpan32x.js} +1 -1
  158. package/dist/{index-4gbybjg6.js → index-hxawqrb6.js} +2 -2
  159. package/dist/{index-0k1ba0ss.js → index-j91jffhv.js} +1 -1
  160. package/dist/{index-d01akj5n.js → index-jr4kwetx.js} +8 -8
  161. package/dist/{index-xqppqn97.js → index-ka6z48zc.js} +315 -69
  162. package/dist/{index-by8w2461.js → index-kw0segzt.js} +104 -3
  163. package/dist/{index-6f4fjygr.js → index-m5t4dr7h.js} +29 -7
  164. package/dist/{index-afaq0nc4.js → index-n0egp1ke.js} +1 -1
  165. package/dist/{index-9fzjgg86.js → index-n74rb1dq.js} +2 -2
  166. package/dist/{index-dwq6a6sq.js → index-pt25vmhc.js} +33 -16
  167. package/dist/{index-vwg0n3e6.js → index-pyazb8q4.js} +23 -14
  168. package/dist/{index-5md04mwc.js → index-qpjjbkc5.js} +4 -4
  169. package/dist/{index-08a3qfr8.js → index-r1qt6zgj.js} +1 -1
  170. package/dist/{index-ctaxjpa4.js → index-r709pqed.js} +1 -1
  171. package/dist/{index-2zrx0nzv.js → index-rzc40z6e.js} +3 -5
  172. package/dist/{index-gq35s3bm.js → index-s5axtd56.js} +2 -2
  173. package/dist/{index-edpkm3k7.js → index-scpcps66.js} +669 -16
  174. package/dist/{index-ry8m2mhg.js → index-sf2mt6wj.js} +1 -1
  175. package/dist/{index-tjhhsnjv.js → index-t1213r0t.js} +1 -1
  176. package/dist/{index-gvgtmt7a.js → index-t7efje30.js} +2 -2
  177. package/dist/{index-w3s79kcb.js → index-tzyk36dy.js} +1 -1
  178. package/dist/{index-8tn10tp6.js → index-v64bvwjr.js} +1 -1
  179. package/dist/{index-1fhbe4e4.js → index-vksbsqpb.js} +1 -1
  180. package/dist/{index-dxft2mnm.js → index-wdg7bswj.js} +1 -1
  181. package/dist/{index-ppy23bd2.js → index-wjx1zs2r.js} +7 -578
  182. package/dist/{index-efbzm2se.js → index-x2r0ma9t.js} +1 -1
  183. package/dist/{index-kd48gk7d.js → index-x8py72a3.js} +1 -1
  184. package/dist/index-xvydbxmk.js +1404 -0
  185. package/dist/index-xwaphv0d.js +31 -0
  186. package/dist/{index-a09r9ff0.js → index-y44j39yk.js} +1 -1
  187. package/dist/{index-7mjsb7zv.js → index-ybrrxjhb.js} +1 -1
  188. package/dist/{index-xsrma0jd.js → index-ysthxsa8.js} +6 -6
  189. package/dist/{index-6p5pshcd.js → index-yyh3ey4b.js} +1 -1
  190. package/dist/{index-mr3njw67.js → index-z6hq9j8j.js} +1 -1
  191. package/dist/{index-67mzzkdv.js → index-z72agxdn.js} +2 -2
  192. package/dist/{index-e4w0sfm1.js → index-z78mtc16.js} +1 -1
  193. package/dist/{index-7csn6pva.js → index-ze94h4ph.js} +5 -0
  194. package/dist/internal/json-stringify.d.ts +12 -0
  195. package/dist/internal/json-stringify.d.ts.map +1 -1
  196. package/dist/internal/unix-client-error.d.ts +4 -0
  197. package/dist/internal/unix-client-error.d.ts.map +1 -1
  198. package/dist/live/watch-contract.d.ts +4 -0
  199. package/dist/live/watch-contract.d.ts.map +1 -1
  200. package/dist/live/watch-fanout-frame.d.ts +81 -0
  201. package/dist/live/watch-fanout-frame.d.ts.map +1 -0
  202. package/dist/live/watch-fanout.d.ts +57 -0
  203. package/dist/live/watch-fanout.d.ts.map +1 -0
  204. package/dist/observability/audit.d.ts.map +1 -1
  205. package/dist/observability/spool-core.d.ts +1 -0
  206. package/dist/observability/spool-core.d.ts.map +1 -1
  207. package/dist/observability/spool-drain.d.ts +48 -0
  208. package/dist/observability/spool-drain.d.ts.map +1 -0
  209. package/dist/observability/spool.d.ts +12 -6
  210. package/dist/observability/spool.d.ts.map +1 -1
  211. package/dist/postgres/connection-config.d.ts +54 -0
  212. package/dist/postgres/connection-config.d.ts.map +1 -0
  213. package/dist/postgres/rollback-transaction.d.ts +61 -0
  214. package/dist/postgres/rollback-transaction.d.ts.map +1 -0
  215. package/dist/primitives/deadline.d.ts +4 -4
  216. package/dist/primitives/deadline.d.ts.map +1 -1
  217. package/dist/server/error-hook.d.ts +3 -32
  218. package/dist/server/error-hook.d.ts.map +1 -1
  219. package/dist/server/local-consent-key.d.ts +104 -0
  220. package/dist/server/local-consent-key.d.ts.map +1 -0
  221. package/dist/server/local-control-journal.d.ts +51 -0
  222. package/dist/server/local-control-journal.d.ts.map +1 -0
  223. package/dist/server/local-control-reporter.d.ts +32 -0
  224. package/dist/server/local-control-reporter.d.ts.map +1 -0
  225. package/dist/server/local-control.d.ts +48 -0
  226. package/dist/server/local-control.d.ts.map +1 -0
  227. package/dist/server/local-host-clients.d.ts +105 -0
  228. package/dist/server/local-host-clients.d.ts.map +1 -0
  229. package/dist/server/middleware/trust-fence.d.ts +20 -0
  230. package/dist/server/middleware/trust-fence.d.ts.map +1 -1
  231. package/dist/spend/receipt-spool.d.ts +9 -4
  232. package/dist/spend/receipt-spool.d.ts.map +1 -1
  233. package/dist/testing/tool-surface-checks.d.ts +89 -0
  234. package/dist/testing/tool-surface-checks.d.ts.map +1 -0
  235. package/dist/testing/tool-surface-cli-callable.d.ts +63 -0
  236. package/dist/testing/tool-surface-cli-callable.d.ts.map +1 -0
  237. package/dist/testing/tool-surface-dead-refs.d.ts +32 -0
  238. package/dist/testing/tool-surface-dead-refs.d.ts.map +1 -0
  239. package/dist/testing/tool-surface-gates.d.ts +72 -0
  240. package/dist/testing/tool-surface-gates.d.ts.map +1 -0
  241. package/dist/testing/tool-surface-parity-drivers.d.ts +56 -0
  242. package/dist/testing/tool-surface-parity-drivers.d.ts.map +1 -0
  243. package/dist/testing/tool-surface-parity.d.ts +28 -0
  244. package/dist/testing/tool-surface-parity.d.ts.map +1 -0
  245. package/dist/testing/tool-surface-ratchet.d.ts +71 -0
  246. package/dist/testing/tool-surface-ratchet.d.ts.map +1 -0
  247. package/dist/tools/agent-tools.d.ts +3 -0
  248. package/dist/tools/agent-tools.d.ts.map +1 -1
  249. package/dist/tools/cli/command.d.ts +3 -0
  250. package/dist/tools/cli/command.d.ts.map +1 -1
  251. package/dist/tools/cli/create-cli.d.ts.map +1 -1
  252. package/dist/tools/cli/distribution-config.d.ts +39 -1
  253. package/dist/tools/cli/distribution-config.d.ts.map +1 -1
  254. package/dist/tools/cli/distribution-routes.d.ts +4 -2
  255. package/dist/tools/cli/distribution-routes.d.ts.map +1 -1
  256. package/dist/tools/cli/format.d.ts +3 -6
  257. package/dist/tools/cli/format.d.ts.map +1 -1
  258. package/dist/tools/cli/invoke.d.ts +4 -0
  259. package/dist/tools/cli/invoke.d.ts.map +1 -1
  260. package/dist/tools/cli/local-key-command.d.ts +53 -0
  261. package/dist/tools/cli/local-key-command.d.ts.map +1 -0
  262. package/dist/tools/cli/managed-surface.d.ts.map +1 -1
  263. package/dist/tools/cli/publication-contract.d.ts +9 -2
  264. package/dist/tools/cli/publication-contract.d.ts.map +1 -1
  265. package/dist/tools/cli/publication.d.ts.map +1 -1
  266. package/dist/tools/cli/run-managed.d.ts.map +1 -1
  267. package/dist/tools/cli/run-stream.d.ts.map +1 -1
  268. package/dist/tools/cli/runner.d.ts +8 -3
  269. package/dist/tools/cli/runner.d.ts.map +1 -1
  270. package/dist/tools/cli/secret.d.ts +55 -0
  271. package/dist/tools/cli/secret.d.ts.map +1 -0
  272. package/dist/tools/cli/session.d.ts +2 -2
  273. package/dist/tools/cli/session.d.ts.map +1 -1
  274. package/dist/tools/cli/signature.d.ts +23 -9
  275. package/dist/tools/cli/signature.d.ts.map +1 -1
  276. package/dist/tools/cli/stream.d.ts.map +1 -1
  277. package/dist/tools/cli/unix-outcome.d.ts +6 -0
  278. package/dist/tools/cli/unix-outcome.d.ts.map +1 -1
  279. package/dist/tools/cli/update.d.ts +6 -1
  280. package/dist/tools/cli/update.d.ts.map +1 -1
  281. package/dist/tools/execute-result.d.ts +20 -0
  282. package/dist/tools/execute-result.d.ts.map +1 -1
  283. package/dist/tools/execute.d.ts +3 -0
  284. package/dist/tools/execute.d.ts.map +1 -1
  285. package/dist/tools/internal/json-projection.d.ts +13 -9
  286. package/dist/tools/internal/json-projection.d.ts.map +1 -1
  287. package/dist/tools/internal/remote-error.d.ts +15 -0
  288. package/dist/tools/internal/remote-error.d.ts.map +1 -0
  289. package/dist/tools/internal/surface-projector.d.ts +2 -0
  290. package/dist/tools/internal/surface-projector.d.ts.map +1 -1
  291. package/dist/tools/invoker.d.ts +3 -0
  292. package/dist/tools/invoker.d.ts.map +1 -1
  293. package/dist/tools/mcp/handler.d.ts.map +1 -1
  294. package/dist/tools/mcp/lazy-discovery.d.ts +2 -0
  295. package/dist/tools/mcp/lazy-discovery.d.ts.map +1 -1
  296. package/dist/tools/mcp/mount.d.ts +5 -0
  297. package/dist/tools/mcp/mount.d.ts.map +1 -1
  298. package/dist/tools/mcp/register.d.ts +2 -0
  299. package/dist/tools/mcp/register.d.ts.map +1 -1
  300. package/dist/tools/mcp/runtime-tools.d.ts +2 -0
  301. package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
  302. package/dist/tools/mcp/stdio.d.ts.map +1 -1
  303. package/dist/tools/mount.d.ts +3 -0
  304. package/dist/tools/mount.d.ts.map +1 -1
  305. package/dist/tools/read-operation.d.ts +2 -6
  306. package/dist/tools/read-operation.d.ts.map +1 -1
  307. package/dist/tools/remote.d.ts.map +1 -1
  308. package/dist/tools/runtime-tool.d.ts.map +1 -1
  309. package/dist/tools/toolkit.d.ts +10 -3
  310. package/dist/tools/toolkit.d.ts.map +1 -1
  311. package/dist/xlsx/schema.d.ts.map +1 -1
  312. package/llms/cli-publish.txt +4 -1
  313. package/llms/cli.2.txt +42 -51
  314. package/llms/cli.3.txt +34 -1
  315. package/llms/cli.txt +18 -3
  316. package/llms/contract.txt +47 -5
  317. package/llms/handler.txt +1 -1
  318. package/llms/live.txt +82 -0
  319. package/llms/node.txt +5 -0
  320. package/llms/observability.2.txt +1 -1
  321. package/llms/observability.txt +6 -0
  322. package/llms/postgres.txt +14 -3
  323. package/llms/server.2.txt +206 -240
  324. package/llms/server.3.txt +242 -202
  325. package/llms/server.4.txt +202 -1025
  326. package/llms/server.5.txt +1053 -255
  327. package/llms/server.6.txt +274 -0
  328. package/llms/server.txt +32 -116
  329. package/llms/spend.txt +8 -7
  330. package/llms/stitchkit.2.txt +13 -35
  331. package/llms/stitchkit.3.txt +27 -0
  332. package/llms/stitchkit.txt +82 -82
  333. package/llms/testing.txt +40 -0
  334. package/llms/tools-toolkit.txt +2 -2
  335. package/llms/tools.2.txt +29 -20
  336. package/llms/{upgrading-0.128.0-0.129.0.txt → upgrading-0.128.0-0.131.0.txt} +101 -3
  337. package/llms/{upgrading-0.130.0-0.136.0.txt → upgrading-0.132.0-0.137.0.txt} +62 -101
  338. package/llms/upgrading.txt +2 -2
  339. package/llms-full.txt +641 -189
  340. package/llms.txt +14 -14
  341. package/package.json +3 -3
  342. package/dist/index-9118dw8d.js +0 -603
  343. package/dist/index-9vj869rx.js +0 -19
  344. package/dist/index-a1rjr381.js +0 -114
  345. package/dist/index-dacxr7nf.js +0 -17
  346. package/dist/index-dm50x3by.js +0 -63
  347. package/dist/index-dmrx8xma.js +0 -163
  348. package/dist/index-ednf2cxs.js +0 -37
  349. package/dist/{index-e4zt2x70.js → index-3czppvrr.js} +3 -3
  350. package/dist/{index-42n9jycn.js → index-3f79t32b.js} +3 -3
  351. package/dist/{index-mfe9a266.js → index-84n49vam.js} +0 -0
  352. package/dist/{index-f16b7rze.js → index-er1tp8de.js} +3 -3
  353. package/dist/{index-k137ezb6.js → index-f5d0fdcf.js} +3 -3
  354. package/dist/{index-65p8v81y.js → index-psz8qrz0.js} +3 -3
  355. package/dist/{index-kadgaw1s.js → index-r8cq86h1.js} +0 -0
  356. package/dist/{index-1yky29qg.js → index-tyyvbarf.js} +0 -0
  357. package/dist/{index-tjakdpf2.js → index-wq71v08n.js} +3 -3
  358. package/dist/{index-7an2fs5h.js → index-wswcpbm4.js} +3 -3
package/llms-full.txt CHANGED
@@ -47,88 +47,88 @@ 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 6 of the 43 minors since 0.94.0, most recently 0.135.0_ | `defineContract`, `createClient`, `createHttpClient`, `createSocketIOClient`, `parseSSE`, the error model |
51
- | `stitchkit/http` | browser, React Native/Hermes **and** server | evolving<br>_redefined in 3 of the 43 minors since 0.94.0, most recently 0.135.0_ | typed HTTP client factories, `ApiError`, `readContractIdentity` and the stream line errors, without optional realtime peers |
52
- | `stitchkit/realtime` | browser, React Native/Hermes **and** server | evolving<br>_redefined in 1 of the 43 minors since 0.94.0, most recently 0.127.0_ | typed realtime clients, binding to an existing socket and retained topics with a required explicit Socket.IO peer loader |
53
- | `stitchkit/device-relay` | browser, React Native/Hermes **and** server | evolving<br>_redefined in 0 of the 3 minors since 0.134.0_ | peer-free User Device Relay over realtime — `createDeviceRelayHub`, `createDeviceRelayAgent`, `createMemoryRelayBroker`, `deviceRelayRealtimeContract`, Fetch-compatible unary RPC and credit-paced cursor streams |
54
- | `stitchkit/contract` | browser **and** server | stable<br>_redefined in 6 of the 43 minors since 0.94.0, most recently 0.136.0_ | the contract layer alone — `defineContract`, errors, pagination |
55
- | `stitchkit/live` | browser **and** server | evolving<br>_redefined in 2 of the 43 minors since 0.94.0, most recently 0.127.0_ | `defineEvents` — topic declarations beside the operation contract — and watched reads: `createWatchClient`, the value/difference frame and its reassembly |
56
- | `stitchkit/primitives` | browser **and** server | evolving<br>_redefined in 0 of the 43 minors since 0.94.0_ | generic values and declarations for lifecycle, access, audit, delivery and exports, exact money and rounding tables |
57
- | `stitchkit/handler` | browser, React Native/Hermes **and** server | evolving<br>_redefined in 1 of the 10 minors since 0.127.0, most recently 0.136.0_ | portable `createHandler`, `implement`, errors and `serveBridge` over a string `postMessage` port, with no Node built-ins |
58
- | `stitchkit/server` | server (Bun) | stable<br>_redefined in 6 of the 43 minors since 0.94.0, most recently 0.136.0_ | `createServer`, `implement`, hooks, auth, Socket.IO server, server primitives |
59
- | `stitchkit/node` | server (Node ≥ 22.3) | stable<br>_redefined in 3 of the 43 minors since 0.94.0, most recently 0.136.0_ | `serveNode` + the runtime-agnostic core — the Node mirror of `/server` |
60
- | `stitchkit/tools` | server | stable<br>_redefined in 13 of the 43 minors since 0.94.0, most recently 0.136.0_ | the transport-neutral tool layer — `mountAgentTools`, `defineAgentTool`, registry, tool names and manifest, runtime tools, native tools, the OAuth provider, the durability engine; loads no optional peer at runtime |
61
- | `stitchkit/tools/mcp` | server (Bun or Node) | evolving<br>_redefined in 3 of the 43 minors since 0.94.0, most recently 0.127.0_ | the canonical MCP HTTP/stdio server, schemas and typed MCP presenters; only Zod and the MCP server SDK peers |
62
- | `stitchkit/tools/agent` | server (Bun or Node) | evolving<br>_redefined in 2 of the 43 minors since 0.94.0, most recently 0.134.0_ | `mountAgent` — thin AI SDK `ToolSet` adapter over `mountAgentTools` for apps driving their own SDK loop; only Zod and the `ai` peer |
63
- | `stitchkit/tools/toolkit` | server (Bun or Node) | evolving<br>_redefined in 2 of the 43 minors since 0.94.0, most recently 0.135.0_ | `createToolkit` — context-pinned MCP, peer-free agent (`mountAgentTools`), and CLI mounts; only the MCP server SDK peer (no `ai` peer) |
64
- | `stitchkit/tools/contract` | browser + server | evolving<br>_redefined in 2 of the 43 minors since 0.94.0, most recently 0.124.0_ | the shapes a tool surface speaks — async-operation contract, snapshot and cancel schemas, view-file input/output — without the runtime that serves them |
65
- | `stitchkit/tools/invoker` | server | stable<br>_redefined in 3 of the 43 minors since 0.94.0, most recently 0.127.0_ | peer-free `createToolInvoker` over the canonical contract tool runner |
66
- | `stitchkit/tools/connections` | server (Bun or Node) | evolving<br>_redefined in 3 of the 43 minors since 0.94.0, most recently 0.127.0_ | consume external MCP servers and a bounded OpenAPI subset — typed reauthorization, a per-request host fence and per-call credentials |
67
- | `stitchkit/cli` | server | stable<br>_redefined in 12 of the 43 minors since 0.94.0, most recently 0.128.0_ | `createCli` / `createCliInvoker` — runtime and strict NodeNext declarations without MCP SDK / `ai` |
68
- | `stitchkit/cli/publish` | build, release and server tooling (Bun or Node, POSIX) | evolving<br>_redefined in 0 of the 43 minors since 0.94.0_ | `publishCli`, shipping-input versioning (`deriveCliVersionFromShippingInputs`, `cliShippingInputsChanged`, `assertCleanCliSource`), and `createCliDistributionRoutes` (`RawRoute[]` channel manifest, asset and installer routes); see [CLI guide](cli.md#publishing-a-complete-version) |
69
- | `stitchkit/remote` | browser **and** server | stable<br>_redefined in 1 of the 43 minors since 0.94.0, most recently 0.104.0_ | peer-free `implementRemote` for thin HTTP proxy processes |
70
- | `stitchkit/process` | server (Bun or Node, POSIX) | evolving<br>_redefined in 4 of the 43 minors since 0.94.0, most recently 0.133.0_ | finite native commands, byte sinks, bounded capture, process-group cancellation and opt-in Linux/Darwin owner-loss cleanup; contract operations executed in one-call child processes |
71
- | `stitchkit/process/bootstrap` | bundled server entry (Bun, POSIX) | evolving<br>_redefined in 0 of the 4 minors since 0.133.0_ | narrow bootstrap that keeps the process runner lazy while carrying the package's own invocations — the owner-loss guard and the process root of launched work — in a single-file bundle |
72
- | `stitchkit/files/packaging` | build time (Bun or Node) | evolving<br>_redefined in 4 of the 43 minors since 0.94.0, most recently 0.133.0_ | installed native asset graph, integrity, Bun packaging plugin and the artifact loader check; a client bundled into one self-contained, hashed file; a typed client built into a proven npm package with several entries, declarations and external peers; no runtime install policy |
73
- | `stitchkit/files` | server (Bun or Node) | stable<br>_redefined in 5 of the 43 minors since 0.94.0, most recently 0.133.0_ | peer-free managed local-file boundary |
74
- | `stitchkit/spend` | server (Bun or Node) | evolving<br>_redefined in 0 of the 10 minors since 0.127.0_ | peer-free spend gateway for paid model APIs: the attempt recorded before the call and closed on every outcome, credentials only for the provider's origin, a spooled ledger, rank-merged receipts and a reconciler |
75
- | `stitchkit/spend/testing` | tests on Bun or Node | evolving<br>_redefined in 0 of the 10 minors since 0.127.0_ | the coverage guard: red on a model SDK import, a provider key or a provider host outside the gateway files |
76
- | `stitchkit/service-host` | server (Bun or Node) | evolving<br>_redefined in 0 of the 10 minors since 0.127.0_ | peer-free host service supervision — verified versioned artifact activation, Linux `systemd` and macOS `launchd` units (`plutil`, `bootout`/`bootstrap`, rollback), live process/Unix-socket identity verification, and an in-process config-watched reloader |
77
- | `stitchkit/service-host/macos` | server (Bun or Node, macOS) | evolving<br>_redefined in 0 of the 10 minors since 0.127.0_ | peer-free macOS daemon bundle toolkit — fail-closed Developer ID `codesign`, strict C11 launcher `.app` bundles with atomic `RENAME_SWAP` install/rollback, Apple 824×824 squircle `AppIcon.icns`, streaming `lsregister` maintenance, and TCC responsibility inspection |
78
- | `stitchkit/service-host/work` | server (Bun or Node; Linux with systemd ≥ 254, or a process root on Linux and macOS) | evolving<br>_redefined in 0 of the 4 minors since 0.133.0_ | peer-free launch of work in its own boundary with a declared owner — a transient systemd scope or a recorded process root, the typed owner record, the one inherited variable that names the boundary, and the membership check that asks the boundary; see [native I/O](native-io.md#work-in-its-own-boundary) |
79
- | `stitchkit/telegram` | server (Bun or Node) | evolving<br>_redefined in 9 of the 43 minors since 0.94.0, most recently 0.136.0_ | peer-free Telegram platform primitives — Mini App `initData` verification, widget limits and the `widget_query`, `shared_widget_query` and widget message schemas, send-failure classification, one outbound budget per bot token with weighted albums and per-chat 429 pauses, resumable broadcasts, the operator channel with dedupe, a Bot API transport that separates a request that never left from an unknown outcome, local Bot API files, the waveform of a voice message read from its PCM, webhook ownership and durable webhook update intake |
80
- | `stitchkit/telegram/grammy` | server (Bun or Node) | evolving<br>_redefined in 0 of the 43 minors since 0.94.0_ | the token's outbound budget as one grammY client transformer — a 429 that comes back as a response pauses its chat, and a cancelled wait is a request that never left; the widget methods over the same client |
81
- | `stitchkit/telegram/html` | browser and server | evolving<br>_redefined in 1 of the 43 minors since 0.94.0, most recently 0.127.0_ | Telegram's HTML as a tree — compile GFM Markdown to Telegram HTML with fence-aware splitting, clean any markup to what Telegram accepts, cut long text into valid parts by what the reader sees, check markup before it is sent |
82
- | `stitchkit/telegram/voice` | browser and server | evolving<br>_redefined in 0 of the 43 minors since 0.94.0_ | the waveform of a voice message as one format — packed for `sendVoice` the way Telegram Desktop scales it, unpacked to draw it, a `getMe` read of whether the server takes it |
83
- | `stitchkit/telegram/screens` | server (Bun or Node) | evolving<br>_redefined in 1 of the 43 minors since 0.94.0, most recently 0.127.0_ | a bot's menus as declared screens over grammY — typed paths, actions and input, message reconciliation, state in any `StorageAdapter`, a test chat |
84
- | `stitchkit/tracking` | browser **and** server | evolving<br>_redefined in 3 of the 43 minors since 0.94.0, most recently 0.127.0_ | visitor-tracking mechanics — `createTrackingClient`, the tab-shared outbox, the page-leave beacon, attribution, the contract factory; no event vocabulary, no React |
85
- | `stitchkit/tracking/contract` | browser **and** server | evolving<br>_redefined in 0 of the 43 minors since 0.94.0_ | the wire shapes — the contract factory, event and visit schemas, the performance sample and its trust threshold; brings `zod` |
86
- | `stitchkit/tracking/performance` | browser **and** server | evolving<br>_redefined in 1 of the 43 minors since 0.94.0, most recently 0.127.0_ | Web Vitals from real visitors, collected after load through the optional peer `web-vitals`; no `zod` |
87
- | `stitchkit/tracking/server` | server (Bun or Node) | evolving<br>_redefined in 0 of the 43 minors since 0.94.0_ | the decisions a tracking backend makes — dispositions, visit lease over an application-owned store, active intervals, presence; no database |
88
- | `stitchkit/release` | browser **and** server | evolving<br>_redefined in 1 of the 43 minors since 0.94.0, most recently 0.127.0_ | a page follows the release it was built for — `createReleaseMarker` on the server, `createReleaseWatcher` in the browser, the `X-Build-Id` header and a socket event between them |
89
- | `stitchkit/voice` | browser **and** server | evolving<br>_redefined in 0 of the 43 minors since 0.94.0_ | the mechanics of a live voice reply — `SentenceCutter`, `speakableText`, a `SpeechQueue` that synthesises ahead and stops on interruption, the conversation phases |
90
- | `stitchkit/sync` | browser **and** server | evolving<br>_redefined in 1 of the 10 minors since 0.127.0, most recently 0.132.0_ | the client half of an offline-first sync — which outbox rows leave next, pending edits on top of remote rows, deletes that win until acknowledged, the cursor session, the push and page wire with an open outcome vocabulary; no driver, runs in Hermes |
91
- | `stitchkit/sync/postgres` | server (Bun or Node) | evolving<br>_redefined in 0 of the 10 minors since 0.127.0_ | the server half — versions that commit in order, a ledger that runs each change once, a feed of what changed, inside the app's own transaction; a memory store and `checkSyncStore` |
92
- | `stitchkit/postgres` | server (Bun or Node) | evolving<br>_redefined in 0 of the 1 minor since 0.136.7_ | peer-free PostgreSQL helpers — `withSerializedPrismaTransactions` queues interactive transaction statements one at a time on a Prisma SQL driver adapter (`PrismaPg`) while keeping pool queries parallel |
93
- | `stitchkit/geo` | server (Bun or Node) | evolving<br>_redefined in 2 of the 43 minors since 0.94.0, most recently 0.127.0_ | managed GeoIP reader generations, last-known-good reload and the optional MaxMind adapter |
94
- | `stitchkit/geo/contract` | browser **and** server | evolving<br>_redefined in 0 of the 43 minors since 0.94.0_ | the place snapshot schema, for a shared contract that stores or sends `GeoAttribution`; brings `zod` |
95
- | `stitchkit/xlsx` | browser **and** server | evolving<br>_redefined in 0 of the 43 minors since 0.94.0_ | a workbook from rows and typed columns, with no dependency; text never runs as a formula |
96
- | `stitchkit/oauth` | browser **and** server | evolving<br>_redefined in 0 of the 43 minors since 0.94.0_ | provider-neutral Authorization Code + PKCE request and one-shot callback transaction mechanics |
97
- | `stitchkit/google` | server (Bun or Node) | evolving<br>_redefined in 1 of the 43 minors since 0.94.0, most recently 0.127.0_ | optional Google code exchange and verified OIDC identity adapter |
98
- | `stitchkit/observability` | server | stable<br>_redefined in 2 of the 43 minors since 0.94.0, most recently 0.136.0_ | request/tool event projections — `createObservability`, trace context, sanitisation |
99
- | `stitchkit/testing` | tests on Bun or Node | stable<br>_redefined in 3 of the 43 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 |
100
- | `stitchkit/declaration` | browser + build and deployment tooling (Bun or Node) | evolving<br>_redefined in 1 of the 43 minors since 0.94.0, most recently 0.128.0_ | `ProjectDeclarationSchema` — the one machine-readable statement a repository makes about itself |
101
- | `stitchkit/react` | browser + server rendering | stable<br>_redefined in 3 of the 43 minors since 0.94.0, most recently 0.136.0_ | `createCursorQuery`, `createCacheBridge`, QueryClient and `ApiError` retry policy |
102
- | `stitchkit/react/keyboard` | browser | evolving<br>_redefined in 1 of the 43 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) |
103
- | `stitchkit/react/keyboard/testing` | server (Bun or Node) | evolving<br>_redefined in 0 of the 43 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 |
104
- | `stitchkit/agent-runtime` | server | evolving<br>_redefined in 12 of the 43 minors since 0.94.0, most recently 0.136.0_ | peer-free durable conversation/run loop over `AgentModelDriver`, stateless `completeText`/`completeObject`, driver composition, history, models, prompts, fencing and events |
105
- | `stitchkit/agent-runtime/sandbox` | server | evolving<br>_redefined in 1 of the 43 minors since 0.94.0, most recently 0.136.0_ | optional Linux Bubblewrap sessions, long-lived OS process sandboxes (`createProcessSandbox`, `probeProcessSandbox`, `buildSeatbeltProfile`), durable workspaces and a host HTTP credential gateway; see [sandbox guide](sandbox.md) |
106
- | `stitchkit/agent-runtime/testing` | tests on Bun or Node | evolving<br>_redefined in 4 of the 43 minors since 0.94.0, most recently 0.136.0_ | peer-free `createScriptedModelDriver`, credential-free replay, scripted provider faults, deterministic race controls and the agent-store conformance kit |
107
- | `stitchkit/agent-runtime/harness` | server | evolving<br>_redefined in 1 of the 43 minors since 0.94.0, most recently 0.134.0_ | peer-free resource-aware process-local facade over the canonical Agent runtime; supervision stays outside |
108
- | `stitchkit/agent-runtime/coding-tools` | server (Bun or Node) | evolving<br>_redefined in 3 of the 43 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 |
109
- | `stitchkit/agent-runtime/openrouter` | server | evolving<br>_redefined in 4 of the 43 minors since 0.94.0, most recently 0.136.0_ | peer-free native OpenRouter Chat Completions SSE driver, catalog, admission, route pinning and spend reconciliation, plus typed non-chat clients (speech-to-text, text-to-speech, images, video, embeddings, rerank, System One, any endpoint through `openRouterRequestJson`) bound once by `createOpenRouterClient`; see [agent runtime guide](agent-runtime.md#openrouter-non-chat-endpoints-and-shared-transport) |
110
- | `stitchkit/agent-runtime/openai` | server | evolving<br>_redefined in 0 of the 3 minors since 0.134.0_ | peer-free native OpenAI Responses API (`POST /v1/responses`) driver, policy schemas and provenance-aware usage normalization |
111
- | `stitchkit/agent-runtime/anthropic` | server | evolving<br>_redefined in 0 of the 3 minors since 0.134.0_ | peer-free native Anthropic Messages API (`POST /v1/messages`) driver, thinking/cache policy schemas and provenance-aware usage normalization |
112
- | `stitchkit/agent-runtime/ai-sdk` | server | evolving<br>_redefined in 0 of the 3 minors since 0.134.0_ | thin optional-peer adapter (`fromAiSdkModel`, `fromAiSdkTools`) bridging AI SDK (`LanguageModelV4` from `ai@7`) models and `ToolSet`s onto `AgentModelDriver` and `AgentToolSet`; requires `ai` |
113
- | `stitchkit/agent-runtime/browser` | browser + server | evolving<br>_redefined in 2 of the 43 minors since 0.94.0, most recently 0.127.0_ | canonical agent records, events, reconnect cursor, interactive approval/input/permission-mode/host-status state (`deriveAgentConversationActivity`, `deriveAgentConversationState`, `delivery: 'unknown'` reconciliation) and optional conversation controller |
114
- | `stitchkit/agent-runtime/react` | browser + server | evolving<br>_redefined in 0 of the 43 minors since 0.94.0_ | React subscription to an application-owned agent controller |
115
- | `stitchkit/agent-runtime/realtime` | server (Bun or Node) | evolving<br>_redefined in 2 of the 43 minors since 0.94.0, most recently 0.127.0_ | authorized agent control over the existing Socket.IO server |
116
- | `stitchkit/agent-executor` | server (Bun or Node) | evolving<br>_redefined in 4 of the 10 minors since 0.127.0, most recently 0.133.0_ | the executor ↔ server contract for external coding agents (Claude Code, Codex, ACP): delta vocabulary (including `ExecutorPlanDelta`) over the shared message parts, thread leases with a fence, turn phases and their reports |
117
- | `stitchkit/agent-executor/claude` | server (Bun or Node) | evolving<br>_redefined in 0 of the 10 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 |
118
- | `stitchkit/agent-executor/claude-sdk` | server (Bun or Node) | evolving<br>_redefined in 1 of the 10 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 |
119
- | `stitchkit/agent-executor/acp` | server (Bun or Node) | evolving<br>_redefined in 0 of the 10 minors since 0.127.0_ | an Agent Client Protocol v1 agent over stdio: settings by category, images, MCP servers, tool metadata (`title`/`kind`/`locations`), meaningful `tool_call_update` progress updates, typed `plan` deltas, `session/resume`/`load`/`list`, `session/cancel`; no reconcile |
120
- | `stitchkit/agent-executor/codex` | server (Bun or Node) | evolving<br>_redefined in 3 of the 10 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` |
121
- | `stitchkit/agent-executor/testing` | server (Bun or Node) | evolving<br>_redefined in 1 of the 10 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 |
122
- | `stitchkit/agent-executor/testing/claude-sdk` | server (Bun or Node) | evolving<br>_redefined in 0 of the 4 minors since 0.133.0_ | the multi-turn fake Claude SDK query harness and the Claude SDK session stub, typed by the optional peer `@anthropic-ai/claude-agent-sdk` |
123
- | `stitchkit/agent-runtime/postgres` | server (Bun or Node) | evolving<br>_redefined in 0 of the 10 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`) |
124
- | `stitchkit/agent-runtime/sqlite/bun` | server (Bun) | evolving<br>_redefined in 1 of the 43 minors since 0.94.0, most recently 0.127.0_ | durable built-in SQLite store for the agent runtime |
125
- | `stitchkit/agent-runtime/sqlite/node` | server (Node ≥ 22.5) | evolving<br>_redefined in 1 of the 43 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 7 of the 44 minors since 0.94.0, most recently 0.137.0_ | `defineContract`, `createClient`, `createHttpClient`, `createSocketIOClient`, `parseSSE`, the error model |
51
+ | `stitchkit/http` | browser, React Native/Hermes **and** server | evolving<br>_redefined in 3 of the 44 minors since 0.94.0, most recently 0.135.0_ | typed HTTP client factories, `ApiError`, `readContractIdentity` and the stream line errors, without optional realtime peers |
52
+ | `stitchkit/realtime` | browser, React Native/Hermes **and** server | evolving<br>_redefined in 1 of the 44 minors since 0.94.0, most recently 0.127.0_ | typed realtime clients, binding to an existing socket and retained topics with a required explicit Socket.IO peer loader |
53
+ | `stitchkit/device-relay` | browser, React Native/Hermes **and** server | evolving<br>_redefined in 0 of the 4 minors since 0.134.0_ | peer-free User Device Relay over realtime — `createDeviceRelayHub`, `createDeviceRelayAgent`, `createMemoryRelayBroker`, `deviceRelayRealtimeContract`, Fetch-compatible unary RPC and credit-paced cursor streams |
54
+ | `stitchkit/contract` | browser **and** server | stable<br>_redefined in 7 of the 44 minors since 0.94.0, most recently 0.137.0_ | the contract layer alone — `defineContract`, errors, pagination |
55
+ | `stitchkit/live` | browser **and** server | evolving<br>_redefined in 2 of the 44 minors since 0.94.0, most recently 0.127.0_ | `defineEvents` — topic declarations beside the operation contract — and watched reads: `createWatchClient`, the value/difference frame and its reassembly |
56
+ | `stitchkit/primitives` | browser **and** server | evolving<br>_redefined in 0 of the 44 minors since 0.94.0_ | generic values and declarations for lifecycle, access, audit, delivery and exports, exact money and rounding tables |
57
+ | `stitchkit/handler` | browser, React Native/Hermes **and** server | evolving<br>_redefined in 2 of the 11 minors since 0.127.0, most recently 0.137.0_ | portable `createHandler`, `implement`, errors and `serveBridge` over a string `postMessage` port, with no Node built-ins |
58
+ | `stitchkit/server` | server (Bun) | stable<br>_redefined in 7 of the 44 minors since 0.94.0, most recently 0.137.0_ | `createServer`, `implement`, hooks, auth, Socket.IO server, server primitives |
59
+ | `stitchkit/node` | server (Node ≥ 22.3) | stable<br>_redefined in 3 of the 44 minors since 0.94.0, most recently 0.136.0_ | `serveNode` + the runtime-agnostic core — the Node mirror of `/server` |
60
+ | `stitchkit/tools` | server | stable<br>_redefined in 14 of the 44 minors since 0.94.0, most recently 0.137.0_ | the transport-neutral tool layer — `mountAgentTools`, `defineAgentTool`, registry, tool names and manifest, runtime tools, native tools, the OAuth provider, the durability engine; loads no optional peer at runtime |
61
+ | `stitchkit/tools/mcp` | server (Bun or Node) | evolving<br>_redefined in 3 of the 44 minors since 0.94.0, most recently 0.127.0_ | the canonical MCP HTTP/stdio server, schemas and typed MCP presenters; only Zod and the MCP server SDK peers |
62
+ | `stitchkit/tools/agent` | server (Bun or Node) | evolving<br>_redefined in 2 of the 44 minors since 0.94.0, most recently 0.134.0_ | `mountAgent` — thin AI SDK `ToolSet` adapter over `mountAgentTools` for apps driving their own SDK loop; only Zod and the `ai` peer |
63
+ | `stitchkit/tools/toolkit` | server (Bun or Node) | evolving<br>_redefined in 2 of the 44 minors since 0.94.0, most recently 0.135.0_ | `createToolkit` — context-pinned MCP, peer-free agent (`mountAgentTools`), and CLI mounts; only the MCP server SDK peer (no `ai` peer) |
64
+ | `stitchkit/tools/contract` | browser + server | evolving<br>_redefined in 2 of the 44 minors since 0.94.0, most recently 0.124.0_ | the shapes a tool surface speaks — async-operation contract, snapshot and cancel schemas, view-file input/output — without the runtime that serves them |
65
+ | `stitchkit/tools/invoker` | server | stable<br>_redefined in 3 of the 44 minors since 0.94.0, most recently 0.127.0_ | peer-free `createToolInvoker` over the canonical contract tool runner |
66
+ | `stitchkit/tools/connections` | server (Bun or Node) | evolving<br>_redefined in 3 of the 44 minors since 0.94.0, most recently 0.127.0_ | consume external MCP servers and a bounded OpenAPI subset — typed reauthorization, a per-request host fence and per-call credentials |
67
+ | `stitchkit/cli` | server | stable<br>_redefined in 12 of the 44 minors since 0.94.0, most recently 0.128.0_ | `createCli` / `createCliInvoker` — runtime and strict NodeNext declarations without MCP SDK / `ai` |
68
+ | `stitchkit/cli/publish` | artifact publication and HTTP serving tooling (Bun or Node, POSIX) | evolving<br>_redefined in 0 of the 44 minors since 0.94.0_ | `publishCli`, shipping-input versioning (`deriveCliVersionFromShippingInputs`, `cliShippingInputsChanged`, `assertCleanCliSource`), `createCliDistributionRoutes`, and the unpublished-channel response contract (`CLI_DISTRIBUTION_UNPUBLISHED_RESPONSE`, `isCliDistributionUnpublishedResponse`); see [CLI guide](cli.md#publishing-a-complete-version) |
69
+ | `stitchkit/remote` | browser **and** server | stable<br>_redefined in 1 of the 44 minors since 0.94.0, most recently 0.104.0_ | peer-free `implementRemote` for thin HTTP proxy processes |
70
+ | `stitchkit/process` | server (Bun or Node, POSIX) | evolving<br>_redefined in 4 of the 44 minors since 0.94.0, most recently 0.133.0_ | finite native commands, byte sinks, bounded capture, process-group cancellation and opt-in Linux/Darwin owner-loss cleanup; contract operations executed in one-call child processes |
71
+ | `stitchkit/process/bootstrap` | bundled server entry (Bun, POSIX) | evolving<br>_redefined in 0 of the 5 minors since 0.133.0_ | narrow bootstrap that keeps the process runner lazy while carrying the package's own invocations — the owner-loss guard and the process root of launched work — in a single-file bundle |
72
+ | `stitchkit/files/packaging` | build time (Bun or Node) | evolving<br>_redefined in 4 of the 44 minors since 0.94.0, most recently 0.133.0_ | installed native asset graph, integrity, Bun packaging plugin and the artifact loader check; a client bundled into one self-contained, hashed file; a typed client built into a proven npm package with several entries, declarations and external peers; no runtime install policy |
73
+ | `stitchkit/files` | server (Bun or Node) | stable<br>_redefined in 5 of the 44 minors since 0.94.0, most recently 0.133.0_ | peer-free managed local-file boundary |
74
+ | `stitchkit/spend` | server (Bun or Node) | evolving<br>_redefined in 0 of the 11 minors since 0.127.0_ | peer-free spend gateway for paid model APIs: the attempt recorded before the call and closed on every outcome, credentials only for the provider's origin, a spooled ledger, rank-merged receipts and a reconciler |
75
+ | `stitchkit/spend/testing` | tests on Bun or Node | evolving<br>_redefined in 0 of the 11 minors since 0.127.0_ | the coverage guard: red on a model SDK import, a provider key or a provider host outside the gateway files |
76
+ | `stitchkit/service-host` | server (Bun or Node) | evolving<br>_redefined in 0 of the 11 minors since 0.127.0_ | peer-free host service supervision — verified versioned artifact activation, Linux `systemd` and macOS `launchd` units (`plutil`, `bootout`/`bootstrap`, rollback), live process/Unix-socket identity verification, and an in-process config-watched reloader |
77
+ | `stitchkit/service-host/macos` | server (Bun or Node, macOS) | evolving<br>_redefined in 0 of the 11 minors since 0.127.0_ | peer-free macOS daemon bundle toolkit — fail-closed Developer ID `codesign`, strict C11 launcher `.app` bundles with atomic `RENAME_SWAP` install/rollback, Apple 824×824 squircle `AppIcon.icns`, streaming `lsregister` maintenance, and TCC responsibility inspection |
78
+ | `stitchkit/service-host/work` | server (Bun or Node; Linux with systemd ≥ 254, or a process root on Linux and macOS) | evolving<br>_redefined in 0 of the 5 minors since 0.133.0_ | peer-free launch of work in its own boundary with a declared owner — a transient systemd scope or a recorded process root, the typed owner record, the one inherited variable that names the boundary, and the membership check that asks the boundary; see [native I/O](native-io.md#work-in-its-own-boundary) |
79
+ | `stitchkit/telegram` | server (Bun or Node) | evolving<br>_redefined in 9 of the 44 minors since 0.94.0, most recently 0.136.0_ | peer-free Telegram platform primitives — Mini App `initData` verification, widget limits and the `widget_query`, `shared_widget_query` and widget message schemas, send-failure classification, one outbound budget per bot token with weighted albums and per-chat 429 pauses, resumable broadcasts, the operator channel with dedupe, a Bot API transport that separates a request that never left from an unknown outcome, local Bot API files, the waveform of a voice message read from its PCM, webhook ownership and durable webhook update intake |
80
+ | `stitchkit/telegram/grammy` | server (Bun or Node) | evolving<br>_redefined in 0 of the 44 minors since 0.94.0_ | the token's outbound budget as one grammY client transformer — a 429 that comes back as a response pauses its chat, and a cancelled wait is a request that never left; the widget methods over the same client |
81
+ | `stitchkit/telegram/html` | browser and server | evolving<br>_redefined in 1 of the 44 minors since 0.94.0, most recently 0.127.0_ | Telegram's HTML as a tree — compile GFM Markdown to Telegram HTML with fence-aware splitting, clean any markup to what Telegram accepts, cut long text into valid parts by what the reader sees, check markup before it is sent |
82
+ | `stitchkit/telegram/voice` | browser and server | evolving<br>_redefined in 0 of the 44 minors since 0.94.0_ | the waveform of a voice message as one format — packed for `sendVoice` the way Telegram Desktop scales it, unpacked to draw it, a `getMe` read of whether the server takes it |
83
+ | `stitchkit/telegram/screens` | server (Bun or Node) | evolving<br>_redefined in 1 of the 44 minors since 0.94.0, most recently 0.127.0_ | a bot's menus as declared screens over grammY — typed paths, actions and input, message reconciliation, state in any `StorageAdapter`, a test chat |
84
+ | `stitchkit/tracking` | browser **and** server | evolving<br>_redefined in 3 of the 44 minors since 0.94.0, most recently 0.127.0_ | visitor-tracking mechanics — `createTrackingClient`, the tab-shared outbox, the page-leave beacon, attribution, the contract factory; no event vocabulary, no React |
85
+ | `stitchkit/tracking/contract` | browser **and** server | evolving<br>_redefined in 0 of the 44 minors since 0.94.0_ | the wire shapes — the contract factory, event and visit schemas, the performance sample and its trust threshold; brings `zod` |
86
+ | `stitchkit/tracking/performance` | browser **and** server | evolving<br>_redefined in 1 of the 44 minors since 0.94.0, most recently 0.127.0_ | Web Vitals from real visitors, collected after load through the optional peer `web-vitals`; no `zod` |
87
+ | `stitchkit/tracking/server` | server (Bun or Node) | evolving<br>_redefined in 0 of the 44 minors since 0.94.0_ | the decisions a tracking backend makes — dispositions, visit lease over an application-owned store, active intervals, presence; no database |
88
+ | `stitchkit/release` | browser **and** server | evolving<br>_redefined in 1 of the 44 minors since 0.94.0, most recently 0.127.0_ | a page follows the release it was built for — `createReleaseMarker` on the server, `createReleaseWatcher` in the browser, the `X-Build-Id` header and a socket event between them |
89
+ | `stitchkit/voice` | browser **and** server | evolving<br>_redefined in 0 of the 44 minors since 0.94.0_ | the mechanics of a live voice reply — `SentenceCutter`, `speakableText`, a `SpeechQueue` that synthesises ahead and stops on interruption, the conversation phases |
90
+ | `stitchkit/sync` | browser **and** server | evolving<br>_redefined in 1 of the 11 minors since 0.127.0, most recently 0.132.0_ | the client half of an offline-first sync — which outbox rows leave next, pending edits on top of remote rows, deletes that win until acknowledged, the cursor session, the push and page wire with an open outcome vocabulary; no driver, runs in Hermes |
91
+ | `stitchkit/sync/postgres` | server (Bun or Node) | evolving<br>_redefined in 0 of the 11 minors since 0.127.0_ | the server half — versions that commit in order, a ledger that runs each change once, a feed of what changed, inside the app's own transaction; a memory store and `checkSyncStore` |
92
+ | `stitchkit/postgres` | server (Bun or Node) | evolving<br>_redefined in 0 of the 2 minors since 0.136.7_ | peer-free PostgreSQL helpers — `postgresConnectionConfig` safely merges URL `?options=` with enforced `TimeZone=UTC`, `search_path` and custom parameters for `PrismaPg`/`pg.Pool`, `withSerializedPrismaTransactions` queues interactive transaction statements one at a time on a Prisma SQL driver adapter while keeping pool queries parallel, and `runRollbackTransaction` runs an interactive transaction that can intentionally roll back while returning a typed payload |
93
+ | `stitchkit/geo` | server (Bun or Node) | evolving<br>_redefined in 2 of the 44 minors since 0.94.0, most recently 0.127.0_ | managed GeoIP reader generations, last-known-good reload and the optional MaxMind adapter |
94
+ | `stitchkit/geo/contract` | browser **and** server | evolving<br>_redefined in 0 of the 44 minors since 0.94.0_ | the place snapshot schema, for a shared contract that stores or sends `GeoAttribution`; brings `zod` |
95
+ | `stitchkit/xlsx` | browser **and** server | evolving<br>_redefined in 0 of the 44 minors since 0.94.0_ | a workbook from rows and typed columns, with no dependency; text never runs as a formula |
96
+ | `stitchkit/oauth` | browser **and** server | evolving<br>_redefined in 0 of the 44 minors since 0.94.0_ | provider-neutral Authorization Code + PKCE request and one-shot callback transaction mechanics |
97
+ | `stitchkit/google` | server (Bun or Node) | evolving<br>_redefined in 1 of the 44 minors since 0.94.0, most recently 0.127.0_ | optional Google code exchange and verified OIDC identity adapter |
98
+ | `stitchkit/observability` | server | stable<br>_redefined in 2 of the 44 minors since 0.94.0, most recently 0.136.0_ | request/tool event projections — `createObservability`, trace context, sanitisation |
99
+ | `stitchkit/testing` | tests on Bun or Node | stable<br>_redefined in 3 of the 44 minors since 0.94.0, most recently 0.127.0_ | in-process generated clients over a real Fetch handler, tool-surface audit gates (`checkToolSurface` / `assertToolSurface`), the managed-resource conformance kit and manual time for schedules and retries |
100
+ | `stitchkit/declaration` | browser + build and deployment tooling (Bun or Node) | evolving<br>_redefined in 1 of the 44 minors since 0.94.0, most recently 0.128.0_ | `ProjectDeclarationSchema` — the one machine-readable statement a repository makes about itself |
101
+ | `stitchkit/react` | browser + server rendering | stable<br>_redefined in 3 of the 44 minors since 0.94.0, most recently 0.136.0_ | `createCursorQuery`, `createCacheBridge`, QueryClient and `ApiError` retry policy |
102
+ | `stitchkit/react/keyboard` | browser | evolving<br>_redefined in 1 of the 44 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) |
103
+ | `stitchkit/react/keyboard/testing` | server (Bun or Node) | evolving<br>_redefined in 0 of the 44 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 |
104
+ | `stitchkit/agent-runtime` | server | evolving<br>_redefined in 12 of the 44 minors since 0.94.0, most recently 0.136.0_ | peer-free durable conversation/run loop over `AgentModelDriver`, stateless `completeText`/`completeObject`, driver composition, history, models, prompts, fencing and events |
105
+ | `stitchkit/agent-runtime/sandbox` | server | evolving<br>_redefined in 1 of the 44 minors since 0.94.0, most recently 0.136.0_ | optional Linux Bubblewrap sessions, long-lived OS process sandboxes (`createProcessSandbox`, `probeProcessSandbox`, `buildSeatbeltProfile`), durable workspaces and a host HTTP credential gateway; see [sandbox guide](sandbox.md) |
106
+ | `stitchkit/agent-runtime/testing` | tests on Bun or Node | evolving<br>_redefined in 4 of the 44 minors since 0.94.0, most recently 0.136.0_ | peer-free `createScriptedModelDriver`, credential-free replay, scripted provider faults, deterministic race controls and the agent-store conformance kit |
107
+ | `stitchkit/agent-runtime/harness` | server | evolving<br>_redefined in 1 of the 44 minors since 0.94.0, most recently 0.134.0_ | peer-free resource-aware process-local facade over the canonical Agent runtime; supervision stays outside |
108
+ | `stitchkit/agent-runtime/coding-tools` | server (Bun or Node) | evolving<br>_redefined in 3 of the 44 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 |
109
+ | `stitchkit/agent-runtime/openrouter` | server | evolving<br>_redefined in 4 of the 44 minors since 0.94.0, most recently 0.136.0_ | peer-free native OpenRouter Chat Completions SSE driver, catalog, admission, route pinning and spend reconciliation, plus typed non-chat clients (speech-to-text, text-to-speech, images, video, embeddings, rerank, System One, any endpoint through `openRouterRequestJson`) bound once by `createOpenRouterClient`; see [agent runtime guide](agent-runtime.md#openrouter-non-chat-endpoints-and-shared-transport) |
110
+ | `stitchkit/agent-runtime/openai` | server | evolving<br>_redefined in 0 of the 4 minors since 0.134.0_ | peer-free native OpenAI Responses API (`POST /v1/responses`) driver, policy schemas and provenance-aware usage normalization |
111
+ | `stitchkit/agent-runtime/anthropic` | server | evolving<br>_redefined in 0 of the 4 minors since 0.134.0_ | peer-free native Anthropic Messages API (`POST /v1/messages`) driver, thinking/cache policy schemas and provenance-aware usage normalization |
112
+ | `stitchkit/agent-runtime/ai-sdk` | server | evolving<br>_redefined in 0 of the 4 minors since 0.134.0_ | thin optional-peer adapter (`fromAiSdkModel`, `fromAiSdkTools`) bridging AI SDK (`LanguageModelV4` from `ai@7`) models and `ToolSet`s onto `AgentModelDriver` and `AgentToolSet`; requires `ai` |
113
+ | `stitchkit/agent-runtime/browser` | browser + server | evolving<br>_redefined in 2 of the 44 minors since 0.94.0, most recently 0.127.0_ | canonical agent records, events, reconnect cursor, interactive approval/input/permission-mode/host-status state (`deriveAgentConversationActivity`, `deriveAgentConversationState`, `delivery: 'unknown'` reconciliation) and optional conversation controller |
114
+ | `stitchkit/agent-runtime/react` | browser + server | evolving<br>_redefined in 0 of the 44 minors since 0.94.0_ | React subscription to an application-owned agent controller |
115
+ | `stitchkit/agent-runtime/realtime` | server (Bun or Node) | evolving<br>_redefined in 2 of the 44 minors since 0.94.0, most recently 0.127.0_ | authorized agent control over the existing Socket.IO server |
116
+ | `stitchkit/agent-executor` | server (Bun or Node) | evolving<br>_redefined in 4 of the 11 minors since 0.127.0, most recently 0.133.0_ | the executor ↔ server contract for external coding agents (Claude Code, Codex, ACP): delta vocabulary (including `ExecutorPlanDelta`) over the shared message parts, thread leases with a fence, turn phases and their reports |
117
+ | `stitchkit/agent-executor/claude` | server (Bun or Node) | evolving<br>_redefined in 0 of the 11 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 |
118
+ | `stitchkit/agent-executor/claude-sdk` | server (Bun or Node) | evolving<br>_redefined in 1 of the 11 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 |
119
+ | `stitchkit/agent-executor/acp` | server (Bun or Node) | evolving<br>_redefined in 0 of the 11 minors since 0.127.0_ | an Agent Client Protocol v1 agent over stdio: settings by category, images, MCP servers, tool metadata (`title`/`kind`/`locations`), meaningful `tool_call_update` progress updates, typed `plan` deltas, `session/resume`/`load`/`list`, `session/cancel`; no reconcile |
120
+ | `stitchkit/agent-executor/codex` | server (Bun or Node) | evolving<br>_redefined in 3 of the 11 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` |
121
+ | `stitchkit/agent-executor/testing` | server (Bun or Node) | evolving<br>_redefined in 1 of the 11 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 |
122
+ | `stitchkit/agent-executor/testing/claude-sdk` | server (Bun or Node) | evolving<br>_redefined in 0 of the 5 minors since 0.133.0_ | the multi-turn fake Claude SDK query harness and the Claude SDK session stub, typed by the optional peer `@anthropic-ai/claude-agent-sdk` |
123
+ | `stitchkit/agent-runtime/postgres` | server (Bun or Node) | evolving<br>_redefined in 0 of the 11 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`) |
124
+ | `stitchkit/agent-runtime/sqlite/bun` | server (Bun) | evolving<br>_redefined in 1 of the 44 minors since 0.94.0, most recently 0.127.0_ | durable built-in SQLite store for the agent runtime |
125
+ | `stitchkit/agent-runtime/sqlite/node` | server (Node ≥ 22.5) | evolving<br>_redefined in 1 of the 44 minors since 0.94.0, most recently 0.127.0_ | durable built-in SQLite store for the agent runtime |
126
126
  | `stitchkit-tui` | terminal (Bun) | evolving | optional official OpenTUI host over a caller-composed headless runtime |
127
- | `stitchkit/application` | browser + server | evolving<br>_redefined in 9 of the 43 minors since 0.94.0, most recently 0.127.0_ | managed resource graph, readiness, admission, schedules, subtree restart and bounded shutdown |
128
- | `stitchkit/application/grammy` | server | evolving<br>_redefined in 0 of the 43 minors since 0.94.0_ | a grammY bot as application resources — configuration, then polling with updates admitted by batch — and the webhook adapter |
129
- | `stitchkit/application/opentelemetry` | server | evolving<br>_redefined in 0 of the 43 minors since 0.94.0_ | maps application snapshots onto an injected OpenTelemetry `Meter` |
130
- | `stitchkit/application/diagnostic-journal` | server | evolving<br>_redefined in 3 of the 43 minors since 0.94.0, most recently 0.127.0_ | the local diagnostic journal — an exclusive bounded writer and snapshot reader with explicit anomalies |
131
- | `stitchkit/application/directory-inbox` | server | evolving<br>_redefined in 0 of the 43 minors since 0.94.0_ | the directory inbox — entries another program drops into a directory, delivered to the application at least once |
127
+ | `stitchkit/application` | browser + server | evolving<br>_redefined in 9 of the 44 minors since 0.94.0, most recently 0.127.0_ | managed resource graph, readiness, admission, schedules, subtree restart and bounded shutdown |
128
+ | `stitchkit/application/grammy` | server | evolving<br>_redefined in 0 of the 44 minors since 0.94.0_ | a grammY bot as application resources — configuration, then polling with updates admitted by batch — and the webhook adapter |
129
+ | `stitchkit/application/opentelemetry` | server | evolving<br>_redefined in 0 of the 44 minors since 0.94.0_ | maps application snapshots onto an injected OpenTelemetry `Meter` |
130
+ | `stitchkit/application/diagnostic-journal` | server | evolving<br>_redefined in 3 of the 44 minors since 0.94.0, most recently 0.127.0_ | the local diagnostic journal — an exclusive bounded writer and snapshot reader with explicit anomalies |
131
+ | `stitchkit/application/directory-inbox` | server | evolving<br>_redefined in 0 of the 44 minors since 0.94.0_ | the directory inbox — entries another program drops into a directory, delivered to the application at least once |
132
132
 
133
133
  Rule of thumb: browser code imports `stitchkit` and `stitchkit/react`; server
134
134
  code adds `stitchkit/server` (or `stitchkit/node` on Node) and opts into
@@ -251,7 +251,7 @@ map — feature → packages:
251
251
  | Anthropic native provider (`stitchkit/agent-runtime/anthropic`) | — (peer-free) |
252
252
  | AI SDK runtime adapter (`stitchkit/agent-runtime/ai-sdk`) | `ai` |
253
253
  | Postgres agent store (`stitchkit/agent-runtime/postgres`) | — (the application's own Postgres client) |
254
- | Postgres Prisma transaction serializer (`stitchkit/postgres`) | — (peer-free; wraps the application's own Prisma SQL driver adapter) |
254
+ | Postgres connection options and Prisma transaction serializer (`stitchkit/postgres`) | — (peer-free; composes with `pg.Pool` and Prisma SQL driver adapters) |
255
255
  | SQLite agent store (`stitchkit/agent-runtime/sqlite/bun` or `/node`) | — (runtime built-in) |
256
256
  | Agent executor — Claude Agent SDK leaf (`stitchkit/agent-executor/claude-sdk`) | `@anthropic-ai/claude-agent-sdk` |
257
257
  | Agent executor — consumer testing kit (`stitchkit/agent-executor/testing`) | — |
@@ -877,7 +877,7 @@ export const users = defineContract({ prefix: 'users' }, {
877
877
  | `multipart` | no | typed file fields, cardinality, delivery and upload policy — see [below](#file-uploads) |
878
878
  | `maxJsonBodyBytes` | no | per-route JSON body ceiling; overrides the server default |
879
879
  | `timeout` | no | per-endpoint client timeout in ms, for slow endpoints |
880
- | `idempotent` | no | safe to call twice with the same input (like `PUT`/`DELETE`); the typed client repeats a call that got no answer only when it is set, or for a `GET`/`HEAD` without `idempotent: false` or `effect: 'write'` — see [Client](./client.md#calls-that-never-got-an-answer); a retrying transport reads it too — see [Realtime](./realtime.md#bring-your-own-transport) |
880
+ | `idempotent` | no | safe to call twice with the same input (like `PUT`/`DELETE`); explicit `idempotent` wins for network-failure replay, otherwise `isReadOnlyOperation` decides (so `effect: 'write'`, `tool.annotations.readOnlyHint: false` and `destructiveHint: true` disable replay on `GET`/`HEAD`, while `effect: 'read'` and `readOnlyHint: true` enable it on `POST`) — see [Client](./client.md#calls-that-never-got-an-answer) and [MCP & agents](./mcp-and-agents.md#saying-which-tools-only-read--readonlyhint); a retrying transport reads it too — see [Realtime](./realtime.md#bring-your-own-transport) |
881
881
  | `meta` | no | opaque app metadata — read in hooks / on tool mounts, never in OpenAPI ([below](#endpoint-metadata-meta)) |
882
882
  | `rawResponse` | no | the handler returns the `Response` itself — a download, a file, an SSE stream. HTTP-only, never a tool, no `output`. See [Raw-response endpoints](./server.md#raw-response-endpoints) |
883
883
  | `rawBody` | no | retain original JSON text for a signed HTTP webhook. See [Signed JSON webhooks](./server.md#signed-json-webhooks) |
@@ -1003,12 +1003,51 @@ possible effective exposures rather than claiming an unfiltered default tuple.
1003
1003
  The same holds for an endpoint whose own type is broad, with or without a factory:
1004
1004
  a value annotated as `EndpointDef` or `FactoryScopedEndpoint<Scope>` carries
1005
1005
  `expose?: readonly Transport[]`, which may hold no HTTP, so it has no client method
1006
- or URL. A helper that builds endpoints keeps their literal type with a const generic:
1006
+ or URL. To split a large contract across multiple files while keeping literal types,
1007
+ use `defineEndpoints` (or the factory's scoped `defineEndpoints`) in each fragment
1008
+ module and combine them with `composeEndpoints`:
1007
1009
 
1008
1010
  ```ts
1009
- const endpoint = <const Endpoint extends FactoryScopedEndpoint<AppScope>>(value: Endpoint) => value
1011
+ // contracts/documents-query.ts
1012
+ import { defineEndpoints } from 'stitchkit/contract' // or appFactory.defineEndpoints
1013
+
1014
+ export const documentQueryEndpoints = defineEndpoints({
1015
+ search: { method: 'GET', path: '/search', desc: 'Search documents', output: SearchResult },
1016
+ })
1017
+
1018
+ // contracts/documents.ts
1019
+ import { composeEndpoints } from 'stitchkit/contract'
1020
+ import { documentQueryEndpoints } from './documents-query'
1021
+
1022
+ export const documents = defineContract(
1023
+ { prefix: 'documents', scope: 'member' },
1024
+ composeEndpoints(
1025
+ defineEndpoints({ get: { method: 'GET', path: '/:id', desc: 'Read a document', output: Doc } }),
1026
+ documentQueryEndpoints,
1027
+ ),
1028
+ )
1010
1029
  ```
1011
1030
 
1031
+ `defineEndpoints` catches misspelled or unknown endpoint fields (and unknown scopes on a
1032
+ factory's `defineEndpoints`) right in the fragment file, and `composeEndpoints` refuses
1033
+ duplicate operation names both at compile time and at runtime instead of silently
1034
+ overwriting an earlier fragment.
1035
+
1036
+ ### IANA time zones (`IanaTimeZoneSchema` and `canonicalizeIanaTimeZone`)
1037
+
1038
+ `stitchkit/contract` (and `stitchkit`) exports `DEFAULT_TIME_ZONE` (`'UTC'`),
1039
+ `IanaTimeZoneSchema`, `IanaTimeZone`, and `canonicalizeIanaTimeZone` so contracts and
1040
+ servers do not mix form validation with runtime `tzdata` existence checks:
1041
+
1042
+ - Use `IanaTimeZoneSchema` in contract schemas and offline storage: it validates IANA
1043
+ syntax (up to 64 characters, 1–3 slash-separated segments, rejecting bare UTC offsets
1044
+ such as `'+08:00'`) without calling `Intl`, so clients with older `tzdata` never fail
1045
+ reading stored or served records.
1046
+ - Call `canonicalizeIanaTimeZone(value)` on the server before storing or scheduling: it
1047
+ checks `IanaTimeZoneSchema` first and then resolves canonical casing through `Intl`
1048
+ (`'asia/kuala_lumpur'` → `'Asia/Kuala_Lumpur'`), returning `null` for unknown zones
1049
+ such as `'Mars/Olympus'` or bare offsets.
1050
+
1012
1051
  For a curated tool surface use `toolExposure: { default: ['HTTP'] }`, then name
1013
1052
  tool transports only on endpoints that intentionally join them. An empty default
1014
1053
  is legal. Each `configure` snapshots its array independently; it does not change
@@ -1630,6 +1669,32 @@ The registry is intentionally flat: every key must point to one concrete
1630
1669
  `defineContract()` result. Composed namespace arrays are mounted explicitly with
1631
1670
  `implement()` because they do not have a one-key-to-one-handler-map boundary.
1632
1671
 
1672
+ ### Splitting a large service surface by domain family
1673
+
1674
+ When an application grows past a handful of services, keep `surface.ts` thin by
1675
+ assembling each domain family in its own module as a plain function returning
1676
+ `readonly ServiceDef[]`:
1677
+
1678
+ ```ts
1679
+ // surface-documents.ts
1680
+ export function documentServices(deps: AppDeps): readonly ServiceDef[] {
1681
+ return [implement(documentsContract, documentHandlers(deps)), implement(templatesContract, templateHandlers(deps))]
1682
+ }
1683
+
1684
+ // surface.ts
1685
+ export function appServices(deps: AppDeps): ServiceDef[] {
1686
+ return [
1687
+ ...documentServices(deps),
1688
+ ...workspaceServices(deps),
1689
+ ...mediaServices(deps),
1690
+ ]
1691
+ }
1692
+ ```
1693
+
1694
+ Pair this with `defineEndpoints` and `composeEndpoints` from `stitchkit/contract` when a
1695
+ single contract spans multiple files, so parallel changes stay isolated per domain module
1696
+ without a single monolithic surface file.
1697
+
1633
1698
  ## `createServer`
1634
1699
 
1635
1700
  `createServer(config)` builds the router and starts `Bun.serve()`. It returns a
@@ -2223,40 +2288,111 @@ the same guard for `serveNode`.
2223
2288
  A call in flight when the host restarts never gets an answer. The typed client sends it again only
2224
2289
  when that is safe — see [calls that never got an answer](./client.md#calls-that-never-got-an-answer).
2225
2290
 
2226
- ### Adding a unix-socket channel for local CLI and agents
2291
+ ### Tracking multiple windows (`createLocalHostClients`)
2227
2292
 
2228
- To expose the same contract handlers to a local CLI or agent without a TCP port or bearer secret,
2229
- start a **second** `createServer` sharing the base configuration (`services`, `scopePrefixes`, audit
2230
- hooks) alongside the guarded loopback TCP server, and coordinate both with one composite
2231
- `ShutdownTarget` passed to `bindProcessSignals`:
2293
+ When a desktop app opens several windows against one local host, each window owns its own
2294
+ subscriptions, audio/screen sessions, and targeted notifications. Pair `createLocalHostGuard`
2295
+ with `createLocalHostClients` (`stitchkit/server` and `stitchkit/node`):
2232
2296
 
2233
2297
  ```ts
2234
- import { bindProcessSignals, createLocalHostGuard, createServer } from 'stitchkit/server'
2298
+ import {
2299
+ bindRealtimeServer,
2300
+ createLocalHostClients,
2301
+ createLocalHostGuard,
2302
+ createServer,
2303
+ createSocketIOServer,
2304
+ } from 'stitchkit/server'
2305
+ import { z } from 'zod'
2235
2306
 
2236
- const base = { services, scopePrefixes }
2307
+ const guard = createLocalHostGuard({ secret, origins: ['tauri://localhost'] })
2308
+ const clientSetup = createLocalHostClients({
2309
+ guard,
2310
+ labelSchema: z.object({ windowId: z.string().min(1) }),
2311
+ onClientGone: (caller) => fanout.release(caller.client),
2312
+ onLastClientGone: () => pauseBackgroundWork(),
2313
+ })
2237
2314
 
2238
- const tcp = createServer({
2239
- ...base,
2240
- hostname: '127.0.0.1',
2241
- port: 0,
2242
- socket,
2243
- cors: guard.cors,
2244
- hooks: {
2245
- onRequest: (request) => guard.onRequest(request),
2246
- authorize: (ctx, endpoint) => authorizeWindowRequest(ctx, endpoint),
2315
+ const socket = await createSocketIOServer({
2316
+ allowRequest: guard.allowRequest,
2317
+ handshake: clientSetup.handshake, // validates secret + labelSchema together
2318
+ cors: clientSetup.cors, // allows x-stitchkit-client alongside default headers
2319
+ })
2320
+ const realtime = bindRealtimeServer(contract, socket)
2321
+ const hostClients = clientSetup.attach(realtime)
2322
+
2323
+ hostClients.on('claimCall', (caller, input, ack) => {
2324
+ ack({ owner: caller.label.windowId })
2325
+ })
2326
+ hostClients.sendTo(targetClientId, 'incomingCall', { id })
2327
+ ```
2328
+
2329
+ Each window reads its connection id from `realtimeClient.id` (`stitchkit` / `stitchkit/realtime`)
2330
+ and passes it in the `x-stitchkit-client` header on HTTP requests so HTTP handlers can resolve
2331
+ `hostClients.callerFromRequest(request)` against the live socket registry. `onClientGone` runs on
2332
+ every individual window disconnect; `onLastClientGone` runs only when the final window disconnects.
2333
+
2334
+ ### Adding a unix-socket control channel for local CLI and agents
2335
+
2336
+ Expose local state inspection and consent-gated key issuance to a local CLI or agent over a
2337
+ dedicated `0600` Unix domain socket alongside the guarded loopback TCP server, wrapped with
2338
+ `createLocalControlGuard`, `createLocalControlJournal`, and `createLocalConsentKeyIssuance`
2339
+ (→ ADR 0346):
2340
+
2341
+ ```ts
2342
+ import {
2343
+ bindProcessSignals,
2344
+ createLocalConsentKeyIssuance,
2345
+ createLocalControlGuard,
2346
+ createLocalControlJournal,
2347
+ createServer,
2348
+ extractReportedClient,
2349
+ respondJson,
2350
+ } from 'stitchkit/server'
2351
+
2352
+ const journal = createLocalControlJournal({
2353
+ path: journalPath, // created 0600, rotates to <path>.1 after 1 MiB
2354
+ })
2355
+
2356
+ const controlGuard = createLocalControlGuard({
2357
+ maxHeaderBytes: 8 * 1024, // 431 HEADERS_TOO_LARGE (Bun parser native cap is ~16 KiB)
2358
+ maxBodyBytes: 2 * 1024 * 1024, // 413 REQUEST_TOO_LARGE; Transfer-Encoding or unsized body -> 400
2359
+ maxConcurrentRequests: 16, // 503 CONTROL_API_BUSY (open SSE/NDJSON streams count)
2360
+ reporter: { headerPrefix: 'x-app-' }, // always tagged verified: false
2361
+ journal,
2362
+ })
2363
+
2364
+ const keyIssuance = createLocalConsentKeyIssuance({
2365
+ path: '/v1/init-key',
2366
+ reporter: { headerPrefix: 'x-app-' },
2367
+ authorizeRequest: async ({ request }) => {
2368
+ const role = lookupRole(request.role)
2369
+ return {
2370
+ callerCanManageKeys: currentDesktopSession.canManageKeys,
2371
+ allowsKeyManagement: role.allowsKeyManagement, // true -> 403 ROLE_NOT_ALLOWED before consent
2372
+ summary: `Issue "${request.role}" key`,
2373
+ }
2247
2374
  },
2375
+ consent: (question, { signal }) => showNativeConsentDialog(question, signal),
2376
+ issueKey: ({ request }) => createScopedProgramKey(currentDesktopSession, request),
2248
2377
  })
2249
2378
 
2250
2379
  // Opt-in: omit this server when the user disables local control.
2251
2380
  const unix = createServer({
2252
- ...base,
2381
+ services: [],
2253
2382
  unix: { path: socketPath, mode: 0o600 },
2254
- hooks: {
2255
- // Filesystem permissions are the credential; scoped endpoints receive the local owner identity.
2256
- authorize: (ctx) => {
2257
- ctx.user = localSessionOwner
2383
+ wrapFetch: (next) => controlGuard.wrapFetch(keyIssuance.guardWhileConsentPending(next)),
2384
+ rawRoutes: [
2385
+ keyIssuance.route,
2386
+ {
2387
+ method: 'GET',
2388
+ path: '/v1/status',
2389
+ handler: (req) =>
2390
+ respondJson({
2391
+ ok: true,
2392
+ client: extractReportedClient(req, { headerPrefix: 'x-app-' }),
2393
+ }),
2258
2394
  },
2259
- },
2395
+ ],
2260
2396
  })
2261
2397
 
2262
2398
  bindProcessSignals({
@@ -2266,19 +2402,37 @@ bindProcessSignals({
2266
2402
 
2267
2403
  Trust boundary and operational rules for the unix channel:
2268
2404
 
2269
- - **The trust boundary is the OS user, not a specific client binary.** Bun does not expose `SO_PEERCRED` /
2270
- `LOCAL_PEERCRED` peer credentials on `Bun.serve` requests, so any process running as the same OS user
2271
- can connect to the socket. Any custom client header (for example `X-Client-Name`, sent via
2272
- `HttpClientConfig.headers`) is **audit metadata only** and can be spoofed by any same-user process.
2273
- The client side (`createUnixClientTransport`) verifies the socket directory and socket owner (`uid`)
2274
- before connecting, guarding against talking to another user's or symlinked socket.
2405
+ - **Do not silently delegate the signed-in human's session to the Unix socket.** The socket proves
2406
+ only that the peer runs as the same OS user. Use the Unix channel to read local state and to issue
2407
+ a scoped program key with explicit human approval via `createLocalConsentKeyIssuance` (with the
2408
+ CLI counterpart `defineLocalKeyInitCommand` in `stitchkit/cli`), then send mutations over HTTPS
2409
+ under that scoped key. If an application intentionally chooses to delegate a human session over a
2410
+ Unix socket anyway, every edit made by a local agent or script is indistinguishable from the human
2411
+ owner's own edits (same permissions, same author attribution).
2412
+ - **No OS-verified peer credentials on `Bun.serve({ unix })` (→ ADR 0347).** On Bun 1.4.5,
2413
+ `server.requestIP(request)` returns `null` for Unix domain sockets and exposes neither the socket
2414
+ file descriptor nor `SO_PEERCRED` / `LOCAL_PEERCRED` / `LOCAL_PEERPID`. StitchKit intentionally
2415
+ does not replace `Bun.serve` with a custom HTTP/1.1 server or FFI proxy over undocumented
2416
+ `Bun.listen` internals. Every identity parsed by `extractReportedClient` carries `verified: false`
2417
+ and must be presented in UIs and call journals as self-reported ("reported, not verified") until
2418
+ Bun exposes native Unix peer credentials. Applications that need kernel-verified caller PID and
2419
+ executable path today should terminate the Unix socket in their native desktop shell (Rust/Swift
2420
+ via `LOCAL_PEERPID` + `proc_pidpath` or `SO_PEERCRED` + `/proc/<pid>/exe`) and pass verified
2421
+ metadata over a private internal channel.
2422
+ - **Request limits and call journal.** `createLocalControlGuard` enforces `maxHeaderBytes` (default
2423
+ 8 KiB; Bun's native parser caps raw headers at ~16 KiB so larger values cannot raise Bun's native
2424
+ ceiling), explicit `Content-Length` up to `maxBodyBytes` (default 2 MiB; refuses
2425
+ `Transfer-Encoding` and unsized bodies while accepting body-less requests such as body-less `POST`
2426
+ from `createUnixClientTransport`), and `maxConcurrentRequests` (default 16, holding slots while
2427
+ `text/event-stream` / `application/x-ndjson` responses stay open without cloning `Request` or
2428
+ breaking `server.shutdown()`). `createLocalControlJournal` writes metadata-only `0600` JSONL
2429
+ (`url.pathname` only — never query strings, request bodies, `Authorization`, or `2xx` responses)
2430
+ with serialized rotation to `<path>.1`.
2275
2431
  - **Opt-in by configuration.** No socket file is created unless the application explicitly configures
2276
2432
  `createServer({ unix })`.
2277
- - **Narrowing the surface.** Passing the same `services` array gives local CLI and agents everything
2278
- the window can do. If sensitive operations (such as payments or destructive deletes) must stay
2279
- window-only, pass a narrowed `services` subset to the unix server instead.
2280
2433
  - **Streaming events over the socket.** Socket.IO does not mount on a unix listener; expose live
2281
- events to local CLI/agent consumers through contract `stream` endpoints (NDJSON/SSE).
2434
+ events to local CLI/agent consumers through `sseRoute` / `ndjsonRoute` or contract `stream`
2435
+ endpoints.
2282
2436
  - **Bind order.** Because `bindUnixSocket` adjusts `process.umask` during bind, create the unix
2283
2437
  server before spawning `Worker` threads.
2284
2438
  - **macOS boundaries.** Under macOS App Sandbox, place the socket inside the app's App Group
@@ -3875,20 +4029,25 @@ upload.
3875
4029
  A connection that drops after the request left and before an answer came — a host process that
3876
4030
  restarted, a reset loopback socket — leaves the caller not knowing whether the call ran. A response
3877
4031
  of any status is an answer and is never repeated. A network failure is repeated only when sending the
3878
- call twice is safe, and the endpoint says when that is:
4032
+ call twice is safe, using explicit `idempotent` first and then the single canonical
4033
+ `isReadOnlyOperation` rule shared with MCP `readOnlyHint` and CLI refused views
4034
+ ([MCP & agents → `readOnlyHint`](./mcp-and-agents.md#saying-which-tools-only-read--readonlyhint)):
3879
4035
 
3880
4036
  | endpoint | repeated after a network failure |
3881
4037
  | --- | --- |
3882
- | `idempotent: true` | yes, whatever the method |
3883
- | `GET` / `HEAD`, `idempotent` unset | yes |
3884
- | `idempotent: false` | never, even a `GET` |
3885
- | `effect: 'write'`, `idempotent` unset | never, even a `GET` |
3886
- | any other method, `idempotent` unset | never |
4038
+ | `idempotent: true` | yes, whatever the method or `effect` |
4039
+ | `idempotent: false` | never, even a `GET` or `effect: 'read'` |
4040
+ | `effect: 'write'` (with `idempotent` unset) | never, even a `GET` / `HEAD` |
4041
+ | `tool.annotations.readOnlyHint: false` or `destructiveHint: true` (with `idempotent` unset) | never, even a `GET` / `HEAD` |
4042
+ | `effect: 'read'` or `tool.annotations.readOnlyHint: true` (with `idempotent` unset) | yes, even on `POST` |
4043
+ | `GET` / `HEAD` (with `idempotent`, `effect` and hints unset) | yes |
4044
+ | any other method (with `idempotent`, `effect` and hints unset) | never |
3887
4045
 
3888
4046
  Both clients read the rule from the endpoint itself: the bare `createClient(contract, { baseUrl })`
3889
4047
  repeats up to `retry.limit` times (default 2) with a short doubling pause, and a client on
3890
- `createHttpClient` passes the endpoint's `idempotent` — or `false` for a declared write — to its own
3891
- transport retry. A call that is not
4048
+ `createHttpClient` passes the resolved replay flag (`true` / `false`) to its own transport retry
4049
+ while leaving ordinary unflagged `GET`/`HEAD` and non-`GET`/`HEAD` endpoints to respect
4050
+ `createHttpClient({ retry: { methods } })`. A call that is not
3892
4051
  repeated fails with the network error, and its outcome is unknown: the server may have run it.
3893
4052
  Declare `idempotent: true` on a write that is safe twice — a `PUT` of a whole value, a delete, a
3894
4053
  write keyed by an idempotency key — and it survives a restart of the server it talks to.
@@ -4934,28 +5093,37 @@ that ([CLI → commands discovered from a running server](./cli.md#commands-disc
4934
5093
  ### Saying which tools only read — `readOnlyHint`
4935
5094
 
4936
5095
  A host reads a tool's `annotations` to group tools and to choose permission
4937
- defaults, and a CLI mounted over this surface reads them to decide what a
4938
- refused view may withhold ([CLI → views](./cli.md#aggregate-views)). The server publishes the
4939
- annotations the tool declared, and states `readOnlyHint: true` for a read that
4940
- declared none:
4941
-
4942
- | The tool | Published `readOnlyHint` |
4943
- |---|---|
4944
- | declares `readOnlyHint`, either way | as declared |
4945
- | `effect: 'write'` with no `readOnlyHint` (even on `GET`) | none |
4946
- | `effect: 'read'` with no `readOnlyHint` and `destructiveHint !== true` (even on non-`GET`) | `true` |
4947
- | `GET` with no `readOnlyHint`, no `effect: 'write'`, and `destructiveHint !== true` | `true` |
4948
- | any other method, or `destructiveHint: true` with no `readOnlyHint` | none |
4949
-
4950
- A runtime tool follows the same rule by its `identity.effect` and `identity.method`. A raw SDK
4951
- registration (`mountWait`, `mountViewFile` and the like) publishes only what it
4952
- passes. The catalog digest hashes the published annotations, so it moves once
4953
- when a server starts publishing the derived hint.
5096
+ defaults, a CLI mounted over this surface reads them to decide what a
5097
+ refused view may withhold ([CLI → views](./cli.md#aggregate-views)), and the
5098
+ typed HTTP client reads the same `isReadOnlyOperation` rule to decide automatic
5099
+ network-failure replay ([Client → calls that never got an answer](./client.md#calls-that-never-got-an-answer)).
5100
+ The server publishes the annotations the tool declared, and states
5101
+ `readOnlyHint: true` for a read that declared none:
5102
+
5103
+ | The tool | `isReadOnlyOperation` | Published `readOnlyHint` |
5104
+ |---|---|---|
5105
+ | `effect: 'write'` (even on `GET` / `HEAD`) | `false` | none (unless `readOnlyHint: false` declared) |
5106
+ | `destructiveHint: true` | `false` | none (unless `readOnlyHint: false` declared) |
5107
+ | explicit `readOnlyHint: false` (without `effect: 'read'`) | `false` | `false` |
5108
+ | explicit `readOnlyHint: true` (without `effect: 'write'` or `destructiveHint: true`) | `true` | `true` |
5109
+ | `effect: 'read'` (even on `POST`) | `true` | `true` |
5110
+ | `GET` / `HEAD` with no `effect`, no `readOnlyHint`, and `destructiveHint !== true` | `true` | `true` |
5111
+ | any other method with no `effect` and no `readOnlyHint` | `false` | none |
5112
+
5113
+ Direct contradictions — `effect: 'read'` with `readOnlyHint: false` or
5114
+ `destructiveHint: true`, and `effect: 'write'` with `readOnlyHint: true` — are
5115
+ refused at declaration time (`defineContract`, `defineRuntimeTool`, and runtime
5116
+ mount). A runtime tool follows the same rule by its `identity.effect` and
5117
+ `identity.method`. A raw SDK registration (`mountWait`, `mountViewFile` and the
5118
+ like) publishes only what it passes. The catalog digest hashes the published
5119
+ annotations, so it moves once when a server starts publishing the derived hint.
4954
5120
 
4955
5121
  > **A `GET` with a write effect must say so.** Hosts may run a tool that publishes
4956
- > `readOnlyHint: true` without asking. An endpoint that changes something on
4957
- > `GET` — marks as seen, rotates a token — declares `effect: 'write'` or
4958
- > `tool: { annotations: { readOnlyHint: false } }`.
5122
+ > `readOnlyHint: true` without asking, and HTTP clients replay unflagged `GET`
5123
+ > calls after network failures. Declare `effect: 'write'` (the canonical way) so
5124
+ > both MCP and client replay treat the endpoint as a write; declaring
5125
+ > `tool: { annotations: { readOnlyHint: false } }` without `effect` also opts out
5126
+ > of both `readOnlyHint` and client replay.
4959
5127
 
4960
5128
  A client connection (`defineMcpClientConnection`) carries the hints a server
4961
5129
  published onto the tools it mounts, field by field: a hint of the wrong type is
@@ -12633,16 +12801,25 @@ Login, self-update, diagnostics, integration setup and shell completion belong
12633
12801
  to the executable, not to HTTP/MCP/Agent. Define them with `defineCliCommand`:
12634
12802
 
12635
12803
  ```ts
12636
- import { createCli, defineCliCommand } from 'stitchkit/cli'
12804
+ import { createCli, defineCliCommand, readSecret, readSecretFile } from 'stitchkit/cli'
12637
12805
  import { z } from 'zod'
12638
12806
 
12639
12807
  const login = defineCliCommand({
12640
12808
  name: 'login',
12641
12809
  description: 'Store credentials for later managed commands',
12642
- input: z.object({ token: z.string() }),
12810
+ input: z.object({
12811
+ keyFile: z.string().optional().describe('Read token from a 0600 file instead of prompting'),
12812
+ }),
12643
12813
  output: z.object({ configured: z.boolean() }),
12644
12814
  handler: async ({ input }) => {
12645
- await saveToken(input.token)
12815
+ // Never accept tokens as CLI arguments (--token): arguments end up in shell
12816
+ // history and process listings (`ps`). `readSecret` disables TTY echo and
12817
+ // restores terminal mode in `finally`, or reads piped stdin; `readSecretFile`
12818
+ // refuses symlinks, FIFOs, and any file readable by group or others (`chmod 600`).
12819
+ const token = input.keyFile
12820
+ ? readSecretFile(input.keyFile)
12821
+ : await readSecret({ prompt: 'API token: ' })
12822
+ await saveToken(token)
12646
12823
  return { configured: true }
12647
12824
  },
12648
12825
  })
@@ -12657,6 +12834,12 @@ await createCli({
12657
12834
  })
12658
12835
  ```
12659
12836
 
12837
+ For local daemons that issue a scoped program key only after interactive operator
12838
+ consent over a `0600` Unix control socket, `defineLocalKeyInitCommand` pairs with
12839
+ `createLocalConsentKeyIssuance` from `stitchkit/server`: it requests a key over the
12840
+ local socket without retries, waits for the operator prompt, and writes the returned
12841
+ key directly to the local profile file (`0600`) without printing the secret.
12842
+
12660
12843
  Native commands receive only typed `input`, parsed global `options` and the
12661
12844
  configured stdout/stderr writers. They reuse help, argv/stdin parsing,
12662
12845
  validation, dry-run, error envelopes and exit mapping, but deliberately have no
@@ -13409,14 +13592,16 @@ and `details.resultOnStdout` states which case occurred:
13409
13592
  | has an effect | the complete original result in the normal JSON format (`--json` still selects compact output) | reading stdout — never by repeating the mutation |
13410
13593
  | only reads | nothing | repeating the command with a corrected view |
13411
13594
 
13412
- A managed command only reads by the same four-step rule used for `readOnlyHint`:
13413
- an explicit `annotations.readOnlyHint` decides in either direction; otherwise
13414
- `effect: 'write'` marks a non-read (even on `GET`); otherwise `effect: 'read'`
13415
- marks a read unless `destructiveHint: true`; otherwise `GET` is the fallback read
13416
- unless `destructiveHint: true`. `readOnlyHint: false`, `effect: 'write'` without
13417
- `readOnlyHint`, or `destructiveHint: true` without `readOnlyHint` keeps the result
13418
- on stdout. A native `defineCliCommand` declares none of those facts, so a failed
13419
- `present` always keeps the validated result on stdout.
13595
+ A managed command only reads by the single canonical `isReadOnlyOperation` rule
13596
+ shared with MCP `readOnlyHint` and HTTP client network-failure replay
13597
+ ([MCP & agents → `readOnlyHint`](./mcp-and-agents.md#saying-which-tools-only-read--readonlyhint),
13598
+ [Client → calls that never got an answer](./client.md#calls-that-never-got-an-answer)):
13599
+ `effect: 'write'` or `destructiveHint: true` is never a read; otherwise an
13600
+ explicit `annotations.readOnlyHint` decides in either direction; otherwise
13601
+ `effect: 'read'` is a read; otherwise `GET`/`HEAD` defaults to a read.
13602
+ `readOnlyHint: false`, `effect: 'write'`, or `destructiveHint: true` keeps the
13603
+ result on stdout. A native `defineCliCommand` declares none of those facts, so a
13604
+ failed `present` always keeps the validated result on stdout.
13420
13605
 
13421
13606
  A CLI that mounts a server's tools through `defineMcpClientConnection` never sees the
13422
13607
  method or contract `effect` — every MCP call is a `POST` — so it reads the `readOnlyHint`
@@ -13584,7 +13769,7 @@ exists to distrust.
13584
13769
  `publishCli` is an opt-in publisher for a local application-owned distribution
13585
13770
  directory. It commits every target and its version manifest before atomically
13586
13771
  replacing the public `manifest.json`. It ships from its own evolving entrypoint,
13587
- `stitchkit/cli/publish`: release infrastructure follows how distributions are
13772
+ `stitchkit/cli/publish`: artifact publication and HTTP serving infrastructure follows how distributions are
13588
13773
  published, so it is not held to the stable promise of `stitchkit/cli`
13589
13774
  ([ADR 0245](../decisions/0245-cli-publication-is-an-evolving-leaf.md)). The
13590
13775
  manifest, signatures, installer and updater it writes for stay in
@@ -13662,9 +13847,11 @@ be checked. A failure after public-pointer rename may already have published;
13662
13847
  `AtomicFilePublicationError.published` remains available when the atomic writer
13663
13848
  reports that boundary. Read the durable manifest and retry the admitted same
13664
13849
  identity to recover; an error does not promise rollback. Optional `signing` and
13665
- `trust` reuse the Ed25519 contract below. The generated shell installer checks
13666
- raw digest and size; the updater checks manifest authorship when given a trust
13667
- root.
13850
+ `trust` reuse the Ed25519 contract below; when `trust` is passed, `publishCli`
13851
+ validates it eagerly with `CliTrustRootSchema` (requiring at least one valid Ed25519
13852
+ public key) and requires a `'valid'` manifest signature fail-closed. The generated shell
13853
+ installer checks raw digest and size; the updater checks manifest authorship when given a
13854
+ trust root.
13668
13855
 
13669
13856
  ### Versioning from shipping inputs and verifying clean source
13670
13857
 
@@ -13740,14 +13927,32 @@ Each configured channel mounts `${basePath}/channels/<channel>/manifest.json`
13740
13927
  descriptor-streamed binary listed in the signed manifest with `Content-Length`
13741
13928
  and `Content-Disposition`). `${basePath}/install.sh` renders `renderCliInstaller`
13742
13929
  from the verified `installerChannel` manifest (`no-store`). Every read checks
13743
- canonical directory containment (`realpath` + `isWithinDir`), opens regular files
13744
- with `O_NOFOLLOW`, parses strict UTF-8 JSON without `__proto__`, verifies
13745
- `manifest.name` and Ed25519 signature strictly (`verifyCliManifest === 'valid'`),
13746
- and streams full asset bodies portably on both Bun and Node without `Bun.file`.
13747
- When `root` is `undefined`, `trust.keys` is empty, or the manifest is missing,
13748
- unsigned, tampered, oversized or has no assets, channel manifest and installer
13749
- routes fail closed with `503 No verified CLI build is published` (`no-store`),
13750
- and exceptions thrown by `onUnavailable` are isolated.
13930
+ each directory segment with `lstat` plus canonical containment (`realpath` +
13931
+ `isWithinDir`), opens regular files with `O_NOFOLLOW`, parses strict UTF-8 JSON
13932
+ without `__proto__`, verifies `manifest.name` and Ed25519 signature strictly
13933
+ (`verifyCliManifest === 'valid'`), and streams full asset bodies portably on both
13934
+ Bun and Node without `Bun.file`.
13935
+
13936
+ Channel manifest and installer routes deliberately separate a genuinely empty
13937
+ (not yet published) channel from configuration, path, integrity and signature
13938
+ faults:
13939
+
13940
+ - When `reason` is `'missing'` (an existing `root` whose channel directory or
13941
+ `manifest.json` has not been published yet), the route responds with the
13942
+ exported contract `CLI_DISTRIBUTION_UNPUBLISHED_RESPONSE` (`503`,
13943
+ `Cache-Control: no-store`, header
13944
+ `x-stitchkit-cli-distribution-state: unpublished`, body
13945
+ `No verified CLI build is published`). External probes and gates identify this
13946
+ state with the synchronous, body-free `isCliDistributionUnpublishedResponse(res)`
13947
+ helper instead of matching prose strings.
13948
+ - For every other failure (`unconfigured-root`, missing or non-directory `root`,
13949
+ `empty-trust-root`, `unsafe-path` including dangling or escaping symlinks,
13950
+ `too-large`, `invalid-manifest` including empty `assets` on `install.sh`,
13951
+ `identity-mismatch`, `untrusted-signature`, or `io-error`), the route fails
13952
+ closed with a distinct `503` carrying
13953
+ `x-stitchkit-cli-distribution-state: unavailable` (`CLI distribution is
13954
+ unavailable`), for which `isCliDistributionUnpublishedResponse(res)` always
13955
+ returns `false`. Exceptions thrown by `onUnavailable` are isolated.
13751
13956
 
13752
13957
  ### Proving who built it — signing the manifest
13753
13958
 
@@ -15810,6 +16015,51 @@ has not moved. That needs the key to still exist on the server — set `holdMs`
15810
16015
  past your reconnect delay, or the last detach releases the source and the page
15811
16016
  pays the whole value once.
15812
16017
 
16018
+ ### Relaying watches to multiple local windows (`createWatchFanout`)
16019
+
16020
+ When one local desktop host holds a single upstream watch socket to the cloud and
16021
+ serves several local windows, forwarding raw `WATCH_OPEN` and `WATCH_CLOSE` frames
16022
+ breaks twice: a second window opening an already-held key receives `{ accepted: true }`
16023
+ with no value frame, and one window closing a key drops it for every other window.
16024
+
16025
+ `createWatchFanout` (`stitchkit/live`) multiplexes one shared upstream subscription per
16026
+ `(service, action, digest)` across any number of downstream clients while preserving
16027
+ each client's own `WatchKey.instance`, maintaining a verified host copy (`applyWatchDelta`
16028
+ + fingerprint check), translating upstream revision resets onto a monotonic downstream
16029
+ counter so windows stay live across a cloud restart, and resyncing upstream if a delta
16030
+ base mismatches without corrupting the host copy:
16031
+
16032
+ ```ts
16033
+ import {
16034
+ createWatchFanout,
16035
+ WATCH_CLOSE,
16036
+ WATCH_OPEN,
16037
+ WATCH_STATE,
16038
+ WATCH_VALUE,
16039
+ } from 'stitchkit/live'
16040
+
16041
+ const fanout = createWatchFanout<string>({
16042
+ upstream: {
16043
+ open: (input) => cloudSocket.request(WATCH_OPEN, input, { timeoutMs: 10_000 }),
16044
+ close: (key) => cloudSocket.emit(WATCH_CLOSE, { key }),
16045
+ },
16046
+ deliver: {
16047
+ value: (client, frame) => hostClients.sendTo(client, WATCH_VALUE, frame),
16048
+ state: (client, frame) => hostClients.sendTo(client, WATCH_STATE, frame),
16049
+ },
16050
+ })
16051
+
16052
+ // Wire downstream open/close/disconnect and upstream frames/reconnect:
16053
+ hostClients.on(WATCH_OPEN, async (caller, input, ack) => ack(await fanout.open(caller.client, input)))
16054
+ hostClients.on(WATCH_CLOSE, (caller, payload) => fanout.close(caller.client, payload.key))
16055
+ cloudSocket.on(WATCH_VALUE, (frame) => fanout.value(frame))
16056
+ cloudSocket.on(WATCH_STATE, (frame) => fanout.state(frame))
16057
+ cloudSocket.onConnectionChange((connected) => {
16058
+ if (!connected) fanout.forget('upstream disconnected')
16059
+ else void fanout.reopen()
16060
+ })
16061
+ ```
16062
+
15813
16063
  ### Large answers cross as differences
15814
16064
 
15815
16065
  A frame carries the value, a **difference** to a revision this subscriber already
@@ -15957,6 +16207,41 @@ Same entry format as `trustedHosts`, compared against the `Origin`'s authority.
15957
16207
  Declaring one does not widen anything else: an undeclared origin is still
15958
16208
  refused, and `trustedHosts` still decides which authority the server answers on.
15959
16209
 
16210
+ ### Cross-site public read routes (`publicReads`)
16211
+
16212
+ Some HTTP routes are meant to be opened from any site — signed download URLs,
16213
+ public avatars, or read-only shared resources whose capability token travels in
16214
+ the URL or a header. Rather than stripping `Origin` and `Sec-Fetch-Site` in a
16215
+ manual wrapper around `fence.check`, declare a synchronous predicate on the
16216
+ fence:
16217
+
16218
+ ```ts
16219
+ createTrustFence({
16220
+ trustedHosts: ['app.example'],
16221
+ publicReads: (request) => {
16222
+ const { pathname } = new URL(request.url);
16223
+ return pathname.startsWith('/api/public/');
16224
+ },
16225
+ });
16226
+ ```
16227
+
16228
+ When `publicReads(request)` returns strictly `true`, `cross-site` and
16229
+ `origin-mismatch` are skipped — under strict fail-closed boundaries:
16230
+
16231
+ - **`Host` is always enforced first:** `missing-host` and `untrusted-host` are
16232
+ never bypassed, so DNS rebinding remains refused.
16233
+ - **HTTP safe reads only:** evaluated only on the HTTP lane for exact `GET` and
16234
+ `HEAD` requests with no `Upgrade` header. `POST`, `PUT`, `PATCH`, `DELETE`,
16235
+ `OPTIONS`, raw WebSocket `Upgrade` handshakes, and the entire Socket.IO lane
16236
+ (`allowRequest` / `'socket'`) ignore `publicReads` and never call it.
16237
+ - **Fail-closed on error:** if the predicate throws or returns anything other
16238
+ than `true` (including a `Promise`), the request falls through to the normal
16239
+ bare 403 refusal and logs an error via `logger.error` (or `console.error`).
16240
+ - **Not CORS:** `publicReads` only admits `GET`/`HEAD` past the trust fence; it
16241
+ does not add `Access-Control-Allow-Origin` headers or exempt `OPTIONS`
16242
+ preflights. Configure `cors` alongside the fence when cross-site browser code
16243
+ reads the response or sends custom headers.
16244
+
15960
16245
  It is worth knowing what the `Origin` check is for, because it is not what most
15961
16246
  people assume. It is **not** the DNS-rebinding defence — that attack is
15962
16247
  same-origin by construction, so it sends a matching `Origin` or none at all, and
@@ -16604,7 +16889,9 @@ core never models them (ADR 0002). But stitchkit itself emits a set of its own:
16604
16889
  `OPERATION_PROCESS_FAILED`, `STREAM_ITEM_INVALID`, `STREAM_FRAME_TOO_LARGE`,
16605
16890
  `STREAM_TERMINAL_MISSING`, `STREAM_LIFETIME_EXCEEDED`,
16606
16891
  `GRAMMY_WEBHOOK_NOT_ACCEPTING`, `SANDBOX_UNAVAILABLE`, `SANDBOX_INSUFFICIENT`,
16607
- `SPILL_REFERENCE_UNKNOWN`, `INTERNAL_SERVER_ERROR` — a set that grows in
16892
+ `SPILL_REFERENCE_UNKNOWN`, `HEADERS_TOO_LARGE`, `REQUEST_TOO_LARGE`,
16893
+ `CONTROL_API_BUSY`, `ROLE_NOT_ALLOWED`, `KEYS_MANAGE_REQUIRED`, `INIT_DENIED`,
16894
+ `INIT_TIMEOUT`, `CONSENT_PENDING`, `INTERNAL_SERVER_ERROR` — a set that grows in
16608
16895
  ordinary releases, each addition named in the changelog. They are
16609
16896
  published as **`STITCH_ERROR_STATUS`** (the `code → status` map) and
16610
16897
  **`StitchErrorCode`** (its `keyof`), with **`isStitchErrorCode()`** (→ ADR 0026).
@@ -16680,6 +16967,34 @@ An explicit per-code `map` wins over a status fallback. With
16680
16967
  at compile time. Transport boundaries identify errors with `AppError.is`, not
16681
16968
  `instanceof`, so two bundled copies still agree.
16682
16969
 
16970
+ Pass the same `ErrorCodeMapping` (`{ vocabulary }`, `{ codeMap, unmappedCode? }`, and
16971
+ optional `redact` to replace public messages and drop details/hints for internal wire codes)
16972
+ to every surface so HTTP, MCP, agent tools, and CLI emit one error vocabulary:
16973
+
16974
+ ```ts
16975
+ import type { ErrorCodeMapping } from 'stitchkit/contract'
16976
+ import { createErrorHook } from 'stitchkit/server'
16977
+ import { createToolkit } from 'stitchkit/tools/toolkit'
16978
+
16979
+ const errors: ErrorCodeMapping = {
16980
+ vocabulary,
16981
+ redact: { INTERNAL_ERROR: 'Internal server error' },
16982
+ }
16983
+
16984
+ const onError = createErrorHook({
16985
+ ...errors,
16986
+ render: (info) => ({ ok: false, error: { code: info.code, message: info.message } }),
16987
+ })
16988
+ const tools = createToolkit<AppContext>({ errors })
16989
+ // tools.createMcpHandler(...), tools.mountAgentTools(...), tools.createCli(...)
16990
+ // all inherit `errors` automatically (or pass `errors` directly on any mount or invoker).
16991
+ ```
16992
+
16993
+ CLI keeps its default exit codes (`DEFAULT_EXIT_CODES`, e.g. exit `4` for `NOT_FOUND` even
16994
+ when mapped to `not_found`) unless you override the wire code in `exitCodes`, and server-side
16995
+ audit logs keep the raw thrown message behind internal errors even when `redact` masks the
16996
+ wire payload.
16997
+
16683
16998
  ## Domain errors — `defineErrors`
16684
16999
 
16685
17000
  Declare each domain code, HTTP status, default message and optional
@@ -17376,6 +17691,12 @@ const audit = createSpooledSink({
17376
17691
  const { replayed, failed } = await audit.recover();
17377
17692
 
17378
17693
  createObservability({ request: { write: audit.write, filter: auditChanges } });
17694
+
17695
+ // After a transient outage in the same process, the next successful `write`
17696
+ // triggers a single-flight background redelivery pass automatically; call
17697
+ // `await audit.flush()` to explicitly drain undelivered rows alongside live
17698
+ // writes (for example on a timer or graceful shutdown).
17699
+ await audit.flush();
17379
17700
  ```
17380
17701
 
17381
17702
  The guarantee is **at least once**. A crash between the store accepting a row and
@@ -17985,12 +18306,13 @@ one learned. Ranks: 1 the gateway's transport view, 2 the response's reported
17985
18306
  usage, 3 a reconciler's answer.
17986
18307
 
17987
18308
  `createSpooledSpendStore({ store, path })` puts every attempt and receipt on disk
17988
- before the database is offered it. With the database down, calls go on and
17989
- `recover()` at the next start delivers what was spooled, in order — an attempt
17990
- always before its receipts, in the live path too: a receipt whose attempt the
17991
- database has not taken waits on disk with it. Delivery of what was spooled happens
17992
- at `recover()`, not in the background. Only a record that could be neither spooled
17993
- nor stored refuses the call.
18309
+ before the database is offered it. With the database down, calls go on; when the
18310
+ database accepts a later write in the same process, a single-flight background pass
18311
+ redelivers pending records in group order (an attempt always before its receipts,
18312
+ in the live path too: a receipt whose attempt the database has not taken waits on
18313
+ disk with it). Call `await store.flush()` to explicitly redeliver in-process alongside
18314
+ live writes, and `await store.recover()` once at startup for what a previous process
18315
+ left on disk. Only a record that could be neither spooled nor stored refuses the call.
17994
18316
 
17995
18317
  ## Afterwards
17996
18318
 
@@ -18209,6 +18531,43 @@ policy; named surfaces select tools, while `extend.filter` decides which
18209
18531
  selected operations receive extra fields. CLI selection is deliberately plain,
18210
18532
  and Agent owns its own reachable presentation shaping.
18211
18533
 
18534
+ ### Tool surface gates (`checkToolSurface`)
18535
+
18536
+ Beyond snapshot parity, `stitchkit/testing` ships one peer-free primitive —
18537
+ `checkToolSurface` / `assertToolSurface` — covering all seven recurring
18538
+ surface-hygiene gates without duplicating scripts per app:
18539
+
18540
+ - `getReads` — every `GET` operation lives in exactly one bucket: audited `reads`,
18541
+ contract `effect: 'write'`, or a reasoned debt (`readOnlyHint: false` without `effect`).
18542
+ - `cliCallable` — boots the CLI configuration and builds its managed surface,
18543
+ refusing startup faults or `[unavailable]` commands (such as fields shadowing framework or global flags).
18544
+ - `noRefs` — checks advertised MCP (default or named `mcpSurfaces`) and AGENT input schemas for
18545
+ zero `$ref`, `$defs`, or `definitions` (unroll recursion with `tool.inputRecursionDepth`).
18546
+ - `outputJsonSchema` — validates that every operation's `output` and `toolView.output`
18547
+ converts cleanly to JSON Schema (refusing unrepresentable schemas such as `z.date()`).
18548
+ - `transportParity` — calls the same contract operation across configured HTTP, MCP, AGENT, and CLI
18549
+ targets and verifies identical wire JSON (projecting HTTP through `toolView`), identical mapped error
18550
+ codes (`ErrorCodeMapping`), and identical application error messages.
18551
+ - `deadReferences` — scans portable file globs (`node:fs/promises`), in-memory sources, and endpoint
18552
+ descriptions for tool-name tokens, refusing 0 matched files and unused or tool-colliding `ignore` entries.
18553
+ - `schemaRatchet` — enforces strict bidirectional equality against a baseline JSON (`writeToolSurfaceBaseline`,
18554
+ mode `0644`) for `agentSchemaBytes`, untyped input properties (excluding `inputNestingDepth`-opened paths),
18555
+ and bare-array / `list_*` envelope violations, with an explicit `updateCommand` hint on drift.
18556
+
18557
+ ```ts
18558
+ import { assertToolSurface } from 'stitchkit/testing'
18559
+
18560
+ await assertToolSurface({
18561
+ services,
18562
+ runtimeTools,
18563
+ getReads: { registry: getReadsRegistry },
18564
+ cliCallable: { config: cliConfig },
18565
+ transportParity: { http: { handler }, mcp: { handler: mcpHandler }, agent: { invoker: agentInvoker }, cli: { invoker: cliInvoker }, cases },
18566
+ deadReferences: { cwd: process.cwd(), globs: ['src/prompts/**/*.md'], ignore: {} },
18567
+ schemaRatchet: { baseline: { path: 'tests/tool-surface-ratchet.json' }, updateCommand: 'bun scripts/update-ratchet.ts' },
18568
+ })
18569
+ ```
18570
+
18212
18571
  The kit never starts a server, discovers Socket.IO topology remotely, invents
18213
18572
  credentials or synthesises invalid Zod values. Fixtures and observations come
18214
18573
  from the application. The realtime driver creates a rejection channel per
@@ -21255,6 +21614,65 @@ charts, no merged cells and no streaming: an application that needs them takes a
21255
21614
 
21256
21615
  # Upgrading stitchkit
21257
21616
 
21617
+ ## Released migration: 0.137.0
21618
+
21619
+ ### contradictory-read-annotations
21620
+
21621
+ **Who must act:** applications declaring contract endpoints (`defineContract`) or runtime tools (`defineRuntimeTool`) that combine `effect` with a contradicting `tool.annotations.readOnlyHint` or `tool.annotations.destructiveHint`.
21622
+
21623
+ One canonical `isReadOnlyOperation` rule now drives HTTP client network-failure replay, MCP `readOnlyHint` publication, CLI refused-view withholding, and tool surface gates (ADR 0345). Direct contradictions (`effect: 'read'` with `readOnlyHint: false` or `destructiveHint: true`, and `effect: 'write'` with `readOnlyHint: true`) are now refused at declaration time instead of disagreeing across transports:
21624
+
21625
+ ```ts
21626
+ // Before — diverged between HTTP client replay and MCP annotations
21627
+ run: {
21628
+ method: 'GET', path: '/run', desc: 'Mutating operation',
21629
+ effect: 'write',
21630
+ tool: { annotations: { readOnlyHint: true } },
21631
+ }
21632
+
21633
+ // After — declare the true effect without contradicting annotations
21634
+ run: {
21635
+ method: 'GET', path: '/run', desc: 'Mutating operation',
21636
+ effect: 'write',
21637
+ }
21638
+ ```
21639
+
21640
+ A `GET` endpoint declaring `tool: { annotations: { readOnlyHint: false } }` without `effect` stays valid and now disables HTTP client replay as well as MCP `readOnlyHint`. Conversely, a non-`GET`/`HEAD` endpoint (such as a `POST` search) declaring `effect: 'read'` or `tool: { annotations: { readOnlyHint: true } }` (without `destructiveHint: true`) now auto-replays on transport failure unless the endpoint sets `idempotent: false`.
21641
+
21642
+ ### error-code-mapping-type
21643
+
21644
+ **Who must act:** applications importing the TypeScript type `ErrorHookMapping` directly from `stitchkit/server` or `stitchkit/handler`.
21645
+
21646
+ `ErrorHookMapping` is now the transport-neutral `ErrorCodeMapping` exported from `stitchkit/contract` (and re-exported from `stitchkit`, `stitchkit/server`, and `stitchkit/handler`) so the same mapping type can be passed to `createErrorHook`, MCP mounts, agent tool mounts, `createToolInvoker`, `createCli`, `createCliInvoker`, and `createToolkit`:
21647
+
21648
+ ```ts
21649
+ // Before
21650
+ import type { ErrorHookMapping } from 'stitchkit/server'
21651
+
21652
+ // After
21653
+ import type { ErrorCodeMapping } from 'stitchkit/contract'
21654
+ ```
21655
+
21656
+ Runtime calls to `createErrorHook({ vocabulary, render })` and `createErrorHook({ codeMap, unmappedCode, render })` keep their existing shape and also accept optional `redact` to mask internal wire messages and strip details/hints on HTTP and tool transports alike.
21657
+
21658
+ ### local-control-error-codes
21659
+
21660
+ **Who must act:** applications maintaining an exhaustive `Record<StitchErrorCode, …>` map (`satisfies Record<StitchErrorCode, …>` or `defineErrors(..., { exhaustive: true })`).
21661
+
21662
+ Eight framework error codes were added to `STITCH_ERROR_STATUS` / `StitchErrorCode` for local control-socket limits and native-consent key issuance (ADR 0346): `HEADERS_TOO_LARGE` (431), `REQUEST_TOO_LARGE` (413), `CONTROL_API_BUSY` (503), `ROLE_NOT_ALLOWED` (403), `KEYS_MANAGE_REQUIRED` (403), `INIT_DENIED` (403), `INIT_TIMEOUT` (408), and `CONSENT_PENDING` (409). Add them to exhaustive maps, or use a partial `ErrorCodeMapping` with `unmappedCode`:
21663
+
21664
+ ```ts
21665
+ // Add the 8 new framework codes to exhaustive Record<StitchErrorCode, ...> maps:
21666
+ HEADERS_TOO_LARGE: 'bad_request',
21667
+ REQUEST_TOO_LARGE: 'bad_request',
21668
+ CONTROL_API_BUSY: 'unavailable',
21669
+ ROLE_NOT_ALLOWED: 'forbidden',
21670
+ KEYS_MANAGE_REQUIRED: 'forbidden',
21671
+ INIT_DENIED: 'forbidden',
21672
+ INIT_TIMEOUT: 'timeout',
21673
+ CONSENT_PENDING: 'conflict',
21674
+ ```
21675
+
21258
21676
  ## Released migration: 0.136.0
21259
21677
 
21260
21678
  ### trusted-proxy-chain
@@ -29028,6 +29446,9 @@ from the root `stitchkit`.
29028
29446
  | Export | Kind | Summary |
29029
29447
  |--------|------|---------|
29030
29448
  | `defineContract` | function | declare a contract — [guide](../guide/contracts.md#definecontract) |
29449
+ | `defineEndpoints` / `composeEndpoints` / `ScopedDefineEndpoints` | functions / _type_ | split a large contract across files with declaration-site excess-property/scope checks and compile-time + runtime duplicate operation refusal — [guide](../guide/contracts.md) |
29450
+ | `DEFAULT_TIME_ZONE` / `IanaTimeZoneSchema` / `IanaTimeZone` / `canonicalizeIanaTimeZone` | const / schema / _type_ / function | browser- and server-safe IANA time zone schema (`'UTC'` default, rejecting bare offsets like `'+08:00'`) and runtime `Intl` canonicalizer |
29451
+ | `isReadOnlyOperation` / `OperationReadClassification` | function / _type_ | canonical read-only predicate shared by HTTP client replay, MCP `readOnlyHint` publication, CLI refused-view withholding, and tool surface gates — [ADR 0345](../decisions/0345-one-read-rule-across-client-replay-and-tool-surfaces.md) |
29031
29452
  | `ConfiguredScopedDefineContract` | _type_ | scoped authoring parameterized by the exact default transport tuple; explicit endpoint exposure replaces it |
29032
29453
  | `ConfiguredToolExposureEndpoints` | _type_ | endpoint map with materialized exposure; a second generic selects defaults (HTTP when omitted), preserving explicit, optional and conditional overrides |
29033
29454
  | `createContractFactory` | function | a `defineContract` whose scope — on the contract **and** on any endpoint override — is required and held to your union, retaining each concrete literal — [guide](../guide/contracts.md#scope) |
@@ -29087,16 +29508,16 @@ from the root `stitchkit`.
29087
29508
  | `MultipartDescriptor` | _type_ | file fields, cardinality, delivery and request/text limits |
29088
29509
  | `MultipartFilePolicy` | _type_ | required/multiple, per-file bytes/count and declared MIME policy |
29089
29510
  | `MultipartBufferedFiles` | _type_ | `File` map inferred from a multipart descriptor |
29090
- | `EndpointToolAnnotations` | _type_ | MCP behavioural hints on an endpoint (`readOnlyHint` / `destructiveHint` / `title`); omitted `readOnlyHint` derives `true` when `effect: 'read'` (or `GET` without `effect: 'write'`) and `destructiveHint !== true` |
29511
+ | `EndpointToolAnnotations` | _type_ | MCP behavioural hints on an endpoint (`readOnlyHint` / `destructiveHint` / `title`); omitted `readOnlyHint` derives `true` when `effect: 'read'` (or `GET` / `HEAD` without `effect: 'write'`) and `destructiveHint !== true` |
29091
29512
  | `EndpointUiMeta` | _type_ | MCP Apps widget metadata on an endpoint |
29092
29513
  | `EndpointMcpInputRequired` | _type_ | typed MCP multi-round input request (`key`, message and Zod object schema) |
29093
29514
  | `EndpointMcpPolicy` | _type_ | MCP-only endpoint policy containing `inputRequired` |
29094
29515
 
29095
29516
  ### Errors
29096
29517
 
29097
- | `ErrorVocabularyCode` / `ErrorVocabularyMapping` / `VocabularyCodeMap` | _type_ | application-code union, partial/exhaustive framework mapping input and resolved wire map returned by `defineErrors` |
29098
29518
  | Export | Kind | Summary |
29099
29519
  |--------|------|---------|
29520
+ | `ErrorVocabularyCode` / `ErrorVocabularyMapping` / `VocabularyCodeMap` / `ErrorCodeMapping` | _type_ | application-code union, partial/exhaustive framework mapping input, resolved wire map returned by `defineErrors`, and transport-neutral error-code mapping shared across HTTP, MCP, AGENT, CLI, and `createToolkit` |
29100
29521
  | `AppError` | class | the framework error — `code` / `status` / `details` / `hint` |
29101
29522
  | `ErrorEnvelope` | _type_ | the JSON shape of an error response, preserving optional declared boolean `error.retryable` without changing HTTP retry policy |
29102
29523
  | `notFound` | function | throw `404 NOT_FOUND` — [guide](../guide/auth-and-errors.md#throwing-errors) |
@@ -29159,6 +29580,8 @@ realtime contract from `stitchkit`, and the server halves live in `stitchkit/app
29159
29580
  | `watchContract` | const | the four-event realtime contract a watched read travels on |
29160
29581
  | `WATCH_OPEN` / `WATCH_CLOSE` / `WATCH_VALUE` / `WATCH_STATE` | const | the event names of that contract |
29161
29582
  | `WatchKey` / `WatchKeySchema` / `watchKeyString` | type / schema / function | `(service, action, arguments digest)` — the identity both ends compute the same way |
29583
+ | `WatchOpenInput` / `WatchAccepted` | _types_ | Zod-inferred payload (`{ key, args, have? }`) and acknowledgement (`{ accepted, reason? }`) for `WATCH_OPEN` |
29584
+ | `createWatchFanout` / `WatchFanout` / `WatchFanoutConfig` / `WatchFanoutUpstream` / `WatchFanoutDelivery` | function / _types_ | multi-client watch relay sharing one upstream subscription per `(service, action, digest)` across local windows while preserving per-client `WatchKey.instance`, host copy verification, monotonic downstream revisions across cloud restarts, resync on bad deltas, and `forget` / `reopen` — [guide](../guide/live.md#relaying-watches-to-multiple-local-windows-createwatchfanout) |
29162
29585
  | `WatchValueFrame` / `WatchValueSchema` / `WatchStateFrame` / `WatchStateSchema` | _types_ | one answer — `full`, `delta` or `unchanged`, with its monotonic revision and fingerprint — and a phase from `LiveStatePhase` with the read's own code and message |
29163
29586
  | `WatchHave` / `WatchHaveSchema` | type / schema | what a reconnecting subscriber already holds, offered on `open`: a revision and the fingerprint that proves it |
29164
29587
  | `WatchDelta` / `WatchDeltaSchema` / `WatchArrayOp` / `WatchArrayOpSchema` | _types_ / schemas | a structural difference over parsed JSON — objects by changed and dropped key, arrays by runs copied from the previous value |
@@ -29246,6 +29669,11 @@ Also re-exports the error helpers from `stitchkit/contract`.
29246
29669
  | `createServer` | function | build the router and start `Bun.serve` — [guide](../guide/server.md#createserver) |
29247
29670
  | `createHandler` | function | the router as a bare `(req) => Response` — [guide](../guide/server.md#createserver) |
29248
29671
  | `createLocalHostGuard` / `LocalHostGuard` / `LocalHostGuardConfig` / `LocalHostRefusal` | function / _types_ | a host that serves only its own machine's windows: loopback `Host`, allowed `Origin`, a constant-time Bearer secret — as `hooks.onRequest` and as Socket.IO `allowRequest` and `handshake`, with `cors` for the same origins (`undefined` when `origins` is empty for native-only hosts) — [guide](../guide/server.md#a-host-beside-its-own-window) |
29672
+ | `createLocalHostClients` / `DEFAULT_LOCAL_HOST_CLIENT_ID_HEADER` / `HostClient` / `LocalHostClientData` / `LocalHostClients` / `LocalHostClientsConfig` / `LocalHostClientsSetup` | function / const / _types_ | per-window identity (`labelSchema` + `guard` handshake), targeted `sendTo(client, ...)`, HTTP `callerFromRequest(req)`, `clients()`, `onClientGone` / `onLastClientGone`, and CORS header extension for multi-window local hosts — [guide](../guide/server.md#tracking-multiple-windows-createlocalhostclients) |
29673
+ | `extractReportedClient` / `ReportedClient` / `ReportedClientField` / `ReportedClientOptions` | function / _types_ | extract sanitized caller-supplied attribution headers tagged `verified: false` for local control sockets — [ADR 0346](../decisions/0346-local-control-socket-trust-model-and-consent-key-issuance.md), [ADR 0347](../decisions/0347-unix-socket-peer-credentials-boundary.md) |
29674
+ | `createLocalControlJournal` / `LocalControlJournal` / `LocalControlJournalConfig` / `LocalControlJournalEntry` / `LocalControlJournalEntrySchema` | function / _types_ / schema | append-only `0600` metadata-only JSONL call journal with serialized `.1` rotation and bounded `maxPendingWrites` backpressure queue for local control sockets |
29675
+ | `createLocalControlGuard` / `LocalControlGuard` / `LocalControlGuardConfig` | function / _types_ | wrap local control socket `fetch` with `maxHeaderBytes` (`431 HEADERS_TOO_LARGE`), explicit `Content-Length` / `maxBodyBytes` (`413 REQUEST_TOO_LARGE` / `400 BAD_REQUEST`), `maxConcurrentRequests` (`503 CONTROL_API_BUSY` holding slots for live streams), and journal recording |
29676
+ | `createLocalConsentKeyIssuance` / `LocalConsentAuthorization` / `LocalConsentDecision` / `LocalConsentKeyConfig` / `LocalConsentKeyIssuance` / `LocalConsentKeyRequest` / `LocalConsentKeyRequestSchema` / `LocalConsentQuestion` | function / _types_ / schema | fail-closed native-consent program key issuance route (`ROLE_NOT_ALLOWED`, `KEYS_MANAGE_REQUIRED`, `INIT_DENIED`, `INIT_TIMEOUT` non-retryable, `CONSENT_PENDING`, `no-store`) plus `guardWhileConsentPending` |
29249
29677
  | `implement` | function | bind a contract to typed handlers — [guide](../guide/server.md#implement) |
29250
29678
  | `withContractIdentity` | function | the given services plus the one answering `contractIdentityContract` with their fingerprint — the list to mount — [guide](../guide/client.md#which-contract-does-the-server-speak) |
29251
29679
  | `createImplement` | function | fix the handler context type once |
@@ -29320,7 +29748,7 @@ Also re-exports the error helpers from `stitchkit/contract`.
29320
29748
  | `createAuthHook` | function | one scope gate for HTTP `authorize` and tool `beforeHandle` — [guide](../guide/auth-and-errors.md#createauthhook) |
29321
29749
  | `composeAuthHooks` | function | route multiple canonical auth domains by owned scope and atomically commit their typed contributions |
29322
29750
  | `createErrorHook` | function | an async-capable, endpoint-aware `onError` hook from a `defineErrors` vocabulary or a code map, plus an envelope renderer — [guide](../guide/auth-and-errors.md#createerrorhook) |
29323
- | `ErrorHookBase` / `ErrorHookMapping` | _type_ | common hook fields and the vocabulary-or-map branch accepted by `createErrorHook` |
29751
+ | `ErrorHookBase` / `ErrorCodeMapping` | _type_ | common hook fields and the transport-neutral vocabulary-or-map branch accepted by `createErrorHook` |
29324
29752
  | `ErrorHookConfig` | _type_ | async observer/renderer config with partial `codeMap` and optional typed `unmappedCode` fallback |
29325
29753
  | `ResolvedError` | _type_ | the normalised error handed to `createErrorHook`'s `render` |
29326
29754
  | `createBearerResolver` | function | a bearer-token identity resolver |
@@ -29477,7 +29905,7 @@ lane never reaches the hooks on either runtime.
29477
29905
  |--------|------|---------|
29478
29906
  | `createTrustFence` | function | `hooks` for the HTTP lane and `allowRequest` for the Socket.IO lane; a bare 403 that never says which rule refused |
29479
29907
  | `isLoopbackAddress` | function | whether an address is this machine — for the auth rule a privileged operation belongs in, not for the fence |
29480
- | `TrustFence` / `TrustFenceConfig` / `TrustRefusal` / `TrustRefusalReason` / `TrustLane` | _types_ | the two admission points, the declared authorities, and why and where a request was refused |
29908
+ | `TrustFence` / `TrustFenceConfig` / `TrustRefusal` / `TrustRefusalReason` / `TrustLane` | _types_ | the two admission points, the declared authorities (`trustedHosts`, `trustedOrigins`, and optional HTTP `GET`/`HEAD`-only `publicReads`), and why and where a request was refused |
29481
29909
  | `RouteGroupHooks` | _type_ | a route group's hooks — `LifecycleHooks` without `onRequest`, which runs before the group is known |
29482
29910
 
29483
29911
  ---
@@ -30808,7 +31236,7 @@ audit event. See the [Observability guide](../guide/observability.md).
30808
31236
  |--------|------|---------|
30809
31237
  | `createObservability` | function | configure framework-owned request completion and canonical tool event sinks — [guide](../guide/observability.md#createobservability) |
30810
31238
  | `auditChanges` | function | the sink `filter` most projects write themselves — drops `GET`/`HEAD`/`OPTIONS`, keeps `401`/`403` whatever the verb, keeps an unrecognised verb |
30811
- | `createSpooledSink` / `SpooledSink` / `SpooledSinkConfig` / `SpoolRecovery` | function / _types_ | spool the row to an append-only file before the store and replay what a previous process left undelivered — at least once, keyed on `spanId`; `recover()` reads the file line by line, and a debt over `maxFileBytes` goes to `<path>.<ms>.overflow`, named by `SpoolRecovery.quarantined` and reported as `SPOOL_QUARANTINED`, so new records still spool; a file that cannot be read sets `unread: true` and reports `SPOOL_UNREADABLE` with its `cause`, never `{ replayed: 0, failed: 0 }`; a row past `maxPendingEntries` or `maxFileBytes` that the store also refuses rejects `write` with `SPOOL_UNSPOOLED` (store error as `cause`) and `onSpoolError` reports `SPOOL_FULL` (ADR 0323) |
31239
+ | `createSpooledSink` / `SpooledSink` / `SpooledSinkConfig` / `SpoolRecovery` | function / _types_ | spool the row to an append-only file before the store, replay what a previous process left undelivered (`recover()`), and redeliver spooled rows in the same process via bounded single-flight auto-drain once the store accepts a write again plus explicit `flush(): Promise<SpoolRecovery>` — at least once, keyed on `spanId`; `recover()` reads the file line by line, and a debt over `maxFileBytes` goes to `<path>.<ms>.overflow`, named by `SpoolRecovery.quarantined` and reported as `SPOOL_QUARANTINED`, so new records still spool; a file that cannot be read sets `unread: true` and reports `SPOOL_UNREADABLE` with its `cause`, never `{ replayed: 0, failed: 0 }`; a row past `maxPendingEntries` or `maxFileBytes` that the store also refuses rejects `write` with `SPOOL_UNSPOOLED` (store error as `cause`) and `onSpoolError` reports `SPOOL_FULL` (ADR 0323) |
30812
31240
  | `createDimensionsProjector` / `DimensionsProjector` / `DimensionsProjectorConfig` / `ProjectedDimensions` | function / _type_ | typed request/result/error attribution projected into the existing request context |
30813
31241
  | `DimensionCollision` / `SetRequestDimensionsOptions` | _type_ | explicit overwrite, preserve or error policy for dimension keys |
30814
31242
  | `createBoundedLogger` | function | decorate a `StitchLogger` with request context, shared sanitisation, redaction and total bounds |
@@ -31218,8 +31646,8 @@ Server-only. One context-typed tool set for MCP servers, peer-free `mountAgentTo
31218
31646
 
31219
31647
  | Export | Kind | Summary |
31220
31648
  |--------|------|---------|
31221
- | `createToolkit` | function | context-typed tool mounts (`mountMcp`, `mountAgentTools`, `buildMcpServer`, `createMcpHandler`, `createStdioMcpServer`, `createCli`) — [guide](../guide/cli.md#typed-context) |
31222
- | `Toolkit` | _type_ | the context-pinned tool surface from `createToolkit` (including both `mountAgentTools(services, config)` and single-argument `mountAgentTools(config)`; no AI SDK `mountAgent`) |
31649
+ | `createToolkit` | function | context-typed tool mounts (`mountMcp`, `mountAgentTools`, `buildMcpServer`, `createMcpHandler`, `createStdioMcpServer`, `createCli`) with optional shared `ToolkitConfig` defaults (`errors`) — [guide](../guide/cli.md#typed-context) |
31650
+ | `Toolkit` / `ToolkitConfig` | _types_ | the context-pinned tool surface from `createToolkit` and its optional default `{ errors? }` config |
31223
31651
 
31224
31652
  ## `stitchkit/tools/connections`
31225
31653
 
@@ -31325,6 +31753,9 @@ handler pipeline without opening a TCP port.
31325
31753
  | `McpSchemaValidationConfig` / `IncompatibleSchemaPolicy` | _type_ | canonical MCP schema-preparation policy used by real mounts and manifests |
31326
31754
  | `SurfaceRealtimeSchemaPairSchema` | schema | input/output digest pair for args or acknowledgements |
31327
31755
  | `SurfaceSchemaDigestsSchema` | schema | params/input/output/multipart digest object |
31756
+ | `checkToolSurface` / `assertToolSurface` / `computeToolSurfaceRatchet` / `writeToolSurfaceBaseline` / `formatToolSurfaceReport` / `ToolSurfaceError` | functions / class | peer-free unified tool-surface gate covering `getReads`, `cliCallable`, `noRefs`, `outputJsonSchema`, `transportParity`, `deadReferences`, and bidirectional `schemaRatchet` with atomic `0644` baseline writing — [guide](../guide/testing-and-deployment.md#tool-surface-gates-checktoolsurface) |
31757
+ | `TOOL_SURFACE_CHECK_NAMES` / `ToolSurfaceCheckName` / `ToolSurfaceCheckNameSchema` / `ToolSurfaceFinding` / `ToolSurfaceFindingSchema` / `ToolSurfaceGetReadsRegistry` / `ToolSurfaceGetReadsRegistrySchema` / `ToolSurfaceRatchetBaseline` / `ToolSurfaceRatchetBaselineSchema` | const / schemas / _types_ | closed check vocabulary, structured finding, GET-reads registry, and ratchet baseline schemas for `checkToolSurface` |
31758
+ | `ToolSurfaceCheckConfig` / `ToolSurfaceCheckOutcome` / `ToolSurfaceCheckReport` / `ToolSurfaceGetReadsConfig` / `ToolSurfaceCliCallableConfig` / `ToolSurfaceCliConfig` / `ToolSurfaceProjectionOptions` / `ToolSurfaceMcpSurface` / `ToolSurfaceDeadReferencesConfig` / `ToolSurfaceParityConfig` / `ToolSurfaceParityCase` / `ToolSurfaceParityTransport` / `ToolSurfaceHttpParityTarget` / `ToolSurfaceMcpParityTarget` / `ToolSurfaceAgentParityTarget` / `ToolSurfaceCliParityTarget` / `ToolSurfaceRatchetConfig` / `ToolSurfaceRatchetSnapshot` | _types_ | configuration, report, transport parity targets, and ratchet snapshot types for `checkToolSurface` |
31328
31759
 
31329
31760
  ---
31330
31761
 
@@ -31384,7 +31815,7 @@ Peer-free, server-only spend accounting for paid model APIs (→ [guide](../guid
31384
31815
  | `SpendGatewayError` | class | `code`: `unknown-provider`, `origin-mismatch`, `no-attribution`, `intent-unrecorded`, `refused` (`admit` said no; recorded as a `refused` attempt) — every one refused before anything was sent |
31385
31816
  | `runWithSpendAttribution` / `getSpendAttribution` | function | the attribution of every gateway call in a call chain (AsyncLocalStorage); nested calls refine, `labels` merge |
31386
31817
  | `openAiCompatibleUsage` / `SpendFactsReader` | const / _type_ | reads `id`, `model` and `usage` (tokens, reasoning, cache, OpenRouter's `cost`) from a JSON body or the stream's events |
31387
- | `createSpooledSpendStore` / `SpooledSpendStore` / `SpooledSpendStoreConfig` | function / _types_ | a ledger that survives its database: on disk first (`0o600`, bounded), delivered after; `recover()` replays in order, an attempt before its receipts — a receipt whose attempt is undelivered waits on disk with it, in the live path too; a record neither spooled nor stored refuses the call; `pendingCosts` and `openAttempts` pass through |
31818
+ | `createSpooledSpendStore` / `SpooledSpendStore` / `SpooledSpendStoreConfig` | function / _types_ | a ledger that survives its database: on disk first (`0o600`, bounded), delivered after; `recover()` replays in order, an attempt before its receipts — a receipt whose attempt is undelivered waits on disk with it, in the live path too; once the store accepts a subsequent write, bounded single-flight in-process auto-drain and explicit `flush(): Promise<SpoolRecovery>` redeliver spooled rows in order without restarting; a record neither spooled nor stored refuses the call; `pendingCosts` and `openAttempts` pass through |
31388
31819
  | `mergeSpendReceipt` | function | the monotone merge a ledger applies: a higher rank adds what it knows, equal ranks resolve by `at` (a factual cost breaks exact-timestamp ties), a closed outcome never returns to `pending`, a reported cost is never erased, a non-factual rank-3 reconciler receipt neither pollutes a factual cost with `failureCode`/`failureMessage` nor leaves those fields behind once a factual price arrives (while rank 1–2 transport failure codes stay intact), and an `orphaned` close never replaces a real one (a real one replaces it) |
31389
31820
  | `reconcilePendingSpend` / `SpendReconciler` / `ReconcilePendingSpendOptions` / `SpendReconcileResult` | function / _types_ | one pass over attempts whose cost is `pending`: each gateway's reconciler answers, rank-3 receipts are settled; optional `maxPendingAgeMs` (positive safe integer validated upfront) settles attempts whose reconciler still returns `undefined` at or past that age since `record.receipt.at` (or `record.attempt.startedAt`) as `costStatus: 'unknown'` with `failureCode: 'price-never-reported'` (while reconciler throws and gateways without a reconciler stay `pending`); `onError` sees a reconciler that threw or returned invalid facts, an invalid record timestamp, or a receipt-merge failure (while broken `now()` clocks and `store.settle` failures still reject) |
31390
31821
  | `closeOrphanedSpend` | function | closes attempts left open longer than `olderThanMs` as `orphaned` with an `unknown` cost |
@@ -31853,7 +32284,11 @@ The server half, inside the application's own transaction. See the [sync guide](
31853
32284
 
31854
32285
  ## `stitchkit/postgres`
31855
32286
 
31856
- Server-only, peer-free PostgreSQL application helpers. Wraps any Prisma SQL driver adapter factory
32287
+ Server-only, peer-free PostgreSQL application helpers. `postgresConnectionConfig`
32288
+ surgically strips `?options=` from `DATABASE_URL` and merges URL options, config options,
32289
+ custom parameters, `searchPath`, and `timeZone` (default `'UTC'`) in startup-packet order
32290
+ for `PrismaPg` and `pg.Pool` without rewriting unrelated parameters or importing `pg`.
32291
+ `withSerializedPrismaTransactions` wraps any Prisma SQL driver adapter factory
31857
32292
  (such as `new PrismaPg(...)`) without importing `@prisma/adapter-pg` or `pg`, so statements inside
31858
32293
  each interactive transaction reach its single PostgreSQL connection one at a time while queries
31859
32294
  outside transactions and separate transactions stay parallel across the pool. See
@@ -31861,20 +32296,27 @@ outside transactions and separate transactions stay parallel across the pool. Se
31861
32296
 
31862
32297
  ```ts
31863
32298
  import { PrismaPg } from '@prisma/adapter-pg';
31864
- import { withSerializedPrismaTransactions } from 'stitchkit/postgres';
32299
+ import {
32300
+ postgresConnectionConfig,
32301
+ withSerializedPrismaTransactions,
32302
+ } from 'stitchkit/postgres';
31865
32303
 
31866
32304
  const adapter = withSerializedPrismaTransactions(
31867
- new PrismaPg({ connectionString: env.DATABASE_URL }),
32305
+ new PrismaPg(postgresConnectionConfig(env.DATABASE_URL)),
31868
32306
  );
31869
32307
  const prisma = new PrismaClient({ adapter });
31870
32308
  ```
31871
32309
 
31872
32310
  | Export | Kind | Summary |
31873
32311
  |--------|------|---------|
32312
+ | `postgresConnectionConfig` | function | build a `pg.PoolConfig` / `PrismaPg`-compatible config from a connection string or plain config object, stripping `?options=` surgically from the URL, validating raw fragments against `pg_split_opts` boundaries, and appending `parameters`, `searchPath` and `timeZone` (default `'UTC'`; `null` omits) so later startup flags win |
32313
+ | `PostgresConnectionConfig` | _type_ | minimal `{ connectionString, options? }` shape accepted and returned by `postgresConnectionConfig`, structurally compatible with `pg.PoolConfig` without importing `pg` |
32314
+ | `PostgresConnectionOptions` | _type_ | structured session options for `postgresConnectionConfig` (`timeZone`, `searchPath`, `parameters`) |
31874
32315
  | `withSerializedPrismaTransactions` | function | wraps a Prisma SQL driver adapter factory (`connect` and optional `connectToShadowDb`) so `queryRaw`, `executeRaw`, `commit`, `rollback` and savepoints inside each interactive transaction execute in strict FIFO order without overlapping on one connection; idempotent and fails fast with `TypeError` on non-factory inputs (such as a raw `pg.Pool`) |
31875
32316
  | `PrismaDriverAdapterFactory` | _type_ | minimal structural Prisma SQL driver adapter factory (`provider`, `adapterName`, `connect`, optional `connectToShadowDb`) accepted by `withSerializedPrismaTransactions` |
31876
32317
  | `PrismaDriverAdapter` | _type_ | minimal structural connected Prisma SQL driver adapter (`startTransaction`) |
31877
32318
  | `PrismaDriverTransaction` | _type_ | minimal structural interactive transaction handle (`queryRaw`, `executeRaw`, `commit`, `rollback` and optional savepoints) |
32319
+ | `runRollbackTransaction` / `InteractiveTransactionClient` / `PlannedRollback` / `TransactionRollback` / `RollbackTransactionResult` | function / _types_ | peer-free planned-rollback interactive transaction helper (`return rollback(value)`) for dry-run and stop-on-first-failure flows without swallowing real database errors |
31878
32320
 
31879
32321
  ---
31880
32322
 
@@ -32016,6 +32458,11 @@ runtime-agnostic pieces of `stitchkit/server` and the error helpers.
32016
32458
  | `serveNode` | function | build the router and start a Node HTTP server (via `srvx`) |
32017
32459
  | `createHandler` | function | the router as a bare `(req) => Response` (same as `/server`) |
32018
32460
  | `createLocalHostGuard` / `LocalHostGuard` / `LocalHostGuardConfig` / `LocalHostRefusal` | function / _types_ | the local-host guard for `serveNode` (same as `/server`) |
32461
+ | `createLocalHostClients` / `DEFAULT_LOCAL_HOST_CLIENT_ID_HEADER` / `HostClient` / `LocalHostClientData` / `LocalHostClients` / `LocalHostClientsConfig` / `LocalHostClientsSetup` | function / const / _types_ | multi-window local-host client identity, `sendTo`, `callerFromRequest`, and departure hooks for `serveNode` (same as `/server`) |
32462
+ | `extractReportedClient` / `ReportedClient` / `ReportedClientField` / `ReportedClientOptions` | function / _types_ | extract sanitized caller-supplied attribution headers tagged `verified: false` for local control sockets (same as `/server`) |
32463
+ | `createLocalControlJournal` / `LocalControlJournal` / `LocalControlJournalConfig` / `LocalControlJournalEntry` / `LocalControlJournalEntrySchema` | function / _types_ / schema | append-only `0600` metadata-only JSONL call journal with serialized `.1` rotation and bounded `maxPendingWrites` backpressure queue (same as `/server`) |
32464
+ | `createLocalControlGuard` / `LocalControlGuard` / `LocalControlGuardConfig` | function / _types_ | local control-socket fetch guard with header, body, concurrency, and journal limits (same as `/server`) |
32465
+ | `createLocalConsentKeyIssuance` / `LocalConsentAuthorization` / `LocalConsentDecision` / `LocalConsentKeyConfig` / `LocalConsentKeyIssuance` / `LocalConsentKeyRequest` / `LocalConsentKeyRequestSchema` / `LocalConsentQuestion` | function / _types_ / schema | fail-closed native-consent program key issuance route plus `guardWhileConsentPending` (same as `/server`) |
32019
32466
  | `createSocketIOServer` | function | the typed Node Socket.IO server (`io` + `attach`; no Bun engine declarations) |
32020
32467
  | `createUnixClientTransport` | function | the same fail-closed Bun/Node Unix client adapter exported by `stitchkit/server` (including optional `expectedOwnerUid`) |
32021
32468
  | `implement` / `createImplement` / `createScopedImplement` / `createScopedImplementRegistry` / `createMultipartStream` | function | bind a contract to typed handlers, optionally typed per endpoint scope (same as `/server`) |
@@ -32051,6 +32498,8 @@ SDK nor the `ai` peer.
32051
32498
  | `CliArgumentError` | class | the refusal `parseCliArgs` and the view flags raise; a CLI reports it and exits `2` |
32052
32499
  | `renderCliView` | function | compute an aggregate over a result (`--count-by`, `--sum`, `--top`, `--table`) — [guide](../guide/cli.md#aggregate-views) |
32053
32500
  | `createCliProfileStore` | function | named `0600` credential profiles resolved by name, with the never-substitute rule built in — [guide](../guide/cli.md#named-profiles) |
32501
+ | `readSecret` / `readSecretFile` / `ReadSecretOptions` / `ReadSecretFileOptions` / `SecretInputStream` | functions / _types_ | read a secret from a TTY in raw mode without echo (restoring terminal mode in `finally`) or piped stdin, or from a `0600` regular file via `O_NOFOLLOW | O_NONBLOCK` — [guide](../guide/cli.md#native-binary-commands) |
32502
+ | `defineLocalKeyInitCommand` / `LocalKeyInitCommandConfig` / `LocalKeyInitOutput` / `LocalKeyInitOutputSchema` | function / _types_ / schema | native CLI command requesting a consent-gated local program key over a `0600` Unix control socket without retries and saving it to a `0600` profile without printing the secret |
32054
32503
  | `CliProfileError` | class | an `AppError` refusing a named profile that is missing, unreadable or shared between users |
32055
32504
  | `renderCliInstaller` | function | generate the one-line installer from a build manifest, with the URL and digest substituted — [guide](../guide/cli.md#distribution-and-self-update) |
32056
32505
  | `checkCliUpdate` | function | bounded, interval-limited, never-throwing check for a newer published build |
@@ -32059,7 +32508,7 @@ SDK nor the `ai` peer.
32059
32508
  | `rollbackCliUpdate` / `CliRollbackConfig` / `RolledBackCliUpdate` | function / _types_ | put the kept previous build back, digest-checked first and written by the same atomic rename the update uses |
32060
32509
  | `signCliManifest` / `verifyCliManifest` / `cliManifestSigningPayload` | function | Ed25519 over `{name, version, commit, builtAt, assets[]}` — every asset's digest included, so the chain closes on the file that executes |
32061
32510
  | `cliSignatureAccepted` / `CliSignatureVerdict` | function / _type_ | `valid` \| `unenforced` \| `missing` \| `unknown-key` \| `invalid`; `unenforced` keeps an unpinned build updating while making the absence of a check visible |
32062
- | `CliTrustRoot` / `CliSigningKey` / `CliBuildSignature` / `CliBuildSignatureSchema` | _types_ / schema | the keys a build trusts, by id, and the detached signature a manifest carries |
32511
+ | `CliTrustRoot` / `CliTrustRootSchema` / `CliSigningKey` / `CliBuildSignature` / `CliBuildSignatureSchema` | _types_ / schemas | the keys a build trusts, by id (validated non-empty Ed25519 SPKI PEM or canonical 32-byte base64 via `CliTrustRootSchema`), and the detached signature a manifest carries |
32063
32512
  | `selectCliBuildAsset` | function | the asset for one target, or `undefined` |
32064
32513
  | `currentCliBuildTarget` | function | `{ platform, arch }` of the running process |
32065
32514
  | `formatCliBuildStamp` | function | one line saying what the running build is |
@@ -32131,9 +32580,12 @@ in `stitchkit/cli` — [guide](../guide/cli.md#publishing-a-complete-version),
32131
32580
  | `CliShippingInputsChangedOptions` | _type_ | options for `cliShippingInputsChanged` (`repository`, `previousCommit`, `nextCommit`, `shippingPaths`, `timeoutMs`, `signal`) |
32132
32581
  | `assertCleanCliSource` | function | verify a clean git root matching optional `expectedCommit`, optional `untrackedPaths` globs and optional `servingSource` realpath; returns verified 40-hex `HEAD` |
32133
32582
  | `CleanCliSourceOptions` | _type_ | options for `assertCleanCliSource` (`repository`, `expectedCommit`, `untrackedPaths`, `servingSource`, `timeoutMs`, `signal`) |
32134
- | `createCliDistributionRoutes` | function | portable `RawRoute[]` (`GET` only) serving verified signed channel manifests (`no-store`), immutable versioned manifests and descriptor-streamed binary assets, and `install.sh`, failing closed with `503 No verified CLI build is published` |
32583
+ | `createCliDistributionRoutes` | function | portable `RawRoute[]` (`GET` only) serving verified signed channel manifests (`no-store`), immutable versioned manifests and descriptor-streamed binary assets, and `install.sh`; returns `CLI_DISTRIBUTION_UNPUBLISHED_RESPONSE` (`503`, `x-stitchkit-cli-distribution-state: unpublished`) only for a missing channel manifest and fails closed with `503` (`x-stitchkit-cli-distribution-state: unavailable`) on all configuration, path, integrity and signature faults |
32135
32584
  | `CliDistributionRoutesOptions` | _type_ | options for `createCliDistributionRoutes` (`root`, `name`, `trust`, `channels`, `installerChannel`, `basePath`, `binaryName`, `installDir`, `maxManifestBytes`, `serviceName`, `onUnavailable`) |
32136
32585
  | `CliDistributionUnavailableEvent` | _type_ | diagnostic event passed to `onUnavailable` with `route`, `channel`, optional `version`/`asset`, inline `reason`, optional `verdict` and `error` |
32586
+ | `CLI_DISTRIBUTION_UNPUBLISHED_RESPONSE` | constant | frozen canonical HTTP response contract (`status: 503`, `header: 'x-stitchkit-cli-distribution-state'`, `headerValue: 'unpublished'`, `body: 'No verified CLI build is published'`) emitted only when a channel has no published manifest yet (`reason: 'missing'`) |
32587
+ | `CliDistributionUnpublishedResponse` | _type_ | readonly wire-contract type of `CLI_DISTRIBUTION_UNPUBLISHED_RESPONSE` |
32588
+ | `isCliDistributionUnpublishedResponse` | function | synchronous, body-free predicate matching the exact `503` + `x-stitchkit-cli-distribution-state: unpublished` contract without consuming `response.body`, returning `false` for all fault and generic `503` responses |
32137
32589
 
32138
32590
  ---
32139
32591
 
@@ -32375,7 +32827,7 @@ Portable Fetch handler and `postMessage` bridge host without Node built-ins; usa
32375
32827
  |--------|------|---------|
32376
32828
  | `createHandler` | function | build a Fetch `(req) => Promise<Response>` contract router without Node built-ins |
32377
32829
  | `implement` / `createImplement` | function | bind typed contract handlers (`ImplementOptions`, `MissingHandlerPolicy`) |
32378
- | `createErrorHook` | function | build a composable error hook (`ErrorHookBase`, `ErrorHookConfig`, `ErrorHookMapping`, `ResolvedError`) |
32830
+ | `createErrorHook` | function | build a composable error hook (`ErrorHookBase`, `ErrorHookConfig`, `ErrorCodeMapping`, `ResolvedError`) |
32379
32831
  | `serveBridge` | function | serve a `FetchHandler` over a string-only `postMessage` bridge port with origin trust, optional constant-time secret, `maxFrameBytes` before `JSON.parse` and `maxInFlight` |
32380
32832
  | `BridgeHostConfig` / `BridgeHostHandle` / `BridgeHostPort` / `BridgeHostStats` / `BridgeInboundMessage` | _types_ | configuration, handle, port, diagnostic counters and inbound container message for `serveBridge` |
32381
32833
  | `AppError` / `badRequest` / `unauthorized` / `forbidden` / `notFound` / `conflict` / `rateLimited` / `isStitchErrorCode` / `STITCH_ERROR_STATUS` / `StitchErrorCode` | class / function / const / _type_ | shared error vocabulary re-exported for portable handlers |