@rivet-dev/agentos-runtime-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.
Files changed (238) hide show
  1. package/README.md +2 -2
  2. package/commands/[ +0 -0
  3. package/commands/_stubs +0 -0
  4. package/commands/acl_tools +0 -0
  5. package/commands/arch +0 -0
  6. package/commands/attr +0 -0
  7. package/commands/awk +0 -0
  8. package/commands/b2sum +0 -0
  9. package/commands/base32 +0 -0
  10. package/commands/base64 +0 -0
  11. package/commands/basename +0 -0
  12. package/commands/basenc +0 -0
  13. package/commands/bash +0 -0
  14. package/commands/bc +0 -0
  15. package/commands/cat +0 -0
  16. package/commands/chacl +0 -0
  17. package/commands/chcon +0 -0
  18. package/commands/chgrp +0 -0
  19. package/commands/chmod +0 -0
  20. package/commands/chown +0 -0
  21. package/commands/chroot +0 -0
  22. package/commands/cksum +0 -0
  23. package/commands/cmp +0 -0
  24. package/commands/column +0 -0
  25. package/commands/comm +0 -0
  26. package/commands/cp +0 -0
  27. package/commands/curl +0 -0
  28. package/commands/cut +0 -0
  29. package/commands/date +0 -0
  30. package/commands/dd +0 -0
  31. package/commands/df +0 -0
  32. package/commands/diff +0 -0
  33. package/commands/dir +0 -0
  34. package/commands/dircolors +0 -0
  35. package/commands/dirname +0 -0
  36. package/commands/du +0 -0
  37. package/commands/echo +0 -0
  38. package/commands/egrep +0 -0
  39. package/commands/env +0 -0
  40. package/commands/envsubst +0 -0
  41. package/commands/expand +0 -0
  42. package/commands/expr +0 -0
  43. package/commands/factor +0 -0
  44. package/commands/false +0 -0
  45. package/commands/fd +0 -0
  46. package/commands/fgrep +0 -0
  47. package/commands/file +0 -0
  48. package/commands/find +0 -0
  49. package/commands/findmnt +0 -0
  50. package/commands/fmt +0 -0
  51. package/commands/fold +0 -0
  52. package/commands/getent +0 -0
  53. package/commands/getfacl +0 -0
  54. package/commands/getfattr +0 -0
  55. package/commands/git +0 -0
  56. package/commands/git-receive-pack +0 -0
  57. package/commands/git-remote-http +0 -0
  58. package/commands/git-remote-https +0 -0
  59. package/commands/git-upload-archive +0 -0
  60. package/commands/git-upload-pack +0 -0
  61. package/commands/grep +0 -0
  62. package/commands/groups +0 -0
  63. package/commands/gunzip +0 -0
  64. package/commands/gzip +0 -0
  65. package/commands/head +0 -0
  66. package/commands/hostid +0 -0
  67. package/commands/hostname +0 -0
  68. package/commands/http-test +0 -0
  69. package/commands/id +0 -0
  70. package/commands/install +0 -0
  71. package/commands/join +0 -0
  72. package/commands/jq +0 -0
  73. package/commands/kill +0 -0
  74. package/commands/link +0 -0
  75. package/commands/ln +0 -0
  76. package/commands/logname +0 -0
  77. package/commands/ls +0 -0
  78. package/commands/md5sum +0 -0
  79. package/commands/mkdir +0 -0
  80. package/commands/mkfifo +0 -0
  81. package/commands/mknod +0 -0
  82. package/commands/mktemp +0 -0
  83. package/commands/more +0 -0
  84. package/commands/mount +0 -0
  85. package/commands/mv +0 -0
  86. package/commands/nice +0 -0
  87. package/commands/nl +0 -0
  88. package/commands/nohup +0 -0
  89. package/commands/nproc +0 -0
  90. package/commands/numfmt +0 -0
  91. package/commands/od +0 -0
  92. package/commands/paste +0 -0
  93. package/commands/pathchk +0 -0
  94. package/commands/pinky +0 -0
  95. package/commands/printenv +0 -0
  96. package/commands/printf +0 -0
  97. package/commands/ptx +0 -0
  98. package/commands/pwd +0 -0
  99. package/commands/readlink +0 -0
  100. package/commands/realpath +0 -0
  101. package/commands/rev +0 -0
  102. package/commands/rg +0 -0
  103. package/commands/rm +0 -0
  104. package/commands/rmdir +0 -0
  105. package/commands/runas +0 -0
  106. package/commands/runcon +0 -0
  107. package/commands/sed +0 -0
  108. package/commands/seq +0 -0
  109. package/commands/setfacl +0 -0
  110. package/commands/setfattr +0 -0
  111. package/commands/sh +0 -0
  112. package/commands/sha1sum +0 -0
  113. package/commands/sha224sum +0 -0
  114. package/commands/sha256sum +0 -0
  115. package/commands/sha384sum +0 -0
  116. package/commands/sha512sum +0 -0
  117. package/commands/shred +0 -0
  118. package/commands/shuf +0 -0
  119. package/commands/sleep +0 -0
  120. package/commands/sort +0 -0
  121. package/commands/spawn-test-host +0 -0
  122. package/commands/split +0 -0
  123. package/commands/sqlite3 +0 -0
  124. package/commands/ssh +0 -0
  125. package/commands/ssh-keysign +0 -0
  126. package/commands/ssh-sk-helper +0 -0
  127. package/commands/stat +0 -0
  128. package/commands/stdbuf +0 -0
  129. package/commands/strings +0 -0
  130. package/commands/stty +0 -0
  131. package/commands/su +0 -0
  132. package/commands/sum +0 -0
  133. package/commands/sync +0 -0
  134. package/commands/tac +0 -0
  135. package/commands/tail +0 -0
  136. package/commands/tar +0 -0
  137. package/commands/tee +0 -0
  138. package/commands/test +0 -0
  139. package/commands/timeout +0 -0
  140. package/commands/touch +0 -0
  141. package/commands/tr +0 -0
  142. package/commands/tree +0 -0
  143. package/commands/true +0 -0
  144. package/commands/truncate +0 -0
  145. package/commands/tsort +0 -0
  146. package/commands/tty +0 -0
  147. package/commands/uname +0 -0
  148. package/commands/unexpand +0 -0
  149. package/commands/uniq +0 -0
  150. package/commands/unlink +0 -0
  151. package/commands/unzip +0 -0
  152. package/commands/uptime +0 -0
  153. package/commands/users +0 -0
  154. package/commands/vdir +0 -0
  155. package/commands/wc +0 -0
  156. package/commands/wget +0 -0
  157. package/commands/which +0 -0
  158. package/commands/who +0 -0
  159. package/commands/whoami +0 -0
  160. package/commands/xargs +0 -0
  161. package/commands/xattr_tools +0 -0
  162. package/commands/xfs_io +0 -0
  163. package/commands/xu +0 -0
  164. package/commands/yes +0 -0
  165. package/commands/yq +0 -0
  166. package/commands/zcat +0 -0
  167. package/commands/zip +0 -0
  168. package/dist/binary.js +4 -3
  169. package/dist/descriptors.d.ts +2 -12
  170. package/dist/descriptors.js +10 -6
  171. package/dist/event-buffer.d.ts +14 -0
  172. package/dist/event-buffer.js +30 -1
  173. package/dist/frame-stream.d.ts +34 -0
  174. package/dist/frame-stream.js +121 -0
  175. package/dist/generated/AcpLimitsConfig.d.ts +16 -0
  176. package/dist/generated/BindingLimitsConfig.d.ts +10 -0
  177. package/dist/generated/CreateVmConfig.d.ts +4 -0
  178. package/dist/generated/ExecutionLimitsConfig.d.ts +5 -0
  179. package/dist/generated/ExecutionLimitsConfig.js +2 -0
  180. package/dist/generated/Http2LimitsConfig.d.ts +12 -0
  181. package/dist/generated/Http2LimitsConfig.js +2 -0
  182. package/dist/generated/JsRuntimeLimitsConfig.d.ts +1 -0
  183. package/dist/generated/MountPluginDescriptor.d.ts +1 -1
  184. package/dist/generated/ProcessLimitsConfig.d.ts +7 -0
  185. package/dist/generated/ProcessLimitsConfig.js +2 -0
  186. package/dist/generated/ReactorLimitsConfig.d.ts +23 -0
  187. package/dist/generated/ReactorLimitsConfig.js +2 -0
  188. package/dist/generated/SqliteLimitsConfig.d.ts +3 -0
  189. package/dist/generated/SqliteLimitsConfig.js +2 -0
  190. package/dist/generated/TlsLimitsConfig.d.ts +3 -0
  191. package/dist/generated/TlsLimitsConfig.js +2 -0
  192. package/dist/generated/UdpLimitsConfig.d.ts +4 -0
  193. package/dist/generated/UdpLimitsConfig.js +2 -0
  194. package/dist/generated/VmGroupConfig.d.ts +5 -0
  195. package/dist/generated/VmGroupConfig.js +2 -0
  196. package/dist/generated/VmLimitsConfig.d.ts +16 -2
  197. package/dist/generated/VmSqliteDescriptor.d.ts +10 -0
  198. package/dist/generated/VmSqliteDescriptor.js +2 -0
  199. package/dist/generated/VmUserAccountConfig.d.ts +9 -0
  200. package/dist/generated/VmUserAccountConfig.js +2 -0
  201. package/dist/generated/VmUserConfig.d.ts +19 -0
  202. package/dist/generated/VmUserConfig.js +1 -0
  203. package/dist/generated/WasmLimitsConfig.d.ts +1 -0
  204. package/dist/generated-protocol.d.ts +610 -2
  205. package/dist/generated-protocol.js +1534 -75
  206. package/dist/kernel-proxy.d.ts +4 -0
  207. package/dist/kernel-proxy.js +66 -34
  208. package/dist/native-client.d.ts +3 -3
  209. package/dist/native-client.js +43 -8
  210. package/dist/node-runtime-options-schema.d.ts +1 -1
  211. package/dist/node-runtime-options-schema.js +43 -1
  212. package/dist/node-runtime.d.ts +12 -3
  213. package/dist/node-runtime.js +13 -12
  214. package/dist/process.d.ts +5 -1
  215. package/dist/process.js +35 -8
  216. package/dist/protocol-client.d.ts +9 -2
  217. package/dist/protocol-client.js +127 -7
  218. package/dist/protocol-frames.d.ts +14 -3
  219. package/dist/protocol-frames.js +26 -1
  220. package/dist/protocol-schema.d.ts +1 -1
  221. package/dist/protocol-schema.js +1 -1
  222. package/dist/request-payloads.d.ts +100 -1
  223. package/dist/request-payloads.js +73 -2
  224. package/dist/response-payloads.d.ts +49 -1
  225. package/dist/response-payloads.js +51 -1
  226. package/dist/sidecar-errors.d.ts +22 -0
  227. package/dist/sidecar-errors.js +10 -0
  228. package/dist/sidecar-process.d.ts +20 -3
  229. package/dist/sidecar-process.js +104 -14
  230. package/dist/test-runtime.d.ts +25 -7
  231. package/dist/test-runtime.js +216 -69
  232. package/dist/vm-config.d.ts +5 -1
  233. package/package.json +16 -6
  234. package/commands/codex +0 -0
  235. package/commands/codex-exec +0 -0
  236. package/commands/http_get +0 -0
  237. package/dist/generated/ToolLimitsConfig.d.ts +0 -10
  238. /package/dist/generated/{ToolLimitsConfig.js → BindingLimitsConfig.js} +0 -0
@@ -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 {
@@ -239,6 +271,24 @@ export function fromGeneratedResponsePayload(payload) {
239
271
  type: "ext_result",
240
272
  envelope: fromGeneratedExtEnvelope(payload.val),
241
273
  };
274
+ case "ExecutionAcceptedResponse":
275
+ return { type: "execution_accepted", response: payload.val };
276
+ case "ExecutionCompletedResponse":
277
+ return { type: "execution_completed", response: payload.val };
278
+ case "ExecutionEvaluationResponse":
279
+ return { type: "execution_evaluation", response: payload.val };
280
+ case "TypeScriptCheckResponse":
281
+ return { type: "typescript_check", response: payload.val };
282
+ case "ExecutionDescriptorResponse":
283
+ return { type: "execution_descriptor", response: payload.val };
284
+ case "ExecutionListResponse":
285
+ return { type: "execution_list", response: payload.val };
286
+ case "ExecutionDeletedResponse":
287
+ return { type: "execution_deleted", response: payload.val };
288
+ case "ExecutionIoResponse":
289
+ return { type: "execution_io", response: payload.val };
290
+ case "ExecutionOutputPageResponse":
291
+ return { type: "execution_output_page", response: payload.val };
242
292
  }
243
293
  }
