rivetkit 0.0.0-skip-ready-wait-flatten-client-options.1cae221 → 0.0.0-sql-metrics.eac581d

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