rivetkit 2.0.2 → 2.0.4-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 (403) hide show
  1. package/README.md +3 -5
  2. package/dist/browser/client.d.ts +2485 -0
  3. package/dist/browser/client.js +5182 -0
  4. package/dist/browser/client.js.map +1 -0
  5. package/dist/browser/inspector/client.d.ts +130 -0
  6. package/dist/browser/inspector/client.js +2854 -0
  7. package/dist/browser/inspector/client.js.map +1 -0
  8. package/dist/browser/v3-DnYObHH3.d.ts +279 -0
  9. package/dist/inspector.tar.gz +0 -0
  10. package/dist/schemas/actor-inspector/v1.ts +784 -0
  11. package/dist/schemas/actor-inspector/v2.ts +796 -0
  12. package/dist/schemas/actor-inspector/v3.ts +899 -0
  13. package/dist/schemas/actor-persist/v1.ts +225 -0
  14. package/dist/schemas/actor-persist/v2.ts +268 -0
  15. package/dist/schemas/actor-persist/v3.ts +280 -0
  16. package/dist/schemas/actor-persist/v4.ts +406 -0
  17. package/dist/schemas/client-protocol/v1.ts +441 -0
  18. package/dist/schemas/client-protocol/v2.ts +438 -0
  19. package/dist/schemas/client-protocol/v3.ts +554 -0
  20. package/dist/schemas/file-system-driver/v1.ts +108 -0
  21. package/dist/schemas/file-system-driver/v2.ts +142 -0
  22. package/dist/schemas/file-system-driver/v3.ts +167 -0
  23. package/dist/schemas/persist/v1.ts +781 -0
  24. package/dist/schemas/transport/v1.ts +697 -0
  25. package/dist/tsup/actor/errors.cjs +106 -0
  26. package/dist/tsup/actor/errors.cjs.map +1 -0
  27. package/dist/tsup/actor/errors.d.cts +188 -0
  28. package/dist/tsup/actor/errors.d.ts +188 -0
  29. package/dist/tsup/actor/errors.js +106 -0
  30. package/dist/tsup/actor/errors.js.map +1 -0
  31. package/dist/tsup/actor-router-consts-D29T1Z-K.d.cts +24 -0
  32. package/dist/tsup/actor-router-consts-D29T1Z-K.d.ts +24 -0
  33. package/dist/tsup/chunk-325TLXJT.js +1060 -0
  34. package/dist/tsup/chunk-325TLXJT.js.map +1 -0
  35. package/dist/tsup/chunk-424PT5DM.js +23 -0
  36. package/dist/tsup/chunk-424PT5DM.js.map +1 -0
  37. package/dist/tsup/chunk-4JVIG3SS.cjs +6289 -0
  38. package/dist/tsup/chunk-4JVIG3SS.cjs.map +1 -0
  39. package/dist/tsup/chunk-6LJAZ5R4.cjs +96 -0
  40. package/dist/tsup/chunk-6LJAZ5R4.cjs.map +1 -0
  41. package/dist/tsup/chunk-6XU3FMCB.cjs +534 -0
  42. package/dist/tsup/chunk-6XU3FMCB.cjs.map +1 -0
  43. package/dist/tsup/chunk-7HTNH26M.js +509 -0
  44. package/dist/tsup/chunk-7HTNH26M.js.map +1 -0
  45. package/dist/tsup/chunk-AUVH72RE.cjs +5977 -0
  46. package/dist/tsup/chunk-AUVH72RE.cjs.map +1 -0
  47. package/dist/tsup/chunk-D4BYUPNQ.js +645 -0
  48. package/dist/tsup/chunk-D4BYUPNQ.js.map +1 -0
  49. package/dist/tsup/chunk-HDQ2JUQT.cjs +23 -0
  50. package/dist/tsup/chunk-HDQ2JUQT.cjs.map +1 -0
  51. package/dist/tsup/chunk-HHXX2VRM.js +6289 -0
  52. package/dist/tsup/chunk-HHXX2VRM.js.map +1 -0
  53. package/dist/tsup/chunk-JEAEA2PB.js +49 -0
  54. package/dist/tsup/chunk-JEAEA2PB.js.map +1 -0
  55. package/dist/tsup/chunk-JYSEG3VF.cjs +642 -0
  56. package/dist/tsup/chunk-JYSEG3VF.cjs.map +1 -0
  57. package/dist/tsup/chunk-K6DGYILQ.js +2657 -0
  58. package/dist/tsup/chunk-K6DGYILQ.js.map +1 -0
  59. package/dist/tsup/chunk-KJSYAUOM.js +96 -0
  60. package/dist/tsup/chunk-KJSYAUOM.js.map +1 -0
  61. package/dist/tsup/chunk-L47L3ZWJ.cjs +509 -0
  62. package/dist/tsup/chunk-L47L3ZWJ.cjs.map +1 -0
  63. package/dist/tsup/chunk-LXUQ667X.js +2006 -0
  64. package/dist/tsup/chunk-LXUQ667X.js.map +1 -0
  65. package/dist/tsup/chunk-MXNPAB5W.js +5977 -0
  66. package/dist/tsup/chunk-MXNPAB5W.js.map +1 -0
  67. package/dist/tsup/chunk-N4KRDJ56.js +72 -0
  68. package/dist/tsup/chunk-N4KRDJ56.js.map +1 -0
  69. package/dist/tsup/chunk-NIYZDWMW.cjs +2006 -0
  70. package/dist/tsup/chunk-NIYZDWMW.cjs.map +1 -0
  71. package/dist/tsup/chunk-PQZHDKRW.cjs +1060 -0
  72. package/dist/tsup/chunk-PQZHDKRW.cjs.map +1 -0
  73. package/dist/tsup/chunk-PVOE6BU7.cjs +1050 -0
  74. package/dist/tsup/chunk-PVOE6BU7.cjs.map +1 -0
  75. package/dist/tsup/chunk-Q4UD2GA4.cjs +1810 -0
  76. package/dist/tsup/chunk-Q4UD2GA4.cjs.map +1 -0
  77. package/dist/tsup/chunk-QUD664YZ.js +1810 -0
  78. package/dist/tsup/chunk-QUD664YZ.js.map +1 -0
  79. package/dist/tsup/chunk-RTOCTWME.js +1050 -0
  80. package/dist/tsup/chunk-RTOCTWME.js.map +1 -0
  81. package/dist/tsup/chunk-SAZZ4SB2.cjs +2657 -0
  82. package/dist/tsup/chunk-SAZZ4SB2.cjs.map +1 -0
  83. package/dist/tsup/chunk-SR3KQE7Q.cjs +72 -0
  84. package/dist/tsup/chunk-SR3KQE7Q.cjs.map +1 -0
  85. package/dist/tsup/chunk-V2GHLYC6.cjs +49 -0
  86. package/dist/tsup/chunk-V2GHLYC6.cjs.map +1 -0
  87. package/dist/tsup/chunk-V3WG7XTW.cjs +645 -0
  88. package/dist/tsup/chunk-V3WG7XTW.cjs.map +1 -0
  89. package/dist/tsup/chunk-VKVNIQRQ.js +257 -0
  90. package/dist/tsup/chunk-VKVNIQRQ.js.map +1 -0
  91. package/dist/tsup/chunk-WMPW7JYC.js +642 -0
  92. package/dist/tsup/chunk-WMPW7JYC.js.map +1 -0
  93. package/dist/tsup/chunk-Z7HNQ2WF.js +534 -0
  94. package/dist/tsup/chunk-Z7HNQ2WF.js.map +1 -0
  95. package/dist/tsup/chunk-ZFY5J2EP.cjs +257 -0
  96. package/dist/tsup/chunk-ZFY5J2EP.cjs.map +1 -0
  97. package/dist/tsup/client/mod.cjs +33 -0
  98. package/dist/tsup/client/mod.cjs.map +1 -0
  99. package/dist/tsup/client/mod.d.cts +64 -0
  100. package/dist/tsup/client/mod.d.ts +64 -0
  101. package/dist/tsup/client/mod.js +33 -0
  102. package/dist/tsup/client/mod.js.map +1 -0
  103. package/dist/tsup/common/log.cjs +21 -0
  104. package/dist/tsup/common/log.cjs.map +1 -0
  105. package/dist/tsup/common/log.d.cts +34 -0
  106. package/dist/tsup/common/log.d.ts +34 -0
  107. package/dist/tsup/common/log.js +21 -0
  108. package/dist/tsup/common/log.js.map +1 -0
  109. package/dist/tsup/common/websocket.cjs +10 -0
  110. package/dist/tsup/common/websocket.cjs.map +1 -0
  111. package/dist/tsup/common/websocket.d.cts +3 -0
  112. package/dist/tsup/common/websocket.d.ts +3 -0
  113. package/dist/tsup/common/websocket.js +10 -0
  114. package/dist/tsup/common/websocket.js.map +1 -0
  115. package/dist/tsup/config-BiNoIHRs.d.cts +80 -0
  116. package/dist/tsup/config-BiNoIHRs.d.ts +80 -0
  117. package/dist/tsup/config-P3XujgRr.d.ts +2594 -0
  118. package/dist/tsup/config-_gfywqqI.d.cts +2594 -0
  119. package/dist/tsup/context-Bxd8Cx4H.d.cts +75 -0
  120. package/dist/tsup/context-uNA4TRn3.d.ts +75 -0
  121. package/dist/tsup/db/drizzle/mod.cjs +49 -0
  122. package/dist/tsup/db/drizzle/mod.cjs.map +1 -0
  123. package/dist/tsup/db/drizzle/mod.d.cts +17 -0
  124. package/dist/tsup/db/drizzle/mod.d.ts +17 -0
  125. package/dist/tsup/db/drizzle/mod.js +49 -0
  126. package/dist/tsup/db/drizzle/mod.js.map +1 -0
  127. package/dist/tsup/db/mod.cjs +9 -0
  128. package/dist/tsup/db/mod.cjs.map +1 -0
  129. package/dist/tsup/db/mod.d.cts +9 -0
  130. package/dist/tsup/db/mod.d.ts +9 -0
  131. package/dist/tsup/db/mod.js +9 -0
  132. package/dist/tsup/db/mod.js.map +1 -0
  133. package/dist/tsup/driver-BcLvZcKl.d.cts +13 -0
  134. package/dist/tsup/driver-CPGHKXyh.d.ts +13 -0
  135. package/dist/tsup/driver-helpers/mod.cjs +53 -0
  136. package/dist/tsup/driver-helpers/mod.cjs.map +1 -0
  137. package/dist/tsup/driver-helpers/mod.d.cts +47 -0
  138. package/dist/tsup/driver-helpers/mod.d.ts +47 -0
  139. package/dist/tsup/driver-helpers/mod.js +53 -0
  140. package/dist/tsup/driver-helpers/mod.js.map +1 -0
  141. package/dist/tsup/driver-test-suite/mod.cjs +4974 -0
  142. package/dist/tsup/driver-test-suite/mod.cjs.map +1 -0
  143. package/dist/tsup/driver-test-suite/mod.d.cts +73 -0
  144. package/dist/tsup/driver-test-suite/mod.d.ts +73 -0
  145. package/dist/tsup/driver-test-suite/mod.js +4974 -0
  146. package/dist/tsup/driver-test-suite/mod.js.map +1 -0
  147. package/dist/tsup/inspector/mod.cjs +164 -0
  148. package/dist/tsup/inspector/mod.cjs.map +1 -0
  149. package/dist/tsup/inspector/mod.d.cts +130 -0
  150. package/dist/tsup/inspector/mod.d.ts +130 -0
  151. package/dist/tsup/inspector/mod.js +164 -0
  152. package/dist/tsup/inspector/mod.js.map +1 -0
  153. package/dist/tsup/keys-CydblqMh.d.cts +13 -0
  154. package/dist/tsup/keys-CydblqMh.d.ts +13 -0
  155. package/dist/tsup/mod.cjs +82 -0
  156. package/dist/tsup/mod.cjs.map +1 -0
  157. package/dist/tsup/mod.d.cts +126 -0
  158. package/dist/tsup/mod.d.ts +126 -0
  159. package/dist/tsup/mod.js +82 -0
  160. package/dist/tsup/mod.js.map +1 -0
  161. package/dist/tsup/serve-test-suite/mod.cjs +2601 -0
  162. package/dist/tsup/serve-test-suite/mod.cjs.map +1 -0
  163. package/dist/tsup/serve-test-suite/mod.d.cts +9 -0
  164. package/dist/tsup/serve-test-suite/mod.d.ts +9 -0
  165. package/dist/tsup/serve-test-suite/mod.js +2601 -0
  166. package/dist/tsup/serve-test-suite/mod.js.map +1 -0
  167. package/dist/tsup/test/mod.cjs +90 -0
  168. package/dist/tsup/test/mod.cjs.map +1 -0
  169. package/dist/tsup/test/mod.d.cts +26 -0
  170. package/dist/tsup/test/mod.d.ts +26 -0
  171. package/dist/tsup/test/mod.js +90 -0
  172. package/dist/tsup/test/mod.js.map +1 -0
  173. package/dist/tsup/utils-fwx3o3K9.d.cts +18 -0
  174. package/dist/tsup/utils-fwx3o3K9.d.ts +18 -0
  175. package/dist/tsup/utils.cjs +43 -0
  176. package/dist/tsup/utils.cjs.map +1 -0
  177. package/dist/tsup/utils.d.cts +148 -0
  178. package/dist/tsup/utils.d.ts +148 -0
  179. package/dist/tsup/utils.js +43 -0
  180. package/dist/tsup/utils.js.map +1 -0
  181. package/dist/tsup/v3-DnYObHH3.d.cts +279 -0
  182. package/dist/tsup/v3-DnYObHH3.d.ts +279 -0
  183. package/dist/tsup/workflow/mod.cjs +16 -0
  184. package/dist/tsup/workflow/mod.cjs.map +1 -0
  185. package/dist/tsup/workflow/mod.d.cts +25 -0
  186. package/dist/tsup/workflow/mod.d.ts +25 -0
  187. package/dist/tsup/workflow/mod.js +16 -0
  188. package/dist/tsup/workflow/mod.js.map +1 -0
  189. package/package.json +293 -5
  190. package/src/actor/config.ts +1221 -0
  191. package/src/actor/conn/driver.ts +61 -0
  192. package/src/actor/conn/drivers/http.ts +17 -0
  193. package/src/actor/conn/drivers/raw-request.ts +24 -0
  194. package/src/actor/conn/drivers/raw-websocket.ts +65 -0
  195. package/src/actor/conn/drivers/websocket.ts +144 -0
  196. package/src/actor/conn/mod.ts +288 -0
  197. package/src/actor/conn/persisted.ts +81 -0
  198. package/src/actor/conn/state-manager.ts +196 -0
  199. package/src/actor/contexts/action.ts +47 -0
  200. package/src/actor/contexts/base/actor.ts +347 -0
  201. package/src/actor/contexts/base/conn-init.ts +68 -0
  202. package/src/actor/contexts/base/conn.ts +73 -0
  203. package/src/actor/contexts/before-action-response.ts +42 -0
  204. package/src/actor/contexts/before-connect.ts +31 -0
  205. package/src/actor/contexts/connect.ts +42 -0
  206. package/src/actor/contexts/create-conn-state.ts +32 -0
  207. package/src/actor/contexts/create-vars.ts +39 -0
  208. package/src/actor/contexts/create.ts +39 -0
  209. package/src/actor/contexts/destroy.ts +42 -0
  210. package/src/actor/contexts/disconnect.ts +43 -0
  211. package/src/actor/contexts/index.ts +33 -0
  212. package/src/actor/contexts/request.ts +80 -0
  213. package/src/actor/contexts/run.ts +47 -0
  214. package/src/actor/contexts/sleep.ts +42 -0
  215. package/src/actor/contexts/state-change.ts +42 -0
  216. package/src/actor/contexts/wake.ts +42 -0
  217. package/src/actor/contexts/websocket.ts +80 -0
  218. package/src/actor/database.ts +13 -0
  219. package/src/actor/definition.ts +64 -0
  220. package/src/actor/driver.ts +114 -0
  221. package/src/actor/errors.ts +556 -0
  222. package/src/actor/instance/connection-manager.ts +574 -0
  223. package/src/actor/instance/event-manager.ts +314 -0
  224. package/src/actor/instance/keys.ts +146 -0
  225. package/src/actor/instance/kv.ts +241 -0
  226. package/src/actor/instance/mod.ts +1658 -0
  227. package/src/actor/instance/persisted.ts +67 -0
  228. package/src/actor/instance/queue-manager.ts +603 -0
  229. package/src/actor/instance/queue.ts +345 -0
  230. package/src/actor/instance/schedule-manager.ts +392 -0
  231. package/src/actor/instance/state-manager.ts +542 -0
  232. package/src/actor/instance/traces-driver.ts +128 -0
  233. package/src/actor/keys.test.ts +275 -0
  234. package/src/actor/keys.ts +89 -0
  235. package/src/actor/log.ts +6 -0
  236. package/src/actor/mod.ts +110 -0
  237. package/src/actor/protocol/old.ts +416 -0
  238. package/src/actor/protocol/serde.ts +222 -0
  239. package/src/actor/router-endpoints.ts +400 -0
  240. package/src/actor/router-websocket-endpoints.test.ts +54 -0
  241. package/src/actor/router-websocket-endpoints.ts +405 -0
  242. package/src/actor/router.ts +380 -0
  243. package/src/actor/schedule.ts +17 -0
  244. package/src/actor/schema.ts +291 -0
  245. package/src/actor/utils.test.ts +48 -0
  246. package/src/actor/utils.ts +158 -0
  247. package/src/client/actor-common.ts +32 -0
  248. package/src/client/actor-conn.ts +1262 -0
  249. package/src/client/actor-handle.ts +344 -0
  250. package/src/client/actor-query.ts +112 -0
  251. package/src/client/client.ts +558 -0
  252. package/src/client/config.ts +151 -0
  253. package/src/client/errors.ts +76 -0
  254. package/src/client/log.ts +5 -0
  255. package/src/client/mod.browser.ts +2 -0
  256. package/src/client/mod.ts +70 -0
  257. package/src/client/queue.ts +146 -0
  258. package/src/client/raw-utils.ts +149 -0
  259. package/src/client/test.ts +44 -0
  260. package/src/client/utils.ts +252 -0
  261. package/src/common/actor-router-consts.ts +59 -0
  262. package/src/common/cors.ts +57 -0
  263. package/src/common/eventsource-interface.ts +47 -0
  264. package/src/common/eventsource.ts +44 -0
  265. package/src/common/inline-websocket-adapter.ts +154 -0
  266. package/src/common/log-levels.ts +27 -0
  267. package/src/common/log.ts +229 -0
  268. package/src/common/logfmt.ts +221 -0
  269. package/src/common/network.ts +2 -0
  270. package/src/common/router.ts +174 -0
  271. package/src/common/utils.ts +339 -0
  272. package/src/common/websocket-interface.ts +7 -0
  273. package/src/common/websocket.ts +43 -0
  274. package/src/db/config.ts +100 -0
  275. package/src/db/drizzle/mod.ts +226 -0
  276. package/src/db/drizzle/sqlite-core.ts +22 -0
  277. package/src/db/mod.ts +125 -0
  278. package/src/db/shared.ts +92 -0
  279. package/src/db/sqlite-vfs.ts +12 -0
  280. package/src/devtools-loader/index.ts +33 -0
  281. package/src/devtools-loader/log.ts +5 -0
  282. package/src/driver-helpers/mod.ts +33 -0
  283. package/src/driver-helpers/utils.ts +54 -0
  284. package/src/driver-test-suite/log.ts +5 -0
  285. package/src/driver-test-suite/mod.ts +293 -0
  286. package/src/driver-test-suite/test-inline-client-driver.ts +307 -0
  287. package/src/driver-test-suite/tests/access-control.ts +218 -0
  288. package/src/driver-test-suite/tests/action-features.ts +203 -0
  289. package/src/driver-test-suite/tests/actor-conn-hibernation.ts +152 -0
  290. package/src/driver-test-suite/tests/actor-conn-state.ts +300 -0
  291. package/src/driver-test-suite/tests/actor-conn.ts +596 -0
  292. package/src/driver-test-suite/tests/actor-db-raw.ts +73 -0
  293. package/src/driver-test-suite/tests/actor-db.ts +477 -0
  294. package/src/driver-test-suite/tests/actor-destroy.ts +294 -0
  295. package/src/driver-test-suite/tests/actor-driver.ts +18 -0
  296. package/src/driver-test-suite/tests/actor-error-handling.ts +150 -0
  297. package/src/driver-test-suite/tests/actor-handle.ts +312 -0
  298. package/src/driver-test-suite/tests/actor-inline-client.ts +163 -0
  299. package/src/driver-test-suite/tests/actor-inspector.ts +264 -0
  300. package/src/driver-test-suite/tests/actor-kv.ts +65 -0
  301. package/src/driver-test-suite/tests/actor-metadata.ts +116 -0
  302. package/src/driver-test-suite/tests/actor-onstatechange.ts +95 -0
  303. package/src/driver-test-suite/tests/actor-queue.ts +325 -0
  304. package/src/driver-test-suite/tests/actor-run.ts +181 -0
  305. package/src/driver-test-suite/tests/actor-schedule.ts +97 -0
  306. package/src/driver-test-suite/tests/actor-sleep.ts +415 -0
  307. package/src/driver-test-suite/tests/actor-state.ts +54 -0
  308. package/src/driver-test-suite/tests/actor-stateless.ts +70 -0
  309. package/src/driver-test-suite/tests/actor-vars.ts +97 -0
  310. package/src/driver-test-suite/tests/actor-workflow.ts +118 -0
  311. package/src/driver-test-suite/tests/manager-driver.ts +388 -0
  312. package/src/driver-test-suite/tests/raw-http-direct-registry.ts +227 -0
  313. package/src/driver-test-suite/tests/raw-http-request-properties.ts +454 -0
  314. package/src/driver-test-suite/tests/raw-http.ts +359 -0
  315. package/src/driver-test-suite/tests/raw-websocket-direct-registry.ts +393 -0
  316. package/src/driver-test-suite/tests/raw-websocket.ts +513 -0
  317. package/src/driver-test-suite/tests/request-access.ts +240 -0
  318. package/src/driver-test-suite/utils.ts +80 -0
  319. package/src/drivers/default.ts +38 -0
  320. package/src/drivers/engine/actor-driver.ts +1027 -0
  321. package/src/drivers/engine/config.ts +43 -0
  322. package/src/drivers/engine/log.ts +5 -0
  323. package/src/drivers/engine/mod.ts +36 -0
  324. package/src/drivers/file-system/actor.ts +102 -0
  325. package/src/drivers/file-system/global-state.ts +1445 -0
  326. package/src/drivers/file-system/kv-limits.ts +70 -0
  327. package/src/drivers/file-system/log.ts +5 -0
  328. package/src/drivers/file-system/manager.ts +300 -0
  329. package/src/drivers/file-system/mod.ts +78 -0
  330. package/src/drivers/file-system/sqlite-runtime.ts +210 -0
  331. package/src/drivers/file-system/utils.ts +125 -0
  332. package/src/engine-process/constants.ts +2 -0
  333. package/src/engine-process/log.ts +5 -0
  334. package/src/engine-process/mod.ts +464 -0
  335. package/src/globals.d.ts +35 -0
  336. package/src/inspector/actor-inspector.ts +352 -0
  337. package/src/inspector/config.ts +49 -0
  338. package/src/inspector/handler.ts +273 -0
  339. package/src/inspector/log.ts +5 -0
  340. package/src/inspector/mod.browser.ts +8 -0
  341. package/src/inspector/mod.ts +4 -0
  342. package/src/inspector/serve-ui.ts +40 -0
  343. package/src/inspector/transport.ts +18 -0
  344. package/src/inspector/utils.ts +32 -0
  345. package/src/manager/driver.ts +106 -0
  346. package/src/manager/gateway.ts +668 -0
  347. package/src/manager/log.ts +5 -0
  348. package/src/manager/mod.ts +2 -0
  349. package/src/manager/protocol/mod.ts +22 -0
  350. package/src/manager/protocol/query.ts +85 -0
  351. package/src/manager/router-schema.ts +22 -0
  352. package/src/manager/router.ts +660 -0
  353. package/src/manager-api/actors.ts +83 -0
  354. package/src/manager-api/common.ts +4 -0
  355. package/src/mod.ts +24 -0
  356. package/src/registry/config/driver.ts +21 -0
  357. package/src/registry/config/index.ts +510 -0
  358. package/src/registry/config/legacy-runner.ts +157 -0
  359. package/src/registry/config/runner.ts +21 -0
  360. package/src/registry/config/serverless.ts +94 -0
  361. package/src/registry/index.ts +194 -0
  362. package/src/registry/log.ts +5 -0
  363. package/src/remote-manager-driver/actor-http-client.ts +84 -0
  364. package/src/remote-manager-driver/actor-websocket-client.ts +81 -0
  365. package/src/remote-manager-driver/api-endpoints.ts +159 -0
  366. package/src/remote-manager-driver/api-utils.ts +69 -0
  367. package/src/remote-manager-driver/log.ts +5 -0
  368. package/src/remote-manager-driver/metadata.ts +64 -0
  369. package/src/remote-manager-driver/mod.ts +414 -0
  370. package/src/remote-manager-driver/ws-proxy.ts +189 -0
  371. package/src/schemas/actor-inspector/mod.ts +1 -0
  372. package/src/schemas/actor-inspector/versioned.ts +233 -0
  373. package/src/schemas/actor-persist/mod.ts +1 -0
  374. package/src/schemas/actor-persist/versioned.ts +217 -0
  375. package/src/schemas/client-protocol/mod.ts +1 -0
  376. package/src/schemas/client-protocol/versioned.ts +330 -0
  377. package/src/schemas/client-protocol-zod/mod.ts +118 -0
  378. package/src/schemas/file-system-driver/mod.ts +1 -0
  379. package/src/schemas/file-system-driver/versioned.ts +135 -0
  380. package/src/schemas/persist/mod.ts +1 -0
  381. package/src/schemas/transport/mod.ts +1 -0
  382. package/src/serde.ts +138 -0
  383. package/src/serve-test-suite/mod.ts +148 -0
  384. package/src/serverless/configure.ts +82 -0
  385. package/src/serverless/log.ts +5 -0
  386. package/src/serverless/router.test.ts +299 -0
  387. package/src/serverless/router.ts +215 -0
  388. package/src/test/log.ts +5 -0
  389. package/src/test/mod.ts +99 -0
  390. package/src/utils/crypto.ts +24 -0
  391. package/src/utils/endpoint-parser.test.ts +202 -0
  392. package/src/utils/endpoint-parser.ts +124 -0
  393. package/src/utils/env-vars.ts +78 -0
  394. package/src/utils/node.ts +178 -0
  395. package/src/utils/router.ts +83 -0
  396. package/src/utils/serve.ts +212 -0
  397. package/src/utils.test.ts +34 -0
  398. package/src/utils.ts +437 -0
  399. package/src/workflow/constants.ts +2 -0
  400. package/src/workflow/context.ts +597 -0
  401. package/src/workflow/driver.ts +194 -0
  402. package/src/workflow/inspector.ts +268 -0
  403. package/src/workflow/mod.ts +128 -0
