stitchkit 0.104.2 → 0.105.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 (429) hide show
  1. package/CHANGELOG.md +372 -13
  2. package/darwin-native.cjs +4 -2
  3. package/dist/agent-runtime/browser-control-contract.d.ts +32 -2
  4. package/dist/agent-runtime/browser-control-contract.d.ts.map +1 -1
  5. package/dist/agent-runtime/browser-controller.d.ts +21 -3
  6. package/dist/agent-runtime/browser-controller.d.ts.map +1 -1
  7. package/dist/agent-runtime/coding-shell-process.d.ts.map +1 -1
  8. package/dist/agent-runtime/coding-tool-refusals.d.ts +1 -0
  9. package/dist/agent-runtime/coding-tool-refusals.d.ts.map +1 -1
  10. package/dist/agent-runtime/coding-tool-shell.d.ts.map +1 -1
  11. package/dist/agent-runtime/compaction.d.ts.map +1 -1
  12. package/dist/agent-runtime/contained-write.d.ts.map +1 -1
  13. package/dist/agent-runtime/control-schema.d.ts +48 -1
  14. package/dist/agent-runtime/control-schema.d.ts.map +1 -1
  15. package/dist/agent-runtime/deferred-tool-search.d.ts +3 -2
  16. package/dist/agent-runtime/deferred-tool-search.d.ts.map +1 -1
  17. package/dist/agent-runtime/harness-control.d.ts.map +1 -1
  18. package/dist/agent-runtime/harness-realtime.d.ts +34 -4
  19. package/dist/agent-runtime/harness-realtime.d.ts.map +1 -1
  20. package/dist/agent-runtime/runtime-recovery.d.ts.map +1 -1
  21. package/dist/agent-runtime/runtime-state.d.ts.map +1 -1
  22. package/dist/agent-runtime/sandbox-contract.d.ts.map +1 -1
  23. package/dist/agent-runtime/sandbox-process-owner.d.ts +9 -1
  24. package/dist/agent-runtime/sandbox-process-owner.d.ts.map +1 -1
  25. package/dist/agent-runtime/sandbox.d.ts +32 -1
  26. package/dist/agent-runtime/sandbox.d.ts.map +1 -1
  27. package/dist/agent-runtime/schedule-records.d.ts.map +1 -1
  28. package/dist/agent-runtime/schedules.d.ts.map +1 -1
  29. package/dist/agent-runtime/store-events.d.ts +9 -4
  30. package/dist/agent-runtime/store-events.d.ts.map +1 -1
  31. package/dist/agent-runtime/testing.d.ts.map +1 -1
  32. package/dist/application/diagnostic-journal-contract.d.ts +50 -0
  33. package/dist/application/diagnostic-journal-contract.d.ts.map +1 -1
  34. package/dist/application/diagnostic-journal-generations.d.ts +24 -0
  35. package/dist/application/diagnostic-journal-generations.d.ts.map +1 -0
  36. package/dist/application/diagnostic-journal-manager.d.ts.map +1 -1
  37. package/dist/application/diagnostic-journal-open.d.ts +10 -0
  38. package/dist/application/diagnostic-journal-open.d.ts.map +1 -0
  39. package/dist/application/diagnostic-journal-quarantine.d.ts +28 -0
  40. package/dist/application/diagnostic-journal-quarantine.d.ts.map +1 -0
  41. package/dist/application/diagnostic-journal-read-contract.d.ts +73 -3
  42. package/dist/application/diagnostic-journal-read-contract.d.ts.map +1 -1
  43. package/dist/application/diagnostic-journal-reader.d.ts +17 -2
  44. package/dist/application/diagnostic-journal-reader.d.ts.map +1 -1
  45. package/dist/application/diagnostic-journal-recovery.d.ts +18 -2
  46. package/dist/application/diagnostic-journal-recovery.d.ts.map +1 -1
  47. package/dist/application/diagnostic-journal-storage.d.ts +6 -2
  48. package/dist/application/diagnostic-journal-storage.d.ts.map +1 -1
  49. package/dist/application/diagnostic-journal-tail.d.ts +12 -0
  50. package/dist/application/diagnostic-journal-tail.d.ts.map +1 -0
  51. package/dist/application/diagnostic-journal.d.ts +3 -0
  52. package/dist/application/diagnostic-journal.d.ts.map +1 -1
  53. package/dist/application/directory-inbox-accept.d.ts +3 -3
  54. package/dist/application/directory-inbox-accept.d.ts.map +1 -1
  55. package/dist/application/directory-inbox-contract.d.ts +38 -10
  56. package/dist/application/directory-inbox-contract.d.ts.map +1 -1
  57. package/dist/application/directory-inbox-delivery.d.ts +3 -3
  58. package/dist/application/directory-inbox-delivery.d.ts.map +1 -1
  59. package/dist/application/directory-inbox-files.d.ts +17 -2
  60. package/dist/application/directory-inbox-files.d.ts.map +1 -1
  61. package/dist/application/directory-inbox-state.d.ts +1 -1
  62. package/dist/application/directory-inbox-state.d.ts.map +1 -1
  63. package/dist/application/directory-inbox.d.ts +1 -1
  64. package/dist/application/directory-inbox.d.ts.map +1 -1
  65. package/dist/application/file-state-store.d.ts +21 -1
  66. package/dist/application/file-state-store.d.ts.map +1 -1
  67. package/dist/application/grammy.d.ts.map +1 -1
  68. package/dist/application/kernel-contract.d.ts.map +1 -1
  69. package/dist/application/revision-signal.d.ts.map +1 -1
  70. package/dist/application/state-store.d.ts +3 -0
  71. package/dist/application/state-store.d.ts.map +1 -1
  72. package/dist/browser/api-error.d.ts +38 -0
  73. package/dist/browser/api-error.d.ts.map +1 -0
  74. package/dist/browser/chunked-upload.d.ts.map +1 -1
  75. package/dist/browser/client-executors.d.ts.map +1 -1
  76. package/dist/browser/client-url.d.ts.map +1 -1
  77. package/dist/browser/contract-stream.d.ts.map +1 -1
  78. package/dist/browser/http.d.ts +0 -25
  79. package/dist/browser/http.d.ts.map +1 -1
  80. package/dist/browser/resumable.d.ts.map +1 -1
  81. package/dist/contract/define-validation.d.ts +0 -1
  82. package/dist/contract/define-validation.d.ts.map +1 -1
  83. package/dist/contract/define.d.ts.map +1 -1
  84. package/dist/contract/errors-factory.d.ts.map +1 -1
  85. package/dist/contract/errors.d.ts +15 -18
  86. package/dist/contract/errors.d.ts.map +1 -1
  87. package/dist/contract/normalize.d.ts.map +1 -1
  88. package/dist/durability/effect.d.ts.map +1 -1
  89. package/dist/durability/scheduler.d.ts.map +1 -1
  90. package/dist/entrypoints/agent-runtime/browser.js +29 -18
  91. package/dist/entrypoints/agent-runtime/coding-tools.js +8 -7
  92. package/dist/entrypoints/agent-runtime/harness.js +15 -14
  93. package/dist/entrypoints/agent-runtime/realtime.d.ts +1 -1
  94. package/dist/entrypoints/agent-runtime/realtime.d.ts.map +1 -1
  95. package/dist/entrypoints/agent-runtime/realtime.js +119 -54
  96. package/dist/entrypoints/agent-runtime/sandbox.js +23 -17
  97. package/dist/entrypoints/agent-runtime/sqlite/bun.js +4 -3
  98. package/dist/entrypoints/agent-runtime/sqlite/node.js +4 -3
  99. package/dist/entrypoints/agent-runtime/testing.js +8 -6
  100. package/dist/entrypoints/agent-runtime.js +37 -38
  101. package/dist/entrypoints/application/diagnostic-journal.js +305 -111
  102. package/dist/entrypoints/application/directory-inbox.js +174 -77
  103. package/dist/entrypoints/application/grammy.js +5 -2
  104. package/dist/entrypoints/application/opentelemetry.js +2 -2
  105. package/dist/entrypoints/application.d.ts +2 -2
  106. package/dist/entrypoints/application.d.ts.map +1 -1
  107. package/dist/entrypoints/application.js +17 -8
  108. package/dist/entrypoints/cli/publish.d.ts +16 -0
  109. package/dist/entrypoints/cli/publish.d.ts.map +1 -0
  110. package/dist/entrypoints/cli/publish.js +527 -0
  111. package/dist/entrypoints/cli.d.ts +1 -2
  112. package/dist/entrypoints/cli.d.ts.map +1 -1
  113. package/dist/entrypoints/cli.js +59 -966
  114. package/dist/entrypoints/contract.js +3 -3
  115. package/dist/entrypoints/files/packaging.js +153 -64
  116. package/dist/entrypoints/files.d.ts +1 -0
  117. package/dist/entrypoints/files.d.ts.map +1 -1
  118. package/dist/entrypoints/files.js +17 -10
  119. package/dist/entrypoints/index.d.ts +2 -1
  120. package/dist/entrypoints/index.d.ts.map +1 -1
  121. package/dist/entrypoints/index.js +31 -60
  122. package/dist/entrypoints/node.js +8 -8
  123. package/dist/entrypoints/observability.js +3 -3
  124. package/dist/entrypoints/primitives.js +67 -83
  125. package/dist/entrypoints/process.d.ts +1 -1
  126. package/dist/entrypoints/process.d.ts.map +1 -1
  127. package/dist/entrypoints/process.js +2 -2
  128. package/dist/entrypoints/react.js +4 -2
  129. package/dist/entrypoints/remote.js +37 -13
  130. package/dist/entrypoints/server.js +18 -16
  131. package/dist/entrypoints/telegram/screens.js +5 -3
  132. package/dist/entrypoints/telegram.js +31 -46
  133. package/dist/entrypoints/testing.d.ts +1 -1
  134. package/dist/entrypoints/testing.d.ts.map +1 -1
  135. package/dist/entrypoints/testing.js +444 -448
  136. package/dist/entrypoints/tools/connections.js +268 -105
  137. package/dist/entrypoints/tools/contract.js +2 -2
  138. package/dist/entrypoints/tools/invoker.js +8 -7
  139. package/dist/entrypoints/tools/mcp.d.ts +2 -2
  140. package/dist/entrypoints/tools/mcp.d.ts.map +1 -1
  141. package/dist/entrypoints/tools/mcp.js +10 -9
  142. package/dist/entrypoints/tools.d.ts +0 -1
  143. package/dist/entrypoints/tools.d.ts.map +1 -1
  144. package/dist/entrypoints/tools.js +118 -53
  145. package/dist/entrypoints/tracking.js +2 -3
  146. package/dist/files/boundary.d.ts +2 -2
  147. package/dist/files/boundary.d.ts.map +1 -1
  148. package/dist/files/chunk-spool.d.ts.map +1 -1
  149. package/dist/files/file-io.d.ts +2 -2
  150. package/dist/files/file-io.d.ts.map +1 -1
  151. package/dist/files/native-packaging-layout.d.ts +50 -4
  152. package/dist/files/native-packaging-layout.d.ts.map +1 -1
  153. package/dist/files/native-packaging.d.ts +78 -17
  154. package/dist/files/native-packaging.d.ts.map +1 -1
  155. package/dist/{index-r5hsgkz5.js → index-0gs4ymfj.js} +6 -3
  156. package/dist/{index-zax7resm.js → index-0gxvns6s.js} +1 -13
  157. package/dist/index-0s4xebbg.js +8 -0
  158. package/dist/{index-r4r70zmh.js → index-12zsej7b.js} +5 -2
  159. package/dist/{index-kemm0ej5.js → index-1pwwan01.js} +65 -22
  160. package/dist/{index-vgkbcnkc.js → index-299sm5tr.js} +1 -1
  161. package/dist/{index-2vnh05w4.js → index-2k91mewf.js} +31 -74
  162. package/dist/{index-269zqj8m.js → index-2rc6jd9n.js} +28 -12
  163. package/dist/{index-wh0ecvyk.js → index-37asdw3a.js} +1 -1
  164. package/dist/index-3h0ztg0z.js +285 -0
  165. package/dist/{index-g95fk660.js → index-4vsby8n8.js} +8 -15
  166. package/dist/index-556g5hsh.js +17 -0
  167. package/dist/{index-adhgd4pe.js → index-5p55xreg.js} +2 -2
  168. package/dist/index-5w6t91ze.js +47 -0
  169. package/dist/{index-9pw0a51a.js → index-6yxhe58g.js} +40 -7
  170. package/dist/{index-6d9xaxw1.js → index-8ks9b85e.js} +33 -5
  171. package/dist/{index-bhb950qs.js → index-916yh4e2.js} +25 -12
  172. package/dist/index-9tqbxv5p.js +44 -0
  173. package/dist/{index-5csmzesf.js → index-azx12jgv.js} +4 -3
  174. package/dist/{index-mbnnw3f2.js → index-b0kddvzw.js} +15 -5
  175. package/dist/{index-n5yqxd3d.js → index-b0w7rbpt.js} +23 -2
  176. package/dist/index-b56nnscm.js +132 -0
  177. package/dist/{index-0ndk4555.js → index-c0hffcmj.js} +2 -2
  178. package/dist/{index-pptyv13k.js → index-c17xcx4k.js} +42 -6
  179. package/dist/{index-g2j7pnak.js → index-cmzvhhtd.js} +5 -2
  180. package/dist/index-cq59agna.js +51 -0
  181. package/dist/{index-ssmd41kh.js → index-d2h99n7d.js} +1 -1
  182. package/dist/{index-z94wht4y.js → index-dky0dcmf.js} +34 -5
  183. package/dist/{index-za6j7nwy.js → index-dsnjzb62.js} +104 -51
  184. package/dist/index-eemvahkc.js +21 -0
  185. package/dist/index-ef8gdaq0.js +105 -0
  186. package/dist/{index-fa4wg312.js → index-f199nfq5.js} +10 -6
  187. package/dist/{index-ck71tbcf.js → index-fsw1ybf3.js} +11 -15
  188. package/dist/{index-f330qqyg.js → index-g2vfg7ak.js} +217 -63
  189. package/dist/{index-fk18k56k.js → index-gr5g3xfw.js} +11 -18
  190. package/dist/{index-jn9g8xdt.js → index-hjvje0pf.js} +6 -4
  191. package/dist/{index-x928baz2.js → index-j9gxbztg.js} +18 -14
  192. package/dist/index-kfjkb396.js +37 -0
  193. package/dist/{index-6drst9sg.js → index-ksfagmyz.js} +45 -345
  194. package/dist/index-m616f0yz.js +120 -0
  195. package/dist/{index-fm1c1a08.js → index-m6w6jtda.js} +40 -21
  196. package/dist/{index-ptn0g0gj.js → index-ma963wz7.js} +21 -20
  197. package/dist/{index-bakgedh8.js → index-msfpyy2f.js} +2 -4
  198. package/dist/{index-ywppsaby.js → index-n1nszyk0.js} +23 -34
  199. package/dist/{index-v14qqmys.js → index-n4689krb.js} +1 -1
  200. package/dist/{index-a0zzh8ak.js → index-pz3y6b6g.js} +3 -3
  201. package/dist/{index-43p08g7t.js → index-pzb63z66.js} +12 -8
  202. package/dist/{index-h97tqqp1.js → index-qaet40b2.js} +5 -3
  203. package/dist/{index-t1sr4aks.js → index-qaqbdm7s.js} +52 -6
  204. package/dist/{index-77nxk6ay.js → index-r393tnfp.js} +16 -10
  205. package/dist/{index-kb8styz3.js → index-rpzewktb.js} +15 -5
  206. package/dist/{index-27a2pj09.js → index-sj28htvf.js} +1 -1
  207. package/dist/index-szybbezc.js +455 -0
  208. package/dist/{index-2hyavjjj.js → index-wbhdzxar.js} +3 -3
  209. package/dist/{index-4e0ah203.js → index-wdy68sh6.js} +47 -24
  210. package/dist/{index-hbd32c6a.js → index-wqmvtnkp.js} +38 -89
  211. package/dist/{index-hp9d77wk.js → index-x7w1z6pf.js} +15 -4
  212. package/dist/{index-20yvtn9a.js → index-yt7gyg5x.js} +1 -1
  213. package/dist/{index-cvda079a.js → index-yvfk3y36.js} +12 -2
  214. package/dist/{index-5z6jn897.js → index-z23rfxhj.js} +1 -1
  215. package/dist/internal/abort-race.d.ts +8 -2
  216. package/dist/internal/abort-race.d.ts.map +1 -1
  217. package/dist/internal/atomic-file.d.ts +55 -9
  218. package/dist/internal/atomic-file.d.ts.map +1 -1
  219. package/dist/internal/atomic-publication.d.ts +39 -4
  220. package/dist/internal/atomic-publication.d.ts.map +1 -1
  221. package/dist/internal/atomic-staging.d.ts +46 -0
  222. package/dist/internal/atomic-staging.d.ts.map +1 -0
  223. package/dist/internal/bounded-file-read.d.ts +19 -11
  224. package/dist/internal/bounded-file-read.d.ts.map +1 -1
  225. package/dist/internal/bounded-lines.d.ts.map +1 -1
  226. package/dist/internal/close-after.d.ts +11 -0
  227. package/dist/internal/close-after.d.ts.map +1 -0
  228. package/dist/internal/deadline.d.ts +10 -0
  229. package/dist/internal/deadline.d.ts.map +1 -1
  230. package/dist/internal/exclusive-lock-read.d.ts +10 -12
  231. package/dist/internal/exclusive-lock-read.d.ts.map +1 -1
  232. package/dist/internal/exclusive-lock.d.ts +2 -2
  233. package/dist/internal/exclusive-lock.d.ts.map +1 -1
  234. package/dist/internal/file-observation.d.ts +14 -0
  235. package/dist/internal/file-observation.d.ts.map +1 -0
  236. package/dist/internal/json-data.d.ts +22 -5
  237. package/dist/internal/json-data.d.ts.map +1 -1
  238. package/dist/internal/positive-integer.d.ts +9 -0
  239. package/dist/internal/positive-integer.d.ts.map +1 -0
  240. package/dist/internal/process-instance.d.ts +35 -5
  241. package/dist/internal/process-instance.d.ts.map +1 -1
  242. package/dist/internal/secure-fetch.d.ts.map +1 -1
  243. package/dist/internal/timers.d.ts +11 -0
  244. package/dist/internal/timers.d.ts.map +1 -0
  245. package/dist/internal/with-exclusive-lock.d.ts +5 -4
  246. package/dist/internal/with-exclusive-lock.d.ts.map +1 -1
  247. package/dist/observability/bounded-sink.d.ts.map +1 -1
  248. package/dist/primitives/canonical-json.d.ts +23 -2
  249. package/dist/primitives/canonical-json.d.ts.map +1 -1
  250. package/dist/primitives/delivery.d.ts.map +1 -1
  251. package/dist/primitives/index.d.ts +1 -1
  252. package/dist/primitives/index.d.ts.map +1 -1
  253. package/dist/primitives/money.d.ts.map +1 -1
  254. package/dist/process/cleanup.d.ts +6 -1
  255. package/dist/process/cleanup.d.ts.map +1 -1
  256. package/dist/process/command-lifetime.d.ts +4 -0
  257. package/dist/process/command-lifetime.d.ts.map +1 -1
  258. package/dist/process/command-owner.d.ts.map +1 -1
  259. package/dist/process/command.d.ts +4 -0
  260. package/dist/process/command.d.ts.map +1 -1
  261. package/dist/process/contract.d.ts +67 -2
  262. package/dist/process/contract.d.ts.map +1 -1
  263. package/dist/process/group.d.ts +40 -3
  264. package/dist/process/group.d.ts.map +1 -1
  265. package/dist/process/launch.d.ts +12 -1
  266. package/dist/process/launch.d.ts.map +1 -1
  267. package/dist/process/terminate.d.ts +39 -0
  268. package/dist/process/terminate.d.ts.map +1 -0
  269. package/dist/react/query-client.d.ts.map +1 -1
  270. package/dist/realtime/rejection.d.ts.map +1 -1
  271. package/dist/server/contract-stream.d.ts.map +1 -1
  272. package/dist/server/handler-state.d.ts.map +1 -1
  273. package/dist/server/implement.d.ts.map +1 -1
  274. package/dist/server/request-body.d.ts +0 -1
  275. package/dist/server/request-body.d.ts.map +1 -1
  276. package/dist/server/unix-client.d.ts.map +1 -1
  277. package/dist/telegram/broadcast-delivery.d.ts.map +1 -1
  278. package/dist/telegram/broadcast-failure.d.ts +10 -2
  279. package/dist/telegram/broadcast-failure.d.ts.map +1 -1
  280. package/dist/telegram/operator-channel.d.ts.map +1 -1
  281. package/dist/telegram/screens/outcome.d.ts.map +1 -1
  282. package/dist/testing/surface-conformance.d.ts +1 -1
  283. package/dist/testing/surface-conformance.d.ts.map +1 -1
  284. package/dist/testing/surface-manifest.d.ts +0 -6
  285. package/dist/testing/surface-manifest.d.ts.map +1 -1
  286. package/dist/tools/agent.d.ts +1 -1
  287. package/dist/tools/agent.d.ts.map +1 -1
  288. package/dist/tools/cli/args.d.ts +1 -1
  289. package/dist/tools/cli/args.d.ts.map +1 -1
  290. package/dist/tools/cli/help.d.ts.map +1 -1
  291. package/dist/tools/cli/invoke.d.ts +2 -2
  292. package/dist/tools/cli/invoke.d.ts.map +1 -1
  293. package/dist/tools/cli/profile.d.ts.map +1 -1
  294. package/dist/tools/cli/publication-assets.d.ts.map +1 -1
  295. package/dist/tools/cli/publication-contract.d.ts +8 -0
  296. package/dist/tools/cli/publication-contract.d.ts.map +1 -1
  297. package/dist/tools/cli/publication-control.d.ts.map +1 -1
  298. package/dist/tools/cli/publication-storage.d.ts +23 -2
  299. package/dist/tools/cli/publication-storage.d.ts.map +1 -1
  300. package/dist/tools/cli/publication.d.ts +8 -1
  301. package/dist/tools/cli/publication.d.ts.map +1 -1
  302. package/dist/tools/connections/errors.d.ts +18 -6
  303. package/dist/tools/connections/errors.d.ts.map +1 -1
  304. package/dist/tools/connections/limits.d.ts +8 -2
  305. package/dist/tools/connections/limits.d.ts.map +1 -1
  306. package/dist/tools/connections/mcp-client.d.ts.map +1 -1
  307. package/dist/tools/connections/mcp-envelope.d.ts.map +1 -1
  308. package/dist/tools/connections/openapi.d.ts.map +1 -1
  309. package/dist/tools/connections/schema-budget.d.ts +1 -1
  310. package/dist/tools/connections/schema-budget.d.ts.map +1 -1
  311. package/dist/tools/connections/sse-session.d.ts.map +1 -1
  312. package/dist/tools/execute-args.d.ts.map +1 -1
  313. package/dist/tools/execute-result.d.ts.map +1 -1
  314. package/dist/tools/internal/surface-projector.d.ts +17 -3
  315. package/dist/tools/internal/surface-projector.d.ts.map +1 -1
  316. package/dist/tools/internal/tool-error-projection.d.ts +16 -0
  317. package/dist/tools/internal/tool-error-projection.d.ts.map +1 -0
  318. package/dist/tools/internal/tool-view.d.ts.map +1 -1
  319. package/dist/tools/invoker.d.ts.map +1 -1
  320. package/dist/tools/list-names.d.ts +3 -2
  321. package/dist/tools/list-names.d.ts.map +1 -1
  322. package/dist/tools/manifest.d.ts +3 -2
  323. package/dist/tools/manifest.d.ts.map +1 -1
  324. package/dist/tools/mcp/handler.d.ts +7 -0
  325. package/dist/tools/mcp/handler.d.ts.map +1 -1
  326. package/dist/tools/mcp/mount.d.ts +18 -2
  327. package/dist/tools/mcp/mount.d.ts.map +1 -1
  328. package/dist/tools/mcp/prepare.d.ts +3 -3
  329. package/dist/tools/mcp/prepare.d.ts.map +1 -1
  330. package/dist/tools/mcp/register.d.ts.map +1 -1
  331. package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
  332. package/dist/tools/mcp/stdio-signals.d.ts +14 -0
  333. package/dist/tools/mcp/stdio-signals.d.ts.map +1 -1
  334. package/dist/tools/mcp/stdio.d.ts +7 -0
  335. package/dist/tools/mcp/stdio.d.ts.map +1 -1
  336. package/dist/tools/operations/async-operation-runtime-tools.d.ts.map +1 -1
  337. package/dist/tools/operations/async-operation-runtime-types.d.ts +3 -3
  338. package/dist/tools/operations/async-operation-runtime-types.d.ts.map +1 -1
  339. package/dist/tools/operations/define-wait-tool.d.ts +1 -1
  340. package/dist/tools/operations/define-wait-tool.d.ts.map +1 -1
  341. package/dist/tools/operations/wait-core.d.ts +0 -6
  342. package/dist/tools/operations/wait-core.d.ts.map +1 -1
  343. package/dist/tools/registry.d.ts +1 -1
  344. package/dist/tools/registry.d.ts.map +1 -1
  345. package/dist/tools/remote.d.ts +1 -1
  346. package/dist/tools/remote.d.ts.map +1 -1
  347. package/dist/tools/{runtime-tool-execution.d.ts → runtime-tool-declaration.d.ts} +32 -9
  348. package/dist/tools/runtime-tool-declaration.d.ts.map +1 -0
  349. package/dist/tools/runtime-tool-mcp.d.ts +6 -15
  350. package/dist/tools/runtime-tool-mcp.d.ts.map +1 -1
  351. package/dist/tools/runtime-tool.d.ts +14 -12
  352. package/dist/tools/runtime-tool.d.ts.map +1 -1
  353. package/dist/tools/schema/coerce.d.ts +4 -0
  354. package/dist/tools/schema/coerce.d.ts.map +1 -1
  355. package/dist/tools/schema/flatten-join.d.ts.map +1 -1
  356. package/dist/tools/surface.d.ts +7 -11
  357. package/dist/tools/surface.d.ts.map +1 -1
  358. package/dist/tools/transfer/define-download-tool.d.ts +1 -1
  359. package/dist/tools/transfer/define-download-tool.d.ts.map +1 -1
  360. package/dist/tools/transfer/define-upload-tool.d.ts +1 -1
  361. package/dist/tools/transfer/define-upload-tool.d.ts.map +1 -1
  362. package/dist/tools/transfer/define-view-file-tool.d.ts +1 -1
  363. package/dist/tools/transfer/define-view-file-tool.d.ts.map +1 -1
  364. package/dist/tools/transfer/managed-file-error.d.ts.map +1 -1
  365. package/dist/tools/transfer/view-file-contract.d.ts.map +1 -1
  366. package/dist/tools/transfer/view-file.d.ts +1 -1
  367. package/dist/tools/transfer/view-file.d.ts.map +1 -1
  368. package/dist/tools/transports.d.ts +3 -2
  369. package/dist/tools/transports.d.ts.map +1 -1
  370. package/llms/agent-runtime-browser.txt +10 -4
  371. package/llms/agent-runtime-harness.txt +32 -31
  372. package/llms/agent-runtime-react.txt +1 -1
  373. package/llms/agent-runtime-realtime.txt +14 -5
  374. package/llms/agent-runtime-sandbox.txt +3 -11
  375. package/llms/agent-runtime.3.txt +2 -2
  376. package/llms/agent-runtime.txt +0 -9
  377. package/llms/application.2.txt +3 -12
  378. package/llms/application.3.txt +7 -4
  379. package/llms/application.txt +44 -15
  380. package/llms/cli-publish.txt +29 -0
  381. package/llms/cli.2.txt +9 -11
  382. package/llms/cli.txt +26 -14
  383. package/llms/declaration.txt +0 -9
  384. package/llms/files-packaging.txt +16 -8
  385. package/llms/files.txt +4 -2
  386. package/llms/geo.txt +0 -9
  387. package/llms/live.txt +4 -13
  388. package/llms/observability.txt +31 -5
  389. package/llms/primitives.txt +38 -20
  390. package/llms/process.txt +287 -157
  391. package/llms/react-keyboard.txt +0 -9
  392. package/llms/react.txt +0 -18
  393. package/llms/server.4.txt +1 -1
  394. package/llms/server.5.txt +1 -1
  395. package/llms/server.txt +1 -1
  396. package/llms/stitchkit.txt +6 -7
  397. package/llms/telegram-screens.txt +2 -2
  398. package/llms/testing.txt +0 -1
  399. package/llms/tools-mcp.txt +2 -3
  400. package/llms/tools.2.txt +12 -0
  401. package/llms/tools.3.txt +5 -6
  402. package/llms/tools.txt +6 -4
  403. package/llms/upgrading-0.37.0-0.50.0.txt +947 -0
  404. package/llms/{upgrading-0.44.0-0.61.0.txt → upgrading-0.53.0-0.67.0.txt} +576 -506
  405. package/llms/{upgrading-0.62.0-0.80.0.txt → upgrading-0.68.0-0.94.0.txt} +562 -576
  406. package/llms/{upgrading-0.81.0-0.104.0.txt → upgrading-0.95.0-0.105.0.txt} +452 -567
  407. package/llms/upgrading.txt +4 -4
  408. package/llms-full.txt +1029 -409
  409. package/llms.txt +24 -24
  410. package/native-assets.json +11 -3
  411. package/package.json +6 -6
  412. package/dist/agent-runtime/harness-tools.d.ts +0 -11
  413. package/dist/agent-runtime/harness-tools.d.ts.map +0 -1
  414. package/dist/entrypoints/agent-runtime/harness-tools.d.ts +0 -2
  415. package/dist/entrypoints/agent-runtime/harness-tools.d.ts.map +0 -1
  416. package/dist/entrypoints/agent-runtime/harness-tools.js +0 -32
  417. package/dist/index-1a6jtnd9.js +0 -88
  418. package/dist/index-8a9ksm91.js +0 -95
  419. package/dist/index-a3wma1hk.js +0 -48
  420. package/dist/index-jd470k6q.js +0 -109
  421. package/dist/index-n1dqr7gf.js +0 -20
  422. package/dist/index-nggfa2yn.js +0 -34
  423. package/dist/index-s4evrmp5.js +0 -98
  424. package/dist/index-ze1eph1k.js +0 -20
  425. package/dist/tools/connections/error-projection.d.ts +0 -4
  426. package/dist/tools/connections/error-projection.d.ts.map +0 -1
  427. package/dist/tools/runtime-tool-execution.d.ts.map +0 -1
  428. package/llms/agent-runtime-harness-tools.txt +0 -25
  429. package/llms/upgrading-0.37.0-0.44.0.txt +0 -444
