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/cli.3.txt CHANGED
@@ -12,6 +12,37 @@ Parts of this slice:
12
12
  # Guide: CLI (docs/guide/cli.md) (continued)
13
13
  ==============================================================================
14
14
 
15
+ ## Auth parity
16
+
17
+ Every managed CLI (any `createCli` / `createCliInvoker` with `services` or
18
+ `runtimeTools`) requires an explicit `access` policy — guard scoped commands
19
+ with the same `createAuthHook` your HTTP server uses via
20
+ `access: { gate: { beforeHandle: authHook } }`, and inject the identity through
21
+ `context` so `resolveFromContext` can read it:
22
+
23
+ ```ts
24
+ const authHook = createAuthHook({ /* resolve, resolveFromContext, rules */ })
25
+
26
+ await createCli({
27
+ name: 'myapp',
28
+ version: '1.0.0',
29
+ resolveAuth: () => resolveIdentityFromToken(process.env.MYAPP_TOKEN),
30
+ context: (identity) => ({ user: identity }), // resolveFromContext reads this
31
+ access: { gate: { beforeHandle: authHook } }, // same policy; HTTP wires it as authorize
32
+ services,
33
+ })
34
+ ```
35
+
36
+ Omitting `access` (or passing an empty object or legacy `lifecycle`) is both a
37
+ type error and a startup `TypeError` before the first command executes
38
+ ([ADR 0311](../decisions/0311-planned-breaking-release-access-expose-and-clean-boundaries.md),
39
+ amending [ADR 0014](../decisions/0014-tool-http-parity.md)). When a CLI talks
40
+ only to a remote server that enforces its own auth, or serves a deliberately
41
+ public or local-operator surface, declare that explicitly with
42
+ `access: { open: 'remote' | 'public' | 'local-operator', afterHandle? }`.
43
+ A native-only CLI (only `commands`, no `services` or `runtimeTools`) takes no
44
+ `access`.
45
+
15
46
  ## Typed context
16
47
 
17
48
  For a peer-free CLI, import `createCli` directly from `stitchkit/cli` and
@@ -97,6 +128,8 @@ SDK nor the `ai` peer.
97
128
  | `CliArgumentError` | class | the refusal `parseCliArgs` and the view flags raise; a CLI reports it and exits `2` |
