rivetkit 0.0.0-skip-ready-wait-flatten-client-options.1cae221 → 0.0.0-sqlite-uds.ea644f1

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 (254) hide show
  1. package/dist/browser/client.d.ts +561 -89
  2. package/dist/browser/client.js +1063 -430
  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 +2232 -2082
  13. package/dist/tsup/agent-os/index.cjs.map +1 -1
  14. package/dist/tsup/agent-os/index.d.cts +556 -85
  15. package/dist/tsup/agent-os/index.d.ts +556 -85
  16. package/dist/tsup/agent-os/index.js +2234 -2084
  17. package/dist/tsup/agent-os/index.js.map +1 -1
  18. package/dist/tsup/{chunk-7MRGNVSR.js → chunk-3GLNEWGY.js} +78 -6
  19. package/dist/tsup/chunk-3GLNEWGY.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-XNZR7UD2.cjs → chunk-7DDQA6KN.cjs} +90 -65
  23. package/dist/tsup/chunk-7DDQA6KN.cjs.map +1 -0
  24. package/dist/tsup/{chunk-NFC5VU36.cjs → chunk-AESHILFV.cjs} +18 -10
  25. package/dist/tsup/chunk-AESHILFV.cjs.map +1 -0
  26. package/dist/tsup/{chunk-D4TSTM6C.js → chunk-EFQCNJ23.js} +83 -58
  27. package/dist/tsup/chunk-EFQCNJ23.js.map +1 -0
  28. package/dist/tsup/{chunk-OIKOPSXQ.js → chunk-FUS4OFX5.js} +12 -4
  29. package/dist/tsup/chunk-FUS4OFX5.js.map +1 -0
  30. package/dist/tsup/{chunk-IOYKCB6Y.cjs → chunk-GUCITCR3.cjs} +44 -9
  31. package/dist/tsup/chunk-GUCITCR3.cjs.map +1 -0
  32. package/dist/tsup/{chunk-3BFYSYRU.js → chunk-HXUEHHJF.js} +3 -2
  33. package/dist/tsup/chunk-HXUEHHJF.js.map +1 -0
  34. package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JZ7TWV65.js} +1 -1
  35. package/dist/tsup/chunk-JZ7TWV65.js.map +1 -0
  36. package/dist/tsup/{chunk-KSG2COSQ.js → chunk-KYBAXJRA.js} +6 -6
  37. package/dist/tsup/chunk-KYBAXJRA.js.map +1 -0
  38. package/dist/tsup/{chunk-LNMB25HW.js → chunk-LMUEIJUM.js} +780 -183
  39. package/dist/tsup/chunk-LMUEIJUM.js.map +1 -0
  40. package/dist/tsup/{chunk-RZEJJJKU.js → chunk-LTMSYD2A.js} +42 -7
  41. package/dist/tsup/chunk-LTMSYD2A.js.map +1 -0
  42. package/dist/tsup/{chunk-AK57AL7S.cjs → chunk-OAPVVVTX.cjs} +79 -7
  43. package/dist/tsup/chunk-OAPVVVTX.cjs.map +1 -0
  44. package/dist/tsup/{chunk-D2TLG75Y.cjs → chunk-TIUL6FNF.cjs} +10 -10
  45. package/dist/tsup/chunk-TIUL6FNF.cjs.map +1 -0
  46. package/dist/tsup/{chunk-POTPHU3P.cjs → chunk-UYT2CIWO.cjs} +3 -3
  47. package/dist/tsup/{chunk-POTPHU3P.cjs.map → chunk-UYT2CIWO.cjs.map} +1 -1
  48. package/dist/tsup/{chunk-TPBHXFB2.cjs → chunk-VDTC257X.cjs} +138 -24
  49. package/dist/tsup/chunk-VDTC257X.cjs.map +1 -0
  50. package/dist/tsup/{chunk-LLD2D5LO.cjs → chunk-VE2X4KMG.cjs} +3 -2
  51. package/dist/tsup/chunk-VE2X4KMG.cjs.map +1 -0
  52. package/dist/tsup/{chunk-22XU3BVY.cjs → chunk-VWOA7DRK.cjs} +925 -328
  53. package/dist/tsup/chunk-VWOA7DRK.cjs.map +1 -0
  54. package/dist/tsup/{chunk-4ZIWB4CQ.js → chunk-VYQASICJ.js} +2 -2
  55. package/dist/tsup/{chunk-W54QCENI.js → chunk-X4BXYDTG.js} +134 -20
  56. package/dist/tsup/chunk-X4BXYDTG.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.cjs.map +1 -1
  63. package/dist/tsup/client/mod.d.cts +8 -9
  64. package/dist/tsup/client/mod.d.ts +8 -9
  65. package/dist/tsup/client/mod.js +8 -8
  66. package/dist/tsup/common/log.cjs +5 -3
  67. package/dist/tsup/common/log.cjs.map +1 -1
  68. package/dist/tsup/common/log.d.cts +5 -1
  69. package/dist/tsup/common/log.d.ts +5 -1
  70. package/dist/tsup/common/log.js +6 -4
  71. package/dist/tsup/common/websocket.cjs +4 -4
  72. package/dist/tsup/common/websocket.js +3 -3
  73. package/dist/tsup/{config-CRdGwwbr.d.cts → config-CxG53eQo.d.cts} +577 -36
  74. package/dist/tsup/{config-kxXbtrJU.d.ts → config-DLOxy81E.d.cts} +5 -5
  75. package/dist/tsup/{config-kxXbtrJU.d.cts → config-DLOxy81E.d.ts} +5 -5
  76. package/dist/tsup/{config-DIpBWm5C.d.ts → config-Ds6DCRhV.d.ts} +577 -36
  77. package/dist/tsup/context-8KlcOYIs.d.cts +129 -0
  78. package/dist/tsup/context-Cfbm4QLr.d.ts +129 -0
  79. package/dist/tsup/db/drizzle.cjs +164 -78
  80. package/dist/tsup/db/drizzle.cjs.map +1 -1
  81. package/dist/tsup/db/drizzle.d.cts +4 -2
  82. package/dist/tsup/db/drizzle.d.ts +4 -2
  83. package/dist/tsup/db/drizzle.js +164 -78
  84. package/dist/tsup/db/drizzle.js.map +1 -1
  85. package/dist/tsup/db/mod.cjs +93 -24
  86. package/dist/tsup/db/mod.cjs.map +1 -1
  87. package/dist/tsup/db/mod.d.cts +2 -2
  88. package/dist/tsup/db/mod.d.ts +2 -2
  89. package/dist/tsup/db/mod.js +92 -23
  90. package/dist/tsup/db/mod.js.map +1 -1
  91. package/dist/tsup/dynamic/mod.cjs +24 -0
  92. package/dist/tsup/dynamic/mod.cjs.map +1 -0
  93. package/dist/tsup/dynamic/mod.d.cts +37 -0
  94. package/dist/tsup/dynamic/mod.d.ts +37 -0
  95. package/dist/tsup/dynamic/mod.js +24 -0
  96. package/dist/tsup/dynamic/mod.js.map +1 -0
  97. package/dist/tsup/inspector/mod.cjs +47 -12
  98. package/dist/tsup/inspector/mod.cjs.map +1 -1
  99. package/dist/tsup/inspector/mod.d.cts +37 -15
  100. package/dist/tsup/inspector/mod.d.ts +37 -15
  101. package/dist/tsup/inspector/mod.js +46 -11
  102. package/dist/tsup/inspector/mod.js.map +1 -1
  103. package/dist/tsup/inspector-tab/mod.cjs +162 -0
  104. package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
  105. package/dist/tsup/inspector-tab/mod.d.cts +240 -0
  106. package/dist/tsup/inspector-tab/mod.d.ts +240 -0
  107. package/dist/tsup/inspector-tab/mod.js +162 -0
  108. package/dist/tsup/inspector-tab/mod.js.map +1 -0
  109. package/dist/tsup/mod.cjs +1078 -479
  110. package/dist/tsup/mod.cjs.map +1 -1
  111. package/dist/tsup/mod.d.cts +5 -6
  112. package/dist/tsup/mod.d.ts +5 -6
  113. package/dist/tsup/mod.js +996 -397
  114. package/dist/tsup/mod.js.map +1 -1
  115. package/dist/tsup/test/mod.cjs +21 -18
  116. package/dist/tsup/test/mod.cjs.map +1 -1
  117. package/dist/tsup/test/mod.d.cts +4 -5
  118. package/dist/tsup/test/mod.d.ts +4 -5
  119. package/dist/tsup/test/mod.js +18 -15
  120. package/dist/tsup/test/mod.js.map +1 -1
  121. package/dist/tsup/utils-CqDnC_PS.d.cts +104 -0
  122. package/dist/tsup/utils-CqDnC_PS.d.ts +104 -0
  123. package/dist/tsup/utils.cjs +3 -3
  124. package/dist/tsup/utils.d.cts +1 -1
  125. package/dist/tsup/utils.d.ts +1 -1
  126. package/dist/tsup/utils.js +2 -2
  127. package/dist/tsup/workflow/mod.cjs +386 -322
  128. package/dist/tsup/workflow/mod.cjs.map +1 -1
  129. package/dist/tsup/workflow/mod.d.cts +8 -9
  130. package/dist/tsup/workflow/mod.d.ts +8 -9
  131. package/dist/tsup/workflow/mod.js +363 -299
  132. package/dist/tsup/workflow/mod.js.map +1 -1
  133. package/package.json +35 -14
  134. package/src/actor/config.ts +188 -59
  135. package/src/actor/contexts/index.ts +7 -2
  136. package/src/actor/definition.ts +17 -19
  137. package/src/actor/driver.ts +3 -3
  138. package/src/actor/errors.ts +70 -7
  139. package/src/actor/instance/mod.ts +39 -56
  140. package/src/actor/keys.ts +2 -1
  141. package/src/actor/mod.ts +22 -20
  142. package/src/actor/schema.ts +2 -2
  143. package/src/agent-os/actor/index.ts +38 -18
  144. package/src/agent-os/actor/preview.ts +1 -2
  145. package/src/agent-os/actor/session.ts +2 -2
  146. package/src/agent-os/config.ts +1 -1
  147. package/src/agent-os/fs/database-vfs.ts +1 -1
  148. package/src/agent-os/index.ts +16 -15
  149. package/src/client/actor-common.ts +88 -62
  150. package/src/client/actor-conn.ts +58 -63
  151. package/src/client/actor-handle.ts +125 -71
  152. package/src/client/actor-query.ts +5 -5
  153. package/src/client/config.ts +3 -3
  154. package/src/client/errors.ts +2 -1
  155. package/src/client/lifecycle-errors.ts +2 -4
  156. package/src/client/query.ts +1 -1
  157. package/src/client/queue.ts +8 -3
  158. package/src/client/raw-utils.ts +10 -10
  159. package/src/client/resolve-gateway-target.ts +1 -1
  160. package/src/client/utils.ts +34 -10
  161. package/src/common/actor-router-consts.ts +7 -4
  162. package/src/common/actor-websocket.ts +3 -1
  163. package/src/common/bare/actor-persist/v1.ts +205 -163
  164. package/src/common/bare/actor-persist/v2.ts +265 -213
  165. package/src/common/bare/actor-persist/v3.ts +176 -172
  166. package/src/common/bare/actor-persist/v4.ts +254 -253
  167. package/src/common/bare/generated/actor-uds-protocol/v1.ts +802 -0
  168. package/src/common/bare/generated/client-protocol/v4.ts +599 -0
  169. package/src/common/bare/generated/inspector/v5.ts +1016 -0
  170. package/src/common/bare/transport/v1.ts +694 -542
  171. package/src/common/client-protocol-versioned.ts +176 -67
  172. package/src/common/client-protocol-zod.ts +7 -0
  173. package/src/common/client-protocol.ts +1 -1
  174. package/src/common/database/config.ts +16 -5
  175. package/src/common/database/mod.test.ts +137 -16
  176. package/src/common/database/mod.ts +100 -30
  177. package/src/common/database/native-database.test.ts +35 -22
  178. package/src/common/database/native-database.ts +26 -10
  179. package/src/common/database/shared.ts +1 -0
  180. package/src/common/encoding.ts +250 -16
  181. package/src/common/engine.ts +28 -1
  182. package/src/common/eventsource.ts +1 -1
  183. package/src/common/inline-websocket-adapter.ts +14 -13
  184. package/src/common/log.ts +15 -8
  185. package/src/common/router.ts +49 -23
  186. package/src/common/utils.ts +10 -202
  187. package/src/common/websocket-interface.ts +1 -1
  188. package/src/db/drizzle.ts +194 -95
  189. package/src/db/mod.ts +1 -1
  190. package/src/devtools-loader/index.ts +4 -7
  191. package/src/devtools-loader/serve-devtools.ts +26 -0
  192. package/src/drivers/engine/actor-driver.ts +76 -73
  193. package/src/dynamic/instance.ts +32 -0
  194. package/src/dynamic/internal.ts +50 -0
  195. package/src/dynamic/isolate-runtime.ts +66 -0
  196. package/src/dynamic/mod.ts +32 -0
  197. package/src/engine-client/actor-http-client.ts +6 -9
  198. package/src/engine-client/actor-websocket-client.ts +14 -13
  199. package/src/engine-client/api-endpoints.ts +51 -2
  200. package/src/engine-client/api-utils.ts +2 -2
  201. package/src/engine-client/driver.ts +3 -4
  202. package/src/engine-client/mod.ts +17 -10
  203. package/src/engine-client/ws-proxy.ts +9 -4
  204. package/src/inspector/client.browser.ts +66 -15
  205. package/src/inspector/mod.ts +2 -4
  206. package/src/inspector-tab/mod.ts +300 -0
  207. package/src/registry/config/envoy.ts +1 -2
  208. package/src/registry/config/index.ts +46 -20
  209. package/src/registry/index.ts +364 -87
  210. package/src/registry/napi-runtime.ts +97 -8
  211. package/src/registry/native-validation.ts +10 -12
  212. package/src/registry/native.ts +592 -343
  213. package/src/registry/process-metrics.ts +250 -0
  214. package/src/registry/runtime.ts +85 -6
  215. package/src/registry/wasm-runtime.ts +72 -3
  216. package/src/registry/write-through-proxy.ts +40 -0
  217. package/src/serde.ts +2 -2
  218. package/src/serverless/configure.ts +19 -8
  219. package/src/test/mod.ts +11 -8
  220. package/src/utils/crypto.ts +14 -0
  221. package/src/utils/endpoint-parser.ts +1 -1
  222. package/src/utils/env-vars.ts +37 -0
  223. package/src/utils/router.ts +1 -1
  224. package/src/utils.ts +1 -2
  225. package/src/workflow/context.ts +703 -240
  226. package/src/workflow/driver.ts +23 -12
  227. package/src/workflow/inspector.ts +12 -3
  228. package/src/workflow/mod.ts +37 -23
  229. package/dist/tsup/chunk-22XU3BVY.cjs.map +0 -1
  230. package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
  231. package/dist/tsup/chunk-3BFYSYRU.js.map +0 -1
  232. package/dist/tsup/chunk-7MRGNVSR.js.map +0 -1
  233. package/dist/tsup/chunk-AK57AL7S.cjs.map +0 -1
  234. package/dist/tsup/chunk-D2TLG75Y.cjs.map +0 -1
  235. package/dist/tsup/chunk-D4TSTM6C.js.map +0 -1
  236. package/dist/tsup/chunk-IOYKCB6Y.cjs.map +0 -1
  237. package/dist/tsup/chunk-K34B3OVG.js.map +0 -1
  238. package/dist/tsup/chunk-KSG2COSQ.js.map +0 -1
  239. package/dist/tsup/chunk-LLD2D5LO.cjs.map +0 -1
  240. package/dist/tsup/chunk-LNMB25HW.js.map +0 -1
  241. package/dist/tsup/chunk-NFC5VU36.cjs.map +0 -1
  242. package/dist/tsup/chunk-OIKOPSXQ.js.map +0 -1
  243. package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
  244. package/dist/tsup/chunk-RZEJJJKU.js.map +0 -1
  245. package/dist/tsup/chunk-TPBHXFB2.cjs.map +0 -1
  246. package/dist/tsup/chunk-V3QNBJ7N.cjs.map +0 -1
  247. package/dist/tsup/chunk-W54QCENI.js.map +0 -1
  248. package/dist/tsup/chunk-XNZR7UD2.cjs.map +0 -1
  249. package/dist/tsup/context-B7G6sk7x.d.ts +0 -92
  250. package/dist/tsup/context-DzMRHkjC.d.cts +0 -92
  251. package/dist/tsup/utils-fwx3o3K9.d.cts +0 -18
  252. package/dist/tsup/utils-fwx3o3K9.d.ts +0 -18
  253. package/src/utils/serve.ts +0 -217
  254. /package/dist/tsup/{chunk-4ZIWB4CQ.js.map → chunk-VYQASICJ.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
 
@@ -275,7 +285,6 @@ type GatewayTarget = {
275
285
  directId: string;
276
286
  } | ActorQuery;
277
287
  interface GatewayRequestOptions {
278
- bypassConnectable?: boolean;
279
288
  skipReadyWait?: boolean;
280
289
  }
281
290
  interface EngineControlClient {
@@ -376,8 +385,13 @@ interface QueueSendResult<TResponse = unknown> {
376
385
  * @returns {Promise<Response>}
377
386
  */
378
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;
379
394
  interface ActorGatewayOptions {
380
- bypassConnectable?: boolean;
381
395
  skipReadyWait?: boolean;
382
396
  }
383
397
  interface ActorActionOptions extends ActorGatewayOptions {
@@ -389,9 +403,7 @@ type ActorWebSocketOptions = ActorGatewayOptions;
389
403
  /**
390
404
  * Maps action methods from actor definition to typed function signatures.
391
405
  */
392
- type ActorDefinitionActions<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<any, any, any, any, any, any, any, any, infer R> ? {
393
- [K in keyof R]: R[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Return> : never;
394
- } : never;
406
+ type ActorDefinitionActions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? Record<string, ActorActionFunction<any[], any>> : ActorActionMap<ActionsOf<AD>>;
395
407
  type ActorQueueSend<TQueues extends QueueSchemaConfig> = {
396
408
  <K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options: QueueSendWaitOptions): Promise<QueueSendResult<InferQueueCompleteMap<TQueues>[K]>>;
397
409
  <K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options?: QueueSendNoWaitOptions): Promise<void>;
@@ -402,13 +414,31 @@ type ActorEventSubscribe<TEvents extends EventSchemaConfig> = {
402
414
  <K extends keyof TEvents & string>(eventName: K, callback: (...args: InferEventArgs<InferSchemaMap<TEvents>[K]>) => void): () => void;
403
415
  (eventName: keyof TEvents extends never ? string : never, callback: (...args: any[]) => void): () => void;
404
416
  };
405
- 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 ? {
406
424
  send: ActorQueueSend<Q>;
407
- } : never : never;
408
- 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 ? {
409
436
  on: ActorEventSubscribe<E>;
410
437
  once: ActorEventSubscribe<E>;
411
- } : 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
+ } : {} : {};
412
442
 
413
443
  declare class ActorClientError extends Error {
414
444
  }
@@ -682,7 +712,7 @@ declare const ClientConfigSchema: z$1.ZodPipe<z$1.ZodObject<{
682
712
  }>>;
683
713
  headers: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>>;
684
714
  gateway: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodObject<{
685
- bypassConnectable: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
715
+ skipReadyWait: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
686
716
  }, z$1.core.$strip>>>;
687
717
  getUpgradeWebSocket: z$1.ZodOptional<z$1.ZodCustom<GetUpgradeWebSocket, GetUpgradeWebSocket>>;
688
718
  disableMetadataLookup: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
@@ -696,7 +726,7 @@ declare const ClientConfigSchema: z$1.ZodPipe<z$1.ZodObject<{
696
726
  encoding: "json" | "cbor" | "bare";
697
727
  headers: Record<string, string>;
698
728
  gateway: {
699
- bypassConnectable: boolean;
729
+ skipReadyWait: boolean;
700
730
  };
701
731
  disableMetadataLookup: boolean;
702
732
  maxInputSize: number;
@@ -710,7 +740,7 @@ declare const ClientConfigSchema: z$1.ZodPipe<z$1.ZodObject<{
710
740
  encoding: "json" | "cbor" | "bare";
711
741
  headers: Record<string, string>;
712
742
  gateway: {
713
- bypassConnectable: boolean;
743
+ skipReadyWait: boolean;
714
744
  };
715
745
  disableMetadataLookup: boolean;
716
746
  maxInputSize: number;
@@ -922,6 +952,7 @@ type Client<A extends Registry<any>> = ClientRaw & {
922
952
  };
923
953
 
924
954
  declare const ACTOR_CONTEXT_INTERNAL_SYMBOL: unique symbol;
955
+ declare const RAW_STATE_SYMBOL: unique symbol;
925
956
  interface ActorLogger {
926
957
  level: any;
927
958
  fatal: any;
@@ -954,6 +985,10 @@ type ActorKvListOptions<T extends ActorKvValueType = "text", K extends ActorKvKe
954
985
  limit?: number;
955
986
  };
956
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
+ */
957
992
  interface ActorKv {
958
993
  get<T extends ActorKvValueType = "text">(key: Uint8Array | string, options?: ActorKvValueOptions<T>): Promise<ActorKvValueTypeMap[T] | null>;
959
994
  put<T extends ActorKvValueType = "text">(key: Uint8Array | string, value: Uint8Array | string | ArrayBuffer, options?: ActorKvValueOptions<T>): Promise<void>;
@@ -1030,7 +1065,7 @@ interface ActorQueue<TQueues extends QueueSchemaConfig = Record<never, never>> {
1030
1065
  iter<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueIterOptions<TName, TCompletable>): AsyncIterable<any>;
1031
1066
  [key: string]: any;
1032
1067
  }
1033
- 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>> {
1034
1069
  id: string;
1035
1070
  params: TConnParams;
1036
1071
  state: TConnState;
@@ -1041,8 +1076,14 @@ interface Conn<TState = unknown, TConnParams = unknown, TConnState = unknown, TV
1041
1076
  }
1042
1077
  interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
1043
1078
  [ACTOR_CONTEXT_INTERNAL_SYMBOL]?: unknown;
1079
+ /** Returns the raw unwrapped state without the write-through proxy. */
1080
+ [RAW_STATE_SYMBOL](): TState;
1044
1081
  state: TState;
1045
1082
  vars: TVars;
1083
+ /**
1084
+ * @deprecated Actor KV is deprecated. Use embedded SQLite (`db` / `sql`)
1085
+ * or actor state instead.
1086
+ */
1046
1087
  readonly kv: ActorKv;
1047
1088
  readonly db: InferDatabaseClient<TDatabase>;
1048
1089
  readonly schedule: ActorSchedule;
@@ -1051,6 +1092,11 @@ interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase
1051
1092
  readonly name: string;
1052
1093
  readonly key: string[];
1053
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
+ }>;
1054
1100
  readonly conns: Map<string, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>;
1055
1101
  readonly log: ActorLogger;
1056
1102
  readonly abortSignal: AbortSignal;
@@ -1167,8 +1213,27 @@ declare const ActorConfigSchema: z.ZodObject<{
1167
1213
  preloadMaxWorkflowBytes: z.ZodOptional<z.ZodNumber>;
1168
1214
  preloadMaxConnectionsBytes: z.ZodOptional<z.ZodNumber>;
1169
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>>;
1170
1235
  }, z.core.$strict>;
1171
- 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> = {
1172
1237
  state: TState;
1173
1238
  } | {
1174
1239
  createState: (c: CreateContext<TState, TInput, TDatabase, TEvents, TQueues>, input: TInput) => TState | Promise<TState>;
@@ -1181,7 +1246,7 @@ type CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase e
1181
1246
  /**
1182
1247
  * @experimental
1183
1248
  */
1184
- 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> = {
1185
1250
  /**
1186
1251
  * @experimental
1187
1252
  */
@@ -1249,7 +1314,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
1249
1314
  * shutdown window (`sleepGracePeriod`) cover deferred work.
1250
1315
  *
1251
1316
  * The handler receives an abort signal via `c.abortSignal` and a
1252
- * `c.aborted` alias for loop checks. Use these to gracefully exit.
1317
+ * `c.aborted` alias. Use these to gracefully exit when shutdown starts.
1253
1318
  *
1254
1319
  * If this handler exits, the actor will follow the normal idle sleep timeout
1255
1320
  * once it becomes idle.
@@ -1278,10 +1343,11 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
1278
1343
  * Called before a client connects to the actor.
1279
1344
  *
1280
1345
  * Use this hook to determine if a connection should be accepted
1281
- * 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.
1282
1348
  *
1283
1349
  * @param opts Connection parameters including client-provided data
1284
- * @returns The initial connection state or a Promise that resolves to it
1350
+ * @returns Void or a Promise.
1285
1351
  * @throws Throw an error to reject the connection
1286
1352
  */
1287
1353
  onBeforeConnect?: (c: BeforeConnectContext<TState, TVars, TInput, TDatabase, TEvents, TQueues>, params: TConnParams) => void | Promise<void>;
@@ -1289,7 +1355,8 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
1289
1355
  * Called when a client successfully connects to the actor.
1290
1356
  *
1291
1357
  * Use this hook to perform actions when a connection is established,
1292
- * 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.
1293
1360
  *
1294
1361
  * @param conn The connection object
1295
1362
  * @returns Void or a Promise that resolves when connection handling is complete
@@ -1365,19 +1432,21 @@ type ActorDatabaseConfig<TDatabase extends AnyDatabaseProvider> = {
1365
1432
  */
1366
1433
  db: TDatabase;
1367
1434
  } | Record<never, never>;
1368
- 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>;
1369
1436
 
1370
- 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>> {
1371
- 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;
1372
1442
  }
1373
- type AnyActorDefinition = BaseActorDefinition<any, any, any, any, any, any, any, any, any>;
1374
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> {
1375
1444
  #private;
1376
- constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q>);
1377
- 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>;
1378
1447
  }
1379
1448
 
1380
- 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>>;
1381
1450
  type RegistryActors = z$2.infer<typeof ActorsSchema>;
1382
1451
  declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1383
1452
  use: z$2.ZodRecord<z$2.ZodString, z$2.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
@@ -1390,6 +1459,7 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1390
1459
  }, z$2.core.$strip>>>;
1391
1460
  maxIncomingMessageSize: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
1392
1461
  maxOutgoingMessageSize: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
1462
+ experimentalActorUds: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodBoolean>>;
1393
1463
  runtime: z$2.ZodPipe<z$2.ZodOptional<z$2.ZodEnum<{
1394
1464
  auto: "auto";
1395
1465
  native: "native";
@@ -1397,11 +1467,7 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1397
1467
  }>>, z$2.ZodTransform<"auto" | "native" | "wasm", "auto" | "native" | "wasm" | undefined>>;
1398
1468
  wasm: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodObject<{
1399
1469
  bindings: z$2.ZodOptional<z$2.ZodCustom<typeof _rivetkit_rivetkit_wasm, typeof _rivetkit_rivetkit_wasm>>;
1400
- initInput: z$2.ZodOptional<z$2.ZodCustom<{
1401
- module_or_path: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput>;
1402
- } | _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined, {
1403
- module_or_path: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput>;
1404
- } | _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>>;
1405
1471
  }, z$2.core.$strip>>>;
1406
1472
  sqlite: z$2.ZodPipe<z$2.ZodOptional<z$2.ZodUnion<readonly [z$2.ZodEnum<{
1407
1473
  local: "local";
@@ -1438,6 +1504,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1438
1504
  httpPort: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
1439
1505
  httpHost: z$2.ZodOptional<z$2.ZodString>;
1440
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>>;
1441
1509
  engineVersion: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodString>>;
1442
1510
  configurePool: z$2.ZodOptional<z$2.ZodOptional<z$2.ZodObject<{
1443
1511
  name: z$2.ZodOptional<z$2.ZodString>;
@@ -1462,7 +1530,7 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1462
1530
  envoyKey: z$2.ZodOptional<z$2.ZodString>;
1463
1531
  }, z$2.core.$strip>>>;
1464
1532
  shutdown: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodObject<{
1465
- gracePeriodMs: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
1533
+ gracePeriodMs: z$2.ZodOptional<z$2.ZodNumber>;
1466
1534
  disableSignalHandlers: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodBoolean>>;
1467
1535
  }, z$2.core.$strip>>>;
1468
1536
  }, z$2.core.$strip>, z$2.ZodTransform<{
@@ -1489,12 +1557,11 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1489
1557
  };
1490
1558
  maxIncomingMessageSize: number;
1491
1559
  maxOutgoingMessageSize: number;
1560
+ experimentalActorUds: boolean;
1492
1561
  runtime: "auto" | "native" | "wasm";
1493
1562
  wasm: {
1494
1563
  bindings?: typeof _rivetkit_rivetkit_wasm | undefined;
1495
- initInput?: {
1496
- module_or_path: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput>;
1497
- } | _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined;
1564
+ initInput?: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined;
1498
1565
  };
1499
1566
  noWelcome: boolean;
1500
1567
  logging: {
@@ -1505,6 +1572,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1505
1572
  httpBasePath: string;
1506
1573
  httpPort: number;
1507
1574
  startEngine: boolean;
1575
+ engineHost: string;
1576
+ enginePort: number;
1508
1577
  engineVersion: string;
1509
1578
  envoy: {
1510
1579
  poolName: string;
@@ -1513,8 +1582,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1513
1582
  envoyKey?: string | undefined;
1514
1583
  };
1515
1584
  shutdown: {
1516
- gracePeriodMs: number;
1517
1585
  disableSignalHandlers: boolean;
1586
+ gracePeriodMs?: number | undefined;
1518
1587
  };
1519
1588
  staticDir?: string | undefined;
1520
1589
  httpHost?: string | undefined;
@@ -1536,12 +1605,11 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1536
1605
  };
1537
1606
  maxIncomingMessageSize: number;
1538
1607
  maxOutgoingMessageSize: number;
1608
+ experimentalActorUds: boolean;
1539
1609
  runtime: "auto" | "native" | "wasm";
1540
1610
  wasm: {
1541
1611
  bindings?: typeof _rivetkit_rivetkit_wasm | undefined;
1542
- initInput?: {
1543
- module_or_path: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput>;
1544
- } | _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined;
1612
+ initInput?: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined;
1545
1613
  };
1546
1614
  sqlite: {
1547
1615
  backend: "local" | "remote";
@@ -1558,6 +1626,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1558
1626
  httpBasePath: string;
1559
1627
  httpPort: number;
1560
1628
  startEngine: boolean;
1629
+ engineHost: string;
1630
+ enginePort: number;
1561
1631
  engineVersion: string;
1562
1632
  serverless: {
1563
1633
  basePath: string;
@@ -1572,8 +1642,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1572
1642
  envoyKey?: string | undefined;
1573
1643
  };
1574
1644
  shutdown: {
1575
- gracePeriodMs: number;
1576
1645
  disableSignalHandlers: boolean;
1646
+ gracePeriodMs?: number | undefined;
1577
1647
  };
1578
1648
  staticDir?: string | undefined;
1579
1649
  httpHost?: string | undefined;
@@ -1593,19 +1663,375 @@ type RegistryConfigInput<A extends RegistryActors> = Omit<z$2.input<typeof Regis
1593
1663
  use: A;
1594
1664
  };
1595
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
+
1596
2012
  type FetchHandler = (request: Request, ...args: any) => Response | Promise<Response>;
1597
2013
  interface ServerlessHandler {
1598
2014
  fetch: FetchHandler;
1599
2015
  }
1600
- interface RegistryDiagnostics {
1601
- mode: string;
1602
- 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;
1603
2028
  }
1604
2029
  declare class Registry<A extends RegistryActors> {
1605
2030
  #private;
2031
+ readonly routes: RegistryRoutes;
1606
2032
  get config(): RegistryConfigInput<A>;
1607
2033
  parseConfig(): RegistryConfig;
1608
- constructor(config: RegistryConfigInput<A>);
2034
+ constructor(config: RegistryConfigInput<A>, deps?: Partial<RegistryDeps>);
1609
2035
  /**
1610
2036
  * Handle an incoming HTTP request for serverless deployments.
1611
2037
  *
@@ -1626,11 +2052,57 @@ declare class Registry<A extends RegistryActors> {
1626
2052
  * ```
1627
2053
  */
1628
2054
  serve(): ServerlessHandler;
1629
- 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>;
1630
2098
  startEnvoy(): void;
1631
2099
  /**
1632
2100
  * Starts the actor envoy for standalone server deployments.
1633
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
+ *
1634
2106
  * @example
1635
2107
  * ```ts
1636
2108
  * const registry = setup({ use: { counter } });