rivetkit 2.3.0-rc.11 → 2.3.0-rc.13

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 (123) hide show
  1. package/dist/browser/client.d.ts +407 -20
  2. package/dist/browser/client.js +101 -86
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.js +12 -2
  5. package/dist/browser/inspector/client.js.map +1 -1
  6. package/dist/tsup/actor/errors.d.cts +1 -1
  7. package/dist/tsup/actor/errors.d.ts +1 -1
  8. package/dist/tsup/agent-os/index.cjs +66 -3
  9. package/dist/tsup/agent-os/index.cjs.map +1 -1
  10. package/dist/tsup/agent-os/index.d.cts +404 -17
  11. package/dist/tsup/agent-os/index.d.ts +404 -17
  12. package/dist/tsup/agent-os/index.js +66 -3
  13. package/dist/tsup/agent-os/index.js.map +1 -1
  14. package/dist/tsup/{chunk-WXYWDLJY.js → chunk-33YE6XCI.js} +4 -4
  15. package/dist/tsup/{chunk-2NXFKPRB.cjs → chunk-7OR3CHD5.cjs} +10 -10
  16. package/dist/tsup/{chunk-2NXFKPRB.cjs.map → chunk-7OR3CHD5.cjs.map} +1 -1
  17. package/dist/tsup/{chunk-LW5HNCWD.cjs → chunk-7XQCARVY.cjs} +3 -3
  18. package/dist/tsup/{chunk-LW5HNCWD.cjs.map → chunk-7XQCARVY.cjs.map} +1 -1
  19. package/dist/tsup/{chunk-GX6W4MW3.cjs → chunk-BSPS6NSN.cjs} +5 -5
  20. package/dist/tsup/{chunk-GX6W4MW3.cjs.map → chunk-BSPS6NSN.cjs.map} +1 -1
  21. package/dist/tsup/{chunk-T3VCJ4PV.js → chunk-DPIMKYNB.js} +61 -2
  22. package/dist/tsup/chunk-DPIMKYNB.js.map +1 -0
  23. package/dist/tsup/{chunk-XG25CGSW.cjs → chunk-E5CLYAUZ.cjs} +146 -143
  24. package/dist/tsup/chunk-E5CLYAUZ.cjs.map +1 -0
  25. package/dist/tsup/{chunk-RDBGKI66.cjs → chunk-EBWOJRCC.cjs} +22 -5
  26. package/dist/tsup/chunk-EBWOJRCC.cjs.map +1 -0
  27. package/dist/tsup/{chunk-YRQ4F5CD.js → chunk-HHNYEQD3.js} +6 -6
  28. package/dist/tsup/chunk-HHNYEQD3.js.map +1 -0
  29. package/dist/tsup/{chunk-4FP4FFB5.js → chunk-IOUSQVXI.js} +21 -4
  30. package/dist/tsup/chunk-IOUSQVXI.js.map +1 -0
  31. package/dist/tsup/{chunk-LNP7Q6I6.cjs → chunk-ISDKSSYR.cjs} +4 -4
  32. package/dist/tsup/{chunk-LNP7Q6I6.cjs.map → chunk-ISDKSSYR.cjs.map} +1 -1
  33. package/dist/tsup/{chunk-TTLUIDVH.js → chunk-J72WHUBC.js} +12 -9
  34. package/dist/tsup/chunk-J72WHUBC.js.map +1 -0
  35. package/dist/tsup/{chunk-Y3JBOFBG.cjs → chunk-KWABEUUA.cjs} +10 -10
  36. package/dist/tsup/chunk-KWABEUUA.cjs.map +1 -0
  37. package/dist/tsup/{chunk-XCDCURZ4.cjs → chunk-NIY3RSPX.cjs} +62 -3
  38. package/dist/tsup/chunk-NIY3RSPX.cjs.map +1 -0
  39. package/dist/tsup/{chunk-3P2JUHWJ.js → chunk-T44AVAGW.js} +2 -2
  40. package/dist/tsup/{chunk-GRFBV2U7.js → chunk-TCXEM6PA.js} +2 -2
  41. package/dist/tsup/{chunk-KRC4L3YB.js → chunk-ZI5CNA2Z.js} +2 -2
  42. package/dist/tsup/client/mod.cjs +7 -7
  43. package/dist/tsup/client/mod.cjs.map +1 -1
  44. package/dist/tsup/client/mod.d.cts +3 -3
  45. package/dist/tsup/client/mod.d.ts +3 -3
  46. package/dist/tsup/client/mod.js +6 -6
  47. package/dist/tsup/common/log.cjs +2 -2
  48. package/dist/tsup/common/log.js +1 -1
  49. package/dist/tsup/common/websocket.cjs +3 -3
  50. package/dist/tsup/common/websocket.js +2 -2
  51. package/dist/tsup/{config-De5UVu0V.d.ts → config-BxWAw3iH.d.ts} +476 -20
  52. package/dist/tsup/{config-CTwe3WwC.d.cts → config-CZQQ-mso.d.cts} +476 -20
  53. package/dist/tsup/{context-Dmj477Uh.d.cts → context-Bw7xq8w3.d.cts} +1 -1
  54. package/dist/tsup/{context-DPHISlUi.d.ts → context-D8QA76sV.d.ts} +1 -1
  55. package/dist/tsup/dynamic/mod.cjs +2 -2
  56. package/dist/tsup/dynamic/mod.d.cts +2 -2
  57. package/dist/tsup/dynamic/mod.d.ts +2 -2
  58. package/dist/tsup/dynamic/mod.js +1 -1
  59. package/dist/tsup/inspector/mod.cjs +5 -5
  60. package/dist/tsup/inspector/mod.js +4 -4
  61. package/dist/tsup/inspector-tab/mod.cjs +173 -0
  62. package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
  63. package/dist/tsup/inspector-tab/mod.d.cts +250 -0
  64. package/dist/tsup/inspector-tab/mod.d.ts +250 -0
  65. package/dist/tsup/inspector-tab/mod.js +173 -0
  66. package/dist/tsup/inspector-tab/mod.js.map +1 -0
  67. package/dist/tsup/mod.cjs +341 -138
  68. package/dist/tsup/mod.cjs.map +1 -1
  69. package/dist/tsup/mod.d.cts +4 -4
  70. package/dist/tsup/mod.d.ts +4 -4
  71. package/dist/tsup/mod.js +277 -74
  72. package/dist/tsup/mod.js.map +1 -1
  73. package/dist/tsup/test/mod.cjs +10 -10
  74. package/dist/tsup/test/mod.d.cts +2 -2
  75. package/dist/tsup/test/mod.d.ts +2 -2
  76. package/dist/tsup/test/mod.js +6 -6
  77. package/dist/tsup/{utils-DVekpm4I.d.ts → utils-DQosb24I.d.cts} +1 -1
  78. package/dist/tsup/{utils-DVekpm4I.d.cts → utils-DQosb24I.d.ts} +1 -1
  79. package/dist/tsup/utils.cjs +2 -2
  80. package/dist/tsup/utils.d.cts +1 -1
  81. package/dist/tsup/utils.d.ts +1 -1
  82. package/dist/tsup/utils.js +1 -1
  83. package/dist/tsup/workflow/mod.cjs +11 -11
  84. package/dist/tsup/workflow/mod.cjs.map +1 -1
  85. package/dist/tsup/workflow/mod.d.cts +4 -4
  86. package/dist/tsup/workflow/mod.d.ts +4 -4
  87. package/dist/tsup/workflow/mod.js +5 -5
  88. package/package.json +19 -9
  89. package/src/actor/config.ts +111 -10
  90. package/src/actor/definition.ts +6 -5
  91. package/src/actor/instance/mod.ts +4 -4
  92. package/src/actor/mod.ts +2 -0
  93. package/src/client/actor-common.ts +24 -27
  94. package/src/client/actor-handle.ts +2 -1
  95. package/src/common/engine.ts +28 -1
  96. package/src/common/utils.ts +1 -1
  97. package/src/devtools-loader/index.ts +4 -7
  98. package/src/devtools-loader/serve-devtools.ts +26 -0
  99. package/src/drivers/engine/actor-driver.ts +16 -5
  100. package/src/engine-client/actor-http-client.ts +2 -2
  101. package/src/engine-client/api-endpoints.ts +5 -1
  102. package/src/engine-client/ws-proxy.ts +5 -0
  103. package/src/inspector-tab/mod.ts +315 -0
  104. package/src/registry/config/index.ts +40 -16
  105. package/src/registry/index.ts +143 -62
  106. package/src/registry/napi-runtime.ts +6 -0
  107. package/src/registry/native.ts +170 -27
  108. package/src/registry/process-metrics.ts +16 -4
  109. package/src/registry/runtime.ts +26 -0
  110. package/src/registry/wasm-runtime.ts +16 -1
  111. package/src/utils/env-vars.ts +6 -0
  112. package/dist/tsup/chunk-4FP4FFB5.js.map +0 -1
  113. package/dist/tsup/chunk-RDBGKI66.cjs.map +0 -1
  114. package/dist/tsup/chunk-T3VCJ4PV.js.map +0 -1
  115. package/dist/tsup/chunk-TTLUIDVH.js.map +0 -1
  116. package/dist/tsup/chunk-XCDCURZ4.cjs.map +0 -1
  117. package/dist/tsup/chunk-XG25CGSW.cjs.map +0 -1
  118. package/dist/tsup/chunk-Y3JBOFBG.cjs.map +0 -1
  119. package/dist/tsup/chunk-YRQ4F5CD.js.map +0 -1
  120. /package/dist/tsup/{chunk-WXYWDLJY.js.map → chunk-33YE6XCI.js.map} +0 -0
  121. /package/dist/tsup/{chunk-3P2JUHWJ.js.map → chunk-T44AVAGW.js.map} +0 -0
  122. /package/dist/tsup/{chunk-GRFBV2U7.js.map → chunk-TCXEM6PA.js.map} +0 -0
  123. /package/dist/tsup/{chunk-KRC4L3YB.js.map → chunk-ZI5CNA2Z.js.map} +0 -0
