rivetkit 2.0.42 → 2.1.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. package/dist/{tsup/config-CLnylLYY.d.ts → browser/client.d.ts} +2127 -1910
  2. package/dist/browser/client.js +5182 -0
  3. package/dist/browser/client.js.map +1 -0
  4. package/dist/browser/inspector/client.d.ts +130 -0
  5. package/dist/browser/inspector/client.js +2854 -0
  6. package/dist/browser/inspector/client.js.map +1 -0
  7. package/dist/browser/v3-DnYObHH3.d.ts +279 -0
  8. package/dist/schemas/actor-inspector/v2.ts +796 -0
  9. package/dist/schemas/actor-inspector/v3.ts +899 -0
  10. package/dist/schemas/actor-persist/v4.ts +406 -0
  11. package/dist/schemas/client-protocol/v3.ts +554 -0
  12. package/dist/schemas/persist/v1.ts +781 -0
  13. package/dist/schemas/transport/v1.ts +697 -0
  14. package/dist/tsup/actor/errors.cjs +27 -3
  15. package/dist/tsup/actor/errors.cjs.map +1 -1
  16. package/dist/tsup/actor/errors.d.cts +37 -1
  17. package/dist/tsup/actor/errors.d.ts +37 -1
  18. package/dist/tsup/actor/errors.js +26 -1
  19. package/dist/tsup/{actor-router-consts-DzI2szci.d.cts → actor-router-consts-D29T1Z-K.d.cts} +1 -1
  20. package/dist/tsup/{actor-router-consts-DzI2szci.d.ts → actor-router-consts-D29T1Z-K.d.ts} +1 -1
  21. package/dist/tsup/chunk-424PT5DM.js +23 -0
  22. package/dist/tsup/chunk-424PT5DM.js.map +1 -0
  23. package/dist/tsup/{chunk-JDAD2YFA.js → chunk-5ESWDTHJ.js} +148 -273
  24. package/dist/tsup/chunk-5ESWDTHJ.js.map +1 -0
  25. package/dist/tsup/{chunk-FJ3KTN4V.js → chunk-6LIBPELE.js} +119 -11
  26. package/dist/tsup/chunk-6LIBPELE.js.map +1 -0
  27. package/dist/tsup/chunk-6LJAZ5R4.cjs +96 -0
  28. package/dist/tsup/chunk-6LJAZ5R4.cjs.map +1 -0
  29. package/dist/tsup/{chunk-LFVF5SCU.js → chunk-7HTNH26M.js} +126 -1
  30. package/dist/tsup/chunk-7HTNH26M.js.map +1 -0
  31. package/dist/tsup/chunk-7K4CYDGD.js +630 -0
  32. package/dist/tsup/chunk-7K4CYDGD.js.map +1 -0
  33. package/dist/tsup/{chunk-XXGJCOL6.js → chunk-A6YIZWTK.js} +2 -2
  34. package/dist/tsup/chunk-AIYEYMX5.cjs +630 -0
  35. package/dist/tsup/chunk-AIYEYMX5.cjs.map +1 -0
  36. package/dist/tsup/{chunk-Q6W7RJJP.js → chunk-DIGBC2VI.js} +211 -2316
  37. package/dist/tsup/chunk-DIGBC2VI.js.map +1 -0
  38. package/dist/tsup/{chunk-RZW2DNND.cjs → chunk-F6JYU5IK.cjs} +1957 -1039
  39. package/dist/tsup/chunk-F6JYU5IK.cjs.map +1 -0
  40. package/dist/tsup/chunk-HAZL2EPK.cjs +534 -0
  41. package/dist/tsup/chunk-HAZL2EPK.cjs.map +1 -0
  42. package/dist/tsup/chunk-HDQ2JUQT.cjs +23 -0
  43. package/dist/tsup/chunk-HDQ2JUQT.cjs.map +1 -0
  44. package/dist/tsup/chunk-HIDX4C5Y.cjs +1036 -0
  45. package/dist/tsup/chunk-HIDX4C5Y.cjs.map +1 -0
  46. package/dist/tsup/chunk-IVG73YCW.js +534 -0
  47. package/dist/tsup/chunk-IVG73YCW.js.map +1 -0
  48. package/dist/tsup/chunk-KJSYAUOM.js +96 -0
  49. package/dist/tsup/chunk-KJSYAUOM.js.map +1 -0
  50. package/dist/tsup/{chunk-2XQS746M.cjs → chunk-L47L3ZWJ.cjs} +127 -2
  51. package/dist/tsup/chunk-L47L3ZWJ.cjs.map +1 -0
  52. package/dist/tsup/{chunk-H4TB4X25.cjs → chunk-LW6KLR7A.cjs} +126 -18
  53. package/dist/tsup/chunk-LW6KLR7A.cjs.map +1 -0
  54. package/dist/tsup/chunk-LXUQ667X.js +2006 -0
  55. package/dist/tsup/chunk-LXUQ667X.js.map +1 -0
  56. package/dist/tsup/{chunk-GMAVRZSF.js → chunk-M2T62AZQ.js} +1790 -872
  57. package/dist/tsup/chunk-M2T62AZQ.js.map +1 -0
  58. package/dist/tsup/chunk-MZ37VV3P.js +5974 -0
  59. package/dist/tsup/chunk-MZ37VV3P.js.map +1 -0
  60. package/dist/tsup/chunk-N4KRDJ56.js +72 -0
  61. package/dist/tsup/chunk-N4KRDJ56.js.map +1 -0
  62. package/dist/tsup/chunk-NIYZDWMW.cjs +2006 -0
  63. package/dist/tsup/chunk-NIYZDWMW.cjs.map +1 -0
  64. package/dist/tsup/chunk-OMEPCQK2.js +649 -0
  65. package/dist/tsup/chunk-OMEPCQK2.js.map +1 -0
  66. package/dist/tsup/chunk-SR3KQE7Q.cjs +72 -0
  67. package/dist/tsup/chunk-SR3KQE7Q.cjs.map +1 -0
  68. package/dist/tsup/chunk-SSEP6DHP.cjs +2657 -0
  69. package/dist/tsup/chunk-SSEP6DHP.cjs.map +1 -0
  70. package/dist/tsup/chunk-T5YCUGVS.js +1036 -0
  71. package/dist/tsup/chunk-T5YCUGVS.js.map +1 -0
  72. package/dist/tsup/{chunk-EJVBH5VF.cjs → chunk-TPGXWFQT.cjs} +3 -3
  73. package/dist/tsup/{chunk-EJVBH5VF.cjs.map → chunk-TPGXWFQT.cjs.map} +1 -1
  74. package/dist/tsup/{chunk-X35U3YNX.cjs → chunk-TYLXNCA5.cjs} +214 -339
  75. package/dist/tsup/chunk-TYLXNCA5.cjs.map +1 -0
  76. package/dist/tsup/chunk-VKVNIQRQ.js +257 -0
  77. package/dist/tsup/chunk-VKVNIQRQ.js.map +1 -0
  78. package/dist/tsup/chunk-XWBAQO5H.cjs +649 -0
  79. package/dist/tsup/chunk-XWBAQO5H.cjs.map +1 -0
  80. package/dist/tsup/chunk-YQ4LDVD6.cjs +5974 -0
  81. package/dist/tsup/chunk-YQ4LDVD6.cjs.map +1 -0
  82. package/dist/tsup/chunk-ZFY5J2EP.cjs +257 -0
  83. package/dist/tsup/chunk-ZFY5J2EP.cjs.map +1 -0
  84. package/dist/tsup/client/mod.cjs +9 -10
  85. package/dist/tsup/client/mod.cjs.map +1 -1
  86. package/dist/tsup/client/mod.d.cts +11 -5
  87. package/dist/tsup/client/mod.d.ts +11 -5
  88. package/dist/tsup/client/mod.js +8 -8
  89. package/dist/tsup/common/log.cjs +4 -4
  90. package/dist/tsup/common/log.d.cts +2 -2
  91. package/dist/tsup/common/log.d.ts +2 -2
  92. package/dist/tsup/common/log.js +3 -2
  93. package/dist/tsup/common/websocket.cjs +5 -5
  94. package/dist/tsup/common/websocket.js +4 -3
  95. package/dist/tsup/config-BFqid9Gr.d.ts +2574 -0
  96. package/dist/tsup/config-BiNoIHRs.d.cts +80 -0
  97. package/dist/tsup/config-BiNoIHRs.d.ts +80 -0
  98. package/dist/tsup/{config-CZB2-W8x.d.cts → config-CAZphOS1.d.cts} +681 -355
  99. package/dist/tsup/db/drizzle/mod.cjs +49 -0
  100. package/dist/tsup/db/drizzle/mod.cjs.map +1 -0
  101. package/dist/tsup/db/drizzle/mod.d.cts +17 -0
  102. package/dist/tsup/db/drizzle/mod.d.ts +17 -0
  103. package/dist/tsup/db/drizzle/mod.js +49 -0
  104. package/dist/tsup/db/drizzle/mod.js.map +1 -0
  105. package/dist/tsup/db/mod.cjs +9 -0
  106. package/dist/tsup/db/mod.cjs.map +1 -0
  107. package/dist/tsup/db/mod.d.cts +9 -0
  108. package/dist/tsup/db/mod.d.ts +9 -0
  109. package/dist/tsup/db/mod.js +9 -0
  110. package/dist/tsup/db/mod.js.map +1 -0
  111. package/dist/tsup/{driver-D0QX9M11.d.ts → driver-Bxv62E2p.d.ts} +2 -2
  112. package/dist/tsup/{driver-q-zqG7fc.d.cts → driver-DYXwJR5D.d.cts} +2 -2
  113. package/dist/tsup/driver-helpers/mod.cjs +12 -6
  114. package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
  115. package/dist/tsup/driver-helpers/mod.d.cts +12 -5
  116. package/dist/tsup/driver-helpers/mod.d.ts +12 -5
  117. package/dist/tsup/driver-helpers/mod.js +12 -5
  118. package/dist/tsup/driver-test-suite/mod.cjs +1370 -116
  119. package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
  120. package/dist/tsup/driver-test-suite/mod.d.cts +10 -4
  121. package/dist/tsup/driver-test-suite/mod.d.ts +10 -4
  122. package/dist/tsup/driver-test-suite/mod.js +2093 -838
  123. package/dist/tsup/driver-test-suite/mod.js.map +1 -1
  124. package/dist/tsup/inspector/mod.cjs +29 -3
  125. package/dist/tsup/inspector/mod.cjs.map +1 -1
  126. package/dist/tsup/inspector/mod.d.cts +124 -3
  127. package/dist/tsup/inspector/mod.d.ts +124 -3
  128. package/dist/tsup/inspector/mod.js +72 -45
  129. package/dist/tsup/keys-CydblqMh.d.cts +13 -0
  130. package/dist/tsup/keys-CydblqMh.d.ts +13 -0
  131. package/dist/tsup/mod.cjs +16 -10
  132. package/dist/tsup/mod.cjs.map +1 -1
  133. package/dist/tsup/mod.d.cts +26 -14
  134. package/dist/tsup/mod.d.ts +26 -14
  135. package/dist/tsup/mod.js +20 -13
  136. package/dist/tsup/serve-test-suite/mod.cjs +1165 -83
  137. package/dist/tsup/serve-test-suite/mod.cjs.map +1 -1
  138. package/dist/tsup/serve-test-suite/mod.js +1114 -29
  139. package/dist/tsup/serve-test-suite/mod.js.map +1 -1
  140. package/dist/tsup/test/mod.cjs +84 -11
  141. package/dist/tsup/test/mod.cjs.map +1 -1
  142. package/dist/tsup/test/mod.d.cts +10 -5
  143. package/dist/tsup/test/mod.d.ts +10 -5
  144. package/dist/tsup/test/mod.js +85 -11
  145. package/dist/tsup/test/mod.js.map +1 -1
  146. package/dist/tsup/utils.cjs +10 -4
  147. package/dist/tsup/utils.cjs.map +1 -1
  148. package/dist/tsup/utils.d.cts +72 -2
  149. package/dist/tsup/utils.d.ts +72 -2
  150. package/dist/tsup/utils.js +9 -2
  151. package/dist/tsup/v3-DnYObHH3.d.cts +279 -0
  152. package/dist/tsup/v3-DnYObHH3.d.ts +279 -0
  153. package/dist/tsup/workflow/mod.cjs +16 -0
  154. package/dist/tsup/workflow/mod.cjs.map +1 -0
  155. package/dist/tsup/workflow/mod.d.cts +83 -0
  156. package/dist/tsup/workflow/mod.d.ts +83 -0
  157. package/dist/tsup/workflow/mod.js +16 -0
  158. package/dist/tsup/workflow/mod.js.map +1 -0
  159. package/package.json +62 -5
  160. package/src/actor/config.ts +478 -68
  161. package/src/actor/conn/mod.ts +68 -16
  162. package/src/actor/conn/state-manager.ts +2 -2
  163. package/src/actor/contexts/action.ts +20 -12
  164. package/src/actor/contexts/base/actor.ts +137 -7
  165. package/src/actor/contexts/base/conn-init.ts +27 -7
  166. package/src/actor/contexts/base/conn.ts +27 -18
  167. package/src/actor/contexts/before-action-response.ts +9 -2
  168. package/src/actor/contexts/before-connect.ts +7 -2
  169. package/src/actor/contexts/connect.ts +9 -2
  170. package/src/actor/contexts/create-conn-state.ts +7 -2
  171. package/src/actor/contexts/create-vars.ts +16 -3
  172. package/src/actor/contexts/create.ts +16 -3
  173. package/src/actor/contexts/destroy.ts +9 -3
  174. package/src/actor/contexts/disconnect.ts +10 -4
  175. package/src/actor/contexts/index.ts +4 -3
  176. package/src/actor/contexts/request.ts +23 -6
  177. package/src/actor/contexts/run.ts +47 -0
  178. package/src/actor/contexts/sleep.ts +9 -3
  179. package/src/actor/contexts/state-change.ts +9 -3
  180. package/src/actor/contexts/wake.ts +9 -3
  181. package/src/actor/contexts/websocket.ts +23 -6
  182. package/src/actor/database.ts +8 -18
  183. package/src/actor/definition.ts +20 -6
  184. package/src/actor/driver.ts +32 -3
  185. package/src/actor/errors.ts +127 -0
  186. package/src/actor/instance/connection-manager.ts +183 -80
  187. package/src/actor/instance/event-manager.ts +26 -15
  188. package/src/actor/instance/keys.ts +117 -0
  189. package/src/actor/instance/mod.ts +784 -174
  190. package/src/actor/instance/queue-manager.ts +603 -0
  191. package/src/actor/instance/queue.ts +287 -0
  192. package/src/actor/instance/schedule-manager.ts +49 -7
  193. package/src/actor/instance/state-manager.ts +35 -11
  194. package/src/actor/instance/traces-driver.ts +128 -0
  195. package/src/actor/mod.ts +26 -2
  196. package/src/actor/protocol/old.ts +28 -13
  197. package/src/actor/protocol/serde.ts +1 -1
  198. package/src/actor/router-endpoints.ts +177 -21
  199. package/src/actor/router-websocket-endpoints.ts +18 -29
  200. package/src/actor/router.ts +177 -0
  201. package/src/actor/schema.ts +291 -0
  202. package/src/actor/utils.ts +40 -0
  203. package/src/client/actor-common.ts +1 -1
  204. package/src/client/actor-conn.ts +100 -33
  205. package/src/client/actor-handle.ts +61 -33
  206. package/src/client/client.ts +2 -4
  207. package/src/client/config.ts +1 -1
  208. package/src/client/mod.browser.ts +2 -0
  209. package/src/client/mod.ts +1 -4
  210. package/src/client/queue.ts +146 -0
  211. package/src/client/utils.ts +1 -1
  212. package/src/common/log.ts +1 -1
  213. package/src/common/utils.ts +3 -3
  214. package/src/db/config.ts +100 -0
  215. package/src/db/drizzle/mod.ts +226 -0
  216. package/src/db/drizzle/sqlite-core.ts +22 -0
  217. package/src/db/mod.ts +125 -0
  218. package/src/db/shared.ts +92 -0
  219. package/src/db/sqlite-vfs.ts +12 -0
  220. package/src/driver-helpers/mod.ts +1 -0
  221. package/src/driver-test-suite/mod.ts +69 -43
  222. package/src/driver-test-suite/tests/access-control.ts +218 -0
  223. package/src/driver-test-suite/tests/actor-db-raw.ts +73 -0
  224. package/src/driver-test-suite/tests/actor-db.ts +394 -0
  225. package/src/driver-test-suite/tests/actor-inspector.ts +259 -358
  226. package/src/driver-test-suite/tests/actor-kv.ts +41 -20
  227. package/src/driver-test-suite/tests/actor-queue.ts +324 -0
  228. package/src/driver-test-suite/tests/actor-run.ts +181 -0
  229. package/src/driver-test-suite/tests/actor-schedule.ts +5 -2
  230. package/src/driver-test-suite/tests/actor-sleep.ts +3 -3
  231. package/src/driver-test-suite/tests/actor-stateless.ts +70 -0
  232. package/src/driver-test-suite/tests/actor-workflow.ts +108 -0
  233. package/src/driver-test-suite/tests/manager-driver.ts +11 -0
  234. package/src/driver-test-suite/tests/raw-http-request-properties.ts +1 -1
  235. package/src/driver-test-suite/tests/raw-websocket.ts +12 -12
  236. package/src/drivers/default.ts +7 -2
  237. package/src/drivers/engine/actor-driver.ts +45 -37
  238. package/src/drivers/engine/config.ts +1 -1
  239. package/src/drivers/file-system/actor.ts +20 -2
  240. package/src/drivers/file-system/global-state.ts +569 -258
  241. package/src/drivers/file-system/kv-limits.ts +70 -0
  242. package/src/drivers/file-system/manager.ts +22 -6
  243. package/src/drivers/file-system/mod.ts +39 -16
  244. package/src/drivers/file-system/sqlite-runtime.ts +210 -0
  245. package/src/inspector/actor-inspector.ts +224 -102
  246. package/src/inspector/config.ts +1 -1
  247. package/src/inspector/handler.ts +102 -20
  248. package/src/inspector/mod.browser.ts +8 -0
  249. package/src/inspector/mod.ts +2 -0
  250. package/src/inspector/serve-ui.ts +40 -0
  251. package/src/inspector/transport.ts +18 -0
  252. package/src/inspector/utils.ts +5 -39
  253. package/src/manager/gateway.ts +1 -1
  254. package/src/manager/protocol/mod.ts +1 -1
  255. package/src/manager/protocol/query.ts +1 -1
  256. package/src/manager/router-schema.ts +1 -1
  257. package/src/manager/router.ts +38 -12
  258. package/src/manager-api/actors.ts +1 -1
  259. package/src/manager-api/common.ts +1 -1
  260. package/src/registry/config/driver.ts +1 -1
  261. package/src/registry/config/index.ts +212 -43
  262. package/src/registry/config/legacy-runner.ts +1 -1
  263. package/src/registry/config/runner.ts +1 -1
  264. package/src/registry/config/serverless.ts +1 -1
  265. package/src/registry/index.ts +7 -5
  266. package/src/remote-manager-driver/api-utils.ts +1 -1
  267. package/src/schemas/actor-inspector/mod.ts +1 -1
  268. package/src/schemas/actor-inspector/versioned.ts +195 -8
  269. package/src/schemas/actor-persist/versioned.ts +87 -7
  270. package/src/schemas/client-protocol/mod.ts +1 -1
  271. package/src/schemas/client-protocol/versioned.ts +127 -11
  272. package/src/schemas/client-protocol-zod/mod.ts +16 -1
  273. package/src/schemas/persist/mod.ts +1 -0
  274. package/src/schemas/transport/mod.ts +1 -0
  275. package/src/serde.ts +1 -1
  276. package/src/serve-test-suite/mod.ts +10 -9
  277. package/src/test/mod.ts +15 -56
  278. package/src/utils/endpoint-parser.test.ts +1 -1
  279. package/src/utils/endpoint-parser.ts +1 -1
  280. package/src/utils/env-vars.ts +12 -1
  281. package/src/utils/node.ts +15 -2
  282. package/src/utils.test.ts +34 -0
  283. package/src/utils.ts +140 -6
  284. package/src/workflow/constants.ts +2 -0
  285. package/src/workflow/context.ts +532 -0
  286. package/src/workflow/driver.ts +191 -0
  287. package/src/workflow/inspector.ts +268 -0
  288. package/src/workflow/mod.ts +122 -0
  289. package/dist/tsup/chunk-2IJTYN6K.cjs +0 -278
  290. package/dist/tsup/chunk-2IJTYN6K.cjs.map +0 -1
  291. package/dist/tsup/chunk-2XQS746M.cjs.map +0 -1
  292. package/dist/tsup/chunk-3VP5CSHV.cjs +0 -114
  293. package/dist/tsup/chunk-3VP5CSHV.cjs.map +0 -1
  294. package/dist/tsup/chunk-AQFSQMBG.js +0 -114
  295. package/dist/tsup/chunk-AQFSQMBG.js.map +0 -1
  296. package/dist/tsup/chunk-E6ZE2YEA.js +0 -664
  297. package/dist/tsup/chunk-E6ZE2YEA.js.map +0 -1
  298. package/dist/tsup/chunk-FJ3KTN4V.js.map +0 -1
  299. package/dist/tsup/chunk-GBENOENJ.cjs +0 -8
  300. package/dist/tsup/chunk-GBENOENJ.cjs.map +0 -1
  301. package/dist/tsup/chunk-GD7UXGOE.cjs +0 -4762
  302. package/dist/tsup/chunk-GD7UXGOE.cjs.map +0 -1
  303. package/dist/tsup/chunk-GMAVRZSF.js.map +0 -1
  304. package/dist/tsup/chunk-H4TB4X25.cjs.map +0 -1
  305. package/dist/tsup/chunk-JDAD2YFA.js.map +0 -1
  306. package/dist/tsup/chunk-KCOVZOPS.js +0 -1946
  307. package/dist/tsup/chunk-KCOVZOPS.js.map +0 -1
  308. package/dist/tsup/chunk-KDFWJKMJ.cjs +0 -664
  309. package/dist/tsup/chunk-KDFWJKMJ.cjs.map +0 -1
  310. package/dist/tsup/chunk-LFVF5SCU.js.map +0 -1
  311. package/dist/tsup/chunk-Q6W7RJJP.js.map +0 -1
  312. package/dist/tsup/chunk-RUW5CZ5Z.cjs +0 -1949
  313. package/dist/tsup/chunk-RUW5CZ5Z.cjs.map +0 -1
  314. package/dist/tsup/chunk-RZW2DNND.cjs.map +0 -1
  315. package/dist/tsup/chunk-TCOEBUUE.js +0 -278
  316. package/dist/tsup/chunk-TCOEBUUE.js.map +0 -1
  317. package/dist/tsup/chunk-X35U3YNX.cjs.map +0 -1
  318. package/dist/tsup/keys-Chhy4ylv.d.cts +0 -8
  319. package/dist/tsup/keys-Chhy4ylv.d.ts +0 -8
  320. package/dist/tsup/v1-Gq4avTK3.d.cts +0 -240
  321. package/dist/tsup/v1-Gq4avTK3.d.ts +0 -240
  322. /package/dist/tsup/{chunk-XXGJCOL6.js.map → chunk-A6YIZWTK.js.map} +0 -0
