rivetkit 0.0.0-main.a904d4f → 0.0.0-main.b2d3b94

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 (300) hide show
  1. package/dist/browser/client.d.ts +949 -104
  2. package/dist/browser/client.js +1702 -707
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.d.ts +252 -129
  5. package/dist/browser/inspector/client.js +2079 -233
  6. package/dist/browser/inspector/client.js.map +1 -1
  7. package/dist/tsup/actor/errors.cjs +6 -2
  8. package/dist/tsup/actor/errors.cjs.map +1 -1
  9. package/dist/tsup/actor/errors.d.cts +1 -74
  10. package/dist/tsup/actor/errors.d.ts +1 -74
  11. package/dist/tsup/actor/errors.js +5 -1
  12. package/dist/tsup/agent-os/index.cjs +2408 -2029
  13. package/dist/tsup/agent-os/index.cjs.map +1 -1
  14. package/dist/tsup/agent-os/index.d.cts +942 -114
  15. package/dist/tsup/agent-os/index.d.ts +942 -114
  16. package/dist/tsup/agent-os/index.js +2412 -2033
  17. package/dist/tsup/agent-os/index.js.map +1 -1
  18. package/dist/tsup/{chunk-VUOHCAFE.cjs → chunk-2IQC4K2O.cjs} +1348 -519
  19. package/dist/tsup/chunk-2IQC4K2O.cjs.map +1 -0
  20. package/dist/tsup/{chunk-EKNNADY4.cjs → chunk-37KUQDMK.cjs} +3 -3
  21. package/dist/tsup/chunk-37KUQDMK.cjs.map +1 -0
  22. package/dist/tsup/{chunk-AK57AL7S.cjs → chunk-4KGXFC6M.cjs} +238 -22
  23. package/dist/tsup/chunk-4KGXFC6M.cjs.map +1 -0
  24. package/dist/tsup/{chunk-FYU2E424.js → chunk-4PWBZFDL.js} +6 -6
  25. package/dist/tsup/chunk-4PWBZFDL.js.map +1 -0
  26. package/dist/tsup/{chunk-UCNWWNAK.js → chunk-5G3T73UZ.js} +1224 -395
  27. package/dist/tsup/chunk-5G3T73UZ.js.map +1 -0
  28. package/dist/tsup/{chunk-26A5VRUX.cjs → chunk-6BPEJOVY.cjs} +18 -11
  29. package/dist/tsup/chunk-6BPEJOVY.cjs.map +1 -0
  30. package/dist/tsup/{chunk-7MRGNVSR.js → chunk-6W5VGLFT.js} +237 -21
  31. package/dist/tsup/chunk-6W5VGLFT.js.map +1 -0
  32. package/dist/tsup/{chunk-FEHBT5R3.js → chunk-77ELMRQG.js} +16 -9
  33. package/dist/tsup/chunk-77ELMRQG.js.map +1 -0
  34. package/dist/tsup/chunk-7NDNXFWX.cjs +1257 -0
  35. package/dist/tsup/chunk-7NDNXFWX.cjs.map +1 -0
  36. package/dist/tsup/{chunk-UJU6T2YN.js → chunk-ADHLA6ZD.js} +594 -72
  37. package/dist/tsup/chunk-ADHLA6ZD.js.map +1 -0
  38. package/dist/tsup/chunk-B5MBSXX6.js +243 -0
  39. package/dist/tsup/chunk-B5MBSXX6.js.map +1 -0
  40. package/dist/tsup/{chunk-2TT4HHAE.js → chunk-BBQJVQXT.js} +2 -2
  41. package/dist/tsup/chunk-FOQHHXJ7.js +14 -0
  42. package/dist/tsup/chunk-FOQHHXJ7.js.map +1 -0
  43. package/dist/tsup/chunk-GRZB7FGO.cjs +243 -0
  44. package/dist/tsup/chunk-GRZB7FGO.cjs.map +1 -0
  45. package/dist/tsup/{chunk-ZGWSH7YV.js → chunk-IXBD7BXC.js} +48 -72
  46. package/dist/tsup/chunk-IXBD7BXC.js.map +1 -0
  47. package/dist/tsup/chunk-J46J2NAB.cjs +14 -0
  48. package/dist/tsup/chunk-J46J2NAB.cjs.map +1 -0
  49. package/dist/tsup/{chunk-3BFYSYRU.js → chunk-JI6GZ2C2.js} +4 -12
  50. package/dist/tsup/chunk-JI6GZ2C2.js.map +1 -0
  51. package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JTHHCZCZ.js} +24 -1
  52. package/dist/tsup/chunk-JTHHCZCZ.js.map +1 -0
  53. package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-KVFIONKQ.cjs} +25 -2
  54. package/dist/tsup/chunk-KVFIONKQ.cjs.map +1 -0
  55. package/dist/tsup/{chunk-SNLONX3U.cjs → chunk-LIL22VCI.cjs} +10 -10
  56. package/dist/tsup/chunk-LIL22VCI.cjs.map +1 -0
  57. package/dist/tsup/{chunk-LLD2D5LO.cjs → chunk-MYWZCDML.cjs} +4 -12
  58. package/dist/tsup/chunk-MYWZCDML.cjs.map +1 -0
  59. package/dist/tsup/{chunk-YZ3UW53N.js → chunk-ODZI35CD.js} +70 -8
  60. package/dist/tsup/chunk-ODZI35CD.js.map +1 -0
  61. package/dist/tsup/{chunk-JTL6Y2UN.cjs → chunk-SPJORZMM.cjs} +49 -73
  62. package/dist/tsup/chunk-SPJORZMM.cjs.map +1 -0
  63. package/dist/tsup/{chunk-7C27Y6XI.cjs → chunk-ZJ5W5FX5.cjs} +72 -10
  64. package/dist/tsup/chunk-ZJ5W5FX5.cjs.map +1 -0
  65. package/dist/tsup/client/mod.cjs +8 -9
  66. package/dist/tsup/client/mod.cjs.map +1 -1
  67. package/dist/tsup/client/mod.d.cts +18 -7
  68. package/dist/tsup/client/mod.d.ts +18 -7
  69. package/dist/tsup/client/mod.js +7 -8
  70. package/dist/tsup/common/log.cjs +5 -3
  71. package/dist/tsup/common/log.cjs.map +1 -1
  72. package/dist/tsup/common/log.d.cts +5 -1
  73. package/dist/tsup/common/log.d.ts +5 -1
  74. package/dist/tsup/common/log.js +6 -4
  75. package/dist/tsup/common/websocket.cjs +4 -4
  76. package/dist/tsup/common/websocket.cjs.map +1 -1
  77. package/dist/tsup/common/websocket.js +3 -3
  78. package/dist/tsup/{config-B3RIidaJ.d.ts → config-B5W9fynN.d.cts} +997 -72
  79. package/dist/tsup/{config-D6WxBYjV.d.cts → config-BDF1rXLB.d.ts} +997 -72
  80. package/dist/tsup/{config-B9qUIHX4.d.cts → config-ey2I2zz5.d.cts} +82 -15
  81. package/dist/tsup/{config-B9qUIHX4.d.ts → config-ey2I2zz5.d.ts} +82 -15
  82. package/dist/tsup/context-C7L81_hK.d.cts +129 -0
  83. package/dist/tsup/context-DLNpbLZ3.d.ts +129 -0
  84. package/dist/tsup/db/drizzle.cjs +168 -103
  85. package/dist/tsup/db/drizzle.cjs.map +1 -1
  86. package/dist/tsup/db/drizzle.d.cts +8 -4
  87. package/dist/tsup/db/drizzle.d.ts +8 -4
  88. package/dist/tsup/db/drizzle.js +170 -105
  89. package/dist/tsup/db/drizzle.js.map +1 -1
  90. package/dist/tsup/db/mod.cjs +6 -163
  91. package/dist/tsup/db/mod.cjs.map +1 -1
  92. package/dist/tsup/db/mod.d.cts +12 -4
  93. package/dist/tsup/db/mod.d.ts +12 -4
  94. package/dist/tsup/db/mod.js +5 -162
  95. package/dist/tsup/db/mod.js.map +1 -1
  96. package/dist/tsup/dynamic/mod.cjs +24 -0
  97. package/dist/tsup/dynamic/mod.cjs.map +1 -0
  98. package/dist/tsup/dynamic/mod.d.cts +38 -0
  99. package/dist/tsup/dynamic/mod.d.ts +38 -0
  100. package/dist/tsup/dynamic/mod.js +24 -0
  101. package/dist/tsup/dynamic/mod.js.map +1 -0
  102. package/dist/tsup/inspector/mod.cjs +47 -12
  103. package/dist/tsup/inspector/mod.cjs.map +1 -1
  104. package/dist/tsup/inspector/mod.d.cts +26 -136
  105. package/dist/tsup/inspector/mod.d.ts +26 -136
  106. package/dist/tsup/inspector/mod.js +46 -11
  107. package/dist/tsup/inspector/mod.js.map +1 -1
  108. package/dist/tsup/inspector/workflow.cjs +21 -0
  109. package/dist/tsup/inspector/workflow.cjs.map +1 -0
  110. package/dist/tsup/inspector/workflow.d.cts +144 -0
  111. package/dist/tsup/inspector/workflow.d.ts +144 -0
  112. package/dist/tsup/inspector/workflow.js +21 -0
  113. package/dist/tsup/inspector/workflow.js.map +1 -0
  114. package/dist/tsup/inspector-tab/mod.cjs +162 -0
  115. package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
  116. package/dist/tsup/inspector-tab/mod.d.cts +241 -0
  117. package/dist/tsup/inspector-tab/mod.d.ts +241 -0
  118. package/dist/tsup/inspector-tab/mod.js +162 -0
  119. package/dist/tsup/inspector-tab/mod.js.map +1 -0
  120. package/dist/tsup/mod.cjs +4525 -981
  121. package/dist/tsup/mod.cjs.map +1 -1
  122. package/dist/tsup/mod.d.cts +9 -8
  123. package/dist/tsup/mod.d.ts +9 -8
  124. package/dist/tsup/mod.js +4485 -941
  125. package/dist/tsup/mod.js.map +1 -1
  126. package/dist/tsup/test/mod.cjs +26 -21
  127. package/dist/tsup/test/mod.cjs.map +1 -1
  128. package/dist/tsup/test/mod.d.cts +7 -6
  129. package/dist/tsup/test/mod.d.ts +7 -6
  130. package/dist/tsup/test/mod.js +25 -20
  131. package/dist/tsup/test/mod.js.map +1 -1
  132. package/dist/tsup/unstable/migrations.cjs +101 -0
  133. package/dist/tsup/unstable/migrations.cjs.map +1 -0
  134. package/dist/tsup/unstable/migrations.d.cts +29 -0
  135. package/dist/tsup/unstable/migrations.d.ts +29 -0
  136. package/dist/tsup/unstable/migrations.js +101 -0
  137. package/dist/tsup/unstable/migrations.js.map +1 -0
  138. package/dist/tsup/utils-Bbz-3411.d.cts +162 -0
  139. package/dist/tsup/utils-BqdWVlzm.d.ts +162 -0
  140. package/dist/tsup/utils-vvJQyygr.d.cts +109 -0
  141. package/dist/tsup/utils-vvJQyygr.d.ts +109 -0
  142. package/dist/tsup/utils.cjs +7 -3
  143. package/dist/tsup/utils.cjs.map +1 -1
  144. package/dist/tsup/utils.d.cts +4 -147
  145. package/dist/tsup/utils.d.ts +4 -147
  146. package/dist/tsup/utils.js +6 -2
  147. package/dist/tsup/workflow/mod.cjs +517 -412
  148. package/dist/tsup/workflow/mod.cjs.map +1 -1
  149. package/dist/tsup/workflow/mod.d.cts +11 -10
  150. package/dist/tsup/workflow/mod.d.ts +11 -10
  151. package/dist/tsup/workflow/mod.js +511 -406
  152. package/dist/tsup/workflow/mod.js.map +1 -1
  153. package/package.json +62 -14
  154. package/src/actor/actions.ts +119 -0
  155. package/src/actor/config.test.ts +78 -0
  156. package/src/actor/config.ts +518 -96
  157. package/src/actor/contexts/index.ts +7 -2
  158. package/src/actor/definition.ts +38 -26
  159. package/src/actor/errors.ts +101 -89
  160. package/src/actor/keys.ts +2 -1
  161. package/src/actor/mod.ts +32 -21
  162. package/src/actor/schema.ts +2 -2
  163. package/src/agent-os/actor/cron.ts +37 -2
  164. package/src/agent-os/actor/index.ts +39 -19
  165. package/src/agent-os/actor/preview.ts +1 -2
  166. package/src/agent-os/actor/session.ts +2 -2
  167. package/src/agent-os/config.ts +1 -1
  168. package/src/agent-os/fs/database-vfs.ts +1 -1
  169. package/src/agent-os/index.ts +16 -15
  170. package/src/agent-os/types.ts +11 -0
  171. package/src/client/actor-common.ts +106 -53
  172. package/src/client/actor-conn.ts +94 -45
  173. package/src/client/actor-handle.ts +219 -90
  174. package/src/client/actor-query.ts +13 -6
  175. package/src/client/client.ts +43 -15
  176. package/src/client/config.ts +8 -0
  177. package/src/client/errors.ts +4 -2
  178. package/src/client/lifecycle-errors.ts +28 -4
  179. package/src/client/mod.ts +9 -4
  180. package/src/client/query.ts +3 -1
  181. package/src/client/queue.ts +8 -3
  182. package/src/client/raw-utils.ts +32 -16
  183. package/src/client/resolve-gateway-target.ts +3 -1
  184. package/src/client/utils.ts +36 -10
  185. package/src/common/actor-router-consts.ts +8 -0
  186. package/src/common/actor-websocket.ts +3 -1
  187. package/src/common/bare/actor-persist/v1.ts +205 -163
  188. package/src/common/bare/actor-persist/v2.ts +265 -213
  189. package/src/common/bare/actor-persist/v3.ts +176 -172
  190. package/src/common/bare/actor-persist/v4.ts +254 -253
  191. package/src/common/bare/generated/actor-runtime-socket-protocol/v1.ts +848 -0
  192. package/src/common/bare/generated/client-protocol/v4.ts +599 -0
  193. package/src/common/bare/generated/inspector/v5.ts +1016 -0
  194. package/src/common/bare/generated/inspector/v6.ts +1367 -0
  195. package/src/common/bare/transport/v1.ts +694 -542
  196. package/src/common/client-protocol-versioned.ts +176 -67
  197. package/src/common/client-protocol-zod.ts +7 -0
  198. package/src/common/client-protocol.ts +1 -1
  199. package/src/common/database/config.ts +103 -10
  200. package/src/common/database/mod.test.ts +364 -0
  201. package/src/common/database/mod.ts +278 -149
  202. package/src/common/database/native-database.test.ts +220 -0
  203. package/src/common/database/native-database.ts +394 -58
  204. package/src/common/database/shared.ts +25 -0
  205. package/src/common/encoding.ts +302 -38
  206. package/src/common/engine.ts +28 -1
  207. package/src/common/eventsource.ts +1 -1
  208. package/src/common/fetch-like.ts +49 -0
  209. package/src/common/inline-websocket-adapter.ts +14 -13
  210. package/src/common/inspector-transport.ts +12 -2
  211. package/src/common/log.ts +117 -14
  212. package/src/common/router.ts +49 -23
  213. package/src/common/utils.ts +23 -203
  214. package/src/common/websocket-interface.ts +1 -1
  215. package/src/db/drizzle.test.ts +164 -0
  216. package/src/db/drizzle.ts +207 -121
  217. package/src/db/mod.ts +6 -1
  218. package/src/devtools-loader/index.ts +4 -7
  219. package/src/devtools-loader/serve-devtools.ts +26 -0
  220. package/src/dynamic/instance.ts +32 -0
  221. package/src/dynamic/internal.ts +50 -0
  222. package/src/dynamic/isolate-runtime.ts +64 -0
  223. package/src/dynamic/mod.ts +32 -0
  224. package/src/engine-client/actor-http-client.ts +28 -25
  225. package/src/engine-client/actor-websocket-client.ts +32 -5
  226. package/src/engine-client/api-endpoints.ts +52 -2
  227. package/src/engine-client/api-utils.ts +2 -2
  228. package/src/engine-client/driver.ts +21 -17
  229. package/src/engine-client/mod.ts +163 -80
  230. package/src/engine-client/ws-proxy.ts +9 -4
  231. package/src/globals.d.ts +4 -0
  232. package/src/inspector/client.browser.ts +127 -15
  233. package/src/inspector/mod.ts +2 -4
  234. package/src/inspector/workflow.ts +61 -0
  235. package/src/inspector-tab/mod.ts +301 -0
  236. package/src/registry/config/envoy.ts +1 -2
  237. package/src/registry/config/index.ts +160 -53
  238. package/src/registry/config/serverless.ts +7 -1
  239. package/src/registry/index.ts +699 -96
  240. package/src/registry/napi-runtime.ts +1181 -0
  241. package/src/registry/native-http.ts +223 -0
  242. package/src/registry/native-validation.ts +10 -12
  243. package/src/registry/native.ts +2089 -992
  244. package/src/registry/process-metrics.ts +250 -0
  245. package/src/registry/run-handler-coordinator.test.ts +252 -0
  246. package/src/registry/run-handler-coordinator.ts +219 -0
  247. package/src/registry/runtime.test.ts +50 -0
  248. package/src/registry/runtime.ts +853 -0
  249. package/src/registry/wasm-runtime.ts +1283 -0
  250. package/src/registry/write-through-proxy.ts +141 -0
  251. package/src/serde.ts +8 -2
  252. package/src/serverless/configure.ts +102 -49
  253. package/src/test/mod.ts +2 -17
  254. package/src/test/ready.ts +22 -0
  255. package/src/unstable/migrations.test.ts +170 -0
  256. package/src/unstable/migrations.ts +141 -0
  257. package/src/utils/crypto.ts +14 -0
  258. package/src/utils/endpoint-parser.ts +1 -1
  259. package/src/utils/env-vars.ts +39 -0
  260. package/src/utils/node.ts +44 -28
  261. package/src/utils/router.ts +1 -1
  262. package/src/utils.ts +4 -2
  263. package/src/workflow/context.ts +683 -242
  264. package/src/workflow/driver.test.ts +62 -0
  265. package/src/workflow/driver.ts +246 -119
  266. package/src/workflow/inspector.ts +24 -24
  267. package/src/workflow/mod.ts +76 -84
  268. package/dist/tsup/chunk-26A5VRUX.cjs.map +0 -1
  269. package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
  270. package/dist/tsup/chunk-3BFYSYRU.js.map +0 -1
  271. package/dist/tsup/chunk-7C27Y6XI.cjs.map +0 -1
  272. package/dist/tsup/chunk-7MRGNVSR.js.map +0 -1
  273. package/dist/tsup/chunk-AK57AL7S.cjs.map +0 -1
  274. package/dist/tsup/chunk-EKNNADY4.cjs.map +0 -1
  275. package/dist/tsup/chunk-FEHBT5R3.js.map +0 -1
  276. package/dist/tsup/chunk-FV4UXVN5.js +0 -253
  277. package/dist/tsup/chunk-FV4UXVN5.js.map +0 -1
  278. package/dist/tsup/chunk-FYU2E424.js.map +0 -1
  279. package/dist/tsup/chunk-JTL6Y2UN.cjs.map +0 -1
  280. package/dist/tsup/chunk-LLD2D5LO.cjs.map +0 -1
  281. package/dist/tsup/chunk-MXGVKS3S.cjs +0 -735
  282. package/dist/tsup/chunk-MXGVKS3S.cjs.map +0 -1
  283. package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
  284. package/dist/tsup/chunk-SNLONX3U.cjs.map +0 -1
  285. package/dist/tsup/chunk-UCNWWNAK.js.map +0 -1
  286. package/dist/tsup/chunk-UJU6T2YN.js.map +0 -1
  287. package/dist/tsup/chunk-V46OWSAV.cjs +0 -253
  288. package/dist/tsup/chunk-V46OWSAV.cjs.map +0 -1
  289. package/dist/tsup/chunk-VUOHCAFE.cjs.map +0 -1
  290. package/dist/tsup/chunk-YZ3UW53N.js.map +0 -1
  291. package/dist/tsup/chunk-ZGWSH7YV.js.map +0 -1
  292. package/dist/tsup/context-BxvHh9wi.d.cts +0 -92
  293. package/dist/tsup/context-CNIZBIKl.d.ts +0 -92
  294. package/dist/tsup/utils-fwx3o3K9.d.cts +0 -18
  295. package/dist/tsup/utils-fwx3o3K9.d.ts +0 -18
  296. package/src/actor/driver.ts +0 -141
  297. package/src/actor/instance/mod.ts +0 -2501
  298. package/src/drivers/engine/actor-driver.ts +0 -2470
  299. package/src/utils/serve.ts +0 -217
  300. /package/dist/tsup/{chunk-2TT4HHAE.js.map → chunk-BBQJVQXT.js.map} +0 -0
