stitchkit 0.104.2 → 0.105.1

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 (430) hide show
  1. package/CHANGELOG.md +401 -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 +161 -66
  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-269zqj8m.js → index-1ptj98e0.js} +28 -12
  160. package/dist/{index-kemm0ej5.js → index-1pwwan01.js} +65 -22
  161. package/dist/{index-vgkbcnkc.js → index-299sm5tr.js} +1 -1
  162. package/dist/{index-2vnh05w4.js → index-2k91mewf.js} +31 -74
  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-f330qqyg.js → index-5c26631f.js} +244 -67
  168. package/dist/{index-adhgd4pe.js → index-5p55xreg.js} +2 -2
  169. package/dist/index-5w6t91ze.js +47 -0
  170. package/dist/{index-9pw0a51a.js → index-6yxhe58g.js} +40 -7
  171. package/dist/{index-6d9xaxw1.js → index-8ks9b85e.js} +33 -5
  172. package/dist/{index-bhb950qs.js → index-916yh4e2.js} +25 -12
  173. package/dist/index-9tqbxv5p.js +44 -0
  174. package/dist/{index-5csmzesf.js → index-azx12jgv.js} +4 -3
  175. package/dist/{index-mbnnw3f2.js → index-b0kddvzw.js} +15 -5
  176. package/dist/{index-n5yqxd3d.js → index-b0w7rbpt.js} +23 -2
  177. package/dist/index-b56nnscm.js +132 -0
  178. package/dist/{index-0ndk4555.js → index-c0hffcmj.js} +2 -2
  179. package/dist/{index-pptyv13k.js → index-c17xcx4k.js} +42 -6
  180. package/dist/index-cazts87s.js +105 -0
  181. package/dist/{index-g2j7pnak.js → index-cmzvhhtd.js} +5 -2
  182. package/dist/{index-ssmd41kh.js → index-d2h99n7d.js} +1 -1
  183. package/dist/{index-z94wht4y.js → index-dky0dcmf.js} +34 -5
  184. package/dist/index-drs41arz.js +455 -0
  185. package/dist/{index-za6j7nwy.js → index-dsnjzb62.js} +104 -51
  186. package/dist/index-eemvahkc.js +21 -0
  187. package/dist/{index-fa4wg312.js → index-f199nfq5.js} +10 -6
  188. package/dist/{index-ck71tbcf.js → index-fsw1ybf3.js} +11 -15
  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-j4zh647a.js +59 -0
  192. package/dist/{index-x928baz2.js → index-j9gxbztg.js} +18 -14
  193. package/dist/index-kfjkb396.js +37 -0
  194. package/dist/{index-6drst9sg.js → index-ksfagmyz.js} +45 -345
  195. package/dist/index-m616f0yz.js +120 -0
  196. package/dist/{index-fm1c1a08.js → index-m6w6jtda.js} +40 -21
  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-hbd32c6a.js → index-w8etpm8j.js} +38 -89
  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-hp9d77wk.js → index-x7w1z6pf.js} +15 -4
  211. package/dist/{index-ptn0g0gj.js → index-y7k2cdgv.js} +21 -20
  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 +47 -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 +7 -2
  255. package/dist/process/cleanup.d.ts.map +1 -1
  256. package/dist/process/command-lifetime.d.ts +6 -1
  257. package/dist/process/command-lifetime.d.ts.map +1 -1
  258. package/dist/process/command-owner.d.ts +1 -0
  259. package/dist/process/command-owner.d.ts.map +1 -1
  260. package/dist/process/command.d.ts +4 -0
  261. package/dist/process/command.d.ts.map +1 -1
  262. package/dist/process/contract.d.ts +68 -2
  263. package/dist/process/contract.d.ts.map +1 -1
  264. package/dist/process/group.d.ts +42 -3
  265. package/dist/process/group.d.ts.map +1 -1
  266. package/dist/process/launch.d.ts +12 -1
  267. package/dist/process/launch.d.ts.map +1 -1
  268. package/dist/process/terminate.d.ts +40 -0
  269. package/dist/process/terminate.d.ts.map +1 -0
  270. package/dist/react/query-client.d.ts.map +1 -1
  271. package/dist/realtime/rejection.d.ts.map +1 -1
  272. package/dist/server/contract-stream.d.ts.map +1 -1
  273. package/dist/server/handler-state.d.ts.map +1 -1
  274. package/dist/server/implement.d.ts.map +1 -1
  275. package/dist/server/request-body.d.ts +0 -1
  276. package/dist/server/request-body.d.ts.map +1 -1
  277. package/dist/server/unix-client.d.ts.map +1 -1
  278. package/dist/telegram/broadcast-delivery.d.ts.map +1 -1
  279. package/dist/telegram/broadcast-failure.d.ts +10 -2
  280. package/dist/telegram/broadcast-failure.d.ts.map +1 -1
  281. package/dist/telegram/operator-channel.d.ts.map +1 -1
  282. package/dist/telegram/screens/outcome.d.ts.map +1 -1
  283. package/dist/testing/surface-conformance.d.ts +1 -1
  284. package/dist/testing/surface-conformance.d.ts.map +1 -1
  285. package/dist/testing/surface-manifest.d.ts +0 -6
  286. package/dist/testing/surface-manifest.d.ts.map +1 -1
  287. package/dist/tools/agent.d.ts +1 -1
  288. package/dist/tools/agent.d.ts.map +1 -1
  289. package/dist/tools/cli/args.d.ts +1 -1
  290. package/dist/tools/cli/args.d.ts.map +1 -1
  291. package/dist/tools/cli/help.d.ts.map +1 -1
  292. package/dist/tools/cli/invoke.d.ts +2 -2
  293. package/dist/tools/cli/invoke.d.ts.map +1 -1
  294. package/dist/tools/cli/profile.d.ts.map +1 -1
  295. package/dist/tools/cli/publication-assets.d.ts.map +1 -1
  296. package/dist/tools/cli/publication-contract.d.ts +8 -0
  297. package/dist/tools/cli/publication-contract.d.ts.map +1 -1
  298. package/dist/tools/cli/publication-control.d.ts.map +1 -1
  299. package/dist/tools/cli/publication-storage.d.ts +23 -2
  300. package/dist/tools/cli/publication-storage.d.ts.map +1 -1
  301. package/dist/tools/cli/publication.d.ts +8 -1
  302. package/dist/tools/cli/publication.d.ts.map +1 -1
  303. package/dist/tools/connections/errors.d.ts +18 -6
  304. package/dist/tools/connections/errors.d.ts.map +1 -1
  305. package/dist/tools/connections/limits.d.ts +8 -2
  306. package/dist/tools/connections/limits.d.ts.map +1 -1
  307. package/dist/tools/connections/mcp-client.d.ts.map +1 -1
  308. package/dist/tools/connections/mcp-envelope.d.ts.map +1 -1
  309. package/dist/tools/connections/openapi.d.ts.map +1 -1
  310. package/dist/tools/connections/schema-budget.d.ts +1 -1
  311. package/dist/tools/connections/schema-budget.d.ts.map +1 -1
  312. package/dist/tools/connections/sse-session.d.ts.map +1 -1
  313. package/dist/tools/execute-args.d.ts.map +1 -1
  314. package/dist/tools/execute-result.d.ts.map +1 -1
  315. package/dist/tools/internal/surface-projector.d.ts +17 -3
  316. package/dist/tools/internal/surface-projector.d.ts.map +1 -1
  317. package/dist/tools/internal/tool-error-projection.d.ts +16 -0
  318. package/dist/tools/internal/tool-error-projection.d.ts.map +1 -0
  319. package/dist/tools/internal/tool-view.d.ts.map +1 -1
  320. package/dist/tools/invoker.d.ts.map +1 -1
  321. package/dist/tools/list-names.d.ts +3 -2
  322. package/dist/tools/list-names.d.ts.map +1 -1
  323. package/dist/tools/manifest.d.ts +3 -2
  324. package/dist/tools/manifest.d.ts.map +1 -1
  325. package/dist/tools/mcp/handler.d.ts +7 -0
  326. package/dist/tools/mcp/handler.d.ts.map +1 -1
  327. package/dist/tools/mcp/mount.d.ts +18 -2
  328. package/dist/tools/mcp/mount.d.ts.map +1 -1
  329. package/dist/tools/mcp/prepare.d.ts +3 -3
  330. package/dist/tools/mcp/prepare.d.ts.map +1 -1
  331. package/dist/tools/mcp/register.d.ts.map +1 -1
  332. package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
  333. package/dist/tools/mcp/stdio-signals.d.ts +14 -0
  334. package/dist/tools/mcp/stdio-signals.d.ts.map +1 -1
  335. package/dist/tools/mcp/stdio.d.ts +7 -0
  336. package/dist/tools/mcp/stdio.d.ts.map +1 -1
  337. package/dist/tools/operations/async-operation-runtime-tools.d.ts.map +1 -1
  338. package/dist/tools/operations/async-operation-runtime-types.d.ts +3 -3
  339. package/dist/tools/operations/async-operation-runtime-types.d.ts.map +1 -1
  340. package/dist/tools/operations/define-wait-tool.d.ts +1 -1
  341. package/dist/tools/operations/define-wait-tool.d.ts.map +1 -1
  342. package/dist/tools/operations/wait-core.d.ts +0 -6
  343. package/dist/tools/operations/wait-core.d.ts.map +1 -1
  344. package/dist/tools/registry.d.ts +1 -1
  345. package/dist/tools/registry.d.ts.map +1 -1
  346. package/dist/tools/remote.d.ts +1 -1
  347. package/dist/tools/remote.d.ts.map +1 -1
  348. package/dist/tools/{runtime-tool-execution.d.ts → runtime-tool-declaration.d.ts} +32 -9
  349. package/dist/tools/runtime-tool-declaration.d.ts.map +1 -0
  350. package/dist/tools/runtime-tool-mcp.d.ts +6 -15
  351. package/dist/tools/runtime-tool-mcp.d.ts.map +1 -1
  352. package/dist/tools/runtime-tool.d.ts +14 -12
  353. package/dist/tools/runtime-tool.d.ts.map +1 -1
  354. package/dist/tools/schema/coerce.d.ts +4 -0
  355. package/dist/tools/schema/coerce.d.ts.map +1 -1
  356. package/dist/tools/schema/flatten-join.d.ts.map +1 -1
  357. package/dist/tools/surface.d.ts +7 -11
  358. package/dist/tools/surface.d.ts.map +1 -1
  359. package/dist/tools/transfer/define-download-tool.d.ts +1 -1
  360. package/dist/tools/transfer/define-download-tool.d.ts.map +1 -1
  361. package/dist/tools/transfer/define-upload-tool.d.ts +1 -1
  362. package/dist/tools/transfer/define-upload-tool.d.ts.map +1 -1
  363. package/dist/tools/transfer/define-view-file-tool.d.ts +1 -1
  364. package/dist/tools/transfer/define-view-file-tool.d.ts.map +1 -1
  365. package/dist/tools/transfer/managed-file-error.d.ts.map +1 -1
  366. package/dist/tools/transfer/view-file-contract.d.ts.map +1 -1
  367. package/dist/tools/transfer/view-file.d.ts +1 -1
  368. package/dist/tools/transfer/view-file.d.ts.map +1 -1
  369. package/dist/tools/transports.d.ts +3 -2
  370. package/dist/tools/transports.d.ts.map +1 -1
  371. package/llms/agent-runtime-browser.txt +10 -4
  372. package/llms/agent-runtime-harness.txt +32 -31
  373. package/llms/agent-runtime-react.txt +1 -1
  374. package/llms/agent-runtime-realtime.txt +14 -5
  375. package/llms/agent-runtime-sandbox.txt +3 -11
  376. package/llms/agent-runtime.3.txt +2 -2
  377. package/llms/agent-runtime.txt +0 -9
  378. package/llms/application.2.txt +3 -12
  379. package/llms/application.3.txt +7 -4
  380. package/llms/application.txt +44 -15
  381. package/llms/cli-publish.txt +29 -0
  382. package/llms/cli.2.txt +9 -11
  383. package/llms/cli.txt +26 -14
  384. package/llms/declaration.txt +0 -9
  385. package/llms/files-packaging.txt +18 -8
  386. package/llms/files.txt +4 -2
  387. package/llms/geo.txt +0 -9
  388. package/llms/live.txt +4 -13
  389. package/llms/observability.txt +31 -5
  390. package/llms/primitives.txt +38 -20
  391. package/llms/process.txt +324 -160
  392. package/llms/react-keyboard.txt +0 -9
  393. package/llms/react.txt +0 -18
  394. package/llms/server.4.txt +1 -1
  395. package/llms/server.5.txt +1 -1
  396. package/llms/server.txt +1 -1
  397. package/llms/stitchkit.txt +6 -7
  398. package/llms/telegram-screens.txt +2 -2
  399. package/llms/testing.txt +0 -1
  400. package/llms/tools-mcp.txt +2 -3
  401. package/llms/tools.2.txt +12 -0
  402. package/llms/tools.3.txt +5 -6
  403. package/llms/tools.txt +6 -4
  404. package/llms/upgrading-0.37.0-0.50.0.txt +947 -0
  405. package/llms/{upgrading-0.44.0-0.61.0.txt → upgrading-0.53.0-0.67.0.txt} +576 -506
  406. package/llms/{upgrading-0.62.0-0.80.0.txt → upgrading-0.68.0-0.94.0.txt} +562 -576
  407. package/llms/{upgrading-0.81.0-0.104.0.txt → upgrading-0.95.0-0.105.0.txt} +452 -567
  408. package/llms/upgrading.txt +4 -4
  409. package/llms-full.txt +1068 -412
  410. package/llms.txt +24 -24
  411. package/native-assets.json +11 -3
  412. package/package.json +6 -6
  413. package/dist/agent-runtime/harness-tools.d.ts +0 -11
  414. package/dist/agent-runtime/harness-tools.d.ts.map +0 -1
  415. package/dist/entrypoints/agent-runtime/harness-tools.d.ts +0 -2
  416. package/dist/entrypoints/agent-runtime/harness-tools.d.ts.map +0 -1
  417. package/dist/entrypoints/agent-runtime/harness-tools.js +0 -32
  418. package/dist/index-1a6jtnd9.js +0 -88
  419. package/dist/index-8a9ksm91.js +0 -95
  420. package/dist/index-a3wma1hk.js +0 -48
  421. package/dist/index-jd470k6q.js +0 -109
  422. package/dist/index-n1dqr7gf.js +0 -20
  423. package/dist/index-nggfa2yn.js +0 -34
  424. package/dist/index-s4evrmp5.js +0 -98
  425. package/dist/index-ze1eph1k.js +0 -20
  426. package/dist/tools/connections/error-projection.d.ts +0 -4
  427. package/dist/tools/connections/error-projection.d.ts.map +0 -1
  428. package/dist/tools/runtime-tool-execution.d.ts.map +0 -1
  429. package/llms/agent-runtime-harness-tools.txt +0 -25
  430. package/llms/upgrading-0.37.0-0.44.0.txt +0 -444
