# Robodev Agents: developer guide

Robodev Agents runs **Claude Code, Codex or Cursor** in an isolated sandbox per session, on each user's own subscription or API key, and returns **one normalized event log** whichever agent ran.

- Console: https://agents-staging.robodev.povio.dev
- API base URL: https://agents-staging.robodev.povio.dev/v1 (Bearer auth)
- API reference: https://agents-staging.robodev.povio.dev/docs (OpenAPI: https://agents-staging.robodev.povio.dev/openapi.json)
- MCP server: https://agents-staging.robodev.povio.dev/mcp
- This guide as markdown: https://agents-staging.robodev.povio.dev/docs/guide.md

Objects: a **Workspace** (your personal one, or a team you share), a **Connection** (a subscription or provider API key, owned by whoever signed in and shared into workspaces; one is the default), a **Pool** (an ordered list of connections agents run on), a **Session** (one sandbox, many turns), **Events** (the normalized log), and two optional presets: an **Agent** (instructions, MCP servers, a connection or a pool, and a model per connection) and an **Environment** (sandbox template: image, env vars, size, optionally a base disk saved from a session). A session needs neither: with no `agentId` it runs on your default connection (or the `credentialId` you pass) with that harness's default model and no instructions, and with no `environmentId` in the built-in bare sandbox. Create agents and environments in the console or over MCP (`create_environment`, `create_agent`); runs reference them by id. Connections are added in the console only; `set_default_connection` picks the default.

## Use it from a coding agent (MCP)

The MCP server lets Claude Code, Cursor, Codex or any MCP client set up agents and environments, run them, and read what they did. It speaks Streamable HTTP (protocol 2026-07-28, with 2025-11-25 and earlier for older clients) and signs you in with OAuth 2.1: the client opens the console, you approve, and it gets a token for the MCP server only.

Claude Code:

```bash
claude mcp add --transport http robodev https://agents-staging.robodev.povio.dev/mcp
# then run /mcp in Claude Code and choose "Authenticate"
```

Cursor:

```json
// ~/.cursor/mcp.json
{
  "mcpServers": {
    "robodev": { "url": "https://agents-staging.robodev.povio.dev/mcp" }
  }
}
```

Codex:

```toml
# ~/.codex/config.toml
[mcp_servers.robodev]
url = "https://agents-staging.robodev.povio.dev/mcp"
# then: codex mcp login robodev
```

Headless:

```bash
# No browser (CI, a sandboxed agent): send an API key instead of signing in.
claude mcp add --transport http robodev https://agents-staging.robodev.povio.dev/mcp \
  --header "Authorization: Bearer $ROBODEV_API_KEY"
```

Tools:

- `list_agents` (agents:read): Agents in your workspace (optional presets): id, name, harness, model, effort, and the connection or pool each runs on.
- `list_vaults` (agents:read): Vaults in your workspace (id, name, how many secrets, never values). Pass vaultId to start a session or run with one.
- `list_environments` (agents:read): Your environments: id, name, network mode.
- `list_connections` (agents:read): Subscriptions and API keys in your workspace (ids, labels and owners, never secrets), and which one is the default.
- `list_teams` (agents:read): The workspace this client acts in, and your other workspaces with your role.
- `list_pools` (agents:read): Connection pools: members with plan usage, strategy, threshold, what each picks now, its agents and recent moves.
- `update_pool` (agents:write): Change a pool (admins): name, strategy fill or spread, threshold, handoff carry or pin, or members in order.
- `set_default_connection` (agents:write): Set or clear the default connection: what a session with neither an agent nor a connection runs on.
- `create_environment` (agents:write): New environment: image, env vars, limits. Save a session into it to give it a base disk.
- `update_environment` (agents:write): Change an environment; only the fields you pass change. envVars replaces the whole set; list existing names in keepEnvVars to keep their values.
- `save_session_as_environment` (agents:write): Save an idle session's disk (credentials scrubbed, no memory) as the base of an existing environment or a new one; new sessions there boot from it.
- `list_environment_builds` (agents:read): Saved bases of an environment: status, size, source session, which one is current.
- `delete_environment_build` (agents:write): Delete a saved base and its disk.
- `create_agent` (agents:write): New agent: instructions, a connection or a pool, the model per connection (models, or model/effort for one connection), MCP servers.
- `update_agent` (agents:write): Change an agent; only the fields you pass change. mcpServers replaces the list; give a server auth "bearer" or "headers" without new values to keep its stored secret.
- `run_agent` (agents:run): One-shot run in a fresh sandbox, on an agent, a connection, or the default connection; waits for the answer (optionally checked against an outputSchema).
- `get_run` (agents:read): Result of a run or session that was still going when run_agent returned.
- `start_session` (agents:run): Keep a sandbox for several turns, optionally with a vault (fixed for the session).
- `send_message` (agents:run): Next turn in a session; waits for the answer. Ended and failed sessions continue in a fresh sandbox. Can refresh MCP server tokens.
- `list_sessions` (agents:read): Recent sessions and their status.
- `get_session` (agents:read): One session with all its turns.
- `get_events` (agents:read): The normalized event log (commands, file changes, messages), paged by seq.
- `interrupt_session` (agents:run): Stop the running turn; the sandbox stays.
- `list_secret_requests` (agents:read): Secrets and browser sign-ins agents asked a person for (open ones by default).
- `provide_secret` (agents:run): Answer a secret request: the value goes into the session's vault and the session continues with it.
- `cancel_secret_request` (agents:run): Decline a secret or sign-in request.
- `end_session` (agents:run): End the session. Its disk is archived and send_message restores it; `deleteSandbox: true` deletes the sandbox instead.

