@rivet-dev/agentos-runtime-core 0.2.8-rc.1 → 0.2.8-rc.3
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 +1 -1
- package/commands/[ +0 -0
- package/commands/_stubs +0 -0
- package/commands/acl_tools +0 -0
- package/commands/arch +0 -0
- package/commands/attr +0 -0
- package/commands/awk +0 -0
- package/commands/b2sum +0 -0
- package/commands/base32 +0 -0
- package/commands/base64 +0 -0
- package/commands/basename +0 -0
- package/commands/basenc +0 -0
- package/commands/bash +0 -0
- package/commands/bc +0 -0
- package/commands/cat +0 -0
- package/commands/chacl +0 -0
- package/commands/chcon +0 -0
- package/commands/chgrp +0 -0
- package/commands/chmod +0 -0
- package/commands/chown +0 -0
- package/commands/chroot +0 -0
- package/commands/cksum +0 -0
- package/commands/cmp +0 -0
- package/commands/column +0 -0
- package/commands/comm +0 -0
- package/commands/cp +0 -0
- package/commands/curl +0 -0
- package/commands/cut +0 -0
- package/commands/date +0 -0
- package/commands/dd +0 -0
- package/commands/df +0 -0
- package/commands/diff +0 -0
- package/commands/dir +0 -0
- package/commands/dircolors +0 -0
- package/commands/dirname +0 -0
- package/commands/du +0 -0
- package/commands/echo +0 -0
- package/commands/egrep +0 -0
- package/commands/env +0 -0
- package/commands/envsubst +0 -0
- package/commands/expand +0 -0
- package/commands/expr +0 -0
- package/commands/factor +0 -0
- package/commands/false +0 -0
- package/commands/fd +0 -0
- package/commands/fgrep +0 -0
- package/commands/file +0 -0
- package/commands/find +0 -0
- package/commands/findmnt +0 -0
- package/commands/fmt +0 -0
- package/commands/fold +0 -0
- package/commands/getent +0 -0
- package/commands/getfacl +0 -0
- package/commands/getfattr +0 -0
- package/commands/git +0 -0
- package/commands/git-receive-pack +0 -0
- package/commands/git-remote-http +0 -0
- package/commands/git-remote-https +0 -0
- package/commands/git-upload-archive +0 -0
- package/commands/git-upload-pack +0 -0
- package/commands/grep +0 -0
- package/commands/groups +0 -0
- package/commands/gunzip +0 -0
- package/commands/gzip +0 -0
- package/commands/head +0 -0
- package/commands/hostid +0 -0
- package/commands/hostname +0 -0
- package/commands/http-test +0 -0
- package/commands/id +0 -0
- package/commands/install +0 -0
- package/commands/join +0 -0
- package/commands/jq +0 -0
- package/commands/kill +0 -0
- package/commands/link +0 -0
- package/commands/ln +0 -0
- package/commands/logname +0 -0
- package/commands/ls +0 -0
- package/commands/md5sum +0 -0
- package/commands/mkdir +0 -0
- package/commands/mkfifo +0 -0
- package/commands/mknod +0 -0
- package/commands/mktemp +0 -0
- package/commands/more +0 -0
- package/commands/mount +0 -0
- package/commands/mv +0 -0
- package/commands/nice +0 -0
- package/commands/nl +0 -0
- package/commands/nohup +0 -0
- package/commands/nproc +0 -0
- package/commands/numfmt +0 -0
- package/commands/od +0 -0
- package/commands/paste +0 -0
- package/commands/pathchk +0 -0
- package/commands/pinky +0 -0
- package/commands/printenv +0 -0
- package/commands/printf +0 -0
- package/commands/ptx +0 -0
- package/commands/pwd +0 -0
- package/commands/readlink +0 -0
- package/commands/realpath +0 -0
- package/commands/rev +0 -0
- package/commands/rg +0 -0
- package/commands/rm +0 -0
- package/commands/rmdir +0 -0
- package/commands/runas +0 -0
- package/commands/runcon +0 -0
- package/commands/sed +0 -0
- package/commands/seq +0 -0
- package/commands/setfacl +0 -0
- package/commands/setfattr +0 -0
- package/commands/sh +0 -0
- package/commands/sha1sum +0 -0
- package/commands/sha224sum +0 -0
- package/commands/sha256sum +0 -0
- package/commands/sha384sum +0 -0
- package/commands/sha512sum +0 -0
- package/commands/shred +0 -0
- package/commands/shuf +0 -0
- package/commands/sleep +0 -0
- package/commands/sort +0 -0
- package/commands/spawn-test-host +0 -0
- package/commands/split +0 -0
- package/commands/sqlite3 +0 -0
- package/commands/ssh +0 -0
- package/commands/ssh-keysign +0 -0
- package/commands/ssh-sk-helper +0 -0
- package/commands/stat +0 -0
- package/commands/stdbuf +0 -0
- package/commands/strings +0 -0
- package/commands/stty +0 -0
- package/commands/su +0 -0
- package/commands/sum +0 -0
- package/commands/sync +0 -0
- package/commands/tac +0 -0
- package/commands/tail +0 -0
- package/commands/tar +0 -0
- package/commands/tee +0 -0
- package/commands/test +0 -0
- package/commands/timeout +0 -0
- package/commands/touch +0 -0
- package/commands/tr +0 -0
- package/commands/tree +0 -0
- package/commands/true +0 -0
- package/commands/truncate +0 -0
- package/commands/tsort +0 -0
- package/commands/tty +0 -0
- package/commands/uname +0 -0
- package/commands/unexpand +0 -0
- package/commands/uniq +0 -0
- package/commands/unlink +0 -0
- package/commands/unzip +0 -0
- package/commands/uptime +0 -0
- package/commands/users +0 -0
- package/commands/vdir +0 -0
- package/commands/wc +0 -0
- package/commands/wget +0 -0
- package/commands/which +0 -0
- package/commands/who +0 -0
- package/commands/whoami +0 -0
- package/commands/xargs +0 -0
- package/commands/xattr_tools +0 -0
- package/commands/xfs_io +0 -0
- package/commands/xu +0 -0
- package/commands/yes +0 -0
- package/commands/yq +0 -0
- package/commands/zcat +0 -0
- package/commands/zip +0 -0
- package/dist/binary.js +4 -3
- package/dist/descriptors.d.ts +2 -12
- package/dist/descriptors.js +10 -6
- package/dist/frame-stream.d.ts +33 -0
- package/dist/frame-stream.js +113 -0
- package/dist/generated/AcpLimitsConfig.d.ts +16 -0
- package/dist/generated/BindingLimitsConfig.d.ts +10 -0
- package/dist/generated/CreateVmConfig.d.ts +4 -0
- package/dist/generated/Http2LimitsConfig.d.ts +12 -0
- package/dist/generated/Http2LimitsConfig.js +2 -0
- package/dist/generated/JsRuntimeLimitsConfig.d.ts +1 -0
- package/dist/generated/MountPluginDescriptor.d.ts +1 -1
- package/dist/generated/ProcessLimitsConfig.d.ts +7 -0
- package/dist/generated/ProcessLimitsConfig.js +2 -0
- package/dist/generated/ReactorLimitsConfig.d.ts +23 -0
- package/dist/generated/ReactorLimitsConfig.js +2 -0
- package/dist/generated/SqliteLimitsConfig.d.ts +3 -0
- package/dist/generated/SqliteLimitsConfig.js +2 -0
- package/dist/generated/TlsLimitsConfig.d.ts +3 -0
- package/dist/generated/TlsLimitsConfig.js +2 -0
- package/dist/generated/UdpLimitsConfig.d.ts +4 -0
- package/dist/generated/UdpLimitsConfig.js +2 -0
- package/dist/generated/VmGroupConfig.d.ts +5 -0
- package/dist/generated/VmGroupConfig.js +2 -0
- package/dist/generated/VmLimitsConfig.d.ts +14 -2
- package/dist/generated/VmSqliteDescriptor.d.ts +10 -0
- package/dist/generated/VmSqliteDescriptor.js +2 -0
- 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/VmUserConfig.js +1 -0
- package/dist/generated/WasmLimitsConfig.d.ts +1 -0
- package/dist/generated-protocol.d.ts +60 -2
- package/dist/generated-protocol.js +166 -31
- package/dist/kernel-proxy.d.ts +4 -0
- package/dist/kernel-proxy.js +65 -33
- package/dist/native-client.d.ts +3 -3
- package/dist/native-client.js +43 -8
- package/dist/node-runtime-options-schema.d.ts +1 -1
- package/dist/node-runtime-options-schema.js +43 -1
- package/dist/node-runtime.d.ts +12 -3
- package/dist/node-runtime.js +8 -7
- package/dist/process.d.ts +5 -1
- package/dist/process.js +35 -8
- package/dist/protocol-client.d.ts +9 -2
- package/dist/protocol-client.js +127 -7
- package/dist/protocol-frames.d.ts +14 -3
- package/dist/protocol-frames.js +26 -1
- package/dist/protocol-schema.d.ts +1 -1
- package/dist/protocol-schema.js +1 -1
- package/dist/request-payloads.d.ts +4 -1
- package/dist/request-payloads.js +7 -2
- package/dist/response-payloads.d.ts +22 -1
- package/dist/response-payloads.js +33 -1
- package/dist/sidecar-errors.d.ts +22 -0
- package/dist/sidecar-errors.js +10 -0
- package/dist/sidecar-process.d.ts +12 -2
- package/dist/sidecar-process.js +77 -12
- package/dist/test-runtime.d.ts +21 -7
- package/dist/test-runtime.js +213 -66
- package/dist/vm-config.d.ts +5 -1
- package/package.json +11 -6
- package/commands/codex +0 -0
- package/commands/codex-exec +0 -0
- package/commands/http_get +0 -0
- package/dist/generated/ToolLimitsConfig.d.ts +0 -10
- /package/dist/generated/{ToolLimitsConfig.js → BindingLimitsConfig.js} +0 -0
package/dist/protocol-schema.js
CHANGED
|
@@ -42,7 +42,7 @@ export type LiveRequestPayload = {
|
|
|
42
42
|
packages?: LivePackageDescriptor[];
|
|
43
43
|
packages_mount_at?: string;
|
|
44
44
|
bootstrap_commands?: string[];
|
|
45
|
-
|
|
45
|
+
binding_shim_commands?: string[];
|
|
46
46
|
} | {
|
|
47
47
|
type: "link_package";
|
|
48
48
|
package: LivePackageDescriptor;
|
|
@@ -79,6 +79,9 @@ export type LiveRequestPayload = {
|
|
|
79
79
|
lower_layer_ids: string[];
|
|
80
80
|
} | {
|
|
81
81
|
type: "snapshot_root_filesystem";
|
|
82
|
+
max_bytes: number;
|
|
83
|
+
} | {
|
|
84
|
+
type: "list_mounts";
|
|
82
85
|
} | {
|
|
83
86
|
type: "guest_kernel_call";
|
|
84
87
|
execution_id: string;
|
package/dist/request-payloads.js
CHANGED
|
@@ -58,7 +58,7 @@ export function toGeneratedRequestPayload(payload) {
|
|
|
58
58
|
packages: (payload.packages ?? []).map(toGeneratedPackageDescriptor),
|
|
59
59
|
packagesMountAt: payload.packages_mount_at ?? "",
|
|
60
60
|
bootstrapCommands: payload.bootstrap_commands ?? [],
|
|
61
|
-
|
|
61
|
+
bindingShimCommands: payload.binding_shim_commands ?? [],
|
|
62
62
|
},
|
|
63
63
|
};
|
|
64
64
|
case "link_package":
|
|
@@ -153,7 +153,12 @@ export function toGeneratedRequestPayload(payload) {
|
|
|
153
153
|
},
|
|
154
154
|
};
|
|
155
155
|
case "snapshot_root_filesystem":
|
|
156
|
-
return {
|
|
156
|
+
return {
|
|
157
|
+
tag: "SnapshotRootFilesystemRequest",
|
|
158
|
+
val: { maxBytes: BigInt(payload.max_bytes) },
|
|
159
|
+
};
|
|
160
|
+
case "list_mounts":
|
|
161
|
+
return { tag: "ListMountsRequest", val: null };
|
|
157
162
|
case "execute":
|
|
158
163
|
return {
|
|
159
164
|
tag: "ExecuteRequest",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type LiveRootFilesystemEntry, type LiveRootFilesystemEntryEncoding } from "./filesystem.js";
|
|
2
1
|
import { type LiveExtEnvelope } from "./ext.js";
|
|
2
|
+
import { type LiveRootFilesystemEntry, type LiveRootFilesystemEntryEncoding } from "./filesystem.js";
|
|
3
3
|
import type * as protocol from "./generated-protocol.js";
|
|
4
4
|
import { type LiveFilesystemOperation, type LiveGuestFilesystemOperation, type LiveSignalDispositionAction } from "./protocol-maps.js";
|
|
5
5
|
import { type LiveGuestFilesystemStat, type LiveProcessSnapshotEntry, type LiveSocketStateEntry } from "./state.js";
|
|
@@ -49,6 +49,11 @@ export interface LivePackageCommands {
|
|
|
49
49
|
package_name: string;
|
|
50
50
|
commands: string[];
|
|
51
51
|
}
|
|
52
|
+
export interface LiveMountInfo {
|
|
53
|
+
path: string;
|
|
54
|
+
kind: string;
|
|
55
|
+
read_only: boolean;
|
|
56
|
+
}
|
|
52
57
|
export interface LiveAgentosProjectedAgent {
|
|
53
58
|
id: string;
|
|
54
59
|
acp_entrypoint: string;
|
|
@@ -79,6 +84,9 @@ export type LiveResponsePayload = {
|
|
|
79
84
|
} | {
|
|
80
85
|
type: "provided_commands_response";
|
|
81
86
|
packages: LivePackageCommands[];
|
|
87
|
+
} | {
|
|
88
|
+
type: "mounts_listed";
|
|
89
|
+
mounts: LiveMountInfo[];
|
|
82
90
|
} | {
|
|
83
91
|
type: "host_callbacks_registered";
|
|
84
92
|
registration: string;
|
|
@@ -179,6 +187,19 @@ export type LiveResponsePayload = {
|
|
|
179
187
|
type: "rejected";
|
|
180
188
|
code: string;
|
|
181
189
|
message: string;
|
|
190
|
+
limit_name: string | null;
|
|
191
|
+
configured_limit: number | null;
|
|
192
|
+
current_usage: number | null;
|
|
193
|
+
requested: number | null;
|
|
194
|
+
unit: string | null;
|
|
195
|
+
scope: string | null;
|
|
196
|
+
vm_id: string | null;
|
|
197
|
+
session_generation: number | null;
|
|
198
|
+
capability_id: number | null;
|
|
199
|
+
operation: string | null;
|
|
200
|
+
configuration_path: string | null;
|
|
201
|
+
retryable: boolean | null;
|
|
202
|
+
errno: string | null;
|
|
182
203
|
} | {
|
|
183
204
|
type: "ext_result";
|
|
184
205
|
envelope: LiveExtEnvelope;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { fromGeneratedRootFilesystemEntry, } from "./filesystem.js";
|
|
2
1
|
import { fromGeneratedExtEnvelope } from "./ext.js";
|
|
2
|
+
import { fromGeneratedRootFilesystemEntry, } from "./filesystem.js";
|
|
3
3
|
import { bigIntToSafeNumber } from "./numbers.js";
|
|
4
4
|
import { fromGeneratedFilesystemOperation, fromGeneratedGuestFilesystemOperation, fromGeneratedRootFilesystemEntryEncoding, fromGeneratedSignalDispositionAction, } from "./protocol-maps.js";
|
|
5
5
|
import { fromGeneratedGuestFilesystemStat, fromGeneratedProcessSnapshotEntry, fromGeneratedSocketStateEntry, } from "./state.js";
|
|
@@ -55,6 +55,15 @@ export function fromGeneratedResponsePayload(payload) {
|
|
|
55
55
|
commands: [...pkg.commands],
|
|
56
56
|
})),
|
|
57
57
|
};
|
|
58
|
+
case "ListMountsResponse":
|
|
59
|
+
return {
|
|
60
|
+
type: "mounts_listed",
|
|
61
|
+
mounts: payload.val.mounts.map((mount) => ({
|
|
62
|
+
path: mount.path,
|
|
63
|
+
kind: mount.kind,
|
|
64
|
+
read_only: mount.readOnly,
|
|
65
|
+
})),
|
|
66
|
+
};
|
|
58
67
|
case "HostCallbacksRegisteredResponse":
|
|
59
68
|
return {
|
|
60
69
|
type: "host_callbacks_registered",
|
|
@@ -228,6 +237,29 @@ export function fromGeneratedResponsePayload(payload) {
|
|
|
228
237
|
type: "rejected",
|
|
229
238
|
code: payload.val.code,
|
|
230
239
|
message: payload.val.message,
|
|
240
|
+
limit_name: payload.val.limitName,
|
|
241
|
+
configured_limit: payload.val.configuredLimit === null
|
|
242
|
+
? null
|
|
243
|
+
: bigIntToSafeNumber(payload.val.configuredLimit, "rejected.configured_limit"),
|
|
244
|
+
current_usage: payload.val.currentUsage === null
|
|
245
|
+
? null
|
|
246
|
+
: bigIntToSafeNumber(payload.val.currentUsage, "rejected.current_usage"),
|
|
247
|
+
requested: payload.val.requested === null
|
|
248
|
+
? null
|
|
249
|
+
: bigIntToSafeNumber(payload.val.requested, "rejected.requested"),
|
|
250
|
+
unit: payload.val.unit,
|
|
251
|
+
scope: payload.val.scope,
|
|
252
|
+
vm_id: payload.val.vmId,
|
|
253
|
+
session_generation: payload.val.sessionGeneration === null
|
|
254
|
+
? null
|
|
255
|
+
: bigIntToSafeNumber(payload.val.sessionGeneration, "rejected.session_generation"),
|
|
256
|
+
capability_id: payload.val.capabilityId === null
|
|
257
|
+
? null
|
|
258
|
+
: bigIntToSafeNumber(payload.val.capabilityId, "rejected.capability_id"),
|
|
259
|
+
operation: payload.val.operation,
|
|
260
|
+
configuration_path: payload.val.configurationPath,
|
|
261
|
+
retryable: payload.val.retryable,
|
|
262
|
+
errno: payload.val.errno,
|
|
231
263
|
};
|
|
232
264
|
case "VmFetchResponse":
|
|
233
265
|
return {
|
package/dist/sidecar-errors.d.ts
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
export interface SidecarRejectionDetail {
|
|
2
|
+
code: string;
|
|
3
|
+
message: string;
|
|
4
|
+
limit_name: string | null;
|
|
5
|
+
configured_limit: number | null;
|
|
6
|
+
current_usage: number | null;
|
|
7
|
+
requested: number | null;
|
|
8
|
+
unit: string | null;
|
|
9
|
+
scope: string | null;
|
|
10
|
+
vm_id: string | null;
|
|
11
|
+
session_generation: number | null;
|
|
12
|
+
capability_id: number | null;
|
|
13
|
+
operation: string | null;
|
|
14
|
+
configuration_path: string | null;
|
|
15
|
+
retryable: boolean | null;
|
|
16
|
+
errno: string | null;
|
|
17
|
+
}
|
|
18
|
+
export declare class SidecarRejectedError extends Error {
|
|
19
|
+
readonly requestId: number;
|
|
20
|
+
readonly detail: SidecarRejectionDetail;
|
|
21
|
+
constructor(requestId: number, detail: SidecarRejectionDetail);
|
|
22
|
+
}
|
|
1
23
|
export declare class SidecarProcessExited extends Error {
|
|
2
24
|
readonly exitCode: number | null;
|
|
3
25
|
readonly signal: string | null;
|
package/dist/sidecar-errors.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
function formatSidecarStderrSuffix(stderr) {
|
|
2
2
|
return stderr ? `\nstderr:\n${stderr}` : "";
|
|
3
3
|
}
|
|
4
|
+
export class SidecarRejectedError extends Error {
|
|
5
|
+
requestId;
|
|
6
|
+
detail;
|
|
7
|
+
constructor(requestId, detail) {
|
|
8
|
+
super(`sidecar rejected request ${requestId}: ${detail.code}: ${detail.message}`);
|
|
9
|
+
this.name = "SidecarRejectedError";
|
|
10
|
+
this.requestId = requestId;
|
|
11
|
+
this.detail = detail;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
4
14
|
export class SidecarProcessExited extends Error {
|
|
5
15
|
exitCode;
|
|
6
16
|
signal;
|
|
@@ -105,6 +105,8 @@ export interface SidecarSpawnOptions {
|
|
|
105
105
|
command?: string;
|
|
106
106
|
args?: string[];
|
|
107
107
|
eventBufferCapacity?: number;
|
|
108
|
+
gracefulExitMs?: number;
|
|
109
|
+
forceExitMs?: number;
|
|
108
110
|
payloadCodec?: NativeTransportPayloadCodec;
|
|
109
111
|
/**
|
|
110
112
|
* Override the sidecar silence watchdog window (default 30s). Tests only —
|
|
@@ -150,6 +152,8 @@ export interface SidecarMountPluginDescriptor {
|
|
|
150
152
|
}
|
|
151
153
|
export interface SidecarMountDescriptor {
|
|
152
154
|
guestPath: string;
|
|
155
|
+
guestSource?: string;
|
|
156
|
+
guestFstype?: string;
|
|
153
157
|
readOnly: boolean;
|
|
154
158
|
plugin: SidecarMountPluginDescriptor;
|
|
155
159
|
}
|
|
@@ -242,7 +246,7 @@ export declare class SidecarProcess {
|
|
|
242
246
|
packages?: SidecarPackageDescriptor[];
|
|
243
247
|
packagesMountAt?: string;
|
|
244
248
|
bootstrapCommands?: string[];
|
|
245
|
-
|
|
249
|
+
bindingShimCommands?: string[];
|
|
246
250
|
}): Promise<SidecarVmConfiguredResponse>;
|
|
247
251
|
/**
|
|
248
252
|
* Runtime dynamic `linkSoftware`: project one package into the live
|
|
@@ -270,10 +274,16 @@ export declare class SidecarProcess {
|
|
|
270
274
|
lowerLayerIds: string[];
|
|
271
275
|
}): Promise<string>;
|
|
272
276
|
bootstrapRootFilesystem(session: AuthenticatedSession, vm: CreatedVm, entries: RootFilesystemEntry[]): Promise<void>;
|
|
273
|
-
snapshotRootFilesystem(session: AuthenticatedSession, vm: CreatedVm): Promise<RootFilesystemEntry[]>;
|
|
277
|
+
snapshotRootFilesystem(session: AuthenticatedSession, vm: CreatedVm, maxBytes: number): Promise<RootFilesystemEntry[]>;
|
|
278
|
+
listMounts(session: AuthenticatedSession, vm: CreatedVm): Promise<Array<{
|
|
279
|
+
path: string;
|
|
280
|
+
kind: string;
|
|
281
|
+
readOnly: boolean;
|
|
282
|
+
}>>;
|
|
274
283
|
readFile(session: AuthenticatedSession, vm: CreatedVm, path: string): Promise<Uint8Array>;
|
|
275
284
|
pread(session: AuthenticatedSession, vm: CreatedVm, path: string, offset: number, length: number): Promise<Uint8Array>;
|
|
276
285
|
writeFile(session: AuthenticatedSession, vm: CreatedVm, path: string, content: string | Uint8Array): Promise<void>;
|
|
286
|
+
pwrite(session: AuthenticatedSession, vm: CreatedVm, path: string, offset: number, content: Uint8Array): Promise<void>;
|
|
277
287
|
mkdir(session: AuthenticatedSession, vm: CreatedVm, path: string, options?: {
|
|
278
288
|
recursive?: boolean;
|
|
279
289
|
}): Promise<void>;
|
package/dist/sidecar-process.js
CHANGED
|
@@ -32,8 +32,8 @@ export class SidecarProcess {
|
|
|
32
32
|
cwd: options.cwd,
|
|
33
33
|
silenceTimeoutMs: options.silenceTimeoutMs,
|
|
34
34
|
eventBufferCapacity: options.eventBufferCapacity ?? DEFAULT_SIDECAR_EVENT_BUFFER_CAPACITY,
|
|
35
|
-
gracefulExitMs: DEFAULT_SIDECAR_GRACEFUL_EXIT_MS,
|
|
36
|
-
forceExitMs: DEFAULT_SIDECAR_FORCE_EXIT_MS,
|
|
35
|
+
gracefulExitMs: options.gracefulExitMs ?? DEFAULT_SIDECAR_GRACEFUL_EXIT_MS,
|
|
36
|
+
forceExitMs: options.forceExitMs ?? DEFAULT_SIDECAR_FORCE_EXIT_MS,
|
|
37
37
|
disposedErrorMessage: "native sidecar disposed",
|
|
38
38
|
payloadCodec: options.payloadCodec ?? "bare",
|
|
39
39
|
});
|
|
@@ -147,7 +147,7 @@ export class SidecarProcess {
|
|
|
147
147
|
? { packages_mount_at: options.packagesMountAt }
|
|
148
148
|
: {}),
|
|
149
149
|
bootstrap_commands: options.bootstrapCommands ?? [],
|
|
150
|
-
|
|
150
|
+
binding_shim_commands: options.bindingShimCommands ?? [],
|
|
151
151
|
},
|
|
152
152
|
});
|
|
153
153
|
if (response.payload.type !== "vm_configured") {
|
|
@@ -361,7 +361,7 @@ export class SidecarProcess {
|
|
|
361
361
|
throw new Error(`unexpected bootstrap_root_filesystem response: ${response.payload.type}`);
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
|
-
async snapshotRootFilesystem(session, vm) {
|
|
364
|
+
async snapshotRootFilesystem(session, vm, maxBytes) {
|
|
365
365
|
const response = await this.sendRequest({
|
|
366
366
|
ownership: {
|
|
367
367
|
scope: "vm",
|
|
@@ -371,6 +371,7 @@ export class SidecarProcess {
|
|
|
371
371
|
},
|
|
372
372
|
payload: {
|
|
373
373
|
type: "snapshot_root_filesystem",
|
|
374
|
+
max_bytes: maxBytes,
|
|
374
375
|
},
|
|
375
376
|
});
|
|
376
377
|
if (response.payload.type !== "root_filesystem_snapshot") {
|
|
@@ -378,6 +379,25 @@ export class SidecarProcess {
|
|
|
378
379
|
}
|
|
379
380
|
return response.payload.entries;
|
|
380
381
|
}
|
|
382
|
+
async listMounts(session, vm) {
|
|
383
|
+
const response = await this.sendRequest({
|
|
384
|
+
ownership: {
|
|
385
|
+
scope: "vm",
|
|
386
|
+
connection_id: session.connectionId,
|
|
387
|
+
session_id: session.sessionId,
|
|
388
|
+
vm_id: vm.vmId,
|
|
389
|
+
},
|
|
390
|
+
payload: { type: "list_mounts" },
|
|
391
|
+
});
|
|
392
|
+
if (response.payload.type !== "mounts_listed") {
|
|
393
|
+
throw new Error(`unexpected list_mounts response: ${response.payload.type}`);
|
|
394
|
+
}
|
|
395
|
+
return response.payload.mounts.map((mount) => ({
|
|
396
|
+
path: mount.path,
|
|
397
|
+
kind: mount.kind,
|
|
398
|
+
readOnly: mount.read_only,
|
|
399
|
+
}));
|
|
400
|
+
}
|
|
381
401
|
async readFile(session, vm, path) {
|
|
382
402
|
const response = await this.guestFilesystemCall(session, vm, {
|
|
383
403
|
operation: "read_file",
|
|
@@ -403,6 +423,16 @@ export class SidecarProcess {
|
|
|
403
423
|
encoding: encoded.encoding,
|
|
404
424
|
});
|
|
405
425
|
}
|
|
426
|
+
async pwrite(session, vm, path, offset, content) {
|
|
427
|
+
const encoded = encodeGuestFilesystemContent(content);
|
|
428
|
+
await this.guestFilesystemCall(session, vm, {
|
|
429
|
+
operation: "pwrite",
|
|
430
|
+
path,
|
|
431
|
+
offset,
|
|
432
|
+
content: encoded.content,
|
|
433
|
+
encoding: encoded.encoding,
|
|
434
|
+
});
|
|
435
|
+
}
|
|
406
436
|
async mkdir(session, vm, path, options) {
|
|
407
437
|
await this.guestFilesystemCall(session, vm, {
|
|
408
438
|
operation: options?.recursive ? "mkdir" : "create_dir",
|
|
@@ -840,33 +870,66 @@ export class SidecarProcess {
|
|
|
840
870
|
}
|
|
841
871
|
async hostFilesystemCall(session, vm, request) {
|
|
842
872
|
const response = await this.sendRequest({
|
|
843
|
-
ownership: {
|
|
844
|
-
|
|
873
|
+
ownership: {
|
|
874
|
+
scope: "vm",
|
|
875
|
+
connection_id: session.connectionId,
|
|
876
|
+
session_id: session.sessionId,
|
|
877
|
+
vm_id: vm.vmId,
|
|
878
|
+
},
|
|
879
|
+
payload: {
|
|
880
|
+
type: "host_filesystem_call",
|
|
881
|
+
operation: request.operation,
|
|
882
|
+
path: request.path,
|
|
883
|
+
payload_size_bytes: request.payloadSizeBytes,
|
|
884
|
+
},
|
|
845
885
|
});
|
|
846
886
|
if (response.payload.type !== "filesystem_result") {
|
|
847
887
|
throw new Error(`unexpected host_filesystem_call response: ${response.payload.type}`);
|
|
848
888
|
}
|
|
849
|
-
return {
|
|
889
|
+
return {
|
|
890
|
+
operation: response.payload.operation,
|
|
891
|
+
status: response.payload.status,
|
|
892
|
+
payloadSizeBytes: response.payload.payload_size_bytes,
|
|
893
|
+
};
|
|
850
894
|
}
|
|
851
895
|
async persistenceLoad(session, key) {
|
|
852
896
|
const response = await this.sendRequest({
|
|
853
|
-
ownership: {
|
|
897
|
+
ownership: {
|
|
898
|
+
scope: "session",
|
|
899
|
+
connection_id: session.connectionId,
|
|
900
|
+
session_id: session.sessionId,
|
|
901
|
+
},
|
|
854
902
|
payload: { type: "persistence_load", key },
|
|
855
903
|
});
|
|
856
904
|
if (response.payload.type !== "persistence_state") {
|
|
857
905
|
throw new Error(`unexpected persistence_load response: ${response.payload.type}`);
|
|
858
906
|
}
|
|
859
|
-
return {
|
|
907
|
+
return {
|
|
908
|
+
key: response.payload.key,
|
|
909
|
+
found: response.payload.found,
|
|
910
|
+
payloadSizeBytes: response.payload.payload_size_bytes,
|
|
911
|
+
};
|
|
860
912
|
}
|
|
861
913
|
async persistenceFlush(session, request) {
|
|
862
914
|
const response = await this.sendRequest({
|
|
863
|
-
ownership: {
|
|
864
|
-
|
|
915
|
+
ownership: {
|
|
916
|
+
scope: "session",
|
|
917
|
+
connection_id: session.connectionId,
|
|
918
|
+
session_id: session.sessionId,
|
|
919
|
+
},
|
|
920
|
+
payload: {
|
|
921
|
+
type: "persistence_flush",
|
|
922
|
+
key: request.key,
|
|
923
|
+
payload_size_bytes: request.payloadSizeBytes,
|
|
924
|
+
},
|
|
865
925
|
});
|
|
866
926
|
if (response.payload.type !== "persistence_flushed") {
|
|
867
927
|
throw new Error(`unexpected persistence_flush response: ${response.payload.type}`);
|
|
868
928
|
}
|
|
869
|
-
return {
|
|
929
|
+
return {
|
|
930
|
+
key: response.payload.key,
|
|
931
|
+
committedBytes: response.payload.committed_bytes,
|
|
932
|
+
};
|
|
870
933
|
}
|
|
871
934
|
async waitForEvent(matcher, timeoutMs, options) {
|
|
872
935
|
return await this.protocolClient.waitForEvent(matcher, timeoutMs, options);
|
|
@@ -961,6 +1024,8 @@ function toWireRootFilesystemEntry(entry) {
|
|
|
961
1024
|
function toWireMountDescriptor(descriptor) {
|
|
962
1025
|
return {
|
|
963
1026
|
guest_path: descriptor.guestPath,
|
|
1027
|
+
guest_source: descriptor.guestSource ?? descriptor.plugin.id,
|
|
1028
|
+
guest_fstype: descriptor.guestFstype ?? descriptor.plugin.id,
|
|
964
1029
|
read_only: descriptor.readOnly,
|
|
965
1030
|
plugin: {
|
|
966
1031
|
id: descriptor.plugin.id,
|
package/dist/test-runtime.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import "./native-client.js";
|
|
2
|
-
import { SidecarProcess } from "./kernel-proxy.js";
|
|
3
2
|
import type { JsRuntimeConfig } from "./generated/JsRuntimeConfig.js";
|
|
3
|
+
import type { VmLimitsConfig } from "./generated/VmLimitsConfig.js";
|
|
4
|
+
import type { VmUserConfig } from "./generated/VmUserConfig.js";
|
|
5
|
+
import { SidecarProcess } from "./kernel-proxy.js";
|
|
4
6
|
export declare const AF_INET = 2;
|
|
5
7
|
export declare const AF_UNIX = 1;
|
|
6
8
|
export declare const SOCK_STREAM = 1;
|
|
@@ -61,7 +63,9 @@ export interface VirtualFileSystem {
|
|
|
61
63
|
lstat(path: string): Promise<VirtualStat>;
|
|
62
64
|
link(oldPath: string, newPath: string): Promise<void>;
|
|
63
65
|
chmod(path: string, mode: number): Promise<void>;
|
|
64
|
-
chown(path: string, uid: number, gid: number
|
|
66
|
+
chown(path: string, uid: number, gid: number, options?: {
|
|
67
|
+
followSymlinks?: boolean;
|
|
68
|
+
}): Promise<void>;
|
|
65
69
|
utimes(path: string, atime: number, mtime: number): Promise<void>;
|
|
66
70
|
truncate(path: string, length: number): Promise<void>;
|
|
67
71
|
pread(path: string, offset: number, length: number): Promise<Uint8Array>;
|
|
@@ -118,6 +122,7 @@ export interface ManagedProcess {
|
|
|
118
122
|
export interface ShellHandle {
|
|
119
123
|
pid: number;
|
|
120
124
|
write(data: Uint8Array | string): void;
|
|
125
|
+
/** Ordered PTY output containing stdout and stderr exactly once. */
|
|
121
126
|
onData: ((data: Uint8Array) => void) | null;
|
|
122
127
|
resize(cols: number, rows: number): void;
|
|
123
128
|
kill(signal?: number): void;
|
|
@@ -130,6 +135,7 @@ export interface OpenShellOptions {
|
|
|
130
135
|
cwd?: string;
|
|
131
136
|
cols?: number;
|
|
132
137
|
rows?: number;
|
|
138
|
+
/** Optional stderr-only diagnostic tap; do not render it alongside `onData`. */
|
|
133
139
|
onStderr?: (data: Uint8Array) => void;
|
|
134
140
|
}
|
|
135
141
|
export interface ConnectTerminalOptions extends OpenShellOptions {
|
|
@@ -182,7 +188,7 @@ export interface Permissions {
|
|
|
182
188
|
binding?: BindingPermissions;
|
|
183
189
|
}
|
|
184
190
|
/** A worked example shown alongside a registered binding. */
|
|
185
|
-
export interface
|
|
191
|
+
export interface BindingExample {
|
|
186
192
|
/** What this example demonstrates. */
|
|
187
193
|
description: string;
|
|
188
194
|
/** Example input matching the binding's input schema. */
|
|
@@ -204,7 +210,7 @@ export interface BindingDefinition {
|
|
|
204
210
|
/** Abort the invocation after this many milliseconds. */
|
|
205
211
|
timeoutMs?: number;
|
|
206
212
|
/** Worked examples shown alongside the binding. */
|
|
207
|
-
examples?:
|
|
213
|
+
examples?: BindingExample[];
|
|
208
214
|
/**
|
|
209
215
|
* Extra command names the guest can use to invoke this binding, in addition
|
|
210
216
|
* to the key it is registered under.
|
|
@@ -329,6 +335,7 @@ export interface Kernel extends KernelInterface {
|
|
|
329
335
|
removeFile(path: string): Promise<void>;
|
|
330
336
|
removeDir(path: string): Promise<void>;
|
|
331
337
|
rename(oldPath: string, newPath: string): Promise<void>;
|
|
338
|
+
pwrite(path: string, offset: number, data: Uint8Array): Promise<void>;
|
|
332
339
|
vmFetch(request: {
|
|
333
340
|
port: number;
|
|
334
341
|
method: string;
|
|
@@ -336,7 +343,7 @@ export interface Kernel extends KernelInterface {
|
|
|
336
343
|
headersJson: string;
|
|
337
344
|
body?: string;
|
|
338
345
|
}): Promise<string>;
|
|
339
|
-
|
|
346
|
+
registerBindings(bindings: Record<string, BindingDefinition>): Promise<void>;
|
|
340
347
|
getResourceSnapshot(): Promise<{
|
|
341
348
|
runningProcesses: number;
|
|
342
349
|
exitedProcesses: number;
|
|
@@ -453,7 +460,9 @@ export declare class InMemoryFileSystem implements VirtualFileSystem {
|
|
|
453
460
|
lstat(targetPath: string): Promise<VirtualStat>;
|
|
454
461
|
link(oldPath: string, newPath: string): Promise<void>;
|
|
455
462
|
chmod(targetPath: string, mode: number): Promise<void>;
|
|
456
|
-
chown(targetPath: string, uid: number, gid: number
|
|
463
|
+
chown(targetPath: string, uid: number, gid: number, options?: {
|
|
464
|
+
followSymlinks?: boolean;
|
|
465
|
+
}): Promise<void>;
|
|
457
466
|
utimes(targetPath: string, atime: number, mtime: number): Promise<void>;
|
|
458
467
|
truncate(targetPath: string, length: number): Promise<void>;
|
|
459
468
|
pread(targetPath: string, offset: number, length: number): Promise<Uint8Array>;
|
|
@@ -491,7 +500,9 @@ export declare class NodeFileSystem implements VirtualFileSystem {
|
|
|
491
500
|
lstat(targetPath: string): Promise<VirtualStat>;
|
|
492
501
|
link(oldPath: string, newPath: string): Promise<void>;
|
|
493
502
|
chmod(targetPath: string, mode: number): Promise<void>;
|
|
494
|
-
chown(targetPath: string, uid: number, gid: number
|
|
503
|
+
chown(targetPath: string, uid: number, gid: number, options?: {
|
|
504
|
+
followSymlinks?: boolean;
|
|
505
|
+
}): Promise<void>;
|
|
495
506
|
utimes(targetPath: string, atime: number, mtime: number): Promise<void>;
|
|
496
507
|
truncate(targetPath: string, length: number): Promise<void>;
|
|
497
508
|
pread(targetPath: string, offset: number, length: number): Promise<Uint8Array>;
|
|
@@ -550,12 +561,14 @@ export declare function createKernel(options: {
|
|
|
550
561
|
permissions?: Permissions;
|
|
551
562
|
env?: Record<string, string>;
|
|
552
563
|
cwd?: string;
|
|
564
|
+
user?: VmUserConfig;
|
|
553
565
|
sidecar?: SidecarProcess;
|
|
554
566
|
onBootTiming?: (timing: KernelBootTiming) => void;
|
|
555
567
|
maxProcesses?: number;
|
|
556
568
|
hostNetworkAdapter?: unknown;
|
|
557
569
|
loopbackExemptPorts?: number[];
|
|
558
570
|
jsRuntime?: Partial<JsRuntimeConfig>;
|
|
571
|
+
limits?: VmLimitsConfig;
|
|
559
572
|
logger?: unknown;
|
|
560
573
|
mounts?: Array<{
|
|
561
574
|
path: string;
|
|
@@ -563,4 +576,5 @@ export declare function createKernel(options: {
|
|
|
563
576
|
readOnly?: boolean;
|
|
564
577
|
}>;
|
|
565
578
|
syncFilesystemOnDispose?: boolean;
|
|
579
|
+
maxFilesystemBytes?: number;
|
|
566
580
|
}): Kernel;
|