rivetkit 0.0.0-sqlite-profiling-compat.4a9a623 → 0.0.0-sqlite-sync-3-0-0-release.14341d0
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 +1317 -765
- package/dist/browser/client.js +1433 -692
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.d.ts +252 -129
- package/dist/browser/inspector/client.js +2042 -228
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +6 -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 +5 -1
- package/dist/tsup/agent-os/index.cjs +3 -2367
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +1 -2277
- package/dist/tsup/agent-os/index.d.ts +1 -2277
- package/dist/tsup/agent-os/index.js +3 -2367
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-AGDY6TKH.js → chunk-2EQ2WCO7.js} +1054 -364
- package/dist/tsup/chunk-2EQ2WCO7.js.map +1 -0
- package/dist/tsup/{chunk-7QKCGUTJ.cjs → chunk-4H2LT2WB.cjs} +444 -29
- package/dist/tsup/chunk-4H2LT2WB.cjs.map +1 -0
- package/dist/tsup/{chunk-XIX5DOZN.js → chunk-6FEYCVZC.js} +196 -20
- package/dist/tsup/chunk-6FEYCVZC.js.map +1 -0
- package/dist/tsup/{chunk-QAVN4QNO.cjs → chunk-6WYQ3NJI.cjs} +7 -7
- package/dist/tsup/chunk-6WYQ3NJI.cjs.map +1 -0
- package/dist/tsup/{chunk-75UE45DE.js → chunk-6ZJX3KXW.js} +436 -21
- package/dist/tsup/chunk-6ZJX3KXW.js.map +1 -0
- package/dist/tsup/{chunk-HXUEHHJF.js → chunk-A2CF6PFH.js} +19 -11
- package/dist/tsup/chunk-A2CF6PFH.js.map +1 -0
- package/dist/tsup/{chunk-RIT7N3TX.js → chunk-AIGW2SKA.js} +50 -3
- package/dist/tsup/chunk-AIGW2SKA.js.map +1 -0
- package/dist/tsup/{chunk-3MHDOUD7.cjs → chunk-HDVZ6YZG.cjs} +197 -21
- package/dist/tsup/chunk-HDVZ6YZG.cjs.map +1 -0
- package/dist/tsup/{chunk-2CICCOBL.cjs → chunk-HU4F7H3F.cjs} +52 -5
- package/dist/tsup/chunk-HU4F7H3F.cjs.map +1 -0
- package/dist/tsup/{chunk-4PX3ZKJR.js → chunk-JNJEWQZL.js} +3 -3
- package/dist/tsup/chunk-JNJEWQZL.js.map +1 -0
- package/dist/tsup/{chunk-JZ7TWV65.js → chunk-JTHHCZCZ.js} +24 -1
- package/dist/tsup/chunk-JTHHCZCZ.js.map +1 -0
- package/dist/tsup/{chunk-ZA7FLHKH.cjs → chunk-KVFIONKQ.cjs} +25 -2
- package/dist/tsup/chunk-KVFIONKQ.cjs.map +1 -0
- package/dist/tsup/{chunk-4FC7TVS6.cjs → chunk-MGI2VVF6.cjs} +39 -7
- package/dist/tsup/chunk-MGI2VVF6.cjs.map +1 -0
- package/dist/tsup/{chunk-NHUTYWKU.cjs → chunk-NE5CUQRN.cjs} +1173 -483
- package/dist/tsup/chunk-NE5CUQRN.cjs.map +1 -0
- package/dist/tsup/{chunk-IICIOTML.js → chunk-OX5MX7TO.js} +2 -2
- package/dist/tsup/{chunk-ND567FR5.cjs → chunk-PSIBTOAR.cjs} +3 -3
- package/dist/tsup/chunk-PSIBTOAR.cjs.map +1 -0
- package/dist/tsup/chunk-PW6FYEIV.cjs +14 -0
- package/dist/tsup/chunk-PW6FYEIV.cjs.map +1 -0
- package/dist/tsup/{chunk-VE2X4KMG.cjs → chunk-RTWH3AX3.cjs} +18 -10
- package/dist/tsup/chunk-RTWH3AX3.cjs.map +1 -0
- package/dist/tsup/chunk-SLICBKAU.js +14 -0
- package/dist/tsup/chunk-SLICBKAU.js.map +1 -0
- package/dist/tsup/{chunk-XFYEVYHG.js → chunk-WCVYMFWJ.js} +16 -9
- package/dist/tsup/chunk-WCVYMFWJ.js.map +1 -0
- package/dist/tsup/chunk-WX3JS4XU.cjs +243 -0
- package/dist/tsup/chunk-WX3JS4XU.cjs.map +1 -0
- package/dist/tsup/chunk-X32L7FDD.js +243 -0
- package/dist/tsup/chunk-X32L7FDD.js.map +1 -0
- package/dist/tsup/{chunk-2WMYYG4R.cjs → chunk-XAY2HIZN.cjs} +18 -11
- package/dist/tsup/chunk-XAY2HIZN.cjs.map +1 -0
- package/dist/tsup/{chunk-ZZ3WBRPD.js → chunk-ZOVJDAOW.js} +38 -6
- 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 +32 -6
- package/dist/tsup/client/mod.d.ts +32 -6
- 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.cjs.map +1 -1
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-BR1Nn0QQ.d.ts → config-B4erdavw.d.ts} +571 -65
- package/dist/tsup/{config-B0LNDrLY.d.ts → config-BfG1qpYz.d.cts} +80 -14
- package/dist/tsup/{config-B0LNDrLY.d.cts → config-BfG1qpYz.d.ts} +80 -14
- package/dist/tsup/{config-tCvkwzyN.d.cts → config-DK144OAw.d.cts} +571 -65
- package/dist/tsup/{context-oc9zhA3x.d.ts → context-Cvnf3BRe.d.cts} +3 -2
- package/dist/tsup/{context-D4WDwf9m.d.cts → context-Oxi6YWcG.d.ts} +3 -2
- 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 -126
- package/dist/tsup/db/mod.cjs.map +1 -1
- package/dist/tsup/db/mod.d.cts +8 -4
- package/dist/tsup/db/mod.d.ts +8 -4
- package/dist/tsup/db/mod.js +5 -125
- package/dist/tsup/db/mod.js.map +1 -1
- package/dist/tsup/dynamic/mod.cjs +2 -2
- package/dist/tsup/dynamic/mod.cjs.map +1 -1
- package/dist/tsup/dynamic/mod.d.cts +6 -4
- package/dist/tsup/dynamic/mod.d.ts +6 -4
- package/dist/tsup/dynamic/mod.js +1 -1
- 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 +2 -13
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -1
- package/dist/tsup/inspector-tab/mod.d.cts +9 -17
- package/dist/tsup/inspector-tab/mod.d.ts +9 -17
- package/dist/tsup/inspector-tab/mod.js +1 -12
- package/dist/tsup/inspector-tab/mod.js.map +1 -1
- package/dist/tsup/mod.cjs +2728 -611
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +9 -7
- package/dist/tsup/mod.d.ts +9 -7
- package/dist/tsup/mod.js +2645 -528
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +19 -17
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +6 -4
- package/dist/tsup/test/mod.d.ts +6 -4
- package/dist/tsup/test/mod.js +18 -16
- 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-CqDnC_PS.d.cts → utils-3rsE0JvI.d.cts} +25 -2
- package/dist/tsup/{utils-CqDnC_PS.d.ts → utils-3rsE0JvI.d.ts} +25 -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 +260 -200
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +8 -6
- package/dist/tsup/workflow/mod.d.ts +8 -6
- package/dist/tsup/workflow/mod.js +249 -189
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +34 -14
- package/src/actor/actions.ts +155 -0
- package/src/actor/config.ts +403 -43
- package/src/actor/definition.ts +26 -7
- package/src/actor/errors.ts +87 -5
- package/src/actor/keys.ts +86 -0
- package/src/actor/mod.ts +15 -1
- package/src/actor/tracing.ts +28 -0
- package/src/agent-os/index.ts +5 -65
- package/src/client/actor-common.ts +8 -15
- package/src/client/actor-conn.ts +178 -25
- package/src/client/actor-handle.ts +180 -42
- package/src/client/actor-query.ts +8 -1
- package/src/client/auth.ts +37 -0
- package/src/client/client.ts +89 -21
- package/src/client/config.ts +27 -2
- package/src/client/errors.ts +2 -1
- package/src/client/lifecycle-errors.ts +29 -1
- package/src/client/mod.ts +9 -0
- package/src/client/outbound-telemetry.ts +66 -0
- package/src/client/query.ts +2 -0
- package/src/client/queue.ts +3 -0
- package/src/client/raw-utils.ts +37 -8
- package/src/client/resolve-gateway-target.ts +2 -0
- package/src/client/retry-budget.ts +78 -0
- package/src/client/token-provider.ts +93 -0
- package/src/client/utils.ts +16 -2
- package/src/common/actor-router-consts.ts +5 -0
- package/src/common/actor-telemetry-context.ts +19 -0
- package/src/common/bare/generated/actor-runtime-socket-protocol/v1.ts +848 -0
- 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 +36 -0
- package/src/common/database/config.ts +108 -15
- package/src/common/database/mod.ts +247 -76
- package/src/common/database/native-database.ts +433 -23
- package/src/common/database/shared.ts +24 -0
- package/src/common/encoding.ts +31 -21
- package/src/common/fetch-like.ts +63 -0
- package/src/common/inspector-transport.ts +12 -2
- package/src/common/log.ts +14 -8
- package/src/common/otel-context.ts +99 -0
- package/src/common/router.ts +1 -1
- package/src/common/utils.ts +7 -19
- package/src/db/drizzle.ts +182 -80
- package/src/db/mod.ts +2 -0
- package/src/dynamic/isolate-runtime.ts +0 -2
- package/src/engine-api/actors.ts +3 -3
- package/src/engine-client/actor-http-client.ts +29 -20
- package/src/engine-client/actor-websocket-client.ts +6 -3
- package/src/engine-client/api-endpoints.ts +72 -14
- package/src/engine-client/driver.ts +8 -15
- package/src/engine-client/mod.ts +248 -112
- package/src/inspector/client.browser.ts +134 -16
- package/src/inspector/mod.ts +1 -1
- package/src/inspector/workflow.ts +61 -0
- package/src/inspector-tab/mod.ts +1 -15
- package/src/registry/config/envoy.ts +2 -18
- package/src/registry/config/index.ts +54 -61
- package/src/registry/index.ts +324 -21
- package/src/registry/napi-runtime.ts +583 -39
- package/src/registry/native-http.ts +225 -0
- package/src/registry/native.ts +1365 -414
- package/src/registry/run-handler-coordinator.ts +219 -0
- package/src/registry/runtime.ts +372 -7
- package/src/registry/wasm-runtime.ts +490 -21
- package/src/registry/write-through-proxy.ts +101 -0
- package/src/test/mod.ts +1 -19
- package/src/test/ready.ts +22 -0
- package/src/unstable/migrations.ts +141 -0
- package/src/utils/env-vars.ts +15 -6
- package/src/utils/node.ts +44 -28
- package/src/utils.ts +3 -0
- package/src/workflow/context.ts +9 -27
- package/src/workflow/driver.ts +253 -116
- package/src/workflow/inspector.ts +23 -24
- package/src/workflow/mod.ts +50 -72
- package/dist/tsup/chunk-2CICCOBL.cjs.map +0 -1
- package/dist/tsup/chunk-2WMYYG4R.cjs.map +0 -1
- package/dist/tsup/chunk-3MHDOUD7.cjs.map +0 -1
- package/dist/tsup/chunk-4FC7TVS6.cjs.map +0 -1
- package/dist/tsup/chunk-4PX3ZKJR.js.map +0 -1
- package/dist/tsup/chunk-75UE45DE.js.map +0 -1
- package/dist/tsup/chunk-7QKCGUTJ.cjs.map +0 -1
- package/dist/tsup/chunk-AGDY6TKH.js.map +0 -1
- package/dist/tsup/chunk-HXUEHHJF.js.map +0 -1
- package/dist/tsup/chunk-JZ7TWV65.js.map +0 -1
- package/dist/tsup/chunk-ND567FR5.cjs.map +0 -1
- package/dist/tsup/chunk-NHUTYWKU.cjs.map +0 -1
- package/dist/tsup/chunk-QAVN4QNO.cjs.map +0 -1
- package/dist/tsup/chunk-RIT7N3TX.js.map +0 -1
- package/dist/tsup/chunk-RV5MAFDT.cjs +0 -382
- package/dist/tsup/chunk-RV5MAFDT.cjs.map +0 -1
- package/dist/tsup/chunk-VE2X4KMG.cjs.map +0 -1
- package/dist/tsup/chunk-XFYEVYHG.js.map +0 -1
- package/dist/tsup/chunk-XHGDS3DZ.js +0 -382
- package/dist/tsup/chunk-XHGDS3DZ.js.map +0 -1
- package/dist/tsup/chunk-XIX5DOZN.js.map +0 -1
- package/dist/tsup/chunk-ZA7FLHKH.cjs.map +0 -1
- package/dist/tsup/chunk-ZZ3WBRPD.js.map +0 -1
- package/src/actor/driver.ts +0 -141
- package/src/actor/instance/mod.ts +0 -2484
- 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 -285
- package/src/agent-os/actor/network.ts +0 -58
- package/src/agent-os/actor/preview.ts +0 -190
- 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 -2473
- package/src/registry/process-metrics.ts +0 -250
- package/src/registry/runtime.test.ts +0 -50
- package/src/utils/endpoint-parser.test.ts +0 -206
- package/src/utils.test.ts +0 -34
- /package/dist/tsup/{chunk-IICIOTML.js.map → chunk-OX5MX7TO.js.map} +0 -0
package/src/agent-os/types.ts
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AgentCapabilities,
|
|
3
|
-
AgentInfo,
|
|
4
|
-
AgentOs,
|
|
5
|
-
CronEvent,
|
|
6
|
-
JsonRpcNotification,
|
|
7
|
-
JsonRpcResponse,
|
|
8
|
-
PermissionRequest,
|
|
9
|
-
} from "@rivet-dev/agent-os-core";
|
|
10
|
-
import type { ActionContext } from "@/actor/config";
|
|
11
|
-
|
|
12
|
-
// --- Actor state (persisted across sleep/wake) ---
|
|
13
|
-
|
|
14
|
-
// biome-ignore lint/complexity/noBannedTypes: empty state placeholder, consumers extend via generics
|
|
15
|
-
export type AgentOsActorState = {};
|
|
16
|
-
|
|
17
|
-
// --- Actor vars (ephemeral, recreated on wake) ---
|
|
18
|
-
|
|
19
|
-
export interface AgentOsActorVars {
|
|
20
|
-
agentOs: AgentOs | null;
|
|
21
|
-
activeSessionIds: Set<string>;
|
|
22
|
-
activeProcesses: Set<number>;
|
|
23
|
-
activeHooks: Set<Promise<void>>;
|
|
24
|
-
activeShells: Set<string>;
|
|
25
|
-
sessions: Set<string>;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// --- Event payloads ---
|
|
29
|
-
|
|
30
|
-
export interface SessionEventPayload {
|
|
31
|
-
sessionId: string;
|
|
32
|
-
event: JsonRpcNotification;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface PermissionRequestPayload {
|
|
36
|
-
sessionId: string;
|
|
37
|
-
request: PermissionRequest;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export type VmBootedPayload = Record<string, never>;
|
|
41
|
-
|
|
42
|
-
export interface VmShutdownPayload {
|
|
43
|
-
reason: "sleep" | "destroy" | "error";
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface ProcessOutputPayload {
|
|
47
|
-
pid: number;
|
|
48
|
-
stream: "stdout" | "stderr";
|
|
49
|
-
data: Uint8Array;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface ProcessExitPayload {
|
|
53
|
-
pid: number;
|
|
54
|
-
exitCode: number;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface ShellDataPayload {
|
|
58
|
-
shellId: string;
|
|
59
|
-
data: Uint8Array;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export interface CronEventPayload {
|
|
63
|
-
event: CronEvent;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// --- Event schema map (used by actor() events config) ---
|
|
67
|
-
|
|
68
|
-
export interface AgentOsEvents {
|
|
69
|
-
sessionEvent: SessionEventPayload;
|
|
70
|
-
permissionRequest: PermissionRequestPayload;
|
|
71
|
-
vmBooted: VmBootedPayload;
|
|
72
|
-
vmShutdown: VmShutdownPayload;
|
|
73
|
-
processOutput: ProcessOutputPayload;
|
|
74
|
-
processExit: ProcessExitPayload;
|
|
75
|
-
shellData: ShellDataPayload;
|
|
76
|
-
cronEvent: CronEventPayload;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// --- Prompt result ---
|
|
80
|
-
|
|
81
|
-
/** Result from sendPrompt. */
|
|
82
|
-
export interface PromptResult {
|
|
83
|
-
/** Raw JSON-RPC response from the ACP adapter. */
|
|
84
|
-
response: JsonRpcResponse;
|
|
85
|
-
/** Accumulated agent text output from streamed message chunks. */
|
|
86
|
-
text: string;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// --- Session serialization ---
|
|
90
|
-
|
|
91
|
-
export interface SessionRecord {
|
|
92
|
-
sessionId: string;
|
|
93
|
-
agentType: string;
|
|
94
|
-
capabilities: AgentCapabilities;
|
|
95
|
-
agentInfo: AgentInfo | null;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// --- Persisted session types ---
|
|
99
|
-
|
|
100
|
-
export interface PersistedSessionRecord {
|
|
101
|
-
sessionId: string;
|
|
102
|
-
agentType: string;
|
|
103
|
-
capabilities: AgentCapabilities;
|
|
104
|
-
agentInfo: AgentInfo | null;
|
|
105
|
-
createdAt: number;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export interface PersistedSessionEvent {
|
|
109
|
-
sessionId: string;
|
|
110
|
-
seq: number;
|
|
111
|
-
event: JsonRpcNotification;
|
|
112
|
-
createdAt: number;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// --- Serializable cron action (excludes callback type) ---
|
|
116
|
-
|
|
117
|
-
export type SerializableCronAction =
|
|
118
|
-
| { type: "session"; agentType: string; prompt: string; cwd?: string }
|
|
119
|
-
| { type: "exec"; command: string; args?: string[] };
|
|
120
|
-
|
|
121
|
-
export interface SerializableCronJobOptions {
|
|
122
|
-
id?: string;
|
|
123
|
-
schedule: string;
|
|
124
|
-
action: SerializableCronAction;
|
|
125
|
-
overlap?: "allow" | "skip" | "queue";
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export interface SerializableCronJobInfo {
|
|
129
|
-
id: string;
|
|
130
|
-
schedule: string;
|
|
131
|
-
action: SerializableCronAction;
|
|
132
|
-
overlap: "allow" | "skip" | "queue";
|
|
133
|
-
lastRun?: string;
|
|
134
|
-
nextRun?: string;
|
|
135
|
-
runCount: number;
|
|
136
|
-
running: boolean;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// --- Action context alias ---
|
|
140
|
-
|
|
141
|
-
export type AgentOsActionContext<TConnParams = undefined> = ActionContext<
|
|
142
|
-
AgentOsActorState,
|
|
143
|
-
TConnParams,
|
|
144
|
-
undefined,
|
|
145
|
-
AgentOsActorVars,
|
|
146
|
-
undefined,
|
|
147
|
-
any
|
|
148
|
-
>;
|
package/src/client/test.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
//import { exec as execCallback } from "node:child_process";
|
|
2
|
-
//import { setupLogging } from "@/common//log";
|
|
3
|
-
//import type { ClientOptions } from "./client";
|
|
4
|
-
//import { InternalError } from "./errors";
|
|
5
|
-
//import { Client } from "./mod.ts";
|
|
6
|
-
//
|
|
7
|
-
///**
|
|
8
|
-
// * Uses the Rivet CLI to read the manager endpoint to connect to. This allows
|
|
9
|
-
// * for writing tests that run locally without hardcoding the manager endpoint.
|
|
10
|
-
// */
|
|
11
|
-
//export async function readEndpointFromCli(): Promise<string> {
|
|
12
|
-
// // Read endpoint
|
|
13
|
-
// const cliPath = process.env.RIVET_CLI_PATH ?? "rivet";
|
|
14
|
-
//
|
|
15
|
-
// try {
|
|
16
|
-
// const { stdout, stderr } = await new Promise<{
|
|
17
|
-
// stdout: string;
|
|
18
|
-
// stderr: string;
|
|
19
|
-
// }>((resolve, reject) => {
|
|
20
|
-
// execCallback(`${cliPath} manager endpoint`, (error, stdout, stderr) => {
|
|
21
|
-
// if (error) reject(error);
|
|
22
|
-
// else resolve({ stdout, stderr });
|
|
23
|
-
// });
|
|
24
|
-
// });
|
|
25
|
-
//
|
|
26
|
-
// if (stderr) {
|
|
27
|
-
// throw new Error(stderr);
|
|
28
|
-
// }
|
|
29
|
-
//
|
|
30
|
-
// // Decode output
|
|
31
|
-
// return stdout.trim();
|
|
32
|
-
// } catch (error) {
|
|
33
|
-
// throw new InternalError(`Read endpoint failed: ${error}`);
|
|
34
|
-
// }
|
|
35
|
-
//}
|
|
36
|
-
//
|
|
37
|
-
//export class TestClient extends Client {
|
|
38
|
-
// public constructor(opts?: ClientOptions) {
|
|
39
|
-
// // Setup logging automatically
|
|
40
|
-
// setupLogging();
|
|
41
|
-
//
|
|
42
|
-
// super(readEndpointFromCli(), opts);
|
|
43
|
-
// }
|
|
44
|
-
//}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest";
|
|
2
|
-
import type {
|
|
3
|
-
DatabaseProviderContext,
|
|
4
|
-
SqliteBindings,
|
|
5
|
-
SqliteDatabase,
|
|
6
|
-
SqliteExecuteResult,
|
|
7
|
-
} from "./config";
|
|
8
|
-
import { db } from "./mod";
|
|
9
|
-
|
|
10
|
-
class FakeSqliteDatabase implements SqliteDatabase {
|
|
11
|
-
executeCalls: {
|
|
12
|
-
sql: string;
|
|
13
|
-
params?: SqliteBindings;
|
|
14
|
-
}[] = [];
|
|
15
|
-
|
|
16
|
-
async exec(): Promise<void> {}
|
|
17
|
-
|
|
18
|
-
async execute(
|
|
19
|
-
sql: string,
|
|
20
|
-
params?: SqliteBindings,
|
|
21
|
-
): Promise<SqliteExecuteResult> {
|
|
22
|
-
this.executeCalls.push({
|
|
23
|
-
sql,
|
|
24
|
-
params,
|
|
25
|
-
});
|
|
26
|
-
return {
|
|
27
|
-
columns: [],
|
|
28
|
-
rows: [],
|
|
29
|
-
changes: 0,
|
|
30
|
-
lastInsertRowId: null,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async run(sql: string, params?: SqliteBindings): Promise<void> {
|
|
35
|
-
await this.execute(sql, params);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async query(sql: string, params?: SqliteBindings) {
|
|
39
|
-
const { columns, rows } = await this.execute(sql, params);
|
|
40
|
-
return { columns, rows };
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async close(): Promise<void> {}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function testProviderContext(
|
|
47
|
-
database: SqliteDatabase,
|
|
48
|
-
): DatabaseProviderContext {
|
|
49
|
-
return {
|
|
50
|
-
actorId: "actor-a",
|
|
51
|
-
kv: {
|
|
52
|
-
batchPut: async () => {},
|
|
53
|
-
batchGet: async (keys) => keys.map(() => null),
|
|
54
|
-
batchDelete: async () => {},
|
|
55
|
-
deleteRange: async () => {},
|
|
56
|
-
},
|
|
57
|
-
nativeDatabaseProvider: {
|
|
58
|
-
open: async () => database,
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
describe("db", () => {
|
|
64
|
-
test("runs onMigrate inside a sqlite savepoint", async () => {
|
|
65
|
-
const nativeDb = new FakeSqliteDatabase();
|
|
66
|
-
const provider = db({
|
|
67
|
-
onMigrate: async (client) => {
|
|
68
|
-
await client.execute(
|
|
69
|
-
"CREATE TABLE items(id INTEGER PRIMARY KEY, value TEXT)",
|
|
70
|
-
);
|
|
71
|
-
await client.execute("SELECT COUNT(*) AS count FROM items");
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
const client = await provider.createClient(
|
|
75
|
-
testProviderContext(nativeDb),
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
await provider.onMigrate(client);
|
|
79
|
-
|
|
80
|
-
expect(nativeDb.executeCalls).toEqual([
|
|
81
|
-
{
|
|
82
|
-
sql: "SAVEPOINT __rivet_on_migrate",
|
|
83
|
-
params: undefined,
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
sql: "CREATE TABLE items(id INTEGER PRIMARY KEY, value TEXT)",
|
|
87
|
-
params: undefined,
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
sql: "SELECT COUNT(*) AS count FROM items",
|
|
91
|
-
params: undefined,
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
sql: "RELEASE SAVEPOINT __rivet_on_migrate",
|
|
95
|
-
params: undefined,
|
|
96
|
-
},
|
|
97
|
-
]);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
test("rolls back the migration savepoint when onMigrate fails", async () => {
|
|
101
|
-
const nativeDb = new FakeSqliteDatabase();
|
|
102
|
-
const provider = db({
|
|
103
|
-
onMigrate: async (client) => {
|
|
104
|
-
await client.execute(
|
|
105
|
-
"CREATE TABLE items(id INTEGER PRIMARY KEY, value TEXT)",
|
|
106
|
-
);
|
|
107
|
-
throw new Error("migration failed");
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
const client = await provider.createClient(
|
|
111
|
-
testProviderContext(nativeDb),
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
await expect(provider.onMigrate(client)).rejects.toThrow(
|
|
115
|
-
"migration failed",
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
expect(nativeDb.executeCalls).toEqual([
|
|
119
|
-
{
|
|
120
|
-
sql: "SAVEPOINT __rivet_on_migrate",
|
|
121
|
-
params: undefined,
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
sql: "CREATE TABLE items(id INTEGER PRIMARY KEY, value TEXT)",
|
|
125
|
-
params: undefined,
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
sql: "ROLLBACK TO SAVEPOINT __rivet_on_migrate",
|
|
129
|
-
params: undefined,
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
sql: "RELEASE SAVEPOINT __rivet_on_migrate",
|
|
133
|
-
params: undefined,
|
|
134
|
-
},
|
|
135
|
-
]);
|
|
136
|
-
});
|
|
137
|
-
});
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest";
|
|
2
|
-
import { BRIDGE_RIVET_ERROR_PREFIX } from "@/actor/errors";
|
|
3
|
-
import {
|
|
4
|
-
type JsNativeDatabaseLike,
|
|
5
|
-
wrapJsNativeDatabase,
|
|
6
|
-
} from "./native-database";
|
|
7
|
-
|
|
8
|
-
type NativeParams = Parameters<JsNativeDatabaseLike["execute"]>[1];
|
|
9
|
-
type NativeExecuteResult = Awaited<ReturnType<JsNativeDatabaseLike["execute"]>>;
|
|
10
|
-
|
|
11
|
-
function deferred<T>() {
|
|
12
|
-
let resolve!: (value: T) => void;
|
|
13
|
-
let reject!: (error: unknown) => void;
|
|
14
|
-
const promise = new Promise<T>((resolvePromise, rejectPromise) => {
|
|
15
|
-
resolve = resolvePromise;
|
|
16
|
-
reject = rejectPromise;
|
|
17
|
-
});
|
|
18
|
-
return { promise, resolve, reject };
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
class FakeNativeDatabase implements JsNativeDatabaseLike {
|
|
22
|
-
active = 0;
|
|
23
|
-
maxActive = 0;
|
|
24
|
-
closed = false;
|
|
25
|
-
executeCalls: { sql: string; params?: NativeParams; write: boolean }[] = [];
|
|
26
|
-
#pending: ReturnType<typeof deferred<NativeExecuteResult>>[] = [];
|
|
27
|
-
|
|
28
|
-
async exec() {
|
|
29
|
-
return { columns: [], rows: [] };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async execute(sql: string, params?: NativeParams) {
|
|
33
|
-
return await this.#startExecute(sql, params, false);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async query(sql: string, params?: NativeParams) {
|
|
37
|
-
const { columns, rows } = await this.execute(sql, params);
|
|
38
|
-
return { columns, rows };
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async run(sql: string, params?: NativeParams) {
|
|
42
|
-
const { changes } = await this.execute(sql, params);
|
|
43
|
-
return { changes };
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
takeLastKvError() {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async close() {
|
|
51
|
-
this.closed = true;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
resolveNext(result: Partial<NativeExecuteResult> = {}) {
|
|
55
|
-
const pending = this.#pending.shift();
|
|
56
|
-
if (!pending) {
|
|
57
|
-
throw new Error("no pending native execute call");
|
|
58
|
-
}
|
|
59
|
-
pending.resolve({
|
|
60
|
-
columns: [],
|
|
61
|
-
rows: [],
|
|
62
|
-
changes: 0,
|
|
63
|
-
lastInsertRowId: null,
|
|
64
|
-
...result,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
rejectNext(error: unknown) {
|
|
69
|
-
const pending = this.#pending.shift();
|
|
70
|
-
if (!pending) {
|
|
71
|
-
throw new Error("no pending native execute call");
|
|
72
|
-
}
|
|
73
|
-
pending.reject(error);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async #startExecute(
|
|
77
|
-
sql: string,
|
|
78
|
-
params: NativeParams,
|
|
79
|
-
write: boolean,
|
|
80
|
-
): Promise<NativeExecuteResult> {
|
|
81
|
-
this.executeCalls.push({ sql, params, write });
|
|
82
|
-
this.active++;
|
|
83
|
-
this.maxActive = Math.max(this.maxActive, this.active);
|
|
84
|
-
const pending = deferred<NativeExecuteResult>();
|
|
85
|
-
this.#pending.push(pending);
|
|
86
|
-
try {
|
|
87
|
-
return await pending.promise;
|
|
88
|
-
} finally {
|
|
89
|
-
this.active--;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
describe("wrapJsNativeDatabase", () => {
|
|
95
|
-
test("admits Promise.all read queries concurrently", async () => {
|
|
96
|
-
const native = new FakeNativeDatabase();
|
|
97
|
-
const db = wrapJsNativeDatabase(native);
|
|
98
|
-
|
|
99
|
-
const first = db.query("SELECT 1");
|
|
100
|
-
const second = db.query("SELECT 2");
|
|
101
|
-
|
|
102
|
-
expect(native.maxActive).toBe(2);
|
|
103
|
-
native.resolveNext({ columns: ["value"], rows: [[1]] });
|
|
104
|
-
native.resolveNext({ columns: ["value"], rows: [[2]] });
|
|
105
|
-
|
|
106
|
-
await expect(first).resolves.toEqual({
|
|
107
|
-
columns: ["value"],
|
|
108
|
-
rows: [[1]],
|
|
109
|
-
});
|
|
110
|
-
await expect(second).resolves.toEqual({
|
|
111
|
-
columns: ["value"],
|
|
112
|
-
rows: [[2]],
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
test("normalizes supported sqlite bind values", async () => {
|
|
117
|
-
const native = new FakeNativeDatabase();
|
|
118
|
-
const db = wrapJsNativeDatabase(native);
|
|
119
|
-
const blob = new Uint8Array([1, 2, 3]);
|
|
120
|
-
|
|
121
|
-
const query = db.query("SELECT ?, ?, ?, ?, ?, ?, ?", [
|
|
122
|
-
1n,
|
|
123
|
-
true,
|
|
124
|
-
"text",
|
|
125
|
-
1.5,
|
|
126
|
-
null,
|
|
127
|
-
undefined,
|
|
128
|
-
blob,
|
|
129
|
-
]);
|
|
130
|
-
|
|
131
|
-
expect(native.executeCalls[0]?.params).toEqual([
|
|
132
|
-
{ kind: "int", intValue: 1 },
|
|
133
|
-
{ kind: "int", intValue: 1 },
|
|
134
|
-
{ kind: "text", textValue: "text" },
|
|
135
|
-
{ kind: "float", floatValue: 1.5 },
|
|
136
|
-
{ kind: "null" },
|
|
137
|
-
{ kind: "null" },
|
|
138
|
-
{ kind: "blob", blobValue: Buffer.from(blob) },
|
|
139
|
-
]);
|
|
140
|
-
|
|
141
|
-
native.resolveNext({ columns: ["value"], rows: [[1]] });
|
|
142
|
-
|
|
143
|
-
await expect(query).resolves.toEqual({
|
|
144
|
-
columns: ["value"],
|
|
145
|
-
rows: [[1]],
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
test("returns native execute metadata", async () => {
|
|
150
|
-
const native = new FakeNativeDatabase();
|
|
151
|
-
const db = wrapJsNativeDatabase(native);
|
|
152
|
-
|
|
153
|
-
const write = db.execute("INSERT INTO test VALUES (1)");
|
|
154
|
-
native.resolveNext({ changes: 1, lastInsertRowId: 7 });
|
|
155
|
-
await expect(write).resolves.toMatchObject({
|
|
156
|
-
changes: 1,
|
|
157
|
-
lastInsertRowId: 7,
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
const fallback = db.execute("SELECT last_insert_rowid()");
|
|
161
|
-
await expect(fallback).resolves.toMatchObject({
|
|
162
|
-
rows: [[7]],
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
test("close waits for admitted native calls and rejects new work", async () => {
|
|
167
|
-
const native = new FakeNativeDatabase();
|
|
168
|
-
const db = wrapJsNativeDatabase(native);
|
|
169
|
-
|
|
170
|
-
const query = db.query("SELECT 1");
|
|
171
|
-
const close = db.close();
|
|
172
|
-
await Promise.resolve();
|
|
173
|
-
|
|
174
|
-
expect(native.closed).toBe(false);
|
|
175
|
-
native.resolveNext({ columns: ["value"], rows: [[1]] });
|
|
176
|
-
|
|
177
|
-
await query;
|
|
178
|
-
await close;
|
|
179
|
-
|
|
180
|
-
expect(native.closed).toBe(true);
|
|
181
|
-
await expect(db.query("SELECT 2")).rejects.toThrow(
|
|
182
|
-
"Database is closed",
|
|
183
|
-
);
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
test("decodes sanitized native bridge errors without logging", async () => {
|
|
187
|
-
const native = new FakeNativeDatabase();
|
|
188
|
-
const db = wrapJsNativeDatabase(native);
|
|
189
|
-
const query = db.execute("SELECT broken", [1, "two"]);
|
|
190
|
-
const bridgeReason = `${BRIDGE_RIVET_ERROR_PREFIX}${JSON.stringify({
|
|
191
|
-
group: "rivetkit",
|
|
192
|
-
code: "internal_error",
|
|
193
|
-
message: "An internal error occurred",
|
|
194
|
-
statusCode: 500,
|
|
195
|
-
})}`;
|
|
196
|
-
|
|
197
|
-
native.rejectNext(new Error(bridgeReason));
|
|
198
|
-
|
|
199
|
-
await expect(query).rejects.toMatchObject({
|
|
200
|
-
name: "RivetError",
|
|
201
|
-
group: "rivetkit",
|
|
202
|
-
code: "internal_error",
|
|
203
|
-
message: "An internal error occurred",
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
await query.catch((error) => {
|
|
207
|
-
expect(error.stack).toContain("decodeBridgeRivetError");
|
|
208
|
-
expect(error.stack).toContain("enrichNativeDatabaseError");
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test, vi } from "vitest";
|
|
2
|
-
import { InlineWebSocketAdapter } from "./inline-websocket-adapter";
|
|
3
|
-
|
|
4
|
-
describe("InlineWebSocketAdapter", () => {
|
|
5
|
-
test("buffers client messages until open completes", async () => {
|
|
6
|
-
const events: string[] = [];
|
|
7
|
-
const adapter = new InlineWebSocketAdapter({
|
|
8
|
-
onOpen: () => {
|
|
9
|
-
events.push("handler.open");
|
|
10
|
-
},
|
|
11
|
-
onMessage: (event: {
|
|
12
|
-
data: string;
|
|
13
|
-
rivetMessageIndex?: number;
|
|
14
|
-
}) => {
|
|
15
|
-
events.push(
|
|
16
|
-
`handler.message:${event.data}:${event.rivetMessageIndex ?? "none"}`,
|
|
17
|
-
);
|
|
18
|
-
},
|
|
19
|
-
onClose: () => {},
|
|
20
|
-
onError: () => {},
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
adapter.clientWebSocket.addEventListener("open", () => {
|
|
24
|
-
events.push("client.open");
|
|
25
|
-
});
|
|
26
|
-
adapter.actorWebSocket.addEventListener("open", () => {
|
|
27
|
-
events.push("actor.open");
|
|
28
|
-
});
|
|
29
|
-
adapter.actorWebSocket.addEventListener(
|
|
30
|
-
"message",
|
|
31
|
-
(event: { data: string; rivetMessageIndex?: number }) => {
|
|
32
|
-
events.push(
|
|
33
|
-
`actor.message:${event.data}:${event.rivetMessageIndex ?? "none"}`,
|
|
34
|
-
);
|
|
35
|
-
},
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
adapter.dispatchClientMessageWithMetadata("hello", 7);
|
|
39
|
-
expect(events).toEqual([]);
|
|
40
|
-
|
|
41
|
-
await vi.waitFor(() => {
|
|
42
|
-
expect(events).toEqual([
|
|
43
|
-
"handler.open",
|
|
44
|
-
"client.open",
|
|
45
|
-
"actor.open",
|
|
46
|
-
"handler.message:hello:7",
|
|
47
|
-
"actor.message:hello:7",
|
|
48
|
-
]);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
});
|