rivetkit 2.1.5 → 2.1.6-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 (333) hide show
  1. package/dist/browser/client.d.ts +593 -588
  2. package/dist/browser/client.js +215 -35
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.js +109 -10
  5. package/dist/browser/inspector/client.js.map +1 -1
  6. package/dist/inspector.tar.gz +0 -0
  7. package/dist/tsup/actor/errors.cjs +2 -2
  8. package/dist/tsup/actor/errors.js +1 -1
  9. package/dist/tsup/{actor-router-consts-D29T1Z-K.d.cts → actor-router-consts-DU-1IdQj.d.cts} +1 -1
  10. package/dist/tsup/{actor-router-consts-D29T1Z-K.d.ts → actor-router-consts-DU-1IdQj.d.ts} +1 -1
  11. package/dist/tsup/chunk-2ELYUO6C.cjs +112 -0
  12. package/dist/tsup/chunk-2ELYUO6C.cjs.map +1 -0
  13. package/dist/tsup/chunk-2LY7RW3Y.cjs +2316 -0
  14. package/dist/tsup/chunk-2LY7RW3Y.cjs.map +1 -0
  15. package/dist/tsup/{chunk-L47L3ZWJ.cjs → chunk-6G7ZNM27.cjs} +11 -6
  16. package/dist/tsup/chunk-6G7ZNM27.cjs.map +1 -0
  17. package/dist/tsup/{chunk-PB5AEMKQ.cjs → chunk-A4KEUCB6.cjs} +84 -34
  18. package/dist/tsup/chunk-A4KEUCB6.cjs.map +1 -0
  19. package/dist/tsup/{chunk-7HTNH26M.js → chunk-AKUJ5OTO.js} +11 -6
  20. package/dist/tsup/chunk-AKUJ5OTO.js.map +1 -0
  21. package/dist/tsup/{chunk-TADUYCHF.js → chunk-C22JYHVT.js} +77 -27
  22. package/dist/tsup/chunk-C22JYHVT.js.map +1 -0
  23. package/dist/tsup/chunk-C4EB42ET.js +1459 -0
  24. package/dist/tsup/chunk-C4EB42ET.js.map +1 -0
  25. package/dist/tsup/chunk-CGGGBIDP.cjs +1459 -0
  26. package/dist/tsup/chunk-CGGGBIDP.cjs.map +1 -0
  27. package/dist/tsup/chunk-CMQPDBBR.cjs +1486 -0
  28. package/dist/tsup/chunk-CMQPDBBR.cjs.map +1 -0
  29. package/dist/tsup/{chunk-GQGRQDRL.cjs → chunk-DH6UINWA.cjs} +4 -4
  30. package/dist/tsup/{chunk-GQGRQDRL.cjs.map → chunk-DH6UINWA.cjs.map} +1 -1
  31. package/dist/tsup/chunk-DK46YYCJ.js +1486 -0
  32. package/dist/tsup/chunk-DK46YYCJ.js.map +1 -0
  33. package/dist/tsup/chunk-EGWXXBZV.js +2316 -0
  34. package/dist/tsup/chunk-EGWXXBZV.js.map +1 -0
  35. package/dist/tsup/{chunk-S662Y6ZU.js → chunk-EONWXYMN.js} +2 -2
  36. package/dist/tsup/{chunk-N4KRDJ56.js → chunk-GFGRBYO2.js} +35 -6
  37. package/dist/tsup/chunk-GFGRBYO2.js.map +1 -0
  38. package/dist/tsup/{chunk-IIJNPVPQ.cjs → chunk-GUHXWPGB.cjs} +1515 -1479
  39. package/dist/tsup/chunk-GUHXWPGB.cjs.map +1 -0
  40. package/dist/tsup/{chunk-TI5PXQGG.cjs → chunk-HNE2AK6C.cjs} +2375 -3713
  41. package/dist/tsup/chunk-HNE2AK6C.cjs.map +1 -0
  42. package/dist/tsup/{chunk-2OK7S6QF.js → chunk-I5I6OALK.js} +2 -2
  43. package/dist/tsup/chunk-IHQAF2HV.cjs +23 -0
  44. package/dist/tsup/chunk-IHQAF2HV.cjs.map +1 -0
  45. package/dist/tsup/{chunk-U5SMSA27.cjs → chunk-JJNZQDUN.cjs} +667 -2517
  46. package/dist/tsup/chunk-JJNZQDUN.cjs.map +1 -0
  47. package/dist/tsup/{chunk-ZPWOYQHN.js → chunk-JJSPHLJN.js} +219 -287
  48. package/dist/tsup/chunk-JJSPHLJN.js.map +1 -0
  49. package/dist/tsup/chunk-JRKPV5NJ.js +481 -0
  50. package/dist/tsup/chunk-JRKPV5NJ.js.map +1 -0
  51. package/dist/tsup/{chunk-VKVNIQRQ.js → chunk-K7MVU5SI.js} +36 -41
  52. package/dist/tsup/chunk-K7MVU5SI.js.map +1 -0
  53. package/dist/tsup/{chunk-KJSYAUOM.js → chunk-MLK3GY6P.js} +43 -27
  54. package/dist/tsup/chunk-MLK3GY6P.js.map +1 -0
  55. package/dist/tsup/{chunk-HYPIHCDT.cjs → chunk-MPLMTJY5.cjs} +123 -23
  56. package/dist/tsup/chunk-MPLMTJY5.cjs.map +1 -0
  57. package/dist/tsup/{chunk-MIX2KB6U.js → chunk-PQWI44WD.js} +1755 -3093
  58. package/dist/tsup/chunk-PQWI44WD.js.map +1 -0
  59. package/dist/tsup/{chunk-SR3KQE7Q.cjs → chunk-SQFCIDCG.cjs} +35 -6
  60. package/dist/tsup/chunk-SQFCIDCG.cjs.map +1 -0
  61. package/dist/tsup/{chunk-WY2SHWXQ.js → chunk-SVHJSM2E.js} +110 -24
  62. package/dist/tsup/chunk-SVHJSM2E.js.map +1 -0
  63. package/dist/tsup/chunk-T5KYKM6R.js +49 -0
  64. package/dist/tsup/chunk-T5KYKM6R.js.map +1 -0
  65. package/dist/tsup/{chunk-7WF2QSIC.cjs → chunk-TJ7DKW6F.cjs} +123 -37
  66. package/dist/tsup/chunk-TJ7DKW6F.cjs.map +1 -0
  67. package/dist/tsup/chunk-UQZRMTM3.js +23 -0
  68. package/dist/tsup/chunk-UQZRMTM3.js.map +1 -0
  69. package/dist/tsup/{chunk-JC6BEPE7.cjs → chunk-V3JSZR5P.cjs} +3 -3
  70. package/dist/tsup/{chunk-JC6BEPE7.cjs.map → chunk-V3JSZR5P.cjs.map} +1 -1
  71. package/dist/tsup/{chunk-OAXJWGMU.cjs → chunk-VBR35EQF.cjs} +271 -339
  72. package/dist/tsup/chunk-VBR35EQF.cjs.map +1 -0
  73. package/dist/tsup/{chunk-EIATSBYZ.js → chunk-VWYO36X4.js} +117 -17
  74. package/dist/tsup/chunk-VWYO36X4.js.map +1 -0
  75. package/dist/tsup/{chunk-JPXO2H55.js → chunk-WW27B6DM.js} +1452 -1416
  76. package/dist/tsup/chunk-WW27B6DM.js.map +1 -0
  77. package/dist/tsup/chunk-YAE3MEJM.cjs +49 -0
  78. package/dist/tsup/chunk-YAE3MEJM.cjs.map +1 -0
  79. package/dist/tsup/{chunk-SRIM3GHD.js → chunk-YGYGANCA.js} +473 -2323
  80. package/dist/tsup/chunk-YGYGANCA.js.map +1 -0
  81. package/dist/tsup/chunk-YZJWZBY5.cjs +481 -0
  82. package/dist/tsup/chunk-YZJWZBY5.cjs.map +1 -0
  83. package/dist/tsup/{chunk-ZFY5J2EP.cjs → chunk-ZZLJ5TSM.cjs} +39 -44
  84. package/dist/tsup/chunk-ZZLJ5TSM.cjs.map +1 -0
  85. package/dist/tsup/client/mod.cjs +10 -7
  86. package/dist/tsup/client/mod.cjs.map +1 -1
  87. package/dist/tsup/client/mod.d.cts +6 -6
  88. package/dist/tsup/client/mod.d.ts +6 -6
  89. package/dist/tsup/client/mod.js +11 -8
  90. package/dist/tsup/common/log.cjs +3 -3
  91. package/dist/tsup/common/log.js +2 -2
  92. package/dist/tsup/common/websocket.cjs +4 -4
  93. package/dist/tsup/common/websocket.js +3 -3
  94. package/dist/tsup/{config-Qj-zLJPc.d.ts → config-C2Wwnc69.d.ts} +142 -208
  95. package/dist/tsup/{config-BiNoIHRs.d.ts → config-DROwzBLT.d.cts} +82 -6
  96. package/dist/tsup/{config-BiNoIHRs.d.cts → config-DROwzBLT.d.ts} +82 -6
  97. package/dist/tsup/{config-iPj5l1bL.d.cts → config-ehT-_3BB.d.cts} +142 -208
  98. package/dist/tsup/{context-DzvH1PBK.d.cts → context-DGMJuAyc.d.ts} +16 -3
  99. package/dist/tsup/{context-CQCMuHND.d.ts → context-Dpp2RJbW.d.cts} +16 -3
  100. package/dist/tsup/db/drizzle/mod.cjs +3 -3
  101. package/dist/tsup/db/drizzle/mod.d.cts +1 -1
  102. package/dist/tsup/db/drizzle/mod.d.ts +1 -1
  103. package/dist/tsup/db/drizzle/mod.js +2 -2
  104. package/dist/tsup/db/mod.cjs +3 -3
  105. package/dist/tsup/db/mod.d.cts +1 -1
  106. package/dist/tsup/db/mod.d.ts +1 -1
  107. package/dist/tsup/db/mod.js +2 -2
  108. package/dist/tsup/{driver-Jo8v-kbU.d.ts → driver-CYZP9QYo.d.ts} +1 -1
  109. package/dist/tsup/{driver-iV8J-WMv.d.cts → driver-CoTFpipv.d.cts} +1 -1
  110. package/dist/tsup/driver-helpers/mod.cjs +7 -5
  111. package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
  112. package/dist/tsup/driver-helpers/mod.d.cts +17 -18
  113. package/dist/tsup/driver-helpers/mod.d.ts +17 -18
  114. package/dist/tsup/driver-helpers/mod.js +11 -9
  115. package/dist/tsup/driver-test-suite/mod.cjs +1275 -228
  116. package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
  117. package/dist/tsup/driver-test-suite/mod.d.cts +6 -5
  118. package/dist/tsup/driver-test-suite/mod.d.ts +6 -5
  119. package/dist/tsup/driver-test-suite/mod.js +1581 -534
  120. package/dist/tsup/driver-test-suite/mod.js.map +1 -1
  121. package/dist/tsup/inspector/mod.cjs +4 -4
  122. package/dist/tsup/inspector/mod.js +3 -3
  123. package/dist/tsup/mod.cjs +15 -9
  124. package/dist/tsup/mod.cjs.map +1 -1
  125. package/dist/tsup/mod.d.cts +9 -9
  126. package/dist/tsup/mod.d.ts +9 -9
  127. package/dist/tsup/mod.js +19 -13
  128. package/dist/tsup/sandbox/client.cjs +28 -0
  129. package/dist/tsup/sandbox/client.cjs.map +1 -0
  130. package/dist/tsup/sandbox/client.d.cts +88 -0
  131. package/dist/tsup/sandbox/client.d.ts +88 -0
  132. package/dist/tsup/sandbox/client.js +28 -0
  133. package/dist/tsup/sandbox/client.js.map +1 -0
  134. package/dist/tsup/sandbox/index.cjs +761 -0
  135. package/dist/tsup/sandbox/index.cjs.map +1 -0
  136. package/dist/tsup/sandbox/index.d.cts +120 -0
  137. package/dist/tsup/sandbox/index.d.ts +120 -0
  138. package/dist/tsup/sandbox/index.js +761 -0
  139. package/dist/tsup/sandbox/index.js.map +1 -0
  140. package/dist/tsup/sandbox/providers/computesdk.cjs +3 -0
  141. package/dist/tsup/sandbox/providers/computesdk.cjs.map +1 -0
  142. package/dist/tsup/sandbox/providers/computesdk.d.cts +7 -0
  143. package/dist/tsup/sandbox/providers/computesdk.d.ts +7 -0
  144. package/dist/tsup/sandbox/providers/computesdk.js +3 -0
  145. package/dist/tsup/sandbox/providers/computesdk.js.map +1 -0
  146. package/dist/tsup/sandbox/providers/daytona.cjs +3 -0
  147. package/dist/tsup/sandbox/providers/daytona.cjs.map +1 -0
  148. package/dist/tsup/sandbox/providers/daytona.d.cts +1 -0
  149. package/dist/tsup/sandbox/providers/daytona.d.ts +1 -0
  150. package/dist/tsup/sandbox/providers/daytona.js +3 -0
  151. package/dist/tsup/sandbox/providers/daytona.js.map +1 -0
  152. package/dist/tsup/sandbox/providers/docker.cjs +3 -0
  153. package/dist/tsup/sandbox/providers/docker.cjs.map +1 -0
  154. package/dist/tsup/sandbox/providers/docker.d.cts +1 -0
  155. package/dist/tsup/sandbox/providers/docker.d.ts +1 -0
  156. package/dist/tsup/sandbox/providers/docker.js +3 -0
  157. package/dist/tsup/sandbox/providers/docker.js.map +1 -0
  158. package/dist/tsup/sandbox/providers/e2b.cjs +3 -0
  159. package/dist/tsup/sandbox/providers/e2b.cjs.map +1 -0
  160. package/dist/tsup/sandbox/providers/e2b.d.cts +1 -0
  161. package/dist/tsup/sandbox/providers/e2b.d.ts +1 -0
  162. package/dist/tsup/sandbox/providers/e2b.js +3 -0
  163. package/dist/tsup/sandbox/providers/e2b.js.map +1 -0
  164. package/dist/tsup/sandbox/providers/local.cjs +3 -0
  165. package/dist/tsup/sandbox/providers/local.cjs.map +1 -0
  166. package/dist/tsup/sandbox/providers/local.d.cts +1 -0
  167. package/dist/tsup/sandbox/providers/local.d.ts +1 -0
  168. package/dist/tsup/sandbox/providers/local.js +3 -0
  169. package/dist/tsup/sandbox/providers/local.js.map +1 -0
  170. package/dist/tsup/sandbox/providers/modal.cjs +3 -0
  171. package/dist/tsup/sandbox/providers/modal.cjs.map +1 -0
  172. package/dist/tsup/sandbox/providers/modal.d.cts +1 -0
  173. package/dist/tsup/sandbox/providers/modal.d.ts +1 -0
  174. package/dist/tsup/sandbox/providers/modal.js +3 -0
  175. package/dist/tsup/sandbox/providers/modal.js.map +1 -0
  176. package/dist/tsup/sandbox/providers/vercel.cjs +3 -0
  177. package/dist/tsup/sandbox/providers/vercel.cjs.map +1 -0
  178. package/dist/tsup/sandbox/providers/vercel.d.cts +1 -0
  179. package/dist/tsup/sandbox/providers/vercel.d.ts +1 -0
  180. package/dist/tsup/sandbox/providers/vercel.js +3 -0
  181. package/dist/tsup/sandbox/providers/vercel.js.map +1 -0
  182. package/dist/tsup/serve-test-suite/mod.cjs +451 -327
  183. package/dist/tsup/serve-test-suite/mod.cjs.map +1 -1
  184. package/dist/tsup/serve-test-suite/mod.js +362 -238
  185. package/dist/tsup/serve-test-suite/mod.js.map +1 -1
  186. package/dist/tsup/test/mod.cjs +17 -14
  187. package/dist/tsup/test/mod.cjs.map +1 -1
  188. package/dist/tsup/test/mod.d.cts +4 -4
  189. package/dist/tsup/test/mod.d.ts +4 -4
  190. package/dist/tsup/test/mod.js +14 -11
  191. package/dist/tsup/test/mod.js.map +1 -1
  192. package/dist/tsup/utils.cjs +3 -3
  193. package/dist/tsup/utils.js +2 -2
  194. package/dist/tsup/workflow/mod.cjs +6 -6
  195. package/dist/tsup/workflow/mod.d.cts +13 -9
  196. package/dist/tsup/workflow/mod.d.ts +13 -9
  197. package/dist/tsup/workflow/mod.js +5 -5
  198. package/package.json +114 -15
  199. package/src/actor/config.ts +94 -88
  200. package/src/actor/conn/drivers/websocket.ts +2 -1
  201. package/src/actor/contexts/base/actor.ts +27 -4
  202. package/src/actor/database.ts +6 -1
  203. package/src/actor/driver.ts +27 -8
  204. package/src/actor/errors.ts +10 -5
  205. package/src/actor/instance/connection-manager.ts +4 -3
  206. package/src/actor/instance/kv.ts +52 -9
  207. package/src/actor/instance/mod.ts +135 -84
  208. package/src/actor/instance/queue-manager.ts +2 -5
  209. package/src/actor/instance/queue.ts +31 -29
  210. package/src/actor/instance/state-manager.ts +7 -1
  211. package/src/actor/instance/traces-driver.ts +34 -36
  212. package/src/actor/metrics.ts +137 -0
  213. package/src/actor/protocol/old.ts +9 -12
  214. package/src/actor/router-websocket-endpoints.ts +12 -6
  215. package/src/actor/router.ts +46 -9
  216. package/src/actor/schema.ts +14 -22
  217. package/src/client/actor-common.ts +65 -0
  218. package/src/client/actor-conn.ts +71 -9
  219. package/src/client/actor-handle.ts +22 -5
  220. package/src/client/client.ts +32 -6
  221. package/src/client/config.ts +18 -21
  222. package/src/client/mod.ts +1 -0
  223. package/src/client/queue.ts +8 -6
  224. package/src/common/inline-websocket-adapter.ts +8 -2
  225. package/src/common/router.ts +1 -4
  226. package/src/common/utils.ts +2 -5
  227. package/src/db/config.ts +10 -5
  228. package/src/db/drizzle/mod.ts +51 -41
  229. package/src/db/mod.ts +54 -29
  230. package/src/db/shared.ts +42 -8
  231. package/src/driver-helpers/mod.ts +2 -1
  232. package/src/driver-helpers/sqlite-pool.ts +42 -0
  233. package/src/driver-helpers/utils.ts +0 -20
  234. package/src/driver-test-suite/mod.ts +11 -1
  235. package/src/driver-test-suite/tests/access-control.ts +19 -12
  236. package/src/driver-test-suite/tests/action-features.ts +20 -8
  237. package/src/driver-test-suite/tests/actor-conn.ts +94 -8
  238. package/src/driver-test-suite/tests/actor-db-kv-stats.ts +282 -0
  239. package/src/driver-test-suite/tests/actor-db-raw.ts +6 -2
  240. package/src/driver-test-suite/tests/actor-db.ts +101 -31
  241. package/src/driver-test-suite/tests/actor-inspector.ts +174 -32
  242. package/src/driver-test-suite/tests/actor-kv.ts +79 -33
  243. package/src/driver-test-suite/tests/actor-lifecycle.ts +4 -12
  244. package/src/driver-test-suite/tests/actor-queue.ts +125 -17
  245. package/src/driver-test-suite/tests/actor-run.ts +59 -55
  246. package/src/driver-test-suite/tests/actor-sandbox.ts +78 -0
  247. package/src/driver-test-suite/tests/actor-schedule.ts +1 -4
  248. package/src/driver-test-suite/tests/actor-sleep.ts +111 -0
  249. package/src/driver-test-suite/tests/actor-workflow.ts +387 -3
  250. package/src/driver-test-suite/tests/conn-error-serialization.ts +3 -1
  251. package/src/driver-test-suite/tests/raw-websocket.ts +5 -1
  252. package/src/drivers/default.ts +1 -3
  253. package/src/drivers/engine/actor-driver.ts +94 -21
  254. package/src/drivers/engine/config.ts +4 -12
  255. package/src/drivers/engine/mod.ts +1 -5
  256. package/src/drivers/file-system/actor.ts +43 -8
  257. package/src/drivers/file-system/global-state.ts +180 -64
  258. package/src/drivers/file-system/kv-limits.ts +1 -1
  259. package/src/drivers/file-system/sqlite-runtime.ts +13 -4
  260. package/src/engine-process/mod.ts +5 -1
  261. package/src/inspector/actor-inspector.ts +47 -21
  262. package/src/inspector/config.ts +1 -4
  263. package/src/inspector/mod.browser.ts +2 -2
  264. package/src/inspector/mod.ts +4 -1
  265. package/src/inspector/serve-ui.ts +0 -1
  266. package/src/inspector/workflow-history-json.ts +309 -0
  267. package/src/manager/gateway.ts +6 -2
  268. package/src/manager/router.ts +3 -3
  269. package/src/registry/config/index.ts +65 -12
  270. package/src/registry/config/runner.ts +19 -4
  271. package/src/registry/index.ts +42 -89
  272. package/src/sandbox/actor/db.ts +36 -0
  273. package/src/sandbox/actor/index.ts +476 -0
  274. package/src/sandbox/actor/session.ts +350 -0
  275. package/src/sandbox/actor.test.ts +36 -0
  276. package/src/sandbox/client.test.ts +484 -0
  277. package/src/sandbox/client.ts +707 -0
  278. package/src/sandbox/config.ts +151 -0
  279. package/src/sandbox/index.ts +41 -0
  280. package/src/sandbox/providers/computesdk.ts +1 -0
  281. package/src/sandbox/providers/daytona.ts +1 -0
  282. package/src/sandbox/providers/docker.ts +1 -0
  283. package/src/sandbox/providers/e2b.ts +1 -0
  284. package/src/sandbox/providers/local.ts +1 -0
  285. package/src/sandbox/providers/modal.ts +1 -0
  286. package/src/sandbox/providers/vercel.ts +1 -0
  287. package/src/sandbox/session-persist-driver.ts +180 -0
  288. package/src/sandbox/types.ts +138 -0
  289. package/src/serverless/configure.ts +5 -3
  290. package/src/serverless/router.test.ts +17 -9
  291. package/src/serverless/router.ts +20 -13
  292. package/src/test/mod.ts +3 -4
  293. package/src/utils/endpoint-parser.test.ts +6 -2
  294. package/src/utils/endpoint-parser.ts +6 -2
  295. package/src/utils/env-vars.ts +0 -2
  296. package/src/utils/node.ts +1 -1
  297. package/src/utils/serve.ts +10 -5
  298. package/src/utils.ts +6 -1
  299. package/src/workflow/constants.ts +1 -2
  300. package/src/workflow/context.ts +42 -9
  301. package/src/workflow/driver.ts +57 -23
  302. package/src/workflow/inspector.ts +7 -13
  303. package/src/workflow/mod.ts +91 -4
  304. package/dist/tsup/chunk-6LJAZ5R4.cjs +0 -96
  305. package/dist/tsup/chunk-6LJAZ5R4.cjs.map +0 -1
  306. package/dist/tsup/chunk-7HTNH26M.js.map +0 -1
  307. package/dist/tsup/chunk-7WF2QSIC.cjs.map +0 -1
  308. package/dist/tsup/chunk-D2SPAJVT.cjs +0 -645
  309. package/dist/tsup/chunk-D2SPAJVT.cjs.map +0 -1
  310. package/dist/tsup/chunk-EIATSBYZ.js.map +0 -1
  311. package/dist/tsup/chunk-HYPIHCDT.cjs.map +0 -1
  312. package/dist/tsup/chunk-IIJNPVPQ.cjs.map +0 -1
  313. package/dist/tsup/chunk-JPXO2H55.js.map +0 -1
  314. package/dist/tsup/chunk-KJSYAUOM.js.map +0 -1
  315. package/dist/tsup/chunk-L47L3ZWJ.cjs.map +0 -1
  316. package/dist/tsup/chunk-MIX2KB6U.js.map +0 -1
  317. package/dist/tsup/chunk-N4KRDJ56.js.map +0 -1
  318. package/dist/tsup/chunk-OAXJWGMU.cjs.map +0 -1
  319. package/dist/tsup/chunk-PB5AEMKQ.cjs.map +0 -1
  320. package/dist/tsup/chunk-R5OQUSLN.js +0 -645
  321. package/dist/tsup/chunk-R5OQUSLN.js.map +0 -1
  322. package/dist/tsup/chunk-SR3KQE7Q.cjs.map +0 -1
  323. package/dist/tsup/chunk-SRIM3GHD.js.map +0 -1
  324. package/dist/tsup/chunk-TADUYCHF.js.map +0 -1
  325. package/dist/tsup/chunk-TI5PXQGG.cjs.map +0 -1
  326. package/dist/tsup/chunk-U5SMSA27.cjs.map +0 -1
  327. package/dist/tsup/chunk-VKVNIQRQ.js.map +0 -1
  328. package/dist/tsup/chunk-WY2SHWXQ.js.map +0 -1
  329. package/dist/tsup/chunk-ZFY5J2EP.cjs.map +0 -1
  330. package/dist/tsup/chunk-ZPWOYQHN.js.map +0 -1
  331. package/src/db/sqlite-vfs.ts +0 -12
  332. /package/dist/tsup/{chunk-S662Y6ZU.js.map → chunk-EONWXYMN.js.map} +0 -0
  333. /package/dist/tsup/{chunk-2OK7S6QF.js.map → chunk-I5I6OALK.js.map} +0 -0
