rivetkit 2.0.42 → 2.1.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. package/dist/{tsup/config-CLnylLYY.d.ts → browser/client.d.ts} +2127 -1910
  2. package/dist/browser/client.js +5182 -0
  3. package/dist/browser/client.js.map +1 -0
  4. package/dist/browser/inspector/client.d.ts +130 -0
  5. package/dist/browser/inspector/client.js +2854 -0
  6. package/dist/browser/inspector/client.js.map +1 -0
  7. package/dist/browser/v3-DnYObHH3.d.ts +279 -0
  8. package/dist/schemas/actor-inspector/v2.ts +796 -0
  9. package/dist/schemas/actor-inspector/v3.ts +899 -0
  10. package/dist/schemas/actor-persist/v4.ts +406 -0
  11. package/dist/schemas/client-protocol/v3.ts +554 -0
  12. package/dist/schemas/persist/v1.ts +781 -0
  13. package/dist/schemas/transport/v1.ts +697 -0
  14. package/dist/tsup/actor/errors.cjs +27 -3
  15. package/dist/tsup/actor/errors.cjs.map +1 -1
  16. package/dist/tsup/actor/errors.d.cts +37 -1
  17. package/dist/tsup/actor/errors.d.ts +37 -1
  18. package/dist/tsup/actor/errors.js +26 -1
  19. package/dist/tsup/{actor-router-consts-DzI2szci.d.cts → actor-router-consts-D29T1Z-K.d.cts} +1 -1
  20. package/dist/tsup/{actor-router-consts-DzI2szci.d.ts → actor-router-consts-D29T1Z-K.d.ts} +1 -1
  21. package/dist/tsup/chunk-424PT5DM.js +23 -0
  22. package/dist/tsup/chunk-424PT5DM.js.map +1 -0
  23. package/dist/tsup/{chunk-JDAD2YFA.js → chunk-5ESWDTHJ.js} +148 -273
  24. package/dist/tsup/chunk-5ESWDTHJ.js.map +1 -0
  25. package/dist/tsup/{chunk-FJ3KTN4V.js → chunk-6LIBPELE.js} +119 -11
  26. package/dist/tsup/chunk-6LIBPELE.js.map +1 -0
  27. package/dist/tsup/chunk-6LJAZ5R4.cjs +96 -0
  28. package/dist/tsup/chunk-6LJAZ5R4.cjs.map +1 -0
  29. package/dist/tsup/{chunk-LFVF5SCU.js → chunk-7HTNH26M.js} +126 -1
  30. package/dist/tsup/chunk-7HTNH26M.js.map +1 -0
  31. package/dist/tsup/chunk-7K4CYDGD.js +630 -0
  32. package/dist/tsup/chunk-7K4CYDGD.js.map +1 -0
  33. package/dist/tsup/{chunk-XXGJCOL6.js → chunk-A6YIZWTK.js} +2 -2
  34. package/dist/tsup/chunk-AIYEYMX5.cjs +630 -0
  35. package/dist/tsup/chunk-AIYEYMX5.cjs.map +1 -0
  36. package/dist/tsup/{chunk-Q6W7RJJP.js → chunk-DIGBC2VI.js} +211 -2316
  37. package/dist/tsup/chunk-DIGBC2VI.js.map +1 -0
  38. package/dist/tsup/{chunk-RZW2DNND.cjs → chunk-F6JYU5IK.cjs} +1957 -1039
  39. package/dist/tsup/chunk-F6JYU5IK.cjs.map +1 -0
  40. package/dist/tsup/chunk-HAZL2EPK.cjs +534 -0
  41. package/dist/tsup/chunk-HAZL2EPK.cjs.map +1 -0
  42. package/dist/tsup/chunk-HDQ2JUQT.cjs +23 -0
  43. package/dist/tsup/chunk-HDQ2JUQT.cjs.map +1 -0
  44. package/dist/tsup/chunk-HIDX4C5Y.cjs +1036 -0
  45. package/dist/tsup/chunk-HIDX4C5Y.cjs.map +1 -0
  46. package/dist/tsup/chunk-IVG73YCW.js +534 -0
  47. package/dist/tsup/chunk-IVG73YCW.js.map +1 -0
  48. package/dist/tsup/chunk-KJSYAUOM.js +96 -0
  49. package/dist/tsup/chunk-KJSYAUOM.js.map +1 -0
  50. package/dist/tsup/{chunk-2XQS746M.cjs → chunk-L47L3ZWJ.cjs} +127 -2
  51. package/dist/tsup/chunk-L47L3ZWJ.cjs.map +1 -0
  52. package/dist/tsup/{chunk-H4TB4X25.cjs → chunk-LW6KLR7A.cjs} +126 -18
  53. package/dist/tsup/chunk-LW6KLR7A.cjs.map +1 -0
  54. package/dist/tsup/chunk-LXUQ667X.js +2006 -0
  55. package/dist/tsup/chunk-LXUQ667X.js.map +1 -0
  56. package/dist/tsup/{chunk-GMAVRZSF.js → chunk-M2T62AZQ.js} +1790 -872
  57. package/dist/tsup/chunk-M2T62AZQ.js.map +1 -0
  58. package/dist/tsup/chunk-MZ37VV3P.js +5974 -0
  59. package/dist/tsup/chunk-MZ37VV3P.js.map +1 -0
  60. package/dist/tsup/chunk-N4KRDJ56.js +72 -0
  61. package/dist/tsup/chunk-N4KRDJ56.js.map +1 -0
  62. package/dist/tsup/chunk-NIYZDWMW.cjs +2006 -0
  63. package/dist/tsup/chunk-NIYZDWMW.cjs.map +1 -0
  64. package/dist/tsup/chunk-OMEPCQK2.js +649 -0
  65. package/dist/tsup/chunk-OMEPCQK2.js.map +1 -0
  66. package/dist/tsup/chunk-SR3KQE7Q.cjs +72 -0
  67. package/dist/tsup/chunk-SR3KQE7Q.cjs.map +1 -0
  68. package/dist/tsup/chunk-SSEP6DHP.cjs +2657 -0
  69. package/dist/tsup/chunk-SSEP6DHP.cjs.map +1 -0
  70. package/dist/tsup/chunk-T5YCUGVS.js +1036 -0
  71. package/dist/tsup/chunk-T5YCUGVS.js.map +1 -0
  72. package/dist/tsup/{chunk-EJVBH5VF.cjs → chunk-TPGXWFQT.cjs} +3 -3
  73. package/dist/tsup/{chunk-EJVBH5VF.cjs.map → chunk-TPGXWFQT.cjs.map} +1 -1
  74. package/dist/tsup/{chunk-X35U3YNX.cjs → chunk-TYLXNCA5.cjs} +214 -339
  75. package/dist/tsup/chunk-TYLXNCA5.cjs.map +1 -0
  76. package/dist/tsup/chunk-VKVNIQRQ.js +257 -0
  77. package/dist/tsup/chunk-VKVNIQRQ.js.map +1 -0
  78. package/dist/tsup/chunk-XWBAQO5H.cjs +649 -0
  79. package/dist/tsup/chunk-XWBAQO5H.cjs.map +1 -0
  80. package/dist/tsup/chunk-YQ4LDVD6.cjs +5974 -0
  81. package/dist/tsup/chunk-YQ4LDVD6.cjs.map +1 -0
  82. package/dist/tsup/chunk-ZFY5J2EP.cjs +257 -0
  83. package/dist/tsup/chunk-ZFY5J2EP.cjs.map +1 -0
  84. package/dist/tsup/client/mod.cjs +9 -10
  85. package/dist/tsup/client/mod.cjs.map +1 -1
  86. package/dist/tsup/client/mod.d.cts +11 -5
  87. package/dist/tsup/client/mod.d.ts +11 -5
  88. package/dist/tsup/client/mod.js +8 -8
  89. package/dist/tsup/common/log.cjs +4 -4
  90. package/dist/tsup/common/log.d.cts +2 -2
  91. package/dist/tsup/common/log.d.ts +2 -2
  92. package/dist/tsup/common/log.js +3 -2
  93. package/dist/tsup/common/websocket.cjs +5 -5
  94. package/dist/tsup/common/websocket.js +4 -3
  95. package/dist/tsup/config-BFqid9Gr.d.ts +2574 -0
  96. package/dist/tsup/config-BiNoIHRs.d.cts +80 -0
  97. package/dist/tsup/config-BiNoIHRs.d.ts +80 -0
  98. package/dist/tsup/{config-CZB2-W8x.d.cts → config-CAZphOS1.d.cts} +681 -355
  99. package/dist/tsup/db/drizzle/mod.cjs +49 -0
  100. package/dist/tsup/db/drizzle/mod.cjs.map +1 -0
  101. package/dist/tsup/db/drizzle/mod.d.cts +17 -0
  102. package/dist/tsup/db/drizzle/mod.d.ts +17 -0
  103. package/dist/tsup/db/drizzle/mod.js +49 -0
  104. package/dist/tsup/db/drizzle/mod.js.map +1 -0
  105. package/dist/tsup/db/mod.cjs +9 -0
  106. package/dist/tsup/db/mod.cjs.map +1 -0
  107. package/dist/tsup/db/mod.d.cts +9 -0
  108. package/dist/tsup/db/mod.d.ts +9 -0
  109. package/dist/tsup/db/mod.js +9 -0
  110. package/dist/tsup/db/mod.js.map +1 -0
  111. package/dist/tsup/{driver-D0QX9M11.d.ts → driver-Bxv62E2p.d.ts} +2 -2
  112. package/dist/tsup/{driver-q-zqG7fc.d.cts → driver-DYXwJR5D.d.cts} +2 -2
  113. package/dist/tsup/driver-helpers/mod.cjs +12 -6
  114. package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
  115. package/dist/tsup/driver-helpers/mod.d.cts +12 -5
  116. package/dist/tsup/driver-helpers/mod.d.ts +12 -5
  117. package/dist/tsup/driver-helpers/mod.js +12 -5
  118. package/dist/tsup/driver-test-suite/mod.cjs +1370 -116
  119. package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
  120. package/dist/tsup/driver-test-suite/mod.d.cts +10 -4
  121. package/dist/tsup/driver-test-suite/mod.d.ts +10 -4
  122. package/dist/tsup/driver-test-suite/mod.js +2093 -838
  123. package/dist/tsup/driver-test-suite/mod.js.map +1 -1
  124. package/dist/tsup/inspector/mod.cjs +29 -3
  125. package/dist/tsup/inspector/mod.cjs.map +1 -1
  126. package/dist/tsup/inspector/mod.d.cts +124 -3
  127. package/dist/tsup/inspector/mod.d.ts +124 -3
  128. package/dist/tsup/inspector/mod.js +72 -45
  129. package/dist/tsup/keys-CydblqMh.d.cts +13 -0
  130. package/dist/tsup/keys-CydblqMh.d.ts +13 -0
  131. package/dist/tsup/mod.cjs +16 -10
  132. package/dist/tsup/mod.cjs.map +1 -1
  133. package/dist/tsup/mod.d.cts +26 -14
  134. package/dist/tsup/mod.d.ts +26 -14
  135. package/dist/tsup/mod.js +20 -13
  136. package/dist/tsup/serve-test-suite/mod.cjs +1165 -83
  137. package/dist/tsup/serve-test-suite/mod.cjs.map +1 -1
  138. package/dist/tsup/serve-test-suite/mod.js +1114 -29
  139. package/dist/tsup/serve-test-suite/mod.js.map +1 -1
  140. package/dist/tsup/test/mod.cjs +84 -11
  141. package/dist/tsup/test/mod.cjs.map +1 -1
  142. package/dist/tsup/test/mod.d.cts +10 -5
  143. package/dist/tsup/test/mod.d.ts +10 -5
  144. package/dist/tsup/test/mod.js +85 -11
  145. package/dist/tsup/test/mod.js.map +1 -1
  146. package/dist/tsup/utils.cjs +10 -4
  147. package/dist/tsup/utils.cjs.map +1 -1
  148. package/dist/tsup/utils.d.cts +72 -2
  149. package/dist/tsup/utils.d.ts +72 -2
  150. package/dist/tsup/utils.js +9 -2
  151. package/dist/tsup/v3-DnYObHH3.d.cts +279 -0
  152. package/dist/tsup/v3-DnYObHH3.d.ts +279 -0
  153. package/dist/tsup/workflow/mod.cjs +16 -0
  154. package/dist/tsup/workflow/mod.cjs.map +1 -0
  155. package/dist/tsup/workflow/mod.d.cts +83 -0
  156. package/dist/tsup/workflow/mod.d.ts +83 -0
  157. package/dist/tsup/workflow/mod.js +16 -0
  158. package/dist/tsup/workflow/mod.js.map +1 -0
  159. package/package.json +62 -5
  160. package/src/actor/config.ts +478 -68
  161. package/src/actor/conn/mod.ts +68 -16
  162. package/src/actor/conn/state-manager.ts +2 -2
  163. package/src/actor/contexts/action.ts +20 -12
  164. package/src/actor/contexts/base/actor.ts +137 -7
  165. package/src/actor/contexts/base/conn-init.ts +27 -7
  166. package/src/actor/contexts/base/conn.ts +27 -18
  167. package/src/actor/contexts/before-action-response.ts +9 -2
  168. package/src/actor/contexts/before-connect.ts +7 -2
  169. package/src/actor/contexts/connect.ts +9 -2
  170. package/src/actor/contexts/create-conn-state.ts +7 -2
  171. package/src/actor/contexts/create-vars.ts +16 -3
  172. package/src/actor/contexts/create.ts +16 -3
  173. package/src/actor/contexts/destroy.ts +9 -3
  174. package/src/actor/contexts/disconnect.ts +10 -4
  175. package/src/actor/contexts/index.ts +4 -3
  176. package/src/actor/contexts/request.ts +23 -6
  177. package/src/actor/contexts/run.ts +47 -0
  178. package/src/actor/contexts/sleep.ts +9 -3
  179. package/src/actor/contexts/state-change.ts +9 -3
  180. package/src/actor/contexts/wake.ts +9 -3
  181. package/src/actor/contexts/websocket.ts +23 -6
  182. package/src/actor/database.ts +8 -18
  183. package/src/actor/definition.ts +20 -6
  184. package/src/actor/driver.ts +32 -3
  185. package/src/actor/errors.ts +127 -0
  186. package/src/actor/instance/connection-manager.ts +183 -80
  187. package/src/actor/instance/event-manager.ts +26 -15
  188. package/src/actor/instance/keys.ts +117 -0
  189. package/src/actor/instance/mod.ts +784 -174
  190. package/src/actor/instance/queue-manager.ts +603 -0
  191. package/src/actor/instance/queue.ts +287 -0
  192. package/src/actor/instance/schedule-manager.ts +49 -7
  193. package/src/actor/instance/state-manager.ts +35 -11
  194. package/src/actor/instance/traces-driver.ts +128 -0
  195. package/src/actor/mod.ts +26 -2
  196. package/src/actor/protocol/old.ts +28 -13
  197. package/src/actor/protocol/serde.ts +1 -1
  198. package/src/actor/router-endpoints.ts +177 -21
  199. package/src/actor/router-websocket-endpoints.ts +18 -29
  200. package/src/actor/router.ts +177 -0
  201. package/src/actor/schema.ts +291 -0
  202. package/src/actor/utils.ts +40 -0
  203. package/src/client/actor-common.ts +1 -1
  204. package/src/client/actor-conn.ts +100 -33
  205. package/src/client/actor-handle.ts +61 -33
  206. package/src/client/client.ts +2 -4
  207. package/src/client/config.ts +1 -1
  208. package/src/client/mod.browser.ts +2 -0
  209. package/src/client/mod.ts +1 -4
  210. package/src/client/queue.ts +146 -0
  211. package/src/client/utils.ts +1 -1
  212. package/src/common/log.ts +1 -1
  213. package/src/common/utils.ts +3 -3
  214. package/src/db/config.ts +100 -0
  215. package/src/db/drizzle/mod.ts +226 -0
  216. package/src/db/drizzle/sqlite-core.ts +22 -0
  217. package/src/db/mod.ts +125 -0
  218. package/src/db/shared.ts +92 -0
  219. package/src/db/sqlite-vfs.ts +12 -0
  220. package/src/driver-helpers/mod.ts +1 -0
  221. package/src/driver-test-suite/mod.ts +69 -43
  222. package/src/driver-test-suite/tests/access-control.ts +218 -0
  223. package/src/driver-test-suite/tests/actor-db-raw.ts +73 -0
  224. package/src/driver-test-suite/tests/actor-db.ts +394 -0
  225. package/src/driver-test-suite/tests/actor-inspector.ts +259 -358
  226. package/src/driver-test-suite/tests/actor-kv.ts +41 -20
  227. package/src/driver-test-suite/tests/actor-queue.ts +324 -0
  228. package/src/driver-test-suite/tests/actor-run.ts +181 -0
  229. package/src/driver-test-suite/tests/actor-schedule.ts +5 -2
  230. package/src/driver-test-suite/tests/actor-sleep.ts +3 -3
  231. package/src/driver-test-suite/tests/actor-stateless.ts +70 -0
  232. package/src/driver-test-suite/tests/actor-workflow.ts +108 -0
  233. package/src/driver-test-suite/tests/manager-driver.ts +11 -0
  234. package/src/driver-test-suite/tests/raw-http-request-properties.ts +1 -1
  235. package/src/driver-test-suite/tests/raw-websocket.ts +12 -12
  236. package/src/drivers/default.ts +7 -2
  237. package/src/drivers/engine/actor-driver.ts +45 -37
  238. package/src/drivers/engine/config.ts +1 -1
  239. package/src/drivers/file-system/actor.ts +20 -2
  240. package/src/drivers/file-system/global-state.ts +569 -258
  241. package/src/drivers/file-system/kv-limits.ts +70 -0
  242. package/src/drivers/file-system/manager.ts +22 -6
  243. package/src/drivers/file-system/mod.ts +39 -16
  244. package/src/drivers/file-system/sqlite-runtime.ts +210 -0
  245. package/src/inspector/actor-inspector.ts +224 -102
  246. package/src/inspector/config.ts +1 -1
  247. package/src/inspector/handler.ts +102 -20
  248. package/src/inspector/mod.browser.ts +8 -0
  249. package/src/inspector/mod.ts +2 -0
  250. package/src/inspector/serve-ui.ts +40 -0
  251. package/src/inspector/transport.ts +18 -0
  252. package/src/inspector/utils.ts +5 -39
  253. package/src/manager/gateway.ts +1 -1
  254. package/src/manager/protocol/mod.ts +1 -1
  255. package/src/manager/protocol/query.ts +1 -1
  256. package/src/manager/router-schema.ts +1 -1
  257. package/src/manager/router.ts +38 -12
  258. package/src/manager-api/actors.ts +1 -1
  259. package/src/manager-api/common.ts +1 -1
  260. package/src/registry/config/driver.ts +1 -1
  261. package/src/registry/config/index.ts +212 -43
  262. package/src/registry/config/legacy-runner.ts +1 -1
  263. package/src/registry/config/runner.ts +1 -1
  264. package/src/registry/config/serverless.ts +1 -1
  265. package/src/registry/index.ts +7 -5
  266. package/src/remote-manager-driver/api-utils.ts +1 -1
  267. package/src/schemas/actor-inspector/mod.ts +1 -1
  268. package/src/schemas/actor-inspector/versioned.ts +195 -8
  269. package/src/schemas/actor-persist/versioned.ts +87 -7
  270. package/src/schemas/client-protocol/mod.ts +1 -1
  271. package/src/schemas/client-protocol/versioned.ts +127 -11
  272. package/src/schemas/client-protocol-zod/mod.ts +16 -1
  273. package/src/schemas/persist/mod.ts +1 -0
  274. package/src/schemas/transport/mod.ts +1 -0
  275. package/src/serde.ts +1 -1
  276. package/src/serve-test-suite/mod.ts +10 -9
  277. package/src/test/mod.ts +15 -56
  278. package/src/utils/endpoint-parser.test.ts +1 -1
  279. package/src/utils/endpoint-parser.ts +1 -1
  280. package/src/utils/env-vars.ts +12 -1
  281. package/src/utils/node.ts +15 -2
  282. package/src/utils.test.ts +34 -0
  283. package/src/utils.ts +140 -6
  284. package/src/workflow/constants.ts +2 -0
  285. package/src/workflow/context.ts +532 -0
  286. package/src/workflow/driver.ts +191 -0
  287. package/src/workflow/inspector.ts +268 -0
  288. package/src/workflow/mod.ts +122 -0
  289. package/dist/tsup/chunk-2IJTYN6K.cjs +0 -278
  290. package/dist/tsup/chunk-2IJTYN6K.cjs.map +0 -1
  291. package/dist/tsup/chunk-2XQS746M.cjs.map +0 -1
  292. package/dist/tsup/chunk-3VP5CSHV.cjs +0 -114
  293. package/dist/tsup/chunk-3VP5CSHV.cjs.map +0 -1
  294. package/dist/tsup/chunk-AQFSQMBG.js +0 -114
  295. package/dist/tsup/chunk-AQFSQMBG.js.map +0 -1
  296. package/dist/tsup/chunk-E6ZE2YEA.js +0 -664
  297. package/dist/tsup/chunk-E6ZE2YEA.js.map +0 -1
  298. package/dist/tsup/chunk-FJ3KTN4V.js.map +0 -1
  299. package/dist/tsup/chunk-GBENOENJ.cjs +0 -8
  300. package/dist/tsup/chunk-GBENOENJ.cjs.map +0 -1
  301. package/dist/tsup/chunk-GD7UXGOE.cjs +0 -4762
  302. package/dist/tsup/chunk-GD7UXGOE.cjs.map +0 -1
  303. package/dist/tsup/chunk-GMAVRZSF.js.map +0 -1
  304. package/dist/tsup/chunk-H4TB4X25.cjs.map +0 -1
  305. package/dist/tsup/chunk-JDAD2YFA.js.map +0 -1
  306. package/dist/tsup/chunk-KCOVZOPS.js +0 -1946
  307. package/dist/tsup/chunk-KCOVZOPS.js.map +0 -1
  308. package/dist/tsup/chunk-KDFWJKMJ.cjs +0 -664
  309. package/dist/tsup/chunk-KDFWJKMJ.cjs.map +0 -1
  310. package/dist/tsup/chunk-LFVF5SCU.js.map +0 -1
  311. package/dist/tsup/chunk-Q6W7RJJP.js.map +0 -1
  312. package/dist/tsup/chunk-RUW5CZ5Z.cjs +0 -1949
  313. package/dist/tsup/chunk-RUW5CZ5Z.cjs.map +0 -1
  314. package/dist/tsup/chunk-RZW2DNND.cjs.map +0 -1
  315. package/dist/tsup/chunk-TCOEBUUE.js +0 -278
  316. package/dist/tsup/chunk-TCOEBUUE.js.map +0 -1
  317. package/dist/tsup/chunk-X35U3YNX.cjs.map +0 -1
  318. package/dist/tsup/keys-Chhy4ylv.d.cts +0 -8
  319. package/dist/tsup/keys-Chhy4ylv.d.ts +0 -8
  320. package/dist/tsup/v1-Gq4avTK3.d.cts +0 -240
  321. package/dist/tsup/v1-Gq4avTK3.d.ts +0 -240
  322. /package/dist/tsup/{chunk-XXGJCOL6.js.map → chunk-A6YIZWTK.js.map} +0 -0
