rivetkit 0.0.0-runner-config-drain-grace-threshold.e1be3d6 → 0.0.0-sql-metrics.eac581d

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 (273) hide show
  1. package/dist/browser/client.d.ts +774 -92
  2. package/dist/browser/client.js +1385 -736
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.d.ts +126 -3
  5. package/dist/browser/inspector/client.js +2067 -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 +2371 -2093
  13. package/dist/tsup/agent-os/index.cjs.map +1 -1
  14. package/dist/tsup/agent-os/index.d.cts +771 -91
  15. package/dist/tsup/agent-os/index.d.ts +771 -91
  16. package/dist/tsup/agent-os/index.js +2375 -2097
  17. package/dist/tsup/agent-os/index.js.map +1 -1
  18. package/dist/tsup/{chunk-TCQKPKZN.js → chunk-3Q3KETKF.js} +13 -7
  19. package/dist/tsup/chunk-3Q3KETKF.js.map +1 -0
  20. package/dist/tsup/{chunk-V3QNBJ7N.cjs → chunk-4FC7TVS6.cjs} +35 -10
  21. package/dist/tsup/chunk-4FC7TVS6.cjs.map +1 -0
  22. package/dist/tsup/{chunk-GL3HIPV4.cjs → chunk-6ADBGIKV.cjs} +484 -66
  23. package/dist/tsup/chunk-6ADBGIKV.cjs.map +1 -0
  24. package/dist/tsup/{chunk-DPXHJ73A.js → chunk-DZ7KAOCW.js} +2 -2
  25. package/dist/tsup/{chunk-67RKOMDW.cjs → chunk-EI3JQYAW.cjs} +1050 -455
  26. package/dist/tsup/chunk-EI3JQYAW.cjs.map +1 -0
  27. package/dist/tsup/{chunk-FYDM3DOZ.js → chunk-FMMENOAT.js} +920 -325
  28. package/dist/tsup/chunk-FMMENOAT.js.map +1 -0
  29. package/dist/tsup/{chunk-BNGG6IEA.cjs → chunk-HNHLBM3Y.cjs} +197 -18
  30. package/dist/tsup/chunk-HNHLBM3Y.cjs.map +1 -0
  31. package/dist/tsup/{chunk-SRMJW54U.cjs → chunk-IW3TD3AZ.cjs} +10 -10
  32. package/dist/tsup/chunk-IW3TD3AZ.cjs.map +1 -0
  33. package/dist/tsup/{chunk-3YY5S6TV.js → chunk-JI6GZ2C2.js} +3 -12
  34. package/dist/tsup/chunk-JI6GZ2C2.js.map +1 -0
  35. package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JTHHCZCZ.js} +24 -1
  36. package/dist/tsup/chunk-JTHHCZCZ.js.map +1 -0
  37. package/dist/tsup/{chunk-5I23FPCU.cjs → chunk-KTH2ZCJ7.cjs} +3 -3
  38. package/dist/tsup/chunk-KTH2ZCJ7.cjs.map +1 -0
  39. package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-KVFIONKQ.cjs} +25 -2
  40. package/dist/tsup/chunk-KVFIONKQ.cjs.map +1 -0
  41. package/dist/tsup/{chunk-ZLQ4AEF5.cjs → chunk-MCRNU6ZS.cjs} +46 -9
  42. package/dist/tsup/chunk-MCRNU6ZS.cjs.map +1 -0
  43. package/dist/tsup/{chunk-LD5YASJU.cjs → chunk-MYWZCDML.cjs} +3 -12
  44. package/dist/tsup/chunk-MYWZCDML.cjs.map +1 -0
  45. package/dist/tsup/{chunk-5DM7UBJ6.js → chunk-QWLJCP3X.js} +195 -16
  46. package/dist/tsup/chunk-QWLJCP3X.js.map +1 -0
  47. package/dist/tsup/{chunk-5Q26DE3S.js → chunk-VHZ2ICIB.js} +476 -58
  48. package/dist/tsup/chunk-VHZ2ICIB.js.map +1 -0
  49. package/dist/tsup/{chunk-ZULMYDHF.cjs → chunk-XFAJRV5B.cjs} +17 -11
  50. package/dist/tsup/chunk-XFAJRV5B.cjs.map +1 -0
  51. package/dist/tsup/{chunk-IWKPKMUZ.js → chunk-XUBFECDW.js} +45 -8
  52. package/dist/tsup/chunk-XUBFECDW.js.map +1 -0
  53. package/dist/tsup/{chunk-27VQ5J4Q.js → chunk-ZKM6KFU7.js} +6 -6
  54. package/dist/tsup/chunk-ZKM6KFU7.js.map +1 -0
  55. package/dist/tsup/{chunk-K34B3OVG.js → chunk-ZZ3WBRPD.js} +34 -9
  56. package/dist/tsup/chunk-ZZ3WBRPD.js.map +1 -0
  57. package/dist/tsup/client/mod.cjs +8 -9
  58. package/dist/tsup/client/mod.cjs.map +1 -1
  59. package/dist/tsup/client/mod.d.cts +7 -7
  60. package/dist/tsup/client/mod.d.ts +7 -7
  61. package/dist/tsup/client/mod.js +7 -8
  62. package/dist/tsup/common/log.cjs +5 -3
  63. package/dist/tsup/common/log.cjs.map +1 -1
  64. package/dist/tsup/common/log.d.cts +5 -1
  65. package/dist/tsup/common/log.d.ts +5 -1
  66. package/dist/tsup/common/log.js +6 -4
  67. package/dist/tsup/common/websocket.cjs +4 -4
  68. package/dist/tsup/common/websocket.cjs.map +1 -1
  69. package/dist/tsup/common/websocket.js +3 -3
  70. package/dist/tsup/{config-kxXbtrJU.d.cts → config-BiFJvUlm.d.cts} +48 -4
  71. package/dist/tsup/{config-kxXbtrJU.d.ts → config-BiFJvUlm.d.ts} +48 -4
  72. package/dist/tsup/{config-B2reim3z.d.ts → config-Dc-M9yZ2.d.cts} +771 -59
  73. package/dist/tsup/{config-BA5q_2Kt.d.cts → config-gT4c5si9.d.ts} +771 -59
  74. package/dist/tsup/context-DIes1x7n.d.cts +129 -0
  75. package/dist/tsup/context-DKoLp07T.d.ts +129 -0
  76. package/dist/tsup/db/drizzle.cjs +146 -72
  77. package/dist/tsup/db/drizzle.cjs.map +1 -1
  78. package/dist/tsup/db/drizzle.d.cts +8 -4
  79. package/dist/tsup/db/drizzle.d.ts +8 -4
  80. package/dist/tsup/db/drizzle.js +146 -72
  81. package/dist/tsup/db/drizzle.js.map +1 -1
  82. package/dist/tsup/db/mod.cjs +83 -18
  83. package/dist/tsup/db/mod.cjs.map +1 -1
  84. package/dist/tsup/db/mod.d.cts +12 -4
  85. package/dist/tsup/db/mod.d.ts +12 -4
  86. package/dist/tsup/db/mod.js +83 -18
  87. package/dist/tsup/db/mod.js.map +1 -1
  88. package/dist/tsup/dynamic/mod.cjs +24 -0
  89. package/dist/tsup/dynamic/mod.cjs.map +1 -0
  90. package/dist/tsup/dynamic/mod.d.cts +37 -0
  91. package/dist/tsup/dynamic/mod.d.ts +37 -0
  92. package/dist/tsup/dynamic/mod.js +24 -0
  93. package/dist/tsup/dynamic/mod.js.map +1 -0
  94. package/dist/tsup/inspector/mod.cjs +46 -12
  95. package/dist/tsup/inspector/mod.cjs.map +1 -1
  96. package/dist/tsup/inspector/mod.d.cts +30 -6
  97. package/dist/tsup/inspector/mod.d.ts +30 -6
  98. package/dist/tsup/inspector/mod.js +45 -11
  99. package/dist/tsup/inspector/mod.js.map +1 -1
  100. package/dist/tsup/inspector-tab/mod.cjs +162 -0
  101. package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
  102. package/dist/tsup/inspector-tab/mod.d.cts +240 -0
  103. package/dist/tsup/inspector-tab/mod.d.ts +240 -0
  104. package/dist/tsup/inspector-tab/mod.js +162 -0
  105. package/dist/tsup/inspector-tab/mod.js.map +1 -0
  106. package/dist/tsup/mod.cjs +1852 -559
  107. package/dist/tsup/mod.cjs.map +1 -1
  108. package/dist/tsup/mod.d.cts +6 -7
  109. package/dist/tsup/mod.d.ts +6 -7
  110. package/dist/tsup/mod.js +1773 -480
  111. package/dist/tsup/mod.js.map +1 -1
  112. package/dist/tsup/test/mod.cjs +26 -21
  113. package/dist/tsup/test/mod.cjs.map +1 -1
  114. package/dist/tsup/test/mod.d.cts +5 -6
  115. package/dist/tsup/test/mod.d.ts +5 -6
  116. package/dist/tsup/test/mod.js +25 -20
  117. package/dist/tsup/test/mod.js.map +1 -1
  118. package/dist/tsup/unstable/migrations.cjs +101 -0
  119. package/dist/tsup/unstable/migrations.cjs.map +1 -0
  120. package/dist/tsup/unstable/migrations.d.cts +29 -0
  121. package/dist/tsup/unstable/migrations.d.ts +29 -0
  122. package/dist/tsup/unstable/migrations.js +101 -0
  123. package/dist/tsup/unstable/migrations.js.map +1 -0
  124. package/dist/tsup/utils-CV0akuDD.d.ts +162 -0
  125. package/dist/tsup/utils-CqDnC_PS.d.cts +104 -0
  126. package/dist/tsup/utils-CqDnC_PS.d.ts +104 -0
  127. package/dist/tsup/utils-DQDCphrl.d.cts +162 -0
  128. package/dist/tsup/utils.cjs +7 -3
  129. package/dist/tsup/utils.cjs.map +1 -1
  130. package/dist/tsup/utils.d.cts +4 -147
  131. package/dist/tsup/utils.d.ts +4 -147
  132. package/dist/tsup/utils.js +6 -2
  133. package/dist/tsup/workflow/mod.cjs +486 -375
  134. package/dist/tsup/workflow/mod.cjs.map +1 -1
  135. package/dist/tsup/workflow/mod.d.cts +9 -10
  136. package/dist/tsup/workflow/mod.d.ts +9 -10
  137. package/dist/tsup/workflow/mod.js +478 -367
  138. package/dist/tsup/workflow/mod.js.map +1 -1
  139. package/package.json +51 -15
  140. package/src/actor/actions.ts +119 -0
  141. package/src/actor/config.test.ts +14 -0
  142. package/src/actor/config.ts +349 -91
  143. package/src/actor/contexts/index.ts +7 -2
  144. package/src/actor/definition.ts +38 -26
  145. package/src/actor/errors.ts +70 -7
  146. package/src/actor/keys.ts +1 -1
  147. package/src/actor/mod.ts +22 -20
  148. package/src/actor/schema.ts +2 -2
  149. package/src/agent-os/actor/index.ts +39 -19
  150. package/src/agent-os/actor/preview.ts +1 -2
  151. package/src/agent-os/actor/session.ts +2 -2
  152. package/src/agent-os/config.ts +1 -1
  153. package/src/agent-os/fs/database-vfs.ts +1 -1
  154. package/src/agent-os/index.ts +16 -15
  155. package/src/client/actor-common.ts +89 -54
  156. package/src/client/actor-conn.ts +59 -64
  157. package/src/client/actor-handle.ts +121 -69
  158. package/src/client/actor-query.ts +5 -5
  159. package/src/client/client.ts +35 -11
  160. package/src/client/errors.ts +2 -1
  161. package/src/client/lifecycle-errors.ts +2 -4
  162. package/src/client/query.ts +3 -1
  163. package/src/client/queue.ts +8 -3
  164. package/src/client/raw-utils.ts +13 -12
  165. package/src/client/resolve-gateway-target.ts +3 -1
  166. package/src/client/utils.ts +34 -10
  167. package/src/common/actor-router-consts.ts +4 -0
  168. package/src/common/actor-websocket.ts +3 -1
  169. package/src/common/bare/actor-persist/v1.ts +205 -163
  170. package/src/common/bare/actor-persist/v2.ts +265 -213
  171. package/src/common/bare/actor-persist/v3.ts +176 -172
  172. package/src/common/bare/actor-persist/v4.ts +254 -253
  173. package/src/common/bare/generated/actor-runtime-socket-protocol/v1.ts +848 -0
  174. package/src/common/bare/generated/client-protocol/v4.ts +599 -0
  175. package/src/common/bare/generated/inspector/v5.ts +1016 -0
  176. package/src/common/bare/generated/inspector/v6.ts +1367 -0
  177. package/src/common/bare/transport/v1.ts +694 -542
  178. package/src/common/client-protocol-versioned.ts +176 -67
  179. package/src/common/client-protocol-zod.ts +7 -0
  180. package/src/common/client-protocol.ts +1 -1
  181. package/src/common/database/config.ts +63 -9
  182. package/src/common/database/mod.test.ts +201 -40
  183. package/src/common/database/mod.ts +111 -30
  184. package/src/common/database/native-database.test.ts +44 -22
  185. package/src/common/database/native-database.ts +162 -6
  186. package/src/common/database/shared.ts +25 -0
  187. package/src/common/encoding.ts +278 -34
  188. package/src/common/engine.ts +28 -1
  189. package/src/common/eventsource.ts +1 -1
  190. package/src/common/fetch-like.ts +49 -0
  191. package/src/common/inline-websocket-adapter.ts +14 -13
  192. package/src/common/inspector-transport.ts +12 -2
  193. package/src/common/log.ts +15 -8
  194. package/src/common/router.ts +49 -23
  195. package/src/common/utils.ts +10 -202
  196. package/src/common/websocket-interface.ts +1 -1
  197. package/src/db/drizzle.test.ts +164 -0
  198. package/src/db/drizzle.ts +187 -89
  199. package/src/db/mod.ts +3 -1
  200. package/src/devtools-loader/index.ts +4 -7
  201. package/src/devtools-loader/serve-devtools.ts +26 -0
  202. package/src/dynamic/instance.ts +32 -0
  203. package/src/dynamic/internal.ts +50 -0
  204. package/src/dynamic/isolate-runtime.ts +64 -0
  205. package/src/dynamic/mod.ts +32 -0
  206. package/src/engine-client/actor-http-client.ts +3 -3
  207. package/src/engine-client/actor-websocket-client.ts +6 -5
  208. package/src/engine-client/api-endpoints.ts +51 -2
  209. package/src/engine-client/api-utils.ts +2 -2
  210. package/src/engine-client/driver.ts +5 -16
  211. package/src/engine-client/mod.ts +19 -48
  212. package/src/engine-client/ws-proxy.ts +9 -4
  213. package/src/inspector/client.browser.ts +127 -15
  214. package/src/inspector/mod.ts +2 -4
  215. package/src/inspector-tab/mod.ts +301 -0
  216. package/src/registry/config/envoy.ts +1 -2
  217. package/src/registry/config/index.ts +41 -55
  218. package/src/registry/index.ts +554 -91
  219. package/src/registry/napi-runtime.ts +340 -23
  220. package/src/registry/native-validation.ts +10 -12
  221. package/src/registry/native.ts +844 -413
  222. package/src/registry/process-metrics.ts +250 -0
  223. package/src/registry/runtime.ts +243 -9
  224. package/src/registry/wasm-runtime.ts +290 -9
  225. package/src/registry/write-through-proxy.ts +141 -0
  226. package/src/serde.ts +2 -2
  227. package/src/serverless/configure.ts +18 -7
  228. package/src/test/mod.ts +2 -17
  229. package/src/test/ready.ts +22 -0
  230. package/src/unstable/migrations.test.ts +170 -0
  231. package/src/unstable/migrations.ts +141 -0
  232. package/src/utils/crypto.ts +14 -0
  233. package/src/utils/endpoint-parser.ts +1 -1
  234. package/src/utils/env-vars.ts +37 -0
  235. package/src/utils/router.ts +1 -1
  236. package/src/utils.ts +4 -2
  237. package/src/workflow/context.ts +683 -242
  238. package/src/workflow/driver.test.ts +62 -0
  239. package/src/workflow/driver.ts +248 -119
  240. package/src/workflow/inspector.ts +21 -16
  241. package/src/workflow/mod.ts +39 -25
  242. package/dist/tsup/chunk-27VQ5J4Q.js.map +0 -1
  243. package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
  244. package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
  245. package/dist/tsup/chunk-5DM7UBJ6.js.map +0 -1
  246. package/dist/tsup/chunk-5I23FPCU.cjs.map +0 -1
  247. package/dist/tsup/chunk-5Q26DE3S.js.map +0 -1
  248. package/dist/tsup/chunk-67RKOMDW.cjs.map +0 -1
  249. package/dist/tsup/chunk-BNGG6IEA.cjs.map +0 -1
  250. package/dist/tsup/chunk-FYDM3DOZ.js.map +0 -1
  251. package/dist/tsup/chunk-GL3HIPV4.cjs.map +0 -1
  252. package/dist/tsup/chunk-IWKPKMUZ.js.map +0 -1
  253. package/dist/tsup/chunk-K34B3OVG.js.map +0 -1
  254. package/dist/tsup/chunk-LD5YASJU.cjs.map +0 -1
  255. package/dist/tsup/chunk-M56BAR36.cjs +0 -268
  256. package/dist/tsup/chunk-M56BAR36.cjs.map +0 -1
  257. package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
  258. package/dist/tsup/chunk-SRMJW54U.cjs.map +0 -1
  259. package/dist/tsup/chunk-TCQKPKZN.js.map +0 -1
  260. package/dist/tsup/chunk-V3QNBJ7N.cjs.map +0 -1
  261. package/dist/tsup/chunk-YCTA3LBC.js +0 -268
  262. package/dist/tsup/chunk-YCTA3LBC.js.map +0 -1
  263. package/dist/tsup/chunk-ZLQ4AEF5.cjs.map +0 -1
  264. package/dist/tsup/chunk-ZULMYDHF.cjs.map +0 -1
  265. package/dist/tsup/context-7374C2do.d.ts +0 -92
  266. package/dist/tsup/context-Vv4C_cT-.d.cts +0 -92
  267. package/dist/tsup/utils-fwx3o3K9.d.cts +0 -18
  268. package/dist/tsup/utils-fwx3o3K9.d.ts +0 -18
  269. package/src/actor/driver.ts +0 -141
  270. package/src/actor/instance/mod.ts +0 -2493
  271. package/src/drivers/engine/actor-driver.ts +0 -2470
  272. package/src/utils/serve.ts +0 -217
  273. /package/dist/tsup/{chunk-DPXHJ73A.js.map → chunk-DZ7KAOCW.js.map} +0 -0
