rivetkit 2.3.0-rc.8 → 2.3.0

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 (221) hide show
  1. package/dist/browser/client.d.ts +481 -74
  2. package/dist/browser/client.js +174 -148
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.js +47 -18
  5. package/dist/browser/inspector/client.js.map +1 -1
  6. package/dist/tsup/actor/errors.cjs +2 -2
  7. package/dist/tsup/actor/errors.d.cts +1 -1
  8. package/dist/tsup/actor/errors.d.ts +1 -1
  9. package/dist/tsup/actor/errors.js +1 -1
  10. package/dist/tsup/agent-os/index.cjs +2160 -2086
  11. package/dist/tsup/agent-os/index.cjs.map +1 -1
  12. package/dist/tsup/agent-os/index.d.cts +479 -73
  13. package/dist/tsup/agent-os/index.d.ts +479 -73
  14. package/dist/tsup/agent-os/index.js +2160 -2086
  15. package/dist/tsup/agent-os/index.js.map +1 -1
  16. package/dist/tsup/{chunk-KY3CERZR.js → chunk-2OTRTA3J.js} +7 -21
  17. package/dist/tsup/chunk-2OTRTA3J.js.map +1 -0
  18. package/dist/tsup/{chunk-HGW6PBWR.cjs → chunk-3677IIOV.cjs} +11 -25
  19. package/dist/tsup/chunk-3677IIOV.cjs.map +1 -0
  20. package/dist/tsup/{chunk-OT7FF6GB.cjs → chunk-47HHIEXH.cjs} +24 -9
  21. package/dist/tsup/chunk-47HHIEXH.cjs.map +1 -0
  22. package/dist/tsup/{chunk-EMFKMVJR.js → chunk-4JDSFJS5.js} +69 -58
  23. package/dist/tsup/chunk-4JDSFJS5.js.map +1 -0
  24. package/dist/tsup/{chunk-7HLFSAJP.cjs → chunk-7QKCIVAY.cjs} +225 -214
  25. package/dist/tsup/chunk-7QKCIVAY.cjs.map +1 -0
  26. package/dist/tsup/{chunk-AWTPTUQ7.cjs → chunk-B6VUNZUD.cjs} +10 -10
  27. package/dist/tsup/{chunk-AWTPTUQ7.cjs.map → chunk-B6VUNZUD.cjs.map} +1 -1
  28. package/dist/tsup/{chunk-D3T3ZBSY.js → chunk-BEI24WTI.js} +2 -2
  29. package/dist/tsup/{chunk-TMLOKTRB.js → chunk-BRP62GZC.js} +1 -1
  30. package/dist/tsup/chunk-BRP62GZC.js.map +1 -0
  31. package/dist/tsup/{chunk-D5G75T7J.js → chunk-DPIMKYNB.js} +61 -2
  32. package/dist/tsup/chunk-DPIMKYNB.js.map +1 -0
  33. package/dist/tsup/{chunk-BATTOVHF.cjs → chunk-DXXJPH55.cjs} +40 -13
  34. package/dist/tsup/chunk-DXXJPH55.cjs.map +1 -0
  35. package/dist/tsup/{chunk-3YY5S6TV.js → chunk-HXUEHHJF.js} +2 -2
  36. package/dist/tsup/chunk-HXUEHHJF.js.map +1 -0
  37. package/dist/tsup/{chunk-4BPKKZJO.cjs → chunk-I4LN3FNT.cjs} +10 -10
  38. package/dist/tsup/chunk-I4LN3FNT.cjs.map +1 -0
  39. package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JZ7TWV65.js} +1 -1
  40. package/dist/tsup/chunk-JZ7TWV65.js.map +1 -0
  41. package/dist/tsup/{chunk-63WNTDRC.cjs → chunk-KORQB2IR.cjs} +1 -1
  42. package/dist/tsup/{chunk-63WNTDRC.cjs.map → chunk-KORQB2IR.cjs.map} +1 -1
  43. package/dist/tsup/{chunk-6TQSSJ4F.cjs → chunk-LVTBW2RE.cjs} +3 -3
  44. package/dist/tsup/{chunk-6TQSSJ4F.cjs.map → chunk-LVTBW2RE.cjs.map} +1 -1
  45. package/dist/tsup/{chunk-4JU3IPG2.js → chunk-MEHBWPLJ.js} +6 -6
  46. package/dist/tsup/chunk-MEHBWPLJ.js.map +1 -0
  47. package/dist/tsup/{chunk-SRNOPUC6.cjs → chunk-NIY3RSPX.cjs} +62 -3
  48. package/dist/tsup/chunk-NIY3RSPX.cjs.map +1 -0
  49. package/dist/tsup/{chunk-UZXQEGVJ.js → chunk-P2GNQ4RN.js} +4 -4
  50. package/dist/tsup/{chunk-UZXQEGVJ.js.map → chunk-P2GNQ4RN.js.map} +1 -1
  51. package/dist/tsup/{chunk-VUGENVIK.js → chunk-UMZVD6DQ.js} +22 -7
  52. package/dist/tsup/chunk-UMZVD6DQ.js.map +1 -0
  53. package/dist/tsup/{chunk-LD5YASJU.cjs → chunk-VE2X4KMG.cjs} +2 -2
  54. package/dist/tsup/{chunk-LD5YASJU.cjs.map → chunk-VE2X4KMG.cjs.map} +1 -1
  55. package/dist/tsup/{chunk-GBG63SUG.js → chunk-VTTFNQQI.js} +32 -5
  56. package/dist/tsup/chunk-VTTFNQQI.js.map +1 -0
  57. package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-ZA7FLHKH.cjs} +1 -1
  58. package/dist/tsup/chunk-ZA7FLHKH.cjs.map +1 -0
  59. package/dist/tsup/client/mod.cjs +9 -9
  60. package/dist/tsup/client/mod.d.cts +5 -5
  61. package/dist/tsup/client/mod.d.ts +5 -5
  62. package/dist/tsup/client/mod.js +8 -8
  63. package/dist/tsup/common/log.cjs +3 -3
  64. package/dist/tsup/common/log.js +2 -2
  65. package/dist/tsup/common/websocket.cjs +4 -4
  66. package/dist/tsup/common/websocket.js +3 -3
  67. package/dist/tsup/{config-Ak1lv4gF.d.ts → config-BxWAw3iH.d.ts} +512 -27
  68. package/dist/tsup/{config-DU_xj4qZ.d.cts → config-CZQQ-mso.d.cts} +512 -27
  69. package/dist/tsup/{config-CxjGYf4K.d.ts → config-D49x8NpL.d.cts} +1 -2
  70. package/dist/tsup/{config-CxjGYf4K.d.cts → config-D49x8NpL.d.ts} +1 -2
  71. package/dist/tsup/{context-DAAp4Lpg.d.ts → context-Bw7xq8w3.d.cts} +8 -8
  72. package/dist/tsup/{context-Dt_L55q8.d.cts → context-D8QA76sV.d.ts} +8 -8
  73. package/dist/tsup/db/drizzle.cjs +3 -3
  74. package/dist/tsup/db/drizzle.d.cts +1 -1
  75. package/dist/tsup/db/drizzle.d.ts +1 -1
  76. package/dist/tsup/db/drizzle.js +1 -1
  77. package/dist/tsup/db/mod.cjs +2 -2
  78. package/dist/tsup/db/mod.d.cts +2 -2
  79. package/dist/tsup/db/mod.d.ts +2 -2
  80. package/dist/tsup/db/mod.js +1 -1
  81. package/dist/tsup/dynamic/mod.cjs +24 -0
  82. package/dist/tsup/dynamic/mod.cjs.map +1 -0
  83. package/dist/tsup/dynamic/mod.d.cts +37 -0
  84. package/dist/tsup/dynamic/mod.d.ts +37 -0
  85. package/dist/tsup/dynamic/mod.js +24 -0
  86. package/dist/tsup/dynamic/mod.js.map +1 -0
  87. package/dist/tsup/inspector/mod.cjs +6 -6
  88. package/dist/tsup/inspector/mod.js +5 -5
  89. package/dist/tsup/inspector-tab/mod.cjs +173 -0
  90. package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
  91. package/dist/tsup/inspector-tab/mod.d.cts +250 -0
  92. package/dist/tsup/inspector-tab/mod.d.ts +250 -0
  93. package/dist/tsup/inspector-tab/mod.js +173 -0
  94. package/dist/tsup/inspector-tab/mod.js.map +1 -0
  95. package/dist/tsup/mod.cjs +615 -348
  96. package/dist/tsup/mod.cjs.map +1 -1
  97. package/dist/tsup/mod.d.cts +5 -5
  98. package/dist/tsup/mod.d.ts +5 -5
  99. package/dist/tsup/mod.js +511 -244
  100. package/dist/tsup/mod.js.map +1 -1
  101. package/dist/tsup/test/mod.cjs +21 -18
  102. package/dist/tsup/test/mod.cjs.map +1 -1
  103. package/dist/tsup/test/mod.d.cts +4 -4
  104. package/dist/tsup/test/mod.d.ts +4 -4
  105. package/dist/tsup/test/mod.js +18 -15
  106. package/dist/tsup/test/mod.js.map +1 -1
  107. package/dist/tsup/{utils-DVekpm4I.d.cts → utils-DQosb24I.d.cts} +1 -1
  108. package/dist/tsup/{utils-DVekpm4I.d.ts → utils-DQosb24I.d.ts} +1 -1
  109. package/dist/tsup/utils.cjs +3 -3
  110. package/dist/tsup/utils.d.cts +1 -1
  111. package/dist/tsup/utils.d.ts +1 -1
  112. package/dist/tsup/utils.js +2 -2
  113. package/dist/tsup/workflow/mod.cjs +279 -279
  114. package/dist/tsup/workflow/mod.cjs.map +1 -1
  115. package/dist/tsup/workflow/mod.d.cts +6 -6
  116. package/dist/tsup/workflow/mod.d.ts +6 -6
  117. package/dist/tsup/workflow/mod.js +380 -380
  118. package/dist/tsup/workflow/mod.js.map +1 -1
  119. package/package.json +29 -9
  120. package/src/actor/config.ts +156 -51
  121. package/src/actor/contexts/index.ts +7 -2
  122. package/src/actor/definition.ts +17 -19
  123. package/src/actor/driver.ts +3 -3
  124. package/src/actor/errors.ts +8 -2
  125. package/src/actor/instance/mod.ts +26 -34
  126. package/src/actor/keys.ts +1 -1
  127. package/src/actor/mod.ts +22 -20
  128. package/src/actor/schema.ts +2 -2
  129. package/src/agent-os/actor/index.ts +38 -18
  130. package/src/agent-os/actor/preview.ts +1 -2
  131. package/src/agent-os/config.ts +1 -1
  132. package/src/agent-os/fs/database-vfs.ts +1 -1
  133. package/src/agent-os/index.ts +16 -15
  134. package/src/client/actor-common.ts +87 -54
  135. package/src/client/actor-conn.ts +11 -11
  136. package/src/client/actor-handle.ts +69 -52
  137. package/src/client/actor-query.ts +5 -5
  138. package/src/client/errors.ts +1 -1
  139. package/src/client/lifecycle-errors.ts +2 -4
  140. package/src/client/query.ts +1 -1
  141. package/src/client/queue.ts +8 -4
  142. package/src/client/raw-utils.ts +8 -6
  143. package/src/client/resolve-gateway-target.ts +1 -1
  144. package/src/client/utils.ts +2 -6
  145. package/src/common/actor-websocket.ts +3 -1
  146. package/src/common/bare/actor-persist/v1.ts +205 -163
  147. package/src/common/bare/actor-persist/v2.ts +265 -213
  148. package/src/common/bare/actor-persist/v3.ts +176 -172
  149. package/src/common/bare/actor-persist/v4.ts +254 -253
  150. package/src/common/bare/transport/v1.ts +659 -543
  151. package/src/common/client-protocol-versioned.ts +66 -64
  152. package/src/common/database/config.ts +2 -8
  153. package/src/common/database/native-database.ts +1 -1
  154. package/src/common/database/shared.ts +1 -0
  155. package/src/common/encoding.ts +13 -17
  156. package/src/common/engine.ts +28 -1
  157. package/src/common/eventsource.ts +1 -1
  158. package/src/common/inline-websocket-adapter.ts +3 -2
  159. package/src/common/router.ts +13 -17
  160. package/src/common/utils.ts +1 -2
  161. package/src/common/websocket-interface.ts +1 -1
  162. package/src/db/mod.ts +1 -1
  163. package/src/devtools-loader/index.ts +4 -7
  164. package/src/devtools-loader/serve-devtools.ts +26 -0
  165. package/src/drivers/engine/actor-driver.ts +48 -46
  166. package/src/dynamic/instance.ts +32 -0
  167. package/src/dynamic/internal.ts +50 -0
  168. package/src/dynamic/isolate-runtime.ts +66 -0
  169. package/src/dynamic/mod.ts +32 -0
  170. package/src/engine-client/actor-http-client.ts +3 -3
  171. package/src/engine-client/actor-websocket-client.ts +5 -5
  172. package/src/engine-client/api-endpoints.ts +51 -2
  173. package/src/engine-client/api-utils.ts +2 -2
  174. package/src/engine-client/driver.ts +1 -1
  175. package/src/engine-client/mod.ts +5 -3
  176. package/src/engine-client/ws-proxy.ts +9 -4
  177. package/src/inspector/client.browser.ts +5 -11
  178. package/src/inspector/mod.ts +1 -3
  179. package/src/inspector-tab/mod.ts +315 -0
  180. package/src/registry/config/envoy.ts +1 -2
  181. package/src/registry/config/index.ts +40 -16
  182. package/src/registry/index.ts +226 -83
  183. package/src/registry/napi-runtime.ts +46 -12
  184. package/src/registry/native-validation.ts +10 -12
  185. package/src/registry/native.ts +307 -164
  186. package/src/registry/process-metrics.ts +90 -23
  187. package/src/registry/runtime.ts +53 -6
  188. package/src/registry/wasm-runtime.ts +30 -3
  189. package/src/serde.ts +1 -1
  190. package/src/serverless/configure.ts +18 -7
  191. package/src/test/mod.ts +11 -8
  192. package/src/utils/endpoint-parser.ts +1 -1
  193. package/src/utils/env-vars.ts +6 -0
  194. package/src/utils/router.ts +1 -1
  195. package/src/utils/serve.ts +4 -5
  196. package/src/utils.ts +1 -2
  197. package/src/workflow/context.ts +30 -29
  198. package/src/workflow/driver.ts +4 -6
  199. package/src/workflow/inspector.ts +2 -2
  200. package/src/workflow/mod.ts +15 -17
  201. package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
  202. package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
  203. package/dist/tsup/chunk-4BPKKZJO.cjs.map +0 -1
  204. package/dist/tsup/chunk-4JU3IPG2.js.map +0 -1
  205. package/dist/tsup/chunk-7HLFSAJP.cjs.map +0 -1
  206. package/dist/tsup/chunk-BATTOVHF.cjs.map +0 -1
  207. package/dist/tsup/chunk-D5G75T7J.js.map +0 -1
  208. package/dist/tsup/chunk-EMFKMVJR.js.map +0 -1
  209. package/dist/tsup/chunk-GBG63SUG.js.map +0 -1
  210. package/dist/tsup/chunk-HGW6PBWR.cjs.map +0 -1
  211. package/dist/tsup/chunk-KY3CERZR.js.map +0 -1
  212. package/dist/tsup/chunk-OT7FF6GB.cjs.map +0 -1
  213. package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
  214. package/dist/tsup/chunk-SRNOPUC6.cjs.map +0 -1
  215. package/dist/tsup/chunk-TMLOKTRB.js.map +0 -1
  216. package/dist/tsup/chunk-VUGENVIK.js.map +0 -1
  217. package/dist/tsup/process-metrics-NW754INA.js +0 -118
  218. package/dist/tsup/process-metrics-NW754INA.js.map +0 -1
  219. package/dist/tsup/process-metrics-TYAGKCEJ.cjs +0 -118
  220. package/dist/tsup/process-metrics-TYAGKCEJ.cjs.map +0 -1
  221. /package/dist/tsup/{chunk-D3T3ZBSY.js.map → chunk-BEI24WTI.js.map} +0 -0
