rivetkit 0.0.0-sqlite-uds.37f9e48 → 0.0.0-sqlite-profiling-compat.87d61c0
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 +28 -23
- package/dist/browser/client.js +6 -9
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.d.ts +2 -22
- package/dist/browser/inspector/client.js +222 -996
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs.map +1 -1
- package/dist/tsup/agent-os/index.cjs +34 -104
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +28 -23
- package/dist/tsup/agent-os/index.d.ts +28 -23
- package/dist/tsup/agent-os/index.js +36 -106
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-2EYF7KY7.js → chunk-3GVMLSND.js} +4 -4
- package/dist/tsup/{chunk-HTREBONF.cjs → chunk-3MHDOUD7.cjs} +1 -6
- package/dist/tsup/chunk-3MHDOUD7.cjs.map +1 -0
- package/dist/tsup/chunk-4FC7TVS6.cjs.map +1 -1
- package/dist/tsup/{chunk-Q3ODMSBE.js → chunk-B3GLD4IN.js} +2 -22
- package/dist/tsup/chunk-B3GLD4IN.js.map +1 -0
- package/dist/tsup/{chunk-OSQX3QN2.cjs → chunk-BWERJMV6.cjs} +139 -139
- package/dist/tsup/chunk-BWERJMV6.cjs.map +1 -0
- package/dist/tsup/{chunk-AGWIB6VG.cjs → chunk-D363DMNH.cjs} +3 -3
- package/dist/tsup/chunk-D363DMNH.cjs.map +1 -0
- package/dist/tsup/{chunk-42H5OK5Z.cjs → chunk-DTRDGPHU.cjs} +7 -7
- package/dist/tsup/chunk-DTRDGPHU.cjs.map +1 -0
- package/dist/tsup/{chunk-MFLAOS2S.cjs → chunk-E4LNLI3W.cjs} +8 -12
- package/dist/tsup/chunk-E4LNLI3W.cjs.map +1 -0
- package/dist/tsup/{chunk-FFJXFXEW.js → chunk-EFU4JW3T.js} +7 -11
- package/dist/tsup/chunk-EFU4JW3T.js.map +1 -0
- package/dist/tsup/{chunk-UEDIZR2M.cjs → chunk-FNAXD5BQ.cjs} +4 -24
- package/dist/tsup/chunk-FNAXD5BQ.cjs.map +1 -0
- package/dist/tsup/{chunk-PVR4LVX2.cjs → chunk-GM45LG7L.cjs} +10 -18
- package/dist/tsup/chunk-GM45LG7L.cjs.map +1 -0
- package/dist/tsup/{chunk-DB45WHMU.js → chunk-O3ZUMAN7.js} +3 -3
- package/dist/tsup/{chunk-UEYBIN52.js → chunk-OAUFXOG7.js} +2 -2
- package/dist/tsup/{chunk-LIEQDMZ6.cjs → chunk-P6F5MEWX.cjs} +5 -5
- package/dist/tsup/chunk-P6F5MEWX.cjs.map +1 -0
- package/dist/tsup/{chunk-E4X3JSN7.js → chunk-PT7AC5PC.js} +4 -12
- package/dist/tsup/chunk-PT7AC5PC.js.map +1 -0
- package/dist/tsup/{chunk-D2JJWLWM.js → chunk-UV7INX3N.js} +2 -2
- package/dist/tsup/chunk-VE2X4KMG.cjs.map +1 -1
- package/dist/tsup/{chunk-ARD7UMSN.js → chunk-XIX5DOZN.js} +1 -6
- package/dist/tsup/chunk-XIX5DOZN.js.map +1 -0
- package/dist/tsup/chunk-ZA7FLHKH.cjs.map +1 -1
- package/dist/tsup/client/mod.cjs +6 -6
- package/dist/tsup/client/mod.cjs.map +1 -1
- package/dist/tsup/client/mod.d.cts +3 -3
- package/dist/tsup/client/mod.d.ts +3 -3
- package/dist/tsup/client/mod.js +5 -5
- package/dist/tsup/common/log.cjs +2 -4
- package/dist/tsup/common/log.cjs.map +1 -1
- package/dist/tsup/common/log.d.cts +1 -5
- package/dist/tsup/common/log.d.ts +1 -5
- package/dist/tsup/common/log.js +3 -5
- package/dist/tsup/common/websocket.cjs +3 -3
- package/dist/tsup/common/websocket.cjs.map +1 -1
- package/dist/tsup/common/websocket.js +2 -2
- package/dist/tsup/{config-DLOxy81E.d.cts → config-B0LNDrLY.d.cts} +25 -5
- package/dist/tsup/{config-DLOxy81E.d.ts → config-B0LNDrLY.d.ts} +25 -5
- package/dist/tsup/{config-BkLXikR2.d.ts → config-BR1Nn0QQ.d.ts} +5 -24
- package/dist/tsup/{config-BARPNFvr.d.cts → config-tCvkwzyN.d.cts} +5 -24
- package/dist/tsup/{context-DntnH005.d.ts → context-D4WDwf9m.d.cts} +2 -3
- package/dist/tsup/{context-A16ymKhK.d.cts → context-oc9zhA3x.d.ts} +2 -3
- package/dist/tsup/db/drizzle.cjs +72 -144
- package/dist/tsup/db/drizzle.cjs.map +1 -1
- package/dist/tsup/db/drizzle.d.cts +2 -4
- package/dist/tsup/db/drizzle.d.ts +2 -4
- package/dist/tsup/db/drizzle.js +72 -144
- package/dist/tsup/db/drizzle.js.map +1 -1
- package/dist/tsup/db/mod.cjs +28 -90
- 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 +28 -90
- 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 +2 -2
- package/dist/tsup/dynamic/mod.d.ts +2 -2
- package/dist/tsup/dynamic/mod.js +1 -1
- package/dist/tsup/inspector/mod.cjs +11 -46
- package/dist/tsup/inspector/mod.cjs.map +1 -1
- package/dist/tsup/inspector/mod.d.cts +15 -37
- package/dist/tsup/inspector/mod.d.ts +15 -37
- package/dist/tsup/inspector/mod.js +10 -45
- package/dist/tsup/inspector/mod.js.map +1 -1
- package/dist/tsup/inspector-tab/mod.cjs +13 -2
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -1
- package/dist/tsup/inspector-tab/mod.d.cts +14 -4
- package/dist/tsup/inspector-tab/mod.d.ts +14 -4
- package/dist/tsup/inspector-tab/mod.js +12 -1
- package/dist/tsup/inspector-tab/mod.js.map +1 -1
- package/dist/tsup/mod.cjs +90 -188
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +4 -4
- package/dist/tsup/mod.d.ts +4 -4
- package/dist/tsup/mod.js +26 -124
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +9 -9
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +2 -2
- package/dist/tsup/test/mod.d.ts +2 -2
- package/dist/tsup/test/mod.js +5 -5
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.cjs.map +1 -1
- package/dist/tsup/utils.js +1 -1
- package/dist/tsup/workflow/mod.cjs +11 -14
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +4 -4
- package/dist/tsup/workflow/mod.d.ts +4 -4
- package/dist/tsup/workflow/mod.js +5 -8
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +14 -9
- package/src/actor/config.ts +0 -10
- package/src/common/bare/transport/v1.ts +0 -36
- package/src/common/database/config.ts +24 -19
- package/src/common/database/mod.test.ts +2 -96
- package/src/common/database/mod.ts +38 -102
- package/src/common/database/native-database.ts +4 -19
- package/src/common/log.ts +8 -14
- package/src/db/drizzle.ts +86 -187
- package/src/db/mod.ts +1 -0
- package/src/inspector/client.browser.ts +16 -73
- package/src/inspector/mod.ts +1 -1
- package/src/inspector-tab/mod.ts +15 -0
- package/src/registry/index.ts +0 -4
- package/src/registry/napi-runtime.ts +1 -25
- package/src/registry/native.ts +13 -95
- package/src/registry/runtime.ts +6 -18
- package/src/registry/wasm-runtime.ts +0 -22
- package/src/workflow/context.ts +0 -4
- package/src/workflow/inspector.ts +0 -8
- package/dist/tsup/chunk-42H5OK5Z.cjs.map +0 -1
- package/dist/tsup/chunk-AGWIB6VG.cjs.map +0 -1
- package/dist/tsup/chunk-ARD7UMSN.js.map +0 -1
- package/dist/tsup/chunk-E4X3JSN7.js.map +0 -1
- package/dist/tsup/chunk-FFJXFXEW.js.map +0 -1
- package/dist/tsup/chunk-HTREBONF.cjs.map +0 -1
- package/dist/tsup/chunk-LIEQDMZ6.cjs.map +0 -1
- package/dist/tsup/chunk-MFLAOS2S.cjs.map +0 -1
- package/dist/tsup/chunk-OSQX3QN2.cjs.map +0 -1
- package/dist/tsup/chunk-PVR4LVX2.cjs.map +0 -1
- package/dist/tsup/chunk-Q3ODMSBE.js.map +0 -1
- package/dist/tsup/chunk-UEDIZR2M.cjs.map +0 -1
- package/src/actor/config.test.ts +0 -11
- package/src/common/bare/generated/actor-uds-protocol/v1.ts +0 -802
- package/src/common/bare/generated/inspector/v5.ts +0 -1016
- /package/dist/tsup/{chunk-2EYF7KY7.js.map → chunk-3GVMLSND.js.map} +0 -0
- /package/dist/tsup/{chunk-DB45WHMU.js.map → chunk-O3ZUMAN7.js.map} +0 -0
- /package/dist/tsup/{chunk-UEYBIN52.js.map → chunk-OAUFXOG7.js.map} +0 -0
- /package/dist/tsup/{chunk-D2JJWLWM.js.map → chunk-UV7INX3N.js.map} +0 -0
|
@@ -17,6 +17,24 @@ interface ActorMetricsLike {
|
|
|
17
17
|
}
|
|
18
18
|
type InferDatabaseClient<DBProvider extends AnyDatabaseProvider> = DBProvider extends DatabaseProvider<any> ? Awaited<ReturnType<DBProvider["createClient"]>> : never;
|
|
19
19
|
type SqliteBindings = unknown[] | Record<string, unknown>;
|
|
20
|
+
/**
|
|
21
|
+
* SQLite profiling controls.
|
|
22
|
+
*
|
|
23
|
+
* @experimental This entire configuration surface is subject to change.
|
|
24
|
+
*/
|
|
25
|
+
interface SqliteProfilingOptions {
|
|
26
|
+
enabled?: boolean;
|
|
27
|
+
maxTrackedStatementFingerprints?: number;
|
|
28
|
+
maxTrackedTransactionFingerprints?: number;
|
|
29
|
+
maxPrometheusSeries?: number;
|
|
30
|
+
maxStatementsPerTransactionTrace?: number;
|
|
31
|
+
maxGetPagesRequestsPerTrace?: number;
|
|
32
|
+
maxTransactionNameBytes?: number;
|
|
33
|
+
slowOperationThresholdMs?: number;
|
|
34
|
+
baselineSampleRate?: number;
|
|
35
|
+
maxDiagnosticEventsPerMinute?: number;
|
|
36
|
+
diagnosticEventQueueCapacity?: number;
|
|
37
|
+
}
|
|
20
38
|
interface SqliteQueryResult {
|
|
21
39
|
columns: string[];
|
|
22
40
|
rows: unknown[][];
|
|
@@ -39,8 +57,8 @@ interface SqliteNativeMetrics {
|
|
|
39
57
|
dbSizePages: number;
|
|
40
58
|
}
|
|
41
59
|
interface SqliteDatabase {
|
|
42
|
-
exec(sql: string, callback?: (row: unknown[], columns: string[]) => void
|
|
43
|
-
execute(sql: string, params?: SqliteBindings
|
|
60
|
+
exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
|
|
61
|
+
execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
|
|
44
62
|
run(sql: string, params?: SqliteBindings): Promise<void>;
|
|
45
63
|
query(sql: string, params?: SqliteBindings): Promise<SqliteQueryResult>;
|
|
46
64
|
nativeMetrics?(): SqliteNativeMetrics | Promise<SqliteNativeMetrics | null> | null;
|
|
@@ -89,6 +107,10 @@ interface DatabaseProviderContext {
|
|
|
89
107
|
nativeDatabaseProvider?: NativeDatabaseProvider;
|
|
90
108
|
}
|
|
91
109
|
type DatabaseProvider<DB extends RawAccess> = {
|
|
110
|
+
/**
|
|
111
|
+
* @experimental This entire configuration surface is subject to change.
|
|
112
|
+
*/
|
|
113
|
+
sqliteProfiling?: SqliteProfilingOptions;
|
|
92
114
|
/**
|
|
93
115
|
* Creates a new database client for the actor.
|
|
94
116
|
* The result is passed to the actor context as `c.db`.
|
|
@@ -112,8 +134,6 @@ type RawAccess = {
|
|
|
112
134
|
* Executes a raw SQL query.
|
|
113
135
|
*/
|
|
114
136
|
execute: ExecuteFunction;
|
|
115
|
-
/** Runs a callback in an isolated native SQLite transaction. */
|
|
116
|
-
transaction: <T>(callback: (tx: RawAccess) => Promise<T> | T) => Promise<T>;
|
|
117
137
|
/**
|
|
118
138
|
* Returns native SQLite metrics when the active runtime supports them.
|
|
119
139
|
*/
|
|
@@ -677,14 +697,6 @@ type RuntimeSqlBindParam = ({
|
|
|
677
697
|
blobValue: RuntimeBytes;
|
|
678
698
|
};
|
|
679
699
|
type RuntimeSqlBindParams = RuntimeSqlBindParam[] | null;
|
|
680
|
-
interface RuntimeSqlLeaseOptions {
|
|
681
|
-
key: string;
|
|
682
|
-
timeoutMs?: number;
|
|
683
|
-
}
|
|
684
|
-
interface RuntimeActorUdsEndpointInfo {
|
|
685
|
-
path: string;
|
|
686
|
-
token: string;
|
|
687
|
-
}
|
|
688
700
|
interface RuntimeSqlQueryResult {
|
|
689
701
|
columns: string[];
|
|
690
702
|
rows: unknown[][];
|
|
@@ -702,7 +714,8 @@ interface RuntimeActorConfig {
|
|
|
702
714
|
icon?: string;
|
|
703
715
|
hasDatabase?: boolean;
|
|
704
716
|
remoteSqlite?: boolean;
|
|
705
|
-
|
|
717
|
+
/** @experimental This entire configuration surface is subject to change. */
|
|
718
|
+
sqliteProfiling?: SqliteProfilingOptions;
|
|
706
719
|
hasState?: boolean;
|
|
707
720
|
canHibernateWebsocket?: boolean;
|
|
708
721
|
stateSaveIntervalMs?: number;
|
|
@@ -871,14 +884,13 @@ interface CoreRuntime {
|
|
|
871
884
|
actorKvBatchGet(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<Array<RuntimeBytes | undefined | null>>;
|
|
872
885
|
actorKvBatchPut(ctx: ActorContextHandle, entries: RuntimeKvEntry[]): Promise<void>;
|
|
873
886
|
actorKvBatchDelete(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<void>;
|
|
874
|
-
actorSqlExec(ctx: ActorContextHandle, sql: string
|
|
875
|
-
actorSqlExecute(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams
|
|
887
|
+
actorSqlExec(ctx: ActorContextHandle, sql: string): Promise<RuntimeSqlExecResult>;
|
|
888
|
+
actorSqlExecute(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
|
|
876
889
|
actorSqlQuery(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlQueryResult>;
|
|
877
890
|
actorSqlRun(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlRunResult>;
|
|
878
891
|
actorSqlMetrics(ctx: ActorContextHandle): SqliteNativeMetrics | null;
|
|
879
892
|
actorSqlTakeLastKvError(ctx: ActorContextHandle): string | null;
|
|
880
893
|
actorSqlClose(ctx: ActorContextHandle): Promise<void>;
|
|
881
|
-
actorUdsProvision(ctx: ActorContextHandle): Promise<RuntimeActorUdsEndpointInfo>;
|
|
882
894
|
actorQueueSend(ctx: ActorContextHandle, name: string, body: RuntimeBytes): Promise<RuntimeQueueMessage>;
|
|
883
895
|
actorQueueNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueNextBatchOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage[]>;
|
|
884
896
|
actorQueueWaitForNames(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage>;
|
|
@@ -887,7 +899,6 @@ interface CoreRuntime {
|
|
|
887
899
|
actorQueueTryNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueTryNextBatchOptions | undefined | null): RuntimeQueueMessage[];
|
|
888
900
|
actorQueueMaxSize(ctx: ActorContextHandle): number;
|
|
889
901
|
actorQueueInspectMessages(ctx: ActorContextHandle): Promise<RuntimeQueueInspectMessage[]>;
|
|
890
|
-
actorQueueReset(ctx: ActorContextHandle): Promise<void>;
|
|
891
902
|
actorScheduleAfter(ctx: ActorContextHandle, durationMs: number, actionName: string, args: RuntimeBytes): void;
|
|
892
903
|
actorScheduleAt(ctx: ActorContextHandle, timestampMs: number, actionName: string, args: RuntimeBytes): void;
|
|
893
904
|
connId(conn: ConnHandle): string;
|
|
@@ -1655,11 +1666,6 @@ interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase
|
|
|
1655
1666
|
readonly name: string;
|
|
1656
1667
|
readonly key: string[];
|
|
1657
1668
|
readonly region: string;
|
|
1658
|
-
/** Provisions credentials for the experimental local actor Unix socket API. */
|
|
1659
|
-
actorUds(): Promise<{
|
|
1660
|
-
path: string;
|
|
1661
|
-
token: string;
|
|
1662
|
-
}>;
|
|
1663
1669
|
readonly conns: Map<string, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>;
|
|
1664
1670
|
readonly log: ActorLogger;
|
|
1665
1671
|
readonly abortSignal: AbortSignal;
|
|
@@ -1756,7 +1762,6 @@ declare const ActorConfigSchema: z$1.ZodObject<{
|
|
|
1756
1762
|
options: z$1.ZodPrefault<z$1.ZodObject<{
|
|
1757
1763
|
name: z$1.ZodOptional<z$1.ZodString>;
|
|
1758
1764
|
icon: z$1.ZodOptional<z$1.ZodString>;
|
|
1759
|
-
enableSqliteUds: z$1.ZodDefault<z$1.ZodBoolean>;
|
|
1760
1765
|
canHibernateWebSocket: z$1.ZodDefault<z$1.ZodUnion<readonly [z$1.ZodBoolean, z$1.ZodCustom<(request: Request) => boolean, (request: Request) => boolean>]>>;
|
|
1761
1766
|
createVarsTimeout: z$1.ZodDefault<z$1.ZodNumber>;
|
|
1762
1767
|
createConnStateTimeout: z$1.ZodDefault<z$1.ZodNumber>;
|
|
@@ -17,6 +17,24 @@ interface ActorMetricsLike {
|
|
|
17
17
|
}
|
|
18
18
|
type InferDatabaseClient<DBProvider extends AnyDatabaseProvider> = DBProvider extends DatabaseProvider<any> ? Awaited<ReturnType<DBProvider["createClient"]>> : never;
|
|
19
19
|
type SqliteBindings = unknown[] | Record<string, unknown>;
|
|
20
|
+
/**
|
|
21
|
+
* SQLite profiling controls.
|
|
22
|
+
*
|
|
23
|
+
* @experimental This entire configuration surface is subject to change.
|
|
24
|
+
*/
|
|
25
|
+
interface SqliteProfilingOptions {
|
|
26
|
+
enabled?: boolean;
|
|
27
|
+
maxTrackedStatementFingerprints?: number;
|
|
28
|
+
maxTrackedTransactionFingerprints?: number;
|
|
29
|
+
maxPrometheusSeries?: number;
|
|
30
|
+
maxStatementsPerTransactionTrace?: number;
|
|
31
|
+
maxGetPagesRequestsPerTrace?: number;
|
|
32
|
+
maxTransactionNameBytes?: number;
|
|
33
|
+
slowOperationThresholdMs?: number;
|
|
34
|
+
baselineSampleRate?: number;
|
|
35
|
+
maxDiagnosticEventsPerMinute?: number;
|
|
36
|
+
diagnosticEventQueueCapacity?: number;
|
|
37
|
+
}
|
|
20
38
|
interface SqliteQueryResult {
|
|
21
39
|
columns: string[];
|
|
22
40
|
rows: unknown[][];
|
|
@@ -39,8 +57,8 @@ interface SqliteNativeMetrics {
|
|
|
39
57
|
dbSizePages: number;
|
|
40
58
|
}
|
|
41
59
|
interface SqliteDatabase {
|
|
42
|
-
exec(sql: string, callback?: (row: unknown[], columns: string[]) => void
|
|
43
|
-
execute(sql: string, params?: SqliteBindings
|
|
60
|
+
exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
|
|
61
|
+
execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
|
|
44
62
|
run(sql: string, params?: SqliteBindings): Promise<void>;
|
|
45
63
|
query(sql: string, params?: SqliteBindings): Promise<SqliteQueryResult>;
|
|
46
64
|
nativeMetrics?(): SqliteNativeMetrics | Promise<SqliteNativeMetrics | null> | null;
|
|
@@ -89,6 +107,10 @@ interface DatabaseProviderContext {
|
|
|
89
107
|
nativeDatabaseProvider?: NativeDatabaseProvider;
|
|
90
108
|
}
|
|
91
109
|
type DatabaseProvider<DB extends RawAccess> = {
|
|
110
|
+
/**
|
|
111
|
+
* @experimental This entire configuration surface is subject to change.
|
|
112
|
+
*/
|
|
113
|
+
sqliteProfiling?: SqliteProfilingOptions;
|
|
92
114
|
/**
|
|
93
115
|
* Creates a new database client for the actor.
|
|
94
116
|
* The result is passed to the actor context as `c.db`.
|
|
@@ -112,8 +134,6 @@ type RawAccess = {
|
|
|
112
134
|
* Executes a raw SQL query.
|
|
113
135
|
*/
|
|
114
136
|
execute: ExecuteFunction;
|
|
115
|
-
/** Runs a callback in an isolated native SQLite transaction. */
|
|
116
|
-
transaction: <T>(callback: (tx: RawAccess) => Promise<T> | T) => Promise<T>;
|
|
117
137
|
/**
|
|
118
138
|
* Returns native SQLite metrics when the active runtime supports them.
|
|
119
139
|
*/
|
|
@@ -677,14 +697,6 @@ type RuntimeSqlBindParam = ({
|
|
|
677
697
|
blobValue: RuntimeBytes;
|
|
678
698
|
};
|
|
679
699
|
type RuntimeSqlBindParams = RuntimeSqlBindParam[] | null;
|
|
680
|
-
interface RuntimeSqlLeaseOptions {
|
|
681
|
-
key: string;
|
|
682
|
-
timeoutMs?: number;
|
|
683
|
-
}
|
|
684
|
-
interface RuntimeActorUdsEndpointInfo {
|
|
685
|
-
path: string;
|
|
686
|
-
token: string;
|
|
687
|
-
}
|
|
688
700
|
interface RuntimeSqlQueryResult {
|
|
689
701
|
columns: string[];
|
|
690
702
|
rows: unknown[][];
|
|
@@ -702,7 +714,8 @@ interface RuntimeActorConfig {
|
|
|
702
714
|
icon?: string;
|
|
703
715
|
hasDatabase?: boolean;
|
|
704
716
|
remoteSqlite?: boolean;
|
|
705
|
-
|
|
717
|
+
/** @experimental This entire configuration surface is subject to change. */
|
|
718
|
+
sqliteProfiling?: SqliteProfilingOptions;
|
|
706
719
|
hasState?: boolean;
|
|
707
720
|
canHibernateWebsocket?: boolean;
|
|
708
721
|
stateSaveIntervalMs?: number;
|
|
@@ -871,14 +884,13 @@ interface CoreRuntime {
|
|
|
871
884
|
actorKvBatchGet(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<Array<RuntimeBytes | undefined | null>>;
|
|
872
885
|
actorKvBatchPut(ctx: ActorContextHandle, entries: RuntimeKvEntry[]): Promise<void>;
|
|
873
886
|
actorKvBatchDelete(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<void>;
|
|
874
|
-
actorSqlExec(ctx: ActorContextHandle, sql: string
|
|
875
|
-
actorSqlExecute(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams
|
|
887
|
+
actorSqlExec(ctx: ActorContextHandle, sql: string): Promise<RuntimeSqlExecResult>;
|
|
888
|
+
actorSqlExecute(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
|
|
876
889
|
actorSqlQuery(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlQueryResult>;
|
|
877
890
|
actorSqlRun(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlRunResult>;
|
|
878
891
|
actorSqlMetrics(ctx: ActorContextHandle): SqliteNativeMetrics | null;
|
|
879
892
|
actorSqlTakeLastKvError(ctx: ActorContextHandle): string | null;
|
|
880
893
|
actorSqlClose(ctx: ActorContextHandle): Promise<void>;
|
|
881
|
-
actorUdsProvision(ctx: ActorContextHandle): Promise<RuntimeActorUdsEndpointInfo>;
|
|
882
894
|
actorQueueSend(ctx: ActorContextHandle, name: string, body: RuntimeBytes): Promise<RuntimeQueueMessage>;
|
|
883
895
|
actorQueueNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueNextBatchOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage[]>;
|
|
884
896
|
actorQueueWaitForNames(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage>;
|
|
@@ -887,7 +899,6 @@ interface CoreRuntime {
|
|
|
887
899
|
actorQueueTryNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueTryNextBatchOptions | undefined | null): RuntimeQueueMessage[];
|
|
888
900
|
actorQueueMaxSize(ctx: ActorContextHandle): number;
|
|
889
901
|
actorQueueInspectMessages(ctx: ActorContextHandle): Promise<RuntimeQueueInspectMessage[]>;
|
|
890
|
-
actorQueueReset(ctx: ActorContextHandle): Promise<void>;
|
|
891
902
|
actorScheduleAfter(ctx: ActorContextHandle, durationMs: number, actionName: string, args: RuntimeBytes): void;
|
|
892
903
|
actorScheduleAt(ctx: ActorContextHandle, timestampMs: number, actionName: string, args: RuntimeBytes): void;
|
|
893
904
|
connId(conn: ConnHandle): string;
|
|
@@ -1655,11 +1666,6 @@ interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase
|
|
|
1655
1666
|
readonly name: string;
|
|
1656
1667
|
readonly key: string[];
|
|
1657
1668
|
readonly region: string;
|
|
1658
|
-
/** Provisions credentials for the experimental local actor Unix socket API. */
|
|
1659
|
-
actorUds(): Promise<{
|
|
1660
|
-
path: string;
|
|
1661
|
-
token: string;
|
|
1662
|
-
}>;
|
|
1663
1669
|
readonly conns: Map<string, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>;
|
|
1664
1670
|
readonly log: ActorLogger;
|
|
1665
1671
|
readonly abortSignal: AbortSignal;
|
|
@@ -1756,7 +1762,6 @@ declare const ActorConfigSchema: z$1.ZodObject<{
|
|
|
1756
1762
|
options: z$1.ZodPrefault<z$1.ZodObject<{
|
|
1757
1763
|
name: z$1.ZodOptional<z$1.ZodString>;
|
|
1758
1764
|
icon: z$1.ZodOptional<z$1.ZodString>;
|
|
1759
|
-
enableSqliteUds: z$1.ZodDefault<z$1.ZodBoolean>;
|
|
1760
1765
|
canHibernateWebSocket: z$1.ZodDefault<z$1.ZodUnion<readonly [z$1.ZodBoolean, z$1.ZodCustom<(request: Request) => boolean, (request: Request) => boolean>]>>;
|
|
1761
1766
|
createVarsTimeout: z$1.ZodDefault<z$1.ZodNumber>;
|
|
1762
1767
|
createConnStateTimeout: z$1.ZodDefault<z$1.ZodNumber>;
|
|
@@ -81,8 +81,6 @@ var GlobalActorOptionsBaseSchema = z.object({
|
|
|
81
81
|
name: z.string().optional(),
|
|
82
82
|
/** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
|
|
83
83
|
icon: z.string().optional(),
|
|
84
|
-
/** Enables the experimental local SQLite Unix socket endpoint for this actor. */
|
|
85
|
-
enableSqliteUds: z.boolean().default(false),
|
|
86
84
|
/**
|
|
87
85
|
* Can hibernate WebSockets for onWebSocket.
|
|
88
86
|
*
|
|
@@ -176,9 +174,6 @@ var DocActorOptionsSchema = z.object({
|
|
|
176
174
|
icon: z.string().optional().describe(
|
|
177
175
|
"Icon for the actor in the Inspector UI. Can be an emoji (e.g., '\u{1F680}') or FontAwesome icon name (e.g., 'rocket')."
|
|
178
176
|
),
|
|
179
|
-
enableSqliteUds: z.boolean().optional().describe(
|
|
180
|
-
"Enables the experimental local SQLite Unix socket endpoint for this actor. Default: false"
|
|
181
|
-
),
|
|
182
177
|
createVarsTimeout: z.number().optional().describe("Timeout in ms for createVars handler. Default: 5000"),
|
|
183
178
|
createConnStateTimeout: z.number().optional().describe(
|
|
184
179
|
"Timeout in ms for createConnState handler. Default: 5000"
|
|
@@ -319,7 +314,7 @@ function isRivetErrorCode(error, group, code) {
|
|
|
319
314
|
// package.json
|
|
320
315
|
var package_default = {
|
|
321
316
|
name: "rivetkit",
|
|
322
|
-
version: "0.0.0-sqlite-
|
|
317
|
+
version: "0.0.0-sqlite-profiling-compat.87d61c0",
|
|
323
318
|
description: "Lightweight libraries for building stateful actors on edge platforms",
|
|
324
319
|
license: "Apache-2.0",
|
|
325
320
|
keywords: [
|
|
@@ -611,8 +606,11 @@ function getPinoLevel(logLevel) {
|
|
|
611
606
|
function getIncludeTarget() {
|
|
612
607
|
return getLogTarget();
|
|
613
608
|
}
|
|
614
|
-
function
|
|
615
|
-
|
|
609
|
+
function configureDefaultLogger(logLevel) {
|
|
610
|
+
if (logLevel) {
|
|
611
|
+
configuredLogLevel = logLevel;
|
|
612
|
+
}
|
|
613
|
+
baseLogger = pino(
|
|
616
614
|
{
|
|
617
615
|
level: getPinoLevel(logLevel),
|
|
618
616
|
messageKey: "msg",
|
|
@@ -629,12 +627,6 @@ function makeDefaultLogger(logLevel) {
|
|
|
629
627
|
},
|
|
630
628
|
createLogfmtDestination()
|
|
631
629
|
);
|
|
632
|
-
}
|
|
633
|
-
function configureDefaultLogger(logLevel) {
|
|
634
|
-
if (logLevel) {
|
|
635
|
-
configuredLogLevel = logLevel;
|
|
636
|
-
}
|
|
637
|
-
baseLogger = makeDefaultLogger(logLevel);
|
|
638
630
|
loggerCache.clear();
|
|
639
631
|
}
|
|
640
632
|
function getBaseLogger() {
|
|
@@ -811,15 +803,16 @@ function toSqliteBindings(input) {
|
|
|
811
803
|
}
|
|
812
804
|
|
|
813
805
|
// src/common/database/mod.ts
|
|
814
|
-
var MIGRATION_LEASE_TIMEOUT_MS = 6e4;
|
|
815
806
|
function hasMultipleStatements(query) {
|
|
816
807
|
const trimmed = query.trim().replace(/;+$/, "").trimEnd();
|
|
817
808
|
return trimmed.includes(";");
|
|
818
809
|
}
|
|
819
810
|
function db({
|
|
820
|
-
onMigrate
|
|
811
|
+
onMigrate,
|
|
812
|
+
profiling
|
|
821
813
|
} = {}) {
|
|
822
814
|
return {
|
|
815
|
+
sqliteProfiling: profiling,
|
|
823
816
|
createClient: async (ctx) => {
|
|
824
817
|
const nativeDatabaseProvider = ctx.nativeDatabaseProvider;
|
|
825
818
|
if (!nativeDatabaseProvider) {
|
|
@@ -829,7 +822,6 @@ function db({
|
|
|
829
822
|
}
|
|
830
823
|
const db2 = await nativeDatabaseProvider.open(ctx.actorId);
|
|
831
824
|
let closed = false;
|
|
832
|
-
let transactionActive = false;
|
|
833
825
|
const ensureOpen = () => {
|
|
834
826
|
if (closed) {
|
|
835
827
|
throw new Error(
|
|
@@ -837,15 +829,10 @@ function db({
|
|
|
837
829
|
);
|
|
838
830
|
}
|
|
839
831
|
};
|
|
840
|
-
const
|
|
832
|
+
const client = {
|
|
841
833
|
execute: async (query, ...args) => {
|
|
842
834
|
var _a, _b, _c, _d;
|
|
843
835
|
ensureOpen();
|
|
844
|
-
if (!lease && transactionActive) {
|
|
845
|
-
throw new Error(
|
|
846
|
-
"Use the tx argument inside db.transaction(); the outer database client cannot run work from the transaction callback."
|
|
847
|
-
);
|
|
848
|
-
}
|
|
849
836
|
const kvReadsBefore = ((_a = ctx.metrics) == null ? void 0 : _a.totalKvReads) ?? 0;
|
|
850
837
|
const kvWritesBefore = ((_b = ctx.metrics) == null ? void 0 : _b.totalKvWrites) ?? 0;
|
|
851
838
|
const start = performance.now();
|
|
@@ -854,24 +841,19 @@ function db({
|
|
|
854
841
|
const bindings = args.length === 1 && isSqliteBindingObject(args[0]) ? toSqliteBindings(args[0]) : toSqliteBindings(args);
|
|
855
842
|
const { rows, columns } = await db2.execute(
|
|
856
843
|
query,
|
|
857
|
-
bindings
|
|
858
|
-
lease
|
|
844
|
+
bindings
|
|
859
845
|
);
|
|
860
846
|
return rows.map(
|
|
861
847
|
(row) => rowToObject(row, columns)
|
|
862
848
|
);
|
|
863
849
|
}
|
|
864
850
|
if (!hasMultipleStatements(query)) {
|
|
865
|
-
const { rows, columns } = await db2.execute(
|
|
866
|
-
query,
|
|
867
|
-
void 0,
|
|
868
|
-
lease
|
|
869
|
-
);
|
|
851
|
+
const { rows, columns } = await db2.execute(query);
|
|
870
852
|
return rows.map(
|
|
871
853
|
(row) => rowToObject(row, columns)
|
|
872
854
|
);
|
|
873
855
|
}
|
|
874
|
-
return await execMultiStatement(db2, query
|
|
856
|
+
return await execMultiStatement(db2, query);
|
|
875
857
|
} finally {
|
|
876
858
|
const durationMs = performance.now() - start;
|
|
877
859
|
(_c = ctx.metrics) == null ? void 0 : _c.trackSql(query, durationMs);
|
|
@@ -888,41 +870,6 @@ function db({
|
|
|
888
870
|
}
|
|
889
871
|
}
|
|
890
872
|
},
|
|
891
|
-
transaction: async (callback) => {
|
|
892
|
-
if (lease || transactionActive) {
|
|
893
|
-
throw new Error(
|
|
894
|
-
"Nested or concurrent db.transaction() calls are not supported."
|
|
895
|
-
);
|
|
896
|
-
}
|
|
897
|
-
const transactionLease = { key: crypto.randomUUID() };
|
|
898
|
-
const tx = createClient(transactionLease);
|
|
899
|
-
await db2.execute("BEGIN", void 0, transactionLease);
|
|
900
|
-
transactionActive = true;
|
|
901
|
-
try {
|
|
902
|
-
const result = await callback(tx);
|
|
903
|
-
await db2.execute("COMMIT", void 0, transactionLease);
|
|
904
|
-
return result;
|
|
905
|
-
} catch (error) {
|
|
906
|
-
try {
|
|
907
|
-
await db2.execute(
|
|
908
|
-
"ROLLBACK",
|
|
909
|
-
void 0,
|
|
910
|
-
transactionLease
|
|
911
|
-
);
|
|
912
|
-
} catch {
|
|
913
|
-
}
|
|
914
|
-
throw error;
|
|
915
|
-
} finally {
|
|
916
|
-
transactionActive = false;
|
|
917
|
-
}
|
|
918
|
-
},
|
|
919
|
-
__withSqliteLease: async (timeoutMs, callback) => {
|
|
920
|
-
const internalLease = {
|
|
921
|
-
key: crypto.randomUUID(),
|
|
922
|
-
timeoutMs
|
|
923
|
-
};
|
|
924
|
-
return await callback(createClient(internalLease));
|
|
925
|
-
},
|
|
926
873
|
close: async () => {
|
|
927
874
|
if (!closed) {
|
|
928
875
|
closed = true;
|
|
@@ -933,16 +880,12 @@ function db({
|
|
|
933
880
|
var _a;
|
|
934
881
|
return ((_a = db2.nativeMetrics) == null ? void 0 : _a.call(db2)) ?? null;
|
|
935
882
|
}
|
|
936
|
-
}
|
|
937
|
-
const client = createClient();
|
|
883
|
+
};
|
|
938
884
|
return client;
|
|
939
885
|
},
|
|
940
886
|
onMigrate: async (client) => {
|
|
941
887
|
if (onMigrate) {
|
|
942
|
-
await withMigrationSavepoint(
|
|
943
|
-
client,
|
|
944
|
-
(leased) => onMigrate(leased)
|
|
945
|
-
);
|
|
888
|
+
await withMigrationSavepoint(client, () => onMigrate(client));
|
|
946
889
|
}
|
|
947
890
|
}
|
|
948
891
|
};
|
|
@@ -954,44 +897,31 @@ function rowToObject(row, columns) {
|
|
|
954
897
|
}
|
|
955
898
|
return rowObj;
|
|
956
899
|
}
|
|
957
|
-
async function execMultiStatement(db2, query
|
|
900
|
+
async function execMultiStatement(db2, query) {
|
|
958
901
|
const results = [];
|
|
959
902
|
let columnNames = null;
|
|
960
|
-
await db2.exec(
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
results.push(rowToObject(row, columnNames));
|
|
967
|
-
},
|
|
968
|
-
lease
|
|
969
|
-
);
|
|
903
|
+
await db2.exec(query, (row, columns) => {
|
|
904
|
+
if (!columnNames) {
|
|
905
|
+
columnNames = columns;
|
|
906
|
+
}
|
|
907
|
+
results.push(rowToObject(row, columnNames));
|
|
908
|
+
});
|
|
970
909
|
return results;
|
|
971
910
|
}
|
|
972
911
|
async function withMigrationSavepoint(client, callback) {
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
await leased.execute(
|
|
984
|
-
"ROLLBACK TO SAVEPOINT __rivet_on_migrate"
|
|
985
|
-
);
|
|
986
|
-
} finally {
|
|
987
|
-
await leased.execute(
|
|
988
|
-
"RELEASE SAVEPOINT __rivet_on_migrate"
|
|
989
|
-
);
|
|
990
|
-
}
|
|
991
|
-
throw error;
|
|
992
|
-
}
|
|
912
|
+
await client.execute("SAVEPOINT __rivet_on_migrate");
|
|
913
|
+
try {
|
|
914
|
+
const result = await callback();
|
|
915
|
+
await client.execute("RELEASE SAVEPOINT __rivet_on_migrate");
|
|
916
|
+
return result;
|
|
917
|
+
} catch (error) {
|
|
918
|
+
try {
|
|
919
|
+
await client.execute("ROLLBACK TO SAVEPOINT __rivet_on_migrate");
|
|
920
|
+
} finally {
|
|
921
|
+
await client.execute("RELEASE SAVEPOINT __rivet_on_migrate");
|
|
993
922
|
}
|
|
994
|
-
|
|
923
|
+
throw error;
|
|
924
|
+
}
|
|
995
925
|
}
|
|
996
926
|
|
|
997
927
|
// src/agent-os/config.ts
|
|
@@ -1151,9 +1081,9 @@ function buildNetworkActions(config) {
|
|
|
1151
1081
|
}
|
|
1152
1082
|
|
|
1153
1083
|
// src/agent-os/actor/preview.ts
|
|
1154
|
-
import
|
|
1084
|
+
import crypto from "crypto";
|
|
1155
1085
|
function generateToken() {
|
|
1156
|
-
const bytes =
|
|
1086
|
+
const bytes = crypto.randomBytes(32);
|
|
1157
1087
|
const alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
1158
1088
|
let token = "";
|
|
1159
1089
|
for (let i = 0; i < 32; i++) {
|