244
294
  function fromGeneratedAgentosProjectedAgent(agent) {
@@ -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;
@@ -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;
@@ -7,7 +7,8 @@ import type { SidecarProcessTransport } from "./sidecar-client.js";
7
7
  import { type LiveFsPermissionRule, type LivePatternPermissionRule, type LivePermissionMode, type LivePermissionScope, type LiveRulePermissions } from "./permissions.js";
8
8
  import type { LiveFilesystemOperation, LiveGuestRuntimeKind, LiveWasmPermissionTier } from "./protocol-maps.js";
9
9
  import { type LiveEventFrame, type LiveSidecarRequestHandler, type LiveSidecarRequestFrame, type LiveSidecarResponseFrame, type ProtocolFramePayloadCodec } from "./protocol-frames.js";
10
- import type { LiveGuestDirEntry } from "./response-payloads.js";
10
+ import { type LiveRequestPayload } from "./request-payloads.js";
11
+ import type { LiveGuestDirEntry, LiveResponsePayload } from "./response-payloads.js";
11
12
  import { type LiveGuestFilesystemStat } from "./state.js";
12
13
  export { SidecarProcessError, SidecarProcessExited, SidecarSilenceTimeout, } from "./sidecar-errors.js";
13
14
  export { SidecarEventBufferOverflow } from "./event-buffer.js";
@@ -105,6 +106,8 @@ export interface SidecarSpawnOptions {
105
106
  command?: string;
106
107
  args?: string[];
107
108
  eventBufferCapacity?: number;
109
+ gracefulExitMs?: number;
110
+ forceExitMs?: number;
108
111
  payloadCodec?: NativeTransportPayloadCodec;
109
112
  /**
110
113
  * Override the sidecar silence watchdog window (default 30s). Tests only —
@@ -150,6 +153,8 @@ export interface SidecarMountPluginDescriptor {
150
153
  }
151
154
  export interface SidecarMountDescriptor {
152
155
  guestPath: string;
156
+ guestSource?: string;
157
+ guestFstype?: string;
153
158
  readOnly: boolean;
154
159
  plugin: SidecarMountPluginDescriptor;
155
160
  }
@@ -242,7 +247,7 @@ export declare class SidecarProcess {
242
247
  packages?: SidecarPackageDescriptor[];
243
248
  packagesMountAt?: string;
244
249
  bootstrapCommands?: string[];
245
- toolShimCommands?: string[];
250
+ bindingShimCommands?: string[];
246
251
  }): Promise<SidecarVmConfiguredResponse>;
247
252
  /**
248
253
  * Runtime dynamic `linkSoftware`: project one package into the live
@@ -270,10 +275,16 @@ export declare class SidecarProcess {
270
275
  lowerLayerIds: string[];
271
276
  }): Promise<string>;
272
277
  bootstrapRootFilesystem(session: AuthenticatedSession, vm: CreatedVm, entries: RootFilesystemEntry[]): Promise<void>;
273
- snapshotRootFilesystem(session: AuthenticatedSession, vm: CreatedVm): Promise<RootFilesystemEntry[]>;
278
+ snapshotRootFilesystem(session: AuthenticatedSession, vm: CreatedVm, maxBytes: number): Promise<RootFilesystemEntry[]>;
279
+ listMounts(session: AuthenticatedSession, vm: CreatedVm): Promise<Array<{
280
+ path: string;
281
+ kind: string;
282
+ readOnly: boolean;
283
+ }>>;
274
284
  readFile(session: AuthenticatedSession, vm: CreatedVm, path: string): Promise<Uint8Array>;
275
285
  pread(session: AuthenticatedSession, vm: CreatedVm, path: string, offset: number, length: number): Promise<Uint8Array>;
276
286
  writeFile(session: AuthenticatedSession, vm: CreatedVm, path: string, content: string | Uint8Array): Promise<void>;
287
+ pwrite(session: AuthenticatedSession, vm: CreatedVm, path: string, offset: number, content: Uint8Array): Promise<void>;
277
288
  mkdir(session: AuthenticatedSession, vm: CreatedVm, path: string, options?: {
278
289
  recursive?: boolean;
279
290
  }): Promise<void>;
@@ -338,6 +349,10 @@ export declare class SidecarProcess {
338
349
  path: string;
339
350
  headersJson: string;
340
351
  body?: string;
352
+ bodyBase64?: string;
353
+ streamOperation?: "start" | "read" | "cancel";
354
+ streamId?: string;
355
+ maxBytes?: number;
341
356
  }): Promise<string>;
342
357
  getSignalState(session: AuthenticatedSession, vm: CreatedVm, processId: string): Promise<SidecarSignalState>;
343
358
  getZombieTimerCount(session: AuthenticatedSession, vm: CreatedVm): Promise<SidecarZombieTimerCount>;
@@ -354,6 +369,8 @@ export declare class SidecarProcess {
354
369
  waitForEvent(matcher: SidecarEventSelector | ((event: EventFrame) => boolean), timeoutMs?: number, options?: {
355
370
  signal?: AbortSignal;
356
371
  }): Promise<EventFrame>;
372
+ /** Internal semantic request entrypoint used by the AgentOS client surface. */
373
+ sendVmRequest(session: AuthenticatedSession, vm: CreatedVm, payload: LiveRequestPayload): Promise<LiveResponsePayload>;
357
374
  dispose(): Promise<void>;
358
375
  private sendRequest;
359
376
  private guestFilesystemCall;
@@ -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
  });