98
129
  | `renderCliView` | function | compute an aggregate over a result (`--count-by`, `--sum`, `--top`, `--table`) — [guide](../guide/cli.md#aggregate-views) |
99
130
  | `createCliProfileStore` | function | named `0600` credential profiles resolved by name, with the never-substitute rule built in — [guide](../guide/cli.md#named-profiles) |
131
+ | `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) |
132
+ | `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 |
100
133
  | `CliProfileError` | class | an `AppError` refusing a named profile that is missing, unreadable or shared between users |
101
134
  | `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) |
102
135
  | `checkCliUpdate` | function | bounded, interval-limited, never-throwing check for a newer published build |
@@ -105,7 +138,7 @@ SDK nor the `ai` peer.
105
138
  | `rollbackCliUpdate` / `CliRollbackConfig` / `RolledBackCliUpdate` | function / _types_ | put the kept previous build back, digest-checked first and written by the same atomic rename the update uses |
106
139
  | `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 |
107
140
  | `cliSignatureAccepted` / `CliSignatureVerdict` | function / _type_ | `valid` \| `unenforced` \| `missing` \| `unknown-key` \| `invalid`; `unenforced` keeps an unpinned build updating while making the absence of a check visible |
108
- | `CliTrustRoot` / `CliSigningKey` / `CliBuildSignature` / `CliBuildSignatureSchema` | _types_ / schema | the keys a build trusts, by id, and the detached signature a manifest carries |
141
+ | `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 |
109
142
  | `selectCliBuildAsset` | function | the asset for one target, or `undefined` |
110
143
  | `currentCliBuildTarget` | function | `{ platform, arch }` of the running process |
111
144
  | `formatCliBuildStamp` | function | one line saying what the running build is |
package/llms/cli.txt CHANGED
@@ -165,16 +165,25 @@ Login, self-update, diagnostics, integration setup and shell completion belong
165
165
  to the executable, not to HTTP/MCP/Agent. Define them with `defineCliCommand`:
166
166
 
167
167
  ```ts
168
- import { createCli, defineCliCommand } from 'stitchkit/cli'
168
+ import { createCli, defineCliCommand, readSecret, readSecretFile } from 'stitchkit/cli'
169
169
  import { z } from 'zod'
170
170
 
171
171
  const login = defineCliCommand({
172
172
  name: 'login',
173
173
  description: 'Store credentials for later managed commands',
174
- input: z.object({ token: z.string() }),
174
+ input: z.object({
175
+ keyFile: z.string().optional().describe('Read token from a 0600 file instead of prompting'),
176
+ }),
175
177
  output: z.object({ configured: z.boolean() }),
176
178
  handler: async ({ input }) => {
177
- await saveToken(input.token)
179
+ // Never accept tokens as CLI arguments (--token): arguments end up in shell
180
+ // history and process listings (`ps`). `readSecret` disables TTY echo and
181
+ // restores terminal mode in `finally`, or reads piped stdin; `readSecretFile`
182
+ // refuses symlinks, FIFOs, and any file readable by group or others (`chmod 600`).
183
+ const token = input.keyFile
184
+ ? readSecretFile(input.keyFile)
185
+ : await readSecret({ prompt: 'API token: ' })
186
+ await saveToken(token)
178
187
  return { configured: true }
179
188
  },
180
189
  })
@@ -189,6 +198,12 @@ await createCli({
189
198
  })
190
199
  ```
191
200
 
201
+ For local daemons that issue a scoped program key only after interactive operator
202
+ consent over a `0600` Unix control socket, `defineLocalKeyInitCommand` pairs with
203
+ `createLocalConsentKeyIssuance` from `stitchkit/server`: it requests a key over the
204
+ local socket without retries, waits for the operator prompt, and writes the returned
205
+ key directly to the local profile file (`0600`) without printing the secret.
206
+
192
207
  Native commands receive only typed `input`, parsed global `options` and the
193
208
  configured stdout/stderr writers. They reuse help, argv/stdin parsing,
194
209
  validation, dry-run, error envelopes and exit mapping, but deliberately have no
package/llms/contract.txt CHANGED
@@ -78,7 +78,7 @@ export const users = defineContract({ prefix: 'users' }, {
78
78
  | `multipart` | no | typed file fields, cardinality, delivery and upload policy — see [below](#file-uploads) |
79
79
  | `maxJsonBodyBytes` | no | per-route JSON body ceiling; overrides the server default |
80
80
  | `timeout` | no | per-endpoint client timeout in ms, for slow endpoints |
81
- | `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) |
81
+ | `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) |
82
82
  | `meta` | no | opaque app metadata — read in hooks / on tool mounts, never in OpenAPI ([below](#endpoint-metadata-meta)) |
83
83
  | `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) |
