rivetkit 2.3.18-rc.4 → 2.3.19
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 +723 -616
- package/dist/browser/client.js +184 -28
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +3 -1
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +6 -2
- package/dist/tsup/actor/errors.cjs.map +1 -1
- package/dist/tsup/actor/errors.d.cts +1 -1
- package/dist/tsup/actor/errors.d.ts +1 -1
- package/dist/tsup/actor/errors.js +5 -1
- package/dist/tsup/agent-os/index.cjs +3 -1
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +110 -3
- package/dist/tsup/agent-os/index.d.ts +110 -3
- package/dist/tsup/agent-os/index.js +3 -1
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-ENDOWQTM.js → chunk-464WE4RF.js} +2 -2
- package/dist/tsup/{chunk-KKG2CTSI.js → chunk-4SC2NSAV.js} +2 -2
- package/dist/tsup/{chunk-R2WRP6VV.cjs → chunk-7A5EIXJJ.cjs} +7 -7
- package/dist/tsup/{chunk-R2WRP6VV.cjs.map → chunk-7A5EIXJJ.cjs.map} +1 -1
- package/dist/tsup/{chunk-GUVDWB2O.cjs → chunk-7BRRGBRY.cjs} +10 -10
- package/dist/tsup/{chunk-GUVDWB2O.cjs.map → chunk-7BRRGBRY.cjs.map} +1 -1
- package/dist/tsup/{chunk-KVPU65TI.js → chunk-7HTST3NX.js} +3 -3
- package/dist/tsup/{chunk-MS6C3B2I.js → chunk-BKX7UDTA.js} +185 -28
- package/dist/tsup/chunk-BKX7UDTA.js.map +1 -0
- package/dist/tsup/{chunk-FL2FDUSZ.js → chunk-DK3L22R6.js} +4 -4
- package/dist/tsup/{chunk-CAL23WOC.js → chunk-DN6MD3KK.js} +7 -7
- package/dist/tsup/chunk-DN6MD3KK.js.map +1 -0
- package/dist/tsup/{chunk-6W5VGLFT.js → chunk-EB77NZL4.js} +1 -1
- package/dist/tsup/chunk-EB77NZL4.js.map +1 -0
- package/dist/tsup/{chunk-4KGXFC6M.cjs → chunk-EO5UOXXY.cjs} +1 -1
- package/dist/tsup/chunk-EO5UOXXY.cjs.map +1 -0
- package/dist/tsup/{chunk-QFLG6UB4.cjs → chunk-G4U5L6AX.cjs} +3 -3
- package/dist/tsup/{chunk-QFLG6UB4.cjs.map → chunk-G4U5L6AX.cjs.map} +1 -1
- package/dist/tsup/{chunk-TGGF6SZN.cjs → chunk-IJUXBWH4.cjs} +351 -194
- package/dist/tsup/chunk-IJUXBWH4.cjs.map +1 -0
- package/dist/tsup/{chunk-2JSYYH6P.cjs → chunk-JX2ITWAV.cjs} +13 -2
- package/dist/tsup/chunk-JX2ITWAV.cjs.map +1 -0
- package/dist/tsup/{chunk-N3DJTMSZ.cjs → chunk-OGPFN6BT.cjs} +3 -3
- package/dist/tsup/{chunk-N3DJTMSZ.cjs.map → chunk-OGPFN6BT.cjs.map} +1 -1
- package/dist/tsup/{chunk-OUQUIBVW.js → chunk-P2OFXH4G.js} +12 -1
- package/dist/tsup/chunk-P2OFXH4G.js.map +1 -0
- package/dist/tsup/{chunk-F3IP3SGO.cjs → chunk-PPEIPCW4.cjs} +4 -4
- package/dist/tsup/{chunk-F3IP3SGO.cjs.map → chunk-PPEIPCW4.cjs.map} +1 -1
- package/dist/tsup/{chunk-7E2W2YSM.cjs → chunk-RJC5O2SD.cjs} +13 -13
- package/dist/tsup/chunk-RJC5O2SD.cjs.map +1 -0
- package/dist/tsup/{chunk-YQD6RRVP.js → chunk-WME6KOXW.js} +2 -2
- package/dist/tsup/{chunk-PLAJJOTE.js → chunk-X7RMJQGY.js} +2 -2
- package/dist/tsup/{chunk-4OMHYVOQ.cjs → chunk-Z4RAXFSD.cjs} +3 -3
- package/dist/tsup/{chunk-4OMHYVOQ.cjs.map → chunk-Z4RAXFSD.cjs.map} +1 -1
- package/dist/tsup/client/mod.cjs +6 -6
- package/dist/tsup/client/mod.d.cts +5 -5
- package/dist/tsup/client/mod.d.ts +5 -5
- package/dist/tsup/client/mod.js +5 -5
- 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-gvHwMas-.d.cts → config-8n2AOhXK.d.cts} +114 -10
- package/dist/tsup/{config-Ug5M2MOr.d.ts → config-DEm0yIVV.d.ts} +114 -10
- package/dist/tsup/{context-DererUCI.d.ts → context-DGg2-IOm.d.ts} +1 -1
- package/dist/tsup/{context-BSCBvbfM.d.cts → context-DwjOVvlE.d.cts} +1 -1
- package/dist/tsup/db/drizzle.cjs +3 -3
- package/dist/tsup/db/drizzle.js +2 -2
- package/dist/tsup/db/mod.cjs +4 -4
- package/dist/tsup/db/mod.js +3 -3
- package/dist/tsup/dynamic/mod.cjs +2 -2
- package/dist/tsup/dynamic/mod.d.cts +3 -3
- package/dist/tsup/dynamic/mod.d.ts +3 -3
- 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/workflow.cjs +5 -5
- package/dist/tsup/inspector/workflow.js +4 -4
- package/dist/tsup/inspector-tab/mod.cjs +2 -2
- package/dist/tsup/inspector-tab/mod.d.cts +4 -4
- package/dist/tsup/inspector-tab/mod.d.ts +4 -4
- package/dist/tsup/inspector-tab/mod.js +1 -1
- package/dist/tsup/mod.cjs +492 -319
- 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 +367 -194
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +7 -7
- package/dist/tsup/test/mod.d.cts +3 -3
- package/dist/tsup/test/mod.d.ts +3 -3
- package/dist/tsup/test/mod.js +5 -5
- package/dist/tsup/{utils-Bbz-3411.d.cts → utils-CNFeS-Dk.d.cts} +1 -1
- package/dist/tsup/{utils-vvJQyygr.d.ts → utils-DsoDinPz.d.cts} +9 -1
- package/dist/tsup/{utils-vvJQyygr.d.cts → utils-DsoDinPz.d.ts} +9 -1
- package/dist/tsup/{utils-BqdWVlzm.d.ts → utils-OQHBjfcM.d.ts} +1 -1
- package/dist/tsup/utils.cjs +3 -3
- package/dist/tsup/utils.d.cts +2 -2
- package/dist/tsup/utils.d.ts +2 -2
- package/dist/tsup/utils.js +2 -2
- package/dist/tsup/workflow/mod.cjs +33 -27
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +5 -5
- package/dist/tsup/workflow/mod.d.ts +5 -5
- package/dist/tsup/workflow/mod.js +25 -19
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +10 -8
- package/src/actor/config.ts +38 -0
- package/src/actor/errors.ts +31 -0
- package/src/client/actor-conn.ts +7 -0
- package/src/client/actor-handle.ts +57 -17
- package/src/client/client.ts +26 -6
- package/src/client/outbound-telemetry.ts +66 -0
- package/src/client/queue.ts +3 -0
- package/src/client/raw-utils.ts +3 -0
- package/src/common/actor-router-consts.ts +3 -0
- package/src/common/actor-telemetry-context.ts +19 -0
- package/src/common/otel-context.ts +99 -0
- package/src/common/utils.ts +1 -19
- package/src/engine-client/actor-http-client.ts +15 -0
- package/src/registry/index.ts +6 -0
- package/src/registry/napi-runtime.ts +155 -35
- package/src/registry/native.ts +277 -191
- package/src/registry/runtime.ts +66 -0
- package/src/registry/wasm-runtime.ts +40 -0
- package/src/workflow/driver.ts +20 -12
- package/dist/tsup/chunk-2JSYYH6P.cjs.map +0 -1
- package/dist/tsup/chunk-4KGXFC6M.cjs.map +0 -1
- package/dist/tsup/chunk-6W5VGLFT.js.map +0 -1
- package/dist/tsup/chunk-7E2W2YSM.cjs.map +0 -1
- package/dist/tsup/chunk-CAL23WOC.js.map +0 -1
- package/dist/tsup/chunk-MS6C3B2I.js.map +0 -1
- package/dist/tsup/chunk-OUQUIBVW.js.map +0 -1
- package/dist/tsup/chunk-TGGF6SZN.cjs.map +0 -1
- /package/dist/tsup/{chunk-ENDOWQTM.js.map → chunk-464WE4RF.js.map} +0 -0
- /package/dist/tsup/{chunk-KKG2CTSI.js.map → chunk-4SC2NSAV.js.map} +0 -0
- /package/dist/tsup/{chunk-KVPU65TI.js.map → chunk-7HTST3NX.js.map} +0 -0
- /package/dist/tsup/{chunk-FL2FDUSZ.js.map → chunk-DK3L22R6.js.map} +0 -0
- /package/dist/tsup/{chunk-YQD6RRVP.js.map → chunk-WME6KOXW.js.map} +0 -0
- /package/dist/tsup/{chunk-PLAJJOTE.js.map → chunk-X7RMJQGY.js.map} +0 -0
|
@@ -624,6 +624,25 @@ interface ActorOutput {
|
|
|
624
624
|
error?: unknown;
|
|
625
625
|
}
|
|
626
626
|
|
|
627
|
+
/** Correlation owned by the currently executing Core actor invocation. */
|
|
628
|
+
interface ActorInvocationTraceContext {
|
|
629
|
+
/** Ray ID the invocation received, absent when nothing upstream supplied one. */
|
|
630
|
+
readonly rayId?: string;
|
|
631
|
+
/** Core-owned invocation span context, absent when tracing is disabled. */
|
|
632
|
+
readonly span?: ActorInvocationSpanContext;
|
|
633
|
+
}
|
|
634
|
+
/** W3C span context of the Core invocation span. */
|
|
635
|
+
interface ActorInvocationSpanContext {
|
|
636
|
+
/** W3C trace identifier. */
|
|
637
|
+
readonly traceId: string;
|
|
638
|
+
/** W3C span identifier for the Core invocation. */
|
|
639
|
+
readonly spanId: string;
|
|
640
|
+
/** OpenTelemetry trace flags encoded as an integer. */
|
|
641
|
+
readonly traceFlags: number;
|
|
642
|
+
/** Optional vendor trace state inherited by the Core invocation. */
|
|
643
|
+
readonly tracestate?: string;
|
|
644
|
+
}
|
|
645
|
+
|
|
627
646
|
declare const handleBrand: unique symbol;
|
|
628
647
|
type OpaqueHandle<Name extends string> = {
|
|
629
648
|
readonly [handleBrand]: Name;
|
|
@@ -642,6 +661,27 @@ interface RuntimeActorKeySegment {
|
|
|
642
661
|
stringValue?: string;
|
|
643
662
|
numberValue?: number;
|
|
644
663
|
}
|
|
664
|
+
/** Resolves correlation at operation time so retained clients cannot freeze stale context. */
|
|
665
|
+
type CurrentActorInvocation = () => ActorInvocationTraceContext | undefined;
|
|
666
|
+
/** One open call from an actor out to another actor. */
|
|
667
|
+
interface RuntimeOutboundCall {
|
|
668
|
+
/**
|
|
669
|
+
* W3C context of the call's own span, to send to the callee so it parents to
|
|
670
|
+
* the call. Absent when tracing is disabled.
|
|
671
|
+
*/
|
|
672
|
+
readonly span?: ActorInvocationSpanContext;
|
|
673
|
+
/**
|
|
674
|
+
* Records the call's outcome. `error` is the failure encoded the way the
|
|
675
|
+
* bridge encodes errors, so a structured error keeps its group and code.
|
|
676
|
+
*/
|
|
677
|
+
finish(error?: string): void;
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* Opens the span covering one call out to another actor, or returns `undefined`
|
|
681
|
+
* outside an invocation or on a runtime without invocation telemetry. Callers
|
|
682
|
+
* send their own context when it returns nothing.
|
|
683
|
+
*/
|
|
684
|
+
type StartCallSpan = (actorName: string, actionName: string) => RuntimeOutboundCall | undefined;
|
|
645
685
|
interface RuntimeHttpRequest {
|
|
646
686
|
method: string;
|
|
647
687
|
uri: string;
|
|
@@ -939,6 +979,7 @@ interface CoreRuntime {
|
|
|
939
979
|
serveRegistry(registry: RegistryHandle, config: RuntimeServeConfig): Promise<void>;
|
|
940
980
|
waitRegistryReady(registry: RegistryHandle): Promise<void>;
|
|
941
981
|
shutdownRegistry(registry: RegistryHandle): Promise<void>;
|
|
982
|
+
shutdownTelemetry?(): Promise<void>;
|
|
942
983
|
registryActorStopThresholdMs?(registry: RegistryHandle): Promise<number | undefined>;
|
|
943
984
|
handleServerlessRequest(registry: RegistryHandle, req: RuntimeServerlessRequest, onStreamEvent: RuntimeServerlessStreamCallback, cancelToken: CancellationTokenHandle, config: RuntimeServeConfig): Promise<RuntimeServerlessResponseHead>;
|
|
944
985
|
serveListener(registry: RegistryHandle, listener: RuntimeListenerConfig, config: RuntimeServeConfig): Promise<void>;
|
|
@@ -968,6 +1009,31 @@ interface CoreRuntime {
|
|
|
968
1009
|
actorSaveState(ctx: ActorContextHandle, payload: RuntimeStateDeltaPayload): Promise<void>;
|
|
969
1010
|
actorSaveStateAndWorkflowBatch(ctx: ActorContextHandle, writes: RuntimeWorkflowKvWrite[]): Promise<void>;
|
|
970
1011
|
actorId(ctx: ActorContextHandle): string;
|
|
1012
|
+
/**
|
|
1013
|
+
* Runs one actor callback with `ctx` as the current invocation: operations
|
|
1014
|
+
* on retained handles for the same actor resolve to it, and its Core span
|
|
1015
|
+
* is the active OpenTelemetry span for the duration of `run`. Only actions,
|
|
1016
|
+
* raw requests, and queue dispatch run this way; other callbacks have no
|
|
1017
|
+
* invocation span.
|
|
1018
|
+
*/
|
|
1019
|
+
runWithActorInvocationContext<T>(ctx: ActorContextHandle, run: () => T): T;
|
|
1020
|
+
/**
|
|
1021
|
+
* Correlation of the invocation currently executing for this actor, or
|
|
1022
|
+
* `undefined` outside an invocation or after it finished. A sampled-out
|
|
1023
|
+
* invocation can still expose valid span context for propagation.
|
|
1024
|
+
*/
|
|
1025
|
+
actorInvocationTraceContext(ctx: ActorContextHandle): ActorInvocationTraceContext | undefined;
|
|
1026
|
+
/**
|
|
1027
|
+
* Opens the span covering one call this actor makes to another actor. See
|
|
1028
|
+
* `StartCallSpan` for when this returns nothing.
|
|
1029
|
+
*/
|
|
1030
|
+
startCallSpan(ctx: ActorContextHandle, actorName: string, actionName: string): RuntimeOutboundCall | undefined;
|
|
1031
|
+
/** Backs `ActorRun.startWorkflowSpan`. */
|
|
1032
|
+
startWorkflowSpan(ctx: ActorContextHandle): Promise<WorkflowSpan>;
|
|
1033
|
+
/** Backs `ActorRun.runOutsideWorkflowSpan`. */
|
|
1034
|
+
runOutsideActorInvocationContext<T>(run: () => T): T;
|
|
1035
|
+
/** Identity of the invocation the caller runs in, usable as a cache key. */
|
|
1036
|
+
currentInvocationScope(): object | undefined;
|
|
971
1037
|
actorName(ctx: ActorContextHandle): string;
|
|
972
1038
|
actorKey(ctx: ActorContextHandle): RuntimeActorKeySegment[];
|
|
973
1039
|
actorRegion(ctx: ActorContextHandle): string;
|
|
@@ -1306,7 +1372,7 @@ declare class ActorConnRaw {
|
|
|
1306
1372
|
*
|
|
1307
1373
|
* @protected
|
|
1308
1374
|
*/
|
|
1309
|
-
constructor(client: ClientRaw, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState, gatewayOptions?: ActorGatewayOptions);
|
|
1375
|
+
constructor(client: ClientRaw, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState, gatewayOptions?: ActorGatewayOptions, currentActorInvocation?: CurrentActorInvocation);
|
|
1310
1376
|
send(name: string, body: unknown, options: QueueSendWaitOptions): Promise<QueueSendResult>;
|
|
1311
1377
|
send(name: string, body: unknown, options?: QueueSendNoWaitOptions): Promise<void>;
|
|
1312
1378
|
/**
|
|
@@ -1442,7 +1508,7 @@ declare class ActorHandleRaw {
|
|
|
1442
1508
|
*
|
|
1443
1509
|
* @protected
|
|
1444
1510
|
*/
|
|
1445
|
-
constructor(client: any, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState, gatewayOptions?: ActorGatewayOptions, signal?: AbortSignal);
|
|
1511
|
+
constructor(client: any, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState, gatewayOptions?: ActorGatewayOptions, signal?: AbortSignal, currentActorInvocation?: CurrentActorInvocation, startCallSpan?: StartCallSpan);
|
|
1446
1512
|
send(name: string, body: unknown, options: QueueSendWaitOptions): Promise<QueueSendResult>;
|
|
1447
1513
|
send(name: string, body: unknown, options?: QueueSendNoWaitOptions): Promise<void>;
|
|
1448
1514
|
/**
|
|
@@ -1617,6 +1683,18 @@ interface CreateOptions extends QueryOptions {
|
|
|
1617
1683
|
}
|
|
1618
1684
|
declare const ACTOR_CONNS_SYMBOL: unique symbol;
|
|
1619
1685
|
declare const CREATE_ACTOR_CONN_PROXY: unique symbol;
|
|
1686
|
+
/** Options for constructing a raw actor client. */
|
|
1687
|
+
interface ClientRawOptions {
|
|
1688
|
+
encoding?: Encoding;
|
|
1689
|
+
gateway?: ActorGatewayOptions;
|
|
1690
|
+
}
|
|
1691
|
+
/** Runtime-supplied wiring for clients created inside an actor. Set only by the native runtime. */
|
|
1692
|
+
interface ActorClientRuntimeOptions {
|
|
1693
|
+
/** Supplies the calling actor's invocation so actor-to-actor clients propagate its trace and ray ID. */
|
|
1694
|
+
currentActorInvocation?: CurrentActorInvocation;
|
|
1695
|
+
/** Opens and finishes the Core span covering an actor-to-actor call. */
|
|
1696
|
+
startCallSpan?: StartCallSpan;
|
|
1697
|
+
}
|
|
1620
1698
|
/**
|
|
1621
1699
|
* Client for managing & connecting to actors.
|
|
1622
1700
|
*
|
|
@@ -1629,7 +1707,7 @@ declare class ClientRaw {
|
|
|
1629
1707
|
/**
|
|
1630
1708
|
* Creates an instance of Client.
|
|
1631
1709
|
*/
|
|
1632
|
-
constructor(driver: EngineControlClient,
|
|
1710
|
+
constructor(driver: EngineControlClient, options?: ClientRawOptions & ActorClientRuntimeOptions);
|
|
1633
1711
|
/**
|
|
1634
1712
|
* Gets a stateless handle to a actor by its ID.
|
|
1635
1713
|
*
|
|
@@ -1936,6 +2014,28 @@ interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase
|
|
|
1936
2014
|
client<T = any>(): ActorClientFor<T>;
|
|
1937
2015
|
[key: string]: any;
|
|
1938
2016
|
}
|
|
2017
|
+
/** @experimental How one run of a workflow function ended. */
|
|
2018
|
+
type WorkflowOutcome = "completed" | "sleeping" | "evicted" | "failed" | "cancelled";
|
|
2019
|
+
/** @experimental How one workflow step attempt ended. `retry` will be tried again, `failed` will not. */
|
|
2020
|
+
type WorkflowStepOutcome = "ok" | "retry" | "failed";
|
|
2021
|
+
/** @experimental One open run of a workflow function, traced as its own invocation. */
|
|
2022
|
+
interface WorkflowSpan {
|
|
2023
|
+
/** Runs `body` attributed to this run. */
|
|
2024
|
+
run<T>(body: () => Promise<T>): Promise<T>;
|
|
2025
|
+
/**
|
|
2026
|
+
* Called by a workflow engine before each attempt at a step. Returns
|
|
2027
|
+
* nothing when tracing is off.
|
|
2028
|
+
*/
|
|
2029
|
+
startStep(name: string, attempt: number): WorkflowStepSpan | undefined;
|
|
2030
|
+
finish(outcome: WorkflowOutcome): Promise<void>;
|
|
2031
|
+
}
|
|
2032
|
+
/** @experimental One open attempt at one workflow step. */
|
|
2033
|
+
interface WorkflowStepSpan {
|
|
2034
|
+
/** Runs `body` attributed to this attempt. */
|
|
2035
|
+
run<T>(body: () => Promise<T>): Promise<T>;
|
|
2036
|
+
/** `error` is what the step callback threw. */
|
|
2037
|
+
finish(outcome: WorkflowStepOutcome, error?: unknown): void;
|
|
2038
|
+
}
|
|
1939
2039
|
/** @experimental */
|
|
1940
2040
|
interface ActorRun {
|
|
1941
2041
|
/**
|
|
@@ -1943,6 +2043,13 @@ interface ActorRun {
|
|
|
1943
2043
|
* ensures this actor's run handler is active, starting it if inactive.
|
|
1944
2044
|
*/
|
|
1945
2045
|
setWakeAt(timestamp: number | null): Promise<void>;
|
|
2046
|
+
/** @experimental Called by a workflow engine each time it runs the workflow function. */
|
|
2047
|
+
startWorkflowSpan(): Promise<WorkflowSpan>;
|
|
2048
|
+
/**
|
|
2049
|
+
* @experimental Runs `body` outside the current workflow run, so a workflow
|
|
2050
|
+
* engine's own history storage stays out of the trace.
|
|
2051
|
+
*/
|
|
2052
|
+
runOutsideWorkflowSpan<T>(body: () => T): T;
|
|
1946
2053
|
}
|
|
1947
2054
|
type ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & {
|
|
1948
2055
|
conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
@@ -624,6 +624,25 @@ interface ActorOutput {
|
|
|
624
624
|
error?: unknown;
|
|
625
625
|
}
|
|
626
626
|
|
|
627
|
+
/** Correlation owned by the currently executing Core actor invocation. */
|
|
628
|
+
interface ActorInvocationTraceContext {
|
|
629
|
+
/** Ray ID the invocation received, absent when nothing upstream supplied one. */
|
|
630
|
+
readonly rayId?: string;
|
|
631
|
+
/** Core-owned invocation span context, absent when tracing is disabled. */
|
|
632
|
+
readonly span?: ActorInvocationSpanContext;
|
|
633
|
+
}
|
|
634
|
+
/** W3C span context of the Core invocation span. */
|
|
635
|
+
interface ActorInvocationSpanContext {
|
|
636
|
+
/** W3C trace identifier. */
|
|
637
|
+
readonly traceId: string;
|
|
638
|
+
/** W3C span identifier for the Core invocation. */
|
|
639
|
+
readonly spanId: string;
|
|
640
|
+
/** OpenTelemetry trace flags encoded as an integer. */
|
|
641
|
+
readonly traceFlags: number;
|
|
642
|
+
/** Optional vendor trace state inherited by the Core invocation. */
|
|
643
|
+
readonly tracestate?: string;
|
|
644
|
+
}
|
|
645
|
+
|
|
627
646
|
declare const handleBrand: unique symbol;
|
|
628
647
|
type OpaqueHandle<Name extends string> = {
|
|
629
648
|
readonly [handleBrand]: Name;
|
|
@@ -642,6 +661,27 @@ interface RuntimeActorKeySegment {
|
|
|
642
661
|
stringValue?: string;
|
|
643
662
|
numberValue?: number;
|
|
644
663
|
}
|
|
664
|
+
/** Resolves correlation at operation time so retained clients cannot freeze stale context. */
|
|
665
|
+
type CurrentActorInvocation = () => ActorInvocationTraceContext | undefined;
|
|
666
|
+
/** One open call from an actor out to another actor. */
|
|
667
|
+
interface RuntimeOutboundCall {
|
|
668
|
+
/**
|
|
669
|
+
* W3C context of the call's own span, to send to the callee so it parents to
|
|
670
|
+
* the call. Absent when tracing is disabled.
|
|
671
|
+
*/
|
|
672
|
+
readonly span?: ActorInvocationSpanContext;
|
|
673
|
+
/**
|
|
674
|
+
* Records the call's outcome. `error` is the failure encoded the way the
|
|
675
|
+
* bridge encodes errors, so a structured error keeps its group and code.
|
|
676
|
+
*/
|
|
677
|
+
finish(error?: string): void;
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* Opens the span covering one call out to another actor, or returns `undefined`
|
|
681
|
+
* outside an invocation or on a runtime without invocation telemetry. Callers
|
|
682
|
+
* send their own context when it returns nothing.
|
|
683
|
+
*/
|
|
684
|
+
type StartCallSpan = (actorName: string, actionName: string) => RuntimeOutboundCall | undefined;
|
|
645
685
|
interface RuntimeHttpRequest {
|
|
646
686
|
method: string;
|
|
647
687
|
uri: string;
|
|
@@ -939,6 +979,7 @@ interface CoreRuntime {
|
|
|
939
979
|
serveRegistry(registry: RegistryHandle, config: RuntimeServeConfig): Promise<void>;
|
|
940
980
|
waitRegistryReady(registry: RegistryHandle): Promise<void>;
|
|
941
981
|
shutdownRegistry(registry: RegistryHandle): Promise<void>;
|
|
982
|
+
shutdownTelemetry?(): Promise<void>;
|
|
942
983
|
registryActorStopThresholdMs?(registry: RegistryHandle): Promise<number | undefined>;
|
|
943
984
|
handleServerlessRequest(registry: RegistryHandle, req: RuntimeServerlessRequest, onStreamEvent: RuntimeServerlessStreamCallback, cancelToken: CancellationTokenHandle, config: RuntimeServeConfig): Promise<RuntimeServerlessResponseHead>;
|
|
944
985
|
serveListener(registry: RegistryHandle, listener: RuntimeListenerConfig, config: RuntimeServeConfig): Promise<void>;
|
|
@@ -968,6 +1009,31 @@ interface CoreRuntime {
|
|
|
968
1009
|
actorSaveState(ctx: ActorContextHandle, payload: RuntimeStateDeltaPayload): Promise<void>;
|
|
969
1010
|
actorSaveStateAndWorkflowBatch(ctx: ActorContextHandle, writes: RuntimeWorkflowKvWrite[]): Promise<void>;
|
|
970
1011
|
actorId(ctx: ActorContextHandle): string;
|
|
1012
|
+
/**
|
|
1013
|
+
* Runs one actor callback with `ctx` as the current invocation: operations
|
|
1014
|
+
* on retained handles for the same actor resolve to it, and its Core span
|
|
1015
|
+
* is the active OpenTelemetry span for the duration of `run`. Only actions,
|
|
1016
|
+
* raw requests, and queue dispatch run this way; other callbacks have no
|
|
1017
|
+
* invocation span.
|
|
1018
|
+
*/
|
|
1019
|
+
runWithActorInvocationContext<T>(ctx: ActorContextHandle, run: () => T): T;
|
|
1020
|
+
/**
|
|
1021
|
+
* Correlation of the invocation currently executing for this actor, or
|
|
1022
|
+
* `undefined` outside an invocation or after it finished. A sampled-out
|
|
1023
|
+
* invocation can still expose valid span context for propagation.
|
|
1024
|
+
*/
|
|
1025
|
+
actorInvocationTraceContext(ctx: ActorContextHandle): ActorInvocationTraceContext | undefined;
|
|
1026
|
+
/**
|
|
1027
|
+
* Opens the span covering one call this actor makes to another actor. See
|
|
1028
|
+
* `StartCallSpan` for when this returns nothing.
|
|
1029
|
+
*/
|
|
1030
|
+
startCallSpan(ctx: ActorContextHandle, actorName: string, actionName: string): RuntimeOutboundCall | undefined;
|
|
1031
|
+
/** Backs `ActorRun.startWorkflowSpan`. */
|
|
1032
|
+
startWorkflowSpan(ctx: ActorContextHandle): Promise<WorkflowSpan>;
|
|
1033
|
+
/** Backs `ActorRun.runOutsideWorkflowSpan`. */
|
|
1034
|
+
runOutsideActorInvocationContext<T>(run: () => T): T;
|
|
1035
|
+
/** Identity of the invocation the caller runs in, usable as a cache key. */
|
|
1036
|
+
currentInvocationScope(): object | undefined;
|
|
971
1037
|
actorName(ctx: ActorContextHandle): string;
|
|
972
1038
|
actorKey(ctx: ActorContextHandle): RuntimeActorKeySegment[];
|
|
973
1039
|
actorRegion(ctx: ActorContextHandle): string;
|
|
@@ -1306,7 +1372,7 @@ declare class ActorConnRaw {
|
|
|
1306
1372
|
*
|
|
1307
1373
|
* @protected
|
|
1308
1374
|
*/
|
|
1309
|
-
constructor(client: ClientRaw, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState, gatewayOptions?: ActorGatewayOptions);
|
|
1375
|
+
constructor(client: ClientRaw, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState, gatewayOptions?: ActorGatewayOptions, currentActorInvocation?: CurrentActorInvocation);
|
|
1310
1376
|
send(name: string, body: unknown, options: QueueSendWaitOptions): Promise<QueueSendResult>;
|
|
1311
1377
|
send(name: string, body: unknown, options?: QueueSendNoWaitOptions): Promise<void>;
|
|
1312
1378
|
/**
|
|
@@ -1442,7 +1508,7 @@ declare class ActorHandleRaw {
|
|
|
1442
1508
|
*
|
|
1443
1509
|
* @protected
|
|
1444
1510
|
*/
|
|
1445
|
-
constructor(client: any, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState, gatewayOptions?: ActorGatewayOptions, signal?: AbortSignal);
|
|
1511
|
+
constructor(client: any, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState, gatewayOptions?: ActorGatewayOptions, signal?: AbortSignal, currentActorInvocation?: CurrentActorInvocation, startCallSpan?: StartCallSpan);
|
|
1446
1512
|
send(name: string, body: unknown, options: QueueSendWaitOptions): Promise<QueueSendResult>;
|
|
1447
1513
|
send(name: string, body: unknown, options?: QueueSendNoWaitOptions): Promise<void>;
|
|
1448
1514
|
/**
|
|
@@ -1617,6 +1683,18 @@ interface CreateOptions extends QueryOptions {
|
|
|
1617
1683
|
}
|
|
1618
1684
|
declare const ACTOR_CONNS_SYMBOL: unique symbol;
|
|
1619
1685
|
declare const CREATE_ACTOR_CONN_PROXY: unique symbol;
|
|
1686
|
+
/** Options for constructing a raw actor client. */
|
|
1687
|
+
interface ClientRawOptions {
|
|
1688
|
+
encoding?: Encoding;
|
|
1689
|
+
gateway?: ActorGatewayOptions;
|
|
1690
|
+
}
|
|
1691
|
+
/** Runtime-supplied wiring for clients created inside an actor. Set only by the native runtime. */
|
|
1692
|
+
interface ActorClientRuntimeOptions {
|
|
1693
|
+
/** Supplies the calling actor's invocation so actor-to-actor clients propagate its trace and ray ID. */
|
|
1694
|
+
currentActorInvocation?: CurrentActorInvocation;
|
|
1695
|
+
/** Opens and finishes the Core span covering an actor-to-actor call. */
|
|
1696
|
+
startCallSpan?: StartCallSpan;
|
|
1697
|
+
}
|
|
1620
1698
|
/**
|
|
1621
1699
|
* Client for managing & connecting to actors.
|
|
1622
1700
|
*
|
|
@@ -1629,7 +1707,7 @@ declare class ClientRaw {
|
|
|
1629
1707
|
/**
|
|
1630
1708
|
* Creates an instance of Client.
|
|
1631
1709
|
*/
|
|
1632
|
-
constructor(driver: EngineControlClient,
|
|
1710
|
+
constructor(driver: EngineControlClient, options?: ClientRawOptions & ActorClientRuntimeOptions);
|
|
1633
1711
|
/**
|
|
1634
1712
|
* Gets a stateless handle to a actor by its ID.
|
|
1635
1713
|
*
|
|
@@ -1936,6 +2014,28 @@ interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase
|
|
|
1936
2014
|
client<T = any>(): ActorClientFor<T>;
|
|
1937
2015
|
[key: string]: any;
|
|
1938
2016
|
}
|
|
2017
|
+
/** @experimental How one run of a workflow function ended. */
|
|
2018
|
+
type WorkflowOutcome = "completed" | "sleeping" | "evicted" | "failed" | "cancelled";
|
|
2019
|
+
/** @experimental How one workflow step attempt ended. `retry` will be tried again, `failed` will not. */
|
|
2020
|
+
type WorkflowStepOutcome = "ok" | "retry" | "failed";
|
|
2021
|
+
/** @experimental One open run of a workflow function, traced as its own invocation. */
|
|
2022
|
+
interface WorkflowSpan {
|
|
2023
|
+
/** Runs `body` attributed to this run. */
|
|
2024
|
+
run<T>(body: () => Promise<T>): Promise<T>;
|
|
2025
|
+
/**
|
|
2026
|
+
* Called by a workflow engine before each attempt at a step. Returns
|
|
2027
|
+
* nothing when tracing is off.
|
|
2028
|
+
*/
|
|
2029
|
+
startStep(name: string, attempt: number): WorkflowStepSpan | undefined;
|
|
2030
|
+
finish(outcome: WorkflowOutcome): Promise<void>;
|
|
2031
|
+
}
|
|
2032
|
+
/** @experimental One open attempt at one workflow step. */
|
|
2033
|
+
interface WorkflowStepSpan {
|
|
2034
|
+
/** Runs `body` attributed to this attempt. */
|
|
2035
|
+
run<T>(body: () => Promise<T>): Promise<T>;
|
|
2036
|
+
/** `error` is what the step callback threw. */
|
|
2037
|
+
finish(outcome: WorkflowStepOutcome, error?: unknown): void;
|
|
2038
|
+
}
|
|
1939
2039
|
/** @experimental */
|
|
1940
2040
|
interface ActorRun {
|
|
1941
2041
|
/**
|
|
@@ -1943,6 +2043,13 @@ interface ActorRun {
|
|
|
1943
2043
|
* ensures this actor's run handler is active, starting it if inactive.
|
|
1944
2044
|
*/
|
|
1945
2045
|
setWakeAt(timestamp: number | null): Promise<void>;
|
|
2046
|
+
/** @experimental Called by a workflow engine each time it runs the workflow function. */
|
|
2047
|
+
startWorkflowSpan(): Promise<WorkflowSpan>;
|
|
2048
|
+
/**
|
|
2049
|
+
* @experimental Runs `body` outside the current workflow run, so a workflow
|
|
2050
|
+
* engine's own history storage stays out of the trace.
|
|
2051
|
+
*/
|
|
2052
|
+
runOutsideWorkflowSpan<T>(body: () => T): T;
|
|
1946
2053
|
}
|
|
1947
2054
|
type ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & {
|
|
1948
2055
|
conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
@@ -420,7 +420,7 @@ function isRivetErrorCode(error, group, code) {
|
|
|
420
420
|
// package.json
|
|
421
421
|
var package_default = {
|
|
422
422
|
name: "rivetkit",
|
|
423
|
-
version: "2.3.
|
|
423
|
+
version: "2.3.19",
|
|
424
424
|
description: "Lightweight libraries for building stateful actors on edge platforms",
|
|
425
425
|
license: "Apache-2.0",
|
|
426
426
|
keywords: [
|
|
@@ -629,6 +629,7 @@ var package_default = {
|
|
|
629
629
|
},
|
|
630
630
|
dependencies: {
|
|
631
631
|
"@hono/zod-openapi": "^1.1.5",
|
|
632
|
+
"@opentelemetry/api": "^1.1.0",
|
|
632
633
|
"@rivet-dev/agent-os-core": "^0.1.1",
|
|
633
634
|
"@rivet-dev/services": "^0.1.5",
|
|
634
635
|
"@rivetkit/bare-ts": "^0.6.2",
|
|
@@ -655,6 +656,7 @@ var package_default = {
|
|
|
655
656
|
"@copilotkit/llmock": "^1.6.0",
|
|
656
657
|
"@hono/node-server": "^1.18.2",
|
|
657
658
|
"@hono/node-ws": "^1.1.1",
|
|
659
|
+
"@opentelemetry/sdk-trace-node": "2.11.0",
|
|
658
660
|
"@rivet-dev/agent-os-common": "*",
|
|
659
661
|
"@rivet-dev/agent-os-pi": "^0.1.1",
|
|
660
662
|
"@standard-schema/spec": "^1.0.0",
|