@@ -1,8 +1,8 @@
1
1
  import * as _rivetkit_rivetkit_wasm from '@rivetkit/rivetkit-wasm';
2
2
  import { z as z$2 } from 'zod';
3
3
  import z$1, { z } from 'zod/v4';
4
- import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
5
4
  import { Context, Handler, Hono } from 'hono';
5
+ import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
6
6
  import { StandardSchemaV1 } from '@standard-schema/spec';
7
7
  import { ContentfulStatusCode } from 'hono/utils/http-status';
8
8
  import { Logger } from 'pino';
@@ -23,6 +23,35 @@ interface SqliteExecuteResult extends SqliteQueryResult {
23
23
  changes: number;
24
24
  lastInsertRowId?: number | null;
25
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
+ }
36
+ /**
37
+ * SQLite profiling configuration.
38
+ *
39
+ * @experimental This entire configuration surface is experimental and subject
40
+ * to change without notice.
41
+ */
42
+ interface SqliteProfilingOptions {
43
+ enabled?: boolean;
44
+ maxTrackedStatementFingerprints?: number;
45
+ maxTrackedTransactionFingerprints?: number;
46
+ maxPrometheusSeries?: number;
47
+ maxStatementsPerTransactionTrace?: number;
48
+ maxGetPagesRequestsPerTrace?: number;
49
+ maxTransactionNameBytes?: number;
50
+ slowOperationThresholdMs?: number;
51
+ baselineSampleRate?: number;
52
+ maxDiagnosticEventsPerMinute?: number;
53
+ diagnosticEventQueueCapacity?: number;
54
+ }
26
55
  interface SqliteNativeMetrics {
27
56
  requestBuildNs: number;
28
57
  serializeNs: number;
@@ -39,12 +68,19 @@ interface SqliteNativeMetrics {
39
68
  interface SqliteDatabase {
40
69
  exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
41
70
  execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
71
+ executeBatch(statements: SqliteBatchStatement[]): Promise<SqliteExecuteResult[]>;
72
+ beginTransaction(timeoutMs?: number, name?: string): Promise<SqliteTransactionDatabase>;
42
73
  run(sql: string, params?: SqliteBindings): Promise<void>;
43
74
  query(sql: string, params?: SqliteBindings): Promise<SqliteQueryResult>;
44
- writeMode<T>(callback: () => Promise<T>): Promise<T>;
45
75
  nativeMetrics?(): SqliteNativeMetrics | Promise<SqliteNativeMetrics | null> | null;
46
76
  close(): Promise<void>;
47
77
  }
78
+ interface SqliteTransactionDatabase {
79
+ exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
80
+ execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
81
+ commit(): Promise<void>;
82
+ rollback(): Promise<void>;
83
+ }
48
84
  /**
49
85
  * Provider for opening native databases from the active runtime.
50
86
  */
@@ -88,6 +124,13 @@ interface DatabaseProviderContext {
88
124
  nativeDatabaseProvider?: NativeDatabaseProvider;
89
125
  }
90
126
  type DatabaseProvider<DB extends RawAccess> = {
127
+ /**
128
+ * Local SQLite profiling controls consumed by the actor runtime.
129
+ *
130
+ * @experimental This entire configuration surface is experimental and
131
+ * subject to change without notice.
132
+ */
133
+ sqliteProfiling?: SqliteProfilingOptions;
91
134
  /**
92
135
  * Creates a new database client for the actor.
93
136
  * The result is passed to the actor context as `c.db`.
@@ -104,14 +147,15 @@ type DatabaseProvider<DB extends RawAccess> = {
104
147
  /**
105
148
  * Drizzle database client interface (will be extended by drizzle-orm types)
106
149
  */
107
- interface DrizzleDatabaseClient {
108
- }
150
+ type DrizzleDatabaseClient = {};
109
151
  type ExecuteFunction = <TRow extends Record<string, unknown> = Record<string, unknown>>(query: string, ...args: unknown[]) => Promise<TRow[]>;
110
152
  type RawAccess = {
111
153
  /**
112
154
  * Executes a raw SQL query.
113
155
  */
114
156
  execute: ExecuteFunction;
157
+ /** Runs a callback in an isolated SQLite transaction. */
158
+ transaction: <T>(callback: (tx: RawAccess) => Promise<T> | T, options?: SqliteTransactionOptions) => Promise<T>;
115
159
  /**
116
160
  * Returns native SQLite metrics when the active runtime supports them.
117
161
  */
@@ -151,6 +195,7 @@ declare const CreateRequestSchema: z.ZodObject<{
151
195
  key: z.ZodArray<z.ZodString>;
152
196
  input: z.ZodOptional<z.ZodUnknown>;
153
197
  region: z.ZodOptional<z.ZodString>;
198
+ poolName: z.ZodOptional<z.ZodString>;
154
199
  }, z.core.$strip>;
155
200
  declare const ActorQuerySchema: z.ZodUnion<readonly [z.ZodObject<{
156
201
  getForId: z.ZodObject<{
@@ -168,6 +213,7 @@ declare const ActorQuerySchema: z.ZodUnion<readonly [z.ZodObject<{
168
213
  key: z.ZodArray<z.ZodString>;
169
214
  input: z.ZodOptional<z.ZodUnknown>;
170
215
  region: z.ZodOptional<z.ZodString>;
216
+ poolName: z.ZodOptional<z.ZodString>;
171
217
  }, z.core.$strip>;
172
218
  }, z.core.$strip>, z.ZodObject<{
173
219
  create: z.ZodObject<{
@@ -175,6 +221,7 @@ declare const ActorQuerySchema: z.ZodUnion<readonly [z.ZodObject<{
175
221
  key: z.ZodArray<z.ZodString>;
176
222
  input: z.ZodOptional<z.ZodUnknown>;
177
223
  region: z.ZodOptional<z.ZodString>;
224
+ poolName: z.ZodOptional<z.ZodString>;
178
225
  }, z.core.$strip>;
179
226
  }, z.core.$strip>]>;
180
227
  type ActorQuery = z.infer<typeof ActorQuerySchema>;
@@ -183,6 +230,44 @@ type ActorQuery = z.infer<typeof ActorQuerySchema>;
183
230
  */
184
231
  type CreateRequest = z.infer<typeof CreateRequestSchema>;
185
232
 
233
+ type SchemaHookResult = boolean | Promise<boolean>;
234
+ type SchemaHook<TContext = any> = (ctx: TContext) => SchemaHookResult;
235
+ interface EventTypeToken<T, TContext = any> {
236
+ readonly _eventType?: T;
237
+ readonly canSubscribe?: SchemaHook<TContext>;
238
+ readonly schema?: PrimitiveSchema;
239
+ }
240
+ interface QueueTypeToken<TMessage, TComplete = never, TContext = any> {
241
+ readonly _queueMessage?: TMessage;
242
+ readonly _queueComplete?: TComplete;
243
+ readonly canPublish?: SchemaHook<TContext>;
244
+ readonly message?: PrimitiveSchema;
245
+ readonly complete?: PrimitiveSchema;
246
+ }
247
+ type PrimitiveSchema = StandardSchemaV1 | EventTypeToken<unknown, any>;
248
+ interface EventSchemaDefinition<TContext = any> {
249
+ schema: PrimitiveSchema;
250
+ canSubscribe?: SchemaHook<TContext>;
251
+ }
252
+ interface QueueSchemaDefinition<TContext = any> {
253
+ message: PrimitiveSchema;
254
+ complete?: PrimitiveSchema;
255
+ canPublish?: SchemaHook<TContext>;
256
+ }
257
+ type EventSchema<TContext = any> = PrimitiveSchema | EventSchemaDefinition<TContext>;
258
+ type QueueSchema = PrimitiveSchema | QueueSchemaDefinition<any> | QueueTypeToken<unknown, unknown, any>;
259
+ type EventSchemaConfig<TContext = any> = Record<string, EventSchema<TContext>>;
260
+ type QueueSchemaConfig<_TContext = any> = Record<string, QueueSchema>;
261
+ 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;
262
+ type InferSchemaMap<T extends Record<string, unknown>> = {
263
+ [K in keyof T]: InferSchema<T[K]>;
264
+ };
265
+ 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;
266
+ type InferQueueCompleteMap<T extends QueueSchemaConfig> = {
267
+ [K in keyof T]: InferQueueComplete<T[K]>;
268
+ };
269
+ type InferEventArgs<T> = T extends readonly unknown[] ? number extends T["length"] ? [T] : T : [T];
270
+
186
271
  interface DeconstructedError {
187
272
  __type: "ActorError";
188
273
  statusCode: ContentfulStatusCode;
@@ -191,6 +276,7 @@ interface DeconstructedError {
191
276
  code: string;
192
277
  message: string;
193
278
  metadata?: unknown;
279
+ actor?: ActorSpecifier;
194
280
  }
195
281
 
196
282
  interface RivetErrorOptions extends ErrorOptions {
@@ -200,6 +286,14 @@ interface RivetErrorOptions extends ErrorOptions {
200
286
  metadata?: unknown;
201
287
  /** Explicit HTTP status override for router responses. */
202
288
  statusCode?: number;
289
+ /** Actor context associated with this error. */
290
+ actor?: ActorSpecifier;
291
+ }
292
+ /** Identifies the actor that was handling work when an error was produced. */
293
+ interface ActorSpecifier {
294
+ actorId: string;
295
+ generation: number;
296
+ key?: string;
203
297
  }
204
298
  interface UserErrorOptions extends ErrorOptions {
205
299
  /**
@@ -218,6 +312,7 @@ declare class RivetError extends Error {
218
312
  public: boolean;
219
313
  metadata?: unknown;
220
314
  statusCode: number;
315
+ actor?: ActorSpecifier;
221
316
  readonly group: string;
222
317
  readonly code: string;
223
318
  static isRivetError(error: unknown): error is RivetError | DeconstructedError;
@@ -230,44 +325,6 @@ declare class UserError extends RivetError {
230
325
  constructor(message: string, options?: UserErrorOptions);
231
326
  }
232
327
 
233
- type SchemaHookResult = boolean | Promise<boolean>;
234
- type SchemaHook<TContext = any> = (ctx: TContext) => SchemaHookResult;
235
- interface EventTypeToken<T, TContext = any> {
236
- readonly _eventType?: T;
237
- readonly canSubscribe?: SchemaHook<TContext>;
238
- readonly schema?: PrimitiveSchema;
239
- }
240
- interface QueueTypeToken<TMessage, TComplete = never, TContext = any> {
241
- readonly _queueMessage?: TMessage;
242
- readonly _queueComplete?: TComplete;
243
- readonly canPublish?: SchemaHook<TContext>;
244
- readonly message?: PrimitiveSchema;
245
- readonly complete?: PrimitiveSchema;
246
- }
247
- type PrimitiveSchema = StandardSchemaV1 | EventTypeToken<unknown, any>;
248
- interface EventSchemaDefinition<TContext = any> {
249
- schema: PrimitiveSchema;
250
- canSubscribe?: SchemaHook<TContext>;
251
- }
252
- interface QueueSchemaDefinition<TContext = any> {
253
- message: PrimitiveSchema;
254
- complete?: PrimitiveSchema;
255
- canPublish?: SchemaHook<TContext>;
256
- }
257
- type EventSchema<TContext = any> = PrimitiveSchema | EventSchemaDefinition<TContext>;
258
- type QueueSchema = PrimitiveSchema | QueueSchemaDefinition<any> | QueueTypeToken<unknown, unknown, any>;
259
- type EventSchemaConfig<TContext = any> = Record<string, EventSchema<TContext>>;
260
- type QueueSchemaConfig<TContext = any> = Record<string, QueueSchema>;
261
- 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;
262
- type InferSchemaMap<T extends Record<string, unknown>> = {
263
- [K in keyof T]: InferSchema<T[K]>;
264
- };
265
- 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;
266
- type InferQueueCompleteMap<T extends QueueSchemaConfig> = {
267
- [K in keyof T]: InferQueueComplete<T[K]>;
268
- };
269
- type InferEventArgs<T> = T extends readonly unknown[] ? number extends T["length"] ? [T] : T : [T];
270
-
271
328
  type UpgradeWebSocket = (createEvents: (c: Context) => any) => Handler;
272
329
  type GetUpgradeWebSocket = () => UpgradeWebSocket;
273
330
 
@@ -297,11 +354,6 @@ interface EngineControlClient {
297
354
  * Test-only helper that simulates an abrupt actor crash.
298
355
  */
299
356
  hardCrashActor?(actorId: string): Promise<void>;
300
- kvGet(actorId: string, key: Uint8Array): Promise<string | null>;
301
- kvBatchGet(actorId: string, keys: Uint8Array[]): Promise<(Uint8Array | null)[]>;
302
- kvBatchPut(actorId: string, entries: [Uint8Array, Uint8Array][]): Promise<void>;
303
- kvBatchDelete(actorId: string, keys: Uint8Array[]): Promise<void>;
304
- kvDeleteRange(actorId: string, start: Uint8Array, end: Uint8Array): Promise<void>;
305
357
  }
306
358
  interface RuntimeDisplayInformation {
307
359
  properties: Record<string, string>;
@@ -323,6 +375,8 @@ interface GetOrCreateWithKeyInput {
323
375
  input?: unknown;
324
376
  region?: string;
325
377
  crashPolicy?: CrashPolicy;
378
+ /** Overrides the client's configured pool name for this actor. */
379
+ poolName?: string;
326
380
  }
327
381
  interface CreateInput {
328
382
  c?: Context | undefined;
@@ -331,6 +385,8 @@ interface CreateInput {
331
385
  input?: unknown;
332
386
  region?: string;
333
387
  crashPolicy?: CrashPolicy;
388
+ /** Overrides the client's configured pool name for this actor. */
389
+ poolName?: string;
334
390
  }
335
391
  interface ListActorsInput {
336
392
  c?: Context | undefined;
@@ -375,6 +431,12 @@ interface QueueSendResult<TResponse = unknown> {
375
431
  * @returns {Promise<Response>}
376
432
  */
377
433
  type ActorActionFunction<Args extends Array<unknown> = unknown[], Response = unknown> = (...args: Args extends [unknown, ...infer Rest] ? Rest : Args) => Promise<Response>;
434
+ type IsAny<T> = 0 extends 1 & T ? true : false;
435
+ type LooseEventSubscribe = (eventName: string, callback: (...args: any[]) => void) => () => void;
436
+ type ActorActionMap<R> = {
437
+ [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;
438
+ };
439
+ type ActionsOf<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<any, any, any, any, any, any, any, any, infer R> ? R : never;
378
440
  interface ActorGatewayOptions {
379
441
  skipReadyWait?: boolean;
380
442
  }
@@ -387,9 +449,7 @@ type ActorWebSocketOptions = ActorGatewayOptions;
387
449
  /**
388
450
  * Maps action methods from actor definition to typed function signatures.
389
451
  */
390
- type ActorDefinitionActions<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<any, any, any, any, any, any, any, any, infer R> ? {
391
- [K in keyof R]: R[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Return> : never;
392
- } : never;
452
+ type ActorDefinitionActions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? Record<string, ActorActionFunction<any[], any>> : ActorActionMap<ActionsOf<AD>>;
393
453
  type ActorQueueSend<TQueues extends QueueSchemaConfig> = {
394
454
  <K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options: QueueSendWaitOptions): Promise<QueueSendResult<InferQueueCompleteMap<TQueues>[K]>>;
395
455
  <K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options?: QueueSendNoWaitOptions): Promise<void>;
@@ -400,13 +460,31 @@ type ActorEventSubscribe<TEvents extends EventSchemaConfig> = {
400
460
  <K extends keyof TEvents & string>(eventName: K, callback: (...args: InferEventArgs<InferSchemaMap<TEvents>[K]>) => void): () => void;
401
461
  (eventName: keyof TEvents extends never ? string : never, callback: (...args: any[]) => void): () => void;
402
462
  };
403
- type ActorDefinitionQueueSend<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<any, any, any, any, any, any, any, infer Q, any> ? Q extends QueueSchemaConfig ? {
463
+ type ActorDefinitionQueueSend<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
464
+ send: ActorQueueSend<Record<string, any>>;
465
+ } : AD extends {
466
+ config: {
467
+ queues?: infer Q;
468
+ };
469
+ } ? Q extends QueueSchemaConfig ? {
404
470
  send: ActorQueueSend<Q>;
405
- } : never : never;
406
- type ActorDefinitionEventSubscriptions<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<any, any, any, any, any, any, infer E, any, any> ? E extends EventSchemaConfig ? {
471
+ } : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, any, infer Q, any> ? Q extends QueueSchemaConfig ? {
472
+ send: ActorQueueSend<Q>;
473
+ } : {} : {};
474
+ type ActorDefinitionEventSubscriptions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
475
+ on: LooseEventSubscribe;
476
+ once: LooseEventSubscribe;
477
+ } : AD extends {
478
+ config: {
479
+ events?: infer E;
480
+ };
481
+ } ? E extends EventSchemaConfig ? {
407
482
  on: ActorEventSubscribe<E>;
408
483
  once: ActorEventSubscribe<E>;
409
- } : never : never;
484
+ } : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, infer E, any, any> ? E extends EventSchemaConfig ? {
485
+ on: ActorEventSubscribe<E>;
486
+ once: ActorEventSubscribe<E>;
487
+ } : {} : {};
410
488
 
411
489
  declare class ActorClientError extends Error {
412
490
  }
@@ -815,6 +893,11 @@ interface GetOrCreateOptions extends QueryOptions {
815
893
  createInRegion?: string;
816
894
  /** Input data to pass to the actor. */
817
895
  createWithInput?: unknown;
896
+ /**
897
+ * Name of the envoy pool to select for this actor if it is created.
898
+ * Overrides the client's configured `poolName` for this call.
899
+ */
900
+ poolName?: string;
818
901
  }
819
902
  /**
820
903
  * Options for creating a actor.
@@ -826,6 +909,11 @@ interface CreateOptions extends QueryOptions {
826
909
  region?: string;
827
910
  /** Input data to pass to the actor. */
828
911
  input?: unknown;
912
+ /**
913
+ * Name of the envoy pool to select for this actor.
914
+ * Overrides the client's configured `poolName` for this call.
915
+ */
916
+ poolName?: string;
829
917
  }
830
918
  /**
831
919
  * Represents a region to connect to.
@@ -920,6 +1008,7 @@ type Client<A extends Registry<any>> = ClientRaw & {
920
1008
  };
921
1009
 
922
1010
  declare const ACTOR_CONTEXT_INTERNAL_SYMBOL: unique symbol;
1011
+ declare const RAW_STATE_SYMBOL: unique symbol;
923
1012
  interface ActorLogger {
924
1013
  level: any;
925
1014
  fatal: any;
@@ -952,6 +1041,10 @@ type ActorKvListOptions<T extends ActorKvValueType = "text", K extends ActorKvKe
952
1041
  limit?: number;
953
1042
  };
954
1043
  type ActorClientFor<T> = T extends Registry<any> ? Client<T> : T;
1044
+ /**
1045
+ * @deprecated Actor KV is deprecated. Use embedded SQLite (`c.db` / `c.sql`)
1046
+ * or actor state instead.
1047
+ */
955
1048
  interface ActorKv {
956
1049
  get<T extends ActorKvValueType = "text">(key: Uint8Array | string, options?: ActorKvValueOptions<T>): Promise<ActorKvValueTypeMap[T] | null>;
957
1050
  put<T extends ActorKvValueType = "text">(key: Uint8Array | string, value: Uint8Array | string | ArrayBuffer, options?: ActorKvValueOptions<T>): Promise<void>;
@@ -966,10 +1059,76 @@ interface ActorKv {
966
1059
  [key: string]: any;
967
1060
  }
968
1061
  interface ActorSchedule {
969
- after(duration: number, action: string, ...args: unknown[]): Promise<void>;
970
- at(timestamp: number, action: string, ...args: unknown[]): Promise<void>;
1062
+ after(duration: number, action: string, ...args: unknown[]): Promise<string>;
1063
+ at(timestamp: number, action: string, ...args: unknown[]): Promise<string>;
1064
+ cancel(id: string): Promise<boolean>;
1065
+ get(id: string): Promise<ScheduledEventInfo | undefined>;
1066
+ list(): Promise<ScheduledEventInfo[]>;
1067
+ [key: string]: any;
1068
+ }
1069
+ interface ActorCronSetOptions {
1070
+ name: string;
1071
+ expression: string;
1072
+ action: string;
1073
+ args?: unknown[];
1074
+ timezone?: string;
1075
+ /** Defaults to 100. Set to 0 to disable and clear history. Maximum 1,000. */
1076
+ maxHistory?: number;
1077
+ }
1078
+ interface ActorCronEveryOptions {
1079
+ name: string;
1080
+ /** Fixed interval in milliseconds. Minimum 5,000. */
1081
+ interval: number;
1082
+ action: string;
1083
+ args?: unknown[];
1084
+ /** Defaults to 100. Set to 0 to disable and clear history. Maximum 1,000. */
1085
+ maxHistory?: number;
1086
+ }
1087
+ interface ActorCron {
1088
+ set(options: ActorCronSetOptions): Promise<void>;
1089
+ every(options: ActorCronEveryOptions): Promise<void>;
1090
+ get(name: string): Promise<CronJobInfo | undefined>;
1091
+ list(): Promise<CronJobInfo[]>;
1092
+ delete(name: string): Promise<boolean>;
1093
+ history(name: string, options?: {
1094
+ limit?: number;
1095
+ }): Promise<CronFire[]>;
971
1096
  [key: string]: any;
972
1097
  }
1098
+ interface ScheduledEventInfo {
1099
+ id: string;
1100
+ action: string;
1101
+ args: unknown[];
1102
+ runAt: number;
1103
+ }
1104
+ type CronJobInfo = {
1105
+ name: string;
1106
+ action: string;
1107
+ args: unknown[];
1108
+ nextRunAt: number;
1109
+ lastRunAt?: number;
1110
+ maxHistory: number;
1111
+ } & ({
1112
+ kind: "cron";
1113
+ expression: string;
1114
+ timezone: string;
1115
+ } | {
1116
+ kind: "every";
1117
+ interval: number;
1118
+ });
1119
+ interface CronFire {
1120
+ action: string;
1121
+ scheduledAt: number;
1122
+ firedAt: number;
1123
+ finishedAt?: number;
1124
+ result: "running" | "ok" | "error" | "skipped";
1125
+ error?: {
1126
+ group: string;
1127
+ code: string;
1128
+ message: string;
1129
+ metadata?: unknown;
1130
+ };
1131
+ }
973
1132
  type QueueMessageOf<Name extends string, Body> = {
974
1133
  id: number | bigint;
975
1134
  name: Name;
@@ -1028,7 +1187,7 @@ interface ActorQueue<TQueues extends QueueSchemaConfig = Record<never, never>> {
1028
1187
  iter<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueIterOptions<TName, TCompletable>): AsyncIterable<any>;
1029
1188
  [key: string]: any;
1030
1189
  }
1031
- 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>> {
1190
+ 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>> {
1032
1191
  id: string;
1033
1192
  params: TConnParams;
1034
1193
  state: TConnState;
@@ -1039,16 +1198,27 @@ interface Conn<TState = unknown, TConnParams = unknown, TConnState = unknown, TV
1039
1198
  }
1040
1199
  interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
1041
1200
  [ACTOR_CONTEXT_INTERNAL_SYMBOL]?: unknown;
1201
+ /** Returns the raw unwrapped state without the write-through proxy. */
1202
+ [RAW_STATE_SYMBOL](): TState;
1042
1203
  state: TState;
1043
1204
  vars: TVars;
1205
+ /**
1206
+ * @deprecated Actor KV is deprecated. Use embedded SQLite (`db` / `sql`)
1207
+ * or actor state instead.
1208
+ */
1044
1209
  readonly kv: ActorKv;
1045
1210
  readonly db: InferDatabaseClient<TDatabase>;
1046
1211
  readonly schedule: ActorSchedule;
1212
+ readonly cron: ActorCron;
1047
1213
  readonly queue: ActorQueue<TQueues>;
1048
1214
  readonly actorId: string;
1049
1215
  readonly name: string;
1050
1216
  readonly key: string[];
1051
1217
  readonly region: string;
1218
+ /** Provisions the experimental Actor Runtime Socket for this actor generation. */
1219
+ actorRuntimeSocket(): Promise<{
1220
+ path: string;
1221
+ }>;
1052
1222
  readonly conns: Map<string, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>;
1053
1223
  readonly log: ActorLogger;
1054
1224
  readonly abortSignal: AbortSignal;
@@ -1130,7 +1300,7 @@ declare const ActorConfigSchema: z.ZodObject<{
1130
1300
  onBeforeActionResponse: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
1131
1301
  onRequest: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
1132
1302
  onWebSocket: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
1133
- actions: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>>;
1303
+ actions: z.ZodDefault<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
1134
1304
  actionInputSchemas: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1135
1305
  connParamsSchema: z.ZodOptional<z.ZodAny>;
1136
1306
  events: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
@@ -1145,6 +1315,7 @@ declare const ActorConfigSchema: z.ZodObject<{
1145
1315
  options: z.ZodPrefault<z.ZodObject<{
1146
1316
  name: z.ZodOptional<z.ZodString>;
1147
1317
  icon: z.ZodOptional<z.ZodString>;
1318
+ enableActorRuntimeSocket: z.ZodDefault<z.ZodBoolean>;
1148
1319
  canHibernateWebSocket: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodCustom<(request: Request) => boolean, (request: Request) => boolean>]>>;
1149
1320
  createVarsTimeout: z.ZodDefault<z.ZodNumber>;
1150
1321
  createConnStateTimeout: z.ZodDefault<z.ZodNumber>;
@@ -1161,12 +1332,33 @@ declare const ActorConfigSchema: z.ZodObject<{
1161
1332
  noSleep: z.ZodDefault<z.ZodBoolean>;
1162
1333
  sleepTimeout: z.ZodDefault<z.ZodNumber>;
1163
1334
  maxQueueSize: z.ZodDefault<z.ZodNumber>;
1335
+ maxSchedules: z.ZodDefault<z.ZodNumber>;
1164
1336
  maxQueueMessageSize: z.ZodDefault<z.ZodNumber>;
1165
1337
  preloadMaxWorkflowBytes: z.ZodOptional<z.ZodNumber>;
1166
1338
  preloadMaxConnectionsBytes: z.ZodOptional<z.ZodNumber>;
1167
1339
  }, z.core.$strict>>;
1340
+ inspector: z.ZodOptional<z.ZodObject<{
1341
+ tabs: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
1342
+ id: z.ZodString;
1343
+ label: z.ZodString;
1344
+ source: z.ZodString;
1345
+ icon: z.ZodOptional<z.ZodString>;
1346
+ hidden: z.ZodOptional<z.ZodLiteral<false>>;
1347
+ }, z.core.$strict>, z.ZodObject<{
1348
+ id: z.ZodEnum<{
1349
+ state: "state";
1350
+ workflow: "workflow";
1351
+ database: "database";
1352
+ queue: "queue";
1353
+ schedules: "schedules";
1354
+ connections: "connections";
1355
+ console: "console";
1356
+ }>;
1357
+ hidden: z.ZodLiteral<true>;
1358
+ }, z.core.$strict>]>>>;
1359
+ }, z.core.$strict>>;
1168
1360
  }, z.core.$strict>;
1169
- type CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
1361
+ type CreateState<TState, _TConnParams, _TConnState, _TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
1170
1362
  state: TState;
1171
1363
  } | {
1172
1364
  createState: (c: CreateContext<TState, TInput, TDatabase, TEvents, TQueues>, input: TInput) => TState | Promise<TState>;
@@ -1179,7 +1371,7 @@ type CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase e
1179
1371
  /**
1180
1372
  * @experimental
1181
1373
  */
1182
- type CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
1374
+ type CreateVars<TState, _TConnParams, _TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
1183
1375
  /**
1184
1376
  * @experimental
1185
1377
  */
@@ -1191,7 +1383,10 @@ type CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase extend
1191
1383
  createVars: (c: CreateVarsContext<TState, TInput, TDatabase, TEvents, TQueues>, driverCtx: any) => TVars | Promise<TVars>;
1192
1384
  } | Record<never, never>;
1193
1385
  interface Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
1194
- [Action: string]: (c: ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, ...args: any[]) => any;
1386
+ [Action: string]: ((c: ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, ...args: any[]) => any) | Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
1387
+ }
1388
+ interface ActionInputSchemas {
1389
+ [Action: string]: PrimitiveSchema | ActionInputSchemas;
1195
1390
  }
1196
1391
  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>> {
1197
1392
  /**
@@ -1276,10 +1471,11 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
1276
1471
  * Called before a client connects to the actor.
1277
1472
  *
1278
1473
  * Use this hook to determine if a connection should be accepted
1279
- * and to initialize connection-specific state.
1474
+ * and to validate client-provided parameters. The pending connection
1475
+ * is not visible in `c.conns` while this hook runs.
1280
1476
  *
1281
1477
  * @param opts Connection parameters including client-provided data
1282
- * @returns The initial connection state or a Promise that resolves to it
1478
+ * @returns Void or a Promise.
1283
1479
  * @throws Throw an error to reject the connection
1284
1480
  */
1285
1481
  onBeforeConnect?: (c: BeforeConnectContext<TState, TVars, TInput, TDatabase, TEvents, TQueues>, params: TConnParams) => void | Promise<void>;
@@ -1287,7 +1483,8 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
1287
1483
  * Called when a client successfully connects to the actor.
1288
1484
  *
1289
1485
  * Use this hook to perform actions when a connection is established,
1290
- * such as sending initial data or updating the actor's state.
1486
+ * such as sending initial data or updating the actor's state. The
1487
+ * connection is visible in `c.conns` before this hook runs.
1291
1488
  *
1292
1489
  * @param conn The connection object
1293
1490
  * @returns Void or a Promise that resolves when connection handling is complete
@@ -1341,9 +1538,10 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
1341
1538
  onWebSocket?: (c: WebSocketContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, websocket: UniversalWebSocket) => void | Promise<void>;
1342
1539
  actions?: TActions;
1343
1540
  /**
1344
- * Optional schema map for validating action argument tuples in native runtimes.
1541
+ * Optional schemas for validating action argument tuples in native runtimes.
1542
+ * May mirror nested action groups or use dot-separated low-level action names.
1345
1543
  */
1346
- actionInputSchemas?: Record<string, PrimitiveSchema>;
1544
+ actionInputSchemas?: ActionInputSchemas;
1347
1545
  /**
1348
1546
  * Optional schema for validating connection params in native runtimes.
1349
1547
  */
@@ -1363,19 +1561,21 @@ type ActorDatabaseConfig<TDatabase extends AnyDatabaseProvider> = {
1363
1561
  */
1364
1562
  db: TDatabase;
1365
1563
  } | Record<never, never>;
1366
- 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>;
1564
+ 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>;
1367
1565
 
1368
- 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>> {
1369
- readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q>;
1566
+ 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>> {
1567
+ readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q, _R>;
1568
+ }
1569
+ interface AnyActorDefinition {
1570
+ readonly config: any;
1370
1571
  }
1371
- type AnyActorDefinition = BaseActorDefinition<any, any, any, any, any, any, any, any, any>;
1372
1572
  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> {
1373
1573
  #private;
1374
- constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q>);
1375
- get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q>;
1574
+ constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q, R>);
1575
+ get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q, R>;
1376
1576
  }
1377
1577
 
1378
- 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>>>;
1578
+ declare const ActorsSchema: z$2.ZodRecord<z$2.ZodString, z$2.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
1379
1579
  type RegistryActors = z$2.infer<typeof ActorsSchema>;
1380
1580
  declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1381
1581
  use: z$2.ZodRecord<z$2.ZodString, z$2.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
@@ -1395,11 +1595,7 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1395
1595
  }>>, z$2.ZodTransform<"auto" | "native" | "wasm", "auto" | "native" | "wasm" | undefined>>;
1396
1596
  wasm: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodObject<{
1397
1597
  bindings: z$2.ZodOptional<z$2.ZodCustom<typeof _rivetkit_rivetkit_wasm, typeof _rivetkit_rivetkit_wasm>>;
1398
- initInput: z$2.ZodOptional<z$2.ZodCustom<{
1399
- module_or_path: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput>;
1400
- } | _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined, {
1401
- module_or_path: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput>;
1402
- } | _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined>>;
1598
+ initInput: z$2.ZodOptional<z$2.ZodCustom<_rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined, _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined>>;
1403
1599
  }, z$2.core.$strip>>>;
1404
1600
  sqlite: z$2.ZodPipe<z$2.ZodOptional<z$2.ZodUnion<readonly [z$2.ZodEnum<{
1405
1601
  local: "local";
@@ -1436,6 +1632,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1436
1632
  httpPort: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
1437
1633
  httpHost: z$2.ZodOptional<z$2.ZodString>;
1438
1634
  startEngine: z$2.ZodDefault<z$2.ZodBoolean>;
1635
+ engineHost: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodString>>;
1636
+ enginePort: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
1439
1637
  engineVersion: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodString>>;
1440
1638
  configurePool: z$2.ZodOptional<z$2.ZodOptional<z$2.ZodObject<{
1441
1639
  name: z$2.ZodOptional<z$2.ZodString>;
@@ -1460,7 +1658,7 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1460
1658
  envoyKey: z$2.ZodOptional<z$2.ZodString>;
1461
1659
  }, z$2.core.$strip>>>;
1462
1660
  shutdown: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodObject<{
1463
- gracePeriodMs: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
1661
+ gracePeriodMs: z$2.ZodOptional<z$2.ZodNumber>;
1464
1662
  disableSignalHandlers: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodBoolean>>;
1465
1663
  }, z$2.core.$strip>>>;
1466
1664
  }, z$2.core.$strip>, z$2.ZodTransform<{
@@ -1490,9 +1688,7 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1490
1688
  runtime: "auto" | "native" | "wasm";
1491
1689
  wasm: {
1492
1690
  bindings?: typeof _rivetkit_rivetkit_wasm | undefined;
1493
- initInput?: {
1494
- module_or_path: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput>;
1495
- } | _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined;
1691
+ initInput?: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined;
1496
1692
  };
1497
1693
  noWelcome: boolean;
1498
1694
  logging: {
@@ -1503,6 +1699,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1503
1699
  httpBasePath: string;
1504
1700
  httpPort: number;
1505
1701
  startEngine: boolean;
1702
+ engineHost: string;
1703
+ enginePort: number;
1506
1704
  engineVersion: string;
1507
1705
  envoy: {
1508
1706
  poolName: string;
@@ -1511,8 +1709,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1511
1709
  envoyKey?: string | undefined;
1512
1710
  };
1513
1711
  shutdown: {
1514
- gracePeriodMs: number;
1515
1712
  disableSignalHandlers: boolean;
1713
+ gracePeriodMs?: number | undefined;
1516
1714
  };
1517
1715
  staticDir?: string | undefined;
1518
1716
  httpHost?: string | undefined;
@@ -1537,9 +1735,7 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1537
1735
  runtime: "auto" | "native" | "wasm";
1538
1736
  wasm: {
1539
1737
  bindings?: typeof _rivetkit_rivetkit_wasm | undefined;
1540
- initInput?: {
1541
- module_or_path: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput>;
1542
- } | _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined;
1738
+ initInput?: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined;
1543
1739
  };
1544
1740
  sqlite: {
1545
1741
  backend: "local" | "remote";
@@ -1556,6 +1752,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1556
1752
  httpBasePath: string;
1557
1753
  httpPort: number;
1558
1754
  startEngine: boolean;
1755
+ engineHost: string;
1756
+ enginePort: number;
1559
1757
  engineVersion: string;
1560
1758
  serverless: {
1561
1759
  basePath: string;
@@ -1570,8 +1768,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1570
1768
  envoyKey?: string | undefined;
1571
1769
  };
1572
1770
  shutdown: {
1573
- gracePeriodMs: number;
1574
1771
  disableSignalHandlers: boolean;
1772
+ gracePeriodMs?: number | undefined;
1575
1773
  };
1576
1774
  staticDir?: string | undefined;
1577
1775
  httpHost?: string | undefined;
@@ -1591,19 +1789,450 @@ type RegistryConfigInput<A extends RegistryActors> = Omit<z$2.input<typeof Regis
1591
1789
  use: A;
1592
1790
  };
1593
1791
 
1792
+ declare const handleBrand: unique symbol;
1793
+ type OpaqueHandle<Name extends string> = {
1794
+ readonly [handleBrand]: Name;
1795
+ };
1796
+ type RegistryHandle = OpaqueHandle<"registry">;
1797
+ type ActorFactoryHandle = OpaqueHandle<"actorFactory">;
1798
+ type ActorContextHandle = OpaqueHandle<"actorContext">;
1799
+ type ConnHandle = OpaqueHandle<"conn">;
1800
+ type WebSocketHandle = OpaqueHandle<"webSocket">;
1801
+ type CancellationTokenHandle = OpaqueHandle<"cancellationToken">;
1802
+ type SqliteTransactionHandle = OpaqueHandle<"sqliteTransaction">;
1803
+ type RuntimeBytes = Uint8Array;
1804
+ interface RuntimeActorKeySegment {
1805
+ kind: string;
1806
+ stringValue?: string;
1807
+ numberValue?: number;
1808
+ }
1809
+ interface RuntimeHttpRequest {
1810
+ method: string;
1811
+ uri: string;
1812
+ headers?: Record<string, string>;
1813
+ body?: RuntimeBytes;
1814
+ }
1815
+ interface RuntimeStateDeltaPayload {
1816
+ state?: RuntimeBytes;
1817
+ connHibernation: Array<{
1818
+ connId: string;
1819
+ bytes: RuntimeBytes;
1820
+ }>;
1821
+ connHibernationRemoved: string[];
1822
+ }
1823
+ interface RuntimeWorkflowKvWrite {
1824
+ key: RuntimeBytes;
1825
+ value: RuntimeBytes;
1826
+ }
1827
+ interface RuntimeRequestSaveOpts {
1828
+ immediate?: boolean;
1829
+ maxWaitMs?: number;
1830
+ }
1831
+ interface RuntimeInspectorSnapshot {
1832
+ stateRevision: number;
1833
+ connectionsRevision: number;
1834
+ queueRevision: number;
1835
+ activeConnections: number;
1836
+ queueSize: number;
1837
+ connectedClients: number;
1838
+ }
1839
+ interface RuntimeQueueMessage {
1840
+ id(): bigint;
1841
+ name(): string;
1842
+ body(): RuntimeBytes;
1843
+ createdAt(): number;
1844
+ isCompletable(): boolean;
1845
+ complete(response?: RuntimeBytes | undefined | null): Promise<void>;
1846
+ }
1847
+ interface RuntimeQueueInspectMessage {
1848
+ id: number;
1849
+ name: string;
1850
+ createdAtMs: number;
1851
+ }
1852
+ interface RuntimeScheduledEventInfo {
1853
+ id: string;
1854
+ action: string;
1855
+ args: RuntimeBytes;
1856
+ runAt: number;
1857
+ }
1858
+ interface RuntimeCronJobInfo {
1859
+ name: string;
1860
+ kind: "cron" | "every";
1861
+ action: string;
1862
+ args: RuntimeBytes;
1863
+ nextRunAt: number;
1864
+ lastRunAt?: number;
1865
+ expression?: string;
1866
+ timezone?: string;
1867
+ intervalMs?: number;
1868
+ maxHistory: number;
1869
+ }
1870
+ interface RuntimeScheduleErrorInfo {
1871
+ group: string;
1872
+ code: string;
1873
+ message: string;
1874
+ metadata?: unknown;
1875
+ }
1876
+ interface RuntimeCronFire {
1877
+ action: string;
1878
+ scheduledAt: number;
1879
+ firedAt: number;
1880
+ finishedAt?: number;
1881
+ result: "running" | "ok" | "error" | "skipped";
1882
+ error?: RuntimeScheduleErrorInfo;
1883
+ }
1884
+ interface RuntimeQueueNextBatchOptions {
1885
+ names?: string[];
1886
+ count?: number;
1887
+ timeoutMs?: number;
1888
+ completable?: boolean;
1889
+ }
1890
+ interface RuntimeQueueWaitOptions {
1891
+ timeoutMs?: number;
1892
+ completable?: boolean;
1893
+ }
1894
+ interface RuntimeQueueEnqueueAndWaitOptions {
1895
+ timeoutMs?: number;
1896
+ }
1897
+ interface RuntimeQueueTryNextBatchOptions {
1898
+ names?: string[];
1899
+ count?: number;
1900
+ completable?: boolean;
1901
+ }
1902
+ interface RuntimeKvListOptions {
1903
+ reverse?: boolean;
1904
+ limit?: number;
1905
+ }
1906
+ interface RuntimeKvEntry {
1907
+ key: RuntimeBytes;
1908
+ value: RuntimeBytes;
1909
+ }
1910
+ type RuntimeSqlBindNoValues = {
1911
+ intValue?: never;
1912
+ floatValue?: never;
1913
+ textValue?: never;
1914
+ blobValue?: never;
1915
+ };
1916
+ type RuntimeSqlBindParam = ({
1917
+ kind: "null";
1918
+ } & RuntimeSqlBindNoValues) | {
1919
+ kind: "int";
1920
+ intValue: number;
1921
+ floatValue?: never;
1922
+ textValue?: never;
1923
+ blobValue?: never;
1924
+ } | {
1925
+ kind: "float";
1926
+ intValue?: never;
1927
+ floatValue: number;
1928
+ textValue?: never;
1929
+ blobValue?: never;
1930
+ } | {
1931
+ kind: "text";
1932
+ intValue?: never;
1933
+ floatValue?: never;
1934
+ textValue: string;
1935
+ blobValue?: never;
1936
+ } | {
1937
+ kind: "blob";
1938
+ intValue?: never;
1939
+ floatValue?: never;
1940
+ textValue?: never;
1941
+ blobValue: RuntimeBytes;
1942
+ };
1943
+ type RuntimeSqlBindParams = RuntimeSqlBindParam[] | null;
1944
+ interface RuntimeActorRuntimeSocketEndpointInfo {
1945
+ path: string;
1946
+ }
1947
+ interface RuntimeSqlQueryResult {
1948
+ columns: string[];
1949
+ rows: unknown[][];
1950
+ }
1951
+ type RuntimeSqlExecResult = RuntimeSqlQueryResult;
1952
+ interface RuntimeSqlExecuteResult extends RuntimeSqlQueryResult {
1953
+ changes: number;
1954
+ lastInsertRowId?: number | null;
1955
+ }
1956
+ interface RuntimeSqlBatchStatement {
1957
+ sql: string;
1958
+ params?: RuntimeSqlBindParams;
1959
+ }
1960
+ interface RuntimeSqlRunResult {
1961
+ changes: number;
1962
+ }
1963
+ interface RuntimeActorConfig {
1964
+ name?: string;
1965
+ icon?: string;
1966
+ hasDatabase?: boolean;
1967
+ remoteSqlite?: boolean;
1968
+ sqliteProfiling?: SqliteProfilingOptions;
1969
+ enableActorRuntimeSocket?: boolean;
1970
+ hasState?: boolean;
1971
+ canHibernateWebsocket?: boolean;
1972
+ stateSaveIntervalMs?: number;
1973
+ createStateTimeoutMs?: number;
1974
+ onCreateTimeoutMs?: number;
1975
+ createVarsTimeoutMs?: number;
1976
+ createConnStateTimeoutMs?: number;
1977
+ onBeforeConnectTimeoutMs?: number;
1978
+ onConnectTimeoutMs?: number;
1979
+ onMigrateTimeoutMs?: number;
1980
+ onWakeTimeoutMs?: number;
1981
+ onBeforeActorStartTimeoutMs?: number;
1982
+ actionTimeoutMs?: number;
1983
+ onRequestTimeoutMs?: number;
1984
+ sleepTimeoutMs?: number;
1985
+ noSleep?: boolean;
1986
+ sleepGracePeriodMs?: number;
1987
+ connectionLivenessTimeoutMs?: number;
1988
+ connectionLivenessIntervalMs?: number;
1989
+ maxQueueSize?: number;
1990
+ maxSchedules?: number;
1991
+ maxQueueMessageSize?: number;
1992
+ maxIncomingMessageSize?: number;
1993
+ maxOutgoingMessageSize?: number;
1994
+ preloadMaxWorkflowBytes?: number;
1995
+ preloadMaxConnectionsBytes?: number;
1996
+ actions?: Array<{
1997
+ name: string;
1998
+ }>;
1999
+ inspectorTabs?: Array<RuntimeInspectorTabEntry>;
2000
+ }
2001
+ interface RuntimeInspectorTabEntry {
2002
+ id: string;
2003
+ /** Required for custom entries; omitted for built-in hides. */
2004
+ label?: string;
2005
+ /**
2006
+ * Required for custom entries — absolute path to the source directory.
2007
+ * Resolved on the TS side before being handed to the runtime.
2008
+ */
2009
+ source?: string;
2010
+ /** Optional icon id for custom entries. */
2011
+ icon?: string;
2012
+ /** Set to true for built-in hide entries. */
2013
+ hidden?: boolean;
2014
+ }
2015
+ interface RuntimeServeConfig {
2016
+ version: number;
2017
+ endpoint: string;
2018
+ token?: string;
2019
+ namespace: string;
2020
+ poolName: string;
2021
+ engineBinaryPath?: string;
2022
+ engineHost?: string;
2023
+ enginePort?: number;
2024
+ handleInspectorHttpInRuntime?: boolean;
2025
+ inspectorTestToken?: string;
2026
+ serverlessBasePath?: string;
2027
+ serverlessPackageVersion: string;
2028
+ serverlessClientEndpoint?: string;
2029
+ serverlessClientNamespace?: string;
2030
+ serverlessClientToken?: string;
2031
+ serverlessValidateEndpoint: boolean;
2032
+ serverlessMaxStartPayloadBytes: number;
2033
+ }
2034
+ interface RuntimeListenerConfig {
2035
+ port: number;
2036
+ host?: string;
2037
+ publicDir?: string;
2038
+ application?: RuntimeApplicationFetch;
2039
+ }
2040
+ interface RuntimeServerlessRequest {
2041
+ method: string;
2042
+ url: string;
2043
+ headers: Record<string, string>;
2044
+ body: RuntimeBytes;
2045
+ }
2046
+ interface RuntimeApplicationResponse {
2047
+ status: number;
2048
+ headers: Record<string, string>;
2049
+ body: RuntimeBytes;
2050
+ }
2051
+ type RuntimeApplicationFetch = (request: RuntimeServerlessRequest) => Promise<RuntimeApplicationResponse>;
2052
+ interface RuntimeApplicationListenerConfig extends RuntimeListenerConfig {
2053
+ application: RuntimeApplicationFetch;
2054
+ }
2055
+ interface RuntimeServerlessResponseHead {
2056
+ status: number;
2057
+ headers: Record<string, string>;
2058
+ }
2059
+ interface RuntimeRegistryRouteResponse {
2060
+ status: number;
2061
+ headers: Record<string, string>;
2062
+ body: RuntimeBytes;
2063
+ }
2064
+ type RuntimeServerlessStreamEvent = {
2065
+ kind: "chunk";
2066
+ chunk?: RuntimeBytes;
2067
+ } | {
2068
+ kind: "end";
2069
+ error?: {
2070
+ group: string;
2071
+ code: string;
2072
+ message: string;
2073
+ };
2074
+ };
2075
+ type RuntimeServerlessStreamCallback = (error: unknown, event?: RuntimeServerlessStreamEvent) => unknown;
2076
+ type RuntimeWebSocketEvent = {
2077
+ kind: "message";
2078
+ data: string | RuntimeBytes;
2079
+ binary: boolean;
2080
+ messageIndex?: number;
2081
+ } | {
2082
+ kind: "close";
2083
+ code: number;
2084
+ reason: string;
2085
+ wasClean: boolean;
2086
+ };
2087
+ interface CoreRuntime {
2088
+ readonly kind: "napi" | "wasm";
2089
+ createRegistry(): RegistryHandle;
2090
+ registerActor(registry: RegistryHandle, name: string, factory: ActorFactoryHandle): void;
2091
+ serveRegistry(registry: RegistryHandle, config: RuntimeServeConfig): Promise<void>;
2092
+ waitRegistryReady(registry: RegistryHandle): Promise<void>;
2093
+ shutdownRegistry(registry: RegistryHandle): Promise<void>;
2094
+ registryActorStopThresholdMs?(registry: RegistryHandle): Promise<number | undefined>;
2095
+ handleServerlessRequest(registry: RegistryHandle, req: RuntimeServerlessRequest, onStreamEvent: RuntimeServerlessStreamCallback, cancelToken: CancellationTokenHandle, config: RuntimeServeConfig): Promise<RuntimeServerlessResponseHead>;
2096
+ serveListener(registry: RegistryHandle, listener: RuntimeListenerConfig, config: RuntimeServeConfig): Promise<void>;
2097
+ serveApplicationListener(registry: RegistryHandle, listener: RuntimeApplicationListenerConfig, config: RuntimeServeConfig): Promise<void>;
2098
+ registryHealth?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
2099
+ registryMetadata?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
2100
+ registryMetrics?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
2101
+ createActorFactory(callbacks: object, config?: RuntimeActorConfig | undefined | null): ActorFactoryHandle;
2102
+ createCancellationToken(): CancellationTokenHandle;
2103
+ cancellationTokenAborted(token: CancellationTokenHandle): boolean;
2104
+ cancelCancellationToken(token: CancellationTokenHandle): void;
2105
+ onCancellationTokenCancelled(token: CancellationTokenHandle, callback: (...args: unknown[]) => unknown): void;
2106
+ actorState(ctx: ActorContextHandle): RuntimeBytes;
2107
+ actorBeginOnStateChange(ctx: ActorContextHandle): void;
2108
+ actorEndOnStateChange(ctx: ActorContextHandle): void;
2109
+ actorSetAlarm(ctx: ActorContextHandle, timestampMs?: number | undefined | null): void;
2110
+ actorRequestSave(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): void;
2111
+ actorRequestSaveAndWait(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): Promise<void>;
2112
+ actorInspectorSnapshot(ctx: ActorContextHandle): RuntimeInspectorSnapshot;
2113
+ actorDecodeInspectorRequest(ctx: ActorContextHandle, bytes: RuntimeBytes, advertisedVersion: number): RuntimeBytes;
2114
+ actorEncodeInspectorResponse(ctx: ActorContextHandle, bytes: RuntimeBytes, targetVersion: number): RuntimeBytes;
2115
+ actorVerifyInspectorAuth(ctx: ActorContextHandle, bearerToken?: string | undefined | null): Promise<void>;
2116
+ actorQueueHibernationRemoval(ctx: ActorContextHandle, connId: string): void;
2117
+ actorTakePendingHibernationChanges(ctx: ActorContextHandle): string[];
2118
+ actorDirtyHibernatableConns(ctx: ActorContextHandle): ConnHandle[];
2119
+ actorSaveState(ctx: ActorContextHandle, payload: RuntimeStateDeltaPayload): Promise<void>;
2120
+ actorSaveStateAndWorkflowBatch(ctx: ActorContextHandle, writes: RuntimeWorkflowKvWrite[]): Promise<void>;
2121
+ actorId(ctx: ActorContextHandle): string;
2122
+ actorName(ctx: ActorContextHandle): string;
2123
+ actorKey(ctx: ActorContextHandle): RuntimeActorKeySegment[];
2124
+ actorRegion(ctx: ActorContextHandle): string;
2125
+ actorSleep(ctx: ActorContextHandle): void;
2126
+ actorDestroy(ctx: ActorContextHandle): void;
2127
+ actorAbortSignal(ctx: ActorContextHandle): AbortSignal;
2128
+ actorConns(ctx: ActorContextHandle): ConnHandle[];
2129
+ actorConnectConn(ctx: ActorContextHandle, params: RuntimeBytes, request?: RuntimeHttpRequest | undefined | null): Promise<ConnHandle>;
2130
+ actorBroadcast(ctx: ActorContextHandle, name: string, args: RuntimeBytes): void;
2131
+ actorWaitUntil(ctx: ActorContextHandle, promise: Promise<unknown>): void;
2132
+ actorWaitForTrackedShutdownWork(ctx: ActorContextHandle): Promise<boolean>;
2133
+ actorWaitForTrackedShutdownWorkUnbounded(ctx: ActorContextHandle): Promise<void>;
2134
+ actorKeepAwake(ctx: ActorContextHandle, promise: Promise<unknown>): void;
2135
+ actorBeginKeepAwake(ctx: ActorContextHandle): number;
2136
+ actorEndKeepAwake(ctx: ActorContextHandle, regionId: number): void;
2137
+ actorRegisterTask(ctx: ActorContextHandle, promise: Promise<unknown>): void;
2138
+ actorRuntimeState(ctx: ActorContextHandle): object;
2139
+ actorClearRuntimeState(ctx: ActorContextHandle): void;
2140
+ actorRestartRunHandler(ctx: ActorContextHandle): void;
2141
+ actorBeginWebsocketCallback(ctx: ActorContextHandle): number;
2142
+ actorEndWebsocketCallback(ctx: ActorContextHandle, regionId: number): void;
2143
+ actorKvGet(ctx: ActorContextHandle, key: RuntimeBytes): Promise<RuntimeBytes | null>;
2144
+ actorKvPut(ctx: ActorContextHandle, key: RuntimeBytes, value: RuntimeBytes): Promise<void>;
2145
+ actorKvDelete(ctx: ActorContextHandle, key: RuntimeBytes): Promise<void>;
2146
+ actorKvDeleteRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes): Promise<void>;
2147
+ actorKvListPrefix(ctx: ActorContextHandle, prefix: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
2148
+ actorKvListRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
2149
+ actorKvBatchGet(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<Array<RuntimeBytes | undefined | null>>;
2150
+ actorKvBatchPut(ctx: ActorContextHandle, entries: RuntimeKvEntry[]): Promise<void>;
2151
+ actorKvBatchDelete(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<void>;
2152
+ actorSqlExec(ctx: ActorContextHandle, sql: string): Promise<RuntimeSqlExecResult>;
2153
+ actorSqlExecute(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
2154
+ actorSqlExecuteBatch(ctx: ActorContextHandle, statements: RuntimeSqlBatchStatement[]): Promise<RuntimeSqlExecuteResult[]>;
2155
+ actorSqlBeginTransaction(ctx: ActorContextHandle, timeoutMs?: number, name?: string): Promise<SqliteTransactionHandle>;
2156
+ actorSqlTransactionExec(transaction: SqliteTransactionHandle, sql: string): Promise<RuntimeSqlExecResult>;
2157
+ actorSqlTransactionExecute(transaction: SqliteTransactionHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
2158
+ actorSqlTransactionCommit(transaction: SqliteTransactionHandle): Promise<void>;
2159
+ actorSqlTransactionRollback(transaction: SqliteTransactionHandle): Promise<void>;
2160
+ actorSqlQuery(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlQueryResult>;
2161
+ actorSqlRun(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlRunResult>;
2162
+ actorSqlMetrics(ctx: ActorContextHandle): SqliteNativeMetrics | null;
2163
+ actorSqlTakeLastKvError(ctx: ActorContextHandle): string | null;
2164
+ actorSqlClose(ctx: ActorContextHandle): Promise<void>;
2165
+ actorRuntimeSocketProvision(ctx: ActorContextHandle): Promise<RuntimeActorRuntimeSocketEndpointInfo>;
2166
+ actorQueueSend(ctx: ActorContextHandle, name: string, body: RuntimeBytes): Promise<RuntimeQueueMessage>;
2167
+ actorQueueNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueNextBatchOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage[]>;
2168
+ actorQueueWaitForNames(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage>;
2169
+ actorQueueWaitForNamesAvailable(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<void>;
2170
+ actorQueueEnqueueAndWait(ctx: ActorContextHandle, name: string, body: RuntimeBytes, options?: RuntimeQueueEnqueueAndWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeBytes | null>;
2171
+ actorQueueTryNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueTryNextBatchOptions | undefined | null): RuntimeQueueMessage[];
2172
+ actorQueueMaxSize(ctx: ActorContextHandle): number;
2173
+ actorQueueInspectMessages(ctx: ActorContextHandle): Promise<RuntimeQueueInspectMessage[]>;
2174
+ actorQueueReset(ctx: ActorContextHandle): Promise<void>;
2175
+ actorScheduleAfter(ctx: ActorContextHandle, durationMs: number, actionName: string, args: RuntimeBytes): Promise<string>;
2176
+ actorScheduleAt(ctx: ActorContextHandle, timestampMs: number, actionName: string, args: RuntimeBytes): Promise<string>;
2177
+ actorScheduleCancel(ctx: ActorContextHandle, id: string): Promise<boolean>;
2178
+ actorScheduleGet(ctx: ActorContextHandle, id: string): Promise<RuntimeScheduledEventInfo | undefined>;
2179
+ actorScheduleList(ctx: ActorContextHandle): Promise<RuntimeScheduledEventInfo[]>;
2180
+ actorCronSet(ctx: ActorContextHandle, name: string, expression: string, timezone: string | undefined, actionName: string, args: RuntimeBytes, maxHistory: number | undefined): Promise<void>;
2181
+ actorCronEvery(ctx: ActorContextHandle, name: string, intervalMs: number, actionName: string, args: RuntimeBytes, maxHistory: number | undefined): Promise<void>;
2182
+ actorCronGet(ctx: ActorContextHandle, name: string): Promise<RuntimeCronJobInfo | undefined>;
2183
+ actorCronList(ctx: ActorContextHandle): Promise<RuntimeCronJobInfo[]>;
2184
+ actorCronDelete(ctx: ActorContextHandle, name: string): Promise<boolean>;
2185
+ actorCronHistory(ctx: ActorContextHandle, name: string, limit: number | undefined): Promise<RuntimeCronFire[]>;
2186
+ connId(conn: ConnHandle): string;
2187
+ connParams(conn: ConnHandle): RuntimeBytes;
2188
+ connState(conn: ConnHandle): RuntimeBytes;
2189
+ connSetState(conn: ConnHandle, state: RuntimeBytes): void;
2190
+ connIsHibernatable(conn: ConnHandle): boolean;
2191
+ connSend(conn: ConnHandle, name: string, args: RuntimeBytes): void;
2192
+ connDisconnect(conn: ConnHandle, reason?: string | undefined | null): Promise<void>;
2193
+ webSocketSend(ws: WebSocketHandle, data: RuntimeBytes, binary: boolean): void;
2194
+ webSocketClose(ws: WebSocketHandle, code?: number | undefined | null, reason?: string | undefined | null): Promise<void>;
2195
+ webSocketSetEventCallback(ws: WebSocketHandle, callback: (event: RuntimeWebSocketEvent) => void): void;
2196
+ }
2197
+
2198
+ declare function buildConfiguredRegistry(config: RegistryConfig): Promise<{
2199
+ runtime: CoreRuntime;
2200
+ registry: RegistryHandle;
2201
+ serveConfig: RuntimeServeConfig;
2202
+ }>;
2203
+
1594
2204
  type FetchHandler = (request: Request, ...args: any) => Response | Promise<Response>;
1595
2205
  interface ServerlessHandler {
1596
2206
  fetch: FetchHandler;
1597
2207
  }
1598
- interface RegistryDiagnostics {
1599
- mode: string;
1600
- envoyActiveActorCount?: number | null;
2208
+ interface RegistryApplication {
2209
+ fetch: FetchHandler;
2210
+ }
2211
+ interface RegistryListenOptions {
2212
+ port?: number;
2213
+ host?: string;
2214
+ publicDir?: string;
2215
+ application?: RegistryApplication;
2216
+ }
2217
+ interface RegistryRoutes {
2218
+ health(): Promise<Response>;
2219
+ metadata(): Promise<Response>;
2220
+ prometheusMetrics(request?: Request): Promise<Response>;
2221
+ }
2222
+ /**
2223
+ * Injectable dependencies for {@link Registry}. Production code uses the
2224
+ * defaults. Tests override `buildConfiguredRegistry` to drive lifecycle
2225
+ * orchestration against a fake `CoreRuntime` without an engine.
2226
+ */
2227
+ interface RegistryDeps {
2228
+ buildConfiguredRegistry: typeof buildConfiguredRegistry;
1601
2229
  }
1602
2230
  declare class Registry<A extends RegistryActors> {
1603
2231
  #private;
2232
+ readonly routes: RegistryRoutes;
1604
2233
  get config(): RegistryConfigInput<A>;
1605
2234
  parseConfig(): RegistryConfig;
1606
- constructor(config: RegistryConfigInput<A>);
2235
+ constructor(config: RegistryConfigInput<A>, deps?: Partial<RegistryDeps>);
1607
2236
  /**
1608
2237
  * Handle an incoming HTTP request for serverless deployments.
1609
2238
  *
@@ -1624,11 +2253,64 @@ declare class Registry<A extends RegistryActors> {
1624
2253
  * ```
1625
2254
  */
1626
2255
  serve(): ServerlessHandler;
1627
- diagnostics(): Promise<RegistryDiagnostics>;
2256
+ /**
2257
+ * Bind an HTTP listener provided by the native (Rust) runtime and serve
2258
+ * the registry's serverless endpoints over it. Resolves only after the
2259
+ * registry is shut down (SIGINT/SIGTERM or `nativeRegistry.shutdown()`).
2260
+ *
2261
+ * @param opts.port Port to listen on. Defaults to `process.env.RIVET_PORT`
2262
+ * if set, otherwise 3000.
2263
+ * @param opts.host Address to bind. Defaults to `0.0.0.0`.
2264
+ * @param opts.publicDir If set, serves static files from this directory
2265
+ * as a fallback below the framework routes.
2266
+ * @param opts.application If set, handles requests that do not match a
2267
+ * framework route.
2268
+ *
2269
+ * @example
2270
+ * ```ts
2271
+ * await registry.listen();
2272
+ * await registry.listen({ application: app });
2273
+ * ```
2274
+ */
2275
+ listen(opts?: RegistryListenOptions): Promise<void>;
2276
+ /**
2277
+ * Gracefully drains all live registries.
2278
+ *
2279
+ * Programmatic counterpart to the SIGINT/SIGTERM handlers: tears down
2280
+ * every live `CoreRegistry` (both `start()` and `handler()` modes) and
2281
+ * waits for the serve promise to resolve, all bounded by the shutdown
2282
+ * grace period. Unlike a signal-driven shutdown, this does not re-raise a
2283
+ * signal or exit the process. The caller owns process lifetime.
2284
+ *
2285
+ * Idempotent: concurrent or repeated calls share a single drain. Safe to
2286
+ * call even if nothing has been started.
2287
+ *
2288
+ * @example
2289
+ * ```ts
2290
+ * const registry = setup({ use: { counter } });
2291
+ * registry.start();
2292
+ * // ...later, on your own shutdown trigger:
2293
+ * await registry.shutdown();
2294
+ * ```
2295
+ */
2296
+ shutdown(): Promise<void>;
1628
2297
  startEnvoy(): void;
2298
+ /**
2299
+ * Starts the serverful registry if needed and waits until its envoy has
2300
+ * registered with the Engine. Repeated and concurrent calls share one
2301
+ * startup lifecycle and readiness promise.
2302
+ *
2303
+ * Unlike {@link start}, this reports startup failures and does not resolve
2304
+ * merely because an HTTP health endpoint is listening.
2305
+ */
2306
+ startAndWait(): Promise<void>;
1629
2307
  /**
1630
2308
  * Starts the actor envoy for standalone server deployments.
1631
2309
  *
2310
+ * Set `RIVETKIT_RUNTIME_MODE=serverless` to instead bind an HTTP listener
2311
+ * via `listen()` (Mode B). Mode A (envoy) and Mode B (listener) are
2312
+ * mutually exclusive per registry instance.
2313
+ *
1632
2314
  * @example
1633
2315
  * ```ts
1634
2316
  * const registry = setup({ use: { counter } });