@@ -15,11 +15,20 @@ Also read:
15
15
 
16
16
  ## `stitchkit/agent-runtime/realtime`
17
17
 
18
- Optional evolving Socket.IO server binding. `bindAgentHarnessRealtime` takes `(harness, socket, config)` and returns `close()` for its subscriptions and control connections, without closing
19
- socket or harness. `AgentHarnessRealtimeConfig` requires `authorize({ identity, request,
20
- signal })`: return `{ context }` after verifying the session principal, conversation,
21
- operation, files and metadata, or `null`. Identity is `socket.data` from the application's
22
- verified handshake. Every request and event delivery is authorized. Observe access does
18
+ Optional evolving Socket.IO server binding, experimental: no committed consumer yet.
19
+ `bindAgentHarnessRealtime` takes `(harness, socket, config)` and returns an
20
+ `AgentHarnessRealtimeBinding`: `close()` for its subscriptions and control connections, without closing
21
+ socket or harness, and `revoke(conversationId, matches?)`. `AgentHarnessRealtimeConfig` requires
22
+ `authorize({ identity, request, source, signal })`: return `{ context }` after verifying the session
23
+ principal, conversation, operation, files and metadata, or `null`. Identity is `socket.data` from the
24
+ application's verified handshake. Every request is authorized on arrival. The events of an
25
+ attached conversation are delivered under the grant the latest successful request created, so a
26
+ token stream costs no authorization call per event. `revoke` drops the grant of every matching
27
+ socket; the next event is re-authorized (`source: 'delivery'`, an `operation: 'snapshot'` request),
28
+ and a refusal or failure detaches the conversation and sends an `access-denied` delivery, which
29
+ turns the browser controller into an `error` state. Without a `revoke` call a grant lasts until the socket disconnects or the conversation
30
+ is detached; this fail-open default is deliberate, so call `revoke` whenever access to a conversation may
31
+ have been withdrawn. An authorization that began before a `revoke` never restores the grant. Observe access does
23
32
  not grant mutation; controller leases and approval policy still belong to the harness.
