rivetkit 2.3.0-rc.5 → 2.3.0-rc.7

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 (142) hide show
  1. package/dist/browser/client.d.ts +35 -3
  2. package/dist/browser/client.js +795 -200
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.js +4 -3
  5. package/dist/browser/inspector/client.js.map +1 -1
  6. package/dist/tsup/actor/errors.cjs +4 -2
  7. package/dist/tsup/actor/errors.cjs.map +1 -1
  8. package/dist/tsup/actor/errors.d.cts +1 -74
  9. package/dist/tsup/actor/errors.d.ts +1 -74
  10. package/dist/tsup/actor/errors.js +3 -1
  11. package/dist/tsup/agent-os/index.cjs +7 -5
  12. package/dist/tsup/agent-os/index.cjs.map +1 -1
  13. package/dist/tsup/agent-os/index.d.cts +35 -3
  14. package/dist/tsup/agent-os/index.d.ts +35 -3
  15. package/dist/tsup/agent-os/index.js +7 -5
  16. package/dist/tsup/agent-os/index.js.map +1 -1
  17. package/dist/tsup/{chunk-2GANBXVP.cjs → chunk-2H4ISA4Y.cjs} +10 -10
  18. package/dist/tsup/chunk-2H4ISA4Y.cjs.map +1 -0
  19. package/dist/tsup/{chunk-UXTP4EBU.js → chunk-4DJMFOSU.js} +2 -2
  20. package/dist/tsup/{chunk-LDTT6WKJ.js → chunk-4LTY5TOO.js} +132 -4
  21. package/dist/tsup/chunk-4LTY5TOO.js.map +1 -0
  22. package/dist/tsup/{chunk-PGYEMIOE.js → chunk-52TPEKEC.js} +2 -2
  23. package/dist/tsup/{chunk-OVJX4IFY.cjs → chunk-55E7IR6D.cjs} +4 -4
  24. package/dist/tsup/{chunk-OVJX4IFY.cjs.map → chunk-55E7IR6D.cjs.map} +1 -1
  25. package/dist/tsup/{chunk-V3QNBJ7N.cjs → chunk-63WNTDRC.cjs} +31 -10
  26. package/dist/tsup/chunk-63WNTDRC.cjs.map +1 -0
  27. package/dist/tsup/{chunk-SULB574D.js → chunk-CMV6N5OX.js} +3 -3
  28. package/dist/tsup/{chunk-T6YVRM4K.js → chunk-D5G75T7J.js} +3 -1
  29. package/dist/tsup/chunk-D5G75T7J.js.map +1 -0
  30. package/dist/tsup/{chunk-NW2J4SOL.cjs → chunk-FEOG44WH.cjs} +137 -9
  31. package/dist/tsup/chunk-FEOG44WH.cjs.map +1 -0
  32. package/dist/tsup/{chunk-HR547GVH.cjs → chunk-G5HUSWP4.cjs} +8 -8
  33. package/dist/tsup/{chunk-HR547GVH.cjs.map → chunk-G5HUSWP4.cjs.map} +1 -1
  34. package/dist/tsup/{chunk-N2DQSJIW.js → chunk-HERL2VQ2.js} +17 -48
  35. package/dist/tsup/chunk-HERL2VQ2.js.map +1 -0
  36. package/dist/tsup/{chunk-LELRJK66.cjs → chunk-SJLPZEA3.cjs} +3 -3
  37. package/dist/tsup/{chunk-LELRJK66.cjs.map → chunk-SJLPZEA3.cjs.map} +1 -1
  38. package/dist/tsup/{chunk-WQ4HNA4W.cjs → chunk-SRNOPUC6.cjs} +4 -2
  39. package/dist/tsup/chunk-SRNOPUC6.cjs.map +1 -0
  40. package/dist/tsup/{chunk-K34B3OVG.js → chunk-TMLOKTRB.js} +30 -9
  41. package/dist/tsup/chunk-TMLOKTRB.js.map +1 -0
  42. package/dist/tsup/{chunk-NATOT3ET.js → chunk-VFIY6GWO.js} +4 -4
  43. package/dist/tsup/chunk-VFIY6GWO.js.map +1 -0
  44. package/dist/tsup/{chunk-JY73X7VU.js → chunk-VJ4Y4WBT.js} +692 -114
  45. package/dist/tsup/chunk-VJ4Y4WBT.js.map +1 -0
  46. package/dist/tsup/{chunk-JRCZDHXT.cjs → chunk-X6HIFXNK.cjs} +23 -54
  47. package/dist/tsup/chunk-X6HIFXNK.cjs.map +1 -0
  48. package/dist/tsup/{chunk-FTZIZ3JG.cjs → chunk-ZGPX6KAH.cjs} +838 -260
  49. package/dist/tsup/chunk-ZGPX6KAH.cjs.map +1 -0
  50. package/dist/tsup/client/mod.cjs +7 -7
  51. package/dist/tsup/client/mod.d.cts +3 -4
  52. package/dist/tsup/client/mod.d.ts +3 -4
  53. package/dist/tsup/client/mod.js +6 -6
  54. package/dist/tsup/common/log.cjs +3 -3
  55. package/dist/tsup/common/log.js +2 -2
  56. package/dist/tsup/common/websocket.cjs +4 -4
  57. package/dist/tsup/common/websocket.js +3 -3
  58. package/dist/tsup/{config-CvQUtDp9.d.ts → config-Ak1lv4gF.d.ts} +27 -5
  59. package/dist/tsup/{config-C-a9vrke.d.cts → config-DU_xj4qZ.d.cts} +27 -5
  60. package/dist/tsup/{context-A7R0bsZL.d.ts → context-DAAp4Lpg.d.ts} +1 -1
  61. package/dist/tsup/{context-CA3r-pf2.d.cts → context-Dt_L55q8.d.cts} +1 -1
  62. package/dist/tsup/inspector/mod.cjs +6 -6
  63. package/dist/tsup/inspector/mod.js +5 -5
  64. package/dist/tsup/mod.cjs +507 -308
  65. package/dist/tsup/mod.cjs.map +1 -1
  66. package/dist/tsup/mod.d.cts +4 -5
  67. package/dist/tsup/mod.d.ts +4 -5
  68. package/dist/tsup/mod.js +432 -233
  69. package/dist/tsup/mod.js.map +1 -1
  70. package/dist/tsup/process-metrics-NW754INA.js +118 -0
  71. package/dist/tsup/process-metrics-NW754INA.js.map +1 -0
  72. package/dist/tsup/process-metrics-TYAGKCEJ.cjs +118 -0
  73. package/dist/tsup/process-metrics-TYAGKCEJ.cjs.map +1 -0
  74. package/dist/tsup/test/mod.cjs +10 -10
  75. package/dist/tsup/test/mod.d.cts +2 -3
  76. package/dist/tsup/test/mod.d.ts +2 -3
  77. package/dist/tsup/test/mod.js +6 -6
  78. package/dist/tsup/utils-DVekpm4I.d.cts +103 -0
  79. package/dist/tsup/utils-DVekpm4I.d.ts +103 -0
  80. package/dist/tsup/utils.cjs +3 -3
  81. package/dist/tsup/utils.d.cts +1 -1
  82. package/dist/tsup/utils.d.ts +1 -1
  83. package/dist/tsup/utils.js +2 -2
  84. package/dist/tsup/workflow/mod.cjs +41 -16
  85. package/dist/tsup/workflow/mod.cjs.map +1 -1
  86. package/dist/tsup/workflow/mod.d.cts +4 -5
  87. package/dist/tsup/workflow/mod.d.ts +4 -5
  88. package/dist/tsup/workflow/mod.js +35 -10
  89. package/dist/tsup/workflow/mod.js.map +1 -1
  90. package/package.json +11 -10
  91. package/src/actor/config.ts +3 -0
  92. package/src/actor/errors.ts +53 -7
  93. package/src/agent-os/actor/session.ts +2 -2
  94. package/src/client/actor-conn.ts +55 -60
  95. package/src/client/actor-handle.ts +59 -24
  96. package/src/client/errors.ts +2 -1
  97. package/src/client/queue.ts +2 -1
  98. package/src/client/raw-utils.ts +2 -4
  99. package/src/client/utils.ts +32 -4
  100. package/src/common/actor-router-consts.ts +4 -0
  101. package/src/common/bare/generated/client-protocol/v4.ts +599 -0
  102. package/src/common/client-protocol-versioned.ts +125 -18
  103. package/src/common/client-protocol-zod.ts +7 -0
  104. package/src/common/client-protocol.ts +1 -1
  105. package/src/common/database/native-database.test.ts +35 -0
  106. package/src/common/database/native-database.ts +8 -4
  107. package/src/common/encoding.ts +243 -5
  108. package/src/common/inline-websocket-adapter.ts +12 -12
  109. package/src/common/log.ts +1 -0
  110. package/src/common/router.ts +40 -10
  111. package/src/common/utils.ts +9 -200
  112. package/src/drivers/engine/actor-driver.ts +29 -28
  113. package/src/engine-client/actor-websocket-client.ts +2 -1
  114. package/src/engine-client/mod.ts +3 -2
  115. package/src/registry/config/index.ts +3 -5
  116. package/src/registry/index.ts +90 -16
  117. package/src/registry/napi-runtime.ts +15 -0
  118. package/src/registry/native.ts +197 -255
  119. package/src/registry/process-metrics.ts +183 -0
  120. package/src/registry/runtime.ts +4 -0
  121. package/src/registry/wasm-runtime.ts +9 -0
  122. package/src/registry/write-through-proxy.ts +40 -0
  123. package/src/serde.ts +2 -2
  124. package/src/workflow/context.ts +32 -5
  125. package/src/workflow/inspector.ts +2 -1
  126. package/dist/tsup/chunk-2GANBXVP.cjs.map +0 -1
  127. package/dist/tsup/chunk-FTZIZ3JG.cjs.map +0 -1
  128. package/dist/tsup/chunk-JRCZDHXT.cjs.map +0 -1
  129. package/dist/tsup/chunk-JY73X7VU.js.map +0 -1
  130. package/dist/tsup/chunk-K34B3OVG.js.map +0 -1
  131. package/dist/tsup/chunk-LDTT6WKJ.js.map +0 -1
  132. package/dist/tsup/chunk-N2DQSJIW.js.map +0 -1
  133. package/dist/tsup/chunk-NATOT3ET.js.map +0 -1
  134. package/dist/tsup/chunk-NW2J4SOL.cjs.map +0 -1
  135. package/dist/tsup/chunk-T6YVRM4K.js.map +0 -1
  136. package/dist/tsup/chunk-V3QNBJ7N.cjs.map +0 -1
  137. package/dist/tsup/chunk-WQ4HNA4W.cjs.map +0 -1
  138. package/dist/tsup/utils-fwx3o3K9.d.cts +0 -18
  139. package/dist/tsup/utils-fwx3o3K9.d.ts +0 -18
  140. /package/dist/tsup/{chunk-UXTP4EBU.js.map → chunk-4DJMFOSU.js.map} +0 -0
  141. /package/dist/tsup/{chunk-PGYEMIOE.js.map → chunk-52TPEKEC.js.map} +0 -0
  142. /package/dist/tsup/{chunk-SULB574D.js.map → chunk-CMV6N5OX.js.map} +0 -0
