@rivet-dev/agentos-core 0.0.0-main.2f99c77 → 0.0.0-main.5ac5a14
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/README.md +10 -196
- package/dist/agent-os.d.ts +508 -271
- package/dist/agent-os.js +2277 -1243
- package/dist/agentos-package.d.ts +6 -4
- package/dist/agentos-package.js +6 -3
- package/dist/base-filesystem.js +2 -2
- package/dist/{host-tools-zod.d.ts → bindings-zod.d.ts} +1 -1
- package/dist/{host-tools-zod.js → bindings-zod.js} +27 -20
- package/dist/bindings.d.ts +43 -0
- package/dist/bindings.js +34 -0
- package/dist/code-execution.d.ts +70 -0
- package/dist/code-execution.js +115 -0
- package/dist/cron/cron-manager.js +43 -10
- package/dist/cron/index.d.ts +1 -1
- package/dist/cron/types.d.ts +25 -9
- package/dist/filesystem-snapshot.d.ts +1 -2
- package/dist/filesystem-snapshot.js +0 -43
- package/dist/generated/AcpLimitsConfig.d.ts +16 -0
- package/dist/generated/BindingLimitsConfig.d.ts +10 -0
- package/dist/generated/CreateVmConfig.d.ts +2 -0
- package/dist/generated/ProcessLimitsConfig.d.ts +7 -0
- package/dist/generated/ProcessLimitsConfig.js +2 -0
- package/dist/generated/VmGroupConfig.d.ts +5 -0
- package/dist/generated/VmGroupConfig.js +2 -0
- package/dist/generated/VmLimitsConfig.d.ts +4 -2
- package/dist/generated/VmUserAccountConfig.d.ts +9 -0
- package/dist/generated/VmUserAccountConfig.js +2 -0
- package/dist/generated/VmUserConfig.d.ts +19 -0
- package/dist/generated/WasmLimitsConfig.d.ts +1 -0
- package/dist/index.d.ts +7 -5
- package/dist/index.js +5 -5
- package/dist/language-execution.d.ts +170 -0
- package/dist/language-execution.js +1 -0
- package/dist/layers.d.ts +5 -2
- package/dist/layers.js +0 -185
- package/dist/options-schema.d.ts +150 -31
- package/dist/options-schema.js +159 -26
- package/dist/packages.d.ts +1 -1
- package/dist/runtime-compat.d.ts +6 -35
- package/dist/runtime-compat.js +85 -373
- package/dist/runtime.d.ts +5 -1
- package/dist/sandbox.d.ts +4 -4
- package/dist/sandbox.js +34 -21
- package/dist/session-api.d.ts +180 -0
- package/dist/session-api.js +1 -0
- package/dist/sidecar/agentos-protocol.d.ts +434 -32
- package/dist/sidecar/agentos-protocol.js +693 -93
- package/dist/sidecar/rpc-client.d.ts +18 -6
- package/dist/sidecar/rpc-client.js +88 -39
- package/dist/test/runtime.d.ts +2 -1
- package/dist/test/runtime.js +2 -1
- package/dist/test/terminal-harness.js +0 -3
- package/dist/types.d.ts +7 -6
- package/package.json +38 -28
- package/dist/agent-session-types.d.ts +0 -67
- package/dist/generated/ToolLimitsConfig.d.ts +0 -10
- package/dist/host-tools.d.ts +0 -45
- package/dist/host-tools.js +0 -35
- package/dist/overlay-filesystem.d.ts +0 -19
- package/dist/overlay-filesystem.js +0 -645
- /package/dist/generated/{ToolLimitsConfig.js → BindingLimitsConfig.js} +0 -0
- /package/dist/{agent-session-types.js → generated/VmUserConfig.js} +0 -0
|
@@ -40,11 +40,11 @@ interface NativeSidecarKernelProxyOptions {
|
|
|
40
40
|
* `configure_vm` rebuilds the whole VM configuration from each payload, so
|
|
41
41
|
* every runtime mount reconfigure must resend these or a post-boot
|
|
42
42
|
* `mountFs()` silently drops the `/opt/agentos` package projections and
|
|
43
|
-
*
|
|
43
|
+
* binding shim commands applied at boot.
|
|
44
44
|
*/
|
|
45
45
|
packages?: Parameters<SidecarProcess["configureVm"]>[2]["packages"];
|
|
46
46
|
packagesMountAt?: string;
|
|
47
|
-
|
|
47
|
+
bindingShimCommands?: string[];
|
|
48
48
|
commandGuestPaths: ReadonlyMap<string, string>;
|
|
49
49
|
onWasmCommandResolved?: (command: string) => void;
|
|
50
50
|
onDispose?: () => Promise<void>;
|
|
@@ -70,12 +70,13 @@ export declare class NativeSidecarKernelProxy {
|
|
|
70
70
|
private readonly ownsClient;
|
|
71
71
|
private readonly localMounts;
|
|
72
72
|
private readonly baseSidecarMounts;
|
|
73
|
+
private readonly dynamicSidecarMounts;
|
|
73
74
|
private readonly permissions;
|
|
74
75
|
private readonly commandPermissions;
|
|
75
76
|
private readonly loopbackExemptPorts;
|
|
76
77
|
private packages;
|
|
77
78
|
private readonly packagesMountAt;
|
|
78
|
-
private readonly
|
|
79
|
+
private readonly bindingShimCommands;
|
|
79
80
|
private readonly commandDrivers;
|
|
80
81
|
private readonly onWasmCommandResolved;
|
|
81
82
|
private readonly onDispose;
|
|
@@ -161,6 +162,13 @@ export declare class NativeSidecarKernelProxy {
|
|
|
161
162
|
sidecarMount?: SidecarMountDescriptor;
|
|
162
163
|
}): Promise<void>;
|
|
163
164
|
unmountFs(path: string): Promise<void>;
|
|
165
|
+
mountDescriptor(mount: SidecarMountDescriptor): Promise<void>;
|
|
166
|
+
unmountDescriptor(path: string): Promise<void>;
|
|
167
|
+
listMounts(): Promise<Array<{
|
|
168
|
+
path: string;
|
|
169
|
+
kind: string;
|
|
170
|
+
readOnly: boolean;
|
|
171
|
+
}>>;
|
|
164
172
|
private desiredSidecarMounts;
|
|
165
173
|
private reconfigureSidecarMounts;
|
|
166
174
|
private waitForMountReconfigure;
|
|
@@ -175,6 +183,7 @@ export declare class NativeSidecarKernelProxy {
|
|
|
175
183
|
port?: number;
|
|
176
184
|
}): KernelSocketSnapshot | null;
|
|
177
185
|
getSignalState(pid: number): KernelSignalState;
|
|
186
|
+
private scheduleSignalStateRefresh;
|
|
178
187
|
private refreshSocketLookup;
|
|
179
188
|
private refreshSignalState;
|
|
180
189
|
private refreshProcessSnapshot;
|
|
@@ -262,7 +271,7 @@ export interface AgentOsSidecarTransport {
|
|
|
262
271
|
dispose(): Promise<void>;
|
|
263
272
|
}
|
|
264
273
|
export interface AgentOsSidecarClientOptions {
|
|
265
|
-
|
|
274
|
+
createOwnershipTransport(bootstrap: AgentOsSidecarSessionBootstrap): Promise<AgentOsSidecarTransport>;
|
|
266
275
|
createId?: () => string;
|
|
267
276
|
now?: () => number;
|
|
268
277
|
}
|
|
@@ -284,13 +293,14 @@ export declare class AgentOsSidecarSessionHandle {
|
|
|
284
293
|
dispose(): Promise<void>;
|
|
285
294
|
}
|
|
286
295
|
export declare class AgentOsSidecarClient {
|
|
287
|
-
private readonly
|
|
296
|
+
private readonly createOwnershipTransport;
|
|
288
297
|
private readonly createId;
|
|
289
298
|
private readonly now;
|
|
290
299
|
private readonly sessions;
|
|
291
300
|
private disposed;
|
|
292
301
|
constructor(options: AgentOsSidecarClientOptions);
|
|
293
|
-
|
|
302
|
+
/** Open a physical sidecar ownership scope, not a durable ACP session. */
|
|
303
|
+
createOwnershipSession(options?: AgentOsSidecarSessionOptions): Promise<AgentOsSidecarSessionHandle>;
|
|
294
304
|
listSessions(): AgentOsSidecarSessionLifecycle[];
|
|
295
305
|
requireSessionLifecycle(sessionId: string): AgentOsSidecarSessionLifecycle;
|
|
296
306
|
listVms(sessionId: string): AgentOsSidecarVmLifecycle[];
|
|
@@ -315,6 +325,8 @@ export interface SidecarMountPluginDescriptor {
|
|
|
315
325
|
}
|
|
316
326
|
export interface SidecarMountDescriptor {
|
|
317
327
|
guestPath: string;
|
|
328
|
+
guestSource?: string;
|
|
329
|
+
guestFstype?: string;
|
|
318
330
|
readOnly: boolean;
|
|
319
331
|
plugin: SidecarMountPluginDescriptor;
|
|
320
332
|
}
|
|
@@ -20,7 +20,9 @@ function formatStructuredSidecarDetail(detail) {
|
|
|
20
20
|
if (entries.length === 0) {
|
|
21
21
|
return "";
|
|
22
22
|
}
|
|
23
|
-
return entries
|
|
23
|
+
return entries
|
|
24
|
+
.map(([key, value]) => `${key}=${JSON.stringify(value)}`)
|
|
25
|
+
.join(" ");
|
|
24
26
|
}
|
|
25
27
|
function logStructuredSidecarEvent(name, detail) {
|
|
26
28
|
if (!shouldLogStructuredSidecarEvent(name)) {
|
|
@@ -211,6 +213,7 @@ export class NativeSidecarKernelProxy {
|
|
|
211
213
|
ownsClient;
|
|
212
214
|
localMounts;
|
|
213
215
|
baseSidecarMounts;
|
|
216
|
+
dynamicSidecarMounts = [];
|
|
214
217
|
permissions;
|
|
215
218
|
commandPermissions;
|
|
216
219
|
loopbackExemptPorts;
|
|
@@ -218,7 +221,7 @@ export class NativeSidecarKernelProxy {
|
|
|
218
221
|
// later mount reconfigures resend linked packages too, not just boot ones.
|
|
219
222
|
packages;
|
|
220
223
|
packagesMountAt;
|
|
221
|
-
|
|
224
|
+
bindingShimCommands;
|
|
222
225
|
commandDrivers;
|
|
223
226
|
onWasmCommandResolved;
|
|
224
227
|
onDispose;
|
|
@@ -257,7 +260,7 @@ export class NativeSidecarKernelProxy {
|
|
|
257
260
|
this.loopbackExemptPorts = options.loopbackExemptPorts;
|
|
258
261
|
this.packages = options.packages ? [...options.packages] : [];
|
|
259
262
|
this.packagesMountAt = options.packagesMountAt;
|
|
260
|
-
this.
|
|
263
|
+
this.bindingShimCommands = options.bindingShimCommands;
|
|
261
264
|
this.commandDrivers = buildCommandMap(options.commandGuestPaths);
|
|
262
265
|
this.onWasmCommandResolved = options.onWasmCommandResolved;
|
|
263
266
|
this.onDispose = options.onDispose;
|
|
@@ -358,16 +361,16 @@ export class NativeSidecarKernelProxy {
|
|
|
358
361
|
const parsedCommand = parseSimpleExecCommand(command);
|
|
359
362
|
const runAndCapture = async (proc, stdinOverride, readExitCode) => {
|
|
360
363
|
if (stdinOverride !== undefined) {
|
|
361
|
-
proc.writeStdin(stdinOverride);
|
|
364
|
+
await proc.writeStdin(stdinOverride);
|
|
362
365
|
}
|
|
363
366
|
else if (options?.stdin !== undefined) {
|
|
364
|
-
proc.writeStdin(options.stdin);
|
|
367
|
+
await proc.writeStdin(options.stdin);
|
|
365
368
|
}
|
|
366
369
|
// `kernel.exec()` is a non-interactive run-to-completion API: when the
|
|
367
370
|
// caller does not opt into a streaming stdin handle, the guest process
|
|
368
371
|
// should observe EOF after any provided input so commands like
|
|
369
372
|
// `node -e ...` do not linger behind an inherited open stdin pipe.
|
|
370
|
-
proc.closeStdin();
|
|
373
|
+
await proc.closeStdin();
|
|
371
374
|
const waitPromise = proc.wait();
|
|
372
375
|
const shellExitCode = typeof options?.timeout === "number"
|
|
373
376
|
? await new Promise((resolve) => {
|
|
@@ -435,9 +438,9 @@ export class NativeSidecarKernelProxy {
|
|
|
435
438
|
const effectiveCwd = options?.cwd ?? this.defaultExecCwd ?? this.cwd;
|
|
436
439
|
const runAndCapture = async (proc) => {
|
|
437
440
|
if (options?.stdin !== undefined) {
|
|
438
|
-
proc.writeStdin(options.stdin);
|
|
441
|
+
await proc.writeStdin(options.stdin);
|
|
439
442
|
}
|
|
440
|
-
proc.closeStdin();
|
|
443
|
+
await proc.closeStdin();
|
|
441
444
|
const waitPromise = proc.wait();
|
|
442
445
|
const exitCode = typeof options?.timeout === "number"
|
|
443
446
|
? await new Promise((resolve) => {
|
|
@@ -521,9 +524,9 @@ export class NativeSidecarKernelProxy {
|
|
|
521
524
|
rejectWait,
|
|
522
525
|
onStdout: new Set(options?.onStdout ? [options.onStdout] : []),
|
|
523
526
|
onStderr: new Set(options?.onStderr ? [options.onStderr] : []),
|
|
524
|
-
pendingStdin: [],
|
|
527
|
+
pendingStdin: options?.stdin === undefined ? [] : [options.stdin],
|
|
525
528
|
stdinFlushPromise: null,
|
|
526
|
-
pendingCloseStdin:
|
|
529
|
+
pendingCloseStdin: !options?.streamStdin,
|
|
527
530
|
pendingKillSignal: null,
|
|
528
531
|
waitWithFallbackPromise: null,
|
|
529
532
|
hostExitObservedAt: null,
|
|
@@ -583,7 +586,7 @@ export class NativeSidecarKernelProxy {
|
|
|
583
586
|
return proc;
|
|
584
587
|
}
|
|
585
588
|
openShell(options) {
|
|
586
|
-
const
|
|
589
|
+
const terminalHandlers = new Set();
|
|
587
590
|
const stderrHandlers = new Set();
|
|
588
591
|
const command = options?.command ?? "sh";
|
|
589
592
|
const args = options?.args ??
|
|
@@ -638,7 +641,7 @@ export class NativeSidecarKernelProxy {
|
|
|
638
641
|
const normalized = normalizeSyntheticTerminalText(text);
|
|
639
642
|
updateSyntheticCursor(normalized);
|
|
640
643
|
const chunk = textEncoder.encode(normalized);
|
|
641
|
-
for (const handler of
|
|
644
|
+
for (const handler of terminalHandlers) {
|
|
642
645
|
handler(chunk);
|
|
643
646
|
}
|
|
644
647
|
};
|
|
@@ -649,7 +652,7 @@ export class NativeSidecarKernelProxy {
|
|
|
649
652
|
const normalized = normalizeSyntheticTerminalText(text);
|
|
650
653
|
updateSyntheticCursor(normalized);
|
|
651
654
|
const chunk = textEncoder.encode(normalized);
|
|
652
|
-
for (const handler of
|
|
655
|
+
for (const handler of terminalHandlers) {
|
|
653
656
|
handler(chunk);
|
|
654
657
|
}
|
|
655
658
|
};
|
|
@@ -694,7 +697,7 @@ export class NativeSidecarKernelProxy {
|
|
|
694
697
|
commandInFlight = false;
|
|
695
698
|
const promptPrefix = syntheticCursorAtLineStart ? "" : "\r\n";
|
|
696
699
|
const promptChunk = textEncoder.encode(`${promptPrefix}${promptText}`);
|
|
697
|
-
for (const handler of
|
|
700
|
+
for (const handler of terminalHandlers) {
|
|
698
701
|
handler(promptChunk);
|
|
699
702
|
}
|
|
700
703
|
syntheticCursorAtLineStart = false;
|
|
@@ -752,7 +755,7 @@ export class NativeSidecarKernelProxy {
|
|
|
752
755
|
}
|
|
753
756
|
};
|
|
754
757
|
let onData = null;
|
|
755
|
-
|
|
758
|
+
terminalHandlers.add((data) => onData?.(data));
|
|
756
759
|
if (options?.onStderr) {
|
|
757
760
|
stderrHandlers.add(options.onStderr);
|
|
758
761
|
}
|
|
@@ -921,7 +924,7 @@ export class NativeSidecarKernelProxy {
|
|
|
921
924
|
if (!sanitized) {
|
|
922
925
|
return;
|
|
923
926
|
}
|
|
924
|
-
for (const handler of
|
|
927
|
+
for (const handler of terminalHandlers) {
|
|
925
928
|
handler(sanitized);
|
|
926
929
|
}
|
|
927
930
|
if (commandInFlight) {
|
|
@@ -933,6 +936,11 @@ export class NativeSidecarKernelProxy {
|
|
|
933
936
|
if (!sanitized) {
|
|
934
937
|
return;
|
|
935
938
|
}
|
|
939
|
+
// `onData` is the ordered PTY rendering stream. `onStderr` remains an
|
|
940
|
+
// optional channel-specific diagnostic tap and must not also be rendered.
|
|
941
|
+
for (const handler of terminalHandlers) {
|
|
942
|
+
handler(sanitized);
|
|
943
|
+
}
|
|
936
944
|
for (const handler of stderrHandlers) {
|
|
937
945
|
handler(sanitized);
|
|
938
946
|
}
|
|
@@ -986,20 +994,16 @@ export class NativeSidecarKernelProxy {
|
|
|
986
994
|
const stdin = process.stdin;
|
|
987
995
|
const stdout = process.stdout;
|
|
988
996
|
const { onData, ...shellOptions } = options ?? {};
|
|
989
|
-
const shell = this.openShell(
|
|
990
|
-
...shellOptions,
|
|
991
|
-
onStderr: shellOptions.onStderr ??
|
|
992
|
-
((data) => {
|
|
993
|
-
process.stderr.write(data);
|
|
994
|
-
}),
|
|
995
|
-
});
|
|
997
|
+
const shell = this.openShell(shellOptions);
|
|
996
998
|
const outputHandler = onData ??
|
|
997
999
|
((data) => {
|
|
998
1000
|
stdout.write(data);
|
|
999
1001
|
});
|
|
1000
1002
|
const restoreRawMode = stdin.isTTY && typeof stdin.setRawMode === "function";
|
|
1001
1003
|
const onStdinData = (data) => {
|
|
1002
|
-
shell.write(data)
|
|
1004
|
+
void shell.write(data).catch((error) => {
|
|
1005
|
+
console.error("[agentos] failed to forward terminal stdin:", error);
|
|
1006
|
+
});
|
|
1003
1007
|
};
|
|
1004
1008
|
const onResize = () => {
|
|
1005
1009
|
shell.resize(stdout.columns, stdout.rows);
|
|
@@ -1164,9 +1168,34 @@ export class NativeSidecarKernelProxy {
|
|
|
1164
1168
|
applied.catch(() => { });
|
|
1165
1169
|
return applied;
|
|
1166
1170
|
}
|
|
1171
|
+
mountDescriptor(mount) {
|
|
1172
|
+
const normalized = posixPath.normalize(mount.guestPath);
|
|
1173
|
+
if (this.desiredSidecarMounts().some((existing) => posixPath.normalize(existing.guestPath) === normalized)) {
|
|
1174
|
+
return Promise.reject(new Error(`mount already exists: ${normalized}`));
|
|
1175
|
+
}
|
|
1176
|
+
this.dynamicSidecarMounts.push({ ...mount, guestPath: normalized });
|
|
1177
|
+
const applied = this.reconfigureSidecarMounts();
|
|
1178
|
+
applied.catch(() => { });
|
|
1179
|
+
return applied;
|
|
1180
|
+
}
|
|
1181
|
+
unmountDescriptor(path) {
|
|
1182
|
+
const normalized = posixPath.normalize(path);
|
|
1183
|
+
const index = this.dynamicSidecarMounts.findIndex((mount) => posixPath.normalize(mount.guestPath) === normalized);
|
|
1184
|
+
if (index < 0)
|
|
1185
|
+
return Promise.resolve();
|
|
1186
|
+
this.dynamicSidecarMounts.splice(index, 1);
|
|
1187
|
+
const applied = this.reconfigureSidecarMounts();
|
|
1188
|
+
applied.catch(() => { });
|
|
1189
|
+
return applied;
|
|
1190
|
+
}
|
|
1191
|
+
async listMounts() {
|
|
1192
|
+
await this.waitForMountReconfigure();
|
|
1193
|
+
return this.client.listMounts(this.session, this.vm);
|
|
1194
|
+
}
|
|
1167
1195
|
desiredSidecarMounts() {
|
|
1168
1196
|
return [
|
|
1169
1197
|
...this.baseSidecarMounts,
|
|
1198
|
+
...this.dynamicSidecarMounts,
|
|
1170
1199
|
...this.localMounts.map((mount) => mount.sidecarMount ?? {
|
|
1171
1200
|
guestPath: mount.path,
|
|
1172
1201
|
readOnly: mount.readOnly,
|
|
@@ -1183,8 +1212,8 @@ export class NativeSidecarKernelProxy {
|
|
|
1183
1212
|
return;
|
|
1184
1213
|
}
|
|
1185
1214
|
// Rust `configure_vm` rebuilds the whole VM configuration from this
|
|
1186
|
-
// payload, so resend the boot packages /
|
|
1187
|
-
// omitting them here strips the `/opt/agentos` projections and
|
|
1215
|
+
// payload, so resend the boot packages / binding shim commands too —
|
|
1216
|
+
// omitting them here strips the `/opt/agentos` projections and binding
|
|
1188
1217
|
// shims from the VM as a side effect of a runtime mount change.
|
|
1189
1218
|
await this.client.configureVm(this.session, this.vm, {
|
|
1190
1219
|
mounts: this.desiredSidecarMounts(),
|
|
@@ -1193,7 +1222,7 @@ export class NativeSidecarKernelProxy {
|
|
|
1193
1222
|
loopbackExemptPorts: this.loopbackExemptPorts,
|
|
1194
1223
|
packages: this.packages,
|
|
1195
1224
|
packagesMountAt: this.packagesMountAt,
|
|
1196
|
-
|
|
1225
|
+
bindingShimCommands: this.bindingShimCommands,
|
|
1197
1226
|
});
|
|
1198
1227
|
};
|
|
1199
1228
|
const previous = this.mountReconfigurePromise ?? Promise.resolve();
|
|
@@ -1238,11 +1267,17 @@ export class NativeSidecarKernelProxy {
|
|
|
1238
1267
|
}
|
|
1239
1268
|
getSignalState(pid) {
|
|
1240
1269
|
const entry = this.trackedProcesses.get(pid);
|
|
1241
|
-
if (entry
|
|
1242
|
-
this.
|
|
1243
|
-
}
|
|
1270
|
+
if (entry)
|
|
1271
|
+
this.scheduleSignalStateRefresh(entry);
|
|
1244
1272
|
return this.signalStates.get(pid) ?? { handlers: new Map() };
|
|
1245
1273
|
}
|
|
1274
|
+
scheduleSignalStateRefresh(entry) {
|
|
1275
|
+
if (this.signalRefreshes.has(entry.pid))
|
|
1276
|
+
return;
|
|
1277
|
+
const refresh = this.refreshSignalState(entry);
|
|
1278
|
+
this.signalRefreshes.set(entry.pid, refresh);
|
|
1279
|
+
void refresh.catch(() => { });
|
|
1280
|
+
}
|
|
1246
1281
|
async refreshSocketLookup(cache, key, lookup) {
|
|
1247
1282
|
try {
|
|
1248
1283
|
const socket = await lookup();
|
|
@@ -1334,7 +1369,11 @@ export class NativeSidecarKernelProxy {
|
|
|
1334
1369
|
entry.started = true;
|
|
1335
1370
|
this.updateTrackedProcessSnapshot(entry);
|
|
1336
1371
|
void this.refreshProcessSnapshot().catch(() => { });
|
|
1337
|
-
|
|
1372
|
+
// Signal metadata is advisory and must not hold process startup behind a
|
|
1373
|
+
// second sidecar RPC. Very short binding commands can finish while the
|
|
1374
|
+
// original execute response is still in flight; synchronously refreshing
|
|
1375
|
+
// here creates a circular wait with their output/exit delivery.
|
|
1376
|
+
this.scheduleSignalStateRefresh(entry);
|
|
1338
1377
|
void this.flushPendingStdin(entry).catch((error) => {
|
|
1339
1378
|
this.handleBackgroundProcessError(entry, error);
|
|
1340
1379
|
});
|
|
@@ -1362,10 +1401,7 @@ export class NativeSidecarKernelProxy {
|
|
|
1362
1401
|
}
|
|
1363
1402
|
entry.outputGeneration += 1;
|
|
1364
1403
|
void this.refreshProcessSnapshot().catch(() => { });
|
|
1365
|
-
|
|
1366
|
-
this.signalRefreshes.set(entry.pid, this.refreshSignalState(entry));
|
|
1367
|
-
await this.signalRefreshes.get(entry.pid);
|
|
1368
|
-
}
|
|
1404
|
+
this.scheduleSignalStateRefresh(entry);
|
|
1369
1405
|
const chunk = event.payload.chunk;
|
|
1370
1406
|
const listeners = event.payload.channel === "stdout"
|
|
1371
1407
|
? entry.onStdout
|
|
@@ -2083,17 +2119,18 @@ export class AgentOsSidecarSessionHandle {
|
|
|
2083
2119
|
}
|
|
2084
2120
|
}
|
|
2085
2121
|
export class AgentOsSidecarClient {
|
|
2086
|
-
|
|
2122
|
+
createOwnershipTransport;
|
|
2087
2123
|
createId;
|
|
2088
2124
|
now;
|
|
2089
2125
|
sessions = new Map();
|
|
2090
2126
|
disposed = false;
|
|
2091
2127
|
constructor(options) {
|
|
2092
|
-
this.
|
|
2128
|
+
this.createOwnershipTransport = options.createOwnershipTransport;
|
|
2093
2129
|
this.createId = options.createId ?? randomUUID;
|
|
2094
2130
|
this.now = options.now ?? Date.now;
|
|
2095
2131
|
}
|
|
2096
|
-
|
|
2132
|
+
/** Open a physical sidecar ownership scope, not a durable ACP session. */
|
|
2133
|
+
async createOwnershipSession(options = {}) {
|
|
2097
2134
|
this.assertActive();
|
|
2098
2135
|
const sessionId = this.createId();
|
|
2099
2136
|
const placement = clonePlacement(options.placement);
|
|
@@ -2112,7 +2149,7 @@ export class AgentOsSidecarClient {
|
|
|
2112
2149
|
};
|
|
2113
2150
|
this.sessions.set(sessionId, entry);
|
|
2114
2151
|
try {
|
|
2115
|
-
entry.transport = await this.
|
|
2152
|
+
entry.transport = await this.createOwnershipTransport({
|
|
2116
2153
|
sessionId,
|
|
2117
2154
|
placement: clonePlacement(placement),
|
|
2118
2155
|
metadata: cloneMetadata(metadata),
|
|
@@ -2278,6 +2315,8 @@ export function serializeMountConfigForSidecar(mount) {
|
|
|
2278
2315
|
if ("driver" in mount) {
|
|
2279
2316
|
return {
|
|
2280
2317
|
guestPath: mount.path,
|
|
2318
|
+
guestSource: mount.guestSource ?? "js_bridge",
|
|
2319
|
+
guestFstype: mount.guestFstype ?? "js_bridge",
|
|
2281
2320
|
readOnly: mount.readOnly ?? false,
|
|
2282
2321
|
plugin: {
|
|
2283
2322
|
id: "js_bridge",
|
|
@@ -2287,6 +2326,8 @@ export function serializeMountConfigForSidecar(mount) {
|
|
|
2287
2326
|
}
|
|
2288
2327
|
return {
|
|
2289
2328
|
guestPath: mount.path,
|
|
2329
|
+
guestSource: mount.guestSource ?? mount.plugin.id,
|
|
2330
|
+
guestFstype: mount.guestFstype ?? mount.plugin.id,
|
|
2290
2331
|
readOnly: mount.readOnly ?? false,
|
|
2291
2332
|
plugin: {
|
|
2292
2333
|
id: mount.plugin.id,
|
|
@@ -2295,6 +2336,14 @@ export function serializeMountConfigForSidecar(mount) {
|
|
|
2295
2336
|
};
|
|
2296
2337
|
}
|
|
2297
2338
|
export function serializeRootFilesystemForSidecar(config, bootstrapLower) {
|
|
2339
|
+
if (config?.type === "native") {
|
|
2340
|
+
return {
|
|
2341
|
+
mode: "ephemeral",
|
|
2342
|
+
disableDefaultBaseLayer: true,
|
|
2343
|
+
lowers: [],
|
|
2344
|
+
bootstrapEntries: [],
|
|
2345
|
+
};
|
|
2346
|
+
}
|
|
2298
2347
|
const lowerInputs = [
|
|
2299
2348
|
...(config?.lowers ?? []),
|
|
2300
2349
|
...(bootstrapLower ? [bootstrapLower] : []),
|
package/dist/test/runtime.d.ts
CHANGED
|
@@ -7,5 +7,6 @@
|
|
|
7
7
|
export { type AgentOsRuntimeAdmin, getAgentOsKernel, getAgentOsRuntimeAdmin, } from "../agent-os.js";
|
|
8
8
|
export type { PermissionTier, WasmVmRuntimeOptions, } from "../runtime.js";
|
|
9
9
|
export type { DriverProcess, Kernel, KernelInterface, KernelRuntimeDriver, ProcessContext, VirtualFileSystem, } from "../runtime-compat.js";
|
|
10
|
-
export { AF_INET, AF_UNIX, allowAll,
|
|
10
|
+
export { AF_INET, AF_UNIX, allowAll, createKernel, createNodeHostNetworkAdapter, createNodeRuntime, createWasmVmRuntime, DEFAULT_FIRST_PARTY_TIERS, NodeFileSystem, SIGTERM, SOCK_DGRAM, SOCK_STREAM, WASMVM_COMMANDS, } from "../runtime-compat.js";
|
|
11
|
+
export { createInMemoryFileSystem } from "@rivet-dev/agentos-runtime-core/test-runtime";
|
|
11
12
|
export { TerminalHarness } from "./terminal-harness.js";
|
package/dist/test/runtime.js
CHANGED
|
@@ -5,5 +5,6 @@
|
|
|
5
5
|
* while the public SDK removes the raw vm.kernel escape hatch.
|
|
6
6
|
*/
|
|
7
7
|
export { getAgentOsKernel, getAgentOsRuntimeAdmin, } from "../agent-os.js";
|
|
8
|
-
export { AF_INET, AF_UNIX, allowAll,
|
|
8
|
+
export { AF_INET, AF_UNIX, allowAll, createKernel, createNodeHostNetworkAdapter, createNodeRuntime, createWasmVmRuntime, DEFAULT_FIRST_PARTY_TIERS, NodeFileSystem, SIGTERM, SOCK_DGRAM, SOCK_STREAM, WASMVM_COMMANDS, } from "../runtime-compat.js";
|
|
9
|
+
export { createInMemoryFileSystem } from "@rivet-dev/agentos-runtime-core/test-runtime";
|
|
9
10
|
export { TerminalHarness } from "./terminal-harness.js";
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export type {
|
|
1
|
+
export type { AgentExitEvent, AgentExitHandler, AgentOsCreateSidecarOptions, AgentOsLimits, AgentOsOptions, AgentOsSharedSidecarOptions, AgentOsSidecarConfig, AgentOsSidecarDescription, AgentRegistryEntry, AgentRestartOutcome, AgentStderrEvent, AgentStderrHandler, BatchReadResult, BatchWriteEntry, BatchWriteResult, DirEntry, DynamicMountDescriptor, ExportRootFilesystemOptions, HttpRequest, HttpResponse, LimitWarning, LimitWarningHandler, MountConfig, MountConfigJsonObject, MountConfigJsonPrimitive, MountConfigJsonValue, MountInfo, NativeMountConfig, NativeMountPluginDescriptor, NativeRootFilesystemConfig, OverlayMountConfig, OverlayRootFilesystemConfig, PlainMountConfig, ProcessOutput, ProcessTreeNode, ReaddirEntry, ReaddirRecursiveOptions, RootFilesystemConfig, RootLowerInput, ShellData, ShellExit, ShellOptions, } from "./agent-os.js";
|
|
2
|
+
export type { CodeEvaluationResult, CodeExecutionResult, ContextDescriptor, ContextState, ExecutionErrorData, ExecutionSignal, InlineExecutionOptions, JavaScriptEvaluationOptions, JavaScriptExecutionOptions, LanguageExecutionOptions, LanguageSpawnOptions, NpmPackageInstallOptions, NpmProjectInstallOptions, OutputCapture, OutputReplay, ProcessDescriptor, ProcessExit, ProcessOutputEvent, PythonInstallOptions, SpawnOptions, TypeScriptCheckOptions, TypeScriptCheckResult, TypeScriptDiagnostic, TypeScriptEvaluationOptions, TypeScriptExecutionOptions, TypeScriptFileExecutionOptions, } from "./language-execution.js";
|
|
3
|
+
export type * from "./session-api.js";
|
|
2
4
|
/**
|
|
3
5
|
* An agent type id — the `name` of an `/opt/agentos` agent package manifest
|
|
4
6
|
* (e.g. `"pi"`, `"claude"`). Agents are resolved by the SIDECAR from the projected
|
|
@@ -6,12 +8,11 @@ export type { AgentCapabilities, AgentInfo, AgentOsCreateSidecarOptions, AgentOs
|
|
|
6
8
|
* passes only the name, so any manifest `name` is a valid agent type.
|
|
7
9
|
*/
|
|
8
10
|
export type AgentType = string;
|
|
9
|
-
export type {
|
|
11
|
+
export type { AgentBlock, PackageDescriptor, PackageRef, SoftwarePackageRef, } from "./agentos-package.js";
|
|
12
|
+
export type { Binding, BindingExample, Bindings } from "./bindings.js";
|
|
13
|
+
export type { CronAction, CronActionInfo, CronEvent, CronEventHandler, CronJob, CronJobInfo, CronJobOptions, ScheduleDriver, ScheduleEntry, ScheduleHandle, } from "./cron/index.js";
|
|
10
14
|
export type { HostDirBackendOptions, HostDirMountPluginConfig, NodeModulesMountConfig, } from "./host-dir-mount.js";
|
|
11
|
-
export type { HostTool, ToolExample, ToolKit } from "./host-tools.js";
|
|
12
|
-
export type { AcpTimeoutErrorData, JsonRpcError, JsonRpcErrorData, JsonRpcNotification, JsonRpcRequest, JsonRpcResponse, UnknownSessionErrorData, } from "./json-rpc.js";
|
|
13
15
|
export type { FilesystemSnapshotExport, LayerHandle, LayerStore, OverlayFilesystemMode, RootSnapshotExport, SnapshotImportSource, SnapshotLayerHandle, WritableLayerHandle, } from "./layers.js";
|
|
14
16
|
export type { SoftwareInput, SoftwareRoot } from "./packages.js";
|
|
15
|
-
export type { AgentBlock, PackageDescriptor, PackageRef, SoftwarePackageRef, } from "./agentos-package.js";
|
|
16
17
|
export type { ChildProcessPermissions, ConnectTerminalOptions, EnvPermissions, ExecOptions, ExecResult, FsPermissionRule, FsPermissions, KernelExecOptions, KernelExecResult, KernelSpawnOptions, NetworkAccessRequest, NetworkPermissions, OpenShellOptions, PatternPermissionRule, PermissionDecision, PermissionMode, Permissions, ProcessInfo, RulePermissions, StdioChannel, TimingMitigation, VirtualDirEntry, VirtualFileSystem, VirtualStat, } from "./runtime.js";
|
|
17
|
-
export type {
|
|
18
|
+
export type { AgentOsSandboxClient, AgentOsSandboxClientOptions, AgentOsSandboxCommonOptions, AgentOsSandboxInput, AgentOsSandboxOptions, AgentOsSandboxProcessInfo, AgentOsSandboxProcessLogs, AgentOsSandboxProcessResult, AgentOsSandboxProvider, AgentOsSandboxProviderOptions, SandboxMountPluginConfig, } from "./sandbox.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rivet-dev/agentos-core",
|
|
3
|
-
"version": "0.0.0-main.
|
|
3
|
+
"version": "0.0.0-main.5ac5a14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,6 +19,11 @@
|
|
|
19
19
|
"import": "./dist/runtime-compat.js",
|
|
20
20
|
"default": "./dist/runtime-compat.js"
|
|
21
21
|
},
|
|
22
|
+
"./internal/code-execution": {
|
|
23
|
+
"types": "./dist/code-execution.d.ts",
|
|
24
|
+
"import": "./dist/code-execution.js",
|
|
25
|
+
"default": "./dist/code-execution.js"
|
|
26
|
+
},
|
|
22
27
|
"./test/file-system": {
|
|
23
28
|
"types": "./dist/test/file-system.d.ts",
|
|
24
29
|
"import": "./dist/test/file-system.js",
|
|
@@ -46,59 +51,61 @@
|
|
|
46
51
|
}
|
|
47
52
|
},
|
|
48
53
|
"scripts": {
|
|
49
|
-
"check-types": "pnpm run build:protocols && tsc --noEmit",
|
|
54
|
+
"check-types": "pnpm run build:protocols && tsc --noEmit && tsc -p tsconfig.type-tests.json",
|
|
50
55
|
"build": "pnpm run build:protocols && tsc",
|
|
51
56
|
"build:agentos-protocol": "node ./scripts/compile-agentos-protocol.mjs",
|
|
52
57
|
"build:protocols": "pnpm run build:agentos-protocol",
|
|
53
|
-
"test": "vitest run --reporter=verbose"
|
|
58
|
+
"test": "vitest run --exclude '**/*.nightly.test.ts' --reporter=verbose",
|
|
59
|
+
"test:unit": "vitest run tests/agent-exit-event.test.ts tests/agentos-package.test.ts tests/agentos-protocol.test.ts tests/allowed-node-builtins.test.ts tests/bindings-zod.test.ts tests/bindings.test.ts tests/cron-manager.test.ts tests/cron-timer-driver.test.ts tests/execution-abort.test.ts tests/generated-protocol.test.ts tests/leak-agent-os-processes.test.ts tests/leak-rpc-client.test.ts tests/mount-descriptors.test.ts tests/mount-reconfigure.test.ts tests/options-schema.test.ts tests/public-api-exports.test.ts tests/root-filesystem-descriptors.test.ts tests/runtime-compat-mount.test.ts tests/session-event-ordering.test.ts tests/session-permission-surface.test.ts tests/sidecar-client.test.ts tests/sidecar-permission-descriptors.test.ts tests/wasm-permission-tiers.test.ts --fileParallelism=false",
|
|
60
|
+
"test:pr": "pnpm test:unit && vitest run tests/migration-parity.test.ts tests/acp-reactor-regression.test.ts --fileParallelism=false --reporter=verbose",
|
|
61
|
+
"test:nightly": "vitest run tests/*.nightly.test.ts --reporter=verbose --passWithNoTests"
|
|
54
62
|
},
|
|
55
63
|
"dependencies": {
|
|
56
|
-
"@
|
|
64
|
+
"@agentclientprotocol/sdk": "0.16.1",
|
|
65
|
+
"@agentos-software/claude-code": "0.2.7",
|
|
57
66
|
"@agentos-software/codex-cli": "0.3.4",
|
|
58
|
-
"@agentos-software/common": "0.0.0-main.
|
|
59
|
-
"@agentos-software/manifest": "0.0.0-main.
|
|
60
|
-
"@agentos-software/opencode": "0.
|
|
61
|
-
"@agentos-software/pi": "0.
|
|
62
|
-
"@agentos-software/pi-cli": "0.0.0-main.2f99c77",
|
|
67
|
+
"@agentos-software/common": "0.0.0-main.5ac5a14",
|
|
68
|
+
"@agentos-software/manifest": "0.0.0-main.5ac5a14",
|
|
69
|
+
"@agentos-software/opencode": "0.2.7",
|
|
70
|
+
"@agentos-software/pi": "0.2.7",
|
|
63
71
|
"@aws-sdk/client-s3": "^3.1019.0",
|
|
64
|
-
"@rivet-dev/agentos-sidecar": "0.0.0-main.
|
|
72
|
+
"@rivet-dev/agentos-sidecar": "0.0.0-main.5ac5a14",
|
|
65
73
|
"@rivetkit/bare-ts": "^0.6.2",
|
|
66
|
-
"@rivet-dev/agentos-runtime-core": "0.0.0-main.
|
|
74
|
+
"@rivet-dev/agentos-runtime-core": "0.0.0-main.5ac5a14",
|
|
67
75
|
"@xterm/headless": "^6.0.0",
|
|
68
76
|
"better-sqlite3": "^12.8.0",
|
|
69
77
|
"croner": "^10.0.1",
|
|
70
78
|
"googleapis": "^144.0.0",
|
|
71
|
-
"isolated-vm": "^6.0.0",
|
|
72
79
|
"long-timeout": "^0.1.1",
|
|
73
80
|
"minimatch": "^10.2.4",
|
|
74
81
|
"zod": "^4.1.11",
|
|
75
82
|
"zod-to-json-schema": "^3.25.2"
|
|
76
83
|
},
|
|
77
84
|
"devDependencies": {
|
|
78
|
-
"@agentos-software/claude-code": "0.
|
|
79
|
-
"@agentos-software/codex": "0.
|
|
80
|
-
"@agentos-software/coreutils": "0.3.
|
|
85
|
+
"@agentos-software/claude-code": "0.2.7",
|
|
86
|
+
"@agentos-software/codex": "0.2.7",
|
|
87
|
+
"@agentos-software/coreutils": "0.3.4",
|
|
81
88
|
"@agentos-software/curl": "0.3.3",
|
|
82
|
-
"@agentos-software/diffutils": "0.3.
|
|
89
|
+
"@agentos-software/diffutils": "0.3.4",
|
|
83
90
|
"@agentos-software/duckdb": "0.3.3",
|
|
84
91
|
"@agentos-software/fd": "0.3.3",
|
|
85
92
|
"@agentos-software/file": "0.3.3",
|
|
86
|
-
"@agentos-software/findutils": "0.3.
|
|
87
|
-
"@agentos-software/gawk": "0.3.
|
|
93
|
+
"@agentos-software/findutils": "0.3.4",
|
|
94
|
+
"@agentos-software/gawk": "0.3.4",
|
|
88
95
|
"@agentos-software/git": "0.3.3",
|
|
89
|
-
"@agentos-software/grep": "0.3.
|
|
90
|
-
"@agentos-software/gzip": "0.3.
|
|
91
|
-
"@agentos-software/http-get": "0.3.3",
|
|
96
|
+
"@agentos-software/grep": "0.3.4",
|
|
97
|
+
"@agentos-software/gzip": "0.3.4",
|
|
92
98
|
"@agentos-software/jq": "0.3.3",
|
|
93
|
-
"@agentos-software/opencode": "0.
|
|
94
|
-
"@agentos-software/pi": "0.
|
|
95
|
-
"@agentos-software/pi-cli": "0.0.0-main.2f99c77",
|
|
99
|
+
"@agentos-software/opencode": "0.2.7",
|
|
100
|
+
"@agentos-software/pi": "0.2.7",
|
|
96
101
|
"@agentos-software/ripgrep": "0.3.3",
|
|
97
|
-
"@agentos-software/sed": "0.3.
|
|
98
|
-
"@agentos-software/tar": "0.3.
|
|
102
|
+
"@agentos-software/sed": "0.3.4",
|
|
103
|
+
"@agentos-software/tar": "0.3.5",
|
|
99
104
|
"@agentos-software/tree": "0.3.3",
|
|
100
105
|
"@agentos-software/vim": "0.3.3",
|
|
106
|
+
"@agentos-software/wget": "0.3.3",
|
|
101
107
|
"@agentos-software/yq": "0.3.3",
|
|
108
|
+
"@rivet-dev/agentos-test-harness": "0.0.0-main.5ac5a14",
|
|
102
109
|
"@anthropic-ai/claude-agent-sdk": "^0.2.87",
|
|
103
110
|
"@anthropic-ai/claude-code": "^2.1.86",
|
|
104
111
|
"@bare-ts/tools": "0.15.0",
|
|
@@ -106,13 +113,16 @@
|
|
|
106
113
|
"@browserbasehq/cli": "0.5.4",
|
|
107
114
|
"@browserbasehq/sdk": "2.10.0",
|
|
108
115
|
"@copilotkit/llmock": "^1.6.0",
|
|
109
|
-
"@mariozechner/pi-coding-agent": "^0.60.0",
|
|
110
116
|
"@types/node": "^22.10.2",
|
|
111
|
-
"pi-acp": "^0.0.23",
|
|
112
117
|
"sandbox-agent": "^0.4.2",
|
|
113
118
|
"typescript": "^5.7.2",
|
|
114
119
|
"vitest": "^2.1.8",
|
|
115
120
|
"ws": "^8.18.0",
|
|
116
121
|
"zod3": "npm:zod@^3.25.76"
|
|
122
|
+
},
|
|
123
|
+
"repository": {
|
|
124
|
+
"type": "git",
|
|
125
|
+
"url": "https://github.com/rivet-dev/agentos.git",
|
|
126
|
+
"directory": "packages/core"
|
|
117
127
|
}
|
|
118
128
|
}
|