24
33
 
25
34
  `maxPendingEvents` and `maxPendingAttachments` forward to the canonical control server;
@@ -12,17 +12,6 @@ Also read:
12
12
  # Guide: Optional process sandbox (docs/guide/sandbox.md)
13
13
  ==============================================================================
14
14
 
15
- ---
16
- title: Optional process sandbox
17
- description: Linux namespace isolation, durable workspaces and a host credential gateway.
18
- updated: 2026-10-03 14:47 +07:00
19
- participants:
20
- - role: implemented
21
- harness: Codex
22
- model: GPT-6
23
- at: 2026-10-03 14:47 +07:00
24
- ---
25
-
26
15
  # Optional process sandbox
27
16
 
28
17
  `stitchkit/agent-runtime/sandbox` is a server-only, evolving API. Existing coding
@@ -86,6 +75,9 @@ access the same workspace through the host's contained-file implementation;
86
75
  commands run inside the namespace with `/workspace` as their root. The host-only
87
76
  `handle.coding` binding never belongs in model input or persisted state.
88
77
  Unsupported backends omit the binding and the factory refuses explicitly.
78
+ When the adapter's `probe()` or `prepare()` fails, the agent gets `SANDBOX_UNAVAILABLE` with a
79
+ fixed reason; the adapter's own error is the refusal's `cause`, delivered to the mount's
80
+ `hooks.onToolError`, which is where an application logs it.
89
81
 
