@rivet-dev/agentos-core 0.0.0-codex-actor-plugin-contract-coverage.c7d8f87 → 0.0.0-fix-main-wasm-ownership.150c49a

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 (58) hide show
  1. package/README.md +39 -36
  2. package/dist/agent-os.d.ts +197 -232
  3. package/dist/agent-os.js +769 -1162
  4. package/dist/agentos-package.d.ts +4 -2
  5. package/dist/agentos-package.js +4 -1
  6. package/dist/{host-tools-zod.d.ts → bindings-zod.d.ts} +1 -1
  7. package/dist/{host-tools-zod.js → bindings-zod.js} +27 -20
  8. package/dist/bindings.d.ts +43 -0
  9. package/dist/bindings.js +34 -0
  10. package/dist/cron/cron-manager.js +43 -10
  11. package/dist/cron/index.d.ts +1 -1
  12. package/dist/cron/types.d.ts +25 -9
  13. package/dist/filesystem-snapshot.d.ts +1 -2
  14. package/dist/filesystem-snapshot.js +0 -43
  15. package/dist/generated/AcpLimitsConfig.d.ts +16 -0
  16. package/dist/generated/BindingLimitsConfig.d.ts +10 -0
  17. package/dist/generated/CreateVmConfig.d.ts +2 -0
  18. package/dist/generated/ProcessLimitsConfig.d.ts +7 -0
  19. package/dist/generated/ProcessLimitsConfig.js +2 -0
  20. package/dist/generated/VmGroupConfig.d.ts +5 -0
  21. package/dist/generated/VmGroupConfig.js +2 -0
  22. package/dist/generated/VmLimitsConfig.d.ts +4 -2
  23. package/dist/generated/VmUserAccountConfig.d.ts +9 -0
  24. package/dist/generated/VmUserAccountConfig.js +2 -0
  25. package/dist/generated/VmUserConfig.d.ts +19 -0
  26. package/dist/generated/WasmLimitsConfig.d.ts +1 -0
  27. package/dist/index.d.ts +4 -5
  28. package/dist/index.js +4 -5
  29. package/dist/layers.d.ts +5 -2
  30. package/dist/layers.js +0 -185
  31. package/dist/options-schema.d.ts +134 -31
  32. package/dist/options-schema.js +144 -26
  33. package/dist/runtime-compat.d.ts +11 -37
  34. package/dist/runtime-compat.js +74 -374
  35. package/dist/runtime.d.ts +10 -3
  36. package/dist/sandbox.d.ts +4 -4
  37. package/dist/sandbox.js +4 -4
  38. package/dist/session-api.d.ts +180 -0
  39. package/dist/session-api.js +1 -0
  40. package/dist/sidecar/agentos-protocol.d.ts +420 -29
  41. package/dist/sidecar/agentos-protocol.js +683 -93
  42. package/dist/sidecar/native-process-client.d.ts +1 -1
  43. package/dist/sidecar/native-process-client.js +1 -1
  44. package/dist/sidecar/rpc-client.d.ts +39 -6
  45. package/dist/sidecar/rpc-client.js +111 -30
  46. package/dist/test/runtime.d.ts +2 -1
  47. package/dist/test/runtime.js +2 -1
  48. package/dist/test/terminal-harness.js +0 -3
  49. package/dist/types.d.ts +4 -5
  50. package/package.json +19 -17
  51. package/dist/agent-session-types.d.ts +0 -67
  52. package/dist/generated/ToolLimitsConfig.d.ts +0 -10
  53. package/dist/host-tools.d.ts +0 -45
  54. package/dist/host-tools.js +0 -35
  55. package/dist/overlay-filesystem.d.ts +0 -19
  56. package/dist/overlay-filesystem.js +0 -645
  57. /package/dist/generated/{ToolLimitsConfig.js → BindingLimitsConfig.js} +0 -0
  58. /package/dist/{agent-session-types.js → generated/VmUserConfig.js} +0 -0
@@ -1,6 +1,6 @@
1
1
  import "@rivet-dev/agentos-runtime-core/native-client";
2
2
  import { SidecarProcess } from "@rivet-dev/agentos-runtime-core/sidecar-client";
3
- export { NATIVE_SIDECAR_FRAME_TIMEOUT_MS, SidecarEventBufferOverflow, SidecarProcess, SidecarProcessError, SidecarProcessExited, } from "@rivet-dev/agentos-runtime-core/sidecar-client";
3
+ export { SidecarEventBufferOverflow, SidecarProcess, SidecarProcessError, SidecarProcessExited, } from "@rivet-dev/agentos-runtime-core/sidecar-client";
4
4
  export declare const NativeSidecarProcessClient: typeof SidecarProcess;
5
5
  export type { AuthenticatedSession, CreatedVm, ExtEnvelope, GuestFilesystemStat, RootFilesystemEntry, RootFilesystemLowerDescriptor, SidecarEventSelector, SidecarFsPermissionRule, SidecarLinkPackageResult, SidecarMountDescriptor, SidecarMountPluginDescriptor, SidecarPatternPermissionRule, SidecarPermissionMode, SidecarPermissionScope, SidecarPermissionsPolicy, SidecarProcessSnapshotEntry, SidecarProjectedAgent, SidecarProjectedModuleDescriptor, SidecarRegisteredHostCallbackDefinition, SidecarRegisteredHostCallbackExample, SidecarRequestFrame, SidecarRequestHandler, SidecarRequestPayload, SidecarResponseFrame, SidecarResponsePayload, SidecarRulePermissions, SidecarSessionState, SidecarSignalHandlerRegistration, SidecarSignalState, SidecarSocketStateEntry, SidecarSoftwareDescriptor, SidecarSpawnOptions, SidecarSpawnOptions as NativeSidecarSpawnOptions, SidecarZombieTimerCount, } from "@rivet-dev/agentos-runtime-core/sidecar-client";