@@ -220,7 +220,7 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
220
220
  envoyKey: z.ZodOptional<z.ZodString>;
221
221
  }, z.core.$strip>>>;
222
222
  shutdown: z.ZodDefault<z.ZodOptional<z.ZodObject<{
223
- gracePeriodMs: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
223
+ gracePeriodMs: z.ZodOptional<z.ZodNumber>;
224
224
  disableSignalHandlers: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
225
225
  }, z.core.$strip>>>;
226
226
  }, z.core.$strip>, z.ZodTransform<{
@@ -269,8 +269,8 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
269
269
  envoyKey?: string | undefined;
270
270
  };
271
271
  shutdown: {
272
- gracePeriodMs: number;
273
272
  disableSignalHandlers: boolean;
273
+ gracePeriodMs?: number | undefined;
274
274
  };
275
275
  staticDir?: string | undefined;
276
276
  httpHost?: string | undefined;
@@ -326,8 +326,8 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
326
326
  envoyKey?: string | undefined;
327
327
  };
328
328
  shutdown: {
329
- gracePeriodMs: number;
330
329
  disableSignalHandlers: boolean;
330
+ gracePeriodMs?: number | undefined;
331
331
  };
332
332
  staticDir?: string | undefined;
333
333
  httpHost?: string | undefined;
