rivetkit 2.3.0-rc.8 → 2.3.0
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 +481 -74
- package/dist/browser/client.js +174 -148
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +47 -18
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +2 -2
- package/dist/tsup/actor/errors.d.cts +1 -1
- package/dist/tsup/actor/errors.d.ts +1 -1
- package/dist/tsup/actor/errors.js +1 -1
- package/dist/tsup/agent-os/index.cjs +2160 -2086
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +479 -73
- package/dist/tsup/agent-os/index.d.ts +479 -73
- package/dist/tsup/agent-os/index.js +2160 -2086
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-KY3CERZR.js → chunk-2OTRTA3J.js} +7 -21
- package/dist/tsup/chunk-2OTRTA3J.js.map +1 -0
- package/dist/tsup/{chunk-HGW6PBWR.cjs → chunk-3677IIOV.cjs} +11 -25
- package/dist/tsup/chunk-3677IIOV.cjs.map +1 -0
- package/dist/tsup/{chunk-OT7FF6GB.cjs → chunk-47HHIEXH.cjs} +24 -9
- package/dist/tsup/chunk-47HHIEXH.cjs.map +1 -0
- package/dist/tsup/{chunk-EMFKMVJR.js → chunk-4JDSFJS5.js} +69 -58
- package/dist/tsup/chunk-4JDSFJS5.js.map +1 -0
- package/dist/tsup/{chunk-7HLFSAJP.cjs → chunk-7QKCIVAY.cjs} +225 -214
- package/dist/tsup/chunk-7QKCIVAY.cjs.map +1 -0
- package/dist/tsup/{chunk-AWTPTUQ7.cjs → chunk-B6VUNZUD.cjs} +10 -10
- package/dist/tsup/{chunk-AWTPTUQ7.cjs.map → chunk-B6VUNZUD.cjs.map} +1 -1
- package/dist/tsup/{chunk-D3T3ZBSY.js → chunk-BEI24WTI.js} +2 -2
- package/dist/tsup/{chunk-TMLOKTRB.js → chunk-BRP62GZC.js} +1 -1
- package/dist/tsup/chunk-BRP62GZC.js.map +1 -0
- package/dist/tsup/{chunk-D5G75T7J.js → chunk-DPIMKYNB.js} +61 -2
- package/dist/tsup/chunk-DPIMKYNB.js.map +1 -0
- package/dist/tsup/{chunk-BATTOVHF.cjs → chunk-DXXJPH55.cjs} +40 -13
- package/dist/tsup/chunk-DXXJPH55.cjs.map +1 -0
- package/dist/tsup/{chunk-3YY5S6TV.js → chunk-HXUEHHJF.js} +2 -2
- package/dist/tsup/chunk-HXUEHHJF.js.map +1 -0
- package/dist/tsup/{chunk-4BPKKZJO.cjs → chunk-I4LN3FNT.cjs} +10 -10
- package/dist/tsup/chunk-I4LN3FNT.cjs.map +1 -0
- package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JZ7TWV65.js} +1 -1
- package/dist/tsup/chunk-JZ7TWV65.js.map +1 -0
- package/dist/tsup/{chunk-63WNTDRC.cjs → chunk-KORQB2IR.cjs} +1 -1
- package/dist/tsup/{chunk-63WNTDRC.cjs.map → chunk-KORQB2IR.cjs.map} +1 -1
- package/dist/tsup/{chunk-6TQSSJ4F.cjs → chunk-LVTBW2RE.cjs} +3 -3
- package/dist/tsup/{chunk-6TQSSJ4F.cjs.map → chunk-LVTBW2RE.cjs.map} +1 -1
- package/dist/tsup/{chunk-4JU3IPG2.js → chunk-MEHBWPLJ.js} +6 -6
- package/dist/tsup/chunk-MEHBWPLJ.js.map +1 -0
- package/dist/tsup/{chunk-SRNOPUC6.cjs → chunk-NIY3RSPX.cjs} +62 -3
- package/dist/tsup/chunk-NIY3RSPX.cjs.map +1 -0
- package/dist/tsup/{chunk-UZXQEGVJ.js → chunk-P2GNQ4RN.js} +4 -4
- package/dist/tsup/{chunk-UZXQEGVJ.js.map → chunk-P2GNQ4RN.js.map} +1 -1
- package/dist/tsup/{chunk-VUGENVIK.js → chunk-UMZVD6DQ.js} +22 -7
- package/dist/tsup/chunk-UMZVD6DQ.js.map +1 -0
- package/dist/tsup/{chunk-LD5YASJU.cjs → chunk-VE2X4KMG.cjs} +2 -2
- package/dist/tsup/{chunk-LD5YASJU.cjs.map → chunk-VE2X4KMG.cjs.map} +1 -1
- package/dist/tsup/{chunk-GBG63SUG.js → chunk-VTTFNQQI.js} +32 -5
- package/dist/tsup/chunk-VTTFNQQI.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/client/mod.cjs +9 -9
- package/dist/tsup/client/mod.d.cts +5 -5
- package/dist/tsup/client/mod.d.ts +5 -5
- package/dist/tsup/client/mod.js +8 -8
- package/dist/tsup/common/log.cjs +3 -3
- package/dist/tsup/common/log.js +2 -2
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-Ak1lv4gF.d.ts → config-BxWAw3iH.d.ts} +512 -27
- package/dist/tsup/{config-DU_xj4qZ.d.cts → config-CZQQ-mso.d.cts} +512 -27
- package/dist/tsup/{config-CxjGYf4K.d.ts → config-D49x8NpL.d.cts} +1 -2
- package/dist/tsup/{config-CxjGYf4K.d.cts → config-D49x8NpL.d.ts} +1 -2
- package/dist/tsup/{context-DAAp4Lpg.d.ts → context-Bw7xq8w3.d.cts} +8 -8
- package/dist/tsup/{context-Dt_L55q8.d.cts → context-D8QA76sV.d.ts} +8 -8
- package/dist/tsup/db/drizzle.cjs +3 -3
- package/dist/tsup/db/drizzle.d.cts +1 -1
- package/dist/tsup/db/drizzle.d.ts +1 -1
- package/dist/tsup/db/drizzle.js +1 -1
- package/dist/tsup/db/mod.cjs +2 -2
- package/dist/tsup/db/mod.d.cts +2 -2
- package/dist/tsup/db/mod.d.ts +2 -2
- package/dist/tsup/db/mod.js +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 +6 -6
- package/dist/tsup/inspector/mod.js +5 -5
- package/dist/tsup/inspector-tab/mod.cjs +173 -0
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
- package/dist/tsup/inspector-tab/mod.d.cts +250 -0
- package/dist/tsup/inspector-tab/mod.d.ts +250 -0
- package/dist/tsup/inspector-tab/mod.js +173 -0
- package/dist/tsup/inspector-tab/mod.js.map +1 -0
- package/dist/tsup/mod.cjs +615 -348
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +5 -5
- package/dist/tsup/mod.d.ts +5 -5
- package/dist/tsup/mod.js +511 -244
- 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 -4
- package/dist/tsup/test/mod.d.ts +4 -4
- package/dist/tsup/test/mod.js +18 -15
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/{utils-DVekpm4I.d.cts → utils-DQosb24I.d.cts} +1 -1
- package/dist/tsup/{utils-DVekpm4I.d.ts → utils-DQosb24I.d.ts} +1 -1
- 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 +279 -279
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +6 -6
- package/dist/tsup/workflow/mod.d.ts +6 -6
- package/dist/tsup/workflow/mod.js +380 -380
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +29 -9
- package/src/actor/config.ts +156 -51
- 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 +8 -2
- package/src/actor/instance/mod.ts +26 -34
- package/src/actor/keys.ts +1 -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/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 +87 -54
- package/src/client/actor-conn.ts +11 -11
- package/src/client/actor-handle.ts +69 -52
- package/src/client/actor-query.ts +5 -5
- package/src/client/errors.ts +1 -1
- package/src/client/lifecycle-errors.ts +2 -4
- package/src/client/query.ts +1 -1
- package/src/client/queue.ts +8 -4
- package/src/client/raw-utils.ts +8 -6
- package/src/client/resolve-gateway-target.ts +1 -1
- package/src/client/utils.ts +2 -6
- 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/transport/v1.ts +659 -543
- package/src/common/client-protocol-versioned.ts +66 -64
- package/src/common/database/config.ts +2 -8
- package/src/common/database/native-database.ts +1 -1
- package/src/common/database/shared.ts +1 -0
- package/src/common/encoding.ts +13 -17
- package/src/common/engine.ts +28 -1
- package/src/common/eventsource.ts +1 -1
- package/src/common/inline-websocket-adapter.ts +3 -2
- package/src/common/router.ts +13 -17
- package/src/common/utils.ts +1 -2
- package/src/common/websocket-interface.ts +1 -1
- 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 +48 -46
- 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 +3 -3
- package/src/engine-client/actor-websocket-client.ts +5 -5
- package/src/engine-client/api-endpoints.ts +51 -2
- package/src/engine-client/api-utils.ts +2 -2
- package/src/engine-client/driver.ts +1 -1
- package/src/engine-client/mod.ts +5 -3
- package/src/engine-client/ws-proxy.ts +9 -4
- package/src/inspector/client.browser.ts +5 -11
- package/src/inspector/mod.ts +1 -3
- package/src/inspector-tab/mod.ts +315 -0
- package/src/registry/config/envoy.ts +1 -2
- package/src/registry/config/index.ts +40 -16
- package/src/registry/index.ts +226 -83
- package/src/registry/napi-runtime.ts +46 -12
- package/src/registry/native-validation.ts +10 -12
- package/src/registry/native.ts +307 -164
- package/src/registry/process-metrics.ts +90 -23
- package/src/registry/runtime.ts +53 -6
- package/src/registry/wasm-runtime.ts +30 -3
- package/src/serde.ts +1 -1
- package/src/serverless/configure.ts +18 -7
- package/src/test/mod.ts +11 -8
- package/src/utils/endpoint-parser.ts +1 -1
- package/src/utils/env-vars.ts +6 -0
- package/src/utils/router.ts +1 -1
- package/src/utils/serve.ts +4 -5
- package/src/utils.ts +1 -2
- package/src/workflow/context.ts +30 -29
- package/src/workflow/driver.ts +4 -6
- package/src/workflow/inspector.ts +2 -2
- package/src/workflow/mod.ts +15 -17
- package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
- package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
- package/dist/tsup/chunk-4BPKKZJO.cjs.map +0 -1
- package/dist/tsup/chunk-4JU3IPG2.js.map +0 -1
- package/dist/tsup/chunk-7HLFSAJP.cjs.map +0 -1
- package/dist/tsup/chunk-BATTOVHF.cjs.map +0 -1
- package/dist/tsup/chunk-D5G75T7J.js.map +0 -1
- package/dist/tsup/chunk-EMFKMVJR.js.map +0 -1
- package/dist/tsup/chunk-GBG63SUG.js.map +0 -1
- package/dist/tsup/chunk-HGW6PBWR.cjs.map +0 -1
- package/dist/tsup/chunk-KY3CERZR.js.map +0 -1
- package/dist/tsup/chunk-OT7FF6GB.cjs.map +0 -1
- package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
- package/dist/tsup/chunk-SRNOPUC6.cjs.map +0 -1
- package/dist/tsup/chunk-TMLOKTRB.js.map +0 -1
- package/dist/tsup/chunk-VUGENVIK.js.map +0 -1
- package/dist/tsup/process-metrics-NW754INA.js +0 -118
- package/dist/tsup/process-metrics-NW754INA.js.map +0 -1
- package/dist/tsup/process-metrics-TYAGKCEJ.cjs +0 -118
- package/dist/tsup/process-metrics-TYAGKCEJ.cjs.map +0 -1
- /package/dist/tsup/{chunk-D3T3ZBSY.js.map → chunk-BEI24WTI.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';
|
|
@@ -105,8 +105,7 @@ type DatabaseProvider<DB extends RawAccess> = {
|
|
|
105
105
|
/**
|
|
106
106
|
* Drizzle database client interface (will be extended by drizzle-orm types)
|
|
107
107
|
*/
|
|
108
|
-
|
|
109
|
-
}
|
|
108
|
+
type DrizzleDatabaseClient = {};
|
|
110
109
|
type ExecuteFunction = <TRow extends Record<string, unknown> = Record<string, unknown>>(query: string, ...args: unknown[]) => Promise<TRow[]>;
|
|
111
110
|
type RawAccess = {
|
|
112
111
|
/**
|
|
@@ -123,23 +122,7 @@ type RawAccess = {
|
|
|
123
122
|
close: () => Promise<void>;
|
|
124
123
|
};
|
|
125
124
|
|
|
126
|
-
declare
|
|
127
|
-
|
|
128
|
-
type VirtualFileSystem = _rivet_dev_agent_os_core.PlainMountConfig["driver"];
|
|
129
|
-
interface DatabaseVfsOptions {
|
|
130
|
-
/** The RawAccess database handle from the actor's db provider. */
|
|
131
|
-
db: RawAccess;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Create a VirtualFileSystem backed by SQLite.
|
|
135
|
-
*
|
|
136
|
-
* The returned filesystem stores all content and metadata in the
|
|
137
|
-
* `agent_os_fs_entries` table. The table must be created beforehand
|
|
138
|
-
* via `migrateAgentOsTables()`.
|
|
139
|
-
*/
|
|
140
|
-
declare function createDatabaseVfs(options: DatabaseVfsOptions): VirtualFileSystem;
|
|
141
|
-
|
|
142
|
-
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>>>;
|
|
125
|
+
declare const ActorsSchema: z.ZodRecord<z.ZodString, z.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
|
|
143
126
|
type RegistryActors = z.infer<typeof ActorsSchema>;
|
|
144
127
|
declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
145
128
|
use: z.ZodRecord<z.ZodString, z.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
|
|
@@ -196,6 +179,8 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
196
179
|
httpPort: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
197
180
|
httpHost: z.ZodOptional<z.ZodString>;
|
|
198
181
|
startEngine: z.ZodDefault<z.ZodBoolean>;
|
|
182
|
+
engineHost: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
183
|
+
enginePort: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
199
184
|
engineVersion: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
200
185
|
configurePool: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
201
186
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -261,6 +246,8 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
261
246
|
httpBasePath: string;
|
|
262
247
|
httpPort: number;
|
|
263
248
|
startEngine: boolean;
|
|
249
|
+
engineHost: string;
|
|
250
|
+
enginePort: number;
|
|
264
251
|
engineVersion: string;
|
|
265
252
|
envoy: {
|
|
266
253
|
poolName: string;
|
|
@@ -312,6 +299,8 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
312
299
|
httpBasePath: string;
|
|
313
300
|
httpPort: number;
|
|
314
301
|
startEngine: boolean;
|
|
302
|
+
engineHost: string;
|
|
303
|
+
enginePort: number;
|
|
315
304
|
engineVersion: string;
|
|
316
305
|
serverless: {
|
|
317
306
|
basePath: string;
|
|
@@ -374,7 +363,7 @@ interface QueueSchemaDefinition<TContext = any> {
|
|
|
374
363
|
type EventSchema<TContext = any> = PrimitiveSchema | EventSchemaDefinition<TContext>;
|
|
375
364
|
type QueueSchema = PrimitiveSchema | QueueSchemaDefinition<any> | QueueTypeToken<unknown, unknown, any>;
|
|
376
365
|
type EventSchemaConfig<TContext = any> = Record<string, EventSchema<TContext>>;
|
|
377
|
-
type QueueSchemaConfig<
|
|
366
|
+
type QueueSchemaConfig<_TContext = any> = Record<string, QueueSchema>;
|
|
378
367
|
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;
|
|
379
368
|
type InferSchemaMap<T extends Record<string, unknown>> = {
|
|
380
369
|
[K in keyof T]: InferSchema<T[K]>;
|
|
@@ -385,14 +374,16 @@ type InferQueueCompleteMap<T extends QueueSchemaConfig> = {
|
|
|
385
374
|
};
|
|
386
375
|
type InferEventArgs<T> = T extends readonly unknown[] ? number extends T["length"] ? [T] : T : [T];
|
|
387
376
|
|
|
388
|
-
interface BaseActorDefinition<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>,
|
|
389
|
-
readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q>;
|
|
377
|
+
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>> {
|
|
378
|
+
readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q, _R>;
|
|
379
|
+
}
|
|
380
|
+
interface AnyActorDefinition {
|
|
381
|
+
readonly config: any;
|
|
390
382
|
}
|
|
391
|
-
type AnyActorDefinition = BaseActorDefinition<any, any, any, any, any, any, any, any, any>;
|
|
392
383
|
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> {
|
|
393
384
|
#private;
|
|
394
|
-
constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q>);
|
|
395
|
-
get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q>;
|
|
385
|
+
constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q, R>);
|
|
386
|
+
get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q, R>;
|
|
396
387
|
}
|
|
397
388
|
|
|
398
389
|
declare const EncodingSchema: z$1.ZodEnum<{
|
|
@@ -569,19 +560,358 @@ interface ActorOutput {
|
|
|
569
560
|
error?: unknown;
|
|
570
561
|
}
|
|
571
562
|
|
|
563
|
+
declare const handleBrand: unique symbol;
|
|
564
|
+
type OpaqueHandle<Name extends string> = {
|
|
565
|
+
readonly [handleBrand]: Name;
|
|
566
|
+
};
|
|
567
|
+
type RegistryHandle = OpaqueHandle<"registry">;
|
|
568
|
+
type ActorFactoryHandle = OpaqueHandle<"actorFactory">;
|
|
569
|
+
type ActorContextHandle = OpaqueHandle<"actorContext">;
|
|
570
|
+
type ConnHandle = OpaqueHandle<"conn">;
|
|
571
|
+
type WebSocketHandle = OpaqueHandle<"webSocket">;
|
|
572
|
+
type CancellationTokenHandle = OpaqueHandle<"cancellationToken">;
|
|
573
|
+
type RuntimeBytes = Uint8Array;
|
|
574
|
+
interface RuntimeActorKeySegment {
|
|
575
|
+
kind: string;
|
|
576
|
+
stringValue?: string;
|
|
577
|
+
numberValue?: number;
|
|
578
|
+
}
|
|
579
|
+
interface RuntimeHttpRequest {
|
|
580
|
+
method: string;
|
|
581
|
+
uri: string;
|
|
582
|
+
headers?: Record<string, string>;
|
|
583
|
+
body?: RuntimeBytes;
|
|
584
|
+
}
|
|
585
|
+
interface RuntimeStateDeltaPayload {
|
|
586
|
+
state?: RuntimeBytes;
|
|
587
|
+
connHibernation: Array<{
|
|
588
|
+
connId: string;
|
|
589
|
+
bytes: RuntimeBytes;
|
|
590
|
+
}>;
|
|
591
|
+
connHibernationRemoved: string[];
|
|
592
|
+
}
|
|
593
|
+
interface RuntimeRequestSaveOpts {
|
|
594
|
+
immediate?: boolean;
|
|
595
|
+
maxWaitMs?: number;
|
|
596
|
+
}
|
|
597
|
+
interface RuntimeInspectorSnapshot {
|
|
598
|
+
stateRevision: number;
|
|
599
|
+
connectionsRevision: number;
|
|
600
|
+
queueRevision: number;
|
|
601
|
+
activeConnections: number;
|
|
602
|
+
queueSize: number;
|
|
603
|
+
connectedClients: number;
|
|
604
|
+
}
|
|
605
|
+
interface RuntimeQueueMessage {
|
|
606
|
+
id(): bigint;
|
|
607
|
+
name(): string;
|
|
608
|
+
body(): RuntimeBytes;
|
|
609
|
+
createdAt(): number;
|
|
610
|
+
isCompletable(): boolean;
|
|
611
|
+
complete(response?: RuntimeBytes | undefined | null): Promise<void>;
|
|
612
|
+
}
|
|
613
|
+
interface RuntimeQueueInspectMessage {
|
|
614
|
+
id: number;
|
|
615
|
+
name: string;
|
|
616
|
+
createdAtMs: number;
|
|
617
|
+
}
|
|
618
|
+
interface RuntimeQueueNextBatchOptions {
|
|
619
|
+
names?: string[];
|
|
620
|
+
count?: number;
|
|
621
|
+
timeoutMs?: number;
|
|
622
|
+
completable?: boolean;
|
|
623
|
+
}
|
|
624
|
+
interface RuntimeQueueWaitOptions {
|
|
625
|
+
timeoutMs?: number;
|
|
626
|
+
completable?: boolean;
|
|
627
|
+
}
|
|
628
|
+
interface RuntimeQueueEnqueueAndWaitOptions {
|
|
629
|
+
timeoutMs?: number;
|
|
630
|
+
}
|
|
631
|
+
interface RuntimeQueueTryNextBatchOptions {
|
|
632
|
+
names?: string[];
|
|
633
|
+
count?: number;
|
|
634
|
+
completable?: boolean;
|
|
635
|
+
}
|
|
636
|
+
interface RuntimeKvListOptions {
|
|
637
|
+
reverse?: boolean;
|
|
638
|
+
limit?: number;
|
|
639
|
+
}
|
|
640
|
+
interface RuntimeKvEntry {
|
|
641
|
+
key: RuntimeBytes;
|
|
642
|
+
value: RuntimeBytes;
|
|
643
|
+
}
|
|
644
|
+
type RuntimeSqlBindNoValues = {
|
|
645
|
+
intValue?: never;
|
|
646
|
+
floatValue?: never;
|
|
647
|
+
textValue?: never;
|
|
648
|
+
blobValue?: never;
|
|
649
|
+
};
|
|
650
|
+
type RuntimeSqlBindParam = ({
|
|
651
|
+
kind: "null";
|
|
652
|
+
} & RuntimeSqlBindNoValues) | {
|
|
653
|
+
kind: "int";
|
|
654
|
+
intValue: number;
|
|
655
|
+
floatValue?: never;
|
|
656
|
+
textValue?: never;
|
|
657
|
+
blobValue?: never;
|
|
658
|
+
} | {
|
|
659
|
+
kind: "float";
|
|
660
|
+
intValue?: never;
|
|
661
|
+
floatValue: number;
|
|
662
|
+
textValue?: never;
|
|
663
|
+
blobValue?: never;
|
|
664
|
+
} | {
|
|
665
|
+
kind: "text";
|
|
666
|
+
intValue?: never;
|
|
667
|
+
floatValue?: never;
|
|
668
|
+
textValue: string;
|
|
669
|
+
blobValue?: never;
|
|
670
|
+
} | {
|
|
671
|
+
kind: "blob";
|
|
672
|
+
intValue?: never;
|
|
673
|
+
floatValue?: never;
|
|
674
|
+
textValue?: never;
|
|
675
|
+
blobValue: RuntimeBytes;
|
|
676
|
+
};
|
|
677
|
+
type RuntimeSqlBindParams = RuntimeSqlBindParam[] | null;
|
|
678
|
+
interface RuntimeSqlQueryResult {
|
|
679
|
+
columns: string[];
|
|
680
|
+
rows: unknown[][];
|
|
681
|
+
}
|
|
682
|
+
type RuntimeSqlExecResult = RuntimeSqlQueryResult;
|
|
683
|
+
interface RuntimeSqlExecuteResult extends RuntimeSqlQueryResult {
|
|
684
|
+
changes: number;
|
|
685
|
+
lastInsertRowId?: number | null;
|
|
686
|
+
}
|
|
687
|
+
interface RuntimeSqlRunResult {
|
|
688
|
+
changes: number;
|
|
689
|
+
}
|
|
690
|
+
interface RuntimeActorConfig {
|
|
691
|
+
name?: string;
|
|
692
|
+
icon?: string;
|
|
693
|
+
hasDatabase?: boolean;
|
|
694
|
+
remoteSqlite?: boolean;
|
|
695
|
+
hasState?: boolean;
|
|
696
|
+
canHibernateWebsocket?: boolean;
|
|
697
|
+
stateSaveIntervalMs?: number;
|
|
698
|
+
createStateTimeoutMs?: number;
|
|
699
|
+
onCreateTimeoutMs?: number;
|
|
700
|
+
createVarsTimeoutMs?: number;
|
|
701
|
+
createConnStateTimeoutMs?: number;
|
|
702
|
+
onBeforeConnectTimeoutMs?: number;
|
|
703
|
+
onConnectTimeoutMs?: number;
|
|
704
|
+
onMigrateTimeoutMs?: number;
|
|
705
|
+
onWakeTimeoutMs?: number;
|
|
706
|
+
onBeforeActorStartTimeoutMs?: number;
|
|
707
|
+
actionTimeoutMs?: number;
|
|
708
|
+
onRequestTimeoutMs?: number;
|
|
709
|
+
sleepTimeoutMs?: number;
|
|
710
|
+
noSleep?: boolean;
|
|
711
|
+
sleepGracePeriodMs?: number;
|
|
712
|
+
connectionLivenessTimeoutMs?: number;
|
|
713
|
+
connectionLivenessIntervalMs?: number;
|
|
714
|
+
maxQueueSize?: number;
|
|
715
|
+
maxQueueMessageSize?: number;
|
|
716
|
+
maxIncomingMessageSize?: number;
|
|
717
|
+
maxOutgoingMessageSize?: number;
|
|
718
|
+
preloadMaxWorkflowBytes?: number;
|
|
719
|
+
preloadMaxConnectionsBytes?: number;
|
|
720
|
+
actions?: Array<{
|
|
721
|
+
name: string;
|
|
722
|
+
}>;
|
|
723
|
+
inspectorTabs?: Array<RuntimeInspectorTabEntry>;
|
|
724
|
+
}
|
|
725
|
+
interface RuntimeInspectorTabEntry {
|
|
726
|
+
id: string;
|
|
727
|
+
/** Required for custom entries; omitted for built-in hides. */
|
|
728
|
+
label?: string;
|
|
729
|
+
/**
|
|
730
|
+
* Required for custom entries — absolute path to the source directory.
|
|
731
|
+
* Resolved on the TS side before being handed to the runtime.
|
|
732
|
+
*/
|
|
733
|
+
source?: string;
|
|
734
|
+
/** Optional icon id for custom entries. */
|
|
735
|
+
icon?: string;
|
|
736
|
+
/** Set to true for built-in hide entries. */
|
|
737
|
+
hidden?: boolean;
|
|
738
|
+
}
|
|
739
|
+
interface RuntimeServeConfig {
|
|
740
|
+
version: number;
|
|
741
|
+
endpoint: string;
|
|
742
|
+
token?: string;
|
|
743
|
+
namespace: string;
|
|
744
|
+
poolName: string;
|
|
745
|
+
engineBinaryPath?: string;
|
|
746
|
+
engineHost?: string;
|
|
747
|
+
enginePort?: number;
|
|
748
|
+
handleInspectorHttpInRuntime?: boolean;
|
|
749
|
+
inspectorTestToken?: string;
|
|
750
|
+
serverlessBasePath?: string;
|
|
751
|
+
serverlessPackageVersion: string;
|
|
752
|
+
serverlessClientEndpoint?: string;
|
|
753
|
+
serverlessClientNamespace?: string;
|
|
754
|
+
serverlessClientToken?: string;
|
|
755
|
+
serverlessValidateEndpoint: boolean;
|
|
756
|
+
serverlessMaxStartPayloadBytes: number;
|
|
757
|
+
}
|
|
758
|
+
interface RuntimeServerlessRequest {
|
|
759
|
+
method: string;
|
|
760
|
+
url: string;
|
|
761
|
+
headers: Record<string, string>;
|
|
762
|
+
body: RuntimeBytes;
|
|
763
|
+
}
|
|
764
|
+
interface RuntimeServerlessResponseHead {
|
|
765
|
+
status: number;
|
|
766
|
+
headers: Record<string, string>;
|
|
767
|
+
}
|
|
768
|
+
interface RuntimeRegistryRouteResponse {
|
|
769
|
+
status: number;
|
|
770
|
+
headers: Record<string, string>;
|
|
771
|
+
body: RuntimeBytes;
|
|
772
|
+
}
|
|
773
|
+
type RuntimeServerlessStreamEvent = {
|
|
774
|
+
kind: "chunk";
|
|
775
|
+
chunk?: RuntimeBytes;
|
|
776
|
+
} | {
|
|
777
|
+
kind: "end";
|
|
778
|
+
error?: {
|
|
779
|
+
group: string;
|
|
780
|
+
code: string;
|
|
781
|
+
message: string;
|
|
782
|
+
};
|
|
783
|
+
};
|
|
784
|
+
type RuntimeServerlessStreamCallback = (error: unknown, event?: RuntimeServerlessStreamEvent) => unknown;
|
|
785
|
+
type RuntimeWebSocketEvent = {
|
|
786
|
+
kind: "message";
|
|
787
|
+
data: string | RuntimeBytes;
|
|
788
|
+
binary: boolean;
|
|
789
|
+
messageIndex?: number;
|
|
790
|
+
} | {
|
|
791
|
+
kind: "close";
|
|
792
|
+
code: number;
|
|
793
|
+
reason: string;
|
|
794
|
+
wasClean: boolean;
|
|
795
|
+
};
|
|
796
|
+
interface CoreRuntime {
|
|
797
|
+
readonly kind: "napi" | "wasm";
|
|
798
|
+
createRegistry(): RegistryHandle;
|
|
799
|
+
registerActor(registry: RegistryHandle, name: string, factory: ActorFactoryHandle): void;
|
|
800
|
+
serveRegistry(registry: RegistryHandle, config: RuntimeServeConfig): Promise<void>;
|
|
801
|
+
shutdownRegistry(registry: RegistryHandle): Promise<void>;
|
|
802
|
+
registryActorStopThresholdMs?(registry: RegistryHandle): Promise<number | undefined>;
|
|
803
|
+
handleServerlessRequest(registry: RegistryHandle, req: RuntimeServerlessRequest, onStreamEvent: RuntimeServerlessStreamCallback, cancelToken: CancellationTokenHandle, config: RuntimeServeConfig): Promise<RuntimeServerlessResponseHead>;
|
|
804
|
+
registryHealth?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
805
|
+
registryMetadata?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
806
|
+
registryMetrics?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
807
|
+
createActorFactory(callbacks: object, config?: RuntimeActorConfig | undefined | null): ActorFactoryHandle;
|
|
808
|
+
createCancellationToken(): CancellationTokenHandle;
|
|
809
|
+
cancellationTokenAborted(token: CancellationTokenHandle): boolean;
|
|
810
|
+
cancelCancellationToken(token: CancellationTokenHandle): void;
|
|
811
|
+
onCancellationTokenCancelled(token: CancellationTokenHandle, callback: (...args: unknown[]) => unknown): void;
|
|
812
|
+
actorState(ctx: ActorContextHandle): RuntimeBytes;
|
|
813
|
+
actorBeginOnStateChange(ctx: ActorContextHandle): void;
|
|
814
|
+
actorEndOnStateChange(ctx: ActorContextHandle): void;
|
|
815
|
+
actorSetAlarm(ctx: ActorContextHandle, timestampMs?: number | undefined | null): void;
|
|
816
|
+
actorRequestSave(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): void;
|
|
817
|
+
actorRequestSaveAndWait(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): Promise<void>;
|
|
818
|
+
actorInspectorSnapshot(ctx: ActorContextHandle): RuntimeInspectorSnapshot;
|
|
819
|
+
actorDecodeInspectorRequest(ctx: ActorContextHandle, bytes: RuntimeBytes, advertisedVersion: number): RuntimeBytes;
|
|
820
|
+
actorEncodeInspectorResponse(ctx: ActorContextHandle, bytes: RuntimeBytes, targetVersion: number): RuntimeBytes;
|
|
821
|
+
actorVerifyInspectorAuth(ctx: ActorContextHandle, bearerToken?: string | undefined | null): Promise<void>;
|
|
822
|
+
actorQueueHibernationRemoval(ctx: ActorContextHandle, connId: string): void;
|
|
823
|
+
actorTakePendingHibernationChanges(ctx: ActorContextHandle): string[];
|
|
824
|
+
actorDirtyHibernatableConns(ctx: ActorContextHandle): ConnHandle[];
|
|
825
|
+
actorSaveState(ctx: ActorContextHandle, payload: RuntimeStateDeltaPayload): Promise<void>;
|
|
826
|
+
actorId(ctx: ActorContextHandle): string;
|
|
827
|
+
actorName(ctx: ActorContextHandle): string;
|
|
828
|
+
actorKey(ctx: ActorContextHandle): RuntimeActorKeySegment[];
|
|
829
|
+
actorRegion(ctx: ActorContextHandle): string;
|
|
830
|
+
actorSleep(ctx: ActorContextHandle): void;
|
|
831
|
+
actorDestroy(ctx: ActorContextHandle): void;
|
|
832
|
+
actorAbortSignal(ctx: ActorContextHandle): AbortSignal;
|
|
833
|
+
actorConns(ctx: ActorContextHandle): ConnHandle[];
|
|
834
|
+
actorConnectConn(ctx: ActorContextHandle, params: RuntimeBytes, request?: RuntimeHttpRequest | undefined | null): Promise<ConnHandle>;
|
|
835
|
+
actorBroadcast(ctx: ActorContextHandle, name: string, args: RuntimeBytes): void;
|
|
836
|
+
actorWaitUntil(ctx: ActorContextHandle, promise: Promise<unknown>): void;
|
|
837
|
+
actorWaitForTrackedShutdownWork(ctx: ActorContextHandle): Promise<boolean>;
|
|
838
|
+
actorWaitForTrackedShutdownWorkUnbounded(ctx: ActorContextHandle): Promise<void>;
|
|
839
|
+
actorKeepAwake(ctx: ActorContextHandle, promise: Promise<unknown>): void;
|
|
840
|
+
actorBeginKeepAwake(ctx: ActorContextHandle): number;
|
|
841
|
+
actorEndKeepAwake(ctx: ActorContextHandle, regionId: number): void;
|
|
842
|
+
actorRegisterTask(ctx: ActorContextHandle, promise: Promise<unknown>): void;
|
|
843
|
+
actorRuntimeState(ctx: ActorContextHandle): object;
|
|
844
|
+
actorClearRuntimeState(ctx: ActorContextHandle): void;
|
|
845
|
+
actorRestartRunHandler(ctx: ActorContextHandle): void;
|
|
846
|
+
actorBeginWebsocketCallback(ctx: ActorContextHandle): number;
|
|
847
|
+
actorEndWebsocketCallback(ctx: ActorContextHandle, regionId: number): void;
|
|
848
|
+
actorKvGet(ctx: ActorContextHandle, key: RuntimeBytes): Promise<RuntimeBytes | null>;
|
|
849
|
+
actorKvPut(ctx: ActorContextHandle, key: RuntimeBytes, value: RuntimeBytes): Promise<void>;
|
|
850
|
+
actorKvDelete(ctx: ActorContextHandle, key: RuntimeBytes): Promise<void>;
|
|
851
|
+
actorKvDeleteRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes): Promise<void>;
|
|
852
|
+
actorKvListPrefix(ctx: ActorContextHandle, prefix: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
|
|
853
|
+
actorKvListRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
|
|
854
|
+
actorKvBatchGet(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<Array<RuntimeBytes | undefined | null>>;
|
|
855
|
+
actorKvBatchPut(ctx: ActorContextHandle, entries: RuntimeKvEntry[]): Promise<void>;
|
|
856
|
+
actorKvBatchDelete(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<void>;
|
|
857
|
+
actorSqlExec(ctx: ActorContextHandle, sql: string): Promise<RuntimeSqlExecResult>;
|
|
858
|
+
actorSqlExecute(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
|
|
859
|
+
actorSqlQuery(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlQueryResult>;
|
|
860
|
+
actorSqlRun(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlRunResult>;
|
|
861
|
+
actorSqlMetrics(ctx: ActorContextHandle): SqliteNativeMetrics | null;
|
|
862
|
+
actorSqlTakeLastKvError(ctx: ActorContextHandle): string | null;
|
|
863
|
+
actorSqlClose(ctx: ActorContextHandle): Promise<void>;
|
|
864
|
+
actorQueueSend(ctx: ActorContextHandle, name: string, body: RuntimeBytes): Promise<RuntimeQueueMessage>;
|
|
865
|
+
actorQueueNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueNextBatchOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage[]>;
|
|
866
|
+
actorQueueWaitForNames(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage>;
|
|
867
|
+
actorQueueWaitForNamesAvailable(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<void>;
|
|
868
|
+
actorQueueEnqueueAndWait(ctx: ActorContextHandle, name: string, body: RuntimeBytes, options?: RuntimeQueueEnqueueAndWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeBytes | null>;
|
|
869
|
+
actorQueueTryNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueTryNextBatchOptions | undefined | null): RuntimeQueueMessage[];
|
|
870
|
+
actorQueueMaxSize(ctx: ActorContextHandle): number;
|
|
871
|
+
actorQueueInspectMessages(ctx: ActorContextHandle): Promise<RuntimeQueueInspectMessage[]>;
|
|
872
|
+
actorScheduleAfter(ctx: ActorContextHandle, durationMs: number, actionName: string, args: RuntimeBytes): void;
|
|
873
|
+
actorScheduleAt(ctx: ActorContextHandle, timestampMs: number, actionName: string, args: RuntimeBytes): void;
|
|
874
|
+
connId(conn: ConnHandle): string;
|
|
875
|
+
connParams(conn: ConnHandle): RuntimeBytes;
|
|
876
|
+
connState(conn: ConnHandle): RuntimeBytes;
|
|
877
|
+
connSetState(conn: ConnHandle, state: RuntimeBytes): void;
|
|
878
|
+
connIsHibernatable(conn: ConnHandle): boolean;
|
|
879
|
+
connSend(conn: ConnHandle, name: string, args: RuntimeBytes): void;
|
|
880
|
+
connDisconnect(conn: ConnHandle, reason?: string | undefined | null): Promise<void>;
|
|
881
|
+
webSocketSend(ws: WebSocketHandle, data: RuntimeBytes, binary: boolean): void;
|
|
882
|
+
webSocketClose(ws: WebSocketHandle, code?: number | undefined | null, reason?: string | undefined | null): Promise<void>;
|
|
883
|
+
webSocketSetEventCallback(ws: WebSocketHandle, callback: (event: RuntimeWebSocketEvent) => void): void;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
declare function buildConfiguredRegistry(config: RegistryConfig): Promise<{
|
|
887
|
+
runtime: CoreRuntime;
|
|
888
|
+
registry: RegistryHandle;
|
|
889
|
+
serveConfig: RuntimeServeConfig;
|
|
890
|
+
}>;
|
|
891
|
+
|
|
572
892
|
type FetchHandler = (request: Request, ...args: any) => Response | Promise<Response>;
|
|
573
893
|
interface ServerlessHandler {
|
|
574
894
|
fetch: FetchHandler;
|
|
575
895
|
}
|
|
576
|
-
interface
|
|
577
|
-
|
|
578
|
-
|
|
896
|
+
interface RegistryRoutes {
|
|
897
|
+
health(): Promise<Response>;
|
|
898
|
+
metadata(): Promise<Response>;
|
|
899
|
+
prometheusMetrics(request?: Request): Promise<Response>;
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* Injectable dependencies for {@link Registry}. Production code uses the
|
|
903
|
+
* defaults. Tests override `buildConfiguredRegistry` to drive lifecycle
|
|
904
|
+
* orchestration against a fake `CoreRuntime` without an engine.
|
|
905
|
+
*/
|
|
906
|
+
interface RegistryDeps {
|
|
907
|
+
buildConfiguredRegistry: typeof buildConfiguredRegistry;
|
|
579
908
|
}
|
|
580
909
|
declare class Registry<A extends RegistryActors> {
|
|
581
910
|
#private;
|
|
911
|
+
readonly routes: RegistryRoutes;
|
|
582
912
|
get config(): RegistryConfigInput<A>;
|
|
583
913
|
parseConfig(): RegistryConfig;
|
|
584
|
-
constructor(config: RegistryConfigInput<A>);
|
|
914
|
+
constructor(config: RegistryConfigInput<A>, deps?: Partial<RegistryDeps>);
|
|
585
915
|
/**
|
|
586
916
|
* Handle an incoming HTTP request for serverless deployments.
|
|
587
917
|
*
|
|
@@ -621,7 +951,27 @@ declare class Registry<A extends RegistryActors> {
|
|
|
621
951
|
port?: number;
|
|
622
952
|
publicDir?: string;
|
|
623
953
|
}): Promise<void>;
|
|
624
|
-
|
|
954
|
+
/**
|
|
955
|
+
* Gracefully drains all live registries.
|
|
956
|
+
*
|
|
957
|
+
* Programmatic counterpart to the SIGINT/SIGTERM handlers: tears down
|
|
958
|
+
* every live `CoreRegistry` (both `start()` and `handler()` modes) and
|
|
959
|
+
* waits for the serve promise to resolve, all bounded by the shutdown
|
|
960
|
+
* grace period. Unlike a signal-driven shutdown, this does not re-raise a
|
|
961
|
+
* signal or exit the process. The caller owns process lifetime.
|
|
962
|
+
*
|
|
963
|
+
* Idempotent: concurrent or repeated calls share a single drain. Safe to
|
|
964
|
+
* call even if nothing has been started.
|
|
965
|
+
*
|
|
966
|
+
* @example
|
|
967
|
+
* ```ts
|
|
968
|
+
* const registry = setup({ use: { counter } });
|
|
969
|
+
* registry.start();
|
|
970
|
+
* // ...later, on your own shutdown trigger:
|
|
971
|
+
* await registry.shutdown();
|
|
972
|
+
* ```
|
|
973
|
+
*/
|
|
974
|
+
shutdown(): Promise<void>;
|
|
625
975
|
startEnvoy(): void;
|
|
626
976
|
/**
|
|
627
977
|
* Starts the actor envoy for standalone server deployments.
|
|
@@ -660,6 +1010,12 @@ interface QueueSendResult<TResponse = unknown> {
|
|
|
660
1010
|
* @returns {Promise<Response>}
|
|
661
1011
|
*/
|
|
662
1012
|
type ActorActionFunction<Args extends Array<unknown> = unknown[], Response = unknown> = (...args: Args extends [unknown, ...infer Rest] ? Rest : Args) => Promise<Response>;
|
|
1013
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
1014
|
+
type LooseEventSubscribe = (eventName: string, callback: (...args: any[]) => void) => () => void;
|
|
1015
|
+
type ActorActionMap<R> = {
|
|
1016
|
+
[K in keyof NonNullable<R>]: NonNullable<R>[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Awaited<Return>> : never;
|
|
1017
|
+
};
|
|
1018
|
+
type ActionsOf<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<any, any, any, any, any, any, any, any, infer R> ? R : never;
|
|
663
1019
|
interface ActorGatewayOptions {
|
|
664
1020
|
skipReadyWait?: boolean;
|
|
665
1021
|
}
|
|
@@ -672,9 +1028,7 @@ type ActorWebSocketOptions = ActorGatewayOptions;
|
|
|
672
1028
|
/**
|
|
673
1029
|
* Maps action methods from actor definition to typed function signatures.
|
|
674
1030
|
*/
|
|
675
|
-
type ActorDefinitionActions<AD extends AnyActorDefinition> = AD extends
|
|
676
|
-
[K in keyof R]: R[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Return> : never;
|
|
677
|
-
} : never;
|
|
1031
|
+
type ActorDefinitionActions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? Record<string, ActorActionFunction<any[], any>> : ActorActionMap<ActionsOf<AD>>;
|
|
678
1032
|
type ActorQueueSend<TQueues extends QueueSchemaConfig> = {
|
|
679
1033
|
<K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options: QueueSendWaitOptions): Promise<QueueSendResult<InferQueueCompleteMap<TQueues>[K]>>;
|
|
680
1034
|
<K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options?: QueueSendNoWaitOptions): Promise<void>;
|
|
@@ -685,13 +1039,31 @@ type ActorEventSubscribe<TEvents extends EventSchemaConfig> = {
|
|
|
685
1039
|
<K extends keyof TEvents & string>(eventName: K, callback: (...args: InferEventArgs<InferSchemaMap<TEvents>[K]>) => void): () => void;
|
|
686
1040
|
(eventName: keyof TEvents extends never ? string : never, callback: (...args: any[]) => void): () => void;
|
|
687
1041
|
};
|
|
688
|
-
type ActorDefinitionQueueSend<AD extends AnyActorDefinition> = AD
|
|
1042
|
+
type ActorDefinitionQueueSend<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
|
|
1043
|
+
send: ActorQueueSend<Record<string, any>>;
|
|
1044
|
+
} : AD extends {
|
|
1045
|
+
config: {
|
|
1046
|
+
queues?: infer Q;
|
|
1047
|
+
};
|
|
1048
|
+
} ? Q extends QueueSchemaConfig ? {
|
|
689
1049
|
send: ActorQueueSend<Q>;
|
|
690
|
-
} :
|
|
691
|
-
|
|
1050
|
+
} : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, any, infer Q, any> ? Q extends QueueSchemaConfig ? {
|
|
1051
|
+
send: ActorQueueSend<Q>;
|
|
1052
|
+
} : {} : {};
|
|
1053
|
+
type ActorDefinitionEventSubscriptions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
|
|
1054
|
+
on: LooseEventSubscribe;
|
|
1055
|
+
once: LooseEventSubscribe;
|
|
1056
|
+
} : AD extends {
|
|
1057
|
+
config: {
|
|
1058
|
+
events?: infer E;
|
|
1059
|
+
};
|
|
1060
|
+
} ? E extends EventSchemaConfig ? {
|
|
692
1061
|
on: ActorEventSubscribe<E>;
|
|
693
1062
|
once: ActorEventSubscribe<E>;
|
|
694
|
-
} :
|
|
1063
|
+
} : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, infer E, any, any> ? E extends EventSchemaConfig ? {
|
|
1064
|
+
on: ActorEventSubscribe<E>;
|
|
1065
|
+
once: ActorEventSubscribe<E>;
|
|
1066
|
+
} : {} : {};
|
|
695
1067
|
|
|
696
1068
|
type ActorResolutionState = ActorQuery;
|
|
697
1069
|
|
|
@@ -1150,6 +1522,10 @@ type ActorKvListOptions<T extends ActorKvValueType = "text", K extends ActorKvKe
|
|
|
1150
1522
|
limit?: number;
|
|
1151
1523
|
};
|
|
1152
1524
|
type ActorClientFor<T> = T extends Registry<any> ? Client<T> : T;
|
|
1525
|
+
/**
|
|
1526
|
+
* @deprecated Actor KV is deprecated. Use embedded SQLite (`c.db` / `c.sql`)
|
|
1527
|
+
* or actor state instead.
|
|
1528
|
+
*/
|
|
1153
1529
|
interface ActorKv {
|
|
1154
1530
|
get<T extends ActorKvValueType = "text">(key: Uint8Array | string, options?: ActorKvValueOptions<T>): Promise<ActorKvValueTypeMap[T] | null>;
|
|
1155
1531
|
put<T extends ActorKvValueType = "text">(key: Uint8Array | string, value: Uint8Array | string | ArrayBuffer, options?: ActorKvValueOptions<T>): Promise<void>;
|
|
@@ -1226,7 +1602,7 @@ interface ActorQueue<TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
|
1226
1602
|
iter<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueIterOptions<TName, TCompletable>): AsyncIterable<any>;
|
|
1227
1603
|
[key: string]: any;
|
|
1228
1604
|
}
|
|
1229
|
-
interface Conn<
|
|
1605
|
+
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>> {
|
|
1230
1606
|
id: string;
|
|
1231
1607
|
params: TConnParams;
|
|
1232
1608
|
state: TConnState;
|
|
@@ -1241,6 +1617,10 @@ interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase
|
|
|
1241
1617
|
[RAW_STATE_SYMBOL](): TState;
|
|
1242
1618
|
state: TState;
|
|
1243
1619
|
vars: TVars;
|
|
1620
|
+
/**
|
|
1621
|
+
* @deprecated Actor KV is deprecated. Use embedded SQLite (`db` / `sql`)
|
|
1622
|
+
* or actor state instead.
|
|
1623
|
+
*/
|
|
1244
1624
|
readonly kv: ActorKv;
|
|
1245
1625
|
readonly db: InferDatabaseClient<TDatabase>;
|
|
1246
1626
|
readonly schedule: ActorSchedule;
|
|
@@ -1365,8 +1745,27 @@ declare const ActorConfigSchema: z$1.ZodObject<{
|
|
|
1365
1745
|
preloadMaxWorkflowBytes: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1366
1746
|
preloadMaxConnectionsBytes: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1367
1747
|
}, z$1.core.$strict>>;
|
|
1748
|
+
inspector: z$1.ZodOptional<z$1.ZodObject<{
|
|
1749
|
+
tabs: z$1.ZodDefault<z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodObject<{
|
|
1750
|
+
id: z$1.ZodString;
|
|
1751
|
+
label: z$1.ZodString;
|
|
1752
|
+
source: z$1.ZodString;
|
|
1753
|
+
icon: z$1.ZodOptional<z$1.ZodString>;
|
|
1754
|
+
hidden: z$1.ZodOptional<z$1.ZodLiteral<false>>;
|
|
1755
|
+
}, z$1.core.$strict>, z$1.ZodObject<{
|
|
1756
|
+
id: z$1.ZodEnum<{
|
|
1757
|
+
state: "state";
|
|
1758
|
+
queue: "queue";
|
|
1759
|
+
workflow: "workflow";
|
|
1760
|
+
database: "database";
|
|
1761
|
+
connections: "connections";
|
|
1762
|
+
console: "console";
|
|
1763
|
+
}>;
|
|
1764
|
+
hidden: z$1.ZodLiteral<true>;
|
|
1765
|
+
}, z$1.core.$strict>]>>>;
|
|
1766
|
+
}, z$1.core.$strict>>;
|
|
1368
1767
|
}, z$1.core.$strict>;
|
|
1369
|
-
type CreateState<TState,
|
|
1768
|
+
type CreateState<TState, _TConnParams, _TConnState, _TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
|
|
1370
1769
|
state: TState;
|
|
1371
1770
|
} | {
|
|
1372
1771
|
createState: (c: CreateContext<TState, TInput, TDatabase, TEvents, TQueues>, input: TInput) => TState | Promise<TState>;
|
|
@@ -1379,7 +1778,7 @@ type CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase e
|
|
|
1379
1778
|
/**
|
|
1380
1779
|
* @experimental
|
|
1381
1780
|
*/
|
|
1382
|
-
type CreateVars<TState,
|
|
1781
|
+
type CreateVars<TState, _TConnParams, _TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
|
|
1383
1782
|
/**
|
|
1384
1783
|
* @experimental
|
|
1385
1784
|
*/
|
|
@@ -1565,7 +1964,7 @@ type ActorDatabaseConfig<TDatabase extends AnyDatabaseProvider> = {
|
|
|
1565
1964
|
*/
|
|
1566
1965
|
db: TDatabase;
|
|
1567
1966
|
} | Record<never, never>;
|
|
1568
|
-
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,
|
|
1967
|
+
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>;
|
|
1569
1968
|
|
|
1570
1969
|
type AgentOsActorState = {};
|
|
1571
1970
|
interface AgentOsActorVars {
|
|
@@ -1687,6 +2086,16 @@ interface AgentOsActorConfigCallbacks<TConnParams> {
|
|
|
1687
2086
|
type AgentOsActorConfig<TConnParams = undefined> = Omit<z$1.infer<typeof agentOsActorConfigSchema>, "onBeforeConnect" | "onSessionEvent" | "onPermissionRequest"> & AgentOsActorConfigCallbacks<TConnParams>;
|
|
1688
2087
|
type AgentOsActorConfigInput<TConnParams = undefined> = Omit<z$1.input<typeof agentOsActorConfigSchema>, "onBeforeConnect" | "onSessionEvent" | "onPermissionRequest"> & AgentOsActorConfigCallbacks<TConnParams>;
|
|
1689
2088
|
|
|
2089
|
+
declare function buildCronActions<TConnParams>(config: AgentOsActorConfig<TConnParams>): {
|
|
2090
|
+
scheduleCron: (c: AgentOsActionContext<TConnParams>, options: SerializableCronJobOptions) => Promise<{
|
|
2091
|
+
id: string;
|
|
2092
|
+
}>;
|
|
2093
|
+
listCronJobs: (c: AgentOsActionContext<TConnParams>) => Promise<SerializableCronJobInfo[]>;
|
|
2094
|
+
cancelCronJob: (c: AgentOsActionContext<TConnParams>, id: string) => Promise<void>;
|
|
2095
|
+
};
|
|
2096
|
+
|
|
2097
|
+
declare function migrateAgentOsTables(db: RawAccess): Promise<void>;
|
|
2098
|
+
|
|
1690
2099
|
type VirtualStat = Awaited<ReturnType<_rivet_dev_agent_os_core.AgentOs["stat"]>>;
|
|
1691
2100
|
type DeleteOptions = Parameters<_rivet_dev_agent_os_core.AgentOs["delete"]>[1];
|
|
1692
2101
|
declare function buildFilesystemActions<TConnParams>(config: AgentOsActorConfig<TConnParams>): {
|
|
@@ -1718,16 +2127,7 @@ declare function agentOs<TConnParams = undefined>(config: AgentOsActorConfigInpu
|
|
|
1718
2127
|
processExit: typeof processExitToken;
|
|
1719
2128
|
shellData: typeof shellDataToken;
|
|
1720
2129
|
cronEvent: typeof cronEventToken;
|
|
1721
|
-
}, Record<never, never>,
|
|
1722
|
-
sessionEvent: typeof sessionEventToken;
|
|
1723
|
-
permissionRequest: typeof permissionRequestToken;
|
|
1724
|
-
vmBooted: typeof vmBootedToken;
|
|
1725
|
-
vmShutdown: typeof vmShutdownToken;
|
|
1726
|
-
processOutput: typeof processOutputToken;
|
|
1727
|
-
processExit: typeof processExitToken;
|
|
1728
|
-
shellData: typeof shellDataToken;
|
|
1729
|
-
cronEvent: typeof cronEventToken;
|
|
1730
|
-
}, Record<never, never>>>;
|
|
2130
|
+
}, Record<never, never>, any>;
|
|
1731
2131
|
declare const sessionEventToken: EventTypeToken<SessionEventPayload, any>;
|
|
1732
2132
|
declare const permissionRequestToken: EventTypeToken<PermissionRequestPayload, any>;
|
|
1733
2133
|
declare const vmBootedToken: EventTypeToken<VmBootedPayload, any>;
|
|
@@ -1737,6 +2137,21 @@ declare const processExitToken: EventTypeToken<ProcessExitPayload, any>;
|
|
|
1737
2137
|
declare const shellDataToken: EventTypeToken<ShellDataPayload, any>;
|
|
1738
2138
|
declare const cronEventToken: EventTypeToken<CronEventPayload, any>;
|
|
1739
2139
|
|
|
2140
|
+
interface VmFetchOptions {
|
|
2141
|
+
method?: string;
|
|
2142
|
+
headers?: Record<string, string>;
|
|
2143
|
+
body?: string | Uint8Array;
|
|
2144
|
+
}
|
|
2145
|
+
interface VmFetchResult {
|
|
2146
|
+
status: number;
|
|
2147
|
+
statusText: string;
|
|
2148
|
+
headers: Record<string, string>;
|
|
2149
|
+
body: Uint8Array;
|
|
2150
|
+
}
|
|
2151
|
+
declare function buildNetworkActions<TConnParams>(config: AgentOsActorConfig<TConnParams>): {
|
|
2152
|
+
vmFetch: (c: AgentOsActionContext<TConnParams>, port: number, url: string, options?: VmFetchOptions) => Promise<VmFetchResult>;
|
|
2153
|
+
};
|
|
2154
|
+
|
|
1740
2155
|
declare function generateToken(): string;
|
|
1741
2156
|
type AgentOsRequestContext<TConnParams> = RequestContext<AgentOsActorState, TConnParams, undefined, AgentOsActorVars, undefined, DatabaseProvider<RawAccess>>;
|
|
1742
2157
|
declare function buildOnRequestHandler<TConnParams>(config: AgentOsActorConfig<TConnParams>): (c: AgentOsRequestContext<TConnParams>, request: Request) => Promise<Response>;
|
|
@@ -1809,27 +2224,18 @@ declare function buildShellActions<TConnParams>(config: AgentOsActorConfig<TConn
|
|
|
1809
2224
|
closeShell: (c: AgentOsActionContext<TConnParams>, shellId: string) => Promise<void>;
|
|
1810
2225
|
};
|
|
1811
2226
|
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
listCronJobs: (c: AgentOsActionContext<TConnParams>) => Promise<SerializableCronJobInfo[]>;
|
|
1817
|
-
cancelCronJob: (c: AgentOsActionContext<TConnParams>, id: string) => Promise<void>;
|
|
1818
|
-
};
|
|
1819
|
-
|
|
1820
|
-
interface VmFetchOptions {
|
|
1821
|
-
method?: string;
|
|
1822
|
-
headers?: Record<string, string>;
|
|
1823
|
-
body?: string | Uint8Array;
|
|
1824
|
-
}
|
|
1825
|
-
interface VmFetchResult {
|
|
1826
|
-
status: number;
|
|
1827
|
-
statusText: string;
|
|
1828
|
-
headers: Record<string, string>;
|
|
1829
|
-
body: Uint8Array;
|
|
2227
|
+
type VirtualFileSystem = _rivet_dev_agent_os_core.PlainMountConfig["driver"];
|
|
2228
|
+
interface DatabaseVfsOptions {
|
|
2229
|
+
/** The RawAccess database handle from the actor's db provider. */
|
|
2230
|
+
db: RawAccess;
|
|
1830
2231
|
}
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
2232
|
+
/**
|
|
2233
|
+
* Create a VirtualFileSystem backed by SQLite.
|
|
2234
|
+
*
|
|
2235
|
+
* The returned filesystem stores all content and metadata in the
|
|
2236
|
+
* `agent_os_fs_entries` table. The table must be created beforehand
|
|
2237
|
+
* via `migrateAgentOsTables()`.
|
|
2238
|
+
*/
|
|
2239
|
+
declare function createDatabaseVfs(options: DatabaseVfsOptions): VirtualFileSystem;
|
|
1834
2240
|
|
|
1835
2241
|
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 };
|