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
@@ -212,13 +212,14 @@ export const ActorConfigSchema = z
212
212
  onDestroyTimeout: z.number().positive().default(5000),
213
213
  stateSaveInterval: z.number().positive().default(10_000),
214
214
  actionTimeout: z.number().positive().default(60_000),
215
- // Max time to wait for waitUntil background promises during shutdown
215
+ // Deprecated timeout for legacy background shutdown tasks
216
216
  waitUntilTimeout: z.number().positive().default(15_000),
217
217
  // Max time to wait for run handler to stop during shutdown
218
218
  runStopTimeout: z.number().positive().default(15_000),
219
219
  connectionLivenessTimeout: z.number().positive().default(2500),
220
220
  connectionLivenessInterval: z.number().positive().default(5000),
221
- noSleep: z.boolean().default(false),
221
+ /** @deprecated Use `c.setPreventSleep(true)` in `onWake` instead. Will be removed in 2.2. */
222
+ noSleep: z.boolean().default(false),
222
223
  sleepTimeout: z.number().positive().default(30_000),
223
224
  maxQueueSize: z.number().positive().default(1000),
224
225
  maxQueueMessageSize: z
@@ -286,11 +287,11 @@ type CreateState<
286
287
  > =
287
288
  | { state: TState }
288
289
  | {
289
- createState: (
290
- c: CreateContext<TState, TInput, TDatabase, TEvents, TQueues>,
291
- input: TInput,
292
- ) => TState | Promise<TState>;
293
- }
290
+ createState: (
291
+ c: CreateContext<TState, TInput, TDatabase, TEvents, TQueues>,
292
+ input: TInput,
293
+ ) => TState | Promise<TState>;
294
+ }
294
295
  | Record<never, never>;
295
296
 
296
297
  // Creates connection state config
@@ -310,18 +311,18 @@ type CreateConnState<
310
311
  > =
311
312
  | { connState: TConnState }
312
313
  | {
313
- createConnState: (
314
- c: CreateConnStateContext<
315
- TState,
316
- TVars,
317
- TInput,
318
- TDatabase,
319
- TEvents,
320
- TQueues
321
- >,
322
- params: TConnParams,
323
- ) => TConnState | Promise<TConnState>;
324
- }
314
+ createConnState: (
315
+ c: CreateConnStateContext<
316
+ TState,
317
+ TVars,
318
+ TInput,
319
+ TDatabase,
320
+ TEvents,
321
+ TQueues
322
+ >,
323
+ params: TConnParams,
324
+ ) => TConnState | Promise<TConnState>;
325
+ }
325
326
  | Record<never, never>;
326
327
 
327
328
  // Creates vars config
@@ -341,26 +342,26 @@ type CreateVars<
341
342
  TQueues extends QueueSchemaConfig,
342
343
  > =
343
344
  | {
344
- /**
345
- * @experimental
346
- */
347
- vars: TVars;
348
- }
345
+ /**
346
+ * @experimental
347
+ */
348
+ vars: TVars;
349
+ }
349
350
  | {
350
- /**
351
- * @experimental
352
- */
353
- createVars: (
354
- c: CreateVarsContext<
355
- TState,
356
- TInput,
357
- TDatabase,
358
- TEvents,
359
- TQueues
360
- >,
361
- driverCtx: any,
362
- ) => TVars | Promise<TVars>;
363
- }
351
+ /**
352
+ * @experimental
353
+ */
354
+ createVars: (
355
+ c: CreateVarsContext<
356
+ TState,
357
+ TInput,
358
+ TDatabase,
359
+ TEvents,
360
+ TQueues
361
+ >,
362
+ driverCtx: any,
363
+ ) => TVars | Promise<TVars>;
364
+ }
364
365
  | Record<never, never>;
365
366
 
366
367
  export interface Actions<
@@ -498,43 +499,48 @@ interface BaseActorConfig<
498
499
  * - Custom workflow logic
499
500
  *
500
501
  * **Important:** The actor may go to sleep at any time during the `run`
501
- * handler. Use `c.keepAwake(promise)` to wrap async operations that should
502
- * not be interrupted by sleep.
502
+ * handler. Use `c.setPreventSleep(true)` while work is active, then clear
503
+ * it with `c.setPreventSleep(false)` once the actor can sleep again.
503
504
  *
504
505
  * The handler receives an abort signal via `c.abortSignal` and a
505
506
  * `c.aborted` alias for loop checks. Use these to gracefully exit.
506
507
  *