84
84
  | `rawBody` | no | retain original JSON text for a signed HTTP webhook. See [Signed JSON webhooks](./server.md#signed-json-webhooks) |
@@ -204,12 +204,51 @@ possible effective exposures rather than claiming an unfiltered default tuple.
204
204
  The same holds for an endpoint whose own type is broad, with or without a factory:
205
205
  a value annotated as `EndpointDef` or `FactoryScopedEndpoint<Scope>` carries
206
206
  `expose?: readonly Transport[]`, which may hold no HTTP, so it has no client method
207
- or URL. A helper that builds endpoints keeps their literal type with a const generic:
207
+ or URL. To split a large contract across multiple files while keeping literal types,
208
+ use `defineEndpoints` (or the factory's scoped `defineEndpoints`) in each fragment
209
+ module and combine them with `composeEndpoints`:
208
210
 
209
211
  ```ts
210
- const endpoint = <const Endpoint extends FactoryScopedEndpoint<AppScope>>(value: Endpoint) => value
212
+ // contracts/documents-query.ts
213
+ import { defineEndpoints } from 'stitchkit/contract' // or appFactory.defineEndpoints
214
+
215
+ export const documentQueryEndpoints = defineEndpoints({
216
+ search: { method: 'GET', path: '/search', desc: 'Search documents', output: SearchResult },
217
+ })
218
+
219
+ // contracts/documents.ts
220
+ import { composeEndpoints } from 'stitchkit/contract'
221
+ import { documentQueryEndpoints } from './documents-query'
222
+
223
+ export const documents = defineContract(
224
+ { prefix: 'documents', scope: 'member' },
225
+ composeEndpoints(
226
+ defineEndpoints({ get: { method: 'GET', path: '/:id', desc: 'Read a document', output: Doc } }),
227
+ documentQueryEndpoints,
228
+ ),
229
+ )
211
230
  ```
212
231
 
232
+ `defineEndpoints` catches misspelled or unknown endpoint fields (and unknown scopes on a
233
+ factory's `defineEndpoints`) right in the fragment file, and `composeEndpoints` refuses
234
+ duplicate operation names both at compile time and at runtime instead of silently
235
+ overwriting an earlier fragment.
236
+
237
+ ### IANA time zones (`IanaTimeZoneSchema` and `canonicalizeIanaTimeZone`)
238
+
239
+ `stitchkit/contract` (and `stitchkit`) exports `DEFAULT_TIME_ZONE` (`'UTC'`),
240
+ `IanaTimeZoneSchema`, `IanaTimeZone`, and `canonicalizeIanaTimeZone` so contracts and
241
+ servers do not mix form validation with runtime `tzdata` existence checks:
242
+
243
+ - Use `IanaTimeZoneSchema` in contract schemas and offline storage: it validates IANA
244
+ syntax (up to 64 characters, 1–3 slash-separated segments, rejecting bare UTC offsets
245
+ such as `'+08:00'`) without calling `Intl`, so clients with older `tzdata` never fail
246
+ reading stored or served records.
247
+ - Call `canonicalizeIanaTimeZone(value)` on the server before storing or scheduling: it
248
+ checks `IanaTimeZoneSchema` first and then resolves canonical casing through `Intl`
249
+ (`'asia/kuala_lumpur'` → `'Asia/Kuala_Lumpur'`), returning `null` for unknown zones
250
+ such as `'Mars/Olympus'` or bare offsets.
251
+
213
252
  For a curated tool surface use `toolExposure: { default: ['HTTP'] }`, then name
214
253
  tool transports only on endpoints that intentionally join them. An empty default
215
254
  is legal. Each `configure` snapshots its array independently; it does not change
@@ -529,6 +568,9 @@ from the root `stitchkit`.
529
568
  | Export | Kind | Summary |
530
569
  |--------|------|---------|
531
570
  | `defineContract` | function | declare a contract — [guide](../guide/contracts.md#definecontract) |
571
+ | `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) |
572
+ | `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 |
573
+ | `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) |
532
574
  | `ConfiguredScopedDefineContract` | _type_ | scoped authoring parameterized by the exact default transport tuple; explicit endpoint exposure replaces it |
533
575
  | `ConfiguredToolExposureEndpoints` | _type_ | endpoint map with materialized exposure; a second generic selects defaults (HTTP when omitted), preserving explicit, optional and conditional overrides |
534
576
  | `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) |
@@ -588,16 +630,16 @@ from the root `stitchkit`.
588
630
  | `MultipartDescriptor` | _type_ | file fields, cardinality, delivery and request/text limits |
589
631
  | `MultipartFilePolicy` | _type_ | required/multiple, per-file bytes/count and declared MIME policy |
590
632
  | `MultipartBufferedFiles` | _type_ | `File` map inferred from a multipart descriptor |
591
- | `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` |
633
+ | `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` |
592
634
  | `EndpointUiMeta` | _type_ | MCP Apps widget metadata on an endpoint |
593
635
  | `EndpointMcpInputRequired` | _type_ | typed MCP multi-round input request (`key`, message and Zod object schema) |
594
636
  | `EndpointMcpPolicy` | _type_ | MCP-only endpoint policy containing `inputRequired` |
595
637
 
596
638
  ### Errors
597
639
 
598
- | `ErrorVocabularyCode` / `ErrorVocabularyMapping` / `VocabularyCodeMap` | _type_ | application-code union, partial/exhaustive framework mapping input and resolved wire map returned by `defineErrors` |
599
640
  | Export | Kind | Summary |
600
641
  |--------|------|---------|
642
+ | `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` |
601
643
  | `AppError` | class | the framework error — `code` / `status` / `details` / `hint` |
602
644
  | `ErrorEnvelope` | _type_ | the JSON shape of an error response, preserving optional declared boolean `error.retryable` without changing HTTP retry policy |
603
645
  | `notFound` | function | throw `404 NOT_FOUND` — [guide](../guide/auth-and-errors.md#throwing-errors) |
package/llms/handler.txt CHANGED
@@ -17,7 +17,7 @@ Portable Fetch handler and `postMessage` bridge host without Node built-ins; usa
17
17
  |--------|------|---------|
18
18
  | `createHandler` | function | build a Fetch `(req) => Promise<Response>` contract router without Node built-ins |
19
19
  | `implement` / `createImplement` | function | bind typed contract handlers (`ImplementOptions`, `MissingHandlerPolicy`) |
20
- | `createErrorHook` | function | build a composable error hook (`ErrorHookBase`, `ErrorHookConfig`, `ErrorHookMapping`, `ResolvedError`) |
20
+ | `createErrorHook` | function | build a composable error hook (`ErrorHookBase`, `ErrorHookConfig`, `ErrorCodeMapping`, `ResolvedError`) |
21
21
  | `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` |
22
22
  | `BridgeHostConfig` / `BridgeHostHandle` / `BridgeHostPort` / `BridgeHostStats` / `BridgeInboundMessage` | _types_ | configuration, handle, port, diagnostic counters and inbound container message for `serveBridge` |
23
23
  | `AppError` / `badRequest` / `unauthorized` / `forbidden` / `notFound` / `conflict` / `rateLimited` / `isStitchErrorCode` / `STITCH_ERROR_STATUS` / `StitchErrorCode` | class / function / const / _type_ | shared error vocabulary re-exported for portable handlers |
package/llms/live.txt CHANGED
@@ -260,6 +260,51 @@ has not moved. That needs the key to still exist on the server — set `holdMs`
260
260
  past your reconnect delay, or the last detach releases the source and the page
261
261
  pays the whole value once.
262
262
 
263
+ ### Relaying watches to multiple local windows (`createWatchFanout`)
264
+
265
+ When one local desktop host holds a single upstream watch socket to the cloud and
266
+ serves several local windows, forwarding raw `WATCH_OPEN` and `WATCH_CLOSE` frames
267
+ breaks twice: a second window opening an already-held key receives `{ accepted: true }`
268
+ with no value frame, and one window closing a key drops it for every other window.
269
+
270
+ `createWatchFanout` (`stitchkit/live`) multiplexes one shared upstream subscription per
271
+ `(service, action, digest)` across any number of downstream clients while preserving
272
+ each client's own `WatchKey.instance`, maintaining a verified host copy (`applyWatchDelta`
273
+ + fingerprint check), translating upstream revision resets onto a monotonic downstream
274
+ counter so windows stay live across a cloud restart, and resyncing upstream if a delta
275
+ base mismatches without corrupting the host copy:
276
+
277
+ ```ts
278
+ import {
279
+ createWatchFanout,
280
+ WATCH_CLOSE,
281
+ WATCH_OPEN,
282
+ WATCH_STATE,
283
+ WATCH_VALUE,
284
+ } from 'stitchkit/live'
285
+
286
+ const fanout = createWatchFanout<string>({
287
+ upstream: {
288
+ open: (input) => cloudSocket.request(WATCH_OPEN, input, { timeoutMs: 10_000 }),
289
+ close: (key) => cloudSocket.emit(WATCH_CLOSE, { key }),
290
+ },
291
+ deliver: {
292
+ value: (client, frame) => hostClients.sendTo(client, WATCH_VALUE, frame),
293
+ state: (client, frame) => hostClients.sendTo(client, WATCH_STATE, frame),
294
+ },
295
+ })
296
+
297
+ // Wire downstream open/close/disconnect and upstream frames/reconnect:
298
+ hostClients.on(WATCH_OPEN, async (caller, input, ack) => ack(await fanout.open(caller.client, input)))
299
+ hostClients.on(WATCH_CLOSE, (caller, payload) => fanout.close(caller.client, payload.key))
300
+ cloudSocket.on(WATCH_VALUE, (frame) => fanout.value(frame))
301
+ cloudSocket.on(WATCH_STATE, (frame) => fanout.state(frame))
302
+ cloudSocket.onConnectionChange((connected) => {
303
+ if (!connected) fanout.forget('upstream disconnected')
304
+ else void fanout.reopen()
305
+ })
306
+ ```
307
+
263
308
  ### Large answers cross as differences
264
309
 
265
310
  A frame carries the value, a **difference** to a revision this subscriber already
@@ -407,6 +452,41 @@ Same entry format as `trustedHosts`, compared against the `Origin`'s authority.
407
452
  Declaring one does not widen anything else: an undeclared origin is still
408
453
  refused, and `trustedHosts` still decides which authority the server answers on.
409
454
 
455
+ ### Cross-site public read routes (`publicReads`)
456
+
457
+ Some HTTP routes are meant to be opened from any site — signed download URLs,
458
+ public avatars, or read-only shared resources whose capability token travels in
459
+ the URL or a header. Rather than stripping `Origin` and `Sec-Fetch-Site` in a
460
+ manual wrapper around `fence.check`, declare a synchronous predicate on the
461
+ fence:
462
+
463
+ ```ts
464
+ createTrustFence({
465
+ trustedHosts: ['app.example'],
466
+ publicReads: (request) => {
467
+ const { pathname } = new URL(request.url);
468
+ return pathname.startsWith('/api/public/');
469
+ },
470
+ });
471
+ ```
472
+
473
+ When `publicReads(request)` returns strictly `true`, `cross-site` and
474
+ `origin-mismatch` are skipped — under strict fail-closed boundaries:
475
+
476
+ - **`Host` is always enforced first:** `missing-host` and `untrusted-host` are
477
+ never bypassed, so DNS rebinding remains refused.
478
+ - **HTTP safe reads only:** evaluated only on the HTTP lane for exact `GET` and
479
+ `HEAD` requests with no `Upgrade` header. `POST`, `PUT`, `PATCH`, `DELETE`,
480
+ `OPTIONS`, raw WebSocket `Upgrade` handshakes, and the entire Socket.IO lane
481
+ (`allowRequest` / `'socket'`) ignore `publicReads` and never call it.
482
+ - **Fail-closed on error:** if the predicate throws or returns anything other
483
+ than `true` (including a `Promise`), the request falls through to the normal
484
+ bare 403 refusal and logs an error via `logger.error` (or `console.error`).
485
+ - **Not CORS:** `publicReads` only admits `GET`/`HEAD` past the trust fence; it
486
+ does not add `Access-Control-Allow-Origin` headers or exempt `OPTIONS`
487
+ preflights. Configure `cors` alongside the fence when cross-site browser code
488
+ reads the response or sends custom headers.
489
+
410
490
  It is worth knowing what the `Origin` check is for, because it is not what most
411
491
  people assume. It is **not** the DNS-rebinding defence — that attack is
412
492
  same-origin by construction, so it sends a matching `Origin` or none at all, and
@@ -483,6 +563,8 @@ realtime contract from `stitchkit`, and the server halves live in `stitchkit/app
483
563
  | `watchContract` | const | the four-event realtime contract a watched read travels on |
484
564
  | `WATCH_OPEN` / `WATCH_CLOSE` / `WATCH_VALUE` / `WATCH_STATE` | const | the event names of that contract |
485
565
  | `WatchKey` / `WatchKeySchema` / `watchKeyString` | type / schema / function | `(service, action, arguments digest)` — the identity both ends compute the same way |
566
+ | `WatchOpenInput` / `WatchAccepted` | _types_ | Zod-inferred payload (`{ key, args, have? }`) and acknowledgement (`{ accepted, reason? }`) for `WATCH_OPEN` |
567
+ | `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) |
486
568
  | `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 |
487
569
  | `WatchHave` / `WatchHaveSchema` | type / schema | what a reconnecting subscriber already holds, offered on `open`: a revision and the fingerprint that proves it |
488
570
  | `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 |
package/llms/node.txt CHANGED
@@ -27,6 +27,11 @@ runtime-agnostic pieces of `stitchkit/server` and the error helpers.
27
27
  | `serveNode` | function | build the router and start a Node HTTP server (via `srvx`) |
28
28
  | `createHandler` | function | the router as a bare `(req) => Response` (same as `/server`) |
29
29
  | `createLocalHostGuard` / `LocalHostGuard` / `LocalHostGuardConfig` / `LocalHostRefusal` | function / _types_ | the local-host guard for `serveNode` (same as `/server`) |
30
+ | `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`) |
31
+ | `extractReportedClient` / `ReportedClient` / `ReportedClientField` / `ReportedClientOptions` | function / _types_ | extract sanitized caller-supplied attribution headers tagged `verified: false` for local control sockets (same as `/server`) |
32
+ | `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`) |
33
+ | `createLocalControlGuard` / `LocalControlGuard` / `LocalControlGuardConfig` | function / _types_ | local control-socket fetch guard with header, body, concurrency, and journal limits (same as `/server`) |
34
+ | `createLocalConsentKeyIssuance` / `LocalConsentAuthorization` / `LocalConsentDecision` / `LocalConsentKeyConfig` / `LocalConsentKeyIssuance` / `LocalConsentKeyRequest` / `LocalConsentKeyRequestSchema` / `LocalConsentQuestion` | function / _types_ / schema | fail-closed native-consent program key issuance route plus `guardWhileConsentPending` (same as `/server`) |
30
35
  | `createSocketIOServer` | function | the typed Node Socket.IO server (`io` + `attach`; no Bun engine declarations) |