@@ -179,6 +179,8 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
179
179
  httpPort: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
180
180
  httpHost: z.ZodOptional<z.ZodString>;
181
181
  startEngine: z.ZodDefault<z.ZodBoolean>;
182
+ engineHost: z.ZodDefault<z.ZodOptional<z.ZodString>>;
183
+ enginePort: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
182
184
  engineVersion: z.ZodDefault<z.ZodOptional<z.ZodString>>;
183
185
  configurePool: z.ZodOptional<z.ZodOptional<z.ZodObject<{
184
186
  name: z.ZodOptional<z.ZodString>;
@@ -203,7 +205,7 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
203
205
  envoyKey: z.ZodOptional<z.ZodString>;
204
206
  }, z.core.$strip>>>;
205
207
  shutdown: z.ZodDefault<z.ZodOptional<z.ZodObject<{
206
- gracePeriodMs: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
208
+ gracePeriodMs: z.ZodOptional<z.ZodNumber>;
207
209
  disableSignalHandlers: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
208
210
  }, z.core.$strip>>>;
209
211
  }, z.core.$strip>, z.ZodTransform<{
@@ -244,6 +246,8 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
244
246
  httpBasePath: string;
245
247
  httpPort: number;
246
248
  startEngine: boolean;
249
+ engineHost: string;
250
+ enginePort: number;
247
251
  engineVersion: string;
248
252
  envoy: {
249
253
  poolName: string;
@@ -252,8 +256,8 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
252
256
  envoyKey?: string | undefined;
253
257
  };
254
258
  shutdown: {
255
- gracePeriodMs: number;
256
259
  disableSignalHandlers: boolean;
260
+ gracePeriodMs?: number | undefined;
257
261
  };
258
262
  staticDir?: string | undefined;
259
263
  httpHost?: string | undefined;
@@ -295,6 +299,8 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
295
299
  httpBasePath: string;
296
300
  httpPort: number;
297
301
  startEngine: boolean;
302
+ engineHost: string;
303
+ enginePort: number;
298
304
  engineVersion: string;
299
305
  serverless: {
300
306
  basePath: string;
@@ -309,8 +315,8 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
309
315
  envoyKey?: string | undefined;
310
316
  };
311
317
  shutdown: {
312
- gracePeriodMs: number;
313
318
  disableSignalHandlers: boolean;
319
+ gracePeriodMs?: number | undefined;
314
320
  };
315
321
  staticDir?: string | undefined;
316
322
  httpHost?: string | undefined;
@@ -369,15 +375,15 @@ type InferQueueCompleteMap<T extends QueueSchemaConfig> = {
369
375
  type InferEventArgs<T> = T extends readonly unknown[] ? number extends T["length"] ? [T] : T : [T];
370
376
 
371
377
  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>> {
372
- readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q>;
378
+ readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q, _R>;
373
379
  }
374
380
  interface AnyActorDefinition {
375
381
  readonly config: any;
376
382
  }
377
383
  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> {
378
384
  #private;
379
- constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q>);
380
- get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q>;
385
+ constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q, R>);
386
+ get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q, R>;
381
387
  }
