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,5 +1,4 @@
1
- import"../index-yex7eg1v.js";
2
- import"../index-ywppsaby.js";
1
+ import"../index-kfjkb396.js";
3
2
  import {
4
3
  joinRoutePath
5
4
  } from "../index-m38ej7e5.js";
@@ -7,12 +6,14 @@ import"../index-h2fhjqy7.js";
7
6
  import {
8
7
  createClient2,
9
8
  createClients2
10
- } from "../index-kemm0ej5.js";
11
- import"../index-x928baz2.js";
9
+ } from "../index-1pwwan01.js";
10
+ import"../index-yex7eg1v.js";
11
+ import"../index-n1nszyk0.js";
12
+ import"../index-j9gxbztg.js";
12
13
  import"../index-q0th8q0z.js";
13
14
  import {
14
15
  createApplication2
15
- } from "../index-r4r70zmh.js";
16
+ } from "../index-12zsej7b.js";
16
17
  import"../index-w5s3xftz.js";
17
18
  import {
18
19
  RealtimeRequestTimeoutError2,
@@ -21,7 +22,7 @@ import {
21
22
  } from "../index-4s0fep5q.js";
22
23
  import {
23
24
  TOOL_TRANSPORTS2
24
- } from "../index-ck71tbcf.js";
25
+ } from "../index-fsw1ybf3.js";
25
26
  import {
26
27
  RealtimeRejectDirectionSchema,
27
28
  RealtimeRejectPhaseSchema,
@@ -36,8 +37,8 @@ import {
36
37
  projectToolSurface,
37
38
  mcpProjectionCandidate,
38
39
  prepareProjectedMcpTools
39
- } from "../index-77nxk6ay.js";
40
- import"../index-kb8styz3.js";
40
+ } from "../index-r393tnfp.js";
41
+ import"../index-rpzewktb.js";
41
42
  import {
42
43
  compareCodeUnits,
43
44
  serializeCanonicalJson
@@ -648,78 +649,397 @@ async function runManagedResourceConformance(config) {
648
649
  }
649
650
  }
650
651
  // src/testing/surface-conformance.ts
651
- import { z as z3 } from "zod";
652
-
653
- // src/testing/surface-manifest.ts
654
652
  import { z as z2 } from "zod";