@@ -1,32 +1,19 @@
1
- import { z } from 'zod';
1
+ import { z as z$1 } from 'zod/v4';
2
2
  import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
3
+ import { A as AnyDatabaseProvider, D as DatabaseProvider, a as RawDatabaseClient } from './config-BiNoIHRs.cjs';
4
+ import { Traces, OtlpExportTraceServiceRequestJson, SpanHandle, SpanStatusInput } from '@rivetkit/traces';
3
5
  import { Env, Context, Hono } from 'hono';
4
6
  import { VersionedDataHandler } from 'vbare';
5
7
  import { Logger } from 'pino';
6
8
  import { GetUpgradeWebSocket } from './utils.cjs';
9
+ import { SqliteVfs } from '@rivetkit/sqlite-vfs';
10
+ import { BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core';
11
+ import { z } from 'zod';
12
+ import { StandardSchemaV1 } from '@standard-schema/spec';
7
13
  import * as nanoevents from 'nanoevents';
8
- import { a1 as Event } from './v1-Gq4avTK3.cjs';
14
+ import { W as WorkflowHistory, k as QueueStatus } from './v3-DnYObHH3.cjs';
9
15
 
10
16
  type InferDatabaseClient<DBProvider extends AnyDatabaseProvider> = DBProvider extends DatabaseProvider<any> ? Awaited<ReturnType<DBProvider["createClient"]>> : never;
11
- type AnyDatabaseProvider = DatabaseProvider<any> | undefined;
12
- type DatabaseProvider<DB extends {
13
- execute: (query: string) => any;
14
- }> = {
15
- /**
16
- * Creates a new database client for the actor.
17
- * The result is passed to the actor context as `c.db`.
18
- * @experimental
19
- */
20
- createClient: (ctx: {
21
- getDatabase: () => Promise<string | unknown>;
22
- }) => Promise<DB>;
23
- /**
24
- * Runs before the actor has started.
25
- * Use this to run migrations or other setup tasks.
26
- * @experimental
27
- */
28
- onMigrate: (client: DB) => void | Promise<void>;
29
- };
30
17
 
31
18
  type ManagerDriverBuilder = (config: RegistryConfig) => ManagerDriver;
32
19
  interface ManagerDriver {
@@ -116,10 +103,28 @@ interface ActorDriver {
116
103
  /** ActorInstance ensure that only one instance of setAlarm is called in parallel at a time. */
117
104
  setAlarm(actor: AnyActorInstance, timestamp: number): Promise<void>;
118
105
  /**
106
+ * Override the default raw database client for the actor.
107
+ * If not provided, rivetkit will construct a KV-backed SQLite client.
119
108
  * @experimental
120
- * This is an experimental API that may change in the future.
121
109
  */
122
- getDatabase(actorId: string): Promise<unknown | undefined>;
110
+ overrideRawDatabaseClient?(actorId: string): Promise<RawDatabaseClient | undefined>;
111
+ /**
112
+ * Override the default Drizzle database client for the actor.
113
+ * If not provided, rivetkit will construct a KV-backed Drizzle client.
114
+ * @experimental
115
+ */
116
+ overrideDrizzleDatabaseClient?(actorId: string): Promise<BaseSQLiteDatabase<any, any, any, any> | undefined>;
117
+ /**
118
+ * Creates a SQLite VFS instance for creating KV-backed databases.
119
+ * If not provided, the database provider will need an override.
120
+ *
121
+ * @rivetkit/sqlite's async build is not re-entrant per module instance. Drivers
122
+ * should return a new instance per call for actor-level isolation.
123
+ *
124
+ * This is a method (not a property) so drivers can use dynamic imports,
125
+ * keeping the core driver tree-shakeable from @rivetkit/sqlite.
126
+ */
127
+ createSqliteVfs?(): SqliteVfs | Promise<SqliteVfs>;
123
128
  /**
124
129
  * Requests the actor to go to sleep.
125
130
  *
@@ -147,7 +152,7 @@ interface ActorDriver {
147
152
  onAfterPersistConn?(conn: AnyConn): void;
148
153
  }
149
154
 
150
- declare const ActorsSchema: z.ZodRecord<z.ZodString, z.ZodCustom<ActorDefinition<any, any, any, any, any, any, any>, ActorDefinition<any, any, any, any, any, any, any>>>;
155
+ declare const ActorsSchema: z.ZodRecord<z.ZodString, z.ZodCustom<ActorDefinition<any, any, any, any, any, any, any, any, any>, ActorDefinition<any, any, any, any, any, any, any, any, any>>>;
151
156
  type RegistryActors = z.infer<typeof ActorsSchema>;
152
157
  declare const TestConfigSchema: z.ZodObject<{
153
158
  enabled: z.ZodBoolean;
@@ -165,6 +170,7 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
165
170
  actor: z.ZodCustom<ActorDriverBuilder, ActorDriverBuilder>;
166
171
  autoStartActorDriver: z.ZodBoolean;
167
172
  }, z.core.$strip>>;
173
+ storagePath: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | undefined, string | undefined>>;
168
174
  maxIncomingMessageSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
169
175
  maxOutgoingMessageSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
170
176
  noWelcome: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
@@ -263,6 +269,7 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
263
269
  test: {
264
270
  enabled: boolean;
265
271
  };
272
+ storagePath: string | undefined;
266
273
  maxIncomingMessageSize: number;
267
274
  maxOutgoingMessageSize: number;
268
275
  noWelcome: boolean;
@@ -292,6 +299,7 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
292
299
  test: {
293
300
  enabled: boolean;
294
301
  };
302
+ storagePath: string | undefined;
295
303
  maxIncomingMessageSize: number;
296
304
  maxOutgoingMessageSize: number;
297
305
  noWelcome: boolean;
@@ -351,7 +359,7 @@ type RegistryConfigInput<A extends RegistryActors> = Omit<z.input<typeof Registr
351
359
  use: A;
352
360
  };
353
361
  declare function buildActorNames(config: RegistryConfig): Record<string, {
354
- metadata: Record<string, any>;
362
+ metadata: Record<string, unknown>;
355
363
  }>;
356
364
  declare const DocInspectorConfigSchema: z.ZodOptional<z.ZodObject<{
357
365
  enabled: z.ZodOptional<z.ZodBoolean>;
@@ -397,6 +405,7 @@ declare const DocRunnerConfigSchema: z.ZodObject<{
397
405
  }, z.core.$strip>;
398
406
  declare const DocRegistryConfigSchema: z.ZodObject<{
399
407
  use: z.ZodRecord<z.ZodString, z.ZodUnknown>;
408
+ storagePath: z.ZodOptional<z.ZodString>;
400
409
  maxIncomingMessageSize: z.ZodOptional<z.ZodNumber>;
401
410
  maxOutgoingMessageSize: z.ZodOptional<z.ZodNumber>;
402
411
  noWelcome: z.ZodOptional<z.ZodBoolean>;
@@ -450,18 +459,69 @@ declare const DocRegistryConfigSchema: z.ZodObject<{
450
459
  }, z.core.$strip>>;
451
460
  }, z.core.$strip>;
452
461
 
453
- type AnyActorDefinition = ActorDefinition<any, any, any, any, any, any, any>;
454
- declare class ActorDefinition<S, CP, CS, V, I, DB extends AnyDatabaseProvider, R extends Actions<S, CP, CS, V, I, DB>> {
462
+ type SchemaHookResult = boolean | Promise<boolean>;
463
+ type SchemaHook<TContext = any> = (ctx: TContext) => SchemaHookResult;
464
+ interface EventTypeToken<T, TContext = any> {
465
+ readonly _eventType?: T;
466
+ readonly canSubscribe?: SchemaHook<TContext>;
467
+ readonly schema?: PrimitiveSchema;
468
+ }
469
+ interface QueueTypeToken<TMessage, TComplete = never, TContext = any> {
470
+ readonly _queueMessage?: TMessage;
471
+ readonly _queueComplete?: TComplete;
472
+ readonly canPublish?: SchemaHook<TContext>;
473
+ readonly message?: PrimitiveSchema;
474
+ readonly complete?: PrimitiveSchema;
475
+ }
476
+ /** @deprecated Use `event<T>()`. */
477
+ type Type<T> = EventTypeToken<T, any>;
478
+ interface EventOptions<TContext = any> {
479
+ canSubscribe?: SchemaHook<TContext>;
480
+ schema?: PrimitiveSchema;
481
+ }
482
+ interface QueueOptions<TContext = any> {
483
+ canPublish?: SchemaHook<TContext>;
484
+ message?: PrimitiveSchema;
485
+ complete?: PrimitiveSchema;
486
+ }
487
+ declare function event<T, TContext = any>(options?: EventOptions<TContext>): EventTypeToken<T, TContext>;
488
+ declare function queue<TMessage, TComplete = never, TContext = any>(options?: QueueOptions<TContext>): QueueTypeToken<TMessage, TComplete, TContext>;
489
+ type PrimitiveSchema = StandardSchemaV1 | EventTypeToken<unknown, any>;
490
+ interface EventSchemaDefinition<TContext = any> {
491
+ schema: PrimitiveSchema;
492
+ canSubscribe?: SchemaHook<TContext>;
493
+ }
494
+ interface QueueSchemaDefinition<TContext = any> {
495
+ message: PrimitiveSchema;
496
+ complete?: PrimitiveSchema;
497
+ canPublish?: SchemaHook<TContext>;
498
+ }
499
+ type EventSchema<TContext = any> = PrimitiveSchema | EventSchemaDefinition<TContext>;
500
+ type QueueSchema = PrimitiveSchema | QueueSchemaDefinition<any> | QueueTypeToken<unknown, unknown, any>;
501
+ type EventSchemaConfig<TContext = any> = Record<string, EventSchema<TContext>>;
502
+ type QueueSchemaConfig<TContext = any> = Record<string, QueueSchema>;
503
+ type InferSchema<T> = T extends QueueSchemaDefinition<any> ? InferSchema<T["message"]> : T extends QueueTypeToken<infer M, unknown, any> ? M : T extends EventSchemaDefinition<any> ? InferSchema<T["schema"]> : T extends StandardSchemaV1<any, infer O> ? O : T extends EventTypeToken<infer R, any> ? R : never;
504
+ type InferSchemaMap<T extends Record<string, unknown>> = {
505
+ [K in keyof T]: InferSchema<T[K]>;
506
+ };
507
+ type InferQueueComplete<T> = T extends QueueTypeToken<unknown, infer C, any> ? [C] extends [never] ? never : C : T extends QueueSchemaDefinition<any> ? T["complete"] extends PrimitiveSchema ? InferSchema<T["complete"]> : never : never;
508
+ type InferQueueCompleteMap<T extends QueueSchemaConfig> = {
509
+ [K in keyof T]: InferQueueComplete<T[K]>;
510
+ };
511
+ type InferEventArgs<T> = T extends readonly unknown[] ? number extends T["length"] ? [T] : T : [T];
512
+
513
+ type AnyActorDefinition = ActorDefinition<any, any, any, any, any, any, any, any, any>;
514
+ declare class ActorDefinition<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>, R extends Actions<S, CP, CS, V, I, DB, E, Q> = Actions<S, CP, CS, V, I, DB, E, Q>> {
455
515
  #private;
456
- constructor(config: ActorConfig<S, CP, CS, V, I, DB>);
457
- get config(): ActorConfig<S, CP, CS, V, I, DB>;
458
- instantiate(): ActorInstance<S, CP, CS, V, I, DB>;
516
+ constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q>);
517
+ get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q>;
518
+ instantiate(): ActorInstance<S, CP, CS, V, I, DB, E, Q>;
459
519
  }
460
520
  declare function lookupInRegistry(config: RegistryConfig, name: string): AnyActorDefinition;
461
521
 
462
522
  /** Data that's been serialized. */
463
523
  type OutputData = string | Uint8Array;
464
- declare const EncodingSchema: z.ZodEnum<{
524
+ declare const EncodingSchema: z$1.ZodEnum<{
465
525
  json: "json";
466
526
  cbor: "cbor";
467
527
  bare: "bare";
@@ -469,45 +529,45 @@ declare const EncodingSchema: z.ZodEnum<{
469
529
  /**
470
530
  * Encoding used to communicate between the client & actor.
471
531
  */
472
- type Encoding = z.infer<typeof EncodingSchema>;
532
+ type Encoding = z$1.infer<typeof EncodingSchema>;
473
533
  /**
474
534
  * Helper class that helps serialize data without re-serializing for the same encoding.
475
535
  */
476
536
  declare class CachedSerializer<TBare, TJson, T = TBare> {
477
537
  #private;
478
- constructor(data: T, versionedDataHandler: VersionedDataHandler<TBare>, version: number, zodSchema: z.ZodType<TJson>, toJson: (value: T) => TJson, toBare: (value: T) => TBare);
538
+ constructor(data: T, versionedDataHandler: VersionedDataHandler<TBare>, version: number, zodSchema: z$1.ZodType<TJson>, toJson: (value: T) => TJson, toBare: (value: T) => TBare);
479
539
  get rawData(): T;
480
540
  serialize(encoding: Encoding): OutputData;
481
541
  }
482
542
 
483
- declare const LegacyRunnerConfigSchema: z.ZodDefault<z.ZodPipe<z.ZodObject<{
484
- driver: z.ZodOptional<z.ZodObject<{
485
- name: z.ZodString;
486
- manager: z.ZodCustom<ManagerDriverBuilder, ManagerDriverBuilder>;
487
- actor: z.ZodCustom<ActorDriverBuilder, ActorDriverBuilder>;
488
- }, z.core.$strip>>;
489
- maxIncomingMessageSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
490
- maxOutgoingMessageSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
491
- inspector: z.ZodDefault<z.ZodOptional<z.ZodObject<{
492
- enabled: z.ZodDefault<z.ZodBoolean>;
493
- token: z.ZodDefault<z.ZodOptional<z.ZodCustom<() => string, () => string>>>;
494
- defaultEndpoint: z.ZodOptional<z.ZodString>;
495
- }, z.core.$strip>>>;
496
- disableDefaultServer: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
497
- defaultServerPort: z.ZodDefault<z.ZodNumber>;
498
- runEngine: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
499
- runEngineVersion: z.ZodDefault<z.ZodOptional<z.ZodString>>;
500
- overrideServerAddress: z.ZodOptional<z.ZodString>;
501
- disableActorDriver: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
502
- runnerKind: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
543
+ declare const LegacyRunnerConfigSchema: z$1.ZodDefault<z$1.ZodPipe<z$1.ZodObject<{
544
+ driver: z$1.ZodOptional<z$1.ZodObject<{
545
+ name: z$1.ZodString;
546
+ manager: z$1.ZodCustom<ManagerDriverBuilder, ManagerDriverBuilder>;
547
+ actor: z$1.ZodCustom<ActorDriverBuilder, ActorDriverBuilder>;
548
+ }, z$1.core.$strip>>;
549
+ maxIncomingMessageSize: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
550
+ maxOutgoingMessageSize: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
551
+ inspector: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodObject<{
552
+ enabled: z$1.ZodDefault<z$1.ZodBoolean>;
553
+ token: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodCustom<() => string, () => string>>>;
554
+ defaultEndpoint: z$1.ZodOptional<z$1.ZodString>;
555
+ }, z$1.core.$strip>>>;
556
+ disableDefaultServer: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
557
+ defaultServerPort: z$1.ZodDefault<z$1.ZodNumber>;
558
+ runEngine: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
559
+ runEngineVersion: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodString>>;
560
+ overrideServerAddress: z$1.ZodOptional<z$1.ZodString>;
561
+ disableActorDriver: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
562
+ runnerKind: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodEnum<{
503
563
  serverless: "serverless";
504
564
  normal: "normal";
505
565
  }>>>;
506
- basePath: z.ZodDefault<z.ZodOptional<z.ZodString>>;
507
- noWelcome: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
508
- logging: z.ZodDefault<z.ZodOptional<z.ZodObject<{
509
- baseLogger: z.ZodOptional<z.ZodCustom<Logger, Logger>>;
510
- level: z.ZodOptional<z.ZodEnum<{
566
+ basePath: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodString>>;
567
+ noWelcome: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
568
+ logging: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodObject<{
569
+ baseLogger: z$1.ZodOptional<z$1.ZodCustom<Logger, Logger>>;
570
+ level: z$1.ZodOptional<z$1.ZodEnum<{
511
571
  error: "error";
512
572
  trace: "trace";
513
573
  fatal: "fatal";
@@ -516,33 +576,33 @@ declare const LegacyRunnerConfigSchema: z.ZodDefault<z.ZodPipe<z.ZodObject<{
516
576
  debug: "debug";
517
577
  silent: "silent";
518
578
  }>>;
519
- }, z.core.$strip>>>;
520
- autoConfigureServerless: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
521
- url: z.ZodOptional<z.ZodString>;
522
- headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
523
- maxRunners: z.ZodOptional<z.ZodNumber>;
524
- minRunners: z.ZodOptional<z.ZodNumber>;
525
- requestLifespan: z.ZodOptional<z.ZodNumber>;
526
- runnersMargin: z.ZodOptional<z.ZodNumber>;
527
- slotsPerRunner: z.ZodOptional<z.ZodNumber>;
528
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
529
- }, z.core.$strip>]>>;
530
- endpoint: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string, string | undefined>>;
531
- token: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | undefined, string | undefined>>;
532
- namespace: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | undefined, string | undefined>>;
533
- runnerName: z.ZodDefault<z.ZodString>;
534
- encoding: z.ZodDefault<z.ZodEnum<{
579
+ }, z$1.core.$strip>>>;
580
+ autoConfigureServerless: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodBoolean, z$1.ZodObject<{
581
+ url: z$1.ZodOptional<z$1.ZodString>;
582
+ headers: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
583
+ maxRunners: z$1.ZodOptional<z$1.ZodNumber>;
584
+ minRunners: z$1.ZodOptional<z$1.ZodNumber>;
585
+ requestLifespan: z$1.ZodOptional<z$1.ZodNumber>;
586
+ runnersMargin: z$1.ZodOptional<z$1.ZodNumber>;
587
+ slotsPerRunner: z$1.ZodOptional<z$1.ZodNumber>;
588
+ metadata: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
589
+ }, z$1.core.$strip>]>>;
590
+ endpoint: z$1.ZodPipe<z$1.ZodOptional<z$1.ZodString>, z$1.ZodTransform<string, string | undefined>>;
591
+ token: z$1.ZodPipe<z$1.ZodOptional<z$1.ZodString>, z$1.ZodTransform<string | undefined, string | undefined>>;
592
+ namespace: z$1.ZodPipe<z$1.ZodOptional<z$1.ZodString>, z$1.ZodTransform<string | undefined, string | undefined>>;
593
+ runnerName: z$1.ZodDefault<z$1.ZodString>;
594
+ encoding: z$1.ZodDefault<z$1.ZodEnum<{
535
595
  json: "json";
536
596
  cbor: "cbor";
537
597
  bare: "bare";
538
598
  }>>;
539
- headers: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
540
- getUpgradeWebSocket: z.ZodOptional<z.ZodCustom<GetUpgradeWebSocket, GetUpgradeWebSocket>>;
541
- disableMetadataLookup: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
542
- devtools: z.ZodDefault<z.ZodBoolean>;
543
- runnerKey: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | undefined, string | undefined>>;
544
- totalSlots: z.ZodDefault<z.ZodNumber>;
545
- }, z.core.$strip>, z.ZodTransform<{
599
+ headers: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>>;
600
+ getUpgradeWebSocket: z$1.ZodOptional<z$1.ZodCustom<GetUpgradeWebSocket, GetUpgradeWebSocket>>;
601
+ disableMetadataLookup: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
602
+ devtools: z$1.ZodDefault<z$1.ZodBoolean>;
603
+ runnerKey: z$1.ZodPipe<z$1.ZodOptional<z$1.ZodString>, z$1.ZodTransform<string | undefined, string | undefined>>;
604
+ totalSlots: z$1.ZodDefault<z$1.ZodNumber>;
605
+ }, z$1.core.$strip>, z$1.ZodTransform<{
546
606
  runnerKey: string | undefined;
547
607
  endpoint: string | undefined;
548
608
  namespace: string;
@@ -637,7 +697,7 @@ declare const LegacyRunnerConfigSchema: z.ZodDefault<z.ZodPipe<z.ZodObject<{
637
697
  } | undefined;
638
698
  getUpgradeWebSocket?: GetUpgradeWebSocket | undefined;
639
699
  }>>>;
640
- type LegacyRunnerConfigInput = z.input<typeof LegacyRunnerConfigSchema>;
700
+ type LegacyRunnerConfigInput = z$1.input<typeof LegacyRunnerConfigSchema>;
641
701
 
642
702
  type FetchHandler = (request: Request, ...args: any) => Response | Promise<Response>;
643
703
  interface ServerlessHandler {
@@ -687,44 +747,44 @@ declare class Registry<A extends RegistryActors> {
687
747
  }
688
748
  declare function setup<A extends RegistryActors>(input: RegistryConfigInput<A>): Registry<A>;
689
749
 
690
- declare const ActorKeySchema: z.ZodArray<z.ZodString>;
691
- type ActorKey = z.infer<typeof ActorKeySchema>;
692
- declare const CreateRequestSchema: z.ZodObject<{
693
- name: z.ZodString;
694
- key: z.ZodArray<z.ZodString>;
695
- input: z.ZodOptional<z.ZodUnknown>;
696
- region: z.ZodOptional<z.ZodString>;
697
- }, z.core.$strip>;
698
- declare const ActorQuerySchema: z.ZodUnion<readonly [z.ZodObject<{
699
- getForId: z.ZodObject<{
700
- name: z.ZodString;
701
- actorId: z.ZodString;
702
- }, z.core.$strip>;
703
- }, z.core.$strip>, z.ZodObject<{
704
- getForKey: z.ZodObject<{
705
- name: z.ZodString;
706
- key: z.ZodArray<z.ZodString>;
707
- }, z.core.$strip>;
708
- }, z.core.$strip>, z.ZodObject<{
709
- getOrCreateForKey: z.ZodObject<{
710
- name: z.ZodString;
711
- key: z.ZodArray<z.ZodString>;
712
- input: z.ZodOptional<z.ZodUnknown>;
713
- region: z.ZodOptional<z.ZodString>;
714
- }, z.core.$strip>;
715
- }, z.core.$strip>, z.ZodObject<{
716
- create: z.ZodObject<{
717
- name: z.ZodString;
718
- key: z.ZodArray<z.ZodString>;
719
- input: z.ZodOptional<z.ZodUnknown>;
720
- region: z.ZodOptional<z.ZodString>;
721
- }, z.core.$strip>;
722
- }, z.core.$strip>]>;
723
- type ActorQuery = z.infer<typeof ActorQuerySchema>;
750
+ declare const ActorKeySchema: z$1.ZodArray<z$1.ZodString>;
751
+ type ActorKey = z$1.infer<typeof ActorKeySchema>;
752
+ declare const CreateRequestSchema: z$1.ZodObject<{
753
+ name: z$1.ZodString;
754
+ key: z$1.ZodArray<z$1.ZodString>;
755
+ input: z$1.ZodOptional<z$1.ZodUnknown>;
756
+ region: z$1.ZodOptional<z$1.ZodString>;
757
+ }, z$1.core.$strip>;
758
+ declare const ActorQuerySchema: z$1.ZodUnion<readonly [z$1.ZodObject<{
759
+ getForId: z$1.ZodObject<{
760
+ name: z$1.ZodString;
761
+ actorId: z$1.ZodString;
762
+ }, z$1.core.$strip>;
763
+ }, z$1.core.$strip>, z$1.ZodObject<{
764
+ getForKey: z$1.ZodObject<{
765
+ name: z$1.ZodString;
766
+ key: z$1.ZodArray<z$1.ZodString>;
767
+ }, z$1.core.$strip>;
768
+ }, z$1.core.$strip>, z$1.ZodObject<{
769
+ getOrCreateForKey: z$1.ZodObject<{
770
+ name: z$1.ZodString;
771
+ key: z$1.ZodArray<z$1.ZodString>;
772
+ input: z$1.ZodOptional<z$1.ZodUnknown>;
773
+ region: z$1.ZodOptional<z$1.ZodString>;
774
+ }, z$1.core.$strip>;
775
+ }, z$1.core.$strip>, z$1.ZodObject<{
776
+ create: z$1.ZodObject<{
777
+ name: z$1.ZodString;
778
+ key: z$1.ZodArray<z$1.ZodString>;
779
+ input: z$1.ZodOptional<z$1.ZodUnknown>;
780
+ region: z$1.ZodOptional<z$1.ZodString>;
781
+ }, z$1.core.$strip>;
782
+ }, z$1.core.$strip>]>;
783
+ type ActorQuery = z$1.infer<typeof ActorQuerySchema>;
724
784
  /**
725
785
  * Interface representing a request to create a actor.
726
786
  */
727
- type CreateRequest = z.infer<typeof CreateRequestSchema>;
787
+ type CreateRequest = z$1.infer<typeof CreateRequestSchema>;
728
788
 
729
789
  /**
730
790
  * Action function returned by Actor connections and handles.
@@ -739,7 +799,7 @@ type ActorActionFunction<Args extends Array<unknown> = unknown[], Response = unk
739
799
  /**
740
800
  * Maps action methods from actor definition to typed function signatures.
741
801
  */
742
- type ActorDefinitionActions<AD extends AnyActorDefinition> = AD extends ActorDefinition<any, any, any, any, any, any, infer R> ? {
802
+ type ActorDefinitionActions<AD extends AnyActorDefinition> = AD extends ActorDefinition<any, any, any, any, any, any, any, any, infer R> ? {
743
803
  [K in keyof R]: R[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Return> : never;
744
804
  } : never;
745
805
 
@@ -764,6 +824,21 @@ declare class ActorConnDisposed extends ActorClientError {
764
824
  constructor();
765
825
  }
766
826
 
827
+ interface QueueSendWaitOptions {
828
+ wait: true;
829
+ timeout?: number;
830
+ signal?: AbortSignal;
831
+ }
832
+ interface QueueSendNoWaitOptions {
833
+ wait?: false;
834
+ timeout?: never;
835
+ signal?: AbortSignal;
836
+ }
837
+ interface QueueSendResult {
838
+ status: "completed" | "timedOut";
839
+ response?: unknown;
840
+ }
841
+
767
842
  /**
768
843
  * Connection status for an actor connection.
769
844
  *
@@ -813,6 +888,8 @@ declare class ActorConnRaw {
813
888
  * @protected
814
889
  */
815
890
  constructor(client: ClientRaw, driver: ManagerDriver, params: unknown, encoding: Encoding, actorQuery: ActorQuery);
891
+ send(name: string, body: unknown, options: QueueSendWaitOptions): Promise<QueueSendResult>;
892
+ send(name: string, body: unknown, options?: QueueSendNoWaitOptions): Promise<void>;
816
893
  /**
817
894
  * Call a raw action connection. See {@link ActorConn} for type-safe action calls.
818
895
  *
@@ -830,7 +907,6 @@ declare class ActorConnRaw {
830
907
  }): Promise<Response>;
831
908
  /**
832
909
  * Do not call this directly.
833
- enc
834
910
  * Establishes a connection to the server using the specified endpoint & encoding & driver.
835
911
  *
836
912
  * @protected
@@ -944,6 +1020,8 @@ declare class ActorHandleRaw {
944
1020
  * @protected
945
1021
  */
946
1022
  constructor(client: any, driver: ManagerDriver, params: unknown, encoding: Encoding, actorQuery: ActorQuery);
1023
+ send(name: string, body: unknown, options: QueueSendWaitOptions): Promise<QueueSendResult>;
1024
+ send(name: string, body: unknown, options?: QueueSendNoWaitOptions): Promise<void>;
947
1025
  /**
948
1026
  * Call a raw action. This method sends an HTTP request to invoke the named action.
949
1027
  *
@@ -964,27 +1042,18 @@ declare class ActorHandleRaw {
964
1042
  */
965
1043
  connect(): ActorConn<AnyActorDefinition>;
966
1044
  /**
967
- * Makes a raw HTTP request to the actor.
968
- *
969
- * @param input - The URL, path, or Request object
970
- * @param init - Standard fetch RequestInit options
971
- * @returns Promise<Response> - The raw HTTP response
1045
+ * Fetches a resource from this actor via the /request endpoint. This is a
1046
+ * convenience wrapper around the raw HTTP API.
972
1047
  */
973
1048
  fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
974
1049
  /**
975
- * Creates a raw WebSocket connection to the actor.
976
- *
977
- * @param path - The path for the WebSocket connection (e.g., "stream")
978
- * @param protocols - Optional WebSocket subprotocols
979
- * @returns WebSocket - A raw WebSocket connection
1050
+ * Opens a raw WebSocket connection to this actor.
980
1051
  */
981
- websocket(path?: string, protocols?: string | string[]): Promise<WebSocket>;
1052
+ webSocket(path?: string, protocols?: string | string[]): Promise<any>;
982
1053
  /**
983
1054
  * Resolves the actor to get its unique actor ID.
984
1055
  */
985
- resolve({ signal }?: {
986
- signal?: AbortSignal;
987
- }): Promise<string>;
1056
+ resolve(): Promise<string>;
988
1057
  /**
989
1058
  * Returns the raw URL for routing traffic to the actor.
990
1059
  */
@@ -1203,32 +1272,9 @@ declare function createClientWithDriver<A extends Registry<any>>(driver: Manager
1203
1272
  interface ActorInspectorEmitterEvents {
1204
1273
  stateUpdated: (state: unknown) => void;
1205
1274
  connectionsUpdated: () => void;
1206
- eventFired: (event: EventDetails) => void;
1207
- eventsChanged: () => void;
1275
+ queueUpdated: () => void;
1276
+ workflowHistoryUpdated: (history: WorkflowHistory) => void;
1208
1277
  }
1209
- type EventDetails = {
1210
- type: "action";
1211
- name: string;
1212
- args: unknown[];
1213
- connId: string;
1214
- } | {
1215
- type: "subscribe";
1216
- eventName: string;
1217
- connId: string;
1218
- } | {
1219
- type: "unsubscribe";
1220
- eventName: string;
1221
- connId: string;
1222
- } | {
1223
- type: "event";
1224
- eventName: string;
1225
- args: unknown[];
1226
- connId: string;
1227
- } | {
1228
- type: "broadcast";
1229
- eventName: string;
1230
- args: unknown[];
1231
- };
1232
1278
  /**
1233
1279
  * Provides a unified interface for inspecting actor external and internal state.
1234
1280
  */
@@ -1237,9 +1283,14 @@ declare class ActorInspector {
1237
1283
  private readonly actor;
1238
1284
  readonly emitter: nanoevents.Emitter<ActorInspectorEmitterEvents>;
1239
1285
  constructor(actor: AnyActorInstance);
1240
- getLastEvents(): Event[];
1241
- clearEvents(): void;
1286
+ getQueueSize(): number;
1287
+ getQueueStatus(limit: number): Promise<QueueStatus>;
1288
+ updateQueueSize(size: number): void;
1289
+ isWorkflowEnabled(): boolean;
1290
+ getWorkflowHistory(): WorkflowHistory | null;
1242
1291
  isDatabaseEnabled(): boolean;
1292
+ getDatabaseSchema(): Promise<ArrayBuffer>;
1293
+ getDatabaseTableRows(table: string, limit: number, offset: number): Promise<ArrayBuffer>;
1243
1294
  isStateEnabled(): boolean;
1244
1295
  getState(): ArrayBuffer;
1245
1296
  getRpcs(): string[];
@@ -1250,6 +1301,35 @@ declare class ActorInspector {
1250
1301
  }[];
1251
1302
  setState(state: ArrayBuffer): Promise<void>;
1252
1303
  executeAction(name: string, params: ArrayBuffer): Promise<ArrayBuffer>;
1304
+ getStateJson(): unknown;
1305
+ setStateJson(state: unknown): Promise<void>;
1306
+ getConnectionsJson(): {
1307
+ id: string;
1308
+ details: unknown;
1309
+ }[];
1310
+ executeActionJson(name: string, args: unknown[]): Promise<unknown>;
1311
+ getTracesJson(options: {
1312
+ startMs: number;
1313
+ endMs: number;
1314
+ limit: number;
1315
+ }): Promise<{
1316
+ otlp: unknown;
1317
+ clamped: boolean;
1318
+ }>;
1319
+ getWorkflowHistoryJson(): {
1320
+ history: unknown | null;
1321
+ isWorkflowEnabled: boolean;
1322
+ };
1323
+ getQueueStatusJson(limit: number): Promise<{
1324
+ size: number;
1325
+ maxSize: number;
1326
+ truncated: boolean;
1327
+ messages: {
1328
+ id: number;
1329
+ name: string;
1330
+ createdAtMs: number;
1331
+ }[];
1332
+ }>;
1253
1333
  }
1254
1334
 
1255
1335
  /**
@@ -1307,6 +1387,95 @@ declare class ActorKv {
1307
1387
  list<T extends KvValueType = "text", K extends KvKeyType = "text">(prefix: KvKeyTypeMap[K], options?: KvListOptions<T, K>): Promise<[KvKeyTypeMap[K], KvValueTypeMap[T]][]>;
1308
1388
  }
1309
1389
 
1390
+ interface QueueMessage {
1391
+ id: bigint;
1392
+ name: string;
1393
+ body: unknown;
1394
+ createdAt: number;
1395
+ }
1396
+ declare class QueueManager<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>> {
1397
+ #private;
1398
+ constructor(actor: ActorInstance<S, CP, CS, V, I, DB, E, Q>, driver: ActorDriver);
1399
+ /** Returns the current number of messages in the queue. */
1400
+ get size(): number;
1401
+ /** Loads queue metadata from storage and initializes internal state. */
1402
+ initialize(): Promise<void>;
1403
+ /** Adds a message to the queue with the given name and body. */
1404
+ enqueue(name: string, body: unknown): Promise<QueueMessage>;
1405
+ /**
1406
+ * Adds a message and waits for completion.
1407
+ */
1408
+ enqueueAndWait(name: string, body: unknown, timeout?: number): Promise<{
1409
+ status: "completed" | "timedOut";
1410
+ response?: unknown;
1411
+ }>;
1412
+ completeMessage(message: QueueMessage, response?: unknown): Promise<void>;
1413
+ completeMessageById(messageId: bigint, response?: unknown): Promise<void>;
1414
+ /** Receives messages from the queue matching the given names. Waits until messages are available or timeout is reached. */
1415
+ receive(names: string[] | undefined, count: number, timeout?: number, abortSignal?: AbortSignal, completable?: boolean): Promise<QueueMessage[]>;
1416
+ waitForNames(names: readonly string[] | undefined, abortSignal?: AbortSignal): Promise<void>;
1417
+ /** Returns all messages currently in the queue without removing them. */
1418
+ getMessages(): Promise<QueueMessage[]>;
1419
+ /** Deletes messages matching the provided IDs. Returns the IDs that were removed. */
1420
+ deleteMessagesById(ids: bigint[]): Promise<bigint[]>;
1421
+ }
1422
+
1423
+ type QueueMessageOf<Name extends string, Body> = Omit<QueueMessage, "name" | "body"> & {
1424
+ name: Name;
1425
+ body: Body;
1426
+ };
1427
+ type QueueName<TQueues extends QueueSchemaConfig> = keyof TQueues & string;
1428
+ type QueueFilterName<TQueues extends QueueSchemaConfig> = keyof TQueues extends never ? string : QueueName<TQueues>;
1429
+ type QueueMessageForName<TQueues extends QueueSchemaConfig, TName extends QueueFilterName<TQueues>> = keyof TQueues extends never ? QueueMessage : TName extends QueueName<TQueues> ? QueueMessageOf<TName, InferSchemaMap<TQueues>[TName]> : never;
1430
+ type QueueCompleteArgs<T> = undefined extends T ? [response?: T] : [response: T];
1431
+ type QueueCompleteArgsForName<TQueues extends QueueSchemaConfig, TName extends QueueFilterName<TQueues>> = keyof TQueues extends never ? [response?: unknown] : TName extends QueueName<TQueues> ? [InferQueueCompleteMap<TQueues>[TName]] extends [never] ? [response?: unknown] : QueueCompleteArgs<InferQueueCompleteMap<TQueues>[TName]> : [response?: unknown];
1432
+ type QueueCompletableMessageForName<TQueues extends QueueSchemaConfig, TName extends QueueFilterName<TQueues>> = QueueMessageForName<TQueues, TName> & {
1433
+ complete(...args: QueueCompleteArgsForName<TQueues, TName>): Promise<void>;
1434
+ };
1435
+ type QueueResultMessageForName<TQueues extends QueueSchemaConfig, TName extends QueueFilterName<TQueues>, TCompletable extends boolean> = TCompletable extends true ? QueueCompletableMessageForName<TQueues, TName> : QueueMessageForName<TQueues, TName>;
1436
+ /** Options for receiving queue messages. */
1437
+ interface QueueNextOptions<TName extends string = string, TCompletable extends boolean = boolean> {
1438
+ /** Queue names to receive from. If omitted, reads from all queue names. */
1439
+ names?: readonly TName[];
1440
+ /** Maximum number of messages to receive. Defaults to 1. */
1441
+ count?: number;
1442
+ /** Timeout in milliseconds. Omit to wait indefinitely. */
1443
+ timeout?: number;
1444
+ /** Optional abort signal for this receive call. */
1445
+ signal?: AbortSignal;
1446
+ /** Whether to return completable messages. */
1447
+ completable?: TCompletable;
1448
+ }
1449
+ /** Options for non-blocking queue reads. */
1450
+ interface QueueTryNextOptions<TName extends string = string, TCompletable extends boolean = boolean> {
1451
+ /** Queue names to receive from. If omitted, reads from all queue names. */
1452
+ names?: readonly TName[];
1453
+ /** Maximum number of messages to receive. Defaults to 1. */
1454
+ count?: number;
1455
+ /** Whether to return completable messages. */
1456
+ completable?: TCompletable;
1457
+ }
1458
+ /** Options for queue async iteration. */
1459
+ interface QueueIterOptions<TName extends string = string, TCompletable extends boolean = boolean> {
1460
+ /** Queue names to receive from. If omitted, reads from all queue names. */
1461
+ names?: readonly TName[];
1462
+ /** Optional abort signal for this iterator. */
1463
+ signal?: AbortSignal;
1464
+ /** Whether to return completable messages. */
1465
+ completable?: TCompletable;
1466
+ }
1467
+ /** User-facing queue interface exposed on ActorContext. */
1468
+ declare class ActorQueue<S, CP, CS, V, I, DB extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
1469
+ #private;
1470
+ constructor(queueManager: QueueManager<S, CP, CS, V, I, DB, TEvents, TQueues>, abortSignal: AbortSignal);
1471
+ next<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueNextOptions<TName, TCompletable>): Promise<Array<QueueResultMessageForName<TQueues, TName, TCompletable>>>;
1472
+ tryNext<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueTryNextOptions<TName, TCompletable>): Promise<Array<QueueResultMessageForName<TQueues, TName, TCompletable>>>;
1473
+ iter<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueIterOptions<TName, TCompletable>): AsyncIterableIterator<QueueResultMessageForName<TQueues, TName, TCompletable>>;
1474
+ /** Sends a message to the specified queue. */
1475
+ send<K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K]): Promise<QueueMessage>;
1476
+ send(name: keyof TQueues extends never ? string : never, body: unknown): Promise<QueueMessage>;
1477
+ }
1478
+
1310
1479
  declare class Schedule {
1311
1480
  #private;
1312
1481
  constructor(actor: AnyActorInstance);
@@ -1314,12 +1483,14 @@ declare class Schedule {
1314
1483
  at(timestamp: number, fn: string, ...args: unknown[]): Promise<void>;
1315
1484
  }
1316
1485
 
1486
+ declare const ACTOR_CONTEXT_INTERNAL_SYMBOL: unique symbol;
1317
1487
  /**
1318
1488
  * ActorContext class that provides access to actor methods and state
1319
1489
  */
1320
- declare class ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> {
1490
+ declare class ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
1321
1491
  #private;
1322
- constructor(actor: ActorInstance<TState, TConnParams, TConnState, TVars, TInput, TDatabase>);
1492
+ [ACTOR_CONTEXT_INTERNAL_SYMBOL]: AnyActorInstance;
1493
+ constructor(actor: ActorInstance<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>);
1323
1494
  /**
1324
1495
  * Gets the KV storage interface.
1325
1496
  */
@@ -1344,11 +1515,16 @@ declare class ActorContext<TState, TConnParams, TConnState, TVars, TInput, TData
1344
1515
  * @param name - The name of the event.
1345
1516
  * @param args - The arguments to send with the event.
1346
1517
  */
1347
- broadcast<Args extends Array<unknown>>(name: string, ...args: Args): void;
1518
+ broadcast<K extends keyof TEvents & string>(name: K, ...args: InferEventArgs<InferSchemaMap<TEvents>[K]>): void;
1519
+ broadcast(name: keyof TEvents extends never ? string : never, ...args: Array<unknown>): void;
1348
1520
  /**
1349
1521
  * Gets the logger instance.
1350
1522
  */
1351
1523
  get log(): Logger;
1524
+ /**
1525
+ * Access to queue receive helpers.
1526
+ */
1527
+ get queue(): ActorQueue<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
1352
1528
  /**
1353
1529
  * Gets actor ID.
1354
1530
  */
@@ -1372,7 +1548,7 @@ declare class ActorContext<TState, TConnParams, TConnState, TVars, TInput, TData
1372
1548
  /**
1373
1549
  * Gets the map of connections.
1374
1550
  */
1375
- get conns(): Map<ConnId, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>>;
1551
+ get conns(): Map<ConnId, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>;
1376
1552
  /**
1377
1553
  * Returns the client for the given registry.
1378
1554
  */
@@ -1396,10 +1572,26 @@ declare class ActorContext<TState, TConnParams, TConnState, TVars, TInput, TData
1396
1572
  * Prevents the actor from sleeping until promise is complete.
1397
1573
  */
1398
1574
  waitUntil(promise: Promise<void>): void;
1575
+ /**
1576
+ * Prevents the actor from sleeping while the given promise is running.
1577
+ *
1578
+ * Use this when performing async operations in the `run` handler or other
1579
+ * background contexts where you need to ensure the actor stays awake.
1580
+ *
1581
+ * Returns the resolved value and resets the sleep timer on completion.
1582
+ * Errors are propagated to the caller.
1583
+ */
1584
+ keepAwake<T>(promise: Promise<T>): Promise<T>;
1399
1585
  /**
1400
1586
  * AbortSignal that fires when the actor is stopping.
1401
1587
  */
1402
1588
  get abortSignal(): AbortSignal;
1589
+ /**
1590
+ * True when the actor is stopping.
1591
+ *
1592
+ * Alias for `c.abortSignal.aborted`.
1593
+ */
1594
+ get aborted(): boolean;
1403
1595
  /**
1404
1596
  * Forces the actor to sleep.
1405
1597
  *
@@ -1417,141 +1609,153 @@ declare class ActorContext<TState, TConnParams, TConnState, TVars, TInput, TData
1417
1609
  */
1418
1610
  destroy(): void;
1419
1611
  }
1420
- type ActorContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? ActorContext<S, CP, CS, V, I, DB> : never;
1612
+ type ActorContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? ActorContext<S, CP, CS, V, I, DB, E, Q> : never;
1421
1613
 
1422
1614
  /**
1423
1615
  * Base context for connection-based handlers.
1424
1616
  * Extends ActorContext with connection-specific functionality.
1425
1617
  */
1426
- declare abstract class ConnContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> extends ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase> {
1427
- readonly conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>;
1618
+ declare abstract class ConnContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
1619
+ readonly conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
1428
1620
  }
1429
- type ConnContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? ConnContext<S, CP, CS, V, I, DB> : never;
1621
+ type ConnContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? ConnContext<S, CP, CS, V, I, DB, E, Q> : never;
1622
+
1623
+ /**
1624
+ * Context for a remote procedure call.
1625
+ */
1626
+ declare class ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ConnContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
1627
+ }
1628
+ /**
1629
+ * Extracts the ActionContext type from an ActorDefinition.
1630
+ */
1631
+ type ActionContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? ActionContext<S, CP, CS, V, I, DB, E, Q> : never;
1430
1632
 
1431
1633
  /**
1432
1634
  * Base context for connection initialization handlers.
1433
1635
  * Extends ActorContext with request-specific functionality for connection lifecycle events.
1434
1636
  */
1435
- declare abstract class ConnInitContext<TState, TVars, TInput, TDatabase extends AnyDatabaseProvider> extends ActorContext<TState, never, never, TVars, TInput, TDatabase> {
1637
+ declare abstract class ConnInitContext<TState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ActorContext<TState, never, never, TVars, TInput, TDatabase, TEvents, TQueues> {
1436
1638
  /**
1437
1639
  * The incoming request that initiated the connection.
1438
1640
  * May be undefined for connections initiated without a direct HTTP request.
1439
1641
  */
1440
1642
  readonly request: Request | undefined;
1441
1643
  }
1442
- type ConnInitContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, any, any, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? ConnInitContext<S, V, I, DB> : never;
1443
-
1444
- /**
1445
- * Context for a remote procedure call.
1446
- */
1447
- declare class ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> extends ConnContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase> {
1448
- }
1449
- /**
1450
- * Extracts the ActionContext type from an ActorDefinition.
1451
- */
1452
- type ActionContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? ActionContext<S, CP, CS, V, I, DB> : never;
1644
+ type ConnInitContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, any, any, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? ConnInitContext<S, V, I, DB, E, Q> : never;
1453
1645
 
1454
1646
  /**
1455
1647
  * Context for the onBeforeActionResponse lifecycle hook.
1456
1648
  */
1457
- declare class BeforeActionResponseContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> extends ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase> {
1649
+ declare class BeforeActionResponseContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
1458
1650
  }
1459
- type BeforeActionResponseContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? BeforeActionResponseContext<S, CP, CS, V, I, DB> : never;
1651
+ type BeforeActionResponseContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? BeforeActionResponseContext<S, CP, CS, V, I, DB, E, Q> : never;
1460
1652
 
1461
1653
  /**
1462
1654
  * Context for the onBeforeConnect lifecycle hook.
1463
1655
  */
1464
- declare class BeforeConnectContext<TState, TVars, TInput, TDatabase extends AnyDatabaseProvider> extends ConnInitContext<TState, TVars, TInput, TDatabase> {
1656
+ declare class BeforeConnectContext<TState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ConnInitContext<TState, TVars, TInput, TDatabase, TEvents, TQueues> {
1465
1657
  }
1466
- type BeforeConnectContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, any, any, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? BeforeConnectContext<S, V, I, DB> : never;
1658
+ type BeforeConnectContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, any, any, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? BeforeConnectContext<S, V, I, DB, E, Q> : never;
1467
1659
 
1468
1660
  /**
1469
1661
  * Context for the onConnect lifecycle hook.
1470
1662
  */
1471
- declare class ConnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> extends ConnContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase> {
1663
+ declare class ConnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ConnContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
1472
1664
  }
1473
- type ConnectContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? ConnectContext<S, CP, CS, V, I, DB> : never;
1665
+ type ConnectContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? ConnectContext<S, CP, CS, V, I, DB, E, Q> : never;
1474
1666
 
1475
1667
  /**
1476
1668
  * Context for the onCreate lifecycle hook.
1477
1669
  */
1478
- declare class CreateContext<TState, TInput, TDatabase extends AnyDatabaseProvider> extends ActorContext<TState, never, never, never, TInput, TDatabase> {
1670
+ declare class CreateContext<TState, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ActorContext<TState, never, never, never, TInput, TDatabase, TEvents, TQueues> {
1479
1671
  }
1480
- type CreateContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, any, any, any, infer I, infer DB extends AnyDatabaseProvider, any> ? CreateContext<S, I, DB> : never;
1672
+ type CreateContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, any, any, any, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? CreateContext<S, I, DB, E, Q> : never;
1481
1673
 
1482
1674
  /**
1483
1675
  * Context for the createConnState lifecycle hook.
1484
1676
  * Called to initialize connection-specific state when a connection is created.
1485
1677
  */
1486
- declare class CreateConnStateContext<TState, TVars, TInput, TDatabase extends AnyDatabaseProvider> extends ConnInitContext<TState, TVars, TInput, TDatabase> {
1678
+ declare class CreateConnStateContext<TState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ConnInitContext<TState, TVars, TInput, TDatabase, TEvents, TQueues> {
1487
1679
  }
1488
- type CreateConnStateContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, any, any, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? CreateConnStateContext<S, V, I, DB> : never;
1680
+ type CreateConnStateContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, any, any, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? CreateConnStateContext<S, V, I, DB, E, Q> : never;
1489
1681
 
1490
1682
  /**
1491
1683
  * Context for the createVars lifecycle hook.
1492
1684
  */
1493
- declare class CreateVarsContext<TState, TInput, TDatabase extends AnyDatabaseProvider> extends ActorContext<TState, never, never, never, TInput, TDatabase> {
1685
+ declare class CreateVarsContext<TState, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ActorContext<TState, never, never, never, TInput, TDatabase, TEvents, TQueues> {
1494
1686
  }
1495
- type CreateVarsContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, any, any, any, infer I, infer DB extends AnyDatabaseProvider, any> ? CreateVarsContext<S, I, DB> : never;
1687
+ type CreateVarsContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, any, any, any, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? CreateVarsContext<S, I, DB, E, Q> : never;
1496
1688
 
1497
1689
  /**
1498
1690
  * Context for the onDestroy lifecycle hook.
1499
1691
  */
1500
- declare class DestroyContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> extends ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase> {
1692
+ declare class DestroyContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
1501
1693
  }
1502
- type DestroyContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? DestroyContext<S, CP, CS, V, I, DB> : never;
1694
+ type DestroyContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? DestroyContext<S, CP, CS, V, I, DB, E, Q> : never;
1503
1695
 
1504
1696
  /**
1505
1697
  * Context for the onDisconnect lifecycle hook.
1506
1698
  */
1507
- declare class DisconnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> extends ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase> {
1699
+ declare class DisconnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
1508
1700
  }
1509
- type DisconnectContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? DisconnectContext<S, CP, CS, V, I, DB> : never;
1701
+ type DisconnectContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? DisconnectContext<S, CP, CS, V, I, DB, E, Q> : never;
1510
1702
 
1511
1703
  /**
1512
1704
  * Context for raw HTTP request handlers (onRequest).
1513
1705
  */
1514
- declare class RequestContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> extends ConnContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase> {
1706
+ declare class RequestContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ConnContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
1515
1707
  /**
1516
1708
  * The incoming HTTP request.
1517
1709
  * May be undefined for request contexts initiated without a direct HTTP request.
1518
1710
  */
1519
1711
  readonly request: Request | undefined;
1520
1712
  }
1521
- type RequestContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? RequestContext<S, CP, CS, V, I, DB> : never;
1713
+ type RequestContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? RequestContext<S, CP, CS, V, I, DB, E, Q> : never;
1714
+
1715
+ /**
1716
+ * Context for the run lifecycle hook.
1717
+ *
1718
+ * This context is passed to the `run` handler which executes after the actor
1719
+ * starts. It does not block actor startup and is intended for background tasks.
1720
+ *
1721
+ * Use `c.aborted` to detect when the actor is stopping and gracefully exit.
1722
+ */
1723
+ declare class RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
1724
+ }
1725
+ type RunContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? RunContext<S, CP, CS, V, I, DB, E, Q> : never;
1522
1726
 
1523
1727
  /**
1524
1728
  * Context for the onSleep lifecycle hook.
1525
1729
  */
1526
- declare class SleepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> extends ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase> {
1730
+ declare class SleepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
1527
1731
  }
1528
- type SleepContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? SleepContext<S, CP, CS, V, I, DB> : never;
1732
+ type SleepContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? SleepContext<S, CP, CS, V, I, DB, E, Q> : never;
1529
1733
 
1530
1734
  /**
1531
1735
  * Context for the onStateChange lifecycle hook.
1532
1736
  */
1533
- declare class StateChangeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> extends ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase> {
1737
+ declare class StateChangeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
1534
1738
  }
1535
- type StateChangeContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? StateChangeContext<S, CP, CS, V, I, DB> : never;
1739
+ type StateChangeContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? StateChangeContext<S, CP, CS, V, I, DB, E, Q> : never;
1536
1740
 
1537
1741
  /**
1538
1742
  * Context for the onWake lifecycle hook.
1539
1743
  */
1540
- declare class WakeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> extends ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase> {
1744
+ declare class WakeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
1541
1745
  }
1542
- type WakeContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? WakeContext<S, CP, CS, V, I, DB> : never;
1746
+ type WakeContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? WakeContext<S, CP, CS, V, I, DB, E, Q> : never;
1543
1747
 
1544
1748
  /**
1545
1749
  * Context for raw WebSocket handlers (onWebSocket).
1546
1750
  */
1547
- declare class WebSocketContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> extends ConnContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase> {
1751
+ declare class WebSocketContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ConnContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
1548
1752
  /**
1549
1753
  * The incoming HTTP request that initiated the WebSocket upgrade.
1550
1754
  * May be undefined for WebSocket connections initiated without a direct HTTP request.
1551
1755
  */
1552
1756
  readonly request: Request | undefined;
1553
1757
  }
1554
- type WebSocketContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? WebSocketContext<S, CP, CS, V, I, DB> : never;
1758
+ type WebSocketContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? WebSocketContext<S, CP, CS, V, I, DB, E, Q> : never;
1555
1759
 
1556
1760
  declare enum DriverReadyState {
1557
1761
  UNKNOWN = -1,
@@ -1625,18 +1829,19 @@ interface PersistedConn<CP, CS> {
1625
1829
  * Manages all connection-related operations for an actor instance.
1626
1830
  * Handles connection creation, tracking, hibernation, and cleanup.
1627
1831
  */
1628
- declare class ConnectionManager<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
1832
+ declare class ConnectionManager<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>> {
1629
1833
  #private;
1630
- constructor(actor: ActorInstance<S, CP, CS, V, I, DB>);
1631
- get connections(): Map<ConnId, Conn<S, CP, CS, V, I, DB>>;
1632
- getConnForId(id: string): Conn<S, CP, CS, V, I, DB> | undefined;
1834
+ constructor(actor: ActorInstance<S, CP, CS, V, I, DB, E, Q>);
1835
+ get connections(): Map<ConnId, Conn<S, CP, CS, V, I, DB, E, Q>>;
1836
+ getConnForId(id: string): Conn<S, CP, CS, V, I, DB, E, Q> | undefined;
1633
1837
  get connsWithPersistChanged(): Set<ConnId>;
1838
+ get pendingDisconnectCount(): number;
1634
1839
  clearConnWithPersistChanged(): void;
1635
- markConnWithPersistChanged(conn: Conn<S, CP, CS, V, I, DB>): void;
1840
+ markConnWithPersistChanged(conn: Conn<S, CP, CS, V, I, DB, E, Q>): void;
1636
1841
  /**
1637
1842
  * Handles pre-connection logic (i.e. auth & create state) before actually connecting the connection.
1638
1843
  */
1639
- prepareConn(driver: ConnDriver, params: CP, request: Request | undefined, requestPath: string | undefined, requestHeaders: Record<string, string> | undefined, isHibernatable: boolean, isRestoringHibernatable: boolean): Promise<Conn<S, CP, CS, V, I, DB>>;
1844
+ prepareConn(driver: ConnDriver, params: CP, request: Request | undefined, requestPath: string | undefined, requestHeaders: Record<string, string> | undefined, isHibernatable: boolean, isRestoringHibernatable: boolean): Promise<Conn<S, CP, CS, V, I, DB, E, Q>>;
1640
1845
  /**
1641
1846
  * Adds a connection form prepareConn to the actor and calls onConnect.
1642
1847
  *
@@ -1645,31 +1850,32 @@ declare class ConnectionManager<S, CP, CS, V, I, DB extends AnyDatabaseProvider>
1645
1850
  * be messed up and cause race conditions that can drop WebSocket messages.
1646
1851
  * So all async work in prepareConn.
1647
1852
  */
1648
- connectConn(conn: Conn<S, CP, CS, V, I, DB>): void;
1853
+ connectConn(conn: Conn<S, CP, CS, V, I, DB, E, Q>): void;
1649
1854
  /**
1650
1855
  * Handle connection disconnection.
1651
1856
  *
1652
1857
  * This is called by `Conn.disconnect`. This should not call `Conn.disconnect.`
1653
1858
  */
1654
- connDisconnected(conn: Conn<S, CP, CS, V, I, DB>): Promise<void>;
1859
+ connDisconnected(conn: Conn<S, CP, CS, V, I, DB, E, Q>): Promise<void>;
1860
+ cleanupPersistedHibernatableConnections(reason?: string): Promise<number>;
1655
1861
  /**
1656
1862
  * Utilify function for call sites that don't need a separate prepare and connect phase.
1657
1863
  */
1658
- prepareAndConnectConn(driver: ConnDriver, params: CP, request: Request | undefined, requestPath: string | undefined, requestHeaders: Record<string, string> | undefined): Promise<Conn<S, CP, CS, V, I, DB>>;
1864
+ prepareAndConnectConn(driver: ConnDriver, params: CP, request: Request | undefined, requestPath: string | undefined, requestHeaders: Record<string, string> | undefined): Promise<Conn<S, CP, CS, V, I, DB, E, Q>>;
1659
1865
  /**
1660
1866
  * Restores connections from persisted data during actor initialization.
1661
1867
  */
1662
1868
  restoreConnections(connections: PersistedConn<CP, CS>[]): void;
1663
- findHibernatableConn(gatewayIdBuf: ArrayBuffer, requestIdBuf: ArrayBuffer): Conn<S, CP, CS, V, I, DB> | undefined;
1869
+ findHibernatableConn(gatewayIdBuf: ArrayBuffer, requestIdBuf: ArrayBuffer): Conn<S, CP, CS, V, I, DB, E, Q> | undefined;
1664
1870
  }
1665
1871
 
1666
1872
  /**
1667
1873
  * Manages event subscriptions and broadcasting for actor instances.
1668
1874
  * Handles subscription tracking and efficient message distribution to connected clients.
1669
1875
  */
1670
- declare class EventManager<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
1876
+ declare class EventManager<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>> {
1671
1877
  #private;
1672
- constructor(actor: ActorInstance<S, CP, CS, V, I, DB>);
1878
+ constructor(actor: ActorInstance<S, CP, CS, V, I, DB, E, Q>);
1673
1879
  /**
1674
1880
  * Adds a subscription for a connection to an event.
1675
1881
  *
@@ -1677,7 +1883,7 @@ declare class EventManager<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
1677
1883
  * @param connection - The connection subscribing to the event
1678
1884
  * @param fromPersist - Whether this subscription is being restored from persistence
1679
1885
  */
1680
- addSubscription(eventName: string, connection: Conn<S, CP, CS, V, I, DB>, fromPersist: boolean): void;
1886
+ addSubscription(eventName: string, connection: Conn<S, CP, CS, V, I, DB, E, Q>, fromPersist: boolean): void;
1681
1887
  /**
1682
1888
  * Removes a subscription for a connection from an event.
1683
1889
  *
@@ -1685,7 +1891,7 @@ declare class EventManager<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
1685
1891
  * @param connection - The connection unsubscribing from the event
1686
1892
  * @param fromRemoveConn - Whether this is being called as part of connection removal
1687
1893
  */
1688
- removeSubscription(eventName: string, connection: Conn<S, CP, CS, V, I, DB>, fromRemoveConn: boolean): void;
1894
+ removeSubscription(eventName: string, connection: Conn<S, CP, CS, V, I, DB, E, Q>, fromRemoveConn: boolean): void;
1689
1895
  /**
1690
1896
  * Broadcasts an event to all subscribed connections.
1691
1897
  *
@@ -1699,7 +1905,7 @@ declare class EventManager<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
1699
1905
  * @param eventName - The name of the event
1700
1906
  * @returns Set of connections subscribed to the event, or undefined if no subscribers
1701
1907
  */
1702
- getSubscribers(eventName: string): Set<Conn<S, CP, CS, V, I, DB>> | undefined;
1908
+ getSubscribers(eventName: string): Set<Conn<S, CP, CS, V, I, DB, E, Q>> | undefined;
1703
1909
  /**
1704
1910
  * Gets all events and their subscriber counts.
1705
1911
  *
@@ -1712,7 +1918,7 @@ declare class EventManager<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
1712
1918
  *
1713
1919
  * @param connection - The connection to clear subscriptions for
1714
1920
  */
1715
- clearConnectionSubscriptions(connection: Conn<S, CP, CS, V, I, DB>): void;
1921
+ clearConnectionSubscriptions(connection: Conn<S, CP, CS, V, I, DB, E, Q>): void;
1716
1922
  /**
1717
1923
  * Gets the total number of unique events being subscribed to.
1718
1924
  */
@@ -1771,9 +1977,9 @@ interface SaveStateOptions {
1771
1977
  * Manages actor state persistence, proxying, and synchronization.
1772
1978
  * Handles automatic state change detection and throttled persistence to KV storage.
1773
1979
  */
1774
- declare class StateManager$1<S, CP, CS, I> {
1980
+ declare class StateManager$1<S, CP, CS, I, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>> {
1775
1981
  #private;
1776
- constructor(actor: ActorInstance<S, CP, CS, any, I, any>, actorDriver: ActorDriver, config: any);
1982
+ constructor(actor: ActorInstance<S, CP, CS, any, I, any, E, Q>, actorDriver: ActorDriver, config: any);
1777
1983
  get persist(): PersistedActor<S, I>;
1778
1984
  get persistRaw(): PersistedActor<S, I>;
1779
1985
  get persistChanged(): boolean;
@@ -1810,15 +2016,16 @@ declare class StateManager$1<S, CP, CS, I> {
1810
2016
  }
1811
2017
 
1812
2018
  /** Actor type alias with all `any` types. Used for `extends` in classes referencing this actor. */
1813
- type AnyActorInstance = ActorInstance<any, any, any, any, any, any>;
1814
- declare class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
2019
+ type AnyActorInstance = ActorInstance<any, any, any, any, any, any, any, any>;
2020
+ declare class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>> {
1815
2021
  #private;
1816
- actorContext: ActorContext<S, CP, CS, V, I, DB>;
2022
+ actorContext: ActorContext<S, CP, CS, V, I, DB, E, Q>;
1817
2023
  driver: ActorDriver;
1818
- connectionManager: ConnectionManager<S, CP, CS, V, I, DB>;
1819
- stateManager: StateManager$1<S, CP, CS, I>;
1820
- eventManager: EventManager<S, CP, CS, V, I, DB>;
1821
- constructor(config: ActorConfig<S, CP, CS, V, I, DB>);
2024
+ connectionManager: ConnectionManager<S, CP, CS, V, I, DB, E, Q>;
2025
+ stateManager: StateManager$1<S, CP, CS, I, E, Q>;
2026
+ eventManager: EventManager<S, CP, CS, V, I, DB, E, Q>;
2027
+ queueManager: QueueManager<S, CP, CS, V, I, DB, E, Q>;
2028
+ constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q>);
1822
2029
  get log(): Logger;
1823
2030
  get rLog(): Logger;
1824
2031
  get isStopping(): boolean;
@@ -1828,12 +2035,18 @@ declare class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
1828
2035
  get region(): string;
1829
2036
  get inlineClient(): Client<Registry<any>>;
1830
2037
  get inspector(): ActorInspector;
2038
+ get traces(): Traces<OtlpExportTraceServiceRequestJson>;
1831
2039
  get inspectorToken(): string | undefined;
1832
- get conns(): Map<ConnId, Conn<S, CP, CS, V, I, DB>>;
2040
+ getCurrentTraceSpan(): SpanHandle | null;
2041
+ startTraceSpan(name: string, attributes?: Record<string, unknown>): SpanHandle;
2042
+ endTraceSpan(handle: SpanHandle, status?: SpanStatusInput): void;
2043
+ runInTraceSpan<T>(name: string, attributes: Record<string, unknown> | undefined, fn: () => T | Promise<T>): Promise<T>;
2044
+ emitTraceEvent(name: string, attributes?: Record<string, unknown>, handle?: SpanHandle): void;
2045
+ get conns(): Map<ConnId, Conn<S, CP, CS, V, I, DB, E, Q>>;
1833
2046
  get schedule(): Schedule;
1834
2047
  get abortSignal(): AbortSignal;
1835
2048
  get actions(): string[];
1836
- get config(): ActorConfig<S, CP, CS, V, I, DB>;
2049
+ get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q>;
1837
2050
  get persist(): PersistedActor<S, I>;
1838
2051
  get state(): S;
1839
2052
  set state(value: S);
@@ -1844,6 +2057,7 @@ declare class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
1844
2057
  start(actorDriver: ActorDriver, inlineClient: Client<Registry<any>>, actorId: string, name: string, key: ActorKey, region: string): Promise<void>;
1845
2058
  isReady(): boolean;
1846
2059
  assertReady(allowStoppingState?: boolean): void;
2060
+ cleanupPersistedConnections(reason?: string): Promise<number>;
1847
2061
  onStop(mode: "sleep" | "destroy"): Promise<void>;
1848
2062
  startSleep(): void;
1849
2063
  startDestroy(): void;
@@ -1864,13 +2078,27 @@ declare class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
1864
2078
  subscribe: boolean;
1865
2079
  };
1866
2080
  };
1867
- }, conn: Conn<S, CP, CS, V, I, DB>): Promise<void>;
1868
- executeAction(ctx: ActionContext<S, CP, CS, V, I, DB>, actionName: string, args: unknown[]): Promise<unknown>;
1869
- handleRawRequest(conn: Conn<S, CP, CS, V, I, DB>, request: Request): Promise<Response>;
1870
- handleRawWebSocket(conn: Conn<S, CP, CS, V, I, DB>, websocket: UniversalWebSocket, request?: Request): void;
2081
+ }, conn: Conn<S, CP, CS, V, I, DB, E, Q>): Promise<void>;
2082
+ assertCanSubscribe(ctx: ActionContext<S, CP, CS, V, I, DB, E, Q>, eventName: string): Promise<void>;
2083
+ assertCanPublish(ctx: ActionContext<S, CP, CS, V, I, DB, E, Q>, queueName: string): Promise<void>;
2084
+ executeAction(ctx: ActionContext<S, CP, CS, V, I, DB, E, Q>, actionName: string, args: unknown[]): Promise<unknown>;
2085
+ handleRawRequest(conn: Conn<S, CP, CS, V, I, DB, E, Q>, request: Request): Promise<Response>;
2086
+ handleRawWebSocket(conn: Conn<S, CP, CS, V, I, DB, E, Q>, websocket: UniversalWebSocket, request?: Request): void;
1871
2087
  scheduleEvent(timestamp: number, action: string, args: unknown[]): Promise<void>;
1872
2088
  onAlarm(): Promise<void>;
1873
2089
  waitUntil(promise: Promise<void>): void;
2090
+ /**
2091
+ * Prevents the actor from sleeping while the given promise is running.
2092
+ *
2093
+ * Use this when performing async operations in the `run` handler or other
2094
+ * background contexts where you need to ensure the actor stays awake.
2095
+ *
2096
+ * Returns the resolved value and resets the sleep timer on completion.
2097
+ * Errors are propagated to the caller.
2098
+ */
2099
+ keepAwake<T>(promise: Promise<T>): Promise<T>;
2100
+ beginQueueWait(): void;
2101
+ endQueueWait(): void;
1874
2102
  resetSleepTimer(): void;
1875
2103
  }
1876
2104
 
@@ -1887,7 +2115,7 @@ type ConnDataInput<CP, CS> = {
1887
2115
  */
1888
2116
  declare class StateManager<CP, CS> {
1889
2117
  #private;
1890
- constructor(conn: Conn<any, CP, CS, any, any, any>, data: ConnDataInput<CP, CS>);
2118
+ constructor(conn: Conn<any, CP, CS, any, any, any, any, any>, data: ConnDataInput<CP, CS>);
1891
2119
  /**
1892
2120
  * Returns the ephemeral or persisted data for this connectioned.
1893
2121
  *
@@ -1910,7 +2138,7 @@ declare class StateManager<CP, CS> {
1910
2138
  }
1911
2139
 
1912
2140
  type ConnId = string;
1913
- type AnyConn = Conn<any, any, any, any, any, any>;
2141
+ type AnyConn = Conn<any, any, any, any, any, any, any, any>;
1914
2142
  declare const CONN_CONNECTED_SYMBOL: unique symbol;
1915
2143
  declare const CONN_SPEAKS_RIVETKIT_SYMBOL: unique symbol;
1916
2144
  declare const CONN_DRIVER_SYMBOL: unique symbol;
@@ -1924,9 +2152,9 @@ declare const CONN_SEND_MESSAGE_SYMBOL: unique symbol;
1924
2152
  *
1925
2153
  * @see {@link https://rivet.dev/docs/connections|Connection Documentation}
1926
2154
  */
1927
- declare class Conn<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
2155
+ declare class Conn<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>> {
1928
2156
  #private;
1929
- get [CONN_ACTOR_SYMBOL](): ActorInstance<S, CP, CS, V, I, DB>;
2157
+ get [CONN_ACTOR_SYMBOL](): ActorInstance<S, CP, CS, V, I, DB, E, Q>;
1930
2158
  get [CONN_STATE_MANAGER_SYMBOL](): StateManager<CP, CS>;
1931
2159
  /**
1932
2160
  * Connections exist before being connected to an actor. If true, this
@@ -1973,7 +2201,7 @@ declare class Conn<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
1973
2201
  *
1974
2202
  * @protected
1975
2203
  */
1976
- constructor(actor: ActorInstance<S, CP, CS, V, I, DB>, data: ConnDataInput<CP, CS>);
2204
+ constructor(actor: ActorInstance<S, CP, CS, V, I, DB, E, Q>, data: ConnDataInput<CP, CS>);
1977
2205
  /**
1978
2206
  * Sends a raw message to the underlying connection.
1979
2207
  */
@@ -1985,7 +2213,8 @@ declare class Conn<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
1985
2213
  * @param args - The arguments for the event.
1986
2214
  * @see {@link https://rivet.dev/docs/events|Events Documentation}
1987
2215
  */
1988
- send(eventName: string, ...args: unknown[]): void;
2216
+ send<K extends keyof E & string>(eventName: K, ...args: InferEventArgs<InferSchemaMap<E>[K]>): void;
2217
+ send(eventName: keyof E extends never ? string : never, ...args: unknown[]): void;
1989
2218
  /**
1990
2219
  * Disconnects the client with an optional reason.
1991
2220
  *
@@ -2002,56 +2231,108 @@ interface ActorTypes<TState, TConnParams, TConnState, TVars, TInput, TDatabase e
2002
2231
  input?: TInput;
2003
2232
  database?: TDatabase;
2004
2233
  }
2005
- declare const ActorConfigSchema: z.ZodObject<{
2006
- onCreate: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2007
- onDestroy: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2008
- onWake: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2009
- onSleep: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2010
- onStateChange: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2011
- onBeforeConnect: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2012
- onConnect: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2013
- onDisconnect: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2014
- onBeforeActionResponse: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2015
- onRequest: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2016
- onWebSocket: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2017
- actions: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>>;
2018
- state: z.ZodOptional<z.ZodAny>;
2019
- createState: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2020
- connState: z.ZodOptional<z.ZodAny>;
2021
- createConnState: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2022
- vars: z.ZodOptional<z.ZodAny>;
2023
- db: z.ZodOptional<z.ZodAny>;
2024
- createVars: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2025
- options: z.ZodPrefault<z.ZodObject<{
2026
- createVarsTimeout: z.ZodDefault<z.ZodNumber>;
2027
- createConnStateTimeout: z.ZodDefault<z.ZodNumber>;
2028
- onConnectTimeout: z.ZodDefault<z.ZodNumber>;
2029
- onSleepTimeout: z.ZodDefault<z.ZodNumber>;
2030
- onDestroyTimeout: z.ZodDefault<z.ZodNumber>;
2031
- stateSaveInterval: z.ZodDefault<z.ZodNumber>;
2032
- actionTimeout: z.ZodDefault<z.ZodNumber>;
2033
- waitUntilTimeout: z.ZodDefault<z.ZodNumber>;
2034
- connectionLivenessTimeout: z.ZodDefault<z.ZodNumber>;
2035
- connectionLivenessInterval: z.ZodDefault<z.ZodNumber>;
2036
- noSleep: z.ZodDefault<z.ZodBoolean>;
2037
- sleepTimeout: z.ZodDefault<z.ZodNumber>;
2038
- canHibernateWebSocket: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodCustom<(request: Request) => boolean, (request: Request) => boolean>]>>;
2039
- }, z.core.$strict>>;
2040
- }, z.core.$strict>;
2041
- type CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> = {
2234
+ type InspectorUnsubscribe = () => void;
2235
+ interface WorkflowInspectorConfig<THistory = unknown> {
2236
+ getHistory: () => THistory | null;
2237
+ onHistoryUpdated?: (listener: (history: THistory) => void) => InspectorUnsubscribe;
2238
+ }
2239
+ interface RunInspectorConfig<THistory = unknown> {
2240
+ workflow?: WorkflowInspectorConfig<THistory>;
2241
+ }
2242
+ declare const RunConfigSchema: z$1.ZodObject<{
2243
+ name: z$1.ZodOptional<z$1.ZodString>;
2244
+ icon: z$1.ZodOptional<z$1.ZodString>;
2245
+ run: z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>;
2246
+ inspector: z$1.ZodOptional<z$1.ZodOptional<z$1.ZodObject<{
2247
+ workflow: z$1.ZodOptional<z$1.ZodObject<{
2248
+ getHistory: z$1.ZodCustom<() => unknown, () => unknown>;
2249
+ onHistoryUpdated: z$1.ZodOptional<z$1.ZodCustom<(listener: (history: unknown) => void) => InspectorUnsubscribe, (listener: (history: unknown) => void) => InspectorUnsubscribe>>;
2250
+ }, z$1.core.$strip>>;
2251
+ }, z$1.core.$strip>>>;
2252
+ }, z$1.core.$strip>;
2253
+ type RunConfigRuntime = z$1.infer<typeof RunConfigSchema>;
2254
+ type RunConfig<TState = unknown, TConnParams = unknown, TConnState = unknown, TVars = unknown, TInput = unknown, TDatabase extends AnyDatabaseProvider = AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = Omit<RunConfigRuntime, "run"> & {
2255
+ run: (c: RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
2256
+ };
2257
+ type AnyRunConfig = RunConfig<any, any, any, any, any, AnyDatabaseProvider, any, any>;
2258
+ declare const RUN_FUNCTION_CONFIG_SYMBOL: unique symbol;
2259
+ /** Extract the run function from either a function or RunConfig object. */
2260
+ declare function getRunFunction(run: ((...args: any[]) => any) | AnyRunConfig | undefined): ((...args: any[]) => any) | undefined;
2261
+ /** Extract run metadata (name/icon) from RunConfig if provided. */
2262
+ declare function getRunMetadata(run: ((...args: any[]) => any) | AnyRunConfig | undefined): {
2263
+ name?: string;
2264
+ icon?: string;
2265
+ };
2266
+ /** Extract run inspector configuration if provided. */
2267
+ declare function getRunInspectorConfig(run: ((...args: any[]) => any) | AnyRunConfig | undefined): RunInspectorConfig | undefined;
2268
+ declare const ActorConfigSchema: z$1.ZodObject<{
2269
+ onCreate: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2270
+ onDestroy: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2271
+ onWake: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2272
+ onSleep: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2273
+ run: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>, z$1.ZodObject<{
2274
+ name: z$1.ZodOptional<z$1.ZodString>;
2275
+ icon: z$1.ZodOptional<z$1.ZodString>;
2276
+ run: z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>;
2277
+ inspector: z$1.ZodOptional<z$1.ZodOptional<z$1.ZodObject<{
2278
+ workflow: z$1.ZodOptional<z$1.ZodObject<{
2279
+ getHistory: z$1.ZodCustom<() => unknown, () => unknown>;
2280
+ onHistoryUpdated: z$1.ZodOptional<z$1.ZodCustom<(listener: (history: unknown) => void) => InspectorUnsubscribe, (listener: (history: unknown) => void) => InspectorUnsubscribe>>;
2281
+ }, z$1.core.$strip>>;
2282
+ }, z$1.core.$strip>>>;
2283
+ }, z$1.core.$strip>]>>;
2284
+ onStateChange: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2285
+ onBeforeConnect: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2286
+ onConnect: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2287
+ onDisconnect: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2288
+ onBeforeActionResponse: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2289
+ onRequest: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2290
+ onWebSocket: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2291
+ actions: z$1.ZodDefault<z$1.ZodRecord<z$1.ZodString, z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>>;
2292
+ events: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
2293
+ queues: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
2294
+ state: z$1.ZodOptional<z$1.ZodAny>;
2295
+ createState: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2296
+ connState: z$1.ZodOptional<z$1.ZodAny>;
2297
+ createConnState: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2298
+ vars: z$1.ZodOptional<z$1.ZodAny>;
2299
+ db: z$1.ZodOptional<z$1.ZodAny>;
2300
+ createVars: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2301
+ options: z$1.ZodPrefault<z$1.ZodObject<{
2302
+ name: z$1.ZodOptional<z$1.ZodString>;
2303
+ icon: z$1.ZodOptional<z$1.ZodString>;
2304
+ createVarsTimeout: z$1.ZodDefault<z$1.ZodNumber>;
2305
+ createConnStateTimeout: z$1.ZodDefault<z$1.ZodNumber>;
2306
+ onConnectTimeout: z$1.ZodDefault<z$1.ZodNumber>;
2307
+ onSleepTimeout: z$1.ZodDefault<z$1.ZodNumber>;
2308
+ onDestroyTimeout: z$1.ZodDefault<z$1.ZodNumber>;
2309
+ stateSaveInterval: z$1.ZodDefault<z$1.ZodNumber>;
2310
+ actionTimeout: z$1.ZodDefault<z$1.ZodNumber>;
2311
+ waitUntilTimeout: z$1.ZodDefault<z$1.ZodNumber>;
2312
+ runStopTimeout: z$1.ZodDefault<z$1.ZodNumber>;
2313
+ connectionLivenessTimeout: z$1.ZodDefault<z$1.ZodNumber>;
2314
+ connectionLivenessInterval: z$1.ZodDefault<z$1.ZodNumber>;
2315
+ noSleep: z$1.ZodDefault<z$1.ZodBoolean>;
2316
+ sleepTimeout: z$1.ZodDefault<z$1.ZodNumber>;
2317
+ maxQueueSize: z$1.ZodDefault<z$1.ZodNumber>;
2318
+ maxQueueMessageSize: z$1.ZodDefault<z$1.ZodNumber>;
2319
+ canHibernateWebSocket: z$1.ZodDefault<z$1.ZodUnion<readonly [z$1.ZodBoolean, z$1.ZodCustom<(request: Request) => boolean, (request: Request) => boolean>]>>;
2320
+ }, z$1.core.$strict>>;
2321
+ }, z$1.core.$strict>;
2322
+ type CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
2042
2323
  state: TState;
2043
2324
  } | {
2044
- createState: (c: CreateContext<TState, TInput, TDatabase>, input: TInput) => TState | Promise<TState>;
2325
+ createState: (c: CreateContext<TState, TInput, TDatabase, TEvents, TQueues>, input: TInput) => TState | Promise<TState>;
2045
2326
  } | Record<never, never>;
2046
- type CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> = {
2327
+ type CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
2047
2328
  connState: TConnState;
2048
2329
  } | {
2049
- createConnState: (c: CreateConnStateContext<TState, TVars, TInput, TDatabase>, params: TConnParams) => TConnState | Promise<TConnState>;
2330
+ createConnState: (c: CreateConnStateContext<TState, TVars, TInput, TDatabase, TEvents, TQueues>, params: TConnParams) => TConnState | Promise<TConnState>;
2050
2331
  } | Record<never, never>;
2051
2332
  /**
2052
2333
  * @experimental
2053
2334
  */
2054
- type CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> = {
2335
+ type CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
2055
2336
  /**
2056
2337
  * @experimental
2057
2338
  */
@@ -2060,27 +2341,27 @@ type CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase extend
2060
2341
  /**
2061
2342
  * @experimental
2062
2343
  */
2063
- createVars: (c: CreateVarsContext<TState, TInput, TDatabase>, driverCtx: any) => TVars | Promise<TVars>;
2344
+ createVars: (c: CreateVarsContext<TState, TInput, TDatabase, TEvents, TQueues>, driverCtx: any) => TVars | Promise<TVars>;
2064
2345
  } | Record<never, never>;
2065
- interface Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> {
2066
- [Action: string]: (c: ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, ...args: any[]) => any;
2346
+ interface Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
2347
+ [Action: string]: (c: ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, ...args: any[]) => any;
2067
2348
  }
2068
2349
  /**
2069
2350
  * @experimental
2070
2351
  */
2071
2352
  type AuthIntent = "get" | "create" | "connect" | "action" | "message";
2072
- interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase>> {
2353
+ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>> {
2073
2354
  /**
2074
2355
  * Called when the actor is first initialized.
2075
2356
  *
2076
2357
  * Use this hook to initialize your actor's state.
2077
2358
  * This is called before any other lifecycle hooks.
2078
2359
  */
2079
- onCreate?: (c: CreateContext<TState, TInput, TDatabase>, input: TInput) => void | Promise<void>;
2360
+ onCreate?: (c: CreateContext<TState, TInput, TDatabase, TEvents, TQueues>, input: TInput) => void | Promise<void>;
2080
2361
  /**
2081
2362
  * Called when the actor is destroyed.
2082
2363
  */
2083
- onDestroy?: (c: DestroyContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>) => void | Promise<void>;
2364
+ onDestroy?: (c: DestroyContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
2084
2365
  /**
2085
2366
  * Called when the actor is started and ready to receive connections and action.
2086
2367
  *
@@ -2089,7 +2370,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
2089
2370
  *
2090
2371
  * @returns Void or a Promise that resolves when startup is complete
2091
2372
  */
2092
- onWake?: (c: WakeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>) => void | Promise<void>;
2373
+ onWake?: (c: WakeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
2093
2374
  /**
2094
2375
  * Called when the actor is stopping or sleeping.
2095
2376
  *
@@ -2100,7 +2381,31 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
2100
2381
  *
2101
2382
  * @returns Void or a Promise that resolves when shutdown is complete
2102
2383
  */
2103
- onSleep?: (c: SleepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>) => void | Promise<void>;
2384
+ onSleep?: (c: SleepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
2385
+ /**
2386
+ * Called after the actor starts up. Does not block actor startup.
2387
+ *
2388
+ * Use this for background tasks like:
2389
+ * - Reading from queues in a loop
2390
+ * - Tick loops for periodic work
2391
+ * - Custom workflow logic
2392
+ *
2393
+ * **Important:** The actor may go to sleep at any time during the `run`
2394
+ * handler. Use `c.keepAwake(promise)` to wrap async operations that should
2395
+ * not be interrupted by sleep.
2396
+ *
2397
+ * The handler receives an abort signal via `c.abortSignal` and a
2398
+ * `c.aborted` alias for loop checks. Use these to gracefully exit.
2399
+ *
2400
+ * If this handler exits or throws, the actor will crash and reschedule.
2401
+ * On shutdown, the actor waits for this handler to complete with a
2402
+ * configurable timeout (options.runStopTimeout, default 15s).
2403
+ *
2404
+ * Can be either a function or a RunConfig object with optional name/icon metadata.
2405
+ *
2406
+ * @returns Void or a Promise. If the promise exits, the actor crashes.
2407
+ */
2408
+ run?: ((c: RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>) | RunConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
2104
2409
  /**
2105
2410
  * Called when the actor's state changes.
2106
2411
  *
@@ -2112,7 +2417,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
2112
2417
  *
2113
2418
  * @param newState The updated state
2114
2419
  */
2115
- onStateChange?: (c: StateChangeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, newState: TState) => void;
2420
+ onStateChange?: (c: StateChangeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, newState: TState) => void;
2116
2421
  /**
2117
2422
  * Called before a client connects to the actor.
2118
2423
  *
@@ -2123,7 +2428,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
2123
2428
  * @returns The initial connection state or a Promise that resolves to it
2124
2429
  * @throws Throw an error to reject the connection
2125
2430
  */
2126
- onBeforeConnect?: (c: BeforeConnectContext<TState, TVars, TInput, TDatabase>, params: TConnParams) => void | Promise<void>;
2431
+ onBeforeConnect?: (c: BeforeConnectContext<TState, TVars, TInput, TDatabase, TEvents, TQueues>, params: TConnParams) => void | Promise<void>;
2127
2432
  /**
2128
2433
  * Called when a client successfully connects to the actor.
2129
2434
  *
@@ -2133,7 +2438,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
2133
2438
  * @param conn The connection object
2134
2439
  * @returns Void or a Promise that resolves when connection handling is complete
2135
2440
  */
2136
- onConnect?: (c: ConnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>) => void | Promise<void>;
2441
+ onConnect?: (c: ConnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
2137
2442
  /**
2138
2443
  * Called when a client disconnects from the actor.
2139
2444
  *
@@ -2143,7 +2448,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
2143
2448
  * @param conn The connection that is being closed
2144
2449
  * @returns Void or a Promise that resolves when disconnect handling is complete
2145
2450
  */
2146
- onDisconnect?: (c: DisconnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>) => void | Promise<void>;
2451
+ onDisconnect?: (c: DisconnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
2147
2452
  /**
2148
2453
  * Called before sending an action response to the client.
2149
2454
  *
@@ -2156,7 +2461,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
2156
2461
  * @param output The output that will be sent to the client
2157
2462
  * @returns The modified output to send to the client
2158
2463
  */
2159
- onBeforeActionResponse?: <Out>(c: BeforeActionResponseContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, name: string, args: unknown[], output: Out) => Out | Promise<Out>;
2464
+ onBeforeActionResponse?: <Out>(c: BeforeActionResponseContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, name: string, args: unknown[], output: Out) => Out | Promise<Out>;
2160
2465
  /**
2161
2466
  * Called when a raw HTTP request is made to the actor.
2162
2467
  *
@@ -2168,7 +2473,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
2168
2473
  * @param opts Additional options
2169
2474
  * @returns A Response object to send back, or void to continue with default routing
2170
2475
  */
2171
- onRequest?: (c: RequestContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, request: Request) => Response | Promise<Response>;
2476
+ onRequest?: (c: RequestContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, request: Request) => Response | Promise<Response>;
2172
2477
  /**
2173
2478
  * Called when a raw WebSocket connection is established to the actor.
2174
2479
  *
@@ -2179,8 +2484,16 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
2179
2484
  * @param websocket The raw WebSocket connection
2180
2485
  * @param opts Additional options including the original HTTP upgrade request
2181
2486
  */
2182
- onWebSocket?: (c: WebSocketContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, websocket: UniversalWebSocket) => void | Promise<void>;
2487
+ onWebSocket?: (c: WebSocketContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, websocket: UniversalWebSocket) => void | Promise<void>;
2183
2488
  actions?: TActions;
2489
+ /**
2490
+ * Schema map for events broadcasted by this actor.
2491
+ */
2492
+ events?: TEvents;
2493
+ /**
2494
+ * Schema map for queue payloads sent by this actor.
2495
+ */
2496
+ queues?: TQueues;
2184
2497
  }
2185
2498
  type ActorDatabaseConfig<TDatabase extends AnyDatabaseProvider> = {
2186
2499
  /**
@@ -2188,61 +2501,74 @@ type ActorDatabaseConfig<TDatabase extends AnyDatabaseProvider> = {
2188
2501
  */
2189
2502
  db: TDatabase;
2190
2503
  } | Record<never, never>;
2191
- type ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> = Omit<z.infer<typeof ActorConfigSchema>, "actions" | "onCreate" | "onDestroy" | "onWake" | "onStateChange" | "onBeforeConnect" | "onConnect" | "onDisconnect" | "onBeforeActionResponse" | "onRequest" | "onWebSocket" | "state" | "createState" | "connState" | "createConnState" | "vars" | "createVars" | "db"> & BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase>> & CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase> & CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase> & CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase> & ActorDatabaseConfig<TDatabase>;
2192
- type ActorConfigInput<TState = undefined, TConnParams = undefined, TConnState = undefined, TVars = undefined, TInput = undefined, TDatabase extends AnyDatabaseProvider = undefined, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase> = Record<never, never>> = {
2504
+ type ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = Omit<z$1.infer<typeof ActorConfigSchema>, "actions" | "events" | "queues" | "onCreate" | "onDestroy" | "onWake" | "onSleep" | "run" | "onStateChange" | "onBeforeConnect" | "onConnect" | "onDisconnect" | "onBeforeActionResponse" | "onRequest" | "onWebSocket" | "state" | "createState" | "connState" | "createConnState" | "vars" | "createVars" | "db"> & BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues, Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>> & CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & ActorDatabaseConfig<TDatabase>;
2505
+ type ActorConfigInput<TState = undefined, TConnParams = undefined, TConnState = undefined, TVars = undefined, TInput = undefined, TDatabase extends AnyDatabaseProvider = undefined, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> = Record<never, never>> = {
2193
2506
  types?: ActorTypes<TState, TConnParams, TConnState, TVars, TInput, TDatabase>;
2194
- } & Omit<z.input<typeof ActorConfigSchema>, "actions" | "onCreate" | "onDestroy" | "onWake" | "onSleep" | "onStateChange" | "onBeforeConnect" | "onConnect" | "onDisconnect" | "onBeforeActionResponse" | "onRequest" | "onWebSocket" | "state" | "createState" | "connState" | "createConnState" | "vars" | "createVars" | "db"> & BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TActions> & CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase> & CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase> & CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase> & ActorDatabaseConfig<TDatabase>;
2195
- declare function test<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase>>(input: ActorConfigInput<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TActions>): ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase>;
2196
- declare const DocActorOptionsSchema: z.ZodObject<{
2197
- createVarsTimeout: z.ZodOptional<z.ZodNumber>;
2198
- createConnStateTimeout: z.ZodOptional<z.ZodNumber>;
2199
- onConnectTimeout: z.ZodOptional<z.ZodNumber>;
2200
- onSleepTimeout: z.ZodOptional<z.ZodNumber>;
2201
- onDestroyTimeout: z.ZodOptional<z.ZodNumber>;
2202
- stateSaveInterval: z.ZodOptional<z.ZodNumber>;
2203
- actionTimeout: z.ZodOptional<z.ZodNumber>;
2204
- waitUntilTimeout: z.ZodOptional<z.ZodNumber>;
2205
- connectionLivenessTimeout: z.ZodOptional<z.ZodNumber>;
2206
- connectionLivenessInterval: z.ZodOptional<z.ZodNumber>;
2207
- noSleep: z.ZodOptional<z.ZodBoolean>;
2208
- sleepTimeout: z.ZodOptional<z.ZodNumber>;
2209
- canHibernateWebSocket: z.ZodOptional<z.ZodBoolean>;
2210
- }, z.core.$strip>;
2211
- declare const DocActorConfigSchema: z.ZodObject<{
2212
- state: z.ZodOptional<z.ZodUnknown>;
2213
- createState: z.ZodOptional<z.ZodUnknown>;
2214
- connState: z.ZodOptional<z.ZodUnknown>;
2215
- createConnState: z.ZodOptional<z.ZodUnknown>;
2216
- vars: z.ZodOptional<z.ZodUnknown>;
2217
- createVars: z.ZodOptional<z.ZodUnknown>;
2218
- db: z.ZodOptional<z.ZodUnknown>;
2219
- onCreate: z.ZodOptional<z.ZodUnknown>;
2220
- onDestroy: z.ZodOptional<z.ZodUnknown>;
2221
- onWake: z.ZodOptional<z.ZodUnknown>;
2222
- onSleep: z.ZodOptional<z.ZodUnknown>;
2223
- onStateChange: z.ZodOptional<z.ZodUnknown>;
2224
- onBeforeConnect: z.ZodOptional<z.ZodUnknown>;
2225
- onConnect: z.ZodOptional<z.ZodUnknown>;
2226
- onDisconnect: z.ZodOptional<z.ZodUnknown>;
2227
- onBeforeActionResponse: z.ZodOptional<z.ZodUnknown>;
2228
- onRequest: z.ZodOptional<z.ZodUnknown>;
2229
- onWebSocket: z.ZodOptional<z.ZodUnknown>;
2230
- actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2231
- options: z.ZodOptional<z.ZodObject<{
2232
- createVarsTimeout: z.ZodOptional<z.ZodNumber>;
2233
- createConnStateTimeout: z.ZodOptional<z.ZodNumber>;
2234
- onConnectTimeout: z.ZodOptional<z.ZodNumber>;
2235
- onSleepTimeout: z.ZodOptional<z.ZodNumber>;
2236
- onDestroyTimeout: z.ZodOptional<z.ZodNumber>;
2237
- stateSaveInterval: z.ZodOptional<z.ZodNumber>;
2238
- actionTimeout: z.ZodOptional<z.ZodNumber>;
2239
- waitUntilTimeout: z.ZodOptional<z.ZodNumber>;
2240
- connectionLivenessTimeout: z.ZodOptional<z.ZodNumber>;
2241
- connectionLivenessInterval: z.ZodOptional<z.ZodNumber>;
2242
- noSleep: z.ZodOptional<z.ZodBoolean>;
2243
- sleepTimeout: z.ZodOptional<z.ZodNumber>;
2244
- canHibernateWebSocket: z.ZodOptional<z.ZodBoolean>;
2245
- }, z.core.$strip>>;
2246
- }, z.core.$strip>;
2507
+ } & Omit<z$1.input<typeof ActorConfigSchema>, "actions" | "events" | "queues" | "onCreate" | "onDestroy" | "onWake" | "onSleep" | "run" | "onStateChange" | "onBeforeConnect" | "onConnect" | "onDisconnect" | "onBeforeActionResponse" | "onRequest" | "onWebSocket" | "state" | "createState" | "connState" | "createConnState" | "vars" | "createVars" | "db"> & BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues, TActions> & CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & ActorDatabaseConfig<TDatabase>;
2508
+ declare function test<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>(input: ActorConfigInput<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues, TActions>): ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
2509
+ declare const DocActorOptionsSchema: z$1.ZodObject<{
2510
+ name: z$1.ZodOptional<z$1.ZodString>;
2511
+ icon: z$1.ZodOptional<z$1.ZodString>;
2512
+ createVarsTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2513
+ createConnStateTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2514
+ onConnectTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2515
+ onSleepTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2516
+ onDestroyTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2517
+ stateSaveInterval: z$1.ZodOptional<z$1.ZodNumber>;
2518
+ actionTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2519
+ waitUntilTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2520
+ runStopTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2521
+ connectionLivenessTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2522
+ connectionLivenessInterval: z$1.ZodOptional<z$1.ZodNumber>;
2523
+ noSleep: z$1.ZodOptional<z$1.ZodBoolean>;
2524
+ sleepTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2525
+ maxQueueSize: z$1.ZodOptional<z$1.ZodNumber>;
2526
+ maxQueueMessageSize: z$1.ZodOptional<z$1.ZodNumber>;
2527
+ canHibernateWebSocket: z$1.ZodOptional<z$1.ZodBoolean>;
2528
+ }, z$1.core.$strip>;
2529
+ declare const DocActorConfigSchema: z$1.ZodObject<{
2530
+ state: z$1.ZodOptional<z$1.ZodUnknown>;
2531
+ createState: z$1.ZodOptional<z$1.ZodUnknown>;
2532
+ connState: z$1.ZodOptional<z$1.ZodUnknown>;
2533
+ createConnState: z$1.ZodOptional<z$1.ZodUnknown>;
2534
+ vars: z$1.ZodOptional<z$1.ZodUnknown>;
2535
+ createVars: z$1.ZodOptional<z$1.ZodUnknown>;
2536
+ db: z$1.ZodOptional<z$1.ZodUnknown>;
2537
+ onCreate: z$1.ZodOptional<z$1.ZodUnknown>;
2538
+ onDestroy: z$1.ZodOptional<z$1.ZodUnknown>;
2539
+ onWake: z$1.ZodOptional<z$1.ZodUnknown>;
2540
+ onSleep: z$1.ZodOptional<z$1.ZodUnknown>;
2541
+ run: z$1.ZodOptional<z$1.ZodUnknown>;
2542
+ onStateChange: z$1.ZodOptional<z$1.ZodUnknown>;
2543
+ onBeforeConnect: z$1.ZodOptional<z$1.ZodUnknown>;
2544
+ onConnect: z$1.ZodOptional<z$1.ZodUnknown>;
2545
+ onDisconnect: z$1.ZodOptional<z$1.ZodUnknown>;
2546
+ onBeforeActionResponse: z$1.ZodOptional<z$1.ZodUnknown>;
2547
+ onRequest: z$1.ZodOptional<z$1.ZodUnknown>;
2548
+ onWebSocket: z$1.ZodOptional<z$1.ZodUnknown>;
2549
+ actions: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
2550
+ events: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
2551
+ queues: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
2552
+ options: z$1.ZodOptional<z$1.ZodObject<{
2553
+ name: z$1.ZodOptional<z$1.ZodString>;
2554
+ icon: z$1.ZodOptional<z$1.ZodString>;
2555
+ createVarsTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2556
+ createConnStateTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2557
+ onConnectTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2558
+ onSleepTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2559
+ onDestroyTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2560
+ stateSaveInterval: z$1.ZodOptional<z$1.ZodNumber>;
2561
+ actionTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2562
+ waitUntilTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2563
+ runStopTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2564
+ connectionLivenessTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2565
+ connectionLivenessInterval: z$1.ZodOptional<z$1.ZodNumber>;
2566
+ noSleep: z$1.ZodOptional<z$1.ZodBoolean>;
2567
+ sleepTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2568
+ maxQueueSize: z$1.ZodOptional<z$1.ZodNumber>;
2569
+ maxQueueMessageSize: z$1.ZodOptional<z$1.ZodNumber>;
2570
+ canHibernateWebSocket: z$1.ZodOptional<z$1.ZodBoolean>;
2571
+ }, z$1.core.$strip>>;
2572
+ }, z$1.core.$strip>;
2247
2573
 
2248
- export { StateChangeContext as $, type ActorDriver as A, ActionContext as B, type Client as C, DocActorOptionsSchema as D, type Encoding as E, type ActionContextOf as F, BeforeActionResponseContext as G, type BeforeActionResponseContextOf as H, BeforeConnectContext as I, type BeforeConnectContextOf as J, ConnectContext as K, type ConnectContextOf as L, CreateContext as M, type CreateContextOf as N, CreateConnStateContext as O, type CreateConnStateContextOf as P, CreateVarsContext as Q, type RegistryConfig as R, type CreateVarsContextOf as S, DestroyContext as T, type DestroyContextOf as U, DisconnectContext as V, type DisconnectContextOf as W, RequestContext as X, type RequestContextOf as Y, SleepContext as Z, type SleepContextOf as _, type AnyConn as a, type StateChangeContextOf as a0, WakeContext as a1, type WakeContextOf as a2, WebSocketContext as a3, type WebSocketContextOf as a4, type RegistryActors as a5, RegistryConfigSchema as a6, type FetchHandler as a7, type ServerlessHandler as a8, type LegacyStartServerOutput as a9, type ActorHandle as aA, ActorHandleRaw as aB, type ActorAccessor as aC, ClientRaw as aD, type CreateOptions as aE, type ExtractActorsFromRegistry as aF, type ExtractRegistryFromClient as aG, type GetOptions as aH, type GetWithIdOptions as aI, type QueryOptions as aJ, type Region as aK, type ManagerDriver as aL, ActorInstance as aM, type ActorOutput as aN, type CreateInput as aO, type GetForIdInput as aP, type GetOrCreateWithKeyInput as aQ, type GetWithKeyInput as aR, type ListActorsInput as aS, type ManagerDisplayInformation as aT, type ManagerDriverBuilder as aU, type ActorDriverBuilder as aV, Registry as aa, setup as ab, ActorsSchema as ac, TestConfigSchema as ad, type TestConfig as ae, type RegistryConfigInput as af, buildActorNames as ag, DocInspectorConfigSchema as ah, DocConfigureRunnerPoolSchema as ai, DocServerlessConfigSchema as aj, DocRunnerConfigSchema as ak, DocRegistryConfigSchema as al, ActorClientError as am, ActorConnDisposed as an, ActorError as ao, InternalError as ap, MalformedResponseMessage as aq, ManagerError as ar, type CreateRequest as as, type ActorActionFunction as at, type ActorConn as au, type ActorConnStatus as av, type ConnectionStateCallback as aw, type EventUnsubscribe as ax, type StatusChangeCallback as ay, ActorConnRaw as az, type AnyActorInstance as b, type AnyDatabaseProvider as c, type Actions as d, type ActorConfigInput as e, ActorDefinition as f, type AnyClient as g, createClientWithDriver as h, type ActorQuery as i, type ActorKey as j, Conn as k, type AnyActorDefinition as l, lookupInRegistry as m, ActorKv as n, type ActorTypes as o, ActorConfigSchema as p, type AuthIntent as q, type ActorConfig as r, DocActorConfigSchema as s, test as t, ActorContext as u, type ActorContextOf as v, ConnContext as w, type ConnContextOf as x, ConnInitContext as y, type ConnInitContextOf as z };
2574
+ export { DocRunnerConfigSchema as $, type ActorDriver as A, BeforeActionResponseContext as B, type Client as C, ConnContext as D, type Encoding as E, type ConnContextOf as F, ConnInitContext as G, type ConnInitContextOf as H, ConnectContext as I, type ConnectContextOf as J, CreateConnStateContext as K, type CreateConnStateContextOf as L, CreateContext as M, type CreateContextOf as N, CreateVarsContext as O, type CreateVarsContextOf as P, type QueueSchemaConfig as Q, type RegistryConfig as R, DestroyContext as S, type DestroyContextOf as T, DisconnectContext as U, type DisconnectContextOf as V, DocActorConfigSchema as W, DocActorOptionsSchema as X, DocConfigureRunnerPoolSchema as Y, DocInspectorConfigSchema as Z, DocRegistryConfigSchema as _, type AnyConn as a, ActorInstance as a$, DocServerlessConfigSchema as a0, type FetchHandler as a1, type InspectorUnsubscribe as a2, type LegacyStartServerOutput as a3, RUN_FUNCTION_CONFIG_SYMBOL as a4, Registry as a5, type RegistryActors as a6, type RegistryConfigInput as a7, RegistryConfigSchema as a8, RequestContext as a9, test as aA, type ActorAccessor as aB, type ActorActionFunction as aC, ActorClientError as aD, type ActorConn as aE, ActorConnDisposed as aF, ActorConnRaw as aG, type ActorConnStatus as aH, ActorError as aI, type ActorHandle as aJ, ActorHandleRaw as aK, ClientRaw as aL, type ConnectionStateCallback as aM, type CreateOptions as aN, type CreateRequest as aO, type EventUnsubscribe as aP, type ExtractActorsFromRegistry as aQ, type ExtractRegistryFromClient as aR, type GetOptions as aS, type GetWithIdOptions as aT, InternalError as aU, MalformedResponseMessage as aV, ManagerError as aW, type QueryOptions as aX, type Region as aY, type StatusChangeCallback as aZ, type ManagerDriver as a_, type RequestContextOf as aa, type RunConfig as ab, RunConfigSchema as ac, RunContext as ad, type RunContextOf as ae, type RunInspectorConfig as af, type ServerlessHandler as ag, SleepContext as ah, type SleepContextOf as ai, StateChangeContext as aj, type StateChangeContextOf as ak, type TestConfig as al, TestConfigSchema as am, type Type as an, WakeContext as ao, type WakeContextOf as ap, WebSocketContext as aq, type WebSocketContextOf as ar, type WorkflowInspectorConfig as as, buildActorNames as at, createClientWithDriver as au, getRunFunction as av, getRunInspectorConfig as aw, getRunMetadata as ax, lookupInRegistry as ay, setup as az, type AnyActorInstance as b, type ActorOutput as b0, type CreateInput as b1, type GetForIdInput as b2, type GetOrCreateWithKeyInput as b3, type GetWithKeyInput as b4, type ListActorsInput as b5, type ManagerDisplayInformation as b6, type ManagerDriverBuilder as b7, type ActorDriverBuilder as b8, type QueueFilterName as b9, type QueueNextOptions as ba, type QueueResultMessageForName as bb, type InferSchemaMap as bc, type InferDatabaseClient as bd, type InferEventArgs as be, type EventSchemaConfig as c, type Actions as d, type ActorConfigInput as e, ActorDefinition as f, event as g, ActionContext as h, type ActionContextOf as i, type ActorConfig as j, ActorConfigSchema as k, ActorContext as l, type ActorContextOf as m, type ActorKey as n, ActorKv as o, type ActorQuery as p, queue as q, type ActorTypes as r, ActorsSchema as s, type AnyActorDefinition as t, type AnyClient as u, type AuthIntent as v, type BeforeActionResponseContextOf as w, BeforeConnectContext as x, type BeforeConnectContextOf as y, Conn as z };