382
388
 
383
389
  declare const EncodingSchema: z$1.ZodEnum<{
@@ -554,6 +560,335 @@ interface ActorOutput {
554
560
  error?: unknown;
555
561
  }
556
562
 
563
+ declare const handleBrand: unique symbol;
564
+ type OpaqueHandle<Name extends string> = {
565
+ readonly [handleBrand]: Name;
566
+ };
567
+ type RegistryHandle = OpaqueHandle<"registry">;
568
+ type ActorFactoryHandle = OpaqueHandle<"actorFactory">;
569
+ type ActorContextHandle = OpaqueHandle<"actorContext">;
570
+ type ConnHandle = OpaqueHandle<"conn">;
571
+ type WebSocketHandle = OpaqueHandle<"webSocket">;
572
+ type CancellationTokenHandle = OpaqueHandle<"cancellationToken">;
573
+ type RuntimeBytes = Uint8Array;
574
+ interface RuntimeActorKeySegment {
575
+ kind: string;
576
+ stringValue?: string;
577
+ numberValue?: number;
578
+ }
579
+ interface RuntimeHttpRequest {
580
+ method: string;
581
+ uri: string;
582
+ headers?: Record<string, string>;
583
+ body?: RuntimeBytes;
584
+ }
585
+ interface RuntimeStateDeltaPayload {
586
+ state?: RuntimeBytes;
587
+ connHibernation: Array<{
588
+ connId: string;
589
+ bytes: RuntimeBytes;
590
+ }>;
591
+ connHibernationRemoved: string[];
592
+ }
593
+ interface RuntimeRequestSaveOpts {
594
+ immediate?: boolean;
595
+ maxWaitMs?: number;
596
+ }
597
+ interface RuntimeInspectorSnapshot {
598
+ stateRevision: number;
599
+ connectionsRevision: number;
600
+ queueRevision: number;
601
+ activeConnections: number;
602
+ queueSize: number;
603
+ connectedClients: number;
604
+ }
605
+ interface RuntimeQueueMessage {
606
+ id(): bigint;
607
+ name(): string;
608
+ body(): RuntimeBytes;
609
+ createdAt(): number;
610
+ isCompletable(): boolean;
611
+ complete(response?: RuntimeBytes | undefined | null): Promise<void>;
612
+ }
613
+ interface RuntimeQueueInspectMessage {
614
+ id: number;
615
+ name: string;
616
+ createdAtMs: number;
617
+ }
618
+ interface RuntimeQueueNextBatchOptions {
619
+ names?: string[];
620
+ count?: number;
621
+ timeoutMs?: number;
622
+ completable?: boolean;
623
+ }
624
+ interface RuntimeQueueWaitOptions {
625
+ timeoutMs?: number;
626
+ completable?: boolean;
627
+ }
628
+ interface RuntimeQueueEnqueueAndWaitOptions {
629
+ timeoutMs?: number;
630
+ }
631
+ interface RuntimeQueueTryNextBatchOptions {
632
+ names?: string[];
633
+ count?: number;
634
+ completable?: boolean;
635
+ }
636
+ interface RuntimeKvListOptions {
637
+ reverse?: boolean;
638
+ limit?: number;
639
+ }
640
+ interface RuntimeKvEntry {
641
+ key: RuntimeBytes;
642
+ value: RuntimeBytes;
643
+ }
644
+ type RuntimeSqlBindNoValues = {
645
+ intValue?: never;
646
+ floatValue?: never;
647
+ textValue?: never;
648
+ blobValue?: never;
649
+ };
650
+ type RuntimeSqlBindParam = ({
651
+ kind: "null";
652
+ } & RuntimeSqlBindNoValues) | {
653
+ kind: "int";
654
+ intValue: number;
655
+ floatValue?: never;
656
+ textValue?: never;
657
+ blobValue?: never;
658
+ } | {
659
+ kind: "float";
660
+ intValue?: never;
661
+ floatValue: number;
662
+ textValue?: never;
663
+ blobValue?: never;
664
+ } | {
665
+ kind: "text";
666
+ intValue?: never;
667
+ floatValue?: never;
668
+ textValue: string;
669
+ blobValue?: never;
670
+ } | {
671
+ kind: "blob";
672
+ intValue?: never;
673
+ floatValue?: never;
674
+ textValue?: never;
675
+ blobValue: RuntimeBytes;
676
+ };
677
+ type RuntimeSqlBindParams = RuntimeSqlBindParam[] | null;
678
+ interface RuntimeSqlQueryResult {
679
+ columns: string[];
680
+ rows: unknown[][];
681
+ }
682
+ type RuntimeSqlExecResult = RuntimeSqlQueryResult;
683
+ interface RuntimeSqlExecuteResult extends RuntimeSqlQueryResult {
684
+ changes: number;
685
+ lastInsertRowId?: number | null;
686
+ }
687
+ interface RuntimeSqlRunResult {
688
+ changes: number;
689
+ }
690
+ interface RuntimeActorConfig {
691
+ name?: string;
692
+ icon?: string;
693
+ hasDatabase?: boolean;
694
+ remoteSqlite?: boolean;
695
+ hasState?: boolean;
696
+ canHibernateWebsocket?: boolean;
697
+ stateSaveIntervalMs?: number;
698
+ createStateTimeoutMs?: number;
699
+ onCreateTimeoutMs?: number;
700
+ createVarsTimeoutMs?: number;
701
+ createConnStateTimeoutMs?: number;
702
+ onBeforeConnectTimeoutMs?: number;
703
+ onConnectTimeoutMs?: number;
704
+ onMigrateTimeoutMs?: number;
705
+ onWakeTimeoutMs?: number;
706
+ onBeforeActorStartTimeoutMs?: number;
707
+ actionTimeoutMs?: number;
708
+ onRequestTimeoutMs?: number;
709
+ sleepTimeoutMs?: number;
710
+ noSleep?: boolean;
711
+ sleepGracePeriodMs?: number;
712
+ connectionLivenessTimeoutMs?: number;
713
+ connectionLivenessIntervalMs?: number;
714
+ maxQueueSize?: number;
715
+ maxQueueMessageSize?: number;
716
+ maxIncomingMessageSize?: number;
717
+ maxOutgoingMessageSize?: number;
718
+ preloadMaxWorkflowBytes?: number;
719
+ preloadMaxConnectionsBytes?: number;
720
+ actions?: Array<{
721
+ name: string;
722
+ }>;
723
+ inspectorTabs?: Array<RuntimeInspectorTabEntry>;
724
+ }
725
+ interface RuntimeInspectorTabEntry {
726
+ id: string;
727
+ /** Required for custom entries; omitted for built-in hides. */
728
+ label?: string;
729
+ /**
730
+ * Required for custom entries — absolute path to the source directory.
731
+ * Resolved on the TS side before being handed to the runtime.
732
+ */
733
+ source?: string;
734
+ /** Optional icon id for custom entries. */
735
+ icon?: string;
736
+ /** Set to true for built-in hide entries. */
737
+ hidden?: boolean;
738
+ }
739
+ interface RuntimeServeConfig {
740
+ version: number;
741
+ endpoint: string;
742
+ token?: string;
743
+ namespace: string;
744
+ poolName: string;
745
+ engineBinaryPath?: string;
746
+ engineHost?: string;
747
+ enginePort?: number;
748
+ handleInspectorHttpInRuntime?: boolean;
749
+ inspectorTestToken?: string;
750
+ serverlessBasePath?: string;
751
+ serverlessPackageVersion: string;
752
+ serverlessClientEndpoint?: string;
753
+ serverlessClientNamespace?: string;
754
+ serverlessClientToken?: string;
755
+ serverlessValidateEndpoint: boolean;
756
+ serverlessMaxStartPayloadBytes: number;
757
+ }
758
+ interface RuntimeServerlessRequest {
759
+ method: string;
760
+ url: string;
761
+ headers: Record<string, string>;
762
+ body: RuntimeBytes;
763
+ }
764
+ interface RuntimeServerlessResponseHead {
765
+ status: number;
766
+ headers: Record<string, string>;
767
+ }
768
+ interface RuntimeRegistryRouteResponse {
769
+ status: number;
770
+ headers: Record<string, string>;
771
+ body: RuntimeBytes;
772
+ }
773
+ type RuntimeServerlessStreamEvent = {
774
+ kind: "chunk";
775
+ chunk?: RuntimeBytes;
776
+ } | {
777
+ kind: "end";
778
+ error?: {
779
+ group: string;
780
+ code: string;
781
+ message: string;
782
+ };
783
+ };
784
+ type RuntimeServerlessStreamCallback = (error: unknown, event?: RuntimeServerlessStreamEvent) => unknown;
785
+ type RuntimeWebSocketEvent = {
786
+ kind: "message";
787
+ data: string | RuntimeBytes;
788
+ binary: boolean;
789
+ messageIndex?: number;
790
+ } | {
791
+ kind: "close";
792
+ code: number;
793
+ reason: string;
794
+ wasClean: boolean;
795
+ };
796
+ interface CoreRuntime {
797
+ readonly kind: "napi" | "wasm";
798
+ createRegistry(): RegistryHandle;
799
+ registerActor(registry: RegistryHandle, name: string, factory: ActorFactoryHandle): void;
800
+ serveRegistry(registry: RegistryHandle, config: RuntimeServeConfig): Promise<void>;
801
+ shutdownRegistry(registry: RegistryHandle): Promise<void>;
802
+ registryActorStopThresholdMs?(registry: RegistryHandle): Promise<number | undefined>;
803
+ handleServerlessRequest(registry: RegistryHandle, req: RuntimeServerlessRequest, onStreamEvent: RuntimeServerlessStreamCallback, cancelToken: CancellationTokenHandle, config: RuntimeServeConfig): Promise<RuntimeServerlessResponseHead>;
804
+ registryHealth?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
805
+ registryMetadata?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
806
+ registryMetrics?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
807
+ createActorFactory(callbacks: object, config?: RuntimeActorConfig | undefined | null): ActorFactoryHandle;
808
+ createCancellationToken(): CancellationTokenHandle;
809
+ cancellationTokenAborted(token: CancellationTokenHandle): boolean;
810
+ cancelCancellationToken(token: CancellationTokenHandle): void;
811
+ onCancellationTokenCancelled(token: CancellationTokenHandle, callback: (...args: unknown[]) => unknown): void;
812
+ actorState(ctx: ActorContextHandle): RuntimeBytes;
813
+ actorBeginOnStateChange(ctx: ActorContextHandle): void;
814
+ actorEndOnStateChange(ctx: ActorContextHandle): void;
815
+ actorSetAlarm(ctx: ActorContextHandle, timestampMs?: number | undefined | null): void;
816
+ actorRequestSave(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): void;
817
+ actorRequestSaveAndWait(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): Promise<void>;
818
+ actorInspectorSnapshot(ctx: ActorContextHandle): RuntimeInspectorSnapshot;
819
+ actorDecodeInspectorRequest(ctx: ActorContextHandle, bytes: RuntimeBytes, advertisedVersion: number): RuntimeBytes;
820
+ actorEncodeInspectorResponse(ctx: ActorContextHandle, bytes: RuntimeBytes, targetVersion: number): RuntimeBytes;
821
+ actorVerifyInspectorAuth(ctx: ActorContextHandle, bearerToken?: string | undefined | null): Promise<void>;
822
+ actorQueueHibernationRemoval(ctx: ActorContextHandle, connId: string): void;
823
+ actorTakePendingHibernationChanges(ctx: ActorContextHandle): string[];
824
+ actorDirtyHibernatableConns(ctx: ActorContextHandle): ConnHandle[];
825
+ actorSaveState(ctx: ActorContextHandle, payload: RuntimeStateDeltaPayload): Promise<void>;
826
+ actorId(ctx: ActorContextHandle): string;
827
+ actorName(ctx: ActorContextHandle): string;
828
+ actorKey(ctx: ActorContextHandle): RuntimeActorKeySegment[];
829
+ actorRegion(ctx: ActorContextHandle): string;
830
+ actorSleep(ctx: ActorContextHandle): void;
831
+ actorDestroy(ctx: ActorContextHandle): void;
832
+ actorAbortSignal(ctx: ActorContextHandle): AbortSignal;
833
+ actorConns(ctx: ActorContextHandle): ConnHandle[];
834
+ actorConnectConn(ctx: ActorContextHandle, params: RuntimeBytes, request?: RuntimeHttpRequest | undefined | null): Promise<ConnHandle>;
835
+ actorBroadcast(ctx: ActorContextHandle, name: string, args: RuntimeBytes): void;
836
+ actorWaitUntil(ctx: ActorContextHandle, promise: Promise<unknown>): void;
837
+ actorWaitForTrackedShutdownWork(ctx: ActorContextHandle): Promise<boolean>;
838
+ actorWaitForTrackedShutdownWorkUnbounded(ctx: ActorContextHandle): Promise<void>;
839
+ actorKeepAwake(ctx: ActorContextHandle, promise: Promise<unknown>): void;
840
+ actorBeginKeepAwake(ctx: ActorContextHandle): number;
841
+ actorEndKeepAwake(ctx: ActorContextHandle, regionId: number): void;
842
+ actorRegisterTask(ctx: ActorContextHandle, promise: Promise<unknown>): void;
843
+ actorRuntimeState(ctx: ActorContextHandle): object;
844
+ actorClearRuntimeState(ctx: ActorContextHandle): void;
845
+ actorRestartRunHandler(ctx: ActorContextHandle): void;
846
+ actorBeginWebsocketCallback(ctx: ActorContextHandle): number;
847
+ actorEndWebsocketCallback(ctx: ActorContextHandle, regionId: number): void;
848
+ actorKvGet(ctx: ActorContextHandle, key: RuntimeBytes): Promise<RuntimeBytes | null>;
849
+ actorKvPut(ctx: ActorContextHandle, key: RuntimeBytes, value: RuntimeBytes): Promise<void>;
850
+ actorKvDelete(ctx: ActorContextHandle, key: RuntimeBytes): Promise<void>;
851
+ actorKvDeleteRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes): Promise<void>;
852
+ actorKvListPrefix(ctx: ActorContextHandle, prefix: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
853
+ actorKvListRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
854
+ actorKvBatchGet(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<Array<RuntimeBytes | undefined | null>>;
855
+ actorKvBatchPut(ctx: ActorContextHandle, entries: RuntimeKvEntry[]): Promise<void>;
856
+ actorKvBatchDelete(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<void>;
857
+ actorSqlExec(ctx: ActorContextHandle, sql: string): Promise<RuntimeSqlExecResult>;
858
+ actorSqlExecute(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
859
+ actorSqlQuery(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlQueryResult>;
860
+ actorSqlRun(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlRunResult>;
861
+ actorSqlMetrics(ctx: ActorContextHandle): SqliteNativeMetrics | null;
862
+ actorSqlTakeLastKvError(ctx: ActorContextHandle): string | null;
863
+ actorSqlClose(ctx: ActorContextHandle): Promise<void>;
864
+ actorQueueSend(ctx: ActorContextHandle, name: string, body: RuntimeBytes): Promise<RuntimeQueueMessage>;
865
+ actorQueueNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueNextBatchOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage[]>;
866
+ actorQueueWaitForNames(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage>;
867
+ actorQueueWaitForNamesAvailable(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<void>;
868
+ actorQueueEnqueueAndWait(ctx: ActorContextHandle, name: string, body: RuntimeBytes, options?: RuntimeQueueEnqueueAndWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeBytes | null>;
869
+ actorQueueTryNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueTryNextBatchOptions | undefined | null): RuntimeQueueMessage[];
870
+ actorQueueMaxSize(ctx: ActorContextHandle): number;
871
+ actorQueueInspectMessages(ctx: ActorContextHandle): Promise<RuntimeQueueInspectMessage[]>;
872
+ actorScheduleAfter(ctx: ActorContextHandle, durationMs: number, actionName: string, args: RuntimeBytes): void;
873
+ actorScheduleAt(ctx: ActorContextHandle, timestampMs: number, actionName: string, args: RuntimeBytes): void;
874
+ connId(conn: ConnHandle): string;
875
+ connParams(conn: ConnHandle): RuntimeBytes;
876
+ connState(conn: ConnHandle): RuntimeBytes;
877
+ connSetState(conn: ConnHandle, state: RuntimeBytes): void;
878
+ connIsHibernatable(conn: ConnHandle): boolean;
879
+ connSend(conn: ConnHandle, name: string, args: RuntimeBytes): void;
880
+ connDisconnect(conn: ConnHandle, reason?: string | undefined | null): Promise<void>;
881
+ webSocketSend(ws: WebSocketHandle, data: RuntimeBytes, binary: boolean): void;
882
+ webSocketClose(ws: WebSocketHandle, code?: number | undefined | null, reason?: string | undefined | null): Promise<void>;
883
+ webSocketSetEventCallback(ws: WebSocketHandle, callback: (event: RuntimeWebSocketEvent) => void): void;
884
+ }
885
+
886
+ declare function buildConfiguredRegistry(config: RegistryConfig): Promise<{
887
+ runtime: CoreRuntime;
888
+ registry: RegistryHandle;
889
+ serveConfig: RuntimeServeConfig;
890
+ }>;
891
+
557
892
  type FetchHandler = (request: Request, ...args: any) => Response | Promise<Response>;
558
893
  interface ServerlessHandler {
559
894
  fetch: FetchHandler;
@@ -563,12 +898,20 @@ interface RegistryRoutes {
563
898
  metadata(): Promise<Response>;
564
899
  prometheusMetrics(request?: Request): Promise<Response>;
565
900
  }
901
+ /**
902
+ * Injectable dependencies for {@link Registry}. Production code uses the
903
+ * defaults. Tests override `buildConfiguredRegistry` to drive lifecycle
904
+ * orchestration against a fake `CoreRuntime` without an engine.
905
+ */
906
+ interface RegistryDeps {
907
+ buildConfiguredRegistry: typeof buildConfiguredRegistry;
908
+ }
566
909
  declare class Registry<A extends RegistryActors> {
567
910
  #private;
568
911
  readonly routes: RegistryRoutes;
569
912
  get config(): RegistryConfigInput<A>;
570
913
  parseConfig(): RegistryConfig;
571
- constructor(config: RegistryConfigInput<A>);
914
+ constructor(config: RegistryConfigInput<A>, deps?: Partial<RegistryDeps>);
572
915
  /**
573
916
  * Handle an incoming HTTP request for serverless deployments.
574
917
  *
@@ -608,6 +951,27 @@ declare class Registry<A extends RegistryActors> {
608
951
  port?: number;
609
952
  publicDir?: string;
610
953
  }): Promise<void>;
954
+ /**
955
+ * Gracefully drains all live registries.
956
+ *
957
+ * Programmatic counterpart to the SIGINT/SIGTERM handlers: tears down
958
+ * every live `CoreRegistry` (both `start()` and `handler()` modes) and
959
+ * waits for the serve promise to resolve, all bounded by the shutdown
960
+ * grace period. Unlike a signal-driven shutdown, this does not re-raise a
961
+ * signal or exit the process. The caller owns process lifetime.
962
+ *
963
+ * Idempotent: concurrent or repeated calls share a single drain. Safe to
964
+ * call even if nothing has been started.
965
+ *
966
+ * @example
967
+ * ```ts
968
+ * const registry = setup({ use: { counter } });
969
+ * registry.start();
970
+ * // ...later, on your own shutdown trigger:
971
+ * await registry.shutdown();
972
+ * ```
973
+ */
974
+ shutdown(): Promise<void>;
611
975
  startEnvoy(): void;
612
976
  /**
613
977
  * Starts the actor envoy for standalone server deployments.
@@ -648,6 +1012,10 @@ interface QueueSendResult<TResponse = unknown> {
648
1012
  type ActorActionFunction<Args extends Array<unknown> = unknown[], Response = unknown> = (...args: Args extends [unknown, ...infer Rest] ? Rest : Args) => Promise<Response>;
649
1013
  type IsAny<T> = 0 extends 1 & T ? true : false;
650
1014
  type LooseEventSubscribe = (eventName: string, callback: (...args: any[]) => void) => () => void;
1015
+ type ActorActionMap<R> = {
1016
+ [K in keyof NonNullable<R>]: NonNullable<R>[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Awaited<Return>> : never;
1017
+ };
1018
+ type ActionsOf<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<any, any, any, any, any, any, any, any, infer R> ? R : never;
651
1019
  interface ActorGatewayOptions {
652
1020
  skipReadyWait?: boolean;
653
1021
  }
@@ -660,15 +1028,7 @@ type ActorWebSocketOptions = ActorGatewayOptions;
660
1028
  /**
661
1029
  * Maps action methods from actor definition to typed function signatures.
662
1030
  */
663
- type ActorDefinitionActions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? Record<string, ActorActionFunction<any[], any>> : AD extends {
664
- config: {
665
- actions?: infer R;
666
- };
667
- } ? {
668
- [K in keyof R]: R[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Return> : never;
669
- } : AD extends BaseActorDefinition<any, any, any, any, any, any, any, any, infer R> ? {
670
- [K in keyof R]: R[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Return> : never;
671
- } : {};
1031
+ type ActorDefinitionActions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? Record<string, ActorActionFunction<any[], any>> : ActorActionMap<ActionsOf<AD>>;
672
1032
  type ActorQueueSend<TQueues extends QueueSchemaConfig> = {
673
1033
  <K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options: QueueSendWaitOptions): Promise<QueueSendResult<InferQueueCompleteMap<TQueues>[K]>>;
674
1034
  <K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options?: QueueSendNoWaitOptions): Promise<void>;
@@ -1162,6 +1522,10 @@ type ActorKvListOptions<T extends ActorKvValueType = "text", K extends ActorKvKe
1162
1522
  limit?: number;
1163
1523
  };
1164
1524
  type ActorClientFor<T> = T extends Registry<any> ? Client<T> : T;
1525
+ /**
1526
+ * @deprecated Actor KV is deprecated. Use embedded SQLite (`c.db` / `c.sql`)
1527
+ * or actor state instead.
1528
+ */
1165
1529
  interface ActorKv {
1166
1530
  get<T extends ActorKvValueType = "text">(key: Uint8Array | string, options?: ActorKvValueOptions<T>): Promise<ActorKvValueTypeMap[T] | null>;
1167
1531
  put<T extends ActorKvValueType = "text">(key: Uint8Array | string, value: Uint8Array | string | ArrayBuffer, options?: ActorKvValueOptions<T>): Promise<void>;
@@ -1253,6 +1617,10 @@ interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase
1253
1617
  [RAW_STATE_SYMBOL](): TState;
1254
1618
  state: TState;
1255
1619
  vars: TVars;
1620
+ /**
1621
+ * @deprecated Actor KV is deprecated. Use embedded SQLite (`db` / `sql`)
1622
+ * or actor state instead.
1623
+ */
1256
1624
  readonly kv: ActorKv;
1257
1625
  readonly db: InferDatabaseClient<TDatabase>;
1258
1626
  readonly schedule: ActorSchedule;
@@ -1377,6 +1745,25 @@ declare const ActorConfigSchema: z$1.ZodObject<{
1377
1745
  preloadMaxWorkflowBytes: z$1.ZodOptional<z$1.ZodNumber>;
1378
1746
  preloadMaxConnectionsBytes: z$1.ZodOptional<z$1.ZodNumber>;
1379
1747
  }, z$1.core.$strict>>;
1748
+ inspector: z$1.ZodOptional<z$1.ZodObject<{
1749
+ tabs: z$1.ZodDefault<z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodObject<{
1750
+ id: z$1.ZodString;
1751
+ label: z$1.ZodString;
1752
+ source: z$1.ZodString;
1753
+ icon: z$1.ZodOptional<z$1.ZodString>;
1754
+ hidden: z$1.ZodOptional<z$1.ZodLiteral<false>>;
1755
+ }, z$1.core.$strict>, z$1.ZodObject<{
1756
+ id: z$1.ZodEnum<{
1757
+ state: "state";
1758
+ queue: "queue";
1759
+ workflow: "workflow";
1760
+ database: "database";
1761
+ connections: "connections";
1762
+ console: "console";
1763
+ }>;
1764
+ hidden: z$1.ZodLiteral<true>;
1765
+ }, z$1.core.$strict>]>>>;
1766
+ }, z$1.core.$strict>>;
1380
1767
  }, z$1.core.$strict>;
1381
1768
  type CreateState<TState, _TConnParams, _TConnState, _TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
1382
1769
  state: TState;
@@ -1577,7 +1964,7 @@ type ActorDatabaseConfig<TDatabase extends AnyDatabaseProvider> = {
1577
1964
  */
1578
1965
  db: TDatabase;
1579
1966
  } | Record<never, never>;
1580
- type ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = Omit<z$1.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>;
1967
+ 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$1.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>;
1581
1968
 
1582
1969
  type AgentOsActorState = {};
1583
1970
  interface AgentOsActorVars {