@@ -2,22 +2,29 @@ import {
2
2
  ManagedFilePathSchema2,
3
3
  ManagedFileRefSchema2
4
4
  } from "./index-xqhede6x.js";
5
+ import {
6
+ raceAbort
7
+ } from "./index-b0kddvzw.js";
5
8
  import {
6
9
  BoundedFileReadError,
7
10
  readBoundedFile
8
- } from "./index-jd470k6q.js";
11
+ } from "./index-m616f0yz.js";
9
12
  import {
10
13
  isWithinDir2
11
14
  } from "./index-5cc6r990.js";
12
15
  import {
13
- AtomicFilePublicationError2,
14
- publishAtomicFile
15
- } from "./index-8a9ksm91.js";
16
+ writeAllBytes,
17
+ writeAtomicFileStaged
18
+ } from "./index-cazts87s.js";
19
+ import {
20
+ AtomicFilePublicationError2
21
+ } from "./index-b56nnscm.js";
22
+ import {
23
+ assertPositiveSafeInteger
24
+ } from "./index-0s4xebbg.js";
16
25
 
17
26
  // src/files/boundary.ts
18
- import { randomUUID } from "node:crypto";
19
- import { constants } from "node:fs";
20
- import { mkdir, open as open2, realpath, stat, unlink } from "node:fs/promises";
27
+ import { mkdir, realpath, stat } from "node:fs/promises";
21
28
  import { basename as basename2, dirname, resolve } from "node:path";
