rivetkit 2.3.19 → 2.3.21
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 +82 -5
- package/dist/browser/client.js +302 -60
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +2 -1
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs.map +1 -1
- package/dist/tsup/agent-os/index.cjs +35 -1
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +71 -4
- package/dist/tsup/agent-os/index.d.ts +71 -4
- package/dist/tsup/agent-os/index.js +35 -1
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-X7RMJQGY.js → chunk-2CI2IEVN.js} +2 -2
- package/dist/tsup/{chunk-WME6KOXW.js → chunk-5EGLHQJJ.js} +2 -2
- package/dist/tsup/{chunk-464WE4RF.js → chunk-5IBUZFLP.js} +2 -2
- package/dist/tsup/{chunk-PPEIPCW4.cjs → chunk-6LRPYB4Q.cjs} +4 -4
- package/dist/tsup/chunk-6LRPYB4Q.cjs.map +1 -0
- package/dist/tsup/{chunk-7BRRGBRY.cjs → chunk-APOANSDG.cjs} +10 -10
- package/dist/tsup/chunk-APOANSDG.cjs.map +1 -0
- package/dist/tsup/{chunk-G4U5L6AX.cjs → chunk-ARGNQGYG.cjs} +3 -3
- package/dist/tsup/chunk-ARGNQGYG.cjs.map +1 -0
- package/dist/tsup/{chunk-IJUXBWH4.cjs → chunk-B5SNXPSS.cjs} +448 -199
- package/dist/tsup/chunk-B5SNXPSS.cjs.map +1 -0
- package/dist/tsup/{chunk-4SC2NSAV.js → chunk-CJXBGTVT.js} +2 -2
- package/dist/tsup/{chunk-EB77NZL4.js → chunk-CSOHAAZK.js} +33 -1
- package/dist/tsup/chunk-CSOHAAZK.js.map +1 -0
- package/dist/tsup/{chunk-Z4RAXFSD.cjs → chunk-GHKQC4PD.cjs} +3 -3
- package/dist/tsup/chunk-GHKQC4PD.cjs.map +1 -0
- package/dist/tsup/chunk-JX2ITWAV.cjs.map +1 -1
- package/dist/tsup/chunk-KVFIONKQ.cjs.map +1 -1
- package/dist/tsup/{chunk-RJC5O2SD.cjs → chunk-KWGN2ZBJ.cjs} +3 -2
- package/dist/tsup/chunk-KWGN2ZBJ.cjs.map +1 -0
- package/dist/tsup/{chunk-OGPFN6BT.cjs → chunk-LWSLKKZ5.cjs} +3 -3
- package/dist/tsup/chunk-LWSLKKZ5.cjs.map +1 -0
- package/dist/tsup/chunk-MYWZCDML.cjs.map +1 -1
- package/dist/tsup/{chunk-7A5EIXJJ.cjs → chunk-NL2EIKK6.cjs} +7 -7
- package/dist/tsup/chunk-NL2EIKK6.cjs.map +1 -0
- package/dist/tsup/{chunk-EO5UOXXY.cjs → chunk-NWCAIWHL.cjs} +34 -2
- package/dist/tsup/chunk-NWCAIWHL.cjs.map +1 -0
- package/dist/tsup/{chunk-BKX7UDTA.js → chunk-PYRI75DL.js} +314 -65
- package/dist/tsup/chunk-PYRI75DL.js.map +1 -0
- package/dist/tsup/{chunk-7HTST3NX.js → chunk-RFN3BG6D.js} +3 -3
- package/dist/tsup/chunk-RFN3BG6D.js.map +1 -0
- package/dist/tsup/{chunk-DN6MD3KK.js → chunk-RGIZNZYO.js} +3 -2
- package/dist/tsup/chunk-RGIZNZYO.js.map +1 -0
- package/dist/tsup/{chunk-DK3L22R6.js → chunk-VMMXXVDO.js} +4 -4
- package/dist/tsup/client/mod.cjs +5 -5
- package/dist/tsup/client/mod.cjs.map +1 -1
- package/dist/tsup/client/mod.d.cts +12 -3
- package/dist/tsup/client/mod.d.ts +12 -3
- package/dist/tsup/client/mod.js +4 -4
- package/dist/tsup/common/log.cjs +2 -2
- package/dist/tsup/common/log.cjs.map +1 -1
- package/dist/tsup/common/log.js +1 -1
- package/dist/tsup/common/websocket.cjs +3 -3
- package/dist/tsup/common/websocket.cjs.map +1 -1
- package/dist/tsup/common/websocket.js +2 -2
- package/dist/tsup/{config-DEm0yIVV.d.ts → config-Bc1nnvUl.d.ts} +76 -6
- package/dist/tsup/{config-8n2AOhXK.d.cts → config-Do_0guSS.d.cts} +76 -6
- package/dist/tsup/{context-DwjOVvlE.d.cts → context-CgNkhjdY.d.cts} +1 -1
- package/dist/tsup/{context-DGg2-IOm.d.ts → context-oGQxZDPz.d.ts} +1 -1
- package/dist/tsup/db/drizzle.cjs +2 -2
- package/dist/tsup/db/drizzle.cjs.map +1 -1
- package/dist/tsup/db/drizzle.js +1 -1
- package/dist/tsup/db/mod.cjs +3 -3
- package/dist/tsup/db/mod.cjs.map +1 -1
- package/dist/tsup/db/mod.js +2 -2
- package/dist/tsup/dynamic/mod.cjs +2 -2
- package/dist/tsup/dynamic/mod.cjs.map +1 -1
- package/dist/tsup/dynamic/mod.d.cts +2 -1
- package/dist/tsup/dynamic/mod.d.ts +2 -1
- package/dist/tsup/dynamic/mod.js +1 -1
- package/dist/tsup/inspector/mod.cjs +5 -5
- package/dist/tsup/inspector/mod.cjs.map +1 -1
- package/dist/tsup/inspector/mod.js +4 -4
- package/dist/tsup/inspector/workflow.cjs +4 -4
- package/dist/tsup/inspector/workflow.cjs.map +1 -1
- package/dist/tsup/inspector/workflow.js +3 -3
- 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 -2
- package/dist/tsup/inspector-tab/mod.d.ts +3 -2
- package/dist/tsup/inspector-tab/mod.js +1 -1
- package/dist/tsup/mod.cjs +140 -136
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +4 -3
- package/dist/tsup/mod.d.ts +4 -3
- package/dist/tsup/mod.js +44 -40
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +6 -6
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +2 -1
- package/dist/tsup/test/mod.d.ts +2 -1
- package/dist/tsup/test/mod.js +4 -4
- package/dist/tsup/unstable/migrations.cjs.map +1 -1
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.cjs.map +1 -1
- package/dist/tsup/utils.js +1 -1
- package/dist/tsup/workflow/mod.cjs +10 -10
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +4 -3
- package/dist/tsup/workflow/mod.d.ts +4 -3
- package/dist/tsup/workflow/mod.js +5 -5
- package/package.json +10 -9
- package/src/actor/actions.ts +36 -0
- package/src/actor/config.ts +27 -0
- package/src/actor/definition.ts +6 -1
- package/src/actor/mod.ts +5 -0
- package/src/actor/tracing.ts +28 -0
- package/src/client/actor-conn.ts +34 -1
- package/src/client/actor-handle.ts +29 -1
- package/src/client/auth.ts +37 -0
- package/src/client/client.ts +10 -2
- package/src/client/config.ts +12 -1
- package/src/client/mod.ts +9 -0
- package/src/client/token-provider.test.ts +86 -0
- package/src/client/token-provider.ts +93 -0
- package/src/client/utils.ts +1 -0
- package/src/engine-client/actor-websocket-client.ts +2 -1
- package/src/engine-client/api-endpoints.ts +28 -0
- package/src/engine-client/driver.ts +4 -0
- package/src/engine-client/mod.ts +201 -64
- package/src/registry/config/envoy.ts +1 -17
- package/src/registry/config/index.test.ts +2 -2
- package/src/registry/config/index.ts +7 -2
- package/src/registry/index.ts +28 -0
- package/src/registry/native.ts +18 -0
- package/src/registry/runtime.ts +8 -0
- package/dist/tsup/chunk-7A5EIXJJ.cjs.map +0 -1
- package/dist/tsup/chunk-7BRRGBRY.cjs.map +0 -1
- package/dist/tsup/chunk-7HTST3NX.js.map +0 -1
- package/dist/tsup/chunk-BKX7UDTA.js.map +0 -1
- package/dist/tsup/chunk-DN6MD3KK.js.map +0 -1
- package/dist/tsup/chunk-EB77NZL4.js.map +0 -1
- package/dist/tsup/chunk-EO5UOXXY.cjs.map +0 -1
- package/dist/tsup/chunk-G4U5L6AX.cjs.map +0 -1
- package/dist/tsup/chunk-IJUXBWH4.cjs.map +0 -1
- package/dist/tsup/chunk-OGPFN6BT.cjs.map +0 -1
- package/dist/tsup/chunk-PPEIPCW4.cjs.map +0 -1
- package/dist/tsup/chunk-RJC5O2SD.cjs.map +0 -1
- package/dist/tsup/chunk-Z4RAXFSD.cjs.map +0 -1
- /package/dist/tsup/{chunk-X7RMJQGY.js.map → chunk-2CI2IEVN.js.map} +0 -0
- /package/dist/tsup/{chunk-WME6KOXW.js.map → chunk-5EGLHQJJ.js.map} +0 -0
- /package/dist/tsup/{chunk-464WE4RF.js.map → chunk-5IBUZFLP.js.map} +0 -0
- /package/dist/tsup/{chunk-4SC2NSAV.js.map → chunk-CJXBGTVT.js.map} +0 -0
- /package/dist/tsup/{chunk-DK3L22R6.js.map → chunk-VMMXXVDO.js.map} +0 -0
|
@@ -2,6 +2,7 @@ import * as _rivet_dev_agent_os_core from '@rivet-dev/agent-os-core';
|
|
|
2
2
|
import { AgentOs, JsonRpcNotification, PermissionRequest, CronEvent, AgentCapabilities, AgentInfo, JsonRpcResponse, AgentOsOptions, BatchReadResult, BatchWriteEntry, BatchWriteResult, ReaddirRecursiveOptions, DirEntry, AgentRegistryEntry, SpawnedProcessInfo, ProcessInfo, ProcessTreeNode, SessionModeState, SessionConfigOption, GetEventsOptions, SequencedEvent, PermissionReply, AgentType, CreateSessionOptions, SessionInfo, OpenShellOptions } from '@rivet-dev/agent-os-core';
|
|
3
3
|
import { z as z$1 } from 'zod/v4';
|
|
4
4
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
5
|
+
import { Rivet } from '@rivetkit/engine-api-full';
|
|
5
6
|
import { Context, Handler, Hono } from 'hono';
|
|
6
7
|
import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
|
|
7
8
|
import * as _rivetkit_rivetkit_wasm from '@rivetkit/rivetkit-wasm';
|
|
@@ -272,7 +273,7 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
272
273
|
endpoint: string | undefined;
|
|
273
274
|
startServices: boolean;
|
|
274
275
|
namespace: string;
|
|
275
|
-
token: string;
|
|
276
|
+
token: string | undefined;
|
|
276
277
|
publicEndpoint: string | undefined;
|
|
277
278
|
publicNamespace: string | undefined;
|
|
278
279
|
publicToken: string | undefined;
|
|
@@ -445,6 +446,24 @@ declare class ActorDefinition<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E
|
|
|
445
446
|
get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q, R>;
|
|
446
447
|
}
|
|
447
448
|
|
|
449
|
+
/** Options for `client.auth.issueToken()`. `expiresIn` is in seconds. */
|
|
450
|
+
type IssueTokenOptions = Pick<Rivet.AuthTokenCreateRequest, "subject" | "grants"> & {
|
|
451
|
+
expiresIn?: Rivet.AuthTokenCreateRequest["duration"];
|
|
452
|
+
};
|
|
453
|
+
/** Token timestamps are Unix milliseconds. */
|
|
454
|
+
interface IssuedToken {
|
|
455
|
+
token: Rivet.AuthTokenCreateResponse["token"];
|
|
456
|
+
issuedAt: Rivet.AuthTokenCreateResponse["issuedTs"];
|
|
457
|
+
expiresAt: Rivet.AuthTokenCreateResponse["expiresTs"];
|
|
458
|
+
}
|
|
459
|
+
/** Resources that can be scoped to a single actor ID. */
|
|
460
|
+
type ActorTokenResource = Extract<Rivet.AuthTokenGrant["resource"], "actor_gateway" | "actor" | "actor_kv">;
|
|
461
|
+
type ActorTokenPermissions = Partial<Record<ActorTokenResource, Rivet.AuthTokenGrant["operations"]>>;
|
|
462
|
+
/** Options for `actor.issueToken()`. Omit permissions for gateway read access only. */
|
|
463
|
+
type ActorIssueTokenOptions = Pick<IssueTokenOptions, "subject" | "expiresIn"> & {
|
|
464
|
+
permissions?: ActorTokenPermissions;
|
|
465
|
+
};
|
|
466
|
+
|
|
448
467
|
declare const EncodingSchema: z$1.ZodEnum<{
|
|
449
468
|
json: "json";
|
|
450
469
|
cbor: "cbor";
|
|
@@ -543,6 +562,29 @@ declare class RivetError extends Error {
|
|
|
543
562
|
toString(): string;
|
|
544
563
|
}
|
|
545
564
|
|
|
565
|
+
/** Sample rates keyed by action name, nested like the actor's action groups. */
|
|
566
|
+
interface ActionSampleRates {
|
|
567
|
+
readonly [name: string]: number | ActionSampleRates;
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* {@link ActionSampleRates} limited to the actions of one actor, so a rate for
|
|
571
|
+
* an action that does not exist is a compile error.
|
|
572
|
+
*/
|
|
573
|
+
type ActionTraceSamplers<TActions> = {
|
|
574
|
+
readonly [K in keyof TActions]?: TActions[K] extends (...args: never[]) => unknown ? number : ActionTraceSamplers<TActions[K]>;
|
|
575
|
+
};
|
|
576
|
+
/** Trace sampling for one actor definition. */
|
|
577
|
+
interface ActorTracingOptions<TActions> {
|
|
578
|
+
/**
|
|
579
|
+
* Share of this actor's invocations that are recorded, from 0 to 1. A rate
|
|
580
|
+
* lowers what is recorded and never raises it, so an invocation inside a
|
|
581
|
+
* trace the caller did not record is not recorded at any rate.
|
|
582
|
+
*/
|
|
583
|
+
readonly sampler?: number;
|
|
584
|
+
/** Rates that replace `sampler` for single actions. */
|
|
585
|
+
readonly actions?: ActionTraceSamplers<TActions>;
|
|
586
|
+
}
|
|
587
|
+
|
|
546
588
|
type UpgradeWebSocket = (createEvents: (c: Context) => any) => Handler;
|
|
547
589
|
type GetUpgradeWebSocket = () => UpgradeWebSocket;
|
|
548
590
|
|
|
@@ -553,6 +595,7 @@ interface GatewayRequestOptions {
|
|
|
553
595
|
skipReadyWait?: boolean;
|
|
554
596
|
}
|
|
555
597
|
interface EngineControlClient {
|
|
598
|
+
issueToken(options: IssueTokenOptions): Promise<IssuedToken>;
|
|
556
599
|
getForId(input: GetForIdInput): Promise<ActorOutput | undefined>;
|
|
557
600
|
getWithKey(input: GetWithKeyInput): Promise<ActorOutput | undefined>;
|
|
558
601
|
getOrCreateWithKey(input: GetOrCreateWithKeyInput): Promise<ActorOutput>;
|
|
@@ -560,6 +603,8 @@ interface EngineControlClient {
|
|
|
560
603
|
listActors(input: ListActorsInput): Promise<ActorOutput[]>;
|
|
561
604
|
sendRequest(target: GatewayTarget, actorRequest: Request, options?: GatewayRequestOptions): Promise<Response>;
|
|
562
605
|
openWebSocket(path: string, target: GatewayTarget, encoding: Encoding, params: unknown, options?: GatewayRequestOptions): Promise<UniversalWebSocket>;
|
|
606
|
+
/** Refresh a credential rejected during this WebSocket handshake, if supported. */
|
|
607
|
+
refreshAuthToken?(ws: UniversalWebSocket): Promise<boolean>;
|
|
563
608
|
proxyRequest(c: Context, actorRequest: Request, actorId: string): Promise<Response>;
|
|
564
609
|
proxyWebSocket(c: Context, path: string, actorId: string, encoding: Encoding, params: unknown): Promise<Response>;
|
|
565
610
|
buildGatewayUrl(target: GatewayTarget, options?: GatewayRequestOptions): Promise<string>;
|
|
@@ -842,12 +887,19 @@ interface RuntimeSqlBatchStatement {
|
|
|
842
887
|
interface RuntimeSqlRunResult {
|
|
843
888
|
changes: number;
|
|
844
889
|
}
|
|
890
|
+
/** Sample rates for the traces an actor starts, in the shape core takes. */
|
|
891
|
+
interface RuntimeActorTracingConfig {
|
|
892
|
+
sampler?: number;
|
|
893
|
+
/** Keyed by flattened, dot-separated action name. */
|
|
894
|
+
actions?: Record<string, number>;
|
|
895
|
+
}
|
|
845
896
|
interface RuntimeActorConfig {
|
|
846
897
|
name?: string;
|
|
847
898
|
icon?: string;
|
|
848
899
|
hasDatabase?: boolean;
|
|
849
900
|
remoteSqlite?: boolean;
|
|
850
901
|
sqliteProfiling?: SqliteProfilingOptions;
|
|
902
|
+
tracing?: RuntimeActorTracingConfig;
|
|
851
903
|
enableActorRuntimeSocket?: boolean;
|
|
852
904
|
hasState?: boolean;
|
|
853
905
|
canHibernateWebsocket?: boolean;
|
|
@@ -1542,6 +1594,8 @@ declare class ActorHandleRaw {
|
|
|
1542
1594
|
* Resolves the actor to get its unique actor ID.
|
|
1543
1595
|
*/
|
|
1544
1596
|
resolve(): Promise<string>;
|
|
1597
|
+
/** Issue a token scoped to this actor. Defaults to actor gateway read access. */
|
|
1598
|
+
issueToken(options?: ActorIssueTokenOptions): Promise<IssuedToken>;
|
|
1545
1599
|
/**
|
|
1546
1600
|
* Returns the raw URL for routing traffic to the actor.
|
|
1547
1601
|
*/
|
|
@@ -1567,7 +1621,7 @@ declare class ActorHandleRaw {
|
|
|
1567
1621
|
type ActorHandle<AD extends AnyActorDefinition> = Omit<ActorHandleRaw, "connect" | "send"> & {
|
|
1568
1622
|
connect(params?: unknown, options?: ActorConnectOptions): ActorConn<AD>;
|
|
1569
1623
|
resolve(): Promise<string>;
|
|
1570
|
-
} & ActorDefinitionQueueSend<AD> & ActorDefinitionActions<AD>;
|
|
1624
|
+
} & ActorDefinitionQueueSend<AD> & Omit<ActorDefinitionActions<AD>, keyof ActorHandleRaw>;
|
|
1571
1625
|
|
|
1572
1626
|
/** Extract the actor registry from the registry definition. */
|
|
1573
1627
|
type ExtractActorsFromRegistry<A extends Registry<any>> = A extends Registry<infer Actors> ? Actors : never;
|
|
@@ -1703,6 +1757,10 @@ interface ActorClientRuntimeOptions {
|
|
|
1703
1757
|
*/
|
|
1704
1758
|
declare class ClientRaw {
|
|
1705
1759
|
#private;
|
|
1760
|
+
/** Issue namespace-scoped tokens with an explicit grant list. */
|
|
1761
|
+
readonly auth: {
|
|
1762
|
+
issueToken(options: IssueTokenOptions): Promise<IssuedToken>;
|
|
1763
|
+
};
|
|
1706
1764
|
[ACTOR_CONNS_SYMBOL]: Set<ActorConnRaw>;
|
|
1707
1765
|
/**
|
|
1708
1766
|
* Creates an instance of Client.
|
|
@@ -1763,9 +1821,9 @@ declare class ClientRaw {
|
|
|
1763
1821
|
*
|
|
1764
1822
|
* @template A The actor registry type.
|
|
1765
1823
|
*/
|
|
1766
|
-
type Client<A extends Registry<any>> = ClientRaw & {
|
|
1824
|
+
type Client<A extends Registry<any>> = ClientRaw & Omit<{
|
|
1767
1825
|
[K in keyof ExtractActorsFromRegistry<A>]: ActorAccessor<ExtractActorsFromRegistry<A>[K]>;
|
|
1768
|
-
}
|
|
1826
|
+
}, keyof ClientRaw>;
|
|
1769
1827
|
|
|
1770
1828
|
/** @experimental State exposed by a durable workflow run handler to the Inspector. */
|
|
1771
1829
|
type WorkflowState = "pending" | "running" | "sleeping" | "failed" | "completed" | "cancelled" | "rolling_back";
|
|
@@ -2115,6 +2173,10 @@ declare const ActorConfigSchema: z$1.ZodObject<{
|
|
|
2115
2173
|
onWebSocket: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
2116
2174
|
actions: z$1.ZodDefault<z$1.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
|
|
2117
2175
|
actionInputSchemas: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
2176
|
+
tracing: z$1.ZodOptional<z$1.ZodObject<{
|
|
2177
|
+
sampler: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2178
|
+
actions: z$1.ZodOptional<z$1.ZodType<ActionSampleRates, unknown, z$1.core.$ZodTypeInternals<ActionSampleRates, unknown>>>;
|
|
2179
|
+
}, z$1.core.$strict>>;
|
|
2118
2180
|
connParamsSchema: z$1.ZodOptional<z$1.ZodAny>;
|
|
2119
2181
|
events: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
2120
2182
|
queues: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
@@ -2355,6 +2417,11 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
|
|
|
2355
2417
|
* May mirror nested action groups or use dot-separated low-level action names.
|
|
2356
2418
|
*/
|
|
2357
2419
|
actionInputSchemas?: ActionInputSchemas;
|
|
2420
|
+
/**
|
|
2421
|
+
* How much of this actor's work is recorded in traces. Defaults to the
|
|
2422
|
+
* process sampler from `OTEL_TRACES_SAMPLER`.
|
|
2423
|
+
*/
|
|
2424
|
+
tracing?: ActorTracingOptions<TActions>;
|
|
2358
2425
|
/**
|
|
2359
2426
|
* Optional schema for validating connection params in native runtimes.
|
|
2360
2427
|
*/
|
|
@@ -2,6 +2,7 @@ import * as _rivet_dev_agent_os_core from '@rivet-dev/agent-os-core';
|
|
|
2
2
|
import { AgentOs, JsonRpcNotification, PermissionRequest, CronEvent, AgentCapabilities, AgentInfo, JsonRpcResponse, AgentOsOptions, BatchReadResult, BatchWriteEntry, BatchWriteResult, ReaddirRecursiveOptions, DirEntry, AgentRegistryEntry, SpawnedProcessInfo, ProcessInfo, ProcessTreeNode, SessionModeState, SessionConfigOption, GetEventsOptions, SequencedEvent, PermissionReply, AgentType, CreateSessionOptions, SessionInfo, OpenShellOptions } from '@rivet-dev/agent-os-core';
|
|
3
3
|
import { z as z$1 } from 'zod/v4';
|
|
4
4
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
5
|
+
import { Rivet } from '@rivetkit/engine-api-full';
|
|
5
6
|
import { Context, Handler, Hono } from 'hono';
|
|
6
7
|
import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
|
|
7
8
|
import * as _rivetkit_rivetkit_wasm from '@rivetkit/rivetkit-wasm';
|
|
@@ -272,7 +273,7 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
272
273
|
endpoint: string | undefined;
|
|
273
274
|
startServices: boolean;
|
|
274
275
|
namespace: string;
|
|
275
|
-
token: string;
|
|
276
|
+
token: string | undefined;
|
|
276
277
|
publicEndpoint: string | undefined;
|
|
277
278
|
publicNamespace: string | undefined;
|
|
278
279
|
publicToken: string | undefined;
|
|
@@ -445,6 +446,24 @@ declare class ActorDefinition<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E
|
|
|
445
446
|
get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q, R>;
|
|
446
447
|
}
|
|
447
448
|
|
|
449
|
+
/** Options for `client.auth.issueToken()`. `expiresIn` is in seconds. */
|
|
450
|
+
type IssueTokenOptions = Pick<Rivet.AuthTokenCreateRequest, "subject" | "grants"> & {
|
|
451
|
+
expiresIn?: Rivet.AuthTokenCreateRequest["duration"];
|
|
452
|
+
};
|
|
453
|
+
/** Token timestamps are Unix milliseconds. */
|
|
454
|
+
interface IssuedToken {
|
|
455
|
+
token: Rivet.AuthTokenCreateResponse["token"];
|
|
456
|
+
issuedAt: Rivet.AuthTokenCreateResponse["issuedTs"];
|
|
457
|
+
expiresAt: Rivet.AuthTokenCreateResponse["expiresTs"];
|
|
458
|
+
}
|
|
459
|
+
/** Resources that can be scoped to a single actor ID. */
|
|
460
|
+
type ActorTokenResource = Extract<Rivet.AuthTokenGrant["resource"], "actor_gateway" | "actor" | "actor_kv">;
|
|
461
|
+
type ActorTokenPermissions = Partial<Record<ActorTokenResource, Rivet.AuthTokenGrant["operations"]>>;
|
|
462
|
+
/** Options for `actor.issueToken()`. Omit permissions for gateway read access only. */
|
|
463
|
+
type ActorIssueTokenOptions = Pick<IssueTokenOptions, "subject" | "expiresIn"> & {
|
|
464
|
+
permissions?: ActorTokenPermissions;
|
|
465
|
+
};
|
|
466
|
+
|
|
448
467
|
declare const EncodingSchema: z$1.ZodEnum<{
|
|
449
468
|
json: "json";
|
|
450
469
|
cbor: "cbor";
|
|
@@ -543,6 +562,29 @@ declare class RivetError extends Error {
|
|
|
543
562
|
toString(): string;
|
|
544
563
|
}
|
|
545
564
|
|
|
565
|
+
/** Sample rates keyed by action name, nested like the actor's action groups. */
|
|
566
|
+
interface ActionSampleRates {
|
|
567
|
+
readonly [name: string]: number | ActionSampleRates;
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* {@link ActionSampleRates} limited to the actions of one actor, so a rate for
|
|
571
|
+
* an action that does not exist is a compile error.
|
|
572
|
+
*/
|
|
573
|
+
type ActionTraceSamplers<TActions> = {
|
|
574
|
+
readonly [K in keyof TActions]?: TActions[K] extends (...args: never[]) => unknown ? number : ActionTraceSamplers<TActions[K]>;
|
|
575
|
+
};
|
|
576
|
+
/** Trace sampling for one actor definition. */
|
|
577
|
+
interface ActorTracingOptions<TActions> {
|
|
578
|
+
/**
|
|
579
|
+
* Share of this actor's invocations that are recorded, from 0 to 1. A rate
|
|
580
|
+
* lowers what is recorded and never raises it, so an invocation inside a
|
|
581
|
+
* trace the caller did not record is not recorded at any rate.
|
|
582
|
+
*/
|
|
583
|
+
readonly sampler?: number;
|
|
584
|
+
/** Rates that replace `sampler` for single actions. */
|
|
585
|
+
readonly actions?: ActionTraceSamplers<TActions>;
|
|
586
|
+
}
|
|
587
|
+
|
|
546
588
|
type UpgradeWebSocket = (createEvents: (c: Context) => any) => Handler;
|
|
547
589
|
type GetUpgradeWebSocket = () => UpgradeWebSocket;
|
|
548
590
|
|
|
@@ -553,6 +595,7 @@ interface GatewayRequestOptions {
|
|
|
553
595
|
skipReadyWait?: boolean;
|
|
554
596
|
}
|
|
555
597
|
interface EngineControlClient {
|
|
598
|
+
issueToken(options: IssueTokenOptions): Promise<IssuedToken>;
|
|
556
599
|
getForId(input: GetForIdInput): Promise<ActorOutput | undefined>;
|
|
557
600
|
getWithKey(input: GetWithKeyInput): Promise<ActorOutput | undefined>;
|
|
558
601
|
getOrCreateWithKey(input: GetOrCreateWithKeyInput): Promise<ActorOutput>;
|
|
@@ -560,6 +603,8 @@ interface EngineControlClient {
|
|
|
560
603
|
listActors(input: ListActorsInput): Promise<ActorOutput[]>;
|
|
561
604
|
sendRequest(target: GatewayTarget, actorRequest: Request, options?: GatewayRequestOptions): Promise<Response>;
|
|
562
605
|
openWebSocket(path: string, target: GatewayTarget, encoding: Encoding, params: unknown, options?: GatewayRequestOptions): Promise<UniversalWebSocket>;
|
|
606
|
+
/** Refresh a credential rejected during this WebSocket handshake, if supported. */
|
|
607
|
+
refreshAuthToken?(ws: UniversalWebSocket): Promise<boolean>;
|
|
563
608
|
proxyRequest(c: Context, actorRequest: Request, actorId: string): Promise<Response>;
|
|
564
609
|
proxyWebSocket(c: Context, path: string, actorId: string, encoding: Encoding, params: unknown): Promise<Response>;
|
|
565
610
|
buildGatewayUrl(target: GatewayTarget, options?: GatewayRequestOptions): Promise<string>;
|
|
@@ -842,12 +887,19 @@ interface RuntimeSqlBatchStatement {
|
|
|
842
887
|
interface RuntimeSqlRunResult {
|
|
843
888
|
changes: number;
|
|
844
889
|
}
|
|
890
|
+
/** Sample rates for the traces an actor starts, in the shape core takes. */
|
|
891
|
+
interface RuntimeActorTracingConfig {
|
|
892
|
+
sampler?: number;
|
|
893
|
+
/** Keyed by flattened, dot-separated action name. */
|
|
894
|
+
actions?: Record<string, number>;
|
|
895
|
+
}
|
|
845
896
|
interface RuntimeActorConfig {
|
|
846
897
|
name?: string;
|
|
847
898
|
icon?: string;
|
|
848
899
|
hasDatabase?: boolean;
|
|
849
900
|
remoteSqlite?: boolean;
|
|
850
901
|
sqliteProfiling?: SqliteProfilingOptions;
|
|
902
|
+
tracing?: RuntimeActorTracingConfig;
|
|
851
903
|
enableActorRuntimeSocket?: boolean;
|
|
852
904
|
hasState?: boolean;
|
|
853
905
|
canHibernateWebsocket?: boolean;
|
|
@@ -1542,6 +1594,8 @@ declare class ActorHandleRaw {
|
|
|
1542
1594
|
* Resolves the actor to get its unique actor ID.
|
|
1543
1595
|
*/
|
|
1544
1596
|
resolve(): Promise<string>;
|
|
1597
|
+
/** Issue a token scoped to this actor. Defaults to actor gateway read access. */
|
|
1598
|
+
issueToken(options?: ActorIssueTokenOptions): Promise<IssuedToken>;
|
|
1545
1599
|
/**
|
|
1546
1600
|
* Returns the raw URL for routing traffic to the actor.
|
|
1547
1601
|
*/
|
|
@@ -1567,7 +1621,7 @@ declare class ActorHandleRaw {
|
|
|
1567
1621
|
type ActorHandle<AD extends AnyActorDefinition> = Omit<ActorHandleRaw, "connect" | "send"> & {
|
|
1568
1622
|
connect(params?: unknown, options?: ActorConnectOptions): ActorConn<AD>;
|
|
1569
1623
|
resolve(): Promise<string>;
|
|
1570
|
-
} & ActorDefinitionQueueSend<AD> & ActorDefinitionActions<AD>;
|
|
1624
|
+
} & ActorDefinitionQueueSend<AD> & Omit<ActorDefinitionActions<AD>, keyof ActorHandleRaw>;
|
|
1571
1625
|
|
|
1572
1626
|
/** Extract the actor registry from the registry definition. */
|
|
1573
1627
|
type ExtractActorsFromRegistry<A extends Registry<any>> = A extends Registry<infer Actors> ? Actors : never;
|
|
@@ -1703,6 +1757,10 @@ interface ActorClientRuntimeOptions {
|
|
|
1703
1757
|
*/
|
|
1704
1758
|
declare class ClientRaw {
|
|
1705
1759
|
#private;
|
|
1760
|
+
/** Issue namespace-scoped tokens with an explicit grant list. */
|
|
1761
|
+
readonly auth: {
|
|
1762
|
+
issueToken(options: IssueTokenOptions): Promise<IssuedToken>;
|
|
1763
|
+
};
|
|
1706
1764
|
[ACTOR_CONNS_SYMBOL]: Set<ActorConnRaw>;
|
|
1707
1765
|
/**
|
|
1708
1766
|
* Creates an instance of Client.
|
|
@@ -1763,9 +1821,9 @@ declare class ClientRaw {
|
|
|
1763
1821
|
*
|
|
1764
1822
|
* @template A The actor registry type.
|
|
1765
1823
|
*/
|
|
1766
|
-
type Client<A extends Registry<any>> = ClientRaw & {
|
|
1824
|
+
type Client<A extends Registry<any>> = ClientRaw & Omit<{
|
|
1767
1825
|
[K in keyof ExtractActorsFromRegistry<A>]: ActorAccessor<ExtractActorsFromRegistry<A>[K]>;
|
|
1768
|
-
}
|
|
1826
|
+
}, keyof ClientRaw>;
|
|
1769
1827
|
|
|
1770
1828
|
/** @experimental State exposed by a durable workflow run handler to the Inspector. */
|
|
1771
1829
|
type WorkflowState = "pending" | "running" | "sleeping" | "failed" | "completed" | "cancelled" | "rolling_back";
|
|
@@ -2115,6 +2173,10 @@ declare const ActorConfigSchema: z$1.ZodObject<{
|
|
|
2115
2173
|
onWebSocket: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
2116
2174
|
actions: z$1.ZodDefault<z$1.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
|
|
2117
2175
|
actionInputSchemas: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
2176
|
+
tracing: z$1.ZodOptional<z$1.ZodObject<{
|
|
2177
|
+
sampler: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2178
|
+
actions: z$1.ZodOptional<z$1.ZodType<ActionSampleRates, unknown, z$1.core.$ZodTypeInternals<ActionSampleRates, unknown>>>;
|
|
2179
|
+
}, z$1.core.$strict>>;
|
|
2118
2180
|
connParamsSchema: z$1.ZodOptional<z$1.ZodAny>;
|
|
2119
2181
|
events: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
2120
2182
|
queues: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
@@ -2355,6 +2417,11 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
|
|
|
2355
2417
|
* May mirror nested action groups or use dot-separated low-level action names.
|
|
2356
2418
|
*/
|
|
2357
2419
|
actionInputSchemas?: ActionInputSchemas;
|
|
2420
|
+
/**
|
|
2421
|
+
* How much of this actor's work is recorded in traces. Defaults to the
|
|
2422
|
+
* process sampler from `OTEL_TRACES_SAMPLER`.
|
|
2423
|
+
*/
|
|
2424
|
+
tracing?: ActorTracingOptions<TActions>;
|
|
2358
2425
|
/**
|
|
2359
2426
|
* Optional schema for validating connection params in native runtimes.
|
|
2360
2427
|
*/
|
|
@@ -33,6 +33,26 @@ function flattenActionInputSchemas(actions, schemas) {
|
|
|
33
33
|
}
|
|
34
34
|
return flattened;
|
|
35
35
|
}
|
|
36
|
+
function flattenActionTraceSamplers(actions, rates = {}) {
|
|
37
|
+
const handlers = flattenActionHandlers(actions);
|
|
38
|
+
const flattened = Object.fromEntries(flattenSampleRates(rates, []));
|
|
39
|
+
for (const name of Object.keys(flattened)) {
|
|
40
|
+
if (!Object.hasOwn(handlers, name)) {
|
|
41
|
+
throw new TypeError(
|
|
42
|
+
`tracing.actions.${name} does not name an action`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return flattened;
|
|
47
|
+
}
|
|
48
|
+
function flattenSampleRates(rates, path) {
|
|
49
|
+
return Object.entries(rates).flatMap(
|
|
50
|
+
([segment, rate]) => {
|
|
51
|
+
const childPath = [...path, segment];
|
|
52
|
+
return typeof rate === "number" ? [[childPath.join("."), rate]] : flattenSampleRates(rate, childPath);
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
}
|
|
36
56
|
function collectActionEntries(actions) {
|
|
37
57
|
const entries = [];
|
|
38
58
|
const names = /* @__PURE__ */ new Set();
|
|
@@ -228,6 +248,10 @@ var InstanceActorOptionsSchema = InstanceActorOptionsBaseSchema.prefault(() => (
|
|
|
228
248
|
var ActorOptionsSchema = GlobalActorOptionsBaseSchema.extend(
|
|
229
249
|
InstanceActorOptionsBaseSchema.shape
|
|
230
250
|
).strict().prefault(() => ({}));
|
|
251
|
+
var zSampleRate = z.number().min(0).max(1);
|
|
252
|
+
var zActionSampleRates = z.lazy(
|
|
253
|
+
() => z.record(z.string(), z.union([zSampleRate, zActionSampleRates]))
|
|
254
|
+
);
|
|
231
255
|
var ActorConfigSchema = z.object({
|
|
232
256
|
onCreate: zFunction().optional(),
|
|
233
257
|
onDestroy: zFunction().optional(),
|
|
@@ -244,6 +268,10 @@ var ActorConfigSchema = z.object({
|
|
|
244
268
|
onWebSocket: zFunction().optional(),
|
|
245
269
|
actions: zActionTree.default(() => ({})),
|
|
246
270
|
actionInputSchemas: z.record(z.string(), z.any()).optional(),
|
|
271
|
+
tracing: z.object({
|
|
272
|
+
sampler: zSampleRate.optional(),
|
|
273
|
+
actions: zActionSampleRates.optional()
|
|
274
|
+
}).strict().optional(),
|
|
247
275
|
connParamsSchema: z.any().optional(),
|
|
248
276
|
events: z.record(z.string(), z.any()).optional(),
|
|
249
277
|
queues: z.record(z.string(), z.any()).optional(),
|
|
@@ -391,6 +419,9 @@ var DocActorConfigSchema = z.object({
|
|
|
391
419
|
actionInputSchemas: z.record(z.string(), z.unknown()).optional().describe(
|
|
392
420
|
"Optional schemas for validating action argument tuples in native runtimes. May mirror nested action groups or use dot-separated low-level action names."
|
|
393
421
|
),
|
|
422
|
+
tracing: z.unknown().optional().describe(
|
|
423
|
+
"Trace sampling for this actor: `sampler` is the share of its invocations that are recorded, from 0 to 1, with optional per-action rates under `actions`. A rate lowers what is recorded and never raises it. Defaults to the process sampler from OTEL_TRACES_SAMPLER."
|
|
424
|
+
),
|
|
394
425
|
connParamsSchema: z.unknown().optional().describe(
|
|
395
426
|
"Optional schema for validating connection params in native runtimes."
|
|
396
427
|
),
|
|
@@ -420,7 +451,7 @@ function isRivetErrorCode(error, group, code) {
|
|
|
420
451
|
// package.json
|
|
421
452
|
var package_default = {
|
|
422
453
|
name: "rivetkit",
|
|
423
|
-
version: "2.3.
|
|
454
|
+
version: "2.3.21",
|
|
424
455
|
description: "Lightweight libraries for building stateful actors on edge platforms",
|
|
425
456
|
license: "Apache-2.0",
|
|
426
457
|
keywords: [
|
|
@@ -633,6 +664,7 @@ var package_default = {
|
|
|
633
664
|
"@rivet-dev/agent-os-core": "^0.1.1",
|
|
634
665
|
"@rivet-dev/services": "^0.1.5",
|
|
635
666
|
"@rivetkit/bare-ts": "^0.6.2",
|
|
667
|
+
"@rivetkit/engine-api-full": "workspace:*",
|
|
636
668
|
"@rivetkit/engine-cli": "workspace:*",
|
|
637
669
|
"@rivetkit/engine-envoy-protocol": "workspace:*",
|
|
638
670
|
"@rivetkit/on-change": "6.0.1",
|
|
@@ -889,12 +921,14 @@ var ActorDefinition = class {
|
|
|
889
921
|
}
|
|
890
922
|
};
|
|
891
923
|
function actor(input) {
|
|
924
|
+
var _a;
|
|
892
925
|
warnDeprecatedOptionKeys(
|
|
893
926
|
input == null ? void 0 : input.options
|
|
894
927
|
);
|
|
895
928
|
const config = ActorConfigSchema.parse(input);
|
|
896
929
|
flattenActionHandlers(config.actions);
|
|
897
930
|
flattenActionInputSchemas(config.actions, config.actionInputSchemas);
|
|
931
|
+
flattenActionTraceSamplers(config.actions, (_a = config.tracing) == null ? void 0 : _a.actions);
|
|
898
932
|
return new ActorDefinition(config);
|
|
899
933
|
}
|
|
900
934
|
|