507
- * If this handler exits or throws, the actor will crash and reschedule.
508
+ * If this handler exits, the actor will follow the normal idle sleep timeout
509
+ * once it becomes idle.
510
+ * If this handler throws, the actor logs the error and then sleeps once it
511
+ * becomes idle.
512
+ * Call `c.destroy()` explicitly if a run handler should destroy the actor.
513
+ *
508
514
  * On shutdown, the actor waits for this handler to complete with a
509
515
  * configurable timeout (options.runStopTimeout, default 15s).
510
516
  *
511
517
  * Can be either a function or a RunConfig object with optional name/icon metadata.
512
518
  *
513
- * @returns Void or a Promise. If the promise exits, the actor crashes.
519
+ * @returns Void or a Promise.
514
520
  */
515
521
  run?:
516
- | ((
517
- c: RunContext<
518
- TState,
519
- TConnParams,
520
- TConnState,
521
- TVars,
522
- TInput,
523
- TDatabase,
524
- TEvents,
525
- TQueues
526
- >,
527
- ) => void | Promise<void>)
528
- | RunConfig<
529
- TState,
530
- TConnParams,
531
- TConnState,
532
- TVars,
533
- TInput,
534
- TDatabase,
535
- TEvents,
536
- TQueues
537
- >;
522
+ | ((
523
+ c: RunContext<
524
+ TState,
525
+ TConnParams,
526
+ TConnState,
527
+ TVars,
528
+ TInput,
529
+ TDatabase,
530
+ TEvents,
531
+ TQueues
532
+ >,
533
+ ) => void | Promise<void>)
534
+ | RunConfig<
535
+ TState,
536
+ TConnParams,
537
+ TConnState,
538
+ TVars,
539
+ TInput,
540
+ TDatabase,
541
+ TEvents,
542
+ TQueues
543
+ >;
538
544
 
539
545
  /**
540
546
  * Called when the actor's state changes.
@@ -739,11 +745,11 @@ interface BaseActorConfig<
739
745
 
740
746
  type ActorDatabaseConfig<TDatabase extends AnyDatabaseProvider> =
741
747
  | {
742
- /**
743
- * @experimental
744
- */
745
- db: TDatabase;
746
- }
748
+ /**
749
+ * @experimental
750
+ */
751
+ db: TDatabase;
752
+ }
747
753
  | Record<never, never>;
748
754
 
749
755
  // 1. Infer schema
@@ -1041,7 +1047,7 @@ export const DocActorOptionsSchema = z
1041
1047
  .number()
1042
1048
  .optional()
1043
1049
  .describe(
1044
- "Max time in ms to wait for waitUntil background promises during shutdown. Default: 15000",
1050
+ "Deprecated. Max time in ms to wait for legacy background shutdown tasks. Default: 15000",
1045
1051
  ),
1046
1052
  runStopTimeout: z
1047
1053
  .number()
@@ -1064,7 +1070,7 @@ export const DocActorOptionsSchema = z
1064
1070
  noSleep: z
1065
1071
  .boolean()
1066
1072
  .optional()
1067
- .describe("If true, the actor will never sleep. Default: false"),
1073
+ .describe("Deprecated: use c.setPreventSleep(true) in onWake instead. Will be removed in 2.2. If true, the actor will never sleep. Default: false"),
1068
1074
  sleepTimeout: z
1069
1075
  .number()
1070
1076
  .optional()
@@ -1160,24 +1166,24 @@ export const DocActorConfigSchema = z
1160
1166
  .unknown()
1161
1167
  .optional()
1162
1168
  .describe(
1163
- "Called after actor starts. Does not block startup. Use for background tasks like queue processing or tick loops. If it exits or throws, the actor crashes.",
1169
+ "Called after actor starts. Does not block startup. Use for background tasks like queue processing or tick loops. If it exits, the actor follows the normal idle sleep timeout once idle. If it throws, the actor logs the error and then follows the normal idle sleep timeout once idle.",
1170
+ ),
1171
+ onStateChange: z
1172
+ .unknown()
1173
+ .optional()
1174
+ .describe(
1175
+ "Called when the actor's state changes. State changes within this hook won't trigger recursion.",
1164
1176
  ),
1165
- onStateChange: z
1166
- .unknown()
1167
- .optional()
1168
- .describe(
1169
- "Called when the actor's state changes. State changes within this hook won't trigger recursion.",
1170
- ),
1171
- onBeforeConnect: z
1172
- .unknown()
1173
- .optional()
1174
- .describe(
1175
- "Called before a client connects. Throw an error to reject the connection.",
1176
- ),
1177
- onConnect: z
1178
- .unknown()
1179
- .optional()
1180
- .describe("Called when a client successfully connects."),
1177
+ onBeforeConnect: z
1178
+ .unknown()
1179
+ .optional()
1180
+ .describe(
1181
+ "Called before a client connects. Throw an error to reject the connection.",
1182
+ ),
1183
+ onConnect: z
1184
+ .unknown()
1185
+ .optional()
1186
+ .describe("Called when a client successfully connects."),
1181
1187
  onDisconnect: z
