@rivet-dev/agentos-runtime-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.
Files changed (240) hide show
  1. package/README.md +1 -1
  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/correlation.d.ts +1 -4
  170. package/dist/correlation.js +7 -10
  171. package/dist/descriptors.d.ts +2 -12
  172. package/dist/descriptors.js +10 -6
  173. package/dist/frame-rpc.d.ts +9 -4
  174. package/dist/frame-rpc.js +19 -2
  175. package/dist/frame-stream.d.ts +33 -0
  176. package/dist/frame-stream.js +113 -0
  177. package/dist/generated/AcpLimitsConfig.d.ts +16 -0
  178. package/dist/generated/BindingLimitsConfig.d.ts +10 -0
  179. package/dist/generated/CreateVmConfig.d.ts +4 -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 +14 -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 +60 -2
  205. package/dist/generated-protocol.js +166 -31
  206. package/dist/kernel-proxy.d.ts +5 -1
  207. package/dist/kernel-proxy.js +82 -40
  208. package/dist/native-client.d.ts +9 -5
  209. package/dist/native-client.js +56 -11
  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 +8 -7
  214. package/dist/process.d.ts +5 -1
  215. package/dist/process.js +35 -8
  216. package/dist/protocol-client.d.ts +28 -4
  217. package/dist/protocol-client.js +193 -12
  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 +4 -1
  223. package/dist/request-payloads.js +7 -2
  224. package/dist/response-payloads.d.ts +23 -2
  225. package/dist/response-payloads.js +34 -2
  226. package/dist/sidecar-errors.d.ts +37 -0
  227. package/dist/sidecar-errors.js +27 -0
  228. package/dist/sidecar-process.d.ts +20 -6
  229. package/dist/sidecar-process.js +79 -15
  230. package/dist/state.d.ts +6 -6
  231. package/dist/state.js +10 -11
  232. package/dist/test-runtime.d.ts +24 -7
  233. package/dist/test-runtime.js +213 -67
  234. package/dist/vm-config.d.ts +5 -1
  235. package/package.json +11 -6
  236. package/commands/codex +0 -0
  237. package/commands/codex-exec +0 -0
  238. package/commands/http_get +0 -0
  239. package/dist/generated/ToolLimitsConfig.d.ts +0 -10
  240. /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",
@@ -95,7 +104,7 @@ export function fromGeneratedResponsePayload(payload) {
95
104
  path: entry.path,
96
105
  isDirectory: entry.isDirectory,
97
106
  isSymbolicLink: entry.isSymbolicLink,
98
- size: bigIntToSafeNumber(entry.size, "guest dir entry size"),
107
+ size: entry.size,
99
108
  })),
100
109
  }
101
110
  : {}),
@@ -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 {
@@ -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;
@@ -8,6 +30,21 @@ export declare class SidecarProcessExited extends Error {
8
30
  stderr: string;
9
31
  });
10
32
  }
33
+ /**
34
+ * The silence watchdog fired: the sidecar produced no protocol frames at all —
35
+ * not even its 10s liveness heartbeats — for the full silence window, so the
36
+ * process is dead or wedged (not merely busy: a busy sidecar still heartbeats
37
+ * from a dedicated thread). The host kills the sidecar and rejects every
38
+ * in-flight request with this error.
39
+ */
40
+ export declare class SidecarSilenceTimeout extends Error {
41
+ readonly silenceMs: number;
42
+ readonly stderr: string;
43
+ constructor(options: {
44
+ silenceMs: number;
45
+ stderr: string;
46
+ });
47
+ }
11
48
  export declare class SidecarProcessError extends Error {
12
49
  readonly childError: Error;
13
50
  readonly stderr: string;
@@ -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;
@@ -18,6 +28,23 @@ export class SidecarProcessExited extends Error {
18
28
  this.stderr = options.stderr;
19
29
  }
20
30
  }
