rivetkit 2.3.0 → 2.3.2
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 -6
- package/dist/browser/client.js +4 -4
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +4 -4
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +4 -2
- package/dist/tsup/actor/errors.cjs.map +1 -1
- package/dist/tsup/actor/errors.d.cts +1 -1
- package/dist/tsup/actor/errors.d.ts +1 -1
- package/dist/tsup/actor/errors.js +3 -1
- package/dist/tsup/agent-os/index.cjs +4 -4
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +18 -5
- package/dist/tsup/agent-os/index.d.ts +18 -5
- package/dist/tsup/agent-os/index.js +4 -4
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-MEHBWPLJ.js → chunk-2OIYUYNN.js} +3 -3
- package/dist/tsup/{chunk-UMZVD6DQ.js → chunk-2WOKGTL3.js} +2 -2
- package/dist/tsup/{chunk-NIY3RSPX.cjs → chunk-3MHDOUD7.cjs} +11 -2
- package/dist/tsup/chunk-3MHDOUD7.cjs.map +1 -0
- package/dist/tsup/{chunk-KORQB2IR.cjs → chunk-4FC7TVS6.cjs} +6 -2
- package/dist/tsup/chunk-4FC7TVS6.cjs.map +1 -0
- package/dist/tsup/{chunk-3677IIOV.cjs → chunk-4PQAFXDX.cjs} +5 -5
- package/dist/tsup/{chunk-3677IIOV.cjs.map → chunk-4PQAFXDX.cjs.map} +1 -1
- package/dist/tsup/{chunk-4JDSFJS5.js → chunk-ASKKONXG.js} +8 -8
- package/dist/tsup/{chunk-P2GNQ4RN.js → chunk-BDXKVROD.js} +4 -4
- package/dist/tsup/{chunk-LVTBW2RE.cjs → chunk-FRVQ34UV.cjs} +3 -3
- package/dist/tsup/{chunk-LVTBW2RE.cjs.map → chunk-FRVQ34UV.cjs.map} +1 -1
- package/dist/tsup/{chunk-B6VUNZUD.cjs → chunk-GFXUYXMK.cjs} +10 -10
- package/dist/tsup/{chunk-B6VUNZUD.cjs.map → chunk-GFXUYXMK.cjs.map} +1 -1
- package/dist/tsup/{chunk-BEI24WTI.js → chunk-HINDZOY3.js} +2 -2
- package/dist/tsup/{chunk-47HHIEXH.cjs → chunk-MZJVAV3I.cjs} +4 -4
- package/dist/tsup/{chunk-47HHIEXH.cjs.map → chunk-MZJVAV3I.cjs.map} +1 -1
- package/dist/tsup/{chunk-DXXJPH55.cjs → chunk-RUBJWXFW.cjs} +39 -14
- package/dist/tsup/chunk-RUBJWXFW.cjs.map +1 -0
- package/dist/tsup/{chunk-7QKCIVAY.cjs → chunk-S4ZHBMD7.cjs} +168 -168
- package/dist/tsup/{chunk-7QKCIVAY.cjs.map → chunk-S4ZHBMD7.cjs.map} +1 -1
- package/dist/tsup/{chunk-VTTFNQQI.js → chunk-TJVQGVTZ.js} +31 -6
- package/dist/tsup/chunk-TJVQGVTZ.js.map +1 -0
- package/dist/tsup/{chunk-2OTRTA3J.js → chunk-VBEZ57VX.js} +2 -2
- package/dist/tsup/{chunk-I4LN3FNT.cjs → chunk-VG6SAPWF.cjs} +7 -7
- package/dist/tsup/{chunk-I4LN3FNT.cjs.map → chunk-VG6SAPWF.cjs.map} +1 -1
- package/dist/tsup/{chunk-DPIMKYNB.js → chunk-XIX5DOZN.js} +10 -1
- package/dist/tsup/chunk-XIX5DOZN.js.map +1 -0
- package/dist/tsup/{chunk-BRP62GZC.js → chunk-ZZ3WBRPD.js} +5 -1
- package/dist/tsup/chunk-ZZ3WBRPD.js.map +1 -0
- package/dist/tsup/client/mod.cjs +8 -8
- package/dist/tsup/client/mod.cjs.map +1 -1
- package/dist/tsup/client/mod.d.cts +3 -3
- package/dist/tsup/client/mod.d.ts +3 -3
- package/dist/tsup/client/mod.js +7 -7
- 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-CZQQ-mso.d.cts → config-CzvopP5m.d.cts} +22 -7
- package/dist/tsup/{config-BxWAw3iH.d.ts → config-DZuT7tcp.d.ts} +22 -7
- package/dist/tsup/context-CyAdY-aA.d.ts +128 -0
- package/dist/tsup/context-sNB28g0N.d.cts +128 -0
- package/dist/tsup/dynamic/mod.cjs +2 -2
- package/dist/tsup/dynamic/mod.d.cts +2 -2
- package/dist/tsup/dynamic/mod.d.ts +2 -2
- package/dist/tsup/dynamic/mod.js +1 -1
- package/dist/tsup/inspector/mod.cjs +6 -6
- package/dist/tsup/inspector/mod.js +5 -5
- package/dist/tsup/inspector-tab/mod.cjs +2 -2
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -1
- package/dist/tsup/inspector-tab/mod.d.cts +3 -3
- package/dist/tsup/inspector-tab/mod.d.ts +3 -3
- package/dist/tsup/inspector-tab/mod.js +1 -1
- package/dist/tsup/inspector-tab/mod.js.map +1 -1
- package/dist/tsup/mod.cjs +293 -277
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +4 -4
- package/dist/tsup/mod.d.ts +4 -4
- package/dist/tsup/mod.js +203 -187
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +10 -10
- package/dist/tsup/test/mod.d.cts +2 -2
- package/dist/tsup/test/mod.d.ts +2 -2
- package/dist/tsup/test/mod.js +6 -6
- package/dist/tsup/{utils-DQosb24I.d.ts → utils-CqDnC_PS.d.cts} +2 -1
- package/dist/tsup/{utils-DQosb24I.d.cts → utils-CqDnC_PS.d.ts} +2 -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 +184 -148
- 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 +177 -141
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +11 -11
- package/src/actor/config.ts +14 -0
- package/src/actor/errors.ts +11 -0
- package/src/inspector-tab/mod.ts +1 -1
- package/src/registry/index.ts +74 -18
- package/src/registry/napi-runtime.ts +16 -0
- package/src/registry/native.ts +79 -30
- package/src/registry/runtime.ts +11 -0
- package/src/registry/wasm-runtime.ts +11 -0
- package/src/utils/env-vars.ts +31 -0
- package/src/workflow/context.ts +675 -244
- package/src/workflow/driver.ts +20 -7
- package/src/workflow/mod.ts +25 -9
- package/dist/tsup/chunk-BRP62GZC.js.map +0 -1
- package/dist/tsup/chunk-DPIMKYNB.js.map +0 -1
- package/dist/tsup/chunk-DXXJPH55.cjs.map +0 -1
- package/dist/tsup/chunk-KORQB2IR.cjs.map +0 -1
- package/dist/tsup/chunk-NIY3RSPX.cjs.map +0 -1
- package/dist/tsup/chunk-VTTFNQQI.js.map +0 -1
- package/dist/tsup/context-Bw7xq8w3.d.cts +0 -92
- package/dist/tsup/context-D8QA76sV.d.ts +0 -92
- package/src/utils/serve.ts +0 -216
- /package/dist/tsup/{chunk-MEHBWPLJ.js.map → chunk-2OIYUYNN.js.map} +0 -0
- /package/dist/tsup/{chunk-UMZVD6DQ.js.map → chunk-2WOKGTL3.js.map} +0 -0
- /package/dist/tsup/{chunk-4JDSFJS5.js.map → chunk-ASKKONXG.js.map} +0 -0
- /package/dist/tsup/{chunk-P2GNQ4RN.js.map → chunk-BDXKVROD.js.map} +0 -0
- /package/dist/tsup/{chunk-BEI24WTI.js.map → chunk-HINDZOY3.js.map} +0 -0
- /package/dist/tsup/{chunk-2OTRTA3J.js.map → chunk-VBEZ57VX.js.map} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ax as Registry, _ as Client } from '../config-
|
|
2
|
-
export {
|
|
1
|
+
import { ax as Registry, _ as Client } from '../config-CzvopP5m.cjs';
|
|
2
|
+
export { b8 as ActorAccessor, b9 as ActorActionFunction, ba as ActorActionOptions, bb as ActorConn, bc as ActorConnRaw, bd as ActorConnStatus, be as ActorConnectOptions, r as ActorDefinition, bf as ActorGatewayOptions, bg as ActorHandle, bh as ActorHandleRaw, A as AnyActorDefinition, bi as ClientRaw, bj as ConnectionStateCallback, bk as CreateOptions, bl as CreateRequest, a9 as Encoding, bm as EventUnsubscribe, bn as ExtractActorsFromRegistry, bo as ExtractRegistryFromClient, bp as GetOptions, bq as GetWithIdOptions, br as QueryOptions, bs as Region, bt as StatusChangeCallback } from '../config-CzvopP5m.cjs';
|
|
3
3
|
import z from 'zod/v4';
|
|
4
4
|
import { GetUpgradeWebSocket } from '../utils.cjs';
|
|
5
|
-
export { R as ActorError, R as RivetError, U as UserError } from '../utils-
|
|
5
|
+
export { R as ActorError, R as RivetError, U as UserError } from '../utils-CqDnC_PS.cjs';
|
|
6
6
|
import '../config-D49x8NpL.cjs';
|
|
7
7
|
import '@rivetkit/rivetkit-wasm';
|
|
8
8
|
import 'zod';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ax as Registry, _ as Client } from '../config-
|
|
2
|
-
export {
|
|
1
|
+
import { ax as Registry, _ as Client } from '../config-DZuT7tcp.js';
|
|
2
|
+
export { b8 as ActorAccessor, b9 as ActorActionFunction, ba as ActorActionOptions, bb as ActorConn, bc as ActorConnRaw, bd as ActorConnStatus, be as ActorConnectOptions, r as ActorDefinition, bf as ActorGatewayOptions, bg as ActorHandle, bh as ActorHandleRaw, A as AnyActorDefinition, bi as ClientRaw, bj as ConnectionStateCallback, bk as CreateOptions, bl as CreateRequest, a9 as Encoding, bm as EventUnsubscribe, bn as ExtractActorsFromRegistry, bo as ExtractRegistryFromClient, bp as GetOptions, bq as GetWithIdOptions, br as QueryOptions, bs as Region, bt as StatusChangeCallback } from '../config-DZuT7tcp.js';
|
|
3
3
|
import z from 'zod/v4';
|
|
4
4
|
import { GetUpgradeWebSocket } from '../utils.js';
|
|
5
|
-
export { R as ActorError, R as RivetError, U as UserError } from '../utils-
|
|
5
|
+
export { R as ActorError, R as RivetError, U as UserError } from '../utils-CqDnC_PS.js';
|
|
6
6
|
import '../config-D49x8NpL.js';
|
|
7
7
|
import '@rivetkit/rivetkit-wasm';
|
|
8
8
|
import 'zod';
|
package/dist/tsup/client/mod.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createClient
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-2OIYUYNN.js";
|
|
4
4
|
import {
|
|
5
5
|
ActorClientError,
|
|
6
6
|
ActorConnDisposed,
|
|
@@ -8,16 +8,16 @@ import {
|
|
|
8
8
|
ActorHandleRaw,
|
|
9
9
|
MalformedResponseMessage,
|
|
10
10
|
ManagerError
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-ASKKONXG.js";
|
|
12
12
|
import "../chunk-HXUEHHJF.js";
|
|
13
|
-
import "../chunk-
|
|
14
|
-
import "../chunk-
|
|
15
|
-
import "../chunk-
|
|
16
|
-
import "../chunk-VTTFNQQI.js";
|
|
13
|
+
import "../chunk-VBEZ57VX.js";
|
|
14
|
+
import "../chunk-HINDZOY3.js";
|
|
15
|
+
import "../chunk-TJVQGVTZ.js";
|
|
17
16
|
import {
|
|
18
17
|
RivetError,
|
|
19
18
|
UserError
|
|
20
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-ZZ3WBRPD.js";
|
|
20
|
+
import "../chunk-JZ7TWV65.js";
|
|
21
21
|
export {
|
|
22
22
|
ActorClientError,
|
|
23
23
|
ActorConnDisposed,
|
package/dist/tsup/common/log.cjs
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
10
|
-
require('../chunk-
|
|
9
|
+
var _chunkRUBJWXFWcjs = require('../chunk-RUBJWXFW.cjs');
|
|
10
|
+
require('../chunk-4FC7TVS6.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -16,5 +16,5 @@ require('../chunk-KORQB2IR.cjs');
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
exports.LogLevelSchema =
|
|
19
|
+
exports.LogLevelSchema = _chunkRUBJWXFWcjs.LogLevelSchema; exports.configureBaseLogger = _chunkRUBJWXFWcjs.configureBaseLogger; exports.configureDefaultLogger = _chunkRUBJWXFWcjs.configureDefaultLogger; exports.getBaseLogger = _chunkRUBJWXFWcjs.getBaseLogger; exports.getIncludeTarget = _chunkRUBJWXFWcjs.getIncludeTarget; exports.getLogger = _chunkRUBJWXFWcjs.getLogger; exports.getPinoLevel = _chunkRUBJWXFWcjs.getPinoLevel;
|
|
20
20
|
//# sourceMappingURL=log.cjs.map
|
package/dist/tsup/common/log.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
5
|
-
require('../chunk-
|
|
3
|
+
var _chunkFRVQ34UVcjs = require('../chunk-FRVQ34UV.cjs');
|
|
4
|
+
require('../chunk-RUBJWXFW.cjs');
|
|
5
|
+
require('../chunk-4FC7TVS6.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
exports.importWebSocket =
|
|
8
|
+
exports.importWebSocket = _chunkFRVQ34UVcjs.importWebSocket;
|
|
9
9
|
//# sourceMappingURL=websocket.cjs.map
|
|
@@ -7,7 +7,7 @@ import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
|
|
|
7
7
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
8
8
|
import { Context, Hono } from 'hono';
|
|
9
9
|
import { GetUpgradeWebSocket } from './utils.cjs';
|
|
10
|
-
import { R as RivetError } from './utils-
|
|
10
|
+
import { R as RivetError } from './utils-CqDnC_PS.cjs';
|
|
11
11
|
|
|
12
12
|
declare const ActorKeySchema: z.ZodArray<z.ZodString>;
|
|
13
13
|
type ActorKey = z.infer<typeof ActorKeySchema>;
|
|
@@ -760,6 +760,11 @@ interface RuntimeServeConfig {
|
|
|
760
760
|
serverlessValidateEndpoint: boolean;
|
|
761
761
|
serverlessMaxStartPayloadBytes: number;
|
|
762
762
|
}
|
|
763
|
+
interface RuntimeListenerConfig {
|
|
764
|
+
port: number;
|
|
765
|
+
host?: string;
|
|
766
|
+
publicDir?: string;
|
|
767
|
+
}
|
|
763
768
|
interface RuntimeServerlessRequest {
|
|
764
769
|
method: string;
|
|
765
770
|
url: string;
|
|
@@ -806,6 +811,7 @@ interface CoreRuntime {
|
|
|
806
811
|
shutdownRegistry(registry: RegistryHandle): Promise<void>;
|
|
807
812
|
registryActorStopThresholdMs?(registry: RegistryHandle): Promise<number | undefined>;
|
|
808
813
|
handleServerlessRequest(registry: RegistryHandle, req: RuntimeServerlessRequest, onStreamEvent: RuntimeServerlessStreamCallback, cancelToken: CancellationTokenHandle, config: RuntimeServeConfig): Promise<RuntimeServerlessResponseHead>;
|
|
814
|
+
serveListener(registry: RegistryHandle, listener: RuntimeListenerConfig, config: RuntimeServeConfig): Promise<void>;
|
|
809
815
|
registryHealth?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
810
816
|
registryMetadata?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
811
817
|
registryMetrics?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
@@ -938,13 +944,15 @@ declare class Registry<A extends RegistryActors> {
|
|
|
938
944
|
*/
|
|
939
945
|
serve(): ServerlessHandler;
|
|
940
946
|
/**
|
|
941
|
-
*
|
|
942
|
-
* serverless
|
|
943
|
-
*
|
|
947
|
+
* Bind an HTTP listener provided by the native (Rust) runtime and serve
|
|
948
|
+
* the registry's serverless endpoints over it. Resolves only after the
|
|
949
|
+
* registry is shut down (SIGINT/SIGTERM or `nativeRegistry.shutdown()`).
|
|
944
950
|
*
|
|
945
|
-
* @param opts.port Port to listen on. Defaults to
|
|
951
|
+
* @param opts.port Port to listen on. Defaults to `process.env.RIVET_PORT`
|
|
952
|
+
* if set, otherwise 3000.
|
|
953
|
+
* @param opts.host Address to bind. Defaults to `0.0.0.0`.
|
|
946
954
|
* @param opts.publicDir If set, serves static files from this directory
|
|
947
|
-
*
|
|
955
|
+
* as a fallback below the framework routes.
|
|
948
956
|
*
|
|
949
957
|
* @example
|
|
950
958
|
* ```ts
|
|
@@ -954,6 +962,7 @@ declare class Registry<A extends RegistryActors> {
|
|
|
954
962
|
*/
|
|
955
963
|
listen(opts?: {
|
|
956
964
|
port?: number;
|
|
965
|
+
host?: string;
|
|
957
966
|
publicDir?: string;
|
|
958
967
|
}): Promise<void>;
|
|
959
968
|
/**
|
|
@@ -981,6 +990,10 @@ declare class Registry<A extends RegistryActors> {
|
|
|
981
990
|
/**
|
|
982
991
|
* Starts the actor envoy for standalone server deployments.
|
|
983
992
|
*
|
|
993
|
+
* Set `RIVETKIT_RUNTIME_MODE=serverless` to instead bind an HTTP listener
|
|
994
|
+
* via `listen()` (Mode B). Mode A (envoy) and Mode B (listener) are
|
|
995
|
+
* mutually exclusive per registry instance.
|
|
996
|
+
*
|
|
984
997
|
* @example
|
|
985
998
|
* ```ts
|
|
986
999
|
* const registry = setup({ use: { counter } });
|
|
@@ -1829,6 +1842,8 @@ declare function getRunMetadata(run: ((...args: any[]) => any) | AnyRunConfig |
|
|
|
1829
1842
|
};
|
|
1830
1843
|
/** Extract run inspector configuration if provided. */
|
|
1831
1844
|
declare function getRunInspectorConfig(run: ((...args: any[]) => any) | AnyRunConfig | undefined, actor?: unknown): RunInspectorConfig | undefined;
|
|
1845
|
+
/** Release per-actor inspector state for a destroyed actor, if the run handler registered a disposer. */
|
|
1846
|
+
declare function disposeRunInspector(run: ((...args: any[]) => any) | AnyRunConfig | undefined, actorId: string): void;
|
|
1832
1847
|
declare const GlobalActorOptionsSchema: z.ZodPrefault<z.ZodObject<{
|
|
1833
1848
|
name: z.ZodOptional<z.ZodString>;
|
|
1834
1849
|
icon: z.ZodOptional<z.ZodString>;
|
|
@@ -2245,4 +2260,4 @@ declare const DocActorConfigSchema: z.ZodObject<{
|
|
|
2245
2260
|
}, z.core.$strip>>;
|
|
2246
2261
|
}, z.core.$strip>;
|
|
2247
2262
|
|
|
2248
|
-
export { type Conn as $, type AnyActorDefinition as A, type BaseActorDefinition as B, type ConnectContext as C, type DestroyContext as D, type EventSchemaConfig as E, type ActorQuery as F, type ActorQueue as G, type ActorSchedule as H, type ActorTypes as I, ActorsSchema as J, type AnyActorInstance as K, type AnyClient as L, type MigrateContext as M, type AnyConn as N, type AnyStaticActorDefinition as O, type AnyStaticActorInstance as P, type QueueSchemaConfig as Q, type RequestContext as R, type SleepContext as S, type AuthIntent as T, BUILTIN_INSPECTOR_TAB_IDS as U, type BaseActorInstance as V, type WakeContext as W, BuiltinInspectorTabIdSchema as X, CONN_DRIVER_SYMBOL as Y, CONN_STATE_MANAGER_SYMBOL as Z, type Client as _, type ActionContext as a,
|
|
2263
|
+
export { type Conn as $, type AnyActorDefinition as A, type BaseActorDefinition as B, type ConnectContext as C, type DestroyContext as D, type EventSchemaConfig as E, type ActorQuery as F, type ActorQueue as G, type ActorSchedule as H, type ActorTypes as I, ActorsSchema as J, type AnyActorInstance as K, type AnyClient as L, type MigrateContext as M, type AnyConn as N, type AnyStaticActorDefinition as O, type AnyStaticActorInstance as P, type QueueSchemaConfig as Q, type RequestContext as R, type SleepContext as S, type AuthIntent as T, BUILTIN_INSPECTOR_TAB_IDS as U, type BaseActorInstance as V, type WakeContext as W, BuiltinInspectorTabIdSchema as X, CONN_DRIVER_SYMBOL as Y, CONN_STATE_MANAGER_SYMBOL as Z, type Client as _, type ActionContext as a, getRunFunction as a$, CustomInspectorTabEntrySchema as a0, DEFAULT_SLEEP_GRACE_PERIOD as a1, DocActorConfigSchema as a2, DocActorOptionsSchema as a3, DocConfigurePoolSchema as a4, DocEnvoyConfigSchema as a5, DocRegistryConfigSchema as a6, DocServerlessConfigSchema as a7, DocSqliteConfigSchema as a8, type Encoding as a9, type RegistryConfigInput as aA, RegistryConfigSchema as aB, type RegistryDeps as aC, type RegistryRoutes as aD, type RunConfig as aE, RunConfigSchema as aF, type RunInspectorConfig as aG, type RuntimeKind as aH, RuntimeKindSchema as aI, type ServerlessHandler as aJ, type SqliteBackend as aK, SqliteBackendSchema as aL, type SqliteConfig as aM, SqliteConfigSchema as aN, type TestConfig as aO, TestConfigSchema as aP, type Type as aQ, type WasmRuntimeBindings as aR, type WasmRuntimeConfig as aS, WasmRuntimeConfigSchema as aT, type WasmRuntimeInitInput as aU, type WorkflowInspectorConfig as aV, actor as aW, buildActorNames as aX, createClientWithDriver as aY, disposeRunInspector as aZ, event as a_, type FetchHandler as aa, type GlobalActorOptions as ab, type GlobalActorOptionsInput as ac, GlobalActorOptionsSchema as ad, HideInspectorTabEntrySchema as ae, InspectorTabEntrySchema as af, type InspectorUnsubscribe as ag, type InstanceActorOptions as ah, type InstanceActorOptionsInput as ai, InstanceActorOptionsSchema as aj, type QueueEnqueueAndWaitOptions as ak, type QueueFilterName as al, type QueueIterOptions as am, type QueueMessageOf as an, type QueueName as ao, type QueueNextBatchOptions as ap, type QueueNextOptions as aq, type QueueResultMessageForName as ar, type QueueTryNextBatchOptions as as, type QueueTryNextOptions as at, type QueueWaitOptions as au, RAW_STATE_SYMBOL as av, RUN_FUNCTION_CONFIG_SYMBOL as aw, Registry as ax, type RegistryActors as ay, type RegistryConfig as az, type BeforeActionResponseContext as b, getRunInspectorConfig as b0, getRunMetadata as b1, isStaticActorDefinition as b2, isStaticActorInstance as b3, lookupInRegistry as b4, queue as b5, setup as b6, test as b7, type ActorAccessor as b8, type ActorActionFunction as b9, type ActorActionOptions as ba, type ActorConn as bb, ActorConnRaw as bc, type ActorConnStatus as bd, type ActorConnectOptions as be, type ActorGatewayOptions as bf, type ActorHandle as bg, ActorHandleRaw as bh, ClientRaw as bi, type ConnectionStateCallback as bj, type CreateOptions as bk, type CreateRequest as bl, type EventUnsubscribe as bm, type ExtractActorsFromRegistry as bn, type ExtractRegistryFromClient as bo, type GetOptions as bp, type GetWithIdOptions as bq, type QueryOptions as br, type Region as bs, type StatusChangeCallback as bt, type InferEventArgs as bu, type InferSchemaMap as bv, type BeforeConnectContext as c, type CreateConnStateContext as d, type CreateContext as e, type CreateVarsContext as f, type DisconnectContext as g, type RunContext as h, type StateChangeContext as i, type WebSocketContext as j, ACTOR_CONTEXT_INTERNAL_SYMBOL as k, type Actions as l, type ActorConfig as m, type ActorConfigInput as n, ActorConfigSchema as o, type ActorContext as p, type ActorContextOf as q, ActorDefinition as r, type ActorInspectorConfig as s, ActorInspectorConfigSchema as t, type ActorKey as u, type ActorKv as v, type ActorLogger as w, type ActorOptions as x, type ActorOptionsInput as y, ActorOptionsSchema as z };
|
|
@@ -7,7 +7,7 @@ import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
|
|
|
7
7
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
8
8
|
import { Context, Hono } from 'hono';
|
|
9
9
|
import { GetUpgradeWebSocket } from './utils.js';
|
|
10
|
-
import { R as RivetError } from './utils-
|
|
10
|
+
import { R as RivetError } from './utils-CqDnC_PS.js';
|
|
11
11
|
|
|
12
12
|
declare const ActorKeySchema: z.ZodArray<z.ZodString>;
|
|
13
13
|
type ActorKey = z.infer<typeof ActorKeySchema>;
|
|
@@ -760,6 +760,11 @@ interface RuntimeServeConfig {
|
|
|
760
760
|
serverlessValidateEndpoint: boolean;
|
|
761
761
|
serverlessMaxStartPayloadBytes: number;
|
|
762
762
|
}
|
|
763
|
+
interface RuntimeListenerConfig {
|
|
764
|
+
port: number;
|
|
765
|
+
host?: string;
|
|
766
|
+
publicDir?: string;
|
|
767
|
+
}
|
|
763
768
|
interface RuntimeServerlessRequest {
|
|
764
769
|
method: string;
|
|
765
770
|
url: string;
|
|
@@ -806,6 +811,7 @@ interface CoreRuntime {
|
|
|
806
811
|
shutdownRegistry(registry: RegistryHandle): Promise<void>;
|
|
807
812
|
registryActorStopThresholdMs?(registry: RegistryHandle): Promise<number | undefined>;
|
|
808
813
|
handleServerlessRequest(registry: RegistryHandle, req: RuntimeServerlessRequest, onStreamEvent: RuntimeServerlessStreamCallback, cancelToken: CancellationTokenHandle, config: RuntimeServeConfig): Promise<RuntimeServerlessResponseHead>;
|
|
814
|
+
serveListener(registry: RegistryHandle, listener: RuntimeListenerConfig, config: RuntimeServeConfig): Promise<void>;
|
|
809
815
|
registryHealth?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
810
816
|
registryMetadata?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
811
817
|
registryMetrics?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
@@ -938,13 +944,15 @@ declare class Registry<A extends RegistryActors> {
|
|
|
938
944
|
*/
|
|
939
945
|
serve(): ServerlessHandler;
|
|
940
946
|
/**
|
|
941
|
-
*
|
|
942
|
-
* serverless
|
|
943
|
-
*
|
|
947
|
+
* Bind an HTTP listener provided by the native (Rust) runtime and serve
|
|
948
|
+
* the registry's serverless endpoints over it. Resolves only after the
|
|
949
|
+
* registry is shut down (SIGINT/SIGTERM or `nativeRegistry.shutdown()`).
|
|
944
950
|
*
|
|
945
|
-
* @param opts.port Port to listen on. Defaults to
|
|
951
|
+
* @param opts.port Port to listen on. Defaults to `process.env.RIVET_PORT`
|
|
952
|
+
* if set, otherwise 3000.
|
|
953
|
+
* @param opts.host Address to bind. Defaults to `0.0.0.0`.
|
|
946
954
|
* @param opts.publicDir If set, serves static files from this directory
|
|
947
|
-
*
|
|
955
|
+
* as a fallback below the framework routes.
|
|
948
956
|
*
|
|
949
957
|
* @example
|
|
950
958
|
* ```ts
|
|
@@ -954,6 +962,7 @@ declare class Registry<A extends RegistryActors> {
|
|
|
954
962
|
*/
|
|
955
963
|
listen(opts?: {
|
|
956
964
|
port?: number;
|
|
965
|
+
host?: string;
|
|
957
966
|
publicDir?: string;
|
|
958
967
|
}): Promise<void>;
|
|
959
968
|
/**
|
|
@@ -981,6 +990,10 @@ declare class Registry<A extends RegistryActors> {
|
|
|
981
990
|
/**
|
|
982
991
|
* Starts the actor envoy for standalone server deployments.
|
|
983
992
|
*
|
|
993
|
+
* Set `RIVETKIT_RUNTIME_MODE=serverless` to instead bind an HTTP listener
|
|
994
|
+
* via `listen()` (Mode B). Mode A (envoy) and Mode B (listener) are
|
|
995
|
+
* mutually exclusive per registry instance.
|
|
996
|
+
*
|
|
984
997
|
* @example
|
|
985
998
|
* ```ts
|
|
986
999
|
* const registry = setup({ use: { counter } });
|
|
@@ -1829,6 +1842,8 @@ declare function getRunMetadata(run: ((...args: any[]) => any) | AnyRunConfig |
|
|
|
1829
1842
|
};
|
|
1830
1843
|
/** Extract run inspector configuration if provided. */
|
|
1831
1844
|
declare function getRunInspectorConfig(run: ((...args: any[]) => any) | AnyRunConfig | undefined, actor?: unknown): RunInspectorConfig | undefined;
|
|
1845
|
+
/** Release per-actor inspector state for a destroyed actor, if the run handler registered a disposer. */
|
|
1846
|
+
declare function disposeRunInspector(run: ((...args: any[]) => any) | AnyRunConfig | undefined, actorId: string): void;
|
|
1832
1847
|
declare const GlobalActorOptionsSchema: z.ZodPrefault<z.ZodObject<{
|
|
1833
1848
|
name: z.ZodOptional<z.ZodString>;
|
|
1834
1849
|
icon: z.ZodOptional<z.ZodString>;
|
|
@@ -2245,4 +2260,4 @@ declare const DocActorConfigSchema: z.ZodObject<{
|
|
|
2245
2260
|
}, z.core.$strip>>;
|
|
2246
2261
|
}, z.core.$strip>;
|
|
2247
2262
|
|
|
2248
|
-
export { type Conn as $, type AnyActorDefinition as A, type BaseActorDefinition as B, type ConnectContext as C, type DestroyContext as D, type EventSchemaConfig as E, type ActorQuery as F, type ActorQueue as G, type ActorSchedule as H, type ActorTypes as I, ActorsSchema as J, type AnyActorInstance as K, type AnyClient as L, type MigrateContext as M, type AnyConn as N, type AnyStaticActorDefinition as O, type AnyStaticActorInstance as P, type QueueSchemaConfig as Q, type RequestContext as R, type SleepContext as S, type AuthIntent as T, BUILTIN_INSPECTOR_TAB_IDS as U, type BaseActorInstance as V, type WakeContext as W, BuiltinInspectorTabIdSchema as X, CONN_DRIVER_SYMBOL as Y, CONN_STATE_MANAGER_SYMBOL as Z, type Client as _, type ActionContext as a,
|
|
2263
|
+
export { type Conn as $, type AnyActorDefinition as A, type BaseActorDefinition as B, type ConnectContext as C, type DestroyContext as D, type EventSchemaConfig as E, type ActorQuery as F, type ActorQueue as G, type ActorSchedule as H, type ActorTypes as I, ActorsSchema as J, type AnyActorInstance as K, type AnyClient as L, type MigrateContext as M, type AnyConn as N, type AnyStaticActorDefinition as O, type AnyStaticActorInstance as P, type QueueSchemaConfig as Q, type RequestContext as R, type SleepContext as S, type AuthIntent as T, BUILTIN_INSPECTOR_TAB_IDS as U, type BaseActorInstance as V, type WakeContext as W, BuiltinInspectorTabIdSchema as X, CONN_DRIVER_SYMBOL as Y, CONN_STATE_MANAGER_SYMBOL as Z, type Client as _, type ActionContext as a, getRunFunction as a$, CustomInspectorTabEntrySchema as a0, DEFAULT_SLEEP_GRACE_PERIOD as a1, DocActorConfigSchema as a2, DocActorOptionsSchema as a3, DocConfigurePoolSchema as a4, DocEnvoyConfigSchema as a5, DocRegistryConfigSchema as a6, DocServerlessConfigSchema as a7, DocSqliteConfigSchema as a8, type Encoding as a9, type RegistryConfigInput as aA, RegistryConfigSchema as aB, type RegistryDeps as aC, type RegistryRoutes as aD, type RunConfig as aE, RunConfigSchema as aF, type RunInspectorConfig as aG, type RuntimeKind as aH, RuntimeKindSchema as aI, type ServerlessHandler as aJ, type SqliteBackend as aK, SqliteBackendSchema as aL, type SqliteConfig as aM, SqliteConfigSchema as aN, type TestConfig as aO, TestConfigSchema as aP, type Type as aQ, type WasmRuntimeBindings as aR, type WasmRuntimeConfig as aS, WasmRuntimeConfigSchema as aT, type WasmRuntimeInitInput as aU, type WorkflowInspectorConfig as aV, actor as aW, buildActorNames as aX, createClientWithDriver as aY, disposeRunInspector as aZ, event as a_, type FetchHandler as aa, type GlobalActorOptions as ab, type GlobalActorOptionsInput as ac, GlobalActorOptionsSchema as ad, HideInspectorTabEntrySchema as ae, InspectorTabEntrySchema as af, type InspectorUnsubscribe as ag, type InstanceActorOptions as ah, type InstanceActorOptionsInput as ai, InstanceActorOptionsSchema as aj, type QueueEnqueueAndWaitOptions as ak, type QueueFilterName as al, type QueueIterOptions as am, type QueueMessageOf as an, type QueueName as ao, type QueueNextBatchOptions as ap, type QueueNextOptions as aq, type QueueResultMessageForName as ar, type QueueTryNextBatchOptions as as, type QueueTryNextOptions as at, type QueueWaitOptions as au, RAW_STATE_SYMBOL as av, RUN_FUNCTION_CONFIG_SYMBOL as aw, Registry as ax, type RegistryActors as ay, type RegistryConfig as az, type BeforeActionResponseContext as b, getRunInspectorConfig as b0, getRunMetadata as b1, isStaticActorDefinition as b2, isStaticActorInstance as b3, lookupInRegistry as b4, queue as b5, setup as b6, test as b7, type ActorAccessor as b8, type ActorActionFunction as b9, type ActorActionOptions as ba, type ActorConn as bb, ActorConnRaw as bc, type ActorConnStatus as bd, type ActorConnectOptions as be, type ActorGatewayOptions as bf, type ActorHandle as bg, ActorHandleRaw as bh, ClientRaw as bi, type ConnectionStateCallback as bj, type CreateOptions as bk, type CreateRequest as bl, type EventUnsubscribe as bm, type ExtractActorsFromRegistry as bn, type ExtractRegistryFromClient as bo, type GetOptions as bp, type GetWithIdOptions as bq, type QueryOptions as br, type Region as bs, type StatusChangeCallback as bt, type InferEventArgs as bu, type InferSchemaMap as bv, type BeforeConnectContext as c, type CreateConnStateContext as d, type CreateContext as e, type CreateVarsContext as f, type DisconnectContext as g, type RunContext as h, type StateChangeContext as i, type WebSocketContext as j, ACTOR_CONTEXT_INTERNAL_SYMBOL as k, type Actions as l, type ActorConfig as m, type ActorConfigInput as n, ActorConfigSchema as o, type ActorContext as p, type ActorContextOf as q, ActorDefinition as r, type ActorInspectorConfig as s, ActorInspectorConfigSchema as t, type ActorKey as u, type ActorKv as v, type ActorLogger as w, type ActorOptions as x, type ActorOptionsInput as y, ActorOptionsSchema as z };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { A as AnyActorDefinition, B as BaseActorDefinition, E as EventSchemaConfig, Q as QueueSchemaConfig, h as RunContext, w as ActorLogger, al as QueueFilterName, aq as QueueNextOptions, ar as QueueResultMessageForName, ap as QueueNextBatchOptions, ax as Registry, _ as Client, bu as InferEventArgs, bv as InferSchemaMap } from './config-DZuT7tcp.js';
|
|
2
|
+
import { WorkflowContextInterface, StepConfig, TryStepResult, TryStepConfig, TryBlockResult, TryBlockConfig, LoopResult, LoopConfig, BranchConfig, BranchOutput, EntryKindType } from '@rivetkit/workflow-engine';
|
|
3
|
+
import { A as AnyDatabaseProvider, I as InferDatabaseClient } from './config-D49x8NpL.js';
|
|
4
|
+
|
|
5
|
+
type WorkflowActorQueueNextOptions<TName extends string, TCompletable extends boolean> = Omit<QueueNextOptions<TName, TCompletable>, "signal">;
|
|
6
|
+
type WorkflowActorQueueNextOptionsFallback<TCompletable extends boolean> = Omit<QueueNextOptions<string, TCompletable>, "signal">;
|
|
7
|
+
type WorkflowActorQueueNextBatchOptions<TName extends string, TCompletable extends boolean> = Omit<QueueNextBatchOptions<TName, TCompletable>, "signal">;
|
|
8
|
+
type WorkflowActorQueueNextBatchOptionsFallback<TCompletable extends boolean> = Omit<QueueNextBatchOptions<string, TCompletable>, "signal">;
|
|
9
|
+
type WorkflowStepRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = (step: WorkflowStepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => Promise<T>;
|
|
10
|
+
type WorkflowStepRollback<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = (step: WorkflowStepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, output: T) => Promise<void>;
|
|
11
|
+
type WorkflowContextRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = (ctx: WorkflowContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => Promise<T>;
|
|
12
|
+
type WorkflowStepConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = Omit<StepConfig<T>, "run" | "rollback"> & {
|
|
13
|
+
run: WorkflowStepRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
14
|
+
rollback?: WorkflowStepRollback<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
15
|
+
};
|
|
16
|
+
type WorkflowTryStepConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = Omit<TryStepConfig<T>, "run" | "rollback"> & {
|
|
17
|
+
run: WorkflowStepRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
18
|
+
rollback?: WorkflowStepRollback<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
19
|
+
};
|
|
20
|
+
type WorkflowTryConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = Omit<TryBlockConfig<T>, "run"> & {
|
|
21
|
+
run: WorkflowContextRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
22
|
+
};
|
|
23
|
+
type WorkflowLoopConfig<S, T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = Omit<LoopConfig<S, T>, "run"> & {
|
|
24
|
+
run: (ctx: WorkflowContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, state: S) => Promise<LoopResult<S, T> | (S extends undefined ? undefined | void : never)>;
|
|
25
|
+
};
|
|
26
|
+
type WorkflowBranchConfig<TOutput, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
|
|
27
|
+
run: WorkflowContextRun<TOutput, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
28
|
+
};
|
|
29
|
+
declare const DEACTIVATE_STEP: unique symbol;
|
|
30
|
+
/**
|
|
31
|
+
* The context handed to a workflow step (`step` / `tryStep` callbacks). This is
|
|
32
|
+
* the only scope where actor data (state, vars, db, client) and side effects
|
|
33
|
+
* (broadcast, queue.send) are reachable. It is valid only while its step is
|
|
34
|
+
* executing; using it after the step resolves throws.
|
|
35
|
+
*/
|
|
36
|
+
declare class WorkflowStepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
37
|
+
#private;
|
|
38
|
+
constructor(runCtx: RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, onGuardViolation: () => void);
|
|
39
|
+
[DEACTIVATE_STEP](): void;
|
|
40
|
+
get actorId(): string;
|
|
41
|
+
get name(): string;
|
|
42
|
+
get key(): string[];
|
|
43
|
+
get log(): ActorLogger;
|
|
44
|
+
get abortSignal(): AbortSignal;
|
|
45
|
+
get state(): TState extends never ? never : TState;
|
|
46
|
+
get vars(): TVars extends never ? never : TVars;
|
|
47
|
+
get db(): TDatabase extends never ? never : InferDatabaseClient<TDatabase>;
|
|
48
|
+
client<R extends Registry<any> = Registry<any>>(): Client<R>;
|
|
49
|
+
broadcast<K extends keyof TEvents & string>(name: K, ...args: InferEventArgs<InferSchemaMap<TEvents>[K]>): void;
|
|
50
|
+
broadcast(name: keyof TEvents extends never ? string : never, ...args: Array<unknown>): void;
|
|
51
|
+
get queue(): {
|
|
52
|
+
send: {
|
|
53
|
+
<K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K]): Promise<void>;
|
|
54
|
+
(name: keyof TQueues extends never ? string : never, body: unknown): Promise<void>;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Holds the actor awake for the duration of the provided promise. The actor
|
|
59
|
+
* cannot idle-sleep or finalize the sleep grace period until the promise
|
|
60
|
+
* settles.
|
|
61
|
+
*/
|
|
62
|
+
keepAwake<T>(promise: Promise<T>): Promise<T>;
|
|
63
|
+
/**
|
|
64
|
+
* Registers a promise that the sleep grace period will wait on. Use this for
|
|
65
|
+
* best-effort flush/cleanup work that may complete inside the grace window.
|
|
66
|
+
*/
|
|
67
|
+
waitUntil(promise: Promise<void>): void;
|
|
68
|
+
destroy(): void;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The context handed to the workflow function and to orchestration callbacks
|
|
72
|
+
* (`try` / `loop` / `race` / `join`). It exposes the deterministic, replayable
|
|
73
|
+
* workflow primitives (step, sleep, queue waits, control flow). It deliberately
|
|
74
|
+
* does NOT expose actor data; reach `state`, `db`, `vars`, `client`, and
|
|
75
|
+
* `broadcast` through the step context passed to `step` / `tryStep`.
|
|
76
|
+
*/
|
|
77
|
+
declare class WorkflowContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
78
|
+
#private;
|
|
79
|
+
constructor(inner: WorkflowContextInterface, runCtx: RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>);
|
|
80
|
+
get workflowId(): string;
|
|
81
|
+
get abortSignal(): AbortSignal;
|
|
82
|
+
get actorId(): string;
|
|
83
|
+
get name(): string;
|
|
84
|
+
get key(): string[];
|
|
85
|
+
get log(): ActorLogger;
|
|
86
|
+
get queue(): {
|
|
87
|
+
next: {
|
|
88
|
+
<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(name: string, opts?: WorkflowActorQueueNextOptions<TName, TCompletable>): Promise<QueueResultMessageForName<TQueues, TName, TCompletable>>;
|
|
89
|
+
<const TCompletable extends boolean = false>(name: string, opts?: WorkflowActorQueueNextOptionsFallback<TCompletable>): Promise<QueueResultMessageForName<TQueues, QueueFilterName<TQueues>, TCompletable>>;
|
|
90
|
+
};
|
|
91
|
+
nextBatch: {
|
|
92
|
+
<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(name: string, opts?: WorkflowActorQueueNextBatchOptions<TName, TCompletable>): Promise<Array<QueueResultMessageForName<TQueues, TName, TCompletable>>>;
|
|
93
|
+
<const TCompletable extends boolean = false>(name: string, opts?: WorkflowActorQueueNextBatchOptionsFallback<TCompletable>): Promise<Array<QueueResultMessageForName<TQueues, QueueFilterName<TQueues>, TCompletable>>>;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
step<T>(name: string, run: WorkflowStepRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<T>;
|
|
97
|
+
step<T>(config: WorkflowStepConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<T>;
|
|
98
|
+
tryStep<T>(name: string, run: WorkflowStepRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<TryStepResult<T>>;
|
|
99
|
+
tryStep<T>(config: WorkflowTryStepConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<TryStepResult<T>>;
|
|
100
|
+
try<T>(name: string, run: WorkflowContextRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<TryBlockResult<T>>;
|
|
101
|
+
try<T>(config: WorkflowTryConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<TryBlockResult<T>>;
|
|
102
|
+
loop<T>(name: string, run: (ctx: WorkflowContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => Promise<LoopResult<undefined, T> | undefined | void>): Promise<T>;
|
|
103
|
+
loop<S, T>(config: WorkflowLoopConfig<S, T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<T>;
|
|
104
|
+
sleep(name: string, durationMs: number): Promise<void>;
|
|
105
|
+
sleepUntil(name: string, timestampMs: number): Promise<void>;
|
|
106
|
+
rollbackCheckpoint(name: string): Promise<void>;
|
|
107
|
+
join<T extends Record<string, WorkflowBranchConfig<unknown, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>>(name: string, branches: T): Promise<{
|
|
108
|
+
[K in keyof T]: Awaited<ReturnType<T[K]["run"]>>;
|
|
109
|
+
}>;
|
|
110
|
+
join<T extends Record<string, BranchConfig<unknown>>>(name: string, branches: T): Promise<{
|
|
111
|
+
[K in keyof T]: BranchOutput<T[K]>;
|
|
112
|
+
}>;
|
|
113
|
+
race<T>(name: string, branches: Array<{
|
|
114
|
+
name: string;
|
|
115
|
+
run: WorkflowContextRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
116
|
+
}>): Promise<{
|
|
117
|
+
winner: string;
|
|
118
|
+
value: T;
|
|
119
|
+
}>;
|
|
120
|
+
removed(name: string, originalType: EntryKindType): Promise<void>;
|
|
121
|
+
isEvicted(): boolean;
|
|
122
|
+
}
|
|
123
|
+
type WorkflowContextOf<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? WorkflowContext<S, CP, CS, V, I, DB, E, Q> : never;
|
|
124
|
+
type WorkflowLoopContextOf<AD extends AnyActorDefinition> = WorkflowContextOf<AD>;
|
|
125
|
+
type WorkflowBranchContextOf<AD extends AnyActorDefinition> = WorkflowContextOf<AD>;
|
|
126
|
+
type WorkflowStepContextOf<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? WorkflowStepContext<S, CP, CS, V, I, DB, E, Q> : never;
|
|
127
|
+
|
|
128
|
+
export { type WorkflowBranchContextOf as W, type WorkflowContextOf as a, type WorkflowLoopContextOf as b, type WorkflowStepContextOf as c, WorkflowContext as d, type WorkflowBranchConfig as e, type WorkflowLoopConfig as f, type WorkflowStepConfig as g, WorkflowStepContext as h, type WorkflowTryConfig as i, type WorkflowTryStepConfig as j };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { A as AnyActorDefinition, B as BaseActorDefinition, E as EventSchemaConfig, Q as QueueSchemaConfig, h as RunContext, w as ActorLogger, al as QueueFilterName, aq as QueueNextOptions, ar as QueueResultMessageForName, ap as QueueNextBatchOptions, ax as Registry, _ as Client, bu as InferEventArgs, bv as InferSchemaMap } from './config-CzvopP5m.cjs';
|
|
2
|
+
import { WorkflowContextInterface, StepConfig, TryStepResult, TryStepConfig, TryBlockResult, TryBlockConfig, LoopResult, LoopConfig, BranchConfig, BranchOutput, EntryKindType } from '@rivetkit/workflow-engine';
|
|
3
|
+
import { A as AnyDatabaseProvider, I as InferDatabaseClient } from './config-D49x8NpL.cjs';
|
|
4
|
+
|
|
5
|
+
type WorkflowActorQueueNextOptions<TName extends string, TCompletable extends boolean> = Omit<QueueNextOptions<TName, TCompletable>, "signal">;
|
|
6
|
+
type WorkflowActorQueueNextOptionsFallback<TCompletable extends boolean> = Omit<QueueNextOptions<string, TCompletable>, "signal">;
|
|
7
|
+
type WorkflowActorQueueNextBatchOptions<TName extends string, TCompletable extends boolean> = Omit<QueueNextBatchOptions<TName, TCompletable>, "signal">;
|
|
8
|
+
type WorkflowActorQueueNextBatchOptionsFallback<TCompletable extends boolean> = Omit<QueueNextBatchOptions<string, TCompletable>, "signal">;
|
|
9
|
+
type WorkflowStepRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = (step: WorkflowStepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => Promise<T>;
|
|
10
|
+
type WorkflowStepRollback<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = (step: WorkflowStepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, output: T) => Promise<void>;
|
|
11
|
+
type WorkflowContextRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = (ctx: WorkflowContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => Promise<T>;
|
|
12
|
+
type WorkflowStepConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = Omit<StepConfig<T>, "run" | "rollback"> & {
|
|
13
|
+
run: WorkflowStepRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
14
|
+
rollback?: WorkflowStepRollback<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
15
|
+
};
|
|
16
|
+
type WorkflowTryStepConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = Omit<TryStepConfig<T>, "run" | "rollback"> & {
|
|
17
|
+
run: WorkflowStepRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
18
|
+
rollback?: WorkflowStepRollback<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
19
|
+
};
|
|
20
|
+
type WorkflowTryConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = Omit<TryBlockConfig<T>, "run"> & {
|
|
21
|
+
run: WorkflowContextRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
22
|
+
};
|
|
23
|
+
type WorkflowLoopConfig<S, T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = Omit<LoopConfig<S, T>, "run"> & {
|
|
24
|
+
run: (ctx: WorkflowContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, state: S) => Promise<LoopResult<S, T> | (S extends undefined ? undefined | void : never)>;
|
|
25
|
+
};
|
|
26
|
+
type WorkflowBranchConfig<TOutput, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
|
|
27
|
+
run: WorkflowContextRun<TOutput, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
28
|
+
};
|
|
29
|
+
declare const DEACTIVATE_STEP: unique symbol;
|
|
30
|
+
/**
|
|
31
|
+
* The context handed to a workflow step (`step` / `tryStep` callbacks). This is
|
|
32
|
+
* the only scope where actor data (state, vars, db, client) and side effects
|
|
33
|
+
* (broadcast, queue.send) are reachable. It is valid only while its step is
|
|
34
|
+
* executing; using it after the step resolves throws.
|
|
35
|
+
*/
|
|
36
|
+
declare class WorkflowStepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
37
|
+
#private;
|
|
38
|
+
constructor(runCtx: RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, onGuardViolation: () => void);
|
|
39
|
+
[DEACTIVATE_STEP](): void;
|
|
40
|
+
get actorId(): string;
|
|
41
|
+
get name(): string;
|
|
42
|
+
get key(): string[];
|
|
43
|
+
get log(): ActorLogger;
|
|
44
|
+
get abortSignal(): AbortSignal;
|
|
45
|
+
get state(): TState extends never ? never : TState;
|
|
46
|
+
get vars(): TVars extends never ? never : TVars;
|
|
47
|
+
get db(): TDatabase extends never ? never : InferDatabaseClient<TDatabase>;
|
|
48
|
+
client<R extends Registry<any> = Registry<any>>(): Client<R>;
|
|
49
|
+
broadcast<K extends keyof TEvents & string>(name: K, ...args: InferEventArgs<InferSchemaMap<TEvents>[K]>): void;
|
|
50
|
+
broadcast(name: keyof TEvents extends never ? string : never, ...args: Array<unknown>): void;
|
|
51
|
+
get queue(): {
|
|
52
|
+
send: {
|
|
53
|
+
<K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K]): Promise<void>;
|
|
54
|
+
(name: keyof TQueues extends never ? string : never, body: unknown): Promise<void>;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Holds the actor awake for the duration of the provided promise. The actor
|
|
59
|
+
* cannot idle-sleep or finalize the sleep grace period until the promise
|
|
60
|
+
* settles.
|
|
61
|
+
*/
|
|
62
|
+
keepAwake<T>(promise: Promise<T>): Promise<T>;
|
|
63
|
+
/**
|
|
64
|
+
* Registers a promise that the sleep grace period will wait on. Use this for
|
|
65
|
+
* best-effort flush/cleanup work that may complete inside the grace window.
|
|
66
|
+
*/
|
|
67
|
+
waitUntil(promise: Promise<void>): void;
|
|
68
|
+
destroy(): void;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The context handed to the workflow function and to orchestration callbacks
|
|
72
|
+
* (`try` / `loop` / `race` / `join`). It exposes the deterministic, replayable
|
|
73
|
+
* workflow primitives (step, sleep, queue waits, control flow). It deliberately
|
|
74
|
+
* does NOT expose actor data; reach `state`, `db`, `vars`, `client`, and
|
|
75
|
+
* `broadcast` through the step context passed to `step` / `tryStep`.
|
|
76
|
+
*/
|
|
77
|
+
declare class WorkflowContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
78
|
+
#private;
|
|
79
|
+
constructor(inner: WorkflowContextInterface, runCtx: RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>);
|
|
80
|
+
get workflowId(): string;
|
|
81
|
+
get abortSignal(): AbortSignal;
|
|
82
|
+
get actorId(): string;
|
|
83
|
+
get name(): string;
|
|
84
|
+
get key(): string[];
|
|
85
|
+
get log(): ActorLogger;
|
|
86
|
+
get queue(): {
|
|
87
|
+
next: {
|
|
88
|
+
<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(name: string, opts?: WorkflowActorQueueNextOptions<TName, TCompletable>): Promise<QueueResultMessageForName<TQueues, TName, TCompletable>>;
|
|
89
|
+
<const TCompletable extends boolean = false>(name: string, opts?: WorkflowActorQueueNextOptionsFallback<TCompletable>): Promise<QueueResultMessageForName<TQueues, QueueFilterName<TQueues>, TCompletable>>;
|
|
90
|
+
};
|
|
91
|
+
nextBatch: {
|
|
92
|
+
<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(name: string, opts?: WorkflowActorQueueNextBatchOptions<TName, TCompletable>): Promise<Array<QueueResultMessageForName<TQueues, TName, TCompletable>>>;
|
|
93
|
+
<const TCompletable extends boolean = false>(name: string, opts?: WorkflowActorQueueNextBatchOptionsFallback<TCompletable>): Promise<Array<QueueResultMessageForName<TQueues, QueueFilterName<TQueues>, TCompletable>>>;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
step<T>(name: string, run: WorkflowStepRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<T>;
|
|
97
|
+
step<T>(config: WorkflowStepConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<T>;
|
|
98
|
+
tryStep<T>(name: string, run: WorkflowStepRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<TryStepResult<T>>;
|
|
99
|
+
tryStep<T>(config: WorkflowTryStepConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<TryStepResult<T>>;
|
|
100
|
+
try<T>(name: string, run: WorkflowContextRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<TryBlockResult<T>>;
|
|
101
|
+
try<T>(config: WorkflowTryConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<TryBlockResult<T>>;
|
|
102
|
+
loop<T>(name: string, run: (ctx: WorkflowContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => Promise<LoopResult<undefined, T> | undefined | void>): Promise<T>;
|
|
103
|
+
loop<S, T>(config: WorkflowLoopConfig<S, T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<T>;
|
|
104
|
+
sleep(name: string, durationMs: number): Promise<void>;
|
|
105
|
+
sleepUntil(name: string, timestampMs: number): Promise<void>;
|
|
106
|
+
rollbackCheckpoint(name: string): Promise<void>;
|
|
107
|
+
join<T extends Record<string, WorkflowBranchConfig<unknown, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>>(name: string, branches: T): Promise<{
|
|
108
|
+
[K in keyof T]: Awaited<ReturnType<T[K]["run"]>>;
|
|
109
|
+
}>;
|
|
110
|
+
join<T extends Record<string, BranchConfig<unknown>>>(name: string, branches: T): Promise<{
|
|
111
|
+
[K in keyof T]: BranchOutput<T[K]>;
|
|
112
|
+
}>;
|
|
113
|
+
race<T>(name: string, branches: Array<{
|
|
114
|
+
name: string;
|
|
115
|
+
run: WorkflowContextRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
116
|
+
}>): Promise<{
|
|
117
|
+
winner: string;
|
|
118
|
+
value: T;
|
|
119
|
+
}>;
|
|
120
|
+
removed(name: string, originalType: EntryKindType): Promise<void>;
|
|
121
|
+
isEvicted(): boolean;
|
|
122
|
+
}
|
|
123
|
+
type WorkflowContextOf<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? WorkflowContext<S, CP, CS, V, I, DB, E, Q> : never;
|
|
124
|
+
type WorkflowLoopContextOf<AD extends AnyActorDefinition> = WorkflowContextOf<AD>;
|
|
125
|
+
type WorkflowBranchContextOf<AD extends AnyActorDefinition> = WorkflowContextOf<AD>;
|
|
126
|
+
type WorkflowStepContextOf<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? WorkflowStepContext<S, CP, CS, V, I, DB, E, Q> : never;
|
|
127
|
+
|
|
128
|
+
export { type WorkflowBranchContextOf as W, type WorkflowContextOf as a, type WorkflowLoopContextOf as b, type WorkflowStepContextOf as c, WorkflowContext as d, type WorkflowBranchConfig as e, type WorkflowLoopConfig as f, type WorkflowStepConfig as g, WorkflowStepContext as h, type WorkflowTryConfig as i, type WorkflowTryStepConfig as j };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk3MHDOUD7cjs = require('../chunk-3MHDOUD7.cjs');
|
|
4
4
|
|
|
5
5
|
// src/dynamic/internal.ts
|
|
6
6
|
var DYNAMIC_ACTOR_DEFINITION_SYMBOL = /* @__PURE__ */ Symbol.for(
|
|
@@ -9,7 +9,7 @@ var DYNAMIC_ACTOR_DEFINITION_SYMBOL = /* @__PURE__ */ Symbol.for(
|
|
|
9
9
|
|
|
10
10
|
// src/dynamic/mod.ts
|
|
11
11
|
function dynamicActor(input) {
|
|
12
|
-
const config =
|
|
12
|
+
const config = _chunk3MHDOUD7cjs.ActorConfigSchema.parse({
|
|
13
13
|
actions: {}
|
|
14
14
|
});
|
|
15
15
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AnyActorDefinition } from '../config-
|
|
1
|
+
import { A as AnyActorDefinition } from '../config-CzvopP5m.cjs';
|
|
2
2
|
import 'zod/v4';
|
|
3
3
|
import '../config-D49x8NpL.cjs';
|
|
4
4
|
import '@rivetkit/rivetkit-wasm';
|
|
@@ -8,7 +8,7 @@ import '@rivetkit/virtual-websocket';
|
|
|
8
8
|
import '@standard-schema/spec';
|
|
9
9
|
import 'hono';
|
|
10
10
|
import '../utils.cjs';
|
|
11
|
-
import '../utils-
|
|
11
|
+
import '../utils-CqDnC_PS.cjs';
|
|
12
12
|
import 'hono/utils/http-status';
|
|
13
13
|
|
|
14
14
|
declare const DYNAMIC_ACTOR_DEFINITION_SYMBOL: unique symbol;
|