22
29
 
23
30
  // src/files/file-io.ts
@@ -25,27 +32,6 @@ var ManagedFileInspectionSchema = ManagedFileRefSchema2.pick({
25
32
  mediaType: true,
26
33
  name: true
27
34
  });
28
- function abortReason(signal) {
29
- return signal.reason ?? new DOMException("The operation was aborted", "AbortError");
30
- }
31
- function raceWithSignal(operation, signal) {
32
- signal.throwIfAborted();
33
- return new Promise((resolvePromise, rejectPromise) => {
34
- let settled = false;
35
- const settle = (complete) => {
36
- if (settled)
37
- return;
38
- settled = true;
39
- signal.removeEventListener("abort", onAbort);
40
- complete();
41
- };
42
- const onAbort = () => settle(() => rejectPromise(abortReason(signal)));
43
- signal.addEventListener("abort", onAbort, { once: true });
44
- if (signal.aborted)
45
- onAbort();
46
- operation.then((value) => settle(() => resolvePromise(value)), (error) => settle(() => rejectPromise(error)));
47
- });
48
- }
49
35
  async function inspectFile(inspector, input, timeoutMs, outerSignal) {
50
36
  if (!inspector)
51
37
  return {};
@@ -53,11 +39,11 @@ async function inspectFile(inspector, input, timeoutMs, outerSignal) {
53
39
  const timeoutSignal = AbortSignal.timeout(timeoutMs);
54
40
  const signal = outerSignal ? AbortSignal.any([outerSignal, timeoutSignal]) : timeoutSignal;
55
41
  try {
56
- const inspected = await raceWithSignal(Promise.resolve().then(() => inspector({ ...input, signal })), signal);
42
+ const inspected = await raceAbort(Promise.resolve().then(() => inspector({ ...input, signal })), signal);
57
43
  return ManagedFileInspectionSchema.parse(inspected);
58
44
  } catch (error) {
59
45
  if (outerSignal?.aborted)
60
- throw abortReason(outerSignal);
46
+ throw outerSignal.reason;
61
47
  throw new ManagedFileError2("FILE_INSPECTION_REJECTED", "managed file rejected by inspection", { cause: error });
62
48
  }
63
49
  }
@@ -75,16 +61,7 @@ function inspectedRef(path, size, inspection, fallback = {}) {
75
61
  }
76
62
  return parsed.data;
77
63
  }
