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
@@ -0,0 +1,50 @@
1
+ import type {
2
+ AnyActorDefinition,
3
+ BaseActorDefinition,
4
+ } from "@/actor/definition";
5
+
6
+ export const DYNAMIC_ACTOR_DEFINITION_SYMBOL = Symbol.for(
7
+ "rivetkit.dynamic_actor_definition",
8
+ );
9
+
10
+ export interface DynamicActorSource {
11
+ source: string;
12
+ nodeProcess?: {
13
+ memoryLimit?: number;
14
+ cpuTimeLimitMs?: number;
15
+ };
16
+ }
17
+
18
+ export interface DynamicActorLoadContext {
19
+ key: string[];
20
+ client(): Promise<any>;
21
+ }
22
+
23
+ export type DynamicActorLoader = (
24
+ c: DynamicActorLoadContext,
25
+ ) => DynamicActorSource | Promise<DynamicActorSource>;
26
+
27
+ export interface DynamicActorDefinition extends AnyActorDefinition {
28
+ readonly [DYNAMIC_ACTOR_DEFINITION_SYMBOL]: true;
29
+ readonly loader: DynamicActorLoader;
30
+ }
31
+
32
+ export function isDynamicActorDefinition(
33
+ definition: BaseActorDefinition<
34
+ any,
35
+ any,
36
+ any,
37
+ any,
38
+ any,
39
+ any,
40
+ any,
41
+ any,
42
+ any
43
+ >,
44
+ ): definition is DynamicActorDefinition {
45
+ return (
46
+ (definition as Partial<DynamicActorDefinition>)[
47
+ DYNAMIC_ACTOR_DEFINITION_SYMBOL
48
+ ] === true
49
+ );
50
+ }
@@ -0,0 +1,66 @@
1
+ import type { ActorDriver } from "@/actor/driver";
2
+ import type { Client } from "@/client/client";
3
+ import type { RegistryConfig } from "@/registry/config";
4
+ import type { DynamicActorLoader } from "./internal";
5
+
6
+ export interface DynamicActorIsolateRuntimeConfig {
7
+ actorId: string;
8
+ actorName: string;
9
+ actorKey: string[];
10
+ input: unknown;
11
+ region: string;
12
+ loader: DynamicActorLoader;
13
+ actorDriver: ActorDriver;
14
+ inlineClient: Client<any>;
15
+ test: RegistryConfig["test"];
16
+ }
17
+
18
+ export interface DynamicHibernatingWebSocketMetadata {
19
+ gatewayId: ArrayBuffer;
20
+ requestId: ArrayBuffer;
21
+ serverMessageIndex: number;
22
+ clientMessageIndex: number;
23
+ path: string;
24
+ headers: Record<string, string>;
25
+ }
26
+
27
+ export class DynamicActorIsolateRuntime {
28
+ #isStopping = false;
29
+
30
+ constructor(private readonly config: DynamicActorIsolateRuntimeConfig) {}
31
+
32
+ get isStopping(): boolean {
33
+ return this.#isStopping;
34
+ }
35
+
36
+ async start(): Promise<void> {
37
+ await this.config.loader({
38
+ key: this.config.actorKey,
39
+ client: async () => this.config.inlineClient,
40
+ });
41
+ }
42
+
43
+ async stop(_mode: "sleep" | "destroy"): Promise<void> {
44
+ this.#isStopping = true;
45
+ }
46
+
47
+ async dispose(): Promise<void> {
48
+ this.#isStopping = true;
49
+ }
50
+
51
+ async onAlarm(): Promise<void> {}
52
+
53
+ async cleanupPersistedConnections(_reason?: string): Promise<number> {
54
+ return 0;
55
+ }
56
+
57
+ async getHibernatingWebSockets(): Promise<
58
+ DynamicHibernatingWebSocketMetadata[]
59
+ > {
60
+ return [];
61
+ }
62
+
63
+ getHibernatingWebSocketMetadata(): DynamicHibernatingWebSocketMetadata[] {
64
+ return [];
65
+ }
66
+ }
@@ -0,0 +1,32 @@
1
+ import { ActorConfigSchema } from "@/actor/config";
2
+ import type { AnyActorDefinition } from "@/actor/definition";
3
+ import {
4
+ DYNAMIC_ACTOR_DEFINITION_SYMBOL,
5
+ type DynamicActorDefinition,
6
+ type DynamicActorLoader,
7
+ } from "./internal";
8
+
9
+ export interface DynamicActorConfig {
10
+ load: DynamicActorLoader;
11
+ }
12
+
13
+ export function dynamicActor(
14
+ input: DynamicActorConfig,
15
+ ): DynamicActorDefinition {
16
+ const config = ActorConfigSchema.parse({
17
+ actions: {},
18
+ }) as unknown as AnyActorDefinition["config"];
19
+
20
+ return {
21
+ [DYNAMIC_ACTOR_DEFINITION_SYMBOL]: true,
22
+ config,
23
+ loader: input.load,
24
+ };
25
+ }
26
+
27
+ export type {
28
+ DynamicActorDefinition,
29
+ DynamicActorLoadContext,
30
+ DynamicActorLoader,
31
+ DynamicActorSource,
32
+ } from "./internal";
@@ -5,7 +5,7 @@ import {
5
5
  HEADER_RIVET_TARGET,
6
6
  HEADER_RIVET_TOKEN,
7
7
  } from "@/common/actor-router-consts";