@@ -1,5 +1,5 @@
1
1
  import * as cbor from "cbor-x";
2
- import { z } from "zod";
2
+ import { z } from "zod/v4";
3
3
  import type { AnyDatabaseProvider } from "@/actor/database";
4
4
  import * as errors from "@/actor/errors";
5
5
  import {
@@ -29,6 +29,7 @@ import {
29
29
  import { CONN_SEND_MESSAGE_SYMBOL, type Conn } from "../conn/mod";
30
30
  import { ActionContext } from "../contexts";
31
31
  import type { ActorInstance } from "../instance/mod";
32
+ import type { EventSchemaConfig, QueueSchemaConfig } from "../schema";
32
33
 
33
34
  interface MessageEventOpts {
34
35
  encoding: Encoding;
@@ -139,19 +140,21 @@ export interface ProcessMessageHandler<
139
140
  V,
140
141
  I,
141
142
  DB extends AnyDatabaseProvider,
143
+ E extends EventSchemaConfig,
144
+ Q extends QueueSchemaConfig,
142
145
  > {
143
146
  onExecuteAction?: (
144
- ctx: ActionContext<S, CP, CS, V, I, DB>,
147
+ ctx: ActionContext<S, CP, CS, V, I, DB, E, Q>,
145
148
  name: string,
146
149
  args: unknown[],
147
150
  ) => Promise<unknown>;
148
151
  onSubscribe?: (
149
152
  eventName: string,
150
- conn: Conn<S, CP, CS, V, I, DB>,
153
+ conn: Conn<S, CP, CS, V, I, DB, E, Q>,
151
154
  ) => Promise<void>;
152
155
  onUnsubscribe?: (
153
156
  eventName: string,
154
- conn: Conn<S, CP, CS, V, I, DB>,
157
+ conn: Conn<S, CP, CS, V, I, DB, E, Q>,
155
158
  ) => Promise<void>;
156
159
  }
157
160
 
@@ -162,6 +165,8 @@ export async function processMessage<
162
165
  V,
163
166
  I,
164
167
  DB extends AnyDatabaseProvider,
168
+ E extends EventSchemaConfig,
169
+ Q extends QueueSchemaConfig,
165
170
  >(
166
171
  message: {
167
172
  body:
@@ -174,9 +179,9 @@ export async function processMessage<
174
179
  val: { eventName: string; subscribe: boolean };
175
180
  };
176
181
  },
177
- actor: ActorInstance<S, CP, CS, V, I, DB>,
178
- conn: Conn<S, CP, CS, V, I, DB>,
179
- handler: ProcessMessageHandler<S, CP, CS, V, I, DB>,
182
+ actor: ActorInstance<S, CP, CS, V, I, DB, E, Q>,
183
+ conn: Conn<S, CP, CS, V, I, DB, E, Q>,
184
+ handler: ProcessMessageHandler<S, CP, CS, V, I, DB, E, Q>,
180
185
  ) {
181
186
  let actionId: bigint | undefined;
182
187
  let actionName: string | undefined;
@@ -199,7 +204,10 @@ export async function processMessage<
199
204
  actionName: name,
200
205
  });
201
206
 
202
- const ctx = new ActionContext<S, CP, CS, V, I, DB>(actor, conn);
207
+ const ctx = new ActionContext<S, CP, CS, V, I, DB, E, Q>(
208
+ actor,
209
+ conn,
210
+ );
203
211
 
204
212
  // Process the action request and wait for the result
205
213
  // This will wait for async actions to complete
@@ -265,11 +273,18 @@ export async function processMessage<
265
273
  subscribe,
266
274
  });
