stitchkit 0.104.1 → 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 +381 -12
  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 +196 -56
  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 +104 -21
  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 +22 -7
  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 +305 -154
  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 +1053 -405
  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
@@ -1,23 +1,32 @@
1
+ import {
2
+ AppError2,
3
+ STITCH_ERROR_STATUS2,
4
+ isRetryableStatus2
5
+ } from "../../index-j9gxbztg.js";
6
+ import {
7
+ TOOL_ERROR_PROJECTION
8
+ } from "../../index-556g5hsh.js";
1
9
  import"../../index-ct75c3at.js";
2
10
  import {
3
11
  declaresDraft07,
4
12
  withDefsDialect
5
- } from "../../index-77nxk6ay.js";
13
+ } from "../../index-r393tnfp.js";
14
+ import"../../index-rpzewktb.js";
6
15
  import {
7
- AppError2
8
- } from "../../index-x928baz2.js";
9
- import"../../index-kb8styz3.js";
16
+ withSignalDeadline
17
+ } from "../../index-9tqbxv5p.js";
10
18
  import {
11
- defineRuntimeTool2
12
- } from "../../index-cvda079a.js";
19
+ raceAbort
20
+ } from "../../index-b0kddvzw.js";
13
21
  import {
14
- ConnectionAuthorizationRequiredError2,
15
- ConnectionRequestError2,
16
- ConnectionUrlError2,
17
- ConnectionBudgetExceededError2,
18
- ConnectionTimeoutError2,
19
- ConnectionResponseTooLargeError2
20
- } from "../../index-1a6jtnd9.js";
22
+ MAX_TIMER_MS
23
+ } from "../../index-eemvahkc.js";
24
+ import {
25
+ assertPositiveSafeInteger
26
+ } from "../../index-0s4xebbg.js";
27
+ import {
28
+ defineRuntimeTool2
29
+ } from "../../index-yvfk3y36.js";
21
30
  import {
22
31
  safeJsonParse
23
32
  } from "../../index-zsarb5xp.js";
@@ -25,10 +34,186 @@ import {
25
34
  isRecord
26
35
  } from "../../index-9jfdm5tg.js";
27
36
 
