rivetkit 2.3.5-rc.1 → 2.3.6
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 +19 -5
- package/dist/browser/client.js +32 -9
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +12 -2
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/agent-os/index.cjs +115 -5
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +19 -5
- package/dist/tsup/agent-os/index.d.ts +19 -5
- package/dist/tsup/agent-os/index.js +115 -5
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-6HQCLWAW.cjs → chunk-234EFKN2.cjs} +13 -3
- package/dist/tsup/chunk-234EFKN2.cjs.map +1 -0
- package/dist/tsup/{chunk-NIC3QLKL.js → chunk-3ZE5UDOA.js} +3 -3
- package/dist/tsup/{chunk-4XKED5P5.cjs → chunk-AXEGEUYB.cjs} +262 -252
- package/dist/tsup/chunk-AXEGEUYB.cjs.map +1 -0
- package/dist/tsup/{chunk-P4OGQ4JL.js → chunk-BX4G2O6M.js} +3 -3
- package/dist/tsup/{chunk-GAV4PKFT.js → chunk-F6ZW7JZQ.js} +130 -120
- package/dist/tsup/chunk-F6ZW7JZQ.js.map +1 -0
- package/dist/tsup/{chunk-TR5NLR5V.cjs → chunk-FNTTW25Q.cjs} +4 -4
- package/dist/tsup/{chunk-TR5NLR5V.cjs.map → chunk-FNTTW25Q.cjs.map} +1 -1
- package/dist/tsup/{chunk-G3CCRCTK.cjs → chunk-HNHLBM3Y.cjs} +108 -6
- package/dist/tsup/chunk-HNHLBM3Y.cjs.map +1 -0
- package/dist/tsup/{chunk-UJ2FQY63.cjs → chunk-HVOKIYUB.cjs} +7 -7
- package/dist/tsup/{chunk-UJ2FQY63.cjs.map → chunk-HVOKIYUB.cjs.map} +1 -1
- package/dist/tsup/{chunk-PAG6G46L.js → chunk-OH6CBWUD.js} +2 -2
- package/dist/tsup/{chunk-TNIWIUNV.cjs → chunk-PD7SZKHY.cjs} +9 -9
- package/dist/tsup/{chunk-TNIWIUNV.cjs.map → chunk-PD7SZKHY.cjs.map} +1 -1
- package/dist/tsup/{chunk-MGTSVSUC.js → chunk-PLLHHJWR.js} +2 -2
- package/dist/tsup/{chunk-SHBE77IT.js → chunk-QWLJCP3X.js} +106 -4
- package/dist/tsup/chunk-QWLJCP3X.js.map +1 -0
- package/dist/tsup/{chunk-B4IZU537.js → chunk-RDTFPGU2.js} +13 -3
- package/dist/tsup/chunk-RDTFPGU2.js.map +1 -0
- package/dist/tsup/{chunk-M3FCXL3Q.cjs → chunk-WS3PP253.cjs} +3 -3
- package/dist/tsup/{chunk-M3FCXL3Q.cjs.map → chunk-WS3PP253.cjs.map} +1 -1
- package/dist/tsup/client/mod.cjs +5 -5
- package/dist/tsup/client/mod.d.cts +2 -2
- package/dist/tsup/client/mod.d.ts +2 -2
- package/dist/tsup/client/mod.js +4 -4
- package/dist/tsup/common/log.cjs +2 -2
- package/dist/tsup/common/log.js +1 -1
- package/dist/tsup/common/websocket.cjs +3 -3
- package/dist/tsup/common/websocket.js +2 -2
- package/dist/tsup/{config-BzdqbLAP.d.ts → config-BRpVbJCD.d.ts} +20 -6
- package/dist/tsup/{config-CPPEwn_e.d.cts → config-BobvQpex.d.cts} +20 -6
- package/dist/tsup/{context-wWv-K2K_.d.ts → context-Cj-DFyiy.d.ts} +1 -1
- package/dist/tsup/{context-DSA9gFXB.d.cts → context-YEBNJrws.d.cts} +1 -1
- package/dist/tsup/db/drizzle.cjs +2 -2
- package/dist/tsup/db/drizzle.js +1 -1
- package/dist/tsup/db/mod.cjs +2 -2
- package/dist/tsup/db/mod.js +1 -1
- package/dist/tsup/dynamic/mod.cjs +2 -2
- package/dist/tsup/dynamic/mod.d.cts +1 -1
- package/dist/tsup/dynamic/mod.d.ts +1 -1
- package/dist/tsup/dynamic/mod.js +1 -1
- package/dist/tsup/inspector/mod.cjs +4 -4
- package/dist/tsup/inspector/mod.js +3 -3
- package/dist/tsup/inspector-tab/mod.cjs +2 -2
- package/dist/tsup/inspector-tab/mod.d.cts +2 -2
- package/dist/tsup/inspector-tab/mod.d.ts +2 -2
- package/dist/tsup/inspector-tab/mod.js +1 -1
- package/dist/tsup/mod.cjs +175 -85
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +3 -3
- package/dist/tsup/mod.d.ts +3 -3
- package/dist/tsup/mod.js +107 -17
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +16 -13
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +1 -1
- package/dist/tsup/test/mod.d.ts +1 -1
- package/dist/tsup/test/mod.js +15 -12
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/unstable/migrations.cjs +101 -0
- package/dist/tsup/unstable/migrations.cjs.map +1 -0
- package/dist/tsup/unstable/migrations.d.cts +29 -0
- package/dist/tsup/unstable/migrations.d.ts +29 -0
- package/dist/tsup/unstable/migrations.js +101 -0
- package/dist/tsup/unstable/migrations.js.map +1 -0
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.js +1 -1
- package/dist/tsup/workflow/mod.cjs +9 -9
- package/dist/tsup/workflow/mod.d.cts +3 -3
- package/dist/tsup/workflow/mod.d.ts +3 -3
- package/dist/tsup/workflow/mod.js +4 -4
- package/package.json +19 -9
- package/src/actor/actions.ts +119 -0
- package/src/actor/config.ts +61 -18
- package/src/actor/definition.ts +3 -0
- package/src/client/actor-common.ts +3 -1
- package/src/client/client.ts +24 -11
- package/src/registry/config/index.ts +2 -4
- package/src/registry/index.ts +86 -5
- package/src/registry/napi-runtime.ts +4 -0
- package/src/registry/native.ts +17 -16
- package/src/registry/runtime.ts +1 -0
- package/src/registry/wasm-runtime.ts +6 -0
- package/src/test/mod.ts +1 -19
- package/src/test/ready.ts +22 -0
- package/src/unstable/migrations.test.ts +170 -0
- package/src/unstable/migrations.ts +141 -0
- package/dist/tsup/chunk-4XKED5P5.cjs.map +0 -1
- package/dist/tsup/chunk-6HQCLWAW.cjs.map +0 -1
- package/dist/tsup/chunk-B4IZU537.js.map +0 -1
- package/dist/tsup/chunk-G3CCRCTK.cjs.map +0 -1
- package/dist/tsup/chunk-GAV4PKFT.js.map +0 -1
- package/dist/tsup/chunk-SHBE77IT.js.map +0 -1
- /package/dist/tsup/{chunk-NIC3QLKL.js.map → chunk-3ZE5UDOA.js.map} +0 -0
- /package/dist/tsup/{chunk-P4OGQ4JL.js.map → chunk-BX4G2O6M.js.map} +0 -0
- /package/dist/tsup/{chunk-PAG6G46L.js.map → chunk-OH6CBWUD.js.map} +0 -0
- /package/dist/tsup/{chunk-MGTSVSUC.js.map → chunk-PLLHHJWR.js.map} +0 -0
|
@@ -860,6 +860,7 @@ interface CoreRuntime {
|
|
|
860
860
|
createRegistry(): RegistryHandle;
|
|
861
861
|
registerActor(registry: RegistryHandle, name: string, factory: ActorFactoryHandle): void;
|
|
862
862
|
serveRegistry(registry: RegistryHandle, config: RuntimeServeConfig): Promise<void>;
|
|
863
|
+
waitRegistryReady(registry: RegistryHandle): Promise<void>;
|
|
863
864
|
shutdownRegistry(registry: RegistryHandle): Promise<void>;
|
|
864
865
|
registryActorStopThresholdMs?(registry: RegistryHandle): Promise<number | undefined>;
|
|
865
866
|
handleServerlessRequest(registry: RegistryHandle, req: RuntimeServerlessRequest, onStreamEvent: RuntimeServerlessStreamCallback, cancelToken: CancellationTokenHandle, config: RuntimeServeConfig): Promise<RuntimeServerlessResponseHead>;
|
|
@@ -1057,6 +1058,15 @@ declare class Registry<A extends RegistryActors> {
|
|
|
1057
1058
|
*/
|
|
1058
1059
|
shutdown(): Promise<void>;
|
|
1059
1060
|
startEnvoy(): void;
|
|
1061
|
+
/**
|
|
1062
|
+
* Starts the serverful registry if needed and waits until its envoy has
|
|
1063
|
+
* registered with the Engine. Repeated and concurrent calls share one
|
|
1064
|
+
* startup lifecycle and readiness promise.
|
|
1065
|
+
*
|
|
1066
|
+
* Unlike {@link start}, this reports startup failures and does not resolve
|
|
1067
|
+
* merely because an HTTP health endpoint is listening.
|
|
1068
|
+
*/
|
|
1069
|
+
startAndWait(): Promise<void>;
|
|
1060
1070
|
/**
|
|
1061
1071
|
* Starts the actor envoy for standalone server deployments.
|
|
1062
1072
|
*
|
|
@@ -1101,7 +1111,7 @@ type ActorActionFunction<Args extends Array<unknown> = unknown[], Response = unk
|
|
|
1101
1111
|
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
1102
1112
|
type LooseEventSubscribe = (eventName: string, callback: (...args: any[]) => void) => () => void;
|
|
1103
1113
|
type ActorActionMap<R> = {
|
|
1104
|
-
[K in keyof NonNullable<R>]: NonNullable<R>[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Awaited<Return>> : never;
|
|
1114
|
+
[K in keyof NonNullable<R>]: NonNullable<R>[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Awaited<Return>> : NonNullable<R>[K] extends Record<string, unknown> ? ActorActionMap<NonNullable<R>[K]> : never;
|
|
1105
1115
|
};
|
|
1106
1116
|
type ActionsOf<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<any, any, any, any, any, any, any, any, infer R> ? R : never;
|
|
1107
1117
|
interface ActorGatewayOptions {
|
|
@@ -1869,7 +1879,7 @@ declare const ActorConfigSchema: z$1.ZodObject<{
|
|
|
1869
1879
|
onBeforeActionResponse: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1870
1880
|
onRequest: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1871
1881
|
onWebSocket: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1872
|
-
actions: z$1.ZodDefault<z$1.
|
|
1882
|
+
actions: z$1.ZodDefault<z$1.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
|
|
1873
1883
|
actionInputSchemas: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
1874
1884
|
connParamsSchema: z$1.ZodOptional<z$1.ZodAny>;
|
|
1875
1885
|
events: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
@@ -1952,7 +1962,10 @@ type CreateVars<TState, _TConnParams, _TConnState, TVars, TInput, TDatabase exte
|
|
|
1952
1962
|
createVars: (c: CreateVarsContext<TState, TInput, TDatabase, TEvents, TQueues>, driverCtx: any) => TVars | Promise<TVars>;
|
|
1953
1963
|
} | Record<never, never>;
|
|
1954
1964
|
interface Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
1955
|
-
[Action: string]: (c: ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, ...args: any[]) => any
|
|
1965
|
+
[Action: string]: ((c: ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, ...args: any[]) => any) | Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1966
|
+
}
|
|
1967
|
+
interface ActionInputSchemas {
|
|
1968
|
+
[Action: string]: PrimitiveSchema | ActionInputSchemas;
|
|
1956
1969
|
}
|
|
1957
1970
|
interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>> {
|
|
1958
1971
|
/**
|
|
@@ -2104,9 +2117,10 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
|
|
|
2104
2117
|
onWebSocket?: (c: WebSocketContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, websocket: UniversalWebSocket) => void | Promise<void>;
|
|
2105
2118
|
actions?: TActions;
|
|
2106
2119
|
/**
|
|
2107
|
-
* Optional
|
|
2120
|
+
* Optional schemas for validating action argument tuples in native runtimes.
|
|
2121
|
+
* May mirror nested action groups or use dot-separated low-level action names.
|
|
2108
2122
|
*/
|
|
2109
|
-
actionInputSchemas?:
|
|
2123
|
+
actionInputSchemas?: ActionInputSchemas;
|
|
2110
2124
|
/**
|
|
2111
2125
|
* Optional schema for validating connection params in native runtimes.
|
|
2112
2126
|
*/
|
|
@@ -860,6 +860,7 @@ interface CoreRuntime {
|
|
|
860
860
|
createRegistry(): RegistryHandle;
|
|
861
861
|
registerActor(registry: RegistryHandle, name: string, factory: ActorFactoryHandle): void;
|
|
862
862
|
serveRegistry(registry: RegistryHandle, config: RuntimeServeConfig): Promise<void>;
|
|
863
|
+
waitRegistryReady(registry: RegistryHandle): Promise<void>;
|
|
863
864
|
shutdownRegistry(registry: RegistryHandle): Promise<void>;
|
|
864
865
|
registryActorStopThresholdMs?(registry: RegistryHandle): Promise<number | undefined>;
|
|
865
866
|
handleServerlessRequest(registry: RegistryHandle, req: RuntimeServerlessRequest, onStreamEvent: RuntimeServerlessStreamCallback, cancelToken: CancellationTokenHandle, config: RuntimeServeConfig): Promise<RuntimeServerlessResponseHead>;
|
|
@@ -1057,6 +1058,15 @@ declare class Registry<A extends RegistryActors> {
|
|
|
1057
1058
|
*/
|
|
1058
1059
|
shutdown(): Promise<void>;
|
|
1059
1060
|
startEnvoy(): void;
|
|
1061
|
+
/**
|
|
1062
|
+
* Starts the serverful registry if needed and waits until its envoy has
|
|
1063
|
+
* registered with the Engine. Repeated and concurrent calls share one
|
|
1064
|
+
* startup lifecycle and readiness promise.
|
|
1065
|
+
*
|
|
1066
|
+
* Unlike {@link start}, this reports startup failures and does not resolve
|
|
1067
|
+
* merely because an HTTP health endpoint is listening.
|
|
1068
|
+
*/
|
|
1069
|
+
startAndWait(): Promise<void>;
|
|
1060
1070
|
/**
|
|
1061
1071
|
* Starts the actor envoy for standalone server deployments.
|
|
1062
1072
|
*
|
|
@@ -1101,7 +1111,7 @@ type ActorActionFunction<Args extends Array<unknown> = unknown[], Response = unk
|
|
|
1101
1111
|
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
1102
1112
|
type LooseEventSubscribe = (eventName: string, callback: (...args: any[]) => void) => () => void;
|
|
1103
1113
|
type ActorActionMap<R> = {
|
|
1104
|
-
[K in keyof NonNullable<R>]: NonNullable<R>[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Awaited<Return>> : never;
|
|
1114
|
+
[K in keyof NonNullable<R>]: NonNullable<R>[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Awaited<Return>> : NonNullable<R>[K] extends Record<string, unknown> ? ActorActionMap<NonNullable<R>[K]> : never;
|
|
1105
1115
|
};
|
|
1106
1116
|
type ActionsOf<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<any, any, any, any, any, any, any, any, infer R> ? R : never;
|
|
1107
1117
|
interface ActorGatewayOptions {
|
|
@@ -1869,7 +1879,7 @@ declare const ActorConfigSchema: z$1.ZodObject<{
|
|
|
1869
1879
|
onBeforeActionResponse: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1870
1880
|
onRequest: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1871
1881
|
onWebSocket: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1872
|
-
actions: z$1.ZodDefault<z$1.
|
|
1882
|
+
actions: z$1.ZodDefault<z$1.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
|
|
1873
1883
|
actionInputSchemas: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
1874
1884
|
connParamsSchema: z$1.ZodOptional<z$1.ZodAny>;
|
|
1875
1885
|
events: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
@@ -1952,7 +1962,10 @@ type CreateVars<TState, _TConnParams, _TConnState, TVars, TInput, TDatabase exte
|
|
|
1952
1962
|
createVars: (c: CreateVarsContext<TState, TInput, TDatabase, TEvents, TQueues>, driverCtx: any) => TVars | Promise<TVars>;
|
|
1953
1963
|
} | Record<never, never>;
|
|
1954
1964
|
interface Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
1955
|
-
[Action: string]: (c: ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, ...args: any[]) => any
|
|
1965
|
+
[Action: string]: ((c: ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, ...args: any[]) => any) | Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1966
|
+
}
|
|
1967
|
+
interface ActionInputSchemas {
|
|
1968
|
+
[Action: string]: PrimitiveSchema | ActionInputSchemas;
|
|
1956
1969
|
}
|
|
1957
1970
|
interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>> {
|
|
1958
1971
|
/**
|
|
@@ -2104,9 +2117,10 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
|
|
|
2104
2117
|
onWebSocket?: (c: WebSocketContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, websocket: UniversalWebSocket) => void | Promise<void>;
|
|
2105
2118
|
actions?: TActions;
|
|
2106
2119
|
/**
|
|
2107
|
-
* Optional
|
|
2120
|
+
* Optional schemas for validating action argument tuples in native runtimes.
|
|
2121
|
+
* May mirror nested action groups or use dot-separated low-level action names.
|
|
2108
2122
|
*/
|
|
2109
|
-
actionInputSchemas?:
|
|
2123
|
+
actionInputSchemas?: ActionInputSchemas;
|
|
2110
2124
|
/**
|
|
2111
2125
|
* Optional schema for validating connection params in native runtimes.
|
|
2112
2126
|
*/
|
|
@@ -1,10 +1,108 @@
|
|
|
1
1
|
// src/agent-os/actor/index.ts
|
|
2
2
|
import { AgentOs, createInMemoryFileSystem } from "@rivet-dev/agent-os-core";
|
|
3
3
|
|
|
4
|
+
// src/actor/actions.ts
|
|
5
|
+
function flattenActionHandlers(actions) {
|
|
6
|
+
const flattened = /* @__PURE__ */ Object.create(null);
|
|
7
|
+
for (const { name, handler } of collectActionEntries(actions)) {
|
|
8
|
+
flattened[name] = handler;
|
|
9
|
+
}
|
|
10
|
+
return flattened;
|
|
11
|
+
}
|
|
12
|
+
function flattenActionInputSchemas(actions, schemas) {
|
|
13
|
+
if (schemas === void 0) return void 0;
|
|
14
|
+
if (!isRecord(schemas)) {
|
|
15
|
+
throw new TypeError("actionInputSchemas must be an object");
|
|
16
|
+
}
|
|
17
|
+
const flattened = /* @__PURE__ */ Object.create(null);
|
|
18
|
+
for (const { name, path } of collectActionEntries(actions)) {
|
|
19
|
+
const nestedSchema = lookupNestedSchema(schemas, path);
|
|
20
|
+
const flatSchema = schemas[name];
|
|
21
|
+
if (nestedSchema !== void 0 && flatSchema !== void 0 && nestedSchema !== flatSchema) {
|
|
22
|
+
throw new TypeError(
|
|
23
|
+
`Action input schema \`${name}\` is defined by both a nested path and a dotted key`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
const schema = nestedSchema ?? flatSchema;
|
|
27
|
+
if (schema !== void 0) {
|
|
28
|
+
flattened[name] = schema;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return flattened;
|
|
32
|
+
}
|
|
33
|
+
function collectActionEntries(actions) {
|
|
34
|
+
const entries = [];
|
|
35
|
+
const names = /* @__PURE__ */ new Set();
|
|
36
|
+
visitActionGroup(actions ?? {}, [], entries, names);
|
|
37
|
+
return entries;
|
|
38
|
+
}
|
|
39
|
+
function visitActionGroup(value, path, entries, names) {
|
|
40
|
+
if (!isRecord(value)) {
|
|
41
|
+
throw new TypeError(
|
|
42
|
+
`${formatActionPath(path)} must be an action handler or group`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
for (const [segment, child] of Object.entries(value)) {
|
|
46
|
+
const childPath = [...path, segment];
|
|
47
|
+
if (typeof child === "function") {
|
|
48
|
+
const name = childPath.join(".");
|
|
49
|
+
if (names.has(name)) {
|
|
50
|
+
throw new TypeError(
|
|
51
|
+
`Multiple action definitions flatten to \`${name}\``
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
names.add(name);
|
|
55
|
+
entries.push({
|
|
56
|
+
name,
|
|
57
|
+
path: childPath,
|
|
58
|
+
handler: child
|
|
59
|
+
});
|
|
60
|
+
} else {
|
|
61
|
+
visitActionGroup(child, childPath, entries, names);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function lookupNestedSchema(schemas, path) {
|
|
66
|
+
let value = schemas;
|
|
67
|
+
for (const segment of path) {
|
|
68
|
+
if (!isRecord(value) || !Object.hasOwn(value, segment)) {
|
|
69
|
+
return void 0;
|
|
70
|
+
}
|
|
71
|
+
value = value[segment];
|
|
72
|
+
}
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
function isRecord(value) {
|
|
76
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
const prototype = Object.getPrototypeOf(value);
|
|
80
|
+
return prototype === Object.prototype || prototype === null;
|
|
81
|
+
}
|
|
82
|
+
function formatActionPath(path) {
|
|
83
|
+
return path.length === 0 ? "actions" : `Action \`${path.join(".")}\``;
|
|
84
|
+
}
|
|
85
|
+
|
|
4
86
|
// src/actor/config.ts
|
|
5
87
|
import { z } from "zod/v4";
|
|
6
88
|
var DEFAULT_SLEEP_GRACE_PERIOD = 15e3;
|
|
7
89
|
var zFunction = () => z.custom((val) => typeof val === "function");
|
|
90
|
+
var zActionTree = z.custom((value) => {
|
|
91
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
const prototype = Object.getPrototypeOf(value);
|
|
95
|
+
return prototype === Object.prototype || prototype === null;
|
|
96
|
+
}).superRefine((actions, ctx) => {
|
|
97
|
+
try {
|
|
98
|
+
flattenActionHandlers(actions);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
ctx.addIssue({
|
|
101
|
+
code: "custom",
|
|
102
|
+
message: error instanceof Error ? error.message : "Invalid action definition"
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
});
|
|
8
106
|
var WorkflowInspectorConfigSchema = z.object({
|
|
9
107
|
getHistory: zFunction(),
|
|
10
108
|
onHistoryUpdated: zFunction().optional(),
|
|
@@ -141,7 +239,7 @@ var ActorConfigSchema = z.object({
|
|
|
141
239
|
onBeforeActionResponse: zFunction().optional(),
|
|
142
240
|
onRequest: zFunction().optional(),
|
|
143
241
|
onWebSocket: zFunction().optional(),
|
|
144
|
-
actions:
|
|
242
|
+
actions: zActionTree.default(() => ({})),
|
|
145
243
|
actionInputSchemas: z.record(z.string(), z.any()).optional(),
|
|
146
244
|
connParamsSchema: z.any().optional(),
|
|
147
245
|
events: z.record(z.string(), z.any()).optional(),
|
|
@@ -285,10 +383,10 @@ var DocActorConfigSchema = z.object({
|
|
|
285
383
|
"Called for raw WebSocket connections to /actors/{name}/websocket/* endpoints."
|
|
286
384
|
),
|
|
287
385
|
actions: z.record(z.string(), z.unknown()).optional().describe(
|
|
288
|
-
"
|
|
386
|
+
"Tree of action names or nested groups to handler functions. Nested paths use dot-separated low-level action names. Defaults to an empty object."
|
|
289
387
|
),
|
|
290
388
|
actionInputSchemas: z.record(z.string(), z.unknown()).optional().describe(
|
|
291
|
-
"Optional
|
|
389
|
+
"Optional schemas for validating action argument tuples in native runtimes. May mirror nested action groups or use dot-separated low-level action names."
|
|
292
390
|
),
|
|
293
391
|
connParamsSchema: z.unknown().optional().describe(
|
|
294
392
|
"Optional schema for validating connection params in native runtimes."
|
|
@@ -319,7 +417,7 @@ function isRivetErrorCode(error, group, code) {
|
|
|
319
417
|
// package.json
|
|
320
418
|
var package_default = {
|
|
321
419
|
name: "rivetkit",
|
|
322
|
-
version: "2.3.
|
|
420
|
+
version: "2.3.6",
|
|
323
421
|
description: "Lightweight libraries for building stateful actors on edge platforms",
|
|
324
422
|
license: "Apache-2.0",
|
|
325
423
|
keywords: [
|
|
@@ -391,6 +489,16 @@ var package_default = {
|
|
|
391
489
|
default: "./dist/tsup/db/drizzle.cjs"
|
|
392
490
|
}
|
|
393
491
|
},
|
|
492
|
+
"./unstable/migrations": {
|
|
493
|
+
import: {
|
|
494
|
+
types: "./dist/tsup/unstable/migrations.d.ts",
|
|
495
|
+
default: "./dist/tsup/unstable/migrations.js"
|
|
496
|
+
},
|
|
497
|
+
require: {
|
|
498
|
+
types: "./dist/tsup/unstable/migrations.d.cts",
|
|
499
|
+
default: "./dist/tsup/unstable/migrations.cjs"
|
|
500
|
+
}
|
|
501
|
+
},
|
|
394
502
|
"./dynamic": {
|
|
395
503
|
import: {
|
|
396
504
|
types: "./dist/tsup/dynamic/mod.d.ts",
|
|
@@ -490,7 +598,7 @@ var package_default = {
|
|
|
490
598
|
"./dist/tsup/chunk-*.cjs"
|
|
491
599
|
],
|
|
492
600
|
scripts: {
|
|
493
|
-
build: "tsup src/mod.ts src/client/mod.ts src/common/log.ts src/common/websocket.ts src/actor/errors.ts src/utils.ts src/workflow/mod.ts src/test/mod.ts src/inspector/mod.ts src/inspector-tab/mod.ts src/db/mod.ts src/db/drizzle.ts src/dynamic/mod.ts && tsup src/agent-os/index.ts --no-clean --out-dir dist/tsup/agent-os",
|
|
601
|
+
build: "tsup src/mod.ts src/client/mod.ts src/common/log.ts src/common/websocket.ts src/actor/errors.ts src/utils.ts src/workflow/mod.ts src/test/mod.ts src/inspector/mod.ts src/inspector-tab/mod.ts src/db/mod.ts src/db/drizzle.ts src/dynamic/mod.ts src/unstable/migrations.ts && tsup src/agent-os/index.ts --no-clean --out-dir dist/tsup/agent-os",
|
|
494
602
|
"build:browser": "tsup --config tsup.browser.config.ts",
|
|
495
603
|
"check-types": "tsc --noEmit",
|
|
496
604
|
lint: "biome check . && pnpm run check:test-skips && pnpm run check:wait-for-comments",
|
|
@@ -769,6 +877,8 @@ function actor(input) {
|
|
|
769
877
|
input == null ? void 0 : input.options
|
|
770
878
|
);
|
|
771
879
|
const config = ActorConfigSchema.parse(input);
|
|
880
|
+
flattenActionHandlers(config.actions);
|
|
881
|
+
flattenActionInputSchemas(config.actions, config.actionInputSchemas);
|
|
772
882
|
return new ActorDefinition(config);
|
|
773
883
|
}
|
|
774
884
|
|