rivetkit 0.0.0-sqlite-profiling-compat.4a9a623 → 0.0.0-sqlite-sync-3-0-0-release.14341d0
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 +1317 -765
- package/dist/browser/client.js +1433 -692
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.d.ts +252 -129
- package/dist/browser/inspector/client.js +2042 -228
- 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 -2367
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +1 -2277
- package/dist/tsup/agent-os/index.d.ts +1 -2277
- package/dist/tsup/agent-os/index.js +3 -2367
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-AGDY6TKH.js → chunk-2EQ2WCO7.js} +1054 -364
- package/dist/tsup/chunk-2EQ2WCO7.js.map +1 -0
- package/dist/tsup/{chunk-7QKCGUTJ.cjs → chunk-4H2LT2WB.cjs} +444 -29
- package/dist/tsup/chunk-4H2LT2WB.cjs.map +1 -0
- package/dist/tsup/{chunk-XIX5DOZN.js → chunk-6FEYCVZC.js} +196 -20
- package/dist/tsup/chunk-6FEYCVZC.js.map +1 -0
- package/dist/tsup/{chunk-QAVN4QNO.cjs → chunk-6WYQ3NJI.cjs} +7 -7
- package/dist/tsup/chunk-6WYQ3NJI.cjs.map +1 -0
- package/dist/tsup/{chunk-75UE45DE.js → chunk-6ZJX3KXW.js} +436 -21
- package/dist/tsup/chunk-6ZJX3KXW.js.map +1 -0
- package/dist/tsup/{chunk-HXUEHHJF.js → chunk-A2CF6PFH.js} +19 -11
- package/dist/tsup/chunk-A2CF6PFH.js.map +1 -0
- package/dist/tsup/{chunk-RIT7N3TX.js → chunk-AIGW2SKA.js} +50 -3
- package/dist/tsup/chunk-AIGW2SKA.js.map +1 -0
- package/dist/tsup/{chunk-3MHDOUD7.cjs → chunk-HDVZ6YZG.cjs} +197 -21
- package/dist/tsup/chunk-HDVZ6YZG.cjs.map +1 -0
- package/dist/tsup/{chunk-2CICCOBL.cjs → chunk-HU4F7H3F.cjs} +52 -5
- package/dist/tsup/chunk-HU4F7H3F.cjs.map +1 -0
- package/dist/tsup/{chunk-4PX3ZKJR.js → chunk-JNJEWQZL.js} +3 -3
- package/dist/tsup/chunk-JNJEWQZL.js.map +1 -0
- package/dist/tsup/{chunk-JZ7TWV65.js → chunk-JTHHCZCZ.js} +24 -1
- package/dist/tsup/chunk-JTHHCZCZ.js.map +1 -0
- package/dist/tsup/{chunk-ZA7FLHKH.cjs → chunk-KVFIONKQ.cjs} +25 -2
- package/dist/tsup/chunk-KVFIONKQ.cjs.map +1 -0
- package/dist/tsup/{chunk-4FC7TVS6.cjs → chunk-MGI2VVF6.cjs} +39 -7
- package/dist/tsup/chunk-MGI2VVF6.cjs.map +1 -0
- package/dist/tsup/{chunk-NHUTYWKU.cjs → chunk-NE5CUQRN.cjs} +1173 -483
- package/dist/tsup/chunk-NE5CUQRN.cjs.map +1 -0
- package/dist/tsup/{chunk-IICIOTML.js → chunk-OX5MX7TO.js} +2 -2
- package/dist/tsup/{chunk-ND567FR5.cjs → chunk-PSIBTOAR.cjs} +3 -3
- package/dist/tsup/chunk-PSIBTOAR.cjs.map +1 -0
- package/dist/tsup/chunk-PW6FYEIV.cjs +14 -0
- package/dist/tsup/chunk-PW6FYEIV.cjs.map +1 -0
- package/dist/tsup/{chunk-VE2X4KMG.cjs → chunk-RTWH3AX3.cjs} +18 -10
- package/dist/tsup/chunk-RTWH3AX3.cjs.map +1 -0
- package/dist/tsup/chunk-SLICBKAU.js +14 -0
- package/dist/tsup/chunk-SLICBKAU.js.map +1 -0
- package/dist/tsup/{chunk-XFYEVYHG.js → chunk-WCVYMFWJ.js} +16 -9
- package/dist/tsup/chunk-WCVYMFWJ.js.map +1 -0
- package/dist/tsup/chunk-WX3JS4XU.cjs +243 -0
- package/dist/tsup/chunk-WX3JS4XU.cjs.map +1 -0
- package/dist/tsup/chunk-X32L7FDD.js +243 -0
- package/dist/tsup/chunk-X32L7FDD.js.map +1 -0
- package/dist/tsup/{chunk-2WMYYG4R.cjs → chunk-XAY2HIZN.cjs} +18 -11
- package/dist/tsup/chunk-XAY2HIZN.cjs.map +1 -0
- package/dist/tsup/{chunk-ZZ3WBRPD.js → chunk-ZOVJDAOW.js} +38 -6
- package/dist/tsup/chunk-ZOVJDAOW.js.map +1 -0
- package/dist/tsup/client/mod.cjs +8 -9
- package/dist/tsup/client/mod.cjs.map +1 -1
- package/dist/tsup/client/mod.d.cts +32 -6
- package/dist/tsup/client/mod.d.ts +32 -6
- package/dist/tsup/client/mod.js +7 -8
- package/dist/tsup/common/log.cjs +5 -3
- package/dist/tsup/common/log.cjs.map +1 -1
- package/dist/tsup/common/log.d.cts +5 -1
- package/dist/tsup/common/log.d.ts +5 -1
- package/dist/tsup/common/log.js +6 -4
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.cjs.map +1 -1
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-BR1Nn0QQ.d.ts → config-B4erdavw.d.ts} +571 -65
- package/dist/tsup/{config-B0LNDrLY.d.ts → config-BfG1qpYz.d.cts} +80 -14
- package/dist/tsup/{config-B0LNDrLY.d.cts → config-BfG1qpYz.d.ts} +80 -14
- package/dist/tsup/{config-tCvkwzyN.d.cts → config-DK144OAw.d.cts} +571 -65
- package/dist/tsup/{context-oc9zhA3x.d.ts → context-Cvnf3BRe.d.cts} +3 -2
- package/dist/tsup/{context-D4WDwf9m.d.cts → context-Oxi6YWcG.d.ts} +3 -2
- package/dist/tsup/db/drizzle.cjs +127 -67
- package/dist/tsup/db/drizzle.cjs.map +1 -1
- package/dist/tsup/db/drizzle.d.cts +8 -4
- package/dist/tsup/db/drizzle.d.ts +8 -4
- package/dist/tsup/db/drizzle.js +127 -67
- package/dist/tsup/db/drizzle.js.map +1 -1
- package/dist/tsup/db/mod.cjs +6 -126
- package/dist/tsup/db/mod.cjs.map +1 -1
- package/dist/tsup/db/mod.d.cts +8 -4
- package/dist/tsup/db/mod.d.ts +8 -4
- package/dist/tsup/db/mod.js +5 -125
- package/dist/tsup/db/mod.js.map +1 -1
- package/dist/tsup/dynamic/mod.cjs +2 -2
- package/dist/tsup/dynamic/mod.cjs.map +1 -1
- package/dist/tsup/dynamic/mod.d.cts +6 -4
- package/dist/tsup/dynamic/mod.d.ts +6 -4
- package/dist/tsup/dynamic/mod.js +1 -1
- package/dist/tsup/inspector/mod.cjs +47 -12
- package/dist/tsup/inspector/mod.cjs.map +1 -1
- package/dist/tsup/inspector/mod.d.cts +26 -136
- package/dist/tsup/inspector/mod.d.ts +26 -136
- package/dist/tsup/inspector/mod.js +46 -11
- package/dist/tsup/inspector/mod.js.map +1 -1
- package/dist/tsup/inspector/workflow.cjs +21 -0
- package/dist/tsup/inspector/workflow.cjs.map +1 -0
- package/dist/tsup/inspector/workflow.d.cts +144 -0
- package/dist/tsup/inspector/workflow.d.ts +144 -0
- package/dist/tsup/inspector/workflow.js +21 -0
- package/dist/tsup/inspector/workflow.js.map +1 -0
- package/dist/tsup/inspector-tab/mod.cjs +2 -13
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -1
- package/dist/tsup/inspector-tab/mod.d.cts +9 -17
- package/dist/tsup/inspector-tab/mod.d.ts +9 -17
- package/dist/tsup/inspector-tab/mod.js +1 -12
- package/dist/tsup/inspector-tab/mod.js.map +1 -1
- package/dist/tsup/mod.cjs +2728 -611
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +9 -7
- package/dist/tsup/mod.d.ts +9 -7
- package/dist/tsup/mod.js +2645 -528
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +19 -17
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +6 -4
- package/dist/tsup/test/mod.d.ts +6 -4
- package/dist/tsup/test/mod.js +18 -16
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/unstable/migrations.cjs +101 -0
- package/dist/tsup/unstable/migrations.cjs.map +1 -0
- package/dist/tsup/unstable/migrations.d.cts +29 -0
- package/dist/tsup/unstable/migrations.d.ts +29 -0
- package/dist/tsup/unstable/migrations.js +101 -0
- package/dist/tsup/unstable/migrations.js.map +1 -0
- package/dist/tsup/{utils-CqDnC_PS.d.cts → utils-3rsE0JvI.d.cts} +25 -2
- package/dist/tsup/{utils-CqDnC_PS.d.ts → utils-3rsE0JvI.d.ts} +25 -2
- package/dist/tsup/utils-C1O-SklO.d.ts +162 -0
- package/dist/tsup/utils-C6b0aYUM.d.cts +162 -0
- package/dist/tsup/utils.cjs +7 -3
- package/dist/tsup/utils.cjs.map +1 -1
- package/dist/tsup/utils.d.cts +4 -147
- package/dist/tsup/utils.d.ts +4 -147
- package/dist/tsup/utils.js +6 -2
- package/dist/tsup/workflow/mod.cjs +260 -200
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +8 -6
- package/dist/tsup/workflow/mod.d.ts +8 -6
- package/dist/tsup/workflow/mod.js +249 -189
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +34 -14
- package/src/actor/actions.ts +155 -0
- package/src/actor/config.ts +403 -43
- package/src/actor/definition.ts +26 -7
- package/src/actor/errors.ts +87 -5
- package/src/actor/keys.ts +86 -0
- package/src/actor/mod.ts +15 -1
- package/src/actor/tracing.ts +28 -0
- package/src/agent-os/index.ts +5 -65
- package/src/client/actor-common.ts +8 -15
- package/src/client/actor-conn.ts +178 -25
- package/src/client/actor-handle.ts +180 -42
- package/src/client/actor-query.ts +8 -1
- package/src/client/auth.ts +37 -0
- package/src/client/client.ts +89 -21
- package/src/client/config.ts +27 -2
- package/src/client/errors.ts +2 -1
- package/src/client/lifecycle-errors.ts +29 -1
- package/src/client/mod.ts +9 -0
- package/src/client/outbound-telemetry.ts +66 -0
- package/src/client/query.ts +2 -0
- package/src/client/queue.ts +3 -0
- package/src/client/raw-utils.ts +37 -8
- package/src/client/resolve-gateway-target.ts +2 -0
- package/src/client/retry-budget.ts +78 -0
- package/src/client/token-provider.ts +93 -0
- package/src/client/utils.ts +16 -2
- package/src/common/actor-router-consts.ts +5 -0
- package/src/common/actor-telemetry-context.ts +19 -0
- package/src/common/bare/generated/actor-runtime-socket-protocol/v1.ts +848 -0
- package/src/common/bare/generated/inspector/v5.ts +1016 -0
- package/src/common/bare/generated/inspector/v6.ts +1367 -0
- package/src/common/bare/transport/v1.ts +36 -0
- package/src/common/database/config.ts +108 -15
- package/src/common/database/mod.ts +247 -76
- package/src/common/database/native-database.ts +433 -23
- package/src/common/database/shared.ts +24 -0
- package/src/common/encoding.ts +31 -21
- package/src/common/fetch-like.ts +63 -0
- package/src/common/inspector-transport.ts +12 -2
- package/src/common/log.ts +14 -8
- package/src/common/otel-context.ts +99 -0
- package/src/common/router.ts +1 -1
- package/src/common/utils.ts +7 -19
- package/src/db/drizzle.ts +182 -80
- package/src/db/mod.ts +2 -0
- package/src/dynamic/isolate-runtime.ts +0 -2
- package/src/engine-api/actors.ts +3 -3
- package/src/engine-client/actor-http-client.ts +29 -20
- package/src/engine-client/actor-websocket-client.ts +6 -3
- package/src/engine-client/api-endpoints.ts +72 -14
- package/src/engine-client/driver.ts +8 -15
- package/src/engine-client/mod.ts +248 -112
- package/src/inspector/client.browser.ts +134 -16
- package/src/inspector/mod.ts +1 -1
- package/src/inspector/workflow.ts +61 -0
- package/src/inspector-tab/mod.ts +1 -15
- package/src/registry/config/envoy.ts +2 -18
- package/src/registry/config/index.ts +54 -61
- package/src/registry/index.ts +324 -21
- package/src/registry/napi-runtime.ts +583 -39
- package/src/registry/native-http.ts +225 -0
- package/src/registry/native.ts +1365 -414
- package/src/registry/run-handler-coordinator.ts +219 -0
- package/src/registry/runtime.ts +372 -7
- package/src/registry/wasm-runtime.ts +490 -21
- package/src/registry/write-through-proxy.ts +101 -0
- package/src/test/mod.ts +1 -19
- package/src/test/ready.ts +22 -0
- package/src/unstable/migrations.ts +141 -0
- package/src/utils/env-vars.ts +15 -6
- package/src/utils/node.ts +44 -28
- package/src/utils.ts +3 -0
- package/src/workflow/context.ts +9 -27
- package/src/workflow/driver.ts +253 -116
- package/src/workflow/inspector.ts +23 -24
- package/src/workflow/mod.ts +50 -72
- package/dist/tsup/chunk-2CICCOBL.cjs.map +0 -1
- package/dist/tsup/chunk-2WMYYG4R.cjs.map +0 -1
- package/dist/tsup/chunk-3MHDOUD7.cjs.map +0 -1
- package/dist/tsup/chunk-4FC7TVS6.cjs.map +0 -1
- package/dist/tsup/chunk-4PX3ZKJR.js.map +0 -1
- package/dist/tsup/chunk-75UE45DE.js.map +0 -1
- package/dist/tsup/chunk-7QKCGUTJ.cjs.map +0 -1
- package/dist/tsup/chunk-AGDY6TKH.js.map +0 -1
- package/dist/tsup/chunk-HXUEHHJF.js.map +0 -1
- package/dist/tsup/chunk-JZ7TWV65.js.map +0 -1
- package/dist/tsup/chunk-ND567FR5.cjs.map +0 -1
- package/dist/tsup/chunk-NHUTYWKU.cjs.map +0 -1
- package/dist/tsup/chunk-QAVN4QNO.cjs.map +0 -1
- package/dist/tsup/chunk-RIT7N3TX.js.map +0 -1
- package/dist/tsup/chunk-RV5MAFDT.cjs +0 -382
- package/dist/tsup/chunk-RV5MAFDT.cjs.map +0 -1
- package/dist/tsup/chunk-VE2X4KMG.cjs.map +0 -1
- package/dist/tsup/chunk-XFYEVYHG.js.map +0 -1
- package/dist/tsup/chunk-XHGDS3DZ.js +0 -382
- package/dist/tsup/chunk-XHGDS3DZ.js.map +0 -1
- package/dist/tsup/chunk-XIX5DOZN.js.map +0 -1
- package/dist/tsup/chunk-ZA7FLHKH.cjs.map +0 -1
- package/dist/tsup/chunk-ZZ3WBRPD.js.map +0 -1
- package/src/actor/driver.ts +0 -141
- package/src/actor/instance/mod.ts +0 -2484
- package/src/actor/keys.test.ts +0 -275
- package/src/actor/utils.test.ts +0 -48
- package/src/agent-os/actor/cron.ts +0 -84
- package/src/agent-os/actor/db.ts +0 -54
- package/src/agent-os/actor/filesystem.ts +0 -131
- package/src/agent-os/actor/index.ts +0 -285
- package/src/agent-os/actor/network.ts +0 -58
- package/src/agent-os/actor/preview.ts +0 -190
- package/src/agent-os/actor/process.ts +0 -177
- package/src/agent-os/actor/session.ts +0 -518
- package/src/agent-os/actor/shell.ts +0 -60
- package/src/agent-os/config.ts +0 -79
- package/src/agent-os/fs/database-vfs.ts +0 -624
- package/src/agent-os/types.ts +0 -148
- package/src/client/test.ts +0 -44
- package/src/common/database/mod.test.ts +0 -137
- package/src/common/database/native-database.test.ts +0 -211
- package/src/common/inline-websocket-adapter.test.ts +0 -51
- package/src/drivers/engine/actor-driver.ts +0 -2473
- package/src/registry/process-metrics.ts +0 -250
- package/src/registry/runtime.test.ts +0 -50
- package/src/utils/endpoint-parser.test.ts +0 -206
- package/src/utils.test.ts +0 -34
- /package/dist/tsup/{chunk-IICIOTML.js.map → chunk-OX5MX7TO.js.map} +0 -0
package/src/actor/definition.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { AnyDatabaseProvider } from "@/common/database/config";
|
|
2
2
|
import type { RegistryConfig } from "@/registry/config";
|
|
3
|
+
import {
|
|
4
|
+
flattenActionHandlers,
|
|
5
|
+
flattenActionInputSchemas,
|
|
6
|
+
flattenActionTraceSamplers,
|
|
7
|
+
} from "./actions";
|
|
3
8
|
import {
|
|
4
9
|
type Actions,
|
|
5
10
|
type ActorConfig,
|
|
@@ -9,16 +14,27 @@ import {
|
|
|
9
14
|
import { loggerWithoutContext } from "./log";
|
|
10
15
|
import type { EventSchemaConfig, QueueSchemaConfig } from "./schema";
|
|
11
16
|
|
|
12
|
-
const
|
|
17
|
+
const warnedDeprecatedOptionKeys = new Set<string>();
|
|
18
|
+
|
|
19
|
+
const DEPRECATED_OPTION_MESSAGES: Record<string, string> = {
|
|
20
|
+
onDestroyTimeout:
|
|
21
|
+
"Configure `sleepGracePeriod` instead, which bounds the entire graceful shutdown window for both sleep and destroy.",
|
|
22
|
+
waitUntilTimeout:
|
|
23
|
+
"Configure `sleepGracePeriod` instead, which bounds the entire graceful shutdown window for both sleep and destroy.",
|
|
24
|
+
preloadMaxWorkflowBytes:
|
|
25
|
+
"Internal storage moved to SQLite and no longer uses KV preloading.",
|
|
26
|
+
preloadMaxConnectionsBytes:
|
|
27
|
+
"Internal storage moved to SQLite and no longer uses KV preloading.",
|
|
28
|
+
};
|
|
13
29
|
|
|
14
|
-
function
|
|
30
|
+
function warnDeprecatedOptionKeys(options: unknown) {
|
|
15
31
|
if (!options || typeof options !== "object") return;
|
|
16
32
|
const opts = options as Record<string, unknown>;
|
|
17
|
-
for (const key of
|
|
18
|
-
if (opts[key] !== undefined && !
|
|
19
|
-
|
|
33
|
+
for (const [key, detail] of Object.entries(DEPRECATED_OPTION_MESSAGES)) {
|
|
34
|
+
if (opts[key] !== undefined && !warnedDeprecatedOptionKeys.has(key)) {
|
|
35
|
+
warnedDeprecatedOptionKeys.add(key);
|
|
20
36
|
loggerWithoutContext().warn({
|
|
21
|
-
msg: `actor option \`${key}\` is deprecated and is now ignored.
|
|
37
|
+
msg: `actor option \`${key}\` is deprecated and is now ignored. ${detail} Will be removed in 2.2.0.`,
|
|
22
38
|
});
|
|
23
39
|
}
|
|
24
40
|
}
|
|
@@ -181,7 +197,7 @@ export function actor<
|
|
|
181
197
|
TQueues,
|
|
182
198
|
TActions
|
|
183
199
|
> {
|
|
184
|
-
|
|
200
|
+
warnDeprecatedOptionKeys(
|
|
185
201
|
(input as { options?: unknown } | undefined)?.options,
|
|
186
202
|
);
|
|
187
203
|
const config = ActorConfigSchema.parse(input) as ActorConfig<
|
|
@@ -195,6 +211,9 @@ export function actor<
|
|
|
195
211
|
TQueues,
|
|
196
212
|
TActions
|
|
197
213
|
>;
|
|
214
|
+
flattenActionHandlers(config.actions);
|
|
215
|
+
flattenActionInputSchemas(config.actions, config.actionInputSchemas);
|
|
216
|
+
flattenActionTraceSamplers(config.actions, config.tracing?.actions);
|
|
198
217
|
return new ActorDefinition(config);
|
|
199
218
|
}
|
|
200
219
|
|
package/src/actor/errors.ts
CHANGED
|
@@ -12,6 +12,8 @@ export interface RivetErrorOptions extends ErrorOptions {
|
|
|
12
12
|
public?: boolean;
|
|
13
13
|
/** Metadata associated with this error. */
|
|
14
14
|
metadata?: unknown;
|
|
15
|
+
/** Request identifier used to correlate this error with engine logs. */
|
|
16
|
+
rayId?: string;
|
|
15
17
|
/** Explicit HTTP status override for router responses. */
|
|
16
18
|
statusCode?: number;
|
|
17
19
|
/** Actor context associated with this error. */
|
|
@@ -31,6 +33,7 @@ export interface RivetErrorLike {
|
|
|
31
33
|
code: string;
|
|
32
34
|
message: string;
|
|
33
35
|
metadata?: unknown;
|
|
36
|
+
rayId?: string;
|
|
34
37
|
public?: boolean;
|
|
35
38
|
statusCode?: number;
|
|
36
39
|
actor?: ActorSpecifier;
|
|
@@ -38,6 +41,15 @@ export interface RivetErrorLike {
|
|
|
38
41
|
|
|
39
42
|
export interface BridgeRivetErrorPayload extends RivetErrorLike {}
|
|
40
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Shape as it arrives from the native bridge, where an absent ray ID serializes
|
|
46
|
+
* to null. Normalized to a BridgeRivetErrorPayload before validation.
|
|
47
|
+
*/
|
|
48
|
+
interface NativeBridgeErrorPayload
|
|
49
|
+
extends Omit<BridgeRivetErrorPayload, "rayId"> {
|
|
50
|
+
rayId?: string | null;
|
|
51
|
+
}
|
|
52
|
+
|
|
41
53
|
export interface UserErrorOptions extends ErrorOptions {
|
|
42
54
|
/**
|
|
43
55
|
* Machine readable code for this error. Useful for catching different types of
|
|
@@ -59,6 +71,7 @@ function looksLikeRivetErrorOptions(
|
|
|
59
71
|
value !== null &&
|
|
60
72
|
("public" in value ||
|
|
61
73
|
"metadata" in value ||
|
|
74
|
+
"rayId" in value ||
|
|
62
75
|
"statusCode" in value ||
|
|
63
76
|
"actor" in value ||
|
|
64
77
|
"cause" in value)
|
|
@@ -94,6 +107,9 @@ export function isRivetErrorLike(
|
|
|
94
107
|
typeof error.code === "string" &&
|
|
95
108
|
"message" in error &&
|
|
96
109
|
typeof error.message === "string" &&
|
|
110
|
+
(!("rayId" in error) ||
|
|
111
|
+
error.rayId === undefined ||
|
|
112
|
+
typeof error.rayId === "string") &&
|
|
97
113
|
(!("__type" in error) || isTypedErrorTag(error.__type))
|
|
98
114
|
);
|
|
99
115
|
}
|
|
@@ -128,6 +144,7 @@ export class RivetError extends Error {
|
|
|
128
144
|
|
|
129
145
|
public public: boolean;
|
|
130
146
|
public metadata?: unknown;
|
|
147
|
+
public readonly rayId?: string;
|
|
131
148
|
public statusCode: number;
|
|
132
149
|
public actor?: ActorSpecifier;
|
|
133
150
|
public readonly group: string;
|
|
@@ -161,6 +178,7 @@ export class RivetError extends Error {
|
|
|
161
178
|
this.code = code;
|
|
162
179
|
this.public = normalized.public ?? false;
|
|
163
180
|
this.metadata = normalized.metadata;
|
|
181
|
+
this.rayId = normalized.rayId ?? undefined;
|
|
164
182
|
this.statusCode = normalized.statusCode ?? (this.public ? 400 : 500);
|
|
165
183
|
this.actor = normalized.actor;
|
|
166
184
|
}
|
|
@@ -205,6 +223,7 @@ export function toRivetError(
|
|
|
205
223
|
public: error.public,
|
|
206
224
|
statusCode: error.statusCode,
|
|
207
225
|
metadata: error.metadata,
|
|
226
|
+
rayId: error.rayId,
|
|
208
227
|
actor: error.actor,
|
|
209
228
|
cause: error instanceof Error ? error.cause : undefined,
|
|
210
229
|
});
|
|
@@ -218,22 +237,78 @@ export function toRivetError(
|
|
|
218
237
|
public: fallback?.public,
|
|
219
238
|
statusCode: fallback?.statusCode,
|
|
220
239
|
metadata: fallback?.metadata,
|
|
240
|
+
rayId: fallback?.rayId,
|
|
221
241
|
actor: fallback?.actor,
|
|
222
242
|
cause: error instanceof Error ? error : undefined,
|
|
223
243
|
},
|
|
224
244
|
);
|
|
225
245
|
}
|
|
226
246
|
|
|
227
|
-
|
|
228
|
-
|
|
247
|
+
/** A structured error encoded for the bridge to Core. */
|
|
248
|
+
export interface EncodedBridgeError {
|
|
249
|
+
readonly encoded: string;
|
|
250
|
+
/** Set when JSON could not encode the metadata, which was dropped. */
|
|
251
|
+
readonly droppedMetadataCause?: unknown;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Encodes a structured error for the bridge to Core. Metadata that JSON cannot
|
|
256
|
+
* encode, such as a `bigint`, is dropped so the error itself still crosses.
|
|
257
|
+
*/
|
|
258
|
+
export function encodeBridgeRivetError(
|
|
259
|
+
error: RivetErrorLike,
|
|
260
|
+
): EncodedBridgeError {
|
|
261
|
+
const payload = {
|
|
229
262
|
group: error.group,
|
|
230
263
|
code: error.code,
|
|
231
264
|
message: error.message,
|
|
232
265
|
metadata: error.metadata,
|
|
266
|
+
rayId: error.rayId,
|
|
233
267
|
public: error.public,
|
|
234
268
|
statusCode: error.statusCode,
|
|
235
269
|
actor: error.actor,
|
|
236
|
-
}
|
|
270
|
+
};
|
|
271
|
+
try {
|
|
272
|
+
return {
|
|
273
|
+
encoded: `${BRIDGE_RIVET_ERROR_PREFIX}${JSON.stringify(payload)}`,
|
|
274
|
+
};
|
|
275
|
+
} catch (cause) {
|
|
276
|
+
return {
|
|
277
|
+
encoded: `${BRIDGE_RIVET_ERROR_PREFIX}${JSON.stringify({ ...payload, metadata: undefined })}`,
|
|
278
|
+
droppedMetadataCause: cause,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Encodes an error for the telemetry bridge. A structured error crosses with
|
|
285
|
+
* its group and code. Anything else crosses as text so Core classifies it,
|
|
286
|
+
* which is the same rule that keeps raw messages out of every span.
|
|
287
|
+
*/
|
|
288
|
+
export function encodeErrorForBridge(error: unknown): string {
|
|
289
|
+
if (isCanonicalStructuredRivetError(error)) {
|
|
290
|
+
return encodeBridgeRivetError(error).encoded;
|
|
291
|
+
}
|
|
292
|
+
return String(error);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/** A `RivetError` instance, or a plain object carrying its full tagged shape. */
|
|
296
|
+
export function isCanonicalStructuredRivetError(
|
|
297
|
+
error: unknown,
|
|
298
|
+
): error is RivetErrorLike {
|
|
299
|
+
return (
|
|
300
|
+
error instanceof RivetError ||
|
|
301
|
+
(typeof error === "object" &&
|
|
302
|
+
error !== null &&
|
|
303
|
+
"__type" in error &&
|
|
304
|
+
error.__type === "RivetError" &&
|
|
305
|
+
"group" in error &&
|
|
306
|
+
typeof error.group === "string" &&
|
|
307
|
+
"code" in error &&
|
|
308
|
+
typeof error.code === "string" &&
|
|
309
|
+
"message" in error &&
|
|
310
|
+
typeof error.message === "string")
|
|
311
|
+
);
|
|
237
312
|
}
|
|
238
313
|
|
|
239
314
|
export function decodeBridgeRivetErrorPayload(
|
|
@@ -244,9 +319,14 @@ export function decodeBridgeRivetErrorPayload(
|
|
|
244
319
|
}
|
|
245
320
|
|
|
246
321
|
try {
|
|
247
|
-
const
|
|
322
|
+
const raw = JSON.parse(
|
|
248
323
|
value.slice(BRIDGE_RIVET_ERROR_PREFIX.length),
|
|
249
|
-
) as
|
|
324
|
+
) as NativeBridgeErrorPayload;
|
|
325
|
+
// Coerce the native bridge's null ray ID to undefined before validation.
|
|
326
|
+
const payload: BridgeRivetErrorPayload = {
|
|
327
|
+
...raw,
|
|
328
|
+
rayId: raw.rayId ?? undefined,
|
|
329
|
+
};
|
|
250
330
|
if (!isRivetErrorLike(payload)) {
|
|
251
331
|
return undefined;
|
|
252
332
|
}
|
|
@@ -272,6 +352,7 @@ export function decodeBridgeRivetError(value: string): RivetError | undefined {
|
|
|
272
352
|
|
|
273
353
|
return new RivetError(payload.group, payload.code, payload.message, {
|
|
274
354
|
metadata: payload.metadata,
|
|
355
|
+
rayId: payload.rayId,
|
|
275
356
|
public: payload.public,
|
|
276
357
|
statusCode: payload.statusCode,
|
|
277
358
|
actor: payload.actor ?? undefined,
|
|
@@ -303,6 +384,7 @@ export function internalError(
|
|
|
303
384
|
public: options?.public,
|
|
304
385
|
statusCode: options?.statusCode,
|
|
305
386
|
metadata: options?.metadata,
|
|
387
|
+
rayId: options?.rayId,
|
|
306
388
|
actor: options?.actor,
|
|
307
389
|
cause: options?.cause,
|
|
308
390
|
},
|
package/src/actor/keys.ts
CHANGED
|
@@ -60,6 +60,8 @@ const TRACES_STORAGE_PREFIX = concatPrefix(
|
|
|
60
60
|
STORAGE_VERSION_BYTES.TRACES,
|
|
61
61
|
);
|
|
62
62
|
|
|
63
|
+
// The slash key form the actor REST API and the actor runtime use. The engine translates it to
|
|
64
|
+
// the canonical form (`encodeActorKey`) at those boundaries.
|
|
63
65
|
export function serializeActorKey(key: ActorKey): string {
|
|
64
66
|
// Use a special marker for empty key arrays
|
|
65
67
|
if (key.length === 0) {
|
|
@@ -145,6 +147,90 @@ export function deserializeActorKey(keyString: string | undefined): ActorKey {
|
|
|
145
147
|
return parts;
|
|
146
148
|
}
|
|
147
149
|
|
|
150
|
+
// The canonical actor key: parts joined with `,`, with `\` and `,` escaped by a backslash, an
|
|
151
|
+
// empty part written as `\0`, and the empty key as the empty string. The engine hashes, stores
|
|
152
|
+
// and compares only canonical keys, and the gateway's `rvt-key` carries one. The Rust twin is
|
|
153
|
+
// `rivetkit_shared_types::actor_key`; both run the vectors in
|
|
154
|
+
// `rivetkit-rust/packages/shared-types/tests/fixtures/actor_key_vectors.json`.
|
|
155
|
+
const CANONICAL_SEPARATOR = ",";
|
|
156
|
+
const CANONICAL_EMPTY_PART = "\\0";
|
|
157
|
+
|
|
158
|
+
/** Encodes `key` in the canonical form. */
|
|
159
|
+
export function encodeActorKey(key: ActorKey): string {
|
|
160
|
+
return key
|
|
161
|
+
.map((part) => {
|
|
162
|
+
if (part === "") {
|
|
163
|
+
return CANONICAL_EMPTY_PART;
|
|
164
|
+
}
|
|
165
|
+
return part.replace(/\\/g, "\\\\").replace(/,/g, "\\,");
|
|
166
|
+
})
|
|
167
|
+
.join(CANONICAL_SEPARATOR);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Decodes a canonical key, or an unescaped `rvt-key` value from an earlier client. Only `\\` and
|
|
172
|
+
* `\,` are escapes; any other backslash is literal, and a part written as exactly `\0` is empty.
|
|
173
|
+
*/
|
|
174
|
+
export function decodeActorKey(key: string): ActorKey {
|
|
175
|
+
if (key === "") {
|
|
176
|
+
return [];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const parts: string[] = [];
|
|
180
|
+
let raw = "";
|
|
181
|
+
let current = "";
|
|
182
|
+
const finishPart = () => {
|
|
183
|
+
parts.push(raw === CANONICAL_EMPTY_PART ? "" : current);
|
|
184
|
+
raw = "";
|
|
185
|
+
current = "";
|
|
186
|
+
};
|
|
187
|
+
for (let i = 0; i < key.length; i++) {
|
|
188
|
+
const char = key[i];
|
|
189
|
+
if (char === CANONICAL_SEPARATOR) {
|
|
190
|
+
finishPart();
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
raw += char;
|
|
195
|
+
if (char !== "\\") {
|
|
196
|
+
current += char;
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const next = key[i + 1];
|
|
201
|
+
if (next === "\\" || next === CANONICAL_SEPARATOR) {
|
|
202
|
+
raw += next;
|
|
203
|
+
current += next;
|
|
204
|
+
i++;
|
|
205
|
+
} else {
|
|
206
|
+
current += char;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
finishPart();
|
|
210
|
+
return parts;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* The gateway's `rvt-key` query value for `key`: the canonical key, or `undefined` when the
|
|
215
|
+
* parameter is omitted, as it is for the empty key.
|
|
216
|
+
*/
|
|
217
|
+
export function actorKeyToGatewayQuery(key: ActorKey): string | undefined {
|
|
218
|
+
if (key.length === 0) {
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
221
|
+
return encodeActorKey(key);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** Reads the gateway's `rvt-key` query value. A missing value is the empty key. */
|
|
225
|
+
export function actorKeyFromGatewayQuery(
|
|
226
|
+
rvtKey: string | null | undefined,
|
|
227
|
+
): ActorKey {
|
|
228
|
+
if (rvtKey === undefined || rvtKey === null) {
|
|
229
|
+
return [];
|
|
230
|
+
}
|
|
231
|
+
return decodeActorKey(rvtKey);
|
|
232
|
+
}
|
|
233
|
+
|
|
148
234
|
export function makePrefixedKey(key: Uint8Array): Uint8Array {
|
|
149
235
|
const prefixed = new Uint8Array(KEYS.KV.length + key.length);
|
|
150
236
|
prefixed.set(KEYS.KV, 0);
|
package/src/actor/mod.ts
CHANGED
|
@@ -14,6 +14,7 @@ export type {
|
|
|
14
14
|
UniversalWebSocket,
|
|
15
15
|
} from "@/common/websocket-interface";
|
|
16
16
|
export type * from "./config";
|
|
17
|
+
export { defineRunHandler } from "./config";
|
|
17
18
|
export type {
|
|
18
19
|
ActionContextOf,
|
|
19
20
|
BeforeActionResponseContextOf,
|
|
@@ -57,4 +58,17 @@ export {
|
|
|
57
58
|
UserError,
|
|
58
59
|
type UserErrorOptions,
|
|
59
60
|
} from "./errors";
|
|
60
|
-
export {
|
|
61
|
+
export {
|
|
62
|
+
type EventSchemaConfig,
|
|
63
|
+
event,
|
|
64
|
+
type InferEventArgs,
|
|
65
|
+
type InferSchemaMap,
|
|
66
|
+
type QueueSchemaConfig,
|
|
67
|
+
queue,
|
|
68
|
+
type Type,
|
|
69
|
+
} from "./schema";
|
|
70
|
+
export type {
|
|
71
|
+
ActionSampleRates,
|
|
72
|
+
ActionTraceSamplers,
|
|
73
|
+
ActorTracingOptions,
|
|
74
|
+
} from "./tracing";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Sample rates keyed by action name, nested like the actor's action groups. */
|
|
2
|
+
export interface ActionSampleRates {
|
|
3
|
+
readonly [name: string]: number | ActionSampleRates;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* {@link ActionSampleRates} limited to the actions of one actor, so a rate for
|
|
8
|
+
* an action that does not exist is a compile error.
|
|
9
|
+
*/
|
|
10
|
+
export type ActionTraceSamplers<TActions> = {
|
|
11
|
+
readonly [K in keyof TActions]?: TActions[K] extends (
|
|
12
|
+
...args: never[]
|
|
13
|
+
) => unknown
|
|
14
|
+
? number
|
|
15
|
+
: ActionTraceSamplers<TActions[K]>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** Trace sampling for one actor definition. */
|
|
19
|
+
export interface ActorTracingOptions<TActions> {
|
|
20
|
+
/**
|
|
21
|
+
* Share of this actor's invocations that are recorded, from 0 to 1. A rate
|
|
22
|
+
* lowers what is recorded and never raises it, so an invocation inside a
|
|
23
|
+
* trace the caller did not record is not recorded at any rate.
|
|
24
|
+
*/
|
|
25
|
+
readonly sampler?: number;
|
|
26
|
+
/** Rates that replace `sampler` for single actions. */
|
|
27
|
+
readonly actions?: ActionTraceSamplers<TActions>;
|
|
28
|
+
}
|
package/src/agent-os/index.ts
CHANGED
|
@@ -1,65 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// Filesystem actions
|
|
7
|
-
export { buildFilesystemActions } from "./actor/filesystem";
|
|
8
|
-
// Actor factory and VM lifecycle helpers
|
|
9
|
-
export { agentOs, ensureVm, runHook, syncPreventSleep } from "./actor/index";
|
|
10
|
-
// Network actions
|
|
11
|
-
export {
|
|
12
|
-
buildNetworkActions,
|
|
13
|
-
type VmFetchOptions,
|
|
14
|
-
type VmFetchResult,
|
|
15
|
-
} from "./actor/network";
|
|
16
|
-
// Preview actions
|
|
17
|
-
export {
|
|
18
|
-
buildOnRequestHandler,
|
|
19
|
-
buildPreviewActions,
|
|
20
|
-
generateToken,
|
|
21
|
-
} from "./actor/preview";
|
|
22
|
-
// Process actions
|
|
23
|
-
export { buildProcessActions } from "./actor/process";
|
|
24
|
-
// Session actions
|
|
25
|
-
export {
|
|
26
|
-
buildConfigActions,
|
|
27
|
-
buildPromptActions,
|
|
28
|
-
buildSessionActions,
|
|
29
|
-
buildSessionPersistenceActions,
|
|
30
|
-
subscribeToSession,
|
|
31
|
-
} from "./actor/session";
|
|
32
|
-
// Shell actions
|
|
33
|
-
export { buildShellActions } from "./actor/shell";
|
|
34
|
-
// Config schema and types
|
|
35
|
-
export {
|
|
36
|
-
type AgentOsActorConfig,
|
|
37
|
-
type AgentOsActorConfigInput,
|
|
38
|
-
agentOsActorConfigSchema,
|
|
39
|
-
} from "./config";
|
|
40
|
-
// Database-backed VFS
|
|
41
|
-
export {
|
|
42
|
-
createDatabaseVfs,
|
|
43
|
-
type DatabaseVfsOptions,
|
|
44
|
-
} from "./fs/database-vfs";
|
|
45
|
-
// Domain types and event payloads
|
|
46
|
-
export type {
|
|
47
|
-
AgentOsActionContext,
|
|
48
|
-
AgentOsActorState,
|
|
49
|
-
AgentOsActorVars,
|
|
50
|
-
AgentOsEvents,
|
|
51
|
-
CronEventPayload,
|
|
52
|
-
PermissionRequestPayload,
|
|
53
|
-
PersistedSessionEvent,
|
|
54
|
-
PersistedSessionRecord,
|
|
55
|
-
ProcessExitPayload,
|
|
56
|
-
ProcessOutputPayload,
|
|
57
|
-
PromptResult,
|
|
58
|
-
SerializableCronAction,
|
|
59
|
-
SerializableCronJobOptions,
|
|
60
|
-
SessionEventPayload,
|
|
61
|
-
SessionRecord,
|
|
62
|
-
ShellDataPayload,
|
|
63
|
-
VmBootedPayload,
|
|
64
|
-
VmShutdownPayload,
|
|
65
|
-
} from "./types";
|
|
1
|
+
// agentOS no longer ships inside RivetKit. This entrypoint remains so existing
|
|
2
|
+
// imports fail with migration guidance instead of a missing-module error.
|
|
3
|
+
throw new Error(
|
|
4
|
+
"rivetkit/agent-os has been removed. Use @rivet-dev/agentos-core to run agentOS VMs in your process, or hosted agentOS with @rivet-dev/agentos. See https://rivet.dev/agentos/docs",
|
|
5
|
+
);
|
|
@@ -43,23 +43,16 @@ type ActorActionMap<R> = {
|
|
|
43
43
|
...args: infer Args
|
|
44
44
|
) => infer Return
|
|
45
45
|
? ActorActionFunction<Args, Awaited<Return>>
|
|
46
|
-
:
|
|
46
|
+
: NonNullable<R>[K] extends Record<string, unknown>
|
|
47
|
+
? ActorActionMap<NonNullable<R>[K]>
|
|
48
|
+
: never;
|
|
47
49
|
};
|
|
48
50
|
|
|
49
|
-
type ActionsOf<AD extends AnyActorDefinition> =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
any,
|
|
55
|
-
any,
|
|
56
|
-
any,
|
|
57
|
-
any,
|
|
58
|
-
any,
|
|
59
|
-
infer R
|
|
60
|
-
>
|
|
61
|
-
? R
|
|
62
|
-
: never;
|
|
51
|
+
type ActionsOf<AD extends AnyActorDefinition> = AD["config"] extends {
|
|
52
|
+
actions?: infer R;
|
|
53
|
+
}
|
|
54
|
+
? R
|
|
55
|
+
: never;
|
|
63
56
|
|
|
64
57
|
export interface ActorGatewayOptions {
|
|
65
58
|
skipReadyWait?: boolean;
|