90
82
  Stop also kills coding commands. Both launch paths share the configured
91
83
  `maxConcurrentCommands` admission limit (default 8); an occupied slot gives
@@ -97,7 +97,7 @@ Server-only optional application runtime. See the
97
97
 
98
98
  | Export | Kind | Summary |
99
99
  |--------|------|---------|
100
- | `AgentConversationArchiveSchema` / `AgentConversationArchive` / `encodeAgentConversationArchive` / `decodeAgentConversationArchive` / `canonicalAgentJson` | schema / _type_ / functions | canonical validated conversation archive with exact ledger events, recovery projection and durable spill payloads |
100
+ | `AgentConversationArchiveSchema` / `AgentConversationArchive` / `encodeAgentConversationArchive` / `decodeAgentConversationArchive` / `canonicalAgentJson` | schema / _type_ / functions | canonical validated conversation archive (`canonicalAgentJson` is `canonicalJson` with the node and byte limits at their maximum, reading `-0` as `0` like `z.json()`) with exact ledger events, recovery projection and durable spill payloads |
101
101
  | `AgentStoreEventEnvelopeSchema` / `AgentStoreEventEnvelope` / `AgentStoreEventKindSchema` / `AgentStoreEventKind` / `AgentStoreEventPageSchema` / `AgentStoreEventPage` | schema / _type_ | append-only event envelope, closed current vocabulary (including `provider/request` and `provider/response`) and bounded page |
102
102
  | `AppendAgentStoreEventSchema` / `AppendAgentStoreEvent` / `ReadAgentStoreEventsSchema` / `ReadAgentStoreEvents` | schema / _type_ | required append and bounded-read store contracts |
103
103
  | `AgentStoreTransitionSchema` / `AgentStoreTransition` / `AgentStoreEventDraft` / `AgentStoreEventDecodeAccepted` / `AgentStoreEventDecodeIgnored` / `AgentStoreEventDecodeResult` / `decodeAgentStoreEvent` | schema / _types_ / function | normalized runtime mutations, append drafts and strict current/ignorable future-event decoding outcomes |
@@ -107,7 +107,7 @@ Server-only optional application runtime. See the
107
107
  | `defineStateSlot` / `AgentStateSlotDefinition` / `AgentStateSlotStore` / `AgentStateSlotValue` / `AnyAgentStateSlot` / `createAgentStateSlotStore` / `renderAgentStateSlots` | functions / _types_ | typed durable state written as ledger events and injected on every provider request |
108
108
  | `agentGoalStateSlot` / `agentTodoStateSlot` / `createAgentStateTools` | constants / function | built-in goal/todo state and bound `goal_*` / `todo_write` Agent tools |
109
109
  | `AgentSandboxGradeSchema` / `AgentSandboxGrade` / `AgentSandboxRestrictionSchema` / `AgentSandboxRestriction` / `AgentProcessSandbox` | schema / _type_ | host-provided process sandbox capability and explicit restriction vocabulary |
110
- | `probeAgentProcessSandbox` / `missingSandboxRestrictions` / `recordAgentSandboxProbe` | functions | process-cached probe, fail-closed required-gap calculation and durable probe record |
110
+ | `probeAgentProcessSandbox` / `missingSandboxRestrictions` / `recordAgentSandboxProbe` | functions | probe cached per sandbox object (keep the sandbox long-lived), fail-closed required-gap calculation and durable probe record; a probe that throws or returns no valid grade resolves to `unavailable` with a fixed reason, its cause emitted as a process warning (the coding tools instead carry it as the refusal's `cause` to the mount's `onToolError` hook) |
111
111
  | `AgentSandboxProcess` / `AgentSandboxOutputStream` | _types_ | structural child/output interface for optional lifecycle-owned `AgentProcessSandbox.spawn`, without Node ambient type dependencies |
112
112
  | `AgentEventSearchResultSchema` / `AgentEventSearchResult` / `createSqliteAgentEventSearch` / `createAgentEventSearchTools` | schema / _type_ / functions | authorized FTS5 search with exact event addresses and `session_*` tools |
113
113
  | `createSqliteAgentSpillStore` | function | durable content-address-checked artifact storage, bounded read/search, retention facts and archive participation |
@@ -13,15 +13,6 @@ Parts of this slice:
13
13
  # Guide: Agent application runtime (docs/guide/agent-runtime.md)
14
14
  ==============================================================================
15
15
 
