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
@@ -5,48 +5,24 @@ import {
5
5
  CONN_DRIVER_SYMBOL,
6
6
  CONN_STATE_MANAGER_SYMBOL,
7
7
  } from "@/actor/conn/mod";
8
+ import { getRunInspectorConfig } from "@/actor/config";
8
9
  import { ActionContext } from "@/actor/contexts/action";
9
10
  import * as actorErrors from "@/actor/errors";
10
11
  import type { AnyActorInstance } from "@/mod";
11
12
  import type * as schema from "@/schemas/actor-inspector/mod";
12
- import { assertUnreachable, bufferToArrayBuffer } from "@/utils";
13
- import type { Event } from "./mod";
13
+ import { bufferToArrayBuffer } from "@/utils";
14
14
 
15
15
  interface ActorInspectorEmitterEvents {
16
16
  stateUpdated: (state: unknown) => void;
17
17
  connectionsUpdated: () => void;
18
- eventFired: (event: EventDetails) => void;
19
- eventsChanged: () => void;
18
+ queueUpdated: () => void;
19
+ workflowHistoryUpdated: (history: schema.WorkflowHistory) => void;
20
20
  }
21
21
 
22
22
  export type Connection = Omit<schema.Connection, "details"> & {
23
23
  details: unknown;
24
24
  };
25
25
 
26
- type EventDetails =
27
- | {
28
- type: "action";
29
- name: string;
30
- args: unknown[];
31
- connId: string;
32
- }
33
- | {
34
- type: "subscribe";
35
- eventName: string;
36
- connId: string;
37
- }
38
- | {
39
- type: "unsubscribe";
40
- eventName: string;
41
- connId: string;
42
- }
43
- | {
44
- type: "event";
45
- eventName: string;
46
- args: unknown[];
47
- connId: string;
48
- }
49
- | { type: "broadcast"; eventName: string; args: unknown[] };
50
26
 