6
6
  export type { SidecarVmConfiguredResponse as SidecarConfigureVmResult, } from "@rivet-dev/agentos-runtime-core/sidecar-client";
@@ -4,5 +4,5 @@
4
4
  // SidecarProcess.spawn works in this native runtime.
5
5
  import "@rivet-dev/agentos-runtime-core/native-client";
6
6
  import { SidecarProcess } from "@rivet-dev/agentos-runtime-core/sidecar-client";
7
- export { NATIVE_SIDECAR_FRAME_TIMEOUT_MS, SidecarEventBufferOverflow, SidecarProcess, SidecarProcessError, SidecarProcessExited, } from "@rivet-dev/agentos-runtime-core/sidecar-client";
7
+ export { SidecarEventBufferOverflow, SidecarProcess, SidecarProcessError, SidecarProcessExited, } from "@rivet-dev/agentos-runtime-core/sidecar-client";
8
8
  export const NativeSidecarProcessClient = SidecarProcess;
@@ -35,6 +35,16 @@ interface NativeSidecarKernelProxyOptions {
35
35
  permissions?: SidecarPermissionsPolicy;
36
36
  commandPermissions?: Parameters<SidecarProcess["configureVm"]>[2]["commandPermissions"];
37
37
  loopbackExemptPorts?: number[];
38
+ /**
39
+ * The boot `configureVm` payload pieces beyond mounts/permissions. Rust
40
+ * `configure_vm` rebuilds the whole VM configuration from each payload, so
41
+ * every runtime mount reconfigure must resend these or a post-boot
42
+ * `mountFs()` silently drops the `/opt/agentos` package projections and
43
+ * binding shim commands applied at boot.
44
+ */
45
+ packages?: Parameters<SidecarProcess["configureVm"]>[2]["packages"];
46
+ packagesMountAt?: string;
47
+ bindingShimCommands?: string[];
38
48
  commandGuestPaths: ReadonlyMap<string, string>;
39
49
  onWasmCommandResolved?: (command: string) => void;
40
50
  onDispose?: () => Promise<void>;
@@ -60,9 +70,13 @@ export declare class NativeSidecarKernelProxy {
60
70
  private readonly ownsClient;
61
71
  private readonly localMounts;
62
72
  private readonly baseSidecarMounts;
73
+ private readonly dynamicSidecarMounts;
63
74
  private readonly permissions;
64
75
  private readonly commandPermissions;
65
76
  private readonly loopbackExemptPorts;
77
+ private packages;
78
+ private readonly packagesMountAt;
79
+ private readonly bindingShimCommands;
66
80
  private readonly commandDrivers;
67
81
  private readonly onWasmCommandResolved;
68
82
  private readonly onDispose;
@@ -88,6 +102,15 @@ export declare class NativeSidecarKernelProxy {
88
102
  createRootView(): VirtualFileSystem;
89
103
  get zombieTimerCount(): number;
90
104
  registerCommandGuestPaths(commandGuestPaths: ReadonlyMap<string, string>): void;
105
+ /**
106
+ * Record a runtime-linked package (`linkSoftware`) so mount reconfigures
107
+ * resend it. Rust `configure_vm` rebuilds the whole VM configuration from
108
+ * each payload, so a linked package omitted here would be silently
109
+ * unprojected from `/opt/agentos` by the next `mountFs`/`unmountFs`.
110
+ */
111
+ registerLinkedPackage(descriptor: {
112
+ path: string;
113
+ }): void;
91
114
  dispose(): Promise<void>;
92
115
  /** Test-only snapshot of the per-VM tracking collection sizes. */
93
116
  __trackingSizesForTest(): {
@@ -137,8 +160,15 @@ export declare class NativeSidecarKernelProxy {
137
160
  mountFs(path: string, driver: VirtualFileSystem, options?: {
138
161
  readOnly?: boolean;
139
162
  sidecarMount?: SidecarMountDescriptor;
140
- }): void;
141
- unmountFs(path: string): void;
163
+ }): Promise<void>;
164
+ unmountFs(path: string): Promise<void>;
165
+ mountDescriptor(mount: SidecarMountDescriptor): Promise<void>;
166
+ unmountDescriptor(path: string): Promise<void>;
167
+ listMounts(): Promise<Array<{
168
+ path: string;
169
+ kind: string;
170
+ readOnly: boolean;
171
+ }>>;
142
172
  private desiredSidecarMounts;
143
173
  private reconfigureSidecarMounts;
144
174
  private waitForMountReconfigure;
@@ -184,7 +214,7 @@ export declare class NativeSidecarKernelProxy {
184
214
  private updateTrackedProcessSnapshot;
185
215
  }
186
216
  export type { AuthenticatedSession, CreatedVm, GuestFilesystemStat, RootFilesystemEntry, SidecarConfigureVmResult, SidecarEventSelector, SidecarLinkPackageResult, SidecarPermissionsPolicy, SidecarProjectedAgent, SidecarRegisteredHostCallbackDefinition, SidecarRequestFrame, SidecarResponsePayload, SidecarSessionState, SidecarSignalHandlerRegistration, SidecarSocketStateEntry, SidecarSpawnOptions, } from "./native-process-client.js";
187
- export { NATIVE_SIDECAR_FRAME_TIMEOUT_MS, NativeSidecarProcessClient, SidecarEventBufferOverflow, SidecarProcess, SidecarProcessError, SidecarProcessExited, } from "./native-process-client.js";
217
+ export { NativeSidecarProcessClient, SidecarEventBufferOverflow, SidecarProcess, SidecarProcessError, SidecarProcessExited, } from "./native-process-client.js";
188
218
  export type AgentOsSidecarPlacement = {
189
219
  kind: "shared";
190
220
  pool?: string;
@@ -240,7 +270,7 @@ export interface AgentOsSidecarTransport {
240
270
  dispose(): Promise<void>;
241
271
  }
242
272
  export interface AgentOsSidecarClientOptions {
243
- createSessionTransport(bootstrap: AgentOsSidecarSessionBootstrap): Promise<AgentOsSidecarTransport>;
273
+ createOwnershipTransport(bootstrap: AgentOsSidecarSessionBootstrap): Promise<AgentOsSidecarTransport>;
244
274
  createId?: () => string;
245
275
  now?: () => number;
246
276
  }
@@ -262,13 +292,14 @@ export declare class AgentOsSidecarSessionHandle {
262
292
  dispose(): Promise<void>;
263
293
  }
264
294
  export declare class AgentOsSidecarClient {
265
- private readonly createSessionTransport;
295
+ private readonly createOwnershipTransport;
266
296
  private readonly createId;
267
297
  private readonly now;
268
298
  private readonly sessions;
269
299
  private disposed;
270
300
  constructor(options: AgentOsSidecarClientOptions);
271
- createSession(options?: AgentOsSidecarSessionOptions): Promise<AgentOsSidecarSessionHandle>;
301
+ /** Open a physical sidecar ownership scope, not a durable ACP session. */
302
+ createOwnershipSession(options?: AgentOsSidecarSessionOptions): Promise<AgentOsSidecarSessionHandle>;
272
303
  listSessions(): AgentOsSidecarSessionLifecycle[];
273
304
  requireSessionLifecycle(sessionId: string): AgentOsSidecarSessionLifecycle;
274
305
  listVms(sessionId: string): AgentOsSidecarVmLifecycle[];
@@ -293,6 +324,8 @@ export interface SidecarMountPluginDescriptor {
293
324
  }
294
325
  export interface SidecarMountDescriptor {
295
326
  guestPath: string;
327
+ guestSource?: string;
328
+ guestFstype?: string;
296
329
  readOnly: boolean;
297
330
  plugin: SidecarMountPluginDescriptor;
298
331
  }
@@ -20,7 +20,9 @@ function formatStructuredSidecarDetail(detail) {
20
20
  if (entries.length === 0) {
21
21
  return "";
22
22
  }
23
- return entries.map(([key, value]) => `${key}=${JSON.stringify(value)}`).join(" ");
23
+ return entries
24
+ .map(([key, value]) => `${key}=${JSON.stringify(value)}`)
25
+ .join(" ");
24
26
  }
25
27
  function logStructuredSidecarEvent(name, detail) {
26
28
  if (!shouldLogStructuredSidecarEvent(name)) {
@@ -211,9 +213,15 @@ export class NativeSidecarKernelProxy {
211
213
  ownsClient;
212
214
  localMounts;
213
215
  baseSidecarMounts;
216
+ dynamicSidecarMounts = [];
214
217
  permissions;
215
218
  commandPermissions;
216
219
  loopbackExemptPorts;
220
+ // Mutable: runtime `linkSoftware` appends via `registerLinkedPackage` so
221
+ // later mount reconfigures resend linked packages too, not just boot ones.
222
+ packages;
223
+ packagesMountAt;
224
+ bindingShimCommands;
217
225
  commandDrivers;
218
226
  onWasmCommandResolved;
219
227
  onDispose;
@@ -250,6 +258,9 @@ export class NativeSidecarKernelProxy {
250
258
  this.permissions = options.permissions;
251
259
  this.commandPermissions = options.commandPermissions;
252
260
  this.loopbackExemptPorts = options.loopbackExemptPorts;
261
+ this.packages = options.packages ? [...options.packages] : [];
262
+ this.packagesMountAt = options.packagesMountAt;
263
+ this.bindingShimCommands = options.bindingShimCommands;
253
264
  this.commandDrivers = buildCommandMap(options.commandGuestPaths);
254
265
  this.onWasmCommandResolved = options.onWasmCommandResolved;
255
266
  this.onDispose = options.onDispose;
@@ -273,6 +284,17 @@ export class NativeSidecarKernelProxy {
273
284
  this.commandDrivers.set(name, "wasmvm");
274
285
  }
275
286
  }
287
+ /**
288
+ * Record a runtime-linked package (`linkSoftware`) so mount reconfigures
289
+ * resend it. Rust `configure_vm` rebuilds the whole VM configuration from
290
+ * each payload, so a linked package omitted here would be silently
291
+ * unprojected from `/opt/agentos` by the next `mountFs`/`unmountFs`.
292
+ */
293
+ registerLinkedPackage(descriptor) {
294
+ if (!this.packages.some((pkg) => pkg.path === descriptor.path)) {
295
+ this.packages.push({ path: descriptor.path });
296
+ }
297
+ }
276
298
  async dispose() {
277
299
  if (this.disposed) {
278
300
  return;
@@ -564,7 +586,7 @@ export class NativeSidecarKernelProxy {
564
586
  return proc;
565
587
  }
566
588
  openShell(options) {
567
- const stdoutHandlers = new Set();
589
+ const terminalHandlers = new Set();
568
590
  const stderrHandlers = new Set();
569
591
  const command = options?.command ?? "sh";
570
592
  const args = options?.args ??
@@ -619,7 +641,7 @@ export class NativeSidecarKernelProxy {
619
641
  const normalized = normalizeSyntheticTerminalText(text);
620
642
  updateSyntheticCursor(normalized);
621
643
  const chunk = textEncoder.encode(normalized);
622
- for (const handler of stdoutHandlers) {
644
+ for (const handler of terminalHandlers) {
623
645
  handler(chunk);
624
646
  }
625
647
  };
@@ -630,7 +652,7 @@ export class NativeSidecarKernelProxy {
630
652
  const normalized = normalizeSyntheticTerminalText(text);
631
653
  updateSyntheticCursor(normalized);
632
654
  const chunk = textEncoder.encode(normalized);
633
- for (const handler of stdoutHandlers) {
655
+ for (const handler of terminalHandlers) {
634
656
  handler(chunk);
635
657
  }
636
658
  };
@@ -675,7 +697,7 @@ export class NativeSidecarKernelProxy {
675
697
  commandInFlight = false;
676
698
  const promptPrefix = syntheticCursorAtLineStart ? "" : "\r\n";
677
699
  const promptChunk = textEncoder.encode(`${promptPrefix}${promptText}`);
678
- for (const handler of stdoutHandlers) {
700
+ for (const handler of terminalHandlers) {
679
701
  handler(promptChunk);
680
702
  }
681
703
  syntheticCursorAtLineStart = false;
@@ -733,7 +755,7 @@ export class NativeSidecarKernelProxy {
733
755
  }
734
756
  };
735
757
  let onData = null;
736
- stdoutHandlers.add((data) => onData?.(data));
758
+ terminalHandlers.add((data) => onData?.(data));
737
759
  if (options?.onStderr) {
738
760
  stderrHandlers.add(options.onStderr);
739
761
  }
@@ -902,7 +924,7 @@ export class NativeSidecarKernelProxy {
902
924
  if (!sanitized) {
903
925
  return;
904
926
  }
905
- for (const handler of stdoutHandlers) {
927
+ for (const handler of terminalHandlers) {
906
928
  handler(sanitized);
907
929
  }
908
930
  if (commandInFlight) {
@@ -914,6 +936,11 @@ export class NativeSidecarKernelProxy {
914
936
  if (!sanitized) {
915
937
  return;
916
938
  }
939
+ // `onData` is the ordered PTY rendering stream. `onStderr` remains an
940
+ // optional channel-specific diagnostic tap and must not also be rendered.
941
+ for (const handler of terminalHandlers) {
942
+ handler(sanitized);
943
+ }
917
944
  for (const handler of stderrHandlers) {
918
945
  handler(sanitized);
919
946
  }
@@ -967,13 +994,7 @@ export class NativeSidecarKernelProxy {
967
994
  const stdin = process.stdin;
968
995
  const stdout = process.stdout;
969
996
  const { onData, ...shellOptions } = options ?? {};
970
- const shell = this.openShell({
971
- ...shellOptions,
972
- onStderr: shellOptions.onStderr ??
973
- ((data) => {
974
- process.stderr.write(data);
975
- }),
976
- });
997
+ const shell = this.openShell(shellOptions);
977
998
  const outputHandler = onData ??
978
999
  ((data) => {
979
1000
  stdout.write(data);
@@ -1058,7 +1079,7 @@ export class NativeSidecarKernelProxy {
1058
1079
  if (local) {
1059
1080
  return this.readdirRecursiveLocal(local.mount.fs, local.relativePath, options?.maxDepth);
1060
1081
  }
1061
- return this.client.readdirRecursive(this.session, this.vm, path, options);
1082
+ return (await this.client.readdirRecursive(this.session, this.vm, path, options)).map((entry) => ({ ...entry, size: Number(entry.size) }));
1062
1083
  }
1063
1084
  async removeFile(path) {
1064
1085
  return this.dispatchWrite(path, (mount, relativePath) => mount.fs.removeFile(relativePath), () => this.client.removeFile(this.session, this.vm, path));
@@ -1126,19 +1147,53 @@ export class NativeSidecarKernelProxy {
1126
1147
  sidecarMount: options?.sidecarMount,
1127
1148
  });
1128
1149
  this.localMounts.sort((left, right) => right.path.length - left.path.length);
1129
- void this.reconfigureSidecarMounts().catch(() => { });
1150
+ // Resolves once the sidecar has the mount; a swallowed rejection here
1151
+ // used to turn reconfigure failures into silently missing guest mounts.
1152
+ // The local catch only guards callers that drop the promise — awaiting
1153
+ // callers still observe the rejection.
1154
+ const applied = this.reconfigureSidecarMounts();
1155
+ applied.catch(() => { });
1156
+ return applied;
1130
1157
  }
1131
1158
  unmountFs(path) {
1132
1159
  const normalized = posixPath.normalize(path);
1133
1160
  const index = this.localMounts.findIndex((mount) => mount.path === normalized);
1134
- if (index >= 0) {
1135
- this.localMounts.splice(index, 1);
1136
- void this.reconfigureSidecarMounts().catch(() => { });
1161
+ if (index < 0) {
1162
+ return Promise.resolve();
1163
+ }
1164
+ this.localMounts.splice(index, 1);
1165
+ const applied = this.reconfigureSidecarMounts();
1166
+ applied.catch(() => { });
1167
+ return applied;
1168
+ }
1169
+ mountDescriptor(mount) {
1170
+ const normalized = posixPath.normalize(mount.guestPath);
1171
+ if (this.desiredSidecarMounts().some((existing) => posixPath.normalize(existing.guestPath) === normalized)) {
1172
+ return Promise.reject(new Error(`mount already exists: ${normalized}`));
1137
1173
  }
1174
+ this.dynamicSidecarMounts.push({ ...mount, guestPath: normalized });
1175
+ const applied = this.reconfigureSidecarMounts();
1176
+ applied.catch(() => { });
1177
+ return applied;
1178
+ }
1179
+ unmountDescriptor(path) {
1180
+ const normalized = posixPath.normalize(path);
1181
+ const index = this.dynamicSidecarMounts.findIndex((mount) => posixPath.normalize(mount.guestPath) === normalized);
1182
+ if (index < 0)
1183
+ return Promise.resolve();
1184
+ this.dynamicSidecarMounts.splice(index, 1);
1185
+ const applied = this.reconfigureSidecarMounts();
1186
+ applied.catch(() => { });
1187
+ return applied;
1188
+ }
1189
+ async listMounts() {
1190
+ await this.waitForMountReconfigure();
1191
+ return this.client.listMounts(this.session, this.vm);
1138
1192
  }
1139
1193
  desiredSidecarMounts() {
1140
1194
  return [
1141
1195
  ...this.baseSidecarMounts,
1196
+ ...this.dynamicSidecarMounts,
1142
1197
  ...this.localMounts.map((mount) => mount.sidecarMount ?? {
1143
1198
  guestPath: mount.path,
1144
1199
  readOnly: mount.readOnly,
@@ -1154,11 +1209,18 @@ export class NativeSidecarKernelProxy {
1154
1209
  if (this.disposed) {
1155
1210
  return;
1156
1211
  }
1212
+ // Rust `configure_vm` rebuilds the whole VM configuration from this
1213
+ // payload, so resend the boot packages / binding shim commands too —
1214
+ // omitting them here strips the `/opt/agentos` projections and binding
1215
+ // shims from the VM as a side effect of a runtime mount change.
1157
1216
  await this.client.configureVm(this.session, this.vm, {
1158
1217
  mounts: this.desiredSidecarMounts(),
1159
1218
  permissions: this.permissions,
1160
1219
  commandPermissions: this.commandPermissions,
1161
1220
  loopbackExemptPorts: this.loopbackExemptPorts,
1221
+ packages: this.packages,
1222
+ packagesMountAt: this.packagesMountAt,
1223
+ bindingShimCommands: this.bindingShimCommands,
1162
1224
  });
1163
1225
  };
1164
1226
  const previous = this.mountReconfigurePromise ?? Promise.resolve();
@@ -1957,21 +2019,27 @@ function isMissingHostProcessError(error) {
1957
2019
  function errnoError(code, message) {
1958
2020
  return Object.assign(new Error(`${code}: ${message}`), { code });
1959
2021
  }
2022
+ // VirtualStat is a numeric, Node-default-shaped view: u64 fields above
2023
+ // Number.MAX_SAFE_INTEGER lose precision here, same as Node's non-bigint
2024
+ // fs.stat on the host.
1960
2025
  function toVirtualStat(stat) {
1961
2026
  return {
1962
2027
  mode: stat.mode,
1963
- size: stat.size,
1964
- blocks: stat.blocks,
1965
- dev: stat.dev,
1966
- rdev: stat.rdev,
2028
+ size: Number(stat.size),
2029
+ sizeExact: stat.size,
2030
+ blocks: Number(stat.blocks),
2031
+ dev: Number(stat.dev),
2032
+ rdev: Number(stat.rdev),
1967
2033
  isDirectory: stat.is_directory,
1968
2034
  isSymbolicLink: stat.is_symbolic_link,
1969
2035
  atimeMs: stat.atime_ms,
1970
2036
  mtimeMs: stat.mtime_ms,
1971
2037
  ctimeMs: stat.ctime_ms,
1972
2038
  birthtimeMs: stat.birthtime_ms,
1973
- ino: stat.ino,
1974
- nlink: stat.nlink,
2039
+ ino: Number(stat.ino),
2040
+ inoExact: stat.ino,
2041
+ nlink: Number(stat.nlink),
2042
+ nlinkExact: stat.nlink,
1975
2043
  uid: stat.uid,
1976
2044
  gid: stat.gid,
1977
2045
  };
@@ -2004,7 +2072,7 @@ function socketLookupKey(kind, request) {
2004
2072
  path: request.path ?? null,
2005
2073
  });
2006
2074
  }
2007
- export { NATIVE_SIDECAR_FRAME_TIMEOUT_MS, NativeSidecarProcessClient, SidecarEventBufferOverflow, SidecarProcess, SidecarProcessError, SidecarProcessExited, } from "./native-process-client.js";
2075
+ export { NativeSidecarProcessClient, SidecarEventBufferOverflow, SidecarProcess, SidecarProcessError, SidecarProcessExited, } from "./native-process-client.js";
2008
2076
  export class AgentOsSidecarVmHandle {
2009
2077
  client;
2010
2078
  sessionId;
@@ -2042,17 +2110,18 @@ export class AgentOsSidecarSessionHandle {
2042
2110
  }
2043
2111
  }
2044
2112
  export class AgentOsSidecarClient {
2045
- createSessionTransport;
2113
+ createOwnershipTransport;
2046
2114
  createId;
2047
2115
  now;
2048
2116
  sessions = new Map();
2049
2117
  disposed = false;
2050
2118
  constructor(options) {
2051
- this.createSessionTransport = options.createSessionTransport;
2119
+ this.createOwnershipTransport = options.createOwnershipTransport;
2052
2120
  this.createId = options.createId ?? randomUUID;
2053
2121
  this.now = options.now ?? Date.now;
2054
2122
  }
2055
- async createSession(options = {}) {
2123
+ /** Open a physical sidecar ownership scope, not a durable ACP session. */
2124
+ async createOwnershipSession(options = {}) {
2056
2125
  this.assertActive();
2057
2126
  const sessionId = this.createId();
2058
2127
  const placement = clonePlacement(options.placement);
@@ -2071,7 +2140,7 @@ export class AgentOsSidecarClient {
2071
2140
  };
2072
2141
  this.sessions.set(sessionId, entry);
2073
2142
  try {
2074
- entry.transport = await this.createSessionTransport({
2143
+ entry.transport = await this.createOwnershipTransport({
2075
2144
  sessionId,
2076
2145
  placement: clonePlacement(placement),
2077
2146
  metadata: cloneMetadata(metadata),
@@ -2237,6 +2306,8 @@ export function serializeMountConfigForSidecar(mount) {
2237
2306
  if ("driver" in mount) {
2238
2307
  return {
2239
2308
  guestPath: mount.path,
2309
+ guestSource: mount.guestSource ?? "js_bridge",
2310
+ guestFstype: mount.guestFstype ?? "js_bridge",
2240
2311
  readOnly: mount.readOnly ?? false,
2241
2312
  plugin: {
2242
2313
  id: "js_bridge",
@@ -2246,6 +2317,8 @@ export function serializeMountConfigForSidecar(mount) {
2246
2317
  }
2247
2318
  return {
2248
2319
  guestPath: mount.path,
2320
+ guestSource: mount.guestSource ?? mount.plugin.id,
2321
+ guestFstype: mount.guestFstype ?? mount.plugin.id,
2249
2322
  readOnly: mount.readOnly ?? false,
2250
2323
  plugin: {
2251
2324
  id: mount.plugin.id,
@@ -2254,6 +2327,14 @@ export function serializeMountConfigForSidecar(mount) {
2254
2327
  };
2255
2328
  }
2256
2329
  export function serializeRootFilesystemForSidecar(config, bootstrapLower) {
2330
+ if (config?.type === "native") {
2331
+ return {
2332
+ mode: "ephemeral",
2333
+ disableDefaultBaseLayer: true,
2334
+ lowers: [],
2335
+ bootstrapEntries: [],
2336
+ };
2337
+ }
2257
2338
  const lowerInputs = [
2258
2339
  ...(config?.lowers ?? []),
2259
2340
  ...(bootstrapLower ? [bootstrapLower] : []),
@@ -7,5 +7,6 @@
7
7
  export { type AgentOsRuntimeAdmin, getAgentOsKernel, getAgentOsRuntimeAdmin, } from "../agent-os.js";
8
8
  export type { PermissionTier, WasmVmRuntimeOptions, } from "../runtime.js";
9
9
  export type { DriverProcess, Kernel, KernelInterface, KernelRuntimeDriver, ProcessContext, VirtualFileSystem, } from "../runtime-compat.js";
10
- export { AF_INET, AF_UNIX, allowAll, createInMemoryFileSystem, createKernel, createNodeHostNetworkAdapter, createNodeRuntime, createWasmVmRuntime, DEFAULT_FIRST_PARTY_TIERS, NodeFileSystem, SIGTERM, SOCK_DGRAM, SOCK_STREAM, WASMVM_COMMANDS, } from "../runtime-compat.js";
10
+ export { AF_INET, AF_UNIX, allowAll, createKernel, createNodeHostNetworkAdapter, createNodeRuntime, createWasmVmRuntime, DEFAULT_FIRST_PARTY_TIERS, NodeFileSystem, SIGTERM, SOCK_DGRAM, SOCK_STREAM, WASMVM_COMMANDS, } from "../runtime-compat.js";
11
+ export { createInMemoryFileSystem } from "@rivet-dev/agentos-runtime-core/test-runtime";
11
12
  export { TerminalHarness } from "./terminal-harness.js";
@@ -5,5 +5,6 @@
5
5
  * while the public SDK removes the raw vm.kernel escape hatch.
6
6
  */
7
7
  export { getAgentOsKernel, getAgentOsRuntimeAdmin, } from "../agent-os.js";
8
- export { AF_INET, AF_UNIX, allowAll, createInMemoryFileSystem, createKernel, createNodeHostNetworkAdapter, createNodeRuntime, createWasmVmRuntime, DEFAULT_FIRST_PARTY_TIERS, NodeFileSystem, SIGTERM, SOCK_DGRAM, SOCK_STREAM, WASMVM_COMMANDS, } from "../runtime-compat.js";
8
+ export { AF_INET, AF_UNIX, allowAll, createKernel, createNodeHostNetworkAdapter, createNodeRuntime, createWasmVmRuntime, DEFAULT_FIRST_PARTY_TIERS, NodeFileSystem, SIGTERM, SOCK_DGRAM, SOCK_STREAM, WASMVM_COMMANDS, } from "../runtime-compat.js";
9
+ export { createInMemoryFileSystem } from "@rivet-dev/agentos-runtime-core/test-runtime";
9
10
  export { TerminalHarness } from "./terminal-harness.js";
@@ -20,9 +20,6 @@ export class TerminalHarness {
20
20
  rows,
21
21
  env: options?.env,
22
22
  cwd: options?.cwd,
23
- onStderr: (data) => {
24
- this.term.write(data);
25
- },
26
23
  });
27
24
  this.shell.onData = (data) => {
28
25
  this.term.write(data);
package/dist/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- export type { AgentCapabilities, AgentInfo, AgentOsCreateSidecarOptions, AgentOsLimits, AgentOsOptions, AgentOsSharedSidecarOptions, AgentOsSidecarConfig, AgentOsSidecarDescription, AgentExitEvent, AgentExitHandler, AgentRestartOutcome, AgentStderrEvent, AgentStderrHandler, AgentRegistryEntry, BatchReadResult, BatchWriteEntry, BatchWriteResult, CreateSessionOptions, DirEntry, LimitWarning, LimitWarningHandler, McpServerConfig, McpServerConfigLocal, McpServerConfigRemote, MountConfig, MountConfigJsonObject, MountConfigJsonPrimitive, MountConfigJsonValue, NativeMountConfig, NativeMountPluginDescriptor, OverlayMountConfig, PermissionReply, PermissionRequest, PermissionRequestHandler, PlainMountConfig, ProcessTreeNode, PromptResult, ReaddirRecursiveOptions, ResumeSessionOptions, ResumeSessionResult, RootFilesystemConfig, RootLowerInput, SessionConfigOption, SessionEventHandler, SessionInfo, SessionInitData, SessionMode, SessionModeState, SpawnedProcessInfo, } from "./agent-os.js";
1
+ export type { AgentOsCreateSidecarOptions, AgentOsLimits, AgentOsOptions, AgentOsSharedSidecarOptions, AgentOsSidecarConfig, AgentOsSidecarDescription, AgentExitEvent, AgentExitHandler, AgentRestartOutcome, AgentStderrEvent, AgentStderrHandler, AgentRegistryEntry, BatchReadResult, BatchWriteEntry, BatchWriteResult, DirEntry, DynamicMountDescriptor, ExportRootFilesystemOptions, HttpRequest, HttpResponse, LimitWarning, LimitWarningHandler, MountConfig, MountInfo, MountConfigJsonObject, MountConfigJsonPrimitive, MountConfigJsonValue, NativeMountConfig, NativeMountPluginDescriptor, NativeRootFilesystemConfig, OverlayMountConfig, OverlayRootFilesystemConfig, PlainMountConfig, ProcessTreeNode, ProcessExit, ProcessOutput, ReaddirEntry, ReaddirRecursiveOptions, RootFilesystemConfig, RootLowerInput, SpawnedProcessInfo, SpawnOptions, ShellData, ShellExit, ShellOptions, } from "./agent-os.js";
2
+ export type * from "./session-api.js";
2
3
  /**
3
4
  * An agent type id — the `name` of an `/opt/agentos` agent package manifest
4
5
  * (e.g. `"pi"`, `"claude"`). Agents are resolved by the SIDECAR from the projected
@@ -6,12 +7,10 @@ export type { AgentCapabilities, AgentInfo, AgentOsCreateSidecarOptions, AgentOs
6
7
  * passes only the name, so any manifest `name` is a valid agent type.
7
8
  */
8
9
  export type AgentType = string;
9
- export type { CronAction, CronEvent, CronEventHandler, CronJob, CronJobInfo, CronJobOptions, ScheduleDriver, ScheduleEntry, ScheduleHandle, } from "./cron/index.js";
10
+ export type { CronAction, CronActionInfo, CronEvent, CronEventHandler, CronJob, CronJobInfo, CronJobOptions, ScheduleDriver, ScheduleEntry, ScheduleHandle, } from "./cron/index.js";
10
11
  export type { HostDirBackendOptions, HostDirMountPluginConfig, NodeModulesMountConfig, } from "./host-dir-mount.js";
11
- export type { HostTool, ToolExample, ToolKit } from "./host-tools.js";
12
- export type { AcpTimeoutErrorData, JsonRpcError, JsonRpcErrorData, JsonRpcNotification, JsonRpcRequest, JsonRpcResponse, UnknownSessionErrorData, } from "./json-rpc.js";
12
+ export type { Binding, BindingExample, Bindings } from "./bindings.js";
13
13
  export type { FilesystemSnapshotExport, LayerHandle, LayerStore, OverlayFilesystemMode, RootSnapshotExport, SnapshotImportSource, SnapshotLayerHandle, WritableLayerHandle, } from "./layers.js";
14
14
  export type { SoftwareInput, SoftwareRoot } from "./packages.js";
15
15
  export type { AgentBlock, PackageDescriptor, PackageRef, SoftwarePackageRef, } from "./agentos-package.js";
16
16
  export type { ChildProcessPermissions, ConnectTerminalOptions, EnvPermissions, ExecOptions, ExecResult, FsPermissionRule, FsPermissions, KernelExecOptions, KernelExecResult, KernelSpawnOptions, NetworkAccessRequest, NetworkPermissions, OpenShellOptions, PatternPermissionRule, PermissionDecision, PermissionMode, Permissions, ProcessInfo, RulePermissions, StdioChannel, TimingMitigation, VirtualDirEntry, VirtualFileSystem, VirtualStat, } from "./runtime.js";
17
- export type { PromptCapabilities } from "./agent-session-types.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivet-dev/agentos-core",
3
- "version": "0.0.0-codex-actor-plugin-contract-coverage.c7d8f87",
3
+ "version": "0.0.0-fix-main-wasm-ownership.150c49a",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
@@ -46,24 +46,25 @@
46
46
  }
47
47
  },
48
48
  "scripts": {
49
- "check-types": "pnpm run build:protocols && tsc --noEmit",
49
+ "check-types": "pnpm run build:protocols && tsc --noEmit && tsc -p tsconfig.type-tests.json",
50
50
  "build": "pnpm run build:protocols && tsc",
51
51
  "build:agentos-protocol": "node ./scripts/compile-agentos-protocol.mjs",
52
52
  "build:protocols": "pnpm run build:agentos-protocol",
53
53
  "test": "vitest run --reporter=verbose"
54
54
  },
55
55
  "dependencies": {
56
- "@agentos-software/claude-code": "0.0.0-codex-actor-plugin-contract-coverage.c7d8f87",
57
- "@agentos-software/codex-cli": "0.3.3",
58
- "@agentos-software/common": "0.0.0-codex-actor-plugin-contract-coverage.c7d8f87",
59
- "@agentos-software/manifest": "0.0.0-codex-actor-plugin-contract-coverage.c7d8f87",
60
- "@agentos-software/opencode": "0.0.0-codex-actor-plugin-contract-coverage.c7d8f87",
61
- "@agentos-software/pi": "0.0.0-codex-actor-plugin-contract-coverage.c7d8f87",
62
- "@agentos-software/pi-cli": "0.0.0-codex-actor-plugin-contract-coverage.c7d8f87",
56
+ "@agentclientprotocol/sdk": "0.16.1",
57
+ "@agentos-software/claude-code": "0.2.7",
58
+ "@agentos-software/codex-cli": "0.3.4",
59
+ "@agentos-software/common": "0.0.0-fix-main-wasm-ownership.150c49a",
60
+ "@agentos-software/manifest": "0.0.0-fix-main-wasm-ownership.150c49a",
61
+ "@agentos-software/opencode": "0.2.7",
62
+ "@agentos-software/pi": "0.2.7",
63
+ "@agentos-software/pi-cli": "0.2.7",
63
64
  "@aws-sdk/client-s3": "^3.1019.0",
64
- "@rivet-dev/agentos-sidecar": "0.0.0-codex-actor-plugin-contract-coverage.c7d8f87",
65
+ "@rivet-dev/agentos-sidecar": "0.0.0-fix-main-wasm-ownership.150c49a",
65
66
  "@rivetkit/bare-ts": "^0.6.2",
66
- "@rivet-dev/agentos-runtime-core": "0.0.0-codex-actor-plugin-contract-coverage.c7d8f87",
67
+ "@rivet-dev/agentos-runtime-core": "0.0.0-fix-main-wasm-ownership.150c49a",
67
68
  "@xterm/headless": "^6.0.0",
68
69
  "better-sqlite3": "^12.8.0",
69
70
  "croner": "^10.0.1",
@@ -75,8 +76,8 @@
75
76
  "zod-to-json-schema": "^3.25.2"
76
77
  },
77
78
  "devDependencies": {
78
- "@agentos-software/claude-code": "0.0.0-codex-actor-plugin-contract-coverage.c7d8f87",
79
- "@agentos-software/codex": "0.0.0-codex-actor-plugin-contract-coverage.c7d8f87",
79
+ "@agentos-software/claude-code": "0.2.7",
80
+ "@agentos-software/codex": "0.2.7",
80
81
  "@agentos-software/coreutils": "0.3.3",
81
82
  "@agentos-software/curl": "0.3.3",
82
83
  "@agentos-software/diffutils": "0.3.3",
@@ -88,17 +89,18 @@
88
89
  "@agentos-software/git": "0.3.3",
89
90
  "@agentos-software/grep": "0.3.3",
90
91
  "@agentos-software/gzip": "0.3.3",
91
- "@agentos-software/http-get": "0.3.3",
92
92
  "@agentos-software/jq": "0.3.3",
93
- "@agentos-software/opencode": "0.0.0-codex-actor-plugin-contract-coverage.c7d8f87",
94
- "@agentos-software/pi": "0.0.0-codex-actor-plugin-contract-coverage.c7d8f87",
95
- "@agentos-software/pi-cli": "0.0.0-codex-actor-plugin-contract-coverage.c7d8f87",
93
+ "@agentos-software/opencode": "0.2.7",
94
+ "@agentos-software/pi": "0.2.7",
95
+ "@agentos-software/pi-cli": "0.2.7",
96
96
  "@agentos-software/ripgrep": "0.3.3",
97
97
  "@agentos-software/sed": "0.3.3",
98
98
  "@agentos-software/tar": "0.3.3",
99
99
  "@agentos-software/tree": "0.3.3",
100
100
  "@agentos-software/vim": "0.3.3",
101
+ "@agentos-software/wget": "0.3.3",
101
102
  "@agentos-software/yq": "0.3.3",
103
+ "@rivet-dev/agentos-test-harness": "0.0.0-fix-main-wasm-ownership.150c49a",
102
104
  "@anthropic-ai/claude-agent-sdk": "^0.2.87",
103
105
  "@anthropic-ai/claude-code": "^2.1.86",
104
106
  "@bare-ts/tools": "0.15.0",
@@ -1,67 +0,0 @@
1
- import type { JsonRpcNotification } from "./json-rpc.js";
2
- export type SessionEventHandler = (event: JsonRpcNotification) => void;
3
- export interface PermissionRequest {
4
- permissionId: string;
5
- description?: string;
6
- params: Record<string, unknown>;
7
- }
8
- export type PermissionReply = "once" | "always" | "reject";
9
- export type PermissionRequestHandler = (request: PermissionRequest) => void;
10
- export interface SessionMode {
11
- id: string;
12
- name?: string;
13
- label?: string;
14
- description?: string;
15
- [key: string]: unknown;
16
- }
17
- export interface SessionModeState {
18
- currentModeId: string;
19
- availableModes: SessionMode[];
20
- }
21
- export interface SessionConfigOption {
22
- id: string;
23
- category?: string;
24
- label?: string;
25
- description?: string;
26
- currentValue?: string;
27
- allowedValues?: Array<{
28
- id: string;
29
- label?: string;
30
- }>;
31
- readOnly?: boolean;
32
- }
33
- export interface PromptCapabilities {
34
- audio?: boolean;
35
- embeddedContext?: boolean;
36
- image?: boolean;
37
- [key: string]: unknown;
38
- }
39
- export interface AgentCapabilities {
40
- permissions?: boolean;
41
- plan_mode?: boolean;
42
- questions?: boolean;
43
- tool_calls?: boolean;
44
- text_messages?: boolean;
45
- images?: boolean;
46
- file_attachments?: boolean;
47
- session_lifecycle?: boolean;
48
- error_events?: boolean;
49
- reasoning?: boolean;
50
- status?: boolean;
51
- streaming_deltas?: boolean;
52
- mcp_tools?: boolean;
53
- promptCapabilities?: PromptCapabilities;
54
- [key: string]: unknown;
55
- }
56
- export interface AgentInfo {
57
- name: string;
58
- title?: string;
59
- version?: string;
60
- [key: string]: unknown;
61
- }
62
- export interface SessionInitData {
63
- modes?: SessionModeState;
64
- configOptions?: SessionConfigOption[];
65
- capabilities?: AgentCapabilities;
66
- agentInfo?: AgentInfo;
67
- }