An open-source, faster Devin alternative
TypeScript
docs: align agent-sessions API reference with the v3 implementation
Igor Zalutskiccad1e42cd3a
diff --git a/docs/agent-sessions/api-reference.mdx b/docs/agent-sessions/api-reference.mdxindex 65a7197c..7081e4ff 100644--- a/docs/agent-sessions/api-reference.mdx+++ b/docs/agent-sessions/api-reference.mdx@@ -16,17 +16,19 @@ Base URL `https://api.opencomputer.dev/v3`. Management calls authenticate with y| `POST /sessions/:id/cancel` | Cooperatively stop the active turn (no-op if not running). || `GET /sessions/:id/result` | The result helper — `{ last_turn, result? }` (the resolved final event). || `GET /sessions/:id/turns` · `GET …/turns/:turnId` | Per-turn history: timing, usage, error. |-| `POST /sessions/:id/client-tokens` | Mint a client token. Body: `scopes?`, `ttl?`. |+| `POST /sessions/:id/client-tokens` | Mint a client token. Body: `scopes?` (subset of `read`, `steer`), `ttl?` (seconds; clamped to 60–86400). |`agent` is **required** (create a saved [agent](#agents) first); a resolvable Anthropic [credential](#credentials) is also required (`422 no_credential` otherwise). `key` gives get-or-create (one session per key); a request-level `Idempotency-Key` header makes a keyless create retry-safe. `input` is the task — a string or a full [envelope](/agent-sessions/messaging#the-envelope) (structured context rides `input.refs`: `repo`/`branch`/`commit`/`issue`/…). `limits` `{ tokens, turn_seconds, turns }` are **non-monetary** — token budget, per-turn wall-clock, auto-run count; hitting one ends the turn with a matching `last_turn.yield_reason`. Destinations on an idempotent create-replay are ignored — manage them via the [destinations API](#destinations).```Session = { id, status, head, input_cursor,agent_snapshot: { prompt_hash, model, runtime, revision },- credential_id, // resolved + pinned at create- last_turn: { state, yield_reason?, turn_id, started_at, completed_at?, result_event_id?, error? },- usage: { active_seconds, tokens? },- limits: { tokens?, turn_seconds?, turns? }, key?, created_at }+ agent_id, credential_id, // resolved + pinned at create+ last_turn: { id, state, yield_reason?, result_event_id? },+ usage, limits: { tokens?, turn_seconds?, turns? }, key?, created_at }++Turn = { id, state, yield_reason?, started_at?, completed_at?, // from GET …/result and …/turns+ result_event_id?, error?, active_seconds, usage }````yield_reason` (`completed | needs_input | error | budget_exceeded | deadline_exceeded | max_turns | canceled`; `requires_action` is reserved, not emitted yet) is the machine-readable "why the turn ended" — `needs_input` means the agent asked a question; answer it by [steering](#steer).@@ -41,17 +43,18 @@ Session = { id, status, head, input_cursor,| `GET /sessions/:id/events/:eventId/content` | Fetch a blob-backed body (large outputs). || `GET /sessions/:id/messages?after=<seq>&limit=<n>` | User-message history (alias for `level=user` + `type=*.message`). |-`after` resumes from a `seq`; `level` is a **visibility threshold** — `user` returns only user-facing events, `progress` adds work updates, `internal` adds everything (see [levels](/agent-sessions/events#levels)). Switch on [`type`](/agent-sessions/events#event-shape), don't parse prose.+`after` resumes from a `seq`; `level` is a **visibility threshold** — `user` returns only user-facing events, `progress` adds work updates, `internal` adds everything (see [levels](/agent-sessions/events#levels)). Omitting `level` defaults to `internal` (you get everything). Switch on [`type`](/agent-sessions/events#event-shape), don't parse prose.```-Event = { id, seq, ts, session, actor, type, level, body, refs }+Event = { id, seq, ts, session, actor, type, level, body, refs, turn_id?,+ content_ref?, body_truncated?, body_bytes? } // content_ref + body_* present when the body spilled to a blob```## Steer| Method · Path | Purpose || --- | --- |-| `POST /sessions/:id/messages` | Append an input message; wakes the session. Body: `{ text, idempotency_key? }` or `{ envelope }`. `202` → `{ event: { id, seq }, session: { id, status, head } }`. |+| `POST /sessions/:id/messages` | Append an input message; wakes the session. Body: `{ text, idempotency_key? }` or `{ envelope }`. `202` (or `200` on an idempotent replay) → `{ event: { id, seq }, session: { id, status, head } }`. |## Destinations@@ -73,8 +76,10 @@ Event = { id, seq, ts, session, actor, type, level, body, refs }See [Webhooks](/agent-sessions/webhooks#delivery-contract) for the signing and delivery contract.```-Destination = { id, url, level, types, include_raw, enabled, created_at }-Delivery = { id, destination_id, event_id, status, attempts, last_attempt_at, response_code?, error? }+Destination = { id, session, kind, url, level, types, include_raw, enabled,+ has_secret, created_after_seq, created_at, updated_at } // secret never returned — has_secret signals it's set+Delivery = { id, session, destination, event_id, event_seq, status, attempts,+ last_attempt_at, response_code?, error?, created_at, updated_at }```## Agents@@ -91,15 +96,15 @@ Pass `key` **or** `credential` (or neither → org default). The agent's `limits| Method · Path | Purpose || --- | --- |-| `POST /credentials` | Add a provider key (Anthropic). Body: `provider`, `key`, `name?`. Key is write-only. **Required** — sessions run on your key (no platform billing yet). |+| `POST /credentials` | Add a provider key (Anthropic). Body: `provider`, `key`, `name?`, `is_default?`. Key is write-only. **Required** — sessions run on your key (no platform billing yet). || `GET /credentials` · `DELETE /credentials/:id` | List / remove. |-| `PUT /credentials/default` | Set the org default for a provider. Body: `provider`, `credential`. |+| `PUT /credentials/default` | Set the org default to a credential (its provider is derived). Body: `credential`. |```-Credential = { id, provider, name?, last4, created_at }+Credential = { id, provider, name?, last4, is_default, created_at }ClientToken = { token, scopes, expires_at }```## Errors & rate limits-Errors use one envelope: `{ "error": { "type", "message", "code", "param?", "request_id" } }`. Cross-owner resources return `404` (not `403`). Rate and concurrency limits are not enforced at launch; clients should still treat a `429` (with a `Retry-After` header, when present) as a signal to back off and retry, since limits may be introduced later.+Errors use one envelope: `{ "error": { "type", "message" } }`. Cross-owner resources return `404` (not `403`). Rate and concurrency limits are not enforced at launch (a `429` with a `Retry-After` header may be introduced later).diff --git a/docs/agent-sessions/authentication.mdx b/docs/agent-sessions/authentication.mdxindex 1806783b..79182aaa 100644--- a/docs/agent-sessions/authentication.mdx+++ b/docs/agent-sessions/authentication.mdx@@ -55,7 +55,7 @@ curl https://api.opencomputer.dev/v3/credentials \# make it the default for this providercurl -X PUT https://api.opencomputer.dev/v3/credentials/default \-H "Authorization: Bearer $OPENCOMPUTER_API_KEY" \- -d '{ "provider": "anthropic", "credential": "cred_…" }'+ -d '{ "credential": "cred_…" }'```**Resolution** per session: the agent's credential → your org default for the provider. (No platform-billed fallback yet — bring a key.)diff --git a/docs/agent-sessions/events.mdx b/docs/agent-sessions/events.mdxindex fb91d51f..2f8512bd 100644--- a/docs/agent-sessions/events.mdx+++ b/docs/agent-sessions/events.mdx@@ -14,6 +14,7 @@ Every step a session takes is an **event**, appended to the log in order. The lo```- **`id`** — the event's own unique id (`evt_…`). The client idempotency key for steering is separate (deduped per session — see [steering](/agent-sessions/messaging)).+- **`turn_id`** — the turn that produced the event, when applicable; filter a turn's output with `?turn_id=`.- **`type`** — the one discriminator: a namespaced string (`agent.message`, `turn.completed`, …). See below.- **`actor`** — who produced it: `{ id, display?, type: "human" | "agent" | "system" }`.- **`level`** — visibility; see below.diff --git a/docs/agent-sessions/sessions.mdx b/docs/agent-sessions/sessions.mdxindex 1c55c6a7..580e4ace 100644--- a/docs/agent-sessions/sessions.mdx+++ b/docs/agent-sessions/sessions.mdx@@ -25,7 +25,7 @@ A **session** is the durable unit of an [agent](/agent-sessions/agents) at work:| `failed` | The session errored out. || `archived` | Closed; read-only. |-A session also carries `last_turn = { state, yield_reason?, turn_id, started_at, completed_at?, result_event_id?, error? }` and `usage` (`active_seconds`, `tokens` — observed only). The **`yield_reason`** tells you *why* the last turn ended — `completed`, `needs_input` (the agent asked a question — the session is now `awaiting_input`; answer by [steering](/agent-sessions/messaging)), `budget_exceeded` / `deadline_exceeded` / `max_turns` (a [limit](#limits) tripped), or `canceled`.+A session also carries `last_turn = { id, state, yield_reason?, result_event_id? }` and `usage`; the fuller turn record (`started_at`, `completed_at`, `error`, `active_seconds`, `usage`) comes from [`GET …/result`](/agent-sessions/api-reference) and `…/turns`. The **`yield_reason`** tells you *why* the last turn ended — `completed`, `needs_input` (the agent asked a question — the session is now `awaiting_input`; answer by [steering](/agent-sessions/messaging)), `budget_exceeded` / `deadline_exceeded` / `max_turns` (a [limit](#limits) tripped), or `canceled`.## Get the result@@ -34,7 +34,7 @@ Don't sniff prose for "is it done." Await the **`turn.completed`** event (on the```bashcurl https://api.opencomputer.dev/v3/sessions/$ID/result \-H "Authorization: Bearer $OPENCOMPUTER_API_KEY"-# → { "last_turn": { "state": "ok", "yield_reason": "completed", "result_event_id": "evt_…" },+# → { "last_turn": { "id": "trn_…", "state": "ok", "yield_reason": "completed", "result_event_id": "evt_…" },# "result": { "type": "agent.message", "level": "user", "body": { "text": "…" } } }```diff --git a/docs/agent-sessions/webhooks.mdx b/docs/agent-sessions/webhooks.mdxindex 2bee053d..d5c94a08 100644--- a/docs/agent-sessions/webhooks.mdx+++ b/docs/agent-sessions/webhooks.mdx@@ -40,7 +40,7 @@ Every send and its outcome — the data behind a deliveries dashboard.A delivery moves `pending → delivering → delivered`, or `failed` (retrying) → `dead_letter` after the max attempts.```-Delivery = { id, destination_id, event_id, status, attempts, last_attempt_at, response_code?, error? }+Delivery = { id, session, destination, event_id, event_seq, status, attempts, last_attempt_at, response_code?, error?, created_at, updated_at }```<Note>Coming soon: full request/response **body** capture in delivery detail (today records status, attempts, response code, and error); a **test-ping** for a destination; and **org/agent-scoped** destinations that persist across sessions.</Note>