@rivet-dev/agentos-core 0.0.0-codex-actor-plugin-contract-coverage.115ca8a → 0.0.0-eve-integration.9df6f34
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 +41 -38
- package/dist/agent-os.d.ts +196 -232
- package/dist/agent-os.js +771 -1162
- package/dist/agentos-package.d.ts +5 -3
- package/dist/agentos-package.js +5 -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/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 +4 -5
- package/dist/index.js +4 -5
- package/dist/layers.d.ts +5 -2
- package/dist/layers.js +0 -185
- package/dist/options-schema.d.ts +133 -31
- package/dist/options-schema.js +143 -26
- package/dist/runtime-compat.d.ts +11 -37
- package/dist/runtime-compat.js +88 -376
- package/dist/runtime.d.ts +10 -3
- package/dist/sandbox.d.ts +4 -4
- package/dist/sandbox.js +4 -4
- package/dist/session-api.d.ts +180 -0
- package/dist/session-api.js +1 -0
- package/dist/sidecar/agentos-protocol.d.ts +429 -29
- package/dist/sidecar/agentos-protocol.js +691 -93
- package/dist/sidecar/native-process-client.d.ts +1 -1
- package/dist/sidecar/native-process-client.js +1 -1
- package/dist/sidecar/rpc-client.d.ts +40 -6
- package/dist/sidecar/rpc-client.js +126 -38
- 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 +4 -5
- package/package.json +29 -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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "@rivet-dev/agentos-runtime-core/native-client";
|
|
2
2
|
import { SidecarProcess } from "@rivet-dev/agentos-runtime-core/sidecar-client";
|
|
3
|
-
export {
|
|
3
|
+
export { SidecarEventBufferOverflow, SidecarProcess, SidecarProcessError, SidecarProcessExited, } from "@rivet-dev/agentos-runtime-core/sidecar-client";
|
|
4
4
|
export declare const NativeSidecarProcessClient: typeof SidecarProcess;
|
|
5
5
|
export type { AuthenticatedSession, CreatedVm, ExtEnvelope, GuestFilesystemStat, RootFilesystemEntry, RootFilesystemLowerDescriptor, SidecarEventSelector, SidecarFsPermissionRule, SidecarLinkPackageResult, SidecarMountDescriptor, SidecarMountPluginDescriptor, SidecarPatternPermissionRule, SidecarPermissionMode, SidecarPermissionScope, SidecarPermissionsPolicy, SidecarProcessSnapshotEntry, SidecarProjectedAgent, SidecarProjectedModuleDescriptor, SidecarRegisteredHostCallbackDefinition, SidecarRegisteredHostCallbackExample, SidecarRequestFrame, SidecarRequestHandler, SidecarRequestPayload, SidecarResponseFrame, SidecarResponsePayload, SidecarRulePermissions, SidecarSessionState, SidecarSignalHandlerRegistration, SidecarSignalState, SidecarSocketStateEntry, SidecarSoftwareDescriptor, SidecarSpawnOptions, SidecarSpawnOptions as NativeSidecarSpawnOptions, SidecarZombieTimerCount, } from "@rivet-dev/agentos-runtime-core/sidecar-client";
|
|
6
6
|
export type { SidecarVmConfiguredResponse as SidecarConfigureVmResult, } from "@rivet-dev/agentos-runtime-core/sidecar-client";
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
// SidecarProcess.spawn works in this native runtime.
|
|
5
5
|
import "@rivet-dev/agentos-runtime-core/native-client";
|
|
6
6
|
import { SidecarProcess } from "@rivet-dev/agentos-runtime-core/sidecar-client";
|
|
7
|
-
export {
|
|
7
|
+
export { SidecarEventBufferOverflow, SidecarProcess, SidecarProcessError, SidecarProcessExited, } from "@rivet-dev/agentos-runtime-core/sidecar-client";
|
|
8
8
|
export const NativeSidecarProcessClient = SidecarProcess;
|
|
@@ -35,6 +35,16 @@ interface NativeSidecarKernelProxyOptions {
|
|
|
35
35
|
permissions?: SidecarPermissionsPolicy;
|
|
36
36
|
commandPermissions?: Parameters<SidecarProcess["configureVm"]>[2]["commandPermissions"];
|
|
37
37
|
loopbackExemptPorts?: number[];
|
|
38
|
+
/**
|
|
39
|
+
* The boot `configureVm` payload pieces beyond mounts/permissions. Rust
|
|
40
|
+
* `configure_vm` rebuilds the whole VM configuration from each payload, so
|
|
41
|
+
* every runtime mount reconfigure must resend these or a post-boot
|
|
42
|
+
* `mountFs()` silently drops the `/opt/agentos` package projections and
|
|
43
|
+
* binding shim commands applied at boot.
|
|
44
|
+
*/
|
|
45
|
+
packages?: Parameters<SidecarProcess["configureVm"]>[2]["packages"];
|
|
46
|
+
packagesMountAt?: string;
|
|
47
|
+
bindingShimCommands?: string[];
|
|
38
48
|
commandGuestPaths: ReadonlyMap<string, string>;
|
|
39
49
|
onWasmCommandResolved?: (command: string) => void;
|
|
40
50
|
onDispose?: () => Promise<void>;
|
|
@@ -60,9 +70,13 @@ export declare class NativeSidecarKernelProxy {
|
|
|
60
70
|
private readonly ownsClient;
|
|
61
71
|
private readonly localMounts;
|
|
62
72
|
private readonly baseSidecarMounts;
|
|
73
|
+
private readonly dynamicSidecarMounts;
|
|
63
74
|
private readonly permissions;
|
|
64
75
|
private readonly commandPermissions;
|
|
65
76
|
private readonly loopbackExemptPorts;
|
|
77
|
+
private packages;
|
|
78
|
+
private readonly packagesMountAt;
|
|
79
|
+
private readonly bindingShimCommands;
|
|
66
80
|
private readonly commandDrivers;
|
|
67
81
|
private readonly onWasmCommandResolved;
|
|
68
82
|
private readonly onDispose;
|
|
@@ -88,6 +102,15 @@ export declare class NativeSidecarKernelProxy {
|
|
|
88
102
|
createRootView(): VirtualFileSystem;
|
|
89
103
|
get zombieTimerCount(): number;
|
|
90
104
|
registerCommandGuestPaths(commandGuestPaths: ReadonlyMap<string, string>): void;
|
|
105
|
+
/**
|
|
106
|
+
* Record a runtime-linked package (`linkSoftware`) so mount reconfigures
|
|
107
|
+
* resend it. Rust `configure_vm` rebuilds the whole VM configuration from
|
|
108
|
+
* each payload, so a linked package omitted here would be silently
|
|
109
|
+
* unprojected from `/opt/agentos` by the next `mountFs`/`unmountFs`.
|
|
110
|
+
*/
|
|
111
|
+
registerLinkedPackage(descriptor: {
|
|
112
|
+
path: string;
|
|
113
|
+
}): void;
|
|
91
114
|
dispose(): Promise<void>;
|
|
92
115
|
/** Test-only snapshot of the per-VM tracking collection sizes. */
|
|
93
116
|
__trackingSizesForTest(): {
|
|
@@ -137,8 +160,15 @@ export declare class NativeSidecarKernelProxy {
|
|
|
137
160
|
mountFs(path: string, driver: VirtualFileSystem, options?: {
|
|
138
161
|
readOnly?: boolean;
|
|
139
162
|
sidecarMount?: SidecarMountDescriptor;
|
|
140
|
-
}): void
|
|
141
|
-
unmountFs(path: string): void
|
|
163
|
+
}): Promise<void>;
|
|
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
|
+
}>>;
|
|
142
172
|
private desiredSidecarMounts;
|
|
143
173
|
private reconfigureSidecarMounts;
|
|
144
174
|
private waitForMountReconfigure;
|
|
@@ -153,6 +183,7 @@ export declare class NativeSidecarKernelProxy {
|
|
|
153
183
|
port?: number;
|
|
154
184
|
}): KernelSocketSnapshot | null;
|
|
155
185
|
getSignalState(pid: number): KernelSignalState;
|
|
186
|
+
private scheduleSignalStateRefresh;
|
|
156
187
|
private refreshSocketLookup;
|
|
157
188
|
private refreshSignalState;
|
|
158
189
|
private refreshProcessSnapshot;
|
|
@@ -184,7 +215,7 @@ export declare class NativeSidecarKernelProxy {
|
|
|
184
215
|
private updateTrackedProcessSnapshot;
|
|
185
216
|
}
|
|
186
217
|
export type { AuthenticatedSession, CreatedVm, GuestFilesystemStat, RootFilesystemEntry, SidecarConfigureVmResult, SidecarEventSelector, SidecarLinkPackageResult, SidecarPermissionsPolicy, SidecarProjectedAgent, SidecarRegisteredHostCallbackDefinition, SidecarRequestFrame, SidecarResponsePayload, SidecarSessionState, SidecarSignalHandlerRegistration, SidecarSocketStateEntry, SidecarSpawnOptions, } from "./native-process-client.js";
|
|
187
|
-
export {
|
|
218
|
+
export { NativeSidecarProcessClient, SidecarEventBufferOverflow, SidecarProcess, SidecarProcessError, SidecarProcessExited, } from "./native-process-client.js";
|
|
188
219
|
export type AgentOsSidecarPlacement = {
|
|
189
220
|
kind: "shared";
|
|
190
221
|
pool?: string;
|
|
@@ -240,7 +271,7 @@ export interface AgentOsSidecarTransport {
|
|
|
240
271
|
dispose(): Promise<void>;
|
|
241
272
|
}
|
|
242
273
|
export interface AgentOsSidecarClientOptions {
|
|
243
|
-
|
|
274
|
+
createOwnershipTransport(bootstrap: AgentOsSidecarSessionBootstrap): Promise<AgentOsSidecarTransport>;
|
|
244
275
|
createId?: () => string;
|
|
245
276
|
now?: () => number;
|
|
246
277
|
}
|
|
@@ -262,13 +293,14 @@ export declare class AgentOsSidecarSessionHandle {
|
|
|
262
293
|
dispose(): Promise<void>;
|
|
263
294
|
}
|
|
264
295
|
export declare class AgentOsSidecarClient {
|
|
265
|
-
private readonly
|
|
296
|
+
private readonly createOwnershipTransport;
|
|
266
297
|
private readonly createId;
|
|
267
298
|
private readonly now;
|
|
268
299
|
private readonly sessions;
|
|
269
300
|
private disposed;
|
|
270
301
|
constructor(options: AgentOsSidecarClientOptions);
|
|
271
|
-
|
|
302
|
+
/** Open a physical sidecar ownership scope, not a durable ACP session. */
|
|
303
|
+
createOwnershipSession(options?: AgentOsSidecarSessionOptions): Promise<AgentOsSidecarSessionHandle>;
|
|
272
304
|
listSessions(): AgentOsSidecarSessionLifecycle[];
|
|
273
305
|
requireSessionLifecycle(sessionId: string): AgentOsSidecarSessionLifecycle;
|
|
274
306
|
listVms(sessionId: string): AgentOsSidecarVmLifecycle[];
|
|
@@ -293,6 +325,8 @@ export interface SidecarMountPluginDescriptor {
|
|
|
293
325
|
}
|
|
294
326
|
export interface SidecarMountDescriptor {
|
|
295
327
|
guestPath: string;
|
|
328
|
+
guestSource?: string;
|
|
329
|
+
guestFstype?: string;
|
|
296
330
|
readOnly: boolean;
|
|
297
331
|
plugin: SidecarMountPluginDescriptor;
|
|
298
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,9 +213,15 @@ export class NativeSidecarKernelProxy {
|
|
|
211
213
|
ownsClient;
|
|
212
214
|
localMounts;
|
|
213
215
|
baseSidecarMounts;
|
|
216
|
+
dynamicSidecarMounts = [];
|
|
214
217
|
permissions;
|
|
215
218
|
commandPermissions;
|
|
216
219
|
loopbackExemptPorts;
|
|
220
|
+
// Mutable: runtime `linkSoftware` appends via `registerLinkedPackage` so
|
|
221
|
+
// later mount reconfigures resend linked packages too, not just boot ones.
|
|
222
|
+
packages;
|
|
223
|
+
packagesMountAt;
|
|
224
|
+
bindingShimCommands;
|
|
217
225
|
commandDrivers;
|
|
218
226
|
onWasmCommandResolved;
|
|
219
227
|
onDispose;
|
|
@@ -250,6 +258,9 @@ export class NativeSidecarKernelProxy {
|
|
|
250
258
|
this.permissions = options.permissions;
|
|
251
259
|
this.commandPermissions = options.commandPermissions;
|
|
252
260
|
this.loopbackExemptPorts = options.loopbackExemptPorts;
|
|
261
|
+
this.packages = options.packages ? [...options.packages] : [];
|
|
262
|
+
this.packagesMountAt = options.packagesMountAt;
|
|
263
|
+
this.bindingShimCommands = options.bindingShimCommands;
|
|
253
264
|
this.commandDrivers = buildCommandMap(options.commandGuestPaths);
|
|
254
265
|
this.onWasmCommandResolved = options.onWasmCommandResolved;
|
|
255
266
|
this.onDispose = options.onDispose;
|
|
@@ -273,6 +284,17 @@ export class NativeSidecarKernelProxy {
|
|
|
273
284
|
this.commandDrivers.set(name, "wasmvm");
|
|
274
285
|
}
|
|
275
286
|
}
|
|
287
|
+
/**
|
|
288
|
+
* Record a runtime-linked package (`linkSoftware`) so mount reconfigures
|
|
289
|
+
* resend it. Rust `configure_vm` rebuilds the whole VM configuration from
|
|
290
|
+
* each payload, so a linked package omitted here would be silently
|
|
291
|
+
* unprojected from `/opt/agentos` by the next `mountFs`/`unmountFs`.
|
|
292
|
+
*/
|
|
293
|
+
registerLinkedPackage(descriptor) {
|
|
294
|
+
if (!this.packages.some((pkg) => pkg.path === descriptor.path)) {
|
|
295
|
+
this.packages.push({ path: descriptor.path });
|
|
296
|
+
}
|
|
297
|
+
}
|
|
276
298
|
async dispose() {
|
|
277
299
|
if (this.disposed) {
|
|
278
300
|
return;
|
|
@@ -564,7 +586,7 @@ export class NativeSidecarKernelProxy {
|
|
|
564
586
|
return proc;
|
|
565
587
|
}
|
|
566
588
|
openShell(options) {
|
|
567
|
-
const
|
|
589
|
+
const terminalHandlers = new Set();
|
|
568
590
|
const stderrHandlers = new Set();
|
|
569
591
|
const command = options?.command ?? "sh";
|
|
570
592
|
const args = options?.args ??
|
|
@@ -619,7 +641,7 @@ export class NativeSidecarKernelProxy {
|
|
|
619
641
|
const normalized = normalizeSyntheticTerminalText(text);
|
|
620
642
|
updateSyntheticCursor(normalized);
|
|
621
643
|
const chunk = textEncoder.encode(normalized);
|
|
622
|
-
for (const handler of
|
|
644
|
+
for (const handler of terminalHandlers) {
|
|
623
645
|
handler(chunk);
|
|
624
646
|
}
|
|
625
647
|
};
|
|
@@ -630,7 +652,7 @@ export class NativeSidecarKernelProxy {
|
|
|
630
652
|
const normalized = normalizeSyntheticTerminalText(text);
|
|
631
653
|
updateSyntheticCursor(normalized);
|
|
632
654
|
const chunk = textEncoder.encode(normalized);
|
|
633
|
-
for (const handler of
|
|
655
|
+
for (const handler of terminalHandlers) {
|
|
634
656
|
handler(chunk);
|
|
635
657
|
}
|
|
636
658
|
};
|
|
@@ -675,7 +697,7 @@ export class NativeSidecarKernelProxy {
|
|
|
675
697
|
commandInFlight = false;
|
|
676
698
|
const promptPrefix = syntheticCursorAtLineStart ? "" : "\r\n";
|
|
677
699
|
const promptChunk = textEncoder.encode(`${promptPrefix}${promptText}`);
|
|
678
|
-
for (const handler of
|
|
700
|
+
for (const handler of terminalHandlers) {
|
|
679
701
|
handler(promptChunk);
|
|
680
702
|
}
|
|
681
703
|
syntheticCursorAtLineStart = false;
|
|
@@ -733,7 +755,7 @@ export class NativeSidecarKernelProxy {
|
|
|
733
755
|
}
|
|
734
756
|
};
|
|
735
757
|
let onData = null;
|
|
736
|
-
|
|
758
|
+
terminalHandlers.add((data) => onData?.(data));
|
|
737
759
|
if (options?.onStderr) {
|
|
738
760
|
stderrHandlers.add(options.onStderr);
|
|
739
761
|
}
|
|
@@ -902,7 +924,7 @@ export class NativeSidecarKernelProxy {
|
|
|
902
924
|
if (!sanitized) {
|
|
903
925
|
return;
|
|
904
926
|
}
|
|
905
|
-
for (const handler of
|
|
927
|
+
for (const handler of terminalHandlers) {
|
|
906
928
|
handler(sanitized);
|
|
907
929
|
}
|
|
908
930
|
if (commandInFlight) {
|
|
@@ -914,6 +936,11 @@ export class NativeSidecarKernelProxy {
|
|
|
914
936
|
if (!sanitized) {
|
|
915
937
|
return;
|
|
916
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
|
+
}
|
|
917
944
|
for (const handler of stderrHandlers) {
|
|
918
945
|
handler(sanitized);
|
|
919
946
|
}
|
|
@@ -967,13 +994,7 @@ export class NativeSidecarKernelProxy {
|
|
|
967
994
|
const stdin = process.stdin;
|
|
968
995
|
const stdout = process.stdout;
|
|
969
996
|
const { onData, ...shellOptions } = options ?? {};
|
|
970
|
-
const shell = this.openShell(
|
|
971
|
-
...shellOptions,
|
|
972
|
-
onStderr: shellOptions.onStderr ??
|
|
973
|
-
((data) => {
|
|
974
|
-
process.stderr.write(data);
|
|
975
|
-
}),
|
|
976
|
-
});
|
|
997
|
+
const shell = this.openShell(shellOptions);
|
|
977
998
|
const outputHandler = onData ??
|
|
978
999
|
((data) => {
|
|
979
1000
|
stdout.write(data);
|
|
@@ -1058,7 +1079,7 @@ export class NativeSidecarKernelProxy {
|
|
|
1058
1079
|
if (local) {
|
|
1059
1080
|
return this.readdirRecursiveLocal(local.mount.fs, local.relativePath, options?.maxDepth);
|
|
1060
1081
|
}
|
|
1061
|
-
return this.client.readdirRecursive(this.session, this.vm, path, options);
|
|
1082
|
+
return (await this.client.readdirRecursive(this.session, this.vm, path, options)).map((entry) => ({ ...entry, size: Number(entry.size) }));
|
|
1062
1083
|
}
|
|
1063
1084
|
async removeFile(path) {
|
|
1064
1085
|
return this.dispatchWrite(path, (mount, relativePath) => mount.fs.removeFile(relativePath), () => this.client.removeFile(this.session, this.vm, path));
|
|
@@ -1126,19 +1147,53 @@ export class NativeSidecarKernelProxy {
|
|
|
1126
1147
|
sidecarMount: options?.sidecarMount,
|
|
1127
1148
|
});
|
|
1128
1149
|
this.localMounts.sort((left, right) => right.path.length - left.path.length);
|
|
1129
|
-
|
|
1150
|
+
// Resolves once the sidecar has the mount; a swallowed rejection here
|
|
1151
|
+
// used to turn reconfigure failures into silently missing guest mounts.
|
|
1152
|
+
// The local catch only guards callers that drop the promise — awaiting
|
|
1153
|
+
// callers still observe the rejection.
|
|
1154
|
+
const applied = this.reconfigureSidecarMounts();
|
|
1155
|
+
applied.catch(() => { });
|
|
1156
|
+
return applied;
|
|
1130
1157
|
}
|
|
1131
1158
|
unmountFs(path) {
|
|
1132
1159
|
const normalized = posixPath.normalize(path);
|
|
1133
1160
|
const index = this.localMounts.findIndex((mount) => mount.path === normalized);
|
|
1134
|
-
if (index
|
|
1135
|
-
|
|
1136
|
-
void this.reconfigureSidecarMounts().catch(() => { });
|
|
1161
|
+
if (index < 0) {
|
|
1162
|
+
return Promise.resolve();
|
|
1137
1163
|
}
|
|
1164
|
+
this.localMounts.splice(index, 1);
|
|
1165
|
+
const applied = this.reconfigureSidecarMounts();
|
|
1166
|
+
applied.catch(() => { });
|
|
1167
|
+
return applied;
|
|
1168
|
+
}
|
|
1169
|
+
mountDescriptor(mount) {
|
|
1170
|
+
const normalized = posixPath.normalize(mount.guestPath);
|
|
1171
|
+
if (this.desiredSidecarMounts().some((existing) => posixPath.normalize(existing.guestPath) === normalized)) {
|
|
1172
|
+
return Promise.reject(new Error(`mount already exists: ${normalized}`));
|
|
1173
|
+
}
|
|
1174
|
+
this.dynamicSidecarMounts.push({ ...mount, guestPath: normalized });
|
|
1175
|
+
const applied = this.reconfigureSidecarMounts();
|
|
1176
|
+
applied.catch(() => { });
|
|
1177
|
+
return applied;
|
|
1178
|
+
}
|
|
1179
|
+
unmountDescriptor(path) {
|
|
1180
|
+
const normalized = posixPath.normalize(path);
|
|
1181
|
+
const index = this.dynamicSidecarMounts.findIndex((mount) => posixPath.normalize(mount.guestPath) === normalized);
|
|
1182
|
+
if (index < 0)
|
|
1183
|
+
return Promise.resolve();
|
|
1184
|
+
this.dynamicSidecarMounts.splice(index, 1);
|
|
1185
|
+
const applied = this.reconfigureSidecarMounts();
|
|
1186
|
+
applied.catch(() => { });
|
|
1187
|
+
return applied;
|
|
1188
|
+
}
|
|
1189
|
+
async listMounts() {
|
|
1190
|
+
await this.waitForMountReconfigure();
|
|
1191
|
+
return this.client.listMounts(this.session, this.vm);
|
|
1138
1192
|
}
|
|
1139
1193
|
desiredSidecarMounts() {
|
|
1140
1194
|
return [
|
|
1141
1195
|
...this.baseSidecarMounts,
|
|
1196
|
+
...this.dynamicSidecarMounts,
|
|
1142
1197
|
...this.localMounts.map((mount) => mount.sidecarMount ?? {
|
|
1143
1198
|
guestPath: mount.path,
|
|
1144
1199
|
readOnly: mount.readOnly,
|
|
@@ -1154,11 +1209,18 @@ export class NativeSidecarKernelProxy {
|
|
|
1154
1209
|
if (this.disposed) {
|
|
1155
1210
|
return;
|
|
1156
1211
|
}
|
|
1212
|
+
// Rust `configure_vm` rebuilds the whole VM configuration from this
|
|
1213
|
+
// payload, so resend the boot packages / binding shim commands too —
|
|
1214
|
+
// omitting them here strips the `/opt/agentos` projections and binding
|
|
1215
|
+
// shims from the VM as a side effect of a runtime mount change.
|
|
1157
1216
|
await this.client.configureVm(this.session, this.vm, {
|
|
1158
1217
|
mounts: this.desiredSidecarMounts(),
|
|
1159
1218
|
permissions: this.permissions,
|
|
1160
1219
|
commandPermissions: this.commandPermissions,
|
|
1161
1220
|
loopbackExemptPorts: this.loopbackExemptPorts,
|
|
1221
|
+
packages: this.packages,
|
|
1222
|
+
packagesMountAt: this.packagesMountAt,
|
|
1223
|
+
bindingShimCommands: this.bindingShimCommands,
|
|
1162
1224
|
});
|
|
1163
1225
|
};
|
|
1164
1226
|
const previous = this.mountReconfigurePromise ?? Promise.resolve();
|
|
@@ -1203,11 +1265,17 @@ export class NativeSidecarKernelProxy {
|
|
|
1203
1265
|
}
|
|
1204
1266
|
getSignalState(pid) {
|
|
1205
1267
|
const entry = this.trackedProcesses.get(pid);
|
|
1206
|
-
if (entry
|
|
1207
|
-
this.
|
|
1208
|
-
}
|
|
1268
|
+
if (entry)
|
|
1269
|
+
this.scheduleSignalStateRefresh(entry);
|
|
1209
1270
|
return this.signalStates.get(pid) ?? { handlers: new Map() };
|
|
1210
1271
|
}
|
|
1272
|
+
scheduleSignalStateRefresh(entry) {
|
|
1273
|
+
if (this.signalRefreshes.has(entry.pid))
|
|
1274
|
+
return;
|
|
1275
|
+
const refresh = this.refreshSignalState(entry);
|
|
1276
|
+
this.signalRefreshes.set(entry.pid, refresh);
|
|
1277
|
+
void refresh.catch(() => { });
|
|
1278
|
+
}
|
|
1211
1279
|
async refreshSocketLookup(cache, key, lookup) {
|
|
1212
1280
|
try {
|
|
1213
1281
|
const socket = await lookup();
|
|
@@ -1299,7 +1367,11 @@ export class NativeSidecarKernelProxy {
|
|
|
1299
1367
|
entry.started = true;
|
|
1300
1368
|
this.updateTrackedProcessSnapshot(entry);
|
|
1301
1369
|
void this.refreshProcessSnapshot().catch(() => { });
|
|
1302
|
-
|
|
1370
|
+
// Signal metadata is advisory and must not hold process startup behind a
|
|
1371
|
+
// second sidecar RPC. Very short binding commands can finish while the
|
|
1372
|
+
// original execute response is still in flight; synchronously refreshing
|
|
1373
|
+
// here creates a circular wait with their output/exit delivery.
|
|
1374
|
+
this.scheduleSignalStateRefresh(entry);
|
|
1303
1375
|
void this.flushPendingStdin(entry).catch((error) => {
|
|
1304
1376
|
this.handleBackgroundProcessError(entry, error);
|
|
1305
1377
|
});
|
|
@@ -1327,10 +1399,7 @@ export class NativeSidecarKernelProxy {
|
|
|
1327
1399
|
}
|
|
1328
1400
|
entry.outputGeneration += 1;
|
|
1329
1401
|
void this.refreshProcessSnapshot().catch(() => { });
|
|
1330
|
-
|
|
1331
|
-
this.signalRefreshes.set(entry.pid, this.refreshSignalState(entry));
|
|
1332
|
-
await this.signalRefreshes.get(entry.pid);
|
|
1333
|
-
}
|
|
1402
|
+
this.scheduleSignalStateRefresh(entry);
|
|
1334
1403
|
const chunk = event.payload.chunk;
|
|
1335
1404
|
const listeners = event.payload.channel === "stdout"
|
|
1336
1405
|
? entry.onStdout
|
|
@@ -1957,21 +2026,27 @@ function isMissingHostProcessError(error) {
|
|
|
1957
2026
|
function errnoError(code, message) {
|
|
1958
2027
|
return Object.assign(new Error(`${code}: ${message}`), { code });
|
|
1959
2028
|
}
|
|
2029
|
+
// VirtualStat is a numeric, Node-default-shaped view: u64 fields above
|
|
2030
|
+
// Number.MAX_SAFE_INTEGER lose precision here, same as Node's non-bigint
|
|
2031
|
+
// fs.stat on the host.
|
|
1960
2032
|
function toVirtualStat(stat) {
|
|
1961
2033
|
return {
|
|
1962
2034
|
mode: stat.mode,
|
|
1963
|
-
size: stat.size,
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
2035
|
+
size: Number(stat.size),
|
|
2036
|
+
sizeExact: stat.size,
|
|
2037
|
+
blocks: Number(stat.blocks),
|
|
2038
|
+
dev: Number(stat.dev),
|
|
2039
|
+
rdev: Number(stat.rdev),
|
|
1967
2040
|
isDirectory: stat.is_directory,
|
|
1968
2041
|
isSymbolicLink: stat.is_symbolic_link,
|
|
1969
2042
|
atimeMs: stat.atime_ms,
|
|
1970
2043
|
mtimeMs: stat.mtime_ms,
|
|
1971
2044
|
ctimeMs: stat.ctime_ms,
|
|
1972
2045
|
birthtimeMs: stat.birthtime_ms,
|
|
1973
|
-
ino: stat.ino,
|
|
1974
|
-
|
|
2046
|
+
ino: Number(stat.ino),
|
|
2047
|
+
inoExact: stat.ino,
|
|
2048
|
+
nlink: Number(stat.nlink),
|
|
2049
|
+
nlinkExact: stat.nlink,
|
|
1975
2050
|
uid: stat.uid,
|
|
1976
2051
|
gid: stat.gid,
|
|
1977
2052
|
};
|
|
@@ -2004,7 +2079,7 @@ function socketLookupKey(kind, request) {
|
|
|
2004
2079
|
path: request.path ?? null,
|
|
2005
2080
|
});
|
|
2006
2081
|
}
|
|
2007
|
-
export {
|
|
2082
|
+
export { NativeSidecarProcessClient, SidecarEventBufferOverflow, SidecarProcess, SidecarProcessError, SidecarProcessExited, } from "./native-process-client.js";
|
|
2008
2083
|
export class AgentOsSidecarVmHandle {
|
|
2009
2084
|
client;
|
|
2010
2085
|
sessionId;
|
|
@@ -2042,17 +2117,18 @@ export class AgentOsSidecarSessionHandle {
|
|
|
2042
2117
|
}
|
|
2043
2118
|
}
|
|
2044
2119
|
export class AgentOsSidecarClient {
|
|
2045
|
-
|
|
2120
|
+
createOwnershipTransport;
|
|
2046
2121
|
createId;
|
|
2047
2122
|
now;
|
|
2048
2123
|
sessions = new Map();
|
|
2049
2124
|
disposed = false;
|
|
2050
2125
|
constructor(options) {
|
|
2051
|
-
this.
|
|
2126
|
+
this.createOwnershipTransport = options.createOwnershipTransport;
|
|
2052
2127
|
this.createId = options.createId ?? randomUUID;
|
|
2053
2128
|
this.now = options.now ?? Date.now;
|
|
2054
2129
|
}
|
|
2055
|
-
|
|
2130
|
+
/** Open a physical sidecar ownership scope, not a durable ACP session. */
|
|
2131
|
+
async createOwnershipSession(options = {}) {
|
|
2056
2132
|
this.assertActive();
|
|
2057
2133
|
const sessionId = this.createId();
|
|
2058
2134
|
const placement = clonePlacement(options.placement);
|
|
@@ -2071,7 +2147,7 @@ export class AgentOsSidecarClient {
|
|
|
2071
2147
|
};
|
|
2072
2148
|
this.sessions.set(sessionId, entry);
|
|
2073
2149
|
try {
|
|
2074
|
-
entry.transport = await this.
|
|
2150
|
+
entry.transport = await this.createOwnershipTransport({
|
|
2075
2151
|
sessionId,
|
|
2076
2152
|
placement: clonePlacement(placement),
|
|
2077
2153
|
metadata: cloneMetadata(metadata),
|
|
@@ -2237,6 +2313,8 @@ export function serializeMountConfigForSidecar(mount) {
|
|
|
2237
2313
|
if ("driver" in mount) {
|
|
2238
2314
|
return {
|
|
2239
2315
|
guestPath: mount.path,
|
|
2316
|
+
guestSource: mount.guestSource ?? "js_bridge",
|
|
2317
|
+
guestFstype: mount.guestFstype ?? "js_bridge",
|
|
2240
2318
|
readOnly: mount.readOnly ?? false,
|
|
2241
2319
|
plugin: {
|
|
2242
2320
|
id: "js_bridge",
|
|
@@ -2246,6 +2324,8 @@ export function serializeMountConfigForSidecar(mount) {
|
|
|
2246
2324
|
}
|
|
2247
2325
|
return {
|
|
2248
2326
|
guestPath: mount.path,
|
|
2327
|
+
guestSource: mount.guestSource ?? mount.plugin.id,
|
|
2328
|
+
guestFstype: mount.guestFstype ?? mount.plugin.id,
|
|
2249
2329
|
readOnly: mount.readOnly ?? false,
|
|
2250
2330
|
plugin: {
|
|
2251
2331
|
id: mount.plugin.id,
|
|
@@ -2254,6 +2334,14 @@ export function serializeMountConfigForSidecar(mount) {
|
|
|
2254
2334
|
};
|
|
2255
2335
|
}
|
|
2256
2336
|
export function serializeRootFilesystemForSidecar(config, bootstrapLower) {
|
|
2337
|
+
if (config?.type === "native") {
|
|
2338
|
+
return {
|
|
2339
|
+
mode: "ephemeral",
|
|
2340
|
+
disableDefaultBaseLayer: true,
|
|
2341
|
+
lowers: [],
|
|
2342
|
+
bootstrapEntries: [],
|
|
2343
|
+
};
|
|
2344
|
+
}
|
|
2257
2345
|
const lowerInputs = [
|
|
2258
2346
|
...(config?.lowers ?? []),
|
|
2259
2347
|
...(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,5 @@
|
|
|
1
|
-
export type {
|
|
1
|
+
export type { AgentOsCreateSidecarOptions, AgentOsLimits, AgentOsOptions, AgentOsSharedSidecarOptions, AgentOsSidecarConfig, AgentOsSidecarDescription, AgentExitEvent, AgentExitHandler, AgentRestartOutcome, AgentStderrEvent, AgentStderrHandler, AgentRegistryEntry, BatchReadResult, BatchWriteEntry, BatchWriteResult, DirEntry, DynamicMountDescriptor, ExportRootFilesystemOptions, HttpRequest, HttpResponse, LimitWarning, LimitWarningHandler, MountConfig, MountInfo, MountConfigJsonObject, MountConfigJsonPrimitive, MountConfigJsonValue, NativeMountConfig, NativeMountPluginDescriptor, NativeRootFilesystemConfig, OverlayMountConfig, OverlayRootFilesystemConfig, PlainMountConfig, ProcessTreeNode, ProcessExit, ProcessOutput, ReaddirEntry, ReaddirRecursiveOptions, RootFilesystemConfig, RootLowerInput, SpawnedProcessInfo, SpawnOptions, ShellData, ShellExit, ShellOptions, } from "./agent-os.js";
|
|
2
|
+
export type * from "./session-api.js";
|
|
2
3
|
/**
|
|
3
4
|
* An agent type id — the `name` of an `/opt/agentos` agent package manifest
|
|
4
5
|
* (e.g. `"pi"`, `"claude"`). Agents are resolved by the SIDECAR from the projected
|
|
@@ -6,12 +7,10 @@ export type { AgentCapabilities, AgentInfo, AgentOsCreateSidecarOptions, AgentOs
|
|
|
6
7
|
* passes only the name, so any manifest `name` is a valid agent type.
|
|
7
8
|
*/
|
|
8
9
|
export type AgentType = string;
|
|
9
|
-
export type { CronAction, CronEvent, CronEventHandler, CronJob, CronJobInfo, CronJobOptions, ScheduleDriver, ScheduleEntry, ScheduleHandle, } from "./cron/index.js";
|
|
10
|
+
export type { CronAction, CronActionInfo, CronEvent, CronEventHandler, CronJob, CronJobInfo, CronJobOptions, ScheduleDriver, ScheduleEntry, ScheduleHandle, } from "./cron/index.js";
|
|
10
11
|
export type { HostDirBackendOptions, HostDirMountPluginConfig, NodeModulesMountConfig, } from "./host-dir-mount.js";
|
|
11
|
-
export type {
|
|
12
|
-
export type { AcpTimeoutErrorData, JsonRpcError, JsonRpcErrorData, JsonRpcNotification, JsonRpcRequest, JsonRpcResponse, UnknownSessionErrorData, } from "./json-rpc.js";
|
|
12
|
+
export type { Binding, BindingExample, Bindings } from "./bindings.js";
|
|
13
13
|
export type { FilesystemSnapshotExport, LayerHandle, LayerStore, OverlayFilesystemMode, RootSnapshotExport, SnapshotImportSource, SnapshotLayerHandle, WritableLayerHandle, } from "./layers.js";
|
|
14
14
|
export type { SoftwareInput, SoftwareRoot } from "./packages.js";
|
|
15
15
|
export type { AgentBlock, PackageDescriptor, PackageRef, SoftwarePackageRef, } from "./agentos-package.js";
|
|
16
16
|
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 { PromptCapabilities } from "./agent-session-types.js";
|