267
275
 
268
- if (subscribe) {
269
- await handler.onSubscribe(eventName, conn);
270
- } else {
271
- await handler.onUnsubscribe(eventName, conn);
272
- }
276
+ if (subscribe) {
277
+ await actor.assertCanSubscribe(
278
+ new ActionContext<S, CP, CS, V, I, DB, E, Q>(
279
+ actor,
280
+ conn,
281
+ ),
282
+ eventName,
283
+ );
284
+ await handler.onSubscribe(eventName, conn);
285
+ } else {
286
+ await handler.onUnsubscribe(eventName, conn);
287
+ }
273
288
 
274
289
  actor.rLog.debug({
275
290
  msg: "subscription request completed",
@@ -1,6 +1,6 @@
1
1
  import * as cbor from "cbor-x";
2
2
  import type { VersionedDataHandler } from "vbare";
3
- import { z } from "zod";
3
+ import { z } from "zod/v4";
4
4
  import * as errors from "@/actor/errors";
5
5
  import { serializeWithEncoding } from "@/serde";
6
6
  import { loggerWithoutContext } from "../log";
@@ -5,6 +5,7 @@ import { ActionContext } from "@/actor/contexts";
5
5
  import * as errors from "@/actor/errors";
6
6
  import type { AnyActorInstance } from "@/actor/instance/mod";
7
7
  import { type Encoding, EncodingSchema } from "@/actor/protocol/serde";
8
+ import { hasSchemaConfigKey } from "@/actor/schema";
8
9
  import {
9
10
  HEADER_ACTOR_QUERY,
10
11
  HEADER_CONN_PARAMS,
@@ -13,17 +14,24 @@ import {
13
14
  WS_PROTOCOL_ENCODING,
14
15
  } from "@/common/actor-router-consts";
15
16
  import { stringifyError } from "@/common/utils";
17
+ import type { RegistryConfig } from "@/registry/config";
16
18
  import type * as protocol from "@/schemas/client-protocol/mod";
17
19
  import {
18
20
  CURRENT_VERSION as CLIENT_PROTOCOL_CURRENT_VERSION,
19
21
  HTTP_ACTION_REQUEST_VERSIONED,
20
22
  HTTP_ACTION_RESPONSE_VERSIONED,
23
+ HTTP_QUEUE_SEND_REQUEST_VERSIONED,
24
+ HTTP_QUEUE_SEND_RESPONSE_VERSIONED,
21
25
  } from "@/schemas/client-protocol/versioned";
22
26
  import {
23
27
  type HttpActionRequest as HttpActionRequestJson,
24
28
  HttpActionRequestSchema,
25
29
  type HttpActionResponse as HttpActionResponseJson,
26
30
  HttpActionResponseSchema,
31
+ type HttpQueueSendRequest as HttpQueueSendRequestJson,
32
+ HttpQueueSendRequestSchema,
33
+ type HttpQueueSendResponse as HttpQueueSendResponseJson,
34
+ HttpQueueSendResponseSchema,
27
35
  } from "@/schemas/client-protocol-zod/mod";
28
36
  import {
29
37
  contentTypeForEncoding,
@@ -35,7 +43,6 @@ import { createHttpDriver } from "./conn/drivers/http";
35
43
  import { createRawRequestDriver } from "./conn/drivers/raw-request";
36
44
  import type { ActorDriver } from "./driver";
37
45
  import { loggerWithoutContext } from "./log";
38
- import { RegistryConfig } from "@/registry/config";
39
46
 
40
47
  export interface ActionOpts {
41
48
  req?: HonoRequest;
@@ -61,6 +68,15 @@ export interface FetchOpts {
61
68
  actorId: string;
62
69
  }
63
70
 
71
+ export interface QueueSendOpts {
72
+ req?: HonoRequest;
73
+ name: string;
74
+ body: unknown;
75
+ wait?: boolean;
76
+ timeout?: number;
77
+ actorId: string;
78
+ }
79
+
64
80
  /**
65
81
  * Creates an action handler
66
82
  */
@@ -96,31 +112,50 @@ export async function handleAction(
96
112
  const actionArgs = request;
97
113
 
98
114
  // Invoke the action
99
- let actor: AnyActorInstance | undefined;
100
- let conn: AnyConn | undefined;
101
115
  let output: unknown | undefined;
102
- try {
103
- actor = await actorDriver.loadActor(actorId);
116
+ let outputReady = false;
117
+ const maxAttempts = 3;
118
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
119
+ let actor: AnyActorInstance | undefined;
120
+ let conn: AnyConn | undefined;
121
+ try {
122
+ actor = await actorDriver.loadActor(actorId);
104
123
 
105
- actor.rLog.debug({ msg: "handling action", actionName, encoding });
124
+ actor.rLog.debug({ msg: "handling action", actionName, encoding });
106
125
 
107
- // Create conn
108
- conn = await actor.connectionManager.prepareAndConnectConn(
109
- createHttpDriver(),
110
- parameters,
111
- c.req.raw,
112
- c.req.path,
113
- c.req.header(),
114
- );
126
+ // Create conn
127
+ conn = await actor.connectionManager.prepareAndConnectConn(
128
+ createHttpDriver(),
129
+ parameters,
130
+ c.req.raw,
131
+ c.req.path,
132
+ c.req.header(),
133
+ );
115
134
 
116
- // Call action
117
- const ctx = new ActionContext(actor, conn!);
118
- output = await actor.executeAction(ctx, actionName, actionArgs);
119
- } finally {
120
- if (conn) {
121
- conn.disconnect();
135
+ // Call action
136
+ const ctx = new ActionContext(actor, conn);
137
+ output = await actor.executeAction(ctx, actionName, actionArgs);
138
+ outputReady = true;
139
+ break;
140
+ } catch (error) {
141
+ const shouldRetry =
142
+ error instanceof errors.InternalError &&
143
+ error.message === "Actor is stopping" &&
144
+ attempt < maxAttempts - 1;
145
+ if (shouldRetry) {
146
+ await new Promise((resolve) => setTimeout(resolve, 25));
147
+ continue;
148
+ }
149
+ throw error;
150
+ } finally {
151
+ if (conn) {
152
+ conn.disconnect();
153
+ }
122
154
  }
123
155
  }
156
+ if (!outputReady) {
157
+ throw new errors.InternalError("Action did not complete");
158
+ }
124
159
 
125
160
  // Send response
126
161
  const serialized = serializeWithEncoding(
@@ -138,7 +173,10 @@ export async function handleAction(
138
173
  );
139
174
 
140
175
  // Check outgoing message size
141
- const messageSize = serialized instanceof Uint8Array ? serialized.byteLength : serialized.length;
176
+ const messageSize =
177
+ serialized instanceof Uint8Array
178
+ ? serialized.byteLength
179
+ : serialized.length;
142
180
  if (messageSize > config.maxOutgoingMessageSize) {
143
181
  throw new errors.OutgoingMessageTooLong();
144
182
  }
@@ -149,6 +187,124 @@ export async function handleAction(
149
187
  });
150
188
  }
151
189
 
190
+ export async function handleQueueSend(
191
+ c: HonoContext,
192
+ config: RegistryConfig,
193
+ actorDriver: ActorDriver,
194
+ actorId: string,
195
+ queueName?: string,
196
+ ) {
197
+ const encoding = getRequestEncoding(c.req);
198
+ const params = getRequestConnParams(c.req);
199
+ const arrayBuffer = await c.req.arrayBuffer();
200
+
201
+ if (arrayBuffer.byteLength > config.maxIncomingMessageSize) {
202
+ throw new errors.IncomingMessageTooLong();
203
+ }
204
+
205
+ const request = deserializeWithEncoding(
206
+ encoding,
207
+ new Uint8Array(arrayBuffer),
208
+ HTTP_QUEUE_SEND_REQUEST_VERSIONED,
209
+ HttpQueueSendRequestSchema,
210
+ (json: HttpQueueSendRequestJson) => json,
211
+ (bare: protocol.HttpQueueSendRequest) => ({
212
+ name: bare.name ?? undefined,
213
+ body: cbor.decode(new Uint8Array(bare.body)),
214
+ wait: bare.wait ?? undefined,
215
+ timeout:
216
+ bare.timeout !== null && bare.timeout !== undefined
217
+ ? Number(bare.timeout)
218
+ : undefined,
219
+ }),
220
+ );
221
+
222
+ const name = queueName ?? request.name;
223
+ if (!name) {
224
+ throw new errors.InvalidRequest("missing queue name");
225
+ }
226
+
227
+ const actor = await actorDriver.loadActor(actorId);
228
+ if (!hasSchemaConfigKey(actor.config.queues, name)) {
229
+ actor.rLog.warn({
230
+ msg: "ignoring incoming queue message for undefined queue",
231
+ queueName: name,
232
+ hasQueueConfig: actor.config.queues !== undefined,
233
+ });
234
+ const ignoredResponse = serializeWithEncoding(
235
+ encoding,
236
+ { status: "completed" as const, response: undefined },
237
+ HTTP_QUEUE_SEND_RESPONSE_VERSIONED,
238
+ CLIENT_PROTOCOL_CURRENT_VERSION,
239
+ HttpQueueSendResponseSchema,
240
+ (value): HttpQueueSendResponseJson => ({
241
+ status: value.status,
242
+ response: value.response,
243
+ }),
244
+ (value): protocol.HttpQueueSendResponse => ({
245
+ status: value.status,
246
+ response:
247
+ value.response !== undefined
248
+ ? bufferToArrayBuffer(cbor.encode(value.response))
249
+ : null,
250
+ }),
251
+ );
252
+ return c.body(ignoredResponse as Uint8Array as any, 200, {
253
+ "Content-Type": contentTypeForEncoding(encoding),
254
+ });
255
+ }
256
+
257
+ const conn = await actor.connectionManager.prepareAndConnectConn(
258
+ createHttpDriver(),
259
+ params,
260
+ c.req.raw,
261
+ c.req.path,
262
+ c.req.header(),
263
+ );
264
+ let result: { status: "completed" | "timedOut"; response?: unknown } = {
265
+ status: "completed",
266
+ };
267
+ try {
268
+ const ctx = new ActionContext(actor, conn);
269
+ await actor.assertCanPublish(ctx, name);
270
+
271
+ if (request.wait) {
272
+ result = await actor.queueManager.enqueueAndWait(
273
+ name,
274
+ request.body,
275
+ request.timeout,
276
+ );
277
+ } else {
278
+ await actor.queueManager.enqueue(name, request.body);
279
+ }
280
+ } finally {
281
+ conn.disconnect();
282
+ }
283
+
284
+ const response = serializeWithEncoding(
285
+ encoding,
286
+ result,
287
+ HTTP_QUEUE_SEND_RESPONSE_VERSIONED,
288
+ CLIENT_PROTOCOL_CURRENT_VERSION,
289
+ HttpQueueSendResponseSchema,
290
+ (value): HttpQueueSendResponseJson => ({
291
+ status: value.status,
292
+ response: value.response,
293
+ }),
294
+ (value): protocol.HttpQueueSendResponse => ({
295
+ status: value.status,
296
+ response:
297
+ value.response !== undefined
298
+ ? bufferToArrayBuffer(cbor.encode(value.response))
299
+ : null,
300
+ }),
301
+ );
302
+
303
+ return c.body(response as Uint8Array as any, 200, {
304
+ "Content-Type": contentTypeForEncoding(encoding),
305
+ });
306
+ }
307
+
152
308
  export async function handleRawRequest(
153
309
  c: HonoContext,
154
310
  req: Request,
@@ -86,7 +86,7 @@ export async function routeWebSocket(
86
86
  });
87
87
 
88
88
  // Promise used to wait for the websocket close in `disconnect`
89
- const closePromiseResolvers = promiseWithResolvers<void>();
89
+ const closePromiseResolvers = promiseWithResolvers<void>((reason) => loggerWithoutContext().warn({ msg: "unhandled websocket close promise rejection", reason }));
90
90
 
91
91
  // Strip query parameters from requestPath for routing purposes.
92
92
  // This handles paths like "/websocket?query=value" which should route
@@ -188,13 +188,13 @@ export async function routeWebSocket(
188
188
  return {
189
189
  conn: createdConn!,
190
190
  onOpen: (_evt: any, ws: WSContext) => {
191
- ws.close(1011, code);
191
+ ws.close(1011, `${group}.${code}`);
192
192
  },
193
193
  onMessage: (_evt: { data: any }, ws: WSContext) => {
194
194
  ws.close(1011, "actor.not_loaded");
195
195
  },
196
- onClose: (_event: any, _ws: WSContext) => {},
197
- onError: (_error: unknown) => {},
196
+ onClose: (_event: any, _ws: WSContext) => { },
197
+ onError: (_error: unknown) => { },
198
198
  };
199
199
  }
200
200
  }
@@ -213,6 +213,10 @@ export async function handleWebSocketConnect(
213
213
  exposeInternalError,
214
214
  }: WebSocketHandlerOpts,
215
215
  ): Promise<UpgradeWebSocketArgs> {
216
+ // Process WS messages in order to avoid races between subscription updates
217
+ // and subsequent action requests.
218
+ let pendingMessage = Promise.resolve();
219
+
216
220
  return {
217
221
  conn,
218
222
  actor,
@@ -230,33 +234,18 @@ export async function handleWebSocketConnect(
230
234
  actor.connectionManager.connectConn(conn);
231
235
  },
232
236
  onMessage: (evt: RivetMessageEvent, ws: WSContext) => {
233
- // Handle message asynchronously
234
237
  actor.rLog.debug({ msg: "received message" });
235
-
236
238
  const value = evt.data.valueOf() as InputData;
237
- parseMessage(value, {
238
- encoding: encoding,
239
- maxIncomingMessageSize: runConfig.maxIncomingMessageSize,
240
- })
241
- .then((message) => {
242
- actor.processMessage(message, conn).catch((error) => {
243
- const { code } = deconstructError(
244
- error,
245
- actor.rLog,
246
- {
247
- wsEvent: "message",
248
- },
249
- exposeInternalError,
250
- );
251
- ws.close(1011, code);
239
+ pendingMessage = pendingMessage
240
+ .then(async () => {
241
+ const message = await parseMessage(value, {
242
+ encoding: encoding,
243
+ maxIncomingMessageSize: runConfig.maxIncomingMessageSize,
252
244
  });
245
+ await actor.processMessage(message, conn);
253
246
  })
254
247
  .catch((error) => {
255
- // Close connection on parse errors (including incoming message too large).
256
- // This is fail-fast behavior: we cannot send an error response for a
257
- // message we couldn't parse (no actionId), and skipping the message
258
- // could cause request/response ordering corruption.
259
- const { code } = deconstructError(
248
+ const { group, code } = deconstructError(
260
249
  error,
261
250
  actor.rLog,
262
251
  {
@@ -264,7 +253,7 @@ export async function handleWebSocketConnect(
264
253
  },
265
254
  exposeInternalError,
266
255
  );
267
- ws.close(1011, code);
256
+ ws.close(1011, `${group}.${code}`);
268
257
  });
269
258
  },
270
259
  onClose: (
@@ -350,7 +339,7 @@ export async function handleRawWebSocket(
350
339
  },
351
340
  // Raw websocket messages are handled directly by the actor's event
352
341
  // listeners on the WebSocket object, not through this callback
353
- onMessage: (_evt: any, _ws: any) => {},
342
+ onMessage: (_evt: any, _ws: any) => { },
354
343
  onClose: (evt: any, ws: any) => {
355
344
  // Resolve the close promise
356
345
  closePromiseResolvers.resolve();
@@ -358,7 +347,7 @@ export async function handleRawWebSocket(
358
347
  // Clean up the connection
359
348
  conn.disconnect(evt?.reason);
360
349
  },
361
- onError: (error: any, ws: any) => {},
350
+ onError: (error: any, ws: any) => { },
362
351
  };
363
352
  }
364
353
 
@@ -4,8 +4,10 @@ import {
4
4
  type ActionOutput,
5
5
  type ConnsMessageOpts,
6
6
  handleAction,
7
+ handleQueueSend,
7
8
  handleRawRequest,
8
9
  } from "@/actor/router-endpoints";
10
+
9
11
  import {
10
12
  PATH_CONNECT,
11
13
  PATH_INSPECTOR_CONNECT,
@@ -17,6 +19,9 @@ import {
17
19
  loggerMiddleware,
18
20
  } from "@/common/router";
19
21
  import { noopNext } from "@/common/utils";
22
+ import { inspectorLogger } from "@/inspector/log";
23
+ import { timingSafeEqual } from "@/utils/crypto";
24
+ import { getNodeEnv } from "@/utils/env-vars";
20
25
 
21
26
  import type { RegistryConfig } from "@/registry/config";
22
27
  import { type GetUpgradeWebSocket, VERSION } from "@/utils";
@@ -158,12 +163,184 @@ export function createActorRouter(
158
163
  );
159
164
  }
160
165
 
166
+ // Inspector HTTP endpoints for agent-based debugging
167
+ if (config.inspector.enabled) {
168
+ // Auth middleware for inspector routes
169
+ const inspectorAuth = async (c: any): Promise<Response | undefined> => {
170
+ if (getNodeEnv() === "development" && !config.inspector.token()) {
171
+ inspectorLogger().warn({
172
+ msg: "RIVET_INSPECTOR_TOKEN is not set, skipping inspector auth in development mode",
173
+ });
174
+ return undefined;
175
+ }
176
+
177
+ const userToken = c.req.header("Authorization")?.replace("Bearer ", "");
178
+ if (!userToken) {
179
+ return c.text("Unauthorized", 401);
180
+ }
181
+
182
+ const inspectorToken = config.inspector.token();
183
+ if (!inspectorToken) {
184
+ return c.text("Unauthorized", 401);
185
+ }
186
+
187
+ if (!timingSafeEqual(userToken, inspectorToken)) {
188
+ return c.text("Unauthorized", 401);
189
+ }
190
+
191
+ return undefined;
192
+ };
193
+
194
+ router.get("/inspector/state", async (c) => {
195
+ const authResponse = await inspectorAuth(c);
196
+ if (authResponse) return authResponse;
197
+
198
+ const actor = await actorDriver.loadActor(c.env.actorId);
199
+ const isStateEnabled = actor.inspector.isStateEnabled();
200
+ const state = isStateEnabled ? actor.inspector.getStateJson() : undefined;
201
+ return c.json({ state, isStateEnabled });
202
+ });
203
+
204
+ router.patch("/inspector/state", async (c) => {
205
+ const authResponse = await inspectorAuth(c);
206
+ if (authResponse) return authResponse;
207
+
208
+ const actor = await actorDriver.loadActor(c.env.actorId);
209
+ const body = await c.req.json<{ state: unknown }>();
210
+ await actor.inspector.setStateJson(body.state);
211
+ return c.json({ ok: true });
212
+ });
213
+
214
+ router.get("/inspector/connections", async (c) => {
215
+ const authResponse = await inspectorAuth(c);
216
+ if (authResponse) return authResponse;
217
+
218
+ const actor = await actorDriver.loadActor(c.env.actorId);
219
+ const connections = actor.inspector.getConnectionsJson();
220
+ return c.json({ connections });
221
+ });
222
+
223
+ router.get("/inspector/rpcs", async (c) => {
224
+ const authResponse = await inspectorAuth(c);
225
+ if (authResponse) return authResponse;
226
+
227
+ const actor = await actorDriver.loadActor(c.env.actorId);
228
+ const rpcs = actor.inspector.getRpcs();
229
+ return c.json({ rpcs });
230
+ });
231
+
232
+ router.post("/inspector/action/:name", async (c) => {
233
+ const authResponse = await inspectorAuth(c);
234
+ if (authResponse) return authResponse;
235
+
236
+ const actor = await actorDriver.loadActor(c.env.actorId);
237
+ const name = c.req.param("name");
238
+ const body = await c.req.json<{ args: unknown[] }>();
239
+ const output = await actor.inspector.executeActionJson(
240
+ name,
241
+ body.args ?? [],
242
+ );
243
+ return c.json({ output });
244
+ });
245
+
246
+ router.get("/inspector/queue", async (c) => {
247
+ const authResponse = await inspectorAuth(c);
248
+ if (authResponse) return authResponse;
249
+
250
+ const actor = await actorDriver.loadActor(c.env.actorId);
251
+ const limit = parseInt(c.req.query("limit") ?? "50", 10);
252
+ const status = await actor.inspector.getQueueStatusJson(limit);
253
+ return c.json(status);
254
+ });
255
+
256
+ router.get("/inspector/traces", async (c) => {
257
+ const authResponse = await inspectorAuth(c);
258
+ if (authResponse) return authResponse;
259
+
260
+ const actor = await actorDriver.loadActor(c.env.actorId);
261
+ const startMs = parseInt(c.req.query("startMs") ?? "0", 10);
262
+ const endMs = parseInt(
263
+ c.req.query("endMs") ?? String(Date.now()),
264
+ 10,
265
+ );
266
+ const limit = parseInt(c.req.query("limit") ?? "1000", 10);
267
+
268
+ await actor.traces.flush();
269
+ const result = await actor.inspector.getTracesJson({
270
+ startMs,
271
+ endMs,
272
+ limit,
273
+ });
274
+ return c.json(result);
275
+ });
276
+
277
+ router.get("/inspector/workflow-history", async (c) => {
278
+ const authResponse = await inspectorAuth(c);
279
+ if (authResponse) return authResponse;
280
+
281
+ const actor = await actorDriver.loadActor(c.env.actorId);
282
+ const result = actor.inspector.getWorkflowHistoryJson();
283
+ return c.json(result);
284
+ });
285
+
286
+ router.get("/inspector/summary", async (c) => {
287
+ const authResponse = await inspectorAuth(c);
288
+ if (authResponse) return authResponse;
289
+
290
+ const actor = await actorDriver.loadActor(c.env.actorId);
291
+
292
+ const isStateEnabled = actor.inspector.isStateEnabled();
293
+ const isDatabaseEnabled = actor.inspector.isDatabaseEnabled();
294
+ const isWorkflowEnabled = actor.inspector.isWorkflowEnabled();
295
+
296
+ const state = isStateEnabled
297
+ ? actor.inspector.getStateJson()
298
+ : undefined;
299
+ const connections = actor.inspector.getConnectionsJson();
300
+ const rpcs = actor.inspector.getRpcs();
301
+ const queueSize = actor.inspector.getQueueSize();
302
+ const workflowHistory = actor.inspector.getWorkflowHistory();
303
+
304
+ // Convert BigInt values in workflow history to numbers for JSON serialization.
305
+ const bigIntReplacer = (_key: string, value: unknown) =>
306
+ typeof value === "bigint" ? Number(value) : value;
307
+ const safeWorkflowHistory = workflowHistory
308
+ ? JSON.parse(JSON.stringify(workflowHistory, bigIntReplacer))
309
+ : null;
310
+
311
+ return c.json({
312
+ state,
313
+ connections,
314
+ rpcs,
315
+ queueSize,
316
+ isStateEnabled,
317
+ isDatabaseEnabled,
318
+ isWorkflowEnabled,
319
+ workflowHistory: safeWorkflowHistory,
320
+ });
321
+ });
322
+ }
323
+
161
324
  router.post("/action/:action", async (c) => {
162
325
  const actionName = c.req.param("action");
163
326
 
164
327
  return handleAction(c, config, actorDriver, actionName, c.env.actorId);
165
328
  });
166
329
 
330
+ router.post("/queue", async (c) => {
331
+ return handleQueueSend(c, config, actorDriver, c.env.actorId);
332
+ });
333
+
334
+ router.post("/queue/:name", async (c) => {
335
+ return handleQueueSend(
336
+ c,
337
+ config,
338
+ actorDriver,
339
+ c.env.actorId,
340
+ c.req.param("name"),
341
+ );
342
+ });
343
+
167
344
  router.all("/request/*", async (c) => {
168
345
  // TODO: This is not a clean way of doing this since `/http/` might exist mid-path
169
346
  // Strip the /http prefix from the URL to get the original path