16
- ---
17
- title: "Agent application runtime"
18
- description: Configure Stitchkit's optional durable history, stream loop, run coordination and managed-tool fencing.
19
- type: architecture
20
- status: active
21
- created: 2026-08-22
22
- updated: 2026-10-02 16:28 +07:00
23
- ---
24
-
25
16
  # Agent application runtime
26
17
 
27
18
  > **Maturity: evolving.** This surface is still finding its shape and may be
@@ -278,15 +278,6 @@ boundary is required. Send and projection callbacks own their external deadlines
278
278
  # Guide: Application migration recipes (docs/guide/application-migration-recipes.md)
279
279
  ==============================================================================
280
280
 
281
- ---
282
- title: Application migration recipes
283
- description: Executable patterns for moving database, poller, queue and operational publishing lifecycle into the managed application kernel.
284
- type: architecture
285
- status: active
286
- created: 2026-08-24
287
- updated: 2026-10-04 13:28 +07:00
288
- ---
289
-
290
281
  # Application migration recipes
291
282
 
292
283
  These recipes are the migration companion to the
@@ -438,10 +429,10 @@ guard must refuse. Filesystem mutations made inside inbox transactions call
438
429
  `assertHeld` immediately before publication or cleanup.
439
430
 
440
431
  For `createFileStateStore`, remove `staleLockMs` and `retryMs` from configuration.
441
- `lockTimeoutMs` remains the acquisition budget. Timestamp age no longer revokes
432
+ `lockTimeoutMs` is the acquisition budget. Timestamp age never revokes
442
433
  a live or unknown writer. Stop and verify old writers before recovering a legacy
