rivetkit 0.0.0-main.72cbc7c → 0.0.0-main.879b6a2
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 +506 -77
- package/dist/browser/client.js +230 -171
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +50 -20
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +2 -2
- package/dist/tsup/actor/errors.d.cts +1 -1
- package/dist/tsup/actor/errors.d.ts +1 -1
- package/dist/tsup/actor/errors.js +1 -1
- package/dist/tsup/agent-os/index.cjs +2163 -2087
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +504 -76
- package/dist/tsup/agent-os/index.d.ts +504 -76
- package/dist/tsup/agent-os/index.js +2163 -2087
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-HSTK7OBI.js → chunk-2SROCV3H.js} +4 -4
- package/dist/tsup/chunk-2SROCV3H.js.map +1 -0
- package/dist/tsup/{chunk-EI55QOUB.js → chunk-3BJAEEQ2.js} +69 -79
- package/dist/tsup/chunk-3BJAEEQ2.js.map +1 -0
- package/dist/tsup/{chunk-YQQ2ZDKT.cjs → chunk-6CGX44N2.cjs} +225 -235
- package/dist/tsup/chunk-6CGX44N2.cjs.map +1 -0
- package/dist/tsup/{chunk-DFHHCPH7.js → chunk-6LUE5746.js} +22 -7
- package/dist/tsup/chunk-6LUE5746.js.map +1 -0
- package/dist/tsup/{chunk-LI5MR5BD.js → chunk-7FICVO7D.js} +134 -20
- package/dist/tsup/chunk-7FICVO7D.js.map +1 -0
- package/dist/tsup/{chunk-4KSYSQHX.js → chunk-AOKMZWB4.js} +2 -2
- package/dist/tsup/{chunk-KIWH5H3K.js → chunk-BRP62GZC.js} +3 -3
- package/dist/tsup/chunk-BRP62GZC.js.map +1 -0
- package/dist/tsup/{chunk-OFP533QU.cjs → chunk-DBO3JXK2.cjs} +3 -3
- package/dist/tsup/{chunk-OFP533QU.cjs.map → chunk-DBO3JXK2.cjs.map} +1 -1
- package/dist/tsup/{chunk-T6YVRM4K.js → chunk-DPIMKYNB.js} +63 -2
- package/dist/tsup/chunk-DPIMKYNB.js.map +1 -0
- package/dist/tsup/{chunk-5DGOZZKE.cjs → chunk-E7HPUUKW.cjs} +24 -9
- package/dist/tsup/chunk-E7HPUUKW.cjs.map +1 -0
- package/dist/tsup/{chunk-OQSBGFIB.cjs → chunk-FZYM7UPI.cjs} +10 -10
- package/dist/tsup/chunk-FZYM7UPI.cjs.map +1 -0
- package/dist/tsup/{chunk-PJSE5ZGN.js → chunk-G2G2MQ5N.js} +6 -6
- package/dist/tsup/chunk-G2G2MQ5N.js.map +1 -0
- package/dist/tsup/{chunk-3YY5S6TV.js → chunk-HXUEHHJF.js} +2 -2
- package/dist/tsup/chunk-HXUEHHJF.js.map +1 -0
- package/dist/tsup/{chunk-O25KOT5C.cjs → chunk-IHP6HIZ2.cjs} +44 -15
- package/dist/tsup/chunk-IHP6HIZ2.cjs.map +1 -0
- package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JZ7TWV65.js} +1 -1
- package/dist/tsup/chunk-JZ7TWV65.js.map +1 -0
- package/dist/tsup/{chunk-QAZLM4WT.cjs → chunk-KORQB2IR.cjs} +3 -3
- package/dist/tsup/{chunk-QAZLM4WT.cjs.map → chunk-KORQB2IR.cjs.map} +1 -1
- package/dist/tsup/{chunk-NDY6IZJ3.cjs → chunk-MTPOTFTS.cjs} +138 -24
- package/dist/tsup/chunk-MTPOTFTS.cjs.map +1 -0
- package/dist/tsup/{chunk-WQ4HNA4W.cjs → chunk-NIY3RSPX.cjs} +64 -3
- package/dist/tsup/chunk-NIY3RSPX.cjs.map +1 -0
- package/dist/tsup/{chunk-WDO5Y6PO.cjs → chunk-PY2ZFXQY.cjs} +10 -10
- package/dist/tsup/chunk-PY2ZFXQY.cjs.map +1 -0
- package/dist/tsup/{chunk-GDKM56PU.js → chunk-SW7LPS7C.js} +36 -7
- package/dist/tsup/chunk-SW7LPS7C.js.map +1 -0
- package/dist/tsup/{chunk-LD5YASJU.cjs → chunk-VE2X4KMG.cjs} +2 -2
- package/dist/tsup/{chunk-LD5YASJU.cjs.map → chunk-VE2X4KMG.cjs.map} +1 -1
- package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-ZA7FLHKH.cjs} +1 -1
- package/dist/tsup/chunk-ZA7FLHKH.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +9 -9
- package/dist/tsup/client/mod.d.cts +5 -5
- package/dist/tsup/client/mod.d.ts +5 -5
- package/dist/tsup/client/mod.js +8 -8
- package/dist/tsup/common/log.cjs +3 -3
- package/dist/tsup/common/log.js +2 -2
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-CRwCN3Ok.d.ts → config-BxWAw3iH.d.ts} +537 -30
- package/dist/tsup/{config-voObiSep.d.cts → config-CZQQ-mso.d.cts} +537 -30
- package/dist/tsup/{config-CxjGYf4K.d.ts → config-D49x8NpL.d.cts} +1 -2
- package/dist/tsup/{config-CxjGYf4K.d.cts → config-D49x8NpL.d.ts} +1 -2
- package/dist/tsup/{context-BPFYVZ5g.d.ts → context-Bw7xq8w3.d.cts} +8 -8
- package/dist/tsup/{context-D0YF1MQq.d.cts → context-D8QA76sV.d.ts} +8 -8
- package/dist/tsup/db/drizzle.cjs +3 -3
- package/dist/tsup/db/drizzle.d.cts +1 -1
- package/dist/tsup/db/drizzle.d.ts +1 -1
- package/dist/tsup/db/drizzle.js +1 -1
- package/dist/tsup/db/mod.cjs +2 -2
- package/dist/tsup/db/mod.d.cts +2 -2
- package/dist/tsup/db/mod.d.ts +2 -2
- package/dist/tsup/db/mod.js +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 +6 -6
- package/dist/tsup/inspector/mod.js +5 -5
- package/dist/tsup/inspector-tab/mod.cjs +173 -0
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
- package/dist/tsup/inspector-tab/mod.d.cts +250 -0
- package/dist/tsup/inspector-tab/mod.d.ts +250 -0
- package/dist/tsup/inspector-tab/mod.js +173 -0
- package/dist/tsup/inspector-tab/mod.js.map +1 -0
- package/dist/tsup/mod.cjs +926 -365
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +5 -5
- package/dist/tsup/mod.d.ts +5 -5
- package/dist/tsup/mod.js +831 -270
- 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 -4
- package/dist/tsup/test/mod.d.ts +4 -4
- package/dist/tsup/test/mod.js +18 -15
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/{utils-DVekpm4I.d.cts → utils-DQosb24I.d.cts} +1 -1
- package/dist/tsup/{utils-DVekpm4I.d.ts → utils-DQosb24I.d.ts} +1 -1
- package/dist/tsup/utils.cjs +3 -3
- package/dist/tsup/utils.d.cts +1 -1
- package/dist/tsup/utils.d.ts +1 -1
- package/dist/tsup/utils.js +2 -2
- package/dist/tsup/workflow/mod.cjs +307 -282
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +6 -6
- package/dist/tsup/workflow/mod.d.ts +6 -6
- package/dist/tsup/workflow/mod.js +501 -476
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +32 -11
- package/src/actor/config.ts +159 -51
- 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 +9 -3
- package/src/actor/instance/mod.ts +26 -34
- package/src/actor/keys.ts +1 -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 +87 -54
- package/src/client/actor-conn.ts +11 -36
- package/src/client/actor-handle.ts +69 -51
- package/src/client/actor-query.ts +5 -5
- package/src/client/errors.ts +1 -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 +8 -6
- package/src/client/resolve-gateway-target.ts +1 -1
- package/src/client/utils.ts +2 -7
- 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/transport/v1.ts +659 -543
- package/src/common/client-protocol-versioned.ts +66 -64
- package/src/common/database/config.ts +2 -8
- package/src/common/database/native-database.ts +1 -1
- 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 +1 -0
- package/src/common/router.ts +13 -17
- package/src/common/utils.ts +1 -150
- package/src/common/websocket-interface.ts +1 -1
- 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 +74 -61
- 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 +3 -3
- package/src/engine-client/actor-websocket-client.ts +6 -5
- package/src/engine-client/api-endpoints.ts +51 -2
- package/src/engine-client/api-utils.ts +2 -2
- package/src/engine-client/driver.ts +1 -1
- package/src/engine-client/mod.ts +6 -3
- package/src/engine-client/ws-proxy.ts +9 -4
- package/src/inspector/client.browser.ts +5 -11
- package/src/inspector/mod.ts +1 -3
- package/src/inspector-tab/mod.ts +315 -0
- package/src/registry/config/envoy.ts +1 -2
- package/src/registry/config/index.ts +42 -20
- package/src/registry/index.ts +305 -88
- package/src/registry/napi-runtime.ts +50 -7
- package/src/registry/native-validation.ts +10 -12
- package/src/registry/native.ts +425 -193
- package/src/registry/process-metrics.ts +250 -0
- package/src/registry/runtime.ts +56 -6
- package/src/registry/wasm-runtime.ts +30 -3
- package/src/registry/write-through-proxy.ts +40 -0
- package/src/serde.ts +2 -2
- package/src/serverless/configure.ts +18 -7
- package/src/test/mod.ts +11 -8
- package/src/utils/endpoint-parser.ts +1 -1
- package/src/utils/env-vars.ts +6 -0
- package/src/utils/router.ts +1 -1
- package/src/utils/serve.ts +4 -5
- package/src/utils.ts +1 -2
- package/src/workflow/context.ts +61 -33
- package/src/workflow/driver.ts +4 -6
- package/src/workflow/inspector.ts +4 -3
- package/src/workflow/mod.ts +15 -17
- package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
- package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
- package/dist/tsup/chunk-5DGOZZKE.cjs.map +0 -1
- package/dist/tsup/chunk-DFHHCPH7.js.map +0 -1
- package/dist/tsup/chunk-EI55QOUB.js.map +0 -1
- package/dist/tsup/chunk-GDKM56PU.js.map +0 -1
- package/dist/tsup/chunk-HSTK7OBI.js.map +0 -1
- package/dist/tsup/chunk-KIWH5H3K.js.map +0 -1
- package/dist/tsup/chunk-LI5MR5BD.js.map +0 -1
- package/dist/tsup/chunk-NDY6IZJ3.cjs.map +0 -1
- package/dist/tsup/chunk-O25KOT5C.cjs.map +0 -1
- package/dist/tsup/chunk-OQSBGFIB.cjs.map +0 -1
- package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
- package/dist/tsup/chunk-PJSE5ZGN.js.map +0 -1
- package/dist/tsup/chunk-T6YVRM4K.js.map +0 -1
- package/dist/tsup/chunk-WDO5Y6PO.cjs.map +0 -1
- package/dist/tsup/chunk-WQ4HNA4W.cjs.map +0 -1
- package/dist/tsup/chunk-YQQ2ZDKT.cjs.map +0 -1
- /package/dist/tsup/{chunk-4KSYSQHX.js.map → chunk-AOKMZWB4.js.map} +0 -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,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
BaseActorDefinition,
|
|
3
2
|
AnyActorDefinition,
|
|
3
|
+
BaseActorDefinition,
|
|
4
4
|
} from "@/actor/definition";
|
|
5
5
|
import type {
|
|
6
6
|
EventSchemaConfig,
|
|
@@ -31,6 +31,36 @@ export type ActorActionFunction<
|
|
|
31
31
|
...args: Args extends [unknown, ...infer Rest] ? Rest : Args
|
|
32
32
|
) => Promise<Response>;
|
|
33
33
|
|
|
34
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
35
|
+
|
|
36
|
+
type LooseEventSubscribe = (
|
|
37
|
+
eventName: string,
|
|
38
|
+
callback: (...args: any[]) => void,
|
|
39
|
+
) => () => void;
|
|
40
|
+
|
|
41
|
+
type ActorActionMap<R> = {
|
|
42
|
+
[K in keyof NonNullable<R>]: NonNullable<R>[K] extends (
|
|
43
|
+
...args: infer Args
|
|
44
|
+
) => infer Return
|
|
45
|
+
? ActorActionFunction<Args, Awaited<Return>>
|
|
46
|
+
: never;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
type ActionsOf<AD extends AnyActorDefinition> =
|
|
50
|
+
AD extends BaseActorDefinition<
|
|
51
|
+
any,
|
|
52
|
+
any,
|
|
53
|
+
any,
|
|
54
|
+
any,
|
|
55
|
+
any,
|
|
56
|
+
any,
|
|
57
|
+
any,
|
|
58
|
+
any,
|
|
59
|
+
infer R
|
|
60
|
+
>
|
|
61
|
+
? R
|
|
62
|
+
: never;
|
|
63
|
+
|
|
34
64
|
export interface ActorGatewayOptions {
|
|
35
65
|
skipReadyWait?: boolean;
|
|
36
66
|
}
|
|
@@ -41,7 +71,8 @@ export function resolveActorGatewayOptions(
|
|
|
41
71
|
defaults: ActorGatewayOptions = {},
|
|
42
72
|
overrides?: ActorGatewayOptions,
|
|
43
73
|
): ResolvedActorGatewayOptions {
|
|
44
|
-
const skipReadyWait =
|
|
74
|
+
const skipReadyWait =
|
|
75
|
+
overrides?.skipReadyWait ?? defaults.skipReadyWait ?? false;
|
|
45
76
|
|
|
46
77
|
return {
|
|
47
78
|
skipReadyWait,
|
|
@@ -63,25 +94,9 @@ export type ActorWebSocketOptions = ActorGatewayOptions;
|
|
|
63
94
|
*/
|
|
64
95
|
export type ActorDefinitionActions<AD extends AnyActorDefinition> =
|
|
65
96
|
// biome-ignore lint/suspicious/noExplicitAny: safe to use any here
|
|
66
|
-
AD extends
|
|
67
|
-
any,
|
|
68
|
-
|
|
69
|
-
any,
|
|
70
|
-
any,
|
|
71
|
-
any,
|
|
72
|
-
any,
|
|
73
|
-
any,
|
|
74
|
-
any,
|
|
75
|
-
infer R
|
|
76
|
-
>
|
|
77
|
-
? {
|
|
78
|
-
[K in keyof R]: R[K] extends (
|
|
79
|
-
...args: infer Args
|
|
80
|
-
) => infer Return
|
|
81
|
-
? ActorActionFunction<Args, Return>
|
|
82
|
-
: never;
|
|
83
|
-
}
|
|
84
|
-
: never;
|
|
97
|
+
IsAny<AD> extends true
|
|
98
|
+
? Record<string, ActorActionFunction<any[], any>>
|
|
99
|
+
: ActorActionMap<ActionsOf<AD>>;
|
|
85
100
|
|
|
86
101
|
type ActorQueueSend<TQueues extends QueueSchemaConfig> = {
|
|
87
102
|
<K extends keyof TQueues & string>(
|
|
@@ -119,39 +134,57 @@ type ActorEventSubscribe<TEvents extends EventSchemaConfig> = {
|
|
|
119
134
|
|
|
120
135
|
export type ActorDefinitionQueueSend<AD extends AnyActorDefinition> =
|
|
121
136
|
// biome-ignore lint/suspicious/noExplicitAny: safe to use any here
|
|
122
|
-
AD extends
|
|
123
|
-
any
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
+
IsAny<AD> extends true
|
|
138
|
+
? { send: ActorQueueSend<Record<string, any>> }
|
|
139
|
+
: AD extends { config: { queues?: infer Q } }
|
|
140
|
+
? Q extends QueueSchemaConfig
|
|
141
|
+
? { send: ActorQueueSend<Q> }
|
|
142
|
+
: {}
|
|
143
|
+
: AD extends BaseActorDefinition<
|
|
144
|
+
any,
|
|
145
|
+
any,
|
|
146
|
+
any,
|
|
147
|
+
any,
|
|
148
|
+
any,
|
|
149
|
+
any,
|
|
150
|
+
any,
|
|
151
|
+
infer Q,
|
|
152
|
+
any
|
|
153
|
+
>
|
|
154
|
+
? Q extends QueueSchemaConfig
|
|
155
|
+
? { send: ActorQueueSend<Q> }
|
|
156
|
+
: {}
|
|
157
|
+
: {};
|
|
137
158
|
|
|
138
159
|
export type ActorDefinitionEventSubscriptions<AD extends AnyActorDefinition> =
|
|
139
160
|
// biome-ignore lint/suspicious/noExplicitAny: safe to use any here
|
|
140
|
-
AD extends
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
161
|
+
IsAny<AD> extends true
|
|
162
|
+
? {
|
|
163
|
+
on: LooseEventSubscribe;
|
|
164
|
+
once: LooseEventSubscribe;
|
|
165
|
+
}
|
|
166
|
+
: AD extends { config: { events?: infer E } }
|
|
167
|
+
? E extends EventSchemaConfig
|
|
168
|
+
? {
|
|
169
|
+
on: ActorEventSubscribe<E>;
|
|
170
|
+
once: ActorEventSubscribe<E>;
|
|
171
|
+
}
|
|
172
|
+
: {}
|
|
173
|
+
: AD extends BaseActorDefinition<
|
|
174
|
+
any,
|
|
175
|
+
any,
|
|
176
|
+
any,
|
|
177
|
+
any,
|
|
178
|
+
any,
|
|
179
|
+
any,
|
|
180
|
+
infer E,
|
|
181
|
+
any,
|
|
182
|
+
any
|
|
183
|
+
>
|
|
184
|
+
? E extends EventSchemaConfig
|
|
185
|
+
? {
|
|
186
|
+
on: ActorEventSubscribe<E>;
|
|
187
|
+
once: ActorEventSubscribe<E>;
|
|
188
|
+
}
|
|
189
|
+
: {}
|
|
190
|
+
: {};
|
package/src/client/actor-conn.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
type ToServer as ToServerJson,
|
|
15
15
|
ToServerSchema,
|
|
16
16
|
} from "@/common/client-protocol-zod";
|
|
17
|
+
import type { JsonCompatValue } from "@/common/encoding";
|
|
17
18
|
import {
|
|
18
19
|
type Encoding,
|
|
19
20
|
inputDataToBuffer,
|
|
@@ -93,8 +94,6 @@ interface EventSubscriptions<Args extends Array<unknown>> {
|
|
|
93
94
|
once: boolean;
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
const DEFAULT_MAX_INCOMING_MESSAGE_SIZE = 65_536;
|
|
97
|
-
|
|
98
97
|
/**
|
|
99
98
|
* A function that unsubscribes from an event.
|
|
100
99
|
*
|
|
@@ -216,6 +215,9 @@ export class ActorConnRaw {
|
|
|
216
215
|
this.#encoding = encoding;
|
|
217
216
|
this.#actorResolutionState = actorResolutionState;
|
|
218
217
|
this.#gatewayOptions = resolveActorGatewayOptions(gatewayOptions);
|
|
218
|
+
if ("getForId" in actorResolutionState) {
|
|
219
|
+
this.#actorId = actorResolutionState.getForId.actorId;
|
|
220
|
+
}
|
|
219
221
|
this.#readyPromise = promiseWithResolvers((reason) =>
|
|
220
222
|
logger().warn({
|
|
221
223
|
msg: "unhandled ready promise rejection",
|
|
@@ -782,12 +784,10 @@ export class ActorConnRaw {
|
|
|
782
784
|
}
|
|
783
785
|
|
|
784
786
|
// Check if this is an actor scheduling error and try to get more details
|
|
785
|
-
let errorToThrow = new errors.ActorError(
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
{ metadata, actor },
|
|
790
|
-
);
|
|
787
|
+
let errorToThrow = new errors.ActorError(group, code, message, {
|
|
788
|
+
metadata,
|
|
789
|
+
actor,
|
|
790
|
+
});
|
|
791
791
|
if (errors.isSchedulingError(group, code) && this.#actorId) {
|
|
792
792
|
const schedulingError = await checkForSchedulingError(
|
|
793
793
|
group,
|
|
@@ -1269,7 +1269,8 @@ export class ActorConnRaw {
|
|
|
1269
1269
|
name: msg.body.val.name,
|
|
1270
1270
|
args: bufferToArrayBuffer(
|
|
1271
1271
|
encodeCborCompat(
|
|
1272
|
-
msg.body.val
|
|
1272
|
+
msg.body.val
|
|
1273
|
+
.args as JsonCompatValue,
|
|
1273
1274
|
),
|
|
1274
1275
|
),
|
|
1275
1276
|
},
|
|
@@ -1280,34 +1281,8 @@ export class ActorConnRaw {
|
|
|
1280
1281
|
}
|
|
1281
1282
|
},
|
|
1282
1283
|
);
|
|
1283
|
-
const serializedLength = messageLength(messageSerialized);
|
|
1284
|
-
if (
|
|
1285
|
-
serializedLength > DEFAULT_MAX_INCOMING_MESSAGE_SIZE &&
|
|
1286
|
-
message.body.tag === "ActionRequest"
|
|
1287
|
-
) {
|
|
1288
|
-
const actionId = Number(message.body.val.id);
|
|
1289
|
-
const inFlight = this.#takeActionInFlight(actionId);
|
|
1290
|
-
const error = new errors.ActorError(
|
|
1291
|
-
"message",
|
|
1292
|
-
"incoming_too_long",
|
|
1293
|
-
"Incoming message too long",
|
|
1294
|
-
{
|
|
1295
|
-
maxSize: DEFAULT_MAX_INCOMING_MESSAGE_SIZE,
|
|
1296
|
-
actualSize: serializedLength,
|
|
1297
|
-
},
|
|
1298
|
-
);
|
|
1299
|
-
logger().warn({
|
|
1300
|
-
msg: "rejecting oversized connection action request",
|
|
1301
|
-
actionId,
|
|
1302
|
-
actionName: inFlight.name,
|
|
1303
|
-
actualSize: serializedLength,
|
|
1304
|
-
maxSize: DEFAULT_MAX_INCOMING_MESSAGE_SIZE,
|
|
1305
|
-
});
|
|
1306
|
-
inFlight.reject(error);
|
|
1307
|
-
this.#dispatchActorError(error);
|
|
1308
|
-
return;
|
|
1309
|
-
}
|
|
1310
1284
|
this.#websocket.send(messageSerialized);
|
|
1285
|
+
const serializedLength = messageLength(messageSerialized);
|
|
1311
1286
|
logger().trace({
|
|
1312
1287
|
msg: "sent websocket message",
|
|
1313
1288
|
len: serializedLength,
|