@moltzap/client 2026.529.0 → 2026.717.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 (363) hide show
  1. package/dist/agent-client.d.ts +2 -65
  2. package/dist/agent-client.d.ts.map +1 -1
  3. package/dist/agent-client.js +1 -286
  4. package/dist/agent-client.js.map +1 -1
  5. package/dist/app-client.d.ts +3 -0
  6. package/dist/app-client.d.ts.map +1 -0
  7. package/dist/app-client.js +2 -0
  8. package/dist/app-client.js.map +1 -0
  9. package/dist/auth.d.ts +6 -15
  10. package/dist/auth.d.ts.map +1 -1
  11. package/dist/auth.js +12 -16
  12. package/dist/auth.js.map +1 -1
  13. package/dist/channel-base/format-cross-conv.d.ts +10 -15
  14. package/dist/channel-base/format-cross-conv.d.ts.map +1 -1
  15. package/dist/channel-base/format-cross-conv.js +10 -15
  16. package/dist/channel-base/format-cross-conv.js.map +1 -1
  17. package/dist/channel-base/format-group-block.d.ts +8 -10
  18. package/dist/channel-base/format-group-block.d.ts.map +1 -1
  19. package/dist/channel-base/format-group-block.js +8 -10
  20. package/dist/channel-base/format-group-block.js.map +1 -1
  21. package/dist/channel-base/index.d.ts +3 -62
  22. package/dist/channel-base/index.d.ts.map +1 -1
  23. package/dist/channel-base/index.js +2 -65
  24. package/dist/channel-base/index.js.map +1 -1
  25. package/dist/channel-base/lease-guard.d.ts +0 -2
  26. package/dist/channel-base/lease-guard.d.ts.map +1 -1
  27. package/dist/channel-base/lease-guard.js +0 -2
  28. package/dist/channel-base/lease-guard.js.map +1 -1
  29. package/dist/channel-base/lease-store.d.ts +2 -3
  30. package/dist/channel-base/lease-store.d.ts.map +1 -1
  31. package/dist/channel-base/lease-store.js +2 -3
  32. package/dist/channel-base/lease-store.js.map +1 -1
  33. package/dist/channel-base/lease.d.ts +25 -31
  34. package/dist/channel-base/lease.d.ts.map +1 -1
  35. package/dist/channel-base/lease.js +29 -45
  36. package/dist/channel-base/lease.js.map +1 -1
  37. package/dist/channel-core-enrichment.d.ts +1 -1
  38. package/dist/channel-core-enrichment.d.ts.map +1 -1
  39. package/dist/channel-core-test-support.d.ts +17 -11
  40. package/dist/channel-core-test-support.d.ts.map +1 -1
  41. package/dist/channel-core-test-support.js +5 -6
  42. package/dist/channel-core-test-support.js.map +1 -1
  43. package/dist/channel-core.d.ts +24 -29
  44. package/dist/channel-core.d.ts.map +1 -1
  45. package/dist/channel-core.js +18 -42
  46. package/dist/channel-core.js.map +1 -1
  47. package/dist/cli/commands/agents.d.ts +3 -6
  48. package/dist/cli/commands/agents.d.ts.map +1 -1
  49. package/dist/cli/commands/agents.js +14 -50
  50. package/dist/cli/commands/agents.js.map +1 -1
  51. package/dist/cli/commands/contacts.d.ts +5 -6
  52. package/dist/cli/commands/contacts.d.ts.map +1 -1
  53. package/dist/cli/commands/contacts.js +15 -43
  54. package/dist/cli/commands/contacts.js.map +1 -1
  55. package/dist/cli/commands/conversations.d.ts +8 -18
  56. package/dist/cli/commands/conversations.d.ts.map +1 -1
  57. package/dist/cli/commands/conversations.js +14 -65
  58. package/dist/cli/commands/conversations.js.map +1 -1
  59. package/dist/cli/commands/messages.d.ts +13 -35
  60. package/dist/cli/commands/messages.d.ts.map +1 -1
  61. package/dist/cli/commands/messages.js +21 -46
  62. package/dist/cli/commands/messages.js.map +1 -1
  63. package/dist/cli/commands/register.d.ts +10 -12
  64. package/dist/cli/commands/register.d.ts.map +1 -1
  65. package/dist/cli/commands/register.js +47 -133
  66. package/dist/cli/commands/register.js.map +1 -1
  67. package/dist/cli/commands/send.d.ts +23 -36
  68. package/dist/cli/commands/send.d.ts.map +1 -1
  69. package/dist/cli/commands/send.js +25 -72
  70. package/dist/cli/commands/send.js.map +1 -1
  71. package/dist/cli/commands/start.d.ts +10 -124
  72. package/dist/cli/commands/start.d.ts.map +1 -1
  73. package/dist/cli/commands/start.js +28 -510
  74. package/dist/cli/commands/start.js.map +1 -1
  75. package/dist/cli/commands/status.d.ts +1 -1
  76. package/dist/cli/commands/status.d.ts.map +1 -1
  77. package/dist/cli/commands/status.js +8 -9
  78. package/dist/cli/commands/status.js.map +1 -1
  79. package/dist/cli/commands/test-transport.d.ts +12 -5
  80. package/dist/cli/commands/test-transport.d.ts.map +1 -1
  81. package/dist/cli/commands/test-transport.js +15 -15
  82. package/dist/cli/commands/test-transport.js.map +1 -1
  83. package/dist/cli/index.js +13 -40
  84. package/dist/cli/index.js.map +1 -1
  85. package/dist/cli/output.d.ts +4 -0
  86. package/dist/cli/output.d.ts.map +1 -0
  87. package/dist/cli/output.js +9 -0
  88. package/dist/cli/output.js.map +1 -0
  89. package/dist/cli/socket-client.d.ts +7 -14
  90. package/dist/cli/socket-client.d.ts.map +1 -1
  91. package/dist/cli/socket-client.js +15 -38
  92. package/dist/cli/socket-client.js.map +1 -1
  93. package/dist/cli/transport.d.ts +53 -116
  94. package/dist/cli/transport.d.ts.map +1 -1
  95. package/dist/cli/transport.js +45 -295
  96. package/dist/cli/transport.js.map +1 -1
  97. package/dist/config.d.ts +24 -0
  98. package/dist/config.d.ts.map +1 -0
  99. package/dist/config.js +35 -0
  100. package/dist/config.js.map +1 -0
  101. package/dist/config.test-utils.d.ts +13 -0
  102. package/dist/config.test-utils.d.ts.map +1 -0
  103. package/dist/config.test-utils.js +46 -0
  104. package/dist/config.test-utils.js.map +1 -0
  105. package/dist/index.d.ts +3 -8
  106. package/dist/index.d.ts.map +1 -1
  107. package/dist/index.js +2 -12
  108. package/dist/index.js.map +1 -1
  109. package/dist/local-daemon-rpc.d.ts +259 -8
  110. package/dist/local-daemon-rpc.d.ts.map +1 -1
  111. package/dist/local-daemon-rpc.js +189 -12
  112. package/dist/local-daemon-rpc.js.map +1 -1
  113. package/dist/{runtime/local-history.d.ts → local-history.d.ts} +16 -21
  114. package/dist/local-history.d.ts.map +1 -0
  115. package/dist/{runtime/local-history.js → local-history.js} +16 -21
  116. package/dist/local-history.js.map +1 -0
  117. package/dist/local-paths.d.ts +0 -2
  118. package/dist/local-paths.d.ts.map +1 -1
  119. package/dist/local-paths.js +0 -4
  120. package/dist/local-paths.js.map +1 -1
  121. package/dist/local-socket-server.d.ts +22 -0
  122. package/dist/local-socket-server.d.ts.map +1 -0
  123. package/dist/{runtime/local-socket-server.js → local-socket-server.js} +4 -9
  124. package/dist/local-socket-server.js.map +1 -0
  125. package/dist/message-rendering.d.ts +3 -0
  126. package/dist/message-rendering.d.ts.map +1 -0
  127. package/dist/message-rendering.js +7 -0
  128. package/dist/message-rendering.js.map +1 -0
  129. package/dist/notification/__tests__/{snapshot-semantics.types-check.d.ts → subscribe-signatures.types-check.d.ts} +1 -1
  130. package/dist/notification/__tests__/subscribe-signatures.types-check.d.ts.map +1 -0
  131. package/dist/notification/__tests__/subscribe-signatures.types-check.js +55 -0
  132. package/dist/notification/__tests__/subscribe-signatures.types-check.js.map +1 -0
  133. package/dist/notification/errors.d.ts +18 -6
  134. package/dist/notification/errors.d.ts.map +1 -1
  135. package/dist/notification/errors.js +13 -15
  136. package/dist/notification/errors.js.map +1 -1
  137. package/dist/notification/index.d.ts +5 -0
  138. package/dist/notification/index.d.ts.map +1 -0
  139. package/dist/notification/index.js +5 -0
  140. package/dist/notification/index.js.map +1 -0
  141. package/dist/notification/stream.d.ts +33 -49
  142. package/dist/notification/stream.d.ts.map +1 -1
  143. package/dist/notification/stream.js +33 -76
  144. package/dist/notification/stream.js.map +1 -1
  145. package/dist/pagination.d.ts +20 -10
  146. package/dist/pagination.d.ts.map +1 -1
  147. package/dist/pagination.js +8 -9
  148. package/dist/pagination.js.map +1 -1
  149. package/dist/profile.d.ts +92 -0
  150. package/dist/profile.d.ts.map +1 -0
  151. package/dist/profile.js +149 -0
  152. package/dist/profile.js.map +1 -0
  153. package/dist/refs.d.ts.map +1 -0
  154. package/dist/refs.js.map +1 -0
  155. package/dist/service-archive-purge.d.ts +2 -1
  156. package/dist/service-archive-purge.d.ts.map +1 -1
  157. package/dist/service-archive-purge.js.map +1 -1
  158. package/dist/{runtime/service-helpers.d.ts → service-helpers.d.ts} +5 -11
  159. package/dist/service-helpers.d.ts.map +1 -0
  160. package/dist/{runtime/service-helpers.js → service-helpers.js} +2 -9
  161. package/dist/service-helpers.js.map +1 -0
  162. package/dist/service-local-daemon.d.ts +22 -0
  163. package/dist/service-local-daemon.d.ts.map +1 -0
  164. package/dist/service-local-daemon.js +185 -0
  165. package/dist/service-local-daemon.js.map +1 -0
  166. package/dist/service.d.ts +65 -57
  167. package/dist/service.d.ts.map +1 -1
  168. package/dist/service.js +205 -156
  169. package/dist/service.js.map +1 -1
  170. package/dist/test-utils/channel-service-fixture.d.ts +3 -2
  171. package/dist/test-utils/channel-service-fixture.d.ts.map +1 -1
  172. package/dist/test-utils/channel-service-fixture.js.map +1 -1
  173. package/dist/test-utils/fake-service.d.ts +26 -18
  174. package/dist/test-utils/fake-service.d.ts.map +1 -1
  175. package/dist/test-utils/fake-service.js +28 -42
  176. package/dist/test-utils/fake-service.js.map +1 -1
  177. package/dist/test-utils/ids.d.ts +3 -1
  178. package/dist/test-utils/ids.d.ts.map +1 -1
  179. package/dist/test-utils/ids.js.map +1 -1
  180. package/dist/test-utils/index.d.ts +9 -2
  181. package/dist/test-utils/index.d.ts.map +1 -1
  182. package/dist/test-utils/index.js +8 -1
  183. package/dist/test-utils/index.js.map +1 -1
  184. package/dist/test-utils/standalone-provisioning.d.ts +17 -0
  185. package/dist/test-utils/standalone-provisioning.d.ts.map +1 -0
  186. package/dist/test-utils/standalone-provisioning.js +14 -0
  187. package/dist/test-utils/standalone-provisioning.js.map +1 -0
  188. package/dist/tsconfig.tsbuildinfo +1 -0
  189. package/package.json +39 -17
  190. package/dist/auth.test.d.ts +0 -2
  191. package/dist/auth.test.d.ts.map +0 -1
  192. package/dist/auth.test.js +0 -121
  193. package/dist/auth.test.js.map +0 -1
  194. package/dist/channel-core-context.test.d.ts +0 -2
  195. package/dist/channel-core-context.test.d.ts.map +0 -1
  196. package/dist/channel-core-context.test.js +0 -342
  197. package/dist/channel-core-context.test.js.map +0 -1
  198. package/dist/channel-core-dispatch.test.d.ts +0 -2
  199. package/dist/channel-core-dispatch.test.d.ts.map +0 -1
  200. package/dist/channel-core-dispatch.test.js +0 -557
  201. package/dist/channel-core-dispatch.test.js.map +0 -1
  202. package/dist/channel-core.test.d.ts +0 -2
  203. package/dist/channel-core.test.d.ts.map +0 -1
  204. package/dist/channel-core.test.js +0 -232
  205. package/dist/channel-core.test.js.map +0 -1
  206. package/dist/cli/__tests__/cli-multi-agent.int.test.d.ts +0 -2
  207. package/dist/cli/__tests__/cli-multi-agent.int.test.d.ts.map +0 -1
  208. package/dist/cli/__tests__/cli-multi-agent.int.test.js +0 -132
  209. package/dist/cli/__tests__/cli-multi-agent.int.test.js.map +0 -1
  210. package/dist/cli/commands/invite.d.ts +0 -7
  211. package/dist/cli/commands/invite.d.ts.map +0 -1
  212. package/dist/cli/commands/invite.js +0 -11
  213. package/dist/cli/commands/invite.js.map +0 -1
  214. package/dist/cli/commands/messages.test.d.ts +0 -2
  215. package/dist/cli/commands/messages.test.d.ts.map +0 -1
  216. package/dist/cli/commands/messages.test.js +0 -99
  217. package/dist/cli/commands/messages.test.js.map +0 -1
  218. package/dist/cli/commands/ping.d.ts +0 -7
  219. package/dist/cli/commands/ping.d.ts.map +0 -1
  220. package/dist/cli/commands/ping.js +0 -37
  221. package/dist/cli/commands/ping.js.map +0 -1
  222. package/dist/cli/commands/register.test.d.ts +0 -2
  223. package/dist/cli/commands/register.test.d.ts.map +0 -1
  224. package/dist/cli/commands/register.test.js +0 -91
  225. package/dist/cli/commands/register.test.js.map +0 -1
  226. package/dist/cli/commands/send.test.d.ts +0 -2
  227. package/dist/cli/commands/send.test.d.ts.map +0 -1
  228. package/dist/cli/commands/send.test.js +0 -59
  229. package/dist/cli/commands/send.test.js.map +0 -1
  230. package/dist/cli/commands/start.test.d.ts +0 -2
  231. package/dist/cli/commands/start.test.d.ts.map +0 -1
  232. package/dist/cli/commands/start.test.js +0 -624
  233. package/dist/cli/commands/start.test.js.map +0 -1
  234. package/dist/cli/commands/whoami.d.ts +0 -8
  235. package/dist/cli/commands/whoami.d.ts.map +0 -1
  236. package/dist/cli/commands/whoami.js +0 -28
  237. package/dist/cli/commands/whoami.js.map +0 -1
  238. package/dist/cli/config.d.ts +0 -66
  239. package/dist/cli/config.d.ts.map +0 -1
  240. package/dist/cli/config.js +0 -148
  241. package/dist/cli/config.js.map +0 -1
  242. package/dist/cli/config.test.d.ts +0 -2
  243. package/dist/cli/config.test.d.ts.map +0 -1
  244. package/dist/cli/config.test.js +0 -89
  245. package/dist/cli/config.test.js.map +0 -1
  246. package/dist/cli/http-client.d.ts +0 -17
  247. package/dist/cli/http-client.d.ts.map +0 -1
  248. package/dist/cli/http-client.js +0 -38
  249. package/dist/cli/http-client.js.map +0 -1
  250. package/dist/cli/profile.d.ts +0 -126
  251. package/dist/cli/profile.d.ts.map +0 -1
  252. package/dist/cli/profile.js +0 -231
  253. package/dist/cli/profile.js.map +0 -1
  254. package/dist/cli/profile.test.d.ts +0 -2
  255. package/dist/cli/profile.test.d.ts.map +0 -1
  256. package/dist/cli/profile.test.js +0 -369
  257. package/dist/cli/profile.test.js.map +0 -1
  258. package/dist/cli/transport.test.d.ts +0 -2
  259. package/dist/cli/transport.test.d.ts.map +0 -1
  260. package/dist/cli/transport.test.js +0 -312
  261. package/dist/cli/transport.test.js.map +0 -1
  262. package/dist/notification/__tests__/filter-equivalence.test.d.ts +0 -2
  263. package/dist/notification/__tests__/filter-equivalence.test.d.ts.map +0 -1
  264. package/dist/notification/__tests__/filter-equivalence.test.js +0 -123
  265. package/dist/notification/__tests__/filter-equivalence.test.js.map +0 -1
  266. package/dist/notification/__tests__/snapshot-semantics.test.d.ts +0 -2
  267. package/dist/notification/__tests__/snapshot-semantics.test.d.ts.map +0 -1
  268. package/dist/notification/__tests__/snapshot-semantics.test.js +0 -261
  269. package/dist/notification/__tests__/snapshot-semantics.test.js.map +0 -1
  270. package/dist/notification/__tests__/snapshot-semantics.types-check.d.ts.map +0 -1
  271. package/dist/notification/__tests__/snapshot-semantics.types-check.js +0 -62
  272. package/dist/notification/__tests__/snapshot-semantics.types-check.js.map +0 -1
  273. package/dist/pagination.test.d.ts +0 -2
  274. package/dist/pagination.test.d.ts.map +0 -1
  275. package/dist/pagination.test.js +0 -72
  276. package/dist/pagination.test.js.map +0 -1
  277. package/dist/runtime/close-info.d.ts +0 -84
  278. package/dist/runtime/close-info.d.ts.map +0 -1
  279. package/dist/runtime/close-info.js +0 -102
  280. package/dist/runtime/close-info.js.map +0 -1
  281. package/dist/runtime/close-info.test.d.ts +0 -2
  282. package/dist/runtime/close-info.test.d.ts.map +0 -1
  283. package/dist/runtime/close-info.test.js +0 -109
  284. package/dist/runtime/close-info.test.js.map +0 -1
  285. package/dist/runtime/errors.d.ts +0 -11
  286. package/dist/runtime/errors.d.ts.map +0 -1
  287. package/dist/runtime/errors.js +0 -41
  288. package/dist/runtime/errors.js.map +0 -1
  289. package/dist/runtime/errors.test.d.ts +0 -2
  290. package/dist/runtime/errors.test.d.ts.map +0 -1
  291. package/dist/runtime/errors.test.js +0 -79
  292. package/dist/runtime/errors.test.js.map +0 -1
  293. package/dist/runtime/frame.d.ts +0 -8
  294. package/dist/runtime/frame.d.ts.map +0 -1
  295. package/dist/runtime/frame.js +0 -12
  296. package/dist/runtime/frame.js.map +0 -1
  297. package/dist/runtime/frame.test.d.ts +0 -2
  298. package/dist/runtime/frame.test.d.ts.map +0 -1
  299. package/dist/runtime/frame.test.js +0 -59
  300. package/dist/runtime/frame.test.js.map +0 -1
  301. package/dist/runtime/index.d.ts +0 -10
  302. package/dist/runtime/index.d.ts.map +0 -1
  303. package/dist/runtime/index.js +0 -9
  304. package/dist/runtime/index.js.map +0 -1
  305. package/dist/runtime/local-history.d.ts.map +0 -1
  306. package/dist/runtime/local-history.js.map +0 -1
  307. package/dist/runtime/local-service-commands.d.ts +0 -26
  308. package/dist/runtime/local-service-commands.d.ts.map +0 -1
  309. package/dist/runtime/local-service-commands.js +0 -29
  310. package/dist/runtime/local-service-commands.js.map +0 -1
  311. package/dist/runtime/local-socket-server.d.ts +0 -20
  312. package/dist/runtime/local-socket-server.d.ts.map +0 -1
  313. package/dist/runtime/local-socket-server.js.map +0 -1
  314. package/dist/runtime/refs.d.ts.map +0 -1
  315. package/dist/runtime/refs.js.map +0 -1
  316. package/dist/runtime/runtime.test.d.ts +0 -2
  317. package/dist/runtime/runtime.test.d.ts.map +0 -1
  318. package/dist/runtime/runtime.test.js +0 -37
  319. package/dist/runtime/runtime.test.js.map +0 -1
  320. package/dist/runtime/service-helpers.d.ts.map +0 -1
  321. package/dist/runtime/service-helpers.js.map +0 -1
  322. package/dist/runtime/service-teardown.d.ts +0 -5
  323. package/dist/runtime/service-teardown.d.ts.map +0 -1
  324. package/dist/runtime/service-teardown.js +0 -36
  325. package/dist/runtime/service-teardown.js.map +0 -1
  326. package/dist/runtime/service-teardown.test.d.ts +0 -2
  327. package/dist/runtime/service-teardown.test.d.ts.map +0 -1
  328. package/dist/runtime/service-teardown.test.js +0 -80
  329. package/dist/runtime/service-teardown.test.js.map +0 -1
  330. package/dist/runtime/subscribers.d.ts +0 -152
  331. package/dist/runtime/subscribers.d.ts.map +0 -1
  332. package/dist/runtime/subscribers.js +0 -222
  333. package/dist/runtime/subscribers.js.map +0 -1
  334. package/dist/service-socket-path.test.d.ts +0 -2
  335. package/dist/service-socket-path.test.d.ts.map +0 -1
  336. package/dist/service-socket-path.test.js +0 -87
  337. package/dist/service-socket-path.test.js.map +0 -1
  338. package/dist/service.test.d.ts +0 -2
  339. package/dist/service.test.d.ts.map +0 -1
  340. package/dist/service.test.js +0 -796
  341. package/dist/service.test.js.map +0 -1
  342. package/dist/test/index.d.ts +0 -47
  343. package/dist/test/index.d.ts.map +0 -1
  344. package/dist/test/index.js +0 -39
  345. package/dist/test/index.js.map +0 -1
  346. package/dist/test-utils/conformance-adapter.d.ts +0 -40
  347. package/dist/test-utils/conformance-adapter.d.ts.map +0 -1
  348. package/dist/test-utils/conformance-adapter.js +0 -250
  349. package/dist/test-utils/conformance-adapter.js.map +0 -1
  350. package/dist/tm-client-test-support.d.ts +0 -184
  351. package/dist/tm-client-test-support.d.ts.map +0 -1
  352. package/dist/tm-client-test-support.js +0 -466
  353. package/dist/tm-client-test-support.js.map +0 -1
  354. package/dist/tm-client.d.ts +0 -269
  355. package/dist/tm-client.d.ts.map +0 -1
  356. package/dist/tm-client.js +0 -518
  357. package/dist/tm-client.js.map +0 -1
  358. package/dist/tm-client.test.d.ts +0 -2
  359. package/dist/tm-client.test.d.ts.map +0 -1
  360. package/dist/tm-client.test.js +0 -490
  361. package/dist/tm-client.test.js.map +0 -1
  362. /package/dist/{runtime/refs.d.ts → refs.d.ts} +0 -0
  363. /package/dist/{runtime/refs.js → refs.js} +0 -0