1182
1188
  .unknown()
1183
1189
  .optional()
@@ -62,7 +62,8 @@ export function createWebSocketDriver(
62
62
 
63
63
  // Check outgoing message size
64
64
  const messageSize =
65
- (serialized as any).byteLength || (serialized as any).length;
65
+ (serialized as any).byteLength ||
66
+ (serialized as any).length;
66
67
  if (messageSize > config.maxOutgoingMessageSize) {
67
68
  actor.rLog.error({
68
69
  msg: "outgoing message exceeds maxOutgoingMessageSize",
@@ -245,7 +245,7 @@ export class ActorContext<
245
245
  /**
246
246
  * Returns the client for the given registry.
247
247
  */
248
- client<R extends Registry<any>>(): Client<R> {
248
+ client<R extends Registry<any> = Registry<any>>(): Client<R> {
249
249
  return this.#actor.inlineClient as Client<R>;
250
250
  }
251
251
 
@@ -274,19 +274,42 @@ export class ActorContext<
274
274
 
275
275
  /**
276
276
  * Prevents the actor from sleeping until promise is complete.
277
+ *
278
+ * @deprecated Use `onSleep` for shutdown or flush work, or
279
+ * `c.setPreventSleep(true)` while work is active if the actor must stay
280
+ * awake until it finishes.
277
281
  */
278
282
  waitUntil(promise: Promise<void>): void {
279
283
  this.#actor.waitUntil(promise);
280
284
  }
281
285
 
282
286
  /**
283
- * Prevents the actor from sleeping while the given promise is running.
287
+ * Prevents the actor from automatically sleeping until cleared.
284
288
  *
285
- * Use this when performing async operations in the `run` handler or other
286
- * background contexts where you need to ensure the actor stays awake.
289
+ * @experimental
290
+ */
291
+ setPreventSleep(prevent: boolean): void {
292
+ this.#actor.setPreventSleep(prevent);
293
+ }
294
+
295
+ /**
296
+ * True when the actor is explicitly blocking automatic sleep.
297
+ *
298
+ * @experimental
299
+ */
300
+ get preventSleep(): boolean {
301
+ return this.#actor.preventSleep;
302
+ }
303
+
304
+ /**
305
+ * Prevents the actor from sleeping while the given promise is running.
287
306
  *
288
307
  * Returns the resolved value and resets the sleep timer on completion.
289
308
  * Errors are propagated to the caller.
309
+ *
310
+ * @deprecated Use `c.setPreventSleep(true)` while work is active, or move
311
+ * shutdown and flush work to `onSleep` if it can wait until the actor is
312
+ * sleeping.
290
313
  */
291
314
  keepAwake<T>(promise: Promise<T>): Promise<T> {
292
315
  return this.#actor.keepAwake(promise);
@@ -10,4 +10,9 @@ export type InferDatabaseClient<DBProvider extends AnyDatabaseProvider> =
10
10
  ? Awaited<ReturnType<DBProvider["createClient"]>>
11
11
  : never;
12
12
 
13
- export type { AnyDatabaseProvider, DatabaseProvider, RawDatabaseClient, DrizzleDatabaseClient };
13
+ export type {
14
+ AnyDatabaseProvider,
15
+ DatabaseProvider,
16
+ RawDatabaseClient,
17
+ DrizzleDatabaseClient,
18
+ };
@@ -4,10 +4,8 @@ import type { ManagerDriver } from "@/manager/driver";
4
4
  import { type AnyConn } from "./conn/mod";
5
5
  import type { AnyActorInstance } from "./instance/mod";
6
6
  import type { RegistryConfig } from "@/registry/config";
7
- import type {
8
- RawDatabaseClient,
9
- } from "@/db/config";
10
- import type { SqliteVfs } from "@rivetkit/sqlite-vfs";
7
+ import type { RawDatabaseClient } from "@/db/config";
8
+ import type { ISqliteVfs } from "@rivetkit/sqlite-vfs";
11
9
  import { BaseSQLiteDatabase } from "drizzle-orm/sqlite-core";
12
10
 
13
11
  export type ActorDriverBuilder = (
@@ -39,10 +37,32 @@ export interface ActorDriver {
39
37
  /** Batch delete multiple keys. */
40
38
  kvBatchDelete(actorId: string, keys: Uint8Array[]): Promise<void>;
41
39
 
40
+ /** Delete all keys in the half-open range [start, end). */
41
+ kvDeleteRange(
42
+ actorId: string,
43
+ start: Uint8Array,
44
+ end: Uint8Array,
45
+ ): Promise<void>;
46
+
42
47
  /** List all keys with a given prefix. */
43
48
  kvListPrefix(
44
49
  actorId: string,
45
50
  prefix: Uint8Array,
51
+ options?: {
52
+ reverse?: boolean;
53
+ limit?: number;
54
+ },
55
+ ): Promise<[Uint8Array, Uint8Array][]>;
56
+
57
+ /** List all keys in the half-open range [start, end). */
58
+ kvListRange(
59
+ actorId: string,
60
+ start: Uint8Array,
61
+ end: Uint8Array,
62
+ options?: {
63
+ reverse?: boolean;
64
+ limit?: number;
65
+ },
46
66
  ): Promise<[Uint8Array, Uint8Array][]>;
47
67
 
48
68
  // Schedule
@@ -66,19 +86,18 @@ export interface ActorDriver {
66
86
  */
67
87
  overrideDrizzleDatabaseClient?(
68
88
  actorId: string,
69
- ): Promise<BaseSQLiteDatabase<any,any,any,any> | undefined>;
89
+ ): Promise<BaseSQLiteDatabase<any, any, any, any> | undefined>;
70
90
 
71
91
  /**
72
92
  * Creates a SQLite VFS instance for creating KV-backed databases.
73
93
  * If not provided, the database provider will need an override.
74
94
  *
75
- * @rivetkit/sqlite's async build is not re-entrant per module instance. Drivers
76
- * should return a new instance per call for actor-level isolation.
95
+ * Drivers may use the actorId for pool-based instance assignment.
77
96
  *
78
97
  * This is a method (not a property) so drivers can use dynamic imports,
79
98
  * keeping the core driver tree-shakeable from @rivetkit/sqlite.
80
99
  */
81
- createSqliteVfs?(): SqliteVfs | Promise<SqliteVfs>;
100
+ createSqliteVfs?(actorId: string): ISqliteVfs | Promise<ISqliteVfs>;
82
101
 
83
102
  /**
84
103
  * Requests the actor to go to sleep.
@@ -138,7 +138,7 @@ export class IncomingMessageTooLong extends ActorError {
138
138
  super(
139
139
  "message",
140
140
  "incoming_too_long",
141
- "Incoming message too long. This can be configured with: `registry.start({ maxIncomingMessageSize: ... })`",
141
+ "Incoming message too long. This can be configured with: `setup({ maxIncomingMessageSize: ... })`",
142
142
  { public: true },
143
143
  );
144
144
  }
@@ -149,7 +149,7 @@ export class OutgoingMessageTooLong extends ActorError {
149
149
  super(
150
150
  "message",
151
151
  "outgoing_too_long",
152
- "Outgoing message too long. This can be configured with: `registry.start({ maxOutgoingMessageSize: ... })`",
152
+ "Outgoing message too long. This can be configured with: `setup({ maxOutgoingMessageSize: ... })`",
153
153
  { public: true },
154
154
  );
155
155
  }
@@ -256,9 +256,14 @@ export class QueueCompletionPayloadInvalid extends ActorError {
256
256
 
257
257
  export class QueueAlreadyCompleted extends ActorError {
258
258
  constructor() {
259
- super("queue", "already_completed", "Queue message was already completed.", {
260
- public: true,
261
- });
259
+ super(
260
+ "queue",
261
+ "already_completed",
262
+ "Queue message was already completed.",
263
+ {
264
+ public: true,
265
+ },
266
+ );
262
267
  }
263
268
  }
264
269
 
@@ -370,7 +370,9 @@ export class ConnectionManager<
370
370
  if (conn.isHibernatable) {
371
371
  const key = makeConnKey(conn.id);
372
372
  try {
373
- await this.#actor.driver.kvBatchDelete(this.#actor.id, [key]);
373
+ await this.#actor.driver.kvBatchDelete(this.#actor.id, [
374
+ key,
375
+ ]);
374
376
  this.#actor.rLog.debug({
375
377
  msg: "removed connection from KV",
376
378
  connId: conn.id,
@@ -396,8 +398,7 @@ export class ConnectionManager<
396
398
  ): Promise<number> {
397
399
  const staleConnections = Array.from(this.#connections.values()).filter(
398
400
  (conn) =>
399
- conn.isHibernatable &&
400
- conn[CONN_DRIVER_SYMBOL] === undefined,
401
+ conn.isHibernatable && conn[CONN_DRIVER_SYMBOL] === undefined,
401
402
  );
402
403
  if (staleConnections.length === 0) {
403
404
  return 0;
@@ -28,6 +28,8 @@ type KvListOptions<
28
28
  K extends KvKeyType = "text",
29
29
  > = KvValueOptions<T> & {
30
30
  keyType?: K;
31
+ reverse?: boolean;
32
+ limit?: number;
31
33
  };
32
34
 
33
35
  const textEncoder = new TextEncoder();
@@ -92,12 +94,16 @@ function encodeValue<T extends KvValueType = KvValueType>(
92
94
  return textEncoder.encode(value);
93
95
  case "arrayBuffer":
94
96
  if (!(value instanceof ArrayBuffer)) {
95
- throw new TypeError("Expected an ArrayBuffer when type is arrayBuffer");
97
+ throw new TypeError(
98
+ "Expected an ArrayBuffer when type is arrayBuffer",
99
+ );
96
100
  }
97
101
  return new Uint8Array(value);
98
102
  case "binary":
99
103
  if (!(value instanceof Uint8Array)) {
100
- throw new TypeError("Expected a Uint8Array when type is binary");
104
+ throw new TypeError(
105
+ "Expected a Uint8Array when type is binary",
106
+ );
101
107
  }
102
108
  return value;
103
109
  default:
@@ -158,9 +164,7 @@ export class ActorKv {
158
164
  keys: KvKey[],
159
165
  options?: KvValueOptions<T>,
160
166
  ): Promise<(KvValueTypeMap[T] | null)[]> {
161
- const prefixedKeys = keys.map((key) =>
162
- makePrefixedKey(encodeKey(key)),
163
- );
167
+ const prefixedKeys = keys.map((key) => makePrefixedKey(encodeKey(key)));
164
168
  const results = await this.#driver.kvBatchGet(
165
169
  this.#actorId,
166
170
  prefixedKeys,
@@ -212,12 +216,21 @@ export class ActorKv {
212
216
  * Delete multiple keys.
213
217
  */
214
218
  async deleteBatch(keys: KvKey[]): Promise<void> {
215
- const prefixedKeys = keys.map((key) =>
216
- makePrefixedKey(encodeKey(key)),
217
- );
219
+ const prefixedKeys = keys.map((key) => makePrefixedKey(encodeKey(key)));
218
220
  await this.#driver.kvBatchDelete(this.#actorId, prefixedKeys);
219
221
  }
220
222
 
223
+ /**
224
+ * Delete all keys in the half-open range [start, end).
225
+ */
226
+ async deleteRange(start: KvKey, end: KvKey): Promise<void> {
227
+ await this.#driver.kvDeleteRange(
228
+ this.#actorId,
229
+ makePrefixedKey(encodeKey(start)),
230
+ makePrefixedKey(encodeKey(end)),
231
+ );
232
+ }
233
+
221
234
  /**
222
235
  * List all keys with a given prefix.
223
236
  * Returns key-value pairs where keys have the user prefix removed.
@@ -232,10 +245,40 @@ export class ActorKv {
232
245
  const results = await this.#driver.kvListPrefix(
233
246
  this.#actorId,
234
247
  prefixedPrefix,
248
+ {
249
+ reverse: options?.reverse,
250
+ limit: options?.limit,
251
+ },
235
252
  );
236
253
  return results.map(([key, value]) => [
237
254
  decodeKey<K>(removePrefixFromKey(key), options?.keyType),
238
255
  decodeValue<T>(value, options),
239
256
  ]);
240
257
  }
241
- }
258
+
259
+ /**
260
+ * List all key-value pairs in the half-open range [start, end).
261
+ */
262
+ async listRange<
263
+ T extends KvValueType = "text",
264
+ K extends KvKeyType = "text",
265
+ >(
266
+ start: KvKeyTypeMap[K],
267
+ end: KvKeyTypeMap[K],
268
+ options?: KvListOptions<T, K>,
269
+ ): Promise<[KvKeyTypeMap[K], KvValueTypeMap[T]][]> {
270
+ const results = await this.#driver.kvListRange(
271
+ this.#actorId,
272
+ makePrefixedKey(encodeKey(start, options?.keyType)),
273
+ makePrefixedKey(encodeKey(end, options?.keyType)),
274
+ {
275
+ reverse: options?.reverse,
276
+ limit: options?.limit,
277
+ },
278
+ );
279
+ return results.map(([key, value]) => [
280
+ decodeKey<K>(removePrefixFromKey(key), options?.keyType),
281
+ decodeValue<T>(value, options),
282
+ ]);
283
+ }
284
+ }