51
27
  /**
52
28
  * Provides a unified interface for inspecting actor external and internal state.
@@ -54,34 +30,67 @@ type EventDetails =
54
30
  export class ActorInspector {
55
31
  public readonly emitter = createNanoEvents<ActorInspectorEmitterEvents>();
56
32
 
57
- #lastEvents: Event[] = [];
33
+ #lastQueueSize = 0;
34
+ #workflowInspector?: NonNullable<
35
+ ReturnType<typeof getRunInspectorConfig>
36
+ >["workflow"];
58
37
 
59
38
  constructor(private readonly actor: AnyActorInstance) {
60
- this.emitter.on("eventFired", (event) => {
61
- const commonParams = {
62
- id: crypto.randomUUID(),
63
- timestamp: BigInt(Date.now()),
64
- };
65
-
66
- this.#lastEvents.push({
67
- ...commonParams,
68
- ...transformEvent(event),
39
+ this.#lastQueueSize = actor.queueManager?.size ?? 0;
40
+ const runInspector = getRunInspectorConfig(actor.config.run);
41
+ this.#workflowInspector = runInspector?.workflow;
42
+ if (this.#workflowInspector?.onHistoryUpdated) {
43
+ this.#workflowInspector.onHistoryUpdated((history) => {
44
+ this.emitter.emit(
45
+ "workflowHistoryUpdated",
46
+ history as schema.WorkflowHistory,
47
+ );
69
48
  });
49
+ }
50
+ }
70
51
 
71
- // keep the last 100 events
72
- if (this.#lastEvents.length > 100) {
73
- this.#lastEvents = this.#lastEvents.slice(-100);
74
- }
75
- });
52
+ getQueueSize() {
53
+ return this.#lastQueueSize;
76
54
  }
77
55
 
78
- getLastEvents() {
79
- return this.#lastEvents;
56
+ async getQueueStatus(limit: number): Promise<schema.QueueStatus> {
57
+ const maxSize = this.actor.config.options.maxQueueSize;
58
+ const safeLimit = Math.max(0, Math.floor(limit));
59
+ const messages = await this.actor.queueManager.getMessages();
60
+ const sorted = messages.sort(
61
+ (a, b) => a.createdAt - b.createdAt,
62
+ );
63
+ const limited = safeLimit > 0 ? sorted.slice(0, safeLimit) : [];
64
+ return {
65
+ size: BigInt(this.#lastQueueSize),
66
+ maxSize: BigInt(maxSize),
67
+ truncated: sorted.length > limited.length,
68
+ messages: limited.map((message) => ({
69
+ id: message.id,
70
+ name: message.name,
71
+ createdAtMs: BigInt(message.createdAt),
72
+ })),
73
+ };
80
74
  }
81
75
 
82
- clearEvents() {
83
- this.#lastEvents = [];
84
- this.emitter.emit("eventsChanged");
76
+ updateQueueSize(size: number) {
77
+ if (this.#lastQueueSize === size) {
78
+ return;
79
+ }
80
+ this.#lastQueueSize = size;
81
+ this.emitter.emit("queueUpdated");
82
+ }
83
+
84
+ isWorkflowEnabled() {
85
+ return this.#workflowInspector !== undefined;
86
+ }
87
+
88
+ getWorkflowHistory(): schema.WorkflowHistory | null {
89
+ if (!this.#workflowInspector) {
90
+ return null;
91
+ }
92
+ const history = this.#workflowInspector.getHistory();
93
+ return (history ?? null) as schema.WorkflowHistory | null;
85
94
  }
86
95
 
87
96
  // actor accessor methods
@@ -94,6 +103,73 @@ export class ActorInspector {
94
103
  }
95
104
  }
96
105
 
106
+ async getDatabaseSchema(): Promise<ArrayBuffer> {
107
+ if (!this.isDatabaseEnabled()) {
108
+ throw new actorErrors.DatabaseNotEnabled();
109
+ }
110
+
111
+ const db = this.actor.db;
112
+
113
+ // Get table list from sqlite_master, excluding internal tables.
114
+ const tables = await db.execute(
115
+ "SELECT name, type FROM sqlite_master WHERE type IN ('table', 'view') AND name NOT LIKE 'sqlite_%' AND name NOT LIKE '__drizzle_%'",
116
+ ) as { name: string; type: string }[];
117
+
118
+ // Serialize all queries to avoid concurrent @rivetkit/sqlite access
119
+ // which can cause "file is not a database" errors.
120
+ const tableInfos = [];
121
+ for (const table of tables) {
122
+ const quoted = `"${escapeDoubleQuotes(table.name)}"`;
123
+ const sample = await db.execute(
124
+ `SELECT * FROM ${quoted} LIMIT 1`,
125
+ ) as Record<string, unknown>[];
126
+ const countResult = await db.execute(
127
+ `SELECT COUNT(*) as count FROM ${quoted}`,
128
+ ) as { count: number }[];
129
+
130
+ const columnNames = sample?.[0]
131
+ ? Object.keys(sample[0])
132
+ : [];
133
+
134
+ tableInfos.push({
135
+ table: { schema: "main", name: table.name, type: table.type },
136
+ columns: columnNames.map((name, cid) => ({
137
+ cid,
138
+ name,
139
+ type: "",
140
+ notnull: 0,
141
+ dflt_value: null,
142
+ pk: 0,
143
+ })),
144
+ foreignKeys: [],
145
+ records: countResult?.[0]?.count ?? 0,
146
+ });
147
+ }
148
+
149
+ return bufferToArrayBuffer(cbor.encode({ tables: tableInfos }));
150
+ }
151
+
152
+ async getDatabaseTableRows(
153
+ table: string,
154
+ limit: number,
155
+ offset: number,
156
+ ): Promise<ArrayBuffer> {
157
+ if (!this.isDatabaseEnabled()) {
158
+ throw new actorErrors.DatabaseNotEnabled();
159
+ }
160
+
161
+ const db = this.actor.db;
162
+ const safeLimit = Math.max(0, Math.min(Math.floor(limit), 500));
163
+ const safeOffset = Math.max(0, Math.floor(offset));
164
+ const quoted = `"${escapeDoubleQuotes(table)}"`;
165
+ const result = await db.execute(
166
+ `SELECT * FROM ${quoted} LIMIT ? OFFSET ?`,
167
+ safeLimit,
168
+ safeOffset,
169
+ );
170
+ return bufferToArrayBuffer(cbor.encode(result));
171
+ }
172
+
97
173
  isStateEnabled() {
98
174
  return this.actor.stateEnabled;
99
175
  }
@@ -168,63 +244,109 @@ export class ActorInspector {
168
244
  conn.disconnect();
169
245
  }
170
246
  }
171
- }
172
247
 
173
- function transformEvent(event: EventDetails) {
174
- if (event.type === "action") {
175
- return {
176
- body: {
177
- tag: "ActionEvent",
178
- val: {
179
- name: event.name,
180
- args: bufferToArrayBuffer(cbor.encode(event.args)),
248
+ // JSON-native methods for the HTTP inspector API. These return raw JS
249
+ // objects suitable for JSON serialization instead of CBOR-encoded buffers.
181
250
 
182
- connId: event.connId,
183
- },
184
- },
185
- } as const;
186
- } else if (event.type === "subscribe") {
187
- return {
188
- body: {
189
- tag: "SubscribeEvent",
190
- val: {
191
- eventName: event.eventName,
192
- connId: event.connId,
193
- },
194
- },
195
- } as const;
196
- } else if (event.type === "unsubscribe") {
197
- return {
198
- body: {
199
- tag: "UnSubscribeEvent",
200
- val: {
201
- eventName: event.eventName,
202
- connId: event.connId,
203
- },
204
- },
205
- } as const;
206
- } else if (event.type === "event") {
207
- return {
208
- body: {
209
- tag: "FiredEvent",
210
- val: {
211
- eventName: event.eventName,
212
- args: bufferToArrayBuffer(cbor.encode(event.args)),
213
- connId: event.connId,
251
+ getStateJson(): unknown {
252
+ if (!this.actor.stateEnabled) {
253
+ throw new actorErrors.StateNotEnabled();
254
+ }
255
+ return this.actor.stateManager.persistRaw.state;
256
+ }
257
+
258
+ async setStateJson(state: unknown): Promise<void> {
259
+ if (!this.actor.stateEnabled) {
260
+ throw new actorErrors.StateNotEnabled();
261
+ }
262
+ this.actor.stateManager.state = state;
263
+ await this.actor.stateManager.saveState({ immediate: true });
264
+ }
265
+
266
+ getConnectionsJson(): { id: string; details: unknown }[] {
267
+ return Array.from(
268
+ this.actor.connectionManager.connections.entries(),
269
+ ).map(([id, conn]) => {
270
+ const connStateManager = conn[CONN_STATE_MANAGER_SYMBOL];
271
+ return {
272
+ type: conn[CONN_DRIVER_SYMBOL]?.type,
273
+ id,
274
+ details: {
275
+ type: conn[CONN_DRIVER_SYMBOL]?.type,
276
+ params: conn.params as any,
277
+ stateEnabled: connStateManager.stateEnabled,
278
+ state: connStateManager.stateEnabled
279
+ ? connStateManager.state
280
+ : undefined,
281
+ subscriptions: conn.subscriptions.size,
282
+ isHibernatable: conn.isHibernatable,
214
283
  },
215
- },
216
- } as const;
217
- } else if (event.type === "broadcast") {
284
+ };
285
+ });
286
+ }
287
+
288
+ async executeActionJson(name: string, args: unknown[]): Promise<unknown> {
289
+ const conn = await this.actor.connectionManager.prepareAndConnectConn(
290
+ createHttpDriver(),
291
+ undefined,
292
+ undefined,
293
+ undefined,
294
+ undefined,
295
+ );
296
+
297
+ try {
298
+ return await this.actor.executeAction(
299
+ new ActionContext(this.actor, conn),
300
+ name,
301
+ args,
302
+ );
303
+ } finally {
304
+ conn.disconnect();
305
+ }
306
+ }
307
+
308
+ async getTracesJson(options: {
309
+ startMs: number;
310
+ endMs: number;
311
+ limit: number;
312
+ }): Promise<{ otlp: unknown; clamped: boolean }> {
313
+ const result = await this.actor.traces.readRange(options);
314
+ return result;
315
+ }
316
+
317
+ getWorkflowHistoryJson(): { history: unknown | null; isWorkflowEnabled: boolean } {
318
+ const bigIntReplacer = (_key: string, value: unknown) =>
319
+ typeof value === "bigint" ? Number(value) : value;
320
+ const history = this.getWorkflowHistory();
321
+ const safeHistory = history
322
+ ? JSON.parse(JSON.stringify(history, bigIntReplacer))
323
+ : null;
218
324
  return {
219
- body: {
220
- tag: "BroadcastEvent",
221
- val: {
222
- eventName: event.eventName,
223
- args: bufferToArrayBuffer(cbor.encode(event.args)),
224
- },
225
- },
226
- } as const;
227
- } else {
228
- assertUnreachable(event);
325
+ history: safeHistory,
326
+ isWorkflowEnabled: this.isWorkflowEnabled(),
327
+ };
328
+ }
329
+
330
+ getQueueStatusJson(limit: number): Promise<{
331
+ size: number;
332
+ maxSize: number;
333
+ truncated: boolean;
334
+ messages: { id: number; name: string; createdAtMs: number }[];
335
+ }> {
336
+ return this.getQueueStatus(limit).then((status) => ({
337
+ size: Number(status.size),
338
+ maxSize: Number(status.maxSize),
339
+ truncated: status.truncated,
340
+ messages: status.messages.map((m) => ({
341
+ id: Number(m.id),
342
+ name: m.name,
343
+ createdAtMs: Number(m.createdAtMs),
344
+ })),
345
+ }));
229
346
  }
230
347
  }
348
+
349
+ function escapeDoubleQuotes(value: string): string {
350
+ return value.replace(/"/g, '""');
351
+ }
352
+
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import { z } from "zod/v4";
2
2
  import {
3
3
  getRivetkitInspectorToken,
4
4
  isDev,
@@ -3,11 +3,13 @@ import type { Unsubscribe } from "nanoevents";
3
3
  import type { UpgradeWebSocketArgs } from "@/actor/router-websocket-endpoints";
4
4
  import type { AnyActorInstance, RivetMessageEvent } from "@/mod";
5
5
  import type { ToClient } from "@/schemas/actor-inspector/mod";
6
+ import { encodeReadRangeWire } from "@rivetkit/traces/encoding";
6
7
  import {
8
+ CURRENT_VERSION as INSPECTOR_CURRENT_VERSION,
7
9
  TO_CLIENT_VERSIONED as toClient,
8
10
  TO_SERVER_VERSIONED as toServer,
9
11
  } from "@/schemas/actor-inspector/versioned";
10
- import { assertUnreachable } from "@/utils";
12
+ import { assertUnreachable, bufferToArrayBuffer } from "@/utils";
11
13
  import { inspectorLogger } from "./log";
12
14
 
13
15
  export async function handleWebSocketInspectorConnect({
@@ -16,6 +18,7 @@ export async function handleWebSocketInspectorConnect({
16
18
  actor: AnyActorInstance;
17
19
  }): Promise<UpgradeWebSocketArgs> {
18
20
  const inspector = actor.inspector;
21
+ const maxQueueStatusLimit = 200;
19
22
 
20
23
  const listeners: Unsubscribe[] = [];
21
24
  return {
@@ -26,13 +29,15 @@ export async function handleWebSocketInspectorConnect({
26
29
  tag: "Init",
27
30
  val: {
28
31
  connections: inspector.getConnections(),
29
- events: inspector.getLastEvents(),
30
32
  rpcs: inspector.getRpcs(),
31
33
  state: inspector.isStateEnabled()
32
34
  ? inspector.getState()
33
35
  : null,
34
36
  isStateEnabled: inspector.isStateEnabled(),
35
37
  isDatabaseEnabled: inspector.isDatabaseEnabled(),
38
+ queueSize: BigInt(inspector.getQueueSize()),
39
+ workflowHistory: inspector.getWorkflowHistory(),
40
+ isWorkflowEnabled: inspector.isWorkflowEnabled(),
36
41
  },
37
42
  },
38
43
  });
@@ -54,19 +59,21 @@ export async function handleWebSocketInspectorConnect({
54
59
  },
55
60
  });
56
61
  }),
57
- inspector.emitter.on("eventFired", () => {
62
+ inspector.emitter.on("queueUpdated", () => {
58
63
  sendMessage(ws, {
59
64
  body: {
60
- tag: "EventsUpdated",
61
- val: { events: inspector.getLastEvents() },
65
+ tag: "QueueUpdated",
66
+ val: {
67
+ queueSize: BigInt(inspector.getQueueSize()),
68
+ },
62
69
  },
63
70
  });
64
71
  }),
65
- inspector.emitter.on("eventsChanged", () => {
72
+ inspector.emitter.on("workflowHistoryUpdated", (history) => {
66
73
  sendMessage(ws, {
67
74
  body: {
68
- tag: "EventsUpdated",
69
- val: { events: inspector.getLastEvents() },
75
+ tag: "WorkflowHistoryUpdated",
76
+ val: { history },
70
77
  },
71
78
  });
72
79
  }),
@@ -115,37 +122,112 @@ export async function handleWebSocketInspectorConnect({
115
122
  },
116
123
  },
117
124
  });
118
- } else if (message.body.tag === "EventsRequest") {
125
+ } else if (message.body.tag === "RpcsListRequest") {
119
126
  sendMessage(ws, {
120
127
  body: {
121
- tag: "EventsResponse",
128
+ tag: "RpcsListResponse",
122
129
  val: {
123
130
  rid: message.body.val.id,
124
- events: inspector.getLastEvents(),
131
+ rpcs: inspector.getRpcs(),
125
132
  },
126
133
  },
127
134
  });
128
- } else if (message.body.tag === "ClearEventsRequest") {
129
- inspector.clearEvents();
135
+ } else if (message.body.tag === "TraceQueryRequest") {
136
+ const { id, startMs, endMs, limit } = message.body.val;
137
+ const wire = await actor.traces.readRangeWire({
138
+ startMs: Number(startMs),
139
+ endMs: Number(endMs),
140
+ limit: Number(limit),
141
+ });
130
142
  sendMessage(ws, {
131
143
  body: {
132
- tag: "EventsResponse",
144
+ tag: "TraceQueryResponse",
133
145
  val: {
134
- rid: message.body.val.id,
135
- events: [],
146
+ rid: id,
147
+ payload: bufferToArrayBuffer(
148
+ encodeReadRangeWire(wire),
149
+ ),
136
150
  },
137
151
  },
138
152
  });
139
- } else if (message.body.tag === "RpcsListRequest") {
153
+ } else if (message.body.tag === "QueueRequest") {
154
+ const { id, limit } = message.body.val;
155
+ const status = await inspector.getQueueStatus(
156
+ Math.min(Number(limit), maxQueueStatusLimit),
157
+ );
140
158
  sendMessage(ws, {
141
159
  body: {
142
- tag: "RpcsListResponse",
160
+ tag: "QueueResponse",
161
+ val: {
162
+ rid: id,
163
+ status,
164
+ },
165
+ },
166
+ });
167
+ } else if (message.body.tag === "WorkflowHistoryRequest") {
168
+ sendMessage(ws, {
169
+ body: {
170
+ tag: "WorkflowHistoryResponse",
143
171
  val: {
144
172
  rid: message.body.val.id,
145
- rpcs: inspector.getRpcs(),
173
+ history: inspector.getWorkflowHistory(),
174
+ isWorkflowEnabled:
175
+ inspector.isWorkflowEnabled(),
146
176
  },
147
177
  },
148
178
  });
179
+ } else if (message.body.tag === "DatabaseSchemaRequest") {
180
+ const { id } = message.body.val;
181
+ try {
182
+ const schema = await inspector.getDatabaseSchema();
183
+ sendMessage(ws, {
184
+ body: {
185
+ tag: "DatabaseSchemaResponse",
186
+ val: { rid: id, schema },
187
+ },
188
+ });
189
+ } catch (error) {
190
+ inspectorLogger().warn(
191
+ { error },
192
+ "Failed to get database schema",
193
+ );
194
+ sendMessage(ws, {
195
+ body: {
196
+ tag: "Error",
197
+ val: {
198
+ message: `Failed to get database schema: ${error instanceof Error ? error.message : String(error)}`,
199
+ },
200
+ },
201
+ });
202
+ }
203
+ } else if (message.body.tag === "DatabaseTableRowsRequest") {
204
+ const { id, table, limit, offset } = message.body.val;
205
+ try {
206
+ const result = await inspector.getDatabaseTableRows(
207
+ table,
208
+ Number(limit),
209
+ Number(offset),
210
+ );
211
+ sendMessage(ws, {
212
+ body: {
213
+ tag: "DatabaseTableRowsResponse",
214
+ val: { rid: id, result },
215
+ },
216
+ });
217
+ } catch (error) {
218
+ inspectorLogger().warn(
219
+ { error },
220
+ "Failed to get database table rows",
221
+ );
222
+ sendMessage(ws, {
223
+ body: {
224
+ tag: "Error",
225
+ val: {
226
+ message: `Failed to get database rows: ${error instanceof Error ? error.message : String(error)}`,
227
+ },
228
+ },
229
+ });
230
+ }
149
231
  } else {
150
232
  assertUnreachable(message.body);
151
233
  }
@@ -181,7 +263,7 @@ function sendMessage(ws: WSContext, message: ToClient) {
181
263
  ws.send(
182
264
  toClient.serializeWithEmbeddedVersion(
183
265
  message,
184
- 1,
266
+ INSPECTOR_CURRENT_VERSION,
185
267
  ) as unknown as ArrayBuffer,
186
268
  );
187
269
  }
@@ -0,0 +1,8 @@
1
+ // Browser-safe inspector exports (schemas and types only, no server runtime)
2
+ export * from "../schemas/actor-inspector/mod";
3
+ export * from "../schemas/actor-inspector/versioned";
4
+ export type { WorkflowHistory as TransportWorkflowHistory } from "../schemas/transport/mod";
5
+ export {
6
+ decodeWorkflowHistoryTransport,
7
+ encodeWorkflowHistoryTransport,
8
+ } from "./transport";
@@ -1,2 +1,4 @@
1
1
  export * from "../schemas/actor-inspector/mod";
2
2
  export * from "../schemas/actor-inspector/versioned";
3
+ export { decodeWorkflowHistoryTransport, encodeWorkflowHistoryTransport } from "./transport";
4
+ export type { WorkflowHistory as TransportWorkflowHistory } from "../schemas/transport/mod";
@@ -0,0 +1,40 @@
1
+
2
+ import { extract } from "tar";
3
+ import { getNodeFs, getNodeOs, getNodePath, getNodeUrl } from "@/utils/node";
4
+
5
+ let extractedDir: string | undefined;
6
+ let extractionPromise: Promise<string> | undefined;
7
+
8
+ export async function getInspectorDir(): Promise<string> {
9
+ if (extractedDir !== undefined) return extractedDir;
10
+ if (extractionPromise !== undefined) return extractionPromise;
11
+
12
+ const nodeFs = getNodeFs();
13
+ const os = getNodeOs();
14
+ const url = getNodeUrl();
15
+ const path = getNodePath();
16
+
17
+ extractionPromise = (async () => {
18
+ const tarball = path.join(
19
+ path.dirname(url.fileURLToPath(import.meta.url)),
20
+ "../../dist/inspector.tar.gz",
21
+ );
22
+
23
+ try {
24
+ await nodeFs.access(tarball);
25
+ } catch {
26
+ throw new Error(
27
+ `Inspector tarball not found at ${tarball}. Run 'pnpm build:pack-inspector' first.`,
28
+ );
29
+ }
30
+
31
+ const dest = path.join(os.tmpdir(), "rivetkit-inspector");
32
+ await nodeFs.mkdir(dest, { recursive: true });
33
+ await extract({ file: tarball, cwd: dest });
34
+
35
+ extractedDir = dest;
36
+ return dest;
37
+ })();
38
+
39
+ return extractionPromise;
40
+ }
@@ -0,0 +1,18 @@
1
+ import type { WorkflowHistory } from "@/schemas/transport/mod";
2
+ import {
3
+ decodeWorkflowHistory,
4
+ encodeWorkflowHistory,
5
+ } from "@/schemas/transport/mod";
6
+ import { bufferToArrayBuffer, toUint8Array } from "@/utils";
7
+
8
+ export function encodeWorkflowHistoryTransport(
9
+ history: WorkflowHistory,
10
+ ): ArrayBuffer {
11
+ return bufferToArrayBuffer(encodeWorkflowHistory(history));
12
+ }
13
+
14
+ export function decodeWorkflowHistoryTransport(
15
+ data: ArrayBuffer | ArrayBufferView,
16
+ ): WorkflowHistory {
17
+ return decodeWorkflowHistory(toUint8Array(data));
18
+ }