8
- import { shouldSkipReadyWait, type GatewayRequestOptions } from "./driver";
8
+ import { type GatewayRequestOptions, shouldSkipReadyWait } from "./driver";
9
9
 
10
10
  export interface HttpGatewayRequestOptions extends GatewayRequestOptions {
11
11
  directActorId?: string;
@@ -34,9 +34,9 @@ export async function sendHttpRequestToGateway(
34
34
  bodyToSend = reqBody;
35
35
 
36
36
  // If this is a streaming request, we need to convert the headers
37
- // for the basic array buffer
37
+ // for the basic array buffer.
38
38
  guardHeaders.delete("transfer-encoding");
39
- guardHeaders.set("content-length", String(bodyToSend.byteLength));
39
+ guardHeaders.delete("content-length");
40
40
  }
41
41
  }
42
42
 
@@ -2,23 +2,24 @@ import {
2
2
  type ClientConfig,
3
3
  DEFAULT_MAX_QUERY_INPUT_SIZE,
4
4
  } from "@/client/config";
5
+ import type { ActorGatewayQuery, CrashPolicy } from "@/client/query";
5
6
  import {
7
+ WS_PROTOCOL_ACTOR,
6
8
  WS_PROTOCOL_CONN_PARAMS,
7
9
  WS_PROTOCOL_ENCODING,
8
10
  WS_PROTOCOL_STANDARD as WS_PROTOCOL_RIVETKIT,
9
- WS_PROTOCOL_TARGET,
10
- WS_PROTOCOL_ACTOR,
11
11
  WS_PROTOCOL_SKIP_READY_WAIT,
12
+ WS_PROTOCOL_TARGET,
12
13
  WS_PROTOCOL_TEST_ACK_HOOK,
13
14
  WS_PROTOCOL_TOKEN,
14
15
  } from "@/common/actor-router-consts";
16
+ import type { JsonCompatValue } from "@/common/encoding";
15
17
  import { importWebSocket } from "@/common/websocket";
16
18
  import { setRemoteHibernatableWebSocketAckTestHooks } from "@/common/websocket-test-hooks";
17
- import type { ActorGatewayQuery, CrashPolicy } from "@/client/query";
18
19
  import type { Encoding, UniversalWebSocket } from "@/mod";
19
20
  import { encodeCborCompat, uint8ArrayToBase64 } from "@/serde";