78
- async function writeChunk(handle, chunk) {
79
- let offset = 0;
80
- while (offset < chunk.byteLength) {
81
- const { bytesWritten } = await handle.write(chunk, offset, chunk.byteLength - offset);
82
- if (bytesWritten === 0)
83
- throw new Error("zero-byte managed-file write");
84
- offset += bytesWritten;
85
- }
86
- }
87
- async function writeSource(handle, source, maxBytes, inspectionBytes, signal) {
64
+ async function writeSource(file, source, maxBytes, inspectionBytes, signal) {
88
65
  let size = 0;
89
66
  const prefixChunks = [];
90
67
  let prefixSize = 0;
@@ -99,7 +76,7 @@ async function writeSource(handle, source, maxBytes, inspectionBytes, signal) {
99
76
  prefixChunks.push(kept);
100
77
  prefixSize += kept.byteLength;
101
78
  }
102
- await writeChunk(handle, chunk);
79
+ await writeAllBytes(file, chunk);
103
80
  };
104
81
  if (source instanceof Uint8Array) {
105
82
  await consume(source);
@@ -157,11 +134,6 @@ async function readManagedDescriptor(target, path, maxBytes, options, inspection
157
134
  var DEFAULT_MAX_BYTES = 100 * 1024 * 1024;
158
135
  var DEFAULT_INSPECTION_BYTES = 64 * 1024;
159
136
  var DEFAULT_INSPECTION_TIMEOUT_MS = 15000;
160
- var nofollowFlag;
161
- var noFollow = () => {
162
- nofollowFlag ??= constants.O_NOFOLLOW ?? 0;
163
- return nofollowFlag;
164
- };
165
137
 
166
138
  class ManagedFileError2 extends Error {
167
139
  code;
@@ -173,9 +145,7 @@ class ManagedFileError2 extends Error {
173
145
  }
174
146
  function positiveLimit(value, fallback, name) {
175
147
  const resolved = value ?? fallback;
176
- if (!Number.isSafeInteger(resolved) || resolved <= 0) {
177
- throw new TypeError(`${name} must be a positive safe integer`);
178
- }
148
+ assertPositiveSafeInteger(name, resolved);
179
149
  return resolved;
180
150
  }
181
151
  function filePath(path) {
@@ -311,37 +281,24 @@ async function createManagedFileBoundary2(config) {
311
281
  const resolved = targetFor(path);
312
282
  const parent = await existingParent(root, resolved.target);
313
283
  const maxBytes = positiveLimit(options.maxBytes, maxWriteBytes, "maxBytes");
314
- const temporary = resolve(parent, `.stitchkit-${randomUUID()}.tmp`);
315
- let handle;
316
- let committed = false;
317
- let size = 0;
318
284
  try {
319
- handle = await open2(temporary, constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY | noFollow(), 384);
320
- const written = await writeSource(handle, source, maxBytes, inspectionBytes, options.signal);
321
- size = written.size;
322
- if (options.durable)
323
- await handle.sync();
324
- await handle.close();
325
- handle = undefined;
326
- const inspection = await inspectFile(config.inspect, {
327
- prefix: written.prefix,
328
- ...options.mediaType ? { declaredMediaType: options.mediaType } : {},
329
- name: options.name ?? basename2(resolved.path)
330
- }, inspectionTimeoutMs, options.signal);
331
- options.signal?.throwIfAborted();
332
- try {
333
- await publishAtomicFile(temporary, resolved.target, options.replace ?? false, options.durable ?? false);
334
- committed = true;
335
- } catch (error) {
336
- if (error instanceof AtomicFilePublicationError2) {
337
- committed = true;
338
- throw error;
339
- }
340
- if (errorCode(error) === "EEXIST")
341
- throw new ManagedFileError2("FILE_EXISTS", "managed file already exists");
342
- throw error;
343
- }
344
- return inspectedRef(resolved.path, size, inspection, {
285
+ const staged = await writeAtomicFileStaged(resolve(parent, basename2(resolved.target)), {
286
+ async fill(file) {
287
+ const written = await writeSource(file, source, maxBytes, inspectionBytes, options.signal);
288
+ const inspection = await inspectFile(config.inspect, {
289
+ prefix: written.prefix,
290
+ ...options.mediaType ? { declaredMediaType: options.mediaType } : {},
291
+ name: options.name ?? basename2(resolved.path)
292
+ }, inspectionTimeoutMs, options.signal);
293
+ options.signal?.throwIfAborted();
294
+ return { size: written.size, inspection };
295
+ },
296
+ onCleanupError: config.onCleanupError
297
+ }, {
298
+ replace: options.replace ?? false,
299
+ durability: options.durable ? "directory" : "none"
300
+ });
301
+ return inspectedRef(resolved.path, staged.size, staged.inspection, {
345
302
  mediaType: options.mediaType,
346
303
  name: options.name
347
304
  });
@@ -350,17 +307,9 @@ async function createManagedFileBoundary2(config) {
350
307
  throw error;
351
308
  if (options.signal?.aborted && error === options.signal.reason)
352
309
  throw error;
310
+ if (errorCode(error) === "EEXIST")
311
+ throw new ManagedFileError2("FILE_EXISTS", "managed file already exists");
353
312
  throw ioError("failed to write managed file", error);
354
- } finally {
355
- await handle?.close().catch(() => {
356
- return;
357
- });
358
- if (!options.replace || !committed) {
359
- await unlink(temporary).catch((error) => {
360
- if (errorCode(error) !== "ENOENT")
361
- config.onCleanupError?.(error);
362
- });
363
- }
364
313
  }
365
314
  }
366
315
  };
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  isRetryableStatus2
3
- } from "./index-x928baz2.js";
3
+ } from "./index-j9gxbztg.js";
4
4
  import {
5
5
  rebuildObject,
6
6
  mergeSchemas,
7
7
  assertToolExtensionCompatible,
8
8
  projectToolSurface
9
- } from "./index-77nxk6ay.js";
9
+ } from "./index-r393tnfp.js";
10
10
  import {
11
11
  toolErrorFromResult,
12
12
  executeToolMethod
13
- } from "./index-2vnh05w4.js";
13
+ } from "./index-2k91mewf.js";
14
14
 
15
15
  // src/tools/mount.ts
16
16
  import { z } from "zod";
@@ -2,7 +2,7 @@ import {
2
2
  AppError2,
3
3
  badRequest2,
4
4
  forbidden2
5
- } from "./index-x928baz2.js";
5
+ } from "./index-j9gxbztg.js";
6
6
  import {
7
7
  isStreamCancellation,
8
8
  ownHttpStream,
@@ -14,7 +14,7 @@ import {
14
14
  recordedErrorMessage,
15
15
  normalizeError2,
16
16
  validateDeclaredOutput
17
- } from "./index-kb8styz3.js";
17
+ } from "./index-rpzewktb.js";
18
18
  import {
19
19
  resolveTraceContext2
20
20
  } from "./index-yex7eg1v.js";
@@ -34,7 +34,10 @@ import {
34
34
  import {
35
35
  bindContract,
36
36
  mediaTypeEssence
37
- } from "./index-g2j7pnak.js";
37
+ } from "./index-cmzvhhtd.js";
38
+ import {
39
+ assertPositiveSafeInteger
40
+ } from "./index-0s4xebbg.js";
38
41
  import {
39
42
  assertCorsConfig,
40
43
  isOriginAllowed,
@@ -900,16 +903,11 @@ function throwIfRequestAborted(req) {
900
903
  if (req.signal.aborted)
901
904
  throw requestAbortReason(req);
902
905
  }
903
- function assertJsonBodyLimit(maxBytes, owner) {
904
- if (maxBytes !== undefined && (!Number.isSafeInteger(maxBytes) || maxBytes <= 0)) {
905
- throw new Error(`${owner} must be a positive safe integer, received ${maxBytes}`);
906
- }
907
- }
908
906
  async function readRequestText(req, maxBytes) {
909
907
  throwIfRequestAborted(req);
910
908
  if (maxBytes === undefined)
911
909
  return req.text();
912
- assertJsonBodyLimit(maxBytes, "maxJsonBodyBytes");
910
+ assertPositiveSafeInteger("maxJsonBodyBytes", maxBytes, Error);
913
911
  const reader = req.body?.getReader();
914
912
  if (!reader)
915
913
  return "";
@@ -1117,7 +1115,10 @@ function contractStreamResponse(request, context, source, descriptor, operationA
1117
1115
  const parsed = descriptor.item.safeParse(next.value);
1118
1116
  if (!parsed.success) {
1119
1117
  console.error("[stitchkit] contract stream item failed validation:", parsed.error);
1120
- throw new AppError2("STREAM_ITEM_INVALID", "Stream item did not match its contract", 500);
1118
+ throw new AppError2("STREAM_ITEM_INVALID", {
1119
+ message: "Stream item did not match its contract",
1120
+ status: 500
1121
+ });
1121
1122
  }
1122
1123
  const item = parsed.data;
1123
1124
  const terminal = descriptor.terminal?.safeParse(item).success ?? false;
@@ -1126,14 +1127,20 @@ function contractStreamResponse(request, context, source, descriptor, operationA
1126
1127
  const frame = descriptor.framing === "item" ? item : { type: "data", data: item };
1127
1128
  if (encodedBytes(frame, format) > maxFrameBytes) {
1128
1129
  console.error(`[stitchkit] contract stream frame exceeded its ${maxFrameBytes} byte limit`);
1129
- throw new AppError2("STREAM_FRAME_TOO_LARGE", "Stream item exceeded its declared frame limit", 500);
1130
+ throw new AppError2("STREAM_FRAME_TOO_LARGE", {
1131
+ message: "Stream item exceeded its declared frame limit",
1132
+ status: 500
1133
+ });
1130
1134
  }
1131
1135
  yield frame;
1132
1136
  if (terminal && descriptor.completion === "terminal")
1133
1137
  return;
1134
1138
  }
1135
1139
  if (!terminalSeen) {
1136
- throw new AppError2("STREAM_TERMINAL_MISSING", "Stream completed before its declared terminal item", 500);
1140
+ throw new AppError2("STREAM_TERMINAL_MISSING", {
1141
+ message: "Stream completed before its declared terminal item",
1142
+ status: 500
1143
+ });
1137
1144
  }
1138
1145
  if (descriptor.framing !== "item")
1139
1146
  yield { type: "end" };
@@ -1145,7 +1152,10 @@ function contractStreamResponse(request, context, source, descriptor, operationA
1145
1152
  return;
1146
1153
  yield {
1147
1154
  type: "error",
1148
- error: new AppError2("STREAM_LIFETIME_EXCEEDED", "Stream exceeded its declared lifetime", 408).toJSON().error
1155
+ error: new AppError2("STREAM_LIFETIME_EXCEEDED", {
1156
+ message: "Stream exceeded its declared lifetime",
1157
+ status: 408
1158
+ }).toJSON().error
1149
1159
  };
1150
1160
  return;
1151
1161
  }
@@ -1221,7 +1231,10 @@ async function endpointResponse(state, request, outcome) {
1221
1231
  }
1222
1232
  function rawEndpointResponse(state, request, { match: { method }, result }) {
1223
1233
  if (!(result instanceof Response)) {
1224
- throw new AppError2("INTERNAL_SERVER_ERROR", `Raw endpoint ${method.serviceName}.${method.key} must return a Response`, 500);
1234
+ throw new AppError2("INTERNAL_SERVER_ERROR", {
1235
+ message: `Raw endpoint ${method.serviceName}.${method.key} must return a Response`,
1236
+ status: 500
1237
+ });
1225
1238
  }
1226
1239
  const response = method.method === "HEAD" ? new Response(null, {
1227
1240
  status: result.status,
@@ -1236,7 +1249,10 @@ async function streamEndpointResponse(state, request, { match: { method, pathPar
1236
1249
  const { req, server, clientIp } = request;
1237
1250
  if (!method.stream || !streamAbort || !isAsyncIterable(result)) {
1238
1251
  streamAbort?.abort();
1239
- throw new AppError2("INTERNAL_SERVER_ERROR", `Streaming endpoint ${method.serviceName}.${method.key} must return an AsyncIterable`, 500);
1252
+ throw new AppError2("INTERNAL_SERVER_ERROR", {
1253
+ message: `Streaming endpoint ${method.serviceName}.${method.key} must return an AsyncIterable`,
1254
+ status: 500
1255
+ });
1240
1256
  }
1241
1257
  const response = await contractStreamResponse(req, { params: pathParams, server, ipAddress: clientIp.socketIp }, result, method.stream, streamAbort);
1242
1258
  const withCors = applyCors(response, state.cors, req);
@@ -1263,18 +1279,24 @@ async function dataEndpointResponse(state, request, {
1263
1279
  result = transformed;
1264
1280
  }
1265
1281
  if (result instanceof Response) {
1266
- throw new AppError2("INTERNAL_SERVER_ERROR", `${method.serviceName}.${method.key} produced a Response on the data path — only a \`rawResponse: true\` endpoint may return one (an afterHandle hook must return data)`, 500);
1282
+ throw new AppError2("INTERNAL_SERVER_ERROR", {
1283
+ message: `${method.serviceName}.${method.key} produced a Response on the data path — only a \`rawResponse: true\` endpoint may return one (an afterHandle hook must return data)`,
1284
+ status: 500
1285
+ });
1267
1286
  }
1268
1287
  const checked = validateDeclaredOutput(method.outputSchema, result, config.warnOnOutputStrip && method.outputSchema ? (paths) => {
1269
1288
  warn(`[stitchkit] output strip ${method.serviceName}.${method.key}: ${paths.join(", ")}`);
1270
1289
  } : undefined);
1271
1290
  if (!checked.ok) {
1272
- throw new AppError2("INTERNAL_SERVER_ERROR", checked.message, 500);
1291
+ throw new AppError2("INTERNAL_SERVER_ERROR", { message: checked.message, status: 500 });
1273
1292
  }
1274
1293
  result = checked.data;
1275
1294
  const responseStatus = method.responseMeta?.status ?? (method.outputSchema ? 200 : 204);
1276
1295
  if (method.outputSchema && (responseStatus === 204 || responseStatus === 205)) {
1277
- throw new AppError2("INTERNAL_SERVER_ERROR", `${method.serviceName}.${method.key} cannot combine output with bodyless status ${responseStatus}`, 500);
1296
+ throw new AppError2("INTERNAL_SERVER_ERROR", {
1297
+ message: `${method.serviceName}.${method.key} cannot combine output with bodyless status ${responseStatus}`,
1298
+ status: 500
1299
+ });
1278
1300
  }
1279
1301
  const responseHeaders = new Headers(requestCorsHeaders(cors, req));
1280
1302
  applyResponseMetadata(responseHeaders, responseMetadata, `${method.serviceName}.${method.key}`);
@@ -1784,7 +1806,7 @@ function createHandlerState(config) {
1784
1806
  const { cors, hooks, logging = false, observability } = config;
1785
1807
  if (cors)
1786
1808
  assertCorsConfig(cors);
1787
- assertJsonBodyLimit(config.maxJsonBodyBytes, "HandlerConfig.maxJsonBodyBytes");
1809
+ assertPositiveSafeInteger("HandlerConfig.maxJsonBodyBytes", config.maxJsonBodyBytes, Error);
1788
1810
  const logConfig = resolveLoggingConfig(logging);
1789
1811
  const customLogger = logConfig?.logger ?? null;
1790
1812
  const useDefaultLog = logConfig !== null && !logConfig.logger;
@@ -2151,11 +2173,14 @@ async function dispatch(state, req, url, traceId, server, clientIp, startedAt) {
2151
2173
  if (!match) {
2152
2174
  const allow = allowedMethods(routeMap, url.pathname);
2153
2175
  if (allow.length > 0) {
2154
- const res = await respondError(new AppError2("METHOD_NOT_ALLOWED", `Method ${req.method} not allowed`, 405));
2176
+ const res = await respondError(new AppError2("METHOD_NOT_ALLOWED", {
2177
+ message: `Method ${req.method} not allowed`,
2178
+ status: 405
2179
+ }));
2155
2180
  res.headers.set("Allow", allow.join(", "));
2156
2181
  return res;
2157
2182
  }
2158
- return respondError(new AppError2("NOT_FOUND", "Not found", 404));
2183
+ return respondError(new AppError2("NOT_FOUND", { message: "Not found", status: 404 }));
2159
2184
  }
2160
2185
  return dispatchEndpoint(state, request, match);
2161
2186
  }
@@ -3175,9 +3200,7 @@ var DEFAULT_MAX_REDIRECTS = 5;
3175
3200
  var DEFAULT_MAX_HEADER_BYTES2 = 64 * 1024;
3176
3201
  function positiveInteger(value, fallback, name) {
3177
3202
  const resolved = value ?? fallback;
3178
- if (!Number.isSafeInteger(resolved) || resolved <= 0) {
3179
- throw new TypeError(`${name} must be a positive safe integer`);
3180
- }
3203
+ assertPositiveSafeInteger(name, resolved);
3181
3204
  return resolved;
3182
3205
  }
3183
3206
  function nonNegativeInteger(value, fallback, name) {
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  defineContract2
3
- } from "./index-ck71tbcf.js";
3
+ } from "./index-fsw1ybf3.js";
4
4
  import {
5
5
  AppError2,
6
6
  STITCH_ERROR_STATUS2,
7
7
  isStitchErrorCode2
8
- } from "./index-x928baz2.js";
8
+ } from "./index-j9gxbztg.js";
9
9
  import {
10
10
  bytesToBase64Url,
11
11
  base64UrlToBytes
@@ -46,10 +46,21 @@ function defineErrors2(source, mapping) {
46
46
  if ("details" in options) {
47
47
  throw new Error(`[stitchkit] Error "${name}" does not declare details`);
48
48
  }
49
- return new AppError2(name, message, definition.status, undefined, options.hint, undefined, definition.retryable);
49
+ return new AppError2(name, {
50
+ message,
51
+ status: definition.status,
52
+ hint: options.hint,
53
+ retryable: definition.retryable
54
+ });
50
55
  }
51
56
  const details = definition.details.parse(options.details);
52
- return new AppError2(name, message, definition.status, details, options.hint, undefined, definition.retryable);
57
+ return new AppError2(name, {
58
+ message,
59
+ status: definition.status,
60
+ details,
61
+ hint: options.hint,
62
+ retryable: definition.retryable
63
+ });
53
64
  };
54
65
  });
55
66
  Object.freeze(errors);
@@ -1,23 +1,25 @@
1
1
  import {
2
2
  forbidden2,
3
3
  conflict2
4
- } from "./index-x928baz2.js";
4
+ } from "./index-j9gxbztg.js";
5
5
  import {
6
6
  loadDarwinBinding
7
7
  } from "./index-v5ee8ath.js";
8
+ import {
9
+ stagingName
10
+ } from "./index-j4zh647a.js";
8
11
  import {
9
12
  NativeCommandError2,
10
- stopCommandGroup,
11
- ownsCommandGroup,
13
+ CommandStopped,
12
14
  startNativeCommand
13
- } from "./index-f330qqyg.js";
15
+ } from "./index-5c26631f.js";
14
16
  import {
15
- probeAgentProcessSandbox2,
17
+ probeAgentProcessSandboxOutcome,
16
18
  missingSandboxRestrictions2,
17
19
  codingRefusal,
18
20
  codingPathRefusal,
19
21
  refuseMissingCodingPath
20
- } from "./index-6d9xaxw1.js";
22
+ } from "./index-8ks9b85e.js";
21
23
  import {
22
24
  NumericFileHandle,
23
25
  descriptorPath,
@@ -34,7 +36,7 @@ import {
34
36
  } from "./index-gxm9rc97.js";
35
37
  import {
36
38
  defineRuntimeTool2
37
- } from "./index-cvda079a.js";
39
+ } from "./index-yvfk3y36.js";
38
40
 
39
41
  // src/agent-runtime/coding-tool-contract.ts
40
42
  import { z } from "zod";
@@ -390,7 +392,7 @@ async function writeContainedFile(input) {
390
392
  await writeFile(path2.join(descriptorPath(input.parent.handle), input.parent.basename), input.content, { flag: "wx", mode });
391
393
  return;
392
394
  }
393
- const temporary = `.${input.parent.basename}.${process.pid}.${crypto.randomUUID()}.tmp`;
395
+ const temporary = stagingName();
394
396
  if (process.platform === "darwin") {
395
397
  const binding = loadDarwinBinding();
396
398
  let created = false;
@@ -1067,15 +1069,14 @@ async function runCodingShell(input) {
1067
1069
  env: { ...input.environment },
1068
1070
  envPolicy: "declared-only",
1069
1071
  signal: input.signal ?? new AbortController().signal,
1070
- killGraceMs: 0,
1072
+ stop: { target: "group", graceMs: 0 },
1073
+ descendants: "terminate-after-leader",
1071
1074
  onOutput: (bytes, channel) => retain(channel === "stdout" ? stdout : stderr, channel === "stdout" ? artifactStdout : artifactStderr, bytes),
1072
- onLeaderSettled: async (event) => {
1075
+ onLeaderSettled: (event) => {
1073
1076
  if (event.kind !== "exit")
1074
1077
  return;
1075
1078
  exitCode = event.exitCode;
1076
1079
  signal = event.signal;
1077
- if (process.platform !== "win32" && child && ownsCommandGroup(child))
1078
- await stopCommandGroup(child?.pid, 0, input.terminationGraceMs, true);
1079
1080
  }
1080
1081
  }, (started) => {
1081
1082
  child = started;
@@ -1104,7 +1105,7 @@ async function runCodingShell(input) {
1104
1105
  outcome = "cancelled";
1105
1106
  else if (error instanceof NativeCommandError2 && error.code === "COMMAND_LIMIT" && (error.reason === "deadline" || error.reason === "output-budget"))
1106
1107
  outcome = error.reason === "deadline" ? "timeout" : "output-limit";
1107
- else if (error instanceof DOMException && error.name === "AbortError" && error.message === "Command stopped")
1108
+ else if (error instanceof CommandStopped)
1108
1109
  outcome = "cancelled";
1109
1110
  else
1110
1111
  throw error;
@@ -1182,10 +1183,12 @@ function createShellCodingTool(config, limits) {
1182
1183
  let executableArgs = input.args;
1183
1184
  let environment = config.environment ?? {};
1184
1185
  if (config.sandbox) {
1185
- const grade = await probeAgentProcessSandbox2(config.sandbox.adapter);
1186
+ const probed = await probeAgentProcessSandboxOutcome(config.sandbox.adapter);
1187
+ const grade = probed.grade;
1186
1188
  if (grade.grade === "unavailable") {
1187
1189
  codingRefusal("SANDBOX_UNAVAILABLE", "The configured process sandbox is unavailable", {
1188
- details: { reason: grade.reason }
1190
+ details: { reason: grade.reason },
1191
+ ...probed.cause !== undefined && { cause: probed.cause }
1189
1192
  });
1190
1193
  }
1191
1194
  const missing = missingSandboxRestrictions2(grade, config.sandbox.required);
@@ -1206,14 +1209,12 @@ function createShellCodingTool(config, limits) {
1206
1209
  executableArgs = [...prepared.args];
1207
1210
  environment = prepared.environment ?? environment;
1208
1211
  } catch (error) {
1209
- const refreshed = await probeAgentProcessSandbox2(config.sandbox.adapter, {
1212
+ const refreshed = await probeAgentProcessSandboxOutcome(config.sandbox.adapter, {
1210
1213
  refresh: true
1211
1214
  });
1212
1215
  codingRefusal("SANDBOX_UNAVAILABLE", "The process sandbox failed while preparing a command", {
1213
- details: {
1214
- grade: refreshed.grade,
1215
- reason: error instanceof Error ? error.message : "unknown sandbox error"
1216
- }
1216
+ details: { grade: refreshed.grade.grade, reason: "sandbox prepare failed" },
1217
+ cause: refreshed.cause === undefined ? error : new AggregateError([error, refreshed.cause], "Sandbox prepare failed and probing it again failed")
1217
1218
  });
1218
1219
  }
1219
1220
  }
@@ -9,7 +9,7 @@ import {
9
9
  AgentControlRequestSchema2,
10
10
  AgentControlResponseSchema2,
11
11
  AgentControlDeliverySchema2
12
- } from "./index-n5yqxd3d.js";
12
+ } from "./index-b0w7rbpt.js";
13
13
 
14
14
  // src/agent-runtime/browser-control-contract.ts
15
15
  import { z } from "zod";
@@ -1,6 +1,9 @@
1
1
  import {
2
2
  projectRuntimeTool
3
- } from "./index-77nxk6ay.js";
3
+ } from "./index-r393tnfp.js";
4
+ import {
5
+ isRecord
6
+ } from "./index-9jfdm5tg.js";
4
7
 
5
8
  // src/tools/runtime-tool.ts
6
9
  function defineRuntimeTool2(definition) {
@@ -52,6 +55,13 @@ function createRuntimeToolFactory2(config) {
52
55
  }
53
56
  return { define };
54
57
  }
58
+ function isAgentPresenter(value) {
59
+ return typeof value === "function";
60
+ }
61
+ function agentPresenterOf(definition) {
62
+ const { present } = definition;
63
+ return isRecord(present) && isAgentPresenter(present.agent) ? present.agent : undefined;
64
+ }
55
65
  function runtimeToolIdentity(definition) {
56
66
  return {
57
67
  method: definition.identity.method,
@@ -97,4 +107,4 @@ function executableAgentRuntimeTools(tools) {
97
107
  return tools;
98
108
  }
99
109
 
100
- export { defineRuntimeTool2, createRuntimeToolFactory2, runtimeToolMountable, executableAgentRuntimeTools };
110
+ export { defineRuntimeTool2, createRuntimeToolFactory2, agentPresenterOf, runtimeToolMountable, executableAgentRuntimeTools };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createValidatedRealtimeSocket
3
- } from "./index-43p08g7t.js";
3
+ } from "./index-pzb63z66.js";
4
4
 
5
5
  // src/server/realtime.ts
6
6
  function bindRealtimeServer2(contract, handle, options = {}) {
@@ -1,3 +1,9 @@
1
- /** Releases an await on cancellation without assuming a callback cooperates with its signal. */
2
- export declare function raceAbort<T>(operation: Promise<T>, signal: AbortSignal): Promise<T>;
1
+ /**
2
+ * Releases an await on cancellation without assuming a callback cooperates with its signal.
3
+ *
4
+ * When the signal wins and the operation settles later, a fulfilled value is handed to
5
+ * `disposeLate` so an owner can release what it would otherwise leak (a stream, a
6
+ * handle); a late rejection is swallowed because the caller already has the reason.
7
+ */
8
+ export declare function raceAbort<T>(operation: Promise<T>, signal: AbortSignal, disposeLate?: (value: T) => void): Promise<T>;
3
9
  //# sourceMappingURL=abort-race.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"abort-race.d.ts","sourceRoot":"","sources":["../../src/internal/abort-race.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,wBAAgB,SAAS,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAsBnF"}
1
+ {"version":3,"file":"abort-race.d.ts","sourceRoot":"","sources":["../../src/internal/abort-race.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,EACzB,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,EACrB,MAAM,EAAE,WAAW,EACnB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAC/B,OAAO,CAAC,CAAC,CAAC,CA+BZ"}