@rivet-dev/agentos-core 0.0.0-agentos-dylib-plugin.bbfdf95 → 0.0.0-codex-on-agent-stderr.dd7a603

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @rivet-dev/agent-os-core
1
+ # @rivet-dev/agentos-core
2
2
 
3
3
  A high-level SDK for running coding agents in isolated VMs. agentOS manages the full lifecycle of virtual machines -- from filesystem setup and process management to launching AI agents via the Agent Communication Protocol (ACP).
4
4
 
@@ -19,13 +19,13 @@ Agents run inside isolated VMs with their own filesystem, process table, and net
19
19
  ## Quick Start
20
20
 
21
21
  ```bash
22
- npm install @rivet-dev/agent-os-core
22
+ npm install @rivet-dev/agentos-core
23
23
  # Install an agent adapter + its underlying agent
24
- npm install @rivet-dev/agent-os-pi @mariozechner/pi-coding-agent
24
+ npm install @agentos-software/pi @mariozechner/pi-coding-agent
25
25
  ```
26
26
 
27
27
  ```typescript
28
- import { AgentOs } from "@rivet-dev/agent-os-core";
28
+ import { AgentOs } from "@rivet-dev/agentos-core";
29
29
 
30
30
  // 1. Create a VM
31
31
  const vm = await AgentOs.create();
@@ -190,15 +190,31 @@ export interface AgentOsLimits {
190
190
  syncReadLimitBytes?: number;
191
191
  };
192
192
  }
193
+ export interface AgentStderrEvent {
194
+ sessionId: string;
195
+ agentType: string;
196
+ processId: string;
197
+ pid: number | null;
198
+ chunk: Uint8Array;
199
+ }
200
+ export type AgentStderrHandler = (event: AgentStderrEvent) => void;
193
201
  export interface AgentOsOptions {
194
202
  /**
195
203
  * Software to install in the VM. Each entry provides agents, tools,
196
204
  * or WASM commands. Any object with a `commandDir` property (e.g.,
197
- * registry packages like @agent-os-pkgs/coreutils) is treated
205
+ * registry packages like @agentos-software/coreutils) is treated
198
206
  * as a WASM command source automatically. Arrays are flattened, so
199
207
  * meta-packages that export arrays of sub-packages work directly.
200
208
  */
201
209
  software?: SoftwareInput[];
210
+ /**
211
+ * Whether to auto-include the default software bundle (`@agentos-software/common`
212
+ * — `sh` + coreutils + the standard CLI tools agents rely on) in addition to
213
+ * any `software` you pass. Defaults to `true`; set `false` for a bare VM with
214
+ * only the software you list explicitly. Entries already present in `software`
215
+ * are not duplicated.
216
+ */
217
+ defaultSoftware?: boolean;
202
218
  /** Loopback ports to exempt from SSRF checks (for testing with host-side mock servers). */
203
219
  loopbackExemptPorts?: number[];
204
220
  /**
@@ -210,6 +226,11 @@ export interface AgentOsOptions {
210
226
  rootFilesystem?: RootFilesystemConfig;
211
227
  /** Filesystems to mount at boot time. */
212
228
  mounts?: MountConfig[];
229
+ /**
230
+ * @deprecated Use `mounts: [nodeModulesMount(path)]` instead.
231
+ * Compatibility alias for mounting `<moduleAccessCwd>/node_modules` at `/root/node_modules`.
232
+ */
233
+ moduleAccessCwd?: string;
213
234
  /** Additional instructions appended to the base OS system prompt injected at session start. */
214
235
  additionalInstructions?: string;
215
236
  /** Custom schedule driver for cron jobs. Defaults to TimerScheduleDriver. */
@@ -231,6 +252,13 @@ export interface AgentOsOptions {
231
252
  * runtime's historical constants, so omitting this leaves behavior unchanged.
232
253
  */
233
254
  limits?: AgentOsLimits;
255
+ /**
256
+ * Called with stderr chunks from the top-level ACP-speaking agent process.
257
+ * The agent process uses stdout for ACP JSON-RPC protocol traffic, so only
258
+ * stderr is forwarded through this hook. Defaults to writing chunks to
259
+ * `process.stderr`.
260
+ */
261
+ onAgentStderr?: AgentStderrHandler;
234
262
  }
235
263
  /** Configuration for a local MCP server (spawned as a child process). */
236
264
  export interface McpServerConfigLocal {
@@ -284,7 +312,7 @@ export interface ResumeSessionOptions {
284
312
  * fallback tier arms a continuation preamble pointing the agent at it.
285
313
  */
286
314
  transcriptPath?: string;
287
- /** Working directory for the resumed agent session (default `/home/user`). */
315
+ /** Working directory for the resumed agent session (default `/workspace`). */
288
316
  cwd?: string;
289
317
  /** Environment variables to pass to the resumed agent process. */
290
318
  env?: Record<string, string>;
@@ -347,11 +375,13 @@ export declare class AgentOs {
347
375
  private readonly _sidecarSession;
348
376
  private readonly _sidecarVm;
349
377
  private readonly _disposeSidecarEventListener;
378
+ private readonly _agentStderrHandler?;
350
379
  private constructor();
351
380
  static createSidecar(options?: AgentOsCreateSidecarOptions): Promise<AgentOsSidecar>;
352
381
  static getSharedSidecar(options?: AgentOsSharedSidecarOptions): Promise<AgentOsSidecar>;
353
382
  static create(options?: AgentOsOptions): Promise<AgentOs>;
354
383
  exec(command: string, options?: KernelExecOptions): Promise<KernelExecResult>;
384
+ execArgv(command: string, args?: readonly string[], options?: KernelExecOptions): Promise<KernelExecResult>;
355
385
  private _trackProcess;
356
386
  spawn(command: string, args: string[], options?: KernelSpawnOptions): {
357
387
  pid: number;
@@ -431,6 +461,7 @@ export declare class AgentOs {
431
461
  private _recordSessionNotification;
432
462
  private _dispatchSessionEvent;
433
463
  private _subscribeSessionEvents;
464
+ private _recordAgentStderr;
434
465
  private _applySyntheticConfigOverrides;
435
466
  private _handleSidecarEvent;
436
467
  private _handleAcpExtEvent;
package/dist/agent-os.js CHANGED
@@ -4,6 +4,7 @@ import { existsSync, mkdtempSync, readdirSync, readFileSync, rmSync, statSync, w
4
4
  import { tmpdir } from "node:os";
5
5
  import { dirname, join, posix as posixPath, resolve as resolveHostPath, } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
+ import commonSoftware from "@agentos-software/common";
7
8
  import { validateToolkits } from "./host-tools.js";
8
9
  import { zodToJsonSchema } from "./host-tools-zod.js";
9
10
  import { resolvePublishedSidecarBinary } from "./sidecar/binary.js";
@@ -50,9 +51,12 @@ import { serializeMountConfigForSidecar, } from "./js-bridge.js";
50
51
  import { createSnapshotExport, } from "./layers.js";
51
52
  import { processSoftware, resolvePackageDir, } from "./packages.js";
52
53
  import { allowAll } from "./runtime-compat.js";
53
- import { AcpRuntimeKind, decodeAcpCallback, decodeAcpEvent, decodeAcpResponse, encodeAcpCallbackResponse, encodeAcpRequest, } from "./sidecar/agent-os-protocol.js";
54
+ import { AcpRuntimeKind, decodeAcpCallback, decodeAcpEvent, decodeAcpResponse, encodeAcpCallbackResponse, encodeAcpRequest, } from "./sidecar/agentos-protocol.js";
54
55
  import { serializePermissionsForSidecar } from "./sidecar/permissions.js";
55
56
  import { createAgentOsSidecarClient, NATIVE_SIDECAR_FRAME_TIMEOUT_MS, NativeSidecarKernelProxy, SidecarProcess, serializeRootFilesystemForSidecar, } from "./sidecar/rpc-client.js";
57
+ function defaultAgentStderrHandler(event) {
58
+ process.stderr.write(event.chunk);
59
+ }
56
60
  const LEGACY_PERMISSION_METHOD = "request/permission";
57
61
  const ACP_PERMISSION_METHOD = "session/request_permission";
58
62
  class AcpDispatchError extends Error {
@@ -366,7 +370,8 @@ const KERNEL_POSIX_BOOTSTRAP_DIRS = [
366
370
  "/mnt",
367
371
  "/media",
368
372
  "/home",
369
- "/home/user",
373
+ "/home/agentos",
374
+ "/workspace",
370
375
  "/usr",
371
376
  "/usr/bin",
372
377
  "/usr/games",
@@ -488,7 +493,7 @@ function prepareCommandDirs(commandPackages) {
488
493
  if (aliasEntries.length === 0) {
489
494
  continue;
490
495
  }
491
- const aliasDir = mkdtempSync(join(tmpdir(), "agent-os-command-aliases-"));
496
+ const aliasDir = mkdtempSync(join(tmpdir(), "agentos-command-aliases-"));
492
497
  for (const [aliasName, sourcePath] of aliasEntries) {
493
498
  writeFileSync(join(aliasDir, aliasName), readFileSync(sourcePath));
494
499
  }
@@ -835,7 +840,7 @@ function collectSidecarMountPlan(options) {
835
840
  return { sidecarMounts, hostMounts, hostPathMappings };
836
841
  }
837
842
  function materializeToolShimDir(toolKits) {
838
- const shimDir = mkdtempSync(join(tmpdir(), "agent-os-host-tools-shims-"));
843
+ const shimDir = mkdtempSync(join(tmpdir(), "agentos-host-tools-shims-"));
839
844
  writeFileSync(join(shimDir, "agentos"), KERNEL_COMMAND_STUB, { mode: 0o755 });
840
845
  for (const toolKit of toolKits) {
841
846
  writeFileSync(join(shimDir, `agentos-${toolKit.name}`), KERNEL_COMMAND_STUB, { mode: 0o755 });
@@ -1402,7 +1407,8 @@ export class AgentOs {
1402
1407
  _sidecarSession;
1403
1408
  _sidecarVm;
1404
1409
  _disposeSidecarEventListener;
1405
- constructor(kernel, sidecar, softwareRoots, softwareAgentConfigs, hostMounts, env, rootFilesystem, sidecarClient, sidecarSession, sidecarVm) {
1410
+ _agentStderrHandler;
1411
+ constructor(kernel, sidecar, softwareRoots, softwareAgentConfigs, hostMounts, env, rootFilesystem, sidecarClient, sidecarSession, sidecarVm, agentStderrHandler) {
1406
1412
  this.#kernel = kernel;
1407
1413
  this.sidecar = sidecar;
1408
1414
  this._softwareRoots = softwareRoots;
@@ -1413,6 +1419,7 @@ export class AgentOs {
1413
1419
  this._sidecarClient = sidecarClient;
1414
1420
  this._sidecarSession = sidecarSession;
1415
1421
  this._sidecarVm = sidecarVm;
1422
+ this._agentStderrHandler = agentStderrHandler;
1416
1423
  this._disposeSidecarEventListener = this._sidecarClient.onEvent((event) => {
1417
1424
  this._handleSidecarEvent(event);
1418
1425
  });
@@ -1430,7 +1437,10 @@ export class AgentOs {
1430
1437
  return getSharedAgentOsSidecarInternal(options);
1431
1438
  }
1432
1439
  static async create(options) {
1433
- const processed = processSoftware(options?.software ?? []);
1440
+ const software = options?.defaultSoftware === false
1441
+ ? (options.software ?? [])
1442
+ : [commonSoftware, ...(options?.software ?? [])];
1443
+ const processed = processSoftware(software);
1434
1444
  const localMounts = await resolveCompatLocalMounts(options?.mounts);
1435
1445
  const toolKits = options?.toolKits;
1436
1446
  if (toolKits && toolKits.length > 0) {
@@ -1467,8 +1477,21 @@ export class AgentOs {
1467
1477
  toolShimDir = materializeToolShimDir(toolKits);
1468
1478
  }
1469
1479
  const commandGuestPaths = collectGuestCommandPaths(preparedCommandDirs.commandDirs);
1480
+ const requestedMounts = options?.moduleAccessCwd
1481
+ ? [
1482
+ ...(options.mounts ?? []),
1483
+ {
1484
+ path: "/root/node_modules",
1485
+ plugin: createHostDirBackend({
1486
+ hostPath: join(options.moduleAccessCwd, "node_modules"),
1487
+ readOnly: true,
1488
+ }),
1489
+ readOnly: true,
1490
+ },
1491
+ ]
1492
+ : options?.mounts;
1470
1493
  const { sidecarMounts, hostMounts, hostPathMappings } = collectSidecarMountPlan({
1471
- mounts: options?.mounts,
1494
+ mounts: requestedMounts,
1472
1495
  softwareRoots: processed.softwareRoots,
1473
1496
  commandDirs: preparedCommandDirs.commandDirs,
1474
1497
  shimDir: toolShimDir,
@@ -1531,7 +1554,7 @@ export class AgentOs {
1531
1554
  session,
1532
1555
  vm: nativeVm,
1533
1556
  env,
1534
- cwd: "/home/user",
1557
+ cwd: "/workspace",
1535
1558
  localMounts,
1536
1559
  commandGuestPaths,
1537
1560
  onDispose: cleanup,
@@ -1588,7 +1611,7 @@ export class AgentOs {
1588
1611
  createVm: async () => createVmAdmin(),
1589
1612
  });
1590
1613
  const vmAdmin = sidecarLease.admin;
1591
- const vm = new AgentOs(vmAdmin.kernel, sidecar, processed.softwareRoots, processed.agentConfigs, vmAdmin.hostMounts, vmAdmin.env, vmAdmin.rootView, vmAdmin.sidecarClient, vmAdmin.sidecarSession, vmAdmin.sidecarVm);
1614
+ const vm = new AgentOs(vmAdmin.kernel, sidecar, processed.softwareRoots, processed.agentConfigs, vmAdmin.hostMounts, vmAdmin.env, vmAdmin.rootView, vmAdmin.sidecarClient, vmAdmin.sidecarSession, vmAdmin.sidecarVm, options?.onAgentStderr ?? defaultAgentStderrHandler);
1592
1615
  vm._sidecarLease = sidecarLease;
1593
1616
  vm._toolKits = vmAdmin.toolKits;
1594
1617
  vm._toolReference = vmAdmin.toolReference;
@@ -1605,6 +1628,10 @@ export class AgentOs {
1605
1628
  async exec(command, options) {
1606
1629
  return this.#kernel.exec(command, options);
1607
1630
  }
1631
+ async execArgv(command, args = [], options) {
1632
+ const kernel = this.#kernel;
1633
+ return kernel.execArgv(command, args, options);
1634
+ }
1608
1635
  _trackProcess(proc, command, args, stdoutHandlers, stderrHandlers, exitHandlers) {
1609
1636
  const entry = {
1610
1637
  proc,
@@ -2227,6 +2254,30 @@ export class AgentOs {
2227
2254
  session.eventHandlers.delete(subscriber);
2228
2255
  };
2229
2256
  }
2257
+ _recordAgentStderr(event) {
2258
+ const session = (event.sessionId ? this._sessions.get(event.sessionId) : undefined) ??
2259
+ [...this._sessions.values()].find((candidate) => candidate.processId === event.processId);
2260
+ const sessionId = event.sessionId || session?.sessionId;
2261
+ if (!sessionId) {
2262
+ return;
2263
+ }
2264
+ const handler = this._agentStderrHandler;
2265
+ if (!handler) {
2266
+ return;
2267
+ }
2268
+ try {
2269
+ handler({
2270
+ sessionId,
2271
+ agentType: event.agentType || session?.agentType || "",
2272
+ processId: event.processId,
2273
+ pid: session?.pid ?? null,
2274
+ chunk: new Uint8Array(event.chunk),
2275
+ });
2276
+ }
2277
+ catch {
2278
+ // Ignore subscriber callback failures and keep event delivery moving.
2279
+ }
2280
+ }
2230
2281
  _applySyntheticConfigOverrides(session) {
2231
2282
  if (session.configOverrides.size === 0) {
2232
2283
  return;
@@ -2283,6 +2334,10 @@ export class AgentOs {
2283
2334
  this._recordSessionNotification(session, toJsonRpcNotification(JSON.parse(event.val.notification)));
2284
2335
  return;
2285
2336
  }
2337
+ case "AcpAgentStderrEvent": {
2338
+ this._recordAgentStderr(event.val);
2339
+ return;
2340
+ }
2286
2341
  }
2287
2342
  }
2288
2343
  catch {
@@ -2507,7 +2562,7 @@ export class AgentOs {
2507
2562
  // skipOsInstructions plus the agent's static launch args and env.
2508
2563
  const launchArgs = [...(config.launchArgs ?? [])];
2509
2564
  let launchEnv = { ...config.defaultEnv, ...options?.env };
2510
- const sessionCwd = options?.cwd ?? "/home/user";
2565
+ const sessionCwd = options?.cwd ?? "/workspace";
2511
2566
  const adapterEntrypoint = this._resolveAdapterBin(config.acpAdapter);
2512
2567
  if ((agentType === "pi" || agentType === "pi-cli") &&
2513
2568
  !launchEnv.PI_ACP_PI_COMMAND) {
@@ -2585,7 +2640,7 @@ export class AgentOs {
2585
2640
  }
2586
2641
  const adapterEntrypoint = this._resolveAdapterBin(config.acpAdapter);
2587
2642
  let launchEnv = { ...config.defaultEnv, ...options?.env };
2588
- const sessionCwd = options?.cwd ?? "/home/user";
2643
+ const sessionCwd = options?.cwd ?? "/workspace";
2589
2644
  if ((agentType === "pi" || agentType === "pi-cli") &&
2590
2645
  !launchEnv.PI_ACP_PI_COMMAND) {
2591
2646
  launchEnv = {
@@ -3498,7 +3553,7 @@ function getSharedAgentOsSidecarInternal(options = {}) {
3498
3553
  if (existing && existing.describe().state !== "disposed") {
3499
3554
  return existing;
3500
3555
  }
3501
- const sidecar = new AgentOsSidecar(`agent-os-shared-sidecar:${pool}`, { kind: "shared", ...(pool ? { pool } : {}) }, pool);
3556
+ const sidecar = new AgentOsSidecar(`agentos-shared-sidecar:${pool}`, { kind: "shared", ...(pool ? { pool } : {}) }, pool);
3502
3557
  sharedSidecars.set(pool, sidecar);
3503
3558
  return sidecar;
3504
3559
  }
package/dist/agents.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // Agent configurations for ACP-compatible coding agents
2
2
  export const AGENT_CONFIGS = {
3
3
  pi: {
4
- acpAdapter: "@rivet-dev/agentos-pi",
4
+ acpAdapter: "@agentos-software/pi",
5
5
  agentPackage: "@mariozechner/pi-coding-agent",
6
6
  },
7
7
  "pi-cli": {
@@ -9,18 +9,18 @@ export const AGENT_CONFIGS = {
9
9
  agentPackage: "@mariozechner/pi-coding-agent",
10
10
  },
11
11
  opencode: {
12
- acpAdapter: "@rivet-dev/agentos-opencode",
13
- agentPackage: "@rivet-dev/agentos-opencode",
12
+ acpAdapter: "@agentos-software/opencode",
13
+ agentPackage: "@agentos-software/opencode",
14
14
  defaultEnv: {
15
15
  OPENCODE_DISABLE_CONFIG_DEP_INSTALL: "1",
16
16
  OPENCODE_DISABLE_EMBEDDED_WEB_UI: "1",
17
17
  },
18
18
  },
19
19
  claude: {
20
- acpAdapter: "@rivet-dev/agentos-claude",
20
+ acpAdapter: "@agentos-software/claude-code",
21
21
  agentPackage: "@anthropic-ai/claude-agent-sdk",
22
22
  defaultEnv: {
23
- CLAUDE_AGENT_SDK_CLIENT_APP: "@rivet-dev/agent-os",
23
+ CLAUDE_AGENT_SDK_CLIENT_APP: "@rivet-dev/agentos",
24
24
  CLAUDE_CODE_SIMPLE: "1",
25
25
  CLAUDE_CODE_FORCE_AGENT_OS_RIPGREP: "1",
26
26
  CLAUDE_CODE_DEFER_GROWTHBOOK_INIT: "1",
@@ -145,10 +145,7 @@ export class CronManager {
145
145
  break;
146
146
  }
147
147
  case "exec": {
148
- const cmd = action.args?.length
149
- ? `${action.command} ${action.args.join(" ")}`
150
- : action.command;
151
- await this.vm.exec(cmd);
148
+ await this.vm.execArgv(action.command, action.args ?? []);
152
149
  break;
153
150
  }
154
151
  case "callback": {
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // @rivet-dev/agent-os
1
+ // @rivet-dev/agentos
2
2
  export { AgentOs, AgentOsSidecar } from "./agent-os.js";
3
3
  export { AGENT_CONFIGS } from "./agents.js";
4
4
  export { CronManager, InvalidScheduleError, PastScheduleError, TimerScheduleDriver, } from "./cron/index.js";
package/dist/layers.d.ts CHANGED
@@ -3,7 +3,7 @@ import { type FilesystemEntry } from "./filesystem-snapshot.js";
3
3
  import type { VirtualFileSystem } from "./runtime-compat.js";
4
4
  export type OverlayFilesystemMode = "ephemeral" | "read-only";
5
5
  export interface FilesystemSnapshotExport {
6
- format: "agent-os-filesystem-snapshot-v1";
6
+ format: "agentos-filesystem-snapshot-v1";
7
7
  filesystem: {
8
8
  entries: FilesystemEntry[];
9
9
  };
package/dist/layers.js CHANGED
@@ -22,7 +22,7 @@ function isFilesystemSnapshotExport(value) {
22
22
  if (!value || typeof value !== "object") {
23
23
  return false;
24
24
  }
25
- if (value.format !== "agent-os-filesystem-snapshot-v1") {
25
+ if (value.format !== "agentos-filesystem-snapshot-v1") {
26
26
  return false;
27
27
  }
28
28
  const filesystem = value.filesystem;
@@ -37,7 +37,7 @@ function normalizeSnapshotExport(source) {
37
37
  throw new Error("Invalid base filesystem artifact");
38
38
  }
39
39
  return {
40
- format: "agent-os-filesystem-snapshot-v1",
40
+ format: "agentos-filesystem-snapshot-v1",
41
41
  filesystem: {
42
42
  entries: source.source.filesystem.entries,
43
43
  },
@@ -52,7 +52,7 @@ export function createSnapshotExport(entries) {
52
52
  return {
53
53
  kind: "snapshot-export",
54
54
  source: {
55
- format: "agent-os-filesystem-snapshot-v1",
55
+ format: "agentos-filesystem-snapshot-v1",
56
56
  filesystem: { entries },
57
57
  },
58
58
  };
@@ -61,7 +61,7 @@ export interface WasmCommandSoftwareDescriptor extends SoftwareDescriptor {
61
61
  }
62
62
  /**
63
63
  * Any object with a commandDir property is treated as a WASM command package.
64
- * This allows registry packages (e.g., @agent-os-pkgs/coreutils) to be
64
+ * This allows registry packages (e.g., @agentos-software/coreutils) to be
65
65
  * passed directly to the `software` option without wrapping.
66
66
  */
67
67
  export interface WasmCommandDirDescriptor {
@@ -304,6 +304,9 @@ export interface BindingTree {
304
304
  [key: string]: BindingFunction | BindingTree;
305
305
  }
306
306
  export type BindingFunction = (...args: unknown[]) => unknown;
307
+ export interface ModuleAccessOptions {
308
+ cwd?: string;
309
+ }
307
310
  export interface NodeDriverOptions {
308
311
  filesystem?: VirtualFileSystem;
309
312
  networkAdapter?: NetworkAdapter;
@@ -311,6 +314,7 @@ export interface NodeDriverOptions {
311
314
  permissions?: Permissions;
312
315
  processConfig?: ProcessConfig;
313
316
  osConfig?: OSConfig;
317
+ moduleAccess?: ModuleAccessOptions;
314
318
  }
315
319
  export interface DefaultNetworkAdapterOptions {
316
320
  loopbackExemptPorts?: number[];
@@ -36,7 +36,8 @@ const KERNEL_POSIX_BOOTSTRAP_DIRS = [
36
36
  "/mnt",
37
37
  "/media",
38
38
  "/home",
39
- "/home/user",
39
+ "/home/agentos",
40
+ "/workspace",
40
41
  "/usr",
41
42
  "/usr/bin",
42
43
  "/usr/games",
@@ -1632,7 +1633,7 @@ class NativeKernel {
1632
1633
  constructor(options) {
1633
1634
  this.options = options;
1634
1635
  this.env = { ...(options.env ?? {}) };
1635
- this.cwd = options.cwd ?? "/home/user";
1636
+ this.cwd = options.cwd ?? "/workspace";
1636
1637
  this.socketTable = {
1637
1638
  hasHostNetworkAdapter: () => Boolean(options.hostNetworkAdapter),
1638
1639
  findListener: (request) => this.proxy?.findListener(request) ?? null,
@@ -1987,7 +1988,7 @@ class NativeKernel {
1987
1988
  vm,
1988
1989
  env: this.env,
1989
1990
  cwd: this.cwd,
1990
- defaultExecCwd: this.options.cwd === undefined ? "/home/user" : this.cwd,
1991
+ defaultExecCwd: this.options.cwd === undefined ? "/workspace" : this.cwd,
1991
1992
  localMounts: this.pendingLocalMounts,
1992
1993
  commandGuestPaths: new Map(),
1993
1994
  onWasmCommandResolved: (command) => {
@@ -163,9 +163,20 @@ export type AcpSessionEvent = {
163
163
  };
164
164
  export declare function readAcpSessionEvent(bc: bare.ByteCursor): AcpSessionEvent;
165
165
  export declare function writeAcpSessionEvent(bc: bare.ByteCursor, x: AcpSessionEvent): void;
166
+ export type AcpAgentStderrEvent = {
167
+ readonly sessionId: string;
168
+ readonly agentType: string;
169
+ readonly processId: string;
170
+ readonly chunk: ArrayBuffer;
171
+ };
172
+ export declare function readAcpAgentStderrEvent(bc: bare.ByteCursor): AcpAgentStderrEvent;
173
+ export declare function writeAcpAgentStderrEvent(bc: bare.ByteCursor, x: AcpAgentStderrEvent): void;
166
174
  export type AcpEvent = {
167
175
  readonly tag: "AcpSessionEvent";
168
176
  readonly val: AcpSessionEvent;
177
+ } | {
178
+ readonly tag: "AcpAgentStderrEvent";
179
+ readonly val: AcpAgentStderrEvent;
169
180
  };
170
181
  export declare function readAcpEvent(bc: bare.ByteCursor): AcpEvent;
171
182
  export declare function writeAcpEvent(bc: bare.ByteCursor, x: AcpEvent): void;
@@ -1,4 +1,4 @@
1
- // @generated - run pnpm --dir packages/core build:agent-os-protocol
1
+ // @generated - run pnpm --dir packages/core build:agentos-protocol
2
2
  import * as bare from "@rivetkit/bare-ts";
3
3
  const DEFAULT_CONFIG = /* @__PURE__ */ bare.Config({});
4
4
  export function readJsonUtf8(bc) {
@@ -433,12 +433,28 @@ export function writeAcpSessionEvent(bc, x) {
433
433
  bare.writeString(bc, x.sessionId);
434
434
  writeJsonUtf8(bc, x.notification);
435
435
  }
436
+ export function readAcpAgentStderrEvent(bc) {
437
+ return {
438
+ sessionId: bare.readString(bc),
439
+ agentType: bare.readString(bc),
440
+ processId: bare.readString(bc),
441
+ chunk: bare.readData(bc),
442
+ };
443
+ }
444
+ export function writeAcpAgentStderrEvent(bc, x) {
445
+ bare.writeString(bc, x.sessionId);
446
+ bare.writeString(bc, x.agentType);
447
+ bare.writeString(bc, x.processId);
448
+ bare.writeData(bc, x.chunk);
449
+ }
436
450
  export function readAcpEvent(bc) {
437
451
  const offset = bc.offset;
438
452
  const tag = bare.readU8(bc);
439
453
  switch (tag) {
440
454
  case 0:
441
455
  return { tag: "AcpSessionEvent", val: readAcpSessionEvent(bc) };
456
+ case 1:
457
+ return { tag: "AcpAgentStderrEvent", val: readAcpAgentStderrEvent(bc) };
442
458
  default: {
443
459
  bc.offset = offset;
444
460
  throw new bare.BareError(offset, "invalid tag");
@@ -452,6 +468,11 @@ export function writeAcpEvent(bc, x) {
452
468
  writeAcpSessionEvent(bc, x.val);
453
469
  break;
454
470
  }
471
+ case "AcpAgentStderrEvent": {
472
+ bare.writeU8(bc, 1);
473
+ writeAcpAgentStderrEvent(bc, x.val);
474
+ break;
475
+ }
455
476
  }
456
477
  }
457
478
  export function encodeAcpEvent(x, config) {
@@ -1,2 +1,3 @@
1
- export { NATIVE_SIDECAR_FRAME_TIMEOUT_MS, NativeSidecarProcessClient as SidecarProcess, SidecarEventBufferOverflow, SidecarProcessError, SidecarProcessExited, } from "@secure-exec/core/sidecar-client";
2
- export type { AuthenticatedSession, CreatedVm, ExtEnvelope, GuestFilesystemStat, NativeSidecarSpawnOptions as SidecarSpawnOptions, RootFilesystemEntry, RootFilesystemLowerDescriptor, SidecarEventSelector, SidecarFsPermissionRule, SidecarMountDescriptor, SidecarMountPluginDescriptor, SidecarPatternPermissionRule, SidecarPermissionMode, SidecarPermissionScope, SidecarPermissionsPolicy, SidecarProcessSnapshotEntry, SidecarProjectedModuleDescriptor, SidecarRegisteredHostCallbackDefinition, SidecarRegisteredHostCallbackExample, SidecarRequestFrame, SidecarRequestHandler, SidecarRequestPayload, SidecarResponseFrame, SidecarResponsePayload, SidecarRulePermissions, SidecarSessionState, SidecarSignalHandlerRegistration, SidecarSignalState, SidecarSocketStateEntry, SidecarSoftwareDescriptor, SidecarZombieTimerCount, } from "@secure-exec/core/sidecar-client";
1
+ import "@secure-exec/core/native-client";
2
+ export { NATIVE_SIDECAR_FRAME_TIMEOUT_MS, SidecarProcess, SidecarProcess as NativeSidecarProcessClient, SidecarEventBufferOverflow, SidecarProcessError, SidecarProcessExited, } from "@secure-exec/core/sidecar-client";
3
+ export type { AuthenticatedSession, CreatedVm, ExtEnvelope, GuestFilesystemStat, RootFilesystemEntry, RootFilesystemLowerDescriptor, SidecarEventSelector, SidecarFsPermissionRule, SidecarMountDescriptor, SidecarMountPluginDescriptor, SidecarPatternPermissionRule, SidecarPermissionMode, SidecarPermissionScope, SidecarPermissionsPolicy, SidecarProcessSnapshotEntry, SidecarProjectedModuleDescriptor, SidecarRegisteredHostCallbackDefinition, SidecarRegisteredHostCallbackExample, SidecarRequestFrame, SidecarRequestHandler, SidecarRequestPayload, SidecarResponseFrame, SidecarResponsePayload, SidecarRulePermissions, SidecarSessionState, SidecarSignalHandlerRegistration, SidecarSignalState, SidecarSocketStateEntry, SidecarSoftwareDescriptor, SidecarSpawnOptions, SidecarSpawnOptions as NativeSidecarSpawnOptions, SidecarZombieTimerCount, } from "@secure-exec/core/sidecar-client";
@@ -1 +1,6 @@
1
- export { NATIVE_SIDECAR_FRAME_TIMEOUT_MS, NativeSidecarProcessClient as SidecarProcess, SidecarEventBufferOverflow, SidecarProcessError, SidecarProcessExited, } from "@secure-exec/core/sidecar-client";
1
+ // Register the native sidecar spawn factory (side effect). After the
2
+ // @secure-exec/core SidecarProcess refactor, native spawn is provided by a
3
+ // separately-registered factory; importing native-client wires it up so
4
+ // SidecarProcess.spawn works in this native runtime.
5
+ import "@secure-exec/core/native-client";
6
+ export { NATIVE_SIDECAR_FRAME_TIMEOUT_MS, SidecarProcess, SidecarProcess as NativeSidecarProcessClient, SidecarEventBufferOverflow, SidecarProcessError, SidecarProcessExited, } from "@secure-exec/core/sidecar-client";
@@ -28,7 +28,7 @@ export function serializePermissionsForSidecar(permissions) {
28
28
  childProcess: "deny",
29
29
  process: "deny",
30
30
  env: "deny",
31
- tool: "deny",
31
+ binding: "deny",
32
32
  };
33
33
  }
34
34
  return {
@@ -47,7 +47,7 @@ export function serializePermissionsForSidecar(permissions) {
47
47
  env: typeof permissions.env === "string" || !permissions.env
48
48
  ? permissions.env
49
49
  : serializePatternScope(permissions.env),
50
- tool: typeof permissions.tool === "string" || !permissions.tool
50
+ binding: typeof permissions.tool === "string" || !permissions.tool
51
51
  ? permissions.tool
52
52
  : serializePatternScope(permissions.tool),
53
53
  };
@@ -71,6 +71,7 @@ export declare class NativeSidecarKernelProxy {
71
71
  registerCommandGuestPaths(commandGuestPaths: ReadonlyMap<string, string>): void;
72
72
  dispose(): Promise<void>;
73
73
  exec(command: string, options?: KernelExecOptions): Promise<KernelExecResult>;
74
+ execArgv(command: string, args?: readonly string[], options?: KernelExecOptions): Promise<KernelExecResult>;
74
75
  spawn(command: string, args: string[], options?: KernelSpawnOptions): ManagedProcess;
75
76
  openShell(options?: OpenShellOptions): ShellHandle;
76
77
  connectTerminal(options?: ConnectTerminalOptions): Promise<number>;
@@ -376,6 +376,51 @@ export class NativeSidecarKernelProxy {
376
376
  });
377
377
  return runAndCapture(proc);
378
378
  }
379
+ async execArgv(command, args = [], options) {
380
+ const stdoutChunks = [];
381
+ const stderrChunks = [];
382
+ const effectiveCwd = options?.cwd ?? this.defaultExecCwd ?? this.cwd;
383
+ const runAndCapture = async (proc) => {
384
+ if (options?.stdin !== undefined) {
385
+ proc.writeStdin(options.stdin);
386
+ }
387
+ proc.closeStdin();
388
+ const waitPromise = proc.wait();
389
+ const exitCode = typeof options?.timeout === "number"
390
+ ? await new Promise((resolve) => {
391
+ const timer = setTimeout(() => {
392
+ proc.kill(9);
393
+ void proc.wait().then(resolve);
394
+ }, options.timeout);
395
+ void waitPromise.then((code) => {
396
+ clearTimeout(timer);
397
+ resolve(code);
398
+ });
399
+ })
400
+ : await waitPromise;
401
+ await drainTrailingProcessOutputTurn();
402
+ return {
403
+ exitCode,
404
+ stdout: Buffer.concat(stdoutChunks.map((chunk) => Buffer.from(chunk))).toString("utf8"),
405
+ stderr: Buffer.concat(stderrChunks.map((chunk) => Buffer.from(chunk))).toString("utf8"),
406
+ };
407
+ };
408
+ if (this.commands.get(command) === "wasmvm") {
409
+ this.onWasmCommandResolved?.(command);
410
+ }
411
+ return runAndCapture(this.spawn(command, [...args], {
412
+ ...options,
413
+ cwd: effectiveCwd,
414
+ onStdout: (chunk) => {
415
+ stdoutChunks.push(chunk);
416
+ options?.onStdout?.(chunk);
417
+ },
418
+ onStderr: (chunk) => {
419
+ stderrChunks.push(chunk);
420
+ options?.onStderr?.(chunk);
421
+ },
422
+ }));
423
+ }
379
424
  spawn(command, args, options) {
380
425
  let spawnCommand = command;
381
426
  let spawnArgs = [...args];
@@ -152,7 +152,7 @@ async function runCommand(request) {
152
152
  });
153
153
  }
154
154
  export async function startMockSandboxAgent() {
155
- const rootDir = await mkdtemp(resolve(tmpdir(), "agent-os-sandbox-agent-"));
155
+ const rootDir = await mkdtemp(resolve(tmpdir(), "agentos-sandbox-agent-"));
156
156
  const processes = new Map();
157
157
  const server = createServer(async (request, response) => {
158
158
  try {
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type { AgentCapabilities, AgentInfo, AgentOsCreateSidecarOptions, AgentOsLimits, AgentOsOptions, AgentOsSharedSidecarOptions, AgentOsSidecarConfig, AgentOsSidecarDescription, AgentRegistryEntry, BatchReadResult, BatchWriteEntry, BatchWriteResult, CreateSessionOptions, DirEntry, 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 { AgentCapabilities, AgentInfo, AgentOsCreateSidecarOptions, AgentOsLimits, AgentOsOptions, AgentOsSharedSidecarOptions, AgentOsSidecarConfig, AgentOsSidecarDescription, AgentStderrEvent, AgentStderrHandler, AgentRegistryEntry, BatchReadResult, BatchWriteEntry, BatchWriteResult, CreateSessionOptions, DirEntry, 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";
2
2
  export type { AgentConfig, AgentType } from "./agents.js";
3
3
  export type { CronAction, CronEvent, CronEventHandler, CronJob, CronJobInfo, CronJobOptions, ScheduleDriver, ScheduleEntry, ScheduleHandle, } from "./cron/index.js";
4
4
  export type { HostDirBackendOptions, HostDirMountPluginConfig, NodeModulesMountConfig, } from "./host-dir-mount.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivet-dev/agentos-core",
3
- "version": "0.0.0-agentos-dylib-plugin.bbfdf95",
3
+ "version": "0.0.0-codex-on-agent-stderr.dd7a603",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
@@ -49,15 +49,16 @@
49
49
  "scripts": {
50
50
  "check-types": "pnpm run build:protocols && tsc --noEmit",
51
51
  "build": "pnpm run build:protocols && tsc",
52
- "build:agent-os-protocol": "node ./scripts/compile-agent-os-protocol.mjs",
53
- "build:protocols": "pnpm run build:agent-os-protocol",
52
+ "build:agentos-protocol": "node ./scripts/compile-agentos-protocol.mjs",
53
+ "build:protocols": "pnpm run build:agentos-protocol",
54
54
  "test": "vitest run --reporter=verbose"
55
55
  },
56
56
  "dependencies": {
57
+ "@agentos-software/common": "0.3.0-rc.2",
57
58
  "@aws-sdk/client-s3": "^3.1019.0",
58
- "@rivet-dev/agentos-sidecar": "0.0.0-agentos-dylib-plugin.bbfdf95",
59
+ "@rivet-dev/agentos-sidecar": "0.0.0-codex-on-agent-stderr.dd7a603",
59
60
  "@rivetkit/bare-ts": "^0.6.2",
60
- "@secure-exec/core": "0.3.0",
61
+ "@secure-exec/core": "0.0.0-nathan-workspace-binding-agentos.83db3e3",
61
62
  "@xterm/headless": "^6.0.0",
62
63
  "better-sqlite3": "^12.8.0",
63
64
  "croner": "^10.0.1",
@@ -74,32 +75,32 @@
74
75
  "@browserbasehq/sdk": "2.10.0",
75
76
  "@bare-ts/tools": "0.15.0",
76
77
  "@copilotkit/llmock": "^1.6.0",
77
- "@rivet-dev/agentos-sandbox": "link:../agent-os-sandbox",
78
- "@agent-os-pkgs/git": "0.0.0-split-runtime-preview.5d46b14",
79
- "@secure-exec/google-drive": "0.3.0",
80
- "@secure-exec/s3": "0.3.0",
78
+ "@rivet-dev/agentos-sandbox": "link:../agentos-sandbox",
79
+ "@agentos-software/git": "0.3.0-rc.2",
80
+ "@secure-exec/google-drive": "0.0.0-nathan-workspace-binding-agentos.83db3e3",
81
+ "@secure-exec/s3": "0.0.0-nathan-workspace-binding-agentos.83db3e3",
81
82
  "@mariozechner/pi-coding-agent": "^0.60.0",
82
- "@rivet-dev/agentos-claude": "link:../../registry/agent/claude",
83
- "@agent-os-pkgs/codex": "0.0.0-split-runtime-preview.5d46b14",
84
- "@rivet-dev/agentos-codex-agent": "link:../../registry/agent/codex",
85
- "@agent-os-pkgs/coreutils": "0.0.0-split-runtime-preview.5d46b14",
86
- "@agent-os-pkgs/curl": "0.0.0-split-runtime-preview.5d46b14",
87
- "@agent-os-pkgs/diffutils": "0.0.0-split-runtime-preview.5d46b14",
88
- "@agent-os-pkgs/fd": "0.0.0-split-runtime-preview.5d46b14",
89
- "@agent-os-pkgs/file": "0.0.0-split-runtime-preview.5d46b14",
90
- "@agent-os-pkgs/findutils": "0.0.0-split-runtime-preview.5d46b14",
91
- "@agent-os-pkgs/gawk": "0.0.0-split-runtime-preview.5d46b14",
92
- "@agent-os-pkgs/grep": "0.0.0-split-runtime-preview.5d46b14",
93
- "@agent-os-pkgs/gzip": "0.0.0-split-runtime-preview.5d46b14",
94
- "@agent-os-pkgs/jq": "0.0.0-split-runtime-preview.5d46b14",
95
- "@rivet-dev/agentos-opencode": "link:../../registry/agent/opencode",
96
- "@rivet-dev/agentos-pi": "link:../../registry/agent/pi",
97
- "@rivet-dev/agentos-pi-cli": "link:../../registry/agent/pi-cli",
98
- "@agent-os-pkgs/ripgrep": "0.0.0-split-runtime-preview.5d46b14",
99
- "@agent-os-pkgs/sed": "0.0.0-split-runtime-preview.5d46b14",
100
- "@agent-os-pkgs/tar": "0.0.0-split-runtime-preview.5d46b14",
101
- "@agent-os-pkgs/tree": "0.0.0-split-runtime-preview.5d46b14",
102
- "@agent-os-pkgs/yq": "0.0.0-split-runtime-preview.5d46b14",
83
+ "@agentos-software/claude-code": "link:../../registry/agent/claude",
84
+ "@agentos-software/codex-cli": "0.3.0-rc.2",
85
+ "@agentos-software/codex": "link:../../registry/agent/codex",
86
+ "@agentos-software/coreutils": "0.3.0-rc.2",
87
+ "@agentos-software/curl": "0.3.0-rc.2",
88
+ "@agentos-software/diffutils": "0.3.0-rc.2",
89
+ "@agentos-software/fd": "0.3.0-rc.2",
90
+ "@agentos-software/file": "0.3.0-rc.2",
91
+ "@agentos-software/findutils": "0.3.0-rc.2",
92
+ "@agentos-software/gawk": "0.3.0-rc.2",
93
+ "@agentos-software/grep": "0.3.0-rc.2",
94
+ "@agentos-software/gzip": "0.3.0-rc.2",
95
+ "@agentos-software/jq": "0.3.0-rc.2",
96
+ "@agentos-software/opencode": "link:../../registry/agent/opencode",
97
+ "@agentos-software/pi": "link:../../registry/agent/pi",
98
+ "@agentos-software/pi-cli": "link:../../registry/agent/pi-cli",
99
+ "@agentos-software/ripgrep": "0.3.0-rc.2",
100
+ "@agentos-software/sed": "0.3.0-rc.2",
101
+ "@agentos-software/tar": "0.3.0-rc.2",
102
+ "@agentos-software/tree": "0.3.0-rc.2",
103
+ "@agentos-software/yq": "0.3.0-rc.2",
103
104
  "@types/node": "^22.10.2",
104
105
  "pi-acp": "^0.0.23",
105
106
  "sandbox-agent": "^0.4.2",