@@ -454,6 +454,7 @@ interface DeconstructedError {
454
454
  code: string;
455
455
  message: string;
456
456
  metadata?: unknown;
457
+ actor?: ActorSpecifier;
457
458
  }
458
459
 
459
460
  interface RivetErrorOptions extends ErrorOptions {
@@ -463,12 +464,21 @@ interface RivetErrorOptions extends ErrorOptions {
463
464
  metadata?: unknown;
464
465
  /** Explicit HTTP status override for router responses. */
465
466
  statusCode?: number;
467
+ /** Actor context associated with this error. */
468
+ actor?: ActorSpecifier;
469
+ }
470
+ /** Identifies the actor that was handling work when an error was produced. */
471
+ interface ActorSpecifier {
472
+ actorId: string;
473
+ generation: number;
474
+ key?: string;
466
475
  }
467
476
  declare class RivetError extends Error {
468
477
  __type: "RivetError";
469
478
  public: boolean;
470
479
  metadata?: unknown;
471
480
  statusCode: number;
481
+ actor?: ActorSpecifier;
472
482
  readonly group: string;
473
483
  readonly code: string;
474
484
  static isRivetError(error: unknown): error is RivetError | DeconstructedError;
@@ -592,6 +602,25 @@ declare class Registry<A extends RegistryActors> {
592
602
  * ```
593
603
  */
594
604
  serve(): ServerlessHandler;
605
+ /**
606
+ * Starts an HTTP server that dispatches every request through the
607
+ * serverless handler. Uses `crossPlatformServe` to pick the right
608
+ * runtime (Node, Bun, Deno).
609
+ *
610
+ * @param opts.port Port to listen on. Defaults to 3000.
611
+ * @param opts.publicDir If set, serves static files from this directory
612
+ * before falling through to the registry handler.
613
+ *
614
+ * @example
615
+ * ```ts
616
+ * await registry.listen();
617
+ * await registry.listen({ port: 8080, publicDir: "./public" });
618
+ * ```
619
+ */
620
+ listen(opts?: {
621
+ port?: number;
622
+ publicDir?: string;
623
+ }): Promise<void>;
595
624
  diagnostics(): Promise<RegistryDiagnostics>;
596
625
  startEnvoy(): void;
597
626
  /**
@@ -1088,6 +1117,7 @@ type Client<A extends Registry<any>> = ClientRaw & {
1088
1117
  };
1089
1118
 
1090
1119
  declare const ACTOR_CONTEXT_INTERNAL_SYMBOL: unique symbol;
1120
+ declare const RAW_STATE_SYMBOL: unique symbol;
1091
1121
  interface ActorLogger {
1092
1122
  level: any;
1093
1123
  fatal: any;
@@ -1207,6 +1237,8 @@ interface Conn<TState = unknown, TConnParams = unknown, TConnState = unknown, TV
1207
1237
  }
1208
1238
  interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
1209
1239
  [ACTOR_CONTEXT_INTERNAL_SYMBOL]?: unknown;
1240
+ /** Returns the raw unwrapped state without the write-through proxy. */
1241
+ [RAW_STATE_SYMBOL](): TState;
1210
1242
  state: TState;
1211
1243
  vars: TVars;
1212
1244
  readonly kv: ActorKv;
@@ -220,7 +220,7 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
220
220
  envoyKey: z.ZodOptional<z.ZodString>;
221
221
  }, z.core.$strip>>>;
222
222
  shutdown: z.ZodDefault<z.ZodOptional<z.ZodObject<{
223
- gracePeriodMs: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
223
+ gracePeriodMs: z.ZodOptional<z.ZodNumber>;
224
224
  disableSignalHandlers: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
225
225
  }, z.core.$strip>>>;
226
226
  }, z.core.$strip>, z.ZodTransform<{
@@ -269,8 +269,8 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
269
269
  envoyKey?: string | undefined;
270
270
  };
271
271
  shutdown: {
272
- gracePeriodMs: number;
273
272
  disableSignalHandlers: boolean;
273
+ gracePeriodMs?: number | undefined;
274
274
  };
275
275
  staticDir?: string | undefined;
276
276
  httpHost?: string | undefined;
@@ -326,8 +326,8 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
326
326
  envoyKey?: string | undefined;
327
327
  };
328
328
  shutdown: {
329
- gracePeriodMs: number;
330
329
  disableSignalHandlers: boolean;
330
+ gracePeriodMs?: number | undefined;
331
331
  };
332
332
  staticDir?: string | undefined;
333
333
  httpHost?: string | undefined;
@@ -454,6 +454,7 @@ interface DeconstructedError {
454
454
  code: string;
455
455
  message: string;
456
456
  metadata?: unknown;
457
+ actor?: ActorSpecifier;
457
458
  }
458
459
 
459
460
  interface RivetErrorOptions extends ErrorOptions {
@@ -463,12 +464,21 @@ interface RivetErrorOptions extends ErrorOptions {
463
464
  metadata?: unknown;
464
465
  /** Explicit HTTP status override for router responses. */
465
466
  statusCode?: number;
467
+ /** Actor context associated with this error. */
468
+ actor?: ActorSpecifier;
469
+ }
470
+ /** Identifies the actor that was handling work when an error was produced. */
471
+ interface ActorSpecifier {
472
+ actorId: string;
473
+ generation: number;
474
+ key?: string;
466
475
  }
467
476
  declare class RivetError extends Error {
468
477
  __type: "RivetError";
469
478
  public: boolean;
470
479
  metadata?: unknown;
471
480
  statusCode: number;
481
+ actor?: ActorSpecifier;
472
482
  readonly group: string;
473
483
  readonly code: string;
474
484
  static isRivetError(error: unknown): error is RivetError | DeconstructedError;
@@ -592,6 +602,25 @@ declare class Registry<A extends RegistryActors> {
592
602
  * ```
593
603
  */
594
604
  serve(): ServerlessHandler;
605
+ /**
606
+ * Starts an HTTP server that dispatches every request through the
607
+ * serverless handler. Uses `crossPlatformServe` to pick the right
608
+ * runtime (Node, Bun, Deno).
609
+ *
610
+ * @param opts.port Port to listen on. Defaults to 3000.
611
+ * @param opts.publicDir If set, serves static files from this directory
612
+ * before falling through to the registry handler.
613
+ *
614
+ * @example
615
+ * ```ts
616
+ * await registry.listen();
617
+ * await registry.listen({ port: 8080, publicDir: "./public" });
618
+ * ```
619
+ */
620
+ listen(opts?: {
621
+ port?: number;
622
+ publicDir?: string;
623
+ }): Promise<void>;
595
624
  diagnostics(): Promise<RegistryDiagnostics>;
596
625
  startEnvoy(): void;
597
626
  /**
@@ -1088,6 +1117,7 @@ type Client<A extends Registry<any>> = ClientRaw & {
1088
1117
  };
1089
1118
 
1090
1119
  declare const ACTOR_CONTEXT_INTERNAL_SYMBOL: unique symbol;
1120
+ declare const RAW_STATE_SYMBOL: unique symbol;
1091
1121
  interface ActorLogger {
1092
1122
  level: any;
1093
1123
  fatal: any;
@@ -1207,6 +1237,8 @@ interface Conn<TState = unknown, TConnParams = unknown, TConnState = unknown, TV
1207
1237
  }
1208
1238
  interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
1209
1239
  [ACTOR_CONTEXT_INTERNAL_SYMBOL]?: unknown;
1240
+ /** Returns the raw unwrapped state without the write-through proxy. */
1241
+ [RAW_STATE_SYMBOL](): TState;
1210
1242
  state: TState;
1211
1243
  vars: TVars;
1212
1244
  readonly kv: ActorKv;
@@ -787,7 +787,7 @@ function isRivetErrorCode(error, group, code) {
787
787
  // package.json
788
788
  var package_default = {
789
789
  name: "rivetkit",
790
- version: "2.3.0-rc.5",
790
+ version: "2.3.0-rc.7",
791
791
  description: "Lightweight libraries for building stateful actors on edge platforms",
792
792
  license: "Apache-2.0",
793
793
  keywords: [
@@ -955,13 +955,14 @@ var package_default = {
955
955
  "actor-config-schema-gen": "tsx scripts/actor-config-schema-gen.ts"
956
956
  },
957
957
  dependencies: {
958
- "@rivet-dev/agent-os-core": "^0.1.1",
959
958
  "@hono/node-server": "^1.18.2",
960
959
  "@hono/node-ws": "^1.1.1",
961
960
  "@hono/zod-openapi": "^1.1.5",
961
+ "@rivet-dev/agent-os-core": "^0.1.1",
962
962
  "@rivetkit/bare-ts": "^0.6.2",
963
963
  "@rivetkit/engine-cli": "workspace:*",
964
964
  "@rivetkit/engine-envoy-protocol": "workspace:*",
965
+ "@rivetkit/on-change": "6.0.1",
965
966
  "@rivetkit/rivetkit-napi": "workspace:*",
966
967
  "@rivetkit/rivetkit-wasm": "workspace:*",
967
968
  "@rivetkit/traces": "workspace:*",
@@ -979,10 +980,10 @@ var package_default = {
979
980
  zod: "^4.1.0"
980
981
  },
981
982
  devDependencies: {
983
+ "@biomejs/biome": "^2.3",
982
984
  "@copilotkit/llmock": "^1.6.0",
983
985
  "@rivet-dev/agent-os-common": "*",
984
986
  "@rivet-dev/agent-os-pi": "^0.1.1",
985
- "@biomejs/biome": "^2.3",
986
987
  "@standard-schema/spec": "^1.0.0",
987
988
  "@types/invariant": "^2",
988
989
  "@types/node": "^22.13.1",
@@ -1068,6 +1069,7 @@ function configureDefaultLogger(logLevel) {
1068
1069
  messageKey: "msg",
1069
1070
  // Do not include pid/hostname in output
1070
1071
  base: {},
1072
+ errorKey: "error",
1071
1073
  // Keep the numeric level so the logfmt sink can match Pino's levels.
1072
1074
  formatters: {
1073
1075
  level(_label, number) {
@@ -1773,10 +1775,10 @@ function subscribeToSession(c, agentOs2, sessionId, parsedConfig) {
1773
1775
  JSON.parse(JSON.stringify({ sessionId, event: event2 }))
1774
1776
  );
1775
1777
  persistSessionEvent(c, sessionId, event2).catch(
1776
- (err) => c.log.error({
1778
+ (error) => c.log.error({
1777
1779
  msg: "agent-os failed to persist session event",
1778
1780
  sessionId,
1779
- error: err
1781
+ error
1780
1782
  })
1781
1783
  );
1782
1784
  if (parsedConfig.onSessionEvent) {