@@ -53,8 +53,8 @@ export class SidecarProcess {
53
53
  },
54
54
  payload: {
55
55
  type: "authenticate",
56
- client_name: "secure-exec-core-client",
57
- auth_token: "secure-exec-core-client-token",
56
+ client_name: "agentos-core-client",
57
+ auth_token: "agentos-core-client-token",
58
58
  protocol_version: SIDECAR_PROTOCOL_SCHEMA.version,
59
59
  bridge_version: BRIDGE_CONTRACT_VERSION,
60
60
  },
@@ -147,7 +147,7 @@ export class SidecarProcess {
147
147
  ? { packages_mount_at: options.packagesMountAt }
148
148
  : {}),
149
149
  bootstrap_commands: options.bootstrapCommands ?? [],
150
- tool_shim_commands: options.toolShimCommands ?? [],
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",
@@ -784,6 +814,18 @@ export class SidecarProcess {
784
814
  path: request.path,
785
815
  headers_json: request.headersJson,
786
816
  ...(request.body !== undefined ? { body: request.body } : {}),
817
+ ...(request.bodyBase64 !== undefined
818
+ ? { body_base64: request.bodyBase64 }
819
+ : {}),
820
+ ...(request.streamOperation !== undefined
821
+ ? { stream_operation: request.streamOperation }
822
+ : {}),
823
+ ...(request.streamId !== undefined
824
+ ? { stream_id: request.streamId }
825
+ : {}),
826
+ ...(request.maxBytes !== undefined
827
+ ? { max_bytes: request.maxBytes }
828
+ : {}),
787
829
  },