655
-
656
- // src/testing/surface-manifest-digest.ts
657
- import { createHash } from "node:crypto";
658
- function digestValue(value) {
659
- return createHash("sha256").update(serializeCanonicalJson(value)).digest("hex").slice(0, 16);
653
+ var RealtimeRejectionObservationSchema = z2.object({
654
+ direction: RealtimeRejectDirectionSchema,
655
+ phase: RealtimeRejectPhaseSchema,
656
+ reason: RealtimeRejectReasonSchema,
657
+ fault: RealtimeRejectFaultSchema
658
+ });
659
+ var ObservationFields = {
660
+ code: z2.string().optional(),
661
+ data: z2.unknown().optional(),
662
+ diagnostic: z2.string().optional(),
663
+ handlerCalls: z2.number().int().nonnegative().optional()
664
+ };
665
+ var RealtimeDisconnectObservationSchema = z2.object({
666
+ phase: z2.enum(["before-invoke", "in-flight"])
667
+ });
668
+ var TransportObservationSchema = z2.discriminatedUnion("outcome", [
669
+ z2.object({ outcome: z2.literal("success"), ...ObservationFields }),
670
+ z2.object({ outcome: z2.literal("validation_error"), ...ObservationFields }),
671
+ z2.object({ outcome: z2.literal("domain_error"), ...ObservationFields }),
672
+ z2.object({ outcome: z2.literal("aborted"), ...ObservationFields }),
673
+ z2.object({
674
+ outcome: z2.literal("realtime_rejected"),
675
+ ...ObservationFields,
676
+ rejection: RealtimeRejectionObservationSchema
677
+ }),
678
+ z2.object({
679
+ outcome: z2.literal("disconnected"),
680
+ ...ObservationFields,
681
+ disconnect: RealtimeDisconnectObservationSchema
682
+ }),
683
+ z2.object({ outcome: z2.literal("timeout"), ...ObservationFields })
684
+ ]);
685
+ function sorted(values) {
686
+ return [...values].sort((left, right) => left < right ? -1 : left > right ? 1 : 0);
660
687
  }
661
- function canonicalSchemaValue(value, parentKey) {
662
- if (Array.isArray(value)) {
663
- const entries = value.map((entry) => canonicalSchemaValue(entry));
664
- return parentKey === "required" && entries.every((entry) => typeof entry === "string") ? entries.sort((left, right) => compareCodeUnits(String(left), String(right))) : entries;
688
+ function assertSameSet(label, expectedValues, actualValues) {
689
+ const expected = sorted(expectedValues);
690
+ const actual = sorted(actualValues);
691
+ if (serializeCanonicalJson(expected) === serializeCanonicalJson(actual))
692
+ return;
693
+ throw new Error(`${label} mismatch
694
+ expected: ${expected.join(", ") || "(empty)"}
695
+ actual: ${actual.join(", ") || "(empty)"}`);
696
+ }
697
+ function openApiOperations(document) {
698
+ return Object.entries(document.paths).flatMap(([path, item]) => Object.keys(item).filter((method) => ["get", "post", "put", "patch", "delete", "head"].includes(method)).map((method) => `${method.toUpperCase()}:${path}`));
699
+ }
700
+ function expectedToolNames(manifest, transport, surface) {
701
+ const projection = manifest.toolSurfaces.find((candidate) => candidate.transport === transport && candidate.surface === surface);
702
+ if (!projection) {
703
+ throw new Error(`${transport} surface "${surface ?? "(default)"}" is not declared in the manifest`);
665
704
  }
666
- if (!isRecord(value))
667
- return value;
668
- const result = {};
669
- for (const key of Object.keys(value).sort(compareCodeUnits)) {
670
- result[key] = canonicalSchemaValue(value[key], key);
705
+ return projection.tools.map((tool) => tool.name);
706
+ }
707
+ function assertSurfaceDiscovery(manifest, observed) {
708
+ if (observed.openApi) {
709
+ assertSameSet("HTTP/OpenAPI", manifest.operations.flatMap((operation) => operation.http.map((entry) => `${entry.method}:${entry.path.replace(/:([^/]+)/g, "{$1}")}`)), openApiOperations(observed.openApi));
710
+ }
711
+ for (const transport of TOOL_TRANSPORTS2) {
712
+ const names = observed[transport];
713
+ if (names) {
714
+ assertSameSet(`${transport} discovery`, expectedToolNames(manifest, transport, null), names);
715
+ }
716
+ }
717
+ for (const projection of observed.toolSurfaces ?? []) {
718
+ assertSameSet(`${projection.transport} surface "${projection.surface ?? "(default)"}" discovery`, expectedToolNames(manifest, projection.transport, projection.surface ?? null), projection.names);
719
+ }
720
+ for (const [contract, topology] of Object.entries(observed.realtime ?? {})) {
721
+ if (!manifest.realtimeContracts.includes(contract)) {
722
+ throw new Error(`REALTIME contract "${contract}" is not declared in the manifest`);
723
+ }
724
+ for (const direction of ["serverToClient", "clientToServer"]) {
725
+ assertSameSet(`REALTIME ${contract}.${direction} discovery`, manifest.realtime.filter((entry) => entry.contract === contract && entry.direction === direction).map((entry) => entry.event), topology[direction]);
726
+ }
727
+ }
728
+ if (observed.cliOnly) {
729
+ assertSameSet("CLI-only discovery", manifest.cliOnly.map((command) => command.name), observed.cliOnly);
730
+ }
731
+ for (const transport of [
732
+ "HTTP",
733
+ "MCP",
734
+ "AGENT",
735
+ "CLI",
736
+ "REALTIME"
737
+ ]) {
738
+ const names = observed.extensions?.[transport];
739
+ if (!names)
740
+ continue;
741
+ assertSameSet(`${transport} extension discovery`, manifest.extensions.filter((extension) => extension.transport === transport).map((extension) => extension.name), names);
671
742
  }
672
- return result;
673
743
  }
674
- function schemaDigest(schema, io) {
675
- if (!schema)
676
- return null;
677
- return digestValue(canonicalSchemaValue(toJsonSchema(schema, io, "any")));
744
+ function boundedObservation(observation, maxDiagnosticBytes) {
745
+ const parsed = TransportObservationSchema.parse(observation);
746
+ if (!parsed.diagnostic)
747
+ return parsed;
748
+ const bytes = new TextEncoder().encode(parsed.diagnostic);
749
+ if (bytes.byteLength <= maxDiagnosticBytes)
750
+ return parsed;
751
+ return {
752
+ ...parsed,
753
+ diagnostic: new TextDecoder().decode(bytes.slice(0, maxDiagnosticBytes))
754
+ };
678
755
  }
679
- function presentationDigest(schema) {
680
- return digestValue(canonicalSchemaValue(schema));
756
+ async function runBounded(run, signal) {
757
+ if (signal.aborted) {
758
+ Promise.resolve().then(run).catch(() => {
759
+ return;
760
+ });
761
+ throw signal.reason;
762
+ }
763
+ let removeAbortListener = () => {
764
+ return;
765
+ };
766
+ const aborted = new Promise((_resolve, reject) => {
767
+ const onAbort = () => reject(signal.reason);
768
+ signal.addEventListener("abort", onAbort, { once: true });
769
+ removeAbortListener = () => signal.removeEventListener("abort", onAbort);
770
+ });
771
+ try {
772
+ return await Promise.race([Promise.resolve().then(run), aborted]);
773
+ } finally {
774
+ removeAbortListener();
775
+ }
681
776
  }
682
- function multipartDigest(value) {
683
- return value === undefined ? null : digestValue(value);
777
+ async function runSurfaceProbes({
778
+ probes,
779
+ drivers,
780
+ signal,
781
+ timeoutMs = 1e4,
782
+ maxDiagnosticBytes = 4096
783
+ }) {
784
+ if (!Number.isInteger(timeoutMs) || timeoutMs <= 0) {
785
+ throw new TypeError("Surface probe timeoutMs must be a positive integer");
786
+ }
787
+ if (!Number.isInteger(maxDiagnosticBytes) || maxDiagnosticBytes <= 0) {
788
+ throw new TypeError("Surface probe maxDiagnosticBytes must be a positive integer");
789
+ }
790
+ for (const probe of probes) {
791
+ const timeoutSignal = AbortSignal.timeout(timeoutMs);
792
+ const probeSignal = signal ? AbortSignal.any([signal, timeoutSignal]) : timeoutSignal;
793
+ let failed = false;
794
+ let failure;
795
+ try {
796
+ probeSignal.throwIfAborted();
797
+ if (probe.setup)
798
+ await runBounded(() => probe.setup?.(probeSignal), probeSignal);
799
+ for (const transport of probe.transports) {
800
+ probeSignal.throwIfAborted();
801
+ const driver = drivers[transport];
802
+ if (!driver) {
803
+ throw new Error(`Surface probe "${probe.name}" has no ${transport} driver`);
804
+ }
805
+ const actual = boundedObservation(await runBounded(() => driver.invoke(probe.fixture, probeSignal), probeSignal), maxDiagnosticBytes);
806
+ const expected = probe.expected[transport];
807
+ if (!expected) {
808
+ throw new Error(`Surface probe "${probe.name}" has no ${transport} expectation`);
809
+ }
810
+ if (serializeCanonicalJson(actual) !== serializeCanonicalJson(expected)) {
811
+ throw new Error(`Surface probe "${probe.name}" ${transport} mismatch
812
+ expected: ${serializeCanonicalJson(expected)}
813
+ actual: ${serializeCanonicalJson(actual)}`);
814
+ }
815
+ }
816
+ } catch (error) {
817
+ failed = true;
818
+ failure = error;
819
+ }
820
+ if (probe.teardown) {
821
+ try {
822
+ await runBounded(() => probe.teardown?.(probeSignal), probeSignal);
823
+ } catch (error) {
824
+ if (!failed) {
825
+ failed = true;
826
+ failure = error;
827
+ }
828
+ }
829
+ }
830
+ if (failed)
831
+ throw failure;
832
+ }
684
833
  }
685
- function operationKey(kind, service, action) {
686
- return `${kind}\x00${service}\x00${action}`;
834
+
835
+ // src/testing/realtime-probe.ts
836
+ function scenarioOutcome(scenario) {
837
+ if (scenario === "event" || scenario === "acknowledgement")
838
+ return "success";
839
+ if (scenario === "invalid_arguments" || scenario === "invalid_acknowledgement" || scenario === "peer_rejection") {
840
+ return "realtime_rejected";
841
+ }
842
+ if (scenario === "disconnected" || scenario === "in_flight_disconnect") {
843
+ return "disconnected";
844
+ }
845
+ return "timeout";
687
846
  }
688
- function operationFrom(kind, source) {
689
- return {
690
- kind,
691
- service: source.serviceName,
692
- action: source.key,
693
- method: source.method,
694
- scope: source.scope ?? null,
695
- description: source.desc,
696
- schemas: {
697
- params: schemaDigest(source.paramsSchema, "input"),
698
- input: schemaDigest(source.inputSchema, "input"),
699
- output: schemaDigest(source.outputSchema, "output"),
700
- multipart: multipartDigest(source.multipart)
701
- },
702
- mcp: mcpRoundsOf(source),
703
- ...toolViewEntry(source),
704
- http: []
705
- };
847
+ function assertScenarioExpectation(scenario, expected) {
848
+ const outcome = scenarioOutcome(scenario);
849
+ if (expected.outcome !== outcome) {
850
+ throw new TypeError(`Realtime probe scenario "${scenario}" requires outcome "${outcome}"`);
851
+ }
852
+ if (expected.outcome === "realtime_rejected" && (scenario === "invalid_arguments" && expected.rejection.phase !== "arguments" || scenario === "invalid_acknowledgement" && expected.rejection.phase !== "acknowledgement")) {
853
+ throw new TypeError(`Realtime probe scenario "${scenario}" has incompatible rejection phase`);
854
+ }
855
+ if (scenario === "invalid_arguments" && expected.handlerCalls !== 0) {
856
+ throw new TypeError('Realtime probe scenario "invalid_arguments" requires handlerCalls: 0');
857
+ }
858
+ if (scenario === "peer_rejection" && (expected.outcome !== "realtime_rejected" || expected.rejection.reason !== "rejected-by-peer")) {
859
+ throw new TypeError('Realtime probe scenario "peer_rejection" requires a rejected-by-peer outcome');
860
+ }
861
+ if (expected.outcome === "disconnected") {
862
+ const phase = scenario === "disconnected" ? "before-invoke" : "in-flight";
863
+ if (expected.disconnect.phase !== phase) {
864
+ throw new TypeError(`Realtime probe scenario "${scenario}" requires disconnect phase "${phase}"`);
865
+ }
866
+ }
706
867
  }
707
- function toolViewOf(source) {
708
- const view = source.toolView;
709
- if (!view)
710
- return null;
868
+ function defineRealtimeProbe(config) {
869
+ const expected = TransportObservationSchema.parse(config.expected);
870
+ assertScenarioExpectation(config.scenario, expected);
711
871
  return {
712
- defaults: view.defaults === undefined || Object.keys(view.defaults).length === 0 ? null : digestValue(view.defaults),
713
- output: schemaDigest(view.output, "output"),
714
- project: view.project !== undefined
872
+ name: config.name,
873
+ fixture: { scenario: config.scenario, value: config.fixture },
874
+ transports: ["REALTIME"],
875
+ expected: { REALTIME: expected },
876
+ setup: config.setup,
877
+ teardown: config.teardown
715
878
  };
716
879
  }
717
- function toolViewEntry(source) {
718
- const toolView = toolViewOf(source);
719
- return toolView ? { toolView } : {};
880
+ function rejectionObservation(rejected) {
881
+ return RealtimeRejectionObservationSchema.parse(rejected);
720
882
  }
721
- function mcpRoundsOf(source) {
722
- if (!source.mcp)
883
+ function createRealtimeProbeDriver({
884
+ bind,
885
+ handlerCalls
886
+ }) {
887
+ return {
888
+ async invoke(fixture, signal) {
889
+ let rejected;
890
+ const currentRejection = () => rejected;
891
+ const adapter = bind((event) => {
892
+ rejected = event;
893
+ }, fixture);
894
+ const connectedBefore = adapter.connected();
895
+ const callsBefore = handlerCalls?.();
896
+ const withCalls = (observation) => {
897
+ if (callsBefore === undefined || !handlerCalls)
898
+ return observation;
899
+ return { ...observation, handlerCalls: handlerCalls() - callsBefore };
900
+ };
901
+ try {
902
+ signal.throwIfAborted();
903
+ const data = await adapter.invoke(fixture, signal);
904
+ const observedRejection = currentRejection();
905
+ if (observedRejection) {
906
+ return withCalls({
907
+ outcome: "realtime_rejected",
908
+ code: observedRejection.error.code,
909
+ rejection: rejectionObservation(observedRejection)
910
+ });
911
+ }
912
+ return withCalls({
913
+ outcome: "success",
914
+ ...data !== undefined && { data }
915
+ });
916
+ } catch (error) {
917
+ const observedRejection = currentRejection();
918
+ if (observedRejection) {
919
+ return withCalls({
920
+ outcome: "realtime_rejected",
921
+ code: error instanceof RealtimeRequestInvalidAcknowledgementError2 ? error.code : observedRejection.error.code,
922
+ rejection: rejectionObservation(observedRejection)
923
+ });
924
+ }
925
+ if (error instanceof RealtimeRequestInvalidAcknowledgementError2) {
926
+ return withCalls({
927
+ outcome: "realtime_rejected",
928
+ code: error.code,
929
+ rejection: {
930
+ direction: "client-inbound",
931
+ phase: "acknowledgement",
932
+ reason: "invalid-acknowledgement-value",
933
+ fault: "peer"
934
+ }
935
+ });
936
+ }
937
+ if (error instanceof RealtimeRequestDisconnectedError2) {
938
+ return withCalls({
939
+ outcome: "disconnected",
940
+ code: error.code,
941
+ disconnect: {
942
+ phase: connectedBefore ? "in-flight" : "before-invoke"
943
+ }
944
+ });
945
+ }
946
+ if (error instanceof RealtimeRequestTimeoutError2) {
947
+ return withCalls({ outcome: "timeout", code: error.code });
948
+ }
949
+ if (signal.aborted && error === signal.reason) {
950
+ return withCalls({ outcome: "aborted" });
951
+ }
952
+ const parsedRejection = RealtimeRejectionObservationSchema.safeParse(typeof error === "object" && error !== null && "details" in error ? error.details : undefined);
953
+ if (parsedRejection.success) {
954
+ const code = typeof error === "object" && error !== null && "code" in error ? String(error.code) : "REALTIME_CONTRACT_VIOLATION";
955
+ return withCalls({
956
+ outcome: "realtime_rejected",
957
+ code,
958
+ rejection: parsedRejection.data
959
+ });
960
+ }
961
+ const code = typeof error === "object" && error !== null && "code" in error ? String(error.code) : undefined;
962
+ return withCalls({
963
+ outcome: "domain_error",
964
+ ...code !== undefined && { code },
965
+ diagnostic: error instanceof Error ? error.message : String(error)
966
+ });
967
+ } finally {
968
+ await adapter.dispose?.();
969
+ }
970
+ }
971
+ };
972
+ }
973
+ // src/testing/surface-manifest.ts
974
+ import { z as z3 } from "zod";
975
+
976
+ // src/testing/surface-manifest-digest.ts
977
+ import { createHash } from "node:crypto";
978
+ function digestValue(value) {
979
+ return createHash("sha256").update(serializeCanonicalJson(value)).digest("hex").slice(0, 16);
980
+ }
981
+ function canonicalSchemaValue(value, parentKey) {
982
+ if (Array.isArray(value)) {
983
+ const entries = value.map((entry) => canonicalSchemaValue(entry));
984
+ return parentKey === "required" && entries.every((entry) => typeof entry === "string") ? entries.sort((left, right) => compareCodeUnits(String(left), String(right))) : entries;
985
+ }
986
+ if (!isRecord(value))
987
+ return value;
988
+ const result = {};
989
+ for (const key of Object.keys(value).sort(compareCodeUnits)) {
990
+ result[key] = canonicalSchemaValue(value[key], key);
991
+ }
992
+ return result;
993
+ }
994
+ function schemaDigest(schema, io) {
995
+ if (!schema)
996
+ return null;
997
+ return digestValue(canonicalSchemaValue(toJsonSchema(schema, io, "any")));
998
+ }
999
+ function presentationDigest(schema) {
1000
+ return digestValue(canonicalSchemaValue(schema));
1001
+ }
1002
+ function multipartDigest(value) {
1003
+ return value === undefined ? null : digestValue(value);
1004
+ }
1005
+ function operationKey(kind, service, action) {
1006
+ return `${kind}\x00${service}\x00${action}`;
1007
+ }
1008
+ function operationFrom(kind, source) {
1009
+ return {
1010
+ kind,
1011
+ service: source.serviceName,
1012
+ action: source.key,
1013
+ method: source.method,
1014
+ scope: source.scope ?? null,
1015
+ description: source.desc,
1016
+ schemas: {
1017
+ params: schemaDigest(source.paramsSchema, "input"),
1018
+ input: schemaDigest(source.inputSchema, "input"),
1019
+ output: schemaDigest(source.outputSchema, "output"),
1020
+ multipart: multipartDigest(source.multipart)
1021
+ },
1022
+ mcp: mcpRoundsOf(source),
1023
+ ...toolViewEntry(source),
1024
+ http: []
1025
+ };
1026
+ }
1027
+ function toolViewOf(source) {
1028
+ const view = source.toolView;
1029
+ if (!view)
1030
+ return null;
1031
+ return {
1032
+ defaults: view.defaults === undefined || Object.keys(view.defaults).length === 0 ? null : digestValue(view.defaults),
1033
+ output: schemaDigest(view.output, "output"),
1034
+ project: view.project !== undefined
1035
+ };
1036
+ }
1037
+ function toolViewEntry(source) {
1038
+ const toolView = toolViewOf(source);
1039
+ return toolView ? { toolView } : {};
1040
+ }
1041
+ function mcpRoundsOf(source) {
1042
+ if (!source.mcp)
723
1043
  return null;
724
1044
  const declared = staticInputRounds(source.mcp);
725
1045
  return {
@@ -785,82 +1105,81 @@ function runtimeOperationSource(source) {
785
1105
 
786
1106
  // src/testing/surface-manifest.ts
787
1107
  var SURFACE_MANIFEST_VERSION = 3;
788
- var HttpMethodSchema = z2.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"]);
789
- var ToolTransportSchema = z2.enum(TOOL_TRANSPORTS2);
790
- var SurfaceTransportSchema = z2.enum(["HTTP", "MCP", "AGENT", "CLI", "REALTIME"]);
791
- var SurfaceSchemaDigestsSchema = z2.object({
792
- params: z2.string().nullable(),
793
- input: z2.string().nullable(),
794
- output: z2.string().nullable(),
795
- multipart: z2.string().nullable()
1108
+ var HttpMethodSchema = z3.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"]);
1109
+ var ToolTransportSchema = z3.enum(TOOL_TRANSPORTS2);
1110
+ var SurfaceTransportSchema = z3.enum(["HTTP", "MCP", "AGENT", "CLI", "REALTIME"]);
1111
+ var SurfaceSchemaDigestsSchema = z3.object({
1112
+ params: z3.string().nullable(),
1113
+ input: z3.string().nullable(),
1114
+ output: z3.string().nullable(),
1115
+ multipart: z3.string().nullable()
796
1116
  });
797
- var SurfaceManifestOperationMcpSchema = z2.object({
798
- inputRequired: z2.union([
799
- z2.array(z2.object({ key: z2.string(), message: z2.string(), schema: z2.string().nullable() })),
800
- z2.literal("resolved-per-call")
1117
+ var SurfaceManifestOperationMcpSchema = z3.object({
1118
+ inputRequired: z3.union([
1119
+ z3.array(z3.object({ key: z3.string(), message: z3.string(), schema: z3.string().nullable() })),
1120
+ z3.literal("resolved-per-call")
801
1121
  ])
802
1122
  }).nullable();
803
- var SurfaceManifestOperationToolViewSchema = z2.object({
804
- defaults: z2.string().nullable(),
805
- output: z2.string().nullable(),
806
- project: z2.boolean()
1123
+ var SurfaceManifestOperationToolViewSchema = z3.object({
1124
+ defaults: z3.string().nullable(),
1125
+ output: z3.string().nullable(),
1126
+ project: z3.boolean()
807
1127
  });
808
- var SurfaceManifestOperationSchema = z2.object({
809
- kind: z2.enum(["contract", "runtime"]),
810
- service: z2.string(),
811
- action: z2.string(),
1128
+ var SurfaceManifestOperationSchema = z3.object({
1129
+ kind: z3.enum(["contract", "runtime"]),
1130
+ service: z3.string(),
1131
+ action: z3.string(),
812
1132
  method: HttpMethodSchema,
813
- scope: z2.string().nullable(),
814
- description: z2.string(),
1133
+ scope: z3.string().nullable(),
1134
+ description: z3.string(),
815
1135
  schemas: SurfaceSchemaDigestsSchema,
816
1136
  mcp: SurfaceManifestOperationMcpSchema,
817
1137
  toolView: SurfaceManifestOperationToolViewSchema.optional(),
818
- http: z2.array(z2.object({ method: HttpMethodSchema, path: z2.string() }))
1138
+ http: z3.array(z3.object({ method: HttpMethodSchema, path: z3.string() }))
819
1139
  });
820
- var SurfaceManifestToolSchema = z2.object({
821
- kind: z2.enum(["contract", "runtime"]),
822
- service: z2.string(),
823
- action: z2.string(),
824
- name: z2.string(),
825
- input: z2.string()
1140
+ var SurfaceManifestToolSchema = z3.object({
1141
+ kind: z3.enum(["contract", "runtime"]),
1142
+ service: z3.string(),
1143
+ action: z3.string(),
1144
+ name: z3.string(),
1145
+ input: z3.string()
826
1146
  });
827
- var SurfaceManifestToolSurfaceSchema = z2.object({
1147
+ var SurfaceManifestToolSurfaceSchema = z3.object({
828
1148
  transport: ToolTransportSchema,
829
- surface: z2.string().nullable(),
830
- tools: z2.array(SurfaceManifestToolSchema)
1149
+ surface: z3.string().nullable(),
1150
+ tools: z3.array(SurfaceManifestToolSchema)
831
1151
  });
832
- var SurfaceManifestCliCommandSchema = z2.object({
833
- name: z2.string(),
834
- description: z2.string(),
835
- input: z2.string(),
836
- output: z2.string().nullable()
1152
+ var SurfaceManifestCliCommandSchema = z3.object({
1153
+ name: z3.string(),
1154
+ description: z3.string(),
1155
+ input: z3.string(),
1156
+ output: z3.string().nullable()
837
1157
  });
838
- var SurfaceManifestExtensionSchema = z2.object({
839
- name: z2.string(),
1158
+ var SurfaceManifestExtensionSchema = z3.object({
1159
+ name: z3.string(),
840
1160
  transport: SurfaceTransportSchema
841
1161
  });
842
- var SurfaceRealtimeSchemaPairSchema = z2.object({
843
- input: z2.string(),
844
- output: z2.string()
1162
+ var SurfaceRealtimeSchemaPairSchema = z3.object({
1163
+ input: z3.string(),
1164
+ output: z3.string()
845
1165
  });
846
- var SurfaceManifestRealtimeEventSchema = z2.object({
847
- contract: z2.string(),
848
- direction: z2.enum(["serverToClient", "clientToServer"]),
849
- event: z2.string(),
1166
+ var SurfaceManifestRealtimeEventSchema = z3.object({
1167
+ contract: z3.string(),
1168
+ direction: z3.enum(["serverToClient", "clientToServer"]),
1169
+ event: z3.string(),
850
1170
  args: SurfaceRealtimeSchemaPairSchema,
851
1171
  acknowledgement: SurfaceRealtimeSchemaPairSchema.nullable()
852
1172
  });
853
- var SurfaceManifestSchema = z2.object({
854
- manifestVersion: z2.literal(SURFACE_MANIFEST_VERSION),
855
- digestVersion: z2.literal(1),
856
- operations: z2.array(SurfaceManifestOperationSchema),
857
- toolSurfaces: z2.array(SurfaceManifestToolSurfaceSchema),
858
- realtimeContracts: z2.array(z2.string()),
859
- realtime: z2.array(SurfaceManifestRealtimeEventSchema),
860
- cliOnly: z2.array(SurfaceManifestCliCommandSchema),
861
- extensions: z2.array(SurfaceManifestExtensionSchema)
1173
+ var SurfaceManifestSchema = z3.object({
1174
+ manifestVersion: z3.literal(SURFACE_MANIFEST_VERSION),
1175
+ digestVersion: z3.literal(1),
1176
+ operations: z3.array(SurfaceManifestOperationSchema),
1177
+ toolSurfaces: z3.array(SurfaceManifestToolSurfaceSchema),
1178
+ realtimeContracts: z3.array(z3.string()),
1179
+ realtime: z3.array(SurfaceManifestRealtimeEventSchema),
1180
+ cliOnly: z3.array(SurfaceManifestCliCommandSchema),
1181
+ extensions: z3.array(SurfaceManifestExtensionSchema)
862
1182
  });
863
- var serializeSurfaceValue = serializeCanonicalJson;
864
1183
  function realtimeEvents(config, realtimeContracts) {
865
1184
  const realtime = [];
866
1185
  for (const contractName of realtimeContracts) {
@@ -1009,336 +1328,14 @@ function assertSurfaceManifestSnapshot(manifest, snapshot) {
1009
1328
  if (committed !== SURFACE_MANIFEST_VERSION) {
1010
1329
  throw new Error(`Surface snapshot is manifestVersion ${String(committed)}; this build writes ` + `${SURFACE_MANIFEST_VERSION}. Regenerate it and review the diff — the format ` + "changed, so the first regeneration is expected to be large.");
1011
1330
  }
1012
- const actual = serializeSurfaceValue(SurfaceManifestSchema.parse(manifest));
1013
- const expected = serializeSurfaceValue(SurfaceManifestSchema.parse(snapshot));
1331
+ const actual = serializeCanonicalJson(SurfaceManifestSchema.parse(manifest));
1332
+ const expected = serializeCanonicalJson(SurfaceManifestSchema.parse(snapshot));
1014
1333
  if (actual !== expected) {
1015
1334
  throw new Error(`Surface manifest diverged from its committed snapshot
1016
1335
  expected: ${expected}
1017
1336
  actual: ${actual}`);
1018
1337
  }
1019
1338
  }
1020
-
1021
- // src/testing/surface-conformance.ts
1022
- var RealtimeRejectionObservationSchema = z3.object({
1023
- direction: RealtimeRejectDirectionSchema,
1024
- phase: RealtimeRejectPhaseSchema,
1025
- reason: RealtimeRejectReasonSchema,
1026
- fault: RealtimeRejectFaultSchema
1027
- });
1028
- var ObservationFields = {
1029
- code: z3.string().optional(),
1030
- data: z3.unknown().optional(),
1031
- diagnostic: z3.string().optional(),
1032
- handlerCalls: z3.number().int().nonnegative().optional()
1033
- };
1034
- var RealtimeDisconnectObservationSchema = z3.object({
1035
- phase: z3.enum(["before-invoke", "in-flight"])
1036
- });
1037
- var TransportObservationSchema = z3.discriminatedUnion("outcome", [
1038
- z3.object({ outcome: z3.literal("success"), ...ObservationFields }),
1039
- z3.object({ outcome: z3.literal("validation_error"), ...ObservationFields }),
1040
- z3.object({ outcome: z3.literal("domain_error"), ...ObservationFields }),
1041
- z3.object({ outcome: z3.literal("aborted"), ...ObservationFields }),
1042
- z3.object({
1043
- outcome: z3.literal("realtime_rejected"),
1044
- ...ObservationFields,
1045
- rejection: RealtimeRejectionObservationSchema
1046
- }),
1047
- z3.object({
1048
- outcome: z3.literal("disconnected"),
1049
- ...ObservationFields,
1050
- disconnect: RealtimeDisconnectObservationSchema
1051
- }),
1052
- z3.object({ outcome: z3.literal("timeout"), ...ObservationFields })
1053
- ]);
1054
- function sorted(values) {
1055
- return [...values].sort((left, right) => left < right ? -1 : left > right ? 1 : 0);
1056
- }
1057
- function assertSameSet(label, expectedValues, actualValues) {
1058
- const expected = sorted(expectedValues);
1059
- const actual = sorted(actualValues);
1060
- if (serializeSurfaceValue(expected) === serializeSurfaceValue(actual))
1061
- return;
1062
- throw new Error(`${label} mismatch
1063
- expected: ${expected.join(", ") || "(empty)"}
1064
- actual: ${actual.join(", ") || "(empty)"}`);
1065
- }
1066
- function openApiOperations(document) {
1067
- return Object.entries(document.paths).flatMap(([path, item]) => Object.keys(item).filter((method) => ["get", "post", "put", "patch", "delete", "head"].includes(method)).map((method) => `${method.toUpperCase()}:${path}`));
1068
- }
1069
- function expectedToolNames(manifest, transport, surface) {
1070
- const projection = manifest.toolSurfaces.find((candidate) => candidate.transport === transport && candidate.surface === surface);
1071
- if (!projection) {
1072
- throw new Error(`${transport} surface "${surface ?? "(default)"}" is not declared in the manifest`);
1073
- }
1074
- return projection.tools.map((tool) => tool.name);
1075
- }
1076
- function assertSurfaceDiscovery(manifest, observed) {
1077
- if (observed.openApi) {
1078
- assertSameSet("HTTP/OpenAPI", manifest.operations.flatMap((operation) => operation.http.map((entry) => `${entry.method}:${entry.path.replace(/:([^/]+)/g, "{$1}")}`)), openApiOperations(observed.openApi));
1079
- }
1080
- for (const transport of TOOL_TRANSPORTS2) {
1081
- const names = observed[transport];
1082
- if (names) {
1083
- assertSameSet(`${transport} discovery`, expectedToolNames(manifest, transport, null), names);
1084
- }
1085
- }
1086
- for (const projection of observed.toolSurfaces ?? []) {
1087
- assertSameSet(`${projection.transport} surface "${projection.surface ?? "(default)"}" discovery`, expectedToolNames(manifest, projection.transport, projection.surface ?? null), projection.names);
1088
- }
1089
- for (const [contract, topology] of Object.entries(observed.realtime ?? {})) {
1090
- if (!manifest.realtimeContracts.includes(contract)) {
1091
- throw new Error(`REALTIME contract "${contract}" is not declared in the manifest`);
1092
- }
1093
- for (const direction of ["serverToClient", "clientToServer"]) {
1094
- assertSameSet(`REALTIME ${contract}.${direction} discovery`, manifest.realtime.filter((entry) => entry.contract === contract && entry.direction === direction).map((entry) => entry.event), topology[direction]);
1095
- }
1096
- }
1097
- if (observed.cliOnly) {
1098
- assertSameSet("CLI-only discovery", manifest.cliOnly.map((command) => command.name), observed.cliOnly);
1099
- }
1100
- for (const transport of [
1101
- "HTTP",
1102
- "MCP",
1103
- "AGENT",
1104
- "CLI",
1105
- "REALTIME"
1106
- ]) {
1107
- const names = observed.extensions?.[transport];
1108
- if (!names)
1109
- continue;
1110
- assertSameSet(`${transport} extension discovery`, manifest.extensions.filter((extension) => extension.transport === transport).map((extension) => extension.name), names);
1111
- }
1112
- }
1113
- function boundedObservation(observation, maxDiagnosticBytes) {
1114
- const parsed = TransportObservationSchema.parse(observation);
1115
- if (!parsed.diagnostic)
1116
- return parsed;
1117
- const bytes = new TextEncoder().encode(parsed.diagnostic);
1118
- if (bytes.byteLength <= maxDiagnosticBytes)
1119
- return parsed;
1120
- return {
1121
- ...parsed,
1122
- diagnostic: new TextDecoder().decode(bytes.slice(0, maxDiagnosticBytes))
1123
- };
1124
- }
1125
- async function runBounded(run, signal) {
1126
- if (signal.aborted) {
1127
- Promise.resolve().then(run).catch(() => {
1128
- return;
1129
- });
1130
- throw signal.reason;
1131
- }
1132
- let removeAbortListener = () => {
1133
- return;
1134
- };
1135
- const aborted = new Promise((_resolve, reject) => {
1136
- const onAbort = () => reject(signal.reason);
1137
- signal.addEventListener("abort", onAbort, { once: true });
1138
- removeAbortListener = () => signal.removeEventListener("abort", onAbort);
1139
- });
1140
- try {
1141
- return await Promise.race([Promise.resolve().then(run), aborted]);
1142
- } finally {
1143
- removeAbortListener();
1144
- }
1145
- }
1146
- async function runSurfaceProbes({
1147
- probes,
1148
- drivers,
1149
- signal,
1150
- timeoutMs = 1e4,
1151
- maxDiagnosticBytes = 4096
1152
- }) {
1153
- if (!Number.isInteger(timeoutMs) || timeoutMs <= 0) {
1154
- throw new TypeError("Surface probe timeoutMs must be a positive integer");
1155
- }
1156
- if (!Number.isInteger(maxDiagnosticBytes) || maxDiagnosticBytes <= 0) {
1157
- throw new TypeError("Surface probe maxDiagnosticBytes must be a positive integer");
1158
- }
1159
- for (const probe of probes) {
1160
- const timeoutSignal = AbortSignal.timeout(timeoutMs);
1161
- const probeSignal = signal ? AbortSignal.any([signal, timeoutSignal]) : timeoutSignal;
1162
- let failed = false;
1163
- let failure;
1164
- try {
1165
- probeSignal.throwIfAborted();
1166
- if (probe.setup)
1167
- await runBounded(() => probe.setup?.(probeSignal), probeSignal);
1168
- for (const transport of probe.transports) {
1169
- probeSignal.throwIfAborted();
1170
- const driver = drivers[transport];
1171
- if (!driver) {
1172
- throw new Error(`Surface probe "${probe.name}" has no ${transport} driver`);
1173
- }
1174
- const actual = boundedObservation(await runBounded(() => driver.invoke(probe.fixture, probeSignal), probeSignal), maxDiagnosticBytes);
1175
- const expected = probe.expected[transport];
1176
- if (!expected) {
1177
- throw new Error(`Surface probe "${probe.name}" has no ${transport} expectation`);
1178
- }
1179
- if (serializeSurfaceValue(actual) !== serializeSurfaceValue(expected)) {
1180
- throw new Error(`Surface probe "${probe.name}" ${transport} mismatch
1181
- expected: ${serializeSurfaceValue(expected)}
1182
- actual: ${serializeSurfaceValue(actual)}`);
1183
- }
1184
- }
1185
- } catch (error) {
1186
- failed = true;
1187
- failure = error;
1188
- }
1189
- if (probe.teardown) {
1190
- try {
1191
- await runBounded(() => probe.teardown?.(probeSignal), probeSignal);
1192
- } catch (error) {
1193
- if (!failed) {
1194
- failed = true;
1195
- failure = error;
1196
- }
1197
- }
1198
- }
1199
- if (failed)
1200
- throw failure;
1201
- }
1202
- }
1203
-
1204
- // src/testing/realtime-probe.ts
1205
- function scenarioOutcome(scenario) {
1206
- if (scenario === "event" || scenario === "acknowledgement")
1207
- return "success";
1208
- if (scenario === "invalid_arguments" || scenario === "invalid_acknowledgement" || scenario === "peer_rejection") {
1209
- return "realtime_rejected";
1210
- }
1211
- if (scenario === "disconnected" || scenario === "in_flight_disconnect") {
1212
- return "disconnected";
1213
- }
1214
- return "timeout";
1215
- }
1216
- function assertScenarioExpectation(scenario, expected) {
1217
- const outcome = scenarioOutcome(scenario);
1218
- if (expected.outcome !== outcome) {
1219
- throw new TypeError(`Realtime probe scenario "${scenario}" requires outcome "${outcome}"`);
1220
- }
1221
- if (expected.outcome === "realtime_rejected" && (scenario === "invalid_arguments" && expected.rejection.phase !== "arguments" || scenario === "invalid_acknowledgement" && expected.rejection.phase !== "acknowledgement")) {
1222
- throw new TypeError(`Realtime probe scenario "${scenario}" has incompatible rejection phase`);
1223
- }
1224
- if (scenario === "invalid_arguments" && expected.handlerCalls !== 0) {
1225
- throw new TypeError('Realtime probe scenario "invalid_arguments" requires handlerCalls: 0');
1226
- }
1227
- if (scenario === "peer_rejection" && (expected.outcome !== "realtime_rejected" || expected.rejection.reason !== "rejected-by-peer")) {
1228
- throw new TypeError('Realtime probe scenario "peer_rejection" requires a rejected-by-peer outcome');
1229
- }
1230
- if (expected.outcome === "disconnected") {
1231
- const phase = scenario === "disconnected" ? "before-invoke" : "in-flight";
1232
- if (expected.disconnect.phase !== phase) {
1233
- throw new TypeError(`Realtime probe scenario "${scenario}" requires disconnect phase "${phase}"`);
1234
- }
1235
- }
1236
- }
1237
- function defineRealtimeProbe(config) {
1238
- const expected = TransportObservationSchema.parse(config.expected);
1239
- assertScenarioExpectation(config.scenario, expected);
1240
- return {
1241
- name: config.name,
1242
- fixture: { scenario: config.scenario, value: config.fixture },
1243
- transports: ["REALTIME"],
1244
- expected: { REALTIME: expected },
1245
- setup: config.setup,
1246
- teardown: config.teardown
1247
- };
1248
- }
1249
- function rejectionObservation(rejected) {
1250
- return RealtimeRejectionObservationSchema.parse(rejected);
1251
- }
1252
- function createRealtimeProbeDriver({
1253
- bind,
1254
- handlerCalls
1255
- }) {
1256
- return {
1257
- async invoke(fixture, signal) {
1258
- let rejected;
1259
- const currentRejection = () => rejected;
1260
- const adapter = bind((event) => {
1261
- rejected = event;
1262
- }, fixture);
1263
- const connectedBefore = adapter.connected();
1264
- const callsBefore = handlerCalls?.();
1265
- const withCalls = (observation) => {
1266
- if (callsBefore === undefined || !handlerCalls)
1267
- return observation;
1268
- return { ...observation, handlerCalls: handlerCalls() - callsBefore };
1269
- };
1270
- try {
1271
- signal.throwIfAborted();
1272
- const data = await adapter.invoke(fixture, signal);
1273
- const observedRejection = currentRejection();
1274
- if (observedRejection) {
1275
- return withCalls({
1276
- outcome: "realtime_rejected",
1277
- code: observedRejection.error.code,
1278
- rejection: rejectionObservation(observedRejection)
1279
- });
1280
- }
1281
- return withCalls({
1282
- outcome: "success",
1283
- ...data !== undefined && { data }
1284
- });
1285
- } catch (error) {
1286
- const observedRejection = currentRejection();
1287
- if (observedRejection) {
1288
- return withCalls({
1289
- outcome: "realtime_rejected",
1290
- code: error instanceof RealtimeRequestInvalidAcknowledgementError2 ? error.code : observedRejection.error.code,
1291
- rejection: rejectionObservation(observedRejection)
1292
- });
1293
- }
1294
- if (error instanceof RealtimeRequestInvalidAcknowledgementError2) {
1295
- return withCalls({
1296
- outcome: "realtime_rejected",
1297
- code: error.code,
1298
- rejection: {
1299
- direction: "client-inbound",
1300
- phase: "acknowledgement",
1301
- reason: "invalid-acknowledgement-value",
1302
- fault: "peer"
1303
- }
1304
- });
1305
- }
1306
- if (error instanceof RealtimeRequestDisconnectedError2) {
1307
- return withCalls({
1308
- outcome: "disconnected",
1309
- code: error.code,
1310
- disconnect: {
1311
- phase: connectedBefore ? "in-flight" : "before-invoke"
1312
- }
1313
- });
1314
- }
1315
- if (error instanceof RealtimeRequestTimeoutError2) {
1316
- return withCalls({ outcome: "timeout", code: error.code });
1317
- }
1318
- if (signal.aborted && error === signal.reason) {
1319
- return withCalls({ outcome: "aborted" });
1320
- }
1321
- const parsedRejection = RealtimeRejectionObservationSchema.safeParse(typeof error === "object" && error !== null && "details" in error ? error.details : undefined);
1322
- if (parsedRejection.success) {
1323
- const code = typeof error === "object" && error !== null && "code" in error ? String(error.code) : "REALTIME_CONTRACT_VIOLATION";
1324
- return withCalls({
1325
- outcome: "realtime_rejected",
1326
- code,
1327
- rejection: parsedRejection.data
1328
- });
1329
- }
1330
- const code = typeof error === "object" && error !== null && "code" in error ? String(error.code) : undefined;
1331
- return withCalls({
1332
- outcome: "domain_error",
1333
- ...code !== undefined && { code },
1334
- diagnostic: error instanceof Error ? error.message : String(error)
1335
- });
1336
- } finally {
1337
- await adapter.dispose?.();
1338
- }
1339
- }
1340
- };
1341
- }
1342
1339
  export {
1343
1340
  ManagedResourceConformanceError,
1344
1341
  ManagedResourceConformancePhaseSchema,
@@ -1368,6 +1365,5 @@ export {
1368
1365
  createRealtimeProbeDriver,
1369
1366
  defineRealtimeProbe,
1370
1367
  runManagedResourceConformance,
1371
- runSurfaceProbes,
1372
- serializeSurfaceValue
1368
+ runSurfaceProbes
1373
1369
  };