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
|
@@ -5,48 +5,24 @@ import {
|
|
|
5
5
|
CONN_DRIVER_SYMBOL,
|
|
6
6
|
CONN_STATE_MANAGER_SYMBOL,
|
|
7
7
|
} from "@/actor/conn/mod";
|
|
8
|
+
import { getRunInspectorConfig } from "@/actor/config";
|
|
8
9
|
import { ActionContext } from "@/actor/contexts/action";
|
|
9
10
|
import * as actorErrors from "@/actor/errors";
|
|
10
11
|
import type { AnyActorInstance } from "@/mod";
|
|
11
12
|
import type * as schema from "@/schemas/actor-inspector/mod";
|
|
12
|
-
import {
|
|
13
|
-
import type { Event } from "./mod";
|
|
13
|
+
import { bufferToArrayBuffer } from "@/utils";
|
|
14
14
|
|
|
15
15
|
interface ActorInspectorEmitterEvents {
|
|
16
16
|
stateUpdated: (state: unknown) => void;
|
|
17
17
|
connectionsUpdated: () => void;
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
queueUpdated: () => void;
|
|
19
|
+
workflowHistoryUpdated: (history: schema.WorkflowHistory) => void;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export type Connection = Omit<schema.Connection, "details"> & {
|
|
23
23
|
details: unknown;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
type EventDetails =
|
|
27
|
-
| {
|
|
28
|
-
type: "action";
|
|
29
|
-
name: string;
|
|
30
|
-
args: unknown[];
|
|
31
|
-
connId: string;
|
|
32
|
-
}
|
|
33
|
-
| {
|
|
34
|
-
type: "subscribe";
|
|
35
|
-
eventName: string;
|
|
36
|
-
connId: string;
|
|
37
|
-
}
|
|
38
|
-
| {
|
|
39
|
-
type: "unsubscribe";
|
|
40
|
-
eventName: string;
|
|
41
|
-
connId: string;
|
|
42
|
-
}
|
|
43
|
-
| {
|
|
44
|
-
type: "event";
|
|
45
|
-
eventName: string;
|
|
46
|
-
args: unknown[];
|
|
47
|
-
connId: string;
|
|
48
|
-
}
|
|
49
|
-
| { type: "broadcast"; eventName: string; args: unknown[] };
|
|
50
26
|
|
|
51
27
|
/**
|
|
52
28
|
* Provides a unified interface for inspecting actor external and internal state.
|
|
@@ -54,34 +30,67 @@ type EventDetails =
|
|
|
54
30
|
export class ActorInspector {
|
|
55
31
|
public readonly emitter = createNanoEvents<ActorInspectorEmitterEvents>();
|
|
56
32
|
|
|
57
|
-
#
|
|
33
|
+
#lastQueueSize = 0;
|
|
34
|
+
#workflowInspector?: NonNullable<
|
|
35
|
+
ReturnType<typeof getRunInspectorConfig>
|
|
36
|
+
>["workflow"];
|
|
58
37
|
|
|
59
38
|
constructor(private readonly actor: AnyActorInstance) {
|
|
60
|
-
this.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
39
|
+
this.#lastQueueSize = actor.queueManager?.size ?? 0;
|
|
40
|
+
const runInspector = getRunInspectorConfig(actor.config.run);
|
|
41
|
+
this.#workflowInspector = runInspector?.workflow;
|
|
42
|
+
if (this.#workflowInspector?.onHistoryUpdated) {
|
|
43
|
+
this.#workflowInspector.onHistoryUpdated((history) => {
|
|
44
|
+
this.emitter.emit(
|
|
45
|
+
"workflowHistoryUpdated",
|
|
46
|
+
history as schema.WorkflowHistory,
|
|
47
|
+
);
|
|
69
48
|
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
70
51
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
this.#lastEvents = this.#lastEvents.slice(-100);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
52
|
+
getQueueSize() {
|
|
53
|
+
return this.#lastQueueSize;
|
|
76
54
|
}
|
|
77
55
|
|
|
78
|
-
|
|
79
|
-
|
|
56
|
+
async getQueueStatus(limit: number): Promise<schema.QueueStatus> {
|
|
57
|
+
const maxSize = this.actor.config.options.maxQueueSize;
|
|
58
|
+
const safeLimit = Math.max(0, Math.floor(limit));
|
|
59
|
+
const messages = await this.actor.queueManager.getMessages();
|
|
60
|
+
const sorted = messages.sort(
|
|
61
|
+
(a, b) => a.createdAt - b.createdAt,
|
|
62
|
+
);
|
|
63
|
+
const limited = safeLimit > 0 ? sorted.slice(0, safeLimit) : [];
|
|
64
|
+
return {
|
|
65
|
+
size: BigInt(this.#lastQueueSize),
|
|
66
|
+
maxSize: BigInt(maxSize),
|
|
67
|
+
truncated: sorted.length > limited.length,
|
|
68
|
+
messages: limited.map((message) => ({
|
|
69
|
+
id: message.id,
|
|
70
|
+
name: message.name,
|
|
71
|
+
createdAtMs: BigInt(message.createdAt),
|
|
72
|
+
})),
|
|
73
|
+
};
|
|
80
74
|
}
|
|
81
75
|
|
|
82
|
-
|
|
83
|
-
this.#
|
|
84
|
-
|
|
76
|
+
updateQueueSize(size: number) {
|
|
77
|
+
if (this.#lastQueueSize === size) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
this.#lastQueueSize = size;
|
|
81
|
+
this.emitter.emit("queueUpdated");
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
isWorkflowEnabled() {
|
|
85
|
+
return this.#workflowInspector !== undefined;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
getWorkflowHistory(): schema.WorkflowHistory | null {
|
|
89
|
+
if (!this.#workflowInspector) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
const history = this.#workflowInspector.getHistory();
|
|
93
|
+
return (history ?? null) as schema.WorkflowHistory | null;
|
|
85
94
|
}
|
|
86
95
|
|
|
87
96
|
// actor accessor methods
|
|
@@ -94,6 +103,73 @@ export class ActorInspector {
|
|
|
94
103
|
}
|
|
95
104
|
}
|
|
96
105
|
|
|
106
|
+
async getDatabaseSchema(): Promise<ArrayBuffer> {
|
|
107
|
+
if (!this.isDatabaseEnabled()) {
|
|
108
|
+
throw new actorErrors.DatabaseNotEnabled();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const db = this.actor.db;
|
|
112
|
+
|
|
113
|
+
// Get table list from sqlite_master, excluding internal tables.
|
|
114
|
+
const tables = await db.execute(
|
|
115
|
+
"SELECT name, type FROM sqlite_master WHERE type IN ('table', 'view') AND name NOT LIKE 'sqlite_%' AND name NOT LIKE '__drizzle_%'",
|
|
116
|
+
) as { name: string; type: string }[];
|
|
117
|
+
|
|
118
|
+
// Serialize all queries to avoid concurrent @rivetkit/sqlite access
|
|
119
|
+
// which can cause "file is not a database" errors.
|
|
120
|
+
const tableInfos = [];
|
|
121
|
+
for (const table of tables) {
|
|
122
|
+
const quoted = `"${escapeDoubleQuotes(table.name)}"`;
|
|
123
|
+
const sample = await db.execute(
|
|
124
|
+
`SELECT * FROM ${quoted} LIMIT 1`,
|
|
125
|
+
) as Record<string, unknown>[];
|
|
126
|
+
const countResult = await db.execute(
|
|
127
|
+
`SELECT COUNT(*) as count FROM ${quoted}`,
|
|
128
|
+
) as { count: number }[];
|
|
129
|
+
|
|
130
|
+
const columnNames = sample?.[0]
|
|
131
|
+
? Object.keys(sample[0])
|
|
132
|
+
: [];
|
|
133
|
+
|
|
134
|
+
tableInfos.push({
|
|
135
|
+
table: { schema: "main", name: table.name, type: table.type },
|
|
136
|
+
columns: columnNames.map((name, cid) => ({
|
|
137
|
+
cid,
|
|
138
|
+
name,
|
|
139
|
+
type: "",
|
|
140
|
+
notnull: 0,
|
|
141
|
+
dflt_value: null,
|
|
142
|
+
pk: 0,
|
|
143
|
+
})),
|
|
144
|
+
foreignKeys: [],
|
|
145
|
+
records: countResult?.[0]?.count ?? 0,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return bufferToArrayBuffer(cbor.encode({ tables: tableInfos }));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async getDatabaseTableRows(
|
|
153
|
+
table: string,
|
|
154
|
+
limit: number,
|
|
155
|
+
offset: number,
|
|
156
|
+
): Promise<ArrayBuffer> {
|
|
157
|
+
if (!this.isDatabaseEnabled()) {
|
|
158
|
+
throw new actorErrors.DatabaseNotEnabled();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const db = this.actor.db;
|
|
162
|
+
const safeLimit = Math.max(0, Math.min(Math.floor(limit), 500));
|
|
163
|
+
const safeOffset = Math.max(0, Math.floor(offset));
|
|
164
|
+
const quoted = `"${escapeDoubleQuotes(table)}"`;
|
|
165
|
+
const result = await db.execute(
|
|
166
|
+
`SELECT * FROM ${quoted} LIMIT ? OFFSET ?`,
|
|
167
|
+
safeLimit,
|
|
168
|
+
safeOffset,
|
|
169
|
+
);
|
|
170
|
+
return bufferToArrayBuffer(cbor.encode(result));
|
|
171
|
+
}
|
|
172
|
+
|
|
97
173
|
isStateEnabled() {
|
|
98
174
|
return this.actor.stateEnabled;
|
|
99
175
|
}
|
|
@@ -168,63 +244,109 @@ export class ActorInspector {
|
|
|
168
244
|
conn.disconnect();
|
|
169
245
|
}
|
|
170
246
|
}
|
|
171
|
-
}
|
|
172
247
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
return {
|
|
176
|
-
body: {
|
|
177
|
-
tag: "ActionEvent",
|
|
178
|
-
val: {
|
|
179
|
-
name: event.name,
|
|
180
|
-
args: bufferToArrayBuffer(cbor.encode(event.args)),
|
|
248
|
+
// JSON-native methods for the HTTP inspector API. These return raw JS
|
|
249
|
+
// objects suitable for JSON serialization instead of CBOR-encoded buffers.
|
|
181
250
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
251
|
+
getStateJson(): unknown {
|
|
252
|
+
if (!this.actor.stateEnabled) {
|
|
253
|
+
throw new actorErrors.StateNotEnabled();
|
|
254
|
+
}
|
|
255
|
+
return this.actor.stateManager.persistRaw.state;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
async setStateJson(state: unknown): Promise<void> {
|
|
259
|
+
if (!this.actor.stateEnabled) {
|
|
260
|
+
throw new actorErrors.StateNotEnabled();
|
|
261
|
+
}
|
|
262
|
+
this.actor.stateManager.state = state;
|
|
263
|
+
await this.actor.stateManager.saveState({ immediate: true });
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
getConnectionsJson(): { id: string; details: unknown }[] {
|
|
267
|
+
return Array.from(
|
|
268
|
+
this.actor.connectionManager.connections.entries(),
|
|
269
|
+
).map(([id, conn]) => {
|
|
270
|
+
const connStateManager = conn[CONN_STATE_MANAGER_SYMBOL];
|
|
271
|
+
return {
|
|
272
|
+
type: conn[CONN_DRIVER_SYMBOL]?.type,
|
|
273
|
+
id,
|
|
274
|
+
details: {
|
|
275
|
+
type: conn[CONN_DRIVER_SYMBOL]?.type,
|
|
276
|
+
params: conn.params as any,
|
|
277
|
+
stateEnabled: connStateManager.stateEnabled,
|
|
278
|
+
state: connStateManager.stateEnabled
|
|
279
|
+
? connStateManager.state
|
|
280
|
+
: undefined,
|
|
281
|
+
subscriptions: conn.subscriptions.size,
|
|
282
|
+
isHibernatable: conn.isHibernatable,
|
|
214
283
|
},
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
284
|
+
};
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
async executeActionJson(name: string, args: unknown[]): Promise<unknown> {
|
|
289
|
+
const conn = await this.actor.connectionManager.prepareAndConnectConn(
|
|
290
|
+
createHttpDriver(),
|
|
291
|
+
undefined,
|
|
292
|
+
undefined,
|
|
293
|
+
undefined,
|
|
294
|
+
undefined,
|
|
295
|
+
);
|
|
296
|
+
|
|
297
|
+
try {
|
|
298
|
+
return await this.actor.executeAction(
|
|
299
|
+
new ActionContext(this.actor, conn),
|
|
300
|
+
name,
|
|
301
|
+
args,
|
|
302
|
+
);
|
|
303
|
+
} finally {
|
|
304
|
+
conn.disconnect();
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
async getTracesJson(options: {
|
|
309
|
+
startMs: number;
|
|
310
|
+
endMs: number;
|
|
311
|
+
limit: number;
|
|
312
|
+
}): Promise<{ otlp: unknown; clamped: boolean }> {
|
|
313
|
+
const result = await this.actor.traces.readRange(options);
|
|
314
|
+
return result;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
getWorkflowHistoryJson(): { history: unknown | null; isWorkflowEnabled: boolean } {
|
|
318
|
+
const bigIntReplacer = (_key: string, value: unknown) =>
|
|
319
|
+
typeof value === "bigint" ? Number(value) : value;
|
|
320
|
+
const history = this.getWorkflowHistory();
|
|
321
|
+
const safeHistory = history
|
|
322
|
+
? JSON.parse(JSON.stringify(history, bigIntReplacer))
|
|
323
|
+
: null;
|
|
218
324
|
return {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
325
|
+
history: safeHistory,
|
|
326
|
+
isWorkflowEnabled: this.isWorkflowEnabled(),
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
getQueueStatusJson(limit: number): Promise<{
|
|
331
|
+
size: number;
|
|
332
|
+
maxSize: number;
|
|
333
|
+
truncated: boolean;
|
|
334
|
+
messages: { id: number; name: string; createdAtMs: number }[];
|
|
335
|
+
}> {
|
|
336
|
+
return this.getQueueStatus(limit).then((status) => ({
|
|
337
|
+
size: Number(status.size),
|
|
338
|
+
maxSize: Number(status.maxSize),
|
|
339
|
+
truncated: status.truncated,
|
|
340
|
+
messages: status.messages.map((m) => ({
|
|
341
|
+
id: Number(m.id),
|
|
342
|
+
name: m.name,
|
|
343
|
+
createdAtMs: Number(m.createdAtMs),
|
|
344
|
+
})),
|
|
345
|
+
}));
|
|
229
346
|
}
|
|
230
347
|
}
|
|
348
|
+
|
|
349
|
+
function escapeDoubleQuotes(value: string): string {
|
|
350
|
+
return value.replace(/"/g, '""');
|
|
351
|
+
}
|
|
352
|
+
|
package/src/inspector/config.ts
CHANGED
package/src/inspector/handler.ts
CHANGED
|
@@ -3,11 +3,13 @@ import type { Unsubscribe } from "nanoevents";
|
|
|
3
3
|
import type { UpgradeWebSocketArgs } from "@/actor/router-websocket-endpoints";
|
|
4
4
|
import type { AnyActorInstance, RivetMessageEvent } from "@/mod";
|
|
5
5
|
import type { ToClient } from "@/schemas/actor-inspector/mod";
|
|
6
|
+
import { encodeReadRangeWire } from "@rivetkit/traces/encoding";
|
|
6
7
|
import {
|
|
8
|
+
CURRENT_VERSION as INSPECTOR_CURRENT_VERSION,
|
|
7
9
|
TO_CLIENT_VERSIONED as toClient,
|
|
8
10
|
TO_SERVER_VERSIONED as toServer,
|
|
9
11
|
} from "@/schemas/actor-inspector/versioned";
|
|
10
|
-
import { assertUnreachable } from "@/utils";
|
|
12
|
+
import { assertUnreachable, bufferToArrayBuffer } from "@/utils";
|
|
11
13
|
import { inspectorLogger } from "./log";
|
|
12
14
|
|
|
13
15
|
export async function handleWebSocketInspectorConnect({
|
|
@@ -16,6 +18,7 @@ export async function handleWebSocketInspectorConnect({
|
|
|
16
18
|
actor: AnyActorInstance;
|
|
17
19
|
}): Promise<UpgradeWebSocketArgs> {
|
|
18
20
|
const inspector = actor.inspector;
|
|
21
|
+
const maxQueueStatusLimit = 200;
|
|
19
22
|
|
|
20
23
|
const listeners: Unsubscribe[] = [];
|
|
21
24
|
return {
|
|
@@ -26,13 +29,15 @@ export async function handleWebSocketInspectorConnect({
|
|
|
26
29
|
tag: "Init",
|
|
27
30
|
val: {
|
|
28
31
|
connections: inspector.getConnections(),
|
|
29
|
-
events: inspector.getLastEvents(),
|
|
30
32
|
rpcs: inspector.getRpcs(),
|
|
31
33
|
state: inspector.isStateEnabled()
|
|
32
34
|
? inspector.getState()
|
|
33
35
|
: null,
|
|
34
36
|
isStateEnabled: inspector.isStateEnabled(),
|
|
35
37
|
isDatabaseEnabled: inspector.isDatabaseEnabled(),
|
|
38
|
+
queueSize: BigInt(inspector.getQueueSize()),
|
|
39
|
+
workflowHistory: inspector.getWorkflowHistory(),
|
|
40
|
+
isWorkflowEnabled: inspector.isWorkflowEnabled(),
|
|
36
41
|
},
|
|
37
42
|
},
|
|
38
43
|
});
|
|
@@ -54,19 +59,21 @@ export async function handleWebSocketInspectorConnect({
|
|
|
54
59
|
},
|
|
55
60
|
});
|
|
56
61
|
}),
|
|
57
|
-
inspector.emitter.on("
|
|
62
|
+
inspector.emitter.on("queueUpdated", () => {
|
|
58
63
|
sendMessage(ws, {
|
|
59
64
|
body: {
|
|
60
|
-
tag: "
|
|
61
|
-
val: {
|
|
65
|
+
tag: "QueueUpdated",
|
|
66
|
+
val: {
|
|
67
|
+
queueSize: BigInt(inspector.getQueueSize()),
|
|
68
|
+
},
|
|
62
69
|
},
|
|
63
70
|
});
|
|
64
71
|
}),
|
|
65
|
-
inspector.emitter.on("
|
|
72
|
+
inspector.emitter.on("workflowHistoryUpdated", (history) => {
|
|
66
73
|
sendMessage(ws, {
|
|
67
74
|
body: {
|
|
68
|
-
tag: "
|
|
69
|
-
val: {
|
|
75
|
+
tag: "WorkflowHistoryUpdated",
|
|
76
|
+
val: { history },
|
|
70
77
|
},
|
|
71
78
|
});
|
|
72
79
|
}),
|
|
@@ -115,37 +122,112 @@ export async function handleWebSocketInspectorConnect({
|
|
|
115
122
|
},
|
|
116
123
|
},
|
|
117
124
|
});
|
|
118
|
-
} else if (message.body.tag === "
|
|
125
|
+
} else if (message.body.tag === "RpcsListRequest") {
|
|
119
126
|
sendMessage(ws, {
|
|
120
127
|
body: {
|
|
121
|
-
tag: "
|
|
128
|
+
tag: "RpcsListResponse",
|
|
122
129
|
val: {
|
|
123
130
|
rid: message.body.val.id,
|
|
124
|
-
|
|
131
|
+
rpcs: inspector.getRpcs(),
|
|
125
132
|
},
|
|
126
133
|
},
|
|
127
134
|
});
|
|
128
|
-
} else if (message.body.tag === "
|
|
129
|
-
|
|
135
|
+
} else if (message.body.tag === "TraceQueryRequest") {
|
|
136
|
+
const { id, startMs, endMs, limit } = message.body.val;
|
|
137
|
+
const wire = await actor.traces.readRangeWire({
|
|
138
|
+
startMs: Number(startMs),
|
|
139
|
+
endMs: Number(endMs),
|
|
140
|
+
limit: Number(limit),
|
|
141
|
+
});
|
|
130
142
|
sendMessage(ws, {
|
|
131
143
|
body: {
|
|
132
|
-
tag: "
|
|
144
|
+
tag: "TraceQueryResponse",
|
|
133
145
|
val: {
|
|
134
|
-
rid:
|
|
135
|
-
|
|
146
|
+
rid: id,
|
|
147
|
+
payload: bufferToArrayBuffer(
|
|
148
|
+
encodeReadRangeWire(wire),
|
|
149
|
+
),
|
|
136
150
|
},
|
|
137
151
|
},
|
|
138
152
|
});
|
|
139
|
-
} else if (message.body.tag === "
|
|
153
|
+
} else if (message.body.tag === "QueueRequest") {
|
|
154
|
+
const { id, limit } = message.body.val;
|
|
155
|
+
const status = await inspector.getQueueStatus(
|
|
156
|
+
Math.min(Number(limit), maxQueueStatusLimit),
|
|
157
|
+
);
|
|
140
158
|
sendMessage(ws, {
|
|
141
159
|
body: {
|
|
142
|
-
tag: "
|
|
160
|
+
tag: "QueueResponse",
|
|
161
|
+
val: {
|
|
162
|
+
rid: id,
|
|
163
|
+
status,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
} else if (message.body.tag === "WorkflowHistoryRequest") {
|
|
168
|
+
sendMessage(ws, {
|
|
169
|
+
body: {
|
|
170
|
+
tag: "WorkflowHistoryResponse",
|
|
143
171
|
val: {
|
|
144
172
|
rid: message.body.val.id,
|
|
145
|
-
|
|
173
|
+
history: inspector.getWorkflowHistory(),
|
|
174
|
+
isWorkflowEnabled:
|
|
175
|
+
inspector.isWorkflowEnabled(),
|
|
146
176
|
},
|
|
147
177
|
},
|
|
148
178
|
});
|
|
179
|
+
} else if (message.body.tag === "DatabaseSchemaRequest") {
|
|
180
|
+
const { id } = message.body.val;
|
|
181
|
+
try {
|
|
182
|
+
const schema = await inspector.getDatabaseSchema();
|
|
183
|
+
sendMessage(ws, {
|
|
184
|
+
body: {
|
|
185
|
+
tag: "DatabaseSchemaResponse",
|
|
186
|
+
val: { rid: id, schema },
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
} catch (error) {
|
|
190
|
+
inspectorLogger().warn(
|
|
191
|
+
{ error },
|
|
192
|
+
"Failed to get database schema",
|
|
193
|
+
);
|
|
194
|
+
sendMessage(ws, {
|
|
195
|
+
body: {
|
|
196
|
+
tag: "Error",
|
|
197
|
+
val: {
|
|
198
|
+
message: `Failed to get database schema: ${error instanceof Error ? error.message : String(error)}`,
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
} else if (message.body.tag === "DatabaseTableRowsRequest") {
|
|
204
|
+
const { id, table, limit, offset } = message.body.val;
|
|
205
|
+
try {
|
|
206
|
+
const result = await inspector.getDatabaseTableRows(
|
|
207
|
+
table,
|
|
208
|
+
Number(limit),
|
|
209
|
+
Number(offset),
|
|
210
|
+
);
|
|
211
|
+
sendMessage(ws, {
|
|
212
|
+
body: {
|
|
213
|
+
tag: "DatabaseTableRowsResponse",
|
|
214
|
+
val: { rid: id, result },
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
} catch (error) {
|
|
218
|
+
inspectorLogger().warn(
|
|
219
|
+
{ error },
|
|
220
|
+
"Failed to get database table rows",
|
|
221
|
+
);
|
|
222
|
+
sendMessage(ws, {
|
|
223
|
+
body: {
|
|
224
|
+
tag: "Error",
|
|
225
|
+
val: {
|
|
226
|
+
message: `Failed to get database rows: ${error instanceof Error ? error.message : String(error)}`,
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
}
|
|
149
231
|
} else {
|
|
150
232
|
assertUnreachable(message.body);
|
|
151
233
|
}
|
|
@@ -181,7 +263,7 @@ function sendMessage(ws: WSContext, message: ToClient) {
|
|
|
181
263
|
ws.send(
|
|
182
264
|
toClient.serializeWithEmbeddedVersion(
|
|
183
265
|
message,
|
|
184
|
-
|
|
266
|
+
INSPECTOR_CURRENT_VERSION,
|
|
185
267
|
) as unknown as ArrayBuffer,
|
|
186
268
|
);
|
|
187
269
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Browser-safe inspector exports (schemas and types only, no server runtime)
|
|
2
|
+
export * from "../schemas/actor-inspector/mod";
|
|
3
|
+
export * from "../schemas/actor-inspector/versioned";
|
|
4
|
+
export type { WorkflowHistory as TransportWorkflowHistory } from "../schemas/transport/mod";
|
|
5
|
+
export {
|
|
6
|
+
decodeWorkflowHistoryTransport,
|
|
7
|
+
encodeWorkflowHistoryTransport,
|
|
8
|
+
} from "./transport";
|
package/src/inspector/mod.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export * from "../schemas/actor-inspector/mod";
|
|
2
2
|
export * from "../schemas/actor-inspector/versioned";
|
|
3
|
+
export { decodeWorkflowHistoryTransport, encodeWorkflowHistoryTransport } from "./transport";
|
|
4
|
+
export type { WorkflowHistory as TransportWorkflowHistory } from "../schemas/transport/mod";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
|
|
2
|
+
import { extract } from "tar";
|
|
3
|
+
import { getNodeFs, getNodeOs, getNodePath, getNodeUrl } from "@/utils/node";
|
|
4
|
+
|
|
5
|
+
let extractedDir: string | undefined;
|
|
6
|
+
let extractionPromise: Promise<string> | undefined;
|
|
7
|
+
|
|
8
|
+
export async function getInspectorDir(): Promise<string> {
|
|
9
|
+
if (extractedDir !== undefined) return extractedDir;
|
|
10
|
+
if (extractionPromise !== undefined) return extractionPromise;
|
|
11
|
+
|
|
12
|
+
const nodeFs = getNodeFs();
|
|
13
|
+
const os = getNodeOs();
|
|
14
|
+
const url = getNodeUrl();
|
|
15
|
+
const path = getNodePath();
|
|
16
|
+
|
|
17
|
+
extractionPromise = (async () => {
|
|
18
|
+
const tarball = path.join(
|
|
19
|
+
path.dirname(url.fileURLToPath(import.meta.url)),
|
|
20
|
+
"../../dist/inspector.tar.gz",
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
await nodeFs.access(tarball);
|
|
25
|
+
} catch {
|
|
26
|
+
throw new Error(
|
|
27
|
+
`Inspector tarball not found at ${tarball}. Run 'pnpm build:pack-inspector' first.`,
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const dest = path.join(os.tmpdir(), "rivetkit-inspector");
|
|
32
|
+
await nodeFs.mkdir(dest, { recursive: true });
|
|
33
|
+
await extract({ file: tarball, cwd: dest });
|
|
34
|
+
|
|
35
|
+
extractedDir = dest;
|
|
36
|
+
return dest;
|
|
37
|
+
})();
|
|
38
|
+
|
|
39
|
+
return extractionPromise;
|
|
40
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { WorkflowHistory } from "@/schemas/transport/mod";
|
|
2
|
+
import {
|
|
3
|
+
decodeWorkflowHistory,
|
|
4
|
+
encodeWorkflowHistory,
|
|
5
|
+
} from "@/schemas/transport/mod";
|
|
6
|
+
import { bufferToArrayBuffer, toUint8Array } from "@/utils";
|
|
7
|
+
|
|
8
|
+
export function encodeWorkflowHistoryTransport(
|
|
9
|
+
history: WorkflowHistory,
|
|
10
|
+
): ArrayBuffer {
|
|
11
|
+
return bufferToArrayBuffer(encodeWorkflowHistory(history));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function decodeWorkflowHistoryTransport(
|
|
15
|
+
data: ArrayBuffer | ArrayBufferView,
|
|
16
|
+
): WorkflowHistory {
|
|
17
|
+
return decodeWorkflowHistory(toUint8Array(data));
|
|
18
|
+
}
|