@@ -1,40 +1,96 @@
1
+ import * as _rivetkit_rivetkit_wasm from '@rivetkit/rivetkit-wasm';
1
2
  import { z as z$2 } from 'zod';
2
3
  import z$1, { z } from 'zod/v4';
3
- import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
4
4
  import { Context, Handler, Hono } from 'hono';
5
+ import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
5
6
  import { StandardSchemaV1 } from '@standard-schema/spec';
6
7
  import { ContentfulStatusCode } from 'hono/utils/http-status';
7
8
  import { Logger } from 'pino';
8
9
 
9
- interface SqliteVfsMetrics {
10
- requestBuildNs: number;
11
- serializeNs: number;
12
- transportNs: number;
13
- stateUpdateNs: number;
14
- totalNs: number;
15
- commitCount: number;
16
- }
17
-
18
10
  type AnyDatabaseProvider = DatabaseProvider<any> | undefined;
19
11
  interface ActorMetricsLike {
20
12
  totalKvReads: number;
21
13
  totalKvWrites: number;
22
14
  trackSql(query: string, durationMs: number): void;
23
- setSqliteVfsMetricsSource(source?: () => SqliteVfsMetrics | null): void;
24
15
  }
25
- type InferDatabaseClient<DBProvider extends AnyDatabaseProvider> = DBProvider extends DatabaseProvider<any> ? Awaited<ReturnType<DBProvider["createClient"]>> : never;
16
+ type InferDatabaseClient<DBProvider extends AnyDatabaseProvider> = DBProvider extends DatabaseProvider<any> ? Awaited<ReturnType<DBProvider["createClient"]>> : RawAccess;
26
17
  type SqliteBindings = unknown[] | Record<string, unknown>;
27
18
  interface SqliteQueryResult {
28
19
  columns: string[];
29
20
  rows: unknown[][];
30
21
  }
22
+ interface SqliteExecuteResult extends SqliteQueryResult {
23
+ changes: number;
24
+ lastInsertRowId?: number | null;
25
+ }
26
+ interface SqliteBatchStatement {
27
+ sql: string;
28
+ params?: SqliteBindings;
29
+ }
30
+ interface SqliteTransactionOptions {
31
+ /** Static operation name used to aggregate transaction performance. */
32
+ name?: string;
33
+ /** Deadlock-safety timeout in milliseconds. */
34
+ timeout?: number;
35
+ /** @experimental */
36
+ experimental?: {
37
+ /**
38
+ * Atomically includes actor and hibernatable connection state.
39
+ * Only single-statement `execute` calls are supported in the transaction.
40
+ * Concurrent actions that try to mutate state while the transaction is
41
+ * active fail with `actor.state_transaction_conflict`.
42
+ */
43
+ includeState?: boolean;
44
+ };
45
+ }
46
+ /**
47
+ * SQLite profiling configuration.
48
+ *
49
+ * @experimental This entire configuration surface is experimental and subject
50
+ * to change without notice.
51
+ */
52
+ interface SqliteProfilingOptions {
53
+ enabled?: boolean;
54
+ maxTrackedStatementFingerprints?: number;
55
+ maxTrackedTransactionFingerprints?: number;
56
+ maxPrometheusSeries?: number;
57
+ maxStatementsPerTransactionTrace?: number;
58
+ maxGetPagesRequestsPerTrace?: number;
59
+ maxTransactionNameBytes?: number;
60
+ slowOperationThresholdMs?: number;
61
+ baselineSampleRate?: number;
62
+ maxDiagnosticEventsPerMinute?: number;
63
+ diagnosticEventQueueCapacity?: number;
64
+ }
65
+ interface SqliteNativeMetrics {
66
+ requestBuildNs: number;
67
+ serializeNs: number;
68
+ transportNs: number;
69
+ stateUpdateNs: number;
70
+ totalNs: number;
71
+ commitCount: number;
72
+ pageCacheEntries: number;
73
+ pageCacheWeightedSize: number;
74
+ pageCacheCapacityPages: number;
75
+ writeBufferDirtyPages: number;
76
+ dbSizePages: number;
77
+ }
31
78
  interface SqliteDatabase {
32
79
  exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
80
+ execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
81
+ executeBatch(statements: SqliteBatchStatement[]): Promise<SqliteExecuteResult[]>;
82
+ beginTransaction(timeoutMs?: number, name?: string): Promise<SqliteTransactionDatabase>;
33
83
  run(sql: string, params?: SqliteBindings): Promise<void>;
34
84
  query(sql: string, params?: SqliteBindings): Promise<SqliteQueryResult>;
35
- getSqliteVfsMetrics?: () => SqliteVfsMetrics | null;
85
+ nativeMetrics?(): SqliteNativeMetrics | Promise<SqliteNativeMetrics | null> | null;
36
86
  close(): Promise<void>;
37
87
  }
88
+ interface SqliteTransactionDatabase {
89
+ exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
90
+ execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
91
+ commit(): Promise<void>;
92
+ rollback(): Promise<void>;
93
+ }
38
94
  /**
39
95
  * Provider for opening native databases from the active runtime.
40
96
  */
@@ -78,6 +134,13 @@ interface DatabaseProviderContext {
78
134
  nativeDatabaseProvider?: NativeDatabaseProvider;
79
135
  }