OAuth details for client authors: protected resource metadata at https://agents-staging.robodev.povio.dev/.well-known/oauth-protected-resource/mcp, authorization server metadata at https://agents-staging.robodev.povio.dev/.well-known/oauth-authorization-server. Clients identify themselves with a Client ID Metadata Document (an https `client_id`) or, for older clients, dynamic client registration. PKCE (S256) and the `resource` parameter are required. Scopes: `agents:read`, `agents:run`, `agents:write` (create and edit agents and environments). Approved clients can be revoked under **Keys** in the console.

## Quickstart (HTTP / TypeScript)

### 1. Install the client

```bash
bun add @robodev/agents-client   # or: npm install @robodev/agents-client
```

TypeScript, no runtime dependencies, Node 18+ and Bun. Not published to a registry yet: depend on `packages/client` from the robodev-managed-agents repo. Plain HTTP works too (see curl below).

### 2. Create an API key

In the console, open **Keys** and create a key named after your app. It's shown once. A key in your personal workspace acts as you. A key in a team belongs to the team: only admins create and revoke it, everyone in the team sees it, and it keeps working when whoever made it leaves. Revoke a key there and apps using it stop working immediately.

```bash
ROBODEV_URL=https://agents-staging.robodev.povio.dev
ROBODEV_API_KEY=rma_…
ROBODEV_CONSOLE_URL=https://agents-staging.robodev.povio.dev   # optional: errors link to the session log
```

### 3. Run the agent

```ts
import { RobodevAgents, RobodevRunError } from '@robodev/agents-client';

const robodev = new RobodevAgents(); // reads ROBODEV_URL and ROBODEV_API_KEY

type Triage = { kind: 'bug' | 'feature' | 'question'; summary: string };

try {
  const { output } = await robodev.runOutput<Triage>({
    // agentId: optional. Leave out to run on your default connection (or pass credentialId).
    // environmentId: optional. Leave out for the built-in bare sandbox.
    prompt: 'Triage this issue: "Login button does nothing on Safari 17"',
    outputSchema: {
      type: 'object',
      properties: { kind: { enum: ['bug', 'feature', 'question'] }, summary: { type: 'string' } },
      required: ['kind', 'summary'],
    },
  });
  console.log(output.kind, output.summary);
} catch (error) {
  if (error instanceof RobodevRunError) console.error(error.reason, error.message);
  else throw error;
}
```

`runOutput` waits for the run, checks the answer against `outputSchema`, and returns it typed. If the agent fails it throws a `RobodevRunError` with a reason and a link to the session log.

Without `agentId` the run uses your default connection (`GET /v1/credentials/default`; the first connection you add becomes it). Pass `credentialId` to pick another connection. Without `environmentId` it runs in the built-in bare sandbox. With no agent, no `credentialId` and no default connection the API answers 422 `no_default_subscription`.

With Zod:

```ts
import { z } from 'zod';

const Triage = z.object({ kind: z.enum(['bug', 'feature', 'question']), summary: z.string() });

const { output } = await robodev.runOutput({
  prompt,
  outputSchema: z.toJSONSchema(Triage),   // Zod 4
});
const triage = Triage.parse(output);       // fully typed
```

Plain HTTP:

```bash
curl -X POST https://agents-staging.robodev.povio.dev/v1/runs \
  -H "Authorization: Bearer $ROBODEV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Triage this issue: \"Login button does nothing on Safari 17\"",
    "wait": 300
  }'
```

`wait` (seconds, max 600) holds the request until the turn finishes. Without it, poll `GET /v1/runs/:sessionId?wait=60`, stream events, or pass `webhookUrl`.

## Teams and pools

Everything lives in a workspace. A key made in a team acts in that team; a key made in your personal workspace acts there. Other tokens pick one per request with `Robodev-Team: <team id>` (`new RobodevAgents({ team })`, `GET /v1/teams` lists them).

A **pool** lines up connections, mixing Claude Code, Codex, Cursor and API keys. Point an agent at it with `poolId`. Before each turn the pool reads the cached plan usage of its subscriptions (refreshed when older than five minutes) and picks one:

- **fill**: the first connection under the threshold (80, 90, 95 or 100% of the 5-hour and the weekly window). **spread**: the least-used one under it.
- An API key has no plan limit, so a key after the subscriptions is the billed overflow.
- Every subscription past the threshold and no key: the least-used one below its limit. Everything full: the turn waits until the earliest reset.
- A turn never switches mid-way. If the provider rate-limits a turn anyway, that connection is marked full and the turn is retried once on the next one.
- Moving to another coding agent: open sessions continue there with the conversation (`handoff: carry`) or stay on theirs (`pin`).

Models aren't portable, so an agent sets its model and effort **per connection** (`models: [{ credentialId, model, effort, skip }]`). A connection without an entry borrows from another of the same coding agent, else uses its default; `skip` keeps the agent off a connection. Each turn reports the `credentialId`, `harness` and `model` it ran on.

## Multi-turn sessions

For work that takes several steps, keep one sandbox and send messages to it. Sessions with no turn for a while are ended to free their disk (by default after 1 hour, or 24 hours on an environment with a saved base). The log stays. A message to an ended or failed session continues it; when its sandbox is gone it gets a fresh one, and the harness starts a new thread seeded with the earlier turns (files from the old sandbox are not kept).

```ts
// Keep the sandbox and talk to it over several turns.
const session = await robodev.sessions.create({});

await robodev.sessions.send(session.id, { prompt: 'Clone the repo and run the tests', wait: 600 });
const next = await robodev.sessions.send(session.id, { prompt: 'Fix the first failing test', wait: 600 });

// Follow along live: same event shape for Claude Code, Codex and Cursor.
for await (const event of robodev.sessions.stream(session.id)) {
  if (event.item?.kind === 'command') console.log('$', event.item.command?.command);
}

// Ends the session and archives its disk. sessions.terminate deletes the sandbox instead.
await robodev.sessions.end(session.id);
```

## Webhooks

Instead of waiting, pass `webhookUrl` and get a signed POST when the turn finishes. Deliveries retry on errors. The signing secret is on the console's **Keys** page.

```ts
await robodev.run({
  prompt,
  metadata: { ticketId: 'ENG-142' },        // comes back on the webhook
  externalId: 'triage:ENG-142',             // retries return the same run
  webhookUrl: 'https://your-app.com/webhooks/robodev',
});
```

```ts
import { verifyWebhook } from '@robodev/agents-client';

// POST /webhooks/robodev  (read the raw body; don't re-serialize JSON)
const event = verifyWebhook(rawBody, req.headers['x-robodev-signature'], process.env.ROBODEV_WEBHOOK_SECRET!);

if (event.type === 'turn.finished') handle(event.session.metadata, event.turn.output);
if (event.type === 'session.failed') alert(event.error);
```

## The event log

Every agent's output is normalized into the same shape. Stream it (`GET /v1/sessions/:id/stream`, SSE, resumable with `Last-Event-ID`), or page it (`GET /v1/sessions/:id/events?after=<seq>`).

```jsonc
{
  "v": 3, "seq": 42, "ts": "2026-10-02T09:12:03.120Z",
  "sessionId": "…", "turnId": "…", "harness": "codex",
  "type": "item.completed",
  "item": {
    "kind": "command",                 // message · reasoning · command · file_change · tool_call · mcp_call · web_search · plan · subagent
    "status": "completed",
    "command": { "command": "npm test", "output": "…", "exitCode": 0 }
  },
  "usage": { "inputTokens": 3799, "cacheReadTokens": 24064, "outputTokens": 43 }
}
```

`seq` is strictly increasing per session. Usage parts add up: total prompt = `inputTokens + cacheReadTokens + cacheWriteTokens`. The native lines are kept verbatim at `GET /v1/sessions/:id/raw`.

A subagent is one `subagent` item. Read `item.subagent`: it has the same fields whichever agent ran, and leaves out what that agent doesn't report.

```jsonc
{
  "v": 3, "seq": 57, "type": "item.completed",
  "itemId": "toolu_01…", "parentItemId": null,
  "item": {
    "kind": "subagent",
    "status": "completed",                 // in_progress · completed · failed
    "subagent": {                          // the same for every agent; a field it doesn't report is absent
      "type": "Explore",                   // Claude Code / Cursor subagent_type, Codex role
      "name": "counter",                   // Codex
      "description": "Read a.txt",
      "prompt": "Read a.txt and report its contents.",
      "model": "…",
      "result": "a.txt contains: alpha",   // its final report
      "error": "…"                         // with status "failed"
    },
    "tool": { "name": "Agent", "input": { … } }   // the native call, as the agent sent it
  }
}
// Its own steps are items with "parentItemId": "toolu_01…".
```