788
830
  });
789
831
  if (response.payload.type !== "vm_fetch_result") {
@@ -840,37 +882,83 @@ export class SidecarProcess {
840
882
  }
841
883
  async hostFilesystemCall(session, vm, request) {
842
884
  const response = await this.sendRequest({
843
- ownership: { scope: "vm", connection_id: session.connectionId, session_id: session.sessionId, vm_id: vm.vmId },
844
- payload: { type: "host_filesystem_call", operation: request.operation, path: request.path, payload_size_bytes: request.payloadSizeBytes },
885
+ ownership: {
886
+ scope: "vm",
887
+ connection_id: session.connectionId,
888
+ session_id: session.sessionId,
889
+ vm_id: vm.vmId,
890
+ },
891
+ payload: {
892
+ type: "host_filesystem_call",
893
+ operation: request.operation,
894
+ path: request.path,
895
+ payload_size_bytes: request.payloadSizeBytes,
896
+ },
845
897
  });
846
898
  if (response.payload.type !== "filesystem_result") {
847
899
  throw new Error(`unexpected host_filesystem_call response: ${response.payload.type}`);
848
900
  }
849
- return { operation: response.payload.operation, status: response.payload.status, payloadSizeBytes: response.payload.payload_size_bytes };
901
+ return {
902
+ operation: response.payload.operation,
903
+ status: response.payload.status,
904
+ payloadSizeBytes: response.payload.payload_size_bytes,
905
+ };
850
906
  }
851
907
  async persistenceLoad(session, key) {
852
908
  const response = await this.sendRequest({
853
- ownership: { scope: "session", connection_id: session.connectionId, session_id: session.sessionId },
909
+ ownership: {
910
+ scope: "session",
911
+ connection_id: session.connectionId,
912
+ session_id: session.sessionId,
913
+ },
854
914
  payload: { type: "persistence_load", key },
855
915
  });
856
916
  if (response.payload.type !== "persistence_state") {
857
917
  throw new Error(`unexpected persistence_load response: ${response.payload.type}`);
858
918
  }
859
- return { key: response.payload.key, found: response.payload.found, payloadSizeBytes: response.payload.payload_size_bytes };
919
+ return {
920
+ key: response.payload.key,
921
+ found: response.payload.found,
922
+ payloadSizeBytes: response.payload.payload_size_bytes,
923
+ };
860
924
  }
861
925
  async persistenceFlush(session, request) {
862
926
  const response = await this.sendRequest({
863
- ownership: { scope: "session", connection_id: session.connectionId, session_id: session.sessionId },
864
- payload: { type: "persistence_flush", key: request.key, payload_size_bytes: request.payloadSizeBytes },
927
+ ownership: {
928
+ scope: "session",
929
+ connection_id: session.connectionId,
930
+ session_id: session.sessionId,
931
+ },
932
+ payload: {
933
+ type: "persistence_flush",
934
+ key: request.key,
935
+ payload_size_bytes: request.payloadSizeBytes,
936
+ },
865
937
  });
866
938
  if (response.payload.type !== "persistence_flushed") {
867
939
  throw new Error(`unexpected persistence_flush response: ${response.payload.type}`);
868
940
  }
869
- return { key: response.payload.key, committedBytes: response.payload.committed_bytes };
941
+ return {
942
+ key: response.payload.key,
943
+ committedBytes: response.payload.committed_bytes,
944
+ };
870
945
  }
871
946
  async waitForEvent(matcher, timeoutMs, options) {
872
947
  return await this.protocolClient.waitForEvent(matcher, timeoutMs, options);
873
948
  }
949
+ /** Internal semantic request entrypoint used by the AgentOS client surface. */
950
+ async sendVmRequest(session, vm, payload) {
951
+ const response = await this.sendRequest({
952
+ ownership: {
953
+ scope: "vm",
954
+ connection_id: session.connectionId,
955
+ session_id: session.sessionId,
956
+ vm_id: vm.vmId,
957
+ },
958
+ payload,
959
+ });
960
+ return response.payload;
961
+ }
874
962
  async dispose() {
875
963
  await this.protocolClient.dispose();
876
964
  }
@@ -961,6 +1049,8 @@ function toWireRootFilesystemEntry(entry) {
961
1049
  function toWireMountDescriptor(descriptor) {
962
1050
  return {
963
1051
  guest_path: descriptor.guestPath,
1052
+ guest_source: descriptor.guestSource ?? descriptor.plugin.id,
1053
+ guest_fstype: descriptor.guestFstype ?? descriptor.plugin.id,
964
1054
  read_only: descriptor.readOnly,
965
1055
  plugin: {
966
1056
  id: descriptor.plugin.id,
@@ -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): Promise<void>;
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 HostToolExample {
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?: HostToolExample[];
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,14 +335,19 @@ 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;
335
342
  path: string;
336
343
  headersJson: string;
337
344
  body?: string;
345
+ bodyBase64?: string;
346
+ streamOperation?: "start" | "read" | "cancel";
347
+ streamId?: string;
348
+ maxBytes?: number;
338
349
  }): Promise<string>;
339
- registerHostTools(tools: Record<string, BindingDefinition>): Promise<void>;
350
+ registerBindings(bindings: Record<string, BindingDefinition>): Promise<void>;
340
351
  getResourceSnapshot(): Promise<{
341
352
  runningProcesses: number;
342
353
  exitedProcesses: number;
@@ -453,7 +464,9 @@ export declare class InMemoryFileSystem implements VirtualFileSystem {
453
464
  lstat(targetPath: string): Promise<VirtualStat>;
454
465
  link(oldPath: string, newPath: string): Promise<void>;
455
466
  chmod(targetPath: string, mode: number): Promise<void>;
456
- chown(targetPath: string, uid: number, gid: number): Promise<void>;
467
+ chown(targetPath: string, uid: number, gid: number, options?: {
468
+ followSymlinks?: boolean;
469
+ }): Promise<void>;
457
470
  utimes(targetPath: string, atime: number, mtime: number): Promise<void>;
458
471
  truncate(targetPath: string, length: number): Promise<void>;
459
472
  pread(targetPath: string, offset: number, length: number): Promise<Uint8Array>;
@@ -491,7 +504,9 @@ export declare class NodeFileSystem implements VirtualFileSystem {
491
504
  lstat(targetPath: string): Promise<VirtualStat>;
492
505
  link(oldPath: string, newPath: string): Promise<void>;
493
506
  chmod(targetPath: string, mode: number): Promise<void>;
494
- chown(targetPath: string, uid: number, gid: number): Promise<void>;
507
+ chown(targetPath: string, uid: number, gid: number, options?: {
508
+ followSymlinks?: boolean;
509
+ }): Promise<void>;
495
510
  utimes(targetPath: string, atime: number, mtime: number): Promise<void>;
496
511
  truncate(targetPath: string, length: number): Promise<void>;
497
512
  pread(targetPath: string, offset: number, length: number): Promise<Uint8Array>;
@@ -550,12 +565,14 @@ export declare function createKernel(options: {
550
565
  permissions?: Permissions;
551
566
  env?: Record<string, string>;
552
567
  cwd?: string;
568
+ user?: VmUserConfig;
553
569
  sidecar?: SidecarProcess;
554
570
  onBootTiming?: (timing: KernelBootTiming) => void;
555
571
  maxProcesses?: number;
556
572
  hostNetworkAdapter?: unknown;
557
573
  loopbackExemptPorts?: number[];
558
574
  jsRuntime?: Partial<JsRuntimeConfig>;
575
+ limits?: VmLimitsConfig;
559
576
  logger?: unknown;
560
577
  mounts?: Array<{
561
578
  path: string;
@@ -563,4 +580,5 @@ export declare function createKernel(options: {
563
580
  readOnly?: boolean;
564
581
  }>;
565
582
  syncFilesystemOnDispose?: boolean;
583
+ maxFilesystemBytes?: number;
566
584
  }): Kernel;