rivetkit 0.0.0-skip-ready-wait-flatten-client-options.1cae221 → 0.0.0-sqlite-uds.4e59a38
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 +561 -89
- package/dist/browser/client.js +1063 -430
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.d.ts +22 -2
- package/dist/browser/inspector/client.js +1036 -232
- 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 -74
- package/dist/tsup/actor/errors.d.ts +1 -74
- package/dist/tsup/actor/errors.js +5 -1
- package/dist/tsup/agent-os/index.cjs +2218 -2082
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +556 -85
- package/dist/tsup/agent-os/index.d.ts +556 -85
- package/dist/tsup/agent-os/index.js +2220 -2084
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-NFC5VU36.cjs → chunk-3GC3EP6D.cjs} +18 -10
- package/dist/tsup/chunk-3GC3EP6D.cjs.map +1 -0
- package/dist/tsup/{chunk-7MRGNVSR.js → chunk-3GLNEWGY.js} +78 -6
- package/dist/tsup/chunk-3GLNEWGY.js.map +1 -0
- package/dist/tsup/{chunk-V3QNBJ7N.cjs → chunk-4FC7TVS6.cjs} +35 -10
- package/dist/tsup/chunk-4FC7TVS6.cjs.map +1 -0
- package/dist/tsup/{chunk-POTPHU3P.cjs → chunk-62LSMTP2.cjs} +3 -3
- package/dist/tsup/{chunk-POTPHU3P.cjs.map → chunk-62LSMTP2.cjs.map} +1 -1
- package/dist/tsup/{chunk-OIKOPSXQ.js → chunk-7IVUT2JT.js} +12 -4
- package/dist/tsup/chunk-7IVUT2JT.js.map +1 -0
- package/dist/tsup/{chunk-22XU3BVY.cjs → chunk-GEYQLGXC.cjs} +925 -328
- package/dist/tsup/chunk-GEYQLGXC.cjs.map +1 -0
- package/dist/tsup/{chunk-D2TLG75Y.cjs → chunk-GMN45CQ6.cjs} +10 -10
- package/dist/tsup/chunk-GMN45CQ6.cjs.map +1 -0
- package/dist/tsup/{chunk-3BFYSYRU.js → chunk-HXUEHHJF.js} +3 -2
- package/dist/tsup/chunk-HXUEHHJF.js.map +1 -0
- package/dist/tsup/{chunk-IOYKCB6Y.cjs → chunk-I336PMWT.cjs} +44 -9
- package/dist/tsup/chunk-I336PMWT.cjs.map +1 -0
- package/dist/tsup/{chunk-RZEJJJKU.js → chunk-IB73AMGJ.js} +42 -7
- package/dist/tsup/chunk-IB73AMGJ.js.map +1 -0
- package/dist/tsup/{chunk-4ZIWB4CQ.js → chunk-ITWJ6Y7G.js} +2 -2
- package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JZ7TWV65.js} +1 -1
- package/dist/tsup/chunk-JZ7TWV65.js.map +1 -0
- package/dist/tsup/{chunk-W54QCENI.js → chunk-KTNBYGRU.js} +134 -20
- package/dist/tsup/chunk-KTNBYGRU.js.map +1 -0
- package/dist/tsup/{chunk-AK57AL7S.cjs → chunk-OAPVVVTX.cjs} +79 -7
- package/dist/tsup/chunk-OAPVVVTX.cjs.map +1 -0
- package/dist/tsup/{chunk-TPBHXFB2.cjs → chunk-OUDV3ITX.cjs} +138 -24
- package/dist/tsup/chunk-OUDV3ITX.cjs.map +1 -0
- package/dist/tsup/{chunk-XNZR7UD2.cjs → chunk-PRXTIERO.cjs} +90 -65
- package/dist/tsup/chunk-PRXTIERO.cjs.map +1 -0
- package/dist/tsup/{chunk-LLD2D5LO.cjs → chunk-VE2X4KMG.cjs} +3 -2
- package/dist/tsup/chunk-VE2X4KMG.cjs.map +1 -0
- package/dist/tsup/{chunk-KSG2COSQ.js → chunk-WRZEVVLL.js} +6 -6
- package/dist/tsup/chunk-WRZEVVLL.js.map +1 -0
- package/dist/tsup/{chunk-LNMB25HW.js → chunk-XAIMHUPG.js} +780 -183
- package/dist/tsup/chunk-XAIMHUPG.js.map +1 -0
- package/dist/tsup/{chunk-D4TSTM6C.js → chunk-XZ62SWSC.js} +83 -58
- package/dist/tsup/chunk-XZ62SWSC.js.map +1 -0
- package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-ZA7FLHKH.cjs} +1 -1
- package/dist/tsup/chunk-ZA7FLHKH.cjs.map +1 -0
- package/dist/tsup/{chunk-K34B3OVG.js → chunk-ZZ3WBRPD.js} +34 -9
- package/dist/tsup/chunk-ZZ3WBRPD.js.map +1 -0
- package/dist/tsup/client/mod.cjs +9 -9
- package/dist/tsup/client/mod.cjs.map +1 -1
- package/dist/tsup/client/mod.d.cts +8 -9
- package/dist/tsup/client/mod.d.ts +8 -9
- package/dist/tsup/client/mod.js +8 -8
- package/dist/tsup/common/log.cjs +5 -3
- package/dist/tsup/common/log.cjs.map +1 -1
- package/dist/tsup/common/log.d.cts +5 -1
- package/dist/tsup/common/log.d.ts +5 -1
- package/dist/tsup/common/log.js +6 -4
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-CRdGwwbr.d.cts → config-CxG53eQo.d.cts} +577 -36
- package/dist/tsup/{config-kxXbtrJU.d.ts → config-DLOxy81E.d.cts} +5 -5
- package/dist/tsup/{config-kxXbtrJU.d.cts → config-DLOxy81E.d.ts} +5 -5
- package/dist/tsup/{config-DIpBWm5C.d.ts → config-Ds6DCRhV.d.ts} +577 -36
- package/dist/tsup/context-8KlcOYIs.d.cts +129 -0
- package/dist/tsup/context-Cfbm4QLr.d.ts +129 -0
- package/dist/tsup/db/drizzle.cjs +151 -79
- package/dist/tsup/db/drizzle.cjs.map +1 -1
- package/dist/tsup/db/drizzle.d.cts +2 -2
- package/dist/tsup/db/drizzle.d.ts +2 -2
- package/dist/tsup/db/drizzle.js +151 -79
- package/dist/tsup/db/drizzle.js.map +1 -1
- package/dist/tsup/db/mod.cjs +79 -24
- package/dist/tsup/db/mod.cjs.map +1 -1
- package/dist/tsup/db/mod.d.cts +2 -2
- package/dist/tsup/db/mod.d.ts +2 -2
- package/dist/tsup/db/mod.js +78 -23
- package/dist/tsup/db/mod.js.map +1 -1
- package/dist/tsup/dynamic/mod.cjs +24 -0
- package/dist/tsup/dynamic/mod.cjs.map +1 -0
- package/dist/tsup/dynamic/mod.d.cts +37 -0
- package/dist/tsup/dynamic/mod.d.ts +37 -0
- package/dist/tsup/dynamic/mod.js +24 -0
- package/dist/tsup/dynamic/mod.js.map +1 -0
- package/dist/tsup/inspector/mod.cjs +47 -12
- package/dist/tsup/inspector/mod.cjs.map +1 -1
- package/dist/tsup/inspector/mod.d.cts +37 -15
- package/dist/tsup/inspector/mod.d.ts +37 -15
- package/dist/tsup/inspector/mod.js +46 -11
- package/dist/tsup/inspector/mod.js.map +1 -1
- package/dist/tsup/inspector-tab/mod.cjs +162 -0
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
- package/dist/tsup/inspector-tab/mod.d.cts +240 -0
- package/dist/tsup/inspector-tab/mod.d.ts +240 -0
- package/dist/tsup/inspector-tab/mod.js +162 -0
- package/dist/tsup/inspector-tab/mod.js.map +1 -0
- package/dist/tsup/mod.cjs +1078 -479
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +5 -6
- package/dist/tsup/mod.d.ts +5 -6
- package/dist/tsup/mod.js +996 -397
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +21 -18
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +4 -5
- package/dist/tsup/test/mod.d.ts +4 -5
- package/dist/tsup/test/mod.js +18 -15
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/utils-CqDnC_PS.d.cts +104 -0
- package/dist/tsup/utils-CqDnC_PS.d.ts +104 -0
- package/dist/tsup/utils.cjs +3 -3
- package/dist/tsup/utils.d.cts +1 -1
- package/dist/tsup/utils.d.ts +1 -1
- package/dist/tsup/utils.js +2 -2
- package/dist/tsup/workflow/mod.cjs +386 -322
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +8 -9
- package/dist/tsup/workflow/mod.d.ts +8 -9
- package/dist/tsup/workflow/mod.js +363 -299
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +35 -14
- package/src/actor/config.ts +188 -59
- package/src/actor/contexts/index.ts +7 -2
- package/src/actor/definition.ts +17 -19
- package/src/actor/driver.ts +3 -3
- package/src/actor/errors.ts +70 -7
- package/src/actor/instance/mod.ts +39 -56
- package/src/actor/keys.ts +2 -1
- package/src/actor/mod.ts +22 -20
- package/src/actor/schema.ts +2 -2
- package/src/agent-os/actor/index.ts +38 -18
- package/src/agent-os/actor/preview.ts +1 -2
- package/src/agent-os/actor/session.ts +2 -2
- package/src/agent-os/config.ts +1 -1
- package/src/agent-os/fs/database-vfs.ts +1 -1
- package/src/agent-os/index.ts +16 -15
- package/src/client/actor-common.ts +88 -62
- package/src/client/actor-conn.ts +58 -63
- package/src/client/actor-handle.ts +125 -71
- package/src/client/actor-query.ts +5 -5
- package/src/client/config.ts +3 -3
- package/src/client/errors.ts +2 -1
- package/src/client/lifecycle-errors.ts +2 -4
- package/src/client/query.ts +1 -1
- package/src/client/queue.ts +8 -3
- package/src/client/raw-utils.ts +10 -10
- package/src/client/resolve-gateway-target.ts +1 -1
- package/src/client/utils.ts +34 -10
- package/src/common/actor-router-consts.ts +7 -4
- package/src/common/actor-websocket.ts +3 -1
- package/src/common/bare/actor-persist/v1.ts +205 -163
- package/src/common/bare/actor-persist/v2.ts +265 -213
- package/src/common/bare/actor-persist/v3.ts +176 -172
- package/src/common/bare/actor-persist/v4.ts +254 -253
- package/src/common/bare/generated/client-protocol/v4.ts +599 -0
- package/src/common/bare/generated/inspector/v5.ts +1016 -0
- package/src/common/bare/transport/v1.ts +694 -542
- package/src/common/client-protocol-versioned.ts +176 -67
- package/src/common/client-protocol-zod.ts +7 -0
- package/src/common/client-protocol.ts +1 -1
- package/src/common/database/config.ts +16 -5
- package/src/common/database/mod.test.ts +83 -16
- package/src/common/database/mod.ts +86 -30
- package/src/common/database/native-database.test.ts +35 -22
- package/src/common/database/native-database.ts +26 -10
- package/src/common/database/shared.ts +1 -0
- package/src/common/encoding.ts +250 -16
- package/src/common/engine.ts +28 -1
- package/src/common/eventsource.ts +1 -1
- package/src/common/inline-websocket-adapter.ts +14 -13
- package/src/common/log.ts +15 -8
- package/src/common/router.ts +49 -23
- package/src/common/utils.ts +10 -202
- package/src/common/websocket-interface.ts +1 -1
- package/src/db/drizzle.ts +173 -96
- package/src/db/mod.ts +1 -1
- package/src/devtools-loader/index.ts +4 -7
- package/src/devtools-loader/serve-devtools.ts +26 -0
- package/src/drivers/engine/actor-driver.ts +76 -73
- package/src/dynamic/instance.ts +32 -0
- package/src/dynamic/internal.ts +50 -0
- package/src/dynamic/isolate-runtime.ts +66 -0
- package/src/dynamic/mod.ts +32 -0
- package/src/engine-client/actor-http-client.ts +6 -9
- package/src/engine-client/actor-websocket-client.ts +14 -13
- package/src/engine-client/api-endpoints.ts +51 -2
- package/src/engine-client/api-utils.ts +2 -2
- package/src/engine-client/driver.ts +3 -4
- package/src/engine-client/mod.ts +17 -10
- package/src/engine-client/ws-proxy.ts +9 -4
- package/src/inspector/client.browser.ts +66 -15
- package/src/inspector/mod.ts +2 -4
- package/src/inspector-tab/mod.ts +300 -0
- package/src/registry/config/envoy.ts +1 -2
- package/src/registry/config/index.ts +46 -20
- package/src/registry/index.ts +364 -87
- package/src/registry/napi-runtime.ts +97 -8
- package/src/registry/native-validation.ts +10 -12
- package/src/registry/native.ts +592 -343
- package/src/registry/process-metrics.ts +250 -0
- package/src/registry/runtime.ts +85 -6
- package/src/registry/wasm-runtime.ts +72 -3
- package/src/registry/write-through-proxy.ts +40 -0
- package/src/serde.ts +2 -2
- package/src/serverless/configure.ts +19 -8
- package/src/test/mod.ts +11 -8
- package/src/utils/crypto.ts +14 -0
- package/src/utils/endpoint-parser.ts +1 -1
- package/src/utils/env-vars.ts +37 -0
- package/src/utils/router.ts +1 -1
- package/src/utils.ts +1 -2
- package/src/workflow/context.ts +703 -240
- package/src/workflow/driver.ts +23 -12
- package/src/workflow/inspector.ts +12 -3
- package/src/workflow/mod.ts +37 -23
- package/dist/tsup/chunk-22XU3BVY.cjs.map +0 -1
- package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
- package/dist/tsup/chunk-3BFYSYRU.js.map +0 -1
- package/dist/tsup/chunk-7MRGNVSR.js.map +0 -1
- package/dist/tsup/chunk-AK57AL7S.cjs.map +0 -1
- package/dist/tsup/chunk-D2TLG75Y.cjs.map +0 -1
- package/dist/tsup/chunk-D4TSTM6C.js.map +0 -1
- package/dist/tsup/chunk-IOYKCB6Y.cjs.map +0 -1
- package/dist/tsup/chunk-K34B3OVG.js.map +0 -1
- package/dist/tsup/chunk-KSG2COSQ.js.map +0 -1
- package/dist/tsup/chunk-LLD2D5LO.cjs.map +0 -1
- package/dist/tsup/chunk-LNMB25HW.js.map +0 -1
- package/dist/tsup/chunk-NFC5VU36.cjs.map +0 -1
- package/dist/tsup/chunk-OIKOPSXQ.js.map +0 -1
- package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
- package/dist/tsup/chunk-RZEJJJKU.js.map +0 -1
- package/dist/tsup/chunk-TPBHXFB2.cjs.map +0 -1
- package/dist/tsup/chunk-V3QNBJ7N.cjs.map +0 -1
- package/dist/tsup/chunk-W54QCENI.js.map +0 -1
- package/dist/tsup/chunk-XNZR7UD2.cjs.map +0 -1
- package/dist/tsup/context-B7G6sk7x.d.ts +0 -92
- package/dist/tsup/context-DzMRHkjC.d.cts +0 -92
- package/dist/tsup/utils-fwx3o3K9.d.cts +0 -18
- package/dist/tsup/utils-fwx3o3K9.d.ts +0 -18
- package/src/utils/serve.ts +0 -217
- /package/dist/tsup/{chunk-4ZIWB4CQ.js.map → chunk-ITWJ6Y7G.js.map} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as _rivet_dev_agent_os_core from '@rivet-dev/agent-os-core';
|
|
2
2
|
import { AgentOs, JsonRpcNotification, PermissionRequest, CronEvent, AgentCapabilities, AgentInfo, JsonRpcResponse, AgentOsOptions, BatchReadResult, BatchWriteEntry, BatchWriteResult, ReaddirRecursiveOptions, DirEntry, AgentRegistryEntry, SpawnedProcessInfo, ProcessInfo, ProcessTreeNode, SessionModeState, SessionConfigOption, GetEventsOptions, SequencedEvent, PermissionReply, AgentType, CreateSessionOptions, SessionInfo, OpenShellOptions } from '@rivet-dev/agent-os-core';
|
|
3
3
|
import { z as z$1 } from 'zod/v4';
|
|
4
|
-
import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
|
|
5
4
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
6
5
|
import { Context, Handler, Hono } from 'hono';
|
|
6
|
+
import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
|
|
7
7
|
import * as _rivetkit_rivetkit_wasm from '@rivetkit/rivetkit-wasm';
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
import { Logger } from 'pino';
|
|
@@ -39,11 +39,10 @@ interface SqliteNativeMetrics {
|
|
|
39
39
|
dbSizePages: number;
|
|
40
40
|
}
|
|
41
41
|
interface SqliteDatabase {
|
|
42
|
-
exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
|
|
43
|
-
execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
|
|
42
|
+
exec(sql: string, callback?: (row: unknown[], columns: string[]) => void, lease?: SqliteLeaseOptions): Promise<void>;
|
|
43
|
+
execute(sql: string, params?: SqliteBindings, lease?: SqliteLeaseOptions): Promise<SqliteExecuteResult>;
|
|
44
44
|
run(sql: string, params?: SqliteBindings): Promise<void>;
|
|
45
45
|
query(sql: string, params?: SqliteBindings): Promise<SqliteQueryResult>;
|
|
46
|
-
writeMode<T>(callback: () => Promise<T>): Promise<T>;
|
|
47
46
|
nativeMetrics?(): SqliteNativeMetrics | Promise<SqliteNativeMetrics | null> | null;
|
|
48
47
|
close(): Promise<void>;
|
|
49
48
|
}
|
|
@@ -106,14 +105,15 @@ type DatabaseProvider<DB extends RawAccess> = {
|
|
|
106
105
|
/**
|
|
107
106
|
* Drizzle database client interface (will be extended by drizzle-orm types)
|
|
108
107
|
*/
|
|
109
|
-
|
|
110
|
-
}
|
|
108
|
+
type DrizzleDatabaseClient = {};
|
|
111
109
|
type ExecuteFunction = <TRow extends Record<string, unknown> = Record<string, unknown>>(query: string, ...args: unknown[]) => Promise<TRow[]>;
|
|
112
110
|
type RawAccess = {
|
|
113
111
|
/**
|
|
114
112
|
* Executes a raw SQL query.
|
|
115
113
|
*/
|
|
116
114
|
execute: ExecuteFunction;
|
|
115
|
+
/** Runs a callback in an isolated native SQLite transaction. */
|
|
116
|
+
transaction: <T>(callback: (tx: RawAccess) => Promise<T> | T) => Promise<T>;
|
|
117
117
|
/**
|
|
118
118
|
* Returns native SQLite metrics when the active runtime supports them.
|
|
119
119
|
*/
|
|
@@ -124,23 +124,7 @@ type RawAccess = {
|
|
|
124
124
|
close: () => Promise<void>;
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
-
declare
|
|
128
|
-
|
|
129
|
-
type VirtualFileSystem = _rivet_dev_agent_os_core.PlainMountConfig["driver"];
|
|
130
|
-
interface DatabaseVfsOptions {
|
|
131
|
-
/** The RawAccess database handle from the actor's db provider. */
|
|
132
|
-
db: RawAccess;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Create a VirtualFileSystem backed by SQLite.
|
|
136
|
-
*
|
|
137
|
-
* The returned filesystem stores all content and metadata in the
|
|
138
|
-
* `agent_os_fs_entries` table. The table must be created beforehand
|
|
139
|
-
* via `migrateAgentOsTables()`.
|
|
140
|
-
*/
|
|
141
|
-
declare function createDatabaseVfs(options: DatabaseVfsOptions): VirtualFileSystem;
|
|
142
|
-
|
|
143
|
-
declare const ActorsSchema: z.ZodRecord<z.ZodString, z.ZodCustom<BaseActorDefinition<any, any, any, any, any, any, any, any, any>, BaseActorDefinition<any, any, any, any, any, any, any, any, any>>>;
|
|
127
|
+
declare const ActorsSchema: z.ZodRecord<z.ZodString, z.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
|
|
144
128
|
type RegistryActors = z.infer<typeof ActorsSchema>;
|
|
145
129
|
declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
146
130
|
use: z.ZodRecord<z.ZodString, z.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
|
|
@@ -153,6 +137,7 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
153
137
|
}, z.core.$strip>>>;
|
|
154
138
|
maxIncomingMessageSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
155
139
|
maxOutgoingMessageSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
140
|
+
experimentalActorUds: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
156
141
|
runtime: z.ZodPipe<z.ZodOptional<z.ZodEnum<{
|
|
157
142
|
auto: "auto";
|
|
158
143
|
native: "native";
|
|
@@ -197,6 +182,8 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
197
182
|
httpPort: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
198
183
|
httpHost: z.ZodOptional<z.ZodString>;
|
|
199
184
|
startEngine: z.ZodDefault<z.ZodBoolean>;
|
|
185
|
+
engineHost: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
186
|
+
enginePort: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
200
187
|
engineVersion: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
201
188
|
configurePool: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
202
189
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -221,7 +208,7 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
221
208
|
envoyKey: z.ZodOptional<z.ZodString>;
|
|
222
209
|
}, z.core.$strip>>>;
|
|
223
210
|
shutdown: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
224
|
-
gracePeriodMs: z.
|
|
211
|
+
gracePeriodMs: z.ZodOptional<z.ZodNumber>;
|
|
225
212
|
disableSignalHandlers: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
226
213
|
}, z.core.$strip>>>;
|
|
227
214
|
}, z.core.$strip>, z.ZodTransform<{
|
|
@@ -248,6 +235,7 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
248
235
|
};
|
|
249
236
|
maxIncomingMessageSize: number;
|
|
250
237
|
maxOutgoingMessageSize: number;
|
|
238
|
+
experimentalActorUds: boolean;
|
|
251
239
|
runtime: "auto" | "native" | "wasm";
|
|
252
240
|
wasm: {
|
|
253
241
|
bindings?: typeof _rivetkit_rivetkit_wasm | undefined;
|
|
@@ -262,6 +250,8 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
262
250
|
httpBasePath: string;
|
|
263
251
|
httpPort: number;
|
|
264
252
|
startEngine: boolean;
|
|
253
|
+
engineHost: string;
|
|
254
|
+
enginePort: number;
|
|
265
255
|
engineVersion: string;
|
|
266
256
|
envoy: {
|
|
267
257
|
poolName: string;
|
|
@@ -270,8 +260,8 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
270
260
|
envoyKey?: string | undefined;
|
|
271
261
|
};
|
|
272
262
|
shutdown: {
|
|
273
|
-
gracePeriodMs: number;
|
|
274
263
|
disableSignalHandlers: boolean;
|
|
264
|
+
gracePeriodMs?: number | undefined;
|
|
275
265
|
};
|
|
276
266
|
staticDir?: string | undefined;
|
|
277
267
|
httpHost?: string | undefined;
|
|
@@ -293,6 +283,7 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
293
283
|
};
|
|
294
284
|
maxIncomingMessageSize: number;
|
|
295
285
|
maxOutgoingMessageSize: number;
|
|
286
|
+
experimentalActorUds: boolean;
|
|
296
287
|
runtime: "auto" | "native" | "wasm";
|
|
297
288
|
wasm: {
|
|
298
289
|
bindings?: typeof _rivetkit_rivetkit_wasm | undefined;
|
|
@@ -313,6 +304,8 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
313
304
|
httpBasePath: string;
|
|
314
305
|
httpPort: number;
|
|
315
306
|
startEngine: boolean;
|
|
307
|
+
engineHost: string;
|
|
308
|
+
enginePort: number;
|
|
316
309
|
engineVersion: string;
|
|
317
310
|
serverless: {
|
|
318
311
|
basePath: string;
|
|
@@ -327,8 +320,8 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
327
320
|
envoyKey?: string | undefined;
|
|
328
321
|
};
|
|
329
322
|
shutdown: {
|
|
330
|
-
gracePeriodMs: number;
|
|
331
323
|
disableSignalHandlers: boolean;
|
|
324
|
+
gracePeriodMs?: number | undefined;
|
|
332
325
|
};
|
|
333
326
|
staticDir?: string | undefined;
|
|
334
327
|
httpHost?: string | undefined;
|
|
@@ -375,7 +368,7 @@ interface QueueSchemaDefinition<TContext = any> {
|
|
|
375
368
|
type EventSchema<TContext = any> = PrimitiveSchema | EventSchemaDefinition<TContext>;
|
|
376
369
|
type QueueSchema = PrimitiveSchema | QueueSchemaDefinition<any> | QueueTypeToken<unknown, unknown, any>;
|
|
377
370
|
type EventSchemaConfig<TContext = any> = Record<string, EventSchema<TContext>>;
|
|
378
|
-
type QueueSchemaConfig<
|
|
371
|
+
type QueueSchemaConfig<_TContext = any> = Record<string, QueueSchema>;
|
|
379
372
|
type InferSchema<T> = T extends QueueSchemaDefinition<any> ? InferSchema<T["message"]> : T extends QueueTypeToken<infer M, unknown, any> ? M : T extends EventSchemaDefinition<any> ? InferSchema<T["schema"]> : T extends StandardSchemaV1<any, infer O> ? O : T extends EventTypeToken<infer R, any> ? R : never;
|
|
380
373
|
type InferSchemaMap<T extends Record<string, unknown>> = {
|
|
381
374
|
[K in keyof T]: InferSchema<T[K]>;
|
|
@@ -386,14 +379,16 @@ type InferQueueCompleteMap<T extends QueueSchemaConfig> = {
|
|
|
386
379
|
};
|
|
387
380
|
type InferEventArgs<T> = T extends readonly unknown[] ? number extends T["length"] ? [T] : T : [T];
|
|
388
381
|
|
|
389
|
-
interface BaseActorDefinition<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>,
|
|
390
|
-
readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q>;
|
|
382
|
+
interface BaseActorDefinition<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>, _R extends Actions<S, CP, CS, V, I, DB, E, Q> = Actions<S, CP, CS, V, I, DB, E, Q>> {
|
|
383
|
+
readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q, _R>;
|
|
384
|
+
}
|
|
385
|
+
interface AnyActorDefinition {
|
|
386
|
+
readonly config: any;
|
|
391
387
|
}
|
|
392
|
-
type AnyActorDefinition = BaseActorDefinition<any, any, any, any, any, any, any, any, any>;
|
|
393
388
|
declare class ActorDefinition<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>, R extends Actions<S, CP, CS, V, I, DB, E, Q> = Actions<S, CP, CS, V, I, DB, E, Q>> implements BaseActorDefinition<S, CP, CS, V, I, DB, E, Q, R> {
|
|
394
389
|
#private;
|
|
395
|
-
constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q>);
|
|
396
|
-
get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q>;
|
|
390
|
+
constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q, R>);
|
|
391
|
+
get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q, R>;
|
|
397
392
|
}
|
|
398
393
|
|
|
399
394
|
declare const EncodingSchema: z$1.ZodEnum<{
|
|
@@ -455,6 +450,7 @@ interface DeconstructedError {
|
|
|
455
450
|
code: string;
|
|
456
451
|
message: string;
|
|
457
452
|
metadata?: unknown;
|
|
453
|
+
actor?: ActorSpecifier;
|
|
458
454
|
}
|
|
459
455
|
|
|
460
456
|
interface RivetErrorOptions extends ErrorOptions {
|
|
@@ -464,12 +460,21 @@ interface RivetErrorOptions extends ErrorOptions {
|
|
|
464
460
|
metadata?: unknown;
|
|
465
461
|
/** Explicit HTTP status override for router responses. */
|
|
466
462
|
statusCode?: number;
|
|
463
|
+
/** Actor context associated with this error. */
|
|
464
|
+
actor?: ActorSpecifier;
|
|
465
|
+
}
|
|
466
|
+
/** Identifies the actor that was handling work when an error was produced. */
|
|
467
|
+
interface ActorSpecifier {
|
|
468
|
+
actorId: string;
|
|
469
|
+
generation: number;
|
|
470
|
+
key?: string;
|
|
467
471
|
}
|
|
468
472
|
declare class RivetError extends Error {
|
|
469
473
|
__type: "RivetError";
|
|
470
474
|
public: boolean;
|
|
471
475
|
metadata?: unknown;
|
|
472
476
|
statusCode: number;
|
|
477
|
+
actor?: ActorSpecifier;
|
|
473
478
|
readonly group: string;
|
|
474
479
|
readonly code: string;
|
|
475
480
|
static isRivetError(error: unknown): error is RivetError | DeconstructedError;
|
|
@@ -485,7 +490,6 @@ type GatewayTarget = {
|
|
|
485
490
|
directId: string;
|
|
486
491
|
} | ActorQuery;
|
|
487
492
|
interface GatewayRequestOptions {
|
|
488
|
-
bypassConnectable?: boolean;
|
|
489
493
|
skipReadyWait?: boolean;
|
|
490
494
|
}
|
|
491
495
|
interface EngineControlClient {
|
|
@@ -561,19 +565,375 @@ interface ActorOutput {
|
|
|
561
565
|
error?: unknown;
|
|
562
566
|
}
|
|
563
567
|
|
|
568
|
+
declare const handleBrand: unique symbol;
|
|
569
|
+
type OpaqueHandle<Name extends string> = {
|
|
570
|
+
readonly [handleBrand]: Name;
|
|
571
|
+
};
|
|
572
|
+
type RegistryHandle = OpaqueHandle<"registry">;
|
|
573
|
+
type ActorFactoryHandle = OpaqueHandle<"actorFactory">;
|
|
574
|
+
type ActorContextHandle = OpaqueHandle<"actorContext">;
|
|
575
|
+
type ConnHandle = OpaqueHandle<"conn">;
|
|
576
|
+
type WebSocketHandle = OpaqueHandle<"webSocket">;
|
|
577
|
+
type CancellationTokenHandle = OpaqueHandle<"cancellationToken">;
|
|
578
|
+
type RuntimeBytes = Uint8Array;
|
|
579
|
+
interface RuntimeActorKeySegment {
|
|
580
|
+
kind: string;
|
|
581
|
+
stringValue?: string;
|
|
582
|
+
numberValue?: number;
|
|
583
|
+
}
|
|
584
|
+
interface RuntimeHttpRequest {
|
|
585
|
+
method: string;
|
|
586
|
+
uri: string;
|
|
587
|
+
headers?: Record<string, string>;
|
|
588
|
+
body?: RuntimeBytes;
|
|
589
|
+
}
|
|
590
|
+
interface RuntimeStateDeltaPayload {
|
|
591
|
+
state?: RuntimeBytes;
|
|
592
|
+
connHibernation: Array<{
|
|
593
|
+
connId: string;
|
|
594
|
+
bytes: RuntimeBytes;
|
|
595
|
+
}>;
|
|
596
|
+
connHibernationRemoved: string[];
|
|
597
|
+
}
|
|
598
|
+
interface RuntimeRequestSaveOpts {
|
|
599
|
+
immediate?: boolean;
|
|
600
|
+
maxWaitMs?: number;
|
|
601
|
+
}
|
|
602
|
+
interface RuntimeInspectorSnapshot {
|
|
603
|
+
stateRevision: number;
|
|
604
|
+
connectionsRevision: number;
|
|
605
|
+
queueRevision: number;
|
|
606
|
+
activeConnections: number;
|
|
607
|
+
queueSize: number;
|
|
608
|
+
connectedClients: number;
|
|
609
|
+
}
|
|
610
|
+
interface RuntimeQueueMessage {
|
|
611
|
+
id(): bigint;
|
|
612
|
+
name(): string;
|
|
613
|
+
body(): RuntimeBytes;
|
|
614
|
+
createdAt(): number;
|
|
615
|
+
isCompletable(): boolean;
|
|
616
|
+
complete(response?: RuntimeBytes | undefined | null): Promise<void>;
|
|
617
|
+
}
|
|
618
|
+
interface RuntimeQueueInspectMessage {
|
|
619
|
+
id: number;
|
|
620
|
+
name: string;
|
|
621
|
+
createdAtMs: number;
|
|
622
|
+
}
|
|
623
|
+
interface RuntimeQueueNextBatchOptions {
|
|
624
|
+
names?: string[];
|
|
625
|
+
count?: number;
|
|
626
|
+
timeoutMs?: number;
|
|
627
|
+
completable?: boolean;
|
|
628
|
+
}
|
|
629
|
+
interface RuntimeQueueWaitOptions {
|
|
630
|
+
timeoutMs?: number;
|
|
631
|
+
completable?: boolean;
|
|
632
|
+
}
|
|
633
|
+
interface RuntimeQueueEnqueueAndWaitOptions {
|
|
634
|
+
timeoutMs?: number;
|
|
635
|
+
}
|
|
636
|
+
interface RuntimeQueueTryNextBatchOptions {
|
|
637
|
+
names?: string[];
|
|
638
|
+
count?: number;
|
|
639
|
+
completable?: boolean;
|
|
640
|
+
}
|
|
641
|
+
interface RuntimeKvListOptions {
|
|
642
|
+
reverse?: boolean;
|
|
643
|
+
limit?: number;
|
|
644
|
+
}
|
|
645
|
+
interface RuntimeKvEntry {
|
|
646
|
+
key: RuntimeBytes;
|
|
647
|
+
value: RuntimeBytes;
|
|
648
|
+
}
|
|
649
|
+
type RuntimeSqlBindNoValues = {
|
|
650
|
+
intValue?: never;
|
|
651
|
+
floatValue?: never;
|
|
652
|
+
textValue?: never;
|
|
653
|
+
blobValue?: never;
|
|
654
|
+
};
|
|
655
|
+
type RuntimeSqlBindParam = ({
|
|
656
|
+
kind: "null";
|
|
657
|
+
} & RuntimeSqlBindNoValues) | {
|
|
658
|
+
kind: "int";
|
|
659
|
+
intValue: number;
|
|
660
|
+
floatValue?: never;
|
|
661
|
+
textValue?: never;
|
|
662
|
+
blobValue?: never;
|
|
663
|
+
} | {
|
|
664
|
+
kind: "float";
|
|
665
|
+
intValue?: never;
|
|
666
|
+
floatValue: number;
|
|
667
|
+
textValue?: never;
|
|
668
|
+
blobValue?: never;
|
|
669
|
+
} | {
|
|
670
|
+
kind: "text";
|
|
671
|
+
intValue?: never;
|
|
672
|
+
floatValue?: never;
|
|
673
|
+
textValue: string;
|
|
674
|
+
blobValue?: never;
|
|
675
|
+
} | {
|
|
676
|
+
kind: "blob";
|
|
677
|
+
intValue?: never;
|
|
678
|
+
floatValue?: never;
|
|
679
|
+
textValue?: never;
|
|
680
|
+
blobValue: RuntimeBytes;
|
|
681
|
+
};
|
|
682
|
+
type RuntimeSqlBindParams = RuntimeSqlBindParam[] | null;
|
|
683
|
+
interface RuntimeSqlLeaseOptions {
|
|
684
|
+
key: string;
|
|
685
|
+
timeoutMs?: number;
|
|
686
|
+
}
|
|
687
|
+
interface RuntimeActorUdsEndpointInfo {
|
|
688
|
+
path: string;
|
|
689
|
+
token: string;
|
|
690
|
+
}
|
|
691
|
+
interface RuntimeSqlQueryResult {
|
|
692
|
+
columns: string[];
|
|
693
|
+
rows: unknown[][];
|
|
694
|
+
}
|
|
695
|
+
type RuntimeSqlExecResult = RuntimeSqlQueryResult;
|
|
696
|
+
interface RuntimeSqlExecuteResult extends RuntimeSqlQueryResult {
|
|
697
|
+
changes: number;
|
|
698
|
+
lastInsertRowId?: number | null;
|
|
699
|
+
}
|
|
700
|
+
interface RuntimeSqlRunResult {
|
|
701
|
+
changes: number;
|
|
702
|
+
}
|
|
703
|
+
interface RuntimeActorConfig {
|
|
704
|
+
name?: string;
|
|
705
|
+
icon?: string;
|
|
706
|
+
hasDatabase?: boolean;
|
|
707
|
+
remoteSqlite?: boolean;
|
|
708
|
+
experimentalActorUds?: boolean;
|
|
709
|
+
hasState?: boolean;
|
|
710
|
+
canHibernateWebsocket?: boolean;
|
|
711
|
+
stateSaveIntervalMs?: number;
|
|
712
|
+
createStateTimeoutMs?: number;
|
|
713
|
+
onCreateTimeoutMs?: number;
|
|
714
|
+
createVarsTimeoutMs?: number;
|
|
715
|
+
createConnStateTimeoutMs?: number;
|
|
716
|
+
onBeforeConnectTimeoutMs?: number;
|
|
717
|
+
onConnectTimeoutMs?: number;
|
|
718
|
+
onMigrateTimeoutMs?: number;
|
|
719
|
+
onWakeTimeoutMs?: number;
|
|
720
|
+
onBeforeActorStartTimeoutMs?: number;
|
|
721
|
+
actionTimeoutMs?: number;
|
|
722
|
+
onRequestTimeoutMs?: number;
|
|
723
|
+
sleepTimeoutMs?: number;
|
|
724
|
+
noSleep?: boolean;
|
|
725
|
+
sleepGracePeriodMs?: number;
|
|
726
|
+
connectionLivenessTimeoutMs?: number;
|
|
727
|
+
connectionLivenessIntervalMs?: number;
|
|
728
|
+
maxQueueSize?: number;
|
|
729
|
+
maxQueueMessageSize?: number;
|
|
730
|
+
maxIncomingMessageSize?: number;
|
|
731
|
+
maxOutgoingMessageSize?: number;
|
|
732
|
+
preloadMaxWorkflowBytes?: number;
|
|
733
|
+
preloadMaxConnectionsBytes?: number;
|
|
734
|
+
actions?: Array<{
|
|
735
|
+
name: string;
|
|
736
|
+
}>;
|
|
737
|
+
inspectorTabs?: Array<RuntimeInspectorTabEntry>;
|
|
738
|
+
}
|
|
739
|
+
interface RuntimeInspectorTabEntry {
|
|
740
|
+
id: string;
|
|
741
|
+
/** Required for custom entries; omitted for built-in hides. */
|
|
742
|
+
label?: string;
|
|
743
|
+
/**
|
|
744
|
+
* Required for custom entries — absolute path to the source directory.
|
|
745
|
+
* Resolved on the TS side before being handed to the runtime.
|
|
746
|
+
*/
|
|
747
|
+
source?: string;
|
|
748
|
+
/** Optional icon id for custom entries. */
|
|
749
|
+
icon?: string;
|
|
750
|
+
/** Set to true for built-in hide entries. */
|
|
751
|
+
hidden?: boolean;
|
|
752
|
+
}
|
|
753
|
+
interface RuntimeServeConfig {
|
|
754
|
+
version: number;
|
|
755
|
+
endpoint: string;
|
|
756
|
+
token?: string;
|
|
757
|
+
namespace: string;
|
|
758
|
+
poolName: string;
|
|
759
|
+
engineBinaryPath?: string;
|
|
760
|
+
engineHost?: string;
|
|
761
|
+
enginePort?: number;
|
|
762
|
+
handleInspectorHttpInRuntime?: boolean;
|
|
763
|
+
inspectorTestToken?: string;
|
|
764
|
+
serverlessBasePath?: string;
|
|
765
|
+
serverlessPackageVersion: string;
|
|
766
|
+
serverlessClientEndpoint?: string;
|
|
767
|
+
serverlessClientNamespace?: string;
|
|
768
|
+
serverlessClientToken?: string;
|
|
769
|
+
serverlessValidateEndpoint: boolean;
|
|
770
|
+
serverlessMaxStartPayloadBytes: number;
|
|
771
|
+
}
|
|
772
|
+
interface RuntimeListenerConfig {
|
|
773
|
+
port: number;
|
|
774
|
+
host?: string;
|
|
775
|
+
publicDir?: string;
|
|
776
|
+
}
|
|
777
|
+
interface RuntimeServerlessRequest {
|
|
778
|
+
method: string;
|
|
779
|
+
url: string;
|
|
780
|
+
headers: Record<string, string>;
|
|
781
|
+
body: RuntimeBytes;
|
|
782
|
+
}
|
|
783
|
+
interface RuntimeServerlessResponseHead {
|
|
784
|
+
status: number;
|
|
785
|
+
headers: Record<string, string>;
|
|
786
|
+
}
|
|
787
|
+
interface RuntimeRegistryRouteResponse {
|
|
788
|
+
status: number;
|
|
789
|
+
headers: Record<string, string>;
|
|
790
|
+
body: RuntimeBytes;
|
|
791
|
+
}
|
|
792
|
+
type RuntimeServerlessStreamEvent = {
|
|
793
|
+
kind: "chunk";
|
|
794
|
+
chunk?: RuntimeBytes;
|
|
795
|
+
} | {
|
|
796
|
+
kind: "end";
|
|
797
|
+
error?: {
|
|
798
|
+
group: string;
|
|
799
|
+
code: string;
|
|
800
|
+
message: string;
|
|
801
|
+
};
|
|
802
|
+
};
|
|
803
|
+
type RuntimeServerlessStreamCallback = (error: unknown, event?: RuntimeServerlessStreamEvent) => unknown;
|
|
804
|
+
type RuntimeWebSocketEvent = {
|
|
805
|
+
kind: "message";
|
|
806
|
+
data: string | RuntimeBytes;
|
|
807
|
+
binary: boolean;
|
|
808
|
+
messageIndex?: number;
|
|
809
|
+
} | {
|
|
810
|
+
kind: "close";
|
|
811
|
+
code: number;
|
|
812
|
+
reason: string;
|
|
813
|
+
wasClean: boolean;
|
|
814
|
+
};
|
|
815
|
+
interface CoreRuntime {
|
|
816
|
+
readonly kind: "napi" | "wasm";
|
|
817
|
+
createRegistry(): RegistryHandle;
|
|
818
|
+
registerActor(registry: RegistryHandle, name: string, factory: ActorFactoryHandle): void;
|
|
819
|
+
serveRegistry(registry: RegistryHandle, config: RuntimeServeConfig): Promise<void>;
|
|
820
|
+
shutdownRegistry(registry: RegistryHandle): Promise<void>;
|
|
821
|
+
registryActorStopThresholdMs?(registry: RegistryHandle): Promise<number | undefined>;
|
|
822
|
+
handleServerlessRequest(registry: RegistryHandle, req: RuntimeServerlessRequest, onStreamEvent: RuntimeServerlessStreamCallback, cancelToken: CancellationTokenHandle, config: RuntimeServeConfig): Promise<RuntimeServerlessResponseHead>;
|
|
823
|
+
serveListener(registry: RegistryHandle, listener: RuntimeListenerConfig, config: RuntimeServeConfig): Promise<void>;
|
|
824
|
+
registryHealth?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
825
|
+
registryMetadata?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
826
|
+
registryMetrics?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
827
|
+
createActorFactory(callbacks: object, config?: RuntimeActorConfig | undefined | null): ActorFactoryHandle;
|
|
828
|
+
createCancellationToken(): CancellationTokenHandle;
|
|
829
|
+
cancellationTokenAborted(token: CancellationTokenHandle): boolean;
|
|
830
|
+
cancelCancellationToken(token: CancellationTokenHandle): void;
|
|
831
|
+
onCancellationTokenCancelled(token: CancellationTokenHandle, callback: (...args: unknown[]) => unknown): void;
|
|
832
|
+
actorState(ctx: ActorContextHandle): RuntimeBytes;
|
|
833
|
+
actorBeginOnStateChange(ctx: ActorContextHandle): void;
|
|
834
|
+
actorEndOnStateChange(ctx: ActorContextHandle): void;
|
|
835
|
+
actorSetAlarm(ctx: ActorContextHandle, timestampMs?: number | undefined | null): void;
|
|
836
|
+
actorRequestSave(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): void;
|
|
837
|
+
actorRequestSaveAndWait(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): Promise<void>;
|
|
838
|
+
actorInspectorSnapshot(ctx: ActorContextHandle): RuntimeInspectorSnapshot;
|
|
839
|
+
actorDecodeInspectorRequest(ctx: ActorContextHandle, bytes: RuntimeBytes, advertisedVersion: number): RuntimeBytes;
|
|
840
|
+
actorEncodeInspectorResponse(ctx: ActorContextHandle, bytes: RuntimeBytes, targetVersion: number): RuntimeBytes;
|
|
841
|
+
actorVerifyInspectorAuth(ctx: ActorContextHandle, bearerToken?: string | undefined | null): Promise<void>;
|
|
842
|
+
actorQueueHibernationRemoval(ctx: ActorContextHandle, connId: string): void;
|
|
843
|
+
actorTakePendingHibernationChanges(ctx: ActorContextHandle): string[];
|
|
844
|
+
actorDirtyHibernatableConns(ctx: ActorContextHandle): ConnHandle[];
|
|
845
|
+
actorSaveState(ctx: ActorContextHandle, payload: RuntimeStateDeltaPayload): Promise<void>;
|
|
846
|
+
actorId(ctx: ActorContextHandle): string;
|
|
847
|
+
actorName(ctx: ActorContextHandle): string;
|
|
848
|
+
actorKey(ctx: ActorContextHandle): RuntimeActorKeySegment[];
|
|
849
|
+
actorRegion(ctx: ActorContextHandle): string;
|
|
850
|
+
actorSleep(ctx: ActorContextHandle): void;
|
|
851
|
+
actorDestroy(ctx: ActorContextHandle): void;
|
|
852
|
+
actorAbortSignal(ctx: ActorContextHandle): AbortSignal;
|
|
853
|
+
actorConns(ctx: ActorContextHandle): ConnHandle[];
|
|
854
|
+
actorConnectConn(ctx: ActorContextHandle, params: RuntimeBytes, request?: RuntimeHttpRequest | undefined | null): Promise<ConnHandle>;
|
|
855
|
+
actorBroadcast(ctx: ActorContextHandle, name: string, args: RuntimeBytes): void;
|
|
856
|
+
actorWaitUntil(ctx: ActorContextHandle, promise: Promise<unknown>): void;
|
|
857
|
+
actorWaitForTrackedShutdownWork(ctx: ActorContextHandle): Promise<boolean>;
|
|
858
|
+
actorWaitForTrackedShutdownWorkUnbounded(ctx: ActorContextHandle): Promise<void>;
|
|
859
|
+
actorKeepAwake(ctx: ActorContextHandle, promise: Promise<unknown>): void;
|
|
860
|
+
actorBeginKeepAwake(ctx: ActorContextHandle): number;
|
|
861
|
+
actorEndKeepAwake(ctx: ActorContextHandle, regionId: number): void;
|
|
862
|
+
actorRegisterTask(ctx: ActorContextHandle, promise: Promise<unknown>): void;
|
|
863
|
+
actorRuntimeState(ctx: ActorContextHandle): object;
|
|
864
|
+
actorClearRuntimeState(ctx: ActorContextHandle): void;
|
|
865
|
+
actorRestartRunHandler(ctx: ActorContextHandle): void;
|
|
866
|
+
actorBeginWebsocketCallback(ctx: ActorContextHandle): number;
|
|
867
|
+
actorEndWebsocketCallback(ctx: ActorContextHandle, regionId: number): void;
|
|
868
|
+
actorKvGet(ctx: ActorContextHandle, key: RuntimeBytes): Promise<RuntimeBytes | null>;
|
|
869
|
+
actorKvPut(ctx: ActorContextHandle, key: RuntimeBytes, value: RuntimeBytes): Promise<void>;
|
|
870
|
+
actorKvDelete(ctx: ActorContextHandle, key: RuntimeBytes): Promise<void>;
|
|
871
|
+
actorKvDeleteRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes): Promise<void>;
|
|
872
|
+
actorKvListPrefix(ctx: ActorContextHandle, prefix: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
|
|
873
|
+
actorKvListRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
|
|
874
|
+
actorKvBatchGet(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<Array<RuntimeBytes | undefined | null>>;
|
|
875
|
+
actorKvBatchPut(ctx: ActorContextHandle, entries: RuntimeKvEntry[]): Promise<void>;
|
|
876
|
+
actorKvBatchDelete(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<void>;
|
|
877
|
+
actorSqlExec(ctx: ActorContextHandle, sql: string, lease?: RuntimeSqlLeaseOptions): Promise<RuntimeSqlExecResult>;
|
|
878
|
+
actorSqlExecute(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams, lease?: RuntimeSqlLeaseOptions): Promise<RuntimeSqlExecuteResult>;
|
|
879
|
+
actorSqlQuery(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlQueryResult>;
|
|
880
|
+
actorSqlRun(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlRunResult>;
|
|
881
|
+
actorSqlMetrics(ctx: ActorContextHandle): SqliteNativeMetrics | null;
|
|
882
|
+
actorSqlTakeLastKvError(ctx: ActorContextHandle): string | null;
|
|
883
|
+
actorSqlClose(ctx: ActorContextHandle): Promise<void>;
|
|
884
|
+
actorUdsProvision(ctx: ActorContextHandle): Promise<RuntimeActorUdsEndpointInfo>;
|
|
885
|
+
actorQueueSend(ctx: ActorContextHandle, name: string, body: RuntimeBytes): Promise<RuntimeQueueMessage>;
|
|
886
|
+
actorQueueNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueNextBatchOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage[]>;
|
|
887
|
+
actorQueueWaitForNames(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage>;
|
|
888
|
+
actorQueueWaitForNamesAvailable(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<void>;
|
|
889
|
+
actorQueueEnqueueAndWait(ctx: ActorContextHandle, name: string, body: RuntimeBytes, options?: RuntimeQueueEnqueueAndWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeBytes | null>;
|
|
890
|
+
actorQueueTryNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueTryNextBatchOptions | undefined | null): RuntimeQueueMessage[];
|
|
891
|
+
actorQueueMaxSize(ctx: ActorContextHandle): number;
|
|
892
|
+
actorQueueInspectMessages(ctx: ActorContextHandle): Promise<RuntimeQueueInspectMessage[]>;
|
|
893
|
+
actorQueueReset(ctx: ActorContextHandle): Promise<void>;
|
|
894
|
+
actorScheduleAfter(ctx: ActorContextHandle, durationMs: number, actionName: string, args: RuntimeBytes): void;
|
|
895
|
+
actorScheduleAt(ctx: ActorContextHandle, timestampMs: number, actionName: string, args: RuntimeBytes): void;
|
|
896
|
+
connId(conn: ConnHandle): string;
|
|
897
|
+
connParams(conn: ConnHandle): RuntimeBytes;
|
|
898
|
+
connState(conn: ConnHandle): RuntimeBytes;
|
|
899
|
+
connSetState(conn: ConnHandle, state: RuntimeBytes): void;
|
|
900
|
+
connIsHibernatable(conn: ConnHandle): boolean;
|
|
901
|
+
connSend(conn: ConnHandle, name: string, args: RuntimeBytes): void;
|
|
902
|
+
connDisconnect(conn: ConnHandle, reason?: string | undefined | null): Promise<void>;
|
|
903
|
+
webSocketSend(ws: WebSocketHandle, data: RuntimeBytes, binary: boolean): void;
|
|
904
|
+
webSocketClose(ws: WebSocketHandle, code?: number | undefined | null, reason?: string | undefined | null): Promise<void>;
|
|
905
|
+
webSocketSetEventCallback(ws: WebSocketHandle, callback: (event: RuntimeWebSocketEvent) => void): void;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
declare function buildConfiguredRegistry(config: RegistryConfig): Promise<{
|
|
909
|
+
runtime: CoreRuntime;
|
|
910
|
+
registry: RegistryHandle;
|
|
911
|
+
serveConfig: RuntimeServeConfig;
|
|
912
|
+
}>;
|
|
913
|
+
|
|
564
914
|
type FetchHandler = (request: Request, ...args: any) => Response | Promise<Response>;
|
|
565
915
|
interface ServerlessHandler {
|
|
566
916
|
fetch: FetchHandler;
|
|
567
917
|
}
|
|
568
|
-
interface
|
|
569
|
-
|
|
570
|
-
|
|
918
|
+
interface RegistryRoutes {
|
|
919
|
+
health(): Promise<Response>;
|
|
920
|
+
metadata(): Promise<Response>;
|
|
921
|
+
prometheusMetrics(request?: Request): Promise<Response>;
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* Injectable dependencies for {@link Registry}. Production code uses the
|
|
925
|
+
* defaults. Tests override `buildConfiguredRegistry` to drive lifecycle
|
|
926
|
+
* orchestration against a fake `CoreRuntime` without an engine.
|
|
927
|
+
*/
|
|
928
|
+
interface RegistryDeps {
|
|
929
|
+
buildConfiguredRegistry: typeof buildConfiguredRegistry;
|
|
571
930
|
}
|
|
572
931
|
declare class Registry<A extends RegistryActors> {
|
|
573
932
|
#private;
|
|
933
|
+
readonly routes: RegistryRoutes;
|
|
574
934
|
get config(): RegistryConfigInput<A>;
|
|
575
935
|
parseConfig(): RegistryConfig;
|
|
576
|
-
constructor(config: RegistryConfigInput<A>);
|
|
936
|
+
constructor(config: RegistryConfigInput<A>, deps?: Partial<RegistryDeps>);
|
|
577
937
|
/**
|
|
578
938
|
* Handle an incoming HTTP request for serverless deployments.
|
|
579
939
|
*
|
|
@@ -594,11 +954,57 @@ declare class Registry<A extends RegistryActors> {
|
|
|
594
954
|
* ```
|
|
595
955
|
*/
|
|
596
956
|
serve(): ServerlessHandler;
|
|
597
|
-
|
|
957
|
+
/**
|
|
958
|
+
* Bind an HTTP listener provided by the native (Rust) runtime and serve
|
|
959
|
+
* the registry's serverless endpoints over it. Resolves only after the
|
|
960
|
+
* registry is shut down (SIGINT/SIGTERM or `nativeRegistry.shutdown()`).
|
|
961
|
+
*
|
|
962
|
+
* @param opts.port Port to listen on. Defaults to `process.env.RIVET_PORT`
|
|
963
|
+
* if set, otherwise 3000.
|
|
964
|
+
* @param opts.host Address to bind. Defaults to `0.0.0.0`.
|
|
965
|
+
* @param opts.publicDir If set, serves static files from this directory
|
|
966
|
+
* as a fallback below the framework routes.
|
|
967
|
+
*
|
|
968
|
+
* @example
|
|
969
|
+
* ```ts
|
|
970
|
+
* await registry.listen();
|
|
971
|
+
* await registry.listen({ port: 8080, publicDir: "./public" });
|
|
972
|
+
* ```
|
|
973
|
+
*/
|
|
974
|
+
listen(opts?: {
|
|
975
|
+
port?: number;
|
|
976
|
+
host?: string;
|
|
977
|
+
publicDir?: string;
|
|
978
|
+
}): Promise<void>;
|
|
979
|
+
/**
|
|
980
|
+
* Gracefully drains all live registries.
|
|
981
|
+
*
|
|
982
|
+
* Programmatic counterpart to the SIGINT/SIGTERM handlers: tears down
|
|
983
|
+
* every live `CoreRegistry` (both `start()` and `handler()` modes) and
|
|
984
|
+
* waits for the serve promise to resolve, all bounded by the shutdown
|
|
985
|
+
* grace period. Unlike a signal-driven shutdown, this does not re-raise a
|
|
986
|
+
* signal or exit the process. The caller owns process lifetime.
|
|
987
|
+
*
|
|
988
|
+
* Idempotent: concurrent or repeated calls share a single drain. Safe to
|
|
989
|
+
* call even if nothing has been started.
|
|
990
|
+
*
|
|
991
|
+
* @example
|
|
992
|
+
* ```ts
|
|
993
|
+
* const registry = setup({ use: { counter } });
|
|
994
|
+
* registry.start();
|
|
995
|
+
* // ...later, on your own shutdown trigger:
|
|
996
|
+
* await registry.shutdown();
|
|
997
|
+
* ```
|
|
998
|
+
*/
|
|
999
|
+
shutdown(): Promise<void>;
|
|
598
1000
|
startEnvoy(): void;
|
|
599
1001
|
/**
|
|
600
1002
|
* Starts the actor envoy for standalone server deployments.
|
|
601
1003
|
*
|
|
1004
|
+
* Set `RIVETKIT_RUNTIME_MODE=serverless` to instead bind an HTTP listener
|
|
1005
|
+
* via `listen()` (Mode B). Mode A (envoy) and Mode B (listener) are
|
|
1006
|
+
* mutually exclusive per registry instance.
|
|
1007
|
+
*
|
|
602
1008
|
* @example
|
|
603
1009
|
* ```ts
|
|
604
1010
|
* const registry = setup({ use: { counter } });
|
|
@@ -633,8 +1039,13 @@ interface QueueSendResult<TResponse = unknown> {
|
|
|
633
1039
|
* @returns {Promise<Response>}
|
|
634
1040
|
*/
|
|
635
1041
|
type ActorActionFunction<Args extends Array<unknown> = unknown[], Response = unknown> = (...args: Args extends [unknown, ...infer Rest] ? Rest : Args) => Promise<Response>;
|
|
1042
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
1043
|
+
type LooseEventSubscribe = (eventName: string, callback: (...args: any[]) => void) => () => void;
|
|
1044
|
+
type ActorActionMap<R> = {
|
|
1045
|
+
[K in keyof NonNullable<R>]: NonNullable<R>[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Awaited<Return>> : never;
|
|
1046
|
+
};
|
|
1047
|
+
type ActionsOf<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<any, any, any, any, any, any, any, any, infer R> ? R : never;
|
|
636
1048
|
interface ActorGatewayOptions {
|
|
637
|
-
bypassConnectable?: boolean;
|
|
638
1049
|
skipReadyWait?: boolean;
|
|
639
1050
|
}
|
|
640
1051
|
interface ActorActionOptions extends ActorGatewayOptions {
|
|
@@ -646,9 +1057,7 @@ type ActorWebSocketOptions = ActorGatewayOptions;
|
|
|
646
1057
|
/**
|
|
647
1058
|
* Maps action methods from actor definition to typed function signatures.
|
|
648
1059
|
*/
|
|
649
|
-
type ActorDefinitionActions<AD extends AnyActorDefinition> = AD extends
|
|
650
|
-
[K in keyof R]: R[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Return> : never;
|
|
651
|
-
} : never;
|
|
1060
|
+
type ActorDefinitionActions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? Record<string, ActorActionFunction<any[], any>> : ActorActionMap<ActionsOf<AD>>;
|
|
652
1061
|
type ActorQueueSend<TQueues extends QueueSchemaConfig> = {
|
|
653
1062
|
<K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options: QueueSendWaitOptions): Promise<QueueSendResult<InferQueueCompleteMap<TQueues>[K]>>;
|
|
654
1063
|
<K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options?: QueueSendNoWaitOptions): Promise<void>;
|
|
@@ -659,13 +1068,31 @@ type ActorEventSubscribe<TEvents extends EventSchemaConfig> = {
|
|
|
659
1068
|
<K extends keyof TEvents & string>(eventName: K, callback: (...args: InferEventArgs<InferSchemaMap<TEvents>[K]>) => void): () => void;
|
|
660
1069
|
(eventName: keyof TEvents extends never ? string : never, callback: (...args: any[]) => void): () => void;
|
|
661
1070
|
};
|
|
662
|
-
type ActorDefinitionQueueSend<AD extends AnyActorDefinition> = AD
|
|
1071
|
+
type ActorDefinitionQueueSend<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
|
|
1072
|
+
send: ActorQueueSend<Record<string, any>>;
|
|
1073
|
+
} : AD extends {
|
|
1074
|
+
config: {
|
|
1075
|
+
queues?: infer Q;
|
|
1076
|
+
};
|
|
1077
|
+
} ? Q extends QueueSchemaConfig ? {
|
|
1078
|
+
send: ActorQueueSend<Q>;
|
|
1079
|
+
} : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, any, infer Q, any> ? Q extends QueueSchemaConfig ? {
|
|
663
1080
|
send: ActorQueueSend<Q>;
|
|
664
|
-
} :
|
|
665
|
-
type ActorDefinitionEventSubscriptions<AD extends AnyActorDefinition> = AD
|
|
1081
|
+
} : {} : {};
|
|
1082
|
+
type ActorDefinitionEventSubscriptions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
|
|
1083
|
+
on: LooseEventSubscribe;
|
|
1084
|
+
once: LooseEventSubscribe;
|
|
1085
|
+
} : AD extends {
|
|
1086
|
+
config: {
|
|
1087
|
+
events?: infer E;
|
|
1088
|
+
};
|
|
1089
|
+
} ? E extends EventSchemaConfig ? {
|
|
666
1090
|
on: ActorEventSubscribe<E>;
|
|
667
1091
|
once: ActorEventSubscribe<E>;
|
|
668
|
-
} :
|
|
1092
|
+
} : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, infer E, any, any> ? E extends EventSchemaConfig ? {
|
|
1093
|
+
on: ActorEventSubscribe<E>;
|
|
1094
|
+
once: ActorEventSubscribe<E>;
|
|
1095
|
+
} : {} : {};
|
|
669
1096
|
|
|
670
1097
|
type ActorResolutionState = ActorQuery;
|
|
671
1098
|
|
|
@@ -1091,6 +1518,7 @@ type Client<A extends Registry<any>> = ClientRaw & {
|
|
|
1091
1518
|
};
|
|
1092
1519
|
|
|
1093
1520
|
declare const ACTOR_CONTEXT_INTERNAL_SYMBOL: unique symbol;
|
|
1521
|
+
declare const RAW_STATE_SYMBOL: unique symbol;
|
|
1094
1522
|
interface ActorLogger {
|
|
1095
1523
|
level: any;
|
|
1096
1524
|
fatal: any;
|
|
@@ -1123,6 +1551,10 @@ type ActorKvListOptions<T extends ActorKvValueType = "text", K extends ActorKvKe
|
|
|
1123
1551
|
limit?: number;
|
|
1124
1552
|
};
|
|
1125
1553
|
type ActorClientFor<T> = T extends Registry<any> ? Client<T> : T;
|
|
1554
|
+
/**
|
|
1555
|
+
* @deprecated Actor KV is deprecated. Use embedded SQLite (`c.db` / `c.sql`)
|
|
1556
|
+
* or actor state instead.
|
|
1557
|
+
*/
|
|
1126
1558
|
interface ActorKv {
|
|
1127
1559
|
get<T extends ActorKvValueType = "text">(key: Uint8Array | string, options?: ActorKvValueOptions<T>): Promise<ActorKvValueTypeMap[T] | null>;
|
|
1128
1560
|
put<T extends ActorKvValueType = "text">(key: Uint8Array | string, value: Uint8Array | string | ArrayBuffer, options?: ActorKvValueOptions<T>): Promise<void>;
|
|
@@ -1199,7 +1631,7 @@ interface ActorQueue<TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
|
1199
1631
|
iter<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueIterOptions<TName, TCompletable>): AsyncIterable<any>;
|
|
1200
1632
|
[key: string]: any;
|
|
1201
1633
|
}
|
|
1202
|
-
interface Conn<
|
|
1634
|
+
interface Conn<_TState = unknown, TConnParams = unknown, TConnState = unknown, _TVars = unknown, _TInput = unknown, _TDatabase extends AnyDatabaseProvider = AnyDatabaseProvider, _TEvents extends EventSchemaConfig = Record<never, never>, _TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
1203
1635
|
id: string;
|
|
1204
1636
|
params: TConnParams;
|
|
1205
1637
|
state: TConnState;
|
|
@@ -1210,8 +1642,14 @@ interface Conn<TState = unknown, TConnParams = unknown, TConnState = unknown, TV
|
|
|
1210
1642
|
}
|
|
1211
1643
|
interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
1212
1644
|
[ACTOR_CONTEXT_INTERNAL_SYMBOL]?: unknown;
|
|
1645
|
+
/** Returns the raw unwrapped state without the write-through proxy. */
|
|
1646
|
+
[RAW_STATE_SYMBOL](): TState;
|
|
1213
1647
|
state: TState;
|
|
1214
1648
|
vars: TVars;
|
|
1649
|
+
/**
|
|
1650
|
+
* @deprecated Actor KV is deprecated. Use embedded SQLite (`db` / `sql`)
|
|
1651
|
+
* or actor state instead.
|
|
1652
|
+
*/
|
|
1215
1653
|
readonly kv: ActorKv;
|
|
1216
1654
|
readonly db: InferDatabaseClient<TDatabase>;
|
|
1217
1655
|
readonly schedule: ActorSchedule;
|
|
@@ -1220,6 +1658,11 @@ interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase
|
|
|
1220
1658
|
readonly name: string;
|
|
1221
1659
|
readonly key: string[];
|
|
1222
1660
|
readonly region: string;
|
|
1661
|
+
/** Provisions credentials for the experimental local actor Unix socket API. */
|
|
1662
|
+
actorUds(): Promise<{
|
|
1663
|
+
path: string;
|
|
1664
|
+
token: string;
|
|
1665
|
+
}>;
|
|
1223
1666
|
readonly conns: Map<string, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>;
|
|
1224
1667
|
readonly log: ActorLogger;
|
|
1225
1668
|
readonly abortSignal: AbortSignal;
|
|
@@ -1336,8 +1779,27 @@ declare const ActorConfigSchema: z$1.ZodObject<{
|
|
|
1336
1779
|
preloadMaxWorkflowBytes: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1337
1780
|
preloadMaxConnectionsBytes: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1338
1781
|
}, z$1.core.$strict>>;
|
|
1782
|
+
inspector: z$1.ZodOptional<z$1.ZodObject<{
|
|
1783
|
+
tabs: z$1.ZodDefault<z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodObject<{
|
|
1784
|
+
id: z$1.ZodString;
|
|
1785
|
+
label: z$1.ZodString;
|
|
1786
|
+
source: z$1.ZodString;
|
|
1787
|
+
icon: z$1.ZodOptional<z$1.ZodString>;
|
|
1788
|
+
hidden: z$1.ZodOptional<z$1.ZodLiteral<false>>;
|
|
1789
|
+
}, z$1.core.$strict>, z$1.ZodObject<{
|
|
1790
|
+
id: z$1.ZodEnum<{
|
|
1791
|
+
state: "state";
|
|
1792
|
+
queue: "queue";
|
|
1793
|
+
workflow: "workflow";
|
|
1794
|
+
database: "database";
|
|
1795
|
+
connections: "connections";
|
|
1796
|
+
console: "console";
|
|
1797
|
+
}>;
|
|
1798
|
+
hidden: z$1.ZodLiteral<true>;
|
|
1799
|
+
}, z$1.core.$strict>]>>>;
|
|
1800
|
+
}, z$1.core.$strict>>;
|
|
1339
1801
|
}, z$1.core.$strict>;
|
|
1340
|
-
type CreateState<TState,
|
|
1802
|
+
type CreateState<TState, _TConnParams, _TConnState, _TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
|
|
1341
1803
|
state: TState;
|
|
1342
1804
|
} | {
|
|
1343
1805
|
createState: (c: CreateContext<TState, TInput, TDatabase, TEvents, TQueues>, input: TInput) => TState | Promise<TState>;
|
|
@@ -1350,7 +1812,7 @@ type CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase e
|
|
|
1350
1812
|
/**
|
|
1351
1813
|
* @experimental
|
|
1352
1814
|
*/
|
|
1353
|
-
type CreateVars<TState,
|
|
1815
|
+
type CreateVars<TState, _TConnParams, _TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
|
|
1354
1816
|
/**
|
|
1355
1817
|
* @experimental
|
|
1356
1818
|
*/
|
|
@@ -1418,7 +1880,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
|
|
|
1418
1880
|
* shutdown window (`sleepGracePeriod`) cover deferred work.
|
|
1419
1881
|
*
|
|
1420
1882
|
* The handler receives an abort signal via `c.abortSignal` and a
|
|
1421
|
-
* `c.aborted` alias
|
|
1883
|
+
* `c.aborted` alias. Use these to gracefully exit when shutdown starts.
|
|
1422
1884
|
*
|
|
1423
1885
|
* If this handler exits, the actor will follow the normal idle sleep timeout
|
|
1424
1886
|
* once it becomes idle.
|
|
@@ -1447,10 +1909,11 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
|
|
|
1447
1909
|
* Called before a client connects to the actor.
|
|
1448
1910
|
*
|
|
1449
1911
|
* Use this hook to determine if a connection should be accepted
|
|
1450
|
-
* and to
|
|
1912
|
+
* and to validate client-provided parameters. The pending connection
|
|
1913
|
+
* is not visible in `c.conns` while this hook runs.
|
|
1451
1914
|
*
|
|
1452
1915
|
* @param opts Connection parameters including client-provided data
|
|
1453
|
-
* @returns
|
|
1916
|
+
* @returns Void or a Promise.
|
|
1454
1917
|
* @throws Throw an error to reject the connection
|
|
1455
1918
|
*/
|
|
1456
1919
|
onBeforeConnect?: (c: BeforeConnectContext<TState, TVars, TInput, TDatabase, TEvents, TQueues>, params: TConnParams) => void | Promise<void>;
|
|
@@ -1458,7 +1921,8 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
|
|
|
1458
1921
|
* Called when a client successfully connects to the actor.
|
|
1459
1922
|
*
|
|
1460
1923
|
* Use this hook to perform actions when a connection is established,
|
|
1461
|
-
* such as sending initial data or updating the actor's state.
|
|
1924
|
+
* such as sending initial data or updating the actor's state. The
|
|
1925
|
+
* connection is visible in `c.conns` before this hook runs.
|
|
1462
1926
|
*
|
|
1463
1927
|
* @param conn The connection object
|
|
1464
1928
|
* @returns Void or a Promise that resolves when connection handling is complete
|
|
@@ -1534,7 +1998,7 @@ type ActorDatabaseConfig<TDatabase extends AnyDatabaseProvider> = {
|
|
|
1534
1998
|
*/
|
|
1535
1999
|
db: TDatabase;
|
|
1536
2000
|
} | Record<never, never>;
|
|
1537
|
-
type ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = Omit<z$1.infer<typeof ActorConfigSchema>, "actions" | "events" | "queues" | "onCreate" | "onDestroy" | "onMigrate" | "onWake" | "onSleep" | "run" | "onStateChange" | "onBeforeConnect" | "onConnect" | "onDisconnect" | "onBeforeActionResponse" | "onRequest" | "onWebSocket" | "state" | "createState" | "connState" | "createConnState" | "vars" | "createVars" | "db"> & BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues,
|
|
2001
|
+
type ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> = Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>> = Omit<z$1.infer<typeof ActorConfigSchema>, "actions" | "events" | "queues" | "onCreate" | "onDestroy" | "onMigrate" | "onWake" | "onSleep" | "run" | "onStateChange" | "onBeforeConnect" | "onConnect" | "onDisconnect" | "onBeforeActionResponse" | "onRequest" | "onWebSocket" | "state" | "createState" | "connState" | "createConnState" | "vars" | "createVars" | "db"> & BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues, TActions> & CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & ActorDatabaseConfig<TDatabase>;
|
|
1538
2002
|
|
|
1539
2003
|
type AgentOsActorState = {};
|
|
1540
2004
|
interface AgentOsActorVars {
|
|
@@ -1656,6 +2120,16 @@ interface AgentOsActorConfigCallbacks<TConnParams> {
|
|
|
1656
2120
|
type AgentOsActorConfig<TConnParams = undefined> = Omit<z$1.infer<typeof agentOsActorConfigSchema>, "onBeforeConnect" | "onSessionEvent" | "onPermissionRequest"> & AgentOsActorConfigCallbacks<TConnParams>;
|
|
1657
2121
|
type AgentOsActorConfigInput<TConnParams = undefined> = Omit<z$1.input<typeof agentOsActorConfigSchema>, "onBeforeConnect" | "onSessionEvent" | "onPermissionRequest"> & AgentOsActorConfigCallbacks<TConnParams>;
|
|
1658
2122
|
|
|
2123
|
+
declare function buildCronActions<TConnParams>(config: AgentOsActorConfig<TConnParams>): {
|
|
2124
|
+
scheduleCron: (c: AgentOsActionContext<TConnParams>, options: SerializableCronJobOptions) => Promise<{
|
|
2125
|
+
id: string;
|
|
2126
|
+
}>;
|
|
2127
|
+
listCronJobs: (c: AgentOsActionContext<TConnParams>) => Promise<SerializableCronJobInfo[]>;
|
|
2128
|
+
cancelCronJob: (c: AgentOsActionContext<TConnParams>, id: string) => Promise<void>;
|
|
2129
|
+
};
|
|
2130
|
+
|
|
2131
|
+
declare function migrateAgentOsTables(db: RawAccess): Promise<void>;
|
|
2132
|
+
|
|
1659
2133
|
type VirtualStat = Awaited<ReturnType<_rivet_dev_agent_os_core.AgentOs["stat"]>>;
|
|
1660
2134
|
type DeleteOptions = Parameters<_rivet_dev_agent_os_core.AgentOs["delete"]>[1];
|
|
1661
2135
|
declare function buildFilesystemActions<TConnParams>(config: AgentOsActorConfig<TConnParams>): {
|
|
@@ -1687,16 +2161,7 @@ declare function agentOs<TConnParams = undefined>(config: AgentOsActorConfigInpu
|
|
|
1687
2161
|
processExit: typeof processExitToken;
|
|
1688
2162
|
shellData: typeof shellDataToken;
|
|
1689
2163
|
cronEvent: typeof cronEventToken;
|
|
1690
|
-
}, Record<never, never>,
|
|
1691
|
-
sessionEvent: typeof sessionEventToken;
|
|
1692
|
-
permissionRequest: typeof permissionRequestToken;
|
|
1693
|
-
vmBooted: typeof vmBootedToken;
|
|
1694
|
-
vmShutdown: typeof vmShutdownToken;
|
|
1695
|
-
processOutput: typeof processOutputToken;
|
|
1696
|
-
processExit: typeof processExitToken;
|
|
1697
|
-
shellData: typeof shellDataToken;
|
|
1698
|
-
cronEvent: typeof cronEventToken;
|
|
1699
|
-
}, Record<never, never>>>;
|
|
2164
|
+
}, Record<never, never>, any>;
|
|
1700
2165
|
declare const sessionEventToken: EventTypeToken<SessionEventPayload, any>;
|
|
1701
2166
|
declare const permissionRequestToken: EventTypeToken<PermissionRequestPayload, any>;
|
|
1702
2167
|
declare const vmBootedToken: EventTypeToken<VmBootedPayload, any>;
|
|
@@ -1706,6 +2171,21 @@ declare const processExitToken: EventTypeToken<ProcessExitPayload, any>;
|
|
|
1706
2171
|
declare const shellDataToken: EventTypeToken<ShellDataPayload, any>;
|
|
1707
2172
|
declare const cronEventToken: EventTypeToken<CronEventPayload, any>;
|
|
1708
2173
|
|
|
2174
|
+
interface VmFetchOptions {
|
|
2175
|
+
method?: string;
|
|
2176
|
+
headers?: Record<string, string>;
|
|
2177
|
+
body?: string | Uint8Array;
|
|
2178
|
+
}
|
|
2179
|
+
interface VmFetchResult {
|
|
2180
|
+
status: number;
|
|
2181
|
+
statusText: string;
|
|
2182
|
+
headers: Record<string, string>;
|
|
2183
|
+
body: Uint8Array;
|
|
2184
|
+
}
|
|
2185
|
+
declare function buildNetworkActions<TConnParams>(config: AgentOsActorConfig<TConnParams>): {
|
|
2186
|
+
vmFetch: (c: AgentOsActionContext<TConnParams>, port: number, url: string, options?: VmFetchOptions) => Promise<VmFetchResult>;
|
|
2187
|
+
};
|
|
2188
|
+
|
|
1709
2189
|
declare function generateToken(): string;
|
|
1710
2190
|
type AgentOsRequestContext<TConnParams> = RequestContext<AgentOsActorState, TConnParams, undefined, AgentOsActorVars, undefined, DatabaseProvider<RawAccess>>;
|
|
1711
2191
|
declare function buildOnRequestHandler<TConnParams>(config: AgentOsActorConfig<TConnParams>): (c: AgentOsRequestContext<TConnParams>, request: Request) => Promise<Response>;
|
|
@@ -1778,27 +2258,18 @@ declare function buildShellActions<TConnParams>(config: AgentOsActorConfig<TConn
|
|
|
1778
2258
|
closeShell: (c: AgentOsActionContext<TConnParams>, shellId: string) => Promise<void>;
|
|
1779
2259
|
};
|
|
1780
2260
|
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
listCronJobs: (c: AgentOsActionContext<TConnParams>) => Promise<SerializableCronJobInfo[]>;
|
|
1786
|
-
cancelCronJob: (c: AgentOsActionContext<TConnParams>, id: string) => Promise<void>;
|
|
1787
|
-
};
|
|
1788
|
-
|
|
1789
|
-
interface VmFetchOptions {
|
|
1790
|
-
method?: string;
|
|
1791
|
-
headers?: Record<string, string>;
|
|
1792
|
-
body?: string | Uint8Array;
|
|
1793
|
-
}
|
|
1794
|
-
interface VmFetchResult {
|
|
1795
|
-
status: number;
|
|
1796
|
-
statusText: string;
|
|
1797
|
-
headers: Record<string, string>;
|
|
1798
|
-
body: Uint8Array;
|
|
2261
|
+
type VirtualFileSystem = _rivet_dev_agent_os_core.PlainMountConfig["driver"];
|
|
2262
|
+
interface DatabaseVfsOptions {
|
|
2263
|
+
/** The RawAccess database handle from the actor's db provider. */
|
|
2264
|
+
db: RawAccess;
|
|
1799
2265
|
}
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
2266
|
+
/**
|
|
2267
|
+
* Create a VirtualFileSystem backed by SQLite.
|
|
2268
|
+
*
|
|
2269
|
+
* The returned filesystem stores all content and metadata in the
|
|
2270
|
+
* `agent_os_fs_entries` table. The table must be created beforehand
|
|
2271
|
+
* via `migrateAgentOsTables()`.
|
|
2272
|
+
*/
|
|
2273
|
+
declare function createDatabaseVfs(options: DatabaseVfsOptions): VirtualFileSystem;
|
|
1803
2274
|
|
|
1804
2275
|
export { type AgentOsActionContext, type AgentOsActorConfig, type AgentOsActorConfigInput, type AgentOsActorState, type AgentOsActorVars, type AgentOsEvents, type CronEventPayload, type DatabaseVfsOptions, type PermissionRequestPayload, type PersistedSessionEvent, type PersistedSessionRecord, type ProcessExitPayload, type ProcessOutputPayload, type PromptResult, type SerializableCronAction, type SerializableCronJobOptions, type SessionEventPayload, type SessionRecord, type ShellDataPayload, type VmBootedPayload, type VmFetchOptions, type VmFetchResult, type VmShutdownPayload, agentOs, agentOsActorConfigSchema, buildConfigActions, buildCronActions, buildFilesystemActions, buildNetworkActions, buildOnRequestHandler, buildPreviewActions, buildProcessActions, buildPromptActions, buildSessionActions, buildSessionPersistenceActions, buildShellActions, createDatabaseVfs, ensureVm, generateToken, migrateAgentOsTables, runHook, subscribeToSession, syncPreventSleep };
|