rivetkit 2.3.0-rc.9 → 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 (222) hide show
  1. package/dist/browser/client.d.ts +498 -62
  2. package/dist/browser/client.js +227 -171
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.js +50 -20
  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 +2163 -2087
  11. package/dist/tsup/agent-os/index.cjs.map +1 -1
  12. package/dist/tsup/agent-os/index.d.cts +496 -69
  13. package/dist/tsup/agent-os/index.d.ts +496 -69
  14. package/dist/tsup/agent-os/index.js +2163 -2087
  15. package/dist/tsup/agent-os/index.js.map +1 -1
  16. package/dist/tsup/{chunk-W7EYSYVI.js → chunk-2OTRTA3J.js} +134 -20
  17. package/dist/tsup/chunk-2OTRTA3J.js.map +1 -0
  18. package/dist/tsup/{chunk-VJFRBJVQ.cjs → chunk-3677IIOV.cjs} +138 -24
  19. package/dist/tsup/chunk-3677IIOV.cjs.map +1 -0
  20. package/dist/tsup/{chunk-4CGA6QJO.cjs → chunk-47HHIEXH.cjs} +24 -9
  21. package/dist/tsup/chunk-47HHIEXH.cjs.map +1 -0
  22. package/dist/tsup/{chunk-F3Q5BFQ6.js → chunk-4JDSFJS5.js} +66 -79
  23. package/dist/tsup/chunk-4JDSFJS5.js.map +1 -0
  24. package/dist/tsup/{chunk-GVTOE34S.cjs → chunk-7QKCIVAY.cjs} +222 -235
  25. package/dist/tsup/chunk-7QKCIVAY.cjs.map +1 -0
  26. package/dist/tsup/{chunk-CPA4Y3RG.cjs → chunk-B6VUNZUD.cjs} +10 -10
  27. package/dist/tsup/chunk-B6VUNZUD.cjs.map +1 -0
  28. package/dist/tsup/{chunk-H37XQU3I.js → chunk-BEI24WTI.js} +2 -2
  29. package/dist/tsup/{chunk-KIWH5H3K.js → chunk-BRP62GZC.js} +3 -3
  30. package/dist/tsup/chunk-BRP62GZC.js.map +1 -0
  31. package/dist/tsup/{chunk-T6YVRM4K.js → chunk-DPIMKYNB.js} +63 -2
  32. package/dist/tsup/chunk-DPIMKYNB.js.map +1 -0
  33. package/dist/tsup/{chunk-Y5NSCZA2.cjs → chunk-DXXJPH55.cjs} +44 -15
  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-4WPEZBK4.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-QAZLM4WT.cjs → chunk-KORQB2IR.cjs} +3 -3
  42. package/dist/tsup/{chunk-QAZLM4WT.cjs.map → chunk-KORQB2IR.cjs.map} +1 -1
  43. package/dist/tsup/{chunk-MALSPBAF.cjs → chunk-LVTBW2RE.cjs} +3 -3
  44. package/dist/tsup/{chunk-MALSPBAF.cjs.map → chunk-LVTBW2RE.cjs.map} +1 -1
  45. package/dist/tsup/{chunk-H7P7WR2Y.js → chunk-MEHBWPLJ.js} +6 -6
  46. package/dist/tsup/chunk-MEHBWPLJ.js.map +1 -0
  47. package/dist/tsup/{chunk-WQ4HNA4W.cjs → chunk-NIY3RSPX.cjs} +64 -3
  48. package/dist/tsup/chunk-NIY3RSPX.cjs.map +1 -0
  49. package/dist/tsup/{chunk-MMMEZM5J.js → chunk-P2GNQ4RN.js} +4 -4
  50. package/dist/tsup/chunk-P2GNQ4RN.js.map +1 -0
  51. package/dist/tsup/{chunk-KJTA3ATT.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-VRCIXJRN.js → chunk-VTTFNQQI.js} +36 -7
  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-0Ta55UV0.d.ts → config-BxWAw3iH.d.ts} +529 -23
  68. package/dist/tsup/{config-Ca8dN4cS.d.cts → config-CZQQ-mso.d.cts} +529 -23
  69. package/dist/tsup/{config-CxjGYf4K.d.cts → config-D49x8NpL.d.cts} +1 -2
  70. package/dist/tsup/{config-CxjGYf4K.d.ts → config-D49x8NpL.d.ts} +1 -2
  71. package/dist/tsup/{context-B_IWbWne.d.ts → context-Bw7xq8w3.d.cts} +8 -8
  72. package/dist/tsup/{context-CUrQ9MHc.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 +730 -336
  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 +633 -239
  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 +307 -282
  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 +501 -476
  118. package/dist/tsup/workflow/mod.js.map +1 -1
  119. package/package.json +32 -11
  120. package/src/actor/config.ts +159 -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 +9 -3
  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/actor/session.ts +2 -2
  132. package/src/agent-os/config.ts +1 -1
  133. package/src/agent-os/fs/database-vfs.ts +1 -1
  134. package/src/agent-os/index.ts +16 -15
  135. package/src/client/actor-common.ts +87 -54
  136. package/src/client/actor-conn.ts +8 -36
  137. package/src/client/actor-handle.ts +69 -51
  138. package/src/client/actor-query.ts +5 -5
  139. package/src/client/errors.ts +1 -1
  140. package/src/client/lifecycle-errors.ts +2 -4
  141. package/src/client/query.ts +1 -1
  142. package/src/client/queue.ts +8 -3
  143. package/src/client/raw-utils.ts +8 -6
  144. package/src/client/resolve-gateway-target.ts +1 -1
  145. package/src/client/utils.ts +2 -7
  146. package/src/common/actor-websocket.ts +3 -1
  147. package/src/common/bare/actor-persist/v1.ts +205 -163
  148. package/src/common/bare/actor-persist/v2.ts +265 -213
  149. package/src/common/bare/actor-persist/v3.ts +176 -172
  150. package/src/common/bare/actor-persist/v4.ts +254 -253
  151. package/src/common/bare/transport/v1.ts +659 -543
  152. package/src/common/client-protocol-versioned.ts +66 -64
  153. package/src/common/database/config.ts +2 -8
  154. package/src/common/database/native-database.ts +1 -1
  155. package/src/common/database/shared.ts +1 -0
  156. package/src/common/encoding.ts +250 -16
  157. package/src/common/engine.ts +28 -1
  158. package/src/common/eventsource.ts +1 -1
  159. package/src/common/inline-websocket-adapter.ts +14 -13
  160. package/src/common/log.ts +1 -0
  161. package/src/common/router.ts +13 -17
  162. package/src/common/utils.ts +1 -150
  163. package/src/common/websocket-interface.ts +1 -1
  164. package/src/db/mod.ts +1 -1
  165. package/src/devtools-loader/index.ts +4 -7
  166. package/src/devtools-loader/serve-devtools.ts +26 -0
  167. package/src/drivers/engine/actor-driver.ts +58 -56
  168. package/src/dynamic/instance.ts +32 -0
  169. package/src/dynamic/internal.ts +50 -0
  170. package/src/dynamic/isolate-runtime.ts +66 -0
  171. package/src/dynamic/mod.ts +32 -0
  172. package/src/engine-client/actor-http-client.ts +3 -3
  173. package/src/engine-client/actor-websocket-client.ts +6 -5
  174. package/src/engine-client/api-endpoints.ts +51 -2
  175. package/src/engine-client/api-utils.ts +2 -2
  176. package/src/engine-client/driver.ts +1 -1
  177. package/src/engine-client/mod.ts +6 -3
  178. package/src/engine-client/ws-proxy.ts +9 -4
  179. package/src/inspector/client.browser.ts +5 -11
  180. package/src/inspector/mod.ts +1 -3
  181. package/src/inspector-tab/mod.ts +315 -0
  182. package/src/registry/config/envoy.ts +1 -2
  183. package/src/registry/config/index.ts +40 -16
  184. package/src/registry/index.ts +154 -74
  185. package/src/registry/napi-runtime.ts +13 -2
  186. package/src/registry/native-validation.ts +10 -12
  187. package/src/registry/native.ts +367 -181
  188. package/src/registry/process-metrics.ts +250 -0
  189. package/src/registry/runtime.ts +41 -1
  190. package/src/registry/wasm-runtime.ts +18 -2
  191. package/src/registry/write-through-proxy.ts +40 -0
  192. package/src/serde.ts +2 -2
  193. package/src/serverless/configure.ts +18 -7
  194. package/src/test/mod.ts +11 -8
  195. package/src/utils/endpoint-parser.ts +1 -1
  196. package/src/utils/env-vars.ts +6 -0
  197. package/src/utils/router.ts +1 -1
  198. package/src/utils/serve.ts +4 -5
  199. package/src/utils.ts +1 -2
  200. package/src/workflow/context.ts +61 -33
  201. package/src/workflow/driver.ts +4 -6
  202. package/src/workflow/inspector.ts +4 -3
  203. package/src/workflow/mod.ts +15 -17
  204. package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
  205. package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
  206. package/dist/tsup/chunk-4CGA6QJO.cjs.map +0 -1
  207. package/dist/tsup/chunk-4WPEZBK4.cjs.map +0 -1
  208. package/dist/tsup/chunk-CPA4Y3RG.cjs.map +0 -1
  209. package/dist/tsup/chunk-F3Q5BFQ6.js.map +0 -1
  210. package/dist/tsup/chunk-GVTOE34S.cjs.map +0 -1
  211. package/dist/tsup/chunk-H7P7WR2Y.js.map +0 -1
  212. package/dist/tsup/chunk-KIWH5H3K.js.map +0 -1
  213. package/dist/tsup/chunk-KJTA3ATT.js.map +0 -1
  214. package/dist/tsup/chunk-MMMEZM5J.js.map +0 -1
  215. package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
  216. package/dist/tsup/chunk-T6YVRM4K.js.map +0 -1
  217. package/dist/tsup/chunk-VJFRBJVQ.cjs.map +0 -1
  218. package/dist/tsup/chunk-VRCIXJRN.js.map +0 -1
  219. package/dist/tsup/chunk-W7EYSYVI.js.map +0 -1
  220. package/dist/tsup/chunk-WQ4HNA4W.cjs.map +0 -1
  221. package/dist/tsup/chunk-Y5NSCZA2.cjs.map +0 -1
  222. /package/dist/tsup/{chunk-H37XQU3I.js.map → chunk-BEI24WTI.js.map} +0 -0
@@ -1,24 +1,18 @@
1
1
  import { z } from "zod/v4";
2
- import type { UniversalWebSocket } from "@/common/websocket-interface";
2
+ import type { Client } from "@/client/client";
3
3
  import type {
4
4
  AnyDatabaseProvider,
5
5
  InferDatabaseClient,
6
- RawDatabaseClient,
7
- DrizzleDatabaseClient,
8
- NativeDatabaseProvider,
9
6
  } from "@/common/database/config";
10
- import type { Client } from "@/client/client";
7
+ import type { UniversalWebSocket } from "@/common/websocket-interface";
11
8
  import type { Registry } from "@/registry";
12
9
  import type { BaseActorDefinition } from "./definition";
13
10
  import type {
14
11
  EventSchemaConfig,
15
- PrimitiveSchema,
16
- QueueSchemaConfig,
17
- } from "./schema";
18
- import type {
19
- InferEventArgs,
20
12
  InferQueueCompleteMap,
21
13
  InferSchemaMap,
14
+ PrimitiveSchema,
15
+ QueueSchemaConfig,
22
16
  } from "./schema";
23
17
 
24
18
  export const DEFAULT_SLEEP_GRACE_PERIOD = 15_000;
@@ -26,6 +20,7 @@ export const DEFAULT_SLEEP_GRACE_PERIOD = 15_000;
26
20
  export const ACTOR_CONTEXT_INTERNAL_SYMBOL = Symbol(
27
21
  "rivetkit.actor_context_internal",
28
22
  );
23
+ export const RAW_STATE_SYMBOL = Symbol("rivetkit.raw_state");
29
24
  export const CONN_DRIVER_SYMBOL = Symbol("rivetkit.conn_driver");
30
25
  export const CONN_STATE_MANAGER_SYMBOL = Symbol("rivetkit.conn_state_manager");
31
26
 
@@ -67,6 +62,10 @@ type ActorKvListOptions<
67
62
 
68
63
  type ActorClientFor<T> = T extends Registry<any> ? Client<T> : T;
69
64
 
65
+ /**
66
+ * @deprecated Actor KV is deprecated. Use embedded SQLite (`c.db` / `c.sql`)
67
+ * or actor state instead.
68
+ */
70
69
  export interface ActorKv {
71
70
  get<T extends ActorKvValueType = "text">(
72
71
  key: Uint8Array | string,
@@ -97,7 +96,10 @@ export interface ActorKv {
97
96
  end: Uint8Array | string,
98
97
  options?: ActorKvListOptions<T, K>,
99
98
  ): Promise<Array<[ActorKvKeyTypeMap[K], ActorKvValueTypeMap[T]]>>;
100
- list<T extends ActorKvValueType = "text", K extends ActorKvKeyType = "text">(
99
+ list<
100
+ T extends ActorKvValueType = "text",
101
+ K extends ActorKvKeyType = "text",
102
+ >(
101
103
  prefix: Uint8Array | string,
102
104
  options?: ActorKvListOptions<T, K>,
103
105
  ): Promise<Array<[ActorKvKeyTypeMap[K], ActorKvValueTypeMap[T]]>>;
@@ -118,7 +120,8 @@ export type QueueMessageOf<Name extends string, Body> = {
118
120
  [key: string]: unknown;
119
121
  };
120
122
 
121
- export type QueueName<TQueues extends QueueSchemaConfig> = keyof TQueues & string;
123
+ export type QueueName<TQueues extends QueueSchemaConfig> = keyof TQueues &
124
+ string;
122
125
  export type QueueFilterName<TQueues extends QueueSchemaConfig> =
123
126
  keyof TQueues extends never ? string : QueueName<TQueues>;
124
127
 
@@ -228,7 +231,9 @@ export interface QueueIterOptions<
228
231
  completable?: TCompletable;
229
232
  }
230
233
 
231
- export interface ActorQueue<TQueues extends QueueSchemaConfig = Record<never, never>> {
234
+ export interface ActorQueue<
235
+ TQueues extends QueueSchemaConfig = Record<never, never>,
236
+ > {
232
237
  send<TName extends QueueFilterName<TQueues>>(
233
238
  name: TName,
234
239
  body: QueueMessageForName<TQueues, TName>["body"],
@@ -236,15 +241,11 @@ export interface ActorQueue<TQueues extends QueueSchemaConfig = Record<never, ne
236
241
  next<
237
242
  const TName extends QueueFilterName<TQueues>,
238
243
  const TCompletable extends boolean = false,
239
- >(
240
- opts?: QueueNextOptions<TName, TCompletable>,
241
- ): Promise<any>;
244
+ >(opts?: QueueNextOptions<TName, TCompletable>): Promise<any>;
242
245
  nextBatch<
243
246
  const TName extends QueueFilterName<TQueues>,
244
247
  const TCompletable extends boolean = false,
245
- >(
246
- opts?: QueueNextBatchOptions<TName, TCompletable>,
247
- ): Promise<any[]>;
248
+ >(opts?: QueueNextBatchOptions<TName, TCompletable>): Promise<any[]>;
248
249
  waitForNames<
249
250
  const TName extends QueueFilterName<TQueues>,
250
251
  const TCompletable extends boolean = false,
@@ -260,33 +261,27 @@ export interface ActorQueue<TQueues extends QueueSchemaConfig = Record<never, ne
260
261
  tryNext<
261
262
  const TName extends QueueFilterName<TQueues>,
262
263
  const TCompletable extends boolean = false,
263
- >(
264
- opts?: QueueTryNextOptions<TName, TCompletable>,
265
- ): Promise<any>;
264
+ >(opts?: QueueTryNextOptions<TName, TCompletable>): Promise<any>;
266
265
  tryNextBatch<
267
266
  const TName extends QueueFilterName<TQueues>,
268
267
  const TCompletable extends boolean = false,
269
- >(
270
- opts?: QueueTryNextBatchOptions<TName, TCompletable>,
271
- ): Promise<any[]>;
268
+ >(opts?: QueueTryNextBatchOptions<TName, TCompletable>): Promise<any[]>;
272
269
  iter<
273
270
  const TName extends QueueFilterName<TQueues>,
274
271
  const TCompletable extends boolean = false,
275
- >(
276
- opts?: QueueIterOptions<TName, TCompletable>,
277
- ): AsyncIterable<any>;
272
+ >(opts?: QueueIterOptions<TName, TCompletable>): AsyncIterable<any>;
278
273
  [key: string]: any;
279
274
  }
280
275
 
281
276
  export interface Conn<
282
- TState = unknown,
277
+ _TState = unknown,
283
278
  TConnParams = unknown,
284
279
  TConnState = unknown,
285
- TVars = unknown,
286
- TInput = unknown,
287
- TDatabase extends AnyDatabaseProvider = AnyDatabaseProvider,
288
- TEvents extends EventSchemaConfig = Record<never, never>,
289
- TQueues extends QueueSchemaConfig = Record<never, never>,
280
+ _TVars = unknown,
281
+ _TInput = unknown,
282
+ _TDatabase extends AnyDatabaseProvider = AnyDatabaseProvider,
283
+ _TEvents extends EventSchemaConfig = Record<never, never>,
284
+ _TQueues extends QueueSchemaConfig = Record<never, never>,
290
285
  > {
291
286
  id: string;
292
287
  params: TConnParams;
@@ -310,8 +305,14 @@ export interface ActorContext<
310
305
  TQueues extends QueueSchemaConfig = Record<never, never>,
311
306
  > {
312
307
  [ACTOR_CONTEXT_INTERNAL_SYMBOL]?: unknown;
308
+ /** Returns the raw unwrapped state without the write-through proxy. */
309
+ [RAW_STATE_SYMBOL](): TState;
313
310
  state: TState;
314
311
  vars: TVars;
312
+ /**
313
+ * @deprecated Actor KV is deprecated. Use embedded SQLite (`db` / `sql`)
314
+ * or actor state instead.
315
+ */
315
316
  readonly kv: ActorKv;
316
317
  readonly db: InferDatabaseClient<TDatabase>;
317
318
  readonly schedule: ActorSchedule;
@@ -320,7 +321,19 @@ export interface ActorContext<
320
321
  readonly name: string;
321
322
  readonly key: string[];
322
323
  readonly region: string;
323
- readonly conns: Map<string, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>;
324
+ readonly conns: Map<
325
+ string,
326
+ Conn<
327
+ TState,
328
+ TConnParams,
329
+ TConnState,
330
+ TVars,
331
+ TInput,
332
+ TDatabase,
333
+ TEvents,
334
+ TQueues
335
+ >
336
+ >;
324
337
  readonly log: ActorLogger;
325
338
  readonly abortSignal: AbortSignal;
326
339
  readonly aborted: boolean;
@@ -651,7 +664,9 @@ export type WebSocketContext<
651
664
  TQueues
652
665
  >;
653
666
 
654
- export type ActorContextOf<AD extends BaseActorDefinition<any, any, any, any, any, any, any, any, any>> =
667
+ export type ActorContextOf<
668
+ AD extends BaseActorDefinition<any, any, any, any, any, any, any, any, any>,
669
+ > =
655
670
  AD extends BaseActorDefinition<
656
671
  infer TState,
657
672
  infer TConnParams,
@@ -728,6 +743,88 @@ const RunInspectorConfigSchema = z
728
743
  })
729
744
  .optional();
730
745
 
746
+ /**
747
+ * Built-in inspector tabs the dashboard ships. Used to validate
748
+ * `hidden: true` entries and reject custom-tab ids that collide with
749
+ * a built-in.
750
+ */
751
+ export const BUILTIN_INSPECTOR_TAB_IDS = [
752
+ "workflow",
753
+ "database",
754
+ "state",
755
+ "queue",
756
+ "connections",
757
+ "console",
758
+ ] as const;
759
+
760
+ export const BuiltinInspectorTabIdSchema = z.enum(BUILTIN_INSPECTOR_TAB_IDS);
761
+
762
+ // Custom tab id grammar — mirrored in Rust at
763
+ // `rivetkit-rust/packages/rivetkit-core/src/inspector/tabs.rs`. Slashes are
764
+ // forbidden because the runtime splits `/inspector/custom-tabs/<id>/<rest>`
765
+ // on the first `/`.
766
+ const CUSTOM_INSPECTOR_TAB_ID_RE = /^[A-Za-z0-9_-]+$/;
767
+
768
+ export const CustomInspectorTabEntrySchema = z
769
+ .object({
770
+ id: z
771
+ .string()
772
+ .regex(
773
+ CUSTOM_INSPECTOR_TAB_ID_RE,
774
+ "inspector.tabs[].id must contain only letters, digits, underscore, or dash",
775
+ ),
776
+ label: z.string().min(1),
777
+ source: z.string().min(1),
778
+ /**
779
+ * Optional icon id. The dashboard maps strings to glyphs (see its
780
+ * icon registry); unknown ids fall back to a generic icon.
781
+ */
782
+ icon: z.string().min(1).optional(),
783
+ hidden: z.literal(false).optional(),
784
+ })
785
+ .strict();
786
+
787
+ export const HideInspectorTabEntrySchema = z
788
+ .object({
789
+ id: BuiltinInspectorTabIdSchema,
790
+ hidden: z.literal(true),
791
+ })
792
+ .strict();
793
+
794
+ export const InspectorTabEntrySchema = z.union([
795
+ CustomInspectorTabEntrySchema,
796
+ HideInspectorTabEntrySchema,
797
+ ]);
798
+
799
+ export const ActorInspectorConfigSchema = z
800
+ .object({
801
+ tabs: z.array(InspectorTabEntrySchema).default(() => []),
802
+ })
803
+ .strict()
804
+ .refine(
805
+ (data) => {
806
+ const ids = data.tabs.map((t) => t.id);
807
+ return new Set(ids).size === ids.length;
808
+ },
809
+ { message: "Duplicate id in inspector.tabs", path: ["tabs"] },
810
+ )
811
+ .refine(
812
+ (data) => {
813
+ // A custom entry's id must not collide with a built-in id.
814
+ const builtinSet = new Set(BUILTIN_INSPECTOR_TAB_IDS);
815
+ return data.tabs.every(
816
+ (t) => t.hidden === true || !builtinSet.has(t.id as any),
817
+ );
818
+ },
819
+ {
820
+ message:
821
+ "Custom inspector tab id collides with a built-in (use hidden: true to hide a built-in)",
822
+ path: ["tabs"],
823
+ },
824
+ );
825
+
826
+ export type ActorInspectorConfig = z.input<typeof ActorInspectorConfigSchema>;
827
+
731
828
  // Schema for run handler with metadata
732
829
  export const RunConfigSchema = z.object({
733
830
  /** Display name for the actor in the Inspector UI. */
@@ -944,6 +1041,7 @@ export const ActorConfigSchema = z
944
1041
  db: z.any().optional(),
945
1042
  createVars: zFunction().optional(),
946
1043
  options: ActorOptionsSchema,
1044
+ inspector: ActorInspectorConfigSchema.optional(),
947
1045
  })
948
1046
  .strict()
949
1047
  .refine(
@@ -979,9 +1077,9 @@ export const ActorConfigSchema = z
979
1077
  // Data returned from this handler will be available on `c.state`.
980
1078
  type CreateState<
981
1079
  TState,
982
- TConnParams,
983
- TConnState,
984
- TVars,
1080
+ _TConnParams,
1081
+ _TConnState,
1082
+ _TVars,
985
1083
  TInput,
986
1084
  TDatabase extends AnyDatabaseProvider,
987
1085
  TEvents extends EventSchemaConfig,
@@ -1036,8 +1134,8 @@ type CreateConnState<
1036
1134
  */
1037
1135
  type CreateVars<
1038
1136
  TState,
1039
- TConnParams,
1040
- TConnState,
1137
+ _TConnParams,
1138
+ _TConnState,
1041
1139
  TVars,
1042
1140
  TInput,
1043
1141
  TDatabase extends AnyDatabaseProvider,
@@ -1498,6 +1596,25 @@ export type ActorConfig<
1498
1596
  TDatabase extends AnyDatabaseProvider,
1499
1597
  TEvents extends EventSchemaConfig = Record<never, never>,
1500
1598
  TQueues extends QueueSchemaConfig = Record<never, never>,
1599
+ TActions extends Actions<
1600
+ TState,
1601
+ TConnParams,
1602
+ TConnState,
1603
+ TVars,
1604
+ TInput,
1605
+ TDatabase,
1606
+ TEvents,
1607
+ TQueues
1608
+ > = Actions<
1609
+ TState,
1610
+ TConnParams,
1611
+ TConnState,
1612
+ TVars,
1613
+ TInput,
1614
+ TDatabase,
1615
+ TEvents,
1616
+ TQueues
1617
+ >,
1501
1618
  > = Omit<
1502
1619
  z.infer<typeof ActorConfigSchema>,
1503
1620
  | "actions"
@@ -1533,16 +1650,7 @@ export type ActorConfig<
1533
1650
  TDatabase,
1534
1651
  TEvents,
1535
1652
  TQueues,
1536
- Actions<
1537
- TState,
1538
- TConnParams,
1539
- TConnState,
1540
- TVars,
1541
- TInput,
1542
- TDatabase,
1543
- TEvents,
1544
- TQueues
1545
- >
1653
+ TActions
1546
1654
  > &
1547
1655
  CreateState<
1548
1656
  TState,
@@ -16,10 +16,15 @@ import type {
16
16
  WakeContext,
17
17
  WebSocketContext,
18
18
  } from "@/actor/config";
19
+
19
20
  export type { ActorContextOf } from "@/actor/config";
20
- import type { AnyActorDefinition, BaseActorDefinition } from "@/actor/definition";
21
- import type { AnyDatabaseProvider } from "@/common/database/config";
21
+
22
+ import type {
23
+ AnyActorDefinition,
24
+ BaseActorDefinition,
25
+ } from "@/actor/definition";
22
26
  import type { EventSchemaConfig, QueueSchemaConfig } from "@/actor/schema";
27
+ import type { AnyDatabaseProvider } from "@/common/database/config";
23
28
 
24
29
  export type ActionContextOf<AD extends AnyActorDefinition> =
25
30
  AD extends BaseActorDefinition<
@@ -1,7 +1,12 @@
1
+ import type { AnyDatabaseProvider } from "@/common/database/config";
1
2
  import type { RegistryConfig } from "@/registry/config";
2
- import { ActorConfigSchema, type Actions, type ActorConfig, type ActorConfigInput } from "./config";
3
+ import {
4
+ type Actions,
5
+ type ActorConfig,
6
+ type ActorConfigInput,
7
+ ActorConfigSchema,
8
+ } from "./config";
3
9
  import { loggerWithoutContext } from "./log";
4
- import type { AnyDatabaseProvider } from "@/common/database/config";
5
10
  import type { EventSchemaConfig, QueueSchemaConfig } from "./schema";
6
11
 
7
12
  const warnedDeprecatedTimeoutKeys = new Set<string>();
@@ -28,7 +33,7 @@ export interface BaseActorDefinition<
28
33
  DB extends AnyDatabaseProvider,
29
34
  E extends EventSchemaConfig = Record<never, never>,
30
35
  Q extends QueueSchemaConfig = Record<never, never>,
31
- R extends Actions<S, CP, CS, V, I, DB, E, Q> = Actions<
36
+ _R extends Actions<S, CP, CS, V, I, DB, E, Q> = Actions<
32
37
  S,
33
38
  CP,
34
39
  CS,
@@ -39,20 +44,12 @@ export interface BaseActorDefinition<
39
44
  Q
40
45
  >,
41
46
  > {
42
- readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q>;
47
+ readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q, _R>;
43
48
  }
44
49
 
45
- export type AnyActorDefinition = BaseActorDefinition<
46
- any,
47
- any,
48
- any,
49
- any,
50
- any,
51
- any,
52
- any,
53
- any,
54
- any
55
- >;
50
+ export interface AnyActorDefinition {
51
+ readonly config: any;
52
+ }
56
53
 
57
54
  export type AnyStaticActorDefinition = ActorDefinition<
58
55
  any,
@@ -87,13 +84,13 @@ export class ActorDefinition<
87
84
  >,
88
85
  > implements BaseActorDefinition<S, CP, CS, V, I, DB, E, Q, R>
89
86
  {
90
- #config: ActorConfig<S, CP, CS, V, I, DB, E, Q>;
87
+ #config: ActorConfig<S, CP, CS, V, I, DB, E, Q, R>;
91
88
 
92
- constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q>) {
89
+ constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q, R>) {
93
90
  this.#config = config;
94
91
  }
95
92
 
96
- get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q> {
93
+ get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q, R> {
97
94
  return this.#config;
98
95
  }
99
96
  }
@@ -195,7 +192,8 @@ export function actor<
195
192
  TInput,
196
193
  TDatabase,
197
194
  TEvents,
198
- TQueues
195
+ TQueues,
196
+ TActions
199
197
  >;
200
198
  return new ActorDefinition(config);
201
199
  }
@@ -1,12 +1,12 @@
1
1
  import type { Context as HonoContext } from "hono";
2
2
  import type { AnyClient } from "@/client/client";
3
- import type { EngineControlClient } from "@/engine-client/driver";
4
- import type { AnyActorInstance, AnyStaticActorInstance } from "./definition";
5
- import type { RegistryConfig } from "@/registry/config";
6
3
  import type {
7
4
  DrizzleDatabaseClient,
8
5
  NativeDatabaseProvider,
9
6
  } from "@/common/database/config";
7
+ import type { EngineControlClient } from "@/engine-client/driver";
8
+ import type { RegistryConfig } from "@/registry/config";
9
+ import type { AnyActorInstance, AnyStaticActorInstance } from "./definition";
10
10
 
11
11
  export type ActorDriverBuilder = (
12
12
  config: RegistryConfig,
@@ -106,7 +106,9 @@ function isActorSpecifier(value: unknown): value is ActorSpecifier {
106
106
  typeof value.actorId === "string" &&
107
107
  "generation" in value &&
108
108
  typeof value.generation === "number" &&
109
- (!("key" in value) || value.key === undefined || typeof value.key === "string")
109
+ (!("key" in value) ||
110
+ value.key === undefined ||
111
+ typeof value.key === "string")
110
112
  );
111
113
  }
112
114
 
@@ -237,7 +239,11 @@ export function decodeBridgeRivetErrorPayload(
237
239
  if (!isRivetErrorLike(payload)) {
238
240
  return undefined;
239
241
  }
240
- if (payload.actor !== undefined && !isActorSpecifier(payload.actor)) {
242
+ if (
243
+ payload.actor !== undefined &&
244
+ payload.actor !== null &&
245
+ !isActorSpecifier(payload.actor)
246
+ ) {
241
247
  return undefined;
242
248
  }
243
249
 
@@ -257,7 +263,7 @@ export function decodeBridgeRivetError(value: string): RivetError | undefined {
257
263
  metadata: payload.metadata,
258
264
  public: payload.public,
259
265
  statusCode: payload.statusCode,
260
- actor: payload.actor,
266
+ actor: payload.actor ?? undefined,
261
267
  });
262
268
  }
263
269
 
@@ -9,22 +9,21 @@ import {
9
9
  type SpanStatusInput,
10
10
  type Traces,
11
11
  } from "@rivetkit/traces";
12
- import { ActorMetrics, type StartupTimingKey } from "@/actor/metrics";
13
12
  import invariant from "invariant";
13
+ import { ActorMetrics, type StartupTimingKey } from "@/actor/metrics";
14
14
  import type { Client } from "@/client/client";
15
+ import type { ActorKey } from "@/client/query";
15
16
  import { getBaseLogger, getIncludeTarget, type Logger } from "@/common/log";
16
17
  import { stringifyError } from "@/common/utils";
17
18
  import type { UniversalWebSocket } from "@/common/websocket-interface";
18
19
  import { ActorInspector } from "@/inspector/actor-inspector";
19
- import type { ActorKey } from "@/client/query";
20
20
  import type { Registry } from "@/mod";
21
21
  import {
22
22
  ACTOR_VERSIONED,
23
23
  CONN_VERSIONED,
24
24
  } from "@/schemas/actor-persist/versioned";
25
- import { EXTRA_ERROR_LOG } from "@/utils";
25
+ import { EXTRA_ERROR_LOG, promiseWithResolvers } from "@/utils";
26
26
  import { getRivetExperimentalOtel } from "@/utils/env-vars";
27
- import { promiseWithResolvers } from "@/utils";
28
27
  import {
29
28
  type Actions,
30
29
  type ActorConfig,
@@ -32,16 +31,13 @@ import {
32
31
  ActorConfigSchema,
33
32
  getRunFunction,
34
33
  } from "../config";
35
- import type { ConnDriver } from "../conn/driver";
36
- import { createHttpDriver } from "../conn/drivers/http";
37
34
  import {
38
- HibernatableWebSocketAckState,
39
35
  handleInboundHibernatableWebSocketMessage as applyInboundHibernatableWebSocketMessage,
36
+ HibernatableWebSocketAckState,
40
37
  } from "../conn/hibernatable-websocket-ack-state";
41
38
  import {
42
- CONN_DRIVER_SYMBOL,
43
- CONN_STATE_MANAGER_SYMBOL,
44
39
  type AnyConn,
40
+ CONN_STATE_MANAGER_SYMBOL,
45
41
  type Conn,
46
42
  type ConnId,
47
43
  } from "../conn/mod";
@@ -50,7 +46,7 @@ import {
50
46
  type PersistedConn,
51
47
  } from "../conn/persisted";
52
48
  import {
53
- ActionContext,
49
+ type ActionContext,
54
50
  ActorContext,
55
51
  RequestContext,
56
52
  WebSocketContext,
@@ -79,20 +75,16 @@ import {
79
75
  import { ConnectionManager } from "./connection-manager";
80
76
  import { EventManager } from "./event-manager";
81
77
  import { KEYS, workflowStoragePrefix } from "./keys";
82
- import {
83
- type PreloadedEntries,
84
- type PreloadHit,
85
- type PreloadMap,
86
- } from "./preload-map";
87
78
  import {
88
79
  convertActorFromBarePersisted,
89
80
  type PersistedActor,
90
81
  } from "./persisted";
82
+ import type { PreloadedEntries, PreloadMap } from "./preload-map";
91
83
  import { QueueManager } from "./queue-manager";
92
84
  import { ScheduleManager } from "./schedule-manager";
93
85
  import { type SaveStateOptions, StateManager } from "./state-manager";
94
- import { TrackedWebSocket } from "./tracked-websocket";
95
86
  import { ActorTracesDriver } from "./traces-driver";
87
+ import { TrackedWebSocket } from "./tracked-websocket";
96
88
  import { WriteCollector } from "./write-collector";
97
89
 
98
90
  export type { SaveStateOptions };
@@ -215,14 +207,14 @@ const ACTIVE_ASYNC_REGION_ERROR_MESSAGES: Record<
215
207
  * only on `ActorInstance`.
216
208
  */
217
209
  export interface BaseActorInstance<
218
- S = any,
219
- CP = any,
220
- CS = any,
221
- V = any,
222
- I = any,
223
- DB extends AnyDatabaseProvider = AnyDatabaseProvider,
224
- E extends EventSchemaConfig = Record<never, never>,
225
- Q extends QueueSchemaConfig = Record<never, never>,
210
+ _S = any,
211
+ _CP = any,
212
+ _CS = any,
213
+ _V = any,
214
+ _I = any,
215
+ _DB extends AnyDatabaseProvider = AnyDatabaseProvider,
216
+ _E extends EventSchemaConfig = Record<never, never>,
217
+ _Q extends QueueSchemaConfig = Record<never, never>,
226
218
  > {
227
219
  readonly id: string;
228
220
  readonly isStopping: boolean;
@@ -1274,7 +1266,7 @@ export class ActorInstance<
1274
1266
  "actor.onBeforeActionResponse",
1275
1267
  { "rivet.action.name": actionName },
1276
1268
  () =>
1277
- this.#config.onBeforeActionResponse!(
1269
+ this.#config.onBeforeActionResponse?.(
1278
1270
  this.actorContext,
1279
1271
  actionName,
1280
1272
  args,
@@ -1406,7 +1398,7 @@ export class ActorInstance<
1406
1398
 
1407
1399
  // NOTE: This is async and will run in the background
1408
1400
  const voidOrPromise = this.#traces.withSpan(span, () =>
1409
- this.#config.onWebSocket!(ctx, trackedWebSocket),
1401
+ this.#config.onWebSocket?.(ctx, trackedWebSocket),
1410
1402
  );
1411
1403
 
1412
1404
  // Save changes from the WebSocket open
@@ -1645,10 +1637,10 @@ export class ActorInstance<
1645
1637
  attributes?: Record<string, unknown>,
1646
1638
  ): Record<string, unknown> {
1647
1639
  return {
1648
- "rivet.actor.id": this.#actorId,
1649
- "rivet.actor.name": this.#name,
1650
- "rivet.actor.key": this.#actorKeyString,
1651
- "rivet.actor.region": this.#region,
1640
+ "rivet.actors.actor.id": this.#actorId,
1641
+ "rivet.actors.actor.name": this.#name,
1642
+ "rivet.actors.actor.key": this.#actorKeyString,
1643
+ "rivet.actors.actor.region": this.#region,
1652
1644
  ...(attributes ?? {}),
1653
1645
  };
1654
1646
  }
@@ -1882,7 +1874,7 @@ export class ActorInstance<
1882
1874
  "actor.createVars",
1883
1875
  undefined,
1884
1876
  () => {
1885
- const dataOrPromise = createVars!(
1877
+ const dataOrPromise = createVars?.(
1886
1878
  this.actorContext as any,
1887
1879
  this.driver.getContext(this.#actorId),
1888
1880
  );
@@ -2084,7 +2076,7 @@ export class ActorInstance<
2084
2076
  }
2085
2077
  }
2086
2078
 
2087
- async #setupDatabase(preload?: PreloadMap) {
2079
+ async #setupDatabase(_preload?: PreloadMap) {
2088
2080
  if (!("db" in this.#config) || !this.#config.db) {
2089
2081
  return;
2090
2082
  }
@@ -2099,14 +2091,14 @@ export class ActorInstance<
2099
2091
  overrideRawDatabaseClient: this.driver
2100
2092
  .overrideRawDatabaseClient
2101
2093
  ? () =>
2102
- this.driver.overrideRawDatabaseClient!(
2094
+ this.driver.overrideRawDatabaseClient?.(
2103
2095
  this.#actorId,
2104
2096
  )
2105
2097
  : undefined,
2106
2098
  overrideDrizzleDatabaseClient: this.driver
2107
2099
  .overrideDrizzleDatabaseClient
2108
2100
  ? () =>
2109
- this.driver.overrideDrizzleDatabaseClient!(
2101
+ this.driver.overrideDrizzleDatabaseClient?.(
2110
2102
  this.#actorId,
2111
2103
  )
2112
2104
  : undefined,
package/src/actor/keys.ts CHANGED
@@ -135,7 +135,7 @@ export function deserializeActorKey(keyString: string | undefined): ActorKey {
135
135
  // Add the last part
136
136
  if (escaping) {
137
137
  // Incomplete escape at the end - treat as literal backslash
138
- parts.push(currentPart + "\\");
138
+ parts.push(`${currentPart}\\`);
139
139
  } else if (isEmptyStringMarker) {
140
140
  parts.push("");
141
141
  } else if (currentPart !== "" || parts.length > 0) {