rivetkit 0.0.0-active-actors-fix-active-count.253e406 → 0.0.0-bisect-sync-sqlite-1.910d1c7
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 +1286 -89
- package/dist/browser/client.js +1699 -704
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.d.ts +252 -129
- package/dist/browser/inspector/client.js +2083 -236
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +8 -2
- package/dist/tsup/actor/errors.cjs.map +1 -1
- package/dist/tsup/actor/errors.d.cts +1 -1
- package/dist/tsup/actor/errors.d.ts +1 -1
- package/dist/tsup/actor/errors.js +7 -1
- package/dist/tsup/agent-os/index.cjs +3 -2289
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +1 -1813
- package/dist/tsup/agent-os/index.d.ts +1 -1813
- package/dist/tsup/agent-os/index.js +3 -2289
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/chunk-2JJU7IQ7.cjs +14 -0
- package/dist/tsup/chunk-2JJU7IQ7.cjs.map +1 -0
- package/dist/tsup/{chunk-DZJZLZ4R.js → chunk-2MXBZGUP.js} +2 -2
- package/dist/tsup/{chunk-L4FVS7GY.js → chunk-47IS5ZFI.js} +6 -6
- package/dist/tsup/chunk-47IS5ZFI.js.map +1 -0
- package/dist/tsup/{chunk-DXWOGCZY.js → chunk-5XWY5CBA.js} +70 -8
- package/dist/tsup/chunk-5XWY5CBA.js.map +1 -0
- package/dist/tsup/{chunk-OQEEZDIK.cjs → chunk-6XVNZKKP.cjs} +506 -31
- package/dist/tsup/chunk-6XVNZKKP.cjs.map +1 -0
- package/dist/tsup/{chunk-3YY5S6TV.js → chunk-A2CF6PFH.js} +20 -12
- package/dist/tsup/chunk-A2CF6PFH.js.map +1 -0
- package/dist/tsup/{chunk-WQ4HNA4W.cjs → chunk-AQJFKHBK.cjs} +276 -27
- package/dist/tsup/chunk-AQJFKHBK.cjs.map +1 -0
- package/dist/tsup/chunk-DPWLASMC.cjs +244 -0
- package/dist/tsup/chunk-DPWLASMC.cjs.map +1 -0
- package/dist/tsup/{chunk-VUF2YEF4.cjs → chunk-DYJOU3MF.cjs} +10 -10
- package/dist/tsup/chunk-DYJOU3MF.cjs.map +1 -0
- package/dist/tsup/{chunk-7WXCRV25.cjs → chunk-ELZ6MT3V.cjs} +18 -11
- package/dist/tsup/chunk-ELZ6MT3V.cjs.map +1 -0
- package/dist/tsup/chunk-HYIVSH5X.js +244 -0
- package/dist/tsup/chunk-HYIVSH5X.js.map +1 -0
- package/dist/tsup/{chunk-T6YVRM4K.js → chunk-IHEO5OT3.js} +275 -26
- package/dist/tsup/chunk-IHEO5OT3.js.map +1 -0
- package/dist/tsup/chunk-IWACVNN5.js +14 -0
- package/dist/tsup/chunk-IWACVNN5.js.map +1 -0
- package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JTHHCZCZ.js} +24 -1
- package/dist/tsup/chunk-JTHHCZCZ.js.map +1 -0
- package/dist/tsup/{chunk-V4JUWAT6.js → chunk-K3AJOPSF.js} +498 -23
- package/dist/tsup/chunk-K3AJOPSF.js.map +1 -0
- package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-KVFIONKQ.cjs} +25 -2
- package/dist/tsup/chunk-KVFIONKQ.cjs.map +1 -0
- package/dist/tsup/{chunk-QAZLM4WT.cjs → chunk-MGI2VVF6.cjs} +45 -9
- package/dist/tsup/chunk-MGI2VVF6.cjs.map +1 -0
- package/dist/tsup/{chunk-QNLGOTQP.js → chunk-NPHTIUUJ.js} +1291 -420
- package/dist/tsup/chunk-NPHTIUUJ.js.map +1 -0
- package/dist/tsup/{chunk-7GKQJFSB.cjs → chunk-POCSZXPQ.cjs} +72 -10
- package/dist/tsup/chunk-POCSZXPQ.cjs.map +1 -0
- package/dist/tsup/{chunk-LD5YASJU.cjs → chunk-RTWH3AX3.cjs} +19 -11
- package/dist/tsup/chunk-RTWH3AX3.cjs.map +1 -0
- package/dist/tsup/{chunk-ARRBQTAR.cjs → chunk-X76BM5JS.cjs} +1420 -549
- package/dist/tsup/chunk-X76BM5JS.cjs.map +1 -0
- package/dist/tsup/{chunk-AGBP757I.js → chunk-X7SYKFPM.js} +16 -9
- package/dist/tsup/chunk-X7SYKFPM.js.map +1 -0
- package/dist/tsup/{chunk-GKAMEBTZ.cjs → chunk-XLDJSZ3B.cjs} +3 -3
- package/dist/tsup/{chunk-GKAMEBTZ.cjs.map → chunk-XLDJSZ3B.cjs.map} +1 -1
- package/dist/tsup/{chunk-KIWH5H3K.js → chunk-ZOVJDAOW.js} +44 -8
- package/dist/tsup/chunk-ZOVJDAOW.js.map +1 -0
- package/dist/tsup/client/mod.cjs +8 -9
- package/dist/tsup/client/mod.cjs.map +1 -1
- package/dist/tsup/client/mod.d.cts +33 -7
- package/dist/tsup/client/mod.d.ts +33 -7
- package/dist/tsup/client/mod.js +7 -8
- package/dist/tsup/common/log.cjs +5 -3
- package/dist/tsup/common/log.cjs.map +1 -1
- package/dist/tsup/common/log.d.cts +5 -1
- package/dist/tsup/common/log.d.ts +5 -1
- package/dist/tsup/common/log.js +6 -4
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-nlTlOKaE.d.cts → config-BMGUEKMZ.d.cts} +1252 -75
- package/dist/tsup/config-CBTr4IhE.d.cts +224 -0
- package/dist/tsup/config-CBTr4IhE.d.ts +224 -0
- package/dist/tsup/{config-D7ykAntK.d.ts → config-iBpXyITj.d.ts} +1252 -75
- package/dist/tsup/context-hyVakgnU.d.ts +136 -0
- package/dist/tsup/context-qfvLuF0P.d.cts +136 -0
- package/dist/tsup/db/drizzle.cjs +127 -67
- package/dist/tsup/db/drizzle.cjs.map +1 -1
- package/dist/tsup/db/drizzle.d.cts +8 -4
- package/dist/tsup/db/drizzle.d.ts +8 -4
- package/dist/tsup/db/drizzle.js +127 -67
- package/dist/tsup/db/drizzle.js.map +1 -1
- package/dist/tsup/db/mod.cjs +6 -124
- package/dist/tsup/db/mod.cjs.map +1 -1
- package/dist/tsup/db/mod.d.cts +12 -4
- package/dist/tsup/db/mod.d.ts +12 -4
- package/dist/tsup/db/mod.js +5 -123
- package/dist/tsup/db/mod.js.map +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 +39 -0
- package/dist/tsup/dynamic/mod.d.ts +39 -0
- package/dist/tsup/dynamic/mod.js +24 -0
- package/dist/tsup/dynamic/mod.js.map +1 -0
- package/dist/tsup/inspector/mod.cjs +47 -12
- package/dist/tsup/inspector/mod.cjs.map +1 -1
- package/dist/tsup/inspector/mod.d.cts +26 -136
- package/dist/tsup/inspector/mod.d.ts +26 -136
- package/dist/tsup/inspector/mod.js +46 -11
- package/dist/tsup/inspector/mod.js.map +1 -1
- package/dist/tsup/inspector/workflow.cjs +21 -0
- package/dist/tsup/inspector/workflow.cjs.map +1 -0
- package/dist/tsup/inspector/workflow.d.cts +144 -0
- package/dist/tsup/inspector/workflow.d.ts +144 -0
- package/dist/tsup/inspector/workflow.js +21 -0
- package/dist/tsup/inspector/workflow.js.map +1 -0
- package/dist/tsup/inspector-tab/mod.cjs +162 -0
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
- package/dist/tsup/inspector-tab/mod.d.cts +242 -0
- package/dist/tsup/inspector-tab/mod.d.ts +242 -0
- package/dist/tsup/inspector-tab/mod.js +162 -0
- package/dist/tsup/inspector-tab/mod.js.map +1 -0
- package/dist/tsup/mod.cjs +3527 -753
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +11 -7
- package/dist/tsup/mod.d.ts +11 -7
- package/dist/tsup/mod.js +3468 -694
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +26 -21
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +7 -5
- package/dist/tsup/test/mod.d.ts +7 -5
- package/dist/tsup/test/mod.js +25 -20
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/unstable/migrations.cjs +101 -0
- package/dist/tsup/unstable/migrations.cjs.map +1 -0
- package/dist/tsup/unstable/migrations.d.cts +29 -0
- package/dist/tsup/unstable/migrations.d.ts +29 -0
- package/dist/tsup/unstable/migrations.js +101 -0
- package/dist/tsup/unstable/migrations.js.map +1 -0
- package/dist/tsup/{utils-DVekpm4I.d.ts → utils-3rsE0JvI.d.cts} +26 -2
- package/dist/tsup/{utils-DVekpm4I.d.cts → utils-3rsE0JvI.d.ts} +26 -2
- package/dist/tsup/utils-C1O-SklO.d.ts +162 -0
- package/dist/tsup/utils-C6b0aYUM.d.cts +162 -0
- package/dist/tsup/utils.cjs +7 -3
- package/dist/tsup/utils.cjs.map +1 -1
- package/dist/tsup/utils.d.cts +4 -147
- package/dist/tsup/utils.d.ts +4 -147
- package/dist/tsup/utils.js +6 -2
- package/dist/tsup/workflow/mod.cjs +557 -410
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +11 -9
- package/dist/tsup/workflow/mod.d.ts +11 -9
- package/dist/tsup/workflow/mod.js +551 -404
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +67 -18
- package/src/actor/actions.ts +155 -0
- package/src/actor/config.ts +679 -101
- package/src/actor/contexts/index.ts +9 -2
- package/src/actor/definition.ts +75 -26
- package/src/actor/errors.ts +107 -8
- package/src/actor/keys.ts +87 -1
- package/src/actor/mod.ts +36 -20
- package/src/actor/schema.ts +6 -2
- package/src/actor/tracing.ts +28 -0
- package/src/agent-os/index.ts +5 -64
- package/src/client/actor-common.ts +84 -54
- package/src/client/actor-conn.ts +231 -68
- package/src/client/actor-handle.ts +283 -89
- package/src/client/actor-query.ts +13 -6
- package/src/client/auth.ts +37 -0
- package/src/client/client.ts +182 -21
- package/src/client/config.ts +28 -3
- package/src/client/errors.ts +15 -2
- package/src/client/lifecycle-errors.ts +63 -5
- package/src/client/mod.ts +10 -0
- package/src/client/outbound-telemetry.ts +66 -0
- package/src/client/query.ts +3 -1
- package/src/client/queue.ts +13 -3
- package/src/client/raw-utils.ts +59 -14
- package/src/client/resolve-gateway-target.ts +3 -1
- package/src/client/retry-budget.ts +81 -0
- package/src/client/token-provider.ts +93 -0
- package/src/client/utils.ts +22 -9
- package/src/common/actor-router-consts.ts +6 -0
- package/src/common/actor-telemetry-context.ts +19 -0
- 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/generated/inspector/v5.ts +1016 -0
- package/src/common/bare/generated/inspector/v6.ts +1367 -0
- package/src/common/bare/transport/v1.ts +694 -542
- package/src/common/client-protocol-versioned.ts +66 -64
- package/src/common/database/config.ts +175 -9
- package/src/common/database/mod.ts +262 -77
- package/src/common/database/native-database.ts +442 -20
- package/src/common/database/shared.ts +25 -0
- package/src/common/encoding.ts +278 -34
- package/src/common/engine.ts +28 -1
- package/src/common/eventsource.ts +1 -1
- package/src/common/fetch-like.ts +63 -0
- package/src/common/inline-websocket-adapter.ts +14 -13
- package/src/common/inspector-transport.ts +12 -2
- package/src/common/log.ts +15 -8
- package/src/common/otel-context.ts +99 -0
- package/src/common/router.ts +14 -18
- package/src/common/utils.ts +8 -169
- package/src/common/websocket-interface.ts +1 -1
- package/src/db/drizzle.ts +182 -80
- package/src/db/mod.ts +5 -1
- package/src/devtools-loader/index.ts +4 -7
- package/src/devtools-loader/serve-devtools.ts +26 -0
- package/src/dynamic/instance.ts +32 -0
- package/src/dynamic/internal.ts +50 -0
- package/src/dynamic/isolate-runtime.ts +64 -0
- package/src/dynamic/mod.ts +32 -0
- package/src/engine-api/actors.ts +15 -3
- package/src/engine-client/actor-http-client.ts +37 -22
- package/src/engine-client/actor-websocket-client.ts +37 -9
- package/src/engine-client/api-endpoints.ts +128 -5
- package/src/engine-client/api-utils.ts +2 -2
- package/src/engine-client/driver.ts +21 -16
- package/src/engine-client/mod.ts +280 -111
- package/src/engine-client/ws-proxy.ts +9 -4
- package/src/inspector/client.browser.ts +127 -15
- package/src/inspector/mod.ts +2 -4
- package/src/inspector/workflow.ts +61 -0
- package/src/inspector-tab/mod.ts +301 -0
- package/src/registry/config/envoy.ts +3 -20
- package/src/registry/config/index.ts +91 -74
- package/src/registry/index.ts +702 -80
- package/src/registry/napi-runtime.ts +643 -42
- package/src/registry/native-http.ts +225 -0
- package/src/registry/native-validation.ts +10 -12
- package/src/registry/native.ts +1881 -582
- package/src/registry/run-handler-coordinator.ts +219 -0
- package/src/registry/runtime.ts +441 -7
- package/src/registry/wasm-runtime.ts +516 -23
- package/src/registry/write-through-proxy.ts +141 -0
- package/src/serde.ts +2 -2
- package/src/serverless/configure.ts +18 -7
- package/src/test/mod.ts +2 -17
- package/src/test/ready.ts +22 -0
- package/src/unstable/migrations.ts +141 -0
- package/src/utils/endpoint-parser.ts +1 -1
- package/src/utils/env-vars.ts +50 -2
- package/src/utils/node.ts +44 -28
- package/src/utils/router.ts +1 -1
- package/src/utils.ts +4 -2
- package/src/workflow/context.ts +703 -242
- package/src/workflow/driver.ts +284 -125
- package/src/workflow/inspector.ts +24 -24
- package/src/workflow/mod.ts +76 -84
- package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
- package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
- package/dist/tsup/chunk-6NT2LIFN.cjs +0 -268
- package/dist/tsup/chunk-6NT2LIFN.cjs.map +0 -1
- package/dist/tsup/chunk-7GKQJFSB.cjs.map +0 -1
- package/dist/tsup/chunk-7WXCRV25.cjs.map +0 -1
- package/dist/tsup/chunk-AGBP757I.js.map +0 -1
- package/dist/tsup/chunk-ARRBQTAR.cjs.map +0 -1
- package/dist/tsup/chunk-DXWOGCZY.js.map +0 -1
- package/dist/tsup/chunk-JGIPV3QU.js +0 -268
- package/dist/tsup/chunk-JGIPV3QU.js.map +0 -1
- package/dist/tsup/chunk-KIWH5H3K.js.map +0 -1
- package/dist/tsup/chunk-L4FVS7GY.js.map +0 -1
- package/dist/tsup/chunk-LD5YASJU.cjs.map +0 -1
- package/dist/tsup/chunk-OQEEZDIK.cjs.map +0 -1
- package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
- package/dist/tsup/chunk-QAZLM4WT.cjs.map +0 -1
- package/dist/tsup/chunk-QNLGOTQP.js.map +0 -1
- package/dist/tsup/chunk-T6YVRM4K.js.map +0 -1
- package/dist/tsup/chunk-V4JUWAT6.js.map +0 -1
- package/dist/tsup/chunk-VUF2YEF4.cjs.map +0 -1
- package/dist/tsup/chunk-WQ4HNA4W.cjs.map +0 -1
- package/dist/tsup/config-CxjGYf4K.d.cts +0 -121
- package/dist/tsup/config-CxjGYf4K.d.ts +0 -121
- package/dist/tsup/context-88opQsfZ.d.cts +0 -92
- package/dist/tsup/context-CVEG5zfg.d.ts +0 -92
- package/src/actor/driver.ts +0 -141
- package/src/actor/instance/mod.ts +0 -2492
- package/src/actor/keys.test.ts +0 -275
- package/src/actor/utils.test.ts +0 -48
- package/src/agent-os/actor/cron.ts +0 -84
- package/src/agent-os/actor/db.ts +0 -54
- package/src/agent-os/actor/filesystem.ts +0 -131
- package/src/agent-os/actor/index.ts +0 -265
- package/src/agent-os/actor/network.ts +0 -58
- package/src/agent-os/actor/preview.ts +0 -191
- package/src/agent-os/actor/process.ts +0 -177
- package/src/agent-os/actor/session.ts +0 -518
- package/src/agent-os/actor/shell.ts +0 -60
- package/src/agent-os/config.ts +0 -79
- package/src/agent-os/fs/database-vfs.ts +0 -624
- package/src/agent-os/types.ts +0 -148
- package/src/client/test.ts +0 -44
- package/src/common/database/mod.test.ts +0 -137
- package/src/common/database/native-database.test.ts +0 -211
- package/src/common/inline-websocket-adapter.test.ts +0 -51
- package/src/drivers/engine/actor-driver.ts +0 -2460
- package/src/registry/runtime.test.ts +0 -50
- package/src/utils/endpoint-parser.test.ts +0 -206
- package/src/utils/serve.ts +0 -217
- package/src/utils.test.ts +0 -34
- /package/dist/tsup/{chunk-DZJZLZ4R.js.map → chunk-2MXBZGUP.js.map} +0 -0
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import type { ClientConfig } from "@/client/config";
|
|
2
2
|
import {
|
|
3
3
|
HEADER_RIVET_ACTOR,
|
|
4
|
+
HEADER_RIVET_NAMESPACE,
|
|
5
|
+
HEADER_RIVET_RAY_ID,
|
|
4
6
|
HEADER_RIVET_SKIP_READY_WAIT,
|
|
5
7
|
HEADER_RIVET_TARGET,
|
|
6
8
|
HEADER_RIVET_TOKEN,
|
|
9
|
+
HEADER_TRACEPARENT,
|
|
10
|
+
HEADER_TRACESTATE,
|
|
7
11
|
} from "@/common/actor-router-consts";
|
|
8
|
-
import {
|
|
12
|
+
import { readRequestBody } from "@/common/fetch-like";
|
|
13
|
+
import { type GatewayRequestOptions, shouldSkipReadyWait } from "./driver";
|
|
9
14
|
|
|
10
15
|
export interface HttpGatewayRequestOptions extends GatewayRequestOptions {
|
|
11
16
|
directActorId?: string;
|
|
@@ -17,7 +22,6 @@ export async function sendHttpRequestToGateway(
|
|
|
17
22
|
actorRequest: Request,
|
|
18
23
|
options: HttpGatewayRequestOptions = {},
|
|
19
24
|
): Promise<Response> {
|
|
20
|
-
// Handle body properly based on method and presence
|
|
21
25
|
let bodyToSend: ArrayBuffer | null = null;
|
|
22
26
|
const guardHeaders = buildGuardHeaders(runConfig, actorRequest, options);
|
|
23
27
|
|
|
@@ -26,35 +30,29 @@ export async function sendHttpRequestToGateway(
|
|
|
26
30
|
throw new Error("Request body has already been consumed");
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (reqBody.byteLength !== 0) {
|
|
34
|
-
bodyToSend = reqBody;
|
|
35
|
-
|
|
36
|
-
// If this is a streaming request, we need to convert the headers
|
|
37
|
-
// for the basic array buffer
|
|
33
|
+
// Browsers reject ReadableStream request bodies, so send bytes.
|
|
34
|
+
const bytes = await readRequestBody(actorRequest);
|
|
35
|
+
if (bytes.byteLength > 0) {
|
|
36
|
+
bodyToSend = bytes;
|
|
38
37
|
guardHeaders.delete("transfer-encoding");
|
|
39
|
-
guardHeaders.
|
|
38
|
+
guardHeaders.delete("content-length");
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
const
|
|
42
|
+
const fetchImpl = runConfig.fetch ?? fetch;
|
|
43
|
+
return fetchImpl(gatewayUrl, {
|
|
44
44
|
method: actorRequest.method,
|
|
45
45
|
headers: guardHeaders,
|
|
46
46
|
body: bodyToSend,
|
|
47
47
|
signal: actorRequest.signal,
|
|
48
|
+
mode: actorRequest.mode,
|
|
49
|
+
credentials: actorRequest.credentials,
|
|
50
|
+
redirect: actorRequest.redirect,
|
|
51
|
+
referrer: actorRequest.referrer,
|
|
52
|
+
referrerPolicy: actorRequest.referrerPolicy,
|
|
53
|
+
integrity: actorRequest.integrity,
|
|
54
|
+
keepalive: actorRequest.keepalive,
|
|
48
55
|
});
|
|
49
|
-
|
|
50
|
-
return mutableResponse(await fetch(guardRequest));
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function mutableResponse(fetchRes: Response): Response {
|
|
54
|
-
// We cannot return the raw response from `fetch` since the response type is not mutable.
|
|
55
|
-
//
|
|
56
|
-
// In order for middleware to be able to mutate the response, we need to build a new Response object that is mutable.
|
|
57
|
-
return new Response(fetchRes.body, fetchRes);
|
|
58
56
|
}
|
|
59
57
|
|
|
60
58
|
function buildGuardHeaders(
|
|
@@ -71,6 +69,18 @@ function buildGuardHeaders(
|
|
|
71
69
|
for (const [key, value] of Object.entries(runConfig.headers)) {
|
|
72
70
|
headers.set(key, value as string);
|
|
73
71
|
}
|
|
72
|
+
// Configured trace context is never sent: it would pin every call to one span.
|
|
73
|
+
for (const name of [HEADER_TRACEPARENT, HEADER_TRACESTATE]) {
|
|
74
|
+
headers.delete(name);
|
|
75
|
+
const value = actorRequest.headers.get(name);
|
|
76
|
+
if (value !== null) {
|
|
77
|
+
headers.set(name, value);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const requestRayId = actorRequest.headers.get(HEADER_RIVET_RAY_ID);
|
|
81
|
+
if (requestRayId !== null) {
|
|
82
|
+
headers.set(HEADER_RIVET_RAY_ID, requestRayId);
|
|
83
|
+
}
|
|
74
84
|
// Add guard-specific headers
|
|
75
85
|
if (runConfig.token) {
|
|
76
86
|
headers.set(HEADER_RIVET_TOKEN, runConfig.token);
|
|
@@ -78,6 +88,11 @@ function buildGuardHeaders(
|
|
|
78
88
|
if (options.directActorId !== undefined) {
|
|
79
89
|
headers.set(HEADER_RIVET_TARGET, "actor");
|
|
80
90
|
headers.set(HEADER_RIVET_ACTOR, options.directActorId);
|
|
91
|
+
// An actor ID resolves within its namespace. Without one the gateway falls back
|
|
92
|
+
// to the token's namespace, or to `default` for the admin token.
|
|
93
|
+
if (runConfig.namespace) {
|
|
94
|
+
headers.set(HEADER_RIVET_NAMESPACE, runConfig.namespace);
|
|
95
|
+
}
|
|
81
96
|
}
|
|
82
97
|
if (shouldSkipReadyWait(options)) {
|
|
83
98
|
headers.set(HEADER_RIVET_SKIP_READY_WAIT, "1");
|
|
@@ -1,24 +1,27 @@
|
|
|
1
|
+
import { actorKeyToGatewayQuery } from "@/actor/keys";
|
|
1
2
|
import {
|
|
2
3
|
type ClientConfig,
|
|
3
4
|
DEFAULT_MAX_QUERY_INPUT_SIZE,
|
|
4
5
|
} from "@/client/config";
|
|
6
|
+
import type { ActorGatewayQuery, CrashPolicy } from "@/client/query";
|
|
5
7
|
import {
|
|
8
|
+
WS_PROTOCOL_ACTOR,
|
|
6
9
|
WS_PROTOCOL_CONN_PARAMS,
|
|
7
10
|
WS_PROTOCOL_ENCODING,
|
|
11
|
+
WS_PROTOCOL_NAMESPACE,
|
|
8
12
|
WS_PROTOCOL_STANDARD as WS_PROTOCOL_RIVETKIT,
|
|
9
|
-
WS_PROTOCOL_TARGET,
|
|
10
|
-
WS_PROTOCOL_ACTOR,
|
|
11
13
|
WS_PROTOCOL_SKIP_READY_WAIT,
|
|
14
|
+
WS_PROTOCOL_TARGET,
|
|
12
15
|
WS_PROTOCOL_TEST_ACK_HOOK,
|
|
13
16
|
WS_PROTOCOL_TOKEN,
|
|
14
17
|
} from "@/common/actor-router-consts";
|
|
18
|
+
import type { JsonCompatValue } from "@/common/encoding";
|
|
15
19
|
import { importWebSocket } from "@/common/websocket";
|
|
16
20
|
import { setRemoteHibernatableWebSocketAckTestHooks } from "@/common/websocket-test-hooks";
|
|
17
|
-
import type { ActorGatewayQuery, CrashPolicy } from "@/client/query";
|
|
18
21
|
import type { Encoding, UniversalWebSocket } from "@/mod";
|
|
19
22
|
import { encodeCborCompat, uint8ArrayToBase64 } from "@/serde";
|
|
20
23
|
import { combineUrlPath } from "@/utils";
|
|
21
|
-
import {
|
|
24
|
+
import { type GatewayRequestOptions, shouldSkipReadyWait } from "./driver";
|
|
22
25
|
import { logger } from "./log";
|
|
23
26
|
|
|
24
27
|
class BufferedRemoteWebSocket implements UniversalWebSocket {
|
|
@@ -192,15 +195,34 @@ class BufferedRemoteWebSocket implements UniversalWebSocket {
|
|
|
192
195
|
}
|
|
193
196
|
}
|
|
194
197
|
|
|
198
|
+
/**
|
|
199
|
+
* Builds the gateway URL of an actor addressed by ID. The actor's namespace rides as
|
|
200
|
+
* `rvt-namespace`: an actor ID is resolved within its namespace, so without it the gateway
|
|
201
|
+
* falls back to the token's namespace, or to `default` for the admin token.
|
|
202
|
+
*/
|
|
195
203
|
export function buildActorGatewayUrl(
|
|
196
204
|
endpoint: string,
|
|
205
|
+
namespace: string,
|
|
197
206
|
actorId: string,
|
|
198
207
|
token: string | undefined,
|
|
199
208
|
path = "",
|
|
200
209
|
): string {
|
|
210
|
+
if (namespace.length === 0) {
|
|
211
|
+
throw new Error("actor gateway namespace must not be empty");
|
|
212
|
+
}
|
|
201
213
|
const tokenSegment =
|
|
202
214
|
token !== undefined ? `@${encodeURIComponent(token)}` : "";
|
|
203
|
-
const
|
|
215
|
+
const params = new URLSearchParams();
|
|
216
|
+
params.append("rvt-namespace", namespace);
|
|
217
|
+
let separator: string;
|
|
218
|
+
if (path.endsWith("?") || path.endsWith("&")) {
|
|
219
|
+
separator = "";
|
|
220
|
+
} else if (path.includes("?")) {
|
|
221
|
+
separator = "&";
|
|
222
|
+
} else {
|
|
223
|
+
separator = "?";
|
|
224
|
+
}
|
|
225
|
+
const gatewayPath = `/gateway/${encodeURIComponent(actorId)}${tokenSegment}${path}${separator}${params.toString()}`;
|
|
204
226
|
return combineUrlPath(endpoint, gatewayPath);
|
|
205
227
|
}
|
|
206
228
|
|
|
@@ -288,8 +310,9 @@ export function buildActorQueryGatewayUrl(
|
|
|
288
310
|
}
|
|
289
311
|
|
|
290
312
|
function pushKeyQueryParams(params: URLSearchParams, key: string[]): void {
|
|
291
|
-
|
|
292
|
-
|
|
313
|
+
const rvtKey = actorKeyToGatewayQuery(key);
|
|
314
|
+
if (rvtKey !== undefined) {
|
|
315
|
+
params.append("rvt-key", rvtKey);
|
|
293
316
|
}
|
|
294
317
|
}
|
|
295
318
|
|
|
@@ -302,7 +325,7 @@ function pushInputQueryParam(
|
|
|
302
325
|
return;
|
|
303
326
|
}
|
|
304
327
|
|
|
305
|
-
const encodedInput = encodeCborCompat(input);
|
|
328
|
+
const encodedInput = encodeCborCompat(input as JsonCompatValue);
|
|
306
329
|
if (encodedInput.byteLength > maxInputSize) {
|
|
307
330
|
throw new Error(
|
|
308
331
|
`Actor query input exceeds maxInputSize (${encodedInput.byteLength} > ${maxInputSize} bytes). Increase client maxInputSize to allow larger query payloads.`,
|
|
@@ -335,7 +358,8 @@ export async function openWebSocketToGateway(
|
|
|
335
358
|
|
|
336
359
|
logger().debug({
|
|
337
360
|
msg: "opening websocket to actor via guard",
|
|
338
|
-
|
|
361
|
+
// Gateway URLs can embed credentials; never include the path or query in logs.
|
|
362
|
+
origin: new URL(gatewayUrl).origin,
|
|
339
363
|
});
|
|
340
364
|
|
|
341
365
|
// Create WebSocket connection
|
|
@@ -391,6 +415,10 @@ export function buildWebSocketProtocols(
|
|
|
391
415
|
if (target) {
|
|
392
416
|
protocols.push(`${WS_PROTOCOL_TARGET}${target.target}`);
|
|
393
417
|
protocols.push(`${WS_PROTOCOL_ACTOR}${target.actorId}`);
|
|
418
|
+
// An actor ID resolves within its namespace; see `buildActorGatewayUrl`.
|
|
419
|
+
if (runConfig.namespace) {
|
|
420
|
+
protocols.push(`${WS_PROTOCOL_NAMESPACE}${runConfig.namespace}`);
|
|
421
|
+
}
|
|
394
422
|
if (runConfig.token) {
|
|
395
423
|
protocols.push(`${WS_PROTOCOL_TOKEN}${runConfig.token}`);
|
|
396
424
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { serializeActorKey } from "@/actor/keys";
|
|
2
2
|
import type { ClientConfig } from "@/client/client";
|
|
3
|
+
import type { IssuedToken, IssueTokenOptions } from "@/client/auth";
|
|
3
4
|
import type { MetadataResponse } from "@/common/router";
|
|
4
5
|
import type {
|
|
5
6
|
ActorsCreateRequest,
|
|
6
7
|
ActorsCreateResponse,
|
|
7
8
|
ActorsDeleteResponse,
|
|
9
|
+
ActorsForkRequest,
|
|
10
|
+
ActorsForkResponse,
|
|
8
11
|
ActorsGetOrCreateRequest,
|
|
9
12
|
ActorsGetOrCreateResponse,
|
|
10
13
|
ActorsListResponse,
|
|
@@ -12,6 +15,33 @@ import type {
|
|
|
12
15
|
import type { RivetId } from "@/engine-api/common";
|
|
13
16
|
import { apiCall } from "./api-utils";
|
|
14
17
|
|
|
18
|
+
/** Engine's JSON response uses snake_case; the public result uses camelCase. */
|
|
19
|
+
export type IssueTokenResponse = {
|
|
20
|
+
token: IssuedToken["token"];
|
|
21
|
+
issued_ts: IssuedToken["issuedAt"];
|
|
22
|
+
expires_ts: IssuedToken["expiresAt"];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export async function issueToken(
|
|
26
|
+
config: ClientConfig,
|
|
27
|
+
options: IssueTokenOptions,
|
|
28
|
+
): Promise<IssueTokenResponse> {
|
|
29
|
+
return apiCall<
|
|
30
|
+
{
|
|
31
|
+
namespace: string;
|
|
32
|
+
subject?: IssueTokenOptions["subject"];
|
|
33
|
+
duration?: IssueTokenOptions["expiresIn"];
|
|
34
|
+
grants: IssueTokenOptions["grants"];
|
|
35
|
+
},
|
|
36
|
+
IssueTokenResponse
|
|
37
|
+
>(config, "POST", "/auth/tokens", {
|
|
38
|
+
namespace: config.namespace,
|
|
39
|
+
subject: options.subject,
|
|
40
|
+
duration: options.expiresIn,
|
|
41
|
+
grants: options.grants,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
15
45
|
// MARK: Get actor
|
|
16
46
|
export async function getActor(
|
|
17
47
|
config: ClientConfig,
|
|
@@ -77,6 +107,20 @@ export async function createActor(
|
|
|
77
107
|
);
|
|
78
108
|
}
|
|
79
109
|
|
|
110
|
+
// MARK: Fork actor
|
|
111
|
+
export async function forkActor(
|
|
112
|
+
config: ClientConfig,
|
|
113
|
+
actorId: RivetId,
|
|
114
|
+
request: ActorsForkRequest,
|
|
115
|
+
): Promise<ActorsForkResponse> {
|
|
116
|
+
return apiCall<ActorsForkRequest, ActorsForkResponse>(
|
|
117
|
+
config,
|
|
118
|
+
"POST",
|
|
119
|
+
`/actors/${encodeURIComponent(actorId)}/fork`,
|
|
120
|
+
request,
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
80
124
|
// MARK: Destroy actor
|
|
81
125
|
export async function destroyActor(
|
|
82
126
|
config: ClientConfig,
|
|
@@ -107,12 +151,48 @@ export async function getDatacenters(
|
|
|
107
151
|
return apiCall<never, DatacentersResponse>(config, "GET", `/datacenters`);
|
|
108
152
|
}
|
|
109
153
|
|
|
154
|
+
// MARK: Get runner configs
|
|
155
|
+
export interface RunnerConfig {
|
|
156
|
+
normal?: {
|
|
157
|
+
drain_on_version_upgrade?: boolean;
|
|
158
|
+
actor_eviction_period?: number;
|
|
159
|
+
actor_eviction_rate?: number;
|
|
160
|
+
};
|
|
161
|
+
serverless?: {
|
|
162
|
+
url: string;
|
|
163
|
+
headers: Record<string, string>;
|
|
164
|
+
drain_grace_period?: number;
|
|
165
|
+
max_runners: number;
|
|
166
|
+
min_runners: number;
|
|
167
|
+
request_lifespan: number;
|
|
168
|
+
runners_margin: number;
|
|
169
|
+
slots_per_runner: number;
|
|
170
|
+
metadata_poll_interval?: number;
|
|
171
|
+
drain_on_version_upgrade?: boolean;
|
|
172
|
+
actor_eviction_period?: number;
|
|
173
|
+
actor_eviction_rate?: number;
|
|
174
|
+
};
|
|
175
|
+
protocol_version?: number;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export interface RunnerConfigDatacenters {
|
|
179
|
+
datacenters: Record<string, RunnerConfig>;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface RunnerConfigsResponse {
|
|
183
|
+
runner_configs: Record<string, RunnerConfigDatacenters>;
|
|
184
|
+
}
|
|
185
|
+
|
|
110
186
|
// MARK: Update runner config
|
|
111
187
|
export interface RegistryConfigRequest {
|
|
112
188
|
datacenters: Record<
|
|
113
189
|
string,
|
|
114
190
|
{
|
|
115
|
-
normal?:
|
|
191
|
+
normal?: {
|
|
192
|
+
drain_on_version_upgrade?: boolean;
|
|
193
|
+
actor_eviction_period?: number;
|
|
194
|
+
actor_eviction_rate?: number;
|
|
195
|
+
};
|
|
116
196
|
serverless?: {
|
|
117
197
|
url: string;
|
|
118
198
|
headers: Record<string, string>;
|
|
@@ -123,9 +203,11 @@ export interface RegistryConfigRequest {
|
|
|
123
203
|
runners_margin: number;
|
|
124
204
|
slots_per_runner: number;
|
|
125
205
|
metadata_poll_interval?: number;
|
|
206
|
+
drain_on_version_upgrade?: boolean;
|
|
207
|
+
actor_eviction_period?: number;
|
|
208
|
+
actor_eviction_rate?: number;
|
|
126
209
|
};
|
|
127
210
|
metadata?: Record<string, unknown>;
|
|
128
|
-
drain_on_version_upgrade?: boolean;
|
|
129
211
|
}
|
|
130
212
|
>;
|
|
131
213
|
}
|
|
@@ -135,11 +217,11 @@ export async function updateRunnerConfig(
|
|
|
135
217
|
runnerName: string,
|
|
136
218
|
request: RegistryConfigRequest,
|
|
137
219
|
): Promise<void> {
|
|
138
|
-
return apiCall<
|
|
220
|
+
return apiCall<unknown, void>(
|
|
139
221
|
config,
|
|
140
222
|
"PUT",
|
|
141
|
-
`/
|
|
142
|
-
request,
|
|
223
|
+
`/pools/${encodeURIComponent(runnerName)}`,
|
|
224
|
+
Object.values(request.datacenters)[0],
|
|
143
225
|
);
|
|
144
226
|
}
|
|
145
227
|
|
|
@@ -160,3 +242,44 @@ export async function kvGet(
|
|
|
160
242
|
`/actors/${encodeURIComponent(actorId)}/kv/keys/${encodeURIComponent(key)}`,
|
|
161
243
|
);
|
|
162
244
|
}
|
|
245
|
+
|
|
246
|
+
/** Pool changes apply when each node next connects. */
|
|
247
|
+
export interface PoolConfig {
|
|
248
|
+
drain_on_version_upgrade?: boolean;
|
|
249
|
+
actor_eviction_delay?: number;
|
|
250
|
+
actor_eviction_period?: number;
|
|
251
|
+
actor_eviction_rate?: number;
|
|
252
|
+
metadata?: unknown;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export function upsertPool(
|
|
256
|
+
config: ClientConfig,
|
|
257
|
+
name: string,
|
|
258
|
+
pool: PoolConfig,
|
|
259
|
+
): Promise<{ pool: PoolConfig & { name: string } }> {
|
|
260
|
+
return apiCall(config, "PUT", `/pools/${encodeURIComponent(name)}`, pool);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export function getPool(
|
|
264
|
+
config: ClientConfig,
|
|
265
|
+
name: string,
|
|
266
|
+
): Promise<{ pool: PoolConfig & { name: string } }> {
|
|
267
|
+
return apiCall(config, "GET", `/pools/${encodeURIComponent(name)}`);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export function listPools(
|
|
271
|
+
config: ClientConfig,
|
|
272
|
+
page?: { limit?: number; cursor?: string },
|
|
273
|
+
): Promise<{
|
|
274
|
+
pools: Array<PoolConfig & { name: string }>;
|
|
275
|
+
pagination: { cursor: string | null };
|
|
276
|
+
}> {
|
|
277
|
+
const query = new URLSearchParams();
|
|
278
|
+
if (page?.limit !== undefined) query.set("limit", String(page.limit));
|
|
279
|
+
if (page?.cursor !== undefined) query.set("cursor", page.cursor);
|
|
280
|
+
return apiCall(config, "GET", `/pools?${query}`);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export function deletePool(config: ClientConfig, name: string): Promise<void> {
|
|
284
|
+
return apiCall(config, "DELETE", `/pools/${encodeURIComponent(name)}`);
|
|
285
|
+
}
|
|
@@ -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,9 @@
|
|
|
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";
|
|
4
|
+
import type { IssuedToken, IssueTokenOptions } from "@/client/auth";
|
|
3
5
|
import type { RegistryConfig } from "@/registry/config";
|
|
4
6
|
import type { GetUpgradeWebSocket } from "@/utils";
|
|
5
|
-
import type { ActorQuery, CrashPolicy } from "@/client/query";
|
|
6
7
|
|
|
7
8
|
export type GatewayTarget = { directId: string } | ActorQuery;
|
|
8
9
|
|
|
@@ -17,10 +18,13 @@ export function shouldSkipReadyWait(
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export interface EngineControlClient {
|
|
21
|
+
issueToken(options: IssueTokenOptions): Promise<IssuedToken>;
|
|
20
22
|
getForId(input: GetForIdInput): Promise<ActorOutput | undefined>;
|
|
21
23
|
getWithKey(input: GetWithKeyInput): Promise<ActorOutput | undefined>;
|
|
22
24
|
getOrCreateWithKey(input: GetOrCreateWithKeyInput): Promise<ActorOutput>;
|
|
23
25
|
createActor(input: CreateInput): Promise<ActorOutput>;
|
|
26
|
+
/** Forks the actor `actorId` into a new actor of the same name, started on a copy of its database. */
|
|
27
|
+
forkActor(input: ForkInput): Promise<ActorOutput>;
|
|
24
28
|
listActors(input: ListActorsInput): Promise<ActorOutput[]>;
|
|
25
29
|
|
|
26
30
|
sendRequest(
|
|
@@ -35,6 +39,8 @@ export interface EngineControlClient {
|
|
|
35
39
|
params: unknown,
|
|
36
40
|
options?: GatewayRequestOptions,
|
|
37
41
|
): Promise<UniversalWebSocket>;
|
|
42
|
+
/** Refresh a credential rejected during this WebSocket handshake, if supported. */
|
|
43
|
+
refreshAuthToken?(ws: UniversalWebSocket): Promise<boolean>;
|
|
38
44
|
proxyRequest(
|
|
39
45
|
c: HonoContext,
|
|
40
46
|
actorRequest: Request,
|
|
@@ -61,21 +67,6 @@ export interface EngineControlClient {
|
|
|
61
67
|
* Test-only helper that simulates an abrupt actor crash.
|
|
62
68
|
*/
|
|
63
69
|
hardCrashActor?(actorId: string): Promise<void>;
|
|
64
|
-
kvGet(actorId: string, key: Uint8Array): Promise<string | null>;
|
|
65
|
-
kvBatchGet(
|
|
66
|
-
actorId: string,
|
|
67
|
-
keys: Uint8Array[],
|
|
68
|
-
): Promise<(Uint8Array | null)[]>;
|
|
69
|
-
kvBatchPut(
|
|
70
|
-
actorId: string,
|
|
71
|
-
entries: [Uint8Array, Uint8Array][],
|
|
72
|
-
): Promise<void>;
|
|
73
|
-
kvBatchDelete(actorId: string, keys: Uint8Array[]): Promise<void>;
|
|
74
|
-
kvDeleteRange(
|
|
75
|
-
actorId: string,
|
|
76
|
-
start: Uint8Array,
|
|
77
|
-
end: Uint8Array,
|
|
78
|
-
): Promise<void>;
|
|
79
70
|
}
|
|
80
71
|
|
|
81
72
|
export interface RuntimeDisplayInformation {
|
|
@@ -101,6 +92,8 @@ export interface GetOrCreateWithKeyInput {
|
|
|
101
92
|
input?: unknown;
|
|
102
93
|
region?: string;
|
|
103
94
|
crashPolicy?: CrashPolicy;
|
|
95
|
+
/** Overrides the client's configured pool name for this actor. */
|
|
96
|
+
poolName?: string;
|
|
104
97
|
}
|
|
105
98
|
|
|
106
99
|
export interface CreateInput {
|
|
@@ -110,6 +103,18 @@ export interface CreateInput {
|
|
|
110
103
|
input?: unknown;
|
|
111
104
|
region?: string;
|
|
112
105
|
crashPolicy?: CrashPolicy;
|
|
106
|
+
/** Overrides the client's configured pool name for this actor. */
|
|
107
|
+
poolName?: string;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface ForkInput {
|
|
111
|
+
c?: HonoContext | undefined;
|
|
112
|
+
/** The source actor. */
|
|
113
|
+
actorId: string;
|
|
114
|
+
/** The new actor's key; omitted for a keyless actor. */
|
|
115
|
+
key?: ActorKey;
|
|
116
|
+
/** The fork input, given to the new actor's `onFork` hook. */
|
|
117
|
+
input?: unknown;
|
|
113
118
|
}
|
|
114
119
|
|
|
115
120
|
export interface ListActorsInput {
|