443
- pid-only lock; do not invent owner metadata. Historical temporary files are no
444
- longer deleted by age. See the [durable intake contract](application-kernel.md#durable-process-facts-and-owner-notifications).
434
+ pid-only lock; do not invent owner metadata. Temporary files are never
435
+ deleted by age. See the [durable intake contract](application-kernel.md#durable-process-facts-and-owner-notifications).
445
436
 
446
437
  ## Long-running poller
447
438
 
@@ -36,7 +36,7 @@ cutovers are covered by the executable
36
36
  | `NotificationOutboxItem` / `NotificationOutboxReceipt` / `NotificationOutboxState` / `NotificationSend` / `NotificationFailureClassification` / `DroppedNotification` / `EnqueueNotification` | _type_ | versioned queue records, stable send identity and delivery decisions |
37
37
  | `notificationOutboxStateSchema` | function | strict persisted-state schema over an application payload schema |
38
38
  | `notificationOutboxResource` / `NotificationOutboxResource` / `NotificationOutboxResourceConfig` | function / _type_ | thin managed-resource scheduler over an outbox handle |
39
- | `createDirectoryInbox` (from `stitchkit/application/directory-inbox`) / `DirectoryInbox` / `DirectoryInboxConfig` / `DirectoryInboxDelivery` / `DirectoryInboxResource` | function / _type_ | one managed directory inbox for files or durable `accept({ source, key, entry })`; first payload wins, bounded capacity/bytes/receipts and renewable fenced leases; delivery begins after readiness and effects remain at least once |
39
+ | `createDirectoryInbox` (from `stitchkit/application/directory-inbox`) / `DirectoryInbox` / `DirectoryInboxConfig` / `DirectoryInboxDelivery` / `DirectoryInboxResource` | function / _type_ | one managed directory inbox for files or durable `accept({ source, key, entry })` (`entry` is the schema's input, stored as given); a hard-linked file is set aside as `invalid`; first payload wins, bounded capacity/bytes/receipts and renewable fenced leases; delivery begins after readiness and effects remain at least once |
40
40
  | `DirectoryInboxIdentitySchema` / `DirectoryInboxIdentity` / `DirectoryInboxAccept` / `DirectoryInboxAcceptResultSchema` / `DirectoryInboxAcceptResult` | schema / _type_ | validated source/key, typed entry and durable accepted/duplicate result with filename; duplicates do not replace the first payload |
41
41
  | `StateStoreUpdateContext` | _type_ | real active protected transaction: `assertHeld()` refuses after ownership loss or completion; custom adapters supply this context to their transition |
42
42
  | `DirectoryInboxStateSchema` / `DirectoryInboxState` / `DirectoryInboxRejection` / `DirectoryInboxRejectionReasonSchema` / `DirectoryInboxRejectionReason` | schema / _type_ | the inbox's claims, receipts and rejections (`invalid`, `too-large`, `attempt-limit`) |
@@ -122,9 +122,10 @@ cutovers are covered by the executable
122
122
  | Export | Kind | Summary |
123
123
  |--------|------|---------|
124
124
  | `createDiagnosticJournal` | function | create one schema-owned FIFO JSONL writer with bounded retained memory, exclusive local path ownership and finite rotation |
125
- | `DiagnosticJournalConfig` / `DiagnosticJournal` | _type_ | owner schema/path/limits/failure observer and the synchronous `submit`, bounded-wait `flush`/`close`, status handle |
125
+ | `DiagnosticJournalConfig` / `DiagnosticJournal` | _type_ | owner schema/path/limits/failure observer, `startupScan` (`tails` by default, or `full`), `onStartupRefusal` (`quarantine` by default, or `fail`) and the synchronous `submit`, bounded-wait `flush`/`close`, status handle |
126
126
  | `DiagnosticJournalLimitsSchema` / `DiagnosticJournalLimits` | schema / _type_ | positive event, pending-item, pending-byte, file-byte and retained-file limits |
127
127
  | `DiagnosticJournalLockPolicySchema` / `DiagnosticJournalLockPolicy` | schema / _type_ | `refuse` (default) or `reclaim-stale`, which reclaims only a lock whose recorded owner is provably gone |
128
+ | `DiagnosticJournalStartupScanSchema` / `DiagnosticJournalStartupScan` | schema / _type_ | how much of the retained generations opening a journal reads: `tails` (default) checks only the end of each file for a torn line, `full` parses every line |
128
129
  | `readDiagnosticJournalLockDiagnosis` / `DiagnosticJournalLockDiagnosis` | function / _type_ | why a `reclaim-stale` acquisition refused — attribution, PID liveness and optional process `identity` evidence (`matched`, `different-boot`, `reused-pid`, `pid-gone`, `legacy`, `unavailable`) — read off the thrown `EEXIST` |
129
130
  | `DiagnosticJournalSubmitResultSchema` / `DiagnosticJournalSubmitResult` | schema / _type_ | accepted epoch/sequence or explicit invalid, oversized, capacity, closed or failed refusal |
130
131
  | `DiagnosticJournalStatusSchema` / `DiagnosticJournalStatus` | schema / _type_ | state, limits, exact admission/write/failure counters, pending ownership, rotations, partial tails and last safe sequences |
@@ -137,8 +138,10 @@ cutovers are covered by the executable
137
138
  | `DiagnosticJournalWaitOptions` / `DiagnosticJournalFailure` | _type_ | caller wait signal/timeout and isolated internal failure callback record |
138
139
  | `DiagnosticJournalAnomalySchema` / `DiagnosticJournalAnomaly` | schema / _type_ | corrupt-row reason, file, zero-based byte offset, one-based line, tail/interior position and skipped bytes |
139
140
  | `createDiagnosticJournalReadResultSchema` / `DiagnosticJournalReadResult` | function / _type_ | owner-schema frame output or explicit anomaly; retains transformed event output types |
140
- | `DiagnosticJournalRecoveryStatusSchema` / `DiagnosticJournalRecoveryStatus` | schema / _type_ | bounded startup inspection counts and first/last anomaly locations |
141
- | `DiagnosticJournalRecoveryError` | class | torn single-file startup refusal carrying recovery observations, preserving evidence and releasing its lock |
141
+ | `DiagnosticJournalRecoveryStatusSchema` / `DiagnosticJournalRecoveryStatus` | schema / _type_ | bounded startup inspection counts, first/last anomaly locations and every quarantined file beside the journal (`quarantined`, this open's moves first with their `reason`, at most 32; `quarantinedUnlisted` counts the rest); evolving and `.strict()`, so every shape change is a breaking changelog item |
142
+ | `DiagnosticJournalStartupRefusalPolicySchema` / `DiagnosticJournalStartupRefusalPolicy` | schema / _type_ | `quarantine` (default) renames a file opening cannot keep in place to `<file>.quarantined-<epoch>` and starts; `fail` throws and moves nothing |
143
+ | `DiagnosticJournalStartupRefusalReasonSchema` / `DiagnosticJournalStartupRefusalReason` | schema / _type_ | `torn-without-retention-slot \| not-a-regular-file \| unreadable` |
144
+ | `DiagnosticJournalRecoveryError` / `DiagnosticJournalRecoveryErrorOptions` | class / _type_ | typed startup refusal (`reason`, `file`, optional `recovery`, `quarantineFailed`) thrown under `fail` or when moving a file aside failed; preserves evidence and releases its lock |
142
145
 
143
146
  `accepted` is bounded in-memory admission and `written` is completed append, not `fsync` or durable
144
147
  delivery. Its filesystem reader is in the diagnostic-journal leaf; there is no managed replay/upload API. See the
@@ -13,15 +13,6 @@ Parts of this slice:
13
13
  # Guide: Managed application kernel (docs/guide/application-kernel.md)
14
14
  ==============================================================================
15
15
 
16
- ---
17
- title: Managed application kernel
18
- description: Compose process-local resources, schedules, readiness, drain and optional provider adapters without building a second job platform.
19
- type: architecture
20
- status: active
21
- created: 2026-08-23
22
- updated: 2026-10-04 13:28 +07:00
23
- ---
24
-
25
16
  # Managed application kernel
26
17
 
27
18
  > **Maturity: evolving.** This surface is still finding its shape and may be
@@ -205,9 +196,8 @@ lifecycle context; the application decides when a database/provider probe runs.
205
196
 
206
197
  **A `reportHealth` call inside `start` is kept.** A resource that says nothing
207
198
  is assumed healthy once it is ready; one that reports its own health has already
208
- answered the question, and the answer stands. (It used to be overwritten — and
209
- the example above hides that, because `healthy` is the same value that
210
- overwrote it.)
199
+ answered the question, and the answer stands. The readiness default never
200
+ overwrites it.
211
201
 
212
202
  **Reporting the same health again is not a change.** A resource may confirm its
213
203
  health on a timer; a report with the value it already reported publishes
@@ -703,9 +693,48 @@ The caller owns file selection and coordination with an active rotator.
703
693
  Writer startup inspects retained and active files under its lock. On damage,
704
694
  `journal.getStatus().recovery` contains counts and first/last anomaly locations, reconstructed
705
695
  again on restart from the preserved bytes. This describes startup observations, not live
706
- continuous inspection. `maxFiles: 1` cannot preserve a torn active file by rotation and throws
707
- `DiagnosticJournalRecoveryError` before removing any evidence; configure at least two slots.
708
- Normal rotation retains the existing finite eviction policy. → [ADR 0219](../decisions/0219-journal-damage-is-data-and-io-failure-is-failure.md).
696
+ continuous inspection. Normal rotation retains the existing finite eviction policy.
697
+ → [ADR 0219](../decisions/0219-journal-damage-is-data-and-io-failure-is-failure.md).
698
+
699
+ A file opening cannot keep in place — a torn active file with `maxFiles: 1`, a generation name
700
+ that is not a regular file, a retained file it cannot read — is renamed to
701
+ `<file>.quarantined-<epoch>` beside it, and the journal starts (`onStartupRefusal: 'quarantine'`,
702
+ the default). Nothing is deleted; quarantined files are outside retention and yours to remove.
703
+ Every open lists them in `getStatus().recovery.quarantined` until you do: the ones it moved
704
+ first, with their `reason`, then the ones earlier runs left, without one — at most 32, and
705
+ `quarantinedUnlisted` counts the rest.
706
+ A journal whose damage must stop the process — one that is a source of truth, not diagnostics —
707
+ declares `onStartupRefusal: 'fail'` and gets a typed `DiagnosticJournalRecoveryError`:
708
+
709
+ ```ts
710
+ import { DiagnosticJournalRecoveryError } from 'stitchkit/application'
711
+
712
+ // A diagnostic journal: start, then say what is set aside.
713
+ const journal = await createDiagnosticJournal({ ...config })
714
+ const { quarantined = [], quarantinedUnlisted = 0 } = journal.getStatus().recovery ?? {}
715
+ for (const entry of quarantined) {
716
+ // `reason` is present only for a file this start moved; an earlier run's has none.
717
+ internalLogger.warn({ file: entry.file, movedTo: entry.quarantinedAs, reason: entry.reason })
718
+ }
719
+ if (quarantinedUnlisted > 0) internalLogger.warn({ quarantinedUnlisted })
720
+
721
+ // A journal that is a source of truth: refuse to start over damage.
722
+ try {
723
+ await createDiagnosticJournal({ ...config, onStartupRefusal: 'fail' })
724
+ } catch (error) {
725
+ if (error instanceof DiagnosticJournalRecoveryError) {
726
+ // error.reason: 'torn-without-retention-slot' | 'not-a-regular-file' | 'unreadable'
727
+ }
728
+ throw error
729
+ }
730
+ ```
731
+
732
+ A quarantining journal writes, so the managed resource that owns it reports `healthy`, and its
733
+ dependants read `recovery` from the value they `use()`. There is no degraded journal: the kernel
734
+ degrades only optional resources, and a required resource cannot depend on one.
735
+ `DiagnosticJournalRecoveryStatusSchema` is evolving and `.strict()`; if you embed it in your own
736
+ protocol, every change to its shape is listed under breaking changes.
737
+ → [ADR 0240](../decisions/0240-a-diagnostic-journal-quarantines-what-it-cannot-keep.md).
709
738
 
710
739
  Shutdown performs one phase barrier at a time: stop admission everywhere,
711
740
  cancel future schedules, drain admitted work, then close in reverse stable
@@ -0,0 +1,29 @@
1
+ # stitchkit/cli/publish — stitchkit docs slice
2
+
3
+ > Generated from the `docs/` tree by `bun run gen:llms`. The index of all slices is
4
+ > `llms.txt` in this package.
5
+
6
+ Contains: API reference: `stitchkit/cli/publish` (docs/api/reference.md)
7
+
8
+ Also read:
9
+ - see `llms/cli.txt` for the CLI guide
10
+
11
+ ==============================================================================
12
+ # API reference: `stitchkit/cli/publish` (docs/api/reference.md)
13
+ ==============================================================================
14
+
15
+ ## `stitchkit/cli/publish`
16
+
17
+ Build and release tooling, evolving. Publishes a CLI distribution into a local
18
+ application-owned directory; the manifest, signatures, installer and updater it
19
+ writes for stay in `stitchkit/cli` — [guide](../guide/cli.md#publishing-a-complete-version),
20
+ [ADR 0245](../decisions/0245-cli-publication-is-an-evolving-leaf.md).
21
+
22
+ | Export | Kind | Summary |
23
+ |--------|------|---------|
24
+ | `publishCli` | function | optional bounded builder/admission over one immutable name/version/commit stamp; commit verified assets before the manifest pointer, recover exact completed versions, retain verified history |
25
+ | `CliPublicationOptions` | _type_ | identity, storage root, base URL, targets, limits, retention, the `admit` and `build` callbacks, optional signing and trust |
26
+ | `CliPublicationPhase` | _type_ | the step `admit` is asked about — `prepare`, `build`, `commit` or `promote` |
27
+ | `CliPublicationResult` | _type_ | `published` or `existing`, with the manifest ready to serve |
28
+
29
+ ---
package/llms/cli.2.txt CHANGED
@@ -38,7 +38,7 @@ await createCli({ name: 'myapp', version, runtimeTools: discovered, commands: [.
38
38
  commands, and a connection without it still contributes nothing to the CLI —
39
39
  exposure stays explicit, as it is everywhere else in the framework.
40
40
 
41
- One unconvertible schema no longer takes the connection down with it. The tool
41
+ One unconvertible schema does not take the connection down. The tool
42
42
  is skipped and **named** (`onSkippedTool`, or a stderr line by default), so a
43
43
  surface of two hundred tools is not lost to one.
44
44
 
@@ -71,13 +71,12 @@ credential, body, identity and stack stay with the original in-process cause in
71
71
  Unknown throws remain `INTERNAL_SERVER_ERROR`. A timeout is not proof that a
72
72
  write did not happen: verify the remote outcome before repeating an operation.
73
73
 
74
- **A remote refusal keeps its code.** A failed `tools/call` used to become a
75
- one-sentence `Error` with the result discarded, which cost three things at once:
76
- the code (so `exitCodes` had nothing to map and every remote failure exited `1`),
77
- the message the operator needed, and the error's own class — a plain `Error` is
78
- an *unexpected* error to the runner, so it printed a code frame of the framework
79
- bundle before the JSON failure and was then scrubbed to `INTERNAL_SERVER_ERROR`.
80
- A structured `{ error, details }` body is now relayed as the contract error it
74
+ **A remote refusal keeps its code.** A failed `tools/call` must keep three things:
75
+ the code (so `exitCodes` can map it instead of every remote failure exiting `1`),
76
+ the message the operator needs, and the error's own class — a plain `Error` is
77
+ an *unexpected* error to the runner, which would print a code frame of the framework
78
+ bundle before the JSON failure and scrub it to `INTERNAL_SERVER_ERROR`.
79
+ A structured `{ error, details }` body is relayed as the contract error it
81
80
  is, on every transport; anything else fails as `UPSTREAM_TOOL_ERROR` carrying
82
81
  what the server did send. Not `INTERNAL_SERVER_ERROR`, because nothing of ours
83
82
  broke.
@@ -172,7 +171,6 @@ SDK nor the `ai` peer.
172
171
  | `checkCliUpdate` | function | bounded, interval-limited, never-throwing check for a newer published build |
173
172
  | `applyCliUpdate` | function | download, verify the decompressed digest and replace the binary by rename |
174
173
  | `assertCliPublishable` | function | refuse republishing one version from a different commit — takes one manifest or every manifest already published, because the promise a version makes does not stop at a channel boundary |
175
- | `publishCli` / `CliPublicationOptions` / `CliPublicationPhase` / `CliPublicationResult` | function / _type_ | optional bounded builder/admission over one immutable name/version/commit stamp; commit verified assets before the manifest pointer, recover exact completed versions, retain verified history; existing signatures/installer/updater own the wire contract |
176
174
  | `rollbackCliUpdate` / `CliRollbackConfig` / `RolledBackCliUpdate` | function / _types_ | put the kept previous build back, digest-checked first and written by the same atomic rename the update uses |
177
175
  | `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 |
178
176
  | `cliSignatureAccepted` / `CliSignatureVerdict` | function / _type_ | `valid` \| `unenforced` \| `missing` \| `unknown-key` \| `invalid`; `unenforced` keeps an unpinned build updating while making the absence of a check visible |
@@ -204,8 +202,8 @@ SDK nor the `ai` peer.
204
202
  | `CliConfig` | _type_ | config for `createCli`; `defaultCommand`, `globalOptions`, `optionAliases` and `positionals` define the shared command presentation policy |
205
203
  | `CliPresentationPolicyConfig` | _type_ | shared command presentation-policy subset of `CliConfig` |
206
204
  | `CliSurfaceSource` | _type_ | static service/runtime array or identity-dependent factory |
207
- | `RuntimeToolExecution` | _type_ | neutral heterogeneous runtime-tool registration; handlers execute through the schema-validating managed runner |
208
- | `RuntimeToolExecutionWithOutput` | _type_ | strict neutral managed definition with schema-derived handler input/output; construct before adding to CLI `runtimeTools` |
205
+ | `RuntimeToolDefinition` | _type_ | neutral heterogeneous runtime-tool registration; an inline handler is contextually typed, and handlers execute through the schema-validating managed runner |
206
+ | `RuntimeToolDefinitionWithOutput` | _type_ | strict neutral managed definition with schema-derived handler input/output, the same declaration `stitchkit/tools` constructs with presenters |
209
207
  | `RuntimeToolDefinitionWithoutOutput` | _type_ | strict neutral managed void definition without an output contract or transport presenters |
210
208
  | `CliCommandDefinition` | _type_ | native command definition union |
211
209
  | `CliCommandDefinitionBase` | _type_ | native command name, description and input schema |
package/llms/cli.txt CHANGED
@@ -33,9 +33,10 @@ declarations do not require `ai`, the MCP SDK or Bun globals. Node consumers can
33
33
  use strict `NodeNext` resolution with `skipLibCheck: false` and ordinary Node
34
34
  types; the package keeps its required dependencies separate from optional SDKs.
35
35
 
36
- CLI runtime tools use the shared executable contract: identity, input and output
37
- schemas, handler, and explicit CLI exposure. SDK presenters belong to the MCP/AI
38
- definitions in `stitchkit/tools`, which require the corresponding peers. A typed
36
+ CLI runtime tools use the one runtime-tool declaration: identity, input and output
37
+ schemas, handler, and explicit CLI exposure. SDK presenters are the adapter's extension
38
+ of that declaration (the fourth type argument of `RuntimeToolDefinitionWithOutput`, or
39
+ `defineRuntimeTool` in `stitchkit/tools`), which requires the corresponding peers. A typed
39
40
  definition returned by `defineRuntimeTool` or `createRuntimeToolFactory` can be
40
41
  passed directly to both CLI and SDK mounts.
41
42
 
@@ -49,7 +50,7 @@ For a CLI-only managed tool, use the neutral generic construction contract to
49
50
  infer the handler from its schemas:
50
51
 
51
52
  ```ts
52
- import type { RuntimeToolExecutionWithOutput } from 'stitchkit/cli'
53
+ import type { RuntimeToolDefinitionWithOutput } from 'stitchkit/cli'
53
54
  import { z } from 'zod'
54
55
 
55
56
  const input = z.object({ text: z.string() })
@@ -59,12 +60,14 @@ const measure = {
59
60
  identity: { serviceName: 'text', action: 'measure', method: 'POST' },
60
61
  transports: ['CLI'], input, output,
61
62
  handler: ({ input }) => ({ size: input.text.length }),
62
- } satisfies RuntimeToolExecutionWithOutput<typeof input, typeof output>
63
+ } satisfies RuntimeToolDefinitionWithOutput<typeof input, typeof output>
63
64
  ```
64
65
 
65
- Pass `measure` to `runtimeTools`. The heterogeneous registration type preserves
66
- the definition without inventing a common handler input; execute it through
67
- `createCli` or `createCliInvoker` so validation remains on the canonical path.
66
+ Pass `measure` to `runtimeTools`. `RuntimeToolDefinition`, the heterogeneous
67
+ registration type, accepts it unchanged, and types an inline handler written directly
68
+ in `runtimeTools` by the parsed object (use the construction type above to type the
69
+ input from the schema). Execute it through `createCli` or `createCliInvoker` so
70
+ validation remains on the canonical path.
68
71
 
69
72
  ## Exposure is opt-in
70
73
 
@@ -254,7 +257,9 @@ the values agree. Duplicates are refused before command execution. Array
254
257
  options accumulate across long and short forms; unknown non-dotted passthrough
255
258
  options retain their raw-list grammar. Tokens after `--` are literal data.
256
259
  Command `--help` and `-h` keep their diagnostic precedence over malformed
257
- operation arguments; application globals are validated before routing.
260
+ operation arguments; application globals are validated before routing. Help is a
261
+ request, not a setting, so repeating it in any spelling (`-h -h`, `-h --help`) asks once
262
+ and never errors.
258
263
 
259
264
  Without presentation configuration, positional arguments fill non-boolean
260
265
  fields in declaration order, so `myapp generate "a fox"` is
@@ -481,8 +486,10 @@ Declared aliases render beside their canonical options, for example
481
486
  The argument table and `Application options:` show bounds from their JSON Schema,
482
487
  for example `<integer> [>=1, <=50]`, `<string> [length >=1, length <=12]`, and
483
488
  `<value…> [items >=2, items <=4]`. Numeric `>` and `<` are exclusive, while `>=`
484
- and `<=` include the endpoint; a zero limit is displayed too. Unbounded fields
485
- keep just their type and description. Bounds on an array's items are not bounds
489
+ and `<=` include the endpoint; a zero limit is displayed too. Only limits the
490
+ schema declares are shown: the safe-integer range every `z.int()` carries is the
491
+ type, not a bound, so a bare integer prints `<integer>`, `.min(1)` prints `>=1` and
492
+ `.positive()` prints `>0`. Unbounded fields keep just their type and description. Bounds on an array's items are not bounds
486
493
  on the array itself.
487
494
 
488
495
  Composed schemas retain their meaning: `any of:` and `one of:` separate
@@ -710,11 +717,16 @@ exists to distrust.
710
717
 
711
718
  `publishCli` is an opt-in publisher for a local application-owned distribution
712
719
  directory. It commits every target and its version manifest before atomically
713
- replacing the public `manifest.json`. Your application selects the CLI source
714
- identity and admits that snapshot at each phase:
720
+ replacing the public `manifest.json`. It ships from its own evolving entrypoint,
721
+ `stitchkit/cli/publish`: release infrastructure follows how distributions are
722
+ published, so it is not held to the stable promise of `stitchkit/cli`
723
+ ([ADR 0245](../decisions/0245-cli-publication-is-an-evolving-leaf.md)). The
724
+ manifest, signatures, installer and updater it writes for stay in
725
+ `stitchkit/cli`. Your application selects the CLI source identity and admits
726
+ that snapshot at each phase:
715
727
 
716
728
  ```ts
717
- import { publishCli } from 'stitchkit/cli'
729
+ import { publishCli } from 'stitchkit/cli/publish'
718
730
 
719
731
  const result = await publishCli({
720
732
  storageRoot: '/srv/myapp/cli',
@@ -9,15 +9,6 @@ Contains: Guide: Project declaration (docs/guide/declaration.md) · API referen
9
9
  # Guide: Project declaration (docs/guide/declaration.md)
10
10
  ==============================================================================
11
11
 
12
- ---
13
- title: Project declaration
14
- description: One machine-readable statement a repository makes about itself — identity, roles, build, requirements, release steps and the names of the values a deployment supplies.
15
- type: architecture
16
- status: active
17
- created: 2026-08-25
18
- updated: 2026-08-30
19
- ---
20
-
21
12
  # Project declaration
22
13
 
23
14
  > **Maturity: evolving.** This surface is still finding its shape and may be
@@ -16,19 +16,27 @@ Also read:
16
16
 
17
17
  `stitchkit/files/packaging` owns `createNativePackaging` and the types
18
18
  `NativePackagingOptions`, `NativePackagingAsset`, `NativePackagingPlugin`, `NativePackagingResult`.
19
- It resolves the installed package's target/version and original addon SHA256.
20
- `platform`, `architecture`, `delivery`, `entryPath` and `assetPath` are explicit public inputs.
21
- The result is `ready` with assets and a structural Bun plugin, or `unsupported`/`missing` with a safe code.
22
- Malformed options/metadata and other filesystem errors fail rather than masquerade as missing.
19
+ It resolves the installed package's target/version, reads each selected addon once and checks it
20
+ against the `size` and `sha256` published in the package's `native-assets.json` (`formatVersion: 2`,
21
+ written when Stitchkit is built). Call it once per build and reuse the result.
22
+ `platform`, `architecture`, `delivery`, `entryPath` and `assetPath` are explicit public inputs;
23
+ `platform` is the closed set `'darwin'`, and another name is a type error and a schema refusal.
24
+ The result is `ready` with verified assets and a structural Bun plugin, or `unsupported` /
25
+ `missing` / `mismatch` with the safe code `NATIVE_TARGET_UNSUPPORTED`, `NATIVE_ASSET_MISSING` or
26
+ `NATIVE_ASSET_DIGEST_MISMATCH`. A `mismatch` names the first differing `architecture` with
27
+ `expected` (published) and `actual` (installed) `{ size, sha256 }`.
28
+ Malformed options, a manifest of another `formatVersion` and other filesystem errors throw rather
29
+ than masquerade as missing.
23
30
  Companion accepts a single `architecture` string with an `assetPath` string, or an architecture
24
31
  array with an exact per-architecture `assetPath` map. `NativePackagingOptions<true>` and
25
32
  `NativePackagingResult<true>` describe the array form; default types preserve single-target signatures.
26
33
  A ready array-form result carries the architecture array; `NativePackagingAsset<true>` identifies
27
- each asset architecture. Default asset types and single-target runtime objects retain their three fields.
34
+ each asset architecture. A single-target asset has four fields: `outputPath`, the verified `bytes`,
35
+ and the published `size` and `sha256`.
28
36
  Targets must be unique; entry and all asset paths must be disjoint. One lazy loader chooses only
29
37
  the actual runtime architecture, with no fallback.
30
- Companion mode places external addons relative to the emitted entry; embedded mode lets
31
- Bun compile retain the matching addon. Keep JS builds without splitting, preserve every output,
32
- and copy each original asset to its `outputPath` after verifying `sha256`.
38
+ Companion mode places external addons relative to the emitted entry; embedded mode gives
39
+ Bun compile the verified bytes of the matching addon. Keep JS builds without splitting, preserve
40
+ every output, and write each asset's `bytes` to its `outputPath`.
33
41
  This evolving entrypoint is a build dependency; runtime imports do not reach it.
34
42
  The detailed recipe is in [native IO](../guide/native-io.md#public-native-packaging).
package/llms/files.txt CHANGED
@@ -29,8 +29,10 @@ available from `stitchkit/contract`.
29
29
  | `ManagedFileError` / `ManagedFileErrorCode` | class / _type_ | stable boundary failures; registered `FILE_*` mistakes are caller-safe while `FILE_IO_ERROR` remains internal |
30
30
  | `ManagedFileInspector` | _type_ | bounded-prefix read/write inspection callback with a finite cancellation signal that cannot own path or size |
31
31
  | `ManagedFileInspectionInput` / `ManagedFileInspection` | _type_ | inspector prefix/name/declared media/signal input and validated metadata-only result |
32
- | `writeFileAtomic` / `writeFileAtomicSync` / `WriteFileAtomicOptions` | function / _type_ | replace a file atomically: a random staging name created exclusively (never through a planted link), the mode set on the descriptor before the file is visible (default `0o600`, not masked by the umask), `fsync`, rename; a failure leaves the target and no staging file. The asynchronous form keeps the event loop running |
33
- | `withExclusiveLock` / `ExclusiveLockOptions` / `ExclusiveLock` / `ExclusiveLockOwner` | function / _type_ | run work under an exclusive lock between processes — a file recording its owner (pid, host, machine identity, time and nullable kernel process identity); waits up to `timeoutMs` (default 10 s) and stops on `signal`; a dead owner on this machine is taken over, a live, slow or foreign one never is; an ownerless lock only after `ownerlessGraceMs` (default 5000 ms, `null` disables age-based reclaim including guards); exact `mode` is independent of umask; shared readers need a common group and traversable directories |
32
+ | `writeFileAtomic` / `writeFileAtomicSync` / `WriteFileAtomicOptions` | function / _type_ | replace a file atomically: a random staging name created exclusively (never through a planted link), the mode set on the descriptor before the file is visible (default `0o600`, not masked by the umask), `fsync`, rename; a failure leaves the target and no staging file. The asynchronous form keeps the event loop running. A process killed before publication leaves its staging file; sweeping it is the caller's job |
33
+ | `isAtomicStagingName` | function | true for a staging file name of an atomic write of this library (`.stitchkit-<24 lowercase hex>.tmp`, also used by the managed writer and the chunk spool); the form is a stable contract, and changing it is a breaking change ([ADR 0242](../decisions/0242-atomic-staging-name-is-a-public-contract.md)) |
34
+ | `sweepAtomicStaging` / `SweepAtomicStagingOptions` | function / _type_ | remove abandoned staging files from one `directory`: only regular files matching `isAtomicStagingName` and older than the required `olderThanMs`, never following a symlink or entering a subdirectory; stops on `signal`; returns the removed names |
35
+ | `withExclusiveLock` / `ExclusiveLockOptions` / `ExclusiveLock` / `ExclusiveLockOwner` | function / _type_ | run work under an exclusive lock between processes — a file recording its owner (pid, host, machine identity, time and nullable kernel process identity); waits up to `timeoutMs` (default 10 s) and stops on `signal`; a dead owner on this machine is taken over, a live, slow or foreign one never is; the lock is published with its owner already recorded (temporary file plus hard link), so a stalled holder is never displaced; a legacy empty lock file is taken by age only when `ownerlessGraceMs` is a number (default `null`: never; an abandoned empty reclaim guard is taken after 5 000 ms unless a value is set); exact `mode` is independent of umask; shared readers need a common group and traversable directories |
34
36
  | `ExclusiveLockError` | class | `LOCK_TIMEOUT` naming the resource and its holder, or `LOCK_ABORTED` with the signal's reason |
35
37
  | `createChunkSpool` | function | the server half of a chunked upload: parts on disk under `owner` + client-minted `uploadId`, each with a size+sha256 receipt; idempotent `open` and `put`, the first writer of a part wins across processes, `assemble` in order once every part is in, `sweep` of untouched uploads — [guide](../guide/client.md#chunked-uploads) |
36
38
  | `ChunkSpool` / `ChunkSpoolConfig` / `ChunkSpoolKey` / `ChunkSpoolOpen` / `ChunkSpoolPart` / `ChunkSpoolAssembly` | _type_ | the spool, its directory, part size, file limit, meta schema and age; an upload's key; its declaration; one part; the assembled parts with a concatenating `stream()` |
package/llms/geo.txt CHANGED
@@ -9,15 +9,6 @@ Contains: Guide: GeoIP (docs/guide/geo.md) · API reference: `stitchkit/geo` (
9
9
  # Guide: GeoIP (docs/guide/geo.md)
10
10
  ==============================================================================
11
11
 
12
- ---
13
- title: GeoIP
14
- description: A server-only managed GeoIP reader with three observable states and last-known-good generation reloads.
15
- type: guide
16
- status: active
17
- created: 2026-09-06
18
- updated: 2026-09-06
19
- ---
20
-
21
12
  # GeoIP
22
13
 
23
14
  `stitchkit/geo` is a server-only, evolving entrypoint for reading local GeoIP
package/llms/live.txt CHANGED
@@ -9,15 +9,6 @@ Contains: Guide: Live data (docs/guide/live.md) · API reference: `stitchkit/li
9
9
  # Guide: Live data (docs/guide/live.md)
10
10
  ==============================================================================
11
11
 
12
- ---
13
- title: Live data — announcements, watched reads, keyspaces and the trust fence
14
- description: How to declare events beside the operation contract, share one server-side read between every browser asking the same question, keep authoritative memory in front of a durable backend, and refuse a request whose authority you never agreed to answer on.
15
- type: guide
16
- status: active
17
- created: 2026-09-02
18
- updated: 2026-09-02
19
- ---
20
-
21
12
  # Live data
22
13
 
23
14
  Four things an application builds by hand the second time it needs them.
@@ -429,11 +420,11 @@ Every refusal answers the same bare 403. A response that said *which* rule
429
420
  refused would let a caller learn your trusted list one guess at a time; the
430
421
  reason goes to `onRefused` and the log, where you are.
431
422
 
432
- ### One thing that changed
423
+ ### Group hooks
433
424
 
434
- A route group can no longer declare `onRequest`. It never worked — the framework
435
- dispatched only the server-level hook — and it could not be made to work without
436
- matching group prefixes a second time, ahead of the real router. Use the
425
+ A route group cannot declare `onRequest`: the framework dispatches only the
426
+ server-level hook, and a group hook would need group prefixes matched a second
427
+ time, ahead of the real router. Use the
437
428
  server-level `hooks.onRequest` to refuse before dispatch, or the group's
438
429
  `authorize` to gate once the endpoint is known.
439
430
 
@@ -303,6 +303,32 @@ Without an `observability` the work still runs inside a context, so trace ids,
303
303
  decision from having a context. `traceparent` continues the trace of whatever
304
304
  scheduled the work, instead of starting an unrelated one.
305
305
 
306
+ ### CPU is not attributed to work
307
+
308
+ Request rows, `runUnitOfWork` rows and schedule status carry durations and
309
+ counts, never CPU. One JavaScript thread interleaves every operation, so a
310
+ `process.cpuUsage()` delta across an operation's start and end measures
311
+ everything the process ran in that time — a long wait reads as the CPU of the
312
+ timers that fired during it. The correct basis is the synchronous segment, and
313
+ Bun gives no callback when a continuation is entered or left
314
+ ([ADR 0244](../decisions/0244-cpu-is-not-attributed-to-operations.md)).
315
+
316
+ Process CPU per window is the number you can observe:
317
+
318
+ ```ts
319
+ let last = process.cpuUsage()
320
+ setInterval(() => {
321
+ const now = process.cpuUsage() // cumulative { user, system } in µs
322
+ logger.info('cpu', { cpuUserUs: now.user - last.user, cpuSystemUs: now.system - last.system })
323
+ last = now
324
+ }, 60_000)
325
+ ```
326
+
327
+ If you build attribution yourself: credit an operation only the CPU of the
328
+ synchronous segments it ran, never its waiting time; put everything outside those
329
+ segments into `unattributed`; never credit a window to the one operation in
330
+ flight — that operation is usually the one waiting.
331
+
306
332
  ### Write the calls that changed something
307
333
 
308
334
  `auditChanges` is the filter most projects end up writing, shipped so they do not
@@ -377,8 +403,8 @@ needed:
377
403
  createServer({ services, logging, observability: observability.request })
378
404
  ```
379
405
 
380
- `wrapInRequestContext` remains available for a custom fetch pipeline that does
381
- not use `createHandler`; it is no longer part of built-in HTTP audit wiring:
406
+ `wrapInRequestContext` serves a custom fetch pipeline that does not use
407
+ `createHandler`; built-in HTTP audit wiring does not use it:
382
408
 
383
409
  ```ts
384
410
  Bun.serve({ fetch: wrapInRequestContext(customFetch) })
@@ -715,9 +741,9 @@ which the built-in **tool** row does not read: a tool event takes
715
741
  `errorCode` / `errorMessage` / `errorDetail` from the `ToolResult`, and only
716
742
  identity and `dimensions` from the context. Calling it in `onToolError` would
717
743
  leave the tool row exactly as scrubbed as before. It is right for the **HTTP**
718
- path, where the request *is* the record. (Since ADR 0045 a tool call runs in its
719
- own context, so it can no longer write into the enclosing `/mcp` request's row
720
- either — the call is simply not where that helper belongs.)
744
+ path, where the request *is* the record. (A tool call runs in its own context, ADR 0045,
745
+ so it cannot write into the enclosing `/mcp` request's row either — the call is
746
+ simply not where that helper belongs.)
721
747
 
722
748
  ### One row that names the cause
723
749