20
21
  import { combineUrlPath } from "@/utils";
21
- import { shouldSkipReadyWait, type GatewayRequestOptions } from "./driver";
22
+ import { type GatewayRequestOptions, shouldSkipReadyWait } from "./driver";
22
23
  import { logger } from "./log";
23
24
 
24
25
  class BufferedRemoteWebSocket implements UniversalWebSocket {
@@ -302,7 +303,7 @@ function pushInputQueryParam(
302
303
  return;
303
304
  }
304
305
 
305
- const encodedInput = encodeCborCompat(input);
306
+ const encodedInput = encodeCborCompat(input as JsonCompatValue);
306
307
  if (encodedInput.byteLength > maxInputSize) {
307
308
  throw new Error(
308
309
  `Actor query input exceeds maxInputSize (${encodedInput.byteLength} > ${maxInputSize} bytes). Increase client maxInputSize to allow larger query payloads.`,
@@ -107,12 +107,59 @@ export async function getDatacenters(
107
107
  return apiCall<never, DatacentersResponse>(config, "GET", `/datacenters`);
108
108
  }
109
109
 
110
+ // MARK: Get runner configs
111
+ export interface RunnerConfig {
112
+ normal?: {
113
+ drain_on_version_upgrade?: boolean;
114
+ actor_eviction_period?: number;
115
+ actor_eviction_rate?: number;
116
+ };
117
+ serverless?: {
118
+ url: string;
119
+ headers: Record<string, string>;
120
+ drain_grace_period?: number;
121
+ max_runners: number;
122
+ min_runners: number;
123
+ request_lifespan: number;
124
+ runners_margin: number;
125
+ slots_per_runner: number;
126
+ metadata_poll_interval?: number;
127
+ drain_on_version_upgrade?: boolean;
128
+ actor_eviction_period?: number;
129
+ actor_eviction_rate?: number;
130
+ };
131
+ protocol_version?: number;
132
+ }
133
+
134
+ export interface RunnerConfigDatacenters {
135
+ datacenters: Record<string, RunnerConfig>;
136
+ }
137
+
138
+ export interface RunnerConfigsResponse {
139
+ runner_configs: Record<string, RunnerConfigDatacenters>;
140
+ }
141
+
142
+ export async function getRunnerConfig(
143
+ config: ClientConfig,
144
+ name: string,
145
+ ): Promise<RunnerConfigsResponse> {
146
+ return apiCall<never, RunnerConfigsResponse>(
147
+ config,
148
+ "GET",
149
+ `/runner-configs?runner_name=${name}`,
150
+ );
151
+ }
152
+
110
153
  // MARK: Update runner config
111
154
  export interface RegistryConfigRequest {
112
155
  datacenters: Record<
113
156
  string,
114
157
  {
115
- normal?: Record<string, unknown>;
158
+ normal?: {
159
+ drain_on_version_upgrade?: boolean;
160
+ actor_eviction_period?: number;
161
+ actor_eviction_rate?: number;
162
+ };
116
163
  serverless?: {
117
164
  url: string;
118
165
  headers: Record<string, string>;
@@ -123,9 +170,11 @@ export interface RegistryConfigRequest {
123
170
  runners_margin: number;
124
171
  slots_per_runner: number;
125
172
  metadata_poll_interval?: number;
173
+ drain_on_version_upgrade?: boolean;
174
+ actor_eviction_period?: number;
175
+ actor_eviction_rate?: number;
126
176
  };
127
177
  metadata?: Record<string, unknown>;
128
- drain_on_version_upgrade?: boolean;
129
178
  }
130
179
  >;
131
180
  }
@@ -1,10 +1,10 @@
1
1
  import { z } from "zod/v4";
2
+ import { RivetError } from "@/actor/errors";
2
3
  import type { ClientConfig } from "@/client/config";
3
4
  import { sendHttpRequest } from "@/client/utils";
4
- import { RivetError } from "@/actor/errors";
5
+ import type { RegistryConfig } from "@/registry/config";
5
6
  import { combineUrlPath } from "@/utils";
6
7
  import { logger } from "./log";
7
- import { RegistryConfig } from "@/registry/config";
8
8
 
9
9
  export { RivetError as EngineApiError };
10
10
 
@@ -1,8 +1,8 @@
1
1
  import type { Hono, Context as HonoContext } from "hono";
2
2
  import type { ActorKey, Encoding, UniversalWebSocket } from "@/actor/mod";
3
+ import type { ActorQuery, CrashPolicy } from "@/client/query";
3
4
  import type { RegistryConfig } from "@/registry/config";
4
5
  import type { GetUpgradeWebSocket } from "@/utils";
5
- import type { ActorQuery, CrashPolicy } from "@/client/query";
6
6
 
7
7
  export type GatewayTarget = { directId: string } | ActorQuery;
8
8
 
@@ -7,9 +7,9 @@ import {
7
7
  PATH_WEBSOCKET_BASE,
8
8
  PATH_WEBSOCKET_PREFIX,
9
9
  } from "@/common/actor-router-consts";
10
+ import type { JsonCompatValue } from "@/common/encoding";
10
11
  import { noopNext } from "@/common/utils";
11
12
  import type { Actor as ApiActor } from "@/engine-api/actors";
12
- import { shouldSkipReadyWait } from "@/engine-client/driver";
13
13
  import type {
14
14
  ActorOutput,
15
15
  CreateInput,
@@ -22,6 +22,7 @@ import type {
22
22
  ListActorsInput,
23
23
  RuntimeDisplayInformation,
24
24
  } from "@/engine-client/driver";
25
+ import { shouldSkipReadyWait } from "@/engine-client/driver";
25
26
  import type { Encoding, UniversalWebSocket } from "@/mod";
26
27
  import { encodeCborCompat, uint8ArrayToBase64 } from "@/serde";
27
28
  import { combineUrlPath, type GetUpgradeWebSocket } from "@/utils";
@@ -181,7 +182,9 @@ export class RemoteEngineControlClient implements EngineControlClient {
181
182
  key: serializeActorKey(key),
182
183
  runner_name_selector: this.#config.poolName,
183
184
  input: actorInput
184
- ? uint8ArrayToBase64(encodeCborCompat(actorInput))
185
+ ? uint8ArrayToBase64(
186
+ encodeCborCompat(actorInput as JsonCompatValue),
187
+ )
185
188
  : undefined,
186
189
  crash_policy: crashPolicy ?? "sleep",
187
190
  });
@@ -215,7 +218,7 @@ export class RemoteEngineControlClient implements EngineControlClient {
215
218
  runner_name_selector: this.#config.poolName,
216
219
  key: serializeActorKey(key),
217
220
  input: input
218
- ? uint8ArrayToBase64(encodeCborCompat(input))
221
+ ? uint8ArrayToBase64(encodeCborCompat(input as JsonCompatValue))
219
222
  : undefined,
220
223
  crash_policy: crashPolicy ?? "sleep",
221
224
  });
@@ -9,7 +9,7 @@ import { logger } from "./log";
9
9
  * Returns Hono `upgradeWebSocket` args that will proxy requests from the client to a destination address.
10
10
  */
11
11
  export async function createWebSocketProxy(
12
- c: HonoContext,
12
+ _c: HonoContext,
13
13
  targetUrl: string,
14
14
  protocols: string[],
15
15
  ): Promise<UpgradeWebSocketArgs> {
@@ -23,7 +23,7 @@ export async function createWebSocketProxy(
23
23
  const state: WsState = {};
24
24
 
25
25
  return {
26
- onOpen: async (event: any, clientWs: WSContext) => {
26
+ onOpen: async (_event: any, clientWs: WSContext) => {
27
27
  logger().debug({ msg: "client websocket connected", targetUrl });
28
28
 
29
29
  if (clientWs.readyState !== 1) {
@@ -68,6 +68,11 @@ export async function createWebSocketProxy(
68
68
  reject(error);
69
69
  });
70
70
  });
71
+ // Attach a no-op rejection handler so Node.js does not treat this as
72
+ // an unhandled rejection if onMessage never runs (e.g. the client
73
+ // disconnects before sending a message). The rejection still propagates
74
+ // to any caller that awaits connectPromise directly.
75
+ state.connectPromise.catch(() => {});
71
76
 
72
77
  // Setup bidirectional forwarding
73
78
  state.targetWs.addEventListener("message", (event) => {
@@ -137,7 +142,7 @@ export async function createWebSocketProxy(
137
142
  }
138
143
  },
139
144
 
140
- onClose: (event: any, clientWs: WSContext) => {
145
+ onClose: (event: any, _clientWs: WSContext) => {
141
146
  logger().debug({
142
147
  msg: "client websocket closed",
143
148
  targetUrl,
@@ -159,7 +164,7 @@ export async function createWebSocketProxy(
159
164
  }
160
165
  },
161
166
 
162
- onError: (event: any, clientWs: WSContext) => {
167
+ onError: (event: any, _clientWs: WSContext) => {
163
168
  logger().error({ msg: "client websocket error", targetUrl, event });
164
169
 
165
170
  if (state.targetWs) {
@@ -198,7 +198,9 @@ const v3ToServerToV4 = (v3Data: v3.ToServer): v4.ToServer =>
198
198
 
199
199
  const v4ToServerToV3 = (v4Data: v4.ToServer): v3.ToServer => {
200
200
  if (v4Data.body.tag === "WorkflowReplayRequest") {
201
- throw new Error("Cannot convert v4-only workflow replay requests to v3");
201
+ throw new Error(
202
+ "Cannot convert v4-only workflow replay requests to v3",
203
+ );
202
204
  }
203
205
 
204
206
  return v4Data as unknown as v3.ToServer;
@@ -238,11 +240,7 @@ export const TO_SERVER_VERSIONED = createVersionedDataHandler<v4.ToServer>({
238
240
  v2ToServerToV3,
239
241
  v3ToServerToV4,
240
242
  ],
241
- serializeConverters: () => [
242
- v4ToServerToV3,
243
- v3ToServerToV2,
244
- v2ToServerToV1,
245
- ],
243
+ serializeConverters: () => [v4ToServerToV3, v3ToServerToV2, v2ToServerToV1],
246
244
  });
247
245
 
248
246
  export const TO_CLIENT_VERSIONED = createVersionedDataHandler<v4.ToClient>({
@@ -279,9 +277,5 @@ export const TO_CLIENT_VERSIONED = createVersionedDataHandler<v4.ToClient>({
279
277
  v2ToClientToV3,
280
278
  v3ToClientToV4,
281
279
  ],
282
- serializeConverters: () => [
283
- v4ToClientToV3,
284
- v3ToClientToV2,
285
- v2ToClientToV1,
286
- ],
280
+ serializeConverters: () => [v4ToClientToV3, v3ToClientToV2, v2ToClientToV1],
287
281
  });
@@ -1,4 +1,5 @@
1
1
  export * from "@/common/bare/generated/inspector/v4";
2
+ export type { WorkflowHistory as TransportWorkflowHistory } from "@/common/bare/transport/v1";
2
3
  export {
3
4
  decodeWorkflowHistoryTransport,
4
5
  encodeWorkflowHistoryTransport,
@@ -7,6 +8,3 @@ export {
7
8
  createWorkflowInspectorAdapter,
8
9
  type WorkflowInspectorAdapter,
9
10
  } from "@/workflow/inspector";
10
- export type {
11
- WorkflowHistory as TransportWorkflowHistory,
12
- } from "@/common/bare/transport/v1";