31
+ /**
32
+ * The silence watchdog fired: the sidecar produced no protocol frames at all —
33
+ * not even its 10s liveness heartbeats — for the full silence window, so the
34
+ * process is dead or wedged (not merely busy: a busy sidecar still heartbeats
35
+ * from a dedicated thread). The host kills the sidecar and rejects every
36
+ * in-flight request with this error.
37
+ */
38
+ export class SidecarSilenceTimeout extends Error {
39
+ silenceMs;
40
+ stderr;
41
+ constructor(options) {
42
+ super(`sidecar unresponsive: no protocol frames or heartbeats for ${Math.round(options.silenceMs)}ms; killing sidecar${formatSidecarStderrSuffix(options.stderr)}`);
43
+ this.name = "SidecarSilenceTimeout";
44
+ this.silenceMs = options.silenceMs;
45
+ this.stderr = options.stderr;
46
+ }
47
+ }
21
48
  export class SidecarProcessError extends Error {
22
49
  childError;
23
50
  stderr;
@@ -9,10 +9,9 @@ import type { LiveFilesystemOperation, LiveGuestRuntimeKind, LiveWasmPermissionT
9
9
  import { type LiveEventFrame, type LiveSidecarRequestHandler, type LiveSidecarRequestFrame, type LiveSidecarResponseFrame, type ProtocolFramePayloadCodec } from "./protocol-frames.js";
10
10
  import type { LiveGuestDirEntry } from "./response-payloads.js";
11
11
  import { type LiveGuestFilesystemStat } from "./state.js";
12
- export { SidecarProcessError, SidecarProcessExited, } from "./sidecar-errors.js";
12
+ export { SidecarProcessError, SidecarProcessExited, SidecarSilenceTimeout, } from "./sidecar-errors.js";
13
13
  export { SidecarEventBufferOverflow } from "./event-buffer.js";
14
14
  export { SidecarProcess as Sidecar };
15
- export declare const NATIVE_SIDECAR_FRAME_TIMEOUT_MS = 120000;
16
15
  type GuestRuntimeKind = Extract<LiveGuestRuntimeKind, "java_script" | "python" | "web_assembly">;
17
16
  type WasmPermissionTier = LiveWasmPermissionTier;
18
17
  export interface RootFilesystemEntry extends LiveRootFilesystemEntry {
@@ -105,20 +104,27 @@ export interface SidecarSpawnOptions {
105
104
  cwd?: string;
106
105
  command?: string;
107
106
  args?: string[];
108
- frameTimeoutMs?: number;
109
107
  eventBufferCapacity?: number;
108
+ gracefulExitMs?: number;
109
+ forceExitMs?: number;
110
110
  payloadCodec?: NativeTransportPayloadCodec;
111
+ /**
112
+ * Override the sidecar silence watchdog window (default 30s). Tests only —
113
+ * it is a fixed protocol constant paired with the sidecar's 10s heartbeat
114
+ * cadence, not an operator tunable.
115
+ */
116
+ silenceTimeoutMs?: number;
111
117
  }
112
118
  export interface ResolvedSidecarSpawnOptions {
113
119
  cwd?: string;
114
120
  command?: string;
115
121
  args: string[];
116
- frameTimeoutMs: number;
117
122
  eventBufferCapacity: number;
118
123
  gracefulExitMs: number;
119
124
  forceExitMs: number;
120
125
  disposedErrorMessage: string;
121
126
  payloadCodec: NativeTransportPayloadCodec;
127
+ silenceTimeoutMs?: number;
122
128
  }
123
129
  type SidecarProcessSpawnFactory = (options: ResolvedSidecarSpawnOptions) => SidecarProcessTransport;
124
130
  export declare function registerSidecarProcessSpawnFactory(factory: SidecarProcessSpawnFactory): void;
@@ -146,6 +152,8 @@ export interface SidecarMountPluginDescriptor {
146
152
  }
147
153
  export interface SidecarMountDescriptor {
148
154
  guestPath: string;
155
+ guestSource?: string;
156
+ guestFstype?: string;
149
157
  readOnly: boolean;
150
158
  plugin: SidecarMountPluginDescriptor;
151
159
  }
@@ -238,7 +246,7 @@ export declare class SidecarProcess {
238
246
  packages?: SidecarPackageDescriptor[];
239
247
  packagesMountAt?: string;
240
248
  bootstrapCommands?: string[];
241
- toolShimCommands?: string[];
249
+ bindingShimCommands?: string[];
242
250
  }): Promise<SidecarVmConfiguredResponse>;
243
251
  /**
244
252
  * Runtime dynamic `linkSoftware`: project one package into the live
@@ -266,10 +274,16 @@ export declare class SidecarProcess {
266
274
  lowerLayerIds: string[];
267
275
  }): Promise<string>;
268
276
  bootstrapRootFilesystem(session: AuthenticatedSession, vm: CreatedVm, entries: RootFilesystemEntry[]): Promise<void>;
269
- 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
+ }>>;
270
283
  readFile(session: AuthenticatedSession, vm: CreatedVm, path: string): Promise<Uint8Array>;
271
284
  pread(session: AuthenticatedSession, vm: CreatedVm, path: string, offset: number, length: number): Promise<Uint8Array>;
272
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>;
273
287
  mkdir(session: AuthenticatedSession, vm: CreatedVm, path: string, options?: {
274
288
  recursive?: boolean;
275
289
  }): Promise<void>;
@@ -1,13 +1,12 @@
1
1
  import { decodeGuestFilesystemContent, encodeGuestFilesystemContent, } from "./filesystem.js";
2
2
  import { SIDECAR_PROTOCOL_SCHEMA } from "./protocol-schema.js";
3
- export { SidecarProcessError, SidecarProcessExited, } from "./sidecar-errors.js";
3
+ export { SidecarProcessError, SidecarProcessExited, SidecarSilenceTimeout, } from "./sidecar-errors.js";
4
4
  export { SidecarEventBufferOverflow } from "./event-buffer.js";
5
5
  // `Sidecar` is the public name for the native sidecar process client. The class
6
6
  // is `SidecarProcess` internally; consumers import it as `Sidecar` via the
7
7
  // `@rivet-dev/agentos-runtime-core/sidecar-client` subpath and the package root.
8
8
  export { SidecarProcess as Sidecar };
9
9
  const BRIDGE_CONTRACT_VERSION = 1;
10
- export const NATIVE_SIDECAR_FRAME_TIMEOUT_MS = 120_000;
11
10
  const DEFAULT_SIDECAR_EVENT_BUFFER_CAPACITY = 4_096;
12
11
  const DEFAULT_SIDECAR_GRACEFUL_EXIT_MS = 5_000;
13
12
  const DEFAULT_SIDECAR_FORCE_EXIT_MS = 2_000;
@@ -31,10 +30,10 @@ export class SidecarProcess {
31
30
  command: options.command,
32
31
  args: options.args ?? [],
33
32
  cwd: options.cwd,
34
- frameTimeoutMs: options.frameTimeoutMs ?? NATIVE_SIDECAR_FRAME_TIMEOUT_MS,
33
+ silenceTimeoutMs: options.silenceTimeoutMs,
35
34
  eventBufferCapacity: options.eventBufferCapacity ?? DEFAULT_SIDECAR_EVENT_BUFFER_CAPACITY,
36
- gracefulExitMs: DEFAULT_SIDECAR_GRACEFUL_EXIT_MS,
37
- forceExitMs: DEFAULT_SIDECAR_FORCE_EXIT_MS,
35
+ gracefulExitMs: options.gracefulExitMs ?? DEFAULT_SIDECAR_GRACEFUL_EXIT_MS,
36
+ forceExitMs: options.forceExitMs ?? DEFAULT_SIDECAR_FORCE_EXIT_MS,
38
37
  disposedErrorMessage: "native sidecar disposed",
39
38
  payloadCodec: options.payloadCodec ?? "bare",
40
39
  });
@@ -148,7 +147,7 @@ export class SidecarProcess {
148
147
  ? { packages_mount_at: options.packagesMountAt }
149
148
  : {}),
150
149
  bootstrap_commands: options.bootstrapCommands ?? [],
151
- tool_shim_commands: options.toolShimCommands ?? [],
150
+ binding_shim_commands: options.bindingShimCommands ?? [],
152
151
  },
153
152
  });
154
153
  if (response.payload.type !== "vm_configured") {
@@ -362,7 +361,7 @@ export class SidecarProcess {
362
361
  throw new Error(`unexpected bootstrap_root_filesystem response: ${response.payload.type}`);
363
362
  }
364
363
  }
365
- async snapshotRootFilesystem(session, vm) {
364
+ async snapshotRootFilesystem(session, vm, maxBytes) {
366
365
  const response = await this.sendRequest({
367
366
  ownership: {
368
367
  scope: "vm",
@@ -372,6 +371,7 @@ export class SidecarProcess {
372
371
  },
373
372
  payload: {
374
373
  type: "snapshot_root_filesystem",
374
+ max_bytes: maxBytes,
375
375
  },
376
376
  });
377
377
  if (response.payload.type !== "root_filesystem_snapshot") {
@@ -379,6 +379,25 @@ export class SidecarProcess {
379
379
  }
380
380
  return response.payload.entries;
381
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
+ }
382
401
  async readFile(session, vm, path) {
383
402
  const response = await this.guestFilesystemCall(session, vm, {
384
403
  operation: "read_file",
@@ -404,6 +423,16 @@ export class SidecarProcess {
404
423
  encoding: encoded.encoding,
405
424
  });
406
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
+ }
407
436
  async mkdir(session, vm, path, options) {
408
437
  await this.guestFilesystemCall(session, vm, {
409
438
  operation: options?.recursive ? "mkdir" : "create_dir",
@@ -841,33 +870,66 @@ export class SidecarProcess {
841
870
  }
842
871
  async hostFilesystemCall(session, vm, request) {
843
872
  const response = await this.sendRequest({
844
- ownership: { scope: "vm", connection_id: session.connectionId, session_id: session.sessionId, vm_id: vm.vmId },
845
- payload: { type: "host_filesystem_call", operation: request.operation, path: request.path, payload_size_bytes: request.payloadSizeBytes },
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
+ },
846
885
  });
847
886
  if (response.payload.type !== "filesystem_result") {
848
887
  throw new Error(`unexpected host_filesystem_call response: ${response.payload.type}`);
849
888
  }
850
- return { operation: response.payload.operation, status: response.payload.status, payloadSizeBytes: response.payload.payload_size_bytes };
889
+ return {
890
+ operation: response.payload.operation,
891
+ status: response.payload.status,
892
+ payloadSizeBytes: response.payload.payload_size_bytes,
893
+ };
851
894
  }
852
895
  async persistenceLoad(session, key) {
853
896
  const response = await this.sendRequest({
854
- ownership: { scope: "session", connection_id: session.connectionId, session_id: session.sessionId },
897
+ ownership: {
898
+ scope: "session",
899
+ connection_id: session.connectionId,
900
+ session_id: session.sessionId,
901
+ },
855
902
  payload: { type: "persistence_load", key },
856
903
  });
857
904
  if (response.payload.type !== "persistence_state") {
858
905
  throw new Error(`unexpected persistence_load response: ${response.payload.type}`);
859
906
  }
860
- return { key: response.payload.key, found: response.payload.found, payloadSizeBytes: response.payload.payload_size_bytes };
907
+ return {
908
+ key: response.payload.key,
909
+ found: response.payload.found,
910
+ payloadSizeBytes: response.payload.payload_size_bytes,
911
+ };
861
912
  }
862
913
  async persistenceFlush(session, request) {
863
914
  const response = await this.sendRequest({
864
- ownership: { scope: "session", connection_id: session.connectionId, session_id: session.sessionId },
865
- payload: { type: "persistence_flush", key: request.key, payload_size_bytes: request.payloadSizeBytes },
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
+ },
866
925
  });
867
926
  if (response.payload.type !== "persistence_flushed") {
868
927
  throw new Error(`unexpected persistence_flush response: ${response.payload.type}`);
869
928
  }
870
- return { key: response.payload.key, committedBytes: response.payload.committed_bytes };
929
+ return {
930
+ key: response.payload.key,
931
+ committedBytes: response.payload.committed_bytes,
932
+ };
871
933
  }
872
934
  async waitForEvent(matcher, timeoutMs, options) {
873
935
  return await this.protocolClient.waitForEvent(matcher, timeoutMs, options);
@@ -962,6 +1024,8 @@ function toWireRootFilesystemEntry(entry) {
962
1024
  function toWireMountDescriptor(descriptor) {
963
1025
  return {
964
1026
  guest_path: descriptor.guestPath,
1027
+ guest_source: descriptor.guestSource ?? descriptor.plugin.id,
1028
+ guest_fstype: descriptor.guestFstype ?? descriptor.plugin.id,
965
1029
  read_only: descriptor.readOnly,
966
1030
  plugin: {
967
1031
  id: descriptor.plugin.id,
package/dist/state.d.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  import * as protocol from "./generated-protocol.js";
2
2
  export interface LiveGuestFilesystemStat {
3
3
  mode: number;
4
- size: number;
5
- blocks: number;
6
- dev: number;
7
- rdev: number;
4
+ size: bigint;
5
+ blocks: bigint;
6
+ dev: bigint;
7
+ rdev: bigint;
8
8
  is_directory: boolean;
9
9
  is_symbolic_link: boolean;
10
10
  atime_ms: number;
11
11
  mtime_ms: number;
12
12
  ctime_ms: number;
13
13
  birthtime_ms: number;
14
- ino: number;
15
- nlink: number;
14
+ ino: bigint;
15
+ nlink: bigint;
16
16
  uid: number;
17
17
  gid: number;
18
18
  }
package/dist/state.js CHANGED
@@ -1,20 +1,19 @@
1
- import { bigIntToSafeNumber } from "./numbers.js";
2
1
  import { fromGeneratedProcessSnapshotStatus } from "./protocol-maps.js";
3
2
  export function fromGeneratedGuestFilesystemStat(stat) {
4
3
  return {
5
4
  mode: stat.mode,
6
- size: bigIntToSafeNumber(stat.size, "guest filesystem stat size"),
7
- blocks: bigIntToSafeNumber(stat.blocks, "guest filesystem stat blocks"),
8
- dev: bigIntToSafeNumber(stat.dev, "guest filesystem stat dev"),
9
- rdev: bigIntToSafeNumber(stat.rdev, "guest filesystem stat rdev"),
5
+ size: stat.size,
6
+ blocks: stat.blocks,
7
+ dev: stat.dev,
8
+ rdev: stat.rdev,
10
9
  is_directory: stat.isDirectory,
11
10
  is_symbolic_link: stat.isSymbolicLink,
12
- atime_ms: bigIntToSafeNumber(stat.atimeMs, "guest filesystem stat atime"),
13
- mtime_ms: bigIntToSafeNumber(stat.mtimeMs, "guest filesystem stat mtime"),
14
- ctime_ms: bigIntToSafeNumber(stat.ctimeMs, "guest filesystem stat ctime"),
15
- birthtime_ms: bigIntToSafeNumber(stat.birthtimeMs, "guest filesystem stat birthtime"),
16
- ino: bigIntToSafeNumber(stat.ino, "guest filesystem stat ino"),
17
- nlink: bigIntToSafeNumber(stat.nlink, "guest filesystem stat nlink"),
11
+ atime_ms: Number(stat.atimeMs),
12
+ mtime_ms: Number(stat.mtimeMs),
13
+ ctime_ms: Number(stat.ctimeMs),
14
+ birthtime_ms: Number(stat.birthtimeMs),
15
+ ino: stat.ino,
16
+ nlink: stat.nlink,
18
17
  uid: stat.uid,
19
18
  gid: stat.gid,
20
19
  };
@@ -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;
@@ -23,6 +25,7 @@ export interface VirtualDirEntry {
23
25
  export interface VirtualStat {
24
26
  mode: number;
25
27
  size: number;
28
+ sizeExact?: bigint;
26
29
  blocks: number;
27
30
  dev: number;
28
31
  rdev: number;
@@ -33,7 +36,9 @@ export interface VirtualStat {
33
36
  ctimeMs: number;
34
37
  birthtimeMs: number;
35
38
  ino: number;
39
+ inoExact?: bigint;
36
40
  nlink: number;
41
+ nlinkExact?: bigint;
37
42
  uid: number;
38
43
  gid: number;
39
44
  }
@@ -58,7 +63,9 @@ export interface VirtualFileSystem {
58
63
  lstat(path: string): Promise<VirtualStat>;
59
64
  link(oldPath: string, newPath: string): Promise<void>;
60
65
  chmod(path: string, mode: number): Promise<void>;
61
- chown(path: string, uid: number, gid: number): Promise<void>;
66
+ chown(path: string, uid: number, gid: number, options?: {
67
+ followSymlinks?: boolean;
68
+ }): Promise<void>;
62
69
  utimes(path: string, atime: number, mtime: number): Promise<void>;
63
70
  truncate(path: string, length: number): Promise<void>;
64
71
  pread(path: string, offset: number, length: number): Promise<Uint8Array>;
@@ -115,6 +122,7 @@ export interface ManagedProcess {
115
122
  export interface ShellHandle {
116
123
  pid: number;
117
124
  write(data: Uint8Array | string): void;
125
+ /** Ordered PTY output containing stdout and stderr exactly once. */
118
126
  onData: ((data: Uint8Array) => void) | null;
119
127
  resize(cols: number, rows: number): void;
120
128
  kill(signal?: number): void;
@@ -127,6 +135,7 @@ export interface OpenShellOptions {
127
135
  cwd?: string;
128
136
  cols?: number;
129
137
  rows?: number;
138
+ /** Optional stderr-only diagnostic tap; do not render it alongside `onData`. */
130
139
  onStderr?: (data: Uint8Array) => void;
131
140
  }
132
141
  export interface ConnectTerminalOptions extends OpenShellOptions {
@@ -179,7 +188,7 @@ export interface Permissions {
179
188
  binding?: BindingPermissions;
180
189
  }
181
190
  /** A worked example shown alongside a registered binding. */
182
- export interface HostToolExample {
191
+ export interface BindingExample {
183
192
  /** What this example demonstrates. */
184
193
  description: string;
185
194
  /** Example input matching the binding's input schema. */
@@ -201,7 +210,7 @@ export interface BindingDefinition {
201
210
  /** Abort the invocation after this many milliseconds. */
202
211
  timeoutMs?: number;
203
212
  /** Worked examples shown alongside the binding. */
204
- examples?: HostToolExample[];
213
+ examples?: BindingExample[];
205
214
  /**
206
215
  * Extra command names the guest can use to invoke this binding, in addition
207
216
  * to the key it is registered under.
@@ -326,6 +335,7 @@ export interface Kernel extends KernelInterface {
326
335
  removeFile(path: string): Promise<void>;
327
336
  removeDir(path: string): Promise<void>;
328
337
  rename(oldPath: string, newPath: string): Promise<void>;
338
+ pwrite(path: string, offset: number, data: Uint8Array): Promise<void>;
329
339
  vmFetch(request: {
330
340
  port: number;
331
341
  method: string;
@@ -333,7 +343,7 @@ export interface Kernel extends KernelInterface {
333
343
  headersJson: string;
334
344
  body?: string;
335
345
  }): Promise<string>;
336
- registerHostTools(tools: Record<string, BindingDefinition>): Promise<void>;
346
+ registerBindings(bindings: Record<string, BindingDefinition>): Promise<void>;
337
347
  getResourceSnapshot(): Promise<{
338
348
  runningProcesses: number;
339
349
  exitedProcesses: number;
@@ -450,7 +460,9 @@ export declare class InMemoryFileSystem implements VirtualFileSystem {
450
460
  lstat(targetPath: string): Promise<VirtualStat>;
451
461
  link(oldPath: string, newPath: string): Promise<void>;
452
462
  chmod(targetPath: string, mode: number): Promise<void>;
453
- chown(targetPath: string, uid: number, gid: number): Promise<void>;
463
+ chown(targetPath: string, uid: number, gid: number, options?: {
464
+ followSymlinks?: boolean;
465
+ }): Promise<void>;
454
466
  utimes(targetPath: string, atime: number, mtime: number): Promise<void>;
455
467
  truncate(targetPath: string, length: number): Promise<void>;
456
468
  pread(targetPath: string, offset: number, length: number): Promise<Uint8Array>;
@@ -488,7 +500,9 @@ export declare class NodeFileSystem implements VirtualFileSystem {
488
500
  lstat(targetPath: string): Promise<VirtualStat>;
489
501
  link(oldPath: string, newPath: string): Promise<void>;
490
502
  chmod(targetPath: string, mode: number): Promise<void>;
491
- chown(targetPath: string, uid: number, gid: number): Promise<void>;
503
+ chown(targetPath: string, uid: number, gid: number, options?: {
504
+ followSymlinks?: boolean;
505
+ }): Promise<void>;
492
506
  utimes(targetPath: string, atime: number, mtime: number): Promise<void>;
493
507
  truncate(targetPath: string, length: number): Promise<void>;
494
508
  pread(targetPath: string, offset: number, length: number): Promise<Uint8Array>;
@@ -547,12 +561,14 @@ export declare function createKernel(options: {
547
561
  permissions?: Permissions;
548
562
  env?: Record<string, string>;
549
563
  cwd?: string;
564
+ user?: VmUserConfig;
550
565
  sidecar?: SidecarProcess;
551
566
  onBootTiming?: (timing: KernelBootTiming) => void;
552
567
  maxProcesses?: number;
553
568
  hostNetworkAdapter?: unknown;
554
569
  loopbackExemptPorts?: number[];
555
570
  jsRuntime?: Partial<JsRuntimeConfig>;
571
+ limits?: VmLimitsConfig;
556
572
  logger?: unknown;
557
573
  mounts?: Array<{
558
574
  path: string;
@@ -560,4 +576,5 @@ export declare function createKernel(options: {
560
576
  readOnly?: boolean;
561
577
  }>;
562
578
  syncFilesystemOnDispose?: boolean;
579
+ maxFilesystemBytes?: number;
563
580
  }): Kernel;