@@ -0,0 +1,2594 @@
1
+ import { z as z$1 } from 'zod/v4';
2
+ import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
3
+ import { A as AnyDatabaseProvider, D as DatabaseProvider, a as RawDatabaseClient } from './config-BiNoIHRs.js';
4
+ import { Traces, OtlpExportTraceServiceRequestJson, SpanHandle, SpanStatusInput } from '@rivetkit/traces';
5
+ import { Env, Context, Hono } from 'hono';
6
+ import { VersionedDataHandler } from 'vbare';
7
+ import { Logger } from 'pino';
8
+ import { GetUpgradeWebSocket } from './utils.js';
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';
13
+ import * as nanoevents from 'nanoevents';
14
+ import { W as WorkflowHistory, k as QueueStatus } from './v3-DnYObHH3.js';
15
+
16
+ type InferDatabaseClient<DBProvider extends AnyDatabaseProvider> = DBProvider extends DatabaseProvider<any> ? Awaited<ReturnType<DBProvider["createClient"]>> : never;
17
+
18
+ type ManagerDriverBuilder = (config: RegistryConfig) => ManagerDriver;
19
+ interface ManagerDriver {
20
+ getForId(input: GetForIdInput): Promise<ActorOutput | undefined>;
21
+ getWithKey(input: GetWithKeyInput): Promise<ActorOutput | undefined>;
22
+ getOrCreateWithKey(input: GetOrCreateWithKeyInput): Promise<ActorOutput>;
23
+ createActor(input: CreateInput): Promise<ActorOutput>;
24
+ listActors(input: ListActorsInput): Promise<ActorOutput[]>;
25
+ sendRequest(actorId: string, actorRequest: Request): Promise<Response>;
26
+ openWebSocket(path: string, actorId: string, encoding: Encoding, params: unknown): Promise<UniversalWebSocket>;
27
+ proxyRequest(c: Context, actorRequest: Request, actorId: string): Promise<Response>;
28
+ proxyWebSocket(c: Context, path: string, actorId: string, encoding: Encoding, params: unknown): Promise<Response>;
29
+ /**
30
+ * Build a public gateway URL for a specific actor.
31
+ *
32
+ * This lives on the driver because the base endpoint varies by runtime.
33
+ */
34
+ buildGatewayUrl(actorId: string): Promise<string>;
35
+ displayInformation(): ManagerDisplayInformation;
36
+ extraStartupLog?: () => Record<string, unknown>;
37
+ modifyManagerRouter?: (config: RegistryConfig, router: Hono) => void;
38
+ /**
39
+ * Allows lazily setting getUpgradeWebSocket after the manager router has
40
+ * been initialized.
41
+ **/
42
+ setGetUpgradeWebSocket(getUpgradeWebSocket: GetUpgradeWebSocket): void;
43
+ /** Read a key. Returns null if the key doesn't exist. */
44
+ kvGet(actorId: string, key: Uint8Array): Promise<string | null>;
45
+ }
46
+ interface ManagerDisplayInformation {
47
+ properties: Record<string, string>;
48
+ }
49
+ interface GetForIdInput<E extends Env = any> {
50
+ c?: Context | undefined;
51
+ name: string;
52
+ actorId: string;
53
+ }
54
+ interface GetWithKeyInput<E extends Env = any> {
55
+ c?: Context | undefined;
56
+ name: string;
57
+ key: ActorKey;
58
+ }
59
+ interface GetOrCreateWithKeyInput<E extends Env = any> {
60
+ c?: Context | undefined;
61
+ name: string;
62
+ key: ActorKey;
63
+ input?: unknown;
64
+ region?: string;
65
+ }
66
+ interface CreateInput<E extends Env = any> {
67
+ c?: Context | undefined;
68
+ name: string;
69
+ key: ActorKey;
70
+ input?: unknown;
71
+ region?: string;
72
+ }
73
+ interface ListActorsInput<E extends Env = any> {
74
+ c?: Context | undefined;
75
+ name: string;
76
+ key?: string;
77
+ includeDestroyed?: boolean;
78
+ }
79
+ interface ActorOutput {
80
+ actorId: string;
81
+ name: string;
82
+ key: ActorKey;
83
+ createTs?: number;
84
+ startTs?: number | null;
85
+ connectableTs?: number | null;
86
+ sleepTs?: number | null;
87
+ destroyTs?: number | null;
88
+ error?: unknown;
89
+ }
90
+
91
+ type ActorDriverBuilder = (config: RegistryConfig, managerDriver: ManagerDriver, inlineClient: AnyClient) => ActorDriver;
92
+ interface ActorDriver {
93
+ loadActor(actorId: string): Promise<AnyActorInstance>;
94
+ getContext(actorId: string): unknown;
95
+ /** Batch write multiple key-value pairs. Keys and values are Uint8Arrays. */
96
+ kvBatchPut(actorId: string, entries: [Uint8Array, Uint8Array][]): Promise<void>;
97
+ /** Batch read multiple keys. Returns null for keys that don't exist. */
98
+ kvBatchGet(actorId: string, keys: Uint8Array[]): Promise<(Uint8Array | null)[]>;
99
+ /** Batch delete multiple keys. */
100
+ kvBatchDelete(actorId: string, keys: Uint8Array[]): Promise<void>;
101
+ /** List all keys with a given prefix. */
102
+ kvListPrefix(actorId: string, prefix: Uint8Array): Promise<[Uint8Array, Uint8Array][]>;
103
+ /** ActorInstance ensure that only one instance of setAlarm is called in parallel at a time. */
104
+ setAlarm(actor: AnyActorInstance, timestamp: number): Promise<void>;
105
+ /**
106
+ * Override the default raw database client for the actor.
107
+ * If not provided, rivetkit will construct a KV-backed SQLite client.
108
+ * @experimental
109
+ */
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>;
128
+ /**
129
+ * Requests the actor to go to sleep.
130
+ *
131
+ * This will call `ActorInstance.onStop` independently.
132
+ */
133
+ startSleep?(actorId: string): void;
134
+ /**
135
+ * Destroys the actor and its associated data.
136
+ *
137
+ * This will call `ActorInstance.onStop` independently.
138
+ */
139
+ startDestroy(actorId: string): void;
140
+ /**
141
+ * Shuts down the actor runner.
142
+ */
143
+ shutdownRunner?(immediate: boolean): Promise<void>;
144
+ /** This handles the serverless start request. This should manage the lifecycle of the runner tied to the request lifecycle. */
145
+ serverlessHandleStart?(c: Context): Promise<Response>;
146
+ /** Extra properties to add to logs for each actor. */
147
+ getExtraActorLogParams?(): Record<string, string>;
148
+ onBeforeActorStart?(actor: AnyActorInstance): Promise<void>;
149
+ onCreateConn?(conn: AnyConn): void;
150
+ onDestroyConn?(conn: AnyConn): void;
151
+ onBeforePersistConn?(conn: AnyConn): void;
152
+ onAfterPersistConn?(conn: AnyConn): void;
153
+ }
154
+
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>>>;
156
+ type RegistryActors = z.infer<typeof ActorsSchema>;
157
+ declare const TestConfigSchema: z.ZodObject<{
158
+ enabled: z.ZodBoolean;
159
+ }, z.core.$strip>;
160
+ type TestConfig = z.infer<typeof TestConfigSchema>;
161
+ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
162
+ use: z.ZodRecord<z.ZodString, z.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
163
+ test: z.ZodDefault<z.ZodOptional<z.ZodObject<{
164
+ enabled: z.ZodBoolean;
165
+ }, z.core.$strip>>>;
166
+ driver: z.ZodOptional<z.ZodObject<{
167
+ name: z.ZodString;
168
+ displayName: z.ZodString;
169
+ manager: z.ZodCustom<ManagerDriverBuilder, ManagerDriverBuilder>;
170
+ actor: z.ZodCustom<ActorDriverBuilder, ActorDriverBuilder>;
171
+ autoStartActorDriver: z.ZodBoolean;
172
+ }, z.core.$strip>>;
173
+ storagePath: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | undefined, string | undefined>>;
174
+ maxIncomingMessageSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
175
+ maxOutgoingMessageSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
176
+ noWelcome: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
177
+ logging: z.ZodDefault<z.ZodOptional<z.ZodObject<{
178
+ baseLogger: z.ZodOptional<z.ZodCustom<Logger, Logger>>;
179
+ level: z.ZodOptional<z.ZodEnum<{
180
+ error: "error";
181
+ trace: "trace";
182
+ fatal: "fatal";
183
+ warn: "warn";
184
+ info: "info";
185
+ debug: "debug";
186
+ silent: "silent";
187
+ }>>;
188
+ }, z.core.$strip>>>;
189
+ endpoint: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | undefined, string | undefined>>;
190
+ token: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | undefined, string | undefined>>;
191
+ namespace: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | undefined, string | undefined>>;
192
+ headers: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
193
+ serveManager: z.ZodOptional<z.ZodBoolean>;
194
+ managerBasePath: z.ZodDefault<z.ZodOptional<z.ZodString>>;
195
+ managerPort: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
196
+ managerHost: z.ZodOptional<z.ZodString>;
197
+ inspector: z.ZodDefault<z.ZodOptional<z.ZodObject<{
198
+ enabled: z.ZodDefault<z.ZodBoolean>;
199
+ token: z.ZodDefault<z.ZodOptional<z.ZodCustom<() => string, () => string>>>;
200
+ defaultEndpoint: z.ZodOptional<z.ZodString>;
201
+ }, z.core.$strip>>>;
202
+ serverless: z.ZodDefault<z.ZodOptional<z.ZodObject<{
203
+ spawnEngine: z.ZodDefault<z.ZodBoolean>;
204
+ engineVersion: z.ZodDefault<z.ZodOptional<z.ZodString>>;
205
+ configureRunnerPool: z.ZodOptional<z.ZodOptional<z.ZodObject<{
206
+ name: z.ZodOptional<z.ZodString>;
207
+ url: z.ZodString;
208
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
209
+ maxRunners: z.ZodOptional<z.ZodNumber>;
210
+ minRunners: z.ZodOptional<z.ZodNumber>;
211
+ requestLifespan: z.ZodOptional<z.ZodNumber>;
212
+ runnersMargin: z.ZodOptional<z.ZodNumber>;
213
+ slotsPerRunner: z.ZodOptional<z.ZodNumber>;
214
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
215
+ metadataPollInterval: z.ZodOptional<z.ZodNumber>;
216
+ drainOnVersionUpgrade: z.ZodOptional<z.ZodBoolean>;
217
+ }, z.core.$strip>>>;
218
+ basePath: z.ZodDefault<z.ZodOptional<z.ZodString>>;
219
+ publicEndpoint: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | undefined, string | undefined>>;
220
+ publicToken: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | undefined, string | undefined>>;
221
+ }, z.core.$strip>>>;
222
+ runner: z.ZodDefault<z.ZodOptional<z.ZodObject<{
223
+ totalSlots: z.ZodDefault<z.ZodNumber>;
224
+ runnerName: z.ZodDefault<z.ZodString>;
225
+ runnerKey: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | undefined, string | undefined>>;
226
+ version: z.ZodDefault<z.ZodNumber>;
227
+ }, z.core.$strip>>>;
228
+ }, z.core.$strip>, z.ZodTransform<{
229
+ endpoint: string | undefined;
230
+ namespace: string;
231
+ token: string | undefined;
232
+ serveManager: boolean;
233
+ publicEndpoint: string | undefined;
234
+ publicNamespace: string | undefined;
235
+ publicToken: string | undefined;
236
+ inspector: {
237
+ enabled: boolean;
238
+ token: () => string;
239
+ defaultEndpoint?: string | undefined;
240
+ } | {
241
+ enabled: {
242
+ manager: boolean;
243
+ actor: boolean;
244
+ };
245
+ token: () => string;
246
+ defaultEndpoint?: string | undefined;
247
+ };
248
+ serverless: {
249
+ publicEndpoint: string | undefined;
250
+ spawnEngine: boolean;
251
+ engineVersion: string;
252
+ basePath: string;
253
+ publicToken: string | undefined;
254
+ configureRunnerPool?: {
255
+ url: string;
256
+ name?: string | undefined;
257
+ headers?: Record<string, string> | undefined;
258
+ maxRunners?: number | undefined;
259
+ minRunners?: number | undefined;
260
+ requestLifespan?: number | undefined;
261
+ runnersMargin?: number | undefined;
262
+ slotsPerRunner?: number | undefined;
263
+ metadata?: Record<string, unknown> | undefined;
264
+ metadataPollInterval?: number | undefined;
265
+ drainOnVersionUpgrade?: boolean | undefined;
266
+ } | undefined;
267
+ };
268
+ use: Record<string, AnyActorDefinition>;
269
+ test: {
270
+ enabled: boolean;
271
+ };
272
+ storagePath: string | undefined;
273
+ maxIncomingMessageSize: number;
274
+ maxOutgoingMessageSize: number;
275
+ noWelcome: boolean;
276
+ logging: {
277
+ baseLogger?: Logger | undefined;
278
+ level?: "error" | "trace" | "fatal" | "warn" | "info" | "debug" | "silent" | undefined;
279
+ };
280
+ headers: Record<string, string>;
281
+ managerBasePath: string;
282
+ managerPort: number;
283
+ runner: {
284
+ totalSlots: number;
285
+ runnerName: string;
286
+ runnerKey: string | undefined;
287
+ version: number;
288
+ };
289
+ driver?: {
290
+ name: string;
291
+ displayName: string;
292
+ manager: ManagerDriverBuilder;
293
+ actor: ActorDriverBuilder;
294
+ autoStartActorDriver: boolean;
295
+ } | undefined;
296
+ managerHost?: string | undefined;
297
+ }, {
298
+ use: Record<string, AnyActorDefinition>;
299
+ test: {
300
+ enabled: boolean;
301
+ };
302
+ storagePath: string | undefined;
303
+ maxIncomingMessageSize: number;
304
+ maxOutgoingMessageSize: number;
305
+ noWelcome: boolean;
306
+ logging: {
307
+ baseLogger?: Logger | undefined;
308
+ level?: "error" | "trace" | "fatal" | "warn" | "info" | "debug" | "silent" | undefined;
309
+ };
310
+ endpoint: string | undefined;
311
+ token: string | undefined;
312
+ namespace: string | undefined;
313
+ headers: Record<string, string>;
314
+ managerBasePath: string;
315
+ managerPort: number;
316
+ inspector: {
317
+ enabled: boolean;
318
+ token: () => string;
319
+ defaultEndpoint?: string | undefined;
320
+ };
321
+ serverless: {
322
+ spawnEngine: boolean;
323
+ engineVersion: string;
324
+ basePath: string;
325
+ publicEndpoint: string | undefined;
326
+ publicToken: string | undefined;
327
+ configureRunnerPool?: {
328
+ url: string;
329
+ name?: string | undefined;
330
+ headers?: Record<string, string> | undefined;
331
+ maxRunners?: number | undefined;
332
+ minRunners?: number | undefined;
333
+ requestLifespan?: number | undefined;
334
+ runnersMargin?: number | undefined;
335
+ slotsPerRunner?: number | undefined;
336
+ metadata?: Record<string, unknown> | undefined;
337
+ metadataPollInterval?: number | undefined;
338
+ drainOnVersionUpgrade?: boolean | undefined;
339
+ } | undefined;
340
+ };
341
+ runner: {
342
+ totalSlots: number;
343
+ runnerName: string;
344
+ runnerKey: string | undefined;
345
+ version: number;
346
+ };
347
+ driver?: {
348
+ name: string;
349
+ displayName: string;
350
+ manager: ManagerDriverBuilder;
351
+ actor: ActorDriverBuilder;
352
+ autoStartActorDriver: boolean;
353
+ } | undefined;
354
+ serveManager?: boolean | undefined;
355
+ managerHost?: string | undefined;
356
+ }>>;
357
+ type RegistryConfig = z.infer<typeof RegistryConfigSchema>;
358
+ type RegistryConfigInput<A extends RegistryActors> = Omit<z.input<typeof RegistryConfigSchema>, "use"> & {
359
+ use: A;
360
+ };
361
+ declare function buildActorNames(config: RegistryConfig): Record<string, {
362
+ metadata: Record<string, unknown>;
363
+ }>;
364
+ declare const DocInspectorConfigSchema: z.ZodOptional<z.ZodObject<{
365
+ enabled: z.ZodOptional<z.ZodBoolean>;
366
+ token: z.ZodOptional<z.ZodString>;
367
+ defaultEndpoint: z.ZodOptional<z.ZodString>;
368
+ }, z.core.$strip>>;
369
+ declare const DocConfigureRunnerPoolSchema: z.ZodOptional<z.ZodObject<{
370
+ name: z.ZodOptional<z.ZodString>;
371
+ url: z.ZodString;
372
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
373
+ maxRunners: z.ZodOptional<z.ZodNumber>;
374
+ minRunners: z.ZodOptional<z.ZodNumber>;
375
+ requestLifespan: z.ZodOptional<z.ZodNumber>;
376
+ runnersMargin: z.ZodOptional<z.ZodNumber>;
377
+ slotsPerRunner: z.ZodOptional<z.ZodNumber>;
378
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
379
+ metadataPollInterval: z.ZodOptional<z.ZodNumber>;
380
+ }, z.core.$strip>>;
381
+ declare const DocServerlessConfigSchema: z.ZodObject<{
382
+ spawnEngine: z.ZodOptional<z.ZodBoolean>;
383
+ engineVersion: z.ZodOptional<z.ZodString>;
384
+ configureRunnerPool: z.ZodOptional<z.ZodObject<{
385
+ name: z.ZodOptional<z.ZodString>;
386
+ url: z.ZodString;
387
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
388
+ maxRunners: z.ZodOptional<z.ZodNumber>;
389
+ minRunners: z.ZodOptional<z.ZodNumber>;
390
+ requestLifespan: z.ZodOptional<z.ZodNumber>;
391
+ runnersMargin: z.ZodOptional<z.ZodNumber>;
392
+ slotsPerRunner: z.ZodOptional<z.ZodNumber>;
393
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
394
+ metadataPollInterval: z.ZodOptional<z.ZodNumber>;
395
+ }, z.core.$strip>>;
396
+ basePath: z.ZodOptional<z.ZodString>;
397
+ publicEndpoint: z.ZodOptional<z.ZodString>;
398
+ publicToken: z.ZodOptional<z.ZodString>;
399
+ }, z.core.$strip>;
400
+ declare const DocRunnerConfigSchema: z.ZodObject<{
401
+ totalSlots: z.ZodOptional<z.ZodNumber>;
402
+ runnerName: z.ZodOptional<z.ZodString>;
403
+ runnerKey: z.ZodOptional<z.ZodString>;
404
+ version: z.ZodOptional<z.ZodNumber>;
405
+ }, z.core.$strip>;
406
+ declare const DocRegistryConfigSchema: z.ZodObject<{
407
+ use: z.ZodRecord<z.ZodString, z.ZodUnknown>;
408
+ storagePath: z.ZodOptional<z.ZodString>;
409
+ maxIncomingMessageSize: z.ZodOptional<z.ZodNumber>;
410
+ maxOutgoingMessageSize: z.ZodOptional<z.ZodNumber>;
411
+ noWelcome: z.ZodOptional<z.ZodBoolean>;
412
+ logging: z.ZodOptional<z.ZodObject<{
413
+ level: z.ZodOptional<z.ZodEnum<{
414
+ error: "error";
415
+ trace: "trace";
416
+ fatal: "fatal";
417
+ warn: "warn";
418
+ info: "info";
419
+ debug: "debug";
420
+ silent: "silent";
421
+ }>>;
422
+ }, z.core.$strip>>;
423
+ endpoint: z.ZodOptional<z.ZodString>;
424
+ token: z.ZodOptional<z.ZodString>;
425
+ namespace: z.ZodOptional<z.ZodString>;
426
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
427
+ serveManager: z.ZodOptional<z.ZodBoolean>;
428
+ managerBasePath: z.ZodOptional<z.ZodString>;
429
+ managerPort: z.ZodOptional<z.ZodNumber>;
430
+ inspector: z.ZodOptional<z.ZodObject<{
431
+ enabled: z.ZodOptional<z.ZodBoolean>;
432
+ token: z.ZodOptional<z.ZodString>;
433
+ defaultEndpoint: z.ZodOptional<z.ZodString>;
434
+ }, z.core.$strip>>;
435
+ serverless: z.ZodOptional<z.ZodObject<{
436
+ spawnEngine: z.ZodOptional<z.ZodBoolean>;
437
+ engineVersion: z.ZodOptional<z.ZodString>;
438
+ configureRunnerPool: z.ZodOptional<z.ZodObject<{
439
+ name: z.ZodOptional<z.ZodString>;
440
+ url: z.ZodString;
441
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
442
+ maxRunners: z.ZodOptional<z.ZodNumber>;
443
+ minRunners: z.ZodOptional<z.ZodNumber>;
444
+ requestLifespan: z.ZodOptional<z.ZodNumber>;
445
+ runnersMargin: z.ZodOptional<z.ZodNumber>;
446
+ slotsPerRunner: z.ZodOptional<z.ZodNumber>;
447
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
448
+ metadataPollInterval: z.ZodOptional<z.ZodNumber>;
449
+ }, z.core.$strip>>;
450
+ basePath: z.ZodOptional<z.ZodString>;
451
+ publicEndpoint: z.ZodOptional<z.ZodString>;
452
+ publicToken: z.ZodOptional<z.ZodString>;
453
+ }, z.core.$strip>>;
454
+ runner: z.ZodOptional<z.ZodObject<{
455
+ totalSlots: z.ZodOptional<z.ZodNumber>;
456
+ runnerName: z.ZodOptional<z.ZodString>;
457
+ runnerKey: z.ZodOptional<z.ZodString>;
458
+ version: z.ZodOptional<z.ZodNumber>;
459
+ }, z.core.$strip>>;
460
+ }, z.core.$strip>;
461
+
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>> {
515
+ #private;
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>;
519
+ }
520
+ declare function lookupInRegistry(config: RegistryConfig, name: string): AnyActorDefinition;
521
+
522
+ /** Data that's been serialized. */
523
+ type OutputData = string | Uint8Array;
524
+ declare const EncodingSchema: z$1.ZodEnum<{
525
+ json: "json";
526
+ cbor: "cbor";
527
+ bare: "bare";
528
+ }>;
529
+ /**
530
+ * Encoding used to communicate between the client & actor.
531
+ */
532
+ type Encoding = z$1.infer<typeof EncodingSchema>;
533
+ /**
534
+ * Helper class that helps serialize data without re-serializing for the same encoding.
535
+ */
536
+ declare class CachedSerializer<TBare, TJson, T = TBare> {
537
+ #private;
538
+ constructor(data: T, versionedDataHandler: VersionedDataHandler<TBare>, version: number, zodSchema: z$1.ZodType<TJson>, toJson: (value: T) => TJson, toBare: (value: T) => TBare);
539
+ get rawData(): T;
540
+ serialize(encoding: Encoding): OutputData;
541
+ }
542
+
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<{
563
+ serverless: "serverless";
564
+ normal: "normal";
565
+ }>>>;
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<{
571
+ error: "error";
572
+ trace: "trace";
573
+ fatal: "fatal";
574
+ warn: "warn";
575
+ info: "info";
576
+ debug: "debug";
577
+ silent: "silent";
578
+ }>>;
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<{
595
+ json: "json";
596
+ cbor: "cbor";
597
+ bare: "bare";
598
+ }>>;
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<{
606
+ runnerKey: string | undefined;
607
+ endpoint: string | undefined;
608
+ namespace: string;
609
+ token: string | undefined;
610
+ runnerName: string;
611
+ encoding: "json" | "cbor" | "bare";
612
+ headers: Record<string, string>;
613
+ disableMetadataLookup: boolean;
614
+ devtools: boolean;
615
+ getUpgradeWebSocket?: GetUpgradeWebSocket | undefined;
616
+ maxIncomingMessageSize: number;
617
+ maxOutgoingMessageSize: number;
618
+ inspector: {
619
+ enabled: boolean;
620
+ token: () => string;
621
+ defaultEndpoint?: string | undefined;
622
+ };
623
+ disableDefaultServer: boolean;
624
+ defaultServerPort: number;
625
+ runEngine: boolean;
626
+ runEngineVersion: string;
627
+ disableActorDriver: boolean;
628
+ runnerKind: "serverless" | "normal";
629
+ basePath: string;
630
+ noWelcome: boolean;
631
+ logging: {
632
+ baseLogger?: Logger | undefined;
633
+ level?: "error" | "trace" | "fatal" | "warn" | "info" | "debug" | "silent" | undefined;
634
+ };
635
+ totalSlots: number;
636
+ driver?: {
637
+ name: string;
638
+ manager: ManagerDriverBuilder;
639
+ actor: ActorDriverBuilder;
640
+ } | undefined;
641
+ overrideServerAddress?: string | undefined;
642
+ autoConfigureServerless?: boolean | {
643
+ url?: string | undefined;
644
+ headers?: Record<string, string> | undefined;
645
+ maxRunners?: number | undefined;
646
+ minRunners?: number | undefined;
647
+ requestLifespan?: number | undefined;
648
+ runnersMargin?: number | undefined;
649
+ slotsPerRunner?: number | undefined;
650
+ metadata?: Record<string, unknown> | undefined;
651
+ } | undefined;
652
+ }, {
653
+ maxIncomingMessageSize: number;
654
+ maxOutgoingMessageSize: number;
655
+ inspector: {
656
+ enabled: boolean;
657
+ token: () => string;
658
+ defaultEndpoint?: string | undefined;
659
+ };
660
+ disableDefaultServer: boolean;
661
+ defaultServerPort: number;
662
+ runEngine: boolean;
663
+ runEngineVersion: string;
664
+ disableActorDriver: boolean;
665
+ runnerKind: "serverless" | "normal";
666
+ basePath: string;
667
+ noWelcome: boolean;
668
+ logging: {
669
+ baseLogger?: Logger | undefined;
670
+ level?: "error" | "trace" | "fatal" | "warn" | "info" | "debug" | "silent" | undefined;
671
+ };
672
+ endpoint: string;
673
+ token: string | undefined;
674
+ namespace: string | undefined;
675
+ runnerName: string;
676
+ encoding: "json" | "cbor" | "bare";
677
+ headers: Record<string, string>;
678
+ disableMetadataLookup: boolean;
679
+ devtools: boolean;
680
+ runnerKey: string | undefined;
681
+ totalSlots: number;
682
+ driver?: {
683
+ name: string;
684
+ manager: ManagerDriverBuilder;
685
+ actor: ActorDriverBuilder;
686
+ } | undefined;
687
+ overrideServerAddress?: string | undefined;
688
+ autoConfigureServerless?: boolean | {
689
+ url?: string | undefined;
690
+ headers?: Record<string, string> | undefined;
691
+ maxRunners?: number | undefined;
692
+ minRunners?: number | undefined;
693
+ requestLifespan?: number | undefined;
694
+ runnersMargin?: number | undefined;
695
+ slotsPerRunner?: number | undefined;
696
+ metadata?: Record<string, unknown> | undefined;
697
+ } | undefined;
698
+ getUpgradeWebSocket?: GetUpgradeWebSocket | undefined;
699
+ }>>>;
700
+ type LegacyRunnerConfigInput = z$1.input<typeof LegacyRunnerConfigSchema>;
701
+
702
+ type FetchHandler = (request: Request, ...args: any) => Response | Promise<Response>;
703
+ interface ServerlessHandler {
704
+ fetch: FetchHandler;
705
+ }
706
+ interface LegacyStartServerOutput<A extends Registry<any>> {
707
+ /** Client to communicate with the actors. */
708
+ client: Client<A>;
709
+ /** Fetch handler to manually route requests to the Rivet manager API. */
710
+ fetch: FetchHandler;
711
+ }
712
+ declare class Registry<A extends RegistryActors> {
713
+ #private;
714
+ get config(): RegistryConfigInput<A>;
715
+ parseConfig(): RegistryConfig;
716
+ constructor(config: RegistryConfigInput<A>);
717
+ /**
718
+ * Handle an incoming HTTP request for serverless deployments.
719
+ *
720
+ * @example
721
+ * ```ts
722
+ * const app = new Hono();
723
+ * app.all("/api/rivet/*", (c) => registry.handler(c.req.raw));
724
+ * export default app;
725
+ * ```
726
+ */
727
+ handler(request: Request): Promise<Response>;
728
+ /**
729
+ * Returns a fetch handler for serverless deployments.
730
+ *
731
+ * @example
732
+ * ```ts
733
+ * export default registry.serve();
734
+ * ```
735
+ */
736
+ serve(): ServerlessHandler;
737
+ /**
738
+ * Starts an actor runner for standalone server deployments.
739
+ */
740
+ startRunner(): void;
741
+ /**
742
+ * Runs the registry for a server.
743
+ *
744
+ * @deprecated Use {@link Registry.startRunner} for long-running servers or {@link Registry.handler} for serverless deployments.
745
+ */
746
+ start(inputConfig?: LegacyRunnerConfigInput): LegacyStartServerOutput<this>;
747
+ }
748
+ declare function setup<A extends RegistryActors>(input: RegistryConfigInput<A>): Registry<A>;
749
+
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>;
784
+ /**
785
+ * Interface representing a request to create a actor.
786
+ */
787
+ type CreateRequest = z$1.infer<typeof CreateRequestSchema>;
788
+
789
+ /**
790
+ * Action function returned by Actor connections and handles.
791
+ *
792
+ * @typedef {Function} ActorActionFunction
793
+ * @template Args
794
+ * @template Response
795
+ * @param {...Args} args - Arguments for the action function.
796
+ * @returns {Promise<Response>}
797
+ */
798
+ type ActorActionFunction<Args extends Array<unknown> = unknown[], Response = unknown> = (...args: Args extends [unknown, ...infer Rest] ? Rest : Args) => Promise<Response>;
799
+ /**
800
+ * Maps action methods from actor definition to typed function signatures.
801
+ */
802
+ type ActorDefinitionActions<AD extends AnyActorDefinition> = AD extends ActorDefinition<any, any, any, any, any, any, any, any, infer R> ? {
803
+ [K in keyof R]: R[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Return> : never;
804
+ } : never;
805
+
806
+ declare class ActorClientError extends Error {
807
+ }
808
+ declare class InternalError extends ActorClientError {
809
+ }
810
+ declare class ManagerError extends ActorClientError {
811
+ constructor(error: string, opts?: ErrorOptions);
812
+ }
813
+ declare class MalformedResponseMessage extends ActorClientError {
814
+ constructor(cause?: unknown);
815
+ }
816
+ declare class ActorError extends ActorClientError {
817
+ readonly group: string;
818
+ readonly code: string;
819
+ readonly metadata?: unknown | undefined;
820
+ __type: string;
821
+ constructor(group: string, code: string, message: string, metadata?: unknown | undefined);
822
+ }
823
+ declare class ActorConnDisposed extends ActorClientError {
824
+ constructor();
825
+ }
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
+
842
+ /**
843
+ * Connection status for an actor connection.
844
+ *
845
+ * - `"idle"`: Not connected, no auto-reconnect (initial state, after dispose, or disabled)
846
+ * - `"connecting"`: Attempting to establish connection
847
+ * - `"connected"`: Connection is active
848
+ * - `"disconnected"`: Connection was lost, will auto-reconnect
849
+ */
850
+ type ActorConnStatus = "idle" | "connecting" | "connected" | "disconnected";
851
+ /**
852
+ * A function that unsubscribes from an event.
853
+ *
854
+ * @typedef {Function} EventUnsubscribe
855
+ */
856
+ type EventUnsubscribe = () => void;
857
+ /**
858
+ * A function that handles connection errors.
859
+ *
860
+ * @typedef {Function} ActorErrorCallback
861
+ */
862
+ type ActorErrorCallback = (error: ActorError) => void;
863
+ /**
864
+ * A callback for connection state changes.
865
+ *
866
+ * @typedef {Function} ConnectionStateCallback
867
+ */
868
+ type ConnectionStateCallback = () => void;
869
+ /**
870
+ * A callback for connection status changes.
871
+ *
872
+ * @typedef {Function} StatusChangeCallback
873
+ */
874
+ type StatusChangeCallback = (status: ActorConnStatus) => void;
875
+ declare const CONNECT_SYMBOL: unique symbol;
876
+ /**
877
+ * Provides underlying functions for {@link ActorConn}. See {@link ActorConn} for using type-safe remote procedure calls.
878
+ *
879
+ * @see {@link ActorConn}
880
+ */
881
+ declare class ActorConnRaw {
882
+ #private;
883
+ /**
884
+ * Do not call this directly.
885
+ *
886
+ * Creates an instance of ActorConnRaw.
887
+ *
888
+ * @protected
889
+ */
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>;
893
+ /**
894
+ * Call a raw action connection. See {@link ActorConn} for type-safe action calls.
895
+ *
896
+ * @see {@link ActorConn}
897
+ * @template Args - The type of arguments to pass to the action function.
898
+ * @template Response - The type of the response returned by the action function.
899
+ * @param {string} name - The name of the action function to call.
900
+ * @param {...Args} args - The arguments to pass to the action function.
901
+ * @returns {Promise<Response>} - A promise that resolves to the response of the action function.
902
+ */
903
+ action<Args extends Array<unknown> = unknown[], Response = unknown>(opts: {
904
+ name: string;
905
+ args: Args;
906
+ signal?: AbortSignal;
907
+ }): Promise<Response>;
908
+ /**
909
+ * Do not call this directly.
910
+ * Establishes a connection to the server using the specified endpoint & encoding & driver.
911
+ *
912
+ * @protected
913
+ */
914
+ [CONNECT_SYMBOL](): void;
915
+ /**
916
+ * Subscribes to an event that will happen repeatedly.
917
+ *
918
+ * @template Args - The type of arguments the event callback will receive.
919
+ * @param {string} eventName - The name of the event to subscribe to.
920
+ * @param {(...args: Args) => void} callback - The callback function to execute when the event is triggered.
921
+ * @returns {EventUnsubscribe} - A function to unsubscribe from the event.
922
+ * @see {@link https://rivet.dev/docs/events|Events Documentation}
923
+ */
924
+ on<Args extends Array<unknown> = unknown[]>(eventName: string, callback: (...args: Args) => void): EventUnsubscribe;
925
+ /**
926
+ * Subscribes to an event that will be triggered only once.
927
+ *
928
+ * @template Args - The type of arguments the event callback will receive.
929
+ * @param {string} eventName - The name of the event to subscribe to.
930
+ * @param {(...args: Args) => void} callback - The callback function to execute when the event is triggered.
931
+ * @returns {EventUnsubscribe} - A function to unsubscribe from the event.
932
+ * @see {@link https://rivet.dev/docs/events|Events Documentation}
933
+ */
934
+ once<Args extends Array<unknown> = unknown[]>(eventName: string, callback: (...args: Args) => void): EventUnsubscribe;
935
+ /**
936
+ * Subscribes to connection errors.
937
+ *
938
+ * @param {ActorErrorCallback} callback - The callback function to execute when a connection error occurs.
939
+ * @returns {() => void} - A function to unsubscribe from the error handler.
940
+ */
941
+ onError(callback: ActorErrorCallback): () => void;
942
+ /**
943
+ * Returns the current connection status.
944
+ *
945
+ * @returns {ActorConnStatus} - The current connection status.
946
+ */
947
+ get connStatus(): ActorConnStatus;
948
+ /**
949
+ * Returns whether the connection is currently open.
950
+ *
951
+ * @deprecated Use `connStatus` instead.
952
+ * @returns {boolean} - True if the connection is open, false otherwise.
953
+ */
954
+ get isConnected(): boolean;
955
+ /**
956
+ * Subscribes to connection open events.
957
+ *
958
+ * This is called when the WebSocket connection is established and the Init message is received.
959
+ *
960
+ * @param {ConnectionStateCallback} callback - The callback function to execute when the connection opens.
961
+ * @returns {() => void} - A function to unsubscribe from the open handler.
962
+ */
963
+ onOpen(callback: ConnectionStateCallback): () => void;
964
+ /**
965
+ * Subscribes to connection close events.
966
+ *
967
+ * This is called when the WebSocket connection is closed. The connection will automatically
968
+ * attempt to reconnect unless disposed.
969
+ *
970
+ * @param {ConnectionStateCallback} callback - The callback function to execute when the connection closes.
971
+ * @returns {() => void} - A function to unsubscribe from the close handler.
972
+ */
973
+ onClose(callback: ConnectionStateCallback): () => void;
974
+ /**
975
+ * Subscribes to connection status changes.
976
+ *
977
+ * This is called whenever the connection status changes between Disconnected, Connecting, and Connected.
978
+ *
979
+ * @param {StatusChangeCallback} callback - The callback function to execute when the status changes.
980
+ * @returns {() => void} - A function to unsubscribe from the status change handler.
981
+ */
982
+ onStatusChange(callback: StatusChangeCallback): () => void;
983
+ /**
984
+ * Disconnects from the actor.
985
+ *
986
+ * @returns {Promise<void>} A promise that resolves when the socket is gracefully closed.
987
+ */
988
+ dispose(): Promise<void>;
989
+ }
990
+ /**
991
+ * Connection to a actor. Allows calling actor's remote procedure calls with inferred types. See {@link ActorConnRaw} for underlying methods.
992
+ *
993
+ * @example
994
+ * ```
995
+ * const room = client.connect<ChatRoom>(...etc...);
996
+ * // This calls the action named `sendMessage` on the `ChatRoom` actor.
997
+ * await room.sendMessage('Hello, world!');
998
+ * ```
999
+ *
1000
+ * Private methods (e.g. those starting with `_`) are automatically excluded.
1001
+ *
1002
+ * @template AD The actor class that this connection is for.
1003
+ * @see {@link ActorConnRaw}
1004
+ */
1005
+ type ActorConn<AD extends AnyActorDefinition> = ActorConnRaw & ActorDefinitionActions<AD>;
1006
+
1007
+ /**
1008
+ * Provides underlying functions for stateless {@link ActorHandle} for action calls.
1009
+ * Similar to ActorConnRaw but doesn't maintain a connection.
1010
+ *
1011
+ * @see {@link ActorHandle}
1012
+ */
1013
+ declare class ActorHandleRaw {
1014
+ #private;
1015
+ /**
1016
+ * Do not call this directly.
1017
+ *
1018
+ * Creates an instance of ActorHandleRaw.
1019
+ *
1020
+ * @protected
1021
+ */
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>;
1025
+ /**
1026
+ * Call a raw action. This method sends an HTTP request to invoke the named action.
1027
+ *
1028
+ * @see {@link ActorHandle}
1029
+ * @template Args - The type of arguments to pass to the action function.
1030
+ * @template Response - The type of the response returned by the action function.
1031
+ */
1032
+ action<Args extends Array<unknown> = unknown[], Response = unknown>(opts: {
1033
+ name: string;
1034
+ args: Args;
1035
+ signal?: AbortSignal;
1036
+ }): Promise<Response>;
1037
+ /**
1038
+ * Establishes a persistent connection to the actor.
1039
+ *
1040
+ * @template AD The actor class that this connection is for.
1041
+ * @returns {ActorConn<AD>} A connection to the actor.
1042
+ */
1043
+ connect(): ActorConn<AnyActorDefinition>;
1044
+ /**
1045
+ * Fetches a resource from this actor via the /request endpoint. This is a
1046
+ * convenience wrapper around the raw HTTP API.
1047
+ */
1048
+ fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
1049
+ /**
1050
+ * Opens a raw WebSocket connection to this actor.
1051
+ */
1052
+ webSocket(path?: string, protocols?: string | string[]): Promise<any>;
1053
+ /**
1054
+ * Resolves the actor to get its unique actor ID.
1055
+ */
1056
+ resolve(): Promise<string>;
1057
+ /**
1058
+ * Returns the raw URL for routing traffic to the actor.
1059
+ */
1060
+ getGatewayUrl(): Promise<string>;
1061
+ }
1062
+ /**
1063
+ * Stateless handle to a actor. Allows calling actor's remote procedure calls with inferred types
1064
+ * without establishing a persistent connection.
1065
+ *
1066
+ * @example
1067
+ * ```
1068
+ * const room = client.get<ChatRoom>(...etc...);
1069
+ * // This calls the action named `sendMessage` on the `ChatRoom` actor without a connection.
1070
+ * await room.sendMessage('Hello, world!');
1071
+ * ```
1072
+ *
1073
+ * Private methods (e.g. those starting with `_`) are automatically excluded.
1074
+ *
1075
+ * @template AD The actor class that this handle is for.
1076
+ * @see {@link ActorHandleRaw}
1077
+ */
1078
+ type ActorHandle<AD extends AnyActorDefinition> = Omit<ActorHandleRaw, "connect"> & {
1079
+ connect(): ActorConn<AD>;
1080
+ resolve(): Promise<string>;
1081
+ } & ActorDefinitionActions<AD>;
1082
+
1083
+ /** Extract the actor registry from the registry definition. */
1084
+ type ExtractActorsFromRegistry<A extends Registry<any>> = A extends Registry<infer Actors> ? Actors : never;
1085
+ /** Extract the registry definition from the client. */
1086
+ type ExtractRegistryFromClient<C extends Client<Registry<{}>>> = C extends Client<infer A> ? A : never;
1087
+ /**
1088
+ * Represents a actor accessor that provides methods to interact with a specific actor.
1089
+ */
1090
+ interface ActorAccessor<AD extends AnyActorDefinition> {
1091
+ /**
1092
+ * Gets a stateless handle to a actor by its key, but does not create the actor if it doesn't exist.
1093
+ * The actor name is automatically injected from the property accessor.
1094
+ *
1095
+ * @template AD The actor class that this handle is for.
1096
+ * @param {string | string[]} [key=[]] - The key to identify the actor. Can be a single string or an array of strings.
1097
+ * @param {GetWithIdOptions} [opts] - Options for getting the actor.
1098
+ * @returns {ActorHandle<AD>} - A handle to the actor.
1099
+ */
1100
+ get(key?: string | string[], opts?: GetWithIdOptions): ActorHandle<AD>;
1101
+ /**
1102
+ * Gets a stateless handle to a actor by its key, creating it if necessary.
1103
+ * The actor name is automatically injected from the property accessor.
1104
+ *
1105
+ * @template AD The actor class that this handle is for.
1106
+ * @param {string | string[]} [key=[]] - The key to identify the actor. Can be a single string or an array of strings.
1107
+ * @param {GetOptions} [opts] - Options for getting the actor.
1108
+ * @returns {ActorHandle<AD>} - A handle to the actor.
1109
+ */
1110
+ getOrCreate(key?: string | string[], opts?: GetOrCreateOptions): ActorHandle<AD>;
1111
+ /**
1112
+ * Gets a stateless handle to a actor by its ID.
1113
+ *
1114
+ * @template AD The actor class that this handle is for.
1115
+ * @param {string} actorId - The ID of the actor.
1116
+ * @param {GetWithIdOptions} [opts] - Options for getting the actor.
1117
+ * @returns {ActorHandle<AD>} - A handle to the actor.
1118
+ */
1119
+ getForId(actorId: string, opts?: GetWithIdOptions): ActorHandle<AD>;
1120
+ /**
1121
+ * Creates a new actor with the name automatically injected from the property accessor,
1122
+ * and returns a stateless handle to it with the actor ID resolved.
1123
+ *
1124
+ * @template AD The actor class that this handle is for.
1125
+ * @param {string | string[]} key - The key to identify the actor. Can be a single string or an array of strings.
1126
+ * @param {CreateOptions} [opts] - Options for creating the actor (excluding name and key).
1127
+ * @returns {Promise<ActorHandle<AD>>} - A promise that resolves to a handle to the actor.
1128
+ */
1129
+ create(key?: string | string[], opts?: CreateOptions): Promise<ActorHandle<AD>>;
1130
+ }
1131
+ /**
1132
+ * Options for querying actors.
1133
+ * @typedef {Object} QueryOptions
1134
+ * @property {unknown} [parameters] - Parameters to pass to the connection.
1135
+ */
1136
+ interface QueryOptions {
1137
+ /** Parameters to pass to the connection. */
1138
+ params?: unknown;
1139
+ /** Signal to abort the request. */
1140
+ signal?: AbortSignal;
1141
+ }
1142
+ /**
1143
+ * Options for getting a actor by ID.
1144
+ * @typedef {QueryOptions} GetWithIdOptions
1145
+ */
1146
+ interface GetWithIdOptions extends QueryOptions {
1147
+ }
1148
+ /**
1149
+ * Options for getting a actor.
1150
+ * @typedef {QueryOptions} GetOptions
1151
+ */
1152
+ interface GetOptions extends QueryOptions {
1153
+ }
1154
+ /**
1155
+ * Options for getting or creating a actor.
1156
+ * @typedef {QueryOptions} GetOrCreateOptions
1157
+ * @property {string} [createInRegion] - Region to create the actor in if it doesn't exist.
1158
+ */
1159
+ interface GetOrCreateOptions extends QueryOptions {
1160
+ /** Region to create the actor in if it doesn't exist. */
1161
+ createInRegion?: string;
1162
+ /** Input data to pass to the actor. */
1163
+ createWithInput?: unknown;
1164
+ }
1165
+ /**
1166
+ * Options for creating a actor.
1167
+ * @typedef {QueryOptions} CreateOptions
1168
+ * @property {string} [region] - The region to create the actor in.
1169
+ */
1170
+ interface CreateOptions extends QueryOptions {
1171
+ /** The region to create the actor in. */
1172
+ region?: string;
1173
+ /** Input data to pass to the actor. */
1174
+ input?: unknown;
1175
+ }
1176
+ /**
1177
+ * Represents a region to connect to.
1178
+ * @typedef {Object} Region
1179
+ * @property {string} id - The region ID.
1180
+ * @property {string} name - The region name.
1181
+ * @see {@link https://rivet.dev/docs/edge|Edge Networking}
1182
+ * @see {@link https://rivet.dev/docs/regions|Available Regions}
1183
+ */
1184
+ interface Region {
1185
+ /**
1186
+ * The region slug.
1187
+ */
1188
+ id: string;
1189
+ /**
1190
+ * The human-friendly region name.
1191
+ */
1192
+ name: string;
1193
+ }
1194
+ declare const ACTOR_CONNS_SYMBOL: unique symbol;
1195
+ declare const CREATE_ACTOR_CONN_PROXY: unique symbol;
1196
+ /**
1197
+ * Client for managing & connecting to actors.
1198
+ *
1199
+ * @template A The actors map type that defines the available actors.
1200
+ * @see {@link https://rivet.dev/docs/manage|Create & Manage Actors}
1201
+ */
1202
+ declare class ClientRaw {
1203
+ #private;
1204
+ [ACTOR_CONNS_SYMBOL]: Set<ActorConnRaw>;
1205
+ /**
1206
+ * Creates an instance of Client.
1207
+ */
1208
+ constructor(driver: ManagerDriver, encoding: Encoding | undefined);
1209
+ /**
1210
+ * Gets a stateless handle to a actor by its ID.
1211
+ *
1212
+ * @template AD The actor class that this handle is for.
1213
+ * @param {string} name - The name of the actor.
1214
+ * @param {string} actorId - The ID of the actor.
1215
+ * @param {GetWithIdOptions} [opts] - Options for getting the actor.
1216
+ * @returns {ActorHandle<AD>} - A handle to the actor.
1217
+ */
1218
+ getForId<AD extends AnyActorDefinition>(name: string, actorId: string, opts?: GetWithIdOptions): ActorHandle<AD>;
1219
+ /**
1220
+ * Gets a stateless handle to a actor by its key, but does not create the actor if it doesn't exist.
1221
+ *
1222
+ * @template AD The actor class that this handle is for.
1223
+ * @param {string} name - The name of the actor.
1224
+ * @param {string | string[]} [key=[]] - The key to identify the actor. Can be a single string or an array of strings.
1225
+ * @param {GetWithIdOptions} [opts] - Options for getting the actor.
1226
+ * @returns {ActorHandle<AD>} - A handle to the actor.
1227
+ */
1228
+ get<AD extends AnyActorDefinition>(name: string, key?: string | string[], opts?: GetWithIdOptions): ActorHandle<AD>;
1229
+ /**
1230
+ * Gets a stateless handle to a actor by its key, creating it if necessary.
1231
+ *
1232
+ * @template AD The actor class that this handle is for.
1233
+ * @param {string} name - The name of the actor.
1234
+ * @param {string | string[]} [key=[]] - The key to identify the actor. Can be a single string or an array of strings.
1235
+ * @param {GetOptions} [opts] - Options for getting the actor.
1236
+ * @returns {ActorHandle<AD>} - A handle to the actor.
1237
+ */
1238
+ getOrCreate<AD extends AnyActorDefinition>(name: string, key?: string | string[], opts?: GetOrCreateOptions): ActorHandle<AD>;
1239
+ /**
1240
+ * Creates a new actor with the provided key and returns a stateless handle to it.
1241
+ * Resolves the actor ID and returns a handle with getForId query.
1242
+ *
1243
+ * @template AD The actor class that this handle is for.
1244
+ * @param {string} name - The name of the actor.
1245
+ * @param {string | string[]} key - The key to identify the actor. Can be a single string or an array of strings.
1246
+ * @param {CreateOptions} [opts] - Options for creating the actor (excluding name and key).
1247
+ * @returns {Promise<ActorHandle<AD>>} - A promise that resolves to a handle to the actor.
1248
+ */
1249
+ create<AD extends AnyActorDefinition>(name: string, key?: string | string[], opts?: CreateOptions): Promise<ActorHandle<AD>>;
1250
+ [CREATE_ACTOR_CONN_PROXY]<AD extends AnyActorDefinition>(conn: ActorConnRaw): ActorConn<AD>;
1251
+ /**
1252
+ * Disconnects from all actors.
1253
+ *
1254
+ * @returns {Promise<void>} A promise that resolves when all connections are closed.
1255
+ */
1256
+ dispose(): Promise<void>;
1257
+ }
1258
+ /**
1259
+ * Client type with actor accessors.
1260
+ * This adds property accessors for actor names to the ClientRaw base class.
1261
+ *
1262
+ * @template A The actor registry type.
1263
+ */
1264
+ type Client<A extends Registry<any>> = ClientRaw & {
1265
+ [K in keyof ExtractActorsFromRegistry<A>]: ActorAccessor<ExtractActorsFromRegistry<A>[K]>;
1266
+ };
1267
+ type AnyClient = Client<Registry<any>>;
1268
+ declare function createClientWithDriver<A extends Registry<any>>(driver: ManagerDriver, config?: {
1269
+ encoding?: Encoding;
1270
+ }): Client<A>;
1271
+
1272
+ interface ActorInspectorEmitterEvents {
1273
+ stateUpdated: (state: unknown) => void;
1274
+ connectionsUpdated: () => void;
1275
+ queueUpdated: () => void;
1276
+ workflowHistoryUpdated: (history: WorkflowHistory) => void;
1277
+ }
1278
+ /**
1279
+ * Provides a unified interface for inspecting actor external and internal state.
1280
+ */
1281
+ declare class ActorInspector {
1282
+ #private;
1283
+ private readonly actor;
1284
+ readonly emitter: nanoevents.Emitter<ActorInspectorEmitterEvents>;
1285
+ constructor(actor: AnyActorInstance);
1286
+ getQueueSize(): number;
1287
+ getQueueStatus(limit: number): Promise<QueueStatus>;
1288
+ updateQueueSize(size: number): void;
1289
+ isWorkflowEnabled(): boolean;
1290
+ getWorkflowHistory(): WorkflowHistory | null;
1291
+ isDatabaseEnabled(): boolean;
1292
+ getDatabaseSchema(): Promise<ArrayBuffer>;
1293
+ getDatabaseTableRows(table: string, limit: number, offset: number): Promise<ArrayBuffer>;
1294
+ isStateEnabled(): boolean;
1295
+ getState(): ArrayBuffer;
1296
+ getRpcs(): string[];
1297
+ getConnections(): {
1298
+ type: string | undefined;
1299
+ id: string;
1300
+ details: ArrayBuffer;
1301
+ }[];
1302
+ setState(state: ArrayBuffer): Promise<void>;
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
+ }>;
1333
+ }
1334
+
1335
+ /**
1336
+ * User-facing KV storage interface exposed on ActorContext.
1337
+ */
1338
+ type KvValueType = "text" | "arrayBuffer" | "binary";
1339
+ type KvKeyType = "text" | "binary";
1340
+ type KvKey = Uint8Array | string;
1341
+ type KvValueTypeMap = {
1342
+ text: string;
1343
+ arrayBuffer: ArrayBuffer;
1344
+ binary: Uint8Array;
1345
+ };
1346
+ type KvKeyTypeMap = {
1347
+ text: string;
1348
+ binary: Uint8Array;
1349
+ };
1350
+ type KvValueOptions<T extends KvValueType = "text"> = {
1351
+ type?: T;
1352
+ };
1353
+ type KvListOptions<T extends KvValueType = "text", K extends KvKeyType = "text"> = KvValueOptions<T> & {
1354
+ keyType?: K;
1355
+ };
1356
+ declare class ActorKv {
1357
+ #private;
1358
+ constructor(driver: ActorDriver, actorId: string);
1359
+ /**
1360
+ * Get a single value by key.
1361
+ */
1362
+ get<T extends KvValueType = "text">(key: KvKey, options?: KvValueOptions<T>): Promise<KvValueTypeMap[T] | null>;
1363
+ /**
1364
+ * Get multiple values by keys.
1365
+ */
1366
+ getBatch<T extends KvValueType = "text">(keys: KvKey[], options?: KvValueOptions<T>): Promise<(KvValueTypeMap[T] | null)[]>;
1367
+ /**
1368
+ * Put a single key-value pair.
1369
+ */
1370
+ put<T extends KvValueType = KvValueType>(key: KvKey, value: KvValueTypeMap[T], options?: KvValueOptions<T>): Promise<void>;
1371
+ /**
1372
+ * Put multiple key-value pairs.
1373
+ */
1374
+ putBatch<T extends KvValueType = KvValueType>(entries: [KvKey, KvValueTypeMap[T]][], options?: KvValueOptions<T>): Promise<void>;
1375
+ /**
1376
+ * Delete a single key.
1377
+ */
1378
+ delete(key: KvKey): Promise<void>;
1379
+ /**
1380
+ * Delete multiple keys.
1381
+ */
1382
+ deleteBatch(keys: KvKey[]): Promise<void>;
1383
+ /**
1384
+ * List all keys with a given prefix.
1385
+ * Returns key-value pairs where keys have the user prefix removed.
1386
+ */
1387
+ list<T extends KvValueType = "text", K extends KvKeyType = "text">(prefix: KvKeyTypeMap[K], options?: KvListOptions<T, K>): Promise<[KvKeyTypeMap[K], KvValueTypeMap[T]][]>;
1388
+ }
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
+ /** Timeout in milliseconds. Omit to wait indefinitely. */
1441
+ timeout?: number;
1442
+ /** Optional abort signal for this receive call. */
1443
+ signal?: AbortSignal;
1444
+ /** Whether to return completable messages. */
1445
+ completable?: TCompletable;
1446
+ }
1447
+ /** Options for receiving queue message batches. */
1448
+ interface QueueNextBatchOptions<TName extends string = string, TCompletable extends boolean = boolean> {
1449
+ /** Queue names to receive from. If omitted, reads from all queue names. */
1450
+ names?: readonly TName[];
1451
+ /** Maximum number of messages to receive. Defaults to 1. */
1452
+ count?: number;
1453
+ /** Timeout in milliseconds. Omit to wait indefinitely. */
1454
+ timeout?: number;
1455
+ /** Optional abort signal for this receive call. */
1456
+ signal?: AbortSignal;
1457
+ /** Whether to return completable messages. */
1458
+ completable?: TCompletable;
1459
+ }
1460
+ /** Options for non-blocking queue reads. */
1461
+ interface QueueTryNextOptions<TName extends string = string, TCompletable extends boolean = boolean> {
1462
+ /** Queue names to receive from. If omitted, reads from all queue names. */
1463
+ names?: readonly TName[];
1464
+ /** Whether to return completable messages. */
1465
+ completable?: TCompletable;
1466
+ }
1467
+ /** Options for non-blocking queue batch reads. */
1468
+ interface QueueTryNextBatchOptions<TName extends string = string, TCompletable extends boolean = boolean> {
1469
+ /** Queue names to receive from. If omitted, reads from all queue names. */
1470
+ names?: readonly TName[];
1471
+ /** Maximum number of messages to receive. Defaults to 1. */
1472
+ count?: number;
1473
+ /** Whether to return completable messages. */
1474
+ completable?: TCompletable;
1475
+ }
1476
+ /** Options for queue async iteration. */
1477
+ interface QueueIterOptions<TName extends string = string, TCompletable extends boolean = boolean> {
1478
+ /** Queue names to receive from. If omitted, reads from all queue names. */
1479
+ names?: readonly TName[];
1480
+ /** Optional abort signal for this iterator. */
1481
+ signal?: AbortSignal;
1482
+ /** Whether to return completable messages. */
1483
+ completable?: TCompletable;
1484
+ }
1485
+ /** User-facing queue interface exposed on ActorContext. */
1486
+ declare class ActorQueue<S, CP, CS, V, I, DB extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
1487
+ #private;
1488
+ constructor(queueManager: QueueManager<S, CP, CS, V, I, DB, TEvents, TQueues>, abortSignal: AbortSignal);
1489
+ next<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueNextOptions<TName, TCompletable>): Promise<QueueResultMessageForName<TQueues, TName, TCompletable> | undefined>;
1490
+ nextBatch<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueNextBatchOptions<TName, TCompletable>): Promise<Array<QueueResultMessageForName<TQueues, TName, TCompletable>>>;
1491
+ tryNext<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueTryNextOptions<TName, TCompletable>): Promise<QueueResultMessageForName<TQueues, TName, TCompletable> | undefined>;
1492
+ tryNextBatch<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueTryNextBatchOptions<TName, TCompletable>): Promise<Array<QueueResultMessageForName<TQueues, TName, TCompletable>>>;
1493
+ iter<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueIterOptions<TName, TCompletable>): AsyncIterableIterator<QueueResultMessageForName<TQueues, TName, TCompletable>>;
1494
+ /** Sends a message to the specified queue. */
1495
+ send<K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K]): Promise<QueueMessage>;
1496
+ send(name: keyof TQueues extends never ? string : never, body: unknown): Promise<QueueMessage>;
1497
+ }
1498
+
1499
+ declare class Schedule {
1500
+ #private;
1501
+ constructor(actor: AnyActorInstance);
1502
+ after(duration: number, fn: string, ...args: unknown[]): Promise<void>;
1503
+ at(timestamp: number, fn: string, ...args: unknown[]): Promise<void>;
1504
+ }
1505
+
1506
+ declare const ACTOR_CONTEXT_INTERNAL_SYMBOL: unique symbol;
1507
+ /**
1508
+ * ActorContext class that provides access to actor methods and state
1509
+ */
1510
+ declare class ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
1511
+ #private;
1512
+ [ACTOR_CONTEXT_INTERNAL_SYMBOL]: AnyActorInstance;
1513
+ constructor(actor: ActorInstance<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>);
1514
+ /**
1515
+ * Gets the KV storage interface.
1516
+ */
1517
+ get kv(): ActorKv;
1518
+ /**
1519
+ * Get the actor state
1520
+ *
1521
+ * @remarks
1522
+ * This property is not available in `createState` since the state hasn't been created yet.
1523
+ */
1524
+ get state(): TState extends never ? never : TState;
1525
+ /**
1526
+ * Get the actor variables
1527
+ *
1528
+ * @remarks
1529
+ * This property is not available in `createVars` since the variables haven't been created yet.
1530
+ * Variables are only available if you define `vars` or `createVars` in your actor config.
1531
+ */
1532
+ get vars(): TVars extends never ? never : TVars;
1533
+ /**
1534
+ * Broadcasts an event to all connected clients.
1535
+ * @param name - The name of the event.
1536
+ * @param args - The arguments to send with the event.
1537
+ */
1538
+ broadcast<K extends keyof TEvents & string>(name: K, ...args: InferEventArgs<InferSchemaMap<TEvents>[K]>): void;
1539
+ broadcast(name: keyof TEvents extends never ? string : never, ...args: Array<unknown>): void;
1540
+ /**
1541
+ * Gets the logger instance.
1542
+ */
1543
+ get log(): Logger;
1544
+ /**
1545
+ * Access to queue receive helpers.
1546
+ */
1547
+ get queue(): ActorQueue<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
1548
+ /**
1549
+ * Gets actor ID.
1550
+ */
1551
+ get actorId(): string;
1552
+ /**
1553
+ * Gets the actor name.
1554
+ */
1555
+ get name(): string;
1556
+ /**
1557
+ * Gets the actor key.
1558
+ */
1559
+ get key(): ActorKey;
1560
+ /**
1561
+ * Gets the region.
1562
+ */
1563
+ get region(): string;
1564
+ /**
1565
+ * Gets the scheduler.
1566
+ */
1567
+ get schedule(): Schedule;
1568
+ /**
1569
+ * Gets the map of connections.
1570
+ */
1571
+ get conns(): Map<ConnId, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>;
1572
+ /**
1573
+ * Returns the client for the given registry.
1574
+ */
1575
+ client<R extends Registry<any>>(): Client<R>;
1576
+ /**
1577
+ * Gets the database.
1578
+ *
1579
+ * @experimental
1580
+ * @remarks
1581
+ * This property is only available if you define a `db` provider in your actor config.
1582
+ * @throws {DatabaseNotEnabled} If the database is not enabled.
1583
+ */
1584
+ get db(): TDatabase extends never ? never : InferDatabaseClient<TDatabase>;
1585
+ /**
1586
+ * Forces the state to get saved.
1587
+ *
1588
+ * @param opts - Options for saving the state.
1589
+ */
1590
+ saveState(opts: SaveStateOptions): Promise<void>;
1591
+ /**
1592
+ * Prevents the actor from sleeping until promise is complete.
1593
+ */
1594
+ waitUntil(promise: Promise<void>): void;
1595
+ /**
1596
+ * Prevents the actor from sleeping while the given promise is running.
1597
+ *
1598
+ * Use this when performing async operations in the `run` handler or other
1599
+ * background contexts where you need to ensure the actor stays awake.
1600
+ *
1601
+ * Returns the resolved value and resets the sleep timer on completion.
1602
+ * Errors are propagated to the caller.
1603
+ */
1604
+ keepAwake<T>(promise: Promise<T>): Promise<T>;
1605
+ /**
1606
+ * AbortSignal that fires when the actor is stopping.
1607
+ */
1608
+ get abortSignal(): AbortSignal;
1609
+ /**
1610
+ * True when the actor is stopping.
1611
+ *
1612
+ * Alias for `c.abortSignal.aborted`.
1613
+ */
1614
+ get aborted(): boolean;
1615
+ /**
1616
+ * Forces the actor to sleep.
1617
+ *
1618
+ * Not supported on all drivers.
1619
+ *
1620
+ * @experimental
1621
+ */
1622
+ sleep(): void;
1623
+ /**
1624
+ * Forces the actor to destroy.
1625
+ *
1626
+ * This will return immediately, then call `onStop` and `onDestroy`.
1627
+ *
1628
+ * @experimental
1629
+ */
1630
+ destroy(): void;
1631
+ }
1632
+ 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;
1633
+
1634
+ /**
1635
+ * Base context for connection-based handlers.
1636
+ * Extends ActorContext with connection-specific functionality.
1637
+ */
1638
+ 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> {
1639
+ readonly conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
1640
+ }
1641
+ 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;
1642
+
1643
+ /**
1644
+ * Context for a remote procedure call.
1645
+ */
1646
+ 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> {
1647
+ }
1648
+ /**
1649
+ * Extracts the ActionContext type from an ActorDefinition.
1650
+ */
1651
+ 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;
1652
+
1653
+ /**
1654
+ * Base context for connection initialization handlers.
1655
+ * Extends ActorContext with request-specific functionality for connection lifecycle events.
1656
+ */
1657
+ 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> {
1658
+ /**
1659
+ * The incoming request that initiated the connection.
1660
+ * May be undefined for connections initiated without a direct HTTP request.
1661
+ */
1662
+ readonly request: Request | undefined;
1663
+ }
1664
+ 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;
1665
+
1666
+ /**
1667
+ * Context for the onBeforeActionResponse lifecycle hook.
1668
+ */
1669
+ 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> {
1670
+ }
1671
+ 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;
1672
+
1673
+ /**
1674
+ * Context for the onBeforeConnect lifecycle hook.
1675
+ */
1676
+ 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> {
1677
+ }
1678
+ 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;
1679
+
1680
+ /**
1681
+ * Context for the onConnect lifecycle hook.
1682
+ */
1683
+ 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> {
1684
+ }
1685
+ 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;
1686
+
1687
+ /**
1688
+ * Context for the onCreate lifecycle hook.
1689
+ */
1690
+ 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> {
1691
+ }
1692
+ 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;
1693
+
1694
+ /**
1695
+ * Context for the createConnState lifecycle hook.
1696
+ * Called to initialize connection-specific state when a connection is created.
1697
+ */
1698
+ 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> {
1699
+ }
1700
+ 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;
1701
+
1702
+ /**
1703
+ * Context for the createVars lifecycle hook.
1704
+ */
1705
+ 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> {
1706
+ }
1707
+ 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;
1708
+
1709
+ /**
1710
+ * Context for the onDestroy lifecycle hook.
1711
+ */
1712
+ 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> {
1713
+ }
1714
+ 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;
1715
+
1716
+ /**
1717
+ * Context for the onDisconnect lifecycle hook.
1718
+ */
1719
+ 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> {
1720
+ }
1721
+ 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;
1722
+
1723
+ /**
1724
+ * Context for raw HTTP request handlers (onRequest).
1725
+ */
1726
+ 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> {
1727
+ /**
1728
+ * The incoming HTTP request.
1729
+ * May be undefined for request contexts initiated without a direct HTTP request.
1730
+ */
1731
+ readonly request: Request | undefined;
1732
+ }
1733
+ 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;
1734
+
1735
+ /**
1736
+ * Context for the run lifecycle hook.
1737
+ *
1738
+ * This context is passed to the `run` handler which executes after the actor
1739
+ * starts. It does not block actor startup and is intended for background tasks.
1740
+ *
1741
+ * Use `c.aborted` to detect when the actor is stopping and gracefully exit.
1742
+ */
1743
+ 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> {
1744
+ }
1745
+ 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;
1746
+
1747
+ /**
1748
+ * Context for the onSleep lifecycle hook.
1749
+ */
1750
+ 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> {
1751
+ }
1752
+ 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;
1753
+
1754
+ /**
1755
+ * Context for the onStateChange lifecycle hook.
1756
+ */
1757
+ 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> {
1758
+ }
1759
+ 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;
1760
+
1761
+ /**
1762
+ * Context for the onWake lifecycle hook.
1763
+ */
1764
+ 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> {
1765
+ }
1766
+ 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;
1767
+
1768
+ /**
1769
+ * Context for raw WebSocket handlers (onWebSocket).
1770
+ */
1771
+ 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> {
1772
+ /**
1773
+ * The incoming HTTP request that initiated the WebSocket upgrade.
1774
+ * May be undefined for WebSocket connections initiated without a direct HTTP request.
1775
+ */
1776
+ readonly request: Request | undefined;
1777
+ }
1778
+ 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;
1779
+
1780
+ declare enum DriverReadyState {
1781
+ UNKNOWN = -1,
1782
+ CONNECTING = 0,
1783
+ OPEN = 1,
1784
+ CLOSING = 2,
1785
+ CLOSED = 3
1786
+ }
1787
+ interface ConnDriver {
1788
+ /** The type of driver. Used for debug purposes only. */
1789
+ type: string;
1790
+ /**
1791
+ * If defined, this connection driver talks the RivetKit client driver (see
1792
+ * schemas/client-protocol/).
1793
+ *
1794
+ * If enabled, events like `Init`, subscription events, etc. will be sent
1795
+ * to this connection.
1796
+ */
1797
+ rivetKitProtocol?: {
1798
+ /** Sends a RivetKit client message. */
1799
+ sendMessage(actor: AnyActorInstance, conn: AnyConn, message: CachedSerializer<any, any, any>): void;
1800
+ };
1801
+ /**
1802
+ * If the connection can be hibernated. If true, this will allow the actor to go to sleep while the connection is still active.
1803
+ **/
1804
+ hibernatable?: {
1805
+ gatewayId: ArrayBuffer;
1806
+ requestId: ArrayBuffer;
1807
+ };
1808
+ /**
1809
+ * This returns a promise since we commonly disconnect at the end of a program, and not waiting will cause the socket to not close cleanly.
1810
+ */
1811
+ disconnect(actor: AnyActorInstance, conn: AnyConn, reason?: string): Promise<void>;
1812
+ /** Terminates the connection without graceful handling. */
1813
+ terminate?(actor: AnyActorInstance, conn: AnyConn): void;
1814
+ /**
1815
+ * Returns the ready state of the connection.
1816
+ * This is used to determine if the connection is ready to send messages, or if the connection is stale.
1817
+ */
1818
+ getConnectionReadyState(actor: AnyActorInstance, conn: AnyConn): DriverReadyState | undefined;
1819
+ }
1820
+
1821
+ /**
1822
+ * Persisted data structures for connections.
1823
+ *
1824
+ * Keep this file in sync with the Connection section of rivetkit-typescript/packages/rivetkit/schemas/actor-persist/
1825
+ */
1826
+
1827
+ type GatewayId = ArrayBuffer;
1828
+ type RequestId = ArrayBuffer;
1829
+ /** Event subscription for connection */
1830
+ interface PersistedSubscription {
1831
+ eventName: string;
1832
+ }
1833
+ /** Connection associated with hibernatable WebSocket that should persist across lifecycles */
1834
+ interface PersistedConn<CP, CS> {
1835
+ /** Connection ID generated by RivetKit */
1836
+ id: string;
1837
+ parameters: CP;
1838
+ state: CS;
1839
+ subscriptions: PersistedSubscription[];
1840
+ gatewayId: GatewayId;
1841
+ requestId: RequestId;
1842
+ serverMessageIndex: number;
1843
+ clientMessageIndex: number;
1844
+ requestPath: string;
1845
+ requestHeaders: Record<string, string>;
1846
+ }
1847
+
1848
+ /**
1849
+ * Manages all connection-related operations for an actor instance.
1850
+ * Handles connection creation, tracking, hibernation, and cleanup.
1851
+ */
1852
+ declare class ConnectionManager<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>> {
1853
+ #private;
1854
+ constructor(actor: ActorInstance<S, CP, CS, V, I, DB, E, Q>);
1855
+ get connections(): Map<ConnId, Conn<S, CP, CS, V, I, DB, E, Q>>;
1856
+ getConnForId(id: string): Conn<S, CP, CS, V, I, DB, E, Q> | undefined;
1857
+ get connsWithPersistChanged(): Set<ConnId>;
1858
+ get pendingDisconnectCount(): number;
1859
+ clearConnWithPersistChanged(): void;
1860
+ markConnWithPersistChanged(conn: Conn<S, CP, CS, V, I, DB, E, Q>): void;
1861
+ /**
1862
+ * Handles pre-connection logic (i.e. auth & create state) before actually connecting the connection.
1863
+ */
1864
+ 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>>;
1865
+ /**
1866
+ * Adds a connection form prepareConn to the actor and calls onConnect.
1867
+ *
1868
+ * This method is intentionally not async since it needs to be called in
1869
+ * `onOpen` for WebSockets. If this is async, the order of open events will
1870
+ * be messed up and cause race conditions that can drop WebSocket messages.
1871
+ * So all async work in prepareConn.
1872
+ */
1873
+ connectConn(conn: Conn<S, CP, CS, V, I, DB, E, Q>): void;
1874
+ /**
1875
+ * Handle connection disconnection.
1876
+ *
1877
+ * This is called by `Conn.disconnect`. This should not call `Conn.disconnect.`
1878
+ */
1879
+ connDisconnected(conn: Conn<S, CP, CS, V, I, DB, E, Q>): Promise<void>;
1880
+ cleanupPersistedHibernatableConnections(reason?: string): Promise<number>;
1881
+ /**
1882
+ * Utilify function for call sites that don't need a separate prepare and connect phase.
1883
+ */
1884
+ 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>>;
1885
+ /**
1886
+ * Restores connections from persisted data during actor initialization.
1887
+ */
1888
+ restoreConnections(connections: PersistedConn<CP, CS>[]): void;
1889
+ findHibernatableConn(gatewayIdBuf: ArrayBuffer, requestIdBuf: ArrayBuffer): Conn<S, CP, CS, V, I, DB, E, Q> | undefined;
1890
+ }
1891
+
1892
+ /**
1893
+ * Manages event subscriptions and broadcasting for actor instances.
1894
+ * Handles subscription tracking and efficient message distribution to connected clients.
1895
+ */
1896
+ declare class EventManager<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>> {
1897
+ #private;
1898
+ constructor(actor: ActorInstance<S, CP, CS, V, I, DB, E, Q>);
1899
+ /**
1900
+ * Adds a subscription for a connection to an event.
1901
+ *
1902
+ * @param eventName - The name of the event to subscribe to
1903
+ * @param connection - The connection subscribing to the event
1904
+ * @param fromPersist - Whether this subscription is being restored from persistence
1905
+ */
1906
+ addSubscription(eventName: string, connection: Conn<S, CP, CS, V, I, DB, E, Q>, fromPersist: boolean): void;
1907
+ /**
1908
+ * Removes a subscription for a connection from an event.
1909
+ *
1910
+ * @param eventName - The name of the event to unsubscribe from
1911
+ * @param connection - The connection unsubscribing from the event
1912
+ * @param fromRemoveConn - Whether this is being called as part of connection removal
1913
+ */
1914
+ removeSubscription(eventName: string, connection: Conn<S, CP, CS, V, I, DB, E, Q>, fromRemoveConn: boolean): void;
1915
+ /**
1916
+ * Broadcasts an event to all subscribed connections.
1917
+ *
1918
+ * @param name - The name of the event to broadcast
1919
+ * @param args - The arguments to send with the event
1920
+ */
1921
+ broadcast<Args extends Array<unknown>>(name: string, ...args: Args): void;
1922
+ /**
1923
+ * Gets all subscribers for a specific event.
1924
+ *
1925
+ * @param eventName - The name of the event
1926
+ * @returns Set of connections subscribed to the event, or undefined if no subscribers
1927
+ */
1928
+ getSubscribers(eventName: string): Set<Conn<S, CP, CS, V, I, DB, E, Q>> | undefined;
1929
+ /**
1930
+ * Gets all events and their subscriber counts.
1931
+ *
1932
+ * @returns Map of event names to subscriber counts
1933
+ */
1934
+ getEventStats(): Map<string, number>;
1935
+ /**
1936
+ * Clears all subscriptions for a connection.
1937
+ * Used during connection cleanup.
1938
+ *
1939
+ * @param connection - The connection to clear subscriptions for
1940
+ */
1941
+ clearConnectionSubscriptions(connection: Conn<S, CP, CS, V, I, DB, E, Q>): void;
1942
+ /**
1943
+ * Gets the total number of unique events being subscribed to.
1944
+ */
1945
+ get eventCount(): number;
1946
+ /**
1947
+ * Gets the total number of subscriptions across all events.
1948
+ */
1949
+ get totalSubscriptionCount(): number;
1950
+ /**
1951
+ * Checks if an event has any subscribers.
1952
+ *
1953
+ * @param eventName - The name of the event to check
1954
+ * @returns True if the event has at least one subscriber
1955
+ */
1956
+ hasSubscribers(eventName: string): boolean;
1957
+ }
1958
+
1959
+ /**
1960
+ * Persisted data structures for actors.
1961
+ *
1962
+ * Keep this file in sync with the Connection section of rivetkit-typescript/packages/rivetkit/schemas/actor-persist/
1963
+ */
1964
+
1965
+ type Cbor = ArrayBuffer;
1966
+ /** Scheduled event to be executed at a specific timestamp */
1967
+ interface PersistedScheduleEvent {
1968
+ eventId: string;
1969
+ timestamp: number;
1970
+ action: string;
1971
+ args?: Cbor;
1972
+ }
1973
+ /** State object that gets automatically persisted to storage */
1974
+ interface PersistedActor<S, I> {
1975
+ /** Input data passed to the actor on initialization */
1976
+ input?: I;
1977
+ hasInitialized: boolean;
1978
+ state: S;
1979
+ scheduledEvents: PersistedScheduleEvent[];
1980
+ }
1981
+
1982
+ interface SaveStateOptions {
1983
+ /**
1984
+ * Forces the state to be saved immediately. This function will return when the state has saved successfully.
1985
+ */
1986
+ immediate?: boolean;
1987
+ /** Bypass ready check for stopping. */
1988
+ allowStoppingState?: boolean;
1989
+ /**
1990
+ * Maximum time in milliseconds to wait before forcing a save.
1991
+ *
1992
+ * If a save is already scheduled to occur later than this deadline, it will be rescheduled earlier.
1993
+ */
1994
+ maxWait?: number;
1995
+ }
1996
+ /**
1997
+ * Manages actor state persistence, proxying, and synchronization.
1998
+ * Handles automatic state change detection and throttled persistence to KV storage.
1999
+ */
2000
+ declare class StateManager$1<S, CP, CS, I, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>> {
2001
+ #private;
2002
+ constructor(actor: ActorInstance<S, CP, CS, any, I, any, E, Q>, actorDriver: ActorDriver, config: any);
2003
+ get persist(): PersistedActor<S, I>;
2004
+ get persistRaw(): PersistedActor<S, I>;
2005
+ get persistChanged(): boolean;
2006
+ get state(): S;
2007
+ set state(value: S);
2008
+ get stateEnabled(): boolean;
2009
+ /**
2010
+ * Initializes state from persisted data or creates new state.
2011
+ */
2012
+ initializeState(persistData: PersistedActor<S, I>): Promise<void>;
2013
+ /**
2014
+ * Creates proxy for persist object that handles automatic state change detection.
2015
+ */
2016
+ initPersistProxy(target: PersistedActor<S, I>): undefined;
2017
+ /**
2018
+ * Forces the state to get saved.
2019
+ */
2020
+ saveState(opts: SaveStateOptions): Promise<void>;
2021
+ /**
2022
+ * Throttled save state method. Used to write to KV at a reasonable cadence.
2023
+ *
2024
+ * Passing a maxWait will override the stateSaveInterval with the min
2025
+ * between that and the maxWait.
2026
+ */
2027
+ savePersistThrottled(maxWait?: number): void;
2028
+ /**
2029
+ * Clears any pending save timeout.
2030
+ */
2031
+ clearPendingSaveTimeout(): void;
2032
+ /**
2033
+ * Waits for any pending write operations to complete.
2034
+ */
2035
+ waitForPendingWrites(): Promise<void>;
2036
+ }
2037
+
2038
+ /** Actor type alias with all `any` types. Used for `extends` in classes referencing this actor. */
2039
+ type AnyActorInstance = ActorInstance<any, any, any, any, any, any, any, any>;
2040
+ declare class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>> {
2041
+ #private;
2042
+ actorContext: ActorContext<S, CP, CS, V, I, DB, E, Q>;
2043
+ driver: ActorDriver;
2044
+ connectionManager: ConnectionManager<S, CP, CS, V, I, DB, E, Q>;
2045
+ stateManager: StateManager$1<S, CP, CS, I, E, Q>;
2046
+ eventManager: EventManager<S, CP, CS, V, I, DB, E, Q>;
2047
+ queueManager: QueueManager<S, CP, CS, V, I, DB, E, Q>;
2048
+ constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q>);
2049
+ get log(): Logger;
2050
+ get rLog(): Logger;
2051
+ get isStopping(): boolean;
2052
+ get id(): string;
2053
+ get name(): string;
2054
+ get key(): ActorKey;
2055
+ get region(): string;
2056
+ get inlineClient(): Client<Registry<any>>;
2057
+ get inspector(): ActorInspector;
2058
+ get traces(): Traces<OtlpExportTraceServiceRequestJson>;
2059
+ get inspectorToken(): string | undefined;
2060
+ getCurrentTraceSpan(): SpanHandle | null;
2061
+ startTraceSpan(name: string, attributes?: Record<string, unknown>): SpanHandle;
2062
+ endTraceSpan(handle: SpanHandle, status?: SpanStatusInput): void;
2063
+ runInTraceSpan<T>(name: string, attributes: Record<string, unknown> | undefined, fn: () => T | Promise<T>): Promise<T>;
2064
+ emitTraceEvent(name: string, attributes?: Record<string, unknown>, handle?: SpanHandle): void;
2065
+ get conns(): Map<ConnId, Conn<S, CP, CS, V, I, DB, E, Q>>;
2066
+ get schedule(): Schedule;
2067
+ get abortSignal(): AbortSignal;
2068
+ get actions(): string[];
2069
+ get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q>;
2070
+ get persist(): PersistedActor<S, I>;
2071
+ get state(): S;
2072
+ set state(value: S);
2073
+ get stateEnabled(): boolean;
2074
+ get connStateEnabled(): boolean;
2075
+ get vars(): V;
2076
+ get db(): InferDatabaseClient<DB>;
2077
+ start(actorDriver: ActorDriver, inlineClient: Client<Registry<any>>, actorId: string, name: string, key: ActorKey, region: string): Promise<void>;
2078
+ isReady(): boolean;
2079
+ assertReady(allowStoppingState?: boolean): void;
2080
+ cleanupPersistedConnections(reason?: string): Promise<number>;
2081
+ onStop(mode: "sleep" | "destroy"): Promise<void>;
2082
+ startSleep(): void;
2083
+ startDestroy(): void;
2084
+ beginHonoHttpRequest(): void;
2085
+ endHonoHttpRequest(): void;
2086
+ processMessage(message: {
2087
+ body: {
2088
+ tag: "ActionRequest";
2089
+ val: {
2090
+ id: bigint;
2091
+ name: string;
2092
+ args: unknown;
2093
+ };
2094
+ } | {
2095
+ tag: "SubscriptionRequest";
2096
+ val: {
2097
+ eventName: string;
2098
+ subscribe: boolean;
2099
+ };
2100
+ };
2101
+ }, conn: Conn<S, CP, CS, V, I, DB, E, Q>): Promise<void>;
2102
+ assertCanSubscribe(ctx: ActionContext<S, CP, CS, V, I, DB, E, Q>, eventName: string): Promise<void>;
2103
+ assertCanPublish(ctx: ActionContext<S, CP, CS, V, I, DB, E, Q>, queueName: string): Promise<void>;
2104
+ executeAction(ctx: ActionContext<S, CP, CS, V, I, DB, E, Q>, actionName: string, args: unknown[]): Promise<unknown>;
2105
+ handleRawRequest(conn: Conn<S, CP, CS, V, I, DB, E, Q>, request: Request): Promise<Response>;
2106
+ handleRawWebSocket(conn: Conn<S, CP, CS, V, I, DB, E, Q>, websocket: UniversalWebSocket, request?: Request): void;
2107
+ scheduleEvent(timestamp: number, action: string, args: unknown[]): Promise<void>;
2108
+ onAlarm(): Promise<void>;
2109
+ waitUntil(promise: Promise<void>): void;
2110
+ /**
2111
+ * Prevents the actor from sleeping while the given promise is running.
2112
+ *
2113
+ * Use this when performing async operations in the `run` handler or other
2114
+ * background contexts where you need to ensure the actor stays awake.
2115
+ *
2116
+ * Returns the resolved value and resets the sleep timer on completion.
2117
+ * Errors are propagated to the caller.
2118
+ */
2119
+ keepAwake<T>(promise: Promise<T>): Promise<T>;
2120
+ beginQueueWait(): void;
2121
+ endQueueWait(): void;
2122
+ resetSleepTimer(): void;
2123
+ }
2124
+
2125
+ /** Pick a subset of persisted data used to represent ephemeral connections */
2126
+ type EphemeralConn<CP, CS> = Pick<PersistedConn<CP, CS>, "id" | "parameters" | "state">;
2127
+ type ConnDataInput<CP, CS> = {
2128
+ ephemeral: EphemeralConn<CP, CS>;
2129
+ } | {
2130
+ hibernatable: PersistedConn<CP, CS>;
2131
+ };
2132
+ /**
2133
+ * Manages connection state persistence, proxying, and change tracking.
2134
+ * Handles automatic state change detection for connection-specific state.
2135
+ */
2136
+ declare class StateManager<CP, CS> {
2137
+ #private;
2138
+ constructor(conn: Conn<any, CP, CS, any, any, any, any, any>, data: ConnDataInput<CP, CS>);
2139
+ /**
2140
+ * Returns the ephemeral or persisted data for this connectioned.
2141
+ *
2142
+ * This property is used to be able to treat both memory & persist conns
2143
+ * identical by looking up the correct underlying data structure.
2144
+ */
2145
+ get ephemeralData(): EphemeralConn<CP, CS>;
2146
+ get hibernatableData(): PersistedConn<CP, CS> | undefined;
2147
+ hibernatableDataOrError(): PersistedConn<CP, CS>;
2148
+ get hibernatableDataRaw(): PersistedConn<CP, CS> | undefined;
2149
+ get stateEnabled(): boolean;
2150
+ get state(): CS;
2151
+ set state(value: CS);
2152
+ addSubscription({ eventName }: {
2153
+ eventName: string;
2154
+ }): void;
2155
+ removeSubscription({ eventName }: {
2156
+ eventName: string;
2157
+ }): boolean | undefined;
2158
+ }
2159
+
2160
+ type ConnId = string;
2161
+ type AnyConn = Conn<any, any, any, any, any, any, any, any>;
2162
+ declare const CONN_CONNECTED_SYMBOL: unique symbol;
2163
+ declare const CONN_SPEAKS_RIVETKIT_SYMBOL: unique symbol;
2164
+ declare const CONN_DRIVER_SYMBOL: unique symbol;
2165
+ declare const CONN_ACTOR_SYMBOL: unique symbol;
2166
+ declare const CONN_STATE_MANAGER_SYMBOL: unique symbol;
2167
+ declare const CONN_SEND_MESSAGE_SYMBOL: unique symbol;
2168
+ /**
2169
+ * Represents a client connection to a actor.
2170
+ *
2171
+ * Manages connection-specific data and controls the connection lifecycle.
2172
+ *
2173
+ * @see {@link https://rivet.dev/docs/connections|Connection Documentation}
2174
+ */
2175
+ declare class Conn<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>> {
2176
+ #private;
2177
+ get [CONN_ACTOR_SYMBOL](): ActorInstance<S, CP, CS, V, I, DB, E, Q>;
2178
+ get [CONN_STATE_MANAGER_SYMBOL](): StateManager<CP, CS>;
2179
+ /**
2180
+ * Connections exist before being connected to an actor. If true, this
2181
+ * connection has been connected.
2182
+ **/
2183
+ [CONN_CONNECTED_SYMBOL]: boolean;
2184
+ /**
2185
+ * If undefined, then no socket is connected to this conn
2186
+ */
2187
+ [CONN_DRIVER_SYMBOL]?: ConnDriver;
2188
+ /**
2189
+ * If this connection is speaking the RivetKit protocol. If false, this is
2190
+ * a raw connection for WebSocket or fetch or inspector.
2191
+ **/
2192
+ get [CONN_SPEAKS_RIVETKIT_SYMBOL](): boolean;
2193
+ subscriptions: Set<string>;
2194
+ get params(): CP;
2195
+ /**
2196
+ * Gets the current state of the connection.
2197
+ *
2198
+ * Throws an error if the state is not enabled.
2199
+ */
2200
+ get state(): CS;
2201
+ /**
2202
+ * Sets the state of the connection.
2203
+ *
2204
+ * Throws an error if the state is not enabled.
2205
+ */
2206
+ set state(value: CS);
2207
+ /**
2208
+ * Unique identifier for the connection.
2209
+ */
2210
+ get id(): ConnId;
2211
+ /**
2212
+ * @experimental
2213
+ *
2214
+ * If the underlying connection can hibernate.
2215
+ */
2216
+ get isHibernatable(): boolean;
2217
+ /**
2218
+ * Initializes a new instance of the Connection class.
2219
+ *
2220
+ * This should only be constructed by {@link Actor}.
2221
+ *
2222
+ * @protected
2223
+ */
2224
+ constructor(actor: ActorInstance<S, CP, CS, V, I, DB, E, Q>, data: ConnDataInput<CP, CS>);
2225
+ /**
2226
+ * Sends a raw message to the underlying connection.
2227
+ */
2228
+ [CONN_SEND_MESSAGE_SYMBOL](message: CachedSerializer<any, any, any>): void;
2229
+ /**
2230
+ * Sends an event with arguments to the client.
2231
+ *
2232
+ * @param eventName - The name of the event.
2233
+ * @param args - The arguments for the event.
2234
+ * @see {@link https://rivet.dev/docs/events|Events Documentation}
2235
+ */
2236
+ send<K extends keyof E & string>(eventName: K, ...args: InferEventArgs<InferSchemaMap<E>[K]>): void;
2237
+ send(eventName: keyof E extends never ? string : never, ...args: unknown[]): void;
2238
+ /**
2239
+ * Disconnects the client with an optional reason.
2240
+ *
2241
+ * @param reason - The reason for disconnection.
2242
+ */
2243
+ disconnect(reason?: string): Promise<void>;
2244
+ }
2245
+
2246
+ interface ActorTypes<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> {
2247
+ state?: TState;
2248
+ connParams?: TConnParams;
2249
+ connState?: TConnState;
2250
+ vars?: TVars;
2251
+ input?: TInput;
2252
+ database?: TDatabase;
2253
+ }
2254
+ type InspectorUnsubscribe = () => void;
2255
+ interface WorkflowInspectorConfig<THistory = unknown> {
2256
+ getHistory: () => THistory | null;
2257
+ onHistoryUpdated?: (listener: (history: THistory) => void) => InspectorUnsubscribe;
2258
+ }
2259
+ interface RunInspectorConfig<THistory = unknown> {
2260
+ workflow?: WorkflowInspectorConfig<THistory>;
2261
+ }
2262
+ declare const RunConfigSchema: z$1.ZodObject<{
2263
+ name: z$1.ZodOptional<z$1.ZodString>;
2264
+ icon: z$1.ZodOptional<z$1.ZodString>;
2265
+ run: z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>;
2266
+ inspector: z$1.ZodOptional<z$1.ZodOptional<z$1.ZodObject<{
2267
+ workflow: z$1.ZodOptional<z$1.ZodObject<{
2268
+ getHistory: z$1.ZodCustom<() => unknown, () => unknown>;
2269
+ onHistoryUpdated: z$1.ZodOptional<z$1.ZodCustom<(listener: (history: unknown) => void) => InspectorUnsubscribe, (listener: (history: unknown) => void) => InspectorUnsubscribe>>;
2270
+ }, z$1.core.$strip>>;
2271
+ }, z$1.core.$strip>>>;
2272
+ }, z$1.core.$strip>;
2273
+ type RunConfigRuntime = z$1.infer<typeof RunConfigSchema>;
2274
+ 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"> & {
2275
+ run: (c: RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
2276
+ };
2277
+ type AnyRunConfig = RunConfig<any, any, any, any, any, AnyDatabaseProvider, any, any>;
2278
+ declare const RUN_FUNCTION_CONFIG_SYMBOL: unique symbol;
2279
+ /** Extract the run function from either a function or RunConfig object. */
2280
+ declare function getRunFunction(run: ((...args: any[]) => any) | AnyRunConfig | undefined): ((...args: any[]) => any) | undefined;
2281
+ /** Extract run metadata (name/icon) from RunConfig if provided. */
2282
+ declare function getRunMetadata(run: ((...args: any[]) => any) | AnyRunConfig | undefined): {
2283
+ name?: string;
2284
+ icon?: string;
2285
+ };
2286
+ /** Extract run inspector configuration if provided. */
2287
+ declare function getRunInspectorConfig(run: ((...args: any[]) => any) | AnyRunConfig | undefined): RunInspectorConfig | undefined;
2288
+ declare const ActorConfigSchema: z$1.ZodObject<{
2289
+ onCreate: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2290
+ onDestroy: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2291
+ onWake: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2292
+ onSleep: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2293
+ run: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>, z$1.ZodObject<{
2294
+ name: z$1.ZodOptional<z$1.ZodString>;
2295
+ icon: z$1.ZodOptional<z$1.ZodString>;
2296
+ run: z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>;
2297
+ inspector: z$1.ZodOptional<z$1.ZodOptional<z$1.ZodObject<{
2298
+ workflow: z$1.ZodOptional<z$1.ZodObject<{
2299
+ getHistory: z$1.ZodCustom<() => unknown, () => unknown>;
2300
+ onHistoryUpdated: z$1.ZodOptional<z$1.ZodCustom<(listener: (history: unknown) => void) => InspectorUnsubscribe, (listener: (history: unknown) => void) => InspectorUnsubscribe>>;
2301
+ }, z$1.core.$strip>>;
2302
+ }, z$1.core.$strip>>>;
2303
+ }, z$1.core.$strip>]>>;
2304
+ onStateChange: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2305
+ onBeforeConnect: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2306
+ onConnect: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2307
+ onDisconnect: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2308
+ onBeforeActionResponse: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2309
+ onRequest: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2310
+ onWebSocket: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2311
+ actions: z$1.ZodDefault<z$1.ZodRecord<z$1.ZodString, z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>>;
2312
+ events: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
2313
+ queues: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
2314
+ state: z$1.ZodOptional<z$1.ZodAny>;
2315
+ createState: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2316
+ connState: z$1.ZodOptional<z$1.ZodAny>;
2317
+ createConnState: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2318
+ vars: z$1.ZodOptional<z$1.ZodAny>;
2319
+ db: z$1.ZodOptional<z$1.ZodAny>;
2320
+ createVars: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
2321
+ options: z$1.ZodPrefault<z$1.ZodObject<{
2322
+ name: z$1.ZodOptional<z$1.ZodString>;
2323
+ icon: z$1.ZodOptional<z$1.ZodString>;
2324
+ createVarsTimeout: z$1.ZodDefault<z$1.ZodNumber>;
2325
+ createConnStateTimeout: z$1.ZodDefault<z$1.ZodNumber>;
2326
+ onConnectTimeout: z$1.ZodDefault<z$1.ZodNumber>;
2327
+ onSleepTimeout: z$1.ZodDefault<z$1.ZodNumber>;
2328
+ onDestroyTimeout: z$1.ZodDefault<z$1.ZodNumber>;
2329
+ stateSaveInterval: z$1.ZodDefault<z$1.ZodNumber>;
2330
+ actionTimeout: z$1.ZodDefault<z$1.ZodNumber>;
2331
+ waitUntilTimeout: z$1.ZodDefault<z$1.ZodNumber>;
2332
+ runStopTimeout: z$1.ZodDefault<z$1.ZodNumber>;
2333
+ connectionLivenessTimeout: z$1.ZodDefault<z$1.ZodNumber>;
2334
+ connectionLivenessInterval: z$1.ZodDefault<z$1.ZodNumber>;
2335
+ noSleep: z$1.ZodDefault<z$1.ZodBoolean>;
2336
+ sleepTimeout: z$1.ZodDefault<z$1.ZodNumber>;
2337
+ maxQueueSize: z$1.ZodDefault<z$1.ZodNumber>;
2338
+ maxQueueMessageSize: z$1.ZodDefault<z$1.ZodNumber>;
2339
+ canHibernateWebSocket: z$1.ZodDefault<z$1.ZodUnion<readonly [z$1.ZodBoolean, z$1.ZodCustom<(request: Request) => boolean, (request: Request) => boolean>]>>;
2340
+ }, z$1.core.$strict>>;
2341
+ }, z$1.core.$strict>;
2342
+ type CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
2343
+ state: TState;
2344
+ } | {
2345
+ createState: (c: CreateContext<TState, TInput, TDatabase, TEvents, TQueues>, input: TInput) => TState | Promise<TState>;
2346
+ } | Record<never, never>;
2347
+ type CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
2348
+ connState: TConnState;
2349
+ } | {
2350
+ createConnState: (c: CreateConnStateContext<TState, TVars, TInput, TDatabase, TEvents, TQueues>, params: TConnParams) => TConnState | Promise<TConnState>;
2351
+ } | Record<never, never>;
2352
+ /**
2353
+ * @experimental
2354
+ */
2355
+ type CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
2356
+ /**
2357
+ * @experimental
2358
+ */
2359
+ vars: TVars;
2360
+ } | {
2361
+ /**
2362
+ * @experimental
2363
+ */
2364
+ createVars: (c: CreateVarsContext<TState, TInput, TDatabase, TEvents, TQueues>, driverCtx: any) => TVars | Promise<TVars>;
2365
+ } | Record<never, never>;
2366
+ interface Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
2367
+ [Action: string]: (c: ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, ...args: any[]) => any;
2368
+ }
2369
+ /**
2370
+ * @experimental
2371
+ */
2372
+ type AuthIntent = "get" | "create" | "connect" | "action" | "message";
2373
+ 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>> {
2374
+ /**
2375
+ * Called when the actor is first initialized.
2376
+ *
2377
+ * Use this hook to initialize your actor's state.
2378
+ * This is called before any other lifecycle hooks.
2379
+ */
2380
+ onCreate?: (c: CreateContext<TState, TInput, TDatabase, TEvents, TQueues>, input: TInput) => void | Promise<void>;
2381
+ /**
2382
+ * Called when the actor is destroyed.
2383
+ */
2384
+ onDestroy?: (c: DestroyContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
2385
+ /**
2386
+ * Called when the actor is started and ready to receive connections and action.
2387
+ *
2388
+ * Use this hook to initialize resources needed for the actor's operation
2389
+ * (timers, external connections, etc.)
2390
+ *
2391
+ * @returns Void or a Promise that resolves when startup is complete
2392
+ */
2393
+ onWake?: (c: WakeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
2394
+ /**
2395
+ * Called when the actor is stopping or sleeping.
2396
+ *
2397
+ * Use this hook to clean up resources, save state, or perform
2398
+ * any shutdown operations before the actor sleeps or stops.
2399
+ *
2400
+ * Not supported on all platforms.
2401
+ *
2402
+ * @returns Void or a Promise that resolves when shutdown is complete
2403
+ */
2404
+ onSleep?: (c: SleepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
2405
+ /**
2406
+ * Called after the actor starts up. Does not block actor startup.
2407
+ *
2408
+ * Use this for background tasks like:
2409
+ * - Reading from queues in a loop
2410
+ * - Tick loops for periodic work
2411
+ * - Custom workflow logic
2412
+ *
2413
+ * **Important:** The actor may go to sleep at any time during the `run`
2414
+ * handler. Use `c.keepAwake(promise)` to wrap async operations that should
2415
+ * not be interrupted by sleep.
2416
+ *
2417
+ * The handler receives an abort signal via `c.abortSignal` and a
2418
+ * `c.aborted` alias for loop checks. Use these to gracefully exit.
2419
+ *
2420
+ * If this handler exits or throws, the actor will crash and reschedule.
2421
+ * On shutdown, the actor waits for this handler to complete with a
2422
+ * configurable timeout (options.runStopTimeout, default 15s).
2423
+ *
2424
+ * Can be either a function or a RunConfig object with optional name/icon metadata.
2425
+ *
2426
+ * @returns Void or a Promise. If the promise exits, the actor crashes.
2427
+ */
2428
+ run?: ((c: RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>) | RunConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
2429
+ /**
2430
+ * Called when the actor's state changes.
2431
+ *
2432
+ * Use this hook to react to state changes, such as updating
2433
+ * external systems or triggering events.
2434
+ *
2435
+ * State changes made within this hook will NOT trigger
2436
+ * another onStateChange call, preventing infinite recursion.
2437
+ *
2438
+ * @param newState The updated state
2439
+ */
2440
+ onStateChange?: (c: StateChangeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, newState: TState) => void;
2441
+ /**
2442
+ * Called before a client connects to the actor.
2443
+ *
2444
+ * Use this hook to determine if a connection should be accepted
2445
+ * and to initialize connection-specific state.
2446
+ *
2447
+ * @param opts Connection parameters including client-provided data
2448
+ * @returns The initial connection state or a Promise that resolves to it
2449
+ * @throws Throw an error to reject the connection
2450
+ */
2451
+ onBeforeConnect?: (c: BeforeConnectContext<TState, TVars, TInput, TDatabase, TEvents, TQueues>, params: TConnParams) => void | Promise<void>;
2452
+ /**
2453
+ * Called when a client successfully connects to the actor.
2454
+ *
2455
+ * Use this hook to perform actions when a connection is established,
2456
+ * such as sending initial data or updating the actor's state.
2457
+ *
2458
+ * @param conn The connection object
2459
+ * @returns Void or a Promise that resolves when connection handling is complete
2460
+ */
2461
+ onConnect?: (c: ConnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
2462
+ /**
2463
+ * Called when a client disconnects from the actor.
2464
+ *
2465
+ * Use this hook to clean up resources associated with the connection
2466
+ * or update the actor's state.
2467
+ *
2468
+ * @param conn The connection that is being closed
2469
+ * @returns Void or a Promise that resolves when disconnect handling is complete
2470
+ */
2471
+ onDisconnect?: (c: DisconnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
2472
+ /**
2473
+ * Called before sending an action response to the client.
2474
+ *
2475
+ * Use this hook to modify or transform the output of an action before it's sent
2476
+ * to the client. This is useful for formatting responses, adding metadata,
2477
+ * or applying transformations to the output.
2478
+ *
2479
+ * @param name The name of the action that was called
2480
+ * @param args The arguments that were passed to the action
2481
+ * @param output The output that will be sent to the client
2482
+ * @returns The modified output to send to the client
2483
+ */
2484
+ onBeforeActionResponse?: <Out>(c: BeforeActionResponseContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, name: string, args: unknown[], output: Out) => Out | Promise<Out>;
2485
+ /**
2486
+ * Called when a raw HTTP request is made to the actor.
2487
+ *
2488
+ * This handler receives raw HTTP requests made to `/actors/{actorName}/http/*` endpoints.
2489
+ * Use this hook to handle custom HTTP patterns, REST APIs, or other HTTP-based protocols.
2490
+ *
2491
+ * @param c The request context with access to the connection
2492
+ * @param request The raw HTTP request object
2493
+ * @param opts Additional options
2494
+ * @returns A Response object to send back, or void to continue with default routing
2495
+ */
2496
+ onRequest?: (c: RequestContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, request: Request) => Response | Promise<Response>;
2497
+ /**
2498
+ * Called when a raw WebSocket connection is established to the actor.
2499
+ *
2500
+ * This handler receives WebSocket connections made to `/actors/{actorName}/websocket/*` endpoints.
2501
+ * Use this hook to handle custom WebSocket protocols, binary streams, or other WebSocket-based communication.
2502
+ *
2503
+ * @param c The WebSocket context with access to the connection
2504
+ * @param websocket The raw WebSocket connection
2505
+ * @param opts Additional options including the original HTTP upgrade request
2506
+ */
2507
+ onWebSocket?: (c: WebSocketContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, websocket: UniversalWebSocket) => void | Promise<void>;
2508
+ actions?: TActions;
2509
+ /**
2510
+ * Schema map for events broadcasted by this actor.
2511
+ */
2512
+ events?: TEvents;
2513
+ /**
2514
+ * Schema map for queue payloads sent by this actor.
2515
+ */
2516
+ queues?: TQueues;
2517
+ }
2518
+ type ActorDatabaseConfig<TDatabase extends AnyDatabaseProvider> = {
2519
+ /**
2520
+ * @experimental
2521
+ */
2522
+ db: TDatabase;
2523
+ } | Record<never, never>;
2524
+ 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>;
2525
+ 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>> = {
2526
+ types?: ActorTypes<TState, TConnParams, TConnState, TVars, TInput, TDatabase>;
2527
+ } & 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>;
2528
+ 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>;
2529
+ declare const DocActorOptionsSchema: z$1.ZodObject<{
2530
+ name: z$1.ZodOptional<z$1.ZodString>;
2531
+ icon: z$1.ZodOptional<z$1.ZodString>;
2532
+ createVarsTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2533
+ createConnStateTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2534
+ onConnectTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2535
+ onSleepTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2536
+ onDestroyTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2537
+ stateSaveInterval: z$1.ZodOptional<z$1.ZodNumber>;
2538
+ actionTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2539
+ waitUntilTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2540
+ runStopTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2541
+ connectionLivenessTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2542
+ connectionLivenessInterval: z$1.ZodOptional<z$1.ZodNumber>;
2543
+ noSleep: z$1.ZodOptional<z$1.ZodBoolean>;
2544
+ sleepTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2545
+ maxQueueSize: z$1.ZodOptional<z$1.ZodNumber>;
2546
+ maxQueueMessageSize: z$1.ZodOptional<z$1.ZodNumber>;
2547
+ canHibernateWebSocket: z$1.ZodOptional<z$1.ZodBoolean>;
2548
+ }, z$1.core.$strip>;
2549
+ declare const DocActorConfigSchema: z$1.ZodObject<{
2550
+ state: z$1.ZodOptional<z$1.ZodUnknown>;
2551
+ createState: z$1.ZodOptional<z$1.ZodUnknown>;
2552
+ connState: z$1.ZodOptional<z$1.ZodUnknown>;
2553
+ createConnState: z$1.ZodOptional<z$1.ZodUnknown>;
2554
+ vars: z$1.ZodOptional<z$1.ZodUnknown>;
2555
+ createVars: z$1.ZodOptional<z$1.ZodUnknown>;
2556
+ db: z$1.ZodOptional<z$1.ZodUnknown>;
2557
+ onCreate: z$1.ZodOptional<z$1.ZodUnknown>;
2558
+ onDestroy: z$1.ZodOptional<z$1.ZodUnknown>;
2559
+ onWake: z$1.ZodOptional<z$1.ZodUnknown>;
2560
+ onSleep: z$1.ZodOptional<z$1.ZodUnknown>;
2561
+ run: z$1.ZodOptional<z$1.ZodUnknown>;
2562
+ onStateChange: z$1.ZodOptional<z$1.ZodUnknown>;
2563
+ onBeforeConnect: z$1.ZodOptional<z$1.ZodUnknown>;
2564
+ onConnect: z$1.ZodOptional<z$1.ZodUnknown>;
2565
+ onDisconnect: z$1.ZodOptional<z$1.ZodUnknown>;
2566
+ onBeforeActionResponse: z$1.ZodOptional<z$1.ZodUnknown>;
2567
+ onRequest: z$1.ZodOptional<z$1.ZodUnknown>;
2568
+ onWebSocket: z$1.ZodOptional<z$1.ZodUnknown>;
2569
+ actions: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
2570
+ events: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
2571
+ queues: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
2572
+ options: z$1.ZodOptional<z$1.ZodObject<{
2573
+ name: z$1.ZodOptional<z$1.ZodString>;
2574
+ icon: z$1.ZodOptional<z$1.ZodString>;
2575
+ createVarsTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2576
+ createConnStateTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2577
+ onConnectTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2578
+ onSleepTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2579
+ onDestroyTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2580
+ stateSaveInterval: z$1.ZodOptional<z$1.ZodNumber>;
2581
+ actionTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2582
+ waitUntilTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2583
+ runStopTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2584
+ connectionLivenessTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2585
+ connectionLivenessInterval: z$1.ZodOptional<z$1.ZodNumber>;
2586
+ noSleep: z$1.ZodOptional<z$1.ZodBoolean>;
2587
+ sleepTimeout: z$1.ZodOptional<z$1.ZodNumber>;
2588
+ maxQueueSize: z$1.ZodOptional<z$1.ZodNumber>;
2589
+ maxQueueMessageSize: z$1.ZodOptional<z$1.ZodNumber>;
2590
+ canHibernateWebSocket: z$1.ZodOptional<z$1.ZodBoolean>;
2591
+ }, z$1.core.$strip>>;
2592
+ }, z$1.core.$strip>;
2593
+
2594
+ 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 QueueNextBatchOptions as bc, type InferSchemaMap as bd, type InferDatabaseClient as be, type InferEventArgs as bf, 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 };