rivetkit 0.0.0-main.337772d → 0.0.0-main.49693dc

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 (290) hide show
  1. package/dist/browser/client.d.ts +814 -78
  2. package/dist/browser/client.js +1445 -753
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.d.ts +252 -129
  5. package/dist/browser/inspector/client.js +2077 -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 +2421 -2095
  13. package/dist/tsup/agent-os/index.cjs.map +1 -1
  14. package/dist/tsup/agent-os/index.d.cts +814 -88
  15. package/dist/tsup/agent-os/index.d.ts +814 -88
  16. package/dist/tsup/agent-os/index.js +2404 -2078
  17. package/dist/tsup/agent-os/index.js.map +1 -1
  18. package/dist/tsup/{chunk-LGZR4WHX.js → chunk-2OBVQZX6.js} +6 -6
  19. package/dist/tsup/chunk-2OBVQZX6.js.map +1 -0
  20. package/dist/tsup/chunk-3ZWHWMFJ.js +14 -0
  21. package/dist/tsup/chunk-3ZWHWMFJ.js.map +1 -0
  22. package/dist/tsup/{chunk-WQ4HNA4W.cjs → chunk-4KGXFC6M.cjs} +232 -18
  23. package/dist/tsup/chunk-4KGXFC6M.cjs.map +1 -0
  24. package/dist/tsup/{chunk-CQYUHACN.js → chunk-5IU3MI7X.js} +491 -58
  25. package/dist/tsup/chunk-5IU3MI7X.js.map +1 -0
  26. package/dist/tsup/{chunk-RSSGGFQA.js → chunk-6CXQMHZR.js} +968 -347
  27. package/dist/tsup/chunk-6CXQMHZR.js.map +1 -0
  28. package/dist/tsup/{chunk-RLAOOSJD.js → chunk-6W2UIH3X.js} +70 -8
  29. package/dist/tsup/chunk-6W2UIH3X.js.map +1 -0
  30. package/dist/tsup/{chunk-T6YVRM4K.js → chunk-6W5VGLFT.js} +231 -17
  31. package/dist/tsup/chunk-6W5VGLFT.js.map +1 -0
  32. package/dist/tsup/{chunk-XAMXMPDR.cjs → chunk-B73TBMMG.cjs} +18 -11
  33. package/dist/tsup/chunk-B73TBMMG.cjs.map +1 -0
  34. package/dist/tsup/chunk-D6TORRA4.js +243 -0
  35. package/dist/tsup/chunk-D6TORRA4.js.map +1 -0
  36. package/dist/tsup/{chunk-VKWY7G34.js → chunk-FXT3HN32.js} +2 -2
  37. package/dist/tsup/{chunk-K34B3OVG.js → chunk-IXBD7BXC.js} +47 -11
  38. package/dist/tsup/chunk-IXBD7BXC.js.map +1 -0
  39. package/dist/tsup/{chunk-3YY5S6TV.js → chunk-JI6GZ2C2.js} +3 -12
  40. package/dist/tsup/chunk-JI6GZ2C2.js.map +1 -0
  41. package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JTHHCZCZ.js} +24 -1
  42. package/dist/tsup/chunk-JTHHCZCZ.js.map +1 -0
  43. package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-KVFIONKQ.cjs} +25 -2
  44. package/dist/tsup/chunk-KVFIONKQ.cjs.map +1 -0
  45. package/dist/tsup/{chunk-7J7EWOUD.cjs → chunk-LGOWPZJ5.cjs} +3 -3
  46. package/dist/tsup/chunk-LGOWPZJ5.cjs.map +1 -0
  47. package/dist/tsup/chunk-LYNWTX6R.cjs +14 -0
  48. package/dist/tsup/chunk-LYNWTX6R.cjs.map +1 -0
  49. package/dist/tsup/{chunk-LD5YASJU.cjs → chunk-MYWZCDML.cjs} +3 -12
  50. package/dist/tsup/chunk-MYWZCDML.cjs.map +1 -0
  51. package/dist/tsup/{chunk-RH4D7BO3.js → chunk-NYDZLWHZ.js} +16 -9
  52. package/dist/tsup/chunk-NYDZLWHZ.js.map +1 -0
  53. package/dist/tsup/{chunk-B4XQ4QIY.cjs → chunk-RB7WUDX6.cjs} +1095 -474
  54. package/dist/tsup/chunk-RB7WUDX6.cjs.map +1 -0
  55. package/dist/tsup/{chunk-V3QNBJ7N.cjs → chunk-SPJORZMM.cjs} +48 -12
  56. package/dist/tsup/chunk-SPJORZMM.cjs.map +1 -0
  57. package/dist/tsup/chunk-SSMKIYEX.cjs +243 -0
  58. package/dist/tsup/chunk-SSMKIYEX.cjs.map +1 -0
  59. package/dist/tsup/{chunk-5VMFWRHI.cjs → chunk-TQ4HSX2U.cjs} +72 -10
  60. package/dist/tsup/chunk-TQ4HSX2U.cjs.map +1 -0
  61. package/dist/tsup/{chunk-3OCAQD6G.cjs → chunk-U6ZQELGJ.cjs} +10 -10
  62. package/dist/tsup/chunk-U6ZQELGJ.cjs.map +1 -0
  63. package/dist/tsup/{chunk-2VLNKGGO.cjs → chunk-XLBMKZD3.cjs} +499 -66
  64. package/dist/tsup/chunk-XLBMKZD3.cjs.map +1 -0
  65. package/dist/tsup/client/mod.cjs +8 -9
  66. package/dist/tsup/client/mod.cjs.map +1 -1
  67. package/dist/tsup/client/mod.d.cts +8 -7
  68. package/dist/tsup/client/mod.d.ts +8 -7
  69. package/dist/tsup/client/mod.js +7 -8
  70. package/dist/tsup/common/log.cjs +5 -3
  71. package/dist/tsup/common/log.cjs.map +1 -1
  72. package/dist/tsup/common/log.d.cts +5 -1
  73. package/dist/tsup/common/log.d.ts +5 -1
  74. package/dist/tsup/common/log.js +6 -4
  75. package/dist/tsup/common/websocket.cjs +4 -4
  76. package/dist/tsup/common/websocket.cjs.map +1 -1
  77. package/dist/tsup/common/websocket.js +3 -3
  78. package/dist/tsup/{config-C-a9vrke.d.cts → config-BXSV17G7.d.cts} +851 -57
  79. package/dist/tsup/{config-CvQUtDp9.d.ts → config-Bi1r6gI7.d.ts} +851 -57
  80. package/dist/tsup/{config-CxjGYf4K.d.cts → config-ey2I2zz5.d.cts} +59 -4
  81. package/dist/tsup/{config-CxjGYf4K.d.ts → config-ey2I2zz5.d.ts} +59 -4
  82. package/dist/tsup/context-4fJemY0D.d.cts +129 -0
  83. package/dist/tsup/context-D4sNYboo.d.ts +129 -0
  84. package/dist/tsup/db/drizzle.cjs +127 -67
  85. package/dist/tsup/db/drizzle.cjs.map +1 -1
  86. package/dist/tsup/db/drizzle.d.cts +8 -4
  87. package/dist/tsup/db/drizzle.d.ts +8 -4
  88. package/dist/tsup/db/drizzle.js +127 -67
  89. package/dist/tsup/db/drizzle.js.map +1 -1
  90. package/dist/tsup/db/mod.cjs +6 -124
  91. package/dist/tsup/db/mod.cjs.map +1 -1
  92. package/dist/tsup/db/mod.d.cts +12 -4
  93. package/dist/tsup/db/mod.d.ts +12 -4
  94. package/dist/tsup/db/mod.js +5 -123
  95. package/dist/tsup/db/mod.js.map +1 -1
  96. package/dist/tsup/dynamic/mod.cjs +24 -0
  97. package/dist/tsup/dynamic/mod.cjs.map +1 -0
  98. package/dist/tsup/dynamic/mod.d.cts +38 -0
  99. package/dist/tsup/dynamic/mod.d.ts +38 -0
  100. package/dist/tsup/dynamic/mod.js +24 -0
  101. package/dist/tsup/dynamic/mod.js.map +1 -0
  102. package/dist/tsup/inspector/mod.cjs +47 -12
  103. package/dist/tsup/inspector/mod.cjs.map +1 -1
  104. package/dist/tsup/inspector/mod.d.cts +26 -136
  105. package/dist/tsup/inspector/mod.d.ts +26 -136
  106. package/dist/tsup/inspector/mod.js +46 -11
  107. package/dist/tsup/inspector/mod.js.map +1 -1
  108. package/dist/tsup/inspector/workflow.cjs +21 -0
  109. package/dist/tsup/inspector/workflow.cjs.map +1 -0
  110. package/dist/tsup/inspector/workflow.d.cts +144 -0
  111. package/dist/tsup/inspector/workflow.d.ts +144 -0
  112. package/dist/tsup/inspector/workflow.js +21 -0
  113. package/dist/tsup/inspector/workflow.js.map +1 -0
  114. package/dist/tsup/inspector-tab/mod.cjs +162 -0
  115. package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
  116. package/dist/tsup/inspector-tab/mod.d.cts +241 -0
  117. package/dist/tsup/inspector-tab/mod.d.ts +241 -0
  118. package/dist/tsup/inspector-tab/mod.js +162 -0
  119. package/dist/tsup/inspector-tab/mod.js.map +1 -0
  120. package/dist/tsup/mod.cjs +2459 -671
  121. package/dist/tsup/mod.cjs.map +1 -1
  122. package/dist/tsup/mod.d.cts +8 -8
  123. package/dist/tsup/mod.d.ts +8 -8
  124. package/dist/tsup/mod.js +2392 -604
  125. package/dist/tsup/mod.js.map +1 -1
  126. package/dist/tsup/test/mod.cjs +26 -21
  127. package/dist/tsup/test/mod.cjs.map +1 -1
  128. package/dist/tsup/test/mod.d.cts +6 -6
  129. package/dist/tsup/test/mod.d.ts +6 -6
  130. package/dist/tsup/test/mod.js +25 -20
  131. package/dist/tsup/test/mod.js.map +1 -1
  132. package/dist/tsup/unstable/migrations.cjs +101 -0
  133. package/dist/tsup/unstable/migrations.cjs.map +1 -0
  134. package/dist/tsup/unstable/migrations.d.cts +29 -0
  135. package/dist/tsup/unstable/migrations.d.ts +29 -0
  136. package/dist/tsup/unstable/migrations.js +101 -0
  137. package/dist/tsup/unstable/migrations.js.map +1 -0
  138. package/dist/tsup/utils-Bbz-3411.d.cts +162 -0
  139. package/dist/tsup/utils-BqdWVlzm.d.ts +162 -0
  140. package/dist/tsup/utils-vvJQyygr.d.cts +109 -0
  141. package/dist/tsup/utils-vvJQyygr.d.ts +109 -0
  142. package/dist/tsup/utils.cjs +7 -3
  143. package/dist/tsup/utils.cjs.map +1 -1
  144. package/dist/tsup/utils.d.cts +4 -147
  145. package/dist/tsup/utils.d.ts +4 -147
  146. package/dist/tsup/utils.js +6 -2
  147. package/dist/tsup/workflow/mod.cjs +517 -412
  148. package/dist/tsup/workflow/mod.cjs.map +1 -1
  149. package/dist/tsup/workflow/mod.d.cts +10 -10
  150. package/dist/tsup/workflow/mod.d.ts +10 -10
  151. package/dist/tsup/workflow/mod.js +511 -406
  152. package/dist/tsup/workflow/mod.js.map +1 -1
  153. package/package.json +61 -15
  154. package/src/actor/actions.ts +119 -0
  155. package/src/actor/config.test.ts +78 -0
  156. package/src/actor/config.ts +505 -88
  157. package/src/actor/contexts/index.ts +7 -2
  158. package/src/actor/definition.ts +38 -26
  159. package/src/actor/errors.ts +98 -8
  160. package/src/actor/keys.ts +1 -1
  161. package/src/actor/mod.ts +32 -21
  162. package/src/actor/schema.ts +2 -2
  163. package/src/agent-os/actor/index.ts +39 -19
  164. package/src/agent-os/actor/preview.ts +1 -2
  165. package/src/agent-os/actor/session.ts +2 -2
  166. package/src/agent-os/config.ts +1 -1
  167. package/src/agent-os/fs/database-vfs.ts +1 -1
  168. package/src/agent-os/index.ts +16 -15
  169. package/src/client/actor-common.ts +80 -54
  170. package/src/client/actor-conn.ts +64 -68
  171. package/src/client/actor-handle.ts +147 -72
  172. package/src/client/actor-query.ts +13 -6
  173. package/src/client/client.ts +35 -11
  174. package/src/client/errors.ts +4 -2
  175. package/src/client/lifecycle-errors.ts +2 -4
  176. package/src/client/query.ts +3 -1
  177. package/src/client/queue.ts +8 -3
  178. package/src/client/raw-utils.ts +14 -15
  179. package/src/client/resolve-gateway-target.ts +3 -1
  180. package/src/client/utils.ts +36 -10
  181. package/src/common/actor-router-consts.ts +4 -0
  182. package/src/common/actor-websocket.ts +3 -1
  183. package/src/common/bare/actor-persist/v1.ts +205 -163
  184. package/src/common/bare/actor-persist/v2.ts +265 -213
  185. package/src/common/bare/actor-persist/v3.ts +176 -172
  186. package/src/common/bare/actor-persist/v4.ts +254 -253
  187. package/src/common/bare/generated/actor-runtime-socket-protocol/v1.ts +848 -0
  188. package/src/common/bare/generated/client-protocol/v4.ts +599 -0
  189. package/src/common/bare/generated/inspector/v5.ts +1016 -0
  190. package/src/common/bare/generated/inspector/v6.ts +1367 -0
  191. package/src/common/bare/transport/v1.ts +694 -542
  192. package/src/common/client-protocol-versioned.ts +176 -67
  193. package/src/common/client-protocol-zod.ts +7 -0
  194. package/src/common/client-protocol.ts +1 -1
  195. package/src/common/database/config.ts +74 -9
  196. package/src/common/database/mod.test.ts +285 -58
  197. package/src/common/database/mod.ts +259 -77
  198. package/src/common/database/native-database.test.ts +44 -0
  199. package/src/common/database/native-database.ts +198 -4
  200. package/src/common/database/shared.ts +25 -0
  201. package/src/common/encoding.ts +278 -34
  202. package/src/common/engine.ts +28 -1
  203. package/src/common/eventsource.ts +1 -1
  204. package/src/common/fetch-like.ts +49 -0
  205. package/src/common/inline-websocket-adapter.ts +14 -13
  206. package/src/common/inspector-transport.ts +12 -2
  207. package/src/common/log.ts +15 -8
  208. package/src/common/router.ts +49 -23
  209. package/src/common/utils.ts +16 -202
  210. package/src/common/websocket-interface.ts +1 -1
  211. package/src/db/drizzle.test.ts +164 -0
  212. package/src/db/drizzle.ts +182 -80
  213. package/src/db/mod.ts +4 -1
  214. package/src/devtools-loader/index.ts +4 -7
  215. package/src/devtools-loader/serve-devtools.ts +26 -0
  216. package/src/dynamic/instance.ts +32 -0
  217. package/src/dynamic/internal.ts +50 -0
  218. package/src/dynamic/isolate-runtime.ts +64 -0
  219. package/src/dynamic/mod.ts +32 -0
  220. package/src/engine-client/actor-http-client.ts +3 -3
  221. package/src/engine-client/actor-websocket-client.ts +6 -5
  222. package/src/engine-client/api-endpoints.ts +51 -2
  223. package/src/engine-client/api-utils.ts +2 -2
  224. package/src/engine-client/driver.ts +5 -16
  225. package/src/engine-client/mod.ts +19 -48
  226. package/src/engine-client/ws-proxy.ts +9 -4
  227. package/src/inspector/client.browser.ts +127 -15
  228. package/src/inspector/mod.ts +2 -4
  229. package/src/inspector/workflow.ts +61 -0
  230. package/src/inspector-tab/mod.ts +301 -0
  231. package/src/registry/config/envoy.ts +1 -2
  232. package/src/registry/config/index.ts +41 -55
  233. package/src/registry/index.ts +554 -91
  234. package/src/registry/napi-runtime.ts +406 -23
  235. package/src/registry/native-validation.ts +10 -12
  236. package/src/registry/native.ts +1288 -551
  237. package/src/registry/process-metrics.ts +250 -0
  238. package/src/registry/run-handler-coordinator.test.ts +252 -0
  239. package/src/registry/run-handler-coordinator.ts +219 -0
  240. package/src/registry/runtime.ts +270 -9
  241. package/src/registry/wasm-runtime.ts +407 -22
  242. package/src/registry/write-through-proxy.ts +141 -0
  243. package/src/serde.ts +2 -2
  244. package/src/serverless/configure.ts +18 -7
  245. package/src/test/mod.ts +2 -17
  246. package/src/test/ready.ts +22 -0
  247. package/src/unstable/migrations.test.ts +170 -0
  248. package/src/unstable/migrations.ts +141 -0
  249. package/src/utils/endpoint-parser.ts +1 -1
  250. package/src/utils/env-vars.ts +37 -0
  251. package/src/utils/node.ts +44 -28
  252. package/src/utils/router.ts +1 -1
  253. package/src/utils.ts +4 -2
  254. package/src/workflow/context.ts +683 -242
  255. package/src/workflow/driver.test.ts +62 -0
  256. package/src/workflow/driver.ts +246 -119
  257. package/src/workflow/inspector.ts +24 -24
  258. package/src/workflow/mod.ts +76 -84
  259. package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
  260. package/dist/tsup/chunk-2VLNKGGO.cjs.map +0 -1
  261. package/dist/tsup/chunk-3OCAQD6G.cjs.map +0 -1
  262. package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
  263. package/dist/tsup/chunk-5VMFWRHI.cjs.map +0 -1
  264. package/dist/tsup/chunk-5VUPNZ5I.cjs +0 -268
  265. package/dist/tsup/chunk-5VUPNZ5I.cjs.map +0 -1
  266. package/dist/tsup/chunk-7J7EWOUD.cjs.map +0 -1
  267. package/dist/tsup/chunk-B4XQ4QIY.cjs.map +0 -1
  268. package/dist/tsup/chunk-CQYUHACN.js.map +0 -1
  269. package/dist/tsup/chunk-K34B3OVG.js.map +0 -1
  270. package/dist/tsup/chunk-LD5YASJU.cjs.map +0 -1
  271. package/dist/tsup/chunk-LGZR4WHX.js.map +0 -1
  272. package/dist/tsup/chunk-NETDFNJW.js +0 -268
  273. package/dist/tsup/chunk-NETDFNJW.js.map +0 -1
  274. package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
  275. package/dist/tsup/chunk-RH4D7BO3.js.map +0 -1
  276. package/dist/tsup/chunk-RLAOOSJD.js.map +0 -1
  277. package/dist/tsup/chunk-RSSGGFQA.js.map +0 -1
  278. package/dist/tsup/chunk-T6YVRM4K.js.map +0 -1
  279. package/dist/tsup/chunk-V3QNBJ7N.cjs.map +0 -1
  280. package/dist/tsup/chunk-WQ4HNA4W.cjs.map +0 -1
  281. package/dist/tsup/chunk-XAMXMPDR.cjs.map +0 -1
  282. package/dist/tsup/context-A7R0bsZL.d.ts +0 -92
  283. package/dist/tsup/context-CA3r-pf2.d.cts +0 -92
  284. package/dist/tsup/utils-fwx3o3K9.d.cts +0 -18
  285. package/dist/tsup/utils-fwx3o3K9.d.ts +0 -18
  286. package/src/actor/driver.ts +0 -141
  287. package/src/actor/instance/mod.ts +0 -2492
  288. package/src/drivers/engine/actor-driver.ts +0 -2470
  289. package/src/utils/serve.ts +0 -217
  290. /package/dist/tsup/{chunk-VKWY7G34.js.map → chunk-FXT3HN32.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';
@@ -13,7 +13,7 @@ interface ActorMetricsLike {
13
13
  totalKvWrites: number;
14
14
  trackSql(query: string, durationMs: number): void;
15
15
  }
16
- type InferDatabaseClient<DBProvider extends AnyDatabaseProvider> = DBProvider extends DatabaseProvider<any> ? Awaited<ReturnType<DBProvider["createClient"]>> : never;
16
+ type InferDatabaseClient<DBProvider extends AnyDatabaseProvider> = DBProvider extends DatabaseProvider<any> ? Awaited<ReturnType<DBProvider["createClient"]>> : RawAccess;
17
17
  type SqliteBindings = unknown[] | Record<string, unknown>;
18
18
  interface SqliteQueryResult {
19
19
  columns: string[];
@@ -23,6 +23,45 @@ 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
+ /** @experimental */
36
+ experimental?: {
37
+ /**
38
+ * Atomically includes actor and hibernatable connection state.
39
+ * Only single-statement `execute` calls are supported in the transaction.
40
+ * Concurrent actions that try to mutate state while the transaction is
41
+ * active fail with `actor.state_transaction_conflict`.
42
+ */
43
+ includeState?: boolean;
44
+ };
45
+ }
46
+ /**
47
+ * SQLite profiling configuration.
48
+ *
49
+ * @experimental This entire configuration surface is experimental and subject
50
+ * to change without notice.
51
+ */
52
+ interface SqliteProfilingOptions {
53
+ enabled?: boolean;
54
+ maxTrackedStatementFingerprints?: number;
55
+ maxTrackedTransactionFingerprints?: number;
56
+ maxPrometheusSeries?: number;
57
+ maxStatementsPerTransactionTrace?: number;
58
+ maxGetPagesRequestsPerTrace?: number;
59
+ maxTransactionNameBytes?: number;
60
+ slowOperationThresholdMs?: number;
61
+ baselineSampleRate?: number;
62
+ maxDiagnosticEventsPerMinute?: number;
63
+ diagnosticEventQueueCapacity?: number;
64
+ }
26
65
  interface SqliteNativeMetrics {
27
66
  requestBuildNs: number;
28
67
  serializeNs: number;
@@ -39,11 +78,19 @@ interface SqliteNativeMetrics {
39
78
  interface SqliteDatabase {
40
79
  exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
41
80
  execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
81
+ executeBatch(statements: SqliteBatchStatement[]): Promise<SqliteExecuteResult[]>;
82
+ beginTransaction(timeoutMs?: number, name?: string): Promise<SqliteTransactionDatabase>;
42
83
  run(sql: string, params?: SqliteBindings): Promise<void>;
43
84
  query(sql: string, params?: SqliteBindings): Promise<SqliteQueryResult>;
44
85
  nativeMetrics?(): SqliteNativeMetrics | Promise<SqliteNativeMetrics | null> | null;
45
86
  close(): Promise<void>;
46
87
  }
88
+ interface SqliteTransactionDatabase {
89
+ exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
90
+ execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
91
+ commit(): Promise<void>;
92
+ rollback(): Promise<void>;
93
+ }
47
94
  /**
48
95
  * Provider for opening native databases from the active runtime.
49
96
  */
@@ -87,6 +134,13 @@ interface DatabaseProviderContext {
87
134
  nativeDatabaseProvider?: NativeDatabaseProvider;
88
135
  }
89
136
  type DatabaseProvider<DB extends RawAccess> = {
137
+ /**
138
+ * Local SQLite profiling controls consumed by the actor runtime.
139
+ *
140
+ * @experimental This entire configuration surface is experimental and
141
+ * subject to change without notice.
142
+ */
143
+ sqliteProfiling?: SqliteProfilingOptions;
90
144
  /**
91
145
  * Creates a new database client for the actor.
92
146
  * The result is passed to the actor context as `c.db`.
@@ -103,14 +157,15 @@ type DatabaseProvider<DB extends RawAccess> = {
103
157
  /**
104
158
  * Drizzle database client interface (will be extended by drizzle-orm types)
105
159
  */
106
- interface DrizzleDatabaseClient {
107
- }
160
+ type DrizzleDatabaseClient = {};
108
161
  type ExecuteFunction = <TRow extends Record<string, unknown> = Record<string, unknown>>(query: string, ...args: unknown[]) => Promise<TRow[]>;
109
162
  type RawAccess = {
110
163
  /**
111
164
  * Executes a raw SQL query.
112
165
  */
113
166
  execute: ExecuteFunction;
167
+ /** Runs a callback in an isolated SQLite transaction. */
168
+ transaction: <T>(callback: (tx: RawAccess) => Promise<T> | T, options?: SqliteTransactionOptions) => Promise<T>;
114
169
  /**
115
170
  * Returns native SQLite metrics when the active runtime supports them.
116
171
  */
@@ -150,6 +205,7 @@ declare const CreateRequestSchema: z.ZodObject<{
150
205
  key: z.ZodArray<z.ZodString>;
151
206
  input: z.ZodOptional<z.ZodUnknown>;
152
207
  region: z.ZodOptional<z.ZodString>;
208
+ poolName: z.ZodOptional<z.ZodString>;
153
209
  }, z.core.$strip>;
154
210
  declare const ActorQuerySchema: z.ZodUnion<readonly [z.ZodObject<{
155
211
  getForId: z.ZodObject<{
@@ -167,6 +223,7 @@ declare const ActorQuerySchema: z.ZodUnion<readonly [z.ZodObject<{
167
223
  key: z.ZodArray<z.ZodString>;
168
224
  input: z.ZodOptional<z.ZodUnknown>;
169
225
  region: z.ZodOptional<z.ZodString>;
226
+ poolName: z.ZodOptional<z.ZodString>;
170
227
  }, z.core.$strip>;
171
228
  }, z.core.$strip>, z.ZodObject<{
172
229
  create: z.ZodObject<{
@@ -174,6 +231,7 @@ declare const ActorQuerySchema: z.ZodUnion<readonly [z.ZodObject<{
174
231
  key: z.ZodArray<z.ZodString>;
175
232
  input: z.ZodOptional<z.ZodUnknown>;
176
233
  region: z.ZodOptional<z.ZodString>;
234
+ poolName: z.ZodOptional<z.ZodString>;
177
235
  }, z.core.$strip>;
178
236
  }, z.core.$strip>]>;
179
237
  type ActorQuery = z.infer<typeof ActorQuerySchema>;
@@ -182,6 +240,44 @@ type ActorQuery = z.infer<typeof ActorQuerySchema>;
182
240
  */
183
241
  type CreateRequest = z.infer<typeof CreateRequestSchema>;
184
242
 
243
+ type SchemaHookResult = boolean | Promise<boolean>;
244
+ type SchemaHook<TContext = any> = (ctx: TContext) => SchemaHookResult;
245
+ interface EventTypeToken<T, TContext = any> {
246
+ readonly _eventType?: T;
247
+ readonly canSubscribe?: SchemaHook<TContext>;
248
+ readonly schema?: PrimitiveSchema;
249
+ }
250
+ interface QueueTypeToken<TMessage, TComplete = never, TContext = any> {
251
+ readonly _queueMessage?: TMessage;
252
+ readonly _queueComplete?: TComplete;
253
+ readonly canPublish?: SchemaHook<TContext>;
254
+ readonly message?: PrimitiveSchema;
255
+ readonly complete?: PrimitiveSchema;
256
+ }
257
+ type PrimitiveSchema = StandardSchemaV1 | EventTypeToken<unknown, any>;
258
+ interface EventSchemaDefinition<TContext = any> {
259
+ schema: PrimitiveSchema;
260
+ canSubscribe?: SchemaHook<TContext>;
261
+ }
262
+ interface QueueSchemaDefinition<TContext = any> {
263
+ message: PrimitiveSchema;
264
+ complete?: PrimitiveSchema;
265
+ canPublish?: SchemaHook<TContext>;
266
+ }
267
+ type EventSchema<TContext = any> = PrimitiveSchema | EventSchemaDefinition<TContext>;
268
+ type QueueSchema = PrimitiveSchema | QueueSchemaDefinition<any> | QueueTypeToken<unknown, unknown, any>;
269
+ type EventSchemaConfig<TContext = any> = Record<string, EventSchema<TContext>>;
270
+ type QueueSchemaConfig<_TContext = any> = Record<string, QueueSchema>;
271
+ type InferSchema<T> = T extends QueueSchemaDefinition<any> ? InferSchema<T["message"]> : T extends QueueTypeToken<infer M, unknown, any> ? M : T extends EventSchemaDefinition<any> ? InferSchema<T["schema"]> : T extends StandardSchemaV1<any, infer O> ? O : T extends EventTypeToken<infer R, any> ? R : never;
272
+ type InferSchemaMap<T extends Record<string, unknown>> = {
273
+ [K in keyof T]: InferSchema<T[K]>;
274
+ };
275
+ type InferQueueComplete<T> = T extends QueueTypeToken<unknown, infer C, any> ? [C] extends [never] ? never : C : T extends QueueSchemaDefinition<any> ? T["complete"] extends PrimitiveSchema ? InferSchema<T["complete"]> : never : never;
276
+ type InferQueueCompleteMap<T extends QueueSchemaConfig> = {
277
+ [K in keyof T]: InferQueueComplete<T[K]>;
278
+ };
279
+ type InferEventArgs<T> = T extends readonly unknown[] ? number extends T["length"] ? [T] : T : [T];
280
+
185
281
  interface DeconstructedError {
186
282
  __type: "ActorError";
187
283
  statusCode: ContentfulStatusCode;
@@ -190,6 +286,8 @@ interface DeconstructedError {
190
286
  code: string;
191
287
  message: string;
192
288
  metadata?: unknown;
289
+ rayId?: string;
290
+ actor?: ActorSpecifier;
193
291
  }
194
292
 
195
293
  interface RivetErrorOptions extends ErrorOptions {
@@ -197,8 +295,18 @@ interface RivetErrorOptions extends ErrorOptions {
197
295
  public?: boolean;
198
296
  /** Metadata associated with this error. */
199
297
  metadata?: unknown;
298
+ /** Request identifier used to correlate this error with engine logs. */
299
+ rayId?: string;
200
300
  /** Explicit HTTP status override for router responses. */
201
301
  statusCode?: number;
302
+ /** Actor context associated with this error. */
303
+ actor?: ActorSpecifier;
304
+ }
305
+ /** Identifies the actor that was handling work when an error was produced. */
306
+ interface ActorSpecifier {
307
+ actorId: string;
308
+ generation: number;
309
+ key?: string;
202
310
  }
203
311
  interface UserErrorOptions extends ErrorOptions {
204
312
  /**
@@ -216,7 +324,9 @@ declare class RivetError extends Error {
216
324
  __type: "RivetError";
217
325
  public: boolean;
218
326
  metadata?: unknown;
327
+ readonly rayId?: string;
219
328
  statusCode: number;
329
+ actor?: ActorSpecifier;
220
330
  readonly group: string;
221
331
  readonly code: string;
222
332
  static isRivetError(error: unknown): error is RivetError | DeconstructedError;
@@ -229,44 +339,6 @@ declare class UserError extends RivetError {
229
339
  constructor(message: string, options?: UserErrorOptions);
230
340
  }
231
341
 
232
- type SchemaHookResult = boolean | Promise<boolean>;
233
- type SchemaHook<TContext = any> = (ctx: TContext) => SchemaHookResult;
234
- interface EventTypeToken<T, TContext = any> {
235
- readonly _eventType?: T;
236
- readonly canSubscribe?: SchemaHook<TContext>;
237
- readonly schema?: PrimitiveSchema;
238
- }
239
- interface QueueTypeToken<TMessage, TComplete = never, TContext = any> {
240
- readonly _queueMessage?: TMessage;
241
- readonly _queueComplete?: TComplete;
242
- readonly canPublish?: SchemaHook<TContext>;
243
- readonly message?: PrimitiveSchema;
244
- readonly complete?: PrimitiveSchema;
245
- }
246
- type PrimitiveSchema = StandardSchemaV1 | EventTypeToken<unknown, any>;
247
- interface EventSchemaDefinition<TContext = any> {
248
- schema: PrimitiveSchema;
249
- canSubscribe?: SchemaHook<TContext>;
250
- }
251
- interface QueueSchemaDefinition<TContext = any> {
252
- message: PrimitiveSchema;
253
- complete?: PrimitiveSchema;
254
- canPublish?: SchemaHook<TContext>;
255
- }
256
- type EventSchema<TContext = any> = PrimitiveSchema | EventSchemaDefinition<TContext>;
257
- type QueueSchema = PrimitiveSchema | QueueSchemaDefinition<any> | QueueTypeToken<unknown, unknown, any>;
258
- type EventSchemaConfig<TContext = any> = Record<string, EventSchema<TContext>>;
259
- type QueueSchemaConfig<TContext = any> = Record<string, QueueSchema>;
260
- 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;
261
- type InferSchemaMap<T extends Record<string, unknown>> = {
262
- [K in keyof T]: InferSchema<T[K]>;
263
- };
264
- 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;
265
- type InferQueueCompleteMap<T extends QueueSchemaConfig> = {
266
- [K in keyof T]: InferQueueComplete<T[K]>;
267
- };
268
- type InferEventArgs<T> = T extends readonly unknown[] ? number extends T["length"] ? [T] : T : [T];
269
-
270
342
  type UpgradeWebSocket = (createEvents: (c: Context) => any) => Handler;
271
343
  type GetUpgradeWebSocket = () => UpgradeWebSocket;
272
344
 
@@ -296,11 +368,6 @@ interface EngineControlClient {
296
368
  * Test-only helper that simulates an abrupt actor crash.
297
369
  */
298
370
  hardCrashActor?(actorId: string): Promise<void>;
299
- kvGet(actorId: string, key: Uint8Array): Promise<string | null>;
300
- kvBatchGet(actorId: string, keys: Uint8Array[]): Promise<(Uint8Array | null)[]>;
301
- kvBatchPut(actorId: string, entries: [Uint8Array, Uint8Array][]): Promise<void>;
302
- kvBatchDelete(actorId: string, keys: Uint8Array[]): Promise<void>;
303
- kvDeleteRange(actorId: string, start: Uint8Array, end: Uint8Array): Promise<void>;
304
371
  }
305
372
  interface RuntimeDisplayInformation {
306
373
  properties: Record<string, string>;
@@ -322,6 +389,8 @@ interface GetOrCreateWithKeyInput {
322
389
  input?: unknown;
323
390
  region?: string;
324
391
  crashPolicy?: CrashPolicy;
392
+ /** Overrides the client's configured pool name for this actor. */
393
+ poolName?: string;
325
394
  }
326
395
  interface CreateInput {
327
396
  c?: Context | undefined;
@@ -330,6 +399,8 @@ interface CreateInput {
330
399
  input?: unknown;
331
400
  region?: string;
332
401
  crashPolicy?: CrashPolicy;
402
+ /** Overrides the client's configured pool name for this actor. */
403
+ poolName?: string;
333
404
  }
334
405
  interface ListActorsInput {
335
406
  c?: Context | undefined;
@@ -374,6 +445,14 @@ interface QueueSendResult<TResponse = unknown> {
374
445
  * @returns {Promise<Response>}
375
446
  */
376
447
  type ActorActionFunction<Args extends Array<unknown> = unknown[], Response = unknown> = (...args: Args extends [unknown, ...infer Rest] ? Rest : Args) => Promise<Response>;
448
+ type IsAny<T> = 0 extends 1 & T ? true : false;
449
+ type LooseEventSubscribe = (eventName: string, callback: (...args: any[]) => void) => () => void;
450
+ type ActorActionMap<R> = {
451
+ [K in keyof NonNullable<R>]: NonNullable<R>[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Awaited<Return>> : NonNullable<R>[K] extends Record<string, unknown> ? ActorActionMap<NonNullable<R>[K]> : never;
452
+ };
453
+ type ActionsOf<AD extends AnyActorDefinition> = AD["config"] extends {
454
+ actions?: infer R;
455
+ } ? R : never;
377
456
  interface ActorGatewayOptions {
378
457
  skipReadyWait?: boolean;
379
458
  }
@@ -386,9 +465,7 @@ type ActorWebSocketOptions = ActorGatewayOptions;
386
465
  /**
387
466
  * Maps action methods from actor definition to typed function signatures.
388
467
  */
389
- type ActorDefinitionActions<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<any, any, any, any, any, any, any, any, infer R> ? {
390
- [K in keyof R]: R[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Return> : never;
391
- } : never;
468
+ type ActorDefinitionActions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? Record<string, ActorActionFunction<any[], any>> : ActorActionMap<ActionsOf<AD>>;
392
469
  type ActorQueueSend<TQueues extends QueueSchemaConfig> = {
393
470
  <K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options: QueueSendWaitOptions): Promise<QueueSendResult<InferQueueCompleteMap<TQueues>[K]>>;
394
471
  <K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options?: QueueSendNoWaitOptions): Promise<void>;
@@ -399,13 +476,31 @@ type ActorEventSubscribe<TEvents extends EventSchemaConfig> = {
399
476
  <K extends keyof TEvents & string>(eventName: K, callback: (...args: InferEventArgs<InferSchemaMap<TEvents>[K]>) => void): () => void;
400
477
  (eventName: keyof TEvents extends never ? string : never, callback: (...args: any[]) => void): () => void;
401
478
  };
402
- type ActorDefinitionQueueSend<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<any, any, any, any, any, any, any, infer Q, any> ? Q extends QueueSchemaConfig ? {
479
+ type ActorDefinitionQueueSend<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
480
+ send: ActorQueueSend<Record<string, any>>;
481
+ } : AD extends {
482
+ config: {
483
+ queues?: infer Q;
484
+ };
485
+ } ? Q extends QueueSchemaConfig ? {
486
+ send: ActorQueueSend<Q>;
487
+ } : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, any, infer Q, any> ? Q extends QueueSchemaConfig ? {
403
488
  send: ActorQueueSend<Q>;
404
- } : never : never;
405
- type ActorDefinitionEventSubscriptions<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<any, any, any, any, any, any, infer E, any, any> ? E extends EventSchemaConfig ? {
489
+ } : {} : {};
490
+ type ActorDefinitionEventSubscriptions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
491
+ on: LooseEventSubscribe;
492
+ once: LooseEventSubscribe;
493
+ } : AD extends {
494
+ config: {
495
+ events?: infer E;
496
+ };
497
+ } ? E extends EventSchemaConfig ? {
406
498
  on: ActorEventSubscribe<E>;
407
499
  once: ActorEventSubscribe<E>;
408
- } : never : never;
500
+ } : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, infer E, any, any> ? E extends EventSchemaConfig ? {
501
+ on: ActorEventSubscribe<E>;
502
+ once: ActorEventSubscribe<E>;
503
+ } : {} : {};
409
504
 
410
505
  declare class ActorClientError extends Error {
411
506
  }
@@ -814,6 +909,11 @@ interface GetOrCreateOptions extends QueryOptions {
814
909
  createInRegion?: string;
815
910
  /** Input data to pass to the actor. */
816
911
  createWithInput?: unknown;
912
+ /**
913
+ * Name of the envoy pool to select for this actor if it is created.
914
+ * Overrides the client's configured `poolName` for this call.
915
+ */
916
+ poolName?: string;
817
917
  }
818
918
  /**
819
919
  * Options for creating a actor.
@@ -825,6 +925,11 @@ interface CreateOptions extends QueryOptions {
825
925
  region?: string;
826
926
  /** Input data to pass to the actor. */
827
927
  input?: unknown;
928
+ /**
929
+ * Name of the envoy pool to select for this actor.
930
+ * Overrides the client's configured `poolName` for this call.
931
+ */
932
+ poolName?: string;
828
933
  }
829
934
  /**
830
935
  * Represents a region to connect to.
@@ -918,7 +1023,11 @@ type Client<A extends Registry<any>> = ClientRaw & {
918
1023
  [K in keyof ExtractActorsFromRegistry<A>]: ActorAccessor<ExtractActorsFromRegistry<A>[K]>;
919
1024
  };
920
1025
 
1026
+ /** @experimental State exposed by a durable workflow run handler to the Inspector. */
1027
+ type WorkflowState = "pending" | "running" | "sleeping" | "failed" | "completed" | "cancelled" | "rolling_back";
1028
+
921
1029
  declare const ACTOR_CONTEXT_INTERNAL_SYMBOL: unique symbol;
1030
+ declare const RAW_STATE_SYMBOL: unique symbol;
922
1031
  interface ActorLogger {
923
1032
  level: any;
924
1033
  fatal: any;
@@ -951,6 +1060,10 @@ type ActorKvListOptions<T extends ActorKvValueType = "text", K extends ActorKvKe
951
1060
  limit?: number;
952
1061
  };
953
1062
  type ActorClientFor<T> = T extends Registry<any> ? Client<T> : T;
1063
+ /**
1064
+ * @deprecated Actor KV is deprecated. Use embedded SQLite (`c.db`)
1065
+ * or actor state instead.
1066
+ */
954
1067
  interface ActorKv {
955
1068
  get<T extends ActorKvValueType = "text">(key: Uint8Array | string, options?: ActorKvValueOptions<T>): Promise<ActorKvValueTypeMap[T] | null>;
956
1069
  put<T extends ActorKvValueType = "text">(key: Uint8Array | string, value: Uint8Array | string | ArrayBuffer, options?: ActorKvValueOptions<T>): Promise<void>;
@@ -965,10 +1078,76 @@ interface ActorKv {
965
1078
  [key: string]: any;
966
1079
  }
967
1080
  interface ActorSchedule {
968
- after(duration: number, action: string, ...args: unknown[]): Promise<void>;
969
- at(timestamp: number, action: string, ...args: unknown[]): Promise<void>;
1081
+ after(duration: number, action: string, ...args: unknown[]): Promise<string>;
1082
+ at(timestamp: number, action: string, ...args: unknown[]): Promise<string>;
1083
+ cancel(id: string): Promise<boolean>;
1084
+ get(id: string): Promise<ScheduledEventInfo | undefined>;
1085
+ list(): Promise<ScheduledEventInfo[]>;
1086
+ [key: string]: any;
1087
+ }
1088
+ interface ActorCronSetOptions {
1089
+ name: string;
1090
+ expression: string;
1091
+ action: string;
1092
+ args?: unknown[];
1093
+ timezone?: string;
1094
+ /** Defaults to 100. Set to 0 to disable and clear history. Maximum 1,000. */
1095
+ maxHistory?: number;
1096
+ }
1097
+ interface ActorCronEveryOptions {
1098
+ name: string;
1099
+ /** Fixed interval in milliseconds. Minimum 5,000. */
1100
+ interval: number;
1101
+ action: string;
1102
+ args?: unknown[];
1103
+ /** Defaults to 100. Set to 0 to disable and clear history. Maximum 1,000. */
1104
+ maxHistory?: number;
1105
+ }
1106
+ interface ActorCron {
1107
+ set(options: ActorCronSetOptions): Promise<void>;
1108
+ every(options: ActorCronEveryOptions): Promise<void>;
1109
+ get(name: string): Promise<CronJobInfo | undefined>;
1110
+ list(): Promise<CronJobInfo[]>;
1111
+ delete(name: string): Promise<boolean>;
1112
+ history(name: string, options?: {
1113
+ limit?: number;
1114
+ }): Promise<CronFire[]>;
970
1115
  [key: string]: any;
971
1116
  }
1117
+ interface ScheduledEventInfo {
1118
+ id: string;
1119
+ action: string;
1120
+ args: unknown[];
1121
+ runAt: number;
1122
+ }
1123
+ type CronJobInfo = {
1124
+ name: string;
1125
+ action: string;
1126
+ args: unknown[];
1127
+ nextRunAt: number;
1128
+ lastRunAt?: number;
1129
+ maxHistory: number;
1130
+ } & ({
1131
+ kind: "cron";
1132
+ expression: string;
1133
+ timezone: string;
1134
+ } | {
1135
+ kind: "every";
1136
+ interval: number;
1137
+ });
1138
+ interface CronFire {
1139
+ action: string;
1140
+ scheduledAt: number;
1141
+ firedAt: number;
1142
+ finishedAt?: number;
1143
+ result: "running" | "ok" | "error" | "skipped";
1144
+ error?: {
1145
+ group: string;
1146
+ code: string;
1147
+ message: string;
1148
+ metadata?: unknown;
1149
+ };
1150
+ }
972
1151
  type QueueMessageOf<Name extends string, Body> = {
973
1152
  id: number | bigint;
974
1153
  name: Name;
@@ -979,6 +1158,8 @@ type QueueMessageOf<Name extends string, Body> = {
979
1158
  type QueueName<TQueues extends QueueSchemaConfig> = keyof TQueues & string;
980
1159
  type QueueFilterName<TQueues extends QueueSchemaConfig> = keyof TQueues extends never ? string : QueueName<TQueues>;
981
1160
  type QueueMessageForName<TQueues extends QueueSchemaConfig, TName extends QueueFilterName<TQueues>> = keyof TQueues extends never ? QueueMessageOf<string, unknown> : TName extends QueueName<TQueues> ? QueueMessageOf<TName, InferSchemaMap<TQueues>[TName]> : never;
1161
+ type QueueCompleteArgs<T> = undefined extends T ? [response?: T] : [response: T];
1162
+ type QueueCompleteArgsForName<TQueues extends QueueSchemaConfig, TName extends QueueFilterName<TQueues>> = keyof TQueues extends never ? [response?: unknown] : TName extends QueueName<TQueues> ? [InferQueueCompleteMap<TQueues>[TName]] extends [never] ? [response?: unknown] : QueueCompleteArgs<InferQueueCompleteMap<TQueues>[TName]> : [response?: unknown];
982
1163
  type QueueCompletionResultForName<TQueues extends QueueSchemaConfig, TName extends QueueFilterName<TQueues>> = keyof TQueues extends never ? unknown | undefined : TName extends QueueName<TQueues> ? InferQueueCompleteMap<TQueues>[TName] | undefined : unknown | undefined;
983
1164
  interface QueueNextOptions<TName extends string = string, TCompletable extends boolean = boolean> {
984
1165
  names?: readonly TName[];
@@ -1021,13 +1202,20 @@ interface ActorQueue<TQueues extends QueueSchemaConfig = Record<never, never>> {
1021
1202
  next<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueNextOptions<TName, TCompletable>): Promise<any>;
1022
1203
  nextBatch<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueNextBatchOptions<TName, TCompletable>): Promise<any[]>;
1023
1204
  waitForNames<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(names: readonly TName[], opts?: QueueWaitOptions<TCompletable>): Promise<any>;
1205
+ /** @experimental */
1206
+ waitForAvailable<const TName extends QueueFilterName<TQueues>>(names?: readonly TName[], opts?: Omit<QueueWaitOptions<false>, "completable">): Promise<void>;
1207
+ /** @experimental */
1208
+ complete<const TName extends QueueFilterName<TQueues>>(message: {
1209
+ id: number | bigint;
1210
+ name: TName;
1211
+ }, ...args: QueueCompleteArgsForName<TQueues, TName>): Promise<void>;
1024
1212
  enqueueAndWait<const TName extends QueueFilterName<TQueues>>(name: TName, body: QueueMessageForName<TQueues, TName>["body"], opts?: QueueEnqueueAndWaitOptions): Promise<QueueCompletionResultForName<TQueues, TName>>;
1025
1213
  tryNext<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueTryNextOptions<TName, TCompletable>): Promise<any>;
1026
1214
  tryNextBatch<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueTryNextBatchOptions<TName, TCompletable>): Promise<any[]>;
1027
1215
  iter<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueIterOptions<TName, TCompletable>): AsyncIterable<any>;
1028
1216
  [key: string]: any;
1029
1217
  }
1030
- interface Conn<TState = unknown, TConnParams = unknown, TConnState = unknown, TVars = unknown, TInput = unknown, TDatabase extends AnyDatabaseProvider = AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
1218
+ interface Conn<_TState = unknown, TConnParams = unknown, TConnState = unknown, _TVars = unknown, _TInput = unknown, _TDatabase extends AnyDatabaseProvider = AnyDatabaseProvider, _TEvents extends EventSchemaConfig = Record<never, never>, _TQueues extends QueueSchemaConfig = Record<never, never>> {
1031
1219
  id: string;
1032
1220
  params: TConnParams;
1033
1221
  state: TConnState;
@@ -1038,16 +1226,29 @@ interface Conn<TState = unknown, TConnParams = unknown, TConnState = unknown, TV
1038
1226
  }
1039
1227
  interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
1040
1228
  [ACTOR_CONTEXT_INTERNAL_SYMBOL]?: unknown;
1229
+ /** Returns the raw unwrapped state without the write-through proxy. */
1230
+ [RAW_STATE_SYMBOL](): TState;
1041
1231
  state: TState;
1042
1232
  vars: TVars;
1233
+ /**
1234
+ * @deprecated Actor KV is deprecated. Use embedded SQLite (`c.db`)
1235
+ * or actor state instead.
1236
+ */
1043
1237
  readonly kv: ActorKv;
1044
1238
  readonly db: InferDatabaseClient<TDatabase>;
1045
1239
  readonly schedule: ActorSchedule;
1240
+ readonly cron: ActorCron;
1046
1241
  readonly queue: ActorQueue<TQueues>;
1242
+ /** @experimental */
1243
+ readonly run: ActorRun;
1047
1244
  readonly actorId: string;
1048
1245
  readonly name: string;
1049
1246
  readonly key: string[];
1050
1247
  readonly region: string;
1248
+ /** Provisions the experimental Actor Runtime Socket for this actor generation. */
1249
+ actorRuntimeSocket(): Promise<{
1250
+ path: string;
1251
+ }>;
1051
1252
  readonly conns: Map<string, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>;
1052
1253
  readonly log: ActorLogger;
1053
1254
  readonly abortSignal: AbortSignal;
@@ -1069,6 +1270,14 @@ interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase
1069
1270
  client<T = any>(): ActorClientFor<T>;
1070
1271
  [key: string]: any;
1071
1272
  }
1273
+ /** @experimental */
1274
+ interface ActorRun {
1275
+ /**
1276
+ * @experimental Sets or clears the durable Unix-millisecond deadline that
1277
+ * ensures this actor's run handler is active, starting it if inactive.
1278
+ */
1279
+ setWakeAt(timestamp: number | null): Promise<void>;
1280
+ }
1072
1281
  type ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & {
1073
1282
  conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
1074
1283
  };
@@ -1095,6 +1304,7 @@ declare const RunConfigSchema: z.ZodObject<{
1095
1304
  inspector: z.ZodOptional<z.ZodOptional<z.ZodObject<{
1096
1305
  workflow: z.ZodOptional<z.ZodObject<{
1097
1306
  getHistory: z.ZodCustom<() => unknown, () => unknown>;
1307
+ getState: z.ZodOptional<z.ZodCustom<() => Promise<WorkflowState | null>, () => Promise<WorkflowState | null>>>;
1098
1308
  onHistoryUpdated: z.ZodOptional<z.ZodCustom<(listener: (history: unknown) => void) => InspectorUnsubscribe, (listener: (history: unknown) => void) => InspectorUnsubscribe>>;
1099
1309
  replayFromStep: z.ZodOptional<z.ZodCustom<(entryId?: string) => Promise<unknown>, (entryId?: string) => Promise<unknown>>>;
1100
1310
  }, z.core.$strip>>;
@@ -1117,6 +1327,7 @@ declare const ActorConfigSchema: z.ZodObject<{
1117
1327
  inspector: z.ZodOptional<z.ZodOptional<z.ZodObject<{
1118
1328
  workflow: z.ZodOptional<z.ZodObject<{
1119
1329
  getHistory: z.ZodCustom<() => unknown, () => unknown>;
1330
+ getState: z.ZodOptional<z.ZodCustom<() => Promise<WorkflowState | null>, () => Promise<WorkflowState | null>>>;
1120
1331
  onHistoryUpdated: z.ZodOptional<z.ZodCustom<(listener: (history: unknown) => void) => InspectorUnsubscribe, (listener: (history: unknown) => void) => InspectorUnsubscribe>>;
1121
1332
  replayFromStep: z.ZodOptional<z.ZodCustom<(entryId?: string) => Promise<unknown>, (entryId?: string) => Promise<unknown>>>;
1122
1333
  }, z.core.$strip>>;
@@ -1129,7 +1340,7 @@ declare const ActorConfigSchema: z.ZodObject<{
1129
1340
  onBeforeActionResponse: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
1130
1341
  onRequest: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
1131
1342
  onWebSocket: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
1132
- actions: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>>;
1343
+ actions: z.ZodDefault<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
1133
1344
  actionInputSchemas: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1134
1345
  connParamsSchema: z.ZodOptional<z.ZodAny>;
1135
1346
  events: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
@@ -1144,6 +1355,7 @@ declare const ActorConfigSchema: z.ZodObject<{
1144
1355
  options: z.ZodPrefault<z.ZodObject<{
1145
1356
  name: z.ZodOptional<z.ZodString>;
1146
1357
  icon: z.ZodOptional<z.ZodString>;
1358
+ enableActorRuntimeSocket: z.ZodDefault<z.ZodBoolean>;
1147
1359
  canHibernateWebSocket: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodCustom<(request: Request) => boolean, (request: Request) => boolean>]>>;
1148
1360
  createVarsTimeout: z.ZodDefault<z.ZodNumber>;
1149
1361
  createConnStateTimeout: z.ZodDefault<z.ZodNumber>;
@@ -1160,12 +1372,33 @@ declare const ActorConfigSchema: z.ZodObject<{
1160
1372
  noSleep: z.ZodDefault<z.ZodBoolean>;
1161
1373
  sleepTimeout: z.ZodDefault<z.ZodNumber>;
1162
1374
  maxQueueSize: z.ZodDefault<z.ZodNumber>;
1375
+ maxSchedules: z.ZodDefault<z.ZodNumber>;
1163
1376
  maxQueueMessageSize: z.ZodDefault<z.ZodNumber>;
1164
1377
  preloadMaxWorkflowBytes: z.ZodOptional<z.ZodNumber>;
1165
1378
  preloadMaxConnectionsBytes: z.ZodOptional<z.ZodNumber>;
1166
1379
  }, z.core.$strict>>;
1380
+ inspector: z.ZodOptional<z.ZodObject<{
1381
+ tabs: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
1382
+ id: z.ZodString;
1383
+ label: z.ZodString;
1384
+ source: z.ZodString;
1385
+ icon: z.ZodOptional<z.ZodString>;
1386
+ hidden: z.ZodOptional<z.ZodLiteral<false>>;
1387
+ }, z.core.$strict>, z.ZodObject<{
1388
+ id: z.ZodEnum<{
1389
+ state: "state";
1390
+ database: "database";
1391
+ console: "console";
1392
+ workflow: "workflow";
1393
+ queue: "queue";
1394
+ schedules: "schedules";
1395
+ connections: "connections";
1396
+ }>;
1397
+ hidden: z.ZodLiteral<true>;
1398
+ }, z.core.$strict>]>>>;
1399
+ }, z.core.$strict>>;
1167
1400
  }, z.core.$strict>;
1168
- type CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
1401
+ type CreateState<TState, _TConnParams, _TConnState, _TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
1169
1402
  state: TState;
1170
1403
  } | {
1171
1404
  createState: (c: CreateContext<TState, TInput, TDatabase, TEvents, TQueues>, input: TInput) => TState | Promise<TState>;
@@ -1178,7 +1411,7 @@ type CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase e
1178
1411
  /**
1179
1412
  * @experimental
1180
1413
  */
1181
- type CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
1414
+ type CreateVars<TState, _TConnParams, _TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
1182
1415
  /**
1183
1416
  * @experimental
1184
1417
  */
@@ -1190,7 +1423,10 @@ type CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase extend
1190
1423
  createVars: (c: CreateVarsContext<TState, TInput, TDatabase, TEvents, TQueues>, driverCtx: any) => TVars | Promise<TVars>;
1191
1424
  } | Record<never, never>;
1192
1425
  interface Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
1193
- [Action: string]: (c: ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, ...args: any[]) => any;
1426
+ [Action: string]: ((c: ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, ...args: any[]) => any) | Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
1427
+ }
1428
+ interface ActionInputSchemas {
1429
+ [Action: string]: PrimitiveSchema | ActionInputSchemas;
1194
1430
  }
1195
1431
  interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>> {
1196
1432
  /**
@@ -1342,9 +1578,10 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
1342
1578
  onWebSocket?: (c: WebSocketContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, websocket: UniversalWebSocket) => void | Promise<void>;
1343
1579
  actions?: TActions;
1344
1580
  /**
1345
- * Optional schema map for validating action argument tuples in native runtimes.
1581
+ * Optional schemas for validating action argument tuples in native runtimes.
1582
+ * May mirror nested action groups or use dot-separated low-level action names.
1346
1583
  */
1347
- actionInputSchemas?: Record<string, PrimitiveSchema>;
1584
+ actionInputSchemas?: ActionInputSchemas;
1348
1585
  /**
1349
1586
  * Optional schema for validating connection params in native runtimes.
1350
1587
  */
@@ -1364,19 +1601,21 @@ type ActorDatabaseConfig<TDatabase extends AnyDatabaseProvider> = {
1364
1601
  */
1365
1602
  db: TDatabase;
1366
1603
  } | Record<never, never>;
1367
- type ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = Omit<z.infer<typeof ActorConfigSchema>, "actions" | "events" | "queues" | "onCreate" | "onDestroy" | "onMigrate" | "onWake" | "onSleep" | "run" | "onStateChange" | "onBeforeConnect" | "onConnect" | "onDisconnect" | "onBeforeActionResponse" | "onRequest" | "onWebSocket" | "state" | "createState" | "connState" | "createConnState" | "vars" | "createVars" | "db"> & BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues, Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>> & CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & ActorDatabaseConfig<TDatabase>;
1604
+ type ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> = Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>> = Omit<z.infer<typeof ActorConfigSchema>, "actions" | "events" | "queues" | "onCreate" | "onDestroy" | "onMigrate" | "onWake" | "onSleep" | "run" | "onStateChange" | "onBeforeConnect" | "onConnect" | "onDisconnect" | "onBeforeActionResponse" | "onRequest" | "onWebSocket" | "state" | "createState" | "connState" | "createConnState" | "vars" | "createVars" | "db"> & BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues, TActions> & CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & ActorDatabaseConfig<TDatabase>;
1368
1605
 
1369
- 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>> {
1370
- readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q>;
1606
+ interface BaseActorDefinition<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>, _R extends Actions<S, CP, CS, V, I, DB, E, Q> = Actions<S, CP, CS, V, I, DB, E, Q>> {
1607
+ readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q, _R>;
1608
+ }
1609
+ interface AnyActorDefinition {
1610
+ readonly config: any;
1371
1611
  }
1372
- type AnyActorDefinition = BaseActorDefinition<any, any, any, any, any, any, any, any, any>;
1373
1612
  declare class ActorDefinition<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>, R extends Actions<S, CP, CS, V, I, DB, E, Q> = Actions<S, CP, CS, V, I, DB, E, Q>> implements BaseActorDefinition<S, CP, CS, V, I, DB, E, Q, R> {
1374
1613
  #private;
1375
- constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q>);
1376
- get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q>;
1614
+ constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q, R>);
1615
+ get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q, R>;
1377
1616
  }
1378
1617
 
1379
- declare const ActorsSchema: z$2.ZodRecord<z$2.ZodString, z$2.ZodCustom<BaseActorDefinition<any, any, any, any, any, any, any, any, any>, BaseActorDefinition<any, any, any, any, any, any, any, any, any>>>;
1618
+ declare const ActorsSchema: z$2.ZodRecord<z$2.ZodString, z$2.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
1380
1619
  type RegistryActors = z$2.infer<typeof ActorsSchema>;
1381
1620
  declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1382
1621
  use: z$2.ZodRecord<z$2.ZodString, z$2.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
@@ -1437,6 +1676,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1437
1676
  httpPort: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
1438
1677
  httpHost: z$2.ZodOptional<z$2.ZodString>;
1439
1678
  startEngine: z$2.ZodDefault<z$2.ZodBoolean>;
1679
+ engineHost: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodString>>;
1680
+ enginePort: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
1440
1681
  engineVersion: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodString>>;
1441
1682
  configurePool: z$2.ZodOptional<z$2.ZodOptional<z$2.ZodObject<{
1442
1683
  name: z$2.ZodOptional<z$2.ZodString>;
@@ -1461,7 +1702,7 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1461
1702
  envoyKey: z$2.ZodOptional<z$2.ZodString>;
1462
1703
  }, z$2.core.$strip>>>;
1463
1704
  shutdown: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodObject<{
1464
- gracePeriodMs: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
1705
+ gracePeriodMs: z$2.ZodOptional<z$2.ZodNumber>;
1465
1706
  disableSignalHandlers: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodBoolean>>;
1466
1707
  }, z$2.core.$strip>>>;
1467
1708
  }, z$2.core.$strip>, z$2.ZodTransform<{
@@ -1504,6 +1745,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1504
1745
  httpBasePath: string;
1505
1746
  httpPort: number;
1506
1747
  startEngine: boolean;
1748
+ engineHost: string;
1749
+ enginePort: number;
1507
1750
  engineVersion: string;
1508
1751
  envoy: {
1509
1752
  poolName: string;
@@ -1512,8 +1755,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1512
1755
  envoyKey?: string | undefined;
1513
1756
  };
1514
1757
  shutdown: {
1515
- gracePeriodMs: number;
1516
1758
  disableSignalHandlers: boolean;
1759
+ gracePeriodMs?: number | undefined;
1517
1760
  };
1518
1761
  staticDir?: string | undefined;
1519
1762
  httpHost?: string | undefined;
@@ -1557,6 +1800,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1557
1800
  httpBasePath: string;
1558
1801
  httpPort: number;
1559
1802
  startEngine: boolean;
1803
+ engineHost: string;
1804
+ enginePort: number;
1560
1805
  engineVersion: string;
1561
1806
  serverless: {
1562
1807
  basePath: string;
@@ -1571,8 +1816,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
1571
1816
  envoyKey?: string | undefined;
1572
1817
  };
1573
1818
  shutdown: {
1574
- gracePeriodMs: number;
1575
1819
  disableSignalHandlers: boolean;
1820
+ gracePeriodMs?: number | undefined;
1576
1821
  };
1577
1822
  staticDir?: string | undefined;
1578
1823
  httpHost?: string | undefined;
@@ -1592,19 +1837,457 @@ type RegistryConfigInput<A extends RegistryActors> = Omit<z$2.input<typeof Regis
1592
1837
  use: A;
1593
1838
  };
1594
1839
 
1840
+ declare const handleBrand: unique symbol;
1841
+ type OpaqueHandle<Name extends string> = {
1842
+ readonly [handleBrand]: Name;
1843
+ };
1844
+ type RegistryHandle = OpaqueHandle<"registry">;
1845
+ type ActorFactoryHandle = OpaqueHandle<"actorFactory">;
1846
+ type ActorContextHandle = OpaqueHandle<"actorContext">;
1847
+ type ConnHandle = OpaqueHandle<"conn">;
1848
+ type WebSocketHandle = OpaqueHandle<"webSocket">;
1849
+ type CancellationTokenHandle = OpaqueHandle<"cancellationToken">;
1850
+ type ActorStateTransactionHandle = OpaqueHandle<"actorStateTransaction">;
1851
+ type SqliteTransactionHandle = OpaqueHandle<"sqliteTransaction">;
1852
+ type RuntimeBytes = Uint8Array;
1853
+ interface RuntimeActorKeySegment {
1854
+ kind: string;
1855
+ stringValue?: string;
1856
+ numberValue?: number;
1857
+ }
1858
+ interface RuntimeHttpRequest {
1859
+ method: string;
1860
+ uri: string;
1861
+ headers?: Record<string, string>;
1862
+ body?: RuntimeBytes;
1863
+ }
1864
+ interface RuntimeStateDeltaPayload {
1865
+ state?: RuntimeBytes;
1866
+ connHibernation: Array<{
1867
+ connId: string;
1868
+ bytes: RuntimeBytes;
1869
+ }>;
1870
+ connHibernationRemoved: string[];
1871
+ }
1872
+ interface RuntimeWorkflowKvWrite {
1873
+ key: RuntimeBytes;
1874
+ value: RuntimeBytes;
1875
+ }
1876
+ interface RuntimeRequestSaveOpts {
1877
+ immediate?: boolean;
1878
+ maxWaitMs?: number;
1879
+ }
1880
+ interface RuntimeInspectorSnapshot {
1881
+ stateRevision: number;
1882
+ connectionsRevision: number;
1883
+ queueRevision: number;
1884
+ activeConnections: number;
1885
+ queueSize: number;
1886
+ connectedClients: number;
1887
+ }
1888
+ interface RuntimeQueueMessage {
1889
+ id(): bigint;
1890
+ name(): string;
1891
+ body(): RuntimeBytes;
1892
+ createdAt(): number;
1893
+ isCompletable(): boolean;
1894
+ complete(response?: RuntimeBytes | undefined | null): Promise<void>;
1895
+ }
1896
+ interface RuntimeQueueInspectMessage {
1897
+ id: number;
1898
+ name: string;
1899
+ createdAtMs: number;
1900
+ }
1901
+ interface RuntimeScheduledEventInfo {
1902
+ id: string;
1903
+ action: string;
1904
+ args: RuntimeBytes;
1905
+ runAt: number;
1906
+ }
1907
+ interface RuntimeCronJobInfo {
1908
+ name: string;
1909
+ kind: "cron" | "every";
1910
+ action: string;
1911
+ args: RuntimeBytes;
1912
+ nextRunAt: number;
1913
+ lastRunAt?: number;
1914
+ expression?: string;
1915
+ timezone?: string;
1916
+ intervalMs?: number;
1917
+ maxHistory: number;
1918
+ }
1919
+ interface RuntimeScheduleErrorInfo {
1920
+ group: string;
1921
+ code: string;
1922
+ message: string;
1923
+ metadata?: unknown;
1924
+ }
1925
+ interface RuntimeCronFire {
1926
+ action: string;
1927
+ scheduledAt: number;
1928
+ firedAt: number;
1929
+ finishedAt?: number;
1930
+ result: "running" | "ok" | "error" | "skipped";
1931
+ error?: RuntimeScheduleErrorInfo;
1932
+ }
1933
+ interface RuntimeQueueNextBatchOptions {
1934
+ names?: string[];
1935
+ count?: number;
1936
+ timeoutMs?: number;
1937
+ completable?: boolean;
1938
+ }
1939
+ interface RuntimeQueueWaitOptions {
1940
+ timeoutMs?: number;
1941
+ completable?: boolean;
1942
+ }
1943
+ interface RuntimeQueueEnqueueAndWaitOptions {
1944
+ timeoutMs?: number;
1945
+ }
1946
+ interface RuntimeQueueTryNextBatchOptions {
1947
+ names?: string[];
1948
+ count?: number;
1949
+ completable?: boolean;
1950
+ }
1951
+ interface RuntimeKvListOptions {
1952
+ reverse?: boolean;
1953
+ limit?: number;
1954
+ }
1955
+ interface RuntimeKvEntry {
1956
+ key: RuntimeBytes;
1957
+ value: RuntimeBytes;
1958
+ }
1959
+ type RuntimeSqlBindNoValues = {
1960
+ intValue?: never;
1961
+ floatValue?: never;
1962
+ textValue?: never;
1963
+ blobValue?: never;
1964
+ };
1965
+ type RuntimeSqlBindParam = ({
1966
+ kind: "null";
1967
+ } & RuntimeSqlBindNoValues) | {
1968
+ kind: "int";
1969
+ intValue: number;
1970
+ floatValue?: never;
1971
+ textValue?: never;
1972
+ blobValue?: never;
1973
+ } | {
1974
+ kind: "float";
1975
+ intValue?: never;
1976
+ floatValue: number;
1977
+ textValue?: never;
1978
+ blobValue?: never;
1979
+ } | {
1980
+ kind: "text";
1981
+ intValue?: never;
1982
+ floatValue?: never;
1983
+ textValue: string;
1984
+ blobValue?: never;
1985
+ } | {
1986
+ kind: "blob";
1987
+ intValue?: never;
1988
+ floatValue?: never;
1989
+ textValue?: never;
1990
+ blobValue: RuntimeBytes;
1991
+ };
1992
+ type RuntimeSqlBindParams = RuntimeSqlBindParam[] | null;
1993
+ interface RuntimeActorRuntimeSocketEndpointInfo {
1994
+ path: string;
1995
+ }
1996
+ interface RuntimeSqlQueryResult {
1997
+ columns: string[];
1998
+ rows: unknown[][];
1999
+ }
2000
+ type RuntimeSqlExecResult = RuntimeSqlQueryResult;
2001
+ interface RuntimeSqlExecuteResult extends RuntimeSqlQueryResult {
2002
+ changes: number;
2003
+ lastInsertRowId?: number | null;
2004
+ }
2005
+ interface RuntimeSqlBatchStatement {
2006
+ sql: string;
2007
+ params?: RuntimeSqlBindParams;
2008
+ }
2009
+ interface RuntimeSqlRunResult {
2010
+ changes: number;
2011
+ }
2012
+ interface RuntimeActorConfig {
2013
+ name?: string;
2014
+ icon?: string;
2015
+ hasDatabase?: boolean;
2016
+ remoteSqlite?: boolean;
2017
+ sqliteProfiling?: SqliteProfilingOptions;
2018
+ enableActorRuntimeSocket?: boolean;
2019
+ hasState?: boolean;
2020
+ canHibernateWebsocket?: boolean;
2021
+ stateSaveIntervalMs?: number;
2022
+ createStateTimeoutMs?: number;
2023
+ onCreateTimeoutMs?: number;
2024
+ createVarsTimeoutMs?: number;
2025
+ createConnStateTimeoutMs?: number;
2026
+ onBeforeConnectTimeoutMs?: number;
2027
+ onConnectTimeoutMs?: number;
2028
+ onMigrateTimeoutMs?: number;
2029
+ onWakeTimeoutMs?: number;
2030
+ onBeforeActorStartTimeoutMs?: number;
2031
+ actionTimeoutMs?: number;
2032
+ onRequestTimeoutMs?: number;
2033
+ sleepTimeoutMs?: number;
2034
+ noSleep?: boolean;
2035
+ sleepGracePeriodMs?: number;
2036
+ connectionLivenessTimeoutMs?: number;
2037
+ connectionLivenessIntervalMs?: number;
2038
+ maxQueueSize?: number;
2039
+ maxSchedules?: number;
2040
+ maxQueueMessageSize?: number;
2041
+ maxIncomingMessageSize?: number;
2042
+ maxOutgoingMessageSize?: number;
2043
+ preloadMaxWorkflowBytes?: number;
2044
+ preloadMaxConnectionsBytes?: number;
2045
+ actions?: Array<{
2046
+ name: string;
2047
+ }>;
2048
+ inspectorTabs?: Array<RuntimeInspectorTabEntry>;
2049
+ }
2050
+ interface RuntimeInspectorTabEntry {
2051
+ id: string;
2052
+ /** Required for custom entries; omitted for built-in hides. */
2053
+ label?: string;
2054
+ /**
2055
+ * Required for custom entries — absolute path to the source directory.
2056
+ * Resolved on the TS side before being handed to the runtime.
2057
+ */
2058
+ source?: string;
2059
+ /** Optional icon id for custom entries. */
2060
+ icon?: string;
2061
+ /** Set to true for built-in hide entries. */
2062
+ hidden?: boolean;
2063
+ }
2064
+ interface RuntimeServeConfig {
2065
+ version: number;
2066
+ endpoint: string;
2067
+ token?: string;
2068
+ namespace: string;
2069
+ poolName: string;
2070
+ engineBinaryPath?: string;
2071
+ engineHost?: string;
2072
+ enginePort?: number;
2073
+ handleInspectorHttpInRuntime?: boolean;
2074
+ inspectorTestToken?: string;
2075
+ serverlessBasePath?: string;
2076
+ serverlessPackageVersion: string;
2077
+ serverlessClientEndpoint?: string;
2078
+ serverlessClientNamespace?: string;
2079
+ serverlessClientToken?: string;
2080
+ serverlessValidateEndpoint: boolean;
2081
+ serverlessMaxStartPayloadBytes: number;
2082
+ }
2083
+ interface RuntimeListenerConfig {
2084
+ port: number;
2085
+ host?: string;
2086
+ publicDir?: string;
2087
+ application?: RuntimeApplicationFetch;
2088
+ }
2089
+ interface RuntimeServerlessRequest {
2090
+ method: string;
2091
+ url: string;
2092
+ headers: Record<string, string>;
2093
+ body: RuntimeBytes;
2094
+ }
2095
+ interface RuntimeApplicationResponse {
2096
+ status: number;
2097
+ headers: Record<string, string>;
2098
+ body: RuntimeBytes;
2099
+ }
2100
+ type RuntimeApplicationFetch = (request: RuntimeServerlessRequest) => Promise<RuntimeApplicationResponse>;
2101
+ interface RuntimeApplicationListenerConfig extends RuntimeListenerConfig {
2102
+ application: RuntimeApplicationFetch;
2103
+ }
2104
+ interface RuntimeServerlessResponseHead {
2105
+ status: number;
2106
+ headers: Record<string, string>;
2107
+ }
2108
+ interface RuntimeRegistryRouteResponse {
2109
+ status: number;
2110
+ headers: Record<string, string>;
2111
+ body: RuntimeBytes;
2112
+ }
2113
+ type RuntimeServerlessStreamEvent = {
2114
+ kind: "chunk";
2115
+ chunk?: RuntimeBytes;
2116
+ } | {
2117
+ kind: "end";
2118
+ error?: {
2119
+ group: string;
2120
+ code: string;
2121
+ message: string;
2122
+ };
2123
+ };
2124
+ type RuntimeServerlessStreamCallback = (error: unknown, event?: RuntimeServerlessStreamEvent) => unknown;
2125
+ type RuntimeWebSocketEvent = {
2126
+ kind: "message";
2127
+ data: string | RuntimeBytes;
2128
+ binary: boolean;
2129
+ messageIndex?: number;
2130
+ } | {
2131
+ kind: "close";
2132
+ code: number;
2133
+ reason: string;
2134
+ wasClean: boolean;
2135
+ };
2136
+ interface CoreRuntime {
2137
+ readonly kind: "napi" | "wasm";
2138
+ createRegistry(): RegistryHandle;
2139
+ registerActor(registry: RegistryHandle, name: string, factory: ActorFactoryHandle): void;
2140
+ serveRegistry(registry: RegistryHandle, config: RuntimeServeConfig): Promise<void>;
2141
+ waitRegistryReady(registry: RegistryHandle): Promise<void>;
2142
+ shutdownRegistry(registry: RegistryHandle): Promise<void>;
2143
+ registryActorStopThresholdMs?(registry: RegistryHandle): Promise<number | undefined>;
2144
+ handleServerlessRequest(registry: RegistryHandle, req: RuntimeServerlessRequest, onStreamEvent: RuntimeServerlessStreamCallback, cancelToken: CancellationTokenHandle, config: RuntimeServeConfig): Promise<RuntimeServerlessResponseHead>;
2145
+ serveListener(registry: RegistryHandle, listener: RuntimeListenerConfig, config: RuntimeServeConfig): Promise<void>;
2146
+ serveApplicationListener(registry: RegistryHandle, listener: RuntimeApplicationListenerConfig, config: RuntimeServeConfig): Promise<void>;
2147
+ registryHealth?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
2148
+ registryMetadata?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
2149
+ registryMetrics?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
2150
+ createActorFactory(callbacks: object, config?: RuntimeActorConfig | undefined | null): ActorFactoryHandle;
2151
+ createCancellationToken(): CancellationTokenHandle;
2152
+ cancellationTokenAborted(token: CancellationTokenHandle): boolean;
2153
+ cancelCancellationToken(token: CancellationTokenHandle): void;
2154
+ onCancellationTokenCancelled(token: CancellationTokenHandle, callback: (...args: unknown[]) => unknown): void;
2155
+ actorState(ctx: ActorContextHandle): RuntimeBytes;
2156
+ actorBeginOnStateChange(ctx: ActorContextHandle): void;
2157
+ actorEndOnStateChange(ctx: ActorContextHandle): void;
2158
+ actorSetAlarm(ctx: ActorContextHandle, timestampMs?: number | undefined | null): void;
2159
+ actorSetRunWakeAt(ctx: ActorContextHandle, timestampMs?: number | undefined | null): Promise<void>;
2160
+ actorRequestSave(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): void;
2161
+ actorRequestSaveAndWait(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): Promise<void>;
2162
+ actorInspectorSnapshot(ctx: ActorContextHandle): RuntimeInspectorSnapshot;
2163
+ actorDecodeInspectorRequest(ctx: ActorContextHandle, bytes: RuntimeBytes, advertisedVersion: number): RuntimeBytes;
2164
+ actorEncodeInspectorResponse(ctx: ActorContextHandle, bytes: RuntimeBytes, targetVersion: number): RuntimeBytes;
2165
+ actorVerifyInspectorAuth(ctx: ActorContextHandle, bearerToken?: string | undefined | null): Promise<void>;
2166
+ actorQueueHibernationRemoval(ctx: ActorContextHandle, connId: string): void;
2167
+ actorTakePendingHibernationChanges(ctx: ActorContextHandle): string[];
2168
+ actorDirtyHibernatableConns(ctx: ActorContextHandle): ConnHandle[];
2169
+ actorSaveState(ctx: ActorContextHandle, payload: RuntimeStateDeltaPayload): Promise<void>;
2170
+ actorSaveStateAndWorkflowBatch(ctx: ActorContextHandle, writes: RuntimeWorkflowKvWrite[]): Promise<void>;
2171
+ actorId(ctx: ActorContextHandle): string;
2172
+ actorName(ctx: ActorContextHandle): string;
2173
+ actorKey(ctx: ActorContextHandle): RuntimeActorKeySegment[];
2174
+ actorRegion(ctx: ActorContextHandle): string;
2175
+ actorSleep(ctx: ActorContextHandle): void;
2176
+ actorDestroy(ctx: ActorContextHandle): void;
2177
+ actorAbortSignal(ctx: ActorContextHandle): AbortSignal;
2178
+ actorConns(ctx: ActorContextHandle): ConnHandle[];
2179
+ actorConnectConn(ctx: ActorContextHandle, params: RuntimeBytes, request?: RuntimeHttpRequest | undefined | null): Promise<ConnHandle>;
2180
+ actorBroadcast(ctx: ActorContextHandle, name: string, args: RuntimeBytes): void;
2181
+ actorWaitUntil(ctx: ActorContextHandle, promise: Promise<unknown>): void;
2182
+ actorWaitForTrackedShutdownWork(ctx: ActorContextHandle): Promise<boolean>;
2183
+ actorWaitForTrackedShutdownWorkUnbounded(ctx: ActorContextHandle): Promise<void>;
2184
+ actorKeepAwake(ctx: ActorContextHandle, promise: Promise<unknown>): void;
2185
+ actorBeginKeepAwake(ctx: ActorContextHandle): number;
2186
+ actorEndKeepAwake(ctx: ActorContextHandle, regionId: number): void;
2187
+ actorRegisterTask(ctx: ActorContextHandle, promise: Promise<unknown>): void;
2188
+ actorRuntimeState(ctx: ActorContextHandle): object;
2189
+ actorClearRuntimeState(ctx: ActorContextHandle): void;
2190
+ actorRestartRunHandler(ctx: ActorContextHandle): void;
2191
+ actorBeginWebsocketCallback(ctx: ActorContextHandle): number;
2192
+ actorEndWebsocketCallback(ctx: ActorContextHandle, regionId: number): void;
2193
+ actorKvGet(ctx: ActorContextHandle, key: RuntimeBytes): Promise<RuntimeBytes | null>;
2194
+ actorKvPut(ctx: ActorContextHandle, key: RuntimeBytes, value: RuntimeBytes): Promise<void>;
2195
+ actorKvDelete(ctx: ActorContextHandle, key: RuntimeBytes): Promise<void>;
2196
+ actorKvDeleteRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes): Promise<void>;
2197
+ actorKvListPrefix(ctx: ActorContextHandle, prefix: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
2198
+ actorKvListRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
2199
+ actorKvBatchGet(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<Array<RuntimeBytes | undefined | null>>;
2200
+ actorKvBatchPut(ctx: ActorContextHandle, entries: RuntimeKvEntry[]): Promise<void>;
2201
+ actorKvBatchDelete(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<void>;
2202
+ actorSqlExec(ctx: ActorContextHandle, sql: string): Promise<RuntimeSqlExecResult>;
2203
+ actorSqlExecute(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
2204
+ actorSqlExecuteBatch(ctx: ActorContextHandle, statements: RuntimeSqlBatchStatement[]): Promise<RuntimeSqlExecuteResult[]>;
2205
+ actorSqlBeginTransaction(ctx: ActorContextHandle, timeoutMs?: number, name?: string): Promise<SqliteTransactionHandle>;
2206
+ actorSqlTransactionExec(transaction: SqliteTransactionHandle, sql: string): Promise<RuntimeSqlExecResult>;
2207
+ actorSqlTransactionExecute(transaction: SqliteTransactionHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
2208
+ actorSqlTransactionCommit(transaction: SqliteTransactionHandle): Promise<void>;
2209
+ actorSqlTransactionRollback(transaction: SqliteTransactionHandle): Promise<void>;
2210
+ actorBeginStateTransaction(ctx: ActorContextHandle, timeoutMs?: number): Promise<ActorStateTransactionHandle>;
2211
+ actorStateTransactionExecute(transaction: ActorStateTransactionHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
2212
+ actorStateTransactionCommit(transaction: ActorStateTransactionHandle, payload: RuntimeStateDeltaPayload): Promise<void>;
2213
+ actorStateTransactionRollback(transaction: ActorStateTransactionHandle): Promise<void>;
2214
+ actorSqlQuery(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlQueryResult>;
2215
+ actorSqlRun(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlRunResult>;
2216
+ actorSqlMetrics(ctx: ActorContextHandle): SqliteNativeMetrics | null;
2217
+ actorSqlTakeLastKvError(ctx: ActorContextHandle): string | null;
2218
+ actorSqlClose(ctx: ActorContextHandle): Promise<void>;
2219
+ actorRuntimeSocketProvision(ctx: ActorContextHandle): Promise<RuntimeActorRuntimeSocketEndpointInfo>;
2220
+ actorQueueSend(ctx: ActorContextHandle, name: string, body: RuntimeBytes): Promise<RuntimeQueueMessage>;
2221
+ actorQueueNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueNextBatchOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage[]>;
2222
+ actorQueueWaitForNames(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage>;
2223
+ actorQueueWaitForNamesAvailable(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<void>;
2224
+ actorQueueCompletePersisted(ctx: ActorContextHandle, messageId: bigint, expectedName: string, response?: RuntimeBytes | undefined | null): Promise<boolean>;
2225
+ actorQueueEnqueueAndWait(ctx: ActorContextHandle, name: string, body: RuntimeBytes, options?: RuntimeQueueEnqueueAndWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeBytes | null>;
2226
+ actorQueueTryNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueTryNextBatchOptions | undefined | null): RuntimeQueueMessage[];
2227
+ actorQueueMaxSize(ctx: ActorContextHandle): number;
2228
+ actorQueueInspectMessages(ctx: ActorContextHandle): Promise<RuntimeQueueInspectMessage[]>;
2229
+ actorQueueReset(ctx: ActorContextHandle): Promise<void>;
2230
+ actorScheduleAfter(ctx: ActorContextHandle, durationMs: number, actionName: string, args: RuntimeBytes): Promise<string>;
2231
+ actorScheduleAt(ctx: ActorContextHandle, timestampMs: number, actionName: string, args: RuntimeBytes): Promise<string>;
2232
+ actorScheduleCancel(ctx: ActorContextHandle, id: string): Promise<boolean>;
2233
+ actorScheduleGet(ctx: ActorContextHandle, id: string): Promise<RuntimeScheduledEventInfo | undefined>;
2234
+ actorScheduleList(ctx: ActorContextHandle): Promise<RuntimeScheduledEventInfo[]>;
2235
+ actorCronSet(ctx: ActorContextHandle, name: string, expression: string, timezone: string | undefined, actionName: string, args: RuntimeBytes, maxHistory: number | undefined): Promise<void>;
2236
+ actorCronEvery(ctx: ActorContextHandle, name: string, intervalMs: number, actionName: string, args: RuntimeBytes, maxHistory: number | undefined): Promise<void>;
2237
+ actorCronGet(ctx: ActorContextHandle, name: string): Promise<RuntimeCronJobInfo | undefined>;
2238
+ actorCronList(ctx: ActorContextHandle): Promise<RuntimeCronJobInfo[]>;
2239
+ actorCronDelete(ctx: ActorContextHandle, name: string): Promise<boolean>;
2240
+ actorCronHistory(ctx: ActorContextHandle, name: string, limit: number | undefined): Promise<RuntimeCronFire[]>;
2241
+ connId(conn: ConnHandle): string;
2242
+ connParams(conn: ConnHandle): RuntimeBytes;
2243
+ connState(conn: ConnHandle): RuntimeBytes;
2244
+ connSetState(conn: ConnHandle, state: RuntimeBytes): void;
2245
+ connIsHibernatable(conn: ConnHandle): boolean;
2246
+ connSend(conn: ConnHandle, name: string, args: RuntimeBytes): void;
2247
+ connDisconnect(conn: ConnHandle, reason?: string | undefined | null): Promise<void>;
2248
+ webSocketSend(ws: WebSocketHandle, data: RuntimeBytes, binary: boolean): void;
2249
+ webSocketClose(ws: WebSocketHandle, code?: number | undefined | null, reason?: string | undefined | null): Promise<void>;
2250
+ webSocketSetEventCallback(ws: WebSocketHandle, callback: (event: RuntimeWebSocketEvent) => void): void;
2251
+ }
2252
+
2253
+ declare function buildConfiguredRegistry(config: RegistryConfig): Promise<{
2254
+ runtime: CoreRuntime;
2255
+ registry: RegistryHandle;
2256
+ serveConfig: RuntimeServeConfig;
2257
+ }>;
2258
+
1595
2259
  type FetchHandler = (request: Request, ...args: any) => Response | Promise<Response>;
1596
2260
  interface ServerlessHandler {
1597
2261
  fetch: FetchHandler;
1598
2262
  }
1599
- interface RegistryDiagnostics {
1600
- mode: string;
1601
- envoyActiveActorCount?: number | null;
2263
+ interface RegistryApplication {
2264
+ fetch: FetchHandler;
2265
+ }
2266
+ interface RegistryListenOptions {
2267
+ port?: number;
2268
+ host?: string;
2269
+ publicDir?: string;
2270
+ application?: RegistryApplication;
2271
+ }
2272
+ interface RegistryRoutes {
2273
+ health(): Promise<Response>;
2274
+ metadata(): Promise<Response>;
2275
+ prometheusMetrics(request?: Request): Promise<Response>;
2276
+ }
2277
+ /**
2278
+ * Injectable dependencies for {@link Registry}. Production code uses the
2279
+ * defaults. Tests override `buildConfiguredRegistry` to drive lifecycle
2280
+ * orchestration against a fake `CoreRuntime` without an engine.
2281
+ */
2282
+ interface RegistryDeps {
2283
+ buildConfiguredRegistry: typeof buildConfiguredRegistry;
1602
2284
  }
1603
2285
  declare class Registry<A extends RegistryActors> {
1604
2286
  #private;
2287
+ readonly routes: RegistryRoutes;
1605
2288
  get config(): RegistryConfigInput<A>;
1606
2289
  parseConfig(): RegistryConfig;
1607
- constructor(config: RegistryConfigInput<A>);
2290
+ constructor(config: RegistryConfigInput<A>, deps?: Partial<RegistryDeps>);
1608
2291
  /**
1609
2292
  * Handle an incoming HTTP request for serverless deployments.
1610
2293
  *
@@ -1625,11 +2308,64 @@ declare class Registry<A extends RegistryActors> {
1625
2308
  * ```
1626
2309
  */
1627
2310
  serve(): ServerlessHandler;
1628
- diagnostics(): Promise<RegistryDiagnostics>;
2311
+ /**
2312
+ * Bind an HTTP listener provided by the native (Rust) runtime and serve
2313
+ * the registry's serverless endpoints over it. Resolves only after the
2314
+ * registry is shut down (SIGINT/SIGTERM or `nativeRegistry.shutdown()`).
2315
+ *
2316
+ * @param opts.port Port to listen on. Defaults to `process.env.RIVET_PORT`
2317
+ * if set, otherwise 3000.
2318
+ * @param opts.host Address to bind. Defaults to `0.0.0.0`.
2319
+ * @param opts.publicDir If set, serves static files from this directory
2320
+ * as a fallback below the framework routes.
2321
+ * @param opts.application If set, handles requests that do not match a
2322
+ * framework route.
2323
+ *
2324
+ * @example
2325
+ * ```ts
2326
+ * await registry.listen();
2327
+ * await registry.listen({ application: app });
2328
+ * ```
2329
+ */
2330
+ listen(opts?: RegistryListenOptions): Promise<void>;
2331
+ /**
2332
+ * Gracefully drains all live registries.
2333
+ *
2334
+ * Programmatic counterpart to the SIGINT/SIGTERM handlers: tears down
2335
+ * every live `CoreRegistry` (both `start()` and `handler()` modes) and
2336
+ * waits for the serve promise to resolve, all bounded by the shutdown
2337
+ * grace period. Unlike a signal-driven shutdown, this does not re-raise a
2338
+ * signal or exit the process. The caller owns process lifetime.
2339
+ *
2340
+ * Idempotent: concurrent or repeated calls share a single drain. Safe to
2341
+ * call even if nothing has been started.
2342
+ *
2343
+ * @example
2344
+ * ```ts
2345
+ * const registry = setup({ use: { counter } });
2346
+ * registry.start();
2347
+ * // ...later, on your own shutdown trigger:
2348
+ * await registry.shutdown();
2349
+ * ```
2350
+ */
2351
+ shutdown(): Promise<void>;
1629
2352
  startEnvoy(): void;
2353
+ /**
2354
+ * Starts the serverful registry if needed and waits until its envoy has
2355
+ * registered with the Engine. Repeated and concurrent calls share one
2356
+ * startup lifecycle and readiness promise.
2357
+ *
2358
+ * Unlike {@link start}, this reports startup failures and does not resolve
2359
+ * merely because an HTTP health endpoint is listening.
2360
+ */
2361
+ startAndWait(): Promise<void>;
1630
2362
  /**
1631
2363
  * Starts the actor envoy for standalone server deployments.
1632
2364
  *
2365
+ * Set `RIVETKIT_RUNTIME_MODE=serverless` to instead bind an HTTP listener
2366
+ * via `listen()` (Mode B). Mode A (envoy) and Mode B (listener) are
2367
+ * mutually exclusive per registry instance.
2368
+ *
1633
2369
  * @example
1634
2370
  * ```ts
1635
2371
  * const registry = setup({ use: { counter } });