rivetkit 0.0.0-runner-config-drain-grace-threshold.e1be3d6 → 0.0.0-sqlite-uds.4e59a38

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 (250) hide show
  1. package/dist/browser/client.d.ts +557 -83
  2. package/dist/browser/client.js +1034 -410
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.d.ts +22 -2
  5. package/dist/browser/inspector/client.js +1036 -232
  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 +2218 -2082
  13. package/dist/tsup/agent-os/index.cjs.map +1 -1
  14. package/dist/tsup/agent-os/index.d.cts +555 -82
  15. package/dist/tsup/agent-os/index.d.ts +555 -82
  16. package/dist/tsup/agent-os/index.js +2220 -2084
  17. package/dist/tsup/agent-os/index.js.map +1 -1
  18. package/dist/tsup/{chunk-ZULMYDHF.cjs → chunk-3GC3EP6D.cjs} +18 -10
  19. package/dist/tsup/chunk-3GC3EP6D.cjs.map +1 -0
  20. package/dist/tsup/{chunk-5DM7UBJ6.js → chunk-3GLNEWGY.js} +77 -5
  21. package/dist/tsup/chunk-3GLNEWGY.js.map +1 -0
  22. package/dist/tsup/{chunk-V3QNBJ7N.cjs → chunk-4FC7TVS6.cjs} +35 -10
  23. package/dist/tsup/chunk-4FC7TVS6.cjs.map +1 -0
  24. package/dist/tsup/{chunk-5I23FPCU.cjs → chunk-62LSMTP2.cjs} +3 -3
  25. package/dist/tsup/{chunk-5I23FPCU.cjs.map → chunk-62LSMTP2.cjs.map} +1 -1
  26. package/dist/tsup/{chunk-TCQKPKZN.js → chunk-7IVUT2JT.js} +12 -4
  27. package/dist/tsup/chunk-7IVUT2JT.js.map +1 -0
  28. package/dist/tsup/{chunk-67RKOMDW.cjs → chunk-GEYQLGXC.cjs} +892 -303
  29. package/dist/tsup/chunk-GEYQLGXC.cjs.map +1 -0
  30. package/dist/tsup/{chunk-SRMJW54U.cjs → chunk-GMN45CQ6.cjs} +10 -10
  31. package/dist/tsup/chunk-GMN45CQ6.cjs.map +1 -0
  32. package/dist/tsup/{chunk-3YY5S6TV.js → chunk-HXUEHHJF.js} +2 -2
  33. package/dist/tsup/chunk-HXUEHHJF.js.map +1 -0
  34. package/dist/tsup/{chunk-ZLQ4AEF5.cjs → chunk-I336PMWT.cjs} +44 -9
  35. package/dist/tsup/chunk-I336PMWT.cjs.map +1 -0
  36. package/dist/tsup/{chunk-IWKPKMUZ.js → chunk-IB73AMGJ.js} +42 -7
  37. package/dist/tsup/chunk-IB73AMGJ.js.map +1 -0
  38. package/dist/tsup/{chunk-DPXHJ73A.js → chunk-ITWJ6Y7G.js} +2 -2
  39. package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JZ7TWV65.js} +1 -1
  40. package/dist/tsup/chunk-JZ7TWV65.js.map +1 -0
  41. package/dist/tsup/{chunk-YCTA3LBC.js → chunk-KTNBYGRU.js} +134 -20
  42. package/dist/tsup/chunk-KTNBYGRU.js.map +1 -0
  43. package/dist/tsup/{chunk-BNGG6IEA.cjs → chunk-OAPVVVTX.cjs} +78 -6
  44. package/dist/tsup/chunk-OAPVVVTX.cjs.map +1 -0
  45. package/dist/tsup/{chunk-M56BAR36.cjs → chunk-OUDV3ITX.cjs} +138 -24
  46. package/dist/tsup/chunk-OUDV3ITX.cjs.map +1 -0
  47. package/dist/tsup/{chunk-GL3HIPV4.cjs → chunk-PRXTIERO.cjs} +90 -65
  48. package/dist/tsup/chunk-PRXTIERO.cjs.map +1 -0
  49. package/dist/tsup/{chunk-LD5YASJU.cjs → chunk-VE2X4KMG.cjs} +2 -2
  50. package/dist/tsup/{chunk-LD5YASJU.cjs.map → chunk-VE2X4KMG.cjs.map} +1 -1
  51. package/dist/tsup/{chunk-27VQ5J4Q.js → chunk-WRZEVVLL.js} +6 -6
  52. package/dist/tsup/chunk-WRZEVVLL.js.map +1 -0
  53. package/dist/tsup/{chunk-FYDM3DOZ.js → chunk-XAIMHUPG.js} +745 -156
  54. package/dist/tsup/chunk-XAIMHUPG.js.map +1 -0
  55. package/dist/tsup/{chunk-5Q26DE3S.js → chunk-XZ62SWSC.js} +83 -58
  56. package/dist/tsup/chunk-XZ62SWSC.js.map +1 -0
  57. package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-ZA7FLHKH.cjs} +1 -1
  58. package/dist/tsup/chunk-ZA7FLHKH.cjs.map +1 -0
  59. package/dist/tsup/{chunk-K34B3OVG.js → chunk-ZZ3WBRPD.js} +34 -9
  60. package/dist/tsup/chunk-ZZ3WBRPD.js.map +1 -0
  61. package/dist/tsup/client/mod.cjs +9 -9
  62. package/dist/tsup/client/mod.d.cts +5 -6
  63. package/dist/tsup/client/mod.d.ts +5 -6
  64. package/dist/tsup/client/mod.js +8 -8
  65. package/dist/tsup/common/log.cjs +5 -3
  66. package/dist/tsup/common/log.cjs.map +1 -1
  67. package/dist/tsup/common/log.d.cts +5 -1
  68. package/dist/tsup/common/log.d.ts +5 -1
  69. package/dist/tsup/common/log.js +6 -4
  70. package/dist/tsup/common/websocket.cjs +4 -4
  71. package/dist/tsup/common/websocket.js +3 -3
  72. package/dist/tsup/{config-BA5q_2Kt.d.cts → config-CxG53eQo.d.cts} +576 -33
  73. package/dist/tsup/{config-kxXbtrJU.d.ts → config-DLOxy81E.d.cts} +5 -5
  74. package/dist/tsup/{config-kxXbtrJU.d.cts → config-DLOxy81E.d.ts} +5 -5
  75. package/dist/tsup/{config-B2reim3z.d.ts → config-Ds6DCRhV.d.ts} +576 -33
  76. package/dist/tsup/context-8KlcOYIs.d.cts +129 -0
  77. package/dist/tsup/context-Cfbm4QLr.d.ts +129 -0
  78. package/dist/tsup/db/drizzle.cjs +151 -79
  79. package/dist/tsup/db/drizzle.cjs.map +1 -1
  80. package/dist/tsup/db/drizzle.d.cts +2 -2
  81. package/dist/tsup/db/drizzle.d.ts +2 -2
  82. package/dist/tsup/db/drizzle.js +151 -79
  83. package/dist/tsup/db/drizzle.js.map +1 -1
  84. package/dist/tsup/db/mod.cjs +79 -24
  85. package/dist/tsup/db/mod.cjs.map +1 -1
  86. package/dist/tsup/db/mod.d.cts +2 -2
  87. package/dist/tsup/db/mod.d.ts +2 -2
  88. package/dist/tsup/db/mod.js +78 -23
  89. package/dist/tsup/db/mod.js.map +1 -1
  90. package/dist/tsup/dynamic/mod.cjs +24 -0
  91. package/dist/tsup/dynamic/mod.cjs.map +1 -0
  92. package/dist/tsup/dynamic/mod.d.cts +37 -0
  93. package/dist/tsup/dynamic/mod.d.ts +37 -0
  94. package/dist/tsup/dynamic/mod.js +24 -0
  95. package/dist/tsup/dynamic/mod.js.map +1 -0
  96. package/dist/tsup/inspector/mod.cjs +47 -12
  97. package/dist/tsup/inspector/mod.cjs.map +1 -1
  98. package/dist/tsup/inspector/mod.d.cts +37 -15
  99. package/dist/tsup/inspector/mod.d.ts +37 -15
  100. package/dist/tsup/inspector/mod.js +46 -11
  101. package/dist/tsup/inspector/mod.js.map +1 -1
  102. package/dist/tsup/inspector-tab/mod.cjs +162 -0
  103. package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
  104. package/dist/tsup/inspector-tab/mod.d.cts +240 -0
  105. package/dist/tsup/inspector-tab/mod.d.ts +240 -0
  106. package/dist/tsup/inspector-tab/mod.js +162 -0
  107. package/dist/tsup/inspector-tab/mod.js.map +1 -0
  108. package/dist/tsup/mod.cjs +1076 -494
  109. package/dist/tsup/mod.cjs.map +1 -1
  110. package/dist/tsup/mod.d.cts +5 -6
  111. package/dist/tsup/mod.d.ts +5 -6
  112. package/dist/tsup/mod.js +992 -410
  113. package/dist/tsup/mod.js.map +1 -1
  114. package/dist/tsup/test/mod.cjs +21 -18
  115. package/dist/tsup/test/mod.cjs.map +1 -1
  116. package/dist/tsup/test/mod.d.cts +4 -5
  117. package/dist/tsup/test/mod.d.ts +4 -5
  118. package/dist/tsup/test/mod.js +18 -15
  119. package/dist/tsup/test/mod.js.map +1 -1
  120. package/dist/tsup/utils-CqDnC_PS.d.cts +104 -0
  121. package/dist/tsup/utils-CqDnC_PS.d.ts +104 -0
  122. package/dist/tsup/utils.cjs +3 -3
  123. package/dist/tsup/utils.d.cts +1 -1
  124. package/dist/tsup/utils.d.ts +1 -1
  125. package/dist/tsup/utils.js +2 -2
  126. package/dist/tsup/workflow/mod.cjs +386 -322
  127. package/dist/tsup/workflow/mod.cjs.map +1 -1
  128. package/dist/tsup/workflow/mod.d.cts +8 -9
  129. package/dist/tsup/workflow/mod.d.ts +8 -9
  130. package/dist/tsup/workflow/mod.js +363 -299
  131. package/dist/tsup/workflow/mod.js.map +1 -1
  132. package/package.json +35 -14
  133. package/src/actor/config.ts +186 -57
  134. package/src/actor/contexts/index.ts +7 -2
  135. package/src/actor/definition.ts +17 -19
  136. package/src/actor/driver.ts +3 -3
  137. package/src/actor/errors.ts +70 -7
  138. package/src/actor/instance/mod.ts +26 -35
  139. package/src/actor/keys.ts +1 -1
  140. package/src/actor/mod.ts +22 -20
  141. package/src/actor/schema.ts +2 -2
  142. package/src/agent-os/actor/index.ts +38 -18
  143. package/src/agent-os/actor/preview.ts +1 -2
  144. package/src/agent-os/actor/session.ts +2 -2
  145. package/src/agent-os/config.ts +1 -1
  146. package/src/agent-os/fs/database-vfs.ts +1 -1
  147. package/src/agent-os/index.ts +16 -15
  148. package/src/client/actor-common.ts +87 -54
  149. package/src/client/actor-conn.ts +58 -63
  150. package/src/client/actor-handle.ts +121 -69
  151. package/src/client/actor-query.ts +5 -5
  152. package/src/client/errors.ts +2 -1
  153. package/src/client/lifecycle-errors.ts +2 -4
  154. package/src/client/query.ts +1 -1
  155. package/src/client/queue.ts +8 -3
  156. package/src/client/raw-utils.ts +10 -10
  157. package/src/client/resolve-gateway-target.ts +1 -1
  158. package/src/client/utils.ts +34 -10
  159. package/src/common/actor-router-consts.ts +4 -0
  160. package/src/common/actor-websocket.ts +3 -1
  161. package/src/common/bare/actor-persist/v1.ts +205 -163
  162. package/src/common/bare/actor-persist/v2.ts +265 -213
  163. package/src/common/bare/actor-persist/v3.ts +176 -172
  164. package/src/common/bare/actor-persist/v4.ts +254 -253
  165. package/src/common/bare/generated/client-protocol/v4.ts +599 -0
  166. package/src/common/bare/generated/inspector/v5.ts +1016 -0
  167. package/src/common/bare/transport/v1.ts +694 -542
  168. package/src/common/client-protocol-versioned.ts +176 -67
  169. package/src/common/client-protocol-zod.ts +7 -0
  170. package/src/common/client-protocol.ts +1 -1
  171. package/src/common/database/config.ts +16 -5
  172. package/src/common/database/mod.test.ts +83 -16
  173. package/src/common/database/mod.ts +86 -30
  174. package/src/common/database/native-database.test.ts +35 -22
  175. package/src/common/database/native-database.ts +26 -10
  176. package/src/common/database/shared.ts +1 -0
  177. package/src/common/encoding.ts +250 -16
  178. package/src/common/engine.ts +28 -1
  179. package/src/common/eventsource.ts +1 -1
  180. package/src/common/inline-websocket-adapter.ts +14 -13
  181. package/src/common/log.ts +15 -8
  182. package/src/common/router.ts +49 -23
  183. package/src/common/utils.ts +10 -202
  184. package/src/common/websocket-interface.ts +1 -1
  185. package/src/db/drizzle.ts +173 -96
  186. package/src/db/mod.ts +1 -1
  187. package/src/devtools-loader/index.ts +4 -7
  188. package/src/devtools-loader/serve-devtools.ts +26 -0
  189. package/src/drivers/engine/actor-driver.ts +76 -73
  190. package/src/dynamic/instance.ts +32 -0
  191. package/src/dynamic/internal.ts +50 -0
  192. package/src/dynamic/isolate-runtime.ts +66 -0
  193. package/src/dynamic/mod.ts +32 -0
  194. package/src/engine-client/actor-http-client.ts +3 -3
  195. package/src/engine-client/actor-websocket-client.ts +6 -5
  196. package/src/engine-client/api-endpoints.ts +51 -2
  197. package/src/engine-client/api-utils.ts +2 -2
  198. package/src/engine-client/driver.ts +1 -1
  199. package/src/engine-client/mod.ts +6 -3
  200. package/src/engine-client/ws-proxy.ts +9 -4
  201. package/src/inspector/client.browser.ts +66 -15
  202. package/src/inspector/mod.ts +2 -4
  203. package/src/inspector-tab/mod.ts +300 -0
  204. package/src/registry/config/envoy.ts +1 -2
  205. package/src/registry/config/index.ts +45 -20
  206. package/src/registry/index.ts +364 -87
  207. package/src/registry/napi-runtime.ts +97 -8
  208. package/src/registry/native-validation.ts +10 -12
  209. package/src/registry/native.ts +587 -363
  210. package/src/registry/process-metrics.ts +250 -0
  211. package/src/registry/runtime.ts +85 -6
  212. package/src/registry/wasm-runtime.ts +72 -3
  213. package/src/registry/write-through-proxy.ts +40 -0
  214. package/src/serde.ts +2 -2
  215. package/src/serverless/configure.ts +18 -7
  216. package/src/test/mod.ts +11 -8
  217. package/src/utils/crypto.ts +14 -0
  218. package/src/utils/endpoint-parser.ts +1 -1
  219. package/src/utils/env-vars.ts +37 -0
  220. package/src/utils/router.ts +1 -1
  221. package/src/utils.ts +1 -2
  222. package/src/workflow/context.ts +703 -240
  223. package/src/workflow/driver.ts +23 -12
  224. package/src/workflow/inspector.ts +12 -3
  225. package/src/workflow/mod.ts +37 -23
  226. package/dist/tsup/chunk-27VQ5J4Q.js.map +0 -1
  227. package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
  228. package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
  229. package/dist/tsup/chunk-5DM7UBJ6.js.map +0 -1
  230. package/dist/tsup/chunk-5Q26DE3S.js.map +0 -1
  231. package/dist/tsup/chunk-67RKOMDW.cjs.map +0 -1
  232. package/dist/tsup/chunk-BNGG6IEA.cjs.map +0 -1
  233. package/dist/tsup/chunk-FYDM3DOZ.js.map +0 -1
  234. package/dist/tsup/chunk-GL3HIPV4.cjs.map +0 -1
  235. package/dist/tsup/chunk-IWKPKMUZ.js.map +0 -1
  236. package/dist/tsup/chunk-K34B3OVG.js.map +0 -1
  237. package/dist/tsup/chunk-M56BAR36.cjs.map +0 -1
  238. package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
  239. package/dist/tsup/chunk-SRMJW54U.cjs.map +0 -1
  240. package/dist/tsup/chunk-TCQKPKZN.js.map +0 -1
  241. package/dist/tsup/chunk-V3QNBJ7N.cjs.map +0 -1
  242. package/dist/tsup/chunk-YCTA3LBC.js.map +0 -1
  243. package/dist/tsup/chunk-ZLQ4AEF5.cjs.map +0 -1
  244. package/dist/tsup/chunk-ZULMYDHF.cjs.map +0 -1
  245. package/dist/tsup/context-7374C2do.d.ts +0 -92
  246. package/dist/tsup/context-Vv4C_cT-.d.cts +0 -92
  247. package/dist/tsup/utils-fwx3o3K9.d.cts +0 -18
  248. package/dist/tsup/utils-fwx3o3K9.d.ts +0 -18
  249. package/src/utils/serve.ts +0 -217
  250. /package/dist/tsup/{chunk-DPXHJ73A.js.map → chunk-ITWJ6Y7G.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';
@@ -37,11 +37,10 @@ interface SqliteNativeMetrics {
37
37
  dbSizePages: number;
38
38
  }
39
39
  interface SqliteDatabase {
40
- exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
41
- execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
40
+ exec(sql: string, callback?: (row: unknown[], columns: string[]) => void, lease?: SqliteLeaseOptions): Promise<void>;
41
+ execute(sql: string, params?: SqliteBindings, lease?: SqliteLeaseOptions): Promise<SqliteExecuteResult>;
42
42
  run(sql: string, params?: SqliteBindings): Promise<void>;
43
43
  query(sql: string, params?: SqliteBindings): Promise<SqliteQueryResult>;
44
- writeMode<T>(callback: () => Promise<T>): Promise<T>;
45
44
  nativeMetrics?(): SqliteNativeMetrics | Promise<SqliteNativeMetrics | null> | null;
46
45
  close(): Promise<void>;
47
46
  }
@@ -104,14 +103,15 @@ type DatabaseProvider<DB extends RawAccess> = {
104
103
  /**
105
104
  * Drizzle database client interface (will be extended by drizzle-orm types)
106
105
  */
107
- interface DrizzleDatabaseClient {
108
- }
106
+ type DrizzleDatabaseClient = {};
109
107
  type ExecuteFunction = <TRow extends Record<string, unknown> = Record<string, unknown>>(query: string, ...args: unknown[]) => Promise<TRow[]>;
110
108
  type RawAccess = {
111
109
  /**
112
110
  * Executes a raw SQL query.
113
111
  */
114
112
  execute: ExecuteFunction;
113
+ /** Runs a callback in an isolated native SQLite transaction. */
114
+ transaction: <T>(callback: (tx: RawAccess) => Promise<T> | T) => Promise<T>;
115
115
  /**
116
116
  * Returns native SQLite metrics when the active runtime supports them.
117
117
  */
@@ -183,6 +183,44 @@ type ActorQuery = z.infer<typeof ActorQuerySchema>;
183
183
  */
184
184
  type CreateRequest = z.infer<typeof CreateRequestSchema>;
185
185
 
186
+ type SchemaHookResult = boolean | Promise<boolean>;
187
+ type SchemaHook<TContext = any> = (ctx: TContext) => SchemaHookResult;
188
+ interface EventTypeToken<T, TContext = any> {
189
+ readonly _eventType?: T;
190
+ readonly canSubscribe?: SchemaHook<TContext>;
191
+ readonly schema?: PrimitiveSchema;
192
+ }
193
+ interface QueueTypeToken<TMessage, TComplete = never, TContext = any> {
194
+ readonly _queueMessage?: TMessage;
195
+ readonly _queueComplete?: TComplete;
196
+ readonly canPublish?: SchemaHook<TContext>;
197
+ readonly message?: PrimitiveSchema;
198
+ readonly complete?: PrimitiveSchema;
199
+ }
200
+ type PrimitiveSchema = StandardSchemaV1 | EventTypeToken<unknown, any>;
201
+ interface EventSchemaDefinition<TContext = any> {
202
+ schema: PrimitiveSchema;
203
+ canSubscribe?: SchemaHook<TContext>;
204
+ }
205
+ interface QueueSchemaDefinition<TContext = any> {
206
+ message: PrimitiveSchema;
207
+ complete?: PrimitiveSchema;
208
+ canPublish?: SchemaHook<TContext>;
209
+ }
210
+ type EventSchema<TContext = any> = PrimitiveSchema | EventSchemaDefinition<TContext>;
211
+ type QueueSchema = PrimitiveSchema | QueueSchemaDefinition<any> | QueueTypeToken<unknown, unknown, any>;
212
+ type EventSchemaConfig<TContext = any> = Record<string, EventSchema<TContext>>;
213
+ type QueueSchemaConfig<_TContext = any> = Record<string, QueueSchema>;
214
+ 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;
215
+ type InferSchemaMap<T extends Record<string, unknown>> = {
216
+ [K in keyof T]: InferSchema<T[K]>;
217
+ };
218
+ 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;
219
+ type InferQueueCompleteMap<T extends QueueSchemaConfig> = {
220
+ [K in keyof T]: InferQueueComplete<T[K]>;
221
+ };
222
+ type InferEventArgs<T> = T extends readonly unknown[] ? number extends T["length"] ? [T] : T : [T];
223
+
186
224
  interface DeconstructedError {
187
225
  __type: "ActorError";
188
226
  statusCode: ContentfulStatusCode;
@@ -191,6 +229,7 @@ interface DeconstructedError {
191
229
  code: string;
192
230
  message: string;
193
231
  metadata?: unknown;
232
+ actor?: ActorSpecifier;
194
233
  }
195
234
 
196
235
  interface RivetErrorOptions extends ErrorOptions {
@@ -200,6 +239,14 @@ interface RivetErrorOptions extends ErrorOptions {
200
239
  metadata?: unknown;
201
240
  /** Explicit HTTP status override for router responses. */
202
241
  statusCode?: number;
242
+ /** Actor context associated with this error. */
243
+ actor?: ActorSpecifier;
244
+ }
245
+ /** Identifies the actor that was handling work when an error was produced. */
246
+ interface ActorSpecifier {
247
+ actorId: string;
248
+ generation: number;
249
+ key?: string;
203
250
  }
204
251
  interface UserErrorOptions extends ErrorOptions {
205
252
  /**
@@ -218,6 +265,7 @@ declare class RivetError extends Error {
218
265
  public: boolean;
219
266
  metadata?: unknown;
220
267
  statusCode: number;
268
+ actor?: ActorSpecifier;
221
269
  readonly group: string;
222
270
  readonly code: string;
223
271
  static isRivetError(error: unknown): error is RivetError | DeconstructedError;
@@ -230,44 +278,6 @@ declare class UserError extends RivetError {
230
278
  constructor(message: string, options?: UserErrorOptions);
231
279
  }
232
280
 
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
281
  type UpgradeWebSocket = (createEvents: (c: Context) => any) => Handler;
272
282
  type GetUpgradeWebSocket = () => UpgradeWebSocket;
273
283
 
@@ -375,6 +385,12 @@ interface QueueSendResult<TResponse = unknown> {
375
385
  * @returns {Promise<Response>}
376
386
  */
377
387
  type ActorActionFunction<Args extends Array<unknown> = unknown[], Response = unknown> = (...args: Args extends [unknown, ...infer Rest] ? Rest : Args) => Promise<Response>;
388
+ type IsAny<T> = 0 extends 1 & T ? true : false;
389
+ type LooseEventSubscribe = (eventName: string, callback: (...args: any[]) => void) => () => void;
390
+ type ActorActionMap<R> = {
391
+ [K in keyof NonNullable<R>]: NonNullable<R>[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Awaited<Return>> : never;
392
+ };
393
+ type ActionsOf<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<any, any, any, any, any, any, any, any, infer R> ? R : never;
378
394
  interface ActorGatewayOptions {
379
395
  skipReadyWait?: boolean;
380
396
  }
@@ -387,9 +403,7 @@ type ActorWebSocketOptions = ActorGatewayOptions;
387
403
  /**
388
404
  * Maps action methods from actor definition to typed function signatures.
389
405
  */
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;
406
+ type ActorDefinitionActions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? Record<string, ActorActionFunction<any[], any>> : ActorActionMap<ActionsOf<AD>>;
393
407
  type ActorQueueSend<TQueues extends QueueSchemaConfig> = {
394
408
  <K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options: QueueSendWaitOptions): Promise<QueueSendResult<InferQueueCompleteMap<TQueues>[K]>>;
395
409
  <K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options?: QueueSendNoWaitOptions): Promise<void>;
@@ -400,13 +414,31 @@ type ActorEventSubscribe<TEvents extends EventSchemaConfig> = {
400
414
  <K extends keyof TEvents & string>(eventName: K, callback: (...args: InferEventArgs<InferSchemaMap<TEvents>[K]>) => void): () => void;
401
415
  (eventName: keyof TEvents extends never ? string : never, callback: (...args: any[]) => void): () => void;
402
416
  };
403
- type ActorDefinitionQueueSend<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<any, any, any, any, any, any, any, infer Q, any> ? Q extends QueueSchemaConfig ? {
417
+ type ActorDefinitionQueueSend<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
418
+ send: ActorQueueSend<Record<string, any>>;
419
+ } : AD extends {
420
+ config: {
421
+ queues?: infer Q;
422
+ };
423
+ } ? Q extends QueueSchemaConfig ? {
404
424
  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 ? {
425
+ } : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, any, infer Q, any> ? Q extends QueueSchemaConfig ? {
426
+ send: ActorQueueSend<Q>;
427
+ } : {} : {};
428
+ type ActorDefinitionEventSubscriptions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
429
+ on: LooseEventSubscribe;
430
+ once: LooseEventSubscribe;
431
+ } : AD extends {
432
+ config: {
433
+ events?: infer E;
434
+ };
435
+ } ? E extends EventSchemaConfig ? {
407
436
  on: ActorEventSubscribe<E>;
408
437
  once: ActorEventSubscribe<E>;
409
- } : never : never;
438
+ } : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, infer E, any, any> ? E extends EventSchemaConfig ? {
439
+ on: ActorEventSubscribe<E>;
440
+ once: ActorEventSubscribe<E>;
441
+ } : {} : {};
410
442
 
411
443
  declare class ActorClientError extends Error {
412
444
  }
@@ -920,6 +952,7 @@ type Client<A extends Registry<any>> = ClientRaw & {
920
952
  };
921
953
 
922
954
  declare const ACTOR_CONTEXT_INTERNAL_SYMBOL: unique symbol;
955
+ declare const RAW_STATE_SYMBOL: unique symbol;
923
956
  interface ActorLogger {
924
957
  level: any;
925
958
  fatal: any;
@@ -952,6 +985,10 @@ type ActorKvListOptions<T extends ActorKvValueType = "text", K extends ActorKvKe
952
985
  limit?: number;
953
986
  };
954
987
  type ActorClientFor<T> = T extends Registry<any> ? Client<T> : T;
988
+ /**
989
+ * @deprecated Actor KV is deprecated. Use embedded SQLite (`c.db` / `c.sql`)
990
+ * or actor state instead.
991
+ */
955
992
  interface ActorKv {
956
993
  get<T extends ActorKvValueType = "text">(key: Uint8Array | string, options?: ActorKvValueOptions<T>): Promise<ActorKvValueTypeMap[T] | null>;
957
994
  put<T extends ActorKvValueType = "text">(key: Uint8Array | string, value: Uint8Array | string | ArrayBuffer, options?: ActorKvValueOptions<T>): Promise<void>;
@@ -1028,7 +1065,7 @@ interface ActorQueue<TQueues extends QueueSchemaConfig = Record<never, never>> {
1028
1065
  iter<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueIterOptions<TName, TCompletable>): AsyncIterable<any>;
1029
1066
  [key: string]: any;
1030
1067
  }
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>> {
1068
+ 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
1069
  id: string;
1033
1070
  params: TConnParams;
1034
1071
  state: TConnState;
@@ -1039,8 +1076,14 @@ interface Conn<TState = unknown, TConnParams = unknown, TConnState = unknown, TV
1039
1076
  }
1040
1077
  interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
1041
1078
  [ACTOR_CONTEXT_INTERNAL_SYMBOL]?: unknown;
1079
+ /** Returns the raw unwrapped state without the write-through proxy. */
1080
+ [RAW_STATE_SYMBOL](): TState;
1042
1081
  state: TState;
1043
1082
  vars: TVars;
1083
+ /**
1084
+ * @deprecated Actor KV is deprecated. Use embedded SQLite (`db` / `sql`)
1085
+ * or actor state instead.
1086
+ */
1044
1087
  readonly kv: ActorKv;
1045
1088
  readonly db: InferDatabaseClient<TDatabase>;
1046
1089
  readonly schedule: ActorSchedule;
@@ -1049,6 +1092,11 @@ interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase
1049
1092
  readonly name: string;
1050
1093
  readonly key: string[];
1051
1094
  readonly region: string;
1095
+ /** Provisions credentials for the experimental local actor Unix socket API. */
1096
+ actorUds(): Promise<{
1097
+ path: string;
1098
+ token: string;
1099
+ }>;
1052
1100
  readonly conns: Map<string, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>;
1053
1101
  readonly log: ActorLogger;
1054
1102
  readonly abortSignal: AbortSignal;
@@ -1165,8 +1213,27 @@ declare const ActorConfigSchema: z.ZodObject<{
1165
1213
  preloadMaxWorkflowBytes: z.ZodOptional<z.ZodNumber>;
1166
1214
  preloadMaxConnectionsBytes: z.ZodOptional<z.ZodNumber>;
1167
1215
  }, z.core.$strict>>;
1216
+ inspector: z.ZodOptional<z.ZodObject<{
1217
+ tabs: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
1218
+ id: z.ZodString;
1219
+ label: z.ZodString;
1220
+ source: z.ZodString;
1221
+ icon: z.ZodOptional<z.ZodString>;
1222
+ hidden: z.ZodOptional<z.ZodLiteral<false>>;
1223
+ }, z.core.$strict>, z.ZodObject<{
1224
+ id: z.ZodEnum<{
1225
+ state: "state";
1226
+ workflow: "workflow";
1227
+ database: "database";
1228
+ queue: "queue";
1229
+ connections: "connections";
1230
+ console: "console";
1231
+ }>;
1232
+ hidden: z.ZodLiteral<true>;
1233
+ }, z.core.$strict>]>>>;
1234
+ }, z.core.$strict>>;
1168
1235
  }, z.core.$strict>;
1169
- type CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
1236
+ type CreateState<TState, _TConnParams, _TConnState, _TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
1170
1237
  state: TState;
1171
1238
  } | {
1172
1239
  createState: (c: CreateContext<TState, TInput, TDatabase, TEvents, TQueues>, input: TInput) => TState | Promise<TState>;
@@ -1179,7 +1246,7 @@ type CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase e
1179
1246
  /**
1180
1247
  * @experimental
1181
1248
  */
1182
- type CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
1249
+ type CreateVars<TState, _TConnParams, _TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
1183
1250
  /**
1184
1251
  * @experimental
1185
1252
  */
@@ -1276,10 +1343,11 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
1276
1343
  * Called before a client connects to the actor.
1277
1344
  *
1278
1345
  * Use this hook to determine if a connection should be accepted
1279
- * and to initialize connection-specific state.
1346
+ * and to validate client-provided parameters. The pending connection
1347
+ * is not visible in `c.conns` while this hook runs.
1280
1348
  *
1281
1349
  * @param opts Connection parameters including client-provided data
1282
- * @returns The initial connection state or a Promise that resolves to it
1350
+ * @returns Void or a Promise.
1283
1351
  * @throws Throw an error to reject the connection
1284
1352
  */
1285
1353
  onBeforeConnect?: (c: BeforeConnectContext<TState, TVars, TInput, TDatabase, TEvents, TQueues>, params: TConnParams) => void | Promise<void>;
@@ -1287,7 +1355,8 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
1287
1355
  * Called when a client successfully connects to the actor.
1288
1356
  *
1289
1357
  * Use this hook to perform actions when a connection is established,
1290
- * such as sending initial data or updating the actor's state.
1358
+ * such as sending initial data or updating the actor's state. The
1359
+ * connection is visible in `c.conns` before this hook runs.
1291
1360
  *
1292
1361
  * @param conn The connection object
1293
1362
  * @returns Void or a Promise that resolves when connection handling is complete
@@ -1363,19 +1432,21 @@ type ActorDatabaseConfig<TDatabase extends AnyDatabaseProvider> = {
1363
1432
  */
1364
1433
  db: TDatabase;
1365
1434
  } | 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>;
1435
+ 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
1436
 
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>;
1437
+ 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>> {
1438
+ readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q, _R>;
1439
+ }
1440
+ interface AnyActorDefinition {
1441
+ readonly config: any;
1370
1442
  }
1371
- type AnyActorDefinition = BaseActorDefinition<any, any, any, any, any, any, any, any, any>;
1372
1443
  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
1444
  #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>;
1445
+ constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q, R>);
1446
+ get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q, R>;
1376
1447
  }