80
136
  type DatabaseProvider<DB extends RawAccess> = {
137
+ /**
138
+ * Local SQLite profiling controls consumed by the actor runtime.
139
+ *
140
+ * @experimental This entire configuration surface is experimental and
141
+ * subject to change without notice.
142
+ */
143
+ sqliteProfiling?: SqliteProfilingOptions;
81
144
  /**
82
145
  * Creates a new database client for the actor.
83
146
  * The result is passed to the actor context as `c.db`.
@@ -94,14 +157,19 @@ type DatabaseProvider<DB extends RawAccess> = {
94
157
  /**
95
158
  * Drizzle database client interface (will be extended by drizzle-orm types)
96
159
  */
97
- interface DrizzleDatabaseClient {
98
- }
160
+ type DrizzleDatabaseClient = {};
99
161
  type ExecuteFunction = <TRow extends Record<string, unknown> = Record<string, unknown>>(query: string, ...args: unknown[]) => Promise<TRow[]>;
100
162
  type RawAccess = {
101
163
  /**
102
164
  * Executes a raw SQL query.
103
165
  */
104
166
  execute: ExecuteFunction;
167
+ /** Runs a callback in an isolated SQLite transaction. */
168
+ transaction: <T>(callback: (tx: RawAccess) => Promise<T> | T, options?: SqliteTransactionOptions) => Promise<T>;
169
+ /**
170
+ * Returns native SQLite metrics when the active runtime supports them.
171
+ */
172
+ nativeMetrics?: () => SqliteNativeMetrics | Promise<SqliteNativeMetrics | null> | null;
105
173
  /**
106
174
  * Closes the database connection and releases resources.
107
175
  */
@@ -137,6 +205,7 @@ declare const CreateRequestSchema: z.ZodObject<{
137
205
  key: z.ZodArray<z.ZodString>;
138
206
  input: z.ZodOptional<z.ZodUnknown>;
139
207
  region: z.ZodOptional<z.ZodString>;
208
+ poolName: z.ZodOptional<z.ZodString>;
140
209
  }, z.core.$strip>;
141
210
  declare const ActorQuerySchema: z.ZodUnion<readonly [z.ZodObject<{
142
211
  getForId: z.ZodObject<{
@@ -154,6 +223,7 @@ declare const ActorQuerySchema: z.ZodUnion<readonly [z.ZodObject<{
154
223
  key: z.ZodArray<z.ZodString>;
155
224
  input: z.ZodOptional<z.ZodUnknown>;
156
225
  region: z.ZodOptional<z.ZodString>;
226
+ poolName: z.ZodOptional<z.ZodString>;
157
227
  }, z.core.$strip>;
158
228
  }, z.core.$strip>, z.ZodObject<{
159
229
  create: z.ZodObject<{
@@ -161,6 +231,7 @@ declare const ActorQuerySchema: z.ZodUnion<readonly [z.ZodObject<{
161
231
  key: z.ZodArray<z.ZodString>;
162
232
  input: z.ZodOptional<z.ZodUnknown>;
163
233
  region: z.ZodOptional<z.ZodString>;
234
+ poolName: z.ZodOptional<z.ZodString>;
164
235
  }, z.core.$strip>;
165
236
  }, z.core.$strip>]>;
166
237
  type ActorQuery = z.infer<typeof ActorQuerySchema>;
@@ -169,6 +240,44 @@ type ActorQuery = z.infer<typeof ActorQuerySchema>;
169
240
  */
170
241
  type CreateRequest = z.infer<typeof CreateRequestSchema>;
171
242
 
243
+ type SchemaHookResult = boolean | Promise<boolean>;
244
+ type SchemaHook<TContext = any> = (ctx: TContext) => SchemaHookResult;
245
+ interface EventTypeToken<T, TContext = any> {
246
+ readonly _eventType?: T;
247
+ readonly canSubscribe?: SchemaHook<TContext>;
248
+ readonly schema?: PrimitiveSchema;
249
+ }
250
+ interface QueueTypeToken<TMessage, TComplete = never, TContext = any> {
251
+ readonly _queueMessage?: TMessage;
252
+ readonly _queueComplete?: TComplete;
253
+ readonly canPublish?: SchemaHook<TContext>;
254
+ readonly message?: PrimitiveSchema;
255
+ readonly complete?: PrimitiveSchema;
256
+ }
257
+ type PrimitiveSchema = StandardSchemaV1 | EventTypeToken<unknown, any>;
258
+ interface EventSchemaDefinition<TContext = any> {
259
+ schema: PrimitiveSchema;
260
+ canSubscribe?: SchemaHook<TContext>;
261
+ }
262
+ interface QueueSchemaDefinition<TContext = any> {
263
+ message: PrimitiveSchema;
264
+ complete?: PrimitiveSchema;
265
+ canPublish?: SchemaHook<TContext>;
266
+ }
267
+ type EventSchema<TContext = any> = PrimitiveSchema | EventSchemaDefinition<TContext>;
268
+ type QueueSchema = PrimitiveSchema | QueueSchemaDefinition<any> | QueueTypeToken<unknown, unknown, any>;
269
+ type EventSchemaConfig<TContext = any> = Record<string, EventSchema<TContext>>;
270
+ type QueueSchemaConfig<_TContext = any> = Record<string, QueueSchema>;
271
+ 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;
272
+ type InferSchemaMap<T extends Record<string, unknown>> = {
273
+ [K in keyof T]: InferSchema<T[K]>;
274
+ };
275
+ 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;
276
+ type InferQueueCompleteMap<T extends QueueSchemaConfig> = {
277
+ [K in keyof T]: InferQueueComplete<T[K]>;
278
+ };
279
+ type InferEventArgs<T> = T extends readonly unknown[] ? number extends T["length"] ? [T] : T : [T];
280
+
172
281
  interface DeconstructedError {
173
282
  __type: "ActorError";
174
283
  statusCode: ContentfulStatusCode;
@@ -177,6 +286,8 @@ interface DeconstructedError {
177
286
  code: string;
178
287
  message: string;
179
288
  metadata?: unknown;
289
+ rayId?: string;
290
+ actor?: ActorSpecifier;
180
291
  }
181
292
 
182
293
  interface RivetErrorOptions extends ErrorOptions {
@@ -184,8 +295,18 @@ interface RivetErrorOptions extends ErrorOptions {
184
295
  public?: boolean;
185
296
  /** Metadata associated with this error. */
186
297
  metadata?: unknown;
298
+ /** Request identifier used to correlate this error with engine logs. */
299
+ rayId?: string;
187
300
  /** Explicit HTTP status override for router responses. */
188
301
  statusCode?: number;
302
+ /** Actor context associated with this error. */
303
+ actor?: ActorSpecifier;
304
+ }
305
+ /** Identifies the actor that was handling work when an error was produced. */
306
+ interface ActorSpecifier {
307
+ actorId: string;
308
+ generation: number;
309
+ key?: string;
189
310
  }
190
311
  interface UserErrorOptions extends ErrorOptions {
191
312
  /**
@@ -203,7 +324,9 @@ declare class RivetError extends Error {
203
324
  __type: "RivetError";
204
325
  public: boolean;
205
326
  metadata?: unknown;
327
+ readonly rayId?: string;
206
328
  statusCode: number;
329
+ actor?: ActorSpecifier;
207
330
  readonly group: string;
208
331
  readonly code: string;
209
332
  static isRivetError(error: unknown): error is RivetError | DeconstructedError;
@@ -216,61 +339,26 @@ declare class UserError extends RivetError {
216
339
  constructor(message: string, options?: UserErrorOptions);
217
340
  }
218
341
 
219
- type SchemaHookResult = boolean | Promise<boolean>;
220
- type SchemaHook<TContext = any> = (ctx: TContext) => SchemaHookResult;
221
- interface EventTypeToken<T, TContext = any> {
222
- readonly _eventType?: T;
223
- readonly canSubscribe?: SchemaHook<TContext>;
224
- readonly schema?: PrimitiveSchema;
225
- }
226
- interface QueueTypeToken<TMessage, TComplete = never, TContext = any> {
227
- readonly _queueMessage?: TMessage;
228
- readonly _queueComplete?: TComplete;
229
- readonly canPublish?: SchemaHook<TContext>;
230
- readonly message?: PrimitiveSchema;
231
- readonly complete?: PrimitiveSchema;
232
- }
233
- type PrimitiveSchema = StandardSchemaV1 | EventTypeToken<unknown, any>;
234
- interface EventSchemaDefinition<TContext = any> {
235
- schema: PrimitiveSchema;
236
- canSubscribe?: SchemaHook<TContext>;
237
- }
238
- interface QueueSchemaDefinition<TContext = any> {
239
- message: PrimitiveSchema;
240
- complete?: PrimitiveSchema;
241
- canPublish?: SchemaHook<TContext>;
242
- }
243
- type EventSchema<TContext = any> = PrimitiveSchema | EventSchemaDefinition<TContext>;
244
- type QueueSchema = PrimitiveSchema | QueueSchemaDefinition<any> | QueueTypeToken<unknown, unknown, any>;
245
- type EventSchemaConfig<TContext = any> = Record<string, EventSchema<TContext>>;
246
- type QueueSchemaConfig<TContext = any> = Record<string, QueueSchema>;
247
- 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;
248
- type InferSchemaMap<T extends Record<string, unknown>> = {
249
- [K in keyof T]: InferSchema<T[K]>;
250
- };
251
- 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;
252
- type InferQueueCompleteMap<T extends QueueSchemaConfig> = {
253
- [K in keyof T]: InferQueueComplete<T[K]>;
254
- };
255
- type InferEventArgs<T> = T extends readonly unknown[] ? number extends T["length"] ? [T] : T : [T];
256
-
257
342
  type UpgradeWebSocket = (createEvents: (c: Context) => any) => Handler;
258
343
  type GetUpgradeWebSocket = () => UpgradeWebSocket;
259
344
 
260
345
  type GatewayTarget = {
261
346
  directId: string;
262
347
  } | ActorQuery;
348
+ interface GatewayRequestOptions {
349
+ skipReadyWait?: boolean;
350
+ }
263
351
  interface EngineControlClient {
264
352
  getForId(input: GetForIdInput): Promise<ActorOutput | undefined>;
265
353
  getWithKey(input: GetWithKeyInput): Promise<ActorOutput | undefined>;
266
354
  getOrCreateWithKey(input: GetOrCreateWithKeyInput): Promise<ActorOutput>;
267
355
  createActor(input: CreateInput): Promise<ActorOutput>;
268
356
  listActors(input: ListActorsInput): Promise<ActorOutput[]>;
269
- sendRequest(target: GatewayTarget, actorRequest: Request): Promise<Response>;
270
- openWebSocket(path: string, target: GatewayTarget, encoding: Encoding, params: unknown): Promise<UniversalWebSocket>;
357
+ sendRequest(target: GatewayTarget, actorRequest: Request, options?: GatewayRequestOptions): Promise<Response>;
358
+ openWebSocket(path: string, target: GatewayTarget, encoding: Encoding, params: unknown, options?: GatewayRequestOptions): Promise<UniversalWebSocket>;
271
359
  proxyRequest(c: Context, actorRequest: Request, actorId: string): Promise<Response>;
272
360
  proxyWebSocket(c: Context, path: string, actorId: string, encoding: Encoding, params: unknown): Promise<Response>;
273
- buildGatewayUrl(target: GatewayTarget): Promise<string>;
361
+ buildGatewayUrl(target: GatewayTarget, options?: GatewayRequestOptions): Promise<string>;
274
362
  displayInformation(): RuntimeDisplayInformation;
275
363
  extraStartupLog?: () => Record<string, unknown>;
276
364
  modifyRuntimeRouter?: (config: RegistryConfig, router: Hono) => void;
@@ -280,11 +368,6 @@ interface EngineControlClient {
280
368
  * Test-only helper that simulates an abrupt actor crash.
281
369
  */
282
370
  hardCrashActor?(actorId: string): Promise<void>;
283
- kvGet(actorId: string, key: Uint8Array): Promise<string | null>;
284
- kvBatchGet(actorId: string, keys: Uint8Array[]): Promise<(Uint8Array | null)[]>;
285
- kvBatchPut(actorId: string, entries: [Uint8Array, Uint8Array][]): Promise<void>;
286
- kvBatchDelete(actorId: string, keys: Uint8Array[]): Promise<void>;
287
- kvDeleteRange(actorId: string, start: Uint8Array, end: Uint8Array): Promise<void>;
288
371
  }
289
372
  interface RuntimeDisplayInformation {
290
373
  properties: Record<string, string>;
@@ -306,6 +389,8 @@ interface GetOrCreateWithKeyInput {
306
389
  input?: unknown;
307
390
  region?: string;
308
391
  crashPolicy?: CrashPolicy;
392
+ /** Overrides the client's configured pool name for this actor. */
393
+ poolName?: string;
309
394
  }
310
395
  interface CreateInput {
311
396
  c?: Context | undefined;
@@ -314,6 +399,8 @@ interface CreateInput {
314
399
  input?: unknown;
315
400
  region?: string;
316
401
  crashPolicy?: CrashPolicy;
402
+ /** Overrides the client's configured pool name for this actor. */
403
+ poolName?: string;
317
404
  }
318
405
  interface ListActorsInput {
319
406
  c?: Context | undefined;
@@ -358,12 +445,27 @@ interface QueueSendResult<TResponse = unknown> {
358
445
  * @returns {Promise<Response>}
359
446
  */
360
447
  type ActorActionFunction<Args extends Array<unknown> = unknown[], Response = unknown> = (...args: Args extends [unknown, ...infer Rest] ? Rest : Args) => Promise<Response>;
448
+ type IsAny<T> = 0 extends 1 & T ? true : false;
449
+ type LooseEventSubscribe = (eventName: string, callback: (...args: any[]) => void) => () => void;
450
+ type ActorActionMap<R> = {
451
+ [K in keyof NonNullable<R>]: NonNullable<R>[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Awaited<Return>> : NonNullable<R>[K] extends Record<string, unknown> ? ActorActionMap<NonNullable<R>[K]> : never;
452
+ };
453
+ type ActionsOf<AD extends AnyActorDefinition> = AD["config"] extends {
454
+ actions?: infer R;
455
+ } ? R : never;
456
+ interface ActorGatewayOptions {
457
+ skipReadyWait?: boolean;
458
+ }
459
+ interface ActorActionOptions extends ActorGatewayOptions {
460
+ signal?: AbortSignal;
461
+ }
462
+ type ActorConnectOptions = ActorGatewayOptions;
463
+ type ActorFetchInit = RequestInit & ActorGatewayOptions;
464
+ type ActorWebSocketOptions = ActorGatewayOptions;
361
465
  /**
362
466
  * Maps action methods from actor definition to typed function signatures.
363
467
  */
364
- type ActorDefinitionActions<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<any, any, any, any, any, any, any, any, infer R> ? {
365
- [K in keyof R]: R[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Return> : never;
366
- } : never;
468
+ type ActorDefinitionActions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? Record<string, ActorActionFunction<any[], any>> : ActorActionMap<ActionsOf<AD>>;
367
469
  type ActorQueueSend<TQueues extends QueueSchemaConfig> = {
368
470
  <K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options: QueueSendWaitOptions): Promise<QueueSendResult<InferQueueCompleteMap<TQueues>[K]>>;
369
471
  <K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options?: QueueSendNoWaitOptions): Promise<void>;
@@ -374,13 +476,31 @@ type ActorEventSubscribe<TEvents extends EventSchemaConfig> = {
374
476
  <K extends keyof TEvents & string>(eventName: K, callback: (...args: InferEventArgs<InferSchemaMap<TEvents>[K]>) => void): () => void;
375
477
  (eventName: keyof TEvents extends never ? string : never, callback: (...args: any[]) => void): () => void;
376
478
  };
377
- type ActorDefinitionQueueSend<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<any, any, any, any, any, any, any, infer Q, any> ? Q extends QueueSchemaConfig ? {
479
+ type ActorDefinitionQueueSend<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
480
+ send: ActorQueueSend<Record<string, any>>;
481
+ } : AD extends {
482
+ config: {
483
+ queues?: infer Q;
484
+ };
485
+ } ? Q extends QueueSchemaConfig ? {
378
486
  send: ActorQueueSend<Q>;
379
- } : never : never;
380
- type ActorDefinitionEventSubscriptions<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<any, any, any, any, any, any, infer E, any, any> ? E extends EventSchemaConfig ? {
487
+ } : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, any, infer Q, any> ? Q extends QueueSchemaConfig ? {
488
+ send: ActorQueueSend<Q>;
489
+ } : {} : {};
490
+ type ActorDefinitionEventSubscriptions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
491
+ on: LooseEventSubscribe;
492
+ once: LooseEventSubscribe;
493
+ } : AD extends {
494
+ config: {
495
+ events?: infer E;
496
+ };
497
+ } ? E extends EventSchemaConfig ? {
381
498
  on: ActorEventSubscribe<E>;
382
499
  once: ActorEventSubscribe<E>;
383
- } : never : never;
500
+ } : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, infer E, any, any> ? E extends EventSchemaConfig ? {
501
+ on: ActorEventSubscribe<E>;
502
+ once: ActorEventSubscribe<E>;
503
+ } : {} : {};
384
504
 
385
505
  declare class ActorClientError extends Error {
386
506
  }
@@ -445,7 +565,7 @@ declare class ActorConnRaw {
445
565
  *
446
566
  * @protected
447
567
  */
448
- constructor(client: ClientRaw, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState);
568
+ constructor(client: ClientRaw, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState, gatewayOptions?: ActorGatewayOptions);
449
569
  send(name: string, body: unknown, options: QueueSendWaitOptions): Promise<QueueSendResult>;
450
570
  send(name: string, body: unknown, options?: QueueSendNoWaitOptions): Promise<void>;
451
571
  /**
@@ -510,6 +630,10 @@ declare class ActorConnRaw {
510
630
  * @returns {boolean} - True if the connection is open, false otherwise.
511
631
  */
512
632
  get isConnected(): boolean;
633
+ /**
634
+ * Resolves when this connection first reaches the connected state.
635
+ */
636
+ get ready(): Promise<void>;
513
637
  /**
514
638
  * Subscribes to connection open events.
515
639
  *
@@ -577,7 +701,7 @@ declare class ActorHandleRaw {
577
701
  *
578
702
  * @protected
579
703
  */
580
- constructor(client: any, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState);
704
+ constructor(client: any, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState, gatewayOptions?: ActorGatewayOptions);
581
705
  send(name: string, body: unknown, options: QueueSendWaitOptions): Promise<QueueSendResult>;
582
706
  send(name: string, body: unknown, options?: QueueSendNoWaitOptions): Promise<void>;
583
707
  /**
@@ -590,24 +714,23 @@ declare class ActorHandleRaw {
590
714
  action<Args extends Array<unknown> = unknown[], Response = unknown>(opts: {
591
715
  name: string;
592
716
  args: Args;
593
- signal?: AbortSignal;
594
- }): Promise<Response>;
717
+ } & ActorActionOptions): Promise<Response>;
595
718
  /**
596
719
  * Establishes a persistent connection to the actor.
597
720
  *
598
721
  * @template AD The actor class that this connection is for.
599
722
  * @returns {ActorConn<AD>} A connection to the actor.
600
723
  */
601
- connect(params?: unknown): ActorConn<AnyActorDefinition>;
724
+ connect(params?: unknown, options?: ActorConnectOptions): ActorConn<AnyActorDefinition>;
602
725
  /**
603
726
  * Fetches a resource from this actor via the /request endpoint. This is a
604
727
  * convenience wrapper around the raw HTTP API.
605
728
  */
606
- fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
729
+ fetch(input: string | URL | Request, init?: ActorFetchInit): Promise<Response>;
607
730
  /**
608
731
  * Opens a raw WebSocket connection to this actor.
609
732
  */
610
- webSocket(path?: string, protocols?: string | string[]): Promise<any>;
733
+ webSocket(path?: string, protocols?: string | string[], options?: ActorWebSocketOptions): Promise<any>;
611
734
  /**
612
735
  * Resolves the actor to get its unique actor ID.
613
736
  */
@@ -635,7 +758,7 @@ declare class ActorHandleRaw {
635
758
  * @see {@link ActorHandleRaw}
636
759
  */
637
760
  type ActorHandle<AD extends AnyActorDefinition> = Omit<ActorHandleRaw, "connect" | "send"> & {
638
- connect(params?: unknown): ActorConn<AD>;
761
+ connect(params?: unknown, options?: ActorConnectOptions): ActorConn<AD>;
639
762
  resolve(): Promise<string>;
640
763
  } & ActorDefinitionQueueSend<AD> & ActorDefinitionActions<AD>;
641
764
 
@@ -650,6 +773,9 @@ declare const ClientConfigSchema: z$1.ZodPipe<z$1.ZodObject<{
650
773
  bare: "bare";
651
774
  }>>;
652
775
  headers: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>>;
776
+ gateway: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodObject<{
777
+ skipReadyWait: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
778
+ }, z$1.core.$strip>>>;
653
779
  getUpgradeWebSocket: z$1.ZodOptional<z$1.ZodCustom<GetUpgradeWebSocket, GetUpgradeWebSocket>>;
654
780
  disableMetadataLookup: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
655
781
  maxInputSize: z$1.ZodDefault<z$1.ZodNumber>;
@@ -661,6 +787,9 @@ declare const ClientConfigSchema: z$1.ZodPipe<z$1.ZodObject<{
661
787
  poolName: string;
662
788
  encoding: "json" | "cbor" | "bare";
663
789
  headers: Record<string, string>;
790
+ gateway: {
791
+ skipReadyWait: boolean;
792
+ };
664
793
  disableMetadataLookup: boolean;
665
794
  maxInputSize: number;
666
795
  devtools: boolean;
@@ -672,6 +801,9 @@ declare const ClientConfigSchema: z$1.ZodPipe<z$1.ZodObject<{
672
801
  poolName: string;
673
802
  encoding: "json" | "cbor" | "bare";
674
803
  headers: Record<string, string>;
804
+ gateway: {
805
+ skipReadyWait: boolean;
806
+ };
675
807
  disableMetadataLookup: boolean;
676
808
  maxInputSize: number;
677
809
  devtools: boolean;
@@ -777,6 +909,11 @@ interface GetOrCreateOptions extends QueryOptions {
777
909
  createInRegion?: string;
778
910
  /** Input data to pass to the actor. */
779
911
  createWithInput?: unknown;
912
+ /**
913
+ * Name of the envoy pool to select for this actor if it is created.
914
+ * Overrides the client's configured `poolName` for this call.
915
+ */
916
+ poolName?: string;
780
917
  }
781
918
  /**
782
919
  * Options for creating a actor.
@@ -788,6 +925,11 @@ interface CreateOptions extends QueryOptions {
788
925
  region?: string;
789
926
  /** Input data to pass to the actor. */
790
927
  input?: unknown;
928
+ /**
929
+ * Name of the envoy pool to select for this actor.
930
+ * Overrides the client's configured `poolName` for this call.
931
+ */
932
+ poolName?: string;
791
933
  }
792
934
  /**
793
935
  * Represents a region to connect to.
@@ -821,7 +963,7 @@ declare class ClientRaw {
821
963
  /**
822
964
  * Creates an instance of Client.
823
965
  */
824
- constructor(driver: EngineControlClient, encoding: Encoding | undefined);
966
+ constructor(driver: EngineControlClient, encoding: Encoding | undefined, gatewayOptions?: ActorGatewayOptions);
825
967
  /**
826
968
  * Gets a stateless handle to a actor by its ID.
827
969
  *
@@ -881,7 +1023,11 @@ type Client<A extends Registry<any>> = ClientRaw & {
881
1023
  [K in keyof ExtractActorsFromRegistry<A>]: ActorAccessor<ExtractActorsFromRegistry<A>[K]>;
882
1024
  };
883
1025
 
1026
+ /** @experimental State exposed by a durable workflow run handler to the Inspector. */
1027
+ type WorkflowState = "pending" | "running" | "sleeping" | "failed" | "completed" | "cancelled" | "rolling_back";
1028
+
884
1029
  declare const ACTOR_CONTEXT_INTERNAL_SYMBOL: unique symbol;
1030
+ declare const RAW_STATE_SYMBOL: unique symbol;
885
1031
  interface ActorLogger {
886
1032
  level: any;
887
1033
  fatal: any;
@@ -914,6 +1060,10 @@ type ActorKvListOptions<T extends ActorKvValueType = "text", K extends ActorKvKe
914
1060
  limit?: number;
915
1061
  };
916
1062
  type ActorClientFor<T> = T extends Registry<any> ? Client<T> : T;
1063
+ /**
1064
+ * @deprecated Actor KV is deprecated. Use embedded SQLite (`c.db`)
1065
+ * or actor state instead.
1066
+ */
917
1067
  interface ActorKv {
918
1068
  get<T extends ActorKvValueType = "text">(key: Uint8Array | string, options?: ActorKvValueOptions<T>): Promise<ActorKvValueTypeMap[T] | null>;
919
1069
  put<T extends ActorKvValueType = "text">(key: Uint8Array | string, value: Uint8Array | string | ArrayBuffer, options?: ActorKvValueOptions<T>): Promise<void>;
@@ -928,10 +1078,76 @@ interface ActorKv {
928
1078
  [key: string]: any;
929
1079
  }
930
1080
  interface ActorSchedule {
931
- after(duration: number, action: string, ...args: unknown[]): Promise<void>;
932
- at(timestamp: number, action: string, ...args: unknown[]): Promise<void>;
1081
+ after(duration: number, action: string, ...args: unknown[]): Promise<string>;
1082
+ at(timestamp: number, action: string, ...args: unknown[]): Promise<string>;
1083
+ cancel(id: string): Promise<boolean>;
1084
+ get(id: string): Promise<ScheduledEventInfo | undefined>;
1085
+ list(): Promise<ScheduledEventInfo[]>;
1086
+ [key: string]: any;
1087
+ }
1088
+ interface ActorCronSetOptions {
1089
+ name: string;
1090
+ expression: string;
1091
+ action: string;
1092
+ args?: unknown[];
1093
+ timezone?: string;
1094
+ /** Defaults to 100. Set to 0 to disable and clear history. Maximum 1,000. */
1095
+ maxHistory?: number;
1096
+ }
1097
+ interface ActorCronEveryOptions {
1098
+ name: string;
1099
+ /** Fixed interval in milliseconds. Minimum 5,000. */
1100
+ interval: number;
1101
+ action: string;
1102
+ args?: unknown[];
1103
+ /** Defaults to 100. Set to 0 to disable and clear history. Maximum 1,000. */
1104
+ maxHistory?: number;
1105
+ }
1106
+ interface ActorCron {
1107
+ set(options: ActorCronSetOptions): Promise<void>;
1108
+ every(options: ActorCronEveryOptions): Promise<void>;
1109
+ get(name: string): Promise<CronJobInfo | undefined>;
1110
+ list(): Promise<CronJobInfo[]>;
1111
+ delete(name: string): Promise<boolean>;
1112
+ history(name: string, options?: {
1113
+ limit?: number;
1114
+ }): Promise<CronFire[]>;
933
1115
  [key: string]: any;
934
1116
  }
1117
+ interface ScheduledEventInfo {
1118
+ id: string;
1119
+ action: string;
1120
+ args: unknown[];
1121
+ runAt: number;
1122
+ }
1123
+ type CronJobInfo = {
1124
+ name: string;
1125
+ action: string;
1126
+ args: unknown[];
1127
+ nextRunAt: number;
1128
+ lastRunAt?: number;
1129
+ maxHistory: number;
1130
+ } & ({
1131
+ kind: "cron";
1132
+ expression: string;
1133
+ timezone: string;
1134
+ } | {
1135
+ kind: "every";
1136
+ interval: number;
1137
+ });
1138
+ interface CronFire {
1139
+ action: string;
1140
+ scheduledAt: number;
1141
+ firedAt: number;
1142
+ finishedAt?: number;
1143
+ result: "running" | "ok" | "error" | "skipped";
1144
+ error?: {
1145
+ group: string;
1146
+ code: string;
1147
+ message: string;
1148
+ metadata?: unknown;
1149
+ };
1150
+ }
935
1151
  type QueueMessageOf<Name extends string, Body> = {
936
1152
  id: number | bigint;
937
1153
  name: Name;
@@ -942,6 +1158,8 @@ type QueueMessageOf<Name extends string, Body> = {
942
1158
  type QueueName<TQueues extends QueueSchemaConfig> = keyof TQueues & string;
943
1159
  type QueueFilterName<TQueues extends QueueSchemaConfig> = keyof TQueues extends never ? string : QueueName<TQueues>;
944
1160
  type QueueMessageForName<TQueues extends QueueSchemaConfig, TName extends QueueFilterName<TQueues>> = keyof TQueues extends never ? QueueMessageOf<string, unknown> : TName extends QueueName<TQueues> ? QueueMessageOf<TName, InferSchemaMap<TQueues>[TName]> : never;
1161
+ type QueueCompleteArgs<T> = undefined extends T ? [response?: T] : [response: T];
1162
+ 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];
945
1163
  type QueueCompletionResultForName<TQueues extends QueueSchemaConfig, TName extends QueueFilterName<TQueues>> = keyof TQueues extends never ? unknown | undefined : TName extends QueueName<TQueues> ? InferQueueCompleteMap<TQueues>[TName] | undefined : unknown | undefined;
946
1164
  interface QueueNextOptions<TName extends string = string, TCompletable extends boolean = boolean> {
947
1165
  names?: readonly TName[];
@@ -984,13 +1202,20 @@ interface ActorQueue<TQueues extends QueueSchemaConfig = Record<never, never>> {
984
1202
  next<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueNextOptions<TName, TCompletable>): Promise<any>;
985
1203
  nextBatch<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueNextBatchOptions<TName, TCompletable>): Promise<any[]>;
986
1204
  waitForNames<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(names: readonly TName[], opts?: QueueWaitOptions<TCompletable>): Promise<any>;
1205
+ /** @experimental */
1206
+ waitForAvailable<const TName extends QueueFilterName<TQueues>>(names?: readonly TName[], opts?: Omit<QueueWaitOptions<false>, "completable">): Promise<void>;
1207
+ /** @experimental */
1208
+ complete<const TName extends QueueFilterName<TQueues>>(message: {
1209
+ id: number | bigint;
1210
+ name: TName;
1211
+ }, ...args: QueueCompleteArgsForName<TQueues, TName>): Promise<void>;
987
1212
  enqueueAndWait<const TName extends QueueFilterName<TQueues>>(name: TName, body: QueueMessageForName<TQueues, TName>["body"], opts?: QueueEnqueueAndWaitOptions): Promise<QueueCompletionResultForName<TQueues, TName>>;
988
1213
  tryNext<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueTryNextOptions<TName, TCompletable>): Promise<any>;
989
1214
  tryNextBatch<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueTryNextBatchOptions<TName, TCompletable>): Promise<any[]>;
990
1215
  iter<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueIterOptions<TName, TCompletable>): AsyncIterable<any>;
991
1216
  [key: string]: any;
992
1217
  }
993
- interface Conn<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>> {
1218
+ interface Conn<_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>> {
994
1219
  id: string;
995
1220
  params: TConnParams;
996
1221
  state: TConnState;
@@ -1001,16 +1226,29 @@ interface Conn<TState = unknown, TConnParams = unknown, TConnState = unknown, TV
1001
1226
  }
1002
1227
  interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
1003
1228
  [ACTOR_CONTEXT_INTERNAL_SYMBOL]?: unknown;
1229
+ /** Returns the raw unwrapped state without the write-through proxy. */
1230
+ [RAW_STATE_SYMBOL](): TState;
1004
1231
  state: TState;
1005
1232
  vars: TVars;
1233
+ /**
1234
+ * @deprecated Actor KV is deprecated. Use embedded SQLite (`c.db`)
1235
+ * or actor state instead.
1236
+ */
1006
1237
  readonly kv: ActorKv;
1007
1238
  readonly db: InferDatabaseClient<TDatabase>;
1008
1239
  readonly schedule: ActorSchedule;
1240
+ readonly cron: ActorCron;
1009
1241
  readonly queue: ActorQueue<TQueues>;
1242
+ /** @experimental */
1243
+ readonly run: ActorRun;
1010
1244
  readonly actorId: string;
1011
1245
  readonly name: string;
1012
1246
  readonly key: string[];
1013
1247
  readonly region: string;
1248
+ /** Provisions the experimental Actor Runtime Socket for this actor generation. */
1249
+ actorRuntimeSocket(): Promise<{
1250
+ path: string;
1251
+ }>;
1014
1252
  readonly conns: Map<string, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>;
1015
1253
  readonly log: ActorLogger;
1016
1254
  readonly abortSignal: AbortSignal;
@@ -1032,6 +1270,14 @@ interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase
1032
1270
  client<T = any>(): ActorClientFor<T>;
1033
1271
  [key: string]: any;
1034
1272
  }
1273
+ /** @experimental */
1274
+ interface ActorRun {
1275
+ /**
1276
+ * @experimental Sets or clears the durable Unix-millisecond deadline that
1277
+ * ensures this actor's run handler is active, starting it if inactive.
1278
+ */
1279
+ setWakeAt(timestamp: number | null): Promise<void>;
1280
+ }
1035
1281
  type ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & {
1036
1282
  conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
1037
1283
  };
@@ -1058,6 +1304,7 @@ declare const RunConfigSchema: z.ZodObject<{
1058
1304
  inspector: z.ZodOptional<z.ZodOptional<z.ZodObject<{
1059
1305
  workflow: z.ZodOptional<z.ZodObject<{
1060
1306
  getHistory: z.ZodCustom<() => unknown, () => unknown>;
1307
+ getState: z.ZodOptional<z.ZodCustom<() => Promise<WorkflowState | null>, () => Promise<WorkflowState | null>>>;
1061
1308
  onHistoryUpdated: z.ZodOptional<z.ZodCustom<(listener: (history: unknown) => void) => InspectorUnsubscribe, (listener: (history: unknown) => void) => InspectorUnsubscribe>>;
1062
1309
  replayFromStep: z.ZodOptional<z.ZodCustom<(entryId?: string) => Promise<unknown>, (entryId?: string) => Promise<unknown>>>;
1063
1310
  }, z.core.$strip>>;
@@ -1080,6 +1327,7 @@ declare const ActorConfigSchema: z.ZodObject<{
1080
1327
  inspector: z.ZodOptional<z.ZodOptional<z.ZodObject<{
1081
1328
  workflow: z.ZodOptional<z.ZodObject<{
1082
1329
  getHistory: z.ZodCustom<() => unknown, () => unknown>;
1330
+ getState: z.ZodOptional<z.ZodCustom<() => Promise<WorkflowState | null>, () => Promise<WorkflowState | null>>>;
1083
1331
  onHistoryUpdated: z.ZodOptional<z.ZodCustom<(listener: (history: unknown) => void) => InspectorUnsubscribe, (listener: (history: unknown) => void) => InspectorUnsubscribe>>;
1084
1332
  replayFromStep: z.ZodOptional<z.ZodCustom<(entryId?: string) => Promise<unknown>, (entryId?: string) => Promise<unknown>>>;
1085
1333
  }, z.core.$strip>>;
@@ -1092,7 +1340,7 @@ declare const ActorConfigSchema: z.ZodObject<{
1092
1340
  onBeforeActionResponse: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
1093
1341
  onRequest: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
1094
1342
  onWebSocket: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
1095
- actions: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>>;
1343
+ actions: z.ZodDefault<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
1096
1344
  actionInputSchemas: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1097
1345
  connParamsSchema: z.ZodOptional<z.ZodAny>;
1098
1346
  events: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
@@ -1107,6 +1355,7 @@ declare const ActorConfigSchema: z.ZodObject<{
1107
1355
  options: z.ZodPrefault<z.ZodObject<{
1108
1356
  name: z.ZodOptional<z.ZodString>;
1109
1357
  icon: z.ZodOptional<z.ZodString>;
1358
+ enableActorRuntimeSocket: z.ZodDefault<z.ZodBoolean>;
1110
1359
  canHibernateWebSocket: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodCustom<(request: Request) => boolean, (request: Request) => boolean>]>>;
1111
1360
  createVarsTimeout: z.ZodDefault<z.ZodNumber>;
1112
1361
  createConnStateTimeout: z.ZodDefault<z.ZodNumber>;
@@ -1123,12 +1372,33 @@ declare const ActorConfigSchema: z.ZodObject<{
1123
1372
  noSleep: z.ZodDefault<z.ZodBoolean>;
1124
1373
  sleepTimeout: z.ZodDefault<z.ZodNumber>;
1125
1374
  maxQueueSize: z.ZodDefault<z.ZodNumber>;
1375
+ maxSchedules: z.ZodDefault<z.ZodNumber>;
1126
1376
  maxQueueMessageSize: z.ZodDefault<z.ZodNumber>;
1127
1377
  preloadMaxWorkflowBytes: z.ZodOptional<z.ZodNumber>;
1128
1378
  preloadMaxConnectionsBytes: z.ZodOptional<z.ZodNumber>;
1129
1379
  }, z.core.$strict>>;
1380
+ inspector: z.ZodOptional<z.ZodObject<{
1381
+ tabs: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
1382
+ id: z.ZodString;
1383
+ label: z.ZodString;
1384
+ source: z.ZodString;
1385
+ icon: z.ZodOptional<z.ZodString>;
1386
+ hidden: z.ZodOptional<z.ZodLiteral<false>>;
1387
+ }, z.core.$strict>, z.ZodObject<{
1388
+ id: z.ZodEnum<{
1389
+ state: "state";
1390
+ database: "database";
1391
+ console: "console";
1392
+ workflow: "workflow";
1393
+ queue: "queue";
1394
+ schedules: "schedules";
1395
+ connections: "connections";
1396
+ }>;
1397
+ hidden: z.ZodLiteral<true>;
1398
+ }, z.core.$strict>]>>>;
1399
+ }, z.core.$strict>>;
1130
1400
  }, z.core.$strict>;
1131
- type CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
1401
+ type CreateState<TState, _TConnParams, _TConnState, _TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
1132
1402
  state: TState;
1133
1403
  } | {
1134
1404
  createState: (c: CreateContext<TState, TInput, TDatabase, TEvents, TQueues>, input: TInput) => TState | Promise<TState>;
@@ -1141,7 +1411,7 @@ type CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase e
1141
1411
  /**
1142
1412
  * @experimental
1143
1413
  */
1144
- type CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
1414
+ type CreateVars<TState, _TConnParams, _TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
1145
1415
  /**
1146
1416
  * @experimental
1147
1417
  */
@@ -1153,7 +1423,10 @@ type CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase extend
1153
1423
  createVars: (c: CreateVarsContext<TState, TInput, TDatabase, TEvents, TQueues>, driverCtx: any) => TVars | Promise<TVars>;
1154
1424
  } | Record<never, never>;
1155
1425
  interface Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
1156
- [Action: string]: (c: ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, ...args: any[]) => any;
1426
+ [Action: string]: ((c: ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, ...args: any[]) => any) | Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
1427
+ }
1428
+ interface ActionInputSchemas {
1429
+ [Action: string]: PrimitiveSchema | ActionInputSchemas;
1157
1430
  }
1158
1431
  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>> {
1159
1432
  /**
@@ -1209,7 +1482,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
1209
1482
  * shutdown window (`sleepGracePeriod`) cover deferred work.
1210
1483
  *
1211
1484
  * The handler receives an abort signal via `c.abortSignal` and a
1212
- * `c.aborted` alias for loop checks. Use these to gracefully exit.
1485
+ * `c.aborted` alias. Use these to gracefully exit when shutdown starts.
1213
1486
  *
1214
1487
  * If this handler exits, the actor will follow the normal idle sleep timeout
1215
1488
  * once it becomes idle.
@@ -1238,10 +1511,11 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
1238
1511
  * Called before a client connects to the actor.
1239
1512
  *
1240
1513
  * Use this hook to determine if a connection should be accepted
1241
- * and to initialize connection-specific state.
1514
+ * and to validate client-provided parameters. The pending connection
1515
+ * is not visible in `c.conns` while this hook runs.
1242
1516
  *
1243
1517
  * @param opts Connection parameters including client-provided data
1244
- * @returns The initial connection state or a Promise that resolves to it
1518
+ * @returns Void or a Promise.
1245
1519
  * @throws Throw an error to reject the connection
1246
1520
  */
1247
1521
  onBeforeConnect?: (c: BeforeConnectContext<TState, TVars, TInput, TDatabase, TEvents, TQueues>, params: TConnParams) => void | Promise<void>;
@@ -1249,7 +1523,8 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
1249
1523
  * Called when a client successfully connects to the actor.
1250
1524
  *
1251
1525
  * Use this hook to perform actions when a connection is established,
1252
- * such as sending initial data or updating the actor's state.
1526
+ * such as sending initial data or updating the actor's state. The
1527
+ * connection is visible in `c.conns` before this hook runs.
1253
1528
  *
1254
1529
  * @param conn The connection object
1255
1530
  * @returns Void or a Promise that resolves when connection handling is complete
@@ -1303,9 +1578,10 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
1303
1578
  onWebSocket?: (c: WebSocketContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, websocket: UniversalWebSocket) => void | Promise<void>;
1304
1579
  actions?: TActions;
1305
1580
  /**
1306
- * Optional schema map for validating action argument tuples in native runtimes.
1581
+ * Optional schemas for validating action argument tuples in native runtimes.
1582
+ * May mirror nested action groups or use dot-separated low-level action names.
1307
1583
  */
1308
- actionInputSchemas?: Record<string, PrimitiveSchema>;
1584
+ actionInputSchemas?: ActionInputSchemas;
1309
1585
  /**
1310
1586
  * Optional schema for validating connection params in native runtimes.
1311
1587
  */
@@ -1325,27 +1601,59 @@ type ActorDatabaseConfig<TDatabase extends AnyDatabaseProvider> = {
1325
1601
  */
1326
1602
  db: TDatabase;
1327
1603
  } | Record<never, never>;
1328
- type ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = Omit<z.infer<typeof ActorConfigSchema>, "actions" | "events" | "queues" | "onCreate" | "onDestroy" | "onMigrate" | "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>;
1604
+ type ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> = Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>> = Omit<z.infer<typeof ActorConfigSchema>, "actions" | "events" | "queues" | "onCreate" | "onDestroy" | "onMigrate" | "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>;
1329
1605
 
1330
- interface BaseActorDefinition<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>> {
1331
- readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q>;
1606
+ interface BaseActorDefinition<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>> {
1607
+ readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q, _R>;
1608
+ }
1609
+ interface AnyActorDefinition {
1610
+ readonly config: any;
1332
1611
  }
1333
- type AnyActorDefinition = BaseActorDefinition<any, any, any, any, any, any, any, any, any>;
1334
1612
  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>> implements BaseActorDefinition<S, CP, CS, V, I, DB, E, Q, R> {
1335
1613
  #private;
1336
- constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q>);
1337
- get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q>;
1614
+ constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q, R>);
1615
+ get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q, R>;
1338
1616
  }
1339
1617
 
1340
- declare const ActorsSchema: z$2.ZodRecord<z$2.ZodString, z$2.ZodCustom<BaseActorDefinition<any, any, any, any, any, any, any, any, any>, BaseActorDefinition<any, any, any, any, any, any, any, any, any>>>;
1618
+ declare const ActorsSchema: z$2.ZodRecord<z$2.ZodString, z$2.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
1341
1619
  type RegistryActors = z$2.infer<typeof ActorsSchema>;
1342
1620
  declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1343
1621
  use: z$2.ZodRecord<z$2.ZodString, z$2.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
1344
1622
  test: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodObject<{
1345
- enabled: z$2.ZodBoolean;
1623
+ enabled: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodBoolean>>;
1624
+ sqliteBackend: z$2.ZodOptional<z$2.ZodEnum<{
1625
+ local: "local";
1626
+ remote: "remote";
1627
+ }>>;
1346
1628
  }, z$2.core.$strip>>>;
1347
1629
  maxIncomingMessageSize: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
1348
1630
  maxOutgoingMessageSize: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
1631
+ runtime: z$2.ZodPipe<z$2.ZodOptional<z$2.ZodEnum<{
1632
+ auto: "auto";
1633
+ native: "native";
1634
+ wasm: "wasm";
1635
+ }>>, z$2.ZodTransform<"auto" | "native" | "wasm", "auto" | "native" | "wasm" | undefined>>;
1636
+ wasm: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodObject<{
1637
+ bindings: z$2.ZodOptional<z$2.ZodCustom<typeof _rivetkit_rivetkit_wasm, typeof _rivetkit_rivetkit_wasm>>;
1638
+ initInput: z$2.ZodOptional<z$2.ZodCustom<{
1639
+ module_or_path: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput>;
1640
+ } | _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined, {
1641
+ module_or_path: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput>;
1642
+ } | _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined>>;
1643
+ }, z$2.core.$strip>>>;
1644
+ sqlite: z$2.ZodPipe<z$2.ZodOptional<z$2.ZodUnion<readonly [z$2.ZodEnum<{
1645
+ local: "local";
1646
+ remote: "remote";
1647
+ }>, z$2.ZodObject<{
1648
+ backend: z$2.ZodEnum<{
1649
+ local: "local";
1650
+ remote: "remote";
1651
+ }>;
1652
+ }, z$2.core.$strip>]>>, z$2.ZodTransform<{
1653
+ backend: "local" | "remote";
1654
+ } | undefined, "local" | "remote" | {
1655
+ backend: "local" | "remote";
1656
+ } | undefined>>;
1349
1657
  noWelcome: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodBoolean>>;
1350
1658
  logging: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodObject<{
1351
1659
  baseLogger: z$2.ZodOptional<z$2.ZodCustom<Logger, Logger>>;
@@ -1368,12 +1676,15 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1368
1676
  httpPort: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
1369
1677
  httpHost: z$2.ZodOptional<z$2.ZodString>;
1370
1678
  startEngine: z$2.ZodDefault<z$2.ZodBoolean>;
1679
+ engineHost: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodString>>;
1680
+ enginePort: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
1371
1681
  engineVersion: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodString>>;
1372
1682
  configurePool: z$2.ZodOptional<z$2.ZodOptional<z$2.ZodObject<{
1373
1683
  name: z$2.ZodOptional<z$2.ZodString>;
1374
1684
  url: z$2.ZodString;
1375
1685
  headers: z$2.ZodOptional<z$2.ZodRecord<z$2.ZodString, z$2.ZodString>>;
1376
1686
  requestLifespan: z$2.ZodOptional<z$2.ZodNumber>;
1687
+ drainGracePeriod: z$2.ZodOptional<z$2.ZodNumber>;
1377
1688
  metadata: z$2.ZodOptional<z$2.ZodRecord<z$2.ZodString, z$2.ZodUnknown>>;
1378
1689
  metadataPollInterval: z$2.ZodOptional<z$2.ZodNumber>;
1379
1690
  drainOnVersionUpgrade: z$2.ZodOptional<z$2.ZodBoolean>;
@@ -1391,10 +1702,13 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1391
1702
  envoyKey: z$2.ZodOptional<z$2.ZodString>;
1392
1703
  }, z$2.core.$strip>>>;
1393
1704
  shutdown: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodObject<{
1394
- gracePeriodMs: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
1705
+ gracePeriodMs: z$2.ZodOptional<z$2.ZodNumber>;
1395
1706
  disableSignalHandlers: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodBoolean>>;
1396
1707
  }, z$2.core.$strip>>>;
1397
1708
  }, z$2.core.$strip>, z$2.ZodTransform<{
1709
+ sqlite: {
1710
+ backend: "local" | "remote";
1711
+ } | undefined;
1398
1712
  endpoint: string | undefined;
1399
1713
  namespace: string;
1400
1714
  token: string | undefined;
@@ -1411,9 +1725,17 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1411
1725
  use: Record<string, AnyActorDefinition>;
1412
1726
  test: {
1413
1727
  enabled: boolean;
1728
+ sqliteBackend?: "local" | "remote" | undefined;
1414
1729
  };
1415
1730
  maxIncomingMessageSize: number;
1416
1731
  maxOutgoingMessageSize: number;
1732
+ runtime: "auto" | "native" | "wasm";
1733
+ wasm: {
1734
+ bindings?: typeof _rivetkit_rivetkit_wasm | undefined;
1735
+ initInput?: {
1736
+ module_or_path: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput>;
1737
+ } | _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined;
1738
+ };
1417
1739
  noWelcome: boolean;
1418
1740
  logging: {
1419
1741
  baseLogger?: Logger | undefined;
@@ -1423,6 +1745,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1423
1745
  httpBasePath: string;
1424
1746
  httpPort: number;
1425
1747
  startEngine: boolean;
1748
+ engineHost: string;
1749
+ enginePort: number;
1426
1750
  engineVersion: string;
1427
1751
  envoy: {
1428
1752
  poolName: string;
@@ -1431,8 +1755,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1431
1755
  envoyKey?: string | undefined;
1432
1756
  };
1433
1757
  shutdown: {
1434
- gracePeriodMs: number;
1435
1758
  disableSignalHandlers: boolean;
1759
+ gracePeriodMs?: number | undefined;
1436
1760
  };
1437
1761
  staticDir?: string | undefined;
1438
1762
  httpHost?: string | undefined;
@@ -1441,6 +1765,7 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1441
1765
  name?: string | undefined;
1442
1766
  headers?: Record<string, string> | undefined;
1443
1767
  requestLifespan?: number | undefined;
1768
+ drainGracePeriod?: number | undefined;
1444
1769
  metadata?: Record<string, unknown> | undefined;
1445
1770
  metadataPollInterval?: number | undefined;
1446
1771
  drainOnVersionUpgrade?: boolean | undefined;
@@ -1449,9 +1774,20 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1449
1774
  use: Record<string, AnyActorDefinition>;
1450
1775
  test: {
1451
1776
  enabled: boolean;
1777
+ sqliteBackend?: "local" | "remote" | undefined;
1452
1778
  };
1453
1779
  maxIncomingMessageSize: number;
1454
1780
  maxOutgoingMessageSize: number;
1781
+ runtime: "auto" | "native" | "wasm";
1782
+ wasm: {
1783
+ bindings?: typeof _rivetkit_rivetkit_wasm | undefined;
1784
+ initInput?: {
1785
+ module_or_path: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput>;
1786
+ } | _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined;
1787
+ };
1788
+ sqlite: {
1789
+ backend: "local" | "remote";
1790
+ } | undefined;
1455
1791
  noWelcome: boolean;
1456
1792
  logging: {
1457
1793
  baseLogger?: Logger | undefined;
@@ -1464,6 +1800,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1464
1800
  httpBasePath: string;
1465
1801
  httpPort: number;
1466
1802
  startEngine: boolean;
1803
+ engineHost: string;
1804
+ enginePort: number;
1467
1805
  engineVersion: string;
1468
1806
  serverless: {
1469
1807
  basePath: string;
@@ -1478,8 +1816,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1478
1816
  envoyKey?: string | undefined;
1479
1817
  };
1480
1818
  shutdown: {
1481
- gracePeriodMs: number;
1482
1819
  disableSignalHandlers: boolean;
1820
+ gracePeriodMs?: number | undefined;
1483
1821
  };
1484
1822
  staticDir?: string | undefined;
1485
1823
  httpHost?: string | undefined;
@@ -1488,6 +1826,7 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1488
1826
  name?: string | undefined;
1489
1827
  headers?: Record<string, string> | undefined;
1490
1828
  requestLifespan?: number | undefined;
1829
+ drainGracePeriod?: number | undefined;
1491
1830
  metadata?: Record<string, unknown> | undefined;
1492
1831
  metadataPollInterval?: number | undefined;
1493
1832
  drainOnVersionUpgrade?: boolean | undefined;
@@ -1498,15 +1837,467 @@ type RegistryConfigInput<A extends RegistryActors> = Omit<z$2.input<typeof Regis
1498
1837
  use: A;
1499
1838
  };
1500
1839
 
1840
+ declare const handleBrand: unique symbol;
1841
+ type OpaqueHandle<Name extends string> = {
1842
+ readonly [handleBrand]: Name;
1843
+ };
1844
+ type RegistryHandle = OpaqueHandle<"registry">;
1845
+ type ActorFactoryHandle = OpaqueHandle<"actorFactory">;
1846
+ type ActorContextHandle = OpaqueHandle<"actorContext">;
1847
+ type ConnHandle = OpaqueHandle<"conn">;
1848
+ type WebSocketHandle = OpaqueHandle<"webSocket">;
1849
+ type CancellationTokenHandle = OpaqueHandle<"cancellationToken">;
1850
+ type ActorStateTransactionHandle = OpaqueHandle<"actorStateTransaction">;
1851
+ type SqliteTransactionHandle = OpaqueHandle<"sqliteTransaction">;
1852
+ type RuntimeBytes = Uint8Array;
1853
+ interface RuntimeActorKeySegment {
1854
+ kind: string;
1855
+ stringValue?: string;
1856
+ numberValue?: number;
1857
+ }
1858
+ interface RuntimeHttpRequest {
1859
+ method: string;
1860
+ uri: string;
1861
+ headers?: Record<string, string>;
1862
+ body?: RuntimeBytes;
1863
+ }
1864
+ interface RuntimeHttpResponseBodyStream {
1865
+ cancelled(): Promise<void>;
1866
+ write(chunk: Uint8Array): Promise<void>;
1867
+ end(): Promise<void>;
1868
+ error(message: string): Promise<void>;
1869
+ }
1870
+ interface RuntimeStateDeltaPayload {
1871
+ state?: RuntimeBytes;
1872
+ connHibernation: Array<{
1873
+ connId: string;
1874
+ bytes: RuntimeBytes;
1875
+ }>;
1876
+ connHibernationRemoved: string[];
1877
+ }
1878
+ interface RuntimeWorkflowKvWrite {
1879
+ key: RuntimeBytes;
1880
+ value: RuntimeBytes;
1881
+ }
1882
+ interface RuntimeRequestSaveOpts {
1883
+ immediate?: boolean;
1884
+ maxWaitMs?: number;
1885
+ }
1886
+ interface RuntimeInspectorSnapshot {
1887
+ stateRevision: number;
1888
+ connectionsRevision: number;
1889
+ queueRevision: number;
1890
+ activeConnections: number;
1891
+ queueSize: number;
1892
+ connectedClients: number;
1893
+ }
1894
+ interface RuntimeQueueMessage {
1895
+ id(): bigint;
1896
+ name(): string;
1897
+ body(): RuntimeBytes;
1898
+ createdAt(): number;
1899
+ isCompletable(): boolean;
1900
+ complete(response?: RuntimeBytes | undefined | null): Promise<void>;
1901
+ }
1902
+ interface RuntimeQueueInspectMessage {
1903
+ id: number;
1904
+ name: string;
1905
+ createdAtMs: number;
1906
+ }
1907
+ interface RuntimeScheduledEventInfo {
1908
+ id: string;
1909
+ action: string;
1910
+ args: RuntimeBytes;
1911
+ runAt: number;
1912
+ }
1913
+ interface RuntimeCronJobInfo {
1914
+ name: string;
1915
+ kind: "cron" | "every";
1916
+ action: string;
1917
+ args: RuntimeBytes;
1918
+ nextRunAt: number;
1919
+ lastRunAt?: number;
1920
+ expression?: string;
1921
+ timezone?: string;
1922
+ intervalMs?: number;
1923
+ maxHistory: number;
1924
+ }
1925
+ interface RuntimeScheduleErrorInfo {
1926
+ group: string;
1927
+ code: string;
1928
+ message: string;
1929
+ metadata?: unknown;
1930
+ }
1931
+ interface RuntimeCronFire {
1932
+ action: string;
1933
+ scheduledAt: number;
1934
+ firedAt: number;
1935
+ finishedAt?: number;
1936
+ result: "running" | "ok" | "error" | "skipped";
1937
+ error?: RuntimeScheduleErrorInfo;
1938
+ }
1939
+ interface RuntimeQueueNextBatchOptions {
1940
+ names?: string[];
1941
+ count?: number;
1942
+ timeoutMs?: number;
1943
+ completable?: boolean;
1944
+ }
1945
+ interface RuntimeQueueWaitOptions {
1946
+ timeoutMs?: number;
1947
+ completable?: boolean;
1948
+ }
1949
+ interface RuntimeQueueEnqueueAndWaitOptions {
1950
+ timeoutMs?: number;
1951
+ }
1952
+ interface RuntimeQueueTryNextBatchOptions {
1953
+ names?: string[];
1954
+ count?: number;
1955
+ completable?: boolean;
1956
+ }
1957
+ interface RuntimeKvListOptions {
1958
+ reverse?: boolean;
1959
+ limit?: number;
1960
+ }
1961
+ interface RuntimeKvEntry {
1962
+ key: RuntimeBytes;
1963
+ value: RuntimeBytes;
1964
+ }
1965
+ type RuntimeSqlBindNoValues = {
1966
+ intValue?: never;
1967
+ floatValue?: never;
1968
+ textValue?: never;
1969
+ blobValue?: never;
1970
+ };
1971
+ type RuntimeSqlBindParam = ({
1972
+ kind: "null";
1973
+ } & RuntimeSqlBindNoValues) | {
1974
+ kind: "int";
1975
+ intValue: number;
1976
+ floatValue?: never;
1977
+ textValue?: never;
1978
+ blobValue?: never;
1979
+ } | {
1980
+ kind: "float";
1981
+ intValue?: never;
1982
+ floatValue: number;
1983
+ textValue?: never;
1984
+ blobValue?: never;
1985
+ } | {
1986
+ kind: "text";
1987
+ intValue?: never;
1988
+ floatValue?: never;
1989
+ textValue: string;
1990
+ blobValue?: never;
1991
+ } | {
1992
+ kind: "blob";
1993
+ intValue?: never;
1994
+ floatValue?: never;
1995
+ textValue?: never;
1996
+ blobValue: RuntimeBytes;
1997
+ };
1998
+ type RuntimeSqlBindParams = RuntimeSqlBindParam[] | null;
1999
+ interface RuntimeActorRuntimeSocketEndpointInfo {
2000
+ path: string;
2001
+ }
2002
+ interface RuntimeSqlQueryResult {
2003
+ columns: string[];
2004
+ rows: unknown[][];
2005
+ }
2006
+ type RuntimeSqlExecResult = RuntimeSqlQueryResult;
2007
+ interface RuntimeSqlExecuteResult extends RuntimeSqlQueryResult {
2008
+ changes: number;
2009
+ lastInsertRowId?: number | null;
2010
+ }
2011
+ interface RuntimeSqlBatchStatement {
2012
+ sql: string;
2013
+ params?: RuntimeSqlBindParams;
2014
+ }
2015
+ interface RuntimeSqlRunResult {
2016
+ changes: number;
2017
+ }
2018
+ interface RuntimeActorConfig {
2019
+ name?: string;
2020
+ icon?: string;
2021
+ hasDatabase?: boolean;
2022
+ remoteSqlite?: boolean;
2023
+ sqliteProfiling?: SqliteProfilingOptions;
2024
+ enableActorRuntimeSocket?: boolean;
2025
+ hasState?: boolean;
2026
+ canHibernateWebsocket?: boolean;
2027
+ stateSaveIntervalMs?: number;
2028
+ createStateTimeoutMs?: number;
2029
+ onCreateTimeoutMs?: number;
2030
+ createVarsTimeoutMs?: number;
2031
+ createConnStateTimeoutMs?: number;
2032
+ onBeforeConnectTimeoutMs?: number;
2033
+ onConnectTimeoutMs?: number;
2034
+ onMigrateTimeoutMs?: number;
2035
+ onWakeTimeoutMs?: number;
2036
+ onBeforeActorStartTimeoutMs?: number;
2037
+ actionTimeoutMs?: number;
2038
+ onRequestTimeoutMs?: number;
2039
+ sleepTimeoutMs?: number;
2040
+ noSleep?: boolean;
2041
+ sleepGracePeriodMs?: number;
2042
+ connectionLivenessTimeoutMs?: number;
2043
+ connectionLivenessIntervalMs?: number;
2044
+ maxQueueSize?: number;
2045
+ maxSchedules?: number;
2046
+ maxQueueMessageSize?: number;
2047
+ maxIncomingMessageSize?: number;
2048
+ maxOutgoingMessageSize?: number;
2049
+ preloadMaxWorkflowBytes?: number;
2050
+ preloadMaxConnectionsBytes?: number;
2051
+ actions?: Array<{
2052
+ name: string;
2053
+ }>;
2054
+ inspectorTabs?: Array<RuntimeInspectorTabEntry>;
2055
+ }
2056
+ interface RuntimeInspectorTabEntry {
2057
+ id: string;
2058
+ /** Required for custom entries; omitted for built-in hides. */
2059
+ label?: string;
2060
+ /**
2061
+ * Required for custom entries — absolute path to the source directory.
2062
+ * Resolved on the TS side before being handed to the runtime.
2063
+ */
2064
+ source?: string;
2065
+ /** Optional icon id for custom entries. */
2066
+ icon?: string;
2067
+ /** Set to true for built-in hide entries. */
2068
+ hidden?: boolean;
2069
+ }
2070
+ interface RuntimeServeConfig {
2071
+ version: number;
2072
+ endpoint: string;
2073
+ token?: string;
2074
+ namespace: string;
2075
+ poolName: string;
2076
+ engineBinaryPath?: string;
2077
+ engineHost?: string;
2078
+ enginePort?: number;
2079
+ handleInspectorHttpInRuntime?: boolean;
2080
+ inspectorTestToken?: string;
2081
+ serverlessBasePath?: string;
2082
+ serverlessPackageVersion: string;
2083
+ serverlessClientEndpoint?: string;
2084
+ serverlessClientNamespace?: string;
2085
+ serverlessClientToken?: string;
2086
+ serverlessValidateEndpoint: boolean;
2087
+ serverlessMaxStartPayloadBytes: number;
2088
+ }
2089
+ interface RuntimeListenerConfig {
2090
+ port: number;
2091
+ host?: string;
2092
+ publicDir?: string;
2093
+ application?: RuntimeApplicationFetch;
2094
+ }
2095
+ interface RuntimeServerlessRequest {
2096
+ method: string;
2097
+ url: string;
2098
+ headers: Record<string, string>;
2099
+ body: RuntimeBytes;
2100
+ }
2101
+ interface RuntimeApplicationRequest extends RuntimeServerlessRequest {
2102
+ cancelToken?: CancellationTokenHandle;
2103
+ }
2104
+ interface RuntimeApplicationResponse {
2105
+ status: number;
2106
+ headers: Record<string, string>;
2107
+ body?: RuntimeBytes;
2108
+ stream?: boolean;
2109
+ }
2110
+ type RuntimeApplicationFetch = (request: RuntimeApplicationRequest, responseBodyStream?: RuntimeHttpResponseBodyStream) => Promise<RuntimeApplicationResponse>;
2111
+ interface RuntimeApplicationListenerConfig extends RuntimeListenerConfig {
2112
+ application: RuntimeApplicationFetch;
2113
+ }
2114
+ interface RuntimeServerlessResponseHead {
2115
+ status: number;
2116
+ headers: Record<string, string>;
2117
+ }
2118
+ interface RuntimeRegistryRouteResponse {
2119
+ status: number;
2120
+ headers: Record<string, string>;
2121
+ body: RuntimeBytes;
2122
+ }
2123
+ type RuntimeServerlessStreamEvent = {
2124
+ kind: "chunk";
2125
+ chunk?: RuntimeBytes;
2126
+ } | {
2127
+ kind: "end";
2128
+ error?: {
2129
+ group: string;
2130
+ code: string;
2131
+ message: string;
2132
+ };
2133
+ };
2134
+ type RuntimeServerlessStreamCallback = (error: unknown, event?: RuntimeServerlessStreamEvent) => unknown;
2135
+ type RuntimeWebSocketEvent = {
2136
+ kind: "message";
2137
+ data: string | RuntimeBytes;
2138
+ binary: boolean;
2139
+ messageIndex?: number;
2140
+ } | {
2141
+ kind: "close";
2142
+ code: number;
2143
+ reason: string;
2144
+ wasClean: boolean;
2145
+ };
2146
+ interface CoreRuntime {
2147
+ readonly kind: "napi" | "wasm";
2148
+ createRegistry(): RegistryHandle;
2149
+ registerActor(registry: RegistryHandle, name: string, factory: ActorFactoryHandle): void;
2150
+ serveRegistry(registry: RegistryHandle, config: RuntimeServeConfig): Promise<void>;
2151
+ waitRegistryReady(registry: RegistryHandle): Promise<void>;
2152
+ shutdownRegistry(registry: RegistryHandle): Promise<void>;
2153
+ registryActorStopThresholdMs?(registry: RegistryHandle): Promise<number | undefined>;
2154
+ handleServerlessRequest(registry: RegistryHandle, req: RuntimeServerlessRequest, onStreamEvent: RuntimeServerlessStreamCallback, cancelToken: CancellationTokenHandle, config: RuntimeServeConfig): Promise<RuntimeServerlessResponseHead>;
2155
+ serveListener(registry: RegistryHandle, listener: RuntimeListenerConfig, config: RuntimeServeConfig): Promise<void>;
2156
+ serveApplicationListener(registry: RegistryHandle, listener: RuntimeApplicationListenerConfig, config: RuntimeServeConfig): Promise<void>;
2157
+ registryHealth?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
2158
+ registryMetadata?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
2159
+ registryMetrics?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
2160
+ createActorFactory(callbacks: object, config?: RuntimeActorConfig | undefined | null): ActorFactoryHandle;
2161
+ createCancellationToken(): CancellationTokenHandle;
2162
+ cancellationTokenAborted(token: CancellationTokenHandle): boolean;
2163
+ cancelCancellationToken(token: CancellationTokenHandle): void;
2164
+ onCancellationTokenCancelled(token: CancellationTokenHandle, callback: (...args: unknown[]) => unknown): void;
2165
+ actorState(ctx: ActorContextHandle): RuntimeBytes;
2166
+ actorBeginOnStateChange(ctx: ActorContextHandle): void;
2167
+ actorEndOnStateChange(ctx: ActorContextHandle): void;
2168
+ actorSetAlarm(ctx: ActorContextHandle, timestampMs?: number | undefined | null): void;
2169
+ actorSetRunWakeAt(ctx: ActorContextHandle, timestampMs?: number | undefined | null): Promise<void>;
2170
+ actorRequestSave(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): void;
2171
+ actorRequestSaveAndWait(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): Promise<void>;
2172
+ actorInspectorSnapshot(ctx: ActorContextHandle): RuntimeInspectorSnapshot;
2173
+ actorDecodeInspectorRequest(ctx: ActorContextHandle, bytes: RuntimeBytes, advertisedVersion: number): RuntimeBytes;
2174
+ actorEncodeInspectorResponse(ctx: ActorContextHandle, bytes: RuntimeBytes, targetVersion: number): RuntimeBytes;
2175
+ actorVerifyInspectorAuth(ctx: ActorContextHandle, bearerToken?: string | undefined | null): Promise<void>;
2176
+ actorQueueHibernationRemoval(ctx: ActorContextHandle, connId: string): void;
2177
+ actorTakePendingHibernationChanges(ctx: ActorContextHandle): string[];
2178
+ actorDirtyHibernatableConns(ctx: ActorContextHandle): ConnHandle[];
2179
+ actorSaveState(ctx: ActorContextHandle, payload: RuntimeStateDeltaPayload): Promise<void>;
2180
+ actorSaveStateAndWorkflowBatch(ctx: ActorContextHandle, writes: RuntimeWorkflowKvWrite[]): Promise<void>;
2181
+ actorId(ctx: ActorContextHandle): string;
2182
+ actorName(ctx: ActorContextHandle): string;
2183
+ actorKey(ctx: ActorContextHandle): RuntimeActorKeySegment[];
2184
+ actorRegion(ctx: ActorContextHandle): string;
2185
+ actorSleep(ctx: ActorContextHandle): void;
2186
+ actorDestroy(ctx: ActorContextHandle): void;
2187
+ actorAbortSignal(ctx: ActorContextHandle): AbortSignal;
2188
+ actorConns(ctx: ActorContextHandle): ConnHandle[];
2189
+ actorConnectConn(ctx: ActorContextHandle, params: RuntimeBytes, request?: RuntimeHttpRequest | undefined | null): Promise<ConnHandle>;
2190
+ actorBroadcast(ctx: ActorContextHandle, name: string, args: RuntimeBytes): void;
2191
+ actorWaitUntil(ctx: ActorContextHandle, promise: Promise<unknown>): void;
2192
+ actorWaitForTrackedShutdownWork(ctx: ActorContextHandle): Promise<boolean>;
2193
+ actorWaitForTrackedShutdownWorkUnbounded(ctx: ActorContextHandle): Promise<void>;
2194
+ actorKeepAwake(ctx: ActorContextHandle, promise: Promise<unknown>): void;
2195
+ actorBeginKeepAwake(ctx: ActorContextHandle): number;
2196
+ actorEndKeepAwake(ctx: ActorContextHandle, regionId: number): void;
2197
+ actorRegisterTask(ctx: ActorContextHandle, promise: Promise<unknown>): void;
2198
+ actorRuntimeState(ctx: ActorContextHandle): object;
2199
+ actorClearRuntimeState(ctx: ActorContextHandle): void;
2200
+ actorRestartRunHandler(ctx: ActorContextHandle): void;
2201
+ actorBeginWebsocketCallback(ctx: ActorContextHandle): number;
2202
+ actorEndWebsocketCallback(ctx: ActorContextHandle, regionId: number): void;
2203
+ actorKvGet(ctx: ActorContextHandle, key: RuntimeBytes): Promise<RuntimeBytes | null>;
2204
+ actorKvPut(ctx: ActorContextHandle, key: RuntimeBytes, value: RuntimeBytes): Promise<void>;
2205
+ actorKvDelete(ctx: ActorContextHandle, key: RuntimeBytes): Promise<void>;
2206
+ actorKvDeleteRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes): Promise<void>;
2207
+ actorKvListPrefix(ctx: ActorContextHandle, prefix: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
2208
+ actorKvListRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
2209
+ actorKvBatchGet(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<Array<RuntimeBytes | undefined | null>>;
2210
+ actorKvBatchPut(ctx: ActorContextHandle, entries: RuntimeKvEntry[]): Promise<void>;
2211
+ actorKvBatchDelete(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<void>;
2212
+ actorSqlExec(ctx: ActorContextHandle, sql: string): Promise<RuntimeSqlExecResult>;
2213
+ actorSqlExecute(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
2214
+ actorSqlExecuteBatch(ctx: ActorContextHandle, statements: RuntimeSqlBatchStatement[]): Promise<RuntimeSqlExecuteResult[]>;
2215
+ actorSqlBeginTransaction(ctx: ActorContextHandle, timeoutMs?: number, name?: string): Promise<SqliteTransactionHandle>;
2216
+ actorSqlTransactionExec(transaction: SqliteTransactionHandle, sql: string): Promise<RuntimeSqlExecResult>;
2217
+ actorSqlTransactionExecute(transaction: SqliteTransactionHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
2218
+ actorSqlTransactionCommit(transaction: SqliteTransactionHandle): Promise<void>;
2219
+ actorSqlTransactionRollback(transaction: SqliteTransactionHandle): Promise<void>;
2220
+ actorBeginStateTransaction(ctx: ActorContextHandle, timeoutMs?: number): Promise<ActorStateTransactionHandle>;
2221
+ actorStateTransactionExecute(transaction: ActorStateTransactionHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
2222
+ actorStateTransactionCommit(transaction: ActorStateTransactionHandle, payload: RuntimeStateDeltaPayload): Promise<void>;
2223
+ actorStateTransactionRollback(transaction: ActorStateTransactionHandle): Promise<void>;
2224
+ actorSqlQuery(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlQueryResult>;
2225
+ actorSqlRun(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlRunResult>;
2226
+ actorSqlMetrics(ctx: ActorContextHandle): SqliteNativeMetrics | null;
2227
+ actorSqlTakeLastKvError(ctx: ActorContextHandle): string | null;
2228
+ actorSqlClose(ctx: ActorContextHandle): Promise<void>;
2229
+ actorRuntimeSocketProvision(ctx: ActorContextHandle): Promise<RuntimeActorRuntimeSocketEndpointInfo>;
2230
+ actorQueueSend(ctx: ActorContextHandle, name: string, body: RuntimeBytes): Promise<RuntimeQueueMessage>;
2231
+ actorQueueNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueNextBatchOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage[]>;
2232
+ actorQueueWaitForNames(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage>;
2233
+ actorQueueWaitForNamesAvailable(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<void>;
2234
+ actorQueueCompletePersisted(ctx: ActorContextHandle, messageId: bigint, expectedName: string, response?: RuntimeBytes | undefined | null): Promise<boolean>;
2235
+ actorQueueEnqueueAndWait(ctx: ActorContextHandle, name: string, body: RuntimeBytes, options?: RuntimeQueueEnqueueAndWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeBytes | null>;
2236
+ actorQueueTryNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueTryNextBatchOptions | undefined | null): RuntimeQueueMessage[];
2237
+ actorQueueMaxSize(ctx: ActorContextHandle): number;
2238
+ actorQueueInspectMessages(ctx: ActorContextHandle): Promise<RuntimeQueueInspectMessage[]>;
2239
+ actorQueueReset(ctx: ActorContextHandle): Promise<void>;
2240
+ actorScheduleAfter(ctx: ActorContextHandle, durationMs: number, actionName: string, args: RuntimeBytes): Promise<string>;
2241
+ actorScheduleAt(ctx: ActorContextHandle, timestampMs: number, actionName: string, args: RuntimeBytes): Promise<string>;
2242
+ actorScheduleCancel(ctx: ActorContextHandle, id: string): Promise<boolean>;
2243
+ actorScheduleGet(ctx: ActorContextHandle, id: string): Promise<RuntimeScheduledEventInfo | undefined>;
2244
+ actorScheduleList(ctx: ActorContextHandle): Promise<RuntimeScheduledEventInfo[]>;
2245
+ actorCronSet(ctx: ActorContextHandle, name: string, expression: string, timezone: string | undefined, actionName: string, args: RuntimeBytes, maxHistory: number | undefined): Promise<void>;
2246
+ actorCronEvery(ctx: ActorContextHandle, name: string, intervalMs: number, actionName: string, args: RuntimeBytes, maxHistory: number | undefined): Promise<void>;
2247
+ actorCronGet(ctx: ActorContextHandle, name: string): Promise<RuntimeCronJobInfo | undefined>;
2248
+ actorCronList(ctx: ActorContextHandle): Promise<RuntimeCronJobInfo[]>;
2249
+ actorCronDelete(ctx: ActorContextHandle, name: string): Promise<boolean>;
2250
+ actorCronHistory(ctx: ActorContextHandle, name: string, limit: number | undefined): Promise<RuntimeCronFire[]>;
2251
+ connId(conn: ConnHandle): string;
2252
+ connParams(conn: ConnHandle): RuntimeBytes;
2253
+ connState(conn: ConnHandle): RuntimeBytes;
2254
+ connSetState(conn: ConnHandle, state: RuntimeBytes): void;
2255
+ connIsHibernatable(conn: ConnHandle): boolean;
2256
+ connSend(conn: ConnHandle, name: string, args: RuntimeBytes): void;
2257
+ connDisconnect(conn: ConnHandle, reason?: string | undefined | null): Promise<void>;
2258
+ webSocketSend(ws: WebSocketHandle, data: RuntimeBytes, binary: boolean): void;
2259
+ webSocketClose(ws: WebSocketHandle, code?: number | undefined | null, reason?: string | undefined | null): Promise<void>;
2260
+ webSocketSetEventCallback(ws: WebSocketHandle, callback: (event: RuntimeWebSocketEvent) => void): void;
2261
+ }
2262
+
2263
+ declare function buildConfiguredRegistry(config: RegistryConfig): Promise<{
2264
+ runtime: CoreRuntime;
2265
+ registry: RegistryHandle;
2266
+ serveConfig: RuntimeServeConfig;
2267
+ }>;
2268
+
1501
2269
  type FetchHandler = (request: Request, ...args: any) => Response | Promise<Response>;
1502
2270
  interface ServerlessHandler {
1503
2271
  fetch: FetchHandler;
1504
2272
  }
2273
+ interface RegistryApplication {
2274
+ fetch: FetchHandler;
2275
+ }
2276
+ interface RegistryListenOptions {
2277
+ port?: number;
2278
+ host?: string;
2279
+ publicDir?: string;
2280
+ application?: RegistryApplication;
2281
+ }
2282
+ interface RegistryRoutes {
2283
+ health(): Promise<Response>;
2284
+ metadata(): Promise<Response>;
2285
+ prometheusMetrics(request?: Request): Promise<Response>;
2286
+ }
2287
+ /**
2288
+ * Injectable dependencies for {@link Registry}. Production code uses the
2289
+ * defaults. Tests override `buildConfiguredRegistry` to drive lifecycle
2290
+ * orchestration against a fake `CoreRuntime` without an engine.
2291
+ */
2292
+ interface RegistryDeps {
2293
+ buildConfiguredRegistry: typeof buildConfiguredRegistry;
2294
+ }
1505
2295
  declare class Registry<A extends RegistryActors> {
1506
2296
  #private;
2297
+ readonly routes: RegistryRoutes;
1507
2298
  get config(): RegistryConfigInput<A>;
1508
2299
  parseConfig(): RegistryConfig;
1509
- constructor(config: RegistryConfigInput<A>);
2300
+ constructor(config: RegistryConfigInput<A>, deps?: Partial<RegistryDeps>);
1510
2301
  /**
1511
2302
  * Handle an incoming HTTP request for serverless deployments.
1512
2303
  *
@@ -1527,9 +2318,63 @@ declare class Registry<A extends RegistryActors> {
1527
2318
  * ```
1528
2319
  */
1529
2320
  serve(): ServerlessHandler;
2321
+ /**
2322
+ * Bind an HTTP listener provided by the native (Rust) runtime and serve
2323
+ * the registry's serverless endpoints over it. Resolves only after the
2324
+ * registry is shut down (SIGINT/SIGTERM or `nativeRegistry.shutdown()`).
2325
+ *
2326
+ * @param opts.port Port to listen on. Defaults to `process.env.RIVET_PORT`
2327
+ * if set, otherwise 3000.
2328
+ * @param opts.host Address to bind. Defaults to `0.0.0.0`.
2329
+ * @param opts.publicDir If set, serves static files from this directory
2330
+ * as a fallback below the framework routes.
2331
+ * @param opts.application If set, handles requests that do not match a
2332
+ * framework route.
2333
+ *
2334
+ * @example
2335
+ * ```ts
2336
+ * await registry.listen();
2337
+ * await registry.listen({ application: app });
2338
+ * ```
2339
+ */
2340
+ listen(opts?: RegistryListenOptions): Promise<void>;
2341
+ /**
2342
+ * Gracefully drains all live registries.
2343
+ *
2344
+ * Programmatic counterpart to the SIGINT/SIGTERM handlers: tears down
2345
+ * every live `CoreRegistry` (both `start()` and `handler()` modes) and
2346
+ * waits for the serve promise to resolve, all bounded by the shutdown
2347
+ * grace period. Unlike a signal-driven shutdown, this does not re-raise a
2348
+ * signal or exit the process. The caller owns process lifetime.
2349
+ *
2350
+ * Idempotent: concurrent or repeated calls share a single drain. Safe to
2351
+ * call even if nothing has been started.
2352
+ *
2353
+ * @example
2354
+ * ```ts
2355
+ * const registry = setup({ use: { counter } });
2356
+ * registry.start();
2357
+ * // ...later, on your own shutdown trigger:
2358
+ * await registry.shutdown();
2359
+ * ```
2360
+ */
2361
+ shutdown(): Promise<void>;
1530
2362
  startEnvoy(): void;
1531
2363
  /**
1532
- * Starts the native actor envoy for standalone server deployments.
2364
+ * Starts the serverful registry if needed and waits until its envoy has
2365
+ * registered with the Engine. Repeated and concurrent calls share one
2366
+ * startup lifecycle and readiness promise.
2367
+ *
2368
+ * Unlike {@link start}, this reports startup failures and does not resolve
2369
+ * merely because an HTTP health endpoint is listening.
2370
+ */
2371
+ startAndWait(): Promise<void>;
2372
+ /**
2373
+ * Starts the actor envoy for standalone server deployments.
2374
+ *
2375
+ * Set `RIVETKIT_RUNTIME_MODE=serverless` to instead bind an HTTP listener
2376
+ * via `listen()` (Mode B). Mode A (envoy) and Mode B (listener) are
2377
+ * mutually exclusive per registry instance.
1533
2378
  *
1534
2379
  * @example
1535
2380
  * ```ts
@@ -1545,4 +2390,4 @@ declare class Registry<A extends RegistryActors> {
1545
2390
  */
1546
2391
  declare function createClient<A extends Registry<any>>(endpointOrConfig?: string | ClientConfigInput): Client<A>;
1547
2392
 
1548
- export { type ActorAccessor, type ActorActionFunction, ActorClientError, type ActorConn, ActorConnDisposed, ActorConnRaw, type ActorConnStatus, ActorDefinition, RivetError as ActorError, type ActorHandle, ActorHandleRaw, type AnyActorDefinition, type Client, type ClientConfigInput, ClientRaw, type ConnectionStateCallback, type CreateOptions, type CreateRequest, type Encoding, type EventUnsubscribe, type ExtractActorsFromRegistry, type ExtractRegistryFromClient, type GetOptions, type GetWithIdOptions, MalformedResponseMessage, ManagerError, type QueryOptions, type Region, RivetError, type StatusChangeCallback, UserError, createClient };
2393
+ export { type ActorAccessor, type ActorActionFunction, type ActorActionOptions, ActorClientError, type ActorConn, ActorConnDisposed, ActorConnRaw, type ActorConnStatus, type ActorConnectOptions, ActorDefinition, RivetError as ActorError, type ActorGatewayOptions, type ActorHandle, ActorHandleRaw, type AnyActorDefinition, type Client, type ClientConfigInput, ClientRaw, type ConnectionStateCallback, type CreateOptions, type CreateRequest, type Encoding, type EventUnsubscribe, type ExtractActorsFromRegistry, type ExtractRegistryFromClient, type GetOptions, type GetWithIdOptions, MalformedResponseMessage, ManagerError, type QueryOptions, type Region, RivetError, type StatusChangeCallback, UserError, createClient };