37
+ // src/tools/connections/errors.ts
38
+ class ConnectionAuthorizationRequiredError extends Error {
39
+ connectionName;
40
+ instanceId;
41
+ operation;
42
+ phase;
43
+ constructor(connectionName, instanceId, context = {}) {
44
+ super(`Connection "${connectionName}" requires authorization`);
45
+ this.name = "ConnectionAuthorizationRequiredError";
46
+ this.connectionName = connectionName;
47
+ this.instanceId = instanceId;
48
+ this.operation = context.operation ?? "request";
49
+ this.phase = context.phase ?? "call";
50
+ }
51
+ [TOOL_ERROR_PROJECTION]() {
52
+ const message = "Authorization required";
53
+ return new AppError2("UNAUTHORIZED", {
54
+ message,
55
+ status: STITCH_ERROR_STATUS2.UNAUTHORIZED,
56
+ details: {
57
+ message,
58
+ reason: "authorization-required",
59
+ operation: this.operation,
60
+ phase: this.phase
61
+ },
62
+ hint: "Obtain a new credential before retrying.",
63
+ retryable: false
64
+ });
65
+ }
66
+ }
67
+
68
+ class ConnectionRequestError extends Error {
69
+ connectionName;
70
+ status;
71
+ body;
72
+ operation;
73
+ phase;
74
+ constructor(connectionName, status, body, context = {}) {
75
+ super(`Connection "${connectionName}" request failed with status ${status}`);
76
+ this.name = "ConnectionRequestError";
77
+ this.connectionName = connectionName;
78
+ this.status = status;
79
+ this.body = body;
80
+ this.operation = context.operation ?? "request";
81
+ this.phase = context.phase ?? "call";
82
+ }
83
+ [TOOL_ERROR_PROJECTION]() {
84
+ const forbidden = this.status === 403;
85
+ const code = forbidden ? "FORBIDDEN" : "CONNECTION_REQUEST_FAILED";
86
+ const message = forbidden ? "Connection access denied" : "Connection request failed";
87
+ return new AppError2(code, {
88
+ message,
89
+ status: STITCH_ERROR_STATUS2[code],
90
+ details: {
91
+ message,
92
+ reason: forbidden ? "permission-denied" : "upstream-request-failed",
93
+ operation: this.operation,
94
+ phase: this.phase,
95
+ upstreamStatus: this.status
96
+ },
97
+ hint: forbidden ? "Check the credential permissions." : "Check the upstream service and verify any write outcome before retrying.",
98
+ retryable: !forbidden && isRetryableStatus2(this.status)
99
+ });
100
+ }
101
+ }
102
+
103
+ class ConnectionUrlError extends Error {
104
+ url;
105
+ constructor(message, url) {
106
+ super(message);
107
+ this.name = "ConnectionUrlError";
108
+ this.url = url;
109
+ }
110
+ [TOOL_ERROR_PROJECTION]() {
111
+ return new AppError2("BAD_REQUEST", {
112
+ message: "Connection URL refused",
113
+ status: STITCH_ERROR_STATUS2.BAD_REQUEST,
114
+ details: { message: "Connection URL refused", reason: "url-rejected" },
115
+ hint: "Check the connection URL and its allowed hosts.",
116
+ retryable: false
117
+ });
118
+ }
119
+ }
120
+
121
+ class ConnectionBudgetExceededError extends Error {
122
+ limit;
123
+ actual;
124
+ constructor(limit, actual, unit = "tools") {
125
+ super(`Connection surface exposes ${actual} ${unit}, above the budget of ${limit}`);
126
+ this.name = "ConnectionBudgetExceededError";
127
+ this.limit = limit;
128
+ this.actual = actual;
129
+ }
130
+ [TOOL_ERROR_PROJECTION]() {
131
+ return new AppError2("BAD_REQUEST", {
132
+ message: "Connection mount budget exceeded",
133
+ status: STITCH_ERROR_STATUS2.BAD_REQUEST,
134
+ details: {
135
+ message: "Connection mount budget exceeded",
136
+ reason: "mount-budget-exceeded",
137
+ limit: this.limit,
138
+ actual: this.actual
139
+ },
140
+ hint: "Narrow the mounted tool surface or increase its mount budget.",
141
+ retryable: false
142
+ });
143
+ }
144
+ }
145
+
146
+ class ConnectionTimeoutError extends Error {
147
+ connectionName;
148
+ timeoutMs;
149
+ operation;
150
+ phase;
151
+ observedReadBytes;
152
+ constructor(connectionName, timeoutMs, context = {}) {
153
+ super(`Connection "${connectionName}" timed out after ${timeoutMs} ms`);
154
+ this.name = "ConnectionTimeoutError";
155
+ this.connectionName = connectionName;
156
+ this.timeoutMs = timeoutMs;
157
+ this.operation = context.operation ?? "request";
158
+ this.phase = context.phase ?? "call";
159
+ this.observedReadBytes = context.observedReadBytes ?? 0;
160
+ }
161
+ [TOOL_ERROR_PROJECTION]() {
162
+ const message = "Connection deadline exceeded";
163
+ return new AppError2("CONNECTION_TIMEOUT", {
164
+ message,
165
+ status: STITCH_ERROR_STATUS2.CONNECTION_TIMEOUT,
166
+ details: {
167
+ message,
168
+ reason: "deadline-exceeded",
169
+ operation: this.operation,
170
+ phase: this.phase,
171
+ timeoutMs: this.timeoutMs,
172
+ observedReadBytes: this.observedReadBytes
173
+ },
174
+ hint: "Check the connection deadline and verify any write outcome before retrying.",
175
+ retryable: false
176
+ });
177
+ }
178
+ }
179
+
180
+ class ConnectionResponseTooLargeError extends Error {
181
+ connectionName;
182
+ maxBytes;
183
+ operation;
184
+ phase;
185
+ observedReadBytes;
186
+ constructor(connectionName, maxBytes, context = {}) {
187
+ super(`Connection "${connectionName}" response exceeded the ${maxBytes} byte limit`);
188
+ this.name = "ConnectionResponseTooLargeError";
189
+ this.connectionName = connectionName;
190
+ this.maxBytes = maxBytes;
191
+ this.operation = context.operation ?? "request";
192
+ this.phase = context.phase ?? "call";
193
+ this.observedReadBytes = context.observedReadBytes ?? 0;
194
+ }
195
+ [TOOL_ERROR_PROJECTION]() {
196
+ const message = "Connection response exceeds the byte limit";
197
+ return new AppError2("CONNECTION_RESPONSE_TOO_LARGE", {
198
+ message,
199
+ status: STITCH_ERROR_STATUS2.CONNECTION_RESPONSE_TOO_LARGE,
200
+ details: {
201
+ message,
202
+ reason: "response-too-large",
203
+ operation: this.operation,
204
+ phase: this.phase,
205
+ maxResponseBytes: this.maxBytes,
206
+ observedReadBytes: this.observedReadBytes
207
+ },
208
+ hint: "Narrow the response or increase the limit for this operation phase.",
209
+ retryable: false
210
+ });
211
+ }
212
+ }
213
+
28
214
  // src/tools/connections/limits.ts