@@ -1,184 +0,0 @@
1
- import { Cause, Duration, Effect, Fiber, Scope, TestClock } from "effect";
2
- import { MoltZapTMClient, RPC_TIMEOUT_MS, type TMHandlers, type CloseInfo } from "./tm-client.js";
3
- import { ForbiddenError, RpcTimeoutError, type ParamsOf } from "@moltzap/protocol";
4
- import { AgentsLookupByName, DispatchAuthorize, TaskList, MessagesSend, MessageReceivedNotificationDefinition, type NotificationFrame, type RequestFrame, type RpcDefinition } from "@moltzap/protocol";
5
- import { JSON_RPC_VERSION, validateResponseFrame } from "@moltzap/protocol/testing";
6
- declare const effectTest: (name: string, effect: () => Effect.Effect<unknown, unknown>, timeout?: number) => void;
7
- declare const scopedEffectTest: import("@effect/vitest").Vitest.Tester<Scope.Scope | import("effect/TestServices").TestServices>;
8
- declare const SESSION_A = "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa";
9
- declare const SESSION_B = "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb";
10
- declare const dispatchRequestParams: (taskId: string) => {
11
- taskId: string;
12
- appId: string;
13
- conversationId: string;
14
- recipient: {
15
- agentId: string;
16
- ownerId: string;
17
- };
18
- message: {
19
- id: string;
20
- senderAgentId: string;
21
- parts: {
22
- type: "text";
23
- text: string;
24
- }[];
25
- };
26
- attempt: number;
27
- };
28
- type DispatchRequestParams = ReturnType<typeof dispatchRequestParams>;
29
- declare const LOCALHOST_HOST = "127.0.0.1";
30
- declare const TEST_AGENT_ID: string & import("effect/Brand").Brand<"AgentId">;
31
- declare const RECONNECT_AGENT_ID: string & import("effect/Brand").Brand<"AgentId">;
32
- declare const NORMAL_CLOSE_CODE = 1000;
33
- declare const SERVER_ERROR_CLOSE_CODE = 1011;
34
- declare const CONNECT_FAILURE_MAX_MS = 3000;
35
- declare const REFUSED_CONNECT_MAX_MS = 15000;
36
- declare const REFUSED_CONNECT_TEST_TIMEOUT_MS = 20000;
37
- declare const REALTIME_POLL_TIMEOUT_MS = 2000;
38
- declare const POST_TIMEOUT_SETTLE_MS = 50;
39
- declare const MALFORMED_FRAME_FLUSH_MS = 300;
40
- declare const CLIENT_DRAIN_COUNT = 10;
41
- declare const CLOSE_PROPAGATION_TIMEOUT_MS = 1000;
42
- declare const STALE_PORT_TEST_TIMEOUT_MS = 15000;
43
- declare const CLOSE_INFO_WAIT_MS = 2000;
44
- declare const HANDLER_REJECTION_CODE = -32001;
45
- declare const NORMAL_CLOSE_REASON = "normal";
46
- declare const SERVER_ERROR_REASON = "boom";
47
- declare const SERVER_TEST_REQUEST_ID = "srv-test-1";
48
- declare const SERVER_ERROR_REQUEST_ID = "srv-err-1";
49
- declare const GRANT_DECISION = "grant";
50
- declare const DOMAIN_REJECTED_MESSAGE = "domain-rejected";
51
- declare const DOMAIN_REJECTED_REASON = "test";
52
- declare const TEST_CONVERSATION_ID: string & import("effect/Brand").Brand<"ConversationId">;
53
- declare const TEST_TASK_ID: string & import("effect/Brand").Brand<"TaskId">;
54
- declare const messageReceivedFrame: () => {
55
- params?: unknown;
56
- jsonrpc: "2.0";
57
- method: string & import("effect/Brand").Brand<"JsonRpcMethod">;
58
- };
59
- /**
60
- * Per-connection context exposed to a handler so tests can inspect and
61
- * manipulate the live server-side socket.
62
- */
63
- interface TestServerConnection {
64
- /** Send a raw string frame to this client. */
65
- readonly send: (raw: string) => Effect.Effect<void>;
66
- /** Close this client's connection (CloseEvent code 1000 = clean). */
67
- readonly close: (code?: number, reason?: string) => Effect.Effect<void>;
68
- /** Every frame received from this client, in order. */
69
- readonly received: ReadonlyArray<string>;
70
- }
71
- /**
72
- * Handler invoked once per accepted server-side connection. Receives
73
- * (serverConn, rawFrame) per inbound frame. Return the raw string to respond,
74
- * `null` to drop, or throw a CloseEvent via `serverConn.close(code)`.
75
- */
76
- type ServerHandler = (conn: TestServerConnection, raw: string) => Effect.Effect<void>;
77
- interface MutableRef<A> {
78
- current: A;
79
- }
80
- interface TestServer {
81
- readonly url: string;
82
- /**
83
- * Accumulates every TestServerConnection ever accepted. Tests assert on
84
- * it to check e.g. no reconnect happened (length === 1).
85
- */
86
- readonly connections: ReadonlyArray<TestServerConnection>;
87
- }
88
- declare const ClosedLocalPortError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
89
- readonly _tag: "ClosedLocalPortError";
90
- } & Readonly<A>;
91
- declare class ClosedLocalPortError extends ClosedLocalPortError_base<{
92
- readonly cause: unknown;
93
- }> {
94
- }
95
- declare const WaitForTimeoutError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
96
- readonly _tag: "WaitForTimeoutError";
97
- } & Readonly<A>;
98
- declare class WaitForTimeoutError extends WaitForTimeoutError_base<{
99
- readonly timeoutMs: number;
100
- }> {
101
- }
102
- declare function findResponseRaw(server: TestServer, id: string): string | undefined;
103
- declare function waitForResponseRaw(server: TestServer, id: string): Effect.Effect<string | undefined, WaitForTimeoutError>;
104
- declare function waitForErrorResponse(server: TestServer, id: string): Effect.Effect<void, WaitForTimeoutError>;
105
- /**
106
- * Spin up an in-process `@effect/platform` WS server on `127.0.0.1:0`.
107
- * Caller owns the provided scope; when it closes, the server shuts down.
108
- */
109
- declare const startTestServer: (handler: ServerHandler) => Effect.Effect<TestServer, unknown, Scope.Scope>;
110
- declare const findClosedLocalPort: () => Effect.Effect<number, ClosedLocalPortError>;
111
- interface MakeClientOverrides {
112
- readonly onNotification?: (evt: NotificationFrame) => void;
113
- readonly onDisconnect?: (close: CloseInfo) => void;
114
- readonly onReconnect?: (hello: unknown) => void;
115
- readonly handlers?: TMHandlers;
116
- }
117
- declare const connectClient: (client: MoltZapTMClient) => Effect.Effect<{
118
- agentId: string & import("effect/Brand").Brand<"AgentId">;
119
- protocolVersion: string;
120
- policy: {
121
- maxMessageBytes: number;
122
- maxPartsPerMessage: number;
123
- maxTextLength: number;
124
- maxGroupParticipants: number;
125
- heartbeatIntervalMs: number;
126
- rateLimits: {
127
- messagesPerMinute: number;
128
- requestsPerMinute: number;
129
- };
130
- };
131
- }, import("@moltzap/protocol").RpcCallError | RpcTimeoutError, never>;
132
- declare const sendRpcEffect: <D extends RpcDefinition<string, any, any>>(client: MoltZapTMClient, definition: D, params: ParamsOf<D>) => Effect.Effect<import("@moltzap/protocol").ResultOf<D>, import("@moltzap/protocol").RpcCallError | RpcTimeoutError, never>;
133
- declare function expectEffectFailure<A, E, R>(effect: Effect.Effect<A, E, R>, pattern: RegExp): Effect.Effect<void, never, R>;
134
- declare const closeClient: (client: MoltZapTMClient) => Effect.Effect<void, never>;
135
- /**
136
- * Start a server whose handler auto-responds to `network/connect` and forwards
137
- * everything else to the test's `handler`. Useful for tests that only care
138
- * about post-handshake behaviour.
139
- */
140
- declare const startHandshakingServer: (handler: (conn: TestServerConnection, raw: string, frame: RequestFrame) => Effect.Effect<void>) => Effect.Effect<TestServer, unknown, Scope.Scope>;
141
- declare function startDispatchAuthorizeServer(requestId: string, params: DispatchRequestParams): Effect.Effect<TestServer, unknown, Scope.Scope>;
142
- declare const setRef: <A>(ref: MutableRef<A>) => (value: A) => void;
143
- declare function startReconnectServer(authResponses: MutableRef<number>): Effect.Effect<TestServer, unknown, Scope.Scope>;
144
- declare function sendMalformedFramesAndResponse(conn: TestServerConnection, _raw: string, frame: RequestFrame): Effect.Effect<void>;
145
- declare function sendPaddedNotificationAndResponse(conn: TestServerConnection, _raw: string, frame: RequestFrame): Effect.Effect<void>;
146
- declare function sendMalformedFrameBurst(conn: TestServerConnection): Effect.Effect<void>;
147
- declare function startAgentsLookupByNameServer(captured: MutableRef<RequestFrame | null>): Effect.Effect<TestServer, unknown, Scope.Scope>;
148
- declare function connectClientForServer(url: string): Effect.Effect<MoltZapTMClient, Effect.Effect.Error<ReturnType<typeof connectClient>>>;
149
- /**
150
- * Build a Spec F (#617) TM-callback handler-table fragment for the
151
- * `dispatch/authorize` slot that grants admission and records the
152
- * `taskId` it was invoked with into `observedTaskId`. Pass as
153
- * `appCallbackHandlers` to `makeClient` so the typed dispatcher sees
154
- * the binding at construction time.
155
- */
156
- declare function grantDispatchAuthorizeHandlers(observedTaskId: MutableRef<string | null>): TMHandlers;
157
- /**
158
- * Promise-returning wrapper that both runs a test Effect and keeps the scope
159
- * alive until the Effect completes. Tests that need a server scope should
160
- * use `withTestServer` rather than mutating a Scope manually.
161
- */
162
- declare const withTestServer: <A, E>(effect: Effect.Effect<A, E, Scope.Scope>) => Effect.Effect<A, E>;
163
- /**
164
- * Poll until `pred()` is true or `maxMs` elapses. The legacy test file used a
165
- * microtask-based loop; we keep that cadence to match the legacy behaviour
166
- * when synchronisation is driven by wall-clock timing in the test harness.
167
- */
168
- declare function waitFor(pred: () => boolean, { maxMs }?: {
169
- maxMs?: number;
170
- }): Effect.Effect<void, WaitForTimeoutError>;
171
- declare const realSleep: (ms: number) => Effect.Effect<void>;
172
- declare const closeWaitSocketOutput: Effect.Effect<string, never, never>;
173
- /**
174
- * Build a `MoltZapTMClient`. Spec #222 OQ-4 deletion: `onNotification` is no
175
- * longer a constructor option; tests that previously stashed an
176
- * `onNotification` callback now register a `subscribe({}, …)` subscription
177
- * post-construction. The helper accepts the same `onNotification` callback as
178
- * a convenience and wires it through the new subscription registry,
179
- * keeping migration noise local to the helper.
180
- */
181
- declare function makeClient(url: string, overrides?: MakeClientOverrides): MoltZapTMClient;
182
- export { AgentsLookupByName, TaskList, DispatchAuthorize, Duration, Fiber, ForbiddenError, MessageReceivedNotificationDefinition, MessagesSend, RpcTimeoutError, TestClock, closeClient, connectClient, connectClientForServer, dispatchRequestParams, effectTest, scopedEffectTest, expectEffectFailure, findClosedLocalPort, findResponseRaw, grantDispatchAuthorizeHandlers, makeClient, messageReceivedFrame, sendMalformedFrameBurst, sendMalformedFramesAndResponse, sendPaddedNotificationAndResponse, sendRpcEffect, setRef, startAgentsLookupByNameServer, startDispatchAuthorizeServer, startHandshakingServer, startReconnectServer, startTestServer, validateResponseFrame, waitFor, realSleep, waitForErrorResponse, waitForResponseRaw, withTestServer, closeWaitSocketOutput, JSON_RPC_VERSION, RPC_TIMEOUT_MS, LOCALHOST_HOST, TEST_AGENT_ID, RECONNECT_AGENT_ID, SESSION_A, SESSION_B, NORMAL_CLOSE_CODE, SERVER_ERROR_CLOSE_CODE, CONNECT_FAILURE_MAX_MS, REFUSED_CONNECT_MAX_MS, REFUSED_CONNECT_TEST_TIMEOUT_MS, REALTIME_POLL_TIMEOUT_MS, POST_TIMEOUT_SETTLE_MS, MALFORMED_FRAME_FLUSH_MS, CLIENT_DRAIN_COUNT, CLOSE_PROPAGATION_TIMEOUT_MS, STALE_PORT_TEST_TIMEOUT_MS, CLOSE_INFO_WAIT_MS, HANDLER_REJECTION_CODE, NORMAL_CLOSE_REASON, SERVER_ERROR_REASON, SERVER_TEST_REQUEST_ID, SERVER_ERROR_REQUEST_ID, GRANT_DECISION, DOMAIN_REJECTED_MESSAGE, DOMAIN_REJECTED_REASON, TEST_CONVERSATION_ID, TEST_TASK_ID, };
183
- export type { CloseInfo, MutableRef, RequestFrame };
184
- //# sourceMappingURL=tm-client-test-support.d.ts.map
@@ -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B,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,cAAc,EACd,uBAAuB,EACvB,sBAAsB,EACtB,oBAAoB,EACpB,YAAY,GACb,CAAC;AACF,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC"}
@@ -1,466 +0,0 @@
1
- /**
2
- * Tests for `tm-client.ts` — now running against a real in-process
3
- * `@effect/platform` WebSocket server instead of a `vi.mock("ws")` fake.
4
- *
5
- * Setup: each test spins up a fresh `NodeSocketServer.makeWebSocket` bound to
6
- * `127.0.0.1:0` (OS-assigned port). An explicit host is required — omitting
7
- * it binds `::` which `server.address()` returns verbatim, yielding a
8
- * non-dialable `ws://:::PORT` URL on Linux/macOS (gotcha §4.11).
9
- *
10
- * Coverage matches the §5 invariants + the typed-manifest + malformed-frame
11
- * cadence tests from the legacy suite. Reconnect-backoff uses real wall-clock
12
- * timing because the reconnect loop runs on the client's internal
13
- * `ManagedRuntime`, whose default Clock is out of reach of a test-fiber's
14
- * `TestClock` (see the `describe("reconnect backoff")` block for details).
15
- */
16
- import { createServer } from "node:net";
17
- import { expect, it } from "vitest";
18
- import { it as itEffect } from "@effect/vitest";
19
- import { Cause, Data, Duration, Effect, Exit, Fiber, Option, Scope, Stream, TestClock, } from "effect";
20
- import * as NodeSocketServer from "@effect/platform-node/NodeSocketServer";
21
- import * as NodeCommandExecutor from "@effect/platform-node/NodeCommandExecutor";
22
- import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem";
23
- import * as Command from "@effect/platform/Command";
24
- import * as Socket from "@effect/platform/Socket";
25
- import { MoltZapTMClient, RPC_TIMEOUT_MS, } from "./tm-client.js";
26
- import { ForbiddenError, RpcTimeoutError, } from "@moltzap/protocol";
27
- import { AgentsLookupByName, DispatchAuthorize, Connect, TaskList, MessagesAuthorize, MessagesSend, MessageReceivedNotificationDefinition, PROTOCOL_VERSION, TaskCreate, } from "@moltzap/protocol";
28
- import { agentId, conversationId, messageId, taskId, JSON_RPC_VERSION, validateRequestFrame, validateResponseFrame, } from "@moltzap/protocol/testing";
29
- const effectTest = (name, effect, timeout) => {
30
- const run = () => {
31
- expect.hasAssertions();
32
- return Effect.runPromise(effect());
33
- };
34
- if (timeout === undefined) {
35
- it(name, run);
36
- return;
37
- }
38
- it(name, run, timeout);
39
- };
40
- const scopedEffectTest = itEffect.scoped;
41
- // Test fixtures for dispatch/authorize round-trip tests below. The
42
- // previous partitioned-dispatcher harness provided these via
43
- // `app-callback-test-requests.ts`; that file was deleted in the
44
- // cutover. The simpler global-queue topology only needs valid
45
- // `dispatch/authorize` params shaped to the descriptor.
46
- const DISPATCH_TASK_A_UUID = "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa";
47
- const DISPATCH_TASK_B_UUID = "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb";
48
- const DISPATCH_CONV_UUID = "cccccccc-cccc-4ccc-8ccc-cccccccccccc";
49
- const DISPATCH_RECIPIENT_UUID = "dddddddd-dddd-4ddd-8ddd-dddddddddddd";
50
- const DISPATCH_SENDER_UUID = "eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee";
51
- const DISPATCH_MESSAGE_UUID = "11111111-1111-4111-8111-111111111111";
52
- const SESSION_A = DISPATCH_TASK_A_UUID;
53
- const SESSION_B = DISPATCH_TASK_B_UUID;
54
- const dispatchRequestParams = (taskId) => ({
55
- taskId,
56
- appId: "app-test",
57
- conversationId: DISPATCH_CONV_UUID,
58
- recipient: { agentId: DISPATCH_RECIPIENT_UUID, ownerId: "owner-test" },
59
- message: {
60
- id: DISPATCH_MESSAGE_UUID,
61
- senderAgentId: DISPATCH_SENDER_UUID,
62
- parts: [{ type: "text", text: "hello" }],
63
- },
64
- attempt: 0,
65
- });
66
- // ── Test server helpers ────────────────────────────────────────────────
67
- const LOCALHOST_HOST = "127.0.0.1";
68
- const SS_COMMAND = "/usr/bin/ss";
69
- const TEST_AGENT_ID = agentId("11111111-1111-4111-8111-111111111111");
70
- const RECONNECT_AGENT_ID = agentId("22222222-2222-4222-8222-222222222222");
71
- const TEST_MESSAGE_ID = messageId("44444444-4444-4444-8444-444444444444");
72
- const NORMAL_CLOSE_CODE = 1000;
73
- const SERVER_ERROR_CLOSE_CODE = 1011;
74
- const WAIT_FOR_DEFAULT_TIMEOUT_MS = 2_000;
75
- const CONNECT_FAILURE_MAX_MS = 3_000;
76
- const REFUSED_CONNECT_MAX_MS = 15_000;
77
- const REFUSED_CONNECT_TEST_TIMEOUT_MS = 20_000;
78
- const REALTIME_POLL_TIMEOUT_MS = 2_000;
79
- const POST_TIMEOUT_SETTLE_MS = 50;
80
- const MALFORMED_FRAME_COUNT = 101;
81
- const MALFORMED_FRAME_FLUSH_MS = 300;
82
- const CLIENT_DRAIN_COUNT = 10;
83
- const CLOSE_PROPAGATION_TIMEOUT_MS = 1_000;
84
- const STALE_PORT_TEST_TIMEOUT_MS = 15_000;
85
- const CLOSE_INFO_WAIT_MS = 2_000;
86
- const HANDLER_REJECTION_CODE = ForbiddenError.code;
87
- const WAIT_FOR_POLL_INTERVAL_MS = 5;
88
- const NORMAL_CLOSE_REASON = "normal";
89
- const SERVER_ERROR_REASON = "boom";
90
- const SERVER_TEST_REQUEST_ID = "srv-test-1";
91
- const SERVER_ERROR_REQUEST_ID = "srv-err-1";
92
- const GRANT_DECISION = "grant";
93
- const DOMAIN_REJECTED_MESSAGE = "domain-rejected";
94
- const DOMAIN_REJECTED_REASON = "test";
95
- const TEST_CONVERSATION_ID = conversationId("33333333-3333-4333-8333-333333333333");
96
- const TEST_TASK_ID = taskId("44444444-4444-4444-8444-444444444444");
97
- const TEST_POLICY = {
98
- maxMessageBytes: 1_000_000,
99
- maxPartsPerMessage: 10,
100
- maxTextLength: 32_768,
101
- maxGroupParticipants: 100,
102
- heartbeatIntervalMs: 30_000,
103
- rateLimits: {
104
- messagesPerMinute: 60,
105
- requestsPerMinute: 120,
106
- },
107
- };
108
- const helloOk = (agentId = TEST_AGENT_ID) => ({
109
- protocolVersion: PROTOCOL_VERSION,
110
- agentId,
111
- policy: TEST_POLICY,
112
- });
113
- const TEST_MESSAGE = {
114
- id: TEST_MESSAGE_ID,
115
- conversationId: TEST_CONVERSATION_ID,
116
- senderId: TEST_AGENT_ID,
117
- parts: [{ type: "text", text: "hello" }],
118
- createdAt: "2026-05-03T00:00:00.000Z",
119
- };
120
- const messageReceivedFrame = () => MessageReceivedNotificationDefinition.encode({
121
- taskId: TEST_TASK_ID,
122
- message: TEST_MESSAGE,
123
- });
124
- class ClosedLocalPortError extends Data.TaggedError("ClosedLocalPortError") {
125
- }
126
- class WaitForTimeoutError extends Data.TaggedError("WaitForTimeoutError") {
127
- }
128
- function rawSocketDataToString(data) {
129
- return typeof data === "string"
130
- ? data
131
- : new TextDecoder("utf-8").decode(data);
132
- }
133
- function handleTestServerRawData(conn, receivedList, handler, data) {
134
- const raw = rawSocketDataToString(data);
135
- receivedList.push(raw);
136
- return handler(conn, raw);
137
- }
138
- const parseJsonOption = (raw) => Effect.runSync(Effect.try({
139
- try: () => JSON.parse(raw),
140
- catch: (cause) => cause,
141
- }).pipe(Effect.option));
142
- function responseFrameHasId(raw, id) {
143
- const parsed = parseJsonOption(raw);
144
- return (Option.isSome(parsed) &&
145
- validateResponseFrame(parsed.value) &&
146
- parsed.value.id === id);
147
- }
148
- function errorResponseFrameHasId(raw, id) {
149
- const parsed = parseJsonOption(raw);
150
- return (Option.isSome(parsed) &&
151
- validateResponseFrame(parsed.value) &&
152
- parsed.value.id === id &&
153
- "error" in parsed.value);
154
- }
155
- function firstConnection(server) {
156
- return server.connections[0];
157
- }
158
- function findResponseRaw(server, id) {
159
- return firstConnection(server).received.find((raw) => responseFrameHasId(raw, id));
160
- }
161
- function waitForResponseRaw(server, id) {
162
- return waitFor(() => findResponseRaw(server, id) !== undefined, {
163
- maxMs: CLOSE_INFO_WAIT_MS,
164
- }).pipe(Effect.map(() => findResponseRaw(server, id)));
165
- }
166
- function waitForErrorResponse(server, id) {
167
- return waitFor(() => firstConnection(server).received.some((raw) => errorResponseFrameHasId(raw, id)), { maxMs: CLOSE_INFO_WAIT_MS });
168
- }
169
- function makeTestServerConnection(write, receivedList) {
170
- return {
171
- send: (raw) => write(raw).pipe(Effect.ignore),
172
- close: (code = NORMAL_CLOSE_CODE, reason = "test close") => write(new Socket.CloseEvent(code, reason)).pipe(Effect.ignore),
173
- get received() {
174
- return receivedList;
175
- },
176
- };
177
- }
178
- function runTestServerSocket(connections, handler, serverSock) {
179
- return Effect.gen(function* () {
180
- const write = yield* serverSock.writer;
181
- const receivedList = [];
182
- const conn = makeTestServerConnection(write, receivedList);
183
- connections.push(conn);
184
- yield* serverSock.runRaw((data) => handleTestServerRawData(conn, receivedList, handler, data));
185
- });
186
- }
187
- /**
188
- * Spin up an in-process `@effect/platform` WS server on `127.0.0.1:0`.
189
- * Caller owns the provided scope; when it closes, the server shuts down.
190
- */
191
- const startTestServer = (handler) => Effect.gen(function* () {
192
- const server = yield* NodeSocketServer.makeWebSocket({
193
- port: 0,
194
- host: LOCALHOST_HOST,
195
- });
196
- const addr = server.address;
197
- if (addr._tag !== "TcpAddress") {
198
- return yield* Effect.die("expected TcpAddress");
199
- }
200
- const connections = [];
201
- yield* Effect.forkScoped(server
202
- .run((serverSock) => runTestServerSocket(connections, handler, serverSock))
203
- .pipe(Effect.ignore));
204
- return {
205
- url: `http://${LOCALHOST_HOST}:${addr.port}`,
206
- get connections() {
207
- return connections;
208
- },
209
- };
210
- });
211
- const findClosedLocalPort = () => Effect.async((resume) => {
212
- const server = createServer();
213
- const fail = (cause) => {
214
- resume(Effect.fail(new ClosedLocalPortError({ cause })));
215
- };
216
- server.once("error", fail);
217
- server.listen(0, LOCALHOST_HOST, () => {
218
- const address = server.address();
219
- if (address === null || typeof address === "string") {
220
- server.close();
221
- fail("expected TCP server address");
222
- return;
223
- }
224
- server.close((err) => {
225
- if (err) {
226
- fail(err);
227
- return;
228
- }
229
- resume(Effect.succeed(address.port));
230
- });
231
- });
232
- });
233
- // Post-D3 R14b vacuous-deny default: handlers REQUIRED on MoltZapTMClient
234
- // constructor; helpers default to deny-everything for tests that don't
235
- // care about TM-callback inbound.
236
- const denyEverythingHandlers = () => ({
237
- "dispatch/authorize": {
238
- definition: DispatchAuthorize,
239
- handle: () => Effect.fail(new ForbiddenError({ message: "test: deny-default" })),
240
- },
241
- "messages/authorize": {
242
- definition: MessagesAuthorize,
243
- handle: () => Effect.fail(new ForbiddenError({ message: "test: deny-default" })),
244
- },
245
- "task/create": {
246
- definition: TaskCreate,
247
- handle: () => Effect.succeed({
248
- verdict: { decision: "reject", reason: "test: deny-default" },
249
- }),
250
- },
251
- });
252
- const ignoreDisconnect = (_close) => undefined;
253
- const ignoreReconnect = (_hello) => undefined;
254
- // Spec B (#596): notification consumption is Stream-based. The legacy
255
- // `(frame: NotificationFrame) => Effect<void>` callback shape is preserved
256
- // here as a thin convenience for tests that previously stashed an
257
- // `onNotification` callback. The bridge reconstructs a wire
258
- // `NotificationFrame` shape from the decoded view.
259
- const notificationHandler = (cb) => (notification) => Effect.sync(() => {
260
- const frame = {
261
- jsonrpc: notification.jsonrpc,
262
- method: notification.method,
263
- ...(notification.params !== undefined
264
- ? // eslint-disable-next-line agent-code-guard/record-cast -- wire-shape rebuild from the decoded notification; provenance preserved
265
- { params: notification.params } // #ignore-sloppy-code[record-cast]: wire-shape rebuild for the test-support adapter's onNotification callback; provenance preserved
266
- : {}),
267
- };
268
- cb(frame);
269
- });
270
- const connectClient = (client) => client.connect();
271
- const sendRpcEffect = (client, definition, params) => client.sendRpc(definition, params);
272
- function expectEffectFailure(effect, pattern) {
273
- return Effect.gen(function* () {
274
- const exit = yield* Effect.exit(effect);
275
- expect(Exit.isFailure(exit)).toBe(true);
276
- if (Exit.isFailure(exit)) {
277
- const failure = Cause.failureOption(exit.cause);
278
- expect(Option.isSome(failure)).toBe(true);
279
- if (Option.isSome(failure)) {
280
- expect(String(failure.value)).toMatch(pattern);
281
- }
282
- }
283
- });
284
- }
285
- const closeClient = (client) => client.close();
286
- /**
287
- * Start a server whose handler auto-responds to `network/connect` and forwards
288
- * everything else to the test's `handler`. Useful for tests that only care
289
- * about post-handshake behaviour.
290
- */
291
- const startHandshakingServer = (handler) => startTestServer((conn, raw) => Effect.gen(function* () {
292
- const parsed = JSON.parse(raw);
293
- if (!validateRequestFrame(parsed)) {
294
- return yield* Effect.die("expected JSON-RPC request frame");
295
- }
296
- const frame = parsed;
297
- if (frame.method === Connect.name) {
298
- yield* conn.send(JSON.stringify(Connect.encodeResponse(frame.id, helloOk())));
299
- return;
300
- }
301
- yield* handler(conn, raw, frame);
302
- }));
303
- function sendDispatchAuthorizeAfterConnect(conn, raw, requestId, params) {
304
- return Effect.gen(function* () {
305
- const parsed = JSON.parse(raw);
306
- if (!validateRequestFrame(parsed)) {
307
- return yield* Effect.die("expected JSON-RPC request frame");
308
- }
309
- const frame = parsed;
310
- if (frame.method === Connect.name) {
311
- yield* conn.send(JSON.stringify(Connect.encodeResponse(frame.id, helloOk())));
312
- yield* conn.send(JSON.stringify(DispatchAuthorize.encodeRequest(requestId, params)));
313
- }
314
- });
315
- }
316
- function startDispatchAuthorizeServer(requestId, params) {
317
- return startTestServer((conn, raw) => sendDispatchAuthorizeAfterConnect(conn, raw, requestId, params));
318
- }
319
- const setRef = (ref) => (value) => {
320
- ref.current = value;
321
- };
322
- function startReconnectServer(authResponses) {
323
- return startTestServer((conn, raw) => Effect.gen(function* () {
324
- const parsed = JSON.parse(raw);
325
- if (!validateRequestFrame(parsed)) {
326
- return yield* Effect.die("expected JSON-RPC request frame");
327
- }
328
- const frame = parsed;
329
- if (frame.method === Connect.name) {
330
- authResponses.current += 1;
331
- yield* conn.send(JSON.stringify(Connect.encodeResponse(frame.id, helloOk(RECONNECT_AGENT_ID))));
332
- }
333
- }));
334
- }
335
- function sendMalformedFramesAndResponse(conn, _raw, frame) {
336
- return Effect.gen(function* () {
337
- if (frame.method !== TaskList.name)
338
- return;
339
- yield* conn.send("not json at all");
340
- yield* conn.send(JSON.stringify({ jsonrpc: JSON_RPC_VERSION, result: {} }));
341
- yield* conn.send(JSON.stringify({ jsonrpc: JSON_RPC_VERSION, id: frame.id }));
342
- yield* conn.send(JSON.stringify(TaskList.encodeResponse(frame.id, {
343
- tasks: [],
344
- })));
345
- });
346
- }
347
- function sendPaddedNotificationAndResponse(conn, _raw, frame) {
348
- if (frame.method !== TaskList.name)
349
- return Effect.void;
350
- return conn.send(JSON.stringify(messageReceivedFrame()) +
351
- "\u0000" +
352
- JSON.stringify(TaskList.encodeResponse(frame.id, {
353
- tasks: [],
354
- })));
355
- }
356
- function sendMalformedFrameBurst(conn) {
357
- return Effect.gen(function* () {
358
- for (let i = 0; i < MALFORMED_FRAME_COUNT; i++) {
359
- yield* conn.send("definitely not json " + i);
360
- }
361
- });
362
- }
363
- function startAgentsLookupByNameServer(captured) {
364
- return startHandshakingServer((conn, _raw, frame) => Effect.gen(function* () {
365
- captured.current = frame;
366
- yield* conn.send(JSON.stringify(AgentsLookupByName.encodeResponse(frame.id, { agents: [] })));
367
- }));
368
- }
369
- function connectClientForServer(url) {
370
- const client = makeClient(url);
371
- return connectClient(client).pipe(Effect.map(() => client));
372
- }
373
- /**
374
- * Build a Spec F (#617) TM-callback handler-table fragment for the
375
- * `dispatch/authorize` slot that grants admission and records the
376
- * `taskId` it was invoked with into `observedTaskId`. Pass as
377
- * `appCallbackHandlers` to `makeClient` so the typed dispatcher sees
378
- * the binding at construction time.
379
- */
380
- function grantDispatchAuthorizeHandlers(observedTaskId) {
381
- return {
382
- "dispatch/authorize": {
383
- definition: DispatchAuthorize,
384
- handle: (params) => Effect.sync(() => {
385
- observedTaskId.current = params.taskId;
386
- return { admission: { decision: GRANT_DECISION } };
387
- }),
388
- },
389
- "messages/authorize": {
390
- definition: MessagesAuthorize,
391
- handle: () => Effect.fail(new ForbiddenError({ message: "test: messages/authorize denied" })),
392
- },
393
- "task/create": {
394
- definition: TaskCreate,
395
- handle: () => Effect.succeed({
396
- verdict: {
397
- decision: "reject",
398
- reason: "test: deny-default",
399
- },
400
- }),
401
- },
402
- };
403
- }
404
- /**
405
- * Promise-returning wrapper that both runs a test Effect and keeps the scope
406
- * alive until the Effect completes. Tests that need a server scope should
407
- * use `withTestServer` rather than mutating a Scope manually.
408
- */
409
- const withTestServer = (effect) => Effect.scoped(effect);
410
- /**
411
- * Poll until `pred()` is true or `maxMs` elapses. The legacy test file used a
412
- * microtask-based loop; we keep that cadence to match the legacy behaviour
413
- * when synchronisation is driven by wall-clock timing in the test harness.
414
- */
415
- function waitFor(pred, { maxMs = WAIT_FOR_DEFAULT_TIMEOUT_MS } = {}) {
416
- const deadline = Date.now() + maxMs;
417
- return Effect.async((resume) => {
418
- const tick = () => {
419
- if (pred()) {
420
- resume(Effect.void);
421
- return;
422
- }
423
- if (Date.now() > deadline) {
424
- resume(Effect.fail(new WaitForTimeoutError({ timeoutMs: maxMs })));
425
- return;
426
- }
427
- setTimeout(tick, WAIT_FOR_POLL_INTERVAL_MS);
428
- };
429
- tick();
430
- });
431
- }
432
- const realSleep = (ms) => Effect.async((resume) => {
433
- const timer = setTimeout(() => resume(Effect.void), ms);
434
- return Effect.sync(() => clearTimeout(timer));
435
- });
436
- const closeWaitSocketOutput = Command.make(SS_COMMAND, "-tn", "state", "CLOSE-WAIT").pipe(Command.string, Effect.catchAll(() => Effect.succeed("")), Effect.provide(NodeCommandExecutor.layer), Effect.provide(NodeFileSystem.layer));
437
- /**
438
- * Build a `MoltZapTMClient`. Spec #222 OQ-4 deletion: `onNotification` is no
439
- * longer a constructor option; tests that previously stashed an
440
- * `onNotification` callback now register a `subscribe({}, …)` subscription
441
- * post-construction. The helper accepts the same `onNotification` callback as
442
- * a convenience and wires it through the new subscription registry,
443
- * keeping migration noise local to the helper.
444
- */
445
- function makeClient(url, overrides = {}) {
446
- const { onNotification, onDisconnect = ignoreDisconnect, onReconnect = ignoreReconnect, handlers, } = overrides;
447
- const client = new MoltZapTMClient({
448
- serverUrl: url,
449
- agentKey: "test-key",
450
- onDisconnect,
451
- onReconnect,
452
- handlers: handlers ?? denyEverythingHandlers(),
453
- });
454
- if (onNotification !== undefined) {
455
- // Spec B (#596): the deleted `client.subscribe({}, handler)` shape is
456
- // replaced by `client.subscribeAll().pipe(Stream.runForEach, …)` forked
457
- // as a daemon fiber. The test-support helper is sync-runnable so we
458
- // route through `Effect.runFork` — the fiber lives until the test ends
459
- // and the client closes (which terminates the Stream with
460
- // `NotConnectedError`, caught + logged).
461
- Effect.runFork(client.subscribeAll().pipe(Stream.runForEach(notificationHandler(onNotification)), Effect.catchAll(() => Effect.void), Effect.asVoid));
462
- }
463
- return client;
464
- }
465
- export { AgentsLookupByName, TaskList, DispatchAuthorize, Duration, Fiber, ForbiddenError, MessageReceivedNotificationDefinition, MessagesSend, RpcTimeoutError, TestClock, closeClient, connectClient, connectClientForServer, dispatchRequestParams, effectTest, scopedEffectTest, expectEffectFailure, findClosedLocalPort, findResponseRaw, grantDispatchAuthorizeHandlers, makeClient, messageReceivedFrame, sendMalformedFrameBurst, sendMalformedFramesAndResponse, sendPaddedNotificationAndResponse, sendRpcEffect, setRef, startAgentsLookupByNameServer, startDispatchAuthorizeServer, startHandshakingServer, startReconnectServer, startTestServer, validateResponseFrame, waitFor, realSleep, waitForErrorResponse, waitForResponseRaw, withTestServer, closeWaitSocketOutput, JSON_RPC_VERSION, RPC_TIMEOUT_MS, LOCALHOST_HOST, TEST_AGENT_ID, RECONNECT_AGENT_ID, SESSION_A, SESSION_B, NORMAL_CLOSE_CODE, SERVER_ERROR_CLOSE_CODE, CONNECT_FAILURE_MAX_MS, REFUSED_CONNECT_MAX_MS, REFUSED_CONNECT_TEST_TIMEOUT_MS, REALTIME_POLL_TIMEOUT_MS, POST_TIMEOUT_SETTLE_MS, MALFORMED_FRAME_FLUSH_MS, CLIENT_DRAIN_COUNT, CLOSE_PROPAGATION_TIMEOUT_MS, STALE_PORT_TEST_TIMEOUT_MS, CLOSE_INFO_WAIT_MS, HANDLER_REJECTION_CODE, NORMAL_CLOSE_REASON, SERVER_ERROR_REASON, SERVER_TEST_REQUEST_ID, SERVER_ERROR_REQUEST_ID, GRANT_DECISION, DOMAIN_REJECTED_MESSAGE, DOMAIN_REJECTED_REASON, TEST_CONVERSATION_ID, TEST_TASK_ID, };
466
- //# sourceMappingURL=tm-client-test-support.js.map