31
36
  | `createUnixClientTransport` | function | the same fail-closed Bun/Node Unix client adapter exported by `stitchkit/server` (including optional `expectedOwnerUid`) |
32
37
  | `implement` / `createImplement` / `createScopedImplement` / `createScopedImplementRegistry` / `createMultipartStream` | function | bind a contract to typed handlers, optionally typed per endpoint scope (same as `/server`) |
@@ -26,7 +26,7 @@ audit event. See the [Observability guide](../guide/observability.md).
26
26
  |--------|------|---------|
27
27
  | `createObservability` | function | configure framework-owned request completion and canonical tool event sinks — [guide](../guide/observability.md#createobservability) |
28
28
  | `auditChanges` | function | the sink `filter` most projects write themselves — drops `GET`/`HEAD`/`OPTIONS`, keeps `401`/`403` whatever the verb, keeps an unrecognised verb |
29
- | `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) |
29
+ | `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) |
30
30
  | `createDimensionsProjector` / `DimensionsProjector` / `DimensionsProjectorConfig` / `ProjectedDimensions` | function / _type_ | typed request/result/error attribution projected into the existing request context |
31
31
  | `DimensionCollision` / `SetRequestDimensionsOptions` | _type_ | explicit overwrite, preserve or error policy for dimension keys |
