diff --git a/vendor/agentos/docs/content/docs/agents/claude.mdx b/vendor/agentos/docs/content/docs/agents/claude.mdx index f8c2d160..ab623dd5 100644 --- a/vendor/agentos/docs/content/docs/agents/claude.mdx +++ b/vendor/agentos/docs/content/docs/agents/claude.mdx @@ -4,7 +4,7 @@ description: "Run Claude Code inside an agentOS VM with durable sessions, config skill: false --- -## Quick start +## Quickstart @@ -27,6 +27,23 @@ Set the relevant variable(s) on the session's `env`, sourced from your server's See [Models & Credentials](/agentos/docs/models-and-credentials), and Claude Code's [environment variables](https://code.claude.com/docs/en/env-vars) for the full list. +## System prompt + +By default, the agentOS [system prompt](/agentos/docs/system-prompt), including your `additionalInstructions`, is appended to Claude Code's built-in `claude_code` system prompt. + +To use only your own system prompt, set `ACP_SYSTEM_PROMPT_MODE=replace` on the session's `env`. The built-in Claude Code prompt is dropped, and Claude receives the assembled agentOS prompt instead. Use `skipOsInstructions: true` with `additionalInstructions` to send only your text. + +```ts +await agent.sessions.open({ + agent: "claude", + env: { ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY!, ACP_SYSTEM_PROMPT_MODE: "replace" }, + skipOsInstructions: true, + additionalInstructions: "You are a support assistant for Acme's billing API.", +}); +``` + +`ACP_SYSTEM_PROMPT_MODE` accepts `append` (the default) or `replace`. Any other value makes the session fail to start with an error that names the variable. `replace` also needs a non-empty prompt, so don't combine it with `skipOsInstructions` unless you set `additionalInstructions`. + ## Skills Claude Code discovers [agent skills](https://docs.claude.com/en/docs/claude-code/skills) from `SKILL.md` files under its skills directory. Write the skill into the VM before creating a session and Claude Code loads it automatically. diff --git a/vendor/agentos/docs/content/docs/agents/codex.mdx b/vendor/agentos/docs/content/docs/agents/codex.mdx index 4b9a2f61..a3fce686 100644 --- a/vendor/agentos/docs/content/docs/agents/codex.mdx +++ b/vendor/agentos/docs/content/docs/agents/codex.mdx @@ -5,7 +5,7 @@ description: "Run Codex inside an agentOS VM with durable sessions, configurable skill: false --- -## Quick start +## Quickstart diff --git a/vendor/agentos/docs/content/docs/agents/opencode.mdx b/vendor/agentos/docs/content/docs/agents/opencode.mdx index 76626444..4292c051 100644 --- a/vendor/agentos/docs/content/docs/agents/opencode.mdx +++ b/vendor/agentos/docs/content/docs/agents/opencode.mdx @@ -4,7 +4,7 @@ description: "Run OpenCode inside an agentOS VM with durable sessions, configura skill: false --- -## Quick start +## Quickstart diff --git a/vendor/agentos/docs/content/docs/agents/pi.mdx b/vendor/agentos/docs/content/docs/agents/pi.mdx index c91bed34..aafad71e 100644 --- a/vendor/agentos/docs/content/docs/agents/pi.mdx +++ b/vendor/agentos/docs/content/docs/agents/pi.mdx @@ -5,12 +5,12 @@ description: "Run Pi inside an agentOS VM with durable sessions, extensions, cus skill: true --- -## Quick start +## Quickstart - + Read [Sessions](/agentos/docs/sessions) first for session options, streaming events, prompts, and lifecycle management. diff --git a/vendor/agentos/docs/content/docs/architecture/javascript-executor.mdx b/vendor/agentos/docs/content/docs/architecture/javascript-executor.mdx index 53d36df9..42232d95 100644 --- a/vendor/agentos/docs/content/docs/architecture/javascript-executor.mdx +++ b/vendor/agentos/docs/content/docs/architecture/javascript-executor.mdx @@ -39,8 +39,9 @@ Guest V8 execution is deliberately different: the only non-V8 platform thread that enters that isolate. - Synchronous guest JavaScript or a synchronous bridge wait can block that executor, but cannot occupy a Tokio worker or another VM's executor. -- The number of active and warm executor threads is bounded separately from - socket and task counts. +- Operators can cap active executor threads separately from socket and task + counts with `runtime.executor.maxActiveVms`. Executor admission is uncapped + by default and is not derived from the sidecar's reported CPU count. There is therefore no "Tokio task running a Node.js process." Trusted I/O runs as Tokio tasks; untrusted JavaScript runs on a V8 executor thread. diff --git a/vendor/agentos/docs/content/docs/bindings.mdx b/vendor/agentos/docs/content/docs/bindings.mdx index ce9d0f1c..1be4ffc5 100644 --- a/vendor/agentos/docs/content/docs/bindings.mdx +++ b/vendor/agentos/docs/content/docs/bindings.mdx @@ -4,7 +4,7 @@ description: "Expose trusted host functions to agentOS coding agents as typed CL skill: true --- -Expose your host JavaScript functions (defined with Zod input schemas) to agents as auto-generated CLI commands installed at `/usr/local/bin/agentos-{name}` inside the VM, injected into the agent's [system prompt](/agentos/docs/system-prompt) and callable inside scripts for code-mode token savings. +Expose your host JavaScript functions (defined with Zod input schemas) to agents as auto-generated CLI commands installed at `/bin/agentos-{name}` inside the VM, injected into the agent's [system prompt](/agentos/docs/system-prompt) and callable inside scripts for code-mode token savings. ## Getting started @@ -34,7 +34,7 @@ Optional fields (via `.optional()`) become optional flags. Required fields are e ### What the agent sees -When bindings are registered, CLI shims are installed at `/usr/local/bin/agentos-{name}` inside the VM and the binding list is injected into the agent's [system prompt](/agentos/docs/system-prompt), so keep binding descriptions concise to save tokens. +When bindings are registered, CLI shims are installed at `/bin/agentos-{name}` inside the VM and the binding list is injected into the agent's [system prompt](/agentos/docs/system-prompt), so keep binding descriptions concise to save tokens. The agent interacts with bindings as shell commands: diff --git a/vendor/agentos/docs/content/docs/javascript.mdx b/vendor/agentos/docs/content/docs/javascript.mdx index 3951977f..54503db4 100644 --- a/vendor/agentos/docs/content/docs/javascript.mdx +++ b/vendor/agentos/docs/content/docs/javascript.mdx @@ -44,8 +44,8 @@ interpolated into source. ## Keep state between calls -Pass a `contextId` to keep globals, imports, and modules alive across calls in -one retained V8 isolate. +Pass a `contextId` to keep one V8 isolate and its global state alive across +calls. @@ -53,6 +53,12 @@ A context runs one operation at a time — reusing a busy `contextId` fails immediately. Files, npm, Bash, and type checks may pass the same id, but they run in fresh processes and never touch retained memory. +JavaScript defaults to `format: "module"`. Each call is a separate root ES +module, so its imports, top-level declarations, and exports are scoped to that +call. Put values on `globalThis` when a later call in the same context needs +them. For REPL-style script semantics where top-level lexical declarations stay +visible, pass `format: "commonjs"` consistently for that context. + Create the context explicitly before use; an unknown id fails instead of silently starting fresh state. A context pins to the first inline language that used it, though JavaScript and TypeScript intentionally share one isolate. diff --git a/vendor/agentos/docs/content/docs/resource-limits.mdx b/vendor/agentos/docs/content/docs/resource-limits.mdx index 9646c97b..c7f8ec2a 100644 --- a/vendor/agentos/docs/content/docs/resource-limits.mdx +++ b/vendor/agentos/docs/content/docs/resource-limits.mdx @@ -15,6 +15,11 @@ Every agentOS VM runs with **per-VM resource and runtime caps**. These caps cont Set caps on the `limits` object in the `agentOS` config. Limits are grouped by subsystem (`resources`, `process`, `jsRuntime`, `python`, `wasm`, and more). Omitted limits keep their secure default. +V8 executor admission is process-wide rather than per-VM. It is uncapped by +default and does not derive a ceiling from the sidecar's reported CPU count. +Operators can set `runtime.executor.maxActiveVms` when creating a sidecar to +enforce an explicit concurrent-executor ceiling. + ## Available caps @@ -23,7 +28,7 @@ Set caps on the `limits` object in the `agentOS` config. Limits are grouped by s |---|---|---| | `resources.maxProcesses` | Concurrent processes in the VM process table | Caps fork bombs and runaway spawning. New spawns fail with `EAGAIN`. | | `resources.maxOpenFds` | Open file descriptors | Exhausting the table fails with `EMFILE` / `ENFILE`. | -| `resources.maxSockets` | Open sockets in the socket table | Bounds concurrent connections; excess `connect`/`accept` fail. | +| `resources.maxSockets` | Open sockets in the socket table | Default is `256`. This includes guest sockets and the sidecar-owned sockets used to send host requests into VM services. Excess socket operations fail instead of consuming more host resources. | | `resources.maxFilesystemBytes` | Total bytes stored in the virtual filesystem | Bounds VFS storage; writes past the budget fail with a no-space error. | | `resources.maxInodeCount` | Inodes retained by the virtual filesystem | Default is `16384`; creating another file or directory fails with a no-space error. This is the expected upper bound for filesystem-schema sizing and benchmarks. | | `resources.maxWasmFuel` | WASM execution budget | Bounds WASM execution work; unset means no explicit fuel budget. | @@ -53,6 +58,19 @@ Set caps on the `limits` object in the `agentOS` config. Limits are grouped by s | `process.maxSpawnFileActions` | File actions decoded for one `posix_spawn` call | Default is `4096`; excess actions fail with `E2BIG`. | | `process.maxSpawnFileActionBytes` | Serialized file-action bytes for one `posix_spawn` call | Default is `1 MiB`; excess input fails with `E2BIG`. | +### Streaming fetch responses + +A VM may have at most `256` host-to-VM streaming HTTP responses open at once. +This is a fixed runtime limit and does not have a `limits` configuration field. +A stream occupies one slot after `fetchStreamStart()` returns and releases it +when `fetchStreamRead()` reports `done: true` or the host calls +`fetchStreamCancel()`. Opening another stream at the limit fails with +`ERR_AGENTOS_VM_FETCH_STREAM_LIMIT`. + +This limit bounds concurrent streams, not the number of requests a warm VM can +serve over its lifetime. Completed and cancelled streams do not accumulate +toward the limit. + ## Behavior at the limit - **WASM stack**: deep recursion throws a stack-overflow error in the guest, never a host crash. diff --git a/vendor/agentos/docs/content/docs/system-prompt.mdx b/vendor/agentos/docs/content/docs/system-prompt.mdx index 307d215e..981b7b03 100644 --- a/vendor/agentos/docs/content/docs/system-prompt.mdx +++ b/vendor/agentos/docs/content/docs/system-prompt.mdx @@ -14,5 +14,6 @@ The base prompt is embedded in the sidecar (not written to a file inside the VM) - `additionalInstructions` appends session-specific text after the base OS prompt and before the generated binding docs, rather than replacing the agent's own instructions. - `skipOsInstructions` suppresses the base OS prompt while still injecting the generated binding docs. +- For Claude Code, `ACP_SYSTEM_PROMPT_MODE=replace` in the session `env` replaces Claude Code's built-in system prompt with the assembled prompt. See [Claude Code](/agentos/docs/agents/claude#system-prompt). diff --git a/vendor/agentos/examples/bindings/README.md b/vendor/agentos/examples/bindings/README.md index 9be61ce7..92a895bc 100644 --- a/vendor/agentos/examples/bindings/README.md +++ b/vendor/agentos/examples/bindings/README.md @@ -9,7 +9,7 @@ Give an agent access to your own host code—API calls, database lookups, intern ## How it works -A binding collection bundles a `name`, a `description`, and a map of named `bindings`. Each binding declares a Zod `inputSchema`, an `execute` handler that runs on the host, and optional `examples`. Pass collections to `agentOS({ bindings: [...] })`; AgentOS exposes each collection as `/usr/local/bin/agentos-{name}` inside the VM. When an agent invokes a binding, its schema validates the arguments before the handler executes host-side. +A binding collection bundles a `name`, a `description`, and a map of named `bindings`. Each binding declares a Zod `inputSchema`, an `execute` handler that runs on the host, and optional `examples`. Pass collections to `agentOS({ bindings: [...] })`; AgentOS exposes each collection as `/bin/agentos-{name}` inside the VM. When an agent invokes a binding, its schema validates the arguments before the handler executes host-side. ## Run it diff --git a/vendor/agentos/examples/bindings/server.ts b/vendor/agentos/examples/bindings/server.ts index e29b83d3..3c909113 100644 --- a/vendor/agentos/examples/bindings/server.ts +++ b/vendor/agentos/examples/bindings/server.ts @@ -3,7 +3,7 @@ import { z } from "zod"; // Define a group of bindings (host functions). Each binding has a Zod input // schema and an `execute` handler that runs on the host. The group is exposed to -// the agent as a CLI command at /usr/local/bin/agentos-{name} inside the VM. +// the agent as a CLI command at /bin/agentos-{name} inside the VM. const weatherBindings = { name: "weather", description: "Weather data bindings", diff --git a/vendor/agentos/examples/browserbase/client-direct.ts b/vendor/agentos/examples/browserbase/client-direct.ts index 49e2cb62..dd7aec63 100644 --- a/vendor/agentos/examples/browserbase/client-direct.ts +++ b/vendor/agentos/examples/browserbase/client-direct.ts @@ -17,7 +17,11 @@ const env = { const { stdout } = await agent.process.exec("browse cloud fetch https://example.com", { env, + output: { capture: "all" }, }); +if (!stdout) { + throw new Error("Browserbase command returned no output"); +} const page = JSON.parse(stdout) as { statusCode: number; content: string }; console.log(`fetched status ${page.statusCode}`); diff --git a/vendor/agentos/examples/browserbase/client.ts b/vendor/agentos/examples/browserbase/client.ts index c07d591a..6d9ac035 100644 --- a/vendor/agentos/examples/browserbase/client.ts +++ b/vendor/agentos/examples/browserbase/client.ts @@ -18,7 +18,11 @@ const env = { const { stdout } = await agent.process.exec("browse cloud fetch https://example.com", { env, + output: { capture: "all" }, }); +if (!stdout) { + throw new Error("Browserbase command returned no output"); +} const page = JSON.parse(stdout) as { statusCode: number; content: string }; console.log(`fetched status ${page.statusCode}`); diff --git a/vendor/agentos/examples/claude/client.ts b/vendor/agentos/examples/claude/client.ts index 4467e5b5..76c09730 100644 --- a/vendor/agentos/examples/claude/client.ts +++ b/vendor/agentos/examples/claude/client.ts @@ -6,7 +6,7 @@ const client = createClient({ }); const agent = client.vm.getOrCreate("my-agent"); -// ── Quick start ─────────────────────────────────────────────────── +// ── Quickstart ──────────────────────────────────────────────────── async function quickStart() { // docs:start quickstart await agent.sessions.open({ diff --git a/vendor/agentos/examples/codex/client.ts b/vendor/agentos/examples/codex/client.ts index 1a827c55..6143777d 100644 --- a/vendor/agentos/examples/codex/client.ts +++ b/vendor/agentos/examples/codex/client.ts @@ -7,7 +7,7 @@ const client = createClient({ }); const agent = client.vm.getOrCreate("my-agent"); -// ── Quick start ─────────────────────────────────────────────────── +// ── Quickstart ──────────────────────────────────────────────────── async function quickStart() { await agent.sessions.open({ agent: "codex", diff --git a/vendor/agentos/examples/embedded/limits.ts b/vendor/agentos/examples/embedded/limits.ts index 14c19c3f..da2fe4c5 100644 --- a/vendor/agentos/examples/embedded/limits.ts +++ b/vendor/agentos/examples/embedded/limits.ts @@ -1,8 +1,13 @@ import { AgentOs } from "@rivet-dev/agentos-core"; +const sidecar = await AgentOs.createSidecar({ + runtime: { executor: { maxActiveVms: 8 } }, +}); + // The same `limits` object the actor takes. `onLimitWarning` is an embedded // create option rather than a broadcast event, so it fires only in this process. const vm = await AgentOs.create({ + sidecar: { kind: "explicit", handle: sidecar }, limits: { resources: { maxProcesses: 64, maxFilesystemBytes: 256 * 1024 * 1024 }, jsRuntime: { v8HeapLimitMb: 128, cpuTimeLimitMs: 30_000 }, @@ -12,3 +17,4 @@ const vm = await AgentOs.create({ }, }); await vm.dispose(); +await sidecar.dispose(); diff --git a/vendor/agentos/examples/filesystem/isolation.ts b/vendor/agentos/examples/filesystem/isolation.ts index 9fc6a178..1195cefa 100644 --- a/vendor/agentos/examples/filesystem/isolation.ts +++ b/vendor/agentos/examples/filesystem/isolation.ts @@ -18,8 +18,8 @@ const result = await agent.process.exec(`node -e ' const note = readFileSync("/home/agentos/note.txt", "utf8").trim(); console.log("guest read seed:", JSON.stringify(seed)); console.log("guest read note:", note); -'`); -console.log("guest stdout:", result.stdout.trim()); +'`, { output: { capture: "all" } }); +console.log("guest stdout:", (result.stdout ?? "").trim()); // Read a guest-written file back on the host. const bytes = await agent.filesystem.readFile("/home/agentos/seed.json"); diff --git a/vendor/agentos/examples/js-sdk-overview/src/contexts.ts b/vendor/agentos/examples/js-sdk-overview/src/contexts.ts index 469f9858..d35ed31e 100644 --- a/vendor/agentos/examples/js-sdk-overview/src/contexts.ts +++ b/vendor/agentos/examples/js-sdk-overview/src/contexts.ts @@ -5,13 +5,16 @@ const runtime = await AgentOs.create(); try { await runtime.createContext("analysis"); - await runtime.javascript.execute("const answer = 40", { + await runtime.javascript.execute("globalThis.answer = 40", { contextId: "analysis", }); - const result = await runtime.javascript.evaluate("answer + 2", { - contextId: "analysis", - }); + const result = await runtime.javascript.evaluate( + "globalThis.answer + 2", + { + contextId: "analysis", + }, + ); console.log(result.outcome === "succeeded" ? result.value : result.error); // 42 // Delete an idle context when you are done with it. `contexts.reset()` diff --git a/vendor/agentos/examples/opencode/client.ts b/vendor/agentos/examples/opencode/client.ts index 450b768d..a3751ad5 100644 --- a/vendor/agentos/examples/opencode/client.ts +++ b/vendor/agentos/examples/opencode/client.ts @@ -6,7 +6,7 @@ const client = createClient({ }); const agent = client.vm.getOrCreate("my-agent"); -// ── Quick start ─────────────────────────────────────────────────── +// ── Quickstart ──────────────────────────────────────────────────── async function quickStart() { // docs:start quickstart await agent.sessions.open({ diff --git a/vendor/agentos/examples/pi/README.md b/vendor/agentos/examples/pi/README.md index 2c01c775..21f8556f 100644 --- a/vendor/agentos/examples/pi/README.md +++ b/vendor/agentos/examples/pi/README.md @@ -1,11 +1,11 @@ --- title: "Pi Agent" -description: "Run the Pi coding agent in a session, including quick start and session management." +description: "Run the Pi coding agent in a session, including quickstart and session management." category: "Agents" order: 1 --- -Spin up the Pi coding agent inside a VM, open a session, and send it prompts. Reach for this when you want an end-to-end agent loop — quick start plus the session knobs for skills and MCP servers. +Spin up the Pi coding agent inside a VM, open a session, and send it prompts. Reach for this when you want an end-to-end agent loop from quickstart through the session knobs for skills and MCP servers. ## How it works diff --git a/vendor/agentos/examples/pi/client.ts b/vendor/agentos/examples/pi/client.ts index 9d335597..32eea592 100644 --- a/vendor/agentos/examples/pi/client.ts +++ b/vendor/agentos/examples/pi/client.ts @@ -6,8 +6,8 @@ const client = createClient({ }); const agent = client.vm.getOrCreate("my-agent"); -// ── Quick start ─────────────────────────────────────────────────── -// docs:start quick-start +// ── Quickstart ──────────────────────────────────────────────────── +// docs:start quickstart async function quickStart() { await agent.sessions.open({ agent: "pi", @@ -21,7 +21,7 @@ async function quickStart() { }); console.log(result.message?.content ?? []); } -// docs:end quick-start +// docs:end quickstart // ── Skills ──────────────────────────────────────────────────────── // diff --git a/vendor/agentos/examples/processes/lifecycle.ts b/vendor/agentos/examples/processes/lifecycle.ts index 619b1346..ee7db6f9 100644 --- a/vendor/agentos/examples/processes/lifecycle.ts +++ b/vendor/agentos/examples/processes/lifecycle.ts @@ -8,20 +8,15 @@ const agent = client.vm.getOrCreate("my-agent"); const { pid } = await agent.process.spawn("node", ["/home/agentos/server.js"]); -const processStatus = (process: { - running: boolean; - exitCode?: number | null; -}) => (process.running ? "running" : `exited ${process.exitCode ?? ""}`.trim()); - // List all processes tracked by the VM const processes = await agent.process.list(); for (const p of processes) { - console.log(p.pid, p.command, p.args.join(" "), processStatus(p)); + console.log(p.pid, p.command, p.state); } // Inspect a specific process by pid const info = await agent.process.get(pid); -console.log(processStatus(info), info.exitCode); +console.log(info.pid, info.state); // Graceful stop (SIGTERM) await agent.process.signal(pid, "SIGTERM"); diff --git a/vendor/agentos/examples/processes/visibility.ts b/vendor/agentos/examples/processes/visibility.ts index f60e3b17..f26153e1 100644 --- a/vendor/agentos/examples/processes/visibility.ts +++ b/vendor/agentos/examples/processes/visibility.ts @@ -4,18 +4,15 @@ import type { registry } from "./server"; const client = createClient({ endpoint: "http://localhost:6420" }); const agent = client.vm.getOrCreate("my-agent"); -const processStatus = (process: { running: boolean; exitCode?: number | null }) => - process.running ? "running" : `exited ${process.exitCode ?? ""}`.trim(); - // All processes spawned in the VM const all = await agent.process.list(); for (const p of all) { - console.log(p.pid, p.command, p.args.join(" "), processStatus(p)); + console.log(p.pid, p.command, p.state); } // Inspect a single process by pid const first = all[0]; if (first) { const info = await agent.process.get(first.pid); - console.log(info.pid, info.command, "status:", processStatus(info)); + console.log(info.pid, info.command, "status:", info.state); } diff --git a/vendor/agentos/examples/quickstart/bindings/index.ts b/vendor/agentos/examples/quickstart/bindings/index.ts index 91edbf4b..0617871f 100644 --- a/vendor/agentos/examples/quickstart/bindings/index.ts +++ b/vendor/agentos/examples/quickstart/bindings/index.ts @@ -47,11 +47,15 @@ const vm = await AgentOs.create({ }); try { - const weather = await vm.process.exec("agentos-weather get --city London"); - console.log("Weather:", weather.stdout.trim()); + const weather = await vm.process.exec("agentos-weather get --city London", { + output: { capture: "all" }, + }); + console.log("Weather:", (weather.stdout ?? "").trim()); - const sum = await vm.process.exec("agentos-calc add --a 10 --b 32"); - console.log("Sum:", sum.stdout.trim()); + const sum = await vm.process.exec("agentos-calc add --a 10 --b 32", { + output: { capture: "all" }, + }); + console.log("Sum:", (sum.stdout ?? "").trim()); } finally { await vm.dispose(); } diff --git a/vendor/agentos/examples/quickstart/git/index.ts b/vendor/agentos/examples/quickstart/git/index.ts index 06fcda71..7887a775 100644 --- a/vendor/agentos/examples/quickstart/git/index.ts +++ b/vendor/agentos/examples/quickstart/git/index.ts @@ -51,13 +51,13 @@ const vm = await AgentOs.create({ }); async function run(command: string): Promise { - const result = await vm.process.exec(command); + const result = await vm.process.exec(command, { output: { capture: "all" } }); + const stdout = result.stdout ?? ""; + const stderr = result.stderr ?? ""; if (result.exitCode !== 0) { - throw new Error( - `command failed: ${command}\n${result.stderr || result.stdout}`, - ); + throw new Error(`command failed: ${command}\n${stderr || stdout}`); } - return result; + return { stdout, stderr, exitCode: result.exitCode ?? 0 }; } await run("git init /tmp/origin"); diff --git a/vendor/agentos/examples/quickstart/processes/index.ts b/vendor/agentos/examples/quickstart/processes/index.ts index 9854dc70..35f07128 100644 --- a/vendor/agentos/examples/quickstart/processes/index.ts +++ b/vendor/agentos/examples/quickstart/processes/index.ts @@ -5,27 +5,30 @@ import { AgentOs } from "@rivet-dev/agentos-core"; const vm = await AgentOs.create(); // Run shell commands with exec() -const result = await vm.process.exec("echo 'hello from shell'"); -console.log("exec stdout:", result.stdout.trim()); +// exec() captures nothing unless you ask for it. +const capture = { output: { capture: "all" } } as const; +const result = await vm.process.exec("echo 'hello from shell'", capture); +console.log("exec stdout:", (result.stdout ?? "").trim()); console.log("exec exit code:", result.exitCode); // Shell pipeline -const piped = await vm.process.exec("echo hello | tr a-z A-Z"); -console.log("piped:", piped.stdout.trim()); +const piped = await vm.process.exec("echo hello | tr a-z A-Z", capture); +console.log("piped:", (piped.stdout ?? "").trim()); // grep await vm.filesystem.writeFile( "/tmp/data.txt", "apple\nbanana\ncherry\napricot\n", ); -const grepped = await vm.process.exec("grep ap /tmp/data.txt"); -console.log("grep:", grepped.stdout.trim()); +const grepped = await vm.process.exec("grep ap /tmp/data.txt", capture); +console.log("grep:", (grepped.stdout ?? "").trim()); // sed const sedResult = await vm.process.exec( "echo 'hello world' | sed 's/world/agentOS/'", + capture, ); -console.log("sed:", sedResult.stdout.trim()); +console.log("sed:", (sedResult.stdout ?? "").trim()); // Spawn a Node.js script and wait for it to complete await vm.filesystem.writeFile( diff --git a/vendor/agentos/examples/quickstart/sandbox/index.ts b/vendor/agentos/examples/quickstart/sandbox/index.ts index cb93c6d7..6bcb32a4 100644 --- a/vendor/agentos/examples/quickstart/sandbox/index.ts +++ b/vendor/agentos/examples/quickstart/sandbox/index.ts @@ -39,10 +39,10 @@ try { const runCommandResult = await vm.process.exec( "agentos-sandbox run-command --command echo --args 'hello from Docker sandbox'", ); - console.log("Sandbox command:", runCommandResult.stdout.trim()); + console.log("Sandbox command:", (runCommandResult.stdout ?? "").trim()); const processList = await vm.process.exec("agentos-sandbox list-processes"); - console.log("Sandbox processes:", processList.stdout.trim()); + console.log("Sandbox processes:", (processList.stdout ?? "").trim()); const ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY; if (ANTHROPIC_API_KEY) { diff --git a/vendor/agentos/examples/vercel-eve/package.json b/vendor/agentos/examples/vercel-eve/package.json index 132ceb42..ed752a16 100644 --- a/vendor/agentos/examples/vercel-eve/package.json +++ b/vendor/agentos/examples/vercel-eve/package.json @@ -16,7 +16,7 @@ "@rivet-dev/agentos": "workspace:*", "@rivet-dev/agentos-core": "workspace:*", "@rivet-dev/agentos-eve": "workspace:*", - "@rivet-dev/vercel-world": "2.3.9", + "@rivet-dev/vercel-world": "2.3.10", "@vercel/connect": "0.4.0", "ai": "7.0.26", "eve": "0.27.0", diff --git a/vendor/agentos/examples/workflows/server.ts b/vendor/agentos/examples/workflows/server.ts index 5fd75dea..fb152315 100644 --- a/vendor/agentos/examples/workflows/server.ts +++ b/vendor/agentos/examples/workflows/server.ts @@ -67,7 +67,7 @@ async function runTests( ): Promise { const agent = step.client().vm.getOrCreate("bug-fixer"); const tests = await agent.process.exec("cd /home/agentos/repo && npm test"); - return tests.exitCode; + return tests.exitCode ?? 1; } // docs:end basic