29
215
  var DEFAULT_CONNECTION_TIMEOUT_MS = 30000;
30
216
  var DEFAULT_MAX_RESPONSE_BYTES = 1024 * 1024;
31
- var MAX_TIMER_MS = 2147483647;
32
217
  function connectionTimeoutMs(value) {
33
218
  if (value === undefined)
34
219
  return DEFAULT_CONNECTION_TIMEOUT_MS;
@@ -40,55 +225,19 @@ function connectionTimeoutMs(value) {
40
225
  function connectionMaxResponseBytes(value) {
41
226
  if (value === undefined)
42
227
  return DEFAULT_MAX_RESPONSE_BYTES;
43
- if (!Number.isSafeInteger(value) || value <= 0) {
44
- throw new RangeError("Connection maxResponseBytes must be a positive safe integer");
45
- }
228
+ assertPositiveSafeInteger("Connection maxResponseBytes", value, RangeError);
46
229
  return value;
47
230
  }
48
- async function awaitConnection(pending, signal) {
49
- if (!signal)
50
- return pending;
51
- if (signal.aborted) {
52
- pending.catch(() => {
53
- return;
54
- });
55
- signal.throwIfAborted();
56
- }
57
- const aborted = Promise.withResolvers();
58
- const onAbort = () => aborted.reject(signal.reason);
59
- signal.addEventListener("abort", onAbort, { once: true });
60
- try {
61
- signal.throwIfAborted();
62
- const result = await Promise.race([pending, aborted.promise]);
63
- signal.throwIfAborted();
64
- return result;
65
- } catch (error) {
66
- signal.throwIfAborted();
67
- throw error;
68
- } finally {
69
- signal.removeEventListener("abort", onAbort);
70
- }
231
+ function awaitConnection(pending, signal) {
232
+ return signal ? raceAbort(pending, signal) : pending;
71
233
  }
72
- async function withConnectionDeadline(connectionName, timeoutMs, callerSignal, body, context) {
73
- connectionTimeoutMs(timeoutMs);
74
- const controller = new AbortController;
75
- const timer = setTimeout(() => controller.abort(new ConnectionTimeoutError2(connectionName, timeoutMs, context)), timeoutMs);
76
- const onAbort = () => controller.abort(callerSignal?.reason);
77
- if (callerSignal) {
78
- if (callerSignal.aborted)
79
- controller.abort(callerSignal.reason);
80
- else
81
- callerSignal.addEventListener("abort", onAbort, { once: true });
82
- }
83
- if (context)
84
- context.signal = controller.signal;
85
- try {
86
- controller.signal.throwIfAborted();
87
- return await awaitConnection(body(controller.signal), controller.signal);
88
- } finally {
89
- clearTimeout(timer);
90
- callerSignal?.removeEventListener("abort", onAbort);
91
- }
234
+ function withConnectionDeadline(connectionName, context, callerSignal, body) {
235
+ const timeoutMs = connectionTimeoutMs(context.timeoutMs);
236
+ let scoped = context;
237
+ return withSignalDeadline(timeoutMs, callerSignal, () => new ConnectionTimeoutError(connectionName, timeoutMs, scoped), (signal) => {
238
+ scoped = { ...context, signal };
239
+ return raceAbort(body(scoped), signal);
240
+ });
92
241
  }
93
242
  async function readBoundedText(response, maxBytes, connectionName, context) {
94
243
  context?.signal?.throwIfAborted();
@@ -111,7 +260,7 @@ async function readBoundedText(response, maxBytes, connectionName, context) {
111
260
  if (context)
112
261
  context.observedReadBytes += value.byteLength;
113
262
  if (total > maxBytes) {
114
- throw new ConnectionResponseTooLargeError2(connectionName, maxBytes, {
263
+ throw new ConnectionResponseTooLargeError(connectionName, maxBytes, {
115
264
  ...context,
116
265
  observedReadBytes: total
117
266
  });
@@ -134,7 +283,7 @@ async function readConnectionErrorText(response, connectionName, context) {
134
283
  return (await readBoundedText(response, context.maxResponseBytes, connectionName, context)).slice(0, 512);
135
284
  } catch (error) {
136
285
  context.signal?.throwIfAborted();
137
- if (error instanceof ConnectionResponseTooLargeError2 || error instanceof ConnectionTimeoutError2) {
286
+ if (error instanceof ConnectionResponseTooLargeError || error instanceof ConnectionTimeoutError) {
138
287
  throw error;
139
288
  }
140
289
  return "";
@@ -178,10 +327,10 @@ function assertConnectionUrl(rawUrl, connectionName) {
178
327
  try {
179
328
  url = new URL(rawUrl);
180
329
  } catch {
181
- throw new ConnectionUrlError2(`Connection "${connectionName}" has an unparseable URL: ${rawUrl}`, rawUrl);
330
+ throw new ConnectionUrlError(`Connection "${connectionName}" has an unparseable URL: ${rawUrl}`, rawUrl);
182
331
  }
183
332
  if (url.protocol !== "http:" && url.protocol !== "https:") {
184
- throw new ConnectionUrlError2(`Connection "${connectionName}" must use http(s), got "${url.protocol}"`, rawUrl);
333
+ throw new ConnectionUrlError(`Connection "${connectionName}" must use http(s), got "${url.protocol}"`, rawUrl);
185
334
  }
186
335
  return url;
187
336
  }
@@ -193,7 +342,7 @@ function connectionAllowedHosts(connectionUrl, extra) {
193
342
  }
194
343
  function assertAllowedHost(url, allowedHosts, connectionName) {
195
344
  if (!allowedHosts.has(url.host.toLowerCase())) {
196
- throw new ConnectionUrlError2(`Connection "${connectionName}" refused request to host "${url.host}": not the connection host or an allowed host`, url.toString());
345
+ throw new ConnectionUrlError(`Connection "${connectionName}" refused request to host "${url.host}": not the connection host or an allowed host`, url.toString());
197
346
  }
198
347
  }
199
348
 
@@ -230,7 +379,7 @@ async function fetchConnection(target, init, allowedHosts, connectionName) {
230
379
  const response = await fetch(url, { ...init, redirect: "manual" });
231
380
  if (response.status >= 300 && response.status < 400) {
232
381
  await response.body?.cancel();
233
- throw new ConnectionUrlError2(`Connection "${connectionName}" refused a redirect`, url.toString());
382
+ throw new ConnectionUrlError(`Connection "${connectionName}" refused a redirect`, url.toString());
234
383
  }
235
384
  return response;
236
385
  }
@@ -262,7 +411,7 @@ async function* readSseFrames(response, maxBytes, connectionName, options = {})
262
411
  const context = () => options.currentContext?.() ?? options.context;
263
412
  const tooLarge = (observedReadBytes) => {
264
413
  const current = context();
265
- return new ConnectionResponseTooLargeError2(connectionName, current?.maxResponseBytes ?? maxBytes, { ...current, observedReadBytes });
414
+ return new ConnectionResponseTooLargeError(connectionName, current?.maxResponseBytes ?? maxBytes, { ...current, observedReadBytes });
266
415
  };
267
416
  try {
268
417
  for (;; ) {
@@ -356,7 +505,7 @@ class SseSession {
356
505
  return this.waitForEndpoint(signal);
357
506
  }
358
507
  const readiness = this.endpointContext;
359
- return withConnectionDeadline(this.connectionName, readiness.timeoutMs, signal, (deadline) => this.waitForEndpoint(deadline), readiness);
508
+ return withConnectionDeadline(this.connectionName, readiness, signal, (scoped) => this.waitForEndpoint(scoped.signal));
360
509
  }
361
510
  close(reason = new Error("MCP SSE session closed")) {
362
511
  if (this.controller.signal.aborted)
@@ -383,7 +532,7 @@ class SseSession {
383
532
  if (context)
384
533
  return this.requestWithin(message, token, context, signal);
385
534
  const operation = connectionReadContext(mcpOperation(message.method), this.limits);
386
- return withConnectionDeadline(this.connectionName, operation.timeoutMs, signal, (deadline) => this.requestWithin(message, token, operation, deadline), operation);
535
+ return withConnectionDeadline(this.connectionName, operation, signal, (scoped) => this.requestWithin(message, token, scoped, scoped.signal));
387
536
  }
388
537
  async requestWithin(message, token, context, signal) {
389
538
  const abort = () => this.close(signal?.reason);
@@ -425,10 +574,10 @@ class SseSession {
425
574
  response.body?.cancel().catch(() => {
426
575
  return;
427
576
  });
428
- throw new ConnectionAuthorizationRequiredError2(this.connectionName, this.instanceId, context);
577
+ throw new ConnectionAuthorizationRequiredError(this.connectionName, this.instanceId, context);
429
578
  }
430
579
  if (!response.ok) {
431
- throw new ConnectionRequestError2(this.connectionName, response.status, await readConnectionErrorText(response, this.connectionName, context), context);
580
+ throw new ConnectionRequestError(this.connectionName, response.status, await readConnectionErrorText(response, this.connectionName, context), context);
432
581
  }
433
582
  }
434
583
  currentContext() {
@@ -448,7 +597,7 @@ class SseSession {
448
597
  const total = (this.streamBytes.get(context) ?? 0) + bytes;
449
598
  this.streamBytes.set(context, total);
450
599
  if (total > context.maxResponseBytes) {
451
- throw new ConnectionResponseTooLargeError2(this.connectionName, context.maxResponseBytes, { ...context, observedReadBytes: total });
600
+ throw new ConnectionResponseTooLargeError(this.connectionName, context.maxResponseBytes, { ...context, observedReadBytes: total });
452
601
  }
453
602
  }
454
603
  }
@@ -537,7 +686,7 @@ class McpHttpClient {
537
686
  await this.dispatch({ jsonrpc: "2.0", method: "notifications/initialized" }, token, signal);
538
687
  } catch (error) {
539
688
  signal?.throwIfAborted();
540
- if (error instanceof ConnectionTimeoutError2 || error instanceof ConnectionResponseTooLargeError2) {
689
+ if (error instanceof ConnectionTimeoutError || error instanceof ConnectionResponseTooLargeError) {
541
690
  throw error;
542
691
  }
543
692
  }
@@ -551,21 +700,21 @@ class McpHttpClient {
551
700
  const negotiate = message.method === "initialize" && this.initialInitializePending;
552
701
  if (message.method === "initialize")
553
702
  this.initialInitializePending = false;
554
- return withConnectionDeadline(this.connectionName, context.timeoutMs, signal, async () => {
703
+ return withConnectionDeadline(this.connectionName, context, signal, async (scoped) => {
555
704
  if (this.mode === "sse")
556
- return this.sseRequest(message, token, context);
705
+ return this.sseRequest(message, token, scoped);
557
706
  try {
558
- return await this.streamableRequest(message, token, context);
707
+ return await this.streamableRequest(message, token, scoped);
559
708
  } catch (error) {
560
- context.signal?.throwIfAborted();
561
- if (negotiate && error instanceof ConnectionRequestError2 && FALLBACK_STATUSES.has(error.status)) {
562
- await this.openSse(token, context);
709
+ scoped.signal?.throwIfAborted();
710
+ if (negotiate && error instanceof ConnectionRequestError && FALLBACK_STATUSES.has(error.status)) {
711
+ await this.openSse(token, scoped);
563
712
  this.mode = "sse";
564
- return this.sseRequest(message, token, context);
713
+ return this.sseRequest(message, token, scoped);
565
714
  }
566
715
  throw error;
567
716
  }
568
- }, context);
717
+ });
569
718
  }
570
719
  async streamableRequest(message, token, context) {
571
720
  const target = new URL(this.options.transport.url);
@@ -581,10 +730,10 @@ class McpHttpClient {
581
730
  response.body?.cancel().catch(() => {
582
731
  return;
583
732
  });
584
- throw new ConnectionAuthorizationRequiredError2(this.connectionName, this.instanceId, context);
733
+ throw new ConnectionAuthorizationRequiredError(this.connectionName, this.instanceId, context);
585
734
  }
586
735
  if (!response.ok) {
587
- throw new ConnectionRequestError2(this.connectionName, response.status, await readConnectionErrorText(response, this.connectionName, context), context);
736
+ throw new ConnectionRequestError(this.connectionName, response.status, await readConnectionErrorText(response, this.connectionName, context), context);
588
737
  }
589
738
  const session = response.headers.get("mcp-session-id");
590
739
  if (session)
@@ -675,9 +824,19 @@ function mcpToolFailure(toolName, result) {
675
824
  if (isRecord(payload) && typeof payload.error === "string") {
676
825
  const details = isRecord(payload.details) ? payload.details : undefined;
677
826
  const message = typeof details?.message === "string" ? details.message : payload.error;
678
- return new AppError2(payload.error, message, 502, details, typeof payload._hint === "string" ? payload._hint : undefined, undefined, typeof payload.retryable === "boolean" ? payload.retryable : undefined);
827
+ return new AppError2(payload.error, {
828
+ message,
829
+ status: 502,
830
+ details,
831
+ hint: typeof payload._hint === "string" ? payload._hint : undefined,
832
+ retryable: typeof payload.retryable === "boolean" ? payload.retryable : undefined
833
+ });
679
834
  }
680
- return new AppError2(UPSTREAM_TOOL_ERROR, `External MCP tool "${toolName}" returned an error`, 502, payload === undefined ? undefined : { upstream: payload });
835
+ return new AppError2(UPSTREAM_TOOL_ERROR, {
836
+ message: `External MCP tool "${toolName}" returned an error`,
837
+ status: 502,
838
+ details: payload === undefined ? undefined : { upstream: payload }
839
+ });
681
840
  }
682
841
 
683
842
  // src/tools/connections/runtime.ts
@@ -687,7 +846,7 @@ async function withConnectionToken(params, body) {
687
846
  try {
688
847
  return await body(token);
689
848
  } catch (error) {
690
- if (error instanceof ConnectionAuthorizationRequiredError2) {
849
+ if (error instanceof ConnectionAuthorizationRequiredError) {
691
850
  params.client?.teardown();
692
851
  }
693
852
  throw error;
@@ -929,8 +1088,12 @@ async function mountOpenApiConnection(connection, instanceId, onSkipped) {
929
1088
  discovery: { timeoutMs, maxResponseBytes },
930
1089
  call: { timeoutMs, maxResponseBytes }
931
1090
  });
932
- return withConnectionDeadline(connection.name, timeoutMs, context.signal, async (signal) => {
933
- const requestInit = { method: entry.method, headers, signal };
1091
+ return withConnectionDeadline(connection.name, readContext, context.signal, async (scoped) => {
1092
+ const requestInit = {
1093
+ method: entry.method,
1094
+ headers,
1095
+ signal: scoped.signal
1096
+ };
934
1097
  if (body && args.body !== undefined) {
935
1098
  headers["content-type"] = "application/json";
936
1099
  requestInit.body = JSON.stringify(args.body);
@@ -938,13 +1101,13 @@ async function mountOpenApiConnection(connection, instanceId, onSkipped) {
938
1101
  const response = await fetchConnection(url, requestInit, allowedHosts, connection.name);
939
1102
  if (response.status === 401) {
940
1103
  await response.body?.cancel();
941
- throw new ConnectionAuthorizationRequiredError2(connection.name, instanceId, readContext);
1104
+ throw new ConnectionAuthorizationRequiredError(connection.name, instanceId, scoped);
942
1105
  }
943
1106
  if (!response.ok) {
944
- throw new ConnectionRequestError2(connection.name, response.status, await readConnectionErrorText(response, connection.name, readContext), readContext);
1107
+ throw new ConnectionRequestError(connection.name, response.status, await readConnectionErrorText(response, connection.name, scoped), scoped);
945
1108
  }
946
- return readResponse(response, maxResponseBytes, connection.name, readContext);
947
- }, readContext);
1109
+ return readResponse(response, maxResponseBytes, connection.name, scoped);
1110
+ });
948
1111
  })
949
1112
  });
950
1113
  recordForeignSchemaBytes(definition, jsonSchemaBytes(schema));
@@ -970,13 +1133,13 @@ async function loadOpenApiDocument(connection, timeoutMs, maxResponseBytes) {
970
1133
  discovery: { timeoutMs, maxResponseBytes },
971
1134
  call: { timeoutMs, maxResponseBytes }
972
1135
  });
973
- const parsed = await withConnectionDeadline(connection.name, timeoutMs, undefined, async (signal) => {
974
- const response = await fetchConnection(url, { signal }, connectionAllowedHosts(url, connection.allowHosts), connection.name);
1136
+ const parsed = await withConnectionDeadline(connection.name, readContext, undefined, async (scoped) => {
1137
+ const response = await fetchConnection(url, { signal: scoped.signal }, connectionAllowedHosts(url, connection.allowHosts), connection.name);
975
1138
  if (!response.ok) {
976
- throw new ConnectionRequestError2(connection.name, response.status, await readConnectionErrorText(response, connection.name, readContext), readContext);
1139
+ throw new ConnectionRequestError(connection.name, response.status, await readConnectionErrorText(response, connection.name, scoped), scoped);
977
1140
  }
978
- return readBoundedJson(response, maxResponseBytes, connection.name, readContext);
979
- }, readContext);
1141
+ return readBoundedJson(response, maxResponseBytes, connection.name, scoped);
1142
+ });
980
1143
  if (!isRecord(parsed))
981
1144
  throw new Error(`OpenAPI spec at ${url} is not an object`);
982
1145
  return { document: parsed, url: url.toString() };
@@ -1206,13 +1369,13 @@ async function mountConnections(connections, options = {}) {
1206
1369
  }
1207
1370
  const limit = options.budget?.maxTools;
1208
1371
  if (limit !== undefined && tools.length > limit) {
1209
- throw new ConnectionBudgetExceededError2(limit, tools.length);
1372
+ throw new ConnectionBudgetExceededError(limit, tools.length);
1210
1373
  }
1211
1374
  const schemaLimit = options.budget?.maxSchemaBytes;
1212
1375
  if (schemaLimit !== undefined) {
1213
1376
  const schemaBytes = tools.reduce((total, tool) => total + foreignSchemaBytes(tool), 0);
1214
1377
  if (schemaBytes > schemaLimit) {
1215
- throw new ConnectionBudgetExceededError2(schemaLimit, schemaBytes, "schema bytes");
1378
+ throw new ConnectionBudgetExceededError(schemaLimit, schemaBytes, "schema bytes");
1216
1379
  }
1217
1380
  }
1218
1381
  return tools;
@@ -1231,12 +1394,12 @@ function instanceIdOf(connection) {
1231
1394
  return connectionInstanceId(connection.name, url, connection.instanceKey);
1232
1395
  }
1233
1396
  export {
1234
- ConnectionAuthorizationRequiredError2 as ConnectionAuthorizationRequiredError,
1235
- ConnectionBudgetExceededError2 as ConnectionBudgetExceededError,
1236
- ConnectionRequestError2 as ConnectionRequestError,
1237
- ConnectionResponseTooLargeError2 as ConnectionResponseTooLargeError,
1238
- ConnectionTimeoutError2 as ConnectionTimeoutError,
1239
- ConnectionUrlError2 as ConnectionUrlError,
1397
+ ConnectionAuthorizationRequiredError,
1398
+ ConnectionBudgetExceededError,
1399
+ ConnectionRequestError,
1400
+ ConnectionResponseTooLargeError,
1401
+ ConnectionTimeoutError,
1402
+ ConnectionUrlError,
1240
1403
  defineMcpClientConnection,
1241
1404
  defineOpenApiConnection,
1242
1405
  mountConnections
@@ -6,10 +6,10 @@ import {
6
6
  ViewFileErrorSchema2,
7
7
  ViewFileOutputSchema2,
8
8
  ViewFileInputSchema2
9
- } from "../../index-zax7resm.js";
9
+ } from "../../index-0gxvns6s.js";
10
10
  import {
11
11
  coerceJsonArgs2
12
- } from "../../index-9pw0a51a.js";
12
+ } from "../../index-6yxhe58g.js";
13
13
  export {
14
14
  AsyncOperationCancelResultSchema2 as AsyncOperationCancelResultSchema,
15
15
  McpAnnotationsSchema2 as McpAnnotationsSchema,
@@ -1,14 +1,15 @@
1
- import"../../index-x928baz2.js";
2
- import"../../index-kb8styz3.js";
3
- import"../../index-2vnh05w4.js";
1
+ import"../../index-j9gxbztg.js";
2
+ import"../../index-rpzewktb.js";
3
+ import"../../index-556g5hsh.js";
4
+ import"../../index-2k91mewf.js";
4
5
  import"../../index-yex7eg1v.js";
5
- import"../../index-9pw0a51a.js";
6
+ import"../../index-6yxhe58g.js";
6
7
  import"../../index-ct75c3at.js";
7
- import"../../index-77nxk6ay.js";
8
- import"../../index-2hyavjjj.js";
8
+ import"../../index-r393tnfp.js";
9
+ import"../../index-wbhdzxar.js";
9
10
  import {
10
11
  createToolInvoker2
11
- } from "../../index-fa4wg312.js";
12
+ } from "../../index-f199nfq5.js";
12
13
  import"../../index-7n68nmc6.js";
13
14
  export {
14
15
  createToolInvoker2 as createToolInvoker
@@ -7,6 +7,6 @@ export { buildMcpServer, type DirectMcpSurfaceConfig, type FiniteMcpSurfaceConfi
7
7
  export type { IncompatibleSchemaPolicy, McpSchemaValidationConfig, McpSurfaceDefinition, McpSurfaceRegistry, ValidateMcpSchemasConfig, } from '../../tools/mcp/prepare.js';
8
8
  export { createStdioMcpServer, type McpStdioHandle, type StdioAuthConfig, type StdioMcpServerConfig, } from '../../tools/mcp/stdio.js';
9
9
  export { bindStdioProcessSignals, type StdioCloseTarget, type StdioProcessSignalsBinding, type StdioProcessSignalsErrorPhase, type StdioProcessSignalsOptions, } from '../../tools/mcp/stdio-signals.js';
10
- export type { RuntimeToolDefinitionWithoutOutput } from '../../tools/runtime-tool-execution.js';
11
- export type { RuntimeMcpPresentation, RuntimeMcpToolDefinition, RuntimeMcpToolDefinitionWithOutput, RuntimeMcpToolPresenters, } from '../../tools/runtime-tool-mcp.js';
10
+ export type { RuntimeToolDefinition, RuntimeToolDefinitionWithOutput, RuntimeToolDefinitionWithoutOutput, } from '../../tools/runtime-tool-declaration.js';
11
+ export type { RuntimeMcpPresentation, RuntimeMcpToolPresenters, } from '../../tools/runtime-tool-mcp.js';
12
12
  //# sourceMappingURL=mcp.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../../src/entrypoints/tools/mcp.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,YAAY,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AACpF,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,EAClB,KAAK,SAAS,EACd,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,oBAAoB,EACpB,KAAK,eAAe,EACpB,cAAc,EACd,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,GACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,cAAc,EACd,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,wBAAwB,EACxB,yBAAyB,EACzB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,oBAAoB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,uBAAuB,EACvB,KAAK,gBAAgB,EACrB,KAAK,0BAA0B,EAC/B,KAAK,6BAA6B,EAClC,KAAK,0BAA0B,GAChC,MAAM,+BAA+B,CAAC;AACvC,YAAY,EAAE,kCAAkC,EAAE,MAAM,oCAAoC,CAAC;AAC7F,YAAY,EACV,sBAAsB,EACtB,wBAAwB,EACxB,kCAAkC,EAClC,wBAAwB,GACzB,MAAM,8BAA8B,CAAC"}
1
+ {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../../src/entrypoints/tools/mcp.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,YAAY,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AACpF,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,EAClB,KAAK,SAAS,EACd,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,oBAAoB,EACpB,KAAK,eAAe,EACpB,cAAc,EACd,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,GACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,cAAc,EACd,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,wBAAwB,EACxB,yBAAyB,EACzB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,oBAAoB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,uBAAuB,EACvB,KAAK,gBAAgB,EACrB,KAAK,0BAA0B,EAC/B,KAAK,6BAA6B,EAClC,KAAK,0BAA0B,GAChC,MAAM,+BAA+B,CAAC;AACvC,YAAY,EACV,qBAAqB,EACrB,+BAA+B,EAC/B,kCAAkC,GACnC,MAAM,sCAAsC,CAAC;AAC9C,YAAY,EACV,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,8BAA8B,CAAC"}
@@ -14,18 +14,19 @@ import {
14
14
  createMcpHttpRoute2,
15
15
  createStdioMcpServer2,
16
16
  bindStdioProcessSignals2
17
- } from "../../index-bhb950qs.js";
18
- import"../../index-x928baz2.js";
19
- import"../../index-kb8styz3.js";
17
+ } from "../../index-916yh4e2.js";
18
+ import"../../index-j9gxbztg.js";
19
+ import"../../index-rpzewktb.js";
20
20
  import"../../index-yex7eg1v.js";
21
- import"../../index-9pw0a51a.js";
22
- import"../../index-77nxk6ay.js";
23
- import"../../index-2vnh05w4.js";
24
- import"../../index-2hyavjjj.js";
21
+ import"../../index-6yxhe58g.js";
22
+ import"../../index-r393tnfp.js";
23
+ import"../../index-2k91mewf.js";
24
+ import"../../index-556g5hsh.js";
25
+ import"../../index-wbhdzxar.js";
25
26
  import"../../index-sznqf8fx.js";
26
27
  import"../../index-e6c2spsd.js";
27
- import"../../index-a0zzh8ak.js";
28
- import"../../index-cvda079a.js";
28
+ import"../../index-pz3y6b6g.js";
29
+ import"../../index-yvfk3y36.js";
29
30
  import"../../index-7n68nmc6.js";
30
31
  export {
31
32
  EXT_APPS_BUNDLE_PLACEHOLDER2 as EXT_APPS_BUNDLE_PLACEHOLDER,
@@ -41,7 +41,6 @@ export { createRuntimeToolFactory, defineRuntimeTool, type RuntimeAgentModelOutp
41
41
  export { flattenToolJsonSchema, type ToolPresentationSchema, } from '../tools/schema/flatten.js';
42
42
  export { findNonPortableFormats, type NonPortableFormat, PORTABLE_JSON_SCHEMA_FORMATS, } from '../tools/schema/portable-formats.js';
43
43
  export { findUntypedProperties, type UntypedProperty, } from '../tools/schema/untyped-properties.js';
44
- export type { ToolSurfaceDefinition } from '../tools/surface.js';
45
44
  export { createToolLogger, type ToolCallRecord, type ToolLoggerConfig, } from '../tools/tool-logger.js';
46
45
  export { createToolkit, type Toolkit } from '../tools/toolkit.js';
47
46
  export { type DefineDownloadToolConfig, defineDownloadTool, } from '../tools/transfer/define-download-tool.js';