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.
- package/dist/browser/client.d.ts +498 -62
- package/dist/browser/client.js +227 -171
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +50 -20
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +2 -2
- package/dist/tsup/actor/errors.d.cts +1 -1
- package/dist/tsup/actor/errors.d.ts +1 -1
- package/dist/tsup/actor/errors.js +1 -1
- package/dist/tsup/agent-os/index.cjs +2163 -2087
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +496 -69
- package/dist/tsup/agent-os/index.d.ts +496 -69
- package/dist/tsup/agent-os/index.js +2163 -2087
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-W7EYSYVI.js → chunk-2OTRTA3J.js} +134 -20
- package/dist/tsup/chunk-2OTRTA3J.js.map +1 -0
- package/dist/tsup/{chunk-VJFRBJVQ.cjs → chunk-3677IIOV.cjs} +138 -24
- package/dist/tsup/chunk-3677IIOV.cjs.map +1 -0
- package/dist/tsup/{chunk-4CGA6QJO.cjs → chunk-47HHIEXH.cjs} +24 -9
- package/dist/tsup/chunk-47HHIEXH.cjs.map +1 -0
- package/dist/tsup/{chunk-F3Q5BFQ6.js → chunk-4JDSFJS5.js} +66 -79
- package/dist/tsup/chunk-4JDSFJS5.js.map +1 -0
- package/dist/tsup/{chunk-GVTOE34S.cjs → chunk-7QKCIVAY.cjs} +222 -235
- package/dist/tsup/chunk-7QKCIVAY.cjs.map +1 -0
- package/dist/tsup/{chunk-CPA4Y3RG.cjs → chunk-B6VUNZUD.cjs} +10 -10
- package/dist/tsup/chunk-B6VUNZUD.cjs.map +1 -0
- package/dist/tsup/{chunk-H37XQU3I.js → chunk-BEI24WTI.js} +2 -2
- package/dist/tsup/{chunk-KIWH5H3K.js → chunk-BRP62GZC.js} +3 -3
- package/dist/tsup/chunk-BRP62GZC.js.map +1 -0
- package/dist/tsup/{chunk-T6YVRM4K.js → chunk-DPIMKYNB.js} +63 -2
- package/dist/tsup/chunk-DPIMKYNB.js.map +1 -0
- package/dist/tsup/{chunk-Y5NSCZA2.cjs → chunk-DXXJPH55.cjs} +44 -15
- package/dist/tsup/chunk-DXXJPH55.cjs.map +1 -0
- package/dist/tsup/{chunk-3YY5S6TV.js → chunk-HXUEHHJF.js} +2 -2
- package/dist/tsup/chunk-HXUEHHJF.js.map +1 -0
- package/dist/tsup/{chunk-4WPEZBK4.cjs → chunk-I4LN3FNT.cjs} +10 -10
- package/dist/tsup/chunk-I4LN3FNT.cjs.map +1 -0
- package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JZ7TWV65.js} +1 -1
- package/dist/tsup/chunk-JZ7TWV65.js.map +1 -0
- package/dist/tsup/{chunk-QAZLM4WT.cjs → chunk-KORQB2IR.cjs} +3 -3
- package/dist/tsup/{chunk-QAZLM4WT.cjs.map → chunk-KORQB2IR.cjs.map} +1 -1
- package/dist/tsup/{chunk-MALSPBAF.cjs → chunk-LVTBW2RE.cjs} +3 -3
- package/dist/tsup/{chunk-MALSPBAF.cjs.map → chunk-LVTBW2RE.cjs.map} +1 -1
- package/dist/tsup/{chunk-H7P7WR2Y.js → chunk-MEHBWPLJ.js} +6 -6
- package/dist/tsup/chunk-MEHBWPLJ.js.map +1 -0
- package/dist/tsup/{chunk-WQ4HNA4W.cjs → chunk-NIY3RSPX.cjs} +64 -3
- package/dist/tsup/chunk-NIY3RSPX.cjs.map +1 -0
- package/dist/tsup/{chunk-MMMEZM5J.js → chunk-P2GNQ4RN.js} +4 -4
- package/dist/tsup/chunk-P2GNQ4RN.js.map +1 -0
- package/dist/tsup/{chunk-KJTA3ATT.js → chunk-UMZVD6DQ.js} +22 -7
- package/dist/tsup/chunk-UMZVD6DQ.js.map +1 -0
- package/dist/tsup/{chunk-LD5YASJU.cjs → chunk-VE2X4KMG.cjs} +2 -2
- package/dist/tsup/{chunk-LD5YASJU.cjs.map → chunk-VE2X4KMG.cjs.map} +1 -1
- package/dist/tsup/{chunk-VRCIXJRN.js → chunk-VTTFNQQI.js} +36 -7
- package/dist/tsup/chunk-VTTFNQQI.js.map +1 -0
- package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-ZA7FLHKH.cjs} +1 -1
- package/dist/tsup/chunk-ZA7FLHKH.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +9 -9
- package/dist/tsup/client/mod.d.cts +5 -5
- package/dist/tsup/client/mod.d.ts +5 -5
- package/dist/tsup/client/mod.js +8 -8
- package/dist/tsup/common/log.cjs +3 -3
- package/dist/tsup/common/log.js +2 -2
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-0Ta55UV0.d.ts → config-BxWAw3iH.d.ts} +529 -23
- package/dist/tsup/{config-Ca8dN4cS.d.cts → config-CZQQ-mso.d.cts} +529 -23
- package/dist/tsup/{config-CxjGYf4K.d.cts → config-D49x8NpL.d.cts} +1 -2
- package/dist/tsup/{config-CxjGYf4K.d.ts → config-D49x8NpL.d.ts} +1 -2
- package/dist/tsup/{context-B_IWbWne.d.ts → context-Bw7xq8w3.d.cts} +8 -8
- package/dist/tsup/{context-CUrQ9MHc.d.cts → context-D8QA76sV.d.ts} +8 -8
- package/dist/tsup/db/drizzle.cjs +3 -3
- package/dist/tsup/db/drizzle.d.cts +1 -1
- package/dist/tsup/db/drizzle.d.ts +1 -1
- package/dist/tsup/db/drizzle.js +1 -1
- package/dist/tsup/db/mod.cjs +2 -2
- package/dist/tsup/db/mod.d.cts +2 -2
- package/dist/tsup/db/mod.d.ts +2 -2
- package/dist/tsup/db/mod.js +1 -1
- package/dist/tsup/dynamic/mod.cjs +24 -0
- package/dist/tsup/dynamic/mod.cjs.map +1 -0
- package/dist/tsup/dynamic/mod.d.cts +37 -0
- package/dist/tsup/dynamic/mod.d.ts +37 -0
- package/dist/tsup/dynamic/mod.js +24 -0
- package/dist/tsup/dynamic/mod.js.map +1 -0
- package/dist/tsup/inspector/mod.cjs +6 -6
- package/dist/tsup/inspector/mod.js +5 -5
- package/dist/tsup/inspector-tab/mod.cjs +173 -0
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
- package/dist/tsup/inspector-tab/mod.d.cts +250 -0
- package/dist/tsup/inspector-tab/mod.d.ts +250 -0
- package/dist/tsup/inspector-tab/mod.js +173 -0
- package/dist/tsup/inspector-tab/mod.js.map +1 -0
- package/dist/tsup/mod.cjs +730 -336
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +5 -5
- package/dist/tsup/mod.d.ts +5 -5
- package/dist/tsup/mod.js +633 -239
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +21 -18
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +4 -4
- package/dist/tsup/test/mod.d.ts +4 -4
- package/dist/tsup/test/mod.js +18 -15
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/{utils-DVekpm4I.d.cts → utils-DQosb24I.d.cts} +1 -1
- package/dist/tsup/{utils-DVekpm4I.d.ts → utils-DQosb24I.d.ts} +1 -1
- package/dist/tsup/utils.cjs +3 -3
- package/dist/tsup/utils.d.cts +1 -1
- package/dist/tsup/utils.d.ts +1 -1
- package/dist/tsup/utils.js +2 -2
- package/dist/tsup/workflow/mod.cjs +307 -282
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +6 -6
- package/dist/tsup/workflow/mod.d.ts +6 -6
- package/dist/tsup/workflow/mod.js +501 -476
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +32 -11
- package/src/actor/config.ts +159 -51
- package/src/actor/contexts/index.ts +7 -2
- package/src/actor/definition.ts +17 -19
- package/src/actor/driver.ts +3 -3
- package/src/actor/errors.ts +9 -3
- package/src/actor/instance/mod.ts +26 -34
- package/src/actor/keys.ts +1 -1
- package/src/actor/mod.ts +22 -20
- package/src/actor/schema.ts +2 -2
- package/src/agent-os/actor/index.ts +38 -18
- package/src/agent-os/actor/preview.ts +1 -2
- package/src/agent-os/actor/session.ts +2 -2
- package/src/agent-os/config.ts +1 -1
- package/src/agent-os/fs/database-vfs.ts +1 -1
- package/src/agent-os/index.ts +16 -15
- package/src/client/actor-common.ts +87 -54
- package/src/client/actor-conn.ts +8 -36
- package/src/client/actor-handle.ts +69 -51
- package/src/client/actor-query.ts +5 -5
- package/src/client/errors.ts +1 -1
- package/src/client/lifecycle-errors.ts +2 -4
- package/src/client/query.ts +1 -1
- package/src/client/queue.ts +8 -3
- package/src/client/raw-utils.ts +8 -6
- package/src/client/resolve-gateway-target.ts +1 -1
- package/src/client/utils.ts +2 -7
- package/src/common/actor-websocket.ts +3 -1
- package/src/common/bare/actor-persist/v1.ts +205 -163
- package/src/common/bare/actor-persist/v2.ts +265 -213
- package/src/common/bare/actor-persist/v3.ts +176 -172
- package/src/common/bare/actor-persist/v4.ts +254 -253
- package/src/common/bare/transport/v1.ts +659 -543
- package/src/common/client-protocol-versioned.ts +66 -64
- package/src/common/database/config.ts +2 -8
- package/src/common/database/native-database.ts +1 -1
- package/src/common/database/shared.ts +1 -0
- package/src/common/encoding.ts +250 -16
- package/src/common/engine.ts +28 -1
- package/src/common/eventsource.ts +1 -1
- package/src/common/inline-websocket-adapter.ts +14 -13
- package/src/common/log.ts +1 -0
- package/src/common/router.ts +13 -17
- package/src/common/utils.ts +1 -150
- package/src/common/websocket-interface.ts +1 -1
- package/src/db/mod.ts +1 -1
- package/src/devtools-loader/index.ts +4 -7
- package/src/devtools-loader/serve-devtools.ts +26 -0
- package/src/drivers/engine/actor-driver.ts +58 -56
- package/src/dynamic/instance.ts +32 -0
- package/src/dynamic/internal.ts +50 -0
- package/src/dynamic/isolate-runtime.ts +66 -0
- package/src/dynamic/mod.ts +32 -0
- package/src/engine-client/actor-http-client.ts +3 -3
- package/src/engine-client/actor-websocket-client.ts +6 -5
- package/src/engine-client/api-endpoints.ts +51 -2
- package/src/engine-client/api-utils.ts +2 -2
- package/src/engine-client/driver.ts +1 -1
- package/src/engine-client/mod.ts +6 -3
- package/src/engine-client/ws-proxy.ts +9 -4
- package/src/inspector/client.browser.ts +5 -11
- package/src/inspector/mod.ts +1 -3
- package/src/inspector-tab/mod.ts +315 -0
- package/src/registry/config/envoy.ts +1 -2
- package/src/registry/config/index.ts +40 -16
- package/src/registry/index.ts +154 -74
- package/src/registry/napi-runtime.ts +13 -2
- package/src/registry/native-validation.ts +10 -12
- package/src/registry/native.ts +367 -181
- package/src/registry/process-metrics.ts +250 -0
- package/src/registry/runtime.ts +41 -1
- package/src/registry/wasm-runtime.ts +18 -2
- package/src/registry/write-through-proxy.ts +40 -0
- package/src/serde.ts +2 -2
- package/src/serverless/configure.ts +18 -7
- package/src/test/mod.ts +11 -8
- package/src/utils/endpoint-parser.ts +1 -1
- package/src/utils/env-vars.ts +6 -0
- package/src/utils/router.ts +1 -1
- package/src/utils/serve.ts +4 -5
- package/src/utils.ts +1 -2
- package/src/workflow/context.ts +61 -33
- package/src/workflow/driver.ts +4 -6
- package/src/workflow/inspector.ts +4 -3
- package/src/workflow/mod.ts +15 -17
- package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
- package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
- package/dist/tsup/chunk-4CGA6QJO.cjs.map +0 -1
- package/dist/tsup/chunk-4WPEZBK4.cjs.map +0 -1
- package/dist/tsup/chunk-CPA4Y3RG.cjs.map +0 -1
- package/dist/tsup/chunk-F3Q5BFQ6.js.map +0 -1
- package/dist/tsup/chunk-GVTOE34S.cjs.map +0 -1
- package/dist/tsup/chunk-H7P7WR2Y.js.map +0 -1
- package/dist/tsup/chunk-KIWH5H3K.js.map +0 -1
- package/dist/tsup/chunk-KJTA3ATT.js.map +0 -1
- package/dist/tsup/chunk-MMMEZM5J.js.map +0 -1
- package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
- package/dist/tsup/chunk-T6YVRM4K.js.map +0 -1
- package/dist/tsup/chunk-VJFRBJVQ.cjs.map +0 -1
- package/dist/tsup/chunk-VRCIXJRN.js.map +0 -1
- package/dist/tsup/chunk-W7EYSYVI.js.map +0 -1
- package/dist/tsup/chunk-WQ4HNA4W.cjs.map +0 -1
- package/dist/tsup/chunk-Y5NSCZA2.cjs.map +0 -1
- /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 {
|
|
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.
|
|
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 {
|
|
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?:
|
|
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 {
|
|
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
|
|
package/src/engine-client/mod.ts
CHANGED
|
@@ -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(
|
|
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
|
-
|
|
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 (
|
|
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,
|
|
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,
|
|
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(
|
|
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
|
});
|
package/src/inspector/mod.ts
CHANGED
|
@@ -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";
|