rivetkit 2.0.42 → 2.1.0-rc.1
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/{tsup/config-CLnylLYY.d.ts → browser/client.d.ts} +2127 -1910
- package/dist/browser/client.js +5182 -0
- package/dist/browser/client.js.map +1 -0
- package/dist/browser/inspector/client.d.ts +130 -0
- package/dist/browser/inspector/client.js +2854 -0
- package/dist/browser/inspector/client.js.map +1 -0
- package/dist/browser/v3-DnYObHH3.d.ts +279 -0
- package/dist/schemas/actor-inspector/v2.ts +796 -0
- package/dist/schemas/actor-inspector/v3.ts +899 -0
- package/dist/schemas/actor-persist/v4.ts +406 -0
- package/dist/schemas/client-protocol/v3.ts +554 -0
- package/dist/schemas/persist/v1.ts +781 -0
- package/dist/schemas/transport/v1.ts +697 -0
- package/dist/tsup/actor/errors.cjs +27 -3
- package/dist/tsup/actor/errors.cjs.map +1 -1
- package/dist/tsup/actor/errors.d.cts +37 -1
- package/dist/tsup/actor/errors.d.ts +37 -1
- package/dist/tsup/actor/errors.js +26 -1
- package/dist/tsup/{actor-router-consts-DzI2szci.d.cts → actor-router-consts-D29T1Z-K.d.cts} +1 -1
- package/dist/tsup/{actor-router-consts-DzI2szci.d.ts → actor-router-consts-D29T1Z-K.d.ts} +1 -1
- package/dist/tsup/chunk-424PT5DM.js +23 -0
- package/dist/tsup/chunk-424PT5DM.js.map +1 -0
- package/dist/tsup/{chunk-JDAD2YFA.js → chunk-5ESWDTHJ.js} +148 -273
- package/dist/tsup/chunk-5ESWDTHJ.js.map +1 -0
- package/dist/tsup/{chunk-FJ3KTN4V.js → chunk-6LIBPELE.js} +119 -11
- package/dist/tsup/chunk-6LIBPELE.js.map +1 -0
- package/dist/tsup/chunk-6LJAZ5R4.cjs +96 -0
- package/dist/tsup/chunk-6LJAZ5R4.cjs.map +1 -0
- package/dist/tsup/{chunk-LFVF5SCU.js → chunk-7HTNH26M.js} +126 -1
- package/dist/tsup/chunk-7HTNH26M.js.map +1 -0
- package/dist/tsup/chunk-7K4CYDGD.js +630 -0
- package/dist/tsup/chunk-7K4CYDGD.js.map +1 -0
- package/dist/tsup/{chunk-XXGJCOL6.js → chunk-A6YIZWTK.js} +2 -2
- package/dist/tsup/chunk-AIYEYMX5.cjs +630 -0
- package/dist/tsup/chunk-AIYEYMX5.cjs.map +1 -0
- package/dist/tsup/{chunk-Q6W7RJJP.js → chunk-DIGBC2VI.js} +211 -2316
- package/dist/tsup/chunk-DIGBC2VI.js.map +1 -0
- package/dist/tsup/{chunk-RZW2DNND.cjs → chunk-F6JYU5IK.cjs} +1957 -1039
- package/dist/tsup/chunk-F6JYU5IK.cjs.map +1 -0
- package/dist/tsup/chunk-HAZL2EPK.cjs +534 -0
- package/dist/tsup/chunk-HAZL2EPK.cjs.map +1 -0
- package/dist/tsup/chunk-HDQ2JUQT.cjs +23 -0
- package/dist/tsup/chunk-HDQ2JUQT.cjs.map +1 -0
- package/dist/tsup/chunk-HIDX4C5Y.cjs +1036 -0
- package/dist/tsup/chunk-HIDX4C5Y.cjs.map +1 -0
- package/dist/tsup/chunk-IVG73YCW.js +534 -0
- package/dist/tsup/chunk-IVG73YCW.js.map +1 -0
- package/dist/tsup/chunk-KJSYAUOM.js +96 -0
- package/dist/tsup/chunk-KJSYAUOM.js.map +1 -0
- package/dist/tsup/{chunk-2XQS746M.cjs → chunk-L47L3ZWJ.cjs} +127 -2
- package/dist/tsup/chunk-L47L3ZWJ.cjs.map +1 -0
- package/dist/tsup/{chunk-H4TB4X25.cjs → chunk-LW6KLR7A.cjs} +126 -18
- package/dist/tsup/chunk-LW6KLR7A.cjs.map +1 -0
- package/dist/tsup/chunk-LXUQ667X.js +2006 -0
- package/dist/tsup/chunk-LXUQ667X.js.map +1 -0
- package/dist/tsup/{chunk-GMAVRZSF.js → chunk-M2T62AZQ.js} +1790 -872
- package/dist/tsup/chunk-M2T62AZQ.js.map +1 -0
- package/dist/tsup/chunk-MZ37VV3P.js +5974 -0
- package/dist/tsup/chunk-MZ37VV3P.js.map +1 -0
- package/dist/tsup/chunk-N4KRDJ56.js +72 -0
- package/dist/tsup/chunk-N4KRDJ56.js.map +1 -0
- package/dist/tsup/chunk-NIYZDWMW.cjs +2006 -0
- package/dist/tsup/chunk-NIYZDWMW.cjs.map +1 -0
- package/dist/tsup/chunk-OMEPCQK2.js +649 -0
- package/dist/tsup/chunk-OMEPCQK2.js.map +1 -0
- package/dist/tsup/chunk-SR3KQE7Q.cjs +72 -0
- package/dist/tsup/chunk-SR3KQE7Q.cjs.map +1 -0
- package/dist/tsup/chunk-SSEP6DHP.cjs +2657 -0
- package/dist/tsup/chunk-SSEP6DHP.cjs.map +1 -0
- package/dist/tsup/chunk-T5YCUGVS.js +1036 -0
- package/dist/tsup/chunk-T5YCUGVS.js.map +1 -0
- package/dist/tsup/{chunk-EJVBH5VF.cjs → chunk-TPGXWFQT.cjs} +3 -3
- package/dist/tsup/{chunk-EJVBH5VF.cjs.map → chunk-TPGXWFQT.cjs.map} +1 -1
- package/dist/tsup/{chunk-X35U3YNX.cjs → chunk-TYLXNCA5.cjs} +214 -339
- package/dist/tsup/chunk-TYLXNCA5.cjs.map +1 -0
- package/dist/tsup/chunk-VKVNIQRQ.js +257 -0
- package/dist/tsup/chunk-VKVNIQRQ.js.map +1 -0
- package/dist/tsup/chunk-XWBAQO5H.cjs +649 -0
- package/dist/tsup/chunk-XWBAQO5H.cjs.map +1 -0
- package/dist/tsup/chunk-YQ4LDVD6.cjs +5974 -0
- package/dist/tsup/chunk-YQ4LDVD6.cjs.map +1 -0
- package/dist/tsup/chunk-ZFY5J2EP.cjs +257 -0
- package/dist/tsup/chunk-ZFY5J2EP.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +9 -10
- package/dist/tsup/client/mod.cjs.map +1 -1
- package/dist/tsup/client/mod.d.cts +11 -5
- package/dist/tsup/client/mod.d.ts +11 -5
- package/dist/tsup/client/mod.js +8 -8
- package/dist/tsup/common/log.cjs +4 -4
- package/dist/tsup/common/log.d.cts +2 -2
- package/dist/tsup/common/log.d.ts +2 -2
- package/dist/tsup/common/log.js +3 -2
- package/dist/tsup/common/websocket.cjs +5 -5
- package/dist/tsup/common/websocket.js +4 -3
- package/dist/tsup/config-BFqid9Gr.d.ts +2574 -0
- package/dist/tsup/config-BiNoIHRs.d.cts +80 -0
- package/dist/tsup/config-BiNoIHRs.d.ts +80 -0
- package/dist/tsup/{config-CZB2-W8x.d.cts → config-CAZphOS1.d.cts} +681 -355
- package/dist/tsup/db/drizzle/mod.cjs +49 -0
- package/dist/tsup/db/drizzle/mod.cjs.map +1 -0
- package/dist/tsup/db/drizzle/mod.d.cts +17 -0
- package/dist/tsup/db/drizzle/mod.d.ts +17 -0
- package/dist/tsup/db/drizzle/mod.js +49 -0
- package/dist/tsup/db/drizzle/mod.js.map +1 -0
- package/dist/tsup/db/mod.cjs +9 -0
- package/dist/tsup/db/mod.cjs.map +1 -0
- package/dist/tsup/db/mod.d.cts +9 -0
- package/dist/tsup/db/mod.d.ts +9 -0
- package/dist/tsup/db/mod.js +9 -0
- package/dist/tsup/db/mod.js.map +1 -0
- package/dist/tsup/{driver-D0QX9M11.d.ts → driver-Bxv62E2p.d.ts} +2 -2
- package/dist/tsup/{driver-q-zqG7fc.d.cts → driver-DYXwJR5D.d.cts} +2 -2
- package/dist/tsup/driver-helpers/mod.cjs +12 -6
- package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
- package/dist/tsup/driver-helpers/mod.d.cts +12 -5
- package/dist/tsup/driver-helpers/mod.d.ts +12 -5
- package/dist/tsup/driver-helpers/mod.js +12 -5
- package/dist/tsup/driver-test-suite/mod.cjs +1370 -116
- package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/driver-test-suite/mod.d.cts +10 -4
- package/dist/tsup/driver-test-suite/mod.d.ts +10 -4
- package/dist/tsup/driver-test-suite/mod.js +2093 -838
- package/dist/tsup/driver-test-suite/mod.js.map +1 -1
- package/dist/tsup/inspector/mod.cjs +29 -3
- package/dist/tsup/inspector/mod.cjs.map +1 -1
- package/dist/tsup/inspector/mod.d.cts +124 -3
- package/dist/tsup/inspector/mod.d.ts +124 -3
- package/dist/tsup/inspector/mod.js +72 -45
- package/dist/tsup/keys-CydblqMh.d.cts +13 -0
- package/dist/tsup/keys-CydblqMh.d.ts +13 -0
- package/dist/tsup/mod.cjs +16 -10
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +26 -14
- package/dist/tsup/mod.d.ts +26 -14
- package/dist/tsup/mod.js +20 -13
- package/dist/tsup/serve-test-suite/mod.cjs +1165 -83
- package/dist/tsup/serve-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/serve-test-suite/mod.js +1114 -29
- package/dist/tsup/serve-test-suite/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +84 -11
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +10 -5
- package/dist/tsup/test/mod.d.ts +10 -5
- package/dist/tsup/test/mod.js +85 -11
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/utils.cjs +10 -4
- package/dist/tsup/utils.cjs.map +1 -1
- package/dist/tsup/utils.d.cts +72 -2
- package/dist/tsup/utils.d.ts +72 -2
- package/dist/tsup/utils.js +9 -2
- package/dist/tsup/v3-DnYObHH3.d.cts +279 -0
- package/dist/tsup/v3-DnYObHH3.d.ts +279 -0
- package/dist/tsup/workflow/mod.cjs +16 -0
- package/dist/tsup/workflow/mod.cjs.map +1 -0
- package/dist/tsup/workflow/mod.d.cts +83 -0
- package/dist/tsup/workflow/mod.d.ts +83 -0
- package/dist/tsup/workflow/mod.js +16 -0
- package/dist/tsup/workflow/mod.js.map +1 -0
- package/package.json +62 -5
- package/src/actor/config.ts +478 -68
- package/src/actor/conn/mod.ts +68 -16
- package/src/actor/conn/state-manager.ts +2 -2
- package/src/actor/contexts/action.ts +20 -12
- package/src/actor/contexts/base/actor.ts +137 -7
- package/src/actor/contexts/base/conn-init.ts +27 -7
- package/src/actor/contexts/base/conn.ts +27 -18
- package/src/actor/contexts/before-action-response.ts +9 -2
- package/src/actor/contexts/before-connect.ts +7 -2
- package/src/actor/contexts/connect.ts +9 -2
- package/src/actor/contexts/create-conn-state.ts +7 -2
- package/src/actor/contexts/create-vars.ts +16 -3
- package/src/actor/contexts/create.ts +16 -3
- package/src/actor/contexts/destroy.ts +9 -3
- package/src/actor/contexts/disconnect.ts +10 -4
- package/src/actor/contexts/index.ts +4 -3
- package/src/actor/contexts/request.ts +23 -6
- package/src/actor/contexts/run.ts +47 -0
- package/src/actor/contexts/sleep.ts +9 -3
- package/src/actor/contexts/state-change.ts +9 -3
- package/src/actor/contexts/wake.ts +9 -3
- package/src/actor/contexts/websocket.ts +23 -6
- package/src/actor/database.ts +8 -18
- package/src/actor/definition.ts +20 -6
- package/src/actor/driver.ts +32 -3
- package/src/actor/errors.ts +127 -0
- package/src/actor/instance/connection-manager.ts +183 -80
- package/src/actor/instance/event-manager.ts +26 -15
- package/src/actor/instance/keys.ts +117 -0
- package/src/actor/instance/mod.ts +784 -174
- package/src/actor/instance/queue-manager.ts +603 -0
- package/src/actor/instance/queue.ts +287 -0
- package/src/actor/instance/schedule-manager.ts +49 -7
- package/src/actor/instance/state-manager.ts +35 -11
- package/src/actor/instance/traces-driver.ts +128 -0
- package/src/actor/mod.ts +26 -2
- package/src/actor/protocol/old.ts +28 -13
- package/src/actor/protocol/serde.ts +1 -1
- package/src/actor/router-endpoints.ts +177 -21
- package/src/actor/router-websocket-endpoints.ts +18 -29
- package/src/actor/router.ts +177 -0
- package/src/actor/schema.ts +291 -0
- package/src/actor/utils.ts +40 -0
- package/src/client/actor-common.ts +1 -1
- package/src/client/actor-conn.ts +100 -33
- package/src/client/actor-handle.ts +61 -33
- package/src/client/client.ts +2 -4
- package/src/client/config.ts +1 -1
- package/src/client/mod.browser.ts +2 -0
- package/src/client/mod.ts +1 -4
- package/src/client/queue.ts +146 -0
- package/src/client/utils.ts +1 -1
- package/src/common/log.ts +1 -1
- package/src/common/utils.ts +3 -3
- package/src/db/config.ts +100 -0
- package/src/db/drizzle/mod.ts +226 -0
- package/src/db/drizzle/sqlite-core.ts +22 -0
- package/src/db/mod.ts +125 -0
- package/src/db/shared.ts +92 -0
- package/src/db/sqlite-vfs.ts +12 -0
- package/src/driver-helpers/mod.ts +1 -0
- package/src/driver-test-suite/mod.ts +69 -43
- package/src/driver-test-suite/tests/access-control.ts +218 -0
- package/src/driver-test-suite/tests/actor-db-raw.ts +73 -0
- package/src/driver-test-suite/tests/actor-db.ts +394 -0
- package/src/driver-test-suite/tests/actor-inspector.ts +259 -358
- package/src/driver-test-suite/tests/actor-kv.ts +41 -20
- package/src/driver-test-suite/tests/actor-queue.ts +324 -0
- package/src/driver-test-suite/tests/actor-run.ts +181 -0
- package/src/driver-test-suite/tests/actor-schedule.ts +5 -2
- package/src/driver-test-suite/tests/actor-sleep.ts +3 -3
- package/src/driver-test-suite/tests/actor-stateless.ts +70 -0
- package/src/driver-test-suite/tests/actor-workflow.ts +108 -0
- package/src/driver-test-suite/tests/manager-driver.ts +11 -0
- package/src/driver-test-suite/tests/raw-http-request-properties.ts +1 -1
- package/src/driver-test-suite/tests/raw-websocket.ts +12 -12
- package/src/drivers/default.ts +7 -2
- package/src/drivers/engine/actor-driver.ts +45 -37
- package/src/drivers/engine/config.ts +1 -1
- package/src/drivers/file-system/actor.ts +20 -2
- package/src/drivers/file-system/global-state.ts +569 -258
- package/src/drivers/file-system/kv-limits.ts +70 -0
- package/src/drivers/file-system/manager.ts +22 -6
- package/src/drivers/file-system/mod.ts +39 -16
- package/src/drivers/file-system/sqlite-runtime.ts +210 -0
- package/src/inspector/actor-inspector.ts +224 -102
- package/src/inspector/config.ts +1 -1
- package/src/inspector/handler.ts +102 -20
- package/src/inspector/mod.browser.ts +8 -0
- package/src/inspector/mod.ts +2 -0
- package/src/inspector/serve-ui.ts +40 -0
- package/src/inspector/transport.ts +18 -0
- package/src/inspector/utils.ts +5 -39
- package/src/manager/gateway.ts +1 -1
- package/src/manager/protocol/mod.ts +1 -1
- package/src/manager/protocol/query.ts +1 -1
- package/src/manager/router-schema.ts +1 -1
- package/src/manager/router.ts +38 -12
- package/src/manager-api/actors.ts +1 -1
- package/src/manager-api/common.ts +1 -1
- package/src/registry/config/driver.ts +1 -1
- package/src/registry/config/index.ts +212 -43
- package/src/registry/config/legacy-runner.ts +1 -1
- package/src/registry/config/runner.ts +1 -1
- package/src/registry/config/serverless.ts +1 -1
- package/src/registry/index.ts +7 -5
- package/src/remote-manager-driver/api-utils.ts +1 -1
- package/src/schemas/actor-inspector/mod.ts +1 -1
- package/src/schemas/actor-inspector/versioned.ts +195 -8
- package/src/schemas/actor-persist/versioned.ts +87 -7
- package/src/schemas/client-protocol/mod.ts +1 -1
- package/src/schemas/client-protocol/versioned.ts +127 -11
- package/src/schemas/client-protocol-zod/mod.ts +16 -1
- package/src/schemas/persist/mod.ts +1 -0
- package/src/schemas/transport/mod.ts +1 -0
- package/src/serde.ts +1 -1
- package/src/serve-test-suite/mod.ts +10 -9
- package/src/test/mod.ts +15 -56
- package/src/utils/endpoint-parser.test.ts +1 -1
- package/src/utils/endpoint-parser.ts +1 -1
- package/src/utils/env-vars.ts +12 -1
- package/src/utils/node.ts +15 -2
- package/src/utils.test.ts +34 -0
- package/src/utils.ts +140 -6
- package/src/workflow/constants.ts +2 -0
- package/src/workflow/context.ts +532 -0
- package/src/workflow/driver.ts +191 -0
- package/src/workflow/inspector.ts +268 -0
- package/src/workflow/mod.ts +122 -0
- package/dist/tsup/chunk-2IJTYN6K.cjs +0 -278
- package/dist/tsup/chunk-2IJTYN6K.cjs.map +0 -1
- package/dist/tsup/chunk-2XQS746M.cjs.map +0 -1
- package/dist/tsup/chunk-3VP5CSHV.cjs +0 -114
- package/dist/tsup/chunk-3VP5CSHV.cjs.map +0 -1
- package/dist/tsup/chunk-AQFSQMBG.js +0 -114
- package/dist/tsup/chunk-AQFSQMBG.js.map +0 -1
- package/dist/tsup/chunk-E6ZE2YEA.js +0 -664
- package/dist/tsup/chunk-E6ZE2YEA.js.map +0 -1
- package/dist/tsup/chunk-FJ3KTN4V.js.map +0 -1
- package/dist/tsup/chunk-GBENOENJ.cjs +0 -8
- package/dist/tsup/chunk-GBENOENJ.cjs.map +0 -1
- package/dist/tsup/chunk-GD7UXGOE.cjs +0 -4762
- package/dist/tsup/chunk-GD7UXGOE.cjs.map +0 -1
- package/dist/tsup/chunk-GMAVRZSF.js.map +0 -1
- package/dist/tsup/chunk-H4TB4X25.cjs.map +0 -1
- package/dist/tsup/chunk-JDAD2YFA.js.map +0 -1
- package/dist/tsup/chunk-KCOVZOPS.js +0 -1946
- package/dist/tsup/chunk-KCOVZOPS.js.map +0 -1
- package/dist/tsup/chunk-KDFWJKMJ.cjs +0 -664
- package/dist/tsup/chunk-KDFWJKMJ.cjs.map +0 -1
- package/dist/tsup/chunk-LFVF5SCU.js.map +0 -1
- package/dist/tsup/chunk-Q6W7RJJP.js.map +0 -1
- package/dist/tsup/chunk-RUW5CZ5Z.cjs +0 -1949
- package/dist/tsup/chunk-RUW5CZ5Z.cjs.map +0 -1
- package/dist/tsup/chunk-RZW2DNND.cjs.map +0 -1
- package/dist/tsup/chunk-TCOEBUUE.js +0 -278
- package/dist/tsup/chunk-TCOEBUUE.js.map +0 -1
- package/dist/tsup/chunk-X35U3YNX.cjs.map +0 -1
- package/dist/tsup/keys-Chhy4ylv.d.cts +0 -8
- package/dist/tsup/keys-Chhy4ylv.d.ts +0 -8
- package/dist/tsup/v1-Gq4avTK3.d.cts +0 -240
- package/dist/tsup/v1-Gq4avTK3.d.ts +0 -240
- /package/dist/tsup/{chunk-XXGJCOL6.js.map → chunk-A6YIZWTK.js.map} +0 -0
package/src/inspector/utils.ts
CHANGED
|
@@ -1,29 +1,6 @@
|
|
|
1
1
|
import { createMiddleware } from "hono/factory";
|
|
2
|
-
import { inspectorLogger } from "./log";
|
|
3
2
|
import type { RegistryConfig } from "@/registry/config";
|
|
4
|
-
|
|
5
|
-
export function compareSecrets(providedSecret: string, validSecret: string) {
|
|
6
|
-
// Early length check to avoid unnecessary processing
|
|
7
|
-
if (providedSecret.length !== validSecret.length) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const encoder = new TextEncoder();
|
|
12
|
-
|
|
13
|
-
const a = encoder.encode(providedSecret);
|
|
14
|
-
const b = encoder.encode(validSecret);
|
|
15
|
-
|
|
16
|
-
if (a.byteLength !== b.byteLength) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// TODO:
|
|
21
|
-
// // Perform timing-safe comparison
|
|
22
|
-
// if (!crypto.timingSafeEqual(a, b)) {
|
|
23
|
-
// return false;
|
|
24
|
-
// }
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
3
|
+
import { timingSafeEqual } from "@/utils/crypto";
|
|
27
4
|
|
|
28
5
|
export const secureInspector = (config: RegistryConfig) =>
|
|
29
6
|
createMiddleware(async (c, next) => {
|
|
@@ -37,8 +14,7 @@ export const secureInspector = (config: RegistryConfig) =>
|
|
|
37
14
|
return c.text("Unauthorized", 401);
|
|
38
15
|
}
|
|
39
16
|
|
|
40
|
-
|
|
41
|
-
if (!isValid) {
|
|
17
|
+
if (!timingSafeEqual(userToken, inspectorToken)) {
|
|
42
18
|
return c.text("Unauthorized", 401);
|
|
43
19
|
}
|
|
44
20
|
await next();
|
|
@@ -50,17 +26,7 @@ export function getInspectorUrl(
|
|
|
50
26
|
): string | undefined {
|
|
51
27
|
if (!config.inspector.enabled) return undefined;
|
|
52
28
|
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const endpoint =
|
|
57
|
-
config.inspector.defaultEndpoint ??
|
|
58
|
-
(config.managerPort !== 6420
|
|
59
|
-
? `http://127.0.0.1:${managerPort}`
|
|
60
|
-
: undefined);
|
|
61
|
-
if (endpoint) {
|
|
62
|
-
url.searchParams.set("u", endpoint);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return url.href;
|
|
29
|
+
const base =
|
|
30
|
+
config.inspector.defaultEndpoint ?? `http://127.0.0.1:${managerPort}`;
|
|
31
|
+
return new URL("/ui/", base).href;
|
|
66
32
|
}
|
package/src/manager/gateway.ts
CHANGED
|
@@ -425,7 +425,7 @@ export async function createTestWebSocketProxy(
|
|
|
425
425
|
promise: clientToProxyWsPromise,
|
|
426
426
|
resolve: clientToProxyWsResolve,
|
|
427
427
|
reject: clientToProxyWsReject,
|
|
428
|
-
} = promiseWithResolvers<WSContext>();
|
|
428
|
+
} = promiseWithResolvers<WSContext>((reason) => logger().warn({ msg: "unhandled client websocket promise rejection", reason }));
|
|
429
429
|
try {
|
|
430
430
|
// Resolve the client WebSocket promise
|
|
431
431
|
logger().debug({ msg: "awaiting client websocket promise" });
|
package/src/manager/router.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
+
import { serveStatic } from "@hono/node-server/serve-static";
|
|
1
2
|
import { createRoute } from "@hono/zod-openapi";
|
|
2
3
|
import * as cbor from "cbor-x";
|
|
3
|
-
|
|
4
4
|
import type { Hono } from "hono";
|
|
5
5
|
import invariant from "invariant";
|
|
6
|
-
import { z } from "zod";
|
|
6
|
+
import { z } from "zod/v4";
|
|
7
7
|
import { Forbidden, RestrictedFeature } from "@/actor/errors";
|
|
8
|
-
|
|
9
|
-
import { serializeActorKey } from "@/actor/keys";
|
|
10
|
-
|
|
8
|
+
import { deserializeActorKey, serializeActorKey } from "@/actor/keys";
|
|
11
9
|
import type { Encoding } from "@/client/mod";
|
|
12
10
|
import {
|
|
13
11
|
HEADER_RIVET_TOKEN,
|
|
@@ -23,6 +21,7 @@ import type {
|
|
|
23
21
|
TestInlineDriverCallRequest,
|
|
24
22
|
TestInlineDriverCallResponse,
|
|
25
23
|
} from "@/driver-test-suite/test-inline-client-driver";
|
|
24
|
+
import { getInspectorDir } from "@/inspector/serve-ui";
|
|
26
25
|
import {
|
|
27
26
|
ActorsCreateRequestSchema,
|
|
28
27
|
type ActorsCreateResponse,
|
|
@@ -95,9 +94,9 @@ export function buildManagerRouter(
|
|
|
95
94
|
|
|
96
95
|
const actorIdsParsed = actor_ids
|
|
97
96
|
? actor_ids
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
.split(",")
|
|
98
|
+
.map((id) => id.trim())
|
|
99
|
+
.filter((id) => id.length > 0)
|
|
101
100
|
: undefined;
|
|
102
101
|
|
|
103
102
|
const actors: ActorOutput[] = [];
|
|
@@ -171,7 +170,7 @@ export function buildManagerRouter(
|
|
|
171
170
|
const actorOutput = await managerDriver.getWithKey({
|
|
172
171
|
c,
|
|
173
172
|
name,
|
|
174
|
-
key:
|
|
173
|
+
key: deserializeActorKey(key),
|
|
175
174
|
});
|
|
176
175
|
if (actorOutput) {
|
|
177
176
|
actors.push(actorOutput);
|
|
@@ -245,7 +244,7 @@ export function buildManagerRouter(
|
|
|
245
244
|
const existingActor = await managerDriver.getWithKey({
|
|
246
245
|
c,
|
|
247
246
|
name: body.name,
|
|
248
|
-
key:
|
|
247
|
+
key: deserializeActorKey(body.key),
|
|
249
248
|
});
|
|
250
249
|
|
|
251
250
|
if (existingActor) {
|
|
@@ -259,7 +258,7 @@ export function buildManagerRouter(
|
|
|
259
258
|
const newActor = await managerDriver.getOrCreateWithKey({
|
|
260
259
|
c,
|
|
261
260
|
name: body.name,
|
|
262
|
-
key:
|
|
261
|
+
key: deserializeActorKey(body.key),
|
|
263
262
|
input: body.input
|
|
264
263
|
? cbor.decode(Buffer.from(body.input, "base64"))
|
|
265
264
|
: undefined,
|
|
@@ -291,7 +290,7 @@ export function buildManagerRouter(
|
|
|
291
290
|
const actorOutput = await managerDriver.createActor({
|
|
292
291
|
c,
|
|
293
292
|
name: body.name,
|
|
294
|
-
key:
|
|
293
|
+
key: deserializeActorKey(body.key || crypto.randomUUID()),
|
|
295
294
|
input: body.input
|
|
296
295
|
? cbor.decode(Buffer.from(body.input, "base64"))
|
|
297
296
|
: undefined,
|
|
@@ -587,6 +586,33 @@ export function buildManagerRouter(
|
|
|
587
586
|
});
|
|
588
587
|
}
|
|
589
588
|
|
|
589
|
+
if (config.inspector.enabled) {
|
|
590
|
+
let inspectorRoot: string | undefined;
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
router.get("/ui/*", async (c, next) => {
|
|
594
|
+
if (!inspectorRoot) {
|
|
595
|
+
inspectorRoot = await getInspectorDir();
|
|
596
|
+
}
|
|
597
|
+
const root = inspectorRoot;
|
|
598
|
+
const rewrite = (path: string) =>
|
|
599
|
+
path.replace(/^\/ui/, "") || "/";
|
|
600
|
+
|
|
601
|
+
return serveStatic({
|
|
602
|
+
root,
|
|
603
|
+
rewriteRequestPath: rewrite,
|
|
604
|
+
onNotFound: async (_path, c) => {
|
|
605
|
+
await serveStatic({ root, path: "index.html" })(
|
|
606
|
+
c,
|
|
607
|
+
next,
|
|
608
|
+
);
|
|
609
|
+
},
|
|
610
|
+
})(c, next);
|
|
611
|
+
});
|
|
612
|
+
|
|
613
|
+
router.get("/ui", (c) => c.redirect("/ui/"));
|
|
614
|
+
}
|
|
615
|
+
|
|
590
616
|
router.get("/health", (c) => handleHealthRequest(c));
|
|
591
617
|
|
|
592
618
|
router.get("/metadata", (c) =>
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { getRunMetadata } from "@/actor/config";
|
|
2
3
|
import type { ActorDefinition, AnyActorDefinition } from "@/actor/definition";
|
|
3
4
|
import { type Logger, LogLevelSchema } from "@/common/log";
|
|
4
5
|
import { ENGINE_ENDPOINT } from "@/engine-process/constants";
|
|
5
6
|
import { InspectorConfigSchema } from "@/inspector/config";
|
|
7
|
+
import { DeepReadonly } from "@/utils";
|
|
6
8
|
import { tryParseEndpoint } from "@/utils/endpoint-parser";
|
|
7
9
|
import {
|
|
8
10
|
getRivetEndpoint,
|
|
9
11
|
getRivetEngine,
|
|
12
|
+
getRivetkitStoragePath,
|
|
10
13
|
getRivetNamespace,
|
|
11
14
|
getRivetToken,
|
|
12
15
|
isDev,
|
|
@@ -14,13 +17,12 @@ import {
|
|
|
14
17
|
import { type DriverConfig, DriverConfigSchema } from "./driver";
|
|
15
18
|
import { RunnerConfigSchema } from "./runner";
|
|
16
19
|
import { ServerlessConfigSchema } from "./serverless";
|
|
17
|
-
import { DeepReadonly } from "@/utils";
|
|
18
20
|
|
|
19
21
|
export { DriverConfigSchema, type DriverConfig };
|
|
20
22
|
|
|
21
23
|
export const ActorsSchema = z.record(
|
|
22
24
|
z.string(),
|
|
23
|
-
z.custom<ActorDefinition<any, any, any, any, any, any, any>>(),
|
|
25
|
+
z.custom<ActorDefinition<any, any, any, any, any, any, any, any, any>>(),
|
|
24
26
|
);
|
|
25
27
|
export type RegistryActors = z.infer<typeof ActorsSchema>;
|
|
26
28
|
|
|
@@ -44,6 +46,17 @@ export const RegistryConfigSchema = z
|
|
|
44
46
|
|
|
45
47
|
// MARK: Driver
|
|
46
48
|
driver: DriverConfigSchema.optional(),
|
|
49
|
+
/**
|
|
50
|
+
* Storage path for RivetKit file-system state when using the default driver.
|
|
51
|
+
*
|
|
52
|
+
* If not set, RivetKit uses the platform default data location.
|
|
53
|
+
*
|
|
54
|
+
* Can also be set via RIVETKIT_STORAGE_PATH.
|
|
55
|
+
*/
|
|
56
|
+
storagePath: z
|
|
57
|
+
.string()
|
|
58
|
+
.optional()
|
|
59
|
+
.transform((val) => val ?? getRivetkitStoragePath()),
|
|
47
60
|
|
|
48
61
|
// MARK: Networking
|
|
49
62
|
/** @experimental */
|
|
@@ -265,9 +278,21 @@ export type RegistryConfigInput<A extends RegistryActors> = Omit<
|
|
|
265
278
|
|
|
266
279
|
export function buildActorNames(
|
|
267
280
|
config: RegistryConfig,
|
|
268
|
-
): Record<string, { metadata: Record<string,
|
|
281
|
+
): Record<string, { metadata: Record<string, unknown> }> {
|
|
269
282
|
return Object.fromEntries(
|
|
270
|
-
Object.keys(config.use).map((
|
|
283
|
+
Object.keys(config.use).map((actorName) => {
|
|
284
|
+
const definition = config.use[actorName];
|
|
285
|
+
const options = definition.config.options ?? {};
|
|
286
|
+
const runMeta = getRunMetadata(definition.config.run);
|
|
287
|
+
const metadata: Record<string, unknown> = {};
|
|
288
|
+
// Actor options take precedence over run metadata
|
|
289
|
+
metadata.icon = options.icon ?? runMeta.icon;
|
|
290
|
+
metadata.name = options.name ?? runMeta.name;
|
|
291
|
+
// Remove undefined values
|
|
292
|
+
if (!metadata.icon) delete metadata.icon;
|
|
293
|
+
if (!metadata.name) delete metadata.name;
|
|
294
|
+
return [actorName, { metadata }];
|
|
295
|
+
}),
|
|
271
296
|
);
|
|
272
297
|
}
|
|
273
298
|
|
|
@@ -277,9 +302,22 @@ export function buildActorNames(
|
|
|
277
302
|
|
|
278
303
|
export const DocInspectorConfigSchema = z
|
|
279
304
|
.object({
|
|
280
|
-
enabled: z
|
|
281
|
-
|
|
282
|
-
|
|
305
|
+
enabled: z
|
|
306
|
+
.boolean()
|
|
307
|
+
.optional()
|
|
308
|
+
.describe(
|
|
309
|
+
"Whether to enable the Rivet Inspector. Defaults to true in development mode.",
|
|
310
|
+
),
|
|
311
|
+
token: z
|
|
312
|
+
.string()
|
|
313
|
+
.optional()
|
|
314
|
+
.describe("Token used to access the Inspector."),
|
|
315
|
+
defaultEndpoint: z
|
|
316
|
+
.string()
|
|
317
|
+
.optional()
|
|
318
|
+
.describe(
|
|
319
|
+
"Default RivetKit server endpoint for Rivet Inspector to connect to.",
|
|
320
|
+
),
|
|
283
321
|
})
|
|
284
322
|
.optional()
|
|
285
323
|
.describe("Inspector configuration for debugging and development.");
|
|
@@ -287,53 +325,184 @@ export const DocInspectorConfigSchema = z
|
|
|
287
325
|
export const DocConfigureRunnerPoolSchema = z
|
|
288
326
|
.object({
|
|
289
327
|
name: z.string().optional().describe("Name of the runner pool."),
|
|
290
|
-
url: z
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
328
|
+
url: z
|
|
329
|
+
.string()
|
|
330
|
+
.describe("URL of the serverless platform to configure runners."),
|
|
331
|
+
headers: z
|
|
332
|
+
.record(z.string(), z.string())
|
|
333
|
+
.optional()
|
|
334
|
+
.describe(
|
|
335
|
+
"Headers to include in requests to the serverless platform.",
|
|
336
|
+
),
|
|
337
|
+
maxRunners: z
|
|
338
|
+
.number()
|
|
339
|
+
.optional()
|
|
340
|
+
.describe("Maximum number of runners in the pool."),
|
|
341
|
+
minRunners: z
|
|
342
|
+
.number()
|
|
343
|
+
.optional()
|
|
344
|
+
.describe("Minimum number of runners to keep warm."),
|
|
345
|
+
requestLifespan: z
|
|
346
|
+
.number()
|
|
347
|
+
.optional()
|
|
348
|
+
.describe("Maximum lifespan of a request in milliseconds."),
|
|
349
|
+
runnersMargin: z
|
|
350
|
+
.number()
|
|
351
|
+
.optional()
|
|
352
|
+
.describe("Buffer margin for scaling runners."),
|
|
353
|
+
slotsPerRunner: z
|
|
354
|
+
.number()
|
|
355
|
+
.optional()
|
|
356
|
+
.describe("Number of actor slots per runner."),
|
|
357
|
+
metadata: z
|
|
358
|
+
.record(z.string(), z.unknown())
|
|
359
|
+
.optional()
|
|
360
|
+
.describe(
|
|
361
|
+
"Additional metadata to pass to the serverless platform.",
|
|
362
|
+
),
|
|
363
|
+
metadataPollInterval: z
|
|
364
|
+
.number()
|
|
365
|
+
.optional()
|
|
366
|
+
.describe(
|
|
367
|
+
"Interval in milliseconds between metadata polls from the engine. Defaults to 10000 milliseconds (10 seconds).",
|
|
368
|
+
),
|
|
299
369
|
})
|
|
300
370
|
.optional();
|
|
301
371
|
|
|
302
|
-
export const DocServerlessConfigSchema = z
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
372
|
+
export const DocServerlessConfigSchema = z
|
|
373
|
+
.object({
|
|
374
|
+
spawnEngine: z
|
|
375
|
+
.boolean()
|
|
376
|
+
.optional()
|
|
377
|
+
.describe(
|
|
378
|
+
"Downloads and starts the full Rust engine process. Auto-enabled in development mode when no endpoint is provided. Default: false",
|
|
379
|
+
),
|
|
380
|
+
engineVersion: z
|
|
381
|
+
.string()
|
|
382
|
+
.optional()
|
|
383
|
+
.describe(
|
|
384
|
+
"Version of the engine to download. Defaults to the current RivetKit version.",
|
|
385
|
+
),
|
|
386
|
+
configureRunnerPool: DocConfigureRunnerPoolSchema.describe(
|
|
387
|
+
"Automatically configure serverless runners in the engine.",
|
|
388
|
+
),
|
|
389
|
+
basePath: z
|
|
390
|
+
.string()
|
|
391
|
+
.optional()
|
|
392
|
+
.describe(
|
|
393
|
+
"Base path for serverless API routes. Default: '/api/rivet'",
|
|
394
|
+
),
|
|
395
|
+
publicEndpoint: z
|
|
396
|
+
.string()
|
|
397
|
+
.optional()
|
|
398
|
+
.describe(
|
|
399
|
+
"The endpoint that clients should connect to. Supports URL auth syntax: https://namespace:token@api.rivet.dev",
|
|
400
|
+
),
|
|
401
|
+
publicToken: z
|
|
402
|
+
.string()
|
|
403
|
+
.optional()
|
|
404
|
+
.describe(
|
|
405
|
+
"Token that clients should use when connecting via the public endpoint.",
|
|
406
|
+
),
|
|
407
|
+
})
|
|
408
|
+
.describe("Configuration for serverless deployment mode.");
|
|
409
|
+
|
|
410
|
+
export const DocRunnerConfigSchema = z
|
|
411
|
+
.object({
|
|
412
|
+
totalSlots: z
|
|
413
|
+
.number()
|
|
414
|
+
.optional()
|
|
415
|
+
.describe("Total number of actor slots available. Default: 100000"),
|
|
416
|
+
runnerName: z
|
|
417
|
+
.string()
|
|
418
|
+
.optional()
|
|
419
|
+
.describe("Name of this runner. Default: 'default'"),
|
|
420
|
+
runnerKey: z
|
|
421
|
+
.string()
|
|
422
|
+
.optional()
|
|
423
|
+
.describe("Authentication key for the runner."),
|
|
424
|
+
version: z
|
|
425
|
+
.number()
|
|
426
|
+
.optional()
|
|
427
|
+
.describe("Version number of this runner. Default: 1"),
|
|
428
|
+
})
|
|
429
|
+
.describe("Configuration for runner mode.");
|
|
317
430
|
|
|
318
431
|
export const DocRegistryConfigSchema = z
|
|
319
432
|
.object({
|
|
320
|
-
use: z
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
433
|
+
use: z
|
|
434
|
+
.record(z.string(), z.unknown())
|
|
435
|
+
.describe(
|
|
436
|
+
"Actor definitions. Keys are actor names, values are actor definitions.",
|
|
437
|
+
),
|
|
438
|
+
storagePath: z
|
|
439
|
+
.string()
|
|
440
|
+
.optional()
|
|
441
|
+
.describe(
|
|
442
|
+
"Storage path for RivetKit file-system state when using the default driver. Can also be set via RIVETKIT_STORAGE_PATH.",
|
|
443
|
+
),
|
|
444
|
+
maxIncomingMessageSize: z
|
|
445
|
+
.number()
|
|
446
|
+
.optional()
|
|
447
|
+
.describe(
|
|
448
|
+
"Maximum size of incoming WebSocket messages in bytes. Default: 65536",
|
|
449
|
+
),
|
|
450
|
+
maxOutgoingMessageSize: z
|
|
451
|
+
.number()
|
|
452
|
+
.optional()
|
|
453
|
+
.describe(
|
|
454
|
+
"Maximum size of outgoing WebSocket messages in bytes. Default: 1048576",
|
|
455
|
+
),
|
|
456
|
+
noWelcome: z
|
|
457
|
+
.boolean()
|
|
458
|
+
.optional()
|
|
459
|
+
.describe("Disable the welcome message on startup. Default: false"),
|
|
324
460
|
logging: z
|
|
325
461
|
.object({
|
|
326
|
-
level: LogLevelSchema.optional().describe(
|
|
462
|
+
level: LogLevelSchema.optional().describe(
|
|
463
|
+
"Log level for RivetKit. Default: 'warn'",
|
|
464
|
+
),
|
|
327
465
|
})
|
|
328
466
|
.optional()
|
|
329
467
|
.describe("Logging configuration."),
|
|
330
|
-
endpoint: z
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
468
|
+
endpoint: z
|
|
469
|
+
.string()
|
|
470
|
+
.optional()
|
|
471
|
+
.describe(
|
|
472
|
+
"Endpoint URL to connect to Rivet Engine. Supports URL auth syntax: https://namespace:token@api.rivet.dev. Can also be set via RIVET_ENDPOINT environment variable.",
|
|
473
|
+
),
|
|
474
|
+
token: z
|
|
475
|
+
.string()
|
|
476
|
+
.optional()
|
|
477
|
+
.describe(
|
|
478
|
+
"Authentication token for Rivet Engine. Can also be set via RIVET_TOKEN environment variable.",
|
|
479
|
+
),
|
|
480
|
+
namespace: z
|
|
481
|
+
.string()
|
|
482
|
+
.optional()
|
|
483
|
+
.describe(
|
|
484
|
+
"Namespace to use. Default: 'default'. Can also be set via RIVET_NAMESPACE environment variable.",
|
|
485
|
+
),
|
|
486
|
+
headers: z
|
|
487
|
+
.record(z.string(), z.string())
|
|
488
|
+
.optional()
|
|
489
|
+
.describe(
|
|
490
|
+
"Additional headers to include in requests to Rivet Engine.",
|
|
491
|
+
),
|
|
492
|
+
serveManager: z
|
|
493
|
+
.boolean()
|
|
494
|
+
.optional()
|
|
495
|
+
.describe(
|
|
496
|
+
"Whether to start the local manager server. Auto-determined based on endpoint and NODE_ENV if not specified.",
|
|
497
|
+
),
|
|
498
|
+
managerBasePath: z
|
|
499
|
+
.string()
|
|
500
|
+
.optional()
|
|
501
|
+
.describe("Base path for the manager API. Default: '/'"),
|
|
502
|
+
managerPort: z
|
|
503
|
+
.number()
|
|
504
|
+
.optional()
|
|
505
|
+
.describe("Port to run the manager on. Default: 6420"),
|
|
337
506
|
inspector: DocInspectorConfigSchema,
|
|
338
507
|
serverless: DocServerlessConfigSchema.optional(),
|
|
339
508
|
runner: DocRunnerConfigSchema.optional(),
|
package/src/registry/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Client } from "@/client/client";
|
|
2
2
|
import { createClient } from "@/client/mod";
|
|
3
|
-
import { isDev } from "@/utils/env-vars";
|
|
3
|
+
import { getNodeEnv, isDev } from "@/utils/env-vars";
|
|
4
4
|
import {
|
|
5
5
|
type RegistryActors,
|
|
6
6
|
type RegistryConfig,
|
|
@@ -49,10 +49,12 @@ export class Registry<A extends RegistryActors> {
|
|
|
49
49
|
this.#config = config;
|
|
50
50
|
|
|
51
51
|
// Auto-prepare on next tick (gives time for sync config modification)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
if (getNodeEnv() !== "test") {
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
// biome-ignore lint/nursery/noFloatingPromises: fire-and-forget auto-prepare
|
|
55
|
+
this.#ensureRuntime();
|
|
56
|
+
}, 0);
|
|
57
|
+
}
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
/** Creates runtime if not already created. Idempotent. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "../../../dist/schemas/actor-inspector/
|
|
1
|
+
export * from "../../../dist/schemas/actor-inspector/v3";
|