rivetkit 0.0.0-skip-ready-wait-flatten-client-options.1cae221 → 0.0.0-sqlite-uds.4e59a38
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 +561 -89
- package/dist/browser/client.js +1063 -430
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.d.ts +22 -2
- package/dist/browser/inspector/client.js +1036 -232
- 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 -74
- package/dist/tsup/actor/errors.d.ts +1 -74
- package/dist/tsup/actor/errors.js +5 -1
- package/dist/tsup/agent-os/index.cjs +2218 -2082
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +556 -85
- package/dist/tsup/agent-os/index.d.ts +556 -85
- package/dist/tsup/agent-os/index.js +2220 -2084
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-NFC5VU36.cjs → chunk-3GC3EP6D.cjs} +18 -10
- package/dist/tsup/chunk-3GC3EP6D.cjs.map +1 -0
- package/dist/tsup/{chunk-7MRGNVSR.js → chunk-3GLNEWGY.js} +78 -6
- package/dist/tsup/chunk-3GLNEWGY.js.map +1 -0
- package/dist/tsup/{chunk-V3QNBJ7N.cjs → chunk-4FC7TVS6.cjs} +35 -10
- package/dist/tsup/chunk-4FC7TVS6.cjs.map +1 -0
- package/dist/tsup/{chunk-POTPHU3P.cjs → chunk-62LSMTP2.cjs} +3 -3
- package/dist/tsup/{chunk-POTPHU3P.cjs.map → chunk-62LSMTP2.cjs.map} +1 -1
- package/dist/tsup/{chunk-OIKOPSXQ.js → chunk-7IVUT2JT.js} +12 -4
- package/dist/tsup/chunk-7IVUT2JT.js.map +1 -0
- package/dist/tsup/{chunk-22XU3BVY.cjs → chunk-GEYQLGXC.cjs} +925 -328
- package/dist/tsup/chunk-GEYQLGXC.cjs.map +1 -0
- package/dist/tsup/{chunk-D2TLG75Y.cjs → chunk-GMN45CQ6.cjs} +10 -10
- package/dist/tsup/chunk-GMN45CQ6.cjs.map +1 -0
- package/dist/tsup/{chunk-3BFYSYRU.js → chunk-HXUEHHJF.js} +3 -2
- package/dist/tsup/chunk-HXUEHHJF.js.map +1 -0
- package/dist/tsup/{chunk-IOYKCB6Y.cjs → chunk-I336PMWT.cjs} +44 -9
- package/dist/tsup/chunk-I336PMWT.cjs.map +1 -0
- package/dist/tsup/{chunk-RZEJJJKU.js → chunk-IB73AMGJ.js} +42 -7
- package/dist/tsup/chunk-IB73AMGJ.js.map +1 -0
- package/dist/tsup/{chunk-4ZIWB4CQ.js → chunk-ITWJ6Y7G.js} +2 -2
- package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JZ7TWV65.js} +1 -1
- package/dist/tsup/chunk-JZ7TWV65.js.map +1 -0
- package/dist/tsup/{chunk-W54QCENI.js → chunk-KTNBYGRU.js} +134 -20
- package/dist/tsup/chunk-KTNBYGRU.js.map +1 -0
- package/dist/tsup/{chunk-AK57AL7S.cjs → chunk-OAPVVVTX.cjs} +79 -7
- package/dist/tsup/chunk-OAPVVVTX.cjs.map +1 -0
- package/dist/tsup/{chunk-TPBHXFB2.cjs → chunk-OUDV3ITX.cjs} +138 -24
- package/dist/tsup/chunk-OUDV3ITX.cjs.map +1 -0
- package/dist/tsup/{chunk-XNZR7UD2.cjs → chunk-PRXTIERO.cjs} +90 -65
- package/dist/tsup/chunk-PRXTIERO.cjs.map +1 -0
- package/dist/tsup/{chunk-LLD2D5LO.cjs → chunk-VE2X4KMG.cjs} +3 -2
- package/dist/tsup/chunk-VE2X4KMG.cjs.map +1 -0
- package/dist/tsup/{chunk-KSG2COSQ.js → chunk-WRZEVVLL.js} +6 -6
- package/dist/tsup/chunk-WRZEVVLL.js.map +1 -0
- package/dist/tsup/{chunk-LNMB25HW.js → chunk-XAIMHUPG.js} +780 -183
- package/dist/tsup/chunk-XAIMHUPG.js.map +1 -0
- package/dist/tsup/{chunk-D4TSTM6C.js → chunk-XZ62SWSC.js} +83 -58
- package/dist/tsup/chunk-XZ62SWSC.js.map +1 -0
- package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-ZA7FLHKH.cjs} +1 -1
- package/dist/tsup/chunk-ZA7FLHKH.cjs.map +1 -0
- package/dist/tsup/{chunk-K34B3OVG.js → chunk-ZZ3WBRPD.js} +34 -9
- package/dist/tsup/chunk-ZZ3WBRPD.js.map +1 -0
- package/dist/tsup/client/mod.cjs +9 -9
- package/dist/tsup/client/mod.cjs.map +1 -1
- package/dist/tsup/client/mod.d.cts +8 -9
- package/dist/tsup/client/mod.d.ts +8 -9
- package/dist/tsup/client/mod.js +8 -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.js +3 -3
- package/dist/tsup/{config-CRdGwwbr.d.cts → config-CxG53eQo.d.cts} +577 -36
- package/dist/tsup/{config-kxXbtrJU.d.ts → config-DLOxy81E.d.cts} +5 -5
- package/dist/tsup/{config-kxXbtrJU.d.cts → config-DLOxy81E.d.ts} +5 -5
- package/dist/tsup/{config-DIpBWm5C.d.ts → config-Ds6DCRhV.d.ts} +577 -36
- package/dist/tsup/context-8KlcOYIs.d.cts +129 -0
- package/dist/tsup/context-Cfbm4QLr.d.ts +129 -0
- package/dist/tsup/db/drizzle.cjs +151 -79
- package/dist/tsup/db/drizzle.cjs.map +1 -1
- package/dist/tsup/db/drizzle.d.cts +2 -2
- package/dist/tsup/db/drizzle.d.ts +2 -2
- package/dist/tsup/db/drizzle.js +151 -79
- package/dist/tsup/db/drizzle.js.map +1 -1
- package/dist/tsup/db/mod.cjs +79 -24
- package/dist/tsup/db/mod.cjs.map +1 -1
- package/dist/tsup/db/mod.d.cts +2 -2
- package/dist/tsup/db/mod.d.ts +2 -2
- package/dist/tsup/db/mod.js +78 -23
- package/dist/tsup/db/mod.js.map +1 -1
- package/dist/tsup/dynamic/mod.cjs +24 -0
- package/dist/tsup/dynamic/mod.cjs.map +1 -0
- package/dist/tsup/dynamic/mod.d.cts +37 -0
- package/dist/tsup/dynamic/mod.d.ts +37 -0
- package/dist/tsup/dynamic/mod.js +24 -0
- package/dist/tsup/dynamic/mod.js.map +1 -0
- package/dist/tsup/inspector/mod.cjs +47 -12
- package/dist/tsup/inspector/mod.cjs.map +1 -1
- package/dist/tsup/inspector/mod.d.cts +37 -15
- package/dist/tsup/inspector/mod.d.ts +37 -15
- package/dist/tsup/inspector/mod.js +46 -11
- package/dist/tsup/inspector/mod.js.map +1 -1
- package/dist/tsup/inspector-tab/mod.cjs +162 -0
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
- package/dist/tsup/inspector-tab/mod.d.cts +240 -0
- package/dist/tsup/inspector-tab/mod.d.ts +240 -0
- package/dist/tsup/inspector-tab/mod.js +162 -0
- package/dist/tsup/inspector-tab/mod.js.map +1 -0
- package/dist/tsup/mod.cjs +1078 -479
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +5 -6
- package/dist/tsup/mod.d.ts +5 -6
- package/dist/tsup/mod.js +996 -397
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +21 -18
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +4 -5
- package/dist/tsup/test/mod.d.ts +4 -5
- package/dist/tsup/test/mod.js +18 -15
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/utils-CqDnC_PS.d.cts +104 -0
- package/dist/tsup/utils-CqDnC_PS.d.ts +104 -0
- package/dist/tsup/utils.cjs +3 -3
- package/dist/tsup/utils.d.cts +1 -1
- package/dist/tsup/utils.d.ts +1 -1
- package/dist/tsup/utils.js +2 -2
- package/dist/tsup/workflow/mod.cjs +386 -322
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +8 -9
- package/dist/tsup/workflow/mod.d.ts +8 -9
- package/dist/tsup/workflow/mod.js +363 -299
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +35 -14
- package/src/actor/config.ts +188 -59
- package/src/actor/contexts/index.ts +7 -2
- package/src/actor/definition.ts +17 -19
- package/src/actor/driver.ts +3 -3
- package/src/actor/errors.ts +70 -7
- package/src/actor/instance/mod.ts +39 -56
- package/src/actor/keys.ts +2 -1
- package/src/actor/mod.ts +22 -20
- package/src/actor/schema.ts +2 -2
- package/src/agent-os/actor/index.ts +38 -18
- package/src/agent-os/actor/preview.ts +1 -2
- package/src/agent-os/actor/session.ts +2 -2
- package/src/agent-os/config.ts +1 -1
- package/src/agent-os/fs/database-vfs.ts +1 -1
- package/src/agent-os/index.ts +16 -15
- package/src/client/actor-common.ts +88 -62
- package/src/client/actor-conn.ts +58 -63
- package/src/client/actor-handle.ts +125 -71
- package/src/client/actor-query.ts +5 -5
- package/src/client/config.ts +3 -3
- package/src/client/errors.ts +2 -1
- package/src/client/lifecycle-errors.ts +2 -4
- package/src/client/query.ts +1 -1
- package/src/client/queue.ts +8 -3
- package/src/client/raw-utils.ts +10 -10
- package/src/client/resolve-gateway-target.ts +1 -1
- package/src/client/utils.ts +34 -10
- package/src/common/actor-router-consts.ts +7 -4
- package/src/common/actor-websocket.ts +3 -1
- package/src/common/bare/actor-persist/v1.ts +205 -163
- package/src/common/bare/actor-persist/v2.ts +265 -213
- package/src/common/bare/actor-persist/v3.ts +176 -172
- package/src/common/bare/actor-persist/v4.ts +254 -253
- package/src/common/bare/generated/client-protocol/v4.ts +599 -0
- package/src/common/bare/generated/inspector/v5.ts +1016 -0
- package/src/common/bare/transport/v1.ts +694 -542
- package/src/common/client-protocol-versioned.ts +176 -67
- package/src/common/client-protocol-zod.ts +7 -0
- package/src/common/client-protocol.ts +1 -1
- package/src/common/database/config.ts +16 -5
- package/src/common/database/mod.test.ts +83 -16
- package/src/common/database/mod.ts +86 -30
- package/src/common/database/native-database.test.ts +35 -22
- package/src/common/database/native-database.ts +26 -10
- package/src/common/database/shared.ts +1 -0
- package/src/common/encoding.ts +250 -16
- package/src/common/engine.ts +28 -1
- package/src/common/eventsource.ts +1 -1
- package/src/common/inline-websocket-adapter.ts +14 -13
- package/src/common/log.ts +15 -8
- package/src/common/router.ts +49 -23
- package/src/common/utils.ts +10 -202
- package/src/common/websocket-interface.ts +1 -1
- package/src/db/drizzle.ts +173 -96
- package/src/db/mod.ts +1 -1
- package/src/devtools-loader/index.ts +4 -7
- package/src/devtools-loader/serve-devtools.ts +26 -0
- package/src/drivers/engine/actor-driver.ts +76 -73
- package/src/dynamic/instance.ts +32 -0
- package/src/dynamic/internal.ts +50 -0
- package/src/dynamic/isolate-runtime.ts +66 -0
- package/src/dynamic/mod.ts +32 -0
- package/src/engine-client/actor-http-client.ts +6 -9
- package/src/engine-client/actor-websocket-client.ts +14 -13
- package/src/engine-client/api-endpoints.ts +51 -2
- package/src/engine-client/api-utils.ts +2 -2
- package/src/engine-client/driver.ts +3 -4
- package/src/engine-client/mod.ts +17 -10
- package/src/engine-client/ws-proxy.ts +9 -4
- package/src/inspector/client.browser.ts +66 -15
- package/src/inspector/mod.ts +2 -4
- package/src/inspector-tab/mod.ts +300 -0
- package/src/registry/config/envoy.ts +1 -2
- package/src/registry/config/index.ts +46 -20
- package/src/registry/index.ts +364 -87
- package/src/registry/napi-runtime.ts +97 -8
- package/src/registry/native-validation.ts +10 -12
- package/src/registry/native.ts +592 -343
- package/src/registry/process-metrics.ts +250 -0
- package/src/registry/runtime.ts +85 -6
- package/src/registry/wasm-runtime.ts +72 -3
- package/src/registry/write-through-proxy.ts +40 -0
- package/src/serde.ts +2 -2
- package/src/serverless/configure.ts +19 -8
- package/src/test/mod.ts +11 -8
- package/src/utils/crypto.ts +14 -0
- package/src/utils/endpoint-parser.ts +1 -1
- package/src/utils/env-vars.ts +37 -0
- package/src/utils/router.ts +1 -1
- package/src/utils.ts +1 -2
- package/src/workflow/context.ts +703 -240
- package/src/workflow/driver.ts +23 -12
- package/src/workflow/inspector.ts +12 -3
- package/src/workflow/mod.ts +37 -23
- package/dist/tsup/chunk-22XU3BVY.cjs.map +0 -1
- package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
- package/dist/tsup/chunk-3BFYSYRU.js.map +0 -1
- package/dist/tsup/chunk-7MRGNVSR.js.map +0 -1
- package/dist/tsup/chunk-AK57AL7S.cjs.map +0 -1
- package/dist/tsup/chunk-D2TLG75Y.cjs.map +0 -1
- package/dist/tsup/chunk-D4TSTM6C.js.map +0 -1
- package/dist/tsup/chunk-IOYKCB6Y.cjs.map +0 -1
- package/dist/tsup/chunk-K34B3OVG.js.map +0 -1
- package/dist/tsup/chunk-KSG2COSQ.js.map +0 -1
- package/dist/tsup/chunk-LLD2D5LO.cjs.map +0 -1
- package/dist/tsup/chunk-LNMB25HW.js.map +0 -1
- package/dist/tsup/chunk-NFC5VU36.cjs.map +0 -1
- package/dist/tsup/chunk-OIKOPSXQ.js.map +0 -1
- package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
- package/dist/tsup/chunk-RZEJJJKU.js.map +0 -1
- package/dist/tsup/chunk-TPBHXFB2.cjs.map +0 -1
- package/dist/tsup/chunk-V3QNBJ7N.cjs.map +0 -1
- package/dist/tsup/chunk-W54QCENI.js.map +0 -1
- package/dist/tsup/chunk-XNZR7UD2.cjs.map +0 -1
- package/dist/tsup/context-B7G6sk7x.d.ts +0 -92
- package/dist/tsup/context-DzMRHkjC.d.cts +0 -92
- package/dist/tsup/utils-fwx3o3K9.d.cts +0 -18
- package/dist/tsup/utils-fwx3o3K9.d.ts +0 -18
- package/src/utils/serve.ts +0 -217
- /package/dist/tsup/{chunk-4ZIWB4CQ.js.map → chunk-ITWJ6Y7G.js.map} +0 -0
package/src/actor/errors.ts
CHANGED
|
@@ -14,6 +14,15 @@ export interface RivetErrorOptions extends ErrorOptions {
|
|
|
14
14
|
metadata?: unknown;
|
|
15
15
|
/** Explicit HTTP status override for router responses. */
|
|
16
16
|
statusCode?: number;
|
|
17
|
+
/** Actor context associated with this error. */
|
|
18
|
+
actor?: ActorSpecifier;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Identifies the actor that was handling work when an error was produced. */
|
|
22
|
+
export interface ActorSpecifier {
|
|
23
|
+
actorId: string;
|
|
24
|
+
generation: number;
|
|
25
|
+
key?: string;
|
|
17
26
|
}
|
|
18
27
|
|
|
19
28
|
export interface RivetErrorLike {
|
|
@@ -24,8 +33,11 @@ export interface RivetErrorLike {
|
|
|
24
33
|
metadata?: unknown;
|
|
25
34
|
public?: boolean;
|
|
26
35
|
statusCode?: number;
|
|
36
|
+
actor?: ActorSpecifier;
|
|
27
37
|
}
|
|
28
38
|
|
|
39
|
+
export interface BridgeRivetErrorPayload extends RivetErrorLike {}
|
|
40
|
+
|
|
29
41
|
export interface UserErrorOptions extends ErrorOptions {
|
|
30
42
|
/**
|
|
31
43
|
* Machine readable code for this error. Useful for catching different types of
|
|
@@ -48,6 +60,7 @@ function looksLikeRivetErrorOptions(
|
|
|
48
60
|
("public" in value ||
|
|
49
61
|
"metadata" in value ||
|
|
50
62
|
"statusCode" in value ||
|
|
63
|
+
"actor" in value ||
|
|
51
64
|
"cause" in value)
|
|
52
65
|
);
|
|
53
66
|
}
|
|
@@ -85,12 +98,38 @@ export function isRivetErrorLike(
|
|
|
85
98
|
);
|
|
86
99
|
}
|
|
87
100
|
|
|
101
|
+
// Matches the `actor`/`aborted` error that core raises when an in-flight queue
|
|
102
|
+
// wait is interrupted because the actor is going to sleep. This is the expected
|
|
103
|
+
// way a parked `run` handler unwinds during sleep, not a failure.
|
|
104
|
+
export function isActorAbortedError(error: unknown): boolean {
|
|
105
|
+
return (
|
|
106
|
+
isRivetErrorLike(error) &&
|
|
107
|
+
error.group === "actor" &&
|
|
108
|
+
error.code === "aborted"
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function isActorSpecifier(value: unknown): value is ActorSpecifier {
|
|
113
|
+
return (
|
|
114
|
+
typeof value === "object" &&
|
|
115
|
+
value !== null &&
|
|
116
|
+
"actorId" in value &&
|
|
117
|
+
typeof value.actorId === "string" &&
|
|
118
|
+
"generation" in value &&
|
|
119
|
+
typeof value.generation === "number" &&
|
|
120
|
+
(!("key" in value) ||
|
|
121
|
+
value.key === undefined ||
|
|
122
|
+
typeof value.key === "string")
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
88
126
|
export class RivetError extends Error {
|
|
89
127
|
__type = "RivetError" as const;
|
|
90
128
|
|
|
91
129
|
public public: boolean;
|
|
92
130
|
public metadata?: unknown;
|
|
93
131
|
public statusCode: number;
|
|
132
|
+
public actor?: ActorSpecifier;
|
|
94
133
|
public readonly group: string;
|
|
95
134
|
public readonly code: string;
|
|
96
135
|
|
|
@@ -123,6 +162,7 @@ export class RivetError extends Error {
|
|
|
123
162
|
this.public = normalized.public ?? false;
|
|
124
163
|
this.metadata = normalized.metadata;
|
|
125
164
|
this.statusCode = normalized.statusCode ?? (this.public ? 400 : 500);
|
|
165
|
+
this.actor = normalized.actor;
|
|
126
166
|
}
|
|
127
167
|
|
|
128
168
|
toString() {
|
|
@@ -165,6 +205,7 @@ export function toRivetError(
|
|
|
165
205
|
public: error.public,
|
|
166
206
|
statusCode: error.statusCode,
|
|
167
207
|
metadata: error.metadata,
|
|
208
|
+
actor: error.actor,
|
|
168
209
|
cause: error instanceof Error ? error.cause : undefined,
|
|
169
210
|
});
|
|
170
211
|
}
|
|
@@ -177,6 +218,7 @@ export function toRivetError(
|
|
|
177
218
|
public: fallback?.public,
|
|
178
219
|
statusCode: fallback?.statusCode,
|
|
179
220
|
metadata: fallback?.metadata,
|
|
221
|
+
actor: fallback?.actor,
|
|
180
222
|
cause: error instanceof Error ? error : undefined,
|
|
181
223
|
},
|
|
182
224
|
);
|
|
@@ -190,10 +232,13 @@ export function encodeBridgeRivetError(error: RivetErrorLike): string {
|
|
|
190
232
|
metadata: error.metadata,
|
|
191
233
|
public: error.public,
|
|
192
234
|
statusCode: error.statusCode,
|
|
235
|
+
actor: error.actor,
|
|
193
236
|
})}`;
|
|
194
237
|
}
|
|
195
238
|
|
|
196
|
-
export function
|
|
239
|
+
export function decodeBridgeRivetErrorPayload(
|
|
240
|
+
value: string,
|
|
241
|
+
): BridgeRivetErrorPayload | undefined {
|
|
197
242
|
if (!value.startsWith(BRIDGE_RIVET_ERROR_PREFIX)) {
|
|
198
243
|
return undefined;
|
|
199
244
|
}
|
|
@@ -201,21 +246,38 @@ export function decodeBridgeRivetError(value: string): RivetError | undefined {
|
|
|
201
246
|
try {
|
|
202
247
|
const payload = JSON.parse(
|
|
203
248
|
value.slice(BRIDGE_RIVET_ERROR_PREFIX.length),
|
|
204
|
-
) as
|
|
249
|
+
) as BridgeRivetErrorPayload;
|
|
205
250
|
if (!isRivetErrorLike(payload)) {
|
|
206
251
|
return undefined;
|
|
207
252
|
}
|
|
253
|
+
if (
|
|
254
|
+
payload.actor !== undefined &&
|
|
255
|
+
payload.actor !== null &&
|
|
256
|
+
!isActorSpecifier(payload.actor)
|
|
257
|
+
) {
|
|
258
|
+
return undefined;
|
|
259
|
+
}
|
|
208
260
|
|
|
209
|
-
return
|
|
210
|
-
metadata: payload.metadata,
|
|
211
|
-
public: payload.public,
|
|
212
|
-
statusCode: payload.statusCode,
|
|
213
|
-
});
|
|
261
|
+
return payload;
|
|
214
262
|
} catch {
|
|
215
263
|
return undefined;
|
|
216
264
|
}
|
|
217
265
|
}
|
|
218
266
|
|
|
267
|
+
export function decodeBridgeRivetError(value: string): RivetError | undefined {
|
|
268
|
+
const payload = decodeBridgeRivetErrorPayload(value);
|
|
269
|
+
if (!payload) {
|
|
270
|
+
return undefined;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return new RivetError(payload.group, payload.code, payload.message, {
|
|
274
|
+
metadata: payload.metadata,
|
|
275
|
+
public: payload.public,
|
|
276
|
+
statusCode: payload.statusCode,
|
|
277
|
+
actor: payload.actor ?? undefined,
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
|
|
219
281
|
export function isRivetErrorCode(
|
|
220
282
|
error: unknown,
|
|
221
283
|
group: string,
|
|
@@ -241,6 +303,7 @@ export function internalError(
|
|
|
241
303
|
public: options?.public,
|
|
242
304
|
statusCode: options?.statusCode,
|
|
243
305
|
metadata: options?.metadata,
|
|
306
|
+
actor: options?.actor,
|
|
244
307
|
cause: options?.cause,
|
|
245
308
|
},
|
|
246
309
|
);
|
|
@@ -9,22 +9,21 @@ import {
|
|
|
9
9
|
type SpanStatusInput,
|
|
10
10
|
type Traces,
|
|
11
11
|
} from "@rivetkit/traces";
|
|
12
|
-
import { ActorMetrics, type StartupTimingKey } from "@/actor/metrics";
|
|
13
12
|
import invariant from "invariant";
|
|
13
|
+
import { ActorMetrics, type StartupTimingKey } from "@/actor/metrics";
|
|
14
14
|
import type { Client } from "@/client/client";
|
|
15
|
+
import type { ActorKey } from "@/client/query";
|
|
15
16
|
import { getBaseLogger, getIncludeTarget, type Logger } from "@/common/log";
|
|
16
17
|
import { stringifyError } from "@/common/utils";
|
|
17
18
|
import type { UniversalWebSocket } from "@/common/websocket-interface";
|
|
18
19
|
import { ActorInspector } from "@/inspector/actor-inspector";
|
|
19
|
-
import type { ActorKey } from "@/client/query";
|
|
20
20
|
import type { Registry } from "@/mod";
|
|
21
21
|
import {
|
|
22
22
|
ACTOR_VERSIONED,
|
|
23
23
|
CONN_VERSIONED,
|
|
24
24
|
} from "@/schemas/actor-persist/versioned";
|
|
25
|
-
import { EXTRA_ERROR_LOG } from "@/utils";
|
|
25
|
+
import { EXTRA_ERROR_LOG, promiseWithResolvers } from "@/utils";
|
|
26
26
|
import { getRivetExperimentalOtel } from "@/utils/env-vars";
|
|
27
|
-
import { promiseWithResolvers } from "@/utils";
|
|
28
27
|
import {
|
|
29
28
|
type Actions,
|
|
30
29
|
type ActorConfig,
|
|
@@ -32,16 +31,13 @@ import {
|
|
|
32
31
|
ActorConfigSchema,
|
|
33
32
|
getRunFunction,
|
|
34
33
|
} from "../config";
|
|
35
|
-
import type { ConnDriver } from "../conn/driver";
|
|
36
|
-
import { createHttpDriver } from "../conn/drivers/http";
|
|
37
34
|
import {
|
|
38
|
-
HibernatableWebSocketAckState,
|
|
39
35
|
handleInboundHibernatableWebSocketMessage as applyInboundHibernatableWebSocketMessage,
|
|
36
|
+
HibernatableWebSocketAckState,
|
|
40
37
|
} from "../conn/hibernatable-websocket-ack-state";
|
|
41
38
|
import {
|
|
42
|
-
CONN_DRIVER_SYMBOL,
|
|
43
|
-
CONN_STATE_MANAGER_SYMBOL,
|
|
44
39
|
type AnyConn,
|
|
40
|
+
CONN_STATE_MANAGER_SYMBOL,
|
|
45
41
|
type Conn,
|
|
46
42
|
type ConnId,
|
|
47
43
|
} from "../conn/mod";
|
|
@@ -50,7 +46,7 @@ import {
|
|
|
50
46
|
type PersistedConn,
|
|
51
47
|
} from "../conn/persisted";
|
|
52
48
|
import {
|
|
53
|
-
ActionContext,
|
|
49
|
+
type ActionContext,
|
|
54
50
|
ActorContext,
|
|
55
51
|
RequestContext,
|
|
56
52
|
WebSocketContext,
|
|
@@ -79,20 +75,16 @@ import {
|
|
|
79
75
|
import { ConnectionManager } from "./connection-manager";
|
|
80
76
|
import { EventManager } from "./event-manager";
|
|
81
77
|
import { KEYS, workflowStoragePrefix } from "./keys";
|
|
82
|
-
import {
|
|
83
|
-
type PreloadedEntries,
|
|
84
|
-
type PreloadHit,
|
|
85
|
-
type PreloadMap,
|
|
86
|
-
} from "./preload-map";
|
|
87
78
|
import {
|
|
88
79
|
convertActorFromBarePersisted,
|
|
89
80
|
type PersistedActor,
|
|
90
81
|
} from "./persisted";
|
|
82
|
+
import type { PreloadedEntries, PreloadMap } from "./preload-map";
|
|
91
83
|
import { QueueManager } from "./queue-manager";
|
|
92
84
|
import { ScheduleManager } from "./schedule-manager";
|
|
93
85
|
import { type SaveStateOptions, StateManager } from "./state-manager";
|
|
94
|
-
import { TrackedWebSocket } from "./tracked-websocket";
|
|
95
86
|
import { ActorTracesDriver } from "./traces-driver";
|
|
87
|
+
import { TrackedWebSocket } from "./tracked-websocket";
|
|
96
88
|
import { WriteCollector } from "./write-collector";
|
|
97
89
|
|
|
98
90
|
export type { SaveStateOptions };
|
|
@@ -215,14 +207,14 @@ const ACTIVE_ASYNC_REGION_ERROR_MESSAGES: Record<
|
|
|
215
207
|
* only on `ActorInstance`.
|
|
216
208
|
*/
|
|
217
209
|
export interface BaseActorInstance<
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
210
|
+
_S = any,
|
|
211
|
+
_CP = any,
|
|
212
|
+
_CS = any,
|
|
213
|
+
_V = any,
|
|
214
|
+
_I = any,
|
|
215
|
+
_DB extends AnyDatabaseProvider = AnyDatabaseProvider,
|
|
216
|
+
_E extends EventSchemaConfig = Record<never, never>,
|
|
217
|
+
_Q extends QueueSchemaConfig = Record<never, never>,
|
|
226
218
|
> {
|
|
227
219
|
readonly id: string;
|
|
228
220
|
readonly isStopping: boolean;
|
|
@@ -957,14 +949,7 @@ export class ActorInstance<
|
|
|
957
949
|
// Scheduled events are persisted and will be re-initialized
|
|
958
950
|
// on wake via initializeAlarms().
|
|
959
951
|
this.driver.cancelAlarm?.(this.#actorId);
|
|
960
|
-
|
|
961
|
-
// Abort listeners in the canonical stop path.
|
|
962
|
-
// This must run for all stop modes, including sleep and remote stop.
|
|
963
|
-
// Destroy may have already triggered an early abort, but repeating abort
|
|
964
|
-
// is intentional and safe.
|
|
965
|
-
try {
|
|
966
|
-
this.#abortController.abort();
|
|
967
|
-
} catch {}
|
|
952
|
+
this.#abortActorSignal();
|
|
968
953
|
|
|
969
954
|
// The run-handler join, lifecycle hooks, and remaining shutdown
|
|
970
955
|
// tasks all share the single sleepGracePeriod budget.
|
|
@@ -1030,11 +1015,8 @@ export class ActorInstance<
|
|
|
1030
1015
|
}
|
|
1031
1016
|
|
|
1032
1017
|
this.driver.cancelAlarm?.(this.#actorId);
|
|
1018
|
+
this.#abortActorSignal();
|
|
1033
1019
|
this.stateManager.clearPendingSaveTimeout();
|
|
1034
|
-
|
|
1035
|
-
try {
|
|
1036
|
-
this.#abortController.abort();
|
|
1037
|
-
} catch {}
|
|
1038
1020
|
} finally {
|
|
1039
1021
|
this.#shutdownComplete = true;
|
|
1040
1022
|
await this.#cleanupDatabase();
|
|
@@ -1087,14 +1069,6 @@ export class ActorInstance<
|
|
|
1087
1069
|
}
|
|
1088
1070
|
this.#destroyCalled = true;
|
|
1089
1071
|
|
|
1090
|
-
// Abort immediately so in flight waits can exit before the driver stop
|
|
1091
|
-
// handshake completes.
|
|
1092
|
-
// The onStop path will call abort again as a safety net for all stop
|
|
1093
|
-
// modes.
|
|
1094
|
-
try {
|
|
1095
|
-
this.#abortController.abort();
|
|
1096
|
-
} catch {}
|
|
1097
|
-
|
|
1098
1072
|
const destroy = this.driver.startDestroy.bind(
|
|
1099
1073
|
this.driver,
|
|
1100
1074
|
this.#actorId,
|
|
@@ -1108,6 +1082,15 @@ export class ActorInstance<
|
|
|
1108
1082
|
});
|
|
1109
1083
|
}
|
|
1110
1084
|
|
|
1085
|
+
#abortActorSignal() {
|
|
1086
|
+
if (this.#abortController.signal.aborted) {
|
|
1087
|
+
return;
|
|
1088
|
+
}
|
|
1089
|
+
try {
|
|
1090
|
+
this.#abortController.abort();
|
|
1091
|
+
} catch {}
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1111
1094
|
// MARK: - HTTP Request Tracking
|
|
1112
1095
|
beginHonoHttpRequest() {
|
|
1113
1096
|
this.#activeHonoHttpRequests++;
|
|
@@ -1283,7 +1266,7 @@ export class ActorInstance<
|
|
|
1283
1266
|
"actor.onBeforeActionResponse",
|
|
1284
1267
|
{ "rivet.action.name": actionName },
|
|
1285
1268
|
() =>
|
|
1286
|
-
this.#config.onBeforeActionResponse
|
|
1269
|
+
this.#config.onBeforeActionResponse?.(
|
|
1287
1270
|
this.actorContext,
|
|
1288
1271
|
actionName,
|
|
1289
1272
|
args,
|
|
@@ -1415,7 +1398,7 @@ export class ActorInstance<
|
|
|
1415
1398
|
|
|
1416
1399
|
// NOTE: This is async and will run in the background
|
|
1417
1400
|
const voidOrPromise = this.#traces.withSpan(span, () =>
|
|
1418
|
-
this.#config.onWebSocket
|
|
1401
|
+
this.#config.onWebSocket?.(ctx, trackedWebSocket),
|
|
1419
1402
|
);
|
|
1420
1403
|
|
|
1421
1404
|
// Save changes from the WebSocket open
|
|
@@ -1654,10 +1637,10 @@ export class ActorInstance<
|
|
|
1654
1637
|
attributes?: Record<string, unknown>,
|
|
1655
1638
|
): Record<string, unknown> {
|
|
1656
1639
|
return {
|
|
1657
|
-
"rivet.actor.id": this.#actorId,
|
|
1658
|
-
"rivet.actor.name": this.#name,
|
|
1659
|
-
"rivet.actor.key": this.#actorKeyString,
|
|
1660
|
-
"rivet.actor.region": this.#region,
|
|
1640
|
+
"rivet.actors.actor.id": this.#actorId,
|
|
1641
|
+
"rivet.actors.actor.name": this.#name,
|
|
1642
|
+
"rivet.actors.actor.key": this.#actorKeyString,
|
|
1643
|
+
"rivet.actors.actor.region": this.#region,
|
|
1661
1644
|
...(attributes ?? {}),
|
|
1662
1645
|
};
|
|
1663
1646
|
}
|
|
@@ -1891,7 +1874,7 @@ export class ActorInstance<
|
|
|
1891
1874
|
"actor.createVars",
|
|
1892
1875
|
undefined,
|
|
1893
1876
|
() => {
|
|
1894
|
-
const dataOrPromise = createVars
|
|
1877
|
+
const dataOrPromise = createVars?.(
|
|
1895
1878
|
this.actorContext as any,
|
|
1896
1879
|
this.driver.getContext(this.#actorId),
|
|
1897
1880
|
);
|
|
@@ -2070,7 +2053,7 @@ export class ActorInstance<
|
|
|
2070
2053
|
|
|
2071
2054
|
if (timeoutMs <= 0) {
|
|
2072
2055
|
this.#rLog.warn({
|
|
2073
|
-
msg: "run handler did not complete in time, it may have leaked - ensure
|
|
2056
|
+
msg: "run handler did not complete in time, it may have leaked - ensure long-running work settles before shutdown finalizes",
|
|
2074
2057
|
timeoutMs,
|
|
2075
2058
|
});
|
|
2076
2059
|
return;
|
|
@@ -2085,7 +2068,7 @@ export class ActorInstance<
|
|
|
2085
2068
|
|
|
2086
2069
|
if (timedOut) {
|
|
2087
2070
|
this.#rLog.warn({
|
|
2088
|
-
msg: "run handler did not complete in time, it may have leaked - ensure
|
|
2071
|
+
msg: "run handler did not complete in time, it may have leaked - ensure long-running work settles before shutdown finalizes",
|
|
2089
2072
|
timeoutMs,
|
|
2090
2073
|
});
|
|
2091
2074
|
} else {
|
|
@@ -2093,7 +2076,7 @@ export class ActorInstance<
|
|
|
2093
2076
|
}
|
|
2094
2077
|
}
|
|
2095
2078
|
|
|
2096
|
-
async #setupDatabase(
|
|
2079
|
+
async #setupDatabase(_preload?: PreloadMap) {
|
|
2097
2080
|
if (!("db" in this.#config) || !this.#config.db) {
|
|
2098
2081
|
return;
|
|
2099
2082
|
}
|
|
@@ -2108,14 +2091,14 @@ export class ActorInstance<
|
|
|
2108
2091
|
overrideRawDatabaseClient: this.driver
|
|
2109
2092
|
.overrideRawDatabaseClient
|
|
2110
2093
|
? () =>
|
|
2111
|
-
this.driver.overrideRawDatabaseClient
|
|
2094
|
+
this.driver.overrideRawDatabaseClient?.(
|
|
2112
2095
|
this.#actorId,
|
|
2113
2096
|
)
|
|
2114
2097
|
: undefined,
|
|
2115
2098
|
overrideDrizzleDatabaseClient: this.driver
|
|
2116
2099
|
.overrideDrizzleDatabaseClient
|
|
2117
2100
|
? () =>
|
|
2118
|
-
this.driver.overrideDrizzleDatabaseClient
|
|
2101
|
+
this.driver.overrideDrizzleDatabaseClient?.(
|
|
2119
2102
|
this.#actorId,
|
|
2120
2103
|
)
|
|
2121
2104
|
: undefined,
|
package/src/actor/keys.ts
CHANGED
|
@@ -8,6 +8,7 @@ export const KEYS = {
|
|
|
8
8
|
INSPECTOR_TOKEN: Uint8Array.from([3]),
|
|
9
9
|
KV: Uint8Array.from([4]),
|
|
10
10
|
QUEUE_PREFIX: Uint8Array.from([5]),
|
|
11
|
+
LAST_PUSHED_ALARM: Uint8Array.from([6]),
|
|
11
12
|
WORKFLOW_PREFIX: Uint8Array.from([6]),
|
|
12
13
|
TRACES_PREFIX: Uint8Array.from([7]),
|
|
13
14
|
};
|
|
@@ -134,7 +135,7 @@ export function deserializeActorKey(keyString: string | undefined): ActorKey {
|
|
|
134
135
|
// Add the last part
|
|
135
136
|
if (escaping) {
|
|
136
137
|
// Incomplete escape at the end - treat as literal backslash
|
|
137
|
-
parts.push(currentPart
|
|
138
|
+
parts.push(`${currentPart}\\`);
|
|
138
139
|
} else if (isEmptyStringMarker) {
|
|
139
140
|
parts.push("");
|
|
140
141
|
} else if (currentPart !== "" || parts.length > 0) {
|
package/src/actor/mod.ts
CHANGED
|
@@ -14,6 +14,26 @@ export type {
|
|
|
14
14
|
UniversalWebSocket,
|
|
15
15
|
} from "@/common/websocket-interface";
|
|
16
16
|
export type * from "./config";
|
|
17
|
+
export type {
|
|
18
|
+
ActionContextOf,
|
|
19
|
+
BeforeActionResponseContextOf,
|
|
20
|
+
BeforeConnectContextOf,
|
|
21
|
+
ConnContextOf,
|
|
22
|
+
ConnectContextOf,
|
|
23
|
+
ConnInitContextOf,
|
|
24
|
+
CreateConnStateContextOf,
|
|
25
|
+
CreateContextOf,
|
|
26
|
+
CreateVarsContextOf,
|
|
27
|
+
DestroyContextOf,
|
|
28
|
+
DisconnectContextOf,
|
|
29
|
+
MigrateContextOf,
|
|
30
|
+
RequestContextOf,
|
|
31
|
+
RunContextOf,
|
|
32
|
+
SleepContextOf,
|
|
33
|
+
StateChangeContextOf,
|
|
34
|
+
WakeContextOf,
|
|
35
|
+
WebSocketContextOf,
|
|
36
|
+
} from "./contexts";
|
|
17
37
|
export type {
|
|
18
38
|
AnyActorDefinition,
|
|
19
39
|
AnyActorInstance,
|
|
@@ -32,27 +52,9 @@ export {
|
|
|
32
52
|
export {
|
|
33
53
|
ActorError,
|
|
34
54
|
RivetError,
|
|
55
|
+
type RivetErrorLike,
|
|
56
|
+
type RivetErrorOptions,
|
|
35
57
|
UserError,
|
|
36
58
|
type UserErrorOptions,
|
|
37
59
|
} from "./errors";
|
|
38
|
-
export type {
|
|
39
|
-
ActionContextOf,
|
|
40
|
-
BeforeActionResponseContextOf,
|
|
41
|
-
BeforeConnectContextOf,
|
|
42
|
-
ConnectContextOf,
|
|
43
|
-
ConnContextOf,
|
|
44
|
-
ConnInitContextOf,
|
|
45
|
-
CreateConnStateContextOf,
|
|
46
|
-
CreateContextOf,
|
|
47
|
-
CreateVarsContextOf,
|
|
48
|
-
DestroyContextOf,
|
|
49
|
-
DisconnectContextOf,
|
|
50
|
-
MigrateContextOf,
|
|
51
|
-
RequestContextOf,
|
|
52
|
-
RunContextOf,
|
|
53
|
-
SleepContextOf,
|
|
54
|
-
StateChangeContextOf,
|
|
55
|
-
WakeContextOf,
|
|
56
|
-
WebSocketContextOf,
|
|
57
|
-
} from "./contexts";
|
|
58
60
|
export { event, queue, type Type } from "./schema";
|
package/src/actor/schema.ts
CHANGED
|
@@ -69,7 +69,7 @@ export type EventSchemaConfig<TContext = any> = Record<
|
|
|
69
69
|
string,
|
|
70
70
|
EventSchema<TContext>
|
|
71
71
|
>;
|
|
72
|
-
export type QueueSchemaConfig<
|
|
72
|
+
export type QueueSchemaConfig<_TContext = any> = Record<string, QueueSchema>;
|
|
73
73
|
export type AnySchemaConfig = EventSchemaConfig | QueueSchemaConfig;
|
|
74
74
|
|
|
75
75
|
/** @deprecated Use `EventSchema` or `QueueSchema`. */
|
|
@@ -155,7 +155,7 @@ export function hasSchemaConfigKey<T extends AnySchemaConfig>(
|
|
|
155
155
|
if (!schemas) {
|
|
156
156
|
return false;
|
|
157
157
|
}
|
|
158
|
-
return Object.
|
|
158
|
+
return Object.hasOwn(schemas, key);
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
export function getEventCanSubscribe<TContext = any>(
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { AgentOs, createInMemoryFileSystem } from "@rivet-dev/agent-os-core";
|
|
2
1
|
import type { AgentOsOptions, MountConfig } from "@rivet-dev/agent-os-core";
|
|
3
|
-
import
|
|
4
|
-
import { actor, event } from "@/actor/mod";
|
|
5
|
-
import type { RawAccess } from "@/common/database/config";
|
|
2
|
+
import { AgentOs, createInMemoryFileSystem } from "@rivet-dev/agent-os-core";
|
|
3
|
+
import { actor, event, type ActorDefinition } from "@/actor/mod";
|
|
4
|
+
import type { DatabaseProvider, RawAccess } from "@/common/database/config";
|
|
6
5
|
import { db } from "@/common/database/mod";
|
|
7
6
|
import {
|
|
8
7
|
type AgentOsActorConfig,
|
|
@@ -141,10 +140,41 @@ function runHook<TConnParams>(
|
|
|
141
140
|
|
|
142
141
|
export function agentOs<TConnParams = undefined>(
|
|
143
142
|
config: AgentOsActorConfigInput<TConnParams>,
|
|
144
|
-
)
|
|
143
|
+
): ActorDefinition<
|
|
144
|
+
AgentOsActorState,
|
|
145
|
+
TConnParams,
|
|
146
|
+
undefined,
|
|
147
|
+
AgentOsActorVars,
|
|
148
|
+
undefined,
|
|
149
|
+
DatabaseProvider<RawAccess>,
|
|
150
|
+
{
|
|
151
|
+
sessionEvent: typeof sessionEventToken;
|
|
152
|
+
permissionRequest: typeof permissionRequestToken;
|
|
153
|
+
vmBooted: typeof vmBootedToken;
|
|
154
|
+
vmShutdown: typeof vmShutdownToken;
|
|
155
|
+
processOutput: typeof processOutputToken;
|
|
156
|
+
processExit: typeof processExitToken;
|
|
157
|
+
shellData: typeof shellDataToken;
|
|
158
|
+
cronEvent: typeof cronEventToken;
|
|
159
|
+
},
|
|
160
|
+
Record<never, never>,
|
|
161
|
+
any
|
|
162
|
+
> {
|
|
145
163
|
const parsedConfig = agentOsActorConfigSchema.parse(
|
|
146
164
|
config,
|
|
147
165
|
) as AgentOsActorConfig<TConnParams>;
|
|
166
|
+
const actions = {
|
|
167
|
+
...buildSessionActions(parsedConfig),
|
|
168
|
+
...buildPromptActions(parsedConfig),
|
|
169
|
+
...buildConfigActions(parsedConfig),
|
|
170
|
+
...buildSessionPersistenceActions(parsedConfig),
|
|
171
|
+
...buildProcessActions(parsedConfig),
|
|
172
|
+
...buildFilesystemActions(parsedConfig),
|
|
173
|
+
...buildPreviewActions(parsedConfig),
|
|
174
|
+
...buildShellActions(parsedConfig),
|
|
175
|
+
...buildCronActions(parsedConfig),
|
|
176
|
+
...buildNetworkActions(parsedConfig),
|
|
177
|
+
};
|
|
148
178
|
|
|
149
179
|
return actor<
|
|
150
180
|
AgentOsActorState,
|
|
@@ -163,7 +193,8 @@ export function agentOs<TConnParams = undefined>(
|
|
|
163
193
|
shellData: typeof shellDataToken;
|
|
164
194
|
cronEvent: typeof cronEventToken;
|
|
165
195
|
},
|
|
166
|
-
Record<never, never
|
|
196
|
+
Record<never, never>,
|
|
197
|
+
typeof actions
|
|
167
198
|
>({
|
|
168
199
|
options: {
|
|
169
200
|
sleepGracePeriod: 900_000,
|
|
@@ -236,18 +267,7 @@ export function agentOs<TConnParams = undefined>(
|
|
|
236
267
|
|
|
237
268
|
c.broadcast("vmShutdown", { reason: "destroy" as const });
|
|
238
269
|
},
|
|
239
|
-
actions
|
|
240
|
-
...buildSessionActions(parsedConfig),
|
|
241
|
-
...buildPromptActions(parsedConfig),
|
|
242
|
-
...buildConfigActions(parsedConfig),
|
|
243
|
-
...buildSessionPersistenceActions(parsedConfig),
|
|
244
|
-
...buildProcessActions(parsedConfig),
|
|
245
|
-
...buildFilesystemActions(parsedConfig),
|
|
246
|
-
...buildPreviewActions(parsedConfig),
|
|
247
|
-
...buildShellActions(parsedConfig),
|
|
248
|
-
...buildCronActions(parsedConfig),
|
|
249
|
-
...buildNetworkActions(parsedConfig),
|
|
250
|
-
},
|
|
270
|
+
actions,
|
|
251
271
|
});
|
|
252
272
|
}
|
|
253
273
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import crypto from "node:crypto";
|
|
2
|
-
import type { DatabaseProvider } from "@/common/database/config";
|
|
3
2
|
import type { RequestContext } from "@/actor/config";
|
|
4
|
-
import type { RawAccess } from "@/common/database/config";
|
|
3
|
+
import type { DatabaseProvider, RawAccess } from "@/common/database/config";
|
|
5
4
|
import type { AgentOsActorConfig } from "../config";
|
|
6
5
|
import type {
|
|
7
6
|
AgentOsActionContext,
|
|
@@ -140,11 +140,11 @@ export function subscribeToSession<TConnParams>(
|
|
|
140
140
|
);
|
|
141
141
|
|
|
142
142
|
// Persist event to SQLite for sleep/wake recovery.
|
|
143
|
-
persistSessionEvent(c, sessionId, event).catch((
|
|
143
|
+
persistSessionEvent(c, sessionId, event).catch((error) =>
|
|
144
144
|
c.log.error({
|
|
145
145
|
msg: "agent-os failed to persist session event",
|
|
146
146
|
sessionId,
|
|
147
|
-
error
|
|
147
|
+
error,
|
|
148
148
|
}),
|
|
149
149
|
);
|
|
150
150
|
|
package/src/agent-os/config.ts
CHANGED
|
@@ -3,8 +3,8 @@ import type {
|
|
|
3
3
|
JsonRpcNotification,
|
|
4
4
|
PermissionRequest,
|
|
5
5
|
} from "@rivet-dev/agent-os-core";
|
|
6
|
-
import type { ActorContext, BeforeConnectContext } from "@/actor/config";
|
|
7
6
|
import { z } from "zod/v4";
|
|
7
|
+
import type { ActorContext, BeforeConnectContext } from "@/actor/config";
|
|
8
8
|
import type { AgentOsActorState, AgentOsActorVars } from "./types";
|
|
9
9
|
|
|
10
10
|
const zFunction = <
|
package/src/agent-os/index.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
// Database migration
|
|
2
|
+
|
|
3
|
+
// Cron actions
|
|
4
|
+
export { buildCronActions } from "./actor/cron";
|
|
2
5
|
export { migrateAgentOsTables } from "./actor/db";
|
|
3
|
-
// Database-backed VFS
|
|
4
|
-
export {
|
|
5
|
-
createDatabaseVfs,
|
|
6
|
-
type DatabaseVfsOptions,
|
|
7
|
-
} from "./fs/database-vfs";
|
|
8
6
|
// Filesystem actions
|
|
9
7
|
export { buildFilesystemActions } from "./actor/filesystem";
|
|
10
8
|
// Actor factory and VM lifecycle helpers
|
|
11
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";
|
|
12
16
|
// Preview actions
|
|
13
17
|
export {
|
|
14
18
|
buildOnRequestHandler,
|
|
@@ -27,20 +31,17 @@ export {
|
|
|
27
31
|
} from "./actor/session";
|
|
28
32
|
// Shell actions
|
|
29
33
|
export { buildShellActions } from "./actor/shell";
|
|
30
|
-
// Cron actions
|
|
31
|
-
export { buildCronActions } from "./actor/cron";
|
|
32
|
-
// Network actions
|
|
33
|
-
export {
|
|
34
|
-
buildNetworkActions,
|
|
35
|
-
type VmFetchOptions,
|
|
36
|
-
type VmFetchResult,
|
|
37
|
-
} from "./actor/network";
|
|
38
34
|
// Config schema and types
|
|
39
35
|
export {
|
|
40
36
|
type AgentOsActorConfig,
|
|
41
37
|
type AgentOsActorConfigInput,
|
|
42
38
|
agentOsActorConfigSchema,
|
|
43
39
|
} from "./config";
|
|
40
|
+
// Database-backed VFS
|
|
41
|
+
export {
|
|
42
|
+
createDatabaseVfs,
|
|
43
|
+
type DatabaseVfsOptions,
|
|
44
|
+
} from "./fs/database-vfs";
|
|
44
45
|
// Domain types and event payloads
|
|
45
46
|
export type {
|
|
46
47
|
AgentOsActionContext,
|
|
@@ -48,12 +49,12 @@ export type {
|
|
|
48
49
|
AgentOsActorVars,
|
|
49
50
|
AgentOsEvents,
|
|
50
51
|
CronEventPayload,
|
|
52
|
+
PermissionRequestPayload,
|
|
51
53
|
PersistedSessionEvent,
|
|
52
54
|
PersistedSessionRecord,
|
|
53
|
-
PermissionRequestPayload,
|
|
54
|
-
PromptResult,
|
|
55
55
|
ProcessExitPayload,
|
|
56
56
|
ProcessOutputPayload,
|
|
57
|
+
PromptResult,
|
|
57
58
|
SerializableCronAction,
|
|
58
59
|
SerializableCronJobOptions,
|
|
59
60
|
SessionEventPayload,
|