1377
1448
 
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>>>;
1449
+ declare const ActorsSchema: z$2.ZodRecord<z$2.ZodString, z$2.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
1379
1450
  type RegistryActors = z$2.infer<typeof ActorsSchema>;
1380
1451
  declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1381
1452
  use: z$2.ZodRecord<z$2.ZodString, z$2.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
@@ -1388,6 +1459,7 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1388
1459
  }, z$2.core.$strip>>>;
1389
1460
  maxIncomingMessageSize: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
1390
1461
  maxOutgoingMessageSize: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
1462
+ experimentalActorUds: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodBoolean>>;
1391
1463
  runtime: z$2.ZodPipe<z$2.ZodOptional<z$2.ZodEnum<{
1392
1464
  auto: "auto";
1393
1465
  native: "native";
@@ -1395,11 +1467,7 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1395
1467
  }>>, z$2.ZodTransform<"auto" | "native" | "wasm", "auto" | "native" | "wasm" | undefined>>;
1396
1468
  wasm: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodObject<{
1397
1469
  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>>;
1470
+ 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
1471
  }, z$2.core.$strip>>>;
1404
1472
  sqlite: z$2.ZodPipe<z$2.ZodOptional<z$2.ZodUnion<readonly [z$2.ZodEnum<{
1405
1473
  local: "local";
@@ -1436,6 +1504,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1436
1504
  httpPort: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
1437
1505
  httpHost: z$2.ZodOptional<z$2.ZodString>;
1438
1506
  startEngine: z$2.ZodDefault<z$2.ZodBoolean>;
1507
+ engineHost: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodString>>;
1508
+ enginePort: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
1439
1509
  engineVersion: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodString>>;
1440
1510
  configurePool: z$2.ZodOptional<z$2.ZodOptional<z$2.ZodObject<{
1441
1511
  name: z$2.ZodOptional<z$2.ZodString>;
@@ -1460,7 +1530,7 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1460
1530
  envoyKey: z$2.ZodOptional<z$2.ZodString>;
1461
1531
  }, z$2.core.$strip>>>;
1462
1532
  shutdown: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodObject<{
1463
- gracePeriodMs: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
1533
+ gracePeriodMs: z$2.ZodOptional<z$2.ZodNumber>;
1464
1534
  disableSignalHandlers: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodBoolean>>;
1465
1535
  }, z$2.core.$strip>>>;
1466
1536
  }, z$2.core.$strip>, z$2.ZodTransform<{
@@ -1487,12 +1557,11 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1487
1557
  };
1488
1558
  maxIncomingMessageSize: number;
1489
1559
  maxOutgoingMessageSize: number;
1560
+ experimentalActorUds: boolean;
1490
1561
  runtime: "auto" | "native" | "wasm";
1491
1562
  wasm: {
1492
1563
  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;
1564
+ initInput?: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined;
1496
1565
  };
1497
1566
  noWelcome: boolean;
1498
1567
  logging: {
@@ -1503,6 +1572,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1503
1572
  httpBasePath: string;
1504
1573
  httpPort: number;
1505
1574
  startEngine: boolean;
1575
+ engineHost: string;
1576
+ enginePort: number;
1506
1577
  engineVersion: string;
1507
1578
  envoy: {
1508
1579
  poolName: string;
@@ -1511,8 +1582,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1511
1582
  envoyKey?: string | undefined;
1512
1583
  };
1513
1584
  shutdown: {
1514
- gracePeriodMs: number;
1515
1585
  disableSignalHandlers: boolean;
1586
+ gracePeriodMs?: number | undefined;
1516
1587
  };
1517
1588
  staticDir?: string | undefined;
1518
1589
  httpHost?: string | undefined;
@@ -1534,12 +1605,11 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1534
1605
  };
1535
1606
  maxIncomingMessageSize: number;
1536
1607
  maxOutgoingMessageSize: number;
1608
+ experimentalActorUds: boolean;
1537
1609
  runtime: "auto" | "native" | "wasm";
1538
1610
  wasm: {
1539
1611
  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;
1612
+ initInput?: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined;
1543
1613
  };
1544
1614
  sqlite: {
1545
1615
  backend: "local" | "remote";
@@ -1556,6 +1626,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1556
1626
  httpBasePath: string;
1557
1627
  httpPort: number;
1558
1628
  startEngine: boolean;
1629
+ engineHost: string;
1630
+ enginePort: number;
1559
1631
  engineVersion: string;
1560
1632
  serverless: {
1561
1633
  basePath: string;
@@ -1570,8 +1642,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1570
1642
  envoyKey?: string | undefined;
1571
1643
  };
1572
1644
  shutdown: {
1573
- gracePeriodMs: number;
1574
1645
  disableSignalHandlers: boolean;
1646
+ gracePeriodMs?: number | undefined;
1575
1647
  };
1576
1648
  staticDir?: string | undefined;
1577
1649
  httpHost?: string | undefined;
@@ -1591,19 +1663,375 @@ type RegistryConfigInput<A extends RegistryActors> = Omit<z$2.input<typeof Regis
1591
1663
  use: A;
1592
1664
  };
1593
1665
 
1666
+ declare const handleBrand: unique symbol;
1667
+ type OpaqueHandle<Name extends string> = {
1668
+ readonly [handleBrand]: Name;
1669
+ };
1670
+ type RegistryHandle = OpaqueHandle<"registry">;
1671
+ type ActorFactoryHandle = OpaqueHandle<"actorFactory">;
1672
+ type ActorContextHandle = OpaqueHandle<"actorContext">;
1673
+ type ConnHandle = OpaqueHandle<"conn">;
1674
+ type WebSocketHandle = OpaqueHandle<"webSocket">;
1675
+ type CancellationTokenHandle = OpaqueHandle<"cancellationToken">;
1676
+ type RuntimeBytes = Uint8Array;
1677
+ interface RuntimeActorKeySegment {
1678
+ kind: string;
1679
+ stringValue?: string;
1680
+ numberValue?: number;
1681
+ }
1682
+ interface RuntimeHttpRequest {
1683
+ method: string;
1684
+ uri: string;
1685
+ headers?: Record<string, string>;
1686
+ body?: RuntimeBytes;
1687
+ }
1688
+ interface RuntimeStateDeltaPayload {
1689
+ state?: RuntimeBytes;
1690
+ connHibernation: Array<{
1691
+ connId: string;
1692
+ bytes: RuntimeBytes;
1693
+ }>;
1694
+ connHibernationRemoved: string[];
1695
+ }
1696
+ interface RuntimeRequestSaveOpts {
1697
+ immediate?: boolean;
1698
+ maxWaitMs?: number;
1699
+ }
1700
+ interface RuntimeInspectorSnapshot {
1701
+ stateRevision: number;
1702
+ connectionsRevision: number;
1703
+ queueRevision: number;
1704
+ activeConnections: number;
1705
+ queueSize: number;
1706
+ connectedClients: number;
1707
+ }
1708
+ interface RuntimeQueueMessage {
1709
+ id(): bigint;
1710
+ name(): string;
1711
+ body(): RuntimeBytes;
1712
+ createdAt(): number;
1713
+ isCompletable(): boolean;
1714
+ complete(response?: RuntimeBytes | undefined | null): Promise<void>;
1715
+ }
1716
+ interface RuntimeQueueInspectMessage {
1717
+ id: number;
1718
+ name: string;
1719
+ createdAtMs: number;
1720
+ }
1721
+ interface RuntimeQueueNextBatchOptions {
1722
+ names?: string[];
1723
+ count?: number;
1724
+ timeoutMs?: number;
1725
+ completable?: boolean;
1726
+ }
1727
+ interface RuntimeQueueWaitOptions {
1728
+ timeoutMs?: number;
1729
+ completable?: boolean;
1730
+ }
1731
+ interface RuntimeQueueEnqueueAndWaitOptions {
1732
+ timeoutMs?: number;
1733
+ }
1734
+ interface RuntimeQueueTryNextBatchOptions {
1735
+ names?: string[];
1736
+ count?: number;
1737
+ completable?: boolean;
1738
+ }
1739
+ interface RuntimeKvListOptions {
1740
+ reverse?: boolean;
1741
+ limit?: number;
1742
+ }
1743
+ interface RuntimeKvEntry {
1744
+ key: RuntimeBytes;
1745
+ value: RuntimeBytes;
1746
+ }
1747
+ type RuntimeSqlBindNoValues = {
1748
+ intValue?: never;
1749
+ floatValue?: never;
1750
+ textValue?: never;
1751
+ blobValue?: never;
1752
+ };
1753
+ type RuntimeSqlBindParam = ({
1754
+ kind: "null";
1755
+ } & RuntimeSqlBindNoValues) | {
1756
+ kind: "int";
1757
+ intValue: number;
1758
+ floatValue?: never;
1759
+ textValue?: never;
1760
+ blobValue?: never;
1761
+ } | {
1762
+ kind: "float";
1763
+ intValue?: never;
1764
+ floatValue: number;
1765
+ textValue?: never;
1766
+ blobValue?: never;
1767
+ } | {
1768
+ kind: "text";
1769
+ intValue?: never;
1770
+ floatValue?: never;
1771
+ textValue: string;
1772
+ blobValue?: never;
1773
+ } | {
1774
+ kind: "blob";
1775
+ intValue?: never;
1776
+ floatValue?: never;
1777
+ textValue?: never;
1778
+ blobValue: RuntimeBytes;
1779
+ };
1780
+ type RuntimeSqlBindParams = RuntimeSqlBindParam[] | null;
1781
+ interface RuntimeSqlLeaseOptions {
1782
+ key: string;
1783
+ timeoutMs?: number;
1784
+ }
1785
+ interface RuntimeActorUdsEndpointInfo {
1786
+ path: string;
1787
+ token: string;
1788
+ }
1789
+ interface RuntimeSqlQueryResult {
1790
+ columns: string[];
1791
+ rows: unknown[][];
1792
+ }
1793
+ type RuntimeSqlExecResult = RuntimeSqlQueryResult;
1794
+ interface RuntimeSqlExecuteResult extends RuntimeSqlQueryResult {
1795
+ changes: number;
1796
+ lastInsertRowId?: number | null;
1797
+ }
1798
+ interface RuntimeSqlRunResult {
1799
+ changes: number;
1800
+ }
1801
+ interface RuntimeActorConfig {
1802
+ name?: string;
1803
+ icon?: string;
1804
+ hasDatabase?: boolean;
1805
+ remoteSqlite?: boolean;
1806
+ experimentalActorUds?: boolean;
1807
+ hasState?: boolean;
1808
+ canHibernateWebsocket?: boolean;
1809
+ stateSaveIntervalMs?: number;
1810
+ createStateTimeoutMs?: number;
1811
+ onCreateTimeoutMs?: number;
1812
+ createVarsTimeoutMs?: number;
1813
+ createConnStateTimeoutMs?: number;
1814
+ onBeforeConnectTimeoutMs?: number;
1815
+ onConnectTimeoutMs?: number;
1816
+ onMigrateTimeoutMs?: number;
1817
+ onWakeTimeoutMs?: number;
1818
+ onBeforeActorStartTimeoutMs?: number;
1819
+ actionTimeoutMs?: number;
1820
+ onRequestTimeoutMs?: number;
1821
+ sleepTimeoutMs?: number;
1822
+ noSleep?: boolean;
1823
+ sleepGracePeriodMs?: number;
1824
+ connectionLivenessTimeoutMs?: number;
1825
+ connectionLivenessIntervalMs?: number;
1826
+ maxQueueSize?: number;
1827
+ maxQueueMessageSize?: number;
1828
+ maxIncomingMessageSize?: number;
1829
+ maxOutgoingMessageSize?: number;
1830
+ preloadMaxWorkflowBytes?: number;
1831
+ preloadMaxConnectionsBytes?: number;
1832
+ actions?: Array<{
1833
+ name: string;
1834
+ }>;
1835
+ inspectorTabs?: Array<RuntimeInspectorTabEntry>;
1836
+ }
1837
+ interface RuntimeInspectorTabEntry {
1838
+ id: string;
1839
+ /** Required for custom entries; omitted for built-in hides. */
1840
+ label?: string;
1841
+ /**
1842
+ * Required for custom entries — absolute path to the source directory.
1843
+ * Resolved on the TS side before being handed to the runtime.
1844
+ */
1845
+ source?: string;
1846
+ /** Optional icon id for custom entries. */
1847
+ icon?: string;
1848
+ /** Set to true for built-in hide entries. */
1849
+ hidden?: boolean;
1850
+ }
1851
+ interface RuntimeServeConfig {
1852
+ version: number;
1853
+ endpoint: string;
1854
+ token?: string;
1855
+ namespace: string;
1856
+ poolName: string;
1857
+ engineBinaryPath?: string;
1858
+ engineHost?: string;
1859
+ enginePort?: number;
1860
+ handleInspectorHttpInRuntime?: boolean;
1861
+ inspectorTestToken?: string;
1862
+ serverlessBasePath?: string;
1863
+ serverlessPackageVersion: string;
1864
+ serverlessClientEndpoint?: string;
1865
+ serverlessClientNamespace?: string;
1866
+ serverlessClientToken?: string;
1867
+ serverlessValidateEndpoint: boolean;
1868
+ serverlessMaxStartPayloadBytes: number;
1869
+ }
1870
+ interface RuntimeListenerConfig {
1871
+ port: number;
1872
+ host?: string;
1873
+ publicDir?: string;
1874
+ }
1875
+ interface RuntimeServerlessRequest {
1876
+ method: string;
1877
+ url: string;
1878
+ headers: Record<string, string>;
1879
+ body: RuntimeBytes;
1880
+ }
1881
+ interface RuntimeServerlessResponseHead {
1882
+ status: number;
1883
+ headers: Record<string, string>;
1884
+ }
1885
+ interface RuntimeRegistryRouteResponse {
1886
+ status: number;
1887
+ headers: Record<string, string>;
1888
+ body: RuntimeBytes;
1889
+ }
1890
+ type RuntimeServerlessStreamEvent = {
1891
+ kind: "chunk";
1892
+ chunk?: RuntimeBytes;
1893
+ } | {
1894
+ kind: "end";
1895
+ error?: {
1896
+ group: string;
1897
+ code: string;
1898
+ message: string;
1899
+ };
1900
+ };
1901
+ type RuntimeServerlessStreamCallback = (error: unknown, event?: RuntimeServerlessStreamEvent) => unknown;
1902
+ type RuntimeWebSocketEvent = {
1903
+ kind: "message";
1904
+ data: string | RuntimeBytes;
1905
+ binary: boolean;
1906
+ messageIndex?: number;
1907
+ } | {
1908
+ kind: "close";
1909
+ code: number;
1910
+ reason: string;
1911
+ wasClean: boolean;
1912
+ };
1913
+ interface CoreRuntime {
1914
+ readonly kind: "napi" | "wasm";
1915
+ createRegistry(): RegistryHandle;
1916
+ registerActor(registry: RegistryHandle, name: string, factory: ActorFactoryHandle): void;
1917
+ serveRegistry(registry: RegistryHandle, config: RuntimeServeConfig): Promise<void>;
1918
+ shutdownRegistry(registry: RegistryHandle): Promise<void>;
1919
+ registryActorStopThresholdMs?(registry: RegistryHandle): Promise<number | undefined>;
1920
+ handleServerlessRequest(registry: RegistryHandle, req: RuntimeServerlessRequest, onStreamEvent: RuntimeServerlessStreamCallback, cancelToken: CancellationTokenHandle, config: RuntimeServeConfig): Promise<RuntimeServerlessResponseHead>;
1921
+ serveListener(registry: RegistryHandle, listener: RuntimeListenerConfig, config: RuntimeServeConfig): Promise<void>;
1922
+ registryHealth?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
1923
+ registryMetadata?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
1924
+ registryMetrics?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
1925
+ createActorFactory(callbacks: object, config?: RuntimeActorConfig | undefined | null): ActorFactoryHandle;
1926
+ createCancellationToken(): CancellationTokenHandle;
1927
+ cancellationTokenAborted(token: CancellationTokenHandle): boolean;
1928
+ cancelCancellationToken(token: CancellationTokenHandle): void;
1929
+ onCancellationTokenCancelled(token: CancellationTokenHandle, callback: (...args: unknown[]) => unknown): void;
1930
+ actorState(ctx: ActorContextHandle): RuntimeBytes;
1931
+ actorBeginOnStateChange(ctx: ActorContextHandle): void;
1932
+ actorEndOnStateChange(ctx: ActorContextHandle): void;
1933
+ actorSetAlarm(ctx: ActorContextHandle, timestampMs?: number | undefined | null): void;
1934
+ actorRequestSave(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): void;
1935
+ actorRequestSaveAndWait(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): Promise<void>;
1936
+ actorInspectorSnapshot(ctx: ActorContextHandle): RuntimeInspectorSnapshot;
1937
+ actorDecodeInspectorRequest(ctx: ActorContextHandle, bytes: RuntimeBytes, advertisedVersion: number): RuntimeBytes;
1938
+ actorEncodeInspectorResponse(ctx: ActorContextHandle, bytes: RuntimeBytes, targetVersion: number): RuntimeBytes;
1939
+ actorVerifyInspectorAuth(ctx: ActorContextHandle, bearerToken?: string | undefined | null): Promise<void>;
1940
+ actorQueueHibernationRemoval(ctx: ActorContextHandle, connId: string): void;
1941
+ actorTakePendingHibernationChanges(ctx: ActorContextHandle): string[];
1942
+ actorDirtyHibernatableConns(ctx: ActorContextHandle): ConnHandle[];
1943
+ actorSaveState(ctx: ActorContextHandle, payload: RuntimeStateDeltaPayload): Promise<void>;
1944
+ actorId(ctx: ActorContextHandle): string;
1945
+ actorName(ctx: ActorContextHandle): string;
1946
+ actorKey(ctx: ActorContextHandle): RuntimeActorKeySegment[];
1947
+ actorRegion(ctx: ActorContextHandle): string;
1948
+ actorSleep(ctx: ActorContextHandle): void;
1949
+ actorDestroy(ctx: ActorContextHandle): void;
1950
+ actorAbortSignal(ctx: ActorContextHandle): AbortSignal;
1951
+ actorConns(ctx: ActorContextHandle): ConnHandle[];
1952
+ actorConnectConn(ctx: ActorContextHandle, params: RuntimeBytes, request?: RuntimeHttpRequest | undefined | null): Promise<ConnHandle>;
1953
+ actorBroadcast(ctx: ActorContextHandle, name: string, args: RuntimeBytes): void;
1954
+ actorWaitUntil(ctx: ActorContextHandle, promise: Promise<unknown>): void;
1955
+ actorWaitForTrackedShutdownWork(ctx: ActorContextHandle): Promise<boolean>;
1956
+ actorWaitForTrackedShutdownWorkUnbounded(ctx: ActorContextHandle): Promise<void>;
1957
+ actorKeepAwake(ctx: ActorContextHandle, promise: Promise<unknown>): void;
1958
+ actorBeginKeepAwake(ctx: ActorContextHandle): number;
1959
+ actorEndKeepAwake(ctx: ActorContextHandle, regionId: number): void;
1960
+ actorRegisterTask(ctx: ActorContextHandle, promise: Promise<unknown>): void;
1961
+ actorRuntimeState(ctx: ActorContextHandle): object;
1962
+ actorClearRuntimeState(ctx: ActorContextHandle): void;
1963
+ actorRestartRunHandler(ctx: ActorContextHandle): void;
1964
+ actorBeginWebsocketCallback(ctx: ActorContextHandle): number;
1965
+ actorEndWebsocketCallback(ctx: ActorContextHandle, regionId: number): void;
1966
+ actorKvGet(ctx: ActorContextHandle, key: RuntimeBytes): Promise<RuntimeBytes | null>;
1967
+ actorKvPut(ctx: ActorContextHandle, key: RuntimeBytes, value: RuntimeBytes): Promise<void>;
1968
+ actorKvDelete(ctx: ActorContextHandle, key: RuntimeBytes): Promise<void>;
1969
+ actorKvDeleteRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes): Promise<void>;
1970
+ actorKvListPrefix(ctx: ActorContextHandle, prefix: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
1971
+ actorKvListRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
1972
+ actorKvBatchGet(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<Array<RuntimeBytes | undefined | null>>;
1973
+ actorKvBatchPut(ctx: ActorContextHandle, entries: RuntimeKvEntry[]): Promise<void>;
1974
+ actorKvBatchDelete(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<void>;
1975
+ actorSqlExec(ctx: ActorContextHandle, sql: string, lease?: RuntimeSqlLeaseOptions): Promise<RuntimeSqlExecResult>;
1976
+ actorSqlExecute(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams, lease?: RuntimeSqlLeaseOptions): Promise<RuntimeSqlExecuteResult>;
1977
+ actorSqlQuery(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlQueryResult>;
1978
+ actorSqlRun(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlRunResult>;
1979
+ actorSqlMetrics(ctx: ActorContextHandle): SqliteNativeMetrics | null;
1980
+ actorSqlTakeLastKvError(ctx: ActorContextHandle): string | null;
1981
+ actorSqlClose(ctx: ActorContextHandle): Promise<void>;
1982
+ actorUdsProvision(ctx: ActorContextHandle): Promise<RuntimeActorUdsEndpointInfo>;
1983
+ actorQueueSend(ctx: ActorContextHandle, name: string, body: RuntimeBytes): Promise<RuntimeQueueMessage>;
1984
+ actorQueueNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueNextBatchOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage[]>;
1985
+ actorQueueWaitForNames(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage>;
1986
+ actorQueueWaitForNamesAvailable(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<void>;
1987
+ actorQueueEnqueueAndWait(ctx: ActorContextHandle, name: string, body: RuntimeBytes, options?: RuntimeQueueEnqueueAndWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeBytes | null>;
1988
+ actorQueueTryNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueTryNextBatchOptions | undefined | null): RuntimeQueueMessage[];
1989
+ actorQueueMaxSize(ctx: ActorContextHandle): number;
1990
+ actorQueueInspectMessages(ctx: ActorContextHandle): Promise<RuntimeQueueInspectMessage[]>;
1991
+ actorQueueReset(ctx: ActorContextHandle): Promise<void>;
1992
+ actorScheduleAfter(ctx: ActorContextHandle, durationMs: number, actionName: string, args: RuntimeBytes): void;
1993
+ actorScheduleAt(ctx: ActorContextHandle, timestampMs: number, actionName: string, args: RuntimeBytes): void;
1994
+ connId(conn: ConnHandle): string;
1995
+ connParams(conn: ConnHandle): RuntimeBytes;
1996
+ connState(conn: ConnHandle): RuntimeBytes;
1997
+ connSetState(conn: ConnHandle, state: RuntimeBytes): void;
1998
+ connIsHibernatable(conn: ConnHandle): boolean;
1999
+ connSend(conn: ConnHandle, name: string, args: RuntimeBytes): void;
2000
+ connDisconnect(conn: ConnHandle, reason?: string | undefined | null): Promise<void>;
2001
+ webSocketSend(ws: WebSocketHandle, data: RuntimeBytes, binary: boolean): void;
2002
+ webSocketClose(ws: WebSocketHandle, code?: number | undefined | null, reason?: string | undefined | null): Promise<void>;
2003
+ webSocketSetEventCallback(ws: WebSocketHandle, callback: (event: RuntimeWebSocketEvent) => void): void;
2004
+ }
2005
+
2006
+ declare function buildConfiguredRegistry(config: RegistryConfig): Promise<{
2007
+ runtime: CoreRuntime;
2008
+ registry: RegistryHandle;
2009
+ serveConfig: RuntimeServeConfig;
2010
+ }>;
2011
+
1594
2012
  type FetchHandler = (request: Request, ...args: any) => Response | Promise<Response>;
1595
2013
  interface ServerlessHandler {
1596
2014
  fetch: FetchHandler;
1597
2015
  }
1598
- interface RegistryDiagnostics {
1599
- mode: string;
1600
- envoyActiveActorCount?: number | null;
2016
+ interface RegistryRoutes {
2017
+ health(): Promise<Response>;
2018
+ metadata(): Promise<Response>;
2019
+ prometheusMetrics(request?: Request): Promise<Response>;
2020
+ }
2021
+ /**
2022
+ * Injectable dependencies for {@link Registry}. Production code uses the
2023
+ * defaults. Tests override `buildConfiguredRegistry` to drive lifecycle
2024
+ * orchestration against a fake `CoreRuntime` without an engine.
2025
+ */
2026
+ interface RegistryDeps {
2027
+ buildConfiguredRegistry: typeof buildConfiguredRegistry;
1601
2028
  }
1602
2029
  declare class Registry<A extends RegistryActors> {
1603
2030
  #private;
2031
+ readonly routes: RegistryRoutes;
1604
2032
  get config(): RegistryConfigInput<A>;
1605
2033
  parseConfig(): RegistryConfig;
1606
- constructor(config: RegistryConfigInput<A>);
2034
+ constructor(config: RegistryConfigInput<A>, deps?: Partial<RegistryDeps>);
1607
2035
  /**
1608
2036
  * Handle an incoming HTTP request for serverless deployments.
1609
2037
  *
@@ -1624,11 +2052,57 @@ declare class Registry<A extends RegistryActors> {
1624
2052
  * ```
1625
2053
  */
1626
2054
  serve(): ServerlessHandler;
1627
- diagnostics(): Promise<RegistryDiagnostics>;
2055
+ /**
2056
+ * Bind an HTTP listener provided by the native (Rust) runtime and serve
2057
+ * the registry's serverless endpoints over it. Resolves only after the
2058
+ * registry is shut down (SIGINT/SIGTERM or `nativeRegistry.shutdown()`).
2059
+ *
2060
+ * @param opts.port Port to listen on. Defaults to `process.env.RIVET_PORT`
2061
+ * if set, otherwise 3000.
2062
+ * @param opts.host Address to bind. Defaults to `0.0.0.0`.
2063
+ * @param opts.publicDir If set, serves static files from this directory
2064
+ * as a fallback below the framework routes.
2065
+ *
2066
+ * @example
2067
+ * ```ts
2068
+ * await registry.listen();
2069
+ * await registry.listen({ port: 8080, publicDir: "./public" });
2070
+ * ```
2071
+ */
2072
+ listen(opts?: {
2073
+ port?: number;
2074
+ host?: string;
2075
+ publicDir?: string;
2076
+ }): Promise<void>;
2077
+ /**
2078
+ * Gracefully drains all live registries.
2079
+ *
2080
+ * Programmatic counterpart to the SIGINT/SIGTERM handlers: tears down
2081
+ * every live `CoreRegistry` (both `start()` and `handler()` modes) and
2082
+ * waits for the serve promise to resolve, all bounded by the shutdown
2083
+ * grace period. Unlike a signal-driven shutdown, this does not re-raise a
2084
+ * signal or exit the process. The caller owns process lifetime.
2085
+ *
2086
+ * Idempotent: concurrent or repeated calls share a single drain. Safe to
2087
+ * call even if nothing has been started.
2088
+ *
2089
+ * @example
2090
+ * ```ts
2091
+ * const registry = setup({ use: { counter } });
2092
+ * registry.start();
2093
+ * // ...later, on your own shutdown trigger:
2094
+ * await registry.shutdown();
2095
+ * ```
2096
+ */
2097
+ shutdown(): Promise<void>;
1628
2098
  startEnvoy(): void;
1629
2099
  /**
1630
2100
  * Starts the actor envoy for standalone server deployments.
1631
2101
  *
2102
+ * Set `RIVETKIT_RUNTIME_MODE=serverless` to instead bind an HTTP listener
2103
+ * via `listen()` (Mode B). Mode A (envoy) and Mode B (listener) are
2104
+ * mutually exclusive per registry instance.
2105
+ *
1632
2106
  * @example
1633
2107
  * ```ts
1634
2108
  * const registry = setup({ use: { counter } });