package/src/db/shared.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import type { DatabaseProviderContext } from "./config";
2
- import type { Database } from "@rivetkit/sqlite-vfs";
3
- import type { KvVfsOptions } from "./sqlite-vfs";
2
+ import type { IDatabase } from "@rivetkit/sqlite-vfs";
3
+ import type { KvVfsOptions } from "@rivetkit/sqlite-vfs";
4
+ import type { ActorMetrics } from "@/actor/metrics";
4
5
 
5
6
  type ActorKvOperations = DatabaseProviderContext["kv"];
6
- type SqliteBindings = NonNullable<Parameters<Database["run"]>[1]>;
7
+ type SqliteBindings = NonNullable<Parameters<IDatabase["run"]>[1]>;
7
8
 
8
9
  function isSqliteBindingValue(value: unknown): boolean {
9
10
  if (
@@ -26,9 +27,7 @@ function isSqliteBindingValue(value: unknown): boolean {
26
27
  export function toSqliteBindings(args: unknown[]): SqliteBindings {
27
28
  for (const value of args) {
28
29
  if (!isSqliteBindingValue(value)) {
29
- throw new Error(
30
- `unsupported sqlite binding type: ${typeof value}`,
31
- );
30
+ throw new Error(`unsupported sqlite binding type: ${typeof value}`);
32
31
  }
33
32
  }
34
33
 
@@ -37,24 +36,59 @@ export function toSqliteBindings(args: unknown[]): SqliteBindings {
37
36
 
38
37
  /**
39
38
  * Create a KV store wrapper that uses the actor driver's KV operations.
39
+ * Tracks per-operation metrics when an ActorMetrics instance is provided.
40
40
  */
41
- export function createActorKvStore(kv: ActorKvOperations): KvVfsOptions {
41
+ export function createActorKvStore(
42
+ kv: ActorKvOperations,
43
+ metrics?: ActorMetrics,
44
+ ): KvVfsOptions {
42
45
  return {
43
46
  get: async (key: Uint8Array) => {
47
+ const start = performance.now();
44
48
  const results = await kv.batchGet([key]);
49
+ if (metrics) {
50
+ metrics.kvGet.calls++;
51
+ metrics.kvGet.keys++;
52
+ metrics.kvGet.totalMs += performance.now() - start;
53
+ }
45
54
  return results[0] ?? null;
46
55
  },
47
56
  getBatch: async (keys: Uint8Array[]) => {
48
- return await kv.batchGet(keys);
57
+ const start = performance.now();
58
+ const results = await kv.batchGet(keys);
59
+ if (metrics) {
60
+ metrics.kvGetBatch.calls++;
61
+ metrics.kvGetBatch.keys += keys.length;
62
+ metrics.kvGetBatch.totalMs += performance.now() - start;
63
+ }
64
+ return results;
49
65
  },
50
66
  put: async (key: Uint8Array, value: Uint8Array) => {
67
+ const start = performance.now();
51
68
  await kv.batchPut([[key, value]]);
69
+ if (metrics) {
70
+ metrics.kvPut.calls++;
71
+ metrics.kvPut.keys++;
72
+ metrics.kvPut.totalMs += performance.now() - start;
73
+ }
52
74
  },
53
75
  putBatch: async (entries: [Uint8Array, Uint8Array][]) => {
76
+ const start = performance.now();
54
77
  await kv.batchPut(entries);
78
+ if (metrics) {
79
+ metrics.kvPutBatch.calls++;
80
+ metrics.kvPutBatch.keys += entries.length;
81
+ metrics.kvPutBatch.totalMs += performance.now() - start;
82
+ }
55
83
  },
56
84
  deleteBatch: async (keys: Uint8Array[]) => {
85
+ const start = performance.now();
57
86
  await kv.batchDelete(keys);
87
+ if (metrics) {
88
+ metrics.kvDeleteBatch.calls++;
89
+ metrics.kvDeleteBatch.keys += keys.length;
90
+ metrics.kvDeleteBatch.totalMs += performance.now() - start;
91
+ }
58
92
  },
59
93
  };
60
94
  }
@@ -30,4 +30,5 @@ export type {
30
30
  ManagerDriver,
31
31
  } from "@/manager/driver";
32
32
  export { buildManagerRouter } from "@/manager/router";
33
- export { getInitialActorKvState, importSqliteVfs } from "./utils";
33
+ export { getInitialActorKvState } from "./utils";
34
+ export { SqliteVfsPoolManager } from "./sqlite-pool";
@@ -0,0 +1,42 @@
1
+ import type { ISqliteVfs } from "@rivetkit/sqlite-vfs";
2
+ import type { RegistryConfig } from "@/registry/config";
3
+
4
+ /**
5
+ * Manages a lazily-created SqliteVfsPool shared across actors in a driver.
6
+ * Uses dynamic import to keep @rivetkit/sqlite-vfs tree-shakeable.
7
+ */
8
+ export class SqliteVfsPoolManager {
9
+ #poolPromise:
10
+ | Promise<{
11
+ acquire(actorId: string): Promise<ISqliteVfs>;
12
+ shutdown(): Promise<void>;
13
+ }>
14
+ | undefined;
15
+ #config: RegistryConfig;
16
+
17
+ constructor(config: RegistryConfig) {
18
+ this.#config = config;
19
+ }
20
+
21
+ async acquire(actorId: string): Promise<ISqliteVfs> {
22
+ if (!this.#poolPromise) {
23
+ const poolConfig = this.#config.sqlitePool;
24
+ this.#poolPromise = import("@rivetkit/sqlite-vfs").then(
25
+ ({ SqliteVfsPool }) =>
26
+ new SqliteVfsPool({
27
+ actorsPerInstance: poolConfig.actorsPerInstance,
28
+ idleDestroyMs: poolConfig.idleDestroyMs,
29
+ }),
30
+ );
31
+ }
32
+ const pool = await this.#poolPromise;
33
+ return await pool.acquire(actorId);
34
+ }
35
+
36
+ async shutdown(): Promise<void> {
37
+ if (this.#poolPromise) {
38
+ const pool = await this.#poolPromise;
39
+ await pool.shutdown();
40
+ }
41
+ }
42
+ }
@@ -6,9 +6,6 @@ import {
6
6
  CURRENT_VERSION,
7
7
  } from "@/schemas/actor-persist/versioned";
8
8
  import { bufferToArrayBuffer } from "@/utils";
9
- import type { ActorDriver } from "./mod";
10
- import type { SqliteVfs } from "@rivetkit/sqlite-vfs";
11
-
12
9
  function serializeEmptyPersistData(input: unknown | undefined): Uint8Array {
13
10
  const persistData: persistSchema.Actor = {
14
11
  input:
@@ -35,20 +32,3 @@ export function getInitialActorKvState(
35
32
  const persistData = serializeEmptyPersistData(input);
36
33
  return [[KEYS.PERSIST_DATA, persistData]];
37
34
  }
38
-
39
- /**
40
- * Dynamically import @rivetkit/sqlite-vfs and return a fresh SqliteVfs instance.
41
- *
42
- * The module specifier is built with Array.join() so that bundlers (esbuild, tsup,
43
- * Turbopack) cannot statically analyze or constant-fold the import path. This
44
- * prevents them from tracing into the WASM dependency tree, which would cause
45
- * errors in environments that don't support .wasm imports (e.g. Turbopack).
46
- *
47
- * Each call returns a new instance so that actors get independent SQLite modules,
48
- * avoiding cross-actor re-entry on the non-reentrant async build.
49
- */
50
- export async function importSqliteVfs(): Promise<SqliteVfs> {
51
- const specifier = ["@rivetkit", "sqlite-vfs"].join("/");
52
- const { SqliteVfs } = await import(specifier);
53
- return new SqliteVfs();
54
- }
@@ -29,6 +29,7 @@ import { runActorMetadataTests } from "./tests/actor-metadata";
29
29
  import { runActorOnStateChangeTests } from "./tests/actor-onstatechange";
30
30
  import { runActorQueueTests } from "./tests/actor-queue";
31
31
  import { runActorRunTests } from "./tests/actor-run";
32
+ import { runActorSandboxTests } from "./tests/actor-sandbox";
32
33
  import { runActorStatelessTests } from "./tests/actor-stateless";
33
34
  import { runActorVarsTests } from "./tests/actor-vars";
34
35
  import { runActorWorkflowTests } from "./tests/actor-workflow";
@@ -36,6 +37,7 @@ import { runManagerDriverTests } from "./tests/manager-driver";
36
37
  import { runRawHttpTests } from "./tests/raw-http";
37
38
  import { runRawHttpRequestPropertiesTests } from "./tests/raw-http-request-properties";
38
39
  import { runRawWebSocketTests } from "./tests/raw-websocket";
40
+ import { runActorDbKvStatsTests } from "./tests/actor-db-kv-stats";
39
41
  import { runRequestAccessTests } from "./tests/request-access";
40
42
 
41
43
  export interface SkipTests {
@@ -43,6 +45,7 @@ export interface SkipTests {
43
45
  sleep?: boolean;
44
46
  hibernation?: boolean;
45
47
  inline?: boolean;
48
+ sandbox?: boolean;
46
49
  }
47
50
 
48
51
  export interface DriverTestConfig {
@@ -138,6 +141,8 @@ export function runDriverTests(
138
141
 
139
142
  runActorRunTests(driverTestConfig);
140
143
 
144
+ runActorSandboxTests(driverTestConfig);
145
+
141
146
  runActorInlineClientTests(driverTestConfig);
142
147
 
143
148
  runActorKvTests(driverTestConfig);
@@ -159,6 +164,8 @@ export function runDriverTests(
159
164
  // runRawWebSocketDirectRegistryTests(driverTestConfig);
160
165
 
161
166
  runActorInspectorTests(driverTestConfig);
167
+
168
+ runActorDbKvStatsTests(driverTestConfig);
162
169
  });
163
170
  }
164
171
  });
@@ -269,7 +276,10 @@ export async function createTestRuntime(
269
276
  );
270
277
  nodeWebSocket.injectWebSocket(server);
271
278
  const address = server.address();
272
- invariant(address && typeof address !== "string", "missing server address");
279
+ invariant(
280
+ address && typeof address !== "string",
281
+ "missing server address",
282
+ );
273
283
  const port = address.port;
274
284
  const serverEndpoint = `http://127.0.0.1:${port}`;
275
285
 
@@ -14,7 +14,9 @@ export function runAccessControlTests(driverTestConfig: DriverTestConfig) {
14
14
 
15
15
  test("passes connection id into canPublish context", async (c) => {
16
16
  const { client } = await setupDriverTest(c, driverTestConfig);
17
- const handle = client.accessControlActor.getOrCreate(["publish-ctx"]);
17
+ const handle = client.accessControlActor.getOrCreate([
18
+ "publish-ctx",
19
+ ]);
18
20
 
19
21
  await handle.send("allowedQueue", { value: "one" });
20
22
 
@@ -104,7 +106,7 @@ export function runAccessControlTests(driverTestConfig: DriverTestConfig) {
104
106
  await conn.dispose();
105
107
 
106
108
  const blockedConn = handle.connect();
107
- blockedConn.on("blockedEvent", () => { });
109
+ blockedConn.on("blockedEvent", () => {});
108
110
  await expect(
109
111
  blockedConn.allowedAction("blocked-subscribe-ready"),
110
112
  ).rejects.toMatchObject({
@@ -120,16 +122,21 @@ export function runAccessControlTests(driverTestConfig: DriverTestConfig) {
120
122
  ]);
121
123
  const conn = handle.connect();
122
124
 
123
- const eventPromise = new Promise<{ value: string }>((resolve, reject) => {
124
- const unsubscribeError = conn.onError((error) => {
125
- reject(error);
126
- });
127
- const unsubscribeEvent = conn.on("undefinedEvent", (payload) => {
128
- unsubscribeError();
129
- unsubscribeEvent();
130
- resolve(payload as { value: string });
131
- });
132
- });
125
+ const eventPromise = new Promise<{ value: string }>(
126
+ (resolve, reject) => {
127
+ const unsubscribeError = conn.onError((error) => {
128
+ reject(error);
129
+ });
130
+ const unsubscribeEvent = conn.on(
131
+ "undefinedEvent",
132
+ (payload) => {
133
+ unsubscribeError();
134
+ unsubscribeEvent();
135
+ resolve(payload as { value: string });
136
+ },
137
+ );
138
+ },
139
+ );
133
140
 
134
141
  await conn.allowedAction("undefined-subscribe-ready");
135
142
  await conn.allowedBroadcastUndefinedEvent("wildcard");
@@ -147,14 +147,20 @@ export function runActionFeaturesTests(driverTestConfig: DriverTestConfig) {
147
147
  // Each item is roughly 60 bytes, so 800 items ≈ 48KB
148
148
  const items: string[] = [];
149
149
  for (let i = 0; i < 800; i++) {
150
- items.push(`Item ${i} with some additional text to increase size`);
150
+ items.push(
151
+ `Item ${i} with some additional text to increase size`,
152
+ );
151
153
  }
152
154
 
153
155
  const result = await instance.processLargeRequest({ items });
154
156
 
155
157
  expect(result.itemCount).toBe(800);
156
- expect(result.firstItem).toBe("Item 0 with some additional text to increase size");
157
- expect(result.lastItem).toBe("Item 799 with some additional text to increase size");
158
+ expect(result.firstItem).toBe(
159
+ "Item 0 with some additional text to increase size",
160
+ );
161
+ expect(result.lastItem).toBe(
162
+ "Item 799 with some additional text to increase size",
163
+ );
158
164
  });
159
165
 
160
166
  test("should reject request exceeding maxIncomingMessageSize", async (c) => {
@@ -166,11 +172,13 @@ export function runActionFeaturesTests(driverTestConfig: DriverTestConfig) {
166
172
  // Each item is roughly 60 bytes, so 1500 items ≈ 90KB
167
173
  const items: string[] = [];
168
174
  for (let i = 0; i < 1500; i++) {
169
- items.push(`Item ${i} with some additional text to increase size`);
175
+ items.push(
176
+ `Item ${i} with some additional text to increase size`,
177
+ );
170
178
  }
171
179
 
172
180
  await expect(
173
- instance.processLargeRequest({ items })
181
+ instance.processLargeRequest({ items }),
174
182
  ).rejects.toThrow();
175
183
  });
176
184
 
@@ -183,8 +191,12 @@ export function runActionFeaturesTests(driverTestConfig: DriverTestConfig) {
183
191
  const result = await instance.getLargeResponse(800);
184
192
 
185
193
  expect(result.items).toHaveLength(800);
186
- expect(result.items[0]).toBe("Item 0 with some additional text to increase size");
187
- expect(result.items[799]).toBe("Item 799 with some additional text to increase size");
194
+ expect(result.items[0]).toBe(
195
+ "Item 0 with some additional text to increase size",
196
+ );
197
+ expect(result.items[799]).toBe(
198
+ "Item 799 with some additional text to increase size",
199
+ );
188
200
  });
189
201
 
190
202
  test("should reject response exceeding maxOutgoingMessageSize", async (c) => {
@@ -195,7 +207,7 @@ export function runActionFeaturesTests(driverTestConfig: DriverTestConfig) {
195
207
  // Request a response that exceeds the default 1MB limit
196
208
  // Each item is roughly 60 bytes, so 20000 items ≈ 1.2MB
197
209
  await expect(
198
- instance.getLargeResponse(20000)
210
+ instance.getLargeResponse(20000),
199
211
  ).rejects.toThrow();
200
212
  });
201
213
  });
@@ -243,6 +243,80 @@ export function runActorConnTests(driverTestConfig: DriverTestConfig) {
243
243
  await conn1.dispose();
244
244
  await conn2.dispose();
245
245
  });
246
+
247
+ test("should call getParams for each connection", async (c) => {
248
+ const { client } = await setupDriverTest(c, driverTestConfig);
249
+
250
+ let connectionCount = 0;
251
+ const handle = client.counterWithParams.getOrCreate(
252
+ ["test-get-params"],
253
+ {
254
+ getParams: async () => ({
255
+ name: `user${++connectionCount}`,
256
+ }),
257
+ },
258
+ );
259
+
260
+ const conn1 = handle.connect();
261
+ await conn1.getInitializers();
262
+ await conn1.dispose();
263
+
264
+ const conn2 = handle.connect();
265
+ const initializers = await conn2.getInitializers();
266
+
267
+ expect(initializers).toEqual(["user1", "user2"]);
268
+ expect(connectionCount).toBe(2);
269
+
270
+ await conn2.dispose();
271
+ });
272
+
273
+ test("should surface getParams errors and retry connection setup", async (c) => {
274
+ const { client } = await setupDriverTest(c, driverTestConfig);
275
+
276
+ let attempts = 0;
277
+ const handle = client.counterWithParams.getOrCreate(
278
+ ["test-get-params-retry"],
279
+ {
280
+ getParams: async () => {
281
+ attempts++;
282
+ if (attempts === 1) {
283
+ throw new Error("token unavailable");
284
+ }
285
+
286
+ return { name: "user1" };
287
+ },
288
+ },
289
+ );
290
+
291
+ const conn = handle.connect();
292
+ const receivedErrors: Array<{ group: string; code: string }> =
293
+ [];
294
+ conn.onError((error) => {
295
+ receivedErrors.push({
296
+ group: error.group,
297
+ code: error.code,
298
+ });
299
+ });
300
+
301
+ await expect(conn.getInitializers()).rejects.toMatchObject({
302
+ group: "client",
303
+ code: "get_params_failed",
304
+ });
305
+
306
+ await vi.waitFor(
307
+ async () => {
308
+ expect(await conn.getInitializers()).toEqual(["user1"]);
309
+ },
310
+ { timeout: 10_000 },
311
+ );
312
+
313
+ expect(receivedErrors).toEqual([
314
+ { group: "client", code: "get_params_failed" },
315
+ ]);
316
+ expect(attempts).toBeGreaterThanOrEqual(2);
317
+
318
+ await conn.dispose();
319
+ });
246
320
  });
247
321
 
248
322
  describe("Lifecycle Hooks", () => {
@@ -515,14 +589,20 @@ export function runActorConnTests(driverTestConfig: DriverTestConfig) {
515
589
  // Each item is roughly 60 bytes, so 800 items ≈ 48KB
516
590
  const items: string[] = [];
517
591
  for (let i = 0; i < 800; i++) {
518
- items.push(`Item ${i} with some additional text to increase size`);
592
+ items.push(
593
+ `Item ${i} with some additional text to increase size`,
594
+ );
519
595
  }
520
596
 
521
597
  const result = await connection.processLargeRequest({ items });
522
598
 
523
599
  expect(result.itemCount).toBe(800);
524
- expect(result.firstItem).toBe("Item 0 with some additional text to increase size");
525
- expect(result.lastItem).toBe("Item 799 with some additional text to increase size");
600
+ expect(result.firstItem).toBe(
601
+ "Item 0 with some additional text to increase size",
602
+ );
603
+ expect(result.lastItem).toBe(
604
+ "Item 799 with some additional text to increase size",
605
+ );
526
606
 
527
607
  // Verify connection state was updated
528
608
  const lastRequestSize = await connection.getLastRequestSize();
@@ -544,11 +624,13 @@ export function runActorConnTests(driverTestConfig: DriverTestConfig) {
544
624
  // Each item is roughly 60 bytes, so 1500 items ≈ 90KB
545
625
  const items: string[] = [];
546
626
  for (let i = 0; i < 1500; i++) {
547
- items.push(`Item ${i} with some additional text to increase size`);
627
+ items.push(
628
+ `Item ${i} with some additional text to increase size`,
629
+ );
548
630
  }
549
631
 
550
632
  await expect(
551
- connection.processLargeRequest({ items })
633
+ connection.processLargeRequest({ items }),
552
634
  ).rejects.toThrow();
553
635
 
554
636
  // Clean up
@@ -567,8 +649,12 @@ export function runActorConnTests(driverTestConfig: DriverTestConfig) {
567
649
  const result = await connection.getLargeResponse(800);
568
650
 
569
651
  expect(result.items).toHaveLength(800);
570
- expect(result.items[0]).toBe("Item 0 with some additional text to increase size");
571
- expect(result.items[799]).toBe("Item 799 with some additional text to increase size");
652
+ expect(result.items[0]).toBe(
653
+ "Item 0 with some additional text to increase size",
654
+ );
655
+ expect(result.items[799]).toBe(
656
+ "Item 799 with some additional text to increase size",
657
+ );
572
658
 
573
659
  // Clean up
574
660
  await connection.dispose();
@@ -585,7 +671,7 @@ export function runActorConnTests(driverTestConfig: DriverTestConfig) {
585
671
  // Request a response that exceeds the default 1MB limit
586
672
  // Each item is roughly 60 bytes, so 20000 items ≈ 1.2MB
587
673
  await expect(
588
- connection.getLargeResponse(20000)
674
+ connection.getLargeResponse(20000),
589
675
  ).rejects.toThrow();
590
676
 
591
677
  // Clean up