@@ -1,13 +1,13 @@
1
1
  import { z } from 'zod/v4';
2
- import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
3
- import { A as AnyDatabaseProvider, I as InferDatabaseClient } from './config-CxjGYf4K.cjs';
2
+ import { A as AnyDatabaseProvider, d as SqliteNativeMetrics, I as InferDatabaseClient } from './config-D49x8NpL.cjs';
4
3
  import * as _rivetkit_rivetkit_wasm from '@rivetkit/rivetkit-wasm';
5
4
  import { z as z$1 } from 'zod';
6
5
  import { Logger } from 'pino';
6
+ import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
7
7
  import { StandardSchemaV1 } from '@standard-schema/spec';
8
8
  import { Context, Hono } from 'hono';
9
9
  import { GetUpgradeWebSocket } from './utils.cjs';
10
- import { R as RivetError } from './utils-DVekpm4I.cjs';
10
+ import { R as RivetError } from './utils-DQosb24I.cjs';
11
11
 
12
12
  declare const ActorKeySchema: z.ZodArray<z.ZodString>;
13
13
  type ActorKey = z.infer<typeof ActorKeySchema>;
@@ -70,7 +70,7 @@ declare const EncodingSchema: z.ZodEnum<{
70
70
  */
71
71
  type Encoding = z.infer<typeof EncodingSchema>;
72
72
 
73
- declare const ActorsSchema: z$1.ZodRecord<z$1.ZodString, z$1.ZodCustom<BaseActorDefinition<any, any, any, any, any, any, any, any, any>, BaseActorDefinition<any, any, any, any, any, any, any, any, any>>>;
73
+ declare const ActorsSchema: z$1.ZodRecord<z$1.ZodString, z$1.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
74
74
  type RegistryActors = z$1.infer<typeof ActorsSchema>;
75
75
  declare const RuntimeKindSchema: z$1.ZodEnum<{
76
76
  auto: "auto";
@@ -167,6 +167,8 @@ declare const RegistryConfigSchema: z$1.ZodPipe<z$1.ZodObject<{
167
167
  httpPort: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
168
168
  httpHost: z$1.ZodOptional<z$1.ZodString>;
169
169
  startEngine: z$1.ZodDefault<z$1.ZodBoolean>;
170
+ engineHost: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodString>>;
171
+ enginePort: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
170
172
  engineVersion: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodString>>;
171
173
  configurePool: z$1.ZodOptional<z$1.ZodOptional<z$1.ZodObject<{
172
174
  name: z$1.ZodOptional<z$1.ZodString>;
@@ -232,6 +234,8 @@ declare const RegistryConfigSchema: z$1.ZodPipe<z$1.ZodObject<{
232
234
  httpBasePath: string;
233
235
  httpPort: number;
234
236
  startEngine: boolean;
237
+ engineHost: string;
238
+ enginePort: number;
235
239
  engineVersion: string;
236
240
  envoy: {
237
241
  poolName: string;
@@ -283,6 +287,8 @@ declare const RegistryConfigSchema: z$1.ZodPipe<z$1.ZodObject<{
283
287
  httpBasePath: string;
284
288
  httpPort: number;
285
289
  startEngine: boolean;
290
+ engineHost: string;
291
+ enginePort: number;
286
292
  engineVersion: string;
287
293
  serverless: {
288
294
  basePath: string;
@@ -444,7 +450,7 @@ interface QueueSchemaDefinition<TContext = any> {
444
450
  type EventSchema<TContext = any> = PrimitiveSchema | EventSchemaDefinition<TContext>;
445
451
  type QueueSchema = PrimitiveSchema | QueueSchemaDefinition<any> | QueueTypeToken<unknown, unknown, any>;
446
452
  type EventSchemaConfig<TContext = any> = Record<string, EventSchema<TContext>>;
447
- type QueueSchemaConfig<TContext = any> = Record<string, QueueSchema>;
453
+ type QueueSchemaConfig<_TContext = any> = Record<string, QueueSchema>;
448
454
  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;
449
455
  type InferSchemaMap<T extends Record<string, unknown>> = {
450
456
  [K in keyof T]: InferSchema<T[K]>;
@@ -455,15 +461,17 @@ type InferQueueCompleteMap<T extends QueueSchemaConfig> = {
455
461
  };
456
462
  type InferEventArgs<T> = T extends readonly unknown[] ? number extends T["length"] ? [T] : T : [T];
457
463
 
458
- 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>> {
459
- readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q>;
464
+ 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>> {
465
+ readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q, _R>;
466
+ }
467
+ interface AnyActorDefinition {
468
+ readonly config: any;
460
469
  }
461
- type AnyActorDefinition = BaseActorDefinition<any, any, any, any, any, any, any, any, any>;
462
470
  type AnyStaticActorDefinition = ActorDefinition<any, any, any, any, any, any, any, any, any>;
463
471
  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> {
464
472
  #private;
465
- constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q>);
466
- get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q>;
473
+ constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q, R>);
474
+ get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q, R>;
467
475
  }
468
476
  interface BaseActorInstance<S = any, CP = any, CS = any, V = any, I = any, DB extends AnyDatabaseProvider = AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>> {
469
477
  id: string;
@@ -557,19 +565,358 @@ interface ActorOutput {
557
565
  error?: unknown;
558
566
  }
559
567
 
568
+ declare const handleBrand: unique symbol;
569
+ type OpaqueHandle<Name extends string> = {
570
+ readonly [handleBrand]: Name;
571
+ };
572
+ type RegistryHandle = OpaqueHandle<"registry">;
573
+ type ActorFactoryHandle = OpaqueHandle<"actorFactory">;
574
+ type ActorContextHandle = OpaqueHandle<"actorContext">;
575
+ type ConnHandle = OpaqueHandle<"conn">;
576
+ type WebSocketHandle = OpaqueHandle<"webSocket">;
577
+ type CancellationTokenHandle = OpaqueHandle<"cancellationToken">;
578
+ type RuntimeBytes = Uint8Array;
579
+ interface RuntimeActorKeySegment {
580
+ kind: string;
581
+ stringValue?: string;
582
+ numberValue?: number;
583
+ }
584
+ interface RuntimeHttpRequest {
585
+ method: string;
586
+ uri: string;
587
+ headers?: Record<string, string>;
588
+ body?: RuntimeBytes;
589
+ }
590
+ interface RuntimeStateDeltaPayload {
591
+ state?: RuntimeBytes;
592
+ connHibernation: Array<{
593
+ connId: string;
594
+ bytes: RuntimeBytes;
595
+ }>;
596
+ connHibernationRemoved: string[];
597
+ }
598
+ interface RuntimeRequestSaveOpts {
599
+ immediate?: boolean;
600
+ maxWaitMs?: number;
601
+ }
602
+ interface RuntimeInspectorSnapshot {
603
+ stateRevision: number;
604
+ connectionsRevision: number;
605
+ queueRevision: number;
606
+ activeConnections: number;
607
+ queueSize: number;
608
+ connectedClients: number;
609
+ }
610
+ interface RuntimeQueueMessage {
611
+ id(): bigint;
612
+ name(): string;
613
+ body(): RuntimeBytes;
614
+ createdAt(): number;
615
+ isCompletable(): boolean;
616
+ complete(response?: RuntimeBytes | undefined | null): Promise<void>;
617
+ }
618
+ interface RuntimeQueueInspectMessage {
619
+ id: number;
620
+ name: string;
621
+ createdAtMs: number;
622
+ }
623
+ interface RuntimeQueueNextBatchOptions {
624
+ names?: string[];
625
+ count?: number;
626
+ timeoutMs?: number;
627
+ completable?: boolean;
628
+ }
629
+ interface RuntimeQueueWaitOptions {
630
+ timeoutMs?: number;
631
+ completable?: boolean;
632
+ }
633
+ interface RuntimeQueueEnqueueAndWaitOptions {
634
+ timeoutMs?: number;
635
+ }
636
+ interface RuntimeQueueTryNextBatchOptions {
637
+ names?: string[];
638
+ count?: number;
639
+ completable?: boolean;
640
+ }
641
+ interface RuntimeKvListOptions {
642
+ reverse?: boolean;
643
+ limit?: number;
644
+ }
645
+ interface RuntimeKvEntry {
646
+ key: RuntimeBytes;
647
+ value: RuntimeBytes;
648
+ }
649
+ type RuntimeSqlBindNoValues = {
650
+ intValue?: never;
651
+ floatValue?: never;
652
+ textValue?: never;
653
+ blobValue?: never;
654
+ };
655
+ type RuntimeSqlBindParam = ({
656
+ kind: "null";
657
+ } & RuntimeSqlBindNoValues) | {
658
+ kind: "int";
659
+ intValue: number;
660
+ floatValue?: never;
661
+ textValue?: never;
662
+ blobValue?: never;
663
+ } | {
664
+ kind: "float";
665
+ intValue?: never;
666
+ floatValue: number;
667
+ textValue?: never;
668
+ blobValue?: never;
669
+ } | {
670
+ kind: "text";
671
+ intValue?: never;
672
+ floatValue?: never;
673
+ textValue: string;
674
+ blobValue?: never;
675
+ } | {
676
+ kind: "blob";
677
+ intValue?: never;
678
+ floatValue?: never;
679
+ textValue?: never;
680
+ blobValue: RuntimeBytes;
681
+ };
682
+ type RuntimeSqlBindParams = RuntimeSqlBindParam[] | null;
683
+ interface RuntimeSqlQueryResult {
684
+ columns: string[];
685
+ rows: unknown[][];
686
+ }
687
+ type RuntimeSqlExecResult = RuntimeSqlQueryResult;
688
+ interface RuntimeSqlExecuteResult extends RuntimeSqlQueryResult {
689
+ changes: number;
690
+ lastInsertRowId?: number | null;
691
+ }
692
+ interface RuntimeSqlRunResult {
693
+ changes: number;
694
+ }
695
+ interface RuntimeActorConfig {
696
+ name?: string;
697
+ icon?: string;
698
+ hasDatabase?: boolean;
699
+ remoteSqlite?: boolean;
700
+ hasState?: boolean;
701
+ canHibernateWebsocket?: boolean;
702
+ stateSaveIntervalMs?: number;
703
+ createStateTimeoutMs?: number;
704
+ onCreateTimeoutMs?: number;
705
+ createVarsTimeoutMs?: number;
706
+ createConnStateTimeoutMs?: number;
707
+ onBeforeConnectTimeoutMs?: number;
708
+ onConnectTimeoutMs?: number;
709
+ onMigrateTimeoutMs?: number;
710
+ onWakeTimeoutMs?: number;
711
+ onBeforeActorStartTimeoutMs?: number;
712
+ actionTimeoutMs?: number;
713
+ onRequestTimeoutMs?: number;
714
+ sleepTimeoutMs?: number;
715
+ noSleep?: boolean;
716
+ sleepGracePeriodMs?: number;
717
+ connectionLivenessTimeoutMs?: number;
718
+ connectionLivenessIntervalMs?: number;
719
+ maxQueueSize?: number;
720
+ maxQueueMessageSize?: number;
721
+ maxIncomingMessageSize?: number;
722
+ maxOutgoingMessageSize?: number;
723
+ preloadMaxWorkflowBytes?: number;
724
+ preloadMaxConnectionsBytes?: number;
725
+ actions?: Array<{
726
+ name: string;
727
+ }>;
728
+ inspectorTabs?: Array<RuntimeInspectorTabEntry>;
729
+ }
730
+ interface RuntimeInspectorTabEntry {
731
+ id: string;
732
+ /** Required for custom entries; omitted for built-in hides. */
733
+ label?: string;
734
+ /**
735
+ * Required for custom entries — absolute path to the source directory.
736
+ * Resolved on the TS side before being handed to the runtime.
737
+ */
738
+ source?: string;
739
+ /** Optional icon id for custom entries. */
740
+ icon?: string;
741
+ /** Set to true for built-in hide entries. */
742
+ hidden?: boolean;
743
+ }
744
+ interface RuntimeServeConfig {
745
+ version: number;
746
+ endpoint: string;
747
+ token?: string;
748
+ namespace: string;
749
+ poolName: string;
750
+ engineBinaryPath?: string;
751
+ engineHost?: string;
752
+ enginePort?: number;
753
+ handleInspectorHttpInRuntime?: boolean;
754
+ inspectorTestToken?: string;
755
+ serverlessBasePath?: string;
756
+ serverlessPackageVersion: string;
757
+ serverlessClientEndpoint?: string;
758
+ serverlessClientNamespace?: string;
759
+ serverlessClientToken?: string;
760
+ serverlessValidateEndpoint: boolean;
761
+ serverlessMaxStartPayloadBytes: number;
762
+ }
763
+ interface RuntimeServerlessRequest {
764
+ method: string;
765
+ url: string;
766
+ headers: Record<string, string>;
767
+ body: RuntimeBytes;
768
+ }
769
+ interface RuntimeServerlessResponseHead {
770
+ status: number;
771
+ headers: Record<string, string>;
772
+ }
773
+ interface RuntimeRegistryRouteResponse {
774
+ status: number;
775
+ headers: Record<string, string>;
776
+ body: RuntimeBytes;
777
+ }
778
+ type RuntimeServerlessStreamEvent = {
779
+ kind: "chunk";
780
+ chunk?: RuntimeBytes;
781
+ } | {
782
+ kind: "end";
783
+ error?: {
784
+ group: string;
785
+ code: string;
786
+ message: string;
787
+ };
788
+ };
789
+ type RuntimeServerlessStreamCallback = (error: unknown, event?: RuntimeServerlessStreamEvent) => unknown;
790
+ type RuntimeWebSocketEvent = {
791
+ kind: "message";
792
+ data: string | RuntimeBytes;
793
+ binary: boolean;
794
+ messageIndex?: number;
795
+ } | {
796
+ kind: "close";
797
+ code: number;
798
+ reason: string;
799
+ wasClean: boolean;
800
+ };
801
+ interface CoreRuntime {
802
+ readonly kind: "napi" | "wasm";
803
+ createRegistry(): RegistryHandle;
804
+ registerActor(registry: RegistryHandle, name: string, factory: ActorFactoryHandle): void;
805
+ serveRegistry(registry: RegistryHandle, config: RuntimeServeConfig): Promise<void>;
806
+ shutdownRegistry(registry: RegistryHandle): Promise<void>;
807
+ registryActorStopThresholdMs?(registry: RegistryHandle): Promise<number | undefined>;
808
+ handleServerlessRequest(registry: RegistryHandle, req: RuntimeServerlessRequest, onStreamEvent: RuntimeServerlessStreamCallback, cancelToken: CancellationTokenHandle, config: RuntimeServeConfig): Promise<RuntimeServerlessResponseHead>;
809
+ registryHealth?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
810
+ registryMetadata?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
811
+ registryMetrics?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
812
+ createActorFactory(callbacks: object, config?: RuntimeActorConfig | undefined | null): ActorFactoryHandle;
813
+ createCancellationToken(): CancellationTokenHandle;
814
+ cancellationTokenAborted(token: CancellationTokenHandle): boolean;
815
+ cancelCancellationToken(token: CancellationTokenHandle): void;
816
+ onCancellationTokenCancelled(token: CancellationTokenHandle, callback: (...args: unknown[]) => unknown): void;
817
+ actorState(ctx: ActorContextHandle): RuntimeBytes;
818
+ actorBeginOnStateChange(ctx: ActorContextHandle): void;
819
+ actorEndOnStateChange(ctx: ActorContextHandle): void;
820
+ actorSetAlarm(ctx: ActorContextHandle, timestampMs?: number | undefined | null): void;
821
+ actorRequestSave(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): void;
822
+ actorRequestSaveAndWait(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): Promise<void>;
823
+ actorInspectorSnapshot(ctx: ActorContextHandle): RuntimeInspectorSnapshot;
824
+ actorDecodeInspectorRequest(ctx: ActorContextHandle, bytes: RuntimeBytes, advertisedVersion: number): RuntimeBytes;
825
+ actorEncodeInspectorResponse(ctx: ActorContextHandle, bytes: RuntimeBytes, targetVersion: number): RuntimeBytes;
826
+ actorVerifyInspectorAuth(ctx: ActorContextHandle, bearerToken?: string | undefined | null): Promise<void>;
827
+ actorQueueHibernationRemoval(ctx: ActorContextHandle, connId: string): void;
828
+ actorTakePendingHibernationChanges(ctx: ActorContextHandle): string[];
829
+ actorDirtyHibernatableConns(ctx: ActorContextHandle): ConnHandle[];
830
+ actorSaveState(ctx: ActorContextHandle, payload: RuntimeStateDeltaPayload): Promise<void>;
831
+ actorId(ctx: ActorContextHandle): string;
832
+ actorName(ctx: ActorContextHandle): string;
833
+ actorKey(ctx: ActorContextHandle): RuntimeActorKeySegment[];
834
+ actorRegion(ctx: ActorContextHandle): string;
835
+ actorSleep(ctx: ActorContextHandle): void;
836
+ actorDestroy(ctx: ActorContextHandle): void;
837
+ actorAbortSignal(ctx: ActorContextHandle): AbortSignal;
838
+ actorConns(ctx: ActorContextHandle): ConnHandle[];
839
+ actorConnectConn(ctx: ActorContextHandle, params: RuntimeBytes, request?: RuntimeHttpRequest | undefined | null): Promise<ConnHandle>;
840
+ actorBroadcast(ctx: ActorContextHandle, name: string, args: RuntimeBytes): void;
841
+ actorWaitUntil(ctx: ActorContextHandle, promise: Promise<unknown>): void;
842
+ actorWaitForTrackedShutdownWork(ctx: ActorContextHandle): Promise<boolean>;
843
+ actorWaitForTrackedShutdownWorkUnbounded(ctx: ActorContextHandle): Promise<void>;
844
+ actorKeepAwake(ctx: ActorContextHandle, promise: Promise<unknown>): void;
845
+ actorBeginKeepAwake(ctx: ActorContextHandle): number;
846
+ actorEndKeepAwake(ctx: ActorContextHandle, regionId: number): void;
847
+ actorRegisterTask(ctx: ActorContextHandle, promise: Promise<unknown>): void;
848
+ actorRuntimeState(ctx: ActorContextHandle): object;
849
+ actorClearRuntimeState(ctx: ActorContextHandle): void;
850
+ actorRestartRunHandler(ctx: ActorContextHandle): void;
851
+ actorBeginWebsocketCallback(ctx: ActorContextHandle): number;
852
+ actorEndWebsocketCallback(ctx: ActorContextHandle, regionId: number): void;
853
+ actorKvGet(ctx: ActorContextHandle, key: RuntimeBytes): Promise<RuntimeBytes | null>;
854
+ actorKvPut(ctx: ActorContextHandle, key: RuntimeBytes, value: RuntimeBytes): Promise<void>;
855
+ actorKvDelete(ctx: ActorContextHandle, key: RuntimeBytes): Promise<void>;
856
+ actorKvDeleteRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes): Promise<void>;
857
+ actorKvListPrefix(ctx: ActorContextHandle, prefix: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
858
+ actorKvListRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
859
+ actorKvBatchGet(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<Array<RuntimeBytes | undefined | null>>;
860
+ actorKvBatchPut(ctx: ActorContextHandle, entries: RuntimeKvEntry[]): Promise<void>;
861
+ actorKvBatchDelete(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<void>;
862
+ actorSqlExec(ctx: ActorContextHandle, sql: string): Promise<RuntimeSqlExecResult>;
863
+ actorSqlExecute(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
864
+ actorSqlQuery(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlQueryResult>;
865
+ actorSqlRun(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlRunResult>;
866
+ actorSqlMetrics(ctx: ActorContextHandle): SqliteNativeMetrics | null;
867
+ actorSqlTakeLastKvError(ctx: ActorContextHandle): string | null;
868
+ actorSqlClose(ctx: ActorContextHandle): Promise<void>;
869
+ actorQueueSend(ctx: ActorContextHandle, name: string, body: RuntimeBytes): Promise<RuntimeQueueMessage>;
870
+ actorQueueNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueNextBatchOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage[]>;
871
+ actorQueueWaitForNames(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage>;
872
+ actorQueueWaitForNamesAvailable(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<void>;
873
+ actorQueueEnqueueAndWait(ctx: ActorContextHandle, name: string, body: RuntimeBytes, options?: RuntimeQueueEnqueueAndWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeBytes | null>;
874
+ actorQueueTryNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueTryNextBatchOptions | undefined | null): RuntimeQueueMessage[];
875
+ actorQueueMaxSize(ctx: ActorContextHandle): number;
876
+ actorQueueInspectMessages(ctx: ActorContextHandle): Promise<RuntimeQueueInspectMessage[]>;
877
+ actorScheduleAfter(ctx: ActorContextHandle, durationMs: number, actionName: string, args: RuntimeBytes): void;
878
+ actorScheduleAt(ctx: ActorContextHandle, timestampMs: number, actionName: string, args: RuntimeBytes): void;
879
+ connId(conn: ConnHandle): string;
880
+ connParams(conn: ConnHandle): RuntimeBytes;
881
+ connState(conn: ConnHandle): RuntimeBytes;
882
+ connSetState(conn: ConnHandle, state: RuntimeBytes): void;
883
+ connIsHibernatable(conn: ConnHandle): boolean;
884
+ connSend(conn: ConnHandle, name: string, args: RuntimeBytes): void;
885
+ connDisconnect(conn: ConnHandle, reason?: string | undefined | null): Promise<void>;
886
+ webSocketSend(ws: WebSocketHandle, data: RuntimeBytes, binary: boolean): void;
887
+ webSocketClose(ws: WebSocketHandle, code?: number | undefined | null, reason?: string | undefined | null): Promise<void>;
888
+ webSocketSetEventCallback(ws: WebSocketHandle, callback: (event: RuntimeWebSocketEvent) => void): void;
889
+ }
890
+
891
+ declare function buildConfiguredRegistry(config: RegistryConfig): Promise<{
892
+ runtime: CoreRuntime;
893
+ registry: RegistryHandle;
894
+ serveConfig: RuntimeServeConfig;
895
+ }>;
896
+
560
897
  type FetchHandler = (request: Request, ...args: any) => Response | Promise<Response>;
561
898
  interface ServerlessHandler {
562
899
  fetch: FetchHandler;
563
900
  }
564
- interface RegistryDiagnostics {
565
- mode: string;
566
- envoyActiveActorCount?: number | null;
901
+ interface RegistryRoutes {
902
+ health(): Promise<Response>;
903
+ metadata(): Promise<Response>;
904
+ prometheusMetrics(request?: Request): Promise<Response>;
905
+ }
906
+ /**
907
+ * Injectable dependencies for {@link Registry}. Production code uses the
908
+ * defaults. Tests override `buildConfiguredRegistry` to drive lifecycle
909
+ * orchestration against a fake `CoreRuntime` without an engine.
910
+ */
911
+ interface RegistryDeps {
912
+ buildConfiguredRegistry: typeof buildConfiguredRegistry;
567
913
  }
568
914
  declare class Registry<A extends RegistryActors> {
569
915
  #private;
916
+ readonly routes: RegistryRoutes;
570
917
  get config(): RegistryConfigInput<A>;
571
918
  parseConfig(): RegistryConfig;
572
- constructor(config: RegistryConfigInput<A>);
919
+ constructor(config: RegistryConfigInput<A>, deps?: Partial<RegistryDeps>);
573
920
  /**
574
921
  * Handle an incoming HTTP request for serverless deployments.
575
922
  *
@@ -609,7 +956,27 @@ declare class Registry<A extends RegistryActors> {
609
956
  port?: number;
610
957
  publicDir?: string;
611
958
  }): Promise<void>;
612
- diagnostics(): Promise<RegistryDiagnostics>;
959
+ /**
960
+ * Gracefully drains all live registries.
961
+ *
962
+ * Programmatic counterpart to the SIGINT/SIGTERM handlers: tears down
963
+ * every live `CoreRegistry` (both `start()` and `handler()` modes) and
964
+ * waits for the serve promise to resolve, all bounded by the shutdown
965
+ * grace period. Unlike a signal-driven shutdown, this does not re-raise a
966
+ * signal or exit the process. The caller owns process lifetime.
967
+ *
968
+ * Idempotent: concurrent or repeated calls share a single drain. Safe to
969
+ * call even if nothing has been started.
970
+ *
971
+ * @example
972
+ * ```ts
973
+ * const registry = setup({ use: { counter } });
974
+ * registry.start();
975
+ * // ...later, on your own shutdown trigger:
976
+ * await registry.shutdown();
977
+ * ```
978
+ */
979
+ shutdown(): Promise<void>;
613
980
  startEnvoy(): void;
614
981
  /**
615
982
  * Starts the actor envoy for standalone server deployments.
@@ -649,6 +1016,12 @@ interface QueueSendResult<TResponse = unknown> {
649
1016
  * @returns {Promise<Response>}
650
1017
  */
651
1018
  type ActorActionFunction<Args extends Array<unknown> = unknown[], Response = unknown> = (...args: Args extends [unknown, ...infer Rest] ? Rest : Args) => Promise<Response>;
1019
+ type IsAny<T> = 0 extends 1 & T ? true : false;
1020
+ type LooseEventSubscribe = (eventName: string, callback: (...args: any[]) => void) => () => void;
1021
+ type ActorActionMap<R> = {
1022
+ [K in keyof NonNullable<R>]: NonNullable<R>[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Awaited<Return>> : never;
1023
+ };
1024
+ type ActionsOf<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<any, any, any, any, any, any, any, any, infer R> ? R : never;
652
1025
  interface ActorGatewayOptions {
653
1026
  skipReadyWait?: boolean;
654
1027
  }
@@ -661,9 +1034,7 @@ type ActorWebSocketOptions = ActorGatewayOptions;
661
1034
  /**
662
1035
  * Maps action methods from actor definition to typed function signatures.
663
1036
  */
664
- type ActorDefinitionActions<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<any, any, any, any, any, any, any, any, infer R> ? {
665
- [K in keyof R]: R[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Return> : never;
666
- } : never;
1037
+ type ActorDefinitionActions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? Record<string, ActorActionFunction<any[], any>> : ActorActionMap<ActionsOf<AD>>;
667
1038
  type ActorQueueSend<TQueues extends QueueSchemaConfig> = {
668
1039
  <K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options: QueueSendWaitOptions): Promise<QueueSendResult<InferQueueCompleteMap<TQueues>[K]>>;
669
1040
  <K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options?: QueueSendNoWaitOptions): Promise<void>;
@@ -674,13 +1045,31 @@ type ActorEventSubscribe<TEvents extends EventSchemaConfig> = {
674
1045
  <K extends keyof TEvents & string>(eventName: K, callback: (...args: InferEventArgs<InferSchemaMap<TEvents>[K]>) => void): () => void;
675
1046
  (eventName: keyof TEvents extends never ? string : never, callback: (...args: any[]) => void): () => void;
676
1047
  };
677
- type ActorDefinitionQueueSend<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<any, any, any, any, any, any, any, infer Q, any> ? Q extends QueueSchemaConfig ? {
1048
+ type ActorDefinitionQueueSend<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
1049
+ send: ActorQueueSend<Record<string, any>>;
1050
+ } : AD extends {
1051
+ config: {
1052
+ queues?: infer Q;
1053
+ };
1054
+ } ? Q extends QueueSchemaConfig ? {
1055
+ send: ActorQueueSend<Q>;
1056
+ } : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, any, infer Q, any> ? Q extends QueueSchemaConfig ? {
678
1057
  send: ActorQueueSend<Q>;
679
- } : never : never;
680
- type ActorDefinitionEventSubscriptions<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<any, any, any, any, any, any, infer E, any, any> ? E extends EventSchemaConfig ? {
1058
+ } : {} : {};
1059
+ type ActorDefinitionEventSubscriptions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
1060
+ on: LooseEventSubscribe;
1061
+ once: LooseEventSubscribe;
1062
+ } : AD extends {
1063
+ config: {
1064
+ events?: infer E;
1065
+ };
1066
+ } ? E extends EventSchemaConfig ? {
1067
+ on: ActorEventSubscribe<E>;
1068
+ once: ActorEventSubscribe<E>;
1069
+ } : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, infer E, any, any> ? E extends EventSchemaConfig ? {
681
1070
  on: ActorEventSubscribe<E>;
682
1071
  once: ActorEventSubscribe<E>;
683
- } : never : never;
1072
+ } : {} : {};
684
1073
 
685
1074
  type ActorResolutionState = ActorQuery;
686
1075
 
@@ -1173,6 +1562,10 @@ type ActorKvListOptions<T extends ActorKvValueType = "text", K extends ActorKvKe
1173
1562
  limit?: number;
1174
1563
  };
1175
1564
  type ActorClientFor<T> = T extends Registry<any> ? Client<T> : T;
1565
+ /**
1566
+ * @deprecated Actor KV is deprecated. Use embedded SQLite (`c.db` / `c.sql`)
1567
+ * or actor state instead.
1568
+ */
1176
1569
  interface ActorKv {
1177
1570
  get<T extends ActorKvValueType = "text">(key: Uint8Array | string, options?: ActorKvValueOptions<T>): Promise<ActorKvValueTypeMap[T] | null>;
1178
1571
  put<T extends ActorKvValueType = "text">(key: Uint8Array | string, value: Uint8Array | string | ArrayBuffer, options?: ActorKvValueOptions<T>): Promise<void>;
@@ -1255,7 +1648,7 @@ interface ActorQueue<TQueues extends QueueSchemaConfig = Record<never, never>> {
1255
1648
  iter<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueIterOptions<TName, TCompletable>): AsyncIterable<any>;
1256
1649
  [key: string]: any;
1257
1650
  }
1258
- 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>> {
1651
+ 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>> {
1259
1652
  id: string;
1260
1653
  params: TConnParams;
1261
1654
  state: TConnState;
@@ -1271,6 +1664,10 @@ interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase
1271
1664
  [RAW_STATE_SYMBOL](): TState;
1272
1665
  state: TState;
1273
1666
  vars: TVars;
1667
+ /**
1668
+ * @deprecated Actor KV is deprecated. Use embedded SQLite (`db` / `sql`)
1669
+ * or actor state instead.
1670
+ */
1274
1671
  readonly kv: ActorKv;
1275
1672
  readonly db: InferDatabaseClient<TDatabase>;
1276
1673
  readonly schedule: ActorSchedule;
@@ -1336,6 +1733,75 @@ interface WorkflowInspectorConfig<THistory = unknown> {
1336
1733
  interface RunInspectorConfig<THistory = unknown> {
1337
1734
  workflow?: WorkflowInspectorConfig<THistory>;
1338
1735
  }
1736
+ /**
1737
+ * Built-in inspector tabs the dashboard ships. Used to validate
1738
+ * `hidden: true` entries and reject custom-tab ids that collide with
1739
+ * a built-in.
1740
+ */
1741
+ declare const BUILTIN_INSPECTOR_TAB_IDS: readonly ["workflow", "database", "state", "queue", "connections", "console"];
1742
+ declare const BuiltinInspectorTabIdSchema: z.ZodEnum<{
1743
+ workflow: "workflow";
1744
+ state: "state";
1745
+ database: "database";
1746
+ queue: "queue";
1747
+ connections: "connections";
1748
+ console: "console";
1749
+ }>;
1750
+ declare const CustomInspectorTabEntrySchema: z.ZodObject<{
1751
+ id: z.ZodString;
1752
+ label: z.ZodString;
1753
+ source: z.ZodString;
1754
+ icon: z.ZodOptional<z.ZodString>;
1755
+ hidden: z.ZodOptional<z.ZodLiteral<false>>;
1756
+ }, z.core.$strict>;
1757
+ declare const HideInspectorTabEntrySchema: z.ZodObject<{
1758
+ id: z.ZodEnum<{
1759
+ workflow: "workflow";
1760
+ state: "state";
1761
+ database: "database";
1762
+ queue: "queue";
1763
+ connections: "connections";
1764
+ console: "console";
1765
+ }>;
1766
+ hidden: z.ZodLiteral<true>;
1767
+ }, z.core.$strict>;
1768
+ declare const InspectorTabEntrySchema: z.ZodUnion<readonly [z.ZodObject<{
1769
+ id: z.ZodString;
1770
+ label: z.ZodString;
1771
+ source: z.ZodString;
1772
+ icon: z.ZodOptional<z.ZodString>;
1773
+ hidden: z.ZodOptional<z.ZodLiteral<false>>;
1774
+ }, z.core.$strict>, z.ZodObject<{
1775
+ id: z.ZodEnum<{
1776
+ workflow: "workflow";
1777
+ state: "state";
1778
+ database: "database";
1779
+ queue: "queue";
1780
+ connections: "connections";
1781
+ console: "console";
1782
+ }>;
1783
+ hidden: z.ZodLiteral<true>;
1784
+ }, z.core.$strict>]>;
1785
+ declare const ActorInspectorConfigSchema: z.ZodObject<{
1786
+ tabs: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
1787
+ id: z.ZodString;
1788
+ label: z.ZodString;
1789
+ source: z.ZodString;
1790
+ icon: z.ZodOptional<z.ZodString>;
1791
+ hidden: z.ZodOptional<z.ZodLiteral<false>>;
1792
+ }, z.core.$strict>, z.ZodObject<{
1793
+ id: z.ZodEnum<{
1794
+ workflow: "workflow";
1795
+ state: "state";
1796
+ database: "database";
1797
+ queue: "queue";
1798
+ connections: "connections";
1799
+ console: "console";
1800
+ }>;
1801
+ hidden: z.ZodLiteral<true>;
1802
+ }, z.core.$strict>]>>>;
1803
+ }, z.core.$strict>;
1804
+ type ActorInspectorConfig = z.input<typeof ActorInspectorConfigSchema>;
1339
1805
  declare const RunConfigSchema: z.ZodObject<{
1340
1806
  name: z.ZodOptional<z.ZodString>;
1341
1807
  icon: z.ZodOptional<z.ZodString>;
@@ -1477,8 +1943,27 @@ declare const ActorConfigSchema: z.ZodObject<{
1477
1943
  preloadMaxWorkflowBytes: z.ZodOptional<z.ZodNumber>;
1478
1944
  preloadMaxConnectionsBytes: z.ZodOptional<z.ZodNumber>;
1479
1945
  }, z.core.$strict>>;
1946
+ inspector: z.ZodOptional<z.ZodObject<{
1947
+ tabs: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
1948
+ id: z.ZodString;
1949
+ label: z.ZodString;
1950
+ source: z.ZodString;
1951
+ icon: z.ZodOptional<z.ZodString>;
1952
+ hidden: z.ZodOptional<z.ZodLiteral<false>>;
1953
+ }, z.core.$strict>, z.ZodObject<{
1954
+ id: z.ZodEnum<{
1955
+ workflow: "workflow";
1956
+ state: "state";
1957
+ database: "database";
1958
+ queue: "queue";
1959
+ connections: "connections";
1960
+ console: "console";
1961
+ }>;
1962
+ hidden: z.ZodLiteral<true>;
1963
+ }, z.core.$strict>]>>>;
1964
+ }, z.core.$strict>>;
1480
1965
  }, z.core.$strict>;
1481
- type CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
1966
+ type CreateState<TState, _TConnParams, _TConnState, _TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
1482
1967
  state: TState;
1483
1968
  } | {
1484
1969
  createState: (c: CreateContext<TState, TInput, TDatabase, TEvents, TQueues>, input: TInput) => TState | Promise<TState>;
@@ -1491,7 +1976,7 @@ type CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase e
1491
1976
  /**
1492
1977
  * @experimental
1493
1978
  */
1494
- type CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
1979
+ type CreateVars<TState, _TConnParams, _TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
1495
1980
  /**
1496
1981
  * @experimental
1497
1982
  */
@@ -1681,7 +2166,7 @@ type ActorDatabaseConfig<TDatabase extends AnyDatabaseProvider> = {
1681
2166
  */
1682
2167
  db: TDatabase;
1683
2168
  } | Record<never, never>;
1684
- 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>;
2169
+ 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>;
1685
2170
  type ActorConfigInput<TState = undefined, TConnParams = undefined, TConnState = undefined, TVars = undefined, TInput = undefined, TDatabase extends AnyDatabaseProvider = undefined, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> = Record<never, never>> = {
1686
2171
  types?: ActorTypes<TState, TConnParams, TConnState, TVars, TInput, TDatabase>;
1687
2172
  } & Omit<z.input<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>;
@@ -1760,4 +2245,4 @@ declare const DocActorConfigSchema: z.ZodObject<{
1760
2245
  }, z.core.$strip>>;
1761
2246
  }, z.core.$strip>;
1762
2247
 
1763
- export { DocConfigurePoolSchema as $, type AnyActorDefinition as A, type BaseActorDefinition as B, type ConnectContext as C, type DestroyContext as D, type EventSchemaConfig as E, type ActorSchedule as F, type ActorTypes as G, ActorsSchema as H, type AnyActorInstance as I, type AnyClient as J, type AnyConn as K, type AnyStaticActorDefinition as L, type MigrateContext as M, type AnyStaticActorInstance as N, type AuthIntent as O, type BaseActorInstance as P, type QueueSchemaConfig as Q, type RequestContext as R, type SleepContext as S, CONN_DRIVER_SYMBOL as T, CONN_STATE_MANAGER_SYMBOL as U, type Client as V, type WakeContext as W, type Conn as X, DEFAULT_SLEEP_GRACE_PERIOD as Y, DocActorConfigSchema as Z, DocActorOptionsSchema as _, type ActionContext as a, type ActorAccessor as a$, DocEnvoyConfigSchema as a0, DocRegistryConfigSchema as a1, DocServerlessConfigSchema as a2, DocSqliteConfigSchema as a3, type Encoding as a4, type FetchHandler as a5, type GlobalActorOptions as a6, type GlobalActorOptionsInput as a7, GlobalActorOptionsSchema as a8, type InspectorUnsubscribe as a9, RuntimeKindSchema as aA, type ServerlessHandler as aB, type SqliteBackend as aC, SqliteBackendSchema as aD, type SqliteConfig as aE, SqliteConfigSchema as aF, type TestConfig as aG, TestConfigSchema as aH, type Type as aI, type WasmRuntimeBindings as aJ, type WasmRuntimeConfig as aK, WasmRuntimeConfigSchema as aL, type WasmRuntimeInitInput as aM, type WorkflowInspectorConfig as aN, actor as aO, buildActorNames as aP, createClientWithDriver as aQ, event as aR, getRunFunction as aS, getRunInspectorConfig as aT, getRunMetadata as aU, isStaticActorDefinition as aV, isStaticActorInstance as aW, lookupInRegistry as aX, queue as aY, setup as aZ, test as a_, type InstanceActorOptions as aa, type InstanceActorOptionsInput as ab, InstanceActorOptionsSchema as ac, type QueueEnqueueAndWaitOptions as ad, type QueueFilterName as ae, type QueueIterOptions as af, type QueueMessageOf as ag, type QueueName as ah, type QueueNextBatchOptions as ai, type QueueNextOptions as aj, type QueueResultMessageForName as ak, type QueueTryNextBatchOptions as al, type QueueTryNextOptions as am, type QueueWaitOptions as an, RAW_STATE_SYMBOL as ao, RUN_FUNCTION_CONFIG_SYMBOL as ap, Registry as aq, type RegistryActors as ar, type RegistryConfig as as, type RegistryConfigInput as at, RegistryConfigSchema as au, type RegistryDiagnostics as av, type RunConfig as aw, RunConfigSchema as ax, type RunInspectorConfig as ay, type RuntimeKind as az, type BeforeActionResponseContext as b, type ActorActionFunction as b0, type ActorActionOptions as b1, type ActorConn as b2, ActorConnRaw as b3, type ActorConnStatus as b4, type ActorConnectOptions as b5, type ActorGatewayOptions as b6, type ActorHandle as b7, ActorHandleRaw as b8, ClientRaw as b9, type ConnectionStateCallback as ba, type CreateOptions as bb, type CreateRequest as bc, type EventUnsubscribe as bd, type ExtractActorsFromRegistry as be, type ExtractRegistryFromClient as bf, type GetOptions as bg, type GetWithIdOptions as bh, type QueryOptions as bi, type Region as bj, type StatusChangeCallback as bk, type InferSchemaMap as bl, type InferEventArgs as bm, type BeforeConnectContext as c, type CreateConnStateContext as d, type CreateContext as e, type CreateVarsContext as f, type DisconnectContext as g, type RunContext as h, type StateChangeContext as i, type WebSocketContext as j, ACTOR_CONTEXT_INTERNAL_SYMBOL as k, type Actions as l, type ActorConfig as m, type ActorConfigInput as n, ActorConfigSchema as o, type ActorContext as p, type ActorContextOf as q, ActorDefinition as r, type ActorKey as s, type ActorKv as t, type ActorLogger as u, type ActorOptions as v, type ActorOptionsInput as w, ActorOptionsSchema as x, type ActorQuery as y, type ActorQueue as z };
2248
+ export { type Conn as $, type AnyActorDefinition as A, type BaseActorDefinition as B, type ConnectContext as C, type DestroyContext as D, type EventSchemaConfig as E, type ActorQuery as F, type ActorQueue as G, type ActorSchedule as H, type ActorTypes as I, ActorsSchema as J, type AnyActorInstance as K, type AnyClient as L, type MigrateContext as M, type AnyConn as N, type AnyStaticActorDefinition as O, type AnyStaticActorInstance as P, type QueueSchemaConfig as Q, type RequestContext as R, type SleepContext as S, type AuthIntent as T, BUILTIN_INSPECTOR_TAB_IDS as U, type BaseActorInstance as V, type WakeContext as W, BuiltinInspectorTabIdSchema as X, CONN_DRIVER_SYMBOL as Y, CONN_STATE_MANAGER_SYMBOL as Z, type Client as _, type ActionContext as a, getRunInspectorConfig as a$, CustomInspectorTabEntrySchema as a0, DEFAULT_SLEEP_GRACE_PERIOD as a1, DocActorConfigSchema as a2, DocActorOptionsSchema as a3, DocConfigurePoolSchema as a4, DocEnvoyConfigSchema as a5, DocRegistryConfigSchema as a6, DocServerlessConfigSchema as a7, DocSqliteConfigSchema as a8, type Encoding as a9, type RegistryConfigInput as aA, RegistryConfigSchema as aB, type RegistryDeps as aC, type RegistryRoutes as aD, type RunConfig as aE, RunConfigSchema as aF, type RunInspectorConfig as aG, type RuntimeKind as aH, RuntimeKindSchema as aI, type ServerlessHandler as aJ, type SqliteBackend as aK, SqliteBackendSchema as aL, type SqliteConfig as aM, SqliteConfigSchema as aN, type TestConfig as aO, TestConfigSchema as aP, type Type as aQ, type WasmRuntimeBindings as aR, type WasmRuntimeConfig as aS, WasmRuntimeConfigSchema as aT, type WasmRuntimeInitInput as aU, type WorkflowInspectorConfig as aV, actor as aW, buildActorNames as aX, createClientWithDriver as aY, event as aZ, getRunFunction as a_, type FetchHandler as aa, type GlobalActorOptions as ab, type GlobalActorOptionsInput as ac, GlobalActorOptionsSchema as ad, HideInspectorTabEntrySchema as ae, InspectorTabEntrySchema as af, type InspectorUnsubscribe as ag, type InstanceActorOptions as ah, type InstanceActorOptionsInput as ai, InstanceActorOptionsSchema as aj, type QueueEnqueueAndWaitOptions as ak, type QueueFilterName as al, type QueueIterOptions as am, type QueueMessageOf as an, type QueueName as ao, type QueueNextBatchOptions as ap, type QueueNextOptions as aq, type QueueResultMessageForName as ar, type QueueTryNextBatchOptions as as, type QueueTryNextOptions as at, type QueueWaitOptions as au, RAW_STATE_SYMBOL as av, RUN_FUNCTION_CONFIG_SYMBOL as aw, Registry as ax, type RegistryActors as ay, type RegistryConfig as az, type BeforeActionResponseContext as b, getRunMetadata as b0, isStaticActorDefinition as b1, isStaticActorInstance as b2, lookupInRegistry as b3, queue as b4, setup as b5, test as b6, type ActorAccessor as b7, type ActorActionFunction as b8, type ActorActionOptions as b9, type ActorConn as ba, ActorConnRaw as bb, type ActorConnStatus as bc, type ActorConnectOptions as bd, type ActorGatewayOptions as be, type ActorHandle as bf, ActorHandleRaw as bg, ClientRaw as bh, type ConnectionStateCallback as bi, type CreateOptions as bj, type CreateRequest as bk, type EventUnsubscribe as bl, type ExtractActorsFromRegistry as bm, type ExtractRegistryFromClient as bn, type GetOptions as bo, type GetWithIdOptions as bp, type QueryOptions as bq, type Region as br, type StatusChangeCallback as bs, type InferSchemaMap as bt, type InferEventArgs as bu, type BeforeConnectContext as c, type CreateConnStateContext as d, type CreateContext as e, type CreateVarsContext as f, type DisconnectContext as g, type RunContext as h, type StateChangeContext as i, type WebSocketContext as j, ACTOR_CONTEXT_INTERNAL_SYMBOL as k, type Actions as l, type ActorConfig as m, type ActorConfigInput as n, ActorConfigSchema as o, type ActorContext as p, type ActorContextOf as q, ActorDefinition as r, type ActorInspectorConfig as s, ActorInspectorConfigSchema as t, type ActorKey as u, type ActorKv as v, type ActorLogger as w, type ActorOptions as x, type ActorOptionsInput as y, ActorOptionsSchema as z };