32
32
  | `createBoundedLogger` | function | decorate a `StitchLogger` with request context, shared sanitisation, redaction and total bounds |
@@ -383,6 +383,12 @@ const audit = createSpooledSink({
383
383
  const { replayed, failed } = await audit.recover();
384
384
 
385
385
  createObservability({ request: { write: audit.write, filter: auditChanges } });
386
+
387
+ // After a transient outage in the same process, the next successful `write`
388
+ // triggers a single-flight background redelivery pass automatically; call
389
+ // `await audit.flush()` to explicitly drain undelivered rows alongside live
390
+ // writes (for example on a timer or graceful shutdown).
391
+ await audit.flush();
386
392
  ```
387
393
 
388
394
  The guarantee is **at least once**. A crash between the store accepting a row and
package/llms/postgres.txt CHANGED
@@ -11,7 +11,11 @@ Contains: API reference: `stitchkit/postgres` (docs/api/reference.md)
11
11
 
12
12
  ## `stitchkit/postgres`
13
13
 
14
- Server-only, peer-free PostgreSQL application helpers. Wraps any Prisma SQL driver adapter factory
14
+ Server-only, peer-free PostgreSQL application helpers. `postgresConnectionConfig`
15
+ surgically strips `?options=` from `DATABASE_URL` and merges URL options, config options,
16
+ custom parameters, `searchPath`, and `timeZone` (default `'UTC'`) in startup-packet order
17
+ for `PrismaPg` and `pg.Pool` without rewriting unrelated parameters or importing `pg`.
18
+ `withSerializedPrismaTransactions` wraps any Prisma SQL driver adapter factory
15
19
  (such as `new PrismaPg(...)`) without importing `@prisma/adapter-pg` or `pg`, so statements inside
16
20
  each interactive transaction reach its single PostgreSQL connection one at a time while queries
17
21
  outside transactions and separate transactions stay parallel across the pool. See
@@ -19,19 +23,26 @@ outside transactions and separate transactions stay parallel across the pool. Se
19
23
 
20
24
  ```ts
21
25
  import { PrismaPg } from '@prisma/adapter-pg';
22
- import { withSerializedPrismaTransactions } from 'stitchkit/postgres';
26
+ import {
27
+ postgresConnectionConfig,
28
+ withSerializedPrismaTransactions,
29
+ } from 'stitchkit/postgres';
23
30
 
24
31
  const adapter = withSerializedPrismaTransactions(
25
- new PrismaPg({ connectionString: env.DATABASE_URL }),
32
+ new PrismaPg(postgresConnectionConfig(env.DATABASE_URL)),
26
33
  );
27
34
  const prisma = new PrismaClient({ adapter });
28
35
  ```
29
36
 
30
37
  | Export | Kind | Summary |
31
38
  |--------|------|---------|
39
+ | `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 |
40
+ | `PostgresConnectionConfig` | _type_ | minimal `{ connectionString, options? }` shape accepted and returned by `postgresConnectionConfig`, structurally compatible with `pg.PoolConfig` without importing `pg` |
41
+ | `PostgresConnectionOptions` | _type_ | structured session options for `postgresConnectionConfig` (`timeZone`, `searchPath`, `parameters`) |
32
42
  | `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`) |
33
43
  | `PrismaDriverAdapterFactory` | _type_ | minimal structural Prisma SQL driver adapter factory (`provider`, `adapterName`, `connect`, optional `connectToShadowDb`) accepted by `withSerializedPrismaTransactions` |
34
44
  | `PrismaDriverAdapter` | _type_ | minimal structural connected Prisma SQL driver adapter (`startTransaction`) |
35
45
  | `PrismaDriverTransaction` | _type_ | minimal structural interactive transaction handle (`queryRaw`, `executeRaw`, `commit`, `rollback` and optional savepoints) |
46
+ | `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 |
36
47
 
37
48
  ---